dsh-taskbridge 1.8.0 → 1.9.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 +32 -0
- package/README.md +246 -231
- package/antigravity/agents/dsh-taskbridge.md +17 -14
- package/antigravity/skills/dsh-taskbridge/SKILL.md +40 -27
- package/bin/dsh-delegate-codex-agent.js +9 -4
- package/codex/skills/dsh-taskbridge/SKILL.md +131 -0
- package/codex/skills/dsh-taskbridge/rules-reference-96027c387cb9b7587efa4aa3836235d86db1108068e007dc08196e807ca25e5d.md +114 -0
- package/docs/INTRODUCTION.md +148 -119
- package/docs/INTRODUCTION.zh.md +151 -134
- package/docs/antigravity-integration.md +47 -42
- package/docs/assets/taskbridge-workflow.en.svg +72 -0
- package/docs/assets/taskbridge-workflow.zh.png +0 -0
- package/docs/claude-code.md +18 -18
- package/docs/codex-integration.md +139 -113
- package/docs/conversation-placement.md +7 -6
- package/docs/releases/1.8.0.zh.md +16 -16
- package/docs/releases/1.8.1.zh.md +24 -0
- package/docs/releases/1.9.0.zh.md +31 -0
- package/docs/runtime-compatibility.md +7 -9
- package/docs/silent-wait.md +17 -26
- package/docs/taskbridge-upgrade.md +4 -4
- package/lib/client.d.ts +74 -3
- package/lib/client.js +7 -7
- package/locale/en.json +7 -7
- package/locale/zh.json +7 -7
- package/package.json +11 -4
- package/src/antigravity/installer.js +1099 -1046
- package/src/antigravity/seam.js +142 -142
- package/src/client/api.js +258 -16
- package/src/client/index.jsx +130 -26
- package/src/client/task-cleanup.js +130 -5
- package/src/codex/agent-ownership.js +72 -12
- package/src/codex/installer.js +691 -268
- package/src/config/defaults.js +11 -15
- package/src/http/execution-plane.js +17 -0
- package/src/http/user-plane.js +17 -1
- package/src/index.d.ts +9 -1
- package/src/index.js +86 -64
- package/src/jobs/engine.js +279 -5
- package/src/jobs/history.js +18 -2
- package/src/jobs/plan-store.js +83 -0
- package/src/jobs/record-cleanup.js +714 -195
- package/src/mcp/server.js +271 -38
- package/src/mcp/wait.js +34 -15
- package/src/runtime/agent-runner.js +1 -0
- package/src/runtime/permissions.js +18 -0
- package/src/runtime/session-placement.js +36 -1
- package/src/runtime/worker-prompt.js +14 -9
- package/src/workspace/worktrees.js +155 -1
- package/codex/dsh-taskbridge.toml +0 -170
|
@@ -417,7 +417,13 @@ export async function placeSession(deps, request) {
|
|
|
417
417
|
const execPath = request.path;
|
|
418
418
|
const continueFromTaskId = continuationOf(request?.continueFromTaskId);
|
|
419
419
|
|
|
420
|
-
|
|
420
|
+
// Only a newly created dedicated worktree Workspace is named after a single task's title.
|
|
421
|
+
// A shared-mode run executes directly inside the project's native source Workspace, which is
|
|
422
|
+
// shared across runs and manual conversations and must keep the project's own Workspace name.
|
|
423
|
+
const workspaceTitleForCreate = continueFromTaskId === null && request?.isolation !== 'shared'
|
|
424
|
+
? request?.title
|
|
425
|
+
: null;
|
|
426
|
+
const workspace = await ensureWorkspace(workspaces, execPath, workspaceTitleForCreate, request?.taskId ?? deps.taskId ?? '');
|
|
421
427
|
if (workspace.namingError) deps.logger?.warn?.(`TaskBridge workspace title: ${workspace.namingError}`);
|
|
422
428
|
|
|
423
429
|
if (continueFromTaskId !== null) {
|
|
@@ -935,6 +941,35 @@ export class SessionStore {
|
|
|
935
941
|
return await run;
|
|
936
942
|
}
|
|
937
943
|
|
|
944
|
+
/**
|
|
945
|
+
* Forget the threads recorded for a batch of tasks in one atomic write.
|
|
946
|
+
* @param {Iterable<string>} taskIds - task ids to remove.
|
|
947
|
+
* @returns {Promise<object[]>} the removed records.
|
|
948
|
+
*/
|
|
949
|
+
async forgetMany(taskIds) {
|
|
950
|
+
if (this.disposed) throw new Error('the session map has been disposed');
|
|
951
|
+
const keys = new Set();
|
|
952
|
+
for (const id of Array.isArray(taskIds) || taskIds instanceof Set ? taskIds : []) {
|
|
953
|
+
const key = typeof id === 'string' ? id.trim() : '';
|
|
954
|
+
if (key !== '') keys.add(key);
|
|
955
|
+
}
|
|
956
|
+
if (keys.size === 0) return [];
|
|
957
|
+
const run = this.enqueue(async () => {
|
|
958
|
+
const base = await this.ensureLoaded();
|
|
959
|
+
const removed = [];
|
|
960
|
+
const next = [];
|
|
961
|
+
for (const item of base) {
|
|
962
|
+
if (keys.has(item.taskId)) removed.push({ ...item });
|
|
963
|
+
else next.push(item);
|
|
964
|
+
}
|
|
965
|
+
if (removed.length === 0) return [];
|
|
966
|
+
await this.writeDocument(next);
|
|
967
|
+
this.records = next;
|
|
968
|
+
return removed;
|
|
969
|
+
});
|
|
970
|
+
return await run;
|
|
971
|
+
}
|
|
972
|
+
|
|
938
973
|
/**
|
|
939
974
|
* Wait for queued writes and stop accepting new ones.
|
|
940
975
|
* @returns {Promise<void>} resolves when settled.
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export function buildWorkerPrompt(input) {
|
|
7
7
|
const lines = [];
|
|
8
|
-
lines.push('You are a delegated
|
|
8
|
+
lines.push('You are a delegated worker.');
|
|
9
9
|
lines.push('');
|
|
10
10
|
lines.push(`Task id: ${input.taskId}`);
|
|
11
11
|
if (typeof input.workspacePath === 'string' && input.workspacePath !== '') {
|
|
@@ -25,10 +25,11 @@ export function buildWorkerPrompt(input) {
|
|
|
25
25
|
}
|
|
26
26
|
lines.push('- Do not commit, push, tag, or rewrite git history.');
|
|
27
27
|
lines.push('- Do not read or print credentials, tokens, or .env contents.');
|
|
28
|
-
lines.push('- Do not install packages
|
|
29
|
-
lines.push('- Report what you changed and what you could not do. Do not claim checks you did not run.');
|
|
28
|
+
lines.push('- Do not install packages or make external network requests (`Invoke-WebRequest`, `curl`, `wget`, etc.) unless the task explicitly requires it.');
|
|
30
29
|
lines.push('');
|
|
31
30
|
lines.push('## Checks and extra permissions');
|
|
31
|
+
lines.push('- Always prefer native file/search/edit tools for files, search, and logs. '
|
|
32
|
+
+ 'Use shell commands only for tests, builds, typechecks, and Git inspection.');
|
|
32
33
|
lines.push('- Read ordinary files and logs with the normal file tools and the ordinary workspace permission. '
|
|
33
34
|
+ 'Do not ask for elevated access merely to read a log, and do not use a sandbox escape as a substitute for '
|
|
34
35
|
+ 'a file tool.');
|
|
@@ -38,11 +39,11 @@ export function buildWorkerPrompt(input) {
|
|
|
38
39
|
lines.push('- Ask for extra permission only for the one complete, bounded command that genuinely needs it, and say '
|
|
39
40
|
+ 'which error it resolves. A permission granted for one call never covers a later call, and it never widens '
|
|
40
41
|
+ 'the sandbox permanently.');
|
|
41
|
-
lines.push('- Run one combined test command
|
|
42
|
-
+ '
|
|
43
|
-
+ '
|
|
44
|
-
|
|
45
|
-
+ '
|
|
42
|
+
lines.push('- Run one combined test command (on Windows prefer `node --test` or `npm.cmd test` over `npm.ps1`) and '
|
|
43
|
+
+ 'read its stdout/stderr and real exit code directly. Do NOT create `.cache/` or temporary log files inside the '
|
|
44
|
+
+ 'workspace; if any temporary probe file is ever created, remove those untracked temporary files before finishing '
|
|
45
|
+
+ 'so the delivery diff contains only intended task changes. Do not re-run a test merely to change a filter, a '
|
|
46
|
+
+ '`Select-String` pattern or a `Select-Object -First N`.');
|
|
46
47
|
lines.push('- A missing dependency is a fact to verify, not a reason to re-run the suite: check whether the module '
|
|
47
48
|
+ 'exists before concluding the test failed, and never use extra permission to paper over a module-not-found '
|
|
48
49
|
+ 'error.');
|
|
@@ -50,7 +51,11 @@ export function buildWorkerPrompt(input) {
|
|
|
50
51
|
+ 'codes and their counts; if the worktree cannot provide a dependency, say so plainly instead of retrying.');
|
|
51
52
|
lines.push('');
|
|
52
53
|
lines.push('## Completion');
|
|
53
|
-
lines.push('
|
|
54
|
+
lines.push('- Before delivery, do one self-review. For implementation tasks, review your diff, new files, and test results '
|
|
55
|
+
+ 'for missed requirements, out-of-scope edits, and gaps in required checks. '
|
|
56
|
+
+ 'Fix concrete in-scope issues and rerun affected checks.');
|
|
57
|
+
lines.push('- For verification-only tasks, check findings against the evidence and keep the work read-only.');
|
|
58
|
+
lines.push('- Summarize work, changed files, checks and results, and gaps. Do not claim checks you did not run.');
|
|
54
59
|
lines.push('You cannot approve your own work; the host decides acceptance.');
|
|
55
60
|
if (input.baseline !== undefined && input.baseline !== null) {
|
|
56
61
|
lines.push('');
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
// rather than implied by the word "isolated".
|
|
21
21
|
|
|
22
22
|
import { randomUUID } from 'node:crypto';
|
|
23
|
-
import { lstat, mkdir, realpath } from 'node:fs/promises';
|
|
23
|
+
import { lstat, mkdir, readdir, realpath, rm } from 'node:fs/promises';
|
|
24
24
|
import { basename, dirname, isAbsolute, join, resolve } from 'node:path';
|
|
25
25
|
|
|
26
26
|
import { AUDIT_CODES, AUDIT_LIMITS, AuditError, probeRepository, readRepositoryTopLevel, readStatus } from './audit.js';
|
|
@@ -632,6 +632,160 @@ export class WorktreeManager {
|
|
|
632
632
|
return this.view(record);
|
|
633
633
|
}
|
|
634
634
|
|
|
635
|
+
/**
|
|
636
|
+
* Check whether a candidate path is syntactically a direct managed child directory
|
|
637
|
+
* of {@link WorktreeManager#rootDir} and never the root directory or the source
|
|
638
|
+
* checkout itself.
|
|
639
|
+
* @param {unknown} workspacePath - candidate worktree path.
|
|
640
|
+
* @param {unknown} [sourcePath] - optional source checkout path.
|
|
641
|
+
* @returns {boolean} true when the path is a managed child worktree path.
|
|
642
|
+
*/
|
|
643
|
+
isManagedChildPath(workspacePath, sourcePath = null) {
|
|
644
|
+
if (typeof workspacePath !== 'string' || workspacePath.trim() === '' || !isAbsolute(workspacePath.trim())) {
|
|
645
|
+
return false;
|
|
646
|
+
}
|
|
647
|
+
const resolvedRoot = resolve(this.rootDir);
|
|
648
|
+
const resolvedTarget = resolve(workspacePath.trim());
|
|
649
|
+
const rootKey = normalizeKey(resolvedRoot);
|
|
650
|
+
const targetKey = normalizeKey(resolvedTarget);
|
|
651
|
+
if (targetKey === rootKey) return false;
|
|
652
|
+
if (typeof sourcePath === 'string' && sourcePath.trim() !== '' && isAbsolute(sourcePath.trim())) {
|
|
653
|
+
if (targetKey === normalizeKey(resolve(sourcePath.trim()))) return false;
|
|
654
|
+
}
|
|
655
|
+
if (normalizeKey(dirname(resolvedTarget)) !== rootKey) return false;
|
|
656
|
+
const folderName = basename(resolvedTarget);
|
|
657
|
+
return /^[A-Za-z0-9._-]+-[A-Za-z0-9]{1,12}$/.test(folderName);
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
/**
|
|
661
|
+
* Safely remove one plugin-managed worktree directory for a cleaned isolated task,
|
|
662
|
+
* including after a host restart when the in-memory tree map no longer holds it.
|
|
663
|
+
*
|
|
664
|
+
* Strictly refuses any path that is not a direct child of {@link WorktreeManager#rootDir},
|
|
665
|
+
* any path equal to `sourcePath`, or any symbolic link at the target location.
|
|
666
|
+
* @param {{ taskId?: string, sourcePath?: string | null, workspacePath?: string | null }} request
|
|
667
|
+
* @returns {Promise<{ removed: boolean, workspacePath: string | null, reason?: string }>}
|
|
668
|
+
*/
|
|
669
|
+
async removeManagedTree(request = {}) {
|
|
670
|
+
const rawTarget = typeof request?.workspacePath === 'string' ? request.workspacePath.trim() : '';
|
|
671
|
+
const rawSource = typeof request?.sourcePath === 'string' && request.sourcePath.trim() !== ''
|
|
672
|
+
? request.sourcePath.trim()
|
|
673
|
+
: null;
|
|
674
|
+
if (!this.isManagedChildPath(rawTarget, rawSource)) {
|
|
675
|
+
return { removed: false, workspacePath: null, reason: 'not-managed-worktree' };
|
|
676
|
+
}
|
|
677
|
+
const resolvedTarget = resolve(rawTarget);
|
|
678
|
+
const targetKey = normalizeKey(resolvedTarget);
|
|
679
|
+
const tracked = this.trees.get(targetKey) ?? null;
|
|
680
|
+
if (tracked !== null && tracked.state === WORKTREE_STATES.active) {
|
|
681
|
+
return { removed: false, workspacePath: resolvedTarget, reason: 'tree-active' };
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
const existedOnDisk = await pathExists(resolvedTarget).catch(() => false);
|
|
685
|
+
if (existedOnDisk) {
|
|
686
|
+
const statInfo = await lstat(resolvedTarget).catch(() => null);
|
|
687
|
+
if (statInfo === null || statInfo.isSymbolicLink() || !statInfo.isDirectory()) {
|
|
688
|
+
return { removed: false, workspacePath: resolvedTarget, reason: 'not-regular-directory' };
|
|
689
|
+
}
|
|
690
|
+
const [realRoot, realParent] = await Promise.all([
|
|
691
|
+
realpath(this.rootDir).catch(() => resolve(this.rootDir)),
|
|
692
|
+
realpath(dirname(resolvedTarget)).catch(() => null),
|
|
693
|
+
]);
|
|
694
|
+
if (realParent === null || normalizeKey(realParent) !== normalizeKey(realRoot)) {
|
|
695
|
+
return { removed: false, workspacePath: resolvedTarget, reason: 'parent-mismatch' };
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
const effectiveSource = tracked?.sourcePath ?? (rawSource !== null && isAbsolute(rawSource) && !rawSource.includes('***') ? resolve(rawSource) : null);
|
|
700
|
+
let disposedViaGit = false;
|
|
701
|
+
if (tracked !== null && tracked.state !== WORKTREE_STATES.disposed) {
|
|
702
|
+
try {
|
|
703
|
+
await this.dispose(resolvedTarget, { reviewed: true });
|
|
704
|
+
disposedViaGit = true;
|
|
705
|
+
} catch {
|
|
706
|
+
tracked.state = WORKTREE_STATES.disposed;
|
|
707
|
+
}
|
|
708
|
+
} else if (effectiveSource !== null) {
|
|
709
|
+
try {
|
|
710
|
+
await this.deps.runGit(effectiveSource, ['worktree', 'remove', '--force', resolvedTarget]);
|
|
711
|
+
disposedViaGit = true;
|
|
712
|
+
} catch {
|
|
713
|
+
// Fallback to direct directory removal inside rootDir below.
|
|
714
|
+
}
|
|
715
|
+
try {
|
|
716
|
+
await this.deps.runGit(effectiveSource, ['worktree', 'prune']);
|
|
717
|
+
} catch {
|
|
718
|
+
// Best-effort git worktree administrative prune.
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
if (await pathExists(resolvedTarget).catch(() => false)) {
|
|
723
|
+
await rm(resolvedTarget, { recursive: true, force: true }).catch(() => {});
|
|
724
|
+
if (effectiveSource !== null) {
|
|
725
|
+
await this.deps.runGit(effectiveSource, ['worktree', 'prune']).catch(() => {});
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
const stillExists = await pathExists(resolvedTarget).catch(() => false);
|
|
730
|
+
if (stillExists) {
|
|
731
|
+
return { removed: false, workspacePath: resolvedTarget, reason: 'remove-failed' };
|
|
732
|
+
}
|
|
733
|
+
if (tracked !== null) {
|
|
734
|
+
tracked.state = WORKTREE_STATES.disposed;
|
|
735
|
+
}
|
|
736
|
+
if (!existedOnDisk && !disposedViaGit) {
|
|
737
|
+
return { removed: false, workspacePath: resolvedTarget, reason: 'already-absent' };
|
|
738
|
+
}
|
|
739
|
+
return { removed: true, workspacePath: resolvedTarget };
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
/**
|
|
743
|
+
* Sweep orphan managed worktree directories under {@link WorktreeManager#rootDir}
|
|
744
|
+
* that are no longer referenced by any live or retained historical task.
|
|
745
|
+
* @param {{ activePaths?: string[], sourcePaths?: string[] }} [options]
|
|
746
|
+
* @returns {Promise<{ removedWorktreePaths: string[] }>}
|
|
747
|
+
*/
|
|
748
|
+
async sweepOrphanTrees(options = {}) {
|
|
749
|
+
const activeKeys = new Set();
|
|
750
|
+
for (const candidate of Array.isArray(options?.activePaths) ? options.activePaths : []) {
|
|
751
|
+
if (typeof candidate === 'string' && candidate.trim() !== '' && isAbsolute(candidate.trim())) {
|
|
752
|
+
activeKeys.add(normalizeKey(resolve(candidate.trim())));
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
for (const [key, record] of this.trees.entries()) {
|
|
756
|
+
if (record.state === WORKTREE_STATES.active) activeKeys.add(key);
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
let entries = [];
|
|
760
|
+
try {
|
|
761
|
+
entries = await readdir(this.rootDir, { withFileTypes: true });
|
|
762
|
+
} catch (error) {
|
|
763
|
+
if (error?.code === 'ENOENT') return { removedWorktreePaths: [] };
|
|
764
|
+
throw error;
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
const removedWorktreePaths = [];
|
|
768
|
+
for (const entry of entries) {
|
|
769
|
+
if (!entry.isDirectory() || entry.isSymbolicLink()) continue;
|
|
770
|
+
if (!/^[A-Za-z0-9._-]+-[A-Za-z0-9]{1,12}$/.test(entry.name)) continue;
|
|
771
|
+
const fullPath = resolve(join(this.rootDir, entry.name));
|
|
772
|
+
if (activeKeys.has(normalizeKey(fullPath))) continue;
|
|
773
|
+
const outcome = await this.removeManagedTree({ workspacePath: fullPath });
|
|
774
|
+
if (outcome.removed) removedWorktreePaths.push(fullPath);
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
const uniqueSources = new Set(
|
|
778
|
+
(Array.isArray(options?.sourcePaths) ? options.sourcePaths : [])
|
|
779
|
+
.filter((p) => typeof p === 'string' && p.trim() !== '' && isAbsolute(p.trim()) && !p.includes('***'))
|
|
780
|
+
.map((p) => resolve(p.trim())),
|
|
781
|
+
);
|
|
782
|
+
for (const source of uniqueSources) {
|
|
783
|
+
await this.deps.runGit(source, ['worktree', 'prune']).catch(() => {});
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
return { removedWorktreePaths };
|
|
787
|
+
}
|
|
788
|
+
|
|
635
789
|
/**
|
|
636
790
|
* Resolve a managed record or refuse.
|
|
637
791
|
* @param {string} workspacePath - tree path.
|
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
# dsh-taskbridge Codex companion — managed by the DSH TaskBridge plugin settings page.
|
|
2
|
-
# Editing this file turns it into an operator-owned file: the plugin then never
|
|
3
|
-
# overwrites or removes it, and reports it as "modified" instead.
|
|
4
|
-
version = "1.8.0"
|
|
5
|
-
|
|
6
|
-
name = "dsh-taskbridge"
|
|
7
|
-
description = "Dispatch an explicitly assigned implementation task to DSH through the dsh-taskbridge MCP tools, then return evidence for Codex review."
|
|
8
|
-
|
|
9
|
-
developer_instructions = """
|
|
10
|
-
You are a dispatcher to DSH, not an implementer. Codex plans and reviews; DSH TaskBridge
|
|
11
|
-
executes as a black-box service (routing, isolation, workspace and session management stay
|
|
12
|
-
inside the plugin). Do not edit files or implement anything locally.
|
|
13
|
-
|
|
14
|
-
ACTIVATION (check this before anything else)
|
|
15
|
-
1. Dispatch only when the parent request explicitly selects this agent or asks to delegate
|
|
16
|
-
this implementation task to DSH (e.g. `@dsh-taskbridge` or the agent picker).
|
|
17
|
-
2. Casual mention of DSH, DeepSeek, dsh-taskbridge or delegation — or a question about
|
|
18
|
-
planning, review, status, logs or settings — is NOT a dispatch request. Answer in Codex.
|
|
19
|
-
3. If assignment is ambiguous, ask one short clarifying question instead of dispatching.
|
|
20
|
-
|
|
21
|
-
P0: COMMANDER-OWNED PLANNING AND WORK PACKETS
|
|
22
|
-
1. Codex owns the plan, scope, interface decisions and acceptance. Inspect relevant code,
|
|
23
|
-
tests and prior evidence before dispatching. Choose the next bounded packet by cohesion
|
|
24
|
-
and verification boundary rather than handing over an entire multi-stage backlog at once.
|
|
25
|
-
2. Before dispatch, tell the operator which packet is next, why, and the chosen approach
|
|
26
|
-
(including any code/library reuse). Put that concrete implementation brief — outcome,
|
|
27
|
-
starting facts, ordered steps, allowed changes and acceptance checks — into
|
|
28
|
-
`delegate_submit.prompt`. DSH handles routine implementation details within the packet
|
|
29
|
-
and reports evidence if a premise conflicts with the repository.
|
|
30
|
-
3. For a multi-stage goal, record the breakdown with `delegate_plan` (`action: "create"`)
|
|
31
|
-
before dispatching subtasks, and link each independent subtask via `planNodeId` (or
|
|
32
|
-
`parentNodeId`) on `delegate_submit`. Record overall goal completion with `delegate_plan`
|
|
33
|
-
(`action: "review"`) after required subtasks pass review. A single cohesive task can be
|
|
34
|
-
submitted directly without a plan tree.
|
|
35
|
-
4. Parallel packets require independent work, non-conflicting ownership and permission under
|
|
36
|
-
the request and repository AGENTS.md. Never expand scope or let a verification-only packet
|
|
37
|
-
modify code or rules.
|
|
38
|
-
|
|
39
|
-
DISPATCH CONTRACT
|
|
40
|
-
1. PREFLIGHT (new task chains only). Call `delegate_status` first, then `delegate_preflight`
|
|
41
|
-
with the exact authorized source `workspacePath`. If the switch is off or a prerequisite
|
|
42
|
-
is missing, report the reason and pause. Never open the switch yourself or fall back to
|
|
43
|
-
another execution route.
|
|
44
|
-
- Reuse verified preflight facts for a same-chain `continueFromTaskId` continuation unless
|
|
45
|
-
the source changed or the engine reports a mismatch.
|
|
46
|
-
- `isolation: "worktree"`: omit `overrides` so the configured isolation and matching project
|
|
47
|
-
override apply.
|
|
48
|
-
- `isolation: "block"` with `decisionRequired: true` (`PREFLIGHT_DIRTY_NEEDS_DECISION`):
|
|
49
|
-
Do NOT downgrade to shared isolation silently. Inspect the reported changed paths; when
|
|
50
|
-
in-place execution is safe, state the reason, call `delegate_preflight` again with
|
|
51
|
-
`allowShared: true`. For a `shared` decision, pass only `overrides = { isolation = "shared" }`.
|
|
52
|
-
If risk or ownership is unclear, ask one focused question.
|
|
53
|
-
- Any other `isolation: "block"` (e.g. `PREFLIGHT_NOT_A_REPOSITORY_ROOT`): stop and report
|
|
54
|
-
the reason code (naming any reported repository root when relevant).
|
|
55
|
-
2. SUBMIT. Set `title` to a short work description in the operator's language. Pass the
|
|
56
|
-
authorized source `workspacePath` and the P0 implementation brief in `prompt`.
|
|
57
|
-
- Never override the configured provider, model or reasoning effort, and never send
|
|
58
|
-
`overrides.timeoutSeconds` unless the operator explicitly asked for a cap (normal runs
|
|
59
|
-
have no default total execution timeout).
|
|
60
|
-
- `agentTeams`: pass `true` or `false` ONLY when the user explicitly stated a choice for
|
|
61
|
-
this dispatch; otherwise omit it (new tasks follow the TaskBridge default; continuations
|
|
62
|
-
inherit the chain's choice, and if that task recorded no choice at all, the plugin
|
|
63
|
-
writes nothing so the Session keeps the mode it already has). If DSH lacks agent-teams
|
|
64
|
-
support, an explicit `true` OR an explicit `false` stops BEFORE the prompt; report the refusal
|
|
65
|
-
without retrying a different value. An implicit off default reports
|
|
66
|
-
`applied: false` (NOT "off"). Do not describe that run as "teams turned off". One outer task = one
|
|
67
|
-
concurrency slot.
|
|
68
|
-
- Task threads: every submission starts a NEW DSH task conversation by default. Pass
|
|
69
|
-
`continueFromTaskId` ONLY when this submission is a follow-up to that same task (use the
|
|
70
|
-
latest prior task id with the original source `workspacePath`; the plugin resolves the
|
|
71
|
-
original managed tree and session internally). Omit `continueFromTaskId` entirely for an
|
|
72
|
-
unrelated task; if a continuation is refused, report it and do not retry as a new task.
|
|
73
|
-
3. RECEIPT CHECK. From `delegate_submit` and the first actionable `delegate_wait` or
|
|
74
|
-
`delegate_result` receipt (never poll a live run for it), verify source path, actual
|
|
75
|
-
execution directory, isolation, DSH workspace/session identity (confirming continuations
|
|
76
|
-
reuse the parent session) and confirmed `agentTeams` / `agentTeamsOrigin` / `team.applied` /
|
|
77
|
-
`team.enabled` state. Pause dependent dispatches and report any mismatch before proceeding.
|
|
78
|
-
|
|
79
|
-
WAIT & EVENTS
|
|
80
|
-
1. Call `delegate_wait({ taskId })` with NO `waitSeconds` argument (default 3600s; you cannot
|
|
81
|
-
wait longer than that, so do not try to "stay longer" by raising it; a shorter explicit
|
|
82
|
-
`waitSeconds` is only for a one-off diagnostic the operator explicitly asked for). Repeat
|
|
83
|
-
on the same `taskId` until a terminal or actionable event arrives. Do NOT poll
|
|
84
|
-
`delegate_result` or `delegate_status` in a loop — the internal observation cadence
|
|
85
|
-
belongs to the tool, not to you.
|
|
86
|
-
2. FIVE DIFFERENT THINGS, never conflated:
|
|
87
|
-
- `wait-limit` — THIS call's own wait budget ran out (`actionable: false` and `terminal: false`):
|
|
88
|
-
call `delegate_wait` on the same `taskId` immediately.
|
|
89
|
-
- An OUTER limit — your client handed the call back on its own CLIENT-SIDE tool timeout.
|
|
90
|
-
It does not prove the execution stopped. Continue the same exec cell / call
|
|
91
|
-
`delegate_wait` on the same `taskId` using the longest yield your client accepts (e.g.
|
|
92
|
-
1200000 ms, not 1 minute); never submit a duplicate, restart or cancel a task because a
|
|
93
|
-
client timeout fired, never promise the plugin will wake you or achieve zero wake-ups
|
|
94
|
-
across clients, and never claim the plugin will notify you in the background.
|
|
95
|
-
- `attention` — the run progress check (`checkpoint: "progress"`): nothing new has been
|
|
96
|
-
delivered back to the host for the operator-configured progress-check interval in DSH
|
|
97
|
-
settings (adjustable or disableable; DSH also runs its configured local self-check once
|
|
98
|
-
after execution starts). Internal model or tool activity, heartbeats and the local
|
|
99
|
-
self-check do NOT reset the delivery clock, so an active long run can still trigger this
|
|
100
|
-
check-in. It is NOT reported because the task has been running a long time or failed: read
|
|
101
|
-
`progress` (`noDeliveryForMs`, `activity`, `selfCheckVerdict`) and
|
|
102
|
-
KEEP WAITING on the SAME taskId unless you
|
|
103
|
-
find a concrete error or a real drift from the goal.
|
|
104
|
-
- A repeated-tool-failure reminder (`attention` with `checkpoint: "failure"`, `eventId`):
|
|
105
|
-
same operation failed repeatedly. Decide deliberately (wait, cancel or follow up), then
|
|
106
|
-
confirm via `delegate_wait({ taskId, ackFailureEventId })`. An ordinary single failing
|
|
107
|
-
test inside the worker is the WORKER's job to diagnose and fix.
|
|
108
|
-
- There is NO default total execution timeout (`JOB_TIMEOUT` only happens with an explicit cap).
|
|
109
|
-
3. HANDLE EACH WAIT REASON:
|
|
110
|
-
- `heartbeat`: nothing to report — call `delegate_wait` on the same `taskId`.
|
|
111
|
-
- `permission`: inspect the complete concrete operation, paths and bounds
|
|
112
|
-
(`argumentsComplete: true`, `completeness: "complete"`, `allowBlocked: null`). Quote the
|
|
113
|
-
exact `fingerprint` and call `delegate_permission_decide` (`allow-once` or `reject`, short
|
|
114
|
-
`reason`, and `waitAfterDecision: true` when supported; otherwise decide first and then
|
|
115
|
-
call `delegate_wait` on the SAME task). Read `decisionReceipt`: `applied: true` is claimed
|
|
116
|
-
ONLY when the harness confirmed the SAME task, request and operation — if `waitError` is
|
|
117
|
-
also returned, which means the DECISION SUCCEEDED and only the FOLLOWING WAIT failed,
|
|
118
|
-
never send the decision again, never cancel or reassign the task, and resume with
|
|
119
|
-
`delegate_wait`. If `applied: null` with `confirmation: "unknown"` means nothing was
|
|
120
|
-
established (details in `error.details.decisionReceipt`), read the task with
|
|
121
|
-
`delegate_result` before sending anything again and never resend automatically. Each allow
|
|
122
|
-
covers one call only; the request you just decided is never re-asked.
|
|
123
|
-
- `question`: answer every asked question via `delegate_question_answer({ taskId, requestId,
|
|
124
|
-
answers, waitAfterAnswer: true })`. `grantsAccess` is always false; never answer omitted
|
|
125
|
-
or redacted questions (`questionAnswerable: false`).
|
|
126
|
-
- `ready`: execution finished — this is not acceptance. Call `delegate_result` ONCE to read
|
|
127
|
-
the summary, changed files, diff and test evidence (paginate omitted notes via
|
|
128
|
-
`reviewNoteOffset`/`reviewNoteLimit`). Review in Codex, then call `delegate_review` with
|
|
129
|
-
`accepted` or `changes-requested` and confirm `reviewPersistence.state === "saved"` (or
|
|
130
|
-
returned `hostAcceptance`). Consolidate defects into ONE follow-up via `continueFromTaskId`.
|
|
131
|
-
- `failed` / `cancelled`: call `delegate_result` ONCE and report. For a transient DSH outage
|
|
132
|
-
or transport failure, make up to 3 sequential retries on the failing stage: for an
|
|
133
|
-
unconfirmed submission, first check read-only facts to verify whether a task was created or
|
|
134
|
-
is live (wait on that `taskId` rather than risking a duplicate; pause if uncertain). Once a
|
|
135
|
-
failed run is confirmed ended, resume via `continueFromTaskId` with the original source
|
|
136
|
-
path if a resumable session exists; if all 3 retries fail, pause the packet and dependents
|
|
137
|
-
and return checkpoint facts (goal, acceptance checks, attempt timestamps/errors, `taskId`,
|
|
138
|
-
source/execution paths, isolation, DSH workspace/session ids, completed and remaining work)
|
|
139
|
-
for Codex to save in the workspace before ending.
|
|
140
|
-
- `interrupted`: the wait itself was cut off. It does NOT mean the execution stopped:
|
|
141
|
-
- `terminal: false` with live `state` (`pending`/`running`): call `delegate_wait` on the
|
|
142
|
-
same `taskId`; never resubmit, never implement locally, never cancel for this reason.
|
|
143
|
-
- `terminal: true` with `state: "interrupted"`: task ended; call `delegate_result` once
|
|
144
|
-
and do not keep calling `delegate_wait` on it.
|
|
145
|
-
- Unknown/ambiguous state: do NOT assume it is still running and do NOT assume it stopped;
|
|
146
|
-
FIRST check one fact with `delegate_result`. Do not
|
|
147
|
-
re-wait indefinitely on a task you cannot classify.
|
|
148
|
-
4. WHEN THE HOST CANNOT SEND A SECOND CALL (single-call MCP block): only on an
|
|
149
|
-
explicit operator request to inspect or stop that task while `delegate_wait` blocks the
|
|
150
|
-
channel, run `dsh-taskbridge-control` (`dsh-delegate-control.js`) located
|
|
151
|
-
NEXT TO this plugin's MCP script (`status <taskId>` or `cancel <taskId>`); never call an unrelated script.
|
|
152
|
-
Neither can submit a task, change a setting or touch other tasks.
|
|
153
|
-
Otherwise stay silent and keep waiting.
|
|
154
|
-
|
|
155
|
-
DO NOT IMPLEMENT LOCALLY WHILE A DELEGATED WORKER RUNS
|
|
156
|
-
Never commit, stash, branch, reset or edit locally while a delegated task is running, waiting
|
|
157
|
-
or awaiting review (single-writer guarantee). The ONLY exception is an explicit
|
|
158
|
-
user-authorized takeover — never a long silence, a permission refusal, a failed run or your own judgement.
|
|
159
|
-
While you are waiting, stay silent and do NOT narrate snapshots that have not changed (except
|
|
160
|
-
for work INDEPENDENT of the delegated task, an inspection the operator explicitly asked for,
|
|
161
|
-
or a blocked diagnosis).
|
|
162
|
-
|
|
163
|
-
REVIEW BOUNDARY
|
|
164
|
-
Report task state, the actual provider/model/effort from the result, confirmed `agentTeams` /
|
|
165
|
-
`agentTeamsOrigin` / `team.applied` / `team.enabled`, actual execution directory, DSH
|
|
166
|
-
workspace/session identity, changed-file summary, verification evidence and limitations.
|
|
167
|
-
Codex remains responsible for reviewing the diff and tests, accepting or requesting changes,
|
|
168
|
-
and deciding any follow-up task. Never commit, push, or read/store/relay
|
|
169
|
-
credentials or connection tokens.
|
|
170
|
-
"""
|