@inixiative/foundry-core 0.5.12 → 0.5.14

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inixiative/foundry-core",
3
- "version": "0.5.12",
3
+ "version": "0.5.14",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
@@ -33,7 +33,7 @@
33
33
  "bun": ">=1.4.4"
34
34
  },
35
35
  "peerDependencies": {
36
- "@inixiative/archive": "^0.33.0"
36
+ "@inixiative/archive": "^0.34.0"
37
37
  },
38
38
  "peerDependenciesMeta": {
39
39
  "@inixiative/archive": {
@@ -41,6 +41,6 @@
41
41
  }
42
42
  },
43
43
  "devDependencies": {
44
- "@inixiative/archive": "^0.33.1"
44
+ "@inixiative/archive": "^0.34.0"
45
45
  }
46
46
  }
@@ -42,6 +42,8 @@ export type StreamEvent =
42
42
  message: string;
43
43
  severity: 'error' | 'warn';
44
44
  timestamp: number;
45
+ /** The thread the error is about, when it is one thread's (the viewer shows it on that thread). */
46
+ threadId?: string;
45
47
  }
46
48
  | ({ kind: 'activity'; timestamp: number } & SystemActivity);
47
49
 
@@ -142,9 +144,21 @@ export class EventStream {
142
144
  return events.slice(-limit);
143
145
  }
144
146
 
