tryharness 0.7.72 → 0.7.73
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/opencode-plugin.js +70 -3
- package/lib/asks.mjs +2 -0
- package/lib/boardCommands.mjs +9 -1
- package/lib/boardProtocol.json +23 -19
- package/lib/bridge.mjs +2 -0
- package/lib/capabilityCheck.mjs +86 -0
- package/lib/computerAddress.mjs +6 -14
- package/lib/coordinator.mjs +207 -26
- package/lib/daemon.mjs +150 -125
- package/lib/dispatchContract.json +1 -31
- package/lib/dispatchTools.js +8 -39
- package/lib/dispatches.mjs +27 -285
- package/lib/goalCommands.mjs +7 -3
- package/lib/herdr.mjs +159 -0
- package/lib/hookDialects.mjs +36 -2
- package/lib/jobAnswers.mjs +3 -0
- package/lib/kanban.mjs +256 -0
- package/lib/localAgentAsk.mjs +20 -29
- package/lib/machineRoutes.mjs +1 -5
- package/lib/manager.mjs +254 -0
- package/lib/mcp-stdio.mjs +58 -39
- package/lib/moves.mjs +365 -0
- package/lib/nudge.mjs +13 -3
- package/lib/ownMachines.mjs +43 -6
- package/lib/places.mjs +29 -2
- package/lib/runAuthority.mjs +2 -14
- package/lib/runBrief.mjs +14 -1
- package/lib/runWorker.mjs +4 -10
- package/lib/runner.mjs +1 -49
- package/lib/sessionControl.mjs +65 -1
- package/lib/steerHook.mjs +124 -0
- package/lib/steerQueue.mjs +176 -0
- package/lib/store.mjs +9 -23
- package/lib/subagentSteering.mjs +363 -0
- package/lib/subagents.mjs +138 -29
- package/lib/swarm.mjs +13 -3
- package/lib/taskCommands.mjs +0 -62
- package/lib/threadActions.mjs +4 -2
- package/lib/threadBriefs.mjs +9 -3
- package/lib/threadRuns.mjs +13 -0
- package/npm-shrinkwrap.json +14 -14
- package/package.json +4 -4
- package/release.json +44 -40
- package/lib/comfyExecution.mjs +0 -545
- package/lib/promptDecider.mjs +0 -471
- package/lib/promptFlow.mjs +0 -597
- package/lib/promptScopes.mjs +0 -670
package/lib/dispatches.mjs
CHANGED
|
@@ -6,7 +6,6 @@ import { limitedCaller, RUN_CALLER } from "./runAuthority.mjs";
|
|
|
6
6
|
import { provenanceFor } from "./provenance.mjs";
|
|
7
7
|
import { stopAgentTask } from "./runner.mjs";
|
|
8
8
|
import { agentBinary, agentCommand } from "./agentBinaries.mjs";
|
|
9
|
-
import { createPromptScopes } from "./promptScopes.mjs";
|
|
10
9
|
|
|
11
10
|
const digest = (value) =>
|
|
12
11
|
createHash("sha256").update(JSON.stringify(value)).digest("hex");
|
|
@@ -59,17 +58,8 @@ export function createDispatches({
|
|
|
59
58
|
notifyBoard,
|
|
60
59
|
inferenceRefusal = () => null,
|
|
61
60
|
projectRoom = () => false,
|
|
62
|
-
standingRules = () => [],
|
|
63
|
-
standingVerdict = () => "no standing permission",
|
|
64
|
-
computers = () => [{ id: machineId(), label: "Home" }],
|
|
65
|
-
privacy = () => true,
|
|
66
|
-
artifact = null,
|
|
67
61
|
}) {
|
|
68
|
-
const snapshot = (
|
|
69
|
-
task,
|
|
70
|
-
scope = null,
|
|
71
|
-
dependsOn = read(store, task.id)?.depends_on
|
|
72
|
-
) => ({
|
|
62
|
+
const snapshot = (task) => ({
|
|
73
63
|
id: task.id,
|
|
74
64
|
origin: task.origin_agent,
|
|
75
65
|
trust: task.trust,
|
|
@@ -79,24 +69,13 @@ export function createDispatches({
|
|
|
79
69
|
parent: task.parent_id,
|
|
80
70
|
target: task.target_agent,
|
|
81
71
|
machine: task.target_machine ?? machineId(),
|
|
82
|
-
checkout:
|
|
83
|
-
scope?.mode === "prompt"
|
|
84
|
-
? {
|
|
85
|
-
...scope.checkout,
|
|
86
|
-
workspace_epoch: scope.workspace_epoch,
|
|
87
|
-
workspace_digest: scope.workspace_digest,
|
|
88
|
-
}
|
|
89
|
-
: checkout(task.run_workspace),
|
|
72
|
+
checkout: checkout(task.run_workspace),
|
|
90
73
|
model: store.meta(`model:${task.id}`),
|
|
91
74
|
review: store.meta(`review:${task.id}`),
|
|
92
75
|
executor: store.meta(`t3-run:${task.id}`),
|
|
93
76
|
executable: fs.realpathSync(
|
|
94
77
|
agentBinary(task.target_agent, agentCommand(task.target_agent))
|
|
95
78
|
),
|
|
96
|
-
...(scope?.mode === "prompt"
|
|
97
|
-
? { capability_ref: scope.capability_ref }
|
|
98
|
-
: {}),
|
|
99
|
-
...(dependsOn ? { depends_on: dependsOn } : {}),
|
|
100
79
|
});
|
|
101
80
|
const scopeKey = (ref) => `dispatch-scope:${ref}`;
|
|
102
81
|
const readScope = (ref) => JSON.parse(store.meta(scopeKey(ref)) || "null");
|
|
@@ -109,17 +88,6 @@ export function createDispatches({
|
|
|
109
88
|
brief: root.brief,
|
|
110
89
|
workspace: root.run_workspace,
|
|
111
90
|
};
|
|
112
|
-
const prompts = createPromptScopes({
|
|
113
|
-
store,
|
|
114
|
-
machineId,
|
|
115
|
-
installedAgents,
|
|
116
|
-
standingRules,
|
|
117
|
-
standingVerdict,
|
|
118
|
-
computers,
|
|
119
|
-
privacy,
|
|
120
|
-
rootSource,
|
|
121
|
-
artifact,
|
|
122
|
-
});
|
|
123
91
|
const scopeRefusal = (scope) => {
|
|
124
92
|
if (!scope || scope.revoked)
|
|
125
93
|
return "The scope was revoked or is unavailable.";
|
|
@@ -133,12 +101,7 @@ export function createDispatches({
|
|
|
133
101
|
)
|
|
134
102
|
return "The owner objective changed or is no longer active.";
|
|
135
103
|
try {
|
|
136
|
-
if (scope.
|
|
137
|
-
const blocked = prompts.check(scope);
|
|
138
|
-
if (blocked) return blocked;
|
|
139
|
-
} else if (
|
|
140
|
-
digest(checkout(scope.checkout.cwd)) !== digest(scope.checkout)
|
|
141
|
-
)
|
|
104
|
+
if (digest(checkout(scope.checkout.cwd)) !== digest(scope.checkout))
|
|
142
105
|
return "The approved scope checkout changed.";
|
|
143
106
|
} catch (error) {
|
|
144
107
|
return error.message;
|
|
@@ -158,16 +121,6 @@ export function createDispatches({
|
|
|
158
121
|
(caller.id === scope.root_id || caller.parent_id === scope.root_id)
|
|
159
122
|
);
|
|
160
123
|
};
|
|
161
|
-
const remaining = (scope) => {
|
|
162
|
-
const own = scope.approved_starts - scope.reserved_starts;
|
|
163
|
-
try {
|
|
164
|
-
return scope.mode === "prompt"
|
|
165
|
-
? Math.min(own, prompts.quota(scope).remaining)
|
|
166
|
-
: own;
|
|
167
|
-
} catch {
|
|
168
|
-
return 0;
|
|
169
|
-
}
|
|
170
|
-
};
|
|
171
124
|
const scopeView = (scope) => ({
|
|
172
125
|
scope_ref: scope.scope_ref,
|
|
173
126
|
root_id: scope.root_id,
|
|
@@ -176,25 +129,13 @@ export function createDispatches({
|
|
|
176
129
|
computer_ref: `computer:${scope.machine}`,
|
|
177
130
|
approved_starts: scope.approved_starts,
|
|
178
131
|
reserved_starts: scope.reserved_starts,
|
|
179
|
-
remaining_starts:
|
|
132
|
+
remaining_starts: scope.approved_starts - scope.reserved_starts,
|
|
180
133
|
templates: scope.templates,
|
|
181
|
-
mode: scope.mode ?? "templates",
|
|
182
|
-
prompt: scope.prompt,
|
|
183
|
-
capability_ref: scope.capability_ref,
|
|
184
|
-
source_workspace: scope.source_workspace,
|
|
185
|
-
outputs:
|
|
186
|
-
scope.outputs &&
|
|
187
|
-
Object.entries(scope.outputs).map(([name, output]) => ({
|
|
188
|
-
name,
|
|
189
|
-
...output,
|
|
190
|
-
})),
|
|
191
134
|
agents: scope.agents,
|
|
192
135
|
proposers: scope.proposers,
|
|
193
136
|
blocked: scopeRefusal(scope),
|
|
194
137
|
capability:
|
|
195
|
-
|
|
196
|
-
? `${scope.capability_ref === "capability:workspace-read@1" ? "read-only source files" : "source reads and private staged file writes"} through the Relay broker; no shell, direct filesystem tools, network, vault or financial effects; at most 100 observed files, 64KB each`
|
|
197
|
-
: "native run permissions; fixed owner templates and checkout; no financial grant",
|
|
138
|
+
"native run permissions; fixed owner templates and checkout; no financial grant",
|
|
198
139
|
});
|
|
199
140
|
const createScope = (request) => {
|
|
200
141
|
const fields = [
|
|
@@ -324,56 +265,34 @@ export function createDispatches({
|
|
|
324
265
|
});
|
|
325
266
|
};
|
|
326
267
|
const propose = (request, agent) => {
|
|
327
|
-
if (!request.proposal || !isRef(request.proposal.scope_ref))
|
|
328
|
-
return { ok: false, code: "proposal_schema" };
|
|
329
|
-
const scope = readScope(request.proposal.scope_ref);
|
|
330
|
-
const dynamic = scope?.mode === "prompt";
|
|
331
268
|
if (
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
"objective",
|
|
336
|
-
"brief",
|
|
337
|
-
"capability_ref",
|
|
338
|
-
]) ||
|
|
339
|
-
request.proposal.capability_ref !== scope.capability_ref ||
|
|
340
|
-
typeof request.proposal.objective !== "string" ||
|
|
341
|
-
!request.proposal.objective.trim() ||
|
|
342
|
-
request.proposal.objective.length > 2000 ||
|
|
343
|
-
typeof request.proposal.brief !== "string" ||
|
|
344
|
-
request.proposal.brief.length > 16000
|
|
345
|
-
: !exactKeys(request.proposal, ["scope_ref", "template_ref"]) ||
|
|
346
|
-
!isRef(request.proposal.template_ref)
|
|
269
|
+
!exactKeys(request.proposal, ["scope_ref", "template_ref"]) ||
|
|
270
|
+
!isRef(request.proposal.scope_ref) ||
|
|
271
|
+
!isRef(request.proposal.template_ref)
|
|
347
272
|
)
|
|
348
273
|
return { ok: false, code: "proposal_schema" };
|
|
274
|
+
const scope = readScope(request.proposal.scope_ref);
|
|
349
275
|
if (!scopeAllowed(scope, agent))
|
|
350
276
|
return { ok: false, code: "scope_forbidden" };
|
|
351
277
|
if (!scopeContext(scope, request))
|
|
352
278
|
return { ok: false, code: "scope_context" };
|
|
353
279
|
const blocked = scopeRefusal(scope);
|
|
354
280
|
if (blocked) return { ok: false, code: "scope_blocked", error: blocked };
|
|
355
|
-
const template =
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
brief: request.proposal.brief,
|
|
359
|
-
}
|
|
360
|
-
: scope.templates.find(
|
|
361
|
-
(t) => t.template_ref === request.proposal.template_ref
|
|
362
|
-
);
|
|
281
|
+
const template = scope.templates.find(
|
|
282
|
+
(t) => t.template_ref === request.proposal.template_ref
|
|
283
|
+
);
|
|
363
284
|
if (!template) return { ok: false, code: "template_reference" };
|
|
364
285
|
return store.dispatchTransaction(() => {
|
|
365
286
|
const current = readScope(scope.scope_ref);
|
|
366
287
|
if (JSON.stringify(current) !== JSON.stringify(scope))
|
|
367
288
|
return { ok: false, code: "scope_changed" };
|
|
368
289
|
// Logical work, not transport request IDs or the agent's wake, owns identity.
|
|
369
|
-
const logical = `dispatch-proposal:${digest([scope.scope_ref,
|
|
290
|
+
const logical = `dispatch-proposal:${digest([scope.scope_ref, template.template_ref])}`;
|
|
370
291
|
const existing = store.meta(logical);
|
|
371
292
|
if (existing)
|
|
372
293
|
return { ok: true, task: store.getTask(existing), existing: true };
|
|
373
294
|
if (scope.reserved_starts >= scope.approved_starts)
|
|
374
295
|
return { ok: false, code: "scope_exhausted" };
|
|
375
|
-
if (dynamic && prompts.quota(scope).remaining < 1)
|
|
376
|
-
return { ok: false, code: "scope_exhausted" };
|
|
377
296
|
const task = store.postTask({
|
|
378
297
|
objective: template.objective,
|
|
379
298
|
brief: template.brief,
|
|
@@ -385,11 +304,7 @@ export function createDispatches({
|
|
|
385
304
|
});
|
|
386
305
|
store.meta(`t3-run:${task.id}`, "0");
|
|
387
306
|
const sources = scope.agents.map((target) => {
|
|
388
|
-
const source = snapshot(
|
|
389
|
-
{ ...task, target_agent: target },
|
|
390
|
-
scope,
|
|
391
|
-
dynamic ? request[RUN_CALLER]?.id : null
|
|
392
|
-
);
|
|
307
|
+
const source = snapshot({ ...task, target_agent: target });
|
|
393
308
|
if (source.executable !== scope.executables[target])
|
|
394
309
|
throw new Error("the approved executable changed");
|
|
395
310
|
return {
|
|
@@ -406,9 +321,6 @@ export function createDispatches({
|
|
|
406
321
|
machine: scope.machine,
|
|
407
322
|
scope_ref: scope.scope_ref,
|
|
408
323
|
template_ref: template.template_ref,
|
|
409
|
-
...(dynamic && request[RUN_CALLER]
|
|
410
|
-
? { depends_on: request[RUN_CALLER].id }
|
|
411
|
-
: {}),
|
|
412
324
|
sources,
|
|
413
325
|
approved_starts: 1,
|
|
414
326
|
state: "offered",
|
|
@@ -434,8 +346,7 @@ export function createDispatches({
|
|
|
434
346
|
if (scope.owner_epoch !== grant.owner_epoch)
|
|
435
347
|
return "The scope approval changed.";
|
|
436
348
|
if (!grant.receipt)
|
|
437
|
-
return scope.reserved_starts >= scope.approved_starts
|
|
438
|
-
(scope.mode === "prompt" && prompts.quota(scope).remaining < 1)
|
|
349
|
+
return scope.reserved_starts >= scope.approved_starts
|
|
439
350
|
? "The shared run limit is exhausted."
|
|
440
351
|
: null;
|
|
441
352
|
}
|
|
@@ -449,8 +360,7 @@ export function createDispatches({
|
|
|
449
360
|
const provider = inferenceRefusal(task.target_agent);
|
|
450
361
|
if (provider) return provider;
|
|
451
362
|
try {
|
|
452
|
-
|
|
453
|
-
if (digest(snapshot(task, scope)) !== grant.source_digest)
|
|
363
|
+
if (digest(snapshot(task)) !== grant.source_digest)
|
|
454
364
|
return "The approved work or checkout changed.";
|
|
455
365
|
} catch (error) {
|
|
456
366
|
return `The approved ${error.message}.`;
|
|
@@ -493,28 +403,9 @@ export function createDispatches({
|
|
|
493
403
|
};
|
|
494
404
|
const view = (id) => {
|
|
495
405
|
const task = store.getTask(id);
|
|
496
|
-
|
|
406
|
+
const grant = read(store, id);
|
|
497
407
|
if (!task || !grant) return { ok: false, code: "missing_grant" };
|
|
498
408
|
const scope = grant.scope_ref ? readScope(grant.scope_ref) : null;
|
|
499
|
-
if (scope?.mode === "prompt" && !grant.receipt && !scopeRefusal(scope)) {
|
|
500
|
-
const sources = grant.sources.map((candidate) => {
|
|
501
|
-
const source = snapshot(
|
|
502
|
-
{ ...task, target_agent: candidate.source.target },
|
|
503
|
-
scope
|
|
504
|
-
);
|
|
505
|
-
return { ...candidate, source, source_digest: digest(source) };
|
|
506
|
-
});
|
|
507
|
-
const next = { ...grant, sources };
|
|
508
|
-
if (
|
|
509
|
-
!store.replaceDispatchGrant({
|
|
510
|
-
id,
|
|
511
|
-
expectedGrant: JSON.stringify(grant),
|
|
512
|
-
nextGrant: JSON.stringify(next),
|
|
513
|
-
})
|
|
514
|
-
)
|
|
515
|
-
return { ok: false, code: "changed" };
|
|
516
|
-
grant = next;
|
|
517
|
-
}
|
|
518
409
|
const blocked =
|
|
519
410
|
refusal(id) ||
|
|
520
411
|
(task.status !== "open" ? `Work is ${task.status}.` : null) ||
|
|
@@ -523,15 +414,7 @@ export function createDispatches({
|
|
|
523
414
|
source: grant.source_digest,
|
|
524
415
|
sources: grant.sources,
|
|
525
416
|
epoch: grant.owner_epoch,
|
|
526
|
-
scope: scope && [
|
|
527
|
-
scope.owner_epoch,
|
|
528
|
-
scope.reserved_starts,
|
|
529
|
-
scope.revoked,
|
|
530
|
-
scope.workspace_epoch,
|
|
531
|
-
scope.mode === "prompt" && !blocked
|
|
532
|
-
? [prompts.quota(scope).key, prompts.quota(scope).expected]
|
|
533
|
-
: null,
|
|
534
|
-
],
|
|
417
|
+
scope: scope && [scope.owner_epoch, scope.reserved_starts, scope.revoked],
|
|
535
418
|
blocked,
|
|
536
419
|
})}`;
|
|
537
420
|
const advisories = store.dispatchAdvisories(id);
|
|
@@ -543,17 +426,11 @@ export function createDispatches({
|
|
|
543
426
|
owner_epoch: grant.owner_epoch,
|
|
544
427
|
basis_ref,
|
|
545
428
|
state: grant.state,
|
|
546
|
-
waiting_on: grant.depends_on
|
|
547
|
-
? {
|
|
548
|
-
task_id: grant.depends_on,
|
|
549
|
-
state: store.getTask(grant.depends_on)?.status ?? "missing",
|
|
550
|
-
}
|
|
551
|
-
: null,
|
|
552
429
|
execution_state: task.status,
|
|
553
430
|
blocked,
|
|
554
431
|
scope_ref: grant.scope_ref ?? null,
|
|
555
432
|
remaining_starts: scope
|
|
556
|
-
?
|
|
433
|
+
? scope.approved_starts - scope.reserved_starts
|
|
557
434
|
: grant.receipt
|
|
558
435
|
? 0
|
|
559
436
|
: grant.approved_starts,
|
|
@@ -579,8 +456,7 @@ export function createDispatches({
|
|
|
579
456
|
role: "make",
|
|
580
457
|
mode: "work",
|
|
581
458
|
capability_ref: scope
|
|
582
|
-
?
|
|
583
|
-
"capability:start-owner-template@1")
|
|
459
|
+
? "capability:start-owner-template@1"
|
|
584
460
|
: "capability:start-exact-owner-run@1",
|
|
585
461
|
cost_bound: 1,
|
|
586
462
|
})),
|
|
@@ -590,18 +466,10 @@ export function createDispatches({
|
|
|
590
466
|
},
|
|
591
467
|
};
|
|
592
468
|
};
|
|
593
|
-
const executionRefusal = (id) => {
|
|
594
|
-
const blocked = refusal(id);
|
|
595
|
-
if (blocked) return blocked;
|
|
596
|
-
const dependency = read(store, id)?.depends_on;
|
|
597
|
-
if (dependency && store.getTask(dependency)?.status !== "done")
|
|
598
|
-
return "The proposing task has not completed successfully; its child stays queued.";
|
|
599
|
-
return null;
|
|
600
|
-
};
|
|
601
469
|
const begin = (id) => {
|
|
602
470
|
const grant = read(store, id);
|
|
603
471
|
if (!grant) return null;
|
|
604
|
-
const blocked =
|
|
472
|
+
const blocked = refusal(id);
|
|
605
473
|
if (blocked) return blocked;
|
|
606
474
|
if (store.getTask(id)?.run_authorized_by !== "dispatch") return null;
|
|
607
475
|
if (grant.state !== "queued" || !grant.receipt)
|
|
@@ -661,7 +529,6 @@ export function createDispatches({
|
|
|
661
529
|
}
|
|
662
530
|
: { ok: false, code: "stale_basis" };
|
|
663
531
|
const offered = view(id).view;
|
|
664
|
-
if (!offered) return { ok: false, code: "changed" };
|
|
665
532
|
if (
|
|
666
533
|
offered.blocked ||
|
|
667
534
|
offered.basis_ref !== decision.basis_ref ||
|
|
@@ -677,9 +544,8 @@ export function createDispatches({
|
|
|
677
544
|
const task = store.getTask(id);
|
|
678
545
|
try {
|
|
679
546
|
if (
|
|
680
|
-
digest(
|
|
681
|
-
|
|
682
|
-
) !== choice.source_digest
|
|
547
|
+
digest(snapshot({ ...task, target_agent: choice.source.target })) !==
|
|
548
|
+
choice.source_digest
|
|
683
549
|
)
|
|
684
550
|
return { ok: false, code: "source_changed" };
|
|
685
551
|
} catch (error) {
|
|
@@ -714,99 +580,12 @@ export function createDispatches({
|
|
|
714
580
|
reserved_starts: scope.reserved_starts + 1,
|
|
715
581
|
})
|
|
716
582
|
: null,
|
|
717
|
-
quota: scope?.mode === "prompt" ? prompts.quota(scope) : null,
|
|
718
583
|
});
|
|
719
584
|
if (!committed) return { ok: false, code: "changed" };
|
|
720
585
|
notifyBoard(store.getTask(id));
|
|
721
586
|
return { ok: true, status: "queued", execution_state: "open", receipt };
|
|
722
587
|
};
|
|
723
|
-
const
|
|
724
|
-
scope?.mode === "prompt" &&
|
|
725
|
-
request[RUN_CALLER]?.dispatchScope === scope.scope_ref &&
|
|
726
|
-
!request[RUN_CALLER]?.review &&
|
|
727
|
-
request.review !== true;
|
|
728
|
-
const openPrompt = async (request) => {
|
|
729
|
-
const result = await prompts.open(request);
|
|
730
|
-
if (!result.ok) return result;
|
|
731
|
-
const scope = result.scope;
|
|
732
|
-
const blocked = scopeRefusal(scope);
|
|
733
|
-
if (blocked)
|
|
734
|
-
return {
|
|
735
|
-
ok: false,
|
|
736
|
-
code: "prompt_blocked",
|
|
737
|
-
error: blocked,
|
|
738
|
-
scope: scopeView(scope),
|
|
739
|
-
};
|
|
740
|
-
const proposed = propose(
|
|
741
|
-
{
|
|
742
|
-
proposal: {
|
|
743
|
-
scope_ref: scope.scope_ref,
|
|
744
|
-
objective: scope.prompt,
|
|
745
|
-
brief:
|
|
746
|
-
"Work toward the original prompt. Use scope_workspace for file access and dispatch_work for necessary follow-up objectives.",
|
|
747
|
-
capability_ref: scope.capability_ref,
|
|
748
|
-
},
|
|
749
|
-
},
|
|
750
|
-
"harness"
|
|
751
|
-
);
|
|
752
|
-
if (!proposed.ok) return proposed;
|
|
753
|
-
const grant = read(store, proposed.task.id);
|
|
754
|
-
if (grant.receipt)
|
|
755
|
-
return {
|
|
756
|
-
ok: true,
|
|
757
|
-
scope: scopeView(readScope(scope.scope_ref)),
|
|
758
|
-
task: store.getTask(proposed.task.id),
|
|
759
|
-
receipt: grant.receipt,
|
|
760
|
-
};
|
|
761
|
-
const offered = view(proposed.task.id).view;
|
|
762
|
-
if (!offered?.assignments.length)
|
|
763
|
-
return {
|
|
764
|
-
ok: false,
|
|
765
|
-
code: "no_eligible_assignment",
|
|
766
|
-
scope: scopeView(scope),
|
|
767
|
-
};
|
|
768
|
-
const admitted = apply(
|
|
769
|
-
proposed.task.id,
|
|
770
|
-
{
|
|
771
|
-
contract_version: 1,
|
|
772
|
-
input_ref: offered.input_ref,
|
|
773
|
-
owner_epoch: offered.owner_epoch,
|
|
774
|
-
basis_ref: offered.basis_ref,
|
|
775
|
-
action: {
|
|
776
|
-
kind: "dispatch",
|
|
777
|
-
work_ref: offered.work_ref,
|
|
778
|
-
assignment_refs: [offered.assignments[0].assignment_ref],
|
|
779
|
-
},
|
|
780
|
-
},
|
|
781
|
-
"user",
|
|
782
|
-
request
|
|
783
|
-
);
|
|
784
|
-
return {
|
|
785
|
-
...admitted,
|
|
786
|
-
scope: scopeView(readScope(scope.scope_ref)),
|
|
787
|
-
task: store.getTask(proposed.task.id),
|
|
788
|
-
};
|
|
789
|
-
};
|
|
790
|
-
const command = (request, { agent, id, machine = null }) => {
|
|
791
|
-
if (request.command === "board.dispatch.prompt") {
|
|
792
|
-
if (agent !== "user" || request[RUN_CALLER] || limited(request))
|
|
793
|
-
return { ok: false, code: "owner_required" };
|
|
794
|
-
if (machine && machine !== machineId())
|
|
795
|
-
return {
|
|
796
|
-
ok: false,
|
|
797
|
-
code: "remote_capability_unavailable",
|
|
798
|
-
requested_machine: `computer:${machine}`,
|
|
799
|
-
};
|
|
800
|
-
return {
|
|
801
|
-
pending: openPrompt(request).catch((error) => ({
|
|
802
|
-
ok: false,
|
|
803
|
-
code: "prompt_source",
|
|
804
|
-
error: error.message,
|
|
805
|
-
})),
|
|
806
|
-
};
|
|
807
|
-
}
|
|
808
|
-
if (request.command === "board.dispatch.workspace")
|
|
809
|
-
return prompts.tool(request);
|
|
588
|
+
const command = (request, { agent, id }) => {
|
|
810
589
|
if (request.command === "board.dispatch.scope.create") {
|
|
811
590
|
if (agent !== "user" || request[RUN_CALLER] || limited(request))
|
|
812
591
|
return { ok: false, code: "owner_required" };
|
|
@@ -856,11 +635,7 @@ export function createDispatches({
|
|
|
856
635
|
return { ok: true };
|
|
857
636
|
}
|
|
858
637
|
if (request.command === "board.dispatch.propose") {
|
|
859
|
-
if (
|
|
860
|
-
limited(request) &&
|
|
861
|
-
!promptCaller(request, readScope(request.proposal?.scope_ref))
|
|
862
|
-
)
|
|
863
|
-
return { ok: false, code: "limited_caller" };
|
|
638
|
+
if (limited(request)) return { ok: false, code: "limited_caller" };
|
|
864
639
|
try {
|
|
865
640
|
const result = propose(request, agent);
|
|
866
641
|
if (result.ok && !result.existing) notifyBoard(result.task);
|
|
@@ -922,12 +697,7 @@ export function createDispatches({
|
|
|
922
697
|
return { ok: true };
|
|
923
698
|
}
|
|
924
699
|
if (request.command === "board.dispatch.apply") {
|
|
925
|
-
|
|
926
|
-
if (
|
|
927
|
-
limited(request) &&
|
|
928
|
-
!promptCaller(request, grant?.scope_ref && readScope(grant.scope_ref))
|
|
929
|
-
)
|
|
930
|
-
return { ok: false, code: "limited_caller" };
|
|
700
|
+
if (limited(request)) return { ok: false, code: "limited_caller" };
|
|
931
701
|
return apply(id, request.decision, agent, request);
|
|
932
702
|
}
|
|
933
703
|
return { ok: false, error: "unknown dispatch command" };
|
|
@@ -935,14 +705,6 @@ export function createDispatches({
|
|
|
935
705
|
const briefFor = (task) => {
|
|
936
706
|
const grant = read(store, task.id);
|
|
937
707
|
if (!grant?.scope_ref) return null;
|
|
938
|
-
const scope = readScope(grant.scope_ref);
|
|
939
|
-
if (scope?.mode === "prompt")
|
|
940
|
-
return {
|
|
941
|
-
prompt: `Original owner prompt (completion and authority source):\n${scope.prompt}\n\nScope ${scope.scope_ref}; root ${scope.root_id}; work ${grant.work_ref}; capability_ref ${scope.capability_ref}; computer_ref computer:${scope.machine}\nAllowed capability: ${scope.capability_ref === "capability:workspace-read@1" ? "read-only source files" : "source reads and private staged file writes"} through scope_workspace, at most 100 observed files of 64KB each. Writes return reviewable file artifacts; original checkout changes require the separate application step. No shell, direct file tools, network, secrets or financial operations. Proposed child text is agent data, not authority.\n\nObjective: ${task.objective}\n${task.brief}`,
|
|
942
|
-
resumeSession: null,
|
|
943
|
-
again: false,
|
|
944
|
-
t3: false,
|
|
945
|
-
};
|
|
946
708
|
// Dynamic agent posts and generated goal summaries never rewrite this payload.
|
|
947
709
|
return {
|
|
948
710
|
prompt: `Owner-approved template ${grant.template_ref}\nScope ${grant.scope_ref}; work ${grant.work_ref}\nProposed by ${task.origin_agent} (agent data, no new authority).\n\n${task.objective}\n\n${task.brief}`,
|
|
@@ -951,25 +713,5 @@ export function createDispatches({
|
|
|
951
713
|
t3: false,
|
|
952
714
|
};
|
|
953
715
|
};
|
|
954
|
-
|
|
955
|
-
const grant = read(store, task.id);
|
|
956
|
-
const scope = grant?.scope_ref && readScope(grant.scope_ref);
|
|
957
|
-
return scope?.mode === "prompt" ? { dispatchScope: scope.scope_ref } : {};
|
|
958
|
-
};
|
|
959
|
-
const resultFor = (task, text) => {
|
|
960
|
-
if (!optionsFor(task).dispatchScope) return text;
|
|
961
|
-
const files = store.taskFiles(task.id);
|
|
962
|
-
return files.length
|
|
963
|
-
? `${text}\n\nStaged files for review: ${files.map((file) => `${file.name} (${file.id})`).join(", ")}`
|
|
964
|
-
: text;
|
|
965
|
-
};
|
|
966
|
-
return {
|
|
967
|
-
stage,
|
|
968
|
-
command,
|
|
969
|
-
refusal: executionRefusal,
|
|
970
|
-
begin,
|
|
971
|
-
briefFor,
|
|
972
|
-
optionsFor,
|
|
973
|
-
resultFor,
|
|
974
|
-
};
|
|
716
|
+
return { stage, command, refusal, begin, briefFor };
|
|
975
717
|
}
|
package/lib/goalCommands.mjs
CHANGED
|
@@ -24,6 +24,7 @@ export function createGoalCommands({
|
|
|
24
24
|
// A post's words as an agent reads them (serverWords.mjs agentText); the person reads every post as written.
|
|
25
25
|
agentText = (post) => post.text,
|
|
26
26
|
heardPerson,
|
|
27
|
+
heardRelayed = () => {},
|
|
27
28
|
inRoom,
|
|
28
29
|
localEvent,
|
|
29
30
|
localReady,
|
|
@@ -230,9 +231,9 @@ export function createGoalCommands({
|
|
|
230
231
|
return { ok: false, error: `${agent} is not on this goal's team` };
|
|
231
232
|
if (goal.status !== "open")
|
|
232
233
|
return { ok: false, error: `the goal is ${goal.status}` };
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
234
|
+
// The person's own words are kept whole; anyone else's post is cut at 20,000 characters.
|
|
235
|
+
const said = String(request.text || "").trim();
|
|
236
|
+
const text = agent === "user" ? said : said.slice(0, 20000);
|
|
236
237
|
if (!text) return { ok: false, error: "a post needs text" };
|
|
237
238
|
// A model named for an agent (`@codex:gpt-6-luna/high`) must be one it lists, or the post is refused saying why.
|
|
238
239
|
const picked = picksIn(store, text, ROOM_AGENTS);
|
|
@@ -321,6 +322,9 @@ export function createGoalCommands({
|
|
|
321
322
|
});
|
|
322
323
|
replaceHeld(goal.id, agent, post);
|
|
323
324
|
if (agent === "user") heardPerson(goal, post);
|
|
325
|
+
// The person's words an agent brings from its own session (post_to_room person_said): asks for the manager,
|
|
326
|
+
// never the person's authority.
|
|
327
|
+
else if (request.personSaid === true) heardRelayed(goal, post);
|
|
324
328
|
if (verdict?.verdict === "flag" || verdict?.verdict === "hold")
|
|
325
329
|
store.meta(`flagged:${post.id}`, String(verdict.score));
|
|
326
330
|
// Shared with guests: the post goes out on each guest's thread, held for the owner unless that thread auto-sends.
|