@noetic-tools/core 0.2.1 → 0.3.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.
Files changed (203) hide show
  1. package/dist/adapters/in-memory-fs-adapter.d.ts +1 -1
  2. package/dist/adapters/in-memory-fs-adapter.js +1 -1
  3. package/dist/adapters/in-memory-shell-adapter.d.ts +1 -1
  4. package/dist/adapters/in-memory-subprocess/manifest-persistence.d.ts +2 -2
  5. package/dist/adapters/in-memory-subprocess/metadata.d.ts +1 -1
  6. package/dist/adapters/in-memory-subprocess/types.d.ts +2 -2
  7. package/dist/adapters/in-memory-subprocess-adapter.d.ts +1 -1
  8. package/dist/adapters/openrouter.d.ts +2 -6
  9. package/dist/adapters/openrouter.js +1 -4
  10. package/dist/builders/channel-builder.d.ts +1 -1
  11. package/dist/builders/control-flow-builders.d.ts +2 -3
  12. package/dist/builders/control-flow-builders.js +1 -2
  13. package/dist/builders/every.d.ts +2 -3
  14. package/dist/builders/every.js +1 -1
  15. package/dist/builders/layer-provides-builders.d.ts +1 -1
  16. package/dist/builders/layer-provides-builders.js +1 -1
  17. package/dist/builders/loop-builder.d.ts +2 -2
  18. package/dist/builders/loop-builder.js +1 -1
  19. package/dist/builders/memory-builder.d.ts +1 -1
  20. package/dist/builders/memory-builder.js +1 -1
  21. package/dist/builders/provide-builder.d.ts +2 -2
  22. package/dist/builders/provide-builder.js +1 -1
  23. package/dist/builders/spawn-builder.d.ts +2 -3
  24. package/dist/builders/spawn-builder.js +1 -1
  25. package/dist/builders/step-builders.d.ts +2 -6
  26. package/dist/builders/step-builders.js +1 -1
  27. package/dist/builders/tool-builder.d.ts +1 -3
  28. package/dist/builders/tool-builder.js +1 -1
  29. package/dist/builders/workflow-hydrator.d.ts +2 -3
  30. package/dist/builders/workflow-hydrator.js +1 -2
  31. package/dist/conditions/conditions.d.ts +2 -3
  32. package/dist/conditions/conditions.js +1 -1
  33. package/dist/harness/agent-harness.d.ts +13 -3
  34. package/dist/harness/agent-harness.js +48 -5
  35. package/dist/harness/deps/memory.d.ts +2 -5
  36. package/dist/harness/deps/memory.js +1 -4
  37. package/dist/harness/deps/types.d.ts +3 -16
  38. package/dist/harness/deps/types.js +1 -1
  39. package/dist/harness/model-call.d.ts +1 -3
  40. package/dist/harness/model-call.js +1 -2
  41. package/dist/harness/model-schema.d.ts +2 -4
  42. package/dist/harness/model-schema.js +1 -1
  43. package/dist/index.d.ts +28 -49
  44. package/dist/index.js +9 -27
  45. package/dist/interpreter/action-deps.d.ts +4 -8
  46. package/dist/interpreter/action-deps.js +2 -6
  47. package/dist/interpreter/action-types.d.ts +3 -8
  48. package/dist/interpreter/action-types.js +1 -1
  49. package/dist/interpreter/collect-tools.d.ts +1 -2
  50. package/dist/interpreter/collect-tools.js +1 -1
  51. package/dist/interpreter/execute-action.js +104 -26
  52. package/dist/interpreter/execute-control.d.ts +1 -2
  53. package/dist/interpreter/execute-control.js +1 -3
  54. package/dist/interpreter/execute.d.ts +2 -3
  55. package/dist/interpreter/execute.js +1 -2
  56. package/dist/interpreter/message-helpers.d.ts +1 -1
  57. package/dist/interpreter/message-helpers.js +1 -1
  58. package/dist/interpreter/step-dispatcher.d.ts +2 -5
  59. package/dist/interpreter/typeguards.d.ts +3 -4
  60. package/dist/interpreter/typeguards.js +1 -1
  61. package/dist/observability/span-impl.d.ts +1 -1
  62. package/dist/observability/trace-exporter.d.ts +1 -1
  63. package/dist/patterns/dynamic-workflow.d.ts +2 -5
  64. package/dist/patterns/dynamic-workflow.js +1 -2
  65. package/dist/patterns/flow.d.ts +2 -2
  66. package/dist/patterns/flow.js +1 -1
  67. package/dist/patterns/interview.d.ts +2 -2
  68. package/dist/patterns/interview.js +1 -1
  69. package/dist/patterns/plans.d.ts +2 -3
  70. package/dist/patterns/plans.js +1 -1
  71. package/dist/patterns/ralph-wiggum.d.ts +2 -3
  72. package/dist/patterns/react.d.ts +2 -3
  73. package/dist/portable/memory-layers.d.ts +1 -7
  74. package/dist/portable/memory-layers.js +1 -7
  75. package/dist/portable.d.ts +2 -2
  76. package/dist/portable.js +2 -2
  77. package/dist/runtime/broadcaster-utils.d.ts +1 -1
  78. package/dist/runtime/channel-store.d.ts +1 -1
  79. package/dist/runtime/channel-store.js +1 -2
  80. package/dist/runtime/context-deps.d.ts +3 -3
  81. package/dist/runtime/context-deps.js +2 -2
  82. package/dist/runtime/context-type-deps.d.ts +2 -11
  83. package/dist/runtime/cwd-helpers.d.ts +1 -1
  84. package/dist/runtime/detached-handle.d.ts +2 -3
  85. package/dist/runtime/detached-handle.js +1 -3
  86. package/dist/runtime/durable/checkpoint-store.d.ts +1 -1
  87. package/dist/runtime/durable/checkpoint-store.js +1 -1
  88. package/dist/runtime/durable/harness-checkpoints.d.ts +2 -5
  89. package/dist/runtime/durable/runnable-loop.d.ts +1 -3
  90. package/dist/runtime/durable/session-seed.d.ts +1 -1
  91. package/dist/runtime/durable/stall-nudge.d.ts +1 -1
  92. package/dist/runtime/event-broadcaster.d.ts +1 -1
  93. package/dist/runtime/in-memory-storage.d.ts +1 -1
  94. package/dist/runtime/in-memory-storage.js +1 -1
  95. package/dist/runtime/item-log-impl.d.ts +1 -3
  96. package/dist/runtime/item-log-impl.js +1 -1
  97. package/dist/runtime/message-queue.d.ts +1 -2
  98. package/dist/runtime/session-runner.d.ts +1 -4
  99. package/dist/runtime/session-streams.d.ts +1 -2
  100. package/dist/runtime/session-streams.js +1 -1
  101. package/dist/runtime/step-registry.d.ts +2 -2
  102. package/dist/runtime/step-registry.js +1 -2
  103. package/dist/runtime/tool-memory.d.ts +1 -3
  104. package/dist/types/mutable-context.d.ts +2 -3
  105. package/dist/types/step-registrar.d.ts +1 -1
  106. package/dist/unstable.d.ts +5 -9
  107. package/dist/unstable.js +3 -6
  108. package/dist/until/combinators.d.ts +1 -1
  109. package/dist/until/never.d.ts +1 -1
  110. package/dist/until/predicates.d.ts +2 -2
  111. package/package.json +4 -2
  112. package/dist/errors/noetic-config-error.d.ts +0 -41
  113. package/dist/errors/noetic-config-error.js +0 -44
  114. package/dist/errors/noetic-error.d.ts +0 -18
  115. package/dist/errors/noetic-error.js +0 -54
  116. package/dist/memory/budget.d.ts +0 -23
  117. package/dist/memory/budget.js +0 -117
  118. package/dist/memory/exec-context-factory.d.ts +0 -25
  119. package/dist/memory/exec-context-factory.js +0 -30
  120. package/dist/memory/flow-schema.d.ts +0 -52
  121. package/dist/memory/flow-schema.js +0 -102
  122. package/dist/memory/function-call-utils.d.ts +0 -6
  123. package/dist/memory/function-call-utils.js +0 -27
  124. package/dist/memory/layer-api.d.ts +0 -14
  125. package/dist/memory/layer-api.js +0 -91
  126. package/dist/memory/layer-lifecycle.d.ts +0 -160
  127. package/dist/memory/layer-lifecycle.js +0 -552
  128. package/dist/memory/layer-provides.d.ts +0 -32
  129. package/dist/memory/layer-provides.js +0 -33
  130. package/dist/memory/layer-usage.d.ts +0 -16
  131. package/dist/memory/layer-usage.js +0 -54
  132. package/dist/memory/layers/durable-task-state.d.ts +0 -79
  133. package/dist/memory/layers/durable-task-state.js +0 -118
  134. package/dist/memory/layers/file-reference.d.ts +0 -55
  135. package/dist/memory/layers/file-reference.js +0 -594
  136. package/dist/memory/layers/history-window.d.ts +0 -29
  137. package/dist/memory/layers/history-window.js +0 -114
  138. package/dist/memory/layers/observational-memory.d.ts +0 -53
  139. package/dist/memory/layers/observational-memory.js +0 -109
  140. package/dist/memory/layers/plan.d.ts +0 -55
  141. package/dist/memory/layers/plan.js +0 -374
  142. package/dist/memory/layers/static-content.d.ts +0 -27
  143. package/dist/memory/layers/static-content.js +0 -35
  144. package/dist/memory/layers/steering.d.ts +0 -51
  145. package/dist/memory/layers/steering.js +0 -258
  146. package/dist/memory/layers/temporal.d.ts +0 -91
  147. package/dist/memory/layers/temporal.js +0 -245
  148. package/dist/memory/layers/tool-memory-layer.d.ts +0 -16
  149. package/dist/memory/layers/tool-memory-layer.js +0 -43
  150. package/dist/memory/layers/working-memory.d.ts +0 -44
  151. package/dist/memory/layers/working-memory.js +0 -92
  152. package/dist/memory/projector.d.ts +0 -10
  153. package/dist/memory/projector.js +0 -19
  154. package/dist/memory/scope.d.ts +0 -3
  155. package/dist/memory/scope.js +0 -31
  156. package/dist/memory/strip-unresolved.d.ts +0 -13
  157. package/dist/memory/strip-unresolved.js +0 -35
  158. package/dist/schemas/item.d.ts +0 -35
  159. package/dist/schemas/item.js +0 -155
  160. package/dist/types/channel.d.ts +0 -29
  161. package/dist/types/channel.js +0 -1
  162. package/dist/types/common.d.ts +0 -68
  163. package/dist/types/common.js +0 -1
  164. package/dist/types/context-parts/item-log.d.ts +0 -6
  165. package/dist/types/context-parts/item-log.js +0 -1
  166. package/dist/types/context-parts/layer-usage.d.ts +0 -18
  167. package/dist/types/context-parts/layer-usage.js +0 -1
  168. package/dist/types/context.d.ts +0 -202
  169. package/dist/types/context.js +0 -1
  170. package/dist/types/detached.d.ts +0 -17
  171. package/dist/types/detached.js +0 -7
  172. package/dist/types/error.d.ts +0 -66
  173. package/dist/types/error.js +0 -1
  174. package/dist/types/fs-adapter.d.ts +0 -51
  175. package/dist/types/fs-adapter.js +0 -3
  176. package/dist/types/harness-result.d.ts +0 -43
  177. package/dist/types/harness-result.js +0 -2
  178. package/dist/types/items.d.ts +0 -131
  179. package/dist/types/items.js +0 -2
  180. package/dist/types/memory-context.d.ts +0 -39
  181. package/dist/types/memory-context.js +0 -1
  182. package/dist/types/memory.d.ts +0 -306
  183. package/dist/types/memory.js +0 -13
  184. package/dist/types/observability.d.ts +0 -30
  185. package/dist/types/observability.js +0 -1
  186. package/dist/types/runtime.d.ts +0 -256
  187. package/dist/types/runtime.js +0 -1
  188. package/dist/types/shell-adapter.d.ts +0 -34
  189. package/dist/types/shell-adapter.js +0 -10
  190. package/dist/types/steering.d.ts +0 -89
  191. package/dist/types/steering.js +0 -14
  192. package/dist/types/step.d.ts +0 -231
  193. package/dist/types/step.js +0 -1
  194. package/dist/types/subprocess-adapter.d.ts +0 -157
  195. package/dist/types/subprocess-adapter.js +0 -3
  196. package/dist/types/tool-context.d.ts +0 -34
  197. package/dist/types/tool-context.js +0 -1
  198. package/dist/types/tool.d.ts +0 -64
  199. package/dist/types/tool.js +0 -1
  200. package/dist/util/framework-cast.d.ts +0 -10
  201. package/dist/util/framework-cast.js +0 -16
  202. package/dist/util/message-helpers.d.ts +0 -17
  203. package/dist/util/message-helpers.js +0 -64
