@xyne/workflow-sdk 3.2.34 → 3.2.36

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 (37) hide show
  1. package/dist/agents/agent-step.d.ts +8 -8
  2. package/dist/agents/agent-step.d.ts.map +1 -1
  3. package/dist/agents/agent-step.js +12 -128
  4. package/dist/agents/agent-step.js.map +1 -1
  5. package/dist/agents/contract.d.ts +225 -0
  6. package/dist/agents/contract.d.ts.map +1 -0
  7. package/dist/agents/contract.js +196 -0
  8. package/dist/agents/contract.js.map +1 -0
  9. package/dist/agents/host-agent-step.d.ts +222 -0
  10. package/dist/agents/host-agent-step.d.ts.map +1 -0
  11. package/dist/agents/host-agent-step.js +352 -0
  12. package/dist/agents/host-agent-step.js.map +1 -0
  13. package/dist/agents/host.d.ts +9 -0
  14. package/dist/agents/host.d.ts.map +1 -0
  15. package/dist/agents/host.js +20 -0
  16. package/dist/agents/host.js.map +1 -0
  17. package/dist/agents/index.d.ts +6 -0
  18. package/dist/agents/index.d.ts.map +1 -1
  19. package/dist/agents/index.js +9 -0
  20. package/dist/agents/index.js.map +1 -1
  21. package/dist/agents/provider.d.ts +227 -0
  22. package/dist/agents/provider.d.ts.map +1 -0
  23. package/dist/agents/provider.js +72 -0
  24. package/dist/agents/provider.js.map +1 -0
  25. package/dist/agents/types.d.ts +2 -21
  26. package/dist/agents/types.d.ts.map +1 -1
  27. package/dist/authz/attributes.d.ts +23 -0
  28. package/dist/authz/attributes.d.ts.map +1 -1
  29. package/dist/router/workflow-router.d.ts.map +1 -1
  30. package/dist/router/workflow-router.js +13 -9
  31. package/dist/router/workflow-router.js.map +1 -1
  32. package/dist/steps/builtin/http-request.step.d.ts +29 -29
  33. package/dist/steps/builtin/http-request.step.js +1 -1
  34. package/dist/steps/builtin/http-request.step.js.map +1 -1
  35. package/dist/storage/types.d.ts +11 -3
  36. package/dist/storage/types.d.ts.map +1 -1
  37. package/package.json +6 -2
@@ -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;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAID,yDAAyD;AACzD,MAAM,WAAW,aAAa;IAC5B,yEAAyE;IACzE,IAAI,EAAE,MAAM,CAAC;I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@ -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,"file":"types.d.ts","sourceRoot":"","sources":["../../src/agents/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB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AAC,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"}
@@ -28,11 +28,34 @@
28
28
  * This mirrors how TanStack Router (`Register`) and Express (`Request`
29
29
  * augmentation) let consumers extend framework types without generics.
30
30
  */
31
+ import type { AuthContext } from '../router/types.js';
31
32
  export interface Register {
32
33
  }
33
34
  type ResolvedAttributes = Register extends {
34
35
  attributes: infer A;
35
36
  } ? A : Record<string, unknown>;
37
+ /**
38
+ * The product's auth-context shape — the same opt-in as {@link ResolvedAttributes}.
39
+ *
40
+ * Declared once:
41
+ * ```ts
42
+ * declare module '@xyne/workflow-sdk' {
43
+ * interface Register { authContext: { userId: string; workspaceId: string } }
44
+ * }
45
+ * ```
46
+ *
47
+ * Its first use is {@link StorageScope}: a caller-initiated blob write has a person
48
+ * and no workflow, so the caller has to be able to say which tenant it is for.
49
+ *
50
+ * NOTE: this does not yet constrain the `TCtx` generic threaded through
51
+ * `WorkflowRuntime` / `WorkflowAuthorizer` / `RouterOptions`. Until it does, a host
52
+ * declaring one and passing the other can drift — see the cast in the router's
53
+ * storage call sites. Constraining `TCtx extends ResolvedAuthContext` is the
54
+ * follow-up, and would let hosts drop those generics entirely.
55
+ */
56
+ export type ResolvedAuthContext = Register extends {
57
+ authContext: infer C;
58
+ } ? C : AuthContext;
36
59
  /** The product's attribute shape for a resource kind — `unknown` if unaugmented. */
37
60
  export type ResourceAttributes<K extends string> = K extends keyof ResolvedAttributes ? ResolvedAttributes[K] : unknown;
38
61
  /** Resource kinds that carry product attributes at creation. */
