@opengeni/contracts 0.50.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent-authored-durable-text.d.ts +70 -0
- package/dist/agent-config.d.ts +869 -0
- package/dist/agent-instruction-changes.d.ts +110 -0
- package/dist/agent-learning.d.ts +243 -0
- package/dist/agent-topology.d.ts +292 -0
- package/dist/allowance-refusal.d.ts +9 -0
- package/dist/allowance-refusal.js +50 -0
- package/dist/allowance-refusal.js.map +1 -0
- package/dist/analytics-consent-report.d.ts +19 -0
- package/dist/analytics-consent-report.js +10 -0
- package/dist/analytics-consent-report.js.map +1 -0
- package/dist/api-key-presets.d.ts +19 -0
- package/dist/artifact-catalog.d.ts +161 -0
- package/dist/artifacts.d.ts +135 -11
- package/dist/atlassian-native-retirement.d.ts +16 -0
- package/dist/atlassian-native-retirement.js +30 -0
- package/dist/atlassian-native-retirement.js.map +1 -0
- package/dist/atlassian.d.ts +2 -0
- package/dist/atlassian.js +26 -12
- package/dist/browser-storage.d.ts +5 -0
- package/dist/browser-storage.js +9 -0
- package/dist/browser-storage.js.map +1 -0
- package/dist/bundled-skills.d.ts +40 -0
- package/dist/chunk-2ACYHZFB.js +292 -0
- package/dist/chunk-2ACYHZFB.js.map +1 -0
- package/dist/chunk-2VORLN2R.js +353 -0
- package/dist/chunk-2VORLN2R.js.map +1 -0
- package/dist/{chunk-Y3MLSLB4.js → chunk-3SIZGL3O.js} +42 -30
- package/dist/chunk-3SIZGL3O.js.map +1 -0
- package/dist/chunk-46KLD2UH.js +186 -0
- package/dist/chunk-46KLD2UH.js.map +1 -0
- package/dist/chunk-4JGHSSB7.js +11 -0
- package/dist/chunk-4JGHSSB7.js.map +1 -0
- package/dist/{chunk-M5ZGRVIQ.js → chunk-5IXYF6XN.js} +14 -5
- package/dist/chunk-5IXYF6XN.js.map +1 -0
- package/dist/chunk-BCS7WHCK.js +139 -0
- package/dist/chunk-BCS7WHCK.js.map +1 -0
- package/dist/chunk-EK7NDGFR.js +128 -0
- package/dist/chunk-EK7NDGFR.js.map +1 -0
- package/dist/{chunk-5UDNP7AO.js → chunk-FZ6BXQHL.js} +78 -38
- package/dist/chunk-FZ6BXQHL.js.map +1 -0
- package/dist/{chunk-CM6BMECR.js → chunk-GRG7PHWQ.js} +2 -1
- package/dist/chunk-GRG7PHWQ.js.map +1 -0
- package/dist/chunk-KHHZTBP7.js +11 -0
- package/dist/chunk-KHHZTBP7.js.map +1 -0
- package/dist/chunk-KR2V42UZ.js +187 -0
- package/dist/chunk-KR2V42UZ.js.map +1 -0
- package/dist/chunk-MZLBPKFE.js +168 -0
- package/dist/chunk-MZLBPKFE.js.map +1 -0
- package/dist/{chunk-LW7OH6CS.js → chunk-NRMCVHAU.js} +6 -5
- package/dist/chunk-NRMCVHAU.js.map +1 -0
- package/dist/{chunk-TZ6YEYN4.js → chunk-NVJMJWLL.js} +3 -1
- package/dist/chunk-NVJMJWLL.js.map +1 -0
- package/dist/chunk-O77VSFYZ.js +70 -0
- package/dist/chunk-O77VSFYZ.js.map +1 -0
- package/dist/chunk-PX3VCKAU.js +29 -0
- package/dist/chunk-PX3VCKAU.js.map +1 -0
- package/dist/chunk-QR5D2IQC.js +61 -0
- package/dist/chunk-QR5D2IQC.js.map +1 -0
- package/dist/chunk-RJ76DRPO.js +117 -0
- package/dist/chunk-RJ76DRPO.js.map +1 -0
- package/dist/chunk-RKX3NQYS.js +28 -0
- package/dist/chunk-RKX3NQYS.js.map +1 -0
- package/dist/{chunk-JBCIY7QD.js → chunk-SIOU2K4U.js} +45 -22
- package/dist/chunk-SIOU2K4U.js.map +1 -0
- package/dist/chunk-TSCDAGET.js +75 -0
- package/dist/chunk-TSCDAGET.js.map +1 -0
- package/dist/{chunk-LSB7GRLG.js → chunk-TXTQIYCV.js} +15 -11
- package/dist/chunk-TXTQIYCV.js.map +1 -0
- package/dist/chunk-X7ETVO4P.js +26544 -0
- package/dist/chunk-X7ETVO4P.js.map +1 -0
- package/dist/{chunk-CADSX6UN.js → chunk-Y3KNXVTD.js} +2 -2
- package/dist/chunk-YBW5JSA3.js +251 -0
- package/dist/chunk-YBW5JSA3.js.map +1 -0
- package/dist/chunk-YRXAWWCU.js +45 -0
- package/dist/chunk-YRXAWWCU.js.map +1 -0
- package/dist/claude-provider-account-authority.d.ts +18 -0
- package/dist/claude-subscription-oauth.d.ts +42 -0
- package/dist/claude-subscription-usage.d.ts +159 -0
- package/dist/client-error-report.d.ts +109 -0
- package/dist/client-error-report.js +87 -0
- package/dist/client-error-report.js.map +1 -0
- package/dist/code-search.d.ts +52 -0
- package/dist/code-search.js +40 -0
- package/dist/code-search.js.map +1 -0
- package/dist/company-brain-governed-writes.d.ts +475 -0
- package/dist/company-brain.d.ts +336 -0
- package/dist/company-profile.d.ts +566 -0
- package/dist/connect.d.ts +325 -0
- package/dist/connect.js +191 -0
- package/dist/connect.js.map +1 -0
- package/dist/connection-account-label.d.ts +2 -0
- package/dist/connection-account-label.js +35 -0
- package/dist/connection-account-label.js.map +1 -0
- package/dist/connection-authority.d.ts +193 -0
- package/dist/connection-authority.js +50 -0
- package/dist/connection-authority.js.map +1 -0
- package/dist/connector-attachments.d.ts +95 -0
- package/dist/connector-attachments.js +51 -0
- package/dist/connector-attachments.js.map +1 -0
- package/dist/connector-tool-permissions.d.ts +73 -0
- package/dist/direct-model-provider.d.ts +36 -0
- package/dist/editable-artifact-codec-registry.d.ts +16 -7
- package/dist/editable-artifact-codec-registry.js +18 -8
- package/dist/editable-artifact-committed-transaction.d.ts +2 -2
- package/dist/editable-artifact-committed-transaction.js +2 -2
- package/dist/editable-artifact-live.d.ts +11 -12
- package/dist/editable-artifact-live.js +110 -45
- package/dist/editable-artifact-live.js.map +1 -1
- package/dist/editable-artifact-serialized-commit.d.ts +2 -1
- package/dist/editable-artifact-serialized-commit.js +8 -7
- package/dist/editable-artifact-versions.d.ts +20 -5
- package/dist/editable-artifact-versions.js +23 -5
- package/dist/editable-artifacts.d.ts +2 -0
- package/dist/editable-artifacts.js +47 -35
- package/dist/external-identities.d.ts +784 -0
- package/dist/external-identities.js +44 -0
- package/dist/external-identities.js.map +1 -0
- package/dist/feedback.d.ts +51 -0
- package/dist/github-repository-contracts.d.ts +36 -0
- package/dist/github-repository-contracts.js +59 -0
- package/dist/github-repository-contracts.js.map +1 -0
- package/dist/github-repository.d.ts +14 -0
- package/dist/github-repository.js +36 -0
- package/dist/github-repository.js.map +1 -0
- package/dist/google-drive.d.ts +90 -1
- package/dist/google-drive.js +90 -16
- package/dist/google-drive.js.map +1 -1
- package/dist/governed-learning-activation.d.ts +154 -0
- package/dist/governed-learning-evaluator.d.ts +152 -0
- package/dist/host-mcp-bindings.d.ts +326 -0
- package/dist/host-mcp-bindings.js +252 -0
- package/dist/host-mcp-bindings.js.map +1 -0
- package/dist/image-generation.d.ts +1 -0
- package/dist/index.d.ts +32396 -11386
- package/dist/index.js +2198 -164
- package/dist/insights-usage.d.ts +877 -0
- package/dist/insights-usage.js +509 -0
- package/dist/insights-usage.js.map +1 -0
- package/dist/interaction.d.ts +344 -0
- package/dist/knowledge-entries.d.ts +982 -0
- package/dist/knowledge-preparation.d.ts +237 -0
- package/dist/knowledge.d.ts +197 -0
- package/dist/managed-auth-session-sets.d.ts +241 -0
- package/dist/managed-auth-session-sets.js +191 -0
- package/dist/managed-auth-session-sets.js.map +1 -0
- package/dist/managed-sign-in-methods.d.ts +56 -0
- package/dist/managed-sign-in-methods.js +46 -0
- package/dist/managed-sign-in-methods.js.map +1 -0
- package/dist/mcp-catalog-limits.d.ts +2 -0
- package/dist/mcp-endpoint.d.ts +7 -0
- package/dist/mcp-endpoint.js +9 -0
- package/dist/mcp-endpoint.js.map +1 -0
- package/dist/mcp-oauth.d.ts +71 -0
- package/dist/modal-native-proof-v2.d.ts +587 -0
- package/dist/modal-native-proof-v2.js +37 -0
- package/dist/modal-native-proof-v2.js.map +1 -0
- package/dist/model-availability.d.ts +15 -0
- package/dist/model-connection-access.d.ts +24 -0
- package/dist/model-context-inspector.d.ts +329 -0
- package/dist/model-display.d.ts +38 -0
- package/dist/model-display.js +134 -0
- package/dist/model-display.js.map +1 -0
- package/dist/model-picker-order.d.ts +25 -0
- package/dist/model-picker-order.js +42 -0
- package/dist/model-picker-order.js.map +1 -0
- package/dist/organization-access.d.ts +231 -0
- package/dist/organization-access.js +34 -0
- package/dist/organization-access.js.map +1 -0
- package/dist/organization-integration-policy.d.ts +27 -0
- package/dist/organization-membership-lifecycle.d.ts +1022 -0
- package/dist/organization-model-usage.d.ts +146 -0
- package/dist/organization-model-usage.js +67 -0
- package/dist/organization-model-usage.js.map +1 -0
- package/dist/organization-recovery.d.ts +337 -0
- package/dist/organization-recovery.js +37 -0
- package/dist/organization-recovery.js.map +1 -0
- package/dist/organization-usage.d.ts +138 -0
- package/dist/permissions.d.ts +54 -0
- package/dist/personal-github.d.ts +320 -0
- package/dist/personal-github.js +222 -0
- package/dist/personal-github.js.map +1 -0
- package/dist/plugin-discovery.d.ts +35 -0
- package/dist/plugin-discovery.js +7 -0
- package/dist/plugin-discovery.js.map +1 -0
- package/dist/preference-registry.d.ts +44 -1
- package/dist/product-analytics.d.ts +113 -0
- package/dist/product-lifecycle-facts.d.ts +73 -0
- package/dist/remember.d.ts +350 -0
- package/dist/retained-output.d.ts +8 -0
- package/dist/sandbox-file-artifacts.d.ts +57 -0
- package/dist/sandbox-provider-command.d.ts +113 -0
- package/dist/sandbox-recovery.d.ts +146 -0
- package/dist/sandbox-snapshots.d.ts +39 -0
- package/dist/session-final-reply.d.ts +6 -0
- package/dist/session-final-reply.js +9 -0
- package/dist/session-final-reply.js.map +1 -0
- package/dist/session-goal-reports.d.ts +21 -0
- package/dist/session-history-import.d.ts +947 -0
- package/dist/session-list-entries.d.ts +4 -0
- package/dist/session-list-entries.js +51 -0
- package/dist/session-list-entries.js.map +1 -0
- package/dist/session-mcp-projections.d.ts +215 -0
- package/dist/session-message-search.d.ts +68 -0
- package/dist/session-titles.d.ts +68 -0
- package/dist/session-titles.js +25 -0
- package/dist/session-titles.js.map +1 -0
- package/dist/session-topology-primitives.d.ts +22 -0
- package/dist/signup-attribution.d.ts +39 -0
- package/dist/site-request-headers.test.d.ts +1 -0
- package/dist/site-session-http.d.ts +11 -0
- package/dist/site-session-http.js +11 -0
- package/dist/site-session-http.js.map +1 -0
- package/dist/skill-catalog-context.d.ts +7 -0
- package/dist/skill-files.d.ts +12 -0
- package/dist/skill-metadata.d.ts +9 -0
- package/dist/skill-use.d.ts +61 -0
- package/dist/skills.d.ts +185 -0
- package/dist/slack-bot-scopes.d.ts +46 -21
- package/dist/slack-bot-scopes.js +14 -3
- package/dist/slack-rest-mcp.d.ts +31 -0
- package/dist/slack-rest-mcp.js +19 -0
- package/dist/slack-rest-mcp.js.map +1 -0
- package/dist/spreadsheet-artifact-commands.d.ts +2 -3
- package/dist/spreadsheet-artifact-commands.js +4 -2
- package/dist/spreadsheet-artifact-query.js +3 -2
- package/dist/subscription-account-pools.d.ts +292 -0
- package/dist/task-notes.d.ts +42 -1
- package/dist/tool-catalog.d.ts +286 -0
- package/dist/tool-result-spill.d.ts +16 -0
- package/dist/usage-allowances.d.ts +285 -0
- package/dist/usage-allowances.js +49 -0
- package/dist/usage-allowances.js.map +1 -0
- package/dist/video-generation.d.ts +3 -0
- package/dist/video-generation.js +1 -1
- package/dist/work-claims.d.ts +411 -0
- package/dist/workspace-instruction-policies.d.ts +94 -0
- package/dist/workspace-integration-wire.d.ts +36 -0
- package/dist/workspace-integration-wire.js +23 -0
- package/dist/workspace-integration-wire.js.map +1 -0
- package/dist/workspace-integrations.d.ts +948 -0
- package/dist/workspace-learning-administration.d.ts +289 -0
- package/dist/workspace-learning-policy.d.ts +1 -1
- package/dist/workspace-state.d.ts +85 -416
- package/dist/xai-provider-account-authority.d.ts +3 -0
- package/dist/xai-provider-account-authority.js +1 -1
- package/package.json +134 -1
- package/src/agent-authored-durable-text.ts +116 -0
- package/src/agent-config.ts +1527 -0
- package/src/agent-instruction-changes.ts +98 -0
- package/src/agent-learning.ts +161 -0
- package/src/agent-topology.ts +69 -0
- package/src/allowance-refusal.ts +81 -0
- package/src/analytics-consent-report.ts +20 -0
- package/src/api-key-presets.ts +25 -0
- package/src/artifact-catalog.ts +60 -0
- package/src/artifacts.ts +146 -18
- package/src/atlassian-native-retirement.ts +33 -0
- package/src/browser-storage.ts +10 -0
- package/src/bundled-skills.ts +73 -0
- package/src/claude-provider-account-authority.ts +12 -0
- package/src/claude-subscription-oauth.ts +62 -0
- package/src/claude-subscription-usage.ts +59 -0
- package/src/client-error-report.ts +184 -0
- package/src/code-search.ts +105 -0
- package/src/company-brain-governed-writes.ts +356 -0
- package/src/company-brain.ts +201 -0
- package/src/company-profile.ts +167 -1
- package/src/connect.ts +202 -0
- package/src/connection-account-label.ts +46 -0
- package/src/connection-authority.ts +213 -0
- package/src/connector-attachments.ts +327 -0
- package/src/connector-tool-permissions.ts +60 -0
- package/src/direct-model-provider.ts +98 -0
- package/src/editable-artifact-codec-registry.ts +55 -17
- package/src/editable-artifact-committed-transaction.ts +44 -31
- package/src/editable-artifact-live.ts +123 -57
- package/src/editable-artifact-serialized-commit.ts +2 -1
- package/src/editable-artifact-versions.ts +26 -5
- package/src/editable-artifacts.ts +2 -0
- package/src/external-identities.ts +285 -0
- package/src/feedback.ts +39 -0
- package/src/github-repository-contracts.ts +85 -0
- package/src/github-repository.ts +59 -0
- package/src/google-drive.ts +76 -4
- package/src/governed-learning-activation.ts +191 -0
- package/src/governed-learning-evaluator.ts +176 -0
- package/src/host-mcp-bindings.ts +298 -0
- package/src/image-generation.ts +8 -2
- package/src/index.ts +7093 -1466
- package/src/insights-usage.ts +679 -0
- package/src/interaction.ts +220 -5
- package/src/knowledge-entries.ts +375 -0
- package/src/knowledge-preparation.ts +50 -0
- package/src/knowledge.ts +134 -6
- package/src/managed-auth-session-sets.ts +253 -0
- package/src/managed-sign-in-methods.ts +37 -0
- package/src/mcp-catalog-limits.ts +2 -0
- package/src/mcp-endpoint.ts +30 -0
- package/src/mcp-oauth.ts +66 -0
- package/src/modal-native-proof-v2.ts +398 -0
- package/src/model-availability.ts +22 -0
- package/src/model-connection-access.ts +17 -0
- package/src/model-context-inspector.ts +139 -0
- package/src/model-display.ts +195 -0
- package/src/model-picker-order.ts +97 -0
- package/src/organization-access.ts +176 -0
- package/src/organization-integration-policy.ts +54 -0
- package/src/organization-membership-lifecycle.ts +559 -0
- package/src/organization-model-usage.ts +72 -0
- package/src/organization-recovery.ts +186 -0
- package/src/organization-usage.ts +79 -0
- package/src/permissions.ts +58 -0
- package/src/personal-github.ts +267 -0
- package/src/plugin-discovery.ts +33 -0
- package/src/preference-registry.ts +20 -1
- package/src/product-analytics.ts +253 -0
- package/src/product-lifecycle-facts.ts +121 -0
- package/src/remember.ts +243 -0
- package/src/retained-output.ts +20 -3
- package/src/sandbox-file-artifacts.ts +73 -0
- package/src/sandbox-provider-command.ts +82 -0
- package/src/sandbox-recovery.ts +116 -0
- package/src/sandbox-snapshots.ts +142 -0
- package/src/session-final-reply.ts +16 -0
- package/src/session-goal-reports.ts +55 -0
- package/src/session-history-import.ts +159 -0
- package/src/session-list-entries.ts +91 -0
- package/src/session-mcp-projections.ts +273 -0
- package/src/session-message-search.ts +54 -0
- package/src/session-titles.ts +467 -0
- package/src/session-topology-primitives.ts +21 -0
- package/src/signup-attribution.ts +81 -0
- package/src/site-request-headers.test.ts +28 -0
- package/src/site-session-http.ts +63 -0
- package/src/skill-catalog-context.ts +50 -0
- package/src/skill-files.ts +52 -0
- package/src/skill-metadata.ts +40 -0
- package/src/skill-use.ts +77 -0
- package/src/skills.ts +136 -0
- package/src/slack-bot-scopes.ts +106 -42
- package/src/slack-rest-mcp.ts +194 -0
- package/src/spreadsheet-artifact-commands.ts +12 -13
- package/src/subscription-account-pools.ts +44 -0
- package/src/task-notes.ts +14 -1
- package/src/tool-catalog.ts +155 -0
- package/src/tool-result-spill.ts +35 -0
- package/src/usage-allowances.ts +187 -0
- package/src/work-claims.ts +266 -0
- package/src/workspace-instruction-policies.ts +31 -0
- package/src/workspace-integration-wire.ts +99 -0
- package/src/workspace-integrations.ts +640 -0
- package/src/workspace-learning-administration.ts +88 -0
- package/src/workspace-learning-policy.ts +4 -3
- package/src/workspace-state.ts +16 -126
- package/src/xai-provider-account-authority.ts +1 -0
- package/dist/chunk-5UDNP7AO.js.map +0 -1
- package/dist/chunk-BVGIYW7D.js +0 -11
- package/dist/chunk-BVGIYW7D.js.map +0 -1
- package/dist/chunk-CM6BMECR.js.map +0 -1
- package/dist/chunk-JBCIY7QD.js.map +0 -1
- package/dist/chunk-LSB7GRLG.js.map +0 -1
- package/dist/chunk-LW7OH6CS.js.map +0 -1
- package/dist/chunk-M5ZGRVIQ.js.map +0 -1
- package/dist/chunk-Q6A7XT2N.js +0 -16734
- package/dist/chunk-Q6A7XT2N.js.map +0 -1
- package/dist/chunk-TZ6YEYN4.js.map +0 -1
- package/dist/chunk-Y3MLSLB4.js.map +0 -1
- /package/dist/{chunk-CADSX6UN.js.map → chunk-Y3KNXVTD.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/external-identities.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { Permission } from \"./permissions\";\n\n// External identifiers are opaque, case-sensitive strings. In particular a\n// native-looking identifier is still host data, never a native subject claim.\n// Bound bytes, not just JS code units: these values share a PostgreSQL B-tree\n// index entry. Never normalize/truncate an identifier to make it fit, and reject\n// text that the driver would replace or PostgreSQL cannot represent.\nconst encoder = new TextEncoder();\nfunction opaqueText(maxBytes: number) {\n return z\n .string()\n .min(1)\n .max(maxBytes)\n .refine(\n (value) =>\n !value.includes(\"\\0\") &&\n !/[\\uD800-\\uDFFF]/u.test(value) &&\n encoder.encode(value).byteLength <= maxBytes,\n {\n message: `Identifier must be valid PostgreSQL Unicode text of at most ${maxBytes} UTF-8 bytes`,\n },\n );\n}\nconst externalId = opaqueText(1024);\nconst source = opaqueText(200);\nconst externalSubject = z\n .string()\n .regex(/^external_user:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$(?![\\s\\S])/);\nconst nativeSubject = z\n .string()\n .min(1)\n .max(1024)\n .regex(/^user:[^\\r\\n]+$(?![\\s\\S])/);\nexport const ExternalIdentityReference = z\n .object({\n externalId,\n source: source.default(\"default\"),\n })\n .strict();\nexport type ExternalIdentityReference = z.infer<typeof ExternalIdentityReference>;\n\nexport const AddExternalWorkspaceMemberRequest = z\n .object({\n identity: ExternalIdentityReference,\n permissions: z.array(Permission).min(1).max(Permission.options.length),\n /** Opt-in durable operation identity; unkeyed legacy requests are not cancellable. */\n operationId: z.string().uuid().optional(),\n })\n .strict();\nexport type AddExternalWorkspaceMemberRequest = z.infer<typeof AddExternalWorkspaceMemberRequest>;\n\n/** Content-free service lookup, including identities which can no longer act. */\nexport const ExternalIdentityLookup = z.discriminatedUnion(\"found\", [\n z.object({ found: z.literal(false) }).strict(),\n z\n .object({\n found: z.literal(true),\n subjectId: externalSubject,\n organizationMembershipId: z.string().uuid(),\n identityStatus: z.enum([\"active\", \"disabled\", \"revoked\"]),\n identityAuthorizationRevision: z.number().int().positive().safe(),\n membershipStatus: z.enum([\"provisioning\", \"active\", \"suspended\", \"revoked\"]),\n membershipAuthorizationRevision: z.number().int().positive().safe(),\n })\n .strict(),\n]);\nexport type ExternalIdentityLookup = z.infer<typeof ExternalIdentityLookup>;\n\n/** Terminal withdrawal of this external member's workspace access, also fencing\n * an exact earlier onboarding operation whether or not it has reached the API. */\nexport const CancelExternalWorkspaceMemberGrantRequest = z\n .object({\n operationId: z.string().uuid(),\n cancelGrantOperationId: z.string().uuid(),\n })\n .strict()\n .refine((value) => value.operationId !== value.cancelGrantOperationId, {\n message: \"Revocation and grant must use different operation identities\",\n });\nexport type CancelExternalWorkspaceMemberGrantRequest = z.infer<\n typeof CancelExternalWorkspaceMemberGrantRequest\n>;\nexport const CancelExternalWorkspaceMemberGrantResponse = z\n .object({\n removed: z.boolean(),\n replay: z.boolean(),\n fencedGrantOperationId: z.string().uuid(),\n })\n .strict();\nexport type CancelExternalWorkspaceMemberGrantResponse = z.infer<\n typeof CancelExternalWorkspaceMemberGrantResponse\n>;\n\n/** Replace an existing external member's permissions in one shared workspace.\n * Keyed and idempotent like a grant; narrowing forces live authority to\n * re-check but never cancels or tears down work. */\nexport const UpdateExternalWorkspaceMemberRequest = z\n .object({\n permissions: z.array(Permission).min(1).max(Permission.options.length),\n operationId: z.string().uuid(),\n })\n .strict();\nexport type UpdateExternalWorkspaceMemberRequest = z.infer<\n typeof UpdateExternalWorkspaceMemberRequest\n>;\nexport const UpdateExternalWorkspaceMemberResponse = z\n .object({\n subjectId: z.string(),\n organizationMembershipId: z.string().uuid(),\n permissions: z.array(Permission),\n /** True when a previously held permission was removed. */\n narrowed: z.boolean(),\n replay: z.boolean(),\n })\n .strict();\nexport type UpdateExternalWorkspaceMemberResponse = z.infer<\n typeof UpdateExternalWorkspaceMemberResponse\n>;\n\n/** Uses the organization membership ID returned by lazy identity admission.\n * Reactivation restores admission only, not revoked work or workspace grants. */\nexport const UpdateExternalIdentityMembershipRequest = z\n .object({\n kind: z.enum([\"suspend\", \"reactivate\", \"offboard\"]),\n expectedAuthorizationRevision: z.number().int().positive().safe(),\n operationId: z.string().uuid(),\n reason: z.string().max(512).optional(),\n })\n .strict();\nexport type UpdateExternalIdentityMembershipRequest = z.infer<\n typeof UpdateExternalIdentityMembershipRequest\n>;\n\nexport const ExternalActorSelection = z.discriminatedUnion(\"mode\", [\n z.object({ mode: z.literal(\"external\"), identity: ExternalIdentityReference }).strict(),\n z\n .object({\n mode: z.literal(\"linked_native\"),\n identity: ExternalIdentityReference,\n linkId: z.string().uuid(),\n expectedLinkRevision: z.number().int().positive().safe(),\n })\n .strict(),\n]);\nexport type ExternalActorSelection = z.infer<typeof ExternalActorSelection>;\n\nexport const ExternalIdentity = z\n .object({\n id: z.string().uuid(),\n accountId: z.string().uuid(),\n source,\n externalId,\n subjectId: externalSubject,\n organizationMembershipId: z.string().uuid(),\n personalWorkspaceId: z.string().uuid(),\n status: z.enum([\"active\", \"disabled\", \"revoked\"]),\n authorizationRevision: z.number().int().positive().safe(),\n })\n .strict();\nexport type ExternalIdentity = z.infer<typeof ExternalIdentity>;\n\n// Audit attribution, not authentication. Only the canonical access resolver\n// may establish provenance; accepting this JSON from a browser proves nothing.\nexport const ExternalActorAttribution = z\n .object({\n accountId: z.string().uuid(),\n authenticatingApiKeyId: z.string().uuid(),\n externalIdentityId: z.string().uuid(),\n externalSubjectId: externalSubject,\n externalAuthorizationRevision: z.number().int().positive().safe(),\n effectiveSubjectId: z.string().min(1).max(1024),\n actingMode: z.enum([\"external\", \"linked_native\"]),\n linkId: z.string().uuid().optional(),\n linkRevision: z.number().int().positive().safe().optional(),\n })\n .strict()\n .superRefine((value, context) => {\n if (value.actingMode === \"external\") {\n if (\n value.effectiveSubjectId !== value.externalSubjectId ||\n value.linkId !== undefined ||\n value.linkRevision !== undefined\n ) {\n context.addIssue({\n code: \"custom\",\n message: \"External mode cannot delegate native identity\",\n });\n }\n } else if (\n !value.linkId ||\n !value.linkRevision ||\n !nativeSubject.safeParse(value.effectiveSubjectId).success\n ) {\n context.addIssue({\n code: \"custom\",\n message: \"Linked mode requires exact native delegation provenance\",\n });\n }\n });\nexport type ExternalActorAttribution = z.infer<typeof ExternalActorAttribution>;\n\n/** Server-signed/encrypted continuation data, never sufficient live authority. */\nexport const ExternalActorContinuation = z\n .object({\n identity: ExternalIdentityReference,\n actor: ExternalActorAttribution,\n })\n .strict();\nexport type ExternalActorContinuation = z.infer<typeof ExternalActorContinuation>;\n\nexport const ExternalIdentityLink = z\n .object({\n id: z.string().uuid(),\n accountId: z.string().uuid(),\n externalIdentityId: z.string().uuid(),\n externalIdentity: ExternalIdentityReference.optional(),\n nativeSubjectId: nativeSubject.nullable(),\n status: z.enum([\"pending\", \"active\", \"revoked\", \"expired\"]),\n revision: z.number().int().positive().safe(),\n permissions: z.array(Permission).max(Permission.options.length),\n expiresAt: z.string().datetime({ offset: true }).nullable(),\n })\n .strict()\n .refine(\n (value) => value.status !== \"active\" || value.nativeSubjectId !== null,\n \"An active link requires a confirmed native identity\",\n );\nexport type ExternalIdentityLink = z.infer<typeof ExternalIdentityLink>;\n\nexport const ExternalIdentityLinkPage = z\n .object({\n links: z.array(ExternalIdentityLink).max(50),\n nextCursor: z.string().uuid().nullable(),\n })\n .strict();\nexport type ExternalIdentityLinkPage = z.infer<typeof ExternalIdentityLinkPage>;\n\n/** A native confirmation may narrow this request, never broaden it. The\n * challenge is delivered once to the host and is not an authentication token. */\nexport const BeginExternalIdentityLinkRequest = z\n .object({\n permissions: z.array(Permission).min(1).max(Permission.options.length),\n expiresAt: z.string().datetime({ offset: true }).nullable().default(null),\n })\n .strict();\nexport type BeginExternalIdentityLinkRequest = z.input<typeof BeginExternalIdentityLinkRequest>;\nexport const ConfirmExternalIdentityLinkRequest = z\n .object({\n challenge: z.string().regex(/^[A-Za-z0-9_-]{43}$/),\n expectedRevision: z.number().int().positive().safe(),\n permissions: z.array(Permission).min(1).max(Permission.options.length),\n })\n .strict();\nexport type ConfirmExternalIdentityLinkRequest = z.infer<typeof ConfirmExternalIdentityLinkRequest>;\nexport const BeginExternalIdentityLinkResponse = z\n .object({\n link: ExternalIdentityLink,\n challenge: z.string().regex(/^[A-Za-z0-9_-]{43}$/),\n confirmBefore: z.string().datetime({ offset: true }),\n })\n .strict();\nexport type BeginExternalIdentityLinkResponse = z.infer<typeof BeginExternalIdentityLinkResponse>;\nexport const ExternalIdentityLinkPreview = z\n .object({\n link: ExternalIdentityLink,\n externalIdentity: ExternalIdentityReference,\n nativeSubjectId: nativeSubject,\n organizationId: z.string().uuid(),\n })\n .strict();\nexport type ExternalIdentityLinkPreview = z.infer<typeof ExternalIdentityLinkPreview>;\n\n/** Immutable accepted-work restriction, not a browser credential. Original key\n * identity remains audit-only; durable use validates the live link and members. */\nexport const ExternalLinkWorkSnapshot = z\n .object({\n identity: ExternalIdentityReference,\n actor: ExternalActorAttribution.refine((value) => value.actingMode === \"linked_native\"),\n permissions: z.array(Permission).max(Permission.options.length),\n /** Absent on historical snapshots, whose legacy semantics are preserved. */\n permissionMode: z.enum([\"legacy\", \"explicit\"]).optional(),\n })\n .strict();\nexport type ExternalLinkWorkSnapshot = z.infer<typeof ExternalLinkWorkSnapshot>;\n"],"mappings":";;;;;AAAA,SAAS,SAAS;AAQlB,IAAM,UAAU,IAAI,YAAY;AAChC,SAAS,WAAW,UAAkB;AACpC,SAAO,EACJ,OAAO,EACP,IAAI,CAAC,EACL,IAAI,QAAQ,EACZ;AAAA,IACC,CAAC,UACC,CAAC,MAAM,SAAS,IAAI,KACpB,CAAC,mBAAmB,KAAK,KAAK,KAC9B,QAAQ,OAAO,KAAK,EAAE,cAAc;AAAA,IACtC;AAAA,MACE,SAAS,+DAA+D,QAAQ;AAAA,IAClF;AAAA,EACF;AACJ;AACA,IAAM,aAAa,WAAW,IAAI;AAClC,IAAM,SAAS,WAAW,GAAG;AAC7B,IAAM,kBAAkB,EACrB,OAAO,EACP,MAAM,wFAAwF;AACjG,IAAM,gBAAgB,EACnB,OAAO,EACP,IAAI,CAAC,EACL,IAAI,IAAI,EACR,MAAM,2BAA2B;AAC7B,IAAM,4BAA4B,EACtC,OAAO;AAAA,EACN;AAAA,EACA,QAAQ,OAAO,QAAQ,SAAS;AAClC,CAAC,EACA,OAAO;AAGH,IAAM,oCAAoC,EAC9C,OAAO;AAAA,EACN,UAAU;AAAA,EACV,aAAa,EAAE,MAAM,UAAU,EAAE,IAAI,CAAC,EAAE,IAAI,WAAW,QAAQ,MAAM;AAAA;AAAA,EAErE,aAAa,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS;AAC1C,CAAC,EACA,OAAO;AAIH,IAAM,yBAAyB,EAAE,mBAAmB,SAAS;AAAA,EAClE,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,KAAK,EAAE,CAAC,EAAE,OAAO;AAAA,EA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A,OAAO;AAKH,IAAM,2BAA2B,EACrC,OAAO;AAAA,EACN,UAAU;AAAA,EACV,OAAO,yBAAyB,OAAO,CAAC,UAAU,MAAM,eAAe,eAAe;AAAA,EACtF,aAAa,EAAE,MAAM,UAAU,EAAE,IAAI,WAAW,QAAQ,MAAM;AAAA;AAAA,EAE9D,gBAAgB,EAAE,KAAK,CAAC,UAAU,UAAU,CAAC,EAAE,SAAS;AAC1D,CAAC,EACA,OAAO;","names":[]}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
// src/slack-rest-mcp.ts
|
|
2
|
+
var OFFICIAL_SLACK_MCP_URL = "https://mcp.slack.com/mcp";
|
|
3
|
+
var SLACK_REST_API_BASE = "https://slack.com/api/";
|
|
4
|
+
var OPENGENI_SLACK_REST_USER_SCOPES = [
|
|
5
|
+
"channels:read",
|
|
6
|
+
"groups:read",
|
|
7
|
+
"im:read",
|
|
8
|
+
"mpim:read",
|
|
9
|
+
"channels:history",
|
|
10
|
+
"groups:history",
|
|
11
|
+
"im:history",
|
|
12
|
+
"mpim:history",
|
|
13
|
+
"users:read",
|
|
14
|
+
"im:write",
|
|
15
|
+
"chat:write"
|
|
16
|
+
];
|
|
17
|
+
function normalizeSlackScopes(scopes) {
|
|
18
|
+
return [
|
|
19
|
+
...new Set(
|
|
20
|
+
(typeof scopes === "string" ? [scopes] : scopes ?? []).flatMap((entry) => entry.split(/[\s,]+/u)).filter(Boolean)
|
|
21
|
+
)
|
|
22
|
+
].sort();
|
|
23
|
+
}
|
|
24
|
+
var conversationScopes = ["channels:read", "groups:read", "im:read", "mpim:read"];
|
|
25
|
+
var historyScopes = ["channels:history", "groups:history", "im:history", "mpim:history"];
|
|
26
|
+
var channel = { type: "string", description: "Slack conversation ID, such as C123 or D123." };
|
|
27
|
+
var cursor = { type: "string", maxLength: 4096, description: "Cursor from the previous page." };
|
|
28
|
+
var directoryPage = { type: "integer", minimum: 1, maximum: 100, default: 100 };
|
|
29
|
+
var historyPage = { type: "integer", minimum: 1, maximum: 15, default: 15 };
|
|
30
|
+
var timestamp = { type: "string", pattern: "^[0-9]+\\.[0-9]+$" };
|
|
31
|
+
function tool(name, description, properties, required = [], mutation = false) {
|
|
32
|
+
return {
|
|
33
|
+
name,
|
|
34
|
+
description,
|
|
35
|
+
inputSchema: { type: "object", properties, required, additionalProperties: false },
|
|
36
|
+
annotations: {
|
|
37
|
+
readOnlyHint: !mutation,
|
|
38
|
+
destructiveHint: false,
|
|
39
|
+
idempotentHint: !mutation,
|
|
40
|
+
openWorldHint: true
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
var SLACK_REST_MCP_TOOLS = [
|
|
45
|
+
tool(
|
|
46
|
+
"slack_list_channels",
|
|
47
|
+
"Lists one page of conversations visible to your connected Slack account. Conversation types without a granted read scope are omitted.",
|
|
48
|
+
{
|
|
49
|
+
types: {
|
|
50
|
+
type: "array",
|
|
51
|
+
items: { type: "string", enum: ["public_channel", "private_channel", "im", "mpim"] },
|
|
52
|
+
minItems: 1,
|
|
53
|
+
maxItems: 4
|
|
54
|
+
},
|
|
55
|
+
cursor,
|
|
56
|
+
limit: directoryPage,
|
|
57
|
+
exclude_archived: { type: "boolean", default: true }
|
|
58
|
+
}
|
|
59
|
+
),
|
|
60
|
+
tool(
|
|
61
|
+
"slack_get_channel_info",
|
|
62
|
+
"Gets metadata for one conversation visible to your connected Slack account.",
|
|
63
|
+
{ channel },
|
|
64
|
+
["channel"]
|
|
65
|
+
),
|
|
66
|
+
tool(
|
|
67
|
+
"slack_list_channel_members",
|
|
68
|
+
"Lists one page of members in a visible channel or group conversation.",
|
|
69
|
+
{ channel, cursor, limit: directoryPage },
|
|
70
|
+
["channel"]
|
|
71
|
+
),
|
|
72
|
+
tool("slack_list_users", "Lists one page of users in the connected Slack workspace.", {
|
|
73
|
+
cursor,
|
|
74
|
+
limit: directoryPage
|
|
75
|
+
}),
|
|
76
|
+
tool(
|
|
77
|
+
"slack_get_user_info",
|
|
78
|
+
"Gets a user's profile by their Slack user ID. Email is included only when Slack has granted that scope.",
|
|
79
|
+
{ user: { type: "string" } },
|
|
80
|
+
["user"]
|
|
81
|
+
),
|
|
82
|
+
tool(
|
|
83
|
+
"slack_read_channel",
|
|
84
|
+
"Reads one page of at most 15 messages from a selected conversation. Slack history limits are shared across the workspace. No automatic pagination or backfill.",
|
|
85
|
+
{
|
|
86
|
+
channel,
|
|
87
|
+
cursor,
|
|
88
|
+
limit: historyPage,
|
|
89
|
+
oldest: timestamp,
|
|
90
|
+
latest: timestamp,
|
|
91
|
+
inclusive: { type: "boolean", default: false }
|
|
92
|
+
},
|
|
93
|
+
["channel"]
|
|
94
|
+
),
|
|
95
|
+
tool(
|
|
96
|
+
"slack_read_thread",
|
|
97
|
+
"Reads one page of at most 15 messages in a selected thread. Slack thread limits are shared across the workspace. No automatic pagination or backfill.",
|
|
98
|
+
{
|
|
99
|
+
channel,
|
|
100
|
+
ts: { ...timestamp, description: "Thread root message timestamp." },
|
|
101
|
+
cursor,
|
|
102
|
+
limit: historyPage
|
|
103
|
+
},
|
|
104
|
+
["channel", "ts"]
|
|
105
|
+
),
|
|
106
|
+
tool(
|
|
107
|
+
"slack_open_dm",
|
|
108
|
+
"Opens or resumes a direct message with one Slack user as your connected account.",
|
|
109
|
+
{ user: { type: "string" } },
|
|
110
|
+
["user"],
|
|
111
|
+
true
|
|
112
|
+
),
|
|
113
|
+
tool(
|
|
114
|
+
"slack_send_message",
|
|
115
|
+
"Sends a message as your connected Slack account. Supply thread_ts to reply in a thread. Review the recipient and text before approving. An uncertain submission is never automatically retried.",
|
|
116
|
+
{
|
|
117
|
+
channel,
|
|
118
|
+
text: { type: "string", minLength: 1, maxLength: 4e4 },
|
|
119
|
+
thread_ts: { ...timestamp, description: "Optional thread root timestamp for a reply." },
|
|
120
|
+
unfurl_links: { type: "boolean", default: false },
|
|
121
|
+
unfurl_media: { type: "boolean", default: false }
|
|
122
|
+
},
|
|
123
|
+
["channel", "text"],
|
|
124
|
+
true
|
|
125
|
+
)
|
|
126
|
+
];
|
|
127
|
+
var REQUIRED_ANY_SCOPES = {
|
|
128
|
+
slack_list_channels: conversationScopes,
|
|
129
|
+
slack_get_channel_info: conversationScopes,
|
|
130
|
+
slack_list_channel_members: ["channels:read", "groups:read", "mpim:read"],
|
|
131
|
+
slack_list_users: ["users:read"],
|
|
132
|
+
slack_get_user_info: ["users:read"],
|
|
133
|
+
slack_read_channel: historyScopes,
|
|
134
|
+
slack_read_thread: historyScopes,
|
|
135
|
+
slack_open_dm: ["im:write"],
|
|
136
|
+
slack_send_message: ["chat:write"]
|
|
137
|
+
};
|
|
138
|
+
function slackRestMcpToolsForScopes(scopes) {
|
|
139
|
+
const granted = new Set(normalizeSlackScopes(scopes));
|
|
140
|
+
return SLACK_REST_MCP_TOOLS.filter(
|
|
141
|
+
(entry) => REQUIRED_ANY_SCOPES[entry.name]?.some((scope) => granted.has(scope))
|
|
142
|
+
).map((entry) => ({
|
|
143
|
+
...entry,
|
|
144
|
+
inputSchema: {
|
|
145
|
+
...entry.inputSchema,
|
|
146
|
+
required: [...entry.inputSchema.required],
|
|
147
|
+
properties: { ...entry.inputSchema.properties }
|
|
148
|
+
},
|
|
149
|
+
annotations: { ...entry.annotations }
|
|
150
|
+
}));
|
|
151
|
+
}
|
|
152
|
+
var SLACK_CONVERSATION_READ_SCOPE_BY_TYPE = {
|
|
153
|
+
public_channel: "channels:read",
|
|
154
|
+
private_channel: "groups:read",
|
|
155
|
+
im: "im:read",
|
|
156
|
+
mpim: "mpim:read"
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
export {
|
|
160
|
+
OFFICIAL_SLACK_MCP_URL,
|
|
161
|
+
SLACK_REST_API_BASE,
|
|
162
|
+
OPENGENI_SLACK_REST_USER_SCOPES,
|
|
163
|
+
normalizeSlackScopes,
|
|
164
|
+
SLACK_REST_MCP_TOOLS,
|
|
165
|
+
slackRestMcpToolsForScopes,
|
|
166
|
+
SLACK_CONVERSATION_READ_SCOPE_BY_TYPE
|
|
167
|
+
};
|
|
168
|
+
//# sourceMappingURL=chunk-MZLBPKFE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/slack-rest-mcp.ts"],"sourcesContent":["/** The catalog and OAuth identity stay stable while calls use the ordinary Web API. */\nexport const OFFICIAL_SLACK_MCP_URL = \"https://mcp.slack.com/mcp\";\nexport const SLACK_REST_API_BASE = \"https://slack.com/api/\";\n\nexport const OPENGENI_SLACK_REST_USER_SCOPES = [\n \"channels:read\",\n \"groups:read\",\n \"im:read\",\n \"mpim:read\",\n \"channels:history\",\n \"groups:history\",\n \"im:history\",\n \"mpim:history\",\n \"users:read\",\n \"im:write\",\n \"chat:write\",\n] as const;\n\n/** Slack returns comma-delimited scopes, including in existing saved grants. */\nexport function normalizeSlackScopes(\n scopes: readonly string[] | string | undefined | null,\n): string[] {\n return [\n ...new Set(\n (typeof scopes === \"string\" ? [scopes] : (scopes ?? []))\n .flatMap((entry) => entry.split(/[\\s,]+/u))\n .filter(Boolean),\n ),\n ].sort();\n}\n\nexport type SlackRestMcpTool = {\n name: string;\n description: string;\n inputSchema: {\n type: \"object\";\n properties: Record<string, unknown>;\n required: string[];\n additionalProperties: false;\n };\n annotations: {\n readOnlyHint: boolean;\n destructiveHint: false;\n idempotentHint: boolean;\n openWorldHint: true;\n };\n};\n\nconst conversationScopes = [\"channels:read\", \"groups:read\", \"im:read\", \"mpim:read\"];\nconst historyScopes = [\"channels:history\", \"groups:history\", \"im:history\", \"mpim:history\"];\nconst channel = { type: \"string\", description: \"Slack conversation ID, such as C123 or D123.\" };\nconst cursor = { type: \"string\", maxLength: 4096, description: \"Cursor from the previous page.\" };\nconst directoryPage = { type: \"integer\", minimum: 1, maximum: 100, default: 100 };\nconst historyPage = { type: \"integer\", minimum: 1, maximum: 15, default: 15 };\nconst timestamp = { type: \"string\", pattern: \"^[0-9]+\\\\.[0-9]+$\" };\n\nfunction tool(\n name: string,\n description: string,\n properties: Record<string, unknown>,\n required: string[] = [],\n mutation = false,\n): SlackRestMcpTool {\n return {\n name,\n description,\n inputSchema: { type: \"object\", properties, required, additionalProperties: false },\n annotations: {\n readOnlyHint: !mutation,\n destructiveHint: false,\n idempotentHint: !mutation,\n openWorldHint: true,\n },\n };\n}\n\n/** Static reviewed pilot surface. Each call reads only one explicitly requested page. */\nexport const SLACK_REST_MCP_TOOLS: SlackRestMcpTool[] = [\n tool(\n \"slack_list_channels\",\n \"Lists one page of conversations visible to your connected Slack account. Conversation types without a granted read scope are omitted.\",\n {\n types: {\n type: \"array\",\n items: { type: \"string\", enum: [\"public_channel\", \"private_channel\", \"im\", \"mpim\"] },\n minItems: 1,\n maxItems: 4,\n },\n cursor,\n limit: directoryPage,\n exclude_archived: { type: \"boolean\", default: true },\n },\n ),\n tool(\n \"slack_get_channel_info\",\n \"Gets metadata for one conversation visible to your connected Slack account.\",\n { channel },\n [\"channel\"],\n ),\n tool(\n \"slack_list_channel_members\",\n \"Lists one page of members in a visible channel or group conversation.\",\n { channel, cursor, limit: directoryPage },\n [\"channel\"],\n ),\n tool(\"slack_list_users\", \"Lists one page of users in the connected Slack workspace.\", {\n cursor,\n limit: directoryPage,\n }),\n tool(\n \"slack_get_user_info\",\n \"Gets a user's profile by their Slack user ID. Email is included only when Slack has granted that scope.\",\n { user: { type: \"string\" } },\n [\"user\"],\n ),\n tool(\n \"slack_read_channel\",\n \"Reads one page of at most 15 messages from a selected conversation. Slack history limits are shared across the workspace. No automatic pagination or backfill.\",\n {\n channel,\n cursor,\n limit: historyPage,\n oldest: timestamp,\n latest: timestamp,\n inclusive: { type: \"boolean\", default: false },\n },\n [\"channel\"],\n ),\n tool(\n \"slack_read_thread\",\n \"Reads one page of at most 15 messages in a selected thread. Slack thread limits are shared across the workspace. No automatic pagination or backfill.\",\n {\n channel,\n ts: { ...timestamp, description: \"Thread root message timestamp.\" },\n cursor,\n limit: historyPage,\n },\n [\"channel\", \"ts\"],\n ),\n tool(\n \"slack_open_dm\",\n \"Opens or resumes a direct message with one Slack user as your connected account.\",\n { user: { type: \"string\" } },\n [\"user\"],\n true,\n ),\n tool(\n \"slack_send_message\",\n \"Sends a message as your connected Slack account. Supply thread_ts to reply in a thread. Review the recipient and text before approving. An uncertain submission is never automatically retried.\",\n {\n channel,\n text: { type: \"string\", minLength: 1, maxLength: 40000 },\n thread_ts: { ...timestamp, description: \"Optional thread root timestamp for a reply.\" },\n unfurl_links: { type: \"boolean\", default: false },\n unfurl_media: { type: \"boolean\", default: false },\n },\n [\"channel\", \"text\"],\n true,\n ),\n];\n\nconst REQUIRED_ANY_SCOPES: Readonly<Record<string, readonly string[]>> = {\n slack_list_channels: conversationScopes,\n slack_get_channel_info: conversationScopes,\n slack_list_channel_members: [\"channels:read\", \"groups:read\", \"mpim:read\"],\n slack_list_users: [\"users:read\"],\n slack_get_user_info: [\"users:read\"],\n slack_read_channel: historyScopes,\n slack_read_thread: historyScopes,\n slack_open_dm: [\"im:write\"],\n slack_send_message: [\"chat:write\"],\n};\n\nexport function slackRestMcpToolsForScopes(scopes: readonly string[] | string): SlackRestMcpTool[] {\n const granted = new Set(normalizeSlackScopes(scopes));\n return SLACK_REST_MCP_TOOLS.filter((entry) =>\n REQUIRED_ANY_SCOPES[entry.name]?.some((scope) => granted.has(scope)),\n ).map((entry) => ({\n ...entry,\n inputSchema: {\n ...entry.inputSchema,\n required: [...entry.inputSchema.required],\n properties: { ...entry.inputSchema.properties },\n },\n annotations: { ...entry.annotations },\n }));\n}\n\nexport const SLACK_CONVERSATION_READ_SCOPE_BY_TYPE = {\n public_channel: \"channels:read\",\n private_channel: \"groups:read\",\n im: \"im:read\",\n mpim: \"mpim:read\",\n} as const;\n"],"mappings":";AACO,IAAM,yBAAyB;AAC/B,IAAM,sBAAsB;AAE5B,IAAM,kCAAkC;AAAA,EAC7C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;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,IAClD;AAAA,IACA,CAAC,WAAW,MAAM;AAAA,IAClB;AAAA,EACF;AACF;AAEA,IAAM,sBAAmE;AAAA,EACvE,qBAAqB;AAAA,EACrB,wBAAwB;AAAA,EACxB,4BAA4B,CAAC,iBAAiB,eAAe,WAAW;AAAA,EACxE,kBAAkB,CAAC,YAAY;AAAA,EAC/B,qBAAqB,CAAC,YAAY;AAAA,EAClC,oBAAoB;AAAA,EACpB,mBAAmB;AAAA,EACnB,eAAe,CAAC,UAAU;AAAA,EAC1B,oBAAoB,CAAC,YAAY;AACnC;AAEO,SAAS,2BAA2B,QAAwD;AACjG,QAAM,UAAU,IAAI,IAAI,qBAAqB,MAAM,CAAC;AACpD,SAAO,qBAAqB;AAAA,IAAO,CAAC,UAClC,oBAAoB,MAAM,IAAI,GAAG,KAAK,CAAC,UAAU,QAAQ,IAAI,KAAK,CAAC;AAAA,EACrE,EAAE,IAAI,CAAC,WAAW;AAAA,IAChB,GAAG;AAAA,IACH,aAAa;AAAA,MACX,GAAG,MAAM;AAAA,MACT,UAAU,CAAC,GAAG,MAAM,YAAY,QAAQ;AAAA,MACxC,YAAY,EAAE,GAAG,MAAM,YAAY,WAAW;AAAA,IAChD;AAAA,IACA,aAAa,EAAE,GAAG,MAAM,YAAY;AAAA,EACtC,EAAE;AACJ;AAEO,IAAM,wCAAwC;AAAA,EACnD,gBAAgB;AAAA,EAChB,iBAAiB;AAAA,EACjB,IAAI;AAAA,EACJ,MAAM;AACR;","names":[]}
|
|
@@ -3,10 +3,10 @@ import {
|
|
|
3
3
|
decodeEditableArtifactMutationIntent,
|
|
4
4
|
encodeEditableArtifactMutationIntent,
|
|
5
5
|
hashEditableArtifactMutationIntentBytes
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-NVJMJWLL.js";
|
|
7
7
|
import {
|
|
8
8
|
editableArtifactCodecFor
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-SIOU2K4U.js";
|
|
10
10
|
import {
|
|
11
11
|
DOCUMENT_ARTIFACT_COMMAND_MAX_COMMANDS,
|
|
12
12
|
DOCUMENT_ARTIFACT_MAX_STRUCTURAL_COUNTER
|
|
@@ -21,10 +21,12 @@ import {
|
|
|
21
21
|
fnv1a64,
|
|
22
22
|
strictUtf8
|
|
23
23
|
} from "./chunk-MYBZRDTY.js";
|
|
24
|
+
import {
|
|
25
|
+
EDITABLE_ARTIFACT_SERIALIZED_COMMIT_VERSION
|
|
26
|
+
} from "./chunk-PX3VCKAU.js";
|
|
24
27
|
|
|
25
28
|
// src/editable-artifact-serialized-commit.ts
|
|
26
29
|
import { bytesToHex } from "@noble/hashes/utils";
|
|
27
|
-
var EDITABLE_ARTIFACT_SERIALIZED_COMMIT_VERSION = 1;
|
|
28
30
|
var EDITABLE_ARTIFACT_SERIALIZED_COMMIT_MAX_BYTES = 8 * 1024 * 1024;
|
|
29
31
|
var EDITABLE_ARTIFACT_NATIVE_RECEIPT_MAX_BYTES = 512 * 1024;
|
|
30
32
|
var MAGIC = strictUtf8("OGAST001", "serialized commit magic");
|
|
@@ -372,11 +374,10 @@ function assertUnsharedBytes(value, label) {
|
|
|
372
374
|
}
|
|
373
375
|
|
|
374
376
|
export {
|
|
375
|
-
EDITABLE_ARTIFACT_SERIALIZED_COMMIT_VERSION,
|
|
376
377
|
EDITABLE_ARTIFACT_SERIALIZED_COMMIT_MAX_BYTES,
|
|
377
378
|
EDITABLE_ARTIFACT_NATIVE_RECEIPT_MAX_BYTES,
|
|
378
379
|
encodeEditableArtifactSerializedCommit,
|
|
379
380
|
decodeEditableArtifactSerializedCommit,
|
|
380
381
|
assertCanonicalEditableArtifactSerializedCommit
|
|
381
382
|
};
|
|
382
|
-
//# sourceMappingURL=chunk-
|
|
383
|
+
//# sourceMappingURL=chunk-NRMCVHAU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/editable-artifact-serialized-commit.ts"],"sourcesContent":["import { bytesToHex } from \"@noble/hashes/utils\";\n\nimport {\n ArtifactBinaryReader,\n ArtifactBinaryWriter,\n EDITABLE_ARTIFACT_BINARY_CHECKSUM_BYTES,\n EDITABLE_ARTIFACT_BINARY_HEADER_BYTES,\n decodeCountedEnvelope,\n equalBytes,\n fnv1a64,\n strictUtf8,\n} from \"./editable-artifact-binary\";\nimport {\n DOCUMENT_ARTIFACT_COMMAND_MAX_COMMANDS,\n DOCUMENT_ARTIFACT_MAX_STRUCTURAL_COUNTER,\n} from \"./document-artifact-commands\";\nimport {\n EDITABLE_ARTIFACT_INTENT_MAX_BYTES,\n decodeEditableArtifactMutationIntent,\n encodeEditableArtifactMutationIntent,\n hashEditableArtifactMutationIntentBytes,\n type EditableArtifactMutationIntent,\n} from \"./editable-artifacts\";\nimport { editableArtifactCodecFor } from \"./editable-artifact-codec-registry\";\nimport { EDITABLE_ARTIFACT_SERIALIZED_COMMIT_VERSION } from \"./editable-artifact-versions\";\n\nexport { EDITABLE_ARTIFACT_SERIALIZED_COMMIT_VERSION } from \"./editable-artifact-versions\";\nexport const EDITABLE_ARTIFACT_SERIALIZED_COMMIT_MAX_BYTES = 8 * 1024 * 1024;\nexport const EDITABLE_ARTIFACT_NATIVE_RECEIPT_MAX_BYTES = 512 * 1024;\n\nconst MAGIC = strictUtf8(\"OGAST001\", \"serialized commit magic\");\nconst SHA256_TEXT = /^sha256:[0-9a-f]{64}$/u;\nconst STABLE_ID = /^[0-9a-f]{32}$/u;\nconst DOCUMENT_RECEIPT_MAGIC = \"OGADR001\";\nconst PRESENTATION_RECEIPT_MAGIC = strictUtf8(\"OGAPR001\", \"presentation receipt magic\");\nconst DOCUMENT_RECEIPT_VERSION = 1;\nconst PRESENTATION_RECEIPT_VERSION = 1;\nconst DOCUMENT_CREATED_IDS_PER_COMMAND = 7;\nconst DOCUMENT_ID_BYTES = 17;\nconst PRESENTATION_RECEIPT_BYTES = 32;\nconst MODALITY_TAG = Object.freeze({ document: 1, presentation: 2 } as const);\n\nexport type EditableArtifactSerializedModality = \"document\" | \"presentation\";\n\nexport type EditableArtifactNativeReceiptSummary =\n | Readonly<{\n modality: \"document\";\n revision: number;\n commandCount: number;\n createdIdCount: number;\n }>\n | Readonly<{\n modality: \"presentation\";\n revision: number;\n commandCount: number;\n }>;\n\nexport type EditableArtifactSerializedCommitInput = Readonly<{\n modality: EditableArtifactSerializedModality;\n transactionId: string;\n parentHeadSequence: number;\n resultHeadSequence: number;\n /** Native model revision before applying this non-empty command batch. */\n priorNativeRevision: number;\n priorStateHash: string;\n stateHash: string;\n /** Exact canonical OGATX001 bytes accepted by the server. */\n intentBytes: Uint8Array;\n /** Exact canonical OGADR001 or OGAPR001 bytes returned by the native kernel. */\n nativeReceiptBytes: Uint8Array;\n}>;\n\nexport type EditableArtifactSerializedCommitSummary = Readonly<{\n commitProtocolVersion: typeof EDITABLE_ARTIFACT_SERIALIZED_COMMIT_VERSION;\n modality: EditableArtifactSerializedModality;\n transactionId: string;\n parentHeadSequence: number;\n resultHeadSequence: number;\n priorNativeRevision: number;\n priorStateHash: string;\n stateHash: string;\n requestHash: string;\n /** Canonical client intent nested in this authoritative commit. */\n intent: EditableArtifactMutationIntent;\n intentBytes: Uint8Array;\n nativeReceiptBytes: Uint8Array;\n nativeReceipt: EditableArtifactNativeReceiptSummary;\n}>;\n\n/**\n * Server-only encoder for one authoritative, strictly serialized commit.\n * Client identity remains solely in the exact nested OGATX envelope.\n */\nexport function encodeEditableArtifactSerializedCommit(\n input: EditableArtifactSerializedCommitInput,\n): Uint8Array {\n const normalized = normalizeSerializedCommit(input);\n const payload = new ArtifactBinaryWriter(\n EDITABLE_ARTIFACT_SERIALIZED_COMMIT_MAX_BYTES -\n EDITABLE_ARTIFACT_BINARY_HEADER_BYTES -\n EDITABLE_ARTIFACT_BINARY_CHECKSUM_BYTES,\n );\n payload.stableId(normalized.transactionId, \"serialized transaction id\");\n payload.u64(normalized.parentHeadSequence);\n payload.u64(normalized.resultHeadSequence);\n payload.u64(normalized.priorNativeRevision);\n payload.bytes(hashBytes(normalized.priorStateHash));\n payload.bytes(hashBytes(normalized.stateHash));\n payload.u32(normalized.intentBytes.byteLength);\n payload.u32(normalized.nativeReceiptBytes.byteLength);\n payload.bytes(normalized.intentBytes);\n payload.bytes(normalized.nativeReceiptBytes);\n\n const payloadBytes = payload.finish();\n const output = new ArtifactBinaryWriter(EDITABLE_ARTIFACT_SERIALIZED_COMMIT_MAX_BYTES);\n output.bytes(MAGIC);\n output.u16(EDITABLE_ARTIFACT_SERIALIZED_COMMIT_VERSION);\n output.u16(0);\n output.u32(MODALITY_TAG[normalized.modality]);\n output.u64(payloadBytes.byteLength);\n output.bytes(payloadBytes);\n output.u64(fnv1a64(output.view()));\n return output.finish();\n}\n\n/** Durable modality must be selected before any nested receipt/command decode. */\nexport function decodeEditableArtifactSerializedCommit(\n bytes: Uint8Array,\n durableModality: EditableArtifactSerializedModality,\n): EditableArtifactSerializedCommitSummary {\n assertUnsharedBytes(bytes, \"serialized commit\");\n const modality = serializedModality(durableModality);\n if (bytes.byteLength > EDITABLE_ARTIFACT_SERIALIZED_COMMIT_MAX_BYTES) {\n throw new RangeError(\"serialized commit exceeds its byte limit\");\n }\n if (\n bytes.byteLength <\n EDITABLE_ARTIFACT_BINARY_HEADER_BYTES + EDITABLE_ARTIFACT_BINARY_CHECKSUM_BYTES\n ) {\n throw new TypeError(\"truncated serialized commit envelope\");\n }\n const header = new ArtifactBinaryReader(bytes);\n if (!equalBytes(header.bytes(8), MAGIC)) {\n throw new TypeError(\"invalid serialized commit magic\");\n }\n if (header.u16() !== EDITABLE_ARTIFACT_SERIALIZED_COMMIT_VERSION) {\n throw new TypeError(\"unsupported serialized commit version\");\n }\n if (header.u16() !== 0) {\n throw new TypeError(\"reserved serialized commit flags must be zero\");\n }\n if (header.u32() !== MODALITY_TAG[modality]) {\n throw new TypeError(\"serialized commit modality disagrees with durable artifact\");\n }\n const payloadLength = header.u64Safe(\"serialized commit payload length\");\n const expectedLength =\n EDITABLE_ARTIFACT_BINARY_HEADER_BYTES + payloadLength + EDITABLE_ARTIFACT_BINARY_CHECKSUM_BYTES;\n if (bytes.byteLength < expectedLength) {\n throw new TypeError(\"truncated serialized commit payload\");\n }\n if (bytes.byteLength > expectedLength) {\n throw new TypeError(\"serialized commit contains trailing bytes\");\n }\n const payloadBytes = header.bytes(payloadLength);\n const checksum = header.u64BigInt();\n header.done();\n if (\n checksum !==\n fnv1a64(bytes.subarray(0, bytes.byteLength - EDITABLE_ARTIFACT_BINARY_CHECKSUM_BYTES))\n ) {\n throw new TypeError(\"serialized commit checksum does not match\");\n }\n\n const payload = new ArtifactBinaryReader(payloadBytes);\n const transactionId = payload.stableId(\"serialized transaction id\");\n const parentHeadSequence = payload.u64Safe(\"serialized parent head sequence\");\n const resultHeadSequence = payload.u64Safe(\"serialized result head sequence\");\n const priorNativeRevision = payload.u64Safe(\"serialized prior native revision\");\n const priorStateHash = stateHashText(payload.bytes(32));\n const stateHash = stateHashText(payload.bytes(32));\n const intentLength = payload.count(\n EDITABLE_ARTIFACT_INTENT_MAX_BYTES,\n \"serialized intent bytes\",\n 1,\n );\n const receiptLength = payload.count(\n EDITABLE_ARTIFACT_NATIVE_RECEIPT_MAX_BYTES,\n \"serialized native receipt bytes\",\n 1,\n );\n if (payload.remaining !== intentLength + receiptLength) {\n throw new TypeError(\"serialized commit nested byte lengths are inconsistent\");\n }\n const intentBytes = payload.bytes(intentLength).slice();\n const nativeReceiptBytes = payload.bytes(receiptLength).slice();\n payload.done();\n\n const normalized = normalizeSerializedCommit({\n modality,\n transactionId,\n parentHeadSequence,\n resultHeadSequence,\n priorNativeRevision,\n priorStateHash,\n stateHash,\n intentBytes,\n nativeReceiptBytes,\n });\n const canonical = encodeEditableArtifactSerializedCommit(normalized);\n if (!equalBytes(bytes, canonical)) {\n throw new TypeError(\"serialized commit is not canonically encoded\");\n }\n return Object.freeze({\n commitProtocolVersion: EDITABLE_ARTIFACT_SERIALIZED_COMMIT_VERSION,\n modality,\n transactionId,\n parentHeadSequence,\n resultHeadSequence,\n priorNativeRevision,\n priorStateHash,\n stateHash,\n requestHash: normalized.requestHash,\n intent: normalized.intent,\n intentBytes,\n nativeReceiptBytes,\n nativeReceipt: normalized.nativeReceipt,\n });\n}\n\nexport function assertCanonicalEditableArtifactSerializedCommit(\n bytes: Uint8Array,\n durableModality: EditableArtifactSerializedModality,\n): void {\n decodeEditableArtifactSerializedCommit(bytes, durableModality);\n}\n\ntype NormalizedSerializedCommit = EditableArtifactSerializedCommitInput &\n Readonly<{\n requestHash: string;\n intent: EditableArtifactMutationIntent;\n nativeReceipt: EditableArtifactNativeReceiptSummary;\n }>;\n\nfunction normalizeSerializedCommit(\n input: EditableArtifactSerializedCommitInput,\n): NormalizedSerializedCommit {\n const modality = serializedModality(input.modality);\n const transactionId = canonicalStableId(input.transactionId, \"serialized transaction id\");\n const parentHeadSequence = safeSequence(\n input.parentHeadSequence,\n \"serialized parent head sequence\",\n );\n const resultHeadSequence = safeSequence(\n input.resultHeadSequence,\n \"serialized result head sequence\",\n );\n if (resultHeadSequence !== parentHeadSequence + 1) {\n throw new TypeError(\"serialized commit must advance the durable head exactly once\");\n }\n const priorNativeRevision = safeSequence(\n input.priorNativeRevision,\n \"serialized prior native revision\",\n );\n const priorStateHash = canonicalSha256(input.priorStateHash, \"serialized prior state hash\");\n const stateHash = canonicalSha256(input.stateHash, \"serialized resulting state hash\");\n assertUnsharedBytes(input.intentBytes, \"serialized intent\");\n assertUnsharedBytes(input.nativeReceiptBytes, \"serialized native receipt\");\n if (\n input.intentBytes.byteLength < 1 ||\n input.intentBytes.byteLength > EDITABLE_ARTIFACT_INTENT_MAX_BYTES\n ) {\n throw new RangeError(\"serialized intent bytes exceed their limit\");\n }\n if (\n input.nativeReceiptBytes.byteLength < 1 ||\n input.nativeReceiptBytes.byteLength > EDITABLE_ARTIFACT_NATIVE_RECEIPT_MAX_BYTES\n ) {\n throw new RangeError(\"serialized native receipt bytes exceed their limit\");\n }\n const intentBytes = input.intentBytes.slice();\n const decodedIntent = decodeEditableArtifactMutationIntent(intentBytes);\n if (!equalBytes(intentBytes, encodeEditableArtifactMutationIntent(decodedIntent))) {\n throw new TypeError(\"nested serialized intent is not canonical OGATX001\");\n }\n if (\n decodedIntent.causalBase.length !== 0 ||\n decodedIntent.selectiveUndoOperationIds.length !== 0\n ) {\n throw new TypeError(\"serialized commits cannot carry CRDT causality or selective undo\");\n }\n if (decodedIntent.observedHeadSequence !== parentHeadSequence) {\n throw new TypeError(\"serialized intent observed head does not match its parent\");\n }\n const descriptor = editableArtifactCodecFor({\n durableModality: modality,\n modelSchemaVersion: decodedIntent.modelSchemaVersion,\n commandProtocolVersion: decodedIntent.commandProtocolVersion,\n });\n descriptor.command.assertCanonical(decodedIntent.commandBytes);\n const commandCount = decodedCommandCount(descriptor.command.decode(decodedIntent.commandBytes));\n if (commandCount < 1) {\n throw new TypeError(\"serialized commits require a non-empty command batch\");\n }\n const nativeReceiptBytes = input.nativeReceiptBytes.slice();\n const nativeReceipt = decodeNativeReceipt(modality, nativeReceiptBytes, commandCount);\n if (modality === \"presentation\") {\n if (nativeReceipt.revision !== priorNativeRevision + 1) {\n throw new TypeError(\n \"presentation receipt must advance its prior native revision exactly once\",\n );\n }\n if (stateHash === priorStateHash) {\n throw new TypeError(\"presentation commit must change its canonical state hash\");\n }\n } else if (nativeReceipt.revision === priorNativeRevision) {\n if (stateHash !== priorStateHash) {\n throw new TypeError(\"document no-op receipt cannot change the canonical state hash\");\n }\n } else {\n if (nativeReceipt.revision !== priorNativeRevision + 1) {\n throw new TypeError(\n \"document receipt must preserve or advance its prior native revision once\",\n );\n }\n if (stateHash === priorStateHash) {\n throw new TypeError(\"document revision advance must change the canonical state hash\");\n }\n }\n const requestHash = hashEditableArtifactMutationIntentBytes(intentBytes);\n return Object.freeze({\n modality,\n transactionId,\n parentHeadSequence,\n resultHeadSequence,\n priorNativeRevision,\n priorStateHash,\n stateHash,\n intentBytes,\n nativeReceiptBytes,\n requestHash,\n intent: decodedIntent,\n nativeReceipt,\n });\n}\n\nfunction decodeNativeReceipt(\n modality: EditableArtifactSerializedModality,\n bytes: Uint8Array,\n expectedCommandCount: number,\n): EditableArtifactNativeReceiptSummary {\n return modality === \"document\"\n ? decodeDocumentReceipt(bytes, expectedCommandCount)\n : decodePresentationReceipt(bytes, expectedCommandCount);\n}\n\nfunction decodeDocumentReceipt(\n bytes: Uint8Array,\n expectedCommandCount: number,\n): Extract<EditableArtifactNativeReceiptSummary, { modality: \"document\" }> {\n const envelope = decodeCountedEnvelope(\n bytes,\n DOCUMENT_RECEIPT_MAGIC,\n DOCUMENT_RECEIPT_VERSION,\n EDITABLE_ARTIFACT_NATIVE_RECEIPT_MAX_BYTES,\n DOCUMENT_ARTIFACT_COMMAND_MAX_COMMANDS,\n );\n const payload = new ArtifactBinaryReader(envelope.payload);\n const revision = payload.u64Safe(\"document receipt revision\");\n const commandCount = payload.u32();\n if (commandCount !== envelope.count || commandCount !== expectedCommandCount) {\n throw new TypeError(\"document receipt command count does not match its intent\");\n }\n const maximumCreatedIds = commandCount * DOCUMENT_CREATED_IDS_PER_COMMAND;\n const createdIdCount = payload.count(\n maximumCreatedIds,\n \"document receipt created ids\",\n DOCUMENT_ID_BYTES,\n );\n for (let index = 0; index < createdIdCount; index += 1) {\n const tag = payload.u8();\n if (tag < 1 || tag > 8) {\n throw new TypeError(\"document receipt contains an invalid id kind\");\n }\n payload.u64BigInt();\n const counter = payload.u64BigInt();\n if (counter === 0n || counter > BigInt(DOCUMENT_ARTIFACT_MAX_STRUCTURAL_COUNTER)) {\n throw new TypeError(\"document receipt contains an invalid id counter\");\n }\n }\n payload.done(\"document receipt contains trailing bytes\");\n return Object.freeze({\n modality: \"document\",\n revision,\n commandCount,\n createdIdCount,\n });\n}\n\nfunction decodePresentationReceipt(\n bytes: Uint8Array,\n expectedCommandCount: number,\n): Extract<EditableArtifactNativeReceiptSummary, { modality: \"presentation\" }> {\n if (bytes.byteLength !== PRESENTATION_RECEIPT_BYTES) {\n throw new TypeError(\n bytes.byteLength < PRESENTATION_RECEIPT_BYTES\n ? \"truncated presentation receipt\"\n : \"presentation receipt contains trailing bytes\",\n );\n }\n const reader = new ArtifactBinaryReader(bytes);\n if (!equalBytes(reader.bytes(8), PRESENTATION_RECEIPT_MAGIC)) {\n throw new TypeError(\"invalid presentation receipt magic\");\n }\n if (reader.u16() !== PRESENTATION_RECEIPT_VERSION) {\n throw new TypeError(\"unsupported presentation receipt version\");\n }\n if (reader.u16() !== 0) {\n throw new TypeError(\"reserved presentation receipt flags must be zero\");\n }\n const revision = reader.u64Safe(\"presentation receipt revision\");\n const commandCount = reader.u32();\n if (commandCount !== expectedCommandCount) {\n throw new TypeError(\"presentation receipt command count does not match its intent\");\n }\n const checksum = reader.u64BigInt();\n reader.done();\n if (\n checksum !==\n fnv1a64(bytes.subarray(0, bytes.byteLength - EDITABLE_ARTIFACT_BINARY_CHECKSUM_BYTES))\n ) {\n throw new TypeError(\"presentation receipt checksum does not match\");\n }\n return Object.freeze({ modality: \"presentation\", revision, commandCount });\n}\n\nfunction decodedCommandCount(value: unknown): number {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n throw new TypeError(\"serialized command decoder returned an invalid batch\");\n }\n const descriptor = Object.getOwnPropertyDescriptor(value, \"commands\");\n if (!descriptor || !(\"value\" in descriptor) || !Array.isArray(descriptor.value)) {\n throw new TypeError(\"serialized command decoder returned an invalid batch\");\n }\n return descriptor.value.length;\n}\n\nfunction serializedModality(value: unknown): EditableArtifactSerializedModality {\n if (value !== \"document\" && value !== \"presentation\") {\n throw new TypeError(\"serialized commit modality is invalid\");\n }\n return value;\n}\n\nfunction canonicalStableId(value: unknown, label: string): string {\n if (typeof value !== \"string\" || !STABLE_ID.test(value) || /^0+$/u.test(value)) {\n throw new TypeError(`${label} must be a nonzero lowercase 128-bit hexadecimal id`);\n }\n return value;\n}\n\nfunction canonicalSha256(value: unknown, label: string): string {\n if (typeof value !== \"string\" || !SHA256_TEXT.test(value)) {\n throw new TypeError(`${label} must be canonical sha256 text`);\n }\n return value;\n}\n\nfunction safeSequence(value: unknown, label: string): number {\n if (typeof value !== \"number\" || !Number.isSafeInteger(value) || value < 0) {\n throw new TypeError(`${label} must be a nonnegative safe integer`);\n }\n return value;\n}\n\nfunction hashBytes(value: string): Uint8Array {\n const hex = value.slice(\"sha256:\".length);\n const bytes = new Uint8Array(32);\n for (let index = 0; index < bytes.byteLength; index += 1) {\n bytes[index] = Number.parseInt(hex.slice(index * 2, index * 2 + 2), 16);\n }\n return bytes;\n}\n\nfunction stateHashText(value: Uint8Array): string {\n return `sha256:${bytesToHex(value)}`;\n}\n\nfunction assertUnsharedBytes(value: unknown, label: string): asserts value is Uint8Array {\n if (!(value instanceof Uint8Array)) {\n throw new TypeError(`${label} bytes must be a Uint8Array`);\n }\n if (typeof SharedArrayBuffer !== \"undefined\" && value.buffer instanceof SharedArrayBuffer) {\n throw new TypeError(`${label} bytes must not use shared mutable memory`);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,kBAAkB;AA2BpB,IAAM,gDAAgD,IAAI,OAAO;AACjE,IAAM,6CAA6C,MAAM;AAEhE,IAAM,QAAQ,WAAW,YAAY,yBAAyB;AAC9D,IAAM,cAAc;AACpB,IAAM,YAAY;AAClB,IAAM,yBAAyB;AAC/B,IAAM,6BAA6B,WAAW,YAAY,4BAA4B;AACtF,IAAM,2BAA2B;AACjC,IAAM,+BAA+B;AACrC,IAAM,mCAAmC;AACzC,IAAM,oBAAoB;AAC1B,IAAM,6BAA6B;AACnC,IAAM,eAAe,OAAO,OAAO,EAAE,UAAU,GAAG,cAAc,EAAE,CAAU;AAqDrE,SAAS,uCACd,OACY;AACZ,QAAM,aAAa,0BAA0B,KAAK;AAClD,QAAM,UAAU,IAAI;AAAA,IAClB,gDACE,wCACA;AAAA,EACJ;AACA,UAAQ,SAAS,WAAW,eAAe,2BAA2B;AACtE,UAAQ,IAAI,WAAW,kBAAkB;AACzC,UAAQ,IAA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es/utils";
|
|
4
4
|
var EDITABLE_ARTIFACT_INTENT_VERSION = 1;
|
|
5
|
+
var EDITABLE_ARTIFACT_INTENT_PROTOCOL_VERSION = 1;
|
|
5
6
|
var EDITABLE_ARTIFACT_INTENT_MAX_BYTES = 5 * 1024 * 1024;
|
|
6
7
|
var EDITABLE_ARTIFACT_COMMAND_MAX_BYTES = 4 * 1024 * 1024;
|
|
7
8
|
var EDITABLE_ARTIFACT_KERNEL_VERSION_MAX_BYTES = 512;
|
|
@@ -371,6 +372,7 @@ var BinaryReader = class {
|
|
|
371
372
|
|
|
372
373
|
export {
|
|
373
374
|
EDITABLE_ARTIFACT_INTENT_VERSION,
|
|
375
|
+
EDITABLE_ARTIFACT_INTENT_PROTOCOL_VERSION,
|
|
374
376
|
EDITABLE_ARTIFACT_INTENT_MAX_BYTES,
|
|
375
377
|
EDITABLE_ARTIFACT_COMMAND_MAX_BYTES,
|
|
376
378
|
EDITABLE_ARTIFACT_KERNEL_VERSION_MAX_BYTES,
|
|
@@ -383,4 +385,4 @@ export {
|
|
|
383
385
|
hashEditableArtifactMutationIntent,
|
|
384
386
|
assertEditableArtifactRequestHash
|
|
385
387
|
};
|
|
386
|
-
//# sourceMappingURL=chunk-
|
|
388
|
+
//# sourceMappingURL=chunk-NVJMJWLL.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/editable-artifacts.ts"],"sourcesContent":["import { sha256 } from \"@noble/hashes/sha256\";\nimport { bytesToHex } from \"@noble/hashes/utils\";\n\nexport * from \"./spreadsheet-artifact-commands\";\nexport * from \"./spreadsheet-artifact-query\";\nexport * from \"./editable-artifact-causal-frontier\";\nexport * from \"./document-artifact-commands\";\nexport * from \"./presentation-artifact-commands\";\nexport * from \"./editable-artifact-codec-registry\";\n\nexport const EDITABLE_ARTIFACT_INTENT_VERSION = 1 as const;\n/** Semantic protocol carried inside the unchanged OGATX001 envelope. */\nexport const EDITABLE_ARTIFACT_INTENT_PROTOCOL_VERSION = 1 as const;\nexport const EDITABLE_ARTIFACT_INTENT_MAX_BYTES = 5 * 1024 * 1024;\nexport const EDITABLE_ARTIFACT_COMMAND_MAX_BYTES = 4 * 1024 * 1024;\nexport const EDITABLE_ARTIFACT_KERNEL_VERSION_MAX_BYTES = 512;\n/** Largest durable snapshot every supported browser/WASM client can open. */\nexport const EDITABLE_ARTIFACT_PRODUCT_MAX_SNAPSHOT_BYTES = 64 * 1024 * 1024;\nexport const EDITABLE_ARTIFACT_INTENT_MAX_CAUSAL_ACTORS = 1_024;\nexport const EDITABLE_ARTIFACT_INTENT_MAX_UNDO_TARGETS = 10_000;\n\nconst MAGIC = new TextEncoder().encode(\"OGATX001\");\nconst textEncoder = new TextEncoder();\nconst textDecoder = new TextDecoder(\"utf-8\", { fatal: true });\nconst STABLE_ID = /^[0-9a-f]{32}$/u;\nconst REPLICA_ID = /^[0-9a-f]{16}$/u;\nconst CLIENT_TRANSACTION_ID = /^[A-Za-z0-9._:-]{1,200}$/u;\nconst REQUEST_HASH = /^sha256:[0-9a-f]{64}$/u;\n\nexport type EditableArtifactCausalEntry = Readonly<{\n replicaId: string;\n counter: number;\n}>;\n\n/**\n * Exact client-authored mutation identity. Scope and actor authority are\n * deliberately absent: the server derives them and binds them in the\n * idempotency lookup tuple instead of trusting client bytes.\n */\nexport type EditableArtifactMutationIntent = Readonly<{\n envelopeVersion: typeof EDITABLE_ARTIFACT_INTENT_VERSION;\n protocolVersion: number;\n modelSchemaVersion: number;\n commandProtocolVersion: number;\n artifactId: string;\n clientTransactionId: string;\n replicaId: string;\n replicaCounter: number;\n previousLocalTransactionId: string | null;\n observedHeadSequence: number;\n causalBase: readonly EditableArtifactCausalEntry[];\n selectiveUndoOperationIds: readonly string[];\n commandBytes: Uint8Array;\n}>;\n\nexport function encodeEditableArtifactMutationIntent(\n input: EditableArtifactMutationIntent,\n): Uint8Array {\n // The writer owns the emitted bytes, so a second eager copy of a potentially\n // multi-megabyte command block would add no safety.\n const intent = normalizeIntent(input, false);\n const writer = new BinaryWriter(EDITABLE_ARTIFACT_INTENT_MAX_BYTES);\n writer.bytes(MAGIC);\n writer.u16(intent.envelopeVersion);\n writer.u16(intent.protocolVersion);\n writer.u16(intent.modelSchemaVersion);\n writer.u16(intent.commandProtocolVersion);\n writer.string(intent.artifactId);\n writer.string(intent.clientTransactionId);\n writer.string(intent.replicaId);\n writer.u64(intent.replicaCounter);\n writer.u8(intent.previousLocalTransactionId === null ? 0 : 1);\n if (intent.previousLocalTransactionId !== null) {\n writer.string(intent.previousLocalTransactionId);\n }\n writer.u64(intent.observedHeadSequence);\n writer.u16(intent.causalBase.length);\n for (const entry of intent.causalBase) {\n writer.string(entry.replicaId);\n writer.u64(entry.counter);\n }\n writer.u16(intent.selectiveUndoOperationIds.length);\n for (const operationId of intent.selectiveUndoOperationIds) writer.string(operationId);\n writer.byteBlock(intent.commandBytes);\n return writer.finish();\n}\n\nexport function decodeEditableArtifactMutationIntent(\n bytes: Uint8Array,\n): EditableArtifactMutationIntent {\n return parseEditableArtifactMutationIntent(bytes, true);\n}\n\nfunction parseEditableArtifactMutationIntent(\n bytes: Uint8Array,\n copyCommandBytes: boolean,\n): EditableArtifactMutationIntent {\n if (!(bytes instanceof Uint8Array)) throw new TypeError(\"intent bytes must be a Uint8Array\");\n if (bytes.byteLength > EDITABLE_ARTIFACT_INTENT_MAX_BYTES) {\n throw new RangeError(\"editable artifact intent exceeds its byte limit\");\n }\n const reader = new BinaryReader(bytes);\n const magic = reader.bytes(MAGIC.byteLength);\n if (!equalBytes(magic, MAGIC)) throw new TypeError(\"invalid editable artifact intent magic\");\n const envelopeVersion = reader.u16();\n if (envelopeVersion !== EDITABLE_ARTIFACT_INTENT_VERSION) {\n throw new TypeError(`unsupported editable artifact intent version: ${envelopeVersion}`);\n }\n const protocolVersion = reader.u16();\n const modelSchemaVersion = reader.u16();\n const commandProtocolVersion = reader.u16();\n const artifactId = reader.string();\n const clientTransactionId = reader.string();\n const replicaId = reader.string();\n const replicaCounter = reader.u64();\n const predecessorFlag = reader.u8();\n if (predecessorFlag > 1) throw new TypeError(\"invalid predecessor presence flag\");\n const previousLocalTransactionId = predecessorFlag === 1 ? reader.string() : null;\n const observedHeadSequence = reader.u64();\n const causalCount = reader.u16();\n if (causalCount > EDITABLE_ARTIFACT_INTENT_MAX_CAUSAL_ACTORS) {\n throw new RangeError(\"editable artifact causal base exceeds its actor limit\");\n }\n const causalBase: EditableArtifactCausalEntry[] = [];\n let previousReplicaId = \"\";\n for (let index = 0; index < causalCount; index += 1) {\n const causalReplicaId = reader.string();\n if (causalReplicaId <= previousReplicaId) {\n throw new TypeError(\"causal base replica ids must be unique and canonically sorted\");\n }\n previousReplicaId = causalReplicaId;\n causalBase.push(Object.freeze({ replicaId: causalReplicaId, counter: reader.u64() }));\n }\n const undoCount = reader.u16();\n if (undoCount > EDITABLE_ARTIFACT_INTENT_MAX_UNDO_TARGETS) {\n throw new RangeError(\"editable artifact undo targets exceed their limit\");\n }\n const selectiveUndoOperationIds: string[] = [];\n let previousOperationId = \"\";\n for (let index = 0; index < undoCount; index += 1) {\n const operationId = reader.string();\n if (operationId <= previousOperationId) {\n throw new TypeError(\"undo operation ids must be unique and canonically sorted\");\n }\n previousOperationId = operationId;\n selectiveUndoOperationIds.push(operationId);\n }\n const commandBytes = reader.byteBlock(EDITABLE_ARTIFACT_COMMAND_MAX_BYTES);\n reader.done();\n return normalizeIntent(\n {\n envelopeVersion: EDITABLE_ARTIFACT_INTENT_VERSION,\n protocolVersion,\n modelSchemaVersion,\n commandProtocolVersion,\n artifactId,\n clientTransactionId,\n replicaId,\n replicaCounter,\n previousLocalTransactionId,\n observedHeadSequence,\n causalBase,\n selectiveUndoOperationIds,\n commandBytes,\n },\n copyCommandBytes,\n );\n}\n\nexport function hashEditableArtifactMutationIntentBytes(bytes: Uint8Array): string {\n // Decode first so noncanonical or malformed bytes can never acquire a valid\n // application-level request hash merely because SHA-256 accepts any bytes.\n parseEditableArtifactMutationIntent(bytes, false);\n return `sha256:${bytesToHex(sha256(bytes))}`;\n}\n\nexport function hashEditableArtifactMutationIntent(intent: EditableArtifactMutationIntent): {\n bytes: Uint8Array;\n requestHash: string;\n} {\n const bytes = encodeEditableArtifactMutationIntent(intent);\n return { bytes, requestHash: `sha256:${bytesToHex(sha256(bytes))}` };\n}\n\nexport function assertEditableArtifactRequestHash(value: string): string {\n if (!REQUEST_HASH.test(value)) {\n throw new TypeError(\"editable artifact request hash must be canonical sha256 text\");\n }\n return value;\n}\n\nfunction normalizeIntent(\n input: EditableArtifactMutationIntent,\n copyCommandBytes = true,\n): EditableArtifactMutationIntent {\n if (!isPlainRecord(input)) throw new TypeError(\"editable artifact intent must be a plain record\");\n if (input.envelopeVersion !== EDITABLE_ARTIFACT_INTENT_VERSION) {\n throw new TypeError(\"editable artifact intent envelope version must be 1\");\n }\n const protocolVersion = positiveU16(input.protocolVersion, \"protocolVersion\");\n const modelSchemaVersion = positiveU16(input.modelSchemaVersion, \"modelSchemaVersion\");\n const commandProtocolVersion = positiveU16(\n input.commandProtocolVersion,\n \"commandProtocolVersion\",\n );\n const artifactId = stableId(input.artifactId, \"artifactId\");\n const clientTransactionId = portableTransactionId(\n input.clientTransactionId,\n \"clientTransactionId\",\n );\n const replicaId = replicaIdentity(input.replicaId, \"replicaId\");\n const replicaCounter = positiveSafeInteger(input.replicaCounter, \"replicaCounter\");\n const previousLocalTransactionId =\n input.previousLocalTransactionId === null\n ? null\n : portableTransactionId(input.previousLocalTransactionId, \"previousLocalTransactionId\");\n const observedHeadSequence = nonnegativeSafeInteger(\n input.observedHeadSequence,\n \"observedHeadSequence\",\n );\n if (!Array.isArray(input.causalBase)) throw new TypeError(\"causalBase must be an array\");\n if (input.causalBase.length > EDITABLE_ARTIFACT_INTENT_MAX_CAUSAL_ACTORS) {\n throw new RangeError(\"editable artifact causal base exceeds its actor limit\");\n }\n const causalByReplica = new Map<string, number>();\n for (const entry of input.causalBase) {\n if (!isPlainRecord(entry)) throw new TypeError(\"causal entries must be plain records\");\n const causalReplicaId = replicaIdentity(entry.replicaId, \"causal replicaId\");\n if (causalByReplica.has(causalReplicaId)) throw new TypeError(\"duplicate causal replicaId\");\n causalByReplica.set(\n causalReplicaId,\n positiveSafeInteger(entry.counter, `causal counter for ${causalReplicaId}`),\n );\n }\n const causalBase = [...causalByReplica]\n .sort(([left], [right]) => compareCodeUnits(left, right))\n .map(([causalReplicaId, counter]) => Object.freeze({ replicaId: causalReplicaId, counter }));\n if (!Array.isArray(input.selectiveUndoOperationIds)) {\n throw new TypeError(\"selectiveUndoOperationIds must be an array\");\n }\n if (input.selectiveUndoOperationIds.length > EDITABLE_ARTIFACT_INTENT_MAX_UNDO_TARGETS) {\n throw new RangeError(\"editable artifact undo targets exceed their limit\");\n }\n const undoSet = new Set<string>();\n for (const value of input.selectiveUndoOperationIds) {\n const operationId = stableId(value, \"selective undo operation id\");\n if (undoSet.has(operationId)) throw new TypeError(\"duplicate selective undo operation id\");\n undoSet.add(operationId);\n }\n const selectiveUndoOperationIds = [...undoSet].sort(compareCodeUnits);\n if (!(input.commandBytes instanceof Uint8Array)) {\n throw new TypeError(\"commandBytes must be a Uint8Array\");\n }\n if (input.commandBytes.byteLength < 1) throw new TypeError(\"commandBytes must not be empty\");\n if (input.commandBytes.byteLength > EDITABLE_ARTIFACT_COMMAND_MAX_BYTES) {\n throw new RangeError(\"commandBytes exceeds its byte limit\");\n }\n return Object.freeze({\n envelopeVersion: EDITABLE_ARTIFACT_INTENT_VERSION,\n protocolVersion,\n modelSchemaVersion,\n commandProtocolVersion,\n artifactId,\n clientTransactionId,\n replicaId,\n replicaCounter,\n previousLocalTransactionId,\n observedHeadSequence,\n causalBase: Object.freeze(causalBase),\n selectiveUndoOperationIds: Object.freeze(selectiveUndoOperationIds),\n commandBytes: copyCommandBytes ? input.commandBytes.slice() : input.commandBytes,\n });\n}\n\nfunction isPlainRecord(value: unknown): value is Record<string, unknown> {\n return (\n typeof value === \"object\" && value !== null && Object.getPrototypeOf(value) === Object.prototype\n );\n}\n\nfunction stableId(value: unknown, label: string): string {\n if (typeof value !== \"string\" || !STABLE_ID.test(value) || /^0+$/u.test(value)) {\n throw new TypeError(`${label} must be nonzero fixed-width lowercase hexadecimal text`);\n }\n return value;\n}\n\nfunction replicaIdentity(value: unknown, label: string): string {\n if (typeof value !== \"string\" || !REPLICA_ID.test(value) || /^0+$/u.test(value)) {\n throw new TypeError(`${label} must be nonzero 64-bit lowercase hexadecimal text`);\n }\n return value;\n}\n\nfunction portableTransactionId(value: unknown, label: string): string {\n if (typeof value !== \"string\" || !CLIENT_TRANSACTION_ID.test(value)) {\n throw new TypeError(`${label} must contain 1-200 portable identifier characters`);\n }\n return value;\n}\n\nfunction positiveU16(value: unknown, label: string): number {\n if (!Number.isInteger(value) || (value as number) < 1 || (value as number) > 0xffff) {\n throw new TypeError(`${label} must be a positive 16-bit integer`);\n }\n return value as number;\n}\n\nfunction positiveSafeInteger(value: unknown, label: string): number {\n if (!Number.isSafeInteger(value) || (value as number) < 1) {\n throw new TypeError(`${label} must be a positive safe integer`);\n }\n return value as number;\n}\n\nfunction nonnegativeSafeInteger(value: unknown, label: string): number {\n if (!Number.isSafeInteger(value) || (value as number) < 0) {\n throw new TypeError(`${label} must be a nonnegative safe integer`);\n }\n return value as number;\n}\n\nfunction compareCodeUnits(left: string, right: string): number {\n return left < right ? -1 : left > right ? 1 : 0;\n}\n\nfunction equalBytes(left: Uint8Array, right: Uint8Array): boolean {\n return (\n left.byteLength === right.byteLength && left.every((value, index) => value === right[index])\n );\n}\n\nclass BinaryWriter {\n private buffer = new Uint8Array(1_024);\n private length = 0;\n\n constructor(private readonly maximum: number) {}\n\n u8(value: number): void {\n this.ensure(1);\n this.buffer[this.length++] = value;\n }\n\n u16(value: number): void {\n this.ensure(2);\n this.buffer[this.length++] = value & 0xff;\n this.buffer[this.length++] = (value >>> 8) & 0xff;\n }\n\n u32(value: number): void {\n this.ensure(4);\n for (let offset = 0; offset < 4; offset += 1) {\n this.buffer[this.length++] = Math.floor(value / 2 ** (offset * 8)) & 0xff;\n }\n }\n\n u64(value: number): void {\n if (!Number.isSafeInteger(value) || value < 0) throw new TypeError(\"u64 must be safe\");\n this.ensure(8);\n let remaining = BigInt(value);\n for (let offset = 0; offset < 8; offset += 1) {\n this.buffer[this.length++] = Number(remaining & 0xffn);\n remaining >>= 8n;\n }\n }\n\n string(value: string): void {\n const bytes = textEncoder.encode(value);\n if (bytes.byteLength > 0xffff) throw new RangeError(\"intent string exceeds 65535 bytes\");\n this.u16(bytes.byteLength);\n this.bytes(bytes);\n }\n\n byteBlock(value: Uint8Array): void {\n this.u32(value.byteLength);\n this.bytes(value);\n }\n\n bytes(value: Uint8Array): void {\n this.ensure(value.byteLength);\n this.buffer.set(value, this.length);\n this.length += value.byteLength;\n }\n\n finish(): Uint8Array {\n return this.buffer.slice(0, this.length);\n }\n\n private ensure(additional: number): void {\n const needed = this.length + additional;\n if (!Number.isSafeInteger(needed) || needed > this.maximum) {\n throw new RangeError(\"editable artifact intent exceeds its byte limit\");\n }\n if (needed <= this.buffer.byteLength) return;\n let size = this.buffer.byteLength;\n while (size < needed) size = Math.min(this.maximum, size * 2);\n const next = new Uint8Array(size);\n next.set(this.buffer.subarray(0, this.length));\n this.buffer = next;\n }\n}\n\nclass BinaryReader {\n private offset = 0;\n\n constructor(private readonly input: Uint8Array) {}\n\n u8(): number {\n this.require(1);\n return this.input[this.offset++]!;\n }\n\n u16(): number {\n this.require(2);\n const value = this.input[this.offset]! | (this.input[this.offset + 1]! << 8);\n this.offset += 2;\n return value;\n }\n\n u32(): number {\n this.require(4);\n const value =\n this.input[this.offset]! +\n this.input[this.offset + 1]! * 2 ** 8 +\n this.input[this.offset + 2]! * 2 ** 16 +\n this.input[this.offset + 3]! * 2 ** 24;\n this.offset += 4;\n return value;\n }\n\n u64(): number {\n this.require(8);\n let value = 0n;\n for (let offset = 0; offset < 8; offset += 1) {\n value |= BigInt(this.input[this.offset + offset]!) << BigInt(offset * 8);\n }\n this.offset += 8;\n if (value > BigInt(Number.MAX_SAFE_INTEGER)) throw new RangeError(\"u64 exceeds safe integer\");\n return Number(value);\n }\n\n string(): string {\n return textDecoder.decode(this.bytes(this.u16()));\n }\n\n byteBlock(maximum: number): Uint8Array {\n const length = this.u32();\n if (length < 1) throw new TypeError(\"commandBytes must not be empty\");\n if (length > maximum) throw new RangeError(\"commandBytes exceeds its byte limit\");\n return this.bytes(length);\n }\n\n bytes(length: number): Uint8Array {\n this.require(length);\n const output = this.input.subarray(this.offset, this.offset + length);\n this.offset += length;\n return output;\n }\n\n done(): void {\n if (this.offset !== this.input.byteLength) {\n throw new TypeError(\"editable artifact intent contains trailing bytes\");\n }\n }\n\n private require(length: number): void {\n if (\n !Number.isSafeInteger(length) ||\n length < 0 ||\n this.offset + length > this.input.byteLength\n ) {\n throw new TypeError(\"truncated editable artifact intent\");\n }\n }\n}\n"],"mappings":";AAAA,SAAS,cAAc;AACvB,SAAS,kBAAkB;AASpB,IAAM,mCAAmC;AAEzC,IAAM,4CAA4C;AAClD,IAAM,qCAAqC,IAAI,OAAO;AACtD,IAAM,sCAAsC,IAAI,OAAO;AACvD,IAAM,6CAA6C;AAEnD,IAAM,+CAA+C,KAAK,OAAO;AACjE,IAAM,6CAA6C;AACnD,IAAM,4CAA4C;AAEzD,IAAM,QAAQ,IAAI,YAAY,EAAE,OAAO,UAAU;AACjD,IAAM,cAAc,IAAI,YAAY;AACpC,IAAM,cAAc,IAAI,YAAY,SAAS,EAAE,OAAO,KAAK,CAAC;AAC5D,IAAM,YAAY;AAClB,IAAM,aAAa;AACnB,IAAM,wBAAwB;AAC9B,IAAM,eAAe;AA4Bd,SAAS,qCACd,OACY;AAGZ,QAAM,SAAS,gBAAgB,OAAO,KAAK;AAC3C,QAAM,SAAS,IAAI,aAAa,kCAAkC;AAClE,SAAO,MAAM,KAAK;AAClB,SAAO,IAAI,OAAO,eAAe;AACjC,SAAO,IAAI,OAAO,eAAe;AACjC,SAAO,IAAI,OAAO,kBAA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,WAAO;AAAA,EACT;AAAA,EAEA,OAAa;AACX,QAAI,KAAK,WAAW,KAAK,MAAM,YAAY;AACzC,YAAM,IAAI,UAAU,kDAAkD;AAAA,IACxE;AAAA,EACF;AAAA,EAEQ,QAAQ,QAAsB;AACpC,QACE,CAAC,OAAO,cAAc,MAAM,KAC5B,SAAS,KACT,KAAK,SAAS,SAAS,KAAK,MAAM,YAClC;AACA,YAAM,IAAI,UAAU,oCAAoC;AAAA,IAC1D;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// src/workspace-integration-wire.ts
|
|
2
|
+
var WORKSPACE_WEBHOOK_EVENT_TYPES = [
|
|
3
|
+
"turn.completed",
|
|
4
|
+
"turn.failed",
|
|
5
|
+
"turn.cancelled",
|
|
6
|
+
"session.status.changed",
|
|
7
|
+
"session.requiresAction",
|
|
8
|
+
"session.humanInput.requested",
|
|
9
|
+
"usage.threshold_reached",
|
|
10
|
+
"usage.exhausted",
|
|
11
|
+
"usage.period_reset"
|
|
12
|
+
];
|
|
13
|
+
var OPENGENI_WEBHOOK_TEST_EVENT_TYPE = "webhook.test";
|
|
14
|
+
var OPENGENI_TEST_REQUEST_NIL_ID = "00000000-0000-0000-0000-000000000000";
|
|
15
|
+
var OPENGENI_SIGNATURE_HEADER = "OpenGeni-Signature";
|
|
16
|
+
var OPENGENI_EVENT_ID_HEADER = "OpenGeni-Event-Id";
|
|
17
|
+
var OPENGENI_DELIVERY_ID_HEADER = "OpenGeni-Delivery-Id";
|
|
18
|
+
var OPENGENI_SIGNATURE_TOLERANCE_SECONDS = 300;
|
|
19
|
+
var encoder = new TextEncoder();
|
|
20
|
+
async function hmacSha256Hex(secret, message) {
|
|
21
|
+
const key = await crypto.subtle.importKey(
|
|
22
|
+
"raw",
|
|
23
|
+
encoder.encode(secret),
|
|
24
|
+
{ name: "HMAC", hash: "SHA-256" },
|
|
25
|
+
false,
|
|
26
|
+
["sign"]
|
|
27
|
+
);
|
|
28
|
+
const signature = new Uint8Array(await crypto.subtle.sign("HMAC", key, encoder.encode(message)));
|
|
29
|
+
return Array.from(signature, (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
30
|
+
}
|
|
31
|
+
function constantTimeEqualHex(left, right) {
|
|
32
|
+
if (left.length !== right.length) return false;
|
|
33
|
+
let difference = 0;
|
|
34
|
+
for (let index = 0; index < left.length; index += 1) {
|
|
35
|
+
difference |= left.charCodeAt(index) ^ right.charCodeAt(index);
|
|
36
|
+
}
|
|
37
|
+
return difference === 0;
|
|
38
|
+
}
|
|
39
|
+
async function signOpenGeniPayload(secret, body, timestampSeconds = Math.floor(Date.now() / 1e3)) {
|
|
40
|
+
return `t=${timestampSeconds},v1=${await hmacSha256Hex(secret, `${timestampSeconds}.${body}`)}`;
|
|
41
|
+
}
|
|
42
|
+
async function verifyOpenGeniSignature(input) {
|
|
43
|
+
if (!input.signature) return false;
|
|
44
|
+
let timestamp = null;
|
|
45
|
+
const candidates = [];
|
|
46
|
+
for (const part of input.signature.split(",")) {
|
|
47
|
+
const [key, value] = part.trim().split("=", 2);
|
|
48
|
+
if (key === "t" && value && /^\d{1,12}$/.test(value)) timestamp = Number(value);
|
|
49
|
+
if (key === "v1" && value && /^[0-9a-f]{64}$/.test(value)) candidates.push(value);
|
|
50
|
+
}
|
|
51
|
+
if (timestamp === null || candidates.length === 0) return false;
|
|
52
|
+
const now = input.nowSeconds ?? Math.floor(Date.now() / 1e3);
|
|
53
|
+
const tolerance = input.toleranceSeconds ?? OPENGENI_SIGNATURE_TOLERANCE_SECONDS;
|
|
54
|
+
if (Math.abs(now - timestamp) > tolerance) return false;
|
|
55
|
+
const expected = await hmacSha256Hex(input.secret, `${timestamp}.${input.body}`);
|
|
56
|
+
return candidates.some((candidate) => constantTimeEqualHex(candidate, expected));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export {
|
|
60
|
+
WORKSPACE_WEBHOOK_EVENT_TYPES,
|
|
61
|
+
OPENGENI_WEBHOOK_TEST_EVENT_TYPE,
|
|
62
|
+
OPENGENI_TEST_REQUEST_NIL_ID,
|
|
63
|
+
OPENGENI_SIGNATURE_HEADER,
|
|
64
|
+
OPENGENI_EVENT_ID_HEADER,
|
|
65
|
+
OPENGENI_DELIVERY_ID_HEADER,
|
|
66
|
+
OPENGENI_SIGNATURE_TOLERANCE_SECONDS,
|
|
67
|
+
signOpenGeniPayload,
|
|
68
|
+
verifyOpenGeniSignature
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=chunk-O77VSFYZ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/workspace-integration-wire.ts"],"sourcesContent":["/**\n * Dependency-free wire constants and the OpenGeni-Signature scheme shared by\n * workspace webhooks and credential providers. Kept free of zod so browser and\n * React Native bundles can verify signatures without the schema runtime.\n */\n\nexport const WORKSPACE_WEBHOOK_EVENT_TYPES = [\n \"turn.completed\",\n \"turn.failed\",\n \"turn.cancelled\",\n \"session.status.changed\",\n \"session.requiresAction\",\n \"session.humanInput.requested\",\n \"usage.threshold_reached\",\n \"usage.exhausted\",\n \"usage.period_reset\",\n] as const;\n\n/**\n * Sent only when an administrator presses \"Send test event\". It is never a\n * subscribable type: every endpoint can receive it, and a receiver that does\n * not care acknowledges it with any 2xx.\n */\nexport const OPENGENI_WEBHOOK_TEST_EVENT_TYPE = \"webhook.test\";\n\n/**\n * The session, turn and attempt ids of a credential-provider test request\n * (`purpose: \"test\"`). A test is not a run, so no real ids exist.\n */\nexport const OPENGENI_TEST_REQUEST_NIL_ID = \"00000000-0000-0000-0000-000000000000\";\n\nexport const OPENGENI_SIGNATURE_HEADER = \"OpenGeni-Signature\";\nexport const OPENGENI_EVENT_ID_HEADER = \"OpenGeni-Event-Id\";\nexport const OPENGENI_DELIVERY_ID_HEADER = \"OpenGeni-Delivery-Id\";\nexport const OPENGENI_SIGNATURE_TOLERANCE_SECONDS = 300;\n\nconst encoder = new TextEncoder();\n\nasync function hmacSha256Hex(secret: string, message: string): Promise<string> {\n const key = await crypto.subtle.importKey(\n \"raw\",\n encoder.encode(secret),\n { name: \"HMAC\", hash: \"SHA-256\" },\n false,\n [\"sign\"],\n );\n const signature = new Uint8Array(await crypto.subtle.sign(\"HMAC\", key, encoder.encode(message)));\n return Array.from(signature, (byte) => byte.toString(16).padStart(2, \"0\")).join(\"\");\n}\n\nfunction constantTimeEqualHex(left: string, right: string): boolean {\n if (left.length !== right.length) return false;\n let difference = 0;\n for (let index = 0; index < left.length; index += 1) {\n difference |= left.charCodeAt(index) ^ right.charCodeAt(index);\n }\n return difference === 0;\n}\n\n/**\n * `OpenGeni-Signature: t=<unix seconds>,v1=<hex HMAC-SHA256(secret, \"<t>.<body>\")>`.\n * The timestamp is signed so a captured request cannot be replayed later.\n */\nexport async function signOpenGeniPayload(\n secret: string,\n body: string,\n timestampSeconds = Math.floor(Date.now() / 1000),\n): Promise<string> {\n return `t=${timestampSeconds},v1=${await hmacSha256Hex(secret, `${timestampSeconds}.${body}`)}`;\n}\n\nexport type VerifyOpenGeniSignatureInput = {\n secret: string;\n /** The exact raw request body, before JSON parsing. */\n body: string;\n /** The `OpenGeni-Signature` header value. */\n signature: string | null | undefined;\n toleranceSeconds?: number;\n nowSeconds?: number;\n};\n\nexport async function verifyOpenGeniSignature(\n input: VerifyOpenGeniSignatureInput,\n): Promise<boolean> {\n if (!input.signature) return false;\n let timestamp: number | null = null;\n const candidates: string[] = [];\n for (const part of input.signature.split(\",\")) {\n const [key, value] = part.trim().split(\"=\", 2);\n if (key === \"t\" && value && /^\\d{1,12}$/.test(value)) timestamp = Number(value);\n if (key === \"v1\" && value && /^[0-9a-f]{64}$/.test(value)) candidates.push(value);\n }\n if (timestamp === null || candidates.length === 0) return false;\n const now = input.nowSeconds ?? Math.floor(Date.now() / 1000);\n const tolerance = input.toleranceSeconds ?? OPENGENI_SIGNATURE_TOLERANCE_SECONDS;\n if (Math.abs(now - timestamp) > tolerance) return false;\n const expected = await hmacSha256Hex(input.sec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,CAAC,MAAM,UAAW,QAAO;AAC7B,MAAI,YAA2B;AAC/B,QAAM,aAAuB,CAAC;AAC9B,aAAW,QAAQ,MAAM,UAAU,MAAM,GAAG,GAAG;AAC7C,UAAM,CAAC,KAAK,KAAK,IAAI,KAAK,KAAK,EAAE,MAAM,KAAK,CAAC;AAC7C,QAAI,QAAQ,OAAO,SAAS,aAAa,KAAK,KAAK,EAAG,aAAY,OAAO,KAAK;AAC9E,QAAI,QAAQ,QAAQ,SAAS,iBAAiB,KAAK,KAAK,EAAG,YAAW,KAAK,KAAK;AAAA,EAClF;AACA,MAAI,cAAc,QAAQ,WAAW,WAAW,EAAG,QAAO;AAC1D,QAAM,MAAM,MAAM,cAAc,KAAK,MAAM,KAAK,IAAI,IAAI,GAAI;AAC5D,QAAM,YAAY,MAAM,oBAAoB;AAC5C,MAAI,KAAK,IAAI,MAAM,SAAS,IAAI,UAAW,QAAO;AAClD,QAAM,WAAW,MAAM,cAAc,MAAM,QAAQ,GAAG,SAAS,IAAI,MAAM,IAAI,EAAE;AAC/E,SAAO,WAAW,KAAK,CAAC,cAAc,qBAAqB,WAAW,QAAQ,CAAC;AACjF;","names":[]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// src/editable-artifact-versions.ts
|
|
2
|
+
var SPREADSHEET_ARTIFACT_MODEL_SCHEMA_VERSION = 2;
|
|
3
|
+
var DOCUMENT_ARTIFACT_MODEL_SCHEMA_VERSION = 1;
|
|
4
|
+
var PRESENTATION_ARTIFACT_MODEL_SCHEMA_VERSION = 1;
|
|
5
|
+
var SPREADSHEET_KERNEL_SNAPSHOT_VERSION = 2;
|
|
6
|
+
var DOCUMENT_ARTIFACT_SNAPSHOT_VERSION = 1;
|
|
7
|
+
var PRESENTATION_ARTIFACT_SNAPSHOT_VERSION = 1;
|
|
8
|
+
var SPREADSHEET_KERNEL_COMMAND_VERSION = 2;
|
|
9
|
+
var SPREADSHEET_ARTIFACT_COMMAND_VERSION = 2;
|
|
10
|
+
var SPREADSHEET_COLLABORATION_SNAPSHOT_VERSION = 2;
|
|
11
|
+
var COMMITTED_TRANSACTION_PROTOCOL_VERSION = 2;
|
|
12
|
+
var EDITABLE_ARTIFACT_SERIALIZED_COMMIT_VERSION = 1;
|
|
13
|
+
var EDITABLE_ARTIFACT_LIVE_WIRE_VERSION = 2;
|
|
14
|
+
|
|
15
|
+
export {
|
|
16
|
+
SPREADSHEET_ARTIFACT_MODEL_SCHEMA_VERSION,
|
|
17
|
+
DOCUMENT_ARTIFACT_MODEL_SCHEMA_VERSION,
|
|
18
|
+
PRESENTATION_ARTIFACT_MODEL_SCHEMA_VERSION,
|
|
19
|
+
SPREADSHEET_KERNEL_SNAPSHOT_VERSION,
|
|
20
|
+
DOCUMENT_ARTIFACT_SNAPSHOT_VERSION,
|
|
21
|
+
PRESENTATION_ARTIFACT_SNAPSHOT_VERSION,
|
|
22
|
+
SPREADSHEET_KERNEL_COMMAND_VERSION,
|
|
23
|
+
SPREADSHEET_ARTIFACT_COMMAND_VERSION,
|
|
24
|
+
SPREADSHEET_COLLABORATION_SNAPSHOT_VERSION,
|
|
25
|
+
COMMITTED_TRANSACTION_PROTOCOL_VERSION,
|
|
26
|
+
EDITABLE_ARTIFACT_SERIALIZED_COMMIT_VERSION,
|
|
27
|
+
EDITABLE_ARTIFACT_LIVE_WIRE_VERSION
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=chunk-PX3VCKAU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/editable-artifact-versions.ts"],"sourcesContent":["/** Modality-specific durable semantic/schema versions. */\nexport const SPREADSHEET_ARTIFACT_MODEL_SCHEMA_VERSION = 2 as const;\nexport const DOCUMENT_ARTIFACT_MODEL_SCHEMA_VERSION = 1 as const;\nexport const PRESENTATION_ARTIFACT_MODEL_SCHEMA_VERSION = 1 as const;\n\n/** Direct kernel workbook snapshot version (OGARTK02), never the durable CRDT snapshot. */\nexport const SPREADSHEET_KERNEL_SNAPSHOT_VERSION = 2 as const;\n\n/** Modality-specific canonical snapshot versions. */\nexport const DOCUMENT_ARTIFACT_SNAPSHOT_VERSION = 1 as const;\nexport const PRESENTATION_ARTIFACT_SNAPSHOT_VERSION = 1 as const;\n\n/** Canonical internal spreadsheet kernel command-envelope version. */\nexport const SPREADSHEET_KERNEL_COMMAND_VERSION = 2 as const;\n\n/** Canonical public, identity-free spreadsheet command-envelope version. */\nexport const SPREADSHEET_ARTIFACT_COMMAND_VERSION = 2 as const;\n\n/** Canonical durable spreadsheet collaboration-snapshot version. */\nexport const SPREADSHEET_COLLABORATION_SNAPSHOT_VERSION = 2 as const;\n\n/** Canonical committed spreadsheet transaction protocol version. */\nexport const COMMITTED_TRANSACTION_PROTOCOL_VERSION = 2 as const;\n\n/** Canonical document/presentation serialized-commit protocol version. */\nexport const EDITABLE_ARTIFACT_SERIALIZED_COMMIT_VERSION = 1 as const;\n\n/** Canonical editable-artifact live transport protocol version. */\nexport const EDITABLE_ARTIFACT_LIVE_WIRE_VERSION = 2 as const;\n"],"mappings":";AACO,IAAM,4CAA4C;AAClD,IAAM,yCAAyC;AAC/C,IAAM,6CAA6C;AAGnD,IAAM,sCAAsC;AAG5C,IAAM,qCAAqC;AAC3C,IAAM,yCAAyC;AAG/C,IAAM,qCAAqC;AAG3C,IAAM,uCAAuC;AAG7C,IAAM,6CAA6C;AAGnD,IAAM,yCAAyC;AAG/C,IAAM,8CAA8C;AAGpD,IAAM,sCAAsC;","names":[]}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// src/permissions.ts
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
var Permission = z.enum([
|
|
4
|
+
"account:read",
|
|
5
|
+
"account:admin",
|
|
6
|
+
"members:manage",
|
|
7
|
+
"workspace:create",
|
|
8
|
+
"billing:read",
|
|
9
|
+
"billing:manage",
|
|
10
|
+
"workspace:read",
|
|
11
|
+
"workspace:admin",
|
|
12
|
+
"sessions:create",
|
|
13
|
+
"sessions:read",
|
|
14
|
+
"sessions:control",
|
|
15
|
+
"stream:view",
|
|
16
|
+
"stream:control",
|
|
17
|
+
"stream:acknowledge",
|
|
18
|
+
"files:upload",
|
|
19
|
+
"files:read",
|
|
20
|
+
"files:write",
|
|
21
|
+
"terminal:attach",
|
|
22
|
+
"documents:manage",
|
|
23
|
+
"documents:search",
|
|
24
|
+
"scheduled_tasks:manage",
|
|
25
|
+
"scheduled_tasks:run",
|
|
26
|
+
"github:manage",
|
|
27
|
+
"github:use",
|
|
28
|
+
"api_keys:manage",
|
|
29
|
+
/** Literal organization-key authority to configure workspace usage allowances. */
|
|
30
|
+
"usage_allowances:manage",
|
|
31
|
+
"connections:read",
|
|
32
|
+
"connections:write",
|
|
33
|
+
"capabilities:manage",
|
|
34
|
+
/** @deprecated alias of variable-sets:manage */
|
|
35
|
+
"environments:manage",
|
|
36
|
+
/** @deprecated alias of variable-sets:use */
|
|
37
|
+
"environments:use",
|
|
38
|
+
"variable-sets:list",
|
|
39
|
+
"variable-sets:read",
|
|
40
|
+
"variable-sets:write",
|
|
41
|
+
"variable-sets:manage",
|
|
42
|
+
"variable-sets:attach",
|
|
43
|
+
"variable-sets:use",
|
|
44
|
+
"secrets:list",
|
|
45
|
+
"secrets:read",
|
|
46
|
+
"secrets:write",
|
|
47
|
+
"mcp_servers:attach",
|
|
48
|
+
"codemode:call",
|
|
49
|
+
"goals:manage",
|
|
50
|
+
"enrollments:read",
|
|
51
|
+
"enrollments:manage",
|
|
52
|
+
"rigs:use",
|
|
53
|
+
"rigs:manage",
|
|
54
|
+
"artifacts:read",
|
|
55
|
+
"artifacts:publish"
|
|
56
|
+
]);
|
|
57
|
+
|
|
58
|
+
export {
|
|
59
|
+
Permission
|
|
60
|
+
};
|
|
61
|
+
//# sourceMappingURL=chunk-QR5D2IQC.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/permissions.ts"],"sourcesContent":["import { z } from \"zod\";\n\n/** Canonical public permission vocabulary shared by operational and control-plane contracts. */\nexport const Permission = z.enum([\n \"account:read\",\n \"account:admin\",\n \"members:manage\",\n \"workspace:create\",\n \"billing:read\",\n \"billing:manage\",\n \"workspace:read\",\n \"workspace:admin\",\n \"sessions:create\",\n \"sessions:read\",\n \"sessions:control\",\n \"stream:view\",\n \"stream:control\",\n \"stream:acknowledge\",\n \"files:upload\",\n \"files:read\",\n \"files:write\",\n \"terminal:attach\",\n \"documents:manage\",\n \"documents:search\",\n \"scheduled_tasks:manage\",\n \"scheduled_tasks:run\",\n \"github:manage\",\n \"github:use\",\n \"api_keys:manage\",\n /** Literal organization-key authority to configure workspace usage allowances. */\n \"usage_allowances:manage\",\n \"connections:read\",\n \"connections:write\",\n \"capabilities:manage\",\n /** @deprecated alias of variable-sets:manage */\n \"environments:manage\",\n /** @deprecated alias of variable-sets:use */\n \"environments:use\",\n \"variable-sets:list\",\n \"variable-sets:read\",\n \"variable-sets:write\",\n \"variable-sets:manage\",\n \"variable-sets:attach\",\n \"variable-sets:use\",\n \"secrets:list\",\n \"secrets:read\",\n \"secrets:write\",\n \"mcp_servers:attach\",\n \"codemode:call\",\n \"goals:manage\",\n \"enrollments:read\",\n \"enrollments:manage\",\n \"rigs:use\",\n \"rigs:manage\",\n \"artifacts:read\",\n \"artifacts:publish\",\n]);\nexport type Permission = z.infer<typeof Permission>;\n"],"mappings":";AAAA,SAAS,SAAS;AAGX,IAAM,aAAa,EAAE,KAAK;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;","names":[]}
|