@code-yeongyu/senpi 2026.9.4 → 2026.9.5-2
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/CHANGELOG.md +131 -0
- package/README.md +5 -4
- package/dist/cli/startup-ui.d.ts.map +1 -1
- package/dist/cli/startup-ui.js +2 -1
- package/dist/cli/startup-ui.js.map +1 -1
- package/dist/core/agent-session-runtime.js +2 -2
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session.d.ts +17 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +106 -3
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +31 -41
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +20 -7
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/credential-pool/state-store.d.ts +1 -0
- package/dist/core/credential-pool/state-store.d.ts.map +1 -1
- package/dist/core/credential-pool/state-store.js +22 -2
- package/dist/core/credential-pool/state-store.js.map +1 -1
- package/dist/core/extensions/builtin/bash-timeout/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/bash-timeout/index.js +1 -5
- package/dist/core/extensions/builtin/bash-timeout/index.js.map +1 -1
- package/dist/core/extensions/builtin/bash-timeout/timeout.d.ts +0 -2
- package/dist/core/extensions/builtin/bash-timeout/timeout.d.ts.map +1 -1
- package/dist/core/extensions/builtin/bash-timeout/timeout.js +3 -4
- package/dist/core/extensions/builtin/bash-timeout/timeout.js.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/prompt-bridge.d.ts.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/prompt-bridge.js +2 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/prompt-bridge.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/model-usability-budget.d.ts +5 -0
- package/dist/core/extensions/builtin/compaction/model-usability-budget.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/model-usability-budget.js +11 -4
- package/dist/core/extensions/builtin/compaction/model-usability-budget.js.map +1 -1
- package/dist/core/extensions/builtin/compaction/openai-remote-convert.d.ts.map +1 -1
- package/dist/core/extensions/builtin/compaction/openai-remote-convert.js +2 -0
- package/dist/core/extensions/builtin/compaction/openai-remote-convert.js.map +1 -1
- package/dist/core/extensions/builtin/goal/prompt.d.ts.map +1 -1
- package/dist/core/extensions/builtin/goal/prompt.js +1 -3
- package/dist/core/extensions/builtin/goal/prompt.js.map +1 -1
- package/dist/core/extensions/builtin/goal/store.d.ts.map +1 -1
- package/dist/core/extensions/builtin/goal/store.js +8 -20
- package/dist/core/extensions/builtin/goal/store.js.map +1 -1
- package/dist/core/extensions/builtin/goal/tool-registration.js +1 -1
- package/dist/core/extensions/builtin/goal/tool-registration.js.map +1 -1
- package/dist/core/extensions/builtin/hooks/trust-storage.d.ts.map +1 -1
- package/dist/core/extensions/builtin/hooks/trust-storage.js +3 -1
- package/dist/core/extensions/builtin/hooks/trust-storage.js.map +1 -1
- package/dist/core/extensions/builtin/imagegen/auth.d.ts.map +1 -1
- package/dist/core/extensions/builtin/imagegen/auth.js +10 -2
- package/dist/core/extensions/builtin/imagegen/auth.js.map +1 -1
- package/dist/core/extensions/builtin/loop/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/loop/index.js +20 -1
- package/dist/core/extensions/builtin/loop/index.js.map +1 -1
- package/dist/core/extensions/builtin/loop/store.d.ts +8 -6
- package/dist/core/extensions/builtin/loop/store.d.ts.map +1 -1
- package/dist/core/extensions/builtin/loop/store.js +54 -88
- package/dist/core/extensions/builtin/loop/store.js.map +1 -1
- package/dist/core/extensions/builtin/loop/tools.d.ts +6 -1
- package/dist/core/extensions/builtin/loop/tools.d.ts.map +1 -1
- package/dist/core/extensions/builtin/loop/tools.js +8 -1
- package/dist/core/extensions/builtin/loop/tools.js.map +1 -1
- package/dist/core/extensions/builtin/monitor-state-event.d.ts +2 -0
- package/dist/core/extensions/builtin/monitor-state-event.d.ts.map +1 -1
- package/dist/core/extensions/builtin/monitor-state-event.js.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-6-astra.d.ts +10 -6
- package/dist/core/extensions/builtin/prompt-preset/gpt-6-astra.d.ts.map +1 -1
- package/dist/core/extensions/builtin/prompt-preset/gpt-6-astra.js +27 -12
- package/dist/core/extensions/builtin/prompt-preset/gpt-6-astra.js.map +1 -1
- package/dist/core/extensions/builtin/recommended-models/index.d.ts +1 -1
- package/dist/core/extensions/builtin/recommended-models/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/recommended-models/index.js +1 -0
- package/dist/core/extensions/builtin/recommended-models/index.js.map +1 -1
- package/dist/core/extensions/builtin/service-tier.d.ts.map +1 -1
- package/dist/core/extensions/builtin/service-tier.js +12 -4
- package/dist/core/extensions/builtin/service-tier.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/durable-command.d.ts +31 -0
- package/dist/core/extensions/builtin/terminal/durable-command.d.ts.map +1 -0
- package/dist/core/extensions/builtin/terminal/durable-command.js +96 -0
- package/dist/core/extensions/builtin/terminal/durable-command.js.map +1 -0
- package/dist/core/extensions/builtin/terminal/durable-file.d.ts +42 -0
- package/dist/core/extensions/builtin/terminal/durable-file.d.ts.map +1 -0
- package/dist/core/extensions/builtin/terminal/durable-file.js +102 -0
- package/dist/core/extensions/builtin/terminal/durable-file.js.map +1 -0
- package/dist/core/extensions/builtin/terminal/extension.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/extension.js +226 -3
- package/dist/core/extensions/builtin/terminal/extension.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/manager.d.ts +10 -0
- package/dist/core/extensions/builtin/terminal/manager.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/manager.js +21 -0
- package/dist/core/extensions/builtin/terminal/manager.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/manifest-lease.d.ts +24 -0
- package/dist/core/extensions/builtin/terminal/manifest-lease.d.ts.map +1 -0
- package/dist/core/extensions/builtin/terminal/manifest-lease.js +105 -0
- package/dist/core/extensions/builtin/terminal/manifest-lease.js.map +1 -0
- package/dist/core/extensions/builtin/terminal/monitor-notify.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/monitor-notify.js +5 -1
- package/dist/core/extensions/builtin/terminal/monitor-notify.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/monitor-registry.d.ts +42 -2
- package/dist/core/extensions/builtin/terminal/monitor-registry.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/monitor-registry.js +73 -2
- package/dist/core/extensions/builtin/terminal/monitor-registry.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/monitor-status.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/monitor-status.js +21 -1
- package/dist/core/extensions/builtin/terminal/monitor-status.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/prompt.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/prompt.js +9 -5
- package/dist/core/extensions/builtin/terminal/prompt.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/restore.d.ts +56 -0
- package/dist/core/extensions/builtin/terminal/restore.d.ts.map +1 -0
- package/dist/core/extensions/builtin/terminal/restore.js +177 -0
- package/dist/core/extensions/builtin/terminal/restore.js.map +1 -0
- package/dist/core/extensions/builtin/terminal/shared.d.ts +25 -0
- package/dist/core/extensions/builtin/terminal/shared.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/shared.js +25 -0
- package/dist/core/extensions/builtin/terminal/shared.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/terminal-manifest-model.d.ts +91 -0
- package/dist/core/extensions/builtin/terminal/terminal-manifest-model.d.ts.map +1 -0
- package/dist/core/extensions/builtin/terminal/terminal-manifest-model.js +14 -0
- package/dist/core/extensions/builtin/terminal/terminal-manifest-model.js.map +1 -0
- package/dist/core/extensions/builtin/terminal/terminal-manifest.d.ts +62 -0
- package/dist/core/extensions/builtin/terminal/terminal-manifest.d.ts.map +1 -0
- package/dist/core/extensions/builtin/terminal/terminal-manifest.js +204 -0
- package/dist/core/extensions/builtin/terminal/terminal-manifest.js.map +1 -0
- package/dist/core/extensions/builtin/terminal/tools/bash-input.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/tools/bash-input.js +3 -2
- package/dist/core/extensions/builtin/terminal/tools/bash-input.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/tools/bash-output.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/tools/bash-output.js +5 -4
- package/dist/core/extensions/builtin/terminal/tools/bash-output.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/tools/bash-resize.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/tools/bash-resize.js +3 -2
- package/dist/core/extensions/builtin/terminal/tools/bash-resize.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/tools/context.d.ts +8 -0
- package/dist/core/extensions/builtin/terminal/tools/context.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/tools/context.js +10 -0
- package/dist/core/extensions/builtin/terminal/tools/context.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/tools/kill-bash.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/tools/kill-bash.js +5 -4
- package/dist/core/extensions/builtin/terminal/tools/kill-bash.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/tools/monitor.d.ts +4 -1
- package/dist/core/extensions/builtin/terminal/tools/monitor.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/tools/monitor.js +114 -22
- package/dist/core/extensions/builtin/terminal/tools/monitor.js.map +1 -1
- package/dist/core/extensions/builtin/todotools/prompt.d.ts +2 -2
- package/dist/core/extensions/builtin/todotools/prompt.d.ts.map +1 -1
- package/dist/core/extensions/builtin/todotools/prompt.js +3 -6
- package/dist/core/extensions/builtin/todotools/prompt.js.map +1 -1
- package/dist/core/extensions/builtin/tool-search/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/tool-search/index.js +1 -1
- package/dist/core/extensions/builtin/tool-search/index.js.map +1 -1
- package/dist/core/extensions/builtin/tool-search/native-search.d.ts +9 -4
- package/dist/core/extensions/builtin/tool-search/native-search.d.ts.map +1 -1
- package/dist/core/extensions/builtin/tool-search/native-search.js +11 -6
- package/dist/core/extensions/builtin/tool-search/native-search.js.map +1 -1
- package/dist/core/extensions/builtin/tool-search/native-support.d.ts +13 -0
- package/dist/core/extensions/builtin/tool-search/native-support.d.ts.map +1 -0
- package/dist/core/extensions/builtin/tool-search/native-support.js +45 -0
- package/dist/core/extensions/builtin/tool-search/native-support.js.map +1 -0
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +5 -0
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +44 -1
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +26 -3
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/footer-data-provider.d.ts.map +1 -1
- package/dist/core/footer-data-provider.js +18 -1
- package/dist/core/footer-data-provider.js.map +1 -1
- package/dist/core/http-dispatcher.d.ts.map +1 -1
- package/dist/core/http-dispatcher.js +2 -0
- package/dist/core/http-dispatcher.js.map +1 -1
- package/dist/core/lockfile-policy.d.ts +11 -0
- package/dist/core/lockfile-policy.d.ts.map +1 -1
- package/dist/core/lockfile-policy.js +19 -0
- package/dist/core/lockfile-policy.js.map +1 -1
- package/dist/core/manual-continue.d.ts +13 -0
- package/dist/core/manual-continue.d.ts.map +1 -0
- package/dist/core/manual-continue.js +19 -0
- package/dist/core/manual-continue.js.map +1 -0
- package/dist/core/messages.d.ts +7 -0
- package/dist/core/messages.d.ts.map +1 -1
- package/dist/core/messages.js +10 -2
- package/dist/core/messages.js.map +1 -1
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +3 -0
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/provider-composer.d.ts.map +1 -1
- package/dist/core/provider-composer.js +13 -2
- package/dist/core/provider-composer.js.map +1 -1
- package/dist/core/retry-fallback/chains.d.ts +1 -13
- package/dist/core/retry-fallback/chains.d.ts.map +1 -1
- package/dist/core/retry-fallback/chains.js +3 -49
- package/dist/core/retry-fallback/chains.js.map +1 -1
- package/dist/core/retry-fallback/controller.d.ts.map +1 -1
- package/dist/core/retry-fallback/controller.js +4 -9
- package/dist/core/retry-fallback/controller.js.map +1 -1
- package/dist/core/retry-fallback/expansion.js +1 -1
- package/dist/core/retry-fallback/expansion.js.map +1 -1
- package/dist/core/retry-fallback/settings.d.ts +2 -4
- package/dist/core/retry-fallback/settings.d.ts.map +1 -1
- package/dist/core/retry-fallback/settings.js +7 -36
- package/dist/core/retry-fallback/settings.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +6 -1
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager.d.ts +12 -1
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +39 -6
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/session-sidecar-store.d.ts +62 -0
- package/dist/core/session-sidecar-store.d.ts.map +1 -0
- package/dist/core/session-sidecar-store.js +149 -0
- package/dist/core/session-sidecar-store.js.map +1 -0
- package/dist/core/settings-manager.d.ts +5 -1
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +45 -15
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +19 -2
- package/dist/core/skills.js.map +1 -1
- package/dist/core/terminal-settings.d.ts +3 -0
- package/dist/core/terminal-settings.d.ts.map +1 -1
- package/dist/core/terminal-settings.js.map +1 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +1 -1
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +2 -2
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js +2 -2
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js +2 -2
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/ls.d.ts.map +1 -1
- package/dist/core/tools/ls.js +2 -2
- package/dist/core/tools/ls.js.map +1 -1
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +1 -1
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +3 -3
- package/dist/core/tools/write.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +2 -0
- package/dist/main.js.map +1 -1
- package/dist/modes/app-server/daemon/process.d.ts +33 -3
- package/dist/modes/app-server/daemon/process.d.ts.map +1 -1
- package/dist/modes/app-server/daemon/process.js +57 -6
- package/dist/modes/app-server/daemon/process.js.map +1 -1
- package/dist/modes/app-server/daemon.js +9 -1
- package/dist/modes/app-server/daemon.js.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.js +5 -11
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +2 -0
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +21 -8
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.js +2 -2
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
- package/dist/modes/interactive/components/trust-selector.js +2 -2
- package/dist/modes/interactive/components/trust-selector.js.map +1 -1
- package/dist/modes/interactive/grok/welcome-card.d.ts.map +1 -1
- package/dist/modes/interactive/grok/welcome-card.js +5 -2
- package/dist/modes/interactive/grok/welcome-card.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +3 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +86 -14
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/version-label.d.ts +7 -0
- package/dist/modes/interactive/version-label.d.ts.map +1 -0
- package/dist/modes/interactive/version-label.js +9 -0
- package/dist/modes/interactive/version-label.js.map +1 -0
- package/dist/modes/rpc/host-ensure.d.ts +2 -0
- package/dist/modes/rpc/host-ensure.d.ts.map +1 -1
- package/dist/modes/rpc/host-ensure.js +77 -18
- package/dist/modes/rpc/host-ensure.js.map +1 -1
- package/dist/utils/version-check.d.ts.map +1 -1
- package/dist/utils/version-check.js +3 -4
- package/dist/utils/version-check.js.map +1 -1
- package/docs/compaction.md +2 -0
- package/docs/environment-variables.md +5 -0
- package/docs/extensions.md +22 -2
- package/docs/keybindings.md +1 -1
- package/docs/models.md +3 -0
- package/docs/quickstart.md +1 -1
- package/docs/rpc.md +1 -1
- package/docs/settings.md +13 -5
- package/docs/terminal-setup.md +27 -0
- package/docs/terminal-tools.md +35 -4
- package/docs/usage.md +5 -3
- package/node_modules/@anthropic-ai/sdk/CHANGELOG.md +96 -0
- package/node_modules/@anthropic-ai/sdk/README.md +1 -1
- package/node_modules/@anthropic-ai/sdk/core/credentials.d.mts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/core/credentials.d.ts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/core/credentials.js +5 -7
- package/node_modules/@anthropic-ai/sdk/core/credentials.js.map +1 -1
- package/node_modules/@anthropic-ai/sdk/core/credentials.mjs +5 -7
- package/node_modules/@anthropic-ai/sdk/core/credentials.mjs.map +1 -1
- package/node_modules/@anthropic-ai/sdk/core/middleware.d.mts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/core/middleware.d.ts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/core/middleware.js +4 -4
- package/node_modules/@anthropic-ai/sdk/core/middleware.js.map +1 -1
- package/node_modules/@anthropic-ai/sdk/core/middleware.mjs +4 -4
- package/node_modules/@anthropic-ai/sdk/core/middleware.mjs.map +1 -1
- package/node_modules/@anthropic-ai/sdk/helpers/beta/standard-schema.d.mts +45 -0
- package/node_modules/@anthropic-ai/sdk/helpers/beta/standard-schema.d.mts.map +1 -0
- package/node_modules/@anthropic-ai/sdk/helpers/beta/standard-schema.d.ts +45 -0
- package/node_modules/@anthropic-ai/sdk/helpers/beta/standard-schema.d.ts.map +1 -0
- package/node_modules/@anthropic-ai/sdk/helpers/beta/standard-schema.js +58 -0
- package/node_modules/@anthropic-ai/sdk/helpers/beta/standard-schema.js.map +1 -0
- package/node_modules/@anthropic-ai/sdk/helpers/beta/standard-schema.mjs +54 -0
- package/node_modules/@anthropic-ai/sdk/helpers/beta/standard-schema.mjs.map +1 -0
- package/node_modules/@anthropic-ai/sdk/internal/detect-platform.js +1 -1
- package/node_modules/@anthropic-ai/sdk/internal/detect-platform.js.map +1 -1
- package/node_modules/@anthropic-ai/sdk/internal/detect-platform.mjs +1 -1
- package/node_modules/@anthropic-ai/sdk/internal/detect-platform.mjs.map +1 -1
- package/node_modules/@anthropic-ai/sdk/internal/errors.d.mts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/internal/errors.d.ts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/internal/errors.js +3 -1
- package/node_modules/@anthropic-ai/sdk/internal/errors.js.map +1 -1
- package/node_modules/@anthropic-ai/sdk/internal/errors.mjs +3 -1
- package/node_modules/@anthropic-ai/sdk/internal/errors.mjs.map +1 -1
- package/node_modules/@anthropic-ai/sdk/internal/file-store.d.mts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/internal/file-store.d.ts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/internal/file-store.js +23 -25
- package/node_modules/@anthropic-ai/sdk/internal/file-store.js.map +1 -1
- package/node_modules/@anthropic-ai/sdk/internal/file-store.mjs +5 -6
- package/node_modules/@anthropic-ai/sdk/internal/file-store.mjs.map +1 -1
- package/node_modules/@anthropic-ai/sdk/internal/node.browser.d.mts +9 -0
- package/node_modules/@anthropic-ai/sdk/internal/node.browser.d.mts.map +1 -0
- package/node_modules/@anthropic-ai/sdk/internal/node.browser.d.ts +9 -0
- package/node_modules/@anthropic-ai/sdk/internal/node.browser.d.ts.map +1 -0
- package/node_modules/@anthropic-ai/sdk/internal/node.browser.js +22 -0
- package/node_modules/@anthropic-ai/sdk/internal/node.browser.js.map +1 -0
- package/node_modules/@anthropic-ai/sdk/internal/node.browser.mjs +19 -0
- package/node_modules/@anthropic-ai/sdk/internal/node.browser.mjs.map +1 -0
- package/node_modules/@anthropic-ai/sdk/internal/node.d.mts +14 -0
- package/node_modules/@anthropic-ai/sdk/internal/node.d.mts.map +1 -0
- package/node_modules/@anthropic-ai/sdk/internal/node.d.ts +14 -0
- package/node_modules/@anthropic-ai/sdk/internal/node.d.ts.map +1 -0
- package/node_modules/@anthropic-ai/sdk/internal/node.js +24 -0
- package/node_modules/@anthropic-ai/sdk/internal/node.js.map +1 -0
- package/node_modules/@anthropic-ai/sdk/internal/node.mjs +14 -0
- package/node_modules/@anthropic-ai/sdk/internal/node.mjs.map +1 -0
- package/node_modules/@anthropic-ai/sdk/internal/parse.js +1 -1
- package/node_modules/@anthropic-ai/sdk/internal/parse.js.map +1 -1
- package/node_modules/@anthropic-ai/sdk/internal/parse.mjs +1 -1
- package/node_modules/@anthropic-ai/sdk/internal/parse.mjs.map +1 -1
- package/node_modules/@anthropic-ai/sdk/internal/uploads.js +10 -6
- package/node_modules/@anthropic-ai/sdk/internal/uploads.js.map +1 -1
- package/node_modules/@anthropic-ai/sdk/internal/uploads.mjs +10 -6
- package/node_modules/@anthropic-ai/sdk/internal/uploads.mjs.map +1 -1
- package/node_modules/@anthropic-ai/sdk/internal/utils/values.d.mts +6 -0
- package/node_modules/@anthropic-ai/sdk/internal/utils/values.d.mts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/internal/utils/values.d.ts +6 -0
- package/node_modules/@anthropic-ai/sdk/internal/utils/values.d.ts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/internal/utils/values.js +7 -0
- package/node_modules/@anthropic-ai/sdk/internal/utils/values.js.map +1 -1
- package/node_modules/@anthropic-ai/sdk/internal/utils/values.mjs +6 -0
- package/node_modules/@anthropic-ai/sdk/internal/utils/values.mjs.map +1 -1
- package/node_modules/@anthropic-ai/sdk/lib/BetaMessageStream.d.mts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/lib/BetaMessageStream.d.ts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/lib/BetaMessageStream.js +6 -4
- package/node_modules/@anthropic-ai/sdk/lib/BetaMessageStream.js.map +1 -1
- package/node_modules/@anthropic-ai/sdk/lib/BetaMessageStream.mjs +4 -2
- package/node_modules/@anthropic-ai/sdk/lib/BetaMessageStream.mjs.map +1 -1
- package/node_modules/@anthropic-ai/sdk/lib/MessageStream.d.mts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/lib/MessageStream.d.ts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/lib/MessageStream.js +3 -4
- package/node_modules/@anthropic-ai/sdk/lib/MessageStream.js.map +1 -1
- package/node_modules/@anthropic-ai/sdk/lib/MessageStream.mjs +1 -2
- package/node_modules/@anthropic-ai/sdk/lib/MessageStream.mjs.map +1 -1
- package/node_modules/@anthropic-ai/sdk/lib/credentials/credential-chain.js +1 -1
- package/node_modules/@anthropic-ai/sdk/lib/credentials/credential-chain.js.map +1 -1
- package/node_modules/@anthropic-ai/sdk/lib/credentials/credential-chain.mjs +1 -1
- package/node_modules/@anthropic-ai/sdk/lib/credentials/credential-chain.mjs.map +1 -1
- package/node_modules/@anthropic-ai/sdk/lib/credentials/identity-token.js +1 -1
- package/node_modules/@anthropic-ai/sdk/lib/credentials/identity-token.js.map +1 -1
- package/node_modules/@anthropic-ai/sdk/lib/credentials/identity-token.mjs +1 -1
- package/node_modules/@anthropic-ai/sdk/lib/credentials/identity-token.mjs.map +1 -1
- package/node_modules/@anthropic-ai/sdk/lib/credentials/types.d.mts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/lib/credentials/types.d.ts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/lib/credentials/types.js +2 -3
- package/node_modules/@anthropic-ai/sdk/lib/credentials/types.js.map +1 -1
- package/node_modules/@anthropic-ai/sdk/lib/credentials/types.mjs +2 -3
- package/node_modules/@anthropic-ai/sdk/lib/credentials/types.mjs.map +1 -1
- package/node_modules/@anthropic-ai/sdk/lib/credentials/user-oauth.js +1 -1
- package/node_modules/@anthropic-ai/sdk/lib/credentials/user-oauth.js.map +1 -1
- package/node_modules/@anthropic-ai/sdk/lib/credentials/user-oauth.mjs +1 -1
- package/node_modules/@anthropic-ai/sdk/lib/credentials/user-oauth.mjs.map +1 -1
- package/node_modules/@anthropic-ai/sdk/lib/middleware.d.mts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/lib/middleware.d.ts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/lib/middleware.js +30 -7
- package/node_modules/@anthropic-ai/sdk/lib/middleware.js.map +1 -1
- package/node_modules/@anthropic-ai/sdk/lib/middleware.mjs +30 -7
- package/node_modules/@anthropic-ai/sdk/lib/middleware.mjs.map +1 -1
- package/node_modules/@anthropic-ai/sdk/lib/sessions/accumulate.d.mts +3 -2
- package/node_modules/@anthropic-ai/sdk/lib/sessions/accumulate.d.mts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/lib/sessions/accumulate.d.ts +3 -2
- package/node_modules/@anthropic-ai/sdk/lib/sessions/accumulate.d.ts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/lib/sessions/accumulate.js +3 -46
- package/node_modules/@anthropic-ai/sdk/lib/sessions/accumulate.js.map +1 -1
- package/node_modules/@anthropic-ai/sdk/lib/sessions/accumulate.mjs +3 -46
- package/node_modules/@anthropic-ai/sdk/lib/sessions/accumulate.mjs.map +1 -1
- package/node_modules/@anthropic-ai/sdk/lib/standard-schema.d.mts +131 -0
- package/node_modules/@anthropic-ai/sdk/lib/standard-schema.d.mts.map +1 -0
- package/node_modules/@anthropic-ai/sdk/lib/standard-schema.d.ts +131 -0
- package/node_modules/@anthropic-ai/sdk/lib/standard-schema.d.ts.map +1 -0
- package/node_modules/@anthropic-ai/sdk/lib/standard-schema.js +45 -0
- package/node_modules/@anthropic-ai/sdk/lib/standard-schema.js.map +1 -0
- package/node_modules/@anthropic-ai/sdk/lib/standard-schema.mjs +41 -0
- package/node_modules/@anthropic-ai/sdk/lib/standard-schema.mjs.map +1 -0
- package/node_modules/@anthropic-ai/sdk/lib/tools/BetaToolRunner.d.mts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/lib/tools/BetaToolRunner.d.ts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/lib/tools/BetaToolRunner.js +35 -6
- package/node_modules/@anthropic-ai/sdk/lib/tools/BetaToolRunner.js.map +1 -1
- package/node_modules/@anthropic-ai/sdk/lib/tools/BetaToolRunner.mjs +35 -6
- package/node_modules/@anthropic-ai/sdk/lib/tools/BetaToolRunner.mjs.map +1 -1
- package/node_modules/@anthropic-ai/sdk/package.json +4 -11
- package/node_modules/@anthropic-ai/sdk/resources/beta/agents/agents.d.mts +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/agents/agents.d.mts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/agents/agents.d.ts +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/agents/agents.d.ts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/agents/agents.js.map +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/agents/agents.mjs.map +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/beta.d.mts +13 -9
- package/node_modules/@anthropic-ai/sdk/resources/beta/beta.d.mts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/beta.d.ts +13 -9
- package/node_modules/@anthropic-ai/sdk/resources/beta/beta.d.ts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/beta.js +4 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/beta.js.map +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/beta.mjs +4 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/beta.mjs.map +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/deployment-runs.d.mts +6 -6
- package/node_modules/@anthropic-ai/sdk/resources/beta/deployment-runs.d.ts +6 -6
- package/node_modules/@anthropic-ai/sdk/resources/beta/deployments.d.mts +3 -2
- package/node_modules/@anthropic-ai/sdk/resources/beta/deployments.d.mts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/deployments.d.ts +3 -2
- package/node_modules/@anthropic-ai/sdk/resources/beta/deployments.d.ts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/dreams.d.mts +28 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/dreams.d.mts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/dreams.d.ts +28 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/dreams.d.ts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/environments/environments.d.mts +8 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/environments/environments.d.mts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/environments/environments.d.ts +8 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/environments/environments.d.ts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/environments/environments.js.map +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/environments/environments.mjs.map +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/files.d.mts +25 -5
- package/node_modules/@anthropic-ai/sdk/resources/beta/files.d.mts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/files.d.ts +25 -5
- package/node_modules/@anthropic-ai/sdk/resources/beta/files.d.ts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/files.js +6 -6
- package/node_modules/@anthropic-ai/sdk/resources/beta/files.js.map +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/files.mjs +7 -7
- package/node_modules/@anthropic-ai/sdk/resources/beta/files.mjs.map +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/index.d.mts +5 -4
- package/node_modules/@anthropic-ai/sdk/resources/beta/index.d.mts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/index.d.ts +5 -4
- package/node_modules/@anthropic-ai/sdk/resources/beta/index.d.ts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/index.js +11 -9
- package/node_modules/@anthropic-ai/sdk/resources/beta/index.js.map +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/index.mjs +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/index.mjs.map +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/memory-stores/memories.d.mts +12 -9
- package/node_modules/@anthropic-ai/sdk/resources/beta/memory-stores/memories.d.mts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/memory-stores/memories.d.ts +12 -9
- package/node_modules/@anthropic-ai/sdk/resources/beta/memory-stores/memories.d.ts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/memory-stores/memory-versions.d.mts +8 -5
- package/node_modules/@anthropic-ai/sdk/resources/beta/memory-stores/memory-versions.d.mts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/memory-stores/memory-versions.d.ts +8 -5
- package/node_modules/@anthropic-ai/sdk/resources/beta/memory-stores/memory-versions.d.ts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/messages/index.d.mts +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/messages/index.d.mts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/messages/index.d.ts +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/messages/index.d.ts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/messages/index.js.map +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/messages/index.mjs.map +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/messages/messages.d.mts +198 -29
- package/node_modules/@anthropic-ai/sdk/resources/beta/messages/messages.d.mts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/messages/messages.d.ts +198 -29
- package/node_modules/@anthropic-ai/sdk/resources/beta/messages/messages.d.ts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/messages/messages.js.map +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/messages/messages.mjs.map +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/api-keys.d.mts +177 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/api-keys.d.mts.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/api-keys.d.ts +177 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/api-keys.d.ts.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/api-keys.js +56 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/api-keys.js.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/api-keys.mjs +52 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/api-keys.mjs.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/compliance-settings.d.mts +74 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/compliance-settings.d.mts.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/compliance-settings.d.ts +74 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/compliance-settings.d.ts.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/compliance-settings.js +52 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/compliance-settings.js.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/compliance-settings.mjs +48 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/compliance-settings.mjs.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/external-keys.d.mts +272 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/external-keys.d.mts.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/external-keys.d.ts +272 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/external-keys.d.ts.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/external-keys.js +119 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/external-keys.js.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/external-keys.mjs +115 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/external-keys.mjs.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/federation.d.mts +14 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/federation.d.mts.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/federation.d.ts +14 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/federation.d.ts.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/federation.js +21 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/federation.js.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/federation.mjs +16 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/federation.mjs.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/index.d.mts +4 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/index.d.mts.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/index.d.ts +4 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/index.d.ts.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/index.js +11 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/index.js.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/index.mjs +5 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/index.mjs.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/issuers.d.mts +353 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/issuers.d.mts.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/issuers.d.ts +353 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/issuers.d.ts.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/issuers.js +169 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/issuers.js.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/issuers.mjs +165 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/issuers.mjs.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/index.d.mts +3 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/index.d.mts.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/index.d.ts +3 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/index.d.ts.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/index.js +9 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/index.js.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/index.mjs +4 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/index.mjs.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/rules.d.mts +468 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/rules.d.mts.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/rules.d.ts +468 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/rules.d.ts.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/rules.js +198 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/rules.js.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/rules.mjs +193 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/rules.mjs.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/workspaces.d.mts +124 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/workspaces.d.mts.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/workspaces.d.ts +124 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/workspaces.d.ts.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/workspaces.js +114 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/workspaces.js.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/workspaces.mjs +110 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules/workspaces.mjs.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules.d.mts +2 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules.d.mts.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules.d.ts +2 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules.d.ts.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules.js +6 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules.js.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules.mjs +3 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation/rules.mjs.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation.d.mts +2 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation.d.mts.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation.d.ts +2 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation.d.ts.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation.js +6 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation.js.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation.mjs +3 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/federation.mjs.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/index.d.mts +11 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/index.d.mts.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/index.d.ts +11 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/index.d.ts.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/index.js +25 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/index.js.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/index.mjs +12 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/index.mjs.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/invites.d.mts +162 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/invites.d.mts.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/invites.d.ts +162 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/invites.d.ts.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/invites.js +76 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/invites.js.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/invites.mjs +72 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/invites.mjs.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/organization.d.mts +73 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/organization.d.mts.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/organization.d.ts +73 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/organization.d.ts.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/organization.js +62 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/organization.js.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/organization.mjs +57 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/organization.mjs.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/rate-limits.d.mts +77 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/rate-limits.d.mts.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/rate-limits.d.ts +77 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/rate-limits.d.ts.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/rate-limits.js +31 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/rate-limits.js.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/rate-limits.mjs +27 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/rate-limits.mjs.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/index.d.mts +3 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/index.d.mts.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/index.d.ts +3 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/index.d.ts.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/index.js +9 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/index.js.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/index.mjs +4 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/index.mjs.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/service-accounts.d.mts +258 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/service-accounts.d.mts.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/service-accounts.d.ts +258 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/service-accounts.d.ts.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/service-accounts.js +174 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/service-accounts.js.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/service-accounts.mjs +169 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/service-accounts.mjs.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/workspaces.d.mts +141 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/workspaces.d.mts.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/workspaces.d.ts +141 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/workspaces.d.ts.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/workspaces.js +125 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/workspaces.js.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/workspaces.mjs +121 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts/workspaces.mjs.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts.d.mts +2 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts.d.mts.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts.d.ts +2 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts.d.ts.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts.js +6 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts.js.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts.mjs +3 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/service-accounts.mjs.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/users.d.mts +124 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/users.d.mts.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/users.d.ts +124 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/users.d.ts.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/users.js +67 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/users.js.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/users.mjs +63 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/users.mjs.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/index.d.mts +5 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/index.d.mts.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/index.d.ts +5 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/index.d.ts.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/index.js +13 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/index.js.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/index.mjs +6 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/index.mjs.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/members.d.mts +135 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/members.d.mts.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/members.d.ts +135 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/members.d.ts.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/members.js +102 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/members.js.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/members.mjs +98 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/members.mjs.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/rate-limits.d.mts +83 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/rate-limits.d.mts.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/rate-limits.d.ts +83 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/rate-limits.d.ts.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/rate-limits.js +34 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/rate-limits.js.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/rate-limits.mjs +30 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/rate-limits.mjs.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/service-accounts.d.mts +210 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/service-accounts.d.mts.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/service-accounts.d.ts +210 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/service-accounts.d.ts.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/service-accounts.js +189 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/service-accounts.js.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/service-accounts.mjs +185 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/service-accounts.mjs.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/workspaces.d.mts +303 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/workspaces.d.mts.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/workspaces.d.ts +303 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/workspaces.d.ts.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/workspaces.js +112 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/workspaces.js.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/workspaces.mjs +107 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces/workspaces.mjs.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces.d.mts +2 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces.d.mts.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces.d.ts +2 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces.d.ts.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces.js +6 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces.js.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces.mjs +3 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization/workspaces.mjs.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization.d.mts +2 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization.d.mts.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization.d.ts +2 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization.d.ts.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization.js +6 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization.js.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization.mjs +3 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/organization.mjs.map +1 -0
- package/node_modules/@anthropic-ai/sdk/resources/beta/sessions/events.d.mts +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/sessions/events.d.ts +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/sessions/sessions.d.mts +10 -10
- package/node_modules/@anthropic-ai/sdk/resources/beta/sessions/sessions.d.ts +10 -10
- package/node_modules/@anthropic-ai/sdk/resources/beta/sessions/threads/threads.d.mts +2 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/sessions/threads/threads.d.mts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/sessions/threads/threads.d.ts +2 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/sessions/threads/threads.d.ts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/sessions/threads/threads.js.map +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/sessions/threads/threads.mjs.map +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/skills/index.d.mts +2 -2
- package/node_modules/@anthropic-ai/sdk/resources/beta/skills/index.d.mts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/skills/index.d.ts +2 -2
- package/node_modules/@anthropic-ai/sdk/resources/beta/skills/index.d.ts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/skills/index.js.map +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/skills/index.mjs.map +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/skills/skills.d.mts +48 -120
- package/node_modules/@anthropic-ai/sdk/resources/beta/skills/skills.d.mts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/skills/skills.d.ts +48 -120
- package/node_modules/@anthropic-ai/sdk/resources/beta/skills/skills.d.ts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/skills/skills.js +12 -8
- package/node_modules/@anthropic-ai/sdk/resources/beta/skills/skills.js.map +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/skills/skills.mjs +12 -8
- package/node_modules/@anthropic-ai/sdk/resources/beta/skills/skills.mjs.map +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/skills/versions.d.mts +35 -138
- package/node_modules/@anthropic-ai/sdk/resources/beta/skills/versions.d.mts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/skills/versions.d.ts +35 -138
- package/node_modules/@anthropic-ai/sdk/resources/beta/skills/versions.d.ts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/skills/versions.js +18 -18
- package/node_modules/@anthropic-ai/sdk/resources/beta/skills/versions.js.map +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/skills/versions.mjs +18 -18
- package/node_modules/@anthropic-ai/sdk/resources/beta/skills/versions.mjs.map +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/user-profiles.d.mts +21 -25
- package/node_modules/@anthropic-ai/sdk/resources/beta/user-profiles.d.mts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/user-profiles.d.ts +21 -25
- package/node_modules/@anthropic-ai/sdk/resources/beta/user-profiles.d.ts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/webhooks.d.mts +16 -17
- package/node_modules/@anthropic-ai/sdk/resources/beta/webhooks.d.mts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/webhooks.d.ts +16 -17
- package/node_modules/@anthropic-ai/sdk/resources/beta/webhooks.d.ts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/webhooks.js +21 -8
- package/node_modules/@anthropic-ai/sdk/resources/beta/webhooks.js.map +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/beta/webhooks.mjs +21 -8
- package/node_modules/@anthropic-ai/sdk/resources/beta/webhooks.mjs.map +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/messages/messages.d.mts +1 -3
- package/node_modules/@anthropic-ai/sdk/resources/messages/messages.d.mts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/messages/messages.d.ts +1 -3
- package/node_modules/@anthropic-ai/sdk/resources/messages/messages.d.ts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/messages/messages.js.map +1 -1
- package/node_modules/@anthropic-ai/sdk/resources/messages/messages.mjs.map +1 -1
- package/node_modules/@anthropic-ai/sdk/src/core/credentials.ts +5 -7
- package/node_modules/@anthropic-ai/sdk/src/core/middleware.ts +4 -3
- package/node_modules/@anthropic-ai/sdk/src/helpers/beta/standard-schema.ts +99 -0
- package/node_modules/@anthropic-ai/sdk/src/internal/detect-platform.ts +1 -1
- package/node_modules/@anthropic-ai/sdk/src/internal/errors.ts +3 -1
- package/node_modules/@anthropic-ai/sdk/src/internal/file-store.ts +11 -10
- package/node_modules/@anthropic-ai/sdk/src/internal/node.browser.ts +22 -0
- package/node_modules/@anthropic-ai/sdk/src/internal/node.ts +14 -0
- package/node_modules/@anthropic-ai/sdk/src/internal/parse.ts +1 -1
- package/node_modules/@anthropic-ai/sdk/src/internal/uploads.ts +10 -7
- package/node_modules/@anthropic-ai/sdk/src/internal/utils/values.ts +7 -0
- package/node_modules/@anthropic-ai/sdk/src/lib/BetaMessageStream.ts +5 -3
- package/node_modules/@anthropic-ai/sdk/src/lib/MessageStream.ts +1 -3
- package/node_modules/@anthropic-ai/sdk/src/lib/credentials/credential-chain.ts +1 -1
- package/node_modules/@anthropic-ai/sdk/src/lib/credentials/identity-token.ts +1 -1
- package/node_modules/@anthropic-ai/sdk/src/lib/credentials/types.ts +2 -3
- package/node_modules/@anthropic-ai/sdk/src/lib/credentials/user-oauth.ts +1 -1
- package/node_modules/@anthropic-ai/sdk/src/lib/middleware.ts +33 -9
- package/node_modules/@anthropic-ai/sdk/src/lib/sessions/accumulate.ts +7 -49
- package/node_modules/@anthropic-ai/sdk/src/lib/standard-schema.ts +209 -0
- package/node_modules/@anthropic-ai/sdk/src/lib/tools/BetaToolRunner.ts +38 -6
- package/node_modules/@anthropic-ai/sdk/src/resources/beta/agents/agents.ts +1 -0
- package/node_modules/@anthropic-ai/sdk/src/resources/beta/beta.ts +45 -15
- package/node_modules/@anthropic-ai/sdk/src/resources/beta/deployment-runs.ts +6 -6
- package/node_modules/@anthropic-ai/sdk/src/resources/beta/deployments.ts +3 -2
- package/node_modules/@anthropic-ai/sdk/src/resources/beta/dreams.ts +42 -0
- package/node_modules/@anthropic-ai/sdk/src/resources/beta/environments/environments.ts +8 -1
- package/node_modules/@anthropic-ai/sdk/src/resources/beta/files.ts +34 -11
- package/node_modules/@anthropic-ai/sdk/src/resources/beta/index.ts +13 -7
- package/node_modules/@anthropic-ai/sdk/src/resources/beta/memory-stores/memories.ts +12 -9
- package/node_modules/@anthropic-ai/sdk/src/resources/beta/memory-stores/memory-versions.ts +8 -5
- package/node_modules/@anthropic-ai/sdk/src/resources/beta/messages/index.ts +5 -1
- package/node_modules/@anthropic-ai/sdk/src/resources/beta/messages/messages.ts +221 -38
- package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/api-keys.ts +231 -0
- package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/compliance-settings.ts +96 -0
- package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/external-keys.ts +365 -0
- package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/federation/federation.ts +71 -0
- package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/federation/index.ts +31 -0
- package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/federation/issuers.ts +486 -0
- package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/federation/rules/index.ts +23 -0
- package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/federation/rules/rules.ts +624 -0
- package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/federation/rules/workspaces.ts +196 -0
- package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/federation/rules.ts +3 -0
- package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/federation.ts +3 -0
- package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/index.ts +92 -0
- package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/invites.ts +207 -0
- package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/organization.ts +269 -0
- package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/rate-limits.ts +104 -0
- package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/service-accounts/index.ts +21 -0
- package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/service-accounts/service-accounts.ts +389 -0
- package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/service-accounts/workspaces.ts +217 -0
- package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/service-accounts.ts +3 -0
- package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/users.ts +163 -0
- package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/workspaces/index.ts +43 -0
- package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/workspaces/members.ts +209 -0
- package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/workspaces/rate-limits.ts +113 -0
- package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/workspaces/service-accounts.ts +325 -0
- package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/workspaces/workspaces.ts +450 -0
- package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization/workspaces.ts +3 -0
- package/node_modules/@anthropic-ai/sdk/src/resources/beta/organization.ts +3 -0
- package/node_modules/@anthropic-ai/sdk/src/resources/beta/sessions/events.ts +1 -1
- package/node_modules/@anthropic-ai/sdk/src/resources/beta/sessions/sessions.ts +10 -10
- package/node_modules/@anthropic-ai/sdk/src/resources/beta/sessions/threads/threads.ts +2 -1
- package/node_modules/@anthropic-ai/sdk/src/resources/beta/skills/index.ts +7 -10
- package/node_modules/@anthropic-ai/sdk/src/resources/beta/skills/skills.ts +60 -150
- package/node_modules/@anthropic-ai/sdk/src/resources/beta/skills/versions.ts +43 -166
- package/node_modules/@anthropic-ai/sdk/src/resources/beta/user-profiles.ts +24 -27
- package/node_modules/@anthropic-ai/sdk/src/resources/beta/webhooks.ts +25 -29
- package/node_modules/@anthropic-ai/sdk/src/resources/messages/messages.ts +2 -8
- package/node_modules/@anthropic-ai/sdk/src/tools/agent-toolset/fs-util.ts +6 -5
- package/node_modules/@anthropic-ai/sdk/src/tools/agent-toolset/memories.ts +5 -3
- package/node_modules/@anthropic-ai/sdk/src/tools/agent-toolset/node.browser.ts +1 -5
- package/node_modules/@anthropic-ai/sdk/src/tools/agent-toolset/node.ts +122 -17
- package/node_modules/@anthropic-ai/sdk/src/tools/agent-toolset/skills.ts +10 -43
- package/node_modules/@anthropic-ai/sdk/src/version.ts +1 -1
- package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/fs-util.d.mts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/fs-util.d.ts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/fs-util.js +13 -15
- package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/fs-util.js.map +1 -1
- package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/fs-util.mjs +3 -4
- package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/fs-util.mjs.map +1 -1
- package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/memories.d.mts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/memories.d.ts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/memories.js +6 -4
- package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/memories.js.map +1 -1
- package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/memories.mjs +5 -3
- package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/memories.mjs.map +1 -1
- package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/node.browser.d.mts +1 -2
- package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/node.browser.d.mts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/node.browser.d.ts +1 -2
- package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/node.browser.d.ts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/node.browser.js +0 -4
- package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/node.browser.js.map +1 -1
- package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/node.browser.mjs +0 -3
- package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/node.browser.mjs.map +1 -1
- package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/node.d.mts +11 -9
- package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/node.d.mts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/node.d.ts +11 -9
- package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/node.d.ts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/node.js +96 -8
- package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/node.js.map +1 -1
- package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/node.mjs +96 -7
- package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/node.mjs.map +1 -1
- package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/skills.d.mts +0 -8
- package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/skills.d.mts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/skills.d.ts +0 -8
- package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/skills.d.ts.map +1 -1
- package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/skills.js +20 -46
- package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/skills.js.map +1 -1
- package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/skills.mjs +9 -33
- package/node_modules/@anthropic-ai/sdk/tools/agent-toolset/skills.mjs.map +1 -1
- package/node_modules/@anthropic-ai/sdk/version.d.mts +1 -1
- package/node_modules/@anthropic-ai/sdk/version.d.ts +1 -1
- package/node_modules/@anthropic-ai/sdk/version.js +1 -1
- package/node_modules/@anthropic-ai/sdk/version.mjs +1 -1
- package/node_modules/@code-yeongyu/senpi-codemode/CHANGELOG.md +59 -0
- package/node_modules/@code-yeongyu/senpi-codemode/README.md +4 -2
- package/node_modules/@code-yeongyu/senpi-codemode/package.json +5 -5
- package/node_modules/@code-yeongyu/senpi-codemode/src/config/settings.ts +29 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/extension/session-manager.ts +8 -4
- package/node_modules/@code-yeongyu/senpi-codemode/src/index.ts +3 -1
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/js/display-image.js +162 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/js/prelude.ts +2 -2
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/js/worker-runtime.js +29 -60
- package/node_modules/@code-yeongyu/senpi-codemode/src/kernels/py/prelude.py +66 -1
- package/node_modules/@code-yeongyu/senpi-codemode/src/prompt/eval-prompt.ts +35 -96
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/cell-execution.ts +7 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/eval-tool-options.ts +6 -0
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/eval-tool.ts +14 -2
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/types.ts +12 -7
- package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js +58 -64
- package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/agent.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/agent.js +3 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/agent.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/agent-harness.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/agent-harness.js +17 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/agent-harness.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/branch-summarization.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/branch-summarization.js +1 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/branch-summarization.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/compaction.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/compaction.js +17 -6
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/compaction.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/messages.d.ts +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/messages.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/messages.js +6 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/messages.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/reducer.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/reducer.js +6 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/reducer.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/context.d.ts +2 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/context.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/context.js +5 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/context.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/codec.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/codec.js +1 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/codec.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/types.d.ts +7 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/types.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/types.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/write.js +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/write.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/proxy.d.ts +2 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/proxy.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/proxy.js +40 -10
- package/node_modules/@earendil-works/pi-agent-core/dist/proxy.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/types.d.ts +8 -2
- package/node_modules/@earendil-works/pi-agent-core/dist/types.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/types.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/package.json +3 -3
- package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.d.ts +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js +130 -15
- package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent.js +4 -4
- package/node_modules/@earendil-works/pi-ai/dist/api/cursor-agent.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.js +3 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.d.ts +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js +3 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js +30 -10
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.d.ts +3 -3
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js +15 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.d.ts +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js +8 -5
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.d.ts +2 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.js +6 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/warm-prompt-cache.js +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/warm-prompt-cache.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.d.ts +30 -0
- package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.js +30 -0
- package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/index.d.ts +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/index.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/index.js +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/index.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/models.d.ts +3 -1
- package/node_modules/@earendil-works/pi-ai/dist/models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/models.js +27 -3
- package/node_modules/@earendil-works/pi-ai/dist/models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/openai-responses-compat.d.ts +2 -0
- package/node_modules/@earendil-works/pi-ai/dist/openai-responses-compat.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/openai-responses-compat.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/anthropic.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/azure-openai-responses.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/baseten.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-ai-gateway.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/fireworks.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/github-copilot.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/openai-codex.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/openai.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode-go.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/faux.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/faux.js +2 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/faux.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.d.ts +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.js +8 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/types.d.ts +22 -2
- package/node_modules/@earendil-works/pi-ai/dist/types.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/types.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/drop-failed-assistant-turns.d.ts +23 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/drop-failed-assistant-turns.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/drop-failed-assistant-turns.js +58 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/drop-failed-assistant-turns.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/estimate.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/estimate.js +2 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/estimate.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/node-http-proxy.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/node-http-proxy.js +53 -12
- package/node_modules/@earendil-works/pi-ai/dist/utils/node-http-proxy.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/prompt-cache-ttl.d.ts +4 -2
- package/node_modules/@earendil-works/pi-ai/dist/utils/prompt-cache-ttl.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/prompt-cache-ttl.js +3 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/prompt-cache-ttl.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry.js +3 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/package.json +3 -3
- package/node_modules/@earendil-works/pi-pty/package.json +1 -1
- package/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
- package/node_modules/@earendil-works/pi-tui/README.md +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/autocomplete.d.ts +1 -0
- package/node_modules/@earendil-works/pi-tui/dist/autocomplete.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/autocomplete.js +36 -3
- package/node_modules/@earendil-works/pi-tui/dist/autocomplete.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/index.d.ts +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/index.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/index.js +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/index.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/terminal-image.d.ts +2 -0
- package/node_modules/@earendil-works/pi-tui/dist/terminal-image.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/terminal-image.js +106 -6
- package/node_modules/@earendil-works/pi-tui/dist/terminal-image.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/terminal.d.ts +6 -0
- package/node_modules/@earendil-works/pi-tui/dist/terminal.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/terminal.js +17 -4
- package/node_modules/@earendil-works/pi-tui/dist/terminal.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/tui-alt-screen.d.ts +11 -0
- package/node_modules/@earendil-works/pi-tui/dist/tui-alt-screen.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/tui-alt-screen.js +57 -15
- package/node_modules/@earendil-works/pi-tui/dist/tui-alt-screen.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/tui.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-tui/dist/tui.js +22 -7
- package/node_modules/@earendil-works/pi-tui/dist/tui.js.map +1 -1
- package/node_modules/@earendil-works/pi-tui/package.json +1 -1
- package/package.json +8 -8
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { resolve } from "node:path";
|
|
1
2
|
import { StringEnum } from "@earendil-works/pi-ai";
|
|
2
3
|
import { Type } from "typebox";
|
|
3
4
|
import { APPROVED_MONITOR_PARENT } from "../monitor-permission.js";
|
|
4
5
|
import { MonitorRegistry } from "../monitor-registry.js";
|
|
5
|
-
import { DEFAULT_COLS, DEFAULT_ROWS, TERMINAL_MONITOR_TOOL } from "../shared.js";
|
|
6
|
-
import { errorResult, textResult } from "./context.js";
|
|
6
|
+
import { DEFAULT_COLS, DEFAULT_ROWS, DURABLE_MONITOR_EXPIRY_MS, MAX_DURABLE_MONITORS, TERMINAL_MONITOR_TOOL, } from "../shared.js";
|
|
7
|
+
import { errorResult, resolveTerminalId, textResult, } from "./context.js";
|
|
7
8
|
import { renderMonitorCall } from "./render.js";
|
|
8
9
|
import { spawnCommandSession } from "./spawn.js";
|
|
9
10
|
export const DEFAULT_MONITOR_TIMEOUT_MS = 300_000;
|
|
@@ -28,7 +29,7 @@ export const monitorSchema = Type.Object({
|
|
|
28
29
|
})),
|
|
29
30
|
path: Type.Optional(Type.String({
|
|
30
31
|
minLength: 1,
|
|
31
|
-
description: "Create, file branch (XOR command): one regular file to watch natively, whose parent directory must already exist; takes no filter
|
|
32
|
+
description: "Create, file branch (XOR command): one regular file to watch natively, whose parent directory must already exist; takes no filter.",
|
|
32
33
|
})),
|
|
33
34
|
event: Type.Optional(StringEnum(["create", "modify"], {
|
|
34
35
|
description: "File branch only: which file event fires the watch (defaults to create).",
|
|
@@ -37,10 +38,12 @@ export const monitorSchema = Type.Object({
|
|
|
37
38
|
timeout_ms: Type.Optional(Type.Number({
|
|
38
39
|
minimum: 1,
|
|
39
40
|
maximum: MAX_MONITOR_TIMEOUT_MS,
|
|
40
|
-
description: "Watcher deadline in milliseconds (default 300000; ignored
|
|
41
|
+
description: "Watcher deadline in milliseconds (default 300000; ignored when persistent).",
|
|
41
42
|
})),
|
|
42
|
-
persistent: Type.Optional(Type.Boolean({
|
|
43
|
-
|
|
43
|
+
persistent: Type.Optional(Type.Boolean({
|
|
44
|
+
description: "Standing watch: no deadline, and it survives a session restart (command re-run once, file rescanned and any detached change reported). Expires 7 days after creation; max 5 per session; stop one with kill_bash.",
|
|
45
|
+
})),
|
|
46
|
+
bash_id: Type.Optional(Type.String({ description: "Rearm: paused monitor id (mon_ or bash_id) to resume; omit for all paused." })),
|
|
44
47
|
});
|
|
45
48
|
function isFileCreateInput(input) {
|
|
46
49
|
return (typeof input.description === "string" &&
|
|
@@ -76,18 +79,83 @@ async function createMonitor(ctx, registry, input, execCtx) {
|
|
|
76
79
|
catch {
|
|
77
80
|
return errorResult(`Invalid monitor filter regex: ${input.filter}`);
|
|
78
81
|
}
|
|
82
|
+
// Durability needs an absolute directory: a restore runs in a different process whose
|
|
83
|
+
// process cwd is unrelated, so the spec must carry the resolved path the spawn used.
|
|
84
|
+
const cwd = resolve(execCtx?.cwd ?? ctx.cwd);
|
|
79
85
|
const { id, runtime } = await spawnCommandSession(ctx, {
|
|
80
86
|
command: input.command,
|
|
81
87
|
cols: resolveDimension(undefined, ctx.defaultCols || DEFAULT_COLS),
|
|
82
88
|
rows: resolveDimension(undefined, ctx.defaultRows || DEFAULT_ROWS),
|
|
83
|
-
cwd
|
|
89
|
+
cwd,
|
|
84
90
|
...(input.persistent ? {} : { timeoutMs: resolveTimeoutMs(input.timeout_ms) }),
|
|
85
91
|
});
|
|
86
92
|
ctx.onMonitorRearmed?.(id);
|
|
87
|
-
registry.register({
|
|
88
|
-
|
|
93
|
+
const monitorId = registry.register({
|
|
94
|
+
id,
|
|
95
|
+
description: input.description,
|
|
96
|
+
runtime,
|
|
97
|
+
filter,
|
|
98
|
+
// Only persistent command watches are restartable-command durable: those carry the fire budget.
|
|
99
|
+
durabilityClass: input.persistent === true ? "restartable-command" : "ephemeral",
|
|
100
|
+
// Same deadline the manifest writer persists, so the footer warns off the live record too.
|
|
101
|
+
...(input.persistent === true ? { expiresAt: Date.now() + DURABLE_MONITOR_EXPIRY_MS } : {}),
|
|
102
|
+
});
|
|
103
|
+
ctx.manager.bindMonitorId(monitorId, id);
|
|
104
|
+
// The tool call site is the only place the branch inputs (command, persistent, filter)
|
|
105
|
+
// live; hand the captured spec to the session's manifest writer for durable recording.
|
|
106
|
+
handMonitorSpec(manifestSessionKey(ctx), {
|
|
107
|
+
monitorId,
|
|
108
|
+
spec: {
|
|
109
|
+
kind: "command",
|
|
110
|
+
description: input.description,
|
|
111
|
+
command: input.command,
|
|
112
|
+
filter: input.filter,
|
|
113
|
+
cwd,
|
|
114
|
+
persistent: input.persistent === true,
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
return textResult(`Monitor started with ID: ${monitorId}`, {
|
|
118
|
+
details: { monitor_id: monitorId, bash_id: id, monitor: true },
|
|
119
|
+
});
|
|
89
120
|
}
|
|
90
121
|
/** Build the PTY-backed monitor tool. Monitor handles share TerminalManager's bash_N namespace. */
|
|
122
|
+
const manifestWriters = new Map();
|
|
123
|
+
/** Bind the session's manifest writer so monitor tool calls can hand it specs captured at the call site. */
|
|
124
|
+
export function bindTerminalManifestWriter(sessionId, writer) {
|
|
125
|
+
manifestWriters.set(sessionId, writer);
|
|
126
|
+
}
|
|
127
|
+
export function unbindTerminalManifestWriter(sessionId) {
|
|
128
|
+
manifestWriters.delete(sessionId);
|
|
129
|
+
}
|
|
130
|
+
/** The durability session key for a tool context: the agent session id, when the context carries one. */
|
|
131
|
+
function manifestSessionKey(ctx) {
|
|
132
|
+
return ctx.getSessionContext?.()?.sessionManager?.getSessionId?.();
|
|
133
|
+
}
|
|
134
|
+
/** Hand a spec captured at the monitor tool call site to the session's bound writer, if any. */
|
|
135
|
+
function handMonitorSpec(sessionKey, registration) {
|
|
136
|
+
const writer = sessionKey === undefined ? undefined : manifestWriters.get(sessionKey);
|
|
137
|
+
void writer?.recordRegister(registration);
|
|
138
|
+
}
|
|
139
|
+
/** Persist a durable file watch's baseline checkpoint through the writer's debounced path. */
|
|
140
|
+
function handFileCheckpoint(sessionKey, monitorId, registry, runtimeId) {
|
|
141
|
+
const writer = sessionKey === undefined ? undefined : manifestWriters.get(sessionKey);
|
|
142
|
+
const checkpoint = registry.fileCheckpoint(runtimeId);
|
|
143
|
+
if (writer && checkpoint)
|
|
144
|
+
writer.scheduleCheckpoint(monitorId, checkpoint);
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Admission control for a durable create: refuse once the session already holds
|
|
148
|
+
* MAX_DURABLE_MONITORS restart-surviving monitors. Checked BEFORE any spawn or registry
|
|
149
|
+
* registration so a refused call leaves no PTY and no manifest entry behind. A context
|
|
150
|
+
* with no bound writer persists nothing, so it has no durable population to cap.
|
|
151
|
+
*/
|
|
152
|
+
function durableAdmissionError(ctx) {
|
|
153
|
+
const sessionKey = manifestSessionKey(ctx);
|
|
154
|
+
const writer = sessionKey === undefined ? undefined : manifestWriters.get(sessionKey);
|
|
155
|
+
if (writer === undefined || writer.durableCount() < MAX_DURABLE_MONITORS)
|
|
156
|
+
return undefined;
|
|
157
|
+
return errorResult(`Cannot start another persistent monitor: this session already holds ${MAX_DURABLE_MONITORS} durable monitors (the maximum). Stop one with kill_bash first.`);
|
|
158
|
+
}
|
|
91
159
|
export function createMonitorTool(ctx) {
|
|
92
160
|
let fallbackRegistry;
|
|
93
161
|
const getRegistry = () => {
|
|
@@ -100,7 +168,7 @@ export function createMonitorTool(ctx) {
|
|
|
100
168
|
return {
|
|
101
169
|
name: TERMINAL_MONITOR_TOOL,
|
|
102
170
|
label: "monitor",
|
|
103
|
-
description: "Subscribe to a change instead of polling. Pass command XOR path, never both: command watches a PTY session,
|
|
171
|
+
description: "Subscribe to a change instead of polling. Pass command XOR path, never both: command watches a PTY session, injecting matching newline-terminated output lines (stderr merged) plus an exit summary; path natively watches one file and fires once, where create (the default) fires only when the file appears after registration, so use event modify for an existing file, and filter is rejected. Returns a bash_id immediately; peek with bash_output, stop with kill_bash.",
|
|
104
172
|
promptSnippet: "Subscribe to a command's output or a file's create/modify event as injected events instead of polling",
|
|
105
173
|
promptGuidelines: [
|
|
106
174
|
"Waiting on observable state (CI checks, builds, log patterns, deploys, a file landing) means a monitor, never a foreground sleep/poll loop.",
|
|
@@ -113,8 +181,7 @@ export function createMonitorTool(ctx) {
|
|
|
113
181
|
async execute(_toolCallId, input, _signal, _onUpdate, execCtx) {
|
|
114
182
|
const registry = getRegistry();
|
|
115
183
|
if (input.action === "rearm") {
|
|
116
|
-
|
|
117
|
-
if (bashId === undefined || bashId.length === 0) {
|
|
184
|
+
if (input.bash_id === undefined || input.bash_id.length === 0) {
|
|
118
185
|
const resumed = registry.resume();
|
|
119
186
|
if (resumed.length === 0)
|
|
120
187
|
return textResult("No paused monitors to re-arm.");
|
|
@@ -124,6 +191,7 @@ export function createMonitorTool(ctx) {
|
|
|
124
191
|
? `Re-armed ${resumed.length} paused monitor(s) (${total} line(s) dropped while muted).`
|
|
125
192
|
: `Re-armed ${resumed.length} paused monitor(s).`);
|
|
126
193
|
}
|
|
194
|
+
const bashId = resolveTerminalId(ctx.manager, input.bash_id);
|
|
127
195
|
const dropped = registry.mutedDropped(bashId);
|
|
128
196
|
const outcome = registry.rearm(bashId);
|
|
129
197
|
if (outcome === "not_found")
|
|
@@ -139,26 +207,50 @@ export function createMonitorTool(ctx) {
|
|
|
139
207
|
const commandInput = isCreateInput(input);
|
|
140
208
|
if (fileInput && commandInput)
|
|
141
209
|
return errorResult("monitor accepts either command or path, not both.");
|
|
210
|
+
// Admission runs before either create branch touches a PTY or the registry.
|
|
211
|
+
if (input.persistent === true && (fileInput || commandInput)) {
|
|
212
|
+
const refused = durableAdmissionError(ctx);
|
|
213
|
+
if (refused)
|
|
214
|
+
return refused;
|
|
215
|
+
}
|
|
142
216
|
if (fileInput) {
|
|
143
|
-
if (input.filter !== undefined
|
|
144
|
-
return errorResult("Native file monitors do not support filter
|
|
217
|
+
if (input.filter !== undefined)
|
|
218
|
+
return errorResult("Native file monitors do not support filter.");
|
|
145
219
|
if (!ctx.monitorRegistry)
|
|
146
220
|
return errorResult("Native file monitors require a lifecycle-owned monitor registry.");
|
|
147
221
|
try {
|
|
148
|
-
const
|
|
222
|
+
const approvedParent = input[APPROVED_MONITOR_PARENT];
|
|
223
|
+
const { id, monitorId } = await ctx.monitorRegistry.registerFile({
|
|
149
224
|
description: input.description,
|
|
150
225
|
path: input.path,
|
|
151
226
|
event: input.event ?? "create",
|
|
152
227
|
timeoutMs: resolveTimeoutMs(input.timeout_ms),
|
|
153
228
|
cwd: execCtx?.cwd ?? ctx.cwd,
|
|
154
|
-
...(
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
229
|
+
...(approvedParent !== undefined ? { approvedParent } : {}),
|
|
230
|
+
...(input.persistent === true ? { expiresAt: Date.now() + DURABLE_MONITOR_EXPIRY_MS } : {}),
|
|
231
|
+
});
|
|
232
|
+
ctx.manager.bindMonitorId(monitorId, id);
|
|
233
|
+
// Same spec capture as the command branch: durability inputs live only here.
|
|
234
|
+
const sessionKey = manifestSessionKey(ctx);
|
|
235
|
+
handMonitorSpec(sessionKey, {
|
|
236
|
+
monitorId,
|
|
237
|
+
spec: {
|
|
238
|
+
kind: "file",
|
|
239
|
+
description: input.description,
|
|
240
|
+
path: input.path,
|
|
241
|
+
event: input.event ?? "create",
|
|
242
|
+
timeoutMs: resolveTimeoutMs(input.timeout_ms),
|
|
243
|
+
cwd: execCtx?.cwd ?? ctx.cwd,
|
|
244
|
+
persistent: input.persistent === true,
|
|
245
|
+
...(approvedParent !== undefined ? { approvedParent } : {}),
|
|
246
|
+
},
|
|
159
247
|
});
|
|
160
|
-
|
|
161
|
-
|
|
248
|
+
// A durable watch checkpoints the registry's own identity tuple straight away, so a
|
|
249
|
+
// restart before the first change still has a baseline (digest included) to compare to.
|
|
250
|
+
if (input.persistent === true)
|
|
251
|
+
handFileCheckpoint(sessionKey, monitorId, ctx.monitorRegistry, id);
|
|
252
|
+
return textResult(`Monitor started with ID: ${monitorId}`, {
|
|
253
|
+
details: { monitor_id: monitorId, bash_id: id, monitor: true },
|
|
162
254
|
});
|
|
163
255
|
}
|
|
164
256
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"monitor.js","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/terminal/tools/monitor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACjF,OAAO,EAAE,WAAW,EAAqD,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1G,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEjD,MAAM,CAAC,MAAM,0BAA0B,GAAG,OAAO,CAAC;AAClD,MAAM,CAAC,MAAM,sBAAsB,GAAG,SAAS,CAAC;AAEhD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC;IACxC,MAAM,EAAE,IAAI,CAAC,QAAQ,CACpB,UAAU,CAAC,CAAC,QAAQ,EAAE,OAAO,CAAU,EAAE;QACxC,WAAW,EAAE,wEAAwE;KACrF,CAAC,CACF;IACD,WAAW,EAAE,IAAI,CAAC,QAAQ,CACzB,IAAI,CAAC,MAAM,CAAC;QACX,SAAS,EAAE,CAAC;QACZ,SAAS,EAAE,GAAG;QACd,WAAW,EAAE,wFAAwF;KACrG,CAAC,CACF;IACD,OAAO,EAAE,IAAI,CAAC,QAAQ,CACrB,IAAI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E,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;qBACrD,CAAC,CAAC;gBACJ,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBAChB,OAAO,WAAW,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;gBAC5E,CAAC;YACF,CAAC;YACD,IAAI,CAAC,YAAY;gBAAE,OAAO,WAAW,CAAC,sEAAsE,CAAC,CAAC;YAC9G,OAAO,aAAa,CAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;QACrD,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["import { StringEnum } from \"@earendil-works/pi-ai\";\nimport { type Static, Type } from \"typebox\";\nimport { APPROVED_MONITOR_PARENT } from \"../monitor-permission.ts\";\nimport { MonitorRegistry } from \"../monitor-registry.ts\";\nimport { DEFAULT_COLS, DEFAULT_ROWS, TERMINAL_MONITOR_TOOL } from \"../shared.ts\";\nimport { errorResult, type TerminalToolContext, type TerminalToolResult, textResult } from \"./context.ts\";\nimport { renderMonitorCall } from \"./render.ts\";\nimport { spawnCommandSession } from \"./spawn.ts\";\n\nexport const DEFAULT_MONITOR_TIMEOUT_MS = 300_000;\nexport const MAX_MONITOR_TIMEOUT_MS = 3_600_000;\n\n/**\n * One flat object schema, no top-level union: several provider payload paths\n * (e.g. Anthropic's legacy input_schema conversion) rebuild tool schemas from\n * top-level `properties` only, so a root anyOf would reach the model as an\n * empty schema. Branch requirements are enforced at runtime in `execute`.\n */\nexport const monitorSchema = Type.Object({\n\taction: Type.Optional(\n\t\tStringEnum([\"create\", \"rearm\"] as const, {\n\t\t\tdescription: \"Defaults to create. rearm resumes a monitor paused by the wake budget.\",\n\t\t}),\n\t),\n\tdescription: Type.Optional(\n\t\tType.String({\n\t\t\tminLength: 1,\n\t\t\tmaxLength: 200,\n\t\t\tdescription: \"Create (required): specific label shown with every event, e.g. 'errors in deploy.log'.\",\n\t\t}),\n\t),\n\tcommand: Type.Optional(\n\t\tType.String({\n\t\t\tdescription:\n\t\t\t\t\"Create, command branch (XOR path): shell command to run and watch in a PTY-backed monitor session.\",\n\t\t}),\n\t),\n\tpath: Type.Optional(\n\t\tType.String({\n\t\t\tminLength: 1,\n\t\t\tdescription:\n\t\t\t\t\"Create, file branch (XOR command): one regular file to watch natively, whose parent directory must already exist; takes no filter and no persistent.\",\n\t\t}),\n\t),\n\tevent: Type.Optional(\n\t\tStringEnum([\"create\", \"modify\"] as const, {\n\t\t\tdescription: \"File branch only: which file event fires the watch (defaults to create).\",\n\t\t}),\n\t),\n\tfilter: Type.Optional(\n\t\tType.String({ description: \"Only PTY output lines matching this regex become monitor events.\" }),\n\t),\n\ttimeout_ms: Type.Optional(\n\t\tType.Number({\n\t\t\tminimum: 1,\n\t\t\tmaximum: MAX_MONITOR_TIMEOUT_MS,\n\t\t\tdescription: \"Watcher deadline in milliseconds (default 300000; ignored by persistent monitors).\",\n\t\t}),\n\t),\n\tpersistent: Type.Optional(\n\t\tType.Boolean({ description: \"Keep watching until the command exits or kill_bash stops its bash_id.\" }),\n\t),\n\tbash_id: Type.Optional(\n\t\tType.String({ description: \"Rearm: paused monitor bash_id to resume; omit to resume all paused monitors.\" }),\n\t),\n});\nexport type MonitorInput = Static<typeof monitorSchema>;\n\ntype MonitorCreateInput = MonitorInput & { description: string; command: string };\ntype FileMonitorCreateInput = MonitorInput & { description: string; path: string };\n\nfunction isFileCreateInput(input: MonitorInput): input is FileMonitorCreateInput {\n\treturn (\n\t\ttypeof input.description === \"string\" &&\n\t\tinput.description.length > 0 &&\n\t\ttypeof input.path === \"string\" &&\n\t\tinput.path.length > 0\n\t);\n}\n\nfunction isCreateInput(input: MonitorInput): input is MonitorCreateInput {\n\treturn (\n\t\ttypeof input.description === \"string\" &&\n\t\tinput.description.length > 0 &&\n\t\ttypeof input.command === \"string\" &&\n\t\tinput.command.length > 0\n\t);\n}\n\nfunction resolveDimension(value: number | undefined, fallback: number): number {\n\tif (value === undefined || !Number.isFinite(value) || value < 1) return fallback;\n\treturn Math.trunc(value);\n}\n\nfunction resolveTimeoutMs(value: number | undefined): number {\n\tconst timeout = value ?? DEFAULT_MONITOR_TIMEOUT_MS;\n\treturn Math.min(Math.max(Math.trunc(timeout), 1), MAX_MONITOR_TIMEOUT_MS);\n}\n\nfunction compileFilter(filter: string | undefined): RegExp | undefined {\n\tif (filter === undefined) return undefined;\n\treturn new RegExp(filter);\n}\n\nasync function createMonitor(\n\tctx: TerminalToolContext,\n\tregistry: MonitorRegistry,\n\tinput: MonitorCreateInput,\n\texecCtx: { cwd?: string } | undefined,\n): Promise<TerminalToolResult> {\n\tlet filter: RegExp | undefined;\n\ttry {\n\t\tfilter = compileFilter(input.filter);\n\t} catch {\n\t\treturn errorResult(`Invalid monitor filter regex: ${input.filter}`);\n\t}\n\n\tconst { id, runtime } = await spawnCommandSession(ctx, {\n\t\tcommand: input.command,\n\t\tcols: resolveDimension(undefined, ctx.defaultCols || DEFAULT_COLS),\n\t\trows: resolveDimension(undefined, ctx.defaultRows || DEFAULT_ROWS),\n\t\tcwd: execCtx?.cwd,\n\t\t...(input.persistent ? {} : { timeoutMs: resolveTimeoutMs(input.timeout_ms) }),\n\t});\n\tctx.onMonitorRearmed?.(id);\n\tregistry.register({ id, description: input.description, runtime, filter });\n\treturn textResult(`Monitor started with ID: ${id}`, { details: { bash_id: id, monitor: true } });\n}\n\n/** Build the PTY-backed monitor tool. Monitor handles share TerminalManager's bash_N namespace. */\nexport function createMonitorTool(ctx: TerminalToolContext) {\n\tlet fallbackRegistry: MonitorRegistry | undefined;\n\tconst getRegistry = (): MonitorRegistry => {\n\t\tconst sessionRegistry = ctx.monitorRegistry;\n\t\tif (sessionRegistry) return sessionRegistry;\n\t\tfallbackRegistry ??= new MonitorRegistry((event) => ctx.onMonitorEvent?.(event));\n\t\treturn fallbackRegistry;\n\t};\n\treturn {\n\t\tname: TERMINAL_MONITOR_TOOL,\n\t\tlabel: \"monitor\",\n\t\tdescription:\n\t\t\t\"Subscribe to a change instead of polling. Pass command XOR path, never both: command watches a PTY session, where newline-terminated output lines (stderr merged) that match filter arrive as injected events while you keep working and command exit always delivers a summary event; path natively watches one file and fires once: create (the default) fires only when the file appears after registration, so watch a file that already exists with event modify. The path branch takes no filter and no persistent. Identical consecutive line-only update batches are deduped, so a watcher reprinting unchanged status does not re-wake the session. Returns a bash_id immediately; peek with bash_output, stop with kill_bash.\",\n\t\tpromptSnippet:\n\t\t\t\"Subscribe to a command's output or a file's create/modify event as injected events instead of polling\",\n\t\tpromptGuidelines: [\n\t\t\t\"Waiting on observable state (CI checks, builds, log patterns, deploys, a file landing) means a monitor, never a foreground sleep/poll loop.\",\n\t\t\t'Waiting for one file to appear or change is the path branch: `monitor({ description, path, event? })` beats wrapping `test -f` in a shell poll loop; a file that already exists needs `event: \"modify\"`, since `create` only fires on appearance, and registration needs the parent directory to exist already — when the run creates that directory too, use the `command` branch instead.',\n\t\t\t\"Shape the command for the events you need: one-shot gate = `until <cond>; do sleep 1; done; printf 'READY\\\\n'` with filter ^READY$; stream = `tail -n 0 -F <log> | grep --line-buffered <pat>` with persistent: true, then kill_bash.\",\n\t\t\t\"Sleep loops belong INSIDE the monitor command, never in your turn: about to sleep, re-poll bash_output, or foreground-block on a long command means register a monitor and keep working.\",\n\t\t],\n\t\tparameters: monitorSchema,\n\t\trenderCall: renderMonitorCall,\n\t\tasync execute(\n\t\t\t_toolCallId: string,\n\t\t\tinput: MonitorInput,\n\t\t\t_signal?: AbortSignal,\n\t\t\t_onUpdate?: undefined,\n\t\t\texecCtx?: { cwd?: string },\n\t\t): Promise<TerminalToolResult> {\n\t\t\tconst registry = getRegistry();\n\t\t\tif (input.action === \"rearm\") {\n\t\t\t\tconst bashId = input.bash_id;\n\t\t\t\tif (bashId === undefined || bashId.length === 0) {\n\t\t\t\t\tconst resumed = registry.resume();\n\t\t\t\t\tif (resumed.length === 0) return textResult(\"No paused monitors to re-arm.\");\n\t\t\t\t\tctx.onMonitorsResumed?.(resumed.map((monitor) => monitor.id));\n\t\t\t\t\tconst total = resumed.reduce((sum, monitor) => sum + monitor.mutedDropped, 0);\n\t\t\t\t\treturn textResult(\n\t\t\t\t\t\ttotal > 0\n\t\t\t\t\t\t\t? `Re-armed ${resumed.length} paused monitor(s) (${total} line(s) dropped while muted).`\n\t\t\t\t\t\t\t: `Re-armed ${resumed.length} paused monitor(s).`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst dropped = registry.mutedDropped(bashId);\n\t\t\t\tconst outcome = registry.rearm(bashId);\n\t\t\t\tif (outcome === \"not_found\") return errorResult(`No active monitor found with id: ${bashId}`);\n\t\t\t\tif (outcome === \"not_paused\") return textResult(`Monitor ${bashId} is not paused; no action taken.`);\n\t\t\t\tctx.onMonitorRearmed?.(bashId);\n\t\t\t\treturn textResult(\n\t\t\t\t\tdropped > 0\n\t\t\t\t\t\t? `Monitor ${bashId} re-armed (${dropped} line(s) dropped while muted).`\n\t\t\t\t\t\t: `Monitor ${bashId} re-armed.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst fileInput = isFileCreateInput(input);\n\t\t\tconst commandInput = isCreateInput(input);\n\t\t\tif (fileInput && commandInput) return errorResult(\"monitor accepts either command or path, not both.\");\n\t\t\tif (fileInput) {\n\t\t\t\tif (input.filter !== undefined || input.persistent)\n\t\t\t\t\treturn errorResult(\"Native file monitors do not support filter or persistent.\");\n\t\t\t\tif (!ctx.monitorRegistry)\n\t\t\t\t\treturn errorResult(\"Native file monitors require a lifecycle-owned monitor registry.\");\n\t\t\t\ttry {\n\t\t\t\t\tconst id = await ctx.monitorRegistry.registerFile({\n\t\t\t\t\t\tdescription: input.description,\n\t\t\t\t\t\tpath: input.path,\n\t\t\t\t\t\tevent: input.event ?? \"create\",\n\t\t\t\t\t\ttimeoutMs: resolveTimeoutMs(input.timeout_ms),\n\t\t\t\t\t\tcwd: execCtx?.cwd ?? ctx.cwd,\n\t\t\t\t\t\t...((input as Record<string | symbol, unknown>)[APPROVED_MONITOR_PARENT] !== undefined\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\tapprovedParent: (input as Record<string | symbol, unknown>)[\n\t\t\t\t\t\t\t\t\t\tAPPROVED_MONITOR_PARENT\n\t\t\t\t\t\t\t\t\t] as string,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t});\n\t\t\t\t\treturn textResult(`Monitor started with ID: ${id}`, {\n\t\t\t\t\t\tdetails: { bash_id: id, watch_id: id, monitor: true },\n\t\t\t\t\t});\n\t\t\t\t} catch (error) {\n\t\t\t\t\treturn errorResult(error instanceof Error ? error.message : String(error));\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!commandInput) return errorResult(\"monitor requires description and command or path to start a watcher.\");\n\t\t\treturn createMonitor(ctx, registry, input, execCtx);\n\t\t},\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"monitor.js","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/terminal/tools/monitor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EACN,YAAY,EACZ,YAAY,EACZ,yBAAyB,EACzB,oBAAoB,EACpB,qBAAqB,GACrB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACN,WAAW,EACX,iBAAiB,EAGjB,UAAU,GACV,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE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AG,CAAC,GAAG;4BAC5B,UAAU,EAAE,KAAK,CAAC,UAAU,KAAK,IAAI;4BACrC,GAAG,CAAC,cAAc,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;yBAC3D;qBACD,CAAC,CAAC;oBACH,oFAAoF;oBACpF,wFAAwF;oBACxF,IAAI,KAAK,CAAC,UAAU,KAAK,IAAI;wBAAE,kBAAkB,CAAC,UAAU,EAAE,SAAS,EAAE,GAAG,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC;oBAClG,OAAO,UAAU,CAAC,4BAA4B,SAAS,EAAE,EAAE;wBAC1D,OAAO,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;qBAC9D,CAAC,CAAC;gBACJ,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBAChB,OAAO,WAAW,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;gBAC5E,CAAC;YACF,CAAC;YACD,IAAI,CAAC,YAAY;gBAAE,OAAO,WAAW,CAAC,sEAAsE,CAAC,CAAC;YAC9G,OAAO,aAAa,CAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;QACrD,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["import { resolve } from \"node:path\";\nimport { StringEnum } from \"@earendil-works/pi-ai\";\nimport { type Static, Type } from \"typebox\";\nimport { APPROVED_MONITOR_PARENT } from \"../monitor-permission.ts\";\nimport { MonitorRegistry } from \"../monitor-registry.ts\";\nimport {\n\tDEFAULT_COLS,\n\tDEFAULT_ROWS,\n\tDURABLE_MONITOR_EXPIRY_MS,\n\tMAX_DURABLE_MONITORS,\n\tTERMINAL_MONITOR_TOOL,\n} from \"../shared.ts\";\nimport type { MonitorRegistration, TerminalManifestWriter } from \"../terminal-manifest.ts\";\nimport {\n\terrorResult,\n\tresolveTerminalId,\n\ttype TerminalToolContext,\n\ttype TerminalToolResult,\n\ttextResult,\n} from \"./context.ts\";\nimport { renderMonitorCall } from \"./render.ts\";\nimport { spawnCommandSession } from \"./spawn.ts\";\n\nexport const DEFAULT_MONITOR_TIMEOUT_MS = 300_000;\nexport const MAX_MONITOR_TIMEOUT_MS = 3_600_000;\n\n/**\n * One flat object schema, no top-level union: several provider payload paths\n * (e.g. Anthropic's legacy input_schema conversion) rebuild tool schemas from\n * top-level `properties` only, so a root anyOf would reach the model as an\n * empty schema. Branch requirements are enforced at runtime in `execute`.\n */\nexport const monitorSchema = Type.Object({\n\taction: Type.Optional(\n\t\tStringEnum([\"create\", \"rearm\"] as const, {\n\t\t\tdescription: \"Defaults to create. rearm resumes a monitor paused by the wake budget.\",\n\t\t}),\n\t),\n\tdescription: Type.Optional(\n\t\tType.String({\n\t\t\tminLength: 1,\n\t\t\tmaxLength: 200,\n\t\t\tdescription: \"Create (required): specific label shown with every event, e.g. 'errors in deploy.log'.\",\n\t\t}),\n\t),\n\tcommand: Type.Optional(\n\t\tType.String({\n\t\t\tdescription:\n\t\t\t\t\"Create, command branch (XOR path): shell command to run and watch in a PTY-backed monitor session.\",\n\t\t}),\n\t),\n\tpath: Type.Optional(\n\t\tType.String({\n\t\t\tminLength: 1,\n\t\t\tdescription:\n\t\t\t\t\"Create, file branch (XOR command): one regular file to watch natively, whose parent directory must already exist; takes no filter.\",\n\t\t}),\n\t),\n\tevent: Type.Optional(\n\t\tStringEnum([\"create\", \"modify\"] as const, {\n\t\t\tdescription: \"File branch only: which file event fires the watch (defaults to create).\",\n\t\t}),\n\t),\n\tfilter: Type.Optional(\n\t\tType.String({ description: \"Only PTY output lines matching this regex become monitor events.\" }),\n\t),\n\ttimeout_ms: Type.Optional(\n\t\tType.Number({\n\t\t\tminimum: 1,\n\t\t\tmaximum: MAX_MONITOR_TIMEOUT_MS,\n\t\t\tdescription: \"Watcher deadline in milliseconds (default 300000; ignored when persistent).\",\n\t\t}),\n\t),\n\tpersistent: Type.Optional(\n\t\tType.Boolean({\n\t\t\tdescription:\n\t\t\t\t\"Standing watch: no deadline, and it survives a session restart (command re-run once, file rescanned and any detached change reported). Expires 7 days after creation; max 5 per session; stop one with kill_bash.\",\n\t\t}),\n\t),\n\tbash_id: Type.Optional(\n\t\tType.String({ description: \"Rearm: paused monitor id (mon_ or bash_id) to resume; omit for all paused.\" }),\n\t),\n});\nexport type MonitorInput = Static<typeof monitorSchema>;\n\ntype MonitorCreateInput = MonitorInput & { description: string; command: string };\ntype FileMonitorCreateInput = MonitorInput & { description: string; path: string };\n\nfunction isFileCreateInput(input: MonitorInput): input is FileMonitorCreateInput {\n\treturn (\n\t\ttypeof input.description === \"string\" &&\n\t\tinput.description.length > 0 &&\n\t\ttypeof input.path === \"string\" &&\n\t\tinput.path.length > 0\n\t);\n}\n\nfunction isCreateInput(input: MonitorInput): input is MonitorCreateInput {\n\treturn (\n\t\ttypeof input.description === \"string\" &&\n\t\tinput.description.length > 0 &&\n\t\ttypeof input.command === \"string\" &&\n\t\tinput.command.length > 0\n\t);\n}\n\nfunction resolveDimension(value: number | undefined, fallback: number): number {\n\tif (value === undefined || !Number.isFinite(value) || value < 1) return fallback;\n\treturn Math.trunc(value);\n}\n\nfunction resolveTimeoutMs(value: number | undefined): number {\n\tconst timeout = value ?? DEFAULT_MONITOR_TIMEOUT_MS;\n\treturn Math.min(Math.max(Math.trunc(timeout), 1), MAX_MONITOR_TIMEOUT_MS);\n}\n\nfunction compileFilter(filter: string | undefined): RegExp | undefined {\n\tif (filter === undefined) return undefined;\n\treturn new RegExp(filter);\n}\n\nasync function createMonitor(\n\tctx: TerminalToolContext,\n\tregistry: MonitorRegistry,\n\tinput: MonitorCreateInput,\n\texecCtx: { cwd?: string } | undefined,\n): Promise<TerminalToolResult> {\n\tlet filter: RegExp | undefined;\n\ttry {\n\t\tfilter = compileFilter(input.filter);\n\t} catch {\n\t\treturn errorResult(`Invalid monitor filter regex: ${input.filter}`);\n\t}\n\n\t// Durability needs an absolute directory: a restore runs in a different process whose\n\t// process cwd is unrelated, so the spec must carry the resolved path the spawn used.\n\tconst cwd = resolve(execCtx?.cwd ?? ctx.cwd);\n\tconst { id, runtime } = await spawnCommandSession(ctx, {\n\t\tcommand: input.command,\n\t\tcols: resolveDimension(undefined, ctx.defaultCols || DEFAULT_COLS),\n\t\trows: resolveDimension(undefined, ctx.defaultRows || DEFAULT_ROWS),\n\t\tcwd,\n\t\t...(input.persistent ? {} : { timeoutMs: resolveTimeoutMs(input.timeout_ms) }),\n\t});\n\tctx.onMonitorRearmed?.(id);\n\tconst monitorId = registry.register({\n\t\tid,\n\t\tdescription: input.description,\n\t\truntime,\n\t\tfilter,\n\t\t// Only persistent command watches are restartable-command durable: those carry the fire budget.\n\t\tdurabilityClass: input.persistent === true ? \"restartable-command\" : \"ephemeral\",\n\t\t// Same deadline the manifest writer persists, so the footer warns off the live record too.\n\t\t...(input.persistent === true ? { expiresAt: Date.now() + DURABLE_MONITOR_EXPIRY_MS } : {}),\n\t});\n\tctx.manager.bindMonitorId(monitorId, id);\n\t// The tool call site is the only place the branch inputs (command, persistent, filter)\n\t// live; hand the captured spec to the session's manifest writer for durable recording.\n\thandMonitorSpec(manifestSessionKey(ctx), {\n\t\tmonitorId,\n\t\tspec: {\n\t\t\tkind: \"command\",\n\t\t\tdescription: input.description,\n\t\t\tcommand: input.command,\n\t\t\tfilter: input.filter,\n\t\t\tcwd,\n\t\t\tpersistent: input.persistent === true,\n\t\t},\n\t});\n\treturn textResult(`Monitor started with ID: ${monitorId}`, {\n\t\tdetails: { monitor_id: monitorId, bash_id: id, monitor: true },\n\t});\n}\n\n/** Build the PTY-backed monitor tool. Monitor handles share TerminalManager's bash_N namespace. */\nconst manifestWriters = new Map<string, TerminalManifestWriter>();\n\n/** Bind the session's manifest writer so monitor tool calls can hand it specs captured at the call site. */\nexport function bindTerminalManifestWriter(sessionId: string, writer: TerminalManifestWriter): void {\n\tmanifestWriters.set(sessionId, writer);\n}\n\nexport function unbindTerminalManifestWriter(sessionId: string): void {\n\tmanifestWriters.delete(sessionId);\n}\n\n/** The durability session key for a tool context: the agent session id, when the context carries one. */\nfunction manifestSessionKey(ctx: TerminalToolContext): string | undefined {\n\treturn ctx.getSessionContext?.()?.sessionManager?.getSessionId?.();\n}\n\n/** Hand a spec captured at the monitor tool call site to the session's bound writer, if any. */\nfunction handMonitorSpec(sessionKey: string | undefined, registration: MonitorRegistration): void {\n\tconst writer = sessionKey === undefined ? undefined : manifestWriters.get(sessionKey);\n\tvoid writer?.recordRegister(registration);\n}\n\n/** Persist a durable file watch's baseline checkpoint through the writer's debounced path. */\nfunction handFileCheckpoint(\n\tsessionKey: string | undefined,\n\tmonitorId: string,\n\tregistry: MonitorRegistry,\n\truntimeId: string,\n): void {\n\tconst writer = sessionKey === undefined ? undefined : manifestWriters.get(sessionKey);\n\tconst checkpoint = registry.fileCheckpoint(runtimeId);\n\tif (writer && checkpoint) writer.scheduleCheckpoint(monitorId, checkpoint);\n}\n\n/**\n * Admission control for a durable create: refuse once the session already holds\n * MAX_DURABLE_MONITORS restart-surviving monitors. Checked BEFORE any spawn or registry\n * registration so a refused call leaves no PTY and no manifest entry behind. A context\n * with no bound writer persists nothing, so it has no durable population to cap.\n */\nfunction durableAdmissionError(ctx: TerminalToolContext): TerminalToolResult | undefined {\n\tconst sessionKey = manifestSessionKey(ctx);\n\tconst writer = sessionKey === undefined ? undefined : manifestWriters.get(sessionKey);\n\tif (writer === undefined || writer.durableCount() < MAX_DURABLE_MONITORS) return undefined;\n\treturn errorResult(\n\t\t`Cannot start another persistent monitor: this session already holds ${MAX_DURABLE_MONITORS} durable monitors (the maximum). Stop one with kill_bash first.`,\n\t);\n}\n\nexport function createMonitorTool(ctx: TerminalToolContext) {\n\tlet fallbackRegistry: MonitorRegistry | undefined;\n\tconst getRegistry = (): MonitorRegistry => {\n\t\tconst sessionRegistry = ctx.monitorRegistry;\n\t\tif (sessionRegistry) return sessionRegistry;\n\t\tfallbackRegistry ??= new MonitorRegistry((event) => ctx.onMonitorEvent?.(event));\n\t\treturn fallbackRegistry;\n\t};\n\treturn {\n\t\tname: TERMINAL_MONITOR_TOOL,\n\t\tlabel: \"monitor\",\n\t\tdescription:\n\t\t\t\"Subscribe to a change instead of polling. Pass command XOR path, never both: command watches a PTY session, injecting matching newline-terminated output lines (stderr merged) plus an exit summary; path natively watches one file and fires once, where create (the default) fires only when the file appears after registration, so use event modify for an existing file, and filter is rejected. Returns a bash_id immediately; peek with bash_output, stop with kill_bash.\",\n\t\tpromptSnippet:\n\t\t\t\"Subscribe to a command's output or a file's create/modify event as injected events instead of polling\",\n\t\tpromptGuidelines: [\n\t\t\t\"Waiting on observable state (CI checks, builds, log patterns, deploys, a file landing) means a monitor, never a foreground sleep/poll loop.\",\n\t\t\t'Waiting for one file to appear or change is the path branch: `monitor({ description, path, event? })` beats wrapping `test -f` in a shell poll loop; a file that already exists needs `event: \"modify\"`, since `create` only fires on appearance, and registration needs the parent directory to exist already — when the run creates that directory too, use the `command` branch instead.',\n\t\t\t\"Shape the command for the events you need: one-shot gate = `until <cond>; do sleep 1; done; printf 'READY\\\\n'` with filter ^READY$; stream = `tail -n 0 -F <log> | grep --line-buffered <pat>` with persistent: true, then kill_bash.\",\n\t\t\t\"Sleep loops belong INSIDE the monitor command, never in your turn: about to sleep, re-poll bash_output, or foreground-block on a long command means register a monitor and keep working.\",\n\t\t],\n\t\tparameters: monitorSchema,\n\t\trenderCall: renderMonitorCall,\n\t\tasync execute(\n\t\t\t_toolCallId: string,\n\t\t\tinput: MonitorInput,\n\t\t\t_signal?: AbortSignal,\n\t\t\t_onUpdate?: undefined,\n\t\t\texecCtx?: { cwd?: string },\n\t\t): Promise<TerminalToolResult> {\n\t\t\tconst registry = getRegistry();\n\t\t\tif (input.action === \"rearm\") {\n\t\t\t\tif (input.bash_id === undefined || input.bash_id.length === 0) {\n\t\t\t\t\tconst resumed = registry.resume();\n\t\t\t\t\tif (resumed.length === 0) return textResult(\"No paused monitors to re-arm.\");\n\t\t\t\t\tctx.onMonitorsResumed?.(resumed.map((monitor) => monitor.id));\n\t\t\t\t\tconst total = resumed.reduce((sum, monitor) => sum + monitor.mutedDropped, 0);\n\t\t\t\t\treturn textResult(\n\t\t\t\t\t\ttotal > 0\n\t\t\t\t\t\t\t? `Re-armed ${resumed.length} paused monitor(s) (${total} line(s) dropped while muted).`\n\t\t\t\t\t\t\t: `Re-armed ${resumed.length} paused monitor(s).`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst bashId = resolveTerminalId(ctx.manager, input.bash_id);\n\t\t\t\tconst dropped = registry.mutedDropped(bashId);\n\t\t\t\tconst outcome = registry.rearm(bashId);\n\t\t\t\tif (outcome === \"not_found\") return errorResult(`No active monitor found with id: ${bashId}`);\n\t\t\t\tif (outcome === \"not_paused\") return textResult(`Monitor ${bashId} is not paused; no action taken.`);\n\t\t\t\tctx.onMonitorRearmed?.(bashId);\n\t\t\t\treturn textResult(\n\t\t\t\t\tdropped > 0\n\t\t\t\t\t\t? `Monitor ${bashId} re-armed (${dropped} line(s) dropped while muted).`\n\t\t\t\t\t\t: `Monitor ${bashId} re-armed.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst fileInput = isFileCreateInput(input);\n\t\t\tconst commandInput = isCreateInput(input);\n\t\t\tif (fileInput && commandInput) return errorResult(\"monitor accepts either command or path, not both.\");\n\t\t\t// Admission runs before either create branch touches a PTY or the registry.\n\t\t\tif (input.persistent === true && (fileInput || commandInput)) {\n\t\t\t\tconst refused = durableAdmissionError(ctx);\n\t\t\t\tif (refused) return refused;\n\t\t\t}\n\t\t\tif (fileInput) {\n\t\t\t\tif (input.filter !== undefined) return errorResult(\"Native file monitors do not support filter.\");\n\t\t\t\tif (!ctx.monitorRegistry)\n\t\t\t\t\treturn errorResult(\"Native file monitors require a lifecycle-owned monitor registry.\");\n\t\t\t\ttry {\n\t\t\t\t\tconst approvedParent = (input as Record<string | symbol, unknown>)[APPROVED_MONITOR_PARENT] as\n\t\t\t\t\t\t| string\n\t\t\t\t\t\t| undefined;\n\t\t\t\t\tconst { id, monitorId } = await ctx.monitorRegistry.registerFile({\n\t\t\t\t\t\tdescription: input.description,\n\t\t\t\t\t\tpath: input.path,\n\t\t\t\t\t\tevent: input.event ?? \"create\",\n\t\t\t\t\t\ttimeoutMs: resolveTimeoutMs(input.timeout_ms),\n\t\t\t\t\t\tcwd: execCtx?.cwd ?? ctx.cwd,\n\t\t\t\t\t\t...(approvedParent !== undefined ? { approvedParent } : {}),\n\t\t\t\t\t\t...(input.persistent === true ? { expiresAt: Date.now() + DURABLE_MONITOR_EXPIRY_MS } : {}),\n\t\t\t\t\t});\n\t\t\t\t\tctx.manager.bindMonitorId(monitorId, id);\n\t\t\t\t\t// Same spec capture as the command branch: durability inputs live only here.\n\t\t\t\t\tconst sessionKey = manifestSessionKey(ctx);\n\t\t\t\t\thandMonitorSpec(sessionKey, {\n\t\t\t\t\t\tmonitorId,\n\t\t\t\t\t\tspec: {\n\t\t\t\t\t\t\tkind: \"file\",\n\t\t\t\t\t\t\tdescription: input.description,\n\t\t\t\t\t\t\tpath: input.path,\n\t\t\t\t\t\t\tevent: input.event ?? \"create\",\n\t\t\t\t\t\t\ttimeoutMs: resolveTimeoutMs(input.timeout_ms),\n\t\t\t\t\t\t\tcwd: execCtx?.cwd ?? ctx.cwd,\n\t\t\t\t\t\t\tpersistent: input.persistent === true,\n\t\t\t\t\t\t\t...(approvedParent !== undefined ? { approvedParent } : {}),\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\t\t\t\t\t// A durable watch checkpoints the registry's own identity tuple straight away, so a\n\t\t\t\t\t// restart before the first change still has a baseline (digest included) to compare to.\n\t\t\t\t\tif (input.persistent === true) handFileCheckpoint(sessionKey, monitorId, ctx.monitorRegistry, id);\n\t\t\t\t\treturn textResult(`Monitor started with ID: ${monitorId}`, {\n\t\t\t\t\t\tdetails: { monitor_id: monitorId, bash_id: id, monitor: true },\n\t\t\t\t\t});\n\t\t\t\t} catch (error) {\n\t\t\t\t\treturn errorResult(error instanceof Error ? error.message : String(error));\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!commandInput) return errorResult(\"monitor requires description and command or path to start a watcher.\");\n\t\t\treturn createMonitor(ctx, registry, input, execCtx);\n\t\t},\n\t};\n}\n"]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare const TODO_TOOL_DESCRIPTION = "**Tasks referenced by verbatim content string, NEVER an auto-generated ID \u2014 no \"task-1\"/\"task-N\" exists. Pass the content text in the task field.**\n\nOn each completion the earliest still-open task (in phase order) auto-promotes to in_progress.\nCompleting tasks out of phase order can move this pointer **back** to an earlier phase \u2014 expected; completed tasks are never reverted.\n\n## Operations\n\n| op | Required fields | Effect |\n|---|---|---|\n| init | list: [{phase, items: string[]}] | Initialize full list (replaces existing) |\n| init | items: string[] | Flattened single-phase init |\n| start | task | Mark in progress |\n| done | task or phase | Mark completed |\n| drop | task or phase | Mark abandoned |\n| rm | task or phase (optional) | Remove task or phase; omit both to clear |\n| append | phase?, items: string[] | Append tasks to phase; lazily creates phase |\n| view | \u2014 | Read-only: echo list |\n\nExample: {\"op\":\"init\",\"list\":[{\"phase\":\"Setup\",\"items\":[\"Survey code\",\"Write tests\"]}]}\n\n## Anatomy\n- **Task content**: 5\u201310 words; what, not how. Unique identifier.\n- **Phase name**: short noun phrase (e.g. Foundation, Auth, Verification). Unique identifier. NEVER prefix 1., A), Phase 1:.\n\n## Rules\n- Mark tasks done immediately after finishing, then re-check the list against the newest user message. Complete phases in order.\n- NEVER make a todo call your turn's only tool call \u2014 batch it with the real work: init with the first reads/edits, each done/start with the next action. Solo todo turns waste a round trip.\n- Blocked? append a task to the active phase, or drop.\n- Keep task/phase strings stable once introduced
|
|
2
|
-
export declare const TASK_MANAGEMENT_SECTION = "\n<Task_Management>\n## Todo Management
|
|
1
|
+
export declare const TODO_TOOL_DESCRIPTION = "**Tasks referenced by verbatim content string, NEVER an auto-generated ID \u2014 no \"task-1\"/\"task-N\" exists. Pass the content text in the task field.**\n\nOn each completion the earliest still-open task (in phase order) auto-promotes to in_progress.\nCompleting tasks out of phase order can move this pointer **back** to an earlier phase \u2014 expected; completed tasks are never reverted.\n\n## Operations\n\n| op | Required fields | Effect |\n|---|---|---|\n| init | list: [{phase, items: string[]}] | Initialize full list (replaces existing) |\n| init | items: string[] | Flattened single-phase init |\n| start | task | Mark in progress |\n| done | task or phase | Mark completed |\n| drop | task or phase | Mark abandoned |\n| rm | task or phase (optional) | Remove task or phase; omit both to clear |\n| append | phase?, items: string[] | Append tasks to phase; lazily creates phase |\n| view | \u2014 | Read-only: echo list |\n\nExample: {\"op\":\"init\",\"list\":[{\"phase\":\"Setup\",\"items\":[\"Survey code\",\"Write tests\"]}]}\n\n## Anatomy\n- **Task content**: 5\u201310 words; what, not how. Unique identifier.\n- **Phase name**: short noun phrase (e.g. Foundation, Auth, Verification). Unique identifier. NEVER prefix 1., A), Phase 1:.\n\n## Rules\n- Mark tasks done immediately after finishing, then re-check the list against the newest user message. Complete phases in order.\n- NEVER make a todo call your turn's only tool call \u2014 batch it with the real work: init with the first reads/edits, each done/start with the next action. Solo todo turns waste a round trip.\n- Blocked? append a task to the active phase, or drop.\n- Keep task/phase strings stable once introduced. done/start/drop take the task's EXACT text \u2014 copy it verbatim from the latest todo result; when it is lost, view echoes the list.\n\n## When to create a list\n- Task requires 3+ distinct steps\n- User explicitly requests one\n- User provides a set of tasks\n- New instructions arrive mid-task \u2014 reconcile before acting: keep what they don't conflict with, amend what they contradict, append what they add; replace only on explicit redirect\n\n<critical>\nUser hands you a multi-step plan \u2014 phased todo, numbered/bulleted checklist, or \"N bugs/items/tasks\":\n- You MUST init the list with EVERY item as its own task before working.\n- Enumerate all; NEVER summarize into fewer tasks, sample \"the important ones\", drop items, or track the rest from memory.\n</critical>";
|
|
2
|
+
export declare const TASK_MANAGEMENT_SECTION = "\n<Task_Management>\n## Todo Management\n\nUse the todo tool for multi-step work; its description carries the operations, anatomy, and rules. Mark each item done the moment it finishes and reconcile the list against the newest user message before ending a turn.\n\n## Evidence\n- File edit: inspect the changed files and diagnostics.\n- Build command: require exit code 0.\n- Test run: require passing output, or state the pre-existing failure.\n</Task_Management>\n";
|
|
3
3
|
//# sourceMappingURL=prompt.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/todotools/prompt.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,qBAAqB,
|
|
1
|
+
{"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/todotools/prompt.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,qBAAqB,67EAwCtB,CAAC;AAEb,eAAO,MAAM,uBAAuB,udAWnC,CAAC"}
|
|
@@ -30,8 +30,7 @@ Example: {"op":"init","list":[{"phase":"Setup","items":["Survey code","Write tes
|
|
|
30
30
|
- Mark tasks done immediately after finishing, then re-check the list against the newest user message. Complete phases in order.
|
|
31
31
|
- NEVER make a todo call your turn's only tool call — batch it with the real work: init with the first reads/edits, each done/start with the next action. Solo todo turns waste a round trip.
|
|
32
32
|
- Blocked? append a task to the active phase, or drop.
|
|
33
|
-
- Keep task/phase strings stable once introduced.
|
|
34
|
-
- Lost the exact task text? view echoes the list — NEVER guess from memory. done/start/drop take the task's EXACT text — copy it verbatim from the latest todo result, never re-type from memory.
|
|
33
|
+
- Keep task/phase strings stable once introduced. done/start/drop take the task's EXACT text — copy it verbatim from the latest todo result; when it is lost, view echoes the list.
|
|
35
34
|
|
|
36
35
|
## When to create a list
|
|
37
36
|
- Task requires 3+ distinct steps
|
|
@@ -46,11 +45,9 @@ User hands you a multi-step plan — phased todo, numbered/bulleted checklist, o
|
|
|
46
45
|
</critical>`;
|
|
47
46
|
export const TASK_MANAGEMENT_SECTION = `
|
|
48
47
|
<Task_Management>
|
|
49
|
-
## Todo Management
|
|
48
|
+
## Todo Management
|
|
50
49
|
|
|
51
|
-
Use the todo tool for multi-step work
|
|
52
|
-
|
|
53
|
-
${TODO_TOOL_DESCRIPTION}
|
|
50
|
+
Use the todo tool for multi-step work; its description carries the operations, anatomy, and rules. Mark each item done the moment it finishes and reconcile the list against the newest user message before ending a turn.
|
|
54
51
|
|
|
55
52
|
## Evidence
|
|
56
53
|
- File edit: inspect the changed files and diagnostics.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/todotools/prompt.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,mCAAmC;AACnC,oCAAoC;AACpC,sCAAsC;AAEtC,MAAM,CAAC,MAAM,qBAAqB,GAAG
|
|
1
|
+
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/todotools/prompt.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,mCAAmC;AACnC,oCAAoC;AACpC,sCAAsC;AAEtC,MAAM,CAAC,MAAM,qBAAqB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAwCzB,CAAC;AAEb,MAAM,CAAC,MAAM,uBAAuB,GAAG;;;;;;;;;;;CAWtC,CAAC","sourcesContent":["// Adapted from oh-my-pi's todo prompt (MIT License).\n// Copyright (c) 2025 Mario Zechner\n// Copyright (c) 2025-2026 Can Bölük\n// https://github.com/can1357/oh-my-pi\n\nexport const TODO_TOOL_DESCRIPTION = `**Tasks referenced by verbatim content string, NEVER an auto-generated ID — no \"task-1\"/\"task-N\" exists. Pass the content text in the task field.**\n\nOn each completion the earliest still-open task (in phase order) auto-promotes to in_progress.\nCompleting tasks out of phase order can move this pointer **back** to an earlier phase — expected; completed tasks are never reverted.\n\n## Operations\n\n| op | Required fields | Effect |\n|---|---|---|\n| init | list: [{phase, items: string[]}] | Initialize full list (replaces existing) |\n| init | items: string[] | Flattened single-phase init |\n| start | task | Mark in progress |\n| done | task or phase | Mark completed |\n| drop | task or phase | Mark abandoned |\n| rm | task or phase (optional) | Remove task or phase; omit both to clear |\n| append | phase?, items: string[] | Append tasks to phase; lazily creates phase |\n| view | — | Read-only: echo list |\n\nExample: {\"op\":\"init\",\"list\":[{\"phase\":\"Setup\",\"items\":[\"Survey code\",\"Write tests\"]}]}\n\n## Anatomy\n- **Task content**: 5–10 words; what, not how. Unique identifier.\n- **Phase name**: short noun phrase (e.g. Foundation, Auth, Verification). Unique identifier. NEVER prefix 1., A), Phase 1:.\n\n## Rules\n- Mark tasks done immediately after finishing, then re-check the list against the newest user message. Complete phases in order.\n- NEVER make a todo call your turn's only tool call — batch it with the real work: init with the first reads/edits, each done/start with the next action. Solo todo turns waste a round trip.\n- Blocked? append a task to the active phase, or drop.\n- Keep task/phase strings stable once introduced. done/start/drop take the task's EXACT text — copy it verbatim from the latest todo result; when it is lost, view echoes the list.\n\n## When to create a list\n- Task requires 3+ distinct steps\n- User explicitly requests one\n- User provides a set of tasks\n- New instructions arrive mid-task — reconcile before acting: keep what they don't conflict with, amend what they contradict, append what they add; replace only on explicit redirect\n\n<critical>\nUser hands you a multi-step plan — phased todo, numbered/bulleted checklist, or \"N bugs/items/tasks\":\n- You MUST init the list with EVERY item as its own task before working.\n- Enumerate all; NEVER summarize into fewer tasks, sample \"the important ones\", drop items, or track the rest from memory.\n</critical>`;\n\nexport const TASK_MANAGEMENT_SECTION = `\n<Task_Management>\n## Todo Management\n\nUse the todo tool for multi-step work; its description carries the operations, anatomy, and rules. Mark each item done the moment it finishes and reconcile the list against the newest user message before ending a turn.\n\n## Evidence\n- File edit: inspect the changed files and diagnostics.\n- Build command: require exit code 0.\n- Test run: require passing output, or state the pre-existing failure.\n</Task_Management>\n`;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/tool-search/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAErE,OAAO,EAAwD,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAGvG,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,iBAAiB,GAAG,gBAAgB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/tool-search/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAErE,OAAO,EAAwD,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAGvG,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,iBAAiB,GAAG,gBAAgB,CA+CtF;AAWD,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,EAAE,EAAE,YAAY,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAUlF;AAED,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -41,7 +41,7 @@ export function createToolSearchExtension(service) {
|
|
|
41
41
|
},
|
|
42
42
|
searchToolName: TOOL_SEARCH_TOOL_NAME,
|
|
43
43
|
});
|
|
44
|
-
pi.on("before_provider_request", (event, ctx) => nativeAdapter.applyBeforeRequest(ctx.model
|
|
44
|
+
pi.on("before_provider_request", (event, ctx) => nativeAdapter.applyBeforeRequest(event.model ?? ctx.model, event.payload));
|
|
45
45
|
pi.on("after_provider_response", (event) => nativeAdapter.noteResponseStatus(event.status));
|
|
46
46
|
};
|
|
47
47
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/tool-search/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAA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EAAE,MAAM,cAAc,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC","sourcesContent":["import { bindToProviderScope } from \"@earendil-works/pi-ai/node/provider-scope\";\nimport type { ExtensionAPI, ExtensionFactory } from \"../../types.ts\";\nimport { AnthropicNativeToolSearchAdapter, isMcpNativeToolSearchEnabled } from \"./native-search.ts\";\nimport { getToolSearchService, installScopedToolSearchService, ToolSearchService } from \"./service.ts\";\nimport { createToolSearchTool, TOOL_SEARCH_TOOL_NAME } from \"./tool.ts\";\n\nexport function createToolSearchExtension(service: ToolSearchService): ExtensionFactory {\n\treturn (pi: ExtensionAPI): void => {\n\t\tservice.bindRuntime(pi);\n\n\t\tpi.on(\"session_start\", (_event, ctx) => {\n\t\t\tservice.beginSession();\n\t\t\tservice.maybeRehydrateFromHistory(ctx.sessionManager.getEntries());\n\t\t});\n\t\tpi.on(\"context\", (event) => {\n\t\t\tservice.maybeRehydrateFromHistory(event.messages);\n\t\t});\n\t\tpi.registerLazyToolActivator((toolName) => service.activateTool(toolName));\n\t\tlet toolRegistered = false;\n\t\tservice.bindToolRegistrar(() => {\n\t\t\tif (toolRegistered) return;\n\t\t\ttoolRegistered = true;\n\t\t\tpi.registerTool(createToolSearchTool(service));\n\t\t});\n\n\t\tconst nativeAdapter = new AnthropicNativeToolSearchAdapter({\n\t\t\tenabled: () => {\n\t\t\t\tconst active = new Set(pi.getActiveTools());\n\t\t\t\treturn service\n\t\t\t\t\t.getCatalog()\n\t\t\t\t\t.some(\n\t\t\t\t\t\t(doc) =>\n\t\t\t\t\t\t\t(doc.source === \"extension\" && !active.has(doc.name)) ||\n\t\t\t\t\t\t\t(doc.source === \"mcp\" && isMcpNativeToolSearchEnabled()),\n\t\t\t\t\t);\n\t\t\t},\n\t\t\tgetCatalog: () => service.getCatalog(),\n\t\t\tgetToolDefinition: (name) => {\n\t\t\t\tconst tool = pi.getAllTools().find((candidate) => candidate.name === name);\n\t\t\t\treturn tool === undefined ? undefined : { description: tool.description, parameters: tool.parameters };\n\t\t\t},\n\t\t\tisDeferrable: (name) => {\n\t\t\t\tconst doc = service.getCatalog().find((candidate) => candidate.name === name);\n\t\t\t\tif (doc?.source === \"mcp\") return isMcpNativeToolSearchEnabled();\n\t\t\t\treturn doc?.source === \"extension\" && !pi.getActiveTools().includes(name);\n\t\t\t},\n\t\t\tsearchToolName: TOOL_SEARCH_TOOL_NAME,\n\t\t});\n\t\tpi.on(\"before_provider_request\", (event, ctx) =>\n\t\t\tnativeAdapter.applyBeforeRequest(event.model ?? ctx.model, event.payload),\n\t\t);\n\t\tpi.on(\"after_provider_response\", (event) => nativeAdapter.noteResponseStatus(event.status));\n\t};\n}\n\nfunction hasProviderScope(): boolean {\n\ttry {\n\t\tbindToProviderScope(() => undefined);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nexport default function toolSearchExtension(pi: ExtensionAPI): void | Promise<void> {\n\tconst runtime = {\n\t\tgetAllTools: () => pi.getAllTools(),\n\t\tgetActiveTools: () => pi.getActiveTools(),\n\t\tsetActiveTools: (names: readonly string[]) => pi.setActiveTools([...names]),\n\t};\n\tconst sessionOwned = hasProviderScope();\n\tconst service = sessionOwned ? new ToolSearchService(runtime) : getToolSearchService(runtime);\n\tif (sessionOwned) installScopedToolSearchService(service);\n\treturn createToolSearchExtension(service)(pi);\n}\n\nexport { getToolSearchService, ToolSearchService } from \"./service.ts\";\nexport { createToolSearchTool, TOOL_SEARCH_TOOL_NAME } from \"./tool.ts\";\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ToolSearchDocument } from "./engine/document.ts";
|
|
2
|
+
import { type AnthropicToolSearchTarget } from "./native-support.ts";
|
|
2
3
|
export declare const ANTHROPIC_TOOL_SEARCH_TYPE = "tool_search_tool_bm25_20251119";
|
|
3
4
|
export declare const ANTHROPIC_TOOL_SEARCH_NAME = "tool_search_tool_bm25";
|
|
4
5
|
/** Anthropic caps a request at 10k tools; beyond that native search is invalid. */
|
|
@@ -27,11 +28,15 @@ export interface AnthropicNativeInjectionConfig {
|
|
|
27
28
|
* local search tool, never combine defer_loading with cache_control, keep at
|
|
28
29
|
* least one non-deferred tool, and skip entirely above the 10k tool cap.
|
|
29
30
|
*/
|
|
30
|
-
export declare function addAnthropicNativeToolSearch(
|
|
31
|
-
/**
|
|
31
|
+
export declare function addAnthropicNativeToolSearch(target: AnthropicToolSearchTarget, payload: unknown, config: AnthropicNativeInjectionConfig): unknown;
|
|
32
|
+
/**
|
|
33
|
+
* `tool_reference` blocks emitted inside a tool_result so the API expands the
|
|
34
|
+
* referenced tools. Anthropic names the target through `tool_name`; a block
|
|
35
|
+
* carrying `name` is rejected as a malformed content block.
|
|
36
|
+
*/
|
|
32
37
|
export declare function buildToolReferenceBlocks(names: readonly string[]): {
|
|
33
38
|
type: "tool_reference";
|
|
34
|
-
|
|
39
|
+
tool_name: string;
|
|
35
40
|
}[];
|
|
36
41
|
export interface AnthropicNativeAdapterDeps extends AnthropicNativeInjectionConfig {
|
|
37
42
|
/** Resolved provider/config gate. */
|
|
@@ -43,7 +48,7 @@ export interface AnthropicNativeAdapterDeps extends AnthropicNativeInjectionConf
|
|
|
43
48
|
export declare class AnthropicNativeToolSearchAdapter {
|
|
44
49
|
#private;
|
|
45
50
|
constructor(deps: AnthropicNativeAdapterDeps);
|
|
46
|
-
applyBeforeRequest(
|
|
51
|
+
applyBeforeRequest(target: AnthropicToolSearchTarget, payload: unknown): unknown;
|
|
47
52
|
noteResponseStatus(status: number): void;
|
|
48
53
|
get disabled(): boolean;
|
|
49
54
|
get fallbackReason(): string | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native-search.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/tool-search/native-search.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"native-search.d.ts","sourceRo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AAE,gBAAgB,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,EAAE,CAElH;AAED,MAAM,WAAW,0BAA2B,SAAQ,8BAA8B;IACjF,qCAAqC;IACrC,OAAO,IAAI,OAAO,CAAC;IACnB,gEAAgE;IAChE,UAAU,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CAClC;AAED,mFAAmF;AACnF,qBAAa,gCAAgC;;gBAMhC,IAAI,EAAE,0BAA0B;IAI5C,kBAAkB,CAAC,MAAM,EAAE,yBAAyB,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO;IAQhF,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAQxC,IAAI,QAAQ,IAAI,OAAO,CAEtB;IAED,IAAI,cAAc,IAAI,MAAM,GAAG,IAAI,CAElC;CACD"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
+
import { supportsAnthropicNativeToolSearch } from "./native-support.js";
|
|
2
3
|
// Anthropic Messages supports native BM25 tool search through request payload
|
|
3
4
|
// injection alone. OpenAI native client-mode search remains intentionally out of
|
|
4
5
|
// scope because it requires a provider-layer seam.
|
|
@@ -25,8 +26,8 @@ function isRecord(value) {
|
|
|
25
26
|
* local search tool, never combine defer_loading with cache_control, keep at
|
|
26
27
|
* least one non-deferred tool, and skip entirely above the 10k tool cap.
|
|
27
28
|
*/
|
|
28
|
-
export function addAnthropicNativeToolSearch(
|
|
29
|
-
if (
|
|
29
|
+
export function addAnthropicNativeToolSearch(target, payload, config) {
|
|
30
|
+
if (!supportsAnthropicNativeToolSearch(target) || !isRecord(payload))
|
|
30
31
|
return payload;
|
|
31
32
|
const tools = Array.isArray(payload.tools) ? payload.tools : [];
|
|
32
33
|
const injected = injectInactiveCatalogTools(tools, config);
|
|
@@ -77,9 +78,13 @@ function maybeDefer(tool, config) {
|
|
|
77
78
|
return tool;
|
|
78
79
|
return { ...tool, defer_loading: true };
|
|
79
80
|
}
|
|
80
|
-
/**
|
|
81
|
+
/**
|
|
82
|
+
* `tool_reference` blocks emitted inside a tool_result so the API expands the
|
|
83
|
+
* referenced tools. Anthropic names the target through `tool_name`; a block
|
|
84
|
+
* carrying `name` is rejected as a malformed content block.
|
|
85
|
+
*/
|
|
81
86
|
export function buildToolReferenceBlocks(names) {
|
|
82
|
-
return names.map((name) => ({ type: "tool_reference", name }));
|
|
87
|
+
return names.map((name) => ({ type: "tool_reference", tool_name: name }));
|
|
83
88
|
}
|
|
84
89
|
/** Session-scoped request injector with permanent 400 fallback for the session. */
|
|
85
90
|
export class AnthropicNativeToolSearchAdapter {
|
|
@@ -90,11 +95,11 @@ export class AnthropicNativeToolSearchAdapter {
|
|
|
90
95
|
constructor(deps) {
|
|
91
96
|
this.#deps = deps;
|
|
92
97
|
}
|
|
93
|
-
applyBeforeRequest(
|
|
98
|
+
applyBeforeRequest(target, payload) {
|
|
94
99
|
this.#injectedLastRequest = false;
|
|
95
100
|
if (this.#disabled || !this.#deps.enabled())
|
|
96
101
|
return payload;
|
|
97
|
-
const next = addAnthropicNativeToolSearch(
|
|
102
|
+
const next = addAnthropicNativeToolSearch(target, payload, this.#deps);
|
|
98
103
|
this.#injectedLastRequest = next !== payload;
|
|
99
104
|
return next;
|
|
100
105
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native-search.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/tool-search/native-search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAGrD,8EAA8E;AAC9E,iFAAiF;AACjF,mDAAmD;AAEnD,MAAM,CAAC,MAAM,0BAA0B,GAAG,gCAAgC,CAAC;AAC3E,MAAM,CAAC,MAAM,0BAA0B,GAAG,uBAAuB,CAAC;AAClE,mFAAmF;AACnF,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,CAAC;AAIzC,MAAM,6BAA6B,GAAG,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C,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,kBAAkB,CAAC,GAAuB,EAAE,OAAgB;QAC3D,IAAI,CAAC,oBAAoB,GAAG,KAAK,CAAC;QAClC,IAAI,IAAI,CAAC,SAAS,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE;YAAE,OAAO,OAAO,CAAC;QAC5D,MAAM,IAAI,GAAG,4BAA4B,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QACpE,IAAI,CAAC,oBAAoB,GAAG,IAAI,KAAK,OAAO,CAAC;QAC7C,OAAO,IAAI,CAAC;IACb,CAAC;IAED,kBAAkB,CAAC,MAAc;QAChC,IAAI,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,oBAAoB,IAAI,IAAI,CAAC,SAAS;YAAE,OAAO;QAC3E,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,IAAI,CAAC,eAAe;YACnB,iHAAiH,CAAC;QACnH,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IAC/C,CAAC;IAED,IAAI,QAAQ;QACX,OAAO,IAAI,CAAC,SAAS,CAAC;IACvB,CAAC;IAED,IAAI,cAAc;QACjB,OAAO,IAAI,CAAC,eAAe,CAAC;IAC7B,CAAC;CACD","sourcesContent":["import { AsyncLocalStorage } from \"node:async_hooks\";\nimport type { ToolSearchDocument } from \"./engine/document.ts\";\n\n// Anthropic Messages supports native BM25 tool search through request payload\n// injection alone. OpenAI native client-mode search remains intentionally out of\n// scope because it requires a provider-layer seam.\n\nexport const ANTHROPIC_TOOL_SEARCH_TYPE = \"tool_search_tool_bm25_20251119\";\nexport const ANTHROPIC_TOOL_SEARCH_NAME = \"tool_search_tool_bm25\";\n/** Anthropic caps a request at 10k tools; beyond that native search is invalid. */\nexport const ANTHROPIC_MAX_TOOLS = 10000;\n\ntype McpNativeToolSearchGate = () => boolean;\n\nconst scopedMcpNativeToolSearchGate = new AsyncLocalStorage<McpNativeToolSearchGate>();\nlet mcpNativeToolSearchGate: McpNativeToolSearchGate = () => false;\n\n/** Bind the MCP-owned user setting without moving MCP configuration into the shared builtin. */\nexport function installMcpNativeToolSearchGate(gate: McpNativeToolSearchGate): void {\n\tmcpNativeToolSearchGate = gate;\n\tscopedMcpNativeToolSearchGate.enterWith(gate);\n}\n\nexport function isMcpNativeToolSearchEnabled(): boolean {\n\treturn (scopedMcpNativeToolSearchGate.getStore() ?? mcpNativeToolSearchGate)();\n}\n\nexport interface NativeToolDefinition {\n\treadonly description?: string;\n\treadonly parameters?: unknown;\n}\n\nexport interface AnthropicNativeInjectionConfig {\n\t/** Never defer this tool (our custom tool_search), and it is non-deferrable. */\n\treadonly searchToolName?: string;\n\t/** True only for catalog tools eligible for native deferral in this request. */\n\treadonly isDeferrable: (toolName: string) => boolean;\n\t/** Current searchable catalog. Omit when only transforming resident tools. */\n\treadonly getCatalog?: () => readonly ToolSearchDocument[];\n\t/** Resolve the winning registered definition used to inject inactive schemas. */\n\treadonly getToolDefinition?: (toolName: string) => NativeToolDefinition | undefined;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null;\n}\n\n/**\n * Pure payload transform. Injects eligible inactive catalog schemas, adds exactly\n * one native search tool, and enforces Anthropic's HARD RULES: never defer the\n * local search tool, never combine defer_loading with cache_control, keep at\n * least one non-deferred tool, and skip entirely above the 10k tool cap.\n */\nexport function addAnthropicNativeToolSearch(\n\tapi: string | undefined,\n\tpayload: unknown,\n\tconfig: AnthropicNativeInjectionConfig,\n): unknown {\n\tif (api !== \"anthropic-messages\" || !isRecord(payload)) return payload;\n\tconst tools = Array.isArray(payload.tools) ? payload.tools : [];\n\tconst injected = injectInactiveCatalogTools(tools, config);\n\tif (injected.length > ANTHROPIC_MAX_TOOLS) return payload;\n\tconst deferred = injected.map((tool) => maybeDefer(tool, config));\n\tconst hasSearchTool = deferred.some((tool) => isRecord(tool) && tool.type === ANTHROPIC_TOOL_SEARCH_TYPE);\n\tconst nextTools = hasSearchTool\n\t\t? deferred\n\t\t: [...deferred, { type: ANTHROPIC_TOOL_SEARCH_TYPE, name: ANTHROPIC_TOOL_SEARCH_NAME }];\n\tif (nextTools.length > ANTHROPIC_MAX_TOOLS) return payload;\n\treturn { ...payload, tools: nextTools };\n}\n\nfunction injectInactiveCatalogTools(tools: readonly unknown[], config: AnthropicNativeInjectionConfig): unknown[] {\n\tconst catalog = config.getCatalog?.() ?? [];\n\tconst residentNames = new Set(\n\t\ttools.flatMap((tool) => (isRecord(tool) && typeof tool.name === \"string\" ? [tool.name] : [])),\n\t);\n\tconst injected: unknown[] = [...tools];\n\tfor (const doc of catalog) {\n\t\tif (doc.name === config.searchToolName || residentNames.has(doc.name) || !config.isDeferrable(doc.name)) continue;\n\t\tconst definition = config.getToolDefinition?.(doc.name);\n\t\tif (definition?.parameters === undefined) continue;\n\t\tinjected.push({\n\t\t\tname: doc.name,\n\t\t\tdescription: definition.description ?? doc.description ?? doc.label,\n\t\t\tinput_schema: definition.parameters,\n\t\t\tdefer_loading: true,\n\t\t});\n\t\tresidentNames.add(doc.name);\n\t}\n\treturn injected;\n}\n\nfunction maybeDefer(tool: unknown, config: AnthropicNativeInjectionConfig): unknown {\n\tif (!isRecord(tool)) return tool;\n\tconst name = typeof tool.name === \"string\" ? tool.name : undefined;\n\tif (name === undefined) return tool;\n\tif (name === config.searchToolName) return tool;\n\tif (!config.isDeferrable(name)) return tool;\n\tif (\"cache_control\" in tool) return tool;\n\tif (tool.defer_loading === true) return tool;\n\treturn { ...tool, defer_loading: true };\n}\n\n/** `tool_reference` blocks emitted inside a tool_result so the API expands the referenced tools. */\nexport function buildToolReferenceBlocks(names: readonly string[]): { type: \"tool_reference\"; name: string }[] {\n\treturn names.map((name) => ({ type: \"tool_reference\", name }));\n}\n\nexport interface AnthropicNativeAdapterDeps extends AnthropicNativeInjectionConfig {\n\t/** Resolved provider/config gate. */\n\tenabled(): boolean;\n\t/** Invoked once when a 400 forces the local-search fallback. */\n\tonFallback?(reason: string): void;\n}\n\n/** Session-scoped request injector with permanent 400 fallback for the session. */\nexport class AnthropicNativeToolSearchAdapter {\n\t#disabled = false;\n\t#injectedLastRequest = false;\n\t#fallbackReason: string | null = null;\n\treadonly #deps: AnthropicNativeAdapterDeps;\n\n\tconstructor(deps: AnthropicNativeAdapterDeps) {\n\t\tthis.#deps = deps;\n\t}\n\n\tapplyBeforeRequest(api: string | undefined, payload: unknown): unknown {\n\t\tthis.#injectedLastRequest = false;\n\t\tif (this.#disabled || !this.#deps.enabled()) return payload;\n\t\tconst next = addAnthropicNativeToolSearch(api, payload, this.#deps);\n\t\tthis.#injectedLastRequest = next !== payload;\n\t\treturn next;\n\t}\n\n\tnoteResponseStatus(status: number): void {\n\t\tif (status !== 400 || !this.#injectedLastRequest || this.#disabled) return;\n\t\tthis.#disabled = true;\n\t\tthis.#fallbackReason =\n\t\t\t\"Anthropic returned 400 for native tool-search; disabled it and fell back to local tool_search for this session.\";\n\t\tthis.#deps.onFallback?.(this.#fallbackReason);\n\t}\n\n\tget disabled(): boolean {\n\t\treturn this.#disabled;\n\t}\n\n\tget fallbackReason(): string | null {\n\t\treturn this.#fallbackReason;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"native-search.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/tool-search/native-search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,OAAO,EAAkC,iCAAiC,EAAE,MAAM,qBAAqB,CAAC;AAExG,8EAA8E;AAC9E,iFAAiF;AACjF,mDAAmD;AAEnD,MAAM,CAAC,MAAM,0BAA0B,GAAG,gCAAgC,CAAC;AAC3E,MAAM,CAAC,MAAM,0BAA0B,GAAG,uBAAuB,CAAC;AAClE,mFAAmF;AACnF,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,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,IAAI,CAAC;IAC7B,KAAK,CAA6B;IAE3C,YAAY,IAAgC;QAC3C,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,kBAAkB,CAAC,MAAiC,EAAE,OAAgB;QACrE,IAAI,CAAC,oBAAoB,GAAG,KAAK,CAAC;QAClC,IAAI,IAAI,CAAC,SAAS,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE;YAAE,OAAO,OAAO,CAAC;QAC5D,MAAM,IAAI,GAAG,4BAA4B,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QACvE,IAAI,CAAC,oBAAoB,GAAG,IAAI,KAAK,OAAO,CAAC;QAC7C,OAAO,IAAI,CAAC;IACb,CAAC;IAED,kBAAkB,CAAC,MAAc;QAChC,IAAI,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,oBAAoB,IAAI,IAAI,CAAC,SAAS;YAAE,OAAO;QAC3E,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,IAAI,CAAC,eAAe;YACnB,iHAAiH,CAAC;QACnH,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IAC/C,CAAC;IAED,IAAI,QAAQ;QACX,OAAO,IAAI,CAAC,SAAS,CAAC;IACvB,CAAC;IAED,IAAI,cAAc;QACjB,OAAO,IAAI,CAAC,eAAe,CAAC;IAC7B,CAAC;CACD","sourcesContent":["import { AsyncLocalStorage } from \"node:async_hooks\";\nimport type { ToolSearchDocument } from \"./engine/document.ts\";\nimport { type AnthropicToolSearchTarget, supportsAnthropicNativeToolSearch } from \"./native-support.ts\";\n\n// Anthropic Messages supports native BM25 tool search through request payload\n// injection alone. OpenAI native client-mode search remains intentionally out of\n// scope because it requires a provider-layer seam.\n\nexport const ANTHROPIC_TOOL_SEARCH_TYPE = \"tool_search_tool_bm25_20251119\";\nexport const ANTHROPIC_TOOL_SEARCH_NAME = \"tool_search_tool_bm25\";\n/** Anthropic caps a request at 10k tools; beyond that native search is invalid. */\nexport const ANTHROPIC_MAX_TOOLS = 10000;\n\ntype McpNativeToolSearchGate = () => boolean;\n\nconst scopedMcpNativeToolSearchGate = new AsyncLocalStorage<McpNativeToolSearchGate>();\nlet mcpNativeToolSearchGate: McpNativeToolSearchGate = () => false;\n\n/** Bind the MCP-owned user setting without moving MCP configuration into the shared builtin. */\nexport function installMcpNativeToolSearchGate(gate: McpNativeToolSearchGate): void {\n\tmcpNativeToolSearchGate = gate;\n\tscopedMcpNativeToolSearchGate.enterWith(gate);\n}\n\nexport function isMcpNativeToolSearchEnabled(): boolean {\n\treturn (scopedMcpNativeToolSearchGate.getStore() ?? mcpNativeToolSearchGate)();\n}\n\nexport interface NativeToolDefinition {\n\treadonly description?: string;\n\treadonly parameters?: unknown;\n}\n\nexport interface AnthropicNativeInjectionConfig {\n\t/** Never defer this tool (our custom tool_search), and it is non-deferrable. */\n\treadonly searchToolName?: string;\n\t/** True only for catalog tools eligible for native deferral in this request. */\n\treadonly isDeferrable: (toolName: string) => boolean;\n\t/** Current searchable catalog. Omit when only transforming resident tools. */\n\treadonly getCatalog?: () => readonly ToolSearchDocument[];\n\t/** Resolve the winning registered definition used to inject inactive schemas. */\n\treadonly getToolDefinition?: (toolName: string) => NativeToolDefinition | undefined;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null;\n}\n\n/**\n * Pure payload transform. Injects eligible inactive catalog schemas, adds exactly\n * one native search tool, and enforces Anthropic's HARD RULES: never defer the\n * local search tool, never combine defer_loading with cache_control, keep at\n * least one non-deferred tool, and skip entirely above the 10k tool cap.\n */\nexport function addAnthropicNativeToolSearch(\n\ttarget: AnthropicToolSearchTarget,\n\tpayload: unknown,\n\tconfig: AnthropicNativeInjectionConfig,\n): unknown {\n\tif (!supportsAnthropicNativeToolSearch(target) || !isRecord(payload)) return payload;\n\tconst tools = Array.isArray(payload.tools) ? payload.tools : [];\n\tconst injected = injectInactiveCatalogTools(tools, config);\n\tif (injected.length > ANTHROPIC_MAX_TOOLS) return payload;\n\tconst deferred = injected.map((tool) => maybeDefer(tool, config));\n\tconst hasSearchTool = deferred.some((tool) => isRecord(tool) && tool.type === ANTHROPIC_TOOL_SEARCH_TYPE);\n\tconst nextTools = hasSearchTool\n\t\t? deferred\n\t\t: [...deferred, { type: ANTHROPIC_TOOL_SEARCH_TYPE, name: ANTHROPIC_TOOL_SEARCH_NAME }];\n\tif (nextTools.length > ANTHROPIC_MAX_TOOLS) return payload;\n\treturn { ...payload, tools: nextTools };\n}\n\nfunction injectInactiveCatalogTools(tools: readonly unknown[], config: AnthropicNativeInjectionConfig): unknown[] {\n\tconst catalog = config.getCatalog?.() ?? [];\n\tconst residentNames = new Set(\n\t\ttools.flatMap((tool) => (isRecord(tool) && typeof tool.name === \"string\" ? [tool.name] : [])),\n\t);\n\tconst injected: unknown[] = [...tools];\n\tfor (const doc of catalog) {\n\t\tif (doc.name === config.searchToolName || residentNames.has(doc.name) || !config.isDeferrable(doc.name)) continue;\n\t\tconst definition = config.getToolDefinition?.(doc.name);\n\t\tif (definition?.parameters === undefined) continue;\n\t\tinjected.push({\n\t\t\tname: doc.name,\n\t\t\tdescription: definition.description ?? doc.description ?? doc.label,\n\t\t\tinput_schema: definition.parameters,\n\t\t\tdefer_loading: true,\n\t\t});\n\t\tresidentNames.add(doc.name);\n\t}\n\treturn injected;\n}\n\nfunction maybeDefer(tool: unknown, config: AnthropicNativeInjectionConfig): unknown {\n\tif (!isRecord(tool)) return tool;\n\tconst name = typeof tool.name === \"string\" ? tool.name : undefined;\n\tif (name === undefined) return tool;\n\tif (name === config.searchToolName) return tool;\n\tif (!config.isDeferrable(name)) return tool;\n\tif (\"cache_control\" in tool) return tool;\n\tif (tool.defer_loading === true) return tool;\n\treturn { ...tool, defer_loading: true };\n}\n\n/**\n * `tool_reference` blocks emitted inside a tool_result so the API expands the\n * referenced tools. Anthropic names the target through `tool_name`; a block\n * carrying `name` is rejected as a malformed content block.\n */\nexport function buildToolReferenceBlocks(names: readonly string[]): { type: \"tool_reference\"; tool_name: string }[] {\n\treturn names.map((name) => ({ type: \"tool_reference\", tool_name: name }));\n}\n\nexport interface AnthropicNativeAdapterDeps extends AnthropicNativeInjectionConfig {\n\t/** Resolved provider/config gate. */\n\tenabled(): boolean;\n\t/** Invoked once when a 400 forces the local-search fallback. */\n\tonFallback?(reason: string): void;\n}\n\n/** Session-scoped request injector with permanent 400 fallback for the session. */\nexport class AnthropicNativeToolSearchAdapter {\n\t#disabled = false;\n\t#injectedLastRequest = false;\n\t#fallbackReason: string | null = null;\n\treadonly #deps: AnthropicNativeAdapterDeps;\n\n\tconstructor(deps: AnthropicNativeAdapterDeps) {\n\t\tthis.#deps = deps;\n\t}\n\n\tapplyBeforeRequest(target: AnthropicToolSearchTarget, payload: unknown): unknown {\n\t\tthis.#injectedLastRequest = false;\n\t\tif (this.#disabled || !this.#deps.enabled()) return payload;\n\t\tconst next = addAnthropicNativeToolSearch(target, payload, this.#deps);\n\t\tthis.#injectedLastRequest = next !== payload;\n\t\treturn next;\n\t}\n\n\tnoteResponseStatus(status: number): void {\n\t\tif (status !== 400 || !this.#injectedLastRequest || this.#disabled) return;\n\t\tthis.#disabled = true;\n\t\tthis.#fallbackReason =\n\t\t\t\"Anthropic returned 400 for native tool-search; disabled it and fell back to local tool_search for this session.\";\n\t\tthis.#deps.onFallback?.(this.#fallbackReason);\n\t}\n\n\tget disabled(): boolean {\n\t\treturn this.#disabled;\n\t}\n\n\tget fallbackReason(): string | null {\n\t\treturn this.#fallbackReason;\n\t}\n}\n"]}
|