@noetic-tools/types 3.6.0 → 3.8.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.
@@ -22,8 +22,8 @@ export declare class NoeticConfigError extends Error {
22
22
  readonly code: string;
23
23
  /** Complete sentence describing what the user should do next. */
24
24
  readonly hint: string;
25
- /** Link to the relevant docs page, if available. */
26
- readonly docsUrl?: string;
25
+ /** Link to the docs explaining this code; defaults to its section of the error reference. */
26
+ readonly docsUrl: string;
27
27
  constructor(opts: {
28
28
  code: string;
29
29
  message: string;
@@ -31,6 +31,16 @@ export declare class NoeticConfigError extends Error {
31
31
  docsUrl?: string;
32
32
  });
33
33
  }
34
+ /**
35
+ * @public
36
+ * The error reference section for a config error `code`. Each code has a
37
+ * heading of its own name on that page, and the docs site slugs headings to
38
+ * lower case, so the code in lower case is the anchor.
39
+ *
40
+ * @param code - A `NoeticConfigError` code, e.g. `'MISSING_API_KEY'`.
41
+ * @returns The URL of the code's section, e.g. `…/errors#missing_api_key`.
42
+ */
43
+ export declare function configErrorDocsUrl(code: string): string;
34
44
  /**
35
45
  * @public
36
46
  * Type guard for `NoeticConfigError`.
@@ -22,16 +22,29 @@ export class NoeticConfigError extends Error {
22
22
  code;
23
23
  /** Complete sentence describing what the user should do next. */
24
24
  hint;
25
- /** Link to the relevant docs page, if available. */
25
+ /** Link to the docs explaining this code; defaults to its section of the error reference. */
26
26
  docsUrl;
27
27
  constructor(opts) {
28
28
  super(opts.message);
29
29
  this.name = 'NoeticConfigError';
30
30
  this.code = opts.code;
31
31
  this.hint = opts.hint;
32
- this.docsUrl = opts.docsUrl;
32
+ this.docsUrl = opts.docsUrl ?? configErrorDocsUrl(opts.code);
33
33
  }
34
34
  }
35
+ const ERROR_REFERENCE_URL = 'https://noetic.tools/docs/framework/errors';
36
+ /**
37
+ * @public
38
+ * The error reference section for a config error `code`. Each code has a
39
+ * heading of its own name on that page, and the docs site slugs headings to
40
+ * lower case, so the code in lower case is the anchor.
41
+ *
42
+ * @param code - A `NoeticConfigError` code, e.g. `'MISSING_API_KEY'`.
43
+ * @returns The URL of the code's section, e.g. `…/errors#missing_api_key`.
44
+ */
45
+ export function configErrorDocsUrl(code) {
46
+ return `${ERROR_REFERENCE_URL}#${code.toLowerCase()}`;
47
+ }
35
48
  /**
36
49
  * @public
37
50
  * Type guard for `NoeticConfigError`.
@@ -51,6 +51,8 @@ function formatMessage(error) {
51
51
  return `Model rate limited at step '${error.stepId}'${error.retryAfter ? ` (retry after ${error.retryAfter}ms)` : ''}`;
52
52
  case 'fork_partial':
53
53
  return `Fork '${error.stepId}' partial failure: ${error.succeeded.length} succeeded, ${error.failed.length} failed`;
54
+ case 'spawn_summary_failed':
55
+ return `Spawn '${error.stepId}' summary failed: ${error.summaryCause.message}`;
54
56
  case 'channel_timeout':
55
57
  return `Channel '${error.channelName}' timed out after ${error.timeout}ms`;
56
58
  case 'channel_closed':
@@ -181,6 +181,16 @@ declare const AcpSessionPolicySchema: z.ZodObject<{
181
181
  }>>;
182
182
  load: z.ZodOptional<z.ZodString>;
183
183
  }, z.core.$strip>;
184
+ /**
185
+ * @public
186
+ * Which part of a node's input names the work it does, so a resumed run replays the
187
+ * node by content rather than by position. `true` keys on the whole input. `from`
188
+ * keys on those top-level properties of the input parsed as a JSON object — the same
189
+ * lookup an `inParallel` node's `over` does. See spec 26 § Replay keys.
190
+ */
191
+ export type WorkflowReplayKey = true | {
192
+ from: string[];
193
+ };
184
194
  interface WorkflowNodeBase {
185
195
  id: string;
186
196
  /**
@@ -188,6 +198,8 @@ interface WorkflowNodeBase {
188
198
  * `false` makes the node run again on every resume. See spec 23a § Identity.
189
199
  */
190
200
  durable?: boolean;
201
+ /** Replay this node by its input instead of its position. Ignored when `durable` is `false`. */
202
+ replayKey?: WorkflowReplayKey;
191
203
  }
192
204
  /**
193
205
  * A reference to a streaming `OutputCodec` for a `callModel` node's structured
@@ -209,9 +209,16 @@ const AcpSessionPolicySchema = z.object({
209
209
  //#endregion
210
210
  //#region Workflow Node Schema
211
211
  const WorkflowNodeRef = z.lazy(() => WorkflowNodeSchema);
212
+ const WorkflowReplayKeySchema = z.union([
213
+ z.literal(true),
214
+ z.object({
215
+ from: z.array(z.string().min(1)).min(1),
216
+ }),
217
+ ]);
212
218
  const SHARED_FIELDS = {
213
219
  id: z.string().min(1),
214
220
  durable: z.boolean().optional(),
221
+ replayKey: WorkflowReplayKeySchema.optional(),
215
222
  };
216
223
  const OutputCodecRefSchema = z.object({
217
224
  codec: z.literal('openui'),
@@ -63,7 +63,12 @@ export interface ModelParams {
63
63
  topP?: number;
64
64
  /** Maximum number of tokens the model may generate. */
