@treeseed/sdk 0.13.0-rc.126 → 0.13.0-rc.128

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/README.md CHANGED
@@ -58,6 +58,33 @@ and cleanup. It must not interpret agent identity, profile, proposal, review, or
58
58
  release policy. Workload preparation and task interpretation belong to the
59
59
  configured application handlers.
60
60
 
61
+ The shared workday selection normalizer accepts activity phases only. It rejects
62
+ agent names, class IDs, class slugs, union matching and unknown fields even on
63
+ internal calls. Proposal groups and discussion addressing supply participants;
64
+ the phase selection describes which activities run. Fair allocation weights
65
+ still use the agent's one class and are independent of participation.
66
+ Closeout participation is also group-driven: public workday intent and generated
67
+ commands reject `reportingAgentId` and expose no `--reporting-agent` flag. Existing
68
+ applied plans retain their derived reporting identity as historical authority.
69
+
70
+ ## Group contribution proposal contract
71
+
72
+ Current proposal metadata uses `treeseed.proposal/v2`. A proposal requires shared
73
+ `groupIds`; its execution plan contains each subscriber's own work items and
74
+ bounded estimates with rationale. Work items have no agent or class selector.
75
+ Each `estimateRef` names the existing PostgreSQL `assignment-attempt` by its
76
+ admitted ID and attempt ordinal (`revision`), rather than its changing lease state
77
+ version. The API must verify that estimating attempt's actual
78
+ author, current proposal authority, completed result and contribution before
79
+ approval or execution; a syntactically valid reference grants no authority.
80
+ Every subscriber contributes and executes its work, rather than bidding for one
81
+ selected assignment. Dependencies order the contributions and independent review.
82
+
83
+ The validator preserves historical `treeseed.proposal/v1` records unchanged for
84
+ read-back. Schema descriptions default to v2; historical consumers can explicitly
85
+ request the v1 description. This contract does not itself implement participation
86
+ readiness, estimate integration, execution provenance or peer review in the API.
87
+
61
88
  ## TreeDX API
62
89
 
