@librechat/agents 3.6.2 → 3.6.4
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/cjs/graphs/Graph.cjs +35 -20
- package/dist/cjs/graphs/Graph.cjs.map +1 -1
- package/dist/cjs/hooks/HookRegistry.cjs +7 -1
- package/dist/cjs/hooks/HookRegistry.cjs.map +1 -1
- package/dist/cjs/hooks/index.cjs +1 -1
- package/dist/cjs/llm/openai/index.cjs +36 -0
- package/dist/cjs/llm/openai/index.cjs.map +1 -1
- package/dist/cjs/main.cjs +4 -1
- package/dist/cjs/messages/core.cjs +3 -0
- package/dist/cjs/messages/core.cjs.map +1 -1
- package/dist/cjs/run.cjs +11 -5
- package/dist/cjs/run.cjs.map +1 -1
- package/dist/cjs/tools/SubagentTool.cjs +8 -3
- package/dist/cjs/tools/SubagentTool.cjs.map +1 -1
- package/dist/cjs/tools/ToolNode.cjs +1 -1
- package/dist/cjs/tools/subagent/InMemorySubagentTaskStore.cjs +399 -0
- package/dist/cjs/tools/subagent/InMemorySubagentTaskStore.cjs.map +1 -0
- package/dist/cjs/tools/subagent/SubagentExecutor.cjs +168 -60
- package/dist/cjs/tools/subagent/SubagentExecutor.cjs.map +1 -1
- package/dist/cjs/tools/subagent/index.cjs +1 -0
- package/dist/esm/graphs/Graph.mjs +35 -20
- package/dist/esm/graphs/Graph.mjs.map +1 -1
- package/dist/esm/hooks/HookRegistry.mjs +7 -1
- package/dist/esm/hooks/HookRegistry.mjs.map +1 -1
- package/dist/esm/hooks/index.mjs +1 -1
- package/dist/esm/llm/openai/index.mjs +37 -1
- package/dist/esm/llm/openai/index.mjs.map +1 -1
- package/dist/esm/main.mjs +4 -3
- package/dist/esm/messages/core.mjs +3 -1
- package/dist/esm/messages/core.mjs.map +1 -1
- package/dist/esm/run.mjs +11 -5
- package/dist/esm/run.mjs.map +1 -1
- package/dist/esm/tools/SubagentTool.mjs +8 -3
- package/dist/esm/tools/SubagentTool.mjs.map +1 -1
- package/dist/esm/tools/ToolNode.mjs +1 -1
- package/dist/esm/tools/subagent/InMemorySubagentTaskStore.mjs +399 -0
- package/dist/esm/tools/subagent/InMemorySubagentTaskStore.mjs.map +1 -0
- package/dist/esm/tools/subagent/SubagentExecutor.mjs +168 -60
- package/dist/esm/tools/subagent/SubagentExecutor.mjs.map +1 -1
- package/dist/esm/tools/subagent/index.mjs +1 -0
- package/dist/types/graphs/Graph.d.ts +6 -3
- package/dist/types/hooks/HookRegistry.d.ts +8 -0
- package/dist/types/messages/core.d.ts +2 -0
- package/dist/types/run.d.ts +1 -0
- package/dist/types/tools/SubagentTool.d.ts +3 -1
- package/dist/types/tools/subagent/InMemorySubagentTaskStore.d.ts +45 -0
- package/dist/types/tools/subagent/SubagentExecutor.d.ts +26 -3
- package/dist/types/tools/subagent/index.d.ts +2 -0
- package/dist/types/types/graph.d.ts +11 -4
- package/dist/types/types/index.d.ts +1 -0
- package/dist/types/types/run.d.ts +6 -0
- package/dist/types/types/subagentTasks.d.ts +140 -0
- package/package.json +4 -4
- package/src/graphs/Graph.ts +84 -36
- package/src/hooks/HookRegistry.ts +18 -0
- package/src/llm/openai/index.ts +96 -0
- package/src/messages/core.ts +5 -0
- package/src/run.ts +20 -5
- package/src/tools/SubagentTool.ts +20 -2
- package/src/tools/subagent/InMemorySubagentTaskStore.ts +624 -0
- package/src/tools/subagent/SubagentExecutor.ts +341 -74
- package/src/tools/subagent/index.ts +2 -0
- package/src/types/graph.ts +11 -4
- package/src/types/index.ts +1 -0
- package/src/types/run.ts +6 -0
- package/src/types/subagentTasks.ts +129 -0
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import type { BaseMessage } from '@langchain/core/messages';
|
|
2
|
+
import type { SubagentUpdateEvent } from './graph';
|
|
3
|
+
import type { InjectedMessage } from './tools';
|
|
4
|
+
|
|
5
|
+
/** Terminal and in-flight states for a detached subagent task. */
|
|
6
|
+
export type SubagentTaskStatus =
|
|
7
|
+
| 'running'
|
|
8
|
+
| 'completed'
|
|
9
|
+
| 'error'
|
|
10
|
+
| 'cancelled';
|
|
11
|
+
|
|
12
|
+
/** Where a pending parent message may enter the child run. */
|
|
13
|
+
export type SubagentTaskBoundary = 'preempt' | 'tool' | 'turn';
|
|
14
|
+
|
|
15
|
+
/** Parent-to-child control operations accepted while a task is running. */
|
|
16
|
+
export type SubagentTaskControlCommand =
|
|
17
|
+
| { action: 'steer' | 'queue' | 'interrupt'; message: string }
|
|
18
|
+
| { action: 'cancel' }
|
|
19
|
+
| { action: 'cancel_message'; controlId: string };
|
|
20
|
+
|
|
21
|
+
/** Small, payload-free progress view safe to retain between parent turns. */
|
|
22
|
+
export interface SubagentTaskProgress {
|
|
23
|
+
phase: SubagentUpdateEvent['phase'];
|
|
24
|
+
at: number;
|
|
25
|
+
eventCount: number;
|
|
26
|
+
label?: string;
|
|
27
|
+
}
|
|
28
|
+
/** Read-only task metadata. Results are exposed only through `claim`. */
|
|
29
|
+
export interface SubagentTaskSnapshot {
|
|
30
|
+
/** Handle for this child-conversation execution within its trusted scope. */
|
|
31
|
+
taskId: string;
|
|
32
|
+
subagentType: string;
|
|
33
|
+
status: SubagentTaskStatus;
|
|
34
|
+
createdAt: number;
|
|
35
|
+
updatedAt: number;
|
|
36
|
+
resultAvailable: boolean;
|
|
37
|
+
resultClaimed: boolean;
|
|
38
|
+
pendingControls: number;
|
|
39
|
+
progress?: SubagentTaskProgress;
|
|
40
|
+
error?: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export type SubagentTaskClaim =
|
|
44
|
+
| { status: 'running'; task: SubagentTaskSnapshot }
|
|
45
|
+
| { status: 'completed'; task: SubagentTaskSnapshot; result: string }
|
|
46
|
+
| { status: 'error'; task: SubagentTaskSnapshot; error: string }
|
|
47
|
+
| { status: 'cancelled'; task: SubagentTaskSnapshot; error: string }
|
|
48
|
+
| { status: 'claimed'; task: SubagentTaskSnapshot }
|
|
49
|
+
| { status: 'not_found' };
|
|
50
|
+
|
|
51
|
+
export type SubagentTaskControlResult =
|
|
52
|
+
| {
|
|
53
|
+
status: 'accepted';
|
|
54
|
+
task: SubagentTaskSnapshot;
|
|
55
|
+
controlId?: string;
|
|
56
|
+
}
|
|
57
|
+
| { status: 'cancelled'; task: SubagentTaskSnapshot }
|
|
58
|
+
| { status: 'not_running'; task: SubagentTaskSnapshot }
|
|
59
|
+
| { status: 'not_found' }
|
|
60
|
+
| { status: 'control_not_found'; task: SubagentTaskSnapshot }
|
|
61
|
+
| { status: 'invalid'; message: string };
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Child-side view supplied to one detached execution. It intentionally owns
|
|
65
|
+
* only cancellation, bounded message drains, and payload-free progress — no
|
|
66
|
+
* request/response object or host transport can leak into retained task state.
|
|
67
|
+
*/
|
|
68
|
+
export interface SubagentTaskRuntime {
|
|
69
|
+
readonly taskId: string;
|
|
70
|
+
readonly signal: AbortSignal;
|
|
71
|
+
shouldPreempt(): boolean;
|
|
72
|
+
drain(boundary: SubagentTaskBoundary): InjectedMessage[];
|
|
73
|
+
closeTurn(): { closed: boolean; messages: InjectedMessage[] };
|
|
74
|
+
reportProgress(event: SubagentUpdateEvent): void;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export interface SubagentTaskStartRequest {
|
|
78
|
+
scopeId: string;
|
|
79
|
+
idempotencyKey: string;
|
|
80
|
+
/** Stable hash of model-writable inputs used to reject conflicting replays. */
|
|
81
|
+
requestFingerprint?: string;
|
|
82
|
+
subagentType: string;
|
|
83
|
+
/**
|
|
84
|
+
* Starts one ephemeral execution lease. The canonical child transcript is
|
|
85
|
+
* returned so a host-owned store may persist it for a later fresh run;
|
|
86
|
+
* retaining a graph/checkpoint after terminal completion is unnecessary.
|
|
87
|
+
*/
|
|
88
|
+
run(runtime: SubagentTaskRuntime): Promise<{
|
|
89
|
+
content: string;
|
|
90
|
+
messages?: BaseMessage[];
|
|
91
|
+
}>;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export type SubagentTaskStartResult =
|
|
95
|
+
| {
|
|
96
|
+
accepted: true;
|
|
97
|
+
isNew: boolean;
|
|
98
|
+
task: SubagentTaskSnapshot;
|
|
99
|
+
}
|
|
100
|
+
| { accepted: false; reason: 'capacity' }
|
|
101
|
+
| {
|
|
102
|
+
accepted: false;
|
|
103
|
+
reason: 'conflict';
|
|
104
|
+
task: SubagentTaskSnapshot;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Host-replaceable store contract used by the SDK's subagent tool. The store
|
|
109
|
+
* should normally outlive individual `Run` instances. Durable hosts may
|
|
110
|
+
* persist the transcript returned by `run` under the task/conversation
|
|
111
|
+
* lineage and start a fresh execution for a later turn.
|
|
112
|
+
*/
|
|
113
|
+
export interface SubagentTaskStore {
|
|
114
|
+
start(request: SubagentTaskStartRequest): SubagentTaskStartResult;
|
|
115
|
+
get(scopeId: string, taskId: string): SubagentTaskSnapshot | undefined;
|
|
116
|
+
list(scopeId: string): SubagentTaskSnapshot[];
|
|
117
|
+
claim(scopeId: string, taskId: string): SubagentTaskClaim;
|
|
118
|
+
control(
|
|
119
|
+
scopeId: string,
|
|
120
|
+
taskId: string,
|
|
121
|
+
command: SubagentTaskControlCommand
|
|
122
|
+
): SubagentTaskControlResult;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** Trusted, host-selected task namespace. It is never model-writable. */
|
|
126
|
+
export interface SubagentTaskConfig {
|
|
127
|
+
store: SubagentTaskStore;
|
|
128
|
+
scopeId: string;
|
|
129
|
+
}
|