@treeseed/sdk 0.13.0-rc.119 → 0.13.0-rc.120
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.treeseed-build-complete.json +1 -1
- package/dist/agent-capacity/allocation.d.ts +0 -3
- package/dist/agent-capacity/allocation.js +0 -221
- package/dist/agent-capacity/contracts/capacity/assignments/agent-execution.d.ts +280 -84
- package/dist/agent-capacity/contracts/capacity/assignments/agent-execution.js +22 -1
- package/dist/agent-capacity/contracts/capacity/assignments/assignment-records.d.ts +5 -0
- package/dist/agent-capacity/contracts/capacity/workdays/assignment-allocation.d.ts +82 -0
- package/dist/agent-capacity/contracts/capacity/workdays/assignment-allocation.js +115 -0
- package/dist/agent-capacity/contracts/capacity/workdays/capability-accounting.d.ts +142 -0
- package/dist/agent-capacity/contracts/capacity/workdays/capability-accounting.js +51 -0
- package/dist/agent-capacity/contracts/capacity/workdays/workday-allocation.d.ts +167 -35
- package/dist/agent-capacity/contracts/capacity/workdays/workday-allocation.js +59 -20
- package/dist/agent-capacity/contracts/capacity/workdays/workday-records.d.ts +2 -21
- package/dist/agent-capacity/contracts/support/execution-graph.d.ts +18 -18
- package/dist/agent-capacity/contracts/support/time-capacity.d.ts +0 -14
- package/dist/agent-capacity/contracts/support/time-capacity.js +1 -8
- package/dist/agent-capacity/validation/agent-definition-schema.d.ts +338 -338
- package/dist/capacity/agents/agent-capacity.d.ts +2 -0
- package/dist/capacity/agents/agent-capacity.js +2 -0
- package/dist/capacity-provider/client.d.ts +5 -3
- package/dist/capacity-provider/contracts/capacity-facts.d.ts +14 -0
- package/dist/capacity-provider/contracts/governance.d.ts +6 -0
- package/dist/capacity-provider/sandbox-contracts.d.ts +55 -1
- package/dist/capacity-provider/sandbox-contracts.js +4 -0
- package/dist/capacity-provider/source-workspace.d.ts +69 -37
- package/dist/capacity-provider/source-workspace.js +36 -5
- package/dist/content/validation/auxiliary-content-schemas.d.ts +10 -10
- package/dist/content/validation/content-model-schemas.d.ts +613 -613
- package/dist/content/validation/content-model-schemas.js +14 -2
- package/dist/content/validation/portable-content-data.d.ts +22 -22
- package/dist/deployment/postgres/requirements.d.ts +3 -2
- package/dist/deployment/postgres/requirements.js +3 -1
- package/dist/operator-contracts/canonical-command-tree.js +20 -6
- package/dist/operator-contracts/catalog/communication-operations.d.ts +2 -0
- package/dist/operator-contracts/catalog/workdays/profile-commands.js +4 -4
- package/dist/operator-contracts/catalog/workdays/profile-operations.d.ts +28 -3
- package/dist/operator-contracts/catalog/workdays/profile-operations.js +10 -8
- package/dist/operator-contracts/catalog/workdays/selection-commands.js +13 -0
- package/dist/operator-contracts/command-tree.d.ts +1 -1
- package/dist/operator-contracts/communication/contracts.d.ts +6 -0
- package/dist/operator-contracts/communication/contracts.js +2 -0
- package/dist/operator-contracts/control-plane-operations.d.ts +34 -3
- package/dist/operator-contracts/control-plane-operations.js +1 -0
- package/dist/operator-contracts/index.d.ts +0 -1
- package/dist/operator-contracts/index.js +0 -1
- package/dist/operator-contracts/workday-lifecycle.d.ts +8 -20
- package/dist/operator-contracts/workday-lifecycle.js +15 -5
- package/dist/secrets-capability/shared-resources.d.ts +6 -6
- package/package.json +1 -1
- package/dist/agent-capacity/policy/capacity/allocations/allocation-hierarchy.d.ts +0 -29
- package/dist/agent-capacity/policy/capacity/allocations/allocation-hierarchy.js +0 -110
- package/dist/operator-contracts/workday-profile.d.ts +0 -72
- package/dist/operator-contracts/workday-profile.js +0 -106
|
@@ -1,72 +1,178 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import { type AgentWorkExecutionMode } from '../../support/authority/execution-mode.js';
|
|
2
3
|
export declare const workdayPolicySchema: z.ZodObject<{
|
|
3
4
|
durationSeconds: z.ZodNumber;
|
|
4
5
|
maximumConcurrency: z.ZodNumber;
|
|
5
|
-
|
|
6
|
+
planningPercent: z.ZodDefault<z.ZodNumber>;
|
|
7
|
+
allocationWeight: z.ZodDefault<z.ZodNumber>;
|
|
8
|
+
planningTurnMaximumSeconds: z.ZodDefault<z.ZodNumber>;
|
|
6
9
|
communicationConcurrency: z.ZodNumber;
|
|
7
|
-
|
|
8
|
-
|
|
10
|
+
projectPercentages: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
11
|
+
agentClassPercentages: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodNumber>>>;
|
|
9
12
|
}, "strict", z.ZodTypeAny, {
|
|
13
|
+
planningPercent: number;
|
|
14
|
+
allocationWeight: number;
|
|
15
|
+
planningTurnMaximumSeconds: number;
|
|
16
|
+
projectPercentages: Record<string, number>;
|
|
17
|
+
agentClassPercentages: Record<string, Record<string, number>>;
|
|
10
18
|
durationSeconds: number;
|
|
11
19
|
maximumConcurrency: number;
|
|
12
|
-
planningSecondsPerAgent: number;
|
|
13
20
|
communicationConcurrency: number;
|
|
14
|
-
projectWeights: Record<string, number>;
|
|
15
|
-
agentClassWeights: Record<string, number>;
|
|
16
21
|
}, {
|
|
17
22
|
durationSeconds: number;
|
|
18
23
|
maximumConcurrency: number;
|
|
19
|
-
planningSecondsPerAgent: number;
|
|
20
24
|
communicationConcurrency: number;
|
|
21
|
-
|
|
22
|
-
|
|
25
|
+
planningPercent?: number | undefined;
|
|
26
|
+
allocationWeight?: number | undefined;
|
|
27
|
+
planningTurnMaximumSeconds?: number | undefined;
|
|
28
|
+
projectPercentages?: Record<string, number> | undefined;
|
|
29
|
+
agentClassPercentages?: Record<string, Record<string, number>> | undefined;
|
|
23
30
|
}>;
|
|
31
|
+
export declare const workdayAllocationOverridesSchema: z.ZodObject<{
|
|
32
|
+
planningPercent: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
|
|
33
|
+
allocationWeight: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
|
|
34
|
+
planningTurnMaximumSeconds: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
|
|
35
|
+
projectPercentages: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodNumber>>>;
|
|
36
|
+
agentClassPercentages: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodNumber>>>>;
|
|
37
|
+
}, "strict", z.ZodTypeAny, {
|
|
38
|
+
planningPercent?: number | undefined;
|
|
39
|
+
allocationWeight?: number | undefined;
|
|
40
|
+
planningTurnMaximumSeconds?: number | undefined;
|
|
41
|
+
projectPercentages?: Record<string, number> | undefined;
|
|
42
|
+
agentClassPercentages?: Record<string, Record<string, number>> | undefined;
|
|
43
|
+
}, {
|
|
44
|
+
planningPercent?: number | undefined;
|
|
45
|
+
allocationWeight?: number | undefined;
|
|
46
|
+
planningTurnMaximumSeconds?: number | undefined;
|
|
47
|
+
projectPercentages?: Record<string, number> | undefined;
|
|
48
|
+
agentClassPercentages?: Record<string, Record<string, number>> | undefined;
|
|
49
|
+
}>;
|
|
50
|
+
/** One canonical default; team-owned overrides use this same policy contract. */
|
|
51
|
+
export declare const DEFAULT_WORKDAY_POLICY: Readonly<{
|
|
52
|
+
planningPercent: number;
|
|
53
|
+
allocationWeight: number;
|
|
54
|
+
planningTurnMaximumSeconds: number;
|
|
55
|
+
projectPercentages: Record<string, number>;
|
|
56
|
+
agentClassPercentages: Record<string, Record<string, number>>;
|
|
57
|
+
durationSeconds: number;
|
|
58
|
+
maximumConcurrency: number;
|
|
59
|
+
communicationConcurrency: number;
|
|
60
|
+
}>;
|
|
61
|
+
export declare const workdayProfileSchema: z.ZodObject<{
|
|
62
|
+
id: z.ZodLiteral<"default">;
|
|
63
|
+
teamId: z.ZodString;
|
|
64
|
+
revision: z.ZodNumber;
|
|
65
|
+
policy: z.ZodObject<{
|
|
66
|
+
durationSeconds: z.ZodNumber;
|
|
67
|
+
maximumConcurrency: z.ZodNumber;
|
|
68
|
+
planningPercent: z.ZodDefault<z.ZodNumber>;
|
|
69
|
+
allocationWeight: z.ZodDefault<z.ZodNumber>;
|
|
70
|
+
planningTurnMaximumSeconds: z.ZodDefault<z.ZodNumber>;
|
|
71
|
+
communicationConcurrency: z.ZodNumber;
|
|
72
|
+
projectPercentages: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
73
|
+
agentClassPercentages: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodNumber>>>;
|
|
74
|
+
}, "strict", z.ZodTypeAny, {
|
|
75
|
+
planningPercent: number;
|
|
76
|
+
allocationWeight: number;
|
|
77
|
+
planningTurnMaximumSeconds: number;
|
|
78
|
+
projectPercentages: Record<string, number>;
|
|
79
|
+
agentClassPercentages: Record<string, Record<string, number>>;
|
|
80
|
+
durationSeconds: number;
|
|
81
|
+
maximumConcurrency: number;
|
|
82
|
+
communicationConcurrency: number;
|
|
83
|
+
}, {
|
|
84
|
+
durationSeconds: number;
|
|
85
|
+
maximumConcurrency: number;
|
|
86
|
+
communicationConcurrency: number;
|
|
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
|
+
}>;
|
|
93
|
+
}, "strict", z.ZodTypeAny, {
|
|
94
|
+
id: "default";
|
|
95
|
+
teamId: string;
|
|
96
|
+
revision: number;
|
|
97
|
+
policy: {
|
|
98
|
+
planningPercent: number;
|
|
99
|
+
allocationWeight: number;
|
|
100
|
+
planningTurnMaximumSeconds: number;
|
|
101
|
+
projectPercentages: Record<string, number>;
|
|
102
|
+
agentClassPercentages: Record<string, Record<string, number>>;
|
|
103
|
+
durationSeconds: number;
|
|
104
|
+
maximumConcurrency: number;
|
|
105
|
+
communicationConcurrency: number;
|
|
106
|
+
};
|
|
107
|
+
}, {
|
|
108
|
+
id: "default";
|
|
109
|
+
teamId: string;
|
|
110
|
+
revision: number;
|
|
111
|
+
policy: {
|
|
112
|
+
durationSeconds: number;
|
|
113
|
+
maximumConcurrency: number;
|
|
114
|
+
communicationConcurrency: number;
|
|
115
|
+
planningPercent?: number | undefined;
|
|
116
|
+
allocationWeight?: number | undefined;
|
|
117
|
+
planningTurnMaximumSeconds?: number | undefined;
|
|
118
|
+
projectPercentages?: Record<string, number> | undefined;
|
|
119
|
+
agentClassPercentages?: Record<string, Record<string, number>> | undefined;
|
|
120
|
+
};
|
|
121
|
+
}>;
|
|
122
|
+
export type WorkdayProfile = z.infer<typeof workdayProfileSchema>;
|
|
24
123
|
export declare const appliedWorkdaySchema: z.ZodObject<{
|
|
25
124
|
schemaVersion: z.ZodLiteral<"treeseed.workday/v1">;
|
|
26
125
|
id: z.ZodString;
|
|
27
126
|
teamId: z.ZodString;
|
|
127
|
+
executionMode: z.ZodEnum<["simulation", "production"]>;
|
|
28
128
|
policyId: z.ZodString;
|
|
29
129
|
policyRevision: z.ZodNumber;
|
|
30
130
|
policySnapshot: z.ZodObject<{
|
|
31
131
|
durationSeconds: z.ZodNumber;
|
|
32
132
|
maximumConcurrency: z.ZodNumber;
|
|
33
|
-
|
|
133
|
+
planningPercent: z.ZodDefault<z.ZodNumber>;
|
|
134
|
+
allocationWeight: z.ZodDefault<z.ZodNumber>;
|
|
135
|
+
planningTurnMaximumSeconds: z.ZodDefault<z.ZodNumber>;
|
|
34
136
|
communicationConcurrency: z.ZodNumber;
|
|
35
|
-
|
|
36
|
-
|
|
137
|
+
projectPercentages: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
138
|
+
agentClassPercentages: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodNumber>>>;
|
|
37
139
|
}, "strict", z.ZodTypeAny, {
|
|
140
|
+
planningPercent: number;
|
|
141
|
+
allocationWeight: number;
|
|
142
|
+
planningTurnMaximumSeconds: number;
|
|
143
|
+
projectPercentages: Record<string, number>;
|
|
144
|
+
agentClassPercentages: Record<string, Record<string, number>>;
|
|
38
145
|
durationSeconds: number;
|
|
39
146
|
maximumConcurrency: number;
|
|
40
|
-
planningSecondsPerAgent: number;
|
|
41
147
|
communicationConcurrency: number;
|
|
42
|
-
projectWeights: Record<string, number>;
|
|
43
|
-
agentClassWeights: Record<string, number>;
|
|
44
148
|
}, {
|
|
45
149
|
durationSeconds: number;
|
|
46
150
|
maximumConcurrency: number;
|
|
47
|
-
planningSecondsPerAgent: number;
|
|
48
151
|
communicationConcurrency: number;
|
|
49
|
-
|
|
50
|
-
|
|
152
|
+
planningPercent?: number | undefined;
|
|
153
|
+
allocationWeight?: number | undefined;
|
|
154
|
+
planningTurnMaximumSeconds?: number | undefined;
|
|
155
|
+
projectPercentages?: Record<string, number> | undefined;
|
|
156
|
+
agentClassPercentages?: Record<string, Record<string, number>> | undefined;
|
|
51
157
|
}>;
|
|
52
158
|
state: z.ZodEnum<["planned", "active", "closing", "ended"]>;
|
|
53
159
|
startsAt: z.ZodString;
|
|
54
160
|
endsAt: z.ZodString;
|
|
55
161
|
planningRounds: z.ZodArray<z.ZodObject<{
|
|
56
|
-
round: z.
|
|
162
|
+
round: z.ZodNumber;
|
|
57
163
|
state: z.ZodEnum<["pending", "active", "complete"]>;
|
|
58
164
|
assignmentIds: z.ZodArray<z.ZodString, "many">;
|
|
59
165
|
startedAt: z.ZodOptional<z.ZodString>;
|
|
60
166
|
completedAt: z.ZodOptional<z.ZodString>;
|
|
61
167
|
}, "strict", z.ZodTypeAny, {
|
|
62
168
|
state: "active" | "pending" | "complete";
|
|
63
|
-
round:
|
|
169
|
+
round: number;
|
|
64
170
|
assignmentIds: string[];
|
|
65
171
|
completedAt?: string | undefined;
|
|
66
172
|
startedAt?: string | undefined;
|
|
67
173
|
}, {
|
|
68
174
|
state: "active" | "pending" | "complete";
|
|
69
|
-
round:
|
|
175
|
+
round: number;
|
|
70
176
|
assignmentIds: string[];
|
|
71
177
|
completedAt?: string | undefined;
|
|
72
178
|
startedAt?: string | undefined;
|
|
@@ -81,21 +187,24 @@ export declare const appliedWorkdaySchema: z.ZodObject<{
|
|
|
81
187
|
state: "active" | "planned" | "closing" | "ended";
|
|
82
188
|
schemaVersion: "treeseed.workday/v1";
|
|
83
189
|
teamId: string;
|
|
190
|
+
executionMode: "production" | "simulation";
|
|
84
191
|
startsAt: string;
|
|
85
192
|
endsAt: string;
|
|
86
193
|
policyId: string;
|
|
87
194
|
policyRevision: number;
|
|
88
195
|
policySnapshot: {
|
|
196
|
+
planningPercent: number;
|
|
197
|
+
allocationWeight: number;
|
|
198
|
+
planningTurnMaximumSeconds: number;
|
|
199
|
+
projectPercentages: Record<string, number>;
|
|
200
|
+
agentClassPercentages: Record<string, Record<string, number>>;
|
|
89
201
|
durationSeconds: number;
|
|
90
202
|
maximumConcurrency: number;
|
|
91
|
-
planningSecondsPerAgent: number;
|
|
92
203
|
communicationConcurrency: number;
|
|
93
|
-
projectWeights: Record<string, number>;
|
|
94
|
-
agentClassWeights: Record<string, number>;
|
|
95
204
|
};
|
|
96
205
|
planningRounds: {
|
|
97
206
|
state: "active" | "pending" | "complete";
|
|
98
|
-
round:
|
|
207
|
+
round: number;
|
|
99
208
|
assignmentIds: string[];
|
|
100
209
|
completedAt?: string | undefined;
|
|
101
210
|
startedAt?: string | undefined;
|
|
@@ -110,6 +219,7 @@ export declare const appliedWorkdaySchema: z.ZodObject<{
|
|
|
110
219
|
state: "active" | "planned" | "closing" | "ended";
|
|
111
220
|
schemaVersion: "treeseed.workday/v1";
|
|
112
221
|
teamId: string;
|
|
222
|
+
executionMode: "production" | "simulation";
|
|
113
223
|
startsAt: string;
|
|
114
224
|
endsAt: string;
|
|
115
225
|
policyId: string;
|
|
@@ -117,14 +227,16 @@ export declare const appliedWorkdaySchema: z.ZodObject<{
|
|
|
117
227
|
policySnapshot: {
|
|
118
228
|
durationSeconds: number;
|
|
119
229
|
maximumConcurrency: number;
|
|
120
|
-
planningSecondsPerAgent: number;
|
|
121
230
|
communicationConcurrency: number;
|
|
122
|
-
|
|
123
|
-
|
|
231
|
+
planningPercent?: number | undefined;
|
|
232
|
+
allocationWeight?: number | undefined;
|
|
233
|
+
planningTurnMaximumSeconds?: number | undefined;
|
|
234
|
+
projectPercentages?: Record<string, number> | undefined;
|
|
235
|
+
agentClassPercentages?: Record<string, Record<string, number>> | undefined;
|
|
124
236
|
};
|
|
125
237
|
planningRounds: {
|
|
126
238
|
state: "active" | "pending" | "complete";
|
|
127
|
-
round:
|
|
239
|
+
round: number;
|
|
128
240
|
assignmentIds: string[];
|
|
129
241
|
completedAt?: string | undefined;
|
|
130
242
|
startedAt?: string | undefined;
|
|
@@ -148,43 +260,63 @@ export interface FairUsage {
|
|
|
148
260
|
seconds: number;
|
|
149
261
|
}
|
|
150
262
|
/** Select work only; provider selection is a later hard-gated admission step. */
|
|
151
|
-
export declare function selectFairReadyNode(nodes: FairReadyNode[], usage: FairUsage[], policy: z.infer<typeof workdayPolicySchema>):
|
|
152
|
-
|
|
263
|
+
export declare function selectFairReadyNode(nodes: FairReadyNode[], usage: FairUsage[], policy: z.infer<typeof workdayPolicySchema>): {
|
|
264
|
+
explanation: {
|
|
265
|
+
projectTargetPercent: number;
|
|
266
|
+
projectDeficitSeconds: number;
|
|
267
|
+
classTargetPercent: number;
|
|
268
|
+
classDeficitSeconds: number;
|
|
269
|
+
readyNodeCount: number;
|
|
270
|
+
};
|
|
271
|
+
id: string;
|
|
272
|
+
projectId: string;
|
|
273
|
+
agentClass: string;
|
|
274
|
+
graphPriority: number;
|
|
275
|
+
readyAt: string;
|
|
276
|
+
} | null;
|
|
277
|
+
export declare function compilePlanningRounds(workdayId: string, agentIds: string[], planningTurnMaximumSeconds: number, round?: number): {
|
|
153
278
|
id: string;
|
|
154
279
|
agentId: string;
|
|
155
280
|
round: number;
|
|
156
281
|
maximumSeconds: number;
|
|
157
282
|
dependsOn: string[];
|
|
158
283
|
}[];
|
|
284
|
+
export declare function workdayPlanningEndsAt(plan: Pick<AppliedWorkday, 'startsAt' | 'policySnapshot'>): string;
|
|
285
|
+
export declare function workdayPhase(plan: Pick<AppliedWorkday, 'startsAt' | 'endsAt' | 'policySnapshot'>, now: string): 'planning' | 'acting' | 'ended';
|
|
159
286
|
/** Shared by read-only plan and mutating start; callers persist this exact value. */
|
|
160
287
|
export declare function compileWorkday(input: {
|
|
161
288
|
id: string;
|
|
162
289
|
teamId: string;
|
|
163
290
|
policyId: string;
|
|
164
291
|
policyRevision: number;
|
|
292
|
+
executionMode: AgentWorkExecutionMode;
|
|
165
293
|
policy: z.input<typeof workdayPolicySchema>;
|
|
166
294
|
agentIds: string[];
|
|
167
295
|
startsAt: string;
|
|
296
|
+
activityTypes?: string[];
|
|
168
297
|
}): {
|
|
169
298
|
id: string;
|
|
170
299
|
state: "active" | "planned" | "closing" | "ended";
|
|
171
300
|
schemaVersion: "treeseed.workday/v1";
|
|
172
301
|
teamId: string;
|
|
302
|
+
executionMode: "production" | "simulation";
|
|
173
303
|
startsAt: string;
|
|
174
304
|
endsAt: string;
|
|
175
305
|
policyId: string;
|
|
176
306
|
policyRevision: number;
|
|
177
307
|
policySnapshot: {
|
|
308
|
+
planningPercent: number;
|
|
309
|
+
allocationWeight: number;
|
|
310
|
+
planningTurnMaximumSeconds: number;
|
|
311
|
+
projectPercentages: Record<string, number>;
|
|
312
|
+
agentClassPercentages: Record<string, Record<string, number>>;
|
|
178
313
|
durationSeconds: number;
|
|
179
314
|
maximumConcurrency: number;
|
|
180
|
-
planningSecondsPerAgent: number;
|
|
181
315
|
communicationConcurrency: number;
|
|
182
|
-
projectWeights: Record<string, number>;
|
|
183
|
-
agentClassWeights: Record<string, number>;
|
|
184
316
|
};
|
|
185
317
|
planningRounds: {
|
|
186
318
|
state: "active" | "pending" | "complete";
|
|
187
|
-
round:
|
|
319
|
+
round: number;
|
|
188
320
|
assignmentIds: string[];
|
|
189
321
|
completedAt?: string | undefined;
|
|
190
322
|
startedAt?: string | undefined;
|
|
@@ -1,18 +1,40 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { AGENT_WORK_EXECUTION_MODES } from "../../support/authority/execution-mode.js";
|
|
2
3
|
const identifier = z.string().trim().min(1).max(200).regex(/^[A-Za-z0-9][A-Za-z0-9._:/-]*$/u);
|
|
3
4
|
const positiveWeights = z.record(z.number().positive());
|
|
4
5
|
const workdayPolicySchema = z.object({
|
|
5
6
|
durationSeconds: z.number().int().positive(),
|
|
6
7
|
maximumConcurrency: z.number().int().positive(),
|
|
7
|
-
|
|
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),
|
|
8
11
|
communicationConcurrency: z.number().int().positive(),
|
|
9
|
-
|
|
10
|
-
|
|
12
|
+
projectPercentages: positiveWeights.default({}),
|
|
13
|
+
agentClassPercentages: z.record(positiveWeights).default({})
|
|
14
|
+
}).strict();
|
|
15
|
+
const workdayAllocationOverridesSchema = workdayPolicySchema.pick({
|
|
16
|
+
planningPercent: true,
|
|
17
|
+
allocationWeight: true,
|
|
18
|
+
planningTurnMaximumSeconds: true,
|
|
19
|
+
projectPercentages: true,
|
|
20
|
+
agentClassPercentages: true
|
|
21
|
+
}).partial();
|
|
22
|
+
const DEFAULT_WORKDAY_POLICY = Object.freeze(workdayPolicySchema.parse({
|
|
23
|
+
durationSeconds: 28800,
|
|
24
|
+
maximumConcurrency: 1,
|
|
25
|
+
communicationConcurrency: 1
|
|
26
|
+
}));
|
|
27
|
+
const workdayProfileSchema = z.object({
|
|
28
|
+
id: z.literal("default"),
|
|
29
|
+
teamId: identifier,
|
|
30
|
+
revision: z.number().int().positive(),
|
|
31
|
+
policy: workdayPolicySchema
|
|
11
32
|
}).strict();
|
|
12
33
|
const appliedWorkdaySchema = z.object({
|
|
13
34
|
schemaVersion: z.literal("treeseed.workday/v1"),
|
|
14
35
|
id: identifier,
|
|
15
36
|
teamId: identifier,
|
|
37
|
+
executionMode: z.enum(AGENT_WORK_EXECUTION_MODES),
|
|
16
38
|
policyId: identifier,
|
|
17
39
|
policyRevision: z.number().int().positive(),
|
|
18
40
|
policySnapshot: workdayPolicySchema,
|
|
@@ -20,12 +42,12 @@ const appliedWorkdaySchema = z.object({
|
|
|
20
42
|
startsAt: z.string().datetime({ offset: true }),
|
|
21
43
|
endsAt: z.string().datetime({ offset: true }),
|
|
22
44
|
planningRounds: z.array(z.object({
|
|
23
|
-
round: z.
|
|
45
|
+
round: z.number().int().positive(),
|
|
24
46
|
state: z.enum(["pending", "active", "complete"]),
|
|
25
47
|
assignmentIds: z.array(identifier),
|
|
26
48
|
startedAt: z.string().datetime({ offset: true }).optional(),
|
|
27
49
|
completedAt: z.string().datetime({ offset: true }).optional()
|
|
28
|
-
}).strict())
|
|
50
|
+
}).strict()),
|
|
29
51
|
admittedSecondsByProject: z.record(z.number().int().nonnegative()),
|
|
30
52
|
admittedSecondsByAgentClass: z.record(z.number().int().nonnegative()),
|
|
31
53
|
activatedAt: z.string().datetime({ offset: true }).optional(),
|
|
@@ -46,51 +68,68 @@ function selectFairReadyNode(nodes, usage, policy) {
|
|
|
46
68
|
projectActual.set(entry.projectId, (projectActual.get(entry.projectId) ?? 0) + entry.seconds);
|
|
47
69
|
classActual.set(`${entry.projectId}:${entry.agentClass}`, (classActual.get(`${entry.projectId}:${entry.agentClass}`) ?? 0) + entry.seconds);
|
|
48
70
|
}
|
|
49
|
-
const
|
|
71
|
+
const projectWeights = Object.fromEntries([...new Set(nodes.map((node) => node.projectId))].map((projectId2) => [projectId2, policy.projectPercentages[projectId2] ?? 1]));
|
|
72
|
+
const projects = Object.keys(projectWeights).sort((left, right) => shareDebt(right, projectWeights, projectActual) - shareDebt(left, projectWeights, projectActual) || left.localeCompare(right));
|
|
50
73
|
const projectId = projects[0];
|
|
51
74
|
const projectNodes = nodes.filter((node) => node.projectId === projectId);
|
|
52
|
-
const classWeights = Object.fromEntries([...new Set(projectNodes.map((node) => node.agentClass))].map((agentClass) => [agentClass, policy.
|
|
75
|
+
const classWeights = Object.fromEntries([...new Set(projectNodes.map((node) => node.agentClass))].map((agentClass) => [agentClass, policy.agentClassPercentages[projectId]?.[agentClass] ?? 1]));
|
|
53
76
|
const projectClassActual = new Map([...classActual].filter(([key]) => key.startsWith(`${projectId}:`)).map(([key, value]) => [key.slice(projectId.length + 1), value]));
|
|
54
77
|
const classes = [...new Set(projectNodes.map((node) => node.agentClass))].sort((left, right) => shareDebt(right, classWeights, projectClassActual) - shareDebt(left, classWeights, projectClassActual) || left.localeCompare(right));
|
|
55
|
-
|
|
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),
|
|
81
|
+
projectDeficitSeconds: shareDebt(projectId, projectWeights, projectActual),
|
|
82
|
+
classTargetPercent: 100 * classWeights[selected.agentClass] / Object.values(classWeights).reduce((sum, weight) => sum + weight, 0),
|
|
83
|
+
classDeficitSeconds: shareDebt(selected.agentClass, classWeights, projectClassActual),
|
|
84
|
+
readyNodeCount: nodes.length
|
|
85
|
+
} } : null;
|
|
56
86
|
}
|
|
57
|
-
function compilePlanningRounds(workdayId, agentIds,
|
|
87
|
+
function compilePlanningRounds(workdayId, agentIds, planningTurnMaximumSeconds, round = 1) {
|
|
58
88
|
const agents = [...new Set(agentIds)].sort();
|
|
59
|
-
return
|
|
89
|
+
return agents.map((agentId) => ({
|
|
60
90
|
id: `planning:${workdayId}:${round}:${agentId}`,
|
|
61
91
|
agentId,
|
|
62
92
|
round,
|
|
63
|
-
maximumSeconds:
|
|
64
|
-
dependsOn: round === 1 ? [] : agents.map((candidate) => `planning:${workdayId}
|
|
65
|
-
}))
|
|
93
|
+
maximumSeconds: planningTurnMaximumSeconds,
|
|
94
|
+
dependsOn: round === 1 ? [] : agents.map((candidate) => `planning:${workdayId}:${round - 1}:${candidate}`)
|
|
95
|
+
}));
|
|
96
|
+
}
|
|
97
|
+
function workdayPlanningEndsAt(plan) {
|
|
98
|
+
return new Date(Date.parse(plan.startsAt) + plan.policySnapshot.durationSeconds * plan.policySnapshot.planningPercent * 10).toISOString();
|
|
99
|
+
}
|
|
100
|
+
function workdayPhase(plan, now) {
|
|
101
|
+
if (Date.parse(now) >= Date.parse(plan.endsAt)) return "ended";
|
|
102
|
+
return Date.parse(now) < Date.parse(workdayPlanningEndsAt(plan)) ? "planning" : "acting";
|
|
66
103
|
}
|
|
67
104
|
function compileWorkday(input) {
|
|
68
105
|
const policy = workdayPolicySchema.parse(input.policy);
|
|
69
|
-
const assignments = compilePlanningRounds(input.id, input.agentIds, policy.
|
|
106
|
+
const assignments = policy.planningPercent > 0 ? compilePlanningRounds(input.id, input.agentIds, policy.planningTurnMaximumSeconds) : [];
|
|
70
107
|
const startsAt = new Date(input.startsAt).toISOString();
|
|
71
108
|
return appliedWorkdaySchema.parse({
|
|
72
109
|
schemaVersion: "treeseed.workday/v1",
|
|
73
110
|
id: input.id,
|
|
74
111
|
teamId: input.teamId,
|
|
112
|
+
executionMode: input.executionMode,
|
|
75
113
|
policyId: input.policyId,
|
|
76
114
|
policyRevision: input.policyRevision,
|
|
77
115
|
policySnapshot: policy,
|
|
78
116
|
state: "planned",
|
|
79
117
|
startsAt,
|
|
80
118
|
endsAt: new Date(Date.parse(startsAt) + policy.durationSeconds * 1e3).toISOString(),
|
|
81
|
-
planningRounds: [1,
|
|
82
|
-
round,
|
|
83
|
-
state: "pending",
|
|
84
|
-
assignmentIds: assignments.filter((assignment) => assignment.round === round).map((assignment) => assignment.id)
|
|
85
|
-
})),
|
|
119
|
+
planningRounds: assignments.length ? [{ round: 1, state: "pending", assignmentIds: assignments.map((assignment) => assignment.id) }] : [],
|
|
86
120
|
admittedSecondsByProject: {},
|
|
87
121
|
admittedSecondsByAgentClass: {}
|
|
88
122
|
});
|
|
89
123
|
}
|
|
90
124
|
export {
|
|
125
|
+
DEFAULT_WORKDAY_POLICY,
|
|
91
126
|
appliedWorkdaySchema,
|
|
92
127
|
compilePlanningRounds,
|
|
93
128
|
compileWorkday,
|
|
94
129
|
selectFairReadyNode,
|
|
95
|
-
|
|
130
|
+
workdayAllocationOverridesSchema,
|
|
131
|
+
workdayPhase,
|
|
132
|
+
workdayPlanningEndsAt,
|
|
133
|
+
workdayPolicySchema,
|
|
134
|
+
workdayProfileSchema
|
|
96
135
|
};
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/** Portable durable records shared by workday control-plane and operator consumers. */
|
|
2
|
-
import type { WorkdayAgentSelection } from '../../../workday.js';
|
|
3
1
|
import type { AgentWorkExecutionMode } from '../../support/authority/execution-mode.js';
|
|
4
2
|
export type CapacityWorkdayRunStatus = 'queued' | 'running' | 'completed' | 'cancelled' | 'failed' | 'degraded';
|
|
5
3
|
export type CapacityWorkdayEventStatus = 'recorded' | 'active' | 'completed' | 'warning' | 'error' | 'failed';
|
|
@@ -14,7 +12,7 @@ export interface CapacityWorkdayRunRecord {
|
|
|
14
12
|
scenarioId: string;
|
|
15
13
|
status: CapacityWorkdayRunStatus;
|
|
16
14
|
environment: string;
|
|
17
|
-
executionMode
|
|
15
|
+
executionMode: AgentWorkExecutionMode;
|
|
18
16
|
executionKind?: import('../communication/communication-records.js').CapacityExecutionKind;
|
|
19
17
|
triggerKind?: import('../communication/communication-records.js').CapacityTriggerKind;
|
|
20
18
|
hidden?: boolean;
|
|
@@ -98,27 +96,10 @@ export interface ProviderRuntimeEventInput {
|
|
|
98
96
|
export interface CapacityWorkdayScheduleRecord {
|
|
99
97
|
id: string;
|
|
100
98
|
teamId: string;
|
|
101
|
-
projectIds: string[];
|
|
102
99
|
status: 'active' | 'paused' | 'completed' | 'failed';
|
|
103
100
|
purpose: string;
|
|
104
|
-
capacityProviderId: string;
|
|
105
|
-
agentSelection: WorkdayAgentSelection;
|
|
106
101
|
cadenceSeconds: number;
|
|
107
|
-
|
|
108
|
-
maxActiveAssignments: number;
|
|
109
|
-
availableSeconds: number;
|
|
110
|
-
timePolicy: import('../../support/time-capacity.js').WorkdayTimePolicy;
|
|
111
|
-
planningOnly: boolean;
|
|
112
|
-
executionMode?: AgentWorkExecutionMode;
|
|
113
|
-
publicationPolicy: {
|
|
114
|
-
bookIds: string[];
|
|
115
|
-
target: 'staging' | 'production';
|
|
116
|
-
cohortMode: 'accepted';
|
|
117
|
-
requireTechnicalReview: boolean;
|
|
118
|
-
requireAudienceReview: boolean;
|
|
119
|
-
requireGraphReviewWhenStructural: boolean;
|
|
120
|
-
simulatedHumanApproval: boolean;
|
|
121
|
-
};
|
|
102
|
+
intent: import('../../../../operator-contracts/workday-lifecycle.js').WorkdayIntent;
|
|
122
103
|
lastRunId: string | null;
|
|
123
104
|
nextRunAt: string;
|
|
124
105
|
stateVersion: number;
|
|
@@ -277,26 +277,26 @@ export declare const executionNodeSchema: z.ZodEffects<z.ZodObject<{
|
|
|
277
277
|
requiredCapabilities: z.ZodOptional<z.ZodEffects<z.ZodArray<z.ZodString, "many">, string[], string[]>>;
|
|
278
278
|
requestedPermissions: z.ZodOptional<z.ZodObject<{
|
|
279
279
|
content: z.ZodObject<{
|
|
280
|
-
read: z.ZodEffects<z.ZodArray<z.ZodEnum<["agent", "book", "knowledge", "objective", "discussion", "discussion-message", "proposal", "question", "note", "decision"]>, "many">, ("agent" | "knowledge" | "
|
|
281
|
-
write: z.ZodEffects<z.ZodArray<z.ZodEnum<["agent", "book", "knowledge", "objective", "discussion", "discussion-message", "proposal", "question", "note", "decision"]>, "many">, ("agent" | "knowledge" | "
|
|
280
|
+
read: z.ZodEffects<z.ZodArray<z.ZodEnum<["agent", "book", "knowledge", "objective", "discussion", "discussion-message", "proposal", "question", "note", "decision"]>, "many">, ("agent" | "knowledge" | "proposal" | "decision" | "objective" | "question" | "discussion" | "note" | "book" | "discussion-message")[], ("agent" | "knowledge" | "proposal" | "decision" | "objective" | "question" | "discussion" | "note" | "book" | "discussion-message")[]>;
|
|
281
|
+
write: z.ZodEffects<z.ZodArray<z.ZodEnum<["agent", "book", "knowledge", "objective", "discussion", "discussion-message", "proposal", "question", "note", "decision"]>, "many">, ("agent" | "knowledge" | "proposal" | "decision" | "objective" | "question" | "discussion" | "note" | "book" | "discussion-message")[], ("agent" | "knowledge" | "proposal" | "decision" | "objective" | "question" | "discussion" | "note" | "book" | "discussion-message")[]>;
|
|
282
282
|
}, "strict", z.ZodTypeAny, {
|
|
283
|
-
read: ("agent" | "knowledge" | "
|
|
284
|
-
write: ("agent" | "knowledge" | "
|
|
283
|
+
read: ("agent" | "knowledge" | "proposal" | "decision" | "objective" | "question" | "discussion" | "note" | "book" | "discussion-message")[];
|
|
284
|
+
write: ("agent" | "knowledge" | "proposal" | "decision" | "objective" | "question" | "discussion" | "note" | "book" | "discussion-message")[];
|
|
285
285
|
}, {
|
|
286
|
-
read: ("agent" | "knowledge" | "
|
|
287
|
-
write: ("agent" | "knowledge" | "
|
|
286
|
+
read: ("agent" | "knowledge" | "proposal" | "decision" | "objective" | "question" | "discussion" | "note" | "book" | "discussion-message")[];
|
|
287
|
+
write: ("agent" | "knowledge" | "proposal" | "decision" | "objective" | "question" | "discussion" | "note" | "book" | "discussion-message")[];
|
|
288
288
|
}>;
|
|
289
289
|
tools: z.ZodEffects<z.ZodArray<z.ZodEnum<["discussion", "source.read", "source.write", "verification", "release"]>, "many">, ("release" | "verification" | "discussion" | "source.read" | "source.write")[], ("release" | "verification" | "discussion" | "source.read" | "source.write")[]>;
|
|
290
290
|
}, "strict", z.ZodTypeAny, {
|
|
291
291
|
content: {
|
|
292
|
-
read: ("agent" | "knowledge" | "
|
|
293
|
-
write: ("agent" | "knowledge" | "
|
|
292
|
+
read: ("agent" | "knowledge" | "proposal" | "decision" | "objective" | "question" | "discussion" | "note" | "book" | "discussion-message")[];
|
|
293
|
+
write: ("agent" | "knowledge" | "proposal" | "decision" | "objective" | "question" | "discussion" | "note" | "book" | "discussion-message")[];
|
|
294
294
|
};
|
|
295
295
|
tools: ("release" | "verification" | "discussion" | "source.read" | "source.write")[];
|
|
296
296
|
}, {
|
|
297
297
|
content: {
|
|
298
|
-
read: ("agent" | "knowledge" | "
|
|
299
|
-
write: ("agent" | "knowledge" | "
|
|
298
|
+
read: ("agent" | "knowledge" | "proposal" | "decision" | "objective" | "question" | "discussion" | "note" | "book" | "discussion-message")[];
|
|
299
|
+
write: ("agent" | "knowledge" | "proposal" | "decision" | "objective" | "question" | "discussion" | "note" | "book" | "discussion-message")[];
|
|
300
300
|
};
|
|
301
301
|
tools: ("release" | "verification" | "discussion" | "source.read" | "source.write")[];
|
|
302
302
|
}>>;
|
|
@@ -481,8 +481,8 @@ export declare const executionNodeSchema: z.ZodEffects<z.ZodObject<{
|
|
|
481
481
|
} | undefined;
|
|
482
482
|
requestedPermissions?: {
|
|
483
483
|
content: {
|
|
484
|
-
read: ("agent" | "knowledge" | "
|
|
485
|
-
write: ("agent" | "knowledge" | "
|
|
484
|
+
read: ("agent" | "knowledge" | "proposal" | "decision" | "objective" | "question" | "discussion" | "note" | "book" | "discussion-message")[];
|
|
485
|
+
write: ("agent" | "knowledge" | "proposal" | "decision" | "objective" | "question" | "discussion" | "note" | "book" | "discussion-message")[];
|
|
486
486
|
};
|
|
487
487
|
tools: ("release" | "verification" | "discussion" | "source.read" | "source.write")[];
|
|
488
488
|
} | undefined;
|
|
@@ -559,8 +559,8 @@ export declare const executionNodeSchema: z.ZodEffects<z.ZodObject<{
|
|
|
559
559
|
} | undefined;
|
|
560
560
|
requestedPermissions?: {
|
|
561
561
|
content: {
|
|
562
|
-
read: ("agent" | "knowledge" | "
|
|
563
|
-
write: ("agent" | "knowledge" | "
|
|
562
|
+
read: ("agent" | "knowledge" | "proposal" | "decision" | "objective" | "question" | "discussion" | "note" | "book" | "discussion-message")[];
|
|
563
|
+
write: ("agent" | "knowledge" | "proposal" | "decision" | "objective" | "question" | "discussion" | "note" | "book" | "discussion-message")[];
|
|
564
564
|
};
|
|
565
565
|
tools: ("release" | "verification" | "discussion" | "source.read" | "source.write")[];
|
|
566
566
|
} | undefined;
|
|
@@ -637,8 +637,8 @@ export declare const executionNodeSchema: z.ZodEffects<z.ZodObject<{
|
|
|
637
637
|
} | undefined;
|
|
638
638
|
requestedPermissions?: {
|
|
639
639
|
content: {
|
|
640
|
-
read: ("agent" | "knowledge" | "
|
|
641
|
-
write: ("agent" | "knowledge" | "
|
|
640
|
+
read: ("agent" | "knowledge" | "proposal" | "decision" | "objective" | "question" | "discussion" | "note" | "book" | "discussion-message")[];
|
|
641
|
+
write: ("agent" | "knowledge" | "proposal" | "decision" | "objective" | "question" | "discussion" | "note" | "book" | "discussion-message")[];
|
|
642
642
|
};
|
|
643
643
|
tools: ("release" | "verification" | "discussion" | "source.read" | "source.write")[];
|
|
644
644
|
} | undefined;
|
|
@@ -715,8 +715,8 @@ export declare const executionNodeSchema: z.ZodEffects<z.ZodObject<{
|
|
|
715
715
|
} | undefined;
|
|
716
716
|
requestedPermissions?: {
|
|
717
717
|
content: {
|
|
718
|
-
read: ("agent" | "knowledge" | "
|
|
719
|
-
write: ("agent" | "knowledge" | "
|
|
718
|
+
read: ("agent" | "knowledge" | "proposal" | "decision" | "objective" | "question" | "discussion" | "note" | "book" | "discussion-message")[];
|
|
719
|
+
write: ("agent" | "knowledge" | "proposal" | "decision" | "objective" | "question" | "discussion" | "note" | "book" | "discussion-message")[];
|
|
720
720
|
};
|
|
721
721
|
tools: ("release" | "verification" | "discussion" | "source.read" | "source.write")[];
|
|
722
722
|
} | undefined;
|
|
@@ -146,18 +146,4 @@ export interface AssignmentPerformanceSummary {
|
|
|
146
146
|
};
|
|
147
147
|
downstreamOutcomes: AssignmentDownstreamOutcome[];
|
|
148
148
|
}
|
|
149
|
-
export interface WorkdayTimePolicy {
|
|
150
|
-
cooperativePlanningPercent: number;
|
|
151
|
-
governedExecutionPercent: number;
|
|
152
|
-
reservePercent: number;
|
|
153
|
-
}
|
|
154
|
-
export declare function validateWorkdayTimePolicy(policy: WorkdayTimePolicy): {
|
|
155
|
-
ok: boolean;
|
|
156
|
-
diagnostics: Array<{
|
|
157
|
-
code: string;
|
|
158
|
-
path: string;
|
|
159
|
-
message: string;
|
|
160
|
-
}>;
|
|
161
|
-
value?: WorkdayTimePolicy;
|
|
162
|
-
};
|
|
163
149
|
export declare function emptyCapacityBudget(deadline: string, requestedSeconds: number): CapacityBudgetV2;
|
|
@@ -38,12 +38,6 @@ const ASSIGNMENT_TERMINAL_DISPOSITIONS = [
|
|
|
38
38
|
"failed"
|
|
39
39
|
];
|
|
40
40
|
const ASSIGNMENT_PERFORMANCE_SCHEMA = "treeseed.assignment-performance/v2";
|
|
41
|
-
function validateWorkdayTimePolicy(policy) {
|
|
42
|
-
const values = [policy.cooperativePlanningPercent, policy.governedExecutionPercent, policy.reservePercent];
|
|
43
|
-
if (values.some((value) => !Number.isFinite(value) || value < 0 || value > 100)) return { ok: false, diagnostics: [{ code: "workday_time_percent_invalid", path: "timePolicy", message: "Workday time percentages must be finite values from 0 through 100." }] };
|
|
44
|
-
if (Math.abs(values.reduce((sum, value) => sum + value, 0) - 100) >= 1e-6) return { ok: false, diagnostics: [{ code: "workday_time_total_invalid", path: "timePolicy", message: "Workday time percentages must total exactly 100%." }] };
|
|
45
|
-
return { ok: true, diagnostics: [], value: policy };
|
|
46
|
-
}
|
|
47
41
|
function emptyCapacityBudget(deadline, requestedSeconds) {
|
|
48
42
|
return {
|
|
49
43
|
schemaVersion: CAPACITY_BUDGET_SCHEMA,
|
|
@@ -58,6 +52,5 @@ export {
|
|
|
58
52
|
ASSIGNMENT_TERMINAL_DISPOSITIONS,
|
|
59
53
|
CAPACITY_BUDGET_SCHEMA,
|
|
60
54
|
assignmentTimeWindow,
|
|
61
|
-
emptyCapacityBudget
|
|
62
|
-
validateWorkdayTimePolicy
|
|
55
|
+
emptyCapacityBudget
|
|
63
56
|
};
|