63
90
  ```ts
@@ -112,7 +112,6 @@ export declare const workdayScheduleSchema: z.ZodObject<{
112
112
  proposalIds: z.ZodOptional<z.ZodEffects<z.ZodArray<z.ZodString, "many">, string[], string[]>>;
113
113
  decisionIds: z.ZodOptional<z.ZodEffects<z.ZodArray<z.ZodString, "many">, string[], string[]>>;
114
114
  groupIds: z.ZodOptional<z.ZodEffects<z.ZodArray<z.ZodString, "many">, string[], string[]>>;
115
- reportingAgentId: z.ZodOptional<z.ZodString>;
116
115
  continueFromWorkdayId: z.ZodOptional<z.ZodString>;
117
116
  allocation: z.ZodOptional<z.ZodObject<{
118
117
  planningPercent: z.ZodOptional<z.ZodNumber>;
@@ -134,8 +133,9 @@ export declare const workdayScheduleSchema: z.ZodObject<{
134
133
  agentClassPercentages?: Record<string, Record<string, number>> | undefined;
135
134
  }>>;
136
135
  agentSelection: z.ZodOptional<z.ZodEffects<z.ZodObject<{
137
- activityTypes: z.ZodOptional<z.ZodArray<z.ZodEnum<["planning", "estimating", "reviewing", "reporting", "chat"]>, "many">>;
138
136
  mode: z.ZodOptional<z.ZodLiteral<"intersection">>;
137
+ } & {
138
+ activityTypes: z.ZodOptional<z.ZodArray<z.ZodEnum<["planning", "estimating", "reviewing", "reporting", "chat"]>, "many">>;
139
139
  }, "strict", z.ZodTypeAny, {
140
140
  mode?: "intersection" | undefined;
141
141
  activityTypes?: ("planning" | "estimating" | "reviewing" | "reporting" | "chat")[] | undefined;
@@ -166,7 +166,6 @@ export declare const workdayScheduleSchema: z.ZodObject<{
166
166
  durationSeconds?: number | undefined;
167
167
  projects?: any;
168
168
  executionMode?: "simulation" | "production" | undefined;
169
- reportingAgentId?: string | undefined;
170
169
  endsAt?: string | undefined;
171
170
  planningOnly?: boolean | undefined;
172
171
  objectiveFilters?: string[] | undefined;
@@ -196,7 +195,6 @@ export declare const workdayScheduleSchema: z.ZodObject<{
196
195
  durationSeconds?: number | undefined;
197
196
  projects?: any;
198
197
  executionMode?: "simulation" | "production" | undefined;
199
- reportingAgentId?: string | undefined;
200
198
  endsAt?: string | undefined;
201
199
  planningOnly?: boolean | undefined;
202
200
  objectiveFilters?: string[] | undefined;
@@ -226,7 +224,6 @@ export declare const workdayScheduleSchema: z.ZodObject<{
226
224
  durationSeconds?: number | undefined;
227
225
  projects?: any;
228
226
  executionMode?: "simulation" | "production" | undefined;
229
- reportingAgentId?: string | undefined;
230
227
  endsAt?: string | undefined;
231
228
  planningOnly?: boolean | undefined;
232
229
  objectiveFilters?: string[] | undefined;
@@ -256,7 +253,6 @@ export declare const workdayScheduleSchema: z.ZodObject<{
256
253
  durationSeconds?: number | undefined;
257
254
  projects?: any;
258
255
  executionMode?: "simulation" | "production" | undefined;
259
- reportingAgentId?: string | undefined;
260
256
  endsAt?: string | undefined;
261
257
  planningOnly?: boolean | undefined;
262
258
  objectiveFilters?: string[] | undefined;
@@ -1,3 +1,4 @@
1
+ import { z } from 'zod';
1
2
  export interface WorkdayPlanningAgent {
2
3
  slug: string;
3
4
  activityType?: string | null;
@@ -5,13 +6,21 @@ export interface WorkdayPlanningAgent {
5
6
  projectAgentClassSlug?: string | null;
6
7
  projectAgentClassId?: string | null;
7
8
  }
9
+ export declare const workdayActivitySelectionSchema: z.ZodObject<{
10
+ activityTypes: z.ZodOptional<z.ZodArray<z.ZodEnum<["planning", "estimating", "reviewing", "reporting", "chat"]>, "many">>;
11
+ mode: z.ZodOptional<z.ZodLiteral<"intersection">>;
12
+ }, "strict", z.ZodTypeAny, {
13
+ mode?: "intersection" | undefined;
14
+ activityTypes?: ("planning" | "estimating" | "reviewing" | "reporting" | "chat")[] | undefined;
15
+ }, {
16
+ mode?: "intersection" | undefined;
17
+ activityTypes?: ("planning" | "estimating" | "reviewing" | "reporting" | "chat")[] | undefined;
18
+ }>;
8
19
  export interface WorkdayAgentSelection {
9
- classIds: string[];
10
- classSlugs: string[];
11
- agentSlugs: string[];
12
20
  activityTypes: string[];
13
- mode: 'intersection' | 'union';
21
+ mode: 'intersection';
14
22
  }
23
+ /** Normalize activity phases only. Group resolution owns the agent audience. */
15
24
  export declare function normalizeWorkdayAgentSelection(value: unknown): WorkdayAgentSelection;
16
25
  export declare function workdayAgentSelectionActive(selection: WorkdayAgentSelection): boolean;
17
26
  export declare function selectWorkdayAgents<T extends WorkdayPlanningAgent>(agents: T[], value: unknown): T[];
@@ -1,35 +1,18 @@
1
- function uniqueStrings(value) {
2
- if (!Array.isArray(value)) return [];
3
- return [...new Set(value.map((item) => String(item).trim()).filter(Boolean))].sort();
4
- }
1
+ import { z } from "zod";
2
+ const workdayActivitySelectionSchema = z.object({
3
+ activityTypes: z.array(z.enum(["planning", "estimating", "reviewing", "reporting", "chat"])).optional(),
4
+ mode: z.literal("intersection").optional()
5
+ }).strict();
5
6
  function normalizeWorkdayAgentSelection(value) {
6
- const input = record(value);
7
- return {
8
- classIds: uniqueStrings(input.classIds),
9
- classSlugs: uniqueStrings(input.classSlugs),
10
- agentSlugs: uniqueStrings(input.agentSlugs),
11
- activityTypes: uniqueStrings(input.activityTypes),
12
- mode: input.mode === "union" ? "union" : "intersection"
13
- };
7
+ const parsed = workdayActivitySelectionSchema.parse(value === void 0 ? {} : value);
8
+ return { activityTypes: [...new Set(parsed.activityTypes ?? [])].sort(), mode: "intersection" };
14
9
  }
15
10
  function workdayAgentSelectionActive(selection) {
16
- return selection.classIds.length > 0 || selection.classSlugs.length > 0 || selection.agentSlugs.length > 0 || selection.activityTypes.length > 0;
11
+ return selection.activityTypes.length > 0;
17
12
  }
18
13
  function selectWorkdayAgents(agents, value) {
19
14
  const selection = normalizeWorkdayAgentSelection(value);
20
- if (!workdayAgentSelectionActive(selection)) return agents;
21
- const classSelectors = /* @__PURE__ */ new Set([...selection.classIds, ...selection.classSlugs]);
22
- const agentSelectors = new Set(selection.agentSlugs);
23
- const activitySelectors = new Set(selection.activityTypes);
24
- return agents.filter((agent) => {
25
- const classMatch = classSelectors.size === 0 || [agent.projectAgentClassId, agent.projectAgentClassSlug].some((candidate) => candidate && [...classSelectors].some((selector) => selector === candidate || selector.endsWith(`:${candidate}`)));
26
- const agentMatch = agentSelectors.size === 0 || agentSelectors.has(agent.slug);
27
- const activityMatch = activitySelectors.size === 0 || Boolean(agent.activityType && activitySelectors.has(agent.activityType));
28
- if (selection.mode === "union") {
29
- return classSelectors.size > 0 && classMatch || agentSelectors.size > 0 && agentMatch || activitySelectors.size > 0 && activityMatch;
30
- }
31
- return classMatch && agentMatch && activityMatch;
32
- });
15
+ return !selection.activityTypes.length ? agents : agents.filter((agent) => Boolean(agent.activityType && selection.activityTypes.includes(agent.activityType)));
33
16
  }
34
17
  function record(value) {
35
18
  return value && typeof value === "object" && !Array.isArray(value) ? value : {};
@@ -101,5 +84,6 @@ export {
101
84
  record,
102
85
  selectFairPlanningAgentCycles,
103
86
  selectWorkdayAgents,
87
+ workdayActivitySelectionSchema,
104
88
  workdayAgentSelectionActive
105
89
  };