diff --git a/packages/webui/src/decision-http.mjs b/packages/webui/src/decision-http.mjs
index 98079409c..4d54b1741 100644
--- a/packages/webui/src/decision-http.mjs
+++ b/packages/webui/src/decision-http.mjs
@@ -42,6 +42,18 @@ const BUS_CODES = {
'decision-closed': 'decision-closed', 'decision-stale': 'decision-stale', 'invalid-choice': 'decision-stale',
'invalid-request': 'invalid-request', 'hire-owner-required':'hire-owner-required','right-required':'right-required','decision-expired':'decision-expired','hire-resolution-required':'hire-resolution-required',
};
+// D4 (#1873, P1-2): a hire start the bus definitely refused keeps its own code. The broker can
+// refuse before it records the decision (a model route the catalogue does not offer) or after
+// (a check or apply that fails), so the message never claims that nothing was recorded. A lost
+// or unreadable reply stays outcome-unknown. The model route codes get a next step; any other code is named.
+const HIRE_START_REFUSALS = {
+ 'model-provider-unavailable': [409, 'The model proxy does not offer this model, or its catalogue is not ready. Pick a model it offers, or ask the owner to check Settings > Model proxy. The hire was not applied.'],
+ 'model-catalogue-unavailable': [503, 'The model catalogue could not be read, so this model could not be checked. Check Settings > Model proxy, then try again. The hire was not applied.'],
+ 'model-harness-incompatible': [409, 'This model does not run on the chosen harness. Pick another model or harness. The hire was not applied.'],
+ 'thinking-unsupported': [409, 'The chosen harness does not apply this thinking level. Clear Thinking or pick a level it applies. The hire was not applied.'],
+};
+const OPEN = ['outcome-unknown', 'invalid-response', 'response-too-large', 'outcome-unknown-revoked'];
+const BUS_CODE = /^[a-z][a-z-]{0,63}$/;
const BODY_MAX = 4096;
const TOKEN = /^[a-f0-9]{64}$/;
const DIGEST = /^[a-f0-9]{64}$/;
@@ -136,7 +148,13 @@ export async function decisionHTTP(req, res, { path, decide, session, live, conf
if(step==='templates' && !Array.isArray(result?.templates))return refuse('confirmation-unavailable');
line(step==='start'?'hire=recorded':'templates=read');
return json(res,200,step==='start'?{id:result.id,op:result.op,choice:result.choice}:result);
- } catch(err) {return refuse(busCode(err,step==='start'?'outcome-unknown':'confirmation-unavailable'));}
+ } catch(err) {
+ if(step!=='start' || !(err instanceof BusReadError) || BUS_CODES[err.code] || OPEN.includes(err.code) || !BUS_CODE.test(err.code ?? ''))
+ return refuse(busCode(err,step==='start'?'outcome-unknown':'confirmation-unavailable'));
+ const [status,message]=HIRE_START_REFUSALS[err.code] ?? [409, `The bus refused this hire (${err.code}). Refresh the inbox to see whether a hire decision is open before trying again.`];
+ line(`error=${err.code}`);
+ return json(res,status,{error:err.code,message});
+ }
}
if (step === 'confirmation') {
if (Object.keys(value).some(k=>!['choice','adjust'].includes(k)) || typeof value.choice !== 'string') return refuse('invalid-request');
diff --git a/packages/webui/src/public/bus.css b/packages/webui/src/public/bus.css
index fbd5a703e..0fc519f95 100644
--- a/packages/webui/src/public/bus.css
+++ b/packages/webui/src/public/bus.css
@@ -60,6 +60,10 @@ table.s1-roles td,table.s1-roles th { overflow-wrap:normal; word-break:normal; }
table.s1-roles { min-width: 0; width: 100%; table-layout: fixed; }
table.s1-roles td, table.s1-roles th { overflow-wrap: anywhere; }
}
+/* D4 (#1873): the hire form on the org-mode workspace inbox. */
+html[data-organizations] #hire-start.ws-hire{margin-top:22px}
+html[data-organizations] #hire-start.ws-hire h2{margin:0 0 4px;font-size:16px}
+html[data-organizations] #hire-start.ws-hire select{min-height:40px;padding:6px 10px;border:1px solid var(--border);border-radius:6px;background:var(--surface);color:var(--text);font:inherit;max-width:100%}
/* A4: use the Console's controls for authority proposals and keep grant labels beside their checkboxes. */
#hire-start form,#hire-adjust{max-width:680px}
#hire-start form>label,#hire-adjust>label{display:grid;gap:5px;margin:12px 0;color:var(--text)}
diff --git a/packages/webui/src/public/bus.js b/packages/webui/src/public/bus.js
index 054639e45..e4a871cf0 100644
--- a/packages/webui/src/public/bus.js
+++ b/packages/webui/src/public/bus.js
@@ -427,20 +427,26 @@
route:{harness:$('hire-route-harness').value.trim(),model:$('hire-route-model').value.trim(),...(thinking?{thinking}:{})}};
}
const HIRE_START_LABEL='Record and approve';
- let hireDraft={op:'hire',level:'org'},hireTemplates=[],hireBusy=false,hireStatus='';
+ let hireDraft={op:'hire',level:'org'},hireTemplates=[],hireBusy=false,hireStatus='',hireCode='';
+ // D4 (#1873, P0-1): an org Console shows this form on the workspace inbox. Its posts go to the
+ // current organization's bus (display.js), so the organization is that one and is not editable.
+ const hireOrg=()=>window.MosaicOrg?.id ?? null;
function hireStartHtml() {
if(!canDecide)return '';
- const d=hireDraft,off=hireBusy?' disabled':'';
- const input=(key,label,extra='')=>``;
- return `
Hire, fire or change an agent
`;
}
function paintHireStart() {const e=$('hire-start');if(e)e.outerHTML=hireStartHtml();}
document.addEventListener('input',e=>{const f=e.target.closest?.('[data-hire-field]');if(f)hireDraft[f.dataset.hireField]=f.value;});
@@ -448,15 +454,15 @@
async function hireSubmit(templatesOnly=false) {
if(hireBusy || out() || !canDecide)return;
const d={...hireDraft},template=hireTemplates.find(t=>t.name===d.template);
- if(!templatesOnly && d.op!=='fire' && !template){hireStatus='Read and choose a role template first.';paintHireStart();return;}
+ if(!templatesOnly && d.op!=='fire' && !template){hireStatus='Read and choose a role template first.';hireCode='';paintHireStart();return;}
const thinking=d.thinking?.trim(),hire={op:d.op,level:d.level,name:d.name,reason:d.reason,...(d.level==='project'?{project:d.project}:{}),...(d.op==='fire'?{}:{role:{template:template?.name,sha256:template?.sha256},route:{harness:d.harness,model:d.model,...(thinking?{thinking}:{})}})};
- hireBusy=true;hireStatus='';paintHireStart();
- const {res,json}=await decidePost(`/api/decisions/hire/${templatesOnly?'templates':'start'}`,{business:d.business,...(templatesOnly?{}:{hire})});
+ hireBusy=true;hireStatus='';hireCode='';paintHireStart();
+ const {res,json}=await decidePost(`/api/decisions/hire/${templatesOnly?'templates':'start'}`,{business:hireOrg() ?? d.business,...(templatesOnly?{}:{hire})});
hireBusy=false;
if(res?.type==='opaqueredirect'){signOut();return;}
if(res?.ok && templatesOnly && Array.isArray(json?.templates)){hireTemplates=json.templates;hireStatus=hireTemplates.length?'Templates read.':'No templates available.';}
else if(res?.ok && !templatesOnly && json?.op==='resolved'){hireStatus=`Recorded decision ${json.id}.`;}
- else hireStatus=decideRefusal(res,json,templatesOnly?'confirmation-unavailable':'outcome-unknown').message;
+ else {const r=decideRefusal(res,json,templatesOnly?'confirmation-unavailable':'outcome-unknown');hireStatus=r.message;hireCode=r.code;}
paintHireStart();
}
document.addEventListener('click',e=>{if(e.target.closest?.('[data-hire-load]'))hireSubmit(true);});
@@ -1524,7 +1530,7 @@
if (n === 0 && window.MosaicOrg) return window.MosaicWorkspace.home();
if (a === 'projects' && n === 1 && window.MosaicOrg) return window.MosaicWorkspace.projectsPage(q);
if (a === 'organization' && n === 1 && window.MosaicOrg) return window.MosaicWorkspace.dashboard();
- if (a === 'inbox' && n === 1 && window.MosaicOrg) return window.MosaicWorkspace.inboxPage(q);
+ if (a === 'inbox' && n === 1 && window.MosaicOrg) return configRead.then(() => window.MosaicWorkspace.inboxPage(q, { hire: hireStartHtml() }));
if (a === 'tasks' && n === 1 && window.MosaicOrg) return window.MosaicTasksBoard.view();
if (a === 'inbox' && n === 1) return inboxView(get);
if (a === 'inbox' && n === 2) return SAFE.test(b) ? decisionView(get, b, current) : notFound(`${txt(b)} is not a decision id.`);
diff --git a/packages/webui/src/public/workspace.js b/packages/webui/src/public/workspace.js
index 9ac75976e..5e902af71 100644
--- a/packages/webui/src/public/workspace.js
+++ b/packages/webui/src/public/workspace.js
@@ -663,7 +663,8 @@
}
// ---- inbox across organizations (sample 05) ----
- async function inboxPage(q) {
+ // `opts.hire`: the hire, fire and change form bus.js builds for the current organization (D4, P0-1).
+ async function inboxPage(q, opts = {}) {
const org = listParam(q, 'org', id => ORG_ID.test(id));
const want = String(q?.get?.('d') || '');
let body, all;
@@ -722,7 +723,8 @@
${unread}
${table}
${secH('Answered today', 'kept for 24 hours, then in the trail')}
-