@mongodb-js/agent-engine-sdk 0.11.3

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/dist/index.js ADDED
@@ -0,0 +1,8 @@
1
+ /** @mongodb-js/agent-engine-sdk — Core TypeScript protocols and models for MongoDB Agent Engine. */
2
+ export { TextBlockSchema, ImageBlockSchema, DocumentBlockSchema, AnyContentBlockSchema, ToolDefinitionSchema, createToolDefinition, JsonValueSchema, LLMTokenUsage, LLMTokenUsageSchema, LLMToolCall, LLMToolCallSchema, LLMToolSchema, LLMToolSchemaValidator, LLMInvocationOptions, LLMInvocationOptionsSchema, LLMResponse, LLMResponseSchema, MessageSchema, serializeMessage, ToolCallChunkSchema, AgentInputSchema, AgentOutputSchema, StreamEventSchema, BranchRefSchema, EventSchema, DateFromStringSchema, SessionSummarySchema, SessionsSummaryResponseSchema, SessionMessageSchema, SessionMessagesResponseSchema, } from "./models.js";
3
+ export { NullExecutionCallback } from "./interfaces.js";
4
+ export { BaseApp } from "./app.js";
5
+ export { EventResponseSchema, EventsResponseSchema } from "./api/events.js";
6
+ export { MemorySource, MemorySourceSchema, FormatStyle, FormatStyleSchema, ModelType, ModelTypeSchema, WriteTurnResultSchema, CreateSemanticResultSchema, BulkCreateSemanticResultSchema, CreateEpisodicResultSchema, CreateTaxonomicResultSchema, CreateProceduralResultSchema, CreateUserContextResultSchema, CreateSnapshotResultSchema, PromoteSnapshotResultSchema, DeleteResultSchema, InternalStateResultSchema, ISGenerationResultSchema, MemoryChunkSchema, ContextConfigSchema, ContextMetadataSchema, ContextResponseSchema, TagScalarSchema, CustomMemorySaveResultSchema, RetrievedCustomMemorySchema, CustomMemoryRetrieveResultSchema, } from "./api/v1/memory.js";
7
+ export { EventClient } from "./clients/events.js";
8
+ export { MemoryClient, MemoryHttpError } from "./clients/memory.js";
@@ -0,0 +1,111 @@
1
+ /** Framework-neutral protocols for the Atlas Agent Engine SDK. */
2
+ import type { AgentInput, AgentOutput, LLMResponse, LLMStreamChunk, Message, RequestContext, StreamEvent } from "./models.js";
3
+ /**
4
+ * Result of an agent execution.
5
+ *
6
+ * Await for the final result, or async-iterate for streaming events.
7
+ *
8
+ * ```ts
9
+ * // Non-streaming
10
+ * const output = await agent.execute(ctx, input)
11
+ *
12
+ * // Streaming
13
+ * for await (const event of agent.execute(ctx, input)) {
14
+ * handle(event)
15
+ * }
16
+ * ```
17
+ */
18
+ export interface ExecutionResult extends PromiseLike<AgentOutput>, AsyncIterable<StreamEvent> {
19
+ }
20
+ /**
21
+ * The contract between agent code and runtimes.
22
+ *
23
+ * Agents expose a single `execute()` method that returns an `ExecutionResult`.
24
+ * Callers choose the execution mode:
25
+ * - `await agent.execute(ctx, input)` for a final result (JSON-style)
26
+ * - `for await (const event of agent.execute(ctx, input))` for streaming (SSE-style)
27
+ */
28
+ export interface BaseAgent {
29
+ execute(ctx: RequestContext, input: AgentInput): ExecutionResult;
30
+ }
31
+ /**
32
+ * Framework-neutral LLM protocol.
33
+ *
34
+ * Used at runtime by the ToolPod. In Python, this protocol exposes both `invoke`
35
+ * (sync) and `ainvoke` (async) since Python supports both call styles. JS has no
36
+ * sync HTTP, so this interface has a single async `invoke` plus `stream`.
37
+ */
38
+ export interface BaseLLM {
39
+ invoke(messages: Message[], kwargs?: Record<string, unknown>): Promise<LLMResponse>;
40
+ stream(messages: Message[], kwargs?: Record<string, unknown>): AsyncIterable<LLMStreamChunk>;
41
+ }
42
+ /**
43
+ * Framework-neutral callback for observability during agent execution.
44
+ *
45
+ * Replaces LangChain's `BaseCallbackHandler`. The AER injects an
46
+ * implementation that forwards node events to the OE for logging.
47
+ * Framework adapters (e.g. sdk-langgraph) bridge from the framework's
48
+ * native callback system to this interface.
49
+ *
50
+ * Prefer subclassing `NullExecutionCallback` over implementing this
51
+ * interface directly — it provides no-op defaults for all methods including
52
+ * optional extensions (e.g. `onNodeSuspend`) so new methods never break
53
+ * existing implementations.
54
+ */
55
+ export interface BaseExecutionCallback {
56
+ onNodeStart(nodeName: string, inputs: Record<string, unknown>, opts: {
57
+ runId: string;
58
+ parentRunId?: string;
59
+ metadata?: Record<string, unknown>;
60
+ }): void;
61
+ onNodeEnd(nodeName: string, outputs: Record<string, unknown>, opts: {
62
+ runId: string;
63
+ parentRunId?: string;
64
+ durationMs?: number;
65
+ metadata?: Record<string, unknown>;
66
+ }): void;
67
+ onNodeError(nodeName: string, error: string, opts: {
68
+ runId: string;
69
+ parentRunId?: string;
70
+ metadata?: Record<string, unknown>;
71
+ }): void;
72
+ }
73
+ /**
74
+ * Concrete base class with no-op defaults for all `BaseExecutionCallback` methods.
75
+ *
76
+ * Subclass this instead of implementing `BaseExecutionCallback` directly so that
77
+ * new methods added to the interface are automatically satisfied — you only
78
+ * override the events you care about.
79
+ *
80
+ * ```ts
81
+ * class MyCallback extends NullExecutionCallback {
82
+ * onNodeStart(nodeName: string, _inputs, _opts) {
83
+ * console.log(`starting ${nodeName}`)
84
+ * }
85
+ * }
86
+ * ```
87
+ */
88
+ export declare class NullExecutionCallback implements BaseExecutionCallback {
89
+ onNodeStart(_nodeName: string, _inputs: Record<string, unknown>, _opts: {
90
+ runId: string;
91
+ parentRunId?: string;
92
+ metadata?: Record<string, unknown>;
93
+ }): void;
94
+ onNodeEnd(_nodeName: string, _outputs: Record<string, unknown>, _opts: {
95
+ runId: string;
96
+ parentRunId?: string;
97
+ durationMs?: number;
98
+ metadata?: Record<string, unknown>;
99
+ }): void;
100
+ onNodeError(_nodeName: string, _error: string, _opts: {
101
+ runId: string;
102
+ parentRunId?: string;
103
+ metadata?: Record<string, unknown>;
104
+ }): void;
105
+ onNodeSuspend(_nodeName: string, _opts: {
106
+ runId: string;
107
+ parentRunId?: string;
108
+ metadata?: Record<string, unknown>;
109
+ }): void;
110
+ }
111
+ //# sourceMappingURL=interfaces.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA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d,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACpC,GACA,IAAI;CACR"}
@@ -0,0 +1,22 @@
1
+ /** Framework-neutral protocols for the Atlas Agent Engine SDK. */
2
+ /**
3
+ * Concrete base class with no-op defaults for all `BaseExecutionCallback` methods.
4
+ *
5
+ * Subclass this instead of implementing `BaseExecutionCallback` directly so that
6
+ * new methods added to the interface are automatically satisfied — you only
7
+ * override the events you care about.
8
+ *
9
+ * ```ts
10
+ * class MyCallback extends NullExecutionCallback {
11
+ * onNodeStart(nodeName: string, _inputs, _opts) {
12
+ * console.log(`starting ${nodeName}`)
13
+ * }
14
+ * }
15
+ * ```
16
+ */
17
+ export class NullExecutionCallback {
18
+ onNodeStart(_nodeName, _inputs, _opts) { }
19
+ onNodeEnd(_nodeName, _outputs, _opts) { }
20
+ onNodeError(_nodeName, _error, _opts) { }
21
+ onNodeSuspend(_nodeName, _opts) { }
22
+ }