@noetic-tools/types 1.0.0 → 1.0.2

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
@@ -22,6 +22,7 @@ export * from './types/runtime.js';
22
22
  export * from './types/shell-adapter.js';
23
23
  export * from './types/steering.js';
24
24
  export * from './types/step.js';
25
+ export * from './types/sub-harness.js';
25
26
  export * from './types/subprocess-adapter.js';
26
27
  export * from './types/tool.js';
27
28
  export * from './types/tool-context.js';
package/dist/index.js CHANGED
@@ -22,6 +22,7 @@ export * from './types/runtime.js';
22
22
  export * from './types/shell-adapter.js';
23
23
  export * from './types/steering.js';
24
24
  export * from './types/step.js';
25
+ export * from './types/sub-harness.js';
25
26
  export * from './types/subprocess-adapter.js';
26
27
  export * from './types/tool.js';
27
28
  export * from './types/tool-context.js';
@@ -9,7 +9,7 @@ import type { FsAdapter } from './fs-adapter.js';
9
9
  import type { HarnessResponse, StreamEvent, StreamingItem } from './harness-result.js';
10
10
  import type { ExecuteInput } from './items.js';
11
11
  import type { ContextMemory, MemoryLayer, ProjectionPolicy, StorageAdapter } from './memory.js';
12
- import type { Span } from './observability.js';
12
+ import type { Span, TraceExporter } from './observability.js';
13
13
  import type { ShellAdapter } from './shell-adapter.js';
14
14
  import type { SteeringDecision } from './steering.js';
15
15
  import type { SubprocessAdapter } from './subprocess-adapter.js';