65
65
  maxTokens?: number;
66
- /** Sequences that cause the model to stop generating. */
66
+ /**
67
+ * Sequences that would cause the model to stop generating.
68
+ * @deprecated Not sent to the model: the OpenRouter Responses API that
69
+ * `callModel` uses has no stop parameter. Accepted so existing steps and
70
+ * workflow documents still parse; it will be removed in the next major.
71
+ */
67
72
  stopSequences?: string[];
68
73
  /** OpenRouter service tier to request. Omit to use the provider default. */
69
74
  serviceTier?: ServiceTier;
@@ -32,6 +32,17 @@ export type NoeticError = {
32
32
  stepId: string;
33
33
  error: NoeticError;
34
34
  }>;
35
+ } | {
36
+ /**
37
+ * A spawn's child succeeded but a context layer's `onReturn` hook (for
38
+ * example a summarizer) failed. The runtime does not throw this: the
39
+ * spawn returns `childOutput` and reports this error as a layer
40
+ * diagnostic and a span event, so the child's work is never discarded.
41
+ */
42
+ kind: 'spawn_summary_failed';
43
+ stepId: string;
44
+ childOutput: unknown;
45
+ summaryCause: Error;
35
46
  } | {
36
47
  kind: 'channel_timeout';
37
48
  channelName: string;
@@ -94,6 +94,12 @@ interface CallModelRequestBase {
94
94
  * each span back to its node in the declared DAG.
95
95
  */
96
96
  nodeId?: string;
97
+ /**
98
+ * @internal Attributes for the first `llm.call` span this request opens. Set
99
+ * by `callModel` steps to record how the view was banded (the
100
+ * `noetic.context.*` anchoring attributes).
101
+ */
102
+ spanAttributes?: Record<string, string | number | boolean>;
97
103
  }
98
104
  /** @public Request shape when tools are provided — ctx is required for tool execution callbacks. */
99
105
  interface CallModelRequestWithTools extends CallModelRequestBase {
@@ -319,7 +325,9 @@ export interface AgentHarnessContract<TParams extends Record<string, unknown> =
319
325
  disposeLayers(layers: ContextLayer[], ctx: Context): Promise<void>;
320
326
  checkpoint(ctx: Context): Promise<void>;
321
327
  /**
322
- * Rebuild a `Context` from a persisted snapshot. `opts` carries the wiring
328
+ * Rebuild a `Context` from a persisted snapshot, or from the step-completion
329
+ * ledger alone when no snapshot was saved (recorded steps replay, the rest run
330
+ * fresh). Resolves `null` when neither is recorded. `opts` carries the wiring
323
331
  * the host attached when it created the original context — without it a
324
332
  * decorated context is silently replaced by a bare one on resume.
325
333
  */
@@ -66,6 +66,13 @@ export interface StepSubprocessRequest extends SubprocessRequestBase {
66
66
  serializedInput: unknown;
67
67
  /** Stable id for the execution — used for handle lookup and durable checkpointing. */
68
68
  executionId: string;
69
+ /**
70
+ * Id of the context that created this child (`spawn`, `detachedSpawn`).
71
+ * Durable adapters persist it so a host can `harness.restore()` the parent
72
+ * after a restart. Absent for a `runCode`, which runs on the dispatching
73
+ * context itself.
74
+ */
75
+ parentExecutionId?: string;
69
76
  /** Child-context overrides (thread, resource, cwd). */
70
77
  overrides: StepSubprocessOverrides;
71
78
  /**
@@ -92,6 +99,8 @@ export interface SubprocessHandleMetadata extends Record<string, unknown> {
92
99
  error?: SerializedError;
93
100
  /** Execution id echoed from the originating `StepSubprocessRequest`. */
94
101
  executionId?: string;
102
+ /** Parent execution id echoed from the originating `StepSubprocessRequest`. */
103
+ parentExecutionId?: string;
95
104
  }
96
105
  /** @public Handle returned by `SubprocessAdapter.spawn()` — a durable reference to a child. */
97
106
  export interface SubprocessHandle {
@@ -127,7 +127,11 @@ export interface Tool<I extends StandardSchemaV1 = StandardSchemaV1, O extends S
127
127
  * the call site to get a typed handle.
128
128
  */
129
129
  execute(args: InferSchemaOutput<I>, toolCtx: unknown): ToolExecutionResult<O>;
130
- /** When true, execution pauses for human approval before running. */
130
+ /**
131
+ * Declares that a call needs human approval before it runs. Core records the
132
+ * flag on `tool.call` spans but does not pause on it: a `beforeToolCall`
133
+ * gating layer or the tool's own integration must enforce it.
134
+ */
131
135
  needsApproval?: boolean;
132
136
  /** Optional context declaration — the runtime generates a ContextLayer from this. */
133
137
  context?: ToolContextDeclaration;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@noetic-tools/types",
3
- "version": "3.6.0",
3
+ "version": "3.8.0",
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",