@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
@@ -1,13 +1,16 @@
1
1
  import { z } from "zod";
2
- import { activityProfileSchema } from "../../../validation/agent-definition-schema.js";
3
- const identifier = z.string().trim().min(1).max(200).regex(/^[A-Za-z0-9][A-Za-z0-9._:/-]*$/u);
2
+ import { conditionalFields, uniqueArray } from "../../../../content/validation/schema-constraints.js";
3
+ import { activityProfileSchema, agentClassSchema } from "../../../validation/agent-definition-schema.js";
4
+ import { AGENT_TOOL_GROUPS } from "../../../../types/agents.js";
5
+ const identifierPattern = /^[A-Za-z0-9][A-Za-z0-9._:/-]*$/u;
6
+ const identifier = z.string().trim().min(1).max(200).regex(identifierPattern);
7
+ const canonicalIdentifier = z.string().min(1).max(200).regex(identifierPattern);
4
8
  const timestamp = z.string().datetime({ offset: true });
5
9
  const digest = z.string().regex(/^sha256:[a-f0-9]{64}$/u);
6
10
  const commit = z.string().regex(/^[a-f0-9]{40}$/u);
7
- const uniqueStrings = z.array(z.string().min(1)).superRefine((items, context) => {
8
- if (new Set(items).size !== items.length) context.addIssue({ code: z.ZodIssueCode.custom, message: "Values must be unique." });
9
- });
10
- const exactEntityReferenceSchema = z.object({
11
+ const uniqueStrings = uniqueArray(z.array(z.string().min(1)));
12
+ const writablePaths = uniqueArray(z.array(z.string().min(1)).min(1));
13
+ const exactEntityReferenceSchema = conditionalFields(z.object({
11
14
  store: z.enum(["treedx", "postgresql", "git", "url"]),
12
15
  model: z.string().min(1),
13
16
  id: identifier,
@@ -20,36 +23,36 @@ const exactEntityReferenceSchema = z.object({
20
23
  startLine: z.number().int().positive().optional(),
21
24
  endLine: z.number().int().positive().optional(),
22
25
  url: z.string().url().optional()
23
- }).strict().superRefine((reference, context) => {
24
- if (reference.endLine && !reference.startLine) context.addIssue({ code: z.ZodIssueCode.custom, path: ["startLine"], message: "startLine is required with endLine." });
25
- if (reference.store === "treedx" && !(reference.commit || reference.revision && reference.digest)) context.addIssue({ code: z.ZodIssueCode.custom, message: "TreeDX references require commit or revision and digest." });
26
- if (reference.store === "git" && !(reference.repository && reference.commit)) context.addIssue({ code: z.ZodIssueCode.custom, message: "Git references require repository and commit." });
27
- if (reference.store === "url" && !reference.url) context.addIssue({ code: z.ZodIssueCode.custom, message: "URL references require url." });
28
- });
26
+ }).strict(), [
27
+ { field: "endLine", alternatives: [["startLine"]], path: ["startLine"], message: "startLine is required with endLine." },
28
+ { field: "store", equals: "treedx", alternatives: [["revision", "digest"], ["commit"]], message: "TreeDX references require commit or revision and digest." },
29
+ { field: "store", equals: "git", alternatives: [["repository", "commit"]], message: "Git references require repository and commit." },
30
+ { field: "store", equals: "url", alternatives: [["url"]], message: "URL references require url." }
31
+ ]);
29
32
  const assignmentReferenceSchema = z.discriminatedUnion("kind", [
30
33
  z.object({ kind: z.literal("git"), repository: z.string().min(1), commit, branch: z.string().min(1).optional(), path: z.string().min(1).optional() }).strict(),
31
34
  z.object({ kind: z.literal("treedx"), projectId: identifier, repository: z.string().min(1), commit, path: z.string().min(1), workspaceId: identifier.optional() }).strict(),
32
35
  z.object({ kind: z.literal("url"), url: z.string().url(), digest: digest.optional() }).strict()
33
36
  ]);
37
+ const exactReferences = uniqueArray(z.array(exactEntityReferenceSchema));
34
38
  const exactGrantSchema = z.object({
35
- contentRead: z.array(exactEntityReferenceSchema),
36
- contentWrite: z.array(exactEntityReferenceSchema),
39
+ contentRead: exactReferences,
40
+ contentWrite: exactReferences,
37
41
  sourceRead: uniqueStrings,
38
42
  sourceWrite: uniqueStrings,
39
- tools: uniqueStrings
43
+ tools: uniqueArray(z.array(z.enum(AGENT_TOOL_GROUPS)))
40
44
  }).strict();
41
45
  const assignmentWorkspaceSchema = z.discriminatedUnion("mode", [
42
46
  z.object({ mode: z.literal("read-only") }).strict(),
43
- z.object({ mode: z.literal("treedx"), workspaceId: identifier, repository: z.string().min(1), baseCommit: commit, writablePaths: uniqueStrings.refine((paths) => paths.length > 0) }).strict(),
44
- z.object({ mode: z.literal("git"), repository: z.string().min(1), baseCommit: commit, branch: z.string().min(1), writablePaths: uniqueStrings.refine((paths) => paths.length > 0) }).strict()
47
+ z.object({ mode: z.literal("treedx"), workspaceId: identifier, repository: z.string().min(1), baseCommit: commit, writablePaths }).strict(),
48
+ z.object({ mode: z.literal("git"), repository: z.string().min(1), baseCommit: commit, branch: z.string().min(1), writablePaths }).strict()
45
49
  ]);
46
50
  const estimateSchema = z.object({
47
- minimumSeconds: z.number().int().positive(),
48
51
  expectedSeconds: z.number().int().positive(),
49
52
  maximumSeconds: z.number().int().positive(),
50
53
  rationale: z.string().optional()
51
- }).strict().refine((value) => value.minimumSeconds <= value.expectedSeconds && value.expectedSeconds <= value.maximumSeconds, {
52
- message: "Estimate must satisfy minimumSeconds <= expectedSeconds <= maximumSeconds."
54
+ }).strict().refine((value) => value.expectedSeconds <= value.maximumSeconds, {
55
+ message: "Estimate must satisfy expectedSeconds <= maximumSeconds."
53
56
  });
54
57
  const effectiveActivityProfileSchema = activityProfileSchema.omit({ dependsOn: true }).extend({
55
58
  profileRef: exactEntityReferenceSchema,
@@ -80,17 +83,18 @@ const assignmentAttemptSchema = z.object({
80
83
  projectId: identifier,
81
84
  workdayId: identifier,
82
85
  nodeId: identifier,
86
+ agentClass: z.string().regex(/^[a-z][a-z0-9-]*$/u),
83
87
  workItemId: identifier.optional(),
84
88
  nodeRevision: z.number().int().positive(),
85
89
  graphRevision: z.number().int().positive(),
86
90
  sourceRef: exactEntityReferenceSchema,
87
- authorityRefs: z.array(exactEntityReferenceSchema).min(1),
91
+ authorityRefs: uniqueArray(z.array(exactEntityReferenceSchema).min(1)),
88
92
  effectiveProfile: effectiveActivityProfileSchema,
89
- requiredCapabilities: uniqueStrings,
93
+ requiredCapabilities: uniqueArray(z.array(canonicalIdentifier)),
90
94
  grant: exactGrantSchema,
91
95
  provider: providerSelectionSchema,
92
- contextRefs: z.array(exactEntityReferenceSchema),
93
- predecessorResultIds: uniqueStrings,
96
+ contextRefs: exactReferences,
97
+ predecessorResultIds: uniqueArray(z.array(canonicalIdentifier)),
94
98
  acceptanceCriteria: z.array(z.string().trim().min(1)).min(1).optional(),
95
99
  workspace: assignmentWorkspaceSchema,
96
100
  estimate: estimateSchema,
@@ -103,7 +107,27 @@ const assignmentAttemptSchema = z.object({
103
107
  createdAt: timestamp,
104
108
  startedAt: timestamp.optional(),
105
109
  finishedAt: timestamp.optional()
106
- }).strict();
110
+ }).strict().superRefine((attempt, context) => {
111
+ const workspace = attempt.workspace;
112
+ const sourceWriters = attempt.grant.sourceWrite;
113
+ const contentWriters = attempt.grant.contentWrite;
114
+ const invalid = (path, message) => context.addIssue({
115
+ code: z.ZodIssueCode.custom,
116
+ path,
117
+ message
118
+ });
119
+ if (workspace.mode === "read-only") {
120
+ if (sourceWriters.length) invalid(["grant", "sourceWrite"], "Read-only assignments cannot write source.");
121
+ if (contentWriters.length) invalid(["grant", "contentWrite"], "Read-only assignments cannot write TreeDX content.");
122
+ } else if (workspace.mode === "git") {
123
+ if (contentWriters.length) invalid(["grant", "contentWrite"], "Git assignments cannot mutate TreeDX content.");
124
+ if (sourceWriters.some((repository) => repository !== workspace.repository)) invalid(["grant", "sourceWrite"], "Git writes must stay in the one assigned repository.");
125
+ } else {
126
+ if (sourceWriters.length) invalid(["grant", "sourceWrite"], "TreeDX assignments cannot mutate Git source.");
127
+ if (contentWriters.some((reference) => reference.store !== "treedx" || reference.repository !== workspace.repository))
128
+ invalid(["grant", "contentWrite"], "TreeDX writes must stay in the one assigned repository.");
129
+ }
130
+ });
107
131
  const verificationRecordSchema = z.object({
108
132
  command: z.string().min(1),
109
133
  status: z.enum(["passed", "failed", "skipped"]),
@@ -115,7 +139,7 @@ const usageSchema = z.object({
115
139
  elapsedSeconds: z.number().int().nonnegative(),
116
140
  modelInputTokens: z.number().int().nonnegative().optional(),
117
141
  modelOutputTokens: z.number().int().nonnegative().optional(),
118
- native: z.record(z.number().nonnegative()).optional()
142
+ native: z.record(z.number().finite().nonnegative()).optional()
119
143
  }).strict();
120
144
  const diagnosticSchema = z.object({
121
145
  code: identifier,
@@ -140,18 +164,57 @@ const assignmentResultSchema = z.object({
140
164
  assignmentId: identifier,
141
165
  status: z.enum(["completed", "blocked", "failed"]),
142
166
  summary: z.string().min(1),
143
- references: z.array(assignmentReferenceSchema),
167
+ references: uniqueArray(z.array(assignmentReferenceSchema)),
144
168
  verification: z.array(verificationRecordSchema),
145
169
  usage: usageSchema,
146
170
  diagnostics: z.array(diagnosticSchema),
147
171
  timingAwareness: assignmentTimingAwarenessReceiptSchema.optional(),
148
172
  completedAt: timestamp
149
173
  }).strict();
174
+ const leaseSchema = z.object({
175
+ schemaVersion: z.literal("treeseed.lease/v1"),
176
+ id: canonicalIdentifier,
177
+ assignmentId: canonicalIdentifier,
178
+ providerId: canonicalIdentifier,
179
+ state: z.enum(["active", "released", "expired", "revoked"]),
180
+ acquiredAt: timestamp,
181
+ expiresAt: timestamp,
182
+ releasedAt: timestamp.optional(),
183
+ revision: z.number().int().positive()
184
+ }).strict();
185
+ const reservationSchema = z.object({
186
+ schemaVersion: z.literal("treeseed.reservation/v1"),
187
+ id: canonicalIdentifier,
188
+ assignmentId: canonicalIdentifier,
189
+ workdayId: canonicalIdentifier,
190
+ providerId: canonicalIdentifier,
191
+ estimatedSeconds: z.number().int().positive(),
192
+ state: z.enum(["held", "consumed", "released", "expired"]),
193
+ reservedAt: timestamp,
194
+ closedAt: timestamp.optional()
195
+ }).strict();
196
+ const usageSettlementSchema = z.object({
197
+ schemaVersion: z.literal("treeseed.usage-settlement/v1"),
198
+ id: canonicalIdentifier,
199
+ idempotencyKey: canonicalIdentifier,
200
+ assignmentId: canonicalIdentifier,
201
+ reservationId: canonicalIdentifier,
202
+ workdayId: canonicalIdentifier,
203
+ teamId: canonicalIdentifier,
204
+ projectId: canonicalIdentifier,
205
+ agentClass: agentClassSchema,
206
+ providerId: canonicalIdentifier,
207
+ actualSeconds: z.number().int().nonnegative(),
208
+ nativeUsage: z.record(z.number().finite().nonnegative()),
209
+ cost: z.number().finite().nonnegative().optional(),
210
+ currency: z.string().regex(/^[A-Z]{3}$/u).optional(),
211
+ settledAt: timestamp
212
+ }).strict();
150
213
  const authorizedContextItemSchema = z.object({
151
214
  ref: exactEntityReferenceSchema,
152
215
  mediaType: z.string().min(1),
153
216
  digest,
154
- value: z.any()
217
+ value: z.unknown().refine((value) => value !== void 0, { message: "Authorized context requires its value payload." })
155
218
  }).strict();
156
219
  const assignmentContextSchema = z.object({
157
220
  assignment: assignmentAttemptSchema,
@@ -171,6 +234,9 @@ export {
171
234
  estimateSchema,
172
235
  exactEntityReferenceSchema,
173
236
  exactGrantSchema,
237
+ leaseSchema,
238
+ reservationSchema,
174
239
  usageSchema,
240
+ usageSettlementSchema,
175
241
  verificationRecordSchema
176
242
  };
@@ -51,12 +51,12 @@ export declare const assignmentContextSourceSchema: z.ZodObject<{
51
51
  amount: z.ZodNumber;
52
52
  provenance: z.ZodString;
53
53
  }, "strict", z.ZodTypeAny, {
54
- provenance: string;
55
54
  amount: number;
55
+ provenance: string;
56
56
  unit: "items" | "tokens" | "bytes";
57
57
  }, {
58
- provenance: string;
59
58
  amount: number;
59
+ provenance: string;
60
60
  unit: "items" | "tokens" | "bytes";
61
61
  }>;
62
62
  reason: z.ZodNullable<z.ZodString>;
@@ -65,35 +65,35 @@ export declare const assignmentContextSourceSchema: z.ZodObject<{
65
65
  path: string | null;
66
66
  kind: string;
67
67
  id: string;
68
- digest: string;
69
68
  required: boolean;
70
- projectId: string;
71
69
  teamId: string;
72
- reason: string | null;
70
+ projectId: string;
73
71
  metadata: Record<string, unknown>;
72
+ digest: string;
74
73
  measurement: {
75
- provenance: string;
76
74
  amount: number;
75
+ provenance: string;
77
76
  unit: "items" | "tokens" | "bytes";
78
77
  };
79
- layer: "agent" | "live" | "core" | "tool" | "activity";
78
+ reason: string | null;
80
79
  disposition: "failed" | "included" | "summarized" | "omitted";
80
+ layer: "agent" | "live" | "activity" | "core" | "tool";
81
81
  }, {
82
82
  path: string | null;
83
83
  kind: string;
84
84
  id: string;
85
- digest: string;
86
85
  required: boolean;
87
- projectId: string;
88
86
  teamId: string;
89
- reason: string | null;
87
+ projectId: string;
88
+ digest: string;
90
89
  measurement: {
91
- provenance: string;
92
90
  amount: number;
91
+ provenance: string;
93
92
  unit: "items" | "tokens" | "bytes";
94
93
  };
95
- layer: "agent" | "live" | "core" | "tool" | "activity";
94
+ reason: string | null;
96
95
  disposition: "failed" | "included" | "summarized" | "omitted";
96
+ layer: "agent" | "live" | "activity" | "core" | "tool";
97
97
  metadata?: Record<string, unknown> | undefined;
98
98
  }>;
99
99
  export declare const assignmentContextPackSchema: z.ZodObject<{
@@ -172,12 +172,12 @@ export declare const assignmentContextPackSchema: z.ZodObject<{
172
172
  amount: z.ZodNumber;
173
173
  provenance: z.ZodString;
174
174
  }, "strict", z.ZodTypeAny, {
175
- provenance: string;
176
175
  amount: number;
176
+ provenance: string;
177
177
  unit: "items" | "tokens" | "bytes";
178
178
  }, {
179
- provenance: string;
180
179
  amount: number;
180
+ provenance: string;
181
181
  unit: "items" | "tokens" | "bytes";
182
182
  }>;
183
183
  reason: z.ZodNullable<z.ZodString>;
@@ -186,60 +186,60 @@ export declare const assignmentContextPackSchema: z.ZodObject<{
186
186
  path: string | null;
187
187
  kind: string;
188
188
  id: string;
189
- digest: string;
190
189
  required: boolean;
191
- projectId: string;
192
190
  teamId: string;
193
- reason: string | null;
191
+ projectId: string;
194
192
  metadata: Record<string, unknown>;
193
+ digest: string;
195
194
  measurement: {
196
- provenance: string;
197
195
  amount: number;
196
+ provenance: string;
198
197
  unit: "items" | "tokens" | "bytes";
199
198
  };
200
- layer: "agent" | "live" | "core" | "tool" | "activity";
199
+ reason: string | null;
201
200
  disposition: "failed" | "included" | "summarized" | "omitted";
201
+ layer: "agent" | "live" | "activity" | "core" | "tool";
202
202
  }, {
203
203
  path: string | null;
204
204
  kind: string;
205
205
  id: string;
206
- digest: string;
207
206
  required: boolean;
208
- projectId: string;
209
207
  teamId: string;
210
- reason: string | null;
208
+ projectId: string;
209
+ digest: string;
211
210
  measurement: {
212
- provenance: string;
213
211
  amount: number;
212
+ provenance: string;
214
213
  unit: "items" | "tokens" | "bytes";
215
214
  };
216
- layer: "agent" | "live" | "core" | "tool" | "activity";
215
+ reason: string | null;
217
216
  disposition: "failed" | "included" | "summarized" | "omitted";
217
+ layer: "agent" | "live" | "activity" | "core" | "tool";
218
218
  metadata?: Record<string, unknown> | undefined;
219
219
  }>, "many">;
220
220
  digest: z.ZodString;
221
221
  }, "strict", z.ZodTypeAny, {
222
222
  schemaVersion: "treeseed.assignment-context-pack/v1";
223
+ assignmentId: string;
224
+ digest: string;
223
225
  sources: {
224
226
  path: string | null;
225
227
  kind: string;
226
228
  id: string;
227
- digest: string;
228
229
  required: boolean;
229
- projectId: string;
230
230
  teamId: string;
231
- reason: string | null;
231
+ projectId: string;
232
232
  metadata: Record<string, unknown>;
233
+ digest: string;
233
234
  measurement: {
234
- provenance: string;
235
235
  amount: number;
236
+ provenance: string;
236
237
  unit: "items" | "tokens" | "bytes";
237
238
  };
238
- layer: "agent" | "live" | "core" | "tool" | "activity";
239
+ reason: string | null;
239
240
  disposition: "failed" | "included" | "summarized" | "omitted";
241
+ layer: "agent" | "live" | "activity" | "core" | "tool";
240
242
  }[];
241
- digest: string;
242
- assignmentId: string;
243
243
  capacity: {
244
244
  maximum: number | null;
245
245
  mode: "bounded" | "unbounded";
@@ -260,26 +260,26 @@ export declare const assignmentContextPackSchema: z.ZodObject<{
260
260
  };
261
261
  }, {
262
262
  schemaVersion: "treeseed.assignment-context-pack/v1";
263
+ assignmentId: string;
264
+ digest: string;
263
265
  sources: {
264
266
  path: string | null;
265
267
  kind: string;
266
268
  id: string;
267
- digest: string;
268
269
  required: boolean;
269
- projectId: string;
270
270
  teamId: string;
271
- reason: string | null;
271
+ projectId: string;
272
+ digest: string;
272
273
  measurement: {
273
- provenance: string;
274
274
  amount: number;
275
+ provenance: string;
275
276
  unit: "items" | "tokens" | "bytes";
276
277
  };
277
- layer: "agent" | "live" | "core" | "tool" | "activity";
278
+ reason: string | null;
278
279
  disposition: "failed" | "included" | "summarized" | "omitted";
280
+ layer: "agent" | "live" | "activity" | "core" | "tool";
279
281
  metadata?: Record<string, unknown> | undefined;
280
282
  }[];
281
- digest: string;
282
- assignmentId: string;
283
283
  capacity: {
284
284
  maximum: number | null;
285
285
  mode: "bounded" | "unbounded";
@@ -0,0 +1,2 @@
1
+ /** Assignment paths are relative, traversal-free, and bounded by their workspace grant. */
2
+ export declare function assignmentPathAllowed(path: string, allowed: readonly string[]): boolean;
@@ -0,0 +1,13 @@
1
+ function assignmentPathAllowed(path, allowed) {
2
+ const safe = (value) => value.length > 0 && !value.includes("\\") && !value.includes("\0") && value.split("/").every((segment) => segment.length > 0 && segment !== "." && segment !== "..");
3
+ if (!safe(path) || /[*?]/u.test(path)) return false;
4
+ return allowed.some((value) => {
5
+ const prefix = value.replace(/\/$/u, "");
6
+ if (prefix === "." || prefix === "**") return true;
7
+ const directory = prefix.endsWith("/**") ? prefix.slice(0, -3) : prefix;
8
+ return safe(directory) && !/[*?]/u.test(directory) && (path === directory || path.startsWith(`${directory}/`));
9
+ });
10
+ }
11
+ export {
12
+ assignmentPathAllowed
13
+ };
@@ -2,8 +2,7 @@ export type AgentExecutionMode = 'planning' | 'acting';
2
2
  import type { AgentWorkExecutionMode } from '../../support/authority/execution-mode.js';
3
3
  export type ProviderAssignmentStatus = 'pending' | 'leased' | 'running' | 'completed' | 'failed' | 'returned' | 'expired' | 'cancelled';
4
4
  export type ProviderAssignmentLeaseState = 'unleased' | 'leased' | 'released' | 'expired';
5
- export type AgentModeRunStatus = 'queued' | 'running' | 'succeeded' | 'failed' | 'cancelled';
6
- export type ProviderAssignmentSynthesisSource = 'approved_decision' | 'planning_input_request' | 'capacity_plan' | 'living_execution_graph' | 'workday_demand' | 'verification_failure' | 'fallback_queue';
5
+ export type ProviderAssignmentSynthesisSource = 'living_execution_graph';
7
6
  export declare const AGENT_ASSIGNMENT_WORKSPACE_ACCESS_MODES: readonly ["context_only", "workspace_write", "brokered_workspace", "full_workspace_no_credentials", "trusted_direct"];
8
7
  export type AgentAssignmentWorkspaceAccessMode = (typeof AGENT_ASSIGNMENT_WORKSPACE_ACCESS_MODES)[number];
9
8
  export type AgentAssignmentCapabilityHandleKind = 'repository_access' | 'treedx_workspace' | 'workflow_operation' | 'secret_use';
@@ -14,7 +13,6 @@ export interface WorkdayCapacityEnvelope {
14
13
  workDayId?: string | null;
15
14
  environment?: string | null;
16
15
  executionMode?: AgentWorkExecutionMode;
17
- allocationSetId?: string | null;
18
16
  availableSeconds?: number | null;
19
17
  requestedSeconds?: number | null;
20
18
  reservedSeconds?: number | null;
@@ -35,23 +33,6 @@ export interface AgentCapacityEnvelope extends WorkdayCapacityEnvelope {
35
33
  reservedNativeAmount?: number | null;
36
34
  limits?: Record<string, unknown>;
37
35
  }
38
- export interface DecisionExecutionInput {
39
- teamId: string;
40
- projectId: string;
41
- projectAgentClassId: string;
42
- mode: AgentExecutionMode;
43
- executionMode?: AgentWorkExecutionMode;
44
- activityType?: import('../../../../types/agents.js').AgentActivityType;
45
- workGraphNodeId?: string | null;
46
- estimateId?: string | null;
47
- taskId?: string | null;
48
- workDayId?: string | null;
49
- agentId?: string | null;
50
- handlerId?: string | null;
51
- capacity: AgentCapacityEnvelope;
52
- input: Record<string, unknown>;
53
- metadata?: Record<string, unknown>;
54
- }
55
36
  export interface TreeDxProxyHandle {
56
37
  id: string;
57
38
  teamId: string;
@@ -163,10 +144,10 @@ export interface ProviderAssignment {
163
144
  parentWorkdayId?: string | null;
164
145
  parentAssignmentId?: string | null;
165
146
  handoffRootId?: string | null;
147
+ operationHandoffId?: string | null;
166
148
  handoffParentId?: string | null;
167
149
  handoffDepth?: number;
168
150
  sourceMessageRefs?: string[];
169
- allocationSetId: string | null;
170
151
  projectAgentClassId: string;
171
152
  reservationId: string | null;
172
153
  workDayId: string | null;
@@ -182,7 +163,6 @@ export interface ProviderAssignment {
182
163
  agentId: string | null;
183
164
  handlerId: string | null;
184
165
  capacityEnvelope: AgentCapacityEnvelope;
185
- decisionInput: DecisionExecutionInput | Record<string, unknown>;
186
166
  workspaceContext: Record<string, unknown>;
187
167
  allowedOutputs: Record<string, unknown>;
188
168
  explanation: Record<string, unknown>;
@@ -227,7 +207,6 @@ export interface ProviderAssignmentLifecycleRequest {
227
207
  output?: Record<string, unknown> | null;
228
208
  summary?: Record<string, unknown> | null;
229
209
  fallbackOutput?: Record<string, unknown> | null;
230
- modeRunId?: string | null;
231
210
  metadata?: Record<string, unknown>;
232
211
  completion?: import('../../support/time-capacity.js').AssignmentCompletionEvidence | null;
233
212
  performance?: import('../../support/time-capacity.js').AssignmentPerformanceSummary | null;
@@ -251,39 +230,3 @@ export interface ProviderAssignmentLifecycleResult {
251
230
  diagnostics?: Record<string, unknown> | null;
252
231
  leaseDiagnostics?: Record<string, unknown> | null;
253
232
  }
254
- export interface AgentModeRunUsageSettlement {
255
- capacityUsageActualId: string | null;
256
- capacityLedgerEntryId: string | null;
257
- activeSeconds: number | null;
258
- elapsedSeconds: number | null;
259
- actualUsd: number | null;
260
- nativeUsage: Record<string, unknown> | null;
261
- metadata: Record<string, unknown>;
262
- }
263
- export interface AgentModeRun {
264
- id: string;
265
- teamId: string;
266
- projectId: string;
267
- providerAssignmentId: string;
268
- capacityProviderId: string;
269
- executionProviderId: string | null;
270
- projectAgentClassId: string;
271
- agentId: string | null;
272
- handlerId: string | null;
273
- mode: AgentExecutionMode;
274
- executionMode?: AgentWorkExecutionMode;
275
- status: AgentModeRunStatus;
276
- selectedInput: Record<string, unknown>;
277
- capacityEnvelope: AgentCapacityEnvelope;
278
- outputs: Record<string, unknown>;
279
- traceRefs: Record<string, unknown>;
280
- usageActual: AgentModeRunUsageSettlement | Record<string, unknown>;
281
- validation: Record<string, unknown>;
282
- fallbackReason: string | null;
283
- startedAt: string | null;
284
- completedAt: string | null;
285
- failedAt: string | null;
286
- metadata: Record<string, unknown>;
287
- createdAt: string;
288
- updatedAt: string;
289
- }
@@ -1,3 +1,129 @@
1
+ import { z } from 'zod';
2
+ export declare const availabilityWindowSchema: z.ZodObject<{
3
+ startsAt: z.ZodString;
4
+ endsAt: z.ZodString;
5
+ }, "strict", z.ZodTypeAny, {
6
+ startsAt: string;
7
+ endsAt: string;
8
+ }, {
9
+ startsAt: string;
10
+ endsAt: string;
11
+ }>;
12
+ export declare const nativeLimitSchema: z.ZodObject<{
13
+ name: z.ZodString;
14
+ unit: z.ZodString;
15
+ maximum: z.ZodNumber;
16
+ }, "strict", z.ZodTypeAny, {
17
+ maximum: number;
18
+ name: string;
19
+ unit: string;
20
+ }, {
21
+ maximum: number;
22
+ name: string;
23
+ unit: string;
24
+ }>;
25
+ export declare const providerOfferSchema: z.ZodObject<{
26
+ schemaVersion: z.ZodLiteral<"treeseed.provider-offer/v1">;
27
+ id: z.ZodString;
28
+ providerId: z.ZodString;
29
+ revision: z.ZodNumber;
30
+ runtimeBuild: z.ZodString;
31
+ capabilities: z.ZodEffects<z.ZodArray<z.ZodString, "many">, string[], string[]>;
32
+ toolGroups: z.ZodEffects<z.ZodArray<z.ZodEnum<["discussion", "source.read", "source.write", "verification", "release"]>, "many">, ("discussion" | "source.read" | "source.write" | "verification" | "release")[], ("discussion" | "source.read" | "source.write" | "verification" | "release")[]>;
33
+ maximumConcurrency: z.ZodNumber;
34
+ availability: z.ZodArray<z.ZodObject<{
35
+ startsAt: z.ZodString;
36
+ endsAt: z.ZodString;
37
+ }, "strict", z.ZodTypeAny, {
38
+ startsAt: string;
39
+ endsAt: string;
40
+ }, {
41
+ startsAt: string;
42
+ endsAt: string;
43
+ }>, "many">;
44
+ nativeLimits: z.ZodArray<z.ZodObject<{
45
+ name: z.ZodString;
46
+ unit: z.ZodString;
47
+ maximum: z.ZodNumber;
48
+ }, "strict", z.ZodTypeAny, {
49
+ maximum: number;
50
+ name: string;
51
+ unit: string;
52
+ }, {
53
+ maximum: number;
54
+ name: string;
55
+ unit: string;
56
+ }>, "many">;
57
+ validFrom: z.ZodString;
58
+ validUntil: z.ZodOptional<z.ZodString>;
59
+ }, "strict", z.ZodTypeAny, {
60
+ id: string;
61
+ schemaVersion: "treeseed.provider-offer/v1";
62
+ revision: number;
63
+ capabilities: string[];
64
+ providerId: string;
65
+ runtimeBuild: string;
66
+ maximumConcurrency: number;
67
+ toolGroups: ("discussion" | "source.read" | "source.write" | "verification" | "release")[];
68
+ availability: {
69
+ startsAt: string;
70
+ endsAt: string;
71
+ }[];
72
+ nativeLimits: {
73
+ maximum: number;
74
+ name: string;
75
+ unit: string;
76
+ }[];
77
+ validFrom: string;
78
+ validUntil?: string | undefined;
79
+ }, {
80
+ id: string;
81
+ schemaVersion: "treeseed.provider-offer/v1";
82
+ revision: number;
83
+ capabilities: string[];
84
+ providerId: string;
85
+ runtimeBuild: string;
86
+ maximumConcurrency: number;
87
+ toolGroups: ("discussion" | "source.read" | "source.write" | "verification" | "release")[];
88
+ availability: {
89
+ startsAt: string;
90
+ endsAt: string;
91
+ }[];
92
+ nativeLimits: {
93
+ maximum: number;
94
+ name: string;
95
+ unit: string;
96
+ }[];
97
+ validFrom: string;
98
+ validUntil?: string | undefined;
99
+ }>;
100
+ export declare const providerStateSchema: z.ZodObject<{
101
+ schemaVersion: z.ZodLiteral<"treeseed.provider-state/v1">;
102
+ providerId: z.ZodString;
103
+ offerId: z.ZodString;
104
+ healthy: z.ZodBoolean;
105
+ activeAssignmentIds: z.ZodEffects<z.ZodArray<z.ZodString, "many">, string[], string[]>;
106
+ observedNativeUsage: z.ZodRecord<z.ZodString, z.ZodNumber>;
107
+ observedAt: z.ZodString;
108
+ }, "strict", z.ZodTypeAny, {
109
+ schemaVersion: "treeseed.provider-state/v1";
110
+ providerId: string;
111
+ observedAt: string;
112
+ offerId: string;
113
+ healthy: boolean;
114
+ activeAssignmentIds: string[];
115
+ observedNativeUsage: Record<string, number>;
116
+ }, {
117
+ schemaVersion: "treeseed.provider-state/v1";
118
+ providerId: string;
119
+ observedAt: string;
120
+ offerId: string;
121
+ healthy: boolean;
122
+ activeAssignmentIds: string[];
123
+ observedNativeUsage: Record<string, number>;
124
+ }>;
125
+ export type ProviderOffer = z.infer<typeof providerOfferSchema>;
126
+ export type ProviderState = z.infer<typeof providerStateSchema>;
1
127
  export declare const CAPACITY_SUPPLY_POLICY_CONTRACT: "treeseed.capacity-supply-policy/v1";
2
128
  export interface CapacitySupplyPolicy {
3
129
  contract: typeof CAPACITY_SUPPLY_POLICY_CONTRACT;
@@ -22,7 +148,6 @@ export interface CapacitySupplyCandidate {
22
148
  availableConcurrency: number;
23
149
  preferred?: boolean;
24
150
  estimatedCost?: number | null;
25
- minimumAssignmentDuration?: import('../../../../capacity-provider/contracts/governance.js').MinimumAssignmentDuration;
26
151
  }
27
152
  export interface CapacitySupplySelection {
28
153
  selected: CapacitySupplyCandidate | null;