@adhdev/daemon-core 0.9.82-rc.31 → 0.9.82-rc.311
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 +214 -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 +34705 -11938
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +38412 -15757
- 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 +169 -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 +395 -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 +204 -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 +217 -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 +180 -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 +291 -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 +1822 -61
- 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 +6041 -589
- package/src/commands/stream-commands.ts +8 -0
- package/src/commands/upgrade-helper.ts +29 -0
- package/src/config/chat-history.ts +483 -24
- package/src/config/config.ts +12 -0
- package/src/config/mesh-config.ts +320 -4
- 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 +142 -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 +1942 -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 +1565 -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 +703 -140
- 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 +980 -0
- package/src/providers/spec/evaluator.ts +345 -0
- package/src/providers/spec/fsm-driver.ts +888 -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 +1035 -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 +226 -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 +376 -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
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
* IMPORTANT: This file must remain runtime-free (types only).
|
|
12
12
|
*/
|
|
13
13
|
import type { GitRepoStatus, GitCompactSummary } from './git/git-types.js';
|
|
14
|
+
import type { MeshMissionSummary, MeshMissionSlimSummary } from './mesh/mesh-missions.js';
|
|
14
15
|
export interface RepoMesh {
|
|
15
16
|
id: string;
|
|
16
17
|
name: string;
|
|
@@ -19,10 +20,37 @@ export interface RepoMesh {
|
|
|
19
20
|
defaultBranch?: string;
|
|
20
21
|
policy: RepoMeshPolicy;
|
|
21
22
|
coordinator: RepoMeshCoordinatorConfig;
|
|
23
|
+
meshHost?: RepoMeshHostMetadata;
|
|
22
24
|
projectContext: ProjectContextSnapshot;
|
|
23
25
|
nodes: RepoMeshNode[];
|
|
24
26
|
status: 'active' | 'archived' | 'deleted';
|
|
25
27
|
}
|
|
28
|
+
export type RepoMeshDaemonRole = 'host' | 'member';
|
|
29
|
+
export interface RepoMeshHostPairingMetadata {
|
|
30
|
+
status: 'not_configured' | 'pairing' | 'paired' | 'rejected' | 'revoked';
|
|
31
|
+
tokenId?: string;
|
|
32
|
+
joinedAt?: string;
|
|
33
|
+
lastPairedAt?: string;
|
|
34
|
+
lastRejectedAt?: string;
|
|
35
|
+
expiresAt?: string;
|
|
36
|
+
}
|
|
37
|
+
export interface RepoMeshHostMetadata {
|
|
38
|
+
/** Local daemon role for this mesh. Missing metadata defaults to host for standalone compatibility. */
|
|
39
|
+
role: RepoMeshDaemonRole;
|
|
40
|
+
/** Daemon that owns mesh truth/status/git/queue/session/ledger/coordinator ownership. */
|
|
41
|
+
hostDaemonId?: string;
|
|
42
|
+
/** Mesh node that represents the host daemon, when known. */
|
|
43
|
+
hostNodeId?: string;
|
|
44
|
+
/** Future standalone manual pairing endpoint entered by member daemons. */
|
|
45
|
+
hostAddress?: string;
|
|
46
|
+
/** Redacted pairing state only; raw join tokens must not be persisted here. */
|
|
47
|
+
pairing?: RepoMeshHostPairingMetadata;
|
|
48
|
+
}
|
|
49
|
+
export interface RepoMeshHostStatus extends RepoMeshHostMetadata {
|
|
50
|
+
canOwnCoordinator: boolean;
|
|
51
|
+
canOwnQueue: boolean;
|
|
52
|
+
defaulted: boolean;
|
|
53
|
+
}
|
|
26
54
|
export interface RepoMeshNode {
|
|
27
55
|
id: string;
|
|
28
56
|
daemonId: string;
|
|
@@ -37,31 +65,137 @@ export interface RepoMeshNode {
|
|
|
37
65
|
effectiveCapabilities: RepoMeshNodeCapabilities;
|
|
38
66
|
policy: RepoMeshNodePolicy;
|
|
39
67
|
health: RepoMeshNodeHealth;
|
|
68
|
+
role?: RepoMeshDaemonRole;
|
|
40
69
|
status: 'enabled' | 'disabled' | 'removed';
|
|
41
70
|
}
|
|
42
71
|
export type RepoMeshNodeHealth = 'online' | 'offline' | 'degraded' | 'dirty' | 'wrong_branch' | 'unknown';
|
|
43
72
|
export type RepoMeshSessionCleanupMode = 'preserve' | 'stop' | 'delete_stopped' | 'stop_and_delete';
|
|
44
73
|
export type RepoMeshSpawnedSessionVisibility = 'visible' | 'hidden';
|
|
74
|
+
/**
|
|
75
|
+
* Mesh-wide tie-break strategy for distributing untargeted queue work across
|
|
76
|
+
* eligible nodes. This ONLY governs the final tie-break stage of the scheduler
|
|
77
|
+
* pipeline (TAG hard-filter → MAX-ALLOC capacity gate → PRIORITY soft score →
|
|
78
|
+
* TIE-BREAK); eligibility/capacity/priority are evaluated identically for every
|
|
79
|
+
* strategy.
|
|
80
|
+
*
|
|
81
|
+
* - 'first_eligible' (DEFAULT): preserve today's behavior exactly. Nodes are
|
|
82
|
+
* visited in config/array order and the first that can launch wins. No
|
|
83
|
+
* load-spreading. This is the strict no-change default — a mesh that never
|
|
84
|
+
* sets schedulingStrategy behaves identically to before this feature.
|
|
85
|
+
* - 'least_loaded': prefer the eligible node with the fewest active assignments,
|
|
86
|
+
* so untargeted work spreads instead of piling onto whichever node asks first.
|
|
87
|
+
* - 'round_robin': among nodes tied at the least load, rotate the winner using a
|
|
88
|
+
* per-mesh cursor so distribution stays fair across passes.
|
|
89
|
+
* - 'priority_only': rank purely by schedulingPriority (then config order),
|
|
90
|
+
* ignoring load — always send to the highest-priority eligible node.
|
|
91
|
+
*
|
|
92
|
+
* Distribution is explicit opt-in: a strategy other than 'first_eligible' must be
|
|
93
|
+
* configured for any load-spreading to occur.
|
|
94
|
+
*/
|
|
95
|
+
export type RepoMeshSchedulingStrategy = 'first_eligible' | 'least_loaded' | 'round_robin' | 'priority_only';
|
|
96
|
+
export declare const MESH_SCHEDULING_STRATEGIES: RepoMeshSchedulingStrategy[];
|
|
97
|
+
export declare const DEFAULT_MESH_SCHEDULING_STRATEGY: RepoMeshSchedulingStrategy;
|
|
98
|
+
/**
|
|
99
|
+
* Normalize an unknown scheduling-strategy value to a valid strategy, defaulting
|
|
100
|
+
* to 'first_eligible' (strict no-change) for anything missing/blank/unrecognized.
|
|
101
|
+
*/
|
|
102
|
+
export declare function normalizeMeshSchedulingStrategy(value: unknown): RepoMeshSchedulingStrategy;
|
|
103
|
+
/**
|
|
104
|
+
* Resolve a node's soft scheduling priority — a single scalar used as the PRIORITY
|
|
105
|
+
* stage rank key (higher = preferred). It is NOT an eligibility gate (the MAX-ALLOC
|
|
106
|
+
* capacity gate alone decides whether a node can take work). Missing/blank/NaN
|
|
107
|
+
* resolves to 0 so unconfigured nodes all share the same neutral priority.
|
|
108
|
+
*/
|
|
109
|
+
export declare function resolveNodeSchedulingPriority(nodePolicy: Pick<RepoMeshNodePolicy, 'schedulingPriority'> | null | undefined): number;
|
|
110
|
+
/**
|
|
111
|
+
* Synthetic capability tag advertised by every mesh node describing how it can land
|
|
112
|
+
* its work onto the base branch:
|
|
113
|
+
* - converge=refine: a local worktree node (on any machine — refine_mesh_node
|
|
114
|
+
* forwards to the owning daemon) can run the Refinery merge → push → cleanup.
|
|
115
|
+
* - converge=fast_forward: a non-worktree node (the machine itself) can only
|
|
116
|
+
* fast-forward/push an already-converged branch.
|
|
117
|
+
* Emitted by buildMeshNodeCapabilityTags and matched through the ordinary
|
|
118
|
+
* required-tags filter.
|
|
119
|
+
*/
|
|
120
|
+
export declare const MESH_CONVERGE_REFINE_TAG = "converge=refine";
|
|
121
|
+
export declare const MESH_CONVERGE_FAST_FORWARD_TAG = "converge=fast_forward";
|
|
122
|
+
/**
|
|
123
|
+
* Resolve whether the load-balancing scheduler should auto-inject a
|
|
124
|
+
* `converge=refine` required tag onto code_change tasks so they hard-filter onto
|
|
125
|
+
* refine-capable (worktree) nodes only. Strict opt-in: defaults to false, so a mesh
|
|
126
|
+
* that does not set it behaves exactly as before (code_change routes to any eligible
|
|
127
|
+
* node, including a non-worktree machine node when no worktree exists).
|
|
128
|
+
*/
|
|
129
|
+
export declare function resolveAutoConvergeCodeChange(policy: Pick<RepoMeshPolicy, 'autoConvergeCodeChange'> | null | undefined): boolean;
|
|
130
|
+
export interface RepoMeshAutoFastForwardPolicy {
|
|
131
|
+
/** Defaults to true. Set false to disable daemon-initiated idle fast-forwards. */
|
|
132
|
+
enabled: boolean;
|
|
133
|
+
/** Maximum behind count eligible for automatic fast-forward. Missing means no limit. */
|
|
134
|
+
maxBehind?: number;
|
|
135
|
+
/** Defaults to true. Require submodule status to be clean before automatic fast-forward. */
|
|
136
|
+
requireCleanSubmodules?: boolean;
|
|
137
|
+
}
|
|
45
138
|
export interface RepoMeshPolicy {
|
|
46
139
|
requirePreTaskCheckpoint: boolean;
|
|
47
140
|
requirePostTaskCheckpoint: boolean;
|
|
48
141
|
requireApprovalForPush: boolean;
|
|
142
|
+
/**
|
|
143
|
+
* Narrow Refinery opt-in: when validation and patch-equivalence have passed,
|
|
144
|
+
* allow Refinery to publish submodule gitlink commits to each submodule's
|
|
145
|
+
* configured remote main branch with a non-force push, then verify reachability.
|
|
146
|
+
* Defaults to false; root branch pushes/merges are not affected.
|
|
147
|
+
*/
|
|
148
|
+
allowAutoPublishSubmoduleMainCommits?: boolean;
|
|
49
149
|
requireApprovalForDestructiveGit: boolean;
|
|
50
150
|
dirtyWorkspaceBehavior: 'block' | 'warn' | 'checkpoint_then_continue';
|
|
51
151
|
maxParallelTasks: number;
|
|
52
152
|
allowedProviders?: string[];
|
|
153
|
+
/**
|
|
154
|
+
* Mesh-wide tie-break strategy for distributing untargeted queue work across
|
|
155
|
+
* eligible nodes. Defaults to 'first_eligible' (today's exact behavior — no
|
|
156
|
+
* load-spreading). Set to 'least_loaded' / 'round_robin' / 'priority_only' to
|
|
157
|
+
* opt into distribution. Only governs the final tie-break stage; eligibility,
|
|
158
|
+
* capacity, and priority are evaluated identically regardless of strategy.
|
|
159
|
+
*/
|
|
160
|
+
schedulingStrategy?: RepoMeshSchedulingStrategy;
|
|
161
|
+
/**
|
|
162
|
+
* Convergence routing opt-in: when true, the scheduler auto-injects a
|
|
163
|
+
* `converge=refine` required tag onto every code_change task at enqueue time, so
|
|
164
|
+
* code_change work hard-filters onto refine-capable worktree nodes (on any
|
|
165
|
+
* machine — refine_mesh_node forwards to the owning daemon) and never lands on a
|
|
166
|
+
* non-worktree machine node. Explicit target_node_id routing and any
|
|
167
|
+
* caller-supplied required_tags are preserved (the tag is merged, not replaced).
|
|
168
|
+
* Defaults to false: code_change routing is unchanged unless opted in.
|
|
169
|
+
*/
|
|
170
|
+
autoConvergeCodeChange?: boolean;
|
|
53
171
|
/**
|
|
54
172
|
* Whether sessions spawned by mesh/coordinator policy should auto-open as visible
|
|
55
173
|
* dashboard tabs or start hidden. Defaults to 'visible' to preserve existing
|
|
56
174
|
* watch-the-agents behavior; hidden sessions remain discoverable and manually openable.
|
|
57
175
|
*/
|
|
58
176
|
spawnedSessionVisibility?: RepoMeshSpawnedSessionVisibility;
|
|
177
|
+
/**
|
|
178
|
+
* Whether worker sessions the coordinator dispatches should auto-approve agent
|
|
179
|
+
* approval modals (tool/command prompts) without firing a user-facing approval
|
|
180
|
+
* notification. Delegated workers are coordinator-driven, so a human should not
|
|
181
|
+
* have to approve each one; defaults to true. Set to false to make delegated
|
|
182
|
+
* worker sessions stop at approval modals like an interactive session.
|
|
183
|
+
* Stamped into the worker launch settings envelope as `autoApprove`, which wins
|
|
184
|
+
* over the global per-provider-type autoApprove config via the settings merge.
|
|
185
|
+
* A node policy may override this per-node (RepoMeshNodePolicy.delegatedWorkerAutoApprove).
|
|
186
|
+
*/
|
|
187
|
+
delegatedWorkerAutoApprove?: boolean;
|
|
59
188
|
/**
|
|
60
189
|
* What to do with delegated session-host records for a node when it is removed.
|
|
61
190
|
* Defaults to 'preserve' so completed work can be reviewed later and live
|
|
62
191
|
* runtimes are never stopped/deleted unless the mesh owner opts in.
|
|
63
192
|
*/
|
|
64
193
|
sessionCleanupOnNodeRemove?: RepoMeshSessionCleanupMode;
|
|
194
|
+
/**
|
|
195
|
+
* Daemon-initiated fast-forward for idle clean nodes that are only behind
|
|
196
|
+
* their tracked upstream. Defaults to enabled.
|
|
197
|
+
*/
|
|
198
|
+
autoFastForward?: RepoMeshAutoFastForwardPolicy;
|
|
65
199
|
/**
|
|
66
200
|
* Maximum number of automatic retry recommendations for a failed task on the
|
|
67
201
|
* same node before the daemon advises the coordinator to escalate or reassign.
|
|
@@ -75,12 +209,67 @@ export interface RepoMeshRelatedRepo {
|
|
|
75
209
|
/** Absolute checkout/workspace path for git freshness probes. */
|
|
76
210
|
workspace: string;
|
|
77
211
|
}
|
|
212
|
+
/**
|
|
213
|
+
* Per-(node, provider) role + parallelism declaration.
|
|
214
|
+
*
|
|
215
|
+
* `role` is a free-form resource-pool label (recommended values:
|
|
216
|
+
* 'investigation' | 'coding' | 'orchestration') describing what this
|
|
217
|
+
* (node, provider) combination is *for*. As of the load-balancing scheduler it
|
|
218
|
+
* is ALSO routable: each declared role is advertised as a synthetic `role=<x>`
|
|
219
|
+
* capability tag (see buildMeshNodeCapabilityTags), so a task enqueued with
|
|
220
|
+
* requiredTags: ["role=validation"] is hard-filtered to nodes/providers that
|
|
221
|
+
* declare that role — through the same nodeSatisfiesRequiredTags path as any
|
|
222
|
+
* other tag. There is intentionally no separate "advertisedRoles" field: the
|
|
223
|
+
* label and the routing tag are one mechanism. A task that does not require a
|
|
224
|
+
* `role=` tag ignores roles entirely (opt-in, fully backward compatible).
|
|
225
|
+
*
|
|
226
|
+
* role is intentionally orthogonal to taskMode: taskMode classifies the *work*
|
|
227
|
+
* (code_change vs live_debug_readonly), role classifies the *resource pool*.
|
|
228
|
+
*
|
|
229
|
+
* `maxParallel` is the only enforced field: the queue will not assign a task
|
|
230
|
+
* to this (node, provider) once it already has `maxParallel` active
|
|
231
|
+
* (status='assigned') tasks. When the global parallel cap and this per-(node,
|
|
232
|
+
* provider) cap disagree, the stricter (lower effective) limit wins — a claim
|
|
233
|
+
* must satisfy both. Omitting `maxParallel` means this provider is bounded only
|
|
234
|
+
* by the global/taskMode caps (full backward compatibility).
|
|
235
|
+
*/
|
|
236
|
+
export interface RepoMeshProviderRole {
|
|
237
|
+
/** Provider type this entry governs (e.g. 'claude-cli', 'codex-cli'). */
|
|
238
|
+
providerType: string;
|
|
239
|
+
/** Free-form role label; recommended: 'investigation' | 'coding' | 'orchestration'. */
|
|
240
|
+
role?: string;
|
|
241
|
+
/** Max concurrent active tasks for this (node, provider). Omit = no per-provider cap. */
|
|
242
|
+
maxParallel?: number;
|
|
243
|
+
}
|
|
78
244
|
export interface RepoMeshNodePolicy {
|
|
79
245
|
readOnly?: boolean;
|
|
80
246
|
canPush?: boolean;
|
|
81
247
|
maxConcurrentSessions?: number;
|
|
248
|
+
/**
|
|
249
|
+
* Soft scheduling priority used as the PRIORITY rank key (higher = preferred)
|
|
250
|
+
* when the mesh schedulingStrategy spreads work across nodes. Defaults to 0.
|
|
251
|
+
* This is NOT an eligibility gate — a node with a high priority that is at its
|
|
252
|
+
* capacity (MAX-ALLOC gate) is still skipped; priority only orders nodes that
|
|
253
|
+
* can actually take work. Ignored entirely under 'first_eligible'.
|
|
254
|
+
*/
|
|
255
|
+
schedulingPriority?: number;
|
|
82
256
|
/** Ordered provider preference used when mesh_launch_session omits an explicit type. */
|
|
83
257
|
providerPriority?: string[];
|
|
258
|
+
/**
|
|
259
|
+
* Per-(node, provider) role + parallelism declarations. Each entry binds a
|
|
260
|
+
* providerType on THIS node to an optional free-form role label and an
|
|
261
|
+
* optional maxParallel cap. maxParallel is enforced (as an additional,
|
|
262
|
+
* stricter-wins constraint on top of the global maxParallelTasks/taskMode
|
|
263
|
+
* caps); role is advertised as a routable `role=<x>` capability tag so tasks
|
|
264
|
+
* can hard-filter by required role. Missing/empty: the node behaves exactly
|
|
265
|
+
* as before (global caps only, no role tags).
|
|
266
|
+
*/
|
|
267
|
+
providerRoles?: RepoMeshProviderRole[];
|
|
268
|
+
/**
|
|
269
|
+
* Per-node override for RepoMeshPolicy.delegatedWorkerAutoApprove. When set, takes
|
|
270
|
+
* precedence over the mesh-level policy for worker sessions launched onto this node.
|
|
271
|
+
*/
|
|
272
|
+
delegatedWorkerAutoApprove?: boolean;
|
|
84
273
|
/**
|
|
85
274
|
* Optional associated/external repos that must be checked alongside this node.
|
|
86
275
|
* These are explicit policy/config entries only; Repo Mesh does not auto-discover
|
|
@@ -104,6 +293,28 @@ export interface RepoMeshNodePolicy {
|
|
|
104
293
|
initSubmodulesOnClone?: boolean;
|
|
105
294
|
}
|
|
106
295
|
export declare const DEFAULT_MESH_POLICY: RepoMeshPolicy;
|
|
296
|
+
/**
|
|
297
|
+
* Resolve whether a delegated worker session launched onto `nodePolicy` (within a mesh
|
|
298
|
+
* governed by `meshPolicy`) should auto-approve. Precedence: node override → mesh policy
|
|
299
|
+
* → default true. The result is stamped into the worker launch settings envelope as
|
|
300
|
+
* `autoApprove`; it wins over the global per-provider-type autoApprove config because the
|
|
301
|
+
* launch path merges the envelope as a settingsOverride on top of the provider defaults.
|
|
302
|
+
*/
|
|
303
|
+
export declare function resolveDelegatedWorkerAutoApprove(meshPolicy?: Pick<RepoMeshPolicy, 'delegatedWorkerAutoApprove'> | null, nodePolicy?: Pick<RepoMeshNodePolicy, 'delegatedWorkerAutoApprove'> | null): boolean;
|
|
304
|
+
/**
|
|
305
|
+
* Resolve the per-(node, provider) role declaration from a node policy.
|
|
306
|
+
* Case-insensitive, trimmed match on providerType. Returns undefined when the
|
|
307
|
+
* node has no providerRoles entry for this provider (caller then applies only
|
|
308
|
+
* the global caps). Defensive against malformed config — non-object entries and
|
|
309
|
+
* blank providerTypes are skipped rather than throwing.
|
|
310
|
+
*/
|
|
311
|
+
export declare function resolveProviderRole(nodePolicy: Pick<RepoMeshNodePolicy, 'providerRoles'> | null | undefined, providerType: string | null | undefined): RepoMeshProviderRole | undefined;
|
|
312
|
+
/**
|
|
313
|
+
* Resolve the enforced per-(node, provider) maxParallel cap, or undefined when
|
|
314
|
+
* no finite, non-negative cap is declared for this provider. Used by the queue
|
|
315
|
+
* claim path as a stricter-wins constraint layered on top of the global caps.
|
|
316
|
+
*/
|
|
317
|
+
export declare function resolveProviderMaxParallel(nodePolicy: Pick<RepoMeshNodePolicy, 'providerRoles'> | null | undefined, providerType: string | null | undefined): number | undefined;
|
|
107
318
|
export interface RepoMeshNodeCapabilities {
|
|
108
319
|
platform?: string;
|
|
109
320
|
packageManagers?: string[];
|
|
@@ -167,7 +378,28 @@ export interface RepoMeshCoordinatorConfig {
|
|
|
167
378
|
providerType?: string;
|
|
168
379
|
/** Preferred node to run coordinator on (null = auto) */
|
|
169
380
|
preferredNodeId?: string;
|
|
170
|
-
/**
|
|
381
|
+
/**
|
|
382
|
+
* Full mesh-level override for the coordinator system prompt. When set,
|
|
383
|
+
* replaces the daemon's rendered default and any user-file override
|
|
384
|
+
* (~/.adhdev/coordinator-prompts/<cli>.md). The per-launch
|
|
385
|
+
* extraSystemPrompt still composes on top — it always lands last as
|
|
386
|
+
* Additional Context. Supports the same {{placeholders}} the daemon's
|
|
387
|
+
* default template uses ({{meshName}}, {{repo}}, {{nodes}}, …).
|
|
388
|
+
*/
|
|
389
|
+
systemPromptOverride?: string;
|
|
390
|
+
/**
|
|
391
|
+
* Mesh-level append. Composes after whichever base prompt won
|
|
392
|
+
* (override → user-file override → daemon default). Use this when you
|
|
393
|
+
* want extra rules for THIS mesh but otherwise the standard prompt is
|
|
394
|
+
* fine. Stacks with the user-file append (`<cli>.append.md`) — both
|
|
395
|
+
* apply if both are set.
|
|
396
|
+
*/
|
|
397
|
+
systemPromptAppend?: string;
|
|
398
|
+
/**
|
|
399
|
+
* @deprecated Use systemPromptAppend. Kept as a fallback alias so
|
|
400
|
+
* existing meshes.json files keep working without a migration step;
|
|
401
|
+
* the daemon prefers systemPromptAppend when both are present.
|
|
402
|
+
*/
|
|
171
403
|
systemPromptSuffix?: string;
|
|
172
404
|
}
|
|
173
405
|
/**
|
|
@@ -185,6 +417,7 @@ export interface LocalMeshEntry {
|
|
|
185
417
|
defaultBranch?: string;
|
|
186
418
|
policy: RepoMeshPolicy;
|
|
187
419
|
coordinator: RepoMeshCoordinatorConfig;
|
|
420
|
+
meshHost?: RepoMeshHostMetadata;
|
|
188
421
|
nodes: LocalMeshNodeEntry[];
|
|
189
422
|
createdAt: string;
|
|
190
423
|
updatedAt: string;
|
|
@@ -196,16 +429,42 @@ export interface LocalMeshNodeEntry {
|
|
|
196
429
|
daemonId?: string;
|
|
197
430
|
/** Machine registry ID that owns this workspace, when known. */
|
|
198
431
|
machineId?: string;
|
|
432
|
+
/** Operator-defined capability tags used by mesh queue matching. */
|
|
433
|
+
capabilities?: string[];
|
|
199
434
|
userOverrides: Partial<RepoMeshNodeCapabilities>;
|
|
200
435
|
policy: RepoMeshNodePolicy;
|
|
436
|
+
/**
|
|
437
|
+
* Per-node instruction surfaced in the coordinator prompt so the LLM
|
|
438
|
+
* knows what each node is for (e.g. "this is the staging mirror — run
|
|
439
|
+
* only smoke tests here", or "use opus on this node, sonnet elsewhere").
|
|
440
|
+
* Empty/missing: omitted silently from the rendered prompt, no rule
|
|
441
|
+
* line about it gets added. The coordinator forwards/honors it when
|
|
442
|
+
* delegating; we don't enforce it at the daemon level.
|
|
443
|
+
*/
|
|
444
|
+
systemPrompt?: string;
|
|
201
445
|
/** For single-machine mesh: same daemon, different worktree */
|
|
202
446
|
isLocalWorktree?: boolean;
|
|
203
447
|
/** Branch this worktree tracks (set when created via clone_mesh_node) */
|
|
204
448
|
worktreeBranch?: string;
|
|
205
449
|
/** Node ID this worktree was cloned from */
|
|
206
450
|
clonedFromNodeId?: string;
|
|
451
|
+
/** Repo-local preparation result for ADHDev-created worktree nodes. */
|
|
452
|
+
worktreeBootstrap?: {
|
|
453
|
+
status: 'ready' | 'running' | 'failed' | 'not_configured' | 'disabled' | 'stale';
|
|
454
|
+
required?: boolean;
|
|
455
|
+
configSource?: string;
|
|
456
|
+
configSourceType?: string;
|
|
457
|
+
startedAt?: string;
|
|
458
|
+
completedAt?: string;
|
|
459
|
+
lastCommand?: string;
|
|
460
|
+
exitCode?: number | null;
|
|
461
|
+
error?: string;
|
|
462
|
+
commandsRun?: Array<Record<string, unknown>>;
|
|
463
|
+
staleInputs?: string[];
|
|
464
|
+
};
|
|
207
465
|
/** Optional associated/external repos configured as node metadata. */
|
|
208
466
|
relatedRepos?: RepoMeshRelatedRepo[];
|
|
467
|
+
role?: RepoMeshDaemonRole;
|
|
209
468
|
}
|
|
210
469
|
export interface RepoMeshStatus {
|
|
211
470
|
meshId: string;
|
|
@@ -213,22 +472,25 @@ export interface RepoMeshStatus {
|
|
|
213
472
|
repoIdentity: string;
|
|
214
473
|
defaultBranch?: string;
|
|
215
474
|
refreshedAt: string;
|
|
475
|
+
meshHost?: RepoMeshHostStatus;
|
|
216
476
|
nodes: RepoMeshNodeStatus[];
|
|
217
477
|
queue?: RepoMeshQueueStatus;
|
|
218
478
|
ledger?: RepoMeshLedgerStatus;
|
|
479
|
+
/**
|
|
480
|
+
* Mission summaries for the dashboard overview. Active/paused missions plus a
|
|
481
|
+
* capped, newest-first slice of completed/abandoned history. Omitted by older
|
|
482
|
+
* daemons — the dashboard must treat this as optional and render an empty
|
|
483
|
+
* state when absent. Split on each entry's `status` for live vs. history.
|
|
484
|
+
*
|
|
485
|
+
* Compact (the default) status calls send the slim shape — `goalPreview` +
|
|
486
|
+
* `goalTruncated` instead of the full `goal` — while verbose sends the full
|
|
487
|
+
* `goal`. Consumers must read `goal ?? goalPreview`. Each entry may also carry
|
|
488
|
+
* an optional `stats` operational rollup (durations / retries).
|
|
489
|
+
*/
|
|
490
|
+
missions?: (MeshMissionSummary | MeshMissionSlimSummary)[];
|
|
219
491
|
}
|
|
220
|
-
export
|
|
221
|
-
|
|
222
|
-
providerType?: string;
|
|
223
|
-
state?: string;
|
|
224
|
-
lifecycle?: 'starting' | 'running' | 'stopping' | 'stopped' | 'failed' | 'interrupted';
|
|
225
|
-
surfaceKind?: 'live_runtime' | 'recovery_snapshot' | 'inactive_record';
|
|
226
|
-
recoveryState?: string | null;
|
|
227
|
-
workspace?: string | null;
|
|
228
|
-
title?: string | null;
|
|
229
|
-
lastActivityAt?: string | null;
|
|
230
|
-
isCached?: boolean;
|
|
231
|
-
}
|
|
492
|
+
export type { RepoMeshSessionStatus } from '@adhdev/mesh-shared';
|
|
493
|
+
import type { RepoMeshSessionStatus } from '@adhdev/mesh-shared';
|
|
232
494
|
export type RepoMeshPeerConnectionState = 'self' | 'connected' | 'connecting' | 'disconnected' | 'failed' | 'closed' | 'unknown';
|
|
233
495
|
export type RepoMeshPeerConnectionTransport = 'local' | 'direct' | 'relay' | 'unknown';
|
|
234
496
|
export interface RepoMeshPeerConnectionStatus {
|
|
@@ -249,9 +511,12 @@ export interface RepoMeshNodeStatus {
|
|
|
249
511
|
repoRoot?: string;
|
|
250
512
|
daemonId?: string;
|
|
251
513
|
machineId?: string;
|
|
514
|
+
role?: RepoMeshDaemonRole;
|
|
252
515
|
machineStatus?: string;
|
|
253
516
|
isLocalWorktree?: boolean;
|
|
254
517
|
worktreeBranch?: string;
|
|
518
|
+
/** Mirrored from LocalMeshNodeEntry.systemPrompt for coordinator-prompt rendering. */
|
|
519
|
+
systemPrompt?: string;
|
|
255
520
|
health: RepoMeshNodeHealth;
|
|
256
521
|
git?: GitRepoStatus;
|
|
257
522
|
/**
|
|
@@ -265,6 +530,14 @@ export interface RepoMeshNodeStatus {
|
|
|
265
530
|
activeSessionDetails?: RepoMeshSessionStatus[];
|
|
266
531
|
providerPriority?: string[];
|
|
267
532
|
launchReady?: boolean;
|
|
533
|
+
/** True when the node is clean, ahead=0, behind>0, and safe for fast-forward consideration. */
|
|
534
|
+
autoFastForwardEligible?: boolean;
|
|
535
|
+
/** Coordinator-facing suggestion for obvious clean catch-up work. */
|
|
536
|
+
suggestedAction?: 'auto_fast_forward';
|
|
537
|
+
worktreeBootstrap?: LocalMeshNodeEntry['worktreeBootstrap'];
|
|
538
|
+
launchBlockedReason?: string;
|
|
539
|
+
launchBlockedMessage?: string;
|
|
540
|
+
recoveryHint?: string;
|
|
268
541
|
lastSeenAt?: string;
|
|
269
542
|
updatedAt?: string;
|
|
270
543
|
connection?: RepoMeshPeerConnectionStatus;
|
|
@@ -352,3 +625,8 @@ export interface RepoMeshLedgerStatus {
|
|
|
352
625
|
entries: RepoMeshLedgerEntryStatus[];
|
|
353
626
|
summary: RepoMeshLedgerSummaryStatus;
|
|
354
627
|
}
|
|
628
|
+
export interface MeshAsyncJobLifecycle {
|
|
629
|
+
startedAt?: string;
|
|
630
|
+
completedAt?: string;
|
|
631
|
+
error?: string;
|
|
632
|
+
}
|
|
@@ -7,6 +7,12 @@ export interface SessionRuntimeTarget {
|
|
|
7
7
|
cdpManagerKey?: string;
|
|
8
8
|
adapterKey?: string;
|
|
9
9
|
instanceKey?: string;
|
|
10
|
+
/** Working directory for CLI/ACP sessions. Used by read_chat to resolve
|
|
11
|
+
* native history when there is no live adapter (e.g. subscription path). */
|
|
12
|
+
workspace?: string;
|
|
13
|
+
/** Wall clock at register time. native-history readers use it as a
|
|
14
|
+
* cutoff so a fresh session can't show records from a prior one. */
|
|
15
|
+
spawnedAtMs?: number;
|
|
10
16
|
}
|
|
11
17
|
export declare class SessionRegistry {
|
|
12
18
|
private readonly bySessionId;
|
|
@@ -18,12 +18,10 @@ export interface RuntimeAttachedClient {
|
|
|
18
18
|
readOnly: boolean;
|
|
19
19
|
}
|
|
20
20
|
/** Session status union (used by SessionEntry.status, legacy recent-launch metadata, etc.) */
|
|
21
|
-
export type SessionStatus = 'idle' | 'generating' | 'waiting_approval' | 'error' | 'stopped' | 'starting' | 'panel_hidden' | 'not_monitored' | 'disconnected';
|
|
21
|
+
export type SessionStatus = 'idle' | 'generating' | 'waiting_approval' | 'waiting_choice' | 'error' | 'stopped' | 'starting' | 'panel_hidden' | 'not_monitored' | 'disconnected';
|
|
22
22
|
/** Inbox bucket categories for recent sessions */
|
|
23
23
|
export type RecentSessionBucket = 'needs_attention' | 'working' | 'task_complete' | 'idle';
|
|
24
24
|
/** Terminal backend status */
|
|
25
25
|
export interface TerminalBackendStatus {
|
|
26
|
-
backend: '
|
|
27
|
-
preference: 'auto' | 'xterm' | 'ghostty-vt';
|
|
28
|
-
ghosttyAvailable: boolean;
|
|
26
|
+
backend: 'ghostty-vt';
|
|
29
27
|
}
|
package/dist/shared-types.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ import type { ActiveChatData as _ActiveChatData, ProviderErrorReason as _Provide
|
|
|
14
14
|
import type { WorkspaceEntry } from './config/workspaces.js';
|
|
15
15
|
import type { ProviderMeshCoordinatorConfig, ProviderResumeCapability } from './providers/contracts.js';
|
|
16
16
|
import type { GitCompactSummary, GitWorkspaceUpdate, WorkspaceGitSubscriptionParams } from './git/git-types.js';
|
|
17
|
+
import type { InteractivePrompt } from './providers/types/interactive-prompt.js';
|
|
17
18
|
export type { GitCommandName, GitCompactSummary, GitDiffSummary, GitFailureReason, GitFileChange, GitFileChangeStatus, GitRepoIdentity, GitRepoStatus, GitSnapshot, GitSnapshotCompareSummary, GitSnapshotReason, GitWorkspaceUpdate, WorkspaceGitSubscriptionParams, } from './git/git-types.js';
|
|
18
19
|
export interface SessionActiveChatData extends Omit<_ActiveChatData, 'messages'> {
|
|
19
20
|
messages?: _ActiveChatData['messages'];
|
|
@@ -49,6 +50,14 @@ export interface ReadChatSyncResult {
|
|
|
49
50
|
message: string;
|
|
50
51
|
buttons: string[];
|
|
51
52
|
} | null;
|
|
53
|
+
activeInteractivePrompt?: InteractivePrompt | null;
|
|
54
|
+
/**
|
|
55
|
+
* Chat source provenance from ChatSourceMachine (A2). Carries the
|
|
56
|
+
* selected source, transition cause, lock state, and legacy
|
|
57
|
+
* fallbackReason — opaque to the daemon-core, consumed by web-core
|
|
58
|
+
* for the source debug badge and SourceTimeline (A3).
|
|
59
|
+
*/
|
|
60
|
+
messageSource?: Record<string, unknown>;
|
|
52
61
|
}
|
|
53
62
|
export interface ProviderSummaryItem {
|
|
54
63
|
id: string;
|
|
@@ -268,6 +277,7 @@ export interface SessionEntry {
|
|
|
268
277
|
runtimeRecoveryState?: string | null;
|
|
269
278
|
resume?: ProviderResumeCapability;
|
|
270
279
|
activeChat: SessionActiveChatData | null;
|
|
280
|
+
activeInteractivePrompt?: InteractivePrompt | null;
|
|
271
281
|
capabilities?: SessionCapability[];
|
|
272
282
|
/** Effective message input/media support for this session. Defaults fail-closed to text-only. */
|
|
273
283
|
messageInput?: MessageInputSupport;
|
|
@@ -292,6 +302,11 @@ export interface SessionEntry {
|
|
|
292
302
|
seenCompletionMarker?: string;
|
|
293
303
|
surfaceHidden?: boolean;
|
|
294
304
|
settings?: Record<string, any>;
|
|
305
|
+
/** Set when this session is acting as a mesh coordinator for the given mesh. */
|
|
306
|
+
coordinator?: {
|
|
307
|
+
meshId: string;
|
|
308
|
+
role: 'coordinator';
|
|
309
|
+
};
|
|
295
310
|
meshQueueStats?: {
|
|
296
311
|
total?: number;
|
|
297
312
|
active?: number;
|
|
@@ -410,7 +425,33 @@ export interface AvailableProviderInfo {
|
|
|
410
425
|
lastVerification?: MachineProviderCheckResult;
|
|
411
426
|
/** Provider-declared Repo Mesh coordinator/MCP behavior. */
|
|
412
427
|
meshCoordinator?: ProviderMeshCoordinatorConfig;
|
|
413
|
-
|
|
428
|
+
/**
|
|
429
|
+
* Provider trust classification — derived from the on-disk layer the
|
|
430
|
+
* manifest came from and the shape of the manifest. Dashboards use
|
|
431
|
+
* this to render a trust badge and gate activation of
|
|
432
|
+
* `external-untrusted` providers behind a confirm modal.
|
|
433
|
+
*/
|
|
434
|
+
trust?: ProviderTrust;
|
|
435
|
+
/** Daemon-side human-readable description of the trust value. */
|
|
436
|
+
trustDescription?: string;
|
|
437
|
+
/** True when activation needs a user-side confirmation step. */
|
|
438
|
+
requiresConfirmation?: boolean;
|
|
439
|
+
/** Which on-disk layer the manifest lives in. */
|
|
440
|
+
sourceLayer?: 'user' | 'upstream' | 'external';
|
|
441
|
+
/** For external providers, the source-name namespace it came from. */
|
|
442
|
+
sourceName?: string | null;
|
|
443
|
+
/** Manifest-declared version, e.g. "1.2.1". */
|
|
444
|
+
providerVersion?: string;
|
|
445
|
+
/** Underlying executable name (CLI/binary providers). */
|
|
446
|
+
binary?: string;
|
|
447
|
+
/** Lifecycle label from the manifest: "Stable", "Beta", … */
|
|
448
|
+
status?: string;
|
|
449
|
+
/** One-line provider description from the manifest. */
|
|
450
|
+
details?: string;
|
|
451
|
+
/** Manifest-declared links: homepage, docs, repo, … */
|
|
452
|
+
links?: Record<string, string>;
|
|
453
|
+
}
|
|
454
|
+
export type ProviderTrust = 'user-custom' | 'trusted' | 'trusted-with-scripts' | 'external-safe' | 'external-untrusted';
|
|
414
455
|
export interface MachineProviderCheckResult {
|
|
415
456
|
ok: boolean;
|
|
416
457
|
stage?: 'detection' | 'runnable' | 'verification';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ActiveChatData } from '../providers/provider-instance.js';
|
|
2
2
|
import type { SessionActiveChatData } from '../shared-types.js';
|
|
3
|
-
export type ManagedStatus = 'idle' | 'generating' | 'waiting_approval' | 'error' | 'stopped' | 'starting' | 'panel_hidden' | 'not_monitored' | 'disconnected';
|
|
3
|
+
export type ManagedStatus = 'idle' | 'generating' | 'waiting_approval' | 'waiting_choice' | 'error' | 'stopped' | 'starting' | 'panel_hidden' | 'not_monitored' | 'disconnected';
|
|
4
4
|
export interface NormalizeActiveChatOptions {
|
|
5
5
|
includeMessages?: boolean;
|
|
6
6
|
includeInputContent?: boolean;
|
package/dist/status/normalize.js
CHANGED
|
@@ -119,6 +119,7 @@ function normalizeManagedStatus(status, opts) {
|
|
|
119
119
|
if (hasApprovalButtons(opts?.activeModal)) return "waiting_approval";
|
|
120
120
|
const normalized = String(status || "idle").trim().toLowerCase();
|
|
121
121
|
if (normalized === "waiting_approval") return "waiting_approval";
|
|
122
|
+
if (normalized === "waiting_choice") return "waiting_choice";
|
|
122
123
|
if (WORKING_STATUSES.has(normalized)) return "generating";
|
|
123
124
|
if (normalized === "error") return "error";
|
|
124
125
|
if (normalized === "stopped") return "stopped";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/status/normalize.ts"],"sourcesContent":["import type { ActiveChatData } from '../providers/provider-instance.js';\nimport type { SessionActiveChatData } from '../shared-types.js';\n\nexport type ManagedStatus =\n | 'idle'\n | 'generating'\n | 'waiting_approval'\n | 'error'\n | 'stopped'\n | 'starting'\n | 'panel_hidden'\n | 'not_monitored'\n | 'disconnected';\n\nconst WORKING_STATUSES = new Set([\n 'generating',\n 'streaming',\n 'loading',\n 'loading_reference',\n 'thinking',\n 'active',\n]);\n\nexport interface NormalizeActiveChatOptions {\n includeMessages?: boolean;\n includeInputContent?: boolean;\n includeActiveModal?: boolean;\n messageLimit?: number;\n totalBytesLimit?: number;\n stringLimit?: number;\n fallbackStringLimit?: number;\n}\n\n// Full snapshots are still capped, but can carry recent chat context for API/inspection use.\nconst FULL_STATUS_ACTIVE_CHAT_OPTIONS: Required<NormalizeActiveChatOptions> = {\n includeMessages: true,\n includeInputContent: true,\n includeActiveModal: true,\n messageLimit: 60,\n totalBytesLimit: 96 * 1024,\n stringLimit: 4 * 1024,\n fallbackStringLimit: 1024,\n};\n\n// Live/metadata snapshots only need routing + UI summary. Current chat text is loaded\n// on demand via `read_chat`, and older history via `chat_history`.\nexport const LIVE_STATUS_ACTIVE_CHAT_OPTIONS: Required<NormalizeActiveChatOptions> = {\n includeMessages: false,\n includeInputContent: false,\n includeActiveModal: false,\n messageLimit: 0,\n totalBytesLimit: 0,\n stringLimit: 512,\n fallbackStringLimit: 256,\n};\n\nconst STATUS_MODAL_MESSAGE_LIMIT = 2 * 1024;\nconst STATUS_MODAL_BUTTON_LIMIT = 120;\n\nfunction truncateString(value: string, maxChars: number): string {\n if (value.length <= maxChars) return value;\n if (maxChars <= 12) return value.slice(0, Math.max(0, maxChars));\n return `${value.slice(0, maxChars - 12)}...[truncated]`;\n}\n\nfunction truncateStringTail(value: string, maxChars: number): string {\n if (value.length <= maxChars) return value;\n if (maxChars <= 12) return value.slice(value.length - Math.max(0, maxChars));\n return `...[truncated]${value.slice(value.length - (maxChars - 12))}`;\n}\n\nfunction trimStructuredStrings(value: unknown, maxChars: number): unknown {\n if (typeof value === 'string') return truncateString(value, maxChars);\n if (Array.isArray(value)) return value.map((item) => trimStructuredStrings(item, maxChars));\n if (!value || typeof value !== 'object') return value;\n return Object.fromEntries(\n Object.entries(value).map(([key, nested]) => [key, trimStructuredStrings(nested, maxChars)]),\n );\n}\n\nfunction estimateBytes(value: unknown): number {\n try {\n return JSON.stringify(value).length;\n } catch {\n return String(value ?? '').length;\n }\n}\n\nfunction trimMessageForStatus(message: unknown, stringLimit: number): unknown {\n if (!message || typeof message !== 'object') return message;\n return trimStructuredStrings(message, stringLimit);\n}\n\n/**\n * Collapse timestamp / createdAt into receivedAt so downstream consumers\n * only ever need to read a single canonical time field.\n */\nfunction normalizeMessageTime(message: unknown): unknown {\n if (!message || typeof message !== 'object') return message;\n const msg = message as Record<string, unknown>;\n if (msg.receivedAt == null) {\n const fallback = msg.timestamp ?? msg.createdAt;\n if (fallback != null) {\n const ts = typeof fallback === 'string' ? Date.parse(fallback as string) : Number(fallback);\n if (Number.isFinite(ts) && ts > 0) msg.receivedAt = ts;\n }\n }\n return msg;\n}\n\nfunction trimMessagesForStatus(\n messages: unknown[] | null | undefined,\n options: Required<NormalizeActiveChatOptions>,\n): unknown[] {\n if (!options.includeMessages || options.messageLimit <= 0 || options.totalBytesLimit <= 0) return [];\n if (!Array.isArray(messages) || messages.length === 0) return [];\n\n const recent = messages.slice(-options.messageLimit);\n const kept: unknown[] = [];\n let totalBytes = 0;\n\n for (let i = recent.length - 1; i >= 0; i -= 1) {\n let normalized = normalizeMessageTime(trimMessageForStatus(recent[i], options.stringLimit));\n let size = estimateBytes(normalized);\n\n if (size > options.totalBytesLimit) {\n normalized = normalizeMessageTime(trimMessageForStatus(recent[i], options.fallbackStringLimit));\n size = estimateBytes(normalized);\n }\n\n if (kept.length > 0 && (totalBytes + size) > options.totalBytesLimit) {\n continue;\n }\n\n kept.push(normalized);\n totalBytes += size;\n }\n\n return kept.reverse();\n}\n\nfunction hasApprovalButtons(activeModal?: { buttons?: unknown[] | null } | null): boolean {\n return (activeModal?.buttons?.length ?? 0) > 0;\n}\n\nexport function normalizeManagedStatus(\n status?: string | null,\n opts?: { activeModal?: { buttons?: unknown[] | null } | null },\n): ManagedStatus {\n if (hasApprovalButtons(opts?.activeModal)) return 'waiting_approval';\n\n const normalized = String(status || 'idle').trim().toLowerCase();\n if (normalized === 'waiting_approval') return 'waiting_approval';\n if (WORKING_STATUSES.has(normalized)) return 'generating';\n if (normalized === 'error') return 'error';\n if (normalized === 'stopped') return 'stopped';\n if (normalized === 'starting') return 'starting';\n if (normalized === 'panel_hidden') return 'panel_hidden';\n if (normalized === 'not_monitored') return 'not_monitored';\n if (normalized === 'disconnected') return 'disconnected';\n return 'idle';\n}\n\nexport function isManagedStatusWorking(status?: string | null): boolean {\n return normalizeManagedStatus(status) === 'generating';\n}\n\nexport function isManagedStatusWaiting(\n status?: string | null,\n opts?: { activeModal?: { buttons?: unknown[] | null } | null },\n): boolean {\n return normalizeManagedStatus(status, opts) === 'waiting_approval';\n}\n\nexport function normalizeActiveChatData<T extends ActiveChatData | null | undefined>(\n activeChat: T,\n options: NormalizeActiveChatOptions = FULL_STATUS_ACTIVE_CHAT_OPTIONS,\n): T extends null | undefined ? T : SessionActiveChatData {\n if (!activeChat) return activeChat as T extends null | undefined ? T : SessionActiveChatData;\n const resolvedOptions: Required<NormalizeActiveChatOptions> = {\n ...FULL_STATUS_ACTIVE_CHAT_OPTIONS,\n ...options,\n };\n const {\n messages: _messages,\n ...rest\n } = activeChat;\n const normalized: SessionActiveChatData = {\n ...rest,\n status: normalizeManagedStatus(activeChat.status, { activeModal: activeChat.activeModal }),\n activeModal: resolvedOptions.includeActiveModal && activeChat.activeModal ? {\n message: truncateString(activeChat.activeModal.message || '', STATUS_MODAL_MESSAGE_LIMIT),\n buttons: (activeChat.activeModal.buttons || []).map((button) =>\n truncateString(String(button || ''), STATUS_MODAL_BUTTON_LIMIT)\n ),\n } : null,\n inputContent: resolvedOptions.includeInputContent && activeChat.inputContent\n ? truncateString(activeChat.inputContent, 2 * 1024)\n : undefined,\n };\n if (resolvedOptions.includeMessages) {\n normalized.messages = trimMessagesForStatus(activeChat.messages, resolvedOptions) as SessionActiveChatData['messages'];\n }\n return normalized as T extends null | undefined ? T : SessionActiveChatData;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAcA,IAAM,mBAAmB,oBAAI,IAAI;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ,CAAC;AAaD,IAAM,kCAAwE;AAAA,EAC1E,iBAAiB;AAAA,EACjB,qBAAqB;AAAA,EACrB,oBAAoB;AAAA,EACpB,cAAc;AAAA,EACd,iBAAiB,KAAK;AAAA,EACtB,aAAa,IAAI;AAAA,EACjB,qBAAqB;AACzB;AAIO,IAAM,kCAAwE;AAAA,EACjF,iBAAiB;AAAA,EACjB,qBAAqB;AAAA,EACrB,oBAAoB;AAAA,EACpB,cAAc;AAAA,EACd,iBAAiB;AAAA,EACjB,aAAa;AAAA,EACb,qBAAqB;AACzB;AAEA,IAAM,6BAA6B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Ae,eAAgB,QAAO;AAC1C,SAAO;AACX;AAEO,SAAS,uBAAuB,QAAiC;AACpE,SAAO,uBAAuB,MAAM,MAAM;AAC9C;AAEO,SAAS,uBACZ,QACA,MACO;AACP,SAAO,uBAAuB,QAAQ,IAAI,MAAM;AACpD;AAEO,SAAS,wBACZ,YACA,UAAsC,iCACgB;AACtD,MAAI,CAAC,WAAY,QAAO;AACxB,QAAM,kBAAwD;AAAA,IAC1D,GAAG;AAAA,IACH,GAAG;AAAA,EACP;AACA,QAAM;AAAA,IACF,UAAU;AAAA,IACV,GAAG;AAAA,EACP,IAAI;AACJ,QAAM,aAAoC;AAAA,IACtC,GAAG;AAAA,IACH,QAAQ,uBAAuB,WAAW,QAAQ,EAAE,aAAa,WAAW,YAAY,CAAC;AAAA,IACzF,aAAa,gBAAgB,sBAAsB,WAAW,cAAc;AAAA,MACxE,SAAS,eAAe,WAAW,YAAY,WAAW,IAAI,0BAA0B;AAAA,MACxF,UAAU,WAAW,YAAY,WAAW,CAAC,GAAG;AAAA,QAAI,CAAC,WACjD,eAAe,OAAO,UAAU,EAAE,GAAG,yBAAyB;AAAA,MAClE;AAAA,IACJ,IAAI;AAAA,IACJ,cAAc,gBAAgB,uBAAuB,WAAW,eAC1D,eAAe,WAAW,cAAc,IAAI,IAAI,IAChD;AAAA,EACV;AACA,MAAI,gBAAgB,iBAAiB;AACjC,eAAW,WAAW,sBAAsB,WAAW,UAAU,eAAe;AAAA,EACpF;AACA,SAAO;AACX;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/status/normalize.ts"],"sourcesContent":["import type { ActiveChatData } from '../providers/provider-instance.js';\nimport type { SessionActiveChatData } from '../shared-types.js';\n\nexport type ManagedStatus =\n | 'idle'\n | 'generating'\n | 'waiting_approval'\n | 'waiting_choice'\n | 'error'\n | 'stopped'\n | 'starting'\n | 'panel_hidden'\n | 'not_monitored'\n | 'disconnected';\n\nconst WORKING_STATUSES = new Set([\n 'generating',\n 'streaming',\n 'loading',\n 'loading_reference',\n 'thinking',\n 'active',\n]);\n\nexport interface NormalizeActiveChatOptions {\n includeMessages?: boolean;\n includeInputContent?: boolean;\n includeActiveModal?: boolean;\n messageLimit?: number;\n totalBytesLimit?: number;\n stringLimit?: number;\n fallbackStringLimit?: number;\n}\n\n// Full snapshots are still capped, but can carry recent chat context for API/inspection use.\nconst FULL_STATUS_ACTIVE_CHAT_OPTIONS: Required<NormalizeActiveChatOptions> = {\n includeMessages: true,\n includeInputContent: true,\n includeActiveModal: true,\n messageLimit: 60,\n totalBytesLimit: 96 * 1024,\n stringLimit: 4 * 1024,\n fallbackStringLimit: 1024,\n};\n\n// Live/metadata snapshots only need routing + UI summary. Current chat text is loaded\n// on demand via `read_chat`, and older history via `chat_history`.\nexport const LIVE_STATUS_ACTIVE_CHAT_OPTIONS: Required<NormalizeActiveChatOptions> = {\n includeMessages: false,\n includeInputContent: false,\n includeActiveModal: false,\n messageLimit: 0,\n totalBytesLimit: 0,\n stringLimit: 512,\n fallbackStringLimit: 256,\n};\n\nconst STATUS_MODAL_MESSAGE_LIMIT = 2 * 1024;\nconst STATUS_MODAL_BUTTON_LIMIT = 120;\n\nfunction truncateString(value: string, maxChars: number): string {\n if (value.length <= maxChars) return value;\n if (maxChars <= 12) return value.slice(0, Math.max(0, maxChars));\n return `${value.slice(0, maxChars - 12)}...[truncated]`;\n}\n\nfunction truncateStringTail(value: string, maxChars: number): string {\n if (value.length <= maxChars) return value;\n if (maxChars <= 12) return value.slice(value.length - Math.max(0, maxChars));\n return `...[truncated]${value.slice(value.length - (maxChars - 12))}`;\n}\n\nfunction trimStructuredStrings(value: unknown, maxChars: number): unknown {\n if (typeof value === 'string') return truncateString(value, maxChars);\n if (Array.isArray(value)) return value.map((item) => trimStructuredStrings(item, maxChars));\n if (!value || typeof value !== 'object') return value;\n return Object.fromEntries(\n Object.entries(value).map(([key, nested]) => [key, trimStructuredStrings(nested, maxChars)]),\n );\n}\n\nfunction estimateBytes(value: unknown): number {\n try {\n return JSON.stringify(value).length;\n } catch {\n return String(value ?? '').length;\n }\n}\n\nfunction trimMessageForStatus(message: unknown, stringLimit: number): unknown {\n if (!message || typeof message !== 'object') return message;\n return trimStructuredStrings(message, stringLimit);\n}\n\n/**\n * Collapse timestamp / createdAt into receivedAt so downstream consumers\n * only ever need to read a single canonical time field.\n */\nfunction normalizeMessageTime(message: unknown): unknown {\n if (!message || typeof message !== 'object') return message;\n const msg = message as Record<string, unknown>;\n if (msg.receivedAt == null) {\n const fallback = msg.timestamp ?? msg.createdAt;\n if (fallback != null) {\n const ts = typeof fallback === 'string' ? Date.parse(fallback as string) : Number(fallback);\n if (Number.isFinite(ts) && ts > 0) msg.receivedAt = ts;\n }\n }\n return msg;\n}\n\nfunction trimMessagesForStatus(\n messages: unknown[] | null | undefined,\n options: Required<NormalizeActiveChatOptions>,\n): unknown[] {\n if (!options.includeMessages || options.messageLimit <= 0 || options.totalBytesLimit <= 0) return [];\n if (!Array.isArray(messages) || messages.length === 0) return [];\n\n const recent = messages.slice(-options.messageLimit);\n const kept: unknown[] = [];\n let totalBytes = 0;\n\n for (let i = recent.length - 1; i >= 0; i -= 1) {\n let normalized = normalizeMessageTime(trimMessageForStatus(recent[i], options.stringLimit));\n let size = estimateBytes(normalized);\n\n if (size > options.totalBytesLimit) {\n normalized = normalizeMessageTime(trimMessageForStatus(recent[i], options.fallbackStringLimit));\n size = estimateBytes(normalized);\n }\n\n if (kept.length > 0 && (totalBytes + size) > options.totalBytesLimit) {\n continue;\n }\n\n kept.push(normalized);\n totalBytes += size;\n }\n\n return kept.reverse();\n}\n\nfunction hasApprovalButtons(activeModal?: { buttons?: unknown[] | null } | null): boolean {\n return (activeModal?.buttons?.length ?? 0) > 0;\n}\n\nexport function normalizeManagedStatus(\n status?: string | null,\n opts?: { activeModal?: { buttons?: unknown[] | null } | null },\n): ManagedStatus {\n if (hasApprovalButtons(opts?.activeModal)) return 'waiting_approval';\n\n const normalized = String(status || 'idle').trim().toLowerCase();\n if (normalized === 'waiting_approval') return 'waiting_approval';\n if (normalized === 'waiting_choice') return 'waiting_choice';\n if (WORKING_STATUSES.has(normalized)) return 'generating';\n if (normalized === 'error') return 'error';\n if (normalized === 'stopped') return 'stopped';\n if (normalized === 'starting') return 'starting';\n if (normalized === 'panel_hidden') return 'panel_hidden';\n if (normalized === 'not_monitored') return 'not_monitored';\n if (normalized === 'disconnected') return 'disconnected';\n return 'idle';\n}\n\nexport function isManagedStatusWorking(status?: string | null): boolean {\n return normalizeManagedStatus(status) === 'generating';\n}\n\nexport function isManagedStatusWaiting(\n status?: string | null,\n opts?: { activeModal?: { buttons?: unknown[] | null } | null },\n): boolean {\n return normalizeManagedStatus(status, opts) === 'waiting_approval';\n}\n\nexport function normalizeActiveChatData<T extends ActiveChatData | null | undefined>(\n activeChat: T,\n options: NormalizeActiveChatOptions = FULL_STATUS_ACTIVE_CHAT_OPTIONS,\n): T extends null | undefined ? T : SessionActiveChatData {\n if (!activeChat) return activeChat as T extends null | undefined ? T : SessionActiveChatData;\n const resolvedOptions: Required<NormalizeActiveChatOptions> = {\n ...FULL_STATUS_ACTIVE_CHAT_OPTIONS,\n ...options,\n };\n const {\n messages: _messages,\n ...rest\n } = activeChat;\n const normalized: SessionActiveChatData = {\n ...rest,\n status: normalizeManagedStatus(activeChat.status, { activeModal: activeChat.activeModal }),\n activeModal: resolvedOptions.includeActiveModal && activeChat.activeModal ? {\n message: truncateString(activeChat.activeModal.message || '', STATUS_MODAL_MESSAGE_LIMIT),\n buttons: (activeChat.activeModal.buttons || []).map((button) =>\n truncateString(String(button || ''), STATUS_MODAL_BUTTON_LIMIT)\n ),\n } : null,\n inputContent: resolvedOptions.includeInputContent && activeChat.inputContent\n ? truncateString(activeChat.inputContent, 2 * 1024)\n : undefined,\n };\n if (resolvedOptions.includeMessages) {\n normalized.messages = trimMessagesForStatus(activeChat.messages, resolvedOptions) as SessionActiveChatData['messages'];\n }\n return normalized as T extends null | undefined ? T : SessionActiveChatData;\n}\n"],"mappings":";;;;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D,eAAe,OAAO,UAAU,EAAE,GAAG,yBAAyB;AAAA,MAClE;AAAA,IACJ,IAAI;AAAA,IACJ,cAAc,gBAAgB,uBAAuB,WAAW,eAC1D,eAAe,WAAW,cAAc,IAAI,IAAI,IAChD;AAAA,EACV;AACA,MAAI,gBAAgB,iBAAiB;AACjC,eAAW,WAAW,sBAAsB,WAAW,UAAU,eAAe;AAAA,EACpF;AACA,SAAO;AACX;","names":[]}
|
|
@@ -91,6 +91,7 @@ function normalizeManagedStatus(status, opts) {
|
|
|
91
91
|
if (hasApprovalButtons(opts?.activeModal)) return "waiting_approval";
|
|
92
92
|
const normalized = String(status || "idle").trim().toLowerCase();
|
|
93
93
|
if (normalized === "waiting_approval") return "waiting_approval";
|
|
94
|
+
if (normalized === "waiting_choice") return "waiting_choice";
|
|
94
95
|
if (WORKING_STATUSES.has(normalized)) return "generating";
|
|
95
96
|
if (normalized === "error") return "error";
|
|
96
97
|
if (normalized === "stopped") return "stopped";
|