@@ -152,6 +152,8 @@ export interface ContextHarness {
152
152
  checkpoint(ctx: Context): Promise<void>;
153
153
  restore(executionId: string): Promise<Context | null>;
154
154
  cancel(ctx: Context, reason?: string): Promise<void>;
155
+ /** Trace exporter spans are flushed to. Defaults to a no-op exporter. */
156
+ readonly traceExporter: TraceExporter;
155
157
  createSpan(name: string, parent: Span | null): Span;
156
158
  abort(scope?: unknown): Promise<void>;
157
159
  getStatus(scope?: unknown): ContextHarnessStatus;
@@ -7,7 +7,7 @@ import type { FsAdapter } from './fs-adapter.js';
7
7
  import type { HarnessResponse, StreamEvent, StreamingItem } from './harness-result.js';
8
8
  import type { ExecuteInput, Item, ItemSchemaExtensions } from './items.js';
9
9
  import type { ContextMemory, MemoryLayer, ProjectionPolicy, StorageAdapter } from './memory.js';
10
- import type { Span } from './observability.js';
10
+ import type { Span, TraceExporter } from './observability.js';
11
11
  import type { ShellAdapter } from './shell-adapter.js';
12
12
  import type { SteeringDecision } from './steering.js';
13
13
  import type { Step } from './step.js';
@@ -56,6 +56,12 @@ interface CallModelRequestBase {
56
56
  emit?: boolean | ((eventType: string, data: Record<string, unknown>) => boolean);
57
57
  /** Optional signal for cancelling the in-flight call (used by session abort). */
58
58
  signal?: AbortSignal;
59
+ /**
60
+ * @internal Parent span for the model-call spans this request produces. When
61
+ * omitted, the caller falls back to `ctx.span`. Set by `parseAndRunWorkflow`
62
+ * so model/tool spans nest under the root `workflow.run` span.
63
+ */
64
+ parentSpan?: Span;
59
65
  }
60
66
  /** @public Request shape when tools are provided — ctx is required for tool execution callbacks. */
61
67
  interface CallModelRequestWithTools extends CallModelRequestBase {
@@ -224,6 +230,8 @@ export interface AgentHarnessContract<TParams extends Record<string, unknown> =
224
230
  checkpoint(ctx: Context): Promise<void>;
225
231
  restore(executionId: string): Promise<Context | null>;
226
232
  cancel(ctx: Context, reason?: string): Promise<void>;
233
+ /** Trace exporter spans are flushed to. Defaults to a no-op exporter. */
234
+ readonly traceExporter: TraceExporter;
227
235
  createSpan(name: string, parent: Span | null): Span;
228
236
  getLayerState<T>(executionId: string, layerId: string): T | undefined;
229
237
  setLayerState<T>(executionId: string, layerId: string, state: T): void;
@@ -4,6 +4,7 @@ import type { ModelParams, RetryPolicy, StepMeta } from './common.js';
4
4
  import type { Context } from './context.js';
5
5
  import type { NoeticError } from './error.js';
6
6
  import type { ContextMemory, MemoryConfig, MemoryLayer, ProjectionPolicy } from './memory.js';
7
+ import type { SubHarness, SubHarnessKind, SubHarnessSessionPolicy, SubHarnessSettings } from './sub-harness.js';
7
8
  import type { SubprocessAdapter } from './subprocess-adapter.js';
8
9
  import type { Tool } from './tool.js';
9
10
  /**
@@ -70,7 +71,7 @@ export interface SettleResult<O> {
70
71
  error?: NoeticError;
71
72
  }
72
73
  /** @public Discriminated union of all step kinds that can be composed into an execution tree. */
73
- export type Step<TMemory = ContextMemory, I = unknown, O = unknown> = StepRun<TMemory, I, O> | StepLLM<TMemory, I, O> | StepTool<TMemory, I, O> | StepBranch<TMemory, I, O> | StepFork<TMemory, I, O> | StepSpawn<TMemory, I, O> | StepProvide<TMemory, I, O> | StepLoop<TMemory, I, O> | StepEvery<TMemory, I, O>;
74
+ export type Step<TMemory = ContextMemory, I = unknown, O = unknown> = StepRun<TMemory, I, O> | StepLLM<TMemory, I, O> | StepSubHarness<TMemory, I, O> | StepTool<TMemory, I, O> | StepBranch<TMemory, I, O> | StepFork<TMemory, I, O> | StepSpawn<TMemory, I, O> | StepProvide<TMemory, I, O> | StepLoop<TMemory, I, O> | StepEvery<TMemory, I, O>;
74
75
  /** @public A step that executes arbitrary async logic via a user-supplied function. */
75
76
  export interface StepRun<TMemory = ContextMemory, I = unknown, O = unknown> {
76
77
  kind: 'run';
@@ -102,6 +103,36 @@ export interface StepLLM<TMemory = ContextMemory, _I = unknown, O = unknown> {
102
103
  /** Projection policy for this step's context window. Overrides the harness-level default. */
103
104
  projection?: ProjectionPolicy;
104
105
  }
106
+ /**
107
+ * A step that delegates a turn to an external coding-agent harness
108
+ * (Claude Code, Codex, opencode, pi). Each harness kind is a distinct
109
+ * `Step.kind`, but every variant shares this shape and is executed by one
110
+ * interpreter handler.
111
+ * @public
112
+ */
113
+ export interface StepSubHarness<TMemory = ContextMemory, _I = unknown, O = unknown> {
114
+ /** The harness kind, equal to the backing adapter's `harnessId`. */
115
+ kind: SubHarnessKind;
116
+ id: string;
117
+ /**
118
+ * The harness adapter that runs the turn. Eager or `(ctx) => SubHarness`.
119
+ * Programmatic builders take it inline; the JSON hydrator resolves it from
120
+ * the workflow's harness registry and inlines it here.
121
+ */
122
+ harness: Lazy<SubHarness, TMemory>;
123
+ /** Turn prompt. Eager string or `(ctx) => string` getter. */
124
+ prompt: Lazy<string, TMemory>;
125
+ /** Shared harness settings (model, permission mode, …). */
126
+ settings?: SubHarnessSettings;
127
+ /** System instructions applied on the first message of a fresh session. */
128
+ instructions?: Lazy<string | undefined, TMemory>;
129
+ /** When set, the assistant text is JSON-parsed and validated against this schema. */
130
+ output?: ZodType<O>;
131
+ /** Session reuse + teardown policy across steps. */
132
+ session?: SubHarnessSessionPolicy;
133
+ /** Controls framework event emission for this step. Defaults to `true`. */
134
+ emit?: boolean | ((eventType: string, data: Record<string, unknown>) => boolean);
135
+ }
105
136
  /** @public A step that invokes a single tool directly, bypassing the LLM. */
106
137
  export interface StepTool<_TMemory = ContextMemory, I = unknown, O = unknown> {
107
138
  kind: 'tool';
@@ -0,0 +1,273 @@
1
+ /**
2
+ * Coding-agent harness contract.
3
+ *
4
+ * A "harness" here is a pluggable backend that drives an external agentic
5
+ * coding tool — Claude Code, Codex, opencode, pi — as a Noetic step. It is the
6
+ * direct analogue of the `MemoryLayer` contract: defined in the dependency-free
7
+ * `@noetic-tools/types` foundation so both `@noetic-tools/core` (which executes
8
+ * harness steps) and the per-tool `@noetic-tools/sub-harness-*` packages (which
9
+ * implement them) can depend on it without forming a cycle.
10
+ *
11
+ * Modelled on Vercel's `HarnessV1` spec: a tagged spec version, a small set of
12
+ * descriptive fields, and a single `doStart` entry point that yields a session.
13
+ * Optional capabilities are signalled by the presence of optional methods, not
14
+ * a static capabilities object — an adapter that cannot satisfy a request
15
+ * throws {@link SubHarnessCapabilityError} from the relevant method.
16
+ */
17
+ import { z } from 'zod';
18
+ import type { TokenUsage } from './common.js';
19
+ import type { FsAdapter } from './fs-adapter.js';
20
+ import type { Item } from './items.js';
21
+ import type { ShellAdapter } from './shell-adapter.js';
22
+ import type { SubprocessAdapter } from './subprocess-adapter.js';
23
+ /**
24
+ * The set of harness step kinds. Each value is a distinct `Step.kind`, so a
25
+ * `step.claudeCode(...)` and a `step.codex(...)` are separate, individually
26
+ * typed step variants — while the interpreter routes all of them through a
27
+ * single shared `executeSubHarness` handler.
28
+ * @public
29
+ */
30
+ export declare const SubHarnessKind: {
31
+ readonly ClaudeCode: "claude-code";
32
+ readonly Codex: "codex";
33
+ readonly Opencode: "opencode";
34
+ readonly Pi: "pi";
35
+ };
36
+ /** @public Union of all harness step kinds. */
37
+ export type SubHarnessKind = (typeof SubHarnessKind)[keyof typeof SubHarnessKind];
38
+ /** @public Ordered list of every harness kind — the single source of truth consumed by the JSON schema and the interpreter. */
39
+ export declare const SUB_HARNESS_KINDS: ReadonlyArray<SubHarnessKind>;
40
+ /**
41
+ * Settings shared by every harness step. Tool-specific knobs that don't map to
42
+ * a shared concept go through `extra`, which each adapter interprets (and may
43
+ * reject with {@link SubHarnessCapabilityError}).
44
+ * @public
45
+ */
46
+ export interface SubHarnessSettings {
47
+ /** Model identifier for the underlying agent (e.g. `claude-opus-4-8`). */
48
+ model?: string;
49
+ /** Permission posture for tool/file mutations the agent attempts. */
50
+ permissionMode?: 'default' | 'plan' | 'acceptEdits' | 'bypassPermissions';
51
+ /** Hard cap on internal agent turns before it must yield. */
52
+ maxTurns?: number;
53
+ /** Restrict the agent to this set of built-in tool names. */
54
+ allowedTools?: ReadonlyArray<string>;
55
+ /** Tool-specific passthrough options interpreted by the adapter. */
56
+ extra?: Record<string, unknown>;
57
+ }
58
+ /**
59
+ * Controls how a harness session is reused and torn down across steps.
60
+ * @public
61
+ */
62
+ export interface SubHarnessSessionPolicy {
63
+ /**
64
+ * Reuse a live session keyed by this id across multiple harness steps. When
65
+ * omitted, each step gets a fresh session that is stopped on completion.
66
+ */
67
+ reuse?: string;
68
+ /**
69
+ * Lifecycle action when the step completes. `'stop'` (default) persists state
70
+ * and stops the runtime; `'detach'` parks it for later resume; `'destroy'`
71
+ * discards it with no resume state.
72
+ */
73
+ onComplete?: 'stop' | 'detach' | 'destroy';
74
+ }
75
+ /** @public Why an agentic turn ended. */
76
+ export type SubHarnessFinishReason = 'stop' | 'length' | 'aborted' | 'error' | 'tool-calls';
77
+ /**
78
+ * Runtime validation schema for {@link SubHarnessStreamPart}. Adapters that move
79
+ * events across a process or transport boundary (e.g. a sandbox bridge)
80
+ * validate with this before forwarding.
81
+ * @public
82
+ */
83
+ export declare const SubHarnessStreamPartSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
84
+ type: z.ZodLiteral<"stream-start">;
85
+ }, z.core.$strip>, z.ZodObject<{
86
+ type: z.ZodLiteral<"text-delta">;
87
+ delta: z.ZodString;
88
+ }, z.core.$strip>, z.ZodObject<{
89
+ type: z.ZodLiteral<"reasoning-delta">;
90
+ delta: z.ZodString;
91
+ }, z.core.$strip>, z.ZodObject<{
92
+ type: z.ZodLiteral<"tool-call">;
93
+ toolCallId: z.ZodString;
94
+ toolName: z.ZodString;
95
+ input: z.ZodUnknown;
96
+ providerExecuted: z.ZodOptional<z.ZodBoolean>;
97
+ }, z.core.$strip>, z.ZodObject<{
98
+ type: z.ZodLiteral<"tool-result">;
99
+ toolCallId: z.ZodString;
100
+ toolName: z.ZodString;
101
+ output: z.ZodUnknown;
102
+ isError: z.ZodOptional<z.ZodBoolean>;
103
+ }, z.core.$strip>, z.ZodObject<{
104
+ type: z.ZodLiteral<"file-change">;
105
+ path: z.ZodOptional<z.ZodString>;
106
+ summary: z.ZodOptional<z.ZodString>;
107
+ }, z.core.$strip>, z.ZodObject<{
108
+ type: z.ZodLiteral<"finish">;
109
+ finishReason: z.ZodEnum<{
110
+ error: "error";
111
+ length: "length";
112
+ aborted: "aborted";
113
+ stop: "stop";
114
+ "tool-calls": "tool-calls";
115
+ }>;
116
+ usage: z.ZodOptional<z.ZodObject<{
117
+ input: z.ZodNumber;
118
+ output: z.ZodNumber;
119
+ total: z.ZodOptional<z.ZodNumber>;
120
+ cached: z.ZodOptional<z.ZodNumber>;
121
+ }, z.core.$strip>>;
122
+ cost: z.ZodOptional<z.ZodNumber>;
123
+ }, z.core.$strip>, z.ZodObject<{
124
+ type: z.ZodLiteral<"error">;
125
+ error: z.ZodString;
126
+ }, z.core.$strip>, z.ZodObject<{
127
+ type: z.ZodLiteral<"raw">;
128
+ value: z.ZodUnknown;
129
+ }, z.core.$strip>], "type">;
130
+ /**
131
+ * A single event emitted by a harness during a turn. Mirrors the model-stream
132
+ * primitives so the interpreter can forward them as framework events with
133
+ * minimal translation. Adapter-specific metadata rides on `raw`.
134
+ * @public
135
+ */
136
+ export type SubHarnessStreamPart = z.infer<typeof SubHarnessStreamPartSchema>;
137
+ /**
138
+ * The workspace surface a harness session may touch during a turn. A focused
139
+ * subset of {@link Context} so adapters don't depend on the full runtime type.
140
+ * @public
141
+ */
142
+ export interface SubHarnessRunContext {
143
+ /** Working directory the agent runs in (resolved from `ctx.cwdState.cwd`). */
144
+ readonly cwd: string;
145
+ readonly fs: FsAdapter;
146
+ readonly shell: ShellAdapter;
147
+ readonly subprocess: SubprocessAdapter;
148
+ /** Conversation thread id, for adapters that persist per-thread session state. */
149
+ readonly threadId: string;
150
+ /** Abort signal for the surrounding execution. */
151
+ readonly signal?: AbortSignal;
152
+ }
153
+ /** @public Opaque, adapter-defined state for resuming a stopped/detached session. */
154
+ export interface SubHarnessResumeState {
155
+ readonly harnessId: string;
156
+ readonly sessionId: string;
157
+ readonly state: unknown;
158
+ }
159
+ /** @public Opaque, adapter-defined state for continuing a turn frozen mid-flight. */
160
+ export interface SubHarnessContinueState {
161
+ readonly harnessId: string;
162
+ readonly sessionId: string;
163
+ readonly state: unknown;
164
+ }
165
+ /** @public Options handed to {@link SubHarness.doStart}. */
166
+ export interface SubHarnessStartOptions<TSettings = SubHarnessSettings> {
167
+ /** Per-step settings (model, permission mode, …). */
168
+ settings?: TSettings;
169
+ /**
170
+ * System instructions applied once on the first message of a fresh session.
171
+ * Never re-applied on resume.
172
+ */
173
+ instructions?: string;
174
+ /**
175
+ * Prior conversation history (from earlier LLM/sub-harness steps and turns)
176
+ * used to seed a fresh session so the agent has full context of the
177
+ * conversation so far. Empty for the very first step of a run.
178
+ */
179
+ history?: ReadonlyArray<Item>;
180
+ /** The workspace surface for this run. */
181
+ ctx: SubHarnessRunContext;
182
+ /** Resume a previously stopped/detached session. */
183
+ resumeFrom?: SubHarnessResumeState;
184
+ /** Continue a turn previously frozen via {@link SubHarnessSession.doSuspendTurn}. */
185
+ continueFrom?: SubHarnessContinueState;
186
+ signal?: AbortSignal;
187
+ }
188
+ /** @public Options for a single agentic turn. */
189
+ export interface SubHarnessPromptTurnOptions {
190
+ /** Fresh turn input only — the session owns conversation history. */
191
+ prompt: string;
192
+ /** Sink for stream events produced during the turn. */
193
+ emit: (part: SubHarnessStreamPart) => void;
194
+ signal?: AbortSignal;
195
+ }
196
+ /** @public Options for continuing a turn frozen mid-flight. */
197
+ export interface SubHarnessContinueTurnOptions {
198
+ emit: (part: SubHarnessStreamPart) => void;
199
+ signal?: AbortSignal;
200
+ }
201
+ /**
202
+ * Result of a completed agentic turn. The interpreter appends `items` to the
203
+ * item log, charges `usage`/`cost`, and returns `text` (or parses it through
204
+ * the step's output schema).
205
+ * @public
206
+ */
207
+ export interface SubHarnessTurnResult {
208
+ /** Noetic Items produced this turn (assistant message, tool calls/results). */
209
+ items: Item[];
210
+ /** Final assistant text of the turn. */
211
+ text: string;
212
+ usage?: TokenUsage;
213
+ cost?: number;
214
+ finishReason?: SubHarnessFinishReason;
215
+ /** Adapter-specific metadata (peer to provider metadata, not a subtype). */
216
+ harnessMetadata?: Record<string, unknown>;
217
+ }
218
+ /**
219
+ * Describes a tool the underlying agent executes natively, mapped to a shared
220
+ * `commonName` so consumers can recognise "the same kind of tool" across
221
+ * harnesses (Claude's `Bash`, Codex's `shell`, pi's `bash` → `shell`).
222
+ * @public
223
+ */
224
+ export interface SubHarnessBuiltinTool {
225
+ /** The agent's native tool name. */
226
+ readonly nativeName: string;
227
+ /** Shared cross-harness name, when one exists. */
228
+ readonly commonName?: string;
229
+ readonly description?: string;
230
+ }
231
+ /**
232
+ * A live harness session: one workspace + one conversation history + one
233
+ * running runtime, kept across turns by the interpreter.
234
+ * @public
235
+ */
236
+ export interface SubHarnessSession {
237
+ readonly sessionId: string;
238
+ /** True when this session was resumed rather than freshly started. */
239
+ readonly isResume: boolean;
240
+ /** The model the session resolved to, when the runtime reports it. */
241
+ readonly modelId?: string;
242
+ /** Run one agentic turn to completion. */
243
+ doPromptTurn(opts: SubHarnessPromptTurnOptions): Promise<SubHarnessTurnResult>;
244
+ /** Continue a turn previously frozen via {@link doSuspendTurn}. */
245
+ doContinueTurn?(opts: SubHarnessContinueTurnOptions): Promise<SubHarnessTurnResult>;
246
+ /** Freeze the current turn at a precise event cursor; runtime stays alive. */
247
+ doSuspendTurn?(): Promise<SubHarnessContinueState>;
248
+ /** Manually compact conversation history. Throws {@link SubHarnessCapabilityError} if unsupported. */
249
+ doCompact?(customInstructions?: string): Promise<void>;
250
+ /** Park the session between turns; runtime stays alive. */
251
+ doDetach?(): Promise<SubHarnessResumeState>;
252
+ /** Persist state and stop the runtime. */
253
+ doStop(): Promise<SubHarnessResumeState>;
254
+ /** Stop the runtime with no resume state. */
255
+ doDestroy?(): Promise<void>;
256
+ }
257
+ /**
258
+ * A coding-agent harness. Each `@noetic-tools/sub-harness-*` package exports a
259
+ * factory returning one of these (e.g. `claudeCode({ model })`).
260
+ * @public
261
+ */
262
+ export interface SubHarness<TSettings = SubHarnessSettings> {
263
+ /** Spec tag for forward-compatibility. */
264
+ readonly specificationVersion: 'harness-v1';
265
+ /** Stable identifier, equal to the step kind it backs (e.g. `claude-code`). */
266
+ readonly harnessId: SubHarnessKind;
267
+ /** Tools the underlying agent executes natively. */
268
+ readonly builtinTools?: ReadonlyArray<SubHarnessBuiltinTool>;
269
+ /** Validates `resumeFrom`/`continueFrom` payloads, when the adapter persists them. */
270
+ readonly lifecycleStateSchema?: z.ZodType;
271
+ /** Start (or resume/continue) a session. */
272
+ doStart(opts: SubHarnessStartOptions<TSettings>): Promise<SubHarnessSession>;
273
+ }
@@ -0,0 +1,106 @@
1
+ /**
2
+ * Coding-agent harness contract.
3
+ *
4
+ * A "harness" here is a pluggable backend that drives an external agentic
5
+ * coding tool — Claude Code, Codex, opencode, pi — as a Noetic step. It is the
6
+ * direct analogue of the `MemoryLayer` contract: defined in the dependency-free
7
+ * `@noetic-tools/types` foundation so both `@noetic-tools/core` (which executes
8
+ * harness steps) and the per-tool `@noetic-tools/sub-harness-*` packages (which
9
+ * implement them) can depend on it without forming a cycle.
10
+ *
11
+ * Modelled on Vercel's `HarnessV1` spec: a tagged spec version, a small set of
12
+ * descriptive fields, and a single `doStart` entry point that yields a session.
13
+ * Optional capabilities are signalled by the presence of optional methods, not
14
+ * a static capabilities object — an adapter that cannot satisfy a request
15
+ * throws {@link SubHarnessCapabilityError} from the relevant method.
16
+ */
17
+ import { z } from 'zod';
18
+ //#region Step-kind discriminator
19
+ /**
20
+ * The set of harness step kinds. Each value is a distinct `Step.kind`, so a
21
+ * `step.claudeCode(...)` and a `step.codex(...)` are separate, individually
22
+ * typed step variants — while the interpreter routes all of them through a
23
+ * single shared `executeSubHarness` handler.
24
+ * @public
25
+ */
26
+ export const SubHarnessKind = {
27
+ ClaudeCode: 'claude-code',
28
+ Codex: 'codex',
29
+ Opencode: 'opencode',
30
+ Pi: 'pi',
31
+ };
32
+ /** @public Ordered list of every harness kind — the single source of truth consumed by the JSON schema and the interpreter. */
33
+ export const SUB_HARNESS_KINDS = [
34
+ SubHarnessKind.ClaudeCode,
35
+ SubHarnessKind.Codex,
36
+ SubHarnessKind.Opencode,
37
+ SubHarnessKind.Pi,
38
+ ];
39
+ const HarnessFinishReasonSchema = z.enum([
40
+ 'stop',
41
+ 'length',
42
+ 'aborted',
43
+ 'error',
44
+ 'tool-calls',
45
+ ]);
46
+ const TokenUsageSchema = z.object({
47
+ input: z.number(),
48
+ output: z.number(),
49
+ total: z.number().optional(),
50
+ cached: z.number().optional(),
51
+ });
52
+ /**
53
+ * Runtime validation schema for {@link SubHarnessStreamPart}. Adapters that move
54
+ * events across a process or transport boundary (e.g. a sandbox bridge)
55
+ * validate with this before forwarding.
56
+ * @public
57
+ */
58
+ export const SubHarnessStreamPartSchema = z.discriminatedUnion('type', [
59
+ z.object({
60
+ type: z.literal('stream-start'),
61
+ }),
62
+ z.object({
63
+ type: z.literal('text-delta'),
64
+ delta: z.string(),
65
+ }),
66
+ z.object({
67
+ type: z.literal('reasoning-delta'),
68
+ delta: z.string(),
69
+ }),
70
+ z.object({
71
+ type: z.literal('tool-call'),
72
+ toolCallId: z.string(),
73
+ toolName: z.string(),
74
+ input: z.unknown(),
75
+ /** True when the underlying agent executed the tool itself (vs. host dispatch). */
76
+ providerExecuted: z.boolean().optional(),
77
+ }),
78
+ z.object({
79
+ type: z.literal('tool-result'),
80
+ toolCallId: z.string(),
81
+ toolName: z.string(),
82
+ output: z.unknown(),
83
+ isError: z.boolean().optional(),
84
+ }),
85
+ z.object({
86
+ type: z.literal('file-change'),
87
+ path: z.string().optional(),
88
+ summary: z.string().optional(),
89
+ }),
90
+ z.object({
91
+ type: z.literal('finish'),
92
+ finishReason: HarnessFinishReasonSchema,
93
+ usage: TokenUsageSchema.optional(),
94
+ cost: z.number().optional(),
95
+ }),
96
+ z.object({
97
+ type: z.literal('error'),
98
+ error: z.string(),
99
+ }),
100
+ /** Adapter-specific passthrough for events with no canonical mapping. */
101
+ z.object({
102
+ type: z.literal('raw'),
103
+ value: z.unknown(),
104
+ }),
105
+ ]);
106
+ //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@noetic-tools/types",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "type": "module",
5
5
  "description": "Foundational type contracts and primitives shared across the Noetic framework (items, LLM config, adapters, steering, errors).",
6
6
  "license": "Apache-2.0",