@cuylabs/agent-runtime-dapr 0.5.0 → 0.6.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 CHANGED
@@ -3,6 +3,22 @@
3
3
  Run AI agents with **Dapr durability** — crash-safe workflows, persistent state,
4
4
  and scheduled jobs. Built on `@cuylabs/agent-core` and `@cuylabs/agent-runtime`.
5
5
 
6
+ ## Package Boundary
7
+
8
+ Use `@cuylabs/agent-runtime-dapr` when you want Dapr-backed infrastructure for workloads or agents:
9
+
10
+ - Dapr runtime driver for scheduled and manually triggered jobs
11
+ - durable workflow decomposition for agent turns
12
+ - persistent execution snapshots and checkpoints
13
+ - hosted HTTP runners and multi-agent hosts
14
+ - Dapr service invocation and workflow clients
15
+
16
+ This package does not redefine agent semantics or generic workload orchestration.
17
+ It builds on:
18
+
19
+ - `agent-core` for task and turn execution semantics
20
+ - `agent-runtime` for the outer workload runtime contract
21
+
6
22
  ## Why Dapr?
7
23
 
8
24
  Dapr provides the durable infrastructure while your agent owns the intelligence:
@@ -30,6 +46,13 @@ import { createDaprAgentRunner } from "@cuylabs/agent-runtime-dapr/host";
30
46
  import { DaprWorkflowClient } from "@cuylabs/agent-runtime-dapr/workflow";
