mixdog 1.4.2 → 1.4.4
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/package.json +2 -2
- package/scripts/build-shipped-history.mjs +15 -5
- package/scripts/gate-local.mjs +65 -19
- package/scripts/graph-parity.mjs +8 -3
- package/scripts/lib/gate-scheduler.mjs +2 -1
- package/scripts/lib/run-node-tests.mjs +17 -5
- package/scripts/lib/test-failure-summary.mjs +1 -8
- package/scripts/lib/test-spawn-ledger.mjs +33 -2
- package/scripts/post-release-check.mjs +26 -16
- package/scripts/provider-pingpong-live.mjs +1 -1
- package/scripts/prune-embedding-runtime.mjs +3 -1
- package/scripts/release-paths.mjs +7 -1
- package/src/defaults/shipped-history.json +24 -0
- package/src/defaults/skills/computer-use/SKILL.md +14 -3
- package/src/defaults/skills/memory-management/SKILL.md +10 -5
- package/src/defaults/skills/setup/SKILL.md +2 -2
- package/src/defaults/skills/setup/references/actions.md +17 -4
- package/src/defaults/skills/setup/references/surfaces.md +3 -0
- package/src/defaults/skills/setup-guide/SKILL.md +6 -1
- package/src/lib/instruction-text.cjs +36 -0
- package/src/lib/rules-builder.cjs +34 -20
- package/src/orchestration/balanced.md +23 -0
- package/src/orchestration/focused.md +22 -0
- package/src/orchestration/none.md +5 -0
- package/src/orchestration/swarm.md +24 -0
- package/src/rules/agent-mode/AGENT_MODE.md +3 -1
- package/src/rules/agent-mode/MIXY.md +5 -3
- package/src/runtime/agent/orchestrator/agent-runtime/agent-dispatch/session-prep.mjs +3 -3
- package/src/runtime/agent/orchestrator/agent-runtime/agent-dispatch.mjs +0 -1
- package/src/runtime/agent/orchestrator/agent-runtime/agent-progress-watchdog.mjs +4 -2
- package/src/runtime/agent/orchestrator/agent-runtime/cache-strategy.mjs +0 -9
- package/src/runtime/agent/orchestrator/agent-runtime/heartbeat-completion.mjs +2 -2
- package/src/runtime/agent/orchestrator/agent-runtime/session-builder.mjs +67 -0
- package/src/runtime/agent/orchestrator/agent-trace-format.mjs +1 -0
- package/src/runtime/agent/orchestrator/context/role-instructions.mjs +4 -4
- package/src/runtime/agent/orchestrator/mcp/agent-connectors.mjs +3 -1
- package/src/runtime/agent/orchestrator/mcp/child-tree.mjs +199 -46
- package/src/runtime/agent/orchestrator/mcp/client-config.mjs +3 -5
- package/src/runtime/agent/orchestrator/mcp/client-transport.mjs +9 -3
- package/src/runtime/agent/orchestrator/mcp/client.mjs +3 -5
- package/src/runtime/agent/orchestrator/mcp/oauth-client.mjs +1 -1
- package/src/runtime/agent/orchestrator/mcp/oauth-credentials.mjs +8 -2
- package/src/runtime/agent/orchestrator/mcp/oauth-probe.mjs +1 -1
- package/src/runtime/agent/orchestrator/mcp/oauth-provider.mjs +14 -0
- package/src/runtime/agent/orchestrator/mcp/oauth.mjs +1 -1
- package/src/runtime/agent/orchestrator/providers/admission-scheduler.mjs +2 -1
- package/src/runtime/agent/orchestrator/providers/anthropic-api-request.mjs +11 -1
- package/src/runtime/agent/orchestrator/providers/anthropic-oauth-client-version.mjs +1 -1
- package/src/runtime/agent/orchestrator/providers/anthropic-sse-turn/turn-events/content-block-start.mjs +4 -0
- package/src/runtime/agent/orchestrator/providers/anthropic-sse-turn/turn-events/content-block-stop.mjs +3 -3
- package/src/runtime/agent/orchestrator/providers/anthropic-sse-turn/turn-outcome.mjs +2 -0
- package/src/runtime/agent/orchestrator/providers/anthropic-turn-result.mjs +2 -0
- package/src/runtime/agent/orchestrator/providers/anthropic.mjs +2 -0
- package/src/runtime/agent/orchestrator/providers/codex-client-meta.mjs +1 -1
- package/src/runtime/agent/orchestrator/providers/custom-provider-config.mjs +121 -9
- package/src/runtime/agent/orchestrator/providers/custom-provider.mjs +4 -1
- package/src/runtime/agent/orchestrator/providers/gemini-thinking.mjs +2 -2
- package/src/runtime/agent/orchestrator/providers/lib/generation-window.mjs +9 -0
- package/src/runtime/agent/orchestrator/providers/openai-compat-chat-send.mjs +9 -1
- package/src/runtime/agent/orchestrator/providers/openai-compat-chat-stream/stream-result.mjs +2 -0
- package/src/runtime/agent/orchestrator/providers/openai-compat-chat-stream/stream-state.mjs +5 -0
- package/src/runtime/agent/orchestrator/providers/openai-compat-options.mjs +3 -0
- package/src/runtime/agent/orchestrator/providers/openai-compat-response-normalization.mjs +6 -6
- package/src/runtime/agent/orchestrator/providers/openai-compat-responses-head-parity.json +2784 -2872
- package/src/runtime/agent/orchestrator/providers/openai-compat-responses.mjs +10 -1
- package/src/runtime/agent/orchestrator/providers/openai-compat-xai.mjs +5 -8
- package/src/runtime/agent/orchestrator/providers/openai-http-sse-response-state/response-events.mjs +3 -0
- package/src/runtime/agent/orchestrator/providers/openai-http-sse-response-state/response-outcome.mjs +2 -0
- package/src/runtime/agent/orchestrator/providers/openai-responses-payload-parity.fixture.json +288 -300
- package/src/runtime/agent/orchestrator/providers/openai-ws-response-state.mjs +9 -2
- package/src/runtime/agent/orchestrator/providers/openrouter-provider-routing.mjs +28 -0
- package/src/runtime/agent/orchestrator/providers/openrouter.mjs +4 -1
- package/src/runtime/agent/orchestrator/providers/registry.mjs +30 -25
- package/src/runtime/agent/orchestrator/providers/vertex-ai.mjs +10 -1
- package/src/runtime/agent/orchestrator/providers/xai-tool-search-head-parity.json +10 -30
- package/src/runtime/agent/orchestrator/runtime-core/ask-user-result.mjs +66 -0
- package/src/runtime/agent/orchestrator/runtime-core/builtin-features.mjs +30 -0
- package/src/runtime/agent/orchestrator/runtime-core/config-helpers.mjs +0 -11
- package/src/runtime/agent/orchestrator/runtime-core/deferred-tool-availability.mjs +8 -0
- package/src/runtime/agent/orchestrator/runtime-core/deferred-tool-delta.mjs +17 -3
- package/src/runtime/agent/orchestrator/runtime-core/goal-control.mjs +47 -27
- package/src/runtime/agent/orchestrator/runtime-core/goal-deadlines.mjs +141 -10
- package/src/runtime/agent/orchestrator/runtime-core/goal-mutations.mjs +26 -63
- package/src/runtime/agent/orchestrator/runtime-core/goal-reminder.mjs +28 -3
- package/src/runtime/agent/orchestrator/runtime-core/goal-runtime.mjs +36 -11
- package/src/runtime/agent/orchestrator/runtime-core/goal-state.mjs +88 -56
- package/src/runtime/agent/orchestrator/runtime-core/goal-storage.mjs +4 -1
- package/src/runtime/agent/orchestrator/runtime-core/goal-store.mjs +51 -32
- package/src/runtime/agent/orchestrator/runtime-core/goal-text.mjs +45 -145
- package/src/runtime/agent/orchestrator/runtime-core/goal-tool-defs.mjs +15 -98
- package/src/runtime/agent/orchestrator/runtime-core/goal-tool-exec.mjs +32 -99
- package/src/runtime/agent/orchestrator/runtime-core/goal-turns.mjs +23 -78
- package/src/runtime/agent/orchestrator/runtime-core/orchestration.mjs +69 -48
- package/src/runtime/agent/orchestrator/runtime-core/todo-list.mjs +367 -0
- package/src/runtime/agent/orchestrator/runtime-core/todo-tool-defs.mjs +47 -0
- package/src/runtime/agent/orchestrator/runtime-core/tool-availability.mjs +155 -0
- package/src/runtime/agent/orchestrator/runtime-core/tool-catalog-data.mjs +9 -0
- package/src/runtime/agent/orchestrator/runtime-core/tool-catalog.mjs +119 -35
- package/src/runtime/agent/orchestrator/runtime-core/tool-defs.mjs +1 -1
- package/src/runtime/agent/orchestrator/runtime-core/workflow/context.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/agent-loop.mjs +28 -22
- package/src/runtime/agent/orchestrator/session/agent-pool-progress.mjs +30 -0
- package/src/runtime/agent/orchestrator/session/attachment-preflight.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/cache-warm.mjs +2 -2
- package/src/runtime/agent/orchestrator/session/catalog-db/index.mjs +2 -2
- package/src/runtime/agent/orchestrator/session/catalog-db/schema.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/compact/execution-tail.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/compact/runner.mjs +3 -0
- package/src/runtime/agent/orchestrator/session/compact/summary-route.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/context-utils.mjs +8 -12
- package/src/runtime/agent/orchestrator/session/conversation-import/claude.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/conversation-import/codex.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/conversation-import/convert.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/conversation-import/imported-session.mjs +7 -3
- package/src/runtime/agent/orchestrator/session/human-gate/held-message.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/human-gate/requests.mjs +1 -2
- package/src/runtime/agent/orchestrator/session/human-gate/run-policy.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/image-strip-recovery.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/loop/completion-guards.mjs +11 -1
- package/src/runtime/agent/orchestrator/session/loop/context-overflow.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/loop/loop-state.mjs +8 -1
- package/src/runtime/agent/orchestrator/session/loop/no-tool-turn/todo-check.mjs +196 -0
- package/src/runtime/agent/orchestrator/session/loop/no-tool-turn.mjs +116 -50
- package/src/runtime/agent/orchestrator/session/loop/pre-dispatch-deny.mjs +8 -1
- package/src/runtime/agent/orchestrator/session/loop/provider-tool-exclusions.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/loop/route-fallback.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/loop/steering.mjs +3 -1
- package/src/runtime/agent/orchestrator/session/loop/stored-tool-args.mjs +5 -6
- package/src/runtime/agent/orchestrator/session/loop/tool-exec/before-hook.mjs +6 -1
- package/src/runtime/agent/orchestrator/session/loop/tool-exec/dispatch.mjs +16 -2
- package/src/runtime/agent/orchestrator/session/loop/turn-report.mjs +35 -0
- package/src/runtime/agent/orchestrator/session/loop/usage.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/manager/ask-session.mjs +57 -26
- package/src/runtime/agent/orchestrator/session/manager/ask-turn-auto-effort.mjs +9 -7
- package/src/runtime/agent/orchestrator/session/manager/ask-turn-execute.mjs +21 -3
- package/src/runtime/agent/orchestrator/session/manager/ask-turn-failure.mjs +27 -11
- package/src/runtime/agent/orchestrator/session/manager/ask-turn-open.mjs +37 -34
- package/src/runtime/agent/orchestrator/session/manager/ask-turn-prepare.mjs +15 -0
- package/src/runtime/agent/orchestrator/session/manager/ask-turn-settle.mjs +25 -15
- package/src/runtime/agent/orchestrator/session/manager/ask-turn-state.mjs +79 -24
- package/src/runtime/agent/orchestrator/session/manager/ask-turn-steering-drain.mjs +3 -0
- package/src/runtime/agent/orchestrator/session/manager/compaction-runner.mjs +12 -1
- package/src/runtime/agent/orchestrator/session/manager/context-meta.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/manager/idle-cleanup.mjs +6 -1
- package/src/runtime/agent/orchestrator/session/manager/pending-messages.mjs +9 -1
- package/src/runtime/agent/orchestrator/session/manager/pending-spool-path.mjs +2 -2
- package/src/runtime/agent/orchestrator/session/manager/pending-spool-shard.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/manager/prompt-settings.mjs +598 -0
- package/src/runtime/agent/orchestrator/session/manager/prompt-utils.mjs +19 -0
- package/src/runtime/agent/orchestrator/session/manager/rules-cache.mjs +19 -10
- package/src/runtime/agent/orchestrator/session/manager/runtime-liveness.mjs +8 -1
- package/src/runtime/agent/orchestrator/session/manager/session-close.mjs +5 -0
- package/src/runtime/agent/orchestrator/session/manager/session-fallback-title.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/manager/session-lifecycle.mjs +31 -0
- package/src/runtime/agent/orchestrator/session/manager/session-lock.mjs +31 -0
- package/src/runtime/agent/orchestrator/session/manager/session-prompt-composition.mjs +42 -6
- package/src/runtime/agent/orchestrator/session/manager/session-record.mjs +2 -0
- package/src/runtime/agent/orchestrator/session/manager/tool-resolution.mjs +11 -1
- package/src/runtime/agent/orchestrator/session/manager/turn-checkpoint-context.mjs +8 -9
- package/src/runtime/agent/orchestrator/session/manager/turn-checkpoint-journal.mjs +339 -88
- package/src/runtime/agent/orchestrator/session/manager/turn-checkpoint-recovery.mjs +135 -11
- package/src/runtime/agent/orchestrator/session/manager/turn-checkpoint.mjs +377 -104
- package/src/runtime/agent/orchestrator/session/manager/turn-durability.mjs +144 -0
- package/src/runtime/agent/orchestrator/session/manager/turn-interruption.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/manager/usage-metrics.mjs +4 -0
- package/src/runtime/agent/orchestrator/session/manager.mjs +6 -0
- package/src/runtime/agent/orchestrator/session/mixy-name.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/pre-send-compact.mjs +8 -1
- package/src/runtime/agent/orchestrator/session/save-session-worker.mjs +5 -1
- package/src/runtime/agent/orchestrator/session/store/canonical-reader.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/store/liveness-veto.mjs +2 -2
- package/src/runtime/agent/orchestrator/session/store/save-worker.mjs +23 -2
- package/src/runtime/agent/orchestrator/session/store/sweep/sub-agent-retention.mjs +3 -3
- package/src/runtime/agent/orchestrator/session/store/transcript-durability.mjs +88 -0
- package/src/runtime/agent/orchestrator/session/store-agent-worker-rows.mjs +5 -0
- package/src/runtime/agent/orchestrator/session/store-summary-log.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/store-transcript-projection.mjs +14 -5
- package/src/runtime/agent/orchestrator/session/store-transcript-worker.mjs +2 -2
- package/src/runtime/agent/orchestrator/session/store.mjs +17 -6
- package/src/runtime/agent/orchestrator/session/synthetic-user-envelope.mjs +7 -1
- package/src/runtime/agent/orchestrator/session/tail-reminder-rules.mjs +9 -1
- package/src/runtime/agent/orchestrator/session/transcript-restore/agent-envelope.mjs +1 -1
- package/src/runtime/agent/orchestrator/session/transcript-restore/restore.mjs +3 -1
- package/src/runtime/agent/orchestrator/session/transcript-restore/user-text.mjs +2 -2
- package/src/runtime/agent/orchestrator/stall-policy.mjs +3 -5
- package/src/runtime/agent/orchestrator/tools/builtin/bash-tool/backgrounded-result.mjs +4 -1
- package/src/runtime/agent/orchestrator/tools/builtin/bash-tool/misuse-guard.mjs +21 -3
- package/src/runtime/agent/orchestrator/tools/builtin/bash-tool/result-format.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/builtin/bash-tool/worktree-add-guard.mjs +77 -0
- package/src/runtime/agent/orchestrator/tools/builtin/bash-tool.mjs +0 -1
- package/src/runtime/agent/orchestrator/tools/builtin/git-command-tool.mjs +7 -3
- package/src/runtime/agent/orchestrator/tools/builtin/git-worktree-tool.mjs +27 -9
- package/src/runtime/agent/orchestrator/tools/builtin/lib/search-input-helpers.mjs +2 -2
- package/src/runtime/agent/orchestrator/tools/builtin/lib/shell-output-silence.mjs +64 -0
- package/src/runtime/agent/orchestrator/tools/builtin/lib/shell-task-output.mjs +20 -6
- package/src/runtime/agent/orchestrator/tools/builtin/read-range-index.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/builtin/read-single-fast-paths.mjs +0 -1
- package/src/runtime/agent/orchestrator/tools/builtin/search-tool.mjs +0 -10
- package/src/runtime/agent/orchestrator/tools/builtin/shell-jobs.mjs +1 -2
- package/src/runtime/agent/orchestrator/tools/builtin/task-tool.mjs +12 -1
- package/src/runtime/agent/orchestrator/tools/builtin.mjs +1 -24
- package/src/runtime/agent/orchestrator/tools/code-graph/graph-binary/child-kill.mjs +4 -3
- package/src/runtime/agent/orchestrator/tools/code-graph/graph-binary.mjs +1 -2
- package/src/runtime/agent/orchestrator/tools/code-graph/modes/calls.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/code-graph/modes/symbols.mjs +2 -2
- package/src/runtime/agent/orchestrator/tools/code-graph/search.mjs +4 -5
- package/src/runtime/agent/orchestrator/tools/code-graph/symbol-index.mjs +3 -4
- package/src/runtime/agent/orchestrator/tools/code-graph.mjs +4 -22
- package/src/runtime/agent/orchestrator/tools/lib/shell-descendants.mjs +2 -2
- package/src/runtime/agent/orchestrator/tools/lib/shell-run-state.mjs +1 -1
- package/src/runtime/agent/orchestrator/tools/shell-command.mjs +0 -4
- package/src/runtime/agent/orchestrator/tools/shell-policy.mjs +0 -1
- package/src/runtime/attachments/attachment-reference.mjs +1 -1
- package/src/runtime/attachments/pdf-extract.mjs +1 -1
- package/src/runtime/attachments/store.d.mts +1 -0
- package/src/runtime/attachments/store.mjs +2 -2
- package/src/runtime/channels/lib/config-reload-watch.mjs +42 -0
- package/src/runtime/channels/lib/owned-runtime/config-reload.mjs +29 -9
- package/src/runtime/channels/lib/routines-db.mjs +35 -0
- package/src/runtime/channels/lib/scheduler.mjs +33 -0
- package/src/runtime/channels/lib/schedules-db.mjs +15 -4
- package/src/runtime/channels/lib/webhook/session-dispatch.mjs +4 -1
- package/src/runtime/channels/lib/webhooks-db.mjs +13 -3
- package/src/runtime/channels/lib/whisper-server.mjs +12 -12
- package/src/runtime/channels/lib/worker-main.mjs +9 -31
- package/src/runtime/computer-bridge/action-schema.mjs +2 -2
- package/src/runtime/computer-bridge/core-actions.mjs +16 -2
- package/src/runtime/computer-bridge/linux-readiness.mjs +10 -14
- package/src/runtime/computer-bridge/result-canonical.mjs +6 -0
- package/src/runtime/connectors/connector-accounts-mcp.mjs +169 -33
- package/src/runtime/connectors/gmail-app-password.mjs +2 -2
- package/src/runtime/connectors/google-mcp.mjs +1 -1
- package/src/runtime/effort-judge/judge-client.mjs +2 -2
- package/src/runtime/effort-judge/judge-input.mjs +4 -4
- package/src/runtime/explore/explorer.mjs +0 -5
- package/src/runtime/explore/tool.mjs +3 -3
- package/src/runtime/local-provider/hardware.mjs +1 -1
- package/src/runtime/media/adapters/codex-image.mjs +3 -3
- package/src/runtime/media/adapters/gemini-video.mjs +1 -1
- package/src/runtime/media/media-usage.mjs +1 -1
- package/src/runtime/media/store.mjs +1 -1
- package/src/runtime/memory/index.mjs +11 -1
- package/src/runtime/memory/lib/embedding-reindex.mjs +27 -0
- package/src/runtime/memory/lib/memory-embed.mjs +83 -14
- package/src/runtime/memory/lib/memory-process-lock.mjs +159 -36
- package/src/runtime/memory/lib/memory-text-utils.mjs +6 -1
- package/src/runtime/memory/lib/memory.mjs +17 -0
- package/src/runtime/memory/lib/pg/process.mjs +1 -1
- package/src/runtime/memory/lib/pg/supervisor.mjs +16 -96
- package/src/runtime/memory/lib/recall-hybrid/hybrid-sql.mjs +12 -3
- package/src/runtime/memory/tool-defs.mjs +1 -1
- package/src/runtime/office/authoring/docx-html-runner.mjs +1 -1
- package/src/runtime/office/authoring/pptx-author-action.mjs +1 -1
- package/src/runtime/office/authoring/xlsx-html-build.mjs +1 -1
- package/src/runtime/office/authoring/xlsx-html-runner.mjs +1 -1
- package/src/runtime/office/capabilities.mjs +1 -1
- package/src/runtime/office/core/office-core.mjs +1 -1
- package/src/runtime/office/design/content-model.mjs +3 -3
- package/src/runtime/office/design/docx/design-docx/section.mjs +6 -6
- package/src/runtime/office/design/xlsx/design-xlsx-components.mjs +1 -1
- package/src/runtime/office/design/xlsx/design-xlsx.mjs +1 -1
- package/src/runtime/office/pdf/ocr-engine.mjs +1 -1
- package/src/runtime/office/pdf/pdf-writer.mjs +4 -4
- package/src/runtime/office/portable/portable-docx-operations.mjs +2 -2
- package/src/runtime/office/portable/portable-soffice.mjs +8 -6
- package/src/runtime/office/portable/xlsx-contract.mjs +1 -1
- package/src/runtime/shared/atomic-file.d.mts +8 -0
- package/src/runtime/shared/background-tasks.mjs +22 -4
- package/src/runtime/shared/background-wait.mjs +66 -0
- package/src/runtime/shared/child-guardian.mjs +17 -7
- package/src/runtime/shared/config.mjs +313 -16
- package/src/runtime/shared/connector-catalog.d.mts +4 -5
- package/src/runtime/shared/connector-catalog.mjs +11 -1
- package/src/runtime/shared/file-lock.mjs +8 -3
- package/src/runtime/shared/git-runner.mjs +7 -2
- package/src/runtime/shared/idle-gc.mjs +30 -7
- package/src/runtime/shared/llm/http-agent.mjs +8 -5
- package/src/runtime/shared/llm/system-proxy.mjs +2 -1
- package/src/runtime/shared/llm/usage-accounting.mjs +110 -19
- package/src/runtime/shared/llm/usage-context.mjs +1 -1
- package/src/runtime/shared/llm/usage-ledger-quota.mjs +33 -12
- package/src/runtime/shared/llm/usage-ledger-requests.mjs +183 -0
- package/src/runtime/shared/llm/usage-ledger-rollup.mjs +90 -10
- package/src/runtime/shared/llm/usage-ledger-worker.mjs +2 -0
- package/src/runtime/shared/llm/usage-ledger.mjs +60 -1
- package/src/runtime/shared/llm/usage-request-status.mjs +48 -0
- package/src/runtime/shared/llm/usage-rollup.mjs +48 -0
- package/src/runtime/shared/maintenance-schedule.mjs +109 -0
- package/src/runtime/shared/process-runner.mjs +8 -4
- package/src/runtime/shared/routine-trigger.d.mts +13 -0
- package/src/runtime/shared/routine-trigger.mjs +34 -0
- package/src/runtime/shared/run-child.d.mts +2 -1
- package/src/runtime/shared/run-child.mjs +70 -18
- package/src/runtime/shared/session-scratch.mjs +14 -2
- package/src/runtime/shared/shipped-definitions.mjs +7 -1
- package/src/runtime/shared/tool-card-model.golden.json +3 -12
- package/src/runtime/shared/tool-execution-contract.mjs +2 -0
- package/src/runtime/shared/tool-result-summary.mjs +1 -1
- package/src/runtime/shared/tool-work-units.mjs +31 -6
- package/src/runtime/shared/turn-snapshot.mjs +26 -4
- package/src/runtime/shared/turn-worktree-snapshot.mjs +6 -11
- package/src/runtime/shared/worker-requests.mjs +17 -3
- package/src/runtime/shared/worktrees/branch-management.mjs +1 -5
- package/src/runtime/shared/worktrees/contract.mjs +16 -6
- package/src/runtime/shared/worktrees/dependencies.mjs +127 -89
- package/src/runtime/shared/worktrees/disk.mjs +79 -2
- package/src/runtime/shared/worktrees/git.mjs +44 -11
- package/src/runtime/shared/worktrees/include.mjs +6 -4
- package/src/runtime/shared/worktrees/maintenance.mjs +422 -30
- package/src/runtime/shared/worktrees/manager.mjs +772 -75
- package/src/runtime/shared/worktrees/settings.mjs +33 -7
- package/src/runtime/shared/worktrees/test-support.mjs +5 -1
- package/src/runtime/shared/worktrees/worker-snapshots.mjs +82 -0
- package/src/runtime/tidy/process.mjs +2 -1
- package/src/runtime/web-search/index.mjs +3 -22
- package/src/runtime/web-search/lib/web-tools.mjs +2 -2
- package/src/runtime/web-search/tool-defs.mjs +17 -26
- package/src/session-runtime/agent-home-delivery.mjs +76 -8
- package/src/session-runtime/agent-profile-changes.mjs +55 -4
- package/src/session-runtime/agent-task-sessions.mjs +63 -22
- package/src/session-runtime/boot/apis.mjs +42 -4
- package/src/session-runtime/boot/begin.mjs +2 -0
- package/src/session-runtime/boot/config.mjs +10 -1
- package/src/session-runtime/boot/facade.mjs +1 -0
- package/src/session-runtime/boot/providers.mjs +70 -3
- package/src/session-runtime/boot/session.mjs +2 -0
- package/src/session-runtime/boot/tools.mjs +75 -25
- package/src/session-runtime/channel-config-api.mjs +1 -0
- package/src/session-runtime/config-change-effects.mjs +179 -0
- package/src/session-runtime/config-lifecycle/config-writers.mjs +1 -0
- package/src/session-runtime/config-lifecycle.mjs +160 -24
- package/src/session-runtime/conversation-import/discovery.mjs +86 -7
- package/src/session-runtime/conversation-import/service.mjs +3 -2
- package/src/session-runtime/goal-facade-api.mjs +49 -3
- package/src/session-runtime/internal-tool-executor/ask-user-tool.mjs +5 -57
- package/src/session-runtime/internal-tool-executor/bridge-tools.mjs +3 -2
- package/src/session-runtime/internal-tool-executor/feature-tools.mjs +3 -11
- package/src/session-runtime/internal-tool-executor/workspace-tools.mjs +18 -4
- package/src/session-runtime/internal-tool-executor.mjs +12 -19
- package/src/session-runtime/lifecycle/cold-heir.mjs +7 -0
- package/src/session-runtime/lifecycle/memory-ingest.mjs +3 -3
- package/src/session-runtime/lifecycle/session-switch/session-delete.mjs +53 -5
- package/src/session-runtime/lifecycle/session-switch.mjs +13 -2
- package/src/session-runtime/lifecycle/teardown/session-close.mjs +4 -4
- package/src/session-runtime/lifecycle-api.mjs +1 -0
- package/src/session-runtime/mcp-glue/server-catalog.mjs +14 -3
- package/src/session-runtime/mcp-glue/server-connection.mjs +34 -8
- package/src/session-runtime/model-route/route-persist.mjs +12 -4
- package/src/session-runtime/model-route/set-route.mjs +40 -7
- package/src/session-runtime/native-web-search/routes.mjs +3 -3
- package/src/session-runtime/provider-auth/refresh.mjs +6 -3
- package/src/session-runtime/provider-auth/setup.mjs +1 -1
- package/src/session-runtime/provider-models/row-hydration.mjs +2 -0
- package/src/session-runtime/provider-readiness.mjs +53 -4
- package/src/session-runtime/resource-api.mjs +1 -1
- package/src/session-runtime/resource-extension-sync.mjs +4 -8
- package/src/session-runtime/resource-mcp-connector-accounts.mjs +5 -1
- package/src/session-runtime/resource-mcp-secrets.mjs +3 -3
- package/src/session-runtime/resource-plugins-api.mjs +4 -0
- package/src/session-runtime/routine-executor.mjs +152 -0
- package/src/session-runtime/routine-home-turn.mjs +46 -5
- package/src/session-runtime/routine-owner.mjs +9 -3
- package/src/session-runtime/runtime-facade.mjs +5 -0
- package/src/session-runtime/runtime-feature-gates.mjs +2 -11
- package/src/session-runtime/schedule-session-run.mjs +1 -0
- package/src/session-runtime/services/agent-task-status.mjs +29 -1
- package/src/session-runtime/services/agent-tool/job-task-reconcile.mjs +6 -1
- package/src/session-runtime/services/agent-tool/job-views/session-progress.mjs +10 -0
- package/src/session-runtime/services/agent-tool/render.mjs +6 -1
- package/src/session-runtime/services/agent-tool/send-flow.mjs +110 -6
- package/src/session-runtime/services/agent-tool/spawn-flow/job-start.mjs +12 -0
- package/src/session-runtime/services/agent-tool/spawn-flow/spawn-plan.mjs +5 -0
- package/src/session-runtime/services/agent-tool/spawn-flow/spawn-run.mjs +24 -6
- package/src/session-runtime/services/agent-tool.mjs +51 -1
- package/src/session-runtime/services/channel-admin.mjs +62 -3
- package/src/session-runtime/services/hook-bus/command-handler.mjs +7 -11
- package/src/session-runtime/services/plugin-admin.mjs +50 -7
- package/src/session-runtime/services/provider-admin.mjs +5 -0
- package/src/session-runtime/services/seeds.mjs +7 -0
- package/src/session-runtime/services/usage-stats-model.mjs +32 -11
- package/src/session-runtime/session-create/materialize.mjs +4 -2
- package/src/session-runtime/session-create/session-options.mjs +2 -0
- package/src/session-runtime/settings-builtin-tools-api.mjs +1 -9
- package/src/session-runtime/setup-tool/agent-settings-actions.mjs +1 -1
- package/src/session-runtime/setup-tool/connector-widen-approval.mjs +1 -1
- package/src/session-runtime/setup-tool/executor.mjs +9 -2
- package/src/session-runtime/setup-tool/extended-actions.mjs +3 -1
- package/src/session-runtime/setup-tool/settings-contract.mjs +30 -2
- package/src/session-runtime/setup-tool/tool-defs.mjs +26 -1
- package/src/session-runtime/tool-policy/agent-profile-fold.mjs +40 -43
- package/src/session-runtime/tool-policy/mode-switch.mjs +1 -1
- package/src/session-runtime/tool-policy/policy-stage.mjs +106 -8
- package/src/session-runtime/tool-policy/workflow-overlay.mjs +2 -1
- package/src/session-runtime/tool-policy-refresh.mjs +182 -5
- package/src/session-runtime/tool-surface.mjs +38 -1
- package/src/session-runtime/turn/agent-ops.mjs +10 -2
- package/src/session-runtime/turn/session-ops.mjs +2 -0
- package/src/session-runtime/turn/turn-run/turn-prepare.mjs +5 -0
- package/src/session-runtime/turn/turn-run.mjs +1 -1
- package/src/session-runtime/usage-stats-api.mjs +117 -1
- package/src/session-runtime/webhook-session-run.mjs +2 -0
- package/src/session-runtime/workflow-agents-api/agent-connectors.mjs +37 -33
- package/src/session-runtime/workflow-agents-api/agent-editor.mjs +183 -23
- package/src/session-runtime/workflow-agents-api/agent-route.mjs +3 -10
- package/src/session-runtime/workflow-agents-api/instruction-files.mjs +165 -0
- package/src/session-runtime/workflow-agents-api/style-and-mode.mjs +5 -4
- package/src/session-runtime/workflow-agents-api/workflow-packs.mjs +2 -3
- package/src/session-runtime/workflow-agents-api.mjs +2 -0
- package/src/session-runtime/workspace/project-branches.mjs +1 -1
- package/src/session-runtime/workspace/session-view.mjs +1 -1
- package/src/session-runtime/workspace/transitions.mjs +20 -4
- package/src/session-runtime/workspace/worktree-maintenance.mjs +126 -6
- package/src/session-runtime/workspace/worktree-setup.mjs +13 -1
- package/src/session-runtime/workspace/worktree-tool.mjs +16 -0
- package/src/standalone/daemon-agent-control.mjs +25 -8
- package/src/standalone/daemon-desktop-runtime.mjs +6 -2
- package/src/standalone/daemon-lag-profiler.mjs +7 -7
- package/src/standalone/daemon.mjs +54 -2
- package/src/standalone/local-session-runtime.mjs +16 -0
- package/src/standalone/session-client/daemon-unavailable.mjs +1 -1
- package/src/standalone/session-protocol.mjs +12 -0
- package/src/standalone/session-service/agent-route-follow.mjs +23 -20
- package/src/standalone/session-service/agent-tree/agent-turns.mjs +18 -6
- package/src/standalone/session-service/quota-resume.mjs +9 -0
- package/src/standalone/session-service/retention/busy.mjs +3 -2
- package/src/standalone/session-service/session-calls/session-action.mjs +51 -1
- package/src/standalone/session-service/session-calls/session-turns.mjs +37 -18
- package/src/standalone/session-service/session-calls/turn-gate.mjs +34 -0
- package/src/standalone/session-service/session-calls.mjs +2 -1
- package/src/tui/App.jsx +8 -0
- package/src/tui/app/clipboard.mjs +1 -1
- package/src/tui/app/create-app-pickers.mjs +2 -0
- package/src/tui/app/doctor.mjs +2 -2
- package/src/tui/app/model-picker/model-footer.mjs +1 -1
- package/src/tui/app/model-picker/provider-models-list.mjs +7 -3
- package/src/tui/app/model-picker/route-selection/fast-parameters.mjs +23 -3
- package/src/tui/app/model-picker/route-selection.mjs +1 -0
- package/src/tui/app/panel-signature.mjs +1 -1
- package/src/tui/app/settings-picker.mjs +53 -8
- package/src/tui/app/shell-layout/row-budgets.mjs +2 -2
- package/src/tui/app/slash-commands.mjs +1 -1
- package/src/tui/app/slash-dispatch/route-commands.mjs +1 -1
- package/src/tui/app/slash-dispatch/session-commands.mjs +1 -1
- package/src/tui/app/use-prompt-queue-history.mjs +2 -2
- package/src/tui/app/use-transcript-activity.mjs +1 -1
- package/src/tui/app/use-transcript-window/geometry.mjs +1 -1
- package/src/tui/components/prompt-input/escape-policy.d.mts +0 -1
- package/src/tui/components/prompt-input/escape-policy.mjs +1 -1
- package/src/tui/components/question-panel-model.mjs +4 -4
- package/src/tui/components/tool-execution/standard-card.jsx +3 -4
- package/src/tui/components/user-message-skills.mjs +1 -1
- package/src/tui/dist/index.mjs +350 -37
- package/src/tui/markdown/render-ansi.mjs +1 -1
- package/src/tui/session/agent-job-feed/notification-router.mjs +10 -0
- package/src/tui/session/agent-job-feed.mjs +2 -0
- package/src/tui/session/context-state.mjs +3 -0
- package/src/tui/session/quota-resume.mjs +1 -1
- package/src/tui/session/session-api/integrations.mjs +3 -0
- package/src/tui/session/session-api/lifecycle/dispose.mjs +1 -0
- package/src/tui/session/session-api/lifecycle/session-reset.mjs +7 -0
- package/src/tui/session/session-api/routes-agent-definitions.mjs +5 -0
- package/src/tui/session/session-api/worktree.mjs +13 -1
- package/src/tui/session/session-flow/drain.mjs +11 -14
- package/src/tui/session/tool-approval-settle.mjs +24 -4
- package/src/tui/session/tool-approval.mjs +35 -10
- package/src/tui/session/tool-card-results/grouped-result.mjs +2 -2
- package/src/tui/session/turn-quiet.mjs +1 -1
- package/src/tui/session/turn.mjs +3 -0
- package/src/tui/session/worktree-setup-notice.mjs +1 -1
- package/src/tui/spinner-meta.mjs +3 -3
- package/src/tui/spinner-verbs.mjs +2 -2
- package/src/defaults/skills/goal-management/SKILL.md +0 -169
- package/src/runtime/agent/orchestrator/runtime-core/goal-tasks.mjs +0 -156
- package/src/session-runtime/goal-tasks.mjs +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
1
|
+
// Bring a session to the settings as they stand at each turn start
|
|
2
|
+
// (reconcileTurnSettings): an empty session's tool surface and BP1/BP3 are
|
|
3
|
+
// rebuilt; a conversation keeps its prefix and takes moved tool gates live.
|
|
4
|
+
// Setters only save config. The exceptions are a workflow or orchestration mode switch
|
|
5
5
|
// made in the session itself (switchSessionWorkflow,
|
|
6
6
|
// switchSessionOrchestrationMode), which that conversation takes as an overlay.
|
|
7
7
|
import { sessionHasConversationMessages } from '../runtime/agent/orchestrator/runtime-core/session-text.mjs';
|
|
@@ -9,6 +9,17 @@ import { createAgentProfileFold } from './tool-policy/agent-profile-fold.mjs';
|
|
|
9
9
|
import { createPolicyStage } from './tool-policy/policy-stage.mjs';
|
|
10
10
|
import { createSessionSwitches } from './tool-policy/session-switches.mjs';
|
|
11
11
|
import { rewriteBp3Core } from './tool-policy/surface-helpers.mjs';
|
|
12
|
+
import {
|
|
13
|
+
stageConnectorAvailability,
|
|
14
|
+
stageToolAvailability,
|
|
15
|
+
} from '../runtime/agent/orchestrator/runtime-core/tool-availability.mjs';
|
|
16
|
+
import { resetBp2StableContext } from '../runtime/agent/orchestrator/context/collect.mjs';
|
|
17
|
+
import {
|
|
18
|
+
promptSettingsRecord,
|
|
19
|
+
stagePromptSettingsNotice,
|
|
20
|
+
} from '../runtime/agent/orchestrator/session/manager/prompt-settings.mjs';
|
|
21
|
+
import { isAgentOwner } from '../runtime/agent/orchestrator/agent-owner.mjs';
|
|
22
|
+
import { configForSession, currentMode } from './tool-policy/surface-helpers.mjs';
|
|
12
23
|
|
|
13
24
|
export function createToolPolicyRefresh({
|
|
14
25
|
getSession,
|
|
@@ -24,11 +35,21 @@ export function createToolPolicyRefresh({
|
|
|
24
35
|
activeWorkflowContext,
|
|
25
36
|
invalidatePreSessionToolSurface,
|
|
26
37
|
persistSession,
|
|
38
|
+
toolDefinitionsFor = () => [],
|
|
39
|
+
getSurfaceGeneration,
|
|
27
40
|
}) {
|
|
28
|
-
const {
|
|
41
|
+
const {
|
|
42
|
+
liveDeniedTools,
|
|
43
|
+
stagePolicy,
|
|
44
|
+
applyPolicy,
|
|
45
|
+
promptSettingsSections,
|
|
46
|
+
presentPromptSettings,
|
|
47
|
+
refreshEnvironmentFacts,
|
|
48
|
+
} = createPolicyStage({
|
|
29
49
|
getRoute,
|
|
30
50
|
getMode,
|
|
31
51
|
getDataDir,
|
|
52
|
+
getConfig,
|
|
32
53
|
modelStandaloneTools,
|
|
33
54
|
featureDisallowedTools,
|
|
34
55
|
loadCoreMemoryContext,
|
|
@@ -55,6 +76,153 @@ export function createToolPolicyRefresh({
|
|
|
55
76
|
);
|
|
56
77
|
}
|
|
57
78
|
|
|
79
|
+
// What the gates a surface is built from read: the config object (replaced,
|
|
80
|
+
// never mutated, on every adopt and every reload of a change made
|
|
81
|
+
// elsewhere), the surface generation (skills/plugins invalidate it) and the
|
|
82
|
+
// live gate list (which carries bridge presence).
|
|
83
|
+
const configGenerations = new WeakMap();
|
|
84
|
+
let configCount = 0;
|
|
85
|
+
function availabilityKey() {
|
|
86
|
+
const config = getConfig?.() || {};
|
|
87
|
+
let generation = configGenerations.get(config);
|
|
88
|
+
if (generation === undefined) {
|
|
89
|
+
generation = ++configCount;
|
|
90
|
+
configGenerations.set(config, generation);
|
|
91
|
+
}
|
|
92
|
+
return `${generation}|${getSurfaceGeneration?.() || 0}|${featureDisallowedTools().join(',')}`;
|
|
93
|
+
}
|
|
94
|
+
// Session → the key it was last brought to (process-local, so a session
|
|
95
|
+
// first seen here, e.g. resumed, is checked once).
|
|
96
|
+
const appliedKeys = new WeakMap();
|
|
97
|
+
|
|
98
|
+
const conversationEmpty = (session) =>
|
|
99
|
+
!sessionHasConversationMessages(session) && !sessionHasConversationMessages({ messages: session.liveTurnMessages });
|
|
100
|
+
|
|
101
|
+
// The revision of the prompt settings `session` would be built from now.
|
|
102
|
+
function settingsRevision(session, coreMemory) {
|
|
103
|
+
const identity = session.promptIdentity;
|
|
104
|
+
if (!identity) return undefined;
|
|
105
|
+
const config = configForSession(getConfig(), session.workflow?.id, currentMode(session));
|
|
106
|
+
return promptSettingsRecord(promptSettingsSections(session, identity, config, coreMemory)).revision;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** A session just built from the current settings (`coreMemory`: the
|
|
110
|
+
* snapshot its prompt was composed with). */
|
|
111
|
+
function noteToolAvailability(session, coreMemory = '') {
|
|
112
|
+
if (session) {
|
|
113
|
+
appliedKeys.set(session, {
|
|
114
|
+
gates: availabilityKey(),
|
|
115
|
+
settings: settingsRevision(session, String(coreMemory || '')),
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** Whether a settings change reaches the current session's whole prompt
|
|
121
|
+
* (no session yet, or one without a conversation, rebuilt at its turn). */
|
|
122
|
+
function settingsReachCurrentSession() {
|
|
123
|
+
const session = getSession?.();
|
|
124
|
+
return !session?.id || (Boolean(session.promptIdentity) && conversationEmpty(session));
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
async function readCoreMemory() {
|
|
128
|
+
try {
|
|
129
|
+
return String((await loadCoreMemoryContext?.()) || '');
|
|
130
|
+
} catch {
|
|
131
|
+
return '';
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
async function reconcileSession(session) {
|
|
136
|
+
// Connector switches are read from their (stat-cached) files every turn.
|
|
137
|
+
const connectors = stageConnectorAvailability(session);
|
|
138
|
+
const coreMemory = await readCoreMemory();
|
|
139
|
+
const gates = availabilityKey();
|
|
140
|
+
const identity = session.promptIdentity;
|
|
141
|
+
// The prompt settings as they stand, file-based ones included (core
|
|
142
|
+
// memory, instruction files, output-style files, the workflow pack, the
|
|
143
|
+
// skill listing): their revision is part of the key.
|
|
144
|
+
const sections = identity
|
|
145
|
+
? promptSettingsSections(
|
|
146
|
+
session,
|
|
147
|
+
identity,
|
|
148
|
+
configForSession(getConfig(), session.workflow?.id, currentMode(session)),
|
|
149
|
+
coreMemory
|
|
150
|
+
)
|
|
151
|
+
: null;
|
|
152
|
+
const settings = sections ? promptSettingsRecord(sections).revision : undefined;
|
|
153
|
+
const applied = appliedKeys.get(session);
|
|
154
|
+
if (applied?.gates === gates && applied.settings === settings && !session.promptSettingsRecheck) {
|
|
155
|
+
return connectors ? { rebuilt: false, ...connectors } : null;
|
|
156
|
+
}
|
|
157
|
+
let rebuilt = false;
|
|
158
|
+
let settingsChanged = [];
|
|
159
|
+
if (identity && conversationEmpty(session)) {
|
|
160
|
+
// Nothing was sent: the whole prompt is rebuilt in place.
|
|
161
|
+
const staged = await stagePolicy(session, identity, getConfig(), { coreMemoryContext: coreMemory });
|
|
162
|
+
if (getSession?.() === session && conversationEmpty(session)) {
|
|
163
|
+
if (typeof staged.stableContext === 'string') resetBp2StableContext(session, staged.stableContext);
|
|
164
|
+
applyPolicy(session, staged);
|
|
165
|
+
rewriteBp3Core(session, staged.core);
|
|
166
|
+
presentPromptSettings(session, staged);
|
|
167
|
+
refreshEnvironmentFacts(session);
|
|
168
|
+
// The first-turn MCP fold may rebuild it in place too (an empty
|
|
169
|
+
// session reopened from disk was never marked).
|
|
170
|
+
session.deferredInitialRefreshPending = true;
|
|
171
|
+
rebuilt = true;
|
|
172
|
+
}
|
|
173
|
+
} else if (identity) {
|
|
174
|
+
// A conversation keeps its prefix: told once, folded at the next cold point.
|
|
175
|
+
settingsChanged = stagePromptSettingsNotice(session, sections);
|
|
176
|
+
// A delegated worker is never folded: after a compaction it is told
|
|
177
|
+
// again instead (rearmPromptSettingsNotice).
|
|
178
|
+
if (settingsChanged.length && !isAgentOwner(session)) session.promptFoldPending = true;
|
|
179
|
+
}
|
|
180
|
+
const staged = stageToolAvailability(session, featureDisallowedTools(), toolDefinitionsFor);
|
|
181
|
+
appliedKeys.set(session, { gates, settings: rebuilt ? session.promptSettings?.revision : settings });
|
|
182
|
+
const tools = staged || connectors;
|
|
183
|
+
const merged =
|
|
184
|
+
staged && connectors
|
|
185
|
+
? { added: [...staged.added, ...connectors.added], removed: [...staged.removed, ...connectors.removed] }
|
|
186
|
+
: tools;
|
|
187
|
+
return rebuilt || tools || settingsChanged.length
|
|
188
|
+
? { rebuilt, ...(merged || {}), ...(settingsChanged.length ? { settingsChanged } : {}) }
|
|
189
|
+
: null;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// One reconcile per session at a time: a turn start and a surface read of
|
|
193
|
+
// the same empty session share it.
|
|
194
|
+
const inflight = new WeakMap();
|
|
195
|
+
|
|
196
|
+
/** Turn start, any session kind: an empty session is rebuilt from current
|
|
197
|
+
* settings; a conversation keeps its prefix, takes moved tool gates live
|
|
198
|
+
* (stageToolAvailability) and prompt settings as a one-time notice. */
|
|
199
|
+
function reconcileTurnSettings() {
|
|
200
|
+
const session = getSession?.();
|
|
201
|
+
if (!session?.id) return Promise.resolve(null);
|
|
202
|
+
let running = inflight.get(session);
|
|
203
|
+
if (!running) {
|
|
204
|
+
running = reconcileSession(session).finally(() => inflight.delete(session));
|
|
205
|
+
inflight.set(session, running);
|
|
206
|
+
}
|
|
207
|
+
return running;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/** A read of an empty session's surface or status: the same reconcile, so
|
|
211
|
+
* what is shown is what its first turn will send. A conversation (or a
|
|
212
|
+
* running turn) is left to its turn start. */
|
|
213
|
+
function reconcileEmptySession() {
|
|
214
|
+
const session = getSession?.();
|
|
215
|
+
if (!session?.id || turnInFlight(session) || !conversationEmpty(session)) return Promise.resolve(null);
|
|
216
|
+
return reconcileTurnSettings();
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/** Sync: whether an empty session's surface lags the settings gates. */
|
|
220
|
+
function emptySessionStale() {
|
|
221
|
+
const session = getSession?.();
|
|
222
|
+
if (!session?.id || turnInFlight(session) || !conversationEmpty(session)) return false;
|
|
223
|
+
return appliedKeys.get(session)?.gates !== availabilityKey();
|
|
224
|
+
}
|
|
225
|
+
|
|
58
226
|
async function refreshEmptySessionToolPolicy() {
|
|
59
227
|
invalidatePreSessionToolSurface?.();
|
|
60
228
|
const session = getSession?.();
|
|
@@ -67,8 +235,11 @@ export function createToolPolicyRefresh({
|
|
|
67
235
|
const staged = await stagePolicy(session, identity, getConfig());
|
|
68
236
|
// Apply: re-check admission after the await, then mutate synchronously.
|
|
69
237
|
if (!admitsRefresh(session)) return { appliedToCurrentSession: false };
|
|
238
|
+
if (typeof staged.stableContext === 'string') resetBp2StableContext(session, staged.stableContext);
|
|
70
239
|
applyPolicy(session, staged);
|
|
71
240
|
rewriteBp3Core(session, staged.core);
|
|
241
|
+
presentPromptSettings(session, staged);
|
|
242
|
+
refreshEnvironmentFacts(session);
|
|
72
243
|
return { appliedToCurrentSession: true };
|
|
73
244
|
}
|
|
74
245
|
|
|
@@ -91,10 +262,16 @@ export function createToolPolicyRefresh({
|
|
|
91
262
|
liveDeniedTools,
|
|
92
263
|
stagePolicy,
|
|
93
264
|
applyPolicy,
|
|
265
|
+
presentPromptSettings,
|
|
94
266
|
turnInFlight,
|
|
95
267
|
});
|
|
96
268
|
|
|
97
269
|
return {
|
|
270
|
+
reconcileTurnSettings,
|
|
271
|
+
reconcileEmptySession,
|
|
272
|
+
emptySessionStale,
|
|
273
|
+
noteToolAvailability,
|
|
274
|
+
settingsReachCurrentSession,
|
|
98
275
|
refreshEmptySessionToolPolicy,
|
|
99
276
|
switchSessionWorkflow: switches.switchSessionWorkflow,
|
|
100
277
|
switchSessionOrchestrationMode: switches.switchSessionOrchestrationMode,
|
|
@@ -6,7 +6,10 @@ import {
|
|
|
6
6
|
filterDisallowedTools,
|
|
7
7
|
selectDeferredTools,
|
|
8
8
|
} from '../runtime/agent/orchestrator/runtime-core/tool-catalog.mjs';
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
AGENT_WORKER_DENIED_TOOLS,
|
|
11
|
+
finalizeSessionToolList,
|
|
12
|
+
} from '../runtime/agent/orchestrator/session/manager/tool-resolution.mjs';
|
|
10
13
|
import { LEAD_DISALLOWED_TOOLS } from '../runtime/agent/orchestrator/runtime-core/tool-defs.mjs';
|
|
11
14
|
import { deferredSurfaceModeForLead, toolSpecForMode } from '../runtime/agent/orchestrator/runtime-core/effort.mjs';
|
|
12
15
|
import { loadSkillToolDependencies } from '../runtime/agent/orchestrator/runtime-core/skill-tool-loading.mjs';
|
|
@@ -39,6 +42,11 @@ export function createToolSurface({
|
|
|
39
42
|
getFeatureDisallowedTools = () => [],
|
|
40
43
|
}) {
|
|
41
44
|
let preSessionSurface = null;
|
|
45
|
+
// The inputs the cached preview was built from (setters no longer
|
|
46
|
+
// invalidate it; a config adopt or reload replaces the config object).
|
|
47
|
+
let preSessionInputs = '';
|
|
48
|
+
let preSessionConfig = null;
|
|
49
|
+
let surfaceGeneration = 0;
|
|
42
50
|
|
|
43
51
|
// A coding Lead keeps `agent` whichever agents exist (the agents reach it as
|
|
44
52
|
// a listing reminder); Solo still offers it (deferred) for explicit user
|
|
@@ -122,16 +130,45 @@ export function createToolSurface({
|
|
|
122
130
|
return selectDeferredTools(session, names, surfaceMode);
|
|
123
131
|
}
|
|
124
132
|
|
|
133
|
+
/** Definitions the current session's kind may hold — built-ins included —
|
|
134
|
+
* for tools a settings gate opened mid-conversation. */
|
|
135
|
+
function toolDefinitionsFor(names) {
|
|
136
|
+
const wanted = new Set((names || []).map(String));
|
|
137
|
+
const session = getSession();
|
|
138
|
+
const ownerIsAgent = isAgentOwner(session);
|
|
139
|
+
const previewTools =
|
|
140
|
+
typeof mgr.previewSessionTools === 'function'
|
|
141
|
+
? mgr.previewSessionTools(toolSpecForMode(mode), [], {
|
|
142
|
+
mcpScopeId: getMcpScopeId(),
|
|
143
|
+
modelName: getRoute().model,
|
|
144
|
+
cwd: getCurrentCwd?.() || null,
|
|
145
|
+
})
|
|
146
|
+
: [];
|
|
147
|
+
const byName = new Map();
|
|
148
|
+
for (const tool of [...modelStandaloneTools(), ...filterModelToolsForProfile(previewTools, getToolProfile())]) {
|
|
149
|
+
const name = String(tool?.name || '');
|
|
150
|
+
if (wanted.has(name) && !byName.has(name)) byName.set(name, tool);
|
|
151
|
+
}
|
|
152
|
+
return finalizeSessionToolList([...byName.values()], { ownerIsAgent });
|
|
153
|
+
}
|
|
154
|
+
|
|
125
155
|
return {
|
|
126
156
|
modelStandaloneTools,
|
|
127
157
|
activateTools,
|
|
158
|
+
toolDefinitionsFor,
|
|
159
|
+
surfaceGeneration: () => surfaceGeneration,
|
|
128
160
|
invalidatePreSessionToolSurface() {
|
|
129
161
|
preSessionSurface = null;
|
|
162
|
+
surfaceGeneration += 1;
|
|
130
163
|
},
|
|
131
164
|
/** The live session once it exists; the preview surface until then. */
|
|
132
165
|
activeToolSurface() {
|
|
133
166
|
const session = getSession();
|
|
134
167
|
if (session) return session;
|
|
168
|
+
const inputs = getFeatureDisallowedTools().join(',');
|
|
169
|
+
if (preSessionConfig !== getConfig() || preSessionInputs !== inputs) preSessionSurface = null;
|
|
170
|
+
preSessionConfig = getConfig();
|
|
171
|
+
preSessionInputs = inputs;
|
|
135
172
|
preSessionSurface ??= buildPreSessionSurface();
|
|
136
173
|
return preSessionSurface;
|
|
137
174
|
},
|
|
@@ -31,6 +31,7 @@ export function createAgentOps(deps) {
|
|
|
31
31
|
subscribeRuntimeNotification,
|
|
32
32
|
agentTool,
|
|
33
33
|
activeToolSurface,
|
|
34
|
+
reconcileEmptySession,
|
|
34
35
|
notificationListeners,
|
|
35
36
|
getReservedSessionId,
|
|
36
37
|
} = deps;
|
|
@@ -136,7 +137,14 @@ export function createAgentOps(deps) {
|
|
|
136
137
|
return () => notificationListeners.delete(listener);
|
|
137
138
|
}
|
|
138
139
|
|
|
139
|
-
|
|
140
|
+
// An empty session has nothing cached: it is brought to the settings first
|
|
141
|
+
// (the turn-start reconcile), so the list is what its first turn sends.
|
|
142
|
+
async function toolsStatus(query = '') {
|
|
143
|
+
await reconcileEmptySession?.();
|
|
144
|
+
return toolsStatusNow(query);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function toolsStatusNow(query = '') {
|
|
140
148
|
const surface = activeToolSurface();
|
|
141
149
|
let catalog = [];
|
|
142
150
|
if (Array.isArray(surface?.deferredToolCatalog)) catalog = surface.deferredToolCatalog;
|
|
@@ -161,7 +169,7 @@ export function createAgentOps(deps) {
|
|
|
161
169
|
function selectTools(names) {
|
|
162
170
|
const list = Array.isArray(names) ? names : String(names || '').split(/[,\s]+/);
|
|
163
171
|
const result = selectDeferredTools(activeToolSurface(), list, getMode());
|
|
164
|
-
return { ...result, status:
|
|
172
|
+
return { ...result, status: toolsStatusNow() };
|
|
165
173
|
}
|
|
166
174
|
|
|
167
175
|
return {
|
|
@@ -6,6 +6,7 @@ import { normalizeToolMode } from '../../runtime/agent/orchestrator/runtime-core
|
|
|
6
6
|
import { interruptTaskWaitForSession } from '../../runtime/agent/orchestrator/session/task-wait-control.mjs';
|
|
7
7
|
import { markPendingGoalReminder } from '../../runtime/agent/orchestrator/runtime-core/goal-reminder.mjs';
|
|
8
8
|
import { rearmLateDeferredTools } from '../../runtime/agent/orchestrator/runtime-core/tool-catalog.mjs';
|
|
9
|
+
import { rearmPromptSettingsNotice } from '../../runtime/agent/orchestrator/session/manager/prompt-settings.mjs';
|
|
9
10
|
|
|
10
11
|
export function createSessionOps(deps) {
|
|
11
12
|
const {
|
|
@@ -101,6 +102,7 @@ export function createSessionOps(deps) {
|
|
|
101
102
|
// The same compaction strips late MCP tool announcements from older turns.
|
|
102
103
|
try {
|
|
103
104
|
rearmLateDeferredTools(getSession());
|
|
105
|
+
rearmPromptSettingsNotice(getSession());
|
|
104
106
|
} catch {
|
|
105
107
|
/* best-effort: a tool reminder must never break manual compact */
|
|
106
108
|
}
|
|
@@ -90,6 +90,7 @@ export function createTurnPreparation({
|
|
|
90
90
|
applyPendingRoute,
|
|
91
91
|
applyPendingAgentProfile,
|
|
92
92
|
applyPendingSessionSwitches,
|
|
93
|
+
reconcileTurnSettings,
|
|
93
94
|
}) {
|
|
94
95
|
async function admitWorkspace(turn, prompt, options) {
|
|
95
96
|
// Turn admission: waits while this session's workspace transitions or
|
|
@@ -149,6 +150,10 @@ export function createTurnPreparation({
|
|
|
149
150
|
// An orchestration mode or workflow chosen while the previous turn ran
|
|
150
151
|
// applies from this one (before a cold-cache fold can take it in).
|
|
151
152
|
const sessionSwitches = applyPendingSessionSwitches?.();
|
|
153
|
+
// Settings saved since this session last ran (here or in any other
|
|
154
|
+
// runtime): an empty session is rebuilt, a conversation takes moved tool
|
|
155
|
+
// gates live — before a cold-cache fold below can take them in.
|
|
156
|
+
await reconcileTurnSettings?.();
|
|
152
157
|
// An agent profile saved while the previous turn ran applies from this one.
|
|
153
158
|
await applyPendingAgentProfile?.();
|
|
154
159
|
options.onRouteApplied?.(getSession());
|
|
@@ -85,7 +85,7 @@ export function createTurnRunner(deps) {
|
|
|
85
85
|
// The agents enabled now (coding Leads), asked for each user turn
|
|
86
86
|
// the ask prepares, for its agent list reminder
|
|
87
87
|
// (manager/agent-listing-notice.mjs).
|
|
88
|
-
{ ...callbacks, agentsNow: currentAgents }
|
|
88
|
+
{ ...callbacks, agentsNow: currentAgents, agentConfig: getConfig }
|
|
89
89
|
);
|
|
90
90
|
} finally {
|
|
91
91
|
releaseWebSearchUsage?.();
|
|
@@ -6,7 +6,9 @@ import { refreshUnpricedUsageAsync } from '../runtime/shared/llm/usage-pricing-r
|
|
|
6
6
|
import { resolvePluginData } from '../runtime/shared/plugin-paths.mjs';
|
|
7
7
|
import { sessionUsageSnapshot, usageStatsSnapshot } from './services/usage-stats-model.mjs';
|
|
8
8
|
import { resolveUsageStatsPeriod } from './services/usage-stats-period.mjs';
|
|
9
|
-
import { usageRollupDayKey } from '../runtime/shared/llm/usage-rollup.mjs';
|
|
9
|
+
import { isConversationUsageSource, usageRollupDayKey } from '../runtime/shared/llm/usage-rollup.mjs';
|
|
10
|
+
import { isLeadVisibleRow } from '../runtime/agent/orchestrator/session/store-summary-catalog.mjs';
|
|
11
|
+
import { agentIdOfHomeSession } from '../runtime/agent/orchestrator/session/agent-home.mjs';
|
|
10
12
|
import {
|
|
11
13
|
ACCOUNT_PROVIDERS,
|
|
12
14
|
accountScopedSessionId,
|
|
@@ -164,6 +166,83 @@ function usageRollupQuery(period) {
|
|
|
164
166
|
};
|
|
165
167
|
}
|
|
166
168
|
|
|
169
|
+
async function readSessionMetadata(sessionId) {
|
|
170
|
+
const { readStoredSessionTranscript } = await import(
|
|
171
|
+
'../runtime/agent/orchestrator/session/store-summary-reader.mjs'
|
|
172
|
+
);
|
|
173
|
+
return readStoredSessionTranscript(sessionId, { metadataOnly: true });
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* What the request log names a session by: its title, and for an agent's
|
|
178
|
+
* session the title of the session it ran for with its role (`agent: true`
|
|
179
|
+
* with no role when only the ledger's owner link survives). A background
|
|
180
|
+
* request on such an openable session adds its source type as
|
|
181
|
+
* `backgroundKind`. A request whose own session the user cannot open (an
|
|
182
|
+
* internal dispatch, or a session file that is gone) carries its source type
|
|
183
|
+
* as `internalKind` instead, and no title: the first prompt line of a
|
|
184
|
+
* background run says nothing about it.
|
|
185
|
+
*/
|
|
186
|
+
async function describeRequestSessions(requests, sessionMetadata) {
|
|
187
|
+
// `exec` is hidden by the catalog but counts as conversation in usage
|
|
188
|
+
// totals; every other hidden source is one the rollup calls background.
|
|
189
|
+
const internalKindOf = (sourceType) => {
|
|
190
|
+
const id = String(sourceType || '')
|
|
191
|
+
.trim()
|
|
192
|
+
.toLowerCase();
|
|
193
|
+
const hidden = id && !isLeadVisibleRow({ sourceType: id, preview: id });
|
|
194
|
+
return hidden && (id === 'exec' || !isConversationUsageSource(id)) ? id : '';
|
|
195
|
+
};
|
|
196
|
+
const metadata = new Map();
|
|
197
|
+
const read = async (id) => {
|
|
198
|
+
if (!id) return null;
|
|
199
|
+
if (!metadata.has(id))
|
|
200
|
+
metadata.set(
|
|
201
|
+
id,
|
|
202
|
+
Promise.resolve(sessionMetadata(id)).catch(() => null)
|
|
203
|
+
);
|
|
204
|
+
return metadata.get(id);
|
|
205
|
+
};
|
|
206
|
+
const labels = new Map();
|
|
207
|
+
for (const request of requests) {
|
|
208
|
+
const key = `${request.sessionId}\u0000${request.ownerSessionId}\u0000${request.sourceType}`;
|
|
209
|
+
if (labels.has(key)) continue;
|
|
210
|
+
const own = await read(request.sessionId);
|
|
211
|
+
const kind = internalKindOf(request.sourceType || own?.sourceType);
|
|
212
|
+
// A session the user can open keeps its label whatever the request's
|
|
213
|
+
// route (a cache warm-up records under the real session id); only the
|
|
214
|
+
// work's kind is added. A session file that is gone cannot be opened, nor
|
|
215
|
+
// can a session that is itself an internal run (a memory-cycle dispatch
|
|
216
|
+
// is stored as an owned agent session).
|
|
217
|
+
const openable =
|
|
218
|
+
Boolean(own) &&
|
|
219
|
+
!internalKindOf(own.sourceType) &&
|
|
220
|
+
((own.agent && (own.ownerSessionId || request.ownerSessionId)) || isLeadVisibleRow({ ...own, preview: 'x' }));
|
|
221
|
+
if (kind && !openable) {
|
|
222
|
+
labels.set(key, { title: '', role: '', agent: false, internalKind: kind });
|
|
223
|
+
continue;
|
|
224
|
+
}
|
|
225
|
+
const ownerId = own?.ownerSessionId || request.ownerSessionId;
|
|
226
|
+
let label = { title: own?.title || agentIdOfHomeSession(request.sessionId) || '', role: '', agent: false };
|
|
227
|
+
if (ownerId && ownerId !== request.sessionId && (own?.agent || !own)) {
|
|
228
|
+
const owner = await read(ownerId);
|
|
229
|
+
label = { title: owner?.title || agentIdOfHomeSession(ownerId) || '', role: own?.agent || '', agent: true };
|
|
230
|
+
}
|
|
231
|
+
labels.set(key, { ...label, backgroundKind: kind });
|
|
232
|
+
}
|
|
233
|
+
return requests.map(({ ownerSessionId, sourceType, ...request }) => {
|
|
234
|
+
const label = labels.get(`${request.sessionId}\u0000${ownerSessionId}\u0000${sourceType}`);
|
|
235
|
+
return {
|
|
236
|
+
...request,
|
|
237
|
+
sessionTitle: label.title,
|
|
238
|
+
agentRole: label.role,
|
|
239
|
+
agent: label.agent,
|
|
240
|
+
internalKind: label.internalKind || '',
|
|
241
|
+
backgroundKind: label.backgroundKind || '',
|
|
242
|
+
};
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
|
|
167
246
|
export function createUsageStatsApi({
|
|
168
247
|
ledger = getUsageLedger,
|
|
169
248
|
importHistory = importUsageHistory,
|
|
@@ -171,6 +250,8 @@ export function createUsageStatsApi({
|
|
|
171
250
|
// provider -> { [accountId]: email } for the picker's secondary text.
|
|
172
251
|
accountEmails = () => ({}),
|
|
173
252
|
getSessionId = () => null,
|
|
253
|
+
// sessionId -> stored metadata ({ title, agent, ownerSessionId }) or null.
|
|
254
|
+
sessionMetadata = readSessionMetadata,
|
|
174
255
|
} = {}) {
|
|
175
256
|
let importing = null;
|
|
176
257
|
let imported = false;
|
|
@@ -234,6 +315,41 @@ export function createUsageStatsApi({
|
|
|
234
315
|
return snapshot;
|
|
235
316
|
},
|
|
236
317
|
|
|
318
|
+
/**
|
|
319
|
+
* The request log: one page of requests in a statistics period (`view`,
|
|
320
|
+
* `anchor`, custom dates; the 24-hour view by default), newest first,
|
|
321
|
+
* optionally of one `status` and one answering `model`. `cursor` is an
|
|
322
|
+
* earlier page's `nextCursor`. `models` lists the models that answered in
|
|
323
|
+
* the period.
|
|
324
|
+
*/
|
|
325
|
+
async getUsageRequests(options = {}) {
|
|
326
|
+
const store = ledger();
|
|
327
|
+
if (!store) throw new Error('Usage ledger is unavailable');
|
|
328
|
+
await store.settleWrites();
|
|
329
|
+
// `asOf` is the first page's `generatedAt`: later pages resolve the same
|
|
330
|
+
// period bounds, so a rolling window does not slide while it is browsed.
|
|
331
|
+
const asOf = Number(options?.asOf);
|
|
332
|
+
const real = Date.now();
|
|
333
|
+
if (options?.asOf != null && !(asOf > 0 && asOf <= real)) throw new RangeError('asOf must be a past timestamp');
|
|
334
|
+
const now = asOf > 0 ? asOf : real;
|
|
335
|
+
const period = usagePeriodFor({ ...options, view: options?.view ?? 'hour' }, now);
|
|
336
|
+
const page = await store.requestsAsync({
|
|
337
|
+
fromMs: period.fromMs,
|
|
338
|
+
toMs: period.toMs,
|
|
339
|
+
status: quotaText(options?.status),
|
|
340
|
+
model: quotaText(options?.model),
|
|
341
|
+
cursor: quotaText(options?.cursor) || null,
|
|
342
|
+
limit: options?.limit,
|
|
343
|
+
});
|
|
344
|
+
return {
|
|
345
|
+
generatedAt: now,
|
|
346
|
+
period,
|
|
347
|
+
requests: await describeRequestSessions(page.requests, sessionMetadata),
|
|
348
|
+
nextCursor: page.nextCursor,
|
|
349
|
+
models: page.models,
|
|
350
|
+
};
|
|
351
|
+
},
|
|
352
|
+
|
|
237
353
|
/**
|
|
238
354
|
* This runtime's session from its first request, compactions included; null before it has one.
|
|
239
355
|
* `sessionIds` adds the same totals for each named session (the agents it spawned) under
|
|
@@ -43,6 +43,7 @@ function runWebhookTurn({
|
|
|
43
43
|
name,
|
|
44
44
|
prompt,
|
|
45
45
|
ownerAgentId = null,
|
|
46
|
+
executorAgentId = null,
|
|
46
47
|
cwd = null,
|
|
47
48
|
attachments = null,
|
|
48
49
|
event = '',
|
|
@@ -55,6 +56,7 @@ function runWebhookTurn({
|
|
|
55
56
|
kind: 'webhook',
|
|
56
57
|
name: endpoint,
|
|
57
58
|
ownerAgentId,
|
|
59
|
+
executorAgentId: executorAgentId || null,
|
|
58
60
|
prompt,
|
|
59
61
|
skillSelection: String(skillSelection ?? ''),
|
|
60
62
|
attachments,
|
|
@@ -50,8 +50,18 @@ export function createAgentConnectorsApi(deps, editor) {
|
|
|
50
50
|
const switches = (policy) => installedIds().map((id) => ({ id, enabled: connectorEnabled(policy, id) }));
|
|
51
51
|
// A legacy list or an unreadable policy becomes its deny-list equivalent
|
|
52
52
|
// over today's connectors before any edit, so an edit never widens it.
|
|
53
|
-
const
|
|
54
|
-
migrateLegacyConnectorPolicy(
|
|
53
|
+
const editablePolicyOf = (stored) =>
|
|
54
|
+
migrateLegacyConnectorPolicy(stored, installedIds()) || { off: [], tools: {} };
|
|
55
|
+
const editablePolicy = (agentId) => editablePolicyOf(editor.getAgentConnectorPolicy(agentId));
|
|
56
|
+
// An edit is derived from the policy stored when its turn in the agent's
|
|
57
|
+
// write queue comes, so two edits started together never undo each other,
|
|
58
|
+
// and the remote no-widen check judges that same policy.
|
|
59
|
+
const editPolicy = (agentId, options, derive) =>
|
|
60
|
+
editor.updateAgentConnectorPolicy(agentId, (stored) => {
|
|
61
|
+
const next = derive(editablePolicyOf(stored));
|
|
62
|
+
if (options?.noWiden) assertConnectorPolicyNotWidened(stored, next);
|
|
63
|
+
return storedConnectorPolicy(next);
|
|
64
|
+
});
|
|
55
65
|
|
|
56
66
|
function listConnectors() {
|
|
57
67
|
return (mcpStatus()?.servers || []).map((row) => ({
|
|
@@ -102,12 +112,10 @@ export function createAgentConnectorsApi(deps, editor) {
|
|
|
102
112
|
async function setAgentConnectorEnabled(agentId, connectorId, enabled, options) {
|
|
103
113
|
const id = requireId(connectorId, 'connector id');
|
|
104
114
|
if (typeof enabled !== 'boolean') throw new TypeError('enabled must be a boolean');
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
await editor.setAgentConnectorPolicy(agentId, storedConnectorPolicy({ off, tools: policy.tools }));
|
|
115
|
+
await editPolicy(agentId, options, (policy) => ({
|
|
116
|
+
off: enabled ? policy.off.filter((entry) => entry !== id) : [...policy.off, id],
|
|
117
|
+
tools: policy.tools,
|
|
118
|
+
}));
|
|
111
119
|
return getAgentConnectors(agentId);
|
|
112
120
|
}
|
|
113
121
|
|
|
@@ -119,26 +127,24 @@ export function createAgentConnectorsApi(deps, editor) {
|
|
|
119
127
|
}
|
|
120
128
|
const server = requireId(connectorId, 'connector id');
|
|
121
129
|
const tool = requireId(toolName, 'tool name');
|
|
122
|
-
const policy = editablePolicy(agentId);
|
|
123
130
|
// The accounts of one connector (`gmail`, `gmail-2`…) share the permission,
|
|
124
131
|
// stored once under the connector's id; an entry an account kept of its own
|
|
125
132
|
// for this tool goes in the same write.
|
|
126
133
|
const group = connectorGroupId(server);
|
|
127
|
-
|
|
128
|
-
Object.
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
}
|
|
141
|
-
return editor.setAgentConnectorPolicy(agentId, storedConnectorPolicy({ off: policy.off, tools }));
|
|
134
|
+
return editPolicy(agentId, options, (policy) => {
|
|
135
|
+
const tools = Object.fromEntries(
|
|
136
|
+
Object.entries(policy.tools).map(([id, entries]) => {
|
|
137
|
+
if (id === group || connectorGroupId(id) !== group) return [id, entries];
|
|
138
|
+
const { [tool]: _dropped, ...rest } = entries;
|
|
139
|
+
return [id, rest];
|
|
140
|
+
})
|
|
141
|
+
);
|
|
142
|
+
const own = { ...tools[group] };
|
|
143
|
+
if (permission == null) delete own[tool];
|
|
144
|
+
else own[tool] = permission;
|
|
145
|
+
tools[group] = own;
|
|
146
|
+
return { off: policy.off, tools };
|
|
147
|
+
});
|
|
142
148
|
}
|
|
143
149
|
|
|
144
150
|
// A card's "항상 허용" for a connector tool saves through this same writer.
|
|
@@ -177,10 +183,7 @@ export function createAgentConnectorsApi(deps, editor) {
|
|
|
177
183
|
return [...names].map((tool) => ({
|
|
178
184
|
connector,
|
|
179
185
|
tool,
|
|
180
|
-
permission: connectorToolPermission(
|
|
181
|
-
{ off: [], tools },
|
|
182
|
-
{ mcpServerName: connector, mcpToolName: tool }
|
|
183
|
-
),
|
|
186
|
+
permission: connectorToolPermission({ off: [], tools }, { mcpServerName: connector, mcpToolName: tool }),
|
|
184
187
|
explicit: connectorToolEntries(tools, group, tool).length > 0,
|
|
185
188
|
}));
|
|
186
189
|
});
|
|
@@ -189,11 +192,12 @@ export function createAgentConnectorsApi(deps, editor) {
|
|
|
189
192
|
/** Replace the agent's connector policy (null removes it). With `options.noWiden`
|
|
190
193
|
* the replacement may not give any tool more authority than the stored policy. */
|
|
191
194
|
async function setAgentConnectors(agentId, connectors, options) {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
195
|
+
return editor.updateAgentConnectorPolicy(agentId, (stored) => {
|
|
196
|
+
if (options?.noWiden) {
|
|
197
|
+
assertConnectorPolicyNotWidened(stored, connectors == null ? null : parseConnectorPolicy(connectors));
|
|
198
|
+
}
|
|
199
|
+
return connectors;
|
|
200
|
+
});
|
|
197
201
|
}
|
|
198
202
|
|
|
199
203
|
/** The registered Project at `projectPath` (its path is the policy key). */
|