flavor-code 1.2.17 → 1.2.20
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/README.md +2 -2
- package/README.zh-CN.md +2 -2
- package/dist/{app-F4P7RV2X.js → app-5D5RSGQX.js} +47 -20
- package/dist/{chunk-YRIPE5K5.js → chunk-A7PMQ22O.js} +1 -1
- package/dist/{chunk-QQCXJC4U.js → chunk-AXLUVJKC.js} +784 -405
- package/dist/cli.js +3 -3
- package/dist/desktop/main.js +1063 -685
- package/dist/desktop/plugin-worker-entry.js +230 -0
- package/dist/evolve/loader.d.ts +1 -1
- package/dist/plugin-worker-entry.js +233 -0
- package/dist/plugins/host.d.ts +2 -3
- package/dist/plugins/sandbox-protocol.d.ts +72 -0
- package/dist/plugins/types.d.ts +3 -0
- package/dist/plugins/worker-host.d.ts +19 -0
- package/dist/production.d.ts +8 -0
- package/dist/sdk/index.js +2 -2
- package/dist/skills/arguments.d.ts +8 -0
- package/dist/skills/tool.d.ts +5 -0
- package/dist/ui/session.d.ts +1 -0
- package/dist/utils/async.d.ts +14 -0
- package/package.json +5 -4
package/dist/desktop/main.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// src/desktop/main.ts
|
|
2
2
|
import { appendFileSync } from "fs";
|
|
3
3
|
import { readFile as readFile34, stat as stat15, writeFile as writeFile18 } from "fs/promises";
|
|
4
|
-
import { dirname as
|
|
4
|
+
import { dirname as dirname24, join as join41 } from "path";
|
|
5
5
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
6
6
|
import { app, BrowserWindow as BrowserWindow2, dialog, ipcMain, Menu, nativeImage, shell } from "electron";
|
|
7
7
|
|
|
@@ -2612,11 +2612,11 @@ function hexToLab(hex) {
|
|
|
2612
2612
|
const b = linearize(channels[2]);
|
|
2613
2613
|
const x = (0.4124564 * r + 0.3575761 * g + 0.1804375 * b) / 0.95047;
|
|
2614
2614
|
const y = 0.2126729 * r + 0.7151522 * g + 0.072175 * b;
|
|
2615
|
-
const
|
|
2615
|
+
const z44 = (0.0193339 * r + 0.119192 * g + 0.9503041 * b) / 1.08883;
|
|
2616
2616
|
const f = (t) => t > 8856e-6 ? Math.cbrt(t) : 7.787 * t + 16 / 116;
|
|
2617
2617
|
const fx = f(x);
|
|
2618
2618
|
const fy = f(y);
|
|
2619
|
-
const fz = f(
|
|
2619
|
+
const fz = f(z44);
|
|
2620
2620
|
return [116 * fy - 16, 500 * (fx - fy), 200 * (fy - fz)];
|
|
2621
2621
|
}
|
|
2622
2622
|
function deltaE76(left, right) {
|
|
@@ -4348,6 +4348,33 @@ function hasCycle(nodes) {
|
|
|
4348
4348
|
}
|
|
4349
4349
|
|
|
4350
4350
|
// src/utils/async.ts
|
|
4351
|
+
function withTimeout(promise, ms) {
|
|
4352
|
+
return new Promise((resolve34, reject) => {
|
|
4353
|
+
let settled = false;
|
|
4354
|
+
const timer = setTimeout(() => {
|
|
4355
|
+
if (settled) return;
|
|
4356
|
+
settled = true;
|
|
4357
|
+
resolve34({ timedOut: true, value: void 0 });
|
|
4358
|
+
}, ms);
|
|
4359
|
+
timer.unref?.();
|
|
4360
|
+
promise.then(
|
|
4361
|
+
(value) => {
|
|
4362
|
+
if (!settled) {
|
|
4363
|
+
settled = true;
|
|
4364
|
+
clearTimeout(timer);
|
|
4365
|
+
resolve34({ timedOut: false, value });
|
|
4366
|
+
}
|
|
4367
|
+
},
|
|
4368
|
+
(error) => {
|
|
4369
|
+
if (!settled) {
|
|
4370
|
+
settled = true;
|
|
4371
|
+
clearTimeout(timer);
|
|
4372
|
+
reject(error);
|
|
4373
|
+
}
|
|
4374
|
+
}
|
|
4375
|
+
);
|
|
4376
|
+
});
|
|
4377
|
+
}
|
|
4351
4378
|
function awaitWithSignal3(promise, signal) {
|
|
4352
4379
|
signal.throwIfAborted();
|
|
4353
4380
|
return new Promise((resolve34, reject) => {
|
|
@@ -8076,7 +8103,7 @@ function createIncidentReporter(options) {
|
|
|
8076
8103
|
import { spawn as spawn2 } from "child_process";
|
|
8077
8104
|
import { writeFile as writeFile7 } from "fs/promises";
|
|
8078
8105
|
import { join as join10 } from "path";
|
|
8079
|
-
import { z as
|
|
8106
|
+
import { z as z18 } from "zod";
|
|
8080
8107
|
|
|
8081
8108
|
// src/evolve/loader.ts
|
|
8082
8109
|
import { cp as cp2, mkdir as mkdir7, mkdtemp, readdir as readdir3, rm as rm4, stat as stat5, writeFile as writeFile5 } from "fs/promises";
|
|
@@ -8085,9 +8112,10 @@ import { join as join8, resolve as resolve9 } from "path";
|
|
|
8085
8112
|
|
|
8086
8113
|
// src/plugins/host.ts
|
|
8087
8114
|
import { lstatSync, realpathSync as realpathSync2 } from "fs";
|
|
8088
|
-
import { lstat as lstat3, open as open4, readdir as readdir2, realpath as
|
|
8115
|
+
import { lstat as lstat3, open as open4, readdir as readdir2, realpath as realpath6, stat as stat4, writeFile as writeFile4 } from "fs/promises";
|
|
8089
8116
|
import { isAbsolute as isAbsolute6, relative as relative6, resolve as resolve8, sep as sep6 } from "path";
|
|
8090
8117
|
import { pathToFileURL as pathToFileURL2 } from "url";
|
|
8118
|
+
import { z as z17 } from "zod";
|
|
8091
8119
|
|
|
8092
8120
|
// src/plugins/types.ts
|
|
8093
8121
|
import { z as z16 } from "zod";
|
|
@@ -8117,10 +8145,188 @@ var PluginManifestSchema = z16.object({
|
|
|
8117
8145
|
}).strict()
|
|
8118
8146
|
}).strict();
|
|
8119
8147
|
|
|
8148
|
+
// src/plugins/worker-host.ts
|
|
8149
|
+
import { realpath as realpath5 } from "fs/promises";
|
|
8150
|
+
import { dirname as dirname7 } from "path";
|
|
8151
|
+
import { Worker as Worker2 } from "worker_threads";
|
|
8152
|
+
var DEFAULT_ACTIVATION_TIMEOUT_MS = 1e4;
|
|
8153
|
+
var DEFAULT_INVOCATION_TIMEOUT_MS = 3e4;
|
|
8154
|
+
var DEFAULT_MAX_OLD_SPACE_MB = 128;
|
|
8155
|
+
var DEFAULT_SHUTDOWN_TIMEOUT_MS = 5e3;
|
|
8156
|
+
async function startPluginSandbox(options) {
|
|
8157
|
+
const entryPath = await realpath5(options.entryPath);
|
|
8158
|
+
const pluginRoot = await realpath5(options.pluginRoot ?? dirname7(entryPath));
|
|
8159
|
+
const activationTimeoutMs = options.activationTimeoutMs ?? DEFAULT_ACTIVATION_TIMEOUT_MS;
|
|
8160
|
+
const invocationTimeoutMs = options.invocationTimeoutMs ?? DEFAULT_INVOCATION_TIMEOUT_MS;
|
|
8161
|
+
let configJson;
|
|
8162
|
+
try {
|
|
8163
|
+
configJson = JSON.stringify(options.config ?? {});
|
|
8164
|
+
} catch (error) {
|
|
8165
|
+
throw new Error(`Plugin sandbox config is not serializable: ${String(error)}`);
|
|
8166
|
+
}
|
|
8167
|
+
const workerEntry = new URL(import.meta.url.endsWith(".ts") ? "./plugin-worker-entry.ts" : "./plugin-worker-entry.js", import.meta.url);
|
|
8168
|
+
const worker = new Worker2(workerEntry, {
|
|
8169
|
+
workerData: { entryPath, pluginRoot, pluginName: options.pluginName, pluginVersion: options.pluginVersion, configJson },
|
|
8170
|
+
execArgv: ["--experimental-vm-modules", "--no-warnings"],
|
|
8171
|
+
resourceLimits: {
|
|
8172
|
+
maxOldGenerationSizeMb: options.maxOldSpaceMb ?? DEFAULT_MAX_OLD_SPACE_MB,
|
|
8173
|
+
maxYoungGenerationSizeMb: 16,
|
|
8174
|
+
codeRangeSizeMb: 16,
|
|
8175
|
+
stackSizeMb: 4
|
|
8176
|
+
}
|
|
8177
|
+
});
|
|
8178
|
+
let closed = false;
|
|
8179
|
+
let nextId = 1;
|
|
8180
|
+
const pending2 = /* @__PURE__ */ new Map();
|
|
8181
|
+
let disposeResolve;
|
|
8182
|
+
let disposeReject;
|
|
8183
|
+
let failWorker;
|
|
8184
|
+
const ready = await new Promise((resolveReady, rejectReady) => {
|
|
8185
|
+
let settled = false;
|
|
8186
|
+
const timer = setTimeout(() => {
|
|
8187
|
+
settled = true;
|
|
8188
|
+
closed = true;
|
|
8189
|
+
void worker.terminate();
|
|
8190
|
+
rejectReady(new Error(`Plugin activation sandbox timed out after ${activationTimeoutMs}ms`));
|
|
8191
|
+
}, activationTimeoutMs);
|
|
8192
|
+
const fail = (error) => {
|
|
8193
|
+
if (closed && settled) return;
|
|
8194
|
+
closed = true;
|
|
8195
|
+
clearTimeout(timer);
|
|
8196
|
+
for (const request of pending2.values()) {
|
|
8197
|
+
clearTimeout(request.timer);
|
|
8198
|
+
request.reject(error);
|
|
8199
|
+
}
|
|
8200
|
+
pending2.clear();
|
|
8201
|
+
disposeReject?.(error);
|
|
8202
|
+
if (!settled) {
|
|
8203
|
+
settled = true;
|
|
8204
|
+
rejectReady(error);
|
|
8205
|
+
}
|
|
8206
|
+
void worker.terminate();
|
|
8207
|
+
};
|
|
8208
|
+
failWorker = fail;
|
|
8209
|
+
worker.on("message", (raw) => {
|
|
8210
|
+
if (!isWorkerMessage(raw)) {
|
|
8211
|
+
fail(new Error("Plugin sandbox sent an invalid protocol message"));
|
|
8212
|
+
return;
|
|
8213
|
+
}
|
|
8214
|
+
const message2 = raw;
|
|
8215
|
+
if (message2.type === "fatal") {
|
|
8216
|
+
fail(new Error(message2.error));
|
|
8217
|
+
return;
|
|
8218
|
+
}
|
|
8219
|
+
if (message2.type === "ready") {
|
|
8220
|
+
if (settled || !isSandboxResult(message2.result)) {
|
|
8221
|
+
fail(new Error("Plugin sandbox sent an invalid or duplicate ready message"));
|
|
8222
|
+
return;
|
|
8223
|
+
}
|
|
8224
|
+
settled = true;
|
|
8225
|
+
clearTimeout(timer);
|
|
8226
|
+
resolveReady(message2.result);
|
|
8227
|
+
return;
|
|
8228
|
+
}
|
|
8229
|
+
if (!settled) {
|
|
8230
|
+
fail(new Error(`Plugin sandbox sent ${message2.type} before ready`));
|
|
8231
|
+
return;
|
|
8232
|
+
}
|
|
8233
|
+
if (message2.type === "response") {
|
|
8234
|
+
const request = pending2.get(message2.id);
|
|
8235
|
+
if (request === void 0) {
|
|
8236
|
+
fail(new Error("Plugin sandbox sent a response for an unknown request"));
|
|
8237
|
+
return;
|
|
8238
|
+
}
|
|
8239
|
+
pending2.delete(message2.id);
|
|
8240
|
+
clearTimeout(request.timer);
|
|
8241
|
+
if (message2.ok) {
|
|
8242
|
+
try {
|
|
8243
|
+
request.resolve(JSON.parse(message2.valueJson));
|
|
8244
|
+
} catch {
|
|
8245
|
+
fail(new Error("Plugin sandbox returned invalid JSON"));
|
|
8246
|
+
}
|
|
8247
|
+
} else request.reject(new Error(message2.error));
|
|
8248
|
+
return;
|
|
8249
|
+
}
|
|
8250
|
+
if (message2.type === "disposed") {
|
|
8251
|
+
closed = true;
|
|
8252
|
+
disposeResolve?.();
|
|
8253
|
+
void worker.terminate();
|
|
8254
|
+
}
|
|
8255
|
+
});
|
|
8256
|
+
worker.once("error", fail);
|
|
8257
|
+
worker.once("exit", (code) => {
|
|
8258
|
+
if (!closed) fail(new Error(`Plugin worker exited with code ${code}`));
|
|
8259
|
+
});
|
|
8260
|
+
});
|
|
8261
|
+
return {
|
|
8262
|
+
result: ready,
|
|
8263
|
+
invoke(kind, name, args) {
|
|
8264
|
+
if (closed) return Promise.reject(new Error("Plugin sandbox is closed"));
|
|
8265
|
+
let argsJson;
|
|
8266
|
+
try {
|
|
8267
|
+
argsJson = JSON.stringify(args);
|
|
8268
|
+
} catch (error) {
|
|
8269
|
+
return Promise.reject(new Error(`Plugin sandbox arguments are not serializable: ${String(error)}`));
|
|
8270
|
+
}
|
|
8271
|
+
const id = nextId++;
|
|
8272
|
+
return new Promise((resolveInvoke, rejectInvoke) => {
|
|
8273
|
+
const timer = setTimeout(() => {
|
|
8274
|
+
const error = new Error(`Plugin sandbox invocation timed out after ${invocationTimeoutMs}ms`);
|
|
8275
|
+
failWorker(error);
|
|
8276
|
+
}, invocationTimeoutMs);
|
|
8277
|
+
pending2.set(id, { resolve: (value) => resolveInvoke(value), reject: rejectInvoke, timer });
|
|
8278
|
+
worker.postMessage({ type: "invoke", id, kind, name, argsJson });
|
|
8279
|
+
});
|
|
8280
|
+
},
|
|
8281
|
+
dispose() {
|
|
8282
|
+
if (closed) return Promise.resolve();
|
|
8283
|
+
return new Promise((resolveDispose, rejectDispose) => {
|
|
8284
|
+
const timer = setTimeout(() => {
|
|
8285
|
+
const error = new Error(`Plugin sandbox shutdown timed out after ${DEFAULT_SHUTDOWN_TIMEOUT_MS}ms`);
|
|
8286
|
+
failWorker(error);
|
|
8287
|
+
}, DEFAULT_SHUTDOWN_TIMEOUT_MS);
|
|
8288
|
+
disposeResolve = () => {
|
|
8289
|
+
clearTimeout(timer);
|
|
8290
|
+
resolveDispose();
|
|
8291
|
+
};
|
|
8292
|
+
disposeReject = (error) => {
|
|
8293
|
+
clearTimeout(timer);
|
|
8294
|
+
rejectDispose(error);
|
|
8295
|
+
};
|
|
8296
|
+
worker.postMessage({ type: "shutdown" });
|
|
8297
|
+
});
|
|
8298
|
+
}
|
|
8299
|
+
};
|
|
8300
|
+
}
|
|
8301
|
+
function isWorkerMessage(value) {
|
|
8302
|
+
if (typeof value !== "object" || value === null || !("type" in value)) return false;
|
|
8303
|
+
const type = value.type;
|
|
8304
|
+
if (type === "disposed") return true;
|
|
8305
|
+
if (type === "fatal") return typeof value.error === "string";
|
|
8306
|
+
if (type === "ready") return "result" in value;
|
|
8307
|
+
if (type !== "response") return false;
|
|
8308
|
+
const response2 = value;
|
|
8309
|
+
return Number.isSafeInteger(response2.id) && typeof response2.ok === "boolean" && (response2.ok ? typeof response2.valueJson === "string" : typeof response2.error === "string");
|
|
8310
|
+
}
|
|
8311
|
+
function isSandboxResult(value) {
|
|
8312
|
+
if (typeof value !== "object" || value === null) return false;
|
|
8313
|
+
const result = value;
|
|
8314
|
+
if (!(result.ok === true && typeof result.name === "string" && typeof result.version === "string" && Array.isArray(result.registeredTools) && result.registeredTools.every((item) => typeof item === "string") && Array.isArray(result.registeredCommands) && result.registeredCommands.every((item) => typeof item === "string") && Array.isArray(result.registeredHooks) && result.registeredHooks.every((item) => typeof item === "string") && Array.isArray(result.registeredSkillRoots) && result.registeredSkillRoots.every((item) => typeof item === "string") && Array.isArray(result.registeredModelAdapters) && result.registeredModelAdapters.every((item) => typeof item === "string") && typeof result.contributions === "object" && result.contributions !== null)) return false;
|
|
8315
|
+
const contributions = result.contributions;
|
|
8316
|
+
const named = (item) => typeof item === "object" && item !== null && typeof item.name === "string";
|
|
8317
|
+
if (!Array.isArray(contributions.commands) || !contributions.commands.every((item) => named(item) && (item.description === void 0 || typeof item.description === "string"))) return false;
|
|
8318
|
+
if (!Array.isArray(contributions.tools) || !contributions.tools.every((item) => named(item) && typeof item.toolName === "string" && typeof item.description === "string" && (item.modelInputSchema === void 0 || typeof item.modelInputSchema === "object" && item.modelInputSchema !== null) && (item.readOnly === void 0 || typeof item.readOnly === "boolean"))) return false;
|
|
8319
|
+
if (!Array.isArray(contributions.hooks) || !contributions.hooks.every(named)) return false;
|
|
8320
|
+
if (!Array.isArray(contributions.skillRoots) || !contributions.skillRoots.every((item) => named(item) && typeof item.root === "string")) return false;
|
|
8321
|
+
if (!Array.isArray(contributions.modelAdapters) || !contributions.modelAdapters.every(named)) return false;
|
|
8322
|
+
const same = (left, right) => left.length === right.length && left.every((name, index) => name === right[index]?.name);
|
|
8323
|
+
return same(result.registeredCommands, contributions.commands) && same(result.registeredTools, contributions.tools) && same(result.registeredHooks, contributions.hooks) && same(result.registeredSkillRoots, contributions.skillRoots) && same(result.registeredModelAdapters, contributions.modelAdapters);
|
|
8324
|
+
}
|
|
8325
|
+
|
|
8120
8326
|
// src/plugins/host.ts
|
|
8121
8327
|
var MANIFEST = "flavor-plugin.json";
|
|
8122
8328
|
var MAX_MANIFEST_BYTES = 64 * 1024;
|
|
8123
|
-
var
|
|
8329
|
+
var DEFAULT_ACTIVATION_TIMEOUT_MS2 = 1e4;
|
|
8124
8330
|
var DEFAULT_UNLOAD_TIMEOUT_MS = 5e3;
|
|
8125
8331
|
var silentLogger = { debug() {
|
|
8126
8332
|
}, info() {
|
|
@@ -8137,7 +8343,7 @@ var PluginHost = class {
|
|
|
8137
8343
|
#loaded = false;
|
|
8138
8344
|
constructor(options) {
|
|
8139
8345
|
this.#options = options;
|
|
8140
|
-
this.#activationTimeoutMs = positiveTimeout(options.activationTimeoutMs,
|
|
8346
|
+
this.#activationTimeoutMs = positiveTimeout(options.activationTimeoutMs, DEFAULT_ACTIVATION_TIMEOUT_MS2, "activationTimeoutMs");
|
|
8141
8347
|
this.#unloadTimeoutMs = positiveTimeout(options.unloadTimeoutMs, DEFAULT_UNLOAD_TIMEOUT_MS, "unloadTimeoutMs");
|
|
8142
8348
|
}
|
|
8143
8349
|
get diagnostics() {
|
|
@@ -8251,7 +8457,7 @@ var PluginHost = class {
|
|
|
8251
8457
|
try {
|
|
8252
8458
|
const rootInfo = await lstat3(inputRoot);
|
|
8253
8459
|
if (!rootInfo.isDirectory() || rootInfo.isSymbolicLink()) throw new Error("Plugin root must be a static directory");
|
|
8254
|
-
const root = await
|
|
8460
|
+
const root = await realpath6(inputRoot);
|
|
8255
8461
|
const rawManifest = await readManifest2(resolve8(root, MANIFEST));
|
|
8256
8462
|
if (typeof rawManifest === "object" && rawManifest !== null && "name" in rawManifest && typeof rawManifest.name === "string") {
|
|
8257
8463
|
diagnosticLabel = rawManifest.name;
|
|
@@ -8271,18 +8477,79 @@ var PluginHost = class {
|
|
|
8271
8477
|
const claimed = [];
|
|
8272
8478
|
const state = { active: true, controller: new AbortController() };
|
|
8273
8479
|
let activation;
|
|
8480
|
+
const useSandbox = this.#options.sandbox === true;
|
|
8274
8481
|
try {
|
|
8275
8482
|
await verifyEntry(candidate.root, candidate.entry, candidate.entrySnapshot);
|
|
8276
|
-
|
|
8277
|
-
|
|
8278
|
-
|
|
8279
|
-
|
|
8280
|
-
|
|
8281
|
-
|
|
8282
|
-
|
|
8283
|
-
|
|
8284
|
-
|
|
8285
|
-
|
|
8483
|
+
if (useSandbox) {
|
|
8484
|
+
const session = await bounded(
|
|
8485
|
+
startPluginSandbox({
|
|
8486
|
+
entryPath: candidate.entrySnapshot.physicalPath,
|
|
8487
|
+
pluginRoot: candidate.root,
|
|
8488
|
+
pluginName: plugin,
|
|
8489
|
+
pluginVersion: candidate.manifest.version,
|
|
8490
|
+
config: redactConfig(this.#options.config ?? {}),
|
|
8491
|
+
activationTimeoutMs: this.#activationTimeoutMs
|
|
8492
|
+
}),
|
|
8493
|
+
this.#activationTimeoutMs + 1e3,
|
|
8494
|
+
"Plugin sandbox activation"
|
|
8495
|
+
);
|
|
8496
|
+
disposers.push(() => session.dispose());
|
|
8497
|
+
const result = session.result;
|
|
8498
|
+
if (!result.ok) throw new Error(result.error ?? `Plugin "${plugin}" sandbox execution failed`);
|
|
8499
|
+
const context = this.#context(candidate, disposers, claimed, state);
|
|
8500
|
+
for (const command of result.contributions.commands) {
|
|
8501
|
+
context.registerCommand(command.name, (args, commandContext) => session.invoke("command", command.name, [
|
|
8502
|
+
args,
|
|
8503
|
+
{ workspace: commandContext.workspace }
|
|
8504
|
+
]), command.description);
|
|
8505
|
+
}
|
|
8506
|
+
for (const contribution of result.contributions.tools) {
|
|
8507
|
+
const tool = {
|
|
8508
|
+
name: contribution.toolName,
|
|
8509
|
+
description: contribution.description,
|
|
8510
|
+
inputSchema: z17.unknown(),
|
|
8511
|
+
...contribution.modelInputSchema === void 0 ? {} : { modelInputSchema: contribution.modelInputSchema },
|
|
8512
|
+
...contribution.readOnly === void 0 ? {} : { readOnly: contribution.readOnly },
|
|
8513
|
+
paths: () => [],
|
|
8514
|
+
execute: (input, _signal, toolContext) => session.invoke("tool", contribution.name, [
|
|
8515
|
+
input,
|
|
8516
|
+
toolContext === void 0 ? void 0 : { agent: toolContext.agent, ownerId: toolContext.ownerId }
|
|
8517
|
+
])
|
|
8518
|
+
};
|
|
8519
|
+
context.registerTool(contribution.name, tool);
|
|
8520
|
+
}
|
|
8521
|
+
for (const hook of result.contributions.hooks) {
|
|
8522
|
+
context.registerHook(
|
|
8523
|
+
hook.name,
|
|
8524
|
+
(event) => session.invoke("hook", hook.name, [event]),
|
|
8525
|
+
hook.options
|
|
8526
|
+
);
|
|
8527
|
+
}
|
|
8528
|
+
for (const skill of result.contributions.skillRoots) {
|
|
8529
|
+
context.registerSkillRoot(skill.name, skill.root);
|
|
8530
|
+
}
|
|
8531
|
+
for (const adapter of result.contributions.modelAdapters) {
|
|
8532
|
+
context.registerModelAdapter(adapter.name, {
|
|
8533
|
+
async *stream(request) {
|
|
8534
|
+
const safeRequest = { ...request, signal: void 0 };
|
|
8535
|
+
const events = await session.invoke("modelAdapter", adapter.name, [safeRequest]);
|
|
8536
|
+
for (const event of events) yield event;
|
|
8537
|
+
}
|
|
8538
|
+
});
|
|
8539
|
+
}
|
|
8540
|
+
await verifyEntry(candidate.root, candidate.entry, candidate.entrySnapshot);
|
|
8541
|
+
} else {
|
|
8542
|
+
const imported = import(`${pathToFileURL2(candidate.entrySnapshot.physicalPath).href}?flavor=${encodeURIComponent(plugin)}&v=${Date.now()}`);
|
|
8543
|
+
const module = await bounded(imported, this.#activationTimeoutMs, "Plugin import");
|
|
8544
|
+
await verifyEntry(candidate.root, candidate.entry, candidate.entrySnapshot);
|
|
8545
|
+
if (typeof module.activate !== "function") throw new Error("Plugin entry must export activate(context)");
|
|
8546
|
+
const context = this.#context(candidate, disposers, claimed, state);
|
|
8547
|
+
activation = Promise.resolve().then(() => module.activate(context));
|
|
8548
|
+
const deactivate = await bounded(activation, this.#activationTimeoutMs, "Plugin activation");
|
|
8549
|
+
if (deactivate !== void 0) {
|
|
8550
|
+
if (typeof deactivate !== "function") throw new Error("Plugin activate result must be a disposer or undefined");
|
|
8551
|
+
disposers.push(deactivate);
|
|
8552
|
+
}
|
|
8286
8553
|
}
|
|
8287
8554
|
this.#assertAllDeclaredRegistered(candidate, claimed);
|
|
8288
8555
|
const metadata = { name: plugin, version: candidate.manifest.version, source: candidate.source, root: candidate.root };
|
|
@@ -8446,7 +8713,7 @@ async function readManifest2(path) {
|
|
|
8446
8713
|
async function snapshotEntry(root, entry2) {
|
|
8447
8714
|
const lexicalStats = await lstat3(entry2, { bigint: true });
|
|
8448
8715
|
if (!lexicalStats.isFile() && !lexicalStats.isSymbolicLink()) throw new Error("Plugin entry must be a file");
|
|
8449
|
-
const physicalPath = await
|
|
8716
|
+
const physicalPath = await realpath6(entry2);
|
|
8450
8717
|
assertContained2(root, physicalPath, "Plugin entry symlink");
|
|
8451
8718
|
const physicalStats = await stat4(physicalPath, { bigint: true });
|
|
8452
8719
|
if (!physicalStats.isFile()) throw new Error("Plugin entry must resolve to a regular file");
|
|
@@ -8562,6 +8829,8 @@ var SCAFFOLD_ENTRY = (name) => `// ${name} \u2014 generated by /evolve improve <
|
|
|
8562
8829
|
// - context: { signal, config, logger, services, registerCommand,
|
|
8563
8830
|
// registerTool, registerHook, registerSkillRoot, registerModelAdapter }
|
|
8564
8831
|
// - every contribution you register MUST be declared in contributes
|
|
8832
|
+
// - sandbox verification only permits relative JS modules inside this plugin root;
|
|
8833
|
+
// Node.js built-ins, package imports, filesystem, and network APIs are unavailable
|
|
8565
8834
|
//
|
|
8566
8835
|
// Implement your fix here. Example \u2014 observe tool failures:
|
|
8567
8836
|
// ctx.registerHook("PostToolUseFailure", (event) => {
|
|
@@ -8601,7 +8870,9 @@ async function verifyFixPlugin(workspace, name) {
|
|
|
8601
8870
|
await cp2(pluginRoot, join8(sandbox, name), { recursive: true });
|
|
8602
8871
|
const host = new PluginHost({
|
|
8603
8872
|
projectPluginDirs: [sandbox],
|
|
8873
|
+
sandbox: true,
|
|
8604
8874
|
config: {},
|
|
8875
|
+
activationTimeoutMs: 5e3,
|
|
8605
8876
|
registrations: {
|
|
8606
8877
|
command: (commandName) => {
|
|
8607
8878
|
collected.commands.push(commandName);
|
|
@@ -8615,12 +8886,11 @@ async function verifyFixPlugin(workspace, name) {
|
|
|
8615
8886
|
skillRoot: () => () => void 0,
|
|
8616
8887
|
modelAdapter: () => () => void 0
|
|
8617
8888
|
},
|
|
8618
|
-
logger: {
|
|
8619
|
-
|
|
8620
|
-
|
|
8621
|
-
|
|
8622
|
-
|
|
8623
|
-
}
|
|
8889
|
+
logger: { debug() {
|
|
8890
|
+
}, info() {
|
|
8891
|
+
}, warn() {
|
|
8892
|
+
}, error() {
|
|
8893
|
+
} }
|
|
8624
8894
|
});
|
|
8625
8895
|
await host.loadAll();
|
|
8626
8896
|
const loaded = host.loadedPlugins;
|
|
@@ -8679,7 +8949,7 @@ async function revertFixPlugin(workspace, name) {
|
|
|
8679
8949
|
// src/evolve/store.ts
|
|
8680
8950
|
import { createHash as createHash5 } from "crypto";
|
|
8681
8951
|
import { appendFile, mkdir as mkdir8, readFile as readFile7, rm as rm5, writeFile as writeFile6 } from "fs/promises";
|
|
8682
|
-
import { dirname as
|
|
8952
|
+
import { dirname as dirname8, join as join9 } from "path";
|
|
8683
8953
|
function normalizeError(message2) {
|
|
8684
8954
|
return String(message2 ?? "").replace(/\s+/g, " ").replace(/"[^"]*"/g, '"\u2026"').replace(/`[^`]*`/g, '"\u2026"').trim().slice(0, 160);
|
|
8685
8955
|
}
|
|
@@ -8708,7 +8978,7 @@ async function readJsonLines(file) {
|
|
|
8708
8978
|
}
|
|
8709
8979
|
}
|
|
8710
8980
|
async function writeJsonLines(file, records) {
|
|
8711
|
-
await mkdir8(
|
|
8981
|
+
await mkdir8(dirname8(file), { recursive: true, mode: 448 });
|
|
8712
8982
|
const body = records.map((record3) => JSON.stringify(record3)).join("\n");
|
|
8713
8983
|
await writeFile6(file, body.length > 0 ? `${body}
|
|
8714
8984
|
` : "", { encoding: "utf8", mode: 384 });
|
|
@@ -8736,7 +9006,7 @@ async function readRules(file) {
|
|
|
8736
9006
|
}
|
|
8737
9007
|
}
|
|
8738
9008
|
async function writeRules(file, rules) {
|
|
8739
|
-
await mkdir8(
|
|
9009
|
+
await mkdir8(dirname8(file), { recursive: true, mode: 448 });
|
|
8740
9010
|
await writeFile6(file, JSON.stringify(rules, null, 2), { encoding: "utf8", mode: 384 });
|
|
8741
9011
|
}
|
|
8742
9012
|
var EvolveStore = class {
|
|
@@ -9358,10 +9628,10 @@ ${result.stderr.slice(-4e3)}` : ""}`;
|
|
|
9358
9628
|
return USAGE;
|
|
9359
9629
|
},
|
|
9360
9630
|
toolDefinition() {
|
|
9361
|
-
const inputSchema =
|
|
9362
|
-
suggestionId:
|
|
9363
|
-
implementation:
|
|
9364
|
-
kind:
|
|
9631
|
+
const inputSchema = z18.object({
|
|
9632
|
+
suggestionId: z18.string().min(1).describe("Signal id from the evolve suggestions"),
|
|
9633
|
+
implementation: z18.string().min(1).describe("Concise description of the fix to implement (plugin plan, or the guardrail rule text when kind is prompt_rule)"),
|
|
9634
|
+
kind: z18.enum(["plugin", "prompt_rule"]).optional().describe(
|
|
9365
9635
|
"plugin (default): scaffold a fix plugin; prompt_rule: store a guardrail rule that is injected into future system prompts"
|
|
9366
9636
|
)
|
|
9367
9637
|
});
|
|
@@ -9410,9 +9680,9 @@ ${result.stderr.slice(-4e3)}` : ""}`;
|
|
|
9410
9680
|
}
|
|
9411
9681
|
|
|
9412
9682
|
// src/init/project.ts
|
|
9413
|
-
import { lstat as lstat4, mkdir as mkdir9, readdir as readdir4, readFile as readFile8, realpath as
|
|
9683
|
+
import { lstat as lstat4, mkdir as mkdir9, readdir as readdir4, readFile as readFile8, realpath as realpath7, writeFile as writeFile8 } from "fs/promises";
|
|
9414
9684
|
import { copyFileSync, mkdirSync, readdirSync, readFileSync } from "fs";
|
|
9415
|
-
import { basename as basename4, dirname as
|
|
9685
|
+
import { basename as basename4, dirname as dirname9, isAbsolute as isAbsolute7, join as join11, relative as relative7, sep as sep7 } from "path";
|
|
9416
9686
|
import { fileURLToPath } from "url";
|
|
9417
9687
|
var GENERATED_START = "<!-- flavor-code:start -->";
|
|
9418
9688
|
var GENERATED_END = "<!-- flavor-code:end -->";
|
|
@@ -9467,7 +9737,7 @@ function isContainedPath(root, candidate) {
|
|
|
9467
9737
|
async function pathKind(path, root) {
|
|
9468
9738
|
try {
|
|
9469
9739
|
const details = await lstat4(path);
|
|
9470
|
-
if (details.isSymbolicLink() || !isContainedPath(root, await
|
|
9740
|
+
if (details.isSymbolicLink() || !isContainedPath(root, await realpath7(path))) return void 0;
|
|
9471
9741
|
if (details.isFile()) return "file";
|
|
9472
9742
|
if (details.isDirectory()) return "directory";
|
|
9473
9743
|
return void 0;
|
|
@@ -9484,7 +9754,7 @@ async function readTextIfSmall(path, root) {
|
|
|
9484
9754
|
if (isMissingPathError(error)) return void 0;
|
|
9485
9755
|
throw error;
|
|
9486
9756
|
});
|
|
9487
|
-
if (details === void 0 || !details.isFile() || details.isSymbolicLink() || details.size > MAX_MANIFEST_BYTES2 || !isContainedPath(root, await
|
|
9757
|
+
if (details === void 0 || !details.isFile() || details.isSymbolicLink() || details.size > MAX_MANIFEST_BYTES2 || !isContainedPath(root, await realpath7(path))) {
|
|
9488
9758
|
return void 0;
|
|
9489
9759
|
}
|
|
9490
9760
|
return readFile8(path, "utf8");
|
|
@@ -9535,7 +9805,7 @@ async function sampleSourceExtensions(cwd, root, directories) {
|
|
|
9535
9805
|
const sampleDirectories = ["", ...directories].slice(0, 12);
|
|
9536
9806
|
for (const relativeDirectory of sampleDirectories) {
|
|
9537
9807
|
const absoluteDirectory = join11(cwd, relativeDirectory);
|
|
9538
|
-
if (!isContainedPath(root, await
|
|
9808
|
+
if (!isContainedPath(root, await realpath7(absoluteDirectory))) continue;
|
|
9539
9809
|
let entries;
|
|
9540
9810
|
try {
|
|
9541
9811
|
entries = await readdir4(absoluteDirectory, { withFileTypes: true });
|
|
@@ -9552,7 +9822,7 @@ async function sampleSourceExtensions(cwd, root, directories) {
|
|
|
9552
9822
|
return extensions;
|
|
9553
9823
|
}
|
|
9554
9824
|
async function inspectProject(cwd) {
|
|
9555
|
-
const root = await
|
|
9825
|
+
const root = await realpath7(cwd);
|
|
9556
9826
|
const sourceDirectories = [];
|
|
9557
9827
|
for (const directory of SOURCE_DIRECTORIES) {
|
|
9558
9828
|
if (await pathKind(join11(cwd, directory), root) === "directory") sourceDirectories.push(directory);
|
|
@@ -9786,7 +10056,7 @@ function isEntryIgnored(lines, entry2) {
|
|
|
9786
10056
|
}
|
|
9787
10057
|
async function addSessionsToGitignore(cwd) {
|
|
9788
10058
|
const path = join11(cwd, ".gitignore");
|
|
9789
|
-
const root = await
|
|
10059
|
+
const root = await realpath7(cwd);
|
|
9790
10060
|
await assertSafeManagedPath(path, root);
|
|
9791
10061
|
let existing;
|
|
9792
10062
|
try {
|
|
@@ -9809,7 +10079,7 @@ async function assertSafeManagedPath(path, root) {
|
|
|
9809
10079
|
if (details.isSymbolicLink()) {
|
|
9810
10080
|
throw new Error(`Refusing to overwrite managed file symbolic link: ${path}`);
|
|
9811
10081
|
}
|
|
9812
|
-
if (!isContainedPath(root, await
|
|
10082
|
+
if (!isContainedPath(root, await realpath7(path))) {
|
|
9813
10083
|
throw new Error(`Refusing to overwrite managed file outside the project: ${path}`);
|
|
9814
10084
|
}
|
|
9815
10085
|
} catch (error) {
|
|
@@ -9818,16 +10088,16 @@ async function assertSafeManagedPath(path, root) {
|
|
|
9818
10088
|
}
|
|
9819
10089
|
}
|
|
9820
10090
|
async function ensureFlavorDirectories(cwd) {
|
|
9821
|
-
const root = await
|
|
10091
|
+
const root = await realpath7(cwd);
|
|
9822
10092
|
const sessionsDir = join11(cwd, ".flavor", "sessions");
|
|
9823
10093
|
const skillsDir = join11(cwd, ".flavor", "skills");
|
|
9824
10094
|
const pluginsDir = join11(cwd, ".flavor", "plugins");
|
|
9825
10095
|
await mkdir9(sessionsDir, { recursive: true, mode: 448 });
|
|
9826
10096
|
await mkdir9(skillsDir, { recursive: true, mode: 448 });
|
|
9827
10097
|
await mkdir9(pluginsDir, { recursive: true, mode: 448 });
|
|
9828
|
-
const canonicalRoot = await
|
|
10098
|
+
const canonicalRoot = await realpath7(root);
|
|
9829
10099
|
for (const dir of [sessionsDir, skillsDir, pluginsDir]) {
|
|
9830
|
-
const canonical3 = await
|
|
10100
|
+
const canonical3 = await realpath7(dir);
|
|
9831
10101
|
if (!isContainedPath(canonicalRoot, canonical3)) {
|
|
9832
10102
|
throw new Error(`Directory escapes the workspace: ${dir}`);
|
|
9833
10103
|
}
|
|
@@ -9835,7 +10105,7 @@ async function ensureFlavorDirectories(cwd) {
|
|
|
9835
10105
|
}
|
|
9836
10106
|
async function createExampleFlavorConfig(cwd) {
|
|
9837
10107
|
const configPath = join11(cwd, ".flavor", "flavor.json");
|
|
9838
|
-
const root = await
|
|
10108
|
+
const root = await realpath7(cwd);
|
|
9839
10109
|
await assertSafeManagedPath(configPath, root);
|
|
9840
10110
|
try {
|
|
9841
10111
|
await lstat4(configPath);
|
|
@@ -9864,7 +10134,7 @@ async function createExampleFlavorConfig(cwd) {
|
|
|
9864
10134
|
};
|
|
9865
10135
|
await writeFile8(configPath, JSON.stringify(example, null, 2) + "\n");
|
|
9866
10136
|
}
|
|
9867
|
-
var CODEISLAND_SRC_DIR = join11(
|
|
10137
|
+
var CODEISLAND_SRC_DIR = join11(dirname9(fileURLToPath(import.meta.url)), "codeisland");
|
|
9868
10138
|
var CODEISLAND_FILES = ["flavor-plugin.json", "activate.mjs", "bridge.mjs"];
|
|
9869
10139
|
async function copyCodeIslandPlugin(cwd) {
|
|
9870
10140
|
const pluginDir = join11(cwd, ".flavor", "plugins", "codeisland");
|
|
@@ -9880,7 +10150,7 @@ async function copyCodeIslandPlugin(cwd) {
|
|
|
9880
10150
|
await writeFile8(join11(pluginDir, name), content);
|
|
9881
10151
|
}
|
|
9882
10152
|
}
|
|
9883
|
-
var ASTGRAPH_SRC_DIR = join11(
|
|
10153
|
+
var ASTGRAPH_SRC_DIR = join11(dirname9(fileURLToPath(import.meta.url)), "astgraph");
|
|
9884
10154
|
async function copyAstgraphPlugin(cwd) {
|
|
9885
10155
|
const pluginDir = join11(cwd, ".flavor", "plugins", "astgraph");
|
|
9886
10156
|
try {
|
|
@@ -9907,7 +10177,7 @@ async function initializeFlavor(cwd) {
|
|
|
9907
10177
|
await createExampleFlavorConfig(cwd);
|
|
9908
10178
|
const facts = await inspectProject(cwd);
|
|
9909
10179
|
const path = join11(cwd, "FLAVOR.md");
|
|
9910
|
-
const root = await
|
|
10180
|
+
const root = await realpath7(cwd);
|
|
9911
10181
|
await assertSafeManagedPath(path, root);
|
|
9912
10182
|
let existing;
|
|
9913
10183
|
try {
|
|
@@ -9941,8 +10211,8 @@ function buildLoopCyclePrompt(input) {
|
|
|
9941
10211
|
}
|
|
9942
10212
|
|
|
9943
10213
|
// src/loop/types.ts
|
|
9944
|
-
import { z as
|
|
9945
|
-
var LoopStatusSchema =
|
|
10214
|
+
import { z as z19 } from "zod";
|
|
10215
|
+
var LoopStatusSchema = z19.enum([
|
|
9946
10216
|
"running",
|
|
9947
10217
|
"succeeded",
|
|
9948
10218
|
"failed",
|
|
@@ -9952,65 +10222,65 @@ var LoopStatusSchema = z18.enum([
|
|
|
9952
10222
|
"no_progress",
|
|
9953
10223
|
"needs_human"
|
|
9954
10224
|
]);
|
|
9955
|
-
var LoopApprovalSchema =
|
|
9956
|
-
dimension:
|
|
9957
|
-
previousCheckpoint:
|
|
9958
|
-
newCheckpoint:
|
|
9959
|
-
usage:
|
|
9960
|
-
approvedAt:
|
|
10225
|
+
var LoopApprovalSchema = z19.object({
|
|
10226
|
+
dimension: z19.enum(["cycles", "tokens"]),
|
|
10227
|
+
previousCheckpoint: z19.number().int().nonnegative(),
|
|
10228
|
+
newCheckpoint: z19.number().int().positive(),
|
|
10229
|
+
usage: z19.number().int().nonnegative(),
|
|
10230
|
+
approvedAt: z19.string().datetime({ offset: true })
|
|
9961
10231
|
}).strict();
|
|
9962
|
-
var LoopVerificationCommandSchema =
|
|
9963
|
-
command:
|
|
9964
|
-
args:
|
|
9965
|
-
exitCode:
|
|
9966
|
-
stdout:
|
|
9967
|
-
stderr:
|
|
9968
|
-
truncated:
|
|
10232
|
+
var LoopVerificationCommandSchema = z19.object({
|
|
10233
|
+
command: z19.string().min(1),
|
|
10234
|
+
args: z19.array(z19.string()),
|
|
10235
|
+
exitCode: z19.number().int().nullable(),
|
|
10236
|
+
stdout: z19.string(),
|
|
10237
|
+
stderr: z19.string(),
|
|
10238
|
+
truncated: z19.boolean()
|
|
9969
10239
|
}).strict();
|
|
9970
|
-
var LoopVerificationEvidenceSchema =
|
|
9971
|
-
passed:
|
|
9972
|
-
commands:
|
|
9973
|
-
summary:
|
|
10240
|
+
var LoopVerificationEvidenceSchema = z19.object({
|
|
10241
|
+
passed: z19.boolean(),
|
|
10242
|
+
commands: z19.array(LoopVerificationCommandSchema),
|
|
10243
|
+
summary: z19.string()
|
|
9974
10244
|
}).strict();
|
|
9975
|
-
var LoopCycleEvidenceSchema =
|
|
9976
|
-
cycle:
|
|
9977
|
-
startedAt:
|
|
9978
|
-
completedAt:
|
|
9979
|
-
inputTokens:
|
|
9980
|
-
outputTokens:
|
|
9981
|
-
workspaceFingerprint:
|
|
10245
|
+
var LoopCycleEvidenceSchema = z19.object({
|
|
10246
|
+
cycle: z19.number().int().positive(),
|
|
10247
|
+
startedAt: z19.string().datetime({ offset: true }),
|
|
10248
|
+
completedAt: z19.string().datetime({ offset: true }),
|
|
10249
|
+
inputTokens: z19.number().int().nonnegative(),
|
|
10250
|
+
outputTokens: z19.number().int().nonnegative(),
|
|
10251
|
+
workspaceFingerprint: z19.string(),
|
|
9982
10252
|
verification: LoopVerificationEvidenceSchema
|
|
9983
10253
|
}).strict();
|
|
9984
|
-
var LoopStateSchema =
|
|
9985
|
-
version:
|
|
9986
|
-
loopId:
|
|
9987
|
-
goal:
|
|
9988
|
-
workspace:
|
|
9989
|
-
createdAt:
|
|
9990
|
-
updatedAt:
|
|
10254
|
+
var LoopStateSchema = z19.object({
|
|
10255
|
+
version: z19.literal(1),
|
|
10256
|
+
loopId: z19.string().regex(/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/),
|
|
10257
|
+
goal: z19.string().trim().min(1),
|
|
10258
|
+
workspace: z19.string().min(1),
|
|
10259
|
+
createdAt: z19.string().datetime({ offset: true }),
|
|
10260
|
+
updatedAt: z19.string().datetime({ offset: true }),
|
|
9991
10261
|
status: LoopStatusSchema,
|
|
9992
|
-
config:
|
|
9993
|
-
cycleStep:
|
|
9994
|
-
tokenStep:
|
|
9995
|
-
isolation:
|
|
10262
|
+
config: z19.object({
|
|
10263
|
+
cycleStep: z19.number().int().positive(),
|
|
10264
|
+
tokenStep: z19.number().int().positive(),
|
|
10265
|
+
isolation: z19.literal("auto")
|
|
9996
10266
|
}).strict(),
|
|
9997
|
-
budget:
|
|
9998
|
-
cyclesUsed:
|
|
9999
|
-
inputTokens:
|
|
10000
|
-
outputTokens:
|
|
10001
|
-
cycleCheckpoint:
|
|
10002
|
-
tokenCheckpoint:
|
|
10003
|
-
approvals:
|
|
10267
|
+
budget: z19.object({
|
|
10268
|
+
cyclesUsed: z19.number().int().nonnegative(),
|
|
10269
|
+
inputTokens: z19.number().int().nonnegative(),
|
|
10270
|
+
outputTokens: z19.number().int().nonnegative(),
|
|
10271
|
+
cycleCheckpoint: z19.number().int().positive(),
|
|
10272
|
+
tokenCheckpoint: z19.number().int().positive(),
|
|
10273
|
+
approvals: z19.array(LoopApprovalSchema)
|
|
10004
10274
|
}).strict(),
|
|
10005
|
-
cycles:
|
|
10006
|
-
terminalReason:
|
|
10275
|
+
cycles: z19.array(LoopCycleEvidenceSchema),
|
|
10276
|
+
terminalReason: z19.string().optional()
|
|
10007
10277
|
}).strict();
|
|
10008
|
-
var LoopEventSchema =
|
|
10009
|
-
version:
|
|
10010
|
-
type:
|
|
10011
|
-
timestamp:
|
|
10012
|
-
loopId:
|
|
10013
|
-
payload:
|
|
10278
|
+
var LoopEventSchema = z19.object({
|
|
10279
|
+
version: z19.literal(1),
|
|
10280
|
+
type: z19.enum(["created", "cycle_started", "cycle_completed", "verification", "budget_approved", "terminal"]),
|
|
10281
|
+
timestamp: z19.string().datetime({ offset: true }),
|
|
10282
|
+
loopId: z19.string().regex(/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/),
|
|
10283
|
+
payload: z19.record(z19.string(), z19.unknown())
|
|
10014
10284
|
}).strict();
|
|
10015
10285
|
|
|
10016
10286
|
// src/loop/budget.ts
|
|
@@ -10326,15 +10596,15 @@ import { writeFile as writeFile9, mkdir as mkdir10 } from "fs/promises";
|
|
|
10326
10596
|
import { join as join13 } from "path";
|
|
10327
10597
|
|
|
10328
10598
|
// src/goal/types.ts
|
|
10329
|
-
import { z as
|
|
10330
|
-
var GoalPhaseSchema =
|
|
10599
|
+
import { z as z20 } from "zod";
|
|
10600
|
+
var GoalPhaseSchema = z20.enum([
|
|
10331
10601
|
"idle",
|
|
10332
10602
|
"planning",
|
|
10333
10603
|
"executing",
|
|
10334
10604
|
"verifying",
|
|
10335
10605
|
"complete"
|
|
10336
10606
|
]);
|
|
10337
|
-
var GoalStatusSchema =
|
|
10607
|
+
var GoalStatusSchema = z20.enum([
|
|
10338
10608
|
"active",
|
|
10339
10609
|
"paused",
|
|
10340
10610
|
"achieved",
|
|
@@ -10342,43 +10612,43 @@ var GoalStatusSchema = z19.enum([
|
|
|
10342
10612
|
"blocked",
|
|
10343
10613
|
"failed"
|
|
10344
10614
|
]);
|
|
10345
|
-
var AcceptanceCriterionSchema =
|
|
10346
|
-
id:
|
|
10347
|
-
description:
|
|
10348
|
-
type:
|
|
10615
|
+
var AcceptanceCriterionSchema = z20.object({
|
|
10616
|
+
id: z20.number().int().positive(),
|
|
10617
|
+
description: z20.string().min(1),
|
|
10618
|
+
type: z20.enum(["gating", "evidence"])
|
|
10349
10619
|
}).strict();
|
|
10350
|
-
var PlanSchema =
|
|
10351
|
-
kind:
|
|
10352
|
-
criteria:
|
|
10353
|
-
verificationPlan:
|
|
10354
|
-
nonGoals:
|
|
10355
|
-
assumedScope:
|
|
10356
|
-
approach:
|
|
10357
|
-
checklist:
|
|
10620
|
+
var PlanSchema = z20.object({
|
|
10621
|
+
kind: z20.enum(["code-change", "analysis", "research"]),
|
|
10622
|
+
criteria: z20.array(AcceptanceCriterionSchema).min(1).max(32),
|
|
10623
|
+
verificationPlan: z20.string().min(1),
|
|
10624
|
+
nonGoals: z20.array(z20.string()).max(16),
|
|
10625
|
+
assumedScope: z20.array(z20.string()).max(16),
|
|
10626
|
+
approach: z20.string().optional(),
|
|
10627
|
+
checklist: z20.array(z20.string()).max(32).optional()
|
|
10358
10628
|
}).strict();
|
|
10359
|
-
var GapSchema =
|
|
10360
|
-
criterion:
|
|
10361
|
-
description:
|
|
10362
|
-
blocking:
|
|
10629
|
+
var GapSchema = z20.object({
|
|
10630
|
+
criterion: z20.string().min(1),
|
|
10631
|
+
description: z20.string().min(1),
|
|
10632
|
+
blocking: z20.enum(["model_fixable", "contradiction", "unverifiable"])
|
|
10363
10633
|
}).strict();
|
|
10364
|
-
var VerdictSchema =
|
|
10365
|
-
refuted:
|
|
10366
|
-
gaps:
|
|
10634
|
+
var VerdictSchema = z20.object({
|
|
10635
|
+
refuted: z20.boolean(),
|
|
10636
|
+
gaps: z20.array(GapSchema)
|
|
10367
10637
|
}).strict();
|
|
10368
|
-
var GoalStateSchema =
|
|
10369
|
-
id:
|
|
10370
|
-
objective:
|
|
10638
|
+
var GoalStateSchema = z20.object({
|
|
10639
|
+
id: z20.string().regex(/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/),
|
|
10640
|
+
objective: z20.string().min(1),
|
|
10371
10641
|
phase: GoalPhaseSchema,
|
|
10372
10642
|
status: GoalStatusSchema,
|
|
10373
10643
|
plan: PlanSchema.nullable(),
|
|
10374
|
-
planPath:
|
|
10375
|
-
verifyRounds:
|
|
10376
|
-
workerRounds:
|
|
10377
|
-
lastGaps:
|
|
10378
|
-
gapFingerprint:
|
|
10379
|
-
stallStreak:
|
|
10380
|
-
createdAt:
|
|
10381
|
-
updatedAt:
|
|
10644
|
+
planPath: z20.string().nullable(),
|
|
10645
|
+
verifyRounds: z20.number().int().min(0),
|
|
10646
|
+
workerRounds: z20.number().int().min(0),
|
|
10647
|
+
lastGaps: z20.array(GapSchema),
|
|
10648
|
+
gapFingerprint: z20.string(),
|
|
10649
|
+
stallStreak: z20.number().int().min(0),
|
|
10650
|
+
createdAt: z20.string().datetime({ offset: true }),
|
|
10651
|
+
updatedAt: z20.string().datetime({ offset: true })
|
|
10382
10652
|
}).strict();
|
|
10383
10653
|
|
|
10384
10654
|
// src/goal/planner.ts
|
|
@@ -10939,7 +11209,7 @@ function formatPriorGaps(gaps) {
|
|
|
10939
11209
|
import { constants as constants2 } from "fs";
|
|
10940
11210
|
import { randomUUID as randomUUID7 } from "crypto";
|
|
10941
11211
|
import { lstat as lstat5, mkdir as mkdir11, open as open5, rename as rename4, rm as rm6 } from "fs/promises";
|
|
10942
|
-
import { dirname as
|
|
11212
|
+
import { dirname as dirname10, join as join14, relative as relative9, resolve as resolve10, sep as sep8 } from "path";
|
|
10943
11213
|
var DEFAULT_MAX_BYTES = 1024 * 1024;
|
|
10944
11214
|
var GoalStore = class {
|
|
10945
11215
|
#workspace;
|
|
@@ -10952,7 +11222,7 @@ var GoalStore = class {
|
|
|
10952
11222
|
}
|
|
10953
11223
|
async save(input) {
|
|
10954
11224
|
const state = GoalStateSchema.parse(input);
|
|
10955
|
-
await assertNoSymlink(this.#workspace,
|
|
11225
|
+
await assertNoSymlink(this.#workspace, dirname10(this.#root));
|
|
10956
11226
|
await mkdir11(this.#root, { recursive: true, mode: 448 });
|
|
10957
11227
|
await assertNoSymlink(this.#workspace, this.#root);
|
|
10958
11228
|
const target = join14(this.#root, `${state.id}.json`);
|
|
@@ -10986,7 +11256,7 @@ async function assertNoSymlink(root, target) {
|
|
|
10986
11256
|
const chain = [];
|
|
10987
11257
|
while (cursor !== stop) {
|
|
10988
11258
|
chain.push(cursor);
|
|
10989
|
-
cursor =
|
|
11259
|
+
cursor = dirname10(cursor);
|
|
10990
11260
|
}
|
|
10991
11261
|
for (const path of chain.reverse()) {
|
|
10992
11262
|
try {
|
|
@@ -11072,8 +11342,8 @@ async function ensureWorktreeDirectoryIgnored(root) {
|
|
|
11072
11342
|
|
|
11073
11343
|
// src/loop/store.ts
|
|
11074
11344
|
import { constants as constants3 } from "fs";
|
|
11075
|
-
import { lstat as lstat6, mkdir as mkdir13, open as open6, readFile as readFile11, realpath as
|
|
11076
|
-
import { dirname as
|
|
11345
|
+
import { lstat as lstat6, mkdir as mkdir13, open as open6, readFile as readFile11, realpath as realpath8, rename as rename5, rm as rm7, stat as stat6 } from "fs/promises";
|
|
11346
|
+
import { dirname as dirname11, join as join16, relative as relative10, resolve as resolve12, sep as sep9 } from "path";
|
|
11077
11347
|
import { randomUUID as randomUUID8 } from "crypto";
|
|
11078
11348
|
var LOOP_ID = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
|
|
11079
11349
|
var DEFAULT_MAX_BYTES2 = 5 * 1024 * 1024;
|
|
@@ -11155,7 +11425,7 @@ var LoopStore = class {
|
|
|
11155
11425
|
}
|
|
11156
11426
|
async #prepare(loopId) {
|
|
11157
11427
|
validateId(loopId);
|
|
11158
|
-
await assertNoSymlink2(this.#workspace,
|
|
11428
|
+
await assertNoSymlink2(this.#workspace, dirname11(this.#root));
|
|
11159
11429
|
await mkdir13(this.#root, { recursive: true, mode: 448 });
|
|
11160
11430
|
await assertNoSymlink2(this.#workspace, this.#root);
|
|
11161
11431
|
const directory = join16(this.#root, loopId);
|
|
@@ -11188,7 +11458,7 @@ async function assertNoSymlink2(root, target) {
|
|
|
11188
11458
|
const chain = [];
|
|
11189
11459
|
while (cursor !== stop) {
|
|
11190
11460
|
chain.push(cursor);
|
|
11191
|
-
cursor =
|
|
11461
|
+
cursor = dirname11(cursor);
|
|
11192
11462
|
}
|
|
11193
11463
|
for (const path of chain.reverse()) {
|
|
11194
11464
|
try {
|
|
@@ -11204,7 +11474,7 @@ function isWithin2(root, path) {
|
|
|
11204
11474
|
}
|
|
11205
11475
|
async function canonical(path) {
|
|
11206
11476
|
try {
|
|
11207
|
-
return await
|
|
11477
|
+
return await realpath8(resolve12(path));
|
|
11208
11478
|
} catch {
|
|
11209
11479
|
return resolve12(path);
|
|
11210
11480
|
}
|
|
@@ -11220,19 +11490,19 @@ import { join as join17 } from "path";
|
|
|
11220
11490
|
// src/tools/shell.ts
|
|
11221
11491
|
import { spawn as spawn3, spawnSync } from "child_process";
|
|
11222
11492
|
import { isAbsolute as isAbsolute8, relative as relative11, resolve as resolve13, sep as sep10 } from "path";
|
|
11223
|
-
import { z as
|
|
11493
|
+
import { z as z22 } from "zod";
|
|
11224
11494
|
|
|
11225
11495
|
// src/tools/jobs.ts
|
|
11226
|
-
import { z as
|
|
11227
|
-
var JobId =
|
|
11228
|
-
var ReadInput =
|
|
11229
|
-
var IdInput =
|
|
11496
|
+
import { z as z21 } from "zod";
|
|
11497
|
+
var JobId = z21.string().regex(/^job-[a-f0-9-]+$/);
|
|
11498
|
+
var ReadInput = z21.object({ id: JobId, cursor: z21.coerce.number().int().min(0).optional() });
|
|
11499
|
+
var IdInput = z21.object({ id: JobId });
|
|
11230
11500
|
function createJobTools(registry) {
|
|
11231
11501
|
const tools = [
|
|
11232
11502
|
{
|
|
11233
11503
|
name: "JobList",
|
|
11234
11504
|
description: "List background jobs owned by this agent",
|
|
11235
|
-
inputSchema:
|
|
11505
|
+
inputSchema: z21.object({}),
|
|
11236
11506
|
paths: () => [],
|
|
11237
11507
|
execute: async (_input, _signal, context) => registry.list(owner(context)),
|
|
11238
11508
|
presentResult: (output) => jobListPresentation(output)
|
|
@@ -11307,14 +11577,14 @@ var ELLIPSIS = "\u2026";
|
|
|
11307
11577
|
var TERMINATION_GRACE_MS = 250;
|
|
11308
11578
|
var TERMINATION_FAILURE_MS = 5e3;
|
|
11309
11579
|
var STREAM_CLOSE_GRACE_MS = 500;
|
|
11310
|
-
var ShellInput =
|
|
11311
|
-
command:
|
|
11312
|
-
args:
|
|
11313
|
-
cwd:
|
|
11314
|
-
timeoutMs:
|
|
11580
|
+
var ShellInput = z22.object({
|
|
11581
|
+
command: z22.string().min(1),
|
|
11582
|
+
args: z22.array(z22.string()),
|
|
11583
|
+
cwd: z22.string().min(1).nullable().optional(),
|
|
11584
|
+
timeoutMs: z22.coerce.number().int().positive().max(864e5).nullable().optional(),
|
|
11315
11585
|
// Accepts booleans and their string forms (weak-typed models emit "true");
|
|
11316
11586
|
// kept transform-free so the schema converts to JSON Schema for providers.
|
|
11317
|
-
background:
|
|
11587
|
+
background: z22.union([z22.boolean(), z22.string().refine((value) => value === "true" || value === "false")]).optional()
|
|
11318
11588
|
});
|
|
11319
11589
|
function normalizeShellCommand(input) {
|
|
11320
11590
|
const { command, args } = input;
|
|
@@ -11916,7 +12186,7 @@ function isEnvTruthy(value) {
|
|
|
11916
12186
|
|
|
11917
12187
|
// src/utils/log.ts
|
|
11918
12188
|
import { appendFile as appendFile3, mkdir as mkdir14 } from "fs/promises";
|
|
11919
|
-
import { dirname as
|
|
12189
|
+
import { dirname as dirname12, join as join18, resolve as resolve14 } from "path";
|
|
11920
12190
|
var pending = Promise.resolve();
|
|
11921
12191
|
var usagePending = Promise.resolve();
|
|
11922
12192
|
function usageLogPath() {
|
|
@@ -11935,7 +12205,7 @@ async function appendUsageLog(line) {
|
|
|
11935
12205
|
usagePending = usagePending.catch(() => void 0).then(async () => {
|
|
11936
12206
|
try {
|
|
11937
12207
|
const path = usageLogPath();
|
|
11938
|
-
await mkdir14(
|
|
12208
|
+
await mkdir14(dirname12(path), { recursive: true, mode: 448 });
|
|
11939
12209
|
const flag = truncateOnNextAppend ? "w" : "a";
|
|
11940
12210
|
truncateOnNextAppend = false;
|
|
11941
12211
|
await appendFile3(path, `${line}
|
|
@@ -11963,7 +12233,7 @@ var AuditLogger = class {
|
|
|
11963
12233
|
}
|
|
11964
12234
|
async #write(line) {
|
|
11965
12235
|
try {
|
|
11966
|
-
await mkdir14(
|
|
12236
|
+
await mkdir14(dirname12(this.#path), { recursive: true, mode: 448 });
|
|
11967
12237
|
await appendFile3(this.#path, line, { encoding: "utf8", mode: 384, flag: "a" });
|
|
11968
12238
|
} catch {
|
|
11969
12239
|
}
|
|
@@ -12548,7 +12818,7 @@ var ModelRegistry = class {
|
|
|
12548
12818
|
|
|
12549
12819
|
// src/mcp/client.ts
|
|
12550
12820
|
import { createHash as createHash7 } from "crypto";
|
|
12551
|
-
import { z as
|
|
12821
|
+
import { z as z23 } from "zod";
|
|
12552
12822
|
var McpManager = class {
|
|
12553
12823
|
#workspace;
|
|
12554
12824
|
#clientFactory;
|
|
@@ -12684,7 +12954,7 @@ async function listAllTools(client) {
|
|
|
12684
12954
|
function createMcpToolDefinition(serverName, timeoutMs, client, remote) {
|
|
12685
12955
|
if (remote.name.length === 0) throw new Error("MCP tool name must not be empty");
|
|
12686
12956
|
if (!isRecord4(remote.inputSchema)) throw new Error(`MCP tool "${remote.name}" has no JSON object input schema`);
|
|
12687
|
-
const inputSchema =
|
|
12957
|
+
const inputSchema = z23.fromJSONSchema(
|
|
12688
12958
|
remote.inputSchema
|
|
12689
12959
|
);
|
|
12690
12960
|
return {
|
|
@@ -12745,12 +13015,12 @@ import {
|
|
|
12745
13015
|
|
|
12746
13016
|
// src/utils/version.ts
|
|
12747
13017
|
import { readFileSync as readFileSync2 } from "fs";
|
|
12748
|
-
import { dirname as
|
|
13018
|
+
import { dirname as dirname13, join as join19 } from "path";
|
|
12749
13019
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
12750
13020
|
var cached;
|
|
12751
13021
|
function packageVersion() {
|
|
12752
13022
|
if (cached !== void 0) return cached;
|
|
12753
|
-
let directory =
|
|
13023
|
+
let directory = dirname13(fileURLToPath2(import.meta.url));
|
|
12754
13024
|
for (; ; ) {
|
|
12755
13025
|
try {
|
|
12756
13026
|
const manifest = JSON.parse(readFileSync2(join19(directory, "package.json"), "utf8"));
|
|
@@ -12760,7 +13030,7 @@ function packageVersion() {
|
|
|
12760
13030
|
}
|
|
12761
13031
|
} catch {
|
|
12762
13032
|
}
|
|
12763
|
-
const parent =
|
|
13033
|
+
const parent = dirname13(directory);
|
|
12764
13034
|
if (parent === directory) break;
|
|
12765
13035
|
directory = parent;
|
|
12766
13036
|
}
|
|
@@ -13120,7 +13390,7 @@ function escapeHtml(text) {
|
|
|
13120
13390
|
}
|
|
13121
13391
|
|
|
13122
13392
|
// src/auth/store.ts
|
|
13123
|
-
import { dirname as
|
|
13393
|
+
import { dirname as dirname14 } from "path";
|
|
13124
13394
|
async function retainOnlyCredentials(store, keepCredentialId) {
|
|
13125
13395
|
const tokens2 = await store.load();
|
|
13126
13396
|
const retained = Object.fromEntries(Object.entries(tokens2).filter(([id]) => id === keepCredentialId));
|
|
@@ -13131,7 +13401,7 @@ function createFileTokenStore(filePath) {
|
|
|
13131
13401
|
const store = {
|
|
13132
13402
|
tokens: {},
|
|
13133
13403
|
async load() {
|
|
13134
|
-
const key = await loadOrCreateConfigKey(
|
|
13404
|
+
const key = await loadOrCreateConfigKey(dirname14(filePath));
|
|
13135
13405
|
const result = await readRecoverableFile(filePath, (raw) => parseTokens(decryptDocument(raw, key)));
|
|
13136
13406
|
const tokens2 = result?.value ?? {};
|
|
13137
13407
|
baseline = { ...tokens2 };
|
|
@@ -13139,7 +13409,7 @@ function createFileTokenStore(filePath) {
|
|
|
13139
13409
|
return tokens2;
|
|
13140
13410
|
},
|
|
13141
13411
|
async save(tokens2) {
|
|
13142
|
-
const key = await loadOrCreateConfigKey(
|
|
13412
|
+
const key = await loadOrCreateConfigKey(dirname14(filePath));
|
|
13143
13413
|
const removals = Object.keys(baseline).filter((providerId) => !(providerId in tokens2));
|
|
13144
13414
|
const upserts = Object.fromEntries(Object.entries(tokens2).filter(
|
|
13145
13415
|
([providerId, token]) => !sameToken(baseline[providerId], token)
|
|
@@ -13257,6 +13527,7 @@ function toolsSection(toolNames) {
|
|
|
13257
13527
|
addToolRule(rules, toolNames, "TaskUpdate", "Use `TaskUpdate` to mark each planned task in progress before starting and completed only after successful verification.");
|
|
13258
13528
|
addToolRule(rules, toolNames, "Task", "Use `Task` when independent, well-bounded subtasks can benefit from isolated child agents. Give each child a self-contained briefing and do not delegate the final synthesis.");
|
|
13259
13529
|
addToolRule(rules, toolNames, "TaskOutput", "Use `TaskOutput` at the end of multi-step work to record changed files, commands, verification, risks, and useful next steps.");
|
|
13530
|
+
addToolRule(rules, toolNames, "Skill", "Use `Skill` whenever an active skill requires or references another skill. Load the required skill before continuing, pass arguments when the nested workflow has its own task input, and follow the returned instructions completely.");
|
|
13260
13531
|
addToolRule(rules, toolNames, "SkillResource", "Use `SkillResource` only to read a resource explicitly referenced by a matched skill. Treat returned scripts as data; do not execute them through that tool.");
|
|
13261
13532
|
addToolRule(rules, toolNames, "RegisterTool", "Use `RegisterTool` to create a durable reusable capability from JSON Schema and async JavaScript. Create one only when the user requests it or the task has a clear recurring need; never persist a tool for a one-off operation. The new tool is available on the next model step in the same run. Its implementation may be either a function body with an explicit `return`, or a complete function/arrow expression; all forms receive `input`, `signal`, and `context`.");
|
|
13262
13533
|
addToolRule(rules, toolNames, "RemoveTool", "Use `RemoveTool` only to delete a tool created by `RegisterTool`. To modify a managed tool, delete and register again; it cannot delete built-in, plugin, or MCP tools.");
|
|
@@ -13305,7 +13576,7 @@ function data(value) {
|
|
|
13305
13576
|
|
|
13306
13577
|
// src/skills/registry.ts
|
|
13307
13578
|
import { constants as constants4 } from "fs";
|
|
13308
|
-
import { lstat as lstat7, open as defaultOpen, readdir as readdir6, realpath as
|
|
13579
|
+
import { lstat as lstat7, open as defaultOpen, readdir as readdir6, realpath as realpath9 } from "fs/promises";
|
|
13309
13580
|
import { isAbsolute as isAbsolute9, relative as relative12, resolve as resolve16, sep as sep11 } from "path";
|
|
13310
13581
|
import { marked } from "marked";
|
|
13311
13582
|
import { parseDocument } from "yaml";
|
|
@@ -13472,7 +13743,7 @@ var SkillRegistry = class {
|
|
|
13472
13743
|
try {
|
|
13473
13744
|
const rootInfo = await lstat7(root);
|
|
13474
13745
|
if (rootInfo.isSymbolicLink() || !rootInfo.isDirectory()) throw new Error("Skill root must be a real directory");
|
|
13475
|
-
physicalRoot = await
|
|
13746
|
+
physicalRoot = await realpath9(root);
|
|
13476
13747
|
entries = await readdir6(root, { withFileTypes: true });
|
|
13477
13748
|
} catch (error) {
|
|
13478
13749
|
if (isMissing(error)) continue;
|
|
@@ -13485,7 +13756,7 @@ var SkillRegistry = class {
|
|
|
13485
13756
|
try {
|
|
13486
13757
|
if (entry2.isSymbolicLink()) throw new Error("Symlinked skill directories are not allowed");
|
|
13487
13758
|
if (!entry2.isDirectory()) continue;
|
|
13488
|
-
const physicalSkillRoot = await
|
|
13759
|
+
const physicalSkillRoot = await realpath9(skillRoot);
|
|
13489
13760
|
if (!isWithin3(physicalRoot, physicalSkillRoot)) throw new Error("Skill directory escapes its registry root");
|
|
13490
13761
|
const skillFile = resolve16(skillRoot, "SKILL.md");
|
|
13491
13762
|
const parsed = await readFrontmatterFile(
|
|
@@ -13627,7 +13898,7 @@ async function openVerifiedFile(path, root, label, opener, expected) {
|
|
|
13627
13898
|
const initial = await lstat7(path, { bigint: true });
|
|
13628
13899
|
if (initial.isSymbolicLink()) throw new Error(`${label} symlinks are not allowed`);
|
|
13629
13900
|
assertRegular(initial, label);
|
|
13630
|
-
const canonical3 = await
|
|
13901
|
+
const canonical3 = await realpath9(path);
|
|
13631
13902
|
if (!isWithin3(root, canonical3)) throw new Error(`${label} escapes the skill root`);
|
|
13632
13903
|
const noFollow = typeof constants4.O_NOFOLLOW === "number" ? constants4.O_NOFOLLOW : 0;
|
|
13633
13904
|
const handle = await opener(canonical3, constants4.O_RDONLY | noFollow);
|
|
@@ -13736,11 +14007,97 @@ function score(metadata, query) {
|
|
|
13736
14007
|
}
|
|
13737
14008
|
|
|
13738
14009
|
// src/skills/tool.ts
|
|
13739
|
-
import { z as
|
|
13740
|
-
|
|
13741
|
-
|
|
13742
|
-
|
|
14010
|
+
import { z as z24 } from "zod";
|
|
14011
|
+
|
|
14012
|
+
// src/skills/arguments.ts
|
|
14013
|
+
function expandSkillArguments(body, argumentsText) {
|
|
14014
|
+
const values = splitSkillArguments(argumentsText);
|
|
14015
|
+
const hasPlaceholder = /\$ARGUMENTS(?:\[\d+\])?|\$\d+/.test(body);
|
|
14016
|
+
let expanded = body.replace(/\$ARGUMENTS\[(\d+)\]/g, (_match, index) => values[Number(index)] ?? "");
|
|
14017
|
+
expanded = expanded.replace(/\$(\d+)/g, (_match, index) => values[Number(index)] ?? "");
|
|
14018
|
+
expanded = expanded.replace(/\$ARGUMENTS/g, argumentsText);
|
|
14019
|
+
if (!hasPlaceholder && argumentsText.trim() !== "") {
|
|
14020
|
+
expanded = `${expanded.trimEnd()}
|
|
14021
|
+
|
|
14022
|
+
ARGUMENTS: ${argumentsText}`;
|
|
14023
|
+
}
|
|
14024
|
+
return expanded;
|
|
14025
|
+
}
|
|
14026
|
+
function splitSkillArguments(input) {
|
|
14027
|
+
const result = [];
|
|
14028
|
+
let current = "";
|
|
14029
|
+
let quote;
|
|
14030
|
+
let started = false;
|
|
14031
|
+
for (let index = 0; index < input.length; index += 1) {
|
|
14032
|
+
const character = input[index] ?? "";
|
|
14033
|
+
const next = input[index + 1];
|
|
14034
|
+
if (character === "\\" && quote !== "'" && next !== void 0 && (/\s/u.test(next) || next === "\\" || next === '"' || quote === void 0 && next === "'")) {
|
|
14035
|
+
current += next;
|
|
14036
|
+
index += 1;
|
|
14037
|
+
started = true;
|
|
14038
|
+
continue;
|
|
14039
|
+
}
|
|
14040
|
+
if (quote !== void 0) {
|
|
14041
|
+
if (character === quote) quote = void 0;
|
|
14042
|
+
else current += character;
|
|
14043
|
+
started = true;
|
|
14044
|
+
continue;
|
|
14045
|
+
}
|
|
14046
|
+
if (character === "'" || character === '"') {
|
|
14047
|
+
quote = character;
|
|
14048
|
+
started = true;
|
|
14049
|
+
continue;
|
|
14050
|
+
}
|
|
14051
|
+
if (/\s/u.test(character)) {
|
|
14052
|
+
if (started) {
|
|
14053
|
+
result.push(current);
|
|
14054
|
+
current = "";
|
|
14055
|
+
started = false;
|
|
14056
|
+
}
|
|
14057
|
+
continue;
|
|
14058
|
+
}
|
|
14059
|
+
current += character;
|
|
14060
|
+
started = true;
|
|
14061
|
+
}
|
|
14062
|
+
if (started) result.push(current);
|
|
14063
|
+
return result;
|
|
14064
|
+
}
|
|
14065
|
+
|
|
14066
|
+
// src/skills/tool.ts
|
|
14067
|
+
var SkillInput = z24.object({
|
|
14068
|
+
skill: z24.string().min(1),
|
|
14069
|
+
arguments: z24.string().optional()
|
|
14070
|
+
}).strict();
|
|
14071
|
+
var SkillResourceInput = z24.object({
|
|
14072
|
+
skill: z24.string().min(1),
|
|
14073
|
+
reference: z24.string().min(1)
|
|
13743
14074
|
}).strict();
|
|
14075
|
+
function createSkillTool(registry) {
|
|
14076
|
+
return {
|
|
14077
|
+
name: "Skill",
|
|
14078
|
+
description: "Load another discovered skill by name so composable workflows can follow its complete instructions; optional arguments use Claude-compatible $ARGUMENTS substitution",
|
|
14079
|
+
inputSchema: SkillInput,
|
|
14080
|
+
readOnly: true,
|
|
14081
|
+
paths: () => [],
|
|
14082
|
+
summarize: ({ skill }) => skill,
|
|
14083
|
+
renderForModel: (output) => {
|
|
14084
|
+
const value = output;
|
|
14085
|
+
return `Matched skill: ${value.skill}
|
|
14086
|
+
${value.content}`;
|
|
14087
|
+
},
|
|
14088
|
+
execute: async (input, signal) => {
|
|
14089
|
+
signal.throwIfAborted();
|
|
14090
|
+
const discovered = await registry.discover();
|
|
14091
|
+
const requested = input.skill.trim();
|
|
14092
|
+
const alias = requested.includes(":") ? requested.slice(requested.lastIndexOf(":") + 1) : requested;
|
|
14093
|
+
const skill = discovered.find((candidate) => candidate.name === requested) ?? discovered.find((candidate) => candidate.name === alias);
|
|
14094
|
+
if (skill === void 0) throw new Error(`Unknown skill: ${input.skill}`);
|
|
14095
|
+
const content = expandSkillArguments(await registry.loadBody(skill), input.arguments ?? "");
|
|
14096
|
+
signal.throwIfAborted();
|
|
14097
|
+
return { skill: skill.name, content };
|
|
14098
|
+
}
|
|
14099
|
+
};
|
|
14100
|
+
}
|
|
13744
14101
|
function createSkillResourceTool(registry) {
|
|
13745
14102
|
return {
|
|
13746
14103
|
name: "SkillResource",
|
|
@@ -13766,10 +14123,10 @@ function createSkillResourceTool(registry) {
|
|
|
13766
14123
|
|
|
13767
14124
|
// src/session/store.ts
|
|
13768
14125
|
import { constants as constants5 } from "fs";
|
|
13769
|
-
import { lstat as lstat8, mkdir as mkdir15, open as open7, readFile as readFile15, readdir as readdir7, realpath as
|
|
13770
|
-
import { basename as basename5, dirname as
|
|
14126
|
+
import { lstat as lstat8, mkdir as mkdir15, open as open7, readFile as readFile15, readdir as readdir7, realpath as realpath10, rename as rename6, rm as rm8, stat as stat7 } from "fs/promises";
|
|
14127
|
+
import { basename as basename5, dirname as dirname15, join as join20, relative as relative13, resolve as resolve17, sep as sep12 } from "path";
|
|
13771
14128
|
import { randomUUID as randomUUID9 } from "crypto";
|
|
13772
|
-
import { z as
|
|
14129
|
+
import { z as z25 } from "zod";
|
|
13773
14130
|
|
|
13774
14131
|
// src/ui/transcript.ts
|
|
13775
14132
|
function createTranscriptState() {
|
|
@@ -14302,91 +14659,91 @@ function addText(turn, text, onNewLine = false) {
|
|
|
14302
14659
|
// src/session/store.ts
|
|
14303
14660
|
var SESSION_VERSION = 3;
|
|
14304
14661
|
var DEFAULT_MAX_SESSION_BYTES = 5 * 1024 * 1024;
|
|
14305
|
-
var SessionIdSchema =
|
|
14306
|
-
var IsoDateSchema =
|
|
14307
|
-
var ToolCallSchema =
|
|
14308
|
-
id:
|
|
14309
|
-
name:
|
|
14310
|
-
input:
|
|
14662
|
+
var SessionIdSchema = z25.string().regex(/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/, "Invalid session id");
|
|
14663
|
+
var IsoDateSchema = z25.string().datetime({ offset: true });
|
|
14664
|
+
var ToolCallSchema = z25.object({
|
|
14665
|
+
id: z25.string().min(1).max(256),
|
|
14666
|
+
name: z25.string().min(1).max(256),
|
|
14667
|
+
input: z25.unknown()
|
|
14311
14668
|
}).strict();
|
|
14312
|
-
var TextContentBlockSchema =
|
|
14313
|
-
type:
|
|
14314
|
-
text:
|
|
14669
|
+
var TextContentBlockSchema = z25.object({
|
|
14670
|
+
type: z25.literal("text"),
|
|
14671
|
+
text: z25.string().max(DEFAULT_MAX_SESSION_BYTES)
|
|
14315
14672
|
}).strict();
|
|
14316
|
-
var ImageContentBlockSchema =
|
|
14317
|
-
type:
|
|
14318
|
-
source:
|
|
14319
|
-
mediaType:
|
|
14320
|
-
sha256:
|
|
14321
|
-
bytes:
|
|
14322
|
-
name:
|
|
14673
|
+
var ImageContentBlockSchema = z25.object({
|
|
14674
|
+
type: z25.literal("image"),
|
|
14675
|
+
source: z25.object({ type: z25.literal("file"), path: z25.string().min(1).max(32768) }).strict(),
|
|
14676
|
+
mediaType: z25.enum(["image/png", "image/jpeg", "image/webp"]),
|
|
14677
|
+
sha256: z25.string().regex(/^[a-f0-9]{64}$/),
|
|
14678
|
+
bytes: z25.number().int().positive().max(20 * 1024 * 1024),
|
|
14679
|
+
name: z25.string().min(1).max(255).optional()
|
|
14323
14680
|
}).strict();
|
|
14324
|
-
var UserContentSchema =
|
|
14325
|
-
|
|
14326
|
-
|
|
14681
|
+
var UserContentSchema = z25.union([
|
|
14682
|
+
z25.string().max(DEFAULT_MAX_SESSION_BYTES),
|
|
14683
|
+
z25.array(z25.discriminatedUnion("type", [TextContentBlockSchema, ImageContentBlockSchema])).min(1).max(100)
|
|
14327
14684
|
]);
|
|
14328
14685
|
var MessageMetadataShape = {
|
|
14329
|
-
toolCallId:
|
|
14330
|
-
toolCalls:
|
|
14686
|
+
toolCallId: z25.string().min(1).max(256).optional(),
|
|
14687
|
+
toolCalls: z25.array(ToolCallSchema).max(1e3).optional()
|
|
14331
14688
|
};
|
|
14332
|
-
var MessageSchema =
|
|
14333
|
-
|
|
14334
|
-
|
|
14335
|
-
|
|
14689
|
+
var MessageSchema = z25.discriminatedUnion("role", [
|
|
14690
|
+
z25.object({ role: z25.literal("user"), content: UserContentSchema, ...MessageMetadataShape }).strict(),
|
|
14691
|
+
z25.object({ role: z25.literal("assistant"), content: z25.string().max(DEFAULT_MAX_SESSION_BYTES), ...MessageMetadataShape }).strict(),
|
|
14692
|
+
z25.object({ role: z25.literal("tool"), content: z25.string().max(DEFAULT_MAX_SESSION_BYTES), ...MessageMetadataShape }).strict()
|
|
14336
14693
|
]);
|
|
14337
|
-
var LegacySummarySchema =
|
|
14338
|
-
var CompactBoundarySchema =
|
|
14339
|
-
summary:
|
|
14694
|
+
var LegacySummarySchema = z25.object({ role: z25.literal("system"), content: z25.string().max(DEFAULT_MAX_SESSION_BYTES) }).strict();
|
|
14695
|
+
var CompactBoundarySchema = z25.object({
|
|
14696
|
+
summary: z25.string().min(1).max(DEFAULT_MAX_SESSION_BYTES),
|
|
14340
14697
|
compactedAt: IsoDateSchema
|
|
14341
14698
|
}).strict();
|
|
14342
|
-
var StateSchema =
|
|
14343
|
-
var MemoryLifecycleSchema =
|
|
14344
|
-
status:
|
|
14345
|
-
taskId:
|
|
14346
|
-
messageStart:
|
|
14699
|
+
var StateSchema = z25.enum(["pending", "running", "completed", "failed", "blocked", "cancelled"]);
|
|
14700
|
+
var MemoryLifecycleSchema = z25.object({
|
|
14701
|
+
status: z25.enum(["active", "completed", "abandoned"]),
|
|
14702
|
+
taskId: z25.string().regex(/^memory-[A-Za-z0-9._-]{1,120}$/).optional(),
|
|
14703
|
+
messageStart: z25.number().int().min(0).max(5e4).optional(),
|
|
14347
14704
|
finalizedAt: IsoDateSchema.optional(),
|
|
14348
|
-
transcriptHash:
|
|
14705
|
+
transcriptHash: z25.string().regex(/^[a-f0-9]{64}$/).optional()
|
|
14349
14706
|
}).strict();
|
|
14350
|
-
var SessionBaseSchema =
|
|
14707
|
+
var SessionBaseSchema = z25.object({
|
|
14351
14708
|
sessionId: SessionIdSchema,
|
|
14352
14709
|
createdAt: IsoDateSchema,
|
|
14353
14710
|
updatedAt: IsoDateSchema,
|
|
14354
|
-
workspace:
|
|
14355
|
-
tasks:
|
|
14711
|
+
workspace: z25.object({ path: z25.string().min(1).max(32768) }).strict(),
|
|
14712
|
+
tasks: z25.object({
|
|
14356
14713
|
plan: TaskPlanSchema.optional(),
|
|
14357
14714
|
graph: TaskGraphSchema.optional(),
|
|
14358
|
-
states:
|
|
14359
|
-
results:
|
|
14715
|
+
states: z25.record(z25.string(), StateSchema),
|
|
14716
|
+
results: z25.record(z25.string(), SubagentResultSchema)
|
|
14360
14717
|
}).strict(),
|
|
14361
|
-
models:
|
|
14718
|
+
models: z25.object({ main: z25.string().min(1).max(1024), subagent: z25.string().min(1).max(1024) }).strict(),
|
|
14362
14719
|
permissionMode: PermissionModeSchema,
|
|
14363
14720
|
memory: MemoryLifecycleSchema.optional()
|
|
14364
14721
|
}).strict();
|
|
14365
14722
|
var SessionDocumentV1Schema = SessionBaseSchema.extend({
|
|
14366
|
-
version:
|
|
14367
|
-
conversation:
|
|
14723
|
+
version: z25.literal(1),
|
|
14724
|
+
conversation: z25.object({
|
|
14368
14725
|
summary: LegacySummarySchema.optional(),
|
|
14369
|
-
messages:
|
|
14726
|
+
messages: z25.array(MessageSchema).max(5e4)
|
|
14370
14727
|
}).strict()
|
|
14371
14728
|
}).strict();
|
|
14372
|
-
var ConversationSchema =
|
|
14729
|
+
var ConversationSchema = z25.object({
|
|
14373
14730
|
compact: CompactBoundarySchema.optional(),
|
|
14374
|
-
messages:
|
|
14731
|
+
messages: z25.array(MessageSchema).max(5e4)
|
|
14375
14732
|
}).strict();
|
|
14376
14733
|
var SessionDocumentV2Schema = SessionBaseSchema.extend({
|
|
14377
|
-
version:
|
|
14734
|
+
version: z25.literal(2),
|
|
14378
14735
|
conversation: ConversationSchema
|
|
14379
14736
|
}).strict();
|
|
14380
|
-
var TranscriptStateSchema =
|
|
14381
|
-
var TimelineSchema =
|
|
14382
|
-
version:
|
|
14737
|
+
var TranscriptStateSchema = z25.custom(isTranscriptState, "Invalid transcript state");
|
|
14738
|
+
var TimelineSchema = z25.object({
|
|
14739
|
+
version: z25.literal(1),
|
|
14383
14740
|
state: TranscriptStateSchema
|
|
14384
14741
|
}).strict();
|
|
14385
14742
|
var SessionDocumentSchema = SessionBaseSchema.extend({
|
|
14386
|
-
version:
|
|
14387
|
-
conversation:
|
|
14743
|
+
version: z25.literal(SESSION_VERSION),
|
|
14744
|
+
conversation: z25.object({
|
|
14388
14745
|
compact: CompactBoundarySchema.optional(),
|
|
14389
|
-
messages:
|
|
14746
|
+
messages: z25.array(MessageSchema).max(5e4)
|
|
14390
14747
|
}).strict(),
|
|
14391
14748
|
timeline: TimelineSchema
|
|
14392
14749
|
}).strict();
|
|
@@ -14562,14 +14919,14 @@ var SessionStore = class {
|
|
|
14562
14919
|
}
|
|
14563
14920
|
}
|
|
14564
14921
|
async #prepareDirectory() {
|
|
14565
|
-
await assertNoSymlink3(this.#workspace,
|
|
14922
|
+
await assertNoSymlink3(this.#workspace, dirname15(this.#sessions));
|
|
14566
14923
|
await mkdir15(this.#sessions, { recursive: true, mode: 448 });
|
|
14567
14924
|
await this.#assertSafeExistingDirectory();
|
|
14568
14925
|
}
|
|
14569
14926
|
async #assertSafeExistingDirectory() {
|
|
14570
14927
|
await assertNoSymlink3(this.#workspace, this.#sessions);
|
|
14571
|
-
const canonicalRoot = await
|
|
14572
|
-
const canonicalSessions = await
|
|
14928
|
+
const canonicalRoot = await realpath10(this.#workspace);
|
|
14929
|
+
const canonicalSessions = await realpath10(this.#sessions);
|
|
14573
14930
|
if (!isWithin4(canonicalRoot, canonicalSessions)) throw new Error("Session directory escapes the workspace");
|
|
14574
14931
|
}
|
|
14575
14932
|
async #quarantine(path) {
|
|
@@ -14726,7 +15083,7 @@ async function assertNoSymlink3(root, target) {
|
|
|
14726
15083
|
const chain = [];
|
|
14727
15084
|
while (cursor !== stop) {
|
|
14728
15085
|
chain.push(cursor);
|
|
14729
|
-
cursor =
|
|
15086
|
+
cursor = dirname15(cursor);
|
|
14730
15087
|
}
|
|
14731
15088
|
for (const path of chain.reverse()) {
|
|
14732
15089
|
try {
|
|
@@ -14742,7 +15099,7 @@ function isWithin4(root, path) {
|
|
|
14742
15099
|
}
|
|
14743
15100
|
async function canonical2(path) {
|
|
14744
15101
|
try {
|
|
14745
|
-
return await
|
|
15102
|
+
return await realpath10(resolve17(path));
|
|
14746
15103
|
} catch {
|
|
14747
15104
|
return resolve17(path);
|
|
14748
15105
|
}
|
|
@@ -14771,13 +15128,13 @@ function sanitize2(input, seen = /* @__PURE__ */ new WeakSet()) {
|
|
|
14771
15128
|
// src/session/tree.ts
|
|
14772
15129
|
import { randomUUID as randomUUID11 } from "crypto";
|
|
14773
15130
|
import { mkdir as mkdir17, readFile as readFile17, rename as rename8, writeFile as writeFile11 } from "fs/promises";
|
|
14774
|
-
import { dirname as
|
|
15131
|
+
import { dirname as dirname17, join as join22, resolve as resolve19 } from "path";
|
|
14775
15132
|
|
|
14776
15133
|
// src/session/checkpoint.ts
|
|
14777
15134
|
import { createHash as createHash10, randomUUID as randomUUID10 } from "crypto";
|
|
14778
15135
|
import { execFile as execFile2 } from "child_process";
|
|
14779
15136
|
import { lstat as lstat9, mkdir as mkdir16, open as open8, readFile as readFile16, readdir as readdir8, rename as rename7, rm as rm9, writeFile as writeFile10 } from "fs/promises";
|
|
14780
|
-
import { dirname as
|
|
15137
|
+
import { dirname as dirname16, join as join21, relative as relative14, resolve as resolve18, sep as sep13 } from "path";
|
|
14781
15138
|
var EXCLUDED = /* @__PURE__ */ new Set([".git", ".flavor", "node_modules", "dist", "build", "release", ".worktrees"]);
|
|
14782
15139
|
var MAX_FILE_BYTES = 16 * 1024 * 1024;
|
|
14783
15140
|
var MAX_TOTAL_BYTES = 128 * 1024 * 1024;
|
|
@@ -14863,7 +15220,7 @@ var WorkspaceCheckpointStore = class {
|
|
|
14863
15220
|
for (const file of checkpoint.files) {
|
|
14864
15221
|
const target = contained(this.#workspace, file.path);
|
|
14865
15222
|
const object = objects.get(file.digest);
|
|
14866
|
-
await mkdir16(
|
|
15223
|
+
await mkdir16(dirname16(target), { recursive: true });
|
|
14867
15224
|
const temporary = `${target}.${process.pid}.${randomUUID10()}.tmp`;
|
|
14868
15225
|
await writeFile10(temporary, object, { mode: file.mode });
|
|
14869
15226
|
await rename7(temporary, target);
|
|
@@ -14935,7 +15292,7 @@ function contained(workspace, path) {
|
|
|
14935
15292
|
return absolute;
|
|
14936
15293
|
}
|
|
14937
15294
|
async function atomicJson(path, value) {
|
|
14938
|
-
await mkdir16(
|
|
15295
|
+
await mkdir16(dirname16(path), { recursive: true });
|
|
14939
15296
|
const temporary = `${path}.${process.pid}.${randomUUID10()}.tmp`;
|
|
14940
15297
|
await writeFile10(temporary, `${JSON.stringify(value)}
|
|
14941
15298
|
`, { encoding: "utf8", mode: 384 });
|
|
@@ -15038,7 +15395,7 @@ var SessionHistory = class _SessionHistory {
|
|
|
15038
15395
|
leafId: this.#leafId,
|
|
15039
15396
|
nodes: this.#nodes
|
|
15040
15397
|
};
|
|
15041
|
-
await mkdir17(
|
|
15398
|
+
await mkdir17(dirname17(this.#path), { recursive: true });
|
|
15042
15399
|
const temporary = `${this.#path}.${process.pid}.${randomUUID11()}.tmp`;
|
|
15043
15400
|
await writeFile11(temporary, `${JSON.stringify(document)}
|
|
15044
15401
|
`, { encoding: "utf8", mode: 384 });
|
|
@@ -15066,45 +15423,45 @@ function isCode9(error, code) {
|
|
|
15066
15423
|
// src/sleep/organizer.ts
|
|
15067
15424
|
import { constants as constants6 } from "fs";
|
|
15068
15425
|
import { randomUUID as randomUUID12 } from "crypto";
|
|
15069
|
-
import { lstat as lstat10, mkdir as mkdir18, open as open9, readdir as readdir9, realpath as
|
|
15426
|
+
import { lstat as lstat10, mkdir as mkdir18, open as open9, readdir as readdir9, realpath as realpath11, rename as rename9, rm as rm10 } from "fs/promises";
|
|
15070
15427
|
import { isAbsolute as isAbsolute10, join as join23, relative as relative15, resolve as resolve20, sep as sep14 } from "path";
|
|
15071
|
-
import { z as
|
|
15072
|
-
var DateKeySchema =
|
|
15073
|
-
var ReviewSchema =
|
|
15074
|
-
title:
|
|
15075
|
-
taskSummary:
|
|
15076
|
-
executionReflection:
|
|
15077
|
-
decisionsAndLearnings:
|
|
15078
|
-
openQuestionsAndRisks:
|
|
15079
|
-
tomorrowPlan:
|
|
15080
|
-
toolUsage:
|
|
15081
|
-
totalCalls:
|
|
15082
|
-
shell:
|
|
15083
|
-
fileRead:
|
|
15084
|
-
fileWrite:
|
|
15085
|
-
search:
|
|
15086
|
-
lsp:
|
|
15087
|
-
subagent:
|
|
15088
|
-
other:
|
|
15428
|
+
import { z as z26 } from "zod";
|
|
15429
|
+
var DateKeySchema = z26.string().regex(/^\d{4}-\d{2}-\d{2}$/);
|
|
15430
|
+
var ReviewSchema = z26.object({
|
|
15431
|
+
title: z26.string().min(1).max(120),
|
|
15432
|
+
taskSummary: z26.array(z26.string().min(1)).min(1).max(20),
|
|
15433
|
+
executionReflection: z26.array(z26.string().min(1)).min(1).max(20),
|
|
15434
|
+
decisionsAndLearnings: z26.array(z26.string().min(1)).max(20),
|
|
15435
|
+
openQuestionsAndRisks: z26.array(z26.string().min(1)).max(20),
|
|
15436
|
+
tomorrowPlan: z26.array(z26.string().min(1)).min(1).max(20),
|
|
15437
|
+
toolUsage: z26.object({
|
|
15438
|
+
totalCalls: z26.number().int().min(0),
|
|
15439
|
+
shell: z26.number().int().min(0),
|
|
15440
|
+
fileRead: z26.number().int().min(0),
|
|
15441
|
+
fileWrite: z26.number().int().min(0),
|
|
15442
|
+
search: z26.number().int().min(0),
|
|
15443
|
+
lsp: z26.number().int().min(0),
|
|
15444
|
+
subagent: z26.number().int().min(0),
|
|
15445
|
+
other: z26.number().int().min(0)
|
|
15089
15446
|
}).strict(),
|
|
15090
|
-
tokenEstimate:
|
|
15091
|
-
estimatedInput:
|
|
15092
|
-
estimatedOutput:
|
|
15093
|
-
notes:
|
|
15447
|
+
tokenEstimate: z26.object({
|
|
15448
|
+
estimatedInput: z26.number().int().min(0),
|
|
15449
|
+
estimatedOutput: z26.number().int().min(0),
|
|
15450
|
+
notes: z26.string().max(200)
|
|
15094
15451
|
}).strict(),
|
|
15095
|
-
humanIntervention:
|
|
15096
|
-
approvalRequests:
|
|
15097
|
-
questionsAsked:
|
|
15098
|
-
summary:
|
|
15452
|
+
humanIntervention: z26.object({
|
|
15453
|
+
approvalRequests: z26.number().int().min(0),
|
|
15454
|
+
questionsAsked: z26.number().int().min(0),
|
|
15455
|
+
summary: z26.string().max(300)
|
|
15099
15456
|
}).strict(),
|
|
15100
|
-
qualityIndicators:
|
|
15101
|
-
hallucinationAlerts:
|
|
15102
|
-
failuresAndRetries:
|
|
15103
|
-
codeChangeSummary:
|
|
15104
|
-
overallAssessment:
|
|
15457
|
+
qualityIndicators: z26.object({
|
|
15458
|
+
hallucinationAlerts: z26.array(z26.string().min(1)).max(10),
|
|
15459
|
+
failuresAndRetries: z26.array(z26.string().min(1)).max(10),
|
|
15460
|
+
codeChangeSummary: z26.string().max(500),
|
|
15461
|
+
overallAssessment: z26.string().max(200)
|
|
15105
15462
|
}).strict(),
|
|
15106
|
-
knowledgeDeposits:
|
|
15107
|
-
worthRemembering:
|
|
15463
|
+
knowledgeDeposits: z26.object({
|
|
15464
|
+
worthRemembering: z26.array(z26.string().min(1)).max(10)
|
|
15108
15465
|
}).strict()
|
|
15109
15466
|
}).strict();
|
|
15110
15467
|
function localDateKey(date) {
|
|
@@ -15213,8 +15570,8 @@ Previous output was invalid. Repair it and return strict JSON only.`;
|
|
|
15213
15570
|
await mkdir18(flavorDirectory, { recursive: true, mode: 448 });
|
|
15214
15571
|
await assertNotSymlink(this.#sleepDirectory);
|
|
15215
15572
|
await mkdir18(this.#sleepDirectory, { recursive: true, mode: 448 });
|
|
15216
|
-
const root = await
|
|
15217
|
-
const target = await
|
|
15573
|
+
const root = await realpath11(this.#workspace);
|
|
15574
|
+
const target = await realpath11(this.#sleepDirectory);
|
|
15218
15575
|
if (!isWithin5(root, target)) throw new Error("Sleep directory escapes the workspace");
|
|
15219
15576
|
}
|
|
15220
15577
|
async #hasReport(date) {
|
|
@@ -15596,10 +15953,10 @@ function computeSessionStats(documents) {
|
|
|
15596
15953
|
|
|
15597
15954
|
// src/tools/files.ts
|
|
15598
15955
|
import { constants as constants7 } from "fs";
|
|
15599
|
-
import { mkdir as mkdir19, open as open10, readFile as readFile18, realpath as
|
|
15600
|
-
import { dirname as
|
|
15956
|
+
import { mkdir as mkdir19, open as open10, readFile as readFile18, realpath as realpath12, rename as rename10, rm as rm11, stat as stat8 } from "fs/promises";
|
|
15957
|
+
import { dirname as dirname18, isAbsolute as isAbsolute11, relative as relative16, resolve as resolve21, sep as sep15 } from "path";
|
|
15601
15958
|
import { randomUUID as randomUUID13 } from "crypto";
|
|
15602
|
-
import { z as
|
|
15959
|
+
import { z as z27 } from "zod";
|
|
15603
15960
|
|
|
15604
15961
|
// src/tools/file-diff.ts
|
|
15605
15962
|
var MAX_DIFF_PREVIEW_LINES = 120;
|
|
@@ -15705,18 +16062,18 @@ function truncateLines(lines) {
|
|
|
15705
16062
|
|
|
15706
16063
|
// src/tools/files.ts
|
|
15707
16064
|
var MAX_READ_BYTES = 1048576;
|
|
15708
|
-
var ReadInput2 =
|
|
15709
|
-
path:
|
|
15710
|
-
maxBytes:
|
|
15711
|
-
startLine:
|
|
15712
|
-
endLine:
|
|
16065
|
+
var ReadInput2 = z27.object({
|
|
16066
|
+
path: z27.string().min(1),
|
|
16067
|
+
maxBytes: z27.coerce.number().int().positive().max(MAX_READ_BYTES).nullable().optional(),
|
|
16068
|
+
startLine: z27.coerce.number().int().positive().nullable().optional(),
|
|
16069
|
+
endLine: z27.coerce.number().int().positive().nullable().optional(),
|
|
15713
16070
|
// Accepts booleans and their string forms (weak-typed models emit "true");
|
|
15714
16071
|
// kept transform-free so the schema converts to JSON Schema for providers.
|
|
15715
|
-
force:
|
|
16072
|
+
force: z27.union([z27.boolean(), z27.string().refine((value) => value === "true" || value === "false")]).nullable().optional()
|
|
15716
16073
|
});
|
|
15717
|
-
var WriteInput =
|
|
15718
|
-
var EditInput =
|
|
15719
|
-
var ApplyPatchInput =
|
|
16074
|
+
var WriteInput = z27.object({ path: z27.string().min(1), content: z27.string() });
|
|
16075
|
+
var EditInput = z27.object({ path: z27.string().min(1), oldText: z27.string().min(1), newText: z27.string() });
|
|
16076
|
+
var ApplyPatchInput = z27.object({ patch: z27.string().min(1) });
|
|
15720
16077
|
var FileObservationStore = class {
|
|
15721
16078
|
#versions = /* @__PURE__ */ new Map();
|
|
15722
16079
|
get(path) {
|
|
@@ -15924,22 +16281,22 @@ function createPathGuard(workspace) {
|
|
|
15924
16281
|
lexical,
|
|
15925
16282
|
existing: async (input) => {
|
|
15926
16283
|
const candidate = lexical(input);
|
|
15927
|
-
const physical = await
|
|
15928
|
-
if (!within2(await
|
|
16284
|
+
const physical = await realpath12(candidate);
|
|
16285
|
+
if (!within2(await realpath12(root), physical)) throw new Error("Path escapes the workspace through a symlink");
|
|
15929
16286
|
return physical;
|
|
15930
16287
|
},
|
|
15931
16288
|
destination: async (input) => {
|
|
15932
16289
|
const candidate = lexical(input);
|
|
15933
|
-
const physicalRoot = await
|
|
16290
|
+
const physicalRoot = await realpath12(root);
|
|
15934
16291
|
let ancestor = candidate;
|
|
15935
16292
|
while (true) {
|
|
15936
16293
|
try {
|
|
15937
|
-
const physical = await
|
|
16294
|
+
const physical = await realpath12(ancestor);
|
|
15938
16295
|
if (!within2(physicalRoot, physical)) throw new Error("Path escapes the workspace through a symlink");
|
|
15939
16296
|
break;
|
|
15940
16297
|
} catch (error) {
|
|
15941
16298
|
if (!isMissing2(error)) throw error;
|
|
15942
|
-
const parent =
|
|
16299
|
+
const parent = dirname18(ancestor);
|
|
15943
16300
|
if (parent === ancestor) throw error;
|
|
15944
16301
|
ancestor = parent;
|
|
15945
16302
|
}
|
|
@@ -15950,7 +16307,7 @@ function createPathGuard(workspace) {
|
|
|
15950
16307
|
}
|
|
15951
16308
|
async function atomicWrite(path, content, signal, expectedVersion) {
|
|
15952
16309
|
abortIfNeeded(signal);
|
|
15953
|
-
await mkdir19(
|
|
16310
|
+
await mkdir19(dirname18(path), { recursive: true });
|
|
15954
16311
|
const temporary = `${path}.${randomUUID13()}.tmp`;
|
|
15955
16312
|
try {
|
|
15956
16313
|
const handle = await open10(temporary, constants7.O_CREAT | constants7.O_EXCL | constants7.O_WRONLY, 384);
|
|
@@ -16310,10 +16667,10 @@ function matchesLines(source, start, expected) {
|
|
|
16310
16667
|
// src/tools/search.ts
|
|
16311
16668
|
import { spawn as spawn4 } from "child_process";
|
|
16312
16669
|
import { open as open11, opendir, stat as stat9 } from "fs/promises";
|
|
16313
|
-
import { dirname as
|
|
16670
|
+
import { dirname as dirname19, isAbsolute as isAbsolute12, relative as relative17, resolve as resolve22, sep as sep16 } from "path";
|
|
16314
16671
|
import { rgPath as bundledRgPath } from "@vscode/ripgrep";
|
|
16315
16672
|
import createIgnore from "ignore";
|
|
16316
|
-
import { z as
|
|
16673
|
+
import { z as z28 } from "zod";
|
|
16317
16674
|
var DEFAULT_RESULT_LIMIT = 1e3;
|
|
16318
16675
|
var DEFAULT_MAX_FILE_BYTES = 1048576;
|
|
16319
16676
|
var DEFAULT_MAX_SEARCH_BYTES = 16777216;
|
|
@@ -16387,18 +16744,18 @@ var FILE_TYPE_EXTENSIONS = {
|
|
|
16387
16744
|
python: [".py", ".pyi"],
|
|
16388
16745
|
typescript: [".ts", ".tsx", ".mts", ".cts"]
|
|
16389
16746
|
};
|
|
16390
|
-
var GlobInput =
|
|
16391
|
-
pattern:
|
|
16392
|
-
path:
|
|
16393
|
-
limit:
|
|
16747
|
+
var GlobInput = z28.object({
|
|
16748
|
+
pattern: z28.string().min(1),
|
|
16749
|
+
path: z28.string().min(1).describe('Workspace-relative search directory. Use JSON null, not the string "null", for the workspace root.').nullable().optional(),
|
|
16750
|
+
limit: z28.coerce.number().int().positive().max(1e5).nullable().optional()
|
|
16394
16751
|
});
|
|
16395
|
-
var GrepInput =
|
|
16396
|
-
pattern:
|
|
16397
|
-
path:
|
|
16398
|
-
glob:
|
|
16399
|
-
fileType:
|
|
16400
|
-
context:
|
|
16401
|
-
limit:
|
|
16752
|
+
var GrepInput = z28.object({
|
|
16753
|
+
pattern: z28.string().min(1),
|
|
16754
|
+
path: z28.string().min(1).describe('Workspace-relative search path. Use JSON null, not the string "null", for the workspace root.').nullable().optional(),
|
|
16755
|
+
glob: z28.string().min(1).nullable().optional(),
|
|
16756
|
+
fileType: z28.enum(FILE_TYPES).nullable().optional(),
|
|
16757
|
+
context: z28.coerce.number().int().nonnegative().max(100).nullable().optional(),
|
|
16758
|
+
limit: z28.coerce.number().int().positive().max(1e5).nullable().optional()
|
|
16402
16759
|
});
|
|
16403
16760
|
function createGlobTool(workspace, options = {}) {
|
|
16404
16761
|
const root = resolve22(workspace);
|
|
@@ -16782,7 +17139,7 @@ async function resolveGrepPath(root, path = ".") {
|
|
|
16782
17139
|
const candidate = scope(root, path);
|
|
16783
17140
|
try {
|
|
16784
17141
|
const info = await stat9(candidate);
|
|
16785
|
-
if (info.isFile()) return
|
|
17142
|
+
if (info.isFile()) return dirname19(candidate);
|
|
16786
17143
|
} catch {
|
|
16787
17144
|
}
|
|
16788
17145
|
return candidate;
|
|
@@ -16977,22 +17334,22 @@ import { lookup } from "dns/promises";
|
|
|
16977
17334
|
import { isIP } from "net";
|
|
16978
17335
|
import { request as httpRequest } from "http";
|
|
16979
17336
|
import { request as httpsRequest } from "https";
|
|
16980
|
-
import { z as
|
|
16981
|
-
var WebFetchInput =
|
|
16982
|
-
url:
|
|
16983
|
-
timeoutMs:
|
|
16984
|
-
maxBytes:
|
|
17337
|
+
import { z as z29 } from "zod";
|
|
17338
|
+
var WebFetchInput = z29.object({
|
|
17339
|
+
url: z29.string().url().max(8192),
|
|
17340
|
+
timeoutMs: z29.coerce.number().int().positive().max(12e4).optional(),
|
|
17341
|
+
maxBytes: z29.coerce.number().int().positive().max(10 * 1024 * 1024).optional()
|
|
16985
17342
|
});
|
|
16986
|
-
var WebSearchInput =
|
|
16987
|
-
query:
|
|
16988
|
-
maxResults:
|
|
17343
|
+
var WebSearchInput = z29.object({
|
|
17344
|
+
query: z29.string().trim().min(1).max(1e3),
|
|
17345
|
+
maxResults: z29.coerce.number().int().min(1).max(20).optional()
|
|
16989
17346
|
});
|
|
16990
17347
|
function createWebFetchTool() {
|
|
16991
17348
|
return {
|
|
16992
17349
|
name: "WebFetch",
|
|
16993
17350
|
description: "Fetch a public HTTP(S) page with SSRF protection and return readable text",
|
|
16994
17351
|
inputSchema: WebFetchInput,
|
|
16995
|
-
outputSchema:
|
|
17352
|
+
outputSchema: z29.object({ url: z29.string(), status: z29.number(), contentType: z29.string(), content: z29.string(), truncated: z29.boolean() }),
|
|
16996
17353
|
paths: () => [],
|
|
16997
17354
|
summarize: (input) => input.url,
|
|
16998
17355
|
presentCall: (input) => ({ kind: "web", title: `Fetching ${new URL(input.url).hostname}`, url: input.url }),
|
|
@@ -17018,7 +17375,7 @@ function createWebSearchTool(provider = createDefaultWebSearchProvider()) {
|
|
|
17018
17375
|
name: "WebSearch",
|
|
17019
17376
|
description: "Search the public web and return titles, URLs, and snippets",
|
|
17020
17377
|
inputSchema: WebSearchInput,
|
|
17021
|
-
outputSchema:
|
|
17378
|
+
outputSchema: z29.object({ query: z29.string(), results: z29.array(z29.object({ title: z29.string(), url: z29.string(), snippet: z29.string() })) }),
|
|
17022
17379
|
paths: () => [],
|
|
17023
17380
|
summarize: (input) => input.query,
|
|
17024
17381
|
presentCall: (input) => ({ kind: "web", title: `Searching: ${input.query}` }),
|
|
@@ -17284,9 +17641,9 @@ function charset(contentType) {
|
|
|
17284
17641
|
import { spawn as spawn5 } from "child_process";
|
|
17285
17642
|
import { existsSync as existsSync2 } from "fs";
|
|
17286
17643
|
import { access as access2, constants as constants8, readFile as readFile19 } from "fs/promises";
|
|
17287
|
-
import { basename as basename6, dirname as
|
|
17644
|
+
import { basename as basename6, dirname as dirname20, extname as extname2, isAbsolute as isAbsolute13, relative as relative18, resolve as resolve23, sep as sep17 } from "path";
|
|
17288
17645
|
import { fileURLToPath as fileURLToPath3, pathToFileURL as pathToFileURL3 } from "url";
|
|
17289
|
-
import { z as
|
|
17646
|
+
import { z as z30 } from "zod";
|
|
17290
17647
|
var LSP_REQUEST_TIMEOUT_MS = 15e3;
|
|
17291
17648
|
var LspConnection = class {
|
|
17292
17649
|
#process;
|
|
@@ -17501,7 +17858,7 @@ var LspBuffer = class {
|
|
|
17501
17858
|
}
|
|
17502
17859
|
};
|
|
17503
17860
|
var TYPESCRIPT_CLI = resolve23(
|
|
17504
|
-
|
|
17861
|
+
dirname20(fileURLToPath3(import.meta.resolve("typescript/package.json"))),
|
|
17505
17862
|
"lib",
|
|
17506
17863
|
"tsc.js"
|
|
17507
17864
|
);
|
|
@@ -17620,18 +17977,18 @@ var RealLspManager = class {
|
|
|
17620
17977
|
return connection;
|
|
17621
17978
|
}
|
|
17622
17979
|
};
|
|
17623
|
-
var LspFindRefsInput =
|
|
17624
|
-
file:
|
|
17625
|
-
line:
|
|
17626
|
-
character:
|
|
17980
|
+
var LspFindRefsInput = z30.object({
|
|
17981
|
+
file: z30.string().min(1),
|
|
17982
|
+
line: z30.coerce.number().int().nonnegative(),
|
|
17983
|
+
character: z30.coerce.number().int().nonnegative()
|
|
17627
17984
|
});
|
|
17628
|
-
var LspHoverInput =
|
|
17629
|
-
file:
|
|
17630
|
-
line:
|
|
17631
|
-
character:
|
|
17985
|
+
var LspHoverInput = z30.object({
|
|
17986
|
+
file: z30.string().min(1),
|
|
17987
|
+
line: z30.coerce.number().int().nonnegative(),
|
|
17988
|
+
character: z30.coerce.number().int().nonnegative()
|
|
17632
17989
|
});
|
|
17633
|
-
var LspDiagnosticsInput =
|
|
17634
|
-
file:
|
|
17990
|
+
var LspDiagnosticsInput = z30.object({
|
|
17991
|
+
file: z30.string().min(1)
|
|
17635
17992
|
});
|
|
17636
17993
|
function createLspTools(workspace, options = {}) {
|
|
17637
17994
|
const root = resolve23(workspace);
|
|
@@ -17857,7 +18214,7 @@ async function gitMarker(workspace) {
|
|
|
17857
18214
|
}
|
|
17858
18215
|
|
|
17859
18216
|
// src/git/insights.ts
|
|
17860
|
-
import { z as
|
|
18217
|
+
import { z as z31 } from "zod";
|
|
17861
18218
|
async function suggestCommitMessage(options, input, signal) {
|
|
17862
18219
|
const prompt = [
|
|
17863
18220
|
"Write a git commit message for the staged changes below.",
|
|
@@ -17896,17 +18253,17 @@ function cleanCommitMessage(raw) {
|
|
|
17896
18253
|
}
|
|
17897
18254
|
return kept.join("\n").trim().slice(0, 2e3);
|
|
17898
18255
|
}
|
|
17899
|
-
var ReviewFindingSchema =
|
|
17900
|
-
severity:
|
|
17901
|
-
file:
|
|
17902
|
-
line:
|
|
17903
|
-
issue:
|
|
17904
|
-
suggestion:
|
|
18256
|
+
var ReviewFindingSchema = z31.object({
|
|
18257
|
+
severity: z31.enum(["critical", "warning", "nit"]),
|
|
18258
|
+
file: z31.string(),
|
|
18259
|
+
line: z31.string().describe('Line number or hunk header the finding refers to, e.g. "42" or "@@ -10,4 +10,6 @@"'),
|
|
18260
|
+
issue: z31.string(),
|
|
18261
|
+
suggestion: z31.string()
|
|
17905
18262
|
}).strict();
|
|
17906
|
-
var ReviewReportSchema =
|
|
17907
|
-
summary:
|
|
17908
|
-
verdict:
|
|
17909
|
-
findings:
|
|
18263
|
+
var ReviewReportSchema = z31.object({
|
|
18264
|
+
summary: z31.string().describe("One-paragraph overall assessment of the change"),
|
|
18265
|
+
verdict: z31.enum(["ship", "ship-with-fixes", "needs-work"]),
|
|
18266
|
+
findings: z31.array(ReviewFindingSchema).max(20)
|
|
17910
18267
|
}).strict();
|
|
17911
18268
|
async function reviewDiff(options, input, signal) {
|
|
17912
18269
|
const prompt = [
|
|
@@ -17950,10 +18307,10 @@ function formatReviewReport(report) {
|
|
|
17950
18307
|
}
|
|
17951
18308
|
|
|
17952
18309
|
// src/git/tools.ts
|
|
17953
|
-
import { z as
|
|
17954
|
-
var GitHistoryInput =
|
|
17955
|
-
path:
|
|
17956
|
-
limit:
|
|
18310
|
+
import { z as z32 } from "zod";
|
|
18311
|
+
var GitHistoryInput = z32.object({
|
|
18312
|
+
path: z32.string().describe("File to inspect; omit for the whole repository history").optional(),
|
|
18313
|
+
limit: z32.number().int().min(1).max(50).describe("Maximum number of commits to return (default 20)").optional()
|
|
17957
18314
|
});
|
|
17958
18315
|
function createGitHistoryTool(workspace) {
|
|
17959
18316
|
return {
|
|
@@ -17982,18 +18339,18 @@ function createGitHistoryTool(workspace) {
|
|
|
17982
18339
|
}
|
|
17983
18340
|
|
|
17984
18341
|
// src/tools/ask-user-question.ts
|
|
17985
|
-
import { z as
|
|
17986
|
-
var QuestionOptionSchema =
|
|
17987
|
-
label:
|
|
17988
|
-
description:
|
|
18342
|
+
import { z as z33 } from "zod";
|
|
18343
|
+
var QuestionOptionSchema = z33.object({
|
|
18344
|
+
label: z33.string().trim().min(1),
|
|
18345
|
+
description: z33.string().trim().min(1)
|
|
17989
18346
|
});
|
|
17990
|
-
var QuestionSchema =
|
|
17991
|
-
question:
|
|
17992
|
-
header:
|
|
17993
|
-
options:
|
|
18347
|
+
var QuestionSchema = z33.object({
|
|
18348
|
+
question: z33.string().trim().min(1),
|
|
18349
|
+
header: z33.string().trim().min(1),
|
|
18350
|
+
options: z33.array(QuestionOptionSchema).min(1).max(4)
|
|
17994
18351
|
});
|
|
17995
|
-
var AskUserQuestionInput =
|
|
17996
|
-
questions:
|
|
18352
|
+
var AskUserQuestionInput = z33.object({
|
|
18353
|
+
questions: z33.array(QuestionSchema).min(1).max(4)
|
|
17997
18354
|
});
|
|
17998
18355
|
function hookAnswersFromUpdatedInput(updatedInput, questions) {
|
|
17999
18356
|
if (typeof updatedInput !== "object" || updatedInput === null) return void 0;
|
|
@@ -18077,20 +18434,20 @@ function createAskUserQuestionTool(handler) {
|
|
|
18077
18434
|
}
|
|
18078
18435
|
|
|
18079
18436
|
// src/tools/todo-write.ts
|
|
18080
|
-
import { z as
|
|
18081
|
-
var TodoStatusSchema =
|
|
18437
|
+
import { z as z34 } from "zod";
|
|
18438
|
+
var TodoStatusSchema = z34.enum([
|
|
18082
18439
|
"pending",
|
|
18083
18440
|
"in_progress",
|
|
18084
18441
|
"completed",
|
|
18085
18442
|
"cancelled"
|
|
18086
18443
|
]);
|
|
18087
|
-
var TodoItemSchema =
|
|
18088
|
-
content:
|
|
18444
|
+
var TodoItemSchema = z34.object({
|
|
18445
|
+
content: z34.string().trim().min(1),
|
|
18089
18446
|
status: TodoStatusSchema,
|
|
18090
|
-
activeForm:
|
|
18447
|
+
activeForm: z34.string().trim().min(1)
|
|
18091
18448
|
});
|
|
18092
|
-
var TodoWriteInput =
|
|
18093
|
-
todos:
|
|
18449
|
+
var TodoWriteInput = z34.object({
|
|
18450
|
+
todos: z34.array(TodoItemSchema).min(1).max(50)
|
|
18094
18451
|
});
|
|
18095
18452
|
function createTodoWriteTool() {
|
|
18096
18453
|
return {
|
|
@@ -18126,37 +18483,37 @@ function createTodoWriteTool() {
|
|
|
18126
18483
|
// src/tools/managed.ts
|
|
18127
18484
|
import { randomUUID as randomUUID14 } from "crypto";
|
|
18128
18485
|
import { link, lstat as lstat11, mkdir as mkdir20, readFile as readFile20, readdir as readdir10, unlink as unlink2, writeFile as writeFile12 } from "fs/promises";
|
|
18129
|
-
import { dirname as
|
|
18130
|
-
import { z as
|
|
18486
|
+
import { dirname as dirname21, join as join24, resolve as resolve24 } from "path";
|
|
18487
|
+
import { z as z35 } from "zod";
|
|
18131
18488
|
var MANAGED_TOOL_VERSION = 1;
|
|
18132
18489
|
var MAX_RECORD_BYTES = 256 * 1024;
|
|
18133
18490
|
var TOOL_NAME = /^[A-Za-z][A-Za-z0-9_]{0,63}$/;
|
|
18134
|
-
var JsonSchemaObject =
|
|
18491
|
+
var JsonSchemaObject = z35.record(z35.string(), z35.unknown()).superRefine((schema, context) => {
|
|
18135
18492
|
if (schema.type !== "object") {
|
|
18136
18493
|
context.addIssue({ code: "custom", message: "Tool input JSON Schema must have type object" });
|
|
18137
18494
|
}
|
|
18138
18495
|
});
|
|
18139
|
-
var RegisterManagedToolInputSchema =
|
|
18140
|
-
name:
|
|
18141
|
-
description:
|
|
18496
|
+
var RegisterManagedToolInputSchema = z35.object({
|
|
18497
|
+
name: z35.string().regex(TOOL_NAME).describe("Unique callable tool name using letters, digits, and underscores"),
|
|
18498
|
+
description: z35.string().min(1).max(4096).describe("Purpose and appropriate use of the generated tool"),
|
|
18142
18499
|
inputSchema: JsonSchemaObject.describe("Provider-facing JSON Schema with an object at the root"),
|
|
18143
|
-
implementation:
|
|
18500
|
+
implementation: z35.string().min(1).max(64 * 1024).describe(
|
|
18144
18501
|
"Async JavaScript function body, or complete function/arrow expression, receiving input, signal, and context; return the tool result"
|
|
18145
18502
|
),
|
|
18146
|
-
scope:
|
|
18503
|
+
scope: z35.enum(["project", "global"]).default("project").describe(
|
|
18147
18504
|
"Project persists in the current workspace; global persists for every workspace"
|
|
18148
18505
|
),
|
|
18149
|
-
agents:
|
|
18506
|
+
agents: z35.array(z35.enum(["main", "subagent"])).min(1).max(2).optional().describe(
|
|
18150
18507
|
"Agent roles allowed to call the generated tool; omit to allow both"
|
|
18151
18508
|
)
|
|
18152
18509
|
}).strict();
|
|
18153
|
-
var RemoveManagedToolInputSchema =
|
|
18154
|
-
name:
|
|
18155
|
-
scope:
|
|
18510
|
+
var RemoveManagedToolInputSchema = z35.object({
|
|
18511
|
+
name: z35.string().regex(TOOL_NAME).describe("Managed tool name to remove"),
|
|
18512
|
+
scope: z35.enum(["project", "global"]).optional().describe("Required only when the same name exists in both scopes")
|
|
18156
18513
|
}).strict();
|
|
18157
18514
|
var ManagedToolRecordSchema = RegisterManagedToolInputSchema.extend({
|
|
18158
|
-
version:
|
|
18159
|
-
createdAt:
|
|
18515
|
+
version: z35.literal(MANAGED_TOOL_VERSION),
|
|
18516
|
+
createdAt: z35.string().datetime()
|
|
18160
18517
|
}).strict();
|
|
18161
18518
|
var AsyncFunction = Object.getPrototypeOf(async function() {
|
|
18162
18519
|
}).constructor;
|
|
@@ -18343,7 +18700,7 @@ function createManagedToolManagementTools(options) {
|
|
|
18343
18700
|
const listTools = {
|
|
18344
18701
|
name: "ListRegisteredTools",
|
|
18345
18702
|
description: "List durable tools created through RegisterTool, including scope, path, and active precedence",
|
|
18346
|
-
inputSchema:
|
|
18703
|
+
inputSchema: z35.object({}).strict(),
|
|
18347
18704
|
agents: mainOnly,
|
|
18348
18705
|
paths: () => [],
|
|
18349
18706
|
execute: async (_input, signal) => {
|
|
@@ -18356,7 +18713,7 @@ function createManagedToolManagementTools(options) {
|
|
|
18356
18713
|
function compileDefinition(record3, scope2, workspace) {
|
|
18357
18714
|
let inputSchema;
|
|
18358
18715
|
try {
|
|
18359
|
-
inputSchema =
|
|
18716
|
+
inputSchema = z35.fromJSONSchema(record3.inputSchema);
|
|
18360
18717
|
} catch (error) {
|
|
18361
18718
|
throw new Error(`Invalid input schema for managed tool "${record3.name}": ${message(error)}`);
|
|
18362
18719
|
}
|
|
@@ -18410,7 +18767,7 @@ ${sourceUrl}`
|
|
|
18410
18767
|
}
|
|
18411
18768
|
}
|
|
18412
18769
|
async function writeExclusive(path, content) {
|
|
18413
|
-
await mkdir20(
|
|
18770
|
+
await mkdir20(dirname21(path), { recursive: true });
|
|
18414
18771
|
const temporary = `${path}.${randomUUID14()}.tmp`;
|
|
18415
18772
|
try {
|
|
18416
18773
|
await writeFile12(temporary, content, { encoding: "utf8", flag: "wx", mode: 384 });
|
|
@@ -18456,7 +18813,7 @@ function isMissing4(error) {
|
|
|
18456
18813
|
}
|
|
18457
18814
|
|
|
18458
18815
|
// src/pals/protocol.ts
|
|
18459
|
-
import { z as
|
|
18816
|
+
import { z as z36 } from "zod";
|
|
18460
18817
|
var PROTOCOL_VERSION = 1;
|
|
18461
18818
|
var MAX_ALIAS_LENGTH = 64;
|
|
18462
18819
|
var MAX_MESSAGE_BYTES = 32 * 1024;
|
|
@@ -18473,65 +18830,65 @@ var MIN_UUID_PREFIX_LENGTH = 8;
|
|
|
18473
18830
|
function normalizePalIdentity(value) {
|
|
18474
18831
|
return value.trim().toLocaleLowerCase("en-US");
|
|
18475
18832
|
}
|
|
18476
|
-
var VersionSchema =
|
|
18477
|
-
var UuidSchema =
|
|
18478
|
-
var PrintableIdentitySchema =
|
|
18833
|
+
var VersionSchema = z36.literal(PROTOCOL_VERSION);
|
|
18834
|
+
var UuidSchema = z36.uuid();
|
|
18835
|
+
var PrintableIdentitySchema = z36.string().trim().min(1).max(MAX_ALIAS_LENGTH).refine(
|
|
18479
18836
|
(value) => !/[\p{Cc}\uD800-\uDFFF]/u.test(value),
|
|
18480
18837
|
"Identity must contain only printable non-control Unicode"
|
|
18481
18838
|
);
|
|
18482
18839
|
var PalAliasSchema = PrintableIdentitySchema;
|
|
18483
18840
|
var PalTargetSchema = PrintableIdentitySchema;
|
|
18484
|
-
var BoundedTextSchema =
|
|
18841
|
+
var BoundedTextSchema = z36.string().refine(
|
|
18485
18842
|
(value) => Buffer.byteLength(value, "utf8") <= MAX_MESSAGE_BYTES,
|
|
18486
18843
|
`Text must not exceed ${MAX_MESSAGE_BYTES} UTF-8 bytes`
|
|
18487
18844
|
);
|
|
18488
18845
|
var NonEmptyBoundedTextSchema = BoundedTextSchema.refine((value) => value.length > 0, "Text must not be empty");
|
|
18489
|
-
var CompletionDetailSchema =
|
|
18846
|
+
var CompletionDetailSchema = z36.string().trim().min(1).refine(
|
|
18490
18847
|
(value) => Buffer.byteLength(value, "utf8") <= MAX_COMPLETION_DETAIL_BYTES,
|
|
18491
18848
|
`Completion evidence must not exceed ${MAX_COMPLETION_DETAIL_BYTES} UTF-8 bytes`
|
|
18492
18849
|
);
|
|
18493
|
-
var PalPresenceSchema =
|
|
18850
|
+
var PalPresenceSchema = z36.object({
|
|
18494
18851
|
version: VersionSchema,
|
|
18495
18852
|
id: UuidSchema,
|
|
18496
18853
|
alias: PalAliasSchema,
|
|
18497
|
-
projectPath:
|
|
18854
|
+
projectPath: z36.string().min(1).refine(
|
|
18498
18855
|
(value) => Buffer.byteLength(value, "utf8") <= MAX_PROJECT_PATH_BYTES,
|
|
18499
18856
|
`Project path must not exceed ${MAX_PROJECT_PATH_BYTES} UTF-8 bytes`
|
|
18500
18857
|
),
|
|
18501
|
-
connectedAt:
|
|
18502
|
-
lastSeenAt:
|
|
18858
|
+
connectedAt: z36.iso.datetime(),
|
|
18859
|
+
lastSeenAt: z36.iso.datetime()
|
|
18503
18860
|
}).strict();
|
|
18504
|
-
var PalPresenceListSchema =
|
|
18505
|
-
var PalTaskMessageSchema =
|
|
18861
|
+
var PalPresenceListSchema = z36.array(PalPresenceSchema).max(MAX_ACTIVE_PALS);
|
|
18862
|
+
var PalTaskMessageSchema = z36.object({
|
|
18506
18863
|
version: VersionSchema,
|
|
18507
|
-
type:
|
|
18864
|
+
type: z36.literal("task"),
|
|
18508
18865
|
messageId: UuidSchema,
|
|
18509
18866
|
target: PalTargetSchema,
|
|
18510
18867
|
goal: NonEmptyBoundedTextSchema
|
|
18511
18868
|
}).strict();
|
|
18512
|
-
var PalTaskEventSchema =
|
|
18869
|
+
var PalTaskEventSchema = z36.object({
|
|
18513
18870
|
version: VersionSchema,
|
|
18514
|
-
type:
|
|
18871
|
+
type: z36.literal("task-event"),
|
|
18515
18872
|
messageId: UuidSchema,
|
|
18516
18873
|
taskId: UuidSchema,
|
|
18517
18874
|
senderId: UuidSchema,
|
|
18518
18875
|
recipientId: UuidSchema,
|
|
18519
|
-
status:
|
|
18876
|
+
status: z36.enum(["accepted", "started", "progress", "completed", "failed", "cancelled"]),
|
|
18520
18877
|
detail: BoundedTextSchema.optional()
|
|
18521
18878
|
}).strict();
|
|
18522
|
-
var DeliveryReceiptSchema =
|
|
18879
|
+
var DeliveryReceiptSchema = z36.object({
|
|
18523
18880
|
version: VersionSchema,
|
|
18524
|
-
type:
|
|
18881
|
+
type: z36.literal("delivery-receipt"),
|
|
18525
18882
|
messageId: UuidSchema,
|
|
18526
|
-
status:
|
|
18527
|
-
recipientIds:
|
|
18883
|
+
status: z36.enum(["delivered", "duplicate", "rejected"]),
|
|
18884
|
+
recipientIds: z36.array(UuidSchema).max(MAX_PARTICIPANTS),
|
|
18528
18885
|
error: BoundedTextSchema.optional()
|
|
18529
18886
|
}).strict();
|
|
18530
|
-
var CoWorkParticipantSchema =
|
|
18887
|
+
var CoWorkParticipantSchema = z36.object({
|
|
18531
18888
|
palId: UuidSchema,
|
|
18532
|
-
required:
|
|
18889
|
+
required: z36.boolean()
|
|
18533
18890
|
}).strict();
|
|
18534
|
-
var CoWorkProposalParticipantsSchema =
|
|
18891
|
+
var CoWorkProposalParticipantsSchema = z36.array(CoWorkParticipantSchema).min(2).max(MAX_PARTICIPANTS).superRefine((participants, context) => {
|
|
18535
18892
|
const seen = /* @__PURE__ */ new Set();
|
|
18536
18893
|
for (const [index, participant] of participants.entries()) {
|
|
18537
18894
|
const id = participant.palId.toLowerCase();
|
|
@@ -18541,19 +18898,19 @@ var CoWorkProposalParticipantsSchema = z35.array(CoWorkParticipantSchema).min(2)
|
|
|
18541
18898
|
seen.add(id);
|
|
18542
18899
|
}
|
|
18543
18900
|
});
|
|
18544
|
-
var CoWorkPlanTaskSchema =
|
|
18545
|
-
id:
|
|
18901
|
+
var CoWorkPlanTaskSchema = z36.object({
|
|
18902
|
+
id: z36.string().min(1).max(128),
|
|
18546
18903
|
assigneeId: UuidSchema,
|
|
18547
18904
|
description: NonEmptyBoundedTextSchema,
|
|
18548
|
-
dependsOn:
|
|
18905
|
+
dependsOn: z36.array(z36.string().min(1).max(128)).max(MAX_PLAN_TASKS)
|
|
18549
18906
|
}).strict();
|
|
18550
|
-
var CoWorkPlanSchema =
|
|
18907
|
+
var CoWorkPlanSchema = z36.object({
|
|
18551
18908
|
version: VersionSchema,
|
|
18552
18909
|
coWorkId: UuidSchema,
|
|
18553
|
-
epoch:
|
|
18910
|
+
epoch: z36.number().int().positive(),
|
|
18554
18911
|
goal: NonEmptyBoundedTextSchema,
|
|
18555
|
-
participants:
|
|
18556
|
-
tasks:
|
|
18912
|
+
participants: z36.array(CoWorkParticipantSchema).min(1).max(MAX_PARTICIPANTS),
|
|
18913
|
+
tasks: z36.array(CoWorkPlanTaskSchema).min(1).max(MAX_PLAN_TASKS)
|
|
18557
18914
|
}).strict().superRefine((plan, context) => {
|
|
18558
18915
|
if (Buffer.byteLength(JSON.stringify(plan), "utf8") > MAX_PLAN_ENCODED_BYTES) {
|
|
18559
18916
|
context.addIssue({ code: "custom", message: `Encoded plan must not exceed ${MAX_PLAN_ENCODED_BYTES} UTF-8 bytes` });
|
|
@@ -18603,7 +18960,7 @@ var CoWorkPlanSchema = z35.object({
|
|
|
18603
18960
|
}
|
|
18604
18961
|
}
|
|
18605
18962
|
});
|
|
18606
|
-
var CoWorkPhaseSchema =
|
|
18963
|
+
var CoWorkPhaseSchema = z36.enum([
|
|
18607
18964
|
"proposed",
|
|
18608
18965
|
"planning",
|
|
18609
18966
|
"prepared",
|
|
@@ -18613,30 +18970,30 @@ var CoWorkPhaseSchema = z35.enum([
|
|
|
18613
18970
|
"failed",
|
|
18614
18971
|
"cancelled"
|
|
18615
18972
|
]);
|
|
18616
|
-
var IntegrationResultSchema =
|
|
18617
|
-
passed:
|
|
18973
|
+
var IntegrationResultSchema = z36.object({
|
|
18974
|
+
passed: z36.boolean(),
|
|
18618
18975
|
evidence: CompletionDetailSchema
|
|
18619
18976
|
}).strict();
|
|
18620
|
-
var CoWorkCompletionAssertionSchema =
|
|
18977
|
+
var CoWorkCompletionAssertionSchema = z36.object({
|
|
18621
18978
|
participantId: UuidSchema,
|
|
18622
|
-
passed:
|
|
18979
|
+
passed: z36.boolean(),
|
|
18623
18980
|
detail: CompletionDetailSchema.optional()
|
|
18624
18981
|
}).strict();
|
|
18625
|
-
var CoWorkSnapshotSchema =
|
|
18982
|
+
var CoWorkSnapshotSchema = z36.object({
|
|
18626
18983
|
version: VersionSchema,
|
|
18627
18984
|
coWorkId: UuidSchema,
|
|
18628
|
-
epoch:
|
|
18985
|
+
epoch: z36.number().int().positive(),
|
|
18629
18986
|
phase: CoWorkPhaseSchema,
|
|
18630
18987
|
goal: NonEmptyBoundedTextSchema,
|
|
18631
|
-
participants:
|
|
18988
|
+
participants: z36.array(CoWorkParticipantSchema).min(1).max(MAX_PARTICIPANTS),
|
|
18632
18989
|
integrationOwnerId: UuidSchema,
|
|
18633
|
-
acceptedParticipantIds:
|
|
18634
|
-
planHash:
|
|
18990
|
+
acceptedParticipantIds: z36.array(UuidSchema).max(MAX_PARTICIPANTS),
|
|
18991
|
+
planHash: z36.string().regex(/^[a-f0-9]{64}$/).nullable(),
|
|
18635
18992
|
plan: CoWorkPlanSchema.nullable(),
|
|
18636
|
-
planAcceptedParticipantIds:
|
|
18637
|
-
readyParticipantIds:
|
|
18638
|
-
completedParticipantIds:
|
|
18639
|
-
completionAssertions:
|
|
18993
|
+
planAcceptedParticipantIds: z36.array(UuidSchema).max(MAX_PARTICIPANTS),
|
|
18994
|
+
readyParticipantIds: z36.array(UuidSchema).max(MAX_PARTICIPANTS),
|
|
18995
|
+
completedParticipantIds: z36.array(UuidSchema).max(MAX_PARTICIPANTS),
|
|
18996
|
+
completionAssertions: z36.array(CoWorkCompletionAssertionSchema).max(MAX_PARTICIPANTS),
|
|
18640
18997
|
integration: IntegrationResultSchema.nullable()
|
|
18641
18998
|
}).strict().superRefine((snapshot4, context) => {
|
|
18642
18999
|
if (Buffer.byteLength(JSON.stringify(snapshot4), "utf8") > MAX_SNAPSHOT_ENCODED_BYTES) {
|
|
@@ -18667,87 +19024,87 @@ var RequestBase = {
|
|
|
18667
19024
|
version: VersionSchema,
|
|
18668
19025
|
requestId: UuidSchema
|
|
18669
19026
|
};
|
|
18670
|
-
var RegisterRequestSchema =
|
|
19027
|
+
var RegisterRequestSchema = z36.object({
|
|
18671
19028
|
...RequestBase,
|
|
18672
|
-
type:
|
|
18673
|
-
authToken:
|
|
19029
|
+
type: z36.literal("register"),
|
|
19030
|
+
authToken: z36.string().regex(/^[a-f0-9]{64}$/).optional(),
|
|
18674
19031
|
presence: PalPresenceSchema
|
|
18675
19032
|
}).strict();
|
|
18676
|
-
var HeartbeatRequestSchema =
|
|
18677
|
-
var ListRequestSchema =
|
|
18678
|
-
var DisconnectRequestSchema =
|
|
18679
|
-
var ChatRequestSchema =
|
|
19033
|
+
var HeartbeatRequestSchema = z36.object({ ...RequestBase, type: z36.literal("heartbeat") }).strict();
|
|
19034
|
+
var ListRequestSchema = z36.object({ ...RequestBase, type: z36.literal("list") }).strict();
|
|
19035
|
+
var DisconnectRequestSchema = z36.object({ ...RequestBase, type: z36.literal("disconnect") }).strict();
|
|
19036
|
+
var ChatRequestSchema = z36.object({
|
|
18680
19037
|
...RequestBase,
|
|
18681
|
-
type:
|
|
19038
|
+
type: z36.literal("chat"),
|
|
18682
19039
|
messageId: UuidSchema,
|
|
18683
19040
|
target: PalTargetSchema,
|
|
18684
19041
|
message: NonEmptyBoundedTextSchema
|
|
18685
19042
|
}).strict();
|
|
18686
|
-
var TaskRequestSchema =
|
|
19043
|
+
var TaskRequestSchema = z36.object({
|
|
18687
19044
|
...RequestBase,
|
|
18688
|
-
type:
|
|
19045
|
+
type: z36.literal("task"),
|
|
18689
19046
|
messageId: UuidSchema,
|
|
18690
19047
|
target: PalTargetSchema,
|
|
18691
19048
|
goal: NonEmptyBoundedTextSchema
|
|
18692
19049
|
}).strict();
|
|
18693
|
-
var CoWorkProposeRequestSchema =
|
|
19050
|
+
var CoWorkProposeRequestSchema = z36.object({
|
|
18694
19051
|
...RequestBase,
|
|
18695
|
-
type:
|
|
19052
|
+
type: z36.literal("cowork-propose"),
|
|
18696
19053
|
coWorkId: UuidSchema,
|
|
18697
19054
|
goal: NonEmptyBoundedTextSchema,
|
|
18698
19055
|
participants: CoWorkProposalParticipantsSchema
|
|
18699
19056
|
}).strict();
|
|
18700
|
-
var CoWorkAcceptanceRequestSchema =
|
|
19057
|
+
var CoWorkAcceptanceRequestSchema = z36.object({
|
|
18701
19058
|
...RequestBase,
|
|
18702
|
-
type:
|
|
19059
|
+
type: z36.literal("cowork-accept"),
|
|
18703
19060
|
coWorkId: UuidSchema,
|
|
18704
|
-
epoch:
|
|
19061
|
+
epoch: z36.number().int().positive()
|
|
18705
19062
|
}).strict();
|
|
18706
|
-
var CoWorkPlanRequestSchema =
|
|
18707
|
-
var CoWorkPlanAcceptanceRequestSchema =
|
|
19063
|
+
var CoWorkPlanRequestSchema = z36.object({ ...RequestBase, type: z36.literal("cowork-plan"), plan: CoWorkPlanSchema }).strict();
|
|
19064
|
+
var CoWorkPlanAcceptanceRequestSchema = z36.object({
|
|
18708
19065
|
...RequestBase,
|
|
18709
|
-
type:
|
|
19066
|
+
type: z36.literal("cowork-plan-accept"),
|
|
18710
19067
|
coWorkId: UuidSchema,
|
|
18711
|
-
epoch:
|
|
18712
|
-
planHash:
|
|
19068
|
+
epoch: z36.number().int().positive(),
|
|
19069
|
+
planHash: z36.string().regex(/^[a-f0-9]{64}$/)
|
|
18713
19070
|
}).strict();
|
|
18714
|
-
var CoWorkReadyRequestSchema =
|
|
19071
|
+
var CoWorkReadyRequestSchema = z36.object({
|
|
18715
19072
|
...RequestBase,
|
|
18716
|
-
type:
|
|
19073
|
+
type: z36.literal("cowork-ready"),
|
|
18717
19074
|
coWorkId: UuidSchema,
|
|
18718
|
-
epoch:
|
|
18719
|
-
planHash:
|
|
19075
|
+
epoch: z36.number().int().positive(),
|
|
19076
|
+
planHash: z36.string().regex(/^[a-f0-9]{64}$/)
|
|
18720
19077
|
}).strict();
|
|
18721
|
-
var CoWorkCompleteRequestSchema =
|
|
19078
|
+
var CoWorkCompleteRequestSchema = z36.object({
|
|
18722
19079
|
...RequestBase,
|
|
18723
|
-
type:
|
|
19080
|
+
type: z36.literal("cowork-complete"),
|
|
18724
19081
|
coWorkId: UuidSchema,
|
|
18725
|
-
epoch:
|
|
18726
|
-
planHash:
|
|
18727
|
-
passed:
|
|
19082
|
+
epoch: z36.number().int().positive(),
|
|
19083
|
+
planHash: z36.string().regex(/^[a-f0-9]{64}$/),
|
|
19084
|
+
passed: z36.boolean(),
|
|
18728
19085
|
detail: CompletionDetailSchema.optional()
|
|
18729
19086
|
}).strict();
|
|
18730
|
-
var CoWorkIntegrationRequestSchema =
|
|
19087
|
+
var CoWorkIntegrationRequestSchema = z36.object({
|
|
18731
19088
|
...RequestBase,
|
|
18732
|
-
type:
|
|
19089
|
+
type: z36.literal("cowork-integration"),
|
|
18733
19090
|
coWorkId: UuidSchema,
|
|
18734
|
-
epoch:
|
|
18735
|
-
planHash:
|
|
18736
|
-
passed:
|
|
19091
|
+
epoch: z36.number().int().positive(),
|
|
19092
|
+
planHash: z36.string().regex(/^[a-f0-9]{64}$/),
|
|
19093
|
+
passed: z36.boolean(),
|
|
18737
19094
|
evidence: CompletionDetailSchema
|
|
18738
19095
|
}).strict();
|
|
18739
|
-
var CoWorkGetRequestSchema =
|
|
19096
|
+
var CoWorkGetRequestSchema = z36.object({
|
|
18740
19097
|
...RequestBase,
|
|
18741
|
-
type:
|
|
19098
|
+
type: z36.literal("cowork-get"),
|
|
18742
19099
|
coWorkId: UuidSchema
|
|
18743
19100
|
}).strict();
|
|
18744
|
-
var CoWorkCancelRequestSchema =
|
|
19101
|
+
var CoWorkCancelRequestSchema = z36.object({
|
|
18745
19102
|
...RequestBase,
|
|
18746
|
-
type:
|
|
19103
|
+
type: z36.literal("cowork-cancel"),
|
|
18747
19104
|
coWorkId: UuidSchema,
|
|
18748
19105
|
reason: NonEmptyBoundedTextSchema
|
|
18749
19106
|
}).strict();
|
|
18750
|
-
var BrokerRequestSchema =
|
|
19107
|
+
var BrokerRequestSchema = z36.discriminatedUnion("type", [
|
|
18751
19108
|
RegisterRequestSchema,
|
|
18752
19109
|
HeartbeatRequestSchema,
|
|
18753
19110
|
ListRequestSchema,
|
|
@@ -18764,49 +19121,49 @@ var BrokerRequestSchema = z35.discriminatedUnion("type", [
|
|
|
18764
19121
|
CoWorkGetRequestSchema,
|
|
18765
19122
|
CoWorkCancelRequestSchema
|
|
18766
19123
|
]);
|
|
18767
|
-
var BrokerOkResponseSchema =
|
|
19124
|
+
var BrokerOkResponseSchema = z36.object({
|
|
18768
19125
|
version: VersionSchema,
|
|
18769
|
-
type:
|
|
19126
|
+
type: z36.literal("ok"),
|
|
18770
19127
|
requestId: UuidSchema,
|
|
18771
|
-
data:
|
|
19128
|
+
data: z36.unknown()
|
|
18772
19129
|
}).strict();
|
|
18773
|
-
var BrokerErrorResponseSchema =
|
|
19130
|
+
var BrokerErrorResponseSchema = z36.object({
|
|
18774
19131
|
version: VersionSchema,
|
|
18775
|
-
type:
|
|
19132
|
+
type: z36.literal("error"),
|
|
18776
19133
|
requestId: UuidSchema,
|
|
18777
|
-
code:
|
|
19134
|
+
code: z36.enum(["invalid-request", "authentication-failed", "not-found", "ambiguous-target", "alias-conflict", "invalid-transition", "stale-epoch", "duplicate"]),
|
|
18778
19135
|
message: BoundedTextSchema
|
|
18779
19136
|
}).strict();
|
|
18780
|
-
var ChatEventSchema =
|
|
19137
|
+
var ChatEventSchema = z36.object({
|
|
18781
19138
|
version: VersionSchema,
|
|
18782
|
-
type:
|
|
19139
|
+
type: z36.literal("chat-event"),
|
|
18783
19140
|
messageId: UuidSchema,
|
|
18784
19141
|
senderId: UuidSchema,
|
|
18785
19142
|
recipientId: UuidSchema,
|
|
18786
19143
|
message: NonEmptyBoundedTextSchema
|
|
18787
19144
|
}).strict();
|
|
18788
|
-
var CoWorkEventSchema =
|
|
19145
|
+
var CoWorkEventSchema = z36.object({
|
|
18789
19146
|
version: VersionSchema,
|
|
18790
|
-
type:
|
|
18791
|
-
action:
|
|
19147
|
+
type: z36.literal("cowork-event"),
|
|
19148
|
+
action: z36.enum(["PROPOSE", "PLAN", "START", "END", "FAIL", "CANCEL"]),
|
|
18792
19149
|
actorId: UuidSchema,
|
|
18793
19150
|
coWorkId: UuidSchema,
|
|
18794
|
-
epoch:
|
|
18795
|
-
planHash:
|
|
19151
|
+
epoch: z36.number().int().positive(),
|
|
19152
|
+
planHash: z36.string().regex(/^[a-f0-9]{64}$/).nullable(),
|
|
18796
19153
|
snapshot: CoWorkSnapshotSchema
|
|
18797
19154
|
}).strict();
|
|
18798
|
-
var BrokerEventSchema =
|
|
18799
|
-
var BrokerEventResponseSchema =
|
|
19155
|
+
var BrokerEventSchema = z36.union([ChatEventSchema, PalTaskEventSchema, DeliveryReceiptSchema, CoWorkEventSchema]);
|
|
19156
|
+
var BrokerEventResponseSchema = z36.object({
|
|
18800
19157
|
version: VersionSchema,
|
|
18801
|
-
type:
|
|
19158
|
+
type: z36.literal("event"),
|
|
18802
19159
|
event: BrokerEventSchema
|
|
18803
19160
|
}).strict();
|
|
18804
|
-
var BrokerResponseSchema =
|
|
19161
|
+
var BrokerResponseSchema = z36.discriminatedUnion("type", [
|
|
18805
19162
|
BrokerOkResponseSchema,
|
|
18806
19163
|
BrokerErrorResponseSchema,
|
|
18807
19164
|
BrokerEventResponseSchema
|
|
18808
19165
|
]);
|
|
18809
|
-
var ControlFrameSchema =
|
|
19166
|
+
var ControlFrameSchema = z36.string().refine(
|
|
18810
19167
|
(frame) => Buffer.byteLength(frame, "utf8") <= MAX_CONTROL_FRAME_BYTES,
|
|
18811
19168
|
`Control frame must not exceed ${MAX_CONTROL_FRAME_BYTES} UTF-8 bytes`
|
|
18812
19169
|
);
|
|
@@ -19290,7 +19647,8 @@ var FlavorSession = class {
|
|
|
19290
19647
|
version: 1,
|
|
19291
19648
|
type: "SessionStart",
|
|
19292
19649
|
payload: { workspace: this.#services.workspace }
|
|
19293
|
-
}).then(() => {
|
|
19650
|
+
}).then(async (decision) => {
|
|
19651
|
+
if (decision.additionalContext !== void 0) await this.#services.addContext?.(decision.additionalContext);
|
|
19294
19652
|
this.#started = true;
|
|
19295
19653
|
});
|
|
19296
19654
|
return this.#startPromise;
|
|
@@ -19727,7 +20085,7 @@ var LANG_LABELS = /* @__PURE__ */ new Map([
|
|
|
19727
20085
|
]);
|
|
19728
20086
|
|
|
19729
20087
|
// src/hallucination/confidence.ts
|
|
19730
|
-
import { z as
|
|
20088
|
+
import { z as z37 } from "zod";
|
|
19731
20089
|
|
|
19732
20090
|
// src/hallucination/types.ts
|
|
19733
20091
|
var DEFAULT_SLIDING_WINDOW_SIZE = 20;
|
|
@@ -19740,12 +20098,12 @@ var DEFAULT_EVALUATION_TIMEOUT_MS = 2e3;
|
|
|
19740
20098
|
var MAX_QUERY_CHARS = 5e3;
|
|
19741
20099
|
var MAX_OUTPUT_CHARS = 1e4;
|
|
19742
20100
|
var MAX_EVIDENCE_CHARS = 6e3;
|
|
19743
|
-
var ConfidenceSchema =
|
|
19744
|
-
taskAlignment:
|
|
19745
|
-
evidenceGrounding:
|
|
19746
|
-
processReliability:
|
|
19747
|
-
reason:
|
|
19748
|
-
unsupportedClaims:
|
|
20101
|
+
var ConfidenceSchema = z37.object({
|
|
20102
|
+
taskAlignment: z37.number(),
|
|
20103
|
+
evidenceGrounding: z37.number(),
|
|
20104
|
+
processReliability: z37.number(),
|
|
20105
|
+
reason: z37.string(),
|
|
20106
|
+
unsupportedClaims: z37.array(z37.string()).max(3)
|
|
19749
20107
|
});
|
|
19750
20108
|
var PROMPT = `You are a fast, evidence-aware task-completion verifier.
|
|
19751
20109
|
|
|
@@ -21838,15 +22196,15 @@ function workspacePath(root, input) {
|
|
|
21838
22196
|
}
|
|
21839
22197
|
|
|
21840
22198
|
// src/tools/terminal.ts
|
|
21841
|
-
import { z as
|
|
22199
|
+
import { z as z38 } from "zod";
|
|
21842
22200
|
import { resolve as resolve29 } from "path";
|
|
21843
|
-
var Id =
|
|
21844
|
-
var OpenInput =
|
|
21845
|
-
var OptionalBoolean =
|
|
21846
|
-
var WriteInput2 =
|
|
21847
|
-
var ReadInput3 =
|
|
21848
|
-
var ResizeInput =
|
|
21849
|
-
var CloseInput =
|
|
22201
|
+
var Id = z38.string().regex(/^term-[a-f0-9-]+$/);
|
|
22202
|
+
var OpenInput = z38.object({ cwd: z38.string().optional(), shell: z38.string().optional(), args: z38.array(z38.string()).optional(), columns: z38.coerce.number().int().min(10).max(500).optional(), rows: z38.coerce.number().int().min(2).max(300).optional() });
|
|
22203
|
+
var OptionalBoolean = z38.union([z38.boolean(), z38.string().refine((value) => value === "true" || value === "false")]);
|
|
22204
|
+
var WriteInput2 = z38.object({ id: Id, data: z38.string().max(1e5), enter: OptionalBoolean.optional() });
|
|
22205
|
+
var ReadInput3 = z38.object({ id: Id, cursor: z38.coerce.number().int().min(0).optional() });
|
|
22206
|
+
var ResizeInput = z38.object({ id: Id, columns: z38.coerce.number().int().min(10).max(500), rows: z38.coerce.number().int().min(2).max(300) });
|
|
22207
|
+
var CloseInput = z38.object({ id: Id });
|
|
21850
22208
|
function createTerminalTools(terminals, workspace = process.cwd()) {
|
|
21851
22209
|
const tools = [
|
|
21852
22210
|
{
|
|
@@ -21922,7 +22280,7 @@ function createTerminalTools(terminals, workspace = process.cwd()) {
|
|
|
21922
22280
|
{
|
|
21923
22281
|
name: "TerminalList",
|
|
21924
22282
|
description: "List persistent terminals owned by this agent",
|
|
21925
|
-
inputSchema:
|
|
22283
|
+
inputSchema: z38.object({}),
|
|
21926
22284
|
paths: () => [],
|
|
21927
22285
|
execute: async (_input, _signal, context) => terminals.list(owner(context))
|
|
21928
22286
|
}
|
|
@@ -21957,7 +22315,7 @@ import { spawn as spawn7 } from "child_process";
|
|
|
21957
22315
|
import { createHash as createHash14, randomUUID as randomUUID19, timingSafeEqual } from "crypto";
|
|
21958
22316
|
import { chmod as chmod2, lstat as lstat12, mkdir as mkdir23, unlink as unlink5 } from "fs/promises";
|
|
21959
22317
|
import { createServer as createServer3, Socket } from "net";
|
|
21960
|
-
import { dirname as
|
|
22318
|
+
import { dirname as dirname23 } from "path";
|
|
21961
22319
|
|
|
21962
22320
|
// src/pals/auth.ts
|
|
21963
22321
|
import { randomBytes as randomBytes3, randomUUID as randomUUID17 } from "crypto";
|
|
@@ -22008,7 +22366,7 @@ function validatePalAuthToken(token) {
|
|
|
22008
22366
|
// src/pals/lifecycle.ts
|
|
22009
22367
|
import { randomUUID as randomUUID18 } from "crypto";
|
|
22010
22368
|
import { mkdir as mkdir22, open as open13, readFile as readFile24, rename as rename11, stat as stat11, unlink as unlink4 } from "fs/promises";
|
|
22011
|
-
import { dirname as
|
|
22369
|
+
import { dirname as dirname22 } from "path";
|
|
22012
22370
|
function defaultProcessAlive(pid) {
|
|
22013
22371
|
if (!Number.isSafeInteger(pid) || pid <= 0) return true;
|
|
22014
22372
|
try {
|
|
@@ -22029,7 +22387,7 @@ function parseMetadata(value) {
|
|
|
22029
22387
|
}
|
|
22030
22388
|
async function acquirePalFileLock(options) {
|
|
22031
22389
|
if (await options.endpointLive()) return void 0;
|
|
22032
|
-
await mkdir22(
|
|
22390
|
+
await mkdir22(dirname22(options.path), { recursive: true, mode: 448 });
|
|
22033
22391
|
const pid = options.pid ?? process.pid;
|
|
22034
22392
|
const now = options.now ?? Date.now;
|
|
22035
22393
|
const nonce = randomUUID18();
|
|
@@ -22498,7 +22856,7 @@ var PalClient = class {
|
|
|
22498
22856
|
};
|
|
22499
22857
|
|
|
22500
22858
|
// src/pals/tools.ts
|
|
22501
|
-
import { z as
|
|
22859
|
+
import { z as z39 } from "zod";
|
|
22502
22860
|
var DEFAULT_SHARE_BUDGET_BYTES = 128 * 1024;
|
|
22503
22861
|
var CollaborationShareGuard = class {
|
|
22504
22862
|
redact;
|
|
@@ -22519,25 +22877,25 @@ var CollaborationShareGuard = class {
|
|
|
22519
22877
|
return redacted;
|
|
22520
22878
|
}
|
|
22521
22879
|
};
|
|
22522
|
-
var Uuid =
|
|
22523
|
-
var Hash =
|
|
22880
|
+
var Uuid = z39.uuid();
|
|
22881
|
+
var Hash = z39.string().regex(/^[a-f0-9]{64}$/);
|
|
22524
22882
|
var Target = PalTargetSchema;
|
|
22525
|
-
var BoundedText =
|
|
22883
|
+
var BoundedText = z39.string().trim().min(1).refine(
|
|
22526
22884
|
(value) => Buffer.byteLength(value, "utf8") <= MAX_MESSAGE_BYTES,
|
|
22527
22885
|
`Text must not exceed ${MAX_MESSAGE_BYTES} UTF-8 bytes`
|
|
22528
22886
|
);
|
|
22529
|
-
var CompletionEvidence =
|
|
22887
|
+
var CompletionEvidence = z39.string().trim().min(1).refine(
|
|
22530
22888
|
(value) => Buffer.byteLength(value, "utf8") <= MAX_COMPLETION_DETAIL_BYTES,
|
|
22531
22889
|
`Completion evidence must not exceed ${MAX_COMPLETION_DETAIL_BYTES} UTF-8 bytes`
|
|
22532
22890
|
);
|
|
22533
|
-
var EmptyInput =
|
|
22534
|
-
var StateInput =
|
|
22535
|
-
var TokenInput =
|
|
22536
|
-
var SendInput =
|
|
22537
|
-
var PlanInput =
|
|
22538
|
-
var ProgressInput =
|
|
22539
|
-
var CompleteInput = TokenInput.extend({ passed:
|
|
22540
|
-
var IntegrateInput = TokenInput.extend({ passed:
|
|
22891
|
+
var EmptyInput = z39.object({}).strict();
|
|
22892
|
+
var StateInput = z39.object({ coWorkId: Uuid }).strict();
|
|
22893
|
+
var TokenInput = z39.object({ coWorkId: Uuid, epoch: z39.number().int().positive(), planHash: Hash }).strict();
|
|
22894
|
+
var SendInput = z39.object({ target: Target, message: BoundedText, coWorkId: Uuid.optional() }).strict();
|
|
22895
|
+
var PlanInput = z39.object({ plan: CoWorkPlanSchema }).strict();
|
|
22896
|
+
var ProgressInput = z39.object({ coWorkId: Uuid, target: Target, detail: BoundedText }).strict();
|
|
22897
|
+
var CompleteInput = TokenInput.extend({ passed: z39.boolean(), detail: CompletionEvidence }).strict();
|
|
22898
|
+
var IntegrateInput = TokenInput.extend({ passed: z39.boolean(), evidence: CompletionEvidence }).strict();
|
|
22541
22899
|
var sharedBytes = (...values) => values.reduce((total, value) => total + Buffer.byteLength(value, "utf8"), 0);
|
|
22542
22900
|
function resolvePresence(presences, target) {
|
|
22543
22901
|
const normalized = normalizePalIdentity(target);
|
|
@@ -22696,6 +23054,7 @@ var INTERRUPTED_TASK_PLAN_CONTEXT = [
|
|
|
22696
23054
|
"Reassess the current query independently.",
|
|
22697
23055
|
"If the current work needs a plan, create a fresh one with TaskPlan before using TaskUpdate."
|
|
22698
23056
|
].join(" ");
|
|
23057
|
+
var DEFAULT_SHUTDOWN_STEP_TIMEOUT_MS = 3e3;
|
|
22699
23058
|
function createPromptEnvironment(input = {}) {
|
|
22700
23059
|
const now = input.now ?? /* @__PURE__ */ new Date();
|
|
22701
23060
|
return {
|
|
@@ -23153,7 +23512,7 @@ async function createProductionRuntime(options) {
|
|
|
23153
23512
|
});
|
|
23154
23513
|
const skillsReady = skills.discover();
|
|
23155
23514
|
skillsReady.catch(() => void 0);
|
|
23156
|
-
tools.push(createSkillResourceTool(skills));
|
|
23515
|
+
tools.push(createSkillTool(skills), createSkillResourceTool(skills));
|
|
23157
23516
|
if (options.extraTools !== void 0) tools.push(...options.extraTools);
|
|
23158
23517
|
const flavor = await optionalText2(join29(workspace, "FLAVOR.md"));
|
|
23159
23518
|
const instructionBaseline = await workspaceInstructions.baseline();
|
|
@@ -23855,6 +24214,10 @@ async function createProductionRuntime(options) {
|
|
|
23855
24214
|
subagentModel: () => childModel,
|
|
23856
24215
|
llmServiceName: () => effectiveLlm?.serviceName,
|
|
23857
24216
|
permissionMode: () => harness.permissionMode,
|
|
24217
|
+
addContext: (content) => {
|
|
24218
|
+
const duplicate = harness.main.context.snapshot().messages.some((entry2) => entry2.role === "system" && entry2.content === content);
|
|
24219
|
+
if (!duplicate) harness.main.context.append({ role: "system", content });
|
|
24220
|
+
},
|
|
23858
24221
|
...palServices === void 0 ? {} : { pals: palServices },
|
|
23859
24222
|
run: (prompt, signal, runOptions) => {
|
|
23860
24223
|
interruptedTaskPlanNeedsReassessment = false;
|
|
@@ -24264,23 +24627,24 @@ ${renderMemoryDocument(entries)}`;
|
|
|
24264
24627
|
async dispose() {
|
|
24265
24628
|
if (disposed) return;
|
|
24266
24629
|
disposed = true;
|
|
24630
|
+
const stepTimeoutMs = options.shutdownStepTimeoutMs ?? DEFAULT_SHUTDOWN_STEP_TIMEOUT_MS;
|
|
24267
24631
|
collaborationEventsOpen = false;
|
|
24268
24632
|
unsubscribeCollaboration?.();
|
|
24269
|
-
await collaborationEventPump;
|
|
24633
|
+
if (collaborationEventPump !== void 0) await boundedStep(stepTimeoutMs, diagnostics, "collaboration-event-pump", collaborationEventPump);
|
|
24270
24634
|
mcpDiscarded = true;
|
|
24271
|
-
await sleepScheduler
|
|
24272
|
-
await memoryCoordinator
|
|
24273
|
-
await persist();
|
|
24274
|
-
await persistTail;
|
|
24275
|
-
if (ideSessionId !== void 0) await ide.endSession(ideSessionId);
|
|
24276
|
-
await executionEnvironment
|
|
24635
|
+
if (sleepScheduler !== void 0) await boundedStep(stepTimeoutMs, diagnostics, "sleep-scheduler", sleepScheduler.dispose());
|
|
24636
|
+
if (memoryCoordinator !== void 0) await boundedStep(stepTimeoutMs, diagnostics, "memory-flush", memoryCoordinator.flush());
|
|
24637
|
+
await boundedStep(stepTimeoutMs, diagnostics, "persist", persist());
|
|
24638
|
+
if (persistTail !== void 0) await boundedStep(stepTimeoutMs, diagnostics, "persist-tail", persistTail);
|
|
24639
|
+
if (ideSessionId !== void 0) await boundedStep(stepTimeoutMs, diagnostics, "ide-end-session", ide.endSession(ideSessionId));
|
|
24640
|
+
if (executionEnvironment !== void 0) await boundedStep(stepTimeoutMs, diagnostics, "execution-environment", executionEnvironment.dispose());
|
|
24277
24641
|
terminals.dispose();
|
|
24278
|
-
await jobs.dispose();
|
|
24642
|
+
await boundedStep(stepTimeoutMs, diagnostics, "jobs", jobs.dispose());
|
|
24279
24643
|
auditLogger.close();
|
|
24280
24644
|
evolveService.dispose();
|
|
24281
24645
|
memoryReviews.dispose();
|
|
24282
|
-
await collaborationClient
|
|
24283
|
-
await cleanupProduction(approvals, questions, pluginHost, mcpManager, harness);
|
|
24646
|
+
if (collaborationClient !== void 0) await boundedStep(stepTimeoutMs, diagnostics, "collaboration-close", collaborationClient.close());
|
|
24647
|
+
await cleanupProduction(approvals, questions, pluginHost, mcpManager, harness, { stepTimeoutMs });
|
|
24284
24648
|
}
|
|
24285
24649
|
};
|
|
24286
24650
|
} catch (primaryError) {
|
|
@@ -24288,16 +24652,17 @@ ${renderMemoryDocument(entries)}`;
|
|
|
24288
24652
|
mcpDiscarded = true;
|
|
24289
24653
|
memoryReviews.dispose();
|
|
24290
24654
|
try {
|
|
24291
|
-
|
|
24292
|
-
await
|
|
24293
|
-
await
|
|
24655
|
+
const stepTimeoutMs = options.shutdownStepTimeoutMs ?? DEFAULT_SHUTDOWN_STEP_TIMEOUT_MS;
|
|
24656
|
+
if (ideSessionId !== void 0) await boundedStep(stepTimeoutMs, diagnostics, "ide-end-session", ide.endSession(ideSessionId));
|
|
24657
|
+
if (sleepScheduler !== void 0) await boundedStep(stepTimeoutMs, diagnostics, "sleep-scheduler", sleepScheduler.dispose());
|
|
24658
|
+
if (executionEnvironment !== void 0) await boundedStep(stepTimeoutMs, diagnostics, "execution-environment", executionEnvironment.dispose());
|
|
24294
24659
|
terminals.dispose();
|
|
24295
|
-
await jobs.dispose();
|
|
24660
|
+
await boundedStep(stepTimeoutMs, diagnostics, "jobs", jobs.dispose());
|
|
24296
24661
|
unsubscribeCollaboration?.();
|
|
24297
24662
|
pendingCollaborationEvents.length = 0;
|
|
24298
|
-
await collaborationEventPump;
|
|
24299
|
-
await collaborationClient
|
|
24300
|
-
await cleanupProduction(approvals, questions, pluginHost, mcpManager, harnessCreated ? harness : void 0);
|
|
24663
|
+
if (collaborationEventPump !== void 0) await boundedStep(stepTimeoutMs, diagnostics, "collaboration-event-pump", collaborationEventPump);
|
|
24664
|
+
if (collaborationClient !== void 0) await boundedStep(stepTimeoutMs, diagnostics, "collaboration-close", collaborationClient.close());
|
|
24665
|
+
await cleanupProduction(approvals, questions, pluginHost, mcpManager, harnessCreated ? harness : void 0, { stepTimeoutMs });
|
|
24301
24666
|
} catch (cleanupError) {
|
|
24302
24667
|
attachCleanupError(primaryError, cleanupError);
|
|
24303
24668
|
}
|
|
@@ -24466,7 +24831,7 @@ async function* runMain(harness, skills, prompt, signal, setupError, memory, get
|
|
|
24466
24831
|
if (ideContext !== void 0) contexts.push(ideContext);
|
|
24467
24832
|
const skill = await skills.match(prompt);
|
|
24468
24833
|
if (skill !== void 0) contexts.push(`Matched skill: ${skill.name}
|
|
24469
|
-
${await skills.loadBody(skill)}`);
|
|
24834
|
+
${expandSkillArguments(await skills.loadBody(skill), prompt)}`);
|
|
24470
24835
|
const additionalContext = contexts.length === 0 ? void 0 : contexts.join("\n\n");
|
|
24471
24836
|
for await (const event of harness.main.loop.run({
|
|
24472
24837
|
prompt,
|
|
@@ -24501,7 +24866,7 @@ async function* runExplicitSkill(harness, skills, skillName, prompt, signal, set
|
|
|
24501
24866
|
}
|
|
24502
24867
|
const userPrompt = prompt || `Apply the ${skillName} skill.`;
|
|
24503
24868
|
const additionalContext = `Matched skill: ${skill.name}
|
|
24504
|
-
${await skills.loadBody(skill)}`;
|
|
24869
|
+
${expandSkillArguments(await skills.loadBody(skill), prompt)}`;
|
|
24505
24870
|
yield* harness.main.loop.run({ prompt: userPrompt, signal, additionalContext });
|
|
24506
24871
|
} catch (error) {
|
|
24507
24872
|
yield { type: "error", error: { code: "unknown", message: message(error) } };
|
|
@@ -24918,7 +25283,8 @@ function storedConversation(snapshot4) {
|
|
|
24918
25283
|
})
|
|
24919
25284
|
};
|
|
24920
25285
|
}
|
|
24921
|
-
async function cleanupProduction(approvals, questions, pluginHost, mcpManager, harness) {
|
|
25286
|
+
async function cleanupProduction(approvals, questions, pluginHost, mcpManager, harness, cleanupOptions = { stepTimeoutMs: DEFAULT_SHUTDOWN_STEP_TIMEOUT_MS }) {
|
|
25287
|
+
const { stepTimeoutMs } = cleanupOptions;
|
|
24922
25288
|
let primary;
|
|
24923
25289
|
try {
|
|
24924
25290
|
approvals.resolve("deny");
|
|
@@ -24932,7 +25298,8 @@ async function cleanupProduction(approvals, questions, pluginHost, mcpManager, h
|
|
|
24932
25298
|
else attachCleanupError(primary, error);
|
|
24933
25299
|
}
|
|
24934
25300
|
try {
|
|
24935
|
-
await pluginHost.unloadAll();
|
|
25301
|
+
const outcome = await withTimeout(pluginHost.unloadAll(), stepTimeoutMs);
|
|
25302
|
+
if (outcome.timedOut) primary = new Error(`Plugin unload timed out after ${stepTimeoutMs}ms`);
|
|
24936
25303
|
} catch (error) {
|
|
24937
25304
|
if (primary === void 0) primary = error;
|
|
24938
25305
|
else attachCleanupError(primary, error);
|
|
@@ -24944,7 +25311,14 @@ async function cleanupProduction(approvals, questions, pluginHost, mcpManager, h
|
|
|
24944
25311
|
else attachCleanupError(primary, error);
|
|
24945
25312
|
}
|
|
24946
25313
|
try {
|
|
24947
|
-
|
|
25314
|
+
if (mcpManager !== void 0) {
|
|
25315
|
+
const outcome = await withTimeout(mcpManager.close(), stepTimeoutMs);
|
|
25316
|
+
if (outcome.timedOut) {
|
|
25317
|
+
const timeoutError = new Error(`MCP shutdown timed out after ${stepTimeoutMs}ms`);
|
|
25318
|
+
if (primary === void 0) primary = timeoutError;
|
|
25319
|
+
else attachCleanupError(primary, timeoutError);
|
|
25320
|
+
}
|
|
25321
|
+
}
|
|
24948
25322
|
} catch (error) {
|
|
24949
25323
|
if (primary === void 0) primary = error;
|
|
24950
25324
|
else attachCleanupError(primary, error);
|
|
@@ -24952,6 +25326,10 @@ async function cleanupProduction(approvals, questions, pluginHost, mcpManager, h
|
|
|
24952
25326
|
}
|
|
24953
25327
|
if (primary !== void 0) throw primary;
|
|
24954
25328
|
}
|
|
25329
|
+
async function boundedStep(timeoutMs, diagnostics, name, step) {
|
|
25330
|
+
const outcome = await withTimeout(step, timeoutMs);
|
|
25331
|
+
if (outcome.timedOut) diagnostics.push(`Shutdown step "${name}" timed out after ${timeoutMs}ms and was abandoned.`);
|
|
25332
|
+
}
|
|
24955
25333
|
function attachCleanupError(primary, cleanup) {
|
|
24956
25334
|
if (typeof primary !== "object" && typeof primary !== "function" || primary === null || !Object.isExtensible(primary)) return;
|
|
24957
25335
|
try {
|
|
@@ -25044,7 +25422,7 @@ import { basename as basename9, join as join39, resolve as resolve33 } from "pat
|
|
|
25044
25422
|
// src/d2c/workflow.ts
|
|
25045
25423
|
import { createHash as createHash17 } from "crypto";
|
|
25046
25424
|
import { join as join30 } from "path";
|
|
25047
|
-
import { z as
|
|
25425
|
+
import { z as z40 } from "zod";
|
|
25048
25426
|
|
|
25049
25427
|
// src/d2c/workflow-shared.ts
|
|
25050
25428
|
function reviewProgress(workflow) {
|
|
@@ -25067,91 +25445,91 @@ function buildD2cQualityRepairPrompt(task, issue) {
|
|
|
25067
25445
|
}
|
|
25068
25446
|
|
|
25069
25447
|
// src/d2c/workflow.ts
|
|
25070
|
-
var ReviewSchema2 =
|
|
25071
|
-
fingerprint:
|
|
25072
|
-
pageId:
|
|
25073
|
-
reportId:
|
|
25074
|
-
signature:
|
|
25075
|
-
label:
|
|
25076
|
-
decision:
|
|
25077
|
-
instruction:
|
|
25078
|
-
moduleId:
|
|
25079
|
-
moduleSourceFiles:
|
|
25080
|
-
updatedAt:
|
|
25448
|
+
var ReviewSchema2 = z40.object({
|
|
25449
|
+
fingerprint: z40.string().min(1).max(256),
|
|
25450
|
+
pageId: z40.string().min(1).max(128),
|
|
25451
|
+
reportId: z40.string().min(1).max(128),
|
|
25452
|
+
signature: z40.string().regex(/^[a-f0-9]{64}$/),
|
|
25453
|
+
label: z40.string().min(1).max(1e3),
|
|
25454
|
+
decision: z40.enum(["pending", "accepted", "needs-fix"]),
|
|
25455
|
+
instruction: z40.string().max(1e4).optional(),
|
|
25456
|
+
moduleId: z40.string().min(1).max(128).optional(),
|
|
25457
|
+
moduleSourceFiles: z40.array(z40.string().min(1).max(2048)).max(64).optional(),
|
|
25458
|
+
updatedAt: z40.iso.datetime()
|
|
25081
25459
|
}).strict();
|
|
25082
|
-
var InteractionRunSchema =
|
|
25083
|
-
schema:
|
|
25084
|
-
runAt:
|
|
25085
|
-
baseUrl:
|
|
25086
|
-
passed:
|
|
25087
|
-
total:
|
|
25088
|
-
failures:
|
|
25089
|
-
apiRequestCount:
|
|
25090
|
-
scenarios:
|
|
25091
|
-
id:
|
|
25092
|
-
pageUrl:
|
|
25093
|
-
passed:
|
|
25094
|
-
durationMs:
|
|
25095
|
-
apiRequestCount:
|
|
25096
|
-
failure:
|
|
25097
|
-
requests:
|
|
25460
|
+
var InteractionRunSchema = z40.object({
|
|
25461
|
+
schema: z40.literal(1),
|
|
25462
|
+
runAt: z40.iso.datetime(),
|
|
25463
|
+
baseUrl: z40.string().url().max(2048),
|
|
25464
|
+
passed: z40.boolean(),
|
|
25465
|
+
total: z40.number().int().nonnegative().max(5e4),
|
|
25466
|
+
failures: z40.number().int().nonnegative().max(5e4),
|
|
25467
|
+
apiRequestCount: z40.number().int().nonnegative().max(1e7),
|
|
25468
|
+
scenarios: z40.array(z40.object({
|
|
25469
|
+
id: z40.string().min(1).max(128),
|
|
25470
|
+
pageUrl: z40.string().url().max(2048),
|
|
25471
|
+
passed: z40.boolean(),
|
|
25472
|
+
durationMs: z40.number().int().nonnegative().max(864e5),
|
|
25473
|
+
apiRequestCount: z40.number().int().nonnegative().max(1e7),
|
|
25474
|
+
failure: z40.string().max(2e4).optional(),
|
|
25475
|
+
requests: z40.array(z40.object({ method: z40.string().min(1).max(16), path: z40.string().min(1).max(2048), status: z40.number().int().min(0).max(599) }).strict()).max(1e4).optional()
|
|
25098
25476
|
}).strict()).max(5e4),
|
|
25099
|
-
evidenceMode:
|
|
25477
|
+
evidenceMode: z40.enum(["contract", "autonomous", "contract-fallback"]).optional()
|
|
25100
25478
|
}).strict();
|
|
25101
|
-
var QualityJudgmentSchema =
|
|
25102
|
-
schema:
|
|
25103
|
-
runAt:
|
|
25104
|
-
model:
|
|
25105
|
-
visualScore:
|
|
25106
|
-
interactionScore:
|
|
25107
|
-
rawVisualScore:
|
|
25108
|
-
rawInteractionScore:
|
|
25109
|
-
staticVisualScore:
|
|
25110
|
-
deterministicInteractionPassed:
|
|
25111
|
-
overallScore:
|
|
25112
|
-
threshold:
|
|
25113
|
-
verdict:
|
|
25114
|
-
confidence:
|
|
25115
|
-
summary:
|
|
25116
|
-
strengths:
|
|
25117
|
-
evidenceMode:
|
|
25118
|
-
issues:
|
|
25119
|
-
category:
|
|
25120
|
-
severity:
|
|
25121
|
-
description:
|
|
25122
|
-
evidence:
|
|
25123
|
-
recommendation:
|
|
25124
|
-
selector:
|
|
25125
|
-
scoreImpact:
|
|
25126
|
-
id:
|
|
25127
|
-
decision:
|
|
25128
|
-
updatedAt:
|
|
25479
|
+
var QualityJudgmentSchema = z40.object({
|
|
25480
|
+
schema: z40.literal(1),
|
|
25481
|
+
runAt: z40.iso.datetime(),
|
|
25482
|
+
model: z40.string().min(1).max(256),
|
|
25483
|
+
visualScore: z40.number().min(0).max(100),
|
|
25484
|
+
interactionScore: z40.number().min(0).max(100),
|
|
25485
|
+
rawVisualScore: z40.number().min(0).max(100).optional(),
|
|
25486
|
+
rawInteractionScore: z40.number().min(0).max(100).optional(),
|
|
25487
|
+
staticVisualScore: z40.number().min(0).max(100),
|
|
25488
|
+
deterministicInteractionPassed: z40.boolean(),
|
|
25489
|
+
overallScore: z40.number().min(0).max(100),
|
|
25490
|
+
threshold: z40.number().min(0).max(100),
|
|
25491
|
+
verdict: z40.enum(["pass", "fail"]),
|
|
25492
|
+
confidence: z40.enum(["high", "medium", "low"]),
|
|
25493
|
+
summary: z40.string().min(1).max(4e3),
|
|
25494
|
+
strengths: z40.array(z40.string().min(1).max(1e3)).max(20),
|
|
25495
|
+
evidenceMode: z40.enum(["contract", "autonomous", "contract-fallback"]).optional(),
|
|
25496
|
+
issues: z40.array(z40.object({
|
|
25497
|
+
category: z40.enum(["visual", "interaction", "accessibility", "reliability"]),
|
|
25498
|
+
severity: z40.enum(["minor", "major", "critical"]),
|
|
25499
|
+
description: z40.string().min(1).max(2e3),
|
|
25500
|
+
evidence: z40.string().min(1).max(2e3).optional(),
|
|
25501
|
+
recommendation: z40.string().min(1).max(2e3),
|
|
25502
|
+
selector: z40.string().min(1).max(2048).optional(),
|
|
25503
|
+
scoreImpact: z40.number().min(0).max(30).optional(),
|
|
25504
|
+
id: z40.string().regex(/^quality-[a-f0-9]{20}$/).optional(),
|
|
25505
|
+
decision: z40.enum(["pending", "skipped", "fixing"]).optional(),
|
|
25506
|
+
updatedAt: z40.iso.datetime().optional()
|
|
25129
25507
|
}).strict()).max(100)
|
|
25130
25508
|
}).strict();
|
|
25131
|
-
var WorkflowSchema =
|
|
25132
|
-
schema:
|
|
25133
|
-
task:
|
|
25134
|
-
revision:
|
|
25135
|
-
stage:
|
|
25136
|
-
framework:
|
|
25137
|
-
activeReportId:
|
|
25138
|
-
activeBatchId:
|
|
25139
|
-
implementationDir:
|
|
25140
|
-
reviews:
|
|
25141
|
-
openapi:
|
|
25142
|
-
sourceName:
|
|
25143
|
-
importedAt:
|
|
25144
|
-
hash:
|
|
25145
|
-
version:
|
|
25146
|
-
title:
|
|
25147
|
-
baseUrl:
|
|
25509
|
+
var WorkflowSchema = z40.object({
|
|
25510
|
+
schema: z40.literal(1),
|
|
25511
|
+
task: z40.string().regex(D2C_TASK_PATTERN),
|
|
25512
|
+
revision: z40.number().int().nonnegative(),
|
|
25513
|
+
stage: z40.enum(["visual-review", "api-mapping", "integrating", "interaction-review", "quality-judge", "completed"]),
|
|
25514
|
+
framework: z40.enum(["vue", "react"]),
|
|
25515
|
+
activeReportId: z40.string().min(1).max(128),
|
|
25516
|
+
activeBatchId: z40.string().min(1).max(128).optional(),
|
|
25517
|
+
implementationDir: z40.string().min(1).max(32768),
|
|
25518
|
+
reviews: z40.array(ReviewSchema2).max(1e4),
|
|
25519
|
+
openapi: z40.object({
|
|
25520
|
+
sourceName: z40.string().min(1).max(255),
|
|
25521
|
+
importedAt: z40.iso.datetime(),
|
|
25522
|
+
hash: z40.string().regex(/^[a-f0-9]{64}$/),
|
|
25523
|
+
version: z40.string().min(1).max(32),
|
|
25524
|
+
title: z40.string().min(1).max(500),
|
|
25525
|
+
baseUrl: z40.string().max(4096).optional()
|
|
25148
25526
|
}).strict().optional(),
|
|
25149
|
-
mappings:
|
|
25150
|
-
integrationFiles:
|
|
25151
|
-
interaction:
|
|
25527
|
+
mappings: z40.array(z40.unknown()).max(5e3).optional(),
|
|
25528
|
+
integrationFiles: z40.array(z40.string().min(1).max(2048)).max(1e3).optional(),
|
|
25529
|
+
interaction: z40.object({ manualDecision: z40.enum(["pending", "accepted"]), automated: InteractionRunSchema.optional(), updatedAt: z40.iso.datetime() }).strict().optional(),
|
|
25152
25530
|
quality: QualityJudgmentSchema.optional(),
|
|
25153
|
-
qualityWaivers:
|
|
25154
|
-
updatedAt:
|
|
25531
|
+
qualityWaivers: z40.array(z40.object({ issueId: z40.string().regex(/^quality-[a-f0-9]{20}$/), updatedAt: z40.iso.datetime() }).strict()).max(100).optional(),
|
|
25532
|
+
updatedAt: z40.iso.datetime()
|
|
25155
25533
|
}).strict();
|
|
25156
25534
|
function pageId(report) {
|
|
25157
25535
|
return report.page?.id ?? "index";
|
|
@@ -25568,16 +25946,16 @@ function confirmApiMapping(mapping, operationKey, operations) {
|
|
|
25568
25946
|
// src/d2c/modules.ts
|
|
25569
25947
|
import { readFile as readFile26 } from "fs/promises";
|
|
25570
25948
|
import { isAbsolute as isAbsolute15, join as join31, normalize as normalize2, posix, sep as sep23, win32 as win322 } from "path";
|
|
25571
|
-
import { z as
|
|
25572
|
-
var ModuleSchema =
|
|
25573
|
-
id:
|
|
25574
|
-
label:
|
|
25575
|
-
sourceFiles:
|
|
25576
|
-
keywords:
|
|
25577
|
-
dataNeeds:
|
|
25578
|
-
actions:
|
|
25949
|
+
import { z as z41 } from "zod";
|
|
25950
|
+
var ModuleSchema = z41.object({
|
|
25951
|
+
id: z41.string().regex(/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/),
|
|
25952
|
+
label: z41.string().trim().min(1).max(200),
|
|
25953
|
+
sourceFiles: z41.array(z41.string().trim().min(1).max(2048)).min(1).max(64),
|
|
25954
|
+
keywords: z41.array(z41.string().trim().min(1).max(100)).max(100).optional(),
|
|
25955
|
+
dataNeeds: z41.array(z41.string().trim().min(1).max(100)).max(100).optional(),
|
|
25956
|
+
actions: z41.array(z41.string().trim().min(1).max(100)).max(100).optional()
|
|
25579
25957
|
}).strict();
|
|
25580
|
-
var ManifestSchema3 =
|
|
25958
|
+
var ManifestSchema3 = z41.object({ schema: z41.literal(1), modules: z41.array(ModuleSchema).min(1).max(500) }).passthrough();
|
|
25581
25959
|
function safeSource(path) {
|
|
25582
25960
|
if (isAbsolute15(path) || posix.isAbsolute(path) || win322.isAbsolute(path) || path.includes("\0")) return false;
|
|
25583
25961
|
const value = normalize2(path);
|
|
@@ -26019,7 +26397,7 @@ ${managed.output().slice(-4e3)}`);
|
|
|
26019
26397
|
import { createHash as createHash19, randomUUID as randomUUID23 } from "crypto";
|
|
26020
26398
|
import { copyFile as copyFile2, mkdir as mkdir25, readFile as readFile30, rename as rename13, stat as stat12, unlink as unlink6, writeFile as writeFile15 } from "fs/promises";
|
|
26021
26399
|
import { join as join34 } from "path";
|
|
26022
|
-
import { z as
|
|
26400
|
+
import { z as z42 } from "zod";
|
|
26023
26401
|
|
|
26024
26402
|
// src/e2e/prd-governance.ts
|
|
26025
26403
|
import { createHash as createHash18, randomUUID as randomUUID22 } from "crypto";
|
|
@@ -26138,38 +26516,38 @@ var RelativePrototypePath = "product/prototype/index.html";
|
|
|
26138
26516
|
var RelativeInteractionPath = "product/prototype/interaction-manifest.json";
|
|
26139
26517
|
var defaultPlanFileOperations = { rename: rename13, copyFile: copyFile2, unlink: unlink6 };
|
|
26140
26518
|
var planWriteQueues = /* @__PURE__ */ new Map();
|
|
26141
|
-
var PlanSchema2 =
|
|
26142
|
-
schema:
|
|
26143
|
-
task:
|
|
26144
|
-
revision:
|
|
26145
|
-
phase:
|
|
26146
|
-
framework:
|
|
26147
|
-
technology:
|
|
26148
|
-
frontend:
|
|
26149
|
-
backend:
|
|
26150
|
-
frontendSource:
|
|
26151
|
-
backendSource:
|
|
26519
|
+
var PlanSchema2 = z42.object({
|
|
26520
|
+
schema: z42.literal(1),
|
|
26521
|
+
task: z42.string().regex(D2C_TASK_PATTERN),
|
|
26522
|
+
revision: z42.number().int().nonnegative(),
|
|
26523
|
+
phase: z42.enum(["prd-generating", "prd-review", "design-generating", "design-review", "ready-for-d2c"]),
|
|
26524
|
+
framework: z42.enum(["vue", "react"]),
|
|
26525
|
+
technology: z42.object({
|
|
26526
|
+
frontend: z42.string().trim().min(1).max(64),
|
|
26527
|
+
backend: z42.string().trim().min(1).max(64),
|
|
26528
|
+
frontendSource: z42.enum(["default", "requirement"]),
|
|
26529
|
+
backendSource: z42.enum(["default", "requirement"])
|
|
26152
26530
|
}).strict().optional(),
|
|
26153
|
-
requirement:
|
|
26154
|
-
prd:
|
|
26155
|
-
approvedPrd:
|
|
26156
|
-
hash:
|
|
26157
|
-
approvedAt:
|
|
26158
|
-
criteria:
|
|
26531
|
+
requirement: z42.string().trim().min(2).max(5e4),
|
|
26532
|
+
prd: z42.object({ path: z42.literal(RelativePrdPath), updatedAt: z42.iso.datetime(), contentHash: z42.string().regex(/^[a-f0-9]{64}$/).optional() }).strict().optional(),
|
|
26533
|
+
approvedPrd: z42.object({
|
|
26534
|
+
hash: z42.string().regex(/^[a-f0-9]{64}$/),
|
|
26535
|
+
approvedAt: z42.iso.datetime(),
|
|
26536
|
+
criteria: z42.array(z42.object({ id: z42.string().regex(/^AC-\d{3,}$/), text: z42.string().trim().min(1).max(4e3) }).strict()).min(1).max(1e4)
|
|
26159
26537
|
}).strict().optional(),
|
|
26160
|
-
prototype:
|
|
26161
|
-
entryHtml:
|
|
26162
|
-
interactionManifest:
|
|
26163
|
-
updatedAt:
|
|
26164
|
-
contentHash:
|
|
26538
|
+
prototype: z42.object({
|
|
26539
|
+
entryHtml: z42.literal(RelativePrototypePath),
|
|
26540
|
+
interactionManifest: z42.literal(RelativeInteractionPath),
|
|
26541
|
+
updatedAt: z42.iso.datetime(),
|
|
26542
|
+
contentHash: z42.string().regex(/^[a-f0-9]{64}$/).optional()
|
|
26165
26543
|
}).strict().optional(),
|
|
26166
|
-
feedback:
|
|
26167
|
-
stage:
|
|
26168
|
-
message:
|
|
26169
|
-
updatedAt:
|
|
26544
|
+
feedback: z42.object({
|
|
26545
|
+
stage: z42.enum(["prd", "design"]),
|
|
26546
|
+
message: z42.string().trim().min(1).max(1e4),
|
|
26547
|
+
updatedAt: z42.iso.datetime()
|
|
26170
26548
|
}).strict().optional(),
|
|
26171
|
-
createdAt:
|
|
26172
|
-
updatedAt:
|
|
26549
|
+
createdAt: z42.iso.datetime(),
|
|
26550
|
+
updatedAt: z42.iso.datetime()
|
|
26173
26551
|
}).strict();
|
|
26174
26552
|
function d2cProductDirectory(workspace, task) {
|
|
26175
26553
|
if (!D2C_TASK_PATTERN.test(task)) throw new Error("Invalid D2C task name");
|
|
@@ -26330,10 +26708,10 @@ async function writeD2cProductPlan(workspace, plan, operations = defaultPlanFile
|
|
|
26330
26708
|
return parsed;
|
|
26331
26709
|
}
|
|
26332
26710
|
async function createD2cProductPlan(workspace, input, now = () => /* @__PURE__ */ new Date()) {
|
|
26333
|
-
const parsed =
|
|
26334
|
-
task:
|
|
26335
|
-
framework:
|
|
26336
|
-
requirement:
|
|
26711
|
+
const parsed = z42.object({
|
|
26712
|
+
task: z42.string().regex(D2C_TASK_PATTERN),
|
|
26713
|
+
framework: z42.enum(["vue", "react"]),
|
|
26714
|
+
requirement: z42.string().trim().min(2).max(5e4)
|
|
26337
26715
|
}).strict().parse(input);
|
|
26338
26716
|
const timestamp2 = now().toISOString();
|
|
26339
26717
|
if (await readD2cProductPlan(workspace, parsed.task) !== void 0) {
|
|
@@ -26565,31 +26943,31 @@ function createAcceptanceEvidence(coverage, run, now = /* @__PURE__ */ new Date(
|
|
|
26565
26943
|
// src/e2e/delivery-run.ts
|
|
26566
26944
|
import { createHash as createHash21 } from "crypto";
|
|
26567
26945
|
import { join as join35 } from "path";
|
|
26568
|
-
import { z as
|
|
26946
|
+
import { z as z43 } from "zod";
|
|
26569
26947
|
var DELIVERY_NODE_IDS = ["requirement", "prd", "design", "d2c", "api", "acceptance", "delivery"];
|
|
26570
|
-
var ArtifactSchema =
|
|
26571
|
-
path:
|
|
26572
|
-
hash:
|
|
26573
|
-
bytes:
|
|
26574
|
-
createdAt:
|
|
26948
|
+
var ArtifactSchema = z43.object({
|
|
26949
|
+
path: z43.string().min(1).max(32768),
|
|
26950
|
+
hash: z43.string().regex(/^[a-f0-9]{64}$/),
|
|
26951
|
+
bytes: z43.number().int().nonnegative(),
|
|
26952
|
+
createdAt: z43.iso.datetime()
|
|
26575
26953
|
}).strict();
|
|
26576
|
-
var NodeSchema =
|
|
26577
|
-
id:
|
|
26578
|
-
status:
|
|
26579
|
-
attempt:
|
|
26580
|
-
inputs:
|
|
26581
|
-
outputs:
|
|
26582
|
-
startedAt:
|
|
26583
|
-
completedAt:
|
|
26584
|
-
error:
|
|
26954
|
+
var NodeSchema = z43.object({
|
|
26955
|
+
id: z43.enum(DELIVERY_NODE_IDS),
|
|
26956
|
+
status: z43.enum(["pending", "running", "waiting-approval", "succeeded", "failed", "stale"]),
|
|
26957
|
+
attempt: z43.number().int().nonnegative(),
|
|
26958
|
+
inputs: z43.array(ArtifactSchema).max(1e4),
|
|
26959
|
+
outputs: z43.array(ArtifactSchema).max(1e4),
|
|
26960
|
+
startedAt: z43.iso.datetime().optional(),
|
|
26961
|
+
completedAt: z43.iso.datetime().optional(),
|
|
26962
|
+
error: z43.string().max(2e4).optional()
|
|
26585
26963
|
}).strict();
|
|
26586
|
-
var DeliveryRunSchema =
|
|
26587
|
-
schema:
|
|
26588
|
-
task:
|
|
26589
|
-
revision:
|
|
26590
|
-
nodes:
|
|
26591
|
-
createdAt:
|
|
26592
|
-
updatedAt:
|
|
26964
|
+
var DeliveryRunSchema = z43.object({
|
|
26965
|
+
schema: z43.literal(1),
|
|
26966
|
+
task: z43.string().regex(D2C_TASK_PATTERN),
|
|
26967
|
+
revision: z43.number().int().nonnegative(),
|
|
26968
|
+
nodes: z43.record(z43.enum(DELIVERY_NODE_IDS), NodeSchema),
|
|
26969
|
+
createdAt: z43.iso.datetime(),
|
|
26970
|
+
updatedAt: z43.iso.datetime()
|
|
26593
26971
|
}).strict();
|
|
26594
26972
|
var dependencies = {
|
|
26595
26973
|
requirement: [],
|
|
@@ -26722,7 +27100,7 @@ async function updateDeliveryRun(workspace, task, expectedRevision, mutation) {
|
|
|
26722
27100
|
}
|
|
26723
27101
|
|
|
26724
27102
|
// src/skills/manager.ts
|
|
26725
|
-
import { lstat as lstat13, mkdir as mkdir26, readFile as readFile32, readdir as readdir12, realpath as
|
|
27103
|
+
import { lstat as lstat13, mkdir as mkdir26, readFile as readFile32, readdir as readdir12, realpath as realpath13, rm as rm14, writeFile as writeFile16 } from "fs/promises";
|
|
26726
27104
|
import { homedir as homedir3 } from "os";
|
|
26727
27105
|
import { isAbsolute as isAbsolute16, join as join36, relative as relative24, resolve as resolve31, sep as sep24 } from "path";
|
|
26728
27106
|
import { stringify } from "yaml";
|
|
@@ -26819,7 +27197,7 @@ var SkillManager = class {
|
|
|
26819
27197
|
}
|
|
26820
27198
|
async #summary(metadata, disabled) {
|
|
26821
27199
|
const expected = this.#projectSkillDirectory(metadata.name);
|
|
26822
|
-
const editable = metadata.source === "project" && await
|
|
27200
|
+
const editable = metadata.source === "project" && await realpath13(expected).then((physical) => physical === metadata.root).catch(() => false);
|
|
26823
27201
|
return {
|
|
26824
27202
|
...metadata,
|
|
26825
27203
|
enabled: !disabled.has(metadata.name),
|
|
@@ -26871,14 +27249,14 @@ async function discoverPluginSkillRoots(directory) {
|
|
|
26871
27249
|
const roots = [];
|
|
26872
27250
|
for (const entry2 of entries) {
|
|
26873
27251
|
if (!entry2.isDirectory() || entry2.isSymbolicLink()) continue;
|
|
26874
|
-
const pluginRoot = await
|
|
27252
|
+
const pluginRoot = await realpath13(join36(directory, entry2.name));
|
|
26875
27253
|
try {
|
|
26876
27254
|
const manifest = PluginManifestSchema.parse(JSON.parse(await readFile32(join36(pluginRoot, "flavor-plugin.json"), "utf8")));
|
|
26877
27255
|
for (const contribution of manifest.contributes.skillRoots) {
|
|
26878
27256
|
const candidate = resolve31(pluginRoot, contribution.path);
|
|
26879
27257
|
const info = await lstat13(candidate);
|
|
26880
27258
|
if (!info.isDirectory() || info.isSymbolicLink()) continue;
|
|
26881
|
-
const physical = await
|
|
27259
|
+
const physical = await realpath13(candidate);
|
|
26882
27260
|
const relation = relative24(pluginRoot, physical);
|
|
26883
27261
|
if (relation === ".." || relation.startsWith(`..${sep24}`) || isAbsolute16(relation)) continue;
|
|
26884
27262
|
roots.push(physical);
|
|
@@ -27123,7 +27501,7 @@ function protocolLabel(type) {
|
|
|
27123
27501
|
|
|
27124
27502
|
// src/desktop/d2c-product-preview.ts
|
|
27125
27503
|
import { createReadStream as createReadStream2 } from "fs";
|
|
27126
|
-
import { realpath as
|
|
27504
|
+
import { realpath as realpath14, stat as stat13 } from "fs/promises";
|
|
27127
27505
|
import { createServer as createServer5 } from "http";
|
|
27128
27506
|
import { extname as extname3, isAbsolute as isAbsolute17, relative as relative25, resolve as resolve32, sep as sep25 } from "path";
|
|
27129
27507
|
var MIME_TYPES = {
|
|
@@ -27147,7 +27525,7 @@ function isInside(root, candidate) {
|
|
|
27147
27525
|
return delta === "" || !delta.startsWith(`..${sep25}`) && delta !== ".." && !isAbsolute17(delta);
|
|
27148
27526
|
}
|
|
27149
27527
|
async function startD2cProductPreview(rootDirectory) {
|
|
27150
|
-
const root = await
|
|
27528
|
+
const root = await realpath14(resolve32(rootDirectory));
|
|
27151
27529
|
const rootInfo = await stat13(root);
|
|
27152
27530
|
if (!rootInfo.isDirectory()) throw new Error("D2C product prototype directory is unavailable");
|
|
27153
27531
|
const server = createServer5(async (request, response2) => {
|
|
@@ -27161,7 +27539,7 @@ async function startD2cProductPreview(rootDirectory) {
|
|
|
27161
27539
|
if (pathname.includes("\0")) return sendNotFound(response2);
|
|
27162
27540
|
const unresolved = resolve32(root, `.${pathname}`);
|
|
27163
27541
|
if (!isInside(root, unresolved)) return sendNotFound(response2);
|
|
27164
|
-
const target = await
|
|
27542
|
+
const target = await realpath14(unresolved).catch(() => void 0);
|
|
27165
27543
|
if (target === void 0 || !isInside(root, target)) return sendNotFound(response2);
|
|
27166
27544
|
const info = await stat13(target);
|
|
27167
27545
|
if (!info.isFile()) return sendNotFound(response2);
|
|
@@ -28498,14 +28876,14 @@ ${reason.stack ?? ""}`;
|
|
|
28498
28876
|
|
|
28499
28877
|
// src/desktop/main.ts
|
|
28500
28878
|
installCrashGuard();
|
|
28501
|
-
var moduleDirectory =
|
|
28879
|
+
var moduleDirectory = dirname24(fileURLToPath4(import.meta.url));
|
|
28502
28880
|
var developmentUrl = process.env.FLAVOR_DESKTOP_DEV_URL;
|
|
28503
28881
|
var mainWindow;
|
|
28504
28882
|
var appMenu;
|
|
28505
28883
|
var quitting = false;
|
|
28506
28884
|
function logStartup(step, detail) {
|
|
28507
28885
|
try {
|
|
28508
|
-
const logPath = join41(
|
|
28886
|
+
const logPath = join41(dirname24(process.execPath), "flavor-code-startup.log");
|
|
28509
28887
|
const ts = (/* @__PURE__ */ new Date()).toISOString();
|
|
28510
28888
|
appendFileSync(logPath, `[${ts}] ${step}${detail ? ` | ${detail}` : ""}
|
|
28511
28889
|
`);
|