@noetic-tools/core 5.3.0 → 5.4.1

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 (94) hide show
  1. package/README.md +8 -6
  2. package/dist/adapters/in-memory-subprocess/step-completion.js +1 -1
  3. package/dist/adapters/openrouter.d.ts +12 -1
  4. package/dist/adapters/openrouter.js +79 -5
  5. package/dist/builders/acp-agent-tool.d.ts +67 -0
  6. package/dist/builders/acp-agent-tool.js +87 -0
  7. package/dist/builders/control-flow-builders.d.ts +13 -13
  8. package/dist/builders/control-flow-builders.js +11 -11
  9. package/dist/{patterns → builders}/dynamic-workflow.d.ts +1 -1
  10. package/dist/{patterns → builders}/dynamic-workflow.js +20 -14
  11. package/dist/builders/every.d.ts +14 -14
  12. package/dist/builders/every.js +16 -16
  13. package/dist/builders/layer-provides-builders.d.ts +1 -1
  14. package/dist/builders/layer-provides-builders.js +1 -1
  15. package/dist/builders/provide-builder.d.ts +5 -12
  16. package/dist/builders/provide-builder.js +9 -10
  17. package/dist/builders/spawn-builder.d.ts +0 -2
  18. package/dist/builders/spawn-builder.js +2 -3
  19. package/dist/builders/step-builders.d.ts +103 -92
  20. package/dist/builders/step-builders.js +146 -163
  21. package/dist/builders/tool-builder.d.ts +18 -22
  22. package/dist/builders/tool-builder.js +6 -4
  23. package/dist/builders/workflow-hydrator.d.ts +11 -7
  24. package/dist/builders/workflow-hydrator.js +75 -87
  25. package/dist/builders/workflow-step.d.ts +15 -27
  26. package/dist/builders/workflow-step.js +14 -19
  27. package/dist/conditions/conditions.d.ts +2 -2
  28. package/dist/conditions/conditions.js +1 -1
  29. package/dist/harness/agent-harness.d.ts +89 -46
  30. package/dist/harness/agent-harness.js +93 -39
  31. package/dist/harness/deps/types.d.ts +1 -1
  32. package/dist/harness/model-call.d.ts +1 -1
  33. package/dist/harness/model-call.js +23 -18
  34. package/dist/index.d.ts +27 -35
  35. package/dist/index.js +13 -29
  36. package/dist/interpreter/acp-events.d.ts +67 -0
  37. package/dist/interpreter/acp-events.js +256 -0
  38. package/dist/interpreter/acp-history.d.ts +22 -0
  39. package/dist/interpreter/acp-history.js +58 -0
  40. package/dist/interpreter/action-types.d.ts +1 -1
  41. package/dist/interpreter/collect-tools.js +10 -13
  42. package/dist/interpreter/execute-acp-agent.d.ts +10 -0
  43. package/dist/interpreter/execute-acp-agent.js +505 -0
  44. package/dist/interpreter/execute-action.d.ts +5 -5
  45. package/dist/interpreter/execute-action.js +284 -218
  46. package/dist/interpreter/execute-control.d.ts +9 -9
  47. package/dist/interpreter/execute-control.js +27 -27
  48. package/dist/interpreter/execute.d.ts +1 -1
  49. package/dist/interpreter/execute.js +29 -35
  50. package/dist/interpreter/step-dispatcher.d.ts +1 -1
  51. package/dist/interpreter/step-dispatcher.js +3 -3
  52. package/dist/interpreter/structured-output.d.ts +14 -0
  53. package/dist/interpreter/structured-output.js +40 -0
  54. package/dist/interpreter/typeguards.d.ts +1 -1
  55. package/dist/interpreter/typeguards.js +1 -1
  56. package/dist/portable/builders.d.ts +5 -3
  57. package/dist/portable/builders.js +8 -5
  58. package/dist/portable/context-layers.d.ts +1 -1
  59. package/dist/portable/context-layers.js +1 -1
  60. package/dist/runtime/acp-session-store.d.ts +75 -0
  61. package/dist/runtime/acp-session-store.js +0 -0
  62. package/dist/runtime/broadcaster-utils.d.ts +1 -1
  63. package/dist/runtime/broadcaster-utils.js +1 -1
  64. package/dist/runtime/context-impl.d.ts +8 -10
  65. package/dist/runtime/context-impl.js +8 -12
  66. package/dist/runtime/durable/step-ledger.d.ts +2 -2
  67. package/dist/runtime/durable/step-ledger.js +3 -3
  68. package/dist/runtime/session-runner.d.ts +12 -1
  69. package/dist/runtime/session-runner.js +33 -1
  70. package/dist/runtime/tool-context.js +0 -2
  71. package/dist/schemas/workflow.d.ts +3 -3
  72. package/dist/schemas/workflow.js +2 -2
  73. package/dist/types/checkpoint.d.ts +11 -2
  74. package/dist/types/checkpoint.js +10 -1
  75. package/dist/{runtime → util}/detached-handle.js +1 -1
  76. package/package.json +6 -4
  77. package/schema/noetic-workflow.schema.json +239 -260
  78. package/dist/builders/context-option.d.ts +0 -23
  79. package/dist/builders/context-option.js +0 -22
  80. package/dist/deprecated.d.ts +0 -30
  81. package/dist/deprecated.js +0 -28
  82. package/dist/interpreter/execute-sub-harness.d.ts +0 -8
  83. package/dist/interpreter/execute-sub-harness.js +0 -241
  84. package/dist/interpreter/sub-harness-events.d.ts +0 -48
  85. package/dist/interpreter/sub-harness-events.js +0 -208
  86. package/dist/patterns/interview.d.ts +0 -53
  87. package/dist/patterns/interview.js +0 -113
  88. package/dist/patterns/plans.d.ts +0 -44
  89. package/dist/patterns/plans.js +0 -125
  90. package/dist/patterns/ralph-wiggum.d.ts +0 -19
  91. package/dist/patterns/ralph-wiggum.js +0 -37
  92. package/dist/patterns/react.d.ts +0 -19
  93. package/dist/patterns/react.js +0 -41
  94. /package/dist/{runtime → util}/detached-handle.d.ts +0 -0
