@treeseed/sdk 0.13.0-rc.121 → 0.13.0-rc.123

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.
Files changed (157) hide show
  1. package/dist/agent-capacity/contracts/capacity/assignments/agent-execution.d.ts +2365 -1275
  2. package/dist/agent-capacity/contracts/capacity/assignments/agent-execution.js +94 -28
  3. package/dist/agent-capacity/contracts/capacity/assignments/assignment-context-pack.d.ts +38 -38
  4. package/dist/agent-capacity/contracts/capacity/assignments/assignment-path.d.ts +2 -0
  5. package/dist/agent-capacity/contracts/capacity/assignments/assignment-path.js +13 -0
  6. package/dist/agent-capacity/contracts/capacity/assignments/assignment-records.d.ts +2 -59
  7. package/dist/agent-capacity/contracts/capacity/providers/supply-policy.d.ts +126 -1
  8. package/dist/agent-capacity/contracts/capacity/providers/supply-policy.js +35 -1
  9. package/dist/agent-capacity/contracts/capacity/workdays/assignment-allocation.d.ts +2 -4
  10. package/dist/agent-capacity/contracts/capacity/workdays/assignment-allocation.js +22 -16
  11. package/dist/agent-capacity/contracts/capacity/workdays/capability-accounting.d.ts +3 -42
  12. package/dist/agent-capacity/contracts/capacity/workdays/capability-accounting.js +8 -8
  13. package/dist/agent-capacity/contracts/capacity/workdays/workday-allocation.d.ts +244 -85
  14. package/dist/agent-capacity/contracts/capacity/workdays/workday-allocation.js +54 -19
  15. package/dist/agent-capacity/contracts/capacity/workdays/workday-records.d.ts +216 -70
  16. package/dist/agent-capacity/contracts/capacity/workdays/workday-records.js +19 -0
  17. package/dist/agent-capacity/contracts/configuration/configuration.d.ts +1 -1
  18. package/dist/agent-capacity/contracts/configuration/configuration.js +0 -2
  19. package/dist/agent-capacity/contracts/operations/agent-team-clone.d.ts +55 -55
  20. package/dist/agent-capacity/contracts/projects/agents/project-agent-class.d.ts +119 -23
  21. package/dist/agent-capacity/contracts/projects/agents/project-agent-class.js +16 -0
  22. package/dist/agent-capacity/contracts/runtime/runtime-observability.d.ts +2 -154
  23. package/dist/agent-capacity/contracts/support/agent-atlas.d.ts +0 -13
  24. package/dist/agent-capacity/contracts/support/execution-graph.d.ts +496 -292
  25. package/dist/agent-capacity/contracts/support/execution-graph.js +21 -19
  26. package/dist/agent-capacity/contracts/support/financial-records.d.ts +3 -6
  27. package/dist/agent-capacity/contracts/support/planning-records.d.ts +1 -87
  28. package/dist/agent-capacity/grant.d.ts +34 -0
  29. package/dist/agent-capacity/grant.js +4 -0
  30. package/dist/agent-capacity/validation/agent-definition-schema.d.ts +1178 -1152
  31. package/dist/agent-capacity/validation/agent-definition-schema.js +21 -28
  32. package/dist/agent-capacity/validation/agent-lab-forensics-schema.d.ts +10 -10
  33. package/dist/agent-capacity/validation/agent-lab-forensics-schema.js +0 -1
  34. package/dist/agent-capacity/validation/assignment-records.d.ts +1 -6
  35. package/dist/agent-capacity/validation/assignment-records.js +49 -35
  36. package/dist/agent-capacity/validation/configuration.d.ts +1 -1
  37. package/dist/agent-capacity/validation/configuration.js +2 -6
  38. package/dist/agent-capacity/validation/grant.d.ts +11 -0
  39. package/dist/agent-capacity/validation/grant.js +31 -0
  40. package/dist/capacity/agents/agent-capacity.d.ts +3 -4
  41. package/dist/capacity/agents/agent-capacity.js +2 -3
  42. package/dist/capacity-provider/capability-ontology.d.ts +150 -150
  43. package/dist/capacity-provider/client.d.ts +15 -9
  44. package/dist/capacity-provider/client.js +1 -10
  45. package/dist/capacity-provider/contracts/capacity-facts.d.ts +0 -1
  46. package/dist/capacity-provider/contracts/environment-profiles.d.ts +44 -44
  47. package/dist/capacity-provider/contracts/governance.d.ts +2 -17
  48. package/dist/capacity-provider/contracts/index.d.ts +2 -0
  49. package/dist/capacity-provider/contracts/index.js +2 -0
  50. package/dist/capacity-provider/core-capability-catalog.d.ts +7 -7
  51. package/dist/capacity-provider/environment-catalog.d.ts +188 -188
  52. package/dist/capacity-provider/environment-catalog.js +1 -1
  53. package/dist/capacity-provider/install-configuration.d.ts +2 -2
  54. package/dist/capacity-provider/sandbox-contracts.d.ts +92 -92
  55. package/dist/capacity-provider/source-workspace.d.ts +166 -68
  56. package/dist/capacity-provider/source-workspace.js +5 -1
  57. package/dist/capacity-provider/validation.d.ts +10 -2
  58. package/dist/capacity-provider/validation.js +52 -22
  59. package/dist/content/validation/agent-operational-content-schemas.d.ts +144 -142
  60. package/dist/content/validation/agent-operational-content-schemas.js +2 -0
  61. package/dist/content/validation/auxiliary-content-schemas.d.ts +158 -158
  62. package/dist/content/validation/content-model-schemas.d.ts +9105 -5295
  63. package/dist/content/validation/content-model-schemas.js +192 -115
  64. package/dist/content/validation/portable-content-data.d.ts +411 -238
  65. package/dist/content/validation/portable-content-data.js +6 -1
  66. package/dist/content/validation/schema-constraints.d.ts +78 -0
  67. package/dist/content/validation/schema-constraints.js +149 -0
  68. package/dist/deployment/ai/storage.d.ts +24 -24
  69. package/dist/deployment/ai-hosting.d.ts +18 -18
  70. package/dist/deployment/ai-instance.d.ts +16 -16
  71. package/dist/deployment/ai-mode.d.ts +92 -92
  72. package/dist/deployment/hosted-topology-template.d.ts +44 -44
  73. package/dist/deployment/hosted-topology.d.ts +335 -335
  74. package/dist/deployment/postgres/contracts.d.ts +52 -52
  75. package/dist/deployment/postgres/transfer.d.ts +6 -6
  76. package/dist/deployment/schemas.d.ts +1114 -1114
  77. package/dist/development/schemas.d.ts +633 -633
  78. package/dist/graph/context-query-contracts.js +1 -1
  79. package/dist/guarantees/index.d.ts +26 -2
  80. package/dist/identity/contracts.js +6 -1
  81. package/dist/knowledge/contracts.d.ts +9 -2
  82. package/dist/knowledge/contracts.js +2 -2
  83. package/dist/model-registry/discussion-models.js +0 -1
  84. package/dist/operator-contracts/canonical-command-tree.js +25 -9
  85. package/dist/operator-contracts/catalog/agents/agent-team-clone-operations.d.ts +29 -29
  86. package/dist/operator-contracts/catalog/capability-ontology-operations.d.ts +30 -30
  87. package/dist/operator-contracts/catalog/commands/command-tree-builders.d.ts +15 -13
  88. package/dist/operator-contracts/catalog/communication-operations.d.ts +176 -158
  89. package/dist/operator-contracts/catalog/hosted-topology-operations.d.ts +67 -67
  90. package/dist/operator-contracts/catalog/inbox-operations.d.ts +65 -65
  91. package/dist/operator-contracts/catalog/infrastructure/ai-instance-operations.d.ts +6 -6
  92. package/dist/operator-contracts/catalog/infrastructure/ai-instance-operations.js +2 -1
  93. package/dist/operator-contracts/catalog/knowledge-share-operations.d.ts +10 -10
  94. package/dist/operator-contracts/catalog/provider-environment-operations.d.ts +3 -3
  95. package/dist/operator-contracts/catalog/services/secret-operations.d.ts +16 -8
  96. package/dist/operator-contracts/catalog/services/secret-operations.js +2 -1
  97. package/dist/operator-contracts/catalog/workdays/profile-operations.d.ts +11 -11
  98. package/dist/operator-contracts/catalog/workdays/selection-commands.js +3 -0
  99. package/dist/operator-contracts/communication/contracts.d.ts +537 -395
  100. package/dist/operator-contracts/communication/contracts.js +6 -1
  101. package/dist/operator-contracts/control-plane-operation.d.ts +7 -0
  102. package/dist/operator-contracts/control-plane-operation.js +6 -0
  103. package/dist/operator-contracts/control-plane-operations.d.ts +631 -610
  104. package/dist/operator-contracts/control-plane-operations.js +26 -12
  105. package/dist/operator-contracts/inbox/contracts.d.ts +229 -229
  106. package/dist/operator-contracts/knowledge/contracts.d.ts +16 -16
  107. package/dist/operator-contracts/mcp.js +4 -3
  108. package/dist/operator-contracts/workday-lifecycle.d.ts +192 -0
  109. package/dist/operator-contracts/workday-lifecycle.js +109 -45
  110. package/dist/platform/agent-schema-verification.d.ts +3 -0
  111. package/dist/platform/agent-schema-verification.js +377 -0
  112. package/dist/platform/contracts.d.ts +72 -72
  113. package/dist/platform/schemas.d.ts +144 -36
  114. package/dist/platform/schemas.js +26 -0
  115. package/dist/platform/verification.js +10 -0
  116. package/dist/sdk-types/support/planning-policy.d.ts +1 -1
  117. package/dist/sdk-types/support/sdk-search-request.d.ts +2 -2
  118. package/dist/secrets-capability/secret-contracts.d.ts +2 -2
  119. package/dist/secrets-capability/shared-access.d.ts +3 -3
  120. package/dist/secrets-capability/shared-resources.d.ts +50 -50
  121. package/dist/secrets-capability/vault-contracts.d.ts +2 -2
  122. package/dist/security/encrypted-envelope.d.ts +14 -14
  123. package/dist/treedx/client.d.ts +4 -4
  124. package/dist/treedx/index.d.ts +1 -1
  125. package/dist/treedx/index.js +1 -0
  126. package/dist/treedx/types.d.ts +286 -0
  127. package/dist/treedx/types.js +44 -0
  128. package/guarantees/agent/golden/component-boundaries.guarantee.yaml +12 -0
  129. package/guarantees/agent/golden/product-custody.guarantee.yaml +12 -0
  130. package/guarantees/agent/golden/product.guarantee.yaml +12 -0
  131. package/guarantees/agent/golden/scenes/component-boundaries.scene.yaml +837 -0
  132. package/guarantees/agent/golden/scenes/product-custody.scene.yaml +53 -0
  133. package/guarantees/agent/golden/scenes/product.scene.yaml +8 -0
  134. package/guarantees/verifiers/golden.verifiers.yaml +1429 -0
  135. package/package.json +9 -3
  136. package/tests/acceptance/golden-product.test.ts +205 -0
  137. package/tests/acceptance/golden-product.ts +404 -0
  138. package/tests/acceptance/product/base-red.ts +73 -0
  139. package/tests/acceptance/product/documentation-examples.ts +68 -0
  140. package/tests/acceptance/product/intent-runtime.ts +145 -0
  141. package/tests/acceptance/product/release-output.ts +160 -0
  142. package/tests/acceptance/product/research-artifact.ts +87 -0
  143. package/tests/acceptance/product/research-revision.ts +82 -0
  144. package/tests/acceptance/product/research-source.ts +91 -0
  145. package/tests/acceptance/product/test-chain.ts +192 -0
  146. package/treeseed.package.yaml +147 -0
  147. package/dist/.treeseed-build-complete.json +0 -1
  148. package/dist/agent-capacity/allocation.d.ts +0 -183
  149. package/dist/agent-capacity/allocation.js +0 -5
  150. package/dist/agent-capacity/artifact-mutation-receipt.d.ts +0 -49
  151. package/dist/agent-capacity/artifact-mutation-receipt.js +0 -36
  152. package/dist/agent-capacity/artifacts.d.ts +0 -123
  153. package/dist/agent-capacity/artifacts.js +0 -39
  154. package/dist/agent-capacity/contracts/support/decision-work.d.ts +0 -227
  155. package/dist/agent-capacity/contracts/support/decision-work.js +0 -0
  156. package/dist/agent-capacity/validation/allocation.d.ts +0 -12
  157. package/dist/agent-capacity/validation/allocation.js +0 -115
