@dnotifier-realtime/dnotifier 1.1.39 → 1.1.40

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.
Files changed (53) hide show
  1. package/dist/agent-runtime/backendClient.js +1 -1
  2. package/dist/agent-runtime/content.js +1 -1
  3. package/dist/agent-runtime/descriptors.js +1 -1
  4. package/dist/agent-runtime/errors.js +1 -1
  5. package/dist/agent-runtime/ids.js +1 -1
  6. package/dist/agent-runtime/index.js +1 -1
  7. package/dist/agent-runtime/localCompletions.js +1 -1
  8. package/dist/agent-runtime/mcp/client.js +1 -1
  9. package/dist/agent-runtime/mcp/registry.js +1 -1
  10. package/dist/agent-runtime/middleware.js +1 -1
  11. package/dist/agent-runtime/observability.js +1 -1
  12. package/dist/agent-runtime/permissions.js +1 -1
  13. package/dist/agent-runtime/runtime.js +1 -1
  14. package/dist/agent-runtime/schema.js +1 -1
  15. package/dist/agent-runtime/toolRegistry.js +1 -1
  16. package/dist/checkpoint/index.js +1 -1
  17. package/dist/cjs/dnotifier.js +1 -1
  18. package/dist/cjs/providers/openai.js +1 -1
  19. package/dist/cjs/transport/httpTransport.js +1 -1
  20. package/dist/cjs/transport/websocketTransport.js +1 -1
  21. package/dist/cjs/utils/buffer.js +1 -1
  22. package/dist/cjs/utils/frame.js +1 -1
  23. package/dist/cjs/utils/id.js +1 -1
  24. package/dist/cjs/utils/payload.js +1 -1
  25. package/dist/config/endpoints.js +1 -1
  26. package/dist/dnotifier.cjs +7 -7
  27. package/dist/dnotifier.d.ts +836 -278
  28. package/dist/dnotifier.js +1 -1
  29. package/dist/providers/openai.js +1 -1
  30. package/dist/transport/httpTransport.js +1 -1
  31. package/dist/transport/websocketTransport.js +1 -1
  32. package/dist/utils/buffer.js +1 -1
  33. package/dist/utils/frame.js +1 -1
  34. package/dist/utils/id.js +1 -1
  35. package/dist/utils/logs.js +1 -1
  36. package/dist/utils/payload.js +1 -1
  37. package/dist/workflow/agent.js +1 -1
  38. package/dist/workflow/capabilities.js +1 -1
  39. package/dist/workflow/context.js +1 -1
  40. package/dist/workflow/errors.js +1 -1
  41. package/dist/workflow/graphParents.js +1 -1
  42. package/dist/workflow/ids.js +1 -1
  43. package/dist/workflow/jsonPayload.js +1 -1
  44. package/dist/workflow/mockObservabilityClient.js +1 -1
  45. package/dist/workflow/observability.js +1 -1
  46. package/dist/workflow/remoteAgentClient.js +1 -1
  47. package/dist/workflow/remoteAgentProtocol.js +1 -1
  48. package/dist/workflow/runner.js +1 -1
  49. package/dist/workflow/stepTypes.js +1 -1
  50. package/dist/workflow/workflow.js +1 -1
  51. package/dist/workflow/workflowObservabilityClient.js +1 -1
  52. package/package.json +6 -5
  53. package/types/dnotifier.d.ts +839 -0
