@adhdev/daemon-core 0.9.82-rc.31 → 0.9.82-rc.310
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/boot/daemon-lifecycle.d.ts +8 -0
- package/dist/boot/process-hardening.d.ts +50 -0
- package/dist/build-info.d.ts +37 -0
- package/dist/chat/source-machine.d.ts +166 -0
- package/dist/chat/source-resolver.d.ts +104 -0
- package/dist/chat/subscription-updates.d.ts +1 -0
- package/dist/cli-adapter-types.d.ts +23 -2
- package/dist/cli-adapters/cli-script-runner.d.ts +117 -0
- package/dist/cli-adapters/cli-state-engine.d.ts +198 -0
- package/dist/cli-adapters/provider-cli-adapter.d.ts +106 -63
- package/dist/cli-adapters/provider-cli-parse.d.ts +4 -0
- package/dist/cli-adapters/provider-cli-shared.d.ts +38 -0
- package/dist/cli-adapters/raw-terminal-io.d.ts +37 -0
- package/dist/cli-adapters/resolve-executable.d.ts +14 -0
- package/dist/cli-adapters/terminal-backends/ghostty-vt-backend.d.ts +6 -3
- package/dist/cli-adapters/terminal-backends/types.d.ts +10 -2
- package/dist/cli-adapters/terminal-screen.d.ts +4 -11
- package/dist/commands/cli-manager.d.ts +2 -1
- package/dist/commands/handler.d.ts +110 -0
- package/dist/commands/mesh-coordinator.d.ts +85 -1
- package/dist/commands/router.d.ts +210 -1
- package/dist/config/chat-history.d.ts +9 -0
- package/dist/config/config.d.ts +5 -0
- package/dist/config/mesh-config.d.ts +72 -1
- package/dist/git/git-commands.d.ts +9 -1
- package/dist/git/git-diff.d.ts +6 -0
- package/dist/git/git-executor.d.ts +11 -0
- package/dist/git/git-status.d.ts +9 -0
- package/dist/git/git-types.d.ts +2 -50
- package/dist/index.d.ts +51 -12
- package/dist/index.js +38320 -16024
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +38009 -15817
- package/dist/index.mjs.map +1 -1
- package/dist/installer.d.ts +1 -4
- package/dist/ipc/local-ipc-server.d.ts +91 -0
- package/dist/launch.d.ts +1 -1
- package/dist/logging/async-batch-writer.d.ts +10 -0
- package/dist/mesh/contracts.d.ts +164 -0
- package/dist/mesh/coordinator-prompt.d.ts +36 -0
- package/dist/mesh/coordinator-registry.d.ts +59 -0
- package/dist/mesh/mesh-active-work.d.ts +108 -0
- package/dist/mesh/mesh-delivery-policy.d.ts +131 -0
- package/dist/mesh/mesh-events-coordinator.d.ts +138 -0
- package/dist/mesh/mesh-events-pending.d.ts +45 -0
- package/dist/mesh/mesh-events-stale.d.ts +40 -0
- package/dist/mesh/mesh-events-utils.d.ts +47 -0
- package/dist/mesh/mesh-events.d.ts +6 -49
- package/dist/mesh/mesh-fast-forward.d.ts +81 -0
- package/dist/mesh/mesh-host-ownership.d.ts +9 -0
- package/dist/mesh/mesh-init.d.ts +86 -0
- package/dist/mesh/mesh-ledger-reconciliation.d.ts +23 -3
- package/dist/mesh/mesh-ledger.d.ts +77 -1
- package/dist/mesh/mesh-missions.d.ts +116 -0
- package/dist/mesh/mesh-reconcile-loop.d.ts +7 -0
- package/dist/mesh/mesh-refine-batch.d.ts +68 -0
- package/dist/mesh/mesh-refine-status.d.ts +62 -0
- package/dist/mesh/mesh-review-inbox.d.ts +90 -0
- package/dist/mesh/mesh-routing.d.ts +70 -0
- package/dist/mesh/mesh-runtime-store.d.ts +377 -0
- package/dist/mesh/mesh-task-stats.d.ts +49 -0
- package/dist/mesh/mesh-unresolved-forward-outbox.d.ts +30 -0
- package/dist/mesh/mesh-work-queue.d.ts +181 -5
- package/dist/mesh/preview-freshness.d.ts +18 -0
- package/dist/mesh/refine-config.d.ts +215 -0
- package/dist/mesh/worktree-bootstrap-config.d.ts +135 -0
- package/dist/providers/acp-provider-instance.d.ts +2 -0
- package/dist/providers/approval-utils.d.ts +13 -0
- package/dist/providers/cli-provider-instance.d.ts +61 -3
- package/dist/providers/contracts.d.ts +130 -6
- package/dist/providers/external-sources.d.ts +71 -0
- package/dist/providers/native-history/antigravity-cli-transcript.d.ts +100 -0
- package/dist/providers/native-history/claude-cli-transcript.d.ts +70 -0
- package/dist/providers/native-history/codex-cli-transcript.d.ts +73 -0
- package/dist/providers/native-history/dispatcher.d.ts +27 -0
- package/dist/providers/native-history/hermes-cli-transcript.d.ts +30 -0
- package/dist/providers/native-history/index.d.ts +13 -0
- package/dist/providers/provider-instance-manager.d.ts +13 -0
- package/dist/providers/provider-instance.d.ts +13 -1
- package/dist/providers/provider-loader.d.ts +26 -4
- package/dist/providers/provider-trust.d.ts +31 -0
- package/dist/providers/read-chat-contract.d.ts +29 -0
- package/dist/providers/sdk/v1/builders/acp/detect-status.d.ts +68 -0
- package/dist/providers/sdk/v1/builders/cli/detect-status.d.ts +85 -0
- package/dist/providers/sdk/v1/builders/cli/parse-approval-squash.d.ts +59 -0
- package/dist/providers/sdk/v1/builders/cli/parse-approval.d.ts +65 -0
- package/dist/providers/sdk/v1/builders/cli/parse-session.d.ts +91 -0
- package/dist/providers/sdk/v1/builders/cli/visible-region.d.ts +42 -0
- package/dist/providers/sdk/v1/fixture-tooling/format.d.ts +126 -0
- package/dist/providers/sdk/v1/fixture-tooling/index.d.ts +8 -0
- package/dist/providers/sdk/v1/fixture-tooling/replay.d.ts +38 -0
- package/dist/providers/sdk/v1/index.d.ts +30 -0
- package/dist/providers/sdk/v1/sandbox/README-design.d.ts +193 -0
- package/dist/providers/sdk/v1/sandbox/require-whitelist.d.ts +74 -0
- package/dist/providers/sdk/v1/sandbox/script-runner.d.ts +98 -0
- package/dist/providers/sdk/v1/types/cli/index.d.ts +277 -0
- package/dist/providers/sdk/v1/types/common/index.d.ts +203 -0
- package/dist/providers/sdk/v1/validators/index.d.ts +5 -0
- package/dist/providers/sdk/v1/validators/manifest.d.ts +40 -0
- package/dist/providers/sdk/v1/validators/taint.d.ts +52 -0
- package/dist/providers/spec/adapter.d.ts +59 -0
- package/dist/providers/spec/cli-adapter.d.ts +186 -0
- package/dist/providers/spec/evaluator.d.ts +23 -0
- package/dist/providers/spec/fsm-driver.d.ts +278 -0
- package/dist/providers/spec/fsm-evaluator.d.ts +72 -0
- package/dist/providers/spec/fsm-loader.d.ts +14 -0
- package/dist/providers/spec/fsm-types.d.ts +128 -0
- package/dist/providers/spec/native-history-executor.d.ts +41 -0
- package/dist/providers/spec/pre-launch-trust.d.ts +16 -0
- package/dist/providers/spec/route.d.ts +4 -0
- package/dist/providers/spec/types.d.ts +144 -0
- package/dist/providers/transcript-v2.d.ts +176 -0
- package/dist/providers/types/interactive-prompt.d.ts +84 -0
- package/dist/repo-mesh-types.d.ts +203 -13
- package/dist/sessions/registry.d.ts +6 -0
- package/dist/shared-types-extra.d.ts +2 -4
- package/dist/shared-types.d.ts +42 -1
- package/dist/status/normalize.d.ts +1 -1
- package/dist/status/normalize.js +1 -0
- package/dist/status/normalize.js.map +1 -1
- package/dist/status/normalize.mjs +1 -0
- package/dist/status/normalize.mjs.map +1 -1
- package/dist/status/reporter.d.ts +2 -0
- package/dist/status/snapshot.d.ts +1 -0
- package/dist/types.d.ts +5 -0
- package/package.json +7 -3
- package/src/agent-stream/poller.ts +2 -3
- package/src/boot/daemon-lifecycle.ts +55 -12
- package/src/boot/process-hardening.ts +89 -0
- package/src/build-info.ts +73 -0
- package/src/chat/source-machine.ts +534 -0
- package/src/chat/source-resolver.ts +0 -0
- package/src/chat/subscription-updates.ts +20 -1
- package/src/cli-adapter-types.d.ts +1 -0
- package/src/cli-adapter-types.ts +22 -2
- package/src/cli-adapters/cli-script-runner.ts +421 -0
- package/src/cli-adapters/cli-state-engine.ts +1215 -0
- package/src/cli-adapters/provider-cli-adapter.d.ts +1 -1
- package/src/cli-adapters/provider-cli-adapter.ts +674 -1139
- package/src/cli-adapters/provider-cli-parse.d.ts +1 -0
- package/src/cli-adapters/provider-cli-parse.ts +13 -0
- package/src/cli-adapters/provider-cli-runtime.ts +3 -1
- package/src/cli-adapters/provider-cli-shared.d.ts +2 -0
- package/src/cli-adapters/provider-cli-shared.ts +68 -11
- package/src/cli-adapters/pty-transport.ts +2 -1
- package/src/cli-adapters/raw-terminal-io.ts +252 -0
- package/src/cli-adapters/resolve-executable.ts +45 -0
- package/src/cli-adapters/session-host-transport.ts +2 -1
- package/src/cli-adapters/terminal-backends/ghostty-vt-backend.ts +53 -29
- package/src/cli-adapters/terminal-backends/types.ts +10 -3
- package/src/cli-adapters/terminal-screen.ts +16 -81
- package/src/commands/chat-commands.ts +1813 -60
- package/src/commands/cli-manager.ts +286 -14
- package/src/commands/handler.ts +809 -2
- package/src/commands/mesh-coordinator.ts +332 -122
- package/src/commands/router.ts +5911 -595
- package/src/commands/upgrade-helper.ts +29 -0
- package/src/config/chat-history.ts +474 -24
- package/src/config/config.ts +12 -0
- package/src/config/mesh-config.ts +303 -3
- package/src/config/recent-activity.ts +8 -2
- package/src/daemon/dev-auto-implement.ts +3 -2
- package/src/daemon/dev-cli-debug.ts +10 -1
- package/src/detection/ide-detector.ts +26 -16
- package/src/git/git-commands.ts +42 -12
- package/src/git/git-diff.ts +53 -0
- package/src/git/git-executor.ts +12 -0
- package/src/git/git-status.ts +302 -18
- package/src/git/git-types.ts +14 -62
- package/src/git/git-worktree.ts +8 -1
- package/src/index.ts +131 -11
- package/src/installer.d.ts +1 -1
- package/src/installer.ts +8 -6
- package/src/ipc/local-ipc-server.ts +278 -0
- package/src/launch.d.ts +1 -1
- package/src/launch.ts +37 -28
- package/src/logging/async-batch-writer.ts +55 -0
- package/src/logging/logger.ts +2 -1
- package/src/mesh/contracts.ts +329 -0
- package/src/mesh/coordinator-prompt.ts +234 -31
- package/src/mesh/coordinator-registry.ts +121 -0
- package/src/mesh/mesh-active-work.ts +469 -0
- package/src/mesh/mesh-delivery-policy.ts +315 -0
- package/src/mesh/mesh-events-coordinator.ts +1786 -0
- package/src/mesh/mesh-events-pending.ts +508 -0
- package/src/mesh/mesh-events-stale.ts +290 -0
- package/src/mesh/mesh-events-utils.ts +254 -0
- package/src/mesh/mesh-events.ts +30 -1035
- package/src/mesh/mesh-fast-forward.ts +839 -0
- package/src/mesh/mesh-host-ownership.ts +73 -0
- package/src/mesh/mesh-init.ts +260 -0
- package/src/mesh/mesh-ledger-reconciliation.ts +12 -5
- package/src/mesh/mesh-ledger.ts +589 -102
- package/src/mesh/mesh-missions.ts +248 -0
- package/src/mesh/mesh-reconcile-loop.ts +466 -0
- package/src/mesh/mesh-refine-batch.ts +197 -0
- package/src/mesh/mesh-refine-status.ts +231 -0
- package/src/mesh/mesh-review-inbox.ts +307 -0
- package/src/mesh/mesh-routing.ts +291 -0
- package/src/mesh/mesh-runtime-store.ts +1513 -0
- package/src/mesh/mesh-task-stats.ts +154 -0
- package/src/mesh/mesh-unresolved-forward-outbox.ts +185 -0
- package/src/mesh/mesh-work-queue.ts +604 -145
- package/src/mesh/preview-freshness.ts +118 -0
- package/src/mesh/refine-config.ts +403 -0
- package/src/mesh/worktree-bootstrap-config.ts +326 -0
- package/src/providers/acp-provider-instance.ts +15 -1
- package/src/providers/approval-utils.d.ts +4 -0
- package/src/providers/approval-utils.ts +47 -5
- package/src/providers/chat-message-normalization.ts +4 -11
- package/src/providers/cli-provider-instance.ts +953 -87
- package/src/providers/contracts.d.ts +55 -0
- package/src/providers/contracts.ts +141 -6
- package/src/providers/extension-provider-instance.ts +5 -1
- package/src/providers/external-sources.ts +218 -0
- package/src/providers/ide-provider-instance.ts +25 -6
- package/src/providers/native-history/antigravity-cli-transcript.ts +643 -0
- package/src/providers/native-history/claude-cli-transcript.ts +396 -0
- package/src/providers/native-history/codex-cli-transcript.ts +479 -0
- package/src/providers/native-history/dispatcher.ts +340 -0
- package/src/providers/native-history/hermes-cli-transcript.ts +230 -0
- package/src/providers/native-history/index.ts +30 -0
- package/src/providers/provider-instance-manager.ts +30 -0
- package/src/providers/provider-instance.ts +10 -1
- package/src/providers/provider-loader.ts +584 -50
- package/src/providers/provider-schema.ts +87 -14
- package/src/providers/provider-trust.ts +114 -0
- package/src/providers/read-chat-contract.ts +76 -16
- package/src/providers/sdk/README.md +49 -0
- package/src/providers/sdk/v1/builders/acp/detect-status.ts +144 -0
- package/src/providers/sdk/v1/builders/cli/detect-status.ts +262 -0
- package/src/providers/sdk/v1/builders/cli/parse-approval-squash.ts +158 -0
- package/src/providers/sdk/v1/builders/cli/parse-approval.ts +250 -0
- package/src/providers/sdk/v1/builders/cli/parse-session.ts +276 -0
- package/src/providers/sdk/v1/builders/cli/visible-region.ts +143 -0
- package/src/providers/sdk/v1/fixture-tooling/format.ts +130 -0
- package/src/providers/sdk/v1/fixture-tooling/index.ts +22 -0
- package/src/providers/sdk/v1/fixture-tooling/replay.ts +352 -0
- package/src/providers/sdk/v1/index.ts +152 -0
- package/src/providers/sdk/v1/sandbox/README-design.ts +195 -0
- package/src/providers/sdk/v1/sandbox/require-whitelist.ts +472 -0
- package/src/providers/sdk/v1/sandbox/script-runner.ts +150 -0
- package/src/providers/sdk/v1/schemas/cli/provider.schema.json +504 -0
- package/src/providers/sdk/v1/schemas/primitives/acp-session-protocol-v1.json +131 -0
- package/src/providers/sdk/v1/schemas/primitives/native-history-codex-rollout-v1.json +66 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-approval-squash-v1.json +91 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-assistant-block-v1.json +91 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-cue-ordering-v1.json +47 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-dispatch-order-v1.json +32 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-footer-chrome-v1.json +42 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-index-finder-v1.json +27 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-modal-v1.json +125 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-prompt-marker-v1.json +45 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-session-id-extraction-v1.json +46 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-settled-prompt-v1.json +71 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-spinner-v1.json +83 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-transcript-pty-v1.json +83 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-visible-region-v1.json +57 -0
- package/src/providers/sdk/v1/schemas/primitives/tui-welcome-screen-v1.json +35 -0
- package/src/providers/sdk/v1/types/cli/index.ts +365 -0
- package/src/providers/sdk/v1/types/common/index.ts +229 -0
- package/src/providers/sdk/v1/validators/index.ts +19 -0
- package/src/providers/sdk/v1/validators/manifest.ts +110 -0
- package/src/providers/sdk/v1/validators/taint.ts +309 -0
- package/src/providers/spec/adapter.ts +155 -0
- package/src/providers/spec/cli-adapter.ts +838 -0
- package/src/providers/spec/evaluator.ts +345 -0
- package/src/providers/spec/fsm-driver.ts +875 -0
- package/src/providers/spec/fsm-evaluator.ts +255 -0
- package/src/providers/spec/fsm-loader.ts +112 -0
- package/src/providers/spec/fsm-types.ts +222 -0
- package/src/providers/spec/native-history-executor.ts +943 -0
- package/src/providers/spec/pre-launch-trust.ts +104 -0
- package/src/providers/spec/route.ts +51 -0
- package/src/providers/spec/types.ts +189 -0
- package/src/providers/transcript-v2.ts +567 -0
- package/src/providers/types/interactive-prompt.ts +536 -0
- package/src/providers/version-archive.ts +38 -20
- package/src/repo-mesh-types.ts +257 -13
- package/src/sessions/registry.ts +6 -0
- package/src/shared-types-extra.ts +2 -4
- package/src/shared-types.ts +45 -1
- package/src/status/builders.ts +26 -6
- package/src/status/normalize.ts +2 -0
- package/src/status/reporter.ts +15 -0
- package/src/status/snapshot.ts +84 -25
- package/src/system/host-memory.ts +29 -12
- package/src/types.ts +5 -0
- package/dist/cli-adapters/terminal-backends/xterm-backend.d.ts +0 -17
- package/dist/mesh/mesh-sync.d.ts +0 -53
- package/src/cli-adapters/terminal-backends/ghostty-vt-backend.d.ts +0 -16
- package/src/cli-adapters/terminal-backends/xterm-backend.ts +0 -97
- package/src/mesh/mesh-sync.ts +0 -111
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import type { DaemonComponents } from '../boot/daemon-lifecycle.js';
|
|
2
|
+
export declare function __resetIdleAutoFastForwardForTests(): void;
|
|
3
|
+
export declare function __resetMeshWorkspaceCacheForTests(): void;
|
|
4
|
+
export declare function tryAssignQueueTask(components: DaemonComponents, meshId: string, nodeId: string, sessionId: string, providerType: string): boolean;
|
|
5
|
+
/** Active assignments that hold the one-active-per-node / global-parallel invariant
|
|
6
|
+
* (everything except read-only diagnoses, which run unbounded by the write cap). */
|
|
7
|
+
export declare function activeWriteAssignedCount(meshId: string): number;
|
|
8
|
+
/** Active read-only (live_debug_readonly) assignments, for the read-only safety cap. */
|
|
9
|
+
export declare function activeReadonlyAssignedCount(meshId: string): number;
|
|
10
|
+
export interface MeshQueueTriggerResult {
|
|
11
|
+
success: true;
|
|
12
|
+
meshId: string;
|
|
13
|
+
pendingBefore: number;
|
|
14
|
+
assignedBefore: number;
|
|
15
|
+
pendingAfter: number;
|
|
16
|
+
assignedAfter: number;
|
|
17
|
+
claimed: boolean;
|
|
18
|
+
newlyAssignedTasks: Array<{
|
|
19
|
+
id: string;
|
|
20
|
+
nodeId?: string;
|
|
21
|
+
sessionId?: string;
|
|
22
|
+
}>;
|
|
23
|
+
localIdleSessionsChecked: number;
|
|
24
|
+
remoteIdleSessionsChecked: number;
|
|
25
|
+
skippedSessions: Array<{
|
|
26
|
+
nodeId?: string;
|
|
27
|
+
sessionId?: string;
|
|
28
|
+
reason: string;
|
|
29
|
+
status?: string;
|
|
30
|
+
}>;
|
|
31
|
+
autoLaunchStarted: boolean;
|
|
32
|
+
noIdleMeshSessionAvailable?: boolean;
|
|
33
|
+
}
|
|
34
|
+
export declare function triggerMeshQueue(components: DaemonComponents, meshId: string): Promise<MeshQueueTriggerResult>;
|
|
35
|
+
export declare function isMeshCoordinatorEvent(eventName: unknown): eventName is string;
|
|
36
|
+
export declare const MESH_FORCE_INJECT_EVENTS: ReadonlySet<string>;
|
|
37
|
+
export declare function shouldForceInjectMeshEvent(eventName: unknown): boolean;
|
|
38
|
+
export declare function handleMeshForwardEvent(components: DaemonComponents, payload: Record<string, unknown>): {
|
|
39
|
+
success: boolean;
|
|
40
|
+
forwarded: number;
|
|
41
|
+
suppressed: boolean;
|
|
42
|
+
intentionalCleanupStop: boolean;
|
|
43
|
+
terminalLedgerEvidence?: undefined;
|
|
44
|
+
terminalLedgerKind?: undefined;
|
|
45
|
+
duplicateRefineTerminalEvent?: undefined;
|
|
46
|
+
duplicateApproval?: undefined;
|
|
47
|
+
duplicateCompletion?: undefined;
|
|
48
|
+
duplicateStopped?: undefined;
|
|
49
|
+
error?: undefined;
|
|
50
|
+
} | {
|
|
51
|
+
success: boolean;
|
|
52
|
+
forwarded: number;
|
|
53
|
+
suppressed: boolean;
|
|
54
|
+
terminalLedgerEvidence: boolean;
|
|
55
|
+
terminalLedgerKind: unknown;
|
|
56
|
+
intentionalCleanupStop?: undefined;
|
|
57
|
+
duplicateRefineTerminalEvent?: undefined;
|
|
58
|
+
duplicateApproval?: undefined;
|
|
59
|
+
duplicateCompletion?: undefined;
|
|
60
|
+
duplicateStopped?: undefined;
|
|
61
|
+
error?: undefined;
|
|
62
|
+
} | {
|
|
63
|
+
success: boolean;
|
|
64
|
+
forwarded: number;
|
|
65
|
+
suppressed: boolean;
|
|
66
|
+
duplicateRefineTerminalEvent: boolean;
|
|
67
|
+
intentionalCleanupStop?: undefined;
|
|
68
|
+
terminalLedgerEvidence?: undefined;
|
|
69
|
+
terminalLedgerKind?: undefined;
|
|
70
|
+
duplicateApproval?: undefined;
|
|
71
|
+
duplicateCompletion?: undefined;
|
|
72
|
+
duplicateStopped?: undefined;
|
|
73
|
+
error?: undefined;
|
|
74
|
+
} | {
|
|
75
|
+
success: boolean;
|
|
76
|
+
forwarded: number;
|
|
77
|
+
suppressed: boolean;
|
|
78
|
+
duplicateApproval: boolean;
|
|
79
|
+
intentionalCleanupStop?: undefined;
|
|
80
|
+
terminalLedgerEvidence?: undefined;
|
|
81
|
+
terminalLedgerKind?: undefined;
|
|
82
|
+
duplicateRefineTerminalEvent?: undefined;
|
|
83
|
+
duplicateCompletion?: undefined;
|
|
84
|
+
duplicateStopped?: undefined;
|
|
85
|
+
error?: undefined;
|
|
86
|
+
} | {
|
|
87
|
+
success: boolean;
|
|
88
|
+
forwarded: number;
|
|
89
|
+
suppressed: boolean;
|
|
90
|
+
duplicateCompletion: boolean;
|
|
91
|
+
terminalLedgerEvidence: boolean;
|
|
92
|
+
intentionalCleanupStop?: undefined;
|
|
93
|
+
terminalLedgerKind?: undefined;
|
|
94
|
+
duplicateRefineTerminalEvent?: undefined;
|
|
95
|
+
duplicateApproval?: undefined;
|
|
96
|
+
duplicateStopped?: undefined;
|
|
97
|
+
error?: undefined;
|
|
98
|
+
} | {
|
|
99
|
+
success: boolean;
|
|
100
|
+
forwarded: number;
|
|
101
|
+
suppressed: boolean;
|
|
102
|
+
duplicateCompletion: boolean;
|
|
103
|
+
intentionalCleanupStop?: undefined;
|
|
104
|
+
terminalLedgerEvidence?: undefined;
|
|
105
|
+
terminalLedgerKind?: undefined;
|
|
106
|
+
duplicateRefineTerminalEvent?: undefined;
|
|
107
|
+
duplicateApproval?: undefined;
|
|
108
|
+
duplicateStopped?: undefined;
|
|
109
|
+
error?: undefined;
|
|
110
|
+
} | {
|
|
111
|
+
success: boolean;
|
|
112
|
+
forwarded: number;
|
|
113
|
+
suppressed: boolean;
|
|
114
|
+
duplicateStopped: boolean;
|
|
115
|
+
intentionalCleanupStop?: undefined;
|
|
116
|
+
terminalLedgerEvidence?: undefined;
|
|
117
|
+
terminalLedgerKind?: undefined;
|
|
118
|
+
duplicateRefineTerminalEvent?: undefined;
|
|
119
|
+
duplicateApproval?: undefined;
|
|
120
|
+
duplicateCompletion?: undefined;
|
|
121
|
+
error?: undefined;
|
|
122
|
+
} | {
|
|
123
|
+
success: boolean;
|
|
124
|
+
forwarded: number;
|
|
125
|
+
suppressed?: undefined;
|
|
126
|
+
intentionalCleanupStop?: undefined;
|
|
127
|
+
terminalLedgerEvidence?: undefined;
|
|
128
|
+
terminalLedgerKind?: undefined;
|
|
129
|
+
duplicateRefineTerminalEvent?: undefined;
|
|
130
|
+
duplicateApproval?: undefined;
|
|
131
|
+
duplicateCompletion?: undefined;
|
|
132
|
+
duplicateStopped?: undefined;
|
|
133
|
+
error?: undefined;
|
|
134
|
+
} | {
|
|
135
|
+
success: boolean;
|
|
136
|
+
error: string;
|
|
137
|
+
};
|
|
138
|
+
export declare function setupMeshEventForwarding(components: DaemonComponents): void;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export interface PendingMeshCoordinatorEvent {
|
|
2
|
+
event: string;
|
|
3
|
+
meshId: string;
|
|
4
|
+
nodeLabel: string;
|
|
5
|
+
nodeId?: string;
|
|
6
|
+
workspace?: string;
|
|
7
|
+
metadataEvent: Record<string, unknown>;
|
|
8
|
+
coordinatorMessage?: string;
|
|
9
|
+
queuedAt: number;
|
|
10
|
+
/**
|
|
11
|
+
* When set, this event is intended for a specific coordinator daemon.
|
|
12
|
+
* Coordinators on other daemons should ignore it during drain.
|
|
13
|
+
* Absent on legacy events — treated as broadcast to any coordinator.
|
|
14
|
+
*/
|
|
15
|
+
targetCoordinatorDaemonId?: string;
|
|
16
|
+
}
|
|
17
|
+
export declare function readRefineJobId(event: {
|
|
18
|
+
metadataEvent?: Record<string, unknown>;
|
|
19
|
+
} | Record<string, unknown>): string;
|
|
20
|
+
export declare function buildPendingEventFingerprint(event: PendingMeshCoordinatorEvent): string;
|
|
21
|
+
export declare function hasPendingCoordinatorEventDuplicate(event: PendingMeshCoordinatorEvent): boolean;
|
|
22
|
+
export declare function queuePendingMeshCoordinatorEvent(event: PendingMeshCoordinatorEvent): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Drain and return pending coordinator events for meshId, removing the drained
|
|
25
|
+
* ones from both the SQLite inbox and the JSONL legacy file.
|
|
26
|
+
*
|
|
27
|
+
* When `opts.onlyEvents` is supplied, ONLY events whose name is in that set are
|
|
28
|
+
* drained; every other event stays queued (undrained in SQLite, rewritten back to
|
|
29
|
+
* the JSONL file). The reconcile loop uses this to force-drain terminal/force-inject
|
|
30
|
+
* events into a *generating* coordinator while leaving non-force progress events for
|
|
31
|
+
* the coordinator's next idle transition. The atomic SQLite drained=1 marking and the
|
|
32
|
+
* atomic JSONL rename keep force-drain and a concurrent full drain from double-consuming.
|
|
33
|
+
*/
|
|
34
|
+
export declare function drainPendingMeshCoordinatorEvents(meshId?: string, coordinatorDaemonId?: string | ReadonlyArray<string>, opts?: {
|
|
35
|
+
onlyEvents?: ReadonlySet<string>;
|
|
36
|
+
}): PendingMeshCoordinatorEvent[];
|
|
37
|
+
/** Peek at pending coordinator events without draining (non-destructive). */
|
|
38
|
+
export declare function getPendingMeshCoordinatorEvents(meshId?: string, coordinatorDaemonId?: string | ReadonlyArray<string>): readonly PendingMeshCoordinatorEvent[];
|
|
39
|
+
/**
|
|
40
|
+
* Test helper: purge all pending-event state for a mesh — SQLite rows
|
|
41
|
+
* (including drained fingerprint history) and JSONL files.
|
|
42
|
+
*/
|
|
43
|
+
export declare function __clearMeshPendingEventsForTests(meshId: string): void;
|
|
44
|
+
/** Explicitly clear all pending coordinator events for a mesh (and coordinator if scoped). */
|
|
45
|
+
export declare function clearPendingMeshCoordinatorEvents(meshId?: string, coordinatorDaemonId?: string): void;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { MeshLedgerKind } from './mesh-ledger.js';
|
|
2
|
+
export declare function findRecentTerminalLedgerEvidence(args: {
|
|
3
|
+
meshId: string;
|
|
4
|
+
sessionId?: string;
|
|
5
|
+
nodeId?: string;
|
|
6
|
+
}): {
|
|
7
|
+
id: string;
|
|
8
|
+
kind: MeshLedgerKind;
|
|
9
|
+
payload: Record<string, unknown>;
|
|
10
|
+
timestamp: string;
|
|
11
|
+
} | null;
|
|
12
|
+
export declare function hasDispatchAfterTerminal(meshId: string, sessionId: string, terminalId: string): boolean;
|
|
13
|
+
export declare function hasUnterminalDirectDispatchLedgerEntry(meshId: string, sessionId: string): boolean;
|
|
14
|
+
export declare function reconcileDirectDispatchCompletionFromTranscript(args: {
|
|
15
|
+
meshId: string;
|
|
16
|
+
nodeId?: string;
|
|
17
|
+
sessionId: string;
|
|
18
|
+
providerType?: string;
|
|
19
|
+
providerSessionId?: string;
|
|
20
|
+
taskId: string;
|
|
21
|
+
finalSummary: string;
|
|
22
|
+
transcriptMessageAt?: string;
|
|
23
|
+
completedAt?: string;
|
|
24
|
+
targetCoordinatorDaemonId?: string;
|
|
25
|
+
source?: string;
|
|
26
|
+
}): {
|
|
27
|
+
reconciled: boolean;
|
|
28
|
+
kind?: MeshLedgerKind;
|
|
29
|
+
alreadyTerminal?: boolean;
|
|
30
|
+
workerResult?: unknown;
|
|
31
|
+
ledgerEntryId?: string;
|
|
32
|
+
reason?: string;
|
|
33
|
+
};
|
|
34
|
+
export declare function buildLongGeneratingCompletionReconciliation(args: {
|
|
35
|
+
meshId: string;
|
|
36
|
+
nodeId?: string;
|
|
37
|
+
nodeLabel: string;
|
|
38
|
+
metadataEvent: Record<string, unknown>;
|
|
39
|
+
sourceInstanceId?: string;
|
|
40
|
+
}): Record<string, unknown> | null;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { SessionRecoveryContext } from './mesh-ledger.js';
|
|
2
|
+
export declare function readNonEmptyString(value: unknown): string;
|
|
3
|
+
export declare function readRecord(value: unknown): Record<string, unknown> | undefined;
|
|
4
|
+
export declare function canonicalDaemonId(value: unknown): string;
|
|
5
|
+
export declare function sameDaemonId(a: unknown, b: unknown): boolean;
|
|
6
|
+
/**
|
|
7
|
+
* The relay-safety metadata a worker session must carry so that its completion /
|
|
8
|
+
* generating events route back to the coordinator proactively (without waiting for
|
|
9
|
+
* a mesh_read_chat reconcile). meshCoordinatorDaemonId is the routing anchor the
|
|
10
|
+
* core forwarder (injectMeshSystemMessage) keys on to pick a remote coordinator
|
|
11
|
+
* target; meshNodeFor/meshNodeId identify the worker, and launchedByCoordinator is
|
|
12
|
+
* the delegation proof. See resolveWorkerDelegateRouting().
|
|
13
|
+
*/
|
|
14
|
+
export interface MeshWorkerRelayStamp {
|
|
15
|
+
meshNodeFor?: string;
|
|
16
|
+
meshNodeId?: string;
|
|
17
|
+
meshCoordinatorDaemonId?: string;
|
|
18
|
+
launchedByCoordinator?: boolean;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Build the relay-safety stamp from a dispatch's meshContext, only including fields
|
|
22
|
+
* the session does not already carry. Returns undefined when there is nothing new to
|
|
23
|
+
* stamp, so callers can skip a no-op updateSettings() write.
|
|
24
|
+
*
|
|
25
|
+
* This closes the remote-session relay gap: a worker session reached by a dispatch
|
|
26
|
+
* that carries coordinatorDaemonId (mesh_send_task / queue assignment over P2P) gets
|
|
27
|
+
* the coordinator anchor persisted onto its settings at dispatch time, even if it was
|
|
28
|
+
* not launched via mesh_launch_session. Without the stamp the forwarder cannot resolve
|
|
29
|
+
* a remote coordinator and the completion event sits in the pending queue until a
|
|
30
|
+
* read_chat-triggered reconcile drains it.
|
|
31
|
+
*/
|
|
32
|
+
export declare function buildMeshWorkerRelayStamp(currentSettings: Record<string, unknown> | undefined, meshContext: {
|
|
33
|
+
meshId?: unknown;
|
|
34
|
+
nodeId?: unknown;
|
|
35
|
+
coordinatorDaemonId?: unknown;
|
|
36
|
+
} | undefined): MeshWorkerRelayStamp | undefined;
|
|
37
|
+
export declare function resolveEventSessionId(event: Record<string, unknown>, fallback?: unknown): string;
|
|
38
|
+
export declare function readRefineJobId(event: {
|
|
39
|
+
metadataEvent?: Record<string, unknown>;
|
|
40
|
+
} | Record<string, unknown>): string;
|
|
41
|
+
export declare function readWorkerResultMetadata(event: Record<string, unknown>): Record<string, unknown> | undefined;
|
|
42
|
+
export declare function buildMeshSystemMessage(args: {
|
|
43
|
+
event: string;
|
|
44
|
+
nodeLabel: string;
|
|
45
|
+
metadataEvent: Record<string, unknown>;
|
|
46
|
+
recoveryContext?: SessionRecoveryContext | null;
|
|
47
|
+
}): string;
|
|
@@ -1,49 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
workspace?: string;
|
|
8
|
-
metadataEvent: Record<string, unknown>;
|
|
9
|
-
queuedAt: number;
|
|
10
|
-
}
|
|
11
|
-
export declare function queuePendingMeshCoordinatorEvent(event: PendingMeshCoordinatorEvent): boolean;
|
|
12
|
-
/** Drain and return all pending coordinator events for meshId, removing them from disk. */
|
|
13
|
-
export declare function drainPendingMeshCoordinatorEvents(meshId?: string): PendingMeshCoordinatorEvent[];
|
|
14
|
-
/** Peek at pending coordinator events without draining (non-destructive). */
|
|
15
|
-
export declare function getPendingMeshCoordinatorEvents(meshId?: string): readonly PendingMeshCoordinatorEvent[];
|
|
16
|
-
/** Explicitly clear all pending coordinator events for a mesh. */
|
|
17
|
-
export declare function clearPendingMeshCoordinatorEvents(meshId?: string): void;
|
|
18
|
-
export declare function tryAssignQueueTask(components: DaemonComponents, meshId: string, nodeId: string, sessionId: string, providerType: string): boolean;
|
|
19
|
-
/**
|
|
20
|
-
* Triggers a queue check for all nodes in the mesh.
|
|
21
|
-
* Called when a new task is enqueued, in case nodes are already idle.
|
|
22
|
-
*/
|
|
23
|
-
export declare function triggerMeshQueue(components: DaemonComponents, meshId: string): Promise<void>;
|
|
24
|
-
export declare function handleMeshForwardEvent(components: DaemonComponents, payload: Record<string, unknown>): {
|
|
25
|
-
success: boolean;
|
|
26
|
-
forwarded: number;
|
|
27
|
-
suppressed: boolean;
|
|
28
|
-
intentionalCleanupStop: boolean;
|
|
29
|
-
duplicateCompletion?: undefined;
|
|
30
|
-
error?: undefined;
|
|
31
|
-
} | {
|
|
32
|
-
success: boolean;
|
|
33
|
-
forwarded: number;
|
|
34
|
-
suppressed: boolean;
|
|
35
|
-
duplicateCompletion: boolean;
|
|
36
|
-
intentionalCleanupStop?: undefined;
|
|
37
|
-
error?: undefined;
|
|
38
|
-
} | {
|
|
39
|
-
success: boolean;
|
|
40
|
-
forwarded: number;
|
|
41
|
-
suppressed?: undefined;
|
|
42
|
-
intentionalCleanupStop?: undefined;
|
|
43
|
-
duplicateCompletion?: undefined;
|
|
44
|
-
error?: undefined;
|
|
45
|
-
} | {
|
|
46
|
-
success: boolean;
|
|
47
|
-
error: string;
|
|
48
|
-
};
|
|
49
|
-
export declare function setupMeshEventForwarding(components: DaemonComponents): void;
|
|
1
|
+
export type { PendingMeshCoordinatorEvent } from './mesh-events-pending.js';
|
|
2
|
+
export { queuePendingMeshCoordinatorEvent, drainPendingMeshCoordinatorEvents, getPendingMeshCoordinatorEvents, clearPendingMeshCoordinatorEvents, } from './mesh-events-pending.js';
|
|
3
|
+
export { reconcileDirectDispatchCompletionFromTranscript, } from './mesh-events-stale.js';
|
|
4
|
+
export { setupMeshReconcileLoop, runMeshReconcileTick, } from './mesh-reconcile-loop.js';
|
|
5
|
+
export type { MeshQueueTriggerResult } from './mesh-events-coordinator.js';
|
|
6
|
+
export { tryAssignQueueTask, triggerMeshQueue, handleMeshForwardEvent, setupMeshEventForwarding, isMeshCoordinatorEvent, __resetIdleAutoFastForwardForTests, __resetMeshWorkspaceCacheForTests, } from './mesh-events-coordinator.js';
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { GitRepoStatus } from '../git/git-types.js';
|
|
2
|
+
export interface MeshFastForwardNodeArgs {
|
|
3
|
+
nodeId?: string;
|
|
4
|
+
meshId?: string;
|
|
5
|
+
workspace: string;
|
|
6
|
+
branch?: string;
|
|
7
|
+
execute?: boolean;
|
|
8
|
+
dryRun?: boolean;
|
|
9
|
+
updateSubmodules?: boolean;
|
|
10
|
+
submoduleIgnorePaths?: string[];
|
|
11
|
+
timeoutMs?: number;
|
|
12
|
+
trigger?: 'manual' | 'idle_auto' | string;
|
|
13
|
+
/**
|
|
14
|
+
* Operation mode. 'merge' (default) absorbs upstream commits into the local
|
|
15
|
+
* branch via git merge --ff-only (requires ahead=0, behind>0). 'push' publishes
|
|
16
|
+
* local commits to origin via a strict ff-only push (requires HEAD to be a
|
|
17
|
+
* descendant of origin/<branch>); it never force-pushes, resets, or rebases.
|
|
18
|
+
*/
|
|
19
|
+
mode?: 'merge' | 'push';
|
|
20
|
+
/**
|
|
21
|
+
* When mode='push', also fast-forward push submodule (e.g. oss) HEADs to their
|
|
22
|
+
* origin main branch. Gated by allowAutoPublishSubmoduleMainCommits — skipped
|
|
23
|
+
* unless that policy is true. Each submodule must still pass the descendant gate.
|
|
24
|
+
* Defaults false (root push only).
|
|
25
|
+
*/
|
|
26
|
+
pushSubmodules?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Mesh policy flag mirrored from RepoMeshPolicy.allowAutoPublishSubmoduleMainCommits.
|
|
29
|
+
* Submodule pushes are refused unless this is true.
|
|
30
|
+
*/
|
|
31
|
+
allowAutoPublishSubmoduleMainCommits?: boolean;
|
|
32
|
+
}
|
|
33
|
+
export interface MeshFastForwardPlannedStep {
|
|
34
|
+
operation: 'refresh_upstream' | 'verify_clean_worktree' | 'verify_fast_forward' | 'merge_ff_only' | 'submodule_update' | 'verify_post_status' | 'verify_push_descendant' | 'push_ff_only' | 'push_submodules_ff_only';
|
|
35
|
+
description: string;
|
|
36
|
+
safe: true;
|
|
37
|
+
willMutateWorktree: boolean;
|
|
38
|
+
}
|
|
39
|
+
export interface MeshFastForwardSubmodulePushResult {
|
|
40
|
+
path: string;
|
|
41
|
+
commit?: string;
|
|
42
|
+
remote: string;
|
|
43
|
+
remoteBranch: string;
|
|
44
|
+
pushed: boolean;
|
|
45
|
+
skipped: boolean;
|
|
46
|
+
code: string;
|
|
47
|
+
refspec?: string;
|
|
48
|
+
error?: string;
|
|
49
|
+
}
|
|
50
|
+
export interface MeshFastForwardResult {
|
|
51
|
+
success: boolean;
|
|
52
|
+
code: string;
|
|
53
|
+
nodeId?: string;
|
|
54
|
+
meshId?: string;
|
|
55
|
+
workspace: string;
|
|
56
|
+
mode: 'merge' | 'push';
|
|
57
|
+
allowed: boolean;
|
|
58
|
+
dryRun: boolean;
|
|
59
|
+
willRun: boolean;
|
|
60
|
+
executed: boolean;
|
|
61
|
+
updateSubmodules: boolean;
|
|
62
|
+
blockingReasons: string[];
|
|
63
|
+
plannedSteps: MeshFastForwardPlannedStep[];
|
|
64
|
+
current?: GitRepoStatus;
|
|
65
|
+
preStatus?: GitRepoStatus;
|
|
66
|
+
postStatus?: GitRepoStatus;
|
|
67
|
+
/** Push target derived from the tracked upstream (mode='push'). */
|
|
68
|
+
pushTarget?: {
|
|
69
|
+
remote: string;
|
|
70
|
+
remoteBranch: string;
|
|
71
|
+
refspec: string;
|
|
72
|
+
};
|
|
73
|
+
/** Submodule ff-only push outcomes (mode='push' with pushSubmodules). */
|
|
74
|
+
submodulePushes?: MeshFastForwardSubmodulePushResult[];
|
|
75
|
+
finalBranchConvergenceState?: Record<string, unknown>;
|
|
76
|
+
operationError?: string;
|
|
77
|
+
ledgerError?: string;
|
|
78
|
+
nextStep?: string;
|
|
79
|
+
trigger?: string;
|
|
80
|
+
}
|
|
81
|
+
export declare function fastForwardMeshNode(args: MeshFastForwardNodeArgs): Promise<MeshFastForwardResult>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { RepoMeshDaemonRole, RepoMeshHostMetadata, RepoMeshHostStatus } from '../repo-mesh-types.js';
|
|
2
|
+
export declare function normalizeMeshDaemonRole(value: unknown): RepoMeshDaemonRole | undefined;
|
|
3
|
+
export declare function resolveMeshHostStatus(mesh: unknown): RepoMeshHostStatus;
|
|
4
|
+
export declare function isMeshHostOwner(mesh: unknown): boolean;
|
|
5
|
+
export declare function buildMeshHostRequiredFailure(mesh: unknown, operation: string): Record<string, unknown>;
|
|
6
|
+
export declare function requireMeshHostQueueOwner(opts?: {
|
|
7
|
+
ownerRole?: RepoMeshDaemonRole;
|
|
8
|
+
}): void;
|
|
9
|
+
export declare function createDefaultMeshHostMetadata(): RepoMeshHostMetadata;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mesh init / onboarding helper.
|
|
3
|
+
*
|
|
4
|
+
* One-shot helper that onboards an existing git project into Repo Mesh:
|
|
5
|
+
* 1. suggest + write `.adhdev/refine.json` (Refinery validation config)
|
|
6
|
+
* 2. suggest + write `.adhdev/worktree_bootstrap.json` (worktree bootstrap config)
|
|
7
|
+
* 3. recommend a node providerPriority from the installed CLI providers
|
|
8
|
+
*
|
|
9
|
+
* Design contract (matches the rest of the mesh tooling):
|
|
10
|
+
* - Heuristics are suggestion/scaffold only. The written files are the
|
|
11
|
+
* execution source of truth; Refinery/bootstrap only ever read the saved
|
|
12
|
+
* config. The suggestion functions never become the execution path.
|
|
13
|
+
* - Writing is opt-in (`write: true`) and never clobbers an existing config
|
|
14
|
+
* unless `overwrite: true` is set, so re-running init on an already-onboarded
|
|
15
|
+
* repo is safe.
|
|
16
|
+
* - The providerPriority recommendation is returned, not auto-applied to the
|
|
17
|
+
* node policy — applying it mutates mesh policy, which is the coordinator's
|
|
18
|
+
* decision.
|
|
19
|
+
*/
|
|
20
|
+
import { type RepoMeshRefineConfig, type RepoMeshRefineValidationCommandConfig } from './refine-config.js';
|
|
21
|
+
import { type RepoMeshWorktreeBootstrapConfig } from './worktree-bootstrap-config.js';
|
|
22
|
+
import type { CLIInfo } from '../detection/cli-detector.js';
|
|
23
|
+
/** Canonical write targets — the first/preferred location for each config family. */
|
|
24
|
+
export declare const MESH_INIT_REFINE_CONFIG_PATH: string;
|
|
25
|
+
export declare const MESH_INIT_WORKTREE_BOOTSTRAP_CONFIG_PATH: string;
|
|
26
|
+
export interface MeshInitConfigFileResult {
|
|
27
|
+
path: string;
|
|
28
|
+
relativePath: string;
|
|
29
|
+
written: boolean;
|
|
30
|
+
/** Why it was not written (already_exists / not_suggested / no change). */
|
|
31
|
+
skippedReason?: 'already_exists' | 'no_suggestion';
|
|
32
|
+
config?: RepoMeshRefineConfig | RepoMeshWorktreeBootstrapConfig;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Build a worktree_bootstrap scaffold from package scripts. Mirrors
|
|
36
|
+
* suggestMeshRefineConfig's "scaffold only" posture: prefers an `install`/`ci`
|
|
37
|
+
* style script, else falls back to `npm install`, and records existing
|
|
38
|
+
* lockfiles as staleInputs so a base merge that changes them re-runs bootstrap.
|
|
39
|
+
*
|
|
40
|
+
* Returns undefined when there is nothing meaningful to scaffold.
|
|
41
|
+
*/
|
|
42
|
+
export declare function suggestMeshWorktreeBootstrapConfig(workspace: string): {
|
|
43
|
+
commands: RepoMeshRefineValidationCommandConfig[];
|
|
44
|
+
staleInputs: string[];
|
|
45
|
+
suggestedConfig?: RepoMeshWorktreeBootstrapConfig;
|
|
46
|
+
};
|
|
47
|
+
export declare function suggestNodeProviderPriority(detected: CLIInfo[]): {
|
|
48
|
+
providerPriority: string[];
|
|
49
|
+
installedProviders: Array<{
|
|
50
|
+
id: string;
|
|
51
|
+
displayName: string;
|
|
52
|
+
version?: string;
|
|
53
|
+
}>;
|
|
54
|
+
};
|
|
55
|
+
export interface RunMeshInitOptions {
|
|
56
|
+
/** When true, persist suggested configs to disk. Defaults to dry-run (false). */
|
|
57
|
+
write?: boolean;
|
|
58
|
+
/** When true, overwrite an existing config file. Defaults to false (never clobber). */
|
|
59
|
+
overwrite?: boolean;
|
|
60
|
+
}
|
|
61
|
+
export interface RunMeshInitResult {
|
|
62
|
+
success: true;
|
|
63
|
+
workspace: string;
|
|
64
|
+
dryRun: boolean;
|
|
65
|
+
refine: MeshInitConfigFileResult;
|
|
66
|
+
worktreeBootstrap: MeshInitConfigFileResult;
|
|
67
|
+
providers: {
|
|
68
|
+
providerPriority: string[];
|
|
69
|
+
installedProviders: Array<{
|
|
70
|
+
id: string;
|
|
71
|
+
displayName: string;
|
|
72
|
+
version?: string;
|
|
73
|
+
}>;
|
|
74
|
+
};
|
|
75
|
+
note: string;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Orchestrate the full onboarding flow for one workspace:
|
|
79
|
+
* detect installed CLIs → suggest refine + bootstrap configs → (optionally)
|
|
80
|
+
* write them → recommend a node providerPriority.
|
|
81
|
+
*
|
|
82
|
+
* `detected` is injected (the caller resolves it via detectCLIs with its
|
|
83
|
+
* ProviderLoader) so this module stays free of provider-loader wiring and is
|
|
84
|
+
* trivially unit-testable.
|
|
85
|
+
*/
|
|
86
|
+
export declare function runMeshInit(mesh: any, workspace: string, detected: CLIInfo[], options?: RunMeshInitOptions): RunMeshInitResult;
|
|
@@ -1,4 +1,24 @@
|
|
|
1
|
-
import type { AppendRemoteLedgerResult,
|
|
1
|
+
import type { AppendRemoteLedgerResult, MeshLedgerSummary } from './mesh-ledger.js';
|
|
2
|
+
/** Minimal ledger slice shape accepted by buildMeshLedgerReplicaEvidence. Covers both JSONL and SQLite slices. */
|
|
3
|
+
export interface AnyLedgerSlice {
|
|
4
|
+
entries: Array<{
|
|
5
|
+
id: string;
|
|
6
|
+
meshId: string;
|
|
7
|
+
timestamp: string;
|
|
8
|
+
kind: string;
|
|
9
|
+
nodeId?: string | null;
|
|
10
|
+
sessionId?: string | null;
|
|
11
|
+
providerType?: string | null;
|
|
12
|
+
payload: unknown;
|
|
13
|
+
}>;
|
|
14
|
+
cursor: {
|
|
15
|
+
afterId: string | null;
|
|
16
|
+
nextAfterId: string | null;
|
|
17
|
+
limit: number;
|
|
18
|
+
hasMore: boolean;
|
|
19
|
+
};
|
|
20
|
+
summary?: MeshLedgerSummary;
|
|
21
|
+
}
|
|
2
22
|
export type MeshLedgerReplicaStatus = 'local' | 'queried' | 'imported' | 'failed';
|
|
3
23
|
export interface MeshLedgerReplicaEvidence {
|
|
4
24
|
nodeId: string;
|
|
@@ -22,7 +42,7 @@ export interface MeshLedgerReconciliationEvidence {
|
|
|
22
42
|
meshId: string;
|
|
23
43
|
generatedAt: string;
|
|
24
44
|
sourceOfTruth: {
|
|
25
|
-
kind: '
|
|
45
|
+
kind: 'coordinator_local_sqlite';
|
|
26
46
|
p2pOnly: true;
|
|
27
47
|
cloudD1LedgerSync: false;
|
|
28
48
|
notes: string;
|
|
@@ -47,7 +67,7 @@ export declare function buildMeshLedgerReplicaEvidence(args: {
|
|
|
47
67
|
nodeId: string;
|
|
48
68
|
daemonId?: string;
|
|
49
69
|
transport: 'local' | 'p2p_datachannel';
|
|
50
|
-
slice?:
|
|
70
|
+
slice?: AnyLedgerSlice;
|
|
51
71
|
importResult?: AppendRemoteLedgerResult;
|
|
52
72
|
status?: MeshLedgerReplicaStatus;
|
|
53
73
|
error?: string;
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
* Safety: mode 0o600, atomic append via appendFileSync
|
|
14
14
|
*/
|
|
15
15
|
import { EventEmitter } from 'events';
|
|
16
|
-
|
|
16
|
+
import { MeshRuntimeStore } from './mesh-runtime-store.js';
|
|
17
|
+
export type MeshLedgerKind = 'task_dispatched' | 'task_completed' | 'task_failed' | 'task_stalled' | 'task_approval_needed' | 'p2p_dispatch_failed' | 'session_launched' | 'session_auto_launch' | 'session_stopped' | 'checkpoint_created' | 'node_cloned' | 'node_joined' | 'node_removed' | 'coordinator_started' | 'recovery_attempted' | 'ledger_replicated' | 'ledger_reconciled' | 'direct_fast_forward' | 'delivery_unroutable' | 'direct_dispatch_pruned';
|
|
17
18
|
export interface MeshLedgerEntry {
|
|
18
19
|
id: string;
|
|
19
20
|
meshId: string;
|
|
@@ -25,6 +26,40 @@ export interface MeshLedgerEntry {
|
|
|
25
26
|
payload: Record<string, unknown>;
|
|
26
27
|
}
|
|
27
28
|
export declare function isIntentionalCleanupStopEntry(entry: Pick<MeshLedgerEntry, 'kind' | 'payload'>): boolean;
|
|
29
|
+
export type MeshWorkerResultStatus = 'completed' | 'failed' | 'blocked' | 'partial' | 'unknown';
|
|
30
|
+
export type MeshProcessArtifactKind = 'process' | 'log' | 'port' | 'window' | 'session' | 'file' | 'url' | 'other';
|
|
31
|
+
export interface MeshValidationResultArtifact {
|
|
32
|
+
command?: string;
|
|
33
|
+
status: 'passed' | 'failed' | 'skipped' | 'unknown';
|
|
34
|
+
durationMs?: number;
|
|
35
|
+
outputPath?: string;
|
|
36
|
+
summary?: string;
|
|
37
|
+
}
|
|
38
|
+
export interface MeshProcessArtifact {
|
|
39
|
+
kind: MeshProcessArtifactKind;
|
|
40
|
+
id?: string;
|
|
41
|
+
label?: string;
|
|
42
|
+
locator?: string;
|
|
43
|
+
pid?: number;
|
|
44
|
+
port?: number;
|
|
45
|
+
url?: string;
|
|
46
|
+
path?: string;
|
|
47
|
+
sessionId?: string;
|
|
48
|
+
keepRunning?: boolean;
|
|
49
|
+
metadata?: Record<string, unknown>;
|
|
50
|
+
}
|
|
51
|
+
export interface MeshWorkerResultArtifact {
|
|
52
|
+
status: MeshWorkerResultStatus;
|
|
53
|
+
classification?: string;
|
|
54
|
+
changedFiles: string[];
|
|
55
|
+
validationResults: MeshValidationResultArtifact[];
|
|
56
|
+
gitStatus?: Record<string, unknown>;
|
|
57
|
+
processArtifacts: MeshProcessArtifact[];
|
|
58
|
+
errors: string[];
|
|
59
|
+
nextAction?: string;
|
|
60
|
+
requiresUserAction: boolean;
|
|
61
|
+
source: 'explicit_metadata' | 'final_summary_json' | 'default';
|
|
62
|
+
}
|
|
28
63
|
export interface MeshTaskCompletionEvidence {
|
|
29
64
|
source: 'agent_status_event';
|
|
30
65
|
event: 'agent:generating_completed' | 'agent:ready';
|
|
@@ -38,6 +73,7 @@ export interface MeshTaskCompletionEvidence {
|
|
|
38
73
|
providerSessionId?: string;
|
|
39
74
|
finalSummaryAvailable: boolean;
|
|
40
75
|
};
|
|
76
|
+
workerResult: MeshWorkerResultArtifact;
|
|
41
77
|
git: {
|
|
42
78
|
status: 'deferred';
|
|
43
79
|
reason: string;
|
|
@@ -59,6 +95,7 @@ export interface BuildTaskCompletionEvidenceOptions {
|
|
|
59
95
|
providerType?: string;
|
|
60
96
|
providerSessionId?: string;
|
|
61
97
|
finalSummary?: string;
|
|
98
|
+
workerResult?: Record<string, unknown>;
|
|
62
99
|
completedAt?: string;
|
|
63
100
|
}
|
|
64
101
|
export interface MeshLedgerSummary {
|
|
@@ -115,6 +152,27 @@ export interface AppendRemoteLedgerResult {
|
|
|
115
152
|
}
|
|
116
153
|
export declare const MAX_LEDGER_SLICE_LIMIT = 500;
|
|
117
154
|
export declare function getLedgerDir(): string;
|
|
155
|
+
/**
|
|
156
|
+
* Footer to append to worker task messages so workers output structured results
|
|
157
|
+
* that the daemon parses via extractJsonObjectFromSummary / normalizeMeshWorkerResult.
|
|
158
|
+
*
|
|
159
|
+
* Usage: append buildWorkerTaskFooter() to the task message in mesh_send_task /
|
|
160
|
+
* mesh_enqueue_task. The coordinator prompt rules instruct coordinators to do this.
|
|
161
|
+
*/
|
|
162
|
+
export declare function buildWorkerTaskFooter(): string;
|
|
163
|
+
/**
|
|
164
|
+
* Compact the active ledger file for a mesh by moving old terminal entries
|
|
165
|
+
* (task_completed, task_failed, task_stalled, recovery_attempted older than 7 days)
|
|
166
|
+
* to <meshId>.archive.jsonl, keeping the active file lean.
|
|
167
|
+
*
|
|
168
|
+
* Non-terminal entries (dispatch, sessions, node lifecycle) are always retained.
|
|
169
|
+
* Called automatically from appendLedgerEntry when the file exceeds COMPACT_THRESHOLD_BYTES.
|
|
170
|
+
*/
|
|
171
|
+
export declare function compactLedger(meshId: string): {
|
|
172
|
+
archivedCount: number;
|
|
173
|
+
retainedCount: number;
|
|
174
|
+
};
|
|
175
|
+
export declare function normalizeMeshWorkerResult(input?: Record<string, unknown>, source?: MeshWorkerResultArtifact['source']): MeshWorkerResultArtifact;
|
|
118
176
|
export declare function buildTaskCompletionEvidence(opts: BuildTaskCompletionEvidenceOptions): MeshTaskCompletionEvidence;
|
|
119
177
|
/**
|
|
120
178
|
* Append a new entry to the mesh ledger.
|
|
@@ -127,8 +185,16 @@ export declare function appendLedgerEntry(meshId: string, partial: Omit<MeshLedg
|
|
|
127
185
|
* This skips deduplicated entries and rejects malformed/cross-mesh entries.
|
|
128
186
|
*/
|
|
129
187
|
export declare function appendRemoteLedgerEntries(meshId: string, entries: MeshLedgerEntry[]): AppendRemoteLedgerResult;
|
|
188
|
+
/**
|
|
189
|
+
* Test helper: clear all runtime ledger state for a mesh — SQLite rows, read
|
|
190
|
+
* cache, and the one-time import flag. JSONL files are the caller's concern.
|
|
191
|
+
*/
|
|
192
|
+
export declare function __clearMeshLedgerForTests(meshId: string): void;
|
|
130
193
|
/**
|
|
131
194
|
* Read ledger entries with optional filtering.
|
|
195
|
+
* G2: SQLite (mesh_event_ledger) is the primary read path; legacy JSONL is
|
|
196
|
+
* imported once per store instance and otherwise retained as an
|
|
197
|
+
* export/import/debug artifact only.
|
|
132
198
|
*/
|
|
133
199
|
export declare function readLedgerEntries(meshId: string, opts?: ReadLedgerOptions): MeshLedgerEntry[];
|
|
134
200
|
/**
|
|
@@ -137,6 +203,16 @@ export declare function readLedgerEntries(meshId: string, opts?: ReadLedgerOptio
|
|
|
137
203
|
* remote daemons on demand without Cloud/D1 becoming a ledger data-plane.
|
|
138
204
|
*/
|
|
139
205
|
export declare function readLedgerSlice(meshId: string, opts?: ReadLedgerSliceOptions): MeshLedgerSlice;
|
|
206
|
+
/**
|
|
207
|
+
* G4: Read a bounded ledger slice from the SQLite mesh_event_ledger table.
|
|
208
|
+
* This is the preferred P2P reconcile read path; JSONL files are retained as
|
|
209
|
+
* export/import/debug/legacy artifacts only.
|
|
210
|
+
*
|
|
211
|
+
* Returns a shape structurally compatible with MeshLedgerSlice (minus the
|
|
212
|
+
* JSONL-specific `summary` and `sourceOfTruth.path` fields) so callers can
|
|
213
|
+
* pass it to buildMeshLedgerReplicaEvidence without modification.
|
|
214
|
+
*/
|
|
215
|
+
export declare function readLedgerSliceFromStore(meshId: string, opts?: ReadLedgerSliceOptions): ReturnType<typeof MeshRuntimeStore.prototype.readLedgerSlice>;
|
|
140
216
|
/**
|
|
141
217
|
* Get a summary of mesh activity from the ledger.
|
|
142
218
|
*/
|