@camox/api-contract 0.63.0 → 0.66.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/threads.d.ts CHANGED
@@ -35,7 +35,8 @@ export declare const RECONCILE_ENTRY = "camox.reconcile";
35
35
  /**
36
36
  * The kind of the transcript entry opening a draft's thread a Live thread handed a request off
37
37
  * to: the Brief, which the model reads and editors see as from Camox, ahead of the editor's
38
- * messages.
38
+ * messages. In a draft Camox opened, such as its Patrol Draft, Camox's own messages are Briefs
39
+ * too, with their `operationId` as data, and start the agent's run, which acts for Camox.
39
40
  */
40
41
  export declare const BRIEF_ENTRY = "camox.brief";
41
42
  /**
@@ -44,6 +45,13 @@ export declare const BRIEF_ENTRY = "camox.brief";
44
45
  * it at the end of the conversation; editors never see it, since the draft's card says so.
45
46
  */
46
47
  export declare const DRAFT_ENDED_ENTRY = "camox.draft-ended";
48
+ /**
49
+ * The kind of the transcript entry a Live thread starts afresh from once its agent handed a
50
+ * request off to a draft (ADR 0036): a reset of Pi's context, with a `startedDraftCardSchema` as
51
+ * data. Editors see it as the draft's card, alone, and the model reads a note naming the draft.
52
+ * Everything before it is left out of both.
53
+ */
54
+ export declare const DRAFT_CARD_ENTRY = "camox.draft-card";
47
55
  /**
48
56
  * The kind of the transcript entry recording a member's push to the draft's code from their own
49
57
  * checkout (ADR 0026), with a `pushDataSchema` as data. The model reads it as context, never
@@ -53,8 +61,8 @@ export declare const PUSH_ENTRY = "camox.push";
53
61
  /** How a pushed head's build ended: built, built with type errors, or built but not previewed. */
54
62
  export declare const pushOutcomeSchema: z.ZodEnum<{
55
63
  built: "built";
56
- typeErrors: "typeErrors";
57
64
  notPreviewed: "notPreviewed";
65
+ typeErrors: "typeErrors";
58
66
  }>;
59
67
  export type PushOutcome = z.infer<typeof pushOutcomeSchema>;
60
68
  /**
@@ -64,6 +72,25 @@ export type PushOutcome = z.infer<typeof pushOutcomeSchema>;
64
72
  export declare const START_DRAFT_TOOL = "startDraft";
65
73
  /** The agent's tool building its code changes mid-turn, which the end of a turn also does. */
66
74
  export declare const BUILD_TOOL = "build";
75
+ /** The agent's tool rendering the draft in a browser and returning screenshots to the model. */
76
+ export declare const LOOK_TOOL = "look";
77
+ /**
78
+ * The agent's tool handing an artifact's source to its Artifact Agent, which writes and changes
79
+ * it in a conversation of its own and answers the agent (ADR 0035).
80
+ */
81
+ export declare const ARTIFACT_TOOL = "artifact";
82
+ /**
83
+ * The kind of the entry recording a request the agent sent an Artifact Agent, in the Artifact
84
+ * Agent's own conversation, which editors never see: who the run acts for and the operation ids
85
+ * of its messages, as data (`artifactRequestDataSchema`).
86
+ */
87
+ export declare const ARTIFACT_REQUEST_ENTRY = "camox.artifact-request";
88
+ /** What an Artifact Agent's request records: the member the run acts for, and its messages. */
89
+ export declare const artifactRequestDataSchema: z.ZodObject<{
90
+ member: z.ZodString;
91
+ operationIds: z.ZodArray<z.ZodString>;
92
+ }, z.core.$strip>;
93
+ export type ArtifactRequestData = z.infer<typeof artifactRequestDataSchema>;
67
94
  /**
68
95
  * The tools whose calls change a draft: the content tools that write, and the code tools that
69
96
  * write files. The model calls the code tools, and code mode scripts call both. A test in the API
@@ -147,21 +174,17 @@ export declare const pushDataSchema: z.ZodObject<{
147
174
  subjects: z.ZodArray<z.ZodString>;
148
175
  outcome: z.ZodEnum<{
149
176
  built: "built";
150
- typeErrors: "typeErrors";
151
177
  notPreviewed: "notPreviewed";
178
+ typeErrors: "typeErrors";
152
179
  }>;
153
180
  }, z.core.$strip>;
154
181
  export type PushData = z.infer<typeof pushDataSchema>;
155
- /**
156
- * What an editor's message entry records: who sent it, the operation id it was sent with, and for
157
- * a message sent on Live as the agent handed the request off, the draft it went to with it.
158
- */
182
+ /** What an editor's message entry records: who sent it, and the operation id it was sent with. */
159
183
  export declare const editorMessageDataSchema: z.ZodObject<{
160
184
  id: z.ZodString;
161
185
  name: z.ZodString;
162
186
  image: z.ZodNullable<z.ZodString>;
163
187
  operationId: z.ZodOptional<z.ZodString>;
164
- handedOffTo: z.ZodOptional<z.ZodString>;
165
188
  }, z.core.$strip>;
