@opengeni/api-router 3.0.1 → 3.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/access-grant-rls.d.ts +8 -1
- package/dist/admission-trace.d.ts +8 -0
- package/dist/app.d.ts +50 -3
- package/dist/app.js +10 -1
- package/dist/artifact-catalog-cursor.d.ts +1 -0
- package/dist/attached-browser-viewer.d.ts +11 -0
- package/dist/auth/managed-auth-attempt-context.d.ts +2 -0
- package/dist/auth/managed-auth-rate-limits.d.ts +167 -0
- package/dist/auth/managed-auth-session-adapter.d.ts +9 -1
- package/dist/auth/managed-auth.d.ts +72 -5
- package/dist/auth/managed-sign-in-notifications.d.ts +4 -0
- package/dist/auth/new-signups-gate.d.ts +23 -0
- package/dist/auth/signup-funnel-metrics.d.ts +44 -0
- package/dist/azure-live.d.ts +28 -0
- package/dist/browser-action-fences.d.ts +13 -0
- package/dist/browser-controller-authority.d.ts +1 -61
- package/dist/browser-ephemeral.d.ts +5 -0
- package/dist/browser-lost-runtime-end.d.ts +24 -0
- package/dist/browser-state-authority.d.ts +1 -27
- package/dist/chunk-OGQDXVXY.js +18 -0
- package/dist/chunk-OGQDXVXY.js.map +1 -0
- package/dist/{chunk-AJ62T5QN.js → chunk-OT56OY4V.js} +80503 -39869
- package/dist/chunk-OT56OY4V.js.map +1 -0
- package/dist/claude-default-models.d.ts +19 -0
- package/dist/claude-subscription-core.d.ts +50 -0
- package/dist/claude-subscription-oauth.d.ts +36 -0
- package/dist/claude-subscription-profile.d.ts +9 -0
- package/dist/claude-subscription-usage.d.ts +6 -0
- package/dist/claude-workspace-connection.d.ts +15 -0
- package/dist/codemode.d.ts +40 -5
- package/dist/codex-realtime.d.ts +29 -3
- package/dist/codex-session-pointers.d.ts +19 -0
- package/dist/connection-ownership.d.ts +6 -3
- package/dist/controller-data-plane.d.ts +16 -0
- package/dist/credit-promotion-snapshot.d.ts +6 -0
- package/dist/editable-artifact-source-session.d.ts +3 -0
- package/dist/editable-artifact-websocket.d.ts +5 -3
- package/dist/fatal-process-boundary.d.ts +9 -1
- package/dist/github-access.d.ts +7 -1
- package/dist/github-browser-flow.d.ts +1 -1
- package/dist/http/acting-person.d.ts +36 -0
- package/dist/http/api-contract-compat.d.ts +19 -0
- package/dist/http/api-error.d.ts +50 -1
- package/dist/http/auth.d.ts +8 -1
- package/dist/http/cors.d.ts +12 -0
- package/dist/http/deprecation.d.ts +42 -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/rejection-telemetry.d.ts +34 -0
- package/dist/http/request-body.d.ts +27 -0
- package/dist/http/request-source.d.ts +41 -3
- package/dist/http/sse.d.ts +12 -1
- package/dist/http/unmatched-route.d.ts +18 -0
- package/dist/http/user-content.d.ts +36 -0
- package/dist/http/variable-sets-removed.d.ts +41 -0
- package/dist/http/websocket-upgrade-dispatch.d.ts +18 -0
- package/dist/index.js +1279 -108
- package/dist/index.js.map +1 -1
- package/dist/integration-connect-metrics.d.ts +35 -0
- package/dist/integration-endpoint-test.d.ts +20 -0
- package/dist/integrations/api-integrations.d.ts +2 -2
- package/dist/integrations/atlassian.d.ts +8 -3
- package/dist/integrations/fiken.d.ts +3 -1
- package/dist/integrations/github-lens-connect.d.ts +37 -66
- package/dist/integrations/google-drive.d.ts +2 -0
- package/dist/integrations/integration-commit-authority.d.ts +13 -0
- package/dist/integrations/marketplace-plugin.d.ts +43 -43
- package/dist/integrations/oauth-client.d.ts +171 -12
- package/dist/integrations/oauth-profiles.d.ts +42 -13
- package/dist/integrations/onepassword-vault-provider.d.ts +9 -0
- package/dist/integrations/slack-bot.d.ts +285 -7
- package/dist/integrations/slack-file-upload-flow.d.ts +62 -0
- package/dist/integrations/slack-interactions.d.ts +89 -10
- package/dist/integrations/slack-mrkdwn.d.ts +41 -0
- package/dist/integrations/slack-routing.d.ts +1 -1
- package/dist/integrations/slack-session-defaults.d.ts +58 -0
- package/dist/integrations/slack-task-file-upload.d.ts +36 -0
- package/dist/integrations/slack-tool-review.d.ts +5 -0
- package/dist/interaction-agent-access.d.ts +13 -8
- package/dist/interaction-agent-version.d.ts +21 -0
- package/dist/interaction-holder-heartbeat.d.ts +5 -0
- package/dist/interaction-metrics.d.ts +27 -2
- package/dist/interaction-route-stages.d.ts +25 -0
- package/dist/interaction-secrets-vault.d.ts +20 -0
- package/dist/interaction-secrets.d.ts +103 -0
- package/dist/mcp/action-catalog-types.d.ts +14 -0
- package/dist/mcp/action-catalog.gen.d.ts +2 -0
- package/dist/mcp/action-descriptions.d.ts +4 -0
- package/dist/mcp/action-schema-imports.gen.d.ts +1 -0
- package/dist/mcp/capability-account-readiness.d.ts +7 -0
- package/dist/mcp/child-read-evidence.d.ts +9 -0
- package/dist/mcp/company-profile-agent-admin.d.ts +12 -0
- package/dist/mcp/contract-input.d.ts +13 -0
- package/dist/mcp/documents.d.ts +2 -0
- package/dist/mcp/first-party-tool-permissions.d.ts +3 -606
- package/dist/mcp/notification-tools.d.ts +26 -0
- package/dist/mcp/orchestration-failure-diagnostic.d.ts +43 -0
- package/dist/mcp/scheduled-task-input.d.ts +1309 -0
- package/dist/mcp/scheduled-task-view.d.ts +217 -3
- package/dist/mcp/secret-tools.d.ts +14 -0
- package/dist/mcp/server.d.ts +108 -5
- package/dist/mcp/session-admin-access-tools.d.ts +33 -0
- package/dist/mcp/session-event-errors.d.ts +28 -0
- package/dist/mcp/session-event-view.d.ts +62 -0
- package/dist/mcp/session-view.d.ts +15 -0
- package/dist/mcp/session-wait.d.ts +18 -0
- package/dist/mcp/site-agent-clamp-tools.d.ts +38 -0
- package/dist/mcp/site-data-tools.d.ts +22 -0
- package/dist/mcp/site-publication-tools.d.ts +19 -0
- package/dist/mcp/site-sql-tools.d.ts +27 -0
- package/dist/mcp-oauth.d.ts +37 -4
- package/dist/model-calls/chat-completions.d.ts +87 -0
- package/dist/model-calls/pending-usage-settlements.d.ts +57 -0
- package/dist/model-calls/service.d.ts +36 -0
- package/dist/model-catalog.d.ts +9 -3
- package/dist/native-push-dispatch.d.ts +69 -0
- package/dist/observability.d.ts +3 -1
- package/dist/organization-mcp.d.ts +82 -0
- package/dist/prepared-mcp-actor.d.ts +77 -0
- package/dist/prepared-mcp-permissions.d.ts +8 -0
- package/dist/routes/analytics-consent.d.ts +26 -0
- package/dist/routes/api-integrations.d.ts +11 -0
- package/dist/routes/api-keys.d.ts +7 -7
- package/dist/routes/automations.d.ts +2 -0
- package/dist/routes/billing.d.ts +59 -0
- package/dist/routes/browser-sessions.d.ts +65 -2
- package/dist/routes/chat-completions.d.ts +11 -0
- package/dist/routes/claude-core-usage.d.ts +20 -0
- 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 +182 -0
- package/dist/routes/codex-core.d.ts +401 -0
- package/dist/routes/codex.d.ts +64 -2
- package/dist/routes/computer-sessions.d.ts +6 -1
- package/dist/routes/desktop-distribution.d.ts +32 -0
- package/dist/routes/github-browser-fonts.gen.d.ts +2 -0
- package/dist/routes/github-browser-pages.d.ts +27 -0
- package/dist/routes/inbox.d.ts +13 -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 +28 -0
- package/dist/routes/interaction-placement-message.d.ts +7 -0
- package/dist/routes/managed-sign-in-methods.d.ts +6 -0
- package/dist/routes/model-account-choice.d.ts +13 -0
- package/dist/routes/model-account-settings.d.ts +19 -0
- package/dist/routes/native-app-auth.d.ts +12 -0
- package/dist/routes/organization-integration-policy.d.ts +8 -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-defaults.d.ts +9 -0
- package/dist/routes/organization-service-accounts.d.ts +3 -0
- package/dist/routes/personal-api-keys.d.ts +3 -0
- package/dist/routes/session-admin-access.d.ts +3 -0
- package/dist/routes/session-artifact-associations.d.ts +4 -0
- package/dist/routes/session-history-imports.d.ts +20 -0
- package/dist/routes/sessions.d.ts +38 -2
- package/dist/routes/site-data.d.ts +18 -0
- package/dist/routes/site-publishing.d.ts +5 -0
- package/dist/routes/site-runtime.d.ts +31 -0
- package/dist/routes/site-sql.d.ts +16 -0
- package/dist/routes/slack-bot-access.d.ts +3 -0
- package/dist/routes/subscription-account-pools.d.ts +21 -0
- package/dist/routes/subscription-core-http.d.ts +5 -0
- package/dist/routes/subscription-pool-access.d.ts +37 -0
- package/dist/routes/subscription-pool-core.d.ts +153 -0
- package/dist/routes/supergrok.d.ts +6 -6
- package/dist/routes/usage-allowances.d.ts +12 -0
- package/dist/routes/variable-sets-removed.d.ts +2 -0
- package/dist/routes/vault-providers.d.ts +34 -0
- package/dist/routes/vaults.d.ts +3 -0
- package/dist/routes/workspace-integrations.d.ts +35 -0
- package/dist/routes/workspace-model-providers.d.ts +4 -0
- package/dist/routes/workspaces.d.ts +11 -2
- package/dist/sandbox/agent-update.d.ts +64 -0
- package/dist/sandbox/auth-callout.d.ts +8 -0
- package/dist/sandbox/channel-a.d.ts +15 -1
- package/dist/sandbox/enrollment.d.ts +26 -4
- package/dist/sandbox/machine-audience.d.ts +29 -0
- package/dist/sandbox/machines.d.ts +15 -2
- package/dist/sandbox/metrics-ingestion.d.ts +6 -2
- package/dist/sandbox/screen-control.d.ts +85 -0
- package/dist/sandbox/viewer.d.ts +5 -1
- package/dist/sandbox-file-artifacts.d.ts +17 -1
- package/dist/scheduled-task-blockers.d.ts +39 -0
- package/dist/scheduled-task-deletion.d.ts +3 -4
- package/dist/scheduled-task-lifecycle.d.ts +14 -0
- package/dist/secret-answers.d.ts +40 -0
- package/dist/session-create-observability.d.ts +5 -0
- package/dist/session-event-view-36GO3IL7.js +528 -0
- package/dist/session-event-view-36GO3IL7.js.map +1 -0
- package/dist/signed-state-secret.d.ts +18 -0
- package/dist/site-agent-guard.d.ts +53 -0
- package/dist/site-data/operations.d.ts +103 -0
- package/dist/site-data/service.d.ts +203 -0
- package/dist/site-frame-guard.d.ts +32 -0
- package/dist/site-publishing/agent-data-tools.d.ts +84 -0
- package/dist/site-publishing/agent-model.d.ts +58 -0
- package/dist/site-publishing/agent-session.d.ts +16 -0
- package/dist/site-publishing/content-scanner.d.ts +31 -0
- package/dist/site-publishing/edge-sync.d.ts +48 -0
- package/dist/site-publishing/gateway-signature.d.ts +56 -0
- package/dist/site-publishing/limits.d.ts +63 -0
- package/dist/site-publishing/page-tool-authority.d.ts +30 -0
- package/dist/site-publishing/platform-usage.d.ts +113 -0
- package/dist/site-publishing/platform.d.ts +21 -0
- package/dist/site-publishing/readiness.d.ts +62 -0
- package/dist/site-publishing/runtime.d.ts +179 -0
- package/dist/site-publishing/service.d.ts +264 -0
- package/dist/site-publishing/session-events.d.ts +22 -0
- package/dist/site-publishing/session-views.d.ts +36 -0
- package/dist/site-publishing/viewer.d.ts +40 -0
- package/dist/site-session-origin.d.ts +31 -6
- package/dist/site-sql/format.d.ts +47 -0
- package/dist/site-sql/gateway.d.ts +50 -0
- package/dist/site-sql/service.d.ts +213 -0
- package/dist/temporal-schedule-sync.d.ts +26 -0
- package/dist/transcription/billing-refusal.d.ts +8 -0
- package/dist/transcription/normalize.d.ts +23 -0
- package/dist/transcription/providers/azure-mai.d.ts +12 -0
- package/dist/transcription/providers/azure-openai.d.ts +4 -0
- package/dist/transcription/providers/openai.d.ts +16 -0
- package/dist/transcription/providers/subscription-core.d.ts +39 -0
- package/dist/transcription/service.d.ts +10 -1
- package/dist/transcription/wav-duration.d.ts +8 -0
- package/dist/workspace-tool-gateway-attestations.d.ts +37 -0
- package/dist/workspace-tool-gateway-observability.d.ts +16 -0
- package/dist/workspace-tool-gateway-secrets.d.ts +27 -0
- package/dist/workspace-tool-gateway.d.ts +102 -6
- package/dist/workspace-tool-target-fence.d.ts +116 -0
- package/dist/workspace-tool-target.d.ts +225 -0
- package/dist/workspace-webhook-dispatch.d.ts +26 -0
- package/dist/xai-subscription-core.d.ts +60 -0
- package/package.json +25 -20
- package/src/access-grant-rls.ts +64 -14
- package/src/admission-trace.ts +14 -0
- package/src/app.ts +1684 -252
- package/src/artifact-catalog-cursor.ts +1 -0
- package/src/attached-browser-viewer.ts +26 -0
- package/src/auth/managed-auth-attempt-context.ts +9 -0
- package/src/auth/managed-auth-rate-limits.ts +252 -0
- package/src/auth/managed-auth-session-adapter.ts +64 -29
- package/src/auth/managed-auth.ts +303 -35
- package/src/auth/managed-email.ts +18 -1
- 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 +3 -3
- package/src/auth/signup-funnel-metrics.ts +164 -0
- package/src/azure-live.ts +103 -0
- package/src/browser-action-fences.ts +45 -0
- package/src/browser-controller-authority.ts +1 -186
- package/src/browser-ephemeral.ts +39 -0
- package/src/browser-lost-runtime-end.ts +71 -0
- package/src/browser-state-authority.ts +1 -236
- package/src/claude-default-models.ts +37 -0
- package/src/claude-subscription-core.ts +154 -0
- package/src/claude-subscription-oauth.ts +352 -0
- package/src/claude-subscription-profile.ts +73 -0
- package/src/claude-subscription-usage.ts +51 -0
- package/src/claude-workspace-connection.ts +82 -0
- package/src/codemode.ts +236 -39
- package/src/codex-realtime.ts +181 -53
- package/src/codex-session-pointers.ts +80 -0
- package/src/company-brain-okf.ts +1 -1
- package/src/connected-machine-computer-access.ts +2 -1
- package/src/connection-ownership.ts +19 -13
- package/src/controller-data-plane.ts +34 -0
- package/src/credit-promotion-snapshot.ts +36 -0
- package/src/editable-artifact-production.ts +10 -0
- package/src/editable-artifact-source-session.ts +123 -0
- package/src/editable-artifact-websocket.ts +16 -3
- package/src/fatal-process-boundary.ts +67 -3
- package/src/gateway-realtime.ts +12 -8
- package/src/github-access.ts +31 -5
- package/src/github-browser-flow.ts +1 -1
- package/src/http/acting-person.ts +105 -0
- package/src/http/api-contract-compat.ts +49 -0
- package/src/http/api-error.ts +210 -2
- package/src/http/auth.ts +68 -4
- package/src/http/cors.ts +37 -5
- package/src/http/deprecation.ts +118 -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/rejection-telemetry.ts +120 -0
- package/src/http/request-body.ts +127 -0
- package/src/http/request-source.ts +154 -13
- package/src/http/sse.ts +88 -28
- package/src/http/unmatched-route.ts +60 -0
- package/src/http/user-content.ts +158 -0
- package/src/http/variable-sets-removed.ts +122 -0
- package/src/http/websocket-upgrade-dispatch.ts +29 -0
- package/src/index.ts +107 -57
- package/src/integration-connect-metrics.ts +228 -0
- package/src/integration-endpoint-test.ts +291 -0
- package/src/integrations/api-integrations.ts +81 -7
- package/src/integrations/atlassian.ts +202 -83
- package/src/integrations/fiken.ts +66 -38
- package/src/integrations/github-app-connect.ts +64 -18
- package/src/integrations/github-lens-connect.ts +8 -29
- package/src/integrations/google-drive.ts +448 -152
- package/src/integrations/integration-commit-authority.ts +69 -0
- package/src/integrations/marketplace-plugin.ts +1 -1
- package/src/integrations/oauth-client.ts +733 -193
- package/src/integrations/oauth-profiles.ts +116 -45
- package/src/integrations/onepassword-vault-provider.ts +16 -0
- package/src/integrations/personal-github-repositories.ts +1 -1
- package/src/integrations/personal-github.ts +61 -35
- package/src/integrations/provider-oauth.ts +67 -85
- package/src/integrations/slack-app-home.ts +5 -5
- package/src/integrations/slack-bot.ts +893 -201
- package/src/integrations/slack-file-upload-flow.ts +147 -0
- package/src/integrations/slack-install.ts +7 -7
- package/src/integrations/slack-interactions.ts +1589 -299
- package/src/integrations/slack-mrkdwn.ts +193 -0
- package/src/integrations/slack-routing.ts +2 -2
- package/src/integrations/slack-session-defaults.ts +224 -0
- package/src/integrations/slack-task-file-upload.ts +323 -0
- package/src/integrations/slack-tool-review.ts +65 -0
- package/src/integrations/social-oauth.ts +90 -58
- package/src/interaction-agent-access.ts +40 -20
- package/src/interaction-agent-version.ts +85 -0
- package/src/interaction-holder-heartbeat.ts +24 -8
- package/src/interaction-metrics.ts +164 -2
- package/src/interaction-route-stages.ts +94 -0
- package/src/interaction-secrets-vault.ts +213 -0
- package/src/interaction-secrets.ts +426 -0
- package/src/mcp/action-catalog-types.ts +14 -0
- package/src/mcp/action-catalog.gen.ts +8014 -0
- package/src/mcp/action-descriptions.ts +299 -0
- package/src/mcp/action-schema-imports.gen.ts +304 -0
- package/src/mcp/capability-account-readiness.ts +17 -0
- package/src/mcp/child-read-evidence.ts +19 -0
- package/src/mcp/company-profile-agent-admin.ts +13 -0
- package/src/mcp/contract-input.ts +165 -0
- package/src/mcp/documents.ts +9 -2
- package/src/mcp/editable-artifacts.ts +29 -11
- package/src/mcp/files.ts +5 -1
- package/src/mcp/first-party-tool-permissions.ts +7 -285
- package/src/mcp/knowledge-entries.ts +108 -34
- package/src/mcp/notification-tools.ts +480 -0
- package/src/mcp/orchestration-failure-diagnostic.ts +43 -0
- package/src/mcp/scheduled-task-input.ts +89 -0
- package/src/mcp/scheduled-task-view.ts +63 -3
- package/src/mcp/secret-tools.ts +185 -0
- package/src/mcp/server.ts +2213 -1116
- package/src/mcp/session-admin-access-tools.ts +163 -0
- package/src/mcp/session-event-errors.ts +123 -0
- package/src/mcp/session-event-view.ts +395 -13
- package/src/mcp/session-view.ts +3 -0
- package/src/mcp/session-wait.ts +67 -7
- package/src/mcp/site-agent-clamp-tools.ts +140 -0
- package/src/mcp/site-data-tools.ts +339 -0
- package/src/mcp/site-publication-tools.ts +201 -0
- package/src/mcp/site-sql-tools.ts +427 -0
- package/src/mcp-oauth.ts +635 -45
- package/src/model-calls/chat-completions.ts +352 -0
- package/src/model-calls/pending-usage-settlements.ts +125 -0
- package/src/model-calls/service.ts +694 -0
- package/src/model-catalog.ts +68 -17
- package/src/native-push-dispatch.ts +457 -0
- package/src/observability.ts +15 -1
- package/src/organization-mcp.ts +485 -0
- package/src/prepared-mcp-actor.ts +154 -0
- package/src/prepared-mcp-permissions.ts +38 -0
- package/src/routes/analytics-consent.ts +123 -0
- package/src/routes/api-integrations.ts +268 -9
- package/src/routes/api-keys.ts +164 -25
- package/src/routes/artifact-catalog.ts +111 -0
- package/src/routes/automations.ts +163 -90
- package/src/routes/billing.ts +535 -59
- package/src/routes/browser-sessions.ts +966 -342
- package/src/routes/canonical-human-identities.ts +61 -0
- package/src/routes/capabilities.ts +112 -5
- package/src/routes/channels.ts +4 -3
- package/src/routes/chat-completions.ts +235 -0
- package/src/routes/claude-core-usage.ts +147 -0
- package/src/routes/claude-subscription-accounts.ts +233 -0
- package/src/routes/claude-subscription-oauth.ts +175 -0
- package/src/routes/client-errors.ts +394 -0
- package/src/routes/codex-core.ts +687 -0
- package/src/routes/codex.ts +1277 -1119
- package/src/routes/company-brain.ts +4 -0
- package/src/routes/computer-sessions.ts +319 -85
- package/src/routes/connect.ts +277 -175
- package/src/routes/connections.ts +690 -363
- package/src/routes/desktop-distribution.ts +217 -0
- package/src/routes/documents.ts +13 -7
- package/src/routes/editable-artifacts.ts +74 -4
- package/src/routes/enrollments.ts +110 -16
- package/src/routes/external-identity-links.ts +13 -12
- package/src/routes/files.ts +41 -16
- package/src/routes/github-browser-fonts.gen.ts +12 -0
- package/src/routes/github-browser-pages.ts +258 -0
- package/src/routes/github.ts +200 -75
- package/src/routes/inbox.ts +353 -0
- package/src/routes/insights-response-cache.ts +83 -0
- package/src/routes/insights-usage.ts +345 -0
- package/src/routes/insights.ts +103 -8
- package/src/routes/install.ts +51 -10
- package/src/routes/integration-facets.ts +70 -28
- package/src/routes/interaction-placement-message.ts +12 -0
- package/src/routes/knowledge.ts +136 -27
- package/src/routes/machines.ts +189 -135
- package/src/routes/managed-auth-session-sets.ts +43 -10
- package/src/routes/managed-onboarding.ts +39 -19
- package/src/routes/managed-sign-in-methods.ts +433 -0
- package/src/routes/memory-slack-publications.ts +3 -2
- package/src/routes/model-account-choice.ts +194 -0
- package/src/routes/model-account-settings.ts +235 -0
- package/src/routes/model-connection-access.ts +210 -48
- package/src/routes/native-app-auth.ts +296 -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 +183 -0
- package/src/routes/organization-memberships.ts +205 -19
- package/src/routes/organization-model-defaults.ts +110 -0
- package/src/routes/organization-model-providers.ts +74 -3
- package/src/routes/organization-service-accounts.ts +128 -0
- package/src/routes/organization-sessions.ts +21 -5
- package/src/routes/personal-api-keys.ts +184 -0
- package/src/routes/personal-github-git-broker.ts +2 -2
- package/src/routes/personal-github.ts +9 -4
- package/src/routes/plugins.ts +46 -7
- package/src/routes/pr-review-github.ts +105 -118
- package/src/routes/pr-review.ts +88 -82
- package/src/routes/preference-registry.ts +18 -0
- package/src/routes/rigs.ts +48 -13
- package/src/routes/scheduled-tasks.ts +347 -27
- package/src/routes/session-admin-access.ts +271 -0
- package/src/routes/session-artifact-associations.ts +164 -0
- package/src/routes/session-history-imports.ts +305 -0
- package/src/routes/sessions.ts +1682 -363
- package/src/routes/site-data.ts +340 -0
- package/src/routes/site-publishing.ts +584 -0
- package/src/routes/site-runtime.ts +1944 -0
- package/src/routes/site-sql.ts +263 -0
- package/src/routes/skill-content.ts +72 -7
- package/src/routes/skills.ts +5 -4
- package/src/routes/slack-bot-access.ts +108 -0
- package/src/routes/social.ts +27 -15
- package/src/routes/subscription-account-pools.ts +209 -0
- package/src/routes/subscription-core-http.ts +18 -0
- package/src/routes/subscription-pool-access.ts +180 -0
- package/src/routes/subscription-pool-core.ts +552 -0
- package/src/routes/supergrok.ts +174 -655
- package/src/routes/transcription-recordings.ts +71 -4
- package/src/routes/transcriptions.ts +26 -2
- package/src/routes/usage-allowances.ts +381 -0
- package/src/routes/variable-sets-removed.ts +19 -0
- package/src/routes/vault-providers.ts +782 -0
- package/src/routes/vaults.ts +421 -0
- package/src/routes/video-generation.ts +30 -12
- package/src/routes/workspace-artifacts.ts +165 -53
- package/src/routes/workspace-integrations.ts +576 -0
- package/src/routes/workspace-model-providers.ts +148 -0
- package/src/routes/workspace-state.ts +4 -0
- package/src/routes/workspaces.ts +625 -117
- package/src/sandbox/agent-update.ts +315 -0
- package/src/sandbox/auth-callout.ts +104 -21
- package/src/sandbox/channel-a.ts +165 -55
- package/src/sandbox/enrollment.ts +131 -22
- package/src/sandbox/machine-audience.ts +192 -0
- package/src/sandbox/machines.ts +75 -31
- package/src/sandbox/metrics-ingestion.ts +133 -2
- package/src/sandbox/rematerialize.ts +51 -21
- package/src/sandbox/screen-control.ts +289 -0
- package/src/sandbox/viewer.ts +33 -58
- package/src/sandbox-file-artifacts.ts +53 -27
- package/src/scheduled-task-blockers.ts +293 -0
- package/src/scheduled-task-deletion.ts +13 -3
- package/src/scheduled-task-lifecycle.ts +84 -0
- package/src/secret-answers.ts +119 -0
- package/src/session-create-observability.ts +46 -0
- package/src/session-realtime-context.ts +26 -4
- package/src/signed-state-secret.ts +58 -0
- package/src/site-agent-guard.ts +261 -0
- package/src/site-data/operations.ts +777 -0
- package/src/site-data/service.ts +1043 -0
- package/src/site-frame-guard.ts +107 -0
- package/src/site-publishing/agent-data-tools.ts +250 -0
- package/src/site-publishing/agent-model.ts +127 -0
- package/src/site-publishing/agent-session.ts +148 -0
- package/src/site-publishing/content-scanner.ts +93 -0
- package/src/site-publishing/edge-sync.ts +148 -0
- package/src/site-publishing/gateway-signature.ts +198 -0
- package/src/site-publishing/limits.ts +315 -0
- package/src/site-publishing/page-tool-authority.ts +111 -0
- package/src/site-publishing/platform-usage.ts +479 -0
- package/src/site-publishing/platform.ts +98 -0
- package/src/site-publishing/readiness.ts +330 -0
- package/src/site-publishing/runtime.ts +831 -0
- package/src/site-publishing/service.ts +1282 -0
- package/src/site-publishing/session-events.ts +262 -0
- package/src/site-publishing/session-views.ts +262 -0
- package/src/site-publishing/viewer.ts +75 -0
- package/src/site-session-origin.ts +91 -6
- package/src/site-sql/format.ts +134 -0
- package/src/site-sql/gateway.ts +168 -0
- package/src/site-sql/service.ts +1636 -0
- package/src/site-uploads.ts +27 -5
- package/src/temporal-schedule-sync.ts +74 -0
- package/src/transcription/billing-refusal.ts +14 -0
- package/src/transcription/normalize.ts +77 -0
- package/src/transcription/providers/azure-mai.ts +98 -0
- package/src/transcription/providers/azure-openai.ts +16 -7
- package/src/transcription/providers/codex-subscription.ts +190 -67
- package/src/transcription/providers/openai.ts +79 -5
- package/src/transcription/providers/subscription-core.ts +125 -0
- package/src/transcription/providers/xai-subscription.ts +81 -83
- package/src/transcription/segmenter.ts +7 -1
- package/src/transcription/service.ts +239 -10
- package/src/transcription/wav-duration.ts +39 -0
- package/src/workspace-deletion.ts +25 -1
- package/src/workspace-tool-gateway-attestations.ts +133 -0
- package/src/workspace-tool-gateway-observability.ts +64 -0
- package/src/workspace-tool-gateway-secrets.ts +104 -0
- package/src/workspace-tool-gateway.ts +921 -103
- package/src/workspace-tool-target-fence.ts +380 -0
- package/src/workspace-tool-target.ts +554 -0
- package/src/workspace-webhook-dispatch.ts +225 -0
- package/src/xai-realtime.ts +85 -81
- package/src/xai-subscription-core.ts +172 -0
- package/dist/browser-auth-broker.d.ts +0 -20
- package/dist/chunk-AJ62T5QN.js.map +0 -1
- package/dist/connection-authority-owner.d.ts +0 -59
- package/dist/routes/connection-authorities.d.ts +0 -3
- package/dist/routes/environments.d.ts +0 -5
- package/dist/routes/host-mcp-bindings.d.ts +0 -5
- package/dist/routes/host-mcp-resolvers.d.ts +0 -3
- package/dist/routes/packs.d.ts +0 -3
- package/dist/session-event-view-MU3HMNV3.js +0 -264
- package/dist/session-event-view-MU3HMNV3.js.map +0 -1
- package/dist/xai-subscription-auth.d.ts +0 -23
- package/src/browser-auth-broker.ts +0 -155
- package/src/connection-authority-owner.ts +0 -61
- package/src/routes/connection-authorities.ts +0 -139
- package/src/routes/environments.ts +0 -388
- package/src/routes/host-mcp-bindings.ts +0 -122
- package/src/routes/host-mcp-resolvers.ts +0 -41
- package/src/routes/packs.ts +0 -784
- package/src/xai-subscription-auth.ts +0 -139
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import type { AccessGrantAuthorization } from "@opengeni/core";
|
|
2
|
-
import type { UserResourceAuthoritySummary } from "@opengeni/db";
|
|
3
|
-
import { type IssueConnectionUseGrantRequest as IssueConnectionUseGrantRequestValue } from "@opengeni/contracts/connection-authority";
|
|
4
|
-
/**
|
|
5
|
-
* Personal connection authority is available only to the exact authenticated
|
|
6
|
-
* human. API keys, delegated bearers, services, and agent attempts cannot name
|
|
7
|
-
* or substitute a personal owner.
|
|
8
|
-
*/
|
|
9
|
-
export declare function requireConnectionAuthorityOwner(access: AccessGrantAuthorization): string;
|
|
10
|
-
/** Removes generic resource kind and refuses non-connection grant actions. */
|
|
11
|
-
export declare function projectSelfConnectionAuthorities(page: {
|
|
12
|
-
authorities: UserResourceAuthoritySummary[];
|
|
13
|
-
nextCursor: string | null;
|
|
14
|
-
}): {
|
|
15
|
-
scope: "user";
|
|
16
|
-
authorities: {
|
|
17
|
-
authorityId: string;
|
|
18
|
-
resourceId: string;
|
|
19
|
-
originWorkspaceId: string | null;
|
|
20
|
-
generation: number;
|
|
21
|
-
status: "active" | "retained" | "revoked";
|
|
22
|
-
grants: {
|
|
23
|
-
grantId: string;
|
|
24
|
-
targetWorkspaceId: string;
|
|
25
|
-
targetSessionId: string | null;
|
|
26
|
-
mode: "always" | "once" | "session";
|
|
27
|
-
context: "user_private" | "workspace_shared";
|
|
28
|
-
authorityEpoch: number | null;
|
|
29
|
-
generation: number;
|
|
30
|
-
status: "active" | "consumed" | "expired" | "revoked";
|
|
31
|
-
expiresAt: string | null;
|
|
32
|
-
delegation: {
|
|
33
|
-
authorityId: string;
|
|
34
|
-
grantId: string;
|
|
35
|
-
organizationId: string;
|
|
36
|
-
workspaceId: string;
|
|
37
|
-
sessionId: string | null;
|
|
38
|
-
action: string;
|
|
39
|
-
mode: "always" | "once" | "session";
|
|
40
|
-
context: "user_private" | "workspace_shared";
|
|
41
|
-
authorityEpoch: number | null;
|
|
42
|
-
authorityGeneration: number;
|
|
43
|
-
grantGeneration: number;
|
|
44
|
-
resourceVersionId?: string | null | undefined;
|
|
45
|
-
};
|
|
46
|
-
action: "connection.use";
|
|
47
|
-
}[];
|
|
48
|
-
}[];
|
|
49
|
-
nextCursor: string | null;
|
|
50
|
-
};
|
|
51
|
-
/** The API owns the action; callers supply neither action nor owner identity. */
|
|
52
|
-
export declare function connectionUseGrantLifecycleInput(input: unknown): {
|
|
53
|
-
action: "connection.use";
|
|
54
|
-
mode: IssueConnectionUseGrantRequestValue["mode"];
|
|
55
|
-
context: IssueConnectionUseGrantRequestValue["context"];
|
|
56
|
-
sessionId: string | null;
|
|
57
|
-
expectedAuthorityEpoch: number | null;
|
|
58
|
-
workspaceSharedAcknowledged: boolean;
|
|
59
|
-
};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { Hono } from "hono";
|
|
2
|
-
import type { ApiRouteDeps } from "@opengeni/core";
|
|
3
|
-
export declare function registerVariableSetRoutes(app: Hono, deps: ApiRouteDeps): void;
|
|
4
|
-
/** @deprecated use registerVariableSetRoutes */
|
|
5
|
-
export declare const registerEnvironmentRoutes: typeof registerVariableSetRoutes;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { Hono } from "hono";
|
|
2
|
-
import { type ApiRouteDeps } from "@opengeni/core";
|
|
3
|
-
/** Registration is not an execution grant. The durable runtime must separately
|
|
4
|
-
* validate the exact binding generation and accepted execution context. */
|
|
5
|
-
export declare function registerHostMcpBindingRoutes(app: Hono, deps: ApiRouteDeps): void;
|
package/dist/routes/packs.d.ts
DELETED
|
@@ -1,264 +0,0 @@
|
|
|
1
|
-
// src/mcp/session-event-view.ts
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
var SESSION_EVENT_VIEW_MAX_BYTES = 16 * 1024;
|
|
4
|
-
var selectionSchema = z.object({
|
|
5
|
-
sessionId: z.string().uuid(),
|
|
6
|
-
view: z.enum(["conversation", "results", "tools"]),
|
|
7
|
-
includeArguments: z.boolean(),
|
|
8
|
-
includeOutput: z.boolean(),
|
|
9
|
-
callId: z.string().max(512).refine(
|
|
10
|
-
(value) => Buffer.byteLength(JSON.stringify(value), "utf8") <= 2048,
|
|
11
|
-
"callId exceeds the encoded cursor budget"
|
|
12
|
-
).nullable(),
|
|
13
|
-
direction: z.enum(["before", "after"]),
|
|
14
|
-
after: z.number().int().nonnegative(),
|
|
15
|
-
before: z.number().int().positive().nullable()
|
|
16
|
-
});
|
|
17
|
-
var cursorSchema = z.object({
|
|
18
|
-
v: z.union([z.literal(1), z.literal(2)]),
|
|
19
|
-
selection: selectionSchema,
|
|
20
|
-
sequence: z.number().int().positive().nullable(),
|
|
21
|
-
offset: z.number().int().nonnegative().max(2147483647)
|
|
22
|
-
});
|
|
23
|
-
var types = {
|
|
24
|
-
conversation: ["user.message", "agent.message.completed"],
|
|
25
|
-
// Final turn output is authoritative: do not repeat message.completed text.
|
|
26
|
-
results: ["turn.completed", "turn.failed", "goal.completed", "goal.paused", "tool.auth_needed"],
|
|
27
|
-
tools: ["agent.toolCall.created", "agent.toolCall.output"]
|
|
28
|
-
};
|
|
29
|
-
var record = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
30
|
-
var bytes = (value) => Buffer.byteLength(JSON.stringify(value, null, 2), "utf8");
|
|
31
|
-
var encode = (selection, sequence = null, offset = 0, v = 2) => Buffer.from(JSON.stringify({ v, selection, sequence, offset })).toString("base64url");
|
|
32
|
-
function resolveSessionEventView(input) {
|
|
33
|
-
let continuation = null;
|
|
34
|
-
if (input.cursor !== void 0) {
|
|
35
|
-
if (input.cursor.length > 4096)
|
|
36
|
-
throw new Error("session_events cursor exceeds 4096 characters");
|
|
37
|
-
try {
|
|
38
|
-
continuation = cursorSchema.parse(
|
|
39
|
-
JSON.parse(Buffer.from(input.cursor, "base64url").toString())
|
|
40
|
-
);
|
|
41
|
-
} catch {
|
|
42
|
-
throw new Error("Invalid session_events cursor");
|
|
43
|
-
}
|
|
44
|
-
const previous = continuation.selection;
|
|
45
|
-
for (const key of [
|
|
46
|
-
"sessionId",
|
|
47
|
-
"view",
|
|
48
|
-
"includeArguments",
|
|
49
|
-
"includeOutput",
|
|
50
|
-
"callId",
|
|
51
|
-
"direction",
|
|
52
|
-
"after",
|
|
53
|
-
"before"
|
|
54
|
-
]) {
|
|
55
|
-
if (input[key] !== void 0 && input[key] !== previous[key]) {
|
|
56
|
-
throw new Error(`session_events cursor cannot change ${key}`);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
const selection = continuation?.selection ?? selectionSchema.parse({
|
|
61
|
-
sessionId: input.sessionId,
|
|
62
|
-
view: input.view ?? "conversation",
|
|
63
|
-
includeArguments: input.includeArguments ?? false,
|
|
64
|
-
includeOutput: input.includeOutput ?? false,
|
|
65
|
-
callId: input.callId ?? null,
|
|
66
|
-
direction: input.direction ?? (input.before !== void 0 || input.after === void 0 ? "before" : "after"),
|
|
67
|
-
after: input.after ?? 0,
|
|
68
|
-
before: input.before ?? null
|
|
69
|
-
});
|
|
70
|
-
if (selection.view !== "tools" && (selection.callId || selection.includeArguments || selection.includeOutput)) {
|
|
71
|
-
throw new Error("callId/includeArguments/includeOutput require view=tools");
|
|
72
|
-
}
|
|
73
|
-
if (continuation && (continuation.sequence === null && continuation.offset !== 0 || continuation.sequence !== null && (continuation.sequence <= selection.after || selection.before !== null && continuation.sequence >= selection.before)))
|
|
74
|
-
throw new Error("Invalid session_events cursor position");
|
|
75
|
-
return { selection, continuation };
|
|
76
|
-
}
|
|
77
|
-
function project(event, selection) {
|
|
78
|
-
if (event.duplicateOfEventId || event.turnAssociation && event.turnAssociation !== "current")
|
|
79
|
-
return null;
|
|
80
|
-
const p = record(event.payload);
|
|
81
|
-
const base = { sequence: event.sequence, ...event.turnId ? { turnId: event.turnId } : {} };
|
|
82
|
-
if (selection.view === "conversation") {
|
|
83
|
-
return typeof p.text === "string" && p.text.length > 0 ? { ...base, role: event.type === "user.message" ? "user" : "assistant", text: p.text } : null;
|
|
84
|
-
}
|
|
85
|
-
if (selection.view === "results") {
|
|
86
|
-
if (event.type === "turn.completed" && ("maintenance" in p || "segmentLimit" in p)) return null;
|
|
87
|
-
const value2 = event.type === "turn.completed" ? p.output ?? p.result : p;
|
|
88
|
-
if (value2 === void 0 || value2 === "") return null;
|
|
89
|
-
return {
|
|
90
|
-
...base,
|
|
91
|
-
type: event.type,
|
|
92
|
-
text: typeof value2 === "string" ? value2 : JSON.stringify(value2)
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
const callId = p.callId ?? p.call_id ?? p.id;
|
|
96
|
-
if (selection.callId !== null && selection.callId !== callId) return null;
|
|
97
|
-
const output = event.type === "agent.toolCall.output";
|
|
98
|
-
const value = output ? p.output : p.arguments ?? p.args;
|
|
99
|
-
return {
|
|
100
|
-
...base,
|
|
101
|
-
callId,
|
|
102
|
-
kind: output ? "result" : "call",
|
|
103
|
-
...typeof p.name === "string" ? { name: p.name } : {},
|
|
104
|
-
...p.identityOmitted === true ? { identityOmitted: true } : {},
|
|
105
|
-
...p.isError === true || record(value).isError === true ? { isError: true } : {},
|
|
106
|
-
...(output ? selection.includeOutput : selection.includeArguments) && value !== void 0 ? {
|
|
107
|
-
text: typeof value === "string" ? value : JSON.stringify(value),
|
|
108
|
-
encoding: typeof value === "string" ? "text" : "json"
|
|
109
|
-
} : {}
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
async function readSessionEventView(input, read) {
|
|
113
|
-
const { selection, continuation } = resolveSessionEventView(input);
|
|
114
|
-
const limit = Math.max(1, Math.min(50, input.limit ?? 10));
|
|
115
|
-
let after = continuation?.sequence && selection.direction === "after" ? continuation.sequence - 1 : selection.after;
|
|
116
|
-
let before = continuation?.sequence && selection.direction === "before" ? continuation.sequence + 1 : selection.before;
|
|
117
|
-
const events = [];
|
|
118
|
-
let hasMore = false;
|
|
119
|
-
let nextCursor = null;
|
|
120
|
-
let sourceExact = true;
|
|
121
|
-
let edge = null;
|
|
122
|
-
let legacyActive = continuation?.v === 1 && continuation.sequence !== null;
|
|
123
|
-
const page = () => ({
|
|
124
|
-
view: selection.view,
|
|
125
|
-
direction: selection.direction,
|
|
126
|
-
events,
|
|
127
|
-
nextAfter: selection.direction === "after" ? edge ?? selection.after : null,
|
|
128
|
-
nextBefore: selection.direction === "before" ? edge ?? selection.before : null,
|
|
129
|
-
hasMore,
|
|
130
|
-
nextCursor,
|
|
131
|
-
sourceExact,
|
|
132
|
-
...!sourceExact ? {
|
|
133
|
-
sourceLoss: {
|
|
134
|
-
reason: "structured_value_exceeds_budget",
|
|
135
|
-
completeTextAvailable: false,
|
|
136
|
-
message: "An oversized structured value was omitted. Scalar text remains retrievable through continuation; omitted structured values are not complete JSON results."
|
|
137
|
-
}
|
|
138
|
-
} : {},
|
|
139
|
-
maxBytes: SESSION_EVENT_VIEW_MAX_BYTES
|
|
140
|
-
});
|
|
141
|
-
const resume = (sequence, offset = 0) => {
|
|
142
|
-
hasMore = true;
|
|
143
|
-
nextCursor = encode(
|
|
144
|
-
{ ...selection, after, before },
|
|
145
|
-
sequence,
|
|
146
|
-
offset,
|
|
147
|
-
legacyActive && sequence === continuation?.sequence ? 1 : 2
|
|
148
|
-
);
|
|
149
|
-
};
|
|
150
|
-
for (let scan = 0; scan < 64; scan += 1) {
|
|
151
|
-
const source = await read({
|
|
152
|
-
after,
|
|
153
|
-
...before === null ? {} : { before },
|
|
154
|
-
direction: selection.direction,
|
|
155
|
-
limit: 8,
|
|
156
|
-
includeTypes: types[selection.view],
|
|
157
|
-
payloadMode: "full",
|
|
158
|
-
excludeUnclaimedHumanPrompts: true,
|
|
159
|
-
maxBytes: 1024 * 1024,
|
|
160
|
-
legacyUtf16: legacyActive,
|
|
161
|
-
view: selection.view,
|
|
162
|
-
includeArguments: selection.includeArguments,
|
|
163
|
-
includeOutput: selection.includeOutput,
|
|
164
|
-
...continuation?.sequence ? { sourceSequence: continuation.sequence, sourceOffset: continuation.offset } : {}
|
|
165
|
-
});
|
|
166
|
-
sourceExact &&= source.fullPayloadsExact;
|
|
167
|
-
const ordered = selection.direction === "before" ? [...source.events].reverse() : source.events;
|
|
168
|
-
for (const event of ordered) {
|
|
169
|
-
const slice = source.slices?.[event.sequence];
|
|
170
|
-
const item = project(event, selection);
|
|
171
|
-
if (item) {
|
|
172
|
-
const offset = continuation?.sequence === event.sequence ? continuation.offset : 0;
|
|
173
|
-
if (slice?.omitted) {
|
|
174
|
-
delete item.text;
|
|
175
|
-
item.sourceOmitted = { reason: "structured_value_exceeds_budget", complete: false };
|
|
176
|
-
}
|
|
177
|
-
const advance = (text) => slice?.unit === "codepoint" ? Array.from(text).length : text.length;
|
|
178
|
-
if (!slice && offset > (item.text?.length ?? 0))
|
|
179
|
-
throw new Error("Invalid message continuation offset");
|
|
180
|
-
if (!slice && offset > 0 && item.text && /[\uD800-\uDBFF]/.test(item.text[offset - 1]) && /[\uDC00-\uDFFF]/.test(item.text[offset] ?? "")) {
|
|
181
|
-
throw new Error("Invalid message continuation offset: splits a surrogate pair");
|
|
182
|
-
}
|
|
183
|
-
if (!slice && offset > 0 && item.text) item.text = item.text.slice(offset);
|
|
184
|
-
events.push(item);
|
|
185
|
-
if (bytes(page()) > SESSION_EVENT_VIEW_MAX_BYTES - 4096) {
|
|
186
|
-
events.pop();
|
|
187
|
-
if (events.length > 0) {
|
|
188
|
-
resume(event.sequence, offset);
|
|
189
|
-
if (selection.direction === "before") events.reverse();
|
|
190
|
-
return page();
|
|
191
|
-
}
|
|
192
|
-
if (!item.text) throw new Error("Session event identity exceeds page budget");
|
|
193
|
-
const text = item.text;
|
|
194
|
-
let low = 0;
|
|
195
|
-
let high = text.length;
|
|
196
|
-
while (low < high) {
|
|
197
|
-
const mid = Math.ceil((low + high) / 2);
|
|
198
|
-
if (bytes({ ...item, text: text.slice(0, mid) }) <= SESSION_EVENT_VIEW_MAX_BYTES - 6e3)
|
|
199
|
-
low = mid;
|
|
200
|
-
else high = mid - 1;
|
|
201
|
-
}
|
|
202
|
-
if (low > 0 && /[\uD800-\uDBFF]/.test(text[low - 1])) low -= 1;
|
|
203
|
-
if (low === 0) throw new Error("Session event identity exceeds page budget");
|
|
204
|
-
events.push({
|
|
205
|
-
...item,
|
|
206
|
-
text: text.slice(0, low),
|
|
207
|
-
fragment: {
|
|
208
|
-
offset,
|
|
209
|
-
nextOffset: offset + advance(text.slice(0, low)),
|
|
210
|
-
complete: false,
|
|
211
|
-
unit: slice?.unit ?? "utf16"
|
|
212
|
-
}
|
|
213
|
-
});
|
|
214
|
-
resume(event.sequence, offset + advance(text.slice(0, low)));
|
|
215
|
-
return page();
|
|
216
|
-
}
|
|
217
|
-
const nextOffset = offset + advance(item.text ?? "");
|
|
218
|
-
if (slice && !slice.omitted && nextOffset < slice.total) {
|
|
219
|
-
item.fragment = { offset, nextOffset, complete: false, unit: slice.unit };
|
|
220
|
-
resume(event.sequence, nextOffset);
|
|
221
|
-
if (selection.direction === "before") events.reverse();
|
|
222
|
-
return page();
|
|
223
|
-
}
|
|
224
|
-
if (offset > 0)
|
|
225
|
-
item.fragment = {
|
|
226
|
-
offset,
|
|
227
|
-
nextOffset,
|
|
228
|
-
complete: true,
|
|
229
|
-
unit: slice?.unit ?? "utf16"
|
|
230
|
-
};
|
|
231
|
-
}
|
|
232
|
-
edge = event.sequence;
|
|
233
|
-
legacyActive = false;
|
|
234
|
-
if (selection.direction === "after") after = event.sequence;
|
|
235
|
-
else before = event.sequence;
|
|
236
|
-
if (events.length >= limit) {
|
|
237
|
-
hasMore = source.hasMore || event !== ordered.at(-1);
|
|
238
|
-
nextCursor = hasMore ? encode({ ...selection, after, before }) : null;
|
|
239
|
-
if (selection.direction === "before") events.reverse();
|
|
240
|
-
return page();
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
if (source.coveredSequence) {
|
|
244
|
-
if (selection.direction === "after") after = Math.max(after, source.coveredSequence.last);
|
|
245
|
-
else before = Math.min(before ?? Infinity, source.coveredSequence.first);
|
|
246
|
-
}
|
|
247
|
-
if (!source.hasMore) {
|
|
248
|
-
hasMore = false;
|
|
249
|
-
nextCursor = null;
|
|
250
|
-
if (selection.direction === "before") events.reverse();
|
|
251
|
-
return page();
|
|
252
|
-
}
|
|
253
|
-
hasMore = true;
|
|
254
|
-
nextCursor = encode({ ...selection, after, before });
|
|
255
|
-
}
|
|
256
|
-
if (selection.direction === "before") events.reverse();
|
|
257
|
-
return page();
|
|
258
|
-
}
|
|
259
|
-
export {
|
|
260
|
-
SESSION_EVENT_VIEW_MAX_BYTES,
|
|
261
|
-
readSessionEventView,
|
|
262
|
-
resolveSessionEventView
|
|
263
|
-
};
|
|
264
|
-
//# sourceMappingURL=session-event-view-MU3HMNV3.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/mcp/session-event-view.ts"],"sourcesContent":["import { z } from \"zod\";\nimport type { SessionEvent, SessionEventType } from \"@opengeni/contracts\";\nimport type {\n SessionEventSliceOptions,\n SessionEventSlicePage,\n} from \"@opengeni/db/session-event-slices\";\n\nexport const SESSION_EVENT_VIEW_MAX_BYTES = 16 * 1024;\nconst selectionSchema = z.object({\n sessionId: z.string().uuid(),\n view: z.enum([\"conversation\", \"results\", \"tools\"]),\n includeArguments: z.boolean(),\n includeOutput: z.boolean(),\n callId: z\n .string()\n .max(512)\n .refine(\n (value) => Buffer.byteLength(JSON.stringify(value), \"utf8\") <= 2048,\n \"callId exceeds the encoded cursor budget\",\n )\n .nullable(),\n direction: z.enum([\"before\", \"after\"]),\n after: z.number().int().nonnegative(),\n before: z.number().int().positive().nullable(),\n});\nconst cursorSchema = z.object({\n v: z.union([z.literal(1), z.literal(2)]),\n selection: selectionSchema,\n sequence: z.number().int().positive().nullable(),\n offset: z.number().int().nonnegative().max(2_147_483_647),\n});\ntype Selection = z.infer<typeof selectionSchema>;\nexport type SessionEventViewInput = {\n sessionId: string;\n view?: Selection[\"view\"] | undefined;\n after?: number | undefined;\n before?: number | undefined;\n direction?: Selection[\"direction\"] | undefined;\n limit?: number | undefined;\n cursor?: string | undefined;\n callId?: string | undefined;\n includeArguments?: boolean | undefined;\n includeOutput?: boolean | undefined;\n};\ntype Item = { sequence: number; turnId?: string; role?: string; text?: string } & Record<\n string,\n unknown\n>;\ntype ReadPage = (options: SessionEventSliceOptions) => Promise<SessionEventSlicePage>;\nconst types: Record<Selection[\"view\"], SessionEventType[]> = {\n conversation: [\"user.message\", \"agent.message.completed\"],\n // Final turn output is authoritative: do not repeat message.completed text.\n results: [\"turn.completed\", \"turn.failed\", \"goal.completed\", \"goal.paused\", \"tool.auth_needed\"],\n tools: [\"agent.toolCall.created\", \"agent.toolCall.output\"],\n};\nconst record = (value: unknown): Record<string, unknown> =>\n value !== null && typeof value === \"object\" && !Array.isArray(value)\n ? (value as Record<string, unknown>)\n : {};\nconst bytes = (value: unknown) => Buffer.byteLength(JSON.stringify(value, null, 2), \"utf8\");\nconst encode = (selection: Selection, sequence: number | null = null, offset = 0, v = 2) =>\n Buffer.from(JSON.stringify({ v, selection, sequence, offset })).toString(\"base64url\");\n\n/** A cursor is a bounded selector, never authority. The caller reauthorizes every read. */\nexport function resolveSessionEventView(input: SessionEventViewInput) {\n let continuation: z.infer<typeof cursorSchema> | null = null;\n if (input.cursor !== undefined) {\n if (input.cursor.length > 4096)\n throw new Error(\"session_events cursor exceeds 4096 characters\");\n try {\n continuation = cursorSchema.parse(\n JSON.parse(Buffer.from(input.cursor, \"base64url\").toString()),\n );\n } catch {\n throw new Error(\"Invalid session_events cursor\");\n }\n const previous = continuation.selection;\n for (const key of [\n \"sessionId\",\n \"view\",\n \"includeArguments\",\n \"includeOutput\",\n \"callId\",\n \"direction\",\n \"after\",\n \"before\",\n ] as const) {\n if (input[key] !== undefined && input[key] !== previous[key]) {\n throw new Error(`session_events cursor cannot change ${key}`);\n }\n }\n }\n const selection =\n continuation?.selection ??\n selectionSchema.parse({\n sessionId: input.sessionId,\n view: input.view ?? \"conversation\",\n includeArguments: input.includeArguments ?? false,\n includeOutput: input.includeOutput ?? false,\n callId: input.callId ?? null,\n direction:\n input.direction ??\n (input.before !== undefined || input.after === undefined ? \"before\" : \"after\"),\n after: input.after ?? 0,\n before: input.before ?? null,\n });\n if (\n selection.view !== \"tools\" &&\n (selection.callId || selection.includeArguments || selection.includeOutput)\n ) {\n throw new Error(\"callId/includeArguments/includeOutput require view=tools\");\n }\n if (\n continuation &&\n ((continuation.sequence === null && continuation.offset !== 0) ||\n (continuation.sequence !== null &&\n (continuation.sequence <= selection.after ||\n (selection.before !== null && continuation.sequence >= selection.before))))\n )\n throw new Error(\"Invalid session_events cursor position\");\n return { selection, continuation };\n}\n\nfunction project(event: SessionEvent, selection: Selection): Item | null {\n if (event.duplicateOfEventId || (event.turnAssociation && event.turnAssociation !== \"current\"))\n return null;\n const p = record(event.payload);\n const base = { sequence: event.sequence, ...(event.turnId ? { turnId: event.turnId } : {}) };\n if (selection.view === \"conversation\") {\n return typeof p.text === \"string\" && p.text.length > 0\n ? { ...base, role: event.type === \"user.message\" ? \"user\" : \"assistant\", text: p.text }\n : null;\n }\n if (selection.view === \"results\") {\n if (event.type === \"turn.completed\" && (\"maintenance\" in p || \"segmentLimit\" in p)) return null;\n const value = event.type === \"turn.completed\" ? (p.output ?? p.result) : p;\n if (value === undefined || value === \"\") return null;\n return {\n ...base,\n type: event.type,\n text: typeof value === \"string\" ? value : JSON.stringify(value),\n };\n }\n const callId = p.callId ?? p.call_id ?? p.id;\n if (selection.callId !== null && selection.callId !== callId) return null;\n const output = event.type === \"agent.toolCall.output\";\n // Choose one canonical slot. Never ship the raw receipt beside its parsed copy.\n const value = output ? p.output : (p.arguments ?? p.args);\n return {\n ...base,\n callId,\n kind: output ? \"result\" : \"call\",\n ...(typeof p.name === \"string\" ? { name: p.name } : {}),\n ...(p.identityOmitted === true ? { identityOmitted: true } : {}),\n ...(p.isError === true || record(value).isError === true ? { isError: true } : {}),\n ...((output ? selection.includeOutput : selection.includeArguments) && value !== undefined\n ? {\n text: typeof value === \"string\" ? value : JSON.stringify(value),\n encoding: typeof value === \"string\" ? \"text\" : \"json\",\n }\n : {}),\n };\n}\n\n/** Read-only projection over the existing RLS/audit query. No command observations. */\nexport async function readSessionEventView(input: SessionEventViewInput, read: ReadPage) {\n const { selection, continuation } = resolveSessionEventView(input);\n const limit = Math.max(1, Math.min(50, input.limit ?? 10));\n let after =\n continuation?.sequence && selection.direction === \"after\"\n ? continuation.sequence - 1\n : selection.after;\n let before =\n continuation?.sequence && selection.direction === \"before\"\n ? continuation.sequence + 1\n : selection.before;\n const events: Item[] = [];\n let hasMore = false;\n let nextCursor: string | null = null;\n let sourceExact = true;\n let edge: number | null = null;\n let legacyActive = continuation?.v === 1 && continuation.sequence !== null;\n const page = () => ({\n view: selection.view,\n direction: selection.direction,\n events,\n nextAfter: selection.direction === \"after\" ? (edge ?? selection.after) : null,\n nextBefore: selection.direction === \"before\" ? (edge ?? selection.before) : null,\n hasMore,\n nextCursor,\n sourceExact,\n ...(!sourceExact\n ? {\n sourceLoss: {\n reason: \"structured_value_exceeds_budget\" as const,\n completeTextAvailable: false as const,\n message:\n \"An oversized structured value was omitted. Scalar text remains retrievable through continuation; omitted structured values are not complete JSON results.\",\n },\n }\n : {}),\n maxBytes: SESSION_EVENT_VIEW_MAX_BYTES,\n });\n const resume = (sequence: number, offset = 0) => {\n hasMore = true;\n nextCursor = encode(\n { ...selection, after, before },\n sequence,\n offset,\n legacyActive && sequence === continuation?.sequence ? 1 : 2,\n );\n };\n // Bound work even when a sparse exact callId lookup matches nothing. The\n // returned cursor advances the scan without claiming the lookup is exhausted.\n for (let scan = 0; scan < 64; scan += 1) {\n const source = await read({\n after,\n ...(before === null ? {} : { before }),\n direction: selection.direction,\n limit: 8,\n includeTypes: types[selection.view],\n payloadMode: \"full\",\n excludeUnclaimedHumanPrompts: true,\n maxBytes: 1024 * 1024,\n legacyUtf16: legacyActive,\n view: selection.view,\n includeArguments: selection.includeArguments,\n includeOutput: selection.includeOutput,\n ...(continuation?.sequence\n ? { sourceSequence: continuation.sequence, sourceOffset: continuation.offset }\n : {}),\n });\n sourceExact &&= source.fullPayloadsExact;\n const ordered = selection.direction === \"before\" ? [...source.events].reverse() : source.events;\n for (const event of ordered) {\n const slice = source.slices?.[event.sequence];\n const item = project(event, selection);\n if (item) {\n const offset = continuation?.sequence === event.sequence ? continuation.offset : 0;\n if (slice?.omitted) {\n delete item.text;\n item.sourceOmitted = { reason: \"structured_value_exceeds_budget\", complete: false };\n }\n const advance = (text: string) =>\n slice?.unit === \"codepoint\" ? Array.from(text).length : text.length;\n if (!slice && offset > (item.text?.length ?? 0))\n throw new Error(\"Invalid message continuation offset\");\n if (\n !slice &&\n offset > 0 &&\n item.text &&\n /[\\uD800-\\uDBFF]/.test(item.text[offset - 1]!) &&\n /[\\uDC00-\\uDFFF]/.test(item.text[offset] ?? \"\")\n ) {\n throw new Error(\"Invalid message continuation offset: splits a surrogate pair\");\n }\n if (!slice && offset > 0 && item.text) item.text = item.text.slice(offset);\n events.push(item);\n // Reserve enough for the bounded cursor and fragment facts.\n if (bytes(page()) > SESSION_EVENT_VIEW_MAX_BYTES - 4096) {\n events.pop();\n if (events.length > 0) {\n resume(event.sequence, offset);\n if (selection.direction === \"before\") events.reverse();\n return page();\n }\n if (!item.text) throw new Error(\"Session event identity exceeds page budget\");\n const text = item.text;\n let low = 0;\n let high = text.length;\n while (low < high) {\n const mid = Math.ceil((low + high) / 2);\n if (bytes({ ...item, text: text.slice(0, mid) }) <= SESSION_EVENT_VIEW_MAX_BYTES - 6000)\n low = mid;\n else high = mid - 1;\n }\n // Do not split a UTF-16 surrogate pair (UTF-8 remains lossless).\n if (low > 0 && /[\\uD800-\\uDBFF]/.test(text[low - 1]!)) low -= 1;\n if (low === 0) throw new Error(\"Session event identity exceeds page budget\");\n events.push({\n ...item,\n text: text.slice(0, low),\n fragment: {\n offset,\n nextOffset: offset + advance(text.slice(0, low)),\n complete: false,\n unit: slice?.unit ?? \"utf16\",\n },\n });\n resume(event.sequence, offset + advance(text.slice(0, low)));\n return page();\n }\n const nextOffset = offset + advance(item.text ?? \"\");\n if (slice && !slice.omitted && nextOffset < slice.total) {\n item.fragment = { offset, nextOffset, complete: false, unit: slice.unit };\n resume(event.sequence, nextOffset);\n if (selection.direction === \"before\") events.reverse();\n return page();\n }\n if (offset > 0)\n item.fragment = {\n offset,\n nextOffset,\n complete: true,\n unit: slice?.unit ?? \"utf16\",\n };\n }\n edge = event.sequence;\n legacyActive = false;\n if (selection.direction === \"after\") after = event.sequence;\n else before = event.sequence;\n if (events.length >= limit) {\n hasMore = source.hasMore || event !== ordered.at(-1);\n nextCursor = hasMore ? encode({ ...selection, after, before }) : null;\n if (selection.direction === \"before\") events.reverse();\n return page();\n }\n }\n // Metadata selection can advance over stale/duplicate rows without a\n // projected payload. Use its covered edge rather than repeating the page.\n if (source.coveredSequence) {\n if (selection.direction === \"after\") after = Math.max(after, source.coveredSequence.last);\n else before = Math.min(before ?? Infinity, source.coveredSequence.first);\n }\n if (!source.hasMore) {\n hasMore = false;\n nextCursor = null;\n if (selection.direction === \"before\") events.reverse();\n return page();\n }\n hasMore = true;\n nextCursor = encode({ ...selection, after, before });\n }\n if (selection.direction === \"before\") events.reverse();\n return page();\n}\n"],"mappings":";AAAA,SAAS,SAAS;AAOX,IAAM,+BAA+B,KAAK;AACjD,IAAM,kBAAkB,EAAE,OAAO;AAAA,EAC/B,WAAW,EAAE,OAAO,EAAE,KAAK;AAAA,EAC3B,MAAM,EAAE,KAAK,CAAC,gBAAgB,WAAW,OAAO,CAAC;AAAA,EACjD,kBAAkB,EAAE,QAAQ;AAAA,EAC5B,eAAe,EAAE,QAAQ;AAAA,EACzB,QAAQ,EACL,OAAO,EACP,IAAI,GAAG,EACP;AAAA,IACC,CAAC,UAAU,OAAO,WAAW,KAAK,UAAU,KAAK,GAAG,MAAM,KAAK;AAAA,I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,iBAAO,MAAM,UAAU,UAAU;AACjC,cAAI,UAAU,cAAc,SAAU,QAAO,QAAQ;AACrD,iBAAO,KAAK;AAAA,QACd;AACA,YAAI,SAAS;AACX,eAAK,WAAW;AAAA,YACd;AAAA,YACA;AAAA,YACA,UAAU;AAAA,YACV,MAAM,OAAO,QAAQ;AAAA,UACvB;AAAA,MACJ;AACA,aAAO,MAAM;AACb,qBAAe;AACf,UAAI,UAAU,cAAc,QAAS,SAAQ,MAAM;AAAA,UAC9C,UAAS,MAAM;AACpB,UAAI,OAAO,UAAU,OAAO;AAC1B,kBAAU,OAAO,WAAW,UAAU,QAAQ,GAAG,EAAE;AACnD,qBAAa,UAAU,OAAO,EAAE,GAAG,WAAW,OAAO,OAAO,CAAC,IAAI;AACjE,YAAI,UAAU,cAAc,SAAU,QAAO,QAAQ;AACrD,eAAO,KAAK;AAAA,MACd;AAAA,IACF;AAGA,QAAI,OAAO,iBAAiB;AAC1B,UAAI,UAAU,cAAc,QAAS,SAAQ,KAAK,IAAI,OAAO,OAAO,gBAAgB,IAAI;AAAA,UACnF,UAAS,KAAK,IAAI,UAAU,UAAU,OAAO,gBAAgB,KAAK;AAAA,IACzE;AACA,QAAI,CAAC,OAAO,SAAS;AACnB,gBAAU;AACV,mBAAa;AACb,UAAI,UAAU,cAAc,SAAU,QAAO,QAAQ;AACrD,aAAO,KAAK;AAAA,IACd;AACA,cAAU;AACV,iBAAa,OAAO,EAAE,GAAG,WAAW,OAAO,OAAO,CAAC;AAAA,EACrD;AACA,MAAI,UAAU,cAAc,SAAU,QAAO,QAAQ;AACrD,SAAO,KAAK;AACd;","names":["value"]}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { type Settings } from "@opengeni/config";
|
|
2
|
-
import type { XaiProviderAccountAuthoritySnapshotV1 } from "@opengeni/contracts";
|
|
3
|
-
import { type Database } from "@opengeni/db";
|
|
4
|
-
import { type XaiFetch, type XaiProxyAuthContext } from "@opengeni/xai-subscription";
|
|
5
|
-
export type XaiSubscriptionAuthorization = {
|
|
6
|
-
context: XaiProxyAuthContext;
|
|
7
|
-
credentialId: string;
|
|
8
|
-
authoritySnapshot: XaiProviderAccountAuthoritySnapshotV1;
|
|
9
|
-
rotationEnabled: boolean;
|
|
10
|
-
};
|
|
11
|
-
export declare function buildXaiSubscriptionAuthorization(input: {
|
|
12
|
-
db: Database;
|
|
13
|
-
settings: Settings;
|
|
14
|
-
accountId: string;
|
|
15
|
-
workspaceId: string;
|
|
16
|
-
subjectId: string;
|
|
17
|
-
shardKey: string;
|
|
18
|
-
pinnedCredentialId?: string | null;
|
|
19
|
-
pinSource?: "manual" | "policy" | null;
|
|
20
|
-
authoritySnapshot?: XaiProviderAccountAuthoritySnapshotV1;
|
|
21
|
-
sessionId?: string;
|
|
22
|
-
fetch?: XaiFetch;
|
|
23
|
-
}): Promise<XaiSubscriptionAuthorization>;
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import { createHmac } from "node:crypto";
|
|
2
|
-
import type {
|
|
3
|
-
BrowserProtectedAuthFieldValue,
|
|
4
|
-
ProtectedAuthField,
|
|
5
|
-
SiteAuthAuthority,
|
|
6
|
-
} from "@opengeni/contracts";
|
|
7
|
-
|
|
8
|
-
type ConnectionFieldsAuthority = Extract<SiteAuthAuthority, { kind: "connection_fields" }>;
|
|
9
|
-
|
|
10
|
-
export class BrowserAuthCredentialError extends Error {
|
|
11
|
-
readonly name = "BrowserAuthCredentialError";
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export function resolveProtectedAuthFieldValues(input: {
|
|
15
|
-
authority: ConnectionFieldsAuthority;
|
|
16
|
-
requestedFields: readonly ProtectedAuthField[];
|
|
17
|
-
credential: Readonly<Record<string, unknown>>;
|
|
18
|
-
nowMs?: number;
|
|
19
|
-
}): BrowserProtectedAuthFieldValue[] {
|
|
20
|
-
const configured = new Map(input.authority.fields.map((field) => [field.id, field]));
|
|
21
|
-
return input.requestedFields.map((requested) => {
|
|
22
|
-
const field = configured.get(requested.fieldId);
|
|
23
|
-
if (!field) {
|
|
24
|
-
throw new BrowserAuthCredentialError(
|
|
25
|
-
`Protected auth field ${requested.fieldId} is not configured`,
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
const stored = Object.prototype.hasOwnProperty.call(input.credential, field.credentialKey)
|
|
29
|
-
? input.credential[field.credentialKey]
|
|
30
|
-
: undefined;
|
|
31
|
-
if (typeof stored !== "string" || stored.length === 0) {
|
|
32
|
-
throw new BrowserAuthCredentialError(
|
|
33
|
-
`Credential field ${field.credentialKey} is unavailable`,
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
const value =
|
|
37
|
-
field.purpose === "totp"
|
|
38
|
-
? totpCode(stored, {
|
|
39
|
-
...(field.digits === undefined ? {} : { digits: field.digits }),
|
|
40
|
-
...(field.periodSeconds === undefined ? {} : { periodSeconds: field.periodSeconds }),
|
|
41
|
-
...(field.algorithm === undefined ? {} : { algorithm: field.algorithm }),
|
|
42
|
-
...(input.nowMs === undefined ? {} : { nowMs: input.nowMs }),
|
|
43
|
-
})
|
|
44
|
-
: stored;
|
|
45
|
-
return {
|
|
46
|
-
fieldId: requested.fieldId,
|
|
47
|
-
locator: requested.locator,
|
|
48
|
-
purpose: field.purpose,
|
|
49
|
-
value,
|
|
50
|
-
};
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export function totpCode(
|
|
55
|
-
secretValue: string,
|
|
56
|
-
options: {
|
|
57
|
-
digits?: number;
|
|
58
|
-
periodSeconds?: number;
|
|
59
|
-
algorithm?: "sha1" | "sha256" | "sha512";
|
|
60
|
-
nowMs?: number;
|
|
61
|
-
} = {},
|
|
62
|
-
): string {
|
|
63
|
-
const uri = secretValue.startsWith("otpauth://") ? parseOtpAuthUri(secretValue) : null;
|
|
64
|
-
const digits = options.digits ?? uri?.digits ?? 6;
|
|
65
|
-
const periodSeconds = options.periodSeconds ?? uri?.periodSeconds ?? 30;
|
|
66
|
-
const algorithm = options.algorithm ?? uri?.algorithm ?? "sha1";
|
|
67
|
-
if (!Number.isInteger(digits) || digits < 6 || digits > 10) {
|
|
68
|
-
throw new BrowserAuthCredentialError("TOTP digits must be between 6 and 10");
|
|
69
|
-
}
|
|
70
|
-
if (!Number.isInteger(periodSeconds) || periodSeconds < 15 || periodSeconds > 300) {
|
|
71
|
-
throw new BrowserAuthCredentialError("TOTP period is outside the supported range");
|
|
72
|
-
}
|
|
73
|
-
const nowMs = options.nowMs ?? Date.now();
|
|
74
|
-
if (!Number.isFinite(nowMs) || nowMs < 0) {
|
|
75
|
-
throw new BrowserAuthCredentialError("TOTP time is invalid");
|
|
76
|
-
}
|
|
77
|
-
const secret = decodeBase32(uri?.secret ?? secretValue);
|
|
78
|
-
const counter = Buffer.alloc(8);
|
|
79
|
-
counter.writeBigUInt64BE(BigInt(Math.floor(nowMs / (periodSeconds * 1_000))));
|
|
80
|
-
const digest = createHmac(algorithm, secret).update(counter).digest();
|
|
81
|
-
const offset = digest[digest.length - 1]! & 0x0f;
|
|
82
|
-
const binary =
|
|
83
|
-
((digest[offset]! & 0x7f) << 24) |
|
|
84
|
-
(digest[offset + 1]! << 16) |
|
|
85
|
-
(digest[offset + 2]! << 8) |
|
|
86
|
-
digest[offset + 3]!;
|
|
87
|
-
const code = String(binary % 10 ** digits).padStart(digits, "0");
|
|
88
|
-
secret.fill(0);
|
|
89
|
-
counter.fill(0);
|
|
90
|
-
digest.fill(0);
|
|
91
|
-
return code;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
function parseOtpAuthUri(value: string): {
|
|
95
|
-
secret: string;
|
|
96
|
-
digits?: number;
|
|
97
|
-
periodSeconds?: number;
|
|
98
|
-
algorithm?: "sha1" | "sha256" | "sha512";
|
|
99
|
-
} {
|
|
100
|
-
let url: URL;
|
|
101
|
-
try {
|
|
102
|
-
url = new URL(value);
|
|
103
|
-
} catch {
|
|
104
|
-
throw new BrowserAuthCredentialError("TOTP credential contains an invalid otpauth URI");
|
|
105
|
-
}
|
|
106
|
-
if (url.protocol !== "otpauth:" || url.hostname !== "totp") {
|
|
107
|
-
throw new BrowserAuthCredentialError("Only otpauth TOTP credentials are supported");
|
|
108
|
-
}
|
|
109
|
-
const secret = url.searchParams.get("secret")?.trim();
|
|
110
|
-
if (!secret) throw new BrowserAuthCredentialError("TOTP credential has no secret");
|
|
111
|
-
const digits = optionalIntegerParameter(url, "digits");
|
|
112
|
-
const periodSeconds = optionalIntegerParameter(url, "period");
|
|
113
|
-
const rawAlgorithm = url.searchParams.get("algorithm")?.toLowerCase();
|
|
114
|
-
if (rawAlgorithm && !["sha1", "sha256", "sha512"].includes(rawAlgorithm)) {
|
|
115
|
-
throw new BrowserAuthCredentialError("TOTP credential uses an unsupported algorithm");
|
|
116
|
-
}
|
|
117
|
-
return {
|
|
118
|
-
secret,
|
|
119
|
-
...(digits === undefined ? {} : { digits }),
|
|
120
|
-
...(periodSeconds === undefined ? {} : { periodSeconds }),
|
|
121
|
-
...(rawAlgorithm ? { algorithm: rawAlgorithm as "sha1" | "sha256" | "sha512" } : {}),
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
function optionalIntegerParameter(url: URL, name: string): number | undefined {
|
|
126
|
-
const value = url.searchParams.get(name);
|
|
127
|
-
if (value === null) return undefined;
|
|
128
|
-
if (!/^\d+$/u.test(value)) {
|
|
129
|
-
throw new BrowserAuthCredentialError(`TOTP ${name} is invalid`);
|
|
130
|
-
}
|
|
131
|
-
return Number(value);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
function decodeBase32(value: string): Buffer {
|
|
135
|
-
const normalized = value.toUpperCase().replace(/[\s=-]/gu, "");
|
|
136
|
-
if (!normalized || /[^A-Z2-7]/u.test(normalized)) {
|
|
137
|
-
throw new BrowserAuthCredentialError("TOTP secret is not valid Base32");
|
|
138
|
-
}
|
|
139
|
-
let accumulator = 0;
|
|
140
|
-
let bits = 0;
|
|
141
|
-
const bytes: number[] = [];
|
|
142
|
-
for (const character of normalized) {
|
|
143
|
-
const code = character.charCodeAt(0);
|
|
144
|
-
const digit = code >= 65 && code <= 90 ? code - 65 : code - 50 + 26;
|
|
145
|
-
accumulator = (accumulator << 5) | digit;
|
|
146
|
-
bits += 5;
|
|
147
|
-
if (bits >= 8) {
|
|
148
|
-
bits -= 8;
|
|
149
|
-
bytes.push((accumulator >>> bits) & 0xff);
|
|
150
|
-
accumulator &= (1 << bits) - 1;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
if (bytes.length === 0) throw new BrowserAuthCredentialError("TOTP secret is empty");
|
|
154
|
-
return Buffer.from(bytes);
|
|
155
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import type { AccessGrantAuthorization } from "@opengeni/core";
|
|
2
|
-
import type { UserResourceAuthoritySummary } from "@opengeni/db";
|
|
3
|
-
import {
|
|
4
|
-
IssueConnectionUseGrantRequest,
|
|
5
|
-
ListConnectionAuthoritiesResponse,
|
|
6
|
-
type IssueConnectionUseGrantRequest as IssueConnectionUseGrantRequestValue,
|
|
7
|
-
} from "@opengeni/contracts/connection-authority";
|
|
8
|
-
import { HTTPException } from "hono/http-exception";
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Personal connection authority is available only to the exact authenticated
|
|
12
|
-
* human. API keys, delegated bearers, services, and agent attempts cannot name
|
|
13
|
-
* or substitute a personal owner.
|
|
14
|
-
*/
|
|
15
|
-
export function requireConnectionAuthorityOwner(access: AccessGrantAuthorization): string {
|
|
16
|
-
if (
|
|
17
|
-
!access.contextIntegrity ||
|
|
18
|
-
access.authenticatedSubjectId !== access.grant.subjectId ||
|
|
19
|
-
access.grant.principalKind !== "human_session" ||
|
|
20
|
-
access.grant.serviceInitiator ||
|
|
21
|
-
access.grant.serviceInitiatorContext ||
|
|
22
|
-
access.grant.subjectId.startsWith("api_key:")
|
|
23
|
-
) {
|
|
24
|
-
throw new HTTPException(403, { message: "authenticated connection owner required" });
|
|
25
|
-
}
|
|
26
|
-
return access.grant.subjectId;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/** Removes generic resource kind and refuses non-connection grant actions. */
|
|
30
|
-
export function projectSelfConnectionAuthorities(page: {
|
|
31
|
-
authorities: UserResourceAuthoritySummary[];
|
|
32
|
-
nextCursor: string | null;
|
|
33
|
-
}) {
|
|
34
|
-
return ListConnectionAuthoritiesResponse.parse({
|
|
35
|
-
scope: "user",
|
|
36
|
-
authorities: page.authorities
|
|
37
|
-
.filter((authority) => authority.resourceKind === "connection")
|
|
38
|
-
.map(({ resourceKind: _resourceKind, ...authority }) => authority),
|
|
39
|
-
nextCursor: page.nextCursor,
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/** The API owns the action; callers supply neither action nor owner identity. */
|
|
44
|
-
export function connectionUseGrantLifecycleInput(input: unknown): {
|
|
45
|
-
action: "connection.use";
|
|
46
|
-
mode: IssueConnectionUseGrantRequestValue["mode"];
|
|
47
|
-
context: IssueConnectionUseGrantRequestValue["context"];
|
|
48
|
-
sessionId: string | null;
|
|
49
|
-
expectedAuthorityEpoch: number | null;
|
|
50
|
-
workspaceSharedAcknowledged: boolean;
|
|
51
|
-
} {
|
|
52
|
-
const request = IssueConnectionUseGrantRequest.parse(input);
|
|
53
|
-
return {
|
|
54
|
-
action: "connection.use",
|
|
55
|
-
mode: request.mode,
|
|
56
|
-
context: request.context,
|
|
57
|
-
sessionId: request.sessionId ?? null,
|
|
58
|
-
expectedAuthorityEpoch: request.expectedAuthorityEpoch ?? null,
|
|
59
|
-
workspaceSharedAcknowledged: request.workspaceSharedAcknowledged,
|
|
60
|
-
};
|
|
61
|
-
}
|