@@ -1,44 +1,44 @@
1
1
  import type { ContextData } from '@noetic-tools/context';
2
- import type { Channel, EveryErrorPolicy, Step, StepEvery } from '@noetic-tools/types';
2
+ import type { Channel, ScheduleErrorPolicy, Step, StepSchedule } from '@noetic-tools/types';
3
3
  /**
4
- * Configuration options accepted by the `every()` builder, excluding the `kind`
5
- * discriminant. `every()` schedules a body step on a fixed-interval, optionally
4
+ * Configuration options accepted by the `schedule()` builder, excluding the `kind`
5
+ * discriminant. `schedule()` schedules a body step on a fixed-interval, optionally
6
6
  * woken early by a channel, and runs until the executing context is cancelled.
7
7
  *
8
8
  * @public
9
9
  */
10
- export interface EveryOptions<TContext = ContextData, I = unknown, O = unknown> {
10
+ export interface ScheduleOptions<TContext = ContextData, I = unknown, O = unknown> {
11
11
  /** Unique step identifier used in traces and error messages. */
12
12
  id: string;
13
13
  /** Body step executed on each iteration. */
14
14
  step: Step<TContext, I, O>;
15
15
  /** Park duration between iterations in milliseconds. Must be >= 0. */
16
- ms: number;
16
+ interval: number;
17
17
  /** Optional channel that wakes the parking interval when any value arrives. */
18
- wakeOn?: Channel<unknown>;
18
+ inbox?: Channel<unknown>;
19
19
  /** Behavior when `step` throws. Defaults to `'continue'`. */
20
- onError?: EveryErrorPolicy;
20
+ onError?: ScheduleErrorPolicy;
21
21
  /** Random jitter applied to the park duration in milliseconds. Must be >= 0. Default 0. */
22
22
  jitter?: number;
23
23
  }
24
24
  /**
25
- * Creates an `every` step that runs a body step on a fixed-interval schedule.
25
+ * Creates a `schedule` step that runs a body step on a fixed-interval schedule.
26
26
  *
27
27
  * The operator runs forever until the executing context is cancelled. After each
28
- * iteration it parks for `ms ± jitter` milliseconds (or until `wakeOn` receives
28
+ * iteration it parks for `interval ± jitter` milliseconds (or until `inbox` receives
29
29
  * a message, whichever comes first).
30
30
  *
31
31
  * @public
32
32
  * @param opts.id - Unique step identifier used in traces and error messages.
33
33
  * @param opts.step - Body step executed on each iteration.
34
- * @param opts.ms - Park duration between iterations in milliseconds.
35
- * @param opts.wakeOn - Optional channel that wakes the parking interval when any value arrives.
34
+ * @param opts.interval - Park duration between iterations in milliseconds.
35
+ * @param opts.inbox - Optional channel that wakes the parking interval when any value arrives.
36
36
  * @param opts.onError - Error policy. `'continue'` (default) records a span event and continues; `'fail'` re-throws.
37
37
  * @param opts.jitter - Random jitter in ms applied to the park duration. Default 0.
38
- * @returns A `StepEvery` step.
38
+ * @returns A `StepSchedule` step.
39
39
  * @throws `NoeticConfigError` with code `EMPTY_STEP_ID` if `id` is empty.
40
40
  * @throws `NoeticConfigError` with code `MISSING_BODY_STEP` if `step` is not provided.
41
- * @throws `NoeticConfigError` with code `INVALID_INTERVAL_MS` if `ms` is negative or not finite.
41
+ * @throws `NoeticConfigError` with code `INVALID_INTERVAL_MS` if `interval` is negative or not finite.
42
42
  * @throws `NoeticConfigError` with code `INVALID_JITTER` if `jitter` is negative or not finite.
43
43
  */
44
- export declare function every<TContext = ContextData, I = unknown, O = unknown>(opts: EveryOptions<TContext, I, O>): StepEvery<TContext, I, O>;
44
+ export declare function schedule<TContext = ContextData, I = unknown, O = unknown>(opts: ScheduleOptions<TContext, I, O>): StepSchedule<TContext, I, O>;
@@ -1,60 +1,60 @@
1
1
  import { NoeticConfigError } from '@noetic-tools/types';
2
2
  import { getDefaultRegistrar } from '../types/step-registrar.js';
3
3
  /**
4
- * Creates an `every` step that runs a body step on a fixed-interval schedule.
4
+ * Creates a `schedule` step that runs a body step on a fixed-interval schedule.
5
5
  *
6
6
  * The operator runs forever until the executing context is cancelled. After each
7
- * iteration it parks for `ms ± jitter` milliseconds (or until `wakeOn` receives
7
+ * iteration it parks for `interval ± jitter` milliseconds (or until `inbox` receives
8
8
  * a message, whichever comes first).
9
9
  *
10
10
  * @public
11
11
  * @param opts.id - Unique step identifier used in traces and error messages.
12
12
  * @param opts.step - Body step executed on each iteration.
13
- * @param opts.ms - Park duration between iterations in milliseconds.
14
- * @param opts.wakeOn - Optional channel that wakes the parking interval when any value arrives.
13
+ * @param opts.interval - Park duration between iterations in milliseconds.
14
+ * @param opts.inbox - Optional channel that wakes the parking interval when any value arrives.
15
15
  * @param opts.onError - Error policy. `'continue'` (default) records a span event and continues; `'fail'` re-throws.
16
16
  * @param opts.jitter - Random jitter in ms applied to the park duration. Default 0.
17
- * @returns A `StepEvery` step.
17
+ * @returns A `StepSchedule` step.
18
18
  * @throws `NoeticConfigError` with code `EMPTY_STEP_ID` if `id` is empty.
19
19
  * @throws `NoeticConfigError` with code `MISSING_BODY_STEP` if `step` is not provided.
20
- * @throws `NoeticConfigError` with code `INVALID_INTERVAL_MS` if `ms` is negative or not finite.
20
+ * @throws `NoeticConfigError` with code `INVALID_INTERVAL_MS` if `interval` is negative or not finite.
21
21
  * @throws `NoeticConfigError` with code `INVALID_JITTER` if `jitter` is negative or not finite.
22
22
  */
23
- export function every(opts) {
23
+ export function schedule(opts) {
24
24
  if (!opts.id || opts.id.trim() === '') {
25
25
  throw new NoeticConfigError({
26
26
  code: 'EMPTY_STEP_ID',
27
- message: 'every() requires a non-empty id.',
28
- hint: 'Pass a unique string as the id field, e.g. every({ id: "my-every", ... }).',
27
+ message: 'schedule() requires a non-empty id.',
28
+ hint: 'Pass a unique string as the id field, e.g. schedule({ id: "my-schedule", ... }).',
29
29
  });
30
30
  }
31
31
  if (!opts.step) {
32
32
  throw new NoeticConfigError({
33
33
  code: 'MISSING_BODY_STEP',
34
- message: 'every() requires a body step.',
34
+ message: 'schedule() requires a body step.',
35
35
  hint: 'Provide the step to execute on each scheduled iteration.',
36
36
  });
37
37
  }
38
- if (!Number.isFinite(opts.ms) || opts.ms < 0) {
38
+ if (!Number.isFinite(opts.interval) || opts.interval < 0) {
39
39
  throw new NoeticConfigError({
40
40
  code: 'INVALID_INTERVAL_MS',
41
- message: `every() requires a non-negative finite ms, got ${opts.ms}.`,
41
+ message: `schedule() requires a non-negative finite interval, got ${opts.interval}.`,
42
42
  hint: 'Pass a non-negative number of milliseconds for the park interval.',
43
43
  });
44
44
  }
45
45
  if (opts.jitter !== undefined && (!Number.isFinite(opts.jitter) || opts.jitter < 0)) {
46
46
  throw new NoeticConfigError({
47
47
  code: 'INVALID_JITTER',
48
- message: `every() requires a non-negative finite jitter, got ${opts.jitter}.`,
48
+ message: `schedule() requires a non-negative finite jitter, got ${opts.jitter}.`,
49
49
  hint: 'Pass a non-negative number of milliseconds for jitter, or omit it.',
50
50
  });
51
51
  }
52
52
  const built = {
53
- kind: 'every',
53
+ kind: 'schedule',
54
54
  id: opts.id,
55
55
  step: opts.step,
56
- ms: opts.ms,
57
- wakeOn: opts.wakeOn,
56
+ interval: opts.interval,
57
+ inbox: opts.inbox,
58
58
  onError: opts.onError ?? 'continue',
59
59
  jitter: opts.jitter ?? 0,
60
60
  };
@@ -1 +1 @@
1
- export { layerData, layerFn } from '@noetic-tools/context';
1
+ export { layerData, layerFunction } from '@noetic-tools/context';
@@ -1 +1 @@
1
- export { layerData, layerFn } from '@noetic-tools/context';
1
+ export { layerData, layerFunction } from '@noetic-tools/context';
@@ -1,5 +1,5 @@
1
1
  import type { ContextConfig, ContextData, ContextLayer } from '@noetic-tools/context';
2
- import type { Step, StepProvide } from '@noetic-tools/types';
2
+ import type { Step, StepWithContext } from '@noetic-tools/types';
3
3
  /**
4
4
  * Creates a provide step that attaches context layers to its child without creating an isolated context.
5
5
  * Like React's Context.Provider — layers are available to all descendant steps.
@@ -9,19 +9,12 @@ import type { Step, StepProvide } from '@noetic-tools/types';
9
9
  * @param opts.id - Unique step identifier used in traces and error messages.
10
10
  * @param opts.child - Step to execute with the provided layers.
11
11
  * @param opts.context - Context layers to provide to descendant steps.
12
- * @returns A `StepProvide` step.
12
+ * @returns A `StepWithContext` step.
13
13
  * @throws `NoeticConfigError` with code `EMPTY_STEP_ID` if `id` is empty.
14
14
  * @throws `NoeticConfigError` with code `MISSING_CHILD_STEP` if `child` is not provided.
15
15
  */
16
- export declare function provide<TContext = ContextData, I = unknown, O = unknown>(opts: {
16
+ export declare function withContext<TContext = ContextData, I = unknown, O = unknown>(opts: {
17
17
  id: string;
18
18
  child: Step<TContext, I, O>;
19
- /**
20
- * Optional in the type only so the deprecated `memory` spelling remains a
21
- * valid way to supply the layers. Exactly one of the two is required — the
22
- * runtime enforces it, the same way `id` and `child` are enforced.
23
- */
24
- context?: ContextConfig | ContextLayer[];
25
- /** @deprecated Renamed to `context`. */
26
- memory?: ContextConfig | ContextLayer[];
27
- }): StepProvide<TContext, I, O>;
19
+ context: ContextConfig | ContextLayer[];
20
+ }): StepWithContext<TContext, I, O>;
@@ -1,6 +1,5 @@
1
1
  import { NoeticConfigError } from '@noetic-tools/types';
2
2
  import { getDefaultRegistrar } from '../types/step-registrar.js';
3
- import { resolveContextOption } from './context-option.js';
4
3
  /**
5
4
  * Creates a provide step that attaches context layers to its child without creating an isolated context.
6
5
  * Like React's Context.Provider — layers are available to all descendant steps.
@@ -10,35 +9,35 @@ import { resolveContextOption } from './context-option.js';
10
9
  * @param opts.id - Unique step identifier used in traces and error messages.
11
10
  * @param opts.child - Step to execute with the provided layers.
12
11
  * @param opts.context - Context layers to provide to descendant steps.
13
- * @returns A `StepProvide` step.
12
+ * @returns A `StepWithContext` step.
14
13
  * @throws `NoeticConfigError` with code `EMPTY_STEP_ID` if `id` is empty.
15
14
  * @throws `NoeticConfigError` with code `MISSING_CHILD_STEP` if `child` is not provided.
16
15
  */
17
- export function provide(opts) {
16
+ export function withContext(opts) {
18
17
  if (!opts.id?.trim()) {
19
18
  throw new NoeticConfigError({
20
19
  code: 'EMPTY_STEP_ID',
21
- message: 'provide() requires a non-empty id.',
22
- hint: 'Pass a unique string as the id field, e.g. provide({ id: "my-provider", ... }).',
20
+ message: 'withContext() requires a non-empty id.',
21
+ hint: 'Pass a unique string as the id field, e.g. withContext({ id: "my-provider", ... }).',
23
22
  });
24
23
  }
25
24
  if (!opts.child) {
26
25
  throw new NoeticConfigError({
27
26
  code: 'MISSING_CHILD_STEP',
28
- message: 'provide() requires a child step.',
27
+ message: 'withContext() requires a child step.',
29
28
  hint: 'Provide a child step to execute with the provided context layers.',
30
29
  });
31
30
  }
32
- const layers = resolveContextOption(opts);
31
+ const layers = opts.context;
33
32
  if (!layers) {
34
33
  throw new NoeticConfigError({
35
34
  code: 'MISSING_CONTEXT_LAYERS',
36
- message: 'provide() requires context layers.',
37
- hint: 'Pass context: [workingMemoryContext()]. The `memory` key is the deprecated spelling of `context`.',
35
+ message: 'withContext() requires context layers.',
36
+ hint: 'Pass context: [scratchpad()].',
38
37
  });
39
38
  }
40
39
  const built = {
41
- kind: 'provide',
40
+ kind: 'withContext',
42
41
  id: opts.id,
43
42
  child: opts.child,
44
43
  context: layers,
@@ -4,8 +4,6 @@ interface SpawnOpts<TContext, I, O> {
4
4
  id: string;
5
5
  child: Step<TContext, I, O>;
6
6
  context?: ContextConfig | ContextLayer[];
7
- /** @deprecated Renamed to `context`. */
8
- memory?: ContextConfig | ContextLayer[];
9
7
  timeout?: number;
10
8
  /**
11
9
  * Optional per-step subprocess adapter override. The interpreter routes
@@ -1,6 +1,5 @@
1
1
  import { NoeticConfigError } from '@noetic-tools/types';
2
2
  import { getDefaultRegistrar } from '../types/step-registrar.js';
3
- import { resolveContextOption } from './context-option.js';
4
3
  //#endregion
5
4
  //#region Public API
6
5
  /**
@@ -38,12 +37,12 @@ export function spawn(opts) {
38
37
  kind: 'spawn',
39
38
  id: opts.id,
40
39
  child: opts.child,
41
- context: resolveContextOption(opts),
40
+ context: opts.context,
42
41
  timeout: opts.timeout,
43
42
  subprocess: opts.subprocess,
44
43
  };
45
44
  getDefaultRegistrar().register(built);
46
- // Ensure the child is addressable by id — builders for `run`/`llm`/`tool`
45
+ // Ensure the child is addressable by id — builders for `runCode`/`callModel`/`invokeTool`
47
46
  // self-register, but a caller can construct a step literal and pass it as
48
47
  // `child` without going through a builder.
49
48
  getDefaultRegistrar().register(opts.child);
@@ -1,7 +1,6 @@
1
1
  import type { ContextData } from '@noetic-tools/context';
2
- import type { Context, Lazy, ModelParams, OutputCodec, RetryPolicy, ServerToolSpec, StepLLM, StepRun, StepSubHarness, StepTool, SubHarness, SubHarnessSessionPolicy, SubHarnessSettings, SubprocessAdapter, Tool } from '@noetic-tools/types';
3
- import type { ZodType } from 'zod';
4
- export interface StepRunOpts<TContext, I, O> {
2
+ import type { AcpAgent, AcpClientCapabilityConfig, AcpContentBlock, AcpMcpServer, AcpPermissionHandler, AcpPermissionPolicy, AcpSessionPolicy, Context, Lazy, ModelParams, OutputCodec, RetryPolicy, ServerToolSpec, StandardSchemaV1, StepAcpAgent, StepCallModel, StepInvokeTool, StepRunCode, SubprocessAdapter, Tool } from '@noetic-tools/types';
3
+ export interface RunCodeOpts<TContext, I, O> {
5
4
  id: string;
6
5
  execute: (input: I, ctx: Context<TContext>) => Promise<O>;
7
6
  retry?: RetryPolicy;
@@ -12,7 +11,7 @@ export interface StepRunOpts<TContext, I, O> {
12
11
  */
13
12
  subprocess?: SubprocessAdapter;
14
13
  }
15
- export interface StepLLMOpts<TContext, O> {
14
+ export interface CallModelOpts<TContext, O> {
16
15
  id: string;
17
16
  /** Model id. Eager string or `(ctx) => string` getter (resolved at step execution). */
18
17
  model: Lazy<string, TContext>;
@@ -24,110 +23,122 @@ export interface StepLLMOpts<TContext, O> {
24
23
  * server tool the provider executes, e.g. web search/fetch).
25
24
  */
26
25
  tools?: Lazy<(Tool | ServerToolSpec)[] | undefined, TContext>;
27
- /** Structured output: a Zod schema or a streaming `OutputCodec` (e.g. OpenUI Lang). */
28
- output?: ZodType<O> | OutputCodec<O>;
26
+ /** Structured output: a Standard Schema (Zod, Valibot, …) or a streaming `OutputCodec` (e.g. OpenUI Lang). */
27
+ output?: StandardSchemaV1<unknown, O> | OutputCodec<O>;
28
+ /**
29
+ * Explicit raw JSON Schema override sent to the model. For non-Zod schemas,
30
+ * it takes precedence over StandardJSONSchemaV1 conversion.
31
+ */
32
+ outputJsonSchema?: Record<string, unknown>;
29
33
  params?: ModelParams;
30
34
  emit?: boolean | ((eventType: string, data: Record<string, unknown>) => boolean);
31
35
  }
32
- export interface StepToolOpts<I, O> {
36
+ export interface InvokeToolOpts<I, O> {
33
37
  id: string;
34
- tool: Tool<ZodType<I>, ZodType<O>>;
38
+ tool: Tool<StandardSchemaV1<unknown, I>, StandardSchemaV1<unknown, O>>;
35
39
  args?: Partial<I>;
36
40
  }
37
- export interface StepSubHarnessOpts<TContext, O> {
41
+ export interface StepAcpAgentOpts<TContext, O> {
38
42
  id: string;
39
- /** The harness adapter created by a `@noetic-tools/sub-harness-*` factory. Eager or `(ctx) => SubHarness`. */
40
- harness: Lazy<SubHarness, TContext>;
41
- /** Turn prompt. Eager string or `(ctx) => string` getter. */
42
- prompt: Lazy<string, TContext>;
43
- /** Shared harness settings (model, permission mode, …). */
44
- settings?: SubHarnessSettings;
45
- /** System instructions applied on the first message of a fresh session. */
46
- instructions?: Lazy<string | undefined, TContext>;
47
- /** Optional Zod schema; when set the assistant text is JSON-parsed and validated. */
48
- output?: ZodType<O>;
43
+ /** An ACP agent adapter, e.g. `claudeCode()` from `@noetic-tools/acp`. Eager or `(ctx) => AcpAgent`. */
44
+ agent: Lazy<AcpAgent, TContext>;
45
+ /** Turn prompt as plain text. Eager string or `(ctx) => string` getter. */
46
+ prompt?: Lazy<string, TContext>;
47
+ /**
48
+ * Full ACP prompt content — images, audio, resource links, embedded context.
49
+ * Appended after `prompt`. Rejected before the turn is sent when the agent
50
+ * did not advertise the matching prompt capability.
51
+ */
52
+ content?: Lazy<ReadonlyArray<AcpContentBlock> | undefined, TContext>;
53
+ /** MCP servers to expose to the agent for this session. */
54
+ mcpServers?: Lazy<ReadonlyArray<AcpMcpServer> | undefined, TContext>;
55
+ /** Working directory for the session. Defaults to `ctx.cwdState.cwd`. */
56
+ cwd?: Lazy<string | undefined, TContext>;
57
+ /** Session mode to switch to before prompting (e.g. `'plan'`). */
58
+ mode?: Lazy<string | undefined, TContext>;
59
+ /** Model to select before prompting, for agents that expose model selection. */
60
+ model?: Lazy<string | undefined, TContext>;
61
+ /** Declarative answer to the agent's permission requests. Defaults to denying. */
62
+ permissions?: AcpPermissionPolicy;
63
+ /** Async resolver consulted when the policy and steering both abstain. */
64
+ onPermissionRequest?: AcpPermissionHandler;
65
+ /** Which client capabilities to advertise to the agent. */
66
+ clientCapabilities?: AcpClientCapabilityConfig;
67
+ /** Optional Standard Schema; when set the assistant text is JSON-parsed and validated. */
68
+ output?: StandardSchemaV1<unknown, O>;
49
69
  /** Session reuse + teardown policy across steps. */
50
- session?: SubHarnessSessionPolicy;
70
+ session?: AcpSessionPolicy;
51
71
  emit?: boolean | ((eventType: string, data: Record<string, unknown>) => boolean);
52
72
  }
73
+ /**
74
+ * Creates a pure async computation step.
75
+ *
76
+ * @public
77
+ * @param opts.id - Unique step identifier used in traces and error messages.
78
+ * @param opts.execute - Async function `(input, ctx) => output` that performs the work.
79
+ * @param opts.retry - Optional retry policy controlling attempts, backoff, and delay.
80
+ * @param opts.subprocess - Optional per-step subprocess adapter override.
81
+ * @returns A `StepRunCode` that can be composed into larger pipelines. The step
82
+ * is auto-registered in the shared step registry so the subprocess
83
+ * adapter can dispatch it by id.
84
+ * @throws `NoeticConfigError` with code `EMPTY_STEP_ID` if `id` is empty.
85
+ * @throws `NoeticConfigError` with code `MISSING_EXECUTE_FUNCTION` if `execute` is not provided.
86
+ * @throws `NoeticConfigError` with code `DUPLICATE_STEP_ID` if another step with the same id is already registered with a different body.
87
+ */
88
+ export declare function runCode<TContext = ContextData, I = unknown, O = unknown>(opts: RunCodeOpts<TContext, I, O>): StepRunCode<TContext, I, O>;
89
+ /**
90
+ * Creates a model call step with optional tools and structured output.
91
+ *
92
+ * @public
93
+ * @param opts.id - Unique step identifier used in traces and error messages.
94
+ * @param opts.model - Model identifier, eager string or `(ctx) => string` getter (resolved at step execution time).
95
+ * @param opts.instructions - Optional system prompt; eager string or `(ctx) => string | undefined` getter.
96
+ * @param opts.tools - Optional tools; eager array or `(ctx) => Tool[] | undefined` getter.
97
+ * @param opts.output - Optional Zod schema enabling structured output parsing.
98
+ * @param opts.params - Optional model parameters (temperature, topP, maxTokens, stopSequences).
99
+ * @returns A `StepCallModel` that can be composed into larger pipelines. The step
100
+ * is auto-registered in the shared step registry.
101
+ * @throws `NoeticConfigError` with code `EMPTY_STEP_ID` if `id` is empty.
102
+ * @throws `NoeticConfigError` with code `MISSING_MODEL` if an eager `model` string is empty. Function-form models are validated at step execution.
103
+ */
104
+ export declare function callModel<TContext = ContextData, I = unknown, O = unknown>(opts: CallModelOpts<TContext, O>): StepCallModel<TContext, I, O>;
105
+ /**
106
+ * Creates a tool execution step that invokes a typed tool definition.
107
+ *
108
+ * @public
109
+ * @param opts.id - Unique step identifier used in traces and error messages.
110
+ * @param opts.tool - The tool definition with typed input/output schemas.
111
+ * @param opts.args - Optional partial args that override or supplement model-provided arguments.
112
+ * @returns A `StepInvokeTool` that can be composed into larger pipelines. The step
113
+ * is auto-registered in the shared step registry.
114
+ * @throws `NoeticConfigError` with code `EMPTY_STEP_ID` if `id` is empty.
115
+ * @throws `NoeticConfigError` with code `MISSING_TOOL` if `tool` is not provided.
116
+ */
117
+ export declare function invokeTool<TContext = ContextData, I = unknown, O = unknown>(opts: InvokeToolOpts<I, O>): StepInvokeTool<TContext, I, O>;
118
+ /**
119
+ * The ACP step builder namespace. Unlike the flattened base builders
120
+ * (`runCode`, `callModel`, `invokeTool`), the coding-agent builder stays
121
+ * grouped under `step`.
122
+ *
123
+ * @public
124
+ */
53
125
  export declare const step: {
54
126
  /**
55
- * Creates a pure async computation step.
127
+ * Creates a step that delegates a turn to an external coding agent over the
128
+ * Agent Client Protocol.
56
129
  *
57
- * @public
58
- * @param opts.id - Unique step identifier used in traces and error messages.
59
- * @param opts.execute - Async function `(input, ctx) => output` that performs the work.
60
- * @param opts.retry - Optional retry policy controlling attempts, backoff, and delay.
61
- * @param opts.subprocess - Optional per-step subprocess adapter override.
62
- * @returns A `StepRun` that can be composed into larger pipelines. The step
63
- * is auto-registered in the shared step registry so the subprocess
64
- * adapter can dispatch it by id.
65
- * @throws `NoeticConfigError` with code `EMPTY_STEP_ID` if `id` is empty.
66
- * @throws `NoeticConfigError` with code `MISSING_EXECUTE_FUNCTION` if `execute` is not provided.
67
- * @throws `NoeticConfigError` with code `DUPLICATE_STEP_ID` if another step with the same id is already registered with a different body.
68
- */
69
- run<TContext = ContextData, I = unknown, O = unknown>(opts: StepRunOpts<TContext, I, O>): StepRun<TContext, I, O>;
70
- /**
71
- * Creates an LLM model call step with optional tools and structured output.
72
- *
73
- * @public
74
- * @param opts.id - Unique step identifier used in traces and error messages.
75
- * @param opts.model - Model identifier, eager string or `(ctx) => string` getter (resolved at step execution time).
76
- * @param opts.instructions - Optional system prompt; eager string or `(ctx) => string | undefined` getter.
77
- * @param opts.tools - Optional tools; eager array or `(ctx) => Tool[] | undefined` getter.
78
- * @param opts.output - Optional Zod schema enabling structured output parsing.
79
- * @param opts.params - Optional model parameters (temperature, topP, maxTokens, stopSequences).
80
- * @returns A `StepLLM` that can be composed into larger pipelines. The step
81
- * is auto-registered in the shared step registry.
82
- * @throws `NoeticConfigError` with code `EMPTY_STEP_ID` if `id` is empty.
83
- * @throws `NoeticConfigError` with code `MISSING_MODEL` if an eager `model` string is empty. Function-form models are validated at step execution.
84
- */
85
- llm<TContext = ContextData, I = unknown, O = unknown>(opts: StepLLMOpts<TContext, O>): StepLLM<TContext, I, O>;
86
- /**
87
- * Creates a tool execution step that invokes a typed tool definition.
88
- *
89
- * @public
90
- * @param opts.id - Unique step identifier used in traces and error messages.
91
- * @param opts.tool - The tool definition with typed input/output schemas.
92
- * @param opts.args - Optional partial args that override or supplement LLM-provided arguments.
93
- * @returns A `StepTool` that can be composed into larger pipelines. The step
94
- * is auto-registered in the shared step registry.
95
- * @throws `NoeticConfigError` with code `EMPTY_STEP_ID` if `id` is empty.
96
- * @throws `NoeticConfigError` with code `MISSING_TOOL` if `tool` is not provided.
97
- */
98
- tool<TContext = ContextData, I = unknown, O = unknown>(opts: StepToolOpts<I, O>): StepTool<TContext, I, O>;
99
- /**
100
- * Creates a step that delegates a turn to the Claude Code harness.
130
+ * One builder covers every ACP-speaking agent: the agent itself is supplied
131
+ * as an adapter, so adding an agent never changes this API or the published
132
+ * workflow schema.
101
133
  *
102
134
  * @public
103
135
  * @param opts.id - Unique step identifier.
104
- * @param opts.harness - A `claudeCode(...)` adapter from `@noetic-tools/sub-harness-claude-code`.
136
+ * @param opts.agent - An agent adapter, e.g. `claudeCode()` from `@noetic-tools/acp`.
105
137
  * @param opts.prompt - The turn prompt; eager string or `(ctx) => string` getter.
106
- * @param opts.settings - Shared harness settings (model, permission mode, …).
107
- * @param opts.output - Optional Zod schema enabling structured output parsing.
108
- * @returns A `StepSubHarness` of kind `claude-code`, auto-registered in the step registry.
109
- * @throws `NoeticConfigError` `EMPTY_STEP_ID` / `MISSING_SUB_HARNESS` / `SUB_HARNESS_KIND_MISMATCH`.
110
- */
111
- claudeCode<TContext = ContextData, I = unknown, O = unknown>(opts: StepSubHarnessOpts<TContext, O>): StepSubHarness<TContext, I, O>;
112
- /**
113
- * Creates a step that delegates a turn to the Codex harness.
114
- * @public
115
- * @param opts - See {@link step.claudeCode}; `opts.harness` is a `codex(...)` adapter.
116
- * @returns A `StepSubHarness` of kind `codex`.
117
- */
118
- codex<TContext = ContextData, I = unknown, O = unknown>(opts: StepSubHarnessOpts<TContext, O>): StepSubHarness<TContext, I, O>;
119
- /**
120
- * Creates a step that delegates a turn to the opencode harness.
121
- * @public
122
- * @param opts - See {@link step.claudeCode}; `opts.harness` is an `opencode(...)` adapter.
123
- * @returns A `StepSubHarness` of kind `opencode`.
124
- */
125
- opencode<TContext = ContextData, I = unknown, O = unknown>(opts: StepSubHarnessOpts<TContext, O>): StepSubHarness<TContext, I, O>;
126
- /**
127
- * Creates a step that delegates a turn to the pi harness.
128
- * @public
129
- * @param opts - See {@link step.claudeCode}; `opts.harness` is a `pi(...)` adapter.
130
- * @returns A `StepSubHarness` of kind `pi`.
138
+ * @param opts.permissions - Declarative policy answering the agent's permission requests.
139
+ * @param opts.output - Optional Standard Schema enabling structured output parsing.
140
+ * @returns A `StepAcpAgent`, auto-registered in the step registry.
141
+ * @throws `NoeticConfigError` `EMPTY_STEP_ID` / `MISSING_ACP_AGENT` / `MISSING_PROMPT`.
131
142
  */
132
- pi<TContext = ContextData, I = unknown, O = unknown>(opts: StepSubHarnessOpts<TContext, O>): StepSubHarness<TContext, I, O>;
143
+ acpAgent<TContext = ContextData, I = unknown, O = unknown>(opts: StepAcpAgentOpts<TContext, O>): StepAcpAgent<TContext, I, O>;
133
144
  };