glirastes 0.3.2 → 0.5.0
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 +386 -1
- package/README.md +304 -853
- package/adapter/nextjs/package.json +5 -0
- package/ai-sdk/package.json +5 -0
- package/browser/package.json +5 -0
- package/contracts/package.json +5 -0
- package/dist/agent/git.d.ts +65 -0
- package/dist/agent/git.js +122 -0
- package/dist/agent/git.js.map +1 -0
- package/dist/agent/openrouter.d.ts +56 -0
- package/dist/agent/openrouter.js +74 -0
- package/dist/agent/openrouter.js.map +1 -0
- package/dist/agent/platform-jobs.d.ts +102 -0
- package/dist/agent/platform-jobs.js +122 -0
- package/dist/agent/platform-jobs.js.map +1 -0
- package/dist/agent/runner.d.ts +150 -0
- package/dist/agent/runner.js +250 -0
- package/dist/agent/runner.js.map +1 -0
- package/dist/agent/workspace.d.ts +65 -0
- package/dist/agent/workspace.js +264 -0
- package/dist/agent/workspace.js.map +1 -0
- package/dist/browser/client-actions.d.ts +26 -0
- package/dist/browser/client-actions.js +42 -0
- package/dist/browser/client-actions.js.map +1 -0
- package/dist/browser/index.d.ts +4 -0
- package/dist/browser/index.js +5 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/browser/navigation.d.ts +32 -0
- package/dist/browser/navigation.js +79 -0
- package/dist/browser/navigation.js.map +1 -0
- package/dist/browser/query-filters.d.ts +30 -0
- package/dist/browser/query-filters.js +85 -0
- package/dist/browser/query-filters.js.map +1 -0
- package/dist/browser/ui-action-bus.d.ts +26 -0
- package/dist/browser/ui-action-bus.js +66 -0
- package/dist/browser/ui-action-bus.js.map +1 -0
- package/dist/cjs/browser/client-actions.d.ts +26 -0
- package/dist/cjs/browser/client-actions.js +45 -0
- package/dist/cjs/browser/index.d.ts +4 -0
- package/dist/cjs/browser/index.js +16 -0
- package/dist/cjs/browser/navigation.d.ts +32 -0
- package/dist/cjs/browser/navigation.js +84 -0
- package/dist/cjs/browser/query-filters.d.ts +30 -0
- package/dist/cjs/browser/query-filters.js +87 -0
- package/dist/cjs/browser/ui-action-bus.d.ts +26 -0
- package/dist/cjs/browser/ui-action-bus.js +70 -0
- package/dist/cjs/codegen/execution-inventory.d.ts +63 -0
- package/dist/cjs/codegen/execution-inventory.js +312 -0
- package/dist/cjs/codegen/index.d.ts +4 -13
- package/dist/cjs/codegen/index.js +13 -31
- package/dist/cjs/codegen/inventory-generation.d.ts +104 -0
- package/dist/cjs/codegen/inventory-generation.js +122 -0
- package/dist/cjs/codegen/next-source-generation.d.ts +17 -0
- package/dist/cjs/codegen/next-source-generation.js +51 -0
- package/dist/cjs/codegen/openapi-document.d.ts +53 -0
- package/dist/cjs/codegen/openapi-document.js +127 -0
- package/dist/cjs/codegen/route-exports.d.ts +13 -0
- package/dist/cjs/codegen/route-exports.js +122 -0
- package/dist/cjs/codegen/route-fingerprint.d.ts +2 -0
- package/dist/cjs/codegen/route-fingerprint.js +11 -0
- package/dist/cjs/codegen/route-scanner.d.ts +57 -0
- package/dist/cjs/codegen/route-scanner.js +239 -0
- package/dist/cjs/codegen/tools/canonical.d.ts +12 -0
- package/dist/cjs/codegen/tools/canonical.js +49 -0
- package/dist/cjs/codegen/tools/sources/nest-decorators.d.ts +27 -0
- package/dist/cjs/codegen/tools/sources/nest-decorators.js +73 -0
- package/dist/cjs/contracts/app-setup.d.ts +346 -0
- package/dist/cjs/contracts/app-setup.js +208 -0
- package/dist/cjs/contracts/chat-command.d.ts +65 -0
- package/dist/cjs/contracts/chat-command.js +128 -0
- package/dist/cjs/contracts/chat-interactions.d.ts +126 -0
- package/dist/cjs/contracts/chat-interactions.js +439 -0
- package/dist/cjs/contracts/clarification.d.ts +53 -0
- package/dist/cjs/contracts/clarification.js +91 -0
- package/dist/cjs/contracts/content-boundary.d.ts +3 -0
- package/dist/cjs/contracts/content-boundary.js +95 -0
- package/dist/cjs/contracts/events.d.ts +273 -0
- package/dist/cjs/contracts/events.js +229 -0
- package/dist/cjs/contracts/index.d.ts +18 -0
- package/dist/cjs/contracts/index.js +83 -0
- package/dist/cjs/contracts/plan.d.ts +20 -0
- package/dist/cjs/contracts/plan.js +38 -0
- package/dist/cjs/contracts/platform-connection.d.ts +44 -0
- package/dist/cjs/contracts/platform-connection.js +66 -0
- package/dist/cjs/contracts/platform-prompt-revision.d.ts +27 -0
- package/dist/cjs/contracts/platform-prompt-revision.js +46 -0
- package/dist/cjs/contracts/prompt-bundle.d.ts +46 -0
- package/dist/cjs/contracts/prompt-bundle.js +74 -0
- package/dist/cjs/contracts/revisions.d.ts +716 -0
- package/dist/cjs/contracts/revisions.js +301 -0
- package/dist/cjs/contracts/runtime.d.ts +55 -0
- package/dist/cjs/contracts/runtime.js +67 -0
- package/dist/cjs/contracts/semantic-change.d.ts +27 -0
- package/dist/cjs/contracts/semantic-change.js +103 -0
- package/dist/cjs/contracts/tool-exclude-pattern.d.ts +12 -0
- package/dist/cjs/contracts/tool-exclude-pattern.js +29 -0
- package/dist/cjs/contracts/tool-policy-entry.d.ts +107 -0
- package/dist/cjs/contracts/tool-policy-entry.js +42 -0
- package/dist/cjs/contracts/tool-policy.d.ts +198 -0
- package/dist/cjs/contracts/tool-policy.js +500 -0
- package/dist/cjs/contracts/url.d.ts +2 -0
- package/dist/cjs/contracts/url.js +10 -0
- package/dist/cjs/diagnostics/foundation-diagnostic.d.ts +34 -0
- package/dist/cjs/diagnostics/foundation-diagnostic.js +52 -0
- package/dist/cjs/diagnostics/index.d.ts +2 -0
- package/dist/cjs/diagnostics/index.js +7 -0
- package/dist/cjs/embed/chat-styles.generated.d.ts +1 -0
- package/dist/cjs/embed/chat-styles.generated.js +6 -0
- package/dist/cjs/embed/glirastes-chat-element.d.ts +67 -0
- package/dist/cjs/embed/glirastes-chat-element.js +282 -0
- package/dist/cjs/embed/index.d.ts +4 -0
- package/dist/cjs/embed/index.js +20 -0
- package/dist/cjs/embed/theme.d.ts +10 -0
- package/dist/cjs/embed/theme.js +45 -0
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/react/assistant/assistant-layout.d.ts +55 -0
- package/dist/cjs/react/assistant/assistant-layout.js +107 -0
- package/dist/cjs/react/assistant/assistant-shell.d.ts +132 -0
- package/dist/cjs/react/assistant/assistant-shell.js +267 -0
- package/dist/cjs/react/assistant/assistant-shortcut-list.d.ts +24 -0
- package/dist/cjs/react/assistant/assistant-shortcut-list.js +35 -0
- package/dist/cjs/react/assistant/assistant-workspace.d.ts +31 -0
- package/dist/cjs/react/assistant/assistant-workspace.js +33 -0
- package/dist/cjs/react/completions/completion-search.d.ts +21 -0
- package/dist/cjs/react/completions/completion-search.js +111 -0
- package/dist/cjs/react/completions/ui-tool-command-provider.d.ts +15 -0
- package/dist/cjs/react/completions/ui-tool-command-provider.js +84 -0
- package/dist/cjs/react/components/activity-log.d.ts +17 -0
- package/dist/cjs/react/components/activity-log.js +70 -0
- package/dist/cjs/react/components/ai-chat-panel.js +13 -6
- package/dist/cjs/react/components/ai-trigger-button.d.ts +1 -1
- package/dist/cjs/react/components/ai-trigger-button.js +11 -66
- package/dist/cjs/react/components/chat-input.js +6 -4
- package/dist/cjs/react/components/chat-window-visibility.d.ts +3 -0
- package/dist/cjs/react/components/chat-window-visibility.js +7 -0
- package/dist/cjs/react/components/chat-window.d.ts +1 -1
- package/dist/cjs/react/components/chat-window.js +124 -57
- package/dist/cjs/react/components/clarification-card.d.ts +10 -0
- package/dist/cjs/react/components/clarification-card.js +35 -0
- package/dist/cjs/react/components/command-arguments-form.d.ts +10 -0
- package/dist/cjs/react/components/command-arguments-form.js +153 -0
- package/dist/cjs/react/components/confirm-dialog.js +1 -1
- package/dist/cjs/react/components/floating-chat-ui.d.ts +3 -3
- package/dist/cjs/react/components/floating-chat-ui.js +30 -4
- package/dist/cjs/react/components/mention-input.d.ts +5 -4
- package/dist/cjs/react/components/mention-input.js +64 -7
- package/dist/cjs/react/components/message-bubble.js +90 -14
- package/dist/cjs/react/components/plan-checklist.d.ts +14 -0
- package/dist/cjs/react/components/plan-checklist.js +20 -0
- package/dist/cjs/react/components/recording-bar.js +44 -58
- package/dist/cjs/react/components/rich-mention-input.js +197 -45
- package/dist/cjs/react/components/session-switcher.d.ts +3 -1
- package/dist/cjs/react/components/session-switcher.js +26 -11
- package/dist/cjs/react/components/status-icon.d.ts +8 -0
- package/dist/cjs/react/components/status-icon.js +11 -0
- package/dist/cjs/react/components/stream-waveform.d.ts +4 -0
- package/dist/cjs/react/components/stream-waveform.js +49 -0
- package/dist/cjs/react/components/voice-input-addon.d.ts +16 -1
- package/dist/cjs/react/components/voice-input-addon.js +255 -18
- package/dist/cjs/react/components/voice-input-button.js +1 -1
- package/dist/cjs/react/hooks/use-chat-shortcuts.d.ts +33 -0
- package/dist/cjs/react/hooks/use-chat-shortcuts.js +139 -0
- package/dist/cjs/react/hooks/use-deepgram-transcription.d.ts +4 -0
- package/dist/cjs/react/hooks/use-deepgram-transcription.js +31 -321
- package/dist/cjs/react/hooks/use-drag-resize-panel.d.ts +1 -0
- package/dist/cjs/react/hooks/use-drag-resize-panel.js +246 -121
- package/dist/cjs/react/hooks/use-floating-panel.d.ts +57 -0
- package/dist/cjs/react/hooks/use-floating-panel.js +217 -0
- package/dist/cjs/react/hooks/use-keyboard-shortcut.js +2 -1
- package/dist/cjs/react/hooks/use-push-to-talk-hotkey.d.ts +24 -0
- package/dist/cjs/react/hooks/use-push-to-talk-hotkey.js +116 -0
- package/dist/cjs/react/hooks/use-sidebar-resize.d.ts +19 -0
- package/dist/cjs/react/hooks/use-sidebar-resize.js +109 -0
- package/dist/cjs/react/index.d.ts +30 -1
- package/dist/cjs/react/index.js +91 -1
- package/dist/cjs/react/interactions/definitions.d.ts +67 -0
- package/dist/cjs/react/interactions/definitions.js +83 -0
- package/dist/cjs/react/interactions/registry.d.ts +74 -0
- package/dist/cjs/react/interactions/registry.js +250 -0
- package/dist/cjs/react/interactions/use-chat-interactions-data.d.ts +15 -0
- package/dist/cjs/react/interactions/use-chat-interactions-data.js +43 -0
- package/dist/cjs/react/locale-de.d.ts +3 -0
- package/dist/cjs/react/locale-de.js +66 -0
- package/dist/cjs/react/provider/ai-chat-provider.d.ts +1 -1
- package/dist/cjs/react/provider/ai-chat-provider.js +407 -106
- package/dist/cjs/react/provider/chat-context.d.ts +52 -1
- package/dist/cjs/react/stt/controller.d.ts +60 -0
- package/dist/cjs/react/stt/controller.js +268 -0
- package/dist/cjs/react/stt/deepgram.d.ts +30 -0
- package/dist/cjs/react/stt/deepgram.js +204 -0
- package/dist/cjs/react/stt/recorded.d.ts +29 -0
- package/dist/cjs/react/stt/recorded.js +115 -0
- package/dist/cjs/react/stt/segments.d.ts +18 -0
- package/dist/cjs/react/stt/segments.js +32 -0
- package/dist/cjs/react/stt/use-stt.d.ts +17 -0
- package/dist/cjs/react/stt/use-stt.js +41 -0
- package/dist/cjs/react/stt/waveform.d.ts +5 -0
- package/dist/cjs/react/stt/waveform.js +31 -0
- package/dist/cjs/react/styles.css +1529 -0
- package/dist/cjs/react/tool-renderers/registry.d.ts +31 -0
- package/dist/cjs/react/tool-renderers/registry.js +50 -0
- package/dist/cjs/react/tool-renderers/renderer-boundary.d.ts +18 -0
- package/dist/cjs/react/tool-renderers/renderer-boundary.js +15 -0
- package/dist/cjs/react/transports/vercel/vercel-ai-chat.d.ts +1 -1
- package/dist/cjs/react/transports/vercel/vercel-ai-chat.js +2 -2
- package/dist/cjs/react/transports/vercel.d.ts +6 -0
- package/dist/cjs/react/transports/vercel.js +12 -6
- package/dist/cjs/react/types.d.ts +264 -6
- package/dist/cjs/react/ui.d.ts +18 -17
- package/dist/cjs/react/ui.js +50 -45
- package/dist/cjs/react/unstyled.d.ts +7 -0
- package/dist/cjs/react/unstyled.js +10 -0
- package/dist/cjs/react/utils/activity.d.ts +16 -0
- package/dist/cjs/react/utils/activity.js +80 -0
- package/dist/cjs/react/utils/clarification.d.ts +31 -0
- package/dist/cjs/react/utils/clarification.js +104 -0
- package/dist/cjs/react/utils/create-approval-description.d.ts +6 -0
- package/dist/cjs/react/utils/create-approval-description.js +32 -3
- package/dist/cjs/react/utils/create-tool-result-handler.d.ts +1 -1
- package/dist/cjs/react/utils/create-tool-result-handler.js +1 -1
- package/dist/cjs/react/utils/entity-names.d.ts +6 -0
- package/dist/cjs/react/utils/entity-names.js +57 -0
- package/dist/cjs/react/utils/followup-suggestions.d.ts +11 -0
- package/dist/cjs/react/utils/followup-suggestions.js +39 -0
- package/dist/cjs/react/utils/local-session-store.d.ts +30 -0
- package/dist/cjs/react/utils/local-session-store.js +165 -0
- package/dist/cjs/react/utils/mention-markup.d.ts +44 -1
- package/dist/cjs/react/utils/mention-markup.js +144 -10
- package/dist/cjs/react/utils/tool-presentation.d.ts +23 -0
- package/dist/cjs/react/utils/tool-presentation.js +46 -0
- package/dist/cjs/react/utils/tool-result-config.d.ts +10 -0
- package/dist/cjs/react/utils/tool-result-config.js +14 -0
- package/dist/cjs/runtime/ai-sdk/engine.d.ts +66 -0
- package/dist/cjs/runtime/ai-sdk/engine.js +192 -0
- package/dist/cjs/runtime/ai-sdk/index.d.ts +1 -0
- package/dist/cjs/runtime/ai-sdk/index.js +5 -0
- package/dist/cjs/runtime/authorization.d.ts +16 -0
- package/dist/cjs/runtime/authorization.js +35 -0
- package/dist/cjs/runtime/budget.d.ts +39 -0
- package/dist/cjs/runtime/budget.js +100 -0
- package/dist/cjs/runtime/contract-bindings.d.ts +52 -0
- package/dist/cjs/runtime/contract-bindings.js +95 -0
- package/dist/cjs/runtime/engine.d.ts +52 -0
- package/dist/cjs/runtime/engine.js +2 -0
- package/dist/cjs/runtime/fingerprint.d.ts +6 -0
- package/dist/cjs/runtime/fingerprint.js +31 -0
- package/dist/cjs/runtime/glirastes.d.ts +112 -0
- package/dist/cjs/runtime/glirastes.js +287 -0
- package/dist/cjs/runtime/index.d.ts +23 -0
- package/dist/cjs/runtime/index.js +71 -0
- package/dist/cjs/runtime/json-schema.d.ts +13 -0
- package/dist/cjs/runtime/json-schema.js +46 -0
- package/dist/cjs/runtime/local-runtime-source.d.ts +76 -0
- package/dist/cjs/runtime/local-runtime-source.js +0 -0
- package/dist/cjs/runtime/local-signer.d.ts +17 -0
- package/dist/cjs/runtime/local-signer.js +34 -0
- package/dist/cjs/runtime/local-tool-bindings.d.ts +57 -0
- package/dist/cjs/runtime/local-tool-bindings.js +197 -0
- package/dist/cjs/runtime/managed-turn.d.ts +29 -0
- package/dist/cjs/runtime/managed-turn.js +99 -0
- package/dist/cjs/runtime/metrics/cost.d.ts +64 -0
- package/dist/cjs/runtime/metrics/cost.js +98 -0
- package/dist/cjs/runtime/metrics/sink.d.ts +56 -0
- package/dist/cjs/runtime/metrics/sink.js +217 -0
- package/dist/cjs/runtime/metrics/turn-recorder.d.ts +62 -0
- package/dist/cjs/runtime/metrics/turn-recorder.js +172 -0
- package/dist/cjs/runtime/offline-execution-lease.d.ts +27 -0
- package/dist/cjs/runtime/offline-execution-lease.js +49 -0
- package/dist/cjs/runtime/policy-overlay.d.ts +86 -0
- package/dist/cjs/runtime/policy-overlay.js +122 -0
- package/dist/cjs/runtime/postgres-store.d.ts +111 -0
- package/dist/cjs/runtime/postgres-store.js +368 -0
- package/dist/cjs/runtime/prompt-bundle-store.d.ts +58 -0
- package/dist/cjs/runtime/prompt-bundle-store.js +123 -0
- package/dist/cjs/runtime/runtime-mode.d.ts +23 -0
- package/dist/cjs/runtime/runtime-mode.js +46 -0
- package/dist/cjs/runtime/tool-discovery.d.ts +51 -0
- package/dist/cjs/runtime/tool-discovery.js +141 -0
- package/dist/cjs/runtime/tool-search.d.ts +31 -0
- package/dist/cjs/runtime/tool-search.js +149 -0
- package/dist/cjs/runtime/turn-snapshot.d.ts +44 -0
- package/dist/cjs/runtime/turn-snapshot.js +112 -0
- package/dist/cjs/server/adapters/nextjs/approval-binding.d.ts +334 -0
- package/dist/cjs/server/adapters/nextjs/approval-binding.js +724 -0
- package/dist/cjs/server/adapters/nextjs/chat-interactions-handler.d.ts +26 -0
- package/dist/cjs/server/adapters/nextjs/chat-interactions-handler.js +67 -0
- package/dist/cjs/server/adapters/nextjs/clarification-resume.d.ts +21 -0
- package/dist/cjs/server/adapters/nextjs/clarification-resume.js +112 -0
- package/dist/cjs/server/adapters/nextjs/context-helpers.d.ts +49 -8
- package/dist/cjs/server/adapters/nextjs/context-helpers.js +76 -21
- package/dist/cjs/server/adapters/nextjs/create-ai-chat-handler.d.ts +59 -1
- package/dist/cjs/server/adapters/nextjs/create-ai-chat-handler.js +648 -94
- package/dist/cjs/server/adapters/nextjs/direct-command.d.ts +75 -0
- package/dist/cjs/server/adapters/nextjs/direct-command.js +322 -0
- package/dist/cjs/server/adapters/nextjs/index.d.ts +10 -2
- package/dist/cjs/server/adapters/nextjs/index.js +24 -1
- package/dist/cjs/server/adapters/nextjs/prepare-model-messages.d.ts +2 -1
- package/dist/cjs/server/adapters/nextjs/prepare-model-messages.js +6 -14
- package/dist/cjs/server/adapters/nextjs/recording-transcription-handler.d.ts +31 -0
- package/dist/cjs/server/adapters/nextjs/recording-transcription-handler.js +58 -0
- package/dist/cjs/server/adapters/nextjs/request-guards.d.ts +41 -0
- package/dist/cjs/server/adapters/nextjs/request-guards.js +112 -0
- package/dist/cjs/server/adapters/nextjs/sanitize-model-messages.js +12 -6
- package/dist/cjs/server/adapters/nextjs/scope-pipeline-tools.d.ts +17 -0
- package/dist/cjs/server/adapters/nextjs/scope-pipeline-tools.js +28 -0
- package/dist/cjs/server/adapters/nextjs/tool-discovery.d.ts +39 -0
- package/dist/cjs/server/adapters/nextjs/tool-discovery.js +50 -0
- package/dist/cjs/server/adapters/nextjs/tool-presentation.d.ts +26 -0
- package/dist/cjs/server/adapters/nextjs/tool-presentation.js +21 -0
- package/dist/cjs/server/adapters/nextjs/types.d.ts +229 -13
- package/dist/cjs/server/adapters/nextjs/with-ai-tool.d.ts +2 -2
- package/dist/cjs/server/core/adaptive-fast-path.d.ts +3 -0
- package/dist/cjs/server/core/adaptive-fast-path.js +188 -0
- package/dist/cjs/server/core/clarification-tool.d.ts +29 -0
- package/dist/cjs/server/core/clarification-tool.js +64 -0
- package/dist/cjs/server/core/generated-ui-tool.d.ts +31 -0
- package/dist/cjs/server/core/generated-ui-tool.js +89 -0
- package/dist/cjs/server/core/index.d.ts +49 -8
- package/dist/cjs/server/core/index.js +208 -17
- package/dist/cjs/server/core/local-guardrails.d.ts +6 -0
- package/dist/cjs/server/core/local-guardrails.js +70 -0
- package/dist/cjs/server/core/module-router.d.ts +3 -1
- package/dist/cjs/server/core/module-router.js +22 -2
- package/dist/cjs/server/core/plan-tool.d.ts +23 -0
- package/dist/cjs/server/core/plan-tool.js +35 -0
- package/dist/cjs/server/core/zod-compact.d.ts +3 -3
- package/dist/cjs/server/core/zod-compact.js +126 -54
- package/dist/cjs/server/index.d.ts +2 -4
- package/dist/cjs/server/index.js +4 -5
- package/dist/cjs/server/local-pipeline.d.ts +14 -0
- package/dist/cjs/server/local-pipeline.js +154 -0
- package/dist/cjs/server/pii-shield/index.d.ts +1 -0
- package/dist/cjs/server/pii-shield/index.js +3 -1
- package/dist/cjs/server/pii-shield/regex-detector.d.ts +13 -0
- package/dist/cjs/server/pii-shield/regex-detector.js +111 -0
- package/dist/cjs/server/testing/edge-cases.js +52 -101
- package/dist/cjs/server/testing/guardrails.js +2 -66
- package/dist/cjs/server/testing/helpers.js +1 -62
- package/dist/cjs/server/testing/index.d.ts +1 -0
- package/dist/cjs/server/testing/index.js +3 -1
- package/dist/cjs/server/testing/registry-parity.d.ts +18 -0
- package/dist/cjs/server/testing/registry-parity.js +40 -0
- package/dist/cjs/server/testing/schema-consistency.js +5 -26
- package/dist/cjs/server/testing/smoke.d.ts +2 -1
- package/dist/cjs/server/testing/smoke.js +7 -3
- package/dist/cjs/server/testing/types.d.ts +1 -1
- package/dist/cjs/server/testing/zod-introspect.d.ts +38 -0
- package/dist/cjs/server/testing/zod-introspect.js +297 -0
- package/dist/cjs/stt/index.d.ts +5 -0
- package/dist/cjs/stt/index.js +16 -0
- package/dist/cjs/sync/app-setup-client.d.ts +46 -0
- package/dist/cjs/sync/app-setup-client.js +140 -0
- package/dist/cjs/sync/capability-report.d.ts +41 -0
- package/dist/cjs/sync/capability-report.js +52 -0
- package/dist/cjs/sync/connection-lookup.d.ts +19 -0
- package/dist/cjs/sync/connection-lookup.js +58 -0
- package/dist/cjs/sync/control-plane-client.d.ts +69 -0
- package/dist/cjs/sync/control-plane-client.js +186 -0
- package/dist/cjs/sync/deployment-selector.d.ts +9 -0
- package/dist/cjs/sync/deployment-selector.js +29 -0
- package/dist/cjs/sync/fetch-sse-push.d.ts +6 -0
- package/dist/cjs/sync/fetch-sse-push.js +45 -0
- package/dist/cjs/sync/index.d.ts +26 -0
- package/dist/cjs/sync/index.js +43 -0
- package/dist/cjs/sync/jwks-provider.d.ts +14 -0
- package/dist/cjs/sync/jwks-provider.js +56 -0
- package/dist/cjs/sync/local-deployment-validator.d.ts +30 -0
- package/dist/cjs/sync/local-deployment-validator.js +62 -0
- package/dist/cjs/sync/managed-sync.d.ts +40 -0
- package/dist/cjs/sync/managed-sync.js +96 -0
- package/dist/cjs/sync/materialize-deployment.d.ts +7 -0
- package/dist/cjs/sync/materialize-deployment.js +65 -0
- package/dist/cjs/sync/runtime-connect-client.d.ts +23 -0
- package/dist/cjs/sync/runtime-connect-client.js +185 -0
- package/dist/cjs/sync/runtime-setup-client.d.ts +62 -0
- package/dist/cjs/sync/runtime-setup-client.js +157 -0
- package/dist/cjs/sync/signature-verifier.d.ts +39 -0
- package/dist/cjs/sync/signature-verifier.js +102 -0
- package/dist/cjs/sync/state-store.d.ts +24 -0
- package/dist/cjs/sync/state-store.js +51 -0
- package/dist/cjs/sync/sync-manager.d.ts +27 -0
- package/dist/cjs/sync/sync-manager.js +173 -0
- package/dist/cjs/types.d.ts +68 -16
- package/dist/cjs/types.js +31 -3
- package/dist/cli/bin.js +34 -23
- package/dist/cli/bin.js.map +1 -1
- package/dist/cli/commands/agent-setup.d.ts +27 -0
- package/dist/cli/commands/agent-setup.js +149 -0
- package/dist/cli/commands/agent-setup.js.map +1 -0
- package/dist/cli/commands/apply-setup-plan.d.ts +21 -0
- package/dist/cli/commands/apply-setup-plan.js +100 -0
- package/dist/cli/commands/apply-setup-plan.js.map +1 -0
- package/dist/cli/commands/atomic-artifact-write.d.ts +19 -0
- package/dist/cli/commands/atomic-artifact-write.js +106 -0
- package/dist/cli/commands/atomic-artifact-write.js.map +1 -0
- package/dist/cli/commands/ci-workflow.d.ts +48 -0
- package/dist/cli/commands/ci-workflow.js +209 -0
- package/dist/cli/commands/ci-workflow.js.map +1 -0
- package/dist/cli/commands/connect.d.ts +47 -0
- package/dist/cli/commands/connect.js +216 -0
- package/dist/cli/commands/connect.js.map +1 -0
- package/dist/cli/commands/connection-descriptor.d.ts +4 -0
- package/dist/cli/commands/connection-descriptor.js +47 -0
- package/dist/cli/commands/connection-descriptor.js.map +1 -0
- package/dist/cli/commands/connection-environment.d.ts +25 -0
- package/dist/cli/commands/connection-environment.js +151 -0
- package/dist/cli/commands/connection-environment.js.map +1 -0
- package/dist/cli/commands/current-setup-manifests.d.ts +7 -0
- package/dist/cli/commands/current-setup-manifests.js +16 -0
- package/dist/cli/commands/current-setup-manifests.js.map +1 -0
- package/dist/cli/commands/doctor-presentation.d.ts +5 -0
- package/dist/cli/commands/doctor-presentation.js +86 -0
- package/dist/cli/commands/doctor-presentation.js.map +1 -0
- package/dist/cli/commands/doctor.d.ts +27 -0
- package/dist/cli/commands/doctor.js +220 -0
- package/dist/cli/commands/doctor.js.map +1 -0
- package/dist/cli/commands/init-scaffold.d.ts +25 -0
- package/dist/cli/commands/init-scaffold.js +214 -0
- package/dist/cli/commands/init-scaffold.js.map +1 -0
- package/dist/cli/commands/install-skills.d.ts +26 -4
- package/dist/cli/commands/install-skills.js +165 -80
- package/dist/cli/commands/install-skills.js.map +1 -1
- package/dist/cli/commands/installed-skills-manifest.d.ts +87 -0
- package/dist/cli/commands/installed-skills-manifest.js +124 -0
- package/dist/cli/commands/installed-skills-manifest.js.map +1 -0
- package/dist/cli/commands/installer-parts.d.ts +31 -0
- package/dist/cli/commands/installer-parts.js +94 -0
- package/dist/cli/commands/installer-parts.js.map +1 -0
- package/dist/cli/commands/project-inspection.d.ts +35 -0
- package/dist/cli/commands/project-inspection.js +199 -0
- package/dist/cli/commands/project-inspection.js.map +1 -0
- package/dist/cli/commands/setup-plan.d.ts +65 -0
- package/dist/cli/commands/setup-plan.js +234 -0
- package/dist/cli/commands/setup-plan.js.map +1 -0
- package/dist/cli/commands/setup-profile.d.ts +28 -0
- package/dist/cli/commands/setup-profile.js +152 -0
- package/dist/cli/commands/setup-profile.js.map +1 -0
- package/dist/cli/commands/setup-wizard.d.ts +66 -0
- package/dist/cli/commands/setup-wizard.js +241 -0
- package/dist/cli/commands/setup-wizard.js.map +1 -0
- package/dist/cli/commands/sync.d.ts +58 -0
- package/dist/cli/commands/sync.js +233 -0
- package/dist/cli/commands/sync.js.map +1 -0
- package/dist/cli/commands/tools/args.d.ts +14 -0
- package/dist/cli/commands/tools/args.js +33 -0
- package/dist/cli/commands/tools/args.js.map +1 -0
- package/dist/cli/commands/tools/check.d.ts +7 -0
- package/dist/cli/commands/tools/check.js +35 -0
- package/dist/cli/commands/tools/check.js.map +1 -0
- package/dist/cli/commands/tools/describe.d.ts +12 -0
- package/dist/cli/commands/tools/describe.js +43 -0
- package/dist/cli/commands/tools/describe.js.map +1 -0
- package/dist/cli/commands/tools/enrich.d.ts +50 -0
- package/dist/cli/commands/tools/enrich.js +597 -0
- package/dist/cli/commands/tools/enrich.js.map +1 -0
- package/dist/cli/commands/tools/eval.d.ts +13 -0
- package/dist/cli/commands/tools/eval.js +49 -0
- package/dist/cli/commands/tools/eval.js.map +1 -0
- package/dist/cli/commands/tools/format.d.ts +42 -0
- package/dist/cli/commands/tools/format.js +155 -0
- package/dist/cli/commands/tools/format.js.map +1 -0
- package/dist/cli/commands/tools/index.d.ts +26 -0
- package/dist/cli/commands/tools/index.js +107 -0
- package/dist/cli/commands/tools/index.js.map +1 -0
- package/dist/cli/commands/tools/policy.d.ts +11 -0
- package/dist/cli/commands/tools/policy.js +355 -0
- package/dist/cli/commands/tools/policy.js.map +1 -0
- package/dist/cli/commands/tools/refresh.d.ts +6 -0
- package/dist/cli/commands/tools/refresh.js +87 -0
- package/dist/cli/commands/tools/refresh.js.map +1 -0
- package/dist/cli/commands/tools/resolve.d.ts +10 -0
- package/dist/cli/commands/tools/resolve.js +19 -0
- package/dist/cli/commands/tools/resolve.js.map +1 -0
- package/dist/cli/commands/tools/status.d.ts +11 -0
- package/dist/cli/commands/tools/status.js +76 -0
- package/dist/cli/commands/tools/status.js.map +1 -0
- package/dist/cli/commands/tools/verify.d.ts +13 -0
- package/dist/cli/commands/tools/verify.js +168 -0
- package/dist/cli/commands/tools/verify.js.map +1 -0
- package/dist/cli/commands/tools/watch.d.ts +27 -0
- package/dist/cli/commands/tools/watch.js +148 -0
- package/dist/cli/commands/tools/watch.js.map +1 -0
- package/dist/cli/commands/validate-build.d.ts +88 -0
- package/dist/cli/commands/validate-build.js +213 -0
- package/dist/cli/commands/validate-build.js.map +1 -0
- package/dist/cli/commands/workspace-sources.d.ts +27 -0
- package/dist/cli/commands/workspace-sources.js +159 -0
- package/dist/cli/commands/workspace-sources.js.map +1 -0
- package/dist/cli/environment-loading.d.ts +6 -0
- package/dist/cli/environment-loading.js +18 -0
- package/dist/cli/environment-loading.js.map +1 -0
- package/dist/cli/index.d.ts +14 -1
- package/dist/cli/index.js +558 -574
- package/dist/cli/index.js.map +1 -1
- package/dist/codegen/execution-inventory.d.ts +63 -0
- package/dist/codegen/execution-inventory.js +306 -0
- package/dist/codegen/execution-inventory.js.map +1 -0
- package/dist/codegen/index.d.ts +4 -13
- package/dist/codegen/index.js +4 -12
- package/dist/codegen/index.js.map +1 -1
- package/dist/codegen/inventory-generation.d.ts +104 -0
- package/dist/codegen/inventory-generation.js +119 -0
- package/dist/codegen/inventory-generation.js.map +1 -0
- package/dist/codegen/next-source-generation.d.ts +17 -0
- package/dist/codegen/next-source-generation.js +49 -0
- package/dist/codegen/next-source-generation.js.map +1 -0
- package/dist/codegen/openapi-document.d.ts +53 -0
- package/dist/codegen/openapi-document.js +120 -0
- package/dist/codegen/openapi-document.js.map +1 -0
- package/dist/codegen/route-exports.d.ts +13 -0
- package/dist/codegen/route-exports.js +117 -0
- package/dist/codegen/route-exports.js.map +1 -0
- package/dist/codegen/route-fingerprint.d.ts +2 -0
- package/dist/codegen/route-fingerprint.js +9 -0
- package/dist/codegen/route-fingerprint.js.map +1 -0
- package/dist/codegen/route-scanner.d.ts +57 -0
- package/dist/codegen/route-scanner.js +233 -0
- package/dist/codegen/route-scanner.js.map +1 -0
- package/dist/codegen/tools/agentic.d.ts +31 -0
- package/dist/codegen/tools/agentic.js +110 -0
- package/dist/codegen/tools/agentic.js.map +1 -0
- package/dist/codegen/tools/artifact.d.ts +139 -0
- package/dist/codegen/tools/artifact.js +199 -0
- package/dist/codegen/tools/artifact.js.map +1 -0
- package/dist/codegen/tools/canonical.d.ts +12 -0
- package/dist/codegen/tools/canonical.js +41 -0
- package/dist/codegen/tools/canonical.js.map +1 -0
- package/dist/codegen/tools/chat-interactions.d.ts +27 -0
- package/dist/codegen/tools/chat-interactions.js +377 -0
- package/dist/codegen/tools/chat-interactions.js.map +1 -0
- package/dist/codegen/tools/config.d.ts +116 -0
- package/dist/codegen/tools/config.js +172 -0
- package/dist/codegen/tools/config.js.map +1 -0
- package/dist/codegen/tools/contract-tiers.d.ts +64 -0
- package/dist/codegen/tools/contract-tiers.js +518 -0
- package/dist/codegen/tools/contract-tiers.js.map +1 -0
- package/dist/codegen/tools/emit-module.d.ts +13 -0
- package/dist/codegen/tools/emit-module.js +182 -0
- package/dist/codegen/tools/emit-module.js.map +1 -0
- package/dist/codegen/tools/evidence.d.ts +13 -0
- package/dist/codegen/tools/evidence.js +138 -0
- package/dist/codegen/tools/evidence.js.map +1 -0
- package/dist/codegen/tools/exclusions.d.ts +30 -0
- package/dist/codegen/tools/exclusions.js +95 -0
- package/dist/codegen/tools/exclusions.js.map +1 -0
- package/dist/codegen/tools/files.d.ts +195 -0
- package/dist/codegen/tools/files.js +119 -0
- package/dist/codegen/tools/files.js.map +1 -0
- package/dist/codegen/tools/findings.d.ts +7 -0
- package/dist/codegen/tools/findings.js +106 -0
- package/dist/codegen/tools/findings.js.map +1 -0
- package/dist/codegen/tools/handler-analysis.d.ts +49 -0
- package/dist/codegen/tools/handler-analysis.js +375 -0
- package/dist/codegen/tools/handler-analysis.js.map +1 -0
- package/dist/codegen/tools/handler-locator.d.ts +21 -0
- package/dist/codegen/tools/handler-locator.js +152 -0
- package/dist/codegen/tools/handler-locator.js.map +1 -0
- package/dist/codegen/tools/identity.d.ts +18 -0
- package/dist/codegen/tools/identity.js +100 -0
- package/dist/codegen/tools/identity.js.map +1 -0
- package/dist/codegen/tools/input-roles.d.ts +32 -0
- package/dist/codegen/tools/input-roles.js +283 -0
- package/dist/codegen/tools/input-roles.js.map +1 -0
- package/dist/codegen/tools/inputs.d.ts +33 -0
- package/dist/codegen/tools/inputs.js +101 -0
- package/dist/codegen/tools/inputs.js.map +1 -0
- package/dist/codegen/tools/interface-digest.d.ts +14 -0
- package/dist/codegen/tools/interface-digest.js +24 -0
- package/dist/codegen/tools/interface-digest.js.map +1 -0
- package/dist/codegen/tools/mcp-names.d.ts +23 -0
- package/dist/codegen/tools/mcp-names.js +59 -0
- package/dist/codegen/tools/mcp-names.js.map +1 -0
- package/dist/codegen/tools/mode.d.ts +7 -0
- package/dist/codegen/tools/mode.js +27 -0
- package/dist/codegen/tools/mode.js.map +1 -0
- package/dist/codegen/tools/output-inference.d.ts +6 -0
- package/dist/codegen/tools/output-inference.js +99 -0
- package/dist/codegen/tools/output-inference.js.map +1 -0
- package/dist/codegen/tools/pipeline.d.ts +85 -0
- package/dist/codegen/tools/pipeline.js +733 -0
- package/dist/codegen/tools/pipeline.js.map +1 -0
- package/dist/codegen/tools/probe-child.mjs +155 -0
- package/dist/codegen/tools/probe-loader.mjs +105 -0
- package/dist/codegen/tools/program.d.ts +16 -0
- package/dist/codegen/tools/program.js +80 -0
- package/dist/codegen/tools/program.js.map +1 -0
- package/dist/codegen/tools/prose.d.ts +42 -0
- package/dist/codegen/tools/prose.js +211 -0
- package/dist/codegen/tools/prose.js.map +1 -0
- package/dist/codegen/tools/resolutions.d.ts +117 -0
- package/dist/codegen/tools/resolutions.js +195 -0
- package/dist/codegen/tools/resolutions.js.map +1 -0
- package/dist/codegen/tools/routing-eval.d.ts +50 -0
- package/dist/codegen/tools/routing-eval.js +81 -0
- package/dist/codegen/tools/routing-eval.js.map +1 -0
- package/dist/codegen/tools/schema-probe.d.ts +62 -0
- package/dist/codegen/tools/schema-probe.js +209 -0
- package/dist/codegen/tools/schema-probe.js.map +1 -0
- package/dist/codegen/tools/semantics.d.ts +134 -0
- package/dist/codegen/tools/semantics.js +206 -0
- package/dist/codegen/tools/semantics.js.map +1 -0
- package/dist/codegen/tools/sources/app-files.d.ts +35 -0
- package/dist/codegen/tools/sources/app-files.js +109 -0
- package/dist/codegen/tools/sources/app-files.js.map +1 -0
- package/dist/codegen/tools/sources/fastapi-routes.py +177 -0
- package/dist/codegen/tools/sources/nest-decorators.d.ts +27 -0
- package/dist/codegen/tools/sources/nest-decorators.js +65 -0
- package/dist/codegen/tools/sources/nest-decorators.js.map +1 -0
- package/dist/codegen/tools/sources/nest-endpoints.d.ts +10 -0
- package/dist/codegen/tools/sources/nest-endpoints.js +522 -0
- package/dist/codegen/tools/sources/nest-endpoints.js.map +1 -0
- package/dist/codegen/tools/sources/next-endpoints.d.ts +5 -0
- package/dist/codegen/tools/sources/next-endpoints.js +389 -0
- package/dist/codegen/tools/sources/next-endpoints.js.map +1 -0
- package/dist/codegen/tools/sources/next-pages.d.ts +18 -0
- package/dist/codegen/tools/sources/next-pages.js +88 -0
- package/dist/codegen/tools/sources/next-pages.js.map +1 -0
- package/dist/codegen/tools/sources/openapi-endpoints.d.ts +17 -0
- package/dist/codegen/tools/sources/openapi-endpoints.js +395 -0
- package/dist/codegen/tools/sources/openapi-endpoints.js.map +1 -0
- package/dist/codegen/tools/sources/page-tree.d.ts +49 -0
- package/dist/codegen/tools/sources/page-tree.js +152 -0
- package/dist/codegen/tools/sources/page-tree.js.map +1 -0
- package/dist/codegen/tools/sources/react-actions.d.ts +12 -0
- package/dist/codegen/tools/sources/react-actions.js +341 -0
- package/dist/codegen/tools/sources/react-actions.js.map +1 -0
- package/dist/codegen/tools/sources/route-config.d.ts +49 -0
- package/dist/codegen/tools/sources/route-config.js +427 -0
- package/dist/codegen/tools/sources/route-config.js.map +1 -0
- package/dist/codegen/tools/sources/ui-controls.d.ts +41 -0
- package/dist/codegen/tools/sources/ui-controls.js +360 -0
- package/dist/codegen/tools/sources/ui-controls.js.map +1 -0
- package/dist/codegen/tools/sources/ui-tools.d.ts +79 -0
- package/dist/codegen/tools/sources/ui-tools.js +207 -0
- package/dist/codegen/tools/sources/ui-tools.js.map +1 -0
- package/dist/codegen/tools/sources/url-filters.d.ts +41 -0
- package/dist/codegen/tools/sources/url-filters.js +813 -0
- package/dist/codegen/tools/sources/url-filters.js.map +1 -0
- package/dist/codegen/tools/sources/vue-sfc.d.ts +22 -0
- package/dist/codegen/tools/sources/vue-sfc.js +65 -0
- package/dist/codegen/tools/sources/vue-sfc.js.map +1 -0
- package/dist/codegen/tools/state.d.ts +37 -0
- package/dist/codegen/tools/state.js +249 -0
- package/dist/codegen/tools/state.js.map +1 -0
- package/dist/codegen/tools/types.d.ts +137 -0
- package/dist/codegen/tools/types.js +2 -0
- package/dist/codegen/tools/types.js.map +1 -0
- package/dist/codegen/tools/worklist.d.ts +157 -0
- package/dist/codegen/tools/worklist.js +406 -0
- package/dist/codegen/tools/worklist.js.map +1 -0
- package/dist/contracts/app-setup.d.ts +346 -0
- package/dist/contracts/app-setup.js +205 -0
- package/dist/contracts/app-setup.js.map +1 -0
- package/dist/contracts/chat-command.d.ts +65 -0
- package/dist/contracts/chat-command.js +121 -0
- package/dist/contracts/chat-command.js.map +1 -0
- package/dist/contracts/chat-interactions.d.ts +126 -0
- package/dist/contracts/chat-interactions.js +431 -0
- package/dist/contracts/chat-interactions.js.map +1 -0
- package/dist/contracts/clarification.d.ts +53 -0
- package/dist/contracts/clarification.js +86 -0
- package/dist/contracts/clarification.js.map +1 -0
- package/dist/contracts/content-boundary.d.ts +3 -0
- package/dist/contracts/content-boundary.js +91 -0
- package/dist/contracts/content-boundary.js.map +1 -0
- package/dist/contracts/events.d.ts +273 -0
- package/dist/contracts/events.js +227 -0
- package/dist/contracts/events.js.map +1 -0
- package/dist/contracts/index.d.ts +18 -0
- package/dist/contracts/index.js +10 -0
- package/dist/contracts/index.js.map +1 -0
- package/dist/contracts/plan.d.ts +20 -0
- package/dist/contracts/plan.js +35 -0
- package/dist/contracts/plan.js.map +1 -0
- package/dist/contracts/platform-connection.d.ts +44 -0
- package/dist/contracts/platform-connection.js +64 -0
- package/dist/contracts/platform-connection.js.map +1 -0
- package/dist/contracts/platform-prompt-revision.d.ts +27 -0
- package/dist/contracts/platform-prompt-revision.js +44 -0
- package/dist/contracts/platform-prompt-revision.js.map +1 -0
- package/dist/contracts/prompt-bundle.d.ts +46 -0
- package/dist/contracts/prompt-bundle.js +70 -0
- package/dist/contracts/prompt-bundle.js.map +1 -0
- package/dist/contracts/revisions.d.ts +716 -0
- package/dist/contracts/revisions.js +298 -0
- package/dist/contracts/revisions.js.map +1 -0
- package/dist/contracts/runtime.d.ts +55 -0
- package/dist/contracts/runtime.js +65 -0
- package/dist/contracts/runtime.js.map +1 -0
- package/dist/contracts/semantic-change.d.ts +27 -0
- package/dist/contracts/semantic-change.js +101 -0
- package/dist/contracts/semantic-change.js.map +1 -0
- package/dist/contracts/tool-exclude-pattern.d.ts +12 -0
- package/dist/contracts/tool-exclude-pattern.js +27 -0
- package/dist/contracts/tool-exclude-pattern.js.map +1 -0
- package/dist/contracts/tool-policy-entry.d.ts +107 -0
- package/dist/contracts/tool-policy-entry.js +40 -0
- package/dist/contracts/tool-policy-entry.js.map +1 -0
- package/dist/contracts/tool-policy.d.ts +198 -0
- package/dist/contracts/tool-policy.js +485 -0
- package/dist/contracts/tool-policy.js.map +1 -0
- package/dist/contracts/url.d.ts +2 -0
- package/dist/contracts/url.js +8 -0
- package/dist/contracts/url.js.map +1 -0
- package/dist/diagnostics/foundation-diagnostic.d.ts +34 -0
- package/dist/diagnostics/foundation-diagnostic.js +47 -0
- package/dist/diagnostics/foundation-diagnostic.js.map +1 -0
- package/dist/diagnostics/index.d.ts +2 -0
- package/dist/diagnostics/index.js +2 -0
- package/dist/diagnostics/index.js.map +1 -0
- package/dist/embed/chat-styles.generated.d.ts +1 -0
- package/dist/embed/chat-styles.generated.js +4 -0
- package/dist/embed/chat-styles.generated.js.map +1 -0
- package/dist/embed/glirastes-chat-element.d.ts +67 -0
- package/dist/embed/glirastes-chat-element.js +278 -0
- package/dist/embed/glirastes-chat-element.js.map +1 -0
- package/dist/embed/index.d.ts +4 -0
- package/dist/embed/index.js +11 -0
- package/dist/embed/index.js.map +1 -0
- package/dist/embed/theme.d.ts +10 -0
- package/dist/embed/theme.js +41 -0
- package/dist/embed/theme.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/react/assistant/assistant-layout.d.ts +55 -0
- package/dist/react/assistant/assistant-layout.js +99 -0
- package/dist/react/assistant/assistant-layout.js.map +1 -0
- package/dist/react/assistant/assistant-shell.d.ts +132 -0
- package/dist/react/assistant/assistant-shell.js +262 -0
- package/dist/react/assistant/assistant-shell.js.map +1 -0
- package/dist/react/assistant/assistant-shortcut-list.d.ts +24 -0
- package/dist/react/assistant/assistant-shortcut-list.js +32 -0
- package/dist/react/assistant/assistant-shortcut-list.js.map +1 -0
- package/dist/react/assistant/assistant-workspace.d.ts +31 -0
- package/dist/react/assistant/assistant-workspace.js +31 -0
- package/dist/react/assistant/assistant-workspace.js.map +1 -0
- package/dist/react/completions/completion-search.d.ts +21 -0
- package/dist/react/completions/completion-search.js +109 -0
- package/dist/react/completions/completion-search.js.map +1 -0
- package/dist/react/completions/ui-tool-command-provider.d.ts +15 -0
- package/dist/react/completions/ui-tool-command-provider.js +82 -0
- package/dist/react/completions/ui-tool-command-provider.js.map +1 -0
- package/dist/react/components/activity-log.d.ts +17 -0
- package/dist/react/components/activity-log.js +68 -0
- package/dist/react/components/activity-log.js.map +1 -0
- package/dist/react/components/ai-chat-panel.js +13 -6
- package/dist/react/components/ai-chat-panel.js.map +1 -1
- package/dist/react/components/ai-trigger-button.d.ts +1 -1
- package/dist/react/components/ai-trigger-button.js +13 -68
- package/dist/react/components/ai-trigger-button.js.map +1 -1
- package/dist/react/components/chat-input.js +7 -5
- package/dist/react/components/chat-input.js.map +1 -1
- package/dist/react/components/chat-window-visibility.d.ts +3 -0
- package/dist/react/components/chat-window-visibility.js +5 -0
- package/dist/react/components/chat-window-visibility.js.map +1 -0
- package/dist/react/components/chat-window.d.ts +1 -1
- package/dist/react/components/chat-window.js +124 -57
- package/dist/react/components/chat-window.js.map +1 -1
- package/dist/react/components/clarification-card.d.ts +10 -0
- package/dist/react/components/clarification-card.js +33 -0
- package/dist/react/components/clarification-card.js.map +1 -0
- package/dist/react/components/command-arguments-form.d.ts +10 -0
- package/dist/react/components/command-arguments-form.js +151 -0
- package/dist/react/components/command-arguments-form.js.map +1 -0
- package/dist/react/components/confirm-dialog.js +1 -1
- package/dist/react/components/confirm-dialog.js.map +1 -1
- package/dist/react/components/floating-chat-ui.d.ts +3 -3
- package/dist/react/components/floating-chat-ui.js +31 -5
- package/dist/react/components/floating-chat-ui.js.map +1 -1
- package/dist/react/components/mention-input.d.ts +5 -4
- package/dist/react/components/mention-input.js +65 -8
- package/dist/react/components/mention-input.js.map +1 -1
- package/dist/react/components/message-bubble.js +90 -14
- package/dist/react/components/message-bubble.js.map +1 -1
- package/dist/react/components/plan-checklist.d.ts +14 -0
- package/dist/react/components/plan-checklist.js +18 -0
- package/dist/react/components/plan-checklist.js.map +1 -0
- package/dist/react/components/recording-bar.js +45 -59
- package/dist/react/components/recording-bar.js.map +1 -1
- package/dist/react/components/rich-mention-input.js +199 -47
- package/dist/react/components/rich-mention-input.js.map +1 -1
- package/dist/react/components/session-switcher.d.ts +3 -1
- package/dist/react/components/session-switcher.js +27 -12
- package/dist/react/components/session-switcher.js.map +1 -1
- package/dist/react/components/status-icon.d.ts +8 -0
- package/dist/react/components/status-icon.js +9 -0
- package/dist/react/components/status-icon.js.map +1 -0
- package/dist/react/components/stream-waveform.d.ts +4 -0
- package/dist/react/components/stream-waveform.js +47 -0
- package/dist/react/components/stream-waveform.js.map +1 -0
- package/dist/react/components/voice-input-addon.d.ts +16 -1
- package/dist/react/components/voice-input-addon.js +256 -19
- package/dist/react/components/voice-input-addon.js.map +1 -1
- package/dist/react/components/voice-input-button.js +1 -1
- package/dist/react/components/voice-input-button.js.map +1 -1
- package/dist/react/hooks/use-chat-shortcuts.d.ts +33 -0
- package/dist/react/hooks/use-chat-shortcuts.js +133 -0
- package/dist/react/hooks/use-chat-shortcuts.js.map +1 -0
- package/dist/react/hooks/use-deepgram-transcription.d.ts +4 -0
- package/dist/react/hooks/use-deepgram-transcription.js +32 -322
- package/dist/react/hooks/use-deepgram-transcription.js.map +1 -1
- package/dist/react/hooks/use-drag-resize-panel.d.ts +1 -0
- package/dist/react/hooks/use-drag-resize-panel.js +246 -121
- package/dist/react/hooks/use-drag-resize-panel.js.map +1 -1
- package/dist/react/hooks/use-floating-panel.d.ts +57 -0
- package/dist/react/hooks/use-floating-panel.js +215 -0
- package/dist/react/hooks/use-floating-panel.js.map +1 -0
- package/dist/react/hooks/use-keyboard-shortcut.js +2 -1
- package/dist/react/hooks/use-keyboard-shortcut.js.map +1 -1
- package/dist/react/hooks/use-push-to-talk-hotkey.d.ts +24 -0
- package/dist/react/hooks/use-push-to-talk-hotkey.js +112 -0
- package/dist/react/hooks/use-push-to-talk-hotkey.js.map +1 -0
- package/dist/react/hooks/use-sidebar-resize.d.ts +19 -0
- package/dist/react/hooks/use-sidebar-resize.js +107 -0
- package/dist/react/hooks/use-sidebar-resize.js.map +1 -0
- package/dist/react/index.d.ts +30 -1
- package/dist/react/index.js +31 -0
- package/dist/react/index.js.map +1 -1
- package/dist/react/interactions/definitions.d.ts +67 -0
- package/dist/react/interactions/definitions.js +78 -0
- package/dist/react/interactions/definitions.js.map +1 -0
- package/dist/react/interactions/registry.d.ts +74 -0
- package/dist/react/interactions/registry.js +248 -0
- package/dist/react/interactions/registry.js.map +1 -0
- package/dist/react/interactions/use-chat-interactions-data.d.ts +15 -0
- package/dist/react/interactions/use-chat-interactions-data.js +41 -0
- package/dist/react/interactions/use-chat-interactions-data.js.map +1 -0
- package/dist/react/locale-de.d.ts +3 -0
- package/dist/react/locale-de.js +64 -0
- package/dist/react/locale-de.js.map +1 -0
- package/dist/react/provider/ai-chat-provider.d.ts +1 -1
- package/dist/react/provider/ai-chat-provider.js +408 -107
- package/dist/react/provider/ai-chat-provider.js.map +1 -1
- package/dist/react/provider/chat-context.d.ts +52 -1
- package/dist/react/provider/chat-context.js.map +1 -1
- package/dist/react/stt/controller.d.ts +60 -0
- package/dist/react/stt/controller.js +265 -0
- package/dist/react/stt/controller.js.map +1 -0
- package/dist/react/stt/deepgram.d.ts +30 -0
- package/dist/react/stt/deepgram.js +199 -0
- package/dist/react/stt/deepgram.js.map +1 -0
- package/dist/react/stt/recorded.d.ts +29 -0
- package/dist/react/stt/recorded.js +111 -0
- package/dist/react/stt/recorded.js.map +1 -0
- package/dist/react/stt/segments.d.ts +18 -0
- package/dist/react/stt/segments.js +29 -0
- package/dist/react/stt/segments.js.map +1 -0
- package/dist/react/stt/use-stt.d.ts +17 -0
- package/dist/react/stt/use-stt.js +39 -0
- package/dist/react/stt/use-stt.js.map +1 -0
- package/dist/react/stt/waveform.d.ts +5 -0
- package/dist/react/stt/waveform.js +29 -0
- package/dist/react/stt/waveform.js.map +1 -0
- package/dist/react/styles.css +758 -126
- package/dist/react/tool-renderers/registry.d.ts +31 -0
- package/dist/react/tool-renderers/registry.js +47 -0
- package/dist/react/tool-renderers/registry.js.map +1 -0
- package/dist/react/tool-renderers/renderer-boundary.d.ts +18 -0
- package/dist/react/tool-renderers/renderer-boundary.js +12 -0
- package/dist/react/tool-renderers/renderer-boundary.js.map +1 -0
- package/dist/react/transports/vercel/vercel-ai-chat.d.ts +1 -1
- package/dist/react/transports/vercel/vercel-ai-chat.js +2 -2
- package/dist/react/transports/vercel/vercel-ai-chat.js.map +1 -1
- package/dist/react/transports/vercel.d.ts +6 -0
- package/dist/react/transports/vercel.js +11 -6
- package/dist/react/transports/vercel.js.map +1 -1
- package/dist/react/types.d.ts +264 -6
- package/dist/react/ui.d.ts +18 -17
- package/dist/react/ui.js +46 -43
- package/dist/react/ui.js.map +1 -1
- package/dist/react/unstyled.d.ts +7 -0
- package/dist/react/unstyled.js +8 -0
- package/dist/react/unstyled.js.map +1 -0
- package/dist/react/utils/activity.d.ts +16 -0
- package/dist/react/utils/activity.js +77 -0
- package/dist/react/utils/activity.js.map +1 -0
- package/dist/react/utils/clarification.d.ts +31 -0
- package/dist/react/utils/clarification.js +99 -0
- package/dist/react/utils/clarification.js.map +1 -0
- package/dist/react/utils/create-approval-description.d.ts +6 -0
- package/dist/react/utils/create-approval-description.js +32 -3
- package/dist/react/utils/create-approval-description.js.map +1 -1
- package/dist/react/utils/create-tool-result-handler.d.ts +1 -1
- package/dist/react/utils/create-tool-result-handler.js +1 -1
- package/dist/react/utils/create-tool-result-handler.js.map +1 -1
- package/dist/react/utils/entity-names.d.ts +6 -0
- package/dist/react/utils/entity-names.js +55 -0
- package/dist/react/utils/entity-names.js.map +1 -0
- package/dist/react/utils/followup-suggestions.d.ts +11 -0
- package/dist/react/utils/followup-suggestions.js +37 -0
- package/dist/react/utils/followup-suggestions.js.map +1 -0
- package/dist/react/utils/local-session-store.d.ts +30 -0
- package/dist/react/utils/local-session-store.js +163 -0
- package/dist/react/utils/local-session-store.js.map +1 -0
- package/dist/react/utils/mention-markup.d.ts +44 -1
- package/dist/react/utils/mention-markup.js +140 -10
- package/dist/react/utils/mention-markup.js.map +1 -1
- package/dist/react/utils/tool-presentation.d.ts +23 -0
- package/dist/react/utils/tool-presentation.js +41 -0
- package/dist/react/utils/tool-presentation.js.map +1 -0
- package/dist/react/utils/tool-result-config.d.ts +10 -0
- package/dist/react/utils/tool-result-config.js +12 -0
- package/dist/react/utils/tool-result-config.js.map +1 -0
- package/dist/runtime/ai-sdk/engine.d.ts +66 -0
- package/dist/runtime/ai-sdk/engine.js +188 -0
- package/dist/runtime/ai-sdk/engine.js.map +1 -0
- package/dist/runtime/ai-sdk/index.d.ts +1 -0
- package/dist/runtime/ai-sdk/index.js +2 -0
- package/dist/runtime/ai-sdk/index.js.map +1 -0
- package/dist/runtime/authorization.d.ts +16 -0
- package/dist/runtime/authorization.js +33 -0
- package/dist/runtime/authorization.js.map +1 -0
- package/dist/runtime/budget.d.ts +39 -0
- package/dist/runtime/budget.js +97 -0
- package/dist/runtime/budget.js.map +1 -0
- package/dist/runtime/contract-bindings.d.ts +52 -0
- package/dist/runtime/contract-bindings.js +92 -0
- package/dist/runtime/contract-bindings.js.map +1 -0
- package/dist/runtime/engine.d.ts +52 -0
- package/dist/runtime/engine.js +2 -0
- package/dist/runtime/engine.js.map +1 -0
- package/dist/runtime/fingerprint.d.ts +6 -0
- package/dist/runtime/fingerprint.js +29 -0
- package/dist/runtime/fingerprint.js.map +1 -0
- package/dist/runtime/glirastes.d.ts +112 -0
- package/dist/runtime/glirastes.js +285 -0
- package/dist/runtime/glirastes.js.map +1 -0
- package/dist/runtime/index.d.ts +23 -0
- package/dist/runtime/index.js +23 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/json-schema.d.ts +13 -0
- package/dist/runtime/json-schema.js +41 -0
- package/dist/runtime/json-schema.js.map +1 -0
- package/dist/runtime/local-runtime-source.d.ts +76 -0
- package/dist/runtime/local-runtime-source.js +0 -0
- package/dist/runtime/local-runtime-source.js.map +1 -0
- package/dist/runtime/local-signer.d.ts +17 -0
- package/dist/runtime/local-signer.js +32 -0
- package/dist/runtime/local-signer.js.map +1 -0
- package/dist/runtime/local-tool-bindings.d.ts +57 -0
- package/dist/runtime/local-tool-bindings.js +190 -0
- package/dist/runtime/local-tool-bindings.js.map +1 -0
- package/dist/runtime/managed-turn.d.ts +29 -0
- package/dist/runtime/managed-turn.js +97 -0
- package/dist/runtime/managed-turn.js.map +1 -0
- package/dist/runtime/metrics/cost.d.ts +64 -0
- package/dist/runtime/metrics/cost.js +92 -0
- package/dist/runtime/metrics/cost.js.map +1 -0
- package/dist/runtime/metrics/sink.d.ts +56 -0
- package/dist/runtime/metrics/sink.js +214 -0
- package/dist/runtime/metrics/sink.js.map +1 -0
- package/dist/runtime/metrics/turn-recorder.d.ts +62 -0
- package/dist/runtime/metrics/turn-recorder.js +170 -0
- package/dist/runtime/metrics/turn-recorder.js.map +1 -0
- package/dist/runtime/offline-execution-lease.d.ts +27 -0
- package/dist/runtime/offline-execution-lease.js +46 -0
- package/dist/runtime/offline-execution-lease.js.map +1 -0
- package/dist/runtime/policy-overlay.d.ts +86 -0
- package/dist/runtime/policy-overlay.js +117 -0
- package/dist/runtime/policy-overlay.js.map +1 -0
- package/dist/runtime/postgres-store.d.ts +111 -0
- package/dist/runtime/postgres-store.js +363 -0
- package/dist/runtime/postgres-store.js.map +1 -0
- package/dist/runtime/prompt-bundle-store.d.ts +58 -0
- package/dist/runtime/prompt-bundle-store.js +120 -0
- package/dist/runtime/prompt-bundle-store.js.map +1 -0
- package/dist/runtime/runtime-mode.d.ts +23 -0
- package/dist/runtime/runtime-mode.js +42 -0
- package/dist/runtime/runtime-mode.js.map +1 -0
- package/dist/runtime/tool-discovery.d.ts +51 -0
- package/dist/runtime/tool-discovery.js +138 -0
- package/dist/runtime/tool-discovery.js.map +1 -0
- package/dist/runtime/tool-search.d.ts +31 -0
- package/dist/runtime/tool-search.js +145 -0
- package/dist/runtime/tool-search.js.map +1 -0
- package/dist/runtime/turn-snapshot.d.ts +44 -0
- package/dist/runtime/turn-snapshot.js +108 -0
- package/dist/runtime/turn-snapshot.js.map +1 -0
- package/dist/server/adapters/nextjs/approval-binding.d.ts +334 -0
- package/dist/server/adapters/nextjs/approval-binding.js +707 -0
- package/dist/server/adapters/nextjs/approval-binding.js.map +1 -0
- package/dist/server/adapters/nextjs/chat-interactions-handler.d.ts +26 -0
- package/dist/server/adapters/nextjs/chat-interactions-handler.js +65 -0
- package/dist/server/adapters/nextjs/chat-interactions-handler.js.map +1 -0
- package/dist/server/adapters/nextjs/clarification-resume.d.ts +21 -0
- package/dist/server/adapters/nextjs/clarification-resume.js +109 -0
- package/dist/server/adapters/nextjs/clarification-resume.js.map +1 -0
- package/dist/server/adapters/nextjs/context-helpers.d.ts +49 -8
- package/dist/server/adapters/nextjs/context-helpers.js +75 -21
- package/dist/server/adapters/nextjs/context-helpers.js.map +1 -1
- package/dist/server/adapters/nextjs/create-ai-chat-handler.d.ts +59 -1
- package/dist/server/adapters/nextjs/create-ai-chat-handler.js +647 -95
- package/dist/server/adapters/nextjs/create-ai-chat-handler.js.map +1 -1
- package/dist/server/adapters/nextjs/direct-command.d.ts +75 -0
- package/dist/server/adapters/nextjs/direct-command.js +316 -0
- package/dist/server/adapters/nextjs/direct-command.js.map +1 -0
- package/dist/server/adapters/nextjs/index.d.ts +10 -2
- package/dist/server/adapters/nextjs/index.js +7 -0
- package/dist/server/adapters/nextjs/index.js.map +1 -1
- package/dist/server/adapters/nextjs/prepare-model-messages.d.ts +2 -1
- package/dist/server/adapters/nextjs/prepare-model-messages.js +7 -15
- package/dist/server/adapters/nextjs/prepare-model-messages.js.map +1 -1
- package/dist/server/adapters/nextjs/recording-transcription-handler.d.ts +31 -0
- package/dist/server/adapters/nextjs/recording-transcription-handler.js +55 -0
- package/dist/server/adapters/nextjs/recording-transcription-handler.js.map +1 -0
- package/dist/server/adapters/nextjs/request-guards.d.ts +41 -0
- package/dist/server/adapters/nextjs/request-guards.js +108 -0
- package/dist/server/adapters/nextjs/request-guards.js.map +1 -0
- package/dist/server/adapters/nextjs/sanitize-model-messages.js +12 -6
- package/dist/server/adapters/nextjs/sanitize-model-messages.js.map +1 -1
- package/dist/server/adapters/nextjs/scope-pipeline-tools.d.ts +17 -0
- package/dist/server/adapters/nextjs/scope-pipeline-tools.js +26 -0
- package/dist/server/adapters/nextjs/scope-pipeline-tools.js.map +1 -0
- package/dist/server/adapters/nextjs/tool-discovery.d.ts +39 -0
- package/dist/server/adapters/nextjs/tool-discovery.js +47 -0
- package/dist/server/adapters/nextjs/tool-discovery.js.map +1 -0
- package/dist/server/adapters/nextjs/tool-presentation.d.ts +26 -0
- package/dist/server/adapters/nextjs/tool-presentation.js +19 -0
- package/dist/server/adapters/nextjs/tool-presentation.js.map +1 -0
- package/dist/server/adapters/nextjs/types.d.ts +229 -13
- package/dist/server/adapters/nextjs/with-ai-tool.d.ts +2 -2
- package/dist/server/core/adaptive-fast-path.d.ts +3 -0
- package/dist/server/core/adaptive-fast-path.js +185 -0
- package/dist/server/core/adaptive-fast-path.js.map +1 -0
- package/dist/server/core/clarification-tool.d.ts +29 -0
- package/dist/server/core/clarification-tool.js +61 -0
- package/dist/server/core/clarification-tool.js.map +1 -0
- package/dist/server/core/generated-ui-tool.d.ts +31 -0
- package/dist/server/core/generated-ui-tool.js +87 -0
- package/dist/server/core/generated-ui-tool.js.map +1 -0
- package/dist/server/core/index.d.ts +49 -8
- package/dist/server/core/index.js +198 -16
- package/dist/server/core/index.js.map +1 -1
- package/dist/server/core/local-guardrails.d.ts +6 -0
- package/dist/server/core/local-guardrails.js +68 -0
- package/dist/server/core/local-guardrails.js.map +1 -0
- package/dist/server/core/module-router.d.ts +3 -1
- package/dist/server/core/module-router.js +22 -2
- package/dist/server/core/module-router.js.map +1 -1
- package/dist/server/core/plan-tool.d.ts +23 -0
- package/dist/server/core/plan-tool.js +32 -0
- package/dist/server/core/plan-tool.js.map +1 -0
- package/dist/server/core/zod-compact.d.ts +3 -3
- package/dist/server/core/zod-compact.js +126 -54
- package/dist/server/core/zod-compact.js.map +1 -1
- package/dist/server/index.d.ts +2 -4
- package/dist/server/index.js +2 -4
- package/dist/server/index.js.map +1 -1
- package/dist/server/local-pipeline.d.ts +14 -0
- package/dist/server/local-pipeline.js +152 -0
- package/dist/server/local-pipeline.js.map +1 -0
- package/dist/server/pii-shield/index.d.ts +1 -0
- package/dist/server/pii-shield/index.js +1 -0
- package/dist/server/pii-shield/index.js.map +1 -1
- package/dist/server/pii-shield/regex-detector.d.ts +13 -0
- package/dist/server/pii-shield/regex-detector.js +109 -0
- package/dist/server/pii-shield/regex-detector.js.map +1 -0
- package/dist/server/testing/edge-cases.js +46 -95
- package/dist/server/testing/edge-cases.js.map +1 -1
- package/dist/server/testing/guardrails.js +1 -65
- package/dist/server/testing/guardrails.js.map +1 -1
- package/dist/server/testing/helpers.js +1 -62
- package/dist/server/testing/helpers.js.map +1 -1
- package/dist/server/testing/index.d.ts +1 -0
- package/dist/server/testing/index.js +1 -0
- package/dist/server/testing/index.js.map +1 -1
- package/dist/server/testing/registry-parity.d.ts +18 -0
- package/dist/server/testing/registry-parity.js +38 -0
- package/dist/server/testing/registry-parity.js.map +1 -0
- package/dist/server/testing/schema-consistency.js +5 -26
- package/dist/server/testing/schema-consistency.js.map +1 -1
- package/dist/server/testing/smoke.d.ts +2 -1
- package/dist/server/testing/smoke.js +5 -3
- package/dist/server/testing/smoke.js.map +1 -1
- package/dist/server/testing/types.d.ts +1 -1
- package/dist/server/testing/zod-introspect.d.ts +38 -0
- package/dist/server/testing/zod-introspect.js +286 -0
- package/dist/server/testing/zod-introspect.js.map +1 -0
- package/dist/stt/index.d.ts +5 -0
- package/dist/stt/index.js +6 -0
- package/dist/stt/index.js.map +1 -0
- package/dist/sync/app-setup-client.d.ts +46 -0
- package/dist/sync/app-setup-client.js +137 -0
- package/dist/sync/app-setup-client.js.map +1 -0
- package/dist/sync/capability-report.d.ts +41 -0
- package/dist/sync/capability-report.js +48 -0
- package/dist/sync/capability-report.js.map +1 -0
- package/dist/sync/connection-lookup.d.ts +19 -0
- package/dist/sync/connection-lookup.js +56 -0
- package/dist/sync/connection-lookup.js.map +1 -0
- package/dist/sync/control-plane-client.d.ts +69 -0
- package/dist/sync/control-plane-client.js +182 -0
- package/dist/sync/control-plane-client.js.map +1 -0
- package/dist/sync/deployment-selector.d.ts +9 -0
- package/dist/sync/deployment-selector.js +26 -0
- package/dist/sync/deployment-selector.js.map +1 -0
- package/dist/sync/fetch-sse-push.d.ts +6 -0
- package/dist/sync/fetch-sse-push.js +42 -0
- package/dist/sync/fetch-sse-push.js.map +1 -0
- package/dist/sync/index.d.ts +26 -0
- package/dist/sync/index.js +17 -0
- package/dist/sync/index.js.map +1 -0
- package/dist/sync/jwks-provider.d.ts +14 -0
- package/dist/sync/jwks-provider.js +53 -0
- package/dist/sync/jwks-provider.js.map +1 -0
- package/dist/sync/local-deployment-validator.d.ts +30 -0
- package/dist/sync/local-deployment-validator.js +60 -0
- package/dist/sync/local-deployment-validator.js.map +1 -0
- package/dist/sync/managed-sync.d.ts +40 -0
- package/dist/sync/managed-sync.js +94 -0
- package/dist/sync/managed-sync.js.map +1 -0
- package/dist/sync/materialize-deployment.d.ts +7 -0
- package/dist/sync/materialize-deployment.js +63 -0
- package/dist/sync/materialize-deployment.js.map +1 -0
- package/dist/sync/runtime-connect-client.d.ts +23 -0
- package/dist/sync/runtime-connect-client.js +182 -0
- package/dist/sync/runtime-connect-client.js.map +1 -0
- package/dist/sync/runtime-setup-client.d.ts +62 -0
- package/dist/sync/runtime-setup-client.js +153 -0
- package/dist/sync/runtime-setup-client.js.map +1 -0
- package/dist/sync/signature-verifier.d.ts +39 -0
- package/dist/sync/signature-verifier.js +97 -0
- package/dist/sync/signature-verifier.js.map +1 -0
- package/dist/sync/state-store.d.ts +24 -0
- package/dist/sync/state-store.js +47 -0
- package/dist/sync/state-store.js.map +1 -0
- package/dist/sync/sync-manager.d.ts +27 -0
- package/dist/sync/sync-manager.js +170 -0
- package/dist/sync/sync-manager.js.map +1 -0
- package/dist/types.d.ts +68 -16
- package/dist/types.js +31 -3
- package/dist/types.js.map +1 -1
- package/embed/package.json +5 -0
- package/package.json +188 -47
- package/runtime/ai-sdk/package.json +5 -0
- package/runtime/package.json +5 -0
- package/skills/README.md +26 -92
- package/skills/building-glirastes-chat-ui/SKILL.md +358 -343
- package/skills/describing-glirastes-tools/SKILL.md +180 -0
- package/skills/integrating-glirastes-nextjs/SKILL.md +149 -302
- package/skills/integrating-glirastes-web/SKILL.md +165 -0
- package/skills/maintaining-glirastes-tools/SKILL.md +133 -461
- package/skills/migrating-to-glirastes/SKILL.md +112 -0
- package/skills/setting-up-glirastes/SKILL.md +158 -0
- package/skills/setting-up-glirastes/agents/openai.yaml +4 -0
- package/skills/setting-up-glirastes/references/artifact-contract.md +40 -0
- package/skills/setting-up-glirastes/scripts/validate-artifact.ts +23 -0
- package/skills/setting-up-glirastes/templates/interview.md +19 -0
- package/stt/package.json +5 -0
- package/dist/cjs/codegen/asset-sync.d.ts +0 -20
- package/dist/cjs/codegen/asset-sync.js +0 -28
- package/dist/cjs/codegen/coverage.d.ts +0 -66
- package/dist/cjs/codegen/coverage.js +0 -408
- package/dist/cjs/codegen/endpoint-scanner.d.ts +0 -16
- package/dist/cjs/codegen/endpoint-scanner.js +0 -197
- package/dist/cjs/codegen/mcp-generator.d.ts +0 -50
- package/dist/cjs/codegen/mcp-generator.js +0 -803
- package/dist/cjs/codegen/module-generator.d.ts +0 -11
- package/dist/cjs/codegen/module-generator.js +0 -353
- package/dist/cjs/codegen/nestjs-scanner.d.ts +0 -43
- package/dist/cjs/codegen/nestjs-scanner.js +0 -241
- package/dist/cjs/codegen/output-recommender.d.ts +0 -23
- package/dist/cjs/codegen/output-recommender.js +0 -33
- package/dist/cjs/codegen/scaffolder.d.ts +0 -36
- package/dist/cjs/codegen/scaffolder.js +0 -262
- package/dist/cjs/codegen/skill-generator.d.ts +0 -49
- package/dist/cjs/codegen/skill-generator.js +0 -967
- package/dist/cjs/codegen/ui-scanner.d.ts +0 -24
- package/dist/cjs/codegen/ui-scanner.js +0 -202
- package/dist/cjs/codegen/validator.d.ts +0 -35
- package/dist/cjs/codegen/validator.js +0 -292
- package/dist/cjs/openapi/index.d.ts +0 -78
- package/dist/cjs/openapi/index.js +0 -347
- package/dist/cjs/react/components/wavesurfer-loader.d.ts +0 -5
- package/dist/cjs/react/components/wavesurfer-loader.js +0 -36
- package/dist/cjs/react/transports/langgraph/index.d.ts +0 -2
- package/dist/cjs/react/transports/langgraph/index.js +0 -8
- package/dist/cjs/react/transports/langgraph/langgraph-ai-chat.d.ts +0 -62
- package/dist/cjs/react/transports/langgraph/langgraph-ai-chat.js +0 -94
- package/dist/cjs/react/transports/langgraph.d.ts +0 -71
- package/dist/cjs/react/transports/langgraph.js +0 -369
- package/dist/cjs/server/adapters/nestjs/chat/ai-chat-auth.guard.d.ts +0 -10
- package/dist/cjs/server/adapters/nestjs/chat/ai-chat-auth.guard.js +0 -42
- package/dist/cjs/server/adapters/nestjs/chat/ai-chat-module-options.interface.d.ts +0 -32
- package/dist/cjs/server/adapters/nestjs/chat/ai-chat-module-options.interface.js +0 -4
- package/dist/cjs/server/adapters/nestjs/chat/ai-chat.controller.d.ts +0 -11
- package/dist/cjs/server/adapters/nestjs/chat/ai-chat.controller.js +0 -80
- package/dist/cjs/server/adapters/nestjs/chat/ai-chat.module.d.ts +0 -9
- package/dist/cjs/server/adapters/nestjs/chat/ai-chat.module.js +0 -119
- package/dist/cjs/server/adapters/nestjs/chat/ai-chat.service.d.ts +0 -13
- package/dist/cjs/server/adapters/nestjs/chat/ai-chat.service.js +0 -131
- package/dist/cjs/server/adapters/nestjs/chat/dto/ai-chat-request.dto.d.ts +0 -7
- package/dist/cjs/server/adapters/nestjs/chat/dto/ai-chat-request.dto.js +0 -52
- package/dist/cjs/server/adapters/nestjs/chat/dto/chat-message-part.dto.d.ts +0 -19
- package/dist/cjs/server/adapters/nestjs/chat/dto/chat-message-part.dto.js +0 -108
- package/dist/cjs/server/adapters/nestjs/chat/dto/chat-message.dto.d.ts +0 -8
- package/dist/cjs/server/adapters/nestjs/chat/dto/chat-message.dto.js +0 -59
- package/dist/cjs/server/adapters/nestjs/chat/dto/index.d.ts +0 -3
- package/dist/cjs/server/adapters/nestjs/chat/dto/index.js +0 -9
- package/dist/cjs/server/adapters/nestjs/chat/index.d.ts +0 -3
- package/dist/cjs/server/adapters/nestjs/chat/index.js +0 -9
- package/dist/cjs/server/adapters/nestjs/chat/speech-stream.gateway.d.ts +0 -4
- package/dist/cjs/server/adapters/nestjs/chat/speech-stream.gateway.js +0 -73
- package/dist/cjs/server/adapters/nestjs/chat/ws-loader.d.ts +0 -5
- package/dist/cjs/server/adapters/nestjs/chat/ws-loader.js +0 -72
- package/dist/cjs/server/adapters/nestjs/decorators/ai-module.decorator.d.ts +0 -6
- package/dist/cjs/server/adapters/nestjs/decorators/ai-module.decorator.js +0 -13
- package/dist/cjs/server/adapters/nestjs/decorators/ai-param.decorator.d.ts +0 -5
- package/dist/cjs/server/adapters/nestjs/decorators/ai-param.decorator.js +0 -15
- package/dist/cjs/server/adapters/nestjs/decorators/ai-tool.decorator.d.ts +0 -6
- package/dist/cjs/server/adapters/nestjs/decorators/ai-tool.decorator.js +0 -22
- package/dist/cjs/server/adapters/nestjs/decorators/constants.d.ts +0 -4
- package/dist/cjs/server/adapters/nestjs/decorators/constants.js +0 -7
- package/dist/cjs/server/adapters/nestjs/index.d.ts +0 -14
- package/dist/cjs/server/adapters/nestjs/index.js +0 -42
- package/dist/cjs/server/adapters/nestjs/metadata.d.ts +0 -39
- package/dist/cjs/server/adapters/nestjs/metadata.js +0 -36
- package/dist/cjs/server/adapters/nestjs/module/ai-tools-explorer.service.d.ts +0 -36
- package/dist/cjs/server/adapters/nestjs/module/ai-tools-explorer.service.js +0 -159
- package/dist/cjs/server/adapters/nestjs/module/ai-tools.module.d.ts +0 -37
- package/dist/cjs/server/adapters/nestjs/module/ai-tools.module.js +0 -44
- package/dist/cjs/server/adapters/nestjs/module/ai-tools.service.d.ts +0 -28
- package/dist/cjs/server/adapters/nestjs/module/ai-tools.service.js +0 -41
- package/dist/cjs/server/adapters/nestjs/scanner/nestjs-scanner.d.ts +0 -16
- package/dist/cjs/server/adapters/nestjs/scanner/nestjs-scanner.js +0 -117
- package/dist/cjs/server/adapters/nestjs/scanner/schema-builder.d.ts +0 -26
- package/dist/cjs/server/adapters/nestjs/scanner/schema-builder.js +0 -259
- package/dist/cjs/server/adapters/nestjs/swagger.d.ts +0 -7
- package/dist/cjs/server/adapters/nestjs/swagger.js +0 -39
- package/dist/cli/commands/check-upgrade.d.ts +0 -15
- package/dist/cli/commands/check-upgrade.js +0 -138
- package/dist/cli/commands/check-upgrade.js.map +0 -1
- package/dist/cli/commands/test.d.ts +0 -8
- package/dist/cli/commands/test.js +0 -76
- package/dist/cli/commands/test.js.map +0 -1
- package/dist/cli/utils/changelog-parser.d.ts +0 -13
- package/dist/cli/utils/changelog-parser.js +0 -89
- package/dist/cli/utils/changelog-parser.js.map +0 -1
- package/dist/cli/utils/commit-parser.d.ts +0 -8
- package/dist/cli/utils/commit-parser.js +0 -23
- package/dist/cli/utils/commit-parser.js.map +0 -1
- package/dist/cli/utils/gap-detector.d.ts +0 -14
- package/dist/cli/utils/gap-detector.js +0 -65
- package/dist/cli/utils/gap-detector.js.map +0 -1
- package/dist/cli/utils/get-cli-version.d.ts +0 -2
- package/dist/cli/utils/get-cli-version.js +0 -10
- package/dist/cli/utils/get-cli-version.js.map +0 -1
- package/dist/codegen/asset-sync.d.ts +0 -20
- package/dist/codegen/asset-sync.js +0 -26
- package/dist/codegen/asset-sync.js.map +0 -1
- package/dist/codegen/coverage.d.ts +0 -66
- package/dist/codegen/coverage.js +0 -372
- package/dist/codegen/coverage.js.map +0 -1
- package/dist/codegen/endpoint-scanner.d.ts +0 -16
- package/dist/codegen/endpoint-scanner.js +0 -161
- package/dist/codegen/endpoint-scanner.js.map +0 -1
- package/dist/codegen/mcp-generator.d.ts +0 -50
- package/dist/codegen/mcp-generator.js +0 -801
- package/dist/codegen/mcp-generator.js.map +0 -1
- package/dist/codegen/module-generator.d.ts +0 -11
- package/dist/codegen/module-generator.js +0 -351
- package/dist/codegen/module-generator.js.map +0 -1
- package/dist/codegen/nestjs-scanner.d.ts +0 -43
- package/dist/codegen/nestjs-scanner.js +0 -239
- package/dist/codegen/nestjs-scanner.js.map +0 -1
- package/dist/codegen/output-recommender.d.ts +0 -23
- package/dist/codegen/output-recommender.js +0 -31
- package/dist/codegen/output-recommender.js.map +0 -1
- package/dist/codegen/scaffolder.d.ts +0 -36
- package/dist/codegen/scaffolder.js +0 -259
- package/dist/codegen/scaffolder.js.map +0 -1
- package/dist/codegen/skill-generator.d.ts +0 -49
- package/dist/codegen/skill-generator.js +0 -965
- package/dist/codegen/skill-generator.js.map +0 -1
- package/dist/codegen/ui-scanner.d.ts +0 -24
- package/dist/codegen/ui-scanner.js +0 -197
- package/dist/codegen/ui-scanner.js.map +0 -1
- package/dist/codegen/validator.d.ts +0 -35
- package/dist/codegen/validator.js +0 -256
- package/dist/codegen/validator.js.map +0 -1
- package/dist/openapi/demo-generate.d.ts +0 -1
- package/dist/openapi/demo-generate.js +0 -15
- package/dist/openapi/demo-generate.js.map +0 -1
- package/dist/openapi/index.d.ts +0 -78
- package/dist/openapi/index.js +0 -341
- package/dist/openapi/index.js.map +0 -1
- package/dist/react/components/wavesurfer-loader.d.ts +0 -5
- package/dist/react/components/wavesurfer-loader.js +0 -34
- package/dist/react/components/wavesurfer-loader.js.map +0 -1
- package/dist/react/transports/langgraph/index.d.ts +0 -2
- package/dist/react/transports/langgraph/index.js +0 -3
- package/dist/react/transports/langgraph/index.js.map +0 -1
- package/dist/react/transports/langgraph/langgraph-ai-chat.d.ts +0 -62
- package/dist/react/transports/langgraph/langgraph-ai-chat.js +0 -92
- package/dist/react/transports/langgraph/langgraph-ai-chat.js.map +0 -1
- package/dist/react/transports/langgraph.d.ts +0 -71
- package/dist/react/transports/langgraph.js +0 -366
- package/dist/react/transports/langgraph.js.map +0 -1
- package/dist/server/adapters/nestjs/chat/ai-chat-auth.guard.d.ts +0 -10
- package/dist/server/adapters/nestjs/chat/ai-chat-auth.guard.js +0 -40
- package/dist/server/adapters/nestjs/chat/ai-chat-auth.guard.js.map +0 -1
- package/dist/server/adapters/nestjs/chat/ai-chat-module-options.interface.d.ts +0 -32
- package/dist/server/adapters/nestjs/chat/ai-chat-module-options.interface.js +0 -2
- package/dist/server/adapters/nestjs/chat/ai-chat-module-options.interface.js.map +0 -1
- package/dist/server/adapters/nestjs/chat/ai-chat.controller.d.ts +0 -11
- package/dist/server/adapters/nestjs/chat/ai-chat.controller.js +0 -78
- package/dist/server/adapters/nestjs/chat/ai-chat.controller.js.map +0 -1
- package/dist/server/adapters/nestjs/chat/ai-chat.module.d.ts +0 -9
- package/dist/server/adapters/nestjs/chat/ai-chat.module.js +0 -117
- package/dist/server/adapters/nestjs/chat/ai-chat.module.js.map +0 -1
- package/dist/server/adapters/nestjs/chat/ai-chat.service.d.ts +0 -13
- package/dist/server/adapters/nestjs/chat/ai-chat.service.js +0 -129
- package/dist/server/adapters/nestjs/chat/ai-chat.service.js.map +0 -1
- package/dist/server/adapters/nestjs/chat/dto/ai-chat-request.dto.d.ts +0 -7
- package/dist/server/adapters/nestjs/chat/dto/ai-chat-request.dto.js +0 -49
- package/dist/server/adapters/nestjs/chat/dto/ai-chat-request.dto.js.map +0 -1
- package/dist/server/adapters/nestjs/chat/dto/chat-message-part.dto.d.ts +0 -19
- package/dist/server/adapters/nestjs/chat/dto/chat-message-part.dto.js +0 -105
- package/dist/server/adapters/nestjs/chat/dto/chat-message-part.dto.js.map +0 -1
- package/dist/server/adapters/nestjs/chat/dto/chat-message.dto.d.ts +0 -8
- package/dist/server/adapters/nestjs/chat/dto/chat-message.dto.js +0 -56
- package/dist/server/adapters/nestjs/chat/dto/chat-message.dto.js.map +0 -1
- package/dist/server/adapters/nestjs/chat/dto/index.d.ts +0 -3
- package/dist/server/adapters/nestjs/chat/dto/index.js +0 -4
- package/dist/server/adapters/nestjs/chat/dto/index.js.map +0 -1
- package/dist/server/adapters/nestjs/chat/index.d.ts +0 -3
- package/dist/server/adapters/nestjs/chat/index.js +0 -3
- package/dist/server/adapters/nestjs/chat/index.js.map +0 -1
- package/dist/server/adapters/nestjs/chat/speech-stream.gateway.d.ts +0 -4
- package/dist/server/adapters/nestjs/chat/speech-stream.gateway.js +0 -71
- package/dist/server/adapters/nestjs/chat/speech-stream.gateway.js.map +0 -1
- package/dist/server/adapters/nestjs/chat/ws-loader.d.ts +0 -5
- package/dist/server/adapters/nestjs/chat/ws-loader.js +0 -37
- package/dist/server/adapters/nestjs/chat/ws-loader.js.map +0 -1
- package/dist/server/adapters/nestjs/decorators/ai-module.decorator.d.ts +0 -6
- package/dist/server/adapters/nestjs/decorators/ai-module.decorator.js +0 -11
- package/dist/server/adapters/nestjs/decorators/ai-module.decorator.js.map +0 -1
- package/dist/server/adapters/nestjs/decorators/ai-param.decorator.d.ts +0 -5
- package/dist/server/adapters/nestjs/decorators/ai-param.decorator.js +0 -13
- package/dist/server/adapters/nestjs/decorators/ai-param.decorator.js.map +0 -1
- package/dist/server/adapters/nestjs/decorators/ai-tool.decorator.d.ts +0 -6
- package/dist/server/adapters/nestjs/decorators/ai-tool.decorator.js +0 -20
- package/dist/server/adapters/nestjs/decorators/ai-tool.decorator.js.map +0 -1
- package/dist/server/adapters/nestjs/decorators/constants.d.ts +0 -4
- package/dist/server/adapters/nestjs/decorators/constants.js +0 -5
- package/dist/server/adapters/nestjs/decorators/constants.js.map +0 -1
- package/dist/server/adapters/nestjs/index.d.ts +0 -14
- package/dist/server/adapters/nestjs/index.js +0 -20
- package/dist/server/adapters/nestjs/index.js.map +0 -1
- package/dist/server/adapters/nestjs/metadata.d.ts +0 -39
- package/dist/server/adapters/nestjs/metadata.js +0 -30
- package/dist/server/adapters/nestjs/metadata.js.map +0 -1
- package/dist/server/adapters/nestjs/module/ai-tools-explorer.service.d.ts +0 -36
- package/dist/server/adapters/nestjs/module/ai-tools-explorer.service.js +0 -156
- package/dist/server/adapters/nestjs/module/ai-tools-explorer.service.js.map +0 -1
- package/dist/server/adapters/nestjs/module/ai-tools.module.d.ts +0 -37
- package/dist/server/adapters/nestjs/module/ai-tools.module.js +0 -42
- package/dist/server/adapters/nestjs/module/ai-tools.module.js.map +0 -1
- package/dist/server/adapters/nestjs/module/ai-tools.service.d.ts +0 -28
- package/dist/server/adapters/nestjs/module/ai-tools.service.js +0 -38
- package/dist/server/adapters/nestjs/module/ai-tools.service.js.map +0 -1
- package/dist/server/adapters/nestjs/scanner/nestjs-scanner.d.ts +0 -16
- package/dist/server/adapters/nestjs/scanner/nestjs-scanner.js +0 -115
- package/dist/server/adapters/nestjs/scanner/nestjs-scanner.js.map +0 -1
- package/dist/server/adapters/nestjs/scanner/schema-builder.d.ts +0 -26
- package/dist/server/adapters/nestjs/scanner/schema-builder.js +0 -255
- package/dist/server/adapters/nestjs/scanner/schema-builder.js.map +0 -1
- package/dist/server/adapters/nestjs/swagger.d.ts +0 -7
- package/dist/server/adapters/nestjs/swagger.js +0 -37
- package/dist/server/adapters/nestjs/swagger.js.map +0 -1
- package/openapi/package.json +0 -5
- package/react/langgraph/package.json +0 -5
- package/server/nestjs/package.json +0 -5
- package/skills/integrating-glirastes-nestjs/SKILL.md +0 -346
- package/skills/integrating-glirastes-nextjs-with-nestjs-backend/SKILL.md +0 -359
|
@@ -1,9 +1,22 @@
|
|
|
1
|
-
import { toolsToAiTools, createFollowupTool } from '../../core/index.js';
|
|
1
|
+
import { toolsToAiTools, createFollowupTool, createClarificationTool, createPlanTool, } from '../../core/index.js';
|
|
2
|
+
import { CLARIFICATION_TOOL_NAME } from '../../../contracts/clarification.js';
|
|
3
|
+
import { PLAN_TOOL_NAME } from '../../../contracts/plan.js';
|
|
4
|
+
/** Handler-created built-ins that stay callable for every tool selection. */
|
|
5
|
+
const ALWAYS_ON_BUILTINS = [CLARIFICATION_TOOL_NAME, PLAN_TOOL_NAME];
|
|
6
|
+
import { applyClarificationResume, resolveClarificationResume, } from './clarification-resume.js';
|
|
7
|
+
import { scopePipelineTools } from './scope-pipeline-tools.js';
|
|
8
|
+
import { checkRequestHeaders, readJsonBody } from './request-guards.js';
|
|
9
|
+
import { ApprovalHistoryError, ApprovalSecretMissingError, approvalScope, assertApprovalMaxAge, assertUnambiguousToolHistory, bindApprovalRequests, createApprovalExecutionGate, defaultApprovalStore, enforceApprovalBindings, gateApprovalTools, resolveApprovalBinder, } from './approval-binding.js';
|
|
10
|
+
import { pseudonymizeCommandToolInputs, resolveDirectCommand, runDirectCommand, stripChatCommandMessages, } from './direct-command.js';
|
|
2
11
|
import { applyPromptOverride } from '../../../types.js';
|
|
3
12
|
import { streamText, createUIMessageStream, createUIMessageStreamResponse, } from 'ai';
|
|
4
13
|
import { buildToolContext, createInternalApiCallerFromRequest, } from './context-helpers.js';
|
|
5
14
|
import { prepareModelMessages, wrapToolsForVercelAi } from './prepare-model-messages.js';
|
|
6
15
|
import { filterFallbackError } from './filter-fallback-error.js';
|
|
16
|
+
import { toolPresentationOf } from './tool-presentation.js';
|
|
17
|
+
import { PrincipalSchema } from '../../../contracts/index.js';
|
|
18
|
+
import { createManagedTurnGuard, createRegistryToolDiscovery, createTurnMetricsRecorder, createTurnToolDiscovery, isToolRevoked, rawChunkCostUsd, resolveStepCost, RuntimePriceTableSchema, } from '../../../runtime/index.js';
|
|
19
|
+
import { createHybridToolDiscovery, NON_DOMAIN_TOOL_NAMES, } from './tool-discovery.js';
|
|
7
20
|
/**
|
|
8
21
|
* Default soft cap on reasoning steps when no module-level or explicit
|
|
9
22
|
* `maxSteps` is configured. Acts as a last-line safety against runaway
|
|
@@ -19,18 +32,74 @@ function asPositiveInt(value) {
|
|
|
19
32
|
return normalized > 0 ? normalized : null;
|
|
20
33
|
}
|
|
21
34
|
export function resolveStepLimit(options) {
|
|
35
|
+
let resolved;
|
|
22
36
|
const moduleMaxSteps = asPositiveInt(options.moduleMaxSteps);
|
|
23
37
|
if (moduleMaxSteps) {
|
|
24
|
-
|
|
38
|
+
resolved = { maxSteps: moduleMaxSteps, stepLimitSource: 'module' };
|
|
25
39
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
40
|
+
else {
|
|
41
|
+
const configuredMaxSteps = asPositiveInt(options.configuredMaxSteps);
|
|
42
|
+
resolved = configuredMaxSteps
|
|
43
|
+
? { maxSteps: configuredMaxSteps, stepLimitSource: 'explicit' }
|
|
44
|
+
: {
|
|
45
|
+
maxSteps: asPositiveInt(options.safetyMaxSteps)
|
|
46
|
+
?? DEFAULT_SAFETY_MAX_STEPS,
|
|
47
|
+
stepLimitSource: 'safety',
|
|
48
|
+
};
|
|
29
49
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
50
|
+
const runtimeBudgetMaxSteps = asPositiveInt(options.runtimeBudgetMaxSteps);
|
|
51
|
+
return runtimeBudgetMaxSteps && runtimeBudgetMaxSteps < resolved.maxSteps
|
|
52
|
+
? {
|
|
53
|
+
maxSteps: runtimeBudgetMaxSteps,
|
|
54
|
+
stepLimitSource: 'runtime-budget',
|
|
55
|
+
}
|
|
56
|
+
: resolved;
|
|
57
|
+
}
|
|
58
|
+
export function resolveTurnTimeout(totalTimeoutMs) {
|
|
59
|
+
if (totalTimeoutMs === undefined)
|
|
60
|
+
return undefined;
|
|
61
|
+
if (!Number.isFinite(totalTimeoutMs) || totalTimeoutMs <= 0) {
|
|
62
|
+
throw new RangeError('totalTimeoutMs must be a positive finite number');
|
|
63
|
+
}
|
|
64
|
+
return { totalMs: totalTimeoutMs };
|
|
65
|
+
}
|
|
66
|
+
export function shouldStopManagedExecution(options) {
|
|
67
|
+
return options.stepCount >= options.maxSteps
|
|
68
|
+
|| options.budgetState === 'hard-limit'
|
|
69
|
+
|| (options.lastStepToolNames ?? []).includes(CLARIFICATION_TOOL_NAME);
|
|
70
|
+
}
|
|
71
|
+
/** Model id of a finished step; AI SDK 6 versions differ in where they put it. */
|
|
72
|
+
function stepModelId(event) {
|
|
73
|
+
const record = event;
|
|
74
|
+
const modelId = record.model?.modelId ?? record.response?.modelId;
|
|
75
|
+
return typeof modelId === 'string' ? modelId : null;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Names of the tool calls of a step that failed: thrown errors and the
|
|
79
|
+
* `{ error }` results SDK tools return. Only names leave this function.
|
|
80
|
+
*/
|
|
81
|
+
function failedToolNames(content) {
|
|
82
|
+
const names = [];
|
|
83
|
+
for (const part of content) {
|
|
84
|
+
const record = part;
|
|
85
|
+
if (typeof record?.toolName !== 'string')
|
|
86
|
+
continue;
|
|
87
|
+
const output = record.output;
|
|
88
|
+
if (record.type === 'tool-error'
|
|
89
|
+
|| (record.type === 'tool-result'
|
|
90
|
+
&& typeof output === 'object'
|
|
91
|
+
&& output !== null
|
|
92
|
+
&& typeof output.error === 'string')) {
|
|
93
|
+
names.push(record.toolName);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return names;
|
|
97
|
+
}
|
|
98
|
+
/** Hands endpoint contract rejections to the turn's metrics, when the app reports metrics. */
|
|
99
|
+
function contractRejectionReporter(turnMetrics) {
|
|
100
|
+
return turnMetrics
|
|
101
|
+
? { onContractRejected: ({ toolName, status }) => { turnMetrics.recordToolContractRejected(toolName, status); } }
|
|
102
|
+
: {};
|
|
34
103
|
}
|
|
35
104
|
function compactToolNames(toolCalls) {
|
|
36
105
|
const unique = new Set();
|
|
@@ -111,34 +180,63 @@ function createPipelineState(options) {
|
|
|
111
180
|
* Converts UI messages → model messages, wraps tools, calls streamText,
|
|
112
181
|
* and returns a UI message stream response.
|
|
113
182
|
*/
|
|
114
|
-
async function defaultStreamHandler(ctx, onFinish) {
|
|
115
|
-
|
|
183
|
+
async function defaultStreamHandler(ctx, onFinish, onStreamError) {
|
|
184
|
+
// SDK built-ins the handler created itself are not manifest tools, so the
|
|
185
|
+
// managed guard would deny them. Everything else stays guarded.
|
|
186
|
+
const builtinNames = new Set(ctx.handlerBuiltinToolNames ?? []);
|
|
187
|
+
const builtinTools = {};
|
|
188
|
+
const domainTools = {};
|
|
189
|
+
for (const [name, tool] of Object.entries(ctx.tools)) {
|
|
190
|
+
(builtinNames.has(name) ? builtinTools : domainTools)[name] = tool;
|
|
191
|
+
}
|
|
192
|
+
const vercelTools = wrapToolsForVercelAi(domainTools, ctx.managedTurn
|
|
193
|
+
? {
|
|
194
|
+
beforeToolCall: ctx.managedTurn.beforeToolCall,
|
|
195
|
+
afterToolCall: ctx.managedTurn.afterToolCall,
|
|
196
|
+
onToolError: ctx.managedTurn.onToolError,
|
|
197
|
+
resolveApproval: ctx.managedTurn.resolveApproval,
|
|
198
|
+
toolTimeoutMs: ctx.managedTurn.toolTimeoutMs,
|
|
199
|
+
}
|
|
200
|
+
: undefined);
|
|
201
|
+
if (Object.keys(builtinTools).length > 0) {
|
|
202
|
+
Object.assign(vercelTools, wrapToolsForVercelAi(builtinTools));
|
|
203
|
+
}
|
|
116
204
|
const modelMessages = await prepareModelMessages(ctx.messages, { maxContextMessages: ctx.maxContextMessages });
|
|
117
205
|
let wasTruncated = false;
|
|
118
|
-
|
|
119
|
-
//
|
|
120
|
-
|
|
206
|
+
// At the runtime budget the turn blocks further tools and gets one bounded
|
|
207
|
+
// final summary, so it still ends with an answer instead of silence.
|
|
208
|
+
let finalSummaryClaimed = false;
|
|
209
|
+
const budgetExhausted = () => ctx.managedTurn?.tracker.evaluate().state === 'hard-limit';
|
|
121
210
|
const shouldStop = (event) => {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
return true;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
return false;
|
|
211
|
+
const budgetState = ctx.managedTurn?.tracker.evaluate().state;
|
|
212
|
+
const summarize = budgetState === 'hard-limit'
|
|
213
|
+
&& ctx.managedTurn.tracker.claimFinalSummary();
|
|
214
|
+
if (summarize)
|
|
215
|
+
finalSummaryClaimed = true;
|
|
216
|
+
return shouldStopManagedExecution({
|
|
217
|
+
stepCount: event.steps.length,
|
|
218
|
+
maxSteps: ctx.maxSteps,
|
|
219
|
+
budgetState: summarize ? undefined : budgetState,
|
|
220
|
+
lastStepToolNames: event.steps.at(-1)?.toolCalls.map((call) => call.toolName),
|
|
221
|
+
});
|
|
137
222
|
};
|
|
223
|
+
let providerErrorReported = false;
|
|
138
224
|
const stream = createUIMessageStream({
|
|
225
|
+
// A turn can also fail outside the provider call, e.g. on a model object
|
|
226
|
+
// from an unsupported AI SDK version. The client gets the generic text,
|
|
227
|
+
// the app's error callback the cause.
|
|
228
|
+
onError: (error) => {
|
|
229
|
+
if (!providerErrorReported) {
|
|
230
|
+
providerErrorReported = true;
|
|
231
|
+
onStreamError?.(error);
|
|
232
|
+
}
|
|
233
|
+
return 'AI request failed';
|
|
234
|
+
},
|
|
139
235
|
execute: async ({ writer }) => {
|
|
140
236
|
let totalSteps = 0;
|
|
141
237
|
let finalStateWritten = false;
|
|
238
|
+
// Cost of the running model step, read from its raw stream chunks.
|
|
239
|
+
let stepRawCostUsd = null;
|
|
142
240
|
const writePipelineState = (state, transient = false) => {
|
|
143
241
|
writer.write({
|
|
144
242
|
type: 'data-pipeline-state',
|
|
@@ -146,6 +244,11 @@ async function defaultStreamHandler(ctx, onFinish) {
|
|
|
146
244
|
transient,
|
|
147
245
|
});
|
|
148
246
|
};
|
|
247
|
+
// Ahead of the first chunk, so the UI can name a tool the moment it is called.
|
|
248
|
+
const presentation = toolPresentationOf(ctx.managedTurn?.snapshot.manifestRevision);
|
|
249
|
+
if (presentation) {
|
|
250
|
+
writer.write({ type: 'data-tool-presentation', data: presentation, transient: true });
|
|
251
|
+
}
|
|
149
252
|
writePipelineState(createPipelineState({
|
|
150
253
|
status: 'running',
|
|
151
254
|
totalSteps: 0,
|
|
@@ -157,10 +260,66 @@ async function defaultStreamHandler(ctx, onFinish) {
|
|
|
157
260
|
messages: modelMessages,
|
|
158
261
|
system: ctx.systemPrompt,
|
|
159
262
|
tools: vercelTools,
|
|
263
|
+
...(ctx.toolDiscovery
|
|
264
|
+
? { activeTools: [...ctx.toolDiscovery.activeToolNames()] }
|
|
265
|
+
: {}),
|
|
266
|
+
prepareStep: () => {
|
|
267
|
+
if (budgetExhausted()) {
|
|
268
|
+
return { activeTools: [], toolChoice: 'none' };
|
|
269
|
+
}
|
|
270
|
+
return ctx.toolDiscovery
|
|
271
|
+
? { activeTools: [...ctx.toolDiscovery.activeToolNames()] }
|
|
272
|
+
: {};
|
|
273
|
+
},
|
|
160
274
|
maxOutputTokens: ctx.maxOutputTokens,
|
|
161
275
|
temperature: ctx.temperature,
|
|
276
|
+
timeout: resolveTurnTimeout(ctx.managedTurn?.snapshot.budget.totalTimeoutMs),
|
|
162
277
|
stopWhen: shouldStop,
|
|
163
|
-
|
|
278
|
+
// OpenRouter reports `usage.cost` only in the raw final chunk when the
|
|
279
|
+
// OpenAI-compatible provider is used; the UI stream drops raw chunks.
|
|
280
|
+
includeRawChunks: Boolean(ctx.managedTurn || ctx.turnMetrics),
|
|
281
|
+
onChunk: ({ chunk }) => {
|
|
282
|
+
if (chunk.type === 'raw') {
|
|
283
|
+
stepRawCostUsd = rawChunkCostUsd(chunk.rawValue) ?? stepRawCostUsd;
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
ctx.turnMetrics?.markFirstChunk();
|
|
287
|
+
},
|
|
288
|
+
// AI SDK's default logs the complete provider error, including
|
|
289
|
+
// request/response content. Only the local consumer owns diagnostics.
|
|
290
|
+
onError: ({ error }) => {
|
|
291
|
+
providerErrorReported = true;
|
|
292
|
+
onStreamError?.(error);
|
|
293
|
+
},
|
|
294
|
+
onStepFinish: async (event) => {
|
|
295
|
+
const inputTokens = event.usage.inputTokens ?? 0;
|
|
296
|
+
const outputTokens = event.usage.outputTokens ?? 0;
|
|
297
|
+
const model = stepModelId(event);
|
|
298
|
+
const rawCostUsd = stepRawCostUsd;
|
|
299
|
+
stepRawCostUsd = null;
|
|
300
|
+
const cost = resolveStepCost({
|
|
301
|
+
model,
|
|
302
|
+
inputTokens,
|
|
303
|
+
outputTokens,
|
|
304
|
+
providerMetadata: event.providerMetadata,
|
|
305
|
+
usageRaw: event.usage.raw,
|
|
306
|
+
rawChunkCostUsd: rawCostUsd,
|
|
307
|
+
}, ctx.modelPricing);
|
|
308
|
+
// A known cost counts against maxEstimatedCostUsd; an unknown one
|
|
309
|
+
// is never recorded as 0.
|
|
310
|
+
await ctx.managedTurn?.afterModelStep({
|
|
311
|
+
inputTokens,
|
|
312
|
+
outputTokens,
|
|
313
|
+
...(cost.usd !== null ? { estimatedCostUsd: cost.usd } : {}),
|
|
314
|
+
});
|
|
315
|
+
ctx.turnMetrics?.recordStep({
|
|
316
|
+
model,
|
|
317
|
+
inputTokens,
|
|
318
|
+
outputTokens,
|
|
319
|
+
cost,
|
|
320
|
+
toolNames: event.toolCalls.map((call) => call.toolName),
|
|
321
|
+
failedToolNames: failedToolNames(event.content),
|
|
322
|
+
});
|
|
164
323
|
const report = buildStepReport({
|
|
165
324
|
stepNumber: event.stepNumber,
|
|
166
325
|
finishReason: event.finishReason,
|
|
@@ -185,6 +344,12 @@ async function defaultStreamHandler(ctx, onFinish) {
|
|
|
185
344
|
ctx.onStepReport?.(report);
|
|
186
345
|
},
|
|
187
346
|
onAbort: (event) => {
|
|
347
|
+
// The runtime time budget is the only abort source of this handler,
|
|
348
|
+
// so an abort at the hard limit is a budget stop, not a user abort.
|
|
349
|
+
const abortedByBudget = ctx.managedTurn?.tracker.evaluate().state === 'hard-limit';
|
|
350
|
+
ctx.turnMetrics?.finish(abortedByBudget
|
|
351
|
+
? { status: 'safety-stop', errorCode: 'budget_exhausted' }
|
|
352
|
+
: { status: 'aborted', errorCode: null });
|
|
188
353
|
if (finalStateWritten)
|
|
189
354
|
return;
|
|
190
355
|
totalSteps = Math.max(totalSteps, event.steps.length);
|
|
@@ -199,18 +364,26 @@ async function defaultStreamHandler(ctx, onFinish) {
|
|
|
199
364
|
finalStateWritten = true;
|
|
200
365
|
},
|
|
201
366
|
onFinish: (event) => {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
367
|
+
const budgetEvaluation = ctx.managedTurn?.tracker.evaluate();
|
|
368
|
+
const stoppedByBudget = budgetEvaluation?.state === 'hard-limit';
|
|
369
|
+
wasTruncated = finalSummaryClaimed || (event.finishReason === 'tool-calls' &&
|
|
370
|
+
(event.steps.length >= ctx.maxSteps || stoppedByBudget));
|
|
205
371
|
totalSteps = Math.max(totalSteps, event.steps.length);
|
|
206
|
-
const isSafetyStop = wasTruncated
|
|
207
|
-
|
|
372
|
+
const isSafetyStop = wasTruncated
|
|
373
|
+
&& (ctx.stepLimitSource === 'safety'
|
|
374
|
+
|| ctx.stepLimitSource === 'runtime-budget'
|
|
375
|
+
|| stoppedByBudget);
|
|
376
|
+
const status = isSafetyStop
|
|
208
377
|
? 'safety-stop'
|
|
209
|
-
:
|
|
210
|
-
? '
|
|
211
|
-
:
|
|
212
|
-
|
|
213
|
-
|
|
378
|
+
: event.finishReason === 'error'
|
|
379
|
+
? 'error'
|
|
380
|
+
: 'completed';
|
|
381
|
+
ctx.turnMetrics?.finish({
|
|
382
|
+
status,
|
|
383
|
+
errorCode: status === 'safety-stop'
|
|
384
|
+
? stoppedByBudget ? 'budget_exhausted' : 'step_limit'
|
|
385
|
+
: status === 'error' ? 'model_error' : null,
|
|
386
|
+
});
|
|
214
387
|
if (!finalStateWritten) {
|
|
215
388
|
writePipelineState(createPipelineState({
|
|
216
389
|
status,
|
|
@@ -218,8 +391,8 @@ async function defaultStreamHandler(ctx, onFinish) {
|
|
|
218
391
|
finishReason: event.finishReason,
|
|
219
392
|
maxSteps: ctx.maxSteps,
|
|
220
393
|
stepLimitSource: ctx.stepLimitSource,
|
|
221
|
-
message:
|
|
222
|
-
?
|
|
394
|
+
message: stoppedByBudget
|
|
395
|
+
? `Stopped at runtime budget: ${budgetEvaluation.reasons.join(', ')}.`
|
|
223
396
|
: wasTruncated
|
|
224
397
|
? isSafetyStop
|
|
225
398
|
? 'Paused at step safety cap. You can continue or stop.'
|
|
@@ -242,11 +415,13 @@ async function defaultStreamHandler(ctx, onFinish) {
|
|
|
242
415
|
});
|
|
243
416
|
},
|
|
244
417
|
});
|
|
245
|
-
|
|
418
|
+
const uiStream = result.toUIMessageStream({ onError: () => 'AI request failed' });
|
|
419
|
+
writer.merge(ctx.bindApprovalRequests ? ctx.bindApprovalRequests(uiStream) : uiStream);
|
|
246
420
|
try {
|
|
247
421
|
await result.response;
|
|
248
422
|
}
|
|
249
423
|
catch (error) {
|
|
424
|
+
ctx.turnMetrics?.finish({ status: 'error', errorCode: 'model_error' });
|
|
250
425
|
if (finalStateWritten)
|
|
251
426
|
return;
|
|
252
427
|
writePipelineState(createPipelineState({
|
|
@@ -258,7 +433,8 @@ async function defaultStreamHandler(ctx, onFinish) {
|
|
|
258
433
|
message: 'Pipeline failed.',
|
|
259
434
|
}));
|
|
260
435
|
finalStateWritten = true;
|
|
261
|
-
|
|
436
|
+
if (!providerErrorReported)
|
|
437
|
+
throw error;
|
|
262
438
|
}
|
|
263
439
|
},
|
|
264
440
|
});
|
|
@@ -284,7 +460,7 @@ async function defaultStreamHandler(ctx, onFinish) {
|
|
|
284
460
|
* checks happen on the backend.
|
|
285
461
|
*/
|
|
286
462
|
export function createAiChatHandler(config) {
|
|
287
|
-
const { tools: staticTools, pipeline, followups, loadTools,
|
|
463
|
+
const { tools: staticTools, managedRuntime, pipeline, followups, clarification, planning, loadTools,
|
|
288
464
|
// PII Shield
|
|
289
465
|
piiShield,
|
|
290
466
|
// Audit & Telemetry
|
|
@@ -292,7 +468,29 @@ export function createAiChatHandler(config) {
|
|
|
292
468
|
// Lancer (Pro: runtime prompt + model overrides)
|
|
293
469
|
lancer, modelDefaults, modelInstanceFactory,
|
|
294
470
|
// Shared
|
|
295
|
-
model: modelConfig, systemPrompt: systemPromptConfig, locale = 'en-US', uiActionSchema, maxOutputTokens = 600, temperature = 0.2, maxSteps: configuredMaxSteps, safetyMaxSteps = DEFAULT_SAFETY_MAX_STEPS, emitStepReports = true, maxContextMessages = 12, maxConversationHistoryPairs = 4, guardrails, intentRouter, wrapHandler, onError, onToolError, onPipelineResult, onStepReport, onFinish, streamHandler: customStreamHandler, } = config;
|
|
471
|
+
model: modelConfig, systemPrompt: systemPromptConfig, locale = 'en-US', uiActionSchema, maxOutputTokens = 600, temperature = 0.2, maxSteps: configuredMaxSteps, safetyMaxSteps = DEFAULT_SAFETY_MAX_STEPS, emitStepReports = true, maxContextMessages = 12, maxConversationHistoryPairs = 4, guardrails, intentRouter, wrapHandler, onError: onErrorConfig, onToolError, onPipelineResult, onStepReport, onFinish, streamHandler: customStreamHandler, toolDiscovery: enableToolDiscovery = false, toolSemantics, metrics, modelPricing: configuredModelPricing, directCommands = true, trustForwardedHeaders = false, endpointCaller = (request) => createInternalApiCallerFromRequest(request, { trustForwardedHeaders }), approvalSecret, approvalMaxAgeMs, approvalStore: configuredApprovalStore, approvalScope: approvalScopeOf, allowedOrigins, crossOriginProtection, maxBodyBytes, } = config;
|
|
472
|
+
if (approvalMaxAgeMs !== undefined)
|
|
473
|
+
assertApprovalMaxAge(approvalMaxAgeMs);
|
|
474
|
+
// Without a callback a failed turn would only say "AI request failed" to
|
|
475
|
+
// the user and nothing to the developer. Name only: provider errors can
|
|
476
|
+
// carry request and response content.
|
|
477
|
+
const onError = onErrorConfig ?? ((error) => {
|
|
478
|
+
const name = error instanceof Error ? error.name : typeof error;
|
|
479
|
+
console.error(`[glirastes] AI chat turn failed (${name}). Pass onError to createAiChatHandler to see the cause.`);
|
|
480
|
+
});
|
|
481
|
+
// The Proctor endpoint behind Lancer telemetry is not served by the
|
|
482
|
+
// Foundation control plane and its audit payloads are not content-free;
|
|
483
|
+
// the managed-local path reports through `metrics` instead.
|
|
484
|
+
if (managedRuntime && telemetry) {
|
|
485
|
+
throw new Error('createAiChatHandler: telemetry (legacy Lancer) cannot be combined with '
|
|
486
|
+
+ 'managedRuntime; use metrics for content-free runtime metrics');
|
|
487
|
+
}
|
|
488
|
+
// Single use without configuration: one process's memory. Instances that
|
|
489
|
+
// share a secret need a shared store to refuse a replay across instances.
|
|
490
|
+
const approvalStore = configuredApprovalStore ?? defaultApprovalStore();
|
|
491
|
+
const modelPricing = configuredModelPricing
|
|
492
|
+
? RuntimePriceTableSchema.parse(configuredModelPricing)
|
|
493
|
+
: undefined;
|
|
296
494
|
// Report model defaults to Glirastes (fire-and-forget, once)
|
|
297
495
|
let defaultsReported = false;
|
|
298
496
|
function reportDefaultsOnce() {
|
|
@@ -302,7 +500,7 @@ export function createAiChatHandler(config) {
|
|
|
302
500
|
lancer.config.reportModels(modelDefaults).catch(() => { });
|
|
303
501
|
}
|
|
304
502
|
// Build stream handler factory — per-request to allow session.ended audit
|
|
305
|
-
function createStreamHandler(auditContext) {
|
|
503
|
+
function createStreamHandler(req, auditContext) {
|
|
306
504
|
const wrappedOnFinish = (event) => {
|
|
307
505
|
onFinish?.(event);
|
|
308
506
|
if (auditContext && (onAudit || telemetry)) {
|
|
@@ -339,23 +537,223 @@ export function createAiChatHandler(config) {
|
|
|
339
537
|
};
|
|
340
538
|
return customStreamHandler
|
|
341
539
|
? customStreamHandler
|
|
342
|
-
: (ctx) => defaultStreamHandler(ctx, wrappedOnFinish);
|
|
540
|
+
: (ctx) => defaultStreamHandler(ctx, wrappedOnFinish, (error) => onError?.(error, req));
|
|
343
541
|
}
|
|
344
542
|
if (!staticTools && !loadTools) {
|
|
345
543
|
throw new Error('createAiChatHandler: either tools or loadTools must be provided');
|
|
346
544
|
}
|
|
545
|
+
const clarificationTool = clarification
|
|
546
|
+
? createClarificationTool(clarification)
|
|
547
|
+
: null;
|
|
548
|
+
const planTool = planning ? createPlanTool(planning) : null;
|
|
549
|
+
const withAlwaysOnBuiltins = (registry) => {
|
|
550
|
+
let next = registry;
|
|
551
|
+
for (const tool of [clarificationTool, planTool]) {
|
|
552
|
+
if (tool && !next[tool.id])
|
|
553
|
+
next = { ...next, [tool.id]: tool };
|
|
554
|
+
}
|
|
555
|
+
return next;
|
|
556
|
+
};
|
|
557
|
+
/** Keeps the always-on built-ins of `source` next to a scoped selection. */
|
|
558
|
+
const keepAlwaysOn = (scoped, source) => {
|
|
559
|
+
const kept = { ...scoped };
|
|
560
|
+
for (const name of ALWAYS_ON_BUILTINS) {
|
|
561
|
+
if (source[name])
|
|
562
|
+
kept[name] = source[name];
|
|
563
|
+
}
|
|
564
|
+
return kept;
|
|
565
|
+
};
|
|
566
|
+
/**
|
|
567
|
+
* The approval binder of a request, and the history with every approved
|
|
568
|
+
* call that this server did not issue (or that is expired or used) denied.
|
|
569
|
+
* Runs once the registry is known: whether tools can ask for approval
|
|
570
|
+
* decides if a missing secret is an error.
|
|
571
|
+
*/
|
|
572
|
+
/**
|
|
573
|
+
* Who an approval of this request is for: the managed principal, else the
|
|
574
|
+
* app's `approvalScope(req)` (encoded as a one-element JSON array, so it
|
|
575
|
+
* cannot equal a managed scope), else `''`: the approval is then bound to
|
|
576
|
+
* no user, and `storeScopeOf` keeps the quota per caller instead.
|
|
577
|
+
*/
|
|
578
|
+
async function requestApprovalScope(req, managedTurn) {
|
|
579
|
+
if (managedTurn)
|
|
580
|
+
return approvalScope(managedTurn.snapshot.principal);
|
|
581
|
+
if (!approvalScopeOf)
|
|
582
|
+
return '';
|
|
583
|
+
const scope = await approvalScopeOf(req);
|
|
584
|
+
if (typeof scope !== 'string')
|
|
585
|
+
throw new TypeError('approvalScope must return a string');
|
|
586
|
+
return JSON.stringify([scope]);
|
|
587
|
+
}
|
|
588
|
+
/**
|
|
589
|
+
* The scope the approval store counts a request's approvals under. With a
|
|
590
|
+
* managed principal or `approvalScope`, the signed scope. Otherwise a key
|
|
591
|
+
* per caller derived from the request's credentials (`Authorization`, else
|
|
592
|
+
* `Cookie`), HMAC-ed with the approval secret and never kept raw, so one
|
|
593
|
+
* caller with fixed credentials cannot use up everyone's quota (varying
|
|
594
|
+
* them gives a fresh quota; only the store's global limit bounds that).
|
|
595
|
+
* It only partitions the quota: it
|
|
596
|
+
* is not signed into the approval id (a cookie may rotate between the
|
|
597
|
+
* approval request and its answer), and single use is checked by the
|
|
598
|
+
* approval id across all keys. A request without credentials has `''`.
|
|
599
|
+
*/
|
|
600
|
+
function storeScopeOf(req, scope, binder) {
|
|
601
|
+
if (scope !== '')
|
|
602
|
+
return scope;
|
|
603
|
+
const credentials = req.headers.get('authorization') ?? req.headers.get('cookie');
|
|
604
|
+
if (!credentials || !binder.callerQuotaKey)
|
|
605
|
+
return '';
|
|
606
|
+
return binder.callerQuotaKey(credentials);
|
|
607
|
+
}
|
|
608
|
+
async function secureApprovals(req, registry, messages, managedTurn, scope) {
|
|
609
|
+
const binder = resolveApprovalBinder({
|
|
610
|
+
secret: approvalSecret,
|
|
611
|
+
maxAgeMs: approvalMaxAgeMs,
|
|
612
|
+
scope,
|
|
613
|
+
// The managed policy and Lancer approvals can ask for approval of a
|
|
614
|
+
// tool that declares none.
|
|
615
|
+
hasApprovalTools: Boolean(managedTurn)
|
|
616
|
+
|| Boolean(lancer?.approvals)
|
|
617
|
+
|| Object.values(registry).some((tool) => Boolean(tool.needsApproval)),
|
|
618
|
+
});
|
|
619
|
+
const storeScope = storeScopeOf(req, scope, binder);
|
|
620
|
+
const checked = await enforceApprovalBindings(messages, {
|
|
621
|
+
binder, store: approvalStore, scope: storeScope, localToolNames: new Set(Object.keys(registry)),
|
|
622
|
+
});
|
|
623
|
+
return { binder, storeScope, messages: checked.messages, verified: checked.verified };
|
|
624
|
+
}
|
|
625
|
+
/**
|
|
626
|
+
* The tools handed to the stream handler, each one that can ask for
|
|
627
|
+
* approval behind the execution gate of this request: it runs only for an
|
|
628
|
+
* approval verified above (exact tool call id, tool name and input) or for
|
|
629
|
+
* a live call whose `needsApproval` said no. A managed policy can ask for
|
|
630
|
+
* approval of any domain tool, so with a managed turn every domain tool is
|
|
631
|
+
* gated; the handler's own built-ins are not.
|
|
632
|
+
*/
|
|
633
|
+
function gateTools(tools, verified, managedTurn, builtinNames) {
|
|
634
|
+
return gateApprovalTools(tools, createApprovalExecutionGate(verified), (name, tool) => Boolean(tool.needsApproval) || (Boolean(managedTurn) && !builtinNames.includes(name)));
|
|
635
|
+
}
|
|
347
636
|
async function handler(req) {
|
|
637
|
+
const refused = checkRequestHeaders(req, { allowedOrigins, crossOriginProtection });
|
|
638
|
+
if (refused)
|
|
639
|
+
return refused;
|
|
348
640
|
reportDefaultsOnce();
|
|
641
|
+
let turnMetrics;
|
|
349
642
|
try {
|
|
350
|
-
const
|
|
351
|
-
if (!
|
|
643
|
+
const body = await readJsonBody(req, maxBodyBytes);
|
|
644
|
+
if (!body.ok)
|
|
645
|
+
return body.response;
|
|
646
|
+
const { messages: requestMessages, glirastesClientActions } = body.value;
|
|
647
|
+
if (!Array.isArray(requestMessages)) {
|
|
352
648
|
return new Response(JSON.stringify({ error: 'messages must be an array' }), { status: 400, headers: { 'Content-Type': 'application/json' } });
|
|
353
649
|
}
|
|
650
|
+
// A history the AI SDK could read in two ways (a tool call id in two
|
|
651
|
+
// parts, a non-boolean approval answer) is refused before anything else.
|
|
652
|
+
try {
|
|
653
|
+
assertUnambiguousToolHistory(requestMessages);
|
|
654
|
+
}
|
|
655
|
+
catch (error) {
|
|
656
|
+
if (error instanceof ApprovalHistoryError)
|
|
657
|
+
return approvalHistoryRefusal(error);
|
|
658
|
+
throw error;
|
|
659
|
+
}
|
|
660
|
+
// A direct command (`/` command or entity action) runs its tool without
|
|
661
|
+
// the model; the model sees earlier commands only by their label.
|
|
662
|
+
const directCommand = directCommands ? resolveDirectCommand(requestMessages) : undefined;
|
|
663
|
+
// A clarification answer resumes its original request: routing sees
|
|
664
|
+
// request + answer, the model sees an explicit continuation. The client
|
|
665
|
+
// session keeps the untouched messages.
|
|
666
|
+
const clarificationResume = directCommand ? undefined : resolveClarificationResume(requestMessages);
|
|
667
|
+
const messages = directCommand
|
|
668
|
+
? requestMessages
|
|
669
|
+
: stripChatCommandMessages(clarificationResume
|
|
670
|
+
? applyClarificationResume(requestMessages, clarificationResume)
|
|
671
|
+
: requestMessages);
|
|
354
672
|
// Build tool context
|
|
355
|
-
const toolContext = buildToolContext(req, { locale });
|
|
673
|
+
const toolContext = buildToolContext(req, { locale, trustForwardedHeaders });
|
|
674
|
+
const clientActions = readClientActions(glirastesClientActions);
|
|
675
|
+
if (clientActions)
|
|
676
|
+
toolContext.runtime = { ...toolContext.runtime, clientActions };
|
|
356
677
|
const requestStart = Date.now();
|
|
678
|
+
const turnId = deriveSessionId(messages);
|
|
679
|
+
let managedTurn;
|
|
680
|
+
if (managedRuntime) {
|
|
681
|
+
const principalResult = PrincipalSchema.safeParse(await managedRuntime.resolvePrincipal(req));
|
|
682
|
+
if (!principalResult.success) {
|
|
683
|
+
return new Response(JSON.stringify({ error: 'Unauthorized' }), { status: 401, headers: { 'Content-Type': 'application/json' } });
|
|
684
|
+
}
|
|
685
|
+
const snapshot = await managedRuntime.resolveTurnSnapshot({
|
|
686
|
+
request: req,
|
|
687
|
+
turnId,
|
|
688
|
+
principal: principalResult.data,
|
|
689
|
+
});
|
|
690
|
+
if (snapshot.turnId !== turnId
|
|
691
|
+
|| snapshot.principal.subjectId !== principalResult.data.subjectId
|
|
692
|
+
|| snapshot.principal.tenantId !== principalResult.data.tenantId) {
|
|
693
|
+
return new Response(JSON.stringify({ error: 'Turn snapshot identity mismatch' }), { status: 403, headers: { 'Content-Type': 'application/json' } });
|
|
694
|
+
}
|
|
695
|
+
managedTurn = createManagedTurnGuard({
|
|
696
|
+
snapshot,
|
|
697
|
+
resolvePrincipal: async () => {
|
|
698
|
+
const current = PrincipalSchema.safeParse(await managedRuntime.resolvePrincipal(req));
|
|
699
|
+
return current.success ? current.data : undefined;
|
|
700
|
+
},
|
|
701
|
+
loadRevocations: managedRuntime.loadRevocations
|
|
702
|
+
? () => managedRuntime.loadRevocations({ request: req, snapshot })
|
|
703
|
+
: undefined,
|
|
704
|
+
onBudgetSignal: managedRuntime.onBudgetSignal,
|
|
705
|
+
});
|
|
706
|
+
}
|
|
707
|
+
turnMetrics = metrics
|
|
708
|
+
? createTurnMetricsRecorder({
|
|
709
|
+
sink: metrics,
|
|
710
|
+
snapshot: managedTurn?.snapshot,
|
|
711
|
+
startedAtMs: requestStart,
|
|
712
|
+
})
|
|
713
|
+
: undefined;
|
|
714
|
+
const buildDiscovery = async (registry, initialToolNames, handlerBuiltinNames) => {
|
|
715
|
+
if (!enableToolDiscovery)
|
|
716
|
+
return undefined;
|
|
717
|
+
// Handler-created SDK built-ins stay active next to the searchable
|
|
718
|
+
// domain tools: clarification whenever configured, follow-ups when
|
|
719
|
+
// this turn's pipeline selected them. Registry-supplied tools sharing
|
|
720
|
+
// a built-in's name are never listed here and stay discoverable only
|
|
721
|
+
// through the manifest-checked index.
|
|
722
|
+
const builtinToolNames = handlerBuiltinNames.filter((name) => ALWAYS_ON_BUILTINS.includes(name) || initialToolNames.includes(name));
|
|
723
|
+
if (!managedTurn) {
|
|
724
|
+
return createHybridToolDiscovery({
|
|
725
|
+
discovery: createRegistryToolDiscovery({
|
|
726
|
+
turnId,
|
|
727
|
+
registry,
|
|
728
|
+
excludeNames: NON_DOMAIN_TOOL_NAMES,
|
|
729
|
+
semantics: toolSemantics,
|
|
730
|
+
}),
|
|
731
|
+
initialToolNames,
|
|
732
|
+
builtinToolNames,
|
|
733
|
+
});
|
|
734
|
+
}
|
|
735
|
+
const revocations = managedRuntime?.loadRevocations
|
|
736
|
+
? await managedRuntime.loadRevocations({
|
|
737
|
+
request: req,
|
|
738
|
+
snapshot: managedTurn.snapshot,
|
|
739
|
+
})
|
|
740
|
+
: [];
|
|
741
|
+
const revokedToolIds = managedTurn.snapshot.manifestRevision.tools
|
|
742
|
+
.filter((tool) => isToolRevoked(managedTurn.snapshot, tool.toolId, revocations))
|
|
743
|
+
.map((tool) => tool.toolId);
|
|
744
|
+
return createHybridToolDiscovery({
|
|
745
|
+
discovery: createTurnToolDiscovery({
|
|
746
|
+
snapshot: managedTurn.snapshot,
|
|
747
|
+
registry,
|
|
748
|
+
revokedToolIds,
|
|
749
|
+
semantics: toolSemantics,
|
|
750
|
+
}),
|
|
751
|
+
initialToolNames,
|
|
752
|
+
builtinToolNames,
|
|
753
|
+
});
|
|
754
|
+
};
|
|
357
755
|
// Derive session ID — stable per conversation turn (groups approval flows)
|
|
358
|
-
const sessionId = (onAudit || piiShield || telemetry) ?
|
|
756
|
+
const sessionId = (onAudit || piiShield || telemetry) ? turnId : '';
|
|
359
757
|
const toolOptions = {
|
|
360
758
|
uiActionSchema,
|
|
361
759
|
onError: onToolError,
|
|
@@ -388,12 +786,69 @@ export function createAiChatHandler(config) {
|
|
|
388
786
|
}
|
|
389
787
|
}
|
|
390
788
|
// ================================================================
|
|
789
|
+
// Direct command: no routing, no guardrails, no model call. The tool
|
|
790
|
+
// runs on the registry and wrappers of a model turn, so authorization,
|
|
791
|
+
// confirmation, revocation, budget, audit, the PII shield and metrics
|
|
792
|
+
// stay the same.
|
|
793
|
+
// ================================================================
|
|
794
|
+
if (directCommand) {
|
|
795
|
+
const callEndpoint = endpointCaller(req);
|
|
796
|
+
const endpointToolContext = {
|
|
797
|
+
...toolContext,
|
|
798
|
+
callEndpoint,
|
|
799
|
+
...(managedTurn
|
|
800
|
+
? { turnSnapshot: managedTurn.snapshot }
|
|
801
|
+
: {}),
|
|
802
|
+
...contractRejectionReporter(turnMetrics),
|
|
803
|
+
};
|
|
804
|
+
const registry = staticTools ?? await loadTools(endpointToolContext);
|
|
805
|
+
const commandScope = await requestApprovalScope(req, managedTurn);
|
|
806
|
+
const { binder: commandBinder, storeScope: commandStoreScope } = await secureApprovals(req, registry, [], managedTurn, commandScope);
|
|
807
|
+
let commandTools = toolsToAiTools(registry, endpointToolContext, toolOptions);
|
|
808
|
+
// The result stays in the chat history that later model turns send to the model.
|
|
809
|
+
if (piiShield) {
|
|
810
|
+
commandTools = wrapToolsWithShield(commandTools, piiShield, sessionId);
|
|
811
|
+
}
|
|
812
|
+
if (lancer?.approvals) {
|
|
813
|
+
commandTools = wrapToolsWithLancerApprovals(commandTools, lancer.approvals, sessionId);
|
|
814
|
+
}
|
|
815
|
+
return await runDirectCommand({
|
|
816
|
+
command: directCommand,
|
|
817
|
+
registry,
|
|
818
|
+
tools: commandTools,
|
|
819
|
+
managedTurn,
|
|
820
|
+
turnMetrics,
|
|
821
|
+
approvals: commandBinder,
|
|
822
|
+
approvalStore,
|
|
823
|
+
approvalScope: commandStoreScope,
|
|
824
|
+
onError: (error) => onError?.(error, req),
|
|
825
|
+
});
|
|
826
|
+
}
|
|
827
|
+
// ================================================================
|
|
391
828
|
// Pipeline mode
|
|
392
829
|
// ================================================================
|
|
830
|
+
// The app's own input check runs first in both modes, without any model call.
|
|
831
|
+
let processedMessages = messages;
|
|
832
|
+
if (guardrails) {
|
|
833
|
+
const check = await guardrails(messages);
|
|
834
|
+
if (!check.ok) {
|
|
835
|
+
return new Response(JSON.stringify({ error: check.reason ?? 'Invalid input' }), { status: 400, headers: { 'Content-Type': 'application/json' } });
|
|
836
|
+
}
|
|
837
|
+
if (check.sanitizedMessages) {
|
|
838
|
+
processedMessages = check.sanitizedMessages;
|
|
839
|
+
}
|
|
840
|
+
}
|
|
393
841
|
if (pipeline) {
|
|
394
842
|
// Create callEndpoint for endpoint tools (needed regardless of static/dynamic)
|
|
395
|
-
const callEndpoint =
|
|
396
|
-
const endpointToolContext = {
|
|
843
|
+
const callEndpoint = endpointCaller(req);
|
|
844
|
+
const endpointToolContext = {
|
|
845
|
+
...toolContext,
|
|
846
|
+
callEndpoint,
|
|
847
|
+
...(managedTurn
|
|
848
|
+
? { turnSnapshot: managedTurn.snapshot }
|
|
849
|
+
: {}),
|
|
850
|
+
...contractRejectionReporter(turnMetrics),
|
|
851
|
+
};
|
|
397
852
|
// Get tools (static or dynamic)
|
|
398
853
|
let registry;
|
|
399
854
|
if (staticTools) {
|
|
@@ -403,21 +858,24 @@ export function createAiChatHandler(config) {
|
|
|
403
858
|
registry = await loadTools(endpointToolContext);
|
|
404
859
|
}
|
|
405
860
|
// Add followup tool if configured
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
registry = { ...registry, [followupTool.id]: followupTool };
|
|
410
|
-
}
|
|
861
|
+
const followupTool = followups ? createFollowupTool(followups) : null;
|
|
862
|
+
if (followupTool && !registry[followupTool.id]) {
|
|
863
|
+
registry = { ...registry, [followupTool.id]: followupTool };
|
|
411
864
|
}
|
|
865
|
+
registry = withAlwaysOnBuiltins(registry);
|
|
866
|
+
const handlerBuiltinNames = findHandlerBuiltins(registry, [followupTool, clarificationTool, planTool]);
|
|
867
|
+
const pipelineApprovals = await secureApprovals(req, registry, processedMessages, managedTurn, await requestApprovalScope(req, managedTurn));
|
|
868
|
+
processedMessages = pipelineApprovals.messages;
|
|
412
869
|
// Extract user input for pipeline
|
|
413
|
-
let userText =
|
|
870
|
+
let userText = clarificationResume?.routingText
|
|
871
|
+
?? extractLastUserText(processedMessages);
|
|
414
872
|
if (piiShield) {
|
|
415
873
|
userText = await piiShield.outbound(userText, sessionId);
|
|
416
874
|
}
|
|
417
875
|
// Build lightweight conversation history for intent classification.
|
|
418
876
|
// Include the last few user/assistant text exchanges (excluding the
|
|
419
877
|
// current message) so the classifier can understand follow-ups.
|
|
420
|
-
const conversationHistory = extractConversationHistory(
|
|
878
|
+
const conversationHistory = extractConversationHistory(processedMessages, maxConversationHistoryPairs);
|
|
421
879
|
// Run pipeline: guardrails + classification + routing + model selection
|
|
422
880
|
const pipelineResult = await pipeline.process(userText, toolContext, conversationHistory.length > 0 ? conversationHistory : undefined);
|
|
423
881
|
// Notify consumer about pipeline decision
|
|
@@ -465,21 +923,47 @@ export function createAiChatHandler(config) {
|
|
|
465
923
|
// Telemetry is fire-and-forget
|
|
466
924
|
}
|
|
467
925
|
}
|
|
926
|
+
const hasExplicitSelection = pipelineResult.toolSelection === 'explicit';
|
|
927
|
+
const initialToolNames = pipelineResult.blocked
|
|
928
|
+
? []
|
|
929
|
+
: hasExplicitSelection || pipelineResult.tools.length > 0
|
|
930
|
+
? pipelineResult.tools
|
|
931
|
+
: Object.keys(registry);
|
|
932
|
+
const discoveryController = pipelineResult.blocked
|
|
933
|
+
? undefined
|
|
934
|
+
: await buildDiscovery(registry, initialToolNames, handlerBuiltinNames);
|
|
468
935
|
// Convert all tools to AI tools
|
|
469
936
|
let aiTools = await toolsToAiTools(registry, endpointToolContext, toolOptions);
|
|
937
|
+
const unscopedAiTools = aiTools;
|
|
470
938
|
// Scope tools to pipeline selection
|
|
471
939
|
if (pipelineResult.blocked) {
|
|
472
940
|
// Guardrails blocked — no tools allowed
|
|
473
941
|
aiTools = {};
|
|
474
942
|
}
|
|
475
|
-
else if (pipelineResult.tools.length > 0) {
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
943
|
+
else if (!discoveryController && (hasExplicitSelection || pipelineResult.tools.length > 0)) {
|
|
944
|
+
aiTools = scopePipelineTools({
|
|
945
|
+
aiTools,
|
|
946
|
+
registryToolNames: new Set(Object.keys(registry)),
|
|
947
|
+
selected: pipelineResult.tools,
|
|
948
|
+
fallbackToAll: !hasExplicitSelection,
|
|
949
|
+
});
|
|
950
|
+
// Clarification and the plan stay callable, also for an empty
|
|
951
|
+
// focused selection.
|
|
952
|
+
aiTools = keepAlwaysOn(aiTools, unscopedAiTools);
|
|
953
|
+
}
|
|
954
|
+
// An approval verified (and consumed) above answers a call that an
|
|
955
|
+
// earlier request already routed. Routing for this request must not
|
|
956
|
+
// turn that approved call into a tool error, so its tool stays in the
|
|
957
|
+
// set (the AI SDK runs approved calls from `tools`, not `activeTools`).
|
|
958
|
+
// Only tools with a verified approval come back; a new call to one of
|
|
959
|
+
// them still needs its own approval. A guardrail block keeps no tools,
|
|
960
|
+
// so the approved call then ends as a tool error and is not run.
|
|
961
|
+
if (!pipelineResult.blocked) {
|
|
962
|
+
for (const { toolName } of pipelineApprovals.verified) {
|
|
963
|
+
const approvedTool = unscopedAiTools[toolName];
|
|
964
|
+
if (approvedTool && !aiTools[toolName])
|
|
965
|
+
aiTools = { ...aiTools, [toolName]: approvedTool };
|
|
480
966
|
}
|
|
481
|
-
if (Object.keys(scoped).length > 0)
|
|
482
|
-
aiTools = scoped;
|
|
483
967
|
}
|
|
484
968
|
// Resolve model — config callback > pipeline instance > error
|
|
485
969
|
let model;
|
|
@@ -493,6 +977,7 @@ export function createAiChatHandler(config) {
|
|
|
493
977
|
model = pipelineResult.model.instance;
|
|
494
978
|
}
|
|
495
979
|
else {
|
|
980
|
+
turnMetrics?.finish({ status: 'error', errorCode: 'pipeline_error' });
|
|
496
981
|
return new Response(JSON.stringify({
|
|
497
982
|
error: 'No model configured. Provide model on handler config or as instance on ModelSelectorConfig.',
|
|
498
983
|
}), { status: 500, headers: { 'Content-Type': 'application/json' } });
|
|
@@ -502,6 +987,7 @@ export function createAiChatHandler(config) {
|
|
|
502
987
|
? systemPromptConfig({
|
|
503
988
|
pipelineResult,
|
|
504
989
|
currentDate: new Date(),
|
|
990
|
+
...(managedTurn ? { turnSnapshot: managedTurn.snapshot } : {}),
|
|
505
991
|
})
|
|
506
992
|
: systemPromptConfig;
|
|
507
993
|
// Track the actual model ID used (may be overridden by Glirastes config)
|
|
@@ -541,10 +1027,11 @@ export function createAiChatHandler(config) {
|
|
|
541
1027
|
moduleMaxSteps: pipelineResult.module?.executionDefaults?.maxSteps,
|
|
542
1028
|
configuredMaxSteps,
|
|
543
1029
|
safetyMaxSteps,
|
|
1030
|
+
runtimeBudgetMaxSteps: managedTurn?.snapshot.budget.maxModelSteps,
|
|
544
1031
|
});
|
|
545
1032
|
const contextWindow = pipelineResult.module?.executionDefaults?.contextWindow ??
|
|
546
1033
|
maxContextMessages;
|
|
547
|
-
let recentMessages =
|
|
1034
|
+
let recentMessages = processedMessages.slice(-contextWindow);
|
|
548
1035
|
// PII Shield: anonymize message history + wrap tools
|
|
549
1036
|
if (piiShield) {
|
|
550
1037
|
recentMessages = await anonymizeMessages(recentMessages, piiShield, sessionId);
|
|
@@ -554,13 +1041,16 @@ export function createAiChatHandler(config) {
|
|
|
554
1041
|
if (lancer?.approvals) {
|
|
555
1042
|
aiTools = wrapToolsWithLancerApprovals(aiTools, lancer.approvals, sessionId);
|
|
556
1043
|
}
|
|
557
|
-
|
|
1044
|
+
aiTools = gateTools(aiTools, pipelineApprovals.verified, managedTurn, handlerBuiltinNames);
|
|
1045
|
+
const pipelineStreamHandler = createStreamHandler(req, (onAudit || telemetry) ? {
|
|
558
1046
|
sessionId,
|
|
559
1047
|
requestStart,
|
|
560
1048
|
modelId: resolvedModelId,
|
|
561
1049
|
} : undefined);
|
|
562
|
-
return pipelineStreamHandler({
|
|
563
|
-
tools:
|
|
1050
|
+
return await pipelineStreamHandler({
|
|
1051
|
+
tools: discoveryController
|
|
1052
|
+
? { ...aiTools, find_tools: discoveryController.tool }
|
|
1053
|
+
: aiTools,
|
|
564
1054
|
messages: recentMessages,
|
|
565
1055
|
systemPrompt,
|
|
566
1056
|
model,
|
|
@@ -574,25 +1064,29 @@ export function createAiChatHandler(config) {
|
|
|
574
1064
|
modelTier: pipelineResult.model.modelId,
|
|
575
1065
|
pipelineResult,
|
|
576
1066
|
piiShield: piiShield ? { shield: piiShield, sessionId } : undefined,
|
|
1067
|
+
managedTurn,
|
|
1068
|
+
turnMetrics,
|
|
1069
|
+
modelPricing,
|
|
1070
|
+
toolDiscovery: discoveryController,
|
|
1071
|
+
handlerBuiltinToolNames: discoveryController
|
|
1072
|
+
? [...handlerBuiltinNames, 'find_tools']
|
|
1073
|
+
: handlerBuiltinNames,
|
|
1074
|
+
bindApprovalRequests: (stream) => bindApprovalRequests(stream, pipelineApprovals.binder),
|
|
577
1075
|
});
|
|
578
1076
|
}
|
|
579
1077
|
// ================================================================
|
|
580
1078
|
// Legacy mode (without pipeline)
|
|
581
1079
|
// ================================================================
|
|
582
|
-
// Guardrails
|
|
583
|
-
let processedMessages = messages;
|
|
584
|
-
if (guardrails) {
|
|
585
|
-
const check = await guardrails(messages);
|
|
586
|
-
if (!check.ok) {
|
|
587
|
-
return new Response(JSON.stringify({ error: check.reason ?? 'Invalid input' }), { status: 400, headers: { 'Content-Type': 'application/json' } });
|
|
588
|
-
}
|
|
589
|
-
if (check.sanitizedMessages) {
|
|
590
|
-
processedMessages = check.sanitizedMessages;
|
|
591
|
-
}
|
|
592
|
-
}
|
|
593
1080
|
// Create callEndpoint for endpoint tools (needed regardless of static/dynamic)
|
|
594
|
-
const callEndpoint =
|
|
595
|
-
const endpointToolContext = {
|
|
1081
|
+
const callEndpoint = endpointCaller(req);
|
|
1082
|
+
const endpointToolContext = {
|
|
1083
|
+
...toolContext,
|
|
1084
|
+
callEndpoint,
|
|
1085
|
+
...(managedTurn
|
|
1086
|
+
? { turnSnapshot: managedTurn.snapshot }
|
|
1087
|
+
: {}),
|
|
1088
|
+
...contractRejectionReporter(turnMetrics),
|
|
1089
|
+
};
|
|
596
1090
|
// Load tools
|
|
597
1091
|
let registry;
|
|
598
1092
|
if (staticTools) {
|
|
@@ -601,7 +1095,12 @@ export function createAiChatHandler(config) {
|
|
|
601
1095
|
else {
|
|
602
1096
|
registry = await loadTools(endpointToolContext);
|
|
603
1097
|
}
|
|
604
|
-
|
|
1098
|
+
registry = withAlwaysOnBuiltins(registry);
|
|
1099
|
+
const handlerBuiltinNames = findHandlerBuiltins(registry, [clarificationTool, planTool]);
|
|
1100
|
+
const legacyApprovals = await secureApprovals(req, registry, processedMessages, managedTurn, await requestApprovalScope(req, managedTurn));
|
|
1101
|
+
processedMessages = legacyApprovals.messages;
|
|
1102
|
+
const allToolNames = Object.keys(registry)
|
|
1103
|
+
.filter((name) => !ALWAYS_ON_BUILTINS.includes(name));
|
|
605
1104
|
// PII Shield: anonymize for legacy mode
|
|
606
1105
|
const legacySessionId = piiShield ? deriveSessionId(processedMessages) : '';
|
|
607
1106
|
if (piiShield) {
|
|
@@ -611,7 +1110,8 @@ export function createAiChatHandler(config) {
|
|
|
611
1110
|
// Intent routing
|
|
612
1111
|
let routing;
|
|
613
1112
|
if (intentRouter) {
|
|
614
|
-
const text =
|
|
1113
|
+
const text = clarificationResume?.routingText
|
|
1114
|
+
?? extractLastUserText(processedMessages);
|
|
615
1115
|
routing = await intentRouter(text, allToolNames);
|
|
616
1116
|
}
|
|
617
1117
|
// Convert to AI tools
|
|
@@ -623,11 +1123,19 @@ export function createAiChatHandler(config) {
|
|
|
623
1123
|
if (aiTools[name])
|
|
624
1124
|
scoped[name] = aiTools[name];
|
|
625
1125
|
}
|
|
626
|
-
if (Object.keys(scoped).length > 0)
|
|
627
|
-
aiTools = scoped;
|
|
1126
|
+
if (Object.keys(scoped).length > 0) {
|
|
1127
|
+
aiTools = keepAlwaysOn(scoped, aiTools);
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
const discoveryController = await buildDiscovery(registry, routing?.toolNames?.length ? routing.toolNames : allToolNames, handlerBuiltinNames);
|
|
1131
|
+
if (discoveryController) {
|
|
1132
|
+
// Discovery needs the full eligible server-side set; `activeTools`
|
|
1133
|
+
// preserves the intent router's fast initial scope.
|
|
1134
|
+
aiTools = await toolsToAiTools(registry, endpointToolContext, toolOptions);
|
|
628
1135
|
}
|
|
629
1136
|
// Resolve model + system prompt (legacy mode — no pipeline fallback)
|
|
630
1137
|
if (!modelConfig) {
|
|
1138
|
+
turnMetrics?.finish({ status: 'error', errorCode: 'pipeline_error' });
|
|
631
1139
|
return new Response(JSON.stringify({
|
|
632
1140
|
error: 'No model configured. In legacy mode (without pipeline), model is required.',
|
|
633
1141
|
}), { status: 500, headers: { 'Content-Type': 'application/json' } });
|
|
@@ -639,11 +1147,13 @@ export function createAiChatHandler(config) {
|
|
|
639
1147
|
? systemPromptConfig({
|
|
640
1148
|
routing,
|
|
641
1149
|
currentDate: new Date(),
|
|
1150
|
+
...(managedTurn ? { turnSnapshot: managedTurn.snapshot } : {}),
|
|
642
1151
|
})
|
|
643
1152
|
: systemPromptConfig;
|
|
644
1153
|
const stepLimit = resolveStepLimit({
|
|
645
1154
|
configuredMaxSteps: routing?.maxSteps ?? configuredMaxSteps,
|
|
646
1155
|
safetyMaxSteps,
|
|
1156
|
+
runtimeBudgetMaxSteps: managedTurn?.snapshot.budget.maxModelSteps,
|
|
647
1157
|
});
|
|
648
1158
|
const contextWindow = routing?.contextWindow ?? maxContextMessages;
|
|
649
1159
|
let recentMessages = processedMessages.slice(-contextWindow);
|
|
@@ -656,13 +1166,16 @@ export function createAiChatHandler(config) {
|
|
|
656
1166
|
if (lancer?.approvals) {
|
|
657
1167
|
aiTools = wrapToolsWithLancerApprovals(aiTools, lancer.approvals, legacySessionId || sessionId);
|
|
658
1168
|
}
|
|
659
|
-
|
|
1169
|
+
aiTools = gateTools(aiTools, legacyApprovals.verified, managedTurn, handlerBuiltinNames);
|
|
1170
|
+
const legacyStreamHandler = createStreamHandler(req, (onAudit || telemetry) ? {
|
|
660
1171
|
sessionId: legacySessionId || sessionId,
|
|
661
1172
|
requestStart,
|
|
662
1173
|
} : undefined);
|
|
663
1174
|
// Delegate streaming to consumer's handler
|
|
664
|
-
return legacyStreamHandler({
|
|
665
|
-
tools:
|
|
1175
|
+
return await legacyStreamHandler({
|
|
1176
|
+
tools: discoveryController
|
|
1177
|
+
? { ...aiTools, find_tools: discoveryController.tool }
|
|
1178
|
+
: aiTools,
|
|
666
1179
|
messages: recentMessages,
|
|
667
1180
|
systemPrompt,
|
|
668
1181
|
model,
|
|
@@ -676,10 +1189,26 @@ export function createAiChatHandler(config) {
|
|
|
676
1189
|
modelTier: routing?.modelTier,
|
|
677
1190
|
routing,
|
|
678
1191
|
piiShield: piiShield ? { shield: piiShield, sessionId: legacySessionId } : undefined,
|
|
1192
|
+
managedTurn,
|
|
1193
|
+
turnMetrics,
|
|
1194
|
+
modelPricing,
|
|
1195
|
+
toolDiscovery: discoveryController,
|
|
1196
|
+
handlerBuiltinToolNames: discoveryController
|
|
1197
|
+
? [...handlerBuiltinNames, 'find_tools']
|
|
1198
|
+
: handlerBuiltinNames,
|
|
1199
|
+
bindApprovalRequests: (stream) => bindApprovalRequests(stream, legacyApprovals.binder),
|
|
679
1200
|
});
|
|
680
1201
|
}
|
|
681
1202
|
catch (error) {
|
|
1203
|
+
if (error instanceof ApprovalHistoryError) {
|
|
1204
|
+
turnMetrics?.finish({ status: 'error', errorCode: 'pipeline_error' });
|
|
1205
|
+
return approvalHistoryRefusal(error);
|
|
1206
|
+
}
|
|
1207
|
+
turnMetrics?.finish({ status: 'error', errorCode: 'pipeline_error' });
|
|
682
1208
|
onError?.(error, req);
|
|
1209
|
+
if (error instanceof ApprovalSecretMissingError) {
|
|
1210
|
+
return new Response(JSON.stringify({ error: error.code, message: error.message }), { status: 500, headers: { 'Content-Type': 'application/json' } });
|
|
1211
|
+
}
|
|
683
1212
|
return new Response(JSON.stringify({ error: 'AI request failed' }), { status: 500, headers: { 'Content-Type': 'application/json' } });
|
|
684
1213
|
}
|
|
685
1214
|
}
|
|
@@ -688,6 +1217,14 @@ export function createAiChatHandler(config) {
|
|
|
688
1217
|
}
|
|
689
1218
|
return handler;
|
|
690
1219
|
}
|
|
1220
|
+
/**
|
|
1221
|
+
* SDK built-ins whose tool instance the handler itself put into the registry.
|
|
1222
|
+
* Instance identity decides, not the name: a registry- or manifest-supplied
|
|
1223
|
+
* tool that shares a built-in's name is never listed and stays fully guarded.
|
|
1224
|
+
*/
|
|
1225
|
+
function findHandlerBuiltins(registry, created) {
|
|
1226
|
+
return NON_DOMAIN_TOOL_NAMES.filter((name) => created.some((tool) => tool !== null && registry[name] === tool));
|
|
1227
|
+
}
|
|
691
1228
|
// ============================================================================
|
|
692
1229
|
// PII Shield Helpers
|
|
693
1230
|
// ============================================================================
|
|
@@ -700,7 +1237,10 @@ function deriveSessionId(messages) {
|
|
|
700
1237
|
return `ai-${msg.id}`;
|
|
701
1238
|
}
|
|
702
1239
|
}
|
|
703
|
-
return `ai-${
|
|
1240
|
+
return `ai-${globalThis.crypto.randomUUID()}`;
|
|
1241
|
+
}
|
|
1242
|
+
function approvalHistoryRefusal(error) {
|
|
1243
|
+
return new Response(JSON.stringify({ error: error.code, message: error.message }), { status: 400, headers: { 'Content-Type': 'application/json' } });
|
|
704
1244
|
}
|
|
705
1245
|
async function anonymizeMessages(messages, shield, sessionId) {
|
|
706
1246
|
const result = [];
|
|
@@ -710,9 +1250,10 @@ async function anonymizeMessages(messages, shield, sessionId) {
|
|
|
710
1250
|
continue;
|
|
711
1251
|
}
|
|
712
1252
|
const record = msg;
|
|
713
|
-
// Only anonymize
|
|
1253
|
+
// Only user messages carry text to anonymize; of the others, only the
|
|
1254
|
+
// arguments of a direct command's tool call are the user's own words.
|
|
714
1255
|
if (record.role !== 'user') {
|
|
715
|
-
result.push(
|
|
1256
|
+
result.push(await pseudonymizeCommandToolInputs(record, shield, sessionId));
|
|
716
1257
|
continue;
|
|
717
1258
|
}
|
|
718
1259
|
// Anonymize string content
|
|
@@ -958,4 +1499,15 @@ function extractTextFromMessage(msg) {
|
|
|
958
1499
|
}
|
|
959
1500
|
return texts.join(' ');
|
|
960
1501
|
}
|
|
1502
|
+
/**
|
|
1503
|
+
* The client actions the chat reported for the open page, or undefined when
|
|
1504
|
+
* the report is missing or malformed (then client-action tools run as before).
|
|
1505
|
+
*/
|
|
1506
|
+
function readClientActions(value) {
|
|
1507
|
+
if (!Array.isArray(value) || value.length > 500)
|
|
1508
|
+
return undefined;
|
|
1509
|
+
if (!value.every((id) => typeof id === 'string' && id.length > 0 && id.length <= 200))
|
|
1510
|
+
return undefined;
|
|
1511
|
+
return value;
|
|
1512
|
+
}
|
|
961
1513
|
//# sourceMappingURL=create-ai-chat-handler.js.map
|