@cuylabs/agent-runtime-dapr 0.9.0 → 0.10.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/README.md +154 -19
- package/dist/{chunk-2CEICSJH.js → chunk-5CJIC4YB.js} +184 -38
- package/dist/chunk-MJKJT3ZO.js +11219 -0
- package/dist/{chunk-A34CHK2E.js → chunk-MQJ4LZOX.js} +30 -4
- package/dist/chunk-YQQTUE6B.js +993 -0
- package/dist/chunk-YS2CWYBQ.js +1358 -0
- package/dist/client-UsEIzDF6.d.ts +322 -0
- package/dist/dispatch/index.d.ts +9 -0
- package/dist/dispatch/index.js +17 -0
- package/dist/execution/index.d.ts +5 -4
- package/dist/execution/index.js +2 -2
- package/dist/host/index.d.ts +8 -4
- package/dist/host/index.js +28 -8
- package/dist/index-BEOwKSPI.d.ts +101 -0
- package/dist/{index-BCMkUMAf.d.ts → index-BmM58WZa.d.ts} +390 -182
- package/dist/index-CFm5LORU.d.ts +63 -0
- package/dist/index.d.ts +62 -14
- package/dist/index.js +76 -6
- package/dist/invoker-B1jvz9DG.d.ts +52 -0
- package/dist/{store-pRLGfYhN.d.ts → store-BXBIDz40.d.ts} +24 -3
- package/dist/team/index.d.ts +612 -0
- package/dist/team/index.js +30 -0
- package/dist/worker-CXq0IFGX.d.ts +42 -0
- package/dist/workflow/index.d.ts +4 -225
- package/dist/workflow/index.js +2 -2
- package/dist/{workflow-bridge-C8Z1yr0Y.d.ts → workflow-bridge-BcicHH1Y.d.ts} +4 -2
- package/dist/workflow-host-D6W6fXoL.d.ts +459 -0
- package/package.json +16 -6
- package/dist/chunk-DILON56B.js +0 -668
- package/dist/chunk-R47X4FG2.js +0 -2009
|
@@ -0,0 +1,459 @@
|
|
|
1
|
+
import { ApprovalRequest, ApprovalAction, ApprovalRememberScope, MiddlewareRunner, Tool, AgentEvent, FollowUpPolicy, FollowUpRequest, QueuedFollowUpRecord, FollowUpStatus, FollowUpDecisionAction, HumanInputRequest, HumanInputResponse, SteeringRequest, AgentWorkflowInterventionSnapshot, AgentWorkflowTurnState, SteeringResponse, FollowUpResponse, Agent, AgentTaskObserver } from '@cuylabs/agent-core';
|
|
2
|
+
import { D as DaprWorkflowClient, p as DaprAgentTurnWorkflowActivityNames, r as DaprAgentTurnWorkflowDefinition, S as StartDaprWorkflowOptions, v as DaprStartWorkflowResponse, c as CreateDaprAgentTurnWorkflowKitOptions, a as DaprAgentTurnWorkflowToolHandler, b as DaprAgentTurnActivityRegistration } from './client-UsEIzDF6.js';
|
|
3
|
+
import { e as DaprStateStoreClientOptions } from './workflow-bridge-BcicHH1Y.js';
|
|
4
|
+
import { EventBus } from '@cuylabs/agent-core/events';
|
|
5
|
+
|
|
6
|
+
interface DaprApprovalDecision {
|
|
7
|
+
action: ApprovalAction;
|
|
8
|
+
feedback?: string;
|
|
9
|
+
rememberScope?: ApprovalRememberScope;
|
|
10
|
+
}
|
|
11
|
+
type DaprApprovalResolution = ApprovalAction | DaprApprovalDecision;
|
|
12
|
+
type DaprApprovalRequestStatus = "pending" | "approved" | "rejected" | "remembered";
|
|
13
|
+
interface DaprApprovalRequestRecord {
|
|
14
|
+
id: string;
|
|
15
|
+
agentId: string;
|
|
16
|
+
sessionId: string;
|
|
17
|
+
workflowInstanceId: string;
|
|
18
|
+
toolCallId: string;
|
|
19
|
+
toolName: string;
|
|
20
|
+
step: number;
|
|
21
|
+
request: ApprovalRequest;
|
|
22
|
+
status: DaprApprovalRequestStatus;
|
|
23
|
+
createdAt: string;
|
|
24
|
+
updatedAt: string;
|
|
25
|
+
decidedAt?: string;
|
|
26
|
+
decision?: DaprApprovalDecision;
|
|
27
|
+
}
|
|
28
|
+
interface DaprApprovalRequestListOptions {
|
|
29
|
+
sessionId?: string;
|
|
30
|
+
workflowInstanceId?: string;
|
|
31
|
+
status?: DaprApprovalRequestStatus | DaprApprovalRequestStatus[];
|
|
32
|
+
}
|
|
33
|
+
interface DaprWorkflowApprovalCheckInput {
|
|
34
|
+
workflowInstanceId: string;
|
|
35
|
+
sessionId: string;
|
|
36
|
+
step: number;
|
|
37
|
+
toolCall: {
|
|
38
|
+
toolCallId: string;
|
|
39
|
+
toolName: string;
|
|
40
|
+
args: unknown;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
type DaprWorkflowApprovalCheckResult = {
|
|
44
|
+
action: "allow";
|
|
45
|
+
} | {
|
|
46
|
+
action: "deny";
|
|
47
|
+
reason: string;
|
|
48
|
+
} | {
|
|
49
|
+
action: "request";
|
|
50
|
+
request: DaprApprovalRequestRecord;
|
|
51
|
+
};
|
|
52
|
+
interface DaprWorkflowApprovalRuntimeOptions extends DaprStateStoreClientOptions {
|
|
53
|
+
agentId: string;
|
|
54
|
+
middleware: MiddlewareRunner;
|
|
55
|
+
tools: Record<string, Tool.Info>;
|
|
56
|
+
cwd: string;
|
|
57
|
+
keyPrefix?: string;
|
|
58
|
+
now?: () => string;
|
|
59
|
+
publishEvent?: (sessionId: string, event: AgentEvent) => Promise<void> | void;
|
|
60
|
+
}
|
|
61
|
+
interface DaprWorkflowApprovalRuntime {
|
|
62
|
+
readonly hasApprovalMiddleware: boolean;
|
|
63
|
+
evaluateToolApproval(input: DaprWorkflowApprovalCheckInput): Promise<DaprWorkflowApprovalCheckResult>;
|
|
64
|
+
getRequest(requestId: string): Promise<DaprApprovalRequestRecord | undefined>;
|
|
65
|
+
listRequests(options?: DaprApprovalRequestListOptions): Promise<DaprApprovalRequestRecord[]>;
|
|
66
|
+
respondToRequest(requestId: string, decision: DaprApprovalResolution, workflowClient: DaprWorkflowClient): Promise<DaprApprovalRequestRecord>;
|
|
67
|
+
}
|
|
68
|
+
declare function createDaprWorkflowApprovalRuntime(options: DaprWorkflowApprovalRuntimeOptions): DaprWorkflowApprovalRuntime;
|
|
69
|
+
|
|
70
|
+
interface DaprFollowUpRecord extends QueuedFollowUpRecord {
|
|
71
|
+
agentId: string;
|
|
72
|
+
}
|
|
73
|
+
interface DaprFollowUpListOptions {
|
|
74
|
+
sessionId?: string;
|
|
75
|
+
workflowInstanceId?: string;
|
|
76
|
+
sourceTurnId?: string;
|
|
77
|
+
status?: FollowUpStatus | FollowUpStatus[];
|
|
78
|
+
}
|
|
79
|
+
interface DaprWorkflowFollowUpRuntimeOptions extends DaprStateStoreClientOptions {
|
|
80
|
+
agentId: string;
|
|
81
|
+
policy?: FollowUpPolicy;
|
|
82
|
+
keyPrefix?: string;
|
|
83
|
+
now?: () => string;
|
|
84
|
+
publishEvent?: (sessionId: string, event: AgentEvent) => Promise<void> | void;
|
|
85
|
+
}
|
|
86
|
+
interface DaprWorkflowFollowUpRuntime {
|
|
87
|
+
readonly policy: FollowUpPolicy;
|
|
88
|
+
createRequest(workflowInstanceId: string, request: FollowUpRequest, options?: {
|
|
89
|
+
sourceTurnId?: string;
|
|
90
|
+
}): Promise<DaprFollowUpRecord>;
|
|
91
|
+
listRequests(options?: DaprFollowUpListOptions): Promise<DaprFollowUpRecord[]>;
|
|
92
|
+
getRequest(requestId: string): Promise<DaprFollowUpRecord | undefined>;
|
|
93
|
+
respondToRequest(requestId: string, action: FollowUpDecisionAction): Promise<DaprFollowUpRecord>;
|
|
94
|
+
listSeedable(sessionId: string): Promise<DaprFollowUpRecord[]>;
|
|
95
|
+
markApplied(requestIds: readonly string[], seededTurnId: string): Promise<void>;
|
|
96
|
+
}
|
|
97
|
+
declare function createDaprWorkflowFollowUpRuntime(options: DaprWorkflowFollowUpRuntimeOptions): DaprWorkflowFollowUpRuntime;
|
|
98
|
+
|
|
99
|
+
type DaprHumanInputRequestStatus = "pending" | "answered";
|
|
100
|
+
interface DaprHumanInputRequestRecord {
|
|
101
|
+
id: string;
|
|
102
|
+
agentId: string;
|
|
103
|
+
sessionId: string;
|
|
104
|
+
workflowInstanceId: string;
|
|
105
|
+
toolCallId: string;
|
|
106
|
+
toolName: string;
|
|
107
|
+
step: number;
|
|
108
|
+
request: HumanInputRequest;
|
|
109
|
+
status: DaprHumanInputRequestStatus;
|
|
110
|
+
createdAt: string;
|
|
111
|
+
updatedAt: string;
|
|
112
|
+
respondedAt?: string;
|
|
113
|
+
response?: HumanInputResponse;
|
|
114
|
+
}
|
|
115
|
+
interface DaprHumanInputRequestListOptions {
|
|
116
|
+
sessionId?: string;
|
|
117
|
+
workflowInstanceId?: string;
|
|
118
|
+
status?: DaprHumanInputRequestStatus | DaprHumanInputRequestStatus[];
|
|
119
|
+
}
|
|
120
|
+
interface DaprWorkflowHumanInputCheckInput {
|
|
121
|
+
workflowInstanceId: string;
|
|
122
|
+
sessionId: string;
|
|
123
|
+
step: number;
|
|
124
|
+
toolCall: {
|
|
125
|
+
toolCallId: string;
|
|
126
|
+
toolName: string;
|
|
127
|
+
args: unknown;
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
type DaprWorkflowHumanInputCheckResult = {
|
|
131
|
+
action: "allow";
|
|
132
|
+
} | {
|
|
133
|
+
action: "deny";
|
|
134
|
+
reason: string;
|
|
135
|
+
} | {
|
|
136
|
+
action: "request";
|
|
137
|
+
request: DaprHumanInputRequestRecord;
|
|
138
|
+
};
|
|
139
|
+
interface DaprWorkflowHumanInputRuntimeOptions extends DaprStateStoreClientOptions {
|
|
140
|
+
agentId: string;
|
|
141
|
+
tools: Record<string, Tool.Info>;
|
|
142
|
+
cwd: string;
|
|
143
|
+
keyPrefix?: string;
|
|
144
|
+
now?: () => string;
|
|
145
|
+
publishEvent?: (sessionId: string, event: AgentEvent) => Promise<void> | void;
|
|
146
|
+
}
|
|
147
|
+
interface DaprWorkflowHumanInputRuntime {
|
|
148
|
+
readonly hasHumanInputTools: boolean;
|
|
149
|
+
evaluateToolRequest(input: DaprWorkflowHumanInputCheckInput): Promise<DaprWorkflowHumanInputCheckResult>;
|
|
150
|
+
getRequest(requestId: string): Promise<DaprHumanInputRequestRecord | undefined>;
|
|
151
|
+
listRequests(options?: DaprHumanInputRequestListOptions): Promise<DaprHumanInputRequestRecord[]>;
|
|
152
|
+
respondToRequest(requestId: string, response: HumanInputResponse, workflowClient: DaprWorkflowClient): Promise<DaprHumanInputRequestRecord>;
|
|
153
|
+
}
|
|
154
|
+
declare function createDaprWorkflowHumanInputRuntime(options: DaprWorkflowHumanInputRuntimeOptions): DaprWorkflowHumanInputRuntime;
|
|
155
|
+
|
|
156
|
+
type DaprSteerStatus = "pending" | "claimed";
|
|
157
|
+
interface DaprSteerRecord {
|
|
158
|
+
id: string;
|
|
159
|
+
agentId: string;
|
|
160
|
+
sessionId: string;
|
|
161
|
+
workflowInstanceId: string;
|
|
162
|
+
message: string;
|
|
163
|
+
timestamp: number;
|
|
164
|
+
createdAt: string;
|
|
165
|
+
updatedAt: string;
|
|
166
|
+
status: DaprSteerStatus;
|
|
167
|
+
claimedBoundaryId?: string;
|
|
168
|
+
claimedStep?: number;
|
|
169
|
+
claimedAt?: string;
|
|
170
|
+
}
|
|
171
|
+
interface DaprWorkflowSteerRuntimeOptions extends DaprStateStoreClientOptions {
|
|
172
|
+
agentId: string;
|
|
173
|
+
keyPrefix?: string;
|
|
174
|
+
now?: () => string;
|
|
175
|
+
}
|
|
176
|
+
interface DaprWorkflowSteerRuntime {
|
|
177
|
+
createRequest(workflowInstanceId: string, request: SteeringRequest): Promise<DaprSteerRecord>;
|
|
178
|
+
drainPending(workflowInstanceId: string, step: number, maxItems?: number): Promise<AgentWorkflowInterventionSnapshot[]>;
|
|
179
|
+
}
|
|
180
|
+
declare function createDaprWorkflowSteerRuntime(options: DaprWorkflowSteerRuntimeOptions): DaprWorkflowSteerRuntime;
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Dapr Pub/Sub bridge for multi-instance event fan-out.
|
|
184
|
+
*
|
|
185
|
+
* Bridges the in-process `EventBus` to Dapr's pub/sub building block so
|
|
186
|
+
* agent events are delivered to *all* app instances — not just the one
|
|
187
|
+
* running the workflow activity.
|
|
188
|
+
*
|
|
189
|
+
* ## Architecture
|
|
190
|
+
*
|
|
191
|
+
* ```
|
|
192
|
+
* Instance A (runs the workflow) Instance B (serves SSE clients)
|
|
193
|
+
* ┌─────────────────────────────┐ ┌──────────────────────────────┐
|
|
194
|
+
* │ Workflow Activity → onEvent │ │ │
|
|
195
|
+
* │ ↓ │ │ │
|
|
196
|
+
* │ EventBus (local) │ │ EventBus (local) │
|
|
197
|
+
* │ ↓ ↓ │ │ ↑ │
|
|
198
|
+
* │ SSE clients publish() │ │ ingest() from sub callback │
|
|
199
|
+
* │ ↓ │ │ ↑ │
|
|
200
|
+
* │ Dapr Sidecar │ │ Dapr Sidecar │
|
|
201
|
+
* │ (pub/sub) │ ───→ │ (pub/sub) │
|
|
202
|
+
* └─────────────────────────────┘ └──────────────────────────────┘
|
|
203
|
+
* ```
|
|
204
|
+
*
|
|
205
|
+
* ## Publishing
|
|
206
|
+
*
|
|
207
|
+
* Uses the Dapr HTTP pub/sub API:
|
|
208
|
+
* `POST /v1.0/publish/{pubsubName}/{topic}`
|
|
209
|
+
*
|
|
210
|
+
* All events go to a single topic (default: `agent-events`). The session
|
|
211
|
+
* ID is encoded in the CloudEvents `subject` field and inside the payload
|
|
212
|
+
* for filtering.
|
|
213
|
+
*
|
|
214
|
+
* ## Subscribing
|
|
215
|
+
*
|
|
216
|
+
* The bridge exposes an `ingest()` handler that should be wired to a Dapr
|
|
217
|
+
* subscription callback — either:
|
|
218
|
+
*
|
|
219
|
+
* 1. **Declarative** (YAML component + `GET /dapr/subscribe` at startup)
|
|
220
|
+
* 2. **Programmatic** (`DaprServer.pubsub.subscribe()` from `@dapr/dapr`)
|
|
221
|
+
* 3. **Streaming** (future: `SubscribeTopicEventsAlpha1` gRPC bidi stream)
|
|
222
|
+
*
|
|
223
|
+
* The bridge doesn't care *how* events arrive — it just needs `ingest()`
|
|
224
|
+
* called with the event data. This keeps the bridge transport-agnostic.
|
|
225
|
+
*
|
|
226
|
+
* ## Usage
|
|
227
|
+
*
|
|
228
|
+
* ```typescript
|
|
229
|
+
* import { createEventBus, createDaprPubSubEventBridge } from "./index.js";
|
|
230
|
+
*
|
|
231
|
+
* const eventBus = createEventBus();
|
|
232
|
+
* const bridge = createDaprPubSubEventBridge({
|
|
233
|
+
* eventBus,
|
|
234
|
+
* daprHttpEndpoint: "http://localhost:3500",
|
|
235
|
+
* pubsubName: "pubsub",
|
|
236
|
+
* });
|
|
237
|
+
*
|
|
238
|
+
* // In workflow host: events auto-publish to Dapr when enabled.
|
|
239
|
+
* // In HTTP handler: events arrive from Dapr and feed into local EventBus.
|
|
240
|
+
*
|
|
241
|
+
* // Wire the subscription callback (e.g., in an Express route):
|
|
242
|
+
* app.post("/dapr/agent-events", async (req, res) => {
|
|
243
|
+
* bridge.ingest(req.body);
|
|
244
|
+
* res.sendStatus(200);
|
|
245
|
+
* });
|
|
246
|
+
* ```
|
|
247
|
+
*/
|
|
248
|
+
|
|
249
|
+
interface DaprPubSubEventBridgeOptions {
|
|
250
|
+
/** The local EventBus to bridge. */
|
|
251
|
+
eventBus: EventBus;
|
|
252
|
+
/**
|
|
253
|
+
* Dapr sidecar HTTP endpoint (e.g. `http://localhost:3500`).
|
|
254
|
+
* Used for publishing events via `POST /v1.0/publish/{pubsubName}/{topic}`.
|
|
255
|
+
*/
|
|
256
|
+
daprHttpEndpoint?: string;
|
|
257
|
+
/** Dapr pub/sub component name. Default: `"pubsub"`. */
|
|
258
|
+
pubsubName?: string;
|
|
259
|
+
/** Topic name for agent events. Default: `"agent-events"`. */
|
|
260
|
+
topic?: string;
|
|
261
|
+
/** Dapr API token for authentication. */
|
|
262
|
+
apiToken?: string;
|
|
263
|
+
/**
|
|
264
|
+
* Fetch implementation. Defaults to `globalThis.fetch`.
|
|
265
|
+
* Useful for testing or environments without native fetch.
|
|
266
|
+
*/
|
|
267
|
+
fetch?: typeof globalThis.fetch;
|
|
268
|
+
/**
|
|
269
|
+
* Source identifier for CloudEvents envelope.
|
|
270
|
+
* Defaults to `"agent-runtime-dapr"`.
|
|
271
|
+
*/
|
|
272
|
+
source?: string;
|
|
273
|
+
/**
|
|
274
|
+
* Whether to publish local events to Dapr pub/sub.
|
|
275
|
+
* Set to `false` on instances that only *receive* events (e.g., a
|
|
276
|
+
* read-only SSE gateway that doesn't run workflows).
|
|
277
|
+
* Default: `true`.
|
|
278
|
+
*/
|
|
279
|
+
publishEnabled?: boolean;
|
|
280
|
+
/**
|
|
281
|
+
* Maximum queued publishes to the Dapr sidecar before low-value streaming
|
|
282
|
+
* events are dropped. This prevents unbounded memory growth under long,
|
|
283
|
+
* high-volume token streams.
|
|
284
|
+
*/
|
|
285
|
+
maxPendingPublishes?: number;
|
|
286
|
+
}
|
|
287
|
+
interface DaprPubSubEventBridge {
|
|
288
|
+
/** The local EventBus bridged to Dapr pub/sub. */
|
|
289
|
+
readonly eventBus: EventBus;
|
|
290
|
+
/**
|
|
291
|
+
* Publish an agent event to Dapr pub/sub for cross-instance delivery.
|
|
292
|
+
*
|
|
293
|
+
* Typically called automatically by the workflow host's `onEvent`
|
|
294
|
+
* callback. Also publishes to the local EventBus.
|
|
295
|
+
*/
|
|
296
|
+
publish(sessionId: string, type: string, data: unknown): Promise<void>;
|
|
297
|
+
/**
|
|
298
|
+
* Ingest an event received from a Dapr subscription callback.
|
|
299
|
+
*
|
|
300
|
+
* Extracts the session ID and event data from the CloudEvents envelope
|
|
301
|
+
* and pushes into the local EventBus. Should be wired to whatever
|
|
302
|
+
* subscription method you're using (declarative YAML, programmatic
|
|
303
|
+
* server.pubsub.subscribe, or streaming gRPC).
|
|
304
|
+
*
|
|
305
|
+
* Safe to call from any context — ignores malformed payloads.
|
|
306
|
+
*/
|
|
307
|
+
ingest(cloudEvent: unknown): void;
|
|
308
|
+
/** The pub/sub component name. */
|
|
309
|
+
readonly pubsubName: string;
|
|
310
|
+
/** The topic name. */
|
|
311
|
+
readonly topic: string;
|
|
312
|
+
/**
|
|
313
|
+
* Express/Koa/Hono-compatible route handler for Dapr subscription
|
|
314
|
+
* callbacks. Returns the path and handler for easy wiring.
|
|
315
|
+
*/
|
|
316
|
+
readonly subscriptionRoute: {
|
|
317
|
+
/** Path the Dapr sidecar should POST to (e.g. `/dapr/agent-events`). */
|
|
318
|
+
path: string;
|
|
319
|
+
/** Handle the incoming pub/sub event. Returns `{ status: "SUCCESS" }`. */
|
|
320
|
+
handler: (body: unknown) => {
|
|
321
|
+
status: "SUCCESS" | "DROP";
|
|
322
|
+
};
|
|
323
|
+
};
|
|
324
|
+
/**
|
|
325
|
+
* Dapr subscription declaration for `GET /dapr/subscribe`.
|
|
326
|
+
* Return this from your subscribe endpoint so the sidecar knows
|
|
327
|
+
* which topic to deliver to this app.
|
|
328
|
+
*/
|
|
329
|
+
readonly subscriptionDeclaration: {
|
|
330
|
+
pubsubname: string;
|
|
331
|
+
topic: string;
|
|
332
|
+
route: string;
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
declare function createDaprPubSubEventBridge(options: DaprPubSubEventBridgeOptions): DaprPubSubEventBridge;
|
|
336
|
+
|
|
337
|
+
interface DaprWorkflowRuntimeRegistrar {
|
|
338
|
+
registerWorkflowWithName(name: string, workflow: DaprAgentTurnWorkflowDefinition): this;
|
|
339
|
+
registerActivityWithName<TInput, TOutput>(name: string, handler: (context: unknown, input: TInput) => Promise<TOutput> | TOutput): this;
|
|
340
|
+
}
|
|
341
|
+
interface DaprWorkflowStarterLike {
|
|
342
|
+
startWorkflow<TInput = unknown>(workflowName: string, options?: StartDaprWorkflowOptions<TInput>): Promise<DaprStartWorkflowResponse>;
|
|
343
|
+
}
|
|
344
|
+
interface DaprWorkflowEventRaiserLike {
|
|
345
|
+
raiseWorkflowEvent(instanceId: string, eventName: string, options?: {
|
|
346
|
+
eventData?: unknown;
|
|
347
|
+
}): Promise<void>;
|
|
348
|
+
}
|
|
349
|
+
interface DaprAgentWorkflowRunRequest {
|
|
350
|
+
message: string;
|
|
351
|
+
sessionId?: string;
|
|
352
|
+
system?: string;
|
|
353
|
+
workflowInstanceId?: string;
|
|
354
|
+
maxSteps?: number;
|
|
355
|
+
title?: string;
|
|
356
|
+
parentSessionId?: string;
|
|
357
|
+
}
|
|
358
|
+
interface DaprAgentWorkflowRunResult {
|
|
359
|
+
sessionId: string;
|
|
360
|
+
workflowInstanceId: string;
|
|
361
|
+
initialState: AgentWorkflowTurnState;
|
|
362
|
+
}
|
|
363
|
+
interface DaprAgentWorkflowSteerRequest {
|
|
364
|
+
workflowInstanceId: string;
|
|
365
|
+
sessionId: string;
|
|
366
|
+
message: string;
|
|
367
|
+
id?: string;
|
|
368
|
+
timestamp?: number;
|
|
369
|
+
}
|
|
370
|
+
interface DaprAgentWorkflowFollowUpRequest {
|
|
371
|
+
workflowInstanceId: string;
|
|
372
|
+
sessionId: string;
|
|
373
|
+
message: string;
|
|
374
|
+
id?: string;
|
|
375
|
+
timestamp?: number;
|
|
376
|
+
}
|
|
377
|
+
interface DaprAgentWorkflowHostOptions {
|
|
378
|
+
agent: Agent;
|
|
379
|
+
workflowName?: string;
|
|
380
|
+
activityNames?: Partial<DaprAgentTurnWorkflowActivityNames>;
|
|
381
|
+
mcpTools?: CreateDaprAgentTurnWorkflowKitOptions["modelStepActivity"]["mcpTools"];
|
|
382
|
+
/**
|
|
383
|
+
* Timeout in milliseconds for durable human-input waits.
|
|
384
|
+
* When omitted, the workflow waits indefinitely for the user response.
|
|
385
|
+
*/
|
|
386
|
+
humanInputTimeoutMs?: number;
|
|
387
|
+
/**
|
|
388
|
+
* Timeout in milliseconds for durable approval waits.
|
|
389
|
+
* When omitted, the workflow waits indefinitely for the user response.
|
|
390
|
+
*/
|
|
391
|
+
approvalTimeoutMs?: number;
|
|
392
|
+
/**
|
|
393
|
+
* Enable mid-turn steering injection via the durable steer inbox.
|
|
394
|
+
* Default: `true` — opt out by setting to `false`.
|
|
395
|
+
*/
|
|
396
|
+
steeringEnabled?: boolean;
|
|
397
|
+
/**
|
|
398
|
+
* Enable deferred follow-up queuing via the durable follow-up runtime.
|
|
399
|
+
* Default: `true` — opt out by setting to `false`.
|
|
400
|
+
*/
|
|
401
|
+
followUpsEnabled?: boolean;
|
|
402
|
+
/**
|
|
403
|
+
* Optional observers that receive lifecycle notifications during
|
|
404
|
+
* workflow execution. The same observers used on the direct (`/agents/run`)
|
|
405
|
+
* path — `DaprExecutionObserver`, `createDaprLoggingObserver`, etc. —
|
|
406
|
+
* work here too via an internal bridge.
|
|
407
|
+
*/
|
|
408
|
+
observers?: AgentTaskObserver[];
|
|
409
|
+
/**
|
|
410
|
+
* Optional event bus for streaming agent events (text deltas, tool calls,
|
|
411
|
+
* etc.) to connected SSE/WebSocket clients. When provided, every
|
|
412
|
+
* model-step event is published to a channel keyed by `sessionId`.
|
|
413
|
+
* The channel is automatically closed when the turn completes or errors.
|
|
414
|
+
*/
|
|
415
|
+
eventBus?: EventBus;
|
|
416
|
+
/**
|
|
417
|
+
* Optional Dapr pub/sub bridge for multi-instance event fan-out.
|
|
418
|
+
* When provided, agent events are published to Dapr pub/sub in addition
|
|
419
|
+
* to the local EventBus, so SSE clients on other instances receive them.
|
|
420
|
+
* If set, `eventBus` is automatically derived from the bridge and you
|
|
421
|
+
* do not need to set it separately.
|
|
422
|
+
*/
|
|
423
|
+
pubsubBridge?: DaprPubSubEventBridge;
|
|
424
|
+
approvalRuntime?: DaprWorkflowApprovalRuntime;
|
|
425
|
+
humanInputRuntime?: DaprWorkflowHumanInputRuntime;
|
|
426
|
+
steerRuntime?: DaprWorkflowSteerRuntime;
|
|
427
|
+
followUpRuntime?: DaprWorkflowFollowUpRuntime;
|
|
428
|
+
workflowToolHandlers?: readonly DaprAgentTurnWorkflowToolHandler[];
|
|
429
|
+
additionalActivities?: readonly DaprAgentTurnActivityRegistration<any, any>[];
|
|
430
|
+
createAbortSignal?: () => AbortSignal;
|
|
431
|
+
now?: () => string;
|
|
432
|
+
}
|
|
433
|
+
interface DaprAgentWorkflowHost {
|
|
434
|
+
workflowName: string;
|
|
435
|
+
activityNames: DaprAgentTurnWorkflowActivityNames;
|
|
436
|
+
/** Event bus for streaming agent events to clients. `undefined` if not configured. */
|
|
437
|
+
readonly eventBus: EventBus | undefined;
|
|
438
|
+
/** Dapr pub/sub bridge for multi-instance fan-out. `undefined` if not configured. */
|
|
439
|
+
readonly pubsubBridge: DaprPubSubEventBridge | undefined;
|
|
440
|
+
readonly approvalRuntime: DaprWorkflowApprovalRuntime | undefined;
|
|
441
|
+
readonly humanInputRuntime: DaprWorkflowHumanInputRuntime | undefined;
|
|
442
|
+
readonly followUpRuntime: DaprWorkflowFollowUpRuntime | undefined;
|
|
443
|
+
register<TRuntime extends DaprWorkflowRuntimeRegistrar>(runtime: TRuntime): TRuntime;
|
|
444
|
+
createInitialState(request: DaprAgentWorkflowRunRequest): Promise<DaprAgentWorkflowRunResult>;
|
|
445
|
+
startTurn(client: DaprWorkflowStarterLike, request: DaprAgentWorkflowRunRequest): Promise<DaprAgentWorkflowRunResult>;
|
|
446
|
+
steerTurn?(client: DaprWorkflowEventRaiserLike, request: DaprAgentWorkflowSteerRequest): Promise<SteeringResponse>;
|
|
447
|
+
followUpTurn?(client: DaprWorkflowEventRaiserLike, request: DaprAgentWorkflowFollowUpRequest): Promise<FollowUpResponse>;
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* Create the host-side Dapr workflow helper for an `Agent`.
|
|
451
|
+
*
|
|
452
|
+
* This wires the extracted workflow kit to a `WorkflowRuntime`-compatible
|
|
453
|
+
* object and provides a safe `startTurn()` helper that creates/loads the
|
|
454
|
+
* session, snapshots the durable turn state, and starts the workflow instance.
|
|
455
|
+
*/
|
|
456
|
+
declare function createDaprAgentWorkflowHost(options: DaprAgentWorkflowHostOptions): DaprAgentWorkflowHost;
|
|
457
|
+
declare function startDaprAgentWorkflowTurn(client: DaprWorkflowClient, host: DaprAgentWorkflowHost, request: DaprAgentWorkflowRunRequest): Promise<DaprAgentWorkflowRunResult>;
|
|
458
|
+
|
|
459
|
+
export { type DaprWorkflowHumanInputCheckInput as A, type DaprWorkflowHumanInputCheckResult as B, type DaprWorkflowHumanInputRuntime as C, type DaprWorkflowRuntimeRegistrar as D, type DaprWorkflowHumanInputRuntimeOptions as E, type DaprWorkflowStarterLike as F, type DaprWorkflowSteerRuntime as G, type DaprWorkflowSteerRuntimeOptions as H, createDaprAgentWorkflowHost as I, createDaprPubSubEventBridge as J, createDaprWorkflowApprovalRuntime as K, createDaprWorkflowFollowUpRuntime as L, createDaprWorkflowHumanInputRuntime as M, createDaprWorkflowSteerRuntime as N, startDaprAgentWorkflowTurn as O, type DaprAgentWorkflowHost as a, type DaprAgentWorkflowFollowUpRequest as b, type DaprAgentWorkflowHostOptions as c, type DaprAgentWorkflowRunRequest as d, type DaprAgentWorkflowRunResult as e, type DaprAgentWorkflowSteerRequest as f, type DaprApprovalDecision as g, type DaprApprovalRequestListOptions as h, type DaprApprovalRequestRecord as i, type DaprApprovalRequestStatus as j, type DaprApprovalResolution as k, type DaprFollowUpListOptions as l, type DaprFollowUpRecord as m, type DaprHumanInputRequestListOptions as n, type DaprHumanInputRequestRecord as o, type DaprHumanInputRequestStatus as p, type DaprPubSubEventBridge as q, type DaprPubSubEventBridgeOptions as r, type DaprSteerRecord as s, type DaprWorkflowApprovalCheckInput as t, type DaprWorkflowApprovalCheckResult as u, type DaprWorkflowApprovalRuntime as v, type DaprWorkflowApprovalRuntimeOptions as w, type DaprWorkflowEventRaiserLike as x, type DaprWorkflowFollowUpRuntime as y, type DaprWorkflowFollowUpRuntimeOptions as z };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cuylabs/agent-runtime-dapr",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Dapr-backed workload runtime and host adapters for @cuylabs/agent-runtime",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -21,10 +21,20 @@
|
|
|
21
21
|
"import": "./dist/host/index.js",
|
|
22
22
|
"default": "./dist/host/index.js"
|
|
23
23
|
},
|
|
24
|
+
"./dispatch": {
|
|
25
|
+
"types": "./dist/dispatch/index.d.ts",
|
|
26
|
+
"import": "./dist/dispatch/index.js",
|
|
27
|
+
"default": "./dist/dispatch/index.js"
|
|
28
|
+
},
|
|
24
29
|
"./workflow": {
|
|
25
30
|
"types": "./dist/workflow/index.d.ts",
|
|
26
31
|
"import": "./dist/workflow/index.js",
|
|
27
32
|
"default": "./dist/workflow/index.js"
|
|
33
|
+
},
|
|
34
|
+
"./team": {
|
|
35
|
+
"types": "./dist/team/index.d.ts",
|
|
36
|
+
"import": "./dist/team/index.js",
|
|
37
|
+
"default": "./dist/team/index.js"
|
|
28
38
|
}
|
|
29
39
|
},
|
|
30
40
|
"files": [
|
|
@@ -32,8 +42,8 @@
|
|
|
32
42
|
"README.md"
|
|
33
43
|
],
|
|
34
44
|
"dependencies": {
|
|
35
|
-
"@cuylabs/agent-core": "^0.
|
|
36
|
-
"@cuylabs/agent-runtime": "^0.
|
|
45
|
+
"@cuylabs/agent-core": "^0.10.0",
|
|
46
|
+
"@cuylabs/agent-runtime": "^0.10.0"
|
|
37
47
|
},
|
|
38
48
|
"peerDependencies": {
|
|
39
49
|
"@dapr/dapr": "^3.6.1",
|
|
@@ -65,7 +75,7 @@
|
|
|
65
75
|
"typescript": "^5.7.0",
|
|
66
76
|
"vitest": "^4.0.18",
|
|
67
77
|
"zod": "^3.24.0",
|
|
68
|
-
"@cuylabs/agent-code": "^0.
|
|
78
|
+
"@cuylabs/agent-code": "^0.10.0"
|
|
69
79
|
},
|
|
70
80
|
"keywords": [
|
|
71
81
|
"agent",
|
|
@@ -88,8 +98,8 @@
|
|
|
88
98
|
"access": "public"
|
|
89
99
|
},
|
|
90
100
|
"scripts": {
|
|
91
|
-
"build": "tsup src/index.ts src/execution/index.ts src/host/index.ts src/workflow/index.ts --format esm --dts --clean",
|
|
92
|
-
"dev": "tsup src/index.ts src/execution/index.ts src/host/index.ts src/workflow/index.ts --format esm --dts --watch",
|
|
101
|
+
"build": "tsup src/index.ts src/execution/index.ts src/host/index.ts src/dispatch/index.ts src/workflow/index.ts src/team/index.ts --format esm --dts --clean",
|
|
102
|
+
"dev": "tsup src/index.ts src/execution/index.ts src/host/index.ts src/dispatch/index.ts src/workflow/index.ts src/team/index.ts --format esm --dts --watch",
|
|
93
103
|
"typecheck": "tsc --noEmit",
|
|
94
104
|
"test": "vitest run",
|
|
95
105
|
"test:watch": "vitest",
|