@inixiative/foundry-core 0.5.1 → 0.5.3

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/src/index.ts CHANGED
@@ -36,6 +36,7 @@ export { HttpMemory } from './adapters/http-memory';
36
36
  export {
37
37
  claudemdSource,
38
38
  formatInstructionFiles,
39
+ INSTRUCTION_FILE_LIMIT,
39
40
  type InstructionFile,
40
41
  type InstructionReadOptions,
41
42
  instructionImports,
@@ -116,6 +117,7 @@ export {
116
117
  } from './classifier';
117
118
  // Context primitives
118
119
  export {
120
+ type CompositionSnapshot,
119
121
  ContextLayer,
120
122
  type ContextLayerConfig,
121
123
  type ContextSource,
@@ -131,9 +133,13 @@ export {
131
133
  type LayerState,
132
134
  type LayerVersionMark,
133
135
  type LogicalMessageIdentity,
136
+ type OmittedSource,
134
137
  REQUIRED_CONTEXT_BLOCKED,
135
138
  type SourceLoadHint,
139
+ type SourcePart,
140
+ type SourceSegment,
136
141
  type SourceSelectionReport,
142
+ segmentsText,
137
143
  type VersionEntry,
138
144
  type VersionLog,
139
145
  } from './context-layer';
@@ -184,6 +190,94 @@ export {
184
190
  scrubSecrets,
185
191
  type TranscriptTurn,
186
192
  } from './feedback/correction';
193
+ export {
194
+ DESIGN_SECTIONS,
195
+ type ExperimentRecord,
196
+ experimentProblems,
197
+ requireExperiment,
198
+ reviewPathOf,
199
+ TINY_MOMENTS,
200
+ } from './feedback/experiment-gate';
201
+ export {
202
+ AUTHORSHIP_MARKERS,
203
+ authorshipOf,
204
+ evidenceSnippet,
205
+ type FindingScope,
206
+ parseReviewFindings,
207
+ REUSE_HINT,
208
+ REVIEW_FINDINGS_PROMPT,
209
+ type ReviewFinding,
210
+ type ReviewMoment,
211
+ type ReviewReading,
212
+ reviewFindingMessages,
213
+ SCOPE_WEIGHT,
214
+ type SessionEvidence,
215
+ styleOf,
216
+ } from './feedback/review-findings';
217
+ export {
218
+ type DomainAgreement,
219
+ fixtureProbe,
220
+ labelAgreement,
221
+ type ParsedWardenLabels,
222
+ parseWardenLabels,
223
+ type UnlabelledFixture,
224
+ WARDEN_LABEL_PROMPT,
225
+ type WardenFixture,
226
+ type WardenLabel,
227
+ type WardenRosterEntry,
228
+ type WardenTriggerKind,
229
+ wardenLabelMessages,
230
+ wardenLabelPrefix,
231
+ } from './feedback/warden-labels';
232
+ export {
233
+ PREFILTER_CONTEXT_CHARS,
234
+ PREFILTER_DESCRIPTION_CHARS,
235
+ PREFILTER_MOMENT_CHARS,
236
+ PREFILTER_SWEEP,
237
+ type PrefilterPair,
238
+ type PrefilterPoint,
239
+ type PrefilterScore,
240
+ type PrefilterTrigger,
241
+ percentiles,
242
+ prefilterConsistency,
243
+ prefilterDescription,
244
+ prefilterQuestion,
245
+ prefilterSkips,
246
+ prefilterState,
247
+ scorePrefilter,
248
+ } from './feedback/warden-prefilter';
249
+ export {
250
+ type Authorship,
251
+ type CharterScore,
252
+ CONCEPT_CLUSTERS,
253
+ CORRECTION_TARGET_PROMPT,
254
+ type CorrectionTarget,
255
+ correctionTargetMessages,
256
+ MISS_KINDS,
257
+ type MissKind,
258
+ POINTER_LEVELS,
259
+ type PointerLevel,
260
+ type ProbeSource,
261
+ parseCorrectionTargets,
262
+ parseTargetCanonical,
263
+ parseWardenJudgement,
264
+ parseWardenPointerJudgement,
265
+ probeTriggers,
266
+ scoreCharterRun,
267
+ TARGET_CANONICAL_PROMPT,
268
+ targetCanonicalMessages,
269
+ WARDEN_JUDGE_PROMPT,
270
+ WARDEN_POINTER_JUDGE_PROMPT,
271
+ type WardenJudgement,
272
+ type WardenPointerJudgement,
273
+ type WardenProbe,
274
+ type WardenProbeAnswer,
275
+ type WardenProbeTrigger,
276
+ type WardenProbeTurn,
277
+ wardenJudgeMessage,
278
+ wardenPointerJudgeMessage,
279
+ wilsonInterval,
280
+ } from './feedback/warden-probes';
187
281
  export {
188
282
  type FlowConfig,
189
283
  type FlowStage,
@@ -297,6 +391,8 @@ export {
297
391
  type ThreadMeta,
298
392
  type ThreadName,
299
393
  type ThreadReference,
394
+ type ThreadSetup,
395
+ type ThreadSpawn,
300
396
  type ThreadStatus,
301
397
  threadTitle,
302
398
  } from './thread';
package/src/messages.ts CHANGED
@@ -1,4 +1,8 @@
1
- import type { LayerInstanceState, LogicalMessageIdentity } from './context-layer';
1
+ import type {
2
+ CompositionSnapshot,
3
+ LayerInstanceState,
4
+ LogicalMessageIdentity,
5
+ } from './context-layer';
2
6
  import { computeHash } from './context-layer';
3
7
  import type { AssembledContext, PromptBlock } from './context-stack';
4
8
  import type { ServedModel } from './native-evidence';
@@ -27,7 +31,7 @@ export interface InjectionBlock {
27
31
  /** One decorator's recorded participation in a turn. */
28
32
  export interface DecorationParticipant {
29
33
  readonly id: string;
30
- /** contribute | abstain | error | timeout | omitted */
34
+ /** contribute | no-comment | skipped | error | timeout | excluded | omitted */
31
35
  readonly decision: string;
32
36
  readonly reason?: string;
33
37
  /** The three named inputs the participant worked from, never inferred. */
@@ -55,6 +59,8 @@ export type ParticipantRequest =
55
59
  readonly capturedAt: number;
56
60
  /** The model and effort that answered, when the provider answered before the phase sealed. */
57
61
  readonly served?: ServedModel;
62
+ /** What the call's instructions and domain knowledge were composed of; the journal stores version ids for it. */
63
+ readonly composition?: CompositionSnapshot;
58
64
  }
59
65
  | { readonly status: 'not-sent'; readonly phase: string; readonly reason: string }
60
66
  /** A call may have been made, but its input was never observed (e.g. the caller threw first). Not "not-sent". */
@@ -34,6 +34,26 @@ export interface OwnedAdmissionInspection {
34
34
  readonly cleanup: 'not-requested' | 'pending' | 'released' | 'unknown';
35
35
  readonly capacity: 'settled' | 'unknown';
36
36
  }
37
+ /** A native subagent's lifecycle event (agent-session `SubagentLifecycle`, allowlisted). */
38
+ export interface NativeSubagentLifecycle {
39
+ readonly phase: 'started' | 'progress' | 'updated' | 'ended';
40
+ readonly taskId: string;
41
+ readonly toolUseId?: string;
42
+ readonly parentTaskId?: string;
43
+ readonly agentType?: string;
44
+ readonly description?: string;
45
+ readonly depth?: number;
46
+ readonly backgrounded?: boolean;
47
+ readonly status?: string;
48
+ readonly summary?: string;
49
+ readonly prompt?: string;
50
+ readonly usage?: {
51
+ readonly totalTokens: number;
52
+ readonly toolUses?: number;
53
+ readonly durationMs?: number;
54
+ };
55
+ }
56
+
37
57
  export interface NativeEvidence {
38
58
  readonly schema: 1;
39
59
  readonly executionMode?: 'controlled-fixture';
@@ -65,6 +85,10 @@ export interface NativeEvidence {
65
85
  readonly content?: string;
66
86
  readonly correlation?: string;
67
87
  readonly kind?: string;
88
+ /** The parent's tool call that spawned the subagent this came from (absent for the thread's own). */
89
+ readonly parentToolUseId?: string;
90
+ /** A subagent's lifecycle (kind `subagent`), as the runtime reported it. */
91
+ readonly subagent?: NativeSubagentLifecycle;
68
92
  readonly toolName?: string;
69
93
  readonly toolServer?: string;
70
94
  readonly toolMethod?: string;
package/src/thread.ts CHANGED
@@ -44,6 +44,21 @@ export function threadTitle(
44
44
  return meta.description ? { text: meta.description, source: 'description' } : undefined;
45
45
  }
46
46
 
47
+ /** How a subagent thread came to be: who spawned it, through what, and its native identity. */
48
+ export interface ThreadSpawn {
49
+ readonly via: 'foundry' | 'native-claude' | 'native-codex' | 'host-paseo' | 'host-t3';
50
+ /** The parent's tool call that spawned it. */
51
+ readonly toolCallId?: string;
52
+ /** The native run's id (Claude task id, Codex child thread id). */
53
+ readonly nativeTaskId?: string;
54
+ readonly agentType?: string;
55
+ readonly description?: string;
56
+ /** The parent's `handoff` phase row for this spawn. */
57
+ readonly handoffId?: string;
58
+ /** Recorded from the native stream only: no Foundry middleware ran on it. */
59
+ readonly observed?: boolean;
60
+ }
61
+
47
62
  export interface ThreadMeta {
48
63
  /** Living description — what this thread is doing right now. */
49
64
  description: string;
@@ -72,6 +87,21 @@ export interface ThreadMeta {
72
87
  /** Parent thread when this thread is a subagent spawned by another. */
73
88
  parentThreadId?: string;
74
89
 
90
+ /** The parent's turn that spawned this thread (a subagent). */
91
+ parentTurnId?: string;
92
+
93
+ /** How this subagent thread was spawned (docs/reference/SUBAGENTS.md §4.1). */
94
+ spawn?: ThreadSpawn;
95
+
96
+ /** 1 for a child of a main thread. */
97
+ depth?: number;
98
+
99
+ /**
100
+ * Start-up of a thread whose Wardens are held in its own process (docs/THREAD-TREE.md spec C):
101
+ * turns typed meanwhile wait as `queued` until it is `ready` (or `degraded`).
102
+ */
103
+ setup?: ThreadSetup;
104
+
75
105
  /** Project that owns this thread. Scopes memory sources and tool calls. */
76
106
  projectId?: string;
77
107
 
@@ -85,6 +115,15 @@ export interface ThreadMeta {
85
115
  archivedAt?: number;
86
116
  }
87
117
 
118
+ export interface ThreadSetup {
119
+ status: 'starting' | 'ready' | 'degraded';
120
+ startedAt: number;
121
+ readyAt?: number;
122
+ /** Every configured Warden, those holding a spare, and those that did not by the deadline. */
123
+ wardens: { expected: number; held: number; failed: string[] };
124
+ runtime: 'claude-in-session' | 'codex-in-process' | 'side-session';
125
+ }
126
+
88
127
  export interface Dispatch<T = unknown> {
89
128
  readonly agentId: string;
90
129
  readonly timestamp: number;
package/src/types.ts CHANGED
@@ -114,6 +114,11 @@ export interface CompletionOpts {
114
114
  * cached prefix; others ignore it. Messages are sent unchanged either way.
115
115
  */
116
116
  stablePrefix?: string;
117
+ /**
118
+ * Text right after `stablePrefix` that changes only between turns (a Warden's thread knowledge and
119
+ * the thread state). Providers that pre-start a call shape hold it; others ignore it.
120
+ */
121
+ threadPrefix?: string;
117
122
  /**
118
123
  * The executor's context split into standing parts and per-turn text. A provider that keeps a
119
124
  * native session delivers standing parts once and then only what changed (session-delivery.ts);
@@ -175,6 +180,13 @@ export interface LLMProvider {
175
180
  };
176
181
  complete(messages: LLMMessage[], opts?: CompletionOpts): Promise<CompletionResult>;
177
182
  stream?(messages: LLMMessage[], opts?: CompletionOpts): AsyncGenerator<LLMStreamEvent>;
183
+ /**
184
+ * Keep this call shape pre-started, so a later `complete` with the same `stablePrefix` and
185
+ * `threadPrefix` starts at once. `messages` end at those prefixes; no decision is made. Optional.
186
+ */
187
+ prestart?(messages: LLMMessage[], opts: CompletionOpts): void;
188
+ /** A thread closed: release whatever the provider holds for it. Optional. */
189
+ releaseThread?(threadId: string): Promise<void>;
178
190
  }
179
191
 
180
192
  export interface EmbeddingProvider {