@treeseed/sdk 0.13.0-rc.127 → 0.13.0-rc.129

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.
@@ -76,32 +76,13 @@ const proposalLinks = {
76
76
  decision_dependencies: z.array(z.object({ projectId: nonEmpty, decisionId: nonEmpty }).strict()).optional(),
77
77
  ...linked
78
78
  };
79
- const executionPlanWorkItemSchema = conditionalFields(z.object({
80
- id: slug,
81
- priority: z.number().int().safe().optional(),
82
- activity: z.literal("acting"),
83
- agentClass,
84
- workspace: z.enum(["read-only", "treedx", "git"]),
85
- review: z.enum(["required", "none"]),
86
- objective: nonEmpty,
87
- estimate: estimateSchema.optional(),
88
- reviewEstimate: estimateSchema.optional(),
89
- maximumReviewCycles: z.number().int().positive().optional(),
90
- dependsOn: unique(z.array(slug)),
91
- requestedPermissions: permissionSetSchema,
92
- requiredCapabilities: unique(z.array(identifier)).optional(),
93
- contextRefs: unique(exactRefs).optional(),
94
- acceptanceCriteria: z.array(nonEmpty).min(1)
95
- }).strict(), [
96
- { field: "review", equals: "required", alternatives: [["maximumReviewCycles"]], message: "Required review needs a maximum cycle count." },
97
- { field: "review", equals: "none", forbidden: { fields: ["reviewEstimate", "maximumReviewCycles"] }, message: "Unreviewed work cannot define review estimates or cycles." }
98
- ]).superRefine((value, context) => {
79
+ function validateWorkItemWorkspace(value, context) {
99
80
  if (value.workspace !== "read-only") {
100
81
  const mutable = (value.contextRefs ?? []).filter((reference) => reference.store === value.workspace && reference.model === "repository");
101
82
  if (mutable.length !== 1) context.addIssue({ code: z.ZodIssueCode.custom, path: ["contextRefs"], message: `${value.workspace} work requires exactly one exact ${value.workspace} workspace reference.` });
102
83
  }
103
- });
104
- const executionPlanSchema = z.object({ workItems: z.array(executionPlanWorkItemSchema).min(1) }).strict().superRefine((value, context) => {
84
+ }
85
+ function validateWorkItemDependencies(value, context) {
105
86
  const ids = new Set(value.workItems.map((item) => item.id));
106
87
  if (ids.size !== value.workItems.length) context.addIssue({ code: z.ZodIssueCode.custom, message: "Work-item IDs must be unique." });
107
88
  for (const [index, item] of value.workItems.entries()) for (const dependency of item.dependsOn) {
@@ -120,7 +101,28 @@ const executionPlanSchema = z.object({ workItems: z.array(executionPlanWorkItemS
120
101
  return false;
121
102
  };
122
103
  if ([...ids].some(cyclic)) context.addIssue({ code: z.ZodIssueCode.custom, path: ["workItems"], message: "Work-item dependencies must be acyclic." });
123
- });
104
+ }
105
+ const executionPlanWorkItemSchema = conditionalFields(z.object({
106
+ id: slug,
107
+ priority: z.number().int().safe().optional(),
108
+ activity: z.literal("acting"),
109
+ agentClass,
110
+ workspace: z.enum(["read-only", "treedx", "git"]),
111
+ review: z.enum(["required", "none"]),
112
+ objective: nonEmpty,
113
+ estimate: estimateSchema.optional(),
114
+ reviewEstimate: estimateSchema.optional(),
115
+ maximumReviewCycles: z.number().int().positive().optional(),
116
+ dependsOn: unique(z.array(slug)),
117
+ requestedPermissions: permissionSetSchema,
118
+ requiredCapabilities: unique(z.array(identifier)).optional(),
119
+ contextRefs: unique(exactRefs).optional(),
120
+ acceptanceCriteria: z.array(nonEmpty).min(1)
121
+ }).strict(), [
122
+ { field: "review", equals: "required", alternatives: [["maximumReviewCycles"]], message: "Required review needs a maximum cycle count." },
123
+ { field: "review", equals: "none", forbidden: { fields: ["reviewEstimate", "maximumReviewCycles"] }, message: "Unreviewed work cannot define review estimates or cycles." }
124
+ ]).superRefine(validateWorkItemWorkspace);
125
+ const executionPlanSchema = z.object({ workItems: z.array(executionPlanWorkItemSchema).min(1) }).strict().superRefine(validateWorkItemDependencies);
124
126
  const proposalSchema = conditionalFields(z.object({
125
127
  schemaVersion: z.literal("treeseed.proposal/v1"),
126
128
  id: identifier,
@@ -146,6 +148,46 @@ const proposalSchema = conditionalFields(z.object({
146
148
  },
147
149
  message: "Ready proposals require a summary, an execution plan, and each required independent estimate."
148
150
  }]);
151
+ const estimateAssignmentRefSchema = exactEntityReferenceSchema.innerType().pick({ store: true, model: true, id: true, revision: true }).extend({
152
+ store: z.literal("postgresql"),
153
+ model: z.literal("assignment-attempt"),
154
+ revision: z.number().int().positive()
155
+ }).strict();
156
+ const contributionEstimateSchema = estimateSchema.innerType().extend({ rationale: nonEmpty }).refine(
157
+ (value) => estimateSchema.safeParse(value).success,
158
+ { message: "Contribution estimates must satisfy the shared bounded estimate contract." }
159
+ );
160
+ const contributionWorkItemSchema = conditionalFields(executionPlanWorkItemSchema.innerType().innerType().omit({ agentClass: true }).extend({
161
+ estimateRef: estimateAssignmentRefSchema,
162
+ estimate: contributionEstimateSchema,
163
+ reviewEstimate: contributionEstimateSchema.optional()
164
+ }), [
165
+ {
166
+ field: "review",
167
+ equals: "required",
168
+ alternatives: [["maximumReviewCycles", "reviewEstimate"]],
169
+ message: "Reviewed contributions require bounded cycles and their author\u2019s own review estimate."
170
+ },
171
+ {
172
+ field: "review",
173
+ equals: "none",
174
+ forbidden: { fields: ["reviewEstimate", "maximumReviewCycles"] },
175
+ message: "Unreviewed work cannot define review estimates or cycles."
176
+ }
177
+ ]).superRefine(validateWorkItemWorkspace);
178
+ const contributionExecutionPlanSchema = executionPlanSchema.innerType().extend({
179
+ workItems: z.array(contributionWorkItemSchema).min(1)
180
+ }).superRefine(validateWorkItemDependencies);
181
+ const contributionProposalSchema = conditionalFields(proposalSchema.innerType().extend({
182
+ schemaVersion: z.literal("treeseed.proposal/v2"),
183
+ groupIds: unique(z.array(identifier).min(1)),
184
+ executionPlan: contributionExecutionPlanSchema.optional()
185
+ }), [{
186
+ field: "status",
187
+ in: ["ready", "decided"],
188
+ alternatives: [["summary", "executionPlan"]],
189
+ message: "Ready proposals require the contribution plan from every subscribed participant."
190
+ }]);
149
191
  const schemas = {
150
192
  page: z.object({
151
193
  title: nonEmpty,
@@ -201,7 +243,7 @@ const schemas = {
201
243
  status: z.enum(["active", "achieved", "abandoned"]),
202
244
  evidenceRefs: unique(exactRefs).optional()
203
245
  }).strict(),
204
- proposal: proposalSchema,
246
+ proposal: z.union([contributionProposalSchema, proposalSchema]),
205
247
  decision: conditionalFields(z.object({
206
248
  schemaVersion: z.literal("treeseed.decision/v1"),
207
249
  id: identifier,
@@ -395,8 +437,11 @@ function validateContentFrontmatter(model, value) {
395
437
  }))
396
438
  };
397
439
  }
398
- function describeContentFrontmatterSchema(model) {
399
- return schemas[model];
440
+ function describeContentFrontmatterSchema(model, schemaVersion) {
441
+ if (model !== "proposal") return schemas[model];
442
+ if (schemaVersion === "treeseed.proposal/v1") return proposalSchema;
443
+ if (schemaVersion !== void 0 && schemaVersion !== "treeseed.proposal/v2") throw new Error("proposal_schema_version_unsupported");
444
+ return contributionProposalSchema;
400
445
  }
401
446
  function fieldContract(schema) {
402
447
  let current = schema;
@@ -432,8 +477,8 @@ function fieldContract(schema) {
432
477
  };
433
478
  return { ...contract, type: current._def.typeName ?? "unknown" };
434
479
  }
435
- function describeContentFrontmatterContract(model) {
436
- const selected = schemas[model];
480
+ function describeContentFrontmatterContract(model, schemaVersion) {
481
+ const selected = describeContentFrontmatterSchema(model, schemaVersion);
437
482
  const schema = selected instanceof z.ZodEffects ? selected.innerType() : selected;
438
483
  if (!(schema instanceof z.ZodObject)) throw new Error(`Content model ${model} is not an object schema.`);
439
484
  return {
@@ -461,8 +506,8 @@ function contractJsonSchema(contract) {
461
506
  if (type === "date") return { type: "string", format: "date-time" };
462
507
  return Object.fromEntries(Object.entries(contract).filter(([name]) => !["required", "fields", "items"].includes(name)));
463
508
  }
464
- function describeContentFrontmatterJsonSchema(model) {
465
- const contract = describeContentFrontmatterContract(model);
509
+ function describeContentFrontmatterJsonSchema(model, schemaVersion) {
510
+ const contract = describeContentFrontmatterContract(model, schemaVersion);
466
511
  return contractJsonSchema({ required: true, type: "object", fields: contract.fields });
467
512
  }
468
513
  export {
@@ -523,6 +523,108 @@ export declare function validatePortableContentData(model: string, value: unknow
523
523
  maximumReviewCycles?: number | undefined;
524
524
  }[];
525
525
  } | undefined;
526
+ } | {
527
+ status: "ready" | "draft" | "discussing" | "decided" | "withdrawn";
528
+ id: string;
529
+ schemaVersion: "treeseed.proposal/v2";
530
+ title: string;
531
+ groupIds: string[];
532
+ request: string;
533
+ projectId: string;
534
+ summary?: string | undefined;
535
+ evidenceRefs?: {
536
+ id: string;
537
+ model: string;
538
+ store: "url" | "treedx" | "git" | "postgresql";
539
+ path?: string | undefined;
540
+ anchor?: string | undefined;
541
+ url?: string | undefined;
542
+ commit?: string | undefined;
543
+ repository?: string | undefined;
544
+ revision?: number | undefined;
545
+ digest?: string | undefined;
546
+ startLine?: number | undefined;
547
+ endLine?: number | undefined;
548
+ }[] | undefined;
549
+ objectiveRefs?: {
550
+ id: string;
551
+ model: string;
552
+ store: "url" | "treedx" | "git" | "postgresql";
553
+ path?: string | undefined;
554
+ anchor?: string | undefined;
555
+ url?: string | undefined;
556
+ commit?: string | undefined;
557
+ repository?: string | undefined;
558
+ revision?: number | undefined;
559
+ digest?: string | undefined;
560
+ startLine?: number | undefined;
561
+ endLine?: number | undefined;
562
+ }[] | undefined;
563
+ discussionRef?: {
564
+ id: string;
565
+ model: string;
566
+ store: "url" | "treedx" | "git" | "postgresql";
567
+ path?: string | undefined;
568
+ anchor?: string | undefined;
569
+ url?: string | undefined;
570
+ commit?: string | undefined;
571
+ repository?: string | undefined;
572
+ revision?: number | undefined;
573
+ digest?: string | undefined;
574
+ startLine?: number | undefined;
575
+ endLine?: number | undefined;
576
+ } | undefined;
577
+ executionPlan?: {
578
+ workItems: {
579
+ id: string;
580
+ objective: string;
581
+ estimate: {
582
+ expectedSeconds: number;
583
+ maximumSeconds: number;
584
+ rationale: string;
585
+ };
586
+ review: "none" | "required";
587
+ dependsOn: string[];
588
+ activity: "acting";
589
+ acceptanceCriteria: string[];
590
+ workspace: "read-only" | "treedx" | "git";
591
+ requestedPermissions: {
592
+ content: {
593
+ read: ("agent" | "note" | "question" | "proposal" | "decision" | "book" | "knowledge" | "objective" | "discussion" | "discussion-message")[];
594
+ write: ("agent" | "note" | "question" | "proposal" | "decision" | "book" | "knowledge" | "objective" | "discussion" | "discussion-message")[];
595
+ };
596
+ tools: ("discussion" | "source.read" | "source.write" | "verification" | "release")[];
597
+ };
598
+ estimateRef: {
599
+ id: string;
600
+ revision: number;
601
+ model: "assignment-attempt";
602
+ store: "postgresql";
603
+ };
604
+ priority?: number | undefined;
605
+ requiredCapabilities?: string[] | undefined;
606
+ contextRefs?: {
607
+ id: string;
608
+ model: string;
609
+ store: "url" | "treedx" | "git" | "postgresql";
610
+ path?: string | undefined;
611
+ anchor?: string | undefined;
612
+ url?: string | undefined;
613
+ commit?: string | undefined;
614
+ repository?: string | undefined;
615
+ revision?: number | undefined;
616
+ digest?: string | undefined;
617
+ startLine?: number | undefined;
618
+ endLine?: number | undefined;
619
+ }[] | undefined;
620
+ reviewEstimate?: {
621
+ expectedSeconds: number;
622
+ maximumSeconds: number;
623
+ rationale: string;
624
+ } | undefined;
625
+ maximumReviewCycles?: number | undefined;
626
+ }[];
627
+ } | undefined;
526
628
  } | {
527
629
  title: string;
528
630
  status?: "planned" | "live" | "in progress" | "exploratory" | "speculative" | undefined;
@@ -1,7 +1,7 @@
1
1
  import { z } from 'zod';
2
2
  import { type PostProcessCallback } from 'zod-to-json-schema';
3
3
  /** Validate with the owning parser without changing the caller's property order. */
4
- export declare function preserveInputOrder<T extends z.ZodType<Record<string, unknown>>>(parser: T): z.ZodEffects<z.ZodType<Record<string, unknown>, z.ZodTypeDef, Record<string, unknown>>, z.output<T>, Record<string, unknown>>;
4
+ export declare function preserveInputOrder<T extends z.ZodType<Record<string, unknown>>>(parser: T, normalize: (value: Record<string, unknown>) => z.output<T>): z.ZodEffects<z.ZodType<Record<string, unknown>, z.ZodTypeDef, Record<string, unknown>>, z.output<T>, Record<string, unknown>>;
5
5
  /** Preserve inherited validation while requiring represented properties. */
6
6
  export declare function requiredProperties<T extends z.AnyZodObject>(object: T, fields: readonly string[], message: string): z.ZodEffects<T, {
7
7
  [x: string]: any;
@@ -1,15 +1,18 @@
1
1
  import { z } from "zod";
2
2
  import { zodToJsonSchema } from "zod-to-json-schema";
3
3
  const exporters = /* @__PURE__ */ new WeakMap();
4
- function preserveInputOrder(parser) {
4
+ function preserveInputOrder(parser, normalize) {
5
5
  const schema = z.custom((value) => Boolean(value && typeof value === "object" && !Array.isArray(value))).transform((value, context) => {
6
- const parsed = parser.safeParse(value);
7
- if (!parsed.success) {
8
- for (const issue of parsed.error.issues) context.addIssue(issue);
6
+ let parsed;
7
+ try {
8
+ parsed = normalize(value);
9
+ } catch (error) {
10
+ if (!(error instanceof z.ZodError)) throw error;
11
+ for (const issue of error.issues) context.addIssue(issue);
9
12
  return z.NEVER;
10
13
  }
11
- const ordered = Object.fromEntries(Object.keys(value).filter((key) => Object.hasOwn(parsed.data, key)).map((key) => [key, parsed.data[key]]));
12
- return { ...ordered, ...parsed.data };
14
+ const ordered = Object.fromEntries(Object.keys(value).filter((key) => Object.hasOwn(parsed, key)).map((key) => [key, parsed[key]]));
15
+ return { ...ordered, ...parsed };
13
16
  });
14
17
  exporters.set(schema._def, (_exported, refs) => {
15
18
  const { $schema: _dialect, ...exported } = zodToJsonSchema(parser, {
@@ -1,5 +1,4 @@
1
1
  const WORKDAY_SELECTION_INPUTS = [
2
- { target: "body", field: "reportingAgentId", source: "option", name: "reportingAgent", required: false, transform: "identity" },
3
2
  { target: "body", field: "allocation.planningPercent", source: "option", name: "planningPercent", transform: "number" },
4
3
  { target: "body", field: "allocation.allocationWeight", source: "option", name: "allocationWeight", transform: "number" },
5
4
  { target: "body", field: "allocation.planningTurnMaximumSeconds", source: "option", name: "planningTurnMaximumSeconds", transform: "integer" },
@@ -9,7 +8,6 @@ const WORKDAY_SELECTION_INPUTS = [
9
8
  { target: "body", field: "agentSelection.activityTypes", source: "option", name: "activity", transform: "csv" }
10
9
  ];
11
10
  const WORKDAY_PLAN_OPTIONS = [
12
- { name: "--reporting-agent", description: "Closeout Reporter identity; required when several are eligible.", type: "string" },
13
11
  { name: "--planning-percent", description: "Planning share of workday time and capacity (default 20%).", type: "number" },
14
12
  { name: "--allocation-weight", description: "Relative share among eligible concurrent workdays (default 1).", type: "number" },
15
13
  { name: "--planning-turn-maximum-seconds", description: "Maximum active seconds per planning turn (default 180).", type: "number" },
@@ -15,7 +15,6 @@ export declare const workdayIntentSchema: z.ZodEffects<z.ZodEffects<z.ZodObject<
15
15
  proposalIds: z.ZodOptional<z.ZodEffects<z.ZodArray<z.ZodString, "many">, string[], string[]>>;
16
16
  decisionIds: z.ZodOptional<z.ZodEffects<z.ZodArray<z.ZodString, "many">, string[], string[]>>;
17
17
  groupIds: z.ZodOptional<z.ZodEffects<z.ZodArray<z.ZodString, "many">, string[], string[]>>;
18
- reportingAgentId: z.ZodOptional<z.ZodString>;
19
18
  continueFromWorkdayId: z.ZodOptional<z.ZodString>;
20
19
  allocation: z.ZodOptional<z.ZodObject<{
21
20
  planningPercent: z.ZodOptional<z.ZodNumber>;
@@ -70,7 +69,6 @@ export declare const workdayIntentSchema: z.ZodEffects<z.ZodEffects<z.ZodObject<
70
69
  durationSeconds?: number | undefined;
71
70
  projects?: any;
72
71
  executionMode?: "simulation" | "production" | undefined;
73
- reportingAgentId?: string | undefined;
74
72
  endsAt?: string | undefined;
75
73
  planningOnly?: boolean | undefined;
76
74
  objectiveFilters?: string[] | undefined;
@@ -100,7 +98,6 @@ export declare const workdayIntentSchema: z.ZodEffects<z.ZodEffects<z.ZodObject<
100
98
  durationSeconds?: number | undefined;
101
99
  projects?: any;
102
100
  executionMode?: "simulation" | "production" | undefined;
103
- reportingAgentId?: string | undefined;
104
101
  endsAt?: string | undefined;
105
102
  planningOnly?: boolean | undefined;
106
103
  objectiveFilters?: string[] | undefined;
@@ -130,7 +127,6 @@ export declare const workdayIntentSchema: z.ZodEffects<z.ZodEffects<z.ZodObject<
130
127
  durationSeconds?: number | undefined;
131
128
  projects?: any;
132
129
  executionMode?: "simulation" | "production" | undefined;
133
- reportingAgentId?: string | undefined;
134
130
  endsAt?: string | undefined;
135
131
  planningOnly?: boolean | undefined;
136
132
  objectiveFilters?: string[] | undefined;
@@ -160,7 +156,6 @@ export declare const workdayIntentSchema: z.ZodEffects<z.ZodEffects<z.ZodObject<
160
156
  durationSeconds?: number | undefined;
161
157
  projects?: any;
162
158
  executionMode?: "simulation" | "production" | undefined;
163
- reportingAgentId?: string | undefined;
164
159
  endsAt?: string | undefined;
165
160
  planningOnly?: boolean | undefined;
166
161
  objectiveFilters?: string[] | undefined;
@@ -182,6 +177,183 @@ export declare const workdayIntentSchema: z.ZodEffects<z.ZodEffects<z.ZodObject<
182
177
  maxConcurrency?: number | undefined;
183
178
  } | undefined;
184
179
  }>, any, any>;
180
+ /** Public request metadata is route-owned; every represented intent field retains its canonical rule. */
181
+ declare const requestIntentFields: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodObject<{
182
+ schemaVersion: z.ZodOptional<z.ZodLiteral<"treeseed.workday-intent/v1">>;
183
+ groupIds: z.ZodOptional<z.ZodEffects<z.ZodArray<z.ZodString, "many">, string[], string[]>>;
184
+ teamId: z.ZodOptional<z.ZodString>;
185
+ profileId: z.ZodString;
186
+ durationSeconds: z.ZodOptional<z.ZodNumber>;
187
+ projects: z.ZodEffects<z.ZodUnion<[z.ZodLiteral<"all">, z.ZodEffects<z.ZodArray<z.ZodString, "many">, string[], string[]>]>, any, any>;
188
+ executionMode: z.ZodOptional<z.ZodDefault<z.ZodEnum<["simulation", "production"]>>>;
189
+ startsAt: z.ZodString;
190
+ endsAt: z.ZodOptional<z.ZodString>;
191
+ planningOnly: z.ZodOptional<z.ZodBoolean>;
192
+ objectiveFilters: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
193
+ proposalIds: z.ZodOptional<z.ZodEffects<z.ZodArray<z.ZodString, "many">, string[], string[]>>;
194
+ decisionIds: z.ZodOptional<z.ZodEffects<z.ZodArray<z.ZodString, "many">, string[], string[]>>;
195
+ continueFromWorkdayId: z.ZodOptional<z.ZodString>;
196
+ allocation: z.ZodOptional<z.ZodObject<{
197
+ planningPercent: z.ZodOptional<z.ZodNumber>;
198
+ allocationWeight: z.ZodOptional<z.ZodNumber>;
199
+ planningTurnMaximumSeconds: z.ZodOptional<z.ZodNumber>;
200
+ projectPercentages: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
201
+ agentClassPercentages: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodNumber>>>;
202
+ }, "strict", z.ZodTypeAny, {
203
+ planningPercent?: number | undefined;
204
+ allocationWeight?: number | undefined;
205
+ planningTurnMaximumSeconds?: number | undefined;
206
+ projectPercentages?: Record<string, number> | undefined;
207
+ agentClassPercentages?: Record<string, Record<string, number>> | undefined;
208
+ }, {
209
+ planningPercent?: number | undefined;
210
+ allocationWeight?: number | undefined;
211
+ planningTurnMaximumSeconds?: number | undefined;
212
+ projectPercentages?: Record<string, number> | undefined;
213
+ agentClassPercentages?: Record<string, Record<string, number>> | undefined;
214
+ }>>;
215
+ agentSelection: z.ZodOptional<z.ZodEffects<z.ZodObject<{
216
+ mode: z.ZodOptional<z.ZodLiteral<"intersection">>;
217
+ } & {
218
+ activityTypes: z.ZodOptional<z.ZodArray<z.ZodEnum<["planning", "estimating", "reviewing", "reporting", "chat"]>, "many">>;
219
+ }, "strict", z.ZodTypeAny, {
220
+ mode?: "intersection" | undefined;
221
+ activityTypes?: ("planning" | "estimating" | "reviewing" | "reporting" | "chat")[] | undefined;
222
+ }, {
223
+ mode?: "intersection" | undefined;
224
+ activityTypes?: ("planning" | "estimating" | "reviewing" | "reporting" | "chat")[] | undefined;
225
+ }>, {
226
+ [x: string]: any;
227
+ }, {
228
+ [x: string]: any;
229
+ }>>;
230
+ operatorConstraints: z.ZodOptional<z.ZodObject<{
231
+ providerIds: z.ZodOptional<z.ZodEffects<z.ZodArray<z.ZodString, "many">, string[], string[]>>;
232
+ maxConcurrency: z.ZodOptional<z.ZodNumber>;
233
+ }, "strict", z.ZodTypeAny, {
234
+ providerIds?: string[] | undefined;
235
+ maxConcurrency?: number | undefined;
236
+ }, {
237
+ providerIds?: string[] | undefined;
238
+ maxConcurrency?: number | undefined;
239
+ }>>;
240
+ }, "strict", z.ZodTypeAny, {
241
+ profileId: string;
242
+ startsAt: string;
243
+ schemaVersion?: "treeseed.workday-intent/v1" | undefined;
244
+ groupIds?: string[] | undefined;
245
+ teamId?: string | undefined;
246
+ durationSeconds?: number | undefined;
247
+ projects?: any;
248
+ executionMode?: "simulation" | "production" | undefined;
249
+ endsAt?: string | undefined;
250
+ planningOnly?: boolean | undefined;
251
+ objectiveFilters?: string[] | undefined;
252
+ proposalIds?: string[] | undefined;
253
+ decisionIds?: string[] | undefined;
254
+ continueFromWorkdayId?: string | undefined;
255
+ allocation?: {
256
+ planningPercent?: number | undefined;
257
+ allocationWeight?: number | undefined;
258
+ planningTurnMaximumSeconds?: number | undefined;
259
+ projectPercentages?: Record<string, number> | undefined;
260
+ agentClassPercentages?: Record<string, Record<string, number>> | undefined;
261
+ } | undefined;
262
+ agentSelection?: {
263
+ [x: string]: any;
264
+ } | undefined;
265
+ operatorConstraints?: {
266
+ providerIds?: string[] | undefined;
267
+ maxConcurrency?: number | undefined;
268
+ } | undefined;
269
+ }, {
270
+ profileId: string;
271
+ startsAt: string;
272
+ schemaVersion?: "treeseed.workday-intent/v1" | undefined;
273
+ groupIds?: string[] | undefined;
274
+ teamId?: string | undefined;
275
+ durationSeconds?: number | undefined;
276
+ projects?: any;
277
+ executionMode?: "simulation" | "production" | undefined;
278
+ endsAt?: string | undefined;
279
+ planningOnly?: boolean | undefined;
280
+ objectiveFilters?: string[] | undefined;
281
+ proposalIds?: string[] | undefined;
282
+ decisionIds?: string[] | undefined;
283
+ continueFromWorkdayId?: string | undefined;
284
+ allocation?: {
285
+ planningPercent?: number | undefined;
286
+ allocationWeight?: number | undefined;
287
+ planningTurnMaximumSeconds?: number | undefined;
288
+ projectPercentages?: Record<string, number> | undefined;
289
+ agentClassPercentages?: Record<string, Record<string, number>> | undefined;
290
+ } | undefined;
291
+ agentSelection?: {
292
+ [x: string]: any;
293
+ } | undefined;
294
+ operatorConstraints?: {
295
+ providerIds?: string[] | undefined;
296
+ maxConcurrency?: number | undefined;
297
+ } | undefined;
298
+ }>, {
299
+ profileId: string;
300
+ startsAt: string;
301
+ schemaVersion?: "treeseed.workday-intent/v1" | undefined;
302
+ groupIds?: string[] | undefined;
303
+ teamId?: string | undefined;
304
+ durationSeconds?: number | undefined;
305
+ projects?: any;
306
+ executionMode?: "simulation" | "production" | undefined;
307
+ endsAt?: string | undefined;
308
+ planningOnly?: boolean | undefined;
309
+ objectiveFilters?: string[] | undefined;
310
+ proposalIds?: string[] | undefined;
311
+ decisionIds?: string[] | undefined;
312
+ continueFromWorkdayId?: string | undefined;
313
+ allocation?: {
314
+ planningPercent?: number | undefined;
315
+ allocationWeight?: number | undefined;
316
+ planningTurnMaximumSeconds?: number | undefined;
317
+ projectPercentages?: Record<string, number> | undefined;
318
+ agentClassPercentages?: Record<string, Record<string, number>> | undefined;
319
+ } | undefined;
320
+ agentSelection?: {
321
+ [x: string]: any;
322
+ } | undefined;
323
+ operatorConstraints?: {
324
+ providerIds?: string[] | undefined;
325
+ maxConcurrency?: number | undefined;
326
+ } | undefined;
327
+ }, {
328
+ profileId: string;
329
+ startsAt: string;
330
+ schemaVersion?: "treeseed.workday-intent/v1" | undefined;
331
+ groupIds?: string[] | undefined;
332
+ teamId?: string | undefined;
333
+ durationSeconds?: number | undefined;
334
+ projects?: any;
335
+ executionMode?: "simulation" | "production" | undefined;
336
+ endsAt?: string | undefined;
337
+ planningOnly?: boolean | undefined;
338
+ objectiveFilters?: string[] | undefined;
339
+ proposalIds?: string[] | undefined;
340
+ decisionIds?: string[] | undefined;
341
+ continueFromWorkdayId?: string | undefined;
342
+ allocation?: {
343
+ planningPercent?: number | undefined;
344
+ allocationWeight?: number | undefined;
345
+ planningTurnMaximumSeconds?: number | undefined;
346
+ projectPercentages?: Record<string, number> | undefined;
347
+ agentClassPercentages?: Record<string, Record<string, number>> | undefined;
348
+ } | undefined;
349
+ agentSelection?: {
350
+ [x: string]: any;
351
+ } | undefined;
352
+ operatorConstraints?: {
353
+ providerIds?: string[] | undefined;
354
+ maxConcurrency?: number | undefined;
355
+ } | undefined;
356
+ }>, any, any>, any, unknown>, any, unknown>;
185
357
  export declare const workdayIntentRequestSchema: z.ZodEffects<z.ZodType<Record<string, unknown>, z.ZodTypeDef, Record<string, unknown>>, Record<string, unknown>, Record<string, unknown>>;
186
358
  export type WorkdayDemandMode = 'planning' | 'acting';
187
359
  export interface WorkdayIntent {
@@ -203,8 +375,6 @@ export interface WorkdayIntent {
203
375
  groupIds?: string[];
204
376
  /** Selects accepted decisions for API-derived acting work; it does not grant acting authority. */
205
377
  decisionIds?: string[];
206
- /** Selects one configured closeout agent; the API resolves its frozen reporting profile. */
207
- reportingAgentId?: string;
208
378
  /** Continue exact accepted work from a settled workday; omission starts a fresh simulation. */
209
379
  continueFromWorkdayId?: string;
210
380
  /** Selects activity phases without excluding group participants by identity or class. */
@@ -334,6 +504,7 @@ export interface WorkdayLifecycleDiagnostic {
334
504
  export declare function validateWorkdayIntent(intent: WorkdayIntent): WorkdayLifecycleDiagnostic[];
335
505
  /** Preserve raw caller evidence; normalize only legitimate selector input. */
336
506
  export declare function normalizeWorkdayIntent(intent: WorkdayIntent): WorkdayIntent;
507
+ export declare function normalizeWorkdayIntent(intent: unknown, shape: 'request'): z.output<typeof requestIntentFields>;
337
508
  export declare function validateWorkdayIntentSelection(value: unknown): WorkdayLifecycleDiagnostic[];
338
509
  export declare function validateSelectedDemand(demand: WorkdaySelectedDemand): WorkdayLifecycleDiagnostic[];
339
510
  export declare function validateWorkdayPreflight(receipt: WorkdayPreflightReceipt, now?: Date): WorkdayLifecycleDiagnostic[];
@@ -23,35 +23,41 @@ const workdayIntentFields = z.object({
23
23
  proposalIds: selectedIdentities.optional(),
24
24
  decisionIds: selectedIdentities.optional(),
25
25
  groupIds: selectedIdentities.optional(),
26
- reportingAgentId: identifier.optional(),
27
26
  continueFromWorkdayId: z.string().min(1).max(128).regex(/\S/u).optional(),
28
27
  allocation: workdayAllocationOverridesSchema.optional(),
29
28
  agentSelection: intentAgentSelectionSchema.optional(),
30
29
  operatorConstraints: z.object({ providerIds: uniqueArray(z.array(identifier)).optional(), maxConcurrency: z.number().int().positive().optional() }).strict().optional()
31
30
  }).strict();
32
- const continuationRules = [{
33
- field: "continueFromWorkdayId",
34
- alternatives: [["decisionIds"]],
35
- forbidden: { fields: ["proposalIds"], conditions: [{ field: "planningOnly", equals: true }] },
36
- path: ["continueFromWorkdayId"],
37
- message: "Continuation requires exact decisions, not new proposal planning."
38
- }];
39
- const workdayIntentSchema = exclusiveProperties(conditionalFields(workdayIntentFields, continuationRules), ["endsAt", "durationSeconds"]);
40
- const requestIntentFields = z.preprocess((value) => {
41
- if (!value || typeof value !== "object" || Array.isArray(value) || !("decisionIds" in value) || !Array.isArray(value.decisionIds)) return value;
42
- return { ...value, decisionIds: value.decisionIds.map((entry) => typeof entry === "string" ? entry.trim() : entry) };
43
- }, exclusiveProperties(conditionalFields(workdayIntentFields.partial({ schemaVersion: true, teamId: true }), continuationRules), ["endsAt", "durationSeconds"])).superRefine((intent, context) => {
31
+ const workdayScopeRules = [
32
+ {
33
+ field: "projects",
34
+ alternatives: [["groupIds"], ["proposalIds"], ["decisionIds"]],
35
+ path: ["groupIds"],
36
+ message: "Select shared groups or exact proposals or decisions whose groups supply participants."
37
+ },
38
+ {
39
+ field: "continueFromWorkdayId",
40
+ alternatives: [["decisionIds"]],
41
+ forbidden: { fields: ["proposalIds"], conditions: [{ field: "planningOnly", equals: true }] },
42
+ path: ["continueFromWorkdayId"],
43
+ message: "Continuation requires exact decisions, not new proposal planning."
44
+ }
45
+ ];
46
+ const workdayIntentSchema = exclusiveProperties(conditionalFields(workdayIntentFields, workdayScopeRules), ["endsAt", "durationSeconds"]);
47
+ const requestIntentFields = z.preprocess(
48
+ portableIntentInput,
49
+ exclusiveProperties(conditionalFields(workdayIntentFields.partial({ schemaVersion: true, teamId: true }), workdayScopeRules), ["endsAt", "durationSeconds"])
50
+ ).superRefine((intent, context) => {
44
51
  if (!validIntentRange(intent)) context.addIssue({ code: z.ZodIssueCode.custom, path: ["endsAt"], message: "endsAt must be after startsAt." });
45
52
  });
46
- const workdayIntentRequestSchema = preserveInputOrder(requestIntentFields.transform((intent) => ({
47
- ...intent,
48
- ...intent.decisionIds ? { decisionIds: [...intent.decisionIds].sort() } : {}
49
- })));
53
+ const workdayIntentRequestSchema = preserveInputOrder(requestIntentFields, (intent) => normalizeWorkdayIntent(intent, "request"));
50
54
  function validIntentRange(intent) {
51
55
  return intent.endsAt === void 0 || Date.parse(intent.endsAt) > Date.parse(intent.startsAt);
52
56
  }
53
- function portableIntentInput(intent) {
54
- return { ...intent, ...Array.isArray(intent.decisionIds) ? { decisionIds: intent.decisionIds.map((value) => typeof value === "string" ? value.trim() : value) } : {} };
57
+ function portableIntentInput(value) {
58
+ if (!value || typeof value !== "object" || Array.isArray(value)) return value;
59
+ const intent = Object.fromEntries(Object.getOwnPropertyNames(value).map((key) => [key, Reflect.get(value, key)]));
60
+ return { ...intent, ...Array.isArray(intent.decisionIds) ? { decisionIds: intent.decisionIds.map((value2) => typeof value2 === "string" ? value2.trim() : value2) } : {} };
55
61
  }
56
62
  function validateWorkdayIntent(intent) {
57
63
  const result = workdayIntentSchema.safeParse(portableIntentInput(intent));
@@ -70,7 +76,6 @@ function validateWorkdayIntent(intent) {
70
76
  proposalIds: "proposal_selection_invalid",
71
77
  decisionIds: "decision_selection_invalid",
72
78
  groupIds: "group_selection_invalid",
73
- reportingAgentId: "reporting_agent_selection_invalid",
74
79
  continueFromWorkdayId: "continuation_invalid",
75
80
  agentSelection: "agent_selection_invalid",
76
81
  allocation: "allocation_invalid"
@@ -89,7 +94,12 @@ function validateWorkdayIntent(intent) {
89
94
  diagnostics.push({ code: "end_invalid", path: "endsAt", message: "endsAt must be after startsAt." });
90
95
  return diagnostics;
91
96
  }
92
- function normalizeWorkdayIntent(intent) {
97
+ function normalizeWorkdayIntent(input, shape) {
98
+ if (shape === "request") {
99
+ const normalized2 = requestIntentFields.parse(input);
100
+ return { ...normalized2, ...normalized2.decisionIds ? { decisionIds: [...normalized2.decisionIds].sort() } : {} };
101
+ }
102
+ const intent = input;
93
103
  const diagnostics = validateWorkdayIntent(intent);
94
104
  if (diagnostics.length) throw new Error(`Invalid workday intent: ${diagnostics.map((value) => `${value.path}: ${value.message}`).join("; ")}`);
95
105
  const normalized = workdayIntentSchema.parse(portableIntentInput(intent));