@@ -1,202 +0,0 @@
1
- import type { ZodType } from 'zod';
2
- import type { ItemSchemaRegistry } from '../schemas/item.js';
3
- import type { Channel, ChannelHandle, ExternalChannel } from './channel.js';
4
- import type { LLMResponse, ModelParams, StepMeta, TokenUsage } from './common.js';
5
- import type { ItemLog } from './context-parts/item-log.js';
6
- import type { LastLayerUsage } from './context-parts/layer-usage.js';
7
- import type { DetachedHandle } from './detached.js';
8
- import type { FsAdapter } from './fs-adapter.js';
9
- import type { HarnessResponse, StreamEvent, StreamingItem } from './harness-result.js';
10
- import type { ExecuteInput } from './items.js';
11
- import type { ContextMemory, MemoryLayer, StorageAdapter } from './memory.js';
12
- import type { Span } from './observability.js';
13
- import type { ShellAdapter } from './shell-adapter.js';
14
- import type { SteeringDecision } from './steering.js';
15
- import type { SubprocessAdapter } from './subprocess-adapter.js';
16
- import type { Tool } from './tool.js';
17
- /**
18
- * @public Mutable working-directory state shared among the tools attached to a
19
- * single Context. The reference is fixed for the Context's lifetime; mutate
20
- * via `setToolCwd` so that all tools observe the new value at execution time.
21
- *
22
- * Spawned children receive a snapshot — child mutations do not affect the parent.
23
- */
24
- export interface CwdState {
25
- cwd: string;
26
- previousCwd?: string;
27
- }
28
- export type ContextHarnessStatus = {
29
- readonly kind: 'idle';
30
- } | {
31
- readonly kind: 'generating';
32
- readonly startedAt: number;
33
- readonly turnId: string;
34
- } | {
35
- readonly kind: 'aborting';
36
- readonly turnId: string;
37
- };
38
- interface ContextCallModelRequestBase {
39
- model: string;
40
- items: ReadonlyArray<import('./items.js').Item>;
41
- instructions?: string;
42
- params?: ModelParams;
43
- outputSchema?: ZodType;
44
- emit?: boolean | ((eventType: string, data: Record<string, unknown>) => boolean);
45
- signal?: AbortSignal;
46
- }
47
- interface ContextCallModelRequestWithTools extends ContextCallModelRequestBase {
48
- tools: Tool[];
49
- ctx: Context;
50
- layers?: MemoryLayer[];
51
- allowedToolNames?: string[];
52
- }
53
- interface ContextCallModelRequestWithoutTools extends ContextCallModelRequestBase {
54
- tools?: undefined;
55
- ctx?: undefined;
56
- layers?: undefined;
57
- }
58
- export type ContextCallModelRequest = ContextCallModelRequestWithTools | ContextCallModelRequestWithoutTools;
59
- export interface ContextDetachedSpawnOverrides {
60
- threadId?: string;
61
- resourceId?: string;
62
- cwdInit?: string;
63
- }
64
- export interface ContextRerenderRequest {
65
- layerId: string;
66
- slot: number;
67
- timing: 'immediate' | 'batched';
68
- scope: 'self' | 'slot-after' | 'all';
69
- }
70
- export interface ContextAppendPipelineResult {
71
- readonly items: import('./items.js').Item[];
72
- readonly rerenderRequests: ContextRerenderRequest[];
73
- }
74
- export interface ContextRecallLayerOutput {
75
- layerId: string;
76
- items: import('./items.js').Item[];
77
- tokenCount: number;
78
- }
79
- export type ContextStep<TMemory = ContextMemory, I = unknown, O = unknown> = {
80
- readonly kind: 'run';
81
- readonly id: string;
82
- readonly execute: (input: I, ctx: Context<TMemory>) => Promise<O>;
83
- } | {
84
- readonly kind: 'llm';
85
- readonly id: string;
86
- readonly output?: ZodType<O>;
87
- } | {
88
- readonly kind: 'loop';
89
- readonly id: string;
90
- readonly steps: ReadonlyArray<ContextStep<TMemory, I, O>>;
91
- readonly prepareNext?: (output: O, verdict: unknown, ctx: Context<TMemory>) => I;
92
- } | {
93
- readonly kind: string;
94
- readonly id: string;
95
- };
96
- /** @public Runtime surface exposed on Context without coupling Context's definition to the runtime type module. */
97
- export interface ContextHarness {
98
- readonly config: {
99
- readonly name: string;
100
- readonly params: Record<string, unknown>;
101
- };
102
- readonly fs: FsAdapter;
103
- readonly shell: ShellAdapter;
104
- readonly subprocess: SubprocessAdapter;
105
- readonly rootCwdState: CwdState;
106
- callModel(request: ContextCallModelRequest): Promise<LLMResponse>;
107
- execute(input: ExecuteInput, options?: unknown): Promise<void>;
108
- getAgentResponse(scope?: unknown): Promise<HarnessResponse>;
109
- getItemStream(scope?: unknown): AsyncIterable<StreamingItem>;
110
- getTextStream(scope?: unknown): AsyncIterable<string>;
111
- getReasoningStream(scope?: unknown): AsyncIterable<string>;
112
- getFullStream(scope?: unknown): AsyncIterable<StreamEvent>;
113
- run<I, O>(step: ContextStep<ContextMemory, I, O>, input: I, ctx: Context): Promise<O>;
114
- detachedSpawn<I, O>(step: unknown, input: I, parentCtx: Context, overrides?: ContextDetachedSpawnOverrides): DetachedHandle<O>;
115
- createContext(opts?: {
116
- parent?: Context;
117
- items?: import('./items.js').Item[];
118
- state?: unknown;
119
- threadId?: string;
120
- resourceId?: string;
121
- memory?: MemoryLayer[];
122
- cwdInit?: string;
123
- }): Context;
124
- setRootCwd(nextCwd: string): void;
125
- getLayerState<T>(executionId: string, layerId: string): T | undefined;
126
- setLayerState<T>(executionId: string, layerId: string, state: T): void;
127
- beforeToolCall(layers: MemoryLayer[], toolName: string, toolArgs: unknown, ctx: Context): Promise<SteeringDecision>;
128
- afterModelCall(layers: MemoryLayer[], response: LLMResponse, ctx: Context): Promise<SteeringDecision>;
129
- runAppendPipeline(layers: MemoryLayer[], items: import('./items.js').Item[], ctx: Context): Promise<ContextAppendPipelineResult>;
130
- recallLayers(layers: MemoryLayer[], input: string, ctx: Context): Promise<ContextRecallLayerOutput[]>;
131
- projectHistory(layers: MemoryLayer[], items: ReadonlyArray<import('./items.js').Item>, ctx: Context): Promise<ReadonlyArray<import('./items.js').Item>>;
132
- storeLayers(layers: MemoryLayer[], response: LLMResponse, ctx: Context): Promise<void>;
133
- previewRequestItems(scope?: unknown): Promise<ReadonlyArray<import('./items.js').Item>>;
134
- send<T>(channel: Channel<T>, value: T, ctx: Context): void;
135
- recv<T>(channel: Channel<T>, ctx: Context, opts?: {
136
- timeout?: number;
137
- }): Promise<T>;
138
- tryRecv<T>(channel: Channel<T>, ctx: Context): T | null;
139
- getChannelHandle<T>(channel: ExternalChannel<T>, executionId: string): ChannelHandle<T>;
140
- initLayers(layers: MemoryLayer[], ctx: Context, storage: StorageAdapter): Promise<void>;
141
- disposeLayers(layers: MemoryLayer[], ctx: Context): Promise<void>;
142
- checkpoint(ctx: Context): Promise<void>;
143
- restore(executionId: string): Promise<Context | null>;
144
- cancel(ctx: Context, reason?: string): Promise<void>;
145
- createSpan(name: string, parent: Span | null): Span;
146
- abort(scope?: unknown): Promise<void>;
147
- getStatus(scope?: unknown): ContextHarnessStatus;
148
- getQueueSize(scope?: unknown): number;
149
- seedSessionHistory(threadId: string, items: ReadonlyArray<import('./items.js').Item>): void;
150
- executeRerender(requests: ContextRerenderRequest[], layers: MemoryLayer[], ctx: Context, budgets: Map<string, number>, query?: string): Promise<ContextRecallLayerOutput[]>;
151
- }
152
- /** @public Execution context threaded through every step, carrying state, metrics, and channels. */
153
- export interface Context<TMemory = ContextMemory, TState = unknown> {
154
- readonly id: string;
155
- readonly stepCount: number;
156
- readonly tokens: TokenUsage;
157
- readonly elapsed: number;
158
- readonly cost: number;
159
- state: TState;
160
- readonly parent: Context<ContextMemory> | null;
161
- readonly depth: number;
162
- readonly span: Span;
163
- readonly threadId: string;
164
- readonly resourceId?: string;
165
- readonly itemLog: ItemLog;
166
- readonly lastStepMeta: StepMeta | null;
167
- /** Per-layer breakdown of the context window as of the most recent callModel. Undefined until the first LLM call completes. */
168
- readonly lastLayerUsage?: LastLayerUsage;
169
- readonly harness: ContextHarness;
170
- /** Filesystem adapter for virtual or real filesystem access. */
171
- readonly fs: FsAdapter;
172
- /** Shell adapter for virtual or real shell command execution. */
173
- readonly shell: ShellAdapter;
174
- /** Subprocess adapter for virtual, same-process, or host process execution. */
175
- readonly subprocess: SubprocessAdapter;
176
- /**
177
- * Mutable cwd state shared with the tools bound to this context. Tools
178
- * resolve relative paths from `cwdState.cwd` at execution time so that an
179
- * agent `cd` propagates to subsequent tool calls.
180
- */
181
- readonly cwdState: CwdState;
182
- readonly layers?: MemoryLayer[];
183
- /** Layer provides keyed by layer ID. Access data/functions via `ctx.memory['layerId'].prop`. */
184
- readonly memory: TMemory;
185
- /** Unified tool set collected from all LLM steps in the step tree before execution. */
186
- readonly unifiedTools?: ReadonlyArray<Tool>;
187
- /** Runtime item schema registry active for this context. */
188
- readonly itemSchemas?: ItemSchemaRegistry;
189
- recv<T>(channel: Channel<T>, opts?: {
190
- timeout?: number;
191
- }): Promise<T>;
192
- send<T>(channel: Channel<T>, value: T): void;
193
- tryRecv<T>(channel: Channel<T>): T | null;
194
- checkpoint(): Promise<void>;
195
- complete<T>(value: T): void;
196
- readonly completed: boolean;
197
- readonly completionValue: unknown;
198
- readonly aborted: boolean;
199
- readonly abortReason?: string;
200
- abort(reason?: string): void;
201
- }
202
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,17 +0,0 @@
1
- /** @public Lifecycle states for a detached (background) execution. */
2
- declare const DetachedStatus: {
3
- readonly Running: "running";
4
- readonly Completed: "completed";
5
- readonly Failed: "failed";
6
- };
7
- type DetachedStatus = (typeof DetachedStatus)[keyof typeof DetachedStatus];
8
- /** @public Handle returned by `detachedSpawn`, used to poll or await a background execution. */
9
- interface DetachedHandle<O> {
10
- readonly id: string;
11
- readonly status: DetachedStatus;
12
- readonly result: O | undefined;
13
- readonly error: string | undefined;
14
- await(timeout?: number): Promise<O>;
15
- }
16
- export type { DetachedHandle };
17
- export { DetachedStatus };
@@ -1,7 +0,0 @@
1
- /** @public Lifecycle states for a detached (background) execution. */
2
- const DetachedStatus = {
3
- Running: 'running',
4
- Completed: 'completed',
5
- Failed: 'failed',
6
- };
7
- export { DetachedStatus };
@@ -1,66 +0,0 @@
1
- import type { ZodError, ZodType } from 'zod';
2
- /** @public Discriminated union of all structured error kinds raised by the runtime. */
3
- export type NoeticError = {
4
- kind: 'step_failed';
5
- stepId: string;
6
- cause: Error;
7
- retriesExhausted: boolean;
8
- } | {
9
- kind: 'llm_refused';
10
- stepId: string;
11
- refusal: string;
12
- } | {
13
- kind: 'llm_parse_error';
14
- stepId: string;
15
- raw: string;
16
- schema: ZodType;
17
- zodError: ZodError;
18
- } | {
19
- kind: 'llm_rate_limit';
20
- stepId: string;
21
- retryAfter?: number;
22
- } | {
23
- kind: 'fork_partial';
24
- stepId: string;
25
- succeeded: Array<{
26
- stepId: string;
27
- value: unknown;
28
- }>;
29
- failed: Array<{
30
- stepId: string;
31
- error: NoeticError;
32
- }>;
33
- } | {
34
- kind: 'channel_timeout';
35
- channelName: string;
36
- timeout: number;
37
- } | {
38
- kind: 'channel_closed';
39
- channelName: string;
40
- } | {
41
- kind: 'cancelled';
42
- reason?: string;
43
- } | {
44
- kind: 'budget_exceeded';
45
- field: 'cost' | 'steps' | 'duration';
46
- limit: number;
47
- actual: number;
48
- } | {
49
- kind: 'steering_denied';
50
- guidance?: string;
51
- } | {
52
- /**
53
- * Raised by `DetachedHandle.await()` when the adapter persistently
54
- * returns `null` for a handle that was previously spawned — the
55
- * handle has been evicted from the adapter's registry, either by
56
- * a restart-after-stop-without-restore flow or by a storage
57
- * inconsistency. This guards against an otherwise-infinite poll
58
- * loop that would hold the promise open forever. A short grace
59
- * period tolerates transient nulls (e.g. the in-memory adapter
60
- * briefly returning null between spawn and first microtask yield).
61
- */
62
- kind: 'handle_evicted';
63
- handleId: string;
64
- stepId: string;
65
- gracePeriodMs: number;
66
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1,51 +0,0 @@
1
- /** @public Minimal stat result returned by the filesystem adapter. */
2
- export interface FsStats {
3
- size: number;
4
- isDirectory(): boolean;
5
- isSymbolicLink(): boolean;
6
- isFile(): boolean;
7
- }
8
- /** @public Filesystem abstraction for agent runtime operations. */
9
- export interface FsAdapter {
10
- /** Read file contents as a Buffer. */
11
- readFile(path: string): Promise<Buffer>;
12
- /** Read file contents as a UTF-8 string. */
13
- readFileText(path: string): Promise<string>;
14
- /** Write string content to a file (UTF-8). */
15
- writeFile(path: string, content: string): Promise<void>;
16
- /**
17
- * Write raw bytes to a file. Use this when content may not be valid
18
- * UTF-8 (binary attachments, images, etc.). Round-tripping through
19
- * `writeFile` corrupts non-UTF-8 sequences.
20
- */
21
- writeFileBytes(path: string, content: Buffer): Promise<void>;
22
- /**
23
- * Append string content to a file (UTF-8). Creates the file if it does
24
- * not exist. On POSIX, the underlying write uses `O_APPEND`, which is
25
- * atomic for sub-`PIPE_BUF` writes — multiple concurrent writers can
26
- * append without interleaving as long as each call's payload stays
27
- * under that ceiling (4 KiB on Linux/macOS).
28
- */
29
- appendFile(path: string, content: string): Promise<void>;
30
- /** Create directories recursively. */
31
- mkdir(dir: string): Promise<void>;
32
- /**
33
- * Atomically rename a file or directory. On POSIX, this is the atomic
34
- * swap used by write-temp + rename to publish a new file version
35
- * without exposing readers to a half-written state.
36
- */
37
- rename(oldPath: string, newPath: string): Promise<void>;
38
- /** Remove a file or directory. With `recursive: true`, removes a directory tree. */
39
- rm(path: string, options?: {
40
- recursive?: boolean;
41
- force?: boolean;
42
- }): Promise<void>;
43
- /** Check file accessibility (throws on failure). */
44
- access(path: string, mode?: number): Promise<void>;
45
- /** Get file/directory stats (follows symlinks). */
46
- stat(path: string): Promise<FsStats>;
47
- /** Get file/directory stats (does NOT follow symlinks). */
48
- lstat(path: string): Promise<FsStats>;
49
- /** Read directory entries (file names). */
50
- readdir(path: string): Promise<string[]>;
51
- }
@@ -1,3 +0,0 @@
1
- //#region Types
2
- export {};
3
- //#endregion
@@ -1,43 +0,0 @@
1
- import type { LastLayerUsage } from './context-parts/layer-usage.js';
2
- import type { Item } from './items.js';
3
- /** @public SDK-originated event from the OpenResponses streaming API. */
4
- export interface SdkStreamEvent {
5
- readonly source: 'sdk';
6
- /** OpenResponses SSE event type string (e.g., 'response.output_text.delta'). */
7
- readonly type: string;
8
- readonly data: Record<string, unknown>;
9
- readonly outputIndex?: number;
10
- readonly contentIndex?: number;
11
- }
12
- /** @public Framework-originated event, prefixed with the harness config.name. */
13
- export interface FrameworkStreamEvent {
14
- readonly source: 'framework';
15
- /** Prefixed event type (e.g., 'myagent:step_started'). */
16
- readonly type: `${string}:${string}`;
17
- readonly data: Record<string, unknown>;
18
- }
19
- /** @public Union of all stream event types emitted during execution. */
20
- export type StreamEvent = SdkStreamEvent | FrameworkStreamEvent;
21
- /** @public Final accumulated result of an execution, including all items, usage, cost, and extracted text.
22
- *
23
- * Returned from `AgentHarness.getAgentResponse()`. Resolves once the session's
24
- * message queue drains and the runner goes idle. When multiple turns run in a
25
- * burst (e.g. queued inbox messages), the response covers the span from the
26
- * last-idle point through the point at which idle is reached again.
27
- */
28
- export interface HarnessResponse {
29
- readonly items: ReadonlyArray<Item>;
30
- readonly usage: {
31
- readonly inputTokens: number;
32
- readonly outputTokens: number;
33
- readonly cachedTokens?: number;
34
- };
35
- readonly cost?: number;
36
- readonly text: string;
37
- /** Per-memory-layer context window breakdown captured at the last callModel of this execution. */
38
- readonly lastLayerUsage?: LastLayerUsage;
39
- }
40
- /** @public An Item snapshot with a completion flag, emitted from getItemStream(). */
41
- export type StreamingItem = Item & {
42
- readonly isComplete: boolean;
43
- };
@@ -1,2 +0,0 @@
1
- export {};
2
- //#endregion
@@ -1,131 +0,0 @@
1
- import type * as OpenRouterAgent from '@openrouter/agent';
2
- import type { ZodTypeAny, z } from 'zod';
3
- type ResponseOutputText = OpenRouterAgent.ResponseOutputText;
4
- type ResponsesImageGenerationCall = OpenRouterAgent.OutputImageGenerationCallItem;
5
- type ResponsesOutputItemFileSearchCall = OpenRouterAgent.OutputFileSearchCallItem;
6
- type ResponsesOutputItemFunctionCall = OpenRouterAgent.OutputFunctionCallItem;
7
- type ResponsesOutputItemReasoning = OpenRouterAgent.OutputReasoningItem;
8
- type ResponsesOutputMessage = OpenRouterAgent.OutputMessage;
9
- type ResponsesWebSearchCallOutput = OpenRouterAgent.OutputWebSearchCallItem;
10
- type ResponsesServerToolOutput = Exclude<OpenRouterAgent.OpenResponsesResult['output'][number], OpenRouterAgent.OutputMessage | OpenRouterAgent.OutputFunctionCallItem | OpenRouterAgent.OutputReasoningItem | OpenRouterAgent.OutputWebSearchCallItem | OpenRouterAgent.OutputFileSearchCallItem | OpenRouterAgent.OutputImageGenerationCallItem>;
11
- type OutputMessageContentPart = OpenRouterAgent.OutputMessage['content'][number];
12
- type OpenAIResponsesRefusalContent = Extract<OutputMessageContentPart, {
13
- type: 'refusal';
14
- }>;
15
- type ReasoningContentPart = NonNullable<OpenRouterAgent.OutputReasoningItem['content']>[number];
16
- type SummaryContentPart = NonNullable<OpenRouterAgent.OutputReasoningItem['summary']>[number];
17
- type ReasoningTextContent = Extract<ReasoningContentPart, {
18
- type: 'reasoning_text';
19
- }>;
20
- type ReasoningSummaryText = Extract<SummaryContentPart, {
21
- type: 'summary_text';
22
- }>;
23
- /** @public Model-generated text content with optional annotations and logprobs. */
24
- export type OutputTextPart = ResponseOutputText;
25
- /** @public Model refusal content. */
26
- export type RefusalPart = OpenAIResponsesRefusalContent;
27
- /** @public User/developer input text (framework-created, not from SDK). */
28
- export interface InputTextPart {
29
- readonly type: 'input_text';
30
- readonly text: string;
31
- }
32
- /** @public User image input content. */
33
- export interface InputImagePart {
34
- readonly type: 'input_image';
35
- readonly imageUrl: string;
36
- readonly detail?: 'auto' | 'low' | 'high';
37
- }
38
- /** @public User file input content. */
39
- export interface InputFilePart {
40
- readonly type: 'input_file';
41
- readonly fileData?: string;
42
- readonly fileId?: string | null;
43
- readonly fileUrl?: string;
44
- readonly filename?: string;
45
- }
46
- /** @public Reasoning trace content. */
47
- export type ReasoningTextPart = ReasoningTextContent;
48
- /** @public Reasoning summary content. */
49
- export type SummaryTextPart = ReasoningSummaryText;
50
- /** @public User/developer input content variants. */
51
- export type InputContentPart = InputTextPart | InputImagePart | InputFilePart;
52
- /** @public Content part variants for message items. */
53
- export type ContentPart = OutputTextPart | RefusalPart | InputContentPart;
54
- /** @public Assistant message output item. */
55
- export type MessageItem = ResponsesOutputMessage;
56
- /** @public Function call requested by the model. */
57
- export type FunctionCallItem = ResponsesOutputItemFunctionCall;
58
- /** @public Reasoning trace from the model. */
59
- export type ReasoningItem = ResponsesOutputItemReasoning;
60
- /** @public Web search call result. */
61
- export type WebSearchItem = ResponsesWebSearchCallOutput;
62
- /** @public File search call result. */
63
- export type FileSearchItem = ResponsesOutputItemFileSearchCall;
64
- /** @public Image generation call result. */
65
- export type ImageGenerationItem = ResponsesImageGenerationCall;
66
- /**
67
- * @public Server tool output (vendor-prefixed type like `openrouter:datetime`).
68
- * Constrains provider output items to the vendor-prefixed subset so discriminant narrowing works in Item unions.
69
- */
70
- export type ServerToolItem = Omit<ResponsesServerToolOutput, 'type'> & {
71
- readonly type: `${string}:${string}`;
72
- };
73
- /** @public Base shape required for framework and extension items. */
74
- export interface ItemBase {
75
- readonly type: string;
76
- }
77
- /**
78
- * @public Input message created by the framework (user, system, or developer role).
79
- * Status includes `failed` as a Noetic extension beyond the Open Responses spec
80
- * (which only defines `in_progress | completed | incomplete` for items).
81
- */
82
- export interface InputMessageItem {
83
- readonly id: string;
84
- readonly type: 'message';
85
- readonly role: 'user' | 'system' | 'developer';
86
- readonly status: 'in_progress' | 'completed' | 'incomplete' | 'failed';
87
- readonly content: InputContentPart[];
88
- }
89
- /**
90
- * @public Tool execution output created by the harness during the tool loop.
91
- * This is an input-only item type in Open Responses (sent by the developer, not the model).
92
- */
93
- export interface FunctionCallOutputItem {
94
- readonly id: string;
95
- readonly type: 'function_call_output';
96
- readonly status: 'in_progress' | 'completed' | 'incomplete' | 'failed';
97
- readonly callId: string;
98
- readonly output: string;
99
- }
100
- /** @public Item produced by an extension schema registered by a tool, memory layer, or harness. */
101
- export type ExtensionItem = ItemBase & Record<string, unknown>;
102
- /** @public Developer-role message item refined by a memory-layer extension schema. */
103
- export type DeveloperMessageExtensionItem = InputMessageItem & {
104
- readonly role: 'developer';
105
- } & Record<string, unknown>;
106
- /** @public Function-call item refined by a tool extension schema. */
107
- export type ToolCallExtensionItem = FunctionCallItem & Record<string, unknown>;
108
- /** @public Function-call output item refined by a tool extension schema. */
109
- export type ToolResultExtensionItem = FunctionCallOutputItem & Record<string, unknown>;
110
- /** @public Zod schemas that extend the runtime `Item` union. */
111
- export interface ItemSchemaExtensions {
112
- /** Harness-wide schemas. Any item matching one of these schemas is accepted. */
113
- readonly items?: ReadonlyArray<ZodTypeAny>;
114
- /** Schemas for memory-layer developer message items. */
115
- readonly developerMessages?: ReadonlyArray<ZodTypeAny>;
116
- /** Schemas for tool call items emitted by the model or a harness adapter. */
117
- readonly toolCalls?: ReadonlyArray<ZodTypeAny>;
118
- /** Schemas for tool result items emitted by the harness or a tool adapter. */
119
- readonly toolResults?: ReadonlyArray<ZodTypeAny>;
120
- }
121
- /** @public Type inferred from an `ItemSchemaExtensions` declaration. */
122
- export type InferExtendedItem<TExtensions extends ItemSchemaExtensions | undefined> = TExtensions extends ItemSchemaExtensions ? (TExtensions['items'] extends ReadonlyArray<infer S extends ZodTypeAny> ? z.infer<S> : never) | (TExtensions['developerMessages'] extends ReadonlyArray<infer S extends ZodTypeAny> ? z.infer<S> : never) | (TExtensions['toolCalls'] extends ReadonlyArray<infer S extends ZodTypeAny> ? z.infer<S> : never) | (TExtensions['toolResults'] extends ReadonlyArray<infer S extends ZodTypeAny> ? z.infer<S> : never) : never;
123
- /** @public Item union extended by a concrete `ItemSchemaExtensions` declaration. */
124
- export type ExtendedItem<TExtensions extends ItemSchemaExtensions | undefined> = Item | InferExtendedItem<TExtensions>;
125
- /** @public All output item types from the model (Open Responses compliant). */
126
- export type OutputItem = MessageItem | FunctionCallItem | ReasoningItem | WebSearchItem | FileSearchItem | ImageGenerationItem | ServerToolItem;
127
- /** @public All item types that can appear in an ItemLog. */
128
- export type Item = OutputItem | InputMessageItem | FunctionCallOutputItem;
129
- /** @public Accepted input types for `AgentHarness.execute()`: a plain string, a single Item, or an array of Items. */
130
- export type ExecuteInput = string | Item | Item[];
131
- export {};
@@ -1,2 +0,0 @@
1
- export {};
2
- //#endregion
@@ -1,39 +0,0 @@
1
- import type { LLMResponse } from './common.js';
2
- import type { FsAdapter } from './fs-adapter.js';
3
- import type { Item } from './items.js';
4
- import type { ShellAdapter } from './shell-adapter.js';
5
- /** @public Isolation scope controlling how a memory layer's state is keyed and shared. */
6
- export type MemoryScope = 'thread' | 'resource' | 'global' | 'execution';
7
- /** @public Terminal outcome of an execution run, reported to memory layers on completion. */
8
- export type ExecutionOutcome = 'success' | 'failure' | 'aborted';
9
- /** @public Minimal model-call surface exposed to memory-layer hooks. */
10
- export interface MemoryCallModelRequest {
11
- model: string;
12
- items: ReadonlyArray<Item>;
13
- instructions?: string;
14
- }
15
- /** @public Runtime metadata available to memory layer hooks during each lifecycle phase. */
16
- export interface ExecutionContext {
17
- executionId: string;
18
- threadId: string;
19
- resourceId?: string;
20
- depth: number;
21
- stepNumber: number;
22
- tokenUsage: {
23
- input: number;
24
- output: number;
25
- };
26
- cost: number;
27
- /** Filesystem adapter for virtual or real filesystem access. */
28
- fs: FsAdapter;
29
- /** Shell adapter for virtual or real shell command execution. */
30
- shell: ShellAdapter;
31
- callModel?: (request: MemoryCallModelRequest) => Promise<LLMResponse>;
32
- tokenize(text: string): number;
33
- trace: {
34
- setAttribute(key: string, value: string | number | boolean): void;
35
- addEvent(name: string, attributes?: Record<string, string | number | boolean>): void;
36
- };
37
- /** Snapshot a sibling memory layer's state by its `layer.id`. */
38
- readLayerState<T>(layerId: string): T | undefined;
39
- }
@@ -1 +0,0 @@
1
- export {};