@pleri/olam-cli 0.1.56 → 0.1.58
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/__tests__/services.test.d.ts +8 -0
- package/dist/__tests__/services.test.d.ts.map +1 -0
- package/dist/__tests__/services.test.js +185 -0
- package/dist/__tests__/services.test.js.map +1 -0
- package/dist/commands/__tests__/__fixtures__/upgrade-helpers.d.ts +6 -0
- package/dist/commands/__tests__/__fixtures__/upgrade-helpers.d.ts.map +1 -0
- package/dist/commands/__tests__/__fixtures__/upgrade-helpers.js +26 -0
- package/dist/commands/__tests__/__fixtures__/upgrade-helpers.js.map +1 -0
- package/dist/commands/__tests__/upgrade.all-three.test.js +1 -13
- package/dist/commands/__tests__/upgrade.all-three.test.js.map +1 -1
- package/dist/commands/__tests__/upgrade.compose-path.test.js +1 -13
- package/dist/commands/__tests__/upgrade.compose-path.test.js.map +1 -1
- package/dist/commands/__tests__/upgrade.olam-tag.test.js +1 -14
- package/dist/commands/__tests__/upgrade.olam-tag.test.js.map +1 -1
- package/dist/commands/__tests__/upgrade.recreate.test.js +1 -13
- package/dist/commands/__tests__/upgrade.recreate.test.js.map +1 -1
- package/dist/commands/__tests__/upgrade.rollback.test.js +1 -21
- package/dist/commands/__tests__/upgrade.rollback.test.js.map +1 -1
- package/dist/commands/__tests__/upgrade.smoke.test.js +1 -21
- package/dist/commands/__tests__/upgrade.smoke.test.js.map +1 -1
- package/dist/commands/__tests__/upgrade.swap.test.js +1 -22
- package/dist/commands/__tests__/upgrade.swap.test.js.map +1 -1
- package/dist/commands/auth.d.ts.map +1 -1
- package/dist/commands/auth.js +15 -38
- package/dist/commands/auth.js.map +1 -1
- package/dist/commands/bootstrap.d.ts +2 -0
- package/dist/commands/bootstrap.d.ts.map +1 -1
- package/dist/commands/bootstrap.js +3 -3
- package/dist/commands/bootstrap.js.map +1 -1
- package/dist/commands/create.d.ts.map +1 -1
- package/dist/commands/create.js +1 -9
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/services.d.ts +39 -0
- package/dist/commands/services.d.ts.map +1 -0
- package/dist/commands/services.js +220 -0
- package/dist/commands/services.js.map +1 -0
- package/dist/commands/upgrade.d.ts +11 -0
- package/dist/commands/upgrade.d.ts.map +1 -1
- package/dist/commands/upgrade.js +70 -6
- package/dist/commands/upgrade.js.map +1 -1
- package/dist/image-digests.json +4 -3
- package/dist/index.js +953 -1023
- package/dist/index.js.map +1 -1
- package/dist/mcp-server.js +258 -370
- package/host-cp/src/server.mjs +9 -1
- package/package.json +1 -1
package/dist/mcp-server.js
CHANGED
|
@@ -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(path21) {
|
|
3232
|
+
let input = path21;
|
|
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 [path21, query] = wsComponent.resourceName.split("?");
|
|
3432
|
+
wsComponent.path = path21 && path21 !== "/" ? path21 : void 0;
|
|
3433
3433
|
wsComponent.query = query;
|
|
3434
3434
|
wsComponent.resourceName = void 0;
|
|
3435
3435
|
}
|
|
@@ -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, fs17, 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, fs17[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, path21) {
|
|
7006
|
+
if (!path21)
|
|
7007
7007
|
return obj;
|
|
7008
|
-
return
|
|
7008
|
+
return path21.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(path21, 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(path21);
|
|
7333
7333
|
return iss;
|
|
7334
7334
|
});
|
|
7335
7335
|
}
|
|
@@ -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: path21, errorMaps, issueData } = params;
|
|
13407
|
+
const fullPath = [...path21, ...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, path21, key) {
|
|
13524
13524
|
this._cachedPath = [];
|
|
13525
13525
|
this.parent = parent;
|
|
13526
13526
|
this.data = value;
|
|
13527
|
-
this._path =
|
|
13527
|
+
this._path = path21;
|
|
13528
13528
|
this._key = key;
|
|
13529
13529
|
}
|
|
13530
13530
|
get path() {
|
|
@@ -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, path21, body, attempt = 0) {
|
|
21369
|
+
const url = `${this.baseUrl}${path21}`;
|
|
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, path21, body, attempt + 1);
|
|
21388
21388
|
}
|
|
21389
21389
|
throw err;
|
|
21390
21390
|
} finally {
|
|
@@ -22191,12 +22191,12 @@ function register3(server, _ctx, _initError) {
|
|
|
22191
22191
|
registry2.close();
|
|
22192
22192
|
}
|
|
22193
22193
|
try {
|
|
22194
|
-
const { default:
|
|
22194
|
+
const { default: fs17 } = await import("node:fs");
|
|
22195
22195
|
const { default: os10 } = await import("node:os");
|
|
22196
|
-
const { default:
|
|
22197
|
-
const tokenPath =
|
|
22198
|
-
if (
|
|
22199
|
-
const token =
|
|
22196
|
+
const { default: path21 } = await import("node:path");
|
|
22197
|
+
const tokenPath = path21.join(os10.homedir(), ".olam", "host-cp.token");
|
|
22198
|
+
if (fs17.existsSync(tokenPath)) {
|
|
22199
|
+
const token = fs17.readFileSync(tokenPath, "utf-8").trim();
|
|
22200
22200
|
await fetch("http://127.0.0.1:19000/api/admin/world-pr", {
|
|
22201
22201
|
method: "POST",
|
|
22202
22202
|
headers: { "Content-Type": "application/json", Authorization: `Bearer ${token}` },
|
|
@@ -22389,7 +22389,7 @@ var KNOWN_TOP_LEVEL_KEYS = /* @__PURE__ */ new Set([
|
|
|
22389
22389
|
"deploy"
|
|
22390
22390
|
]);
|
|
22391
22391
|
var FORBIDDEN_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
22392
|
-
function refineForbiddenKeys(value,
|
|
22392
|
+
function refineForbiddenKeys(value, path21, ctx, rejectSource) {
|
|
22393
22393
|
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
22394
22394
|
return;
|
|
22395
22395
|
}
|
|
@@ -22397,12 +22397,12 @@ function refineForbiddenKeys(value, path22, ctx, rejectSource) {
|
|
|
22397
22397
|
if (FORBIDDEN_KEYS.has(key)) {
|
|
22398
22398
|
ctx.addIssue({
|
|
22399
22399
|
code: external_exports.ZodIssueCode.custom,
|
|
22400
|
-
path: [...
|
|
22400
|
+
path: [...path21, key],
|
|
22401
22401
|
message: `forbidden key "${key}" (prototype-pollution surface)`
|
|
22402
22402
|
});
|
|
22403
22403
|
continue;
|
|
22404
22404
|
}
|
|
22405
|
-
if (rejectSource &&
|
|
22405
|
+
if (rejectSource && path21.length === 0 && key === "source") {
|
|
22406
22406
|
ctx.addIssue({
|
|
22407
22407
|
code: external_exports.ZodIssueCode.custom,
|
|
22408
22408
|
path: ["source"],
|
|
@@ -22410,21 +22410,21 @@ function refineForbiddenKeys(value, path22, ctx, rejectSource) {
|
|
|
22410
22410
|
});
|
|
22411
22411
|
continue;
|
|
22412
22412
|
}
|
|
22413
|
-
refineForbiddenKeys(value[key], [...
|
|
22413
|
+
refineForbiddenKeys(value[key], [...path21, key], ctx, false);
|
|
22414
22414
|
}
|
|
22415
22415
|
}
|
|
22416
|
-
function rejectForbiddenKeys(value,
|
|
22416
|
+
function rejectForbiddenKeys(value, path21, rejectSource) {
|
|
22417
22417
|
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
22418
22418
|
return;
|
|
22419
22419
|
}
|
|
22420
22420
|
for (const key of Object.keys(value)) {
|
|
22421
22421
|
if (FORBIDDEN_KEYS.has(key)) {
|
|
22422
|
-
throw new Error(`[manifest] ${
|
|
22422
|
+
throw new Error(`[manifest] ${path21}: forbidden key "${key}" (prototype-pollution surface)`);
|
|
22423
22423
|
}
|
|
22424
22424
|
if (rejectSource && key === "source") {
|
|
22425
|
-
throw new Error(`[manifest] ${
|
|
22425
|
+
throw new Error(`[manifest] ${path21}: top-level "source" is loader-stamped \u2014 manifests must not author it`);
|
|
22426
22426
|
}
|
|
22427
|
-
rejectForbiddenKeys(value[key], `${
|
|
22427
|
+
rejectForbiddenKeys(value[key], `${path21}.${key}`, false);
|
|
22428
22428
|
}
|
|
22429
22429
|
}
|
|
22430
22430
|
function unknownTopLevelKeys(parsed) {
|
|
@@ -22862,10 +22862,10 @@ function extractMcpConfig(claudeJsonPath) {
|
|
|
22862
22862
|
}
|
|
22863
22863
|
return { mcpServers, secrets };
|
|
22864
22864
|
}
|
|
22865
|
-
function readOptional(
|
|
22866
|
-
if (!existsSync6(
|
|
22865
|
+
function readOptional(path21) {
|
|
22866
|
+
if (!existsSync6(path21)) return null;
|
|
22867
22867
|
try {
|
|
22868
|
-
return readFileSync5(
|
|
22868
|
+
return readFileSync5(path21, "utf8");
|
|
22869
22869
|
} catch {
|
|
22870
22870
|
return null;
|
|
22871
22871
|
}
|
|
@@ -24008,8 +24008,8 @@ var CloudflareProvider = class extends ComputeProvider {
|
|
|
24008
24008
|
// -----------------------------------------------------------------------
|
|
24009
24009
|
// Internal fetch helper
|
|
24010
24010
|
// -----------------------------------------------------------------------
|
|
24011
|
-
async request(
|
|
24012
|
-
const url = `${this.config.workerUrl}${
|
|
24011
|
+
async request(path21, method, body) {
|
|
24012
|
+
const url = `${this.config.workerUrl}${path21}`;
|
|
24013
24013
|
const bearer = await this.config.mintToken();
|
|
24014
24014
|
const headers = {
|
|
24015
24015
|
Authorization: `Bearer ${bearer}`
|
|
@@ -24989,10 +24989,10 @@ var ThoughtLocalStore = class {
|
|
|
24989
24989
|
};
|
|
24990
24990
|
|
|
24991
24991
|
// ../core/dist/world/env-setup.js
|
|
24992
|
-
import * as
|
|
24993
|
-
import * as
|
|
24992
|
+
import * as crypto2 from "node:crypto";
|
|
24993
|
+
import * as fs6 from "node:fs";
|
|
24994
24994
|
import * as os6 from "node:os";
|
|
24995
|
-
import * as
|
|
24995
|
+
import * as path9 from "node:path";
|
|
24996
24996
|
import { globSync } from "node:fs";
|
|
24997
24997
|
|
|
24998
24998
|
// ../core/dist/thought/hooks-config.js
|
|
@@ -25078,182 +25078,82 @@ function generateHooksConfig(hookServerUrl = DEFAULT_HOOK_SERVER_URL) {
|
|
|
25078
25078
|
};
|
|
25079
25079
|
}
|
|
25080
25080
|
|
|
25081
|
-
// ../core/dist/world/merge-settings.js
|
|
25082
|
-
import * as fs6 from "node:fs";
|
|
25083
|
-
import * as path9 from "node:path";
|
|
25084
|
-
import * as crypto2 from "node:crypto";
|
|
25085
|
-
function mergeHomeSettingsJson(filePath, options) {
|
|
25086
|
-
let settings;
|
|
25087
|
-
try {
|
|
25088
|
-
settings = readSettings(filePath);
|
|
25089
|
-
} catch (err) {
|
|
25090
|
-
throw new Error(`merge-settings: failed to parse existing settings.json: ${err?.message ?? err}`);
|
|
25091
|
-
}
|
|
25092
|
-
let changed = false;
|
|
25093
|
-
if (options.ensureHook) {
|
|
25094
|
-
const { stage, sentinel, entry } = options.ensureHook;
|
|
25095
|
-
if (!settings.hooks || typeof settings.hooks !== "object") {
|
|
25096
|
-
settings = { ...settings, hooks: {} };
|
|
25097
|
-
changed = true;
|
|
25098
|
-
}
|
|
25099
|
-
const hooks = settings.hooks;
|
|
25100
|
-
if (!Array.isArray(hooks[stage])) {
|
|
25101
|
-
settings = {
|
|
25102
|
-
...settings,
|
|
25103
|
-
hooks: { ...hooks, [stage]: [] }
|
|
25104
|
-
};
|
|
25105
|
-
changed = true;
|
|
25106
|
-
}
|
|
25107
|
-
const stageArr = settings.hooks[stage];
|
|
25108
|
-
if (isHookSentinelPresent(stageArr, sentinel)) {
|
|
25109
|
-
if (!changed) {
|
|
25110
|
-
return { status: "already-present", message: `hook already present at ${filePath}` };
|
|
25111
|
-
}
|
|
25112
|
-
} else {
|
|
25113
|
-
settings = {
|
|
25114
|
-
...settings,
|
|
25115
|
-
hooks: {
|
|
25116
|
-
...settings.hooks,
|
|
25117
|
-
[stage]: [...stageArr, entry]
|
|
25118
|
-
}
|
|
25119
|
-
};
|
|
25120
|
-
changed = true;
|
|
25121
|
-
}
|
|
25122
|
-
}
|
|
25123
|
-
if (options.env) {
|
|
25124
|
-
const existingEnv = settings.env && typeof settings.env === "object" ? settings.env : {};
|
|
25125
|
-
const mergedEnv = { ...existingEnv, ...options.env };
|
|
25126
|
-
const sameKeys = Object.keys(mergedEnv).length === Object.keys(existingEnv).length && Object.keys(mergedEnv).every((k) => existingEnv[k] === mergedEnv[k]);
|
|
25127
|
-
if (!sameKeys) {
|
|
25128
|
-
settings = { ...settings, env: mergedEnv };
|
|
25129
|
-
changed = true;
|
|
25130
|
-
}
|
|
25131
|
-
}
|
|
25132
|
-
if (!changed) {
|
|
25133
|
-
return { status: "no-op", message: `no change needed at ${filePath}` };
|
|
25134
|
-
}
|
|
25135
|
-
try {
|
|
25136
|
-
atomicWriteJson(filePath, settings);
|
|
25137
|
-
} catch (err) {
|
|
25138
|
-
throw new Error(`merge-settings: failed to write settings.json: ${err?.message ?? err}`);
|
|
25139
|
-
}
|
|
25140
|
-
return { status: "installed", message: `settings.json updated at ${filePath}` };
|
|
25141
|
-
}
|
|
25142
|
-
function readSettings(filePath) {
|
|
25143
|
-
if (!fs6.existsSync(filePath)) {
|
|
25144
|
-
return {};
|
|
25145
|
-
}
|
|
25146
|
-
const raw = fs6.readFileSync(filePath, "utf-8");
|
|
25147
|
-
if (!raw.trim())
|
|
25148
|
-
return {};
|
|
25149
|
-
return JSON.parse(raw);
|
|
25150
|
-
}
|
|
25151
|
-
function isHookSentinelPresent(matchers, sentinel) {
|
|
25152
|
-
for (const matcher of matchers) {
|
|
25153
|
-
if (typeof matcher?.command === "string" && matcher.command.includes(sentinel)) {
|
|
25154
|
-
return true;
|
|
25155
|
-
}
|
|
25156
|
-
if (Array.isArray(matcher?.hooks)) {
|
|
25157
|
-
for (const h of matcher.hooks) {
|
|
25158
|
-
if (typeof h?.command === "string" && h.command.includes(sentinel)) {
|
|
25159
|
-
return true;
|
|
25160
|
-
}
|
|
25161
|
-
}
|
|
25162
|
-
}
|
|
25163
|
-
}
|
|
25164
|
-
return false;
|
|
25165
|
-
}
|
|
25166
|
-
function atomicWriteJson(filePath, data) {
|
|
25167
|
-
const dir = path9.dirname(filePath);
|
|
25168
|
-
fs6.mkdirSync(dir, { recursive: true });
|
|
25169
|
-
const rand = crypto2.randomBytes(6).toString("hex");
|
|
25170
|
-
const tmp = `${filePath}.tmp.${process.pid}.${rand}`;
|
|
25171
|
-
const json = JSON.stringify(data, null, 2) + "\n";
|
|
25172
|
-
fs6.writeFileSync(tmp, json, { mode: 420 });
|
|
25173
|
-
fs6.renameSync(tmp, filePath);
|
|
25174
|
-
}
|
|
25175
|
-
|
|
25176
25081
|
// ../core/dist/world/env-setup.js
|
|
25177
25082
|
function copyClaudeConfig(workspacePath, homeDir, configCtx) {
|
|
25178
|
-
const sourceClaudeDir =
|
|
25179
|
-
const destClaudeDir =
|
|
25083
|
+
const sourceClaudeDir = path9.join(homeDir ?? os6.homedir(), ".claude");
|
|
25084
|
+
const destClaudeDir = path9.join(workspacePath, ".claude-host-config");
|
|
25180
25085
|
void configCtx;
|
|
25181
|
-
if (!
|
|
25086
|
+
if (!fs6.existsSync(sourceClaudeDir))
|
|
25182
25087
|
return;
|
|
25183
|
-
|
|
25184
|
-
const settingsPath =
|
|
25088
|
+
fs6.mkdirSync(destClaudeDir, { recursive: true });
|
|
25089
|
+
const settingsPath = path9.join(sourceClaudeDir, "settings.json");
|
|
25185
25090
|
let settings = {};
|
|
25186
|
-
if (
|
|
25091
|
+
if (fs6.existsSync(settingsPath)) {
|
|
25187
25092
|
try {
|
|
25188
|
-
settings = JSON.parse(
|
|
25093
|
+
settings = JSON.parse(fs6.readFileSync(settingsPath, "utf-8"));
|
|
25189
25094
|
delete settings["hooks"];
|
|
25190
25095
|
} catch {
|
|
25191
25096
|
}
|
|
25192
25097
|
}
|
|
25193
25098
|
const hooksConfig = generateHooksConfig(DEFAULT_HOOK_SERVER_URL);
|
|
25194
25099
|
settings["hooks"] = hooksConfig["hooks"];
|
|
25195
|
-
|
|
25196
|
-
const claudeMdPath =
|
|
25197
|
-
if (
|
|
25198
|
-
|
|
25100
|
+
fs6.writeFileSync(path9.join(destClaudeDir, "settings.json"), JSON.stringify(settings, null, 2));
|
|
25101
|
+
const claudeMdPath = path9.join(sourceClaudeDir, "CLAUDE.md");
|
|
25102
|
+
if (fs6.existsSync(claudeMdPath)) {
|
|
25103
|
+
fs6.copyFileSync(claudeMdPath, path9.join(destClaudeDir, "CLAUDE.md"));
|
|
25199
25104
|
}
|
|
25200
|
-
const rulesDir =
|
|
25201
|
-
if (
|
|
25202
|
-
copyDirRecursive(rulesDir,
|
|
25105
|
+
const rulesDir = path9.join(sourceClaudeDir, "rules");
|
|
25106
|
+
if (fs6.existsSync(rulesDir)) {
|
|
25107
|
+
copyDirRecursive(rulesDir, path9.join(destClaudeDir, "rules"));
|
|
25203
25108
|
}
|
|
25204
|
-
const agentsDir =
|
|
25205
|
-
if (
|
|
25206
|
-
copyDirRecursive(agentsDir,
|
|
25109
|
+
const agentsDir = path9.join(sourceClaudeDir, "agents");
|
|
25110
|
+
if (fs6.existsSync(agentsDir)) {
|
|
25111
|
+
copyDirRecursive(agentsDir, path9.join(destClaudeDir, "agents"));
|
|
25207
25112
|
}
|
|
25208
|
-
const pluginsDir =
|
|
25209
|
-
if (
|
|
25210
|
-
copyDirRecursive(pluginsDir,
|
|
25113
|
+
const pluginsDir = path9.join(sourceClaudeDir, "plugins");
|
|
25114
|
+
if (fs6.existsSync(pluginsDir)) {
|
|
25115
|
+
copyDirRecursive(pluginsDir, path9.join(destClaudeDir, "plugins"), 0, SKIP_FILES);
|
|
25211
25116
|
}
|
|
25212
|
-
const skillsDir =
|
|
25213
|
-
if (
|
|
25214
|
-
copyDirRecursive(skillsDir,
|
|
25117
|
+
const skillsDir = path9.join(sourceClaudeDir, "skills");
|
|
25118
|
+
if (fs6.existsSync(skillsDir)) {
|
|
25119
|
+
copyDirRecursive(skillsDir, path9.join(destClaudeDir, "skills"));
|
|
25215
25120
|
}
|
|
25216
|
-
const scriptsDir =
|
|
25217
|
-
if (
|
|
25218
|
-
copyDirRecursive(scriptsDir,
|
|
25121
|
+
const scriptsDir = path9.join(sourceClaudeDir, "scripts");
|
|
25122
|
+
if (fs6.existsSync(scriptsDir)) {
|
|
25123
|
+
copyDirRecursive(scriptsDir, path9.join(destClaudeDir, "scripts"));
|
|
25219
25124
|
}
|
|
25220
25125
|
applyProjectClaudeOverlay(workspacePath, destClaudeDir);
|
|
25221
25126
|
writeStrippedMcpServersSnapshot(homeDir ?? os6.homedir(), workspacePath, destClaudeDir);
|
|
25222
|
-
if (configCtx != null && configCtx.worlds_default?.agent_teams_enabled !== false) {
|
|
25223
|
-
mergeHomeSettingsJson(path10.join(destClaudeDir, "settings.json"), {
|
|
25224
|
-
env: { CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS: "1" }
|
|
25225
|
-
});
|
|
25226
|
-
}
|
|
25227
25127
|
}
|
|
25228
25128
|
function applyProjectClaudeOverlay(workspacePath, destClaudeDir) {
|
|
25229
|
-
const projectClaudeDir =
|
|
25230
|
-
if (!
|
|
25129
|
+
const projectClaudeDir = path9.join(workspacePath, ".claude");
|
|
25130
|
+
if (!fs6.existsSync(projectClaudeDir))
|
|
25231
25131
|
return;
|
|
25232
|
-
const projectSettingsPath =
|
|
25233
|
-
const destSettingsPath =
|
|
25234
|
-
if (
|
|
25132
|
+
const projectSettingsPath = path9.join(projectClaudeDir, "settings.json");
|
|
25133
|
+
const destSettingsPath = path9.join(destClaudeDir, "settings.json");
|
|
25134
|
+
if (fs6.existsSync(projectSettingsPath)) {
|
|
25235
25135
|
try {
|
|
25236
|
-
const projectSettings = JSON.parse(
|
|
25136
|
+
const projectSettings = JSON.parse(fs6.readFileSync(projectSettingsPath, "utf-8"));
|
|
25237
25137
|
delete projectSettings["hooks"];
|
|
25238
|
-
const existing =
|
|
25138
|
+
const existing = fs6.existsSync(destSettingsPath) ? JSON.parse(fs6.readFileSync(destSettingsPath, "utf-8")) : {};
|
|
25239
25139
|
const merged = { ...existing, ...projectSettings, hooks: existing["hooks"] };
|
|
25240
|
-
|
|
25140
|
+
fs6.writeFileSync(destSettingsPath, JSON.stringify(merged, null, 2));
|
|
25241
25141
|
} catch {
|
|
25242
25142
|
}
|
|
25243
25143
|
}
|
|
25244
|
-
const projectClaudeMd =
|
|
25245
|
-
if (
|
|
25246
|
-
|
|
25144
|
+
const projectClaudeMd = path9.join(projectClaudeDir, "CLAUDE.md");
|
|
25145
|
+
if (fs6.existsSync(projectClaudeMd)) {
|
|
25146
|
+
fs6.copyFileSync(projectClaudeMd, path9.join(destClaudeDir, "CLAUDE.md"));
|
|
25247
25147
|
}
|
|
25248
|
-
const projectAgentsMd =
|
|
25249
|
-
if (
|
|
25250
|
-
|
|
25148
|
+
const projectAgentsMd = path9.join(projectClaudeDir, "AGENTS.md");
|
|
25149
|
+
if (fs6.existsSync(projectAgentsMd)) {
|
|
25150
|
+
fs6.copyFileSync(projectAgentsMd, path9.join(destClaudeDir, "AGENTS.md"));
|
|
25251
25151
|
}
|
|
25252
25152
|
for (const subdir of ["rules", "agents", "plugins", "skills", "scripts"]) {
|
|
25253
|
-
const projectSubdir =
|
|
25254
|
-
if (
|
|
25153
|
+
const projectSubdir = path9.join(projectClaudeDir, subdir);
|
|
25154
|
+
if (fs6.existsSync(projectSubdir)) {
|
|
25255
25155
|
const skip = subdir === "plugins" ? SKIP_FILES : /* @__PURE__ */ new Set();
|
|
25256
|
-
copyDirRecursive(projectSubdir,
|
|
25156
|
+
copyDirRecursive(projectSubdir, path9.join(destClaudeDir, subdir), 0, skip);
|
|
25257
25157
|
}
|
|
25258
25158
|
}
|
|
25259
25159
|
}
|
|
@@ -25289,8 +25189,8 @@ function stripMcpServers(mcpServers) {
|
|
|
25289
25189
|
return out;
|
|
25290
25190
|
}
|
|
25291
25191
|
function writeStrippedMcpServersSnapshot(homeDir, workspacePath, destClaudeDir) {
|
|
25292
|
-
const hostMcpServers = readMcpServersFromFile(
|
|
25293
|
-
const projectMcpServers = readMcpServersFromFile(
|
|
25192
|
+
const hostMcpServers = readMcpServersFromFile(path9.join(homeDir, ".claude.json"));
|
|
25193
|
+
const projectMcpServers = readMcpServersFromFile(path9.join(workspacePath, ".mcp.json"));
|
|
25294
25194
|
if (Object.keys(hostMcpServers).length === 0 && Object.keys(projectMcpServers).length === 0) {
|
|
25295
25195
|
return;
|
|
25296
25196
|
}
|
|
@@ -25299,11 +25199,11 @@ function writeStrippedMcpServersSnapshot(homeDir, workspacePath, destClaudeDir)
|
|
|
25299
25199
|
...stripMcpServers(projectMcpServers)
|
|
25300
25200
|
};
|
|
25301
25201
|
const output = { mcpServers: stripped };
|
|
25302
|
-
|
|
25202
|
+
fs6.writeFileSync(path9.join(destClaudeDir, ".claude.json"), JSON.stringify(output, null, 2), { mode: 384 });
|
|
25303
25203
|
}
|
|
25304
25204
|
function writeWorldEntitlementsJson(workspacePath, configCtx) {
|
|
25305
|
-
const olamDir =
|
|
25306
|
-
|
|
25205
|
+
const olamDir = path9.join(workspacePath, ".olam");
|
|
25206
|
+
fs6.mkdirSync(olamDir, { recursive: true });
|
|
25307
25207
|
const resolvedRepos = configCtx.repos.map((repo) => {
|
|
25308
25208
|
const repoEntitlement = repo;
|
|
25309
25209
|
return {
|
|
@@ -25317,14 +25217,14 @@ function writeWorldEntitlementsJson(workspacePath, configCtx) {
|
|
|
25317
25217
|
worlds_default: configCtx.worlds_default,
|
|
25318
25218
|
repos: resolvedRepos
|
|
25319
25219
|
};
|
|
25320
|
-
const filePath =
|
|
25321
|
-
|
|
25220
|
+
const filePath = path9.join(olamDir, "world-entitlements.json");
|
|
25221
|
+
fs6.writeFileSync(filePath, JSON.stringify(resolved, null, 2), { mode: 420 });
|
|
25322
25222
|
}
|
|
25323
25223
|
function readMcpServersFromFile(filePath) {
|
|
25324
|
-
if (!
|
|
25224
|
+
if (!fs6.existsSync(filePath))
|
|
25325
25225
|
return {};
|
|
25326
25226
|
try {
|
|
25327
|
-
const raw =
|
|
25227
|
+
const raw = fs6.readFileSync(filePath, "utf-8");
|
|
25328
25228
|
if (!raw.trim())
|
|
25329
25229
|
return {};
|
|
25330
25230
|
const parsed = JSON.parse(raw);
|
|
@@ -25360,8 +25260,8 @@ var SKIP_DIRS = /* @__PURE__ */ new Set([
|
|
|
25360
25260
|
function copyDirRecursive(src, dest, depth = 0, skipFiles = /* @__PURE__ */ new Set()) {
|
|
25361
25261
|
if (depth > 10)
|
|
25362
25262
|
return;
|
|
25363
|
-
|
|
25364
|
-
for (const entry of
|
|
25263
|
+
fs6.mkdirSync(dest, { recursive: true });
|
|
25264
|
+
for (const entry of fs6.readdirSync(src, { withFileTypes: true })) {
|
|
25365
25265
|
const { name } = entry;
|
|
25366
25266
|
if (skipFiles.has(name))
|
|
25367
25267
|
continue;
|
|
@@ -25371,12 +25271,12 @@ function copyDirRecursive(src, dest, depth = 0, skipFiles = /* @__PURE__ */ new
|
|
|
25371
25271
|
continue;
|
|
25372
25272
|
if (entry.isDirectory() && SKIP_DIRS.has(name))
|
|
25373
25273
|
continue;
|
|
25374
|
-
const srcPath =
|
|
25375
|
-
const destPath =
|
|
25274
|
+
const srcPath = path9.join(src, name);
|
|
25275
|
+
const destPath = path9.join(dest, name);
|
|
25376
25276
|
if (entry.isSymbolicLink()) {
|
|
25377
25277
|
let stat;
|
|
25378
25278
|
try {
|
|
25379
|
-
stat =
|
|
25279
|
+
stat = fs6.statSync(srcPath);
|
|
25380
25280
|
} catch {
|
|
25381
25281
|
continue;
|
|
25382
25282
|
}
|
|
@@ -25385,12 +25285,12 @@ function copyDirRecursive(src, dest, depth = 0, skipFiles = /* @__PURE__ */ new
|
|
|
25385
25285
|
continue;
|
|
25386
25286
|
copyDirRecursive(srcPath, destPath, depth + 1, skipFiles);
|
|
25387
25287
|
} else if (stat.isFile()) {
|
|
25388
|
-
|
|
25288
|
+
fs6.copyFileSync(srcPath, destPath);
|
|
25389
25289
|
}
|
|
25390
25290
|
} else if (entry.isDirectory()) {
|
|
25391
25291
|
copyDirRecursive(srcPath, destPath, depth + 1, skipFiles);
|
|
25392
25292
|
} else {
|
|
25393
|
-
|
|
25293
|
+
fs6.copyFileSync(srcPath, destPath);
|
|
25394
25294
|
}
|
|
25395
25295
|
}
|
|
25396
25296
|
}
|
|
@@ -25559,9 +25459,9 @@ function setupWorldEnv(repos, workspacePath, serviceEnv, crossRepoEnv = {}, conf
|
|
|
25559
25459
|
}
|
|
25560
25460
|
}
|
|
25561
25461
|
for (const repo of repos) {
|
|
25562
|
-
const worktreePath =
|
|
25462
|
+
const worktreePath = path9.join(workspacePath, repo.name);
|
|
25563
25463
|
const sourcePath = repo.path;
|
|
25564
|
-
if (!sourcePath || !
|
|
25464
|
+
if (!sourcePath || !fs6.existsSync(worktreePath))
|
|
25565
25465
|
continue;
|
|
25566
25466
|
const envSetup = repo.env_setup;
|
|
25567
25467
|
if (!envSetup)
|
|
@@ -25580,23 +25480,23 @@ function setupWorldEnv(repos, workspacePath, serviceEnv, crossRepoEnv = {}, conf
|
|
|
25580
25480
|
}
|
|
25581
25481
|
}
|
|
25582
25482
|
function copyMatchingFiles(sourcePath, destPath, pattern) {
|
|
25583
|
-
const fullPattern =
|
|
25483
|
+
const fullPattern = path9.join(sourcePath, pattern);
|
|
25584
25484
|
if (!pattern.includes("*")) {
|
|
25585
|
-
const sourceFile =
|
|
25586
|
-
const destFile =
|
|
25587
|
-
if (
|
|
25588
|
-
|
|
25589
|
-
|
|
25485
|
+
const sourceFile = path9.join(sourcePath, pattern);
|
|
25486
|
+
const destFile = path9.join(destPath, pattern);
|
|
25487
|
+
if (fs6.existsSync(sourceFile)) {
|
|
25488
|
+
fs6.mkdirSync(path9.dirname(destFile), { recursive: true });
|
|
25489
|
+
fs6.copyFileSync(sourceFile, destFile);
|
|
25590
25490
|
}
|
|
25591
25491
|
return;
|
|
25592
25492
|
}
|
|
25593
25493
|
try {
|
|
25594
25494
|
const matches2 = globSync(fullPattern);
|
|
25595
25495
|
for (const match of matches2) {
|
|
25596
|
-
const relative2 =
|
|
25597
|
-
const dest =
|
|
25598
|
-
|
|
25599
|
-
|
|
25496
|
+
const relative2 = path9.relative(sourcePath, match);
|
|
25497
|
+
const dest = path9.join(destPath, relative2);
|
|
25498
|
+
fs6.mkdirSync(path9.dirname(dest), { recursive: true });
|
|
25499
|
+
fs6.copyFileSync(match, dest);
|
|
25600
25500
|
}
|
|
25601
25501
|
} catch {
|
|
25602
25502
|
}
|
|
@@ -25604,14 +25504,14 @@ function copyMatchingFiles(sourcePath, destPath, pattern) {
|
|
|
25604
25504
|
function generateEnvFromExample(repoPath, overrides) {
|
|
25605
25505
|
const exampleFiles = [".env.example", ".env.sample", ".env.local.example"];
|
|
25606
25506
|
for (const exampleName of exampleFiles) {
|
|
25607
|
-
const examplePath =
|
|
25608
|
-
if (!
|
|
25507
|
+
const examplePath = path9.join(repoPath, exampleName);
|
|
25508
|
+
if (!fs6.existsSync(examplePath))
|
|
25609
25509
|
continue;
|
|
25610
25510
|
const targetName = exampleName.replace(".example", "").replace(".sample", "");
|
|
25611
|
-
const targetPath =
|
|
25612
|
-
if (
|
|
25511
|
+
const targetPath = path9.join(repoPath, targetName);
|
|
25512
|
+
if (fs6.existsSync(targetPath))
|
|
25613
25513
|
continue;
|
|
25614
|
-
const template =
|
|
25514
|
+
const template = fs6.readFileSync(examplePath, "utf-8");
|
|
25615
25515
|
const generated = template.split("\n").map((line) => {
|
|
25616
25516
|
const match = /^([A-Z_][A-Z0-9_]*)=(.*)$/.exec(line);
|
|
25617
25517
|
if (match) {
|
|
@@ -25622,13 +25522,13 @@ function generateEnvFromExample(repoPath, overrides) {
|
|
|
25622
25522
|
}
|
|
25623
25523
|
return line;
|
|
25624
25524
|
}).join("\n");
|
|
25625
|
-
|
|
25525
|
+
fs6.writeFileSync(targetPath, generated);
|
|
25626
25526
|
}
|
|
25627
25527
|
}
|
|
25628
25528
|
function applyEnvOverrides(repoPath, overrides) {
|
|
25629
|
-
const envPath =
|
|
25630
|
-
if (
|
|
25631
|
-
const existing =
|
|
25529
|
+
const envPath = path9.join(repoPath, ".env");
|
|
25530
|
+
if (fs6.existsSync(envPath)) {
|
|
25531
|
+
const existing = fs6.readFileSync(envPath, "utf-8");
|
|
25632
25532
|
const existingKeys = new Set(existing.split("\n").map((l) => l.split("=")[0]?.trim()).filter(Boolean));
|
|
25633
25533
|
const additions = [];
|
|
25634
25534
|
for (const [key, value] of Object.entries(overrides)) {
|
|
@@ -25637,7 +25537,7 @@ function applyEnvOverrides(repoPath, overrides) {
|
|
|
25637
25537
|
}
|
|
25638
25538
|
}
|
|
25639
25539
|
if (additions.length > 0) {
|
|
25640
|
-
|
|
25540
|
+
fs6.appendFileSync(envPath, "\n# Olam injected\n" + additions.join("\n") + "\n");
|
|
25641
25541
|
}
|
|
25642
25542
|
}
|
|
25643
25543
|
}
|
|
@@ -25894,7 +25794,7 @@ __export(world_crystallize_exports, {
|
|
|
25894
25794
|
register: () => register12
|
|
25895
25795
|
});
|
|
25896
25796
|
import "node:path";
|
|
25897
|
-
import * as
|
|
25797
|
+
import * as fs7 from "node:fs";
|
|
25898
25798
|
|
|
25899
25799
|
// ../core/dist/crystallize/checksum.js
|
|
25900
25800
|
import { createHash as createHash2 } from "node:crypto";
|
|
@@ -25950,7 +25850,7 @@ function register12(server, ctx, initError) {
|
|
|
25950
25850
|
}
|
|
25951
25851
|
try {
|
|
25952
25852
|
const thoughtDbPath = getWorldDbPath(world.workspacePath);
|
|
25953
|
-
if (!
|
|
25853
|
+
if (!fs7.existsSync(thoughtDbPath)) {
|
|
25954
25854
|
return {
|
|
25955
25855
|
content: [{
|
|
25956
25856
|
type: "text",
|
|
@@ -26536,23 +26436,23 @@ async function writeManifest(args) {
|
|
|
26536
26436
|
capturedAt: args.capturedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
26537
26437
|
shots: entries
|
|
26538
26438
|
};
|
|
26539
|
-
const
|
|
26540
|
-
await writeFile(
|
|
26439
|
+
const path21 = join12(args.outDir, "manifest.json");
|
|
26440
|
+
await writeFile(path21, `${JSON.stringify(manifest, null, 2)}
|
|
26541
26441
|
`, "utf8");
|
|
26542
|
-
return { path:
|
|
26442
|
+
return { path: path21, manifest };
|
|
26543
26443
|
}
|
|
26544
26444
|
|
|
26545
26445
|
// ../mcp-server/src/tools/_capture/proxy.ts
|
|
26546
|
-
import { chmodSync as chmodSync3, mkdirSync as
|
|
26446
|
+
import { chmodSync as chmodSync3, mkdirSync as mkdirSync7, statSync as statSync3, unlinkSync as unlinkSync2 } from "node:fs";
|
|
26547
26447
|
import { createServer as createServer2 } from "node:http";
|
|
26548
26448
|
import { request as httpRequest } from "node:http";
|
|
26549
26449
|
import { request as httpsRequest } from "node:https";
|
|
26550
26450
|
import { connect as netConnect } from "node:net";
|
|
26551
|
-
import { dirname as
|
|
26451
|
+
import { dirname as dirname6 } from "node:path";
|
|
26552
26452
|
import { userInfo } from "node:os";
|
|
26553
26453
|
|
|
26554
26454
|
// ../mcp-server/src/tools/_capture/token.ts
|
|
26555
|
-
import { createHmac, randomBytes as
|
|
26455
|
+
import { createHmac, randomBytes as randomBytes3, timingSafeEqual } from "node:crypto";
|
|
26556
26456
|
var HOST_TTL_MAX_SEC = 600;
|
|
26557
26457
|
var WORLD_TTL_MAX_SEC = 60;
|
|
26558
26458
|
var WORLD_HOURLY_QUOTA = 50;
|
|
@@ -26594,7 +26494,7 @@ function loadHmacKey() {
|
|
|
26594
26494
|
);
|
|
26595
26495
|
_autoKeyWarned = true;
|
|
26596
26496
|
}
|
|
26597
|
-
_hmacKey =
|
|
26497
|
+
_hmacKey = randomBytes3(32);
|
|
26598
26498
|
return _hmacKey;
|
|
26599
26499
|
}
|
|
26600
26500
|
function base64url2(buf) {
|
|
@@ -26662,7 +26562,7 @@ function mintToken(input) {
|
|
|
26662
26562
|
window2.count++;
|
|
26663
26563
|
}
|
|
26664
26564
|
}
|
|
26665
|
-
const correlationId = base32Crockford(
|
|
26565
|
+
const correlationId = base32Crockford(randomBytes3(16));
|
|
26666
26566
|
const exp = Math.floor(_now() / 1e3) + ttlClamped;
|
|
26667
26567
|
const scope = {
|
|
26668
26568
|
allowedPaths: input.allowedPaths,
|
|
@@ -26793,9 +26693,9 @@ async function startProxy(opts) {
|
|
|
26793
26693
|
const liveCompiled = verified.allowedPaths.map(compileGlob);
|
|
26794
26694
|
const target = parseRequestTarget(req);
|
|
26795
26695
|
if (!target) return httpReject(400, "invalid_target");
|
|
26796
|
-
const
|
|
26797
|
-
if (!liveCompiled.some((re) => re.test(
|
|
26798
|
-
return httpReject(403, "outside_allow_list", { path:
|
|
26696
|
+
const path21 = target.pathname;
|
|
26697
|
+
if (!liveCompiled.some((re) => re.test(path21))) {
|
|
26698
|
+
return httpReject(403, "outside_allow_list", { path: path21 });
|
|
26799
26699
|
}
|
|
26800
26700
|
const headerWorld = req.headers[WORLD_ASSERT_HEADER];
|
|
26801
26701
|
const headerWorldStr = typeof headerWorld === "string" ? headerWorld : Array.isArray(headerWorld) && headerWorld.length > 0 ? headerWorld[0] : void 0;
|
|
@@ -26950,7 +26850,7 @@ ${JSON.stringify({ error: reason })}`
|
|
|
26950
26850
|
};
|
|
26951
26851
|
}
|
|
26952
26852
|
function ensureUdsParentDirSafe(udsPath) {
|
|
26953
|
-
const parent =
|
|
26853
|
+
const parent = dirname6(udsPath);
|
|
26954
26854
|
if (!parent || parent === udsPath || parent === ".") {
|
|
26955
26855
|
throw new Error(
|
|
26956
26856
|
`uds_parent_path_invalid: bindUdsPath "${udsPath}" has no manageable parent directory`
|
|
@@ -26967,7 +26867,7 @@ function ensureUdsParentDirSafe(udsPath) {
|
|
|
26967
26867
|
}
|
|
26968
26868
|
}
|
|
26969
26869
|
if (!stat) {
|
|
26970
|
-
|
|
26870
|
+
mkdirSync7(parent, { recursive: true, mode: 448 });
|
|
26971
26871
|
return;
|
|
26972
26872
|
}
|
|
26973
26873
|
if (!stat.isDirectory()) {
|
|
@@ -27574,14 +27474,14 @@ async function runShot(browser, shot, outDir, format, jpegQuality, allowEval, as
|
|
|
27574
27474
|
await page.waitForTimeout(shot.afterLoadMs);
|
|
27575
27475
|
}
|
|
27576
27476
|
const ext = format === "jpeg" ? "jpg" : "png";
|
|
27577
|
-
const
|
|
27477
|
+
const path21 = join13(outDir, `${shot.name}.${ext}`);
|
|
27578
27478
|
await page.screenshot({
|
|
27579
|
-
path:
|
|
27479
|
+
path: path21,
|
|
27580
27480
|
type: format,
|
|
27581
27481
|
...format === "jpeg" ? { quality: jpegQuality } : {},
|
|
27582
27482
|
fullPage: false
|
|
27583
27483
|
});
|
|
27584
|
-
return { name: shot.name, path:
|
|
27484
|
+
return { name: shot.name, path: path21, urlRedacted: redactUrl(shot.url), viewport };
|
|
27585
27485
|
} finally {
|
|
27586
27486
|
await context.close();
|
|
27587
27487
|
}
|
|
@@ -28024,12 +27924,12 @@ function openUrl(url) {
|
|
|
28024
27924
|
var HOST_CP_URL = "http://127.0.0.1:19000";
|
|
28025
27925
|
async function readHostCpToken2() {
|
|
28026
27926
|
try {
|
|
28027
|
-
const { default:
|
|
27927
|
+
const { default: fs17 } = await import("node:fs");
|
|
28028
27928
|
const { default: os10 } = await import("node:os");
|
|
28029
|
-
const { default:
|
|
28030
|
-
const tp =
|
|
28031
|
-
if (!
|
|
28032
|
-
return { token:
|
|
27929
|
+
const { default: path21 } = await import("node:path");
|
|
27930
|
+
const tp = path21.join(os10.homedir(), ".olam", "host-cp.token");
|
|
27931
|
+
if (!fs17.existsSync(tp)) return { token: null };
|
|
27932
|
+
return { token: fs17.readFileSync(tp, "utf-8").trim() };
|
|
28033
27933
|
} catch {
|
|
28034
27934
|
return { token: null };
|
|
28035
27935
|
}
|
|
@@ -28309,8 +28209,8 @@ function createServer3(ctx, initError) {
|
|
|
28309
28209
|
}
|
|
28310
28210
|
|
|
28311
28211
|
// ../core/dist/config/loader.js
|
|
28312
|
-
import * as
|
|
28313
|
-
import * as
|
|
28212
|
+
import * as fs9 from "node:fs";
|
|
28213
|
+
import * as path12 from "node:path";
|
|
28314
28214
|
import { parse as parseYaml2 } from "yaml";
|
|
28315
28215
|
|
|
28316
28216
|
// ../core/dist/config/schema.js
|
|
@@ -28690,11 +28590,11 @@ function substituteEnvVars(obj) {
|
|
|
28690
28590
|
}
|
|
28691
28591
|
|
|
28692
28592
|
// ../core/dist/config/dotenv.js
|
|
28693
|
-
import * as
|
|
28593
|
+
import * as fs8 from "node:fs";
|
|
28694
28594
|
function loadDotEnv(envPath) {
|
|
28695
|
-
if (!
|
|
28595
|
+
if (!fs8.existsSync(envPath))
|
|
28696
28596
|
return;
|
|
28697
|
-
const content =
|
|
28597
|
+
const content = fs8.readFileSync(envPath, "utf-8");
|
|
28698
28598
|
for (const line of content.split("\n")) {
|
|
28699
28599
|
const trimmed = line.trim();
|
|
28700
28600
|
if (!trimmed || trimmed.startsWith("#"))
|
|
@@ -28713,18 +28613,18 @@ function loadDotEnv(envPath) {
|
|
|
28713
28613
|
// ../core/dist/config/loader.js
|
|
28714
28614
|
function findConfigFile(startDir) {
|
|
28715
28615
|
const searched = [];
|
|
28716
|
-
let current =
|
|
28616
|
+
let current = path12.resolve(startDir);
|
|
28717
28617
|
while (true) {
|
|
28718
|
-
const newLayout =
|
|
28719
|
-
const legacyLayout =
|
|
28618
|
+
const newLayout = path12.join(current, CONFIG_DIR_NAME, CONFIG_FILENAME);
|
|
28619
|
+
const legacyLayout = path12.join(current, LEGACY_CONFIG_FILENAME);
|
|
28720
28620
|
searched.push(newLayout, legacyLayout);
|
|
28721
|
-
if (
|
|
28621
|
+
if (fs9.existsSync(newLayout)) {
|
|
28722
28622
|
return { path: newLayout, isLegacy: false };
|
|
28723
28623
|
}
|
|
28724
|
-
if (
|
|
28624
|
+
if (fs9.existsSync(legacyLayout)) {
|
|
28725
28625
|
return { path: legacyLayout, isLegacy: true };
|
|
28726
28626
|
}
|
|
28727
|
-
const parent =
|
|
28627
|
+
const parent = path12.dirname(current);
|
|
28728
28628
|
if (parent === current)
|
|
28729
28629
|
break;
|
|
28730
28630
|
current = parent;
|
|
@@ -28739,12 +28639,12 @@ function loadConfig(startDir) {
|
|
|
28739
28639
|
Run /olam:init to migrate to .olam/config.yaml
|
|
28740
28640
|
`);
|
|
28741
28641
|
} else {
|
|
28742
|
-
const envPath =
|
|
28642
|
+
const envPath = path12.join(path12.dirname(found.path), ".env");
|
|
28743
28643
|
loadDotEnv(envPath);
|
|
28744
28644
|
}
|
|
28745
28645
|
let rawContent;
|
|
28746
28646
|
try {
|
|
28747
|
-
rawContent =
|
|
28647
|
+
rawContent = fs9.readFileSync(found.path, "utf-8");
|
|
28748
28648
|
} catch (err) {
|
|
28749
28649
|
throw new Error(`Failed to read ${found.path}: ${err instanceof Error ? err.message : String(err)}`);
|
|
28750
28650
|
}
|
|
@@ -28774,11 +28674,11 @@ function loadConfig(startDir) {
|
|
|
28774
28674
|
}
|
|
28775
28675
|
|
|
28776
28676
|
// ../core/dist/world/manager.js
|
|
28777
|
-
import * as
|
|
28677
|
+
import * as crypto4 from "node:crypto";
|
|
28778
28678
|
import { execSync as execSync4 } from "node:child_process";
|
|
28779
|
-
import * as
|
|
28679
|
+
import * as fs14 from "node:fs";
|
|
28780
28680
|
import * as os8 from "node:os";
|
|
28781
|
-
import * as
|
|
28681
|
+
import * as path18 from "node:path";
|
|
28782
28682
|
|
|
28783
28683
|
// ../core/dist/world/state.js
|
|
28784
28684
|
var VALID_TRANSITIONS = {
|
|
@@ -28860,8 +28760,8 @@ function resolveDevboxImage(config2, tag) {
|
|
|
28860
28760
|
|
|
28861
28761
|
// ../core/dist/world/worktree.js
|
|
28862
28762
|
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
28863
|
-
import * as
|
|
28864
|
-
import * as
|
|
28763
|
+
import * as fs10 from "node:fs";
|
|
28764
|
+
import * as path13 from "node:path";
|
|
28865
28765
|
function resolveGitDir(repo) {
|
|
28866
28766
|
if (repo.path) {
|
|
28867
28767
|
return repo.path;
|
|
@@ -28871,11 +28771,11 @@ function resolveGitDir(repo) {
|
|
|
28871
28771
|
async function createWorktrees(repos, worldId, workspacePath, branch) {
|
|
28872
28772
|
const created = [];
|
|
28873
28773
|
for (const repo of repos) {
|
|
28874
|
-
const worktreePath =
|
|
28774
|
+
const worktreePath = path13.join(workspacePath, repo.name);
|
|
28875
28775
|
const gitDir = resolveGitDir(repo);
|
|
28876
28776
|
const branchName = branch || `olam/${worldId}`;
|
|
28877
28777
|
try {
|
|
28878
|
-
|
|
28778
|
+
fs10.mkdirSync(path13.dirname(worktreePath), { recursive: true });
|
|
28879
28779
|
execFileSync2("git", ["worktree", "add", worktreePath, "-b", branchName], {
|
|
28880
28780
|
cwd: gitDir,
|
|
28881
28781
|
stdio: "pipe"
|
|
@@ -28908,7 +28808,7 @@ async function createWorktrees(repos, worldId, workspacePath, branch) {
|
|
|
28908
28808
|
}
|
|
28909
28809
|
async function removeWorktrees(repos, workspacePath) {
|
|
28910
28810
|
for (const repo of repos) {
|
|
28911
|
-
const worktreePath =
|
|
28811
|
+
const worktreePath = path13.join(workspacePath, repo.name);
|
|
28912
28812
|
let gitDir;
|
|
28913
28813
|
try {
|
|
28914
28814
|
gitDir = resolveGitDir(repo);
|
|
@@ -28983,9 +28883,9 @@ function removeBranch(repo, branch) {
|
|
|
28983
28883
|
|
|
28984
28884
|
// ../core/dist/world/baseline-diff.js
|
|
28985
28885
|
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
28986
|
-
import * as
|
|
28886
|
+
import * as fs11 from "node:fs";
|
|
28987
28887
|
import * as os7 from "node:os";
|
|
28988
|
-
import * as
|
|
28888
|
+
import * as path14 from "node:path";
|
|
28989
28889
|
var DEFAULT_MAX_BUFFER_BYTES = 50 * 1024 * 1024;
|
|
28990
28890
|
function expandHome(p, homedir11) {
|
|
28991
28891
|
return p.replace(/^~(?=$|\/|\\)/, homedir11());
|
|
@@ -29012,9 +28912,9 @@ ${stderr}`;
|
|
|
29012
28912
|
function snapshotBaselineDiff(repos, workspacePath, deps = {}) {
|
|
29013
28913
|
const exec = deps.exec ?? ((cmd, args, opts) => execFileSync3(cmd, args, opts));
|
|
29014
28914
|
const homedir11 = deps.homedir ?? (() => os7.homedir());
|
|
29015
|
-
const baselineDir =
|
|
28915
|
+
const baselineDir = path14.join(workspacePath, ".olam", "baseline");
|
|
29016
28916
|
try {
|
|
29017
|
-
|
|
28917
|
+
fs11.mkdirSync(baselineDir, { recursive: true });
|
|
29018
28918
|
} catch (err) {
|
|
29019
28919
|
const msg = err instanceof Error ? err.message : String(err);
|
|
29020
28920
|
console.warn(`[baseline-diff] mkdir ${baselineDir} failed: ${msg}; reaper will see no baseline at all`);
|
|
@@ -29026,9 +28926,9 @@ function snapshotBaselineDiff(repos, workspacePath, deps = {}) {
|
|
|
29026
28926
|
if (!repo.path)
|
|
29027
28927
|
continue;
|
|
29028
28928
|
const filename = `${sanitizeRepoFilename(repo.name)}.diff`;
|
|
29029
|
-
const outPath =
|
|
28929
|
+
const outPath = path14.join(baselineDir, filename);
|
|
29030
28930
|
const repoPath = expandHome(repo.path, homedir11);
|
|
29031
|
-
if (!
|
|
28931
|
+
if (!fs11.existsSync(repoPath)) {
|
|
29032
28932
|
writeBaselineFile(outPath, `# repo: ${repo.name}
|
|
29033
28933
|
# (skipped: path ${repoPath} does not exist)
|
|
29034
28934
|
`);
|
|
@@ -29095,7 +28995,7 @@ function snapshotBaselineDiff(repos, workspacePath, deps = {}) {
|
|
|
29095
28995
|
}
|
|
29096
28996
|
function writeBaselineFile(outPath, content) {
|
|
29097
28997
|
try {
|
|
29098
|
-
|
|
28998
|
+
fs11.writeFileSync(outPath, content);
|
|
29099
28999
|
} catch (err) {
|
|
29100
29000
|
const msg = err instanceof Error ? err.message : String(err);
|
|
29101
29001
|
console.warn(`[baseline-diff] write to ${outPath} failed: ${msg}`);
|
|
@@ -29103,8 +29003,8 @@ function writeBaselineFile(outPath, content) {
|
|
|
29103
29003
|
}
|
|
29104
29004
|
function stripWorktreeEdits(repos, workspacePath) {
|
|
29105
29005
|
for (const repo of repos) {
|
|
29106
|
-
const worktreePath =
|
|
29107
|
-
if (!
|
|
29006
|
+
const worktreePath = path14.join(workspacePath, repo.name);
|
|
29007
|
+
if (!fs11.existsSync(worktreePath))
|
|
29108
29008
|
continue;
|
|
29109
29009
|
try {
|
|
29110
29010
|
execFileSync3("git", ["checkout", "--", "."], {
|
|
@@ -29134,12 +29034,12 @@ function formatBaselineSummary(result) {
|
|
|
29134
29034
|
}
|
|
29135
29035
|
|
|
29136
29036
|
// ../core/dist/world/context-injection.js
|
|
29137
|
-
import * as
|
|
29138
|
-
import * as
|
|
29037
|
+
import * as fs12 from "node:fs";
|
|
29038
|
+
import * as path15 from "node:path";
|
|
29139
29039
|
function injectWorldContext(opts) {
|
|
29140
29040
|
const { world, task, linearTicketId, claudeMdExtra, taskContext, services, pleriPlaneUrl } = opts;
|
|
29141
|
-
const claudeDir =
|
|
29142
|
-
|
|
29041
|
+
const claudeDir = path15.join(world.workspacePath, ".claude");
|
|
29042
|
+
fs12.mkdirSync(claudeDir, { recursive: true });
|
|
29143
29043
|
const sections = [];
|
|
29144
29044
|
sections.push(`# Olam World: ${world.name}`);
|
|
29145
29045
|
sections.push("");
|
|
@@ -29300,7 +29200,7 @@ function injectWorldContext(opts) {
|
|
|
29300
29200
|
sections.push("");
|
|
29301
29201
|
}
|
|
29302
29202
|
const content = sections.join("\n");
|
|
29303
|
-
|
|
29203
|
+
fs12.writeFileSync(path15.join(claudeDir, "CLAUDE.md"), content);
|
|
29304
29204
|
}
|
|
29305
29205
|
function formatTaskSource(ctx) {
|
|
29306
29206
|
if (ctx.source === "linear" && ctx.ticketId) {
|
|
@@ -29314,9 +29214,9 @@ function formatTaskSource(ctx) {
|
|
|
29314
29214
|
function hasPlanFile(world) {
|
|
29315
29215
|
if (world.repos.length === 0)
|
|
29316
29216
|
return false;
|
|
29317
|
-
const plansDir =
|
|
29217
|
+
const plansDir = path15.join(world.workspacePath, world.repos[0], "docs", "plans");
|
|
29318
29218
|
try {
|
|
29319
|
-
return
|
|
29219
|
+
return fs12.existsSync(plansDir) && fs12.readdirSync(plansDir).length > 0;
|
|
29320
29220
|
} catch {
|
|
29321
29221
|
return false;
|
|
29322
29222
|
}
|
|
@@ -29543,7 +29443,7 @@ async function installStack(exec, repos, stacks) {
|
|
|
29543
29443
|
|
|
29544
29444
|
// ../core/dist/world/stack-image.js
|
|
29545
29445
|
import { execSync as execSync2 } from "node:child_process";
|
|
29546
|
-
import * as
|
|
29446
|
+
import * as crypto3 from "node:crypto";
|
|
29547
29447
|
var BASE_IMAGE = "olam-devbox";
|
|
29548
29448
|
var LABEL_PREFIX = "olam.stack-image";
|
|
29549
29449
|
var MAX_TAG_LENGTH = 128;
|
|
@@ -29597,14 +29497,14 @@ function getBaseImageDigest() {
|
|
|
29597
29497
|
cachedBaseDigest = digest.replace("sha256:", "").slice(0, 16);
|
|
29598
29498
|
return cachedBaseDigest;
|
|
29599
29499
|
} catch {
|
|
29600
|
-
cachedBaseDigest =
|
|
29500
|
+
cachedBaseDigest = crypto3.createHash("sha256").update("unknown").digest("hex").slice(0, 16);
|
|
29601
29501
|
return cachedBaseDigest;
|
|
29602
29502
|
}
|
|
29603
29503
|
}
|
|
29604
29504
|
function sanitizeTag(raw) {
|
|
29605
29505
|
let tag = raw.toLowerCase().replace(/[^a-z0-9._-]/g, "-");
|
|
29606
29506
|
if (tag.length > MAX_TAG_LENGTH) {
|
|
29607
|
-
const hash =
|
|
29507
|
+
const hash = crypto3.createHash("sha256").update(raw).digest("hex").slice(0, 12);
|
|
29608
29508
|
tag = tag.slice(0, MAX_TAG_LENGTH - 13) + "_" + hash;
|
|
29609
29509
|
}
|
|
29610
29510
|
return tag;
|
|
@@ -29982,14 +29882,14 @@ function gcloudAvailable(execFn = defaultExecFn) {
|
|
|
29982
29882
|
}
|
|
29983
29883
|
|
|
29984
29884
|
// ../core/dist/world/olam-yaml.js
|
|
29985
|
-
import * as
|
|
29885
|
+
import * as path16 from "node:path";
|
|
29986
29886
|
import YAML2 from "yaml";
|
|
29987
29887
|
function enrichReposWithManifests(repos, workspacePath) {
|
|
29988
29888
|
return repos.map((repo) => {
|
|
29989
29889
|
if (repo.manifest !== void 0 && repo.manifest !== null) {
|
|
29990
29890
|
return repo;
|
|
29991
29891
|
}
|
|
29992
|
-
const repoDir =
|
|
29892
|
+
const repoDir = path16.join(workspacePath, repo.name);
|
|
29993
29893
|
let manifest = null;
|
|
29994
29894
|
try {
|
|
29995
29895
|
manifest = loadRepoManifest(repoDir);
|
|
@@ -30004,8 +29904,8 @@ function enrichReposWithManifests(repos, workspacePath) {
|
|
|
30004
29904
|
}
|
|
30005
29905
|
|
|
30006
29906
|
// ../core/dist/policies/loader.js
|
|
30007
|
-
import * as
|
|
30008
|
-
import * as
|
|
29907
|
+
import * as fs13 from "node:fs";
|
|
29908
|
+
import * as path17 from "node:path";
|
|
30009
29909
|
import { parse as parseYaml3 } from "yaml";
|
|
30010
29910
|
function parseFrontmatter(content) {
|
|
30011
29911
|
const match = /^---\r?\n([\s\S]*?)\r?\n---\r?\n([\s\S]*)$/m.exec(content);
|
|
@@ -30025,20 +29925,20 @@ function toStringArray(v) {
|
|
|
30025
29925
|
return v.filter((x) => typeof x === "string");
|
|
30026
29926
|
}
|
|
30027
29927
|
function loadPolicies(workspaceRoot) {
|
|
30028
|
-
const policiesDir =
|
|
30029
|
-
if (!
|
|
29928
|
+
const policiesDir = path17.join(workspaceRoot, ".olam", "policies");
|
|
29929
|
+
if (!fs13.existsSync(policiesDir))
|
|
30030
29930
|
return [];
|
|
30031
29931
|
let files;
|
|
30032
29932
|
try {
|
|
30033
|
-
files =
|
|
29933
|
+
files = fs13.readdirSync(policiesDir).filter((f) => f.endsWith(".md")).sort();
|
|
30034
29934
|
} catch {
|
|
30035
29935
|
return [];
|
|
30036
29936
|
}
|
|
30037
29937
|
const policies = [];
|
|
30038
29938
|
for (const file of files) {
|
|
30039
|
-
const filePath =
|
|
29939
|
+
const filePath = path17.join(policiesDir, file);
|
|
30040
29940
|
try {
|
|
30041
|
-
const content =
|
|
29941
|
+
const content = fs13.readFileSync(filePath, "utf8");
|
|
30042
29942
|
const parsed = parseFrontmatter(content);
|
|
30043
29943
|
if (!parsed) {
|
|
30044
29944
|
console.warn(`[policies] skipping ${file}: no valid frontmatter block`);
|
|
@@ -30525,15 +30425,6 @@ var WorkspaceNotFoundError = class extends Error {
|
|
|
30525
30425
|
this.name = "WorkspaceNotFoundError";
|
|
30526
30426
|
}
|
|
30527
30427
|
};
|
|
30528
|
-
var RepoSelectionRequiredError = class extends Error {
|
|
30529
|
-
availableRepos;
|
|
30530
|
-
constructor(availableRepos) {
|
|
30531
|
-
const list = availableRepos.length > 0 ? availableRepos.join(", ") : "(none configured)";
|
|
30532
|
-
super(`--repos or --workspace is required. Available repos: ${list}. Pick the subset you actually want \u2014 implicit "all repos" was removed to prevent accidental multi-repo bootstraps.`);
|
|
30533
|
-
this.availableRepos = availableRepos;
|
|
30534
|
-
this.name = "RepoSelectionRequiredError";
|
|
30535
|
-
}
|
|
30536
|
-
};
|
|
30537
30428
|
function buildManifestRuntime(worldId, repos) {
|
|
30538
30429
|
const runtimeRepos = [];
|
|
30539
30430
|
for (const repo of repos) {
|
|
@@ -30586,7 +30477,7 @@ var WorldManager = class {
|
|
|
30586
30477
|
}
|
|
30587
30478
|
}
|
|
30588
30479
|
const worldId = generateWorldId();
|
|
30589
|
-
const workspacePath =
|
|
30480
|
+
const workspacePath = path18.join(os8.homedir(), ".olam", "worlds", worldId);
|
|
30590
30481
|
const portOffset = this.registry.getNextPortOffset();
|
|
30591
30482
|
const branch = opts.branchName ?? `olam/${worldId}`;
|
|
30592
30483
|
const repos = this.resolveReposWithWorkspace(opts);
|
|
@@ -30643,37 +30534,37 @@ var WorldManager = class {
|
|
|
30643
30534
|
if (!repo.path)
|
|
30644
30535
|
continue;
|
|
30645
30536
|
const sourceRoot = repo.path.replace(/^~/, os8.homedir());
|
|
30646
|
-
const worktreeRoot =
|
|
30647
|
-
if (!
|
|
30537
|
+
const worktreeRoot = path18.join(workspacePath, repo.name);
|
|
30538
|
+
if (!fs14.existsSync(sourceRoot) || !fs14.existsSync(worktreeRoot))
|
|
30648
30539
|
continue;
|
|
30649
30540
|
let copied = 0;
|
|
30650
30541
|
for (const pattern of RUNTIME_FILE_PATTERNS) {
|
|
30651
30542
|
const matches2 = [];
|
|
30652
30543
|
if (pattern.includes("*")) {
|
|
30653
|
-
const [dir, glob] = [
|
|
30654
|
-
const sourceDir =
|
|
30655
|
-
if (
|
|
30544
|
+
const [dir, glob] = [path18.dirname(pattern), path18.basename(pattern)];
|
|
30545
|
+
const sourceDir = path18.join(sourceRoot, dir);
|
|
30546
|
+
if (fs14.existsSync(sourceDir)) {
|
|
30656
30547
|
const ext = glob.replace(/^\*+/, "");
|
|
30657
30548
|
try {
|
|
30658
|
-
for (const entry of
|
|
30549
|
+
for (const entry of fs14.readdirSync(sourceDir)) {
|
|
30659
30550
|
if (ext === "" || entry.endsWith(ext))
|
|
30660
|
-
matches2.push(
|
|
30551
|
+
matches2.push(path18.join(dir, entry));
|
|
30661
30552
|
}
|
|
30662
30553
|
} catch {
|
|
30663
30554
|
}
|
|
30664
30555
|
}
|
|
30665
|
-
} else if (
|
|
30556
|
+
} else if (fs14.existsSync(path18.join(sourceRoot, pattern))) {
|
|
30666
30557
|
matches2.push(pattern);
|
|
30667
30558
|
}
|
|
30668
30559
|
for (const rel of matches2) {
|
|
30669
|
-
const src =
|
|
30670
|
-
const dst =
|
|
30560
|
+
const src = path18.join(sourceRoot, rel);
|
|
30561
|
+
const dst = path18.join(worktreeRoot, rel);
|
|
30671
30562
|
try {
|
|
30672
|
-
const st =
|
|
30563
|
+
const st = fs14.statSync(src);
|
|
30673
30564
|
if (!st.isFile())
|
|
30674
30565
|
continue;
|
|
30675
|
-
|
|
30676
|
-
|
|
30566
|
+
fs14.mkdirSync(path18.dirname(dst), { recursive: true });
|
|
30567
|
+
fs14.copyFileSync(src, dst);
|
|
30677
30568
|
copied++;
|
|
30678
30569
|
} catch {
|
|
30679
30570
|
}
|
|
@@ -30773,7 +30664,7 @@ var WorldManager = class {
|
|
|
30773
30664
|
try {
|
|
30774
30665
|
const hostExec = makeHostExecFn();
|
|
30775
30666
|
for (const repo of repos) {
|
|
30776
|
-
const repoDir =
|
|
30667
|
+
const repoDir = path18.join(workspacePath, repo.name);
|
|
30777
30668
|
if (repo.stack && Object.keys(repo.stack).length > 0) {
|
|
30778
30669
|
preDetectedStacks.set(repo.name, { repoName: repo.name, versions: repo.stack });
|
|
30779
30670
|
} else {
|
|
@@ -30830,10 +30721,10 @@ var WorldManager = class {
|
|
|
30830
30721
|
const worldEnv = {};
|
|
30831
30722
|
if (opts.task)
|
|
30832
30723
|
worldEnv.OLAM_TASK = opts.task;
|
|
30833
|
-
const r2CredsPath =
|
|
30834
|
-
if (
|
|
30724
|
+
const r2CredsPath = path18.join(os8.homedir(), ".olam", "r2-credentials.json");
|
|
30725
|
+
if (fs14.existsSync(r2CredsPath)) {
|
|
30835
30726
|
try {
|
|
30836
|
-
const r2Raw =
|
|
30727
|
+
const r2Raw = fs14.readFileSync(r2CredsPath, "utf-8").trim();
|
|
30837
30728
|
if (r2Raw.length > 0) {
|
|
30838
30729
|
const r2 = JSON.parse(r2Raw);
|
|
30839
30730
|
if (typeof r2.account_id === "string")
|
|
@@ -30850,10 +30741,10 @@ var WorldManager = class {
|
|
|
30850
30741
|
} catch {
|
|
30851
30742
|
}
|
|
30852
30743
|
}
|
|
30853
|
-
const keysYamlPath =
|
|
30854
|
-
if (
|
|
30744
|
+
const keysYamlPath = path18.join(os8.homedir(), ".olam", "keys.yaml");
|
|
30745
|
+
if (fs14.existsSync(keysYamlPath)) {
|
|
30855
30746
|
try {
|
|
30856
|
-
const keysRaw =
|
|
30747
|
+
const keysRaw = fs14.readFileSync(keysYamlPath, "utf-8").trim();
|
|
30857
30748
|
if (keysRaw.length > 0) {
|
|
30858
30749
|
const parsed = YAML3.parse(keysRaw);
|
|
30859
30750
|
if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed)) {
|
|
@@ -30900,10 +30791,10 @@ var WorldManager = class {
|
|
|
30900
30791
|
worldEnv[k] = v;
|
|
30901
30792
|
}
|
|
30902
30793
|
for (const { repoName, relativePath, content } of fileWrites) {
|
|
30903
|
-
const absPath =
|
|
30794
|
+
const absPath = path18.join(workspacePath, repoName, relativePath);
|
|
30904
30795
|
try {
|
|
30905
|
-
|
|
30906
|
-
|
|
30796
|
+
fs14.mkdirSync(path18.dirname(absPath), { recursive: true });
|
|
30797
|
+
fs14.writeFileSync(absPath, content.endsWith("\n") ? content : content + "\n", {
|
|
30907
30798
|
mode: 384
|
|
30908
30799
|
});
|
|
30909
30800
|
console.log(`[secrets] ${repoName}: materialised ${relativePath} (${content.length} chars, mode 0600)`);
|
|
@@ -31055,7 +30946,7 @@ var WorldManager = class {
|
|
|
31055
30946
|
let taskWithPolicies = opts.task;
|
|
31056
30947
|
try {
|
|
31057
30948
|
const allPolicies = repos.flatMap((repo) => {
|
|
31058
|
-
const repoWorktree =
|
|
30949
|
+
const repoWorktree = path18.join(workspacePath, repo.name);
|
|
31059
30950
|
return loadPolicies(repoWorktree);
|
|
31060
30951
|
});
|
|
31061
30952
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -31071,8 +30962,8 @@ var WorldManager = class {
|
|
|
31071
30962
|
${opts.task}`;
|
|
31072
30963
|
execSync4(`docker exec ${containerName} mkdir -p /home/olam/.olam/policies`, { stdio: "pipe", timeout: 1e4 });
|
|
31073
30964
|
for (const repo of repos) {
|
|
31074
|
-
const policiesDir =
|
|
31075
|
-
if (
|
|
30965
|
+
const policiesDir = path18.join(workspacePath, repo.name, ".olam", "policies");
|
|
30966
|
+
if (fs14.existsSync(policiesDir)) {
|
|
31076
30967
|
execSync4(`docker cp "${policiesDir}/." "${containerName}:/home/olam/.olam/policies/"`, { stdio: "pipe", timeout: 15e3 });
|
|
31077
30968
|
}
|
|
31078
30969
|
}
|
|
@@ -31151,8 +31042,8 @@ ${opts.task}`;
|
|
|
31151
31042
|
} catch {
|
|
31152
31043
|
}
|
|
31153
31044
|
try {
|
|
31154
|
-
|
|
31155
|
-
if (
|
|
31045
|
+
fs14.rmSync(world.workspacePath, { recursive: true, force: true });
|
|
31046
|
+
if (fs14.existsSync(world.workspacePath)) {
|
|
31156
31047
|
console.warn(`[WorldManager] destroyWorld(${worldId}): workspace dir ${world.workspacePath} still exists after rmSync. Run \`olam clean --apply\` to reap.`);
|
|
31157
31048
|
}
|
|
31158
31049
|
} catch (err) {
|
|
@@ -31207,10 +31098,7 @@ ${opts.task}`;
|
|
|
31207
31098
|
* Resolution precedence (matches the CF worker exactly):
|
|
31208
31099
|
* 1. inline `opts.repos` names → look up in `config.repos`
|
|
31209
31100
|
* 2. named `opts.workspace` → load catalog YAML, map via workspaceToRepoConfigs
|
|
31210
|
-
* 3.
|
|
31211
|
-
* "include every repo in config.yaml" fallback silently fanned a
|
|
31212
|
-
* single-repo audit into 7-repo bootstraps and steered
|
|
31213
|
-
* `image_selectors` to a wider tag than intended.
|
|
31101
|
+
* 3. fallback → every repo declared in the project's config.yaml
|
|
31214
31102
|
*/
|
|
31215
31103
|
resolveReposWithWorkspace(opts) {
|
|
31216
31104
|
if (opts.repos && opts.repos.length > 0) {
|
|
@@ -31222,7 +31110,7 @@ ${opts.task}`;
|
|
|
31222
31110
|
throw new WorkspaceNotFoundError(opts.workspace);
|
|
31223
31111
|
return workspaceToRepoConfigs(ws);
|
|
31224
31112
|
}
|
|
31225
|
-
|
|
31113
|
+
return this.resolveRepos(void 0);
|
|
31226
31114
|
}
|
|
31227
31115
|
resolveRepos(repoNames) {
|
|
31228
31116
|
if (!repoNames || repoNames.length === 0) {
|
|
@@ -31240,14 +31128,14 @@ ${opts.task}`;
|
|
|
31240
31128
|
return names.map((name) => this.config.repos.find((r) => r.name === name)).filter((r) => r !== void 0);
|
|
31241
31129
|
}
|
|
31242
31130
|
transportPlanFile(planFilePath, workspacePath, repoNames) {
|
|
31243
|
-
const planContent =
|
|
31244
|
-
const planFileName =
|
|
31131
|
+
const planContent = fs14.readFileSync(planFilePath, "utf-8");
|
|
31132
|
+
const planFileName = path18.basename(planFilePath);
|
|
31245
31133
|
const targetRepo = repoNames[0];
|
|
31246
31134
|
if (!targetRepo)
|
|
31247
31135
|
return;
|
|
31248
|
-
const plansDir =
|
|
31249
|
-
|
|
31250
|
-
|
|
31136
|
+
const plansDir = path18.join(workspacePath, targetRepo, "docs", "plans");
|
|
31137
|
+
fs14.mkdirSync(plansDir, { recursive: true });
|
|
31138
|
+
fs14.writeFileSync(path18.join(plansDir, planFileName), planContent);
|
|
31251
31139
|
}
|
|
31252
31140
|
resolveServices(repos) {
|
|
31253
31141
|
const services = [];
|
|
@@ -31332,8 +31220,8 @@ import * as http2 from "node:http";
|
|
|
31332
31220
|
|
|
31333
31221
|
// ../core/dist/dashboard/server.js
|
|
31334
31222
|
import * as http from "node:http";
|
|
31335
|
-
import * as
|
|
31336
|
-
import * as
|
|
31223
|
+
import * as fs15 from "node:fs";
|
|
31224
|
+
import * as path19 from "node:path";
|
|
31337
31225
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
31338
31226
|
|
|
31339
31227
|
// ../core/dist/dashboard/serialize.js
|
|
@@ -31668,7 +31556,7 @@ function notFound(res) {
|
|
|
31668
31556
|
}
|
|
31669
31557
|
function openThoughtStore(workspacePath) {
|
|
31670
31558
|
const dbPath = getWorldDbPath(workspacePath);
|
|
31671
|
-
if (!
|
|
31559
|
+
if (!fs15.existsSync(dbPath))
|
|
31672
31560
|
return null;
|
|
31673
31561
|
return new ThoughtLocalStore(dbPath);
|
|
31674
31562
|
}
|
|
@@ -31839,13 +31727,13 @@ function findSessionInWorld(registry2, sessionId) {
|
|
|
31839
31727
|
}
|
|
31840
31728
|
function createDashboardServer(opts) {
|
|
31841
31729
|
const { port, registry: registry2 } = opts;
|
|
31842
|
-
const thisDir =
|
|
31843
|
-
const defaultPublicDir =
|
|
31730
|
+
const thisDir = path19.dirname(fileURLToPath2(import.meta.url));
|
|
31731
|
+
const defaultPublicDir = path19.resolve(thisDir, "../../../control-plane/public");
|
|
31844
31732
|
const publicDir = opts.publicDir ?? defaultPublicDir;
|
|
31845
|
-
let hasPublicDir =
|
|
31733
|
+
let hasPublicDir = fs15.existsSync(publicDir);
|
|
31846
31734
|
const server = http.createServer((req, res) => {
|
|
31847
31735
|
if (!hasPublicDir) {
|
|
31848
|
-
hasPublicDir =
|
|
31736
|
+
hasPublicDir = fs15.existsSync(publicDir);
|
|
31849
31737
|
}
|
|
31850
31738
|
const host = req.headers.host ?? `localhost:${port}`;
|
|
31851
31739
|
const url = new URL(req.url ?? "/", `http://${host}`);
|
|
@@ -32119,22 +32007,22 @@ function createDashboardServer(opts) {
|
|
|
32119
32007
|
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>`);
|
|
32120
32008
|
return;
|
|
32121
32009
|
}
|
|
32122
|
-
let filePath =
|
|
32010
|
+
let filePath = path19.join(publicDir, pathname === "/" ? "index.html" : pathname);
|
|
32123
32011
|
if (!filePath.startsWith(publicDir)) {
|
|
32124
32012
|
notFound(res);
|
|
32125
32013
|
return;
|
|
32126
32014
|
}
|
|
32127
|
-
if (
|
|
32128
|
-
const ext =
|
|
32015
|
+
if (fs15.existsSync(filePath) && fs15.statSync(filePath).isFile()) {
|
|
32016
|
+
const ext = path19.extname(filePath);
|
|
32129
32017
|
const contentType = MIME[ext] ?? "application/octet-stream";
|
|
32130
32018
|
res.writeHead(200, { "Content-Type": contentType });
|
|
32131
|
-
|
|
32019
|
+
fs15.createReadStream(filePath).pipe(res);
|
|
32132
32020
|
return;
|
|
32133
32021
|
}
|
|
32134
|
-
filePath =
|
|
32135
|
-
if (
|
|
32022
|
+
filePath = path19.join(publicDir, "index.html");
|
|
32023
|
+
if (fs15.existsSync(filePath)) {
|
|
32136
32024
|
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
|
|
32137
|
-
|
|
32025
|
+
fs15.createReadStream(filePath).pipe(res);
|
|
32138
32026
|
return;
|
|
32139
32027
|
}
|
|
32140
32028
|
notFound(res);
|
|
@@ -32144,17 +32032,17 @@ function createDashboardServer(opts) {
|
|
|
32144
32032
|
}
|
|
32145
32033
|
|
|
32146
32034
|
// ../core/dist/dashboard/state.js
|
|
32147
|
-
import * as
|
|
32035
|
+
import * as fs16 from "node:fs";
|
|
32148
32036
|
import * as os9 from "node:os";
|
|
32149
|
-
import * as
|
|
32150
|
-
var STATE_PATH =
|
|
32037
|
+
import * as path20 from "node:path";
|
|
32038
|
+
var STATE_PATH = path20.join(os9.homedir(), ".olam", "dashboard.json");
|
|
32151
32039
|
function saveDashboardState(state) {
|
|
32152
|
-
|
|
32153
|
-
|
|
32040
|
+
fs16.mkdirSync(path20.dirname(STATE_PATH), { recursive: true });
|
|
32041
|
+
fs16.writeFileSync(STATE_PATH, JSON.stringify(state, null, 2));
|
|
32154
32042
|
}
|
|
32155
32043
|
function loadDashboardState() {
|
|
32156
32044
|
try {
|
|
32157
|
-
const raw =
|
|
32045
|
+
const raw = fs16.readFileSync(STATE_PATH, "utf-8");
|
|
32158
32046
|
return JSON.parse(raw);
|
|
32159
32047
|
} catch {
|
|
32160
32048
|
return null;
|
|
@@ -32162,7 +32050,7 @@ function loadDashboardState() {
|
|
|
32162
32050
|
}
|
|
32163
32051
|
function clearDashboardState() {
|
|
32164
32052
|
try {
|
|
32165
|
-
|
|
32053
|
+
fs16.unlinkSync(STATE_PATH);
|
|
32166
32054
|
} catch {
|
|
32167
32055
|
}
|
|
32168
32056
|
}
|
|
@@ -32442,8 +32330,8 @@ var PleriClient = class {
|
|
|
32442
32330
|
};
|
|
32443
32331
|
|
|
32444
32332
|
// ../mcp-server/src/env-loader.ts
|
|
32445
|
-
import { readFileSync as
|
|
32446
|
-
import { join as join23, dirname as
|
|
32333
|
+
import { readFileSync as readFileSync14, existsSync as existsSync17, statSync as statSync6 } from "node:fs";
|
|
32334
|
+
import { join as join23, dirname as dirname12, resolve as resolve5 } from "node:path";
|
|
32447
32335
|
var PROJECT_MARKERS = [
|
|
32448
32336
|
".olam/config.yaml",
|
|
32449
32337
|
".olam/config.yml",
|
|
@@ -32455,26 +32343,26 @@ function findProjectRoot2(startDir) {
|
|
|
32455
32343
|
const root = resolve5("/");
|
|
32456
32344
|
while (true) {
|
|
32457
32345
|
for (const marker of PROJECT_MARKERS) {
|
|
32458
|
-
if (
|
|
32346
|
+
if (existsSync17(join23(dir, marker))) return dir;
|
|
32459
32347
|
}
|
|
32460
32348
|
const pkg = join23(dir, "package.json");
|
|
32461
|
-
if (
|
|
32349
|
+
if (existsSync17(pkg)) {
|
|
32462
32350
|
try {
|
|
32463
|
-
const json = JSON.parse(
|
|
32351
|
+
const json = JSON.parse(readFileSync14(pkg, "utf8"));
|
|
32464
32352
|
const isOlamWorkspace = typeof json.name === "string" && json.name.startsWith("@olam/");
|
|
32465
32353
|
const hasOlamDep = json.dependencies && Object.keys(json.dependencies).some((k) => k.startsWith("@olam/")) || json.devDependencies && Object.keys(json.devDependencies).some((k) => k.startsWith("@olam/"));
|
|
32466
32354
|
if (isOlamWorkspace || hasOlamDep) return dir;
|
|
32467
32355
|
} catch {
|
|
32468
32356
|
}
|
|
32469
32357
|
}
|
|
32470
|
-
const parent =
|
|
32358
|
+
const parent = dirname12(dir);
|
|
32471
32359
|
if (parent === dir || parent === root) return null;
|
|
32472
32360
|
dir = parent;
|
|
32473
32361
|
}
|
|
32474
32362
|
}
|
|
32475
|
-
function parseEnvFile(
|
|
32363
|
+
function parseEnvFile(path21) {
|
|
32476
32364
|
const out = {};
|
|
32477
|
-
const raw =
|
|
32365
|
+
const raw = readFileSync14(path21, "utf8");
|
|
32478
32366
|
for (const line of raw.split(/\r?\n/)) {
|
|
32479
32367
|
const trimmed = line.trim();
|
|
32480
32368
|
if (!trimmed || trimmed.startsWith("#")) continue;
|
|
@@ -32498,7 +32386,7 @@ function loadProjectEnv(startDir = process.cwd()) {
|
|
|
32498
32386
|
const merged = {};
|
|
32499
32387
|
for (const name of [".env", ".env.local"]) {
|
|
32500
32388
|
const p = join23(root, name);
|
|
32501
|
-
if (
|
|
32389
|
+
if (existsSync17(p) && statSync6(p).isFile()) {
|
|
32502
32390
|
Object.assign(merged, parseEnvFile(p));
|
|
32503
32391
|
filesRead.push(p);
|
|
32504
32392
|
}
|