@cuylabs/agent-runtime-dapr 0.5.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.
@@ -0,0 +1,533 @@
1
+ import { AgentWorkflowTurnState, Agent, AgentTaskObserver, AgentTaskPayload, AgentTaskResult, AgentTaskRunner, AgentTaskRunnerOptions } from '@cuylabs/agent-core';
2
+ import { h as DaprExecutionStore } from './store-pRLGfYhN.js';
3
+ import { DaprAgentTurnWorkflowActivityNames, DaprAgentTurnWorkflowDefinition, StartDaprWorkflowOptions, DaprStartWorkflowResponse, CreateDaprAgentTurnWorkflowKitOptions, DaprWorkflowClient } from './workflow/index.js';
4
+ import { RuntimeDriver, RuntimeDriverContext, RuntimeJobRecord, AgentRuntime, AgentRuntimeOptions, RuntimeExecutionContext } from '@cuylabs/agent-runtime';
5
+ import { c as DaprRuntimeDriverOptions, a as DaprExecutionStoreOptions } from './workflow-bridge-C8Z1yr0Y.js';
6
+ import { Server } from 'node:http';
7
+
8
+ interface DaprJobTriggerHandler {
9
+ handleJobTriggerByName(jobName: string): Promise<boolean>;
10
+ }
11
+ interface DaprHttpJobHandlerOptions {
12
+ driver: DaprJobTriggerHandler;
13
+ handledStatus?: number;
14
+ unhandledStatus?: number;
15
+ errorStatus?: number;
16
+ onError?: (error: unknown, jobName: string) => void | Promise<void>;
17
+ }
18
+ interface DaprHttpJobHandlerResult {
19
+ status: number;
20
+ handled: boolean;
21
+ error?: unknown;
22
+ }
23
+ declare function createDaprHttpJobHandler(options: DaprHttpJobHandlerOptions): (jobName: string) => Promise<DaprHttpJobHandlerResult>;
24
+
25
+ declare class DaprRuntimeDriver<TPayload = unknown> implements RuntimeDriver<TPayload> {
26
+ readonly name = "dapr";
27
+ private readonly client;
28
+ private readonly jobsApi;
29
+ private readonly keyPrefix;
30
+ private context;
31
+ private started;
32
+ constructor(options: DaprRuntimeDriverOptions);
33
+ start(context: RuntimeDriverContext<TPayload>): Promise<void>;
34
+ stop(): Promise<void>;
35
+ listJobs(): Promise<RuntimeJobRecord<TPayload>[]>;
36
+ getJob(jobId: string): Promise<RuntimeJobRecord<TPayload> | undefined>;
37
+ upsertJob(job: RuntimeJobRecord<TPayload>): Promise<RuntimeJobRecord<TPayload>>;
38
+ removeJob(jobId: string): Promise<boolean>;
39
+ /**
40
+ * Handle a Dapr scheduler callback routed to `/job/:name`.
41
+ * Returns false when the job name is not managed by this driver.
42
+ */
43
+ handleJobTriggerByName(jobName: string): Promise<boolean>;
44
+ private syncScheduledJob;
45
+ private fromDaprJobName;
46
+ private stateKeyForJob;
47
+ private stateKeyForIndex;
48
+ private readJob;
49
+ private writeJob;
50
+ private readIndex;
51
+ private writeIndex;
52
+ private addToIndex;
53
+ private removeFromIndex;
54
+ private listJobsViaStateQuery;
55
+ private listJobsFromIndex;
56
+ private decodeStoredJob;
57
+ private updateIndex;
58
+ private deleteScheduledJob;
59
+ }
60
+
61
+ interface DaprWorkflowRuntimeRegistrar {
62
+ registerWorkflowWithName(name: string, workflow: DaprAgentTurnWorkflowDefinition): this;
63
+ registerActivityWithName<TInput, TOutput>(name: string, handler: (context: unknown, input: TInput) => Promise<TOutput> | TOutput): this;
64
+ }
65
+ interface DaprWorkflowStarterLike {
66
+ startWorkflow<TInput = unknown>(workflowName: string, options?: StartDaprWorkflowOptions<TInput>): Promise<DaprStartWorkflowResponse>;
67
+ }
68
+ interface DaprAgentWorkflowRunRequest {
69
+ message: string;
70
+ sessionId?: string;
71
+ system?: string;
72
+ workflowInstanceId?: string;
73
+ maxSteps?: number;
74
+ }
75
+ interface DaprAgentWorkflowRunResult {
76
+ sessionId: string;
77
+ workflowInstanceId: string;
78
+ initialState: AgentWorkflowTurnState;
79
+ }
80
+ interface DaprAgentWorkflowHostOptions {
81
+ agent: Agent;
82
+ workflowName?: string;
83
+ activityNames?: Partial<DaprAgentTurnWorkflowActivityNames>;
84
+ mcpTools?: CreateDaprAgentTurnWorkflowKitOptions["modelStepActivity"]["mcpTools"];
85
+ /**
86
+ * Optional observers that receive lifecycle notifications during
87
+ * workflow execution. The same observers used on the direct (`/agents/run`)
88
+ * path — `DaprExecutionObserver`, `createDaprLoggingObserver`, etc. —
89
+ * work here too via an internal bridge.
90
+ */
91
+ observers?: AgentTaskObserver[];
92
+ createAbortSignal?: () => AbortSignal;
93
+ now?: () => string;
94
+ }
95
+ interface DaprAgentWorkflowHost {
96
+ workflowName: string;
97
+ activityNames: DaprAgentTurnWorkflowActivityNames;
98
+ register<TRuntime extends DaprWorkflowRuntimeRegistrar>(runtime: TRuntime): TRuntime;
99
+ createInitialState(request: DaprAgentWorkflowRunRequest): Promise<DaprAgentWorkflowRunResult>;
100
+ startTurn(client: DaprWorkflowStarterLike, request: DaprAgentWorkflowRunRequest): Promise<DaprAgentWorkflowRunResult>;
101
+ }
102
+ /**
103
+ * Create the host-side Dapr workflow helper for an `Agent`.
104
+ *
105
+ * This wires the extracted workflow kit to a `WorkflowRuntime`-compatible
106
+ * object and provides a safe `startTurn()` helper that creates/loads the
107
+ * session, appends the initial user message, snapshots the durable turn
108
+ * state, and starts the workflow instance.
109
+ */
110
+ declare function createDaprAgentWorkflowHost(options: DaprAgentWorkflowHostOptions): DaprAgentWorkflowHost;
111
+ declare function startDaprAgentWorkflowTurn(client: DaprWorkflowClient, host: DaprAgentWorkflowHost, request: DaprAgentWorkflowRunRequest): Promise<DaprAgentWorkflowRunResult>;
112
+
113
+ interface DaprHostedAgentInfo<TPayload extends AgentTaskPayload = AgentTaskPayload> {
114
+ readonly id: string;
115
+ readonly aliases: string[];
116
+ readonly description?: string;
117
+ readonly workflowHost: {
118
+ readonly workflowName: string;
119
+ startTurn(client: DaprWorkflowStarterLike, request: DaprAgentWorkflowRunRequest): Promise<DaprAgentWorkflowRunResult>;
120
+ };
121
+ readonly runtimeBundle: {
122
+ readonly executionStore?: DaprExecutionStore<TPayload>;
123
+ };
124
+ }
125
+ interface DaprHostReadinessCheck {
126
+ readonly name: string;
127
+ readonly ok: boolean;
128
+ readonly detail?: string;
129
+ }
130
+ interface DaprHostReadinessStatus {
131
+ readonly ok: boolean;
132
+ readonly checks: readonly DaprHostReadinessCheck[];
133
+ }
134
+ interface DaprHostApp<TPayload extends AgentTaskPayload = AgentTaskPayload> {
135
+ isRunning(): boolean;
136
+ checkReadiness?(): DaprHostReadinessStatus | Promise<DaprHostReadinessStatus>;
137
+ listAgents(): readonly DaprHostedAgentInfo<TPayload>[];
138
+ getAgent(idOrAlias: string): DaprHostedAgentInfo<TPayload> | undefined;
139
+ runAgent(idOrAlias: string, payload: TPayload): Promise<unknown>;
140
+ handleScheduledJob(jobName: string): Promise<DaprHttpJobHandlerResult>;
141
+ }
142
+
143
+ interface DaprServiceInvokerOptions {
144
+ /** Dapr sidecar HTTP endpoint. Defaults to http://127.0.0.1:3500. */
145
+ daprHttpEndpoint?: string;
146
+ /** Optional Dapr API token sent as the dapr-api-token header. */
147
+ apiToken?: string;
148
+ /** Default request timeout in milliseconds. Defaults to 15000. */
149
+ requestTimeoutMs?: number;
150
+ /** Override fetch implementation for tests/custom runtimes. */
151
+ fetch?: typeof fetch;
152
+ }
153
+ interface DaprInvokeMethodOptions<TBody = unknown> {
154
+ /** HTTP method for invocation. Defaults to POST when body exists, otherwise GET. */
155
+ method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
156
+ /** Request body. Objects are serialized as JSON. */
157
+ body?: TBody;
158
+ /** Additional HTTP headers. */
159
+ headers?: Record<string, string>;
160
+ /** Query-string parameters appended to method URL. */
161
+ query?: Record<string, string | number | boolean | undefined>;
162
+ /** Per-request timeout override in milliseconds. */
163
+ timeoutMs?: number;
164
+ }
165
+ interface DaprInvokeMethodResult<TResponse = unknown> {
166
+ status: number;
167
+ data: TResponse | undefined;
168
+ headers: Headers;
169
+ }
170
+ /** Default request contract for invoking a remote agent over service invocation. */
171
+ interface RemoteAgentRunRequest extends AgentTaskPayload {
172
+ }
173
+ /** Default response contract for remote agent execution. */
174
+ interface RemoteAgentRunResponse extends AgentTaskResult {
175
+ }
176
+
177
+ declare class DaprServiceInvoker {
178
+ private readonly daprHttpEndpoint;
179
+ private readonly apiToken?;
180
+ private readonly requestTimeoutMs;
181
+ private readonly fetchImpl;
182
+ constructor(options?: DaprServiceInvokerOptions);
183
+ invokeMethod<TResponse = unknown, TBody = unknown>(appId: string, methodPath: string, options?: DaprInvokeMethodOptions<TBody>): Promise<DaprInvokeMethodResult<TResponse>>;
184
+ }
185
+ /**
186
+ * Invoke a remote agent endpoint using the default run contract.
187
+ *
188
+ * Default route: `POST /agents/run`.
189
+ */
190
+ declare function invokeRemoteAgentRun(invoker: DaprServiceInvoker, appId: string, request: RemoteAgentRunRequest, methodPath?: string): Promise<RemoteAgentRunResponse>;
191
+
192
+ interface DaprWorkflowWorkerRuntime extends DaprWorkflowRuntimeRegistrar {
193
+ start(): Promise<void>;
194
+ stop(): Promise<void>;
195
+ }
196
+ interface DaprWorkflowWorkerLogger {
197
+ info?(message: string): void;
198
+ warn?(message: string): void;
199
+ error?(message: string): void;
200
+ }
201
+ interface DaprWorkflowWorkerAgentDefinition {
202
+ id: string;
203
+ host: DaprAgentWorkflowHost;
204
+ aliases?: string[];
205
+ description?: string;
206
+ }
207
+ interface DaprWorkflowWorkerOptions {
208
+ runtime: DaprWorkflowWorkerRuntime;
209
+ agents: readonly DaprWorkflowWorkerAgentDefinition[];
210
+ logger?: DaprWorkflowWorkerLogger;
211
+ }
212
+ interface DaprWorkflowWorker {
213
+ readonly runtime: DaprWorkflowWorkerRuntime;
214
+ readonly agents: readonly DaprWorkflowWorkerAgentDefinition[];
215
+ start(): Promise<void>;
216
+ stop(): Promise<void>;
217
+ isRunning(): boolean;
218
+ listAgents(): readonly DaprWorkflowWorkerAgentDefinition[];
219
+ getAgent(idOrAlias: string): DaprWorkflowWorkerAgentDefinition | undefined;
220
+ }
221
+ /**
222
+ * Create a Dapr workflow worker controller around one or more agent hosts.
223
+ *
224
+ * This is the host-process analogue of Diagrid's `runner.start()` path:
225
+ * the worker owns Dapr SDK lifecycle and workflow/activity registration,
226
+ * while each registered host owns the workflow definition for a concrete
227
+ * agent profile.
228
+ */
229
+ declare function createDaprWorkflowWorker(options: DaprWorkflowWorkerOptions): DaprWorkflowWorker;
230
+
231
+ interface DaprAgentTaskResultContext<TPayload extends AgentTaskPayload = AgentTaskPayload> {
232
+ jobId: string;
233
+ payload: TPayload;
234
+ runtimeContext: RuntimeExecutionContext;
235
+ result: AgentTaskResult;
236
+ }
237
+ interface DaprAgentTaskErrorContext<TPayload extends AgentTaskPayload = AgentTaskPayload> {
238
+ jobId: string;
239
+ payload: TPayload;
240
+ runtimeContext: RuntimeExecutionContext;
241
+ error: unknown;
242
+ message: string;
243
+ }
244
+ interface DaprAgentRuntimeOptions<TPayload extends AgentTaskPayload = AgentTaskPayload> {
245
+ /** Agent instance used for job execution. */
246
+ agent: Agent;
247
+ /** Dapr driver configuration (sidecar + state store + retries). */
248
+ driver: DaprRuntimeDriverOptions;
249
+ /**
250
+ * Optional runtime options excluding driver and execute.
251
+ * Use this to set concurrency/timeouts/logging behavior.
252
+ */
253
+ runtime?: Omit<AgentRuntimeOptions<TPayload>, "driver" | "execute">;
254
+ /**
255
+ * Optional explicit task runner. If omitted, one is created with
256
+ * createAgentTaskRunner(agent, taskRunnerOptions).
257
+ */
258
+ taskRunner?: AgentTaskRunner<TPayload>;
259
+ /** Options used when creating the default task runner. */
260
+ taskRunnerOptions?: AgentTaskRunnerOptions<TPayload>;
261
+ /**
262
+ * Persist neutral execution snapshots/checkpoints into Dapr state.
263
+ *
264
+ * Enabled by default when this helper creates the task runner. Disable it if
265
+ * you only want outer scheduling/orchestration durability.
266
+ */
267
+ persistExecutionState?: boolean;
268
+ /**
269
+ * Optional pre-created execution store. When omitted and
270
+ * `persistExecutionState !== false`, a store is created from the driver
271
+ * configuration.
272
+ */
273
+ executionStore?: DaprExecutionStore<TPayload>;
274
+ /**
275
+ * Optional execution store configuration override. This is only used when
276
+ * `executionStore` is not provided.
277
+ */
278
+ executionStoreOptions?: DaprExecutionStoreOptions;
279
+ /** Optional hook invoked after successful task execution. */
280
+ onTaskResult?: (context: DaprAgentTaskResultContext<TPayload>) => void | Promise<void>;
281
+ /** Optional hook invoked when task execution fails. */
282
+ onTaskError?: (context: DaprAgentTaskErrorContext<TPayload>) => void | Promise<void>;
283
+ }
284
+ interface DaprAgentRuntimeBundle<TPayload extends AgentTaskPayload = AgentTaskPayload> {
285
+ runtime: AgentRuntime<TPayload>;
286
+ driver: DaprRuntimeDriver<TPayload>;
287
+ runTask: AgentTaskRunner<TPayload>;
288
+ executionStore?: DaprExecutionStore<TPayload>;
289
+ handleDaprJob: (jobName: string) => Promise<DaprHttpJobHandlerResult>;
290
+ }
291
+ /**
292
+ * Create a Dapr-backed runtime bundle for executing agent tasks.
293
+ *
294
+ * The returned bundle includes:
295
+ * - runtime: scheduling + execution loop
296
+ * - driver: Dapr persistence/scheduler adapter
297
+ * - runTask: direct task runner (for manual invocation/tests)
298
+ * - handleDaprJob: reusable callback handler for `/job/:name` routes
299
+ */
300
+ declare function createDaprAgentRuntime<TPayload extends AgentTaskPayload = AgentTaskPayload>(options: DaprAgentRuntimeOptions<TPayload>): DaprAgentRuntimeBundle<TPayload>;
301
+
302
+ interface DaprHostRemoteRunRequest extends AgentTaskPayload {
303
+ agentId?: string;
304
+ }
305
+ interface DaprHostHttpHandlerOptions<TPayload extends AgentTaskPayload = DaprHostRemoteRunRequest> {
306
+ app: DaprHostApp<TPayload>;
307
+ workflowClient?: DaprWorkflowClient;
308
+ }
309
+ interface DaprHostHttpServerOptions<TPayload extends AgentTaskPayload = DaprHostRemoteRunRequest> extends DaprHostHttpHandlerOptions<TPayload> {
310
+ port: number;
311
+ host?: string;
312
+ }
313
+ interface DaprHostHttpServer {
314
+ server: Server;
315
+ origin: string;
316
+ close(): Promise<void>;
317
+ }
318
+ /**
319
+ * Create a lightweight HTTP handler for a Dapr host app.
320
+ *
321
+ * Routes:
322
+ * - `GET /health`
323
+ * - `GET /healthz`
324
+ * - `GET /ready`
325
+ * - `GET /readyz`
326
+ * - `GET /agents`
327
+ * - `POST /job/:name`
328
+ * - `POST /agents/run`
329
+ * - `POST /agents/workflow`
330
+ * - `POST /agents/:id/run`
331
+ * - `POST /agents/:id/workflow`
332
+ * - `GET /agents/:id/executions/:sessionId`
333
+ * - `GET /agents/:id/executions/:sessionId/checkpoints`
334
+ * - `GET /agents/:id/workflows/:instanceId`
335
+ */
336
+ declare function createDaprHostHttpHandler<TPayload extends AgentTaskPayload = DaprHostRemoteRunRequest>(options: DaprHostHttpHandlerOptions<TPayload>): (request: Request) => Promise<Response>;
337
+ declare function startDaprHostHttpServer<TPayload extends AgentTaskPayload = DaprHostRemoteRunRequest>(options: DaprHostHttpServerOptions<TPayload>): Promise<DaprHostHttpServer>;
338
+
339
+ interface DaprAgentRunnerOptions {
340
+ /** The agent to run. */
341
+ agent: Agent;
342
+ /**
343
+ * Unique identifier for this agent in the Dapr ecosystem.
344
+ * Defaults to `agent.name` if omitted.
345
+ */
346
+ name?: string;
347
+ /**
348
+ * Dapr sidecar HTTP endpoint.
349
+ * Defaults to `http://${DAPR_HOST ?? "127.0.0.1"}:${DAPR_HTTP_PORT ?? "3500"}`.
350
+ */
351
+ daprHttpEndpoint?: string;
352
+ /**
353
+ * Dapr gRPC host for the workflow runtime.
354
+ * Configure this directly on the provided `workflowRuntime`.
355
+ */
356
+ /**
357
+ * Dapr state store component name.
358
+ * Defaults to `"statestore"`.
359
+ */
360
+ stateStoreName?: string;
361
+ /**
362
+ * Dapr workflow component name.
363
+ * Defaults to `"dapr"`.
364
+ */
365
+ workflowComponent?: string;
366
+ /**
367
+ * Advanced Dapr driver options shared by the runtime bundle and readiness
368
+ * checks. Use this for API tokens, retry/timeouts, or custom fetch impls.
369
+ */
370
+ driverOptions?: Omit<DaprRuntimeDriverOptions, "stateStoreName" | "daprHttpEndpoint">;
371
+ /**
372
+ * The Dapr workflow runtime for registering workflows and activities.
373
+ * Must implement `start()`, `stop()`, `registerWorkflowWithName()`,
374
+ * and `registerActivityWithName()`.
375
+ *
376
+ * Pass `new WorkflowRuntime(...)` from `@dapr/dapr`.
377
+ */
378
+ workflowRuntime: DaprWorkflowWorkerRuntime;
379
+ /**
380
+ * Optional aliases for multi-agent lookups.
381
+ */
382
+ aliases?: string[];
383
+ /**
384
+ * Optional description for this agent.
385
+ */
386
+ description?: string;
387
+ /**
388
+ * Additional observers for execution lifecycle events.
389
+ * A logging observer is always included by default — pass extras here
390
+ * for persistence (e.g. `createDaprExecutionObserver()`), telemetry, etc.
391
+ */
392
+ observers?: AgentTaskObserver[];
393
+ /**
394
+ * Enable/disable the built-in console logging observer.
395
+ * Defaults to `true`.
396
+ */
397
+ logging?: boolean;
398
+ /**
399
+ * Prefix for log lines from the built-in logging observer.
400
+ * Defaults to `[${name}]`.
401
+ */
402
+ logPrefix?: string;
403
+ /**
404
+ * Override for workflow host options (advanced).
405
+ * Properties set here override the defaults derived from the runner config.
406
+ */
407
+ workflowHost?: Omit<DaprAgentWorkflowHostOptions, "agent" | "observers">;
408
+ /**
409
+ * Override for runtime bundle options (advanced).
410
+ * The `agent` and `driver` fields are always derived from the runner config.
411
+ */
412
+ runtimeOptions?: Omit<DaprAgentRuntimeOptions, "agent" | "driver" | "taskRunnerOptions"> & {
413
+ taskRunnerOptions?: Omit<NonNullable<DaprAgentRuntimeOptions["taskRunnerOptions"]>, "observers">;
414
+ };
415
+ }
416
+ interface DaprAgentServeOptions {
417
+ /** HTTP port. Defaults to `3000`. */
418
+ port?: number;
419
+ /** HTTP host. Defaults to all interfaces. */
420
+ host?: string;
421
+ }
422
+ interface DaprAgentRunner {
423
+ /** Agent name / ID. */
424
+ readonly name: string;
425
+ /** The underlying workflow host. */
426
+ readonly workflowHost: DaprAgentWorkflowHost;
427
+ /** The underlying runtime bundle (scheduling, task runner, execution store). */
428
+ readonly runtimeBundle: DaprAgentRuntimeBundle;
429
+ /** The underlying workflow worker. */
430
+ readonly worker: DaprWorkflowWorker;
431
+ /** The workflow client for managing workflow instances. */
432
+ readonly workflowClient: DaprWorkflowClient;
433
+ /**
434
+ * Start the runtime and workflow worker.
435
+ * Must be called before `serve()` or manual invocation.
436
+ */
437
+ start(): Promise<void>;
438
+ /**
439
+ * Start the HTTP server and block until SIGINT/SIGTERM.
440
+ * Calls `start()` internally if not already started.
441
+ */
442
+ serve(options?: DaprAgentServeOptions): Promise<void>;
443
+ /**
444
+ * Run a task directly (synchronous execution, no workflow).
445
+ * The agent must be started first.
446
+ */
447
+ run(message: string, options?: {
448
+ sessionId?: string;
449
+ }): Promise<AgentTaskResult>;
450
+ /**
451
+ * Gracefully shut down the runner.
452
+ */
453
+ stop(): Promise<void>;
454
+ }
455
+ /**
456
+ * Create a Dapr agent runner — the single-call composition of all pieces
457
+ * needed to run an agent with Dapr durability.
458
+ *
459
+ * Equivalent to Diagrid's `DaprWorkflowAgentRunner`. Internally creates:
460
+ * - Workflow host (Dapr workflow registration + turn state management)
461
+ * - Runtime bundle (scheduling + task runner + execution store)
462
+ * - Workflow worker (gRPC worker for Dapr workflow engine)
463
+ * - Workflow client (HTTP client for managing workflow instances)
464
+ * - HTTP server (on `serve()`)
465
+ *
466
+ * @example
467
+ * ```ts
468
+ * const runner = createDaprAgentRunner({
469
+ * agent,
470
+ * name: "my-agent",
471
+ * workflowRuntime: new WorkflowRuntime({ daprHost: "127.0.0.1", daprPort: "50001" }),
472
+ * });
473
+ *
474
+ * await runner.serve({ port: 3000 });
475
+ * ```
476
+ */
477
+ declare function createDaprAgentRunner(options: DaprAgentRunnerOptions): DaprAgentRunner;
478
+ interface DaprMultiAgentRunnerAgentConfig {
479
+ /** The agent instance. */
480
+ agent: Agent;
481
+ /** Unique identifier for this agent in the Dapr ecosystem. */
482
+ name: string;
483
+ /** Optional aliases for multi-agent lookups. */
484
+ aliases?: string[];
485
+ /** Optional description for this agent. */
486
+ description?: string;
487
+ }
488
+ interface DaprMultiAgentRunnerOptions {
489
+ /** Agent configurations. */
490
+ agents: DaprMultiAgentRunnerAgentConfig[];
491
+ /** Shared Dapr workflow runtime. */
492
+ workflowRuntime: DaprWorkflowWorkerRuntime;
493
+ /** Dapr sidecar HTTP endpoint. */
494
+ daprHttpEndpoint?: string;
495
+ /** Dapr state store component name. Defaults to `"statestore"`. */
496
+ stateStoreName?: string;
497
+ /** Advanced Dapr driver options shared by all hosted runtimes. */
498
+ driverOptions?: Omit<DaprRuntimeDriverOptions, "stateStoreName" | "daprHttpEndpoint">;
499
+ /** Dapr workflow component name. Defaults to `"dapr"`. */
500
+ workflowComponent?: string;
501
+ /** Additional observers applied to all agents. */
502
+ observers?: AgentTaskObserver[];
503
+ /** Enable/disable built-in console logging. Defaults to `true`. */
504
+ logging?: boolean;
505
+ }
506
+ interface DaprMultiAgentRunner {
507
+ /** Start all runtimes and the shared workflow worker. */
508
+ start(): Promise<void>;
509
+ /** Start HTTP server and block until SIGINT/SIGTERM. Calls `start()` internally. */
510
+ serve(options?: DaprAgentServeOptions): Promise<void>;
511
+ /** Gracefully shut down. */
512
+ stop(): Promise<void>;
513
+ }
514
+ /**
515
+ * Create a multi-agent Dapr runner — multiple agents sharing a single
516
+ * workflow worker, HTTP server, and Dapr sidecar.
517
+ *
518
+ * @example
519
+ * ```ts
520
+ * const runner = createDaprMultiAgentRunner({
521
+ * agents: [
522
+ * { agent: greeter, name: "greeter" },
523
+ * { agent: calculator, name: "calculator" },
524
+ * ],
525
+ * workflowRuntime: new WorkflowRuntime(),
526
+ * });
527
+ *
528
+ * await runner.serve({ port: 3000 });
529
+ * ```
530
+ */
531
+ declare function createDaprMultiAgentRunner(options: DaprMultiAgentRunnerOptions): DaprMultiAgentRunner;
532
+
533
+ export { DaprRuntimeDriver as A, DaprServiceInvoker as B, type DaprServiceInvokerOptions as C, type DaprAgentRunner as D, type DaprWorkflowRuntimeRegistrar as E, type DaprWorkflowStarterLike as F, type DaprWorkflowWorker as G, type DaprWorkflowWorkerAgentDefinition as H, type DaprWorkflowWorkerLogger as I, type DaprWorkflowWorkerOptions as J, type DaprWorkflowWorkerRuntime as K, type RemoteAgentRunResponse as L, createDaprAgentRunner as M, createDaprAgentRuntime as N, createDaprAgentWorkflowHost as O, createDaprHostHttpHandler as P, createDaprHttpJobHandler as Q, type RemoteAgentRunRequest as R, createDaprMultiAgentRunner as S, createDaprWorkflowWorker as T, invokeRemoteAgentRun as U, startDaprAgentWorkflowTurn as V, startDaprHostHttpServer as W, type DaprAgentRunnerOptions as a, type DaprAgentRuntimeBundle as b, type DaprAgentRuntimeOptions as c, type DaprAgentServeOptions as d, type DaprAgentTaskErrorContext as e, type DaprAgentTaskResultContext as f, type DaprAgentWorkflowHost as g, type DaprAgentWorkflowHostOptions as h, type DaprAgentWorkflowRunRequest as i, type DaprAgentWorkflowRunResult as j, type DaprHostApp as k, type DaprHostHttpHandlerOptions as l, type DaprHostHttpServer as m, type DaprHostHttpServerOptions as n, type DaprHostReadinessCheck as o, type DaprHostReadinessStatus as p, type DaprHostRemoteRunRequest as q, type DaprHostedAgentInfo as r, type DaprHttpJobHandlerOptions as s, type DaprHttpJobHandlerResult as t, type DaprInvokeMethodOptions as u, type DaprInvokeMethodResult as v, type DaprJobTriggerHandler as w, type DaprMultiAgentRunner as x, type DaprMultiAgentRunnerAgentConfig as y, type DaprMultiAgentRunnerOptions as z };
@@ -0,0 +1,47 @@
1
+ import { D as DaprOrchestratorRunStoreOptions } from './workflow-bridge-C8Z1yr0Y.js';
2
+ export { a as DaprExecutionStoreOptions, b as DaprFetch, c as DaprRuntimeDriverOptions, d as DaprSidecarClientOptions, e as DaprStateStoreClientOptions, f as DaprWorkflowObserverBridge, g as DaprWorkflowObserverOptions, h as createWorkflowObserverBridge } from './workflow-bridge-C8Z1yr0Y.js';
3
+ export { CreateDaprAgentTurnWorkflowDefinitionOptions, CreateDaprAgentTurnWorkflowKitOptions, CreateDaprAgentTurnWorkflowOptions, DaprAgentTurnActivityRegistration, DaprAgentTurnCommitActivityOptions, DaprAgentTurnModelStepActivityOptions, DaprAgentTurnToolCallActivityOptions, DaprAgentTurnWorkflowActivityNames, DaprAgentTurnWorkflowContextLike, DaprAgentTurnWorkflowDefinition, DaprAgentTurnWorkflowKit, DaprAgentTurnWorkflowRegistration, DaprStartWorkflowResponse, DaprWorkflowApiVersion, DaprWorkflowClient, DaprWorkflowClientOptions, DaprWorkflowRuntimeStatus, DaprWorkflowState, RaiseDaprWorkflowEventOptions, StartDaprWorkflowOptions, WaitForDaprWorkflowOptions, createDaprAgentTurnModelStepActivity, createDaprAgentTurnOutputCommitActivity, createDaprAgentTurnStepCommitActivity, createDaprAgentTurnToolCallActivity, createDaprAgentTurnWorkflowDefinition, createDaprAgentTurnWorkflowKit, hasStartedDaprWorkflow, isTerminalDaprWorkflowStatus } from './workflow/index.js';
4
+ export { D as DaprAgentRunner, a as DaprAgentRunnerOptions, b as DaprAgentRuntimeBundle, c as DaprAgentRuntimeOptions, d as DaprAgentServeOptions, e as DaprAgentTaskErrorContext, f as DaprAgentTaskResultContext, g as DaprAgentWorkflowHost, h as DaprAgentWorkflowHostOptions, i as DaprAgentWorkflowRunRequest, j as DaprAgentWorkflowRunResult, k as DaprHostApp, l as DaprHostHttpHandlerOptions, m as DaprHostHttpServer, n as DaprHostHttpServerOptions, o as DaprHostReadinessCheck, p as DaprHostReadinessStatus, q as DaprHostRemoteRunRequest, r as DaprHostedAgentInfo, s as DaprHttpJobHandlerOptions, t as DaprHttpJobHandlerResult, u as DaprInvokeMethodOptions, v as DaprInvokeMethodResult, w as DaprJobTriggerHandler, x as DaprMultiAgentRunner, y as DaprMultiAgentRunnerAgentConfig, z as DaprMultiAgentRunnerOptions, A as DaprRuntimeDriver, B as DaprServiceInvoker, C as DaprServiceInvokerOptions, E as DaprWorkflowRuntimeRegistrar, F as DaprWorkflowStarterLike, G as DaprWorkflowWorker, H as DaprWorkflowWorkerAgentDefinition, I as DaprWorkflowWorkerLogger, J as DaprWorkflowWorkerOptions, K as DaprWorkflowWorkerRuntime, R as RemoteAgentRunRequest, L as RemoteAgentRunResponse, M as createDaprAgentRunner, N as createDaprAgentRuntime, O as createDaprAgentWorkflowHost, P as createDaprHostHttpHandler, Q as createDaprHttpJobHandler, S as createDaprMultiAgentRunner, T as createDaprWorkflowWorker, U as invokeRemoteAgentRun, V as startDaprAgentWorkflowTurn, W as startDaprHostHttpServer } from './index-CKTP36vE.js';
5
+ export { D as DaprExecutionCheckpointRecord, a as DaprExecutionCleanupOptions, b as DaprExecutionCleanupResult, c as DaprExecutionContextMetadata, d as DaprExecutionErrorRecord, e as DaprExecutionRunRecord, f as DaprExecutionSnapshot, g as DaprExecutionStatus, h as DaprExecutionStore } from './store-pRLGfYhN.js';
6
+ export { DaprExecutionObserver, DaprExecutionObserverOptions, DaprHostLoggerLike, DaprLoggingObserverOptions, OtelObserverConfig, createDaprExecutionObserver, createDaprLoggingObserver, createOtelObserver } from './execution/index.js';
7
+ import { OrchestratorRunStatus, OrchestratorRunStore, OrchestratorRunRecord } from '@cuylabs/agent-runtime';
8
+ import '@cuylabs/agent-core';
9
+ import 'node:http';
10
+
11
+ interface DaprOrchestratorRunCleanupOptions {
12
+ maxAgeMs?: number;
13
+ maxRuns?: number;
14
+ statuses?: OrchestratorRunStatus[];
15
+ includeActive?: boolean;
16
+ now?: () => number;
17
+ }
18
+ interface DaprOrchestratorRunCleanupResult {
19
+ deletedRuns: number;
20
+ deletedRunIds: string[];
21
+ }
22
+ declare class DaprOrchestratorRunStore<TInput = unknown, TResult = unknown> implements OrchestratorRunStore<TInput, TResult> {
23
+ private readonly client;
24
+ private readonly keyPrefix;
25
+ constructor(options: DaprOrchestratorRunStoreOptions);
26
+ start(): Promise<void>;
27
+ stop(): Promise<void>;
28
+ get(runId: string): Promise<OrchestratorRunRecord<TInput, TResult> | undefined>;
29
+ list(): Promise<OrchestratorRunRecord<TInput, TResult>[]>;
30
+ upsert(run: OrchestratorRunRecord<TInput, TResult>): Promise<OrchestratorRunRecord<TInput, TResult>>;
31
+ remove(runId: string): Promise<boolean>;
32
+ cleanup(options?: DaprOrchestratorRunCleanupOptions): Promise<DaprOrchestratorRunCleanupResult>;
33
+ private stateKeyForRun;
34
+ private stateKeyForIndex;
35
+ private readRun;
36
+ private writeRun;
37
+ private readIndex;
38
+ private writeIndex;
39
+ private addToIndex;
40
+ private removeFromIndex;
41
+ private listRunsViaStateQuery;
42
+ private listRunsFromIndex;
43
+ private decodeStoredRun;
44
+ private updateIndex;
45
+ }
46
+
47
+ export { type DaprOrchestratorRunCleanupOptions, type DaprOrchestratorRunCleanupResult, DaprOrchestratorRunStore, DaprOrchestratorRunStoreOptions };
package/dist/index.js ADDED
@@ -0,0 +1,65 @@
1
+ import {
2
+ DaprOrchestratorRunStore,
3
+ DaprRuntimeDriver,
4
+ DaprServiceInvoker,
5
+ createDaprAgentRunner,
6
+ createDaprAgentRuntime,
7
+ createDaprAgentWorkflowHost,
8
+ createDaprHostHttpHandler,
9
+ createDaprHttpJobHandler,
10
+ createDaprMultiAgentRunner,
11
+ createDaprWorkflowWorker,
12
+ invokeRemoteAgentRun,
13
+ startDaprAgentWorkflowTurn,
14
+ startDaprHostHttpServer
15
+ } from "./chunk-2FMHOZLU.js";
16
+ import {
17
+ DaprExecutionObserver,
18
+ DaprExecutionStore,
19
+ createDaprExecutionObserver,
20
+ createDaprLoggingObserver,
21
+ createOtelObserver,
22
+ createWorkflowObserverBridge
23
+ } from "./chunk-2CEICSJH.js";
24
+ import {
25
+ DaprWorkflowClient,
26
+ createDaprAgentTurnModelStepActivity,
27
+ createDaprAgentTurnOutputCommitActivity,
28
+ createDaprAgentTurnStepCommitActivity,
29
+ createDaprAgentTurnToolCallActivity,
30
+ createDaprAgentTurnWorkflowDefinition,
31
+ createDaprAgentTurnWorkflowKit,
32
+ hasStartedDaprWorkflow,
33
+ isTerminalDaprWorkflowStatus
34
+ } from "./chunk-DILON56B.js";
35
+ import "./chunk-A34CHK2E.js";
36
+ export {
37
+ DaprExecutionObserver,
38
+ DaprExecutionStore,
39
+ DaprOrchestratorRunStore,
40
+ DaprRuntimeDriver,
41
+ DaprServiceInvoker,
42
+ DaprWorkflowClient,
43
+ createDaprAgentRunner,
44
+ createDaprAgentRuntime,
45
+ createDaprAgentTurnModelStepActivity,
46
+ createDaprAgentTurnOutputCommitActivity,
47
+ createDaprAgentTurnStepCommitActivity,
48
+ createDaprAgentTurnToolCallActivity,
49
+ createDaprAgentTurnWorkflowDefinition,
50
+ createDaprAgentTurnWorkflowKit,
51
+ createDaprAgentWorkflowHost,
52
+ createDaprExecutionObserver,
53
+ createDaprHostHttpHandler,
54
+ createDaprHttpJobHandler,
55
+ createDaprLoggingObserver,
56
+ createDaprMultiAgentRunner,
57
+ createDaprWorkflowWorker,
58
+ createOtelObserver,
59
+ createWorkflowObserverBridge,
60
+ hasStartedDaprWorkflow,
61
+ invokeRemoteAgentRun,
62
+ isTerminalDaprWorkflowStatus,
63
+ startDaprAgentWorkflowTurn,
64
+ startDaprHostHttpServer
65
+ };