@mongodb-js/agent-engine-sdk-langgraph 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/CHANGELOG.md +39 -0
- package/LICENSE.md +201 -0
- package/README.md +149 -0
- package/dist/agent.d.ts +53 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/agent.js +508 -0
- package/dist/agent.js.map +1 -0
- package/dist/backends/tool_sandbox.d.ts +15 -0
- package/dist/backends/tool_sandbox.d.ts.map +1 -0
- package/dist/backends/tool_sandbox.js +15 -0
- package/dist/backends/tool_sandbox.js.map +1 -0
- package/dist/backends/toolpod.d.ts +68 -0
- package/dist/backends/toolpod.d.ts.map +1 -0
- package/dist/backends/toolpod.js +451 -0
- package/dist/backends/toolpod.js.map +1 -0
- package/dist/call_interrupt.d.ts +20 -0
- package/dist/call_interrupt.d.ts.map +1 -0
- package/dist/call_interrupt.js +23 -0
- package/dist/call_interrupt.js.map +1 -0
- package/dist/checkpoint_branch.d.ts +58 -0
- package/dist/checkpoint_branch.d.ts.map +1 -0
- package/dist/checkpoint_branch.js +239 -0
- package/dist/checkpoint_branch.js.map +1 -0
- package/dist/checkpointer.d.ts +21 -0
- package/dist/checkpointer.d.ts.map +1 -0
- package/dist/checkpointer.js +31 -0
- package/dist/checkpointer.js.map +1 -0
- package/dist/deep_agent.d.ts +49 -0
- package/dist/deep_agent.d.ts.map +1 -0
- package/dist/deep_agent.js +110 -0
- package/dist/deep_agent.js.map +1 -0
- package/dist/deep_agent_checkpointer.d.ts +11 -0
- package/dist/deep_agent_checkpointer.d.ts.map +1 -0
- package/dist/deep_agent_checkpointer.js +19 -0
- package/dist/deep_agent_checkpointer.js.map +1 -0
- package/dist/deep_agent_task.d.ts +26 -0
- package/dist/deep_agent_task.d.ts.map +1 -0
- package/dist/deep_agent_task.js +49 -0
- package/dist/deep_agent_task.js.map +1 -0
- package/dist/durable_deep_agent.d.ts +23 -0
- package/dist/durable_deep_agent.d.ts.map +1 -0
- package/dist/durable_deep_agent.js +176 -0
- package/dist/durable_deep_agent.js.map +1 -0
- package/dist/durable_message_identity.d.ts +5 -0
- package/dist/durable_message_identity.d.ts.map +1 -0
- package/dist/durable_message_identity.js +106 -0
- package/dist/durable_message_identity.js.map +1 -0
- package/dist/durable_session.d.ts +30 -0
- package/dist/durable_session.d.ts.map +1 -0
- package/dist/durable_session.js +400 -0
- package/dist/durable_session.js.map +1 -0
- package/dist/durable_subgraphs.d.ts +13 -0
- package/dist/durable_subgraphs.d.ts.map +1 -0
- package/dist/durable_subgraphs.js +82 -0
- package/dist/durable_subgraphs.js.map +1 -0
- package/dist/durable_tools.d.ts +12 -0
- package/dist/durable_tools.d.ts.map +1 -0
- package/dist/durable_tools.js +41 -0
- package/dist/durable_tools.js.map +1 -0
- package/dist/execution_session.d.ts +63 -0
- package/dist/execution_session.d.ts.map +1 -0
- package/dist/execution_session.js +300 -0
- package/dist/execution_session.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/llm_adapter.d.ts +41 -0
- package/dist/llm_adapter.d.ts.map +1 -0
- package/dist/llm_adapter.js +177 -0
- package/dist/llm_adapter.js.map +1 -0
- package/dist/messages.d.ts +56 -0
- package/dist/messages.d.ts.map +1 -0
- package/dist/messages.js +592 -0
- package/dist/messages.js.map +1 -0
- package/dist/node_logger_adapter.d.ts +51 -0
- package/dist/node_logger_adapter.d.ts.map +1 -0
- package/dist/node_logger_adapter.js +163 -0
- package/dist/node_logger_adapter.js.map +1 -0
- package/dist/platform_checkpointer.d.ts +70 -0
- package/dist/platform_checkpointer.d.ts.map +1 -0
- package/dist/platform_checkpointer.js +252 -0
- package/dist/platform_checkpointer.js.map +1 -0
- package/dist/query.d.ts +103 -0
- package/dist/query.d.ts.map +1 -0
- package/dist/query.js +623 -0
- package/dist/query.js.map +1 -0
- package/dist/runtime.d.ts +336 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +881 -0
- package/dist/runtime.js.map +1 -0
- package/dist/secure_llm.d.ts +93 -0
- package/dist/secure_llm.d.ts.map +1 -0
- package/dist/secure_llm.js +423 -0
- package/dist/secure_llm.js.map +1 -0
- package/dist/session_factory.d.ts +6 -0
- package/dist/session_factory.d.ts.map +1 -0
- package/dist/session_factory.js +29 -0
- package/dist/session_factory.js.map +1 -0
- package/dist/session_fork.d.ts +76 -0
- package/dist/session_fork.d.ts.map +1 -0
- package/dist/session_fork.js +428 -0
- package/dist/session_fork.js.map +1 -0
- package/dist/subagents.d.ts +37 -0
- package/dist/subagents.d.ts.map +1 -0
- package/dist/subagents.js +67 -0
- package/dist/subagents.js.map +1 -0
- package/dist/suspend.d.ts +27 -0
- package/dist/suspend.d.ts.map +1 -0
- package/dist/suspend.js +87 -0
- package/dist/suspend.js.map +1 -0
- package/dist/thread_id.d.ts +30 -0
- package/dist/thread_id.d.ts.map +1 -0
- package/dist/thread_id.js +69 -0
- package/dist/thread_id.js.map +1 -0
- package/dist/workflow_json.d.ts +11 -0
- package/dist/workflow_json.d.ts.map +1 -0
- package/dist/workflow_json.js +49 -0
- package/dist/workflow_json.js.map +1 -0
- package/dist/workflow_message.d.ts +11 -0
- package/dist/workflow_message.d.ts.map +1 -0
- package/dist/workflow_message.js +179 -0
- package/dist/workflow_message.js.map +1 -0
- package/dist/workflow_state.d.ts +7 -0
- package/dist/workflow_state.d.ts.map +1 -0
- package/dist/workflow_state.js +62 -0
- package/dist/workflow_state.js.map +1 -0
- package/package.json +66 -0
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LangChain SDK Runtime.
|
|
3
|
+
*
|
|
4
|
+
* Port of `agent_engine_sdk_langgraph/runtime.py`.
|
|
5
|
+
*/
|
|
6
|
+
import type { BaseChatModel } from "@langchain/core/language_models/chat_models";
|
|
7
|
+
import { type StructuredTool } from "@langchain/core/tools";
|
|
8
|
+
import { type ZodType } from "zod";
|
|
9
|
+
import { BaseApp, LLMToolSchema, type ToolDefinition } from "@mongodb-js/agent-engine-sdk";
|
|
10
|
+
import { Memory } from "@mongodb-js/agent-engine-sdk-memory";
|
|
11
|
+
import { RuntimeMode, type SessionFinishStatus } from "@mongodb-js/agent-engine-runner-shared";
|
|
12
|
+
import type { AnyBackendProtocol } from "deepagents";
|
|
13
|
+
import type { BaseCheckpointSaver } from "@langchain/langgraph";
|
|
14
|
+
import { LangGraphBaseAgent } from "./agent.js";
|
|
15
|
+
import type { PrepareAgentInput, ResolveThreadId } from "./agent.js";
|
|
16
|
+
import { createAgentEngineDeepAgent, type CreateAgentEngineDeepAgentOptions } from "./deep_agent.js";
|
|
17
|
+
import { PlatformCheckpointer } from "./platform_checkpointer.js";
|
|
18
|
+
/** Options for {@link App.deepAgent}. */
|
|
19
|
+
export interface DeepAgentOptions extends Omit<CreateAgentEngineDeepAgentOptions, "checkpointer" | "skillsBaseDir"> {
|
|
20
|
+
/**
|
|
21
|
+
* Checkpointer selection. Omitted (`undefined`) resolves to
|
|
22
|
+
* `app.checkpointer()` (MongoDB when configured, else none). `false` disables
|
|
23
|
+
* checkpointing. A `BaseCheckpointSaver` instance is used directly.
|
|
24
|
+
*
|
|
25
|
+
* Note the mapping differs from Python (`None` disables there): in TS,
|
|
26
|
+
* "disable" is `false`, and "use the default" is simply leaving it out.
|
|
27
|
+
*/
|
|
28
|
+
checkpointer?: BaseCheckpointSaver | boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Backend for filesystem/shell ops. Defaults to `AgentEngineToolPodBackend`, so
|
|
31
|
+
* every op is OE-audited and sandboxed in the Tool Pod. Pass a custom backend
|
|
32
|
+
* (e.g. deepagents' in-memory `StateBackend`) to override — note that doing so
|
|
33
|
+
* bypasses the OE audit path.
|
|
34
|
+
*/
|
|
35
|
+
backend?: AnyBackendProtocol;
|
|
36
|
+
}
|
|
37
|
+
export type ToolDefinitionData = ToolDefinition;
|
|
38
|
+
export interface AppOptions {
|
|
39
|
+
appName: string;
|
|
40
|
+
appVersion?: string;
|
|
41
|
+
mongodbUri?: string | null;
|
|
42
|
+
databaseName?: string | null;
|
|
43
|
+
tracesCollectionName?: string;
|
|
44
|
+
/** @deprecated Ignored. The org is taken from the `ORG_ID` env var, which the platform injects. */
|
|
45
|
+
orgId?: string | null;
|
|
46
|
+
}
|
|
47
|
+
export interface ToolDecoratorOptions {
|
|
48
|
+
isLocal?: boolean;
|
|
49
|
+
providerType?: string;
|
|
50
|
+
scopes?: readonly string[];
|
|
51
|
+
network?: readonly string[];
|
|
52
|
+
timeout?: number;
|
|
53
|
+
redactFields?: readonly string[];
|
|
54
|
+
/**
|
|
55
|
+
* Human-readable description shown to the LLM (mirrors Python's docstring).
|
|
56
|
+
* TypeScript has no docstring introspection, so callers pass it explicitly.
|
|
57
|
+
*/
|
|
58
|
+
description?: string;
|
|
59
|
+
/**
|
|
60
|
+
* Zod schema describing the tool's arguments. Without it, the LLM has no
|
|
61
|
+
* structured view of the parameters and tool calling will fail. Mirrors the
|
|
62
|
+
* type hints + Pydantic-style auto-schema that Python's `@app.tool()`
|
|
63
|
+
* derives from the function signature.
|
|
64
|
+
*/
|
|
65
|
+
schema?: ZodType;
|
|
66
|
+
/** Override the registered tool name. Defaults to the wrapped function's `name`. */
|
|
67
|
+
name?: string;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* LangChain SDK for the Atlas Agent Engine.
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```ts
|
|
74
|
+
* import { App } from '@mongodb-js/agent-engine-sdk-langgraph';
|
|
75
|
+
*
|
|
76
|
+
* const app = new App({ appName: 'My Agent' });
|
|
77
|
+
*
|
|
78
|
+
* app.tool()((args: { query: string }) => 'result');
|
|
79
|
+
*
|
|
80
|
+
* app.entrypoint(() => {
|
|
81
|
+
* const llm = app.llm(chatModel);
|
|
82
|
+
* const checkpointer = app.checkpointer();
|
|
83
|
+
* const tools = app.getTools();
|
|
84
|
+
* // Build LangGraph...
|
|
85
|
+
* return graph;
|
|
86
|
+
* });
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
export declare class App extends BaseApp {
|
|
90
|
+
private readonly runtime;
|
|
91
|
+
private builderFn;
|
|
92
|
+
private graphCache;
|
|
93
|
+
private prepareInputFn;
|
|
94
|
+
private resolveThreadIdFn;
|
|
95
|
+
private readonly toolDefs;
|
|
96
|
+
private readonly lcTools;
|
|
97
|
+
private mongoClient;
|
|
98
|
+
private _checkpointer;
|
|
99
|
+
private readonly mcpToolsReady;
|
|
100
|
+
private resolvedCheckpointDb;
|
|
101
|
+
private _memory;
|
|
102
|
+
/**
|
|
103
|
+
* Unified memory facade over app-bound adapters.
|
|
104
|
+
*
|
|
105
|
+
* Lazily constructed on first access and cached (a long-lived singleton over
|
|
106
|
+
* per-request context). Operations resolve the end-user and session from the
|
|
107
|
+
* ambient execution context, so agent code calls `app.memory.saveSemantic(...)`
|
|
108
|
+
* without threading identity through. Requests route through the OE memory
|
|
109
|
+
* proxy; memory is reachable only while handling a platform request.
|
|
110
|
+
*/
|
|
111
|
+
get memory(): Memory;
|
|
112
|
+
constructor(options: AppOptions);
|
|
113
|
+
/**
|
|
114
|
+
* Resolved once configured MCP servers have been discovered and registered
|
|
115
|
+
* as tools. `TenantRuntime.runAsync()` awaits this (via `GraphBuilderLike.ready()`)
|
|
116
|
+
* before starting the server.
|
|
117
|
+
*/
|
|
118
|
+
ready(): Promise<void>;
|
|
119
|
+
/**
|
|
120
|
+
* Discover configured MCP servers' tools and register them the same way
|
|
121
|
+
* `App.tool()` registers author-declared tools. Port of Python's
|
|
122
|
+
* `_register_mcp_tools_from_config`.
|
|
123
|
+
*/
|
|
124
|
+
private registerMcpTools;
|
|
125
|
+
get agentConfig(): ReturnType<typeof this.runtime.getAgentConfig>;
|
|
126
|
+
getToolDefinitions(): ToolDefinitionData[];
|
|
127
|
+
tools(): unknown[];
|
|
128
|
+
private registerToolDefinition;
|
|
129
|
+
/**
|
|
130
|
+
* Register a tool function.
|
|
131
|
+
*
|
|
132
|
+
* Returns a function that, when applied to a tool function, registers it
|
|
133
|
+
* and returns the function unchanged. Mirrors Python's `@app.tool()` shape.
|
|
134
|
+
*/
|
|
135
|
+
tool(options?: ToolDecoratorOptions): <F extends (...input: never[]) => unknown>(fn: F) => F;
|
|
136
|
+
/** Mark the graph builder function. */
|
|
137
|
+
entrypoint<F extends () => unknown>(fn: F): F;
|
|
138
|
+
/**
|
|
139
|
+
* Register a hook that builds the graph's starting input from the caller's
|
|
140
|
+
* `AgentInput` and `RequestContext` for a fresh execution. Resume stays
|
|
141
|
+
* platform-managed. Returns the function unchanged so it can be used as a
|
|
142
|
+
* decorator. Equivalent to the Python SDK's `@app.prepare_agent_input`.
|
|
143
|
+
*/
|
|
144
|
+
prepareAgentInput<F extends PrepareAgentInput>(fn: F): F;
|
|
145
|
+
/**
|
|
146
|
+
* Register a hook that builds the LangGraph checkpoint `thread_id`.
|
|
147
|
+
*
|
|
148
|
+
* Callers manage Atlas Agent Engine `session_id` (and authenticated `user_id`). The
|
|
149
|
+
* agent owns how those map to the LangGraph checkpoint key. When registered,
|
|
150
|
+
* the hook's return value is used verbatim on every invocation — fresh and
|
|
151
|
+
* resume — with no workspace suffix appended. When no hook is registered,
|
|
152
|
+
* the adapter derives `session_id:workspace_id` as today.
|
|
153
|
+
*
|
|
154
|
+
* Custom keys are invisible to Atlas Agent Engine session-history queries
|
|
155
|
+
* (`/query/sessions*`), which still look up only the default
|
|
156
|
+
* session/workspace-derived keys. Agents that bypass workspace scoping also
|
|
157
|
+
* own collision isolation within the checkpoint database.
|
|
158
|
+
*
|
|
159
|
+
* Equivalent to the Python SDK's `@app.resolve_thread_id`.
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* ```ts
|
|
163
|
+
* app.resolveThreadId((ctx) => `${ctx.sessionId}__${actorFrom(ctx.userId)}`);
|
|
164
|
+
* ```
|
|
165
|
+
*/
|
|
166
|
+
resolveThreadId<F extends ResolveThreadId>(fn: F): F;
|
|
167
|
+
/**
|
|
168
|
+
* Build and return a `LangGraphBaseAgent` instance.
|
|
169
|
+
*
|
|
170
|
+
* Matches `GraphBuilderLike.getAgent({ callbacks? })` — agent-engine-runner-shared's
|
|
171
|
+
* `TenantRuntime.registerAndRun` introspects this method to compile the graph.
|
|
172
|
+
* Accepts an options object with an optional `callbacks` array, each wrapped
|
|
173
|
+
* in `LangGraphCallbackAdapter` before being passed to the graph.
|
|
174
|
+
*/
|
|
175
|
+
getAgent(opts?: {
|
|
176
|
+
callbacks?: readonly unknown[];
|
|
177
|
+
}): LangGraphBaseAgent;
|
|
178
|
+
/**
|
|
179
|
+
* Return the materialized graph, building it at most once.
|
|
180
|
+
*
|
|
181
|
+
* `getAgent()` used to call the entrypoint on every `/execute` — real,
|
|
182
|
+
* measurable first-invoke latency. The graph carries no per-request
|
|
183
|
+
* state (callbacks/agent wrapper are still rebuilt fresh by every
|
|
184
|
+
* `getAgent()` call), so caching it is safe.
|
|
185
|
+
*/
|
|
186
|
+
private getOrBuildGraph;
|
|
187
|
+
/**
|
|
188
|
+
* Build and cache the graph when explicitly requested. The TypeScript AER
|
|
189
|
+
* intentionally leaves construction on the existing lazy `/execute` path:
|
|
190
|
+
* this synchronous builder cannot run during standby warming without
|
|
191
|
+
* blocking the Node event loop and server health.
|
|
192
|
+
*/
|
|
193
|
+
warmUp(): void;
|
|
194
|
+
/**
|
|
195
|
+
* Start the agent service.
|
|
196
|
+
*
|
|
197
|
+
* Async because the per-project store-DB name is resolved against the live
|
|
198
|
+
* cluster (an async listDatabases round trip in the Node driver) before the
|
|
199
|
+
* query plugin and checkpointer are wired, so AER writes land in the same
|
|
200
|
+
* database the OE reads. The synchronous framework hooks are still registered
|
|
201
|
+
* before the first `await`, preserving their ordering relative to startup.
|
|
202
|
+
*/
|
|
203
|
+
run(options?: Record<string, unknown>): Promise<void>;
|
|
204
|
+
/**
|
|
205
|
+
* Resolve the store DB name once, before the checkpointer and query plugin
|
|
206
|
+
* are constructed. Honors `CHECKPOINT_DB_NAME` as an exact override (no
|
|
207
|
+
* project scoping). No-op outside AER mode or without a MongoDB URI when
|
|
208
|
+
* the override is unset (the checkpointer returns null in those cases).
|
|
209
|
+
*/
|
|
210
|
+
private resolveCheckpointDbName;
|
|
211
|
+
/**
|
|
212
|
+
* Exact `CHECKPOINT_DB_NAME` override when set, else null.
|
|
213
|
+
* Shared by resolve / checkpointer / query plugin so the three paths cannot
|
|
214
|
+
* drift on trim/precedence.
|
|
215
|
+
*/
|
|
216
|
+
private checkpointDbOverride;
|
|
217
|
+
/**
|
|
218
|
+
* Final MongoDBSaver / query-plugin database name for this app.
|
|
219
|
+
* Prefer the exact env override; otherwise the resolved (or base) store DB.
|
|
220
|
+
*/
|
|
221
|
+
private checkpointDbName;
|
|
222
|
+
/**
|
|
223
|
+
* Register the LangGraph-backed `AERQueryPlugin` (AER mode only). A
|
|
224
|
+
* missing MongoDB URI or a failing checkpointer construction degrades to
|
|
225
|
+
* "no plugin" (routes return 501) instead of failing startup.
|
|
226
|
+
*/
|
|
227
|
+
private registerQueryPlugin;
|
|
228
|
+
/**
|
|
229
|
+
* Register framework-specific hooks so agent-engine-runner-shared can dispatch to
|
|
230
|
+
* LangChain/LangGraph code without importing this package. Mirrors Python's
|
|
231
|
+
* `App._register_hooks` (static method).
|
|
232
|
+
*/
|
|
233
|
+
private static registerHooks;
|
|
234
|
+
/**
|
|
235
|
+
* Wrap a LangChain LLM for audited I/O through the Orchestration Engine.
|
|
236
|
+
*
|
|
237
|
+
* In AER mode the LLM is wrapped in `SecureWrappedLLM`. In TOOL mode the raw
|
|
238
|
+
* LLM is returned unwrapped (the tool pod is the execution end of the chain).
|
|
239
|
+
*
|
|
240
|
+
* For agents with a single LLM, call without `llmId`. For agents with
|
|
241
|
+
* multiple LLMs every call must supply a unique `llmId`:
|
|
242
|
+
* const fast = app.llm(ChatOpenAI("gpt-5.4-mini"), "fast")
|
|
243
|
+
* const primary = app.llm(ChatOpenAI("gpt-5.4"), "primary")
|
|
244
|
+
* Unnamed calls register under the sentinel id `"__default__"`; a second
|
|
245
|
+
* unnamed call therefore raises the same duplicate-id error as a second
|
|
246
|
+
* named call with the same id.
|
|
247
|
+
*/
|
|
248
|
+
llm(llm: BaseChatModel, llmId?: string): BaseChatModel;
|
|
249
|
+
/**
|
|
250
|
+
* Get the platform checkpointer for LangGraph.
|
|
251
|
+
*
|
|
252
|
+
* Lazily constructs and wraps a `MongoDBSaver` on first call in AER mode.
|
|
253
|
+
* Native sessions use that saver through the request-scoped platform
|
|
254
|
+
* wrapper. The underlying `MongoClient` is closed by `App.close()`.
|
|
255
|
+
*
|
|
256
|
+
* The database name is read from `CHECKPOINT_DB_NAME` when set (exact
|
|
257
|
+
* override, no project scoping). Otherwise the existing
|
|
258
|
+
* `MDB_AGENTIC_STORE_DB` / per-project store resolution is used
|
|
259
|
+
* (default: `"mdb_store"`). The URI comes from `MONGODB_URI` — the same
|
|
260
|
+
* source `TenantRuntime` uses internally.
|
|
261
|
+
*
|
|
262
|
+
* Mirrors Python `runtime.py:checkpointer()`.
|
|
263
|
+
*/
|
|
264
|
+
checkpointer(): PlatformCheckpointer | null;
|
|
265
|
+
/**
|
|
266
|
+
* Build a deepagents graph pre-wired for Atlas Agent Engine AER.
|
|
267
|
+
*
|
|
268
|
+
* Wraps `llm` in `SecureWrappedLLM`, resolves relative skill paths, validates
|
|
269
|
+
* the subagent tree (string models are rejected — they would bypass OE
|
|
270
|
+
* routing), then delegates to deepagents' `createDeepAgent`.
|
|
271
|
+
*
|
|
272
|
+
* Each `skills` entry is a parent source directory. At runtime, deepagents
|
|
273
|
+
* lists it through the configured backend and treats each immediate child
|
|
274
|
+
* directory containing `SKILL.md` as one skill; discovery is not recursive.
|
|
275
|
+
* deepagents skips unreadable or unparsable frontmatter and skills missing
|
|
276
|
+
* `name` or `description`; it warns but may still load Agent Skills naming or
|
|
277
|
+
* directory-name violations.
|
|
278
|
+
*
|
|
279
|
+
* Mirrors Python `runtime.py:App.deep_agent()`.
|
|
280
|
+
*
|
|
281
|
+
* @throws {Error} `features.deep_agent` is not enabled, or a subagent spec
|
|
282
|
+
* uses a string model, or nesting exceeds the recursion cap.
|
|
283
|
+
*/
|
|
284
|
+
deepAgent(llm: BaseChatModel, options?: DeepAgentOptions): ReturnType<typeof createAgentEngineDeepAgent>;
|
|
285
|
+
/**
|
|
286
|
+
* Resolve the base directory for relative skill paths: the directory
|
|
287
|
+
* containing `agent.yaml`, optionally narrowed by the source-root-relative
|
|
288
|
+
* `AGENTIC_SKILLS_DIR` override.
|
|
289
|
+
*/
|
|
290
|
+
private resolveSkillsBaseDir;
|
|
291
|
+
/** Release resources held by this App instance. */
|
|
292
|
+
close(): Promise<void>;
|
|
293
|
+
/**
|
|
294
|
+
* Get wrapped tools for LangGraph's `ToolNode`.
|
|
295
|
+
*
|
|
296
|
+
* In AER mode, every tool is wrapped with `SecureToolWrapper` (via
|
|
297
|
+
* `createSecureToolFunction`) so executions route through OE for logging
|
|
298
|
+
* and policy enforcement. In other modes, the raw LangChain tools are
|
|
299
|
+
* returned unchanged.
|
|
300
|
+
*/
|
|
301
|
+
getTools(): readonly StructuredTool[];
|
|
302
|
+
/** Get tool schemas for `llm.bindTools()`. Always the unwrapped LangChain tools. */
|
|
303
|
+
getToolSchemas(): readonly unknown[];
|
|
304
|
+
/**
|
|
305
|
+
* Generate a suspend command. If a tool should suspend, return the result of
|
|
306
|
+
* this method instead of completing normally.
|
|
307
|
+
*/
|
|
308
|
+
suspend(reason: string, context: Record<string, unknown>): string;
|
|
309
|
+
/**
|
|
310
|
+
* Mark this session finished so the platform frees its compute now.
|
|
311
|
+
*
|
|
312
|
+
* Call it when the agent is done with the session. The current turn keeps
|
|
313
|
+
* running and returns its result normally; once it completes, the platform
|
|
314
|
+
* cancels any live sub-agent runs and releases the session's AER and tool
|
|
315
|
+
* pods instead of holding them until the idle timeout expires.
|
|
316
|
+
*
|
|
317
|
+
* Safe to call more than once: the first call returns "requested", later
|
|
318
|
+
* ones "already_requested". Outside an agent run (local scripts, tool pods)
|
|
319
|
+
* there is no session to finish and the call returns "unavailable" without
|
|
320
|
+
* throwing. Calling it after the turn has already ended - e.g. from a
|
|
321
|
+
* setTimeout or a floating promise scheduled during the turn but resolving
|
|
322
|
+
* after it - also returns "unavailable": by then nothing is listening for
|
|
323
|
+
* the request anymore, so reporting "requested" would promise a release
|
|
324
|
+
* that will never happen.
|
|
325
|
+
*
|
|
326
|
+
* A turn that suspends for human review, or that fails, keeps its
|
|
327
|
+
* resources so it stays resumable and diagnosable; the session then falls
|
|
328
|
+
* back to the idle timeout.
|
|
329
|
+
*/
|
|
330
|
+
finishSession(): SessionFinishStatus;
|
|
331
|
+
getCurrentUserId(): string | null;
|
|
332
|
+
getCurrentSessionId(): string | null;
|
|
333
|
+
}
|
|
334
|
+
export { LLMToolSchema };
|
|
335
|
+
export { RuntimeMode };
|
|
336
|
+
//# sourceMappingURL=runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC;AAEjF,OAAO,EAAkB,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAI5E,OAAO,EAAK,KAAK,OAAO,EAAE,MAAM,KAAK,CAAC;AAEtC,OAAO,EACL,OAAO,EAEP,aAAa,EACb,KAAK,cAAc,EACpB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC7D,OAAO,EA4BL,WAAW,EACX,KAAK,mBAAmB,EAWzB,MAAM,wCAAwC,CAAC;AAChD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAGhE,OAAO,EAAE,kB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