@@ -5,20 +5,20 @@ export declare const knowledgeShareGrantInputSchema: z.ZodObject<{
5
5
  projectIds: z.ZodEffects<z.ZodArray<z.ZodString, "many">, string[], string[]>;
6
6
  contentModels: z.ZodDefault<z.ZodEffects<z.ZodArray<z.ZodString, "many">, string[], string[]>>;
7
7
  paths: z.ZodDefault<z.ZodEffects<z.ZodArray<z.ZodString, "many">, string[], string[]>>;
8
- operations: z.ZodDefault<z.ZodEffects<z.ZodArray<z.ZodEnum<["read", "query", "context", "graph"]>, "many">, ("read" | "context" | "query" | "graph")[], ("read" | "context" | "query" | "graph")[]>>;
8
+ operations: z.ZodDefault<z.ZodEffects<z.ZodArray<z.ZodEnum<["read", "query", "context", "graph"]>, "many">, ("query" | "read" | "context" | "graph")[], ("query" | "read" | "context" | "graph")[]>>;
9
9
  expiresAt: z.ZodDefault<z.ZodNullable<z.ZodString>>;
10
10
  }, "strict", z.ZodTypeAny, {
11
11
  expiresAt: string | null;
12
- operations: ("read" | "context" | "query" | "graph")[];
12
+ operations: ("query" | "read" | "context" | "graph")[];
13
+ projectIds: string[];
13
14
  paths: string[];
14
15
  targetTeamId: string;
15
- projectIds: string[];
16
16
  contentModels: string[];
17
17
  }, {
18
- targetTeamId: string;
19
18
  projectIds: string[];
19
+ targetTeamId: string;
20
20
  expiresAt?: string | null | undefined;
21
- operations?: ("read" | "context" | "query" | "graph")[] | undefined;
21
+ operations?: ("query" | "read" | "context" | "graph")[] | undefined;
22
22
  paths?: string[] | undefined;
23
23
  contentModels?: string[] | undefined;
24
24
  }>;
