@opengeni/contracts 0.44.1 → 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 +27 -11
- 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/canonical-human-identities.d.ts +157 -0
- package/dist/canonical-human-identities.js +23 -0
- package/dist/canonical-human-identities.js.map +1 -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-52SGB2QO.js → chunk-5IXYF6XN.js} +50 -10
- 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-GRG7PHWQ.js +25 -0
- package/dist/chunk-GRG7PHWQ.js.map +1 -0
- package/dist/chunk-JUFK3T4Q.js +80 -0
- package/dist/chunk-JUFK3T4Q.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-H5BVCZKF.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-FJBG5E4O.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/codex-provider-account-authority.d.ts +23 -0
- package/dist/codex-provider-account-authority.js +23 -0
- package/dist/codex-provider-account-authority.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 +19 -9
- 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 +48 -36
- 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 +91 -15
- 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 +27574 -5374
- package/dist/index.js +2531 -177
- 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 +1752 -13
- package/dist/knowledge-entries.d.ts +982 -0
- package/dist/knowledge-preparation.d.ts +237 -0
- package/dist/knowledge.d.ts +740 -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/slack-task-policy.d.ts +294 -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 +169 -0
- 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 +51 -0
- package/dist/video-generation.js +9 -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 +26 -0
- package/dist/xai-provider-account-authority.js +9 -0
- package/dist/xai-provider-account-authority.js.map +1 -0
- package/package.json +146 -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/canonical-human-identities.ts +93 -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/codex-provider-account-authority.ts +37 -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 +8019 -1799
- package/src/insights-usage.ts +679 -0
- package/src/interaction.ts +1102 -6
- package/src/knowledge-entries.ts +375 -0
- package/src/knowledge-preparation.ts +50 -0
- package/src/knowledge.ts +335 -0
- 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/slack-task-policy.ts +215 -0
- package/src/spreadsheet-artifact-commands.ts +12 -13
- package/src/subscription-account-pools.ts +44 -0
- package/src/task-notes.ts +105 -0
- package/src/tool-catalog.ts +155 -0
- package/src/tool-result-spill.ts +35 -0
- package/src/usage-allowances.ts +187 -0
- package/src/video-generation.ts +43 -6
- 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 +38 -0
- package/dist/chunk-52SGB2QO.js.map +0 -1
- 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-FJBG5E4O.js.map +0 -1
- package/dist/chunk-H5BVCZKF.js.map +0 -1
- package/dist/chunk-LSB7GRLG.js.map +0 -1
- package/dist/chunk-TZ6YEYN4.js.map +0 -1
- package/dist/chunk-VA22KRHS.js +0 -15177
- package/dist/chunk-VA22KRHS.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,201 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
import { WorkspaceStateKnowledge } from "./workspace-state";
|
|
4
|
+
|
|
5
|
+
export const COMPANY_BRAIN_OKF_SCHEMA_VERSION = 1 as const;
|
|
6
|
+
export const COMPANY_BRAIN_GUIDANCE_MAX_ENTRIES = 512;
|
|
7
|
+
export const COMPANY_BRAIN_GUIDANCE_CONTENT_MAX_CHARS = 262_144;
|
|
8
|
+
export const COMPANY_BRAIN_GUIDANCE_MAX_CONTENT_BYTES = 4 * 1024 * 1024;
|
|
9
|
+
export const COMPANY_BRAIN_INSPECTOR_DEFAULT_LIMIT = 20;
|
|
10
|
+
export const COMPANY_BRAIN_INSPECTOR_MAX_LIMIT = 50;
|
|
11
|
+
export const COMPANY_BRAIN_INSPECTOR_CURSOR_MAX_CHARS = 1_024;
|
|
12
|
+
export const COMPANY_BRAIN_PROPOSAL_CONTENT_MAX_BYTES = 16 * 1_024;
|
|
13
|
+
export const COMPANY_BRAIN_PROPOSAL_RESPONSE_MAX_BYTES = 64 * 1_024;
|
|
14
|
+
|
|
15
|
+
const utf8Bytes = (value: string): number => new TextEncoder().encode(value).byteLength;
|
|
16
|
+
const boundedUtf8 = (maxBytes: number) =>
|
|
17
|
+
z.string().superRefine((value, context) => {
|
|
18
|
+
if (utf8Bytes(value) > maxBytes) {
|
|
19
|
+
context.addIssue({
|
|
20
|
+
code: z.ZodIssueCode.custom,
|
|
21
|
+
message: `must be at most ${maxBytes} UTF-8 bytes`,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
export const CompanyBrainContextReceipt = z
|
|
27
|
+
.object({
|
|
28
|
+
id: z.string().uuid(),
|
|
29
|
+
sessionId: z.string().uuid(),
|
|
30
|
+
rootSessionId: z.string().uuid(),
|
|
31
|
+
turnId: z.string().uuid(),
|
|
32
|
+
acceptedAt: z.string().datetime(),
|
|
33
|
+
createdAt: z.string().datetime(),
|
|
34
|
+
sessionRole: z.enum(["root", "child"]),
|
|
35
|
+
memoryEnabled: z.boolean(),
|
|
36
|
+
// Snapshots are immutable: a turn accepted before the standing block was
|
|
37
|
+
// retired recorded `legacy_standing` and still reads back that way. This
|
|
38
|
+
// is a historical fact about that turn, not a mode anyone can select.
|
|
39
|
+
memoryPromptMode: z.enum(["legacy_standing", "retrieval_only"]),
|
|
40
|
+
companyProfileIncluded: z.boolean(),
|
|
41
|
+
instructionPolicyEntryHash: z.string().regex(/^[0-9a-f]{64}$/u),
|
|
42
|
+
preferenceDescriptorHash: z
|
|
43
|
+
.string()
|
|
44
|
+
.regex(/^[0-9a-f]{64}$/u)
|
|
45
|
+
.nullable(),
|
|
46
|
+
companyProfileSnapshotHash: z.string().regex(/^[0-9a-f]{64}$/u),
|
|
47
|
+
turnContextSnapshotId: z.string().uuid(),
|
|
48
|
+
turnContextSnapshotHash: z.string().regex(/^[0-9a-f]{64}$/u),
|
|
49
|
+
turnContextSnapshotSource: z.enum(["accepted_turn", "legacy_first_claim"]),
|
|
50
|
+
selectionHash: z.string().regex(/^[0-9a-f]{64}$/u),
|
|
51
|
+
selectedMemoryCount: z.number().int().nonnegative().max(50),
|
|
52
|
+
renderedMemoryCount: z.number().int().nonnegative().max(50),
|
|
53
|
+
budgetOmittedMemoryCount: z.number().int().nonnegative().max(50),
|
|
54
|
+
})
|
|
55
|
+
.strict();
|
|
56
|
+
export type CompanyBrainContextReceipt = z.infer<typeof CompanyBrainContextReceipt>;
|
|
57
|
+
|
|
58
|
+
export const CompanyBrainContextReceiptPage = z
|
|
59
|
+
.object({
|
|
60
|
+
receipts: z.array(CompanyBrainContextReceipt).max(COMPANY_BRAIN_INSPECTOR_MAX_LIMIT),
|
|
61
|
+
nextCursor: z.string().min(1).max(COMPANY_BRAIN_INSPECTOR_CURSOR_MAX_CHARS).nullable(),
|
|
62
|
+
hasMore: z.boolean(),
|
|
63
|
+
})
|
|
64
|
+
.strict();
|
|
65
|
+
export type CompanyBrainContextReceiptPage = z.infer<typeof CompanyBrainContextReceiptPage>;
|
|
66
|
+
|
|
67
|
+
export const CompanyBrainKnowledgeProposal = z
|
|
68
|
+
.object({
|
|
69
|
+
id: z.string().uuid(),
|
|
70
|
+
authority: z.object({ kind: z.enum(["organization", "workspace", "personal"]) }).strict(),
|
|
71
|
+
targetKind: z.enum(["instruction_policy", "preference"]),
|
|
72
|
+
targetScope: z.string().min(1).max(96),
|
|
73
|
+
targetKey: z.string().min(1).max(96).nullable(),
|
|
74
|
+
content: boundedUtf8(COMPANY_BRAIN_PROPOSAL_CONTENT_MAX_BYTES),
|
|
75
|
+
contentHash: z.string().regex(/^[0-9a-f]{64}$/u),
|
|
76
|
+
source: z.object({ claimId: z.string().uuid(), evidenceId: z.string().uuid() }).strict(),
|
|
77
|
+
status: z.literal("proposed"),
|
|
78
|
+
createdAt: z.string().datetime(),
|
|
79
|
+
projection: z
|
|
80
|
+
.object({
|
|
81
|
+
truncated: z.boolean(),
|
|
82
|
+
originalContentUtf8Bytes: z.number().int().nonnegative().max(1_048_576),
|
|
83
|
+
})
|
|
84
|
+
.strict(),
|
|
85
|
+
})
|
|
86
|
+
.strict();
|
|
87
|
+
export type CompanyBrainKnowledgeProposal = z.infer<typeof CompanyBrainKnowledgeProposal>;
|
|
88
|
+
|
|
89
|
+
export const CompanyBrainKnowledgeProposalPage = z
|
|
90
|
+
.object({
|
|
91
|
+
proposals: z.array(CompanyBrainKnowledgeProposal).max(COMPANY_BRAIN_INSPECTOR_MAX_LIMIT),
|
|
92
|
+
truncatedForCount: z.boolean(),
|
|
93
|
+
truncatedForResponseBytes: z.boolean(),
|
|
94
|
+
responseBytes: z.number().int().nonnegative().max(COMPANY_BRAIN_PROPOSAL_RESPONSE_MAX_BYTES),
|
|
95
|
+
})
|
|
96
|
+
.strict();
|
|
97
|
+
export type CompanyBrainKnowledgeProposalPage = z.infer<typeof CompanyBrainKnowledgeProposalPage>;
|
|
98
|
+
|
|
99
|
+
export const CompanyBrainGuidanceClassification = z.enum([
|
|
100
|
+
"company_profile",
|
|
101
|
+
"mandatory_rule",
|
|
102
|
+
"guide",
|
|
103
|
+
]);
|
|
104
|
+
export type CompanyBrainGuidanceClassification = z.infer<typeof CompanyBrainGuidanceClassification>;
|
|
105
|
+
|
|
106
|
+
export const CompanyBrainGuidanceScope = z.enum(["organization", "workspace", "personal"]);
|
|
107
|
+
export type CompanyBrainGuidanceScope = z.infer<typeof CompanyBrainGuidanceScope>;
|
|
108
|
+
|
|
109
|
+
export const CompanyBrainGuidanceLifecycle = z.enum([
|
|
110
|
+
"active",
|
|
111
|
+
"proposal",
|
|
112
|
+
"inactive",
|
|
113
|
+
"rejected",
|
|
114
|
+
"superseded",
|
|
115
|
+
"expired",
|
|
116
|
+
"historical",
|
|
117
|
+
]);
|
|
118
|
+
export type CompanyBrainGuidanceLifecycle = z.infer<typeof CompanyBrainGuidanceLifecycle>;
|
|
119
|
+
|
|
120
|
+
export const CompanyBrainGuidanceRelationship = z
|
|
121
|
+
.object({
|
|
122
|
+
type: z.enum(["corrects", "supersedes", "superseded_by"]),
|
|
123
|
+
targetId: z.string().min(1).max(512),
|
|
124
|
+
})
|
|
125
|
+
.strict();
|
|
126
|
+
export type CompanyBrainGuidanceRelationship = z.infer<typeof CompanyBrainGuidanceRelationship>;
|
|
127
|
+
|
|
128
|
+
export const CompanyBrainGuidanceEntry = z
|
|
129
|
+
.object({
|
|
130
|
+
id: z.string().min(1).max(512),
|
|
131
|
+
revisionId: z.string().uuid(),
|
|
132
|
+
path: z.string().min(1).max(512),
|
|
133
|
+
scope: CompanyBrainGuidanceScope,
|
|
134
|
+
classification: CompanyBrainGuidanceClassification,
|
|
135
|
+
title: z.string().min(1).max(160),
|
|
136
|
+
description: z.string().max(512).nullable(),
|
|
137
|
+
content: z.string().min(1).max(COMPANY_BRAIN_GUIDANCE_CONTENT_MAX_CHARS),
|
|
138
|
+
contentHash: z.string().regex(/^[0-9a-f]{64}$/),
|
|
139
|
+
revision: z.number().int().positive(),
|
|
140
|
+
active: z.boolean(),
|
|
141
|
+
lifecycle: CompanyBrainGuidanceLifecycle,
|
|
142
|
+
provenance: z
|
|
143
|
+
.object({
|
|
144
|
+
source: z.string().min(1).max(96),
|
|
145
|
+
sourceId: z.string().min(1).max(512).nullable(),
|
|
146
|
+
trust: z.string().min(1).max(96).nullable(),
|
|
147
|
+
})
|
|
148
|
+
.strict(),
|
|
149
|
+
relationships: z.array(CompanyBrainGuidanceRelationship).max(32),
|
|
150
|
+
createdAt: z.string().datetime(),
|
|
151
|
+
})
|
|
152
|
+
.strict();
|
|
153
|
+
export type CompanyBrainGuidanceEntry = z.infer<typeof CompanyBrainGuidanceEntry>;
|
|
154
|
+
|
|
155
|
+
export const CompanyBrainGuidanceTruncationReason = z.enum([
|
|
156
|
+
"company_profile_history",
|
|
157
|
+
"instruction_policy_history",
|
|
158
|
+
"preference_count",
|
|
159
|
+
"preference_history",
|
|
160
|
+
"aggregate_item_count",
|
|
161
|
+
"aggregate_content_bytes",
|
|
162
|
+
]);
|
|
163
|
+
export type CompanyBrainGuidanceTruncationReason = z.infer<
|
|
164
|
+
typeof CompanyBrainGuidanceTruncationReason
|
|
165
|
+
>;
|
|
166
|
+
|
|
167
|
+
export const CompanyBrainOkfPackage = z
|
|
168
|
+
.object({
|
|
169
|
+
kind: z.literal("opengeni.company_brain.okf"),
|
|
170
|
+
schemaVersion: z.literal(COMPANY_BRAIN_OKF_SCHEMA_VERSION),
|
|
171
|
+
workspaceId: z.string().uuid(),
|
|
172
|
+
generatedAt: z.string().datetime(),
|
|
173
|
+
permissions: z
|
|
174
|
+
.object({
|
|
175
|
+
guidance: z.literal("available"),
|
|
176
|
+
knowledge: z.enum(["available", "unavailable"]),
|
|
177
|
+
})
|
|
178
|
+
.strict(),
|
|
179
|
+
guidance: z
|
|
180
|
+
.object({
|
|
181
|
+
entries: z.array(CompanyBrainGuidanceEntry).max(COMPANY_BRAIN_GUIDANCE_MAX_ENTRIES),
|
|
182
|
+
truncated: z.boolean(),
|
|
183
|
+
truncationReasons: z.array(CompanyBrainGuidanceTruncationReason).max(6),
|
|
184
|
+
})
|
|
185
|
+
.strict(),
|
|
186
|
+
knowledge: WorkspaceStateKnowledge,
|
|
187
|
+
omissions: z
|
|
188
|
+
.array(
|
|
189
|
+
z.enum([
|
|
190
|
+
"inaccessible_knowledge",
|
|
191
|
+
"document_bodies_use_documents_export",
|
|
192
|
+
"memory_bodies_and_provenance",
|
|
193
|
+
"secret_values_and_credentials",
|
|
194
|
+
"session_messages_and_task_notes",
|
|
195
|
+
"policy_and_preference_actor_identifiers",
|
|
196
|
+
]),
|
|
197
|
+
)
|
|
198
|
+
.max(6),
|
|
199
|
+
})
|
|
200
|
+
.strict();
|
|
201
|
+
export type CompanyBrainOkfPackage = z.infer<typeof CompanyBrainOkfPackage>;
|
package/src/company-profile.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import {
|
|
3
|
+
AGENT_AUTHORED_COMPANY_PROFILE_CONTENT_MAX_UTF8_BYTES,
|
|
4
|
+
AGENT_AUTHORED_COMPANY_PROFILE_ENTRY_MAX_CHARS,
|
|
5
|
+
AGENT_AUTHORED_COMPANY_PROFILE_SCALAR_MAX_CHARS,
|
|
6
|
+
AGENT_AUTHORED_COMPANY_PROFILE_TOO_LONG_MESSAGE,
|
|
7
|
+
} from "./agent-authored-durable-text";
|
|
8
|
+
import { HumanInputQuestion } from "./index";
|
|
2
9
|
|
|
3
10
|
export const COMPANY_PROFILE_SCALAR_MAX_CHARS = 2_048;
|
|
4
11
|
export const COMPANY_PROFILE_ENTRY_MAX_CHARS = 1_024;
|
|
@@ -100,10 +107,56 @@ export const CompanyProfileContent = z
|
|
|
100
107
|
});
|
|
101
108
|
export type CompanyProfileContent = z.infer<typeof CompanyProfileContent>;
|
|
102
109
|
|
|
110
|
+
/**
|
|
111
|
+
* The same profile, bounded for an **agent** author. The human `account:admin`
|
|
112
|
+
* route keeps `CompanyProfileContent` and its wider limits; this is the shape
|
|
113
|
+
* persisted by the first-party `company_profile_propose` tool. The current tool
|
|
114
|
+
* accepts only identity and mission and writes empty compatibility lists, but
|
|
115
|
+
* the validator must still read historical revisions without rewriting them.
|
|
116
|
+
*/
|
|
117
|
+
export const AgentAuthoredCompanyProfileContent = CompanyProfileContent.superRefine(
|
|
118
|
+
(value, context) => {
|
|
119
|
+
for (const field of ["identity", "mission"] as const) {
|
|
120
|
+
const scalar = value[field];
|
|
121
|
+
if (scalar !== null && scalar.length > AGENT_AUTHORED_COMPANY_PROFILE_SCALAR_MAX_CHARS) {
|
|
122
|
+
context.addIssue({
|
|
123
|
+
code: "custom",
|
|
124
|
+
path: [field],
|
|
125
|
+
message: `${field} is ${scalar.length} characters. ${AGENT_AUTHORED_COMPANY_PROFILE_TOO_LONG_MESSAGE}`,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
for (const field of ["products", "customers", "goals", "constraints"] as const) {
|
|
130
|
+
for (const [index, entry] of value[field].entries()) {
|
|
131
|
+
if (entry.content.length > AGENT_AUTHORED_COMPANY_PROFILE_ENTRY_MAX_CHARS) {
|
|
132
|
+
context.addIssue({
|
|
133
|
+
code: "custom",
|
|
134
|
+
path: [field, index, "content"],
|
|
135
|
+
message: `this entry is ${entry.content.length} characters. ${AGENT_AUTHORED_COMPANY_PROFILE_TOO_LONG_MESSAGE}`,
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
const contentBytes = new TextEncoder().encode(JSON.stringify(value)).byteLength;
|
|
141
|
+
if (contentBytes > AGENT_AUTHORED_COMPANY_PROFILE_CONTENT_MAX_UTF8_BYTES) {
|
|
142
|
+
context.addIssue({
|
|
143
|
+
code: "custom",
|
|
144
|
+
message: `this profile is ${contentBytes} UTF-8 bytes. ${AGENT_AUTHORED_COMPANY_PROFILE_TOO_LONG_MESSAGE}`,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
);
|
|
149
|
+
export type AgentAuthoredCompanyProfileContent = z.infer<typeof AgentAuthoredCompanyProfileContent>;
|
|
150
|
+
|
|
103
151
|
export const CompanyProfileRevisionIntent = z.enum(["active", "proposal"]);
|
|
104
152
|
export type CompanyProfileRevisionIntent = z.infer<typeof CompanyProfileRevisionIntent>;
|
|
105
153
|
|
|
106
|
-
export const CompanyProfileProvenanceSource = z.enum([
|
|
154
|
+
export const CompanyProfileProvenanceSource = z.enum([
|
|
155
|
+
"human",
|
|
156
|
+
"agent_admin",
|
|
157
|
+
"durable_learning",
|
|
158
|
+
"migration",
|
|
159
|
+
]);
|
|
107
160
|
export type CompanyProfileProvenanceSource = z.infer<typeof CompanyProfileProvenanceSource>;
|
|
108
161
|
|
|
109
162
|
export const CompanyProfilePrincipalKind = z.enum(["human_session", "agent_attempt", "service"]);
|
|
@@ -240,6 +293,119 @@ export const CompanyProfileMutationResponse = z.object({
|
|
|
240
293
|
});
|
|
241
294
|
export type CompanyProfileMutationResponse = z.infer<typeof CompanyProfileMutationResponse>;
|
|
242
295
|
|
|
296
|
+
export const COMPANY_PROFILE_AGENT_APPROVE_OPTION = "activate" as const;
|
|
297
|
+
export const COMPANY_PROFILE_AGENT_REJECT_OPTION = "skip" as const;
|
|
298
|
+
|
|
299
|
+
export const CompanyProfileAgentPolicyMode = z.enum(["off", "suggest", "automatic"]);
|
|
300
|
+
export type CompanyProfileAgentPolicyMode = z.infer<typeof CompanyProfileAgentPolicyMode>;
|
|
301
|
+
|
|
302
|
+
export const CompanyProfileAgentPolicy = z.object({
|
|
303
|
+
organizationId: z.string().uuid(),
|
|
304
|
+
mode: CompanyProfileAgentPolicyMode,
|
|
305
|
+
version: z.number().int().nonnegative(),
|
|
306
|
+
updatedAt: z.string().datetime({ offset: true }),
|
|
307
|
+
changed: z.boolean().optional(),
|
|
308
|
+
});
|
|
309
|
+
export type CompanyProfileAgentPolicy = z.infer<typeof CompanyProfileAgentPolicy>;
|
|
310
|
+
|
|
311
|
+
export const UpdateCompanyProfileAgentPolicyRequest = z
|
|
312
|
+
.object({
|
|
313
|
+
mode: CompanyProfileAgentPolicyMode,
|
|
314
|
+
expectedVersion: z.number().int().nonnegative(),
|
|
315
|
+
operationId: z.string().uuid(),
|
|
316
|
+
})
|
|
317
|
+
.strict();
|
|
318
|
+
export type UpdateCompanyProfileAgentPolicyRequest = z.infer<
|
|
319
|
+
typeof UpdateCompanyProfileAgentPolicyRequest
|
|
320
|
+
>;
|
|
321
|
+
|
|
322
|
+
export const CompanyProfileAgentAttempt = z
|
|
323
|
+
.object({
|
|
324
|
+
accountId: z.string().uuid(),
|
|
325
|
+
workspaceId: z.string().uuid(),
|
|
326
|
+
sessionId: z.string().uuid(),
|
|
327
|
+
turnId: z.string().uuid(),
|
|
328
|
+
attemptId: z.string().uuid(),
|
|
329
|
+
executionGeneration: z.number().int().positive(),
|
|
330
|
+
agentSubjectId: z.string().trim().min(1).max(1_024),
|
|
331
|
+
})
|
|
332
|
+
.strict();
|
|
333
|
+
export type CompanyProfileAgentAttempt = z.infer<typeof CompanyProfileAgentAttempt>;
|
|
334
|
+
|
|
335
|
+
export const CompanyProfileAgentProposalRequest = z
|
|
336
|
+
.object({
|
|
337
|
+
operationId: z.string().uuid(),
|
|
338
|
+
profile: CompanyProfileContent,
|
|
339
|
+
reason: z.string().trim().min(1).max(COMPANY_PROFILE_REASON_MAX_CHARS),
|
|
340
|
+
})
|
|
341
|
+
.strict();
|
|
342
|
+
export type CompanyProfileAgentProposalRequest = z.infer<typeof CompanyProfileAgentProposalRequest>;
|
|
343
|
+
|
|
344
|
+
// z.lazy avoids an import cycle because HumanInputQuestion is declared in the
|
|
345
|
+
// root contracts module that re-exports this file.
|
|
346
|
+
export const CompanyProfileAgentHumanInputPrompt = z.object({
|
|
347
|
+
questions: z.array(z.lazy(() => HumanInputQuestion)).length(1),
|
|
348
|
+
allowSkip: z.literal(false),
|
|
349
|
+
});
|
|
350
|
+
export type CompanyProfileAgentHumanInputPrompt = z.infer<
|
|
351
|
+
typeof CompanyProfileAgentHumanInputPrompt
|
|
352
|
+
>;
|
|
353
|
+
|
|
354
|
+
export const CompanyProfileAgentReviewRequiredReceipt = z.object({
|
|
355
|
+
status: z.literal("confirmation_required"),
|
|
356
|
+
operationId: z.string().uuid(),
|
|
357
|
+
proposalReceiptId: z.string().uuid(),
|
|
358
|
+
revision: CompanyProfileRevision,
|
|
359
|
+
policyMode: z.literal("suggest"),
|
|
360
|
+
humanInput: CompanyProfileAgentHumanInputPrompt,
|
|
361
|
+
confirmWith: z.literal("company_profile_confirm"),
|
|
362
|
+
replayed: z.boolean(),
|
|
363
|
+
});
|
|
364
|
+
export type CompanyProfileAgentReviewRequiredReceipt = z.infer<
|
|
365
|
+
typeof CompanyProfileAgentReviewRequiredReceipt
|
|
366
|
+
>;
|
|
367
|
+
|
|
368
|
+
export const CompanyProfileAgentAutomaticActivationReceipt = z.object({
|
|
369
|
+
status: z.literal("activated"),
|
|
370
|
+
operationId: z.string().uuid(),
|
|
371
|
+
proposalReceiptId: z.string().uuid(),
|
|
372
|
+
automaticActivationReceiptId: z.string().uuid(),
|
|
373
|
+
policyMode: z.literal("automatic"),
|
|
374
|
+
mutation: CompanyProfileMutationResponse,
|
|
375
|
+
replayed: z.boolean(),
|
|
376
|
+
});
|
|
377
|
+
export type CompanyProfileAgentAutomaticActivationReceipt = z.infer<
|
|
378
|
+
typeof CompanyProfileAgentAutomaticActivationReceipt
|
|
379
|
+
>;
|
|
380
|
+
|
|
381
|
+
export const CompanyProfileAgentProposalReceipt = z.discriminatedUnion("status", [
|
|
382
|
+
CompanyProfileAgentReviewRequiredReceipt,
|
|
383
|
+
CompanyProfileAgentAutomaticActivationReceipt,
|
|
384
|
+
]);
|
|
385
|
+
export type CompanyProfileAgentProposalReceipt = z.infer<typeof CompanyProfileAgentProposalReceipt>;
|
|
386
|
+
|
|
387
|
+
export const CompanyProfileAgentConfirmRequest = z
|
|
388
|
+
.object({
|
|
389
|
+
operationId: z.string().uuid(),
|
|
390
|
+
proposalReceiptId: z.string().uuid(),
|
|
391
|
+
humanInputRequestId: z.string().uuid(),
|
|
392
|
+
})
|
|
393
|
+
.strict();
|
|
394
|
+
export type CompanyProfileAgentConfirmRequest = z.infer<typeof CompanyProfileAgentConfirmRequest>;
|
|
395
|
+
|
|
396
|
+
export const CompanyProfileAgentConfirmationReceipt = z.object({
|
|
397
|
+
status: z.literal("activated"),
|
|
398
|
+
operationId: z.string().uuid(),
|
|
399
|
+
confirmationReceiptId: z.string().uuid(),
|
|
400
|
+
proposalReceiptId: z.string().uuid(),
|
|
401
|
+
humanInputRequestId: z.string().uuid(),
|
|
402
|
+
mutation: CompanyProfileMutationResponse,
|
|
403
|
+
replayed: z.boolean(),
|
|
404
|
+
});
|
|
405
|
+
export type CompanyProfileAgentConfirmationReceipt = z.infer<
|
|
406
|
+
typeof CompanyProfileAgentConfirmationReceipt
|
|
407
|
+
>;
|
|
408
|
+
|
|
243
409
|
export const CompanyProfileDiffRequest = z
|
|
244
410
|
.object({ fromRevisionId: z.string().uuid(), toRevisionId: z.string().uuid() })
|
|
245
411
|
.refine((value) => value.fromRevisionId !== value.toRevisionId, {
|
package/src/connect.ts
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { IntegrationInstanceKey, IntegrationSource } from "./index";
|
|
3
|
+
|
|
4
|
+
const opaqueId = z.string().min(1).max(512);
|
|
5
|
+
export const ConnectOwnership = z.enum(["personal", "workspace"]);
|
|
6
|
+
export type ConnectOwnership = z.infer<typeof ConnectOwnership>;
|
|
7
|
+
export const ConnectProvider = z
|
|
8
|
+
.object({
|
|
9
|
+
id: opaqueId,
|
|
10
|
+
label: z.string().min(1).max(256),
|
|
11
|
+
family: opaqueId,
|
|
12
|
+
readiness: z.enum(["available", "needs_configuration", "operator_only", "unsupported"]),
|
|
13
|
+
reason: z.string().max(1024).optional(),
|
|
14
|
+
ownership: z.array(ConnectOwnership).max(2),
|
|
15
|
+
setup: z
|
|
16
|
+
.array(
|
|
17
|
+
z.enum(["none", "oauth", "credentials", "device", "installation", "openapi", "graphql"]),
|
|
18
|
+
)
|
|
19
|
+
.max(7),
|
|
20
|
+
})
|
|
21
|
+
.strict();
|
|
22
|
+
export type ConnectProvider = z.infer<typeof ConnectProvider>;
|
|
23
|
+
export const ConnectAccount = z
|
|
24
|
+
.object({
|
|
25
|
+
id: opaqueId,
|
|
26
|
+
providerId: opaqueId,
|
|
27
|
+
version: z.number().int().positive().optional(),
|
|
28
|
+
label: z.string().max(256),
|
|
29
|
+
ownership: ConnectOwnership,
|
|
30
|
+
status: z.enum(["connected", "auth_needed", "disabled"]),
|
|
31
|
+
})
|
|
32
|
+
.strict();
|
|
33
|
+
export type ConnectAccount = z.infer<typeof ConnectAccount>;
|
|
34
|
+
export const ConnectResource = z
|
|
35
|
+
.object({ id: opaqueId, label: z.string().max(512), kind: opaqueId })
|
|
36
|
+
.strict();
|
|
37
|
+
export type ConnectResource = z.infer<typeof ConnectResource>;
|
|
38
|
+
export const ConnectNextAction = z.discriminatedUnion("type", [
|
|
39
|
+
z.object({ type: z.literal("authorize"), url: z.string().url().max(16_384) }).strict(),
|
|
40
|
+
z
|
|
41
|
+
.object({
|
|
42
|
+
type: z.literal("credentials"),
|
|
43
|
+
fields: z
|
|
44
|
+
.array(
|
|
45
|
+
z
|
|
46
|
+
.object({
|
|
47
|
+
name: opaqueId,
|
|
48
|
+
label: z.string().max(256),
|
|
49
|
+
required: z.boolean(),
|
|
50
|
+
secret: z.boolean(),
|
|
51
|
+
options: z
|
|
52
|
+
.array(z.object({ value: opaqueId, label: z.string().max(512) }).strict())
|
|
53
|
+
.max(1000)
|
|
54
|
+
.optional(),
|
|
55
|
+
})
|
|
56
|
+
.strict(),
|
|
57
|
+
)
|
|
58
|
+
.max(32),
|
|
59
|
+
})
|
|
60
|
+
.strict(),
|
|
61
|
+
z
|
|
62
|
+
.object({
|
|
63
|
+
type: z.literal("wait"),
|
|
64
|
+
pollAfterMs: z.number().int().min(250).max(60_000),
|
|
65
|
+
userCode: z.string().max(128).optional(),
|
|
66
|
+
verificationUrl: z.string().url().max(2048).optional(),
|
|
67
|
+
})
|
|
68
|
+
.strict(),
|
|
69
|
+
z
|
|
70
|
+
.object({ type: z.literal("select_account"), accounts: z.array(ConnectAccount).max(100) })
|
|
71
|
+
.strict(),
|
|
72
|
+
z
|
|
73
|
+
.object({
|
|
74
|
+
type: z.literal("select_resources"),
|
|
75
|
+
resources: z.array(ConnectResource).max(100),
|
|
76
|
+
cursor: z.string().max(2048).optional(),
|
|
77
|
+
})
|
|
78
|
+
.strict(),
|
|
79
|
+
z
|
|
80
|
+
.object({
|
|
81
|
+
type: z.literal("preview"),
|
|
82
|
+
previewId: opaqueId,
|
|
83
|
+
contentHash: opaqueId,
|
|
84
|
+
operations: z.array(ConnectResource).max(2000),
|
|
85
|
+
})
|
|
86
|
+
.strict(),
|
|
87
|
+
z.object({ type: z.literal("none") }).strict(),
|
|
88
|
+
]);
|
|
89
|
+
export type ConnectNextAction = z.infer<typeof ConnectNextAction>;
|
|
90
|
+
export const ConnectInstallationTarget = z
|
|
91
|
+
.object({
|
|
92
|
+
instanceKey: IntegrationInstanceKey,
|
|
93
|
+
displayName: z.string().min(1).max(200),
|
|
94
|
+
expectedInstanceVersion: z.number().int().positive().optional(),
|
|
95
|
+
})
|
|
96
|
+
.strict();
|
|
97
|
+
export type ConnectInstallationTarget = z.infer<typeof ConnectInstallationTarget>;
|
|
98
|
+
export const ConnectAttemptState = z.enum([
|
|
99
|
+
"ready",
|
|
100
|
+
"requires_user_action",
|
|
101
|
+
"credential_input",
|
|
102
|
+
"provider_wait",
|
|
103
|
+
"account_selection",
|
|
104
|
+
"resource_selection",
|
|
105
|
+
"preview",
|
|
106
|
+
"installing",
|
|
107
|
+
"connected_but_incomplete",
|
|
108
|
+
"complete",
|
|
109
|
+
"cancelled",
|
|
110
|
+
"expired",
|
|
111
|
+
"failed",
|
|
112
|
+
"uncertain",
|
|
113
|
+
]);
|
|
114
|
+
export const ConnectAttempt = z
|
|
115
|
+
.object({
|
|
116
|
+
id: opaqueId,
|
|
117
|
+
workspaceId: opaqueId,
|
|
118
|
+
providerId: opaqueId,
|
|
119
|
+
ownership: ConnectOwnership,
|
|
120
|
+
revision: z.number().int().positive(),
|
|
121
|
+
state: ConnectAttemptState,
|
|
122
|
+
credentialsCommitted: z.boolean(),
|
|
123
|
+
integrationInstalled: z.boolean(),
|
|
124
|
+
completionRequirement: z.enum(["connection", "integration", "provider_setup"]),
|
|
125
|
+
nextAction: ConnectNextAction,
|
|
126
|
+
expiresAt: z.string().datetime({ offset: true }),
|
|
127
|
+
account: ConnectAccount.optional(),
|
|
128
|
+
installationTarget: ConnectInstallationTarget.optional(),
|
|
129
|
+
source: IntegrationSource.optional(),
|
|
130
|
+
error: z
|
|
131
|
+
.object({ code: opaqueId, message: z.string().max(2048), retryable: z.boolean() })
|
|
132
|
+
.strict()
|
|
133
|
+
.optional(),
|
|
134
|
+
})
|
|
135
|
+
.strict()
|
|
136
|
+
.superRefine((value, context) => {
|
|
137
|
+
if (
|
|
138
|
+
value.state === "complete" &&
|
|
139
|
+
value.completionRequirement === "integration" &&
|
|
140
|
+
!value.integrationInstalled
|
|
141
|
+
) {
|
|
142
|
+
context.addIssue({
|
|
143
|
+
code: "custom",
|
|
144
|
+
message: "Complete setup requires an installed integration",
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
if (
|
|
148
|
+
value.state === "complete" &&
|
|
149
|
+
value.completionRequirement === "connection" &&
|
|
150
|
+
!value.credentialsCommitted
|
|
151
|
+
) {
|
|
152
|
+
context.addIssue({
|
|
153
|
+
code: "custom",
|
|
154
|
+
message: "Connection setup requires committed credentials",
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
if (
|
|
158
|
+
["complete", "cancelled", "expired"].includes(value.state) &&
|
|
159
|
+
value.nextAction.type !== "none"
|
|
160
|
+
) {
|
|
161
|
+
context.addIssue({ code: "custom", message: "A terminal setup has no next action" });
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
export type ConnectAttempt = z.infer<typeof ConnectAttempt>;
|
|
165
|
+
export const ConnectAdvance = z.discriminatedUnion("type", [
|
|
166
|
+
z
|
|
167
|
+
.object({
|
|
168
|
+
type: z.literal("credentials"),
|
|
169
|
+
values: z.record(z.string().max(256), z.string().max(16_384)),
|
|
170
|
+
})
|
|
171
|
+
.strict(),
|
|
172
|
+
z.object({ type: z.literal("account"), accountId: opaqueId }).strict(),
|
|
173
|
+
z.object({ type: z.literal("resources"), resourceIds: z.array(opaqueId).max(1000) }).strict(),
|
|
174
|
+
z
|
|
175
|
+
.object({
|
|
176
|
+
type: z.literal("install"),
|
|
177
|
+
previewId: opaqueId,
|
|
178
|
+
contentHash: opaqueId,
|
|
179
|
+
operationIds: z.array(opaqueId).max(2000),
|
|
180
|
+
})
|
|
181
|
+
.strict(),
|
|
182
|
+
z.object({ type: z.literal("retry") }).strict(),
|
|
183
|
+
]);
|
|
184
|
+
export type ConnectAdvance = z.infer<typeof ConnectAdvance>;
|
|
185
|
+
export const ConnectOperationRequest = z
|
|
186
|
+
.object({
|
|
187
|
+
expectedRevision: z.number().int().positive().safe(),
|
|
188
|
+
idempotencyKey: opaqueId,
|
|
189
|
+
})
|
|
190
|
+
.strict();
|
|
191
|
+
export const AdvanceConnectRequest = ConnectOperationRequest.extend({ action: ConnectAdvance });
|
|
192
|
+
export const BeginConnectRequest = z
|
|
193
|
+
.object({
|
|
194
|
+
providerId: opaqueId,
|
|
195
|
+
ownership: ConnectOwnership,
|
|
196
|
+
// URL parsing validates separately; never transform this original string.
|
|
197
|
+
returnUrl: z.string().min(1).max(4096),
|
|
198
|
+
idempotencyKey: opaqueId,
|
|
199
|
+
reconnectAccountId: opaqueId.optional(),
|
|
200
|
+
installationTarget: ConnectInstallationTarget.optional(),
|
|
201
|
+
})
|
|
202
|
+
.strict();
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/** Display identity from an already authorized connection. Never used to select credentials. */
|
|
2
|
+
export function connectionAccountIdentityLabel(
|
|
3
|
+
metadata: Record<string, unknown>,
|
|
4
|
+
fallback: string,
|
|
5
|
+
): string {
|
|
6
|
+
const text = (value: unknown): string | undefined =>
|
|
7
|
+
typeof value === "string" && value.trim()
|
|
8
|
+
? value
|
|
9
|
+
.replace(/[\u0000-\u001f\u007f]/gu, " ")
|
|
10
|
+
.trim()
|
|
11
|
+
.slice(0, 180)
|
|
12
|
+
: undefined;
|
|
13
|
+
const nestedName = (value: unknown): unknown =>
|
|
14
|
+
value && typeof value === "object" ? (value as Record<string, unknown>).name : value;
|
|
15
|
+
const name =
|
|
16
|
+
[
|
|
17
|
+
metadata.email,
|
|
18
|
+
metadata.providerEmail,
|
|
19
|
+
metadata.googleEmail,
|
|
20
|
+
metadata.gmailEmail,
|
|
21
|
+
metadata.accountLabel,
|
|
22
|
+
metadata.displayName,
|
|
23
|
+
metadata.providerDisplayName,
|
|
24
|
+
metadata.googleDisplayName,
|
|
25
|
+
metadata.accountName,
|
|
26
|
+
metadata.name,
|
|
27
|
+
metadata.slackUserName,
|
|
28
|
+
metadata.username,
|
|
29
|
+
metadata.slackUserId,
|
|
30
|
+
]
|
|
31
|
+
.map(text)
|
|
32
|
+
.find(Boolean) ?? fallback;
|
|
33
|
+
const workspace = [
|
|
34
|
+
metadata.slackTeamName,
|
|
35
|
+
metadata.teamName,
|
|
36
|
+
metadata.workspaceName,
|
|
37
|
+
metadata.team_name,
|
|
38
|
+
metadata.workspace_name,
|
|
39
|
+
nestedName(metadata.team),
|
|
40
|
+
nestedName(metadata.workspace),
|
|
41
|
+
metadata.slackTeamId,
|
|
42
|
+
]
|
|
43
|
+
.map(text)
|
|
44
|
+
.find(Boolean);
|
|
45
|
+
return [...new Set([name, workspace].filter(Boolean))].join(" · ");
|
|
46
|
+
}
|