@treeseed/sdk 0.13.0-rc.128 → 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.
@@ -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, {
@@ -177,6 +177,183 @@ export declare const workdayIntentSchema: z.ZodEffects<z.ZodEffects<z.ZodObject<
177
177
  maxConcurrency?: number | undefined;
178
178
  } | undefined;
179
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>;
180
357
  export declare const workdayIntentRequestSchema: z.ZodEffects<z.ZodType<Record<string, unknown>, z.ZodTypeDef, Record<string, unknown>>, Record<string, unknown>, Record<string, unknown>>;
181
358
  export type WorkdayDemandMode = 'planning' | 'acting';
182
359
  export interface WorkdayIntent {
@@ -327,6 +504,7 @@ export interface WorkdayLifecycleDiagnostic {
327
504
  export declare function validateWorkdayIntent(intent: WorkdayIntent): WorkdayLifecycleDiagnostic[];
328
505
  /** Preserve raw caller evidence; normalize only legitimate selector input. */
329
506
  export declare function normalizeWorkdayIntent(intent: WorkdayIntent): WorkdayIntent;
507
+ export declare function normalizeWorkdayIntent(intent: unknown, shape: 'request'): z.output<typeof requestIntentFields>;
330
508
  export declare function validateWorkdayIntentSelection(value: unknown): WorkdayLifecycleDiagnostic[];
331
509
  export declare function validateSelectedDemand(demand: WorkdaySelectedDemand): WorkdayLifecycleDiagnostic[];
332
510
  export declare function validateWorkdayPreflight(receipt: WorkdayPreflightReceipt, now?: Date): WorkdayLifecycleDiagnostic[];
@@ -28,29 +28,36 @@ const workdayIntentFields = z.object({
28
28
  agentSelection: intentAgentSelectionSchema.optional(),
29
29
  operatorConstraints: z.object({ providerIds: uniqueArray(z.array(identifier)).optional(), maxConcurrency: z.number().int().positive().optional() }).strict().optional()
30
30
  }).strict();
31
- const continuationRules = [{
32
- field: "continueFromWorkdayId",
33
- alternatives: [["decisionIds"]],
34
- forbidden: { fields: ["proposalIds"], conditions: [{ field: "planningOnly", equals: true }] },
35
- path: ["continueFromWorkdayId"],
36
- message: "Continuation requires exact decisions, not new proposal planning."
37
- }];
38
- const workdayIntentSchema = exclusiveProperties(conditionalFields(workdayIntentFields, continuationRules), ["endsAt", "durationSeconds"]);
39
- const requestIntentFields = z.preprocess((value) => {
40
- if (!value || typeof value !== "object" || Array.isArray(value) || !("decisionIds" in value) || !Array.isArray(value.decisionIds)) return value;
41
- return { ...value, decisionIds: value.decisionIds.map((entry) => typeof entry === "string" ? entry.trim() : entry) };
42
- }, 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) => {
43
51
  if (!validIntentRange(intent)) context.addIssue({ code: z.ZodIssueCode.custom, path: ["endsAt"], message: "endsAt must be after startsAt." });
44
52
  });
45
- const workdayIntentRequestSchema = preserveInputOrder(requestIntentFields.transform((intent) => ({
46
- ...intent,
47
- ...intent.decisionIds ? { decisionIds: [...intent.decisionIds].sort() } : {}
48
- })));
53
+ const workdayIntentRequestSchema = preserveInputOrder(requestIntentFields, (intent) => normalizeWorkdayIntent(intent, "request"));
49
54
  function validIntentRange(intent) {
50
55
  return intent.endsAt === void 0 || Date.parse(intent.endsAt) > Date.parse(intent.startsAt);
51
56
  }
52
- function portableIntentInput(intent) {
53
- 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) } : {} };
54
61
  }
55
62
  function validateWorkdayIntent(intent) {
56
63
  const result = workdayIntentSchema.safeParse(portableIntentInput(intent));
@@ -87,7 +94,12 @@ function validateWorkdayIntent(intent) {
87
94
  diagnostics.push({ code: "end_invalid", path: "endsAt", message: "endsAt must be after startsAt." });
88
95
  return diagnostics;
89
96
  }
90
- 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;
91
103
  const diagnostics = validateWorkdayIntent(intent);
92
104
  if (diagnostics.length) throw new Error(`Invalid workday intent: ${diagnostics.map((value) => `${value.path}: ${value.message}`).join("; ")}`);
93
105
  const normalized = workdayIntentSchema.parse(portableIntentInput(intent));
@@ -15,6 +15,12 @@ workflow:
15
15
  - id: group-phase-selection
16
16
  action: { verifier: sdk.golden.group-phase-selection }
17
17
  expect: { status: passed }
18
+ - id: group-workday-audience
19
+ action: { verifier: sdk.golden.group-workday-audience }
20
+ expect: { status: passed }
21
+ - id: group-workday-audience-native
22
+ action: { verifier: sdk.golden.group-workday-audience-native }
23
+ expect: { status: passed }
18
24
  - id: integration-reviewed-input-unit
19
25
  action: { verifier: sdk.golden.integration-reviewed-input-unit }
20
26
  expect: { status: passed }
@@ -21,6 +21,16 @@ verifiers:
21
21
  ownerPackage: "@treeseed/sdk"
22
22
  testFile: tests/unit/operator-contracts/group-workday-intent.test.ts
23
23
  testName: "keeps normalized internal phase snapshots free of identity filters and rejects legacy targeting"
24
+ sdk.golden.group-workday-audience:
25
+ kind: vitestCase
26
+ ownerPackage: "@treeseed/sdk"
27
+ testFile: tests/unit/operator-contracts/group-workday-intent.test.ts
28
+ testName: "requires groups or exact governed subjects instead of treating project and activity scope as an agent audience"
29
+ sdk.golden.group-workday-audience-native:
30
+ kind: vitestCase
31
+ ownerPackage: "@treeseed/sdk"
32
+ testFile: tests/unit/operator-contracts/acceptance/workday-group-scope-native.test.ts
33
+ testName: "native manual and scheduled workday requests preserve group-derived scope and deny an unscoped audience before HTTP"
24
34
  sdk.golden.cli-read-library-unit:
25
35
  kind: vitestCase
26
36
  ownerPackage: "@treeseed/sdk"
@@ -1334,7 +1344,7 @@ verifiers:
1334
1344
  kind: vitestCase
1335
1345
  ownerPackage: "@treeseed/sdk"
1336
1346
  testFile: tests/unit/operator-contracts/product/intent-runtime-native.test.ts
1337
- testName: "native product inspection uses actual built public SDK exports and refuses hidden retired intent fields without fixing the candidate"
1347
+ testName: "native product inspection uses actual built public SDK exports and refuses hidden retired intent fields through the shared normalizer"
1338
1348
 
1339
1349
  sdk.golden.intent-runtime-custody-unit:
1340
1350
  kind: vitestCase
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@treeseed/sdk",
3
- "version": "0.13.0-rc.128",
3
+ "version": "0.13.0-rc.129",
4
4
  "description": "Portable TreeSeed contracts, standards, and typed remote control-plane clients.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {