@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.
- package/LICENSE +201 -0
- package/README.md +260 -0
- package/dist/chunk-2CEICSJH.js +809 -0
- package/dist/chunk-2FMHOZLU.js +1997 -0
- package/dist/chunk-A34CHK2E.js +283 -0
- package/dist/chunk-DILON56B.js +668 -0
- package/dist/execution/index.d.ts +126 -0
- package/dist/execution/index.js +17 -0
- package/dist/host/index.d.ts +7 -0
- package/dist/host/index.js +27 -0
- package/dist/index-CKTP36vE.d.ts +533 -0
- package/dist/index.d.ts +47 -0
- package/dist/index.js +65 -0
- package/dist/store-pRLGfYhN.d.ts +97 -0
- package/dist/workflow/index.d.ts +216 -0
- package/dist/workflow/index.js +23 -0
- package/dist/workflow-bridge-C8Z1yr0Y.d.ts +83 -0
- package/package.json +99 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { h as DaprExecutionStore } from '../store-pRLGfYhN.js';
|
|
2
|
+
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 } from '../store-pRLGfYhN.js';
|
|
3
|
+
import { AgentTaskPayload, AgentTaskObserver, AgentTaskExecutionRun, AgentTaskExecutionSnapshot, AgentTaskExecutionCheckpoint, AgentTaskResult } from '@cuylabs/agent-core';
|
|
4
|
+
export { f as DaprWorkflowObserverBridge, g as DaprWorkflowObserverOptions, h as createWorkflowObserverBridge } from '../workflow-bridge-C8Z1yr0Y.js';
|
|
5
|
+
|
|
6
|
+
interface DaprExecutionObserverOptions<TPayload extends AgentTaskPayload = AgentTaskPayload> {
|
|
7
|
+
/**
|
|
8
|
+
* Store used to persist durable execution snapshots and checkpoints.
|
|
9
|
+
*
|
|
10
|
+
* The observer itself is intentionally thin. Persistence policy lives in the
|
|
11
|
+
* store so host apps can inspect execution state independently of runtime
|
|
12
|
+
* scheduling or orchestration concerns.
|
|
13
|
+
*/
|
|
14
|
+
store: DaprExecutionStore<TPayload>;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Dapr-backed execution observer for `createAgentTaskRunner(...)`.
|
|
18
|
+
*
|
|
19
|
+
* This adapter consumes the neutral lifecycle/checkpoint hooks exported by
|
|
20
|
+
* `@cuylabs/agent-core` and persists them into Dapr state without leaking any
|
|
21
|
+
* Dapr-specific dependency back into `agent-core`.
|
|
22
|
+
*/
|
|
23
|
+
declare class DaprExecutionObserver<TPayload extends AgentTaskPayload = AgentTaskPayload> implements AgentTaskObserver<TPayload> {
|
|
24
|
+
private readonly store;
|
|
25
|
+
constructor(options: DaprExecutionObserverOptions<TPayload>);
|
|
26
|
+
onTaskStart(run: AgentTaskExecutionRun<TPayload>, snapshot: AgentTaskExecutionSnapshot): Promise<void>;
|
|
27
|
+
onCheckpoint(checkpoint: AgentTaskExecutionCheckpoint<TPayload>): Promise<void>;
|
|
28
|
+
onTaskComplete(run: AgentTaskExecutionRun<TPayload>, result: AgentTaskResult, snapshot: AgentTaskExecutionSnapshot): Promise<void>;
|
|
29
|
+
onTaskError(run: AgentTaskExecutionRun<TPayload>, error: Error, snapshot: AgentTaskExecutionSnapshot): Promise<void>;
|
|
30
|
+
}
|
|
31
|
+
declare function createDaprExecutionObserver<TPayload extends AgentTaskPayload = AgentTaskPayload>(options: DaprExecutionObserverOptions<TPayload>): DaprExecutionObserver<TPayload>;
|
|
32
|
+
|
|
33
|
+
interface DaprHostLoggerLike {
|
|
34
|
+
info(message: string): void;
|
|
35
|
+
warn?(message: string): void;
|
|
36
|
+
error?(message: string): void;
|
|
37
|
+
}
|
|
38
|
+
interface DaprLoggingObserverOptions {
|
|
39
|
+
/** Logger instance. Defaults to console. */
|
|
40
|
+
logger?: DaprHostLoggerLike;
|
|
41
|
+
/** Prefix for all log lines. Defaults to "[agent]". */
|
|
42
|
+
prefix?: string;
|
|
43
|
+
/**
|
|
44
|
+
* Log every streamed event (very verbose).
|
|
45
|
+
* Defaults to false — only lifecycle events are logged.
|
|
46
|
+
*/
|
|
47
|
+
verbose?: boolean;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* A lightweight observer that logs agent task lifecycle events.
|
|
51
|
+
*
|
|
52
|
+
* Wire it into `createDaprAgentRuntime({ taskRunnerOptions: { observers: [...] } })`
|
|
53
|
+
* or pass it directly.
|
|
54
|
+
*/
|
|
55
|
+
declare function createDaprLoggingObserver<TPayload extends AgentTaskPayload = AgentTaskPayload>(options?: DaprLoggingObserverOptions): AgentTaskObserver<TPayload>;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* OpenTelemetry Observer
|
|
59
|
+
*
|
|
60
|
+
* Creates spans for Dapr workflow activities so that the full agent
|
|
61
|
+
* execution — from workflow orchestration down to individual LLM calls
|
|
62
|
+
* — appears as a single correlated trace.
|
|
63
|
+
*
|
|
64
|
+
* Uses `@opentelemetry/api` directly (the standard approach).
|
|
65
|
+
* If no TracerProvider is registered, all spans are no-ops.
|
|
66
|
+
*
|
|
67
|
+
* Span hierarchy (direct execution — /agents/run or runner.run()):
|
|
68
|
+
* ```
|
|
69
|
+
* agent.turn ← this observer
|
|
70
|
+
* └─ invoke_agent my-agent ← otelMiddleware (via activateContext)
|
|
71
|
+
* └─ ai.streamText ← AI SDK
|
|
72
|
+
* └─ execute_tool greet ← otelMiddleware
|
|
73
|
+
* ```
|
|
74
|
+
*
|
|
75
|
+
* Span hierarchy (workflow execution — /agents/workflow):
|
|
76
|
+
* ```
|
|
77
|
+
* agent.turn ← this observer
|
|
78
|
+
* └─ invoke_agent my-agent ← otelMiddleware (via runChatStart/End)
|
|
79
|
+
* └─ ai.streamText ← AI SDK
|
|
80
|
+
* └─ ai.toolCall ← AI SDK
|
|
81
|
+
* └─ execute_tool greet ← otelMiddleware (via beforeToolCall)
|
|
82
|
+
* └─ invoke_agent my-agent ← otelMiddleware (step 2)
|
|
83
|
+
* └─ ai.streamText ← AI SDK
|
|
84
|
+
* ```
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```typescript
|
|
88
|
+
* import { createDaprAgentRunner, createOtelObserver } from "@cuylabs/agent-runtime-dapr";
|
|
89
|
+
*
|
|
90
|
+
* const runner = createDaprAgentRunner({
|
|
91
|
+
* agent,
|
|
92
|
+
* name: "my-agent",
|
|
93
|
+
* workflowRuntime: new WorkflowRuntime(),
|
|
94
|
+
* observers: [createOtelObserver()],
|
|
95
|
+
* });
|
|
96
|
+
* ```
|
|
97
|
+
*
|
|
98
|
+
* Requires `@opentelemetry/api` as a peer dependency.
|
|
99
|
+
*/
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Configuration for the OpenTelemetry observer.
|
|
103
|
+
*/
|
|
104
|
+
interface OtelObserverConfig {
|
|
105
|
+
/**
|
|
106
|
+
* Agent name — recorded as `gen_ai.agent.name` on the `agent.turn` span.
|
|
107
|
+
* Required for Phoenix/OpenInference to classify the span as AGENT kind.
|
|
108
|
+
*/
|
|
109
|
+
agentName?: string;
|
|
110
|
+
/**
|
|
111
|
+
* TTL in milliseconds for orphaned spans.
|
|
112
|
+
* If `onTaskComplete`/`onTaskError` is never called, the span is
|
|
113
|
+
* auto-closed after this duration. Defaults to 5 minutes.
|
|
114
|
+
*/
|
|
115
|
+
spanTimeoutMs?: number;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Create an OpenTelemetry observer for Dapr agent workflow execution.
|
|
119
|
+
*
|
|
120
|
+
* Emits an `agent.turn` span per agent turn with checkpoint events
|
|
121
|
+
* and `gen_ai.usage.*` token attributes. Pair with `otelMiddleware()`
|
|
122
|
+
* from agent-core for full trace correlation.
|
|
123
|
+
*/
|
|
124
|
+
declare function createOtelObserver(config?: OtelObserverConfig): AgentTaskObserver;
|
|
125
|
+
|
|
126
|
+
export { DaprExecutionObserver, type DaprExecutionObserverOptions, DaprExecutionStore, type DaprHostLoggerLike, type DaprLoggingObserverOptions, type OtelObserverConfig, createDaprExecutionObserver, createDaprLoggingObserver, createOtelObserver };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DaprExecutionObserver,
|
|
3
|
+
DaprExecutionStore,
|
|
4
|
+
createDaprExecutionObserver,
|
|
5
|
+
createDaprLoggingObserver,
|
|
6
|
+
createOtelObserver,
|
|
7
|
+
createWorkflowObserverBridge
|
|
8
|
+
} from "../chunk-2CEICSJH.js";
|
|
9
|
+
import "../chunk-A34CHK2E.js";
|
|
10
|
+
export {
|
|
11
|
+
DaprExecutionObserver,
|
|
12
|
+
DaprExecutionStore,
|
|
13
|
+
createDaprExecutionObserver,
|
|
14
|
+
createDaprLoggingObserver,
|
|
15
|
+
createOtelObserver,
|
|
16
|
+
createWorkflowObserverBridge
|
|
17
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
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';
|
|
2
|
+
import '@cuylabs/agent-core';
|
|
3
|
+
import '../store-pRLGfYhN.js';
|
|
4
|
+
import '../workflow-bridge-C8Z1yr0Y.js';
|
|
5
|
+
import '../workflow/index.js';
|
|
6
|
+
import '@cuylabs/agent-runtime';
|
|
7
|
+
import 'node:http';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DaprServiceInvoker,
|
|
3
|
+
createDaprAgentRunner,
|
|
4
|
+
createDaprAgentRuntime,
|
|
5
|
+
createDaprAgentWorkflowHost,
|
|
6
|
+
createDaprHostHttpHandler,
|
|
7
|
+
createDaprMultiAgentRunner,
|
|
8
|
+
createDaprWorkflowWorker,
|
|
9
|
+
invokeRemoteAgentRun,
|
|
10
|
+
startDaprAgentWorkflowTurn,
|
|
11
|
+
startDaprHostHttpServer
|
|
12
|
+
} from "../chunk-2FMHOZLU.js";
|
|
13
|
+
import "../chunk-2CEICSJH.js";
|
|
14
|
+
import "../chunk-DILON56B.js";
|
|
15
|
+
import "../chunk-A34CHK2E.js";
|
|
16
|
+
export {
|
|
17
|
+
DaprServiceInvoker,
|
|
18
|
+
createDaprAgentRunner,
|
|
19
|
+
createDaprAgentRuntime,
|
|
20
|
+
createDaprAgentWorkflowHost,
|
|
21
|
+
createDaprHostHttpHandler,
|
|
22
|
+
createDaprMultiAgentRunner,
|
|
23
|
+
createDaprWorkflowWorker,
|
|
24
|
+
invokeRemoteAgentRun,
|
|
25
|
+
startDaprAgentWorkflowTurn,
|
|
26
|
+
startDaprHostHttpServer
|
|
27
|
+
};
|