@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
package/dist/names.js
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/** Ontology names: lowercase snake_case. */
|
|
2
|
+
export const SNAKE_CASE_NAME = /^[a-z][a-z0-9]*(?:_[a-z0-9]+)*$/;
|
|
3
|
+
/** TypeScript names are converted only at the ontology's serialization boundary. */
|
|
4
|
+
function isUppercase(letter) {
|
|
5
|
+
return letter !== undefined && letter >= "A" && letter <= "Z";
|
|
6
|
+
}
|
|
7
|
+
function isLowercase(letter) {
|
|
8
|
+
return letter !== undefined && letter >= "a" && letter <= "z";
|
|
9
|
+
}
|
|
10
|
+
/** Convert each character once, including acronym boundaries such as HTTPClient. */
|
|
11
|
+
export function toSnakeCase(name) {
|
|
12
|
+
if (name.toLowerCase() === name) {
|
|
13
|
+
return name;
|
|
14
|
+
}
|
|
15
|
+
const characters = [];
|
|
16
|
+
for (let index = 0; index < name.length; index++) {
|
|
17
|
+
const current = name[index];
|
|
18
|
+
const previous = name[index - 1];
|
|
19
|
+
const next = name[index + 1];
|
|
20
|
+
const followsWord = isLowercase(previous) || (previous !== undefined && previous >= "0" && previous <= "9");
|
|
21
|
+
const endsAcronym = isUppercase(previous) && isLowercase(next);
|
|
22
|
+
if (isUppercase(current) && (followsWord || endsAcronym)) {
|
|
23
|
+
characters.push("_");
|
|
24
|
+
}
|
|
25
|
+
characters.push(current);
|
|
26
|
+
}
|
|
27
|
+
return characters.join("").toLowerCase();
|
|
28
|
+
}
|
|
29
|
+
export function toCamelCase(name) {
|
|
30
|
+
return name.replace(/_([a-z0-9])/g, (_, letter) => letter.toUpperCase());
|
|
31
|
+
}
|
|
32
|
+
// @legacy ontology.camelcase-member-names
|
|
33
|
+
/** Historical property names accepted only as explicit rename sources. */
|
|
34
|
+
export const LEGACY_MEMBER_NAME = /^(?:[a-z][a-zA-Z0-9]*|[a-z][a-z0-9]*(?:_[a-z0-9]+)*)$/;
|
|
35
|
+
/** Stable entity identities, for example `ent_01J9Q4M8ZK`. */
|
|
36
|
+
export const ENTITY_ID = /^ent_[A-Za-z0-9_]+$/;
|
|
37
|
+
/** Properties every entity has. They are never declared and cannot be redeclared. */
|
|
38
|
+
export const SYSTEM_PROPERTIES = [
|
|
39
|
+
"id",
|
|
40
|
+
"created_at",
|
|
41
|
+
"updated_at",
|
|
42
|
+
"created_by",
|
|
43
|
+
"updated_by",
|
|
44
|
+
];
|
|
45
|
+
/** Actions the platform generates for every entity; authored actions cannot use these names. */
|
|
46
|
+
export const GENERATED_ACTIONS = ["create", "update", "delete", "link", "unlink"];
|
|
47
|
+
/** Prefix of the generated `upsert_by_<property>` actions. */
|
|
48
|
+
export const GENERATED_UPSERT_PREFIX = "upsert_by_";
|
|
49
|
+
/** The built-in role every active app user holds. */
|
|
50
|
+
export const MEMBER_ROLE = "member";
|
|
51
|
+
/** Implicit human feedback authority; never a stored or assignable role. */
|
|
52
|
+
export const FEEDBACK_REPORTER_ROLE = "feedback_reporter";
|
|
53
|
+
/** Suffix reserved for the history table each entity gets. */
|
|
54
|
+
export const HISTORY_SUFFIX = "_history";
|
|
55
|
+
/** The combinators of the query language, which take the place of field names in a `where`. */
|
|
56
|
+
export const RESERVED_MEMBER_NAMES = ["and", "or", "not"];
|
|
57
|
+
/**
|
|
58
|
+
* The ontology service's route for metric queries across entities, `/api/ontology/query_metrics`,
|
|
59
|
+
* named as the MCP tool is. Each entity with metrics has `/api/ontology/<entity>/query_metrics`.
|
|
60
|
+
*/
|
|
61
|
+
export const QUERY_METRICS_ROUTE = "query_metrics";
|
|
62
|
+
/** Routes of the ontology service under `/api/ontology/`, which an entity's routes would shadow. */
|
|
63
|
+
export const RESERVED_ENTITY_NAMES = [
|
|
64
|
+
"chat",
|
|
65
|
+
QUERY_METRICS_ROUTE,
|
|
66
|
+
"graph",
|
|
67
|
+
"status",
|
|
68
|
+
"describe",
|
|
69
|
+
"openapi",
|
|
70
|
+
"docs",
|
|
71
|
+
"mcp",
|
|
72
|
+
"me",
|
|
73
|
+
"oauth",
|
|
74
|
+
"agent",
|
|
75
|
+
"workflows",
|
|
76
|
+
];
|
|
77
|
+
/** The MCP tools of every stored entity's reads: `lead_find`, `lead_get` and `lead_history`. */
|
|
78
|
+
export const MCP_READ_TOOLS = ["find", "get", "history"];
|
|
79
|
+
/** The MCP tools of the ontology as a whole. No entity tool can take them: they have no underscore. */
|
|
80
|
+
export const MCP_GLOBAL_TOOLS = ["discover", "me"];
|
|
81
|
+
/**
|
|
82
|
+
* The metric tools, named as dbt names its MCP tools. Their names have an underscore, so `check`
|
|
83
|
+
* refuses an entity tool that takes one, such as entity `list`'s action `metrics`.
|
|
84
|
+
*/
|
|
85
|
+
export const MCP_METRIC_TOOLS = [
|
|
86
|
+
"list_metrics",
|
|
87
|
+
"get_dimensions",
|
|
88
|
+
"get_dimension_values",
|
|
89
|
+
"query_metrics",
|
|
90
|
+
];
|
|
91
|
+
/** The longest tool name that Claude and OpenAI accept. */
|
|
92
|
+
export const MCP_TOOL_NAME_MAX_LENGTH = 64;
|
|
93
|
+
/** The MCP tool of an entity's read or action: `lead_find`, `lead_change_status`. */
|
|
94
|
+
export function mcpToolName(entity, operation) {
|
|
95
|
+
return `${entity}_${operation}`;
|
|
96
|
+
}
|
|
97
|
+
/** `/api/ontology/<entity>/{id}/history`, which a relationship's traversal would shadow. */
|
|
98
|
+
export const RESERVED_RELATIONSHIP_NAMES = ["history"];
|
|
99
|
+
export function isSystemProperty(name) {
|
|
100
|
+
return SYSTEM_PROPERTIES.includes(name);
|
|
101
|
+
}
|
|
102
|
+
/** `created_at` → `Created at`, `pilot_request` → `Pilot request`. */
|
|
103
|
+
export function humanize(name) {
|
|
104
|
+
const words = name
|
|
105
|
+
.replace(/([a-z0-9])([A-Z])/g, "$1 $2")
|
|
106
|
+
.replace(/[_-]+/g, " ")
|
|
107
|
+
.trim()
|
|
108
|
+
.toLowerCase();
|
|
109
|
+
return words.charAt(0).toUpperCase() + words.slice(1);
|
|
110
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type PageCatalogV1 } from "./navigation-catalog.js";
|
|
2
|
+
declare global {
|
|
3
|
+
interface ImportMeta {
|
|
4
|
+
readonly segmentstreamNavigationCatalog?: unknown;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
/** Capability gate for immutable catalog transport; independent of SDK release numbering. */
|
|
8
|
+
export declare const NAVIGATION_ARTIFACT_VERSION = 1;
|
|
9
|
+
/**
|
|
10
|
+
* Nitro replaces this import-meta property with validated catalog JSON at build time. There is no
|
|
11
|
+
* runtime file, environment variable, or Cloud row to change the deployment's navigation catalog.
|
|
12
|
+
*/
|
|
13
|
+
export declare function bundledNavigationCatalog(): PageCatalogV1 | undefined;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { parsePageCatalog } from "./navigation-catalog.js";
|
|
2
|
+
/** Capability gate for immutable catalog transport; independent of SDK release numbering. */
|
|
3
|
+
export const NAVIGATION_ARTIFACT_VERSION = 1;
|
|
4
|
+
/**
|
|
5
|
+
* Nitro replaces this import-meta property with validated catalog JSON at build time. There is no
|
|
6
|
+
* runtime file, environment variable, or Cloud row to change the deployment's navigation catalog.
|
|
7
|
+
*/
|
|
8
|
+
export function bundledNavigationCatalog() {
|
|
9
|
+
const value = import.meta.segmentstreamNavigationCatalog;
|
|
10
|
+
return value === undefined ? undefined : parsePageCatalog(value);
|
|
11
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/** Workspace-authored metadata beside an ordinary UI page. Routes are generated, never authored. */
|
|
2
|
+
export interface PageMetadata {
|
|
3
|
+
readonly title: string;
|
|
4
|
+
readonly entities: readonly string[];
|
|
5
|
+
readonly description: string;
|
|
6
|
+
readonly parameters?: Readonly<Record<string, string>>;
|
|
7
|
+
readonly query?: Readonly<Record<string, string>>;
|
|
8
|
+
}
|
|
9
|
+
export interface PageEntry {
|
|
10
|
+
readonly ref: string;
|
|
11
|
+
readonly route: string;
|
|
12
|
+
readonly title: string;
|
|
13
|
+
readonly description: string;
|
|
14
|
+
readonly entities: readonly string[];
|
|
15
|
+
readonly parameters: readonly {
|
|
16
|
+
readonly name: string;
|
|
17
|
+
readonly kind: "segment" | "catch_all";
|
|
18
|
+
readonly required: boolean;
|
|
19
|
+
readonly description?: string;
|
|
20
|
+
}[];
|
|
21
|
+
readonly query: Readonly<Record<string, string>>;
|
|
22
|
+
}
|
|
23
|
+
export interface PageCatalogV1 {
|
|
24
|
+
readonly version: 1;
|
|
25
|
+
readonly revision: string;
|
|
26
|
+
readonly pages: readonly PageEntry[];
|
|
27
|
+
}
|
|
28
|
+
export declare const NAVIGATION_CATALOG_LIMITS: Readonly<{
|
|
29
|
+
pages: 1000;
|
|
30
|
+
bytes: number;
|
|
31
|
+
title: 120;
|
|
32
|
+
description: 2000;
|
|
33
|
+
hint: 512;
|
|
34
|
+
associations: 32;
|
|
35
|
+
hints: 32;
|
|
36
|
+
responseBytes: number;
|
|
37
|
+
}>;
|
|
38
|
+
/**
|
|
39
|
+
* Whether a generated page and a routing source can share a path. Compare complete segment
|
|
40
|
+
* shapes for ordinary parameters, optional parameters and catch-alls; custom regex sources
|
|
41
|
+
* remain conservative when their static prefixes cannot prove disjointness.
|
|
42
|
+
*/
|
|
43
|
+
export declare function navigationRoutesMayOverlap(route: string, source: string): boolean;
|
|
44
|
+
export declare class NavigationCatalogError extends Error {
|
|
45
|
+
readonly code: "invalid_page_catalog" | "page_catalog_too_large";
|
|
46
|
+
readonly name = "NavigationCatalogError";
|
|
47
|
+
constructor(code: "invalid_page_catalog" | "page_catalog_too_large", message: string);
|
|
48
|
+
}
|
|
49
|
+
/** Validate and copy an untrusted artifact. Entity existence is checked against the serving ontology. */
|
|
50
|
+
export declare function parsePageCatalog(value: unknown): PageCatalogV1;
|
|
51
|
+
/** Generate an immutable catalog identity from normalized metadata, ontology, and source identity. */
|
|
52
|
+
export declare function createPageCatalog(pages: readonly PageEntry[], context: {
|
|
53
|
+
readonly ontologyHash: string;
|
|
54
|
+
readonly sourceHash: string;
|
|
55
|
+
}): PageCatalogV1;
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
export const NAVIGATION_CATALOG_LIMITS = Object.freeze({
|
|
3
|
+
pages: 1_000,
|
|
4
|
+
bytes: 1024 * 1024,
|
|
5
|
+
title: 120,
|
|
6
|
+
description: 2_000,
|
|
7
|
+
hint: 512,
|
|
8
|
+
associations: 32,
|
|
9
|
+
hints: 32,
|
|
10
|
+
responseBytes: 32 * 1024,
|
|
11
|
+
});
|
|
12
|
+
function routeShape(path, source) {
|
|
13
|
+
if (!path.startsWith("/")) {
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
const result = [];
|
|
17
|
+
for (const segment of path.split("/").filter(Boolean)) {
|
|
18
|
+
const parameter = source
|
|
19
|
+
? /^:[A-Za-z0-9_]+([?*+]?)$/u.exec(segment)
|
|
20
|
+
: /^(?:\[\[\.\.\.[^\[\]]+\]\]|\[\.\.\.[^\[\]]+\]|\[[^\[\]]+\])$/u.exec(segment);
|
|
21
|
+
if (parameter) {
|
|
22
|
+
result.push({
|
|
23
|
+
literal: undefined,
|
|
24
|
+
optional: source ? ["?", "*"].includes(parameter[1]) : segment.startsWith("[["),
|
|
25
|
+
repeat: source ? ["*", "+"].includes(parameter[1]) : segment.includes("..."),
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
else if (/[:()*+?{}\\\[\]%]/u.test(segment)) {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
result.push({ literal: segment.toLowerCase(), optional: false, repeat: false });
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Whether a generated page and a routing source can share a path. Compare complete segment
|
|
39
|
+
* shapes for ordinary parameters, optional parameters and catch-alls; custom regex sources
|
|
40
|
+
* remain conservative when their static prefixes cannot prove disjointness.
|
|
41
|
+
*/
|
|
42
|
+
export function navigationRoutesMayOverlap(route, source) {
|
|
43
|
+
const page = routeShape(route, false);
|
|
44
|
+
const rule = routeShape(source, true);
|
|
45
|
+
if (page === undefined || rule === undefined) {
|
|
46
|
+
const pagePrefix = route.split("[")[0].toLowerCase();
|
|
47
|
+
const rulePrefix = source.split(/[:(*?+{\\]/u)[0].toLowerCase();
|
|
48
|
+
return (pagePrefix.includes("%") ||
|
|
49
|
+
rulePrefix.includes("%") ||
|
|
50
|
+
pagePrefix.startsWith(rulePrefix) ||
|
|
51
|
+
rulePrefix.startsWith(pagePrefix));
|
|
52
|
+
}
|
|
53
|
+
const pending = [[0, 0]];
|
|
54
|
+
const visited = new Set();
|
|
55
|
+
while (pending.length > 0) {
|
|
56
|
+
const [left, right] = pending.pop();
|
|
57
|
+
const key = `${left}:${right}`;
|
|
58
|
+
if (visited.has(key)) {
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
visited.add(key);
|
|
62
|
+
if (left === page.length && right === rule.length) {
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
const a = page[left];
|
|
66
|
+
const b = rule[right];
|
|
67
|
+
if (a?.optional) {
|
|
68
|
+
pending.push([left + 1, right]);
|
|
69
|
+
}
|
|
70
|
+
if (b?.optional) {
|
|
71
|
+
pending.push([left, right + 1]);
|
|
72
|
+
}
|
|
73
|
+
if (a && b && (a.literal === undefined || b.literal === undefined || a.literal === b.literal)) {
|
|
74
|
+
pending.push([left + 1, right + 1]);
|
|
75
|
+
if (a.repeat) {
|
|
76
|
+
pending.push([left, right + 1]);
|
|
77
|
+
}
|
|
78
|
+
if (b.repeat) {
|
|
79
|
+
pending.push([left + 1, right]);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
export class NavigationCatalogError extends Error {
|
|
86
|
+
code;
|
|
87
|
+
name = "NavigationCatalogError";
|
|
88
|
+
constructor(code, message) {
|
|
89
|
+
super(message);
|
|
90
|
+
this.code = code;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function invalid(message) {
|
|
94
|
+
throw new NavigationCatalogError("invalid_page_catalog", message);
|
|
95
|
+
}
|
|
96
|
+
function bounded(condition, message) {
|
|
97
|
+
if (!condition) {
|
|
98
|
+
throw new NavigationCatalogError("page_catalog_too_large", message);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
function object(value, fields) {
|
|
102
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
103
|
+
return invalid("Navigation metadata must be a JSON object.");
|
|
104
|
+
}
|
|
105
|
+
if (fields !== undefined && Object.keys(value).some((key) => !fields.includes(key))) {
|
|
106
|
+
return invalid("Navigation metadata contains an unknown field.");
|
|
107
|
+
}
|
|
108
|
+
return value;
|
|
109
|
+
}
|
|
110
|
+
function text(value, maximum, field) {
|
|
111
|
+
if (typeof value !== "string" ||
|
|
112
|
+
value.trim() === "" ||
|
|
113
|
+
/[\u0000-\u0008\u000b\u000c\u000e-\u001f]/u.test(value)) {
|
|
114
|
+
return invalid(`${field} must be nonblank text without control characters.`);
|
|
115
|
+
}
|
|
116
|
+
bounded(Array.from(value).length <= maximum, `${field} exceeds ${maximum} Unicode code points.`);
|
|
117
|
+
return value;
|
|
118
|
+
}
|
|
119
|
+
function hints(value) {
|
|
120
|
+
const entries = Object.entries(object(value));
|
|
121
|
+
bounded(entries.length <= NAVIGATION_CATALOG_LIMITS.hints, "A page has more than 32 query hints.");
|
|
122
|
+
return Object.freeze(Object.fromEntries(entries
|
|
123
|
+
.sort(([a], [b]) => compare(a, b))
|
|
124
|
+
.map(([key, hint]) => [
|
|
125
|
+
text(key, NAVIGATION_CATALOG_LIMITS.responseBytes, "Query name"),
|
|
126
|
+
text(hint, NAVIGATION_CATALOG_LIMITS.hint, "Query hint"),
|
|
127
|
+
])));
|
|
128
|
+
}
|
|
129
|
+
function compare(left, right) {
|
|
130
|
+
return left < right ? -1 : left > right ? 1 : 0;
|
|
131
|
+
}
|
|
132
|
+
function entry(value) {
|
|
133
|
+
const page = object(value, [
|
|
134
|
+
"ref",
|
|
135
|
+
"route",
|
|
136
|
+
"title",
|
|
137
|
+
"description",
|
|
138
|
+
"entities",
|
|
139
|
+
"parameters",
|
|
140
|
+
"query",
|
|
141
|
+
]);
|
|
142
|
+
const route = text(page.route, NAVIGATION_CATALOG_LIMITS.responseBytes, "Page route");
|
|
143
|
+
if (!route.startsWith("/") || /[?#\\\s\u007f]/u.test(route) || route.includes("//")) {
|
|
144
|
+
return invalid("A page route must be a normalized absolute path without an origin or query.");
|
|
145
|
+
}
|
|
146
|
+
const segments = route.slice(1).split("/").filter(Boolean);
|
|
147
|
+
const routeParameters = [];
|
|
148
|
+
for (const [index, segment] of segments.entries()) {
|
|
149
|
+
const match = /^(?:\[\[\.\.\.([^\[\]/]+)\]\]|\[\.\.\.([^\[\]/]+)\]|\[([^\[\]/]+)\])$/u.exec(segment);
|
|
150
|
+
if (match) {
|
|
151
|
+
const name = match[1] ?? match[2] ?? match[3];
|
|
152
|
+
const kind = match[3] === undefined ? "catch_all" : "segment";
|
|
153
|
+
text(name, NAVIGATION_CATALOG_LIMITS.responseBytes, "Parameter name");
|
|
154
|
+
if (routeParameters.some((parameter) => parameter.name === name) ||
|
|
155
|
+
(kind === "catch_all" && index !== segments.length - 1)) {
|
|
156
|
+
return invalid("Route parameters must be unique and catch-all parameters must be last.");
|
|
157
|
+
}
|
|
158
|
+
routeParameters.push({ name, kind, required: match[1] === undefined });
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
let decoded;
|
|
162
|
+
try {
|
|
163
|
+
decoded = decodeURIComponent(segment);
|
|
164
|
+
}
|
|
165
|
+
catch {
|
|
166
|
+
return invalid("Page route has invalid percent encoding.");
|
|
167
|
+
}
|
|
168
|
+
if (decoded === "." || decoded === ".." || /[\[\]\/\\\u0000-\u0020\u007f]/u.test(decoded)) {
|
|
169
|
+
return invalid("Page route has an unsupported or unsafe segment.");
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
if (page.ref !== `page:${route}`) {
|
|
174
|
+
return invalid("Page references must be page: followed by the normalized route.");
|
|
175
|
+
}
|
|
176
|
+
if (!Array.isArray(page.entities) || !Array.isArray(page.parameters)) {
|
|
177
|
+
return invalid("Page entities and parameters must be arrays.");
|
|
178
|
+
}
|
|
179
|
+
bounded(page.entities.length <= NAVIGATION_CATALOG_LIMITS.associations, "A page has more than 32 entities.");
|
|
180
|
+
const entities = Array.from(page.entities, (name) => {
|
|
181
|
+
if (typeof name !== "string" || !/^[a-z][a-z0-9_]*$/u.test(name)) {
|
|
182
|
+
return invalid("Page entity associations must be canonical ontology names.");
|
|
183
|
+
}
|
|
184
|
+
return name;
|
|
185
|
+
});
|
|
186
|
+
if (new Set(entities).size !== entities.length) {
|
|
187
|
+
return invalid("A page repeats an entity association.");
|
|
188
|
+
}
|
|
189
|
+
if (page.parameters.length !== routeParameters.length) {
|
|
190
|
+
return invalid("Page parameters must exactly describe their route.");
|
|
191
|
+
}
|
|
192
|
+
const declaredParameters = page.parameters;
|
|
193
|
+
const parameters = routeParameters.map((expected, index) => {
|
|
194
|
+
const parameter = object(declaredParameters[index], [
|
|
195
|
+
"name",
|
|
196
|
+
"kind",
|
|
197
|
+
"required",
|
|
198
|
+
"description",
|
|
199
|
+
]);
|
|
200
|
+
if (parameter.name !== expected.name ||
|
|
201
|
+
parameter.kind !== expected.kind ||
|
|
202
|
+
parameter.required !== expected.required) {
|
|
203
|
+
return invalid("Page parameters must match their route in path order.");
|
|
204
|
+
}
|
|
205
|
+
return Object.freeze({
|
|
206
|
+
...expected,
|
|
207
|
+
...(parameter.description === undefined
|
|
208
|
+
? {}
|
|
209
|
+
: {
|
|
210
|
+
description: text(parameter.description, NAVIGATION_CATALOG_LIMITS.hint, "Parameter hint"),
|
|
211
|
+
}),
|
|
212
|
+
});
|
|
213
|
+
});
|
|
214
|
+
bounded(parameters.filter((parameter) => parameter.description !== undefined).length <=
|
|
215
|
+
NAVIGATION_CATALOG_LIMITS.hints, "A page has more than 32 parameter hints.");
|
|
216
|
+
const normalized = Object.freeze({
|
|
217
|
+
ref: `page:${route}`,
|
|
218
|
+
route,
|
|
219
|
+
title: text(page.title, NAVIGATION_CATALOG_LIMITS.title, "Page title"),
|
|
220
|
+
description: text(page.description, NAVIGATION_CATALOG_LIMITS.description, "Page description"),
|
|
221
|
+
entities: Object.freeze(entities.sort(compare)),
|
|
222
|
+
parameters: Object.freeze(parameters),
|
|
223
|
+
query: hints(page.query),
|
|
224
|
+
});
|
|
225
|
+
// An entry must fit even when more results follow. Runtime checks the actual origin/envelope too.
|
|
226
|
+
const revision = `sha256:${"0".repeat(64)}`;
|
|
227
|
+
const result = {
|
|
228
|
+
revision,
|
|
229
|
+
pages: [
|
|
230
|
+
{
|
|
231
|
+
...normalized,
|
|
232
|
+
[parameters.length === 0 ? "url" : "url_pattern"]: `https://navigation.invalid${route}`,
|
|
233
|
+
},
|
|
234
|
+
],
|
|
235
|
+
next_cursor: Buffer.from(JSON.stringify({
|
|
236
|
+
revision,
|
|
237
|
+
scope: "0".repeat(64),
|
|
238
|
+
request: "0".repeat(64),
|
|
239
|
+
last: normalized.ref,
|
|
240
|
+
})).toString("base64url"),
|
|
241
|
+
};
|
|
242
|
+
bounded(Buffer.byteLength(JSON.stringify({
|
|
243
|
+
content: [{ type: "text", text: JSON.stringify(result) }],
|
|
244
|
+
structuredContent: result,
|
|
245
|
+
})) <= NAVIGATION_CATALOG_LIMITS.responseBytes, "A complete page entry exceeds the MCP response budget.");
|
|
246
|
+
return normalized;
|
|
247
|
+
}
|
|
248
|
+
/** Canonical JSON is independent of insertion order, process locale, and object prototypes. */
|
|
249
|
+
function canonical(value) {
|
|
250
|
+
if (Array.isArray(value)) {
|
|
251
|
+
return `[${value.map(canonical).join(",")}]`;
|
|
252
|
+
}
|
|
253
|
+
if (typeof value === "object" && value !== null) {
|
|
254
|
+
return `{${Object.entries(value)
|
|
255
|
+
.sort(([a], [b]) => compare(a, b))
|
|
256
|
+
.map(([key, item]) => `${JSON.stringify(key)}:${canonical(item)}`)
|
|
257
|
+
.join(",")}}`;
|
|
258
|
+
}
|
|
259
|
+
return JSON.stringify(value);
|
|
260
|
+
}
|
|
261
|
+
/** Validate and copy an untrusted artifact. Entity existence is checked against the serving ontology. */
|
|
262
|
+
export function parsePageCatalog(value) {
|
|
263
|
+
const catalog = object(value, ["version", "revision", "pages"]);
|
|
264
|
+
if (catalog.version !== 1 ||
|
|
265
|
+
typeof catalog.revision !== "string" ||
|
|
266
|
+
!/^sha256:[a-f0-9]{64}$/u.test(catalog.revision) ||
|
|
267
|
+
!Array.isArray(catalog.pages)) {
|
|
268
|
+
return invalid("Expected a version-1 page catalog with a SHA-256 revision and pages array.");
|
|
269
|
+
}
|
|
270
|
+
bounded(catalog.pages.length <= NAVIGATION_CATALOG_LIMITS.pages, "A catalog has more than 1,000 pages.");
|
|
271
|
+
const pages = Array.from(catalog.pages, entry).sort((a, b) => compare(a.ref, b.ref));
|
|
272
|
+
if (new Set(pages.map((page) => page.ref)).size !== pages.length) {
|
|
273
|
+
return invalid("Page catalog contains duplicate routes.");
|
|
274
|
+
}
|
|
275
|
+
const normalized = {
|
|
276
|
+
version: 1,
|
|
277
|
+
revision: catalog.revision,
|
|
278
|
+
pages: Object.freeze(pages),
|
|
279
|
+
};
|
|
280
|
+
bounded(Buffer.byteLength(canonical(normalized)) <= NAVIGATION_CATALOG_LIMITS.bytes, "Page catalog exceeds 1 MiB.");
|
|
281
|
+
return Object.freeze(normalized);
|
|
282
|
+
}
|
|
283
|
+
/** Generate an immutable catalog identity from normalized metadata, ontology, and source identity. */
|
|
284
|
+
export function createPageCatalog(pages, context) {
|
|
285
|
+
text(context.ontologyHash, NAVIGATION_CATALOG_LIMITS.bytes, "Ontology hash");
|
|
286
|
+
text(context.sourceHash, NAVIGATION_CATALOG_LIMITS.bytes, "Source hash");
|
|
287
|
+
const normalized = parsePageCatalog({ version: 1, revision: `sha256:${"0".repeat(64)}`, pages });
|
|
288
|
+
const revision = `sha256:${createHash("sha256")
|
|
289
|
+
.update(canonical({
|
|
290
|
+
version: 1,
|
|
291
|
+
pages: normalized.pages,
|
|
292
|
+
ontologyHash: context.ontologyHash,
|
|
293
|
+
sourceHash: context.sourceHash,
|
|
294
|
+
}))
|
|
295
|
+
.digest("hex")}`;
|
|
296
|
+
return Object.freeze({ ...normalized, revision });
|
|
297
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { readFile, rename, rm, writeFile } from "node:fs/promises";
|
|
3
|
+
import { resolve } from "node:path";
|
|
4
|
+
import { parsePageCatalog } from "./navigation-catalog.js";
|
|
5
|
+
async function optionalFile(path) {
|
|
6
|
+
try {
|
|
7
|
+
return await readFile(path, "utf8");
|
|
8
|
+
}
|
|
9
|
+
catch (error) {
|
|
10
|
+
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
throw error;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
/** Called by the SDK's Nitro module, before independently compiling the ontology service. */
|
|
17
|
+
export async function setupNavigationCatalog(nitro) {
|
|
18
|
+
const directory = resolve(nitro.options.rootDir, ".segmentstream/navigation");
|
|
19
|
+
const enabled = await optionalFile(resolve(directory, "enabled.json"));
|
|
20
|
+
const contents = await optionalFile(resolve(directory, "catalog.json"));
|
|
21
|
+
const receipt = resolve(directory, "build-binding.json");
|
|
22
|
+
let replacement = "undefined";
|
|
23
|
+
await rm(receipt, { force: true });
|
|
24
|
+
if (enabled !== undefined) {
|
|
25
|
+
const marker = JSON.parse(enabled);
|
|
26
|
+
if (marker === null ||
|
|
27
|
+
typeof marker !== "object" ||
|
|
28
|
+
Array.isArray(marker) ||
|
|
29
|
+
Object.keys(marker).length !== 1 ||
|
|
30
|
+
!("version" in marker) ||
|
|
31
|
+
marker.version !== 1) {
|
|
32
|
+
throw new Error("navigation_artifact_marker_invalid");
|
|
33
|
+
}
|
|
34
|
+
if (contents === undefined) {
|
|
35
|
+
throw new Error("navigation_artifact_missing");
|
|
36
|
+
}
|
|
37
|
+
const catalog = parsePageCatalog(JSON.parse(contents));
|
|
38
|
+
replacement = JSON.stringify(catalog);
|
|
39
|
+
nitro.hooks.hook("compiled", async () => {
|
|
40
|
+
const temporary = `${receipt}.${randomUUID()}.tmp`;
|
|
41
|
+
try {
|
|
42
|
+
await writeFile(temporary, JSON.stringify({ version: 1, revision: catalog.revision }), {
|
|
43
|
+
flag: "wx",
|
|
44
|
+
});
|
|
45
|
+
await rename(temporary, receipt);
|
|
46
|
+
}
|
|
47
|
+
finally {
|
|
48
|
+
await rm(temporary, { force: true });
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
// The replacement must reach the SDK accessor instead of leaving it in node_modules.
|
|
52
|
+
if (nitro.options.noExternals !== true) {
|
|
53
|
+
nitro.options.noExternals = [
|
|
54
|
+
...(Array.isArray(nitro.options.noExternals) ? nitro.options.noExternals : []),
|
|
55
|
+
"@segmentstream/ontology",
|
|
56
|
+
];
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
else if (contents !== undefined) {
|
|
60
|
+
throw new Error("navigation_artifact_marker_missing");
|
|
61
|
+
}
|
|
62
|
+
nitro.options.replace ??= {};
|
|
63
|
+
nitro.options.replace["import.meta.segmentstreamNavigationCatalog"] = replacement;
|
|
64
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { BaseBuilder } from "@workflow/builders";
|
|
2
|
+
import type { Nitro } from "nitro/types";
|
|
3
|
+
/**
|
|
4
|
+
* The build side of `ontologyWorkflows()` (see `./nitro.ts`), loaded only while Nitro builds.
|
|
5
|
+
*/
|
|
6
|
+
interface Settings {
|
|
7
|
+
readonly dirs: Array<string>;
|
|
8
|
+
readonly basePath: string;
|
|
9
|
+
readonly namespace: string;
|
|
10
|
+
readonly route: string;
|
|
11
|
+
readonly trigger: object;
|
|
12
|
+
}
|
|
13
|
+
/** The directory, inside Nitro's build directory, that holds the generated bundles. */
|
|
14
|
+
export declare function workflowBuildDir(buildDir: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* The directory that holds the platform's own workflow files, which the builder writes before
|
|
17
|
+
* every build and compiles with the workspace's. Beside the navigation artifact under the
|
|
18
|
+
* project's `.segmentstream/`, which the starter ignores in Git: the Workflow SDK's builder
|
|
19
|
+
* skips files under Nitro's `.nitro/` build directory, so they cannot live there.
|
|
20
|
+
*/
|
|
21
|
+
export declare function platformWorkflowDir(rootDir: string): string;
|
|
22
|
+
/** The platform workflow file the builder writes, and the name of its workflow function. */
|
|
23
|
+
export declare const PLATFORM_WORKFLOW_FILE = "recover-starts.ts";
|
|
24
|
+
export declare const PLATFORM_RECOVERY_WORKFLOW = "recoverStarts";
|
|
25
|
+
/** Where the generated platform workflow takes the SDK from; tests point it at the sources. */
|
|
26
|
+
export interface PlatformWorkflowImports {
|
|
27
|
+
/** The module that exports `recoverWorkflowStarts`: the `workflows` entry. */
|
|
28
|
+
readonly workflows: string;
|
|
29
|
+
/**
|
|
30
|
+
* Modules imported for their steps alone. The SDK's step discovery reads `./start-recovery.js`
|
|
31
|
+
* in the package's sources literally and finds no such file beside `start-recovery.ts`; the
|
|
32
|
+
* built package has it. Tests name the source module here.
|
|
33
|
+
*/
|
|
34
|
+
readonly steps?: ReadonlyArray<string>;
|
|
35
|
+
}
|
|
36
|
+
/** The platform's workflow files: where they are written, and how they import the SDK. */
|
|
37
|
+
export interface PlatformWorkflowsSettings {
|
|
38
|
+
/** The directory the files are written to, included in the build. */
|
|
39
|
+
readonly dir: string;
|
|
40
|
+
readonly imports?: PlatformWorkflowImports;
|
|
41
|
+
/** Shorter sleeps for the recovery run; tests only, production builds set none. */
|
|
42
|
+
readonly delays?: {
|
|
43
|
+
readonly firstSweepMs: number;
|
|
44
|
+
readonly confirmMs: number;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The platform's start recovery workflow, as a workflow file of the workspace's build: its body is
|
|
49
|
+
* the SDK's, so an SDK upgrade changes what the run does without touching the workspace's code.
|
|
50
|
+
*/
|
|
51
|
+
export declare function platformWorkflowSource(settings?: Pick<PlatformWorkflowsSettings, "imports" | "delays">): string;
|
|
52
|
+
/**
|
|
53
|
+
* The Nitro plugin that registers the compiled platform workflow with the SDK at startup, so that
|
|
54
|
+
* the service starts it as it starts a declared workflow's `run`. The server build's transform
|
|
55
|
+
* compiles the imported function like the workspace's workflow files.
|
|
56
|
+
*/
|
|
57
|
+
export declare function platformPluginSource(input: {
|
|
58
|
+
readonly file: string;
|
|
59
|
+
/** The module that exports `registerPlatformWorkflows`: the `server` entry. */
|
|
60
|
+
readonly server?: string;
|
|
61
|
+
}): string;
|
|
62
|
+
/**
|
|
63
|
+
* Bundles a folder's workflows and steps as the ontology service serves them, as the SDK's own
|
|
64
|
+
* Nitro integration does since version 5: `steps.mjs` registers the steps, and `workflows.mjs`
|
|
65
|
+
* imports it and exports the flow handler, `workflowEntrypoint(code, { namespace, basePath })`,
|
|
66
|
+
* which runs the steps. Bundles import the rest of the project and its packages, which the server
|
|
67
|
+
* build resolves.
|
|
68
|
+
*/
|
|
69
|
+
export declare class OntologyWorkflowBuilder extends BaseBuilder {
|
|
70
|
+
#private;
|
|
71
|
+
constructor(input: {
|
|
72
|
+
readonly workingDir: string;
|
|
73
|
+
readonly projectRoot?: string;
|
|
74
|
+
readonly dirs: Array<string>;
|
|
75
|
+
readonly basePath: string;
|
|
76
|
+
readonly namespace: string;
|
|
77
|
+
readonly outDir: string;
|
|
78
|
+
readonly watch?: boolean;
|
|
79
|
+
/** The platform's workflow files, compiled with the workspace's; none when absent. */
|
|
80
|
+
readonly platform?: PlatformWorkflowsSettings;
|
|
81
|
+
});
|
|
82
|
+
get outDir(): string;
|
|
83
|
+
/** The platform workflow file this build compiles, when it has one. */
|
|
84
|
+
get platformWorkflowFile(): string | undefined;
|
|
85
|
+
build(): Promise<void>;
|
|
86
|
+
}
|
|
87
|
+
/** Where the generated handler takes its runtime from; tests point them elsewhere. */
|
|
88
|
+
export interface CallbackImports {
|
|
89
|
+
/** The module that exports `serveWorkflowCallback`. */
|
|
90
|
+
readonly ontology: string;
|
|
91
|
+
/** The module that exports Nitro's `serverFetch`. */
|
|
92
|
+
readonly nitroApp: string;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* The flow handler module. It answers only a queue delivery at its exact route, warms the
|
|
96
|
+
* ontology service of this instance first, through Nitro's own fetch, so that `run(effect)` finds
|
|
97
|
+
* its runtime, and keeps the request's Vercel OIDC token for the steps' connection calls.
|
|
98
|
+
*/
|
|
99
|
+
export declare function callbackHandlerSource(input: {
|
|
100
|
+
readonly file: string;
|
|
101
|
+
readonly dev: boolean;
|
|
102
|
+
readonly route: string;
|
|
103
|
+
readonly namespace: string;
|
|
104
|
+
readonly statusPath: string;
|
|
105
|
+
readonly imports?: CallbackImports;
|
|
106
|
+
}): string;
|
|
107
|
+
export declare function setupOntologyWorkflows(nitro: Nitro, settings: Settings): Promise<void>;
|
|
108
|
+
export {};
|