@opengeni/api-router 0.30.1 → 1.0.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/dist/access-grant-rls.d.ts +3 -0
- package/dist/admission-trace.d.ts +8 -0
- package/dist/api-websocket.d.ts +18 -0
- package/dist/app.d.ts +50 -2
- package/dist/app.js +12 -1
- package/dist/artifact-catalog-cursor.d.ts +27 -0
- package/dist/auth/managed-auth-attempt-context.d.ts +10 -0
- package/dist/auth/managed-auth-rate-limits.d.ts +167 -0
- package/dist/auth/managed-auth-session-adapter.d.ts +6 -0
- package/dist/auth/managed-auth.d.ts +102 -3
- package/dist/auth/managed-email.d.ts +29 -0
- package/dist/auth/managed-sign-in-notifications.d.ts +4 -0
- package/dist/auth/new-signups-gate.d.ts +23 -0
- package/dist/auth/organization-user-setup.d.ts +80 -0
- package/dist/auth/signup-funnel-metrics.d.ts +44 -0
- package/dist/browser-controller-authority.d.ts +1 -61
- package/dist/browser-ephemeral.d.ts +5 -0
- package/dist/browser-state-authority.d.ts +1 -27
- package/dist/chunk-6TZ5LG3O.js +123948 -0
- package/dist/chunk-6TZ5LG3O.js.map +1 -0
- package/dist/chunk-OGQDXVXY.js +18 -0
- package/dist/chunk-OGQDXVXY.js.map +1 -0
- package/dist/claude-subscription-account-conflicts.d.ts +1 -0
- package/dist/claude-subscription-account-usage.d.ts +39 -0
- package/dist/claude-subscription-oauth.d.ts +25 -0
- package/dist/claude-subscription-profile.d.ts +9 -0
- package/dist/claude-subscription-usage.d.ts +44 -0
- package/dist/claude-workspace-connection.d.ts +15 -0
- package/dist/codemode.d.ts +32 -1
- package/dist/company-brain-okf.d.ts +24 -0
- package/dist/connected-machine-computer-access.d.ts +11 -0
- package/dist/connection-ownership.d.ts +54 -0
- package/dist/controller-data-plane.d.ts +32 -0
- package/dist/editable-artifact-office-import.d.ts +7 -4
- package/dist/editable-artifact-source-session.d.ts +3 -0
- package/dist/editable-artifact-websocket.d.ts +10 -18
- package/dist/editable-artifact-workspace-files.d.ts +1 -1
- package/dist/fatal-process-boundary.d.ts +25 -0
- package/dist/github-access.d.ts +31 -2
- package/dist/http/acting-person.d.ts +24 -0
- package/dist/http/api-contract-compat.d.ts +19 -0
- package/dist/http/api-error.d.ts +27 -1
- package/dist/http/cors.d.ts +17 -0
- package/dist/http/deprecation.d.ts +42 -0
- package/dist/http/interaction-control-error.d.ts +13 -0
- package/dist/http/keyed-admission.d.ts +12 -0
- package/dist/http/local-browser-boundary.d.ts +72 -0
- package/dist/http/metrics-listener.d.ts +22 -0
- package/dist/http/path-identifier.d.ts +17 -0
- package/dist/http/registered-route-label.d.ts +16 -0
- package/dist/http/request-body.d.ts +27 -0
- package/dist/http/request-source.d.ts +52 -0
- package/dist/http/sse.d.ts +17 -6
- package/dist/http/unmatched-route.d.ts +18 -0
- package/dist/http/user-content.d.ts +36 -0
- package/dist/http/websocket-upgrade-dispatch.d.ts +18 -0
- package/dist/index.d.ts +10 -3
- package/dist/index.js +1129 -166
- package/dist/index.js.map +1 -1
- package/dist/integration-endpoint-test.d.ts +20 -0
- package/dist/integrations/api-integrations.d.ts +2 -2
- package/dist/integrations/atlassian.d.ts +29 -3
- package/dist/integrations/connect-authority.d.ts +1 -0
- package/dist/integrations/connect-callback-return.d.ts +6 -0
- package/dist/integrations/fiken.d.ts +16 -2
- package/dist/integrations/github-app-connect.d.ts +47 -0
- package/dist/integrations/github-installation-proof.d.ts +3 -0
- package/dist/integrations/github-lens-connect.d.ts +116 -0
- package/dist/integrations/github-skill-source.d.ts +1 -5
- package/dist/integrations/google-drive.d.ts +25 -0
- package/dist/integrations/integration-commit-authority.d.ts +13 -0
- package/dist/integrations/marketplace-plugin.d.ts +2691 -0
- package/dist/integrations/oauth-client.d.ts +178 -18
- package/dist/integrations/oauth-profiles.d.ts +222 -0
- package/dist/integrations/oauth-return-path.d.ts +1 -0
- package/dist/integrations/personal-github-repositories.d.ts +84 -0
- package/dist/integrations/personal-github.d.ts +42 -0
- package/dist/integrations/pr-review-provider.d.ts +22 -0
- package/dist/integrations/provider-oauth.d.ts +19 -1
- package/dist/integrations/slack-app-home.d.ts +24 -0
- package/dist/integrations/slack-bot.d.ts +367 -12
- package/dist/integrations/slack-file-upload-flow.d.ts +62 -0
- package/dist/integrations/slack-install.d.ts +20 -0
- package/dist/integrations/slack-interactions.d.ts +113 -10
- package/dist/integrations/slack-mrkdwn.d.ts +41 -0
- package/dist/integrations/slack-routing.d.ts +120 -0
- package/dist/integrations/slack-session-defaults.d.ts +58 -0
- package/dist/integrations/slack-task-file-upload.d.ts +36 -0
- package/dist/integrations/social-oauth.d.ts +7 -0
- package/dist/interaction-agent-access.d.ts +15 -0
- package/dist/interaction-frame-proxy.d.ts +68 -0
- package/dist/interaction-metrics.d.ts +2 -0
- package/dist/mcp/action-catalog-types.d.ts +9 -0
- package/dist/mcp/action-catalog.gen.d.ts +2 -0
- package/dist/mcp/capability-account-readiness.d.ts +7 -0
- package/dist/mcp/child-read-evidence.d.ts +9 -0
- package/dist/mcp/command-read.d.ts +24 -0
- package/dist/mcp/company-profile-agent-admin.d.ts +44 -0
- package/dist/mcp/contract-input.d.ts +11 -0
- package/dist/mcp/documents.d.ts +7 -5
- package/dist/mcp/files.d.ts +2 -2
- package/dist/mcp/first-party-tool-permissions.d.ts +650 -0
- package/dist/mcp/knowledge-entries.d.ts +5 -0
- package/dist/mcp/orchestration-failure-diagnostic.d.ts +43 -0
- package/dist/mcp/receipts.d.ts +9 -0
- package/dist/mcp/request-abort.d.ts +19 -0
- package/dist/mcp/scheduled-task-input.d.ts +1189 -0
- package/dist/mcp/scheduled-task-view.d.ts +22 -4
- package/dist/mcp/server.d.ts +255 -3
- package/dist/mcp/session-event-view.d.ts +94 -0
- package/dist/mcp/session-view.d.ts +66 -2
- package/dist/mcp/session-wait.d.ts +174 -0
- package/dist/mcp-oauth.d.ts +52 -0
- package/dist/model-catalog.d.ts +11 -31
- package/dist/observability.d.ts +3 -1
- package/dist/organization-mcp.d.ts +52 -0
- package/dist/organization-recovery-notifications.d.ts +41 -0
- package/dist/routes/analytics-consent.d.ts +26 -0
- package/dist/routes/api-integrations.d.ts +25 -0
- package/dist/routes/api-keys.d.ts +17 -0
- package/dist/routes/artifact-catalog.d.ts +6 -0
- package/dist/routes/automations.d.ts +19 -0
- package/dist/routes/billing.d.ts +49 -0
- package/dist/routes/browser-sessions.d.ts +71 -3
- package/dist/routes/claude-subscription-accounts.d.ts +3 -0
- package/dist/routes/claude-subscription-oauth.d.ts +3 -0
- package/dist/routes/client-errors.d.ts +146 -0
- package/dist/routes/codex.d.ts +76 -2
- package/dist/routes/company-brain.d.ts +3 -0
- package/dist/routes/company-profile.d.ts +2 -1
- package/dist/routes/computer-sessions.d.ts +14 -0
- package/dist/routes/connect.d.ts +5 -0
- package/dist/routes/editable-artifacts.d.ts +2 -0
- package/dist/routes/external-identity-links.d.ts +6 -0
- package/dist/routes/feedback.d.ts +3 -0
- package/dist/routes/files.d.ts +4 -0
- package/dist/routes/github-browser-pages.d.ts +12 -0
- package/dist/routes/github.d.ts +2 -0
- package/dist/routes/insights-response-cache.d.ts +10 -0
- package/dist/routes/insights-usage.d.ts +12 -0
- package/dist/routes/insights.d.ts +30 -1
- package/dist/routes/knowledge.d.ts +3 -0
- package/dist/routes/managed-auth-session-sets.d.ts +26 -0
- package/dist/routes/managed-onboarding.d.ts +29 -0
- package/dist/routes/managed-sign-in-methods.d.ts +6 -0
- package/dist/routes/model-connection-access.d.ts +3 -0
- package/dist/routes/organization-integration-policy.d.ts +3 -0
- package/dist/routes/organization-integrations.d.ts +6 -0
- package/dist/routes/organization-mcp-connections.d.ts +3 -0
- package/dist/routes/organization-model-providers.d.ts +3 -0
- package/dist/routes/organization-recovery.d.ts +19 -0
- package/dist/routes/organization-service-accounts.d.ts +3 -0
- package/dist/routes/organization-sessions.d.ts +26 -0
- package/dist/routes/personal-github-git-broker.d.ts +29 -0
- package/dist/routes/personal-github.d.ts +3 -0
- package/dist/routes/pr-review-github.d.ts +3 -0
- package/dist/routes/pr-review.d.ts +3 -0
- package/dist/routes/session-artifact-associations.d.ts +4 -0
- package/dist/routes/session-history-imports.d.ts +9 -0
- package/dist/routes/sessions.d.ts +44 -6
- package/dist/routes/skill-content.d.ts +4 -0
- package/dist/routes/skill-install-authority.d.ts +6 -0
- package/dist/routes/subscription-account-pools.d.ts +34 -0
- package/dist/routes/subscription-pool-access.d.ts +16 -0
- package/dist/routes/supergrok.d.ts +6 -1
- package/dist/routes/usage-allowances.d.ts +12 -0
- package/dist/routes/user-resource-authorities.d.ts +3 -0
- package/dist/routes/workspace-artifacts.d.ts +2 -1
- package/dist/routes/workspace-capture.d.ts +10 -2
- package/dist/routes/workspace-integrations.d.ts +35 -0
- package/dist/routes/workspace-learning.d.ts +3 -0
- package/dist/routes/workspace-model-providers.d.ts +4 -0
- package/dist/routes/workspaces.d.ts +29 -0
- package/dist/sandbox/auth-callout.d.ts +8 -0
- package/dist/sandbox/channel-a.d.ts +19 -1
- package/dist/sandbox/connection-authority.d.ts +3 -0
- package/dist/sandbox/enrollment.d.ts +9 -1
- package/dist/sandbox/machines.d.ts +5 -2
- package/dist/sandbox/metrics-ingestion.d.ts +28 -20
- package/dist/sandbox/rematerialize.d.ts +2 -0
- package/dist/sandbox/session-attach-variable-sets.d.ts +30 -0
- package/dist/sandbox/viewer.d.ts +26 -1
- package/dist/sandbox-file-artifacts.d.ts +50 -0
- package/dist/scheduled-task-deletion.d.ts +13 -0
- package/dist/session-create-observability.d.ts +5 -0
- package/dist/session-event-view-MPS2OZD3.js +292 -0
- package/dist/session-event-view-MPS2OZD3.js.map +1 -0
- package/dist/site-session-origin.d.ts +13 -0
- package/dist/site-uploads.d.ts +41 -0
- package/dist/slack-reaction-files.d.ts +1 -1
- package/dist/temporal-schedule-cleanup.d.ts +1 -0
- package/dist/temporal-schedule-sync.d.ts +26 -0
- package/dist/transcription/providers/xai-subscription.d.ts +1 -0
- package/dist/transcription/service.d.ts +2 -1
- package/dist/work-discovery-observability.d.ts +33 -0
- package/dist/workspace-artifact-content.d.ts +28 -0
- package/dist/workspace-artifact-provenance.d.ts +7 -0
- package/dist/workspace-delete-observability.d.ts +10 -0
- package/dist/workspace-deletion.d.ts +6 -0
- package/dist/workspace-state-projection.d.ts +3 -5
- package/dist/workspace-tool-gateway-observability.d.ts +17 -0
- package/dist/workspace-tool-gateway.d.ts +123 -0
- package/dist/workspace-webhook-dispatch.d.ts +26 -0
- package/package.json +23 -19
- package/src/access-grant-rls.ts +75 -0
- package/src/admission-trace.ts +14 -0
- package/src/api-websocket.ts +23 -0
- package/src/app.ts +1974 -256
- package/src/artifact-catalog-cursor.ts +60 -0
- package/src/auth/managed-auth-attempt-context.ts +70 -0
- package/src/auth/managed-auth-rate-limits.ts +252 -0
- package/src/auth/managed-auth-session-adapter.ts +222 -0
- package/src/auth/managed-auth.ts +536 -60
- package/src/auth/managed-email.ts +174 -0
- package/src/auth/managed-sign-in-notifications.ts +81 -0
- package/src/auth/new-signups-gate.ts +49 -0
- package/src/auth/organization-user-setup.ts +307 -0
- package/src/auth/signup-funnel-metrics.ts +164 -0
- package/src/browser-controller-authority.ts +1 -186
- package/src/browser-ephemeral.ts +39 -0
- package/src/browser-state-authority.ts +1 -236
- package/src/claude-subscription-account-conflicts.ts +12 -0
- package/src/claude-subscription-account-usage.ts +48 -0
- package/src/claude-subscription-oauth.ts +362 -0
- package/src/claude-subscription-profile.ts +73 -0
- package/src/claude-subscription-usage.ts +97 -0
- package/src/claude-workspace-connection.ts +82 -0
- package/src/codemode.ts +194 -30
- package/src/codex-realtime.ts +8 -2
- package/src/company-brain-okf.ts +340 -0
- package/src/connected-machine-computer-access.ts +33 -0
- package/src/connection-ownership.ts +199 -0
- package/src/controller-data-plane.ts +81 -0
- package/src/editable-artifact-native-kernel.ts +26 -15
- package/src/editable-artifact-office-import.ts +77 -9
- package/src/editable-artifact-production.ts +23 -7
- package/src/editable-artifact-source-session.ts +123 -0
- package/src/editable-artifact-websocket.ts +27 -21
- package/src/editable-artifact-workspace-files.ts +31 -6
- package/src/fatal-process-boundary.ts +246 -0
- package/src/gateway-realtime.ts +1 -1
- package/src/github-access.ts +147 -5
- package/src/http/acting-person.ts +71 -0
- package/src/http/api-contract-compat.ts +49 -0
- package/src/http/api-error.ts +115 -1
- package/src/http/auth.ts +48 -0
- package/src/http/cors.ts +67 -0
- package/src/http/deprecation.ts +118 -0
- package/src/http/interaction-control-error.ts +164 -0
- package/src/http/keyed-admission.ts +29 -0
- package/src/http/local-browser-boundary.ts +343 -0
- package/src/http/metrics-listener.ts +57 -0
- package/src/http/path-identifier.ts +54 -0
- package/src/http/registered-route-label.ts +34 -0
- package/src/http/request-body.ts +127 -0
- package/src/http/request-source.ts +178 -0
- package/src/http/sse.ts +486 -132
- package/src/http/unmatched-route.ts +60 -0
- package/src/http/user-content.ts +158 -0
- package/src/http/websocket-upgrade-dispatch.ts +29 -0
- package/src/index.ts +157 -52
- package/src/integration-endpoint-test.ts +291 -0
- package/src/integrations/api-integrations.ts +98 -11
- package/src/integrations/atlassian.ts +474 -136
- package/src/integrations/connect-authority.ts +2 -0
- package/src/integrations/connect-callback-return.ts +86 -0
- package/src/integrations/fiken.ts +354 -64
- package/src/integrations/github-app-connect.ts +435 -0
- package/src/integrations/github-installation-proof.ts +60 -0
- package/src/integrations/github-lens-connect.ts +76 -0
- package/src/integrations/github-skill-source.ts +2 -142
- package/src/integrations/google-drive.ts +820 -222
- package/src/integrations/integration-commit-authority.ts +69 -0
- package/src/integrations/marketplace-plugin.ts +48 -0
- package/src/integrations/oauth-client.ts +1356 -459
- package/src/integrations/oauth-profiles.ts +537 -0
- package/src/integrations/oauth-return-path.ts +18 -0
- package/src/integrations/personal-github-repositories.ts +674 -0
- package/src/integrations/personal-github.ts +825 -0
- package/src/integrations/pr-review-provider.ts +246 -0
- package/src/integrations/provider-oauth.ts +250 -22
- package/src/integrations/slack-app-home.ts +300 -0
- package/src/integrations/slack-bot.ts +963 -239
- package/src/integrations/slack-file-upload-flow.ts +147 -0
- package/src/integrations/slack-install.ts +83 -0
- package/src/integrations/slack-interactions.ts +3170 -474
- package/src/integrations/slack-mrkdwn.ts +193 -0
- package/src/integrations/slack-routing.ts +337 -0
- package/src/integrations/slack-session-defaults.ts +224 -0
- package/src/integrations/slack-task-file-upload.ts +323 -0
- package/src/integrations/social-oauth.ts +213 -15
- package/src/interaction-agent-access.ts +48 -0
- package/src/interaction-frame-proxy.ts +409 -0
- package/src/interaction-metrics.ts +30 -0
- package/src/mcp/action-catalog-types.ts +9 -0
- package/src/mcp/action-catalog.gen.ts +6696 -0
- package/src/mcp/capability-account-readiness.ts +17 -0
- package/src/mcp/child-read-evidence.ts +19 -0
- package/src/mcp/command-read.ts +109 -0
- package/src/mcp/company-profile-agent-admin.ts +198 -0
- package/src/mcp/contract-input.ts +141 -0
- package/src/mcp/documents.ts +65 -377
- package/src/mcp/editable-artifacts.ts +12 -6
- package/src/mcp/files.ts +80 -38
- package/src/mcp/first-party-tool-permissions.ts +305 -0
- package/src/mcp/knowledge-entries.ts +322 -0
- package/src/mcp/orchestration-failure-diagnostic.ts +43 -0
- package/src/mcp/receipts.ts +34 -0
- package/src/mcp/request-abort.ts +44 -0
- package/src/mcp/scheduled-task-input.ts +76 -0
- package/src/mcp/scheduled-task-view.ts +44 -3
- package/src/mcp/server.ts +3030 -1267
- package/src/mcp/session-event-view.ts +383 -0
- package/src/mcp/session-view.ts +84 -3
- package/src/mcp/session-wait.ts +665 -0
- package/src/mcp-oauth.ts +1123 -0
- package/src/model-catalog.ts +91 -333
- package/src/observability.ts +15 -1
- package/src/organization-mcp.ts +397 -0
- package/src/organization-recovery-notifications.ts +103 -0
- package/src/routes/analytics-consent.ts +123 -0
- package/src/routes/api-integrations.ts +364 -74
- package/src/routes/api-keys.ts +336 -10
- package/src/routes/artifact-catalog.ts +279 -0
- package/src/routes/automations.ts +768 -0
- package/src/routes/billing.ts +461 -46
- package/src/routes/browser-sessions.ts +839 -131
- package/src/routes/canonical-human-identities.ts +90 -14
- package/src/routes/capabilities.ts +107 -6
- package/src/routes/channels.ts +20 -3
- package/src/routes/claude-subscription-accounts.ts +334 -0
- package/src/routes/claude-subscription-oauth.ts +142 -0
- package/src/routes/client-errors.ts +362 -0
- package/src/routes/codex.ts +833 -116
- package/src/routes/company-brain.ts +322 -0
- package/src/routes/company-profile.ts +65 -1
- package/src/routes/computer-sessions.ts +557 -106
- package/src/routes/connect.ts +1938 -0
- package/src/routes/connections.ts +1040 -349
- package/src/routes/documents.ts +488 -287
- package/src/routes/editable-artifacts.ts +79 -9
- package/src/routes/enrollments.ts +135 -39
- package/src/routes/environments.ts +154 -58
- package/src/routes/external-identity-links.ts +201 -0
- package/src/routes/feedback.ts +113 -0
- package/src/routes/files.ts +337 -39
- package/src/routes/github-browser-pages.ts +162 -0
- package/src/routes/github.ts +446 -144
- package/src/routes/insights-response-cache.ts +83 -0
- package/src/routes/insights-usage.ts +345 -0
- package/src/routes/insights.ts +153 -19
- package/src/routes/install.ts +133 -38
- package/src/routes/integration-facets.ts +107 -33
- package/src/routes/interaction-resources.ts +30 -3
- package/src/routes/knowledge.ts +488 -0
- package/src/routes/machines.ts +313 -15
- package/src/routes/managed-auth-session-sets.ts +1218 -0
- package/src/routes/managed-onboarding.ts +337 -0
- package/src/routes/managed-sign-in-methods.ts +433 -0
- package/src/routes/memory-slack-publications.ts +3 -2
- package/src/routes/model-connection-access.ts +208 -0
- package/src/routes/organization-integration-policy.ts +116 -0
- package/src/routes/organization-integrations.ts +326 -0
- package/src/routes/organization-mcp-connections.ts +178 -0
- package/src/routes/organization-memberships.ts +1019 -27
- package/src/routes/organization-model-providers.ts +293 -0
- package/src/routes/organization-recovery.ts +325 -0
- package/src/routes/organization-service-accounts.ts +128 -0
- package/src/routes/organization-sessions.ts +350 -0
- package/src/routes/personal-github-git-broker.ts +785 -0
- package/src/routes/personal-github.ts +370 -0
- package/src/routes/plugins.ts +251 -22
- package/src/routes/pr-review-github.ts +881 -0
- package/src/routes/pr-review.ts +622 -0
- package/src/routes/preference-registry.ts +12 -93
- package/src/routes/rigs.ts +167 -50
- package/src/routes/scheduled-tasks.ts +346 -41
- package/src/routes/session-artifact-associations.ts +87 -0
- package/src/routes/session-history-imports.ts +280 -0
- package/src/routes/sessions.ts +2306 -264
- package/src/routes/skill-content.ts +297 -0
- package/src/routes/skill-install-authority.ts +64 -0
- package/src/routes/skills.ts +62 -9
- package/src/routes/social.ts +46 -18
- package/src/routes/subscription-account-pools.ts +436 -0
- package/src/routes/subscription-pool-access.ts +126 -0
- package/src/routes/supergrok.ts +219 -303
- package/src/routes/transcription-recordings.ts +38 -3
- package/src/routes/transcriptions.ts +4 -0
- package/src/routes/usage-allowances.ts +378 -0
- package/src/routes/user-resource-authorities.ts +138 -0
- package/src/routes/video-generation.ts +14 -10
- package/src/routes/workspace-artifacts.ts +275 -69
- package/src/routes/workspace-capture.ts +21 -0
- package/src/routes/workspace-integrations.ts +576 -0
- package/src/routes/workspace-learning.ts +159 -0
- package/src/routes/workspace-model-providers.ts +148 -0
- package/src/routes/workspace-state.ts +38 -25
- package/src/routes/workspaces.ts +1004 -127
- package/src/sandbox/auth-callout.ts +96 -19
- package/src/sandbox/channel-a.ts +323 -24
- package/src/sandbox/connection-authority.ts +3 -0
- package/src/sandbox/enrollment.ts +81 -6
- package/src/sandbox/machines.ts +218 -76
- package/src/sandbox/metrics-ingestion.ts +411 -62
- package/src/sandbox/rematerialize.ts +121 -19
- package/src/sandbox/session-attach-variable-sets.ts +131 -0
- package/src/sandbox/viewer.ts +280 -25
- package/src/sandbox-file-artifacts.ts +413 -0
- package/src/scheduled-task-deletion.ts +138 -0
- package/src/session-create-observability.ts +46 -0
- package/src/session-realtime-context.ts +6 -3
- package/src/site-session-origin.ts +48 -0
- package/src/site-uploads.ts +224 -0
- package/src/slack-reaction-files.ts +16 -5
- package/src/temporal-schedule-cleanup.ts +13 -0
- package/src/temporal-schedule-sync.ts +74 -0
- package/src/transcription/providers/codex-subscription.ts +2 -0
- package/src/transcription/providers/openai.ts +1 -0
- package/src/transcription/providers/xai-subscription.ts +49 -3
- package/src/transcription/segmenter.ts +8 -2
- package/src/transcription/service.ts +43 -6
- package/src/work-discovery-observability.ts +121 -0
- package/src/workspace-artifact-content.ts +144 -0
- package/src/workspace-artifact-provenance.ts +104 -0
- package/src/workspace-delete-observability.ts +75 -0
- package/src/workspace-deletion.ts +73 -0
- package/src/workspace-state-projection.ts +18 -148
- package/src/workspace-tool-gateway-observability.ts +100 -0
- package/src/workspace-tool-gateway.ts +870 -0
- package/src/workspace-webhook-dispatch.ts +190 -0
- package/src/xai-subscription-auth.ts +9 -2
- package/dist/chunk-2PQMSRCB.js +0 -49759
- package/dist/chunk-2PQMSRCB.js.map +0 -1
- package/dist/routes/packs.d.ts +0 -3
- package/src/routes/packs.ts +0 -729
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { McpConnectionAccountBinding } from "@opengeni/contracts";
|
|
2
|
+
|
|
3
|
+
/** Canonical readiness comes only from routes present in this exact attempt,
|
|
4
|
+
* joined to this turn's accepted bindings. It never grants account access. */
|
|
5
|
+
export function capabilityAccountReadiness(
|
|
6
|
+
availableRoutes: Iterable<string>,
|
|
7
|
+
bindings: readonly McpConnectionAccountBinding[] | null,
|
|
8
|
+
) {
|
|
9
|
+
const available = new Set(availableRoutes);
|
|
10
|
+
const actualRoutes = new Set(available);
|
|
11
|
+
const accepted = new Set<string>();
|
|
12
|
+
for (const binding of bindings ?? []) {
|
|
13
|
+
accepted.add(binding.canonicalServerId);
|
|
14
|
+
if (actualRoutes.has(binding.serverId)) available.add(binding.canonicalServerId);
|
|
15
|
+
}
|
|
16
|
+
return { available, accepted };
|
|
17
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** Select only whole items that actually survived the model-facing envelope.
|
|
2
|
+
* A cursor is a position, never proof that preceding content was consumed. */
|
|
3
|
+
export function completeChildReadSequences(page: {
|
|
4
|
+
view: string;
|
|
5
|
+
sourceExact: boolean;
|
|
6
|
+
events: readonly ({ sequence: number } & Record<string, unknown>)[];
|
|
7
|
+
}): number[] {
|
|
8
|
+
if (!page.sourceExact || !["conversation", "results"].includes(page.view)) return [];
|
|
9
|
+
return page.events
|
|
10
|
+
.filter((event) => {
|
|
11
|
+
if (event.sourceOmitted) return false;
|
|
12
|
+
if (event.fragment === undefined) return true;
|
|
13
|
+
if (!event.fragment || typeof event.fragment !== "object") return false;
|
|
14
|
+
const fragment = event.fragment as Record<string, unknown>;
|
|
15
|
+
// A final fragment cannot prove earlier fragments were ever read.
|
|
16
|
+
return fragment.offset === 0 && fragment.complete === true;
|
|
17
|
+
})
|
|
18
|
+
.map((event) => event.sequence);
|
|
19
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import type { SessionEvent } from "@opengeni/contracts";
|
|
2
|
+
import { COMMAND_OUTPUT_MAX_BYTES } from "@opengeni/db/session-background-commands";
|
|
3
|
+
|
|
4
|
+
export const COMMAND_READ_MAX_WAIT_SECONDS = 50;
|
|
5
|
+
export const COMMAND_WAIT_DEFAULT_SECONDS = 45;
|
|
6
|
+
|
|
7
|
+
/** Shared provider-neutral command_read/command_wait operation. Notifications
|
|
8
|
+
* are only wake hints. Every result, including timeout, comes from durable DB
|
|
9
|
+
* state. Subscribe before reading to close the finish/subscription race, and
|
|
10
|
+
* periodically recheck durable state because live hints may be lost. */
|
|
11
|
+
export async function readCommandWithWait<
|
|
12
|
+
T extends { terminal: boolean; chunks: unknown[]; hasMore?: boolean },
|
|
13
|
+
>(input: {
|
|
14
|
+
commandId: string;
|
|
15
|
+
waitSeconds?: number;
|
|
16
|
+
maxOutputBytes?: number | undefined;
|
|
17
|
+
signal?: AbortSignal;
|
|
18
|
+
read: () => Promise<T>;
|
|
19
|
+
subscribe: (onEvents: (events: SessionEvent[]) => void) => Promise<() => void>;
|
|
20
|
+
}) {
|
|
21
|
+
const seconds = input.waitSeconds ?? 0;
|
|
22
|
+
if (!Number.isInteger(seconds) || seconds < 0 || seconds > COMMAND_READ_MAX_WAIT_SECONDS) {
|
|
23
|
+
throw new Error("waitSeconds must be between 0 and 50");
|
|
24
|
+
}
|
|
25
|
+
if (
|
|
26
|
+
input.maxOutputBytes !== undefined &&
|
|
27
|
+
(!Number.isInteger(input.maxOutputBytes) ||
|
|
28
|
+
input.maxOutputBytes < 4 ||
|
|
29
|
+
input.maxOutputBytes > COMMAND_OUTPUT_MAX_BYTES)
|
|
30
|
+
) {
|
|
31
|
+
throw new Error("maxOutputBytes must be between 4 and 65536");
|
|
32
|
+
}
|
|
33
|
+
const started = Date.now();
|
|
34
|
+
const deadline = started + seconds * 1000;
|
|
35
|
+
let unsubscribe: (() => void) | undefined;
|
|
36
|
+
let wake: (() => void) | undefined;
|
|
37
|
+
let changed = false;
|
|
38
|
+
let liveFanout = true;
|
|
39
|
+
const notify = () => {
|
|
40
|
+
changed = true;
|
|
41
|
+
wake?.();
|
|
42
|
+
};
|
|
43
|
+
input.signal?.addEventListener("abort", notify);
|
|
44
|
+
try {
|
|
45
|
+
if (seconds > 0) {
|
|
46
|
+
try {
|
|
47
|
+
unsubscribe = await input.subscribe((events) => {
|
|
48
|
+
if (
|
|
49
|
+
events.some(
|
|
50
|
+
(event) =>
|
|
51
|
+
(event.type === "session.command.finished" ||
|
|
52
|
+
event.type === "sandbox.command.output.delta") &&
|
|
53
|
+
event.payload !== null &&
|
|
54
|
+
typeof event.payload === "object" &&
|
|
55
|
+
(event.payload as Record<string, unknown>).commandId === input.commandId,
|
|
56
|
+
)
|
|
57
|
+
)
|
|
58
|
+
notify();
|
|
59
|
+
});
|
|
60
|
+
} catch {
|
|
61
|
+
liveFanout = false;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
while (true) {
|
|
65
|
+
changed = false;
|
|
66
|
+
const result = await input.read();
|
|
67
|
+
const expired = Date.now() >= deadline;
|
|
68
|
+
if (
|
|
69
|
+
result.terminal ||
|
|
70
|
+
result.chunks.length > 0 ||
|
|
71
|
+
result.hasMore ||
|
|
72
|
+
expired ||
|
|
73
|
+
input.signal?.aborted
|
|
74
|
+
) {
|
|
75
|
+
return {
|
|
76
|
+
...result,
|
|
77
|
+
waitedMs: Date.now() - started,
|
|
78
|
+
timedOut:
|
|
79
|
+
seconds > 0 &&
|
|
80
|
+
expired &&
|
|
81
|
+
!result.terminal &&
|
|
82
|
+
result.chunks.length === 0 &&
|
|
83
|
+
!result.hasMore,
|
|
84
|
+
aborted: input.signal?.aborted ?? false,
|
|
85
|
+
liveFanout,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
if (changed) continue;
|
|
89
|
+
await new Promise<void>((resolve) => {
|
|
90
|
+
const timer = setTimeout(
|
|
91
|
+
() => {
|
|
92
|
+
wake = undefined;
|
|
93
|
+
resolve();
|
|
94
|
+
},
|
|
95
|
+
Math.max(0, Math.min(1_000, deadline - Date.now())),
|
|
96
|
+
);
|
|
97
|
+
wake = () => {
|
|
98
|
+
clearTimeout(timer);
|
|
99
|
+
wake = undefined;
|
|
100
|
+
resolve();
|
|
101
|
+
};
|
|
102
|
+
if (changed || input.signal?.aborted) wake();
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
} finally {
|
|
106
|
+
input.signal?.removeEventListener("abort", notify);
|
|
107
|
+
unsubscribe?.();
|
|
108
|
+
}
|
|
109
|
+
}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AGENT_AUTHORED_COMPANY_PROFILE_ENTRY_MAX_CHARS,
|
|
3
|
+
AGENT_AUTHORED_COMPANY_PROFILE_SCALAR_MAX_CHARS,
|
|
4
|
+
AGENT_AUTHORED_COMPANY_PROFILE_TOO_LONG_MESSAGE,
|
|
5
|
+
AgentAuthoredCompanyProfileContent,
|
|
6
|
+
COMPANY_PROFILE_REASON_MAX_CHARS,
|
|
7
|
+
COMPANY_PROFILE_STABLE_KEY_MAX_CHARS,
|
|
8
|
+
normalizeCompanyProfileStableKey,
|
|
9
|
+
type CompanyProfileAgentAttempt,
|
|
10
|
+
type CompanyProfileEntry,
|
|
11
|
+
} from "@opengeni/contracts";
|
|
12
|
+
import {
|
|
13
|
+
CompanyProfileAgentAdminError,
|
|
14
|
+
createCompanyProfileAgentAdminRouter,
|
|
15
|
+
} from "@opengeni/core";
|
|
16
|
+
import type { Database } from "@opengeni/db";
|
|
17
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
18
|
+
import * as z from "zod/v4";
|
|
19
|
+
|
|
20
|
+
type JsonResult = (value: unknown) => {
|
|
21
|
+
content: { type: "text"; text: string }[];
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type RegisterCompanyProfileAgentAdminToolsInput = {
|
|
25
|
+
server: McpServer;
|
|
26
|
+
db: Database;
|
|
27
|
+
attempt: CompanyProfileAgentAttempt;
|
|
28
|
+
authorize: () => Promise<void>;
|
|
29
|
+
json: JsonResult;
|
|
30
|
+
router?: Pick<ReturnType<typeof createCompanyProfileAgentAdminRouter>, "propose" | "confirm">;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
// Agent-only bounds. The human `account:admin` API keeps the wider historical
|
|
34
|
+
// `COMPANY_PROFILE_*` limits; the current agent tool authors only the two
|
|
35
|
+
// always-on identity fields and therefore gets a much smaller budget.
|
|
36
|
+
const scalar = z
|
|
37
|
+
.string()
|
|
38
|
+
.trim()
|
|
39
|
+
.min(1)
|
|
40
|
+
.max(
|
|
41
|
+
AGENT_AUTHORED_COMPANY_PROFILE_SCALAR_MAX_CHARS,
|
|
42
|
+
AGENT_AUTHORED_COMPANY_PROFILE_TOO_LONG_MESSAGE,
|
|
43
|
+
)
|
|
44
|
+
.nullable();
|
|
45
|
+
const entry = z.object({
|
|
46
|
+
key: z.string().trim().min(1).max(COMPANY_PROFILE_STABLE_KEY_MAX_CHARS).optional(),
|
|
47
|
+
content: z
|
|
48
|
+
.string()
|
|
49
|
+
.trim()
|
|
50
|
+
.min(1)
|
|
51
|
+
.max(
|
|
52
|
+
AGENT_AUTHORED_COMPANY_PROFILE_ENTRY_MAX_CHARS,
|
|
53
|
+
AGENT_AUTHORED_COMPANY_PROFILE_TOO_LONG_MESSAGE,
|
|
54
|
+
),
|
|
55
|
+
});
|
|
56
|
+
const DEFAULT_PROPOSAL_REASON = "Activate agent-proposed organization identity";
|
|
57
|
+
const STABLE_KEY_WORDS = 6;
|
|
58
|
+
|
|
59
|
+
type EntryInput = z.infer<typeof entry>;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Derive a stable key from entry content: the first few words, normalized into
|
|
63
|
+
* the company-profile key alphabet and bounded to the stable-key length.
|
|
64
|
+
*/
|
|
65
|
+
export function deriveCompanyProfileStableKey(content: string): string {
|
|
66
|
+
const words = content
|
|
67
|
+
.normalize("NFKC")
|
|
68
|
+
.toLowerCase()
|
|
69
|
+
.replace(/[^\p{L}\p{N}\s._-]+/gu, " ")
|
|
70
|
+
.trim()
|
|
71
|
+
.split(/\s+/u)
|
|
72
|
+
.filter(Boolean)
|
|
73
|
+
.slice(0, STABLE_KEY_WORDS)
|
|
74
|
+
.join(" ");
|
|
75
|
+
const normalized = normalizeCompanyProfileStableKey(words)
|
|
76
|
+
.replace(/[^a-z0-9._-]+/g, "-")
|
|
77
|
+
.replace(/-+/g, "-")
|
|
78
|
+
.slice(0, COMPANY_PROFILE_STABLE_KEY_MAX_CHARS)
|
|
79
|
+
.replace(/^[._-]+|[._-]+$/g, "");
|
|
80
|
+
return normalized.length > 0 ? normalized : "entry";
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Resolve explicit or derived keys for one list and de-duplicate by suffixing
|
|
85
|
+
* `-2`, `-3`, ... so the profile passes the unique-key contract.
|
|
86
|
+
*/
|
|
87
|
+
export function resolveCompanyProfileEntries(input: readonly EntryInput[]): CompanyProfileEntry[] {
|
|
88
|
+
const used = new Set<string>();
|
|
89
|
+
return input.map(({ key, content }) => {
|
|
90
|
+
const base = key
|
|
91
|
+
? normalizeCompanyProfileStableKey(key)
|
|
92
|
+
: deriveCompanyProfileStableKey(content);
|
|
93
|
+
let candidate = base;
|
|
94
|
+
for (let suffix = 2; used.has(candidate); suffix += 1) {
|
|
95
|
+
const tail = `-${suffix}`;
|
|
96
|
+
candidate = `${base.slice(0, COMPANY_PROFILE_STABLE_KEY_MAX_CHARS - tail.length)}${tail}`;
|
|
97
|
+
}
|
|
98
|
+
used.add(candidate);
|
|
99
|
+
return { key: candidate, content };
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function boundedIssueMessage(error: z.ZodError): string {
|
|
104
|
+
return error.issues
|
|
105
|
+
.slice(0, 5)
|
|
106
|
+
.map((issue) => `${issue.path.join(".") || "profile"}: ${issue.message}`)
|
|
107
|
+
.join("; ")
|
|
108
|
+
.slice(0, 1_024);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Register the organization profile administration path. This is not derived
|
|
113
|
+
* workspace learning: the initiating human must be the organization's active
|
|
114
|
+
* owner (the same authority as the manual `account:admin` route). The separate
|
|
115
|
+
* organization policy either blocks the proposal, keeps the exact bound
|
|
116
|
+
* human-confirmation path, or permits immediate activation through the native
|
|
117
|
+
* company-profile lifecycle.
|
|
118
|
+
*/
|
|
119
|
+
export function registerCompanyProfileAgentAdminTools(
|
|
120
|
+
input: RegisterCompanyProfileAgentAdminToolsInput,
|
|
121
|
+
): void {
|
|
122
|
+
const router = input.router ?? createCompanyProfileAgentAdminRouter({ db: input.db });
|
|
123
|
+
input.server.registerTool(
|
|
124
|
+
"company_profile_propose",
|
|
125
|
+
{
|
|
126
|
+
description:
|
|
127
|
+
"Prepare the organization's small, stable identity: identity says who the organization is, and mission says why it exists. " +
|
|
128
|
+
"Once activated, both fields are mandatory prompt context in every root session for the whole organization, so use one plain descriptive statement per field with no products, customers, goals, constraints, procedures, or marketing copy. Those details belong in organization-scoped Documents and are retrieved only when relevant. " +
|
|
129
|
+
`Each field is bounded to ${AGENT_AUTHORED_COMPANY_PROFILE_SCALAR_MAX_CHARS} characters for agent-authored proposals. ` +
|
|
130
|
+
"This is independent of workspace learning policy and follows the organization owner's Agent-managed identity mode. Off creates nothing. Require approval returns status=confirmation_required with the exact `humanInput` payload; call `request_human_input` with it verbatim, then call `company_profile_confirm` with the returned requestId. Autonomous may return status=activated immediately after exact live-owner, stale-head, and compare-and-swap checks; do not ask for another confirmation in that case.",
|
|
131
|
+
inputSchema: {
|
|
132
|
+
operationId: z.string().uuid(),
|
|
133
|
+
identity: scalar,
|
|
134
|
+
mission: scalar,
|
|
135
|
+
reason: z.string().trim().min(1).max(COMPANY_PROFILE_REASON_MAX_CHARS).optional(),
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
async (request) => {
|
|
139
|
+
await input.authorize();
|
|
140
|
+
const parsed = AgentAuthoredCompanyProfileContent.safeParse({
|
|
141
|
+
identity: request.identity,
|
|
142
|
+
mission: request.mission,
|
|
143
|
+
products: [],
|
|
144
|
+
customers: [],
|
|
145
|
+
goals: [],
|
|
146
|
+
constraints: [],
|
|
147
|
+
});
|
|
148
|
+
if (!parsed.success) {
|
|
149
|
+
return input.json({
|
|
150
|
+
status: "not_proposed",
|
|
151
|
+
code: "invalid_profile",
|
|
152
|
+
message: boundedIssueMessage(parsed.error),
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
try {
|
|
156
|
+
return input.json(
|
|
157
|
+
await router.propose({
|
|
158
|
+
attempt: input.attempt,
|
|
159
|
+
request: {
|
|
160
|
+
operationId: request.operationId,
|
|
161
|
+
profile: parsed.data,
|
|
162
|
+
reason: request.reason ?? DEFAULT_PROPOSAL_REASON,
|
|
163
|
+
},
|
|
164
|
+
}),
|
|
165
|
+
);
|
|
166
|
+
} catch (error) {
|
|
167
|
+
if (error instanceof CompanyProfileAgentAdminError) {
|
|
168
|
+
return input.json({ status: "not_proposed", code: error.code, message: error.message });
|
|
169
|
+
}
|
|
170
|
+
throw error;
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
);
|
|
174
|
+
|
|
175
|
+
input.server.registerTool(
|
|
176
|
+
"company_profile_confirm",
|
|
177
|
+
{
|
|
178
|
+
description:
|
|
179
|
+
"Activate a `company_profile_propose` receipt only after the exact initiating organization owner answered Activate on the returned `request_human_input` prompt. Pass the proposalReceiptId and requestId unchanged. Confirmation revalidates the live turn, organization role, proposal hash, and unchanged active-profile baseline, then returns the immutable activation receipt.",
|
|
180
|
+
inputSchema: {
|
|
181
|
+
operationId: z.string().uuid(),
|
|
182
|
+
proposalReceiptId: z.string().uuid(),
|
|
183
|
+
humanInputRequestId: z.string().uuid(),
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
async (request) => {
|
|
187
|
+
await input.authorize();
|
|
188
|
+
try {
|
|
189
|
+
return input.json(await router.confirm({ attempt: input.attempt, request }));
|
|
190
|
+
} catch (error) {
|
|
191
|
+
if (error instanceof CompanyProfileAgentAdminError) {
|
|
192
|
+
return input.json({ status: "not_confirmed", code: error.code, message: error.message });
|
|
193
|
+
}
|
|
194
|
+
throw error;
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
);
|
|
198
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import * as z from "zod/v4";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Publish the input side of a contract, validate it, and retain the exact call.
|
|
5
|
+
* MCP parsing must not insert defaults, trim text, or erase omitted fields before
|
|
6
|
+
* the application applies presence-sensitive inheritance and authority rules.
|
|
7
|
+
* A narrower projection may hide host-only fields; validation retains the full
|
|
8
|
+
* contract's preprocessors and cross-field checks.
|
|
9
|
+
*/
|
|
10
|
+
export function contractToolInput<T extends z.ZodObject>(
|
|
11
|
+
projection: T,
|
|
12
|
+
validation: z.ZodType = projection,
|
|
13
|
+
): z.ZodType<z.input<T>, z.input<T>> {
|
|
14
|
+
const inputProjection = projection.strict();
|
|
15
|
+
const jsonSchema = z.toJSONSchema(inputProjection, {
|
|
16
|
+
io: "input",
|
|
17
|
+
target: "draft-7",
|
|
18
|
+
});
|
|
19
|
+
assertDescribedToolInput(jsonSchema);
|
|
20
|
+
// MCP's SDK only publishes recognized object schemas. A passthrough object
|
|
21
|
+
// keeps the call intact, while metadata supplies the projected JSON Schema.
|
|
22
|
+
return z
|
|
23
|
+
.object({})
|
|
24
|
+
.catchall(z.unknown())
|
|
25
|
+
.superRefine((args, context) => {
|
|
26
|
+
const projected = inputProjection.safeParse(args);
|
|
27
|
+
const parsed = projected.success ? validation.safeParse(args) : projected;
|
|
28
|
+
if (!parsed.success) {
|
|
29
|
+
for (const issue of inputIssues(parsed.error.issues)) context.addIssue({ ...issue });
|
|
30
|
+
}
|
|
31
|
+
})
|
|
32
|
+
.meta(jsonSchema) as unknown as z.ZodType<z.input<T>, z.input<T>>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Every named input and array element needs a schema. Dictionary values may be arbitrary JSON. */
|
|
36
|
+
export function assertDescribedToolInput(schema: unknown, tool = "tool"): void {
|
|
37
|
+
const activeRefs = new Set<string>();
|
|
38
|
+
function visit(value: unknown, path: string, allowOpaque = false): void {
|
|
39
|
+
if (value === false) return;
|
|
40
|
+
if (value === true && allowOpaque) return;
|
|
41
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
42
|
+
throw new Error(`${tool}: invalid input schema at ${path}`);
|
|
43
|
+
}
|
|
44
|
+
const node = value as Record<string, unknown>;
|
|
45
|
+
const constraints = ["type", "$ref", "enum", "const", "anyOf", "oneOf", "allOf", "not"];
|
|
46
|
+
if (!constraints.some((key) => Object.hasOwn(node, key))) {
|
|
47
|
+
if (allowOpaque) return;
|
|
48
|
+
throw new Error(`${tool}: input ${path} has no declared structure; use its contract schema`);
|
|
49
|
+
}
|
|
50
|
+
if (typeof node.$ref === "string" && node.$ref.startsWith("#/") && !activeRefs.has(node.$ref)) {
|
|
51
|
+
const ref = node.$ref;
|
|
52
|
+
let target = schema;
|
|
53
|
+
for (const part of ref.slice(2).split("/")) {
|
|
54
|
+
target = (target as Record<string, unknown>)?.[
|
|
55
|
+
part.replace(/~1/g, "/").replace(/~0/g, "~")
|
|
56
|
+
];
|
|
57
|
+
}
|
|
58
|
+
activeRefs.add(ref);
|
|
59
|
+
visit(target, path, allowOpaque);
|
|
60
|
+
activeRefs.delete(ref);
|
|
61
|
+
}
|
|
62
|
+
for (const [key, child] of Object.entries((node.properties ?? {}) as Record<string, unknown>)) {
|
|
63
|
+
visit(child, `${path}.${key}`);
|
|
64
|
+
}
|
|
65
|
+
if (node.type === "array" && node.items === undefined && node.prefixItems === undefined) {
|
|
66
|
+
throw new Error(
|
|
67
|
+
`${tool}: input ${path}[] has no declared structure; use its contract schema`,
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
if (Array.isArray(node.items)) {
|
|
71
|
+
node.items.forEach((child, index) => visit(child, `${path}[${index}]`));
|
|
72
|
+
if (node.additionalItems !== undefined) visit(node.additionalItems, `${path}[...]`);
|
|
73
|
+
else if (typeof node.maxItems !== "number" || node.maxItems > node.items.length) {
|
|
74
|
+
throw new Error(
|
|
75
|
+
`${tool}: input ${path}[...] has no declared structure; use its contract schema`,
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
} else if (node.items !== undefined) visit(node.items, `${path}[]`);
|
|
79
|
+
if (Array.isArray(node.prefixItems)) {
|
|
80
|
+
node.prefixItems.forEach((child, index) => visit(child, `${path}[${index}]`));
|
|
81
|
+
if (
|
|
82
|
+
node.items === undefined &&
|
|
83
|
+
(typeof node.maxItems !== "number" || node.maxItems > node.prefixItems.length)
|
|
84
|
+
) {
|
|
85
|
+
throw new Error(
|
|
86
|
+
`${tool}: input ${path}[...] has no declared structure; use its contract schema`,
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
// An unconstrained dictionary is intentional extension data. If its values
|
|
91
|
+
// declare a structure, check that structure's fields just like named inputs.
|
|
92
|
+
const dictionary = node.additionalProperties;
|
|
93
|
+
if (dictionary && typeof dictionary === "object" && Object.keys(dictionary).length > 0) {
|
|
94
|
+
visit(dictionary, `${path}.*`, true);
|
|
95
|
+
}
|
|
96
|
+
for (const [key, child] of Object.entries(
|
|
97
|
+
(node.patternProperties ?? {}) as Record<string, unknown>,
|
|
98
|
+
)) {
|
|
99
|
+
if (child && typeof child === "object" && Object.keys(child).length === 0) continue;
|
|
100
|
+
visit(child, `${path}.[${key}]`, true);
|
|
101
|
+
}
|
|
102
|
+
for (const keyword of ["anyOf", "oneOf", "allOf"]) {
|
|
103
|
+
for (const [index, child] of ((node[keyword] ?? []) as unknown[]).entries()) {
|
|
104
|
+
visit(child, `${path}.${keyword}[${index}]`, allowOpaque);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
visit(schema, "arguments");
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** Only raw contract preflight errors, never downstream provider or storage exceptions. */
|
|
112
|
+
function inputIssues(issues: readonly z.core.$ZodIssue[]): z.core.$ZodIssueCustom[] {
|
|
113
|
+
const result: z.core.$ZodIssueCustom[] = [];
|
|
114
|
+
for (const issue of issues.slice(0, 8)) {
|
|
115
|
+
const path = [...issue.path];
|
|
116
|
+
let message: string;
|
|
117
|
+
if (issue.code === "invalid_type") message = `expected ${issue.expected}`;
|
|
118
|
+
else if (issue.code === "invalid_value")
|
|
119
|
+
message = `allowed values: ${JSON.stringify(issue.values)}`;
|
|
120
|
+
else if (issue.code === "invalid_union" && issue.errors.length === 0 && issue.discriminator) {
|
|
121
|
+
if (path.at(-1) !== issue.discriminator) path.push(issue.discriminator);
|
|
122
|
+
message = `allowed values: ${JSON.stringify("options" in issue ? issue.options : [])}`;
|
|
123
|
+
} else if (issue.code === "invalid_union") {
|
|
124
|
+
// These are alternatives, never cumulative requirements.
|
|
125
|
+
message = "does not match any of the declared alternative input formats";
|
|
126
|
+
} else if (issue.code === "unrecognized_keys")
|
|
127
|
+
message = `fields not declared by this tool: ${JSON.stringify(issue.keys)}`;
|
|
128
|
+
else if (issue.code === "too_small") message = `must meet minimum ${issue.minimum}`;
|
|
129
|
+
else if (issue.code === "too_big") message = `must meet maximum ${issue.maximum}`;
|
|
130
|
+
else message = issue.message;
|
|
131
|
+
result.push({ code: "custom", path, message });
|
|
132
|
+
}
|
|
133
|
+
if (issues.length > 8) {
|
|
134
|
+
result.push({
|
|
135
|
+
code: "custom",
|
|
136
|
+
path: [],
|
|
137
|
+
message: `${issues.length - 8} additional input problems`,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
return result;
|
|
141
|
+
}
|