@noetic-tools/types 3.2.1 → 3.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.
package/dist/index.d.ts CHANGED
@@ -6,6 +6,7 @@ export * from './errors/noetic-config-error.js';
6
6
  export * from './errors/noetic-error.js';
7
7
  export * from './schemas/item.js';
8
8
  export * from './schemas/workflow.js';
9
+ export * from './types/acp.js';
9
10
  export * from './types/channel.js';
10
11
  export * from './types/common.js';
11
12
  export * from './types/context.js';
@@ -27,7 +28,6 @@ export * from './types/schema.js';
27
28
  export * from './types/shell-adapter.js';
28
29
  export * from './types/steering.js';
29
30
  export * from './types/step.js';
30
- export * from './types/sub-harness.js';
31
31
  export * from './types/subprocess-adapter.js';
32
32
  export * from './types/tool.js';
33
33
  export * from './types/tool-context.js';
package/dist/index.js CHANGED
@@ -6,6 +6,7 @@ export * from './errors/noetic-config-error.js';
6
6
  export * from './errors/noetic-error.js';
7
7
  export * from './schemas/item.js';
8
8
  export * from './schemas/workflow.js';
9
+ export * from './types/acp.js';
9
10
  export * from './types/channel.js';
10
11
  export * from './types/common.js';
11
12
  export * from './types/context.js';
@@ -27,7 +28,6 @@ export * from './types/schema.js';
27
28
  export * from './types/shell-adapter.js';
28
29
  export * from './types/steering.js';
29
30
  export * from './types/step.js';
30
- export * from './types/sub-harness.js';
31
31
  export * from './types/subprocess-adapter.js';
32
32
  export * from './types/tool.js';
33
33
  export * from './types/tool-context.js';
@@ -9,7 +9,6 @@
9
9
  * document back into live `Step` objects via the existing builders.
10
10
  */
11
11
  import { z } from 'zod';