31
47
  ```
32
48
 
49
+ Under the hood, this package now exposes two layers:
50
+
51
+ - `createDaprWorkloadRuntime(...)` for any workload that fits the neutral
52
+ `agent-runtime` contract
53
+ - `createDaprAgentRuntime(...)` and `createDaprAgentRunner(...)` as the
54
+ `agent-core`-specific adapters built on top of that
55
+
33
56
  ## Quick Start
34
57
 
35
58
  ### Step 1: Define your agent
@@ -214,6 +237,7 @@ invocation), the package also exports the lower-level building blocks:
214
237
  |--------|---------|
215
238
  | `createDaprAgentWorkflowHost()` | Wrap an Agent into a workflow host |
216
239
  | `createDaprWorkflowWorker()` | Register workflow hosts in a WorkflowRuntime |
240
+ | `createDaprWorkloadRuntime()` | Dapr-backed runtime bundle for generic workloads |
217
241
  | `createDaprAgentRuntime()` | Create runtime bundle (scheduling + runner + store) |
218
242
  | `startDaprHostHttpServer()` | Start the HTTP control surface |
219
243
  | `DaprWorkflowClient` | Manage workflow instances via HTTP API |
@@ -230,6 +254,32 @@ See the [docs/](docs/) folder for detailed guides:
230
254
  - [API Reference](docs/api-reference.md) — all exported types and functions
231
255
  - [Advanced Patterns](docs/advanced-patterns.md) — cross-service invocation, custom observers, etc.
232
256
 
257
+ ## Runtime Boundary
258
+
259
+ The package layering is:
260
+
261
+ - `agent-core`: agent turn/task semantics
262
+ - `agent-runtime`: generic workload orchestration contract
263
+ - `agent-runtime-dapr`: Dapr-backed implementation of that contract
264
+
265
+ `agent-runtime-dapr` integrates with those lower layers in two different ways:
266
+
267
+ - outer workload path: it uses `agent-runtime` to schedule, dispatch, retry,
268
+ and observe jobs
269
+ - inner durable turn path: it uses `agent-core` runtime primitives to split one
270
+ agent turn into durable workflow activities such as `model-step`,
271
+ `tool-call`, `step-commit`, and `output-commit`
272
+
273
+ So this package does not only sit "on top of" `agent-runtime`. It also reaches
274
+ into the reusable turn/task surface exported by `agent-core` when it needs
275
+ fine-grained durable execution.
276
+
277
+ If you are running ordinary jobs or non-agent workloads, use
278
+ `createDaprWorkloadRuntime(...)`.
279
+
280
+ If you are running `agent-core` tasks, use `createDaprAgentRuntime(...)` or the
281
+ higher-level `createDaprAgentRunner(...)`.
282
+
233
283
  ## Examples
234
284
 
235
285
  The [`examples/`](examples/) directory has complete, runnable scripts:
@@ -1092,14 +1092,9 @@ import {
1092
1092
  createAgentTaskRunner
1093
1093
  } from "@cuylabs/agent-core";
1094
1094
  import {
1095
- createAgentRuntime
1095
+ createWorkloadRuntime,
1096
+ createRuntimeWorkloadExecutor
1096
1097
  } from "@cuylabs/agent-runtime";
1097
- function toErrorMessage(error) {
1098
- if (error instanceof Error && error.message) {
1099
- return error.message;
1100
- }
1101
- return String(error);
1102
- }
1103
1098
  function createExecutionContext(jobId, runtimeContext) {
1104
1099
  return {
1105
1100
  signal: runtimeContext.signal,
@@ -1139,45 +1134,53 @@ function resolveExecutionStore(options) {
1139
1134
  ...options.executionStoreOptions
1140
1135
  });
1141
1136
  }
1142
- function createExecutor(runTask, options) {
1143
- return async (job, runtimeContext) => {
1144
- try {
1145
- const result = await runTask(
1146
- job.payload,
1147
- createExecutionContext(job.id, runtimeContext)
1148
- );
1149
- if (options.onTaskResult) {
1150
- await options.onTaskResult({
1151
- jobId: job.id,
1152
- payload: job.payload,
1153
- runtimeContext,
1154
- result
1155
- });
1156
- }
1157
- return { status: "ok" };
1158
- } catch (error) {
1159
- const message = toErrorMessage(error);
1160
- if (options.onTaskError) {
1161
- try {
1162
- await options.onTaskError({
1137
+ function createAgentWorkloadRunner(runTask) {
1138
+ return async (payload, runtimeContext) => {
1139
+ return await runTask(
1140
+ payload,
1141
+ createExecutionContext(runtimeContext.jobId, runtimeContext)
1142
+ );
1143
+ };
1144
+ }
1145
+ function createDaprWorkloadRuntime(options) {
1146
+ const driver = new DaprRuntimeDriver(options.driver);
1147
+ const runtime = createWorkloadRuntime({
1148
+ ...options.runtime,
1149
+ driver,
1150
+ execute: createRuntimeWorkloadExecutor({
1151
+ run: options.runWorkload,
1152
+ ...options.onWorkloadResult ? {
1153
+ onResult: async ({ job, context, result }) => {
1154
+ await options.onWorkloadResult?.({
1163
1155
  jobId: job.id,
1164
1156
  payload: job.payload,
1165
- runtimeContext,
1157
+ runtimeContext: context,
1158
+ result
1159
+ });
1160
+ }
1161
+ } : {},
1162
+ ...options.onWorkloadError ? {
1163
+ onError: async ({ job, context, error, message }) => {
1164
+ await options.onWorkloadError?.({
1165
+ jobId: job.id,
1166
+ payload: job.payload,
1167
+ runtimeContext: context,
1166
1168
  error,
1167
1169
  message
1168
1170
  });
1169
- } catch {
1170
1171
  }
1171
- }
1172
- return {
1173
- status: "error",
1174
- error: message
1175
- };
1176
- }
1172
+ } : {}
1173
+ })
1174
+ });
1175
+ const handleDaprJob = createDaprHttpJobHandler({ driver });
1176
+ return {
1177
+ runtime,
1178
+ driver,
1179
+ runWorkload: options.runWorkload,
1180
+ handleDaprJob
1177
1181
  };
1178
1182
  }
1179
1183
  function createDaprAgentRuntime(options) {
1180
- const driver = new DaprRuntimeDriver(options.driver);
1181
1184
  const executionStore = resolveExecutionStore(options);
1182
1185
  if (options.taskRunner && executionStore) {
1183
1186
  throw new Error(
@@ -1189,18 +1192,26 @@ function createDaprAgentRuntime(options) {
1189
1192
  options.agent,
1190
1193
  buildTaskRunnerOptions(options, executionObserver)
1191
1194
  );
1192
- const runtime = createAgentRuntime({
1193
- ...options.runtime,
1194
- driver,
1195
- execute: createExecutor(runTask, options)
1195
+ const runWorkload = createAgentWorkloadRunner(runTask);
1196
+ const bundle = createDaprWorkloadRuntime({
1197
+ driver: options.driver,
1198
+ runtime: options.runtime,
1199
+ runWorkload,
1200
+ ...options.onTaskResult ? {
1201
+ onWorkloadResult: async (context) => {
1202
+ await options.onTaskResult?.(context);
1203
+ }
1204
+ } : {},
1205
+ ...options.onTaskError ? {
1206
+ onWorkloadError: async (context) => {
1207
+ await options.onTaskError?.(context);
1208
+ }
1209
+ } : {}
1196
1210
  });
1197
- const handleDaprJob = createDaprHttpJobHandler({ driver });
1198
1211
  return {
1199
- runtime,
1200
- driver,
1212
+ ...bundle,
1201
1213
  runTask,
1202
- executionStore,
1203
- handleDaprJob
1214
+ executionStore
1204
1215
  };
1205
1216
  }
1206
1217
 
@@ -1222,7 +1233,7 @@ function json(value, status = 200) {
1222
1233
  function text(message, status = 200) {
1223
1234
  return new Response(message, { status });
1224
1235
  }
1225
- function toErrorMessage2(error) {
1236
+ function toErrorMessage(error) {
1226
1237
  if (error instanceof Error && error.message) {
1227
1238
  return error.message;
1228
1239
  }
@@ -1390,7 +1401,7 @@ function createDaprHostHttpHandler(options) {
1390
1401
  );
1391
1402
  return json(result);
1392
1403
  } catch (error) {
1393
- return json({ error: toErrorMessage2(error) }, 404);
1404
+ return json({ error: toErrorMessage(error) }, 404);
1394
1405
  }
1395
1406
  }
1396
1407
  if (request.method === "POST" && segments.length === 2 && segments[0] === "agents" && segments[1] === "workflow") {
@@ -1423,7 +1434,7 @@ function createDaprHostHttpHandler(options) {
1423
1434
  sessionId: result.sessionId
1424
1435
  }, 202);
1425
1436
  } catch (error) {
1426
- return json({ error: toErrorMessage2(error) }, 500);
1437
+ return json({ error: toErrorMessage(error) }, 500);
1427
1438
  }
1428
1439
  }
1429
1440
  if (segments[0] === "agents" && segments.length >= 2) {
@@ -1453,7 +1464,7 @@ function createDaprHostHttpHandler(options) {
1453
1464
  sessionId: result.sessionId
1454
1465
  }, 202);
1455
1466
  } catch (error) {
1456
- return json({ error: toErrorMessage2(error) }, 500);
1467
+ return json({ error: toErrorMessage(error) }, 500);
1457
1468
  }
1458
1469
  }
1459
1470
  if (request.method === "GET" && segments.length === 4 && segments[2] === "executions") {
@@ -1477,7 +1488,7 @@ async function startDaprHostHttpServer(options) {
1477
1488
  const response = await handler(request);
1478
1489
  await writeResponse(response, res);
1479
1490
  } catch (error) {
1480
- await writeResponse(json({ error: toErrorMessage2(error) }, 500), res);
1491
+ await writeResponse(json({ error: toErrorMessage(error) }, 500), res);
1481
1492
  }
1482
1493
  });
1483
1494
  await new Promise((resolve, reject) => {
@@ -1533,7 +1544,7 @@ function buildObservers(options) {
1533
1544
  }
1534
1545
  return observers;
1535
1546
  }
1536
- function toErrorMessage3(error) {
1547
+ function toErrorMessage2(error) {
1537
1548
  if (error instanceof Error && error.message) {
1538
1549
  return error.message;
1539
1550
  }
@@ -1579,7 +1590,7 @@ async function collectSingleRunnerReadiness(params) {
1579
1590
  checks.push({
1580
1591
  name: "dapr-sidecar",
1581
1592
  ok: false,
1582
- detail: toErrorMessage3(error)
1593
+ detail: toErrorMessage2(error)
1583
1594
  });
1584
1595
  }
1585
1596
  try {
@@ -1589,7 +1600,7 @@ async function collectSingleRunnerReadiness(params) {
1589
1600
  checks.push({
1590
1601
  name: "state-store",
1591
1602
  ok: false,
1592
- detail: toErrorMessage3(error)
1603
+ detail: toErrorMessage2(error)
1593
1604
  });
1594
1605
  }
1595
1606
  return {
@@ -1865,7 +1876,7 @@ function createDaprMultiAgentRunner(options) {
1865
1876
  checks.push({
1866
1877
  name: "dapr-sidecar",
1867
1878
  ok: false,
1868
- detail: toErrorMessage3(error)
1879
+ detail: toErrorMessage2(error)
1869
1880
  });
1870
1881
  }
1871
1882
  try {
@@ -1875,7 +1886,7 @@ function createDaprMultiAgentRunner(options) {
1875
1886
  checks.push({
1876
1887
  name: "state-store",
1877
1888
  ok: false,
1878
- detail: toErrorMessage3(error)
1889
+ detail: toErrorMessage2(error)
1879
1890
  });
1880
1891
  }
1881
1892
  return {
@@ -1989,6 +2000,7 @@ export {
1989
2000
  createDaprAgentWorkflowHost,
1990
2001
  startDaprAgentWorkflowTurn,
1991
2002
  createDaprWorkflowWorker,
2003
+ createDaprWorkloadRuntime,
1992
2004
  createDaprAgentRuntime,
1993
2005
  createDaprHostHttpHandler,
1994
2006
  startDaprHostHttpServer,
@@ -1,4 +1,4 @@
1
- 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, u as DaprInvokeMethodOptions, v as DaprInvokeMethodResult, x as DaprMultiAgentRunner, y as DaprMultiAgentRunnerAgentConfig, z as DaprMultiAgentRunnerOptions, 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, S as createDaprMultiAgentRunner, T as createDaprWorkflowWorker, U as invokeRemoteAgentRun, V as startDaprAgentWorkflowTurn, W as startDaprHostHttpServer } from '../index-CKTP36vE.js';
1
+ 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, u as DaprInvokeMethodOptions, v as DaprInvokeMethodResult, x as DaprMultiAgentRunner, y as DaprMultiAgentRunnerAgentConfig, z as DaprMultiAgentRunnerOptions, 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, L as DaprWorkloadErrorContext, M as DaprWorkloadResultContext, N as DaprWorkloadRuntimeBundle, O as DaprWorkloadRuntimeOptions, R as RemoteAgentRunRequest, P as RemoteAgentRunResponse, Q as createDaprAgentRunner, S as createDaprAgentRuntime, T as createDaprAgentWorkflowHost, U as createDaprHostHttpHandler, W as createDaprMultiAgentRunner, X as createDaprWorkflowWorker, Y as createDaprWorkloadRuntime, Z as invokeRemoteAgentRun, _ as startDaprAgentWorkflowTurn, $ as startDaprHostHttpServer } from '../index-nZvCz3bO.js';
2
2
  import '@cuylabs/agent-core';
3
3
  import '../store-pRLGfYhN.js';
4
4
  import '../workflow-bridge-C8Z1yr0Y.js';
@@ -6,10 +6,11 @@ import {
6
6
  createDaprHostHttpHandler,
7
7
  createDaprMultiAgentRunner,
8
8
  createDaprWorkflowWorker,
9
+ createDaprWorkloadRuntime,
9
10
  invokeRemoteAgentRun,
10
11
  startDaprAgentWorkflowTurn,
11
12
  startDaprHostHttpServer
12
- } from "../chunk-2FMHOZLU.js";
13
+ } from "../chunk-R47X4FG2.js";
13
14
  import "../chunk-2CEICSJH.js";
14
15
  import "../chunk-DILON56B.js";
15
16
  import "../chunk-A34CHK2E.js";
@@ -21,6 +22,7 @@ export {
21
22
  createDaprHostHttpHandler,
22
23
  createDaprMultiAgentRunner,
23
24
  createDaprWorkflowWorker,
25
+ createDaprWorkloadRuntime,
24
26
  invokeRemoteAgentRun,
25
27
  startDaprAgentWorkflowTurn,
26
28
  startDaprHostHttpServer
@@ -1,7 +1,7 @@
1
1
  import { AgentWorkflowTurnState, Agent, AgentTaskObserver, AgentTaskPayload, AgentTaskResult, AgentTaskRunner, AgentTaskRunnerOptions } from '@cuylabs/agent-core';
2
2
  import { h as DaprExecutionStore } from './store-pRLGfYhN.js';
3
3
  import { DaprAgentTurnWorkflowActivityNames, DaprAgentTurnWorkflowDefinition, StartDaprWorkflowOptions, DaprStartWorkflowResponse, CreateDaprAgentTurnWorkflowKitOptions, DaprWorkflowClient } from './workflow/index.js';
4
- import { RuntimeDriver, RuntimeDriverContext, RuntimeJobRecord, AgentRuntime, AgentRuntimeOptions, RuntimeExecutionContext } from '@cuylabs/agent-runtime';
4
+ import { RuntimeDriver, RuntimeDriverContext, RuntimeJobRecord, WorkloadRuntime, RuntimeWorkloadRunner, WorkloadRuntimeOptions, RuntimeWorkloadContext } from '@cuylabs/agent-runtime';
5
5
  import { c as DaprRuntimeDriverOptions, a as DaprExecutionStoreOptions } from './workflow-bridge-C8Z1yr0Y.js';
6
6
  import { Server } from 'node:http';
7
7
 
@@ -228,29 +228,53 @@ interface DaprWorkflowWorker {
228
228
  */
229
229
  declare function createDaprWorkflowWorker(options: DaprWorkflowWorkerOptions): DaprWorkflowWorker;
230
230
 
231
- interface DaprAgentTaskResultContext<TPayload extends AgentTaskPayload = AgentTaskPayload> {
231
+ interface DaprWorkloadResultContext<TPayload = unknown, TResult = unknown> {
232
232
  jobId: string;
233
233
  payload: TPayload;
234
- runtimeContext: RuntimeExecutionContext;
235
- result: AgentTaskResult;
234
+ runtimeContext: RuntimeWorkloadContext;
235
+ result: TResult;
236
236
  }
237
- interface DaprAgentTaskErrorContext<TPayload extends AgentTaskPayload = AgentTaskPayload> {
237
+ interface DaprWorkloadErrorContext<TPayload = unknown> {
238
238
  jobId: string;
239
239
  payload: TPayload;
240
- runtimeContext: RuntimeExecutionContext;
240
+ runtimeContext: RuntimeWorkloadContext;
241
241
  error: unknown;
242
242
  message: string;
243
243
  }
244
- interface DaprAgentRuntimeOptions<TPayload extends AgentTaskPayload = AgentTaskPayload> {
245
- /** Agent instance used for job execution. */
246
- agent: Agent;
244
+ interface DaprWorkloadRuntimeOptions<TPayload = unknown, TResult = unknown> {
247
245
  /** Dapr driver configuration (sidecar + state store + retries). */
248
246
  driver: DaprRuntimeDriverOptions;
249
247
  /**
250
248
  * Optional runtime options excluding driver and execute.
251
249
  * Use this to set concurrency/timeouts/logging behavior.
252
250
  */
253
- runtime?: Omit<AgentRuntimeOptions<TPayload>, "driver" | "execute">;
251
+ runtime?: Omit<WorkloadRuntimeOptions<TPayload>, "driver" | "execute">;
252
+ /**
253
+ * Domain workload executed for each scheduled or manually triggered job.
254
+ *
255
+ * This is the neutral seam between `agent-runtime` orchestration and
256
+ * application-specific work. `agent-core` task runners can plug in here,
257
+ * but so can any other job/workload adapter.
258
+ */
259
+ runWorkload: RuntimeWorkloadRunner<TPayload, TResult>;
260
+ /** Optional hook invoked after successful workload execution. */
261
+ onWorkloadResult?: (context: DaprWorkloadResultContext<TPayload, TResult>) => void | Promise<void>;
262
+ /** Optional hook invoked when workload execution fails. */
263
+ onWorkloadError?: (context: DaprWorkloadErrorContext<TPayload>) => void | Promise<void>;
264
+ }
265
+ interface DaprWorkloadRuntimeBundle<TPayload = unknown, TResult = unknown> {
266
+ runtime: WorkloadRuntime<TPayload>;
267
+ driver: DaprRuntimeDriver<TPayload>;
268
+ runWorkload: RuntimeWorkloadRunner<TPayload, TResult>;
269
+ handleDaprJob: (jobName: string) => Promise<DaprHttpJobHandlerResult>;
270
+ }
271
+ interface DaprAgentTaskResultContext<TPayload extends AgentTaskPayload = AgentTaskPayload> extends DaprWorkloadResultContext<TPayload, AgentTaskResult> {
272
+ }
273
+ interface DaprAgentTaskErrorContext<TPayload extends AgentTaskPayload = AgentTaskPayload> extends DaprWorkloadErrorContext<TPayload> {
274
+ }
275
+ interface DaprAgentRuntimeOptions<TPayload extends AgentTaskPayload = AgentTaskPayload> extends Omit<DaprWorkloadRuntimeOptions<TPayload, AgentTaskResult>, "runWorkload" | "onWorkloadResult" | "onWorkloadError"> {
276
+ /** Agent instance used for job execution. */
277
+ agent: Agent;
254
278
  /**
255
279
  * Optional explicit task runner. If omitted, one is created with
256
280
  * createAgentTaskRunner(agent, taskRunnerOptions).
@@ -281,21 +305,28 @@ interface DaprAgentRuntimeOptions<TPayload extends AgentTaskPayload = AgentTaskP
281
305
  /** Optional hook invoked when task execution fails. */
282
306
  onTaskError?: (context: DaprAgentTaskErrorContext<TPayload>) => void | Promise<void>;
283
307
  }
284
- interface DaprAgentRuntimeBundle<TPayload extends AgentTaskPayload = AgentTaskPayload> {
285
- runtime: AgentRuntime<TPayload>;
286
- driver: DaprRuntimeDriver<TPayload>;
308
+ interface DaprAgentRuntimeBundle<TPayload extends AgentTaskPayload = AgentTaskPayload> extends DaprWorkloadRuntimeBundle<TPayload, AgentTaskResult> {
287
309
  runTask: AgentTaskRunner<TPayload>;
288
310
  executionStore?: DaprExecutionStore<TPayload>;
289
- handleDaprJob: (jobName: string) => Promise<DaprHttpJobHandlerResult>;
290
311
  }
291
312
  /**
292
- * Create a Dapr-backed runtime bundle for executing agent tasks.
313
+ * Create a Dapr-backed runtime bundle for generic application workloads.
314
+ *
315
+ * This is the neutral Dapr implementation of the `agent-runtime` workload
316
+ * contract. Agent-specific helpers in this package are built on top of this.
317
+ */
318
+ declare function createDaprWorkloadRuntime<TPayload = unknown, TResult = unknown>(options: DaprWorkloadRuntimeOptions<TPayload, TResult>): DaprWorkloadRuntimeBundle<TPayload, TResult>;
319
+ /**
320
+ * Create a Dapr-backed runtime bundle for executing `agent-core` task
321
+ * workloads. This is a thin agent-specific wrapper over
322
+ * `createDaprWorkloadRuntime(...)`.
323
+ *
324
+ * This is the outer integration seam:
325
+ * - `createAgentTaskRunner(...)` adapts an `Agent` into a workload-shaped task
326
+ * - `createDaprWorkloadRuntime(...)` lets `agent-runtime` schedule and dispatch it
293
327
  *
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
328
+ * Durable workflow decomposition is handled separately by the workflow host
329
+ * and `workflow/runtime.ts`.
299
330
  */
300
331
  declare function createDaprAgentRuntime<TPayload extends AgentTaskPayload = AgentTaskPayload>(options: DaprAgentRuntimeOptions<TPayload>): DaprAgentRuntimeBundle<TPayload>;
301
332
 
@@ -424,7 +455,7 @@ interface DaprAgentRunner {
424
455
  readonly name: string;
425
456
  /** The underlying workflow host. */
426
457
  readonly workflowHost: DaprAgentWorkflowHost;
427
- /** The underlying runtime bundle (scheduling, task runner, execution store). */
458
+ /** The underlying runtime bundle (scheduling, workload adapter, execution store). */
428
459
  readonly runtimeBundle: DaprAgentRuntimeBundle;
429
460
  /** The underlying workflow worker. */
430
461
  readonly worker: DaprWorkflowWorker;
@@ -458,7 +489,7 @@ interface DaprAgentRunner {
458
489
  *
459
490
  * Equivalent to Diagrid's `DaprWorkflowAgentRunner`. Internally creates:
460
491
  * - Workflow host (Dapr workflow registration + turn state management)
461
- * - Runtime bundle (scheduling + task runner + execution store)
492
+ * - Runtime bundle (scheduling + workload adapter + execution store)
462
493
  * - Workflow worker (gRPC worker for Dapr workflow engine)
463
494
  * - Workflow client (HTTP client for managing workflow instances)
464
495
  * - HTTP server (on `serve()`)
@@ -530,4 +561,4 @@ interface DaprMultiAgentRunner {
530
561
  */
531
562
  declare function createDaprMultiAgentRunner(options: DaprMultiAgentRunnerOptions): DaprMultiAgentRunner;
532
563
 
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 };
564
+ export { startDaprHostHttpServer as $, 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 DaprWorkloadErrorContext as L, type DaprWorkloadResultContext as M, type DaprWorkloadRuntimeBundle as N, type DaprWorkloadRuntimeOptions as O, type RemoteAgentRunResponse as P, createDaprAgentRunner as Q, type RemoteAgentRunRequest as R, createDaprAgentRuntime as S, createDaprAgentWorkflowHost as T, createDaprHostHttpHandler as U, createDaprHttpJobHandler as V, createDaprMultiAgentRunner as W, createDaprWorkflowWorker as X, createDaprWorkloadRuntime as Y, invokeRemoteAgentRun as Z, startDaprAgentWorkflowTurn as _, 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 };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { D as DaprOrchestratorRunStoreOptions } from './workflow-bridge-C8Z1yr0Y.js';
2
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
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';
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, L as DaprWorkloadErrorContext, M as DaprWorkloadResultContext, N as DaprWorkloadRuntimeBundle, O as DaprWorkloadRuntimeOptions, R as RemoteAgentRunRequest, P as RemoteAgentRunResponse, Q as createDaprAgentRunner, S as createDaprAgentRuntime, T as createDaprAgentWorkflowHost, U as createDaprHostHttpHandler, V as createDaprHttpJobHandler, W as createDaprMultiAgentRunner, X as createDaprWorkflowWorker, Y as createDaprWorkloadRuntime, Z as invokeRemoteAgentRun, _ as startDaprAgentWorkflowTurn, $ as startDaprHostHttpServer } from './index-nZvCz3bO.js';
5
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
6
  export { DaprExecutionObserver, DaprExecutionObserverOptions, DaprHostLoggerLike, DaprLoggingObserverOptions, OtelObserverConfig, createDaprExecutionObserver, createDaprLoggingObserver, createOtelObserver } from './execution/index.js';
7
7
  import { OrchestratorRunStatus, OrchestratorRunStore, OrchestratorRunRecord } from '@cuylabs/agent-runtime';
package/dist/index.js CHANGED
@@ -9,10 +9,11 @@ import {
9
9
  createDaprHttpJobHandler,
10
10
  createDaprMultiAgentRunner,
11
11
  createDaprWorkflowWorker,
12
+ createDaprWorkloadRuntime,
12
13
  invokeRemoteAgentRun,
13
14
  startDaprAgentWorkflowTurn,
14
15
  startDaprHostHttpServer
15
- } from "./chunk-2FMHOZLU.js";
16
+ } from "./chunk-R47X4FG2.js";
16
17
  import {
17
18
  DaprExecutionObserver,
18
19
  DaprExecutionStore,
@@ -55,6 +56,7 @@ export {
55
56
  createDaprLoggingObserver,
56
57
  createDaprMultiAgentRunner,
57
58
  createDaprWorkflowWorker,
59
+ createDaprWorkloadRuntime,
58
60
  createOtelObserver,
59
61
  createWorkflowObserverBridge,
60
62
  hasStartedDaprWorkflow,
@@ -62,6 +62,15 @@ interface DaprStartWorkflowResponse {
62
62
  declare function isTerminalDaprWorkflowStatus(status: DaprWorkflowRuntimeStatus): boolean;
63
63
  declare function hasStartedDaprWorkflow(status: DaprWorkflowRuntimeStatus): boolean;
64
64
 
65
+ /**
66
+ * Durable workflow execution for agent turns.
67
+ *
68
+ * This is the inner integration seam between `agent-runtime-dapr` and
69
+ * `agent-core`: instead of scheduling a whole task as one opaque unit, the
70
+ * workflow reuses `agent-core` turn primitives to run model, tool, and commit
71
+ * phases as separate durable activities.
72
+ */
73
+
65
74
  interface DaprAgentTurnWorkflowActivityNames {
66
75
  modelStep: string;
67
76
  toolCall: string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cuylabs/agent-runtime-dapr",
3
- "version": "0.5.0",
4
- "description": "Dapr-backed runtime driver for @cuylabs/agent-runtime",
3
+ "version": "0.6.0",
4
+ "description": "Dapr-backed workload runtime and host adapters for @cuylabs/agent-runtime",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",
@@ -32,8 +32,8 @@
32
32
  "README.md"
33
33
  ],
34
34
  "dependencies": {
35
- "@cuylabs/agent-core": "^0.5.0",
36
- "@cuylabs/agent-runtime": "^0.5.0"
35
+ "@cuylabs/agent-core": "^0.6.0",
36
+ "@cuylabs/agent-runtime": "^0.6.0"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "@dapr/dapr": "^3.6.1",
@@ -65,7 +65,7 @@
65
65
  "typescript": "^5.7.0",
66
66
  "vitest": "^4.0.18",
67
67
  "zod": "^3.24.0",
68
- "@cuylabs/agent-code": "^0.5.0"
68
+ "@cuylabs/agent-code": "^0.6.0"
69
69
  },
70
70
  "keywords": [
71
71
  "agent",