@theokit/sdk 2.8.0 → 2.10.0
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 +17 -0
- package/dist/a2a/index.cjs +36 -12
- package/dist/a2a/index.cjs.map +1 -1
- package/dist/a2a/index.js +36 -12
- package/dist/a2a/index.js.map +1 -1
- package/dist/compaction.cjs +1 -1
- package/dist/compaction.cjs.map +1 -1
- package/dist/compaction.d.cts +6 -0
- package/dist/compaction.d.ts +6 -0
- package/dist/compaction.js +1 -1
- package/dist/compaction.js.map +1 -1
- package/dist/{cron-CRPY-aKq.d.cts → cron-BNI8pyn_.d.cts} +128 -3
- package/dist/{cron-Bhp8rP8i.d.ts → cron-CZlMLA1K.d.ts} +128 -3
- package/dist/cron.cjs +26 -12
- 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 +26 -12
- package/dist/cron.js.map +1 -1
- package/dist/eval.cjs +139 -13
- package/dist/eval.cjs.map +1 -1
- package/dist/eval.js +141 -15
- package/dist/eval.js.map +1 -1
- package/dist/index.cjs +26 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -120
- package/dist/index.d.ts +6 -120
- package/dist/index.js +26 -12
- package/dist/index.js.map +1 -1
- package/dist/internal/plugins/enabled-names.d.cts +1 -0
- package/dist/internal/plugins/enabled-names.d.ts +1 -0
- package/dist/sandbox/index.cjs +3 -1
- package/dist/sandbox/index.cjs.map +1 -1
- package/dist/sandbox/index.js +3 -1
- package/dist/sandbox/index.js.map +1 -1
- package/dist/sandbox/provision.d.cts +7 -0
- package/dist/sandbox/provision.d.ts +7 -0
- package/dist/types/agent.d.ts +14 -2
- package/dist/types/eval.d.ts +6 -2
- package/package.json +1 -1
package/dist/eval.cjs
CHANGED
|
@@ -3291,6 +3291,18 @@ async function writeVersionedJson(path, data2, currentVersion) {
|
|
|
3291
3291
|
await atomicWriteJson(path, file);
|
|
3292
3292
|
}
|
|
3293
3293
|
|
|
3294
|
+
// src/internal/plugins/enabled-names.ts
|
|
3295
|
+
function isPluginArray(plugins) {
|
|
3296
|
+
return Array.isArray(plugins);
|
|
3297
|
+
}
|
|
3298
|
+
function asPluginsSettings(plugins) {
|
|
3299
|
+
if (plugins === void 0) return void 0;
|
|
3300
|
+
return isPluginArray(plugins) ? void 0 : plugins;
|
|
3301
|
+
}
|
|
3302
|
+
function enabledPluginNames(plugins) {
|
|
3303
|
+
return asPluginsSettings(plugins)?.enabled ?? [];
|
|
3304
|
+
}
|
|
3305
|
+
|
|
3294
3306
|
// src/internal/runtime/registry/agent-registry-store.ts
|
|
3295
3307
|
var SCHEMA_VERSION = 1;
|
|
3296
3308
|
var LEGACY_SCHEMA_VERSION_STRING = "1.0";
|
|
@@ -3304,7 +3316,9 @@ function stripSecretsFromOptions(options) {
|
|
|
3304
3316
|
cloud: serializeCloud(options.cloud),
|
|
3305
3317
|
memory: serializeMemory(options.memory),
|
|
3306
3318
|
skills: serializeEnabledList(options.skills),
|
|
3307
|
-
|
|
3319
|
+
// Code-`Plugin` objects are closures and cannot be persisted (like custom
|
|
3320
|
+
// tools); only the named-enable settings form is serialized.
|
|
3321
|
+
plugins: serializeEnabledList(asPluginsSettings(options.plugins)),
|
|
3308
3322
|
context: serializeContext(options.context),
|
|
3309
3323
|
providers: serializeProviders(options.providers),
|
|
3310
3324
|
agents: serializeAgents(options.agents)
|
|
@@ -3612,8 +3626,9 @@ function serializeSkills(skills) {
|
|
|
3612
3626
|
return { enabled: [...skills.enabled] };
|
|
3613
3627
|
}
|
|
3614
3628
|
function serializePlugins(plugins) {
|
|
3615
|
-
|
|
3616
|
-
|
|
3629
|
+
const enabled = enabledPluginNames(plugins);
|
|
3630
|
+
if (enabled.length === 0) return void 0;
|
|
3631
|
+
return { enabled: [...enabled] };
|
|
3617
3632
|
}
|
|
3618
3633
|
function serializeMcp(mcpServers) {
|
|
3619
3634
|
if (mcpServers === void 0) return void 0;
|
|
@@ -3796,11 +3811,8 @@ function defaultLocalTools(request) {
|
|
|
3796
3811
|
tools.push(`mcp_${sanitizeMcpName(name)}_call`);
|
|
3797
3812
|
}
|
|
3798
3813
|
}
|
|
3799
|
-
const
|
|
3800
|
-
|
|
3801
|
-
for (const _pluginName of plugins.enabled) {
|
|
3802
|
-
tools.push("mcp_search_provider_web_search");
|
|
3803
|
-
}
|
|
3814
|
+
for (const _pluginName of enabledPluginNames(request.agentOptions.plugins)) {
|
|
3815
|
+
tools.push("mcp_search_provider_web_search");
|
|
3804
3816
|
}
|
|
3805
3817
|
return tools;
|
|
3806
3818
|
}
|
|
@@ -7043,7 +7055,7 @@ function resolveRoute(route, modelProvider, plugins) {
|
|
|
7043
7055
|
if (modelName !== void 0) base.model = modelName;
|
|
7044
7056
|
return base;
|
|
7045
7057
|
}
|
|
7046
|
-
if (plugins
|
|
7058
|
+
if (enabledPluginNames(plugins).length > 0) {
|
|
7047
7059
|
return {
|
|
7048
7060
|
capability: route.capability,
|
|
7049
7061
|
provider: route.provider,
|
|
@@ -8046,7 +8058,7 @@ function bootstrapSubmanagers(args) {
|
|
|
8046
8058
|
args.settingSourcesIncludeProject
|
|
8047
8059
|
);
|
|
8048
8060
|
}
|
|
8049
|
-
const providerCount = (args.options.providers?.routes?.length ?? 0) + (args.options.plugins
|
|
8061
|
+
const providerCount = (args.options.providers?.routes?.length ?? 0) + enabledPluginNames(args.options.plugins).length;
|
|
8050
8062
|
if (providerCount > 0 || args.options.providers !== void 0) {
|
|
8051
8063
|
out.providers = new ProvidersManagerImpl(
|
|
8052
8064
|
args.options.model,
|
|
@@ -8066,7 +8078,9 @@ function bootstrapSubmanagers(args) {
|
|
|
8066
8078
|
if (args.options.plugins !== void 0 || args.settingSourcesIncludePlugins) {
|
|
8067
8079
|
out.pluginsManager = new PluginsManager(
|
|
8068
8080
|
args.workspaceCwd,
|
|
8069
|
-
|
|
8081
|
+
// The array (code-`Plugin`) form has no named-enable list; `undefined`
|
|
8082
|
+
// here preserves "no filter / load all file-discovered plugins".
|
|
8083
|
+
asPluginsSettings(args.options.plugins)?.enabled,
|
|
8070
8084
|
args.settingSourcesIncludePlugins,
|
|
8071
8085
|
false,
|
|
8072
8086
|
void 0
|
|
@@ -15358,7 +15372,7 @@ var Agent = class _Agent {
|
|
|
15358
15372
|
const runtime = options.cloud !== void 0 ? "cloud" : "local";
|
|
15359
15373
|
const span = telemetry.startSpan(SPAN_NAMES.AGENT_CREATE, {
|
|
15360
15374
|
runtime,
|
|
15361
|
-
pluginCount: options.plugins
|
|
15375
|
+
pluginCount: enabledPluginNames(options.plugins).length
|
|
15362
15376
|
});
|
|
15363
15377
|
try {
|
|
15364
15378
|
const agent = await runCreateUnderSpan(options, span);
|
|
@@ -16193,6 +16207,118 @@ async function llmJudgeScore(options) {
|
|
|
16193
16207
|
return parseScore(judgement.text, rubric);
|
|
16194
16208
|
}
|
|
16195
16209
|
|
|
16210
|
+
// src/sandbox/types.ts
|
|
16211
|
+
var SandboxSecurityError = class extends Error {
|
|
16212
|
+
code = "sandbox_security";
|
|
16213
|
+
constructor(message) {
|
|
16214
|
+
super(message);
|
|
16215
|
+
this.name = "SandboxSecurityError";
|
|
16216
|
+
}
|
|
16217
|
+
};
|
|
16218
|
+
var SHELL_METACHARACTERS = /[;&|`$(){}]/;
|
|
16219
|
+
var SandboxBackend = class {
|
|
16220
|
+
config;
|
|
16221
|
+
constructor(config = {}) {
|
|
16222
|
+
this.config = {
|
|
16223
|
+
workDir: config.workDir ?? "/tmp",
|
|
16224
|
+
timeoutMs: config.timeoutMs ?? 3e4,
|
|
16225
|
+
maxOutputBytes: config.maxOutputBytes ?? 5 * 1024 * 1024
|
|
16226
|
+
};
|
|
16227
|
+
}
|
|
16228
|
+
async readFile(path) {
|
|
16229
|
+
const result = await this.execute(`cat ${this.shellEscape(path)}`);
|
|
16230
|
+
if (result.exitCode !== 0) {
|
|
16231
|
+
throw new Error(`readFile failed: ${result.stderr}`);
|
|
16232
|
+
}
|
|
16233
|
+
return result.stdout;
|
|
16234
|
+
}
|
|
16235
|
+
async writeFile(path, content) {
|
|
16236
|
+
await this.uploadFile(path, content);
|
|
16237
|
+
}
|
|
16238
|
+
async glob(pattern, cwd) {
|
|
16239
|
+
const dir = cwd ?? this.config.workDir ?? ".";
|
|
16240
|
+
const result = await this.execute(
|
|
16241
|
+
`find ${this.shellEscape(dir)} -name ${this.shellEscape(pattern)} -type f 2>/dev/null`
|
|
16242
|
+
);
|
|
16243
|
+
if (result.exitCode !== 0) return [];
|
|
16244
|
+
return result.stdout.trim().split("\n").filter(Boolean);
|
|
16245
|
+
}
|
|
16246
|
+
async grep(pattern, path) {
|
|
16247
|
+
const target = path ?? ".";
|
|
16248
|
+
const result = await this.execute(
|
|
16249
|
+
`grep -rn ${this.shellEscape(pattern)} ${this.shellEscape(target)} 2>/dev/null`
|
|
16250
|
+
);
|
|
16251
|
+
if (result.exitCode !== 0) return [];
|
|
16252
|
+
return result.stdout.trim().split("\n").filter(Boolean);
|
|
16253
|
+
}
|
|
16254
|
+
async listDir(path) {
|
|
16255
|
+
const result = await this.execute(`ls -1 ${this.shellEscape(path)}`);
|
|
16256
|
+
if (result.exitCode !== 0) return [];
|
|
16257
|
+
return result.stdout.trim().split("\n").filter(Boolean);
|
|
16258
|
+
}
|
|
16259
|
+
validateCommand(command) {
|
|
16260
|
+
if (SHELL_METACHARACTERS.test(command)) {
|
|
16261
|
+
throw new SandboxSecurityError(
|
|
16262
|
+
`Command contains shell metacharacters: ${command.slice(0, 80)}`
|
|
16263
|
+
);
|
|
16264
|
+
}
|
|
16265
|
+
}
|
|
16266
|
+
truncateOutput(output) {
|
|
16267
|
+
const max = this.config.maxOutputBytes ?? 5 * 1024 * 1024;
|
|
16268
|
+
if (Buffer.byteLength(output) > max) {
|
|
16269
|
+
return `${output.slice(0, max)}
|
|
16270
|
+
...(truncated)`;
|
|
16271
|
+
}
|
|
16272
|
+
return output;
|
|
16273
|
+
}
|
|
16274
|
+
shellEscape(arg) {
|
|
16275
|
+
return shellEscapePosix(arg);
|
|
16276
|
+
}
|
|
16277
|
+
};
|
|
16278
|
+
|
|
16279
|
+
// src/sandbox/local-sandbox.ts
|
|
16280
|
+
var LocalSandbox = class extends SandboxBackend {
|
|
16281
|
+
constructor(config = {}) {
|
|
16282
|
+
super(config);
|
|
16283
|
+
}
|
|
16284
|
+
async execute(command, opts) {
|
|
16285
|
+
const timeout = opts?.timeoutMs ?? this.config.timeoutMs ?? 3e4;
|
|
16286
|
+
const max = this.config.maxOutputBytes ?? 5 * 1024 * 1024;
|
|
16287
|
+
return new Promise((resolve3) => {
|
|
16288
|
+
const child = child_process.execFile(
|
|
16289
|
+
"/bin/sh",
|
|
16290
|
+
["-c", command],
|
|
16291
|
+
{
|
|
16292
|
+
cwd: this.config.workDir,
|
|
16293
|
+
timeout,
|
|
16294
|
+
maxBuffer: max,
|
|
16295
|
+
encoding: "utf-8"
|
|
16296
|
+
},
|
|
16297
|
+
(error, stdout, stderr) => {
|
|
16298
|
+
resolve3(this.buildResult(error, stdout ?? "", stderr ?? ""));
|
|
16299
|
+
}
|
|
16300
|
+
);
|
|
16301
|
+
child.on("error", () => {
|
|
16302
|
+
resolve3({ stdout: "", stderr: "spawn error", exitCode: 1, timedOut: false });
|
|
16303
|
+
});
|
|
16304
|
+
});
|
|
16305
|
+
}
|
|
16306
|
+
buildResult(error, stdout, stderr) {
|
|
16307
|
+
const timedOut = error !== null && "killed" in error && error.killed;
|
|
16308
|
+
return {
|
|
16309
|
+
stdout: this.truncateOutput(stdout),
|
|
16310
|
+
stderr: this.truncateOutput(stderr),
|
|
16311
|
+
exitCode: timedOut ? 124 : error ? 1 : 0,
|
|
16312
|
+
timedOut
|
|
16313
|
+
};
|
|
16314
|
+
}
|
|
16315
|
+
async uploadFile(path$1, content) {
|
|
16316
|
+
const fullPath = path$1.startsWith("/") ? path$1 : `${this.config.workDir}/${path$1}`;
|
|
16317
|
+
await promises.mkdir(path.dirname(fullPath), { recursive: true });
|
|
16318
|
+
await promises.writeFile(fullPath, content, "utf-8");
|
|
16319
|
+
}
|
|
16320
|
+
};
|
|
16321
|
+
|
|
16196
16322
|
// src/scorers.ts
|
|
16197
16323
|
var JSON_SHAPE_MAX_BYTES = 1e6;
|
|
16198
16324
|
function makeStringScorer(name, caseSensitive, compare) {
|
|
@@ -16296,7 +16422,7 @@ var Scorers = {
|
|
|
16296
16422
|
* that rejects shell metacharacters in `execute` is unsupported for this scorer.
|
|
16297
16423
|
*/
|
|
16298
16424
|
verifyGate(opts) {
|
|
16299
|
-
const { sandbox, repoDir, failToPass, passToPass, command } = opts;
|
|
16425
|
+
const { sandbox = new LocalSandbox(), repoDir, failToPass, passToPass, command } = opts;
|
|
16300
16426
|
return {
|
|
16301
16427
|
name: "verify-gate",
|
|
16302
16428
|
score: async () => {
|