12
- import type { SubHarnessKind } from '../types/sub-harness.js';
13
12
  interface UntilAnyPredicate {
14
13
  kind: 'any';
15
14
  predicates: UntilPredicate[];
@@ -93,25 +92,83 @@ declare const RetryPolicySchema: z.ZodObject<{
93
92
  initialDelay: z.ZodNumber;
94
93
  maxDelay: z.ZodOptional<z.ZodNumber>;
95
94
  }, z.core.$strip>;
96
- declare const HarnessSettingsSchema: z.ZodObject<{
97
- model: z.ZodOptional<z.ZodString>;
98
- permissionMode: z.ZodOptional<z.ZodEnum<{
99
- acceptEdits: "acceptEdits";
100
- bypassPermissions: "bypassPermissions";
101
- default: "default";
102
- plan: "plan";
95
+ declare const AcpPermissionPolicySchema: z.ZodObject<{
96
+ default: z.ZodOptional<z.ZodEnum<{
97
+ allow: "allow";
98
+ cancel: "cancel";
99
+ deny: "deny";
103
100
  }>>;
104
- maxTurns: z.ZodOptional<z.ZodNumber>;
105
- allowedTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
106
- extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
101
+ allow: z.ZodOptional<z.ZodArray<z.ZodObject<{
102
+ kind: z.ZodOptional<z.ZodEnum<{
103
+ delete: "delete";
104
+ edit: "edit";
105
+ execute: "execute";
106
+ fetch: "fetch";
107
+ move: "move";
108
+ other: "other";
109
+ read: "read";
110
+ search: "search";
111
+ switch_mode: "switch_mode";
112
+ think: "think";
113
+ }>>;
114
+ title: z.ZodOptional<z.ZodString>;
115
+ }, z.core.$strip>>>;
116
+ deny: z.ZodOptional<z.ZodArray<z.ZodObject<{
117
+ kind: z.ZodOptional<z.ZodEnum<{
118
+ delete: "delete";
119
+ edit: "edit";
120
+ execute: "execute";
121
+ fetch: "fetch";
122
+ move: "move";
123
+ other: "other";
124
+ read: "read";
125
+ search: "search";
126
+ switch_mode: "switch_mode";
127
+ think: "think";
128
+ }>>;
129
+ title: z.ZodOptional<z.ZodString>;
130
+ }, z.core.$strip>>>;
131
+ persist: z.ZodOptional<z.ZodBoolean>;
107
132
  }, z.core.$strip>;
108
- declare const HarnessSessionPolicySchema: z.ZodObject<{
133
+ declare const AcpClientCapabilityConfigSchema: z.ZodObject<{
134
+ readTextFile: z.ZodOptional<z.ZodBoolean>;
135
+ writeTextFile: z.ZodOptional<z.ZodBoolean>;
136
+ terminal: z.ZodOptional<z.ZodBoolean>;
137
+ }, z.core.$strip>;
138
+ /** ACP `McpServer`. Stdio is untagged and mandatory for every agent; http/sse are capability-gated. */
139
+ declare const AcpMcpServerSchema: z.ZodUnion<readonly [z.ZodObject<{
140
+ type: z.ZodLiteral<"http">;
141
+ name: z.ZodString;
142
+ url: z.ZodString;
143
+ headers: z.ZodArray<z.ZodObject<{
144
+ name: z.ZodString;
145
+ value: z.ZodString;
146
+ }, z.core.$strip>>;
147
+ }, z.core.$strip>, z.ZodObject<{
148
+ type: z.ZodLiteral<"sse">;
149
+ name: z.ZodString;
150
+ url: z.ZodString;
151
+ headers: z.ZodArray<z.ZodObject<{
152
+ name: z.ZodString;
153
+ value: z.ZodString;
154
+ }, z.core.$strip>>;
155
+ }, z.core.$strip>, z.ZodObject<{
156
+ name: z.ZodString;
157
+ command: z.ZodString;
158
+ args: z.ZodArray<z.ZodString>;
159
+ env: z.ZodArray<z.ZodObject<{
160
+ name: z.ZodString;
161
+ value: z.ZodString;
162
+ }, z.core.$strip>>;
163
+ }, z.core.$strip>]>;
164
+ declare const AcpSessionPolicySchema: z.ZodObject<{
109
165
  reuse: z.ZodOptional<z.ZodString>;
110
- onComplete: z.ZodOptional<z.ZodEnum<{
111
- destroy: "destroy";
112
- detach: "detach";
113
- stop: "stop";
166
+ keepAlive: z.ZodOptional<z.ZodEnum<{
167
+ harness: "harness";
168
+ run: "run";
169
+ step: "step";
114
170
  }>>;
171
+ load: z.ZodOptional<z.ZodString>;
115
172
  }, z.core.$strip>;
116
173
  interface WorkflowNodeBase {
117
174
  id: string;
@@ -120,7 +177,7 @@ interface WorkflowNodeBase {
120
177
  * A reference to a streaming `OutputCodec` for a `callModel` node's structured
121
178
  * output. The hydrator resolves `library` from `HydrationContext.uiLibraries`
122
179
  * to a live codec (e.g. `openUi(myLibrary)` from `@noetic-tools/openui`), the
123
- * same registry-resolution pattern sub-harness nodes use for adapters. Kept a
180
+ * same registry-resolution pattern `acp-agent` nodes use for adapters. Kept a
124
181
  * *reference* because a codec is a runtime object, not JSON-expressible.
125
182
  */
126
183
  export interface OutputCodecRef {
@@ -233,16 +290,26 @@ export interface ScheduleWorkflowNode extends WorkflowNodeBase {
233
290
  onError?: 'continue' | 'fail';
234
291
  }
235
292
  /**
236
- * A node that delegates a turn to a coding-agent harness. `kind` is the harness
237
- * id (e.g. `claude-code`); the hydrator resolves the matching adapter from the
238
- * workflow's harness registry.
293
+ * A node that delegates a turn to an external coding agent over the Agent
294
+ * Client Protocol. `agent` is a registry key resolved from
295
+ * `HydrationContext.acpAgents` — an OPEN set, so supporting a new agent never
296
+ * changes this schema.
239
297
  */
240
- export interface SubHarnessWorkflowNode extends WorkflowNodeBase {
241
- kind: SubHarnessKind;
298
+ export interface AcpAgentWorkflowNode extends WorkflowNodeBase {
299
+ kind: 'acp-agent';
300
+ /** Registry key for the ACP agent adapter (e.g. `claude-code`). */
301
+ agent: string;
242
302
  prompt: string;
243
- instructions?: string;
244
- settings?: z.infer<typeof HarnessSettingsSchema>;
245
- session?: z.infer<typeof HarnessSessionPolicySchema>;
303
+ /** Absolute working directory for the session. Defaults to the runtime cwd. */
304
+ cwd?: string;
305
+ /** Session mode to switch to before prompting. */
306
+ mode?: string;
307
+ /** Model to select before prompting. */
308
+ model?: string;
309
+ mcpServers?: z.infer<typeof AcpMcpServerSchema>[];
310
+ permissions?: z.infer<typeof AcpPermissionPolicySchema>;
311
+ clientCapabilities?: z.infer<typeof AcpClientCapabilityConfigSchema>;
312
+ session?: z.infer<typeof AcpSessionPolicySchema>;
246
313
  }
247
314
  /**
248
315
  * A node that runs another workflow document as a sub-step. The document is
@@ -259,7 +326,7 @@ export interface SubflowWorkflowNode extends WorkflowNodeBase {
259
326
  input?: string;
260
327
  }
261
328
  /** @public Discriminated union of all JSON-serialisable workflow node kinds. */
262
- export type WorkflowNode = CallModelWorkflowNode | InvokeToolWorkflowNode | RunCodeWorkflowNode | ConditionalWorkflowNode | InParallelWorkflowNode | SpawnWorkflowNode | WithContextWorkflowNode | LoopWorkflowNode | SequenceWorkflowNode | ScheduleWorkflowNode | SubflowWorkflowNode | SubHarnessWorkflowNode;
329
+ export type WorkflowNode = CallModelWorkflowNode | InvokeToolWorkflowNode | RunCodeWorkflowNode | ConditionalWorkflowNode | InParallelWorkflowNode | SpawnWorkflowNode | WithContextWorkflowNode | LoopWorkflowNode | SequenceWorkflowNode | ScheduleWorkflowNode | SubflowWorkflowNode | AcpAgentWorkflowNode;
263
330
  /** @public Zod schema validating a single `WorkflowNode` (any JSON-safe kind). */
264
331
  export declare const WorkflowNodeSchema: z.ZodType<WorkflowNode>;
265
332
  /** @public Top-level envelope for a JSON workflow definition. */
@@ -124,30 +124,84 @@ const RetryPolicySchema = z.object({
124
124
  maxDelay: z.number().nonnegative().optional(),
125
125
  });
126
126
  //#endregion
127
- //#region SubHarness Settings
128
- const HarnessSettingsSchema = z.object({
129
- model: z.string().optional(),
130
- permissionMode: z
131
- .enum([
132
- 'default',
133
- 'plan',
134
- 'acceptEdits',
135
- 'bypassPermissions',
136
- ])
137
- .optional(),
138
- maxTurns: z.number().int().positive().optional(),
139
- allowedTools: z.array(z.string()).optional(),
140
- extra: z.record(z.string(), z.unknown()).optional(),
127
+ //#region ACP Agent Settings
128
+ /** ACP `ToolKind` — the agent's own classification of a tool call. */
129
+ const AcpToolKindSchema = z.enum([
130
+ 'read',
131
+ 'edit',
132
+ 'delete',
133
+ 'move',
134
+ 'search',
135
+ 'execute',
136
+ 'think',
137
+ 'fetch',
138
+ 'switch_mode',
139
+ 'other',
140
+ ]);
141
+ const AcpPermissionDecisionSchema = z.enum([
142
+ 'allow',
143
+ 'deny',
144
+ 'cancel',
145
+ ]);
146
+ /**
147
+ * A permission rule. Both fields are optional matchers; an omitted field
148
+ * matches anything. `title` is a case-insensitive substring match here — the
149
+ * programmatic API additionally accepts a `RegExp`, which JSON cannot express.
150
+ */
151
+ const AcpPermissionRuleSchema = z.object({
152
+ kind: AcpToolKindSchema.optional(),
153
+ title: z.string().min(1).optional(),
141
154
  });
142
- const HarnessSessionPolicySchema = z.object({
155
+ const AcpPermissionPolicySchema = z.object({
156
+ default: AcpPermissionDecisionSchema.optional(),
157
+ allow: z.array(AcpPermissionRuleSchema).optional(),
158
+ deny: z.array(AcpPermissionRuleSchema).optional(),
159
+ persist: z.boolean().optional(),
160
+ });
161
+ const AcpClientCapabilityConfigSchema = z.object({
162
+ readTextFile: z.boolean().optional(),
163
+ writeTextFile: z.boolean().optional(),
164
+ terminal: z.boolean().optional(),
165
+ });
166
+ const AcpNamedValueSchema = z.object({
167
+ name: z.string(),
168
+ value: z.string(),
169
+ });
170
+ /** ACP `McpServer`. Stdio is untagged and mandatory for every agent; http/sse are capability-gated. */
171
+ const AcpMcpServerSchema = z.union([
172
+ z.object({
173
+ type: z.literal('http'),
174
+ name: z.string().min(1),
175
+ url: z.string(),
176
+ headers: z.array(AcpNamedValueSchema),
177
+ }),
178
+ z.object({
179
+ type: z.literal('sse'),
180
+ name: z.string().min(1),
181
+ url: z.string(),
182
+ headers: z.array(AcpNamedValueSchema),
183
+ }),
184
+ z.object({
185
+ name: z.string().min(1),
186
+ command: z.string().min(1),
187
+ args: z.array(z.string()),
188
+ env: z.array(AcpNamedValueSchema),
189
+ }),
190
+ ]);
191
+ const AcpSessionPolicySchema = z.object({
143
192
  reuse: z.string().min(1).optional(),
144
- onComplete: z
193
+ /**
194
+ * How long the connection is kept alive. Defaults to `step`; `run` and
195
+ * `harness` are explicit opt-ins because a connection owns a live agent.
196
+ */
197
+ keepAlive: z
145
198
  .enum([
146
- 'stop',
147
- 'detach',
148
- 'destroy',
199
+ 'step',
200
+ 'run',
201
+ 'harness',
149
202
  ])
150
203
  .optional(),
204
+ load: z.string().min(1).optional(),
151
205
  });
152
206
  //#endregion
153
207
  //#region Workflow Node Schema
@@ -258,21 +312,19 @@ const SubflowNodeSchema = z
258
312
  .refine((node) => (node.document === undefined) !== (node.ref === undefined), {
259
313
  message: "subflow node requires exactly one of 'document' (inline) or 'ref' (named).",
260
314
  });
261
- /** Builds the schema for a single harness node kind (`claude-code`, `codex`, …). */
262
- function subHarnessNodeSchema(kind) {
263
- return z.object({
264
- kind: z.literal(kind),
265
- ...SHARED_FIELDS,
266
- prompt: z.string().min(1),
267
- instructions: z.string().optional(),
268
- settings: HarnessSettingsSchema.optional(),
269
- session: HarnessSessionPolicySchema.optional(),
270
- });
271
- }
272
- const ClaudeCodeNodeSchema = subHarnessNodeSchema('claude-code');
273
- const CodexNodeSchema = subHarnessNodeSchema('codex');
274
- const OpencodeNodeSchema = subHarnessNodeSchema('opencode');
275
- const PiNodeSchema = subHarnessNodeSchema('pi');
315
+ const AcpAgentNodeSchema = z.object({
316
+ kind: z.literal('acp-agent'),
317
+ ...SHARED_FIELDS,
318
+ agent: z.string().min(1),
319
+ prompt: z.string().min(1),
320
+ cwd: z.string().min(1).optional(),
321
+ mode: z.string().min(1).optional(),
322
+ model: z.string().min(1).optional(),
323
+ mcpServers: z.array(AcpMcpServerSchema).optional(),
324
+ permissions: AcpPermissionPolicySchema.optional(),
325
+ clientCapabilities: AcpClientCapabilityConfigSchema.optional(),
326
+ session: AcpSessionPolicySchema.optional(),
327
+ });
276
328
  /** @public Zod schema validating a single `WorkflowNode` (any JSON-safe kind). */
277
329
  export const WorkflowNodeSchema = z
278
330
  .discriminatedUnion('kind', [
@@ -287,10 +339,7 @@ export const WorkflowNodeSchema = z
287
339
  SequenceNodeSchema,
288
340
  ScheduleNodeSchema,
289
341
  SubflowNodeSchema,
290
- ClaudeCodeNodeSchema,
291
- CodexNodeSchema,
292
- OpencodeNodeSchema,
293
- PiNodeSchema,
342
+ AcpAgentNodeSchema,
294
343
  ])
295
344
  .meta({
296
345
  id: 'WorkflowNode',