@pleri/olam-cli 0.1.115 → 0.1.117
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/mcp/serve.d.ts +11 -0
- package/dist/commands/mcp/serve.d.ts.map +1 -1
- package/dist/commands/mcp/serve.js +26 -7
- package/dist/commands/mcp/serve.js.map +1 -1
- package/dist/image-digests.json +1 -1
- package/dist/index.js +892 -708
- package/dist/mcp-server.js +461 -265
- package/package.json +1 -1
package/dist/mcp-server.js
CHANGED
|
@@ -2986,7 +2986,7 @@ var require_compile = __commonJS({
|
|
|
2986
2986
|
const schOrFunc = root.refs[ref];
|
|
2987
2987
|
if (schOrFunc)
|
|
2988
2988
|
return schOrFunc;
|
|
2989
|
-
let _sch =
|
|
2989
|
+
let _sch = resolve9.call(this, root, ref);
|
|
2990
2990
|
if (_sch === void 0) {
|
|
2991
2991
|
const schema = (_a = root.localRefs) === null || _a === void 0 ? void 0 : _a[ref];
|
|
2992
2992
|
const { schemaId } = this.opts;
|
|
@@ -3013,7 +3013,7 @@ var require_compile = __commonJS({
|
|
|
3013
3013
|
function sameSchemaEnv(s1, s2) {
|
|
3014
3014
|
return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
|
|
3015
3015
|
}
|
|
3016
|
-
function
|
|
3016
|
+
function resolve9(root, ref) {
|
|
3017
3017
|
let sch;
|
|
3018
3018
|
while (typeof (sch = this.refs[ref]) == "string")
|
|
3019
3019
|
ref = sch;
|
|
@@ -3228,8 +3228,8 @@ var require_utils = __commonJS({
|
|
|
3228
3228
|
}
|
|
3229
3229
|
return ind;
|
|
3230
3230
|
}
|
|
3231
|
-
function removeDotSegments(
|
|
3232
|
-
let input =
|
|
3231
|
+
function removeDotSegments(path28) {
|
|
3232
|
+
let input = path28;
|
|
3233
3233
|
const output = [];
|
|
3234
3234
|
let nextSlash = -1;
|
|
3235
3235
|
let len = 0;
|
|
@@ -3428,8 +3428,8 @@ var require_schemes = __commonJS({
|
|
|
3428
3428
|
wsComponent.secure = void 0;
|
|
3429
3429
|
}
|
|
3430
3430
|
if (wsComponent.resourceName) {
|
|
3431
|
-
const [
|
|
3432
|
-
wsComponent.path =
|
|
3431
|
+
const [path28, query] = wsComponent.resourceName.split("?");
|
|
3432
|
+
wsComponent.path = path28 && path28 !== "/" ? path28 : void 0;
|
|
3433
3433
|
wsComponent.query = query;
|
|
3434
3434
|
wsComponent.resourceName = void 0;
|
|
3435
3435
|
}
|
|
@@ -3588,7 +3588,7 @@ var require_fast_uri = __commonJS({
|
|
|
3588
3588
|
}
|
|
3589
3589
|
return uri;
|
|
3590
3590
|
}
|
|
3591
|
-
function
|
|
3591
|
+
function resolve9(baseURI, relativeURI, options) {
|
|
3592
3592
|
const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
|
|
3593
3593
|
const resolved = resolveComponent(parse3(baseURI, schemelessOptions), parse3(relativeURI, schemelessOptions), schemelessOptions, true);
|
|
3594
3594
|
schemelessOptions.skipEscape = true;
|
|
@@ -3815,7 +3815,7 @@ var require_fast_uri = __commonJS({
|
|
|
3815
3815
|
var fastUri = {
|
|
3816
3816
|
SCHEMES,
|
|
3817
3817
|
normalize,
|
|
3818
|
-
resolve:
|
|
3818
|
+
resolve: resolve9,
|
|
3819
3819
|
resolveComponent,
|
|
3820
3820
|
equal,
|
|
3821
3821
|
serialize,
|
|
@@ -6791,12 +6791,12 @@ var require_dist = __commonJS({
|
|
|
6791
6791
|
throw new Error(`Unknown format "${name}"`);
|
|
6792
6792
|
return f;
|
|
6793
6793
|
};
|
|
6794
|
-
function addFormats(ajv, list,
|
|
6794
|
+
function addFormats(ajv, list, fs25, exportName) {
|
|
6795
6795
|
var _a;
|
|
6796
6796
|
var _b;
|
|
6797
6797
|
(_a = (_b = ajv.opts.code).formats) !== null && _a !== void 0 ? _a : _b.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
|
|
6798
6798
|
for (const f of list)
|
|
6799
|
-
ajv.addFormat(f,
|
|
6799
|
+
ajv.addFormat(f, fs25[f]);
|
|
6800
6800
|
}
|
|
6801
6801
|
module.exports = exports = formatsPlugin;
|
|
6802
6802
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -7002,10 +7002,10 @@ function assignProp(target, prop, value) {
|
|
|
7002
7002
|
configurable: true
|
|
7003
7003
|
});
|
|
7004
7004
|
}
|
|
7005
|
-
function getElementAtPath(obj,
|
|
7006
|
-
if (!
|
|
7005
|
+
function getElementAtPath(obj, path28) {
|
|
7006
|
+
if (!path28)
|
|
7007
7007
|
return obj;
|
|
7008
|
-
return
|
|
7008
|
+
return path28.reduce((acc, key) => acc?.[key], obj);
|
|
7009
7009
|
}
|
|
7010
7010
|
function promiseAllObject(promisesObj) {
|
|
7011
7011
|
const keys = Object.keys(promisesObj);
|
|
@@ -7325,11 +7325,11 @@ function aborted(x, startIndex = 0) {
|
|
|
7325
7325
|
}
|
|
7326
7326
|
return false;
|
|
7327
7327
|
}
|
|
7328
|
-
function prefixIssues(
|
|
7328
|
+
function prefixIssues(path28, issues) {
|
|
7329
7329
|
return issues.map((iss) => {
|
|
7330
7330
|
var _a;
|
|
7331
7331
|
(_a = iss).path ?? (_a.path = []);
|
|
7332
|
-
iss.path.unshift(
|
|
7332
|
+
iss.path.unshift(path28);
|
|
7333
7333
|
return iss;
|
|
7334
7334
|
});
|
|
7335
7335
|
}
|
|
@@ -12914,12 +12914,12 @@ var StdioServerTransport = class {
|
|
|
12914
12914
|
this.onclose?.();
|
|
12915
12915
|
}
|
|
12916
12916
|
send(message) {
|
|
12917
|
-
return new Promise((
|
|
12917
|
+
return new Promise((resolve9) => {
|
|
12918
12918
|
const json = serializeMessage(message);
|
|
12919
12919
|
if (this._stdout.write(json)) {
|
|
12920
|
-
|
|
12920
|
+
resolve9();
|
|
12921
12921
|
} else {
|
|
12922
|
-
this._stdout.once("drain",
|
|
12922
|
+
this._stdout.once("drain", resolve9);
|
|
12923
12923
|
}
|
|
12924
12924
|
});
|
|
12925
12925
|
}
|
|
@@ -13403,8 +13403,8 @@ function getErrorMap() {
|
|
|
13403
13403
|
|
|
13404
13404
|
// ../../node_modules/zod/v3/helpers/parseUtil.js
|
|
13405
13405
|
var makeIssue = (params) => {
|
|
13406
|
-
const { data, path:
|
|
13407
|
-
const fullPath = [...
|
|
13406
|
+
const { data, path: path28, errorMaps, issueData } = params;
|
|
13407
|
+
const fullPath = [...path28, ...issueData.path || []];
|
|
13408
13408
|
const fullIssue = {
|
|
13409
13409
|
...issueData,
|
|
13410
13410
|
path: fullPath
|
|
@@ -13520,11 +13520,11 @@ var errorUtil;
|
|
|
13520
13520
|
|
|
13521
13521
|
// ../../node_modules/zod/v3/types.js
|
|
13522
13522
|
var ParseInputLazyPath = class {
|
|
13523
|
-
constructor(parent, value,
|
|
13523
|
+
constructor(parent, value, path28, key) {
|
|
13524
13524
|
this._cachedPath = [];
|
|
13525
13525
|
this.parent = parent;
|
|
13526
13526
|
this.data = value;
|
|
13527
|
-
this._path =
|
|
13527
|
+
this._path = path28;
|
|
13528
13528
|
this._key = key;
|
|
13529
13529
|
}
|
|
13530
13530
|
get path() {
|
|
@@ -18987,7 +18987,7 @@ var Protocol = class {
|
|
|
18987
18987
|
return;
|
|
18988
18988
|
}
|
|
18989
18989
|
const pollInterval = task2.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1e3;
|
|
18990
|
-
await new Promise((
|
|
18990
|
+
await new Promise((resolve9) => setTimeout(resolve9, pollInterval));
|
|
18991
18991
|
options?.signal?.throwIfAborted();
|
|
18992
18992
|
}
|
|
18993
18993
|
} catch (error2) {
|
|
@@ -19004,7 +19004,7 @@ var Protocol = class {
|
|
|
19004
19004
|
*/
|
|
19005
19005
|
request(request2, resultSchema, options) {
|
|
19006
19006
|
const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
|
|
19007
|
-
return new Promise((
|
|
19007
|
+
return new Promise((resolve9, reject2) => {
|
|
19008
19008
|
const earlyReject = (error2) => {
|
|
19009
19009
|
reject2(error2);
|
|
19010
19010
|
};
|
|
@@ -19082,7 +19082,7 @@ var Protocol = class {
|
|
|
19082
19082
|
if (!parseResult.success) {
|
|
19083
19083
|
reject2(parseResult.error);
|
|
19084
19084
|
} else {
|
|
19085
|
-
|
|
19085
|
+
resolve9(parseResult.data);
|
|
19086
19086
|
}
|
|
19087
19087
|
} catch (error2) {
|
|
19088
19088
|
reject2(error2);
|
|
@@ -19343,12 +19343,12 @@ var Protocol = class {
|
|
|
19343
19343
|
}
|
|
19344
19344
|
} catch {
|
|
19345
19345
|
}
|
|
19346
|
-
return new Promise((
|
|
19346
|
+
return new Promise((resolve9, reject2) => {
|
|
19347
19347
|
if (signal.aborted) {
|
|
19348
19348
|
reject2(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
19349
19349
|
return;
|
|
19350
19350
|
}
|
|
19351
|
-
const timeoutId = setTimeout(
|
|
19351
|
+
const timeoutId = setTimeout(resolve9, interval);
|
|
19352
19352
|
signal.addEventListener("abort", () => {
|
|
19353
19353
|
clearTimeout(timeoutId);
|
|
19354
19354
|
reject2(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
@@ -20448,7 +20448,7 @@ var McpServer = class {
|
|
|
20448
20448
|
let task = createTaskResult.task;
|
|
20449
20449
|
const pollInterval = task.pollInterval ?? 5e3;
|
|
20450
20450
|
while (task.status !== "completed" && task.status !== "failed" && task.status !== "cancelled") {
|
|
20451
|
-
await new Promise((
|
|
20451
|
+
await new Promise((resolve9) => setTimeout(resolve9, pollInterval));
|
|
20452
20452
|
const updatedTask = await extra.taskStore.getTask(taskId);
|
|
20453
20453
|
if (!updatedTask) {
|
|
20454
20454
|
throw new McpError(ErrorCode.InternalError, `Task ${taskId} not found during polling`);
|
|
@@ -21365,8 +21365,8 @@ var AuthClient = class {
|
|
|
21365
21365
|
throw new Error(`failed to report rate-limit for ${accountId} (HTTP ${res.status})`);
|
|
21366
21366
|
}
|
|
21367
21367
|
}
|
|
21368
|
-
async request(method,
|
|
21369
|
-
const url = `${this.baseUrl}${
|
|
21368
|
+
async request(method, path28, body, attempt = 0) {
|
|
21369
|
+
const url = `${this.baseUrl}${path28}`;
|
|
21370
21370
|
const controller = new AbortController();
|
|
21371
21371
|
const timer = setTimeout(() => controller.abort(), this.timeoutMs);
|
|
21372
21372
|
const headers = {};
|
|
@@ -21384,7 +21384,7 @@ var AuthClient = class {
|
|
|
21384
21384
|
} catch (err) {
|
|
21385
21385
|
if (attempt < RETRY_COUNT && isTransient(err)) {
|
|
21386
21386
|
await sleep(RETRY_BACKOFF_MS * (attempt + 1));
|
|
21387
|
-
return this.request(method,
|
|
21387
|
+
return this.request(method, path28, body, attempt + 1);
|
|
21388
21388
|
}
|
|
21389
21389
|
throw err;
|
|
21390
21390
|
} finally {
|
|
@@ -21411,7 +21411,7 @@ async function safeText(res) {
|
|
|
21411
21411
|
}
|
|
21412
21412
|
}
|
|
21413
21413
|
function sleep(ms) {
|
|
21414
|
-
return new Promise((
|
|
21414
|
+
return new Promise((resolve9) => setTimeout(resolve9, ms));
|
|
21415
21415
|
}
|
|
21416
21416
|
|
|
21417
21417
|
// ../core/dist/auth/container.js
|
|
@@ -21543,7 +21543,7 @@ function resolveAuthServicePath() {
|
|
|
21543
21543
|
return path3.join(pkgsDir, "auth-service");
|
|
21544
21544
|
}
|
|
21545
21545
|
function sleep2(ms) {
|
|
21546
|
-
return new Promise((
|
|
21546
|
+
return new Promise((resolve9) => setTimeout(resolve9, ms));
|
|
21547
21547
|
}
|
|
21548
21548
|
|
|
21549
21549
|
// ../core/dist/auth/preflight.js
|
|
@@ -22212,12 +22212,12 @@ function register3(server, _ctx, _initError) {
|
|
|
22212
22212
|
registry2.close();
|
|
22213
22213
|
}
|
|
22214
22214
|
try {
|
|
22215
|
-
const { default:
|
|
22215
|
+
const { default: fs25 } = await import("node:fs");
|
|
22216
22216
|
const { default: os15 } = await import("node:os");
|
|
22217
|
-
const { default:
|
|
22218
|
-
const tokenPath =
|
|
22219
|
-
if (
|
|
22220
|
-
const token =
|
|
22217
|
+
const { default: path28 } = await import("node:path");
|
|
22218
|
+
const tokenPath = path28.join(os15.homedir(), ".olam", "host-cp.token");
|
|
22219
|
+
if (fs25.existsSync(tokenPath)) {
|
|
22220
|
+
const token = fs25.readFileSync(tokenPath, "utf-8").trim();
|
|
22221
22221
|
await fetch("http://127.0.0.1:19000/api/admin/world-pr", {
|
|
22222
22222
|
method: "POST",
|
|
22223
22223
|
headers: { "Content-Type": "application/json", Authorization: `Bearer ${token}` },
|
|
@@ -22412,7 +22412,7 @@ var KNOWN_TOP_LEVEL_KEYS = /* @__PURE__ */ new Set([
|
|
|
22412
22412
|
"deploy"
|
|
22413
22413
|
]);
|
|
22414
22414
|
var FORBIDDEN_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
22415
|
-
function refineForbiddenKeys(value,
|
|
22415
|
+
function refineForbiddenKeys(value, path28, ctx, rejectSource) {
|
|
22416
22416
|
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
22417
22417
|
return;
|
|
22418
22418
|
}
|
|
@@ -22420,12 +22420,12 @@ function refineForbiddenKeys(value, path27, ctx, rejectSource) {
|
|
|
22420
22420
|
if (FORBIDDEN_KEYS.has(key)) {
|
|
22421
22421
|
ctx.addIssue({
|
|
22422
22422
|
code: external_exports.ZodIssueCode.custom,
|
|
22423
|
-
path: [...
|
|
22423
|
+
path: [...path28, key],
|
|
22424
22424
|
message: `forbidden key "${key}" (prototype-pollution surface)`
|
|
22425
22425
|
});
|
|
22426
22426
|
continue;
|
|
22427
22427
|
}
|
|
22428
|
-
if (rejectSource &&
|
|
22428
|
+
if (rejectSource && path28.length === 0 && key === "source") {
|
|
22429
22429
|
ctx.addIssue({
|
|
22430
22430
|
code: external_exports.ZodIssueCode.custom,
|
|
22431
22431
|
path: ["source"],
|
|
@@ -22433,21 +22433,21 @@ function refineForbiddenKeys(value, path27, ctx, rejectSource) {
|
|
|
22433
22433
|
});
|
|
22434
22434
|
continue;
|
|
22435
22435
|
}
|
|
22436
|
-
refineForbiddenKeys(value[key], [...
|
|
22436
|
+
refineForbiddenKeys(value[key], [...path28, key], ctx, false);
|
|
22437
22437
|
}
|
|
22438
22438
|
}
|
|
22439
|
-
function rejectForbiddenKeys(value,
|
|
22439
|
+
function rejectForbiddenKeys(value, path28, rejectSource) {
|
|
22440
22440
|
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
22441
22441
|
return;
|
|
22442
22442
|
}
|
|
22443
22443
|
for (const key of Object.keys(value)) {
|
|
22444
22444
|
if (FORBIDDEN_KEYS.has(key)) {
|
|
22445
|
-
throw new Error(`[manifest] ${
|
|
22445
|
+
throw new Error(`[manifest] ${path28}: forbidden key "${key}" (prototype-pollution surface)`);
|
|
22446
22446
|
}
|
|
22447
22447
|
if (rejectSource && key === "source") {
|
|
22448
|
-
throw new Error(`[manifest] ${
|
|
22448
|
+
throw new Error(`[manifest] ${path28}: top-level "source" is loader-stamped \u2014 manifests must not author it`);
|
|
22449
22449
|
}
|
|
22450
|
-
rejectForbiddenKeys(value[key], `${
|
|
22450
|
+
rejectForbiddenKeys(value[key], `${path28}.${key}`, false);
|
|
22451
22451
|
}
|
|
22452
22452
|
}
|
|
22453
22453
|
function unknownTopLevelKeys(parsed) {
|
|
@@ -22885,10 +22885,10 @@ function extractMcpConfig(claudeJsonPath) {
|
|
|
22885
22885
|
}
|
|
22886
22886
|
return { mcpServers, secrets };
|
|
22887
22887
|
}
|
|
22888
|
-
function readOptional(
|
|
22889
|
-
if (!existsSync6(
|
|
22888
|
+
function readOptional(path28) {
|
|
22889
|
+
if (!existsSync6(path28)) return null;
|
|
22890
22890
|
try {
|
|
22891
|
-
return readFileSync5(
|
|
22891
|
+
return readFileSync5(path28, "utf8");
|
|
22892
22892
|
} catch {
|
|
22893
22893
|
return null;
|
|
22894
22894
|
}
|
|
@@ -23012,7 +23012,7 @@ var realDocker = {
|
|
|
23012
23012
|
}
|
|
23013
23013
|
};
|
|
23014
23014
|
function spawnAsync(cmd, args, opts = {}) {
|
|
23015
|
-
return new Promise((
|
|
23015
|
+
return new Promise((resolve9) => {
|
|
23016
23016
|
const child = spawn(cmd, [...args], {
|
|
23017
23017
|
stdio: ["ignore", "pipe", "pipe"],
|
|
23018
23018
|
signal: opts.signal
|
|
@@ -23026,10 +23026,10 @@ function spawnAsync(cmd, args, opts = {}) {
|
|
|
23026
23026
|
stderr += chunk.toString();
|
|
23027
23027
|
});
|
|
23028
23028
|
child.on("error", (err) => {
|
|
23029
|
-
|
|
23029
|
+
resolve9({ exitCode: -1, stdout, stderr: stderr + err.message });
|
|
23030
23030
|
});
|
|
23031
23031
|
child.on("close", (code) => {
|
|
23032
|
-
|
|
23032
|
+
resolve9({ exitCode: code ?? -1, stdout, stderr });
|
|
23033
23033
|
});
|
|
23034
23034
|
});
|
|
23035
23035
|
}
|
|
@@ -23362,7 +23362,7 @@ var stopAndRemove = async (container) => {
|
|
|
23362
23362
|
|
|
23363
23363
|
// ../adapters/dist/docker/exec.js
|
|
23364
23364
|
import { PassThrough } from "node:stream";
|
|
23365
|
-
var demuxStream = (stream) => new Promise((
|
|
23365
|
+
var demuxStream = (stream) => new Promise((resolve9, reject2) => {
|
|
23366
23366
|
const stdoutChunks = [];
|
|
23367
23367
|
const stderrChunks = [];
|
|
23368
23368
|
const stdout = new PassThrough();
|
|
@@ -23376,7 +23376,7 @@ var demuxStream = (stream) => new Promise((resolve8, reject2) => {
|
|
|
23376
23376
|
stream.pipe(stdout);
|
|
23377
23377
|
}
|
|
23378
23378
|
stream.on("end", () => {
|
|
23379
|
-
|
|
23379
|
+
resolve9({
|
|
23380
23380
|
stdout: Buffer.concat(stdoutChunks).toString("utf-8"),
|
|
23381
23381
|
stderr: Buffer.concat(stderrChunks).toString("utf-8")
|
|
23382
23382
|
});
|
|
@@ -23721,7 +23721,7 @@ var SSHConnectionPool = class {
|
|
|
23721
23721
|
// -----------------------------------------------------------------------
|
|
23722
23722
|
async exec(host, command) {
|
|
23723
23723
|
const client = await this.getConnection(host);
|
|
23724
|
-
return new Promise((
|
|
23724
|
+
return new Promise((resolve9, reject2) => {
|
|
23725
23725
|
client.exec(command, (err, stream) => {
|
|
23726
23726
|
if (err) {
|
|
23727
23727
|
reject2(new Error(`SSH exec failed on ${host}: ${err.message}`));
|
|
@@ -23736,7 +23736,7 @@ var SSHConnectionPool = class {
|
|
|
23736
23736
|
stderr += data.toString();
|
|
23737
23737
|
});
|
|
23738
23738
|
stream.on("close", (code) => {
|
|
23739
|
-
|
|
23739
|
+
resolve9({
|
|
23740
23740
|
exitCode: code ?? 0,
|
|
23741
23741
|
stdout: stdout.trimEnd(),
|
|
23742
23742
|
stderr: stderr.trimEnd()
|
|
@@ -23767,10 +23767,10 @@ var SSHConnectionPool = class {
|
|
|
23767
23767
|
throw new Error(`No SSH configuration found for host: ${host}`);
|
|
23768
23768
|
}
|
|
23769
23769
|
const client = new SSHClient();
|
|
23770
|
-
return new Promise((
|
|
23770
|
+
return new Promise((resolve9, reject2) => {
|
|
23771
23771
|
client.on("ready", () => {
|
|
23772
23772
|
this.connections.set(host, client);
|
|
23773
|
-
|
|
23773
|
+
resolve9(client);
|
|
23774
23774
|
}).on("error", (err) => {
|
|
23775
23775
|
this.connections.delete(host);
|
|
23776
23776
|
reject2(new Error(`SSH connection to ${host} failed: ${err.message}`));
|
|
@@ -24187,8 +24187,8 @@ var CloudflareProvider = class extends ComputeProvider {
|
|
|
24187
24187
|
// -----------------------------------------------------------------------
|
|
24188
24188
|
// Internal fetch helper
|
|
24189
24189
|
// -----------------------------------------------------------------------
|
|
24190
|
-
async request(
|
|
24191
|
-
const url = `${this.config.workerUrl}${
|
|
24190
|
+
async request(path28, method, body) {
|
|
24191
|
+
const url = `${this.config.workerUrl}${path28}`;
|
|
24192
24192
|
const bearer = await this.config.mintToken();
|
|
24193
24193
|
const headers = {
|
|
24194
24194
|
Authorization: `Bearer ${bearer}`
|
|
@@ -24750,7 +24750,7 @@ function register6(server, ctx, initError) {
|
|
|
24750
24750
|
}
|
|
24751
24751
|
} catch {
|
|
24752
24752
|
}
|
|
24753
|
-
await new Promise((
|
|
24753
|
+
await new Promise((resolve9) => setTimeout(resolve9, POLL_INTERVAL_MS));
|
|
24754
24754
|
}
|
|
24755
24755
|
}
|
|
24756
24756
|
if (authenticated) {
|
|
@@ -26627,10 +26627,10 @@ async function writeManifest(args) {
|
|
|
26627
26627
|
capturedAt: args.capturedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
26628
26628
|
shots: entries
|
|
26629
26629
|
};
|
|
26630
|
-
const
|
|
26631
|
-
await writeFile(
|
|
26630
|
+
const path28 = join12(args.outDir, "manifest.json");
|
|
26631
|
+
await writeFile(path28, `${JSON.stringify(manifest, null, 2)}
|
|
26632
26632
|
`, "utf8");
|
|
26633
|
-
return { path:
|
|
26633
|
+
return { path: path28, manifest };
|
|
26634
26634
|
}
|
|
26635
26635
|
|
|
26636
26636
|
// ../mcp-server/src/tools/_capture/proxy.ts
|
|
@@ -26884,9 +26884,9 @@ async function startProxy(opts) {
|
|
|
26884
26884
|
const liveCompiled = verified.allowedPaths.map(compileGlob);
|
|
26885
26885
|
const target = parseRequestTarget(req);
|
|
26886
26886
|
if (!target) return httpReject(400, "invalid_target");
|
|
26887
|
-
const
|
|
26888
|
-
if (!liveCompiled.some((re) => re.test(
|
|
26889
|
-
return httpReject(403, "outside_allow_list", { path:
|
|
26887
|
+
const path28 = target.pathname;
|
|
26888
|
+
if (!liveCompiled.some((re) => re.test(path28))) {
|
|
26889
|
+
return httpReject(403, "outside_allow_list", { path: path28 });
|
|
26890
26890
|
}
|
|
26891
26891
|
const headerWorld = req.headers[WORLD_ASSERT_HEADER];
|
|
26892
26892
|
const headerWorldStr = typeof headerWorld === "string" ? headerWorld : Array.isArray(headerWorld) && headerWorld.length > 0 ? headerWorld[0] : void 0;
|
|
@@ -26990,15 +26990,15 @@ ${JSON.stringify({ error: reason })}`
|
|
|
26990
26990
|
unlinkSync2(udsPath);
|
|
26991
26991
|
} catch {
|
|
26992
26992
|
}
|
|
26993
|
-
await new Promise((
|
|
26994
|
-
server.listen(udsPath, () =>
|
|
26993
|
+
await new Promise((resolve9, reject2) => {
|
|
26994
|
+
server.listen(udsPath, () => resolve9());
|
|
26995
26995
|
server.once("error", reject2);
|
|
26996
26996
|
});
|
|
26997
26997
|
chmodSync3(udsPath, 384);
|
|
26998
26998
|
port = 0;
|
|
26999
26999
|
} else {
|
|
27000
|
-
await new Promise((
|
|
27001
|
-
server.listen(opts.port ?? 0, "127.0.0.1", () =>
|
|
27000
|
+
await new Promise((resolve9, reject2) => {
|
|
27001
|
+
server.listen(opts.port ?? 0, "127.0.0.1", () => resolve9());
|
|
27002
27002
|
server.once("error", reject2);
|
|
27003
27003
|
});
|
|
27004
27004
|
const addr = server.address();
|
|
@@ -27014,10 +27014,10 @@ ${JSON.stringify({ error: reason })}`
|
|
|
27014
27014
|
} catch {
|
|
27015
27015
|
}
|
|
27016
27016
|
await Promise.race([
|
|
27017
|
-
new Promise((
|
|
27018
|
-
server.close((err) => err ? reject2(err) :
|
|
27017
|
+
new Promise((resolve9, reject2) => {
|
|
27018
|
+
server.close((err) => err ? reject2(err) : resolve9());
|
|
27019
27019
|
}),
|
|
27020
|
-
new Promise((
|
|
27020
|
+
new Promise((resolve9) => setTimeout(resolve9, 5e3))
|
|
27021
27021
|
]);
|
|
27022
27022
|
if (udsPath) {
|
|
27023
27023
|
try {
|
|
@@ -27349,10 +27349,10 @@ async function acquireLaunchSlot() {
|
|
|
27349
27349
|
_inFlightLaunches++;
|
|
27350
27350
|
return releaseLaunchSlot;
|
|
27351
27351
|
}
|
|
27352
|
-
return new Promise((
|
|
27352
|
+
return new Promise((resolve9) => {
|
|
27353
27353
|
_launchQueue.push(() => {
|
|
27354
27354
|
_inFlightLaunches++;
|
|
27355
|
-
|
|
27355
|
+
resolve9(releaseLaunchSlot);
|
|
27356
27356
|
});
|
|
27357
27357
|
});
|
|
27358
27358
|
}
|
|
@@ -27665,14 +27665,14 @@ async function runShot(browser, shot, outDir, format, jpegQuality, allowEval, as
|
|
|
27665
27665
|
await page.waitForTimeout(shot.afterLoadMs);
|
|
27666
27666
|
}
|
|
27667
27667
|
const ext = format === "jpeg" ? "jpg" : "png";
|
|
27668
|
-
const
|
|
27668
|
+
const path28 = join13(outDir, `${shot.name}.${ext}`);
|
|
27669
27669
|
await page.screenshot({
|
|
27670
|
-
path:
|
|
27670
|
+
path: path28,
|
|
27671
27671
|
type: format,
|
|
27672
27672
|
...format === "jpeg" ? { quality: jpegQuality } : {},
|
|
27673
27673
|
fullPage: false
|
|
27674
27674
|
});
|
|
27675
|
-
return { name: shot.name, path:
|
|
27675
|
+
return { name: shot.name, path: path28, urlRedacted: redactUrl(shot.url), viewport };
|
|
27676
27676
|
} finally {
|
|
27677
27677
|
await context.close();
|
|
27678
27678
|
}
|
|
@@ -28115,12 +28115,12 @@ function openUrl(url) {
|
|
|
28115
28115
|
var HOST_CP_URL = "http://127.0.0.1:19000";
|
|
28116
28116
|
async function readHostCpToken2() {
|
|
28117
28117
|
try {
|
|
28118
|
-
const { default:
|
|
28118
|
+
const { default: fs25 } = await import("node:fs");
|
|
28119
28119
|
const { default: os15 } = await import("node:os");
|
|
28120
|
-
const { default:
|
|
28121
|
-
const tp =
|
|
28122
|
-
if (!
|
|
28123
|
-
return { token:
|
|
28120
|
+
const { default: path28 } = await import("node:path");
|
|
28121
|
+
const tp = path28.join(os15.homedir(), ".olam", "host-cp.token");
|
|
28122
|
+
if (!fs25.existsSync(tp)) return { token: null };
|
|
28123
|
+
return { token: fs25.readFileSync(tp, "utf-8").trim() };
|
|
28124
28124
|
} catch {
|
|
28125
28125
|
return { token: null };
|
|
28126
28126
|
}
|
|
@@ -28762,9 +28762,9 @@ function register22(server, _ctx, _initError) {
|
|
|
28762
28762
|
description: external_exports.string().optional().describe("Optional human-readable description."),
|
|
28763
28763
|
defaultBranch: external_exports.string().optional().describe("Default branch name (e.g. main).")
|
|
28764
28764
|
},
|
|
28765
|
-
async ({ name, path:
|
|
28765
|
+
async ({ name, path: path28, description, defaultBranch }) => {
|
|
28766
28766
|
try {
|
|
28767
|
-
const entry = addRepo({ name, path:
|
|
28767
|
+
const entry = addRepo({ name, path: path28, description, defaultBranch });
|
|
28768
28768
|
return {
|
|
28769
28769
|
content: [{
|
|
28770
28770
|
type: "text",
|
|
@@ -28805,9 +28805,9 @@ function register22(server, _ctx, _initError) {
|
|
|
28805
28805
|
description: external_exports.string().optional().describe("New description."),
|
|
28806
28806
|
defaultBranch: external_exports.string().optional().describe("New default branch.")
|
|
28807
28807
|
},
|
|
28808
|
-
async ({ name, path:
|
|
28808
|
+
async ({ name, path: path28, description, defaultBranch }) => {
|
|
28809
28809
|
try {
|
|
28810
|
-
const entry = updateRepo(name, { path:
|
|
28810
|
+
const entry = updateRepo(name, { path: path28, description, defaultBranch });
|
|
28811
28811
|
return {
|
|
28812
28812
|
content: [{
|
|
28813
28813
|
type: "text",
|
|
@@ -29638,9 +29638,9 @@ function loadConfig(startDir) {
|
|
|
29638
29638
|
// ../core/dist/world/manager.js
|
|
29639
29639
|
import * as crypto5 from "node:crypto";
|
|
29640
29640
|
import { execSync as execSync5 } from "node:child_process";
|
|
29641
|
-
import * as
|
|
29641
|
+
import * as fs22 from "node:fs";
|
|
29642
29642
|
import * as os13 from "node:os";
|
|
29643
|
-
import * as
|
|
29643
|
+
import * as path25 from "node:path";
|
|
29644
29644
|
|
|
29645
29645
|
// ../core/dist/world/state.js
|
|
29646
29646
|
var VALID_TRANSITIONS = {
|
|
@@ -29857,14 +29857,183 @@ function removeBranch(repo, branch) {
|
|
|
29857
29857
|
return { branch, action: "kept-local-commits", localCommitCount };
|
|
29858
29858
|
}
|
|
29859
29859
|
|
|
29860
|
-
// ../core/dist/world/
|
|
29860
|
+
// ../core/dist/world/kg-overlay.js
|
|
29861
29861
|
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
29862
29862
|
import * as fs15 from "node:fs";
|
|
29863
|
-
import * as os10 from "node:os";
|
|
29864
29863
|
import * as path17 from "node:path";
|
|
29864
|
+
|
|
29865
|
+
// ../core/dist/kg/storage-paths.js
|
|
29866
|
+
import { homedir as homedir10 } from "node:os";
|
|
29867
|
+
import { join as join18, resolve as resolve4 } from "node:path";
|
|
29868
|
+
|
|
29869
|
+
// ../core/dist/world/workspace-name.js
|
|
29870
|
+
var InvalidWorkspaceNameError = class extends Error {
|
|
29871
|
+
constructor(name, reason) {
|
|
29872
|
+
super(`invalid workspace name ${JSON.stringify(name)}: ${reason}`);
|
|
29873
|
+
this.name = "InvalidWorkspaceNameError";
|
|
29874
|
+
}
|
|
29875
|
+
};
|
|
29876
|
+
var WORKSPACE_NAME_RE = /^[a-z0-9][a-z0-9_-]*$/;
|
|
29877
|
+
function validateWorkspaceName(name) {
|
|
29878
|
+
if (typeof name !== "string" || name.length === 0) {
|
|
29879
|
+
throw new InvalidWorkspaceNameError(String(name), "must be a non-empty string");
|
|
29880
|
+
}
|
|
29881
|
+
if (!WORKSPACE_NAME_RE.test(name)) {
|
|
29882
|
+
throw new InvalidWorkspaceNameError(name, "must match ^[a-z0-9][a-z0-9_-]*$ (lowercase letters, digits, hyphens, underscores; must start with letter or digit)");
|
|
29883
|
+
}
|
|
29884
|
+
}
|
|
29885
|
+
|
|
29886
|
+
// ../core/dist/kg/storage-paths.js
|
|
29887
|
+
function olamHome() {
|
|
29888
|
+
return process.env.OLAM_HOME ?? join18(homedir10(), ".olam");
|
|
29889
|
+
}
|
|
29890
|
+
function kgRoot() {
|
|
29891
|
+
return join18(olamHome(), "kg");
|
|
29892
|
+
}
|
|
29893
|
+
function worldsRoot() {
|
|
29894
|
+
return join18(olamHome(), "worlds");
|
|
29895
|
+
}
|
|
29896
|
+
function assertWithinPrefix(path28, prefix, label) {
|
|
29897
|
+
if (!path28.startsWith(prefix + "/")) {
|
|
29898
|
+
throw new Error(`${label} escape: ${path28} not under ${prefix}/`);
|
|
29899
|
+
}
|
|
29900
|
+
}
|
|
29901
|
+
function kgPristinePath(workspace) {
|
|
29902
|
+
validateWorkspaceName(workspace);
|
|
29903
|
+
const root = kgRoot();
|
|
29904
|
+
const path28 = resolve4(join18(root, workspace));
|
|
29905
|
+
assertWithinPrefix(path28, root, "kgPristinePath");
|
|
29906
|
+
return path28;
|
|
29907
|
+
}
|
|
29908
|
+
var KG_PATHS_INTERNALS = Object.freeze({
|
|
29909
|
+
olamHome,
|
|
29910
|
+
kgRoot,
|
|
29911
|
+
worldsRoot
|
|
29912
|
+
});
|
|
29913
|
+
|
|
29914
|
+
// ../core/dist/world/kg-overlay.js
|
|
29915
|
+
var KgOverlayError = class extends Error {
|
|
29916
|
+
constructor(message) {
|
|
29917
|
+
super(message);
|
|
29918
|
+
this.name = "KgOverlayError";
|
|
29919
|
+
}
|
|
29920
|
+
};
|
|
29921
|
+
function ensureGitignoreEntry(worldClonePath) {
|
|
29922
|
+
const gitignorePath = path17.join(worldClonePath, ".gitignore");
|
|
29923
|
+
if (!fs15.existsSync(gitignorePath))
|
|
29924
|
+
return "no-gitignore";
|
|
29925
|
+
const content = fs15.readFileSync(gitignorePath, "utf-8");
|
|
29926
|
+
const lines = content.split("\n").map((l) => l.trim());
|
|
29927
|
+
const recognised = /* @__PURE__ */ new Set([
|
|
29928
|
+
"graphify-out",
|
|
29929
|
+
"graphify-out/",
|
|
29930
|
+
"/graphify-out",
|
|
29931
|
+
"/graphify-out/",
|
|
29932
|
+
"**/graphify-out",
|
|
29933
|
+
"**/graphify-out/"
|
|
29934
|
+
]);
|
|
29935
|
+
if (lines.some((l) => recognised.has(l)))
|
|
29936
|
+
return "present";
|
|
29937
|
+
const eol = content.includes("\r\n") ? "\r\n" : "\n";
|
|
29938
|
+
const needsLeadingNewline = content.length > 0 && !content.endsWith(eol);
|
|
29939
|
+
const block = `${needsLeadingNewline ? eol : ""}${eol}# olam-kg-service: per-world KG overlay (Phase B1)${eol}graphify-out/${eol}`;
|
|
29940
|
+
fs15.appendFileSync(gitignorePath, block, "utf-8");
|
|
29941
|
+
return "appended";
|
|
29942
|
+
}
|
|
29943
|
+
function createWorldOverlay(opts) {
|
|
29944
|
+
const pristineRoot = kgPristinePath(opts.workspace);
|
|
29945
|
+
const pristinePath = path17.join(pristineRoot, "graphify-out");
|
|
29946
|
+
if (!fs15.existsSync(pristinePath)) {
|
|
29947
|
+
throw new KgOverlayError(`Pristine KG for workspace ${JSON.stringify(opts.workspace)} not found at ${pristinePath}. Run \`olam kg build ${opts.workspace}\` first.`);
|
|
29948
|
+
}
|
|
29949
|
+
if (!path17.isAbsolute(opts.worldClonePath)) {
|
|
29950
|
+
throw new KgOverlayError(`worldClonePath must be absolute (got ${opts.worldClonePath})`);
|
|
29951
|
+
}
|
|
29952
|
+
if (!fs15.existsSync(opts.worldClonePath)) {
|
|
29953
|
+
throw new KgOverlayError(`worldClonePath does not exist: ${opts.worldClonePath}. Create the clone before reflinking.`);
|
|
29954
|
+
}
|
|
29955
|
+
const overlayPath = path17.join(opts.worldClonePath, "graphify-out");
|
|
29956
|
+
if (fs15.existsSync(overlayPath)) {
|
|
29957
|
+
fs15.rmSync(overlayPath, { recursive: true, force: true });
|
|
29958
|
+
}
|
|
29959
|
+
const useReflink = process.platform === "darwin";
|
|
29960
|
+
let strategy;
|
|
29961
|
+
let reflinkError;
|
|
29962
|
+
if (useReflink) {
|
|
29963
|
+
try {
|
|
29964
|
+
execFileSync3("cp", ["-c", "-r", pristinePath, opts.worldClonePath], {
|
|
29965
|
+
stdio: ["ignore", "ignore", "pipe"]
|
|
29966
|
+
});
|
|
29967
|
+
strategy = "cp-c-r-reflink";
|
|
29968
|
+
} catch (err) {
|
|
29969
|
+
reflinkError = err;
|
|
29970
|
+
strategy = "cp-r";
|
|
29971
|
+
}
|
|
29972
|
+
} else {
|
|
29973
|
+
strategy = "cp-r";
|
|
29974
|
+
}
|
|
29975
|
+
if (strategy === "cp-r" || !fs15.existsSync(overlayPath)) {
|
|
29976
|
+
try {
|
|
29977
|
+
execFileSync3("cp", ["-r", pristinePath, opts.worldClonePath], {
|
|
29978
|
+
stdio: ["ignore", "ignore", "pipe"]
|
|
29979
|
+
});
|
|
29980
|
+
strategy = "cp-r";
|
|
29981
|
+
} catch (err) {
|
|
29982
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
29983
|
+
const reflinkMsg = reflinkError instanceof Error ? ` (reflink also failed: ${reflinkError.message})` : "";
|
|
29984
|
+
throw new KgOverlayError(`cp -r failed: ${msg}${reflinkMsg}`);
|
|
29985
|
+
}
|
|
29986
|
+
}
|
|
29987
|
+
if (!fs15.existsSync(overlayPath)) {
|
|
29988
|
+
throw new KgOverlayError(`Overlay creation produced no ${overlayPath} after cp \u2014 filesystem returned without error?`);
|
|
29989
|
+
}
|
|
29990
|
+
const gitignoreAction = ensureGitignoreEntry(opts.worldClonePath);
|
|
29991
|
+
return {
|
|
29992
|
+
pristinePath,
|
|
29993
|
+
overlayPath,
|
|
29994
|
+
strategy,
|
|
29995
|
+
gitignoreAction
|
|
29996
|
+
};
|
|
29997
|
+
}
|
|
29998
|
+
|
|
29999
|
+
// ../core/dist/world/kg-install-hook.js
|
|
30000
|
+
import { execFileSync as execFileSync4 } from "node:child_process";
|
|
30001
|
+
var KgHookInstallError = class extends Error {
|
|
30002
|
+
constructor(message) {
|
|
30003
|
+
super(message);
|
|
30004
|
+
this.name = "KgHookInstallError";
|
|
30005
|
+
}
|
|
30006
|
+
};
|
|
30007
|
+
function installGraphifyHookInWorld(opts) {
|
|
30008
|
+
const timeout = opts.timeoutMs ?? 3e4;
|
|
30009
|
+
try {
|
|
30010
|
+
execFileSync4("docker", [
|
|
30011
|
+
"exec",
|
|
30012
|
+
"-u",
|
|
30013
|
+
"olam",
|
|
30014
|
+
"-w",
|
|
30015
|
+
`/home/olam/workspace/${opts.repoName}`,
|
|
30016
|
+
opts.containerName,
|
|
30017
|
+
"graphify",
|
|
30018
|
+
"claude",
|
|
30019
|
+
"install",
|
|
30020
|
+
"--platform",
|
|
30021
|
+
"claude"
|
|
30022
|
+
], { stdio: ["ignore", "pipe", "pipe"], encoding: "utf-8", timeout });
|
|
30023
|
+
} catch (err) {
|
|
30024
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
30025
|
+
throw new KgHookInstallError(`graphify claude install failed in ${opts.containerName} (repo=${opts.repoName}): ${msg}`);
|
|
30026
|
+
}
|
|
30027
|
+
}
|
|
30028
|
+
|
|
30029
|
+
// ../core/dist/world/baseline-diff.js
|
|
30030
|
+
import { execFileSync as execFileSync5 } from "node:child_process";
|
|
30031
|
+
import * as fs16 from "node:fs";
|
|
30032
|
+
import * as os10 from "node:os";
|
|
30033
|
+
import * as path18 from "node:path";
|
|
29865
30034
|
var DEFAULT_MAX_BUFFER_BYTES = 50 * 1024 * 1024;
|
|
29866
|
-
function expandHome(p,
|
|
29867
|
-
return p.replace(/^~(?=$|\/|\\)/,
|
|
30035
|
+
function expandHome(p, homedir16) {
|
|
30036
|
+
return p.replace(/^~(?=$|\/|\\)/, homedir16());
|
|
29868
30037
|
}
|
|
29869
30038
|
function sanitizeRepoFilename(name) {
|
|
29870
30039
|
const sanitized = name.replace(/[^A-Za-z0-9._-]/g, "_");
|
|
@@ -29886,11 +30055,11 @@ ${stderr}`;
|
|
|
29886
30055
|
return /unknown revision|bad revision|does not have any commits|HEAD'?: ambiguous|Needed a single revision/.test(blob);
|
|
29887
30056
|
}
|
|
29888
30057
|
function snapshotBaselineDiff(repos, workspacePath, deps = {}) {
|
|
29889
|
-
const exec = deps.exec ?? ((cmd, args, opts) =>
|
|
29890
|
-
const
|
|
29891
|
-
const baselineDir =
|
|
30058
|
+
const exec = deps.exec ?? ((cmd, args, opts) => execFileSync5(cmd, args, opts));
|
|
30059
|
+
const homedir16 = deps.homedir ?? (() => os10.homedir());
|
|
30060
|
+
const baselineDir = path18.join(workspacePath, ".olam", "baseline");
|
|
29892
30061
|
try {
|
|
29893
|
-
|
|
30062
|
+
fs16.mkdirSync(baselineDir, { recursive: true });
|
|
29894
30063
|
} catch (err) {
|
|
29895
30064
|
const msg = err instanceof Error ? err.message : String(err);
|
|
29896
30065
|
console.warn(`[baseline-diff] mkdir ${baselineDir} failed: ${msg}; reaper will see no baseline at all`);
|
|
@@ -29902,9 +30071,9 @@ function snapshotBaselineDiff(repos, workspacePath, deps = {}) {
|
|
|
29902
30071
|
if (!repo.path)
|
|
29903
30072
|
continue;
|
|
29904
30073
|
const filename = `${sanitizeRepoFilename(repo.name)}.diff`;
|
|
29905
|
-
const outPath =
|
|
29906
|
-
const repoPath = expandHome(repo.path,
|
|
29907
|
-
if (!
|
|
30074
|
+
const outPath = path18.join(baselineDir, filename);
|
|
30075
|
+
const repoPath = expandHome(repo.path, homedir16);
|
|
30076
|
+
if (!fs16.existsSync(repoPath)) {
|
|
29908
30077
|
writeBaselineFile(outPath, `# repo: ${repo.name}
|
|
29909
30078
|
# (skipped: path ${repoPath} does not exist)
|
|
29910
30079
|
`);
|
|
@@ -29971,7 +30140,7 @@ function snapshotBaselineDiff(repos, workspacePath, deps = {}) {
|
|
|
29971
30140
|
}
|
|
29972
30141
|
function writeBaselineFile(outPath, content) {
|
|
29973
30142
|
try {
|
|
29974
|
-
|
|
30143
|
+
fs16.writeFileSync(outPath, content);
|
|
29975
30144
|
} catch (err) {
|
|
29976
30145
|
const msg = err instanceof Error ? err.message : String(err);
|
|
29977
30146
|
console.warn(`[baseline-diff] write to ${outPath} failed: ${msg}`);
|
|
@@ -29979,11 +30148,11 @@ function writeBaselineFile(outPath, content) {
|
|
|
29979
30148
|
}
|
|
29980
30149
|
function stripWorktreeEdits(repos, workspacePath) {
|
|
29981
30150
|
for (const repo of repos) {
|
|
29982
|
-
const worktreePath =
|
|
29983
|
-
if (!
|
|
30151
|
+
const worktreePath = path18.join(workspacePath, repo.name);
|
|
30152
|
+
if (!fs16.existsSync(worktreePath))
|
|
29984
30153
|
continue;
|
|
29985
30154
|
try {
|
|
29986
|
-
|
|
30155
|
+
execFileSync5("git", ["checkout", "--", "."], {
|
|
29987
30156
|
cwd: worktreePath,
|
|
29988
30157
|
stdio: "pipe"
|
|
29989
30158
|
});
|
|
@@ -30010,14 +30179,14 @@ function formatBaselineSummary(result) {
|
|
|
30010
30179
|
}
|
|
30011
30180
|
|
|
30012
30181
|
// ../core/dist/world/context-injection.js
|
|
30013
|
-
import * as
|
|
30014
|
-
import * as
|
|
30182
|
+
import * as fs17 from "node:fs";
|
|
30183
|
+
import * as path19 from "node:path";
|
|
30015
30184
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
30016
30185
|
var TEMPLATES_DIR = fileURLToPath2(new URL("./templates", import.meta.url));
|
|
30017
30186
|
function injectWorldContext(opts) {
|
|
30018
30187
|
const { world, task, linearTicketId, claudeMdExtra, taskContext, services, pleriPlaneUrl } = opts;
|
|
30019
|
-
const claudeDir =
|
|
30020
|
-
|
|
30188
|
+
const claudeDir = path19.join(world.workspacePath, ".claude");
|
|
30189
|
+
fs17.mkdirSync(claudeDir, { recursive: true });
|
|
30021
30190
|
const sections = [];
|
|
30022
30191
|
sections.push(`# Olam World: ${world.name}`);
|
|
30023
30192
|
sections.push("");
|
|
@@ -30118,16 +30287,16 @@ function injectWorldContext(opts) {
|
|
|
30118
30287
|
sections.push("");
|
|
30119
30288
|
}
|
|
30120
30289
|
const content = sections.join("\n");
|
|
30121
|
-
|
|
30290
|
+
fs17.writeFileSync(path19.join(claudeDir, "CLAUDE.md"), content);
|
|
30122
30291
|
writeOlamDocs(world.workspacePath);
|
|
30123
30292
|
}
|
|
30124
30293
|
function writeOlamDocs(workspacePath) {
|
|
30125
|
-
const docsDir =
|
|
30126
|
-
|
|
30294
|
+
const docsDir = path19.join(workspacePath, ".olam", "docs");
|
|
30295
|
+
fs17.mkdirSync(docsDir, { recursive: true });
|
|
30127
30296
|
for (const filename of ["lane-orchestration.md", "gh-pr-create.md"]) {
|
|
30128
|
-
const src =
|
|
30129
|
-
const dest =
|
|
30130
|
-
|
|
30297
|
+
const src = path19.join(TEMPLATES_DIR, filename);
|
|
30298
|
+
const dest = path19.join(docsDir, filename);
|
|
30299
|
+
fs17.copyFileSync(src, dest);
|
|
30131
30300
|
}
|
|
30132
30301
|
}
|
|
30133
30302
|
function formatTaskSource(ctx) {
|
|
@@ -30142,9 +30311,9 @@ function formatTaskSource(ctx) {
|
|
|
30142
30311
|
function hasPlanFile(world) {
|
|
30143
30312
|
if (world.repos.length === 0)
|
|
30144
30313
|
return false;
|
|
30145
|
-
const plansDir =
|
|
30314
|
+
const plansDir = path19.join(world.workspacePath, world.repos[0], "docs", "plans");
|
|
30146
30315
|
try {
|
|
30147
|
-
return
|
|
30316
|
+
return fs17.existsSync(plansDir) && fs17.readdirSync(plansDir).length > 0;
|
|
30148
30317
|
} catch {
|
|
30149
30318
|
return false;
|
|
30150
30319
|
}
|
|
@@ -30706,25 +30875,25 @@ function shellQuote(s) {
|
|
|
30706
30875
|
|
|
30707
30876
|
// ../core/dist/world/snapshot.js
|
|
30708
30877
|
import * as crypto4 from "node:crypto";
|
|
30709
|
-
import * as
|
|
30878
|
+
import * as fs18 from "node:fs";
|
|
30710
30879
|
import * as os11 from "node:os";
|
|
30711
|
-
import * as
|
|
30712
|
-
import { execFileSync as
|
|
30880
|
+
import * as path20 from "node:path";
|
|
30881
|
+
import { execFileSync as execFileSync6, spawn as spawn2 } from "node:child_process";
|
|
30713
30882
|
import { gunzipSync } from "node:zlib";
|
|
30714
30883
|
function snapshotsDir() {
|
|
30715
|
-
return process.env["OLAM_SNAPSHOTS_DIR"] ??
|
|
30884
|
+
return process.env["OLAM_SNAPSHOTS_DIR"] ?? path20.join(os11.homedir(), ".olam", "snapshots");
|
|
30716
30885
|
}
|
|
30717
30886
|
function snapshotKindDirByWorkspace(workspace, arch, kind) {
|
|
30718
|
-
return
|
|
30887
|
+
return path20.join(snapshotsDir(), "by-workspace", workspace, arch, kind);
|
|
30719
30888
|
}
|
|
30720
30889
|
function cleanupLegacyByWorldDir(worldId) {
|
|
30721
|
-
const legacyDir =
|
|
30890
|
+
const legacyDir = path20.join(snapshotsDir(), worldId);
|
|
30722
30891
|
if (worldId === "by-workspace")
|
|
30723
30892
|
return;
|
|
30724
|
-
if (!
|
|
30893
|
+
if (!fs18.existsSync(legacyDir))
|
|
30725
30894
|
return;
|
|
30726
30895
|
try {
|
|
30727
|
-
|
|
30896
|
+
fs18.rmSync(legacyDir, { recursive: true, force: true });
|
|
30728
30897
|
} catch {
|
|
30729
30898
|
}
|
|
30730
30899
|
}
|
|
@@ -30743,11 +30912,11 @@ function hashBuffers(entries) {
|
|
|
30743
30912
|
return hash.digest("hex").slice(0, 12);
|
|
30744
30913
|
}
|
|
30745
30914
|
function computeGemsFingerprint(repoDir, imageDigest) {
|
|
30746
|
-
const lockfile =
|
|
30747
|
-
if (!
|
|
30915
|
+
const lockfile = path20.join(repoDir, "Gemfile.lock");
|
|
30916
|
+
if (!fs18.existsSync(lockfile))
|
|
30748
30917
|
return null;
|
|
30749
30918
|
const entries = [
|
|
30750
|
-
{ path: "Gemfile.lock", content:
|
|
30919
|
+
{ path: "Gemfile.lock", content: fs18.readFileSync(lockfile) }
|
|
30751
30920
|
];
|
|
30752
30921
|
if (imageDigest) {
|
|
30753
30922
|
entries.push({ path: "__image_digest__", content: Buffer.from(imageDigest, "utf-8") });
|
|
@@ -30757,10 +30926,10 @@ function computeGemsFingerprint(repoDir, imageDigest) {
|
|
|
30757
30926
|
function computeNodeFingerprint(repoDir, imageDigest) {
|
|
30758
30927
|
const candidates = ["yarn.lock", "pnpm-lock.yaml", "package-lock.json"];
|
|
30759
30928
|
for (const name of candidates) {
|
|
30760
|
-
const lockfile =
|
|
30761
|
-
if (
|
|
30929
|
+
const lockfile = path20.join(repoDir, name);
|
|
30930
|
+
if (fs18.existsSync(lockfile)) {
|
|
30762
30931
|
const entries = [
|
|
30763
|
-
{ path: name, content:
|
|
30932
|
+
{ path: name, content: fs18.readFileSync(lockfile) }
|
|
30764
30933
|
];
|
|
30765
30934
|
if (imageDigest) {
|
|
30766
30935
|
entries.push({ path: "__image_digest__", content: Buffer.from(imageDigest, "utf-8") });
|
|
@@ -30779,18 +30948,18 @@ function unpackTarballAtomic(srcPath, destDir) {
|
|
|
30779
30948
|
detail: validation.detail ?? `unsafe entry: ${validation.unsafePath}`
|
|
30780
30949
|
};
|
|
30781
30950
|
}
|
|
30782
|
-
const parent =
|
|
30783
|
-
|
|
30951
|
+
const parent = path20.dirname(destDir);
|
|
30952
|
+
fs18.mkdirSync(parent, { recursive: true });
|
|
30784
30953
|
const tmpSuffix = `.tmp-${process.pid}-${crypto4.randomBytes(4).toString("hex")}`;
|
|
30785
30954
|
const tmpDir = `${destDir}${tmpSuffix}`;
|
|
30786
30955
|
try {
|
|
30787
|
-
|
|
30788
|
-
|
|
30789
|
-
|
|
30956
|
+
fs18.mkdirSync(tmpDir, { recursive: true });
|
|
30957
|
+
execFileSync6("tar", ["-xzf", srcPath, "-C", tmpDir], { stdio: "pipe" });
|
|
30958
|
+
fs18.renameSync(tmpDir, destDir);
|
|
30790
30959
|
return { ok: true, entryCount: validation.entries.length };
|
|
30791
30960
|
} catch (err) {
|
|
30792
30961
|
try {
|
|
30793
|
-
|
|
30962
|
+
fs18.rmSync(tmpDir, { recursive: true, force: true });
|
|
30794
30963
|
} catch {
|
|
30795
30964
|
}
|
|
30796
30965
|
return {
|
|
@@ -30801,12 +30970,12 @@ function unpackTarballAtomic(srcPath, destDir) {
|
|
|
30801
30970
|
}
|
|
30802
30971
|
}
|
|
30803
30972
|
function resolvesWithin(base, target) {
|
|
30804
|
-
const resolved =
|
|
30805
|
-
const baseResolved =
|
|
30806
|
-
const rel =
|
|
30973
|
+
const resolved = path20.resolve(base, target);
|
|
30974
|
+
const baseResolved = path20.resolve(base);
|
|
30975
|
+
const rel = path20.relative(baseResolved, resolved);
|
|
30807
30976
|
if (rel === "")
|
|
30808
30977
|
return true;
|
|
30809
|
-
return !rel.startsWith("..") && !
|
|
30978
|
+
return !rel.startsWith("..") && !path20.isAbsolute(rel);
|
|
30810
30979
|
}
|
|
30811
30980
|
var TYPE_CHAR_TO_TYPE = {
|
|
30812
30981
|
"-": "file",
|
|
@@ -30856,7 +31025,7 @@ function parseTarListLine(line) {
|
|
|
30856
31025
|
function validateHardlinksBinary(tarPath, targetDir) {
|
|
30857
31026
|
let raw;
|
|
30858
31027
|
try {
|
|
30859
|
-
raw = gunzipSync(
|
|
31028
|
+
raw = gunzipSync(fs18.readFileSync(tarPath));
|
|
30860
31029
|
} catch {
|
|
30861
31030
|
return null;
|
|
30862
31031
|
}
|
|
@@ -30871,7 +31040,7 @@ function validateHardlinksBinary(tarPath, targetDir) {
|
|
|
30871
31040
|
const name = block.subarray(0, nameNull >= 0 && nameNull <= 99 ? nameNull : 100).toString("utf-8");
|
|
30872
31041
|
const linkNull = block.indexOf(0, 157);
|
|
30873
31042
|
const linkname = block.subarray(157, linkNull >= 157 && linkNull <= 256 ? linkNull : 257).toString("utf-8");
|
|
30874
|
-
if (linkname && (
|
|
31043
|
+
if (linkname && (path20.isAbsolute(linkname) || !resolvesWithin(targetDir, linkname))) {
|
|
30875
31044
|
return {
|
|
30876
31045
|
valid: false,
|
|
30877
31046
|
reason: "hardlink-escape",
|
|
@@ -30889,7 +31058,7 @@ function validateHardlinksBinary(tarPath, targetDir) {
|
|
|
30889
31058
|
function enumerateAndValidateTarballEntries(tarPath, targetDir) {
|
|
30890
31059
|
let raw;
|
|
30891
31060
|
try {
|
|
30892
|
-
raw =
|
|
31061
|
+
raw = execFileSync6("tar", ["-tvf", tarPath], {
|
|
30893
31062
|
stdio: ["ignore", "pipe", "pipe"],
|
|
30894
31063
|
env: { ...process.env, LC_ALL: "C", TZ: "UTC" },
|
|
30895
31064
|
encoding: "utf-8",
|
|
@@ -30909,7 +31078,7 @@ function enumerateAndValidateTarballEntries(tarPath, targetDir) {
|
|
|
30909
31078
|
const entry = parseTarListLine(line);
|
|
30910
31079
|
if (!entry)
|
|
30911
31080
|
continue;
|
|
30912
|
-
if (
|
|
31081
|
+
if (path20.isAbsolute(entry.name) || !resolvesWithin(targetDir, entry.name)) {
|
|
30913
31082
|
return {
|
|
30914
31083
|
valid: false,
|
|
30915
31084
|
reason: "path-traversal",
|
|
@@ -30917,8 +31086,8 @@ function enumerateAndValidateTarballEntries(tarPath, targetDir) {
|
|
|
30917
31086
|
};
|
|
30918
31087
|
}
|
|
30919
31088
|
if (entry.type === "symlink" && entry.linkname !== void 0) {
|
|
30920
|
-
const symlinkParent =
|
|
30921
|
-
if (
|
|
31089
|
+
const symlinkParent = path20.join(targetDir, path20.dirname(entry.name));
|
|
31090
|
+
if (path20.isAbsolute(entry.linkname) || !resolvesWithin(targetDir, path20.join(path20.dirname(entry.name), entry.linkname))) {
|
|
30922
31091
|
return {
|
|
30923
31092
|
valid: false,
|
|
30924
31093
|
reason: "symlink-escape",
|
|
@@ -30928,7 +31097,7 @@ function enumerateAndValidateTarballEntries(tarPath, targetDir) {
|
|
|
30928
31097
|
}
|
|
30929
31098
|
}
|
|
30930
31099
|
if (entry.type === "hardlink" && entry.linkname !== void 0) {
|
|
30931
|
-
if (
|
|
31100
|
+
if (path20.isAbsolute(entry.linkname) || !resolvesWithin(targetDir, entry.linkname)) {
|
|
30932
31101
|
return {
|
|
30933
31102
|
valid: false,
|
|
30934
31103
|
reason: "hardlink-escape",
|
|
@@ -30961,8 +31130,8 @@ function restoreSnapshotsForRepos(input) {
|
|
|
30961
31130
|
}
|
|
30962
31131
|
const archDir = snapshotKindDirByWorkspace(input.workspace, input.arch, kind);
|
|
30963
31132
|
const tarFilename = `${repo.name}-${input.arch}-${fingerprint}.tar.gz`;
|
|
30964
|
-
const tarPath =
|
|
30965
|
-
if (!
|
|
31133
|
+
const tarPath = path20.join(archDir, tarFilename);
|
|
31134
|
+
if (!fs18.existsSync(tarPath)) {
|
|
30966
31135
|
outcomes.push({ repo: repo.name, kind, outcome: "miss", reason: "no-tarball", fingerprint });
|
|
30967
31136
|
continue;
|
|
30968
31137
|
}
|
|
@@ -30977,9 +31146,9 @@ function restoreSnapshotsForRepos(input) {
|
|
|
30977
31146
|
});
|
|
30978
31147
|
continue;
|
|
30979
31148
|
}
|
|
30980
|
-
const targetDir =
|
|
31149
|
+
const targetDir = path20.join(repo.worktreeDir, targetSubpath);
|
|
30981
31150
|
try {
|
|
30982
|
-
|
|
31151
|
+
fs18.rmSync(targetDir, { recursive: true, force: true });
|
|
30983
31152
|
} catch {
|
|
30984
31153
|
}
|
|
30985
31154
|
const result = unpackTarballAtomic(tarPath, targetDir);
|
|
@@ -30992,8 +31161,8 @@ function restoreSnapshotsForRepos(input) {
|
|
|
30992
31161
|
fingerprint
|
|
30993
31162
|
});
|
|
30994
31163
|
try {
|
|
30995
|
-
|
|
30996
|
-
|
|
31164
|
+
fs18.rmSync(tarPath, { force: true });
|
|
31165
|
+
fs18.rmSync(manifestPath(tarPath), { force: true });
|
|
30997
31166
|
} catch {
|
|
30998
31167
|
}
|
|
30999
31168
|
continue;
|
|
@@ -31009,10 +31178,10 @@ function restoreSnapshotsForRepos(input) {
|
|
|
31009
31178
|
}
|
|
31010
31179
|
function readManifest(tarPath) {
|
|
31011
31180
|
const mPath = manifestPath(tarPath);
|
|
31012
|
-
if (!
|
|
31181
|
+
if (!fs18.existsSync(mPath))
|
|
31013
31182
|
return null;
|
|
31014
31183
|
try {
|
|
31015
|
-
return JSON.parse(
|
|
31184
|
+
return JSON.parse(fs18.readFileSync(mPath, "utf-8"));
|
|
31016
31185
|
} catch {
|
|
31017
31186
|
return null;
|
|
31018
31187
|
}
|
|
@@ -31027,17 +31196,17 @@ function isPidAlive(pid) {
|
|
|
31027
31196
|
}
|
|
31028
31197
|
}
|
|
31029
31198
|
function evictOldSnapshotsWithFlock(maxBytes, dir = snapshotsDir()) {
|
|
31030
|
-
|
|
31031
|
-
const lockPath =
|
|
31199
|
+
fs18.mkdirSync(dir, { recursive: true });
|
|
31200
|
+
const lockPath = path20.join(dir, EVICT_LOCK_FILENAME);
|
|
31032
31201
|
let fd;
|
|
31033
31202
|
try {
|
|
31034
|
-
fd =
|
|
31203
|
+
fd = fs18.openSync(lockPath, fs18.constants.O_WRONLY | fs18.constants.O_CREAT | fs18.constants.O_EXCL, 384);
|
|
31035
31204
|
} catch (err) {
|
|
31036
31205
|
if (err.code !== "EEXIST")
|
|
31037
31206
|
return 0;
|
|
31038
31207
|
let holderPid = null;
|
|
31039
31208
|
try {
|
|
31040
|
-
holderPid = parseInt(
|
|
31209
|
+
holderPid = parseInt(fs18.readFileSync(lockPath, "utf-8").trim(), 10);
|
|
31041
31210
|
} catch {
|
|
31042
31211
|
holderPid = null;
|
|
31043
31212
|
}
|
|
@@ -31045,23 +31214,23 @@ function evictOldSnapshotsWithFlock(maxBytes, dir = snapshotsDir()) {
|
|
|
31045
31214
|
return 0;
|
|
31046
31215
|
}
|
|
31047
31216
|
try {
|
|
31048
|
-
|
|
31049
|
-
fd =
|
|
31217
|
+
fs18.unlinkSync(lockPath);
|
|
31218
|
+
fd = fs18.openSync(lockPath, fs18.constants.O_WRONLY | fs18.constants.O_CREAT | fs18.constants.O_EXCL, 384);
|
|
31050
31219
|
} catch {
|
|
31051
31220
|
return 0;
|
|
31052
31221
|
}
|
|
31053
31222
|
}
|
|
31054
31223
|
try {
|
|
31055
|
-
|
|
31224
|
+
fs18.writeSync(fd, `${process.pid}
|
|
31056
31225
|
`);
|
|
31057
31226
|
} finally {
|
|
31058
|
-
|
|
31227
|
+
fs18.closeSync(fd);
|
|
31059
31228
|
}
|
|
31060
31229
|
try {
|
|
31061
31230
|
return evictOldSnapshots(maxBytes, dir);
|
|
31062
31231
|
} finally {
|
|
31063
31232
|
try {
|
|
31064
|
-
|
|
31233
|
+
fs18.unlinkSync(lockPath);
|
|
31065
31234
|
} catch {
|
|
31066
31235
|
}
|
|
31067
31236
|
}
|
|
@@ -31094,16 +31263,16 @@ function spawnAutoCapture(worldId, olamBin = "olam") {
|
|
|
31094
31263
|
}
|
|
31095
31264
|
}
|
|
31096
31265
|
function evictOldSnapshots(maxBytes, dir = snapshotsDir()) {
|
|
31097
|
-
if (!
|
|
31266
|
+
if (!fs18.existsSync(dir))
|
|
31098
31267
|
return 0;
|
|
31099
31268
|
const allTars = [];
|
|
31100
31269
|
const walk = (d) => {
|
|
31101
|
-
for (const entry of
|
|
31102
|
-
const full =
|
|
31270
|
+
for (const entry of fs18.readdirSync(d, { withFileTypes: true })) {
|
|
31271
|
+
const full = path20.join(d, entry.name);
|
|
31103
31272
|
if (entry.isDirectory()) {
|
|
31104
31273
|
walk(full);
|
|
31105
31274
|
} else if (entry.name.endsWith(".tar.gz")) {
|
|
31106
|
-
const stat =
|
|
31275
|
+
const stat = fs18.statSync(full);
|
|
31107
31276
|
allTars.push({ path: full, size: stat.size, mtime: stat.mtimeMs });
|
|
31108
31277
|
}
|
|
31109
31278
|
}
|
|
@@ -31118,8 +31287,8 @@ function evictOldSnapshots(maxBytes, dir = snapshotsDir()) {
|
|
|
31118
31287
|
for (const tar of allTars) {
|
|
31119
31288
|
if (remaining <= maxBytes)
|
|
31120
31289
|
break;
|
|
31121
|
-
|
|
31122
|
-
|
|
31290
|
+
fs18.rmSync(tar.path, { force: true });
|
|
31291
|
+
fs18.rmSync(manifestPath(tar.path), { force: true });
|
|
31123
31292
|
freed += tar.size;
|
|
31124
31293
|
remaining -= tar.size;
|
|
31125
31294
|
}
|
|
@@ -31235,14 +31404,14 @@ function gcloudAvailable(execFn = defaultExecFn) {
|
|
|
31235
31404
|
}
|
|
31236
31405
|
|
|
31237
31406
|
// ../core/dist/world/olam-yaml.js
|
|
31238
|
-
import * as
|
|
31407
|
+
import * as path21 from "node:path";
|
|
31239
31408
|
import YAML2 from "yaml";
|
|
31240
31409
|
function enrichReposWithManifests(repos, workspacePath) {
|
|
31241
31410
|
return repos.map((repo) => {
|
|
31242
31411
|
if (repo.manifest !== void 0 && repo.manifest !== null) {
|
|
31243
31412
|
return repo;
|
|
31244
31413
|
}
|
|
31245
|
-
const repoDir =
|
|
31414
|
+
const repoDir = path21.join(workspacePath, repo.name);
|
|
31246
31415
|
let manifest = null;
|
|
31247
31416
|
try {
|
|
31248
31417
|
manifest = loadRepoManifest(repoDir);
|
|
@@ -31257,8 +31426,8 @@ function enrichReposWithManifests(repos, workspacePath) {
|
|
|
31257
31426
|
}
|
|
31258
31427
|
|
|
31259
31428
|
// ../core/dist/policies/loader.js
|
|
31260
|
-
import * as
|
|
31261
|
-
import * as
|
|
31429
|
+
import * as fs19 from "node:fs";
|
|
31430
|
+
import * as path22 from "node:path";
|
|
31262
31431
|
import { parse as parseYaml3 } from "yaml";
|
|
31263
31432
|
function parseFrontmatter(content) {
|
|
31264
31433
|
const match = /^---\r?\n([\s\S]*?)\r?\n---\r?\n([\s\S]*)$/m.exec(content);
|
|
@@ -31278,20 +31447,20 @@ function toStringArray(v) {
|
|
|
31278
31447
|
return v.filter((x) => typeof x === "string");
|
|
31279
31448
|
}
|
|
31280
31449
|
function loadPolicies(workspaceRoot) {
|
|
31281
|
-
const policiesDir =
|
|
31282
|
-
if (!
|
|
31450
|
+
const policiesDir = path22.join(workspaceRoot, ".olam", "policies");
|
|
31451
|
+
if (!fs19.existsSync(policiesDir))
|
|
31283
31452
|
return [];
|
|
31284
31453
|
let files;
|
|
31285
31454
|
try {
|
|
31286
|
-
files =
|
|
31455
|
+
files = fs19.readdirSync(policiesDir).filter((f) => f.endsWith(".md")).sort();
|
|
31287
31456
|
} catch {
|
|
31288
31457
|
return [];
|
|
31289
31458
|
}
|
|
31290
31459
|
const policies = [];
|
|
31291
31460
|
for (const file of files) {
|
|
31292
|
-
const filePath =
|
|
31461
|
+
const filePath = path22.join(policiesDir, file);
|
|
31293
31462
|
try {
|
|
31294
|
-
const content =
|
|
31463
|
+
const content = fs19.readFileSync(filePath, "utf8");
|
|
31295
31464
|
const parsed = parseFrontmatter(content);
|
|
31296
31465
|
if (!parsed) {
|
|
31297
31466
|
console.warn(`[policies] skipping ${file}: no valid frontmatter block`);
|
|
@@ -31342,12 +31511,12 @@ function formatPoliciesBrief(policies) {
|
|
|
31342
31511
|
}
|
|
31343
31512
|
|
|
31344
31513
|
// ../core/dist/global-config/runbook-resolver.js
|
|
31345
|
-
import * as
|
|
31514
|
+
import * as fs20 from "node:fs";
|
|
31346
31515
|
import * as os12 from "node:os";
|
|
31347
|
-
import * as
|
|
31516
|
+
import * as path23 from "node:path";
|
|
31348
31517
|
function expandTilde(p) {
|
|
31349
31518
|
if (p === "~" || p.startsWith("~/")) {
|
|
31350
|
-
return
|
|
31519
|
+
return path23.join(os12.homedir(), p.slice(1));
|
|
31351
31520
|
}
|
|
31352
31521
|
return p;
|
|
31353
31522
|
}
|
|
@@ -31359,7 +31528,7 @@ function resolveRunbookToWorldParams(runbook, repoRegistry) {
|
|
|
31359
31528
|
throw new Error(`repo "${repoName}" is referenced by runbook "${runbook.name}" but is not in the registry. Run "olam repos add ${repoName} --path <path>" to register it.`);
|
|
31360
31529
|
}
|
|
31361
31530
|
const resolvedPath = expandTilde(entry.path);
|
|
31362
|
-
if (!
|
|
31531
|
+
if (!fs20.existsSync(resolvedPath)) {
|
|
31363
31532
|
throw new Error(`repo "${repoName}" path "${resolvedPath}" no longer exists. Run "olam repos update ${repoName} --path <new-path>" to fix.`);
|
|
31364
31533
|
}
|
|
31365
31534
|
}
|
|
@@ -31372,19 +31541,19 @@ function resolveRunbookToWorldParams(runbook, repoRegistry) {
|
|
|
31372
31541
|
}
|
|
31373
31542
|
|
|
31374
31543
|
// ../core/dist/world/bootstrap-hooks.js
|
|
31375
|
-
import * as
|
|
31376
|
-
import * as
|
|
31544
|
+
import * as fs21 from "node:fs";
|
|
31545
|
+
import * as path24 from "node:path";
|
|
31377
31546
|
function runFixtureCopySeeds(seeds, workspacePath) {
|
|
31378
31547
|
if (!seeds)
|
|
31379
31548
|
return;
|
|
31380
31549
|
for (const seed of seeds) {
|
|
31381
31550
|
if (seed.type !== "fixture-copy")
|
|
31382
31551
|
continue;
|
|
31383
|
-
const srcAbs =
|
|
31384
|
-
const destAbs =
|
|
31385
|
-
const destDir =
|
|
31386
|
-
|
|
31387
|
-
|
|
31552
|
+
const srcAbs = path24.resolve(workspacePath, seed.repo, seed.src);
|
|
31553
|
+
const destAbs = path24.resolve(workspacePath, seed.repo, seed.dest);
|
|
31554
|
+
const destDir = path24.dirname(destAbs);
|
|
31555
|
+
fs21.mkdirSync(destDir, { recursive: true });
|
|
31556
|
+
fs21.cpSync(srcAbs, destAbs, { recursive: true, force: true });
|
|
31388
31557
|
}
|
|
31389
31558
|
}
|
|
31390
31559
|
async function runSeedHooks(seeds, containerName, servicePortMap, exec) {
|
|
@@ -32021,7 +32190,7 @@ ${detail}`);
|
|
|
32021
32190
|
runbookSeeds = resolved.seeds;
|
|
32022
32191
|
}
|
|
32023
32192
|
const worldId = generateWorldId();
|
|
32024
|
-
const workspacePath =
|
|
32193
|
+
const workspacePath = path25.join(os13.homedir(), ".olam", "worlds", worldId);
|
|
32025
32194
|
const portOffset = this.registry.getNextPortOffset();
|
|
32026
32195
|
const branch = opts.branchName ?? `olam/${worldId}`;
|
|
32027
32196
|
const repos = this.resolveReposWithWorkspace(opts);
|
|
@@ -32091,37 +32260,37 @@ ${detail}`);
|
|
|
32091
32260
|
if (!repo.path)
|
|
32092
32261
|
continue;
|
|
32093
32262
|
const sourceRoot = repo.path.replace(/^~/, os13.homedir());
|
|
32094
|
-
const worktreeRoot =
|
|
32095
|
-
if (!
|
|
32263
|
+
const worktreeRoot = path25.join(workspacePath, repo.name);
|
|
32264
|
+
if (!fs22.existsSync(sourceRoot) || !fs22.existsSync(worktreeRoot))
|
|
32096
32265
|
continue;
|
|
32097
32266
|
let copied = 0;
|
|
32098
32267
|
for (const pattern of RUNTIME_FILE_PATTERNS) {
|
|
32099
32268
|
const matches2 = [];
|
|
32100
32269
|
if (pattern.includes("*")) {
|
|
32101
|
-
const [dir, glob] = [
|
|
32102
|
-
const sourceDir =
|
|
32103
|
-
if (
|
|
32270
|
+
const [dir, glob] = [path25.dirname(pattern), path25.basename(pattern)];
|
|
32271
|
+
const sourceDir = path25.join(sourceRoot, dir);
|
|
32272
|
+
if (fs22.existsSync(sourceDir)) {
|
|
32104
32273
|
const ext = glob.replace(/^\*+/, "");
|
|
32105
32274
|
try {
|
|
32106
|
-
for (const entry of
|
|
32275
|
+
for (const entry of fs22.readdirSync(sourceDir)) {
|
|
32107
32276
|
if (ext === "" || entry.endsWith(ext))
|
|
32108
|
-
matches2.push(
|
|
32277
|
+
matches2.push(path25.join(dir, entry));
|
|
32109
32278
|
}
|
|
32110
32279
|
} catch {
|
|
32111
32280
|
}
|
|
32112
32281
|
}
|
|
32113
|
-
} else if (
|
|
32282
|
+
} else if (fs22.existsSync(path25.join(sourceRoot, pattern))) {
|
|
32114
32283
|
matches2.push(pattern);
|
|
32115
32284
|
}
|
|
32116
32285
|
for (const rel of matches2) {
|
|
32117
|
-
const src =
|
|
32118
|
-
const dst =
|
|
32286
|
+
const src = path25.join(sourceRoot, rel);
|
|
32287
|
+
const dst = path25.join(worktreeRoot, rel);
|
|
32119
32288
|
try {
|
|
32120
|
-
const st =
|
|
32289
|
+
const st = fs22.statSync(src);
|
|
32121
32290
|
if (!st.isFile())
|
|
32122
32291
|
continue;
|
|
32123
|
-
|
|
32124
|
-
|
|
32292
|
+
fs22.mkdirSync(path25.dirname(dst), { recursive: true });
|
|
32293
|
+
fs22.copyFileSync(src, dst);
|
|
32125
32294
|
copied++;
|
|
32126
32295
|
} catch {
|
|
32127
32296
|
}
|
|
@@ -32205,6 +32374,24 @@ ${detail}`);
|
|
|
32205
32374
|
console.warn(`[WorldManager] context injection failed: ${msg}`);
|
|
32206
32375
|
}
|
|
32207
32376
|
}
|
|
32377
|
+
const overlayAttachments = [];
|
|
32378
|
+
for (const repo of repos) {
|
|
32379
|
+
const worldClonePath = path25.join(workspacePath, repo.name);
|
|
32380
|
+
try {
|
|
32381
|
+
const result = createWorldOverlay({
|
|
32382
|
+
workspace: repo.name,
|
|
32383
|
+
worldClonePath
|
|
32384
|
+
});
|
|
32385
|
+
overlayAttachments.push({ repo: repo.name, overlayPath: result.overlayPath });
|
|
32386
|
+
console.log(`[WorldManager] KG overlay attached for ${repo.name}: ${result.strategy} (.gitignore: ${result.gitignoreAction})`);
|
|
32387
|
+
} catch (err) {
|
|
32388
|
+
if (err instanceof KgOverlayError && /pristine.*not found|MISSING/i.test(err.message)) {
|
|
32389
|
+
continue;
|
|
32390
|
+
}
|
|
32391
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
32392
|
+
console.warn(`[WorldManager] KG overlay attach failed for ${repo.name}: ${msg}`);
|
|
32393
|
+
}
|
|
32394
|
+
}
|
|
32208
32395
|
if (opts.planFile) {
|
|
32209
32396
|
try {
|
|
32210
32397
|
this.transportPlanFile(opts.planFile, workspacePath, repos.map((r) => r.name));
|
|
@@ -32221,7 +32408,7 @@ ${detail}`);
|
|
|
32221
32408
|
try {
|
|
32222
32409
|
const hostExec = makeHostExecFn();
|
|
32223
32410
|
for (const repo of repos) {
|
|
32224
|
-
const repoDir =
|
|
32411
|
+
const repoDir = path25.join(workspacePath, repo.name);
|
|
32225
32412
|
if (repo.stack && Object.keys(repo.stack).length > 0) {
|
|
32226
32413
|
preDetectedStacks.set(repo.name, { repoName: repo.name, versions: repo.stack });
|
|
32227
32414
|
} else {
|
|
@@ -32287,10 +32474,10 @@ ${detail}`);
|
|
|
32287
32474
|
const worldEnv = {};
|
|
32288
32475
|
if (opts.task)
|
|
32289
32476
|
worldEnv.OLAM_TASK = opts.task;
|
|
32290
|
-
const r2CredsPath =
|
|
32291
|
-
if (
|
|
32477
|
+
const r2CredsPath = path25.join(os13.homedir(), ".olam", "r2-credentials.json");
|
|
32478
|
+
if (fs22.existsSync(r2CredsPath)) {
|
|
32292
32479
|
try {
|
|
32293
|
-
const r2Raw =
|
|
32480
|
+
const r2Raw = fs22.readFileSync(r2CredsPath, "utf-8").trim();
|
|
32294
32481
|
if (r2Raw.length > 0) {
|
|
32295
32482
|
const r2 = JSON.parse(r2Raw);
|
|
32296
32483
|
if (typeof r2.account_id === "string")
|
|
@@ -32307,10 +32494,10 @@ ${detail}`);
|
|
|
32307
32494
|
} catch {
|
|
32308
32495
|
}
|
|
32309
32496
|
}
|
|
32310
|
-
const keysYamlPath =
|
|
32311
|
-
if (
|
|
32497
|
+
const keysYamlPath = path25.join(os13.homedir(), ".olam", "keys.yaml");
|
|
32498
|
+
if (fs22.existsSync(keysYamlPath)) {
|
|
32312
32499
|
try {
|
|
32313
|
-
const keysRaw =
|
|
32500
|
+
const keysRaw = fs22.readFileSync(keysYamlPath, "utf-8").trim();
|
|
32314
32501
|
if (keysRaw.length > 0) {
|
|
32315
32502
|
const parsed = YAML3.parse(keysRaw);
|
|
32316
32503
|
if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed)) {
|
|
@@ -32369,10 +32556,10 @@ ${detail}`);
|
|
|
32369
32556
|
worldEnv[k] = v;
|
|
32370
32557
|
}
|
|
32371
32558
|
for (const { repoName, relativePath, content } of fileWrites) {
|
|
32372
|
-
const absPath =
|
|
32559
|
+
const absPath = path25.join(workspacePath, repoName, relativePath);
|
|
32373
32560
|
try {
|
|
32374
|
-
|
|
32375
|
-
|
|
32561
|
+
fs22.mkdirSync(path25.dirname(absPath), { recursive: true });
|
|
32562
|
+
fs22.writeFileSync(absPath, content.endsWith("\n") ? content : content + "\n", {
|
|
32376
32563
|
mode: 384
|
|
32377
32564
|
});
|
|
32378
32565
|
console.log(`[secrets] ${repoName}: materialised ${relativePath} (${content.length} chars, mode 0600)`);
|
|
@@ -32423,6 +32610,15 @@ ${detail}`);
|
|
|
32423
32610
|
await copyClaudeConfigIntoContainer(containerName);
|
|
32424
32611
|
} catch {
|
|
32425
32612
|
}
|
|
32613
|
+
for (const { repo: repoName } of overlayAttachments) {
|
|
32614
|
+
try {
|
|
32615
|
+
installGraphifyHookInWorld({ containerName, repoName });
|
|
32616
|
+
console.log(`[WorldManager] KG hook installed for ${repoName}`);
|
|
32617
|
+
} catch (err) {
|
|
32618
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
32619
|
+
console.warn(`[WorldManager] KG hook install failed for ${repoName}: ${msg}`);
|
|
32620
|
+
}
|
|
32621
|
+
}
|
|
32426
32622
|
const credentialsInjected = { claude: !opts.noAuth, codex: false };
|
|
32427
32623
|
try {
|
|
32428
32624
|
await setupContainerGit(containerName, repos, branch);
|
|
@@ -32487,7 +32683,7 @@ ${detail}`);
|
|
|
32487
32683
|
imageDigest: void 0,
|
|
32488
32684
|
repos: enrichedRepos.map((r) => ({
|
|
32489
32685
|
name: r.name,
|
|
32490
|
-
worktreeDir:
|
|
32686
|
+
worktreeDir: path25.join(workspacePath, r.name)
|
|
32491
32687
|
}))
|
|
32492
32688
|
});
|
|
32493
32689
|
for (const out of restoreResult.outcomes) {
|
|
@@ -32600,7 +32796,7 @@ ${detail}`);
|
|
|
32600
32796
|
let taskWithPolicies = opts.task;
|
|
32601
32797
|
try {
|
|
32602
32798
|
const allPolicies = repos.flatMap((repo) => {
|
|
32603
|
-
const repoWorktree =
|
|
32799
|
+
const repoWorktree = path25.join(workspacePath, repo.name);
|
|
32604
32800
|
return loadPolicies(repoWorktree);
|
|
32605
32801
|
});
|
|
32606
32802
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -32616,8 +32812,8 @@ ${detail}`);
|
|
|
32616
32812
|
${opts.task}`;
|
|
32617
32813
|
execSync5(`docker exec ${containerName} mkdir -p /home/olam/.olam/policies`, { stdio: "pipe", timeout: 1e4 });
|
|
32618
32814
|
for (const repo of repos) {
|
|
32619
|
-
const policiesDir =
|
|
32620
|
-
if (
|
|
32815
|
+
const policiesDir = path25.join(workspacePath, repo.name, ".olam", "policies");
|
|
32816
|
+
if (fs22.existsSync(policiesDir)) {
|
|
32621
32817
|
execSync5(`docker cp "${policiesDir}/." "${containerName}:/home/olam/.olam/policies/"`, { stdio: "pipe", timeout: 15e3 });
|
|
32622
32818
|
}
|
|
32623
32819
|
}
|
|
@@ -32717,8 +32913,8 @@ ${opts.task}`;
|
|
|
32717
32913
|
} catch {
|
|
32718
32914
|
}
|
|
32719
32915
|
try {
|
|
32720
|
-
|
|
32721
|
-
if (
|
|
32916
|
+
fs22.rmSync(world.workspacePath, { recursive: true, force: true });
|
|
32917
|
+
if (fs22.existsSync(world.workspacePath)) {
|
|
32722
32918
|
console.warn(`[WorldManager] destroyWorld(${worldId}): workspace dir ${world.workspacePath} still exists after rmSync. Run \`olam clean --apply\` to reap.`);
|
|
32723
32919
|
}
|
|
32724
32920
|
} catch (err) {
|
|
@@ -32827,14 +33023,14 @@ ${opts.task}`;
|
|
|
32827
33023
|
}).filter((r) => r !== void 0);
|
|
32828
33024
|
}
|
|
32829
33025
|
transportPlanFile(planFilePath, workspacePath, repoNames) {
|
|
32830
|
-
const planContent =
|
|
32831
|
-
const planFileName =
|
|
33026
|
+
const planContent = fs22.readFileSync(planFilePath, "utf-8");
|
|
33027
|
+
const planFileName = path25.basename(planFilePath);
|
|
32832
33028
|
const targetRepo = repoNames[0];
|
|
32833
33029
|
if (!targetRepo)
|
|
32834
33030
|
return;
|
|
32835
|
-
const plansDir =
|
|
32836
|
-
|
|
32837
|
-
|
|
33031
|
+
const plansDir = path25.join(workspacePath, targetRepo, "docs", "plans");
|
|
33032
|
+
fs22.mkdirSync(plansDir, { recursive: true });
|
|
33033
|
+
fs22.writeFileSync(path25.join(plansDir, planFileName), planContent);
|
|
32838
33034
|
}
|
|
32839
33035
|
resolveServices(repos) {
|
|
32840
33036
|
const services = [];
|
|
@@ -32930,8 +33126,8 @@ import * as http2 from "node:http";
|
|
|
32930
33126
|
|
|
32931
33127
|
// ../core/dist/dashboard/server.js
|
|
32932
33128
|
import * as http from "node:http";
|
|
32933
|
-
import * as
|
|
32934
|
-
import * as
|
|
33129
|
+
import * as fs23 from "node:fs";
|
|
33130
|
+
import * as path26 from "node:path";
|
|
32935
33131
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
32936
33132
|
|
|
32937
33133
|
// ../core/dist/dashboard/serialize.js
|
|
@@ -33266,7 +33462,7 @@ function notFound(res) {
|
|
|
33266
33462
|
}
|
|
33267
33463
|
function openThoughtStore(workspacePath) {
|
|
33268
33464
|
const dbPath = getWorldDbPath(workspacePath);
|
|
33269
|
-
if (!
|
|
33465
|
+
if (!fs23.existsSync(dbPath))
|
|
33270
33466
|
return null;
|
|
33271
33467
|
return new ThoughtLocalStore(dbPath);
|
|
33272
33468
|
}
|
|
@@ -33437,13 +33633,13 @@ function findSessionInWorld(registry2, sessionId) {
|
|
|
33437
33633
|
}
|
|
33438
33634
|
function createDashboardServer(opts) {
|
|
33439
33635
|
const { port, registry: registry2 } = opts;
|
|
33440
|
-
const thisDir =
|
|
33441
|
-
const defaultPublicDir =
|
|
33636
|
+
const thisDir = path26.dirname(fileURLToPath3(import.meta.url));
|
|
33637
|
+
const defaultPublicDir = path26.resolve(thisDir, "../../../control-plane/public");
|
|
33442
33638
|
const publicDir = opts.publicDir ?? defaultPublicDir;
|
|
33443
|
-
let hasPublicDir =
|
|
33639
|
+
let hasPublicDir = fs23.existsSync(publicDir);
|
|
33444
33640
|
const server = http.createServer((req, res) => {
|
|
33445
33641
|
if (!hasPublicDir) {
|
|
33446
|
-
hasPublicDir =
|
|
33642
|
+
hasPublicDir = fs23.existsSync(publicDir);
|
|
33447
33643
|
}
|
|
33448
33644
|
const host = req.headers.host ?? `localhost:${port}`;
|
|
33449
33645
|
const url = new URL(req.url ?? "/", `http://${host}`);
|
|
@@ -33717,22 +33913,22 @@ function createDashboardServer(opts) {
|
|
|
33717
33913
|
res.end(`<html><body style="font-family:system-ui;padding:2rem"><h1>Olam Dashboard</h1><p>The React app has not been built yet.</p><p>Run <code>npm run build:app</code> in <code>packages/control-plane</code> to build it.</p><p>API routes are available at <code>/api/*</code>.</p></body></html>`);
|
|
33718
33914
|
return;
|
|
33719
33915
|
}
|
|
33720
|
-
let filePath =
|
|
33916
|
+
let filePath = path26.join(publicDir, pathname === "/" ? "index.html" : pathname);
|
|
33721
33917
|
if (!filePath.startsWith(publicDir)) {
|
|
33722
33918
|
notFound(res);
|
|
33723
33919
|
return;
|
|
33724
33920
|
}
|
|
33725
|
-
if (
|
|
33726
|
-
const ext =
|
|
33921
|
+
if (fs23.existsSync(filePath) && fs23.statSync(filePath).isFile()) {
|
|
33922
|
+
const ext = path26.extname(filePath);
|
|
33727
33923
|
const contentType = MIME[ext] ?? "application/octet-stream";
|
|
33728
33924
|
res.writeHead(200, { "Content-Type": contentType });
|
|
33729
|
-
|
|
33925
|
+
fs23.createReadStream(filePath).pipe(res);
|
|
33730
33926
|
return;
|
|
33731
33927
|
}
|
|
33732
|
-
filePath =
|
|
33733
|
-
if (
|
|
33928
|
+
filePath = path26.join(publicDir, "index.html");
|
|
33929
|
+
if (fs23.existsSync(filePath)) {
|
|
33734
33930
|
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
|
|
33735
|
-
|
|
33931
|
+
fs23.createReadStream(filePath).pipe(res);
|
|
33736
33932
|
return;
|
|
33737
33933
|
}
|
|
33738
33934
|
notFound(res);
|
|
@@ -33742,17 +33938,17 @@ function createDashboardServer(opts) {
|
|
|
33742
33938
|
}
|
|
33743
33939
|
|
|
33744
33940
|
// ../core/dist/dashboard/state.js
|
|
33745
|
-
import * as
|
|
33941
|
+
import * as fs24 from "node:fs";
|
|
33746
33942
|
import * as os14 from "node:os";
|
|
33747
|
-
import * as
|
|
33748
|
-
var STATE_PATH =
|
|
33943
|
+
import * as path27 from "node:path";
|
|
33944
|
+
var STATE_PATH = path27.join(os14.homedir(), ".olam", "dashboard.json");
|
|
33749
33945
|
function saveDashboardState(state) {
|
|
33750
|
-
|
|
33751
|
-
|
|
33946
|
+
fs24.mkdirSync(path27.dirname(STATE_PATH), { recursive: true });
|
|
33947
|
+
fs24.writeFileSync(STATE_PATH, JSON.stringify(state, null, 2));
|
|
33752
33948
|
}
|
|
33753
33949
|
function loadDashboardState() {
|
|
33754
33950
|
try {
|
|
33755
|
-
const raw =
|
|
33951
|
+
const raw = fs24.readFileSync(STATE_PATH, "utf-8");
|
|
33756
33952
|
return JSON.parse(raw);
|
|
33757
33953
|
} catch {
|
|
33758
33954
|
return null;
|
|
@@ -33760,7 +33956,7 @@ function loadDashboardState() {
|
|
|
33760
33956
|
}
|
|
33761
33957
|
function clearDashboardState() {
|
|
33762
33958
|
try {
|
|
33763
|
-
|
|
33959
|
+
fs24.unlinkSync(STATE_PATH);
|
|
33764
33960
|
} catch {
|
|
33765
33961
|
}
|
|
33766
33962
|
}
|
|
@@ -33789,7 +33985,7 @@ function isCloudflaredAvailable() {
|
|
|
33789
33985
|
}
|
|
33790
33986
|
}
|
|
33791
33987
|
function startTunnel(port) {
|
|
33792
|
-
return new Promise((
|
|
33988
|
+
return new Promise((resolve9, reject2) => {
|
|
33793
33989
|
const child = spawn3("cloudflared", ["tunnel", "--url", `http://localhost:${port}`], {
|
|
33794
33990
|
stdio: ["ignore", "pipe", "pipe"],
|
|
33795
33991
|
detached: false
|
|
@@ -33811,7 +34007,7 @@ function startTunnel(port) {
|
|
|
33811
34007
|
if (match) {
|
|
33812
34008
|
resolved = true;
|
|
33813
34009
|
clearTimeout(timeout);
|
|
33814
|
-
|
|
34010
|
+
resolve9(match[0]);
|
|
33815
34011
|
}
|
|
33816
34012
|
}
|
|
33817
34013
|
child.stdout?.on("data", scan);
|
|
@@ -33879,8 +34075,8 @@ var DashboardManager = class {
|
|
|
33879
34075
|
}
|
|
33880
34076
|
throw err;
|
|
33881
34077
|
}
|
|
33882
|
-
await new Promise((
|
|
33883
|
-
this.server.on("listening",
|
|
34078
|
+
await new Promise((resolve9, reject2) => {
|
|
34079
|
+
this.server.on("listening", resolve9);
|
|
33884
34080
|
this.server.on("error", reject2);
|
|
33885
34081
|
});
|
|
33886
34082
|
this.info = { localUrl: `http://localhost:${port}` };
|
|
@@ -33926,8 +34122,8 @@ var DashboardManager = class {
|
|
|
33926
34122
|
async stop() {
|
|
33927
34123
|
stopTunnel();
|
|
33928
34124
|
if (this.server) {
|
|
33929
|
-
await new Promise((
|
|
33930
|
-
this.server.close(() =>
|
|
34125
|
+
await new Promise((resolve9) => {
|
|
34126
|
+
this.server.close(() => resolve9());
|
|
33931
34127
|
});
|
|
33932
34128
|
this.server = null;
|
|
33933
34129
|
}
|
|
@@ -34040,8 +34236,8 @@ var PleriClient = class {
|
|
|
34040
34236
|
};
|
|
34041
34237
|
|
|
34042
34238
|
// ../mcp-server/src/env-loader.ts
|
|
34043
|
-
import { readFileSync as
|
|
34044
|
-
import { join as
|
|
34239
|
+
import { readFileSync as readFileSync17, existsSync as existsSync23, statSync as statSync7 } from "node:fs";
|
|
34240
|
+
import { join as join29, dirname as dirname15, resolve as resolve8 } from "node:path";
|
|
34045
34241
|
var PROJECT_MARKERS = [
|
|
34046
34242
|
".olam/config.yaml",
|
|
34047
34243
|
".olam/config.yml",
|
|
@@ -34049,16 +34245,16 @@ var PROJECT_MARKERS = [
|
|
|
34049
34245
|
"olam.yml"
|
|
34050
34246
|
];
|
|
34051
34247
|
function findProjectRoot2(startDir) {
|
|
34052
|
-
let dir =
|
|
34053
|
-
const root =
|
|
34248
|
+
let dir = resolve8(startDir);
|
|
34249
|
+
const root = resolve8("/");
|
|
34054
34250
|
while (true) {
|
|
34055
34251
|
for (const marker of PROJECT_MARKERS) {
|
|
34056
|
-
if (
|
|
34252
|
+
if (existsSync23(join29(dir, marker))) return dir;
|
|
34057
34253
|
}
|
|
34058
|
-
const pkg =
|
|
34059
|
-
if (
|
|
34254
|
+
const pkg = join29(dir, "package.json");
|
|
34255
|
+
if (existsSync23(pkg)) {
|
|
34060
34256
|
try {
|
|
34061
|
-
const json = JSON.parse(
|
|
34257
|
+
const json = JSON.parse(readFileSync17(pkg, "utf8"));
|
|
34062
34258
|
const isOlamWorkspace = typeof json.name === "string" && json.name.startsWith("@olam/");
|
|
34063
34259
|
const hasOlamDep = json.dependencies && Object.keys(json.dependencies).some((k) => k.startsWith("@olam/")) || json.devDependencies && Object.keys(json.devDependencies).some((k) => k.startsWith("@olam/"));
|
|
34064
34260
|
if (isOlamWorkspace || hasOlamDep) return dir;
|
|
@@ -34070,9 +34266,9 @@ function findProjectRoot2(startDir) {
|
|
|
34070
34266
|
dir = parent;
|
|
34071
34267
|
}
|
|
34072
34268
|
}
|
|
34073
|
-
function parseEnvFile(
|
|
34269
|
+
function parseEnvFile(path28) {
|
|
34074
34270
|
const out = {};
|
|
34075
|
-
const raw =
|
|
34271
|
+
const raw = readFileSync17(path28, "utf8");
|
|
34076
34272
|
for (const line of raw.split(/\r?\n/)) {
|
|
34077
34273
|
const trimmed = line.trim();
|
|
34078
34274
|
if (!trimmed || trimmed.startsWith("#")) continue;
|
|
@@ -34095,8 +34291,8 @@ function loadProjectEnv(startDir = process.cwd()) {
|
|
|
34095
34291
|
const filesRead = [];
|
|
34096
34292
|
const merged = {};
|
|
34097
34293
|
for (const name of [".env", ".env.local"]) {
|
|
34098
|
-
const p =
|
|
34099
|
-
if (
|
|
34294
|
+
const p = join29(root, name);
|
|
34295
|
+
if (existsSync23(p) && statSync7(p).isFile()) {
|
|
34100
34296
|
Object.assign(merged, parseEnvFile(p));
|
|
34101
34297
|
filesRead.push(p);
|
|
34102
34298
|
}
|