@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
package/dist/query.d.ts
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LangGraph-backed implementation of runner-shared's `AERQueryPlugin`.
|
|
3
|
+
*
|
|
4
|
+
* Reads from the same MongoDB collections that LangGraph's `MongoDBSaver`
|
|
5
|
+
* writes to (`checkpoints`, `checkpoint_writes`). Deserialization is
|
|
6
|
+
* delegated to the saver's `serde` so this code does not need to know how
|
|
7
|
+
* LangGraph encodes state on disk.
|
|
8
|
+
*
|
|
9
|
+
* Port of Python's `agent_engine_sdk_langgraph/query.py`. One structural
|
|
10
|
+
* difference: the JS `MongoDBSaver` keeps its `Db` handle protected, so the
|
|
11
|
+
* plugin is constructed with the `MongoClient` + database name instead.
|
|
12
|
+
*
|
|
13
|
+
* Checkpoints are keyed by a workspace-scoped `thread_id` — see
|
|
14
|
+
* `thread_id.ts`. The plugin composes that scope onto the plain `session_id`
|
|
15
|
+
* it receives before querying, and strips it back off before returning.
|
|
16
|
+
* Reads never query the bare unscoped key when a workspace scope is known:
|
|
17
|
+
* bare keys are shared across every workspace on the store.
|
|
18
|
+
* An empty scope is legitimate only on explicitly unscoped runtimes (local
|
|
19
|
+
* dev / tests, no `APP_ID`), whose writes are bare-keyed to match. Managed
|
|
20
|
+
* runtimes carry `REQUIRE_PROJECT_SCOPED_DB` and reject a missing `APP_ID`.
|
|
21
|
+
*/
|
|
22
|
+
import type { MongoClient } from "mongodb";
|
|
23
|
+
import type { MongoDBSaver } from "@langchain/langgraph-checkpoint-mongodb";
|
|
24
|
+
import { type SessionMessagesResponse, type SessionsSummaryResponse } from "@mongodb-js/agent-engine-sdk";
|
|
25
|
+
export interface LangGraphQueryPluginParams {
|
|
26
|
+
saver: MongoDBSaver;
|
|
27
|
+
client: MongoClient;
|
|
28
|
+
dbName: string;
|
|
29
|
+
workspaceId?: string;
|
|
30
|
+
workspaceIdResolver?: () => string | null | undefined;
|
|
31
|
+
}
|
|
32
|
+
/** AERQueryPlugin backed by LangGraph's MongoDBSaver. */
|
|
33
|
+
export declare class LangGraphQueryPlugin {
|
|
34
|
+
private readonly saver;
|
|
35
|
+
private readonly checkpointsCollection;
|
|
36
|
+
private readonly writesCollection;
|
|
37
|
+
private readonly workspaceId;
|
|
38
|
+
private readonly workspaceIdResolver;
|
|
39
|
+
constructor(params: LangGraphQueryPluginParams);
|
|
40
|
+
/**
|
|
41
|
+
* Resolve the workspace scope for a read. "" is a legitimate scope — an
|
|
42
|
+
* explicitly unscoped runtime (local dev / tests, no APP_ID) whose
|
|
43
|
+
* checkpoints are bare-keyed by construction, matching the write path. The
|
|
44
|
+
* runner rejects this state when managed-runtime scoping is required. A
|
|
45
|
+
* resolver returning null/undefined signals a genuinely unresolvable scope
|
|
46
|
+
* (a custom resolver that cannot make that call) and fails closed rather
|
|
47
|
+
* than silently reading the shared store.
|
|
48
|
+
*/
|
|
49
|
+
private effectiveWorkspaceId;
|
|
50
|
+
getSummariesForSessions(sessionIds: string[]): Promise<SessionsSummaryResponse>;
|
|
51
|
+
getMessagesForSession(sessionId: string): Promise<SessionMessagesResponse>;
|
|
52
|
+
/**
|
|
53
|
+
* Resolve a session's authoritative message list: the `messages` channel of
|
|
54
|
+
* the most recent checkpoint that carries a usable one, plus each message
|
|
55
|
+
* index's first-appearance timestamp. Returns null when no checkpoint has a
|
|
56
|
+
* usable `messages` channel.
|
|
57
|
+
*
|
|
58
|
+
* Both the messages endpoint and the sessions-list `message_count` derive
|
|
59
|
+
* from this so the two always agree — `message_count` reports the
|
|
60
|
+
* number of messages, not the number of checkpoints.
|
|
61
|
+
*/
|
|
62
|
+
private loadAuthoritativeMessages;
|
|
63
|
+
/**
|
|
64
|
+
* Materialize a bounded checkpoint window across one or more thread keys.
|
|
65
|
+
*
|
|
66
|
+
* The scan is wrapped in a wall-clock deadline rather than checked between
|
|
67
|
+
* yields: the driver's `MongoClient` is constructed without socket/read
|
|
68
|
+
* timeouts, so a stalled cursor can leave the `for await` parked forever and
|
|
69
|
+
* an in-loop clock check would never run.
|
|
70
|
+
*/
|
|
71
|
+
private collectCheckpointsForThreadIds;
|
|
72
|
+
private streamCheckpointsForThreadIds;
|
|
73
|
+
private aggregateSessionSummaries;
|
|
74
|
+
/**
|
|
75
|
+
* Count messages per session from the same authoritative list the messages
|
|
76
|
+
* endpoint returns, so a summary's `message_count` matches that endpoint
|
|
77
|
+
* exactly. Sessions with no usable checkpoint count as 0.
|
|
78
|
+
*
|
|
79
|
+
* Unlike the single-session messages endpoint — where a corrupt checkpoint
|
|
80
|
+
* rightly surfaces as a 500 — a failed read here degrades that one session's
|
|
81
|
+
* count to 0 and leaves the rest of the list intact. One unreadable session
|
|
82
|
+
* must not take down a summaries request naming hundreds of others.
|
|
83
|
+
*/
|
|
84
|
+
private collectMessageCounts;
|
|
85
|
+
private collectPreviews;
|
|
86
|
+
/**
|
|
87
|
+
* Return the first non-empty human-message preview across `writes`.
|
|
88
|
+
*
|
|
89
|
+
* `writes` is the per-session accumulation from the preview pipeline,
|
|
90
|
+
* ordered oldest-first. Returns `""` if no write decodes to a human
|
|
91
|
+
* message with text content.
|
|
92
|
+
*/
|
|
93
|
+
private firstNonEmptyHumanPreview;
|
|
94
|
+
/**
|
|
95
|
+
* Decode a single `checkpoint_writes` document and return the first
|
|
96
|
+
* human-authored text content it contains, truncated.
|
|
97
|
+
*
|
|
98
|
+
* Returns `""` for non-human writes, malformed writes, and any
|
|
99
|
+
* deserialization failures (logged at WARNING for observability).
|
|
100
|
+
*/
|
|
101
|
+
private decodeHumanPreview;
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=query.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAwB,WAAW,EAAE,MAAM,SAAS,CAAC;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AAC5E,OAAO,EAIL,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAE7B,MAAM,8BAA8B,CAAC;AAwDtC,MAAM,WAAW,0BAA0B;IACzC,KAAK,EAAE,YAAY,CAAC;IACpB,MAAM,EAAE,WAAW,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mBAAmB,CAAC,EAAE,MAAM,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;CACvD;AAED,yDAAyD;AACzD,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAe;IACrC,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAuB;IAC7D,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAuB;IACxD,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAEtB;gBAEF,MAAM,EAAE,0BAA0B;IAa9C;;;;;;;;OAQG;IACH,OAAO,CAAC,oBAAoB;IActB,uBAAuB,CAC3B,UAAU,EAAE,MAAM,EAAE,GACnB,OAAO,CAAC,uBAAuB,CAAC;IAS7B,qBAAqB,CACzB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,uBAAuB,CAAC;IAmBnC;;;;;;;;;OASG;YACW,yBAAyB;IAqCvC;;;;;;;OAOG;YACW,8BAA8B;YAU9B,6BAA6B;YAuB7B,yBAAyB;IA0CvC;;;;;;;;;OASG;YACW,oBAAoB;YAgCpB,eAAe;IAsC7B;;;;;;OAMG;YACW,yBAAyB;IAWvC;;;;;;OAMG;YACW,kBAAkB;CAiCjC"}
|