@cuylabs/agent-runtime-dapr 0.9.0 → 0.11.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,612 @@
1
+ import { TaskBoardStore, TeamMember, TaskListFilter, TeamTask, MailboxStore, TeamMessage, MessageListFilter, TaskResult, WorkerReport, TeamCoordinator, TaskExecutor, CoordinatorLoopOptions, CoordinatorLoopResult, TeamEvent, TeamCoordinatorConfig } from '@cuylabs/agent-core/team';
2
+ import { d as DaprSidecarClientOptions } from '../workflow-bridge-BcicHH1Y.js';
3
+ import { TokenUsage, AgentWorkflowTurnState, Agent, DispatchRole } from '@cuylabs/agent-core';
4
+ import { d as DaprWorkflowWorkerRuntime } from '../worker-CXq0IFGX.js';
5
+ import { z as DaprWorkflowState, W as WaitForDaprWorkflowOptions } from '../client-UsEIzDF6.js';
6
+ import { EventBus } from '@cuylabs/agent-core/events';
7
+ import '../workflow-host-D6W6fXoL.js';
8
+
9
+ type DaprStateQueryResponse<TValue> = {
10
+ results?: Array<{
11
+ key: string;
12
+ data?: TValue;
13
+ etag?: string;
14
+ error?: string;
15
+ }>;
16
+ token?: string;
17
+ };
18
+ type DaprStateValue<TValue> = {
19
+ value?: TValue;
20
+ etag?: string;
21
+ };
22
+ declare class DaprSidecarClient {
23
+ readonly stateStoreName?: string;
24
+ private readonly daprHttpEndpoint;
25
+ private readonly apiToken?;
26
+ private readonly fetchImpl;
27
+ private readonly requestTimeoutMs;
28
+ private readonly maxRequestRetries;
29
+ private readonly verifySidecarOnStart;
30
+ constructor(options: DaprSidecarClientOptions & {
31
+ stateStoreName?: string;
32
+ });
33
+ verifySidecar(): Promise<void>;
34
+ getStateEntry<TValue>(key: string): Promise<DaprStateValue<TValue>>;
35
+ getState<TValue>(key: string): Promise<TValue | undefined>;
36
+ saveState(key: string, value: unknown, options?: {
37
+ etag?: string;
38
+ concurrency?: "first-write" | "last-write";
39
+ }): Promise<void>;
40
+ deleteState(key: string, options?: {
41
+ etag?: string;
42
+ concurrency?: "first-write" | "last-write";
43
+ }): Promise<void>;
44
+ queryState<TValue>(query: unknown): Promise<DaprStateQueryResponse<TValue> | undefined>;
45
+ publish(pubsubName: string, topic: string, data: unknown, metadata?: Record<string, string>): Promise<void>;
46
+ requestJson<TValue = unknown>(path: string, init: RequestInit, allowedStatusCodes: number[]): Promise<TValue | undefined>;
47
+ request(path: string, init: RequestInit, allowedStatusCodes: number[], withJsonContentType?: boolean): Promise<Response>;
48
+ private requireStateStoreName;
49
+ }
50
+
51
+ /**
52
+ * Dapr State Store-backed TaskBoardStore
53
+ *
54
+ * Implements the `TaskBoardStore` interface from agent-core's team module
55
+ * using Dapr's state management API. Tasks and members are persisted as
56
+ * individual state entries, with lightweight indexes for list operations.
57
+ *
58
+ * Key layout:
59
+ * team:{teamId}:members — string[] index of member IDs
60
+ * team:{teamId}:member:{id} — serialized TeamMember
61
+ * team:{teamId}:tasks — string[] index of task IDs
62
+ * team:{teamId}:task:{id} — serialized TeamTask
63
+ *
64
+ * Index updates use optimistic concurrency (etag-based) with retries
65
+ * to handle concurrent access safely.
66
+ */
67
+
68
+ interface DaprTaskBoardStoreOptions {
69
+ /** Dapr state store component name. Defaults to `"statestore"`. */
70
+ stateStoreName?: string;
71
+ /** Team identifier — scopes all keys. */
72
+ teamId: string;
73
+ /** Pre-existing client to reuse. If omitted, one is created from the other options. */
74
+ client?: DaprSidecarClient;
75
+ /** Dapr sidecar connection options (used only when `client` is not provided). */
76
+ clientOptions?: DaprSidecarClientOptions;
77
+ }
78
+ declare class DaprTaskBoardStore implements TaskBoardStore {
79
+ private readonly client;
80
+ private readonly teamId;
81
+ private readonly memberEtags;
82
+ private readonly taskEtags;
83
+ constructor(options: DaprTaskBoardStoreOptions);
84
+ private memberKey;
85
+ private memberIndexKey;
86
+ private taskKey;
87
+ private taskIndexKey;
88
+ listMembers(): Promise<TeamMember[]>;
89
+ getMember(memberId: string): Promise<TeamMember | undefined>;
90
+ putMember(member: TeamMember): Promise<TeamMember>;
91
+ listTasks(filter?: TaskListFilter): Promise<TeamTask[]>;
92
+ getTask(taskId: string): Promise<TeamTask | undefined>;
93
+ putTask(task: TeamTask): Promise<TeamTask>;
94
+ private resolveMemberEtag;
95
+ private resolveTaskEtag;
96
+ private readIndex;
97
+ private addToIndex;
98
+ private updateIndex;
99
+ }
100
+
101
+ /**
102
+ * Dapr State Store-backed MailboxStore
103
+ *
104
+ * Implements the `MailboxStore` interface from agent-core's team module
105
+ * using Dapr's state management API. Messages are individually stored
106
+ * with a lightweight index for list operations.
107
+ *
108
+ * Key layout:
109
+ * team:{teamId}:messages — string[] index of message IDs
110
+ * team:{teamId}:msg:{id} — serialized TeamMessage
111
+ *
112
+ * Index updates use optimistic concurrency (etag-based) with retries.
113
+ */
114
+
115
+ interface DaprMailboxStoreOptions {
116
+ /** Dapr state store component name. Defaults to `"statestore"`. */
117
+ stateStoreName?: string;
118
+ /** Team identifier — scopes all keys. */
119
+ teamId: string;
120
+ /** Pre-existing client to reuse. If omitted, one is created from the other options. */
121
+ client?: DaprSidecarClient;
122
+ /** Dapr sidecar connection options (used only when `client` is not provided). */
123
+ clientOptions?: DaprSidecarClientOptions;
124
+ }
125
+ declare class DaprMailboxStore implements MailboxStore {
126
+ private readonly client;
127
+ private readonly teamId;
128
+ constructor(options: DaprMailboxStoreOptions);
129
+ private messageKey;
130
+ private messageIndexKey;
131
+ append(message: TeamMessage): Promise<TeamMessage>;
132
+ list(filter?: MessageListFilter): Promise<TeamMessage[]>;
133
+ private readIndex;
134
+ private addToIndex;
135
+ private updateIndex;
136
+ }
137
+
138
+ /**
139
+ * Durable Coordinator Workflow (Level 2)
140
+ *
141
+ * The coordinator loop runs as a Dapr workflow, but task and mailbox state
142
+ * still flow through `agent-core`'s team coordinator. The workflow records
143
+ * coordinator intent, applies those actions through the core coordinator,
144
+ * launches durable child turns for ready tasks, and feeds task/report
145
+ * notifications back into the next round.
146
+ */
147
+
148
+ interface CoordinatorWorkflowInput {
149
+ prompt: string;
150
+ teamId: string;
151
+ maxRounds: number;
152
+ waitTimeoutMs: number;
153
+ coordinatorSessionId: string;
154
+ roleNames: string[];
155
+ }
156
+ interface CoordinatorAssignment {
157
+ /**
158
+ * Coordinator-local task alias used inside the LLM round.
159
+ * This is resolved to a real task-board task ID by `applyCoordinatorActions`.
160
+ */
161
+ taskId: string;
162
+ memberId: string;
163
+ title: string;
164
+ prompt: string;
165
+ dependsOn?: string[];
166
+ }
167
+ interface CoordinatorMessage {
168
+ memberId: string;
169
+ message: string;
170
+ }
171
+ interface CoordinatorAbort {
172
+ taskId: string;
173
+ reason?: string;
174
+ }
175
+ type CoordinatorRecordedAction = ({
176
+ kind: "assign";
177
+ } & CoordinatorAssignment) | ({
178
+ kind: "message";
179
+ } & CoordinatorMessage) | ({
180
+ kind: "abort";
181
+ } & CoordinatorAbort);
182
+ interface CoordinatorReasonResult {
183
+ response: string;
184
+ usage: TokenUsage;
185
+ actions: CoordinatorRecordedAction[];
186
+ assignments: CoordinatorAssignment[];
187
+ messages: CoordinatorMessage[];
188
+ aborts: CoordinatorAbort[];
189
+ allTasksDone: boolean;
190
+ }
191
+ interface CoordinatorTrackedTask {
192
+ id: string;
193
+ memberId?: string;
194
+ title: string;
195
+ status: string;
196
+ runId?: string;
197
+ }
198
+ interface CoordinatorTaskNotification {
199
+ taskId: string;
200
+ memberId: string;
201
+ title: string;
202
+ status: string;
203
+ result?: TaskResult;
204
+ error?: string;
205
+ }
206
+ interface AppliedCoordinatorActionsResult {
207
+ createdTasks: CoordinatorTrackedTask[];
208
+ notifications: CoordinatorTaskNotification[];
209
+ }
210
+ interface CoordinatorChildLaunch {
211
+ taskId: string;
212
+ memberId: string;
213
+ memberRole: string;
214
+ title: string;
215
+ prompt: string;
216
+ sessionId: string;
217
+ runId: string;
218
+ }
219
+ interface PreparedExternalTasksResult {
220
+ launches: CoordinatorChildLaunch[];
221
+ }
222
+ interface CommittedCoordinatorTaskResult {
223
+ notifications: CoordinatorTaskNotification[];
224
+ }
225
+ interface CollectedWorkerReportsResult {
226
+ reports: WorkerReport[];
227
+ consumedReportIds: string[];
228
+ }
229
+ interface CoordinatorWorkflowState {
230
+ input: CoordinatorWorkflowInput;
231
+ round: number;
232
+ nextMessage: string;
233
+ rounds: CoordinatorWorkflowRound[];
234
+ totalUsage: TokenUsage;
235
+ knownTerminalIds: string[];
236
+ }
237
+ interface CoordinatorWorkflowResult {
238
+ response: string;
239
+ rounds: CoordinatorWorkflowRound[];
240
+ usage: TokenUsage;
241
+ }
242
+ interface CoordinatorWorkflowRound {
243
+ number: number;
244
+ assigned: Array<{
245
+ taskId: string;
246
+ memberId: string;
247
+ title: string;
248
+ }>;
249
+ messaged: Array<{
250
+ memberId: string;
251
+ }>;
252
+ stopped: string[];
253
+ childResults: Array<{
254
+ taskId: string;
255
+ memberId: string;
256
+ title: string;
257
+ status: string;
258
+ result?: TaskResult;
259
+ error?: string;
260
+ }>;
261
+ response: string;
262
+ usage: TokenUsage;
263
+ }
264
+ interface CoordinatorWorkflowActivityNames {
265
+ coordinatorReason: string;
266
+ applyCoordinatorActions: string;
267
+ prepareExternalTasks: string;
268
+ commitExternalTask: string;
269
+ collectWorkerReports: string;
270
+ checkTrackedTasksTerminal: string;
271
+ }
272
+ interface CoordinatorWorkflowContextLike {
273
+ callActivity(name: string, input: unknown): unknown;
274
+ callChildWorkflow(name: string, input: unknown, instanceId?: string): unknown;
275
+ whenAny(tasks: unknown[]): unknown;
276
+ waitForExternalEvent(name: string): unknown;
277
+ createTimer(fireAt: Date | number): unknown;
278
+ setCustomStatus?(status: string): void;
279
+ isReplaying?(): boolean;
280
+ getWorkflowInstanceId?(): string;
281
+ }
282
+ interface CoordinatorWorkflowRegistration {
283
+ workflowName: string;
284
+ activityNames: CoordinatorWorkflowActivityNames;
285
+ workflow: (ctx: CoordinatorWorkflowContextLike, input: CoordinatorWorkflowInput) => AsyncGenerator<unknown, CoordinatorWorkflowResult, unknown>;
286
+ }
287
+ interface CreateCoordinatorWorkflowOptions {
288
+ workflowName?: string;
289
+ activityNames?: Partial<CoordinatorWorkflowActivityNames>;
290
+ resolveAgentTurnWorkflowName?: (roleName: string) => string;
291
+ }
292
+ declare function createCoordinatorWorkflowDefinition(options?: CreateCoordinatorWorkflowOptions): CoordinatorWorkflowRegistration;
293
+
294
+ /**
295
+ * Coordinator Workflow Activities
296
+ *
297
+ * These activities bridge the durable workflow back into `agent-core` team
298
+ * semantics. The coordinator round still records intent deterministically,
299
+ * but task/message/abort side effects flow through the real coordinator,
300
+ * task board, and mailbox.
301
+ */
302
+
303
+ interface CoordinatorReasonActivityInput {
304
+ coordinatorSessionId: string;
305
+ teamId: string;
306
+ message: string;
307
+ roundNum: number;
308
+ knownTerminalIds: string[];
309
+ }
310
+ interface CoordinatorReasonActivityOptions {
311
+ lead: Agent;
312
+ coordinator: TeamCoordinator;
313
+ onCoordinatorEvent?: (event: unknown) => void;
314
+ }
315
+ declare function createCoordinatorReasonActivity(options: CoordinatorReasonActivityOptions): (ctx: unknown, input: CoordinatorReasonActivityInput) => Promise<CoordinatorReasonResult>;
316
+ interface ApplyCoordinatorActionsInput {
317
+ actions: CoordinatorRecordedAction[];
318
+ }
319
+ interface ApplyCoordinatorActionsActivityOptions {
320
+ coordinator: TeamCoordinator;
321
+ }
322
+ declare function createApplyCoordinatorActionsActivity(options: ApplyCoordinatorActionsActivityOptions): (ctx: unknown, input: ApplyCoordinatorActionsInput) => Promise<AppliedCoordinatorActionsResult>;
323
+ interface PrepareExternalTasksInput {
324
+ tasks: Array<{
325
+ taskId: string;
326
+ runId: string;
327
+ }>;
328
+ }
329
+ interface PrepareExternalTasksActivityOptions {
330
+ coordinator: TeamCoordinator;
331
+ }
332
+ declare function createPrepareExternalTasksActivity(options: PrepareExternalTasksActivityOptions): (ctx: unknown, input: PrepareExternalTasksInput) => Promise<PreparedExternalTasksResult>;
333
+ interface CommitExternalTaskInput {
334
+ taskId: string;
335
+ turnState?: AgentWorkflowTurnState;
336
+ error?: string;
337
+ }
338
+ interface CommitExternalTaskActivityOptions {
339
+ coordinator: TeamCoordinator;
340
+ }
341
+ declare function createCommitExternalTaskActivity(options: CommitExternalTaskActivityOptions): (ctx: unknown, input: CommitExternalTaskInput) => Promise<CommittedCoordinatorTaskResult>;
342
+ interface CollectWorkerReportsInput {
343
+ consumedReportIds: string[];
344
+ }
345
+ interface CollectWorkerReportsActivityOptions {
346
+ coordinator: TeamCoordinator;
347
+ }
348
+ declare function createCollectWorkerReportsActivity(options: CollectWorkerReportsActivityOptions): (ctx: unknown, input: CollectWorkerReportsInput) => Promise<CollectedWorkerReportsResult>;
349
+ interface CheckTrackedTasksTerminalInput {
350
+ taskIds: string[];
351
+ }
352
+ interface CheckTrackedTasksTerminalActivityOptions {
353
+ coordinator: TeamCoordinator;
354
+ }
355
+ declare function createCheckTrackedTasksTerminalActivity(options: CheckTrackedTasksTerminalActivityOptions): (ctx: unknown, input: CheckTrackedTasksTerminalInput) => Promise<boolean>;
356
+
357
+ /**
358
+ * Type definitions for the Dapr Team Runner.
359
+ *
360
+ * Extracted from `team-runner.ts` for maintainability.
361
+ */
362
+
363
+ interface DaprTeamDispatchOptions {
364
+ /**
365
+ * Explicit executor used for member task dispatch in non-durable runs.
366
+ *
367
+ * Build this with dispatch-layer helpers such as
368
+ * `createDaprCompositeDispatchExecutor(...)`,
369
+ * `createDaprAppDispatchExecutor(...)`, or any custom `TaskExecutor`.
370
+ *
371
+ * When `workflowRuntime` is enabled, durable child workflows own member
372
+ * execution and this executor is ignored.
373
+ */
374
+ executor?: TaskExecutor;
375
+ }
376
+ interface DaprTeamRunnerOptions {
377
+ /** The lead agent that members are forked from. */
378
+ lead: Agent;
379
+ /** Available roles for team members. */
380
+ roles: DispatchRole[];
381
+ /** Session ID for the lead agent (used for synthesis calls). */
382
+ leadSessionId: string;
383
+ /** Team identifier. Auto-generated if omitted. */
384
+ teamId?: string;
385
+ /** Dapr sidecar HTTP endpoint. Defaults to `http://127.0.0.1:3500`. */
386
+ daprHttpEndpoint?: string;
387
+ /** Dapr state store component name. Defaults to `"statestore"`. */
388
+ stateStoreName?: string;
389
+ /**
390
+ * Enable member work loops. When true, registered members enter
391
+ * a persistent idle loop that auto-claims tasks. When false (default),
392
+ * the coordinator dispatches tasks manually.
393
+ */
394
+ workLoopEnabled?: boolean;
395
+ /** How often (ms) the idle loop polls for new work. Default: 500. */
396
+ pollIntervalMs?: number;
397
+ /** Enable/disable built-in console logging. Defaults to `true`. */
398
+ logging?: boolean;
399
+ /** Prefix for log messages. Defaults to `"[team]"`. */
400
+ logPrefix?: string;
401
+ /** Coordinator loop options (used when calling run()). */
402
+ coordinatorLoopOptions?: Omit<CoordinatorLoopOptions, "onRound" | "onStatus">;
403
+ /** Optional event callback — invoked for every team lifecycle event. */
404
+ onEvent?: (event: TeamEvent) => void | Promise<void>;
405
+ /**
406
+ * Auto-register all roles on start.
407
+ * If true, all roles are registered as members when start() is called.
408
+ * If an array, only those role names are registered.
409
+ * Defaults to false (manual registration via coordinator or HTTP).
410
+ */
411
+ autoRegister?: boolean | string[];
412
+ /**
413
+ * Whether to attempt recovery of interrupted tasks on start.
414
+ * When true (default), tasks that were "running" when the process last
415
+ * died are marked as failed so the coordinator can re-queue them.
416
+ */
417
+ recoverOnStart?: boolean;
418
+ /**
419
+ * Dispatch-layer configuration for non-durable member execution.
420
+ *
421
+ * This keeps backend selection outside the runner itself. For example,
422
+ * pass `dispatch: { executor: createDaprCompositeDispatchExecutor(...) }`
423
+ * for mixed local/remote teams.
424
+ */
425
+ dispatch?: DaprTeamDispatchOptions;
426
+ /**
427
+ * Dapr workflow runtime for registering durable workflows.
428
+ * When provided, enables Level 2 durable coordination:
429
+ * - the root coordinator loop runs as a Dapr workflow
430
+ * - member task executions run as child workflows (durable, crash-safe)
431
+ * - use `runDurable()` to start the durable root workflow
432
+ *
433
+ * When omitted, the same core team semantics still run through
434
+ * `createDaprTeamRunner()`, but execution stays in-process and you
435
+ * use `run()` instead.
436
+ *
437
+ * Pass `new WorkflowRuntime(...)` from `@dapr/dapr`.
438
+ */
439
+ workflowRuntime?: DaprWorkflowWorkerRuntime;
440
+ /**
441
+ * Options for the coordinator workflow definition.
442
+ * Only used when `workflowRuntime` is provided.
443
+ */
444
+ coordinatorWorkflowOptions?: {
445
+ /** Custom workflow name. Defaults to `"team-coordinator"`. */
446
+ workflowName?: string;
447
+ /** Max rounds before forcing completion. Defaults to `20`. */
448
+ maxRounds?: number;
449
+ /** Wait timeout per round (ms). Defaults to `120_000`. */
450
+ waitTimeoutMs?: number;
451
+ /** Custom resolve function for agent turn workflow names. */
452
+ resolveAgentTurnWorkflowName?: (roleName: string) => string;
453
+ };
454
+ /**
455
+ * Additional coordinator config options to pass through.
456
+ */
457
+ coordinatorConfig?: Partial<Pick<TeamCoordinatorConfig, "onPermissionRequest" | "beforeIteration" | "sharedPermissions" | "signal" | "createId">>;
458
+ }
459
+ interface DaprTeamDurableRunOptions {
460
+ /** Max coordinator rounds before forcing completion. */
461
+ maxRounds?: number;
462
+ /** Wait timeout per round in milliseconds. */
463
+ waitTimeoutMs?: number;
464
+ }
465
+ interface DaprTeamDurableRunStartResult {
466
+ teamId: string;
467
+ workflowName: string;
468
+ coordinatorSessionId: string;
469
+ instanceId: string;
470
+ }
471
+ interface DaprTeamDurableRunState extends DaprWorkflowState {
472
+ teamId: string;
473
+ coordinatorSessionId: string;
474
+ result?: CoordinatorWorkflowResult;
475
+ customStatus?: unknown;
476
+ }
477
+ interface DaprTeamServeOptions {
478
+ /** HTTP port. Defaults to `3000`. */
479
+ port?: number;
480
+ /** HTTP host. Defaults to all interfaces. */
481
+ host?: string;
482
+ }
483
+ interface DaprTeamRunner {
484
+ /** The underlying team coordinator. */
485
+ readonly coordinator: TeamCoordinator;
486
+ /** The Dapr sidecar client. */
487
+ readonly client: DaprSidecarClient;
488
+ /** Start the team runner (stores + recovery + optional auto-register). */
489
+ start(): Promise<void>;
490
+ /** Start the HTTP server and block until SIGINT/SIGTERM. */
491
+ serve(options?: DaprTeamServeOptions): Promise<void>;
492
+ /**
493
+ * Run the coordinator loop directly (Level 1 — in-process).
494
+ * Convenience wrapper around coordinator.run().
495
+ *
496
+ * This keeps the core coordinator loop in-process while still using
497
+ * the Dapr-backed runner shell and stores.
498
+ */
499
+ run(prompt: string, options?: CoordinatorLoopOptions): Promise<CoordinatorLoopResult>;
500
+ /**
501
+ * Start a durable coordinator workflow (Level 2).
502
+ * Requires `workflowRuntime` in options.
503
+ *
504
+ * Vocabulary:
505
+ * - `run()` = direct, in-process coordinator execution
506
+ * - `runDurable()` = start the durable root coordinator workflow
507
+ * - child workflows = durable member task executions started by the root
508
+ *
509
+ * The coordinator loop itself is the root Dapr workflow. Each member task
510
+ * execution runs as a child workflow. On crash, Dapr replays from the last
511
+ * checkpoint — no work is lost.
512
+ *
513
+ * This is the durable transport for the same core team semantics
514
+ * exposed by `run()`. The call returns immediately with the workflow
515
+ * instance identifiers; use `getDurableRun()` or `waitForDurableRun()`
516
+ * to inspect or wait for completion explicitly from outside the workflow.
517
+ */
518
+ runDurable(prompt: string, options?: DaprTeamDurableRunOptions): Promise<DaprTeamDurableRunStartResult>;
519
+ /** Get the current state of a durable team run by workflow instance ID. */
520
+ getDurableRun(instanceId: string): Promise<DaprTeamDurableRunState | undefined>;
521
+ /**
522
+ * Wait for a durable team run to reach a terminal workflow state.
523
+ * This is an explicit edge-level polling helper over Dapr workflow APIs.
524
+ * It is for callers outside the workflow, not for parent/child coordination
525
+ * inside the durable team workflow itself.
526
+ */
527
+ waitForDurableRun(instanceId: string, options?: WaitForDaprWorkflowOptions): Promise<DaprTeamDurableRunState | undefined>;
528
+ /** Gracefully shut down. */
529
+ stop(): Promise<void>;
530
+ }
531
+
532
+ /**
533
+ * Team HTTP Handler
534
+ *
535
+ * Adds team-scoped HTTP routes to the Dapr host. These routes expose the
536
+ * TeamCoordinator's functionality over HTTP, enabling external callers
537
+ * (CLIs, dashboards, other services) to manage team coordination.
538
+ *
539
+ * Routes:
540
+ * POST /team/run — Start coordinator.run(prompt) with optional SSE streaming
541
+ * POST /team/run-durable — Start a durable coordinator workflow and return its instance ID
542
+ * POST /team/queue — Queue a new task
543
+ * POST /team/register — Register a member from a role
544
+ * POST /team/guide — Send guidance to a member
545
+ * POST /team/broadcast — Broadcast message to all members
546
+ * POST /team/abort/:taskId — Abort a task
547
+ * POST /team/cancel/:taskId — Cancel a task
548
+ * POST /team/shutdown — Shutdown the team
549
+ * GET /team/status — Team snapshot (members, tasks, stats)
550
+ * GET /team/tasks — List tasks (optional ?status=... &memberId=...)
551
+ * GET /team/tasks/:taskId — Get a specific task
552
+ * GET /team/members — List members
553
+ * GET /team/messages — List messages (optional ?from=... &to=... &kind=...)
554
+ * GET /team/roles — List available roles
555
+ * GET /team/workflows/:instanceId — Inspect durable workflow status and extracted result/custom status
556
+ */
557
+
558
+ interface DaprTeamHttpHandlerOptions {
559
+ /** The team coordinator instance. */
560
+ coordinator: TeamCoordinator;
561
+ /** Optional event bus for SSE streaming of coordinator rounds. */
562
+ eventBus?: EventBus;
563
+ /** Coordinator loop options passed to coordinator.run(). */
564
+ coordinatorLoopOptions?: Omit<CoordinatorLoopOptions, "onRound" | "onStatus">;
565
+ /** Optional durable team runner callback for /team/run-durable. */
566
+ runDurable?: (input: {
567
+ prompt: string;
568
+ maxRounds?: number;
569
+ waitTimeoutMs?: number;
570
+ }) => Promise<DaprTeamDurableRunStartResult>;
571
+ /** Optional durable team workflow lookup for /team/workflows/:instanceId. */
572
+ getDurableRun?: (instanceId: string) => Promise<DaprTeamDurableRunState | undefined>;
573
+ /** Optional guard for rejecting mutable routes such as late registration. */
574
+ rejectRegistration?: () => string | undefined;
575
+ }
576
+ /**
577
+ * Create an HTTP request handler for team coordination routes.
578
+ *
579
+ * Returns `undefined` for unmatched routes (not a team route), allowing
580
+ * the caller to chain with the standard agent HTTP handler.
581
+ */
582
+ declare function createDaprTeamHttpHandler(options: DaprTeamHttpHandlerOptions): (request: Request) => Promise<Response | undefined>;
583
+
584
+ /**
585
+ * Dapr Team Runner
586
+ *
587
+ * High-level composition helper that creates a durable team coordinator
588
+ * with Dapr-backed stores and an HTTP server.
589
+ *
590
+ * Organized into three files:
591
+ * - `team-runner-types.ts` — Options, interfaces
592
+ * - `team-runner-http.ts` — HTTP helpers (Request/Response bridge, health routes)
593
+ * - `team-runner.ts` (this file) — Factory function
594
+ */
595
+
596
+ /**
597
+ * Create a Dapr-backed team runner.
598
+ *
599
+ * @example
600
+ * ```ts
601
+ * const runner = createDaprTeamRunner({
602
+ * lead: agent,
603
+ * leadSessionId: "main",
604
+ * roles: [researcherRole, writerRole, reviewerRole],
605
+ * });
606
+ *
607
+ * await runner.serve({ port: 3000 });
608
+ * ```
609
+ */
610
+ declare function createDaprTeamRunner(options: DaprTeamRunnerOptions): DaprTeamRunner;
611
+
612
+ export { type AppliedCoordinatorActionsResult, type ApplyCoordinatorActionsActivityOptions, type ApplyCoordinatorActionsInput, type CheckTrackedTasksTerminalActivityOptions, type CheckTrackedTasksTerminalInput, type CollectWorkerReportsActivityOptions, type CollectWorkerReportsInput, type CollectedWorkerReportsResult, type CommitExternalTaskActivityOptions, type CommitExternalTaskInput, type CommittedCoordinatorTaskResult, type CoordinatorAbort, type CoordinatorAssignment, type CoordinatorChildLaunch, type CoordinatorMessage, type CoordinatorReasonActivityInput, type CoordinatorReasonActivityOptions, type CoordinatorReasonResult, type CoordinatorRecordedAction, type CoordinatorTaskNotification, type CoordinatorTrackedTask, type CoordinatorWorkflowActivityNames, type CoordinatorWorkflowContextLike, type CoordinatorWorkflowInput, type CoordinatorWorkflowRegistration, type CoordinatorWorkflowResult, type CoordinatorWorkflowRound, type CoordinatorWorkflowState, type CreateCoordinatorWorkflowOptions, DaprMailboxStore, type DaprMailboxStoreOptions, DaprTaskBoardStore, type DaprTaskBoardStoreOptions, type DaprTeamDispatchOptions, type DaprTeamDurableRunOptions, type DaprTeamDurableRunStartResult, type DaprTeamDurableRunState, type DaprTeamHttpHandlerOptions, type DaprTeamRunner, type DaprTeamRunnerOptions, type DaprTeamServeOptions, type PrepareExternalTasksActivityOptions, type PrepareExternalTasksInput, type PreparedExternalTasksResult, createApplyCoordinatorActionsActivity, createCheckTrackedTasksTerminalActivity, createCollectWorkerReportsActivity, createCommitExternalTaskActivity, createCoordinatorReasonActivity, createCoordinatorWorkflowDefinition, createDaprTeamHttpHandler, createDaprTeamRunner, createPrepareExternalTasksActivity };
@@ -0,0 +1,30 @@
1
+ import {
2
+ DaprMailboxStore,
3
+ DaprTaskBoardStore,
4
+ createApplyCoordinatorActionsActivity,
5
+ createCheckTrackedTasksTerminalActivity,
6
+ createCollectWorkerReportsActivity,
7
+ createCommitExternalTaskActivity,
8
+ createCoordinatorReasonActivity,
9
+ createCoordinatorWorkflowDefinition,
10
+ createDaprTeamHttpHandler,
11
+ createDaprTeamRunner,
12
+ createPrepareExternalTasksActivity
13
+ } from "../chunk-O7H3XGY2.js";
14
+ import "../chunk-YQQTUE6B.js";
15
+ import "../chunk-5CJIC4YB.js";
16
+ import "../chunk-YS2CWYBQ.js";
17
+ import "../chunk-MQJ4LZOX.js";
18
+ export {
19
+ DaprMailboxStore,
20
+ DaprTaskBoardStore,
21
+ createApplyCoordinatorActionsActivity,
22
+ createCheckTrackedTasksTerminalActivity,
23
+ createCollectWorkerReportsActivity,
24
+ createCommitExternalTaskActivity,
25
+ createCoordinatorReasonActivity,
26
+ createCoordinatorWorkflowDefinition,
27
+ createDaprTeamHttpHandler,
28
+ createDaprTeamRunner,
29
+ createPrepareExternalTasksActivity
30
+ };
@@ -0,0 +1,42 @@
1
+ import { D as DaprWorkflowRuntimeRegistrar, a as DaprAgentWorkflowHost } from './workflow-host-D6W6fXoL.js';
2
+
3
+ interface DaprWorkflowWorkerRuntime extends DaprWorkflowRuntimeRegistrar {
4
+ start(): Promise<void>;
5
+ stop(): Promise<void>;
6
+ }
7
+ interface DaprWorkflowWorkerLogger {
8
+ info?(message: string): void;
9
+ warn?(message: string): void;
10
+ error?(message: string): void;
11
+ }
12
+ interface DaprWorkflowWorkerAgentDefinition {
13
+ id: string;
14
+ host: DaprAgentWorkflowHost;
15
+ aliases?: string[];
16
+ description?: string;
17
+ }
18
+ interface DaprWorkflowWorkerOptions {
19
+ runtime: DaprWorkflowWorkerRuntime;
20
+ agents: readonly DaprWorkflowWorkerAgentDefinition[];
21
+ logger?: DaprWorkflowWorkerLogger;
22
+ }
23
+ interface DaprWorkflowWorker {
24
+ readonly runtime: DaprWorkflowWorkerRuntime;
25
+ readonly agents: readonly DaprWorkflowWorkerAgentDefinition[];
26
+ start(): Promise<void>;
27
+ stop(): Promise<void>;
28
+ isRunning(): boolean;
29
+ listAgents(): readonly DaprWorkflowWorkerAgentDefinition[];
30
+ getAgent(idOrAlias: string): DaprWorkflowWorkerAgentDefinition | undefined;
31
+ }
32
+ /**
33
+ * Create a Dapr workflow worker controller around one or more agent hosts.
34
+ *
35
+ * This is the host-process analogue of Diagrid's `runner.start()` path:
36
+ * the worker owns Dapr SDK lifecycle and workflow/activity registration,
37
+ * while each registered host owns the workflow definition for a concrete
38
+ * agent profile.
39
+ */
40
+ declare function createDaprWorkflowWorker(options: DaprWorkflowWorkerOptions): DaprWorkflowWorker;
41
+
42
+ export { type DaprWorkflowWorker as D, type DaprWorkflowWorkerAgentDefinition as a, type DaprWorkflowWorkerLogger as b, type DaprWorkflowWorkerOptions as c, type DaprWorkflowWorkerRuntime as d, createDaprWorkflowWorker as e };