@botbotgo/agent-harness 0.0.96 → 0.0.98
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/api.d.ts +5 -5
- package/dist/contracts/core.d.ts +9 -0
- package/dist/contracts/core.js +1 -0
- package/dist/contracts/runtime.d.ts +421 -0
- package/dist/contracts/runtime.js +1 -0
- package/dist/contracts/types.d.ts +3 -653
- package/dist/contracts/types.js +3 -1
- package/dist/contracts/workspace.d.ts +229 -0
- package/dist/contracts/workspace.js +1 -0
- package/dist/package-version.d.ts +1 -1
- package/dist/package-version.js +1 -1
- package/dist/runtime/adapter/compat/deepagent-compat.d.ts +16 -0
- package/dist/runtime/adapter/compat/deepagent-compat.js +45 -0
- package/dist/runtime/adapter/compat/openai-compatible.d.ts +2 -0
- package/dist/runtime/adapter/compat/openai-compatible.js +43 -0
- package/dist/runtime/adapter/index.d.ts +15 -0
- package/dist/runtime/adapter/index.js +15 -0
- package/dist/runtime/{langgraph-profiles.d.ts → adapter/langgraph/profiles.d.ts} +1 -1
- package/dist/runtime/adapter/model/invocation-request.d.ts +10 -0
- package/dist/runtime/adapter/model/invocation-request.js +46 -0
- package/dist/runtime/adapter/model/message-assembly.d.ts +6 -0
- package/dist/runtime/adapter/model/message-assembly.js +21 -0
- package/dist/runtime/adapter/model/model-providers.d.ts +2 -0
- package/dist/runtime/adapter/model/model-providers.js +27 -0
- package/dist/runtime/adapter/resilience.d.ts +12 -0
- package/dist/runtime/adapter/resilience.js +60 -0
- package/dist/runtime/{declared-middleware.d.ts → adapter/tool/declared-middleware.d.ts} +1 -1
- package/dist/runtime/adapter/tool/interrupt-policy.d.ts +8 -0
- package/dist/runtime/adapter/tool/interrupt-policy.js +34 -0
- package/dist/runtime/adapter/tool/provider-tool.d.ts +2 -0
- package/dist/runtime/adapter/tool/provider-tool.js +25 -0
- package/dist/runtime/adapter/tool/resolved-tool.d.ts +18 -0
- package/dist/runtime/adapter/tool/resolved-tool.js +62 -0
- package/dist/runtime/adapter/tool/tool-arguments.d.ts +7 -0
- package/dist/runtime/adapter/tool/tool-arguments.js +87 -0
- package/dist/runtime/{tool-hitl.d.ts → adapter/tool/tool-hitl.d.ts} +2 -2
- package/dist/runtime/adapter/tool/tool-name-mapping.d.ts +13 -0
- package/dist/runtime/adapter/tool/tool-name-mapping.js +101 -0
- package/dist/runtime/agent-runtime-adapter.d.ts +5 -20
- package/dist/runtime/agent-runtime-adapter.js +33 -536
- package/dist/runtime/checkpoint-maintenance.d.ts +1 -45
- package/dist/runtime/checkpoint-maintenance.js +1 -259
- package/dist/runtime/file-checkpoint-saver.d.ts +1 -20
- package/dist/runtime/file-checkpoint-saver.js +1 -106
- package/dist/runtime/{event-bus.d.ts → harness/events/event-bus.d.ts} +1 -1
- package/dist/runtime/{event-sink.d.ts → harness/events/event-sink.d.ts} +1 -1
- package/dist/runtime/{event-sink.js → harness/events/event-sink.js} +1 -1
- package/dist/runtime/harness/events/events.d.ts +23 -0
- package/dist/runtime/harness/events/events.js +61 -0
- package/dist/runtime/harness/events/streaming.d.ts +19 -0
- package/dist/runtime/harness/events/streaming.js +96 -0
- package/dist/runtime/harness/index.d.ts +16 -0
- package/dist/runtime/harness/index.js +16 -0
- package/dist/runtime/harness/run/helpers.d.ts +33 -0
- package/dist/runtime/harness/run/helpers.js +74 -0
- package/dist/runtime/harness/run/resources.d.ts +7 -0
- package/dist/runtime/harness/run/resources.js +58 -0
- package/dist/runtime/harness/run/resume.d.ts +6 -0
- package/dist/runtime/harness/run/resume.js +56 -0
- package/dist/runtime/harness/run/routing.d.ts +12 -0
- package/dist/runtime/harness/run/routing.js +47 -0
- package/dist/runtime/harness/run/run-lifecycle.d.ts +37 -0
- package/dist/runtime/harness/run/run-lifecycle.js +109 -0
- package/dist/runtime/harness/run/run-queue.d.ts +17 -0
- package/dist/runtime/harness/run/run-queue.js +43 -0
- package/dist/runtime/{health-monitor.d.ts → harness/system/health-monitor.d.ts} +3 -3
- package/dist/runtime/{health-monitor.js → harness/system/health-monitor.js} +2 -2
- package/dist/runtime/{inventory.d.ts → harness/system/inventory.d.ts} +2 -2
- package/dist/runtime/{inventory.js → harness/system/inventory.js} +4 -4
- package/dist/runtime/{policy-engine.d.ts → harness/system/policy-engine.d.ts} +1 -1
- package/dist/runtime/{policy-engine.js → harness/system/policy-engine.js} +1 -1
- package/dist/runtime/{skill-requirements.d.ts → harness/system/skill-requirements.d.ts} +1 -1
- package/dist/runtime/{skill-requirements.js → harness/system/skill-requirements.js} +1 -1
- package/dist/runtime/{thread-memory-sync.d.ts → harness/system/thread-memory-sync.d.ts} +2 -2
- package/dist/runtime/{thread-memory-sync.js → harness/system/thread-memory-sync.js} +1 -1
- package/dist/runtime/harness.d.ts +2 -8
- package/dist/runtime/harness.js +143 -493
- package/dist/runtime/index.d.ts +7 -7
- package/dist/runtime/index.js +7 -7
- package/dist/runtime/maintenance/checkpoint-maintenance.d.ts +45 -0
- package/dist/runtime/maintenance/checkpoint-maintenance.js +259 -0
- package/dist/runtime/maintenance/file-checkpoint-saver.d.ts +20 -0
- package/dist/runtime/maintenance/file-checkpoint-saver.js +106 -0
- package/dist/runtime/maintenance/index.d.ts +4 -0
- package/dist/runtime/maintenance/index.js +4 -0
- package/dist/runtime/{runtime-record-maintenance.d.ts → maintenance/runtime-record-maintenance.d.ts} +1 -1
- package/dist/runtime/{runtime-record-maintenance.js → maintenance/runtime-record-maintenance.js} +2 -2
- package/dist/runtime/maintenance/sqlite-maintained-checkpoint-saver.d.ts +9 -0
- package/dist/runtime/maintenance/sqlite-maintained-checkpoint-saver.js +39 -0
- package/dist/runtime/sqlite-maintained-checkpoint-saver.d.ts +1 -9
- package/dist/runtime/sqlite-maintained-checkpoint-saver.js +1 -39
- package/dist/runtime/support/harness-support.d.ts +4 -4
- package/dist/runtime/support/runtime-factories.d.ts +1 -1
- package/dist/runtime/support/runtime-factories.js +1 -1
- package/package.json +4 -4
- /package/dist/runtime/{langgraph-presets.d.ts → adapter/langgraph/presets.d.ts} +0 -0
- /package/dist/runtime/{langgraph-presets.js → adapter/langgraph/presets.js} +0 -0
- /package/dist/runtime/{langgraph-profiles.js → adapter/langgraph/profiles.js} +0 -0
- /package/dist/runtime/{declared-middleware.js → adapter/tool/declared-middleware.js} +0 -0
- /package/dist/runtime/{tool-hitl.js → adapter/tool/tool-hitl.js} +0 -0
- /package/dist/runtime/{event-bus.js → harness/events/event-bus.js} +0 -0
- /package/dist/runtime/{store.d.ts → harness/system/store.d.ts} +0 -0
- /package/dist/runtime/{store.js → harness/system/store.js} +0 -0
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import type { ExecutionMode, RuntimeCapabilities, RuntimeModelRefMap, RuntimeModelSlot } from "./core.js";
|
|
2
|
+
export type ParsedAgentObject = {
|
|
3
|
+
id: string;
|
|
4
|
+
executionMode: ExecutionMode;
|
|
5
|
+
runtimeModelRefs?: RuntimeModelRefMap;
|
|
6
|
+
capabilities?: RuntimeCapabilities;
|
|
7
|
+
description: string;
|
|
8
|
+
modelRef: string;
|
|
9
|
+
runRoot?: string;
|
|
10
|
+
toolRefs: string[];
|
|
11
|
+
mcpServers?: Array<Record<string, unknown>>;
|
|
12
|
+
skillPathRefs: string[];
|
|
13
|
+
memorySources: string[];
|
|
14
|
+
subagentRefs: string[];
|
|
15
|
+
subagentPathRefs: string[];
|
|
16
|
+
langchainAgentConfig?: Record<string, unknown>;
|
|
17
|
+
deepAgentConfig?: Record<string, unknown>;
|
|
18
|
+
sourcePath: string;
|
|
19
|
+
};
|
|
20
|
+
export type WorkspaceObject = {
|
|
21
|
+
id: string;
|
|
22
|
+
kind: string;
|
|
23
|
+
sourcePath: string;
|
|
24
|
+
value: Record<string, unknown>;
|
|
25
|
+
};
|
|
26
|
+
export type ParsedModelObject = {
|
|
27
|
+
id: string;
|
|
28
|
+
provider: string;
|
|
29
|
+
model: string;
|
|
30
|
+
init: Record<string, unknown>;
|
|
31
|
+
clientRef?: string;
|
|
32
|
+
fallbacks: string[];
|
|
33
|
+
metadata?: Record<string, unknown>;
|
|
34
|
+
sourcePath: string;
|
|
35
|
+
};
|
|
36
|
+
export type ParsedEmbeddingModelObject = {
|
|
37
|
+
id: string;
|
|
38
|
+
provider: string;
|
|
39
|
+
model: string;
|
|
40
|
+
init: Record<string, unknown>;
|
|
41
|
+
clientRef?: string;
|
|
42
|
+
metadata?: Record<string, unknown>;
|
|
43
|
+
sourcePath: string;
|
|
44
|
+
};
|
|
45
|
+
export type ParsedVectorStoreObject = {
|
|
46
|
+
id: string;
|
|
47
|
+
kind: string;
|
|
48
|
+
url?: string;
|
|
49
|
+
authToken?: string;
|
|
50
|
+
table?: string;
|
|
51
|
+
column?: string;
|
|
52
|
+
embeddingModelRef?: string;
|
|
53
|
+
metadata?: Record<string, unknown>;
|
|
54
|
+
sourcePath: string;
|
|
55
|
+
};
|
|
56
|
+
export type ParsedMcpServerObject = {
|
|
57
|
+
id: string;
|
|
58
|
+
transport: "stdio" | "http" | "sse" | "websocket";
|
|
59
|
+
url?: string;
|
|
60
|
+
command?: string;
|
|
61
|
+
args?: string[];
|
|
62
|
+
env?: Record<string, string>;
|
|
63
|
+
cwd?: string;
|
|
64
|
+
token?: string;
|
|
65
|
+
headers?: Record<string, string>;
|
|
66
|
+
sourcePath: string;
|
|
67
|
+
};
|
|
68
|
+
export type ParsedToolObject = {
|
|
69
|
+
id: string;
|
|
70
|
+
type: string;
|
|
71
|
+
name: string;
|
|
72
|
+
description: string;
|
|
73
|
+
implementationName?: string;
|
|
74
|
+
config?: Record<string, unknown>;
|
|
75
|
+
inputSchemaRef?: string;
|
|
76
|
+
backendOperation?: string;
|
|
77
|
+
mcpRef?: string;
|
|
78
|
+
bundleRefs: string[];
|
|
79
|
+
hitl?: {
|
|
80
|
+
enabled: boolean;
|
|
81
|
+
allow?: Array<"approve" | "edit" | "reject">;
|
|
82
|
+
};
|
|
83
|
+
retryable?: boolean;
|
|
84
|
+
sourcePath: string;
|
|
85
|
+
};
|
|
86
|
+
export type CompiledModel = {
|
|
87
|
+
id: string;
|
|
88
|
+
provider: string;
|
|
89
|
+
model: string;
|
|
90
|
+
init: Record<string, unknown>;
|
|
91
|
+
clientRef?: string;
|
|
92
|
+
fallbacks: string[];
|
|
93
|
+
runtimeValue: string;
|
|
94
|
+
};
|
|
95
|
+
export type CompiledEmbeddingModel = {
|
|
96
|
+
id: string;
|
|
97
|
+
provider: string;
|
|
98
|
+
model: string;
|
|
99
|
+
init: Record<string, unknown>;
|
|
100
|
+
clientRef?: string;
|
|
101
|
+
runtimeValue: string;
|
|
102
|
+
};
|
|
103
|
+
export type CompiledVectorStore = {
|
|
104
|
+
id: string;
|
|
105
|
+
kind: string;
|
|
106
|
+
url?: string;
|
|
107
|
+
authToken?: string;
|
|
108
|
+
table?: string;
|
|
109
|
+
column?: string;
|
|
110
|
+
embeddingModelRef?: string;
|
|
111
|
+
runtimeValue: string;
|
|
112
|
+
};
|
|
113
|
+
export type CompiledTool = {
|
|
114
|
+
id: string;
|
|
115
|
+
type: string;
|
|
116
|
+
name: string;
|
|
117
|
+
description: string;
|
|
118
|
+
config?: Record<string, unknown>;
|
|
119
|
+
inputSchemaRef?: string;
|
|
120
|
+
backendOperation?: string;
|
|
121
|
+
mcpRef?: string;
|
|
122
|
+
bundleRefs: string[];
|
|
123
|
+
hitl?: {
|
|
124
|
+
enabled: boolean;
|
|
125
|
+
allow: Array<"approve" | "edit" | "reject">;
|
|
126
|
+
};
|
|
127
|
+
retryable?: boolean;
|
|
128
|
+
runtimeValue: {
|
|
129
|
+
name: string;
|
|
130
|
+
description: string;
|
|
131
|
+
type: string;
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
export type CompiledSubAgent = {
|
|
135
|
+
name: string;
|
|
136
|
+
description: string;
|
|
137
|
+
systemPrompt: string;
|
|
138
|
+
tools?: CompiledTool[];
|
|
139
|
+
model?: CompiledModel;
|
|
140
|
+
interruptOn?: Record<string, boolean | object>;
|
|
141
|
+
skills?: string[];
|
|
142
|
+
memory?: string[];
|
|
143
|
+
responseFormat?: unknown;
|
|
144
|
+
contextSchema?: unknown;
|
|
145
|
+
middleware?: Array<Record<string, unknown>>;
|
|
146
|
+
passthrough?: Record<string, unknown>;
|
|
147
|
+
};
|
|
148
|
+
export type LangChainAgentParams = {
|
|
149
|
+
model: CompiledModel;
|
|
150
|
+
tools: CompiledTool[];
|
|
151
|
+
systemPrompt?: string;
|
|
152
|
+
stateSchema?: unknown;
|
|
153
|
+
responseFormat?: unknown;
|
|
154
|
+
contextSchema?: unknown;
|
|
155
|
+
filesystem?: Record<string, unknown>;
|
|
156
|
+
middleware?: Array<Record<string, unknown>>;
|
|
157
|
+
passthrough?: Record<string, unknown>;
|
|
158
|
+
subagents?: CompiledSubAgent[];
|
|
159
|
+
memory?: string[];
|
|
160
|
+
skills?: string[];
|
|
161
|
+
generalPurposeAgent?: boolean;
|
|
162
|
+
taskDescription?: string;
|
|
163
|
+
includeAgentName?: "inline";
|
|
164
|
+
version?: "v1" | "v2";
|
|
165
|
+
name?: string;
|
|
166
|
+
description: string;
|
|
167
|
+
};
|
|
168
|
+
export type DeepAgentParams = {
|
|
169
|
+
model: CompiledModel;
|
|
170
|
+
tools: CompiledTool[];
|
|
171
|
+
systemPrompt?: string;
|
|
172
|
+
responseFormat?: unknown;
|
|
173
|
+
contextSchema?: unknown;
|
|
174
|
+
middleware?: Array<Record<string, unknown>>;
|
|
175
|
+
passthrough?: Record<string, unknown>;
|
|
176
|
+
description: string;
|
|
177
|
+
subagents: CompiledSubAgent[];
|
|
178
|
+
interruptOn?: Record<string, boolean | object>;
|
|
179
|
+
backend?: Record<string, unknown>;
|
|
180
|
+
store?: Record<string, unknown>;
|
|
181
|
+
name: string;
|
|
182
|
+
memory: string[];
|
|
183
|
+
skills: string[];
|
|
184
|
+
generalPurposeAgent?: boolean;
|
|
185
|
+
taskDescription?: string;
|
|
186
|
+
};
|
|
187
|
+
export type RuntimeModelMap = Partial<Record<RuntimeModelSlot, CompiledModel>>;
|
|
188
|
+
export type CompiledAgentBinding = {
|
|
189
|
+
agent: ParsedAgentObject;
|
|
190
|
+
adapter?: {
|
|
191
|
+
kind: string;
|
|
192
|
+
config: Record<string, unknown>;
|
|
193
|
+
};
|
|
194
|
+
langchainAgentParams?: LangChainAgentParams;
|
|
195
|
+
deepAgentParams?: DeepAgentParams;
|
|
196
|
+
harnessRuntime: {
|
|
197
|
+
runRoot: string;
|
|
198
|
+
workspaceRoot?: string;
|
|
199
|
+
modelRefs?: RuntimeModelRefMap;
|
|
200
|
+
models?: RuntimeModelMap;
|
|
201
|
+
capabilities?: RuntimeCapabilities;
|
|
202
|
+
resilience?: Record<string, unknown>;
|
|
203
|
+
checkpointer?: Record<string, unknown> | boolean;
|
|
204
|
+
store?: Record<string, unknown>;
|
|
205
|
+
runtimeMemory?: Record<string, unknown>;
|
|
206
|
+
};
|
|
207
|
+
};
|
|
208
|
+
export type WorkspaceBundle = {
|
|
209
|
+
workspaceRoot: string;
|
|
210
|
+
resourceSources: string[];
|
|
211
|
+
refs: Map<string, WorkspaceObject | ParsedAgentObject>;
|
|
212
|
+
models: Map<string, ParsedModelObject>;
|
|
213
|
+
embeddings: Map<string, ParsedEmbeddingModelObject>;
|
|
214
|
+
vectorStores: Map<string, ParsedVectorStoreObject>;
|
|
215
|
+
mcpServers: Map<string, ParsedMcpServerObject>;
|
|
216
|
+
tools: Map<string, ParsedToolObject>;
|
|
217
|
+
agents: Map<string, ParsedAgentObject>;
|
|
218
|
+
bindings: Map<string, CompiledAgentBinding>;
|
|
219
|
+
};
|
|
220
|
+
export type WorkspaceLoadOptions = {
|
|
221
|
+
/**
|
|
222
|
+
* Additional workspace roots to load before the runtime workspace root.
|
|
223
|
+
* Merge order is deterministic:
|
|
224
|
+
* framework defaults -> each overlayRoot (in order) -> workspaceRoot.
|
|
225
|
+
* Later values always override earlier values.
|
|
226
|
+
*/
|
|
227
|
+
overlayRoots?: string[];
|
|
228
|
+
resourceSources?: string[];
|
|
229
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const AGENT_HARNESS_VERSION = "0.0.
|
|
1
|
+
export declare const AGENT_HARNESS_VERSION = "0.0.97";
|
package/dist/package-version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const AGENT_HARNESS_VERSION = "0.0.
|
|
1
|
+
export const AGENT_HARNESS_VERSION = "0.0.97";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CompiledModel, CompiledSubAgent } from "../../../contracts/types.js";
|
|
2
|
+
type DelegationPromptCompatibilityParams = {
|
|
3
|
+
subagents?: CompiledSubAgent[];
|
|
4
|
+
generalPurposeAgent?: boolean;
|
|
5
|
+
taskDescription?: string;
|
|
6
|
+
};
|
|
7
|
+
export declare function relativizeDeepAgentSkillSourcePaths(workspaceRoot: string | undefined, skillPaths: string[] | undefined): string[] | undefined;
|
|
8
|
+
export declare function materializeDeepAgentSkillSourcePaths(options: {
|
|
9
|
+
workspaceRoot?: string;
|
|
10
|
+
runRoot?: string;
|
|
11
|
+
ownerId: string;
|
|
12
|
+
skillPaths?: string[];
|
|
13
|
+
}): Promise<string[] | undefined>;
|
|
14
|
+
export declare function shouldRelaxDeepAgentDelegationPrompt(model: CompiledModel | undefined, params: DelegationPromptCompatibilityParams): boolean;
|
|
15
|
+
export declare function applyDeepAgentDelegationPromptCompatibility<T extends DelegationPromptCompatibilityParams>(model: CompiledModel | undefined, params: T): T;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
function isOpenAICompatibleGptOssModel(model) {
|
|
3
|
+
return model?.provider === "openai-compatible" && model.model.trim().toLowerCase().startsWith("gpt-oss");
|
|
4
|
+
}
|
|
5
|
+
export function relativizeDeepAgentSkillSourcePaths(workspaceRoot, skillPaths) {
|
|
6
|
+
if (!workspaceRoot || !skillPaths) {
|
|
7
|
+
return skillPaths;
|
|
8
|
+
}
|
|
9
|
+
return skillPaths.map((skillPath) => {
|
|
10
|
+
if (!path.isAbsolute(skillPath)) {
|
|
11
|
+
return skillPath;
|
|
12
|
+
}
|
|
13
|
+
const relative = path.relative(workspaceRoot, skillPath);
|
|
14
|
+
if (!relative || relative.startsWith("..")) {
|
|
15
|
+
return skillPath;
|
|
16
|
+
}
|
|
17
|
+
return relative.split(path.sep).join("/");
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
export async function materializeDeepAgentSkillSourcePaths(options) {
|
|
21
|
+
const { workspaceRoot, skillPaths } = options;
|
|
22
|
+
if (!skillPaths) {
|
|
23
|
+
return skillPaths;
|
|
24
|
+
}
|
|
25
|
+
return relativizeDeepAgentSkillSourcePaths(workspaceRoot, skillPaths) ?? skillPaths;
|
|
26
|
+
}
|
|
27
|
+
export function shouldRelaxDeepAgentDelegationPrompt(model, params) {
|
|
28
|
+
if (!isOpenAICompatibleGptOssModel(model)) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
if ((params.subagents?.length ?? 0) === 0) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
return params.generalPurposeAgent === true || Boolean(params.taskDescription?.trim());
|
|
35
|
+
}
|
|
36
|
+
export function applyDeepAgentDelegationPromptCompatibility(model, params) {
|
|
37
|
+
if (!shouldRelaxDeepAgentDelegationPrompt(model, params)) {
|
|
38
|
+
return params;
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
...params,
|
|
42
|
+
generalPurposeAgent: undefined,
|
|
43
|
+
taskDescription: undefined,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
function asObject(value) {
|
|
2
|
+
return typeof value === "object" && value ? value : undefined;
|
|
3
|
+
}
|
|
4
|
+
function isPlaceholderApiKey(value) {
|
|
5
|
+
return typeof value === "string" && value.trim().toLowerCase() === "dummy";
|
|
6
|
+
}
|
|
7
|
+
export function buildAuthOmittingFetch(baseFetch = fetch) {
|
|
8
|
+
return async (input, init) => {
|
|
9
|
+
const sanitizedHeaders = new Headers(input instanceof Request ? input.headers : undefined);
|
|
10
|
+
const initHeaders = new Headers(init?.headers);
|
|
11
|
+
initHeaders.forEach((value, key) => {
|
|
12
|
+
sanitizedHeaders.set(key, value);
|
|
13
|
+
});
|
|
14
|
+
sanitizedHeaders.delete("authorization");
|
|
15
|
+
if (input instanceof Request) {
|
|
16
|
+
return baseFetch(new Request(input, {
|
|
17
|
+
...init,
|
|
18
|
+
headers: sanitizedHeaders,
|
|
19
|
+
}));
|
|
20
|
+
}
|
|
21
|
+
return baseFetch(input, {
|
|
22
|
+
...init,
|
|
23
|
+
headers: sanitizedHeaders,
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export function normalizeOpenAICompatibleInit(init) {
|
|
28
|
+
const normalized = { ...init };
|
|
29
|
+
const configuration = asObject(init.configuration) ?? {};
|
|
30
|
+
const baseUrl = typeof init.baseUrl === "string" && init.baseUrl.trim() ? init.baseUrl.trim() : undefined;
|
|
31
|
+
const omitAuthHeader = init.omitAuthHeader === true || isPlaceholderApiKey(init.apiKey);
|
|
32
|
+
const nextConfiguration = { ...configuration };
|
|
33
|
+
if (baseUrl && typeof nextConfiguration.baseURL !== "string") {
|
|
34
|
+
nextConfiguration.baseURL = baseUrl;
|
|
35
|
+
}
|
|
36
|
+
if (omitAuthHeader) {
|
|
37
|
+
nextConfiguration.fetch = buildAuthOmittingFetch(typeof configuration.fetch === "function" ? configuration.fetch : fetch);
|
|
38
|
+
}
|
|
39
|
+
normalized.configuration = nextConfiguration;
|
|
40
|
+
delete normalized.baseUrl;
|
|
41
|
+
delete normalized.omitAuthHeader;
|
|
42
|
+
return normalized;
|
|
43
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export * from "./tool/declared-middleware.js";
|
|
2
|
+
export * from "./compat/deepagent-compat.js";
|
|
3
|
+
export * from "./tool/interrupt-policy.js";
|
|
4
|
+
export * from "./model/invocation-request.js";
|
|
5
|
+
export * from "./langgraph/presets.js";
|
|
6
|
+
export * from "./langgraph/profiles.js";
|
|
7
|
+
export * from "./model/message-assembly.js";
|
|
8
|
+
export * from "./model/model-providers.js";
|
|
9
|
+
export * from "./compat/openai-compatible.js";
|
|
10
|
+
export * from "./tool/provider-tool.js";
|
|
11
|
+
export * from "./resilience.js";
|
|
12
|
+
export * from "./tool/resolved-tool.js";
|
|
13
|
+
export * from "./tool/tool-arguments.js";
|
|
14
|
+
export * from "./tool/tool-hitl.js";
|
|
15
|
+
export * from "./tool/tool-name-mapping.js";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export * from "./tool/declared-middleware.js";
|
|
2
|
+
export * from "./compat/deepagent-compat.js";
|
|
3
|
+
export * from "./tool/interrupt-policy.js";
|
|
4
|
+
export * from "./model/invocation-request.js";
|
|
5
|
+
export * from "./langgraph/presets.js";
|
|
6
|
+
export * from "./langgraph/profiles.js";
|
|
7
|
+
export * from "./model/message-assembly.js";
|
|
8
|
+
export * from "./model/model-providers.js";
|
|
9
|
+
export * from "./compat/openai-compatible.js";
|
|
10
|
+
export * from "./tool/provider-tool.js";
|
|
11
|
+
export * from "./resilience.js";
|
|
12
|
+
export * from "./tool/resolved-tool.js";
|
|
13
|
+
export * from "./tool/tool-arguments.js";
|
|
14
|
+
export * from "./tool/tool-hitl.js";
|
|
15
|
+
export * from "./tool/tool-name-mapping.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { LangGraphPresetWorkflow } from "./
|
|
1
|
+
import type { LangGraphPresetWorkflow } from "./presets.js";
|
|
2
2
|
export type LangGraphProfileName = "coding-runtime" | "personal-assistant" | "research-runtime" | "approval-review-runtime" | "claw-style-assistant" | "chat-operator" | "copilot-sidecar" | "task-delegation-hub";
|
|
3
3
|
type LangGraphProfileOptions = Record<string, unknown>;
|
|
4
4
|
export declare const SUPPORTED_LANGGRAPH_PROFILES: LangGraphProfileName[];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CompiledAgentBinding, MessageContent, TranscriptMessage } from "../../../contracts/types.js";
|
|
2
|
+
export declare function buildAgentMessages(history: TranscriptMessage[], input: MessageContent): Array<{
|
|
3
|
+
role: string;
|
|
4
|
+
content: MessageContent;
|
|
5
|
+
}>;
|
|
6
|
+
export declare function buildSlashCommandSkillInstruction(binding: CompiledAgentBinding, input: MessageContent): string | undefined;
|
|
7
|
+
export declare function buildInvocationRequest(binding: CompiledAgentBinding, history: TranscriptMessage[], input: MessageContent, options?: {
|
|
8
|
+
state?: Record<string, unknown>;
|
|
9
|
+
files?: Record<string, unknown>;
|
|
10
|
+
}): Record<string, unknown>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { extractMessageText, normalizeMessageContent } from "../../../utils/message-content.js";
|
|
2
|
+
import { readSkillMetadata } from "../../support/skill-metadata.js";
|
|
3
|
+
export function buildAgentMessages(history, input) {
|
|
4
|
+
return [
|
|
5
|
+
...history.map((item) => ({ role: item.role, content: normalizeMessageContent(item.content) })),
|
|
6
|
+
{ role: "user", content: normalizeMessageContent(input) },
|
|
7
|
+
];
|
|
8
|
+
}
|
|
9
|
+
export function buildSlashCommandSkillInstruction(binding, input) {
|
|
10
|
+
const inputText = extractMessageText(input).trim();
|
|
11
|
+
const match = inputText.match(/^\/([a-z0-9]+(?:-[a-z0-9]+)*)(?:\s+([\s\S]*))?$/i);
|
|
12
|
+
if (!match) {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
const invokedName = match[1].toLowerCase();
|
|
16
|
+
const argumentText = match[2]?.trim() ?? "";
|
|
17
|
+
const skillPaths = binding.deepAgentParams?.skills ?? binding.langchainAgentParams?.skills ?? [];
|
|
18
|
+
const matchedSkillPath = skillPaths.find((skillPath) => readSkillMetadata(skillPath).name.toLowerCase() === invokedName);
|
|
19
|
+
if (!matchedSkillPath) {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
const metadata = readSkillMetadata(matchedSkillPath);
|
|
23
|
+
const skillQualifier = metadata.userInvocable === true ? "user-invocable skill" : "skill";
|
|
24
|
+
const dryRunHint = /\s--dry-run(?:\s|$)/.test(` ${argumentText} `)
|
|
25
|
+
? "This invocation includes `--dry-run`. Perform the real fetch or inspection steps needed for dry-run output. Do not return hypothetical or mock results."
|
|
26
|
+
: undefined;
|
|
27
|
+
return [
|
|
28
|
+
`This user message is an explicit command-style invocation of the ${skillQualifier} \`${metadata.name}\`.`,
|
|
29
|
+
`Read the skill file for \`${metadata.name}\` before taking action, then follow its documented phases and constraints exactly.`,
|
|
30
|
+
`You must use the \`${metadata.name}\` skill for this request and follow its documented workflow.`,
|
|
31
|
+
`Treat everything after \`/${metadata.name}\` as the skill argument string: ${argumentText ? JSON.stringify(argumentText) : '""'}.`,
|
|
32
|
+
"Do not answer with a generic explanation of what the skill would do. Execute the skill workflow using the available tools unless the skill instructions explicitly require confirmation before acting.",
|
|
33
|
+
dryRunHint,
|
|
34
|
+
].filter((line) => typeof line === "string" && line.length > 0).join("\n");
|
|
35
|
+
}
|
|
36
|
+
export function buildInvocationRequest(binding, history, input, options = {}) {
|
|
37
|
+
const userInvocableInstruction = buildSlashCommandSkillInstruction(binding, input);
|
|
38
|
+
const messages = buildAgentMessages(history, input);
|
|
39
|
+
return {
|
|
40
|
+
...(options.state ?? {}),
|
|
41
|
+
...(options.files ? { files: options.files } : {}),
|
|
42
|
+
messages: userInvocableInstruction
|
|
43
|
+
? [{ role: "system", content: userInvocableInstruction }, ...messages]
|
|
44
|
+
: messages,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { CompiledAgentBinding, MessageContent, TranscriptMessage } from "../../../contracts/types.js";
|
|
2
|
+
export declare function buildStateSnapshot(result: Record<string, unknown>): Record<string, unknown> | undefined;
|
|
3
|
+
export declare function buildRawModelMessages(binding: CompiledAgentBinding, systemPrompt: string | undefined, history: TranscriptMessage[], input: MessageContent): Array<{
|
|
4
|
+
role: string;
|
|
5
|
+
content: MessageContent;
|
|
6
|
+
}>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { buildAgentMessages, buildSlashCommandSkillInstruction } from "./invocation-request.js";
|
|
2
|
+
export function buildStateSnapshot(result) {
|
|
3
|
+
const snapshot = { ...result };
|
|
4
|
+
delete snapshot.messages;
|
|
5
|
+
delete snapshot.__interrupt__;
|
|
6
|
+
delete snapshot.structuredResponse;
|
|
7
|
+
delete snapshot.files;
|
|
8
|
+
return Object.keys(snapshot).length > 0 ? snapshot : undefined;
|
|
9
|
+
}
|
|
10
|
+
export function buildRawModelMessages(binding, systemPrompt, history, input) {
|
|
11
|
+
const messages = [];
|
|
12
|
+
if (systemPrompt) {
|
|
13
|
+
messages.push({ role: "system", content: systemPrompt });
|
|
14
|
+
}
|
|
15
|
+
const userInvocableInstruction = buildSlashCommandSkillInstruction(binding, input);
|
|
16
|
+
if (userInvocableInstruction) {
|
|
17
|
+
messages.push({ role: "system", content: userInvocableInstruction });
|
|
18
|
+
}
|
|
19
|
+
messages.push(...buildAgentMessages(history, input));
|
|
20
|
+
return messages;
|
|
21
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ChatAnthropic } from "@langchain/anthropic";
|
|
2
|
+
import { ChatGoogle } from "@langchain/google";
|
|
3
|
+
import { ChatOllama } from "@langchain/ollama";
|
|
4
|
+
import { ChatOpenAI } from "@langchain/openai";
|
|
5
|
+
import { initChatModel } from "langchain";
|
|
6
|
+
import { normalizeOpenAICompatibleInit } from "../compat/openai-compatible.js";
|
|
7
|
+
export async function createResolvedModel(model, modelResolver) {
|
|
8
|
+
if (modelResolver) {
|
|
9
|
+
return modelResolver(model.id);
|
|
10
|
+
}
|
|
11
|
+
if (model.provider === "ollama") {
|
|
12
|
+
return new ChatOllama({ model: model.model, ...model.init });
|
|
13
|
+
}
|
|
14
|
+
if (model.provider === "openai-compatible") {
|
|
15
|
+
return new ChatOpenAI({ model: model.model, ...normalizeOpenAICompatibleInit(model.init) });
|
|
16
|
+
}
|
|
17
|
+
if (model.provider === "openai") {
|
|
18
|
+
return new ChatOpenAI({ model: model.model, ...model.init });
|
|
19
|
+
}
|
|
20
|
+
if (model.provider === "anthropic") {
|
|
21
|
+
return new ChatAnthropic({ model: model.model, ...model.init });
|
|
22
|
+
}
|
|
23
|
+
if (model.provider === "google" || model.provider === "google-genai" || model.provider === "gemini") {
|
|
24
|
+
return new ChatGoogle({ model: model.model, ...model.init });
|
|
25
|
+
}
|
|
26
|
+
return initChatModel(model.model, { modelProvider: model.provider, ...model.init });
|
|
27
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CompiledAgentBinding } from "../../contracts/types.js";
|
|
2
|
+
export declare function resolveTimeoutMs(value: unknown): number | undefined;
|
|
3
|
+
export declare function computeRemainingTimeoutMs(deadlineAt: number | undefined, fallbackTimeoutMs: number | undefined): number | undefined;
|
|
4
|
+
export declare function resolveBindingTimeout(binding: CompiledAgentBinding): number | undefined;
|
|
5
|
+
export declare function resolveStreamIdleTimeout(binding: CompiledAgentBinding): number | undefined;
|
|
6
|
+
export type ProviderRetryPolicy = {
|
|
7
|
+
maxAttempts: number;
|
|
8
|
+
backoffMs: number;
|
|
9
|
+
retryableMessages: string[];
|
|
10
|
+
};
|
|
11
|
+
export declare function resolveProviderRetryPolicy(binding: CompiledAgentBinding): ProviderRetryPolicy;
|
|
12
|
+
export declare function isRetryableProviderError(binding: CompiledAgentBinding, error: unknown): boolean;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { getBindingModelInit } from "../support/compiled-binding.js";
|
|
2
|
+
export function resolveTimeoutMs(value) {
|
|
3
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : undefined;
|
|
4
|
+
}
|
|
5
|
+
export function computeRemainingTimeoutMs(deadlineAt, fallbackTimeoutMs) {
|
|
6
|
+
if (!deadlineAt) {
|
|
7
|
+
return fallbackTimeoutMs;
|
|
8
|
+
}
|
|
9
|
+
const remaining = deadlineAt - Date.now();
|
|
10
|
+
if (remaining <= 0) {
|
|
11
|
+
return 0;
|
|
12
|
+
}
|
|
13
|
+
return fallbackTimeoutMs ? Math.min(fallbackTimeoutMs, remaining) : remaining;
|
|
14
|
+
}
|
|
15
|
+
export function resolveBindingTimeout(binding) {
|
|
16
|
+
return resolveTimeoutMs(getBindingModelInit(binding)?.timeout);
|
|
17
|
+
}
|
|
18
|
+
export function resolveStreamIdleTimeout(binding) {
|
|
19
|
+
const configuredIdleTimeout = resolveTimeoutMs(getBindingModelInit(binding)?.streamIdleTimeout);
|
|
20
|
+
if (configuredIdleTimeout) {
|
|
21
|
+
return configuredIdleTimeout;
|
|
22
|
+
}
|
|
23
|
+
const invokeTimeout = resolveBindingTimeout(binding);
|
|
24
|
+
if (invokeTimeout) {
|
|
25
|
+
return Math.min(invokeTimeout, 15_000);
|
|
26
|
+
}
|
|
27
|
+
return 15_000;
|
|
28
|
+
}
|
|
29
|
+
export function resolveProviderRetryPolicy(binding) {
|
|
30
|
+
const resilience = typeof binding.harnessRuntime.resilience === "object" && binding.harnessRuntime.resilience
|
|
31
|
+
? binding.harnessRuntime.resilience
|
|
32
|
+
: {};
|
|
33
|
+
const providerRetries = typeof resilience.providerRetries === "object" && resilience.providerRetries
|
|
34
|
+
? resilience.providerRetries
|
|
35
|
+
: {};
|
|
36
|
+
const maxAttempts = typeof providerRetries.maxAttempts === "number" &&
|
|
37
|
+
Number.isFinite(providerRetries.maxAttempts) &&
|
|
38
|
+
providerRetries.maxAttempts > 0
|
|
39
|
+
? Math.floor(providerRetries.maxAttempts)
|
|
40
|
+
: 2;
|
|
41
|
+
const backoffMs = typeof providerRetries.backoffMs === "number" &&
|
|
42
|
+
Number.isFinite(providerRetries.backoffMs) &&
|
|
43
|
+
providerRetries.backoffMs >= 0
|
|
44
|
+
? Math.floor(providerRetries.backoffMs)
|
|
45
|
+
: 1_000;
|
|
46
|
+
const retryableMessages = Array.isArray(providerRetries.retryableMessages)
|
|
47
|
+
? providerRetries.retryableMessages.filter((value) => typeof value === "string" && value.trim().length > 0)
|
|
48
|
+
: [];
|
|
49
|
+
return {
|
|
50
|
+
maxAttempts,
|
|
51
|
+
backoffMs,
|
|
52
|
+
retryableMessages,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
export function isRetryableProviderError(binding, error) {
|
|
56
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
57
|
+
const normalized = message.toLowerCase();
|
|
58
|
+
const { retryableMessages } = resolveProviderRetryPolicy(binding);
|
|
59
|
+
return retryableMessages.some((candidate) => normalized.includes(candidate.toLowerCase()));
|
|
60
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CompiledAgentBinding, CompiledModel } from "
|
|
1
|
+
import type { CompiledAgentBinding, CompiledModel } from "../../../contracts/types.js";
|
|
2
2
|
type MiddlewareConfig = Record<string, unknown>;
|
|
3
3
|
type MiddlewareFactoryContext = {
|
|
4
4
|
config: MiddlewareConfig;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CompiledTool } from "../../../contracts/types.js";
|
|
2
|
+
export type InterruptDecision = "approve" | "edit" | "reject";
|
|
3
|
+
export declare function normalizeInterruptPolicy(rule: boolean | object | undefined): InterruptDecision[] | null;
|
|
4
|
+
export declare function compileInterruptOn(tools: Array<Pick<CompiledTool, "name">> | Array<{
|
|
5
|
+
name: string;
|
|
6
|
+
}>, compatibilityRules?: Record<string, boolean | object>): Record<string, {
|
|
7
|
+
allowedDecisions: InterruptDecision[];
|
|
8
|
+
}> | undefined;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { buildToolNameMapping } from "./tool-name-mapping.js";
|
|
2
|
+
export function normalizeInterruptPolicy(rule) {
|
|
3
|
+
if (!rule)
|
|
4
|
+
return null;
|
|
5
|
+
if (rule === true)
|
|
6
|
+
return ["approve", "edit", "reject"];
|
|
7
|
+
const typed = rule;
|
|
8
|
+
if (Array.isArray(typed.allowedDecisions)) {
|
|
9
|
+
return typed.allowedDecisions.filter((item) => item === "approve" || item === "edit" || item === "reject");
|
|
10
|
+
}
|
|
11
|
+
const decisions = [];
|
|
12
|
+
if (typed.allowAccept !== false)
|
|
13
|
+
decisions.push("approve");
|
|
14
|
+
if (typed.allowEdit !== false)
|
|
15
|
+
decisions.push("edit");
|
|
16
|
+
if (typed.allowReject !== false)
|
|
17
|
+
decisions.push("reject");
|
|
18
|
+
return decisions.length > 0 ? decisions : null;
|
|
19
|
+
}
|
|
20
|
+
export function compileInterruptOn(tools, compatibilityRules) {
|
|
21
|
+
const toolNameMapping = buildToolNameMapping(tools);
|
|
22
|
+
const compiled = new Map();
|
|
23
|
+
for (const [toolName, rule] of Object.entries(compatibilityRules ?? {})) {
|
|
24
|
+
const modelFacingName = toolNameMapping.originalToModelFacing.get(toolName) ?? toolName;
|
|
25
|
+
const allowedDecisions = normalizeInterruptPolicy(rule);
|
|
26
|
+
if (!allowedDecisions) {
|
|
27
|
+
compiled.delete(modelFacingName);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
compiled.set(modelFacingName, { allowedDecisions });
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return compiled.size > 0 ? Object.fromEntries(compiled.entries()) : undefined;
|
|
34
|
+
}
|