@adhdev/daemon-core 0.9.76-rc.2 → 0.9.76-rc.20
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/dist/cli-adapters/provider-cli-adapter.d.ts +2 -1
- package/dist/cli-adapters/provider-cli-runtime.d.ts +1 -0
- package/dist/commands/cli-manager.d.ts +6 -4
- package/dist/commands/mesh-coordinator.d.ts +2 -0
- package/dist/commands/router.d.ts +4 -0
- package/dist/config/mesh-config.d.ts +3 -0
- package/dist/git/git-worktree.d.ts +64 -0
- package/dist/git/index.d.ts +2 -0
- package/dist/index.js +870 -361
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +897 -393
- package/dist/index.mjs.map +1 -1
- package/dist/mesh/coordinator-prompt.d.ts +1 -0
- package/dist/providers/cli-provider-instance.d.ts +3 -0
- package/dist/repo-mesh-types.d.ts +4 -0
- package/dist/shared-types.d.ts +18 -1
- package/package.json +3 -4
- package/src/cli-adapters/provider-cli-adapter.ts +6 -3
- package/src/cli-adapters/provider-cli-runtime.ts +3 -2
- package/src/commands/chat-commands.ts +49 -4
- package/src/commands/cli-manager.ts +13 -3
- package/src/commands/mesh-coordinator.ts +149 -6
- package/src/commands/router.ts +247 -30
- package/src/config/mesh-config.ts +6 -0
- package/src/git/git-worktree.ts +214 -0
- package/src/git/index.ts +14 -0
- package/src/mesh/coordinator-prompt.ts +25 -10
- package/src/providers/cli-provider-instance.d.ts +2 -0
- package/src/providers/cli-provider-instance.ts +6 -1
- package/src/repo-mesh-types.ts +4 -0
- package/src/shared-types.ts +20 -1
- package/src/status/builders.ts +17 -12
|
@@ -16,6 +16,7 @@ import type {
|
|
|
16
16
|
RepoMeshStatus,
|
|
17
17
|
RepoMeshNodeStatus,
|
|
18
18
|
} from '../repo-mesh-types.js';
|
|
19
|
+
import { DEFAULT_MESH_POLICY } from '../repo-mesh-types.js';
|
|
19
20
|
|
|
20
21
|
// ─── Prompt Builder ─────────────────────────────
|
|
21
22
|
|
|
@@ -23,10 +24,11 @@ export interface CoordinatorPromptContext {
|
|
|
23
24
|
mesh: LocalMeshEntry;
|
|
24
25
|
status?: RepoMeshStatus;
|
|
25
26
|
userInstruction?: string;
|
|
27
|
+
coordinatorCliType?: string;
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
export function buildCoordinatorSystemPrompt(ctx: CoordinatorPromptContext): string {
|
|
29
|
-
const { mesh, status, userInstruction } = ctx;
|
|
31
|
+
const { mesh, status, userInstruction, coordinatorCliType } = ctx;
|
|
30
32
|
const sections: string[] = [];
|
|
31
33
|
|
|
32
34
|
// ── Identity ──
|
|
@@ -45,7 +47,7 @@ Repository: \`${mesh.repoIdentity}\`${mesh.defaultBranch ? `\nDefault branch: \`
|
|
|
45
47
|
}
|
|
46
48
|
|
|
47
49
|
// ── Policy ──
|
|
48
|
-
sections.push(buildPolicySection(mesh.policy));
|
|
50
|
+
sections.push(buildPolicySection({ ...DEFAULT_MESH_POLICY, ...(mesh.policy || {}) }));
|
|
49
51
|
|
|
50
52
|
// ── Tools ──
|
|
51
53
|
sections.push(TOOLS_SECTION);
|
|
@@ -54,14 +56,14 @@ Repository: \`${mesh.repoIdentity}\`${mesh.defaultBranch ? `\nDefault branch: \`
|
|
|
54
56
|
sections.push(WORKFLOW_SECTION);
|
|
55
57
|
|
|
56
58
|
// ── Rules ──
|
|
57
|
-
sections.push(
|
|
59
|
+
sections.push(buildRulesSection(coordinatorCliType));
|
|
58
60
|
|
|
59
61
|
// ── User instruction ──
|
|
60
62
|
if (userInstruction) {
|
|
61
63
|
sections.push(`## Additional Context\n${userInstruction}`);
|
|
62
64
|
}
|
|
63
65
|
|
|
64
|
-
if (mesh.coordinator
|
|
66
|
+
if (mesh.coordinator?.systemPromptSuffix) {
|
|
65
67
|
sections.push(mesh.coordinator.systemPromptSuffix);
|
|
66
68
|
}
|
|
67
69
|
|
|
@@ -130,7 +132,9 @@ const TOOLS_SECTION = `## Available Tools
|
|
|
130
132
|
| \`mesh_read_chat\` | Read an agent's recent messages to check progress |
|
|
131
133
|
| \`mesh_git_status\` | Check git status on a specific node |
|
|
132
134
|
| \`mesh_checkpoint\` | Create a git checkpoint on a node |
|
|
133
|
-
| \`mesh_approve\` | Approve/reject a pending agent action
|
|
135
|
+
| \`mesh_approve\` | Approve/reject a pending agent action |
|
|
136
|
+
| \`mesh_clone_node\` | Create a worktree node for isolated parallel branch work |
|
|
137
|
+
| \`mesh_remove_node\` | Remove a node (cleans up worktree if applicable) |`;
|
|
134
138
|
|
|
135
139
|
const WORKFLOW_SECTION = `## Orchestration Workflow
|
|
136
140
|
|
|
@@ -138,21 +142,32 @@ const WORKFLOW_SECTION = `## Orchestration Workflow
|
|
|
138
142
|
2. **Plan** — Decompose the user's request into independent tasks for parallel execution, or sequential tasks when dependencies exist.
|
|
139
143
|
3. **Delegate** — For each task:
|
|
140
144
|
a. Pick the best node (consider: health, dirty state, current workload).
|
|
141
|
-
b. If
|
|
142
|
-
c.
|
|
145
|
+
b. If you need branch isolation for parallel work, call \`mesh_clone_node\` to create a worktree node first.
|
|
146
|
+
c. If no session exists, call \`mesh_launch_session\` to start one.
|
|
147
|
+
d. Call \`mesh_send_task\` with a **complete, self-contained** instruction that includes all context the agent needs (file paths, line numbers, what to change, why). Do not send partial instructions expecting future follow-up.
|
|
143
148
|
4. **Monitor** — Periodically call \`mesh_read_chat\` to check progress. Handle approvals via \`mesh_approve\`.
|
|
144
149
|
5. **Verify** — When a task reports completion, call \`mesh_git_status\` to verify changes were made.
|
|
145
150
|
6. **Checkpoint** — Call \`mesh_checkpoint\` to save the work.
|
|
146
|
-
7. **
|
|
151
|
+
7. **Clean up** — Remove worktree nodes via \`mesh_remove_node\` after their work is merged or no longer needed.
|
|
152
|
+
8. **Report** — Summarize what was done, what changed, and any issues.`;
|
|
147
153
|
|
|
148
|
-
|
|
154
|
+
function buildRulesSection(coordinatorCliType?: string): string {
|
|
155
|
+
const coordinatorNote = coordinatorCliType
|
|
156
|
+
? `\n- **Coordinator runtime is not a delegation default.** This coordinator is running as \`${coordinatorCliType}\`, but delegated node sessions must follow the user's requested provider, not the coordinator's own runtime.`
|
|
157
|
+
: '';
|
|
158
|
+
|
|
159
|
+
return `## Rules
|
|
149
160
|
|
|
150
161
|
- **Minimize coordinator context.** The coordinator's job is routing, not implementing. Do not read source files, run commands, or analyze code directly — delegate all of that to node agents. Your context should stay lean.
|
|
151
162
|
- **Delegate analysis too.** If you need to understand a bug or explore the codebase, send that investigation as a task to a node. Do not do it yourself.
|
|
163
|
+
- **Respect explicit provider requests.** If the user names an agent/provider, pass the matching provider type to \`mesh_launch_session\`: Hermes → \`hermes-cli\`, Claude Code/Claude → \`claude-cli\`, Codex → \`codex-cli\`, Gemini → \`gemini-cli\`. Never substitute \`claude-cli\` just because the coordinator itself is Claude Code.
|
|
152
164
|
- **Front-load the task message.** When calling \`mesh_send_task\`, include everything the agent needs: what files to touch, what the problem is, what the fix should look like. The agent won't ask follow-up questions.
|
|
153
165
|
- **Don't inspect code.** Trust the agent's output. Verify via \`mesh_git_status\`, not by reading source files.
|
|
154
166
|
- **Don't over-parallelize.** Start with 1-2 concurrent tasks. Scale up if they succeed.
|
|
155
167
|
- **Handle failures gracefully.** If a task fails, read the chat to understand why, then retry or reassign.
|
|
156
168
|
- **Keep the user informed.** Report progress after each delegation round — one or two sentences, not a narration.
|
|
157
169
|
- **Respect node capabilities.** Don't send build tasks to read-only nodes. Don't push from nodes that aren't allowed to.
|
|
158
|
-
- **Never fabricate tool results.** Always call the actual tool; never pretend you did
|
|
170
|
+
- **Never fabricate tool results.** Always call the actual tool; never pretend you did.
|
|
171
|
+
- **Clean up worktree nodes.** After a worktree task completes and its changes are merged or checkpointed, call \`mesh_remove_node\` to free resources.
|
|
172
|
+
- **Name worktree branches meaningfully.** Use descriptive names like \`feat/auth-refactor\` or \`fix/build-123\`.${coordinatorNote}`;
|
|
173
|
+
}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import type { ProviderModule } from './contracts.js';
|
|
8
8
|
import type { ProviderInstance, ProviderState, InstanceContext } from './provider-instance.js';
|
|
9
|
+
import type { ChatMessage } from '../types.js';
|
|
9
10
|
import { ProviderCliAdapter } from '../cli-adapters/provider-cli-adapter.js';
|
|
10
11
|
import type { PtyTransportFactory } from '../cli-adapters/pty-transport.js';
|
|
11
12
|
export declare class CliProviderInstance implements ProviderInstance {
|
|
@@ -77,6 +78,7 @@ export declare class CliProviderInstance implements ProviderInstance {
|
|
|
77
78
|
private formatMarkerTimestamp;
|
|
78
79
|
private maybeAppendRuntimeRecoveryMessage;
|
|
79
80
|
private appendRuntimeSystemMessage;
|
|
81
|
+
mergeRuntimeChatMessages(parsedMessages: ChatMessage[]): ChatMessage[];
|
|
80
82
|
private mergeConversationMessages;
|
|
81
83
|
private formatApprovalRequestMessage;
|
|
82
84
|
private promoteProviderSessionId;
|
|
@@ -214,6 +214,7 @@ export class CliProviderInstance implements ProviderInstance {
|
|
|
214
214
|
options?: {
|
|
215
215
|
providerSessionId?: string;
|
|
216
216
|
launchMode?: 'new' | 'resume' | 'manual';
|
|
217
|
+
extraEnv?: Record<string, string>;
|
|
217
218
|
onProviderSessionResolved?: (info: {
|
|
218
219
|
instanceId: string;
|
|
219
220
|
providerType: string;
|
|
@@ -230,7 +231,7 @@ export class CliProviderInstance implements ProviderInstance {
|
|
|
230
231
|
this.providerSessionId = options?.providerSessionId;
|
|
231
232
|
this.launchMode = options?.launchMode || 'new';
|
|
232
233
|
this.onProviderSessionResolved = options?.onProviderSessionResolved;
|
|
233
|
-
this.adapter = new ProviderCliAdapter(provider as CliProviderModule, workingDir, cliArgs, transportFactory);
|
|
234
|
+
this.adapter = new ProviderCliAdapter(provider as CliProviderModule, workingDir, cliArgs, options?.extraEnv || {}, transportFactory);
|
|
234
235
|
this.monitor = new StatusMonitor();
|
|
235
236
|
this.historyWriter = new ChatHistoryWriter();
|
|
236
237
|
}
|
|
@@ -977,6 +978,10 @@ export class CliProviderInstance implements ProviderInstance {
|
|
|
977
978
|
}
|
|
978
979
|
}
|
|
979
980
|
|
|
981
|
+
mergeRuntimeChatMessages(parsedMessages: ChatMessage[]): ChatMessage[] {
|
|
982
|
+
return this.mergeConversationMessages(parsedMessages);
|
|
983
|
+
}
|
|
984
|
+
|
|
980
985
|
private mergeConversationMessages(parsedMessages: any[]): ChatMessage[] {
|
|
981
986
|
if (this.runtimeMessages.length === 0) return normalizeChatMessages(parsedMessages);
|
|
982
987
|
|
package/src/repo-mesh-types.ts
CHANGED
|
@@ -189,6 +189,10 @@ export interface LocalMeshNodeEntry {
|
|
|
189
189
|
policy: RepoMeshNodePolicy;
|
|
190
190
|
/** For single-machine mesh: same daemon, different worktree */
|
|
191
191
|
isLocalWorktree?: boolean;
|
|
192
|
+
/** Branch this worktree tracks (set when created via clone_mesh_node) */
|
|
193
|
+
worktreeBranch?: string;
|
|
194
|
+
/** Node ID this worktree was cloned from */
|
|
195
|
+
clonedFromNodeId?: string;
|
|
192
196
|
}
|
|
193
197
|
|
|
194
198
|
// ─── Mesh Status (runtime, not persisted) ───────
|
package/src/shared-types.ts
CHANGED
|
@@ -432,6 +432,17 @@ export type VersionUpdateReason =
|
|
|
432
432
|
| 'patch_mismatch'
|
|
433
433
|
| 'daemon_ahead';
|
|
434
434
|
|
|
435
|
+
export type ReleaseChannel = 'stable' | 'preview';
|
|
436
|
+
export type NpmUpdateTag = 'latest' | 'next';
|
|
437
|
+
|
|
438
|
+
export interface VersionUpdatePolicy {
|
|
439
|
+
channel: ReleaseChannel;
|
|
440
|
+
npmTag: NpmUpdateTag;
|
|
441
|
+
targetVersion: string;
|
|
442
|
+
minVersion?: string;
|
|
443
|
+
updateCommand: string;
|
|
444
|
+
}
|
|
445
|
+
|
|
435
446
|
/** Available provider information */
|
|
436
447
|
export interface AvailableProviderInfo {
|
|
437
448
|
type: string;
|
|
@@ -577,6 +588,10 @@ export interface CompactDaemonEntry {
|
|
|
577
588
|
versionMismatch?: boolean;
|
|
578
589
|
versionUpdateRequired?: boolean;
|
|
579
590
|
versionUpdateReason?: VersionUpdateReason;
|
|
591
|
+
releaseChannel?: ReleaseChannel;
|
|
592
|
+
updateChannel?: ReleaseChannel;
|
|
593
|
+
updatePolicy?: VersionUpdatePolicy;
|
|
594
|
+
updateCommand?: string;
|
|
580
595
|
terminalBackend?: TerminalBackendStatus;
|
|
581
596
|
detectedIdes?: DetectedIdeInfo[];
|
|
582
597
|
availableProviders?: AvailableProviderInfo[];
|
|
@@ -599,11 +614,15 @@ export interface CloudDaemonSummaryEntry {
|
|
|
599
614
|
versionMismatch?: boolean;
|
|
600
615
|
versionUpdateRequired?: boolean;
|
|
601
616
|
versionUpdateReason?: VersionUpdateReason;
|
|
617
|
+
releaseChannel?: ReleaseChannel;
|
|
618
|
+
updateChannel?: ReleaseChannel;
|
|
619
|
+
updatePolicy?: VersionUpdatePolicy;
|
|
620
|
+
updateCommand?: string;
|
|
602
621
|
terminalBackend?: TerminalBackendStatus;
|
|
603
622
|
}
|
|
604
623
|
|
|
605
624
|
/** Minimal daemon bootstrap payload used by dashboard WS to initiate P2P. */
|
|
606
|
-
export interface DashboardBootstrapDaemonEntry {
|
|
625
|
+
export interface DashboardBootstrapDaemonEntry extends Partial<CloudDaemonSummaryEntry> {
|
|
607
626
|
id: string;
|
|
608
627
|
p2p?: StatusReportPayload['p2p'];
|
|
609
628
|
timestamp?: number;
|
package/src/status/builders.ts
CHANGED
|
@@ -43,6 +43,19 @@ function getActiveChatOptions(profile: SessionEntryProfile): NormalizeActiveChat
|
|
|
43
43
|
return LIVE_STATUS_ACTIVE_CHAT_OPTIONS;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
function resolveSessionStatus(
|
|
47
|
+
activeChat: { status?: string | null; activeModal?: { buttons?: unknown[] | null } | null } | null | undefined,
|
|
48
|
+
providerStatus?: string | null,
|
|
49
|
+
) {
|
|
50
|
+
const chatStatus = normalizeManagedStatus(activeChat?.status, { activeModal: activeChat?.activeModal || null });
|
|
51
|
+
const topLevelStatus = normalizeManagedStatus(providerStatus, { activeModal: activeChat?.activeModal || null });
|
|
52
|
+
|
|
53
|
+
if (chatStatus === 'waiting_approval' || topLevelStatus === 'waiting_approval') return 'waiting_approval';
|
|
54
|
+
if (chatStatus === 'generating' || topLevelStatus === 'generating') return 'generating';
|
|
55
|
+
if (topLevelStatus !== 'idle') return topLevelStatus;
|
|
56
|
+
return chatStatus;
|
|
57
|
+
}
|
|
58
|
+
|
|
46
59
|
function shouldIncludeSessionControls(profile: SessionEntryProfile): boolean {
|
|
47
60
|
return profile !== 'live';
|
|
48
61
|
}
|
|
@@ -170,9 +183,7 @@ function buildIdeWorkspaceSession(
|
|
|
170
183
|
providerName: state.name,
|
|
171
184
|
kind: 'workspace',
|
|
172
185
|
transport: 'cdp-page',
|
|
173
|
-
status:
|
|
174
|
-
activeModal: activeChat?.activeModal || null,
|
|
175
|
-
}),
|
|
186
|
+
status: resolveSessionStatus(activeChat, state.status),
|
|
176
187
|
title,
|
|
177
188
|
workspace,
|
|
178
189
|
...(git && { git }),
|
|
@@ -212,9 +223,7 @@ function buildExtensionAgentSession(
|
|
|
212
223
|
providerSessionId: ext.providerSessionId,
|
|
213
224
|
kind: 'agent',
|
|
214
225
|
transport: 'cdp-webview',
|
|
215
|
-
status:
|
|
216
|
-
activeModal: activeChat?.activeModal || null,
|
|
217
|
-
}),
|
|
226
|
+
status: resolveSessionStatus(activeChat, ext.status),
|
|
218
227
|
title: activeChat?.title || ext.name,
|
|
219
228
|
workspace,
|
|
220
229
|
...(git && { git }),
|
|
@@ -277,9 +286,7 @@ function buildCliSession(state: CliProviderState, options: SessionEntryBuildOpti
|
|
|
277
286
|
providerSessionId: state.providerSessionId,
|
|
278
287
|
kind: 'agent',
|
|
279
288
|
transport: 'pty',
|
|
280
|
-
status:
|
|
281
|
-
activeModal: activeChat?.activeModal || null,
|
|
282
|
-
}),
|
|
289
|
+
status: resolveSessionStatus(activeChat, state.status),
|
|
283
290
|
title: activeChat?.title || state.name,
|
|
284
291
|
workspace,
|
|
285
292
|
...(git && { git }),
|
|
@@ -328,9 +335,7 @@ function buildAcpSession(state: AcpProviderState, options: SessionEntryBuildOpti
|
|
|
328
335
|
providerName: state.name,
|
|
329
336
|
kind: 'agent',
|
|
330
337
|
transport: 'acp',
|
|
331
|
-
status:
|
|
332
|
-
activeModal: activeChat?.activeModal || null,
|
|
333
|
-
}),
|
|
338
|
+
status: resolveSessionStatus(activeChat, state.status),
|
|
334
339
|
title: activeChat?.title || state.name,
|
|
335
340
|
workspace,
|
|
336
341
|
...(git && { git }),
|