@xyne/workflow-sdk 3.2.34 → 3.2.35

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.
@@ -0,0 +1,227 @@
1
+ /**
2
+ * Agent provider port — the seam between a workflow's agent step and whoever
3
+ * actually runs the agent.
4
+ *
5
+ * The SDK ships one agent implementation ({@link AgentStep}, which drives an
6
+ * LLM directly through a pi-mono runtime). That works when the SDK owns the
7
+ * agent: the step config carries the system prompt, the tool list and the turn
8
+ * budget, and the SDK drives the loop.
9
+ *
10
+ * It does not work when the *host* already owns agent lifecycle. In xyne-spaces
11
+ * agents live in claw; in xyne-search they live in an `agents` table. In both
12
+ * cases the prompt, tools, MCP connections and model are the host's to resolve
13
+ * — a workflow step should name an agent and hand it a task, not re-specify it.
14
+ *
15
+ * A provider is that: the host's agent platform, behind a port. It resolves
16
+ * config into a run and reports back; the step keeps the workflow contract
17
+ * (output shape, JSON repair, citations, artifacts). See ./host-agent-step.ts.
18
+ *
19
+ * Two transports, because hosts genuinely have both:
20
+ *
21
+ * - {@link SyncAgentCapability} streams the run. The step holds a worker slot
22
+ * for its duration and forwards progress to the execution viewer. Right for
23
+ * a workflow someone is watching.
24
+ * - {@link AsyncAgentCapability} dispatches the run and parks the step. The
25
+ * worker slot is released and the execution resumes on callback. Right for
26
+ * headless automations, and for agents that run for a long time.
27
+ *
28
+ * A provider may implement either or both. Where it implements both, the choice
29
+ * is per-invocation — the same agent, watched or not — so it belongs in step
30
+ * config, not in the provider's identity.
31
+ *
32
+ * Deliberately free of pi-mono imports.
33
+ */
34
+ import type { z } from 'zod';
35
+ import type { Attachment } from '../common/attachment.js';
36
+ import type { StepExecutionContext } from '../steps/base-step.js';
37
+ import type { ResumePayload } from '../common/resume-payload.js';
38
+ import type { ResponseDefect, ToolCallRecord } from './contract.js';
39
+ /**
40
+ * One selectable agent, as shown in the step's agent picker.
41
+ *
42
+ * Returned by {@link BaseAgentProvider.listAgents} and served over the host's
43
+ * agents route — never baked into the config JSON Schema, which is generated
44
+ * once per process and has no tenant context.
45
+ */
46
+ export interface AgentDescriptor {
47
+ id: string;
48
+ name: string;
49
+ description?: string;
50
+ avatarUrl?: string;
51
+ }
52
+ /** What the step hands a provider for one invocation. */
53
+ export interface AgentRunInput {
54
+ /** The instruction for this run, with workflow refs already resolved. */
55
+ task: string;
56
+ /** Input documents the agent should have access to. */
57
+ attachments: Attachment[];
58
+ /** True when the step expects a JSON object back rather than free text. */
59
+ expectJson: boolean;
60
+ /** The JSON Schema the response should match. Present only when `expectJson`. */
61
+ outputSchema?: Record<string, unknown>;
62
+ /** True when every data point in the response must carry a source citation. */
63
+ cite: boolean;
64
+ /** Aborted when the step's wall-clock budget expires or the execution is cancelled. */
65
+ signal: AbortSignal;
66
+ /**
67
+ * Set when re-prompting after an unusable response. Providers should feed
68
+ * the defect back to the agent rather than starting a fresh conversation.
69
+ */
70
+ repair?: {
71
+ attempt: number;
72
+ } & ResponseDefect;
73
+ }
74
+ /**
75
+ * What a streaming run reports back.
76
+ *
77
+ * A provider translates its own transport (SSE frames, a websocket, an
78
+ * in-process iterator) into these. Failures are thrown, not yielded — a
79
+ * provider that ends without a `done` event is treated as a failed run.
80
+ */
81
+ export type AgentRunEvent = {
82
+ type: 'text';
83
+ text: string;
84
+ } | {
85
+ type: 'thinking';
86
+ text?: string;
87
+ } | {
88
+ type: 'tool_start';
89
+ toolCallId: string;
90
+ tool: string;
91
+ args: Record<string, unknown>;
92
+ } | {
93
+ type: 'tool_end';
94
+ toolCallId: string;
95
+ tool: string;
96
+ result: unknown;
97
+ }
98
+ /** A file the agent produced. The step stores it; the provider only yields bytes. */
99
+ | {
100
+ type: 'artifact';
101
+ name: string;
102
+ mimeType: string;
103
+ bytes: Uint8Array;
104
+ } | {
105
+ type: 'done';
106
+ result: AgentRunResult;
107
+ };
108
+ /**
109
+ * The outcome of one agent invocation.
110
+ *
111
+ * Note there are no attachments here: artifacts arrive as events and are
112
+ * persisted by the step through `ctx.storage`, so storage policy stays in the
113
+ * SDK rather than being re-implemented by every provider.
114
+ */
115
+ export interface AgentRunResult {
116
+ /** The agent's response text, unparsed — the step shapes it per `outputType`. */
117
+ text: string;
118
+ toolCalls: ToolCallRecord[];
119
+ turnCount: number;
120
+ usage: {
121
+ inputTokens: number;
122
+ outputTokens: number;
123
+ };
124
+ /**
125
+ * Artifacts the provider resolved itself.
126
+ *
127
+ * Streaming providers should leave this unset and yield `artifact` events
128
+ * instead, so the step persists the bytes through `ctx.storage` and storage
129
+ * policy stays in one place. Dispatching providers have no byte stream to
130
+ * intercept — their artifacts arrive as references in the callback payload —
131
+ * so they map them to {@link Attachment} themselves.
132
+ */
133
+ attachments?: Attachment[];
134
+ }
135
+ /**
136
+ * What a parked step remembers about its dispatched run, written under
137
+ * `data.agent` on the step record and handed back to {@link
138
+ * AsyncAgentCapability.collect}.
139
+ *
140
+ * `provider` is stamped so a provider swap between dispatch and callback is
141
+ * caught rather than silently mis-resolved. `externalRef` is the correlation
142
+ * key: the SDK does not persist the one passed to `ctx.pause`, so this is the
143
+ * durable copy a host's callback route matches against. `attempt` carries the
144
+ * repair budget across the pause boundary, since the async repair loop is
145
+ * re-entry rather than iteration.
146
+ */
147
+ export interface AgentDispatchRecord {
148
+ provider: string;
149
+ attempt: number;
150
+ externalRef: string;
151
+ }
152
+ /**
153
+ * A host's agent platform, behind a port.
154
+ *
155
+ * `TConfig` is the provider's own slice of step config — typically just the
156
+ * agent reference, since everything else about the agent is the host's to
157
+ * resolve. The step merges it with the shared contract fields.
158
+ *
159
+ * `TCtx` is the host's authorization context, used only by {@link listAgents},
160
+ * which is called from a request route rather than from step execution.
161
+ */
162
+ export declare abstract class BaseAgentProvider<TConfig extends z.ZodTypeAny = z.ZodTypeAny, TCtx = unknown> {
163
+ /** Human-readable provider name. Also stamped on paused step records so a
164
+ * provider swap mid-flight is caught rather than silently mis-resolved. */
165
+ abstract readonly name: string;
166
+ /** The provider's config fields, merged into the step's config schema. */
167
+ abstract readonly configSchema: TConfig;
168
+ /**
169
+ * List the agents this caller may run. Backs the step's agent picker.
170
+ *
171
+ * Omit when the provider's config names an agent some other way (a free-text
172
+ * id, a fixed single agent); the picker then falls back to a plain field.
173
+ */
174
+ listAgents?(ctx: TCtx): Promise<AgentDescriptor[]>;
175
+ /**
176
+ * Customize the JSON Schema generated from {@link configSchema} — the same
177
+ * hook steps have, scoped to the provider's own fields.
178
+ *
179
+ * Note this runs once per process with no tenant context, so it can inject
180
+ * static metadata (formats, enums over process-global lists) but never a
181
+ * per-workspace list. That is what {@link listAgents} is for.
182
+ */
183
+ decorateConfigSchema?(jsonSchema: Record<string, unknown>): Record<string, unknown>;
184
+ }
185
+ /**
186
+ * Stream the run and report progress as it happens.
187
+ *
188
+ * The step consumes the iterable to completion, so a provider holding an open
189
+ * connection must release it from the generator's `finally` — the step may stop
190
+ * consuming early (timeout, abort, workflow cancellation).
191
+ */
192
+ export interface SyncAgentCapability<TConfig extends z.ZodTypeAny = z.ZodTypeAny> {
193
+ run(config: z.infer<TConfig>, input: AgentRunInput, ctx: StepExecutionContext): AsyncIterable<AgentRunEvent>;
194
+ }
195
+ /**
196
+ * Dispatch the run and let the step park until the host calls back.
197
+ *
198
+ * `dispatch` returns a correlation reference the host's callback route carries;
199
+ * the step persists it and pauses. `collect` runs on resume and turns the
200
+ * parked record plus the callback payload into a result.
201
+ */
202
+ export interface AsyncAgentCapability<TConfig extends z.ZodTypeAny = z.ZodTypeAny> {
203
+ dispatch(config: z.infer<TConfig>, input: AgentRunInput, ctx: StepExecutionContext): Promise<{
204
+ externalRef: string;
205
+ }>;
206
+ /**
207
+ * Turn the host's callback into a result.
208
+ *
209
+ * `payload` is what the host passed to `runtime.resume()` — a dispatching
210
+ * provider typically reads its own envelope out of `payload.data`. `record`
211
+ * is what this provider stored when it dispatched, so a provider that needs
212
+ * its own correlation reference has it without going near the step row.
213
+ */
214
+ collect(payload: ResumePayload, record: AgentDispatchRecord, config: z.infer<TConfig>, ctx: StepExecutionContext): Promise<AgentRunResult>;
215
+ }
216
+ /**
217
+ * Resolve which transport an invocation should take.
218
+ *
219
+ * A provider implementing exactly one capability decides it; one implementing
220
+ * both defers to step config, where the author chose per invocation.
221
+ */
222
+ export declare function resolveAgentMode<TConfig extends z.ZodTypeAny, TCtx>(provider: BaseAgentProvider<TConfig, TCtx>, mode: unknown): 'sync' | 'async';
223
+ /** A provider paired with at least one transport. */
224
+ export type AgentProvider<TConfig extends z.ZodTypeAny = z.ZodTypeAny, TCtx = unknown> = BaseAgentProvider<TConfig, TCtx> & (SyncAgentCapability<TConfig> | AsyncAgentCapability<TConfig>);
225
+ export declare function supportsSync<TConfig extends z.ZodTypeAny, TCtx>(provider: BaseAgentProvider<TConfig, TCtx>): provider is BaseAgentProvider<TConfig, TCtx> & SyncAgentCapability<TConfig>;
226
+ export declare function supportsAsync<TConfig extends z.ZodTypeAny, TCtx>(provider: BaseAgentProvider<TConfig, TCtx>): provider is BaseAgentProvider<TConfig, TCtx> & AsyncAgentCapability<TConfig>;
227
+ //# sourceMappingURL=provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/agents/provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAIpE;;;;;;GAMG;AACH,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC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C,OAAO,EAAE,IAAI,CAAC,GACzC,QAAQ,IAAI,iBAAiB,CAAC,OAAO,EAAE,IAAI,CAAC,GAAG,oBAAoB,CAAC,OAAO,CAAC,CAG9E"}
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Agent provider port — the seam between a workflow's agent step and whoever
3
+ * actually runs the agent.
4
+ *
5
+ * The SDK ships one agent implementation ({@link AgentStep}, which drives an
6
+ * LLM directly through a pi-mono runtime). That works when the SDK owns the
7
+ * agent: the step config carries the system prompt, the tool list and the turn
8
+ * budget, and the SDK drives the loop.
9
+ *
10
+ * It does not work when the *host* already owns agent lifecycle. In xyne-spaces
11
+ * agents live in claw; in xyne-search they live in an `agents` table. In both
12
+ * cases the prompt, tools, MCP connections and model are the host's to resolve
13
+ * — a workflow step should name an agent and hand it a task, not re-specify it.
14
+ *
15
+ * A provider is that: the host's agent platform, behind a port. It resolves
16
+ * config into a run and reports back; the step keeps the workflow contract
17
+ * (output shape, JSON repair, citations, artifacts). See ./host-agent-step.ts.
18
+ *
19
+ * Two transports, because hosts genuinely have both:
20
+ *
21
+ * - {@link SyncAgentCapability} streams the run. The step holds a worker slot
22
+ * for its duration and forwards progress to the execution viewer. Right for
23
+ * a workflow someone is watching.
24
+ * - {@link AsyncAgentCapability} dispatches the run and parks the step. The
25
+ * worker slot is released and the execution resumes on callback. Right for
26
+ * headless automations, and for agents that run for a long time.
27
+ *
28
+ * A provider may implement either or both. Where it implements both, the choice
29
+ * is per-invocation — the same agent, watched or not — so it belongs in step
30
+ * config, not in the provider's identity.
31
+ *
32
+ * Deliberately free of pi-mono imports.
33
+ */
34
+ // ─── Provider ───
35
+ /**
36
+ * A host's agent platform, behind a port.
37
+ *
38
+ * `TConfig` is the provider's own slice of step config — typically just the
39
+ * agent reference, since everything else about the agent is the host's to
40
+ * resolve. The step merges it with the shared contract fields.
41
+ *
42
+ * `TCtx` is the host's authorization context, used only by {@link listAgents},
43
+ * which is called from a request route rather than from step execution.
44
+ */
45
+ export class BaseAgentProvider {
46
+ }
47
+ /**
48
+ * Resolve which transport an invocation should take.
49
+ *
50
+ * A provider implementing exactly one capability decides it; one implementing
51
+ * both defers to step config, where the author chose per invocation.
52
+ */
53
+ export function resolveAgentMode(provider, mode) {
54
+ const sync = supportsSync(provider);
55
+ const async = supportsAsync(provider);
56
+ if (sync && async)
57
+ return mode === 'async' ? 'async' : 'sync';
58
+ if (async)
59
+ return 'async';
60
+ if (sync)
61
+ return 'sync';
62
+ throw new Error(`Agent provider "${provider.name}" implements neither SyncAgentCapability nor AsyncAgentCapability`);
63
+ }
64
+ // ─── Capability Detection ───
65
+ export function supportsSync(provider) {
66
+ return typeof provider.run === 'function';
67
+ }
68
+ export function supportsAsync(provider) {
69
+ return typeof provider.dispatch === 'function'
70
+ && typeof provider.collect === 'function';
71
+ }
72
+ //# sourceMappingURL=provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.js","sourceRoot":"","sources":["../../src/agents/provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AA8GH,mBAAmB;AAEnB;;;;;;;;;GASG;AACH,MAAM,OAAgB,iBAAiB;CA4BtC;AAiDD;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAC9B,QAA0C,EAC1C,IAAa;IAEb,MAAM,IAAI,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC;IACpC,MAAM,KAAK,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAC;IACtC,IAAI,IAAI,IAAI,KAAK;QAAE,OAAO,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC;IAC9D,IAAI,KAAK;QAAE,OAAO,OAAO,CAAC;IAC1B,IAAI,IAAI;QAAE,OAAO,MAAM,CAAC;IACxB,MAAM,IAAI,KAAK,CACb,mBAAmB,QAAQ,CAAC,IAAI,mEAAmE,CACpG,CAAC;AACJ,CAAC;AASD,+BAA+B;AAE/B,MAAM,UAAU,YAAY,CAC1B,QAA0C;IAE1C,OAAO,OAAQ,QAA8B,CAAC,GAAG,KAAK,UAAU,CAAC;AACnE,CAAC;AAED,MAAM,UAAU,aAAa,CAC3B,QAA0C;IAE1C,OAAO,OAAQ,QAAmC,CAAC,QAAQ,KAAK,UAAU;WACrE,OAAQ,QAAkC,CAAC,OAAO,KAAK,UAAU,CAAC;AACzE,CAAC"}
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * Only usable when pi-mono peer dependencies are installed.
10
10
  */