166
189
  /**
167
190
  * A draft the agent on Live started with `startDraft`, and the operation ids of the messages of
@@ -176,18 +199,18 @@ export type StartedDraft = z.infer<typeof startedDraftSchema>;
176
199
  /** How a write touched what it names. */
177
200
  export declare const touchKindSchema: z.ZodEnum<{
178
201
  created: "created";
202
+ deleted: "deleted";
179
203
  edited: "edited";
180
204
  moved: "moved";
181
- deleted: "deleted";
182
205
  settings: "settings";
183
206
  }>;
184
207
  export type TouchKind = z.infer<typeof touchKindSchema>;
185
208
  export declare const touchSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
186
209
  kind: z.ZodEnum<{
187
210
  created: "created";
211
+ deleted: "deleted";
188
212
  edited: "edited";
189
213
  moved: "moved";
190
- deleted: "deleted";
191
214
  settings: "settings";
192
215
  }>;
193
216
  locale: z.ZodOptional<z.ZodString>;
@@ -197,9 +220,9 @@ export declare const touchSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
197
220
  }, z.core.$strip>, z.ZodObject<{
198
221
  kind: z.ZodEnum<{
199
222
  created: "created";
223
+ deleted: "deleted";
200
224
  edited: "edited";
201
225
  moved: "moved";
202
- deleted: "deleted";
203
226
  settings: "settings";
204
227
  }>;
205
228
  locale: z.ZodOptional<z.ZodString>;
@@ -208,9 +231,9 @@ export declare const touchSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
208
231
  }, z.core.$strip>, z.ZodObject<{
209
232
  kind: z.ZodEnum<{
210
233
  created: "created";
234
+ deleted: "deleted";
211
235
  edited: "edited";
212
236
  moved: "moved";
213
- deleted: "deleted";
214
237
  settings: "settings";
215
238
  }>;
216
239
  locale: z.ZodOptional<z.ZodString>;
@@ -228,9 +251,9 @@ export declare const touchedBatchSchema: z.ZodObject<{
228
251
  touches: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
229
252
  kind: z.ZodEnum<{
230
253
  created: "created";
254
+ deleted: "deleted";
231
255
  edited: "edited";
232
256
  moved: "moved";
233
- deleted: "deleted";
234
257
  settings: "settings";
235
258
  }>;
236
259
  locale: z.ZodOptional<z.ZodString>;
@@ -240,9 +263,9 @@ export declare const touchedBatchSchema: z.ZodObject<{
240
263
  }, z.core.$strip>, z.ZodObject<{
241
264
  kind: z.ZodEnum<{
242
265
  created: "created";
266
+ deleted: "deleted";
243
267
  edited: "edited";
244
268
  moved: "moved";
245
- deleted: "deleted";
246
269
  settings: "settings";
247
270
  }>;
248
271
  locale: z.ZodOptional<z.ZodString>;
@@ -251,9 +274,9 @@ export declare const touchedBatchSchema: z.ZodObject<{
251
274
  }, z.core.$strip>, z.ZodObject<{
252
275
  kind: z.ZodEnum<{
253
276
  created: "created";
277
+ deleted: "deleted";
254
278
  edited: "edited";
255
279
  moved: "moved";
256
- deleted: "deleted";
257
280
  settings: "settings";
258
281
  }>;
259
282
  locale: z.ZodOptional<z.ZodString>;
@@ -336,10 +359,40 @@ export type ThreadMessage = {
336
359
  * - `changing`: a call of that round changes the draft (`CHANGING_TOOLS`), as soon as it's written
337
360
  * or, in a code mode script, as soon as the script calls one.
338
361
  * - `building`: its `build` call runs, or the end of the turn builds its code changes.
362
+ * - `checking`: it looks at what it designed, from writing a `look` call until the model is
363
+ * called again.
339
364
  * - `fixing`: the end of the turn's build failed, and the agent fixes it.
340
365
  * - `startingDraft`: on Live, its `startDraft` call runs.
341
366
  */
342
- export type AgentActivity = "thinking" | "exploring" | "changing" | "building" | "fixing" | "startingDraft";
367
+ export declare const agentActivitySchema: z.ZodEnum<{
368
+ building: "building";
369
+ changing: "changing";
370
+ checking: "checking";
371
+ exploring: "exploring";
372
+ fixing: "fixing";
373
+ startingDraft: "startingDraft";
374
+ thinking: "thinking";
375
+ }>;
376
+ export type AgentActivity = z.infer<typeof agentActivitySchema>;
377
+ /**
378
+ * What an `artifact` call's result carries for the studio: the Artifact Agent's answer, whether
379
+ * it's the agent's answer to the turn too, which then ends on it, and while it works, what the
380
+ * Artifact Agent is doing.
381
+ */
382
+ export declare const artifactDetailsSchema: z.ZodObject<{
383
+ answer: z.ZodOptional<z.ZodString>;
384
+ final: z.ZodOptional<z.ZodBoolean>;
385
+ activity: z.ZodOptional<z.ZodEnum<{
386
+ building: "building";
387
+ changing: "changing";
388
+ checking: "checking";
389
+ exploring: "exploring";
390
+ fixing: "fixing";
391
+ startingDraft: "startingDraft";
392
+ thinking: "thinking";
393
+ }>>;
394
+ }, z.core.$strip>;
395
+ export type ArtifactDetails = z.infer<typeof artifactDetailsSchema>;
343
396
  /** Everything the studio shows for a thread. */
344
397
  export type ThreadView = {
345
398
  messages: readonly ThreadMessage[];
@@ -369,6 +422,10 @@ export type ThreadState = {
369
422
  * or making it until the model is called again.
370
423
  */
371
424
  changing?: boolean;
425
+ /** Whether the model's latest round calls `look`: from writing the call until it's called again. */
426
+ checking?: boolean;
427
+ /** What the Artifact Agent the running `artifact` call waits for is doing, as it last said. */
428
+ artifactActivity?: AgentActivity;
372
429
  /** The drafts the thread's cards name, as the thread last looked them up. */
373
430
  drafts?: DraftCardStates;
374
431
  };
@@ -380,8 +437,6 @@ type ThreadStep = {
380
437
  type: "editor";
381
438
  sender: ThreadSender;
382
439
  text: string;
383
- /** The draft the message went to, as the agent on Live handed the request off. */
384
- handedOffTo?: string;
385
440
  } | {
386
441
  type: "connectedAgent";
387
442
  member: ThreadSender;
@@ -559,7 +614,7 @@ export declare const editorTextOf: (content: Message["content"]) => string;
559
614
  * run is over, or a later message started another run after its last model call came back
560
615
  * unfinished. While Pi retries a failed call, the run goes on, so the turn shows as working.
561
616
  */
562
- export declare function threadViewOf({ steps, running, toolCalls, callingTools, changing, drafts }: ThreadState): ThreadView;
617
+ export declare function threadViewOf({ steps, running, toolCalls, callingTools, changing, checking, artifactActivity, drafts }: ThreadState): ThreadView;
563
618
  /** Folds one of Pi's agent events into the thread's state. */
564
619
  export declare function reduceThreadState(state: ThreadState, event: AgentEvent): ThreadState;
565
620
  /** Folds a batch of Pi's agent events into the thread's state. */
package/dist/threads.js CHANGED
@@ -33,7 +33,8 @@ const RECONCILE_ENTRY = "camox.reconcile";
33
33
  /**
34
34
  * The kind of the transcript entry opening a draft's thread a Live thread handed a request off
35
35
  * to: the Brief, which the model reads and editors see as from Camox, ahead of the editor's
36
- * messages.
36
+ * messages. In a draft Camox opened, such as its Patrol Draft, Camox's own messages are Briefs
37
+ * too, with their `operationId` as data, and start the agent's run, which acts for Camox.
37
38
  */
38
39
  const BRIEF_ENTRY = "camox.brief";
39
40
  /**
@@ -43,6 +44,13 @@ const BRIEF_ENTRY = "camox.brief";
43
44
  */
44
45
  const DRAFT_ENDED_ENTRY = "camox.draft-ended";
45
46
  /**
47
+ * The kind of the transcript entry a Live thread starts afresh from once its agent handed a
48
+ * request off to a draft (ADR 0036): a reset of Pi's context, with a `startedDraftCardSchema` as
49
+ * data. Editors see it as the draft's card, alone, and the model reads a note naming the draft.
50
+ * Everything before it is left out of both.
51
+ */
52
+ const DRAFT_CARD_ENTRY = "camox.draft-card";
53
+ /**
46
54
  * The kind of the transcript entry recording a member's push to the draft's code from their own
47
55
  * checkout (ADR 0026), with a `pushDataSchema` as data. The model reads it as context, never
48
56
  * answering it, and editors see who pushed, their commits, and whether they built.
@@ -61,6 +69,24 @@ const pushOutcomeSchema = z.enum([
61
69
  const START_DRAFT_TOOL = "startDraft";
62
70
  /** The agent's tool building its code changes mid-turn, which the end of a turn also does. */
63
71
  const BUILD_TOOL = "build";
72
+ /** The agent's tool rendering the draft in a browser and returning screenshots to the model. */
73
+ const LOOK_TOOL = "look";
74
+ /**
75
+ * The agent's tool handing an artifact's source to its Artifact Agent, which writes and changes
76
+ * it in a conversation of its own and answers the agent (ADR 0035).
77
+ */
78
+ const ARTIFACT_TOOL = "artifact";
79
+ /**
80
+ * The kind of the entry recording a request the agent sent an Artifact Agent, in the Artifact
81
+ * Agent's own conversation, which editors never see: who the run acts for and the operation ids
82
+ * of its messages, as data (`artifactRequestDataSchema`).
83
+ */
84
+ const ARTIFACT_REQUEST_ENTRY = "camox.artifact-request";
85
+ /** What an Artifact Agent's request records: the member the run acts for, and its messages. */
86
+ const artifactRequestDataSchema = z.object({
87
+ member: z.string(),
88
+ operationIds: z.array(z.string())
89
+ });
64
90
  /**
65
91
  * The tools whose calls change a draft: the content tools that write, and the code tools that
66
92
  * write files. The model calls the code tools, and code mode scripts call both. A test in the API
@@ -69,6 +95,7 @@ const BUILD_TOOL = "build";
69
95
  const CHANGING_TOOLS = /* @__PURE__ */ new Set([
70
96
  "addBackToLocale",
71
97
  "addLocale",
98
+ "applyFindingFix",
72
99
  "createBlock",
73
100
  "createCollectionRecord",
74
101
  "createPage",
@@ -128,14 +155,8 @@ const pushDataSchema = z.object({
128
155
  subjects: z.array(z.string()),
129
156
  outcome: pushOutcomeSchema
130
157
  });
131
- /**
132
- * What an editor's message entry records: who sent it, the operation id it was sent with, and for
133
- * a message sent on Live as the agent handed the request off, the draft it went to with it.
134
- */
135
- const editorMessageDataSchema = threadSenderSchema.extend({
136
- operationId: z.string().optional(),
137
- handedOffTo: z.string().optional()
138
- });
158
+ /** What an editor's message entry records: who sent it, and the operation id it was sent with. */
159
+ const editorMessageDataSchema = threadSenderSchema.extend({ operationId: z.string().optional() });
139
160
  /**
140
161
  * A draft the agent on Live started with `startDraft`, and the operation ids of the messages of
141
162
  * the run that started it: the studio that sent one of them enters the draft, if it still shows
@@ -189,6 +210,37 @@ const touchedBatchSchema = z.object({
189
210
  operationIds: z.array(z.string()),
190
211
  touches: z.array(touchSchema)
191
212
  });
213
+ /**
214
+ * What the agent is doing during a run, as editors see it, without the details of how it works:
215
+ * - `thinking`: the model is called, and hasn't started writing a tool call.
216
+ * - `exploring`: it uses tools that only read, from writing a call until the model is called again.
217
+ * - `changing`: a call of that round changes the draft (`CHANGING_TOOLS`), as soon as it's written
218
+ * or, in a code mode script, as soon as the script calls one.
219
+ * - `building`: its `build` call runs, or the end of the turn builds its code changes.
220
+ * - `checking`: it looks at what it designed, from writing a `look` call until the model is
221
+ * called again.
222
+ * - `fixing`: the end of the turn's build failed, and the agent fixes it.
223
+ * - `startingDraft`: on Live, its `startDraft` call runs.
224
+ */
225
+ const agentActivitySchema = z.enum([
226
+ "thinking",
227
+ "exploring",
228
+ "changing",
229
+ "building",
230
+ "checking",
231
+ "fixing",
232
+ "startingDraft"
233
+ ]);
234
+ /**
235
+ * What an `artifact` call's result carries for the studio: the Artifact Agent's answer, whether
236
+ * it's the agent's answer to the turn too, which then ends on it, and while it works, what the
237
+ * Artifact Agent is doing.
238
+ */
239
+ const artifactDetailsSchema = z.object({
240
+ answer: z.string().optional(),
241
+ final: z.boolean().optional(),
242
+ activity: agentActivitySchema.optional()
243
+ });
192
244
  const EMPTY_THREAD_VIEW = {
193
245
  messages: [],
194
246
  running: false
@@ -303,19 +355,23 @@ function threadStepOf(entry) {
303
355
  ...push
304
356
  };
305
357
  }
358
+ if (entry.kind === "camox.draft-card") {
359
+ const card = startedDraftCardSchema.safeParse(entry.data).data;
360
+ return card && {
361
+ id,
362
+ type: "draft",
363
+ ...card
364
+ };
365
+ }
306
366
  const message = entry.model?.find((candidate) => candidate.role !== "system");
307
367
  if (!message) return void 0;
308
368
  if (message.role === "user") {
309
- if (entry.kind === "camox.editor-message") {
310
- const handedOffTo = editorMessageDataSchema.safeParse(entry.data).data?.handedOffTo;
311
- return sender && {
312
- id,
313
- type: "editor",
314
- sender,
315
- text: editorTextOf(message.content),
316
- ...handedOffTo && { handedOffTo }
317
- };
318
- }
369
+ if (entry.kind === "camox.editor-message") return sender && {
370
+ id,
371
+ type: "editor",
372
+ sender,
373
+ text: editorTextOf(message.content)
374
+ };
319
375
  if (entry.kind === "camox.connected-agent-message") {
320
376
  const data = connectedAgentMessageDataSchema.safeParse(entry.data).data;
321
377
  return data && {
@@ -349,6 +405,14 @@ function threadStepOf(entry) {
349
405
  }
350
406
  if (message.role === "assistant") return assistantStep(id, message);
351
407
  if (message.role === "toolResult") {
408
+ if (message.toolName === "artifact" && !message.isError) {
409
+ const details = artifactDetailsSchema.safeParse(message.details).data;
410
+ if (details?.final && details.answer) return {
411
+ id,
412
+ type: "answer",
413
+ text: details.answer
414
+ };
415
+ }
352
416
  const card = message.toolName === "startDraft" && !message.isError ? startedDraftCardSchema.safeParse(message.details).data : void 0;
353
417
  return card ? {
354
418
  id,
@@ -369,7 +433,7 @@ function threadStepOf(entry) {
369
433
  * run is over, or a later message started another run after its last model call came back
370
434
  * unfinished. While Pi retries a failed call, the run goes on, so the turn shows as working.
371
435
  */
372
- function threadViewOf({ steps, running, toolCalls = [], callingTools = false, changing = false, drafts = {} }) {
436
+ function threadViewOf({ steps, running, toolCalls = [], callingTools = false, changing = false, checking = false, artifactActivity, drafts = {} }) {
373
437
  const messages = [];
374
438
  let waiting;
375
439
  let unfinished = false;
@@ -391,17 +455,7 @@ function threadViewOf({ steps, running, toolCalls = [], callingTools = false, ch
391
455
  endTurn();
392
456
  };
393
457
  for (const step of steps) switch (step.type) {
394
- case "editor": {
395
- const card = step.handedOffTo ? messages.findLastIndex((message) => message.from === "draft" && message.draftId === step.handedOffTo) : -1;
396
- if (card !== -1) {
397
- messages.splice(card, 0, {
398
- id: step.id,
399
- from: "editor",
400
- sender: step.sender,
401
- text: step.text
402
- });
403
- break;
404
- }
458
+ case "editor":
405
459
  if (unfinished) fail();
406
460
  messages.push({
407
461
  id: step.id,
@@ -411,7 +465,6 @@ function threadViewOf({ steps, running, toolCalls = [], callingTools = false, ch
411
465
  });
412
466
  waiting = step.id;
413
467
  break;
414
- }
415
468
  case "connectedAgent":
416
469
  if (unfinished) fail();
417
470
  messages.push({
@@ -507,14 +560,18 @@ function threadViewOf({ steps, running, toolCalls = [], callingTools = false, ch
507
560
  status,
508
561
  toolCalls,
509
562
  callingTools,
510
- changing
563
+ changing,
564
+ checking,
565
+ artifactActivity
511
566
  })
512
567
  };
513
568
  }
514
569
  /** What the agent is doing during a run, from where the turn's build stands and its tool calls. */
515
- function activityOf({ status, toolCalls, callingTools, changing }) {
570
+ function activityOf({ status, toolCalls, callingTools, changing, checking, artifactActivity }) {
516
571
  const calling = (name) => toolCalls.some((call) => call.name === name);
517
572
  if (status === "building" || calling("build")) return "building";
573
+ if (calling("artifact")) return artifactActivity ?? "changing";
574
+ if (checking) return "checking";
518
575
  if (status === "fixing") return "fixing";
519
576
  if (calling("startDraft")) return "startingDraft";
520
577
  if (changing) return "changing";
@@ -525,8 +582,24 @@ function activityOf({ status, toolCalls, callingTools, changing }) {
525
582
  const changes = (name) => CHANGING_TOOLS.has(name);
526
583
  /** Whether a block of the model's message is a call of a tool that changes the draft. */
527
584
  const callsChangingTool = (block) => block.type === "toolCall" && changes(block.name);
585
+ /** Whether a block of the model's message is a call of `look`. */
586
+ const callsLook = (block) => block.type === "toolCall" && block.name === "look";
587
+ /**
588
+ * Adds an entry to the thread's state as Pi places it. An entry heading a new context, such as
589
+ * the card a Live thread starts afresh from, leaves out every step before its head, as Pi's
590
+ * snapshots do.
591
+ */
528
592
  const append = (state, entry) => {
529
- const step = entry && threadStepOf(entry);
593
+ if (!entry) return state;
594
+ const step = threadStepOf(entry);
595
+ if (entry.head !== void 0) {
596
+ const head = Number(entry.head);
597
+ const kept = state.steps.filter((known) => Number(known.id) >= head && known.id !== String(entry.id));
598
+ return {
599
+ ...state,
600
+ steps: step ? [step, ...kept] : kept
601
+ };
602
+ }
530
603
  if (!step || state.steps.some((known) => known.id === step.id)) return state;
531
604
  return {
532
605
  ...state,
@@ -542,12 +615,15 @@ function reduceThreadState(state, event) {
542
615
  name: tool.name
543
616
  }]);
544
617
  const generated = event.generation?.message?.content ?? [];
618
+ const artifact = event.tools.find((tool) => tool.name === "artifact" && tool.status !== "done");
545
619
  return {
546
620
  ...state,
547
621
  steps: event.entries.flatMap((entry) => threadStepOf(entry) ?? []),
622
+ artifactActivity: artifactDetailsSchema.safeParse(artifact?.details).data?.activity,
548
623
  running: event.run !== void 0,
549
624
  toolCalls,
550
625
  callingTools: generated.some((part) => part.type === "toolCall"),
626
+ checking: generated.some(callsLook) || toolCalls.some((call) => call.name === "look"),
551
627
  changing: generated.some(callsChangingTool) || toolCalls.some((call) => changes(call.name)) || event.nestedTools.some((nested) => changes(nested.name) && toolCalls.some((call) => nested.parentCallId === call.callId || nested.parentCallId.startsWith(`${call.callId}/`)))
552
628
  };
553
629
  }
@@ -560,12 +636,15 @@ function reduceThreadState(state, event) {
560
636
  running: false,
561
637
  toolCalls: [],
562
638
  callingTools: false,
563
- changing: false
639
+ changing: false,
640
+ checking: false,
641
+ artifactActivity: void 0
564
642
  };
565
643
  case "message_start": return event.message.role === "assistant" ? {
566
644
  ...state,
567
645
  callingTools: false,
568
- changing: false
646
+ changing: false,
647
+ checking: false
569
648
  } : state;
570
649
  case "message_update": {
571
650
  const calls = event.changes.flatMap((change) => change.type === "toolcall_start" || change.type === "block" ? [change.block] : change.type === "message" ? change.message.content : []);
@@ -573,7 +652,8 @@ function reduceThreadState(state, event) {
573
652
  return {
574
653
  ...state,
575
654
  callingTools: state.callingTools || calls.some((block) => block.type === "toolCall"),
576
- changing: state.changing || calls.some(callsChangingTool)
655
+ changing: state.changing || calls.some(callsChangingTool),
656
+ checking: state.checking || calls.some(callsLook)
577
657
  };
578
658
  }
579
659
  case "tool_execution_start": {
@@ -585,15 +665,25 @@ function reduceThreadState(state, event) {
585
665
  return {
586
666
  ...state,
587
667
  changing,
668
+ checking: state.checking || event.toolName === "look",
588
669
  toolCalls: [...state.toolCalls ?? [], {
589
670
  callId: event.toolCallId,
590
671
  name: event.toolName
591
672
  }]
592
673
  };
593
674
  }
675
+ case "tool_execution_update": {
676
+ if (event.toolName !== "artifact" || event.parentToolCallId !== void 0) return state;
677
+ const activity = artifactDetailsSchema.safeParse(event.details).data?.activity;
678
+ return activity ? {
679
+ ...state,
680
+ artifactActivity: activity
681
+ } : state;
682
+ }
594
683
  case "tool_execution_end": return append({
595
684
  ...state,
596
- toolCalls: state.toolCalls?.filter((call) => call.callId !== event.toolCallId)
685
+ toolCalls: state.toolCalls?.filter((call) => call.callId !== event.toolCallId),
686
+ ...event.toolName === "artifact" && event.parentToolCallId === void 0 && { artifactActivity: void 0 }
597
687
  }, event.entry);
598
688
  case "message_end":
599
689
  case "entry_appended": return append(state, event.entry);
@@ -615,4 +705,4 @@ function reduceThreadFrame(state, frame) {
615
705
  }
616
706
 
617
707
  //#endregion
618
- export { BRIEF_ENTRY, BUILD_STATUS_ENTRY, BUILD_TOOL, CHANGING_TOOLS, CONNECTED_AGENT_MESSAGE_ENTRY, DRAFT_ENDED_ENTRY, EDITOR_MESSAGE_ENTRY, EMPTY_THREAD_STATE, EMPTY_THREAD_VIEW, PUSH_ENTRY, RECONCILE_ENTRY, RUN_STOPPED_ENTRY, START_DRAFT_TOOL, THREAD_ENDED_CLOSE_CODE, buildStatusDataSchema, buildStatusSchema, connectedAgentClientSchema, connectedAgentMessageDataSchema, editorMessageDataSchema, editorSelectionSchema, editorTextOf, editorWhereSchema, isSender, pushDataSchema, pushOutcomeSchema, reconcileDataSchema, reduceThreadEvents, reduceThreadFrame, reduceThreadState, startedDraftCardSchema, startedDraftSchema, textOf, threadClientMessageSchema, threadSenderSchema, threadViewOf, touchKindSchema, touchSchema, touchedBatchSchema };
708
+ export { ARTIFACT_REQUEST_ENTRY, ARTIFACT_TOOL, BRIEF_ENTRY, BUILD_STATUS_ENTRY, BUILD_TOOL, CHANGING_TOOLS, CONNECTED_AGENT_MESSAGE_ENTRY, DRAFT_CARD_ENTRY, DRAFT_ENDED_ENTRY, EDITOR_MESSAGE_ENTRY, EMPTY_THREAD_STATE, EMPTY_THREAD_VIEW, LOOK_TOOL, PUSH_ENTRY, RECONCILE_ENTRY, RUN_STOPPED_ENTRY, START_DRAFT_TOOL, THREAD_ENDED_CLOSE_CODE, agentActivitySchema, artifactDetailsSchema, artifactRequestDataSchema, buildStatusDataSchema, buildStatusSchema, connectedAgentClientSchema, connectedAgentMessageDataSchema, editorMessageDataSchema, editorSelectionSchema, editorTextOf, editorWhereSchema, isSender, pushDataSchema, pushOutcomeSchema, reconcileDataSchema, reduceThreadEvents, reduceThreadFrame, reduceThreadState, startedDraftCardSchema, startedDraftSchema, textOf, threadClientMessageSchema, threadSenderSchema, threadViewOf, touchKindSchema, touchSchema, touchedBatchSchema };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camox/api-contract",
3
- "version": "0.63.0",
3
+ "version": "0.66.0",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "src",
@@ -51,6 +51,10 @@
51
51
  "./router": {
52
52
  "types": "./dist/router.d.ts",
53
53
  "default": "./dist/router.js"
54
+ },
55
+ "./layout-routes": {
56
+ "types": "./dist/layout-routes.d.ts",
57
+ "default": "./dist/layout-routes.js"
54
58
  }
55
59
  },
56
60
  "dependencies": {
@@ -60,7 +64,8 @@
60
64
  },
61
65
  "devDependencies": {
62
66
  "@earendil-works/pi-ai": "1.3.0",
63
- "@earendil-works/pi-durable": "1.3.0"
67
+ "@earendil-works/pi-durable": "1.3.0",
68
+ "tsrs": "0.20.1-ts7.1.0-beta"
64
69
  },
65
70
  "peerDependencies": {
66
71
  "@earendil-works/pi-ai": "1.3.0",
@@ -85,6 +90,7 @@
85
90
  "^production",
86
91
  "{workspaceRoot}/apps/api/src/**/*",
87
92
  "{workspaceRoot}/packages/ai-tools/src/**/*",
93
+ "{workspaceRoot}/tsconfig.dts.api-contract.json",
88
94
  "!{workspaceRoot}/**/*.test.ts"
89
95
  ]
90
96
  }