dsh-taskbridge 1.6.0 → 1.7.0
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/CHANGELOG.md +10 -1
- package/README.md +41 -41
- package/THIRD_PARTY_NOTICES.txt +23 -0
- package/codex/dsh-taskbridge.toml +140 -71
- package/docs/INTRODUCTION.md +44 -22
- package/docs/INTRODUCTION.zh.md +32 -26
- package/docs/codex-integration.md +90 -10
- package/docs/contracts-stage-b.md +4 -4
- package/docs/conversation-placement.md +25 -7
- package/docs/plugin-market.md +1 -1
- package/docs/releases/1.7.0.zh.md +11 -0
- package/docs/runtime-compatibility.md +4 -11
- package/docs/silent-wait.md +69 -31
- package/docs/taskbridge-upgrade.md +1 -1
- package/docs/worker-permissions.md +4 -14
- package/docs/workspace-grouping.md +126 -0
- package/lib/client.d.ts +365 -3
- package/lib/client.js +260 -5
- package/locale/en.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +7 -19
- package/src/client/api.js +550 -90
- package/src/client/index.jsx +699 -307
- package/src/client/sidebar.jsx +6 -5
- package/src/client/styles.js +251 -0
- package/src/client/task-cleanup.js +304 -0
- package/src/client/task-records-table.jsx +217 -0
- package/src/client/task-view.js +226 -10
- package/src/client/workspace-groups.js +482 -0
- package/src/client/workspaces-browser.jsx +770 -0
- package/src/codex/agent-ownership.js +270 -0
- package/src/codex/installer.js +525 -35
- package/src/codex/seam.js +5 -0
- package/src/config/defaults.js +63 -17
- package/src/config/settings.js +60 -62
- package/src/config/validate.js +126 -71
- package/src/http/respond.js +8 -0
- package/src/http/user-plane.js +197 -2
- package/src/index.js +50 -42
- package/src/jobs/activity.js +968 -78
- package/src/jobs/engine.js +784 -230
- package/src/jobs/history.js +188 -12
- package/src/jobs/plan-store.js +5 -0
- package/src/jobs/record-cleanup.js +196 -0
- package/src/jobs/task-tree.js +5 -3
- package/src/jobs/title.js +129 -12
- package/src/mcp/server.js +16 -8
- package/src/mcp/wait.js +64 -5
- package/src/runtime/agent-runner.js +53 -15
- package/src/runtime/worker-prompt.js +53 -0
- package/src/workspace/locks.js +288 -167
- package/docs/releases/1.4.0-token-benchmark.zh.md +0 -40
- package/docs/releases/1.4.0.zh.md +0 -54
- package/docs/releases/1.4.1.zh.md +0 -59
- package/docs/releases/1.4.2.zh.md +0 -23
- package/docs/releases/1.5.0-token-benchmark.zh.md +0 -73
- package/docs/releases/1.5.0.zh.md +0 -51
- package/docs/releases/1.5.1.zh.md +0 -70
- package/docs/releases/1.5.2.zh.md +0 -30
- package/docs/releases/1.5.3-test.1.zh.md +0 -28
- package/docs/releases/1.5.3-test.2.zh.md +0 -24
- package/docs/releases/1.5.3.zh.md +0 -33
- package/docs/releases/1.5.4.zh.md +0 -25
- package/src/review/preset.js +0 -868
- package/src/review/prompts.js +0 -145
- package/src/review/reviewer.js +0 -933
package/src/mcp/server.js
CHANGED
|
@@ -346,12 +346,18 @@ export const TOOLS = Object.freeze([
|
|
|
346
346
|
type: 'boolean',
|
|
347
347
|
description: 'OPTIONAL. Your Agent Teams decision for THIS task\u2019s own DSH Session: the same switch the '
|
|
348
348
|
+ 'DSH model menu exposes as \u300cUse Agent Teams\u300d/\u300c\u542f\u7528\u667a\u80fd\u4f53\u56e2\u961f\u534f\u4f5c\u300d. '
|
|
349
|
-
+ '
|
|
350
|
-
+ '
|
|
351
|
-
+ '
|
|
352
|
-
+ '
|
|
353
|
-
+ '
|
|
354
|
-
+ '
|
|
349
|
+
+ 'Send `true` or `false` only when the operator chooses a mode for this task. An explicit value wins over the operator\u2019s '
|
|
350
|
+
+ 'TaskBridge default. Leave it absent, including inside overrides, when the operator leaves it unspecified. A new task follows the operator\u2019s '
|
|
351
|
+
+ '\u300c\u65b0\u4efb\u52a1\u9ed8\u8ba4\u5f00\u542f\u667a\u80fd\u4f53\u534f\u4f5c\u300d setting (off on a fresh install and after an '
|
|
352
|
+
+ 'upgrade), and a follow-up (`continueFromTaskId`) keeps the mode the task it continues ran with \u2014 if that '
|
|
353
|
+
+ 'task recorded none, its Session keeps the existing mode. '
|
|
354
|
+
+ 'The plugin applies it to this run only and never opens a global default. Teams never replaces your '
|
|
355
|
+
+ 'approval or your final review, and this flag never selects a model or an effort \u2014 those come from the '
|
|
356
|
+
+ 'task\u2019s frozen configuration. On a DSH without agent-teams support, an explicit `true` or `false` is '
|
|
357
|
+
+ 'REFUSED (the worker is not prompted and the task records why); only the operator\u2019s implicit off default '
|
|
358
|
+
+ 'still runs, reported as not applied. The task record reports `agentTeams` (the choice that was '
|
|
359
|
+
+ 'applied), `agentTeamsOrigin` (`request`, `continuation` or `settings-default`) and `team` (what DSH '
|
|
360
|
+
+ 'confirmed, or why it could not).',
|
|
355
361
|
},
|
|
356
362
|
continueFromTaskId: {
|
|
357
363
|
type: 'string',
|
|
@@ -1843,8 +1849,10 @@ function skeletonize(task, path, cap, collect, stage = {}) {
|
|
|
1843
1849
|
for (const key of ['taskId', 'state', 'phase', 'route', 'reviewRoute', 'reviewRouteError', 'execution', 'error',
|
|
1844
1850
|
'hostAcceptance', 'selfApproved', 'cancelledBy', 'createdAt', 'endedAt',
|
|
1845
1851
|
// The Agent Teams verdict is four booleans and a short reason: it survives every
|
|
1846
|
-
// bound so a compressed answer still says whether teams are on for this run.
|
|
1847
|
-
|
|
1852
|
+
// bound so a compressed answer still says whether teams are on for this run. The
|
|
1853
|
+
// origin is one closed word, and it is what separates "you asked for this" from
|
|
1854
|
+
// "the operator's new-task default decided it".
|
|
1855
|
+
'agentTeams', 'agentTeamsOrigin', 'team']) {
|
|
1848
1856
|
if (key === 'hostAcceptance') {
|
|
1849
1857
|
// Projected directly from the uncut review block so the generic per-string cap never
|
|
1850
1858
|
// shortens `completionSummary` or `note` before their field-specific rules run.
|
package/src/mcp/wait.js
CHANGED
|
@@ -43,6 +43,7 @@ import {
|
|
|
43
43
|
isQuestionAnswerable,
|
|
44
44
|
} from './server.js';
|
|
45
45
|
import { REPEATED_FAILURE_KIND } from '../jobs/diagnostics.js';
|
|
46
|
+
import { CHECKPOINTS } from '../jobs/activity.js';
|
|
46
47
|
|
|
47
48
|
/** Re-exported so a caller can assert the discriminator without importing the engine. */
|
|
48
49
|
export { REPEATED_FAILURE_KIND };
|
|
@@ -101,6 +102,10 @@ const TASK_FIELDS = Object.freeze([
|
|
|
101
102
|
// are on for this run (`applied`/`enabled`) or why they are not (`reason`) without
|
|
102
103
|
// reading the full result. Four booleans plus a bounded reason — no team content.
|
|
103
104
|
'agentTeams',
|
|
105
|
+
// Where that frozen decision came from (`request` / `continuation` / `settings-default`),
|
|
106
|
+
// so a wait answer distinguishes "you asked for this" from "the operator's setting
|
|
107
|
+
// decided it" without reading the full result.
|
|
108
|
+
'agentTeamsOrigin',
|
|
104
109
|
'team',
|
|
105
110
|
]);
|
|
106
111
|
|
|
@@ -252,10 +257,22 @@ function resolvedTaskState(task, reason) {
|
|
|
252
257
|
|
|
253
258
|
/**
|
|
254
259
|
* The instructions a host reads in a wait answer.
|
|
260
|
+
*
|
|
261
|
+
* The `attention` wording is chosen by `facts.checkpoint` — a scheduled progress
|
|
262
|
+
* check of a still-active run, the repeated-failure reminder, or the delivery
|
|
263
|
+
* interval — because the correct response differs. Every branch keeps the same two
|
|
264
|
+
* invariants: nothing was changed automatically, and the host keeps waiting on the
|
|
265
|
+
* SAME task unless it has a concrete reason to act.
|
|
266
|
+
*
|
|
267
|
+
* The progress branch is worded in terms of what the product actually measures: nothing new
|
|
268
|
+
* was RETURNED to the host. A local self-check read, internal model/tool activity, a heartbeat
|
|
269
|
+
* and the check itself are not results, and the wording must not imply that they are.
|
|
255
270
|
* @param {string} reason - the reported reason.
|
|
256
|
-
* @param {{ resolved?: boolean, taskState?: string | null, kind?: string
|
|
257
|
-
*
|
|
258
|
-
*
|
|
271
|
+
* @param {{ resolved?: boolean, taskState?: string | null, kind?: string, checkpoint?: string | null,
|
|
272
|
+
* progress?: object | null }} [facts] - `resolved`: the reason was settled by
|
|
273
|
+
* {@link resolveInterruption} rather than read verbatim; `taskState`: the state the
|
|
274
|
+
* answer reports, for the `interrupted` wording; `checkpoint`: which `attention`
|
|
275
|
+
* reminder this is; `progress`: its bounded diagnostic.
|
|
259
276
|
* @returns {string} one actionable sentence.
|
|
260
277
|
*/
|
|
261
278
|
function instructionFor(reason, facts = {}) {
|
|
@@ -269,13 +286,31 @@ function instructionFor(reason, facts = {}) {
|
|
|
269
286
|
+ 'permission.requestId (and permission.fingerprint for allow-once), or reject it. The task is still '
|
|
270
287
|
+ 'running and waiting.';
|
|
271
288
|
case 'attention':
|
|
272
|
-
if (facts.failureKind === REPEATED_FAILURE_KIND) {
|
|
289
|
+
if (facts.checkpoint === REPEATED_FAILURE_KIND || facts.failureKind === REPEATED_FAILURE_KIND) {
|
|
273
290
|
return 'The worker has repeated the SAME tool operation and failed the same way several times in a row, '
|
|
274
291
|
+ 'while the task is still running. See `failure` (toolName, failureCode, consecutive). This is a '
|
|
275
292
|
+ 'question, not a verdict: decide deliberately whether to keep waiting, cancel, or follow up. Nothing '
|
|
276
293
|
+ 'was cancelled or changed automatically, and the run is still going.';
|
|
277
294
|
}
|
|
278
|
-
|
|
295
|
+
if (facts.checkpoint === CHECKPOINTS.progress) {
|
|
296
|
+
// The run progress check: the host is asked to look, and the default answer is
|
|
297
|
+
// to keep waiting on the SAME task. It is NOT reported because the task has run
|
|
298
|
+
// for a long time — only because nothing new was DELIVERED back to the host for the
|
|
299
|
+
// interval. A local self-check diagnostic, internal model or tool activity, heartbeats
|
|
300
|
+
// and this check itself are not deliveries.
|
|
301
|
+
const idle = Number.isFinite(facts.progress?.noDeliveryMinutes)
|
|
302
|
+
? `for about ${facts.progress.noDeliveryMinutes} minutes`
|
|
303
|
+
: 'for the configured interval';
|
|
304
|
+
return `Run progress check: nothing new has been returned ${idle} while the task is still `
|
|
305
|
+
+ 'running (see `progress`: `noDeliveryForMs` is how long nothing came back, `activity` is what DSH is '
|
|
306
|
+
+ 'doing right now, and `selfCheckVerdict` is the last local inspection). This is a checkpoint, NOT a '
|
|
307
|
+
+ 'failure and NOT a verdict on the run\'s total duration: a task that keeps delivering results '
|
|
308
|
+
+ 'never produces one, and reading the local self-check is not itself a result. Check whether the work so '
|
|
309
|
+
+ 'far still matches the goal, and then KEEP WAITING on the SAME taskId unless you find a concrete error or '
|
|
310
|
+
+ 'a real drift from the goal. Nothing was cancelled, restarted, resubmitted or re-queued, and this '
|
|
311
|
+
+ 'interval will not be reported again.';
|
|
312
|
+
}
|
|
313
|
+
return 'Nothing has been reported back for the configured no-progress threshold (ten minutes by default) '
|
|
279
314
|
+ 'while the task is still running. The run may be stuck. Check the current tool and idle time; cancel '
|
|
280
315
|
+ 'or follow up deliberately rather than assuming completion.';
|
|
281
316
|
case 'ready':
|
|
@@ -714,6 +749,24 @@ export async function waitForTask(options) {
|
|
|
714
749
|
&& typeof observation?.failure === 'object'
|
|
715
750
|
? observation.failure
|
|
716
751
|
: null;
|
|
752
|
+
// WHICH `attention` reminder this is: the run progress check (`progress`) or the
|
|
753
|
+
// repeated-failure reminder (`failure`). They need different responses, and a host
|
|
754
|
+
// must not have to guess from prose. Derived from the engine's own claim when it
|
|
755
|
+
// published one; otherwise from the `failure` block, so an older engine that predates
|
|
756
|
+
// the field still classifies its reminders correctly.
|
|
757
|
+
//
|
|
758
|
+
// The classification is closed: an engine (or a fixture) that leaked a checkpoint
|
|
759
|
+
// onto a reason that is not `attention` — a terminal outcome, a pending decision —
|
|
760
|
+
// cannot make this answer claim one.
|
|
761
|
+
const checkpoint = reason === 'attention'
|
|
762
|
+
? (typeof observation?.checkpoint === 'string' && CHECKPOINTS[observation.checkpoint] !== undefined
|
|
763
|
+
? observation.checkpoint
|
|
764
|
+
: (failure !== null ? CHECKPOINTS.failure : CHECKPOINTS.progress))
|
|
765
|
+
: null;
|
|
766
|
+
const progress = checkpoint === CHECKPOINTS.progress && observation?.progress !== null
|
|
767
|
+
&& typeof observation?.progress === 'object'
|
|
768
|
+
? observation.progress
|
|
769
|
+
: null;
|
|
717
770
|
const out = {
|
|
718
771
|
taskId: typeof task.taskId === 'string' ? task.taskId : taskId,
|
|
719
772
|
state,
|
|
@@ -731,11 +784,17 @@ export async function waitForTask(options) {
|
|
|
731
784
|
taskState: state,
|
|
732
785
|
kind: facts.kind,
|
|
733
786
|
failureKind: failure?.kind ?? null,
|
|
787
|
+
checkpoint,
|
|
788
|
+
progress,
|
|
734
789
|
}),
|
|
735
790
|
task,
|
|
736
791
|
metrics: metrics(1),
|
|
737
792
|
};
|
|
738
793
|
if (failure !== null) out.failure = failure;
|
|
794
|
+
if (checkpoint !== null) out.checkpoint = checkpoint;
|
|
795
|
+
// The bounded progress diagnostic (elapsed, interval, phase, open tool, silence)
|
|
796
|
+
// — facts the engine already held, no output, diff or review prose.
|
|
797
|
+
if (progress !== null) out.progress = progress;
|
|
739
798
|
// The permission block is carried WHOLE — identity, fingerprint, completeness
|
|
740
799
|
// flags and the redacted operation — because a host that had to read
|
|
741
800
|
// `delegate_result` first would be doing two round trips to answer one question,
|
|
@@ -8,9 +8,8 @@
|
|
|
8
8
|
// acquired afterwards is disposed instead of driven;
|
|
9
9
|
// 2. the agent-preset mount, because an Agent that joins no preset has no tools
|
|
10
10
|
// at all and would report a model it cannot exercise. The identity is the
|
|
11
|
-
// caller's choice: omitted
|
|
12
|
-
//
|
|
13
|
-
// owns and has already verified (the additional review);
|
|
11
|
+
// caller's choice: omitted uses the registry's configured default. An
|
|
12
|
+
// explicit `presetId` names a composition the caller owns and has verified;
|
|
14
13
|
// 3. bounded prompt sizes, so a huge request cannot be smuggled into a turn;
|
|
15
14
|
// 4. an explicit, bounded request budget for the model call (never
|
|
16
15
|
// `maxTokens: 1`, which makes a working provider look broken, and never an
|
|
@@ -460,8 +459,7 @@ export class ExecutionDeadline {
|
|
|
460
459
|
* was created in.
|
|
461
460
|
* * no placement: the historical path, which creates a Session (and Agent) through
|
|
462
461
|
* `agents.create` under a caller-supplied or generated identity. Retained for a
|
|
463
|
-
* caller that owns its own conversation identity
|
|
464
|
-
* composes its own preset and must not join the operator's history.
|
|
462
|
+
* caller that owns its own conversation identity.
|
|
465
463
|
*
|
|
466
464
|
* The runner never disposes an agent it resolved. Disposal would end a conversation
|
|
467
465
|
* a later follow-up must be able to continue, so {@link driveAgent} accepts an
|
|
@@ -872,9 +870,12 @@ export async function driveAgent(deps, request) {
|
|
|
872
870
|
// keyword heuristics) and never opens the global default.
|
|
873
871
|
//
|
|
874
872
|
// A REQUESTED team mode that cannot be applied STOPS the run here, before the prompt:
|
|
875
|
-
// continuing with the Session's old mode would silently do the opposite of what
|
|
876
|
-
//
|
|
877
|
-
|
|
873
|
+
// continuing with the Session's old mode would silently do the opposite of what was
|
|
874
|
+
// asked. Only an ABSENT choice (`null`) keeps the Session as it is — and an absent
|
|
875
|
+
// choice is what a continuation with no provable chain decision now arrives as.
|
|
876
|
+
state.team = await applyTeamSelection(
|
|
877
|
+
deps, handle.agent, request?.agentTeams ?? null, state, { aborted }, request?.agentTeamsImplicit === true,
|
|
878
|
+
);
|
|
878
879
|
if (state.team !== null && typeof state.team.refuseReason === 'string') {
|
|
879
880
|
// A requested mode that could not be applied is a REFUSAL, not a downgrade: the
|
|
880
881
|
// worker is released without ever receiving the prompt, so nothing runs under the
|
|
@@ -1163,9 +1164,7 @@ export async function driveAgent(deps, request) {
|
|
|
1163
1164
|
* `this.ctx.waterfall(scopeTarget(req.agent, req.agent), 'approval/request', req, …)`,
|
|
1164
1165
|
* and `approveEscalation` is the one caller that raises it for a widened sandbox
|
|
1165
1166
|
* request). A listener registered on the AGENT's own context therefore sees only
|
|
1166
|
-
* that Agent's requests
|
|
1167
|
-
* optional read-only reviewer are all outside this scope and are never answered
|
|
1168
|
-
* by this bridge.
|
|
1167
|
+
* that Agent's requests. Other sessions and tasks use their own answerers.
|
|
1169
1168
|
*
|
|
1170
1169
|
* The listener answers with the bridge's closed outcome. It never throws: the
|
|
1171
1170
|
* seam already contains a thrown answerer into `'unavailable'`, and a bridge that
|
|
@@ -1469,6 +1468,8 @@ export async function driveAgent(deps, request) {
|
|
|
1469
1468
|
? null
|
|
1470
1469
|
: {
|
|
1471
1470
|
requested: state.team.requested,
|
|
1471
|
+
// Strictly boolean: was the operator's SETTING behind the request, or a person?
|
|
1472
|
+
implicit: state.team.implicit === true,
|
|
1472
1473
|
supported: state.team.supported,
|
|
1473
1474
|
applied: state.team.applied,
|
|
1474
1475
|
enabled: state.team.enabled,
|
|
@@ -1490,20 +1491,33 @@ export async function driveAgent(deps, request) {
|
|
|
1490
1491
|
* other conversation and no future task inherits it;
|
|
1491
1492
|
* * a REQUESTED mode that cannot be applied stops the run BEFORE the prompt (the
|
|
1492
1493
|
* caller treats `refuseReason` as terminal); an ABSENT choice never does;
|
|
1494
|
+
* * what is requested is the outcome that will be APPLIED — an explicit per-task
|
|
1495
|
+
* choice, an inherited chain choice, or the operator's new-task default — not only
|
|
1496
|
+
* the dispatcher's own field. An older host with no agent-teams service refuses both
|
|
1497
|
+
* an explicit and an inherited choice (somebody asked for exactly that mode), and
|
|
1498
|
+
* proceeds only for the operator's implicit OFF default, which it reports as NOT
|
|
1499
|
+
* APPLIED rather than claiming the Session is off;
|
|
1493
1500
|
* * the wait is BOUNDED by the run itself: it races the caller's own `aborted` latch
|
|
1494
1501
|
* (internal deadline or cancellation), so a service that never resolves cannot hold
|
|
1495
1502
|
* the run past its budget, and a late settle never reaches the prompt.
|
|
1496
1503
|
* @param {object} deps - run dependencies (`policyServices`).
|
|
1497
1504
|
* @param {object} agent - the live root Agent this run drives.
|
|
1498
|
-
* @param {boolean | null} requested - the
|
|
1505
|
+
* @param {boolean | null} requested - the decision to apply, or null for none.
|
|
1499
1506
|
* @param {object} state - the run state carrying the abort latch.
|
|
1500
1507
|
* @param {{ aborted: Promise<string> }} hooks - the run's own abort latch promise.
|
|
1501
|
-
* @
|
|
1508
|
+
* @param {boolean} [implicit] - whether `requested` is the operator's DEFAULT filling an
|
|
1509
|
+
* absent choice rather than something a person decided. Only an implicit OFF may
|
|
1510
|
+
* proceed on a host with no agent-teams service, and even then it is reported as not
|
|
1511
|
+
* applied rather than claimed as "off".
|
|
1512
|
+
* @returns {Promise<object>} `{ requested, implicit, supported, applied, enabled, reason, refuseReason }`
|
|
1502
1513
|
* where `refuseReason` is non-null exactly when the run must NOT proceed.
|
|
1503
1514
|
*/
|
|
1504
|
-
async function applyTeamSelection(deps, agent, requested, state, hooks = {}) {
|
|
1515
|
+
async function applyTeamSelection(deps, agent, requested, state, hooks = {}, implicit = false) {
|
|
1505
1516
|
const base = {
|
|
1506
1517
|
requested: requested === true ? true : requested === false ? false : null,
|
|
1518
|
+
// A strictly-boolean view of the same fact, so a reader never has to interpret a
|
|
1519
|
+
// tri-state to know whether the setting or a person was behind the value.
|
|
1520
|
+
implicit: implicit === true,
|
|
1507
1521
|
supported: false,
|
|
1508
1522
|
applied: false,
|
|
1509
1523
|
enabled: null,
|
|
@@ -1530,6 +1544,21 @@ export async function driveAgent(deps, request) {
|
|
|
1530
1544
|
service = null;
|
|
1531
1545
|
}
|
|
1532
1546
|
if (service === null || typeof service.setEnabled !== 'function') {
|
|
1547
|
+
// No agent-teams service on this host.
|
|
1548
|
+
//
|
|
1549
|
+
// An EXPLICIT `true` or `false`, and an INHERITED chain decision, are both REFUSED:
|
|
1550
|
+
// somebody asked for that exact mode, and proceeding would run under whatever the
|
|
1551
|
+
// Session happens to hold while the record implies otherwise. That is a refusal, not
|
|
1552
|
+
// a downgrade, so the prompt is never delivered.
|
|
1553
|
+
//
|
|
1554
|
+
// The one exception is the operator's DEFAULT filling an absent choice, and only its
|
|
1555
|
+
// OFF direction: that is exactly what a host without the service already does, so an
|
|
1556
|
+
// ordinary older-version dispatch keeps working. It is still reported as NOT
|
|
1557
|
+
// APPLIED — `applied: false`, `enabled: null` — because nothing confirmed it, and
|
|
1558
|
+
// claiming "off" would be asserting a fact this run never observed.
|
|
1559
|
+
if (base.requested === false && base.implicit) {
|
|
1560
|
+
return { ...base, supported: false, applied: false, enabled: null, reason: 'service-absent-default-off' };
|
|
1561
|
+
}
|
|
1533
1562
|
return refuse('agent-teams-unavailable');
|
|
1534
1563
|
}
|
|
1535
1564
|
if (state.abortRequested === true) return refuse('agent-teams-aborted');
|
|
@@ -1573,9 +1602,18 @@ export async function driveAgent(deps, request) {
|
|
|
1573
1602
|
if (state.abortRequested === true) return refuse('agent-teams-aborted');
|
|
1574
1603
|
// Read back from the SERVICE, not from what we just asked for: `isEnabled` resolves
|
|
1575
1604
|
// the runtime root and returns the saved projection, so this is the applied fact.
|
|
1605
|
+
//
|
|
1606
|
+
// STRICT: only a real boolean is a confirmed reading. `isEnabled(agent) === true`
|
|
1607
|
+
// would turn `undefined` (no runtime root, no saved selection, a service that answers
|
|
1608
|
+
// nothing) into `false` and then "confirm" an OFF request nobody observed — the same
|
|
1609
|
+
// class of false evidence this plugin refuses everywhere else. Anything that is not
|
|
1610
|
+
// `true` or `false` reads as UNCONFIRMED instead.
|
|
1576
1611
|
let enabled = null;
|
|
1577
1612
|
try {
|
|
1578
|
-
|
|
1613
|
+
if (typeof service.isEnabled === 'function') {
|
|
1614
|
+
const reported = service.isEnabled(agent);
|
|
1615
|
+
enabled = reported === true ? true : reported === false ? false : null;
|
|
1616
|
+
}
|
|
1579
1617
|
} catch {
|
|
1580
1618
|
enabled = null;
|
|
1581
1619
|
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build the delegation prompt for one task.
|
|
3
|
+
* @param {object} input - `taskId`, `prompt`, `workspacePath`, `isolation`, `diff`, `baseline`.
|
|
4
|
+
* @returns {string} assembled prompt.
|
|
5
|
+
*/
|
|
6
|
+
export function buildWorkerPrompt(input) {
|
|
7
|
+
const lines = [];
|
|
8
|
+
lines.push('You are a delegated implementation worker. Your work will be reviewed by the host.');
|
|
9
|
+
lines.push('');
|
|
10
|
+
lines.push(`Task id: ${input.taskId}`);
|
|
11
|
+
if (typeof input.workspacePath === 'string' && input.workspacePath !== '') {
|
|
12
|
+
lines.push(`Workspace: ${input.workspacePath}`);
|
|
13
|
+
}
|
|
14
|
+
lines.push(`Isolation: ${input.isolation ?? 'shared'}`);
|
|
15
|
+
lines.push('');
|
|
16
|
+
lines.push('## Task');
|
|
17
|
+
lines.push(String(input.prompt ?? '').trim());
|
|
18
|
+
lines.push('');
|
|
19
|
+
lines.push('## Working rules');
|
|
20
|
+
lines.push('- You may modify files only inside the workspace above.');
|
|
21
|
+
lines.push('- Do not commit, push, tag, or rewrite git history.');
|
|
22
|
+
lines.push('- Do not read or print credentials, tokens, or .env contents.');
|
|
23
|
+
lines.push('- Do not install packages from the network unless the task explicitly requires it.');
|
|
24
|
+
lines.push('- Report what you changed and what you could not do. Do not claim checks you did not run.');
|
|
25
|
+
lines.push('');
|
|
26
|
+
lines.push('## Checks and extra permissions');
|
|
27
|
+
lines.push('- Read ordinary files and logs with the normal file tools and the ordinary workspace permission. '
|
|
28
|
+
+ 'Do not ask for elevated access merely to read a log, and do not use a sandbox escape as a substitute for '
|
|
29
|
+
+ 'a file tool.');
|
|
30
|
+
lines.push('- Run tests under the ordinary permission first. If a test fails for a CONCRETE environment reason '
|
|
31
|
+
+ '(a missing module, a denied pipe, an absent binary), keep that error text and report it rather than retrying '
|
|
32
|
+
+ 'the same command with more access.');
|
|
33
|
+
lines.push('- Ask for extra permission only for the one complete, bounded command that genuinely needs it, and say '
|
|
34
|
+
+ 'which error it resolves. A permission granted for one call never covers a later call, and it never widens '
|
|
35
|
+
+ 'the sandbox permanently.');
|
|
36
|
+
lines.push('- Run one combined test command, save its FULL stdout/stderr, its real exit code and a short summary '
|
|
37
|
+
+ '(for example into `.cache/`), and read that saved log afterwards with the file tools. Do not re-run a test '
|
|
38
|
+
+ 'merely to change a filter, a `Select-String` pattern or a `Select-Object -First N`: read the log instead.');
|
|
39
|
+
lines.push('- A missing dependency is a fact to verify, not a reason to re-run the suite: check whether the module '
|
|
40
|
+
+ 'exists before concluding the test failed, and never use extra permission to paper over a module-not-found '
|
|
41
|
+
+ 'error.');
|
|
42
|
+
lines.push('- Fix a failing test before running the suite again. Report the tests you actually ran, their exit '
|
|
43
|
+
+ 'codes and their counts; if the worktree cannot provide a dependency, say so plainly instead of retrying.');
|
|
44
|
+
lines.push('');
|
|
45
|
+
lines.push('## Completion');
|
|
46
|
+
lines.push('When the task is complete, reply with a short summary, the files you changed, and any checks you actually ran with their results.');
|
|
47
|
+
lines.push('You cannot approve your own work; the host decides acceptance.');
|
|
48
|
+
if (input.baseline !== undefined && input.baseline !== null) {
|
|
49
|
+
lines.push('');
|
|
50
|
+
lines.push(`## Starting state: ${input.baseline.dirtyBaseline === true ? 'the workspace already had uncommitted changes' : 'the workspace was clean'}`);
|
|
51
|
+
}
|
|
52
|
+
return lines.join('\n');
|
|
53
|
+
}
|