@@ -1 +1 @@
1
- {"version":3,"file":"attributes.d.ts","sourceRoot":"","sources":["../../src/authz/attributes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,WAAW,QAAQ;CAAG;AAE5B,KAAK,kBAAkB,GAAG,QAAQ,SAAS;IAAE,UAAU,EAAE,MAAM,CAAC,CAAA;CAAE,GAC9D,CAAC,GACD,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE5B,oFAAoF;AACpF,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,SAAS,MAAM,kBAAkB,GACjF,kBAAkB,CAAC,CAAC,CAAC,GACrB,OAAO,CAAC;AAEZ,gEAAgE;AAChE,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG,UAAU,GAAG,YAAY,CAAC"}
1
+ {"version":3,"file":"attributes.d.ts","sourceRoot":"","sources":["../../src/authz/attributes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEtD,MAAM,WAAW,QAAQ;CAAG;AAE5B,KAAK,kBAAkB,GAAG,QAAQ,SAAS;IAAE,UAAU,EAAE,MAAM,CAAC,CAAA;CAAE,GAC9D,CAAC,GACD,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE5B;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,MAAM,mBAAmB,GAAG,QAAQ,SAAS;IAAE,WAAW,EAAE,MAAM,CAAC,CAAA;CAAE,GACvE,CAAC,GACD,WAAW,CAAC;AAEhB,oFAAoF;AACpF,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,SAAS,MAAM,kBAAkB,GACjF,kBAAkB,CAAC,CAAC,CAAC,GACrB,OAAO,CAAC;AAEZ,gEAAgE;AAChE,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG,UAAU,GAAG,YAAY,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"workflow-router.d.ts","sourceRoot":"","sources":["../../src/router/workflow-router.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,KAAK,EAAE,eAAe,EAA+B,WAAW,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AA4J3G,wBAAgB,oBAAoB,CAAC,IAAI,GAAG,WAAW,EAGrD,OAAO,EAAE,eAAe,CAAC,GAAG,EAAE,IAAI,CAAC,EAEnC,KAAK,EAAE,aAAa,CAAC,IAAI,CAAC,GACzB,eAAe,CAAC,IAAI,CAAC,EAAE,CAk6CzB"}
1
+ {"version":3,"file":"workflow-router.d.ts","sourceRoot":"","sources":["../../src/router/workflow-router.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,KAAK,EAAE,eAAe,EAA+B,WAAW,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AA4J3G,wBAAgB,oBAAoB,CAAC,IAAI,GAAG,WAAW,EAGrD,OAAO,EAAE,eAAe,CAAC,GAAG,EAAE,IAAI,CAAC,EAEnC,KAAK,EAAE,aAAa,CAAC,IAAI,CAAC,GACzB,eAAe,CAAC,IAAI,CAAC,EAAE,CAs6CzB"}
@@ -487,8 +487,9 @@ _opts) {
487
487
  method: 'POST',
488
488
  path: '/uploads',
489
489
  multipart: 'files',
490
- // TODO(uploads): guard/scope via the authorizer once uploads are ACL-modeled.
491
- handler: async (req, _auth) => {
490
+ // TODO(uploads): guard via the authorizer once blobs are ACL-modeled. The scope
491
+ // below gives tenant attribution; it is not authorization.
492
+ handler: async (req, auth) => {
492
493
  if (!runtime.storage) {
493
494
  return error(501, 'No StorageAdapter configured — file uploads are disabled');
494
495
  }
@@ -507,10 +508,11 @@ _opts) {
507
508
  }
508
509
  }
509
510
  }
510
- // TODO(uploads): uploads are not yet ACL-scoped. The storage scope must be
511
- // produceable from BOTH a caller (here) and a workflow (execution-time
512
- // writes have no caller) designed in the uploads pass. Empty for now.
513
- const scope = {};
511
+ // The host's auth context IS its storage scope for caller-initiated work: an
512
+ // upload has a person and no workflow yet. Not provable here (TCtx is unbound
513
+ // at this point), so the host's adapter validates and rejects a scope it
514
+ // cannot read a tenant from.
515
+ const scope = auth;
514
516
  try {
515
517
  const attachments = [];
516
518
  for (const file of files) {
@@ -539,7 +541,7 @@ _opts) {
539
541
  routes.push({
540
542
  method: 'GET',
541
543
  path: '/attachments',
542
- handler: async (req, _auth) => {
544
+ handler: async (req, auth) => {
543
545
  if (!runtime.storage) {
544
546
  return error(501, 'No StorageAdapter configured — downloads are disabled');
545
547
  }
@@ -554,7 +556,9 @@ _opts) {
554
556
  const url = await runtime.storage.signUrl(attachment, 300);
555
557
  return { status: 302, body: null, headers: { Location: url } };
556
558
  }
557
- const bytes = await runtime.storage.read(attachment);
559
+ // Pass the caller so a tenant-enforcing adapter can refuse a reference
560
+ // owned by another workspace. `ref` is client-supplied.
561
+ const bytes = await runtime.storage.read(attachment, auth);
558
562
  return {
559
563
  status: 200,
560
564
  body: bytes,
@@ -1287,7 +1291,7 @@ _opts) {
1287
1291
  if (typeof att.attachment.size === 'number' && att.attachment.size > MAX_MOUNT_BYTES)
1288
1292
  continue;
1289
1293
  try {
1290
- const bytes = await runtime.storage.read(att.attachment);
1294
+ const bytes = await runtime.storage.read(att.attachment, auth);
1291
1295
  preloadFiles.push({ path: att.sandboxPath, bytes });
1292
1296
  mountedPaths.set(att.attachment.data, att.sandboxPath);
1293
1297
  }