@@ -27,7 +27,7 @@ export declare const knowledgeShareSchema: z.ZodEffects<z.ZodObject<{
27
27
  projectIds: z.ZodEffects<z.ZodArray<z.ZodString, "many">, string[], string[]>;
28
28
  contentModels: z.ZodDefault<z.ZodEffects<z.ZodArray<z.ZodString, "many">, string[], string[]>>;
29
29
  paths: z.ZodDefault<z.ZodEffects<z.ZodArray<z.ZodString, "many">, string[], string[]>>;
30
- operations: z.ZodDefault<z.ZodEffects<z.ZodArray<z.ZodEnum<["read", "query", "context", "graph"]>, "many">, ("read" | "context" | "query" | "graph")[], ("read" | "context" | "query" | "graph")[]>>;
30
+ operations: z.ZodDefault<z.ZodEffects<z.ZodArray<z.ZodEnum<["read", "query", "context", "graph"]>, "many">, ("query" | "read" | "context" | "graph")[], ("query" | "read" | "context" | "graph")[]>>;
31
31
  expiresAt: z.ZodDefault<z.ZodNullable<z.ZodString>>;
32
32
  } & {
33
33
  schemaVersion: z.ZodLiteral<"treeseed.knowledge-share/v1">;
@@ -43,11 +43,11 @@ export declare const knowledgeShareSchema: z.ZodEffects<z.ZodObject<{
43
43
  expiresAt: string | null;
44
44
  schemaVersion: "treeseed.knowledge-share/v1";
45
45
  createdAt: string;
46
- operations: ("read" | "context" | "query" | "graph")[];
47
- paths: string[];
48
46
  updatedAt: string;
49
- targetTeamId: string;
47
+ operations: ("query" | "read" | "context" | "graph")[];
50
48
  projectIds: string[];
49
+ paths: string[];
50
+ targetTeamId: string;
51
51
  contentModels: string[];
52
52
  sourceTeamId: string;
53
53
  revokedAt: string | null;
@@ -57,12 +57,12 @@ export declare const knowledgeShareSchema: z.ZodEffects<z.ZodObject<{
57
57
  schemaVersion: "treeseed.knowledge-share/v1";
58
58
  createdAt: string;
59
59
  updatedAt: string;
60
- targetTeamId: string;
61
60
  projectIds: string[];
61
+ targetTeamId: string;
62
62
  sourceTeamId: string;
63
63
  revokedAt: string | null;
64
64
  expiresAt?: string | null | undefined;
65
- operations?: ("read" | "context" | "query" | "graph")[] | undefined;
65
+ operations?: ("query" | "read" | "context" | "graph")[] | undefined;
66
66
  paths?: string[] | undefined;
67
67
  contentModels?: string[] | undefined;
68
68
  }>, {
@@ -71,11 +71,11 @@ export declare const knowledgeShareSchema: z.ZodEffects<z.ZodObject<{
71
71
  expiresAt: string | null;
72
72
  schemaVersion: "treeseed.knowledge-share/v1";
73
73
  createdAt: string;
74
- operations: ("read" | "context" | "query" | "graph")[];
75
- paths: string[];
76
74
  updatedAt: string;
77
- targetTeamId: string;
75
+ operations: ("query" | "read" | "context" | "graph")[];
78
76
  projectIds: string[];
77
+ paths: string[];
78
+ targetTeamId: string;
79
79
  contentModels: string[];
80
80
  sourceTeamId: string;
81
81
  revokedAt: string | null;
@@ -85,12 +85,12 @@ export declare const knowledgeShareSchema: z.ZodEffects<z.ZodObject<{
85
85
  schemaVersion: "treeseed.knowledge-share/v1";
86
86
  createdAt: string;
87
87
  updatedAt: string;
88
- targetTeamId: string;
89
88
  projectIds: string[];
89
+ targetTeamId: string;
90
90
  sourceTeamId: string;
91
91
  revokedAt: string | null;
92
92
  expiresAt?: string | null | undefined;
93
- operations?: ("read" | "context" | "query" | "graph")[] | undefined;
93
+ operations?: ("query" | "read" | "context" | "graph")[] | undefined;
94
94
  paths?: string[] | undefined;
95
95
  contentModels?: string[] | undefined;
96
96
  }>;
@@ -21,12 +21,13 @@ function resourcePath(restPath) {
21
21
  }
22
22
  function operationToMcpResource(operation) {
23
23
  if (!operation.surfaces.includes("mcp_resource")) return null;
24
- if (operation.kind !== "read" || operation.rest.method !== "GET") {
24
+ const rest = operation.rest;
25
+ if (operation.kind !== "read" || !rest || rest.method !== "GET") {
25
26
  throw new Error(`MCP resource operation ${operation.operationId} must be a read-only GET operation.`);
26
27
  }
27
- const uriTemplate = `treeseed://${resourcePath(operation.rest.path)}`;
28
+ const uriTemplate = `treeseed://${resourcePath(rest.path)}`;
28
29
  const parameters = (value) => [...value.matchAll(/\{([^}]+)\}/gu)].map((match) => match[1]).sort();
29
- if (JSON.stringify(parameters(uriTemplate)) !== JSON.stringify(parameters(operation.rest.path))) {
30
+ if (JSON.stringify(parameters(uriTemplate)) !== JSON.stringify(parameters(rest.path))) {
30
31
  throw new Error(`MCP resource ${operation.operationId} must preserve its REST path parameter names.`);
31
32
  }
32
33
  return {
@@ -1,5 +1,191 @@
1
1
  import type { WorkdayAgentSelection } from '../agent-capacity/workday.js';
2
+ import { z } from 'zod';
2
3
  export { normalizeWorkdayAgentSelection } from '../agent-capacity/workday.js';
4
+ export declare const workdayIntentSchema: z.ZodEffects<z.ZodEffects<z.ZodObject<{
5
+ schemaVersion: z.ZodLiteral<"treeseed.workday-intent/v1">;
6
+ teamId: z.ZodString;
7
+ profileId: z.ZodString;
8
+ projects: z.ZodEffects<z.ZodUnion<[z.ZodLiteral<"all">, z.ZodEffects<z.ZodArray<z.ZodString, "many">, string[], string[]>]>, any, any>;
9
+ executionMode: z.ZodOptional<z.ZodDefault<z.ZodEnum<["simulation", "production"]>>>;
10
+ startsAt: z.ZodString;
11
+ endsAt: z.ZodOptional<z.ZodString>;
12
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
13
+ planningOnly: z.ZodOptional<z.ZodBoolean>;
14
+ objectiveFilters: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
15
+ proposalIds: z.ZodOptional<z.ZodEffects<z.ZodArray<z.ZodString, "many">, string[], string[]>>;
16
+ decisionIds: z.ZodOptional<z.ZodEffects<z.ZodArray<z.ZodString, "many">, string[], string[]>>;
17
+ reportingAgentId: z.ZodOptional<z.ZodString>;
18
+ continueFromWorkdayId: z.ZodOptional<z.ZodString>;
19
+ allocation: z.ZodOptional<z.ZodObject<{
20
+ planningPercent: z.ZodOptional<z.ZodNumber>;
21
+ allocationWeight: z.ZodOptional<z.ZodNumber>;
22
+ planningTurnMaximumSeconds: z.ZodOptional<z.ZodNumber>;
23
+ projectPercentages: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
24
+ agentClassPercentages: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodNumber>>>;
25
+ }, "strict", z.ZodTypeAny, {
26
+ planningPercent?: number | undefined;
27
+ allocationWeight?: number | undefined;
28
+ planningTurnMaximumSeconds?: number | undefined;
29
+ projectPercentages?: Record<string, number> | undefined;
30
+ agentClassPercentages?: Record<string, Record<string, number>> | undefined;
31
+ }, {
32
+ planningPercent?: number | undefined;
33
+ allocationWeight?: number | undefined;
34
+ planningTurnMaximumSeconds?: number | undefined;
35
+ projectPercentages?: Record<string, number> | undefined;
36
+ agentClassPercentages?: Record<string, Record<string, number>> | undefined;
37
+ }>>;
38
+ agentSelection: z.ZodOptional<z.ZodEffects<z.ZodObject<{
39
+ agentSlugs: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
40
+ classIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
41
+ classSlugs: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
42
+ activityTypes: z.ZodOptional<z.ZodArray<z.ZodEnum<["planning", "estimating", "reviewing", "reporting", "chat"]>, "many">>;
43
+ mode: z.ZodOptional<z.ZodLiteral<"intersection">>;
44
+ }, "strict", z.ZodTypeAny, {
45
+ mode?: "intersection" | undefined;
46
+ classIds?: string[] | undefined;
47
+ classSlugs?: string[] | undefined;
48
+ agentSlugs?: string[] | undefined;
49
+ activityTypes?: ("planning" | "estimating" | "reviewing" | "reporting" | "chat")[] | undefined;
50
+ }, {
51
+ mode?: "intersection" | undefined;
52
+ classIds?: string[] | undefined;
53
+ classSlugs?: string[] | undefined;
54
+ agentSlugs?: string[] | undefined;
55
+ activityTypes?: ("planning" | "estimating" | "reviewing" | "reporting" | "chat")[] | undefined;
56
+ }>, {
57
+ [x: string]: any;
58
+ }, {
59
+ [x: string]: any;
60
+ }>>;
61
+ operatorConstraints: z.ZodOptional<z.ZodObject<{
62
+ providerIds: z.ZodOptional<z.ZodEffects<z.ZodArray<z.ZodString, "many">, string[], string[]>>;
63
+ maxConcurrency: z.ZodOptional<z.ZodNumber>;
64
+ }, "strict", z.ZodTypeAny, {
65
+ providerIds?: string[] | undefined;
66
+ maxConcurrency?: number | undefined;
67
+ }, {
68
+ providerIds?: string[] | undefined;
69
+ maxConcurrency?: number | undefined;
70
+ }>>;
71
+ }, "strict", z.ZodTypeAny, {
72
+ schemaVersion: "treeseed.workday-intent/v1";
73
+ teamId: string;
74
+ profileId: string;
75
+ startsAt: string;
76
+ durationSeconds?: number | undefined;
77
+ projects?: any;
78
+ executionMode?: "simulation" | "production" | undefined;
79
+ reportingAgentId?: string | undefined;
80
+ endsAt?: string | undefined;
81
+ planningOnly?: boolean | undefined;
82
+ objectiveFilters?: string[] | undefined;
83
+ proposalIds?: string[] | undefined;
84
+ decisionIds?: string[] | undefined;
85
+ continueFromWorkdayId?: string | undefined;
86
+ allocation?: {
87
+ planningPercent?: number | undefined;
88
+ allocationWeight?: number | undefined;
89
+ planningTurnMaximumSeconds?: number | undefined;
90
+ projectPercentages?: Record<string, number> | undefined;
91
+ agentClassPercentages?: Record<string, Record<string, number>> | undefined;
92
+ } | undefined;
93
+ agentSelection?: {
94
+ [x: string]: any;
95
+ } | undefined;
96
+ operatorConstraints?: {
97
+ providerIds?: string[] | undefined;
98
+ maxConcurrency?: number | undefined;
99
+ } | undefined;
100
+ }, {
101
+ schemaVersion: "treeseed.workday-intent/v1";
102
+ teamId: string;
103
+ profileId: string;
104
+ startsAt: string;
105
+ durationSeconds?: number | undefined;
106
+ projects?: any;
107
+ executionMode?: "simulation" | "production" | undefined;
108
+ reportingAgentId?: string | undefined;
109
+ endsAt?: string | undefined;
110
+ planningOnly?: boolean | undefined;
111
+ objectiveFilters?: string[] | undefined;
112
+ proposalIds?: string[] | undefined;
113
+ decisionIds?: string[] | undefined;
114
+ continueFromWorkdayId?: string | undefined;
115
+ allocation?: {
116
+ planningPercent?: number | undefined;
117
+ allocationWeight?: number | undefined;
118
+ planningTurnMaximumSeconds?: number | undefined;
119
+ projectPercentages?: Record<string, number> | undefined;
120
+ agentClassPercentages?: Record<string, Record<string, number>> | undefined;
121
+ } | undefined;
122
+ agentSelection?: {
123
+ [x: string]: any;
124
+ } | undefined;
125
+ operatorConstraints?: {
126
+ providerIds?: string[] | undefined;
127
+ maxConcurrency?: number | undefined;
128
+ } | undefined;
129
+ }>, {
130
+ schemaVersion: "treeseed.workday-intent/v1";
131
+ teamId: string;
132
+ profileId: string;
133
+ startsAt: string;
134
+ durationSeconds?: number | undefined;
135
+ projects?: any;
136
+ executionMode?: "simulation" | "production" | undefined;
137
+ reportingAgentId?: string | undefined;
138
+ endsAt?: string | undefined;
139
+ planningOnly?: boolean | undefined;
140
+ objectiveFilters?: string[] | undefined;
141
+ proposalIds?: string[] | undefined;
142
+ decisionIds?: string[] | undefined;
143
+ continueFromWorkdayId?: string | undefined;
144
+ allocation?: {
145
+ planningPercent?: number | undefined;
146
+ allocationWeight?: number | undefined;
147
+ planningTurnMaximumSeconds?: number | undefined;
148
+ projectPercentages?: Record<string, number> | undefined;
149
+ agentClassPercentages?: Record<string, Record<string, number>> | undefined;
150
+ } | undefined;
151
+ agentSelection?: {
152
+ [x: string]: any;
153
+ } | undefined;
154
+ operatorConstraints?: {
155
+ providerIds?: string[] | undefined;
156
+ maxConcurrency?: number | undefined;
157
+ } | undefined;
158
+ }, {
159
+ schemaVersion: "treeseed.workday-intent/v1";
160
+ teamId: string;
161
+ profileId: string;
162
+ startsAt: string;
163
+ durationSeconds?: number | undefined;
164
+ projects?: any;
165
+ executionMode?: "simulation" | "production" | undefined;
166
+ reportingAgentId?: string | undefined;
167
+ endsAt?: string | undefined;
168
+ planningOnly?: boolean | undefined;
169
+ objectiveFilters?: string[] | undefined;
170
+ proposalIds?: string[] | undefined;
171
+ decisionIds?: string[] | undefined;
172
+ continueFromWorkdayId?: string | undefined;
173
+ allocation?: {
174
+ planningPercent?: number | undefined;
175
+ allocationWeight?: number | undefined;
176
+ planningTurnMaximumSeconds?: number | undefined;
177
+ projectPercentages?: Record<string, number> | undefined;
178
+ agentClassPercentages?: Record<string, Record<string, number>> | undefined;
179
+ } | undefined;
180
+ agentSelection?: {
181
+ [x: string]: any;
182
+ } | undefined;
183
+ operatorConstraints?: {
184
+ providerIds?: string[] | undefined;
185
+ maxConcurrency?: number | undefined;
186
+ } | undefined;
187
+ }>, any, any>;
188
+ export declare const workdayIntentRequestSchema: z.ZodEffects<z.ZodType<Record<string, unknown>, z.ZodTypeDef, Record<string, unknown>>, any, Record<string, unknown>>;
3
189
  export type WorkdayDemandMode = 'planning' | 'acting';
4
190
  export interface WorkdayIntent {
5
191
  schemaVersion: 'treeseed.workday-intent/v1';
@@ -18,6 +204,10 @@ export interface WorkdayIntent {
18
204
  proposalIds?: string[];
19
205
  /** Selects accepted decisions for API-derived acting work; it does not grant acting authority. */
20
206
  decisionIds?: string[];
207
+ /** Selects one configured closeout agent; the API resolves its frozen reporting profile. */
208
+ reportingAgentId?: string;
209
+ /** Continue exact accepted work from a settled workday; omission starts a fresh simulation. */
210
+ continueFromWorkdayId?: string;
21
211
  /** Limits cooperative planning; acting still requires accepted decision/estimate authority. */
22
212
  agentSelection?: Partial<WorkdayAgentSelection>;
23
213
  /** High-level overrides of the canonical workday allocation policy. */
@@ -143,6 +333,8 @@ export interface WorkdayLifecycleDiagnostic {
143
333
  message: string;
144
334
  }
145
335
  export declare function validateWorkdayIntent(intent: WorkdayIntent): WorkdayLifecycleDiagnostic[];
336
+ /** Preserve raw caller evidence; normalize only legitimate selector input. */
337
+ export declare function normalizeWorkdayIntent(intent: WorkdayIntent): WorkdayIntent;
146
338
  export declare function validateWorkdayIntentSelection(value: unknown): WorkdayLifecycleDiagnostic[];
147
339
  export declare function validateSelectedDemand(demand: WorkdaySelectedDemand): WorkdayLifecycleDiagnostic[];
148
340
  export declare function validateWorkdayPreflight(receipt: WorkdayPreflightReceipt, now?: Date): WorkdayLifecycleDiagnostic[];
@@ -1,54 +1,115 @@
1
1
  import { workdayAllocationOverridesSchema } from "../agent-capacity/contracts/capacity/workdays/workday-allocation.js";
2
+ import { z } from "zod";
3
+ import { leaseSchema } from "../agent-capacity/contracts/capacity/assignments/agent-execution.js";
4
+ import { alternativeProperties, conditionalFields, exclusiveProperties, exclusiveUnion, uniqueArray } from "../content/validation/schema-constraints.js";
2
5
  import { normalizeWorkdayAgentSelection } from "../agent-capacity/workday.js";
3
- function validateWorkdayIntent(intent) {
4
- const diagnostics = [];
5
- if (intent.schemaVersion !== "treeseed.workday-intent/v1") diagnostics.push({ code: "schema_version_invalid", path: "schemaVersion", message: "Unsupported workday intent schema." });
6
- if (!intent.teamId.trim()) diagnostics.push({ code: "team_required", path: "teamId", message: "Team identity is required." });
7
- if (!intent.profileId.trim()) diagnostics.push({ code: "profile_required", path: "profileId", message: "Allocation profile identity is required." });
8
- if (intent.executionMode !== void 0 && !["simulation", "production"].includes(intent.executionMode)) diagnostics.push({ code: "execution_mode_invalid", path: "executionMode", message: "Select simulation or production custody." });
9
- if (intent.endsAt !== void 0 && intent.durationSeconds !== void 0) diagnostics.push({ code: "time_range_ambiguous", path: "endsAt", message: "Specify endsAt or durationSeconds, not both; omission uses the team policy duration." });
10
- const start = Date.parse(intent.startsAt);
11
- if (!Number.isFinite(start)) diagnostics.push({ code: "start_invalid", path: "startsAt", message: "startsAt must be an ISO timestamp." });
12
- if (intent.endsAt !== void 0 && (!Number.isFinite(Date.parse(intent.endsAt)) || Date.parse(intent.endsAt) <= start)) diagnostics.push({ code: "end_invalid", path: "endsAt", message: "endsAt must be a valid timestamp after startsAt." });
13
- if (intent.durationSeconds !== void 0 && (!Number.isInteger(intent.durationSeconds) || intent.durationSeconds <= 0)) diagnostics.push({ code: "duration_invalid", path: "durationSeconds", message: "durationSeconds must be a positive integer." });
14
- if (intent.planningOnly !== void 0 && typeof intent.planningOnly !== "boolean") diagnostics.push({ code: "planning_only_invalid", path: "planningOnly", message: "planningOnly must be boolean." });
15
- if (intent.proposalIds !== void 0 && (!Array.isArray(intent.proposalIds) || intent.proposalIds.length === 0 || intent.proposalIds.length > 64 || intent.proposalIds.some((entry) => typeof entry !== "string" || !entry.trim() || entry.length > 128))) {
16
- diagnostics.push({ code: "proposal_selection_invalid", path: "proposalIds", message: "Proposal selection must be a bounded nonempty array of proposal identities." });
17
- }
18
- if (intent.decisionIds !== void 0 && (!Array.isArray(intent.decisionIds) || intent.decisionIds.length === 0 || intent.decisionIds.length > 64 || intent.decisionIds.some((entry) => typeof entry !== "string" || !entry.trim() || entry.length > 128))) {
19
- diagnostics.push({ code: "decision_selection_invalid", path: "decisionIds", message: "Decision selection must be a bounded nonempty array of decision identities." });
6
+ const identifier = leaseSchema.shape.id, timestamp = leaseSchema.shape.acquiredAt;
7
+ const selectedIdentities = uniqueArray(z.array(identifier).min(1).max(64));
8
+ const intentAgentSelectionSchema = alternativeProperties(z.object({
9
+ agentSlugs: z.array(identifier).min(1).optional(),
10
+ classIds: z.array(identifier).min(1).optional(),
11
+ classSlugs: z.array(identifier).min(1).optional(),
12
+ activityTypes: z.array(z.enum(["planning", "estimating", "reviewing", "reporting", "chat"])).min(1).optional(),
13
+ mode: z.literal("intersection").optional()
14
+ }).strict(), ["agentSlugs", "activityTypes", "classIds", "classSlugs"]);
15
+ const workdayIntentFields = z.object({
16
+ schemaVersion: z.literal("treeseed.workday-intent/v1"),
17
+ teamId: identifier,
18
+ profileId: identifier,
19
+ projects: exclusiveUnion(z.union([z.literal("all"), uniqueArray(z.array(identifier).min(1))])),
20
+ executionMode: z.enum(["simulation", "production"]).default("simulation").optional(),
21
+ startsAt: timestamp,
22
+ endsAt: timestamp.optional(),
23
+ durationSeconds: z.number().int().positive().optional(),
24
+ planningOnly: z.boolean().optional(),
25
+ objectiveFilters: z.array(identifier).optional(),
26
+ proposalIds: selectedIdentities.optional(),
27
+ decisionIds: selectedIdentities.optional(),
28
+ reportingAgentId: identifier.optional(),
29
+ continueFromWorkdayId: z.string().min(1).max(128).regex(/\S/u).optional(),
30
+ allocation: workdayAllocationOverridesSchema.optional(),
31
+ agentSelection: intentAgentSelectionSchema.optional(),
32
+ operatorConstraints: z.object({ providerIds: uniqueArray(z.array(identifier)).optional(), maxConcurrency: z.number().int().positive().optional() }).strict().optional()
33
+ }).strict();
34
+ const continuationRules = [{
35
+ field: "continueFromWorkdayId",
36
+ alternatives: [["decisionIds"]],
37
+ forbidden: { fields: ["proposalIds"], conditions: [{ field: "planningOnly", equals: true }] },
38
+ path: ["continueFromWorkdayId"],
39
+ message: "Continuation requires exact decisions, not new proposal planning."
40
+ }];
41
+ const workdayIntentSchema = exclusiveProperties(conditionalFields(workdayIntentFields, continuationRules), ["endsAt", "durationSeconds"]);
42
+ const requestIntentFields = z.preprocess((value) => {
43
+ if (!value || typeof value !== "object" || Array.isArray(value) || !("decisionIds" in value) || !Array.isArray(value.decisionIds)) return value;
44
+ return { ...value, decisionIds: value.decisionIds.map((entry) => typeof entry === "string" ? entry.trim() : entry) };
45
+ }, exclusiveProperties(conditionalFields(workdayIntentFields.partial({ schemaVersion: true, teamId: true }), continuationRules), ["endsAt", "durationSeconds"])).superRefine((intent, context) => {
46
+ if (!validIntentRange(intent)) context.addIssue({ code: z.ZodIssueCode.custom, path: ["endsAt"], message: "endsAt must be after startsAt." });
47
+ });
48
+ const workdayIntentRequestSchema = z.custom((value) => Boolean(value && typeof value === "object" && !Array.isArray(value))).transform((intent, context) => {
49
+ const parsed = requestIntentFields.safeParse(intent);
50
+ if (!parsed.success) {
51
+ for (const issue of parsed.error.issues) context.addIssue(issue);
52
+ return z.NEVER;
20
53
  }
21
- if (intent.agentSelection !== void 0) diagnostics.push(...validateWorkdayIntentSelection(intent.agentSelection));
22
- if (intent.allocation !== void 0) {
23
- const result = workdayAllocationOverridesSchema.safeParse(intent.allocation);
24
- if (!result.success) diagnostics.push(...result.error.issues.map((issue) => ({
25
- code: "allocation_invalid",
26
- path: `allocation.${issue.path.join(".")}`,
54
+ return { ...intent, ...parsed.data, ...parsed.data.decisionIds ? { decisionIds: [...parsed.data.decisionIds].sort() } : {} };
55
+ });
56
+ function validIntentRange(intent) {
57
+ return intent.endsAt === void 0 || Date.parse(intent.endsAt) > Date.parse(intent.startsAt);
58
+ }
59
+ function portableIntentInput(intent) {
60
+ return { ...intent, ...Array.isArray(intent.decisionIds) ? { decisionIds: intent.decisionIds.map((value) => typeof value === "string" ? value.trim() : value) } : {} };
61
+ }
62
+ function validateWorkdayIntent(intent) {
63
+ const result = workdayIntentSchema.safeParse(portableIntentInput(intent));
64
+ const codes = {
65
+ schemaVersion: "schema_version_invalid",
66
+ teamId: "team_required",
67
+ profileId: "profile_required",
68
+ projects: "project_selection_invalid",
69
+ operatorConstraints: "operator_constraints_invalid",
70
+ executionMode: "execution_mode_invalid",
71
+ startsAt: "start_invalid",
72
+ endsAt: "end_invalid",
73
+ durationSeconds: "duration_invalid",
74
+ planningOnly: "planning_only_invalid",
75
+ objectiveFilters: "objective_selection_invalid",
76
+ proposalIds: "proposal_selection_invalid",
77
+ decisionIds: "decision_selection_invalid",
78
+ reportingAgentId: "reporting_agent_selection_invalid",
79
+ continueFromWorkdayId: "continuation_invalid",
80
+ agentSelection: "agent_selection_invalid",
81
+ allocation: "allocation_invalid"
82
+ };
83
+ const diagnostics = result.success ? [] : result.error.issues.flatMap((issue) => {
84
+ if (issue.code === z.ZodIssueCode.unrecognized_keys && !issue.path.length)
85
+ return issue.keys.map((key) => ({ code: "field_forbidden", path: key, message: "Derived execution state is not portable workday intent." }));
86
+ const root = String(issue.path[0] ?? "");
87
+ return [{
88
+ code: root === "endsAt" && intent.durationSeconds !== void 0 && intent.endsAt !== void 0 ? "time_range_ambiguous" : codes[root] ?? "intent_invalid",
89
+ path: root === "allocation" || root === "agentSelection" ? issue.path.join(".") : root,
27
90
  message: issue.message
28
- })));
29
- }
91
+ }];
92
+ });
93
+ if (!validIntentRange(intent))
94
+ diagnostics.push({ code: "end_invalid", path: "endsAt", message: "endsAt must be after startsAt." });
30
95
  return diagnostics;
31
96
  }
97
+ function normalizeWorkdayIntent(intent) {
98
+ const diagnostics = validateWorkdayIntent(intent);
99
+ if (diagnostics.length) throw new Error(`Invalid workday intent: ${diagnostics.map((value) => `${value.path}: ${value.message}`).join("; ")}`);
100
+ const normalized = workdayIntentSchema.parse(portableIntentInput(intent));
101
+ return { ...intent, ...normalized, ...normalized.decisionIds ? { decisionIds: [...normalized.decisionIds].sort() } : {} };
102
+ }
32
103
  function validateWorkdayIntentSelection(value) {
33
- const invalid = (path, message) => ({ code: "agent_selection_invalid", path: `agentSelection${path ? `.${path}` : ""}`, message });
34
- if (!value || typeof value !== "object" || Array.isArray(value)) return [invalid("", "Agent selection must be an object.")];
35
- const selection = value, diagnostics = [];
36
- const fields = ["classIds", "classSlugs", "agentSlugs", "activityTypes"];
37
- for (const key of Object.keys(selection)) if (![...fields, "mode"].includes(key)) diagnostics.push(invalid(key, "Unknown selection field."));
38
- if (selection.mode !== void 0 && !["intersection", "union"].includes(String(selection.mode))) diagnostics.push(invalid("mode", "Select intersection or union."));
39
- let selected = 0;
40
- for (const field of fields) {
41
- const entries = selection[field];
42
- if (entries === void 0) continue;
43
- if (!Array.isArray(entries) || entries.length > 128 || entries.some((entry) => typeof entry !== "string" || !entry.trim() || entry.length > 128)) {
44
- diagnostics.push(invalid(field, "Selectors must be a bounded array of nonempty strings."));
45
- continue;
46
- }
47
- selected += entries.length;
48
- if (field === "activityTypes" && entries.some((entry) => !["planning", "estimating", "reviewing", "reporting", "chat"].includes(String(entry).trim()))) diagnostics.push(invalid(field, "Select a planning activity; acting is controlled by accepted decisions and estimates."));
49
- }
50
- if (!selected) diagnostics.push(invalid("", "Explicit selection must select an agent, class, or activity; omit it to select all."));
51
- return diagnostics;
104
+ const input = value && typeof value === "object" && !Array.isArray(value) ? Object.fromEntries(
105
+ Object.entries(value).map(([key, entries]) => [key, Array.isArray(entries) ? entries.map((entry) => typeof entry === "string" ? entry.trim() : entry) : entries])
106
+ ) : value;
107
+ const result = intentAgentSelectionSchema.safeParse(input);
108
+ return result.success ? [] : result.error.issues.map((issue) => ({
109
+ code: "agent_selection_invalid",
110
+ path: ["agentSelection", ...issue.path].join("."),
111
+ message: issue.message
112
+ }));
52
113
  }
53
114
  function validateSelectedDemand(demand) {
54
115
  const diagnostics = [];
@@ -94,10 +155,13 @@ function validateWorkdaySettlement(settlement) {
94
155
  }
95
156
  export {
96
157
  normalizeWorkdayAgentSelection,
158
+ normalizeWorkdayIntent,
97
159
  validateSelectedDemand,
98
160
  validateWorkdayIntent,
99
161
  validateWorkdayIntentSelection,
100
162
  validateWorkdayPreflight,
101
163
  validateWorkdayPreflightFreshness,
102
- validateWorkdaySettlement
164
+ validateWorkdaySettlement,
165
+ workdayIntentRequestSchema,
166
+ workdayIntentSchema
103
167
  };
@@ -0,0 +1,3 @@
1
+ import type { PlatformDiagnostic } from './schemas.js';
2
+ /** Compare the authored architecture declaration with its executable content validators. */
3
+ export declare function verifyAgentContentSchema(document: unknown, path?: string): PlatformDiagnostic[];