diff --git a/packages/webui/src/decision-http.mjs b/packages/webui/src/decision-http.mjs
index 98079409c..0255689ca 100644
--- a/packages/webui/src/decision-http.mjs
+++ b/packages/webui/src/decision-http.mjs
@@ -42,6 +42,21 @@ 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, fire or change start the bus definitely refused keeps its own code,
+// but only for codes the broker raises before it records the decision: the proposal checks in
+// hire-decisions.mjs prepare(), which #raiseHire runs before its INSERT. hire.start.console then
+// resolves the decision and applies it in #hireConsole, and those steps can raise other codes (and
+// some of the same generic ones) after the decision exists or is consumed, so every code not listed
+// here stays outcome-unknown. Review P3: an allowlist, not a pass-through of any well-formed code.
+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. Nothing was 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. Nothing was applied.'],
+ 'model-harness-incompatible': [409, 'This model does not run on the chosen harness. Pick another model or harness. Nothing was applied.'],
+ 'thinking-unsupported': [409, 'The chosen harness does not apply this thinking level. Clear Thinking or pick a level it applies. Nothing was applied.'],
+ 'definition-not-hireable': [409, 'This organization does not hire agents from this role template. Pick another template. Nothing was applied.'],
+ 'definition-shared': [409, 'Another agent uses the same role definition, so this change cannot replace it. Nothing was applied.'],
+ 'no-chief-of-staff': [409, 'This organization has no chief of staff, so a hire, fire or change cannot be checked against it. Nothing was applied.'],
+};
const BODY_MAX = 4096;
const TOKEN = /^[a-f0-9]{64}$/;
const DIGEST = /^[a-f0-9]{64}$/;
@@ -136,7 +151,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) || !Object.hasOwn(HIRE_START_REFUSALS,err.code))
+ return refuse(busCode(err,step==='start'?'outcome-unknown':'confirmation-unavailable'));
+ const [status,message]=HIRE_START_REFUSALS[err.code];
+ 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..e2f0f6f0a 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..68e8291c5 100644
--- a/packages/webui/src/public/workspace.js
+++ b/packages/webui/src/public/workspace.js
@@ -663,7 +663,10 @@
}
// ---- inbox across organizations (sample 05) ----
- async function inboxPage(q) {
+ // `opts.hire`: a function that returns the hire, fire and change form bus.js builds for the current
+ // organization (D4, P0-1). It is called after the workspace read so typing or a submit result that
+ // lands during the read is not painted over with an older draft.
+ 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 +725,8 @@
${unread}
${table}
${secH('Answered today', 'kept for 24 hours, then in the trail')}
-