@aerovato/operator-helper 1.3.1 → 1.3.2
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/index.js +67 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -17998,7 +17998,7 @@ var Uint8Array2 = /* @__PURE__ */ instanceOf(globalThis.Uint8Array, {
|
|
|
17998
17998
|
// package.json
|
|
17999
17999
|
var package_default = {
|
|
18000
18000
|
name: "@aerovato/operator-helper",
|
|
18001
|
-
version: "1.3.
|
|
18001
|
+
version: "1.3.2",
|
|
18002
18002
|
description: "Installation and setup CLI for Operator Memory",
|
|
18003
18003
|
license: "BSD-3-Clause",
|
|
18004
18004
|
author: "Aerovato Research",
|
|
@@ -19203,6 +19203,9 @@ var installCodex = fn2("installCodex")(function* (context) {
|
|
|
19203
19203
|
if (!marketplace.ok)
|
|
19204
19204
|
return marketplace.result;
|
|
19205
19205
|
const addMarketplace = yield* runProcess("codex", ["plugin", "marketplace", "add", marketplace.path, "--json"], context.cwd, { NPM_CONFIG_MIN_RELEASE_AGE: "0" });
|
|
19206
|
+
if (!addMarketplace.ok && isMissingBinary(addMarketplace.error)) {
|
|
19207
|
+
return yield* registerDesktopMarketplace(context, marketplace.path);
|
|
19208
|
+
}
|
|
19206
19209
|
const addFailure = commandFailure(addMarketplace, "Codex marketplace installation failed");
|
|
19207
19210
|
if (addFailure !== null)
|
|
19208
19211
|
return addFailure;
|
|
@@ -19262,6 +19265,68 @@ function writeMarketplace(home) {
|
|
|
19262
19265
|
}
|
|
19263
19266
|
});
|
|
19264
19267
|
}
|
|
19268
|
+
function isMissingBinary(error) {
|
|
19269
|
+
return error.startsWith("NotFound:");
|
|
19270
|
+
}
|
|
19271
|
+
function registerDesktopMarketplace(context, marketplacePath) {
|
|
19272
|
+
return promise2(async () => {
|
|
19273
|
+
const codexHome = process.env.CODEX_HOME || join3(context.home, ".codex");
|
|
19274
|
+
const config = join3(codexHome, "config.toml");
|
|
19275
|
+
try {
|
|
19276
|
+
const content = await readOptionalFile(config);
|
|
19277
|
+
await mkdir3(codexHome, { recursive: true });
|
|
19278
|
+
await writeFile4(config, upsertMarketplaceTable(content, marketplacePath));
|
|
19279
|
+
} catch (error) {
|
|
19280
|
+
return {
|
|
19281
|
+
exitCode: 1,
|
|
19282
|
+
output: `✗ Could not register the Codex marketplace: ${getErrorMessage(error)}`
|
|
19283
|
+
};
|
|
19284
|
+
}
|
|
19285
|
+
return {
|
|
19286
|
+
exitCode: 0,
|
|
19287
|
+
output: [
|
|
19288
|
+
"✓ Registered the Operator Codex marketplace",
|
|
19289
|
+
"Codex CLI unavailable: install aerovato@operator-memory from the Codex plugins browser, then start a new session and approve the Operator hooks."
|
|
19290
|
+
].join(`
|
|
19291
|
+
`)
|
|
19292
|
+
};
|
|
19293
|
+
});
|
|
19294
|
+
}
|
|
19295
|
+
function upsertMarketplaceTable(content, source) {
|
|
19296
|
+
const header = `[marketplaces.${MARKETPLACE_NAME}]`;
|
|
19297
|
+
const block = `${header}
|
|
19298
|
+
source_type = "local"
|
|
19299
|
+
source = ${JSON.stringify(source)}
|
|
19300
|
+
`;
|
|
19301
|
+
if (content === null)
|
|
19302
|
+
return block;
|
|
19303
|
+
const lines = content.split(`
|
|
19304
|
+
`);
|
|
19305
|
+
for (const line of lines) {
|
|
19306
|
+
const trimmed = line.trim();
|
|
19307
|
+
if (/^marketplaces\s*=/.test(trimmed) || /^marketplaces\./.test(trimmed)) {
|
|
19308
|
+
throw new Error("config.toml expresses marketplaces without tables; refusing to edit it");
|
|
19309
|
+
}
|
|
19310
|
+
}
|
|
19311
|
+
const headerPattern = new RegExp(`^\\[\\s*marketplaces\\.${MARKETPLACE_NAME}\\s*\\]$`);
|
|
19312
|
+
const headerIndex = lines.findIndex((line) => headerPattern.test(line.trim()));
|
|
19313
|
+
if (headerIndex === -1) {
|
|
19314
|
+
return content.endsWith(`
|
|
19315
|
+
`) || content.length === 0 ? `${content}${block}` : `${content}
|
|
19316
|
+
${block}`;
|
|
19317
|
+
}
|
|
19318
|
+
let end = lines.length;
|
|
19319
|
+
for (let index = headerIndex + 1;index < lines.length; index += 1) {
|
|
19320
|
+
const line = lines[index];
|
|
19321
|
+
if (line !== undefined && /^\s*\[\[?/.test(line)) {
|
|
19322
|
+
end = index;
|
|
19323
|
+
break;
|
|
19324
|
+
}
|
|
19325
|
+
}
|
|
19326
|
+
return [...lines.slice(0, headerIndex), ...block.split(`
|
|
19327
|
+
`), ...lines.slice(end)].join(`
|
|
19328
|
+
`);
|
|
19329
|
+
}
|
|
19265
19330
|
function isInstalledAndEnabled(output) {
|
|
19266
19331
|
try {
|
|
19267
19332
|
const value = JSON.parse(output);
|
|
@@ -20662,4 +20727,4 @@ var main = gen2(function* () {
|
|
|
20662
20727
|
}).pipe(provide4(LiveLayers));
|
|
20663
20728
|
runMain2(main);
|
|
20664
20729
|
|
|
20665
|
-
//# debugId=
|
|
20730
|
+
//# debugId=5C64FD78B739360C64756E2164756E21
|