145
- /** Push an error event — surfaced as a toast in the viewer UI. */
146
- pushError(source: string, message: string, severity: 'error' | 'warn' = 'error'): void {
147
- this.push({ kind: 'error', source, message, severity, timestamp: Date.now() });
147
+ /** Push an error event — surfaced as a toast in the viewer UI, on its thread when it names one. */
148
+ pushError(
149
+ source: string,
150
+ message: string,
151
+ severity: 'error' | 'warn' = 'error',
152
+ threadId?: string,
153
+ ): void {
154
+ this.push({
155
+ kind: 'error',
156
+ source,
157
+ message,
158
+ severity,
159
+ timestamp: Date.now(),
160
+ ...(threadId ? { threadId } : {}),
161
+ });
148
162
  }
149
163
 
150
164
  /** Push what the system is doing (shown above the composer, never as a toast). */
package/src/index.ts CHANGED
@@ -418,6 +418,8 @@ export {
418
418
  type FanResult,
419
419
  Thread,
420
420
  type ThreadAgentStatus,
421
+ type ThreadArtifact,
422
+ type ThreadArtifactKind,
421
423
  type ThreadCheckout,
422
424
  type ThreadConfig,
423
425
  type ThreadContext,
@@ -431,6 +433,7 @@ export {
431
433
  type ThreadPlan,
432
434
  type ThreadPlanItem,
433
435
  type ThreadReference,
436
+ type ThreadScheduled,
434
437
  type ThreadSnooze,
435
438
  type ThreadSpawn,
436
439
  type ThreadStatus,
package/src/thread.ts CHANGED
@@ -68,7 +68,7 @@ export interface ThreadPlanItem {
68
68
 
69
69
  /**
70
70
  * The thread's plan, written by its agent through Foundry's `set_plan` tool. Outcomes are what the
71
- * person gets (`you`: waits on the person); pains what hurts today; strategy how the work goes;
71
+ * person gets (`you`: waits on the person, shown in Plan, never Attention); pains what hurts today; strategy how the work goes;
72
72
  * reasons why this way. Each technical row names, per concern (auth, permissions, db access,
73
73
  * requests, locks, jobs, events, errors…), the existing system it uses and where, or why none fits.
74
74
  */
@@ -95,6 +95,26 @@ export interface ThreadPlan {
95
95
  readonly updatedAt: number;
96
96
  }
97
97
 
98
+ /** How an artifact renders: Markdown, a Mermaid diagram, an HTML page (scripts run sandboxed) or code. */
99
+ export type ThreadArtifactKind = 'markdown' | 'mermaid' | 'html' | 'code';
100
+
101
+ /**
102
+ * One artifact the thread's agent made with `set_artifact`, as the thread lists it: what it is and
103
+ * its versions. The content of each version is a journal row (`artifact` phase), read on demand.
104
+ */
105
+ export interface ThreadArtifact {
106
+ readonly id: string;
107
+ readonly title: string;
108
+ readonly kind: ThreadArtifactKind;
109
+ readonly versions: readonly {
110
+ readonly version: number;
111
+ /** The turn that wrote it, when one was running: the conversation shows its card there. */
112
+ readonly turnId: string | null;
113
+ readonly at: number;
114
+ }[];
115
+ readonly updatedAt: number;
116
+ }
117
+
98
118
  /** One round of a thread's loop: how it went and what it found. */
99
119
  export interface ThreadLoopRound {
100
120
  readonly round: number;
@@ -194,6 +214,15 @@ export interface ThreadFork {
194
214
  readonly journalSeq: number;
195
215
  }
196
216
 
217
+ /** The schedule run a thread was started for (provenance; a run is top-level). */
218
+ export interface ThreadScheduled {
219
+ readonly scheduleId: string;
220
+ /** The run's id, `schedule:<scheduleId>:<dueAt>`: one run per due time. */
221
+ readonly runId: string;
222
+ /** When the run was due (epoch ms). */
223
+ readonly dueAt: number;
224
+ }
225
+
197
226
  /** How a subagent thread came to be: who spawned it, through what, and its native identity. */
198
227
  export interface ThreadSpawn {
199
228
  readonly via: 'foundry' | 'native-claude' | 'native-codex' | 'host-paseo' | 'host-t3';
@@ -241,6 +270,8 @@ export interface ThreadMeta {
241
270
  plan?: ThreadPlan;
242
271
  /** The process the agent repeats to reach the plan (`set_loop`, the Loop view). */
243
272
  loop?: ThreadLoop;
273
+ /** What the agent made to show the person (`set_artifact`, the Artifacts view), newest last. */
274
+ artifacts?: ThreadArtifact[];
244
275
  /** Where the agent says it stands: waiting on the person or blocked (`set_status`). */
245
276
  agentStatus?: ThreadAgentStatus;
246
277
  /** The machine (Foundry device identity, `~/.foundry/device.json`) the thread runs on. */
@@ -270,6 +301,9 @@ export interface ThreadMeta {
270
301
  /** The thread and point this one was forked from (provenance; a fork is top-level). */
271
302
  forkedFrom?: ThreadFork;
272
303
 
304
+ /** The schedule run this thread was started for. */
305
+ scheduledBy?: ThreadScheduled;
306
+
273
307
  /** How this subagent thread was spawned. */
274
308
  spawn?: ThreadSpawn;
275
309
 
@@ -387,6 +421,8 @@ export interface ThreadConfig {
387
421
  parentThreadId?: string;
388
422
  /** The thread and point this one was forked from. */
389
423
  forkedFrom?: ThreadFork;
424
+ /** The schedule run this thread was started for. */
425
+ scheduledBy?: ThreadScheduled;
390
426
  /** Project that owns this thread. Scopes memory sources and tool calls. */
391
427
  projectId?: string;
392
428
  /** The harness running this thread's main session. */
@@ -444,6 +480,7 @@ export class Thread {
444
480
  branch: opts?.branch,
445
481
  parentThreadId: opts?.parentThreadId,
446
482
  ...(opts?.forkedFrom ? { forkedFrom: opts.forkedFrom } : {}),
483
+ ...(opts?.scheduledBy ? { scheduledBy: opts.scheduledBy } : {}),
447
484
  projectId: opts?.projectId,
448
485
  ...(opts?.worker ? { worker: opts.worker } : {}),
449
486
  ...(opts?.role ? { role: opts.role } : {}),