11
- import type { Attachment } from '../common/attachment.js';
11
+ import type { ToolCallRecord } from './contract.js';
12
12
  export type { AgentEvent, AgentTool, AgentToolResult, AgentToolUpdateCallback, AgentContext, AgentMessage, AgentLoopConfig, BeforeToolCallResult, AfterToolCallResult, BeforeToolCallContext, AfterToolCallContext, ThinkingLevel, } from '@earendil-works/pi-agent-core';
13
13
  export type { AgentSessionEvent } from '@earendil-works/pi-coding-agent';
14
14
  export type { Message, UserMessage, AssistantMessage, ToolResultMessage, TextContent, ThinkingContent, ImageContent, ToolCall, Tool, Usage, Model, Context, StopReason, } from '@earendil-works/pi-ai';
@@ -73,24 +73,5 @@ export interface AgentPauseState {
73
73
  outputTokens: number;
74
74
  };
75
75
  }
76
- /** Record of a completed tool call with timing — written to workflow context. */
77
- export interface ToolCallRecord {
78
- name: string;
79
- args: Record<string, unknown>;
80
- result: unknown;
81
- durationMs: number;
82
- }
83
- /** Final output written to workflow context after agent execution. */
84
- export interface AgentResult extends Record<string, unknown> {
85
- /** Free text (outputType 'string') or a parsed JSON object (outputType 'json'). */
86
- response: string | Record<string, unknown>;
87
- toolCalls: ToolCallRecord[];
88
- turnCount: number;
89
- usage: {
90
- inputTokens: number;
91
- outputTokens: number;
92
- };
93
- /** Files the agent generated in the sandbox, persisted as artifacts. */
94
- attachments: Attachment[];
95
- }
76
+ export type { ToolCallRecord, AgentResult } from './contract.js';
96
77
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,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AAO,+BAA+B,EAAE,SAAS,EAAE,CAAC;IAC3D,KAAK,EAAE,UAAU,CAAC;IAClB,MAAM,EAAE,WAAW,CAAC;IACpB,0CAA0C;IAC1C,MAAM,CAAC,EAAE;QACP,QAAQ,EAAE,OAAO,+BAA+B,EAAE,YAAY,EAAE,CAAC;QACjE,OAAO,EAAE,OAAO,6BAA6B,EAAE,aAAa,CAAC;QAC7D,UAAU,EAAE,YAAY,CAAC;KAC1B,CAAC;CACH;AAID,4DAA4D;AAC5D,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,OAAO,+BAA+B,EAAE,YAAY,EAAE,CAAC;IACjE,gBAAgB,CAAC,EAAE,OAAO,uBAAuB,EAAE,QAAQ,EAAE,CAAC;IAC9D,wBAAwB,CAAC,EAAE,OAAO,uBAAuB,EAAE,iBAAiB,EAAE,CAAC;IAC/E,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,kBAAkB,EAAE,cAAc,EAAE,CAAC;IACrC,KAAK,EAAE;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,CAAC;CACtD;AAKD,YAAY,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@xyne/workflow-sdk",
3
- "version": "3.2.34",
4
- "description": "Workflow engine SDK steps, triggers, executor, agents, and a framework-agnostic HTTP router.",
3
+ "version": "3.2.35",
4
+ "description": "Workflow engine SDK \u2014 steps, triggers, executor, agents, and a framework-agnostic HTTP router.",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
7
7
  "type": "git",
@@ -40,6 +40,10 @@
40
40
  "types": "./dist/agents/index.d.ts",
41
41
  "import": "./dist/agents/index.js"
42
42
  },
43
+ "./agents/host": {
44
+ "types": "./dist/agents/host.d.ts",
45
+ "import": "./dist/agents/host.js"
46
+ },
43
47
  "./runtime": {
44
48
  "types": "./dist/runtime/types.d.ts",
45
49
  "import": "./dist/runtime/types.js"