@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,16 +1,22 @@
1
1
  import { z } from "zod";
2
+ import { conditionalFields, minimumProperties, uniqueArray } from "../../../../content/validation/schema-constraints.js";
2
3
  import { AGENT_WORK_EXECUTION_MODES } from "../../support/authority/execution-mode.js";
4
+ import { assignmentReferenceSchema, leaseSchema } from "../assignments/agent-execution.js";
5
+ import { agentClassSchema } from "../../../validation/agent-definition-schema.js";
3
6
  const identifier = z.string().trim().min(1).max(200).regex(/^[A-Za-z0-9][A-Za-z0-9._:/-]*$/u);
4
- const positiveWeights = z.record(z.number().positive());
7
+ const positiveWeights = z.record(z.number().finite().positive());
8
+ const weightMapSchema = minimumProperties(z.record(z.number().int().positive()), 1, "At least one integer weight is required.");
9
+ const projectWeightSchema = z.object({ projectId: leaseSchema.shape.id, weight: z.number().int().positive() }).strict();
10
+ const agentClassWeightSchema = z.object({ agentClass: agentClassSchema, weight: z.number().int().positive() }).strict();
5
11
  const workdayPolicySchema = z.object({
6
12
  durationSeconds: z.number().int().positive(),
7
13
  maximumConcurrency: z.number().int().positive(),
8
- planningPercent: z.number().min(0).max(100).default(20),
9
- allocationWeight: z.number().positive().default(1),
10
- planningTurnMaximumSeconds: z.number().int().positive().default(180),
14
+ planningPercent: z.number().min(0).max(100),
15
+ allocationWeight: z.number().finite().positive(),
16
+ planningTurnMaximumSeconds: z.number().int().positive(),
11
17
  communicationConcurrency: z.number().int().positive(),
12
- projectPercentages: positiveWeights.default({}),
13
- agentClassPercentages: z.record(positiveWeights).default({})
18
+ projectPercentages: positiveWeights,
19
+ agentClassPercentages: z.record(positiveWeights)
14
20
  }).strict();
