mixdog 0.9.95 → 0.9.97
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/LICENSES/Apache-2.0.txt +201 -0
- package/LICENSES/MIT.txt +56 -0
- package/LICENSES/codex-NOTICE.txt +6 -0
- package/NOTICE.md +46 -9
- package/README.md +0 -17
- package/package.json +16 -12
- package/scripts/.tmp-coverage-report.mjs +96 -0
- package/scripts/build-tui.mjs +17 -1
- package/scripts/{channel-daemon-stub.mjs → daemon-stub.mjs} +18 -12
- package/scripts/fixtures/patch-replay-corpus.json +98 -0
- package/src/defaults/mixdog-config.template.json +5 -8
- package/src/defaults/skills/setup/SKILL.md +1 -1
- package/src/lib/keychain-cjs.cjs +1 -1
- package/src/lib/mixdog-debug.cjs +2 -3
- package/src/rules/agent/30-explorer.md +7 -4
- package/src/rules/lead/01-general.md +1 -2
- package/src/rules/lead/lead-tool.md +0 -3
- package/src/rules/shared/01-tool.md +21 -29
- package/src/runtime/agent/orchestrator/agent-runtime/agent-dispatch.mjs +18 -2
- package/src/runtime/agent/orchestrator/agent-runtime/agent-progress-watchdog.mjs +31 -1
- package/src/runtime/agent/orchestrator/agent-runtime/maintenance-route.mjs +6 -17
- package/src/runtime/agent/orchestrator/agent-trace-format.mjs +12 -1
- package/src/runtime/agent/orchestrator/agent-trace-io.mjs +4 -13
- package/src/runtime/agent/orchestrator/config.mjs +246 -67
- package/src/runtime/agent/orchestrator/mcp/client.mjs +104 -41
- package/src/runtime/agent/orchestrator/mcp/reconnect-singleflight.mjs +23 -0
- package/src/runtime/agent/orchestrator/providers/admission-scheduler.mjs +113 -14
- package/src/runtime/agent/orchestrator/providers/anthropic-sse.mjs +5 -1
- package/src/runtime/agent/orchestrator/providers/gemini-stream.mjs +32 -11
- package/src/runtime/agent/orchestrator/providers/gemini.mjs +89 -2
- package/src/runtime/agent/orchestrator/providers/grok-oauth.mjs +12 -1
- package/src/runtime/agent/orchestrator/providers/openai-compat-xai.mjs +19 -1
- package/src/runtime/agent/orchestrator/providers/openai-compat.mjs +144 -39
- package/src/runtime/agent/orchestrator/providers/openai-oauth-http-sse.mjs +22 -8
- package/src/runtime/agent/orchestrator/providers/openai-oauth.mjs +15 -1
- package/src/runtime/agent/orchestrator/providers/openai-transport-policy.mjs +1 -1
- package/src/runtime/agent/orchestrator/providers/openai-ws-pool.mjs +3 -4
- package/src/runtime/agent/orchestrator/providers/openai-ws-stream.mjs +3 -6
- package/src/runtime/agent/orchestrator/providers/registry.mjs +2 -2
- package/src/runtime/agent/orchestrator/providers/retry-classifier.mjs +67 -7
- package/src/runtime/agent/orchestrator/providers/stream-json-pool.mjs +291 -0
- package/src/runtime/agent/orchestrator/providers/stream-json-worker.mjs +21 -0
- package/src/runtime/agent/orchestrator/session/agent-loop.mjs +36 -10
- package/src/runtime/agent/orchestrator/session/compact.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/eager-dispatch.mjs +22 -33
- package/src/runtime/agent/orchestrator/session/loop/pre-dispatch-deny.mjs +13 -0
- package/src/runtime/agent/orchestrator/session/loop/termination.mjs +2 -2
- package/src/runtime/agent/orchestrator/session/loop/tool-classify.mjs +0 -24
- package/src/runtime/agent/orchestrator/session/loop/tool-exec.mjs +21 -29
- package/src/runtime/agent/orchestrator/session/loop/tool-helpers.mjs +7 -10
- package/src/runtime/agent/orchestrator/session/manager/ask-session.mjs +45 -25
- package/src/runtime/agent/orchestrator/session/manager/compaction-runner.mjs +2 -3
- package/src/runtime/agent/orchestrator/session/manager/pending-messages.mjs +142 -84
- package/src/runtime/agent/orchestrator/session/manager/prefetch-bridge.mjs +12 -6
- package/src/runtime/agent/orchestrator/session/manager/runtime-loaders.mjs +4 -0
- package/src/runtime/agent/orchestrator/session/manager/session-crud.mjs +31 -1
- package/src/runtime/agent/orchestrator/session/manager/session-lock.mjs +38 -2
- package/src/runtime/agent/orchestrator/session/manager/turn-interruption.mjs +29 -9
- package/src/runtime/agent/orchestrator/session/manager.mjs +2 -0
- package/src/runtime/agent/orchestrator/session/result-classification.mjs +65 -0
- package/src/runtime/agent/orchestrator/session/send-with-recovery.mjs +86 -8
- package/src/runtime/agent/orchestrator/session/store/summary-cache.mjs +10 -3
- package/src/runtime/agent/orchestrator/session/store-summary-index.mjs +4 -0
- package/src/runtime/agent/orchestrator/session/store-summary-reader.mjs +71 -42
- package/src/runtime/agent/orchestrator/session/tool-batch.mjs +4 -33
- package/src/runtime/agent/orchestrator/session/tool-result-offload.mjs +4 -5
- package/src/runtime/agent/orchestrator/stall-policy.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/bash-session.mjs +2 -2
- package/src/runtime/agent/orchestrator/tools/builtin/arg-guard.mjs +35 -1
- package/src/runtime/agent/orchestrator/tools/builtin/bash-tool.mjs +116 -26
- package/src/runtime/agent/orchestrator/tools/builtin/binary-file.mjs +92 -19
- package/src/runtime/agent/orchestrator/tools/builtin/builtin-tools.mjs +8 -9
- package/src/runtime/agent/orchestrator/tools/builtin/cache-layers.mjs +2 -2
- package/src/runtime/agent/orchestrator/tools/builtin/device-paths.mjs +2 -2
- package/src/runtime/agent/orchestrator/tools/builtin/fs-reachability.mjs +2 -2
- package/src/runtime/agent/orchestrator/tools/builtin/lib/grep-context-expander.mjs +6 -15
- package/src/runtime/agent/orchestrator/tools/builtin/list-tool.mjs +12 -26
- package/src/runtime/agent/orchestrator/tools/builtin/read-image.mjs +5 -5
- package/src/runtime/agent/orchestrator/tools/builtin/read-single-tool.mjs +83 -33
- package/src/runtime/agent/orchestrator/tools/builtin/read-tool.mjs +42 -45
- package/src/runtime/agent/orchestrator/tools/builtin/rg-runner.mjs +27 -9
- package/src/runtime/agent/orchestrator/tools/builtin/search-path-diagnostics.mjs +7 -0
- package/src/runtime/agent/orchestrator/tools/builtin/search-tool.mjs +17 -39
- package/src/runtime/agent/orchestrator/tools/builtin/shell-analysis.mjs +73 -0
- package/src/runtime/agent/orchestrator/tools/builtin/shell-job-paths.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/builtin/shell-job-spawn.mjs +0 -2
- package/src/runtime/agent/orchestrator/tools/builtin/shell-jobs.mjs +3 -8
- package/src/runtime/agent/orchestrator/tools/builtin/shell-runtime.mjs +30 -0
- package/src/runtime/agent/orchestrator/tools/code-graph/build.mjs +5 -5
- package/src/runtime/agent/orchestrator/tools/code-graph/dispatch.mjs +142 -26
- package/src/runtime/agent/orchestrator/tools/code-graph/search-references.mjs +12 -1
- package/src/runtime/agent/orchestrator/tools/code-graph/search.mjs +47 -19
- package/src/runtime/agent/orchestrator/tools/code-graph-tool-defs.mjs +3 -2
- package/src/runtime/agent/orchestrator/tools/env-scrub.mjs +1 -2
- package/src/runtime/agent/orchestrator/tools/lib/pwsh-standby-pool.mjs +83 -13
- package/src/runtime/agent/orchestrator/tools/patch/matcher.mjs +39 -1
- package/src/runtime/agent/orchestrator/tools/patch/native-server.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/patch/orchestrator.mjs +94 -20
- package/src/runtime/agent/orchestrator/tools/patch/parsing.mjs +16 -0
- package/src/runtime/agent/orchestrator/tools/patch/v4a-convert.mjs +108 -12
- package/src/runtime/agent/orchestrator/tools/patch-tool-defs.mjs +12 -11
- package/src/runtime/agent/orchestrator/tools/patch.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/shell-command.mjs +63 -9
- package/src/runtime/agent/orchestrator/tools/shell-exec-output.mjs +2 -2
- package/src/runtime/channels/lib/config.mjs +34 -34
- package/src/runtime/channels/lib/inbound-handler.mjs +8 -8
- package/src/runtime/channels/lib/interaction-handlers.mjs +6 -6
- package/src/runtime/channels/lib/memory-client.mjs +31 -157
- package/src/runtime/channels/lib/output-forwarder.mjs +16 -16
- package/src/runtime/channels/lib/owned-runtime.mjs +60 -60
- package/src/runtime/channels/lib/owner-heartbeat.mjs +1 -1
- package/src/runtime/channels/lib/{backend-dispatch.mjs → provider-dispatch.mjs} +6 -6
- package/src/runtime/channels/lib/runtime-paths.mjs +4 -30
- package/src/runtime/channels/lib/scheduler.mjs +2 -2
- package/src/runtime/channels/lib/status-snapshot.mjs +3 -3
- package/src/runtime/channels/lib/tool-dispatch.mjs +4 -4
- package/src/runtime/channels/lib/worker-bootstrap.mjs +1 -1
- package/src/runtime/channels/lib/worker-ipc.mjs +7 -7
- package/src/runtime/channels/lib/worker-main.mjs +38 -38
- package/src/runtime/channels/{backends → providers}/discord-access.mjs +1 -1
- package/src/runtime/channels/{backends → providers}/discord-gateway.mjs +1 -1
- package/src/runtime/channels/{backends → providers}/discord.mjs +3 -3
- package/src/runtime/channels/{backends → providers}/telegram.mjs +12 -12
- package/src/runtime/channels/tool-defs.mjs +1 -1
- package/src/runtime/memory/index.mjs +76 -248
- package/src/runtime/memory/lib/agent-ipc.mjs +146 -81
- package/src/runtime/memory/lib/compact-vector-cache.mjs +88 -0
- package/src/runtime/memory/lib/core-memory-store.mjs +18 -1
- package/src/runtime/memory/lib/cycle-llm-adapters.mjs +13 -34
- package/src/runtime/memory/lib/embedding-provider.mjs +47 -26
- package/src/runtime/memory/lib/embedding-worker.mjs +30 -34
- package/src/runtime/memory/lib/http-router.mjs +9 -6
- package/src/runtime/memory/lib/ko-morph.mjs +3 -20
- package/src/runtime/memory/lib/memory-action-handlers.mjs +2 -1
- package/src/runtime/memory/lib/memory-config-flags.mjs +1 -1
- package/src/runtime/memory/lib/memory-cycle1.mjs +1 -0
- package/src/runtime/memory/lib/memory-cycle2-gate.mjs +4 -2
- package/src/runtime/memory/lib/memory-cycle2-mutations.mjs +1 -0
- package/src/runtime/memory/lib/memory-cycle2-shared.mjs +4 -1
- package/src/runtime/memory/lib/memory-cycle3.mjs +3 -1
- package/src/runtime/memory/lib/memory-daemon-lifecycle.mjs +5 -0
- package/src/runtime/memory/lib/memory-log.mjs +1 -1
- package/src/runtime/memory/lib/memory-process-lock.mjs +5 -60
- package/src/runtime/memory/lib/memory.mjs +1 -1
- package/src/runtime/memory/lib/pg/process.mjs +32 -9
- package/src/runtime/memory/lib/session-ingest.mjs +1 -1
- package/src/runtime/memory/tool-defs.mjs +1 -5
- package/src/runtime/search/index.mjs +2 -2
- package/src/runtime/search/tool-defs.mjs +2 -2
- package/src/runtime/shared/abort-race.mjs +70 -0
- package/src/runtime/shared/agent-route-config.mjs +119 -0
- package/src/runtime/shared/atomic-file.mjs +80 -4
- package/src/runtime/shared/channel-notification-routing.mjs +2 -2
- package/src/runtime/shared/child-guardian.mjs +204 -108
- package/src/runtime/shared/child-spawn-gate.mjs +139 -72
- package/src/runtime/shared/config.mjs +120 -47
- package/src/runtime/shared/llm/index.mjs +1 -1
- package/src/runtime/shared/owner-fair-gate.mjs +134 -0
- package/src/runtime/shared/resource-admission.mjs +150 -100
- package/src/runtime/shared/stream-progress.mjs +6 -0
- package/src/runtime/shared/tool-execution-owner.mjs +12 -0
- package/src/runtime/shared/tool-result-summary.mjs +1 -1
- package/src/runtime/shared/tool-surface.mjs +91 -27
- package/src/runtime/shared/tool-workload-gates.mjs +29 -0
- package/src/runtime/shared/turn-snapshot.mjs +47 -6
- package/src/runtime/shared/turn-worktree-snapshot.mjs +14 -2
- package/src/session-runtime/channel-config-api.mjs +5 -5
- package/src/session-runtime/config-helpers.mjs +39 -37
- package/src/session-runtime/config-lifecycle.mjs +27 -27
- package/src/session-runtime/lifecycle-api.mjs +22 -3
- package/src/session-runtime/memory-runtime-prewarm.mjs +15 -0
- package/src/session-runtime/model-route-api.mjs +7 -5
- package/src/session-runtime/prewarm.mjs +1 -1
- package/src/session-runtime/provider-auth-api.mjs +0 -7
- package/src/session-runtime/provider-models.mjs +1 -1
- package/src/session-runtime/remote-control.mjs +6 -7
- package/src/session-runtime/runtime-core.mjs +63 -39
- package/src/session-runtime/runtime-tunables.mjs +4 -4
- package/src/session-runtime/self-update.mjs +1 -1
- package/src/session-runtime/session-lifecycle.mjs +45 -17
- package/src/session-runtime/session-title.mjs +1 -1
- package/src/session-runtime/session-turn-api.mjs +96 -24
- package/src/session-runtime/settings-api.mjs +12 -24
- package/src/session-runtime/tool-defs.mjs +3 -3
- package/src/session-runtime/workflow-agents-api.mjs +55 -81
- package/src/session-runtime/workflow.mjs +14 -24
- package/src/standalone/agent-dispatch-broker.mjs +198 -0
- package/src/standalone/agent-tool/helpers.mjs +2 -2
- package/src/standalone/agent-tool/spawn-flow.mjs +2 -0
- package/src/standalone/agent-tool/spawn-preset.mjs +11 -21
- package/src/standalone/agent-tool/tool-def.mjs +0 -14
- package/src/standalone/channel-admin.mjs +53 -64
- package/src/standalone/{channel-daemon-client.mjs → channel-client.mjs} +33 -19
- package/src/standalone/{channel-daemon-transport.mjs → channel-transport.mjs} +127 -46
- package/src/standalone/channel-worker.mjs +124 -647
- package/src/standalone/{backend-daemon.mjs → daemon.mjs} +270 -154
- package/src/standalone/explore-tool.mjs +187 -70
- package/src/standalone/fair-call-scheduler.mjs +264 -0
- package/src/standalone/memory-runtime-proxy.mjs +58 -1
- package/src/standalone/session-client.mjs +1134 -0
- package/src/standalone/session-protocol.mjs +192 -0
- package/src/standalone/session-runtime-pool.mjs +393 -0
- package/src/standalone/session-runtime-record.mjs +20 -0
- package/src/standalone/session-runtime-worker.mjs +203 -0
- package/src/standalone/{engine-daemon-service.mjs → session-service.mjs} +481 -224
- package/src/standalone/{engine-daemon-transport.mjs → session-transport.mjs} +390 -121
- package/src/standalone/session-wire.mjs +55 -0
- package/src/tui/App.jsx +34 -21
- package/src/tui/app/app-format.mjs +1 -1
- package/src/tui/app/app-view.jsx +5 -2
- package/src/tui/app/channel-pickers.mjs +41 -41
- package/src/tui/app/core-memory-picker.mjs +19 -19
- package/src/tui/app/doctor.mjs +5 -11
- package/src/tui/app/input-parsers.mjs +2 -2
- package/src/tui/app/message-selector.mjs +103 -0
- package/src/tui/app/onboarding-steps.mjs +3 -4
- package/src/tui/app/project-picker.mjs +80 -56
- package/src/tui/app/prompt-submit.mjs +48 -43
- package/src/tui/app/resume-picker.mjs +2 -2
- package/src/tui/app/route-pickers.mjs +3 -1
- package/src/tui/app/settings-picker.mjs +31 -33
- package/src/tui/app/transcript-window.mjs +38 -0
- package/src/tui/app/use-prompt-draft-flow.mjs +5 -7
- package/src/tui/app/use-prompt-handlers.mjs +86 -21
- package/src/tui/app/use-prompt-hint.mjs +3 -2
- package/src/tui/app/use-prompt-queue-history.mjs +10 -3
- package/src/tui/app/use-transcript-scroll.mjs +10 -3
- package/src/tui/app/use-transcript-window.mjs +50 -17
- package/src/tui/components/PromptInput.jsx +71 -38
- package/src/tui/components/Spinner.jsx +1 -1
- package/src/tui/components/ToolExecution.jsx +1 -1
- package/src/tui/components/prompt-input/edit-helpers.mjs +9 -11
- package/src/tui/components/prompt-input/escape-policy.mjs +42 -0
- package/src/tui/components/prompt-input/immediate-render.mjs +0 -10
- package/src/tui/components/prompt-input/interrupt-policy.mjs +10 -0
- package/src/tui/components/prompt-input/restore-policy.mjs +10 -0
- package/src/tui/components/tool-execution/surface-detail.mjs +1 -1
- package/src/tui/dist/index.mjs +1031 -1676
- package/src/tui/hooks/useSession.mjs +16 -0
- package/src/tui/index.jsx +12 -13
- package/src/tui/{engine → session}/agent-envelope.mjs +3 -3
- package/src/tui/{engine → session}/agent-job-feed.mjs +4 -4
- package/src/tui/{engine → session}/boot-profile.mjs +2 -2
- package/src/tui/{engine → session}/context-state.mjs +3 -3
- package/src/tui/{engine → session}/labels.mjs +2 -2
- package/src/tui/{engine → session}/live-share.mjs +38 -4
- package/src/tui/{engine → session}/notice-text.mjs +2 -2
- package/src/tui/{engine → session}/notification-plan.mjs +3 -3
- package/src/tui/session/oauth-flows.mjs +140 -0
- package/src/tui/{engine → session}/prompt-history.mjs +3 -3
- package/src/tui/{engine → session}/queue-helpers.mjs +2 -2
- package/src/tui/{engine → session}/render-timing.mjs +2 -2
- package/src/tui/{engine → session}/session-api-ext.mjs +30 -20
- package/src/tui/{engine → session}/session-api.mjs +110 -93
- package/src/tui/{engine → session}/session-flow.mjs +8 -2
- package/src/tui/{engine → session}/session-stats.mjs +3 -3
- package/src/tui/{engine → session}/tool-approval.mjs +3 -3
- package/src/tui/{engine → session}/tool-call-fields.mjs +2 -2
- package/src/tui/{engine → session}/tool-card-results.mjs +8 -6
- package/src/tui/{engine → session}/tool-result-status.mjs +5 -5
- package/src/tui/{engine → session}/tool-result-text.mjs +13 -3
- package/src/tui/{engine → session}/transcript-spill.mjs +34 -34
- package/src/tui/{engine → session}/turn.mjs +38 -176
- package/src/tui/{engine-local-session.mjs → session-local.mjs} +103 -103
- package/src/tui/session.mjs +22 -0
- package/src/tui/spinner-meta.mjs +4 -4
- package/src/tui/spinner-verbs.mjs +51 -3
- package/src/ui/statusline-segments.mjs +1 -1
- package/src/ui/statusline.mjs +1 -1
- package/vendor/ink/build/components/App.js +10 -1
- package/src/session-runtime/memory-daemon-probe.mjs +0 -61
- package/src/standalone/engine-daemon-client.mjs +0 -894
- package/src/standalone/engine-daemon-local-bridge.mjs +0 -20
- package/src/standalone/engine-daemon-protocol.mjs +0 -33
- package/src/tui/engine/turn-watchdog.mjs +0 -92
- package/src/tui/engine.mjs +0 -22
- package/src/tui/hooks/useEngine.mjs +0 -16
- /package/src/runtime/agent/orchestrator/session/compact/{engine.mjs → runner.mjs} +0 -0
- /package/src/runtime/channels/{backends → providers}/discord-attachments.mjs +0 -0
- /package/src/tui/{engine → session}/agent-response-tail.mjs +0 -0
- /package/src/tui/{engine → session}/frame-batched-store.mjs +0 -0
- /package/src/tui/{engine → session}/tui-steering-persist.mjs +0 -0
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
const LOCAL_ENGINE_BRIDGE_KEY = Symbol.for('mixdog.engine-daemon.local-bridge.v1');
|
|
2
|
-
|
|
3
|
-
/** Return the daemon-process-local session bridge, when this module is running
|
|
4
|
-
* inside the singleton backend process. External TUI/Electron clients never
|
|
5
|
-
* see this registry and keep using the authenticated loopback transport. */
|
|
6
|
-
export function engineDaemonLocalBridge() {
|
|
7
|
-
return globalThis[LOCAL_ENGINE_BRIDGE_KEY] ?? null;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export function installEngineDaemonLocalBridge(bridge) {
|
|
11
|
-
if (!bridge || typeof bridge.attach !== 'function') {
|
|
12
|
-
throw new TypeError('engine daemon local bridge is invalid');
|
|
13
|
-
}
|
|
14
|
-
globalThis[LOCAL_ENGINE_BRIDGE_KEY] = bridge;
|
|
15
|
-
return () => {
|
|
16
|
-
if (globalThis[LOCAL_ENGINE_BRIDGE_KEY] === bridge) {
|
|
17
|
-
delete globalThis[LOCAL_ENGINE_BRIDGE_KEY];
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
// Wire identity shared by the engine daemon and its views. Kept dependency-free
|
|
2
|
-
// so both the host process and the client can read it without pulling in the
|
|
3
|
-
// other side's module graph.
|
|
4
|
-
import { readFileSync } from 'node:fs';
|
|
5
|
-
|
|
6
|
-
/** Bump on any incompatible change to the /call contract or frame shapes. */
|
|
7
|
-
export const ENGINE_DAEMON_PROTOCOL = 3;
|
|
8
|
-
|
|
9
|
-
let cachedVersion = null;
|
|
10
|
-
|
|
11
|
-
/** Version of the mixdog install this process runs from. A daemon and a view
|
|
12
|
-
* from DIFFERENT installs cannot share engines safely — the snapshot contract
|
|
13
|
-
* travels with the runtime, not with the protocol number alone. */
|
|
14
|
-
export function engineRuntimeVersion() {
|
|
15
|
-
if (cachedVersion) return cachedVersion;
|
|
16
|
-
try {
|
|
17
|
-
const manifest = JSON.parse(readFileSync(new URL('../../package.json', import.meta.url), 'utf8'));
|
|
18
|
-
cachedVersion = String(manifest?.version || '0.0.0');
|
|
19
|
-
} catch {
|
|
20
|
-
cachedVersion = '0.0.0';
|
|
21
|
-
}
|
|
22
|
-
return cachedVersion;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export function compareRuntimeVersions(left, right) {
|
|
26
|
-
const parse = (value) => String(value || '0.0.0').split('.').map((part) => Number(part) || 0);
|
|
27
|
-
const a = parse(left);
|
|
28
|
-
const b = parse(right);
|
|
29
|
-
for (let index = 0; index < 3; index += 1) {
|
|
30
|
-
if ((a[index] ?? 0) !== (b[index] ?? 0)) return (a[index] ?? 0) - (b[index] ?? 0);
|
|
31
|
-
}
|
|
32
|
-
return 0;
|
|
33
|
-
}
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
// Lead-turn stall watchdog. A turn is declared stuck only when NOTHING has
|
|
2
|
-
// progressed for the timeout: local deltas mark progress directly, and before
|
|
3
|
-
// tripping we re-read the orchestrator's own liveness so a long-but-alive tool
|
|
4
|
-
// (its self-deadline plus a grace ceiling) defers the trip instead of aborting
|
|
5
|
-
// real work. Extracted from turn.mjs; the trip ACTION stays there because it
|
|
6
|
-
// unwinds turn-scoped UI state.
|
|
7
|
-
export function createTurnWatchdog({
|
|
8
|
-
runtime,
|
|
9
|
-
timeoutMs,
|
|
10
|
-
toolMaxMs,
|
|
11
|
-
isCurrentTurn,
|
|
12
|
-
onTrip,
|
|
13
|
-
}) {
|
|
14
|
-
let timer = null;
|
|
15
|
-
let tripped = false;
|
|
16
|
-
let lastProgressAt = Date.now();
|
|
17
|
-
let lastProgressLabel = 'start';
|
|
18
|
-
// While a tool runs, the trip is deferred until this wall-clock ceiling.
|
|
19
|
-
let deferralCeilingAt = 0;
|
|
20
|
-
|
|
21
|
-
function clear() {
|
|
22
|
-
if (timer) { clearTimeout(timer); timer = null; }
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// Adopt the orchestrator's liveness as progress when it is fresher than the
|
|
26
|
-
// local view; returns true when the trip was deferred.
|
|
27
|
-
function refreshFromRuntimeLiveness() {
|
|
28
|
-
let liveness;
|
|
29
|
-
try { liveness = runtime.getTurnLiveness?.(); } catch { return false; }
|
|
30
|
-
if (liveness?.stage !== 'tool_running') deferralCeilingAt = 0;
|
|
31
|
-
const progressAt = Number(liveness?.lastProgressAt);
|
|
32
|
-
const now = Date.now();
|
|
33
|
-
if (!liveness || !Number.isFinite(progressAt) || progressAt <= now - timeoutMs) return false;
|
|
34
|
-
|
|
35
|
-
if (liveness.stage === 'tool_running') {
|
|
36
|
-
deferralCeilingAt = 0;
|
|
37
|
-
const toolStartedAt = Number(liveness.toolStartedAt);
|
|
38
|
-
if (!Number.isFinite(toolStartedAt) || toolStartedAt <= 0) return false;
|
|
39
|
-
const toolSelfDeadlineMs = Number(liveness.toolSelfDeadlineMs);
|
|
40
|
-
const toolCeilingMs = Math.max(
|
|
41
|
-
Number.isFinite(toolSelfDeadlineMs) && toolSelfDeadlineMs > 0 ? toolSelfDeadlineMs + 60_000 : 0,
|
|
42
|
-
toolMaxMs,
|
|
43
|
-
);
|
|
44
|
-
if (now - toolStartedAt >= toolCeilingMs) return false;
|
|
45
|
-
deferralCeilingAt = toolStartedAt + toolCeilingMs;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
lastProgressAt = progressAt;
|
|
49
|
-
lastProgressLabel = `orchestrator:${String(liveness.stage || 'unknown')}`;
|
|
50
|
-
arm();
|
|
51
|
-
return true;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function arm() {
|
|
55
|
-
clear();
|
|
56
|
-
if (tripped) return;
|
|
57
|
-
const now = Date.now();
|
|
58
|
-
const remaining = Math.max(1, timeoutMs - Math.max(0, now - lastProgressAt));
|
|
59
|
-
const ceilingRemaining = deferralCeilingAt > 0 ? Math.max(1, deferralCeilingAt - now) : Infinity;
|
|
60
|
-
timer = setTimeout(() => {
|
|
61
|
-
if (!isCurrentTurn() || tripped) return;
|
|
62
|
-
const firedAt = Date.now();
|
|
63
|
-
const idleMs = firedAt - lastProgressAt;
|
|
64
|
-
if (idleMs < timeoutMs) {
|
|
65
|
-
if (deferralCeilingAt > 0 && firedAt >= deferralCeilingAt) {
|
|
66
|
-
if (refreshFromRuntimeLiveness()) return;
|
|
67
|
-
} else {
|
|
68
|
-
arm();
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
} else if (refreshFromRuntimeLiveness()) return;
|
|
72
|
-
tripped = true;
|
|
73
|
-
onTrip({ idleMs, lastProgressLabel });
|
|
74
|
-
}, Math.min(remaining, ceilingRemaining));
|
|
75
|
-
timer.unref?.();
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function markProgress(label) {
|
|
79
|
-
if (!isCurrentTurn()) return false;
|
|
80
|
-
if (tripped) return false;
|
|
81
|
-
lastProgressAt = Date.now();
|
|
82
|
-
lastProgressLabel = String(label || 'progress');
|
|
83
|
-
return true;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return {
|
|
87
|
-
arm,
|
|
88
|
-
clear,
|
|
89
|
-
markProgress,
|
|
90
|
-
get tripped() { return tripped; },
|
|
91
|
-
};
|
|
92
|
-
}
|
package/src/tui/engine.mjs
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TUI engine facade.
|
|
3
|
-
*
|
|
4
|
-
* Product clients receive only a daemon-owned session projection. The large
|
|
5
|
-
* in-process store is isolated in engine-local-session.mjs and is not exposed
|
|
6
|
-
* from this client facade.
|
|
7
|
-
*/
|
|
8
|
-
export {
|
|
9
|
-
cleanupStaleTranscriptSpillDirs,
|
|
10
|
-
createTranscriptSpillBuffer,
|
|
11
|
-
refillTranscriptViewOverlap,
|
|
12
|
-
replaceEngineItemsState,
|
|
13
|
-
createEngineItemMutators,
|
|
14
|
-
TRANSCRIPT_LIVE_ITEM_CAP,
|
|
15
|
-
TRANSCRIPT_SPILL_CHUNK_ITEMS,
|
|
16
|
-
} from './engine/transcript-spill.mjs';
|
|
17
|
-
export { parseBackgroundTaskEnvelope } from './engine/agent-envelope.mjs';
|
|
18
|
-
|
|
19
|
-
export async function createEngineSession(options = {}) {
|
|
20
|
-
const { createRemoteEngineSession } = await import('../standalone/engine-daemon-client.mjs');
|
|
21
|
-
return await createRemoteEngineSession(options);
|
|
22
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* src/tui/hooks/useEngine.mjs — subscribe React to the engine store.
|
|
3
|
-
*
|
|
4
|
-
* The store (engine.mjs) lives outside React and emits immutable snapshots;
|
|
5
|
-
* useSyncExternalStore re-renders the tree whenever a snapshot changes. This
|
|
6
|
-
* keeps the agentLoop fully decoupled from React's lifecycle.
|
|
7
|
-
*/
|
|
8
|
-
import { useSyncExternalStore } from 'react';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* @param {object} store engine session from createEngineSession()
|
|
12
|
-
* @returns the current engine state snapshot
|
|
13
|
-
*/
|
|
14
|
-
export function useEngine(store) {
|
|
15
|
-
return useSyncExternalStore(store.subscribe, store.getState, store.getState);
|
|
16
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|