@code-yeongyu/senpi 2026.9.4 → 2026.9.5
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 +116 -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 +86 -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 +16 -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/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/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 +9 -5
- 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 +20 -11
- 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.map +1 -1
- package/dist/core/messages.js +8 -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 +1 -1
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +10 -3
- 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 +83 -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 +45 -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 +28 -94
- 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/harness/compaction/compaction.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/compaction.js +16 -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/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 +6 -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 +1 -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.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/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 +14 -1
- 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/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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/imagegen/auth.ts"],"names":[],"mappings":"AAgDA,MAAM,eAAe,GAAG,2BAA2B,CAAC;AACpD,MAAM,YAAY,GACjB,mNAAmN,CAAC;AAErN,SAAS,QAAQ,CAAC,KAAyB;IAC1C,MAAM,OAAO,GAAG,KAAK,EAAE,IAAI,EAAE,CAAC;IAC9B,OAAO,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;AACtC,CAAC;AAED,SAAS,eAAe,CAAC,OAAkD;IAC1E,IAAI,CAAC,OAAO;QAAE,OAAO,SAAS,CAAC;IAC/B,MAAM,QAAQ,GAA2B,EAAE,CAAC;IAC5C,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAA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":["export interface ImageGenAuthModel {\n\tprovider: string;\n\tid: string;\n\tbaseUrl: string;\n\tapi?: string;\n}\n\nexport type ImageGenRegistryAuthResult =\n\t| { ok: true; apiKey?: string; headers?: Record<string, string | null> }\n\t| { ok: false; error: string };\n\nexport interface ImageGenProviderAuthResult {\n\tauth: {\n\t\tapiKey?: string;\n\t\theaders?: Record<string, string | null>;\n\t};\n}\n\nexport interface ImageGenAuthRegistry<TModel extends ImageGenAuthModel = ImageGenAuthModel> {\n\tauthStorage: {\n\t\tget(provider: string): unknown;\n\t};\n\tgetAll(): TModel[];\n\tgetApiKeyAndHeaders(model: TModel): Promise<ImageGenRegistryAuthResult>;\n\tgetProviderAuth(provider: string): Promise<ImageGenProviderAuthResult | undefined>;\n}\n\nexport interface ResolveImageGenAuthDeps<TModel extends ImageGenAuthModel = ImageGenAuthModel> {\n\tmodelRegistry: ImageGenAuthRegistry<TModel>;\n\tenv?: Readonly<Record<string, string | undefined>>;\n}\n\nexport type ImageGenAuthResolution =\n\t| {\n\t\t\tkind: \"native-openai\" | \"gateway\";\n\t\t\tapiKey: string | undefined;\n\t\t\tbaseUrl: string;\n\t\t\theaders?: Record<string, string>;\n\t\t\tprovenance: \"store\" | \"env\" | \"provider-config\";\n\t\t\tproviderId?: string;\n\t }\n\t| { kind: \"none\"; reason: string };\n\ninterface CredentialParts {\n\tapiKey: string | undefined;\n\theaders?: Record<string, string>;\n}\n\nconst OPENAI_BASE_URL = \"https://api.openai.com/v1\";\nconst SETUP_REASON =\n\t'Image generation is not configured. Store an OpenAI API key for provider \"openai\", configure an OpenAI-compatible gateway in models.json and optionally pin it with PI_IMAGE_GEN_PROVIDER, or set OPENAI_API_KEY.';\n\nfunction nonEmpty(value: string | undefined): string | undefined {\n\tconst trimmed = value?.trim();\n\treturn trimmed ? trimmed : undefined;\n}\n\nfunction resolvedHeaders(headers: Record<string, string | null> | undefined): Record<string, string> | undefined {\n\tif (!headers) return undefined;\n\tconst resolved: Record<string, string> = {};\n\tfor (const [name, value] of Object.entries(headers)) {\n\t\tif (typeof value === \"string\" && value.trim().length > 0) resolved[name] = value;\n\t}\n\treturn Object.keys(resolved).length > 0 ? resolved : undefined;\n}\n\nfunction credentialParts(\n\tauth: { apiKey?: string; headers?: Record<string, string | null> } | undefined,\n): CredentialParts | undefined {\n\tconst apiKey = nonEmpty(auth?.apiKey);\n\tif (!apiKey) return undefined;\n\tconst headers = resolvedHeaders(auth?.headers);\n\treturn { apiKey, ...(headers ? { headers } : {}) };\n}\n\nfunction isStoredApiKey(value: unknown): boolean {\n\treturn typeof value === \"object\" && value !== null && \"type\" in value && value.type === \"api_key\";\n}\n\nfunction isGatewayApi(api: string | undefined): boolean {\n\treturn api === \"openai-completions\" || api === \"openai-responses\";\n}\n\nfunction compareText(left: string, right: string): number {\n\tif (left < right) return -1;\n\tif (left > right) return 1;\n\treturn 0;\n}\n\nfunction compareProviderIds(left: string, right: string): number {\n\tconst leftMatches = /openai/i.test(left);\n\tconst rightMatches = /openai/i.test(right);\n\tif (leftMatches !== rightMatches) return leftMatches ? -1 : 1;\n\treturn compareText(left, right);\n}\n\nfunction groupGatewayModels<TModel extends ImageGenAuthModel>(models: readonly TModel[]): Map<string, TModel> {\n\tconst groups = new Map<string, TModel>();\n\tconst ordered = [...models].sort(\n\t\t(left, right) => compareText(left.provider, right.provider) || compareText(left.id, right.id),\n\t);\n\tfor (const model of ordered) {\n\t\tif (model.provider === \"openai\" || !isGatewayApi(model.api) || !nonEmpty(model.baseUrl)) continue;\n\t\tif (!groups.has(model.provider)) groups.set(model.provider, model);\n\t}\n\treturn groups;\n}\n\nasync function resolveStoredOpenAi<TModel extends ImageGenAuthModel>(\n\tregistry: ImageGenAuthRegistry<TModel>,\n): Promise<ImageGenAuthResolution | undefined> {\n\tif (!isStoredApiKey(registry.authStorage.get(\"openai\"))) return undefined;\n\tlet resolved: ImageGenProviderAuthResult | undefined;\n\ttry {\n\t\tresolved = await registry.getProviderAuth(\"openai\");\n\t} catch {\n\t\treturn undefined;\n\t}\n\tconst credentials = credentialParts(resolved?.auth);\n\tif (!credentials) return undefined;\n\treturn {\n\t\tkind: \"native-openai\",\n\t\t...credentials,\n\t\tbaseUrl: OPENAI_BASE_URL,\n\t\tprovenance: \"store\",\n\t\tproviderId: \"openai\",\n\t};\n}\n\nasync function resolveGateway<TModel extends ImageGenAuthModel>(\n\tproviderId: string,\n\tmodel: TModel,\n\tregistry: ImageGenAuthRegistry<TModel>,\n): Promise<ImageGenAuthResolution | undefined> {\n\tconst baseUrl = nonEmpty(model.baseUrl);\n\tif (!baseUrl) return undefined;\n\tlet resolved: ImageGenRegistryAuthResult;\n\ttry {\n\t\tresolved = await registry.getApiKeyAndHeaders(model);\n\t} catch {\n\t\treturn undefined;\n\t}\n\tif (!resolved.ok) return undefined;\n\tconst credentials = credentialParts(resolved);\n\tif (!credentials) return undefined;\n\treturn {\n\t\tkind: \"gateway\",\n\t\t...credentials,\n\t\tbaseUrl,\n\t\tprovenance: \"provider-config\",\n\t\tproviderId,\n\t};\n}\n\nexport async function resolveImageGenAuth<TModel extends ImageGenAuthModel>(\n\tdeps: ResolveImageGenAuthDeps<TModel>,\n): Promise<ImageGenAuthResolution> {\n\tconst native = await resolveStoredOpenAi(deps.modelRegistry);\n\tif (native) return native;\n\n\tconst groups = groupGatewayModels(deps.modelRegistry.getAll());\n\tconst env = deps.env ?? process.env;\n\tconst pinnedProvider = nonEmpty(env.PI_IMAGE_GEN_PROVIDER);\n\tif (pinnedProvider) {\n\t\tconst pinnedModel = groups.get(pinnedProvider);\n\t\tif (pinnedModel) {\n\t\t\tconst pinned = await resolveGateway(pinnedProvider, pinnedModel, deps.modelRegistry);\n\t\t\tif (pinned) return pinned;\n\t\t}\n\t}\n\n\tconst providerIds = [...groups.keys()]\n\t\t.filter((providerId) => providerId !== pinnedProvider)\n\t\t.sort(compareProviderIds);\n\tfor (const providerId of providerIds) {\n\t\tconst model = groups.get(providerId);\n\t\tif (!model) continue;\n\t\tconst gateway = await resolveGateway(providerId, model, deps.modelRegistry);\n\t\tif (gateway) return gateway;\n\t}\n\n\tconst envApiKey = nonEmpty(env.OPENAI_API_KEY);\n\tif (envApiKey) {\n\t\treturn {\n\t\t\tkind: \"native-openai\",\n\t\t\tapiKey: envApiKey,\n\t\t\tbaseUrl: OPENAI_BASE_URL,\n\t\t\tprovenance: \"env\",\n\t\t};\n\t}\n\n\treturn { kind: \"none\", reason: SETUP_REASON };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/imagegen/auth.ts"],"names":[],"mappings":"AAgDA,MAAM,eAAe,GAAG,2BAA2B,CAAC;AACpD,MAAM,YAAY,GACjB,mNAAmN,CAAC;AAErN,SAAS,QAAQ,CAAC,KAAyB;IAC1C,MAAM,OAAO,GAAG,KAAK,EAAE,IAAI,EAAE,CAAC;IAC9B,OAAO,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;AACtC,CAAC;AAED,SAAS,eAAe,CAAC,OAAkD;IAC1E,IAAI,CAAC,OAAO;QAAE,OAAO,SAAS,CAAC;IAC/B,MAAM,QAAQ,GAA2B,EAAE,CAAC;IAC5C,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACrD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC;YAAE,QAAQ,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;IAClF,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;AAChE,CAAC;AAED;;;;GAIG;AACH,SAAS,gBAAgB,CAAC,MAAc;IACvC,OAAO,0BAA0B,CAAC,IAAI,CAAC,MAAM,CAAC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AI,WAAW,EAAE,CAAC;YACjB,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,cAAc,EAAE,WAAW,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;YACrF,IAAI,MAAM;gBAAE,OAAO,MAAM,CAAC;QAC3B,CAAC;IACF,CAAC;IAED,MAAM,WAAW,GAAG,CAAC,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC;SACpC,MAAM,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,KAAK,cAAc,CAAC;SACrD,IAAI,CAAC,kBAAkB,CAAC,CAAC;IAC3B,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;QACtC,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QACrC,IAAI,CAAC,KAAK;YAAE,SAAS;QACrB,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,UAAU,EAAE,KAAK,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;QAC5E,IAAI,OAAO;YAAE,OAAO,OAAO,CAAC;IAC7B,CAAC;IAED,MAAM,SAAS,GAAG,QAAQ,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IAC/C,IAAI,SAAS,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,EAAE,CAAC;QAC/C,OAAO;YACN,IAAI,EAAE,eAAe;YACrB,MAAM,EAAE,SAAS;YACjB,OAAO,EAAE,eAAe;YACxB,UAAU,EAAE,KAAK;SACjB,CAAC;IACH,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC;AAC/C,CAAC","sourcesContent":["export interface ImageGenAuthModel {\n\tprovider: string;\n\tid: string;\n\tbaseUrl: string;\n\tapi?: string;\n}\n\nexport type ImageGenRegistryAuthResult =\n\t| { ok: true; apiKey?: string; headers?: Record<string, string | null> }\n\t| { ok: false; error: string };\n\nexport interface ImageGenProviderAuthResult {\n\tauth: {\n\t\tapiKey?: string;\n\t\theaders?: Record<string, string | null>;\n\t};\n}\n\nexport interface ImageGenAuthRegistry<TModel extends ImageGenAuthModel = ImageGenAuthModel> {\n\tauthStorage: {\n\t\tget(provider: string): unknown;\n\t};\n\tgetAll(): TModel[];\n\tgetApiKeyAndHeaders(model: TModel): Promise<ImageGenRegistryAuthResult>;\n\tgetProviderAuth(provider: string): Promise<ImageGenProviderAuthResult | undefined>;\n}\n\nexport interface ResolveImageGenAuthDeps<TModel extends ImageGenAuthModel = ImageGenAuthModel> {\n\tmodelRegistry: ImageGenAuthRegistry<TModel>;\n\tenv?: Readonly<Record<string, string | undefined>>;\n}\n\nexport type ImageGenAuthResolution =\n\t| {\n\t\t\tkind: \"native-openai\" | \"gateway\";\n\t\t\tapiKey: string | undefined;\n\t\t\tbaseUrl: string;\n\t\t\theaders?: Record<string, string>;\n\t\t\tprovenance: \"store\" | \"env\" | \"provider-config\";\n\t\t\tproviderId?: string;\n\t }\n\t| { kind: \"none\"; reason: string };\n\ninterface CredentialParts {\n\tapiKey: string | undefined;\n\theaders?: Record<string, string>;\n}\n\nconst OPENAI_BASE_URL = \"https://api.openai.com/v1\";\nconst SETUP_REASON =\n\t'Image generation is not configured. Store an OpenAI API key for provider \"openai\", configure an OpenAI-compatible gateway in models.json and optionally pin it with PI_IMAGE_GEN_PROVIDER, or set OPENAI_API_KEY.';\n\nfunction nonEmpty(value: string | undefined): string | undefined {\n\tconst trimmed = value?.trim();\n\treturn trimmed ? trimmed : undefined;\n}\n\nfunction resolvedHeaders(headers: Record<string, string | null> | undefined): Record<string, string> | undefined {\n\tif (!headers) return undefined;\n\tconst resolved: Record<string, string> = {};\n\tfor (const [name, value] of Object.entries(headers)) {\n\t\tif (typeof value === \"string\" && value.trim().length > 0) resolved[name] = value;\n\t}\n\treturn Object.keys(resolved).length > 0 ? resolved : undefined;\n}\n\n/**\n * Seeded placeholder keys (`SK-SENTINEL-DO-NOT-LOG-*`) are not credentials. Left unfiltered, such a\n * value satisfies the stored-openai branch, pins `api.openai.com`, and every request 401s with\n * `Incorrect API key provided: SK-SENTI***OG-2` while a working gateway sits unused.\n */\nfunction isPlaceholderKey(apiKey: string): boolean {\n\treturn /^SK-SENTINEL-DO-NOT-LOG/i.test(apiKey);\n}\n\nfunction credentialParts(\n\tauth: { apiKey?: string; headers?: Record<string, string | null> } | undefined,\n): CredentialParts | undefined {\n\tconst apiKey = nonEmpty(auth?.apiKey);\n\tif (!apiKey || isPlaceholderKey(apiKey)) return undefined;\n\tconst headers = resolvedHeaders(auth?.headers);\n\treturn { apiKey, ...(headers ? { headers } : {}) };\n}\n\nfunction isStoredApiKey(value: unknown): boolean {\n\treturn typeof value === \"object\" && value !== null && \"type\" in value && value.type === \"api_key\";\n}\n\nfunction isGatewayApi(api: string | undefined): boolean {\n\treturn api === \"openai-completions\" || api === \"openai-responses\";\n}\n\nfunction compareText(left: string, right: string): number {\n\tif (left < right) return -1;\n\tif (left > right) return 1;\n\treturn 0;\n}\n\nfunction compareProviderIds(left: string, right: string): number {\n\tconst leftMatches = /openai/i.test(left);\n\tconst rightMatches = /openai/i.test(right);\n\tif (leftMatches !== rightMatches) return leftMatches ? -1 : 1;\n\treturn compareText(left, right);\n}\n\nfunction groupGatewayModels<TModel extends ImageGenAuthModel>(models: readonly TModel[]): Map<string, TModel> {\n\tconst groups = new Map<string, TModel>();\n\tconst ordered = [...models].sort(\n\t\t(left, right) => compareText(left.provider, right.provider) || compareText(left.id, right.id),\n\t);\n\tfor (const model of ordered) {\n\t\tif (model.provider === \"openai\" || !isGatewayApi(model.api) || !nonEmpty(model.baseUrl)) continue;\n\t\tif (!groups.has(model.provider)) groups.set(model.provider, model);\n\t}\n\treturn groups;\n}\n\nasync function resolveStoredOpenAi<TModel extends ImageGenAuthModel>(\n\tregistry: ImageGenAuthRegistry<TModel>,\n): Promise<ImageGenAuthResolution | undefined> {\n\tif (!isStoredApiKey(registry.authStorage.get(\"openai\"))) return undefined;\n\tlet resolved: ImageGenProviderAuthResult | undefined;\n\ttry {\n\t\tresolved = await registry.getProviderAuth(\"openai\");\n\t} catch {\n\t\treturn undefined;\n\t}\n\tconst credentials = credentialParts(resolved?.auth);\n\tif (!credentials) return undefined;\n\treturn {\n\t\tkind: \"native-openai\",\n\t\t...credentials,\n\t\tbaseUrl: OPENAI_BASE_URL,\n\t\tprovenance: \"store\",\n\t\tproviderId: \"openai\",\n\t};\n}\n\nasync function resolveGateway<TModel extends ImageGenAuthModel>(\n\tproviderId: string,\n\tmodel: TModel,\n\tregistry: ImageGenAuthRegistry<TModel>,\n): Promise<ImageGenAuthResolution | undefined> {\n\tconst baseUrl = nonEmpty(model.baseUrl);\n\tif (!baseUrl) return undefined;\n\tlet resolved: ImageGenRegistryAuthResult;\n\ttry {\n\t\tresolved = await registry.getApiKeyAndHeaders(model);\n\t} catch {\n\t\treturn undefined;\n\t}\n\tif (!resolved.ok) return undefined;\n\tconst credentials = credentialParts(resolved);\n\tif (!credentials) return undefined;\n\treturn {\n\t\tkind: \"gateway\",\n\t\t...credentials,\n\t\tbaseUrl,\n\t\tprovenance: \"provider-config\",\n\t\tproviderId,\n\t};\n}\n\nexport async function resolveImageGenAuth<TModel extends ImageGenAuthModel>(\n\tdeps: ResolveImageGenAuthDeps<TModel>,\n): Promise<ImageGenAuthResolution> {\n\tconst native = await resolveStoredOpenAi(deps.modelRegistry);\n\tif (native) return native;\n\n\tconst groups = groupGatewayModels(deps.modelRegistry.getAll());\n\tconst env = deps.env ?? process.env;\n\tconst pinnedProvider = nonEmpty(env.PI_IMAGE_GEN_PROVIDER);\n\tif (pinnedProvider) {\n\t\tconst pinnedModel = groups.get(pinnedProvider);\n\t\tif (pinnedModel) {\n\t\t\tconst pinned = await resolveGateway(pinnedProvider, pinnedModel, deps.modelRegistry);\n\t\t\tif (pinned) return pinned;\n\t\t}\n\t}\n\n\tconst providerIds = [...groups.keys()]\n\t\t.filter((providerId) => providerId !== pinnedProvider)\n\t\t.sort(compareProviderIds);\n\tfor (const providerId of providerIds) {\n\t\tconst model = groups.get(providerId);\n\t\tif (!model) continue;\n\t\tconst gateway = await resolveGateway(providerId, model, deps.modelRegistry);\n\t\tif (gateway) return gateway;\n\t}\n\n\tconst envApiKey = nonEmpty(env.OPENAI_API_KEY);\n\tif (envApiKey && !isPlaceholderKey(envApiKey)) {\n\t\treturn {\n\t\t\tkind: \"native-openai\",\n\t\t\tapiKey: envApiKey,\n\t\t\tbaseUrl: OPENAI_BASE_URL,\n\t\t\tprovenance: \"env\",\n\t\t};\n\t}\n\n\treturn { kind: \"none\", reason: SETUP_REASON };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/loop/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAOH,OAAO,KAAK,EAAE,aAAa,EAAgB,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGtG,OAAO,EAAE,KAAK,cAAc,EAAqD,MAAM,eAAe,CAAC;AACvG,OAAO,EAEN,KAAK,SAAS,EACd,KAAK,aAAa,EAGlB,KAAK,aAAa,EAClB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAA2C,KAAK,QAAQ,EAAE,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAE7G,OAAO,KAAK,EAEX,UAAU,EACV,OAAO,EACP,aAAa,EACb,MAAM,EAEN,YAAY,EACZ,SAAS,EACT,YAAY,EACZ,iBAAiB,EAEjB,MAAM,YAAY,CAAC;AAEpB,wFAAwF;AACxF,eAAO,MAAM,oBAAoB,cAAc,CAAC;AAEhD,MAAM,WAAW,iBAAiB;IACjC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAChC,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;IACjC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,Q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;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC;IAClG,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,YAAY,KAAK,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC;IACtE,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,YAAY,EAAE,KAAK,EAAE,SAAS,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7E;;;;OAIG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,CAAC,UAAU,EAAE,cAAc,KAAK,IAAI,CAAC;CAClE;AAED,eAAO,MAAM,mBAAmB,EAAE,aAAa,CAAC,iBAAiB,CAc/D,CAAC;AAEH;;;;;;GAMG;AACH,wBAAgB,mBAAmB,IAAI,aAAa,CA6BnD;AAiFD,wBAAgB,mBAAmB,CAAC,IAAI,GAAE,iBAAsB,GAAG,gBAAgB,CAqmBlF;;AAOD,wBAAqC"}
|
|
@@ -28,7 +28,7 @@ import { createLoopScheduler, } from "./scheduler.js";
|
|
|
28
28
|
import { formatLoopStatus, formatNoopFold, LoopStatusTicker } from "./status.js";
|
|
29
29
|
import { readLoopState, writeLoopState } from "./store.js";
|
|
30
30
|
import { buildTickMessage } from "./tick-prompt.js";
|
|
31
|
-
import { registerLoopTools } from "./tools.js";
|
|
31
|
+
import { registerLoopTools, SCHEDULE_WAKEUP_TOOL } from "./tools.js";
|
|
32
32
|
/** Custom entry type carrying one dispatched tick, used for attribution and folding. */
|
|
33
33
|
export const LOOP_TICK_ENTRY_TYPE = "loop-tick";
|
|
34
34
|
export const renderLoopTickEntry = noticeEntryRenderer((entry) => {
|
|
@@ -286,7 +286,23 @@ export function createLoopExtension(deps = {}) {
|
|
|
286
286
|
ticker.dispose();
|
|
287
287
|
ctx?.ui.notify(`/loop state could not be used and the affected loops were ended: ${message}`, "error");
|
|
288
288
|
}
|
|
289
|
+
/**
|
|
290
|
+
* `schedule_wakeup` is search-exposed, so it is callable only while this extension keeps it
|
|
291
|
+
* active: exactly when a dynamic loop is live (not ended, not suspended). Idempotent, so
|
|
292
|
+
* every state transition can call it without churning the active tool list.
|
|
293
|
+
*/
|
|
294
|
+
function syncScheduleWakeupActivation() {
|
|
295
|
+
if (scheduler === undefined)
|
|
296
|
+
return;
|
|
297
|
+
const wanted = Object.values(scheduler.getState().entries).some((entry) => entry.kind === "dynamic" && entry.phase !== "ended" && entry.phase !== "suspended");
|
|
298
|
+
const active = pi.getActiveTools();
|
|
299
|
+
const present = active.includes(SCHEDULE_WAKEUP_TOOL);
|
|
300
|
+
if (wanted === present)
|
|
301
|
+
return;
|
|
302
|
+
pi.setActiveTools(wanted ? [...active, SCHEDULE_WAKEUP_TOOL] : active.filter((name) => name !== SCHEDULE_WAKEUP_TOOL));
|
|
303
|
+
}
|
|
289
304
|
function refreshStatus() {
|
|
305
|
+
syncScheduleWakeupActivation();
|
|
290
306
|
if (scheduler === undefined)
|
|
291
307
|
return;
|
|
292
308
|
const state = scheduler.getState();
|
|
@@ -371,6 +387,9 @@ export function createLoopExtension(deps = {}) {
|
|
|
371
387
|
attributedLoopId = entry.id;
|
|
372
388
|
attributedDeliveryId = tick.deliveryId;
|
|
373
389
|
attributionResolved = false;
|
|
390
|
+
// The tick prompt tells the model to call schedule_wakeup, so the tool must be active
|
|
391
|
+
// before the tick is queued, not after the turn has already read its tool list.
|
|
392
|
+
syncScheduleWakeupActivation();
|
|
374
393
|
pi.sendUserMessage(built.text, {
|
|
375
394
|
expandPromptTemplates: true,
|
|
376
395
|
...(busy ? { deliverAs: "followUp" } : {}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/loop/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;A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AAE,CAAC;oBAClC,GAAG,EAAE,EAAE,CAAC,MAAM,CACb,SAAS,CAAC,SAAS,KAAK,qBAAqB;wBAC5C,CAAC,CAAC,mDAAmD;wBACrD,CAAC,CAAC,mDAAmD,EACtD,MAAM,CACN,CAAC;gBACH,CAAC;gBACD,OAAO;YACR,CAAC;YAED,IAAI,OAAO,EAAE,MAAM,KAAK,UAAU,EAAE,CAAC;gBACpC,gFAAgF;gBAChF,MAAM,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAClC,CAAC;iBAAM,IAAI,OAAO,EAAE,MAAM,KAAK,OAAO,EAAE,CAAC;gBACxC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,eAAe,OAAO,CAAC,SAAS,GAAG,EAAE,MAAM,CAAC,CAAC;YAC7D,CAAC;YACD,aAAa,EAAE,CAAC;QACjB,CAAC;IACF,CAAC,CAAC;AACH,CAAC;AAED,sFAAsF;AACtF,SAAS,mBAAmB,CAAC,KAA4B;IACxD,OAAO,KAAK,CAAC,2BAA2B,IAAI,KAAK,CAAC,qBAAqB,KAAK,IAAI,CAAC;AAClF,CAAC;AAED,eAAe,mBAAmB,EAAE,CAAC","sourcesContent":["/**\n * `/loop` extension factory and lifecycle wiring.\n *\n * This module owns the only impure parts of the feature: real timers, the session store,\n * the extension event wiring, and message dispatch. Every decision it makes is delegated\n * to the pure modules beside it (`scheduler.ts`, `tick-prompt.ts`, `cron-planner.ts`,\n * `loopfile.ts`, `status.ts`), so the runtime here is a thin, testable adapter.\n *\n * Load-bearing rules implemented here:\n * - A tick NEVER steers. Idle dispatch goes through `sendUserMessage(..., {\n * expandPromptTemplates: true })` so a slash payload reaches the real command path;\n * a busy session receives the tick as a follow-up instead.\n * - Shutdown SUSPENDS: timers are cancelled, the ticker disposed, and the snapshot is\n * persisted without a terminal reason (every senpi shutdown reason is resumable).\n * - Keepalive is applied only to an attributed dynamic iteration, never after an ordinary\n * user turn, and never after a user abort (an abort PAUSES the loop instead).\n * - A store failure is not swallowed: the affected loops end with `error` and the user is\n * told, because a schedule that cannot be persisted must not keep running.\n */\n\nimport { homedir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { getAgentDir } from \"../../../../config.ts\";\nimport type { SessionEntry } from \"../../../session-manager.ts\";\nimport { noticeEntryRenderer } from \"../../notice/index.ts\";\nimport type { EntryRenderer, ExtensionAPI, ExtensionContext, ExtensionFactory } from \"../../types.ts\";\nimport { registerLoopCommand } from \"./command-registration.ts\";\nimport { describeCron, normalizeInterval } from \"./cron-planner.ts\";\nimport { type LoopFileResult, nodeFs, resolveLoopFile as resolveLoopFileDefault } from \"./loopfile.ts\";\nimport {\n\tcreateLoopScheduler,\n\ttype LoopClock,\n\ttype LoopIdFactory,\n\ttype LoopScheduler,\n\ttype LoopTick,\n\ttype LoopTimerPort,\n} from \"./scheduler.ts\";\nimport { formatLoopStatus, formatNoopFold, LoopStatusTicker } from \"./status.ts\";\nimport { readLoopState, writeLoopState } from \"./store.ts\";\nimport { buildTickMessage, type LoopFileSnapshot, type LoopMode, type TickDelivery } from \"./tick-prompt.ts\";\nimport { registerLoopTools, type ScheduleWakeupTarget } from \"./tools.ts\";\nimport type {\n\tCronEntry,\n\tDeliveryId,\n\tEpochMs,\n\tLoopEndReason,\n\tLoopId,\n\tLoopPayload,\n\tLoopSentinel,\n\tLoopState,\n\tLoopStoreRef,\n\tRequestedInterval,\n\tSentinelDeliveryState,\n} from \"./types.ts\";\n\n/** Custom entry type carrying one dispatched tick, used for attribution and folding. */\nexport const LOOP_TICK_ENTRY_TYPE = \"loop-tick\";\n\nexport interface LoopTickEntryData {\n\treadonly loopId: LoopId;\n\treadonly deliveryId: DeliveryId;\n\treadonly scheduledForAt: EpochMs;\n\treadonly mode: LoopMode;\n\treadonly delivery: TickDelivery;\n\treadonly sentinel?: LoopSentinel;\n\t/** Consecutive quiet dynamic iterations at the moment this tick was dispatched. */\n\treadonly noopStreak: number;\n\t/** True when this tick continues a quiet streak and should render folded. */\n\treadonly folded: boolean;\n}\n\nexport interface LoopCreateOk {\n\treadonly ok: true;\n\treadonly loopId: LoopId;\n\t/** Present when a new dynamic loop replaced a previous one. */\n\treadonly supersededLoopId?: LoopId;\n\t/** Human-readable rounding notice when the requested cadence was normalized. */\n\treadonly roundingNotice?: string;\n\treadonly cronExpression?: string;\n\treadonly effectiveCadence?: string;\n\treadonly expiresAt?: EpochMs;\n}\n\nexport interface LoopCreateRejected {\n\treadonly ok: false;\n\treadonly message: string;\n}\n\nexport type LoopCreateOutcome = LoopCreateOk | LoopCreateRejected;\n\nexport interface LoopStoreFailure {\n\treadonly endReason: LoopEndReason;\n\treadonly message: string;\n\treadonly loopIds: readonly LoopId[];\n}\n\nexport interface StartFixedRequest {\n\treadonly originalArgs: string;\n\treadonly prompt: string;\n\treadonly requestedInterval: RequestedInterval;\n}\n\nexport interface StartDynamicRequest {\n\treadonly originalArgs: string;\n\treadonly prompt: string;\n}\n\nexport interface StartBareRequest {\n\treadonly originalArgs: string;\n\treadonly interval?: RequestedInterval;\n}\n\nexport interface ControllerScheduleWakeupRequest {\n\treadonly loopId: LoopId;\n\treadonly requestedDelaySeconds: number;\n\treadonly delaySeconds: number;\n\treadonly reason: string;\n\treadonly prompt: string;\n\treadonly noop: boolean;\n}\n\n/**\n * Runtime surface of a live loop extension. The `/loop` command module drives the\n * extension exclusively through this interface, so command parsing never reaches into\n * scheduler or store internals.\n */\nexport interface LoopController {\n\tstartFixed(request: StartFixedRequest): Promise<LoopCreateOutcome>;\n\tstartDynamic(request: StartDynamicRequest): Promise<LoopCreateOutcome>;\n\tstartBare(request: StartBareRequest): Promise<LoopCreateOutcome>;\n\t/** Runs the due decision for a loop at the current clock reading and dispatches it. */\n\tfireDue(loopId: LoopId): Promise<void>;\n\tscheduleWakeup(request: ControllerScheduleWakeupRequest): Promise<void>;\n\tstop(target: LoopId | \"all\", detail: string): Promise<readonly LoopId[]>;\n\tpause(target: LoopId | \"all\"): Promise<readonly LoopId[]>;\n\tresume(target: LoopId | \"all\"): Promise<readonly LoopId[]>;\n\tgetState(): LoopState;\n\tstatusLine(): string | undefined;\n\t/** Set when a store read/write failed and the affected loops were ended with `error`. */\n\tlastStoreFailure(): LoopStoreFailure | undefined;\n\t/** True when this loop was retired because its state could not be read or written. */\n\tisEndedWithError(loopId: LoopId): boolean;\n}\n\nexport interface LoopExtensionDeps {\n\treadonly clock?: LoopClock;\n\t/** Factory so each session gets its own timer port; defaults to real timeouts. */\n\treadonly timers?: () => LoopTimerPort;\n\treadonly ids?: LoopIdFactory;\n\treadonly storeRef?: (ctx: ExtensionContext) => LoopStoreRef;\n\treadonly resolveLoopFile?: (options: { cwd: string; homeDir: string }) => Promise<LoopFileResult>;\n\treadonly readState?: (ref: LoopStoreRef) => Promise<LoopState | null>;\n\treadonly writeState?: (ref: LoopStoreRef, state: LoopState) => Promise<void>;\n\t/**\n\t * Published at factory time so a command module (or a test) can drive this instance.\n\t * The controller is bound to the extension's own session state, so it stays valid across\n\t * session starts within one extension generation.\n\t */\n\treadonly onControllerReady?: (controller: LoopController) => void;\n}\n\nexport const renderLoopTickEntry: EntryRenderer<LoopTickEntryData> = noticeEntryRenderer((entry) => {\n\tconst data = entry.data;\n\tif (data === undefined) return undefined;\n\tconst folded = data.folded ? formatNoopFold(data.noopStreak) : \"\";\n\tif (folded.length > 0) {\n\t\treturn {\n\t\t\ttitle: folded,\n\t\t\twhy: \"Consecutive loop ticks reported no actionable change.\",\n\t\t};\n\t}\n\treturn {\n\t\ttitle: `↻ loop tick (${data.mode}) · ${data.delivery}`,\n\t\twhy: \"A /loop schedule dispatched this tick.\",\n\t};\n});\n\n/**\n * Real timer port: exactly one live timeout per key, replaced on re-arm.\n *\n * Follows the generation-counter discipline of `cache-keepalive/index.ts`: cancelling or\n * re-arming a key bumps its generation, so a callback whose generation is stale returns\n * without firing even if it was already scheduled on the event loop.\n */\nexport function createNodeTimerPort(): LoopTimerPort {\n\tconst handles = new Map<string, ReturnType<typeof setTimeout>>();\n\tconst generations = new Map<string, number>();\n\n\tfunction cancel(key: string): void {\n\t\tconst handle = handles.get(key);\n\t\tif (handle !== undefined) clearTimeout(handle);\n\t\thandles.delete(key);\n\t\tgenerations.set(key, (generations.get(key) ?? 0) + 1);\n\t}\n\n\treturn {\n\t\tarm(key, dueAt, callback) {\n\t\t\tcancel(key);\n\t\t\tconst generation = generations.get(key) ?? 0;\n\t\t\tconst delayMs = Math.max(0, dueAt - Date.now());\n\t\t\tconst handle = setTimeout(() => {\n\t\t\t\thandles.delete(key);\n\t\t\t\tif (generations.get(key) !== generation) return;\n\t\t\t\tcallback();\n\t\t\t}, delayMs);\n\t\t\thandle.unref?.();\n\t\t\thandles.set(key, handle);\n\t\t},\n\t\tcancel,\n\t\tcancelAll() {\n\t\t\tfor (const key of [...handles.keys()]) cancel(key);\n\t\t},\n\t};\n}\n\nfunction defaultIds(): LoopIdFactory {\n\tlet sequence = 0;\n\tconst mint = (prefix: string): string => {\n\t\tsequence += 1;\n\t\treturn `${prefix}-${Date.now().toString(36)}-${sequence.toString(36)}`;\n\t};\n\treturn {\n\t\tloopId: () => mint(\"loop\"),\n\t\twakeupId: () => mint(\"wakeup\"),\n\t\tdeliveryId: () => mint(\"delivery\"),\n\t};\n}\n\nfunction defaultStoreRef(ctx: ExtensionContext): LoopStoreRef {\n\tconst sessionFile = ctx.sessionManager.getSessionFile();\n\tconst baseDir =\n\t\tsessionFile === undefined\n\t\t\t? join(getAgentDir(), \"extensions\", \"loop\", \"no-session\")\n\t\t\t: join(ctx.sessionManager.getSessionDir(), \"extensions\", \"loop\");\n\treturn { baseDir, sessionId: ctx.sessionManager.getSessionId() };\n}\n\nfunction emptyDeliveryState(): SentinelDeliveryState {\n\treturn { autonomousPreambleDelivered: false, lastLoopFileDelivered: null, forceFullDelivery: false };\n}\n\nfunction loopFileSnapshot(result: LoopFileResult): LoopFileSnapshot {\n\tif (!result.found) return { present: false };\n\treturn {\n\t\tpresent: true,\n\t\tpath: result.path,\n\t\tcontent: result.content,\n\t\tmtimeMs: result.fingerprint.mtimeMs,\n\t\tsize: result.fingerprint.size,\n\t\tcontentHash: result.fingerprint.contentHash,\n\t};\n}\n\nfunction sentinelFor(mode: LoopMode, loopFilePresent: boolean): LoopSentinel {\n\tif (loopFilePresent) return mode === \"fixed\" ? \"<<loop.md>>\" : \"<<loop.md-dynamic>>\";\n\treturn mode === \"fixed\" ? \"<<autonomous-loop>>\" : \"<<autonomous-loop-dynamic>>\";\n}\n\nfunction modeOf(entry: CronEntry): LoopMode {\n\treturn entry.kind === \"fixed\" ? \"fixed\" : \"dynamic\";\n}\n\ninterface AnchorPayload {\n\treadonly loopId?: string;\n\treadonly deliveryId?: string;\n}\n\n/** Reads the tick payload of a `loop-tick` entry, whichever entry kind carries it. */\nfunction anchorPayloadOf(entry: SessionEntry): AnchorPayload | undefined {\n\tif (entry.type === \"custom\") {\n\t\treturn entry.customType === LOOP_TICK_ENTRY_TYPE ? (entry.data as AnchorPayload | undefined) : undefined;\n\t}\n\tif (entry.type === \"custom_message\") {\n\t\treturn entry.customType === LOOP_TICK_ENTRY_TYPE ? (entry.details as AnchorPayload | undefined) : undefined;\n\t}\n\treturn undefined;\n}\n\n/**\n * True when the compaction-aware context still contains the delivery that anchored a full\n * sentinel block. Compaction can drop it, and a reminder's \"established earlier in this\n * conversation\" phrasing must never dangle, so a missing anchor forces the next tick back\n * to full. When no specific anchor id was recorded (the autonomous preamble carries none),\n * any surviving tick delivery for that loop counts as the anchor.\n */\nfunction anchorPresent(ctx: ExtensionContext, loopId: LoopId, deliveryId: DeliveryId | undefined): boolean {\n\treturn ctx.sessionManager.buildContextEntries().some((entry) => {\n\t\tconst payload = anchorPayloadOf(entry);\n\t\tif (payload === undefined) return false;\n\t\tif (payload.loopId !== undefined && payload.loopId !== loopId) return false;\n\t\treturn deliveryId === undefined ? true : payload.deliveryId === deliveryId;\n\t});\n}\n\nexport function createLoopExtension(deps: LoopExtensionDeps = {}): ExtensionFactory {\n\tconst clock: LoopClock = deps.clock ?? { now: () => Date.now() };\n\tconst makeTimers = deps.timers ?? createNodeTimerPort;\n\tconst ids = deps.ids ?? defaultIds();\n\tconst storeRefOf = deps.storeRef ?? defaultStoreRef;\n\tconst resolveLoopFile =\n\t\tdeps.resolveLoopFile ??\n\t\t((options: { cwd: string; homeDir: string }) =>\n\t\t\tresolveLoopFileDefault({ cwd: options.cwd, homeDir: options.homeDir, fs: nodeFs, path: { join } }));\n\tconst readState = deps.readState ?? readLoopState;\n\tconst writeState = deps.writeState ?? writeLoopState;\n\n\treturn (pi: ExtensionAPI) => {\n\t\tlet ctx: ExtensionContext | undefined;\n\t\tlet scheduler: LoopScheduler | undefined;\n\t\tlet storeRef: LoopStoreRef | undefined;\n\t\tlet timers: LoopTimerPort = makeTimers();\n\t\tlet storeFailure: LoopStoreFailure | undefined;\n\t\tlet sessionNamed = false;\n\t\t/** Loop the currently running iteration is attributed to, for keepalive + tools. */\n\t\tlet attributedLoopId: LoopId | undefined;\n\t\t/** Delivery id of the tick that started the attributed iteration. */\n\t\tlet attributedDeliveryId: DeliveryId | undefined;\n\t\t/** True once the attributed iteration rescheduled or stopped itself. */\n\t\tlet attributionResolved = false;\n\t\t/** Ticks held back because their slash payload cannot be queued while streaming. */\n\t\tconst deferredDispatches: LoopTick[] = [];\n\t\tconst deliveryStates = new Map<LoopId, SentinelDeliveryState>();\n\t\t/** Loops retired with `error` because their state could not be read or written. */\n\t\tconst endedWithError = new Set<LoopId>();\n\t\t/** True once this session has state worth persisting (loaded or created). */\n\t\tlet storeTouched = false;\n\t\tlet persistTail: Promise<void> = Promise.resolve();\n\n\t\tconst ticker = new LoopStatusTicker({\n\t\t\trender: (key, text) => {\n\t\t\t\ttry {\n\t\t\t\t\tctx?.ui.setStatus(key, text);\n\t\t\t\t} catch {\n\t\t\t\t\t// A stale context after session replacement must not break the loop runtime.\n\t\t\t\t}\n\t\t\t},\n\t\t\tnow: () => clock.now(),\n\t\t});\n\n\t\tpi.registerEntryRenderer(LOOP_TICK_ENTRY_TYPE, renderLoopTickEntry);\n\t\tregisterLoopTools(pi, {\n\t\t\tscheduler: {\n\t\t\t\tgetWakeupTarget: (): ScheduleWakeupTarget => {\n\t\t\t\t\tif (scheduler === undefined || attributedLoopId === undefined) return null;\n\t\t\t\t\tconst entry = scheduler.getState().entries[attributedLoopId];\n\t\t\t\t\tif (entry === undefined || entry.phase === \"ended\") return null;\n\t\t\t\t\treturn { kind: entry.kind, loopId: entry.id };\n\t\t\t\t},\n\t\t\t\tscheduleWakeup: async (request) => {\n\t\t\t\t\tconst active = requireScheduler();\n\t\t\t\t\tconst result = active.onScheduleWakeup(request);\n\t\t\t\t\tif (!result.ok) throw new Error(`schedule_wakeup rejected: ${result.reason}`);\n\t\t\t\t\tattributionResolved = true;\n\t\t\t\t\tawait persist();\n\t\t\t\t\trefreshStatus();\n\t\t\t\t\treturn {\n\t\t\t\t\t\twakeupId: result.wakeupId,\n\t\t\t\t\t\t...(result.replacedWakeupId === undefined ? {} : { replacedWakeupId: result.replacedWakeupId }),\n\t\t\t\t\t\tdueAt: result.dueAt,\n\t\t\t\t\t\tnoopStreak: result.noopStreak,\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t\tstopDynamicLoop: async (request) => {\n\t\t\t\t\tconst active = requireScheduler();\n\t\t\t\t\tactive.stop(request.loopId, \"model-stop\");\n\t\t\t\t\tattributionResolved = true;\n\t\t\t\t\tawait persist();\n\t\t\t\t\trefreshStatus();\n\t\t\t\t\treturn { endedAt: clock.now() };\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\n\t\tfunction requireScheduler(): LoopScheduler {\n\t\t\tif (scheduler === undefined) throw new Error(\"loop extension has no active session\");\n\t\t\treturn scheduler;\n\t\t}\n\n\t\t/** Merges extension-owned sentinel delivery state into the scheduler's snapshot. */\n\t\tfunction withDeliveryOverlay(state: LoopState): LoopState {\n\t\t\tconst entries: Record<LoopId, CronEntry> = {};\n\t\t\tfor (const [id, entry] of Object.entries(state.entries)) {\n\t\t\t\tconst delivery = deliveryStates.get(id);\n\t\t\t\tentries[id] = delivery === undefined ? entry : { ...entry, sentinelDelivery: delivery };\n\t\t\t}\n\t\t\treturn { ...state, entries };\n\t\t}\n\n\t\t/** Serializes persistence so a timer, tool, and command write cannot interleave. */\n\t\tfunction persist(): Promise<void> {\n\t\t\tconst ref = storeRef;\n\t\t\tconst active = scheduler;\n\t\t\tif (ref === undefined || active === undefined) return Promise.resolve();\n\t\t\tconst snapshot = withDeliveryOverlay(active.getState());\n\t\t\t// The extension is registered for every session, so a session that never ran a loop\n\t\t\t// must not leave a sidecar behind.\n\t\t\tif (!storeTouched && Object.keys(snapshot.entries).length === 0) return Promise.resolve();\n\t\t\tstoreTouched = true;\n\t\t\tpersistTail = persistTail.then(async () => {\n\t\t\t\ttry {\n\t\t\t\t\tawait writeState(ref, snapshot);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tfailStore(error, Object.keys(snapshot.entries));\n\t\t\t\t}\n\t\t\t});\n\t\t\treturn persistTail;\n\t\t}\n\n\t\t/**\n\t\t * A schedule that cannot be read or written must not keep running: end the affected\n\t\t * loops with `error` and tell the user, rather than silently losing the schedule. The\n\t\t * terminal record is kept in memory because the store that would hold it is exactly the\n\t\t * thing that just failed; what matters is that nothing stays armed and the user knows.\n\t\t */\n\t\tfunction failStore(error: unknown, loopIds: readonly LoopId[]): void {\n\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\ttimers.cancelAll();\n\t\t\tfor (const loopId of loopIds) endedWithError.add(loopId);\n\t\t\tstoreFailure = {\n\t\t\t\tendReason: \"error\",\n\t\t\t\tmessage,\n\t\t\t\tloopIds,\n\t\t\t};\n\t\t\tticker.dispose();\n\t\t\tctx?.ui.notify(`/loop state could not be used and the affected loops were ended: ${message}`, \"error\");\n\t\t}\n\n\t\tfunction refreshStatus(): void {\n\t\t\tif (scheduler === undefined) return;\n\t\t\tconst state = scheduler.getState();\n\t\t\t// The ticker owns a repeating render timer, so it only runs while a loop is armed;\n\t\t\t// a session that never used /loop must not carry one.\n\t\t\tif (Object.values(state.entries).every((entry) => entry.phase === \"ended\")) {\n\t\t\t\tif (ticker.running) ticker.dispose();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tticker.sync(state);\n\t\t}\n\n\t\tfunction deliveryStateOf(loopId: LoopId): SentinelDeliveryState {\n\t\t\treturn deliveryStates.get(loopId) ?? emptyDeliveryState();\n\t\t}\n\n\t\tfunction markForceFullDelivery(): void {\n\t\t\tfor (const [id, state] of deliveryStates) {\n\t\t\t\tdeliveryStates.set(id, { ...state, forceFullDelivery: true });\n\t\t\t}\n\t\t\tconst active = scheduler;\n\t\t\tif (active === undefined) return;\n\t\t\tfor (const entry of Object.values(active.getState().entries)) {\n\t\t\t\tif (entry.phase === \"ended\") continue;\n\t\t\t\tif (deliveryStates.has(entry.id)) continue;\n\t\t\t\tdeliveryStates.set(entry.id, { ...entry.sentinelDelivery, forceFullDelivery: true });\n\t\t\t}\n\t\t}\n\n\t\tfunction isExtensionCommandPayload(text: string): boolean {\n\t\t\tif (!text.startsWith(\"/\")) return false;\n\t\t\tconst name = text.slice(1).split(/\\s+/)[0];\n\t\t\treturn pi.getCommands().some((command) => command.name === name);\n\t\t}\n\n\t\t/**\n\t\t * Delivers one tick. Idle dispatch expands prompt templates so a slash payload\n\t\t * reaches its real command handler; a busy session gets a follow-up instead of\n\t\t * steering. A slash payload cannot be queued at all, so it waits for the turn to\n\t\t * settle rather than being rewritten into plain text.\n\t\t */\n\t\tasync function dispatchTick(tick: LoopTick): Promise<void> {\n\t\t\tconst active = requireScheduler();\n\t\t\tconst entry = active.getState().entries[tick.loopId];\n\t\t\tif (entry === undefined || entry.phase === \"ended\") return;\n\t\t\tif (endedWithError.has(tick.loopId)) return;\n\t\t\tconst currentCtx = ctx;\n\t\t\tif (currentCtx === undefined) return;\n\n\t\t\tconst mode = modeOf(entry);\n\t\t\tconst loopFile =\n\t\t\t\tentry.payload.type === \"sentinel\" ? await resolveLoopFileSafely(currentCtx) : { found: false as const };\n\t\t\tconst built = buildTickMessage({\n\t\t\t\tloopId: entry.id,\n\t\t\t\tdeliveryId: tick.deliveryId,\n\t\t\t\tmode,\n\t\t\t\tpayload: entry.payload,\n\t\t\t\treentryPrompt: entry.reentryPrompt,\n\t\t\t\tdeliveryState: deliveryStateOf(entry.id),\n\t\t\t\tloopFile: loopFileSnapshot(loopFile),\n\t\t\t});\n\t\t\tdeliveryStates.set(entry.id, built.deliveryState);\n\n\t\t\tconst busy = !currentCtx.isIdle() || currentCtx.hasPendingMessages();\n\t\t\tif (busy && isExtensionCommandPayload(built.text)) {\n\t\t\t\t// Extension commands cannot be queued; hold this delivery until the turn settles.\n\t\t\t\tdeferredDispatches.push(tick);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst noopStreak = entry.noopStreak;\n\t\t\tpi.appendEntry<LoopTickEntryData>(LOOP_TICK_ENTRY_TYPE, {\n\t\t\t\tloopId: entry.id,\n\t\t\t\tdeliveryId: tick.deliveryId,\n\t\t\t\tscheduledForAt: tick.scheduledForAt,\n\t\t\t\tmode,\n\t\t\t\tdelivery: built.delivery,\n\t\t\t\t...(built.details.sentinel === undefined ? {} : { sentinel: built.details.sentinel }),\n\t\t\t\tnoopStreak,\n\t\t\t\tfolded: noopStreak >= 2,\n\t\t\t});\n\n\t\t\tattributedLoopId = entry.id;\n\t\t\tattributedDeliveryId = tick.deliveryId;\n\t\t\tattributionResolved = false;\n\t\t\tpi.sendUserMessage(built.text, {\n\t\t\t\texpandPromptTemplates: true,\n\t\t\t\t...(busy ? { deliverAs: \"followUp\" as const } : {}),\n\t\t\t});\n\t\t\tawait persist();\n\t\t\trefreshStatus();\n\t\t}\n\n\t\tasync function resolveLoopFileSafely(currentCtx: ExtensionContext): Promise<LoopFileResult> {\n\t\t\ttry {\n\t\t\t\treturn await resolveLoopFile({ cwd: currentCtx.cwd, homeDir: homedir() });\n\t\t\t} catch {\n\t\t\t\t// A loop file that cannot be read is treated as absent for this tick; the loop\n\t\t\t\t// stays alive and picks the file up again once it is readable.\n\t\t\t\treturn { found: false };\n\t\t\t}\n\t\t}\n\n\t\tasync function drainDeferred(): Promise<void> {\n\t\t\tif (deferredDispatches.length === 0) return;\n\t\t\tconst pending = deferredDispatches.splice(0, deferredDispatches.length);\n\t\t\tfor (const tick of pending) await dispatchTick(tick);\n\t\t}\n\n\t\tasync function fireDue(loopId: LoopId): Promise<void> {\n\t\t\tconst active = scheduler;\n\t\t\tconst currentCtx = ctx;\n\t\t\tif (active === undefined || currentCtx === undefined) return;\n\t\t\tconst busy = !currentCtx.isIdle() || currentCtx.hasPendingMessages();\n\t\t\tconst decision = active.onDue(loopId, clock.now(), busy);\n\t\t\tawait persist();\n\t\t\tif (decision.action === \"dispatch\") {\n\t\t\t\tawait dispatchTick(decision.tick);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (decision.action === \"expire\") {\n\t\t\t\tctx?.ui.notify(\"Loop expired after 7 days and is no longer armed.\", \"info\");\n\t\t\t}\n\t\t\trefreshStatus();\n\t\t}\n\n\t\t/**\n\t\t * Timer callbacks are synchronous, so the async due step is scheduled and its failure is\n\t\t * contained: a rejected dispatch must never take down the timer that owns the loop.\n\t\t */\n\t\tfunction handleTimerFire(loopId: LoopId): void {\n\t\t\tvoid fireDue(loopId).catch((error) => {\n\t\t\t\tctx?.ui.notify(`Loop tick failed: ${error instanceof Error ? error.message : String(error)}`, \"error\");\n\t\t\t});\n\t\t}\n\n\t\tfunction payloadForPrompt(prompt: string): LoopPayload {\n\t\t\treturn { type: \"prompt\", prompt };\n\t\t}\n\n\t\tasync function startFixed(request: StartFixedRequest): Promise<LoopCreateOutcome> {\n\t\t\tconst active = requireScheduler();\n\t\t\tconst effective = normalizeInterval(request.requestedInterval);\n\t\t\tconst created = active.createFixed({\n\t\t\t\toriginalArgs: request.originalArgs,\n\t\t\t\treentryPrompt: `/loop ${request.originalArgs}`.trimEnd(),\n\t\t\t\tpayload: payloadForPrompt(request.prompt),\n\t\t\t\trequestedInterval: request.requestedInterval,\n\t\t\t\teffectiveInterval: effective,\n\t\t\t\tcronExpression: describeCron(effective),\n\t\t\t\tintervalMs: effective.intervalMs,\n\t\t\t});\n\t\t\tif (!created.ok) return { ok: false, message: created.message };\n\t\t\tdeliveryStates.set(created.loopId, emptyDeliveryState());\n\t\t\tawait persist();\n\t\t\tnameSessionAfterLoop(request.prompt);\n\t\t\tawait fireDue(created.loopId);\n\t\t\trefreshStatus();\n\t\t\treturn {\n\t\t\t\tok: true,\n\t\t\t\tloopId: created.loopId,\n\t\t\t\t...(effective.roundingNotice === undefined ? {} : { roundingNotice: effective.roundingNotice }),\n\t\t\t\tcronExpression: describeCron(effective),\n\t\t\t\teffectiveCadence: effective.human,\n\t\t\t\texpiresAt: active.getState().entries[created.loopId]?.expiresAt,\n\t\t\t};\n\t\t}\n\n\t\tasync function startDynamic(request: StartDynamicRequest): Promise<LoopCreateOutcome> {\n\t\t\tconst active = requireScheduler();\n\t\t\tconst created = active.createDynamic({\n\t\t\t\toriginalArgs: request.originalArgs,\n\t\t\t\treentryPrompt: `/loop ${request.originalArgs}`.trimEnd(),\n\t\t\t\tpayload: payloadForPrompt(request.prompt),\n\t\t\t});\n\t\t\tif (!created.ok) return { ok: false, message: created.message };\n\t\t\tdeliveryStates.set(created.loopId, emptyDeliveryState());\n\t\t\tawait persist();\n\t\t\tnameSessionAfterLoop(request.prompt);\n\t\t\tawait fireDue(created.loopId);\n\t\t\trefreshStatus();\n\t\t\treturn {\n\t\t\t\tok: true,\n\t\t\t\tloopId: created.loopId,\n\t\t\t\t...(created.supersededLoopId === undefined ? {} : { supersededLoopId: created.supersededLoopId }),\n\t\t\t\texpiresAt: active.getState().entries[created.loopId]?.expiresAt,\n\t\t\t};\n\t\t}\n\n\t\tasync function startBare(request: StartBareRequest): Promise<LoopCreateOutcome> {\n\t\t\tconst active = requireScheduler();\n\t\t\tconst currentCtx = ctx;\n\t\t\tif (currentCtx === undefined) return { ok: false, message: \"loop extension has no active session\" };\n\t\t\tconst loopFile = await resolveLoopFileSafely(currentCtx);\n\t\t\tconst mode: LoopMode = request.interval === undefined ? \"dynamic\" : \"fixed\";\n\t\t\tconst payload: LoopPayload = { type: \"sentinel\", sentinel: sentinelFor(mode, loopFile.found) };\n\t\t\tconst reentryPrompt = request.originalArgs.trim() === \"\" ? \"/loop\" : `/loop ${request.originalArgs.trim()}`;\n\n\t\t\tconst created =\n\t\t\t\trequest.interval === undefined\n\t\t\t\t\t? active.createDynamic({ originalArgs: request.originalArgs, reentryPrompt, payload })\n\t\t\t\t\t: (() => {\n\t\t\t\t\t\t\tconst effective = normalizeInterval(request.interval);\n\t\t\t\t\t\t\treturn active.createFixed({\n\t\t\t\t\t\t\t\toriginalArgs: request.originalArgs,\n\t\t\t\t\t\t\t\treentryPrompt,\n\t\t\t\t\t\t\t\tpayload,\n\t\t\t\t\t\t\t\trequestedInterval: request.interval,\n\t\t\t\t\t\t\t\teffectiveInterval: effective,\n\t\t\t\t\t\t\t\tcronExpression: describeCron(effective),\n\t\t\t\t\t\t\t\tintervalMs: effective.intervalMs,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t})();\n\t\t\tif (!created.ok) return { ok: false, message: created.message };\n\t\t\tdeliveryStates.set(created.loopId, emptyDeliveryState());\n\t\t\tawait persist();\n\t\t\tnameSessionAfterLoop(reentryPrompt);\n\t\t\tawait fireDue(created.loopId);\n\t\t\trefreshStatus();\n\t\t\treturn {\n\t\t\t\tok: true,\n\t\t\t\tloopId: created.loopId,\n\t\t\t\texpiresAt: active.getState().entries[created.loopId]?.expiresAt,\n\t\t\t};\n\t\t}\n\n\t\tfunction nameSessionAfterLoop(prompt: string): void {\n\t\t\tif (sessionNamed) return;\n\t\t\tsessionNamed = true;\n\t\t\tif (pi.getSessionName() !== undefined) return;\n\t\t\tpi.setSessionName(`loop: ${prompt}`.trim());\n\t\t}\n\n\t\tconst controller: LoopController = {\n\t\t\tstartFixed,\n\t\t\tstartDynamic,\n\t\t\tstartBare,\n\t\t\tfireDue,\n\t\t\tscheduleWakeup: async (request) => {\n\t\t\t\tconst active = requireScheduler();\n\t\t\t\tconst result = active.onScheduleWakeup(request);\n\t\t\t\tif (result.ok) attributionResolved = true;\n\t\t\t\tawait persist();\n\t\t\t\trefreshStatus();\n\t\t\t},\n\t\t\tstop: async (target, detail) => {\n\t\t\t\tconst active = requireScheduler();\n\t\t\t\tconst result = active.stop(target, detail);\n\t\t\t\tawait persist();\n\t\t\t\trefreshStatus();\n\t\t\t\treturn result.affectedLoopIds;\n\t\t\t},\n\t\t\tpause: async (target) => {\n\t\t\t\tconst active = requireScheduler();\n\t\t\t\tconst result = active.pause(target);\n\t\t\t\tawait persist();\n\t\t\t\trefreshStatus();\n\t\t\t\treturn result.affectedLoopIds;\n\t\t\t},\n\t\t\tresume: async (target) => {\n\t\t\t\tconst active = requireScheduler();\n\t\t\t\tconst result = active.resume(target);\n\t\t\t\tawait persist();\n\t\t\t\trefreshStatus();\n\t\t\t\treturn result.affectedLoopIds;\n\t\t\t},\n\t\t\tgetState: () => requireScheduler().getState(),\n\t\t\tstatusLine: () => formatLoopStatus(requireScheduler().getState(), clock.now()),\n\t\t\tlastStoreFailure: () => storeFailure,\n\t\t\tisEndedWithError: (loopId) => endedWithError.has(loopId),\n\t\t};\n\n\t\tdeps.onControllerReady?.(controller);\n\t\tregisterLoopCommand(pi, { controller });\n\n\t\tpi.on(\"session_start\", async (_event, nextCtx) => {\n\t\t\tctx = nextCtx;\n\t\t\ttimers.cancelAll();\n\t\t\ttimers = makeTimers();\n\t\t\tstoreFailure = undefined;\n\t\t\tendedWithError.clear();\n\t\t\tstoreTouched = false;\n\t\t\tsessionNamed = false;\n\t\t\tattributedLoopId = undefined;\n\t\t\tattributedDeliveryId = undefined;\n\t\t\tattributionResolved = false;\n\t\t\tdeferredDispatches.length = 0;\n\t\t\tdeliveryStates.clear();\n\t\t\tstoreRef = storeRefOf(nextCtx);\n\n\t\t\tlet initialState: LoopState | undefined;\n\t\t\ttry {\n\t\t\t\tinitialState = (await readState(storeRef)) ?? undefined;\n\t\t\t} catch (error) {\n\t\t\t\t// Fail closed: arm nothing, end nothing silently, and tell the user.\n\t\t\t\tfailStore(error, []);\n\t\t\t\tscheduler = createLoopScheduler({\n\t\t\t\t\tsessionId: nextCtx.sessionManager.getSessionId(),\n\t\t\t\t\tclock,\n\t\t\t\t\ttimers,\n\t\t\t\t\tids,\n\t\t\t\t\tonFire: handleTimerFire,\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tscheduler = createLoopScheduler({\n\t\t\t\tsessionId: nextCtx.sessionManager.getSessionId(),\n\t\t\t\tclock,\n\t\t\t\ttimers,\n\t\t\t\tids,\n\t\t\t\tonFire: handleTimerFire,\n\t\t\t\t...(initialState === undefined ? {} : { initialState }),\n\t\t\t});\n\t\t\tstoreTouched = initialState !== undefined;\n\n\t\t\tfor (const entry of Object.values(scheduler.getState().entries)) {\n\t\t\t\tconst anchorDeliveryId = entry.sentinelDelivery.lastLoopFileDelivered?.anchorDeliveryId;\n\t\t\t\tconst anchored = anchorPresent(nextCtx, entry.id, anchorDeliveryId);\n\t\t\t\tconst needsFull = !anchored && hasAnchoredDelivery(entry.sentinelDelivery);\n\t\t\t\tdeliveryStates.set(entry.id, {\n\t\t\t\t\t...entry.sentinelDelivery,\n\t\t\t\t\tforceFullDelivery: entry.sentinelDelivery.forceFullDelivery || needsFull,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst restored = scheduler.restore(clock.now());\n\t\t\tawait persist();\n\t\t\trefreshStatus();\n\t\t\tfor (const tick of restored.recoveryTicks) await dispatchTick(tick);\n\t\t\tif (restored.expiredLoopIds.length > 0) {\n\t\t\t\tnextCtx.ui.notify(`Loop expired after 7 days: ${restored.expiredLoopIds.join(\", \")}`, \"info\");\n\t\t\t}\n\t\t});\n\n\t\tpi.on(\"session_compact\", async (event) => {\n\t\t\t// Accepted compaction may have dropped the anchor the reminders point at, so the\n\t\t\t// next sentinel tick must carry the full instructions again. Timers and phase are\n\t\t\t// deliberately untouched.\n\t\t\tif (event.accepted !== true) return;\n\t\t\tmarkForceFullDelivery();\n\t\t\tawait persist();\n\t\t});\n\n\t\tpi.on(\"input\", async (event) => {\n\t\t\t// A user turn is never an attributed loop iteration, so keepalive must not see it.\n\t\t\t// A tick dispatched by this extension arrives with source \"extension\" and MUST keep\n\t\t\t// its attribution, or no dynamic iteration would ever be judged.\n\t\t\tif (event.source === \"extension\") return;\n\t\t\tattributedLoopId = undefined;\n\t\t\tattributedDeliveryId = undefined;\n\t\t\tattributionResolved = false;\n\t\t});\n\n\t\tpi.on(\"agent_end\", async (event) => {\n\t\t\t// A retrying turn is still in progress: neither settle it nor judge its liveness.\n\t\t\tif (event.willRetry === true) return;\n\t\t\tif (event.aborted === true && event.abortSource === \"user\") {\n\t\t\t\tawait pauseAttributedLoop();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tawait settleAttributedTick(event.aborted === true ? \"error\" : \"completed\");\n\t\t});\n\n\t\tpi.on(\"agent_settled\", async () => {\n\t\t\tawait settleAttributedTick(\"completed\");\n\t\t\tawait drainDeferred();\n\t\t\trefreshStatus();\n\t\t});\n\n\t\tpi.on(\"session_abort\", async () => {\n\t\t\tawait pauseAttributedLoop();\n\t\t});\n\n\t\tpi.on(\"session_shutdown\", async () => {\n\t\t\tconst active = scheduler;\n\t\t\tif (active !== undefined) {\n\t\t\t\t// Shutdown SUSPENDS: every senpi shutdown reason leaves the session resumable,\n\t\t\t\t// so the snapshot must carry no terminal reason.\n\t\t\t\tactive.onShutdown();\n\t\t\t\tawait persist();\n\t\t\t}\n\t\t\ttimers.cancelAll();\n\t\t\tdeferredDispatches.length = 0;\n\t\t\tticker.dispose();\n\t\t\tattributedLoopId = undefined;\n\t\t\tattributedDeliveryId = undefined;\n\t\t\tattributionResolved = false;\n\t\t\tctx = undefined;\n\t\t});\n\n\t\tasync function pauseAttributedLoop(): Promise<void> {\n\t\t\tconst active = scheduler;\n\t\t\tif (active === undefined) return;\n\t\t\tconst targets =\n\t\t\t\tattributedLoopId === undefined\n\t\t\t\t\t? Object.values(active.getState().entries)\n\t\t\t\t\t\t\t.filter((entry) => entry.phase !== \"ended\")\n\t\t\t\t\t\t\t.map((entry) => entry.id)\n\t\t\t\t\t: [attributedLoopId];\n\t\t\tconst paused: LoopId[] = [];\n\t\t\tfor (const loopId of targets) {\n\t\t\t\tif (active.onUserAbort(loopId).action === \"paused\") paused.push(loopId);\n\t\t\t}\n\t\t\tattributedLoopId = undefined;\n\t\t\tattributedDeliveryId = undefined;\n\t\t\tattributionResolved = false;\n\t\t\tif (paused.length === 0) return;\n\t\t\tawait persist();\n\t\t\trefreshStatus();\n\t\t\tctx?.ui.notify(\"loop paused - /loop resume or /loop stop\", \"info\");\n\t\t}\n\n\t\t/**\n\t\t * Settles the tick this turn was attributed to, drains a coalesced occurrence, and\n\t\t * applies the two-strike keepalive to a dynamic iteration that ended without calling\n\t\t * `schedule_wakeup`. An ordinary user turn clears the attribution first, so keepalive\n\t\t * can never be charged to it, and a user abort takes the pause path instead.\n\t\t */\n\t\tasync function settleAttributedTick(outcome: \"completed\" | \"error\"): Promise<void> {\n\t\t\tconst active = scheduler;\n\t\t\tconst loopId = attributedLoopId;\n\t\t\tconst deliveryId = attributedDeliveryId;\n\t\t\tif (active === undefined || loopId === undefined) return;\n\t\t\tconst entry = active.getState().entries[loopId];\n\t\t\tif (entry === undefined) return;\n\t\t\tconst resolved = attributionResolved;\n\t\t\tattributedLoopId = undefined;\n\t\t\tattributedDeliveryId = undefined;\n\t\t\tattributionResolved = false;\n\n\t\t\tconst settled = deliveryId === undefined ? undefined : active.onTickSettled({ loopId, deliveryId, outcome });\n\t\t\tawait persist();\n\n\t\t\tif (!resolved && entry.kind === \"dynamic\") {\n\t\t\t\tconst keepalive = active.onTurnEndedWithoutSchedule(loopId);\n\t\t\t\tawait persist();\n\t\t\t\trefreshStatus();\n\t\t\t\tif (keepalive.action === \"ended\") {\n\t\t\t\t\tctx?.ui.notify(\n\t\t\t\t\t\tkeepalive.endReason === \"keepalive_exhausted\"\n\t\t\t\t\t\t\t? \"Loop ended: the model stopped scheduling wakeups.\"\n\t\t\t\t\t\t\t: \"Loop expired after 7 days and is no longer armed.\",\n\t\t\t\t\t\t\"info\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (settled?.action === \"dispatch\") {\n\t\t\t\t// Exactly one delivery drains a coalesced occurrence, however many were missed.\n\t\t\t\tawait dispatchTick(settled.tick);\n\t\t\t} else if (settled?.action === \"ended\") {\n\t\t\t\tctx?.ui.notify(`Loop ended: ${settled.endReason}.`, \"info\");\n\t\t\t}\n\t\t\trefreshStatus();\n\t\t}\n\t};\n}\n\n/** True when a reminder would refer back to a full delivery that must still exist. */\nfunction hasAnchoredDelivery(state: SentinelDeliveryState): boolean {\n\treturn state.autonomousPreambleDelivered || state.lastLoopFileDelivered !== null;\n}\n\nexport default createLoopExtension();\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/loop/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAAuB,MAAM,EAAE,eAAe,IAAI,sBAAsB,EAAE,MAAM,eAAe,CAAC;AACvG,OAAO,EACN,mBAAmB,GAMnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,gBAAg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AAC,MAAM,CAAC,aAAa,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC,CAAC;YAC7G,MAAM,OAAO,EAAE,CAAC;YAEhB,IAAI,CAAC,QAAQ,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;gBAC3C,MAAM,SAAS,GAAG,MAAM,CAAC,0BAA0B,CAAC,MAAM,CAAC,CAAC;gBAC5D,MAAM,OAAO,EAAE,CAAC;gBAChB,aAAa,EAAE,CAAC;gBAChB,IAAI,SAAS,CAAC,MAAM,KAAK,OAAO,EAAE,CAAC;oBAClC,GAAG,EAAE,EAAE,CAAC,MAAM,CACb,SAAS,CAAC,SAAS,KAAK,qBAAqB;wBAC5C,CAAC,CAAC,mDAAmD;wBACrD,CAAC,CAAC,mDAAmD,EACtD,MAAM,CACN,CAAC;gBACH,CAAC;gBACD,OAAO;YACR,CAAC;YAED,IAAI,OAAO,EAAE,MAAM,KAAK,UAAU,EAAE,CAAC;gBACpC,gFAAgF;gBAChF,MAAM,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAClC,CAAC;iBAAM,IAAI,OAAO,EAAE,MAAM,KAAK,OAAO,EAAE,CAAC;gBACxC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,eAAe,OAAO,CAAC,SAAS,GAAG,EAAE,MAAM,CAAC,CAAC;YAC7D,CAAC;YACD,aAAa,EAAE,CAAC;QACjB,CAAC;IACF,CAAC,CAAC;AACH,CAAC;AAED,sFAAsF;AACtF,SAAS,mBAAmB,CAAC,KAA4B;IACxD,OAAO,KAAK,CAAC,2BAA2B,IAAI,KAAK,CAAC,qBAAqB,KAAK,IAAI,CAAC;AAClF,CAAC;AAED,eAAe,mBAAmB,EAAE,CAAC","sourcesContent":["/**\n * `/loop` extension factory and lifecycle wiring.\n *\n * This module owns the only impure parts of the feature: real timers, the session store,\n * the extension event wiring, and message dispatch. Every decision it makes is delegated\n * to the pure modules beside it (`scheduler.ts`, `tick-prompt.ts`, `cron-planner.ts`,\n * `loopfile.ts`, `status.ts`), so the runtime here is a thin, testable adapter.\n *\n * Load-bearing rules implemented here:\n * - A tick NEVER steers. Idle dispatch goes through `sendUserMessage(..., {\n * expandPromptTemplates: true })` so a slash payload reaches the real command path;\n * a busy session receives the tick as a follow-up instead.\n * - Shutdown SUSPENDS: timers are cancelled, the ticker disposed, and the snapshot is\n * persisted without a terminal reason (every senpi shutdown reason is resumable).\n * - Keepalive is applied only to an attributed dynamic iteration, never after an ordinary\n * user turn, and never after a user abort (an abort PAUSES the loop instead).\n * - A store failure is not swallowed: the affected loops end with `error` and the user is\n * told, because a schedule that cannot be persisted must not keep running.\n */\n\nimport { homedir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { getAgentDir } from \"../../../../config.ts\";\nimport type { SessionEntry } from \"../../../session-manager.ts\";\nimport { noticeEntryRenderer } from \"../../notice/index.ts\";\nimport type { EntryRenderer, ExtensionAPI, ExtensionContext, ExtensionFactory } from \"../../types.ts\";\nimport { registerLoopCommand } from \"./command-registration.ts\";\nimport { describeCron, normalizeInterval } from \"./cron-planner.ts\";\nimport { type LoopFileResult, nodeFs, resolveLoopFile as resolveLoopFileDefault } from \"./loopfile.ts\";\nimport {\n\tcreateLoopScheduler,\n\ttype LoopClock,\n\ttype LoopIdFactory,\n\ttype LoopScheduler,\n\ttype LoopTick,\n\ttype LoopTimerPort,\n} from \"./scheduler.ts\";\nimport { formatLoopStatus, formatNoopFold, LoopStatusTicker } from \"./status.ts\";\nimport { readLoopState, writeLoopState } from \"./store.ts\";\nimport { buildTickMessage, type LoopFileSnapshot, type LoopMode, type TickDelivery } from \"./tick-prompt.ts\";\nimport { registerLoopTools, SCHEDULE_WAKEUP_TOOL, type ScheduleWakeupTarget } from \"./tools.ts\";\nimport type {\n\tCronEntry,\n\tDeliveryId,\n\tEpochMs,\n\tLoopEndReason,\n\tLoopId,\n\tLoopPayload,\n\tLoopSentinel,\n\tLoopState,\n\tLoopStoreRef,\n\tRequestedInterval,\n\tSentinelDeliveryState,\n} from \"./types.ts\";\n\n/** Custom entry type carrying one dispatched tick, used for attribution and folding. */\nexport const LOOP_TICK_ENTRY_TYPE = \"loop-tick\";\n\nexport interface LoopTickEntryData {\n\treadonly loopId: LoopId;\n\treadonly deliveryId: DeliveryId;\n\treadonly scheduledForAt: EpochMs;\n\treadonly mode: LoopMode;\n\treadonly delivery: TickDelivery;\n\treadonly sentinel?: LoopSentinel;\n\t/** Consecutive quiet dynamic iterations at the moment this tick was dispatched. */\n\treadonly noopStreak: number;\n\t/** True when this tick continues a quiet streak and should render folded. */\n\treadonly folded: boolean;\n}\n\nexport interface LoopCreateOk {\n\treadonly ok: true;\n\treadonly loopId: LoopId;\n\t/** Present when a new dynamic loop replaced a previous one. */\n\treadonly supersededLoopId?: LoopId;\n\t/** Human-readable rounding notice when the requested cadence was normalized. */\n\treadonly roundingNotice?: string;\n\treadonly cronExpression?: string;\n\treadonly effectiveCadence?: string;\n\treadonly expiresAt?: EpochMs;\n}\n\nexport interface LoopCreateRejected {\n\treadonly ok: false;\n\treadonly message: string;\n}\n\nexport type LoopCreateOutcome = LoopCreateOk | LoopCreateRejected;\n\nexport interface LoopStoreFailure {\n\treadonly endReason: LoopEndReason;\n\treadonly message: string;\n\treadonly loopIds: readonly LoopId[];\n}\n\nexport interface StartFixedRequest {\n\treadonly originalArgs: string;\n\treadonly prompt: string;\n\treadonly requestedInterval: RequestedInterval;\n}\n\nexport interface StartDynamicRequest {\n\treadonly originalArgs: string;\n\treadonly prompt: string;\n}\n\nexport interface StartBareRequest {\n\treadonly originalArgs: string;\n\treadonly interval?: RequestedInterval;\n}\n\nexport interface ControllerScheduleWakeupRequest {\n\treadonly loopId: LoopId;\n\treadonly requestedDelaySeconds: number;\n\treadonly delaySeconds: number;\n\treadonly reason: string;\n\treadonly prompt: string;\n\treadonly noop: boolean;\n}\n\n/**\n * Runtime surface of a live loop extension. The `/loop` command module drives the\n * extension exclusively through this interface, so command parsing never reaches into\n * scheduler or store internals.\n */\nexport interface LoopController {\n\tstartFixed(request: StartFixedRequest): Promise<LoopCreateOutcome>;\n\tstartDynamic(request: StartDynamicRequest): Promise<LoopCreateOutcome>;\n\tstartBare(request: StartBareRequest): Promise<LoopCreateOutcome>;\n\t/** Runs the due decision for a loop at the current clock reading and dispatches it. */\n\tfireDue(loopId: LoopId): Promise<void>;\n\tscheduleWakeup(request: ControllerScheduleWakeupRequest): Promise<void>;\n\tstop(target: LoopId | \"all\", detail: string): Promise<readonly LoopId[]>;\n\tpause(target: LoopId | \"all\"): Promise<readonly LoopId[]>;\n\tresume(target: LoopId | \"all\"): Promise<readonly LoopId[]>;\n\tgetState(): LoopState;\n\tstatusLine(): string | undefined;\n\t/** Set when a store read/write failed and the affected loops were ended with `error`. */\n\tlastStoreFailure(): LoopStoreFailure | undefined;\n\t/** True when this loop was retired because its state could not be read or written. */\n\tisEndedWithError(loopId: LoopId): boolean;\n}\n\nexport interface LoopExtensionDeps {\n\treadonly clock?: LoopClock;\n\t/** Factory so each session gets its own timer port; defaults to real timeouts. */\n\treadonly timers?: () => LoopTimerPort;\n\treadonly ids?: LoopIdFactory;\n\treadonly storeRef?: (ctx: ExtensionContext) => LoopStoreRef;\n\treadonly resolveLoopFile?: (options: { cwd: string; homeDir: string }) => Promise<LoopFileResult>;\n\treadonly readState?: (ref: LoopStoreRef) => Promise<LoopState | null>;\n\treadonly writeState?: (ref: LoopStoreRef, state: LoopState) => Promise<void>;\n\t/**\n\t * Published at factory time so a command module (or a test) can drive this instance.\n\t * The controller is bound to the extension's own session state, so it stays valid across\n\t * session starts within one extension generation.\n\t */\n\treadonly onControllerReady?: (controller: LoopController) => void;\n}\n\nexport const renderLoopTickEntry: EntryRenderer<LoopTickEntryData> = noticeEntryRenderer((entry) => {\n\tconst data = entry.data;\n\tif (data === undefined) return undefined;\n\tconst folded = data.folded ? formatNoopFold(data.noopStreak) : \"\";\n\tif (folded.length > 0) {\n\t\treturn {\n\t\t\ttitle: folded,\n\t\t\twhy: \"Consecutive loop ticks reported no actionable change.\",\n\t\t};\n\t}\n\treturn {\n\t\ttitle: `↻ loop tick (${data.mode}) · ${data.delivery}`,\n\t\twhy: \"A /loop schedule dispatched this tick.\",\n\t};\n});\n\n/**\n * Real timer port: exactly one live timeout per key, replaced on re-arm.\n *\n * Follows the generation-counter discipline of `cache-keepalive/index.ts`: cancelling or\n * re-arming a key bumps its generation, so a callback whose generation is stale returns\n * without firing even if it was already scheduled on the event loop.\n */\nexport function createNodeTimerPort(): LoopTimerPort {\n\tconst handles = new Map<string, ReturnType<typeof setTimeout>>();\n\tconst generations = new Map<string, number>();\n\n\tfunction cancel(key: string): void {\n\t\tconst handle = handles.get(key);\n\t\tif (handle !== undefined) clearTimeout(handle);\n\t\thandles.delete(key);\n\t\tgenerations.set(key, (generations.get(key) ?? 0) + 1);\n\t}\n\n\treturn {\n\t\tarm(key, dueAt, callback) {\n\t\t\tcancel(key);\n\t\t\tconst generation = generations.get(key) ?? 0;\n\t\t\tconst delayMs = Math.max(0, dueAt - Date.now());\n\t\t\tconst handle = setTimeout(() => {\n\t\t\t\thandles.delete(key);\n\t\t\t\tif (generations.get(key) !== generation) return;\n\t\t\t\tcallback();\n\t\t\t}, delayMs);\n\t\t\thandle.unref?.();\n\t\t\thandles.set(key, handle);\n\t\t},\n\t\tcancel,\n\t\tcancelAll() {\n\t\t\tfor (const key of [...handles.keys()]) cancel(key);\n\t\t},\n\t};\n}\n\nfunction defaultIds(): LoopIdFactory {\n\tlet sequence = 0;\n\tconst mint = (prefix: string): string => {\n\t\tsequence += 1;\n\t\treturn `${prefix}-${Date.now().toString(36)}-${sequence.toString(36)}`;\n\t};\n\treturn {\n\t\tloopId: () => mint(\"loop\"),\n\t\twakeupId: () => mint(\"wakeup\"),\n\t\tdeliveryId: () => mint(\"delivery\"),\n\t};\n}\n\nfunction defaultStoreRef(ctx: ExtensionContext): LoopStoreRef {\n\tconst sessionFile = ctx.sessionManager.getSessionFile();\n\tconst baseDir =\n\t\tsessionFile === undefined\n\t\t\t? join(getAgentDir(), \"extensions\", \"loop\", \"no-session\")\n\t\t\t: join(ctx.sessionManager.getSessionDir(), \"extensions\", \"loop\");\n\treturn { baseDir, sessionId: ctx.sessionManager.getSessionId() };\n}\n\nfunction emptyDeliveryState(): SentinelDeliveryState {\n\treturn { autonomousPreambleDelivered: false, lastLoopFileDelivered: null, forceFullDelivery: false };\n}\n\nfunction loopFileSnapshot(result: LoopFileResult): LoopFileSnapshot {\n\tif (!result.found) return { present: false };\n\treturn {\n\t\tpresent: true,\n\t\tpath: result.path,\n\t\tcontent: result.content,\n\t\tmtimeMs: result.fingerprint.mtimeMs,\n\t\tsize: result.fingerprint.size,\n\t\tcontentHash: result.fingerprint.contentHash,\n\t};\n}\n\nfunction sentinelFor(mode: LoopMode, loopFilePresent: boolean): LoopSentinel {\n\tif (loopFilePresent) return mode === \"fixed\" ? \"<<loop.md>>\" : \"<<loop.md-dynamic>>\";\n\treturn mode === \"fixed\" ? \"<<autonomous-loop>>\" : \"<<autonomous-loop-dynamic>>\";\n}\n\nfunction modeOf(entry: CronEntry): LoopMode {\n\treturn entry.kind === \"fixed\" ? \"fixed\" : \"dynamic\";\n}\n\ninterface AnchorPayload {\n\treadonly loopId?: string;\n\treadonly deliveryId?: string;\n}\n\n/** Reads the tick payload of a `loop-tick` entry, whichever entry kind carries it. */\nfunction anchorPayloadOf(entry: SessionEntry): AnchorPayload | undefined {\n\tif (entry.type === \"custom\") {\n\t\treturn entry.customType === LOOP_TICK_ENTRY_TYPE ? (entry.data as AnchorPayload | undefined) : undefined;\n\t}\n\tif (entry.type === \"custom_message\") {\n\t\treturn entry.customType === LOOP_TICK_ENTRY_TYPE ? (entry.details as AnchorPayload | undefined) : undefined;\n\t}\n\treturn undefined;\n}\n\n/**\n * True when the compaction-aware context still contains the delivery that anchored a full\n * sentinel block. Compaction can drop it, and a reminder's \"established earlier in this\n * conversation\" phrasing must never dangle, so a missing anchor forces the next tick back\n * to full. When no specific anchor id was recorded (the autonomous preamble carries none),\n * any surviving tick delivery for that loop counts as the anchor.\n */\nfunction anchorPresent(ctx: ExtensionContext, loopId: LoopId, deliveryId: DeliveryId | undefined): boolean {\n\treturn ctx.sessionManager.buildContextEntries().some((entry) => {\n\t\tconst payload = anchorPayloadOf(entry);\n\t\tif (payload === undefined) return false;\n\t\tif (payload.loopId !== undefined && payload.loopId !== loopId) return false;\n\t\treturn deliveryId === undefined ? true : payload.deliveryId === deliveryId;\n\t});\n}\n\nexport function createLoopExtension(deps: LoopExtensionDeps = {}): ExtensionFactory {\n\tconst clock: LoopClock = deps.clock ?? { now: () => Date.now() };\n\tconst makeTimers = deps.timers ?? createNodeTimerPort;\n\tconst ids = deps.ids ?? defaultIds();\n\tconst storeRefOf = deps.storeRef ?? defaultStoreRef;\n\tconst resolveLoopFile =\n\t\tdeps.resolveLoopFile ??\n\t\t((options: { cwd: string; homeDir: string }) =>\n\t\t\tresolveLoopFileDefault({ cwd: options.cwd, homeDir: options.homeDir, fs: nodeFs, path: { join } }));\n\tconst readState = deps.readState ?? readLoopState;\n\tconst writeState = deps.writeState ?? writeLoopState;\n\n\treturn (pi: ExtensionAPI) => {\n\t\tlet ctx: ExtensionContext | undefined;\n\t\tlet scheduler: LoopScheduler | undefined;\n\t\tlet storeRef: LoopStoreRef | undefined;\n\t\tlet timers: LoopTimerPort = makeTimers();\n\t\tlet storeFailure: LoopStoreFailure | undefined;\n\t\tlet sessionNamed = false;\n\t\t/** Loop the currently running iteration is attributed to, for keepalive + tools. */\n\t\tlet attributedLoopId: LoopId | undefined;\n\t\t/** Delivery id of the tick that started the attributed iteration. */\n\t\tlet attributedDeliveryId: DeliveryId | undefined;\n\t\t/** True once the attributed iteration rescheduled or stopped itself. */\n\t\tlet attributionResolved = false;\n\t\t/** Ticks held back because their slash payload cannot be queued while streaming. */\n\t\tconst deferredDispatches: LoopTick[] = [];\n\t\tconst deliveryStates = new Map<LoopId, SentinelDeliveryState>();\n\t\t/** Loops retired with `error` because their state could not be read or written. */\n\t\tconst endedWithError = new Set<LoopId>();\n\t\t/** True once this session has state worth persisting (loaded or created). */\n\t\tlet storeTouched = false;\n\t\tlet persistTail: Promise<void> = Promise.resolve();\n\n\t\tconst ticker = new LoopStatusTicker({\n\t\t\trender: (key, text) => {\n\t\t\t\ttry {\n\t\t\t\t\tctx?.ui.setStatus(key, text);\n\t\t\t\t} catch {\n\t\t\t\t\t// A stale context after session replacement must not break the loop runtime.\n\t\t\t\t}\n\t\t\t},\n\t\t\tnow: () => clock.now(),\n\t\t});\n\n\t\tpi.registerEntryRenderer(LOOP_TICK_ENTRY_TYPE, renderLoopTickEntry);\n\t\tregisterLoopTools(pi, {\n\t\t\tscheduler: {\n\t\t\t\tgetWakeupTarget: (): ScheduleWakeupTarget => {\n\t\t\t\t\tif (scheduler === undefined || attributedLoopId === undefined) return null;\n\t\t\t\t\tconst entry = scheduler.getState().entries[attributedLoopId];\n\t\t\t\t\tif (entry === undefined || entry.phase === \"ended\") return null;\n\t\t\t\t\treturn { kind: entry.kind, loopId: entry.id };\n\t\t\t\t},\n\t\t\t\tscheduleWakeup: async (request) => {\n\t\t\t\t\tconst active = requireScheduler();\n\t\t\t\t\tconst result = active.onScheduleWakeup(request);\n\t\t\t\t\tif (!result.ok) throw new Error(`schedule_wakeup rejected: ${result.reason}`);\n\t\t\t\t\tattributionResolved = true;\n\t\t\t\t\tawait persist();\n\t\t\t\t\trefreshStatus();\n\t\t\t\t\treturn {\n\t\t\t\t\t\twakeupId: result.wakeupId,\n\t\t\t\t\t\t...(result.replacedWakeupId === undefined ? {} : { replacedWakeupId: result.replacedWakeupId }),\n\t\t\t\t\t\tdueAt: result.dueAt,\n\t\t\t\t\t\tnoopStreak: result.noopStreak,\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t\tstopDynamicLoop: async (request) => {\n\t\t\t\t\tconst active = requireScheduler();\n\t\t\t\t\tactive.stop(request.loopId, \"model-stop\");\n\t\t\t\t\tattributionResolved = true;\n\t\t\t\t\tawait persist();\n\t\t\t\t\trefreshStatus();\n\t\t\t\t\treturn { endedAt: clock.now() };\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\n\t\tfunction requireScheduler(): LoopScheduler {\n\t\t\tif (scheduler === undefined) throw new Error(\"loop extension has no active session\");\n\t\t\treturn scheduler;\n\t\t}\n\n\t\t/** Merges extension-owned sentinel delivery state into the scheduler's snapshot. */\n\t\tfunction withDeliveryOverlay(state: LoopState): LoopState {\n\t\t\tconst entries: Record<LoopId, CronEntry> = {};\n\t\t\tfor (const [id, entry] of Object.entries(state.entries)) {\n\t\t\t\tconst delivery = deliveryStates.get(id);\n\t\t\t\tentries[id] = delivery === undefined ? entry : { ...entry, sentinelDelivery: delivery };\n\t\t\t}\n\t\t\treturn { ...state, entries };\n\t\t}\n\n\t\t/** Serializes persistence so a timer, tool, and command write cannot interleave. */\n\t\tfunction persist(): Promise<void> {\n\t\t\tconst ref = storeRef;\n\t\t\tconst active = scheduler;\n\t\t\tif (ref === undefined || active === undefined) return Promise.resolve();\n\t\t\tconst snapshot = withDeliveryOverlay(active.getState());\n\t\t\t// The extension is registered for every session, so a session that never ran a loop\n\t\t\t// must not leave a sidecar behind.\n\t\t\tif (!storeTouched && Object.keys(snapshot.entries).length === 0) return Promise.resolve();\n\t\t\tstoreTouched = true;\n\t\t\tpersistTail = persistTail.then(async () => {\n\t\t\t\ttry {\n\t\t\t\t\tawait writeState(ref, snapshot);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tfailStore(error, Object.keys(snapshot.entries));\n\t\t\t\t}\n\t\t\t});\n\t\t\treturn persistTail;\n\t\t}\n\n\t\t/**\n\t\t * A schedule that cannot be read or written must not keep running: end the affected\n\t\t * loops with `error` and tell the user, rather than silently losing the schedule. The\n\t\t * terminal record is kept in memory because the store that would hold it is exactly the\n\t\t * thing that just failed; what matters is that nothing stays armed and the user knows.\n\t\t */\n\t\tfunction failStore(error: unknown, loopIds: readonly LoopId[]): void {\n\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\ttimers.cancelAll();\n\t\t\tfor (const loopId of loopIds) endedWithError.add(loopId);\n\t\t\tstoreFailure = {\n\t\t\t\tendReason: \"error\",\n\t\t\t\tmessage,\n\t\t\t\tloopIds,\n\t\t\t};\n\t\t\tticker.dispose();\n\t\t\tctx?.ui.notify(`/loop state could not be used and the affected loops were ended: ${message}`, \"error\");\n\t\t}\n\n\t\t/**\n\t\t * `schedule_wakeup` is search-exposed, so it is callable only while this extension keeps it\n\t\t * active: exactly when a dynamic loop is live (not ended, not suspended). Idempotent, so\n\t\t * every state transition can call it without churning the active tool list.\n\t\t */\n\t\tfunction syncScheduleWakeupActivation(): void {\n\t\t\tif (scheduler === undefined) return;\n\t\t\tconst wanted = Object.values(scheduler.getState().entries).some(\n\t\t\t\t(entry) => entry.kind === \"dynamic\" && entry.phase !== \"ended\" && entry.phase !== \"suspended\",\n\t\t\t);\n\t\t\tconst active = pi.getActiveTools();\n\t\t\tconst present = active.includes(SCHEDULE_WAKEUP_TOOL);\n\t\t\tif (wanted === present) return;\n\t\t\tpi.setActiveTools(\n\t\t\t\twanted ? [...active, SCHEDULE_WAKEUP_TOOL] : active.filter((name) => name !== SCHEDULE_WAKEUP_TOOL),\n\t\t\t);\n\t\t}\n\n\t\tfunction refreshStatus(): void {\n\t\t\tsyncScheduleWakeupActivation();\n\t\t\tif (scheduler === undefined) return;\n\t\t\tconst state = scheduler.getState();\n\t\t\t// The ticker owns a repeating render timer, so it only runs while a loop is armed;\n\t\t\t// a session that never used /loop must not carry one.\n\t\t\tif (Object.values(state.entries).every((entry) => entry.phase === \"ended\")) {\n\t\t\t\tif (ticker.running) ticker.dispose();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tticker.sync(state);\n\t\t}\n\n\t\tfunction deliveryStateOf(loopId: LoopId): SentinelDeliveryState {\n\t\t\treturn deliveryStates.get(loopId) ?? emptyDeliveryState();\n\t\t}\n\n\t\tfunction markForceFullDelivery(): void {\n\t\t\tfor (const [id, state] of deliveryStates) {\n\t\t\t\tdeliveryStates.set(id, { ...state, forceFullDelivery: true });\n\t\t\t}\n\t\t\tconst active = scheduler;\n\t\t\tif (active === undefined) return;\n\t\t\tfor (const entry of Object.values(active.getState().entries)) {\n\t\t\t\tif (entry.phase === \"ended\") continue;\n\t\t\t\tif (deliveryStates.has(entry.id)) continue;\n\t\t\t\tdeliveryStates.set(entry.id, { ...entry.sentinelDelivery, forceFullDelivery: true });\n\t\t\t}\n\t\t}\n\n\t\tfunction isExtensionCommandPayload(text: string): boolean {\n\t\t\tif (!text.startsWith(\"/\")) return false;\n\t\t\tconst name = text.slice(1).split(/\\s+/)[0];\n\t\t\treturn pi.getCommands().some((command) => command.name === name);\n\t\t}\n\n\t\t/**\n\t\t * Delivers one tick. Idle dispatch expands prompt templates so a slash payload\n\t\t * reaches its real command handler; a busy session gets a follow-up instead of\n\t\t * steering. A slash payload cannot be queued at all, so it waits for the turn to\n\t\t * settle rather than being rewritten into plain text.\n\t\t */\n\t\tasync function dispatchTick(tick: LoopTick): Promise<void> {\n\t\t\tconst active = requireScheduler();\n\t\t\tconst entry = active.getState().entries[tick.loopId];\n\t\t\tif (entry === undefined || entry.phase === \"ended\") return;\n\t\t\tif (endedWithError.has(tick.loopId)) return;\n\t\t\tconst currentCtx = ctx;\n\t\t\tif (currentCtx === undefined) return;\n\n\t\t\tconst mode = modeOf(entry);\n\t\t\tconst loopFile =\n\t\t\t\tentry.payload.type === \"sentinel\" ? await resolveLoopFileSafely(currentCtx) : { found: false as const };\n\t\t\tconst built = buildTickMessage({\n\t\t\t\tloopId: entry.id,\n\t\t\t\tdeliveryId: tick.deliveryId,\n\t\t\t\tmode,\n\t\t\t\tpayload: entry.payload,\n\t\t\t\treentryPrompt: entry.reentryPrompt,\n\t\t\t\tdeliveryState: deliveryStateOf(entry.id),\n\t\t\t\tloopFile: loopFileSnapshot(loopFile),\n\t\t\t});\n\t\t\tdeliveryStates.set(entry.id, built.deliveryState);\n\n\t\t\tconst busy = !currentCtx.isIdle() || currentCtx.hasPendingMessages();\n\t\t\tif (busy && isExtensionCommandPayload(built.text)) {\n\t\t\t\t// Extension commands cannot be queued; hold this delivery until the turn settles.\n\t\t\t\tdeferredDispatches.push(tick);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst noopStreak = entry.noopStreak;\n\t\t\tpi.appendEntry<LoopTickEntryData>(LOOP_TICK_ENTRY_TYPE, {\n\t\t\t\tloopId: entry.id,\n\t\t\t\tdeliveryId: tick.deliveryId,\n\t\t\t\tscheduledForAt: tick.scheduledForAt,\n\t\t\t\tmode,\n\t\t\t\tdelivery: built.delivery,\n\t\t\t\t...(built.details.sentinel === undefined ? {} : { sentinel: built.details.sentinel }),\n\t\t\t\tnoopStreak,\n\t\t\t\tfolded: noopStreak >= 2,\n\t\t\t});\n\n\t\t\tattributedLoopId = entry.id;\n\t\t\tattributedDeliveryId = tick.deliveryId;\n\t\t\tattributionResolved = false;\n\t\t\t// The tick prompt tells the model to call schedule_wakeup, so the tool must be active\n\t\t\t// before the tick is queued, not after the turn has already read its tool list.\n\t\t\tsyncScheduleWakeupActivation();\n\t\t\tpi.sendUserMessage(built.text, {\n\t\t\t\texpandPromptTemplates: true,\n\t\t\t\t...(busy ? { deliverAs: \"followUp\" as const } : {}),\n\t\t\t});\n\t\t\tawait persist();\n\t\t\trefreshStatus();\n\t\t}\n\n\t\tasync function resolveLoopFileSafely(currentCtx: ExtensionContext): Promise<LoopFileResult> {\n\t\t\ttry {\n\t\t\t\treturn await resolveLoopFile({ cwd: currentCtx.cwd, homeDir: homedir() });\n\t\t\t} catch {\n\t\t\t\t// A loop file that cannot be read is treated as absent for this tick; the loop\n\t\t\t\t// stays alive and picks the file up again once it is readable.\n\t\t\t\treturn { found: false };\n\t\t\t}\n\t\t}\n\n\t\tasync function drainDeferred(): Promise<void> {\n\t\t\tif (deferredDispatches.length === 0) return;\n\t\t\tconst pending = deferredDispatches.splice(0, deferredDispatches.length);\n\t\t\tfor (const tick of pending) await dispatchTick(tick);\n\t\t}\n\n\t\tasync function fireDue(loopId: LoopId): Promise<void> {\n\t\t\tconst active = scheduler;\n\t\t\tconst currentCtx = ctx;\n\t\t\tif (active === undefined || currentCtx === undefined) return;\n\t\t\tconst busy = !currentCtx.isIdle() || currentCtx.hasPendingMessages();\n\t\t\tconst decision = active.onDue(loopId, clock.now(), busy);\n\t\t\tawait persist();\n\t\t\tif (decision.action === \"dispatch\") {\n\t\t\t\tawait dispatchTick(decision.tick);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (decision.action === \"expire\") {\n\t\t\t\tctx?.ui.notify(\"Loop expired after 7 days and is no longer armed.\", \"info\");\n\t\t\t}\n\t\t\trefreshStatus();\n\t\t}\n\n\t\t/**\n\t\t * Timer callbacks are synchronous, so the async due step is scheduled and its failure is\n\t\t * contained: a rejected dispatch must never take down the timer that owns the loop.\n\t\t */\n\t\tfunction handleTimerFire(loopId: LoopId): void {\n\t\t\tvoid fireDue(loopId).catch((error) => {\n\t\t\t\tctx?.ui.notify(`Loop tick failed: ${error instanceof Error ? error.message : String(error)}`, \"error\");\n\t\t\t});\n\t\t}\n\n\t\tfunction payloadForPrompt(prompt: string): LoopPayload {\n\t\t\treturn { type: \"prompt\", prompt };\n\t\t}\n\n\t\tasync function startFixed(request: StartFixedRequest): Promise<LoopCreateOutcome> {\n\t\t\tconst active = requireScheduler();\n\t\t\tconst effective = normalizeInterval(request.requestedInterval);\n\t\t\tconst created = active.createFixed({\n\t\t\t\toriginalArgs: request.originalArgs,\n\t\t\t\treentryPrompt: `/loop ${request.originalArgs}`.trimEnd(),\n\t\t\t\tpayload: payloadForPrompt(request.prompt),\n\t\t\t\trequestedInterval: request.requestedInterval,\n\t\t\t\teffectiveInterval: effective,\n\t\t\t\tcronExpression: describeCron(effective),\n\t\t\t\tintervalMs: effective.intervalMs,\n\t\t\t});\n\t\t\tif (!created.ok) return { ok: false, message: created.message };\n\t\t\tdeliveryStates.set(created.loopId, emptyDeliveryState());\n\t\t\tawait persist();\n\t\t\tnameSessionAfterLoop(request.prompt);\n\t\t\tawait fireDue(created.loopId);\n\t\t\trefreshStatus();\n\t\t\treturn {\n\t\t\t\tok: true,\n\t\t\t\tloopId: created.loopId,\n\t\t\t\t...(effective.roundingNotice === undefined ? {} : { roundingNotice: effective.roundingNotice }),\n\t\t\t\tcronExpression: describeCron(effective),\n\t\t\t\teffectiveCadence: effective.human,\n\t\t\t\texpiresAt: active.getState().entries[created.loopId]?.expiresAt,\n\t\t\t};\n\t\t}\n\n\t\tasync function startDynamic(request: StartDynamicRequest): Promise<LoopCreateOutcome> {\n\t\t\tconst active = requireScheduler();\n\t\t\tconst created = active.createDynamic({\n\t\t\t\toriginalArgs: request.originalArgs,\n\t\t\t\treentryPrompt: `/loop ${request.originalArgs}`.trimEnd(),\n\t\t\t\tpayload: payloadForPrompt(request.prompt),\n\t\t\t});\n\t\t\tif (!created.ok) return { ok: false, message: created.message };\n\t\t\tdeliveryStates.set(created.loopId, emptyDeliveryState());\n\t\t\tawait persist();\n\t\t\tnameSessionAfterLoop(request.prompt);\n\t\t\tawait fireDue(created.loopId);\n\t\t\trefreshStatus();\n\t\t\treturn {\n\t\t\t\tok: true,\n\t\t\t\tloopId: created.loopId,\n\t\t\t\t...(created.supersededLoopId === undefined ? {} : { supersededLoopId: created.supersededLoopId }),\n\t\t\t\texpiresAt: active.getState().entries[created.loopId]?.expiresAt,\n\t\t\t};\n\t\t}\n\n\t\tasync function startBare(request: StartBareRequest): Promise<LoopCreateOutcome> {\n\t\t\tconst active = requireScheduler();\n\t\t\tconst currentCtx = ctx;\n\t\t\tif (currentCtx === undefined) return { ok: false, message: \"loop extension has no active session\" };\n\t\t\tconst loopFile = await resolveLoopFileSafely(currentCtx);\n\t\t\tconst mode: LoopMode = request.interval === undefined ? \"dynamic\" : \"fixed\";\n\t\t\tconst payload: LoopPayload = { type: \"sentinel\", sentinel: sentinelFor(mode, loopFile.found) };\n\t\t\tconst reentryPrompt = request.originalArgs.trim() === \"\" ? \"/loop\" : `/loop ${request.originalArgs.trim()}`;\n\n\t\t\tconst created =\n\t\t\t\trequest.interval === undefined\n\t\t\t\t\t? active.createDynamic({ originalArgs: request.originalArgs, reentryPrompt, payload })\n\t\t\t\t\t: (() => {\n\t\t\t\t\t\t\tconst effective = normalizeInterval(request.interval);\n\t\t\t\t\t\t\treturn active.createFixed({\n\t\t\t\t\t\t\t\toriginalArgs: request.originalArgs,\n\t\t\t\t\t\t\t\treentryPrompt,\n\t\t\t\t\t\t\t\tpayload,\n\t\t\t\t\t\t\t\trequestedInterval: request.interval,\n\t\t\t\t\t\t\t\teffectiveInterval: effective,\n\t\t\t\t\t\t\t\tcronExpression: describeCron(effective),\n\t\t\t\t\t\t\t\tintervalMs: effective.intervalMs,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t})();\n\t\t\tif (!created.ok) return { ok: false, message: created.message };\n\t\t\tdeliveryStates.set(created.loopId, emptyDeliveryState());\n\t\t\tawait persist();\n\t\t\tnameSessionAfterLoop(reentryPrompt);\n\t\t\tawait fireDue(created.loopId);\n\t\t\trefreshStatus();\n\t\t\treturn {\n\t\t\t\tok: true,\n\t\t\t\tloopId: created.loopId,\n\t\t\t\texpiresAt: active.getState().entries[created.loopId]?.expiresAt,\n\t\t\t};\n\t\t}\n\n\t\tfunction nameSessionAfterLoop(prompt: string): void {\n\t\t\tif (sessionNamed) return;\n\t\t\tsessionNamed = true;\n\t\t\tif (pi.getSessionName() !== undefined) return;\n\t\t\tpi.setSessionName(`loop: ${prompt}`.trim());\n\t\t}\n\n\t\tconst controller: LoopController = {\n\t\t\tstartFixed,\n\t\t\tstartDynamic,\n\t\t\tstartBare,\n\t\t\tfireDue,\n\t\t\tscheduleWakeup: async (request) => {\n\t\t\t\tconst active = requireScheduler();\n\t\t\t\tconst result = active.onScheduleWakeup(request);\n\t\t\t\tif (result.ok) attributionResolved = true;\n\t\t\t\tawait persist();\n\t\t\t\trefreshStatus();\n\t\t\t},\n\t\t\tstop: async (target, detail) => {\n\t\t\t\tconst active = requireScheduler();\n\t\t\t\tconst result = active.stop(target, detail);\n\t\t\t\tawait persist();\n\t\t\t\trefreshStatus();\n\t\t\t\treturn result.affectedLoopIds;\n\t\t\t},\n\t\t\tpause: async (target) => {\n\t\t\t\tconst active = requireScheduler();\n\t\t\t\tconst result = active.pause(target);\n\t\t\t\tawait persist();\n\t\t\t\trefreshStatus();\n\t\t\t\treturn result.affectedLoopIds;\n\t\t\t},\n\t\t\tresume: async (target) => {\n\t\t\t\tconst active = requireScheduler();\n\t\t\t\tconst result = active.resume(target);\n\t\t\t\tawait persist();\n\t\t\t\trefreshStatus();\n\t\t\t\treturn result.affectedLoopIds;\n\t\t\t},\n\t\t\tgetState: () => requireScheduler().getState(),\n\t\t\tstatusLine: () => formatLoopStatus(requireScheduler().getState(), clock.now()),\n\t\t\tlastStoreFailure: () => storeFailure,\n\t\t\tisEndedWithError: (loopId) => endedWithError.has(loopId),\n\t\t};\n\n\t\tdeps.onControllerReady?.(controller);\n\t\tregisterLoopCommand(pi, { controller });\n\n\t\tpi.on(\"session_start\", async (_event, nextCtx) => {\n\t\t\tctx = nextCtx;\n\t\t\ttimers.cancelAll();\n\t\t\ttimers = makeTimers();\n\t\t\tstoreFailure = undefined;\n\t\t\tendedWithError.clear();\n\t\t\tstoreTouched = false;\n\t\t\tsessionNamed = false;\n\t\t\tattributedLoopId = undefined;\n\t\t\tattributedDeliveryId = undefined;\n\t\t\tattributionResolved = false;\n\t\t\tdeferredDispatches.length = 0;\n\t\t\tdeliveryStates.clear();\n\t\t\tstoreRef = storeRefOf(nextCtx);\n\n\t\t\tlet initialState: LoopState | undefined;\n\t\t\ttry {\n\t\t\t\tinitialState = (await readState(storeRef)) ?? undefined;\n\t\t\t} catch (error) {\n\t\t\t\t// Fail closed: arm nothing, end nothing silently, and tell the user.\n\t\t\t\tfailStore(error, []);\n\t\t\t\tscheduler = createLoopScheduler({\n\t\t\t\t\tsessionId: nextCtx.sessionManager.getSessionId(),\n\t\t\t\t\tclock,\n\t\t\t\t\ttimers,\n\t\t\t\t\tids,\n\t\t\t\t\tonFire: handleTimerFire,\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tscheduler = createLoopScheduler({\n\t\t\t\tsessionId: nextCtx.sessionManager.getSessionId(),\n\t\t\t\tclock,\n\t\t\t\ttimers,\n\t\t\t\tids,\n\t\t\t\tonFire: handleTimerFire,\n\t\t\t\t...(initialState === undefined ? {} : { initialState }),\n\t\t\t});\n\t\t\tstoreTouched = initialState !== undefined;\n\n\t\t\tfor (const entry of Object.values(scheduler.getState().entries)) {\n\t\t\t\tconst anchorDeliveryId = entry.sentinelDelivery.lastLoopFileDelivered?.anchorDeliveryId;\n\t\t\t\tconst anchored = anchorPresent(nextCtx, entry.id, anchorDeliveryId);\n\t\t\t\tconst needsFull = !anchored && hasAnchoredDelivery(entry.sentinelDelivery);\n\t\t\t\tdeliveryStates.set(entry.id, {\n\t\t\t\t\t...entry.sentinelDelivery,\n\t\t\t\t\tforceFullDelivery: entry.sentinelDelivery.forceFullDelivery || needsFull,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst restored = scheduler.restore(clock.now());\n\t\t\tawait persist();\n\t\t\trefreshStatus();\n\t\t\tfor (const tick of restored.recoveryTicks) await dispatchTick(tick);\n\t\t\tif (restored.expiredLoopIds.length > 0) {\n\t\t\t\tnextCtx.ui.notify(`Loop expired after 7 days: ${restored.expiredLoopIds.join(\", \")}`, \"info\");\n\t\t\t}\n\t\t});\n\n\t\tpi.on(\"session_compact\", async (event) => {\n\t\t\t// Accepted compaction may have dropped the anchor the reminders point at, so the\n\t\t\t// next sentinel tick must carry the full instructions again. Timers and phase are\n\t\t\t// deliberately untouched.\n\t\t\tif (event.accepted !== true) return;\n\t\t\tmarkForceFullDelivery();\n\t\t\tawait persist();\n\t\t});\n\n\t\tpi.on(\"input\", async (event) => {\n\t\t\t// A user turn is never an attributed loop iteration, so keepalive must not see it.\n\t\t\t// A tick dispatched by this extension arrives with source \"extension\" and MUST keep\n\t\t\t// its attribution, or no dynamic iteration would ever be judged.\n\t\t\tif (event.source === \"extension\") return;\n\t\t\tattributedLoopId = undefined;\n\t\t\tattributedDeliveryId = undefined;\n\t\t\tattributionResolved = false;\n\t\t});\n\n\t\tpi.on(\"agent_end\", async (event) => {\n\t\t\t// A retrying turn is still in progress: neither settle it nor judge its liveness.\n\t\t\tif (event.willRetry === true) return;\n\t\t\tif (event.aborted === true && event.abortSource === \"user\") {\n\t\t\t\tawait pauseAttributedLoop();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tawait settleAttributedTick(event.aborted === true ? \"error\" : \"completed\");\n\t\t});\n\n\t\tpi.on(\"agent_settled\", async () => {\n\t\t\tawait settleAttributedTick(\"completed\");\n\t\t\tawait drainDeferred();\n\t\t\trefreshStatus();\n\t\t});\n\n\t\tpi.on(\"session_abort\", async () => {\n\t\t\tawait pauseAttributedLoop();\n\t\t});\n\n\t\tpi.on(\"session_shutdown\", async () => {\n\t\t\tconst active = scheduler;\n\t\t\tif (active !== undefined) {\n\t\t\t\t// Shutdown SUSPENDS: every senpi shutdown reason leaves the session resumable,\n\t\t\t\t// so the snapshot must carry no terminal reason.\n\t\t\t\tactive.onShutdown();\n\t\t\t\tawait persist();\n\t\t\t}\n\t\t\ttimers.cancelAll();\n\t\t\tdeferredDispatches.length = 0;\n\t\t\tticker.dispose();\n\t\t\tattributedLoopId = undefined;\n\t\t\tattributedDeliveryId = undefined;\n\t\t\tattributionResolved = false;\n\t\t\tctx = undefined;\n\t\t});\n\n\t\tasync function pauseAttributedLoop(): Promise<void> {\n\t\t\tconst active = scheduler;\n\t\t\tif (active === undefined) return;\n\t\t\tconst targets =\n\t\t\t\tattributedLoopId === undefined\n\t\t\t\t\t? Object.values(active.getState().entries)\n\t\t\t\t\t\t\t.filter((entry) => entry.phase !== \"ended\")\n\t\t\t\t\t\t\t.map((entry) => entry.id)\n\t\t\t\t\t: [attributedLoopId];\n\t\t\tconst paused: LoopId[] = [];\n\t\t\tfor (const loopId of targets) {\n\t\t\t\tif (active.onUserAbort(loopId).action === \"paused\") paused.push(loopId);\n\t\t\t}\n\t\t\tattributedLoopId = undefined;\n\t\t\tattributedDeliveryId = undefined;\n\t\t\tattributionResolved = false;\n\t\t\tif (paused.length === 0) return;\n\t\t\tawait persist();\n\t\t\trefreshStatus();\n\t\t\tctx?.ui.notify(\"loop paused - /loop resume or /loop stop\", \"info\");\n\t\t}\n\n\t\t/**\n\t\t * Settles the tick this turn was attributed to, drains a coalesced occurrence, and\n\t\t * applies the two-strike keepalive to a dynamic iteration that ended without calling\n\t\t * `schedule_wakeup`. An ordinary user turn clears the attribution first, so keepalive\n\t\t * can never be charged to it, and a user abort takes the pause path instead.\n\t\t */\n\t\tasync function settleAttributedTick(outcome: \"completed\" | \"error\"): Promise<void> {\n\t\t\tconst active = scheduler;\n\t\t\tconst loopId = attributedLoopId;\n\t\t\tconst deliveryId = attributedDeliveryId;\n\t\t\tif (active === undefined || loopId === undefined) return;\n\t\t\tconst entry = active.getState().entries[loopId];\n\t\t\tif (entry === undefined) return;\n\t\t\tconst resolved = attributionResolved;\n\t\t\tattributedLoopId = undefined;\n\t\t\tattributedDeliveryId = undefined;\n\t\t\tattributionResolved = false;\n\n\t\t\tconst settled = deliveryId === undefined ? undefined : active.onTickSettled({ loopId, deliveryId, outcome });\n\t\t\tawait persist();\n\n\t\t\tif (!resolved && entry.kind === \"dynamic\") {\n\t\t\t\tconst keepalive = active.onTurnEndedWithoutSchedule(loopId);\n\t\t\t\tawait persist();\n\t\t\t\trefreshStatus();\n\t\t\t\tif (keepalive.action === \"ended\") {\n\t\t\t\t\tctx?.ui.notify(\n\t\t\t\t\t\tkeepalive.endReason === \"keepalive_exhausted\"\n\t\t\t\t\t\t\t? \"Loop ended: the model stopped scheduling wakeups.\"\n\t\t\t\t\t\t\t: \"Loop expired after 7 days and is no longer armed.\",\n\t\t\t\t\t\t\"info\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (settled?.action === \"dispatch\") {\n\t\t\t\t// Exactly one delivery drains a coalesced occurrence, however many were missed.\n\t\t\t\tawait dispatchTick(settled.tick);\n\t\t\t} else if (settled?.action === \"ended\") {\n\t\t\t\tctx?.ui.notify(`Loop ended: ${settled.endReason}.`, \"info\");\n\t\t\t}\n\t\t\trefreshStatus();\n\t\t}\n\t};\n}\n\n/** True when a reminder would refer back to a full delivery that must still exist. */\nfunction hasAnchoredDelivery(state: SentinelDeliveryState): boolean {\n\treturn state.autonomousPreambleDelivered || state.lastLoopFileDelivered !== null;\n}\n\nexport default createLoopExtension();\n"]}
|
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Atomic, versioned, per-session sidecar store for `/loop` state.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* Persistence (temp file + rename, per-file mutation serialization, envelope
|
|
5
|
+
* version/session checks) lives in the shared session sidecar primitive. This
|
|
6
|
+
* module supplies the loop domain parser and keeps the historical exported
|
|
7
|
+
* surface so callers continue to catch {@link InvalidLoopStoreError} /
|
|
8
|
+
* {@link UnsupportedLoopStoreVersionError} by name.
|
|
8
9
|
*
|
|
9
10
|
* Session custom entries are deliberately NOT the authoritative store: they are branch
|
|
10
11
|
* nodes, so a globally scanned "latest" entry can come from an abandoned branch, while
|
|
11
12
|
* loop schedules are session-scoped.
|
|
12
13
|
*/
|
|
14
|
+
import { InvalidSidecarStoreError, UnsupportedSidecarStoreVersionError } from "../../../session-sidecar-store.ts";
|
|
13
15
|
import { type LoopState, type LoopStoreRef } from "./types.ts";
|
|
14
|
-
export declare class InvalidLoopStoreError extends
|
|
16
|
+
export declare class InvalidLoopStoreError extends InvalidSidecarStoreError {
|
|
15
17
|
constructor(message: string, options?: {
|
|
16
18
|
cause?: unknown;
|
|
17
19
|
});
|
|
18
20
|
}
|
|
19
|
-
export declare class UnsupportedLoopStoreVersionError extends
|
|
21
|
+
export declare class UnsupportedLoopStoreVersionError extends UnsupportedSidecarStoreVersionError {
|
|
20
22
|
constructor(message: string);
|
|
21
23
|
}
|
|
22
24
|
/** Mutation callback. May be async; its result becomes the next persisted state. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/loop/store.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/loop/store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAGN,wBAAwB,EAIxB,mCAAmC,EACnC,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAqBN,KAAK,SAAS,EACd,KAAK,YAAY,EAQjB,MAAM,YAAY,CAAC;AAEpB,qBAAa,qBAAsB,SAAQ,wBAAwB;gBACtD,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;CAI1D;AAED,qBAAa,gCAAiC,SAAQ,mCAAmC;gBAC5E,OAAO,EAAE,MAAM;CAI3B;AAED,oFAAoF;AACpF,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,EAAE,SAAS,KAAK,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;AAIvF,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,YAAY,GAAG,MAAM,CAE1D;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,YAAY,GAAG,MAAM,CAE3D;AAED,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAE3D;AA8BD;;;;GAIG;AACH,wBAAsB,aAAa,CAAC,GAAG,EAAE,YAAY,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,CAMhF;AAED,wFAAwF;AACxF,wBAAsB,aAAa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