15
21
  const workdayAllocationOverridesSchema = workdayPolicySchema.pick({
16
22
  planningPercent: true,
@@ -22,7 +28,12 @@ const workdayAllocationOverridesSchema = workdayPolicySchema.pick({
22
28
  const DEFAULT_WORKDAY_POLICY = Object.freeze(workdayPolicySchema.parse({
23
29
  durationSeconds: 28800,
24
30
  maximumConcurrency: 1,
25
- communicationConcurrency: 1
31
+ communicationConcurrency: 1,
32
+ planningPercent: 20,
33
+ allocationWeight: 1,
34
+ planningTurnMaximumSeconds: 180,
35
+ projectPercentages: {},
36
+ agentClassPercentages: {}
26
37
  }));
27
38
  const workdayProfileSchema = z.object({
28
39
  id: z.literal("default"),
@@ -30,11 +41,12 @@ const workdayProfileSchema = z.object({
30
41
  revision: z.number().int().positive(),
31
42
  policy: workdayPolicySchema
32
43
  }).strict();
33
- const appliedWorkdaySchema = z.object({
44
+ const appliedWorkdaySchema = conditionalFields(z.object({
34
45
  schemaVersion: z.literal("treeseed.workday/v1"),
35
46
  id: identifier,
36
47
  teamId: identifier,
37
48
  executionMode: z.enum(AGENT_WORK_EXECUTION_MODES),
49
+ reportingAgentId: identifier.optional(),
38
50
  policyId: identifier,
39
51
  policyRevision: z.number().int().positive(),
40
52
  policySnapshot: workdayPolicySchema,
@@ -44,7 +56,7 @@ const appliedWorkdaySchema = z.object({
44
56
  planningRounds: z.array(z.object({
45
57
  round: z.number().int().positive(),
46
58
  state: z.enum(["pending", "active", "complete"]),
47
- assignmentIds: z.array(identifier),
59
+ assignmentIds: uniqueArray(z.array(identifier)),
48
60
  startedAt: z.string().datetime({ offset: true }).optional(),
49
61
  completedAt: z.string().datetime({ offset: true }).optional()
50
62
  }).strict()),
@@ -52,16 +64,32 @@ const appliedWorkdaySchema = z.object({
52
64
  admittedSecondsByAgentClass: z.record(z.number().int().nonnegative()),
53
65
  activatedAt: z.string().datetime({ offset: true }).optional(),
54
66
  closingAt: z.string().datetime({ offset: true }).optional(),
55
- endedAt: z.string().datetime({ offset: true }).optional()
56
- }).strict();
67
+ endedAt: z.string().datetime({ offset: true }).optional(),
68
+ reportRef: assignmentReferenceSchema.options[1].optional()
69
+ }).strict(), [{
70
+ field: "state",
71
+ equals: "ended",
72
+ alternatives: [["reportRef"]],
73
+ path: ["reportRef"],
74
+ message: "An ended workday requires its exact TreeDX closeout report."
75
+ }]);
76
+ function weightedAmount(amount, weight, weights) {
77
+ const values = Object.values(weights), total = values.reduce((sum, value) => sum + value, 0) || 1;
78
+ const product = amount * weight;
79
+ if (amount === 0) return 0;
80
+ const minimumNormal = 2 ** -1022;
81
+ if (Number.isFinite(total) && Number.isFinite(product) && total >= minimumNormal && Math.abs(product) >= minimumNormal) return product / total;
82
+ const scale = Math.max(...values);
83
+ return amount * (weight / scale) / values.reduce((sum, value) => sum + value / scale, 0);
84
+ }
57
85
  function shareDebt(id, weights, actual) {
58
86
  const weight = weights[id] ?? 1;
59
- const totalWeight = Object.values(weights).reduce((sum, value) => sum + value, 0) || 1;
60
87
  const totalActual = [...actual.values()].reduce((sum, value) => sum + value, 0);
61
- return totalActual * weight / totalWeight - (actual.get(id) ?? 0);
88
+ return weightedAmount(totalActual, weight, weights) - (actual.get(id) ?? 0);
62
89
  }
63
90
  function selectFairReadyNode(nodes, usage, policy) {
64
91
  if (!nodes.length) return null;
92
+ for (const node of nodes) if (node.priority !== void 0 && !Number.isSafeInteger(node.priority)) throw new Error("execution_node_priority_invalid");
65
93
  const projectActual = /* @__PURE__ */ new Map();
66
94
  const classActual = /* @__PURE__ */ new Map();
67
95
  for (const entry of usage) {
@@ -75,11 +103,14 @@ function selectFairReadyNode(nodes, usage, policy) {
75
103
  const classWeights = Object.fromEntries([...new Set(projectNodes.map((node) => node.agentClass))].map((agentClass) => [agentClass, policy.agentClassPercentages[projectId]?.[agentClass] ?? 1]));
76
104
  const projectClassActual = new Map([...classActual].filter(([key]) => key.startsWith(`${projectId}:`)).map(([key, value]) => [key.slice(projectId.length + 1), value]));
77
105
  const classes = [...new Set(projectNodes.map((node) => node.agentClass))].sort((left, right) => shareDebt(right, classWeights, projectClassActual) - shareDebt(left, classWeights, projectClassActual) || left.localeCompare(right));
78
- const selected = projectNodes.filter((node) => node.agentClass === classes[0]).sort((left, right) => right.graphPriority - left.graphPriority || Date.parse(left.readyAt) - Date.parse(right.readyAt) || left.id.localeCompare(right.id))[0] ?? null;
79
- return selected ? { ...selected, explanation: {
80
- projectTargetPercent: 100 * projectWeights[projectId] / Object.values(projectWeights).reduce((sum, weight) => sum + weight, 0),
106
+ const selected = projectNodes.filter((node) => node.agentClass === classes[0]).sort((left, right) => (right.priority ?? 0) - (left.priority ?? 0) || Date.parse(left.readyAt) - Date.parse(right.readyAt) || left.id.localeCompare(right.id))[0] ?? null;
107
+ return selected ? { ...selected, input: structuredClone({
108
+ nodes: [...nodes].sort((left, right) => left.id.localeCompare(right.id)),
109
+ usage: [...usage].sort((left, right) => left.projectId.localeCompare(right.projectId) || left.agentClass.localeCompare(right.agentClass) || left.seconds - right.seconds)
110
+ }), explanation: {
111
+ projectTargetPercent: weightedAmount(100, projectWeights[projectId], projectWeights),
81
112
  projectDeficitSeconds: shareDebt(projectId, projectWeights, projectActual),
82
- classTargetPercent: 100 * classWeights[selected.agentClass] / Object.values(classWeights).reduce((sum, weight) => sum + weight, 0),
113
+ classTargetPercent: weightedAmount(100, classWeights[selected.agentClass], classWeights),
83
114
  classDeficitSeconds: shareDebt(selected.agentClass, classWeights, projectClassActual),
84
115
  readyNodeCount: nodes.length
85
116
  } } : null;
@@ -97,9 +128,9 @@ function compilePlanningRounds(workdayId, agentIds, planningTurnMaximumSeconds,
97
128
  function workdayPlanningEndsAt(plan) {
98
129
  return new Date(Date.parse(plan.startsAt) + plan.policySnapshot.durationSeconds * plan.policySnapshot.planningPercent * 10).toISOString();
99
130
  }
100
- function workdayPhase(plan, now) {
131
+ function workdayPhase(plan, now, actingReady) {
101
132
  if (Date.parse(now) >= Date.parse(plan.endsAt)) return "ended";
102
- return Date.parse(now) < Date.parse(workdayPlanningEndsAt(plan)) ? "planning" : "acting";
133
+ return Date.parse(now) < Date.parse(workdayPlanningEndsAt(plan)) || !actingReady ? "planning" : "acting";
103
134
  }
104
135
  function compileWorkday(input) {
105
136
  const policy = workdayPolicySchema.parse(input.policy);
@@ -110,6 +141,7 @@ function compileWorkday(input) {
110
141
  id: input.id,
111
142
  teamId: input.teamId,
112
143
  executionMode: input.executionMode,
144
+ ...input.reportingAgentId === void 0 ? {} : { reportingAgentId: input.reportingAgentId },
113
145
  policyId: input.policyId,
114
146
  policyRevision: input.policyRevision,
115
147
  policySnapshot: policy,
@@ -123,10 +155,13 @@ function compileWorkday(input) {
123
155
  }
124
156
  export {
125
157
  DEFAULT_WORKDAY_POLICY,
158
+ agentClassWeightSchema,
126
159
  appliedWorkdaySchema,
127
160
  compilePlanningRounds,
128
161
  compileWorkday,
162
+ projectWeightSchema,
129
163
  selectFairReadyNode,
164
+ weightMapSchema,
130
165
  workdayAllocationOverridesSchema,
131
166
  workdayPhase,
132
167
  workdayPlanningEndsAt,
@@ -1,10 +1,7 @@
1
1
  import type { AgentWorkExecutionMode } from '../../support/authority/execution-mode.js';
2
+ import { z } from 'zod';
2
3
  export type CapacityWorkdayRunStatus = 'queued' | 'running' | 'completed' | 'cancelled' | 'failed' | 'degraded';
3
4
  export type CapacityWorkdayEventStatus = 'recorded' | 'active' | 'completed' | 'warning' | 'error' | 'failed';
4
- export type CapacityWorkdayDemandSource = 'objective' | 'question' | 'proposal' | 'decision-review' | 'knowledge-gap' | 'release-readiness' | 'idle-intent' | 'planning-input' | 'capacity-plan' | 'assignment-completion' | 'assignment-blockage' | 'workday-summary' | 'handoff' | 'research-workflow';
5
- export type CapacityWorkdayDemandStatus = 'pending' | 'claimed' | 'admitted' | 'completed' | 'blocked' | 'cancelled' | 'superseded';
6
- export type CapacityWorkdayParticipationCycleStatus = 'open' | 'covered' | 'closed';
7
- export type CapacityWorkdayParticipationEntryStatus = 'pending' | 'assigned' | 'completed' | 'excluded' | 'blocked';
8
5
  export interface CapacityWorkdayRunRecord {
9
6
  id: string;
10
7
  teamId: string;
@@ -36,7 +33,6 @@ export interface CapacityWorkdayEventRecord {
36
33
  projectId: string | null;
37
34
  workdayId: string | null;
38
35
  assignmentId: string | null;
39
- modeRunId: string | null;
40
36
  eventIndex: number;
41
37
  eventType: string;
42
38
  status: CapacityWorkdayEventStatus;
@@ -59,7 +55,6 @@ export interface AgentActivityEvent {
59
55
  projectId: string | null;
60
56
  workdayId: string;
61
57
  assignmentId: string | null;
62
- modeRunId: string | null;
63
58
  executionRunId: string | null;
64
59
  agentId: string | null;
65
60
  agentClassId: string | null;
@@ -84,6 +79,10 @@ export interface AgentActivityEvent {
84
79
  }
85
80
  export interface ProviderRuntimeEventInput {
86
81
  id: string;
82
+ leaseToken?: string;
83
+ runnerId?: string;
84
+ sequence?: number;
85
+ protectedPayload?: Record<string, unknown>;
87
86
  eventType: `provider.${string}`;
88
87
  status: 'recorded' | 'active' | 'completed' | 'warning' | 'error' | 'failed';
89
88
  component: 'provider-manager' | 'provider-runner' | 'lease' | 'execution-provider' | 'recovery';
@@ -93,77 +92,224 @@ export interface ProviderRuntimeEventInput {
93
92
  refs?: Record<string, unknown>;
94
93
  metrics?: Record<string, unknown>;
95
94
  }
96
- export interface CapacityWorkdayScheduleRecord {
95
+ export declare const workdayScheduleSchema: z.ZodObject<{
96
+ id: z.ZodString;
97
+ teamId: z.ZodString;
98
+ status: z.ZodEnum<["active", "paused", "completed", "failed"]>;
99
+ purpose: z.ZodString;
100
+ cadenceSeconds: z.ZodNumber;
101
+ intent: z.ZodEffects<z.ZodEffects<z.ZodObject<{
102
+ schemaVersion: z.ZodLiteral<"treeseed.workday-intent/v1">;
103
+ teamId: z.ZodString;
104
+ profileId: z.ZodString;
105
+ projects: z.ZodEffects<z.ZodUnion<[z.ZodLiteral<"all">, z.ZodEffects<z.ZodArray<z.ZodString, "many">, string[], string[]>]>, any, any>;
106
+ executionMode: z.ZodOptional<z.ZodDefault<z.ZodEnum<["simulation", "production"]>>>;
107
+ startsAt: z.ZodString;
108
+ endsAt: z.ZodOptional<z.ZodString>;
109
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
110
+ planningOnly: z.ZodOptional<z.ZodBoolean>;
111
+ objectiveFilters: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
112
+ proposalIds: z.ZodOptional<z.ZodEffects<z.ZodArray<z.ZodString, "many">, string[], string[]>>;
113
+ decisionIds: z.ZodOptional<z.ZodEffects<z.ZodArray<z.ZodString, "many">, string[], string[]>>;
114
+ reportingAgentId: z.ZodOptional<z.ZodString>;
115
+ continueFromWorkdayId: z.ZodOptional<z.ZodString>;
116
+ allocation: z.ZodOptional<z.ZodObject<{
117
+ planningPercent: z.ZodOptional<z.ZodNumber>;
118
+ allocationWeight: z.ZodOptional<z.ZodNumber>;
119
+ planningTurnMaximumSeconds: z.ZodOptional<z.ZodNumber>;
120
+ projectPercentages: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
121
+ agentClassPercentages: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodNumber>>>;
122
+ }, "strict", z.ZodTypeAny, {
123
+ planningPercent?: number | undefined;
124
+ allocationWeight?: number | undefined;
125
+ planningTurnMaximumSeconds?: number | undefined;
126
+ projectPercentages?: Record<string, number> | undefined;
127
+ agentClassPercentages?: Record<string, Record<string, number>> | undefined;
128
+ }, {
129
+ planningPercent?: number | undefined;
130
+ allocationWeight?: number | undefined;
131
+ planningTurnMaximumSeconds?: number | undefined;
132
+ projectPercentages?: Record<string, number> | undefined;
133
+ agentClassPercentages?: Record<string, Record<string, number>> | undefined;
134
+ }>>;
135
+ agentSelection: z.ZodOptional<z.ZodEffects<z.ZodObject<{
136
+ agentSlugs: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
137
+ classIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
138
+ classSlugs: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
139
+ activityTypes: z.ZodOptional<z.ZodArray<z.ZodEnum<["planning", "estimating", "reviewing", "reporting", "chat"]>, "many">>;
140
+ mode: z.ZodOptional<z.ZodLiteral<"intersection">>;
141
+ }, "strict", z.ZodTypeAny, {
142
+ mode?: "intersection" | undefined;
143
+ classIds?: string[] | undefined;
144
+ classSlugs?: string[] | undefined;
145
+ agentSlugs?: string[] | undefined;
146
+ activityTypes?: ("planning" | "estimating" | "reviewing" | "reporting" | "chat")[] | undefined;
147
+ }, {
148
+ mode?: "intersection" | undefined;
149
+ classIds?: string[] | undefined;
150
+ classSlugs?: string[] | undefined;
151
+ agentSlugs?: string[] | undefined;
152
+ activityTypes?: ("planning" | "estimating" | "reviewing" | "reporting" | "chat")[] | undefined;
153
+ }>, {
154
+ [x: string]: any;
155
+ }, {
156
+ [x: string]: any;
157
+ }>>;
158
+ operatorConstraints: z.ZodOptional<z.ZodObject<{
159
+ providerIds: z.ZodOptional<z.ZodEffects<z.ZodArray<z.ZodString, "many">, string[], string[]>>;
160
+ maxConcurrency: z.ZodOptional<z.ZodNumber>;
161
+ }, "strict", z.ZodTypeAny, {
162
+ providerIds?: string[] | undefined;
163
+ maxConcurrency?: number | undefined;
164
+ }, {
165
+ providerIds?: string[] | undefined;
166
+ maxConcurrency?: number | undefined;
167
+ }>>;
168
+ }, "strict", z.ZodTypeAny, {
169
+ schemaVersion: "treeseed.workday-intent/v1";
170
+ teamId: string;
171
+ profileId: string;
172
+ startsAt: string;
173
+ durationSeconds?: number | undefined;
174
+ projects?: any;
175
+ executionMode?: "simulation" | "production" | undefined;
176
+ reportingAgentId?: string | undefined;
177
+ endsAt?: string | undefined;
178
+ planningOnly?: boolean | undefined;
179
+ objectiveFilters?: string[] | undefined;
180
+ proposalIds?: string[] | undefined;
181
+ decisionIds?: string[] | undefined;
182
+ continueFromWorkdayId?: string | undefined;
183
+ allocation?: {
184
+ planningPercent?: number | undefined;
185
+ allocationWeight?: number | undefined;
186
+ planningTurnMaximumSeconds?: number | undefined;
187
+ projectPercentages?: Record<string, number> | undefined;
188
+ agentClassPercentages?: Record<string, Record<string, number>> | undefined;
189
+ } | undefined;
190
+ agentSelection?: {
191
+ [x: string]: any;
192
+ } | undefined;
193
+ operatorConstraints?: {
194
+ providerIds?: string[] | undefined;
195
+ maxConcurrency?: number | undefined;
196
+ } | undefined;
197
+ }, {
198
+ schemaVersion: "treeseed.workday-intent/v1";
199
+ teamId: string;
200
+ profileId: string;
201
+ startsAt: string;
202
+ durationSeconds?: number | undefined;
203
+ projects?: any;
204
+ executionMode?: "simulation" | "production" | undefined;
205
+ reportingAgentId?: string | undefined;
206
+ endsAt?: string | undefined;
207
+ planningOnly?: boolean | undefined;
208
+ objectiveFilters?: string[] | undefined;
209
+ proposalIds?: string[] | undefined;
210
+ decisionIds?: string[] | undefined;
211
+ continueFromWorkdayId?: string | undefined;
212
+ allocation?: {
213
+ planningPercent?: number | undefined;
214
+ allocationWeight?: number | undefined;
215
+ planningTurnMaximumSeconds?: number | undefined;
216
+ projectPercentages?: Record<string, number> | undefined;
217
+ agentClassPercentages?: Record<string, Record<string, number>> | undefined;
218
+ } | undefined;
219
+ agentSelection?: {
220
+ [x: string]: any;
221
+ } | undefined;
222
+ operatorConstraints?: {
223
+ providerIds?: string[] | undefined;
224
+ maxConcurrency?: number | undefined;
225
+ } | undefined;
226
+ }>, {
227
+ schemaVersion: "treeseed.workday-intent/v1";
228
+ teamId: string;
229
+ profileId: string;
230
+ startsAt: string;
231
+ durationSeconds?: number | undefined;
232
+ projects?: any;
233
+ executionMode?: "simulation" | "production" | undefined;
234
+ reportingAgentId?: string | undefined;
235
+ endsAt?: string | undefined;
236
+ planningOnly?: boolean | undefined;
237
+ objectiveFilters?: string[] | undefined;
238
+ proposalIds?: string[] | undefined;
239
+ decisionIds?: string[] | undefined;
240
+ continueFromWorkdayId?: string | undefined;
241
+ allocation?: {
242
+ planningPercent?: number | undefined;
243
+ allocationWeight?: number | undefined;
244
+ planningTurnMaximumSeconds?: number | undefined;
245
+ projectPercentages?: Record<string, number> | undefined;
246
+ agentClassPercentages?: Record<string, Record<string, number>> | undefined;
247
+ } | undefined;
248
+ agentSelection?: {
249
+ [x: string]: any;
250
+ } | undefined;
251
+ operatorConstraints?: {
252
+ providerIds?: string[] | undefined;
253
+ maxConcurrency?: number | undefined;
254
+ } | undefined;
255
+ }, {
256
+ schemaVersion: "treeseed.workday-intent/v1";
257
+ teamId: string;
258
+ profileId: string;
259
+ startsAt: string;
260
+ durationSeconds?: number | undefined;
261
+ projects?: any;
262
+ executionMode?: "simulation" | "production" | undefined;
263
+ reportingAgentId?: string | undefined;
264
+ endsAt?: string | undefined;
265
+ planningOnly?: boolean | undefined;
266
+ objectiveFilters?: string[] | undefined;
267
+ proposalIds?: string[] | undefined;
268
+ decisionIds?: string[] | undefined;
269
+ continueFromWorkdayId?: string | undefined;
270
+ allocation?: {
271
+ planningPercent?: number | undefined;
272
+ allocationWeight?: number | undefined;
273
+ planningTurnMaximumSeconds?: number | undefined;
274
+ projectPercentages?: Record<string, number> | undefined;
275
+ agentClassPercentages?: Record<string, Record<string, number>> | undefined;
276
+ } | undefined;
277
+ agentSelection?: {
278
+ [x: string]: any;
279
+ } | undefined;
280
+ operatorConstraints?: {
281
+ providerIds?: string[] | undefined;
282
+ maxConcurrency?: number | undefined;
283
+ } | undefined;
284
+ }>, any, any>;
285
+ lastRunId: z.ZodNullable<z.ZodString>;
286
+ nextRunAt: z.ZodString;
287
+ stateVersion: z.ZodNumber;
288
+ createdAt: z.ZodString;
289
+ updatedAt: z.ZodString;
290
+ }, "strict", z.ZodTypeAny, {
291
+ status: "active" | "completed" | "failed" | "paused";
97
292
  id: string;
98
- teamId: string;
99
- status: 'active' | 'paused' | 'completed' | 'failed';
100
293
  purpose: string;
294
+ createdAt: string;
295
+ updatedAt: string;
296
+ teamId: string;
101
297
  cadenceSeconds: number;
102
- intent: import('../../../../operator-contracts/workday-lifecycle.js').WorkdayIntent;
103
298
  lastRunId: string | null;
104
299
  nextRunAt: string;
105
300
  stateVersion: number;
106
- createdAt: string;
107
- updatedAt: string;
108
- }
109
- export interface CapacityWorkdayDemandRecord {
110
- id: string;
111
- teamId: string;
112
- projectId: string;
113
- workdayRunId: string;
114
- workdayId: string;
115
- sourceType: CapacityWorkdayDemandSource;
116
- sourceId: string;
117
- mode: 'planning' | 'acting';
118
- executionMode?: AgentWorkExecutionMode;
119
- projectAgentClassId: string;
120
- agentId: string | null;
121
- handlerId: string;
122
- activityType: string;
123
- decisionId: string | null;
124
- capacityPlanId: string | null;
125
- status: CapacityWorkdayDemandStatus;
126
- priority: number;
127
- requestedSeconds: number;
128
- idempotencyKey: string;
129
- claimToken: string | null;
130
- assignmentId: string | null;
131
- payload: Record<string, unknown>;
132
- metadata: Record<string, unknown>;
133
- availableAt: string;
134
- claimedAt: string | null;
135
- admittedAt: string | null;
136
- completedAt: string | null;
137
- createdAt: string;
138
- updatedAt: string;
139
- }
140
- export interface CapacityWorkdayParticipationCycleRecord {
301
+ intent?: any;
302
+ }, {
303
+ status: "active" | "completed" | "failed" | "paused";
141
304
  id: string;
142
- teamId: string;
143
- projectId: string;
144
- workdayRunId: string;
145
- cycleNumber: number;
146
- status: CapacityWorkdayParticipationCycleStatus;
147
- openedAt: string;
148
- coveredAt: string | null;
149
- closedAt: string | null;
305
+ purpose: string;
150
306
  createdAt: string;
151
307
  updatedAt: string;
152
- }
153
- export interface CapacityWorkdayParticipationEntryRecord {
154
- id: string;
155
- cycleId: string;
156
308
  teamId: string;
157
- projectId: string;
158
- workdayRunId: string;
159
- agentId: string;
160
- projectAgentClassId: string;
161
- status: CapacityWorkdayParticipationEntryStatus;
162
- reasonCode: string | null;
163
- demandId: string | null;
164
- assignmentId: string | null;
165
- coveredAt: string | null;
166
- metadata: Record<string, unknown>;
167
- createdAt: string;
168
- updatedAt: string;
169
- }
309
+ cadenceSeconds: number;
310
+ lastRunId: string | null;
311
+ nextRunAt: string;
312
+ stateVersion: number;
313
+ intent?: any;
314
+ }>;
315
+ export type CapacityWorkdayScheduleRecord = z.infer<typeof workdayScheduleSchema>;
@@ -0,0 +1,19 @@
1
+ import { z } from "zod";
2
+ import { leaseSchema } from "../assignments/agent-execution.js";
3
+ import { workdayIntentSchema } from "../../../../operator-contracts/workday-lifecycle.js";
4
+ const workdayScheduleSchema = z.object({
5
+ id: leaseSchema.shape.id,
6
+ teamId: leaseSchema.shape.id,
7
+ status: z.enum(["active", "paused", "completed", "failed"]),
8
+ purpose: z.string(),
9
+ cadenceSeconds: z.number().int().min(60),
10
+ intent: workdayIntentSchema,
11
+ lastRunId: z.string().nullable(),
12
+ nextRunAt: leaseSchema.shape.acquiredAt,
13
+ stateVersion: z.number().int().positive(),
14
+ createdAt: leaseSchema.shape.acquiredAt,
15
+ updatedAt: leaseSchema.shape.acquiredAt
16
+ }).strict();
17
+ export {
18
+ workdayScheduleSchema
19
+ };
@@ -1,4 +1,4 @@
1
- export declare const CAPACITY_CONFIGURATION_FAMILIES: readonly ["provider-manifest", "provider-offer", "capacity-grant", "allocation-set", "project-agent-class", "activity-profile"];
1
+ export declare const CAPACITY_CONFIGURATION_FAMILIES: readonly ["provider-manifest", "provider-offer", "capacity-grant", "project-agent-class", "activity-profile"];
2
2
  export type CapacityConfigurationFamily = (typeof CAPACITY_CONFIGURATION_FAMILIES)[number];
3
3
  export interface CapacityConfigurationDescriptor {
4
4
  id: CapacityConfigurationFamily;
@@ -2,7 +2,6 @@ const CAPACITY_CONFIGURATION_FAMILIES = [
2
2
  "provider-manifest",
3
3
  "provider-offer",
4
4
  "capacity-grant",
5
- "allocation-set",
6
5
  "project-agent-class",
7
6
  "activity-profile"
8
7
  ];
@@ -10,7 +9,6 @@ const CAPACITY_CONFIGURATION_DESCRIPTORS = [
10
9
  { id: "provider-manifest", ownerPackage: "@treeseed/sdk", format: "yaml", schemaId: "treeseed.capacity-provider/v5", validator: "validateCapacityProviderManifestV5", runtimeOwner: "@treeseed/agent" },
11
10
  { id: "provider-offer", ownerPackage: "@treeseed/sdk", format: "yaml", schemaId: "treeseed.provider-supply-offer/v1", validator: "validateProviderSupplyOffer", runtimeOwner: "@treeseed/agent" },
12
11
  { id: "capacity-grant", ownerPackage: "@treeseed/sdk", format: "yaml", schemaId: "treeseed.capacity-grant/v2", validator: "validateCapacityGrantV2", runtimeOwner: "@treeseed/api" },
13
- { id: "allocation-set", ownerPackage: "@treeseed/sdk", format: "yaml", schemaId: "treeseed.capacity-allocation-set/v2", validator: "validateCapacityAllocationSetV2", runtimeOwner: "@treeseed/api" },
14
12
  { id: "project-agent-class", ownerPackage: "@treeseed/sdk", format: "yaml", schemaId: "treeseed.project-agent-class/v1", validator: "validateProjectAgentClassConfiguration", runtimeOwner: "@treeseed/api" },
15
13
  { id: "activity-profile", ownerPackage: "@treeseed/sdk", format: "mdx-frontmatter", schemaId: "treeseed.agent-activity-profiles/v1", validator: "validateAgentActivityProfilesConfiguration", runtimeOwner: "@treeseed/agent" }
16
14
  ];