@theokit/sdk 2.0.0 → 2.0.1
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 +18 -0
- package/dist/a2a/index.cjs +154 -148
- package/dist/a2a/index.cjs.map +1 -1
- package/dist/a2a/index.js +154 -148
- package/dist/a2a/index.js.map +1 -1
- package/dist/{cron-Ci_NUkUj.d.ts → cron-Bj8-Aq1O.d.ts} +1 -1
- package/dist/{cron-Bse1MbaE.d.cts → cron-DFG9-W17.d.cts} +1 -1
- package/dist/cron.cjs +135 -128
- package/dist/cron.cjs.map +1 -1
- package/dist/cron.d.cts +1 -1
- package/dist/cron.d.ts +1 -1
- package/dist/cron.js +138 -131
- package/dist/cron.js.map +1 -1
- package/dist/eval.cjs +134 -124
- package/dist/eval.cjs.map +1 -1
- package/dist/eval.d.cts +1 -0
- package/dist/eval.d.ts +1 -0
- package/dist/eval.js +137 -127
- package/dist/eval.js.map +1 -1
- package/dist/index.cjs +113 -106
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +113 -106
- package/dist/index.js.map +1 -1
- package/dist/internal/runtime/{fork-agent.d.ts → lifecycle/fork-agent.d.ts} +1 -1
- package/dist/internal/runtime/{run-until.d.ts → lifecycle/run-until.d.ts} +3 -3
- package/dist/internal/runtime/local-agent/local-agent-bootstrap.d.ts +1 -1
- package/dist/internal/runtime/registry/agent-factory-registry.d.ts +12 -9
- package/dist/internal/scorers/llm-judge.d.ts +4 -4
- package/dist/internal/security/index.d.cts +1 -1
- package/dist/internal/security/index.d.ts +1 -1
- package/dist/types/fork.d.ts +1 -1
- package/dist/workflow.cjs +2 -2
- package/dist/workflow.cjs.map +1 -1
- package/dist/workflow.js +2 -2
- package/dist/workflow.js.map +1 -1
- package/package.json +6 -2
- /package/dist/internal/{errors/mappers → error-mappers}/anthropic.d.ts +0 -0
- /package/dist/internal/{errors/mappers → error-mappers}/bedrock.d.ts +0 -0
- /package/dist/internal/{errors/mappers → error-mappers}/ollama.d.ts +0 -0
- /package/dist/internal/{errors/mappers → error-mappers}/openai-compatible.d.ts +0 -0
- /package/dist/internal/{errors/mappers → error-mappers}/shared.d.ts +0 -0
- /package/dist/internal/{errors/mappers → error-mappers}/vertex.d.ts +0 -0
- /package/dist/internal/runtime/{abort-utils.d.ts → concurrency/abort-utils.d.ts} +0 -0
- /package/dist/internal/runtime/{async-local-storage.d.ts → concurrency/async-local-storage.d.ts} +0 -0
- /package/dist/internal/runtime/{async-semaphore.d.ts → concurrency/async-semaphore.d.ts} +0 -0
- /package/dist/internal/runtime/{default-model.d.ts → config/default-model.d.ts} +0 -0
- /package/dist/internal/runtime/{providers-manager.d.ts → config/providers-manager.d.ts} +0 -0
- /package/dist/internal/runtime/{workspace-dir.d.ts → config/workspace-dir.d.ts} +0 -0
- /package/dist/internal/runtime/{yaml-frontmatter.d.ts → context/yaml-frontmatter.d.ts} +0 -0
- /package/dist/internal/runtime/{post-run-lifecycle.d.ts → lifecycle/post-run-lifecycle.d.ts} +0 -0
- /package/dist/internal/runtime/{spawn-collect.d.ts → lifecycle/spawn-collect.d.ts} +0 -0
- /package/dist/internal/runtime/{system-prompt.d.ts → system-prompt/system-prompt.d.ts} +0 -0
- /package/dist/internal/runtime/{shell-tool.d.ts → tools/shell-tool.d.ts} +0 -0
- /package/dist/internal/runtime/{validate-agent-options.d.ts → validation/validate-agent-options.d.ts} +0 -0
- /package/dist/internal/runtime/{validate-response.d.ts → validation/validate-response.d.ts} +0 -0
package/dist/eval.d.cts
CHANGED
package/dist/eval.d.ts
CHANGED
package/dist/eval.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { randomUUID,
|
|
2
|
-
import {
|
|
1
|
+
import { randomUUID, randomBytes, createHash } from 'crypto';
|
|
2
|
+
import { readFile, unlink, mkdir, open, rename, statfs, stat, rm, readdir, appendFile, access } from 'fs/promises';
|
|
3
3
|
import { join, dirname, resolve, sep, relative, isAbsolute } from 'path';
|
|
4
4
|
import { z, toJSONSchema } from 'zod';
|
|
5
|
-
import { existsSync, realpathSync, lstatSync, readlinkSync,
|
|
5
|
+
import { mkdirSync, readdirSync, existsSync, realpathSync, lstatSync, readlinkSync, readFileSync } from 'fs';
|
|
6
6
|
import { AsyncLocalStorage } from 'async_hooks';
|
|
7
7
|
import { createRequire } from 'module';
|
|
8
8
|
import { homedir } from 'os';
|
|
@@ -582,7 +582,7 @@ var init_atomic_write = __esm({
|
|
|
582
582
|
}
|
|
583
583
|
});
|
|
584
584
|
|
|
585
|
-
// src/internal/runtime/yaml-frontmatter.ts
|
|
585
|
+
// src/internal/runtime/context/yaml-frontmatter.ts
|
|
586
586
|
function parseSimpleYaml(text) {
|
|
587
587
|
const fields = {};
|
|
588
588
|
for (const line of text.split(/\r?\n/)) {
|
|
@@ -606,7 +606,7 @@ function coerce(raw) {
|
|
|
606
606
|
return raw;
|
|
607
607
|
}
|
|
608
608
|
var init_yaml_frontmatter = __esm({
|
|
609
|
-
"src/internal/runtime/yaml-frontmatter.ts"() {
|
|
609
|
+
"src/internal/runtime/context/yaml-frontmatter.ts"() {
|
|
610
610
|
}
|
|
611
611
|
});
|
|
612
612
|
async function loadMarkdownEntities(opts) {
|
|
@@ -809,7 +809,7 @@ function checkToolWhitelist(toolName) {
|
|
|
809
809
|
}
|
|
810
810
|
var toolWhitelistStore;
|
|
811
811
|
var init_async_local_storage = __esm({
|
|
812
|
-
"src/internal/runtime/async-local-storage.ts"() {
|
|
812
|
+
"src/internal/runtime/concurrency/async-local-storage.ts"() {
|
|
813
813
|
toolWhitelistStore = new AsyncLocalStorage();
|
|
814
814
|
}
|
|
815
815
|
});
|
|
@@ -1158,7 +1158,7 @@ var init_local_agent_plugins = __esm({
|
|
|
1158
1158
|
}
|
|
1159
1159
|
});
|
|
1160
1160
|
|
|
1161
|
-
// src/internal/runtime/run-until.ts
|
|
1161
|
+
// src/internal/runtime/lifecycle/run-until.ts
|
|
1162
1162
|
var run_until_exports = {};
|
|
1163
1163
|
__export(run_until_exports, {
|
|
1164
1164
|
composeContinuation: () => composeContinuation,
|
|
@@ -1251,7 +1251,7 @@ Your last response was:
|
|
|
1251
1251
|
${lastResponse.slice(0, 1e3)}`;
|
|
1252
1252
|
}
|
|
1253
1253
|
var init_run_until = __esm({
|
|
1254
|
-
"src/internal/runtime/run-until.ts"() {
|
|
1254
|
+
"src/internal/runtime/lifecycle/run-until.ts"() {
|
|
1255
1255
|
}
|
|
1256
1256
|
});
|
|
1257
1257
|
|
|
@@ -1362,16 +1362,16 @@ var init_judge_call = __esm({
|
|
|
1362
1362
|
// src/internal/runtime/registry/agent-factory-registry.ts
|
|
1363
1363
|
var agent_factory_registry_exports = {};
|
|
1364
1364
|
__export(agent_factory_registry_exports, {
|
|
1365
|
-
|
|
1366
|
-
|
|
1365
|
+
getAgentFacade: () => getAgentFacade,
|
|
1366
|
+
setAgentFacade: () => setAgentFacade
|
|
1367
1367
|
});
|
|
1368
|
-
function
|
|
1369
|
-
registered3 =
|
|
1368
|
+
function setAgentFacade(facade) {
|
|
1369
|
+
registered3 = facade;
|
|
1370
1370
|
}
|
|
1371
|
-
function
|
|
1371
|
+
function getAgentFacade() {
|
|
1372
1372
|
if (registered3 === void 0) {
|
|
1373
1373
|
throw new Error(
|
|
1374
|
-
"internal: Agent
|
|
1374
|
+
"internal: Agent facade not registered. The `agent.ts` module must be loaded before internal subsystems (LocalAgent.runUntil/fork, eval, scorers, cron) invoke it."
|
|
1375
1375
|
);
|
|
1376
1376
|
}
|
|
1377
1377
|
return registered3;
|
|
@@ -1382,7 +1382,7 @@ var init_agent_factory_registry = __esm({
|
|
|
1382
1382
|
}
|
|
1383
1383
|
});
|
|
1384
1384
|
|
|
1385
|
-
// src/internal/runtime/fork-agent.ts
|
|
1385
|
+
// src/internal/runtime/lifecycle/fork-agent.ts
|
|
1386
1386
|
var fork_agent_exports = {};
|
|
1387
1387
|
__export(fork_agent_exports, {
|
|
1388
1388
|
filterMemoryPlugins: () => filterMemoryPlugins,
|
|
@@ -1442,7 +1442,7 @@ function extractUsage(result) {
|
|
|
1442
1442
|
};
|
|
1443
1443
|
}
|
|
1444
1444
|
var init_fork_agent = __esm({
|
|
1445
|
-
"src/internal/runtime/fork-agent.ts"() {
|
|
1445
|
+
"src/internal/runtime/lifecycle/fork-agent.ts"() {
|
|
1446
1446
|
init_async_local_storage();
|
|
1447
1447
|
init_local_agent_plugins();
|
|
1448
1448
|
}
|
|
@@ -1465,7 +1465,7 @@ var init_task = __esm({
|
|
|
1465
1465
|
}
|
|
1466
1466
|
});
|
|
1467
1467
|
|
|
1468
|
-
// src/internal/runtime/async-semaphore.ts
|
|
1468
|
+
// src/internal/runtime/concurrency/async-semaphore.ts
|
|
1469
1469
|
function createSemaphore(permits) {
|
|
1470
1470
|
if (!Number.isInteger(permits) || permits < 1) {
|
|
1471
1471
|
throw new ConfigurationError(
|
|
@@ -1503,7 +1503,7 @@ function createSemaphore(permits) {
|
|
|
1503
1503
|
};
|
|
1504
1504
|
}
|
|
1505
1505
|
var init_async_semaphore = __esm({
|
|
1506
|
-
"src/internal/runtime/async-semaphore.ts"() {
|
|
1506
|
+
"src/internal/runtime/concurrency/async-semaphore.ts"() {
|
|
1507
1507
|
init_errors();
|
|
1508
1508
|
}
|
|
1509
1509
|
});
|
|
@@ -3080,7 +3080,7 @@ function sanitizeIdentifier(input, options) {
|
|
|
3080
3080
|
return input.toLowerCase();
|
|
3081
3081
|
}
|
|
3082
3082
|
|
|
3083
|
-
// src/internal/runtime/default-model.ts
|
|
3083
|
+
// src/internal/runtime/config/default-model.ts
|
|
3084
3084
|
var DEFAULT_AGENTIC_MODEL_ID = "google/gemini-2.0-flash-001";
|
|
3085
3085
|
|
|
3086
3086
|
// src/internal/runtime/registry/agent-registry-store.ts
|
|
@@ -3401,7 +3401,7 @@ async function flushRegistrySaves(cwd) {
|
|
|
3401
3401
|
}
|
|
3402
3402
|
}
|
|
3403
3403
|
|
|
3404
|
-
// src/internal/runtime/system-prompt.ts
|
|
3404
|
+
// src/internal/runtime/system-prompt/system-prompt.ts
|
|
3405
3405
|
async function resolveSystemPrompt(agent, override, ctx) {
|
|
3406
3406
|
if (override !== void 0) return override;
|
|
3407
3407
|
if (agent === void 0) return void 0;
|
|
@@ -5784,28 +5784,6 @@ function parseDecisionFromStdout(stdout) {
|
|
|
5784
5784
|
return { decision: "allow" };
|
|
5785
5785
|
}
|
|
5786
5786
|
|
|
5787
|
-
// src/internal/runtime/memory/memory-path-selector.ts
|
|
5788
|
-
var PORT_MEMORY_PATH_ENV_VAR = "THEOKIT_PORT_MEMORY_PATH";
|
|
5789
|
-
function shouldUsePortMemoryPath() {
|
|
5790
|
-
const env = globalThis.process?.env;
|
|
5791
|
-
if (env === void 0) return false;
|
|
5792
|
-
const val = env[PORT_MEMORY_PATH_ENV_VAR];
|
|
5793
|
-
return val === "1" || val === "true";
|
|
5794
|
-
}
|
|
5795
|
-
function resolveMemoryProviderForLoop(consumerSupplied, defaultAdapter, portPathEnabled) {
|
|
5796
|
-
if (consumerSupplied !== void 0) return consumerSupplied;
|
|
5797
|
-
if (portPathEnabled) return defaultAdapter;
|
|
5798
|
-
return void 0;
|
|
5799
|
-
}
|
|
5800
|
-
function resolveMemoryToolsForLoop(legacyTools, portPathEnabled) {
|
|
5801
|
-
if (portPathEnabled) return void 0;
|
|
5802
|
-
return legacyTools;
|
|
5803
|
-
}
|
|
5804
|
-
function resolveActiveMemorySummaryForSend(legacySummary, portPathEnabled) {
|
|
5805
|
-
if (portPathEnabled) return void 0;
|
|
5806
|
-
return legacySummary;
|
|
5807
|
-
}
|
|
5808
|
-
|
|
5809
5787
|
// src/internal/memory/storage/session-summary-writer.ts
|
|
5810
5788
|
init_atomic_write();
|
|
5811
5789
|
var MAX_TURN_CHARS = 2e3;
|
|
@@ -5849,6 +5827,28 @@ async function writeSessionSummary(input) {
|
|
|
5849
5827
|
await replaceFileAtomic(path, body);
|
|
5850
5828
|
}
|
|
5851
5829
|
|
|
5830
|
+
// src/internal/runtime/memory/memory-path-selector.ts
|
|
5831
|
+
var PORT_MEMORY_PATH_ENV_VAR = "THEOKIT_PORT_MEMORY_PATH";
|
|
5832
|
+
function shouldUsePortMemoryPath() {
|
|
5833
|
+
const env = globalThis.process?.env;
|
|
5834
|
+
if (env === void 0) return false;
|
|
5835
|
+
const val = env[PORT_MEMORY_PATH_ENV_VAR];
|
|
5836
|
+
return val === "1" || val === "true";
|
|
5837
|
+
}
|
|
5838
|
+
function resolveMemoryProviderForLoop(consumerSupplied, defaultAdapter, portPathEnabled) {
|
|
5839
|
+
if (consumerSupplied !== void 0) return consumerSupplied;
|
|
5840
|
+
if (portPathEnabled) return defaultAdapter;
|
|
5841
|
+
return void 0;
|
|
5842
|
+
}
|
|
5843
|
+
function resolveMemoryToolsForLoop(legacyTools, portPathEnabled) {
|
|
5844
|
+
if (portPathEnabled) return void 0;
|
|
5845
|
+
return legacyTools;
|
|
5846
|
+
}
|
|
5847
|
+
function resolveActiveMemorySummaryForSend(legacySummary, portPathEnabled) {
|
|
5848
|
+
if (portPathEnabled) return void 0;
|
|
5849
|
+
return legacySummary;
|
|
5850
|
+
}
|
|
5851
|
+
|
|
5852
5852
|
// src/internal/runtime/session/agent-session-store.ts
|
|
5853
5853
|
init_atomic_write();
|
|
5854
5854
|
var VALID_ROLES = /* @__PURE__ */ new Set([
|
|
@@ -6105,7 +6105,7 @@ function clearSession(agentId) {
|
|
|
6105
6105
|
sessions.delete(agentId);
|
|
6106
6106
|
}
|
|
6107
6107
|
|
|
6108
|
-
// src/internal/runtime/post-run-lifecycle.ts
|
|
6108
|
+
// src/internal/runtime/lifecycle/post-run-lifecycle.ts
|
|
6109
6109
|
async function runPostRunLifecycle(inputs) {
|
|
6110
6110
|
const {
|
|
6111
6111
|
run,
|
|
@@ -6337,7 +6337,7 @@ var liveAgentRegistry = new LiveAgentRegistry();
|
|
|
6337
6337
|
// src/internal/runtime/skills/subagents-loader.ts
|
|
6338
6338
|
init_errors();
|
|
6339
6339
|
|
|
6340
|
-
// src/internal/runtime/workspace-dir.ts
|
|
6340
|
+
// src/internal/runtime/config/workspace-dir.ts
|
|
6341
6341
|
init_errors();
|
|
6342
6342
|
async function readWorkspaceDir(root, errorCode, describe) {
|
|
6343
6343
|
try {
|
|
@@ -6623,7 +6623,7 @@ var SystemPromptPipeline = class _SystemPromptPipeline {
|
|
|
6623
6623
|
}
|
|
6624
6624
|
};
|
|
6625
6625
|
|
|
6626
|
-
// src/internal/runtime/validate-agent-options.ts
|
|
6626
|
+
// src/internal/runtime/validation/validate-agent-options.ts
|
|
6627
6627
|
init_errors();
|
|
6628
6628
|
function validateAgentOptions(options) {
|
|
6629
6629
|
rejectProgrammaticHooks(options);
|
|
@@ -6818,6 +6818,71 @@ function validateMemory(options) {
|
|
|
6818
6818
|
}
|
|
6819
6819
|
}
|
|
6820
6820
|
|
|
6821
|
+
// src/internal/runtime/config/providers-manager.ts
|
|
6822
|
+
var ProvidersManagerImpl = class {
|
|
6823
|
+
constructor(model, providers, plugins) {
|
|
6824
|
+
this.model = model;
|
|
6825
|
+
this.providers = providers;
|
|
6826
|
+
this.plugins = plugins;
|
|
6827
|
+
}
|
|
6828
|
+
model;
|
|
6829
|
+
providers;
|
|
6830
|
+
plugins;
|
|
6831
|
+
routes() {
|
|
6832
|
+
const resolved = [];
|
|
6833
|
+
const modelProvider = providerFromModel(this.model);
|
|
6834
|
+
const seen = /* @__PURE__ */ new Set();
|
|
6835
|
+
if (this.providers?.routes !== void 0) {
|
|
6836
|
+
for (const route of this.providers.routes) {
|
|
6837
|
+
const resolvedRoute = resolveRoute(route, modelProvider, this.plugins);
|
|
6838
|
+
if (!seen.has(route.capability)) {
|
|
6839
|
+
seen.add(route.capability);
|
|
6840
|
+
resolved.push(resolvedRoute);
|
|
6841
|
+
}
|
|
6842
|
+
}
|
|
6843
|
+
}
|
|
6844
|
+
return Promise.resolve(resolved);
|
|
6845
|
+
}
|
|
6846
|
+
};
|
|
6847
|
+
function providerFromModel(model) {
|
|
6848
|
+
if (model === void 0) return void 0;
|
|
6849
|
+
const id = model.id;
|
|
6850
|
+
if (id.includes(":")) return id.split(":")[0];
|
|
6851
|
+
return void 0;
|
|
6852
|
+
}
|
|
6853
|
+
function resolveRoute(route, modelProvider, plugins) {
|
|
6854
|
+
if (route.capability === "chat" && modelProvider === route.provider) {
|
|
6855
|
+
const modelName = extractModelName(modelProvider, route);
|
|
6856
|
+
const base = {
|
|
6857
|
+
capability: route.capability,
|
|
6858
|
+
provider: route.provider,
|
|
6859
|
+
reason: "explicit-model-provider"
|
|
6860
|
+
};
|
|
6861
|
+
if (modelName !== void 0) base.model = modelName;
|
|
6862
|
+
return base;
|
|
6863
|
+
}
|
|
6864
|
+
if (plugins?.enabled !== void 0 && plugins.enabled.length > 0) {
|
|
6865
|
+
return {
|
|
6866
|
+
capability: route.capability,
|
|
6867
|
+
provider: route.provider,
|
|
6868
|
+
reason: "first-available-plugin-provider"
|
|
6869
|
+
};
|
|
6870
|
+
}
|
|
6871
|
+
return {
|
|
6872
|
+
capability: route.capability,
|
|
6873
|
+
provider: route.provider,
|
|
6874
|
+
reason: "explicit-route"
|
|
6875
|
+
};
|
|
6876
|
+
}
|
|
6877
|
+
function extractModelName(prefix, route) {
|
|
6878
|
+
if (route.model !== void 0) return route.model;
|
|
6879
|
+
return prefix === route.provider ? defaultModelForProvider(prefix) : void 0;
|
|
6880
|
+
}
|
|
6881
|
+
function defaultModelForProvider(provider) {
|
|
6882
|
+
if (provider === "anthropic") return "claude-3-7-sonnet";
|
|
6883
|
+
return void 0;
|
|
6884
|
+
}
|
|
6885
|
+
|
|
6821
6886
|
// src/internal/runtime/context/context-manager.ts
|
|
6822
6887
|
init_errors();
|
|
6823
6888
|
init_markdown_config_loader();
|
|
@@ -7614,71 +7679,6 @@ async function loadPluginManifestFromMarkdown(pluginsRoot, folderName) {
|
|
|
7614
7679
|
return metadata;
|
|
7615
7680
|
}
|
|
7616
7681
|
|
|
7617
|
-
// src/internal/runtime/providers-manager.ts
|
|
7618
|
-
var ProvidersManagerImpl = class {
|
|
7619
|
-
constructor(model, providers, plugins) {
|
|
7620
|
-
this.model = model;
|
|
7621
|
-
this.providers = providers;
|
|
7622
|
-
this.plugins = plugins;
|
|
7623
|
-
}
|
|
7624
|
-
model;
|
|
7625
|
-
providers;
|
|
7626
|
-
plugins;
|
|
7627
|
-
routes() {
|
|
7628
|
-
const resolved = [];
|
|
7629
|
-
const modelProvider = providerFromModel(this.model);
|
|
7630
|
-
const seen = /* @__PURE__ */ new Set();
|
|
7631
|
-
if (this.providers?.routes !== void 0) {
|
|
7632
|
-
for (const route of this.providers.routes) {
|
|
7633
|
-
const resolvedRoute = resolveRoute(route, modelProvider, this.plugins);
|
|
7634
|
-
if (!seen.has(route.capability)) {
|
|
7635
|
-
seen.add(route.capability);
|
|
7636
|
-
resolved.push(resolvedRoute);
|
|
7637
|
-
}
|
|
7638
|
-
}
|
|
7639
|
-
}
|
|
7640
|
-
return Promise.resolve(resolved);
|
|
7641
|
-
}
|
|
7642
|
-
};
|
|
7643
|
-
function providerFromModel(model) {
|
|
7644
|
-
if (model === void 0) return void 0;
|
|
7645
|
-
const id = model.id;
|
|
7646
|
-
if (id.includes(":")) return id.split(":")[0];
|
|
7647
|
-
return void 0;
|
|
7648
|
-
}
|
|
7649
|
-
function resolveRoute(route, modelProvider, plugins) {
|
|
7650
|
-
if (route.capability === "chat" && modelProvider === route.provider) {
|
|
7651
|
-
const modelName = extractModelName(modelProvider, route);
|
|
7652
|
-
const base = {
|
|
7653
|
-
capability: route.capability,
|
|
7654
|
-
provider: route.provider,
|
|
7655
|
-
reason: "explicit-model-provider"
|
|
7656
|
-
};
|
|
7657
|
-
if (modelName !== void 0) base.model = modelName;
|
|
7658
|
-
return base;
|
|
7659
|
-
}
|
|
7660
|
-
if (plugins?.enabled !== void 0 && plugins.enabled.length > 0) {
|
|
7661
|
-
return {
|
|
7662
|
-
capability: route.capability,
|
|
7663
|
-
provider: route.provider,
|
|
7664
|
-
reason: "first-available-plugin-provider"
|
|
7665
|
-
};
|
|
7666
|
-
}
|
|
7667
|
-
return {
|
|
7668
|
-
capability: route.capability,
|
|
7669
|
-
provider: route.provider,
|
|
7670
|
-
reason: "explicit-route"
|
|
7671
|
-
};
|
|
7672
|
-
}
|
|
7673
|
-
function extractModelName(prefix, route) {
|
|
7674
|
-
if (route.model !== void 0) return route.model;
|
|
7675
|
-
return prefix === route.provider ? defaultModelForProvider(prefix) : void 0;
|
|
7676
|
-
}
|
|
7677
|
-
function defaultModelForProvider(provider) {
|
|
7678
|
-
if (provider === "anthropic") return "claude-3-7-sonnet";
|
|
7679
|
-
return void 0;
|
|
7680
|
-
}
|
|
7681
|
-
|
|
7682
7682
|
// src/internal/runtime/skills/skills-manager.ts
|
|
7683
7683
|
init_errors();
|
|
7684
7684
|
|
|
@@ -8025,7 +8025,7 @@ var IterationBudget = class {
|
|
|
8025
8025
|
}
|
|
8026
8026
|
};
|
|
8027
8027
|
|
|
8028
|
-
// src/internal/runtime/validate-response.ts
|
|
8028
|
+
// src/internal/runtime/validation/validate-response.ts
|
|
8029
8029
|
function validateResponse(response) {
|
|
8030
8030
|
const trimmed = response.content.trim();
|
|
8031
8031
|
const toolCallsArr = Array.isArray(response.toolCalls) ? response.toolCalls : [];
|
|
@@ -8484,7 +8484,7 @@ function coerceArgsToSchema(args, schema) {
|
|
|
8484
8484
|
return { value: out, changed };
|
|
8485
8485
|
}
|
|
8486
8486
|
|
|
8487
|
-
// src/internal/runtime/shell-tool.ts
|
|
8487
|
+
// src/internal/runtime/tools/shell-tool.ts
|
|
8488
8488
|
async function runShell(options) {
|
|
8489
8489
|
if (options.sandbox === true && isObviouslyUnsafe(options.command)) {
|
|
8490
8490
|
return {
|
|
@@ -9685,10 +9685,10 @@ function registerBuiltins() {
|
|
|
9685
9685
|
registerCatalogProviders();
|
|
9686
9686
|
}
|
|
9687
9687
|
|
|
9688
|
-
// src/internal/
|
|
9688
|
+
// src/internal/error-mappers/anthropic.ts
|
|
9689
9689
|
init_errors();
|
|
9690
9690
|
|
|
9691
|
-
// src/internal/
|
|
9691
|
+
// src/internal/error-mappers/shared.ts
|
|
9692
9692
|
var RAW_MAX_BYTES = 2048;
|
|
9693
9693
|
function parseRetryAfter(headers) {
|
|
9694
9694
|
if (headers === void 0) return void 0;
|
|
@@ -9717,7 +9717,7 @@ function buildErrorMetadata(args) {
|
|
|
9717
9717
|
};
|
|
9718
9718
|
}
|
|
9719
9719
|
|
|
9720
|
-
// src/internal/
|
|
9720
|
+
// src/internal/error-mappers/anthropic.ts
|
|
9721
9721
|
function mapAnthropicError(args) {
|
|
9722
9722
|
const { status, body, headers, endpoint } = args;
|
|
9723
9723
|
const code = mapAnthropicStatusToCode(status, body);
|
|
@@ -10057,7 +10057,7 @@ function buildAnthropicBody(request) {
|
|
|
10057
10057
|
// src/internal/llm/bedrock-anthropic.ts
|
|
10058
10058
|
init_errors();
|
|
10059
10059
|
|
|
10060
|
-
// src/internal/
|
|
10060
|
+
// src/internal/error-mappers/bedrock.ts
|
|
10061
10061
|
init_errors();
|
|
10062
10062
|
function classifyBedrockError(args, awsType, message) {
|
|
10063
10063
|
if (args.status === 429 || awsType.includes("Throttling") || awsType.includes("TooManyRequests")) {
|
|
@@ -10194,7 +10194,7 @@ function buildBedrockBody(request) {
|
|
|
10194
10194
|
init_credential_pool();
|
|
10195
10195
|
init_credential_pool_context();
|
|
10196
10196
|
|
|
10197
|
-
// src/internal/
|
|
10197
|
+
// src/internal/error-mappers/openai-compatible.ts
|
|
10198
10198
|
init_errors();
|
|
10199
10199
|
function mapOpenAICompatibleError(args) {
|
|
10200
10200
|
const { providerId, status, body, headers, endpoint } = args;
|
|
@@ -10358,7 +10358,7 @@ function readOpenAiContent(body) {
|
|
|
10358
10358
|
return void 0;
|
|
10359
10359
|
}
|
|
10360
10360
|
|
|
10361
|
-
// src/internal/
|
|
10361
|
+
// src/internal/error-mappers/ollama.ts
|
|
10362
10362
|
init_errors();
|
|
10363
10363
|
function mapOllamaTransportError(args) {
|
|
10364
10364
|
if (args.providerId !== "ollama") return void 0;
|
|
@@ -11008,7 +11008,7 @@ function abortError2(signal) {
|
|
|
11008
11008
|
// src/internal/llm/vertex-anthropic.ts
|
|
11009
11009
|
init_errors();
|
|
11010
11010
|
|
|
11011
|
-
// src/internal/
|
|
11011
|
+
// src/internal/error-mappers/vertex.ts
|
|
11012
11012
|
init_errors();
|
|
11013
11013
|
var VERTEX_RULES = [
|
|
11014
11014
|
{ test: (s, e) => s === 429 || e === "RESOURCE_EXHAUSTED", code: "rate_limit" },
|
|
@@ -14258,8 +14258,8 @@ function localAgentRunUntil(agent, goal, options) {
|
|
|
14258
14258
|
async function* wrap() {
|
|
14259
14259
|
const { runUntilImpl: runUntilImpl2 } = await Promise.resolve().then(() => (init_run_until(), run_until_exports));
|
|
14260
14260
|
const { judgeCallImpl: judgeCallImpl2 } = await Promise.resolve().then(() => (init_judge_call(), judge_call_exports));
|
|
14261
|
-
const {
|
|
14262
|
-
const create =
|
|
14261
|
+
const { getAgentFacade: getAgentFacade2 } = await Promise.resolve().then(() => (init_agent_factory_registry(), agent_factory_registry_exports));
|
|
14262
|
+
const create = getAgentFacade2().create;
|
|
14263
14263
|
const deps = {
|
|
14264
14264
|
judge: async (ctx, opts) => judgeCallImpl2(ctx, opts, { create })
|
|
14265
14265
|
};
|
|
@@ -14269,9 +14269,9 @@ function localAgentRunUntil(agent, goal, options) {
|
|
|
14269
14269
|
}
|
|
14270
14270
|
async function localAgentFork(parent, options) {
|
|
14271
14271
|
const { forkAgentImpl: forkAgentImpl2 } = await Promise.resolve().then(() => (init_fork_agent(), fork_agent_exports));
|
|
14272
|
-
const {
|
|
14272
|
+
const { getAgentFacade: getAgentFacade2 } = await Promise.resolve().then(() => (init_agent_factory_registry(), agent_factory_registry_exports));
|
|
14273
14273
|
const { withPersonalityContext: withPersonalityContext2 } = await Promise.resolve().then(() => (init_context(), context_exports));
|
|
14274
|
-
const create =
|
|
14274
|
+
const create = getAgentFacade2().create;
|
|
14275
14275
|
return withPersonalityContext2(
|
|
14276
14276
|
{ slug: parent.personalitySlugSnapshot, isFork: true },
|
|
14277
14277
|
() => forkAgentImpl2(parent, options, { create })
|
|
@@ -14292,7 +14292,7 @@ async function persistMemoryFactIfWritePrompt(workspaceCwd, memoryConfig, userTe
|
|
|
14292
14292
|
// src/internal/runtime/local-agent/local-agent-send.ts
|
|
14293
14293
|
init_errors();
|
|
14294
14294
|
|
|
14295
|
-
// src/internal/runtime/abort-utils.ts
|
|
14295
|
+
// src/internal/runtime/concurrency/abort-utils.ts
|
|
14296
14296
|
function anySignal(signals) {
|
|
14297
14297
|
const filtered = signals.filter((s) => s !== void 0);
|
|
14298
14298
|
if (filtered.length === 0) {
|
|
@@ -15321,7 +15321,16 @@ async function getOrCreateUncached(agentId, options) {
|
|
|
15321
15321
|
throw err;
|
|
15322
15322
|
}
|
|
15323
15323
|
}
|
|
15324
|
-
|
|
15324
|
+
setAgentFacade({
|
|
15325
|
+
create: (options) => Agent.create(options),
|
|
15326
|
+
prompt: (message, options) => Agent.prompt(message, options),
|
|
15327
|
+
get: (agentId) => Agent.get(agentId),
|
|
15328
|
+
resume: (agentId, options) => Agent.resume(agentId, options),
|
|
15329
|
+
batch: (prompts, options) => Agent.batch(prompts, options)
|
|
15330
|
+
});
|
|
15331
|
+
|
|
15332
|
+
// src/internal/eval/runner.ts
|
|
15333
|
+
init_agent_factory_registry();
|
|
15325
15334
|
|
|
15326
15335
|
// src/internal/eval/aggregate.ts
|
|
15327
15336
|
function percentile(sorted, p) {
|
|
@@ -15624,7 +15633,7 @@ async function runRowsViaBatch(entries, agentOptions, scorers, concurrency, sign
|
|
|
15624
15633
|
concurrency,
|
|
15625
15634
|
...signal !== void 0 ? { signal } : {}
|
|
15626
15635
|
};
|
|
15627
|
-
const batchResults = await
|
|
15636
|
+
const batchResults = await getAgentFacade().batch(prompts, batchOpts);
|
|
15628
15637
|
const rows = [];
|
|
15629
15638
|
for (let i = 0; i < batchResults.length; i += 1) {
|
|
15630
15639
|
const entry = entries[i];
|
|
@@ -15697,6 +15706,7 @@ async function runEval(options, runOpts) {
|
|
|
15697
15706
|
}
|
|
15698
15707
|
|
|
15699
15708
|
// src/internal/scorers/llm-judge.ts
|
|
15709
|
+
init_agent_factory_registry();
|
|
15700
15710
|
function buildPrompt(subject, criteria, rubric, expected) {
|
|
15701
15711
|
const scoreHint = rubric === "discrete" ? "between 0 and 1 (use 0 for fail, 1 for pass)" : "between 0.0 and 1.0";
|
|
15702
15712
|
const expectedBlock = expected !== void 0 ? `EXPECTED (reference): ${JSON.stringify(expected)}
|
|
@@ -15721,7 +15731,7 @@ function buildPrompt(subject, criteria, rubric, expected) {
|
|
|
15721
15731
|
var SCORE_REGEX = /\{\s*"score"\s*:\s*([0-9]*\.?[0-9]+)\s*,\s*"reason"\s*:\s*"([^"]*)"\s*\}/;
|
|
15722
15732
|
async function callJudge(message, options) {
|
|
15723
15733
|
try {
|
|
15724
|
-
const result = await
|
|
15734
|
+
const result = await getAgentFacade().prompt(message, {
|
|
15725
15735
|
apiKey: options.apiKey,
|
|
15726
15736
|
model: options.model,
|
|
15727
15737
|
local: { cwd: process.cwd(), sandboxOptions: { enabled: false } },
|