@heedwork/core 0.1.0 → 0.2.0

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/index.d.ts CHANGED
@@ -2,5 +2,6 @@ export * from "./command.js";
2
2
  export * from "./derived-state.js";
3
3
  export * from "./human-api.js";
4
4
  export * from "./item-operations.js";
5
+ export * from "./judge.js";
5
6
  export * from "./workspace-socket.js";
6
7
  export * from "./workspace.js";
package/dist/index.js CHANGED
@@ -2,5 +2,6 @@ export * from "./command.js";
2
2
  export * from "./derived-state.js";
3
3
  export * from "./human-api.js";
4
4
  export * from "./item-operations.js";
5
+ export * from "./judge.js";
5
6
  export * from "./workspace-socket.js";
6
7
  export * from "./workspace.js";
@@ -37,6 +37,7 @@ export declare const ActorSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
37
37
  default_project_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
38
38
  }, z.core.$strict>], "kind">;
39
39
  export declare const LockableFieldSchema: z.ZodEnum<{
40
+ acceptance: "acceptance";
40
41
  priority: "priority";
41
42
  scheduled_on: "scheduled_on";
42
43
  sort_key: "sort_key";
@@ -55,6 +56,7 @@ export declare const AddItemSchema: z.ZodObject<{
55
56
  agent_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
56
57
  note: z.ZodOptional<z.ZodNullable<z.ZodString>>;
57
58
  tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
59
+ acceptance: z.ZodOptional<z.ZodArray<z.ZodString>>;
58
60
  ref_url: z.ZodOptional<z.ZodNullable<z.ZodURL>>;
59
61
  priority: z.ZodOptional<z.ZodInt>;
60
62
  scheduled_on: z.ZodOptional<z.ZodNullable<z.ZodISODate>>;
@@ -73,6 +75,7 @@ export declare const UpdateItemSchema: z.ZodObject<{
73
75
  sort_key: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
74
76
  layout_pos: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodNumber>>>;
75
77
  unlock: z.ZodOptional<z.ZodEnum<{
78
+ acceptance: "acceptance";
76
79
  priority: "priority";
77
80
  scheduled_on: "scheduled_on";
78
81
  sort_key: "sort_key";
@@ -80,6 +83,7 @@ export declare const UpdateItemSchema: z.ZodObject<{
80
83
  }>>;
81
84
  title: z.ZodOptional<z.ZodString>;
82
85
  tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
86
+ acceptance: z.ZodOptional<z.ZodArray<z.ZodString>>;
83
87
  ref_url: z.ZodOptional<z.ZodNullable<z.ZodURL>>;
84
88
  priority: z.ZodOptional<z.ZodInt>;
85
89
  scheduled_on: z.ZodOptional<z.ZodNullable<z.ZodISODate>>;
@@ -102,6 +106,7 @@ export declare const ReportProgressSchema: z.ZodObject<{
102
106
  cancelled: "cancelled";
103
107
  }>>;
104
108
  ref_url: z.ZodOptional<z.ZodNullable<z.ZodURL>>;
109
+ evidence: z.ZodOptional<z.ZodString>;
105
110
  agent_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
106
111
  note: z.ZodOptional<z.ZodNullable<z.ZodString>>;
107
112
  }, z.core.$strict>;
@@ -113,6 +118,7 @@ export declare const SetStatusBodySchema: z.ZodObject<{
113
118
  cancelled: "cancelled";
114
119
  }>>>;
115
120
  ref_url: z.ZodOptional<z.ZodNullable<z.ZodURL>>;
121
+ evidence: z.ZodOptional<z.ZodString>;
116
122
  agent_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
117
123
  note: z.ZodOptional<z.ZodNullable<z.ZodString>>;
118
124
  }, z.core.$strict>;
@@ -154,7 +160,7 @@ export interface ItemOperationResult {
154
160
  item_id: string;
155
161
  /** Changed rows, or the removed rows for deleteItem. */
156
162
  items: Item[];
157
- ignored_fields: LockableField[];
163
+ ignored_fields: (LockableField | "evidence")[];
158
164
  guidance_updated_at: string | null;
159
165
  }
160
166
  export interface DependencyOperationResult extends ItemOperationResult {
@@ -41,6 +41,7 @@ export const LockableFieldSchema = z.enum([
41
41
  "scheduled_on",
42
42
  "sort_key",
43
43
  "layout_pos",
44
+ "acceptance",
44
45
  ]);
45
46
  const placement = {
46
47
  parent_id: id.nullable().optional(),
@@ -50,6 +51,15 @@ const itemFields = {
50
51
  ...placement,
51
52
  title,
52
53
  tags: z.array(z.string()),
54
+ acceptance: z
55
+ .array(z
56
+ .string()
57
+ .trim()
58
+ .min(1, "Acceptance criteria must not be empty")
59
+ .refine((value) => value.length <= 200 ||
60
+ (value.length <= 400 && [...value].length <= 200), "Each acceptance criterion must be at most 200 characters")
61
+ .meta({ maxLength: 200 }))
62
+ .max(8, "Provide at most 8 acceptance criteria"),
53
63
  ref_url: z.url().nullable(),
54
64
  priority: z.int().min(1).max(10),
55
65
  scheduled_on: z.iso.date().nullable(),
@@ -85,6 +95,12 @@ const progressFields = {
85
95
  ...assignment,
86
96
  status: StatusSchema.exclude(["queued"]).optional(),
87
97
  ref_url: itemFields.ref_url.optional(),
98
+ evidence: z
99
+ .string()
100
+ .refine((value) => value.length <= 4_000 ||
101
+ (value.length <= 8_000 && [...value].length <= 4_000), "Evidence must be at most 4,000 characters")
102
+ .meta({ maxLength: 4_000 })
103
+ .optional(),
88
104
  };
89
105
  export const ReportProgressSchema = itemSelector.safeExtend(progressFields);
90
106
  export const SetStatusBodySchema = z.strictObject(progressFields).required({
@@ -0,0 +1,35 @@
1
+ import { z } from "zod";
2
+ export declare const JudgeProbabilitySchema: z.ZodNumber;
3
+ export declare const JudgeConfigurationSchema: z.ZodObject<{
4
+ url: z.ZodURL;
5
+ apiKey: z.ZodString;
6
+ model: z.ZodString;
7
+ }, z.core.$strip>;
8
+ export declare const JudgedDetailSchema: z.ZodObject<{
9
+ status_event_id: z.ZodInt;
10
+ model: z.ZodString;
11
+ criteria: z.ZodArray<z.ZodString>;
12
+ probabilities: z.ZodArray<z.ZodNullable<z.ZodNumber>>;
13
+ evidence_supplied: z.ZodBoolean;
14
+ }, z.core.$strict>;
15
+ export declare const JudgeFeedbackDetailSchema: z.ZodObject<{
16
+ judged_event_id: z.ZodInt;
17
+ agrees: z.ZodBoolean;
18
+ }, z.core.$strict>;
19
+ export declare const JudgeUsageSchema: z.ZodObject<{
20
+ type: z.ZodLiteral<"judge">;
21
+ model: z.ZodString;
22
+ inputTokens: z.ZodNullable<z.ZodInt>;
23
+ }, z.core.$strip>;
24
+ export declare const JudgeLimitActionSchema: z.ZodLiteral<"judge">;
25
+ export type JudgeConfiguration = z.infer<typeof JudgeConfigurationSchema>;
26
+ export type JudgedDetail = z.infer<typeof JudgedDetailSchema>;
27
+ export type JudgeFeedbackDetail = z.infer<typeof JudgeFeedbackDetailSchema>;
28
+ export type JudgeUsage = z.infer<typeof JudgeUsageSchema>;
29
+ export type JudgeLimitAction = z.infer<typeof JudgeLimitActionSchema>;
30
+ export type JudgeAgreement = {
31
+ verdicts: number;
32
+ reviewed: number;
33
+ agreed: number;
34
+ };
35
+ export declare function classifyJudgeProbability(probability: number | null): "Unclear" | "Likely met" | "Likely not met";
package/dist/judge.js ADDED
@@ -0,0 +1,36 @@
1
+ import { z } from "zod";
2
+ const model = z.string().trim().min(1).max(256);
3
+ export const JudgeProbabilitySchema = z.number().min(0).max(1);
4
+ export const JudgeConfigurationSchema = z.object({
5
+ url: z.url({ protocol: /^https?$/ }),
6
+ apiKey: z.string().trim().min(1),
7
+ model,
8
+ });
9
+ export const JudgedDetailSchema = z
10
+ .strictObject({
11
+ status_event_id: z.int().positive(),
12
+ model,
13
+ criteria: z.array(z.string().min(1)).min(1).max(8),
14
+ probabilities: z.array(JudgeProbabilitySchema.nullable()).min(1).max(8),
15
+ evidence_supplied: z.boolean(),
16
+ })
17
+ .refine(({ criteria, probabilities }) => criteria.length === probabilities.length);
18
+ export const JudgeFeedbackDetailSchema = z.strictObject({
19
+ judged_event_id: z.int().positive(),
20
+ agrees: z.boolean(),
21
+ });
22
+ export const JudgeUsageSchema = z.object({
23
+ type: z.literal("judge"),
24
+ model,
25
+ inputTokens: z.int().nonnegative().nullable(),
26
+ });
27
+ export const JudgeLimitActionSchema = z.literal("judge");
28
+ export function classifyJudgeProbability(probability) {
29
+ if (probability === null)
30
+ return "Unclear";
31
+ if (probability >= 0.7)
32
+ return "Likely met";
33
+ if (probability <= 0.3)
34
+ return "Likely not met";
35
+ return "Unclear";
36
+ }
@@ -1,5 +1,6 @@
1
1
  import { z } from "zod";
2
- import type { Dependency, Item, Project, Settings, TokenMetadata } from "./workspace.js";
2
+ import type { ItemOperationResult } from "./item-operations.js";
3
+ import type { Dependency, Event, Item, Project, Settings, TokenMetadata } from "./workspace.js";
3
4
  export declare const SocketRequestIdSchema: z.ZodString;
4
5
  export declare const WORKSPACE_RESET_CLOSE_CODE = 4000;
5
6
  export declare const MoveProjectSchema: z.ZodObject<{
@@ -30,6 +31,7 @@ export declare const SocketRequestSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
30
31
  agent_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
31
32
  note: z.ZodOptional<z.ZodNullable<z.ZodString>>;
32
33
  tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
34
+ acceptance: z.ZodOptional<z.ZodArray<z.ZodString>>;
33
35
  ref_url: z.ZodOptional<z.ZodNullable<z.ZodURL>>;
34
36
  priority: z.ZodOptional<z.ZodInt>;
35
37
  scheduled_on: z.ZodOptional<z.ZodNullable<z.ZodISODate>>;
@@ -75,6 +77,14 @@ export declare const SocketRequestSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
75
77
  input: z.ZodObject<{
76
78
  item_id: z.ZodString;
77
79
  }, z.core.$strict>;
80
+ }, z.core.$strict>, z.ZodObject<{
81
+ type: z.ZodLiteral<"JUDGE_FEEDBACK">;
82
+ requestId: z.ZodString;
83
+ input: z.ZodObject<{
84
+ item_id: z.ZodString;
85
+ judged_event_id: z.ZodInt;
86
+ agrees: z.ZodBoolean;
87
+ }, z.core.$strict>;
78
88
  }, z.core.$strict>, z.ZodObject<{
79
89
  type: z.ZodLiteral<"SET_DEPENDENCY">;
80
90
  requestId: z.ZodString;
@@ -174,6 +184,7 @@ export declare const SocketRequestSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
174
184
  sort_key: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
175
185
  layout_pos: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodNumber>>>;
176
186
  unlock: z.ZodOptional<z.ZodEnum<{
187
+ acceptance: "acceptance";
177
188
  priority: "priority";
178
189
  scheduled_on: "scheduled_on";
179
190
  sort_key: "sort_key";
@@ -181,6 +192,7 @@ export declare const SocketRequestSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
181
192
  }>>;
182
193
  title: z.ZodOptional<z.ZodString>;
183
194
  tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
195
+ acceptance: z.ZodOptional<z.ZodArray<z.ZodString>>;
184
196
  ref_url: z.ZodOptional<z.ZodNullable<z.ZodURL>>;
185
197
  priority: z.ZodOptional<z.ZodInt>;
186
198
  scheduled_on: z.ZodOptional<z.ZodNullable<z.ZodISODate>>;
@@ -204,6 +216,7 @@ export declare const SocketRequestSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
204
216
  cancelled: "cancelled";
205
217
  }>>>;
206
218
  ref_url: z.ZodOptional<z.ZodNullable<z.ZodURL>>;
219
+ evidence: z.ZodOptional<z.ZodString>;
207
220
  agent_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
208
221
  note: z.ZodOptional<z.ZodNullable<z.ZodString>>;
209
222
  item_id: z.ZodString;
@@ -286,10 +299,14 @@ export type WorkspaceMessage = {
286
299
  } | {
287
300
  type: "SETTINGS_UPDATE";
288
301
  settings: Settings;
302
+ } | {
303
+ type: "EVENT_APPEND";
304
+ event: Event;
289
305
  } | {
290
306
  type: "ACK";
291
307
  requestId: string;
292
308
  createdToken?: CreatedToken;
309
+ ignored_fields?: ItemOperationResult["ignored_fields"];
293
310
  } | {
294
311
  type: "ERROR";
295
312
  requestId: string | null;
@@ -1,5 +1,6 @@
1
1
  import { z } from "zod";
2
2
  import { AddItemSchema, FlagHandoffSchema, ItemIdSchema, ReopenItemSchema, ReportProgressSchema, SetDependencySchema, SetStatusBodySchema, UpdateItemSchema, } from "./item-operations.js";
3
+ import { JudgeFeedbackDetailSchema } from "./judge.js";
3
4
  import { GuidanceBodySchema, ResetWorkspaceBodySchema, TimezoneBodySchema, } from "./human-api.js";
4
5
  import { CreateProjectSchema, CreateTokenSchema, UpdateProjectSchema, } from "./workspace.js";
5
6
  export const SocketRequestIdSchema = z.string().min(1).max(128);
@@ -25,6 +26,7 @@ export const SocketRequestSchema = z.discriminatedUnion("type", [
25
26
  mutation("REOPEN_ITEM", ReopenItemSchema),
26
27
  mutation("FLAG_HANDOFF", FlagHandoffSchema.omit({ notify: true })),
27
28
  mutation("CLEAR_HANDOFF", ItemIdSchema),
29
+ mutation("JUDGE_FEEDBACK", ItemIdSchema.extend(JudgeFeedbackDetailSchema.shape)),
28
30
  mutation("SET_DEPENDENCY", SetDependencySchema),
29
31
  mutation("SET_NOTE", ItemIdSchema.extend({ note: ReportProgressSchema.shape.note.unwrap() })),
30
32
  mutation("CREATE_PROJECT", CreateProjectSchema),
@@ -30,6 +30,8 @@ export declare const EventKindSchema: z.ZodEnum<{
30
30
  reopened: "reopened";
31
31
  moved: "moved";
32
32
  notified: "notified";
33
+ judged: "judged";
34
+ judge_feedback: "judge_feedback";
33
35
  }>;
34
36
  export declare const DEFAULT_WORKSPACE_ID = "default";
35
37
  export declare const INBOX_PROJECT_ID = "inbox";
@@ -78,6 +80,7 @@ export declare const ItemSchema: z.ZodObject<{
78
80
  external_key: z.ZodNullable<z.ZodString>;
79
81
  title: z.ZodString;
80
82
  tags: z.ZodString;
83
+ acceptance: z.ZodString;
81
84
  depth: z.ZodInt;
82
85
  priority: z.ZodInt;
83
86
  scheduled_on: z.ZodNullable<z.ZodISODate>;
@@ -148,6 +151,8 @@ export declare const EventSchema: z.ZodObject<{
148
151
  reopened: "reopened";
149
152
  moved: "moved";
150
153
  notified: "notified";
154
+ judged: "judged";
155
+ judge_feedback: "judge_feedback";
151
156
  }>;
152
157
  detail: z.ZodNullable<z.ZodString>;
153
158
  }, z.core.$strip>;
package/dist/workspace.js CHANGED
@@ -22,6 +22,8 @@ export const EventKindSchema = z.enum([
22
22
  "reopened",
23
23
  "moved",
24
24
  "notified",
25
+ "judged",
26
+ "judge_feedback",
25
27
  ]);
26
28
  export const DEFAULT_WORKSPACE_ID = "default";
27
29
  export const INBOX_PROJECT_ID = "inbox";
@@ -78,6 +80,7 @@ export const ItemSchema = z.object({
78
80
  external_key: nullableText,
79
81
  title: z.string(),
80
82
  tags: z.string(),
83
+ acceptance: z.string(),
81
84
  depth: z.int().min(1).max(3),
82
85
  priority: z.int().min(1).max(10),
83
86
  scheduled_on: z.iso.date().nullable(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heedwork/core",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "license": "MIT",