@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,105 @@
|
|
|
1
|
+
// Resolvers for the optional Jev-backed `code_search` agent tool. A separate
|
|
2
|
+
// subpath keeps them out of browser bundles; only server code decides.
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Directories holding platform credential material that `code_search` never
|
|
6
|
+
* searches or reads, as path segments matched at any depth: OpenGeni's
|
|
7
|
+
* sandbox state (`.opengeni/`: Codemode bearer tokens, Git credential files
|
|
8
|
+
* and bindings), the Azure CLI login cache (`.azure/`, from the sandbox's
|
|
9
|
+
* service-principal login with HOME=/workspace) and a Connected Machine
|
|
10
|
+
* agent's enrollment credentials (`.config/opengeni/`). The sandbox channel
|
|
11
|
+
* enforces this list; `@opengeni/jev` keeps the same list for its engine, and
|
|
12
|
+
* a worker test pins that the two agree.
|
|
13
|
+
*/
|
|
14
|
+
export const CODE_SEARCH_CREDENTIAL_DIRS: readonly (readonly string[])[] = [
|
|
15
|
+
[".opengeni"],
|
|
16
|
+
[".azure"],
|
|
17
|
+
[".config", "opengeni"],
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The deployment half of the `code_search` decision. `split` gives the tool to
|
|
22
|
+
* a fixed half of sessions (see `codeSearchSessionInExperiment`) so staging can
|
|
23
|
+
* compare sessions with and without it.
|
|
24
|
+
*/
|
|
25
|
+
export type CodeSearchWorkspaceDefault = "off" | "on" | "split";
|
|
26
|
+
export type CodeSearchDeploymentPolicy = {
|
|
27
|
+
available: boolean;
|
|
28
|
+
workspaceDefault: CodeSearchWorkspaceDefault;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* What a workspace gets: the deployment decides first, so nothing enables the
|
|
33
|
+
* tool where the deployment does not offer it. Otherwise an explicit workspace
|
|
34
|
+
* choice wins, and an absent, null or malformed setting follows the deployment
|
|
35
|
+
* default. Only this field is read, so an invalid sibling setting cannot turn
|
|
36
|
+
* an explicit Off back into the deployment default.
|
|
37
|
+
*/
|
|
38
|
+
export function resolveWorkspaceCodeSearchMode(
|
|
39
|
+
settings: unknown,
|
|
40
|
+
deployment: CodeSearchDeploymentPolicy,
|
|
41
|
+
): CodeSearchWorkspaceDefault {
|
|
42
|
+
if (!deployment.available) return "off";
|
|
43
|
+
const explicit = explicitWorkspaceCodeSearchSetting(settings);
|
|
44
|
+
if (explicit === true) return "on";
|
|
45
|
+
if (explicit === false) return "off";
|
|
46
|
+
return deployment.workspaceDefault;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function explicitWorkspaceCodeSearchSetting(settings: unknown): boolean | undefined {
|
|
50
|
+
const explicit =
|
|
51
|
+
typeof settings === "object" && settings !== null
|
|
52
|
+
? (settings as { codeSearchEnabled?: unknown }).codeSearchEnabled
|
|
53
|
+
: undefined;
|
|
54
|
+
return typeof explicit === "boolean" ? explicit : undefined;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Fixed per-session half for the `split` experiment: 32-bit FNV-1a of the
|
|
59
|
+
* session id, low bit 0 gets the tool. Deterministic and dependency-free, so
|
|
60
|
+
* a root session's arm can be recomputed from its id. Child sessions inherit
|
|
61
|
+
* their parent's decision instead.
|
|
62
|
+
*/
|
|
63
|
+
export function codeSearchSessionInExperiment(sessionId: string): boolean {
|
|
64
|
+
let hash = 0x811c9dc5;
|
|
65
|
+
for (let index = 0; index < sessionId.length; index++) {
|
|
66
|
+
hash ^= sessionId.charCodeAt(index);
|
|
67
|
+
hash = Math.imul(hash, 0x01000193) >>> 0;
|
|
68
|
+
}
|
|
69
|
+
return (hash & 1) === 0;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* The decision frozen on a new root session when it is created. Later changes
|
|
74
|
+
* to the workspace setting or the deployment mode never turn the tool on for a
|
|
75
|
+
* session that was created without it.
|
|
76
|
+
*/
|
|
77
|
+
export function resolveSessionCodeSearchEnabled(
|
|
78
|
+
settings: unknown,
|
|
79
|
+
deployment: CodeSearchDeploymentPolicy,
|
|
80
|
+
sessionId: string,
|
|
81
|
+
): boolean {
|
|
82
|
+
const mode = resolveWorkspaceCodeSearchMode(settings, deployment);
|
|
83
|
+
return mode === "on" || (mode === "split" && codeSearchSessionInExperiment(sessionId));
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Whether a turn of this session gets `code_search`. Only a session frozen on
|
|
88
|
+
* at creation can have it. The deployment (mode off or no usable key) and an
|
|
89
|
+
* explicit workspace Off still pause it in running sessions, because they stop
|
|
90
|
+
* repository content going to Jev; undoing that switch-off gives it back to
|
|
91
|
+
* sessions frozen on. Each such change costs every affected session one
|
|
92
|
+
* prompt-cache miss, which is accepted for a deliberate switch. Nothing else
|
|
93
|
+
* changes the tool list of a running session.
|
|
94
|
+
*/
|
|
95
|
+
export function codeSearchEnabledForTurn(
|
|
96
|
+
frozen: boolean | null | undefined,
|
|
97
|
+
settings: unknown,
|
|
98
|
+
deployment: CodeSearchDeploymentPolicy,
|
|
99
|
+
): boolean {
|
|
100
|
+
return (
|
|
101
|
+
frozen === true &&
|
|
102
|
+
deployment.available &&
|
|
103
|
+
explicitWorkspaceCodeSearchSetting(settings) !== false
|
|
104
|
+
);
|
|
105
|
+
}
|
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import {
|
|
3
|
+
AGENT_AUTHORED_INSTRUCTION_POLICY_CONTENT_MAX_CHARS,
|
|
4
|
+
AGENT_AUTHORED_INSTRUCTION_POLICY_CONTENT_TOO_LONG_MESSAGE,
|
|
5
|
+
AGENT_AUTHORED_PREFERENCE_CONTENT_MAX_CHARS,
|
|
6
|
+
AGENT_AUTHORED_PREFERENCE_CONTENT_TOO_LONG_MESSAGE,
|
|
7
|
+
} from "./agent-authored-durable-text";
|
|
8
|
+
import {
|
|
9
|
+
PREFERENCE_REGISTRY_DESCRIPTOR_DESCRIPTION_MAX_CHARS,
|
|
10
|
+
PREFERENCE_REGISTRY_STABLE_KEY_MAX_CHARS,
|
|
11
|
+
PREFERENCE_REGISTRY_TITLE_MAX_CHARS,
|
|
12
|
+
PreferenceRegistryConflictStrategy,
|
|
13
|
+
PreferenceRegistryStableKey,
|
|
14
|
+
} from "./preference-registry";
|
|
15
|
+
import { GovernedLearningActivationDestination } from "./governed-learning-activation";
|
|
16
|
+
import {
|
|
17
|
+
GovernedLearningDecisionOutcome,
|
|
18
|
+
GovernedLearningDecisionReason,
|
|
19
|
+
} from "./governed-learning-evaluator";
|
|
20
|
+
import { WorkspaceInstructionPolicyTarget } from "./workspace-instruction-policies";
|
|
21
|
+
import { WorkspaceLearningPolicyEffectiveMode } from "./workspace-learning-policy";
|
|
22
|
+
|
|
23
|
+
const boundedReason = z.string().trim().min(1).max(4_096);
|
|
24
|
+
const operationId = z.string().uuid();
|
|
25
|
+
const exactEvidence = {
|
|
26
|
+
claimId: z.string().uuid(),
|
|
27
|
+
evidenceId: z.string().uuid(),
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/** Exact accepted-attempt authority. It is validated again inside the write transaction. */
|
|
31
|
+
export const CompanyBrainGovernedWriteAttempt = z
|
|
32
|
+
.object({
|
|
33
|
+
accountId: z.string().uuid(),
|
|
34
|
+
workspaceId: z.string().uuid(),
|
|
35
|
+
sessionId: z.string().uuid(),
|
|
36
|
+
turnId: z.string().uuid(),
|
|
37
|
+
attemptId: z.string().uuid(),
|
|
38
|
+
executionGeneration: z.number().int().positive(),
|
|
39
|
+
})
|
|
40
|
+
.strict();
|
|
41
|
+
export type CompanyBrainGovernedWriteAttempt = z.infer<typeof CompanyBrainGovernedWriteAttempt>;
|
|
42
|
+
|
|
43
|
+
export const ProposeWorkspaceKnowledgeClaimRequest = z
|
|
44
|
+
.object({
|
|
45
|
+
kind: z.literal("propose_knowledge"),
|
|
46
|
+
operationId,
|
|
47
|
+
...exactEvidence,
|
|
48
|
+
reason: boundedReason,
|
|
49
|
+
})
|
|
50
|
+
.strict();
|
|
51
|
+
export type ProposeWorkspaceKnowledgeClaimRequest = z.infer<
|
|
52
|
+
typeof ProposeWorkspaceKnowledgeClaimRequest
|
|
53
|
+
>;
|
|
54
|
+
|
|
55
|
+
export const CorrectWorkspaceKnowledgeClaimRequest = z
|
|
56
|
+
.object({
|
|
57
|
+
kind: z.literal("correct_knowledge"),
|
|
58
|
+
operationId,
|
|
59
|
+
...exactEvidence,
|
|
60
|
+
replacesClaimId: z.string().uuid(),
|
|
61
|
+
reason: boundedReason,
|
|
62
|
+
})
|
|
63
|
+
.strict();
|
|
64
|
+
export type CorrectWorkspaceKnowledgeClaimRequest = z.infer<
|
|
65
|
+
typeof CorrectWorkspaceKnowledgeClaimRequest
|
|
66
|
+
>;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Promote one still-active task-tree note into a normalized, workspace-local
|
|
70
|
+
* Knowledge claim proposal. The note text is the exact fact value and source
|
|
71
|
+
* evidence; callers may describe the subject and predicate but cannot widen
|
|
72
|
+
* authority or supply replacement source bytes.
|
|
73
|
+
*/
|
|
74
|
+
export const PromoteTaskNoteKnowledgeRequest = z
|
|
75
|
+
.object({
|
|
76
|
+
kind: z.literal("promote_task_note_knowledge"),
|
|
77
|
+
operationId,
|
|
78
|
+
noteId: z.string().uuid(),
|
|
79
|
+
expectedNoteVersion: z.literal(1),
|
|
80
|
+
entityType: z
|
|
81
|
+
.string()
|
|
82
|
+
.trim()
|
|
83
|
+
.min(1)
|
|
84
|
+
.max(96)
|
|
85
|
+
.regex(/^[a-z0-9](?:[a-z0-9._-]*[a-z0-9])?$/),
|
|
86
|
+
normalizedKey: z.string().trim().min(1).max(512),
|
|
87
|
+
displayName: z.string().trim().min(1).max(512),
|
|
88
|
+
predicateKey: z
|
|
89
|
+
.string()
|
|
90
|
+
.trim()
|
|
91
|
+
.min(1)
|
|
92
|
+
.max(128)
|
|
93
|
+
.regex(/^[a-z0-9](?:[a-z0-9._-]*[a-z0-9])?$/),
|
|
94
|
+
confidenceBps: z.number().int().min(0).max(10_000),
|
|
95
|
+
reason: boundedReason,
|
|
96
|
+
})
|
|
97
|
+
.strict();
|
|
98
|
+
export type PromoteTaskNoteKnowledgeRequest = z.infer<typeof PromoteTaskNoteKnowledgeRequest>;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Promote the exact immutable Task-note bytes into an inactive mandatory-rule
|
|
102
|
+
* draft. The caller selects only the governed target and active-head baseline;
|
|
103
|
+
* it cannot replace the source content or activate the draft.
|
|
104
|
+
*/
|
|
105
|
+
export const PromoteTaskNoteInstructionPolicyRequest = z
|
|
106
|
+
.strictObject({
|
|
107
|
+
kind: z.literal("promote_task_note_instruction_policy"),
|
|
108
|
+
operationId,
|
|
109
|
+
noteId: z.string().uuid(),
|
|
110
|
+
expectedNoteVersion: z.literal(1),
|
|
111
|
+
entityType: z
|
|
112
|
+
.string()
|
|
113
|
+
.trim()
|
|
114
|
+
.min(1)
|
|
115
|
+
.max(96)
|
|
116
|
+
.regex(/^[a-z0-9](?:[a-z0-9._-]*[a-z0-9])?$/),
|
|
117
|
+
normalizedKey: z.string().trim().min(1).max(512),
|
|
118
|
+
displayName: z.string().trim().min(1).max(512),
|
|
119
|
+
predicateKey: z
|
|
120
|
+
.string()
|
|
121
|
+
.trim()
|
|
122
|
+
.min(1)
|
|
123
|
+
.max(128)
|
|
124
|
+
.regex(/^[a-z0-9](?:[a-z0-9._-]*[a-z0-9])?$/),
|
|
125
|
+
confidenceBps: z.number().int().min(0).max(10_000),
|
|
126
|
+
target: WorkspaceInstructionPolicyTarget,
|
|
127
|
+
expectedCurrentRevisionId: z.string().uuid().nullable(),
|
|
128
|
+
expectedActivationVersion: z.number().int().nonnegative(),
|
|
129
|
+
reason: boundedReason,
|
|
130
|
+
})
|
|
131
|
+
.superRefine((value, context) => {
|
|
132
|
+
const target = WorkspaceInstructionPolicyTarget.safeParse(value.target);
|
|
133
|
+
if (!target.success) {
|
|
134
|
+
for (const issue of target.error.issues) {
|
|
135
|
+
context.addIssue({ ...issue, path: ["target", ...issue.path] });
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
export type PromoteTaskNoteInstructionPolicyRequest = z.infer<
|
|
140
|
+
typeof PromoteTaskNoteInstructionPolicyRequest
|
|
141
|
+
>;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Promote the exact immutable Task-note bytes into an inactive workspace
|
|
145
|
+
* preference proposal. Descriptor metadata is caller-supplied and bounded,
|
|
146
|
+
* while the full proposal content always comes from the admitted note.
|
|
147
|
+
*/
|
|
148
|
+
export const PromoteTaskNotePreferenceRequest = z.strictObject({
|
|
149
|
+
kind: z.literal("promote_task_note_preference"),
|
|
150
|
+
operationId,
|
|
151
|
+
noteId: z.string().uuid(),
|
|
152
|
+
expectedNoteVersion: z.literal(1),
|
|
153
|
+
entityType: z
|
|
154
|
+
.string()
|
|
155
|
+
.trim()
|
|
156
|
+
.min(1)
|
|
157
|
+
.max(96)
|
|
158
|
+
.regex(/^[a-z0-9](?:[a-z0-9._-]*[a-z0-9])?$/),
|
|
159
|
+
normalizedKey: z.string().trim().min(1).max(512),
|
|
160
|
+
displayName: z.string().trim().min(1).max(512),
|
|
161
|
+
predicateKey: z
|
|
162
|
+
.string()
|
|
163
|
+
.trim()
|
|
164
|
+
.min(1)
|
|
165
|
+
.max(128)
|
|
166
|
+
.regex(/^[a-z0-9](?:[a-z0-9._-]*[a-z0-9])?$/),
|
|
167
|
+
confidenceBps: z.number().int().min(0).max(10_000),
|
|
168
|
+
stableKey: PreferenceRegistryStableKey.max(PREFERENCE_REGISTRY_STABLE_KEY_MAX_CHARS),
|
|
169
|
+
title: z.string().trim().min(1).max(PREFERENCE_REGISTRY_TITLE_MAX_CHARS),
|
|
170
|
+
description: z.string().trim().min(1).max(PREFERENCE_REGISTRY_DESCRIPTOR_DESCRIPTION_MAX_CHARS),
|
|
171
|
+
precedenceRank: z.number().int().min(-1_000).max(1_000).default(0),
|
|
172
|
+
conflictStrategy: PreferenceRegistryConflictStrategy.default("override"),
|
|
173
|
+
conflictsWith: z.array(PreferenceRegistryStableKey).max(32).default([]),
|
|
174
|
+
expiresAt: z.string().datetime({ offset: true }).nullable().default(null),
|
|
175
|
+
reason: boundedReason,
|
|
176
|
+
});
|
|
177
|
+
export type PromoteTaskNotePreferenceRequest = z.infer<typeof PromoteTaskNotePreferenceRequest>;
|
|
178
|
+
|
|
179
|
+
export const ProposeWorkspaceInstructionPolicyRequest = z
|
|
180
|
+
.strictObject({
|
|
181
|
+
kind: z.literal("propose_instruction_policy"),
|
|
182
|
+
operationId,
|
|
183
|
+
...exactEvidence,
|
|
184
|
+
target: WorkspaceInstructionPolicyTarget,
|
|
185
|
+
// Instruction drafts use the same storage bound as the human editor.
|
|
186
|
+
// Prompt composition retains its separate byte limit after activation.
|
|
187
|
+
content: z
|
|
188
|
+
.string()
|
|
189
|
+
.min(1)
|
|
190
|
+
.max(
|
|
191
|
+
AGENT_AUTHORED_INSTRUCTION_POLICY_CONTENT_MAX_CHARS,
|
|
192
|
+
AGENT_AUTHORED_INSTRUCTION_POLICY_CONTENT_TOO_LONG_MESSAGE,
|
|
193
|
+
)
|
|
194
|
+
.refine((value) => value.trim().length > 0, "instruction proposal must not be blank"),
|
|
195
|
+
expectedCurrentRevisionId: z.string().uuid().nullable(),
|
|
196
|
+
expectedActivationVersion: z.number().int().nonnegative(),
|
|
197
|
+
reason: boundedReason,
|
|
198
|
+
})
|
|
199
|
+
.superRefine((value, context) => {
|
|
200
|
+
const target = WorkspaceInstructionPolicyTarget.safeParse(value.target);
|
|
201
|
+
if (!target.success) {
|
|
202
|
+
for (const issue of target.error.issues) {
|
|
203
|
+
context.addIssue({ ...issue, path: ["target", ...issue.path] });
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
export type ProposeWorkspaceInstructionPolicyRequest = z.infer<
|
|
208
|
+
typeof ProposeWorkspaceInstructionPolicyRequest
|
|
209
|
+
>;
|
|
210
|
+
|
|
211
|
+
export const ProposeWorkspacePreferenceRequest = z.strictObject({
|
|
212
|
+
kind: z.literal("propose_preference"),
|
|
213
|
+
operationId,
|
|
214
|
+
...exactEvidence,
|
|
215
|
+
stableKey: PreferenceRegistryStableKey.max(PREFERENCE_REGISTRY_STABLE_KEY_MAX_CHARS),
|
|
216
|
+
title: z.string().trim().min(1).max(PREFERENCE_REGISTRY_TITLE_MAX_CHARS),
|
|
217
|
+
description: z.string().trim().min(1).max(PREFERENCE_REGISTRY_DESCRIPTOR_DESCRIPTION_MAX_CHARS),
|
|
218
|
+
// Agent-authored: the descriptor pair is prompt-composed in every session and
|
|
219
|
+
// the content is retrieved on demand, so it stays short.
|
|
220
|
+
content: z
|
|
221
|
+
.string()
|
|
222
|
+
.min(1)
|
|
223
|
+
.max(
|
|
224
|
+
AGENT_AUTHORED_PREFERENCE_CONTENT_MAX_CHARS,
|
|
225
|
+
AGENT_AUTHORED_PREFERENCE_CONTENT_TOO_LONG_MESSAGE,
|
|
226
|
+
)
|
|
227
|
+
.refine((value) => value.trim().length > 0, "preference proposal must not be blank"),
|
|
228
|
+
precedenceRank: z.number().int().min(-1_000).max(1_000).default(0),
|
|
229
|
+
conflictStrategy: PreferenceRegistryConflictStrategy.default("override"),
|
|
230
|
+
conflictsWith: z.array(PreferenceRegistryStableKey).max(32).default([]),
|
|
231
|
+
expiresAt: z.string().datetime({ offset: true }).nullable().default(null),
|
|
232
|
+
reason: boundedReason,
|
|
233
|
+
});
|
|
234
|
+
export type ProposeWorkspacePreferenceRequest = z.infer<typeof ProposeWorkspacePreferenceRequest>;
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Destination selection is explicit and structured. There is deliberately no
|
|
238
|
+
* generic "remember" operation, classifier, personal scope, or active authority.
|
|
239
|
+
*/
|
|
240
|
+
export const CompanyBrainGovernedWriteRequest = z.discriminatedUnion("kind", [
|
|
241
|
+
ProposeWorkspaceKnowledgeClaimRequest,
|
|
242
|
+
CorrectWorkspaceKnowledgeClaimRequest,
|
|
243
|
+
PromoteTaskNoteKnowledgeRequest,
|
|
244
|
+
PromoteTaskNoteInstructionPolicyRequest,
|
|
245
|
+
PromoteTaskNotePreferenceRequest,
|
|
246
|
+
ProposeWorkspaceInstructionPolicyRequest,
|
|
247
|
+
ProposeWorkspacePreferenceRequest,
|
|
248
|
+
]);
|
|
249
|
+
export type CompanyBrainGovernedWriteRequest = z.infer<typeof CompanyBrainGovernedWriteRequest>;
|
|
250
|
+
|
|
251
|
+
export const CompanyBrainGovernedWriteDestination = z.enum([
|
|
252
|
+
"knowledge",
|
|
253
|
+
"instruction_policy",
|
|
254
|
+
"preference",
|
|
255
|
+
]);
|
|
256
|
+
export type CompanyBrainGovernedWriteDestination = z.infer<
|
|
257
|
+
typeof CompanyBrainGovernedWriteDestination
|
|
258
|
+
>;
|
|
259
|
+
|
|
260
|
+
export const CompanyBrainGovernedWriteReceipt = z.object({
|
|
261
|
+
operationId,
|
|
262
|
+
inputHash: z.string().regex(/^[0-9a-f]{64}$/),
|
|
263
|
+
workspaceId: z.string().uuid(),
|
|
264
|
+
destination: CompanyBrainGovernedWriteDestination,
|
|
265
|
+
outcome: z.literal("proposed"),
|
|
266
|
+
claimId: z.string().uuid(),
|
|
267
|
+
evidenceId: z.string().uuid(),
|
|
268
|
+
relationId: z.string().uuid().nullable(),
|
|
269
|
+
reviewId: z.string().uuid().nullable(),
|
|
270
|
+
knowledgeChangeProposalId: z.string().uuid().nullable(),
|
|
271
|
+
destinationProposalId: z.string().uuid().nullable(),
|
|
272
|
+
destinationRevisionId: z.string().uuid().nullable(),
|
|
273
|
+
taskNoteSource: z
|
|
274
|
+
.object({
|
|
275
|
+
noteId: z.string().uuid(),
|
|
276
|
+
rootSessionId: z.string().uuid(),
|
|
277
|
+
noteVersion: z.literal(1),
|
|
278
|
+
textHash: z.string().regex(/^[0-9a-f]{64}$/),
|
|
279
|
+
})
|
|
280
|
+
.nullable()
|
|
281
|
+
.optional(),
|
|
282
|
+
effectiveBoundary: z.literal("human_review_required"),
|
|
283
|
+
rollback: z.object({
|
|
284
|
+
supported: z.literal(false),
|
|
285
|
+
mechanism: z.literal("not_applicable_proposal_only"),
|
|
286
|
+
}),
|
|
287
|
+
});
|
|
288
|
+
export type CompanyBrainGovernedWriteReceipt = z.infer<typeof CompanyBrainGovernedWriteReceipt>;
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Policy routing is deliberately separate from destination admission. The
|
|
292
|
+
* immutable accepted-attempt snapshot decides whether derived evidence may
|
|
293
|
+
* create a proposal; the destination still owns activation and rollback.
|
|
294
|
+
*/
|
|
295
|
+
export const CompanyBrainLearningPolicyDecision = z.enum([
|
|
296
|
+
"blocked",
|
|
297
|
+
"proposal_created",
|
|
298
|
+
"activation_requested",
|
|
299
|
+
"activated",
|
|
300
|
+
]);
|
|
301
|
+
export type CompanyBrainLearningPolicyDecision = z.infer<typeof CompanyBrainLearningPolicyDecision>;
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Content-free summary of the governed-learning decision receipt recorded for
|
|
305
|
+
* a Ways-of-working proposal (instruction policy or preference). Knowledge
|
|
306
|
+
* destinations create no `knowledge_change_proposals` row and are therefore
|
|
307
|
+
* never evaluated; they report `null`.
|
|
308
|
+
*/
|
|
309
|
+
export const CompanyBrainLearningDecisionSummary = z.object({
|
|
310
|
+
receiptId: z.string().uuid(),
|
|
311
|
+
outcome: GovernedLearningDecisionOutcome,
|
|
312
|
+
automaticEligible: z.boolean(),
|
|
313
|
+
reasons: z.array(GovernedLearningDecisionReason).max(16),
|
|
314
|
+
});
|
|
315
|
+
export type CompanyBrainLearningDecisionSummary = z.infer<
|
|
316
|
+
typeof CompanyBrainLearningDecisionSummary
|
|
317
|
+
>;
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Bounded, content-free reason why evaluation or activation did not complete.
|
|
321
|
+
* The proposal write itself remains durable regardless.
|
|
322
|
+
*/
|
|
323
|
+
export const CompanyBrainLearningStepFailure = z.object({
|
|
324
|
+
stage: z.enum(["evaluation", "activation"]),
|
|
325
|
+
code: z.enum(["authority", "conflict", "invalid_operation", "unavailable"]),
|
|
326
|
+
});
|
|
327
|
+
export type CompanyBrainLearningStepFailure = z.infer<typeof CompanyBrainLearningStepFailure>;
|
|
328
|
+
|
|
329
|
+
export const CompanyBrainLearningPolicyRouteReceipt = z.object({
|
|
330
|
+
operationId,
|
|
331
|
+
workspaceId: z.string().uuid(),
|
|
332
|
+
effectivePolicy: WorkspaceLearningPolicyEffectiveMode,
|
|
333
|
+
decision: CompanyBrainLearningPolicyDecision,
|
|
334
|
+
write: CompanyBrainGovernedWriteReceipt.nullable(),
|
|
335
|
+
learning: CompanyBrainLearningDecisionSummary.nullable().default(null),
|
|
336
|
+
learningFailure: CompanyBrainLearningStepFailure.nullable().default(null),
|
|
337
|
+
activation: z.object({
|
|
338
|
+
requested: z.boolean(),
|
|
339
|
+
activated: z.boolean(),
|
|
340
|
+
boundary: z.enum([
|
|
341
|
+
"policy_off",
|
|
342
|
+
"human_review",
|
|
343
|
+
"destination_authority",
|
|
344
|
+
"not_eligible",
|
|
345
|
+
"human_activation_required",
|
|
346
|
+
"activated",
|
|
347
|
+
]),
|
|
348
|
+
receiptId: z.string().uuid().nullable().default(null),
|
|
349
|
+
destination: GovernedLearningActivationDestination.nullable().default(null),
|
|
350
|
+
destinationRevisionId: z.string().uuid().nullable().default(null),
|
|
351
|
+
effectiveAt: z.string().datetime().nullable().default(null),
|
|
352
|
+
}),
|
|
353
|
+
});
|
|
354
|
+
export type CompanyBrainLearningPolicyRouteReceipt = z.infer<
|
|
355
|
+
typeof CompanyBrainLearningPolicyRouteReceipt
|
|
356
|
+
>;
|
|
@@ -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>;
|