@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,375 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { AgentLearningMode } from "./agent-learning";
|
|
3
|
+
|
|
4
|
+
export const KnowledgeEntryKind = z.enum([
|
|
5
|
+
"source",
|
|
6
|
+
"fact",
|
|
7
|
+
"decision",
|
|
8
|
+
"requirement",
|
|
9
|
+
"incident",
|
|
10
|
+
"note",
|
|
11
|
+
"group",
|
|
12
|
+
]);
|
|
13
|
+
export type KnowledgeEntryKind = z.infer<typeof KnowledgeEntryKind>;
|
|
14
|
+
|
|
15
|
+
export const KnowledgeEntryScope = z.enum(["organization", "workspace", "personal"]);
|
|
16
|
+
export type KnowledgeEntryScope = z.infer<typeof KnowledgeEntryScope>;
|
|
17
|
+
|
|
18
|
+
/** Source-shaped location, not a second copy of the source body. */
|
|
19
|
+
export const KnowledgeEvidenceLocation = z
|
|
20
|
+
.object({
|
|
21
|
+
page: z.number().int().positive().optional(),
|
|
22
|
+
passage: z.string().max(2048).optional(),
|
|
23
|
+
messageIds: z.array(z.string().min(1).max(1024)).max(256).optional(),
|
|
24
|
+
path: z.string().min(1).max(4096).optional(),
|
|
25
|
+
commit: z.string().min(1).max(256).optional(),
|
|
26
|
+
lineStart: z.number().int().positive().optional(),
|
|
27
|
+
lineEnd: z.number().int().positive().optional(),
|
|
28
|
+
})
|
|
29
|
+
.strict()
|
|
30
|
+
.refine(
|
|
31
|
+
(value) =>
|
|
32
|
+
value.lineEnd === undefined ||
|
|
33
|
+
(value.lineStart !== undefined && value.lineEnd >= value.lineStart),
|
|
34
|
+
"an ending line requires a starting line and cannot precede it",
|
|
35
|
+
);
|
|
36
|
+
export type KnowledgeEvidenceLocation = z.infer<typeof KnowledgeEvidenceLocation>;
|
|
37
|
+
|
|
38
|
+
export const KnowledgeEntryEvidence = z
|
|
39
|
+
.object({
|
|
40
|
+
entryId: z.uuid(),
|
|
41
|
+
revisionId: z.uuid(),
|
|
42
|
+
location: KnowledgeEvidenceLocation.default({}),
|
|
43
|
+
quote: z.string().optional(),
|
|
44
|
+
})
|
|
45
|
+
.strict();
|
|
46
|
+
export type KnowledgeEntryEvidence = z.infer<typeof KnowledgeEntryEvidence>;
|
|
47
|
+
|
|
48
|
+
export const KnowledgeEntrySource = z
|
|
49
|
+
.object({
|
|
50
|
+
kind: z.enum([
|
|
51
|
+
"file",
|
|
52
|
+
"slack",
|
|
53
|
+
"conversation",
|
|
54
|
+
"repository",
|
|
55
|
+
"web",
|
|
56
|
+
"connector",
|
|
57
|
+
"manual",
|
|
58
|
+
"task_note",
|
|
59
|
+
]),
|
|
60
|
+
noteId: z.uuid().optional(),
|
|
61
|
+
fileId: z.uuid().optional(),
|
|
62
|
+
documentId: z.uuid().optional(),
|
|
63
|
+
sessionId: z.uuid().optional(),
|
|
64
|
+
uri: z.string().min(1).max(8192).optional(),
|
|
65
|
+
externalId: z.string().min(1).max(2048).optional(),
|
|
66
|
+
version: z.string().min(1).max(2048).optional(),
|
|
67
|
+
capturedAt: z.string().datetime({ offset: true }).optional(),
|
|
68
|
+
retention: z.enum(["full_text", "passages", "reference"]).optional(),
|
|
69
|
+
/** Supporting evidence stays retrievable by ID without entering default discovery. */
|
|
70
|
+
purpose: z.enum(["evidence", "reference"]).optional(),
|
|
71
|
+
})
|
|
72
|
+
.strict();
|
|
73
|
+
export type KnowledgeEntrySource = z.infer<typeof KnowledgeEntrySource>;
|
|
74
|
+
|
|
75
|
+
export const KnowledgeEntryRelationship = z
|
|
76
|
+
.object({
|
|
77
|
+
entryId: z.uuid(),
|
|
78
|
+
relation: z.enum(["related_to", "depends_on", "applies_to", "conflicts_with", "supersedes"]),
|
|
79
|
+
})
|
|
80
|
+
.strict();
|
|
81
|
+
export type KnowledgeEntryRelationship = z.infer<typeof KnowledgeEntryRelationship>;
|
|
82
|
+
|
|
83
|
+
export const KnowledgeEntryContent = z
|
|
84
|
+
.object({
|
|
85
|
+
title: z.string().min(1),
|
|
86
|
+
kind: KnowledgeEntryKind,
|
|
87
|
+
// Exact accepted content. Request admission and paginated reads own size;
|
|
88
|
+
// source text is not truncated to the former 4,000-character Memory cap.
|
|
89
|
+
content: z.string(),
|
|
90
|
+
source: KnowledgeEntrySource.optional(),
|
|
91
|
+
evidence: z.array(KnowledgeEntryEvidence).max(256).default([]),
|
|
92
|
+
groupIds: z.array(z.uuid()).max(256).default([]),
|
|
93
|
+
relationships: z.array(KnowledgeEntryRelationship).max(256).default([]),
|
|
94
|
+
})
|
|
95
|
+
.strict()
|
|
96
|
+
.superRefine((value, context) => {
|
|
97
|
+
if (value.kind !== "group" && value.kind !== "source" && !value.content.trim()) {
|
|
98
|
+
context.addIssue({
|
|
99
|
+
code: "custom",
|
|
100
|
+
path: ["content"],
|
|
101
|
+
message: "knowledge content is empty",
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
if (value.kind === "source" && !value.source) {
|
|
105
|
+
context.addIssue({
|
|
106
|
+
code: "custom",
|
|
107
|
+
path: ["source"],
|
|
108
|
+
message: "source entries require source identity",
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
if (new Set(value.groupIds).size !== value.groupIds.length) {
|
|
112
|
+
context.addIssue({
|
|
113
|
+
code: "custom",
|
|
114
|
+
path: ["groupIds"],
|
|
115
|
+
message: "group membership contains duplicate IDs",
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
export type KnowledgeEntryContent = z.infer<typeof KnowledgeEntryContent>;
|
|
120
|
+
/** Historical relationships are lossless. Admission limits apply to new writes. */
|
|
121
|
+
export const StoredKnowledgeEntryContent = KnowledgeEntryContent.safeExtend({
|
|
122
|
+
evidence: z.array(KnowledgeEntryEvidence).default([]),
|
|
123
|
+
groupIds: z.array(z.uuid()).default([]),
|
|
124
|
+
relationships: z.array(KnowledgeEntryRelationship).default([]),
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
const NIL_UUID = "00000000-0000-0000-0000-000000000000";
|
|
128
|
+
/**
|
|
129
|
+
* Omit on create: the host derives the entry id from the operation, so an exact
|
|
130
|
+
* retry replays the same entry. Required to correct an existing entry.
|
|
131
|
+
*/
|
|
132
|
+
const KnowledgeWriteEntryId = z
|
|
133
|
+
.uuid()
|
|
134
|
+
.refine((value) => value !== NIL_UUID, {
|
|
135
|
+
message: "entryId must be a real entry id; omit it to create a new entry",
|
|
136
|
+
})
|
|
137
|
+
.optional();
|
|
138
|
+
|
|
139
|
+
/** Scope identity and agent policy are resolved by the host, never supplied by the model. */
|
|
140
|
+
export const KnowledgeEntrySaveRequest = z
|
|
141
|
+
.object({
|
|
142
|
+
operationId: z.uuid(),
|
|
143
|
+
entryId: KnowledgeWriteEntryId,
|
|
144
|
+
expectedVersion: z.number().int().nonnegative(),
|
|
145
|
+
scope: KnowledgeEntryScope.optional(),
|
|
146
|
+
entry: KnowledgeEntryContent.safeExtend({ title: z.string().min(1).max(1024) }),
|
|
147
|
+
})
|
|
148
|
+
.strict();
|
|
149
|
+
export type KnowledgeEntrySaveRequest = z.input<typeof KnowledgeEntrySaveRequest>;
|
|
150
|
+
|
|
151
|
+
export const KnowledgeTaskNotePromotionRequest = z
|
|
152
|
+
.object({
|
|
153
|
+
operationId: z.uuid(),
|
|
154
|
+
entryId: KnowledgeWriteEntryId,
|
|
155
|
+
expectedVersion: z.literal(0),
|
|
156
|
+
noteId: z.uuid(),
|
|
157
|
+
expectedNoteVersion: z.literal(1),
|
|
158
|
+
title: z.string().min(1).max(1024),
|
|
159
|
+
groupIds: z.array(z.uuid()).max(256).default([]),
|
|
160
|
+
})
|
|
161
|
+
.strict();
|
|
162
|
+
export type KnowledgeTaskNotePromotionRequest = z.input<typeof KnowledgeTaskNotePromotionRequest>;
|
|
163
|
+
|
|
164
|
+
export const KnowledgeEntryReviewRequest = z
|
|
165
|
+
.object({
|
|
166
|
+
operationId: z.uuid(),
|
|
167
|
+
entryId: z.uuid(),
|
|
168
|
+
revisionId: z.uuid(),
|
|
169
|
+
expectedVersion: z.number().int().positive(),
|
|
170
|
+
decision: z.enum(["approve", "reject"]),
|
|
171
|
+
entry: KnowledgeEntryContent.safeExtend({ title: z.string().min(1).max(1024) }).optional(),
|
|
172
|
+
})
|
|
173
|
+
.strict()
|
|
174
|
+
.refine(
|
|
175
|
+
(value) => !value.entry || value.decision === "approve",
|
|
176
|
+
"Only approval can include an edited entry",
|
|
177
|
+
);
|
|
178
|
+
export type KnowledgeEntryReviewRequest = z.input<typeof KnowledgeEntryReviewRequest>;
|
|
179
|
+
|
|
180
|
+
export const KnowledgeEntryBatchReviewRequest = z
|
|
181
|
+
.object({
|
|
182
|
+
entries: z.array(KnowledgeEntryReviewRequest).min(1).max(100),
|
|
183
|
+
})
|
|
184
|
+
.strict()
|
|
185
|
+
.refine(
|
|
186
|
+
(value) => new Set(value.entries.map((entry) => entry.entryId)).size === value.entries.length,
|
|
187
|
+
"A review batch cannot repeat an entry",
|
|
188
|
+
);
|
|
189
|
+
export type KnowledgeEntryBatchReviewRequest = z.input<typeof KnowledgeEntryBatchReviewRequest>;
|
|
190
|
+
|
|
191
|
+
export const KnowledgeEntryRestoreRequest = z
|
|
192
|
+
.object({
|
|
193
|
+
operationId: z.uuid(),
|
|
194
|
+
entryId: z.uuid(),
|
|
195
|
+
revisionId: z.uuid(),
|
|
196
|
+
expectedVersion: z.number().int().positive(),
|
|
197
|
+
})
|
|
198
|
+
.strict();
|
|
199
|
+
export type KnowledgeEntryRestoreRequest = z.infer<typeof KnowledgeEntryRestoreRequest>;
|
|
200
|
+
|
|
201
|
+
export const KnowledgeEntryWriteReceipt = z
|
|
202
|
+
.object({
|
|
203
|
+
operationId: z.uuid(),
|
|
204
|
+
entryId: z.uuid(),
|
|
205
|
+
revisionId: z.uuid(),
|
|
206
|
+
version: z.number().int().positive(),
|
|
207
|
+
outcome: z.enum(["published", "pending", "rejected", "archived"]),
|
|
208
|
+
reviewBatchId: z.uuid().nullable(),
|
|
209
|
+
replayed: z.boolean(),
|
|
210
|
+
})
|
|
211
|
+
.strict();
|
|
212
|
+
export type KnowledgeEntryWriteReceipt = z.infer<typeof KnowledgeEntryWriteReceipt>;
|
|
213
|
+
|
|
214
|
+
export const KnowledgeFilePreparationResult = z.discriminatedUnion("status", [
|
|
215
|
+
z
|
|
216
|
+
.object({
|
|
217
|
+
status: z.literal("retained"),
|
|
218
|
+
fileId: z.uuid(),
|
|
219
|
+
filename: z.string(),
|
|
220
|
+
receipt: KnowledgeEntryWriteReceipt,
|
|
221
|
+
})
|
|
222
|
+
.strict(),
|
|
223
|
+
z.object({ status: z.literal("disabled"), fileId: z.uuid() }).strict(),
|
|
224
|
+
]);
|
|
225
|
+
export type KnowledgeFilePreparationResult = z.infer<typeof KnowledgeFilePreparationResult>;
|
|
226
|
+
|
|
227
|
+
export const KnowledgeEntryRevision = z
|
|
228
|
+
.object({
|
|
229
|
+
id: z.uuid(),
|
|
230
|
+
entryId: z.uuid(),
|
|
231
|
+
number: z.number().int().positive(),
|
|
232
|
+
change: z.enum(["upsert", "archive"]),
|
|
233
|
+
entry: StoredKnowledgeEntryContent,
|
|
234
|
+
previousRevisionId: z.uuid().nullable(),
|
|
235
|
+
restoredFromRevisionId: z.uuid().nullable(),
|
|
236
|
+
createdAt: z.string().datetime({ offset: true }),
|
|
237
|
+
createdBySessionId: z.uuid().nullable(),
|
|
238
|
+
reviewBatchId: z.uuid().nullable(),
|
|
239
|
+
outcome: z.enum(["published", "pending", "rejected", "superseded"]),
|
|
240
|
+
})
|
|
241
|
+
.strict();
|
|
242
|
+
export type KnowledgeEntryRevision = z.infer<typeof KnowledgeEntryRevision>;
|
|
243
|
+
|
|
244
|
+
/** Search/index progress is independent of saved source and keyword access. */
|
|
245
|
+
export const KnowledgeIndexStatus = z.enum([
|
|
246
|
+
"saved",
|
|
247
|
+
"queued",
|
|
248
|
+
"indexing",
|
|
249
|
+
"awaiting_funding",
|
|
250
|
+
"indexed",
|
|
251
|
+
"source_unavailable",
|
|
252
|
+
"provider_failed",
|
|
253
|
+
]);
|
|
254
|
+
export type KnowledgeIndexStatus = z.infer<typeof KnowledgeIndexStatus>;
|
|
255
|
+
|
|
256
|
+
/** Private owner IDs are not part of a content-discovery projection. */
|
|
257
|
+
export const KnowledgeEntryRecord = z
|
|
258
|
+
.object({
|
|
259
|
+
id: z.uuid(),
|
|
260
|
+
scope: KnowledgeEntryScope,
|
|
261
|
+
version: z.number().int().positive(),
|
|
262
|
+
publishedRevisionId: z.uuid().nullable(),
|
|
263
|
+
latestRevisionId: z.uuid(),
|
|
264
|
+
revision: KnowledgeEntryRevision,
|
|
265
|
+
archived: z.boolean(),
|
|
266
|
+
createdAt: z.string().datetime({ offset: true }),
|
|
267
|
+
updatedAt: z.string().datetime({ offset: true }),
|
|
268
|
+
indexStatus: KnowledgeIndexStatus.optional(),
|
|
269
|
+
})
|
|
270
|
+
.strict();
|
|
271
|
+
export type KnowledgeEntryRecord = z.infer<typeof KnowledgeEntryRecord>;
|
|
272
|
+
|
|
273
|
+
export const KnowledgeEntryListRequest = z
|
|
274
|
+
.object({
|
|
275
|
+
query: z.string().max(4096).optional(),
|
|
276
|
+
mode: z.enum(["hybrid", "keyword", "vector"]).default("hybrid"),
|
|
277
|
+
scope: KnowledgeEntryScope.optional(),
|
|
278
|
+
groupId: z.uuid().optional(),
|
|
279
|
+
/** Top-level entries with no visible collection in the selected scope. */
|
|
280
|
+
rootOnly: z.boolean().optional(),
|
|
281
|
+
fileId: z.uuid().optional(),
|
|
282
|
+
/** Include supporting sources in published discovery; never changes access. */
|
|
283
|
+
includeEvidence: z.boolean().optional(),
|
|
284
|
+
kind: KnowledgeEntryKind.optional(),
|
|
285
|
+
view: z.enum(["published", "needs_review", "archived", "rejected"]).default("published"),
|
|
286
|
+
sessionId: z.uuid().optional(),
|
|
287
|
+
reviewBatchId: z.uuid().optional(),
|
|
288
|
+
cursor: z.string().min(1).max(2048).optional(),
|
|
289
|
+
limit: z.number().int().positive().max(50).default(20),
|
|
290
|
+
})
|
|
291
|
+
.strict();
|
|
292
|
+
export type KnowledgeEntryListRequest = z.input<typeof KnowledgeEntryListRequest>;
|
|
293
|
+
|
|
294
|
+
/** Lists never transfer whole source texts or evidence quotations. */
|
|
295
|
+
export const KnowledgeEntrySummary = KnowledgeEntryRecord.omit({ revision: true }).extend({
|
|
296
|
+
score: z.number().finite().optional(),
|
|
297
|
+
excerpts: z
|
|
298
|
+
.array(
|
|
299
|
+
z.object({
|
|
300
|
+
field: z.enum(["title", "content"]),
|
|
301
|
+
start: z.number().int().nonnegative(),
|
|
302
|
+
end: z.number().int().nonnegative(),
|
|
303
|
+
text: z.string(),
|
|
304
|
+
}),
|
|
305
|
+
)
|
|
306
|
+
.default([]),
|
|
307
|
+
revision: KnowledgeEntryRevision.omit({ entry: true }).extend({
|
|
308
|
+
title: z.string(),
|
|
309
|
+
kind: KnowledgeEntryKind,
|
|
310
|
+
preview: z.string(),
|
|
311
|
+
groupIds: z.array(z.uuid()),
|
|
312
|
+
sourceKind: KnowledgeEntrySource.shape.kind.nullable(),
|
|
313
|
+
}),
|
|
314
|
+
});
|
|
315
|
+
export type KnowledgeEntrySummary = z.infer<typeof KnowledgeEntrySummary>;
|
|
316
|
+
|
|
317
|
+
export const KnowledgeEntryListResponse = z.object({
|
|
318
|
+
entries: z.array(KnowledgeEntrySummary),
|
|
319
|
+
nextCursor: z.string().nullable(),
|
|
320
|
+
searchMode: z.enum(["keyword", "hybrid", "vector"]).optional(),
|
|
321
|
+
fallbackReason: z
|
|
322
|
+
.enum(["awaiting_funding", "quota", "provider_unavailable", "query_limit"])
|
|
323
|
+
.optional(),
|
|
324
|
+
});
|
|
325
|
+
export type KnowledgeEntryListResponse = z.infer<typeof KnowledgeEntryListResponse>;
|
|
326
|
+
|
|
327
|
+
export const KnowledgeReviewBatch = z.object({
|
|
328
|
+
id: z.uuid(),
|
|
329
|
+
sessionId: z.uuid().nullable(),
|
|
330
|
+
scheduledTaskId: z.uuid().nullable(),
|
|
331
|
+
scheduledTaskRunId: z.uuid().nullable(),
|
|
332
|
+
title: z.string().nullable(),
|
|
333
|
+
scope: KnowledgeEntryScope,
|
|
334
|
+
pendingCount: z.number().int().nonnegative(),
|
|
335
|
+
createdAt: z.string().datetime({ offset: true }),
|
|
336
|
+
});
|
|
337
|
+
export type KnowledgeReviewBatch = z.infer<typeof KnowledgeReviewBatch>;
|
|
338
|
+
|
|
339
|
+
export const KnowledgeReviewBatchListRequest = z
|
|
340
|
+
.object({
|
|
341
|
+
scope: KnowledgeEntryScope.optional(),
|
|
342
|
+
cursor: z.string().min(1).max(2048).optional(),
|
|
343
|
+
limit: z.number().int().positive().max(50).default(20),
|
|
344
|
+
})
|
|
345
|
+
.strict();
|
|
346
|
+
export type KnowledgeReviewBatchListRequest = z.input<typeof KnowledgeReviewBatchListRequest>;
|
|
347
|
+
export const KnowledgeReviewBatchListResponse = z.object({
|
|
348
|
+
batches: z.array(KnowledgeReviewBatch),
|
|
349
|
+
nextCursor: z.string().nullable(),
|
|
350
|
+
});
|
|
351
|
+
export type KnowledgeReviewBatchListResponse = z.infer<typeof KnowledgeReviewBatchListResponse>;
|
|
352
|
+
|
|
353
|
+
/** All policy outcomes are nonblocking; Off refuses authoring, not task execution. */
|
|
354
|
+
export function knowledgeWriteDisposition(mode: z.infer<typeof AgentLearningMode>) {
|
|
355
|
+
switch (AgentLearningMode.parse(mode)) {
|
|
356
|
+
case "automatic":
|
|
357
|
+
return "published" as const;
|
|
358
|
+
case "review_first":
|
|
359
|
+
return "pending" as const;
|
|
360
|
+
case "off":
|
|
361
|
+
return "disabled" as const;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
export const KnowledgeOriginalFileDownload = z
|
|
366
|
+
.object({
|
|
367
|
+
url: z.string().url(),
|
|
368
|
+
expiresAt: z.string(),
|
|
369
|
+
fileId: z.uuid(),
|
|
370
|
+
filename: z.string(),
|
|
371
|
+
contentType: z.string(),
|
|
372
|
+
sizeBytes: z.number().int().nonnegative(),
|
|
373
|
+
})
|
|
374
|
+
.strict();
|
|
375
|
+
export type KnowledgeOriginalFileDownload = z.infer<typeof KnowledgeOriginalFileDownload>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { KnowledgeEntryListResponse, KnowledgeEntryScope } from "./knowledge-entries";
|
|
3
|
+
|
|
4
|
+
/** Read-only discovery before a model decides whether and where to save. */
|
|
5
|
+
export const KnowledgeSavePreparationRequest = z
|
|
6
|
+
.object({
|
|
7
|
+
query: z.string().trim().min(1).max(4096),
|
|
8
|
+
limit: z.number().int().positive().max(20).default(8),
|
|
9
|
+
collectionCursors: z
|
|
10
|
+
.object({
|
|
11
|
+
published: z.string().min(1).max(2048).nullable(),
|
|
12
|
+
needs_review: z.string().min(1).max(2048).nullable(),
|
|
13
|
+
})
|
|
14
|
+
.strict()
|
|
15
|
+
.optional(),
|
|
16
|
+
})
|
|
17
|
+
.strict();
|
|
18
|
+
export type KnowledgeSavePreparationRequest = z.input<typeof KnowledgeSavePreparationRequest>;
|
|
19
|
+
|
|
20
|
+
export const KnowledgeCollectionDescriptor = z
|
|
21
|
+
.object({
|
|
22
|
+
id: z.uuid(),
|
|
23
|
+
revisionId: z.uuid(),
|
|
24
|
+
version: z.number().int().positive(),
|
|
25
|
+
scope: KnowledgeEntryScope,
|
|
26
|
+
view: z.enum(["published", "needs_review"]),
|
|
27
|
+
title: z.string(),
|
|
28
|
+
description: z.string(),
|
|
29
|
+
descriptionTruncated: z.boolean(),
|
|
30
|
+
parentIds: z.array(z.uuid()),
|
|
31
|
+
})
|
|
32
|
+
.strict();
|
|
33
|
+
|
|
34
|
+
export const KnowledgeSavePreparationResponse = z
|
|
35
|
+
.object({
|
|
36
|
+
collections: z.object({
|
|
37
|
+
entries: z.array(KnowledgeCollectionDescriptor),
|
|
38
|
+
complete: z.boolean(),
|
|
39
|
+
nextCursors: z.object({
|
|
40
|
+
published: z.string().nullable(),
|
|
41
|
+
needs_review: z.string().nullable(),
|
|
42
|
+
}),
|
|
43
|
+
}),
|
|
44
|
+
matches: z.object({
|
|
45
|
+
published: KnowledgeEntryListResponse,
|
|
46
|
+
needs_review: KnowledgeEntryListResponse,
|
|
47
|
+
}),
|
|
48
|
+
})
|
|
49
|
+
.strict();
|
|
50
|
+
export type KnowledgeSavePreparationResponse = z.infer<typeof KnowledgeSavePreparationResponse>;
|
package/src/knowledge.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { z } from "zod";
|
|
|
3
3
|
export const KNOWLEDGE_BROWSE_CURSOR_MAX_CHARS = 1_024;
|
|
4
4
|
export const KNOWLEDGE_BROWSE_DEFAULT_LIMIT = 20;
|
|
5
5
|
export const KNOWLEDGE_BROWSE_MAX_LIMIT = 50;
|
|
6
|
+
export const KNOWLEDGE_BROWSE_MAX_RESPONSE_BYTES = 64 * 1_024;
|
|
6
7
|
export const KNOWLEDGE_TITLE_MAX_BYTES = 1_024;
|
|
7
8
|
export const KNOWLEDGE_BODY_MAX_BYTES = 16 * 1_024;
|
|
8
9
|
export const KNOWLEDGE_SUMMARY_MAX_BYTES = 4 * 1_024;
|
|
@@ -13,6 +14,16 @@ export const KNOWLEDGE_METADATA_MAX_ITEMS = 64;
|
|
|
13
14
|
export const KNOWLEDGE_METADATA_MAX_DEPTH = 4;
|
|
14
15
|
export const KNOWLEDGE_SOURCE_STRING_MAX_BYTES = 2_048;
|
|
15
16
|
export const KNOWLEDGE_SOURCE_URI_MAX_BYTES = 8_192;
|
|
17
|
+
export const KNOWLEDGE_SEARCH_MAX_RESULTS = 50;
|
|
18
|
+
export const KNOWLEDGE_SEARCH_MAX_RESPONSE_BYTES = 64 * 1_024;
|
|
19
|
+
export const KNOWLEDGE_SEARCH_TOKEN_ESTIMATE_BYTES_PER_TOKEN = 4;
|
|
20
|
+
export const KNOWLEDGE_SEARCH_MAX_FLOOR_OMISSIONS = 200;
|
|
21
|
+
// Cosine similarity for unrelated embeddings clusters around 0.5 after the
|
|
22
|
+
// distance conversion used by Documents. Keyword search already excludes
|
|
23
|
+
// non-matches in SQL, but a small normalized floor removes incidental hits.
|
|
24
|
+
export const KNOWLEDGE_SEARCH_MIN_VECTOR_SCORE = 0.52;
|
|
25
|
+
export const KNOWLEDGE_SEARCH_MIN_KEYWORD_SCORE = 0.01;
|
|
26
|
+
export const KNOWLEDGE_QUERY_MAX_BYTES = 4 * 1_024;
|
|
16
27
|
|
|
17
28
|
const utf8Bytes = (value: string): number => new TextEncoder().encode(value).byteLength;
|
|
18
29
|
const boundedUtf8 = (maxBytes: number) =>
|
|
@@ -102,6 +113,60 @@ export const KnowledgeSource = z.object({
|
|
|
102
113
|
});
|
|
103
114
|
export type KnowledgeSource = z.infer<typeof KnowledgeSource>;
|
|
104
115
|
|
|
116
|
+
export const KnowledgeSearchRequest = z
|
|
117
|
+
.object({
|
|
118
|
+
query: boundedUtf8(KNOWLEDGE_QUERY_MAX_BYTES).pipe(z.string().min(1)),
|
|
119
|
+
baseIds: z.array(z.string().uuid()).max(50).optional(),
|
|
120
|
+
mode: z.enum(["hybrid", "vector", "keyword"]).optional(),
|
|
121
|
+
sourceKinds: z.array(KnowledgeSource.shape.kind).max(8).optional(),
|
|
122
|
+
authorityKinds: z.array(KnowledgeAuthority.shape.kind).max(3).optional(),
|
|
123
|
+
aclTags: z
|
|
124
|
+
.array(boundedUtf8(KNOWLEDGE_TOPIC_MAX_BYTES).pipe(z.string().min(1)))
|
|
125
|
+
.max(64)
|
|
126
|
+
.optional(),
|
|
127
|
+
limit: z.number().int().positive().max(KNOWLEDGE_SEARCH_MAX_RESULTS).default(5),
|
|
128
|
+
})
|
|
129
|
+
.strict();
|
|
130
|
+
export type KnowledgeSearchRequest = z.input<typeof KnowledgeSearchRequest>;
|
|
131
|
+
|
|
132
|
+
export const KnowledgeBrowseRequest = z
|
|
133
|
+
.object({
|
|
134
|
+
parentId: KnowledgeRecordId.optional(),
|
|
135
|
+
topic: boundedUtf8(KNOWLEDGE_TOPIC_MAX_BYTES).pipe(z.string().min(1)).optional(),
|
|
136
|
+
sourceKinds: z.array(KnowledgeSource.shape.kind).max(8).optional(),
|
|
137
|
+
cursor: z.string().min(1).max(KNOWLEDGE_BROWSE_CURSOR_MAX_CHARS).optional(),
|
|
138
|
+
limit: z
|
|
139
|
+
.number()
|
|
140
|
+
.int()
|
|
141
|
+
.positive()
|
|
142
|
+
.max(KNOWLEDGE_BROWSE_MAX_LIMIT)
|
|
143
|
+
.default(KNOWLEDGE_BROWSE_DEFAULT_LIMIT),
|
|
144
|
+
})
|
|
145
|
+
.strict()
|
|
146
|
+
.superRefine((value, context) => {
|
|
147
|
+
if (value.parentId && (value.topic || (value.sourceKinds?.length ?? 0) > 0)) {
|
|
148
|
+
context.addIssue({
|
|
149
|
+
code: z.ZodIssueCode.custom,
|
|
150
|
+
message: "document contents do not accept topic or source filters",
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
export type KnowledgeBrowseRequest = z.input<typeof KnowledgeBrowseRequest>;
|
|
155
|
+
|
|
156
|
+
export const KnowledgeProviderCitation = z.object({
|
|
157
|
+
provider: z.literal("google_drive"),
|
|
158
|
+
externalObjectId: boundedUtf8(KNOWLEDGE_SOURCE_STRING_MAX_BYTES),
|
|
159
|
+
providerRevision: boundedUtf8(KNOWLEDGE_SOURCE_STRING_MAX_BYTES).nullable(),
|
|
160
|
+
sourceVersion: boundedUtf8(KNOWLEDGE_SOURCE_STRING_MAX_BYTES),
|
|
161
|
+
driveId: boundedUtf8(KNOWLEDGE_SOURCE_STRING_MAX_BYTES).nullable(),
|
|
162
|
+
deepLink: boundedUtf8(KNOWLEDGE_SOURCE_URI_MAX_BYTES).pipe(z.string().min(1)).nullable(),
|
|
163
|
+
aclRevision: z.string().regex(/^[0-9a-f]{64}$/u),
|
|
164
|
+
authorizationObservedAt: z.string().datetime({ offset: true }),
|
|
165
|
+
authorizationExpiresAt: z.string().datetime({ offset: true }),
|
|
166
|
+
reauthorizedAt: z.string().datetime({ offset: true }),
|
|
167
|
+
});
|
|
168
|
+
export type KnowledgeProviderCitation = z.infer<typeof KnowledgeProviderCitation>;
|
|
169
|
+
|
|
105
170
|
export const KnowledgeLinkTarget = z.discriminatedUnion("kind", [
|
|
106
171
|
z.object({
|
|
107
172
|
kind: z.literal("knowledge"),
|
|
@@ -144,6 +209,7 @@ export const KnowledgeRecord = z.object({
|
|
|
144
209
|
provenance: z.object({
|
|
145
210
|
source: KnowledgeSource,
|
|
146
211
|
indexedAt: z.string(),
|
|
212
|
+
citation: KnowledgeProviderCitation.nullable().optional(),
|
|
147
213
|
}),
|
|
148
214
|
lifecycle: z.object({
|
|
149
215
|
state: z.literal("active"),
|
|
@@ -171,9 +237,10 @@ export const KnowledgeRecord = z.object({
|
|
|
171
237
|
"provenance.source.title",
|
|
172
238
|
"provenance.source.author",
|
|
173
239
|
"provenance.source.version",
|
|
240
|
+
"provenance.citation",
|
|
174
241
|
]),
|
|
175
242
|
)
|
|
176
|
-
.max(
|
|
243
|
+
.max(11),
|
|
177
244
|
}),
|
|
178
245
|
});
|
|
179
246
|
export type KnowledgeRecord = z.infer<typeof KnowledgeRecord>;
|
|
@@ -181,16 +248,59 @@ export type KnowledgeRecord = z.infer<typeof KnowledgeRecord>;
|
|
|
181
248
|
export const KnowledgeSearchResult = z.object({
|
|
182
249
|
record: KnowledgeRecord,
|
|
183
250
|
retrieval: z.object({
|
|
184
|
-
score
|
|
251
|
+
/** Final bounded ordering score after the documented quality adjustment. */
|
|
252
|
+
score: z.number().min(0).max(1),
|
|
253
|
+
/** Semantic score before the quality adjustment. */
|
|
254
|
+
semanticScore: z.number().min(0).max(1),
|
|
185
255
|
matchType: z.enum(["hybrid", "vector", "keyword"]),
|
|
186
|
-
vectorScore: z.number().nullable(),
|
|
187
|
-
keywordScore: z.number().nullable(),
|
|
256
|
+
vectorScore: z.number().min(0).max(1).nullable(),
|
|
257
|
+
keywordScore: z.number().min(0).max(1).nullable(),
|
|
258
|
+
relevanceSignals: z
|
|
259
|
+
.array(z.enum(["vector", "keyword"]))
|
|
260
|
+
.min(1)
|
|
261
|
+
.max(2),
|
|
262
|
+
freshness: z.enum(["current", "aging", "stale"]),
|
|
263
|
+
qualityAdjustment: z.number().min(0).max(1),
|
|
264
|
+
duplicateCount: z.number().int().nonnegative(),
|
|
188
265
|
}),
|
|
189
266
|
});
|
|
190
267
|
export type KnowledgeSearchResult = z.infer<typeof KnowledgeSearchResult>;
|
|
191
268
|
|
|
192
269
|
export const KnowledgeSearchResponse = z.object({
|
|
193
|
-
results: z.array(KnowledgeSearchResult),
|
|
270
|
+
results: z.array(KnowledgeSearchResult).max(KNOWLEDGE_SEARCH_MAX_RESULTS),
|
|
271
|
+
selection: z.object({
|
|
272
|
+
relevanceFloor: z.object({
|
|
273
|
+
policy: z.literal("any_signal"),
|
|
274
|
+
vectorScore: z.literal(KNOWLEDGE_SEARCH_MIN_VECTOR_SCORE),
|
|
275
|
+
keywordScore: z.literal(KNOWLEDGE_SEARCH_MIN_KEYWORD_SCORE),
|
|
276
|
+
}),
|
|
277
|
+
dedupe: z.object({
|
|
278
|
+
policy: z.literal("exact_textual_content"),
|
|
279
|
+
}),
|
|
280
|
+
candidates: z.object({
|
|
281
|
+
ranked: z.number().int().nonnegative().max(KNOWLEDGE_SEARCH_MAX_RESULTS),
|
|
282
|
+
rechecked: z.number().int().nonnegative().max(KNOWLEDGE_SEARCH_MAX_RESULTS),
|
|
283
|
+
omittedOnRecheck: z.number().int().nonnegative().max(KNOWLEDGE_SEARCH_MAX_RESULTS),
|
|
284
|
+
}),
|
|
285
|
+
omitted: z.object({
|
|
286
|
+
belowRelevanceFloor: z.number().int().nonnegative().max(KNOWLEDGE_SEARCH_MAX_FLOOR_OMISSIONS),
|
|
287
|
+
asDuplicate: z.number().int().nonnegative().max(KNOWLEDGE_SEARCH_MAX_RESULTS),
|
|
288
|
+
forLimit: z.number().int().nonnegative().max(KNOWLEDGE_SEARCH_MAX_RESULTS),
|
|
289
|
+
forResponseBudget: z.number().int().nonnegative().max(KNOWLEDGE_SEARCH_MAX_RESULTS),
|
|
290
|
+
}),
|
|
291
|
+
budget: z.object({
|
|
292
|
+
maxResults: z.literal(KNOWLEDGE_SEARCH_MAX_RESULTS),
|
|
293
|
+
maxResponseBytes: z.literal(KNOWLEDGE_SEARCH_MAX_RESPONSE_BYTES),
|
|
294
|
+
responseBytes: z.number().int().nonnegative().max(KNOWLEDGE_SEARCH_MAX_RESPONSE_BYTES),
|
|
295
|
+
tokenEstimateBytesPerToken: z.literal(KNOWLEDGE_SEARCH_TOKEN_ESTIMATE_BYTES_PER_TOKEN),
|
|
296
|
+
estimatedTokens: z.number().int().nonnegative(),
|
|
297
|
+
maxEstimatedTokens: z.literal(
|
|
298
|
+
Math.ceil(
|
|
299
|
+
KNOWLEDGE_SEARCH_MAX_RESPONSE_BYTES / KNOWLEDGE_SEARCH_TOKEN_ESTIMATE_BYTES_PER_TOKEN,
|
|
300
|
+
),
|
|
301
|
+
),
|
|
302
|
+
}),
|
|
303
|
+
}),
|
|
194
304
|
});
|
|
195
305
|
export type KnowledgeSearchResponse = z.infer<typeof KnowledgeSearchResponse>;
|
|
196
306
|
|
|
@@ -200,8 +310,26 @@ export const KnowledgeGetResponse = z.object({
|
|
|
200
310
|
export type KnowledgeGetResponse = z.infer<typeof KnowledgeGetResponse>;
|
|
201
311
|
|
|
202
312
|
export const KnowledgeBrowseResponse = z.object({
|
|
203
|
-
records: z.array(KnowledgeRecord),
|
|
313
|
+
records: z.array(KnowledgeRecord).max(KNOWLEDGE_BROWSE_MAX_LIMIT),
|
|
204
314
|
nextCursor: z.string().min(1).max(KNOWLEDGE_BROWSE_CURSOR_MAX_CHARS).nullable(),
|
|
205
315
|
hasMore: z.boolean(),
|
|
316
|
+
selection: z.object({
|
|
317
|
+
omitted: z.object({
|
|
318
|
+
forResponseBudget: z.number().int().nonnegative().max(KNOWLEDGE_BROWSE_MAX_LIMIT),
|
|
319
|
+
}),
|
|
320
|
+
compactedRecordCount: z.number().int().nonnegative().max(1),
|
|
321
|
+
budget: z.object({
|
|
322
|
+
maxResults: z.literal(KNOWLEDGE_BROWSE_MAX_LIMIT),
|
|
323
|
+
maxResponseBytes: z.literal(KNOWLEDGE_BROWSE_MAX_RESPONSE_BYTES),
|
|
324
|
+
responseBytes: z.number().int().nonnegative().max(KNOWLEDGE_BROWSE_MAX_RESPONSE_BYTES),
|
|
325
|
+
tokenEstimateBytesPerToken: z.literal(KNOWLEDGE_SEARCH_TOKEN_ESTIMATE_BYTES_PER_TOKEN),
|
|
326
|
+
estimatedTokens: z.number().int().nonnegative(),
|
|
327
|
+
maxEstimatedTokens: z.literal(
|
|
328
|
+
Math.ceil(
|
|
329
|
+
KNOWLEDGE_BROWSE_MAX_RESPONSE_BYTES / KNOWLEDGE_SEARCH_TOKEN_ESTIMATE_BYTES_PER_TOKEN,
|
|
330
|
+
),
|
|
331
|
+
),
|
|
332
|
+
}),
|
|
333
|
+
}),
|
|
206
334
|
});
|
|
207
335
|
export type KnowledgeBrowseResponse = z.infer<typeof KnowledgeBrowseResponse>;
|