mixdog 0.9.152 → 0.9.154
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/browser-import-NOTICE.txt +11 -0
- package/NOTICE.md +11 -0
- package/README.md +8 -10
- package/package.json +19 -3
- package/scripts/computer-task-cost-report.mjs +144 -0
- package/scripts/run-office-live-tests.mjs +32 -0
- package/src/agents/front-worker/AGENT.md +13 -0
- package/src/agents/front-worker/agent.json +6 -0
- package/src/agents/heavy-worker/AGENT.md +10 -11
- package/src/agents/heavy-worker/agent.json +1 -1
- package/src/agents/maintainer/AGENT.md +0 -2
- package/src/agents/reviewer/AGENT.md +9 -13
- package/src/agents/reviewer/agent.json +1 -1
- package/src/agents/security/AGENT.md +14 -0
- package/src/agents/security/agent.json +6 -0
- package/src/agents/worker/AGENT.md +8 -8
- package/src/agents/worker/agent.json +1 -1
- package/src/agents/writer/AGENT.md +14 -0
- package/src/agents/writer/agent.json +6 -0
- package/src/rules/agent/00-common.md +4 -7
- package/src/rules/lead/01-general.md +0 -3
- package/src/rules/shared/10-tool-workflow.md +10 -2
- package/src/rules/shared/60-verification.md +2 -0
- package/src/runtime/agent/orchestrator/agent-runtime/agent-dispatch.mjs +183 -26
- package/src/runtime/agent/orchestrator/agent-runtime/session-builder.mjs +4 -0
- package/src/runtime/agent/orchestrator/cache-break-trace.mjs +109 -0
- package/src/runtime/agent/orchestrator/config.mjs +7 -2
- package/src/runtime/agent/orchestrator/providers/admission-scheduler.mjs +16 -3
- package/src/runtime/agent/orchestrator/providers/lib/anthropic-request-utils.mjs +9 -1
- package/src/runtime/agent/orchestrator/providers/media-normalization.mjs +30 -9
- package/src/runtime/agent/orchestrator/providers/openai-codex-metadata.mjs +18 -26
- package/src/runtime/agent/orchestrator/providers/openai-oauth-http-sse.mjs +25 -2
- package/src/runtime/agent/orchestrator/providers/openai-oauth-ws.mjs +103 -10
- package/src/runtime/agent/orchestrator/providers/openai-turn-state.mjs +68 -0
- package/src/runtime/agent/orchestrator/providers/openai-ws-delta.mjs +36 -11
- package/src/runtime/agent/orchestrator/providers/openai-ws-pool.mjs +140 -86
- package/src/runtime/agent/orchestrator/providers/openai-ws-stream.mjs +9 -13
- package/src/runtime/agent/orchestrator/session/agent-loop.mjs +72 -4
- package/src/runtime/agent/orchestrator/session/browser-snapshot-supersession.mjs +61 -0
- package/src/runtime/agent/orchestrator/session/compact/handoff.mjs +0 -22
- package/src/runtime/agent/orchestrator/session/compact/messages.mjs +2 -2
- package/src/runtime/agent/orchestrator/session/compact/runner.mjs +11 -23
- package/src/runtime/agent/orchestrator/session/compact/summary.mjs +28 -269
- package/src/runtime/agent/orchestrator/session/compact.mjs +0 -6
- package/src/runtime/agent/orchestrator/session/context-utils.mjs +86 -11
- package/src/runtime/agent/orchestrator/session/eager-dispatch.mjs +17 -1
- package/src/runtime/agent/orchestrator/session/image-strip-recovery.mjs +12 -8
- package/src/runtime/agent/orchestrator/session/loop/compact-policy.mjs +110 -2
- package/src/runtime/agent/orchestrator/session/loop/pre-dispatch-deny.mjs +3 -16
- package/src/runtime/agent/orchestrator/session/loop/recall-fasttrack.mjs +80 -18
- package/src/runtime/agent/orchestrator/session/loop/steering.mjs +6 -0
- package/src/runtime/agent/orchestrator/session/loop/tool-exec.mjs +3 -0
- package/src/runtime/agent/orchestrator/session/loop/tool-helpers.mjs +6 -0
- package/src/runtime/agent/orchestrator/session/manager/ask-session.mjs +80 -21
- package/src/runtime/agent/orchestrator/session/manager/compaction-runner.mjs +33 -72
- package/src/runtime/agent/orchestrator/session/manager/session-crud.mjs +21 -2
- package/src/runtime/agent/orchestrator/session/manager/session-lifecycle.mjs +25 -51
- package/src/runtime/agent/orchestrator/session/manager/status-telemetry.mjs +3 -0
- package/src/runtime/agent/orchestrator/session/manager/tool-resolution.mjs +4 -110
- package/src/runtime/agent/orchestrator/session/manager/turn-checkpoint-journal.mjs +39 -15
- package/src/runtime/agent/orchestrator/session/manager/turn-checkpoint.mjs +14 -4
- package/src/runtime/agent/orchestrator/session/pre-send-compact.mjs +41 -8
- package/src/runtime/agent/orchestrator/session/provider-prefix-guard.mjs +129 -12
- package/src/runtime/agent/orchestrator/session/send-with-recovery.mjs +2 -2
- package/src/runtime/agent/orchestrator/session/store/listing.mjs +8 -1
- package/src/runtime/agent/orchestrator/session/store/save-worker.mjs +15 -1
- package/src/runtime/agent/orchestrator/session/store-summary-index.mjs +36 -2
- package/src/runtime/agent/orchestrator/session/store-summary-reader.mjs +157 -30
- package/src/runtime/agent/orchestrator/session/store-summary-visibility.mjs +57 -0
- package/src/runtime/agent/orchestrator/session/store.mjs +3 -1
- package/src/runtime/agent/orchestrator/session/tool-batch.mjs +22 -0
- package/src/runtime/agent/orchestrator/tools/builtin/read-special-files.mjs +6 -6
- package/src/runtime/agent/orchestrator/tools/progress-message.mjs +4 -0
- package/src/runtime/attachments/pdf-extract.mjs +3 -0
- package/src/runtime/attachments/pdfjs-runtime.mjs +13 -0
- package/src/runtime/browser-bridge/action-schema.mjs +251 -0
- package/src/runtime/browser-bridge/client.mjs +75 -26
- package/src/runtime/browser-bridge/tool-defs.mjs +132 -15
- package/src/runtime/computer-bridge/action-schema.mjs +653 -0
- package/src/runtime/computer-bridge/client.mjs +211 -28
- package/src/runtime/computer-bridge/tool-defs.mjs +25 -45
- package/src/runtime/office/assurance-benchmark.mjs +358 -0
- package/src/runtime/office/assurance.mjs +833 -0
- package/src/runtime/office/benchmark.mjs +496 -0
- package/src/runtime/office/capabilities.mjs +551 -0
- package/src/runtime/office/com-adapter.mjs +283 -0
- package/src/runtime/office/content-model.mjs +183 -0
- package/src/runtime/office/contract-benchmark.mjs +105 -0
- package/src/runtime/office/design-library.mjs +1562 -0
- package/src/runtime/office/design-system.mjs +1966 -0
- package/src/runtime/office/index.mjs +2413 -0
- package/src/runtime/office/journal.mjs +82 -0
- package/src/runtime/office/office-com-host.ps1 +3781 -0
- package/src/runtime/office/office-com-session-host.ps1 +855 -0
- package/src/runtime/office/ooxml-validator.mjs +271 -0
- package/src/runtime/office/pagination.mjs +132 -0
- package/src/runtime/office/pdf-adapter.mjs +591 -0
- package/src/runtime/office/pdf-analysis.mjs +372 -0
- package/src/runtime/office/pdf-render.mjs +167 -0
- package/src/runtime/office/pdf-security.mjs +63 -0
- package/src/runtime/office/polish-benchmark.mjs +190 -0
- package/src/runtime/office/portable-ooxml.mjs +1867 -0
- package/src/runtime/office/quality-live-benchmark.mjs +486 -0
- package/src/runtime/office/quality-pipeline.mjs +136 -0
- package/src/runtime/office/tabular.mjs +302 -0
- package/src/runtime/office/templates/mixdog-executive.pptx +0 -0
- package/src/runtime/office/templates/mixdog-executive.pptx.mixdog.json +190 -0
- package/src/runtime/office/tool-defs.mjs +113 -0
- package/src/runtime/office/visual-diff.mjs +89 -0
- package/src/runtime/office/xlsx-assertions.mjs +172 -0
- package/src/runtime/office/xlsx-contract.mjs +147 -0
- package/src/runtime/shared/agent-route-config.mjs +9 -0
- package/src/runtime/shared/tool-execution-contract.mjs +16 -0
- package/src/runtime/shared/tool-surface.mjs +9 -0
- package/src/session-runtime/context-status.mjs +9 -3
- package/src/session-runtime/deferred-tool-delta.mjs +104 -0
- package/src/session-runtime/goal-runtime.mjs +617 -197
- package/src/session-runtime/lifecycle-api.mjs +50 -8
- package/src/session-runtime/provider-request-snapshot.mjs +33 -9
- package/src/session-runtime/resource-api.mjs +31 -94
- package/src/session-runtime/runtime-core.mjs +78 -26
- package/src/session-runtime/session-lifecycle.mjs +34 -12
- package/src/session-runtime/session-title.mjs +2 -2
- package/src/session-runtime/session-turn-api.mjs +15 -14
- package/src/session-runtime/tool-catalog-data.mjs +1 -1
- package/src/session-runtime/tool-catalog.mjs +38 -99
- package/src/session-runtime/tool-defs.mjs +6 -1
- package/src/session-runtime/tool-surface.mjs +18 -8
- package/src/session-runtime/workflow-agents-api.mjs +8 -25
- package/src/session-runtime/workflow.mjs +8 -6
- package/src/standalone/agent-tool/helpers.mjs +2 -2
- package/src/standalone/agent-tool/job-views.mjs +3 -1
- package/src/standalone/agent-tool/notify.mjs +5 -1
- package/src/standalone/agent-tool/render.mjs +3 -0
- package/src/standalone/agent-tool/spawn-flow.mjs +61 -16
- package/src/standalone/agent-tool/tool-def.mjs +1 -1
- package/src/standalone/agent-tool/worker-index.mjs +123 -0
- package/src/standalone/agent-tool/worker-rows.mjs +2 -1
- package/src/standalone/agent-tool.mjs +57 -10
- package/src/standalone/daemon.mjs +105 -6
- package/src/standalone/session-runtime-host.mjs +61 -48
- package/src/standalone/session-runtime-inline-host.mjs +34 -127
- package/src/standalone/session-runtime-worker.mjs +20 -198
- package/src/standalone/session-service.mjs +632 -7
- package/src/tui/dist/index.mjs +24 -1
- package/src/tui/lib/voice-setup.mjs +4 -1
- package/src/tui/session/context-state.mjs +2 -13
- package/src/tui/session/goal-continuation.mjs +38 -7
- package/src/tui/session/session-api-ext.mjs +9 -0
- package/src/tui/session/session-api.mjs +15 -1
- package/src/tui/session/session-flow.mjs +25 -1
- package/src/tui/session/turn.mjs +88 -16
- package/src/tui/session-local.mjs +25 -3
- package/src/vendor/statusline/src/gateway/route-meta.mjs +31 -0
- package/scripts/generate-voice-runtime-manifest.test.mjs +0 -135
- package/scripts/native-binary-arch.test.mjs +0 -111
- package/scripts/patch-replay.test.mjs +0 -94
- package/src/headless-exec.test.mjs +0 -539
- package/src/runtime/agent/orchestrator/agent-trace-timing.test.mjs +0 -57
- package/src/runtime/agent/orchestrator/context/collect-skills.test.mjs +0 -153
- package/src/runtime/agent/orchestrator/mcp/cancellation.test.mjs +0 -139
- package/src/runtime/agent/orchestrator/mcp/features.test.mjs +0 -66
- package/src/runtime/agent/orchestrator/mcp/security.test.mjs +0 -80
- package/src/runtime/agent/orchestrator/providers/anthropic-fast-mode.test.mjs +0 -90
- package/src/runtime/agent/orchestrator/providers/anthropic-server-fallback.test.mjs +0 -215
- package/src/runtime/agent/orchestrator/providers/antigravity-oauth.test.mjs +0 -165
- package/src/runtime/agent/orchestrator/providers/media-parity.test.mjs +0 -142
- package/src/runtime/agent/orchestrator/providers/openai-codex-identity.test.mjs +0 -153
- package/src/runtime/agent/orchestrator/providers/openai-codex-model.test.mjs +0 -24
- package/src/runtime/agent/orchestrator/providers/openai-ws-delta-parity.test.mjs +0 -190
- package/src/runtime/agent/orchestrator/providers/provider-replay.test.mjs +0 -235
- package/src/runtime/agent/orchestrator/providers/sse-framing.test.mjs +0 -719
- package/src/runtime/agent/orchestrator/session/cache/prefetch-cache.test.mjs +0 -40
- package/src/runtime/agent/orchestrator/session/compact-policy.test.mjs +0 -176
- package/src/runtime/agent/orchestrator/session/compaction-read-reset.test.mjs +0 -161
- package/src/runtime/agent/orchestrator/session/eager-dispatch.test.mjs +0 -115
- package/src/runtime/agent/orchestrator/session/evidence-union.test.mjs +0 -228
- package/src/runtime/agent/orchestrator/session/image-strip-recovery.test.mjs +0 -245
- package/src/runtime/agent/orchestrator/session/lossless-tool-output.test.mjs +0 -125
- package/src/runtime/agent/orchestrator/session/manager/pending-messages-persistence.test.mjs +0 -325
- package/src/runtime/agent/orchestrator/session/manager/session-lifecycle.test.mjs +0 -70
- package/src/runtime/agent/orchestrator/session/manager/turn-checkpoint-journal.test.mjs +0 -457
- package/src/runtime/agent/orchestrator/session/provider-prefix-guard.test.mjs +0 -117
- package/src/runtime/agent/orchestrator/session/reduction-metrics.test.mjs +0 -87
- package/src/runtime/agent/orchestrator/session/store/serialize.test.mjs +0 -60
- package/src/runtime/agent/orchestrator/session/store-summary-reader.test.mjs +0 -583
- package/src/runtime/agent/orchestrator/session/task-wait-control.test.mjs +0 -78
- package/src/runtime/agent/orchestrator/tools/builtin/absence-absorption.test.mjs +0 -43
- package/src/runtime/agent/orchestrator/tools/builtin/absolute-glob-expand.test.mjs +0 -63
- package/src/runtime/agent/orchestrator/tools/builtin/bash-tool-cwd-env.test.mjs +0 -14
- package/src/runtime/agent/orchestrator/tools/builtin/edit-encoding-eol.test.mjs +0 -224
- package/src/runtime/agent/orchestrator/tools/builtin/edit-sequential-occupation.test.mjs +0 -224
- package/src/runtime/agent/orchestrator/tools/builtin/enoent-outside-project.test.mjs +0 -56
- package/src/runtime/agent/orchestrator/tools/builtin/find-search-budget.test.mjs +0 -103
- package/src/runtime/agent/orchestrator/tools/builtin/git-command-policy.test.mjs +0 -30
- package/src/runtime/agent/orchestrator/tools/builtin/git-command-tool.test.mjs +0 -390
- package/src/runtime/agent/orchestrator/tools/builtin/git-repo-rw-lock.test.mjs +0 -83
- package/src/runtime/agent/orchestrator/tools/builtin/grep-output-budget.test.mjs +0 -31
- package/src/runtime/agent/orchestrator/tools/builtin/grep-single-file-rescue.test.mjs +0 -106
- package/src/runtime/agent/orchestrator/tools/builtin/lib/shell-job-records.test.mjs +0 -102
- package/src/runtime/agent/orchestrator/tools/builtin/list-tool-integrity.test.mjs +0 -152
- package/src/runtime/agent/orchestrator/tools/builtin/native-search-health.test.mjs +0 -24
- package/src/runtime/agent/orchestrator/tools/builtin/native-search-transport.test.mjs +0 -24
- package/src/runtime/agent/orchestrator/tools/builtin/noise-dir-visibility.test.mjs +0 -69
- package/src/runtime/agent/orchestrator/tools/builtin/read-glob-survey.test.mjs +0 -71
- package/src/runtime/agent/orchestrator/tools/builtin/runtime-capabilities.test.mjs +0 -56
- package/src/runtime/agent/orchestrator/tools/builtin/search-builders.test.mjs +0 -16
- package/src/runtime/agent/orchestrator/tools/builtin/search-glob-top-k.test.mjs +0 -39
- package/src/runtime/agent/orchestrator/tools/builtin/write-symlink.test.mjs +0 -153
- package/src/runtime/agent/orchestrator/tools/code-graph/aggregate-anchor-relocation.test.mjs +0 -55
- package/src/runtime/agent/orchestrator/tools/code-graph/dispatch.test.mjs +0 -88
- package/src/runtime/agent/orchestrator/tools/code-graph/loose-file-target.test.mjs +0 -72
- package/src/runtime/agent/orchestrator/tools/code-graph/memory-cache.test.mjs +0 -54
- package/src/runtime/agent/orchestrator/tools/code-graph/search-references.test.mjs +0 -20
- package/src/runtime/agent/orchestrator/tools/code-graph/symbol-search-scope.test.mjs +0 -55
- package/src/runtime/agent/orchestrator/tools/code-graph/text-span-mask.test.mjs +0 -268
- package/src/runtime/agent/orchestrator/tools/env-scrub.test.mjs +0 -57
- package/src/runtime/agent/orchestrator/tools/graph-binary-fetcher.test.mjs +0 -19
- package/src/runtime/agent/orchestrator/tools/lib/native-spawn-client.test.mjs +0 -104
- package/src/runtime/agent/orchestrator/tools/patch/engine-contract-gate.test.mjs +0 -661
- package/src/runtime/agent/orchestrator/tools/patch/patch-codec-eol.test.mjs +0 -552
- package/src/runtime/agent/orchestrator/tools/patch/patch-symlink.test.mjs +0 -141
- package/src/runtime/agent/orchestrator/tools/patch/v4a-pure-move.test.mjs +0 -57
- package/src/runtime/agent/orchestrator/tools/patch/v4a-section-coalesce.test.mjs +0 -81
- package/src/runtime/agent/orchestrator/tools/spawn-binary-fetcher.test.mjs +0 -52
- package/src/runtime/attachments/store.test.mjs +0 -209
- package/src/runtime/channels/lib/voice-runtime-fetcher.test.mjs +0 -17
- package/src/runtime/channels/lib/webhook/deliveries.test.mjs +0 -18
- package/src/runtime/channels/lib/webhook/relay-tunnel.test.mjs +0 -68
- package/src/runtime/media/adapters/codex-image.test.mjs +0 -22
- package/src/runtime/media/download.test.mjs +0 -52
- package/src/runtime/media/renditions.test.mjs +0 -99
- package/src/runtime/media/store.test.mjs +0 -159
- package/src/runtime/memory/lib/archive-security.test.mjs +0 -128
- package/src/runtime/memory/lib/embedding-model-config.test.mjs +0 -33
- package/src/runtime/memory/lib/http-wire.test.mjs +0 -15
- package/src/runtime/memory/lib/memory-cycle-packets.test.mjs +0 -49
- package/src/runtime/memory/lib/memory-cycle2-shared.test.mjs +0 -78
- package/src/runtime/memory/lib/memory-embedding-migration.test.mjs +0 -50
- package/src/runtime/memory/lib/pg/process.test.mjs +0 -36
- package/src/runtime/memory/lib/trace-store.test.mjs +0 -57
- package/src/runtime/memory/lib/transcript-ingest.test.mjs +0 -52
- package/src/runtime/shared/background-tasks.test.mjs +0 -78
- package/src/runtime/shared/bounded-download.test.mjs +0 -41
- package/src/runtime/shared/channel-notification-routing.test.mjs +0 -25
- package/src/runtime/shared/child-spawn-remote.test.mjs +0 -124
- package/src/runtime/shared/remote-intent.test.mjs +0 -40
- package/src/runtime/shared/resource-admission.test.mjs +0 -43
- package/src/runtime/shared/runtime-root.test.mjs +0 -34
- package/src/runtime/shared/schedule-time.test.mjs +0 -29
- package/src/runtime/shared/session-runtime-health.test.mjs +0 -83
- package/src/runtime/shared/skill-document.test.mjs +0 -81
- package/src/runtime/shared/tool-surface.test.mjs +0 -87
- package/src/runtime/shared/update-checker.test.mjs +0 -33
- package/src/runtime/shared/user-cwd.test.mjs +0 -43
- package/src/runtime/shared/webhook-session-run.test.mjs +0 -14
- package/src/session-runtime/agent-disable.test.mjs +0 -123
- package/src/session-runtime/cwd-plugins.test.mjs +0 -75
- package/src/session-runtime/cwd-tool-routing.test.mjs +0 -61
- package/src/session-runtime/global-extensions.test.mjs +0 -28
- package/src/session-runtime/goal-runtime.test.mjs +0 -108
- package/src/session-runtime/lifecycle-api.test.mjs +0 -21
- package/src/session-runtime/model-settings-persist.test.mjs +0 -105
- package/src/session-runtime/notification-bus.test.mjs +0 -148
- package/src/session-runtime/plugin-mcp-standard.test.mjs +0 -177
- package/src/session-runtime/prewarm.test.mjs +0 -52
- package/src/session-runtime/provider-request-snapshot.test.mjs +0 -37
- package/src/session-runtime/resource-api-global.test.mjs +0 -69
- package/src/session-runtime/session-lifecycle.test.mjs +0 -125
- package/src/session-runtime/session-title.test.mjs +0 -36
- package/src/session-runtime/skills-api.test.mjs +0 -99
- package/src/session-runtime/tool-policy-surface.test.mjs +0 -331
- package/src/standalone/agent-tool/helpers.test.mjs +0 -62
- package/src/standalone/agent-tool/notify.test.mjs +0 -37
- package/src/standalone/agent-tool/spawn-flow.test.mjs +0 -63
- package/src/standalone/channel-restart.test.mjs +0 -145
- package/src/standalone/channel-session-router.test.mjs +0 -37
- package/src/standalone/channel-worker-heartbeat.test.mjs +0 -30
- package/src/standalone/hook-bus/handlers.test.mjs +0 -88
- package/src/standalone/plugin-admin.test.mjs +0 -173
- package/src/standalone/session-runtime-agent-control-client.test.mjs +0 -71
- package/src/standalone/session-runtime-dispatch-cancel.test.mjs +0 -139
- package/src/standalone/session-runtime-host-factory.test.mjs +0 -31
- package/src/standalone/session-runtime-host-health.test.mjs +0 -160
- package/src/standalone/session-runtime-inline-host.test.mjs +0 -83
- package/src/standalone/session-runtime-provider-cooldown.test.mjs +0 -80
- package/src/standalone/session-runtime-shard-host.test.mjs +0 -569
- package/src/standalone/session-runtime-shard-router.test.mjs +0 -101
- package/src/tui/app/live-spinner-visibility.test.mjs +0 -44
- package/src/tui/app/panel-epoch.test.mjs +0 -1009
- package/src/tui/app/panel-handoff.test.mjs +0 -311
- package/src/tui/app/prompt-submit.test.mjs +0 -206
- package/src/tui/session/completion-card-restore.test.mjs +0 -111
- package/src/tui/session/goal-continuation.test.mjs +0 -84
- package/src/tui/session/oauth-flows.test.mjs +0 -134
- package/src/tui/session/queue-helpers.test.mjs +0 -46
- package/src/tui/session/session-action-surface.test.mjs +0 -108
- package/src/tui/session/task-wait-submit.test.mjs +0 -80
- package/src/tui/session/tool-result-status.test.mjs +0 -131
- package/src/tui/session/tui-steering-persist.test.mjs +0 -104
|
@@ -278,9 +278,15 @@ import {
|
|
|
278
278
|
import { TOOL_DEFS as BROWSER_BRIDGE_TOOL_DEFS } from '../runtime/browser-bridge/tool-defs.mjs';
|
|
279
279
|
import {
|
|
280
280
|
computerBridgeAvailableSync,
|
|
281
|
+
deferComputerSessionRelease,
|
|
281
282
|
executeComputerTool,
|
|
282
283
|
} from '../runtime/computer-bridge/client.mjs';
|
|
283
284
|
import { TOOL_DEFS as COMPUTER_BRIDGE_TOOL_DEFS } from '../runtime/computer-bridge/tool-defs.mjs';
|
|
285
|
+
import {
|
|
286
|
+
executeOfficeTool,
|
|
287
|
+
initializeOfficeTransactions,
|
|
288
|
+
} from '../runtime/office/index.mjs';
|
|
289
|
+
import { TOOL_DEFS as OFFICE_TOOL_DEFS } from '../runtime/office/tool-defs.mjs';
|
|
284
290
|
import {
|
|
285
291
|
dispatchWebSearchRuntimeTool,
|
|
286
292
|
memoryToolArgsForCaller,
|
|
@@ -329,6 +335,9 @@ const {
|
|
|
329
335
|
export async function createMixdogSessionRuntime({
|
|
330
336
|
provider,
|
|
331
337
|
model,
|
|
338
|
+
effort,
|
|
339
|
+
fast,
|
|
340
|
+
modelParameters,
|
|
332
341
|
cwd = process.cwd(),
|
|
333
342
|
toolMode = 'full',
|
|
334
343
|
approvalMode = null,
|
|
@@ -337,6 +346,8 @@ export async function createMixdogSessionRuntime({
|
|
|
337
346
|
initialConfig = null,
|
|
338
347
|
remote = false,
|
|
339
348
|
desktopSession: initialDesktopSession = null,
|
|
349
|
+
sessionProfile: initialSessionProfile = null,
|
|
350
|
+
executeAgentControl = null,
|
|
340
351
|
} = {}) {
|
|
341
352
|
// Shared mutable runtime state, promoted from closure `let`s so extracted
|
|
342
353
|
// modules can read/write live values through one reference.
|
|
@@ -345,6 +356,9 @@ export async function createMixdogSessionRuntime({
|
|
|
345
356
|
rt.disallowDelegation = disallowDelegation === true;
|
|
346
357
|
rt.mcpScopeId = randomUUID();
|
|
347
358
|
rt.desktopSession = initialDesktopSession;
|
|
359
|
+
rt.sessionProfile = initialSessionProfile && typeof initialSessionProfile === 'object'
|
|
360
|
+
? { ...initialSessionProfile }
|
|
361
|
+
: null;
|
|
348
362
|
bootProfile('session-runtime:start', { provider, model, toolMode, cwd });
|
|
349
363
|
// Last assistant text handed to the transcript writer (via onAssistantText),
|
|
350
364
|
// so the post-turn final-content append can skip an exact duplicate.
|
|
@@ -355,6 +369,12 @@ export async function createMixdogSessionRuntime({
|
|
|
355
369
|
rootDir: STANDALONE_ROOT,
|
|
356
370
|
dataDir: STANDALONE_DATA_DIR,
|
|
357
371
|
});
|
|
372
|
+
// Office journals exist only for cross-process crash recovery, so startup just
|
|
373
|
+
// prunes expired ones in the background. Surfacing them as session context made
|
|
374
|
+
// every new session (agents included) re-announce unrelated leftovers for the
|
|
375
|
+
// full 30-day retention window; recovery stays reachable on demand through
|
|
376
|
+
// office action=transactions / action=recover.
|
|
377
|
+
initializeOfficeTransactions(STANDALONE_DATA_DIR).catch(() => {});
|
|
358
378
|
bootProfile('standalone-env:ready', { ms: (performance.now() - standaloneStartedAt).toFixed(1) });
|
|
359
379
|
const keychainPrewarmPromise = keychain.prewarmSecrets();
|
|
360
380
|
rt.keychainPrewarmWaitDone = false;
|
|
@@ -529,6 +549,11 @@ export async function createMixdogSessionRuntime({
|
|
|
529
549
|
setConfiguredShell(normalizeSystemShellConfig(rt.config.shell).command);
|
|
530
550
|
rt.configHasSecrets = false;
|
|
531
551
|
rt.route = resolveRoute(rt.config, { provider, model });
|
|
552
|
+
if (effort !== undefined) rt.route = { ...rt.route, effort: effort || null };
|
|
553
|
+
if (fast === true || fast === false) rt.route = { ...rt.route, fast };
|
|
554
|
+
if (modelParameters && typeof modelParameters === 'object') {
|
|
555
|
+
rt.route = { ...rt.route, modelParameters: { ...modelParameters } };
|
|
556
|
+
}
|
|
532
557
|
// Unset means the default "follow the Main Model" route, not "unconfigured".
|
|
533
558
|
rt.webSearchRoute = normalizeWebSearchRouteConfig(rt.config.webSearchRoute)
|
|
534
559
|
|| normalizeWebSearchRouteConfig({
|
|
@@ -857,13 +882,20 @@ export async function createMixdogSessionRuntime({
|
|
|
857
882
|
const routedAgentTool = {
|
|
858
883
|
...agentTool,
|
|
859
884
|
execute(args, context = {}) {
|
|
860
|
-
return
|
|
885
|
+
return typeof executeAgentControl === 'function'
|
|
886
|
+
? executeAgentControl(args, context)
|
|
887
|
+
: remoteAgentControlEnabled()
|
|
861
888
|
? executeRemoteAgentControl(args, context)
|
|
862
889
|
: agentTool.execute(args, context);
|
|
863
890
|
},
|
|
864
891
|
closeAll(reason, scope = {}) {
|
|
865
|
-
if (!remoteAgentControlEnabled())
|
|
866
|
-
|
|
892
|
+
if (typeof executeAgentControl !== 'function' && !remoteAgentControlEnabled()) {
|
|
893
|
+
return agentTool.closeAll(reason, scope);
|
|
894
|
+
}
|
|
895
|
+
const execute = typeof executeAgentControl === 'function'
|
|
896
|
+
? executeAgentControl
|
|
897
|
+
: executeRemoteAgentControl;
|
|
898
|
+
void execute({
|
|
867
899
|
type: '__close_all',
|
|
868
900
|
reason: String(reason || 'agent owner closed'),
|
|
869
901
|
}, {
|
|
@@ -893,6 +925,12 @@ export async function createMixdogSessionRuntime({
|
|
|
893
925
|
};
|
|
894
926
|
goalRuntime = createGoalRuntime({
|
|
895
927
|
dataDir: cfgMod.getPluginData?.() || STANDALONE_DATA_DIR,
|
|
928
|
+
generateTitle: async (source, options = {}) => {
|
|
929
|
+
const { generateSessionTitle } = await import(
|
|
930
|
+
'../runtime/agent/orchestrator/agent-runtime/title-completion.mjs'
|
|
931
|
+
);
|
|
932
|
+
return generateSessionTitle(source, options);
|
|
933
|
+
},
|
|
896
934
|
});
|
|
897
935
|
if (rt.session?.id || rt.reservedSessionId) {
|
|
898
936
|
goalRuntime.watchSession(rt.session?.id || rt.reservedSessionId);
|
|
@@ -934,6 +972,7 @@ export async function createMixdogSessionRuntime({
|
|
|
934
972
|
...(codeGraphToolDefs?.CODE_GRAPH_TOOL_DEFS || []).filter((tool) => tool?.name === 'code_graph'),
|
|
935
973
|
...BROWSER_BRIDGE_TOOL_DEFS.filter((tool) => tool?.name === 'browser'),
|
|
936
974
|
...COMPUTER_BRIDGE_TOOL_DEFS.filter((tool) => tool?.name === 'computer'),
|
|
975
|
+
...OFFICE_TOOL_DEFS.filter((tool) => tool?.name === 'office'),
|
|
937
976
|
...goalRuntime.tools,
|
|
938
977
|
...agentTool.tools,
|
|
939
978
|
].map(applyStandaloneToolDefaults);
|
|
@@ -948,7 +987,6 @@ export async function createMixdogSessionRuntime({
|
|
|
948
987
|
// replay) lives in tool-surface.mjs.
|
|
949
988
|
const {
|
|
950
989
|
modelStandaloneTools,
|
|
951
|
-
activateTools: activateRuntimeTools,
|
|
952
990
|
invalidatePreSessionToolSurface,
|
|
953
991
|
activeToolSurface,
|
|
954
992
|
applyPreSessionToolSelection,
|
|
@@ -1005,13 +1043,33 @@ export async function createMixdogSessionRuntime({
|
|
|
1005
1043
|
if (callerCtx?.invocationSource === 'model-tool' && featureEnvOverride('MIXDOG_FEATURE_BROWSER') === false) {
|
|
1006
1044
|
throw new Error('the browser tool is disabled in this environment');
|
|
1007
1045
|
}
|
|
1008
|
-
return await executeBrowserTool(args
|
|
1046
|
+
return await executeBrowserTool(args, {
|
|
1047
|
+
sessionId: callerCtx?.sessionId || callerCtx?.callerSessionId || rt.session?.id,
|
|
1048
|
+
turnId: callerCtx?.turnId || rt.session?.usageMetricsTurnId,
|
|
1049
|
+
signal: callerCtx?.signal || rt.session?.controller?.signal || null,
|
|
1050
|
+
});
|
|
1009
1051
|
}
|
|
1010
1052
|
if (name === 'computer') {
|
|
1011
1053
|
if (callerCtx?.invocationSource === 'model-tool' && featureEnvOverride('MIXDOG_FEATURE_COMPUTER') === false) {
|
|
1012
1054
|
throw new Error('the computer tool is disabled in this environment');
|
|
1013
1055
|
}
|
|
1014
|
-
return await executeComputerTool(args
|
|
1056
|
+
return await executeComputerTool(args, {
|
|
1057
|
+
sessionId: callerCtx?.sessionId || callerCtx?.callerSessionId || rt.session?.id,
|
|
1058
|
+
cwd: callerCwd,
|
|
1059
|
+
requestApproval: callerCtx?.toolApprovalHook,
|
|
1060
|
+
toolCallId: callerCtx?.toolCallId || null,
|
|
1061
|
+
signal: callerCtx?.signal || rt.session?.controller?.signal || null,
|
|
1062
|
+
});
|
|
1063
|
+
}
|
|
1064
|
+
if (name === 'office') {
|
|
1065
|
+
return await executeOfficeTool(args, {
|
|
1066
|
+
cwd: callerCwd,
|
|
1067
|
+
dataDir: STANDALONE_DATA_DIR,
|
|
1068
|
+
requestApproval: callerCtx?.toolApprovalHook,
|
|
1069
|
+
sessionId: callerCtx?.sessionId,
|
|
1070
|
+
toolCallId: callerCtx?.toolCallId,
|
|
1071
|
+
signal: callerCtx?.signal || rt.session?.controller?.signal || null,
|
|
1072
|
+
});
|
|
1015
1073
|
}
|
|
1016
1074
|
if (name === 'web_search' || name === 'web_fetch' || name === 'local_fetch' || name === 'image_fetch') {
|
|
1017
1075
|
return dispatchWebSearchRuntimeTool(name, args, callerCtx, {
|
|
@@ -1062,7 +1120,7 @@ export async function createMixdogSessionRuntime({
|
|
|
1062
1120
|
if (name === 'Skill') {
|
|
1063
1121
|
return skillToolContent(args?.name);
|
|
1064
1122
|
}
|
|
1065
|
-
if (name === 'get_goal' || name === 'create_goal' || name === 'update_goal') {
|
|
1123
|
+
if (name === 'goal' || name === 'get_goal' || name === 'create_goal' || name === 'set_goal_tasks' || name === 'update_goal') {
|
|
1066
1124
|
return await goalRuntime.executeTool(name, args || {}, {
|
|
1067
1125
|
callerSessionId: callerCtx?.callerSessionId || rt.session?.id || rt.reservedSessionId || null,
|
|
1068
1126
|
});
|
|
@@ -1572,16 +1630,14 @@ export async function createMixdogSessionRuntime({
|
|
|
1572
1630
|
});
|
|
1573
1631
|
const resourceApi = createResourceApi({
|
|
1574
1632
|
getConfig: () => rt.config,
|
|
1575
|
-
getSession: () => rt.session,
|
|
1576
1633
|
getCurrentCwd: () => rt.currentCwd,
|
|
1577
1634
|
cfgMod,
|
|
1578
|
-
mgr,
|
|
1579
1635
|
hooks,
|
|
1580
1636
|
STANDALONE_DATA_DIR,
|
|
1581
1637
|
saveConfigAndAdopt,
|
|
1582
1638
|
connectConfiguredMcp,
|
|
1583
1639
|
invalidatePreSessionToolSurface,
|
|
1584
|
-
|
|
1640
|
+
refreshEmptySessionToolPolicy,
|
|
1585
1641
|
normalizeMcpServerInput,
|
|
1586
1642
|
mcpStatus,
|
|
1587
1643
|
getMcpServerConfig,
|
|
@@ -1597,7 +1653,6 @@ export async function createMixdogSessionRuntime({
|
|
|
1597
1653
|
reloadFullConfig,
|
|
1598
1654
|
flushSkillsSave,
|
|
1599
1655
|
awaitKeychainPrewarm,
|
|
1600
|
-
getActiveTurnCount: () => rt.activeTurnCount,
|
|
1601
1656
|
});
|
|
1602
1657
|
disposeGlobalExtensionSubscription = () => resourceApi.disposeGlobalExtensionSubscription?.();
|
|
1603
1658
|
const modelRouteApi = createModelRouteApi({
|
|
@@ -1636,9 +1691,7 @@ export async function createMixdogSessionRuntime({
|
|
|
1636
1691
|
getRoute: () => rt.route,
|
|
1637
1692
|
setRouteState: (v) => { rt.route = v; },
|
|
1638
1693
|
getSession: () => rt.session,
|
|
1639
|
-
setSession: adoptSession,
|
|
1640
1694
|
cfgMod,
|
|
1641
|
-
mgr,
|
|
1642
1695
|
STANDALONE_DATA_DIR,
|
|
1643
1696
|
resolveRoute,
|
|
1644
1697
|
lookupModelMeta,
|
|
@@ -1656,8 +1709,6 @@ export async function createMixdogSessionRuntime({
|
|
|
1656
1709
|
getOutputStyleStatusCached,
|
|
1657
1710
|
seedOutputStyleStatusCache,
|
|
1658
1711
|
scheduleOutputStyleSave,
|
|
1659
|
-
recreateCurrentSessionIfReady,
|
|
1660
|
-
notifyFnForSession,
|
|
1661
1712
|
invalidateContextStatusCache,
|
|
1662
1713
|
invalidatePreSessionToolSurface,
|
|
1663
1714
|
refreshEmptySessionToolPolicy,
|
|
@@ -1696,8 +1747,8 @@ export async function createMixdogSessionRuntime({
|
|
|
1696
1747
|
scheduleProviderModelWarmup,
|
|
1697
1748
|
invalidateContextStatusCache,
|
|
1698
1749
|
agentTool: routedAgentTool,
|
|
1699
|
-
recreateCurrentSessionIfReady,
|
|
1700
1750
|
invalidatePreSessionToolSurface,
|
|
1751
|
+
refreshEmptySessionToolPolicy,
|
|
1701
1752
|
activeToolSurface,
|
|
1702
1753
|
applyResolvedCwd,
|
|
1703
1754
|
resolveCwdPath,
|
|
@@ -1709,6 +1760,7 @@ export async function createMixdogSessionRuntime({
|
|
|
1709
1760
|
getReservedSessionId: () => rt.reservedSessionId,
|
|
1710
1761
|
registerActiveTurnController,
|
|
1711
1762
|
sessionTitles,
|
|
1763
|
+
deferComputerSessionRelease,
|
|
1712
1764
|
});
|
|
1713
1765
|
|
|
1714
1766
|
return {
|
|
@@ -1775,20 +1827,20 @@ export async function createMixdogSessionRuntime({
|
|
|
1775
1827
|
sessionId = rt.session?.id || rt.reservedSessionId || null;
|
|
1776
1828
|
}
|
|
1777
1829
|
if (!sessionId) throw new Error('goal: session could not be created');
|
|
1778
|
-
|
|
1779
|
-
if (result?.goal?.status === 'active') {
|
|
1780
|
-
activateRuntimeTools(goalRuntime.tools.map((tool) => tool.name));
|
|
1781
|
-
}
|
|
1782
|
-
return result;
|
|
1830
|
+
return goalRuntime.control(sessionId, args);
|
|
1783
1831
|
},
|
|
1784
1832
|
goalContinuation() {
|
|
1785
1833
|
const sessionId = rt.session?.id || rt.reservedSessionId || null;
|
|
1786
1834
|
if (!sessionId) return { run: false, reason: 'missing-session', goal: null };
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
return
|
|
1835
|
+
return goalRuntime.continuation(sessionId, { agentStatus: agentStatusState() });
|
|
1836
|
+
},
|
|
1837
|
+
goalTurnStarted() {
|
|
1838
|
+
const sessionId = rt.session?.id || rt.reservedSessionId || null;
|
|
1839
|
+
return sessionId ? goalRuntime.startTurn(sessionId) : null;
|
|
1840
|
+
},
|
|
1841
|
+
goalTurnSettled(detail = {}) {
|
|
1842
|
+
const sessionId = rt.session?.id || rt.reservedSessionId || null;
|
|
1843
|
+
return sessionId ? goalRuntime.settleTurn(sessionId, detail) : null;
|
|
1792
1844
|
},
|
|
1793
1845
|
archiveCompletedGoalOnUserInput() {
|
|
1794
1846
|
const sessionId = rt.session?.id || rt.reservedSessionId || null;
|
|
@@ -243,30 +243,37 @@ export function createSessionLifecycle({
|
|
|
243
243
|
const dataDir = cfgMod.getPluginData?.() || STANDALONE_DATA_DIR;
|
|
244
244
|
// Load the active WORKFLOW.md pack once for both summary + context block.
|
|
245
245
|
const { summary: workflow, context: workflowContext } = activeWorkflowContext(rt.config, dataDir);
|
|
246
|
+
const sessionProfile = rt.sessionProfile && typeof rt.sessionProfile === 'object'
|
|
247
|
+
? rt.sessionProfile
|
|
248
|
+
: null;
|
|
249
|
+
const agentOwned = sessionProfile?.owner === 'agent'
|
|
250
|
+
|| sessionProfile?.visibility === 'agent-only';
|
|
246
251
|
const sessionOpts = {
|
|
247
252
|
...(rt.reservedSessionId ? { id: rt.reservedSessionId } : {}),
|
|
248
253
|
provider: rt.route.provider,
|
|
249
254
|
model: rt.route.model,
|
|
250
255
|
preset: rt.route.preset || undefined,
|
|
251
256
|
tools: toolSpecForMode(rt.mode),
|
|
252
|
-
owner: 'cli',
|
|
253
|
-
agent: 'lead',
|
|
254
|
-
lane: 'cli',
|
|
255
|
-
sourceType: 'lead',
|
|
256
|
-
sourceName: 'main',
|
|
257
|
+
owner: agentOwned ? 'agent' : 'cli',
|
|
258
|
+
agent: agentOwned ? (sessionProfile?.agent || 'worker') : 'lead',
|
|
259
|
+
lane: agentOwned ? 'agent' : 'cli',
|
|
260
|
+
sourceType: agentOwned ? (sessionProfile?.sourceType || 'agent') : 'lead',
|
|
261
|
+
sourceName: agentOwned ? (sessionProfile?.sourceName || sessionProfile?.agent || 'agent') : 'main',
|
|
257
262
|
...(rt.approvalMode ? { approvalMode: rt.approvalMode } : {}),
|
|
258
|
-
clientHostPid: process.pid,
|
|
263
|
+
clientHostPid: sessionProfile?.clientHostPid || process.pid,
|
|
259
264
|
mcpScopeId: rt.mcpScopeId,
|
|
260
|
-
disallowedTools:
|
|
261
|
-
...
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
+
disallowedTools: agentOwned
|
|
266
|
+
? [...featureDisallowedTools()]
|
|
267
|
+
: [
|
|
268
|
+
...LEAD_DISALLOWED_TOOLS,
|
|
269
|
+
...(rt.disallowDelegation ? ['agent'] : []),
|
|
270
|
+
...featureDisallowedTools(),
|
|
271
|
+
],
|
|
265
272
|
cwd: rt.currentCwd,
|
|
266
273
|
...(rt.desktopSession && typeof rt.desktopSession === 'object' ? { desktopSession: rt.desktopSession } : {}),
|
|
267
274
|
coreMemoryContext,
|
|
268
275
|
workflow,
|
|
269
|
-
workflowContext,
|
|
276
|
+
workflowContext: [workflowContext, rt.officeRecoveryContext].filter(Boolean).join('\n\n'),
|
|
270
277
|
fast: rt.route.fast === true,
|
|
271
278
|
modelParameters: rt.route.modelParameters || {},
|
|
272
279
|
contextPercent: rt.route.contextPercent,
|
|
@@ -274,6 +281,21 @@ export function createSessionLifecycle({
|
|
|
274
281
|
compaction: rt.config.compaction && typeof rt.config.compaction === 'object'
|
|
275
282
|
? normalizeCompactionConfig(rt.config.compaction)
|
|
276
283
|
: undefined,
|
|
284
|
+
...(agentOwned ? {
|
|
285
|
+
parentSessionId: sessionProfile?.parentSessionId || null,
|
|
286
|
+
ownerSessionId: sessionProfile?.ownerSessionId || sessionProfile?.parentSessionId || null,
|
|
287
|
+
visibility: 'agent-only',
|
|
288
|
+
agentTag: sessionProfile?.agentTag || null,
|
|
289
|
+
taskType: sessionProfile?.taskType || null,
|
|
290
|
+
maxLoopIterations: Number.isFinite(sessionProfile?.maxLoopIterations)
|
|
291
|
+
? sessionProfile.maxLoopIterations
|
|
292
|
+
: undefined,
|
|
293
|
+
permission: sessionProfile?.permission || undefined,
|
|
294
|
+
permissionMode: sessionProfile?.permissionMode || undefined,
|
|
295
|
+
schemaAllowedTools: Array.isArray(sessionProfile?.schemaAllowedTools)
|
|
296
|
+
? sessionProfile.schemaAllowedTools
|
|
297
|
+
: undefined,
|
|
298
|
+
} : {}),
|
|
277
299
|
};
|
|
278
300
|
if (hasOwn(rt.route, 'effort') || rt.route.effectiveEffort) {
|
|
279
301
|
sessionOpts.effort = rt.route.effectiveEffort || null;
|
|
@@ -27,7 +27,7 @@ function hasMeaningfulTitleText(value) {
|
|
|
27
27
|
return /[\p{L}\p{N}]/u.test(String(value || ''));
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
function
|
|
30
|
+
export function compactSessionTitle(value, maximum = 32) {
|
|
31
31
|
const line = String(value || '')
|
|
32
32
|
.replace(/<think>[\s\S]*?<\/think>\s*/gi, '')
|
|
33
33
|
.split(/\r?\n/)
|
|
@@ -179,7 +179,7 @@ export function createSessionTitleController(deps = {}) {
|
|
|
179
179
|
}),
|
|
180
180
|
timeout,
|
|
181
181
|
]);
|
|
182
|
-
const title =
|
|
182
|
+
const title = compactSessionTitle(raw);
|
|
183
183
|
log(`generated id=${sessionId} stage=${stage} title=${JSON.stringify(title)}`);
|
|
184
184
|
if (title) await promote(sessionId, title, stage);
|
|
185
185
|
} finally {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { clean
|
|
1
|
+
import { clean } from './session-text.mjs';
|
|
2
2
|
import { envFlag } from './env.mjs';
|
|
3
3
|
import { normalizeToolMode } from './effort.mjs';
|
|
4
4
|
import {
|
|
@@ -44,10 +44,11 @@ export function createSessionTurnApi(deps) {
|
|
|
44
44
|
ensureSessionTranscriptWriter, channels,
|
|
45
45
|
hooks, hookCommonPayload, mgr, notifyFnForSession, subscribeRuntimeNotification, bootProfile,
|
|
46
46
|
scheduleProviderWarmup, scheduleProviderModelWarmup, invalidateContextStatusCache,
|
|
47
|
-
agentTool,
|
|
47
|
+
agentTool, invalidatePreSessionToolSurface, refreshEmptySessionToolPolicy,
|
|
48
48
|
activeToolSurface, applyResolvedCwd, resolveCwdPath, agentStatusState, notificationListeners,
|
|
49
49
|
awaitInitialMcpConnect, mcpTurnGraceMs = 0, awaitRoutePreparation,
|
|
50
50
|
getReservedSessionId, sessionTitles, registerActiveTurnController,
|
|
51
|
+
deferComputerSessionRelease = () => false,
|
|
51
52
|
beginTurnSnapshotForTurn = beginTurnSnapshot,
|
|
52
53
|
cancelTurnSnapshotForTurn = cancelTurnSnapshot,
|
|
53
54
|
completeTurnSnapshotForTurn = completeTurnSnapshot,
|
|
@@ -269,14 +270,10 @@ export function createSessionTurnApi(deps) {
|
|
|
269
270
|
try { await awaitTurn(() => awaitMcpGrace()); }
|
|
270
271
|
catch { /* gate must never break the turn */ }
|
|
271
272
|
try {
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
enqueue: (text) => (typeof mgr.enqueuePendingMessage === 'function'
|
|
277
|
-
? mgr.enqueuePendingMessage(session0.id, text) > 0
|
|
278
|
-
: false),
|
|
279
|
-
});
|
|
273
|
+
// Persist a typed world-state delta on the session. askSession
|
|
274
|
+
// attaches it to THIS real prompt; reconciliation itself never
|
|
275
|
+
// enqueues a follow-up turn.
|
|
276
|
+
reconcileDeferredMcpToolCatalog(session0, getMcpTools(session0.mcpScopeId));
|
|
280
277
|
}
|
|
281
278
|
catch { /* MCP delta must never break the turn */ }
|
|
282
279
|
}
|
|
@@ -425,6 +422,9 @@ export function createSessionTurnApi(deps) {
|
|
|
425
422
|
} catch { /* best-effort: StopFailure hook must never break teardown */ }
|
|
426
423
|
throw error;
|
|
427
424
|
} finally {
|
|
425
|
+
try { deferComputerSessionRelease(session0.id); } catch {
|
|
426
|
+
/* deferred computer lease cleanup never overrides turn settlement */
|
|
427
|
+
}
|
|
428
428
|
releaseFirstTitle?.();
|
|
429
429
|
emitTurnTiming(turnTimingStatus);
|
|
430
430
|
armHeavyRuntimeWarmup('turn-settled');
|
|
@@ -503,10 +503,11 @@ export function createSessionTurnApi(deps) {
|
|
|
503
503
|
async setToolMode(nextMode) {
|
|
504
504
|
const mode = normalizeToolMode(nextMode);
|
|
505
505
|
setMode(mode);
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
506
|
+
if (typeof refreshEmptySessionToolPolicy === 'function') {
|
|
507
|
+
await refreshEmptySessionToolPolicy();
|
|
508
|
+
} else {
|
|
509
|
+
invalidatePreSessionToolSurface();
|
|
510
|
+
}
|
|
510
511
|
return mode;
|
|
511
512
|
},
|
|
512
513
|
agentStatus() {
|
|
@@ -38,7 +38,7 @@ export const DEFERRED_DEFAULT_LEAD_TOOLS = Object.freeze([
|
|
|
38
38
|
// cwd / web_fetch demoted to the deferred manifest 2026-08:
|
|
39
39
|
// 0 / 10 calls in a 3-day 7.6k-call trace window; they auto-load on
|
|
40
40
|
// first direct call.
|
|
41
|
-
'edit', 'apply_patch', 'git', 'shell', 'task', 'agent', 'recall', 'web_search',
|
|
41
|
+
'edit', 'apply_patch', 'git', 'shell', 'task', 'agent', 'recall', 'web_search', 'goal',
|
|
42
42
|
'Skill', 'load_tool',
|
|
43
43
|
]);
|
|
44
44
|
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// Deferred-tool catalog: measured-usage ordering, kind/bucket classification,
|
|
2
2
|
// tool_search ranking + auto-selection, and the session tool-surface
|
|
3
3
|
// application/selection logic. Pure module (session objects passed in).
|
|
4
|
-
import { clean
|
|
4
|
+
import { clean } from './session-text.mjs';
|
|
5
|
+
import { mergePendingDeferredToolDelta } from './deferred-tool-delta.mjs';
|
|
5
6
|
import { estimateToolSchemaTokens, toolSchemaSignature } from '../runtime/agent/orchestrator/session/context-utils.mjs';
|
|
6
7
|
import {
|
|
7
8
|
applyInitialDeferredToolManifestToBp2,
|
|
@@ -272,9 +273,12 @@ export function applyDeferredToolSurface(session, mode, extraTools = [], options
|
|
|
272
273
|
if (!session || !Array.isArray(session.tools)) return session;
|
|
273
274
|
const providerMode = deferredProviderMode(options.provider || session.provider);
|
|
274
275
|
const byName = new Map();
|
|
275
|
-
const candidates =
|
|
276
|
-
|
|
277
|
-
|
|
276
|
+
const candidates = filterDisallowedTools(
|
|
277
|
+
filterModelEditTools(
|
|
278
|
+
[...session.tools, ...(extraTools || [])],
|
|
279
|
+
options.model || session.model,
|
|
280
|
+
),
|
|
281
|
+
options.disallowed,
|
|
278
282
|
);
|
|
279
283
|
for (const tool of candidates) {
|
|
280
284
|
const name = clean(tool?.name);
|
|
@@ -450,12 +454,9 @@ export function refreshInitialDeferredMcpSurface(session, liveMcpTools) {
|
|
|
450
454
|
* one the Anthropic providers serialize as defer_loading tools — is never
|
|
451
455
|
* touched, so the tools request parameter (and its cache hash) is byte-identical
|
|
452
456
|
* until a late tool is actually loaded (promoted onto session.tools).
|
|
453
|
-
*
|
|
454
|
-
*
|
|
455
|
-
*
|
|
456
|
-
* to a tail append ONLY when the transcript tail is an assistant turn, else defer
|
|
457
|
-
* the announcement (names stay un-announced and are retried next turn). No filler
|
|
458
|
-
* assistant messages are ever appended.
|
|
457
|
+
* Late additions/removals are merged into one persistent typed delta. The ask
|
|
458
|
+
* boundary attaches that delta to the next real prompt and acknowledges it only
|
|
459
|
+
* after the provider accepts the turn; a catalog change never creates a turn.
|
|
459
460
|
* A disconnected server's unloaded tools leave the late pool; a loaded (active)
|
|
460
461
|
* tool stays on session.tools, is never announced as removed, and is re-linked to
|
|
461
462
|
* the fresh server tool on reconnect.
|
|
@@ -528,100 +529,38 @@ export function reconcileDeferredMcpToolCatalog(session, liveMcpTools, options =
|
|
|
528
529
|
}
|
|
529
530
|
}
|
|
530
531
|
|
|
531
|
-
const
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
const fresh = [];
|
|
532
|
+
const previousNames = new Set(
|
|
533
|
+
lateCatalog.map((tool) => clean(tool?.name)).filter((name) => name && isMcp(name)),
|
|
534
|
+
);
|
|
535
|
+
const nextNames = new Set(
|
|
536
|
+
session.deferredLateToolCatalog
|
|
537
|
+
.map((tool) => clean(tool?.name))
|
|
538
|
+
.filter((name) => name && isMcp(name)),
|
|
539
|
+
);
|
|
540
|
+
const startupNames = new Set(
|
|
541
|
+
Array.isArray(session.deferredAnnouncedTools) ? session.deferredAnnouncedTools : [],
|
|
542
|
+
);
|
|
543
|
+
const bootNames = new Set(
|
|
544
|
+
(Array.isArray(session.deferredToolCatalog) ? session.deferredToolCatalog : [])
|
|
545
|
+
.map((tool) => clean(tool?.name))
|
|
546
|
+
.filter(Boolean),
|
|
547
|
+
);
|
|
548
|
+
const added = [];
|
|
549
549
|
for (const tool of session.deferredLateToolCatalog) {
|
|
550
550
|
const name = clean(tool?.name);
|
|
551
551
|
if (!name || !isMcp(name)) continue;
|
|
552
|
-
if (active.has(name) ||
|
|
553
|
-
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
const reminder = `<system-reminder>\nTools from MCP servers that ${LATE_TOOL_ANNOUNCEMENT_SENTINEL} are now available. Call any tool listed below directly by name; it loads on first use.\n\n${manifest}\n</system-reminder>`;
|
|
560
|
-
const delivery = deliverDeferredAnnouncement(session, reminder, options);
|
|
561
|
-
if (!delivery) return null;
|
|
562
|
-
// Only the tail-append path commits into session.messages synchronously, so
|
|
563
|
-
// mark it announced now. Enqueued reminders are marked on the next reconcile's
|
|
564
|
-
// transcript scan (post-drain) — never at enqueue time (crash-safety above).
|
|
565
|
-
if (delivery === 'committed') {
|
|
566
|
-
for (const entry of fresh) announced.add(entry.name);
|
|
567
|
-
session.deferredAnnouncedTools = sortedNamesByMeasuredUsage([...announced]);
|
|
552
|
+
if (previousNames.has(name) || active.has(name) || startupNames.has(name)) continue;
|
|
553
|
+
added.push({ name, description: lateAnnouncementDescription(tool?.description) });
|
|
554
|
+
}
|
|
555
|
+
const removed = [];
|
|
556
|
+
for (const name of previousNames) {
|
|
557
|
+
if (nextNames.has(name) || active.has(name) || bootNames.has(name)) continue;
|
|
558
|
+
removed.push(name);
|
|
568
559
|
}
|
|
560
|
+
if (!added.length && !removed.length) return null;
|
|
561
|
+
mergePendingDeferredToolDelta(session, { added, removed });
|
|
569
562
|
session.updatedAt = Date.now();
|
|
570
|
-
return
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
// Sentinel phrase carried in every late-tool reminder; used to recognise a
|
|
574
|
-
// delivered (committed) announcement inside session.messages regardless of
|
|
575
|
-
// whether the pending drain merged it with other queued user content.
|
|
576
|
-
// Single source of truth lives in session-text.mjs (imported above) so the
|
|
577
|
-
// hide-from-UI detection can never drift from the emitted reminder text.
|
|
578
|
-
function reminderMessageText(content) {
|
|
579
|
-
if (typeof content === 'string') return content;
|
|
580
|
-
if (Array.isArray(content)) {
|
|
581
|
-
return content.map((b) => (typeof b === 'string' ? b : String(b?.text || ''))).join('\n');
|
|
582
|
-
}
|
|
583
|
-
return '';
|
|
584
|
-
}
|
|
585
|
-
|
|
586
|
-
// Late-tool names whose reminder is already present in session.messages (either
|
|
587
|
-
// tail-appended directly or drained in from the pending queue). Idempotent.
|
|
588
|
-
function committedAnnouncedLateTools(session, lateNames) {
|
|
589
|
-
const names = Array.isArray(lateNames) ? lateNames.filter(Boolean) : [];
|
|
590
|
-
if (!names.length) return [];
|
|
591
|
-
const msgs = Array.isArray(session?.messages) ? session.messages : [];
|
|
592
|
-
const blob = msgs
|
|
593
|
-
.filter((m) => m && m.role === 'user')
|
|
594
|
-
.map((m) => reminderMessageText(m.content))
|
|
595
|
-
.filter((t) => t.includes(LATE_TOOL_ANNOUNCEMENT_SENTINEL))
|
|
596
|
-
.join('\n');
|
|
597
|
-
if (!blob) return [];
|
|
598
|
-
return names.filter((name) => blob.includes(name));
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
// Deliver the late-tool <system-reminder> without any '.' filler turn. Primary
|
|
602
|
-
// path: the pending-message queue (options.enqueue) — the SAME mechanism that
|
|
603
|
-
// carries tool-completion notifications. The queue drains AFTER the current
|
|
604
|
-
// turn's assistant terminal response (ask-session.mjs), so the reminder rides a
|
|
605
|
-
// fresh follow-up user turn that always follows an assistant turn; strict
|
|
606
|
-
// role-alternation holds and no wire-level same-role merge is needed (the
|
|
607
|
-
// Anthropic/OpenAI lowering never merges two plain user turns, and none occurs
|
|
608
|
-
// here). Returns 'enqueued' (commit deferred to drain) on that path.
|
|
609
|
-
// Fallback (queue unreachable, e.g. unit tests): append a user reminder ONLY
|
|
610
|
-
// when the transcript tail is an assistant turn — that commits synchronously
|
|
611
|
-
// ('committed'); otherwise defer to the next turn (null).
|
|
612
|
-
function deliverDeferredAnnouncement(session, reminder, options) {
|
|
613
|
-
const enqueue = typeof options?.enqueue === 'function' ? options.enqueue : null;
|
|
614
|
-
if (enqueue) {
|
|
615
|
-
try { if (enqueue(reminder) === true) return 'enqueued'; }
|
|
616
|
-
catch { /* fall through to the tail-append fallback */ }
|
|
617
|
-
}
|
|
618
|
-
const messages = session.messages;
|
|
619
|
-
const tail = messages[messages.length - 1];
|
|
620
|
-
if (tail && tail.role === 'assistant') {
|
|
621
|
-
messages.push({ role: 'user', meta: 'hook', content: reminder });
|
|
622
|
-
return 'committed';
|
|
623
|
-
}
|
|
624
|
-
return null;
|
|
563
|
+
return [...added.map((entry) => entry.name), ...removed];
|
|
625
564
|
}
|
|
626
565
|
|
|
627
566
|
export function selectDeferredTools(session, names, mode) {
|
|
@@ -67,7 +67,12 @@ export const SKILL_TOOL = {
|
|
|
67
67
|
},
|
|
68
68
|
};
|
|
69
69
|
|
|
70
|
-
export const LEAD_DISALLOWED_TOOLS = Object.freeze([
|
|
70
|
+
export const LEAD_DISALLOWED_TOOLS = Object.freeze([
|
|
71
|
+
'get_goal',
|
|
72
|
+
'create_goal',
|
|
73
|
+
'set_goal_tasks',
|
|
74
|
+
'update_goal',
|
|
75
|
+
]);
|
|
71
76
|
const AGENT_HIDDEN_WRAPPER_TOOLS = new Set([]);
|
|
72
77
|
|
|
73
78
|
export function applyStandaloneToolDefaults(tool) {
|