@agentfield/sdk 0.1.44 → 0.1.45-rc.2
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.d.ts +101 -1
- package/dist/index.js +836 -14
- package/dist/index.js.map +1 -1
- package/package.json +9 -1
package/dist/index.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { createRequire } from 'module';
|
|
4
|
+
import { spawn } from 'child_process';
|
|
1
5
|
import express from 'express';
|
|
2
6
|
import rateLimit from 'express-rate-limit';
|
|
3
7
|
import crypto2, { randomUUID, createHash } from 'crypto';
|
|
@@ -19,7 +23,807 @@ import WebSocket from 'ws';
|
|
|
19
23
|
import { Buffer as Buffer$1 } from 'buffer';
|
|
20
24
|
import { zodToJsonSchema } from 'zod-to-json-schema';
|
|
21
25
|
|
|
22
|
-
|
|
26
|
+
var __defProp = Object.defineProperty;
|
|
27
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
28
|
+
var __esm = (fn, res) => function __init() {
|
|
29
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
30
|
+
};
|
|
31
|
+
var __export = (target, all) => {
|
|
32
|
+
for (var name in all)
|
|
33
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
34
|
+
};
|
|
35
|
+
function getZodConverter() {
|
|
36
|
+
if (zodConverter !== void 0) {
|
|
37
|
+
return zodConverter;
|
|
38
|
+
}
|
|
39
|
+
try {
|
|
40
|
+
const require2 = createRequire(import.meta.url);
|
|
41
|
+
const mod = require2("zod-to-json-schema");
|
|
42
|
+
zodConverter = mod.zodToJsonSchema ?? mod.default ?? null;
|
|
43
|
+
} catch {
|
|
44
|
+
zodConverter = null;
|
|
45
|
+
}
|
|
46
|
+
return zodConverter;
|
|
47
|
+
}
|
|
48
|
+
function isRecord(value) {
|
|
49
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
50
|
+
}
|
|
51
|
+
function hasJsonSchema(value) {
|
|
52
|
+
return isRecord(value) && typeof value.jsonSchema === "function";
|
|
53
|
+
}
|
|
54
|
+
function hasParse(value) {
|
|
55
|
+
return isRecord(value) && typeof value.parse === "function";
|
|
56
|
+
}
|
|
57
|
+
function estimateTokens(text) {
|
|
58
|
+
return Math.floor(text.length / 4);
|
|
59
|
+
}
|
|
60
|
+
function writeSchemaFile(schemaJson, cwd) {
|
|
61
|
+
const filePath = getSchemaPath(cwd);
|
|
62
|
+
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
63
|
+
const fd = fs.openSync(filePath, "w", 384);
|
|
64
|
+
try {
|
|
65
|
+
fs.writeFileSync(fd, schemaJson, "utf8");
|
|
66
|
+
} finally {
|
|
67
|
+
fs.closeSync(fd);
|
|
68
|
+
}
|
|
69
|
+
return filePath;
|
|
70
|
+
}
|
|
71
|
+
function validateAgainstSchema(data, schema) {
|
|
72
|
+
if (hasParse(schema)) {
|
|
73
|
+
return schema.parse(data);
|
|
74
|
+
}
|
|
75
|
+
return data;
|
|
76
|
+
}
|
|
77
|
+
function getOutputPath(cwd) {
|
|
78
|
+
return path.join(cwd, OUTPUT_FILENAME);
|
|
79
|
+
}
|
|
80
|
+
function getSchemaPath(cwd) {
|
|
81
|
+
return path.join(cwd, SCHEMA_FILENAME);
|
|
82
|
+
}
|
|
83
|
+
function schemaToJsonSchema(schema) {
|
|
84
|
+
if (isRecord(schema)) {
|
|
85
|
+
if ("type" in schema || "properties" in schema || "$schema" in schema) {
|
|
86
|
+
return schema;
|
|
87
|
+
}
|
|
88
|
+
if (hasJsonSchema(schema)) {
|
|
89
|
+
return schema.jsonSchema();
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
const converter = getZodConverter();
|
|
93
|
+
if (converter !== null) {
|
|
94
|
+
return converter(schema);
|
|
95
|
+
}
|
|
96
|
+
throw new TypeError("Unsupported schema type. Expected a Zod schema, JSON schema object, or jsonSchema() provider.");
|
|
97
|
+
}
|
|
98
|
+
function isLargeSchema(schemaJson) {
|
|
99
|
+
return estimateTokens(schemaJson) > LARGE_SCHEMA_TOKEN_THRESHOLD;
|
|
100
|
+
}
|
|
101
|
+
function buildPromptSuffix(schema, cwd) {
|
|
102
|
+
const jsonSchema = schemaToJsonSchema(schema);
|
|
103
|
+
const schemaJson = JSON.stringify(jsonSchema, null, 2);
|
|
104
|
+
const outputPath = getOutputPath(cwd);
|
|
105
|
+
if (isLargeSchema(schemaJson)) {
|
|
106
|
+
const schemaPath = writeSchemaFile(schemaJson, cwd);
|
|
107
|
+
return `
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
OUTPUT REQUIREMENTS:
|
|
111
|
+
Read the JSON Schema at: ${schemaPath}
|
|
112
|
+
Write your final answer as valid JSON conforming to that schema to: ${outputPath}
|
|
113
|
+
Do not include any text outside the JSON in that file. Do not wrap in markdown fences.`;
|
|
114
|
+
}
|
|
115
|
+
return `
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
OUTPUT REQUIREMENTS:
|
|
119
|
+
Write your final answer as valid JSON to the file: ${outputPath}
|
|
120
|
+
The JSON must conform to this schema:
|
|
121
|
+
${schemaJson}
|
|
122
|
+
Do not include any text outside the JSON in that file. Do not wrap in markdown fences.`;
|
|
123
|
+
}
|
|
124
|
+
function cosmeticRepair(raw) {
|
|
125
|
+
let text = raw.trim();
|
|
126
|
+
const fenceMatch = text.match(/^```(?:json)?\s*\n([\s\S]*?)```\s*$/);
|
|
127
|
+
if (fenceMatch) {
|
|
128
|
+
text = fenceMatch[1].trim();
|
|
129
|
+
}
|
|
130
|
+
if (text.length > 0 && text[0] !== "{" && text[0] !== "[") {
|
|
131
|
+
const firstJsonCharIndex = [...text].findIndex((char) => char === "{" || char === "[");
|
|
132
|
+
if (firstJsonCharIndex >= 0) {
|
|
133
|
+
text = text.slice(firstJsonCharIndex);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
text = text.replace(/,\s*([}\]])/g, "$1");
|
|
137
|
+
const openBraces = (text.match(/{/g)?.length ?? 0) - (text.match(/}/g)?.length ?? 0);
|
|
138
|
+
const openBrackets = (text.match(/\[/g)?.length ?? 0) - (text.match(/\]/g)?.length ?? 0);
|
|
139
|
+
if (openBraces > 0 || openBrackets > 0) {
|
|
140
|
+
text += "]".repeat(openBrackets) + "}".repeat(openBraces);
|
|
141
|
+
}
|
|
142
|
+
return text;
|
|
143
|
+
}
|
|
144
|
+
function readAndParse(filePath) {
|
|
145
|
+
try {
|
|
146
|
+
const content = fs.readFileSync(filePath, "utf8");
|
|
147
|
+
if (content.trim().length === 0) {
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
return JSON.parse(content);
|
|
151
|
+
} catch {
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
function readRepairAndParse(filePath) {
|
|
156
|
+
try {
|
|
157
|
+
const content = fs.readFileSync(filePath, "utf8");
|
|
158
|
+
if (content.trim().length === 0) {
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
return JSON.parse(cosmeticRepair(content));
|
|
162
|
+
} catch {
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
function parseAndValidate(filePath, schema) {
|
|
167
|
+
const parsed = readAndParse(filePath);
|
|
168
|
+
if (parsed !== null) {
|
|
169
|
+
try {
|
|
170
|
+
return validateAgainstSchema(parsed, schema);
|
|
171
|
+
} catch {
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
const repaired = readRepairAndParse(filePath);
|
|
175
|
+
if (repaired !== null) {
|
|
176
|
+
try {
|
|
177
|
+
return validateAgainstSchema(repaired, schema);
|
|
178
|
+
} catch {
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return null;
|
|
183
|
+
}
|
|
184
|
+
function cleanupTempFiles(cwd) {
|
|
185
|
+
for (const filename of [OUTPUT_FILENAME, SCHEMA_FILENAME]) {
|
|
186
|
+
try {
|
|
187
|
+
fs.unlinkSync(path.join(cwd, filename));
|
|
188
|
+
} catch {
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
var OUTPUT_FILENAME, SCHEMA_FILENAME, LARGE_SCHEMA_TOKEN_THRESHOLD, zodConverter;
|
|
193
|
+
var init_schema = __esm({
|
|
194
|
+
"src/harness/schema.ts"() {
|
|
195
|
+
OUTPUT_FILENAME = ".agentfield_output.json";
|
|
196
|
+
SCHEMA_FILENAME = ".agentfield_schema.json";
|
|
197
|
+
LARGE_SCHEMA_TOKEN_THRESHOLD = 4e3;
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
// src/harness/types.ts
|
|
202
|
+
function createHarnessResult(partial) {
|
|
203
|
+
const r = {
|
|
204
|
+
isError: false,
|
|
205
|
+
numTurns: 0,
|
|
206
|
+
durationMs: 0,
|
|
207
|
+
sessionId: "",
|
|
208
|
+
messages: [],
|
|
209
|
+
...partial,
|
|
210
|
+
get text() {
|
|
211
|
+
return this.result ?? "";
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
return r;
|
|
215
|
+
}
|
|
216
|
+
function createMetrics(partial) {
|
|
217
|
+
return { durationMs: 0, durationApiMs: 0, numTurns: 0, sessionId: "", ...partial };
|
|
218
|
+
}
|
|
219
|
+
function createRawResult(partial) {
|
|
220
|
+
return { messages: [], metrics: createMetrics(), isError: false, ...partial };
|
|
221
|
+
}
|
|
222
|
+
var init_types = __esm({
|
|
223
|
+
"src/harness/types.ts"() {
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
// src/harness/providers/claude.ts
|
|
228
|
+
var claude_exports = {};
|
|
229
|
+
__export(claude_exports, {
|
|
230
|
+
ClaudeCodeProvider: () => ClaudeCodeProvider
|
|
231
|
+
});
|
|
232
|
+
function isRecord2(value) {
|
|
233
|
+
return typeof value === "object" && value !== null;
|
|
234
|
+
}
|
|
235
|
+
function getString(record, key) {
|
|
236
|
+
const value = record[key];
|
|
237
|
+
return typeof value === "string" ? value : void 0;
|
|
238
|
+
}
|
|
239
|
+
function getNumber(record, key) {
|
|
240
|
+
const value = record[key];
|
|
241
|
+
return typeof value === "number" ? value : void 0;
|
|
242
|
+
}
|
|
243
|
+
var ClaudeCodeProvider;
|
|
244
|
+
var init_claude = __esm({
|
|
245
|
+
"src/harness/providers/claude.ts"() {
|
|
246
|
+
init_types();
|
|
247
|
+
ClaudeCodeProvider = class {
|
|
248
|
+
async execute(prompt, options) {
|
|
249
|
+
let sdk;
|
|
250
|
+
try {
|
|
251
|
+
const mod = await import('@anthropic-ai/claude-agent-sdk');
|
|
252
|
+
sdk = mod;
|
|
253
|
+
} catch {
|
|
254
|
+
throw new Error(
|
|
255
|
+
"@anthropic-ai/claude-agent-sdk is required for the 'claude-code' provider. Install it with: npm install @anthropic-ai/claude-agent-sdk"
|
|
256
|
+
);
|
|
257
|
+
}
|
|
258
|
+
const agentOptions = {};
|
|
259
|
+
if (options.model !== void 0) agentOptions.model = options.model;
|
|
260
|
+
if (options.cwd !== void 0) agentOptions.cwd = options.cwd;
|
|
261
|
+
if (options.maxTurns !== void 0) agentOptions.max_turns = options.maxTurns;
|
|
262
|
+
if (options.tools !== void 0) agentOptions.allowed_tools = options.tools;
|
|
263
|
+
if (options.systemPrompt !== void 0) agentOptions.system_prompt = options.systemPrompt;
|
|
264
|
+
if (options.maxBudgetUsd !== void 0) agentOptions.max_budget_usd = options.maxBudgetUsd;
|
|
265
|
+
if (options.permissionMode !== void 0) {
|
|
266
|
+
const modeMap = { auto: "bypassPermissions", plan: "plan" };
|
|
267
|
+
const raw = String(options.permissionMode);
|
|
268
|
+
agentOptions.permission_mode = modeMap[raw] ?? raw;
|
|
269
|
+
}
|
|
270
|
+
if (options.env !== void 0) agentOptions.env = options.env;
|
|
271
|
+
const messages = [];
|
|
272
|
+
let resultText;
|
|
273
|
+
let totalCost;
|
|
274
|
+
let numTurns = 0;
|
|
275
|
+
let sessionId = "";
|
|
276
|
+
const startApi = Date.now();
|
|
277
|
+
try {
|
|
278
|
+
for await (const msg of sdk.query({ prompt, options: agentOptions })) {
|
|
279
|
+
const msgObj = isRecord2(msg) ? msg : { raw: String(msg) };
|
|
280
|
+
messages.push(msgObj);
|
|
281
|
+
const msgType = getString(msgObj, "type") ?? "";
|
|
282
|
+
if (msgType === "result") {
|
|
283
|
+
const resultValue = msgObj.result ?? msgObj.text;
|
|
284
|
+
resultText = typeof resultValue === "string" ? resultValue : resultValue == null ? "" : String(resultValue);
|
|
285
|
+
const sid = getString(msgObj, "session_id");
|
|
286
|
+
if (sid !== void 0) {
|
|
287
|
+
sessionId = sid;
|
|
288
|
+
}
|
|
289
|
+
const costUsd = getNumber(msgObj, "cost_usd");
|
|
290
|
+
const totalCostUsd = getNumber(msgObj, "total_cost_usd");
|
|
291
|
+
if (costUsd !== void 0) {
|
|
292
|
+
totalCost = costUsd;
|
|
293
|
+
} else if (totalCostUsd !== void 0) {
|
|
294
|
+
totalCost = totalCostUsd;
|
|
295
|
+
}
|
|
296
|
+
const turns = getNumber(msgObj, "num_turns");
|
|
297
|
+
numTurns = turns === void 0 ? messages.length : Math.trunc(turns);
|
|
298
|
+
} else if (msgType === "assistant" && resultText === void 0) {
|
|
299
|
+
let content = msgObj.content;
|
|
300
|
+
if (content === void 0 && isRecord2(msgObj.message)) {
|
|
301
|
+
content = msgObj.message.content;
|
|
302
|
+
}
|
|
303
|
+
if (typeof content === "string") {
|
|
304
|
+
resultText = content;
|
|
305
|
+
} else if (Array.isArray(content)) {
|
|
306
|
+
for (const block of content) {
|
|
307
|
+
if (isRecord2(block) && block.type === "text" && typeof block.text === "string") {
|
|
308
|
+
resultText = block.text;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
return createRawResult({
|
|
315
|
+
result: resultText,
|
|
316
|
+
messages,
|
|
317
|
+
metrics: createMetrics({
|
|
318
|
+
durationApiMs: Date.now() - startApi,
|
|
319
|
+
numTurns,
|
|
320
|
+
totalCostUsd: totalCost,
|
|
321
|
+
sessionId
|
|
322
|
+
}),
|
|
323
|
+
isError: false
|
|
324
|
+
});
|
|
325
|
+
} catch (error) {
|
|
326
|
+
return createRawResult({
|
|
327
|
+
result: void 0,
|
|
328
|
+
messages,
|
|
329
|
+
metrics: createMetrics({ durationApiMs: Date.now() - startApi, sessionId }),
|
|
330
|
+
isError: true,
|
|
331
|
+
errorMessage: error instanceof Error ? error.message : String(error)
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
function runCli(cmd, options) {
|
|
339
|
+
return new Promise((resolve, reject) => {
|
|
340
|
+
const [bin, ...args] = cmd;
|
|
341
|
+
const proc = spawn(bin, args, {
|
|
342
|
+
env: { ...process.env, ...options?.env },
|
|
343
|
+
cwd: options?.cwd,
|
|
344
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
345
|
+
});
|
|
346
|
+
let stdout = "";
|
|
347
|
+
let stderr = "";
|
|
348
|
+
proc.stdout.on("data", (data) => {
|
|
349
|
+
stdout += data.toString();
|
|
350
|
+
});
|
|
351
|
+
proc.stderr.on("data", (data) => {
|
|
352
|
+
stderr += data.toString();
|
|
353
|
+
});
|
|
354
|
+
const timer = options?.timeout ? setTimeout(() => {
|
|
355
|
+
proc.kill();
|
|
356
|
+
reject(new Error(`CLI timed out after ${options.timeout}ms`));
|
|
357
|
+
}, options.timeout) : void 0;
|
|
358
|
+
proc.on("close", (code) => {
|
|
359
|
+
if (timer) {
|
|
360
|
+
clearTimeout(timer);
|
|
361
|
+
}
|
|
362
|
+
resolve({ stdout, stderr, exitCode: code ?? 0 });
|
|
363
|
+
});
|
|
364
|
+
proc.on("error", (err) => {
|
|
365
|
+
if (timer) {
|
|
366
|
+
clearTimeout(timer);
|
|
367
|
+
}
|
|
368
|
+
reject(err);
|
|
369
|
+
});
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
function parseJsonl(text) {
|
|
373
|
+
const events = [];
|
|
374
|
+
for (const line of text.split("\n")) {
|
|
375
|
+
const trimmed = line.trim();
|
|
376
|
+
if (!trimmed) {
|
|
377
|
+
continue;
|
|
378
|
+
}
|
|
379
|
+
try {
|
|
380
|
+
events.push(JSON.parse(trimmed));
|
|
381
|
+
} catch {
|
|
382
|
+
continue;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
return events;
|
|
386
|
+
}
|
|
387
|
+
function extractFinalText(events) {
|
|
388
|
+
let result;
|
|
389
|
+
for (const event of events) {
|
|
390
|
+
const type = event.type;
|
|
391
|
+
if (type === "item.completed") {
|
|
392
|
+
const item = event.item;
|
|
393
|
+
if (typeof item === "object" && item !== null) {
|
|
394
|
+
const itemType = item.type;
|
|
395
|
+
const itemText = item.text;
|
|
396
|
+
if (itemType === "agent_message" && typeof itemText === "string") {
|
|
397
|
+
result = itemText;
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
} else if (type === "result") {
|
|
401
|
+
const candidate = event.result ?? event.text;
|
|
402
|
+
if (typeof candidate === "string") {
|
|
403
|
+
result = candidate;
|
|
404
|
+
}
|
|
405
|
+
} else if (type === "turn.completed" && typeof event.text === "string") {
|
|
406
|
+
result = event.text;
|
|
407
|
+
} else if ((type === "message" || type === "assistant") && typeof event.content === "string") {
|
|
408
|
+
result = event.content;
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
return result;
|
|
412
|
+
}
|
|
413
|
+
var init_cli = __esm({
|
|
414
|
+
"src/harness/cli.ts"() {
|
|
415
|
+
}
|
|
416
|
+
});
|
|
417
|
+
|
|
418
|
+
// src/harness/providers/codex.ts
|
|
419
|
+
var codex_exports = {};
|
|
420
|
+
__export(codex_exports, {
|
|
421
|
+
CodexProvider: () => CodexProvider
|
|
422
|
+
});
|
|
423
|
+
var CodexProvider;
|
|
424
|
+
var init_codex = __esm({
|
|
425
|
+
"src/harness/providers/codex.ts"() {
|
|
426
|
+
init_types();
|
|
427
|
+
init_cli();
|
|
428
|
+
CodexProvider = class {
|
|
429
|
+
bin;
|
|
430
|
+
constructor(binPath = "codex") {
|
|
431
|
+
this.bin = binPath;
|
|
432
|
+
}
|
|
433
|
+
async execute(prompt, options) {
|
|
434
|
+
const cmd = [this.bin, "exec", "--json"];
|
|
435
|
+
if (options.cwd) {
|
|
436
|
+
cmd.push("-C", String(options.cwd));
|
|
437
|
+
}
|
|
438
|
+
if (options.permissionMode === "auto") {
|
|
439
|
+
cmd.push("--full-auto");
|
|
440
|
+
}
|
|
441
|
+
cmd.push(prompt);
|
|
442
|
+
const startApi = Date.now();
|
|
443
|
+
try {
|
|
444
|
+
const { stdout, stderr, exitCode } = await runCli(cmd, {
|
|
445
|
+
env: options.env,
|
|
446
|
+
cwd: options.cwd
|
|
447
|
+
});
|
|
448
|
+
const events = parseJsonl(stdout);
|
|
449
|
+
const resultText = extractFinalText(events);
|
|
450
|
+
let numTurns = 0;
|
|
451
|
+
let sessionId = "";
|
|
452
|
+
for (const event of events) {
|
|
453
|
+
if (event.type === "turn.completed") {
|
|
454
|
+
numTurns += 1;
|
|
455
|
+
}
|
|
456
|
+
if (event.type === "thread.started") {
|
|
457
|
+
const threadId = event.thread_id;
|
|
458
|
+
if (typeof threadId === "string") {
|
|
459
|
+
sessionId = threadId;
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
const isError = exitCode !== 0 && !resultText;
|
|
464
|
+
return createRawResult({
|
|
465
|
+
result: resultText,
|
|
466
|
+
messages: events,
|
|
467
|
+
metrics: createMetrics({ durationApiMs: Date.now() - startApi, numTurns, sessionId }),
|
|
468
|
+
isError,
|
|
469
|
+
errorMessage: isError ? stderr.trim() : void 0
|
|
470
|
+
});
|
|
471
|
+
} catch (err) {
|
|
472
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
473
|
+
if (msg.includes("ENOENT")) {
|
|
474
|
+
return createRawResult({
|
|
475
|
+
isError: true,
|
|
476
|
+
errorMessage: `Codex binary not found at '${this.bin}'. Install: https://github.com/openai/codex`,
|
|
477
|
+
metrics: createMetrics({ durationApiMs: Date.now() - startApi })
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
return createRawResult({
|
|
481
|
+
isError: true,
|
|
482
|
+
errorMessage: msg,
|
|
483
|
+
metrics: createMetrics({ durationApiMs: Date.now() - startApi })
|
|
484
|
+
});
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
});
|
|
490
|
+
|
|
491
|
+
// src/harness/providers/gemini.ts
|
|
492
|
+
var gemini_exports = {};
|
|
493
|
+
__export(gemini_exports, {
|
|
494
|
+
GeminiProvider: () => GeminiProvider
|
|
495
|
+
});
|
|
496
|
+
var GeminiProvider;
|
|
497
|
+
var init_gemini = __esm({
|
|
498
|
+
"src/harness/providers/gemini.ts"() {
|
|
499
|
+
init_types();
|
|
500
|
+
init_cli();
|
|
501
|
+
GeminiProvider = class {
|
|
502
|
+
bin;
|
|
503
|
+
constructor(binPath = "gemini") {
|
|
504
|
+
this.bin = binPath;
|
|
505
|
+
}
|
|
506
|
+
async execute(prompt, options) {
|
|
507
|
+
const cmd = [this.bin];
|
|
508
|
+
if (options.cwd) {
|
|
509
|
+
cmd.push("-C", String(options.cwd));
|
|
510
|
+
}
|
|
511
|
+
if (options.permissionMode === "auto") {
|
|
512
|
+
cmd.push("--sandbox");
|
|
513
|
+
}
|
|
514
|
+
if (options.model) {
|
|
515
|
+
cmd.push("-m", String(options.model));
|
|
516
|
+
}
|
|
517
|
+
cmd.push("-p", prompt);
|
|
518
|
+
const startApi = Date.now();
|
|
519
|
+
try {
|
|
520
|
+
const { stdout, stderr, exitCode } = await runCli(cmd, {
|
|
521
|
+
env: options.env,
|
|
522
|
+
cwd: options.cwd
|
|
523
|
+
});
|
|
524
|
+
const resultText = stdout.trim() || void 0;
|
|
525
|
+
const isError = exitCode !== 0 && !resultText;
|
|
526
|
+
return createRawResult({
|
|
527
|
+
result: resultText,
|
|
528
|
+
messages: [],
|
|
529
|
+
metrics: createMetrics({
|
|
530
|
+
durationApiMs: Date.now() - startApi,
|
|
531
|
+
numTurns: resultText ? 1 : 0,
|
|
532
|
+
sessionId: ""
|
|
533
|
+
}),
|
|
534
|
+
isError,
|
|
535
|
+
errorMessage: isError ? stderr.trim() : void 0
|
|
536
|
+
});
|
|
537
|
+
} catch (err) {
|
|
538
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
539
|
+
if (msg.includes("ENOENT")) {
|
|
540
|
+
return createRawResult({
|
|
541
|
+
isError: true,
|
|
542
|
+
errorMessage: `Gemini binary not found at '${this.bin}'. Install: https://github.com/google-gemini/gemini-cli`,
|
|
543
|
+
metrics: createMetrics({ durationApiMs: Date.now() - startApi })
|
|
544
|
+
});
|
|
545
|
+
}
|
|
546
|
+
return createRawResult({
|
|
547
|
+
isError: true,
|
|
548
|
+
errorMessage: msg,
|
|
549
|
+
metrics: createMetrics({ durationApiMs: Date.now() - startApi })
|
|
550
|
+
});
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
};
|
|
554
|
+
}
|
|
555
|
+
});
|
|
556
|
+
|
|
557
|
+
// src/harness/providers/opencode.ts
|
|
558
|
+
var opencode_exports = {};
|
|
559
|
+
__export(opencode_exports, {
|
|
560
|
+
OpenCodeProvider: () => OpenCodeProvider
|
|
561
|
+
});
|
|
562
|
+
var OpenCodeProvider;
|
|
563
|
+
var init_opencode = __esm({
|
|
564
|
+
"src/harness/providers/opencode.ts"() {
|
|
565
|
+
init_types();
|
|
566
|
+
init_cli();
|
|
567
|
+
OpenCodeProvider = class {
|
|
568
|
+
bin;
|
|
569
|
+
constructor(binPath = "opencode") {
|
|
570
|
+
this.bin = binPath;
|
|
571
|
+
}
|
|
572
|
+
async execute(prompt, options) {
|
|
573
|
+
const cmd = [this.bin, "run"];
|
|
574
|
+
if (options.model) {
|
|
575
|
+
cmd.push("--model", String(options.model));
|
|
576
|
+
}
|
|
577
|
+
cmd.push(prompt);
|
|
578
|
+
const startApi = Date.now();
|
|
579
|
+
try {
|
|
580
|
+
const { stdout, stderr, exitCode } = await runCli(cmd, {
|
|
581
|
+
env: options.env,
|
|
582
|
+
cwd: options.cwd
|
|
583
|
+
});
|
|
584
|
+
const resultText = stdout.trim() || void 0;
|
|
585
|
+
const isError = exitCode !== 0 && !resultText;
|
|
586
|
+
return createRawResult({
|
|
587
|
+
result: resultText,
|
|
588
|
+
messages: [],
|
|
589
|
+
metrics: createMetrics({
|
|
590
|
+
durationApiMs: Date.now() - startApi,
|
|
591
|
+
numTurns: resultText ? 1 : 0,
|
|
592
|
+
sessionId: ""
|
|
593
|
+
}),
|
|
594
|
+
isError,
|
|
595
|
+
errorMessage: isError ? stderr.trim() : void 0
|
|
596
|
+
});
|
|
597
|
+
} catch (err) {
|
|
598
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
599
|
+
if (msg.includes("ENOENT")) {
|
|
600
|
+
return createRawResult({
|
|
601
|
+
isError: true,
|
|
602
|
+
errorMessage: `OpenCode binary not found at '${this.bin}'. Install: https://github.com/opencode-ai/opencode`,
|
|
603
|
+
metrics: createMetrics({ durationApiMs: Date.now() - startApi })
|
|
604
|
+
});
|
|
605
|
+
}
|
|
606
|
+
return createRawResult({
|
|
607
|
+
isError: true,
|
|
608
|
+
errorMessage: msg,
|
|
609
|
+
metrics: createMetrics({ durationApiMs: Date.now() - startApi })
|
|
610
|
+
});
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
};
|
|
614
|
+
}
|
|
615
|
+
});
|
|
616
|
+
|
|
617
|
+
// src/harness/providers/factory.ts
|
|
618
|
+
async function buildProvider(config) {
|
|
619
|
+
if (!SUPPORTED_PROVIDERS.has(config.provider)) {
|
|
620
|
+
throw new Error(
|
|
621
|
+
`Unknown harness provider: "${config.provider}". Supported: ${[...SUPPORTED_PROVIDERS].sort().join(", ")}`
|
|
622
|
+
);
|
|
623
|
+
}
|
|
624
|
+
if (config.provider === "claude-code") {
|
|
625
|
+
const { ClaudeCodeProvider: ClaudeCodeProvider2 } = await Promise.resolve().then(() => (init_claude(), claude_exports));
|
|
626
|
+
return new ClaudeCodeProvider2();
|
|
627
|
+
}
|
|
628
|
+
if (config.provider === "codex") {
|
|
629
|
+
const { CodexProvider: CodexProvider2 } = await Promise.resolve().then(() => (init_codex(), codex_exports));
|
|
630
|
+
return new CodexProvider2(config.codexBin ?? "codex");
|
|
631
|
+
}
|
|
632
|
+
if (config.provider === "gemini") {
|
|
633
|
+
const { GeminiProvider: GeminiProvider2 } = await Promise.resolve().then(() => (init_gemini(), gemini_exports));
|
|
634
|
+
return new GeminiProvider2(config.geminiBin ?? "gemini");
|
|
635
|
+
}
|
|
636
|
+
if (config.provider === "opencode") {
|
|
637
|
+
const { OpenCodeProvider: OpenCodeProvider2 } = await Promise.resolve().then(() => (init_opencode(), opencode_exports));
|
|
638
|
+
return new OpenCodeProvider2(config.opencodeBin ?? "opencode");
|
|
639
|
+
}
|
|
640
|
+
throw new Error(`Provider "${config.provider}" is not yet implemented.`);
|
|
641
|
+
}
|
|
642
|
+
var SUPPORTED_PROVIDERS;
|
|
643
|
+
var init_factory = __esm({
|
|
644
|
+
"src/harness/providers/factory.ts"() {
|
|
645
|
+
SUPPORTED_PROVIDERS = /* @__PURE__ */ new Set(["claude-code", "codex", "gemini", "opencode"]);
|
|
646
|
+
}
|
|
647
|
+
});
|
|
648
|
+
|
|
649
|
+
// src/harness/runner.ts
|
|
650
|
+
var runner_exports = {};
|
|
651
|
+
__export(runner_exports, {
|
|
652
|
+
HarnessRunner: () => HarnessRunner
|
|
653
|
+
});
|
|
654
|
+
var TRANSIENT_PATTERNS, HarnessRunner;
|
|
655
|
+
var init_runner = __esm({
|
|
656
|
+
"src/harness/runner.ts"() {
|
|
657
|
+
init_schema();
|
|
658
|
+
init_factory();
|
|
659
|
+
init_types();
|
|
660
|
+
TRANSIENT_PATTERNS = [
|
|
661
|
+
"rate limit",
|
|
662
|
+
"rate_limit",
|
|
663
|
+
"overloaded",
|
|
664
|
+
"timeout",
|
|
665
|
+
"timed out",
|
|
666
|
+
"connection reset",
|
|
667
|
+
"connection refused",
|
|
668
|
+
"temporarily unavailable",
|
|
669
|
+
"service unavailable",
|
|
670
|
+
"503",
|
|
671
|
+
"502",
|
|
672
|
+
"504",
|
|
673
|
+
"internal server error",
|
|
674
|
+
"500"
|
|
675
|
+
];
|
|
676
|
+
HarnessRunner = class {
|
|
677
|
+
constructor(config) {
|
|
678
|
+
this.config = config;
|
|
679
|
+
}
|
|
680
|
+
async run(prompt, options = {}) {
|
|
681
|
+
const { schema, ...rest } = options;
|
|
682
|
+
const resolved = this.resolveOptions(this.config, rest);
|
|
683
|
+
if (!resolved.provider) {
|
|
684
|
+
throw new Error("No harness provider specified. Set 'provider' in HarnessConfig or pass it to .harness() call.");
|
|
685
|
+
}
|
|
686
|
+
const cwd = resolved.cwd ?? ".";
|
|
687
|
+
const provider = await this.buildProvider(resolved.provider, resolved);
|
|
688
|
+
const effectivePrompt = schema === void 0 ? prompt : `${prompt}${buildPromptSuffix(schema, cwd)}`;
|
|
689
|
+
const startTime = Date.now();
|
|
690
|
+
try {
|
|
691
|
+
const raw = await this.executeWithRetry(provider, effectivePrompt, resolved);
|
|
692
|
+
if (schema !== void 0) {
|
|
693
|
+
return this.handleSchemaOutput(raw, schema, cwd, startTime);
|
|
694
|
+
}
|
|
695
|
+
return createHarnessResult({
|
|
696
|
+
result: raw.result,
|
|
697
|
+
isError: raw.isError,
|
|
698
|
+
errorMessage: raw.errorMessage,
|
|
699
|
+
costUsd: raw.metrics.totalCostUsd,
|
|
700
|
+
numTurns: raw.metrics.numTurns,
|
|
701
|
+
durationMs: Date.now() - startTime,
|
|
702
|
+
sessionId: raw.metrics.sessionId,
|
|
703
|
+
messages: raw.messages
|
|
704
|
+
});
|
|
705
|
+
} finally {
|
|
706
|
+
if (schema !== void 0) {
|
|
707
|
+
cleanupTempFiles(cwd);
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
resolveOptions(config, overrides) {
|
|
712
|
+
const out = {};
|
|
713
|
+
if (config) {
|
|
714
|
+
for (const key of [
|
|
715
|
+
"provider",
|
|
716
|
+
"model",
|
|
717
|
+
"maxTurns",
|
|
718
|
+
"maxBudgetUsd",
|
|
719
|
+
"maxRetries",
|
|
720
|
+
"initialDelay",
|
|
721
|
+
"maxDelay",
|
|
722
|
+
"backoffFactor",
|
|
723
|
+
"tools",
|
|
724
|
+
"permissionMode",
|
|
725
|
+
"systemPrompt",
|
|
726
|
+
"env",
|
|
727
|
+
"cwd",
|
|
728
|
+
"codexBin",
|
|
729
|
+
"geminiBin",
|
|
730
|
+
"opencodeBin"
|
|
731
|
+
]) {
|
|
732
|
+
const value = config[key];
|
|
733
|
+
if (value !== void 0 && value !== null) {
|
|
734
|
+
out[key] = value;
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
for (const [key, value] of Object.entries(overrides)) {
|
|
739
|
+
if (value !== void 0 && value !== null) {
|
|
740
|
+
out[key] = value;
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
return out;
|
|
744
|
+
}
|
|
745
|
+
isTransient(errorStr) {
|
|
746
|
+
const lower = errorStr.toLowerCase();
|
|
747
|
+
return TRANSIENT_PATTERNS.some((pattern) => lower.includes(pattern));
|
|
748
|
+
}
|
|
749
|
+
async executeWithRetry(provider, prompt, options) {
|
|
750
|
+
const maxRetries = options.maxRetries ?? 3;
|
|
751
|
+
const initialDelay = options.initialDelay ?? 1;
|
|
752
|
+
const maxDelay = options.maxDelay ?? 30;
|
|
753
|
+
const backoffFactor = options.backoffFactor ?? 2;
|
|
754
|
+
let lastError;
|
|
755
|
+
for (let attempt = 0; attempt <= maxRetries; attempt += 1) {
|
|
756
|
+
try {
|
|
757
|
+
const result = await provider.execute(prompt, options);
|
|
758
|
+
if (!result.isError) {
|
|
759
|
+
return result;
|
|
760
|
+
}
|
|
761
|
+
const message = result.errorMessage ?? "";
|
|
762
|
+
if (this.isTransient(message) && attempt < maxRetries) {
|
|
763
|
+
const delay = this.computeBackoffDelay(initialDelay, backoffFactor, maxDelay, attempt);
|
|
764
|
+
await this.sleep(delay);
|
|
765
|
+
continue;
|
|
766
|
+
}
|
|
767
|
+
return result;
|
|
768
|
+
} catch (error) {
|
|
769
|
+
lastError = error;
|
|
770
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
771
|
+
if (this.isTransient(message) && attempt < maxRetries) {
|
|
772
|
+
const delay = this.computeBackoffDelay(initialDelay, backoffFactor, maxDelay, attempt);
|
|
773
|
+
await this.sleep(delay);
|
|
774
|
+
continue;
|
|
775
|
+
}
|
|
776
|
+
throw error;
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
if (lastError !== void 0) {
|
|
780
|
+
throw lastError;
|
|
781
|
+
}
|
|
782
|
+
return createRawResult({ isError: true, errorMessage: "Max retries exceeded" });
|
|
783
|
+
}
|
|
784
|
+
handleSchemaOutput(raw, schema, cwd, startTime) {
|
|
785
|
+
const outputPath = getOutputPath(cwd);
|
|
786
|
+
const parsed = parseAndValidate(outputPath, schema);
|
|
787
|
+
if (parsed !== null) {
|
|
788
|
+
return createHarnessResult({
|
|
789
|
+
result: raw.result,
|
|
790
|
+
parsed,
|
|
791
|
+
isError: false,
|
|
792
|
+
costUsd: raw.metrics.totalCostUsd,
|
|
793
|
+
numTurns: raw.metrics.numTurns,
|
|
794
|
+
durationMs: Date.now() - startTime,
|
|
795
|
+
sessionId: raw.metrics.sessionId,
|
|
796
|
+
messages: raw.messages
|
|
797
|
+
});
|
|
798
|
+
}
|
|
799
|
+
return createHarnessResult({
|
|
800
|
+
result: raw.result,
|
|
801
|
+
isError: true,
|
|
802
|
+
errorMessage: "Schema validation failed after parse and cosmetic repair attempts.",
|
|
803
|
+
costUsd: raw.metrics.totalCostUsd,
|
|
804
|
+
numTurns: raw.metrics.numTurns,
|
|
805
|
+
durationMs: Date.now() - startTime,
|
|
806
|
+
sessionId: raw.metrics.sessionId,
|
|
807
|
+
messages: raw.messages
|
|
808
|
+
});
|
|
809
|
+
}
|
|
810
|
+
async buildProvider(providerName, options) {
|
|
811
|
+
const { provider: _, ...rest } = options;
|
|
812
|
+
return buildProvider({ provider: providerName, ...rest });
|
|
813
|
+
}
|
|
814
|
+
computeBackoffDelay(initialDelay, backoffFactor, maxDelay, attempt) {
|
|
815
|
+
const base = Math.min(initialDelay * backoffFactor ** attempt, maxDelay);
|
|
816
|
+
const jitter = Math.random() * (base * 0.5) - base * 0.25;
|
|
817
|
+
return base + jitter;
|
|
818
|
+
}
|
|
819
|
+
sleep(delaySeconds) {
|
|
820
|
+
return new Promise((resolve) => {
|
|
821
|
+
setTimeout(resolve, Math.max(0, delaySeconds) * 1e3);
|
|
822
|
+
});
|
|
823
|
+
}
|
|
824
|
+
};
|
|
825
|
+
}
|
|
826
|
+
});
|
|
23
827
|
|
|
24
828
|
// src/agent/ReasonerRegistry.ts
|
|
25
829
|
var ReasonerRegistry = class {
|
|
@@ -2226,6 +3030,7 @@ function evaluateConstraints(constraints, inputParams) {
|
|
|
2226
3030
|
// src/agent/Agent.ts
|
|
2227
3031
|
var TargetNotFoundError = class extends Error {
|
|
2228
3032
|
};
|
|
3033
|
+
var harnessRunners = /* @__PURE__ */ new WeakMap();
|
|
2229
3034
|
var Agent = class {
|
|
2230
3035
|
config;
|
|
2231
3036
|
app;
|
|
@@ -2330,6 +3135,18 @@ var Agent = class {
|
|
|
2330
3135
|
getAIClient() {
|
|
2331
3136
|
return this.aiClient;
|
|
2332
3137
|
}
|
|
3138
|
+
async getHarnessRunner() {
|
|
3139
|
+
const cached = harnessRunners.get(this);
|
|
3140
|
+
if (cached) return cached;
|
|
3141
|
+
const { HarnessRunner: RunnerClass } = await Promise.resolve().then(() => (init_runner(), runner_exports));
|
|
3142
|
+
const runner = new RunnerClass(this.config.harnessConfig);
|
|
3143
|
+
harnessRunners.set(this, runner);
|
|
3144
|
+
return runner;
|
|
3145
|
+
}
|
|
3146
|
+
async harness(prompt, options) {
|
|
3147
|
+
const runner = await this.getHarnessRunner();
|
|
3148
|
+
return runner.run(prompt, options ?? {});
|
|
3149
|
+
}
|
|
2333
3150
|
getMemoryInterface(metadata) {
|
|
2334
3151
|
const defaultScope = this.config.memoryConfig?.defaultScope ?? "workflow";
|
|
2335
3152
|
const defaultScopeId = defaultScope === "session" ? metadata?.sessionId : defaultScope === "actor" ? metadata?.actorId : metadata?.workflowId ?? metadata?.runId ?? metadata?.sessionId ?? metadata?.actorId;
|
|
@@ -2570,22 +3387,22 @@ var Agent = class {
|
|
|
2570
3387
|
},
|
|
2571
3388
|
message: { error: "rate_limit_exceeded", message: "Too many authentication attempts. Try again later." },
|
|
2572
3389
|
skip: (req) => {
|
|
2573
|
-
const
|
|
2574
|
-
if (!
|
|
3390
|
+
const path2 = req.path;
|
|
3391
|
+
if (!path2.startsWith("/reasoners/") && !path2.startsWith("/skills/") && !path2.startsWith("/execute") && !path2.startsWith("/api/v1/reasoners/") && !path2.startsWith("/api/v1/skills/")) {
|
|
2575
3392
|
return true;
|
|
2576
3393
|
}
|
|
2577
|
-
const parts =
|
|
3394
|
+
const parts = path2.replace(/^\/+/, "").split("/");
|
|
2578
3395
|
const funcName = parts[parts.length - 1] ?? "";
|
|
2579
3396
|
return realtimeFunctions.has(funcName);
|
|
2580
3397
|
}
|
|
2581
3398
|
});
|
|
2582
3399
|
this.app.use(authRateLimiter);
|
|
2583
3400
|
this.app.use(async (req, res, next) => {
|
|
2584
|
-
const
|
|
2585
|
-
if (!
|
|
3401
|
+
const path2 = req.path;
|
|
3402
|
+
if (!path2.startsWith("/reasoners/") && !path2.startsWith("/skills/") && !path2.startsWith("/execute") && !path2.startsWith("/api/v1/reasoners/") && !path2.startsWith("/api/v1/skills/")) {
|
|
2586
3403
|
return next();
|
|
2587
3404
|
}
|
|
2588
|
-
const parts =
|
|
3405
|
+
const parts = path2.replace(/^\/+/, "").split("/");
|
|
2589
3406
|
const funcName = parts[parts.length - 1] ?? "";
|
|
2590
3407
|
if (realtimeFunctions.has(funcName)) {
|
|
2591
3408
|
return next();
|
|
@@ -2772,9 +3589,9 @@ var Agent = class {
|
|
|
2772
3589
|
return handler(req, res);
|
|
2773
3590
|
}
|
|
2774
3591
|
async handleServerlessEvent(event) {
|
|
2775
|
-
const
|
|
3592
|
+
const path2 = event?.path ?? event?.rawPath ?? "";
|
|
2776
3593
|
const action = event?.action ?? "";
|
|
2777
|
-
if (
|
|
3594
|
+
if (path2 === "/discover" || action === "discover") {
|
|
2778
3595
|
return {
|
|
2779
3596
|
statusCode: 200,
|
|
2780
3597
|
headers: { "content-type": "application/json" },
|
|
@@ -2783,7 +3600,7 @@ var Agent = class {
|
|
|
2783
3600
|
}
|
|
2784
3601
|
const body = this.normalizeEventBody(event);
|
|
2785
3602
|
const invocation = this.extractInvocationDetails({
|
|
2786
|
-
path,
|
|
3603
|
+
path: path2,
|
|
2787
3604
|
query: event?.queryStringParameters,
|
|
2788
3605
|
body,
|
|
2789
3606
|
reasoner: event?.reasoner,
|
|
@@ -2873,9 +3690,9 @@ var Agent = class {
|
|
|
2873
3690
|
const input = this.normalizeInputPayload(params.body);
|
|
2874
3691
|
return { name: name ?? void 0, targetType: typeValue, input };
|
|
2875
3692
|
}
|
|
2876
|
-
parsePathTarget(
|
|
2877
|
-
if (!
|
|
2878
|
-
const normalized =
|
|
3693
|
+
parsePathTarget(path2) {
|
|
3694
|
+
if (!path2) return {};
|
|
3695
|
+
const normalized = path2.split("?")[0];
|
|
2879
3696
|
const reasonerMatch = normalized.match(/\/reasoners\/([^/]+)/);
|
|
2880
3697
|
if (reasonerMatch?.[1]) {
|
|
2881
3698
|
return { name: reasonerMatch[1], targetType: "reasoner" };
|
|
@@ -3221,6 +4038,11 @@ function sanitize(value) {
|
|
|
3221
4038
|
return value.replace(/[^0-9a-zA-Z]+/g, "_").replace(/_+/g, "_").replace(/^_+|_+$/g, "");
|
|
3222
4039
|
}
|
|
3223
4040
|
|
|
4041
|
+
// src/harness/index.ts
|
|
4042
|
+
init_types();
|
|
4043
|
+
init_factory();
|
|
4044
|
+
init_runner();
|
|
4045
|
+
|
|
3224
4046
|
// src/status/ExecutionStatus.ts
|
|
3225
4047
|
var ExecutionStatus = {
|
|
3226
4048
|
PENDING: "pending",
|
|
@@ -3380,6 +4202,6 @@ function sleep(ms) {
|
|
|
3380
4202
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
3381
4203
|
}
|
|
3382
4204
|
|
|
3383
|
-
export { ACTIVE_STATUSES, AIClient, Agent, AgentRouter, ApprovalClient, CANONICAL_STATUSES, DIDAuthenticator, DidClient, DidInterface, DidManager, ExecutionContext, ExecutionStatus, HEADER_CALLER_DID, HEADER_DID_NONCE, HEADER_DID_SIGNATURE, HEADER_DID_TIMESTAMP, MCPClient, MCPClientRegistry, MCPToolRegistrar, MemoryClient, MemoryEventClient, MemoryInterface, RateLimitError, ReasonerContext, SkillContext, StatelessRateLimiter, TERMINAL_STATUSES, WorkflowReporter, getCurrentContext, getCurrentSkillContext, isActive, isTerminal, normalizeStatus };
|
|
4205
|
+
export { ACTIVE_STATUSES, AIClient, Agent, AgentRouter, ApprovalClient, CANONICAL_STATUSES, DIDAuthenticator, DidClient, DidInterface, DidManager, ExecutionContext, ExecutionStatus, HEADER_CALLER_DID, HEADER_DID_NONCE, HEADER_DID_SIGNATURE, HEADER_DID_TIMESTAMP, HarnessRunner, MCPClient, MCPClientRegistry, MCPToolRegistrar, MemoryClient, MemoryEventClient, MemoryInterface, RateLimitError, ReasonerContext, SUPPORTED_PROVIDERS, SkillContext, StatelessRateLimiter, TERMINAL_STATUSES, WorkflowReporter, buildProvider, createHarnessResult, createMetrics, createRawResult, getCurrentContext, getCurrentSkillContext, isActive, isTerminal, normalizeStatus };
|
|
3384
4206
|
//# sourceMappingURL=index.js.map
|
|
3385
4207
|
//# sourceMappingURL=index.js.map
|