@segmentstream/ontology 0.0.0-stage → 0.92.1
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/LICENSE +201 -0
- package/NOTICE +2 -0
- package/README.md +1655 -2
- package/dist/action.d.ts +193 -0
- package/dist/action.js +41 -0
- package/dist/agent-chat.d.ts +44 -0
- package/dist/agent-chat.js +91 -0
- package/dist/agent-task-contract.d.ts +64 -0
- package/dist/agent-task-contract.js +15 -0
- package/dist/agent-task.d.ts +39 -0
- package/dist/agent-task.js +112 -0
- package/dist/analyze.d.ts +215 -0
- package/dist/analyze.js +2438 -0
- package/dist/app-feedback.d.ts +167 -0
- package/dist/app-feedback.js +176 -0
- package/dist/authoring-input.d.ts +3 -0
- package/dist/authoring-input.js +107 -0
- package/dist/authoring-names.d.ts +4 -0
- package/dist/authoring-names.js +13 -0
- package/dist/authoring-records.d.ts +35 -0
- package/dist/authoring-records.js +264 -0
- package/dist/authoring.d.ts +15 -0
- package/dist/authoring.js +331 -0
- package/dist/bin/check.d.ts +30 -0
- package/dist/bin/check.js +99 -0
- package/dist/bin/load.d.ts +48 -0
- package/dist/bin/load.js +139 -0
- package/dist/bin/main.d.ts +31 -0
- package/dist/bin/main.js +121 -0
- package/dist/bin/migrate.d.ts +57 -0
- package/dist/bin/migrate.js +170 -0
- package/dist/bin/output.d.ts +31 -0
- package/dist/bin/output.js +84 -0
- package/dist/bin.d.ts +2 -0
- package/dist/bin.js +31 -0
- package/dist/blob.d.ts +52 -0
- package/dist/blob.js +87 -0
- package/dist/channel-session.d.ts +16 -0
- package/dist/channel-session.js +16 -0
- package/dist/chat.d.ts +43 -0
- package/dist/chat.js +34 -0
- package/dist/confirmation.d.ts +46 -0
- package/dist/confirmation.js +41 -0
- package/dist/connection.d.ts +213 -0
- package/dist/connection.js +289 -0
- package/dist/deployment.d.ts +35 -0
- package/dist/deployment.js +76 -0
- package/dist/diagnostics.d.ts +27 -0
- package/dist/diagnostics.js +106 -0
- package/dist/emails.d.ts +70 -0
- package/dist/emails.js +221 -0
- package/dist/entity.d.ts +331 -0
- package/dist/entity.js +153 -0
- package/dist/errors.d.ts +154 -0
- package/dist/errors.js +109 -0
- package/dist/feedback-config.d.ts +24 -0
- package/dist/feedback-config.js +126 -0
- package/dist/files.d.ts +39 -0
- package/dist/files.js +4 -0
- package/dist/groups.d.ts +95 -0
- package/dist/groups.js +280 -0
- package/dist/index.d.ts +109 -0
- package/dist/index.js +70 -0
- package/dist/internal/diagnostics.js +594 -0
- package/dist/legacy.d.ts +160 -0
- package/dist/legacy.js +270 -0
- package/dist/manifest-compatibility.d.ts +8 -0
- package/dist/manifest-compatibility.js +87 -0
- package/dist/manifest.d.ts +3329 -0
- package/dist/manifest.js +757 -0
- package/dist/me.d.ts +46 -0
- package/dist/me.js +109 -0
- package/dist/metric-filters.d.ts +48 -0
- package/dist/metric-filters.js +252 -0
- package/dist/metric-routes.d.ts +132 -0
- package/dist/metric-routes.js +498 -0
- package/dist/metric.d.ts +172 -0
- package/dist/metric.js +132 -0
- package/dist/migrate/apply.d.ts +94 -0
- package/dist/migrate/apply.js +526 -0
- package/dist/migrate/errors.d.ts +46 -0
- package/dist/migrate/errors.js +38 -0
- package/dist/migrate/index.d.ts +10 -0
- package/dist/migrate/index.js +7 -0
- package/dist/migrate/model.d.ts +2311 -0
- package/dist/migrate/model.js +148 -0
- package/dist/migrate/plan.d.ts +51 -0
- package/dist/migrate/plan.js +1856 -0
- package/dist/migrate/preview.d.ts +13 -0
- package/dist/migrate/preview.js +65 -0
- package/dist/migrate/storage.d.ts +226 -0
- package/dist/migrate/storage.js +774 -0
- package/dist/model-metrics.d.ts +22 -0
- package/dist/model-metrics.js +545 -0
- package/dist/names.d.ts +49 -0
- package/dist/names.js +110 -0
- package/dist/navigation-artifact.d.ts +13 -0
- package/dist/navigation-artifact.js +11 -0
- package/dist/navigation-catalog.d.ts +55 -0
- package/dist/navigation-catalog.js +297 -0
- package/dist/nitro-navigation.d.ts +3 -0
- package/dist/nitro-navigation.js +64 -0
- package/dist/nitro-workflows.d.ts +108 -0
- package/dist/nitro-workflows.js +286 -0
- package/dist/nitro.d.ts +40 -0
- package/dist/nitro.js +50 -0
- package/dist/ontology.d.ts +41 -0
- package/dist/ontology.js +46 -0
- package/dist/permissions.d.ts +198 -0
- package/dist/permissions.js +272 -0
- package/dist/property.d.ts +188 -0
- package/dist/property.js +301 -0
- package/dist/query.d.ts +245 -0
- package/dist/query.js +615 -0
- package/dist/relationship.d.ts +99 -0
- package/dist/relationship.js +33 -0
- package/dist/render.d.ts +81 -0
- package/dist/render.js +512 -0
- package/dist/replication/baseline.d.ts +51 -0
- package/dist/replication/baseline.js +215 -0
- package/dist/replication/bigquery.d.ts +37 -0
- package/dist/replication/bigquery.js +211 -0
- package/dist/replication/coverage.d.ts +14 -0
- package/dist/replication/coverage.js +53 -0
- package/dist/replication/evolution.d.ts +25 -0
- package/dist/replication/evolution.js +184 -0
- package/dist/replication/identities.d.ts +6 -0
- package/dist/replication/identities.js +47 -0
- package/dist/replication/legacy-baseline.d.ts +27 -0
- package/dist/replication/legacy-baseline.js +109 -0
- package/dist/replication/legacy-store.d.ts +19 -0
- package/dist/replication/legacy-store.js +63 -0
- package/dist/replication/lineage.d.ts +36 -0
- package/dist/replication/lineage.js +72 -0
- package/dist/replication/migrate.d.ts +21 -0
- package/dist/replication/migrate.js +84 -0
- package/dist/replication/model.d.ts +52 -0
- package/dist/replication/model.js +99 -0
- package/dist/replication/scans.d.ts +34 -0
- package/dist/replication/scans.js +158 -0
- package/dist/replication/schema.d.ts +11 -0
- package/dist/replication/schema.js +226 -0
- package/dist/replication/shadow-schema.d.ts +4 -0
- package/dist/replication/shadow-schema.js +61 -0
- package/dist/replication/shadow.d.ts +127 -0
- package/dist/replication/shadow.js +614 -0
- package/dist/replication/source-replacement.d.ts +33 -0
- package/dist/replication/source-replacement.js +76 -0
- package/dist/replication/store.d.ts +36 -0
- package/dist/replication/store.js +382 -0
- package/dist/replication/transaction.d.ts +23 -0
- package/dist/replication/transaction.js +88 -0
- package/dist/role.d.ts +61 -0
- package/dist/role.js +76 -0
- package/dist/runtime/action-deadlocks.d.ts +21 -0
- package/dist/runtime/action-deadlocks.js +130 -0
- package/dist/runtime/action-transactions.d.ts +35 -0
- package/dist/runtime/action-transactions.js +54 -0
- package/dist/runtime/agent-counters.d.ts +26 -0
- package/dist/runtime/agent-counters.js +98 -0
- package/dist/runtime/agent-tasks.d.ts +63 -0
- package/dist/runtime/agent-tasks.js +120 -0
- package/dist/runtime/agents.d.ts +15 -0
- package/dist/runtime/agents.js +457 -0
- package/dist/runtime/batch-diagnostics.d.ts +22 -0
- package/dist/runtime/batch-diagnostics.js +89 -0
- package/dist/runtime/batch.d.ts +52 -0
- package/dist/runtime/batch.js +534 -0
- package/dist/runtime/channel-session-revocation.d.ts +3 -0
- package/dist/runtime/channel-session-revocation.js +5 -0
- package/dist/runtime/channel-sessions.d.ts +4 -0
- package/dist/runtime/channel-sessions.js +61 -0
- package/dist/runtime/confirmations.d.ts +29 -0
- package/dist/runtime/confirmations.js +57 -0
- package/dist/runtime/cursor.d.ts +23 -0
- package/dist/runtime/cursor.js +100 -0
- package/dist/runtime/deployment.d.ts +7 -0
- package/dist/runtime/deployment.js +4 -0
- package/dist/runtime/errors.d.ts +118 -0
- package/dist/runtime/errors.js +109 -0
- package/dist/runtime/federation-tables.d.ts +2 -0
- package/dist/runtime/federation-tables.js +20 -0
- package/dist/runtime/federation.d.ts +42 -0
- package/dist/runtime/federation.js +222 -0
- package/dist/runtime/files.d.ts +39 -0
- package/dist/runtime/files.js +44 -0
- package/dist/runtime/generated-actions.d.ts +37 -0
- package/dist/runtime/generated-actions.js +307 -0
- package/dist/runtime/history.d.ts +91 -0
- package/dist/runtime/history.js +77 -0
- package/dist/runtime/ids.d.ts +6 -0
- package/dist/runtime/ids.js +39 -0
- package/dist/runtime/member-tables.d.ts +8 -0
- package/dist/runtime/member-tables.js +33 -0
- package/dist/runtime/member-writes.d.ts +78 -0
- package/dist/runtime/member-writes.js +202 -0
- package/dist/runtime/metric-query.d.ts +19 -0
- package/dist/runtime/metric-query.js +411 -0
- package/dist/runtime/model.d.ts +67 -0
- package/dist/runtime/model.js +150 -0
- package/dist/runtime/new-user-hook.d.ts +6 -0
- package/dist/runtime/new-user-hook.js +37 -0
- package/dist/runtime/oauth.d.ts +9 -0
- package/dist/runtime/oauth.js +299 -0
- package/dist/runtime/pipeline.d.ts +155 -0
- package/dist/runtime/pipeline.js +597 -0
- package/dist/runtime/postgres-tls.d.ts +10 -0
- package/dist/runtime/postgres-tls.js +14 -0
- package/dist/runtime/principals.d.ts +302 -0
- package/dist/runtime/principals.js +1307 -0
- package/dist/runtime/reads.d.ts +55 -0
- package/dist/runtime/reads.js +313 -0
- package/dist/runtime/records.d.ts +42 -0
- package/dist/runtime/records.js +245 -0
- package/dist/runtime/resolve-agent-identity.d.ts +6 -0
- package/dist/runtime/resolve-agent-identity.js +181 -0
- package/dist/runtime/service-binding.d.ts +18 -0
- package/dist/runtime/service-binding.js +266 -0
- package/dist/runtime/sign-in-links.d.ts +68 -0
- package/dist/runtime/sign-in-links.js +147 -0
- package/dist/runtime/sql-runtime.d.ts +131 -0
- package/dist/runtime/sql-runtime.js +362 -0
- package/dist/runtime/statement.d.ts +18 -0
- package/dist/runtime/statement.js +31 -0
- package/dist/runtime/user-identities.d.ts +66 -0
- package/dist/runtime/user-identities.js +106 -0
- package/dist/runtime/user-identity-sql.d.ts +86 -0
- package/dist/runtime/user-identity-sql.js +297 -0
- package/dist/runtime/user-roles.d.ts +16 -0
- package/dist/runtime/user-roles.js +32 -0
- package/dist/runtime/validation.d.ts +16 -0
- package/dist/runtime/validation.js +26 -0
- package/dist/runtime/where.d.ts +57 -0
- package/dist/runtime/where.js +404 -0
- package/dist/runtime/workflow-admission.d.ts +49 -0
- package/dist/runtime/workflow-admission.js +92 -0
- package/dist/runtime/workflow-argument-codec.d.ts +10 -0
- package/dist/runtime/workflow-argument-codec.js +120 -0
- package/dist/runtime/workflow-arguments.d.ts +17 -0
- package/dist/runtime/workflow-arguments.js +99 -0
- package/dist/runtime/workflow-starts.d.ts +203 -0
- package/dist/runtime/workflow-starts.js +493 -0
- package/dist/runtime/workflow-users.d.ts +9 -0
- package/dist/runtime/workflow-users.js +17 -0
- package/dist/runtime/workload.d.ts +25 -0
- package/dist/runtime/workload.js +24 -0
- package/dist/runtime/writes.d.ts +108 -0
- package/dist/runtime/writes.js +491 -0
- package/dist/runtime-source.d.ts +22 -0
- package/dist/runtime-source.js +28 -0
- package/dist/runtime.d.ts +310 -0
- package/dist/runtime.js +31 -0
- package/dist/server.d.ts +23 -0
- package/dist/server.js +107 -0
- package/dist/service/agent/attachments.d.ts +33 -0
- package/dist/service/agent/attachments.js +228 -0
- package/dist/service/agent/authentication.d.ts +22 -0
- package/dist/service/agent/authentication.js +58 -0
- package/dist/service/agent/confirmations.d.ts +5 -0
- package/dist/service/agent/confirmations.js +73 -0
- package/dist/service/agent/conversation-routes.d.ts +14 -0
- package/dist/service/agent/conversation-routes.js +45 -0
- package/dist/service/agent/conversations.d.ts +40 -0
- package/dist/service/agent/conversations.js +69 -0
- package/dist/service/agent/files.d.ts +12 -0
- package/dist/service/agent/files.js +69 -0
- package/dist/service/agent/protocol.d.ts +90 -0
- package/dist/service/agent/protocol.js +114 -0
- package/dist/service/agent/server.d.ts +28 -0
- package/dist/service/agent/server.js +374 -0
- package/dist/service/agent/task-caller.d.ts +21 -0
- package/dist/service/agent/task-caller.js +35 -0
- package/dist/service/agent/task-start.d.ts +53 -0
- package/dist/service/agent/task-start.js +161 -0
- package/dist/service/agent/tasks.d.ts +40 -0
- package/dist/service/agent/tasks.js +155 -0
- package/dist/service/api.d.ts +50 -0
- package/dist/service/api.js +288 -0
- package/dist/service/authentication.d.ts +227 -0
- package/dist/service/authentication.js +767 -0
- package/dist/service/caller-context.d.ts +24 -0
- package/dist/service/caller-context.js +6 -0
- package/dist/service/catalog.d.ts +42 -0
- package/dist/service/catalog.js +66 -0
- package/dist/service/channel/provider.d.ts +10 -0
- package/dist/service/channel/provider.js +1 -0
- package/dist/service/channel/providers/telegram.d.ts +18 -0
- package/dist/service/channel/providers/telegram.js +108 -0
- package/dist/service/channel/sessions.d.ts +5 -0
- package/dist/service/channel/sessions.js +53 -0
- package/dist/service/channel/sign-in.d.ts +7 -0
- package/dist/service/channel/sign-in.js +78 -0
- package/dist/service/chat/archive.d.ts +64 -0
- package/dist/service/chat/archive.js +62 -0
- package/dist/service/chat/attribution.d.ts +26 -0
- package/dist/service/chat/attribution.js +28 -0
- package/dist/service/chat/delivery.d.ts +18 -0
- package/dist/service/chat/delivery.js +251 -0
- package/dist/service/chat/diagnostics.d.ts +2 -0
- package/dist/service/chat/diagnostics.js +35 -0
- package/dist/service/chat/envelope.d.ts +96 -0
- package/dist/service/chat/envelope.js +39 -0
- package/dist/service/chat/idempotency.d.ts +19 -0
- package/dist/service/chat/idempotency.js +37 -0
- package/dist/service/chat/providers/telegram.d.ts +36 -0
- package/dist/service/chat/providers/telegram.js +133 -0
- package/dist/service/chat/reads.d.ts +25 -0
- package/dist/service/chat/reads.js +75 -0
- package/dist/service/chat/resolve.d.ts +34 -0
- package/dist/service/chat/resolve.js +150 -0
- package/dist/service/chat/routes.d.ts +23 -0
- package/dist/service/chat/routes.js +75 -0
- package/dist/service/chat/schemas.d.ts +43 -0
- package/dist/service/chat/schemas.js +31 -0
- package/dist/service/config.d.ts +218 -0
- package/dist/service/config.js +265 -0
- package/dist/service/connection-stream.d.ts +10 -0
- package/dist/service/connection-stream.js +191 -0
- package/dist/service/connections.d.ts +60 -0
- package/dist/service/connections.js +271 -0
- package/dist/service/decisions.d.ts +35 -0
- package/dist/service/decisions.js +63 -0
- package/dist/service/descriptions.d.ts +8 -0
- package/dist/service/descriptions.js +20 -0
- package/dist/service/discovery-schemas.d.ts +92 -0
- package/dist/service/discovery-schemas.js +59 -0
- package/dist/service/discovery-search.d.ts +30 -0
- package/dist/service/discovery-search.js +95 -0
- package/dist/service/discovery.d.ts +37 -0
- package/dist/service/discovery.js +436 -0
- package/dist/service/docs.d.ts +9 -0
- package/dist/service/docs.js +197 -0
- package/dist/service/errors.d.ts +145 -0
- package/dist/service/errors.js +704 -0
- package/dist/service/federation-provider.d.ts +36 -0
- package/dist/service/federation-provider.js +110 -0
- package/dist/service/federation-server.d.ts +20 -0
- package/dist/service/federation-server.js +249 -0
- package/dist/service/federation-status.d.ts +40 -0
- package/dist/service/federation-status.js +151 -0
- package/dist/service/handlers.d.ts +18 -0
- package/dist/service/handlers.js +287 -0
- package/dist/service/mcp/confirmation.d.ts +68 -0
- package/dist/service/mcp/confirmation.js +178 -0
- package/dist/service/mcp/find-input.d.ts +12 -0
- package/dist/service/mcp/find-input.js +122 -0
- package/dist/service/mcp/input-schema.d.ts +6 -0
- package/dist/service/mcp/input-schema.js +126 -0
- package/dist/service/mcp/listing.d.ts +26 -0
- package/dist/service/mcp/listing.js +92 -0
- package/dist/service/mcp/metric-tools.d.ts +85 -0
- package/dist/service/mcp/metric-tools.js +258 -0
- package/dist/service/mcp/request-log.d.ts +5 -0
- package/dist/service/mcp/request-log.js +53 -0
- package/dist/service/mcp/runtime-policy.d.ts +27 -0
- package/dist/service/mcp/runtime-policy.js +62 -0
- package/dist/service/mcp/server.d.ts +52 -0
- package/dist/service/mcp/server.js +861 -0
- package/dist/service/mcp/tools.d.ts +99 -0
- package/dist/service/mcp/tools.js +938 -0
- package/dist/service/member-file-routes.d.ts +22 -0
- package/dist/service/member-file-routes.js +52 -0
- package/dist/service/member-files.d.ts +245 -0
- package/dist/service/member-files.js +258 -0
- package/dist/service/metric-query-platform.d.ts +77 -0
- package/dist/service/metric-query-platform.js +198 -0
- package/dist/service/metric-query-scopes.d.ts +43 -0
- package/dist/service/metric-query-scopes.js +147 -0
- package/dist/service/metric-query.d.ts +48 -0
- package/dist/service/metric-query.js +200 -0
- package/dist/service/name-suggestions.d.ts +3 -0
- package/dist/service/name-suggestions.js +38 -0
- package/dist/service/navigation-schemas.d.ts +80 -0
- package/dist/service/navigation-schemas.js +49 -0
- package/dist/service/navigation.d.ts +20 -0
- package/dist/service/navigation.js +165 -0
- package/dist/service/oauth/protocol.d.ts +70 -0
- package/dist/service/oauth/protocol.js +157 -0
- package/dist/service/oauth/refresh-replay.d.ts +2 -0
- package/dist/service/oauth/refresh-replay.js +20 -0
- package/dist/service/oauth/server.d.ts +28 -0
- package/dist/service/oauth/server.js +769 -0
- package/dist/service/operations.d.ts +170 -0
- package/dist/service/operations.js +392 -0
- package/dist/service/plan.d.ts +57 -0
- package/dist/service/plan.js +96 -0
- package/dist/service/rate-limit.d.ts +22 -0
- package/dist/service/rate-limit.js +52 -0
- package/dist/service/record-reads.d.ts +21 -0
- package/dist/service/record-reads.js +155 -0
- package/dist/service/replication.d.ts +5 -0
- package/dist/service/replication.js +39 -0
- package/dist/service/runtime-contract.d.ts +508 -0
- package/dist/service/runtime-contract.js +18 -0
- package/dist/service/runtime-identity.d.ts +71 -0
- package/dist/service/runtime-identity.js +122 -0
- package/dist/service/schemas.d.ts +961 -0
- package/dist/service/schemas.js +639 -0
- package/dist/service/service.d.ts +21 -0
- package/dist/service/service.js +526 -0
- package/dist/service/warehouse-platform.d.ts +17 -0
- package/dist/service/warehouse-platform.js +122 -0
- package/dist/service/warehouse-query.d.ts +24 -0
- package/dist/service/warehouse-query.js +280 -0
- package/dist/service/webhooks.d.ts +106 -0
- package/dist/service/webhooks.js +233 -0
- package/dist/service/workflow-admission-provider.d.ts +31 -0
- package/dist/service/workflow-admission-provider.js +205 -0
- package/dist/service/workflow-argument-serialization.d.ts +2 -0
- package/dist/service/workflow-argument-serialization.js +14 -0
- package/dist/service/workflow-callback.d.ts +22 -0
- package/dist/service/workflow-callback.js +75 -0
- package/dist/service/workflow-deployment.d.ts +8 -0
- package/dist/service/workflow-deployment.js +131 -0
- package/dist/service/workflow-diagnostics.d.ts +23 -0
- package/dist/service/workflow-diagnostics.js +263 -0
- package/dist/service/workflow-errors.d.ts +26 -0
- package/dist/service/workflow-errors.js +181 -0
- package/dist/service/workflow-logging.d.ts +2 -0
- package/dist/service/workflow-logging.js +50 -0
- package/dist/service/workflow-queue-fence.d.ts +6 -0
- package/dist/service/workflow-queue-fence.js +66 -0
- package/dist/service/workflows.d.ts +200 -0
- package/dist/service/workflows.js +1549 -0
- package/dist/sign-in.d.ts +58 -0
- package/dist/sign-in.js +57 -0
- package/dist/source.d.ts +30 -0
- package/dist/source.js +107 -0
- package/dist/start-recovery-contract.d.ts +49 -0
- package/dist/start-recovery-contract.js +26 -0
- package/dist/start-recovery.d.ts +27 -0
- package/dist/start-recovery.js +81 -0
- package/dist/storage/api.d.ts +4 -0
- package/dist/storage/api.js +40 -0
- package/dist/storage/attachments.d.ts +146 -0
- package/dist/storage/attachments.js +733 -0
- package/dist/storage/authorization.d.ts +38 -0
- package/dist/storage/authorization.js +83 -0
- package/dist/storage/file-access.d.ts +17 -0
- package/dist/storage/file-access.js +8 -0
- package/dist/storage/limits.d.ts +12 -0
- package/dist/storage/limits.js +17 -0
- package/dist/storage/maintenance-auth.d.ts +20 -0
- package/dist/storage/maintenance-auth.js +24 -0
- package/dist/storage/maintenance.d.ts +11 -0
- package/dist/storage/maintenance.js +67 -0
- package/dist/storage/neon.d.ts +4 -0
- package/dist/storage/neon.js +318 -0
- package/dist/storage/operator.d.ts +11 -0
- package/dist/storage/operator.js +30 -0
- package/dist/storage/provider.d.ts +93 -0
- package/dist/storage/provider.js +36 -0
- package/dist/storage/sessions.d.ts +184 -0
- package/dist/storage/sessions.js +688 -0
- package/dist/storage/tables.d.ts +54 -0
- package/dist/storage/tables.js +205 -0
- package/dist/storage/transfers.d.ts +16 -0
- package/dist/storage/transfers.js +153 -0
- package/dist/storage/writes.d.ts +7 -0
- package/dist/storage/writes.js +88 -0
- package/dist/telegram.d.ts +35 -0
- package/dist/telegram.js +173 -0
- package/dist/user-identity.d.ts +28 -0
- package/dist/user-identity.js +106 -0
- package/dist/user.d.ts +75 -0
- package/dist/user.js +111 -0
- package/dist/warehouse-backed.d.ts +6 -0
- package/dist/warehouse-backed.js +495 -0
- package/dist/webhook-token.d.ts +11 -0
- package/dist/webhook-token.js +18 -0
- package/dist/webhooks.d.ts +40 -0
- package/dist/webhooks.js +55 -0
- package/dist/wire.d.ts +10 -0
- package/dist/wire.js +35 -0
- package/dist/workflow-runtime.d.ts +116 -0
- package/dist/workflow-runtime.js +109 -0
- package/dist/workflow-topics.d.ts +28 -0
- package/dist/workflow-topics.js +28 -0
- package/dist/workflow.d.ts +284 -0
- package/dist/workflow.js +259 -0
- package/dist/workflows.d.ts +24 -0
- package/dist/workflows.js +18 -0
- package/package.json +127 -4
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import { captureRuntimeFailure } from "../internal/diagnostics.js";
|
|
2
|
+
/** The largest page accepted by the Vercel world. */
|
|
3
|
+
export const WORLD_PAGE_SIZE = 100;
|
|
4
|
+
export const MAX_LISTED_WORKFLOW_EVENTS = 10_000;
|
|
5
|
+
// Correlation queries may return empty filtered pages. Bound reads as well as returned events.
|
|
6
|
+
const MAX_DIAGNOSTIC_PAGES = Math.ceil(MAX_LISTED_WORKFLOW_EVENTS / WORLD_PAGE_SIZE) + WORLD_PAGE_SIZE + 1;
|
|
7
|
+
function record(value) {
|
|
8
|
+
return value !== null && typeof value === "object"
|
|
9
|
+
? value
|
|
10
|
+
: undefined;
|
|
11
|
+
}
|
|
12
|
+
/** Current errors are bytes; spec-version 1 stored flattened devalue arrays. */
|
|
13
|
+
export function isSerializedWorkflowError(value) {
|
|
14
|
+
return value instanceof Uint8Array || Array.isArray(value);
|
|
15
|
+
}
|
|
16
|
+
/** Lazy world-vercel errorRef descriptors are opaque, never public error objects. */
|
|
17
|
+
export function hasWorkflowError(value) {
|
|
18
|
+
const item = record(value);
|
|
19
|
+
return (!isSerializedWorkflowError(value) &&
|
|
20
|
+
item !== undefined &&
|
|
21
|
+
item.code !== "workflow_error_unavailable" &&
|
|
22
|
+
(typeof item.name === "string" ||
|
|
23
|
+
typeof item._tag === "string" ||
|
|
24
|
+
typeof item.code === "string"));
|
|
25
|
+
}
|
|
26
|
+
function unavailable(reference) {
|
|
27
|
+
return {
|
|
28
|
+
code: "workflow_error_unavailable",
|
|
29
|
+
...(reference === undefined ? {} : { reference }),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function report(error, runId, operation) {
|
|
33
|
+
return captureRuntimeFailure(error, {
|
|
34
|
+
service: "ontology",
|
|
35
|
+
boundary: "ontology.workflow.diagnostics.failed",
|
|
36
|
+
workflowRunId: runId,
|
|
37
|
+
operation,
|
|
38
|
+
}).errorId;
|
|
39
|
+
}
|
|
40
|
+
/** Resolve only an error, retaining readable metadata when decryption/provider access fails. */
|
|
41
|
+
export async function hydrateWorkflowError(value, run, kind, hydrate) {
|
|
42
|
+
if (value === undefined || value === null || hasWorkflowError(value)) {
|
|
43
|
+
return value;
|
|
44
|
+
}
|
|
45
|
+
if (!isSerializedWorkflowError(value)) {
|
|
46
|
+
return unavailable();
|
|
47
|
+
}
|
|
48
|
+
try {
|
|
49
|
+
// @legacy ontology.workflow-run-legacy-encodings
|
|
50
|
+
// Numeric JSON byte arrays are distinct from legacy flattened devalue arrays.
|
|
51
|
+
const bytes = Array.isArray(value) &&
|
|
52
|
+
value.every((byte) => Number.isInteger(byte) && byte >= 0 && byte <= 255) &&
|
|
53
|
+
["devl", "encr", "gzip", "zstd"].includes(String.fromCharCode(...value.slice(0, 4)))
|
|
54
|
+
? new Uint8Array(value)
|
|
55
|
+
: value;
|
|
56
|
+
const result = await hydrate(bytes, run, kind);
|
|
57
|
+
return hasWorkflowError(result) ? result : unavailable();
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
return unavailable(report(error, run.runId, `hydrate_${kind}_error`));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
export async function hydrateWorkflowStepPage(world, runId, page, hydrate) {
|
|
64
|
+
let run = { runId };
|
|
65
|
+
if (page.data.some((step) => isSerializedWorkflowError(step.error))) {
|
|
66
|
+
try {
|
|
67
|
+
run = await world.runs.get(runId, { resolveData: "none" });
|
|
68
|
+
}
|
|
69
|
+
catch (cause) {
|
|
70
|
+
const reference = report(cause, runId, "read_error_encryption_context");
|
|
71
|
+
// Without the creating deployment, a runtime could derive the current deployment's key.
|
|
72
|
+
// Keep every step's status and any already-readable error, and leave encrypted data alone.
|
|
73
|
+
return {
|
|
74
|
+
...page,
|
|
75
|
+
data: page.data.map((step) => ({
|
|
76
|
+
...step,
|
|
77
|
+
error: hasWorkflowError(step.error)
|
|
78
|
+
? step.error
|
|
79
|
+
: step.error == null
|
|
80
|
+
? step.error
|
|
81
|
+
: unavailable(reference),
|
|
82
|
+
})),
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
...page,
|
|
88
|
+
data: await Promise.all(page.data.map(async (step) => ({
|
|
89
|
+
...step,
|
|
90
|
+
error: await hydrateWorkflowError(step.error, run, "step", hydrate),
|
|
91
|
+
}))),
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Events are the attempt source of truth. Lazy references are resolved by reading ONLY failure
|
|
96
|
+
* events with resolveData:all: run_created/step_created/completed payloads are never hydrated.
|
|
97
|
+
* Each scan keeps partial results when a later page or individual error cannot be read.
|
|
98
|
+
*/
|
|
99
|
+
export async function readWorkflowDiagnostics(world, run, steps, hydrate) {
|
|
100
|
+
const attempts = new Map();
|
|
101
|
+
let error = await hydrateWorkflowError(run.error, run, "run", hydrate);
|
|
102
|
+
let truncated = false;
|
|
103
|
+
let count = 0;
|
|
104
|
+
let pages = 0;
|
|
105
|
+
const events = world.events;
|
|
106
|
+
if (events === undefined) {
|
|
107
|
+
return {
|
|
108
|
+
error: error ?? (run.status === "failed" ? unavailable() : error),
|
|
109
|
+
attempts,
|
|
110
|
+
truncated: true,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
const failure = async (event, kind) => {
|
|
114
|
+
try {
|
|
115
|
+
// In lazy mode error can be a descriptor (or absent in world-local). Read the failure event
|
|
116
|
+
// through the provider, rather than guessing ref URLs or resolving a run's entire I/O.
|
|
117
|
+
const stored = event.eventData?.error;
|
|
118
|
+
const value = isSerializedWorkflowError(stored) || hasWorkflowError(stored)
|
|
119
|
+
? stored
|
|
120
|
+
: (await events.get(run.runId, event.eventId, { resolveData: "all" })).eventData?.error;
|
|
121
|
+
const result = await hydrateWorkflowError(value, run, kind, hydrate);
|
|
122
|
+
if (!hasWorkflowError(result)) {
|
|
123
|
+
truncated = true;
|
|
124
|
+
}
|
|
125
|
+
return result ?? unavailable();
|
|
126
|
+
}
|
|
127
|
+
catch (cause) {
|
|
128
|
+
truncated = true;
|
|
129
|
+
return unavailable(report(cause, run.runId, `read_${kind}_failure`));
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
const consume = async (event) => {
|
|
133
|
+
// Correlation IDs belong to a run. Defend against providers that ignore runId filtering.
|
|
134
|
+
if (event.runId !== undefined && event.runId !== run.runId) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
if (event.eventType === "run_failed" && !hasWorkflowError(error)) {
|
|
138
|
+
const resolved = await failure(event, "run");
|
|
139
|
+
if (hasWorkflowError(resolved) || !hasWorkflowError(error)) {
|
|
140
|
+
error = resolved;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
const stepId = event.correlationId;
|
|
144
|
+
if (!stepId ||
|
|
145
|
+
!event.eventType.startsWith("step_") ||
|
|
146
|
+
(steps !== undefined && !steps.some((step) => step.stepId === stepId))) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
if (event.eventType === "step_created") {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
const history = attempts.get(stepId) ?? [];
|
|
153
|
+
const explicit = event.eventData?.attempt;
|
|
154
|
+
const number = typeof explicit === "number" && Number.isInteger(explicit) && explicit > 0
|
|
155
|
+
? explicit
|
|
156
|
+
: undefined;
|
|
157
|
+
attempts.set(stepId, history);
|
|
158
|
+
if (event.eventType === "step_started") {
|
|
159
|
+
history.push({
|
|
160
|
+
attempt: number ?? (history.at(-1)?.attempt ?? 0) + 1,
|
|
161
|
+
status: "running",
|
|
162
|
+
startedAt: event.createdAt,
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
else if (["step_failed", "step_retrying", "step_completed"].includes(event.eventType)) {
|
|
166
|
+
const last = history.at(-1);
|
|
167
|
+
if (last === undefined) {
|
|
168
|
+
truncated = true;
|
|
169
|
+
}
|
|
170
|
+
history[history.length === 0 ? 0 : history.length - 1] = {
|
|
171
|
+
...(last ?? {
|
|
172
|
+
attempt: number ?? steps?.find((step) => step.stepId === stepId)?.attempt ?? 1,
|
|
173
|
+
}),
|
|
174
|
+
status: event.eventType === "step_completed" ? "completed" : "failed",
|
|
175
|
+
completedAt: event.createdAt,
|
|
176
|
+
...(event.eventType === "step_completed" ? {} : { error: await failure(event, "step") }),
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
const scan = async (list, onlyRunFailure = false) => {
|
|
181
|
+
let cursor;
|
|
182
|
+
const seen = new Set();
|
|
183
|
+
try {
|
|
184
|
+
while (count < MAX_LISTED_WORKFLOW_EVENTS && pages < MAX_DIAGNOSTIC_PAGES) {
|
|
185
|
+
pages++;
|
|
186
|
+
const page = await list(cursor);
|
|
187
|
+
for (const event of page.data) {
|
|
188
|
+
if (count >= MAX_LISTED_WORKFLOW_EVENTS) {
|
|
189
|
+
truncated = true;
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
count++;
|
|
193
|
+
if (!onlyRunFailure || event.eventType === "run_failed") {
|
|
194
|
+
await consume(event);
|
|
195
|
+
}
|
|
196
|
+
if (onlyRunFailure && event.eventType === "run_failed") {
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
if (!page.hasMore) {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
if (page.cursor === null || seen.has(page.cursor)) {
|
|
204
|
+
truncated = true;
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
seen.add(page.cursor);
|
|
208
|
+
cursor = page.cursor;
|
|
209
|
+
}
|
|
210
|
+
truncated = true;
|
|
211
|
+
}
|
|
212
|
+
catch (cause) {
|
|
213
|
+
truncated = true;
|
|
214
|
+
report(cause, run.runId, "list_events");
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
// Retrieve the primary failure before a large attempt history can consume the read budget.
|
|
218
|
+
// Failed-run events are at the end of the log; this scan never reads step payloads.
|
|
219
|
+
if (run.status === "failed" && !hasWorkflowError(error)) {
|
|
220
|
+
await scan((cursor) => events.list({
|
|
221
|
+
runId: run.runId,
|
|
222
|
+
resolveData: "none",
|
|
223
|
+
pagination: {
|
|
224
|
+
limit: WORLD_PAGE_SIZE,
|
|
225
|
+
sortOrder: "desc",
|
|
226
|
+
...(cursor ? { cursor } : {}),
|
|
227
|
+
},
|
|
228
|
+
}), true);
|
|
229
|
+
}
|
|
230
|
+
if (steps !== undefined && events.listByCorrelationId !== undefined) {
|
|
231
|
+
for (let offset = 0; offset < steps.length; offset += 8) {
|
|
232
|
+
await Promise.all(steps.slice(offset, offset + 8).map((step) => scan((cursor) => events.listByCorrelationId({
|
|
233
|
+
runId: run.runId,
|
|
234
|
+
correlationId: step.stepId,
|
|
235
|
+
resolveData: "none",
|
|
236
|
+
pagination: {
|
|
237
|
+
limit: WORLD_PAGE_SIZE,
|
|
238
|
+
sortOrder: "asc",
|
|
239
|
+
...(cursor ? { cursor } : {}),
|
|
240
|
+
},
|
|
241
|
+
}))));
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
else {
|
|
245
|
+
await scan((cursor) => events.list({
|
|
246
|
+
runId: run.runId,
|
|
247
|
+
resolveData: "none",
|
|
248
|
+
pagination: { limit: WORLD_PAGE_SIZE, sortOrder: "asc", ...(cursor ? { cursor } : {}) },
|
|
249
|
+
}));
|
|
250
|
+
}
|
|
251
|
+
for (const step of steps ?? []) {
|
|
252
|
+
const history = attempts.get(step.stepId);
|
|
253
|
+
if ((step.attempt ?? 0) > (history?.length ?? 0) ||
|
|
254
|
+
(step.status === "failed" && history?.at(-1)?.status !== "failed")) {
|
|
255
|
+
truncated = true;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
if (run.status === "failed" && !hasWorkflowError(error)) {
|
|
259
|
+
truncated = true;
|
|
260
|
+
error ??= unavailable();
|
|
261
|
+
}
|
|
262
|
+
return { error, attempts, truncated };
|
|
263
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Cause } from "effect";
|
|
2
|
+
import type { WorkflowStepContext } from "../workflow-runtime.js";
|
|
3
|
+
/** Public diagnostics contain declared safe messages, never the operator report or inputs. */
|
|
4
|
+
export interface WorkflowErrorView {
|
|
5
|
+
readonly tag: string | null;
|
|
6
|
+
readonly message: string | null;
|
|
7
|
+
readonly code: string | null;
|
|
8
|
+
readonly reason?: string;
|
|
9
|
+
readonly requestId?: string;
|
|
10
|
+
readonly reference?: string;
|
|
11
|
+
readonly category?: "deployment_switching" | "deployment_interrupted";
|
|
12
|
+
readonly servedHash?: string;
|
|
13
|
+
readonly appliedHash?: string;
|
|
14
|
+
readonly servedDeploymentId?: string;
|
|
15
|
+
readonly appliedDeploymentId?: string;
|
|
16
|
+
readonly generation?: string;
|
|
17
|
+
}
|
|
18
|
+
/** The SDK preserves Error.cause; custom Error properties are otherwise discarded. */
|
|
19
|
+
export declare class WorkflowStepFailed extends Error {
|
|
20
|
+
readonly fatal: boolean;
|
|
21
|
+
readonly retryAfter?: Date;
|
|
22
|
+
constructor(name: string, message: string, fatal?: boolean, cause?: unknown, retryAfter?: Date);
|
|
23
|
+
}
|
|
24
|
+
export declare function stepFailure(cause: Cause.Cause<unknown>, requestId: string, step: WorkflowStepContext, workflow: string, credentials: readonly (string | undefined)[]): WorkflowStepFailed;
|
|
25
|
+
/** Find our envelope through retry-exhaustion/run wrappers, with bounded cycle-safe traversal. */
|
|
26
|
+
export declare function workflowErrorView(value: unknown): WorkflowErrorView | null;
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { Cause } from "effect";
|
|
2
|
+
import { captureRuntimeFailure, environmentSecrets, makeRedactor, } from "../internal/diagnostics.js";
|
|
3
|
+
const SAFE_FAILURES = new Set([
|
|
4
|
+
"TriggerInputInvalid",
|
|
5
|
+
"WorkflowRecoveryUnavailable",
|
|
6
|
+
"ActionRejected",
|
|
7
|
+
"PermissionDenied",
|
|
8
|
+
"ScopeViolated",
|
|
9
|
+
"Conflict",
|
|
10
|
+
"NotFound",
|
|
11
|
+
"ConnectionError",
|
|
12
|
+
"InvalidActionInput",
|
|
13
|
+
"AgentTaskUnanswered",
|
|
14
|
+
"AgentTaskRefused",
|
|
15
|
+
]);
|
|
16
|
+
const DEPLOYMENT_FAILURES = new Set(["DeploymentSwitching", "DeploymentInterrupted"]);
|
|
17
|
+
const DETERMINISTIC_FAILURES = new Set([
|
|
18
|
+
"TriggerInputInvalid",
|
|
19
|
+
"PermissionDenied",
|
|
20
|
+
"ScopeViolated",
|
|
21
|
+
"ActionRejected",
|
|
22
|
+
"InvalidActionInput",
|
|
23
|
+
"AgentTaskRefused",
|
|
24
|
+
"DeploymentInterrupted",
|
|
25
|
+
]);
|
|
26
|
+
const TAG = /^[A-Za-z][A-Za-z0-9_]{0,99}$/;
|
|
27
|
+
const ID = /^[A-Za-z0-9_.:-]{1,200}$/;
|
|
28
|
+
function record(value) {
|
|
29
|
+
return value !== null && typeof value === "object"
|
|
30
|
+
? value
|
|
31
|
+
: undefined;
|
|
32
|
+
}
|
|
33
|
+
/** The SDK preserves Error.cause; custom Error properties are otherwise discarded. */
|
|
34
|
+
export class WorkflowStepFailed extends Error {
|
|
35
|
+
fatal;
|
|
36
|
+
retryAfter;
|
|
37
|
+
constructor(name, message, fatal = false, cause, retryAfter) {
|
|
38
|
+
super(message, cause === undefined ? undefined : { cause });
|
|
39
|
+
this.name = name;
|
|
40
|
+
this.fatal = fatal;
|
|
41
|
+
if (retryAfter !== undefined) {
|
|
42
|
+
// The pinned Workflow SDK's RetryableError.is guard recognizes this name and Date field.
|
|
43
|
+
this.name = "RetryableError";
|
|
44
|
+
this.retryAfter = retryAfter;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
export function stepFailure(cause, requestId, step, workflow, credentials) {
|
|
49
|
+
const failure = record(Cause.squash(cause));
|
|
50
|
+
const tag = typeof failure?._tag === "string" && TAG.test(failure._tag)
|
|
51
|
+
? failure._tag
|
|
52
|
+
: "WorkflowStepFailed";
|
|
53
|
+
const redact = makeRedactor([...environmentSecrets(process.env), ...credentials]);
|
|
54
|
+
const report = captureRuntimeFailure(cause, {
|
|
55
|
+
service: "ontology",
|
|
56
|
+
boundary: "ontology.workflow.step.failed",
|
|
57
|
+
requestId,
|
|
58
|
+
workflowRunId: step.workflowRunId,
|
|
59
|
+
stepId: step.stepId,
|
|
60
|
+
stepAttempt: step.attempt,
|
|
61
|
+
workflow,
|
|
62
|
+
}, process.env, credentials);
|
|
63
|
+
const publicMessage = SAFE_FAILURES.has(tag) || tag === "SchemaError"
|
|
64
|
+
? report.nodes.find((node) => node.type === tag)?.message
|
|
65
|
+
: undefined;
|
|
66
|
+
const error = {
|
|
67
|
+
tag,
|
|
68
|
+
code: tag,
|
|
69
|
+
message: publicMessage === undefined ? null : redact(publicMessage),
|
|
70
|
+
reference: requestId,
|
|
71
|
+
...deploymentFields(tag, failure),
|
|
72
|
+
...(tag === "ConnectionError" && typeof failure?.reason === "string" && TAG.test(failure.reason)
|
|
73
|
+
? { reason: failure.reason }
|
|
74
|
+
: {}),
|
|
75
|
+
...(tag === "ConnectionError" &&
|
|
76
|
+
typeof failure?.requestId === "string" &&
|
|
77
|
+
ID.test(failure.requestId)
|
|
78
|
+
? { requestId: failure.requestId }
|
|
79
|
+
: {}),
|
|
80
|
+
};
|
|
81
|
+
const switching = tag === "DeploymentSwitching";
|
|
82
|
+
const delay = typeof failure?.retryAfter === "number" && Number.isFinite(failure.retryAfter)
|
|
83
|
+
? Math.max(1, failure.retryAfter)
|
|
84
|
+
: 5;
|
|
85
|
+
return new WorkflowStepFailed(tag, error.message ?? tag, DETERMINISTIC_FAILURES.has(tag), { _tag: "OntologyWorkflowFailure", version: 2, error, report }, switching
|
|
86
|
+
? new Date(Date.now() +
|
|
87
|
+
Math.min(60, delay * 2 ** Math.min(Math.max(step.attempt - 1, 0), 6)) * 1_000)
|
|
88
|
+
: undefined);
|
|
89
|
+
}
|
|
90
|
+
/** Deployment provenance is identifiers only; the operator journal retains the complete cause. */
|
|
91
|
+
function deploymentFields(tag, item) {
|
|
92
|
+
if (tag !== "DeploymentInterrupted" && tag !== "DeploymentSwitching") {
|
|
93
|
+
return {};
|
|
94
|
+
}
|
|
95
|
+
const fields = {
|
|
96
|
+
category: tag === "DeploymentInterrupted" ? "deployment_interrupted" : "deployment_switching",
|
|
97
|
+
};
|
|
98
|
+
for (const field of [
|
|
99
|
+
"servedHash",
|
|
100
|
+
"appliedHash",
|
|
101
|
+
"servedDeploymentId",
|
|
102
|
+
"appliedDeploymentId",
|
|
103
|
+
"generation",
|
|
104
|
+
]) {
|
|
105
|
+
const value = item?.[field];
|
|
106
|
+
if (typeof value === "string" && ID.test(value)) {
|
|
107
|
+
fields[field] = value;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return fields;
|
|
111
|
+
}
|
|
112
|
+
function publicError(item, tag) {
|
|
113
|
+
const redact = makeRedactor(environmentSecrets(process.env));
|
|
114
|
+
const code = typeof item.code === "string" && ID.test(item.code) ? item.code : tag;
|
|
115
|
+
const legacyMismatch = tag === "PermissionDenied" &&
|
|
116
|
+
(item.updating === true ||
|
|
117
|
+
item.message === "The deployed ontology no longer matches the database catalog.");
|
|
118
|
+
return {
|
|
119
|
+
tag,
|
|
120
|
+
code: code ?? "workflow_error_unavailable",
|
|
121
|
+
message: tag !== null &&
|
|
122
|
+
(SAFE_FAILURES.has(tag) || tag === "SchemaError") &&
|
|
123
|
+
typeof item.message === "string"
|
|
124
|
+
? redact(item.message)
|
|
125
|
+
: null,
|
|
126
|
+
...(typeof item.reason === "string" && TAG.test(item.reason) ? { reason: item.reason } : {}),
|
|
127
|
+
...(typeof item.requestId === "string" && ID.test(item.requestId)
|
|
128
|
+
? { requestId: item.requestId }
|
|
129
|
+
: {}),
|
|
130
|
+
...(typeof item.reference === "string" && ID.test(item.reference)
|
|
131
|
+
? { reference: item.reference }
|
|
132
|
+
: {}),
|
|
133
|
+
...deploymentFields(tag, item),
|
|
134
|
+
// @legacy ontology.workflow-run-legacy-encodings
|
|
135
|
+
// Old deployments stored this persistent mismatch as a fatal permission error. Preserve its
|
|
136
|
+
// original tag/code and explain the interruption; reading history must never retry the run.
|
|
137
|
+
...(legacyMismatch
|
|
138
|
+
? { category: "deployment_interrupted", reason: "legacy_catalog_mismatch" }
|
|
139
|
+
: {}),
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
/** Find our envelope through retry-exhaustion/run wrappers, with bounded cycle-safe traversal. */
|
|
143
|
+
export function workflowErrorView(value) {
|
|
144
|
+
if (value === undefined || value === null) {
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
const seen = new Set();
|
|
148
|
+
const pending = [value];
|
|
149
|
+
let legacy;
|
|
150
|
+
while (pending.length > 0 && seen.size < 64) {
|
|
151
|
+
const current = pending.shift();
|
|
152
|
+
if (current === undefined || seen.has(current)) {
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
seen.add(current);
|
|
156
|
+
const item = record(current);
|
|
157
|
+
const name = item?._tag ?? item?.name;
|
|
158
|
+
if (!legacy &&
|
|
159
|
+
typeof name === "string" &&
|
|
160
|
+
(SAFE_FAILURES.has(name) || DEPLOYMENT_FAILURES.has(name))) {
|
|
161
|
+
legacy = item;
|
|
162
|
+
}
|
|
163
|
+
if (item?._tag === "OntologyWorkflowFailure" && (item.version === 1 || item.version === 2)) {
|
|
164
|
+
const error = record(item.error);
|
|
165
|
+
if (error) {
|
|
166
|
+
const tag = typeof error.tag === "string" && TAG.test(error.tag) ? error.tag : null;
|
|
167
|
+
return publicError(error, tag);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
pending.push(item?.cause, item?.error);
|
|
171
|
+
if (Array.isArray(item?.errors)) {
|
|
172
|
+
pending.push(...item.errors.slice(0, 64 - seen.size));
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
// @legacy ontology.workflow-run-legacy-encodings
|
|
176
|
+
// Older deployments stored safe tagged errors without the structured envelope.
|
|
177
|
+
const item = legacy ?? record(value);
|
|
178
|
+
const name = item?._tag ?? item?.name;
|
|
179
|
+
const tag = typeof name === "string" && TAG.test(name) ? name : null;
|
|
180
|
+
return publicError(item ?? {}, tag);
|
|
181
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { formatWithOptions } from "node:util";
|
|
2
|
+
import { environmentSecrets, makeRedactor } from "../internal/diagnostics.js";
|
|
3
|
+
import { currentWorkflowStep } from "../workflow-runtime.js";
|
|
4
|
+
import { callbackIdentityToken } from "./workflow-callback.js";
|
|
5
|
+
const INSTALLED = Symbol.for("@segmentstream/ontology/workflow-logging");
|
|
6
|
+
function runtimeEvent(value) {
|
|
7
|
+
if (typeof value !== "string") {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
const start = value.indexOf("{");
|
|
11
|
+
if (start < 0) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
try {
|
|
15
|
+
const event = JSON.parse(value.slice(start))?.event;
|
|
16
|
+
return (typeof event === "string" &&
|
|
17
|
+
(event.startsWith("diagnostics.") || event.startsWith("ontology.workflow.")));
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
// diagnostics-recovery: Ordinary console text is not a structured runtime event.
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/** Only active Workflow steps receive correlation. Operator reports retain their own framing. */
|
|
25
|
+
export function installWorkflowLogging() {
|
|
26
|
+
const globals = globalThis;
|
|
27
|
+
if (globals[INSTALLED]) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
globals[INSTALLED] = true;
|
|
31
|
+
for (const method of ["log", "info", "warn", "error", "debug"]) {
|
|
32
|
+
const write = console[method].bind(console);
|
|
33
|
+
console[method] = (...args) => {
|
|
34
|
+
const step = currentWorkflowStep();
|
|
35
|
+
if (!step || runtimeEvent(args[0])) {
|
|
36
|
+
write(...args);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const redact = makeRedactor([...environmentSecrets(process.env), callbackIdentityToken()]);
|
|
40
|
+
write(JSON.stringify({
|
|
41
|
+
event: "ontology.workflow.console",
|
|
42
|
+
workflowRunId: step.workflowRunId,
|
|
43
|
+
stepId: step.stepId,
|
|
44
|
+
attempt: step.attempt,
|
|
45
|
+
level: method === "warn" ? "warning" : method === "log" ? "info" : method,
|
|
46
|
+
message: redact(formatWithOptions({ depth: 6 }, ...args)),
|
|
47
|
+
}));
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { World } from "@workflow/world";
|
|
2
|
+
/**
|
|
3
|
+
* Guard authenticated, decoded deliveries. The world's handler retains signature validation,
|
|
4
|
+
* CBOR/JSON decoding, acknowledgements and retries. Production keeps the SDK's existing path.
|
|
5
|
+
*/
|
|
6
|
+
export declare function fenceWorkflowQueue(world: World): World;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { deploymentFromEnv, requireDeploymentCapability } from "../deployment.js";
|
|
2
|
+
import { workflowBinding } from "../workflow-runtime.js";
|
|
3
|
+
import { ONTOLOGY_QUEUE_PREFIX } from "../workflow-topics.js";
|
|
4
|
+
import { workflowRunBelongsToDeployment } from "./workflow-deployment.js";
|
|
5
|
+
/**
|
|
6
|
+
* Guard authenticated, decoded deliveries. The world's handler retains signature validation,
|
|
7
|
+
* CBOR/JSON decoding, acknowledgements and retries. Production keeps the SDK's existing path.
|
|
8
|
+
*/
|
|
9
|
+
export function fenceWorkflowQueue(world) {
|
|
10
|
+
return {
|
|
11
|
+
...world,
|
|
12
|
+
createQueueHandler: (prefix, handler) => world.createQueueHandler(prefix, async (payload, metadata) => {
|
|
13
|
+
const deployment = deploymentFromEnv();
|
|
14
|
+
if (deployment.target === "preview" &&
|
|
15
|
+
metadata.queueName.startsWith(ONTOLOGY_QUEUE_PREFIX)) {
|
|
16
|
+
requireDeploymentCapability(deployment, "workflows");
|
|
17
|
+
const message = payload;
|
|
18
|
+
const runId = message?.runId;
|
|
19
|
+
if (typeof runId !== "string") {
|
|
20
|
+
// Health checks carry no run and must never invoke workspace code in a preview.
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const workflowName = metadata.queueName.slice(ONTOLOGY_QUEUE_PREFIX.length);
|
|
24
|
+
const admit = workflowBinding()?.admitWorkflow;
|
|
25
|
+
if (!admit) {
|
|
26
|
+
throw new Error("WorkflowDeploymentAdmissionUnavailable");
|
|
27
|
+
}
|
|
28
|
+
admit(workflowName);
|
|
29
|
+
const validate = (run) => {
|
|
30
|
+
if (run.workflowName !== workflowName ||
|
|
31
|
+
!workflowRunBelongsToDeployment(deployment, run) ||
|
|
32
|
+
(run.environment !== undefined && run.environment !== "preview") ||
|
|
33
|
+
run.dynamicWorkflowCode !== undefined ||
|
|
34
|
+
run.dynamicWorkflowCodeRef !== undefined) {
|
|
35
|
+
throw new Error("WorkflowDeploymentMismatch");
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
// A first delivery may execute directly from this seed (including SDK turbo starts).
|
|
39
|
+
// Validate it even when a persisted run also exists; neither can override the other.
|
|
40
|
+
if (message.runInput) {
|
|
41
|
+
validate(message.runInput);
|
|
42
|
+
}
|
|
43
|
+
let recorded;
|
|
44
|
+
try {
|
|
45
|
+
recorded = await world.runs.get(runId, { resolveData: "none" });
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
const failure = error;
|
|
49
|
+
if (failure?.name !== "WorkflowRunNotFoundError" && failure?.status !== 404) {
|
|
50
|
+
throw error;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (recorded) {
|
|
54
|
+
validate(recorded);
|
|
55
|
+
}
|
|
56
|
+
else if (!message.runInput) {
|
|
57
|
+
throw new Error("WorkflowRunUnknown");
|
|
58
|
+
}
|
|
59
|
+
// A missing record with a verified seed is the SDK's resilient-start path. Its handler
|
|
60
|
+
// validates the full payload and creates the run; this guard never writes run state.
|
|
61
|
+
requireDeploymentCapability(deployment, "workflows");
|
|
62
|
+
}
|
|
63
|
+
return handler(payload, metadata);
|
|
64
|
+
}),
|
|
65
|
+
};
|
|
66
|
+
}
|