@@ -1,281 +1,839 @@
1
- export class DNotifier {
2
- static Agent: typeof Agent;
3
- static defineAgent: typeof defineAgent;
4
- static Workflow: typeof Workflow;
5
- static WorkflowContext: typeof WorkflowContext;
6
- static WorkflowRunner: typeof WorkflowRunner;
7
- static WorkflowError: typeof WorkflowError;
8
- static ToolNotFoundError: typeof ToolNotFoundError;
9
- static ToolValidationError: typeof ToolValidationError;
10
- static ToolExecutionError: typeof ToolExecutionError;
11
- static PermissionDeniedError: typeof PermissionDeniedError;
12
- static MCPConnectionError: typeof MCPConnectionError;
13
- static MCPToolError: typeof MCPToolError;
14
- static AgentExecutionError: typeof AgentExecutionError;
15
- static BackendError: typeof BackendError;
16
- static LLMError: typeof LLMError;
17
- constructor({ appId, secret, transport, userId, logs, url, onConnected, onMessage, onDisconnected, WebSocketImpl, permissionEnforcement, onAgentEvent, serverConfig, checkpointer, }: {
18
- appId: any;
19
- secret: any;
20
- transport: any;
21
- userId: any;
22
- logs?: boolean | undefined;
23
- url: any;
24
- onConnected: any;
25
- onMessage: any;
26
- onDisconnected: any;
27
- WebSocketImpl: any;
28
- permissionEnforcement?: string | undefined;
29
- onAgentEvent?: null | undefined;
30
- serverConfig?: null | undefined;
31
- checkpointer?: null | undefined;
32
- });
33
- appId: any;
34
- secret: any;
35
- userId: any;
36
- url: any;
37
- _onAgentEvent: any;
38
- checkpointer: "remote" | "memory" | false | null | {
39
- put: Function;
40
- get: Function;
41
- list: Function;
1
+ /**
2
+ * Public TypeScript definitions for `@dnotifier-realtime/dnotifier`.
3
+ * Only the supported SDK surface is declared here (no internal helpers).
4
+ */
5
+
6
+ export type TransportKind = "http" | "ws";
7
+
8
+ /** One multimodal content part (`text` / `image` / `file` / `video`). */
9
+ export type ContentPart =
10
+ | { type: "text"; text: string }
11
+ | {
12
+ type: "image";
13
+ mimeType?: string;
14
+ base64?: string;
15
+ url?: string;
16
+ [key: string]: unknown;
17
+ }
18
+ | {
19
+ type: "file";
20
+ mimeType?: string;
21
+ filename?: string;
22
+ base64?: string;
23
+ url?: string;
24
+ [key: string]: unknown;
25
+ }
26
+ | {
27
+ type: "video";
28
+ mimeType?: string;
29
+ base64?: string;
30
+ url?: string;
31
+ [key: string]: unknown;
32
+ }
33
+ | { type: string; [key: string]: unknown };
34
+
35
+ /** Message body: plain string or multimodal parts. */
36
+ export type MessageContent = string | ContentPart[];
37
+
38
+ export interface ChatMessage {
39
+ role: "system" | "user" | "assistant" | "tool" | string;
40
+ content: MessageContent;
41
+ [key: string]: unknown;
42
+ }
43
+
44
+ /**
45
+ * Shared `input` envelope for `sendAI` and `runAgent`.
46
+ * Use a string for text-only, or `{ messages, useKnowledgeBase? }` for chat / RAG / attachments.
47
+ */
48
+ export type AiInput =
49
+ | string
50
+ | {
51
+ messages: ChatMessage[];
52
+ /** When true, ground the reply in indexed documents. Default false. */
53
+ useKnowledgeBase?: boolean;
54
+ [key: string]: unknown;
42
55
  };
43
- onConnectedCallback: any;
44
- onMessageCallback: any;
45
- onDisconnectedCallback: any;
46
- _remoteAgentPending: Map<string, {
47
- resolve: Function;
48
- reject: Function;
49
- timer: any;
50
- }>;
51
- _waitForMessageWaiters: Array<{
52
- resolve: Function;
53
- reject: Function;
54
- timer: any;
55
- }>;
56
- _aiReplyWaiters: Map<string, {
57
- resolve: Function;
58
- reject: Function;
59
- timer: any;
60
- }>;
61
- _workflowListeners: import("./workflow/workflow.js").Workflow[];
62
- _agentListeners: Map<string, import("./workflow/workflow.js").Workflow>;
63
- isConnected: boolean;
64
- aiEnabled: boolean;
65
- serverConfig: any;
66
- messageSizeLimit: number;
67
- _logsEnabled: boolean;
68
- _logsClient: LogsClient;
69
- _agentServices: {
70
- backend: import("./agent-runtime/backendClient.js").AgentBackendClient;
71
- sync: import("./agent-runtime/backendClient.js").AgentSync;
72
- events: import("./agent-runtime/observability.js").AgentObservability;
73
- tools: import("./agent-runtime/toolRegistry.js").ToolRegistry;
74
- mcp: import("./agent-runtime/mcp/registry.js").McpRegistry;
75
- permissionEnforcement: string;
76
- configure(config: {
77
- token?: string | null;
78
- onAgentEvent?: ((event: object) => void) | null;
79
- }): void;
56
+
57
+ export interface PlanLimits {
58
+ messagesHardLimit?: number | null;
59
+ maxAIRequestsPerMonth?: number;
60
+ maxAIWordsPerMonth?: number;
61
+ knowledgeBaseMaxWords?: number;
62
+ aiEnabled?: boolean;
63
+ maxUsers?: number | null;
64
+ maxRowsPerUser?: number | null;
65
+ }
66
+
67
+ export type CheckpointerOption =
68
+ | "remote"
69
+ | "memory"
70
+ | false
71
+ | null
72
+ | {
73
+ put: (...args: unknown[]) => unknown;
74
+ get: (...args: unknown[]) => unknown;
75
+ list: (...args: unknown[]) => unknown;
80
76
  };
81
- tools: import("./agent-runtime/toolRegistry.js").ToolRegistry;
82
- mcp: import("./agent-runtime/mcp/registry.js").McpRegistry;
83
- transport: HttpTransport | WebsocketTransport;
84
- connect(): Promise<true | undefined>;
85
- _authResponse: any;
86
- authToken: any;
87
- currentModel: any;
88
- _dispatchInboundMessage(msg: {
89
- metadata: object;
90
- payload: any;
91
- }): void;
92
- _awaitRemoteAgentReply(correlationId: string, options?: {
93
- timeoutMs?: number;
94
- agentName?: string;
95
- }): Promise<any>;
96
- _usesWebSocket(): boolean;
97
- _awaitAiReply(messageId: string, options?: {
98
- timeoutMs?: number;
99
- }): Promise<any>;
100
- _waitForInboundMessage(options?: {
101
- timeoutMs?: number;
102
- }): Promise<any>;
103
- _registerWorkflowListener(workflow: import("./workflow/workflow.js").Workflow): void;
104
- _unregisterWorkflowListener(workflow: import("./workflow/workflow.js").Workflow): void;
105
- _registerAgentListener(agent: import("./workflow/agent.js").Agent): void;
106
- _unregisterAgentListener(agent: import("./workflow/agent.js").Agent): void;
107
- disconnect(): void;
108
- getPlanLimits(): {
109
- messagesHardLimit: any;
110
- maxAIRequestsPerMonth: any;
111
- maxAIWordsPerMonth: any;
112
- knowledgeBaseMaxWords: any;
113
- aiEnabled: any;
114
- maxUsers: any;
115
- maxRowsPerUser: any;
116
- } | null;
117
- send({ senderId, receiverId, receiverIds, data, saveHistory }: {
118
- senderId: any;
119
- receiverId: any;
120
- receiverIds: any;
121
- data: any;
122
- saveHistory?: boolean | undefined;
123
- }): Promise<any>;
124
- sendAI({ senderId, input, message, saveHistory, sessionId, provider, model, }: {
125
- senderId: string;
126
- input?: string | object | undefined;
127
- message?: string | object | undefined;
128
- saveHistory?: boolean | undefined;
129
- sessionId?: string | null | undefined;
130
- provider?: string | undefined;
131
- model?: string | undefined;
132
- }): Promise<any>;
133
- fetchAIHistory({ senderId }: {
134
- senderId: any;
135
- }): Promise<any>;
136
- fetchChatHistory({ senderId, receiverIds }: {
137
- senderId: string;
138
- }): Promise<any>;
139
- deleteAIHistoryMessage({ senderId, messageId }: {
140
- senderId: string;
141
- messageId: string;
142
- }): Promise<any>;
143
- deleteChatHistoryMessage({ senderId, messageId }: {
144
- senderId: string;
145
- receiverIds: string[];
146
- messageId: string;
147
- }): Promise<any>;
148
- search({ senderId, query, limit, minSimilarity, filterbySource, ...runtime }: {
149
- senderId: string;
150
- query: string;
151
- limit?: number;
152
- minSimilarity?: number;
153
- filterbySource?: string;
154
- vectorStore?: object;
155
- vectorStoreConfig?: object;
156
- embedding?: object;
157
- embeddingConfig?: object;
158
- serverConfig?: object;
159
- }): Promise<any>;
160
- addDocument({ senderId, recordId, record_id, content, text, type, metadata: docMetadata, ...runtime }: {
161
- senderId: string;
162
- recordId?: string;
163
- record_id?: string;
164
- content?: string;
165
- text?: string;
166
- type?: string;
167
- metadata?: object;
168
- }): Promise<any>;
169
- updateDocument({ senderId, recordId, record_id, content, text, type, metadata: docMetadata, ...runtime }: {
170
- senderId: string;
171
- recordId?: string;
172
- record_id?: string;
173
- content?: string;
174
- text?: string;
175
- type?: string;
176
- metadata?: object;
177
- }): Promise<any>;
178
- deleteDocument({ senderId, recordId, record_id, ...runtime }: {
179
- senderId: string;
180
- recordId?: string;
181
- record_id?: string;
182
- vectorStore?: object;
183
- embedding?: object;
184
- serverConfig?: object;
185
- }): Promise<any>;
186
- listDocuments({ senderId, limit, offset, type, ...runtime }: {
187
- senderId: string;
188
- limit?: number;
189
- offset?: number;
190
- type?: string;
191
- vectorStore?: object;
192
- embedding?: object;
193
- serverConfig?: object;
194
- }): Promise<any>;
195
- getDocument({ senderId, recordId, record_id, ...runtime }: {
196
- senderId: string;
197
- recordId?: string;
198
- record_id?: string;
199
- vectorStore?: object;
200
- embedding?: object;
201
- serverConfig?: object;
202
- }): Promise<any>;
203
- _sendKnowledge(metadata: any, data: any): Promise<any>;
204
- sendBinary({ senderId, receiverIds, buffer, type }: {
205
- senderId: any;
206
- receiverIds: any;
207
- buffer: any;
208
- type?: string | undefined;
209
- }): string;
210
- sendWithOpenAI({ senderId, message, openaiApiKey, model, baseUrl }: {
211
- senderId: string;
212
- message: string | object;
213
- }): Promise<void>;
214
- runWorkflow({ workflow, input, senderId, sessionId, checkpointer, mode, resume, fromCheckpointId, }: {
215
- workflow: import("./workflow/workflow.js").Workflow;
216
- input: any;
217
- senderId?: string;
218
- sessionId?: string | null;
219
- checkpointer?: any;
220
- mode?: "run" | "resume" | "retry" | "replay";
221
- resume?: boolean;
222
- fromCheckpointId?: string | null;
223
- }): Promise<{
224
- result: any;
225
- state: any;
226
- mode: "resume" | "run" | "retry";
227
- } | {
228
- result: unknown;
229
- state: any;
230
- mode: "resume" | "run" | "retry" | "replay";
231
- }>;
232
- runAgent(agent: import("./workflow/agent.js").Agent, options?: {
233
- input?: any | {
234
- messages?: object[];
235
- useKnowledgeBase?: boolean;
236
- text?: string;
237
- message?: string;
238
- };
239
- userId?: string;
240
- sessionId?: string | null;
241
- checkpointer?: any;
242
- mode?: "run" | "resume" | "retry" | "replay";
243
- resume?: boolean;
244
- fromCheckpointId?: string | null;
245
- executionId?: string | null;
246
- signal?: AbortSignal;
247
- maxToolRounds?: number;
248
- metadata?: Record<string, unknown>;
249
- observability?: boolean;
250
- }): Promise<unknown>;
251
- resumeWorkflowContext(traceCtx: {
252
- executionId: string;
253
- workflowId: string;
254
- parentStepId?: string | null;
255
- }, options?: {
256
- workflow?: import("./workflow/workflow.js").Workflow;
257
- input?: any;
258
- state?: object;
259
- }): Promise<WorkflowContext>;
77
+
78
+ export type ExecutionMode = "run" | "resume" | "retry" | "replay";
79
+
80
+ export interface ToolDefinition {
81
+ /** Unique tool name (e.g. `math.add`). */
82
+ name: string;
83
+ /** Shown to the model. */
84
+ description?: string;
85
+ /** JSON Schema for tool arguments. */
86
+ inputSchema?: object;
87
+ /** Optional stable id; defaults to a local id derived from `name`. */
88
+ id?: string;
89
+ /** Implementation invoked when the model calls this tool. */
90
+ execute: (input: unknown, context?: object) => unknown | Promise<unknown>;
91
+ }
92
+
93
+ export interface RegisteredTool {
94
+ id: string;
95
+ name: string;
96
+ description: string;
97
+ inputSchema: object;
98
+ provider: string;
99
+ execute: (input: unknown, context?: object) => unknown | Promise<unknown>;
100
+ [key: string]: unknown;
101
+ }
102
+
103
+ /** Local tool registry (`notifier.tools`). */
104
+ export declare class ToolRegistry {
105
+ /**
106
+ * Register a local tool the agent may call.
107
+ * @param definition Tool name, schema, and `execute` implementation.
108
+ */
109
+ register(definition: ToolDefinition): RegisteredTool;
110
+ /** Look up a tool by id. */
111
+ get(id: string): RegisteredTool | undefined;
112
+ /** Look up a tool by name. */
113
+ getByName(name: string): RegisteredTool | undefined;
114
+ /** All registered tools. */
115
+ list(): RegisteredTool[];
116
+ /** Public descriptors (no execute) for every registered tool. */
117
+ listPublic(): object[];
118
+ /** Remove an in-memory tool by id. */
119
+ remove(id: string): void;
120
+ }
121
+
122
+ export interface McpConnectConfig {
123
+ /** Connection id used in tool names (`id.toolName`). */
124
+ id: string;
125
+ /** Display name. */
126
+ name?: string;
127
+ /** MCP HTTP endpoint URL. */
128
+ endpoint: string;
129
+ /** Only `"http"` is supported. */
130
+ transport?: string;
131
+ /** Extra HTTP headers for the MCP server. */
132
+ headers?: Record<string, string>;
133
+ }
134
+
135
+ export declare class McpConnection {
136
+ readonly id: string;
137
+ readonly name: string;
138
+ readonly transport: string;
139
+ /** Cached discovered tools (synchronous). */
140
+ tools(): RegisteredTool[];
141
+ /** Refresh the tool list from the MCP server. */
142
+ refreshTools(): Promise<RegisteredTool[]>;
143
+ }
144
+
145
+ /** MCP registry (`notifier.mcp`). */
146
+ export declare class McpRegistry {
147
+ /**
148
+ * Connect to an MCP HTTP server and discover its tools.
149
+ * @param config Connection id, endpoint, and optional headers.
150
+ */
151
+ connect(config: McpConnectConfig): Promise<McpConnection>;
152
+ /** Get a connection by id. */
153
+ get(id: string): McpConnection | undefined;
154
+ /** All open MCP connections. */
155
+ list(): McpConnection[];
156
+ }
157
+
158
+ export interface DefineAgentOptions {
159
+ /** Unique agent id within your project. */
160
+ name: string;
161
+ /**
162
+ * Custom agent logic. Required unless `tools` (or instructions-only with `tools: []`) is set.
163
+ * @param ctx Workflow context for this run.
164
+ */
165
+ run?: (ctx: WorkflowContext) => unknown | Promise<unknown>;
166
+ /**
167
+ * System prompt. String, or multimodal content-part list.
168
+ * With tools omitted and instructions set, becomes a tool agent with `tools: []`.
169
+ */
170
+ instructions?: MessageContent;
171
+ /** Short summary (portal / MCP / A2A). */
172
+ description?: string;
173
+ /** Tools from `notifier.tools.register` or `mcp.tools()`. */
174
+ tools?: RegisteredTool[] | null;
175
+ /** Which tools this agent may run, e.g. `{ "math.add": ["execute"] }`. */
176
+ permissions?: Record<string, string[]>;
177
+ /** Record runs in Observe → Traces. */
178
+ observability?: boolean;
179
+ /** Default LLM provider (e.g. `open_ai`). */
180
+ provider?: string | null;
181
+ /** Default model (e.g. `gpt-4o-mini`). */
182
+ model?: string | null;
183
+ /** Capabilities when served over MCP or A2A. */
184
+ capabilities?: Record<string, boolean> | string[];
185
+ /** Agent middleware hooks. */
186
+ middleware?: object[];
187
+ }
188
+
189
+ export declare class Agent {
190
+ readonly name: string;
191
+ description: string;
192
+ instructions: MessageContent;
193
+ hasTools: boolean;
194
+ tools: RegisteredTool[];
195
+ permissions: Record<string, string[]>;
196
+ observability: boolean;
197
+ capabilities: Record<string, boolean>;
198
+ provider: string | null;
199
+ model: string | null;
200
+ hasUserRun: boolean;
201
+ /**
202
+ * Answer remote invokes for this agent on `notifier` (WebSocket).
203
+ * @param notifier Connected DNotifier instance.
204
+ */
205
+ listen(notifier: DNotifier): this;
206
+ /** Stop answering remote invokes. */
207
+ stopListening(): this;
208
+ /** Run this agent with a workflow context (usually called by the SDK). */
209
+ run(ctx: WorkflowContext): Promise<unknown>;
210
+ }
211
+
212
+ /**
213
+ * Define an agent (instructions + tools, or a custom `run`).
214
+ * @param options Agent name and either `run` or `tools` / `instructions`.
215
+ */
216
+ export function defineAgent(options: DefineAgentOptions): Agent;
217
+
218
+ export interface WorkflowOptions {
219
+ /** Workflow identifier. */
220
+ name: string;
221
+ /** Main workflow function. */
222
+ entry: (ctx: WorkflowContext) => unknown | Promise<unknown>;
223
+ /** Short description (max 100 chars). */
224
+ description?: string;
225
+ /** Send steps to the workflow dashboard. */
226
+ observability?: boolean;
227
+ /** Capabilities when served over MCP or A2A. */
228
+ capabilities?: Record<string, boolean> | string[];
229
+ /** Workflow middleware hooks. */
230
+ middleware?: object[];
231
+ }
232
+
233
+ export type RemoteAgentRegistration = { receiverId: string };
234
+ export type AgentRegistration = Agent | RemoteAgentRegistration;
235
+
236
+ export declare class Workflow {
237
+ readonly name: string;
238
+ description?: string;
239
+ observability: boolean;
240
+ capabilities: Record<string, boolean>;
241
+ entry: (ctx: WorkflowContext) => unknown | Promise<unknown>;
242
+ constructor(options: WorkflowOptions);
243
+ /**
244
+ * Register one local agent or a remote `{ receiverId }` target.
245
+ * @param name Agent name used with `ctx.runAgent(name)`.
246
+ * @param agent Local `Agent` or remote registration.
247
+ */
248
+ registerAgent(name: string, agent: AgentRegistration): this;
249
+ /**
250
+ * Register many agents at once.
251
+ * @param agents Map of name → agent or remote target.
252
+ */
253
+ registerAgents(agents: Record<string, AgentRegistration>): this;
254
+ /** Look up a local agent by name. */
255
+ getAgent(name: string): Agent | undefined;
256
+ /**
257
+ * Host local agents for remote `runAgent`, MCP, and A2A (WebSocket).
258
+ * @param notifier Connected DNotifier instance.
259
+ */
260
+ listen(notifier: DNotifier): this;
261
+ /** Stop answering remote calls. */
262
+ stopListening(): this;
263
+ }
264
+
265
+ export interface RunAgentCallOptions {
266
+ /** Override workflow input for this agent. */
267
+ input?: unknown;
268
+ label?: string;
269
+ [key: string]: unknown;
270
+ }
271
+
272
+ export interface CtxSendAiOptions {
273
+ /**
274
+ * Prompt: string or `{ messages, useKnowledgeBase? }`.
275
+ * Prefer `input` over deprecated `message`.
276
+ */
277
+ input?: AiInput;
278
+ /** @deprecated Prefer `input`. */
279
+ message?: AiInput;
280
+ /** Persist turn in AI history. Default true. */
281
+ saveHistory?: boolean;
282
+ /** Continue an existing AI session. */
283
+ sessionId?: string | null;
284
+ /** Override provider for this call. */
285
+ provider?: string;
286
+ /** Override model for this call. */
287
+ model?: string;
288
+ /** Step label in Traces. */
289
+ label?: string;
290
+ [key: string]: unknown;
291
+ }
292
+
293
+ export interface RecordStepOptions {
294
+ /** Step label in Traces. */
295
+ label: string;
296
+ input?: unknown;
297
+ output?: unknown;
298
+ status?: string;
299
+ type?: string;
300
+ [key: string]: unknown;
301
+ }
302
+
303
+ /**
304
+ * Context passed to workflow `entry` and agent `run`.
305
+ * Use for `runAgent`, `sendAI`, knowledge-base APIs, and custom steps.
306
+ */
307
+ export declare class WorkflowContext {
308
+ /** Workflow / agent input for this run. */
309
+ input: unknown;
310
+ /** Shared mutable state for the run. */
311
+ state: Record<string, unknown>;
312
+ /** Current agent name when inside an agent handler. */
313
+ agentName: string | null;
314
+ readonly notifier: DNotifier;
315
+ readonly senderId: string;
316
+ readonly workflow: Workflow;
317
+
318
+ /**
319
+ * Run one registered agent.
320
+ * @param name Agent name from `registerAgent`.
321
+ * @param options Optional `input` override and labels.
322
+ */
323
+ runAgent(name: string, options?: RunAgentCallOptions): Promise<unknown>;
324
+
325
+ /**
326
+ * Run several agents in parallel.
327
+ * @param spec Array of names / `{ name, input? }`, or a name→input map.
328
+ */
329
+ runAgents(
330
+ spec:
331
+ | Array<string | { name: string; input?: unknown }>
332
+ | Record<string, unknown>,
333
+ options?: object
334
+ ): Promise<{ results: unknown }>;
335
+
336
+ /**
337
+ * Wait for the next inbound realtime message (WebSocket).
338
+ * @param options Optional timeout in milliseconds.
339
+ */
340
+ waitForMessage(options?: { timeoutMs?: number }): Promise<unknown>;
341
+
342
+ /**
343
+ * Call the AI pipeline (same `input` shapes as `notifier.sendAI`).
344
+ * @param opts Prompt, history, provider/model, and optional trace label.
345
+ */
346
+ sendAI(opts: CtxSendAiOptions): Promise<unknown>;
347
+
348
+ /** Fetch AI conversation history. */
349
+ fetchAIHistory(opts?: { label?: string }): Promise<unknown>;
350
+
351
+ /**
352
+ * Semantic search over the knowledge base.
353
+ * @param opts Query and optional filters / label.
354
+ */
355
+ search(opts: {
356
+ query: string;
357
+ limit?: number;
358
+ minSimilarity?: number;
359
+ filterbySource?: string;
360
+ label?: string;
361
+ [key: string]: unknown;
362
+ }): Promise<unknown>;
363
+
364
+ /** Add a RAG document. */
365
+ addDocument(opts: {
366
+ recordId?: string;
367
+ record_id?: string;
368
+ content?: string;
369
+ text?: string;
370
+ type?: string;
371
+ metadata?: object;
372
+ label?: string;
373
+ [key: string]: unknown;
374
+ }): Promise<unknown>;
375
+
376
+ /** Update a RAG document. */
377
+ updateDocument(opts: {
378
+ recordId?: string;
379
+ record_id?: string;
380
+ content?: string;
381
+ text?: string;
382
+ type?: string;
383
+ metadata?: object;
384
+ label?: string;
385
+ [key: string]: unknown;
386
+ }): Promise<unknown>;
387
+
388
+ /** Delete a RAG document. */
389
+ deleteDocument(opts: {
390
+ recordId?: string;
391
+ record_id?: string;
392
+ label?: string;
393
+ [key: string]: unknown;
394
+ }): Promise<unknown>;
395
+
396
+ /** List RAG documents. */
397
+ listDocuments(opts?: {
398
+ limit?: number;
399
+ offset?: number;
400
+ type?: string;
401
+ label?: string;
402
+ [key: string]: unknown;
403
+ }): Promise<unknown>;
404
+
405
+ /** Get one RAG document by id. */
406
+ getDocument(opts: {
407
+ recordId?: string;
408
+ record_id?: string;
409
+ label?: string;
410
+ [key: string]: unknown;
411
+ }): Promise<unknown>;
412
+
413
+ /**
414
+ * Record a custom observability step.
415
+ * @param step Label plus optional input/output.
416
+ */
417
+ recordStep(step: RecordStepOptions): Promise<unknown>;
418
+ }
419
+
420
+ export declare class WorkflowRunner {
421
+ constructor(options?: object);
422
+ }
423
+
424
+ export declare class WorkflowError extends Error {
425
+ agentName?: string;
426
+ constructor(message?: string, options?: { agentName?: string });
427
+ }
428
+
429
+ export declare class ToolNotFoundError extends Error {}
430
+ export declare class ToolValidationError extends Error {}
431
+ export declare class ToolExecutionError extends Error {}
432
+ export declare class PermissionDeniedError extends Error {}
433
+ export declare class MCPConnectionError extends Error {}
434
+ export declare class MCPToolError extends Error {}
435
+ export declare class AgentExecutionError extends Error {}
436
+ export declare class BackendError extends Error {}
437
+ export declare class LLMError extends Error {}
438
+
439
+ export interface DNotifierOptions {
440
+ /** Application id from the DNotifier portal. */
441
+ appId: string;
442
+ /** Application secret. */
443
+ secret: string;
444
+ /** `"http"` or `"ws"`. Prefer `http` for agents / AI. */
445
+ transport: TransportKind;
446
+ /** End-user id for this client. */
447
+ userId: string;
448
+ /** Enable client-side AI session logging helpers. */
449
+ logs?: boolean;
450
+ /** WebSocket URL override (ws transport). */
451
+ url?: string;
452
+ /** Called after successful connect. */
453
+ onConnected?: () => void;
454
+ /** Called for inbound realtime messages (ws). */
455
+ onMessage?: (message: unknown) => void;
456
+ /** Called when the WebSocket disconnects. */
457
+ onDisconnected?: (info: { code?: number; reason?: string }) => void;
458
+ /** Custom WebSocket implementation (Node). */
459
+ WebSocketImpl?: unknown;
460
+ /** `"backend"` (default) or `"disabled"`. */
461
+ permissionEnforcement?: string;
462
+ /** Agent lifecycle event callback. */
463
+ onAgentEvent?: ((event: object) => void) | null;
464
+ /** Default vector-store / embedding config for knowledge APIs. */
465
+ serverConfig?: object | null;
466
+ /** Default checkpointer for agent/workflow runs. */
467
+ checkpointer?: CheckpointerOption;
468
+ }
469
+
470
+ export interface SendOptions {
471
+ /** Sender user id. */
472
+ senderId: string;
473
+ /** Single recipient (or use `receiverIds`). */
474
+ receiverId?: string;
475
+ /** Multiple recipients. */
476
+ receiverIds?: string[];
477
+ /** Message payload. */
478
+ data: unknown;
479
+ /** Persist in chat history. Default true. */
480
+ saveHistory?: boolean;
481
+ }
482
+
483
+ export interface SendAiOptions {
484
+ /** Sender user id. */
485
+ senderId: string;
486
+ /**
487
+ * Prompt: string or `{ messages, useKnowledgeBase? }`.
488
+ * Prefer this over deprecated `message`.
489
+ */
490
+ input?: AiInput;
491
+ /** @deprecated Prefer `input`. */
492
+ message?: AiInput;
493
+ /** Persist turn in AI history. Default true. */
494
+ saveHistory?: boolean;
495
+ /** Continue an existing AI session. */
496
+ sessionId?: string | null;
497
+ /** LLM provider override. */
498
+ provider?: string;
499
+ /** Model override. */
500
+ model?: string;
501
+ }
502
+
503
+ export interface RunAgentOptions {
504
+ /**
505
+ * Prompt for this run. Same shapes as `sendAI`: string or
506
+ * `{ messages, useKnowledgeBase? }` (multimodal `content` parts allowed).
507
+ * Optional inside workflows (reuses `ctx.input`).
508
+ */
509
+ input?: AiInput;
510
+ /** Who the run is for (defaults to client `userId`). */
511
+ userId?: string;
512
+ /** Keep conversation context across runs. */
513
+ sessionId?: string | null;
514
+ /** Checkpoint store: `"remote"`, `"memory"`, `false`, or a custom store. */
515
+ checkpointer?: CheckpointerOption;
516
+ /** Execution mode. Default `"run"`. */
517
+ mode?: ExecutionMode;
518
+ /** Shortcut for resume mode. */
519
+ resume?: boolean;
520
+ /** Resume from a specific checkpoint id. */
521
+ fromCheckpointId?: string | null;
522
+ /** Optional fixed execution id. */
523
+ executionId?: string | null;
524
+ /** Abort the run. */
525
+ signal?: AbortSignal;
526
+ /** Max model → tool → model rounds. */
527
+ maxToolRounds?: number;
528
+ /** Extra metadata stored on the run. */
529
+ metadata?: Record<string, unknown>;
530
+ /** Override agent observability for this call. */
531
+ observability?: boolean;
532
+ state?: Record<string, unknown>;
533
+ }
534
+
535
+ export interface RunAgentResult {
536
+ /** Final agent answer. */
537
+ output?: unknown;
538
+ executionId?: string;
539
+ sessionId?: string;
540
+ checkpointId?: string;
541
+ finishReason?: string;
542
+ lastStepId?: string;
543
+ mode?: ExecutionMode | string;
544
+ [key: string]: unknown;
545
+ }
546
+
547
+ export interface RunWorkflowOptions {
548
+ /** Workflow instance to run. */
549
+ workflow: Workflow;
550
+ /** Input passed to `ctx.input`. */
551
+ input?: unknown;
552
+ /** Sender / user id for the run. */
553
+ senderId?: string;
554
+ sessionId?: string | null;
555
+ checkpointer?: CheckpointerOption;
556
+ mode?: ExecutionMode;
557
+ resume?: boolean;
558
+ fromCheckpointId?: string | null;
559
+ }
560
+
561
+ export interface RunWorkflowResult {
562
+ /** Return value of `workflow.entry()`. */
563
+ result: unknown;
564
+ /** Shared mutable state after the run. */
565
+ state: unknown;
566
+ mode?: ExecutionMode | string;
567
+ executionId?: string;
568
+ sessionId?: string;
569
+ [key: string]: unknown;
570
+ }
571
+
572
+ export interface KnowledgeRuntimeOptions {
573
+ vectorStore?: object;
574
+ vectorStoreConfig?: object;
575
+ embedding?: object;
576
+ embeddingConfig?: object;
577
+ serverConfig?: object;
578
+ }
579
+
580
+ /**
581
+ * DNotifier client — connect, messaging, AI, agents, workflows, and RAG.
582
+ */
583
+ export declare class DNotifier {
584
+ static Agent: typeof Agent;
585
+ static defineAgent: typeof defineAgent;
586
+ static Workflow: typeof Workflow;
587
+ static WorkflowContext: typeof WorkflowContext;
588
+ static WorkflowRunner: typeof WorkflowRunner;
589
+ static WorkflowError: typeof WorkflowError;
590
+ static ToolNotFoundError: typeof ToolNotFoundError;
591
+ static ToolValidationError: typeof ToolValidationError;
592
+ static ToolExecutionError: typeof ToolExecutionError;
593
+ static PermissionDeniedError: typeof PermissionDeniedError;
594
+ static MCPConnectionError: typeof MCPConnectionError;
595
+ static MCPToolError: typeof MCPToolError;
596
+ static AgentExecutionError: typeof AgentExecutionError;
597
+ static BackendError: typeof BackendError;
598
+ static LLMError: typeof LLMError;
599
+
600
+ readonly appId: string;
601
+ readonly secret: string;
602
+ readonly userId: string;
603
+ url: string;
604
+ isConnected: boolean;
605
+ aiEnabled: boolean;
606
+ authToken?: string;
607
+ messageSizeLimit: number;
608
+ currentModel?: string;
609
+ serverConfig: object | null;
610
+ checkpointer: CheckpointerOption;
611
+ /** Local tool registry. */
612
+ tools: ToolRegistry;
613
+ /** MCP server connections. */
614
+ mcp: McpRegistry;
615
+
616
+ /**
617
+ * Create a client.
618
+ * @param options App credentials, transport, and callbacks.
619
+ */
620
+ constructor(options: DNotifierOptions);
621
+
622
+ /**
623
+ * Authenticate. Opens the WebSocket when `transport` is `"ws"`.
624
+ * @returns `true` when connected.
625
+ */
626
+ connect(): Promise<boolean | undefined>;
627
+
628
+ /** Close the WebSocket and mark the client disconnected. */
629
+ disconnect(): void;
630
+
631
+ /**
632
+ * Plan quotas from the last successful auth.
633
+ * @returns Limits object, or `null` if unavailable.
634
+ */
635
+ getPlanLimits(): PlanLimits | null;
636
+
637
+ /**
638
+ * Send a structured realtime message.
639
+ * @param options Sender, recipient(s), and payload.
640
+ */
641
+ send(options: SendOptions): Promise<unknown>;
642
+
643
+ /**
644
+ * Send raw bytes (WebSocket only).
645
+ * @param options Sender, recipients, and buffer.
646
+ */
647
+ sendBinary(options: {
648
+ senderId: string;
649
+ receiverIds: string[];
650
+ buffer: Uint8Array | ArrayBuffer | Buffer;
651
+ type?: string;
652
+ }): string;
653
+
654
+ /**
655
+ * Call the AI pipeline.
656
+ * Prefer `input` (string or `{ messages, useKnowledgeBase? }`).
657
+ * HTTP returns the response body; WS returns a session id (reply via `onMessage`).
658
+ * @param options Sender, prompt, and optional session / model.
659
+ */
660
+ sendAI(options: SendAiOptions): Promise<unknown>;
661
+
662
+ /**
663
+ * Fetch AI conversation history for a user.
664
+ * @param options `senderId` of the history owner.
665
+ */
666
+ fetchAIHistory(options: { senderId: string }): Promise<unknown>;
667
+
668
+ /**
669
+ * Delete one AI history message.
670
+ * @param options Owner and message id.
671
+ */
672
+ deleteAIHistoryMessage(options: {
673
+ senderId: string;
674
+ messageId: string;
675
+ }): Promise<unknown>;
676
+
677
+ /**
678
+ * Request chat history (WS delivers via `onMessage`).
679
+ * @param options Sender and peer ids.
680
+ */
681
+ fetchChatHistory(options: {
682
+ senderId: string;
683
+ receiverIds: string[];
684
+ }): Promise<unknown>;
685
+
686
+ /**
687
+ * Delete one chat history message.
688
+ * @param options Owner and message id.
689
+ */
690
+ deleteChatHistoryMessage(options: {
691
+ senderId: string;
692
+ messageId: string;
693
+ }): Promise<unknown>;
694
+
695
+ /**
696
+ * Semantic search over the knowledge base.
697
+ * @param options Query and optional filters.
698
+ */
699
+ search(
700
+ options: {
701
+ senderId: string;
702
+ query: string;
703
+ limit?: number;
704
+ minSimilarity?: number;
705
+ filterbySource?: string;
706
+ } & KnowledgeRuntimeOptions
707
+ ): Promise<unknown>;
708
+
709
+ /**
710
+ * Add or upsert a RAG document.
711
+ * @param options Document body (`content` or `text`) and optional id/metadata.
712
+ */
713
+ addDocument(
714
+ options: {
715
+ senderId: string;
716
+ recordId?: string;
717
+ record_id?: string;
718
+ content?: string;
719
+ text?: string;
720
+ type?: string;
721
+ metadata?: object;
722
+ } & KnowledgeRuntimeOptions
723
+ ): Promise<unknown>;
724
+
725
+ /**
726
+ * Update a RAG document.
727
+ * @param options Document id and new body/metadata.
728
+ */
729
+ updateDocument(
730
+ options: {
731
+ senderId: string;
732
+ recordId?: string;
733
+ record_id?: string;
734
+ content?: string;
735
+ text?: string;
736
+ type?: string;
737
+ metadata?: object;
738
+ } & KnowledgeRuntimeOptions
739
+ ): Promise<unknown>;
740
+
741
+ /**
742
+ * Delete a RAG document by id.
743
+ * @param options Document id.
744
+ */
745
+ deleteDocument(
746
+ options: {
747
+ senderId: string;
748
+ recordId?: string;
749
+ record_id?: string;
750
+ } & KnowledgeRuntimeOptions
751
+ ): Promise<unknown>;
752
+
753
+ /**
754
+ * List RAG documents.
755
+ * @param options Optional pagination and type filter.
756
+ */
757
+ listDocuments(
758
+ options: {
759
+ senderId: string;
760
+ limit?: number;
761
+ offset?: number;
762
+ type?: string;
763
+ } & KnowledgeRuntimeOptions
764
+ ): Promise<unknown>;
765
+
766
+ /**
767
+ * Get one RAG document and its chunks.
768
+ * @param options Document id.
769
+ */
770
+ getDocument(
771
+ options: {
772
+ senderId: string;
773
+ recordId?: string;
774
+ record_id?: string;
775
+ } & KnowledgeRuntimeOptions
776
+ ): Promise<unknown>;
777
+
778
+ /**
779
+ * Run a registered workflow.
780
+ * @param options Workflow instance and input.
781
+ */
782
+ runWorkflow(options: RunWorkflowOptions): Promise<RunWorkflowResult>;
783
+
784
+ /**
785
+ * Run a standalone tool agent (outside a workflow).
786
+ * Inside a workflow, use `ctx.runAgent(name)` instead.
787
+ * @param agent Agent from `defineAgent`.
788
+ * @param options Prompt, session, tool-round limits, observability.
789
+ */
790
+ runAgent(
791
+ agent: Agent,
792
+ options?: RunAgentOptions
793
+ ): Promise<RunAgentResult>;
794
+
795
+ /**
796
+ * Advanced: resume an append-only workflow context from a trace pointer.
797
+ * @param traceCtx Execution / workflow ids from a prior run.
798
+ * @param options Optional workflow, input, and state.
799
+ */
800
+ resumeWorkflowContext(
801
+ traceCtx: {
802
+ executionId: string;
803
+ workflowId: string;
804
+ parentStepId?: string | null;
805
+ },
806
+ options?: {
807
+ workflow?: Workflow;
808
+ input?: unknown;
809
+ state?: object;
810
+ }
811
+ ): Promise<WorkflowContext>;
812
+
813
+ /**
814
+ * @deprecated Prefer `sendAI`.
815
+ */
816
+ sendWithOpenAI(options: {
817
+ senderId: string;
818
+ message: string | object;
819
+ openaiApiKey?: string;
820
+ model?: string;
821
+ baseUrl?: string;
822
+ }): Promise<void>;
823
+ }
824
+
825
+ /** In-memory checkpointer for local sessions. */
826
+ export declare class MemoryCheckpointer {
827
+ put(checkpoint: object): Promise<object>;
828
+ get(query: object): Promise<object | null>;
829
+ list(query?: object): Promise<object[]>;
830
+ }
831
+
832
+ /** Remote (server) checkpointer. */
833
+ export declare class RemoteCheckpointer {
834
+ put(checkpoint: object): Promise<object>;
835
+ get(query: object): Promise<object | null>;
836
+ list(query?: object): Promise<object[]>;
260
837
  }
261
- import { Agent } from "./workflow/index.js";
262
- import { defineAgent } from "./workflow/index.js";
263
- import { Workflow } from "./workflow/index.js";
264
- import { WorkflowContext } from "./workflow/index.js";
265
- import { WorkflowRunner } from "./workflow/index.js";
266
- import { WorkflowError } from "./workflow/index.js";
267
- import { ToolNotFoundError } from "./agent-runtime/index.js";
268
- import { ToolValidationError } from "./agent-runtime/index.js";
269
- import { ToolExecutionError } from "./agent-runtime/index.js";
270
- import { PermissionDeniedError } from "./agent-runtime/index.js";
271
- import { MCPConnectionError } from "./agent-runtime/index.js";
272
- import { MCPToolError } from "./agent-runtime/index.js";
273
- import { AgentExecutionError } from "./agent-runtime/index.js";
274
- import { BackendError } from "./agent-runtime/index.js";
275
- import { LLMError } from "./agent-runtime/index.js";
276
- import { LogsClient } from "./utils/logs.js";
277
- import { HttpTransport } from "./transport/httpTransport.js";
278
- import { WebsocketTransport } from "./transport/websocketTransport.js";
279
- export { Agent, defineAgent, Workflow, WorkflowContext, WorkflowRunner, WorkflowError, ToolNotFoundError, ToolValidationError, ToolExecutionError, PermissionDeniedError, MCPConnectionError, MCPToolError, AgentExecutionError, BackendError, LLMError };
280
- export { MemoryCheckpointer, RemoteCheckpointer, beginCheckpointing, resolveRunSession, normalizeRunMode } from "./checkpoint/index.js";
281
- //# sourceMappingURL=dnotifier.d.ts.map
838
+
839
+ export as namespace DNotifierSDK;