@segmentstream/ontology 0.0.0-stage → 0.92.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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,6 @@
|
|
|
1
|
+
import type { JsonSchemaObject } from "../../analyze.js";
|
|
2
|
+
/**
|
|
3
|
+
* MCP clients use different regex engines. Omit Unicode property pattern assertions from the
|
|
4
|
+
* immutable advertised input schema; the original Effect schema still validates every tool call.
|
|
5
|
+
*/
|
|
6
|
+
export declare function mcpInputSchema(schema: JsonSchemaObject): JsonSchemaObject;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
const SCHEMA_MAPS = new Set([
|
|
2
|
+
"$defs",
|
|
3
|
+
"definitions",
|
|
4
|
+
"properties",
|
|
5
|
+
"patternProperties",
|
|
6
|
+
"dependentSchemas",
|
|
7
|
+
"dependencies",
|
|
8
|
+
]);
|
|
9
|
+
const SCHEMA_ARRAYS = new Set(["allOf", "anyOf", "oneOf", "prefixItems"]);
|
|
10
|
+
const SCHEMA_VALUES = new Set([
|
|
11
|
+
"items",
|
|
12
|
+
"additionalItems",
|
|
13
|
+
"contains",
|
|
14
|
+
"additionalProperties",
|
|
15
|
+
"unevaluatedItems",
|
|
16
|
+
"unevaluatedProperties",
|
|
17
|
+
"propertyNames",
|
|
18
|
+
"not",
|
|
19
|
+
"if",
|
|
20
|
+
"then",
|
|
21
|
+
"else",
|
|
22
|
+
"contentSchema",
|
|
23
|
+
]);
|
|
24
|
+
function isObject(value) {
|
|
25
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
26
|
+
}
|
|
27
|
+
/** An escaped backslash is literal text, not the start of a Unicode property escape. */
|
|
28
|
+
function hasUnicodeProperty(pattern) {
|
|
29
|
+
for (let index = 0; index < pattern.length; index++) {
|
|
30
|
+
if (pattern[index] !== "\\") {
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
index++;
|
|
34
|
+
if ((pattern[index] === "p" || pattern[index] === "P") && pattern[index + 1] === "{") {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
function project(value, relaxReferences = false) {
|
|
41
|
+
if (!isObject(value)) {
|
|
42
|
+
return value;
|
|
43
|
+
}
|
|
44
|
+
const result = { ...value };
|
|
45
|
+
const changed = new Set();
|
|
46
|
+
let propertyPatternsRemoved = false;
|
|
47
|
+
for (const [key, child] of Object.entries(value)) {
|
|
48
|
+
// A referenced definition may have been relaxed elsewhere in this schema document.
|
|
49
|
+
if (relaxReferences && ["$ref", "$dynamicRef", "$recursiveRef"].includes(key)) {
|
|
50
|
+
changed.add(key);
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
if (key === "pattern" && typeof child === "string" && hasUnicodeProperty(child)) {
|
|
54
|
+
delete result[key];
|
|
55
|
+
changed.add(key);
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
let projected = child;
|
|
59
|
+
if (SCHEMA_MAPS.has(key) && isObject(child)) {
|
|
60
|
+
if (key === "patternProperties" && Object.keys(child).some(hasUnicodeProperty)) {
|
|
61
|
+
delete result[key];
|
|
62
|
+
changed.add(key);
|
|
63
|
+
propertyPatternsRemoved = true;
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
const entries = Object.entries(child).map(([name, schema]) => [name, project(schema, relaxReferences)]);
|
|
67
|
+
if (entries.some(([name, schema]) => schema !== child[name])) {
|
|
68
|
+
projected = Object.fromEntries(entries);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
else if ((SCHEMA_ARRAYS.has(key) || key === "items") && Array.isArray(child)) {
|
|
72
|
+
const schemas = child.map((schema) => project(schema, relaxReferences));
|
|
73
|
+
if (schemas.some((schema, index) => schema !== child[index])) {
|
|
74
|
+
projected = schemas;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
else if (SCHEMA_VALUES.has(key)) {
|
|
78
|
+
projected = project(child, relaxReferences);
|
|
79
|
+
}
|
|
80
|
+
if (projected !== child) {
|
|
81
|
+
result[key] = projected;
|
|
82
|
+
changed.add(key);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (changed.size === 0) {
|
|
86
|
+
return value;
|
|
87
|
+
}
|
|
88
|
+
// Removing an assertion must only relax the advertised schema. Negation, exclusive unions,
|
|
89
|
+
// conditionals and evaluation-dependent limits would otherwise reject previously valid input.
|
|
90
|
+
if (changed.has("not")) {
|
|
91
|
+
delete result.not;
|
|
92
|
+
}
|
|
93
|
+
if (changed.has("if")) {
|
|
94
|
+
delete result.if;
|
|
95
|
+
delete result.then;
|
|
96
|
+
delete result.else;
|
|
97
|
+
}
|
|
98
|
+
if (changed.has("oneOf") && Array.isArray(result.oneOf)) {
|
|
99
|
+
result.allOf = [...(Array.isArray(result.allOf) ? result.allOf : []), { anyOf: result.oneOf }];
|
|
100
|
+
delete result.oneOf;
|
|
101
|
+
}
|
|
102
|
+
if (changed.has("contains")) {
|
|
103
|
+
delete result.maxContains;
|
|
104
|
+
}
|
|
105
|
+
if (propertyPatternsRemoved) {
|
|
106
|
+
delete result.additionalProperties;
|
|
107
|
+
}
|
|
108
|
+
delete result.unevaluatedProperties;
|
|
109
|
+
delete result.unevaluatedItems;
|
|
110
|
+
return result;
|
|
111
|
+
}
|
|
112
|
+
const inputSchemas = new WeakMap();
|
|
113
|
+
/**
|
|
114
|
+
* MCP clients use different regex engines. Omit Unicode property pattern assertions from the
|
|
115
|
+
* immutable advertised input schema; the original Effect schema still validates every tool call.
|
|
116
|
+
*/
|
|
117
|
+
export function mcpInputSchema(schema) {
|
|
118
|
+
const cached = inputSchemas.get(schema);
|
|
119
|
+
if (cached !== undefined) {
|
|
120
|
+
return cached;
|
|
121
|
+
}
|
|
122
|
+
const first = project(schema);
|
|
123
|
+
const result = (first === schema ? schema : project(schema, true));
|
|
124
|
+
inputSchemas.set(schema, result);
|
|
125
|
+
return result;
|
|
126
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { PermissionHolder } from "../../permissions.js";
|
|
2
|
+
import type { CallerContext } from "../caller-context.js";
|
|
3
|
+
import { type McpTool } from "./tools.js";
|
|
4
|
+
export declare const TOOL_LIST_LIMIT = 128;
|
|
5
|
+
export declare const TOOL_LIST_BYTES = 500000;
|
|
6
|
+
/** A tool as `tools/list` lists it, with a confirmable action's card facts in its annotations. */
|
|
7
|
+
export declare function toolDefinition(tool: McpTool): {
|
|
8
|
+
_meta?: Readonly<Record<string, unknown>> | undefined;
|
|
9
|
+
name: string;
|
|
10
|
+
title: string;
|
|
11
|
+
description: string;
|
|
12
|
+
inputSchema: import("../../analyze.js").JsonSchemaObject;
|
|
13
|
+
annotations: import("./tools.js").McpToolAnnotations | {
|
|
14
|
+
"segmentstream/confirmation": import("./confirmation.js").ConfirmationFacts;
|
|
15
|
+
readOnlyHint: boolean;
|
|
16
|
+
destructiveHint?: boolean;
|
|
17
|
+
irreversibleHint?: boolean;
|
|
18
|
+
idempotentHint?: boolean;
|
|
19
|
+
openWorldHint: boolean;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
/** Standard MCP operation definitions; pagination never substitutes search or dispatch tools. */
|
|
23
|
+
export declare function listTools(tools: ReadonlyArray<McpTool>, principal: PermissionHolder, caller: CallerContext, hash: string, cursor?: unknown): {
|
|
24
|
+
tools: Array<ReturnType<typeof toolDefinition>>;
|
|
25
|
+
nextCursor?: string;
|
|
26
|
+
};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { DiscoveryError } from "../discovery.js";
|
|
3
|
+
import { CONFIRMATION_FACTS } from "./confirmation.js";
|
|
4
|
+
import { mcpInputSchema } from "./input-schema.js";
|
|
5
|
+
import { visibleTools } from "./tools.js";
|
|
6
|
+
export const TOOL_LIST_LIMIT = 128;
|
|
7
|
+
export const TOOL_LIST_BYTES = 500_000;
|
|
8
|
+
/** A tool as `tools/list` lists it, with a confirmable action's card facts in its annotations. */
|
|
9
|
+
export function toolDefinition(tool) {
|
|
10
|
+
return {
|
|
11
|
+
name: tool.name,
|
|
12
|
+
title: tool.title,
|
|
13
|
+
description: tool.description,
|
|
14
|
+
inputSchema: mcpInputSchema(tool.inputSchema),
|
|
15
|
+
annotations: tool.confirmation === undefined
|
|
16
|
+
? tool.annotations
|
|
17
|
+
: { ...tool.annotations, [CONFIRMATION_FACTS]: tool.confirmation },
|
|
18
|
+
...(tool._meta === undefined ? {} : { _meta: tool._meta }),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function invalidCursor() {
|
|
22
|
+
throw new DiscoveryError({
|
|
23
|
+
error: "invalid_cursor",
|
|
24
|
+
detail: "The tool-list cursor is invalid or the catalog or permissions changed. Restart tools/list.",
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
/** Standard MCP operation definitions; pagination never substitutes search or dispatch tools. */
|
|
28
|
+
export function listTools(tools, principal, caller, hash, cursor) {
|
|
29
|
+
const visible = visibleTools(tools, principal, caller);
|
|
30
|
+
const scope = createHash("sha256")
|
|
31
|
+
.update(JSON.stringify([
|
|
32
|
+
hash,
|
|
33
|
+
caller.kind,
|
|
34
|
+
[...new Set(principal.permissions)].sort(),
|
|
35
|
+
visible.map(({ name }) => name),
|
|
36
|
+
]))
|
|
37
|
+
.digest("hex");
|
|
38
|
+
let start = 0;
|
|
39
|
+
if (cursor !== undefined) {
|
|
40
|
+
if (typeof cursor !== "string" || cursor.length > 4096 || !/^[A-Za-z0-9_-]+$/.test(cursor)) {
|
|
41
|
+
return invalidCursor();
|
|
42
|
+
}
|
|
43
|
+
let decoded;
|
|
44
|
+
try {
|
|
45
|
+
decoded = JSON.parse(Buffer.from(cursor, "base64url").toString("utf8"));
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
return invalidCursor();
|
|
49
|
+
}
|
|
50
|
+
if (typeof decoded !== "object" ||
|
|
51
|
+
decoded === null ||
|
|
52
|
+
!("scope" in decoded) ||
|
|
53
|
+
!("last" in decoded) ||
|
|
54
|
+
decoded.scope !== scope ||
|
|
55
|
+
typeof decoded.last !== "string") {
|
|
56
|
+
return invalidCursor();
|
|
57
|
+
}
|
|
58
|
+
const last = decoded.last;
|
|
59
|
+
const position = visible.findIndex(({ name }) => name === last);
|
|
60
|
+
if (position < 0) {
|
|
61
|
+
return invalidCursor();
|
|
62
|
+
}
|
|
63
|
+
start = position + 1;
|
|
64
|
+
}
|
|
65
|
+
// Eve 0.85 calls listTools once, unlike AI SDK's tools() which follows nextCursor.
|
|
66
|
+
// Keep deployed runtime clients working; both paths expose the same direct operations.
|
|
67
|
+
if (caller.kind === "runtime") {
|
|
68
|
+
return { tools: visible.slice(start).map(toolDefinition) };
|
|
69
|
+
}
|
|
70
|
+
const selected = [];
|
|
71
|
+
// Leave room for the JSON-RPC envelope and cursor. Never cut a tool's input contract.
|
|
72
|
+
let bytes = 1024;
|
|
73
|
+
for (const tool of visible.slice(start, start + TOOL_LIST_LIMIT)) {
|
|
74
|
+
const item = toolDefinition(tool);
|
|
75
|
+
const added = Buffer.byteLength(JSON.stringify(item)) + 1;
|
|
76
|
+
// An individually larger definition gets its own page rather than disappearing.
|
|
77
|
+
if (selected.length > 0 && bytes + added > TOOL_LIST_BYTES) {
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
selected.push(item);
|
|
81
|
+
bytes += added;
|
|
82
|
+
}
|
|
83
|
+
const last = selected.at(-1);
|
|
84
|
+
return {
|
|
85
|
+
tools: selected,
|
|
86
|
+
...(last !== undefined && start + selected.length < visible.length
|
|
87
|
+
? {
|
|
88
|
+
nextCursor: Buffer.from(JSON.stringify({ scope, last: last.name })).toString("base64url"),
|
|
89
|
+
}
|
|
90
|
+
: {}),
|
|
91
|
+
};
|
|
92
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
import { type DimensionType } from "../../metric-filters.js";
|
|
3
|
+
import type { OntologyManifest, PropertyManifest } from "../../manifest.js";
|
|
4
|
+
/**
|
|
5
|
+
* The metric tools, named as dbt names its MCP tools: `list_metrics` names what the
|
|
6
|
+
* caller may compute, `get_dimensions` what metrics can be grouped and filtered by,
|
|
7
|
+
* `get_dimension_values` the values a dimension takes, and `query_metrics` computes them. A metric
|
|
8
|
+
* is an entity's, `entity.metric`, or the model's, by its bare name. Every answer is the caller's:
|
|
9
|
+
* it names only what they may read, by the same route rules `query_metrics` resolves.
|
|
10
|
+
*/
|
|
11
|
+
/** One metric, as `list_metrics` lists it. */
|
|
12
|
+
export interface Metric {
|
|
13
|
+
readonly name: string;
|
|
14
|
+
readonly label: string;
|
|
15
|
+
readonly unit: "number" | "currency" | "ratio" | "percent";
|
|
16
|
+
/** What it means: its description, conditions and balance rule, or what it reads and aligns. */
|
|
17
|
+
readonly description: string;
|
|
18
|
+
/** The entity whose rows it is computed over; absent for a model metric. */
|
|
19
|
+
readonly entity?: string;
|
|
20
|
+
/** A model metric's inputs: the entity metrics it reads. */
|
|
21
|
+
readonly reads?: ReadonlyArray<string>;
|
|
22
|
+
}
|
|
23
|
+
/** One dimension, as `get_dimensions` lists it: a name `query_metrics` takes as it is. */
|
|
24
|
+
export interface Dimension {
|
|
25
|
+
readonly name: string;
|
|
26
|
+
readonly label: string;
|
|
27
|
+
readonly type: DimensionType;
|
|
28
|
+
readonly description?: string;
|
|
29
|
+
/** A choice field's values. */
|
|
30
|
+
readonly values?: ReadonlyArray<string>;
|
|
31
|
+
}
|
|
32
|
+
/** The most dimensions one answer lists; `search` narrows a longer list. */
|
|
33
|
+
export declare const DIMENSIONS_LIMIT = 300;
|
|
34
|
+
/** How many values `get_dimension_values` returns by default, and at most. */
|
|
35
|
+
export declare const VALUES_DEFAULT = 100;
|
|
36
|
+
export declare const VALUES_LIMIT: 1000;
|
|
37
|
+
export declare const ListMetricsInput: Schema.Struct<{
|
|
38
|
+
readonly search: Schema.optionalKey<Schema.String>;
|
|
39
|
+
}>;
|
|
40
|
+
export declare const GetDimensionsInput: Schema.Struct<{
|
|
41
|
+
readonly metrics: Schema.$Array<Schema.String>;
|
|
42
|
+
readonly search: Schema.optionalKey<Schema.String>;
|
|
43
|
+
}>;
|
|
44
|
+
export declare const GetDimensionValuesInput: Schema.Struct<{
|
|
45
|
+
readonly dimension: Schema.String;
|
|
46
|
+
readonly metrics: Schema.optionalKey<Schema.$Array<Schema.String>>;
|
|
47
|
+
readonly search: Schema.optionalKey<Schema.String>;
|
|
48
|
+
readonly filters: Schema.optionalKey<Schema.$Array<Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
|
|
49
|
+
readonly limit: Schema.optionalKey<Schema.Int>;
|
|
50
|
+
}>;
|
|
51
|
+
/** Every metric the caller may compute, entity metrics first, in declaration order. */
|
|
52
|
+
export declare function listMetrics(manifest: OntologyManifest, permissions: ReadonlyArray<string>, search?: string): ReadonlyArray<Metric>;
|
|
53
|
+
/** Whether the caller may compute anything: the metric tools are listed only then. */
|
|
54
|
+
export declare function hasMetrics(manifest: OntologyManifest, permissions: ReadonlyArray<string>): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* What every given metric can be grouped and filtered by. The candidates are the properties of
|
|
57
|
+
* each metric's entity and of the entities it reaches, by name, or by route where a target is
|
|
58
|
+
* reached in several ways; each is kept only when the shared resolver accepts it for all the given
|
|
59
|
+
* metrics, alignments of model metrics included, and the caller may read every entity it touches.
|
|
60
|
+
*/
|
|
61
|
+
export declare function metricDimensions(manifest: OntologyManifest, permissions: ReadonlyArray<string>, metrics: ReadonlyArray<string>, search?: string): {
|
|
62
|
+
readonly dimensions: ReadonlyArray<Dimension>;
|
|
63
|
+
readonly truncated: boolean;
|
|
64
|
+
} | {
|
|
65
|
+
readonly reason: string;
|
|
66
|
+
};
|
|
67
|
+
/** How `get_dimension_values` answers: from the definition, or by computing a metric. */
|
|
68
|
+
export type ValuesPlan = {
|
|
69
|
+
readonly kind: "options";
|
|
70
|
+
readonly property: PropertyManifest;
|
|
71
|
+
} | {
|
|
72
|
+
readonly kind: "boolean";
|
|
73
|
+
} | {
|
|
74
|
+
readonly kind: "query";
|
|
75
|
+
readonly metrics: ReadonlyArray<string>;
|
|
76
|
+
} | {
|
|
77
|
+
readonly kind: "refused";
|
|
78
|
+
readonly reason: string;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* How to find a dimension's values. A choice field's are its options and a boolean's are true and
|
|
82
|
+
* false. Any other dimension's values are those it takes among a metric's rows: the given metrics,
|
|
83
|
+
* or the first metric the caller may compute that reaches it, its own entity's first.
|
|
84
|
+
*/
|
|
85
|
+
export declare function planDimensionValues(manifest: OntologyManifest, permissions: ReadonlyArray<string>, dimension: string, metrics?: ReadonlyArray<string>): ValuesPlan;
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
import { dimensionTypeOf } from "../../metric-filters.js";
|
|
3
|
+
import { METRIC_QUERY_NAME_PATTERN, inputEntities, resolveMetricRoutes, } from "../../metric-routes.js";
|
|
4
|
+
import { humanize } from "../../names.js";
|
|
5
|
+
import { isAllowed, permissionOf, READ_VERB } from "../../permissions.js";
|
|
6
|
+
import { metricDescription, metricsFor, modelMetricDescription, modelMetricsFor, reachesOf, } from "../../render.js";
|
|
7
|
+
import { METRIC_QUERY_LIMITS } from "../schemas.js";
|
|
8
|
+
/** The record id of a stored entity. */
|
|
9
|
+
const ID = "id";
|
|
10
|
+
/** The most dimensions one answer lists; `search` narrows a longer list. */
|
|
11
|
+
export const DIMENSIONS_LIMIT = 300;
|
|
12
|
+
/** A dimension's description is clipped to this many code points. */
|
|
13
|
+
const DESCRIPTION_LIMIT = 160;
|
|
14
|
+
/** How many values `get_dimension_values` returns by default, and at most. */
|
|
15
|
+
export const VALUES_DEFAULT = 100;
|
|
16
|
+
export const VALUES_LIMIT = METRIC_QUERY_LIMITS.rows;
|
|
17
|
+
const Name = Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(200));
|
|
18
|
+
const Search = Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(200));
|
|
19
|
+
const Metrics = Schema.Array(Name).check(Schema.isMinLength(1), Schema.isMaxLength(METRIC_QUERY_LIMITS.metrics));
|
|
20
|
+
export const ListMetricsInput = Schema.Struct({ search: Schema.optionalKey(Search) });
|
|
21
|
+
export const GetDimensionsInput = Schema.Struct({
|
|
22
|
+
metrics: Metrics,
|
|
23
|
+
search: Schema.optionalKey(Search),
|
|
24
|
+
});
|
|
25
|
+
export const GetDimensionValuesInput = Schema.Struct({
|
|
26
|
+
dimension: Name,
|
|
27
|
+
metrics: Schema.optionalKey(Metrics),
|
|
28
|
+
search: Schema.optionalKey(Search),
|
|
29
|
+
// Checked as query_metrics checks its filters, by the metric query the values come from.
|
|
30
|
+
filters: Schema.optionalKey(Schema.Array(Schema.Json)),
|
|
31
|
+
limit: Schema.optionalKey(Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: VALUES_LIMIT }))),
|
|
32
|
+
});
|
|
33
|
+
function readable(entity, permissions) {
|
|
34
|
+
return isAllowed(permissionOf(entity, READ_VERB), { permissions });
|
|
35
|
+
}
|
|
36
|
+
/** Whether every word of the search occurs in one of the texts, ignoring case. */
|
|
37
|
+
function matches(search, texts) {
|
|
38
|
+
if (search === undefined) {
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
const haystack = texts
|
|
42
|
+
.filter((text) => text !== undefined)
|
|
43
|
+
.join(" ")
|
|
44
|
+
.toLowerCase();
|
|
45
|
+
return search
|
|
46
|
+
.toLowerCase()
|
|
47
|
+
.split(/\s+/)
|
|
48
|
+
.filter((word) => word !== "")
|
|
49
|
+
.every((word) => haystack.includes(word));
|
|
50
|
+
}
|
|
51
|
+
/** At most `maximum` code points of `text`, ending with an ellipsis when it was cut. */
|
|
52
|
+
function clip(text, maximum) {
|
|
53
|
+
const points = Array.from(text.trim());
|
|
54
|
+
return points.length <= maximum ? points.join("") : `${points.slice(0, maximum - 1).join("")}…`;
|
|
55
|
+
}
|
|
56
|
+
/** Every metric the caller may compute, entity metrics first, in declaration order. */
|
|
57
|
+
export function listMetrics(manifest, permissions, search) {
|
|
58
|
+
const listed = [
|
|
59
|
+
...metricsFor(manifest, permissions).map(({ name, entity, metric }) => ({
|
|
60
|
+
name,
|
|
61
|
+
label: metric.label,
|
|
62
|
+
unit: metric.unit,
|
|
63
|
+
description: metricDescription(entity, metric),
|
|
64
|
+
entity: entity.name,
|
|
65
|
+
})),
|
|
66
|
+
...modelMetricsFor(manifest, permissions).map((metric) => ({
|
|
67
|
+
name: metric.name,
|
|
68
|
+
label: metric.label,
|
|
69
|
+
unit: metric.unit,
|
|
70
|
+
description: modelMetricDescription(metric),
|
|
71
|
+
reads: metric.inputs,
|
|
72
|
+
})),
|
|
73
|
+
];
|
|
74
|
+
return listed.filter((metric) => matches(search, [metric.name, metric.label, metric.description]));
|
|
75
|
+
}
|
|
76
|
+
/** Whether the caller may compute anything: the metric tools are listed only then. */
|
|
77
|
+
export function hasMetrics(manifest, permissions) {
|
|
78
|
+
return (metricsFor(manifest, permissions).length > 0 ||
|
|
79
|
+
modelMetricsFor(manifest, permissions).length > 0);
|
|
80
|
+
}
|
|
81
|
+
const UNKNOWN_METRIC = (name) => `${name} is not a metric you may compute; list_metrics names them.`;
|
|
82
|
+
/** The entities a metric is computed over: its entity, or a model metric's input entities. */
|
|
83
|
+
function metricEntities(manifest, permissions, name) {
|
|
84
|
+
const dot = name.indexOf(".");
|
|
85
|
+
if (dot === -1) {
|
|
86
|
+
const metric = (manifest.metrics ?? []).find((candidate) => candidate.name === name);
|
|
87
|
+
const entities = metric === undefined ? [] : inputEntities(metric);
|
|
88
|
+
return entities.length > 0 && entities.every((entity) => readable(entity, permissions))
|
|
89
|
+
? entities
|
|
90
|
+
: { reason: UNKNOWN_METRIC(name) };
|
|
91
|
+
}
|
|
92
|
+
const entity = manifest.entities.find((candidate) => candidate.name === name.slice(0, dot));
|
|
93
|
+
const metric = name.slice(dot + 1);
|
|
94
|
+
return entity !== undefined &&
|
|
95
|
+
readable(entity.name, permissions) &&
|
|
96
|
+
(entity.metrics ?? []).some((candidate) => candidate.name === metric)
|
|
97
|
+
? [entity.name]
|
|
98
|
+
: { reason: UNKNOWN_METRIC(name) };
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* The `id` of a stored entity, which its replication view carries and the shared resolver accepts as
|
|
102
|
+
* a dimension though no property declares it. It is labeled as a property without a label is.
|
|
103
|
+
*/
|
|
104
|
+
function storedIdOf(entity) {
|
|
105
|
+
return entity.source === undefined &&
|
|
106
|
+
!entity.builtIn &&
|
|
107
|
+
!entity.properties.some((property) => property.name === ID)
|
|
108
|
+
? [
|
|
109
|
+
{
|
|
110
|
+
name: ID,
|
|
111
|
+
type: "text",
|
|
112
|
+
label: humanize(ID),
|
|
113
|
+
optional: false,
|
|
114
|
+
unique: true,
|
|
115
|
+
managed: true,
|
|
116
|
+
},
|
|
117
|
+
]
|
|
118
|
+
: [];
|
|
119
|
+
}
|
|
120
|
+
function dimensionsOf(entity, prefix, via) {
|
|
121
|
+
return [...storedIdOf(entity), ...entity.properties].flatMap((property) => {
|
|
122
|
+
const type = dimensionTypeOf(property.type);
|
|
123
|
+
if (type === undefined) {
|
|
124
|
+
return [];
|
|
125
|
+
}
|
|
126
|
+
const description = property.description?.trim() ?? "";
|
|
127
|
+
return [
|
|
128
|
+
{
|
|
129
|
+
name: `${prefix}.${property.name}`,
|
|
130
|
+
label: `${entity.label} · ${property.label}${via === undefined ? "" : ` (via ${via})`}`,
|
|
131
|
+
type,
|
|
132
|
+
...(description === "" ? {} : { description: clip(description, DESCRIPTION_LIMIT) }),
|
|
133
|
+
...(property.options === undefined
|
|
134
|
+
? {}
|
|
135
|
+
: { values: property.options.map((option) => option.value) }),
|
|
136
|
+
},
|
|
137
|
+
];
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* What every given metric can be grouped and filtered by. The candidates are the properties of
|
|
142
|
+
* each metric's entity and of the entities it reaches, by name, or by route where a target is
|
|
143
|
+
* reached in several ways; each is kept only when the shared resolver accepts it for all the given
|
|
144
|
+
* metrics, alignments of model metrics included, and the caller may read every entity it touches.
|
|
145
|
+
*/
|
|
146
|
+
export function metricDimensions(manifest, permissions, metrics, search) {
|
|
147
|
+
const owners = new Set();
|
|
148
|
+
for (const metric of metrics) {
|
|
149
|
+
const entities = metricEntities(manifest, permissions, metric);
|
|
150
|
+
if ("reason" in entities) {
|
|
151
|
+
return entities;
|
|
152
|
+
}
|
|
153
|
+
for (const entity of entities) {
|
|
154
|
+
owners.add(entity);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
const candidates = new Map();
|
|
158
|
+
const add = (target, prefix, via) => {
|
|
159
|
+
const entity = manifest.entities.find((candidate) => candidate.name === target);
|
|
160
|
+
for (const dimension of entity === undefined ? [] : dimensionsOf(entity, prefix, via)) {
|
|
161
|
+
if (!candidates.has(dimension.name)) {
|
|
162
|
+
candidates.set(dimension.name, dimension);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
for (const owner of owners) {
|
|
167
|
+
add(owner, owner, undefined);
|
|
168
|
+
for (const { target, routes, ambiguous } of reachesOf(manifest, owner, permissions)) {
|
|
169
|
+
if (ambiguous) {
|
|
170
|
+
for (const route of routes) {
|
|
171
|
+
add(target, `${owner}.${route}`, route);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
add(target, target, undefined);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
const found = [...candidates.values()].filter((dimension) => {
|
|
180
|
+
const routes = resolveMetricRoutes(manifest, {
|
|
181
|
+
metrics,
|
|
182
|
+
dimensions: [dimension.name],
|
|
183
|
+
});
|
|
184
|
+
return (routes.ok &&
|
|
185
|
+
routes.touched.every((entity) => readable(entity, permissions)) &&
|
|
186
|
+
matches(search, [dimension.name, dimension.label, dimension.description]));
|
|
187
|
+
});
|
|
188
|
+
return {
|
|
189
|
+
dimensions: found.slice(0, DIMENSIONS_LIMIT),
|
|
190
|
+
truncated: found.length > DIMENSIONS_LIMIT,
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
function propertyOf(manifest, identity) {
|
|
194
|
+
const dot = identity.indexOf(".");
|
|
195
|
+
const entity = manifest.entities.find((candidate) => candidate.name === identity.slice(0, dot));
|
|
196
|
+
return entity?.properties.find((property) => property.name === identity.slice(dot + 1));
|
|
197
|
+
}
|
|
198
|
+
function fixed(property) {
|
|
199
|
+
if (property?.options !== undefined) {
|
|
200
|
+
return { kind: "options", property };
|
|
201
|
+
}
|
|
202
|
+
return property?.type === "boolean" ? { kind: "boolean" } : undefined;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* How to find a dimension's values. A choice field's are its options and a boolean's are true and
|
|
206
|
+
* false. Any other dimension's values are those it takes among a metric's rows: the given metrics,
|
|
207
|
+
* or the first metric the caller may compute that reaches it, its own entity's first.
|
|
208
|
+
*/
|
|
209
|
+
export function planDimensionValues(manifest, permissions, dimension, metrics) {
|
|
210
|
+
if (!new RegExp(METRIC_QUERY_NAME_PATTERN).test(dimension)) {
|
|
211
|
+
return {
|
|
212
|
+
kind: "refused",
|
|
213
|
+
reason: `${dimension} is not a dimension name; get_dimensions lists them.`,
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
const segments = dimension.split(".");
|
|
217
|
+
// entity.property names its property directly, without resolving a metric's route.
|
|
218
|
+
const direct = segments.length === 2 && readable(segments[0], permissions)
|
|
219
|
+
? propertyOf(manifest, dimension)
|
|
220
|
+
: undefined;
|
|
221
|
+
const known = fixed(direct);
|
|
222
|
+
if (known !== undefined) {
|
|
223
|
+
return known;
|
|
224
|
+
}
|
|
225
|
+
const own = segments[0];
|
|
226
|
+
const candidates = metrics === undefined
|
|
227
|
+
? listMetrics(manifest, permissions)
|
|
228
|
+
.toSorted((a, b) => Number(b.entity === own) - Number(a.entity === own))
|
|
229
|
+
.map((metric) => [metric.name])
|
|
230
|
+
: [metrics];
|
|
231
|
+
let refusal;
|
|
232
|
+
for (const candidate of candidates) {
|
|
233
|
+
const routes = resolveMetricRoutes(manifest, {
|
|
234
|
+
metrics: candidate,
|
|
235
|
+
dimensions: [dimension],
|
|
236
|
+
});
|
|
237
|
+
if (!routes.ok) {
|
|
238
|
+
refusal ??= routes.reason;
|
|
239
|
+
continue;
|
|
240
|
+
}
|
|
241
|
+
if (!routes.touched.every((entity) => readable(entity, permissions))) {
|
|
242
|
+
continue;
|
|
243
|
+
}
|
|
244
|
+
const identity = routes.entities[0]?.dimensions[0]?.identity;
|
|
245
|
+
return ((identity === undefined ? undefined : fixed(propertyOf(manifest, identity))) ?? {
|
|
246
|
+
kind: "query",
|
|
247
|
+
metrics: candidate,
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
return {
|
|
251
|
+
kind: "refused",
|
|
252
|
+
reason: metrics !== undefined && refusal !== undefined
|
|
253
|
+
? refusal
|
|
254
|
+
: direct === undefined && refusal !== undefined && candidates.length > 0
|
|
255
|
+
? refusal
|
|
256
|
+
: `No metric you may compute reaches ${dimension}, so its values cannot be listed.`,
|
|
257
|
+
};
|
|
258
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Observe the stateless transport at the HTTP boundary, including authentication failures,
|
|
3
|
+
* preflights, unsupported HTTP methods and failures to initialize the service runtime.
|
|
4
|
+
*/
|
|
5
|
+
export declare function observeMcpRequest(request: Request): ((response: Response, requestId: string, durationMs?: number) => Promise<void>) | undefined;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { MCP_PATH } from "./server.js";
|
|
2
|
+
function isObject(value) {
|
|
3
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Observe the stateless transport at the HTTP boundary, including authentication failures,
|
|
7
|
+
* preflights, unsupported HTTP methods and failures to initialize the service runtime.
|
|
8
|
+
*/
|
|
9
|
+
export function observeMcpRequest(request) {
|
|
10
|
+
if (new URL(request.url).pathname !== MCP_PATH) {
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
const started = performance.now();
|
|
14
|
+
// Consume the clone as well as the original: diagnostics must not disturb the request body.
|
|
15
|
+
const message = request.method === "POST"
|
|
16
|
+
? request
|
|
17
|
+
.clone()
|
|
18
|
+
.json()
|
|
19
|
+
.catch(() => undefined)
|
|
20
|
+
: Promise.resolve();
|
|
21
|
+
const origin = request.headers.get("origin");
|
|
22
|
+
const originHost = origin !== null && URL.canParse(origin) ? new URL(origin).host : null;
|
|
23
|
+
return async (response, requestId, durationMs = Math.round((performance.now() - started) * 100) / 100) => {
|
|
24
|
+
const body = await message;
|
|
25
|
+
const rpcMethod = isObject(body) && typeof body.method === "string" ? body.method : null;
|
|
26
|
+
// Log SSE at response start. Cloning/reading it would delay headers and buffer every heartbeat.
|
|
27
|
+
const streaming = response.headers.get("content-type")?.startsWith("text/event-stream");
|
|
28
|
+
const bytes = streaming ? undefined : await response.clone().arrayBuffer();
|
|
29
|
+
let toolCount = null;
|
|
30
|
+
if (rpcMethod === "tools/list" && response.status === 200 && bytes && bytes.byteLength > 0) {
|
|
31
|
+
const payload = JSON.parse(new TextDecoder().decode(bytes));
|
|
32
|
+
if (isObject(payload) && isObject(payload.result) && Array.isArray(payload.result.tools)) {
|
|
33
|
+
toolCount = payload.result.tools.length;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
console.info(JSON.stringify({
|
|
37
|
+
event: "ontology.mcp.request",
|
|
38
|
+
requestId,
|
|
39
|
+
httpMethod: request.method,
|
|
40
|
+
rpcMethod,
|
|
41
|
+
status: response.status,
|
|
42
|
+
durationMs,
|
|
43
|
+
responseBytes: bytes?.byteLength ?? null,
|
|
44
|
+
toolCount,
|
|
45
|
+
protocolVersion: request.headers.get("mcp-protocol-version"),
|
|
46
|
+
originPresent: origin !== null,
|
|
47
|
+
originHost,
|
|
48
|
+
authKind: /^Bearer\s+\S/i.test(request.headers.get("authorization") ?? "")
|
|
49
|
+
? "bearer"
|
|
50
|
+
: "none",
|
|
51
|
+
}));
|
|
52
|
+
};
|
|
53
|
+
}
|