@nuucognition/flint-cli 0.6.0-dev.12 → 0.6.0-dev.13
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/bin/flint.js +10 -0
- package/dist/_flint/prompts/flint-interactive.md +7 -5
- package/dist/_orbh/prompts/headless.md +9 -7
- package/dist/index.js +326 -170
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -457,7 +457,7 @@ async function startLoginFlow(config) {
|
|
|
457
457
|
const codeChallenge = createHash("sha256").update(codeVerifier).digest("base64url");
|
|
458
458
|
const cliLabel = config.cliname ?? "nuu";
|
|
459
459
|
step(`Logging in to ${import_picocolors.default.bold(config.accountUrl)}`);
|
|
460
|
-
return new Promise((
|
|
460
|
+
return new Promise((resolve24, reject) => {
|
|
461
461
|
let settled = false;
|
|
462
462
|
const finish = (fn) => {
|
|
463
463
|
if (settled) return;
|
|
@@ -504,7 +504,7 @@ async function startLoginFlow(config) {
|
|
|
504
504
|
};
|
|
505
505
|
res.writeHead(200, { "Content-Type": "text/html" });
|
|
506
506
|
res.end(resultHtml(true, "Login successful", "You can close this tab and return to the terminal."));
|
|
507
|
-
void saveAuth(credentials, authEnv).then(() => finish(() =>
|
|
507
|
+
void saveAuth(credentials, authEnv).then(() => finish(() => resolve24(credentials))).catch((cause) => {
|
|
508
508
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
509
509
|
finish(() => {
|
|
510
510
|
stepFail(`Failed to save credentials: ${message}`);
|
|
@@ -542,7 +542,7 @@ async function startLoginFlow(config) {
|
|
|
542
542
|
step("Exchanging authorization code for session token...");
|
|
543
543
|
void exchangeCode(config.accountUrl, code, codeVerifier).then(async (credentials) => {
|
|
544
544
|
await saveAuth(credentials, authEnv);
|
|
545
|
-
finish(() =>
|
|
545
|
+
finish(() => resolve24(credentials));
|
|
546
546
|
}).catch((cause) => {
|
|
547
547
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
548
548
|
finish(() => {
|
|
@@ -67412,14 +67412,14 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
67412
67412
|
};
|
|
67413
67413
|
}
|
|
67414
67414
|
function readAndResolve(iter) {
|
|
67415
|
-
var
|
|
67416
|
-
if (
|
|
67415
|
+
var resolve24 = iter[kLastResolve];
|
|
67416
|
+
if (resolve24 !== null) {
|
|
67417
67417
|
var data = iter[kStream].read();
|
|
67418
67418
|
if (data !== null) {
|
|
67419
67419
|
iter[kLastPromise] = null;
|
|
67420
67420
|
iter[kLastResolve] = null;
|
|
67421
67421
|
iter[kLastReject] = null;
|
|
67422
|
-
|
|
67422
|
+
resolve24(createIterResult(data, false));
|
|
67423
67423
|
}
|
|
67424
67424
|
}
|
|
67425
67425
|
}
|
|
@@ -67427,13 +67427,13 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
67427
67427
|
process.nextTick(readAndResolve, iter);
|
|
67428
67428
|
}
|
|
67429
67429
|
function wrapForNext(lastPromise, iter) {
|
|
67430
|
-
return function(
|
|
67430
|
+
return function(resolve24, reject) {
|
|
67431
67431
|
lastPromise.then(function() {
|
|
67432
67432
|
if (iter[kEnded]) {
|
|
67433
|
-
|
|
67433
|
+
resolve24(createIterResult(void 0, true));
|
|
67434
67434
|
return;
|
|
67435
67435
|
}
|
|
67436
|
-
iter[kHandlePromise](
|
|
67436
|
+
iter[kHandlePromise](resolve24, reject);
|
|
67437
67437
|
}, reject);
|
|
67438
67438
|
};
|
|
67439
67439
|
}
|
|
@@ -67453,12 +67453,12 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
67453
67453
|
return Promise.resolve(createIterResult(void 0, true));
|
|
67454
67454
|
}
|
|
67455
67455
|
if (this[kStream].destroyed) {
|
|
67456
|
-
return new Promise(function(
|
|
67456
|
+
return new Promise(function(resolve24, reject) {
|
|
67457
67457
|
process.nextTick(function() {
|
|
67458
67458
|
if (_this[kError]) {
|
|
67459
67459
|
reject(_this[kError]);
|
|
67460
67460
|
} else {
|
|
67461
|
-
|
|
67461
|
+
resolve24(createIterResult(void 0, true));
|
|
67462
67462
|
}
|
|
67463
67463
|
});
|
|
67464
67464
|
});
|
|
@@ -67481,13 +67481,13 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
67481
67481
|
return this;
|
|
67482
67482
|
}), _defineProperty(_Object$setPrototypeO, "return", function _return() {
|
|
67483
67483
|
var _this2 = this;
|
|
67484
|
-
return new Promise(function(
|
|
67484
|
+
return new Promise(function(resolve24, reject) {
|
|
67485
67485
|
_this2[kStream].destroy(null, function(err) {
|
|
67486
67486
|
if (err) {
|
|
67487
67487
|
reject(err);
|
|
67488
67488
|
return;
|
|
67489
67489
|
}
|
|
67490
|
-
|
|
67490
|
+
resolve24(createIterResult(void 0, true));
|
|
67491
67491
|
});
|
|
67492
67492
|
});
|
|
67493
67493
|
}), _Object$setPrototypeO), AsyncIteratorPrototype);
|
|
@@ -67509,15 +67509,15 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
67509
67509
|
value: stream._readableState.endEmitted,
|
|
67510
67510
|
writable: true
|
|
67511
67511
|
}), _defineProperty(_Object$create, kHandlePromise, {
|
|
67512
|
-
value: function value(
|
|
67512
|
+
value: function value(resolve24, reject) {
|
|
67513
67513
|
var data = iterator[kStream].read();
|
|
67514
67514
|
if (data) {
|
|
67515
67515
|
iterator[kLastPromise] = null;
|
|
67516
67516
|
iterator[kLastResolve] = null;
|
|
67517
67517
|
iterator[kLastReject] = null;
|
|
67518
|
-
|
|
67518
|
+
resolve24(createIterResult(data, false));
|
|
67519
67519
|
} else {
|
|
67520
|
-
iterator[kLastResolve] =
|
|
67520
|
+
iterator[kLastResolve] = resolve24;
|
|
67521
67521
|
iterator[kLastReject] = reject;
|
|
67522
67522
|
}
|
|
67523
67523
|
},
|
|
@@ -67536,12 +67536,12 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
67536
67536
|
iterator[kError] = err;
|
|
67537
67537
|
return;
|
|
67538
67538
|
}
|
|
67539
|
-
var
|
|
67540
|
-
if (
|
|
67539
|
+
var resolve24 = iterator[kLastResolve];
|
|
67540
|
+
if (resolve24 !== null) {
|
|
67541
67541
|
iterator[kLastPromise] = null;
|
|
67542
67542
|
iterator[kLastResolve] = null;
|
|
67543
67543
|
iterator[kLastReject] = null;
|
|
67544
|
-
|
|
67544
|
+
resolve24(createIterResult(void 0, true));
|
|
67545
67545
|
}
|
|
67546
67546
|
iterator[kEnded] = true;
|
|
67547
67547
|
});
|
|
@@ -67554,7 +67554,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
67554
67554
|
require_from = __commonJS2({
|
|
67555
67555
|
"../../node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/internal/streams/from.js"(exports, module) {
|
|
67556
67556
|
"use strict";
|
|
67557
|
-
function asyncGeneratorStep(gen,
|
|
67557
|
+
function asyncGeneratorStep(gen, resolve24, reject, _next, _throw, key, arg) {
|
|
67558
67558
|
try {
|
|
67559
67559
|
var info2 = gen[key](arg);
|
|
67560
67560
|
var value = info2.value;
|
|
@@ -67563,7 +67563,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
67563
67563
|
return;
|
|
67564
67564
|
}
|
|
67565
67565
|
if (info2.done) {
|
|
67566
|
-
|
|
67566
|
+
resolve24(value);
|
|
67567
67567
|
} else {
|
|
67568
67568
|
Promise.resolve(value).then(_next, _throw);
|
|
67569
67569
|
}
|
|
@@ -67571,13 +67571,13 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
67571
67571
|
function _asyncToGenerator(fn) {
|
|
67572
67572
|
return function() {
|
|
67573
67573
|
var self2 = this, args = arguments;
|
|
67574
|
-
return new Promise(function(
|
|
67574
|
+
return new Promise(function(resolve24, reject) {
|
|
67575
67575
|
var gen = fn.apply(self2, args);
|
|
67576
67576
|
function _next(value) {
|
|
67577
|
-
asyncGeneratorStep(gen,
|
|
67577
|
+
asyncGeneratorStep(gen, resolve24, reject, _next, _throw, "next", value);
|
|
67578
67578
|
}
|
|
67579
67579
|
function _throw(err) {
|
|
67580
|
-
asyncGeneratorStep(gen,
|
|
67580
|
+
asyncGeneratorStep(gen, resolve24, reject, _next, _throw, "throw", err);
|
|
67581
67581
|
}
|
|
67582
67582
|
_next(void 0);
|
|
67583
67583
|
});
|
|
@@ -69553,14 +69553,14 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
69553
69553
|
}
|
|
69554
69554
|
const subprocess = childProcess.spawn(command, cliArguments, childProcessOptions);
|
|
69555
69555
|
if (options22.wait) {
|
|
69556
|
-
return new Promise((
|
|
69556
|
+
return new Promise((resolve24, reject) => {
|
|
69557
69557
|
subprocess.once("error", reject);
|
|
69558
69558
|
subprocess.once("close", (exitCode) => {
|
|
69559
69559
|
if (!options22.allowNonzeroExitCode && exitCode > 0) {
|
|
69560
69560
|
reject(new Error(`Exited with code ${exitCode}`));
|
|
69561
69561
|
return;
|
|
69562
69562
|
}
|
|
69563
|
-
|
|
69563
|
+
resolve24(subprocess);
|
|
69564
69564
|
});
|
|
69565
69565
|
});
|
|
69566
69566
|
}
|
|
@@ -79066,7 +79066,7 @@ function createMigrationContext(flintPath, options3 = {}) {
|
|
|
79066
79066
|
});
|
|
79067
79067
|
const error3 = options3.error || (() => {
|
|
79068
79068
|
});
|
|
79069
|
-
const
|
|
79069
|
+
const resolve24 = (p) => join12(flintPath, p);
|
|
79070
79070
|
return {
|
|
79071
79071
|
flintPath,
|
|
79072
79072
|
log,
|
|
@@ -79074,34 +79074,34 @@ function createMigrationContext(flintPath, options3 = {}) {
|
|
|
79074
79074
|
error: error3,
|
|
79075
79075
|
async exists(path31) {
|
|
79076
79076
|
try {
|
|
79077
|
-
await access2(
|
|
79077
|
+
await access2(resolve24(path31));
|
|
79078
79078
|
return true;
|
|
79079
79079
|
} catch {
|
|
79080
79080
|
return false;
|
|
79081
79081
|
}
|
|
79082
79082
|
},
|
|
79083
79083
|
async read(path31) {
|
|
79084
|
-
return readFile6(
|
|
79084
|
+
return readFile6(resolve24(path31), "utf-8");
|
|
79085
79085
|
},
|
|
79086
79086
|
async write(path31, content) {
|
|
79087
|
-
const fullPath =
|
|
79087
|
+
const fullPath = resolve24(path31);
|
|
79088
79088
|
await mkdir6(dirname22(fullPath), { recursive: true });
|
|
79089
79089
|
await writeFile5(fullPath, content, "utf-8");
|
|
79090
79090
|
},
|
|
79091
79091
|
async delete(path31) {
|
|
79092
|
-
await unlink2(
|
|
79092
|
+
await unlink2(resolve24(path31));
|
|
79093
79093
|
},
|
|
79094
79094
|
// ── Intent (flint.toml) ──────────────────────────────────────────────
|
|
79095
79095
|
async readIntentText() {
|
|
79096
79096
|
try {
|
|
79097
|
-
return await readFile6(
|
|
79097
|
+
return await readFile6(resolve24("flint.toml"), "utf-8");
|
|
79098
79098
|
} catch (err) {
|
|
79099
79099
|
if (err.code === "ENOENT") return null;
|
|
79100
79100
|
throw err;
|
|
79101
79101
|
}
|
|
79102
79102
|
},
|
|
79103
79103
|
async writeIntentText(text) {
|
|
79104
|
-
await writeFile5(
|
|
79104
|
+
await writeFile5(resolve24("flint.toml"), text, "utf-8");
|
|
79105
79105
|
},
|
|
79106
79106
|
async readIntent() {
|
|
79107
79107
|
const text = await this.readIntentText();
|
|
@@ -79110,7 +79110,7 @@ function createMigrationContext(flintPath, options3 = {}) {
|
|
|
79110
79110
|
// ── Lockfile (flint.json) ────────────────────────────────────────────
|
|
79111
79111
|
async readLockfile() {
|
|
79112
79112
|
try {
|
|
79113
|
-
const text = await readFile6(
|
|
79113
|
+
const text = await readFile6(resolve24("flint.json"), "utf-8");
|
|
79114
79114
|
return JSON.parse(text);
|
|
79115
79115
|
} catch (err) {
|
|
79116
79116
|
if (err.code === "ENOENT") return null;
|
|
@@ -79118,23 +79118,23 @@ function createMigrationContext(flintPath, options3 = {}) {
|
|
|
79118
79118
|
}
|
|
79119
79119
|
},
|
|
79120
79120
|
async writeLockfile(next) {
|
|
79121
|
-
await writeFile5(
|
|
79121
|
+
await writeFile5(resolve24("flint.json"), JSON.stringify(next, null, 2) + "\n", "utf-8");
|
|
79122
79122
|
},
|
|
79123
79123
|
// ── Filesystem ───────────────────────────────────────────────────────
|
|
79124
79124
|
fs: {
|
|
79125
79125
|
async mv(from, to) {
|
|
79126
|
-
const dest =
|
|
79126
|
+
const dest = resolve24(to);
|
|
79127
79127
|
await mkdir6(dirname22(dest), { recursive: true });
|
|
79128
|
-
await rename6(
|
|
79128
|
+
await rename6(resolve24(from), dest);
|
|
79129
79129
|
},
|
|
79130
79130
|
async rm(path31, options22) {
|
|
79131
|
-
await fsRm(
|
|
79131
|
+
await fsRm(resolve24(path31), { recursive: options22?.recursive ?? false, force: true });
|
|
79132
79132
|
},
|
|
79133
79133
|
async mkdir(path31, options22) {
|
|
79134
|
-
await mkdir6(
|
|
79134
|
+
await mkdir6(resolve24(path31), { recursive: options22?.recursive ?? true });
|
|
79135
79135
|
},
|
|
79136
79136
|
async readDir(path31) {
|
|
79137
|
-
return readdir9(
|
|
79137
|
+
return readdir9(resolve24(path31));
|
|
79138
79138
|
}
|
|
79139
79139
|
}
|
|
79140
79140
|
};
|
|
@@ -86839,6 +86839,7 @@ import { existsSync as existsSync22 } from "fs";
|
|
|
86839
86839
|
import { join as join142, resolve as resolve6 } from "path";
|
|
86840
86840
|
import { homedir as homedir4 } from "os";
|
|
86841
86841
|
import { request } from "http";
|
|
86842
|
+
import { existsSync as existsSync32 } from "fs";
|
|
86842
86843
|
import { readdir as readdir82, readFile as readFile92, mkdir as mkdir12 } from "fs/promises";
|
|
86843
86844
|
import { join as join152, dirname as dirname52, resolve as resolve7, sep as sep22 } from "path";
|
|
86844
86845
|
import { randomUUID as randomUUID22 } from "crypto";
|
|
@@ -90174,6 +90175,7 @@ async function healTinderbox(root) {
|
|
|
90174
90175
|
const check2 = await checkTinderbox(root);
|
|
90175
90176
|
const addedDeclarations = [];
|
|
90176
90177
|
const renamedDeclarations = [];
|
|
90178
|
+
const warnings = [];
|
|
90177
90179
|
let configChanged = false;
|
|
90178
90180
|
for (const renameEntry of check2.reconciliation.renamed) {
|
|
90179
90181
|
const target = config.flints.required.find((flint) => flint.name === renameEntry.declaration.name);
|
|
@@ -90185,6 +90187,22 @@ async function healTinderbox(root) {
|
|
|
90185
90187
|
});
|
|
90186
90188
|
configChanged = true;
|
|
90187
90189
|
}
|
|
90190
|
+
for (const undeclared of check2.reconciliation.undeclared) {
|
|
90191
|
+
if (config.flints.required.some((entry) => entry.name === undeclared.name)) {
|
|
90192
|
+
continue;
|
|
90193
|
+
}
|
|
90194
|
+
const remote = await readGitRemoteUrl(undeclared.path);
|
|
90195
|
+
if (!remote) {
|
|
90196
|
+
warnings.push({
|
|
90197
|
+
scope: `flint:${undeclared.name}`,
|
|
90198
|
+
message: `Cannot declare "${undeclared.name}" \u2014 no git remote configured. Add one with \`git remote add origin <url>\` inside ${undeclared.folderName}/ and re-run \`flint tinderbox heal\`.`
|
|
90199
|
+
});
|
|
90200
|
+
continue;
|
|
90201
|
+
}
|
|
90202
|
+
config.flints.required.push({ name: undeclared.name, source: remote, mode: "own" });
|
|
90203
|
+
addedDeclarations.push(undeclared.name);
|
|
90204
|
+
configChanged = true;
|
|
90205
|
+
}
|
|
90188
90206
|
if (configChanged) {
|
|
90189
90207
|
await writeTinderboxToml(root, config);
|
|
90190
90208
|
}
|
|
@@ -90194,6 +90212,7 @@ async function healTinderbox(root) {
|
|
|
90194
90212
|
root,
|
|
90195
90213
|
addedDeclarations,
|
|
90196
90214
|
renamedDeclarations,
|
|
90215
|
+
warnings,
|
|
90197
90216
|
sync,
|
|
90198
90217
|
finalCheck
|
|
90199
90218
|
};
|
|
@@ -91365,9 +91384,9 @@ async function validateHeadlessInitContent(shardPath, shorthand) {
|
|
|
91365
91384
|
const interfaceSection = findSection(sections, /\borbh interface schema\b/i);
|
|
91366
91385
|
if (!interfaceSection) {
|
|
91367
91386
|
results.push(createContentWarning(relativePath, "Headless init is missing an Orbh Interface Schema section"));
|
|
91368
|
-
} else if (!/flint orbh session
|
|
91387
|
+
} else if (!/flint orbh session(?:\s+\S+)?\s+set/.test(interfaceSection.body)) {
|
|
91369
91388
|
results.push(
|
|
91370
|
-
createContentWarning(relativePath, "Orbh Interface Schema section should describe flint orbh session
|
|
91389
|
+
createContentWarning(relativePath, "Orbh Interface Schema section should describe flint orbh session set keys (id optional when ORBH_SESSION_ID env is set)")
|
|
91371
91390
|
);
|
|
91372
91391
|
}
|
|
91373
91392
|
if (!findSection(sections, /\bphase values\b/i)) {
|
|
@@ -91376,9 +91395,9 @@ async function validateHeadlessInitContent(shardPath, shorthand) {
|
|
|
91376
91395
|
const resultSection = findSection(sections, /\bresult delivery\b/i);
|
|
91377
91396
|
if (!resultSection) {
|
|
91378
91397
|
results.push(createContentWarning(relativePath, "Headless init is missing a Result Delivery section"));
|
|
91379
|
-
} else if (!/flint orbh session
|
|
91398
|
+
} else if (!/flint orbh session(?:\s+\S+)?\s+return/.test(resultSection.body)) {
|
|
91380
91399
|
results.push(
|
|
91381
|
-
createContentWarning(relativePath, "Result Delivery section should instruct agents to call flint orbh session
|
|
91400
|
+
createContentWarning(relativePath, "Result Delivery section should instruct agents to call flint orbh session return (id optional when ORBH_SESSION_ID env is set)")
|
|
91382
91401
|
);
|
|
91383
91402
|
}
|
|
91384
91403
|
return results;
|
|
@@ -91456,14 +91475,14 @@ async function validateWorkflowContent(shardPath) {
|
|
|
91456
91475
|
results.push(createContentWarning(relativePath, "Workflow is missing an Output section"));
|
|
91457
91476
|
}
|
|
91458
91477
|
if (isHeadless) {
|
|
91459
|
-
if (!/flint orbh session
|
|
91478
|
+
if (!/flint orbh session(?:\s+\S+)?\s+set/.test(content)) {
|
|
91460
91479
|
results.push(
|
|
91461
|
-
createContentWarning(relativePath, "Headless workflows should update Orbh interface keys via flint orbh session
|
|
91480
|
+
createContentWarning(relativePath, "Headless workflows should update Orbh interface keys via flint orbh session set (id optional when ORBH_SESSION_ID env is set)")
|
|
91462
91481
|
);
|
|
91463
91482
|
}
|
|
91464
|
-
if (!/flint orbh session
|
|
91483
|
+
if (!/flint orbh session(?:\s+\S+)?\s+return/.test(content)) {
|
|
91465
91484
|
results.push(
|
|
91466
|
-
createContentWarning(relativePath, "Headless workflows should end by calling flint orbh session
|
|
91485
|
+
createContentWarning(relativePath, "Headless workflows should end by calling flint orbh session return (id optional when ORBH_SESSION_ID env is set)")
|
|
91467
91486
|
);
|
|
91468
91487
|
}
|
|
91469
91488
|
} else if (!/^##+\s+Stage\b/m.test(content)) {
|
|
@@ -93007,7 +93026,13 @@ async function postOrbhLaunch(port, profile2, prompt6 = "", timeoutMs = 1e4) {
|
|
|
93007
93026
|
});
|
|
93008
93027
|
}
|
|
93009
93028
|
function getBuiltinPresetsDir() {
|
|
93010
|
-
|
|
93029
|
+
const bundled = join152(__dirname2, "presets");
|
|
93030
|
+
const builtPackage = join152(__dirname2, "..", "presets");
|
|
93031
|
+
const tsxSource = join152(__dirname2, "..", "..", "presets");
|
|
93032
|
+
if (existsSync32(bundled)) return bundled;
|
|
93033
|
+
if (existsSync32(builtPackage)) return builtPackage;
|
|
93034
|
+
if (existsSync32(tsxSource)) return tsxSource;
|
|
93035
|
+
return bundled;
|
|
93011
93036
|
}
|
|
93012
93037
|
function getUserPresetsDir() {
|
|
93013
93038
|
return join152(getGlobalFlintDir(), "presets");
|
|
@@ -95821,7 +95846,7 @@ var init_dist5 = __esm({
|
|
|
95821
95846
|
|
|
95822
95847
|
// ../../packages/orbh/dist/index.js
|
|
95823
95848
|
import { existsSync as existsSync23, readFileSync as readFileSync22 } from "fs";
|
|
95824
|
-
import { existsSync as
|
|
95849
|
+
import { existsSync as existsSync33, readdirSync as readdirSync2, readFileSync as readFileSync32, statSync } from "fs";
|
|
95825
95850
|
import { dirname as dirname11, join as join210 } from "path";
|
|
95826
95851
|
import { closeSync, existsSync as existsSync42, openSync, readSync, statSync as statSync2, unwatchFile, watch, watchFile } from "fs";
|
|
95827
95852
|
import { existsSync as existsSync52, readFileSync as readFileSync42, unwatchFile as unwatchFile2, watch as watch2, watchFile as watchFile2 } from "fs";
|
|
@@ -97148,7 +97173,7 @@ function isRawStreamEvent(value) {
|
|
|
97148
97173
|
return isRecord6(value) && typeof value.type === "string";
|
|
97149
97174
|
}
|
|
97150
97175
|
function loadMessageParts(partsDir) {
|
|
97151
|
-
if (!
|
|
97176
|
+
if (!existsSync33(partsDir)) {
|
|
97152
97177
|
return [];
|
|
97153
97178
|
}
|
|
97154
97179
|
return readdirSync2(partsDir).filter((entry) => entry.endsWith(".json")).sort((left, right) => {
|
|
@@ -97166,7 +97191,7 @@ function loadStateFromSessionPath(sessionPath, sessionInfo) {
|
|
|
97166
97191
|
const messagesDir = join210(storageRoot, "message", sessionInfo.id);
|
|
97167
97192
|
const state = createOpencodeTranscriptState();
|
|
97168
97193
|
state.session = sessionInfo;
|
|
97169
|
-
if (!
|
|
97194
|
+
if (!existsSync33(messagesDir)) {
|
|
97170
97195
|
return state;
|
|
97171
97196
|
}
|
|
97172
97197
|
const messages = readdirSync2(messagesDir).filter((entry) => entry.endsWith(".json")).map((entry) => loadJsonFile(join210(messagesDir, entry))).filter(isMessageInfo).map((info) => ({
|
|
@@ -97882,7 +97907,7 @@ function buildCodexAppServerArgs(options3 = {}) {
|
|
|
97882
97907
|
return args;
|
|
97883
97908
|
}
|
|
97884
97909
|
async function bootstrapCodexSession(cwd2, initPrompt, options3 = {}) {
|
|
97885
|
-
return new Promise((
|
|
97910
|
+
return new Promise((resolve24, reject) => {
|
|
97886
97911
|
const start = async () => {
|
|
97887
97912
|
const executable = await getExecutable("codex");
|
|
97888
97913
|
const spawnCmd = executable.resolvedCommand.cmd;
|
|
@@ -97928,7 +97953,7 @@ async function bootstrapCodexSession(cwd2, initPrompt, options3 = {}) {
|
|
|
97928
97953
|
if (message.id === 3 && message.result) {
|
|
97929
97954
|
cleanup();
|
|
97930
97955
|
proc.kill();
|
|
97931
|
-
|
|
97956
|
+
resolve24(threadId);
|
|
97932
97957
|
return;
|
|
97933
97958
|
}
|
|
97934
97959
|
if (message.error && (message.id ?? 0) <= 3) {
|
|
@@ -98352,7 +98377,7 @@ async function waitForGeminiNativeSession(cwd2, timeoutMs, pollMs, options3) {
|
|
|
98352
98377
|
if (discovered) {
|
|
98353
98378
|
return discovered;
|
|
98354
98379
|
}
|
|
98355
|
-
await new Promise((
|
|
98380
|
+
await new Promise((resolve24) => setTimeout(resolve24, pollMs));
|
|
98356
98381
|
}
|
|
98357
98382
|
return null;
|
|
98358
98383
|
}
|
|
@@ -98625,7 +98650,7 @@ async function bootstrapGrokSession(cwd2, initPrompt, options3 = {}) {
|
|
|
98625
98650
|
if (options3.extraArgs) {
|
|
98626
98651
|
args.push(...options3.extraArgs);
|
|
98627
98652
|
}
|
|
98628
|
-
return new Promise((
|
|
98653
|
+
return new Promise((resolve24, reject) => {
|
|
98629
98654
|
const proc = spawn23(executable.resolvedCommand.cmd, args, {
|
|
98630
98655
|
stdio: ["ignore", "pipe", "pipe"],
|
|
98631
98656
|
cwd: cwd2,
|
|
@@ -98660,7 +98685,7 @@ async function bootstrapGrokSession(cwd2, initPrompt, options3 = {}) {
|
|
|
98660
98685
|
reject(new Error(`Grok bootstrap completed but no sessionId in output: ${stdout.slice(-400)}`));
|
|
98661
98686
|
return;
|
|
98662
98687
|
}
|
|
98663
|
-
|
|
98688
|
+
resolve24(sessionId);
|
|
98664
98689
|
});
|
|
98665
98690
|
});
|
|
98666
98691
|
}
|
|
@@ -99058,7 +99083,7 @@ async function waitForOpencodeNativeSessionByOrbhSessionId(cwd2, orbhSessionId,
|
|
|
99058
99083
|
if (discovered) {
|
|
99059
99084
|
return discovered;
|
|
99060
99085
|
}
|
|
99061
|
-
await new Promise((
|
|
99086
|
+
await new Promise((resolve24) => setTimeout(resolve24, pollMs));
|
|
99062
99087
|
}
|
|
99063
99088
|
return null;
|
|
99064
99089
|
}
|
|
@@ -100289,7 +100314,7 @@ async function waitForCodexNativeSession(cwd2, timeoutMs, pollMs, options3) {
|
|
|
100289
100314
|
if (discovered) {
|
|
100290
100315
|
return discovered;
|
|
100291
100316
|
}
|
|
100292
|
-
await new Promise((
|
|
100317
|
+
await new Promise((resolve24) => setTimeout(resolve24, pollMs));
|
|
100293
100318
|
}
|
|
100294
100319
|
return null;
|
|
100295
100320
|
}
|
|
@@ -100836,19 +100861,19 @@ async function startInputSocket(opts) {
|
|
|
100836
100861
|
process.stderr.write(`orbh input socket error: ${err.message}
|
|
100837
100862
|
`);
|
|
100838
100863
|
});
|
|
100839
|
-
await new Promise((
|
|
100864
|
+
await new Promise((resolve24, reject) => {
|
|
100840
100865
|
server.once("error", reject);
|
|
100841
100866
|
server.listen(socketPath, () => {
|
|
100842
100867
|
server.off("error", reject);
|
|
100843
|
-
|
|
100868
|
+
resolve24();
|
|
100844
100869
|
});
|
|
100845
100870
|
});
|
|
100846
100871
|
let closed = false;
|
|
100847
100872
|
const close = async () => {
|
|
100848
100873
|
if (closed) return;
|
|
100849
100874
|
closed = true;
|
|
100850
|
-
await new Promise((
|
|
100851
|
-
server.close(() =>
|
|
100875
|
+
await new Promise((resolve24) => {
|
|
100876
|
+
server.close(() => resolve24());
|
|
100852
100877
|
});
|
|
100853
100878
|
safeUnlink(socketPath);
|
|
100854
100879
|
};
|
|
@@ -100934,7 +100959,7 @@ async function spawnInteractiveChild(opts) {
|
|
|
100934
100959
|
});
|
|
100935
100960
|
}
|
|
100936
100961
|
function sleep2(ms) {
|
|
100937
|
-
return new Promise((
|
|
100962
|
+
return new Promise((resolve24) => setTimeout(resolve24, ms));
|
|
100938
100963
|
}
|
|
100939
100964
|
async function waitForSession(sessionsDir, sessionId, predicate, timeoutMs) {
|
|
100940
100965
|
const deadline = Date.now() + timeoutMs;
|
|
@@ -101306,7 +101331,7 @@ async function waitForInteractiveResult(child, options3, session, runtime2, inpu
|
|
|
101306
101331
|
}
|
|
101307
101332
|
clearInputSocketField(options3.sessionsDir, session.id);
|
|
101308
101333
|
};
|
|
101309
|
-
return new Promise((
|
|
101334
|
+
return new Promise((resolve24, reject) => {
|
|
101310
101335
|
const onSigHup = () => {
|
|
101311
101336
|
const latest = readSession(options3.sessionsDir, session.id) ?? session;
|
|
101312
101337
|
const run2 = getCurrentRun(latest);
|
|
@@ -101335,7 +101360,7 @@ async function waitForInteractiveResult(child, options3, session, runtime2, inpu
|
|
|
101335
101360
|
finalizeSessionRun(latest, exitCode ?? null, signal ?? null, stderr);
|
|
101336
101361
|
writeSession(options3.sessionsDir, latest);
|
|
101337
101362
|
cleanupSocket();
|
|
101338
|
-
|
|
101363
|
+
resolve24({ session: latest, exitCode: exitCode ?? 0 });
|
|
101339
101364
|
});
|
|
101340
101365
|
});
|
|
101341
101366
|
}
|
|
@@ -165661,21 +165686,21 @@ var require_react_development = __commonJS({
|
|
|
165661
165686
|
);
|
|
165662
165687
|
actScopeDepth = prevActScopeDepth;
|
|
165663
165688
|
}
|
|
165664
|
-
function recursivelyFlushAsyncActWork(returnValue,
|
|
165689
|
+
function recursivelyFlushAsyncActWork(returnValue, resolve24, reject) {
|
|
165665
165690
|
var queue = ReactSharedInternals.actQueue;
|
|
165666
165691
|
if (null !== queue)
|
|
165667
165692
|
if (0 !== queue.length)
|
|
165668
165693
|
try {
|
|
165669
165694
|
flushActQueue(queue);
|
|
165670
165695
|
enqueueTask(function() {
|
|
165671
|
-
return recursivelyFlushAsyncActWork(returnValue,
|
|
165696
|
+
return recursivelyFlushAsyncActWork(returnValue, resolve24, reject);
|
|
165672
165697
|
});
|
|
165673
165698
|
return;
|
|
165674
165699
|
} catch (error3) {
|
|
165675
165700
|
ReactSharedInternals.thrownErrors.push(error3);
|
|
165676
165701
|
}
|
|
165677
165702
|
else ReactSharedInternals.actQueue = null;
|
|
165678
|
-
0 < ReactSharedInternals.thrownErrors.length ? (queue = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, reject(queue)) :
|
|
165703
|
+
0 < ReactSharedInternals.thrownErrors.length ? (queue = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, reject(queue)) : resolve24(returnValue);
|
|
165679
165704
|
}
|
|
165680
165705
|
function flushActQueue(queue) {
|
|
165681
165706
|
if (!isFlushing) {
|
|
@@ -165862,7 +165887,7 @@ var require_react_development = __commonJS({
|
|
|
165862
165887
|
));
|
|
165863
165888
|
});
|
|
165864
165889
|
return {
|
|
165865
|
-
then: function(
|
|
165890
|
+
then: function(resolve24, reject) {
|
|
165866
165891
|
didAwaitActCall = true;
|
|
165867
165892
|
thenable.then(
|
|
165868
165893
|
function(returnValue) {
|
|
@@ -165872,7 +165897,7 @@ var require_react_development = __commonJS({
|
|
|
165872
165897
|
flushActQueue(queue), enqueueTask(function() {
|
|
165873
165898
|
return recursivelyFlushAsyncActWork(
|
|
165874
165899
|
returnValue,
|
|
165875
|
-
|
|
165900
|
+
resolve24,
|
|
165876
165901
|
reject
|
|
165877
165902
|
);
|
|
165878
165903
|
});
|
|
@@ -165886,7 +165911,7 @@ var require_react_development = __commonJS({
|
|
|
165886
165911
|
ReactSharedInternals.thrownErrors.length = 0;
|
|
165887
165912
|
reject(_thrownError);
|
|
165888
165913
|
}
|
|
165889
|
-
} else
|
|
165914
|
+
} else resolve24(returnValue);
|
|
165890
165915
|
},
|
|
165891
165916
|
function(error3) {
|
|
165892
165917
|
popActScope(prevActQueue, prevActScopeDepth);
|
|
@@ -165908,15 +165933,15 @@ var require_react_development = __commonJS({
|
|
|
165908
165933
|
if (0 < ReactSharedInternals.thrownErrors.length)
|
|
165909
165934
|
throw callback = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, callback;
|
|
165910
165935
|
return {
|
|
165911
|
-
then: function(
|
|
165936
|
+
then: function(resolve24, reject) {
|
|
165912
165937
|
didAwaitActCall = true;
|
|
165913
165938
|
0 === prevActScopeDepth ? (ReactSharedInternals.actQueue = queue, enqueueTask(function() {
|
|
165914
165939
|
return recursivelyFlushAsyncActWork(
|
|
165915
165940
|
returnValue$jscomp$0,
|
|
165916
|
-
|
|
165941
|
+
resolve24,
|
|
165917
165942
|
reject
|
|
165918
165943
|
);
|
|
165919
|
-
})) :
|
|
165944
|
+
})) : resolve24(returnValue$jscomp$0);
|
|
165920
165945
|
}
|
|
165921
165946
|
};
|
|
165922
165947
|
};
|
|
@@ -170726,8 +170751,8 @@ var require_react_reconciler_production = __commonJS({
|
|
|
170726
170751
|
currentEntangledActionThenable = {
|
|
170727
170752
|
status: "pending",
|
|
170728
170753
|
value: void 0,
|
|
170729
|
-
then: function(
|
|
170730
|
-
entangledListeners.push(
|
|
170754
|
+
then: function(resolve24) {
|
|
170755
|
+
entangledListeners.push(resolve24);
|
|
170731
170756
|
}
|
|
170732
170757
|
};
|
|
170733
170758
|
}
|
|
@@ -170750,8 +170775,8 @@ var require_react_reconciler_production = __commonJS({
|
|
|
170750
170775
|
status: "pending",
|
|
170751
170776
|
value: null,
|
|
170752
170777
|
reason: null,
|
|
170753
|
-
then: function(
|
|
170754
|
-
listeners.push(
|
|
170778
|
+
then: function(resolve24) {
|
|
170779
|
+
listeners.push(resolve24);
|
|
170755
170780
|
}
|
|
170756
170781
|
};
|
|
170757
170782
|
thenable.then(
|
|
@@ -180350,8 +180375,8 @@ var require_react_reconciler_development = __commonJS({
|
|
|
180350
180375
|
currentEntangledActionThenable = {
|
|
180351
180376
|
status: "pending",
|
|
180352
180377
|
value: void 0,
|
|
180353
|
-
then: function(
|
|
180354
|
-
entangledListeners.push(
|
|
180378
|
+
then: function(resolve24) {
|
|
180379
|
+
entangledListeners.push(resolve24);
|
|
180355
180380
|
}
|
|
180356
180381
|
};
|
|
180357
180382
|
}
|
|
@@ -180374,8 +180399,8 @@ var require_react_reconciler_development = __commonJS({
|
|
|
180374
180399
|
status: "pending",
|
|
180375
180400
|
value: null,
|
|
180376
180401
|
reason: null,
|
|
180377
|
-
then: function(
|
|
180378
|
-
listeners.push(
|
|
180402
|
+
then: function(resolve24) {
|
|
180403
|
+
listeners.push(resolve24);
|
|
180379
180404
|
}
|
|
180380
180405
|
};
|
|
180381
180406
|
thenable.then(
|
|
@@ -201271,8 +201296,8 @@ var init_ink = __esm({
|
|
|
201271
201296
|
}
|
|
201272
201297
|
}
|
|
201273
201298
|
async waitUntilExit() {
|
|
201274
|
-
this.exitPromise ||= new Promise((
|
|
201275
|
-
this.resolveExitPromise =
|
|
201299
|
+
this.exitPromise ||= new Promise((resolve24, reject) => {
|
|
201300
|
+
this.resolveExitPromise = resolve24;
|
|
201276
201301
|
this.rejectExitPromise = reject;
|
|
201277
201302
|
});
|
|
201278
201303
|
if (!this.beforeExitHandler) {
|
|
@@ -202388,12 +202413,12 @@ async function pickSession(options3) {
|
|
|
202388
202413
|
if (!process.stdin.isTTY || !process.stdout.isTTY) {
|
|
202389
202414
|
throw new Error("orbh continue requires an interactive TTY.");
|
|
202390
202415
|
}
|
|
202391
|
-
return new Promise((
|
|
202416
|
+
return new Promise((resolve24) => {
|
|
202392
202417
|
let resolved = false;
|
|
202393
202418
|
const handle = (session) => {
|
|
202394
202419
|
if (resolved) return;
|
|
202395
202420
|
resolved = true;
|
|
202396
|
-
|
|
202421
|
+
resolve24(session);
|
|
202397
202422
|
};
|
|
202398
202423
|
const instance = render_default(
|
|
202399
202424
|
(0, import_react29.createElement)(SessionPicker, {
|
|
@@ -202794,10 +202819,10 @@ async function confirm(message) {
|
|
|
202794
202819
|
input: process.stdin,
|
|
202795
202820
|
output: process.stdout
|
|
202796
202821
|
});
|
|
202797
|
-
return new Promise((
|
|
202822
|
+
return new Promise((resolve24) => {
|
|
202798
202823
|
rl.question(`${message} (y/N) `, (answer) => {
|
|
202799
202824
|
rl.close();
|
|
202800
|
-
|
|
202825
|
+
resolve24(answer.toLowerCase() === "y" || answer.toLowerCase() === "yes");
|
|
202801
202826
|
});
|
|
202802
202827
|
});
|
|
202803
202828
|
}
|
|
@@ -203605,10 +203630,10 @@ async function prompt(question) {
|
|
|
203605
203630
|
input: process.stdin,
|
|
203606
203631
|
output: process.stdout
|
|
203607
203632
|
});
|
|
203608
|
-
return new Promise((
|
|
203633
|
+
return new Promise((resolve24) => {
|
|
203609
203634
|
rl.question(question, (answer) => {
|
|
203610
203635
|
rl.close();
|
|
203611
|
-
|
|
203636
|
+
resolve24(answer.trim());
|
|
203612
203637
|
});
|
|
203613
203638
|
});
|
|
203614
203639
|
}
|
|
@@ -203969,7 +203994,7 @@ var LiveRender = class {
|
|
|
203969
203994
|
async function runStep(entry, step2, index, total, live) {
|
|
203970
203995
|
const cols = Math.max(40, process.stdout.columns ?? 80);
|
|
203971
203996
|
const tailMax = Math.max(20, cols - 6);
|
|
203972
|
-
return new Promise((
|
|
203997
|
+
return new Promise((resolve24) => {
|
|
203973
203998
|
const child = spawn4(process.execPath, [entry, ...step2.args], {
|
|
203974
203999
|
stdio: ["ignore", "pipe", "pipe"],
|
|
203975
204000
|
windowsHide: true
|
|
@@ -204010,7 +204035,7 @@ async function runStep(entry, step2, index, total, live) {
|
|
|
204010
204035
|
child.on("close", (code) => {
|
|
204011
204036
|
done = true;
|
|
204012
204037
|
clearInterval(ticker);
|
|
204013
|
-
|
|
204038
|
+
resolve24({ code: code ?? 1, tail: captured });
|
|
204014
204039
|
});
|
|
204015
204040
|
});
|
|
204016
204041
|
}
|
|
@@ -204023,9 +204048,9 @@ Runs in order:
|
|
|
204023
204048
|
|
|
204024
204049
|
If any step exits non-zero, Gigasync stops and exits with that code.
|
|
204025
204050
|
`).action(async () => {
|
|
204026
|
-
const entry = process.argv[1];
|
|
204051
|
+
const entry = process.env.FLINT_CLI_LAUNCHER ?? process.argv[1];
|
|
204027
204052
|
if (!entry) {
|
|
204028
|
-
console.error(export_pc.red("Error: Could not resolve flint entry script (process.argv[1] missing)."));
|
|
204053
|
+
console.error(export_pc.red("Error: Could not resolve flint entry script (FLINT_CLI_LAUNCHER and process.argv[1] missing)."));
|
|
204029
204054
|
process.exit(1);
|
|
204030
204055
|
}
|
|
204031
204056
|
const flintPath = await findFlintRoot(process.cwd());
|
|
@@ -204225,14 +204250,14 @@ function readPkgVersion2() {
|
|
|
204225
204250
|
}
|
|
204226
204251
|
var PACKAGE_NAME = "@nuucognition/flint-cli";
|
|
204227
204252
|
function fetchLatestVersion() {
|
|
204228
|
-
return new Promise((
|
|
204253
|
+
return new Promise((resolve24, reject) => {
|
|
204229
204254
|
https.get(`https://registry.npmjs.org/${PACKAGE_NAME}/latest`, (res) => {
|
|
204230
204255
|
let data = "";
|
|
204231
204256
|
res.on("data", (chunk) => data += chunk);
|
|
204232
204257
|
res.on("end", () => {
|
|
204233
204258
|
try {
|
|
204234
204259
|
const json = JSON.parse(data);
|
|
204235
|
-
|
|
204260
|
+
resolve24(json.version);
|
|
204236
204261
|
} catch {
|
|
204237
204262
|
reject(new Error("Failed to parse registry response"));
|
|
204238
204263
|
}
|
|
@@ -204300,10 +204325,10 @@ async function prompt2(question) {
|
|
|
204300
204325
|
input: process.stdin,
|
|
204301
204326
|
output: process.stdout
|
|
204302
204327
|
});
|
|
204303
|
-
return new Promise((
|
|
204328
|
+
return new Promise((resolve24) => {
|
|
204304
204329
|
rl.question(question, (answer) => {
|
|
204305
204330
|
rl.close();
|
|
204306
|
-
|
|
204331
|
+
resolve24(answer.trim());
|
|
204307
204332
|
});
|
|
204308
204333
|
});
|
|
204309
204334
|
}
|
|
@@ -204542,10 +204567,10 @@ async function prompt3(question) {
|
|
|
204542
204567
|
input: process.stdin,
|
|
204543
204568
|
output: process.stdout
|
|
204544
204569
|
});
|
|
204545
|
-
return new Promise((
|
|
204570
|
+
return new Promise((resolve24) => {
|
|
204546
204571
|
rl.question(question, (answer) => {
|
|
204547
204572
|
rl.close();
|
|
204548
|
-
|
|
204573
|
+
resolve24(answer.trim());
|
|
204549
204574
|
});
|
|
204550
204575
|
});
|
|
204551
204576
|
}
|
|
@@ -205152,7 +205177,7 @@ ${unfulfilled.length} unfulfilled codebase reference(s):
|
|
|
205152
205177
|
console.log(export_pc.dim(` \u2192 ${resolvedPath}`));
|
|
205153
205178
|
}
|
|
205154
205179
|
function prompt4(message) {
|
|
205155
|
-
return new Promise((
|
|
205180
|
+
return new Promise((resolve24) => {
|
|
205156
205181
|
process.stdout.write(message);
|
|
205157
205182
|
let data = "";
|
|
205158
205183
|
process.stdin.setEncoding("utf-8");
|
|
@@ -205160,7 +205185,7 @@ function prompt4(message) {
|
|
|
205160
205185
|
process.stdin.once("data", (chunk) => {
|
|
205161
205186
|
data = chunk.toString().trim();
|
|
205162
205187
|
process.stdin.pause();
|
|
205163
|
-
|
|
205188
|
+
resolve24(data);
|
|
205164
205189
|
});
|
|
205165
205190
|
});
|
|
205166
205191
|
}
|
|
@@ -205595,10 +205620,10 @@ async function exists3(path31) {
|
|
|
205595
205620
|
}
|
|
205596
205621
|
function prompt5(question) {
|
|
205597
205622
|
const rl = createInterface5({ input: process.stdin, output: process.stdout });
|
|
205598
|
-
return new Promise((
|
|
205623
|
+
return new Promise((resolve24) => {
|
|
205599
205624
|
rl.question(question, (answer) => {
|
|
205600
205625
|
rl.close();
|
|
205601
|
-
|
|
205626
|
+
resolve24(answer.trim());
|
|
205602
205627
|
});
|
|
205603
205628
|
});
|
|
205604
205629
|
}
|
|
@@ -208221,7 +208246,7 @@ function getExpectedRepoUrl() {
|
|
|
208221
208246
|
return platform5() === "win32" ? OBSIDIAN_WINDOWS_REPO_URL : OBSIDIAN_REPO_URL;
|
|
208222
208247
|
}
|
|
208223
208248
|
function postReload(port) {
|
|
208224
|
-
return new Promise((
|
|
208249
|
+
return new Promise((resolve24, reject) => {
|
|
208225
208250
|
const req = httpRequest({
|
|
208226
208251
|
hostname: "127.0.0.1",
|
|
208227
208252
|
port,
|
|
@@ -208230,7 +208255,7 @@ function postReload(port) {
|
|
|
208230
208255
|
timeout: 2e3
|
|
208231
208256
|
}, (res) => {
|
|
208232
208257
|
res.resume();
|
|
208233
|
-
res.on("end", () =>
|
|
208258
|
+
res.on("end", () => resolve24());
|
|
208234
208259
|
});
|
|
208235
208260
|
req.on("error", reject);
|
|
208236
208261
|
req.on("timeout", () => req.destroy(new Error("timeout")));
|
|
@@ -209244,7 +209269,7 @@ var DEFAULT_EXTRA_ARGS_BY_RUNTIME = {
|
|
|
209244
209269
|
};
|
|
209245
209270
|
var INPUT_SOCKET_TIMEOUT_MS = 2e3;
|
|
209246
209271
|
function sendToInputSocket(socketPath, payload) {
|
|
209247
|
-
return new Promise((
|
|
209272
|
+
return new Promise((resolve24, reject) => {
|
|
209248
209273
|
const conn = createConnection(socketPath);
|
|
209249
209274
|
let buffer2 = "";
|
|
209250
209275
|
const timer = setTimeout(() => {
|
|
@@ -209268,7 +209293,7 @@ function sendToInputSocket(socketPath, payload) {
|
|
|
209268
209293
|
cleanup();
|
|
209269
209294
|
try {
|
|
209270
209295
|
const ack = JSON.parse(line);
|
|
209271
|
-
|
|
209296
|
+
resolve24(ack);
|
|
209272
209297
|
} catch (err) {
|
|
209273
209298
|
reject(new Error(`invalid ack: ${err.message}`));
|
|
209274
209299
|
}
|
|
@@ -211162,6 +211187,27 @@ function indentBlock(text, indent = 2) {
|
|
|
211162
211187
|
function resolveMessageSender() {
|
|
211163
211188
|
return process.env.ORBH_SESSION_ID?.trim() || "human";
|
|
211164
211189
|
}
|
|
211190
|
+
var SELF_TARGETING_SESSION_ACTIONS = /* @__PURE__ */ new Set([
|
|
211191
|
+
"register",
|
|
211192
|
+
"status",
|
|
211193
|
+
"return",
|
|
211194
|
+
"set",
|
|
211195
|
+
"get",
|
|
211196
|
+
"ask"
|
|
211197
|
+
]);
|
|
211198
|
+
function resolveSelfSessionId(arg) {
|
|
211199
|
+
const trimmedArg = arg?.trim();
|
|
211200
|
+
if (trimmedArg) return trimmedArg;
|
|
211201
|
+
const env5 = process.env.ORBH_SESSION_ID?.trim();
|
|
211202
|
+
return env5 ? env5 : void 0;
|
|
211203
|
+
}
|
|
211204
|
+
function shiftSessionPositionals(rawId, rawAction, rawValueParts, envSessionId) {
|
|
211205
|
+
if (typeof rawId === "string" && SELF_TARGETING_SESSION_ACTIONS.has(rawId) && envSessionId) {
|
|
211206
|
+
const valueParts = rawAction !== void 0 ? [rawAction, ...rawValueParts] : [...rawValueParts];
|
|
211207
|
+
return { id: envSessionId, action: rawId, valueParts, shifted: true };
|
|
211208
|
+
}
|
|
211209
|
+
return { id: rawId, action: rawAction, valueParts: rawValueParts, shifted: false };
|
|
211210
|
+
}
|
|
211165
211211
|
function formatPiggybackMessages(messages) {
|
|
211166
211212
|
return `---orbh-messages---
|
|
211167
211213
|
${JSON.stringify(messages, null, 2)}`;
|
|
@@ -211261,7 +211307,7 @@ async function defaultResumeDeferredSession(resumeContext) {
|
|
|
211261
211307
|
var REQUEST_SPINNER_FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
|
|
211262
211308
|
var REQUEST_LAUNCH_OPTION_KEYS = ["runtime", "stream", "continues", "maxTurns", "budget", "model", "title", "description", "timeout"];
|
|
211263
211309
|
function sleep3(ms) {
|
|
211264
|
-
return new Promise((
|
|
211310
|
+
return new Promise((resolve24) => setTimeout(resolve24, ms));
|
|
211265
211311
|
}
|
|
211266
211312
|
function getStringOption(options3, key) {
|
|
211267
211313
|
if (typeof options3 !== "object" || options3 === null || !(key in options3)) {
|
|
@@ -212117,7 +212163,7 @@ ${export_pc.bold("Orbh Session Stats")} ${export_pc.dim("\xB7")} ${export_pc.cya
|
|
|
212117
212163
|
const deadline = Date.now() + 3e4;
|
|
212118
212164
|
process.stdout.write(export_pc.dim("Waiting for transcript path resolution..."));
|
|
212119
212165
|
while (Date.now() <= deadline) {
|
|
212120
|
-
await new Promise((
|
|
212166
|
+
await new Promise((resolve24) => setTimeout(resolve24, 500));
|
|
212121
212167
|
const fresh = resolveSession(sessionsDir, id);
|
|
212122
212168
|
if (!fresh) {
|
|
212123
212169
|
break;
|
|
@@ -212211,7 +212257,7 @@ ${export_pc.bold("Orbh Session Stats")} ${export_pc.dim("\xB7")} ${export_pc.cya
|
|
|
212211
212257
|
});
|
|
212212
212258
|
watcher.start();
|
|
212213
212259
|
if (isTerminalStatus(session.status)) {
|
|
212214
|
-
await new Promise((
|
|
212260
|
+
await new Promise((resolve24) => setTimeout(resolve24, 500));
|
|
212215
212261
|
watcher.stop();
|
|
212216
212262
|
if (entryCount > 0) {
|
|
212217
212263
|
process.stdout.write("\r\x1B[2K");
|
|
@@ -212326,9 +212372,14 @@ ${export_pc.bold("Orbh Session Stats")} ${export_pc.dim("\xB7")} ${export_pc.cya
|
|
|
212326
212372
|
console.log(`Focused ${binding.vault} \u2192 leaf ${binding.leafId.slice(0, 8)}`);
|
|
212327
212373
|
});
|
|
212328
212374
|
addOptionalPathOption(
|
|
212329
|
-
command.command("close").description("Close this session's Obsidian terminal tab and flip the title prefix to [Closed] (kills the harness)").argument("
|
|
212375
|
+
command.command("close").description("Close this session's Obsidian terminal tab and flip the title prefix to [Closed] (kills the harness). Self-targets via ORBH_SESSION_ID when run from inside an Orbh harness.").argument("[id]", "Session ID (full or partial). Optional when ORBH_SESSION_ID is set."),
|
|
212330
212376
|
options3
|
|
212331
|
-
).action(async (
|
|
212377
|
+
).action(async (idArg, commandOptions) => {
|
|
212378
|
+
const id = resolveSelfSessionId(idArg);
|
|
212379
|
+
if (!id) {
|
|
212380
|
+
console.error(export_pc.red("Error: Session ID required. Pass it explicitly or run inside an Orbh harness (ORBH_SESSION_ID env var)."));
|
|
212381
|
+
process.exit(1);
|
|
212382
|
+
}
|
|
212332
212383
|
const { sessionsDir } = await getResolvedContext(commandOptions, options3);
|
|
212333
212384
|
const session = resolveSession(sessionsDir, id);
|
|
212334
212385
|
if (!session) {
|
|
@@ -212357,9 +212408,14 @@ ${export_pc.bold("Orbh Session Stats")} ${export_pc.dim("\xB7")} ${export_pc.cya
|
|
|
212357
212408
|
console.log(`Closed tab in ${binding.vault}`);
|
|
212358
212409
|
});
|
|
212359
212410
|
addOptionalPathOption(
|
|
212360
|
-
command.command("park").description("Park this session \u2014 close the Obsidian tab, flip the title prefix to [Parked], and pin to the top of `orbh c`. `orbh resume` auto-unparks.").argument("
|
|
212411
|
+
command.command("park").description("Park this session \u2014 close the Obsidian tab, flip the title prefix to [Parked], and pin to the top of `orbh c`. `orbh resume` auto-unparks. Self-targets via ORBH_SESSION_ID when run from inside an Orbh harness.").argument("[id]", "Session ID (full or partial). Optional when ORBH_SESSION_ID is set."),
|
|
212361
212412
|
options3
|
|
212362
|
-
).action(async (
|
|
212413
|
+
).action(async (idArg, commandOptions) => {
|
|
212414
|
+
const id = resolveSelfSessionId(idArg);
|
|
212415
|
+
if (!id) {
|
|
212416
|
+
console.error(export_pc.red("Error: Session ID required. Pass it explicitly or run inside an Orbh harness (ORBH_SESSION_ID env var)."));
|
|
212417
|
+
process.exit(1);
|
|
212418
|
+
}
|
|
212363
212419
|
const { sessionsDir } = await getResolvedContext(commandOptions, options3);
|
|
212364
212420
|
const session = resolveSession(sessionsDir, id);
|
|
212365
212421
|
if (!session) {
|
|
@@ -212384,6 +212440,34 @@ ${export_pc.bold("Orbh Session Stats")} ${export_pc.dim("\xB7")} ${export_pc.cya
|
|
|
212384
212440
|
}
|
|
212385
212441
|
console.log(`Parked session ${shortId(session.id)} (tab closed in ${binding.vault}). Resume with: orbh resume ${shortId(session.id)}`);
|
|
212386
212442
|
});
|
|
212443
|
+
addOptionalPathOption(
|
|
212444
|
+
command.command("discard").description("Discard this session \u2014 close the Obsidian tab and hard-delete the session entry from .flint/sessions/. No confirmation. Self-targets via ORBH_SESSION_ID when run from inside an Orbh harness.").argument("[id]", "Session ID (full or partial). Optional when ORBH_SESSION_ID is set."),
|
|
212445
|
+
options3
|
|
212446
|
+
).action(async (idArg, commandOptions) => {
|
|
212447
|
+
const id = resolveSelfSessionId(idArg);
|
|
212448
|
+
if (!id) {
|
|
212449
|
+
console.error(export_pc.red("Error: Session ID required. Pass it explicitly or run inside an Orbh harness (ORBH_SESSION_ID env var)."));
|
|
212450
|
+
process.exit(1);
|
|
212451
|
+
}
|
|
212452
|
+
const { sessionsDir } = await getResolvedContext(commandOptions, options3);
|
|
212453
|
+
const session = resolveSession(sessionsDir, id);
|
|
212454
|
+
if (!session) {
|
|
212455
|
+
console.error(export_pc.red(`Error: Session not found: ${id}`));
|
|
212456
|
+
process.exit(1);
|
|
212457
|
+
}
|
|
212458
|
+
const binding = await resolveLiveObsidianBinding(sessionsDir, session);
|
|
212459
|
+
if (!binding) {
|
|
212460
|
+
console.error(export_pc.red("No Obsidian binding on this session."));
|
|
212461
|
+
process.exit(1);
|
|
212462
|
+
}
|
|
212463
|
+
const result = await closeLeaf(binding);
|
|
212464
|
+
if (!result.ok) {
|
|
212465
|
+
console.error(export_pc.red(`Discard failed: ${result.error}`));
|
|
212466
|
+
process.exit(1);
|
|
212467
|
+
}
|
|
212468
|
+
deleteSession(sessionsDir, session.id);
|
|
212469
|
+
console.log(`Discarded session ${shortId(session.id)} (tab closed in ${binding.vault}, entry deleted).`);
|
|
212470
|
+
});
|
|
212387
212471
|
const messageCommand = addOptionalPathOption(
|
|
212388
212472
|
command.command("message").description("Send or inspect persisted inter-session messages"),
|
|
212389
212473
|
options3
|
|
@@ -212435,10 +212519,17 @@ ${export_pc.bold("Orbh Session Stats")} ${export_pc.dim("\xB7")} ${export_pc.cya
|
|
|
212435
212519
|
));
|
|
212436
212520
|
});
|
|
212437
212521
|
const sessionCommand = addOptionalPathOption(
|
|
212438
|
-
command.command("session").description(
|
|
212522
|
+
command.command("session").description('Agent-facing session lifecycle commands. When ORBH_SESSION_ID is set, <id> may be omitted for self-targeting actions (register, status, return, set, get, ask) \u2014 e.g. `orbh session register "title" "desc"`.').argument("<id>", "Session ID (full or partial), or the action verb when ORBH_SESSION_ID is set").argument("[action]", 'Action: register, status, return, set, get, ask \u2014 or use "await" for event subscription').argument("[value...]", "Arguments for the selected action").option("--timeout <seconds>", "Timeout in seconds", "3600").option("-f, --filter <key=value>", "Filter payloads by field value (for await); repeat to add more", collectRepeatedOption, []).option("--list", "List available event types (for await)").option("--host <host>", "Server host override (for await)").option("--port <port>", "Server port override (for await)", Number).option("--sessions-dir <path>", "Override sessions directory (for await)").option("--config <path>", "Path to orbh.toml (for await)"),
|
|
212439
212523
|
options3
|
|
212440
212524
|
);
|
|
212441
|
-
sessionCommand.action(async (
|
|
212525
|
+
sessionCommand.action(async (rawId, rawAction, rawValueParts, commandOptions) => {
|
|
212526
|
+
const envSessionId = process.env.ORBH_SESSION_ID?.trim();
|
|
212527
|
+
const shifted = shiftSessionPositionals(rawId, rawAction, rawValueParts, envSessionId);
|
|
212528
|
+
let { id, action, valueParts } = shifted;
|
|
212529
|
+
if (!shifted.shifted && typeof rawId === "string" && SELF_TARGETING_SESSION_ACTIONS.has(rawId) && !envSessionId) {
|
|
212530
|
+
console.error(export_pc.red(`Error: '${rawId}' looks like a session action, but no session id was provided and ORBH_SESSION_ID is unset. Pass the id explicitly: orbh session <id> ${rawId} ...`));
|
|
212531
|
+
process.exit(1);
|
|
212532
|
+
}
|
|
212442
212533
|
if (id === "await") {
|
|
212443
212534
|
const AWAIT_EVENT_TYPES = [
|
|
212444
212535
|
{ type: "session.created", description: "A new session was created" },
|
|
@@ -212515,15 +212606,22 @@ ${export_pc.bold("Orbh Session Stats")} ${export_pc.dim("\xB7")} ${export_pc.cya
|
|
|
212515
212606
|
}
|
|
212516
212607
|
return;
|
|
212517
212608
|
}
|
|
212609
|
+
if (!id) {
|
|
212610
|
+
console.error(export_pc.red("Error: Missing <id>. Pass it explicitly or run inside an Orbh harness (ORBH_SESSION_ID env var)."));
|
|
212611
|
+
process.exit(1);
|
|
212612
|
+
return;
|
|
212613
|
+
}
|
|
212518
212614
|
if (!action) {
|
|
212519
212615
|
console.error(export_pc.red("Error: Missing <action>. Valid: register, status, return, set, get, ask."));
|
|
212520
212616
|
process.exit(1);
|
|
212617
|
+
return;
|
|
212521
212618
|
}
|
|
212522
212619
|
const { sessionsDir } = await getResolvedContext(commandOptions, options3);
|
|
212523
212620
|
const session = resolveSession(sessionsDir, id);
|
|
212524
212621
|
if (!session) {
|
|
212525
212622
|
console.error(export_pc.red(`Error: Session not found: ${id}`));
|
|
212526
212623
|
process.exit(1);
|
|
212624
|
+
return;
|
|
212527
212625
|
}
|
|
212528
212626
|
switch (action) {
|
|
212529
212627
|
case "register": {
|
|
@@ -212533,7 +212631,7 @@ ${export_pc.bold("Orbh Session Stats")} ${export_pc.dim("\xB7")} ${export_pc.cya
|
|
|
212533
212631
|
}
|
|
212534
212632
|
const [rawTitle, ...descriptionParts] = valueParts;
|
|
212535
212633
|
const description = descriptionParts.join(" ");
|
|
212536
|
-
const cleanTitle = rawTitle.replace(/^\(I\)\s*/i, "").trim();
|
|
212634
|
+
const cleanTitle = (rawTitle ?? "").replace(/^\(I\)\s*/i, "").trim();
|
|
212537
212635
|
const title = session.interactive ? `(I) ${cleanTitle}` : cleanTitle;
|
|
212538
212636
|
updateSession(sessionsDir, session.id, { title, description, status: "in-progress" });
|
|
212539
212637
|
try {
|
|
@@ -212597,6 +212695,11 @@ ${export_pc.bold("Orbh Session Stats")} ${export_pc.dim("\xB7")} ${export_pc.cya
|
|
|
212597
212695
|
process.exit(1);
|
|
212598
212696
|
}
|
|
212599
212697
|
const [key, ...sessionValueParts] = valueParts;
|
|
212698
|
+
if (!key) {
|
|
212699
|
+
console.error(export_pc.red("Error: set requires <key> <value>."));
|
|
212700
|
+
process.exit(1);
|
|
212701
|
+
return;
|
|
212702
|
+
}
|
|
212600
212703
|
const value = sessionValueParts.join(" ");
|
|
212601
212704
|
session.interface[key] = value;
|
|
212602
212705
|
writeSession(sessionsDir, session);
|
|
@@ -212648,7 +212751,7 @@ ${export_pc.bold("Orbh Session Stats")} ${export_pc.dim("\xB7")} ${export_pc.cya
|
|
|
212648
212751
|
deliverPendingMessagesToStdout(sessionsDir, session.id);
|
|
212649
212752
|
return;
|
|
212650
212753
|
}
|
|
212651
|
-
await new Promise((
|
|
212754
|
+
await new Promise((resolve24) => setTimeout(resolve24, 2e3));
|
|
212652
212755
|
}
|
|
212653
212756
|
updateSession(sessionsDir, session.id, { status: "in-progress" });
|
|
212654
212757
|
console.error("Timeout: no response received");
|
|
@@ -213239,8 +213342,13 @@ function registerServerCommands(command) {
|
|
|
213239
213342
|
}
|
|
213240
213343
|
const daemonChild = process.env.ORBH_DAEMON_CHILD === "1";
|
|
213241
213344
|
if (opts.daemon && !daemonChild) {
|
|
213242
|
-
const
|
|
213243
|
-
|
|
213345
|
+
const launcher = process.env.ORBH_CLI_LAUNCHER ?? process.argv[1];
|
|
213346
|
+
if (!launcher) {
|
|
213347
|
+
console.error(export_pc.red("Error: Could not resolve orbh entry script (ORBH_CLI_LAUNCHER and process.argv[1] missing)."));
|
|
213348
|
+
process.exit(1);
|
|
213349
|
+
}
|
|
213350
|
+
const childArgs = [launcher, ...process.argv.slice(2).filter((arg) => arg !== "--daemon")];
|
|
213351
|
+
const child = spawn9(process.execPath, childArgs, {
|
|
213244
213352
|
cwd: process.cwd(),
|
|
213245
213353
|
detached: true,
|
|
213246
213354
|
stdio: "ignore",
|
|
@@ -214305,6 +214413,12 @@ var tinderboxCommand = new Command("tinderbox").description("Orchestrate operati
|
|
|
214305
214413
|
console.log(` ${export_pc.green("\u2713")} ${entry.from} -> ${entry.to}`);
|
|
214306
214414
|
}
|
|
214307
214415
|
}
|
|
214416
|
+
if (result.warnings.length > 0) {
|
|
214417
|
+
console.log(export_pc.bold("\nWarnings"));
|
|
214418
|
+
for (const warning of result.warnings) {
|
|
214419
|
+
console.log(` ${export_pc.yellow("!")} ${warning.scope}: ${warning.message}`);
|
|
214420
|
+
}
|
|
214421
|
+
}
|
|
214308
214422
|
printSummary(result.sync);
|
|
214309
214423
|
printCheck(result.finalCheck);
|
|
214310
214424
|
if (result.sync.errors.length > 0 || !result.finalCheck.ok) {
|
|
@@ -214935,12 +215049,12 @@ var FlintServerClient = class {
|
|
|
214935
215049
|
|
|
214936
215050
|
// ../../packages/flint-sdk/src/discovery.ts
|
|
214937
215051
|
async function loadNodeModules() {
|
|
214938
|
-
const [{ readFile: readFile21 }, { homedir: homedir14 }, { join: join56, resolve:
|
|
215052
|
+
const [{ readFile: readFile21 }, { homedir: homedir14 }, { join: join56, resolve: resolve24 }] = await Promise.all([
|
|
214939
215053
|
import("fs/promises"),
|
|
214940
215054
|
import("os"),
|
|
214941
215055
|
import("path")
|
|
214942
215056
|
]);
|
|
214943
|
-
return { readFile: readFile21, homedir: homedir14, join: join56, resolve:
|
|
215057
|
+
return { readFile: readFile21, homedir: homedir14, join: join56, resolve: resolve24 };
|
|
214944
215058
|
}
|
|
214945
215059
|
function normalizeRegistryFile(value) {
|
|
214946
215060
|
if (!value || typeof value !== "object" || !("servers" in value) || !Array.isArray(value.servers)) {
|
|
@@ -214996,7 +215110,7 @@ init_dist5();
|
|
|
214996
215110
|
import Fastify2 from "fastify";
|
|
214997
215111
|
import fastifyCors from "@fastify/cors";
|
|
214998
215112
|
import fastifyStatic from "@fastify/static";
|
|
214999
|
-
import { stat as
|
|
215113
|
+
import { stat as stat63 } from "fs/promises";
|
|
215000
215114
|
import path72 from "path";
|
|
215001
215115
|
import { fileURLToPath as fileURLToPath7 } from "url";
|
|
215002
215116
|
import { join as join54 } from "path";
|
|
@@ -216548,7 +216662,7 @@ import { parse as parseYaml6 } from "yaml";
|
|
|
216548
216662
|
import { existsSync as existsSync24, watch as watch4 } from "fs";
|
|
216549
216663
|
import { stat as stat25 } from "fs/promises";
|
|
216550
216664
|
import path27 from "path";
|
|
216551
|
-
import { mkdir as mkdir18, readFile as readFile27, writeFile as writeFile14 } from "fs/promises";
|
|
216665
|
+
import { mkdir as mkdir18, readFile as readFile27, stat as stat33, writeFile as writeFile14 } from "fs/promises";
|
|
216552
216666
|
import { homedir as homedir12 } from "os";
|
|
216553
216667
|
import { join as join47, resolve as resolve21 } from "path";
|
|
216554
216668
|
init_dist5();
|
|
@@ -216557,17 +216671,17 @@ init_dist5();
|
|
|
216557
216671
|
init_dist5();
|
|
216558
216672
|
init_dist6();
|
|
216559
216673
|
import { existsSync as existsSync25 } from "fs";
|
|
216560
|
-
import { stat as
|
|
216674
|
+
import { stat as stat43, readFile as readFile37 } from "fs/promises";
|
|
216561
216675
|
import path33 from "path";
|
|
216562
216676
|
import path43, { join as join211 } from "path";
|
|
216563
|
-
import { readdirSync as readdirSync9, readFileSync as readFileSync17, existsSync as
|
|
216677
|
+
import { readdirSync as readdirSync9, readFileSync as readFileSync17, existsSync as existsSync34 } from "fs";
|
|
216564
216678
|
import { readdir as readdir15 } from "fs/promises";
|
|
216565
216679
|
import path53 from "path";
|
|
216566
216680
|
import { readdir as readdir25 } from "fs/promises";
|
|
216567
216681
|
import { join as join310 } from "path";
|
|
216568
216682
|
import { mkdir as mkdir25, readFile as readFile43, rename as rename10, writeFile as writeFile26, readdir as readdir33 } from "fs/promises";
|
|
216569
216683
|
import path62 from "path";
|
|
216570
|
-
import { writeFile as writeFile35, mkdir as mkdir33, readdir as readdir43, readFile as readFile53, stat as
|
|
216684
|
+
import { writeFile as writeFile35, mkdir as mkdir33, readdir as readdir43, readFile as readFile53, stat as stat53 } from "fs/promises";
|
|
216571
216685
|
import { join as join48 } from "path";
|
|
216572
216686
|
var DEFAULT_EVENT_LOG_SIZE = 200;
|
|
216573
216687
|
function computeRuntimeId(flintPath) {
|
|
@@ -216959,7 +217073,7 @@ async function executeHook(options3) {
|
|
|
216959
217073
|
const { hook, event, flintPath, logger } = options3;
|
|
216960
217074
|
const command = resolveHookCommand(hook.command, flintPath);
|
|
216961
217075
|
logger.debug?.("Running hook", hook.command);
|
|
216962
|
-
await new Promise((
|
|
217076
|
+
await new Promise((resolve24, reject) => {
|
|
216963
217077
|
const envPathEntries = [
|
|
216964
217078
|
path26.join(flintPath, "node_modules", ".bin"),
|
|
216965
217079
|
path26.join(process.cwd(), "node_modules", ".bin"),
|
|
@@ -217005,7 +217119,7 @@ async function executeHook(options3) {
|
|
|
217005
217119
|
if (stdout.trim()) {
|
|
217006
217120
|
logger.info?.(`Hook output: ${stdout.trim()}`);
|
|
217007
217121
|
}
|
|
217008
|
-
|
|
217122
|
+
resolve24();
|
|
217009
217123
|
return;
|
|
217010
217124
|
}
|
|
217011
217125
|
if (code === 2) {
|
|
@@ -217013,7 +217127,7 @@ async function executeHook(options3) {
|
|
|
217013
217127
|
if (stderr.trim()) {
|
|
217014
217128
|
logger.warn?.(stderr.trim());
|
|
217015
217129
|
}
|
|
217016
|
-
|
|
217130
|
+
resolve24();
|
|
217017
217131
|
return;
|
|
217018
217132
|
}
|
|
217019
217133
|
const error3 = new Error(`Hook failed (${code ?? "unknown"}): ${hook.command}`);
|
|
@@ -217309,6 +217423,21 @@ async function readAndValidateRegistry() {
|
|
|
217309
217423
|
}
|
|
217310
217424
|
return valid;
|
|
217311
217425
|
}
|
|
217426
|
+
async function readRegistryRaw() {
|
|
217427
|
+
const entries = await readServerRegistry();
|
|
217428
|
+
let registryMtime = null;
|
|
217429
|
+
try {
|
|
217430
|
+
const s = await stat33(REGISTRY_PATH);
|
|
217431
|
+
registryMtime = s.mtime.toISOString();
|
|
217432
|
+
} catch {
|
|
217433
|
+
registryMtime = null;
|
|
217434
|
+
}
|
|
217435
|
+
return {
|
|
217436
|
+
registryPath: REGISTRY_PATH,
|
|
217437
|
+
registryMtime,
|
|
217438
|
+
entries
|
|
217439
|
+
};
|
|
217440
|
+
}
|
|
217312
217441
|
function getServerRegistryPath() {
|
|
217313
217442
|
return REGISTRY_PATH;
|
|
217314
217443
|
}
|
|
@@ -217423,13 +217552,13 @@ function registerPlatesRoutes(app, ctx) {
|
|
|
217423
217552
|
}
|
|
217424
217553
|
const entryPath = path33.resolve(plate.path, plate.manifest.entry);
|
|
217425
217554
|
const distRoot = path33.dirname(entryPath);
|
|
217426
|
-
if (!await
|
|
217555
|
+
if (!await stat43(distRoot).catch(() => null)) {
|
|
217427
217556
|
return sendApiError(reply, 404, "plate_not_built", `Plate "${plate.manifest.name}" has not been built`, {
|
|
217428
217557
|
plate: plate.manifest.name
|
|
217429
217558
|
});
|
|
217430
217559
|
}
|
|
217431
217560
|
const targetPath = requestedPath && requestedPath.length > 0 ? path33.resolve(distRoot, requestedPath) : entryPath;
|
|
217432
|
-
if (!targetPath.startsWith(distRoot) || !await
|
|
217561
|
+
if (!targetPath.startsWith(distRoot) || !await stat43(targetPath).catch(() => null)) {
|
|
217433
217562
|
return sendApiError(reply, 404, "not_found", `Asset "${requestedPath ?? "/"}" was not found`);
|
|
217434
217563
|
}
|
|
217435
217564
|
const content = await readFile37(targetPath);
|
|
@@ -217814,7 +217943,7 @@ async function buildFlintIdentity(ctx) {
|
|
|
217814
217943
|
]);
|
|
217815
217944
|
let totalSessions = 0;
|
|
217816
217945
|
let activeSessions = 0;
|
|
217817
|
-
if (ctx.orbhSessionsDir &&
|
|
217946
|
+
if (ctx.orbhSessionsDir && existsSync34(ctx.orbhSessionsDir)) {
|
|
217818
217947
|
const files = readdirSync9(ctx.orbhSessionsDir).filter((f) => f.endsWith(".json"));
|
|
217819
217948
|
totalSessions = files.length;
|
|
217820
217949
|
for (const file of files) {
|
|
@@ -218550,6 +218679,9 @@ function registerRegistryRoutes(app) {
|
|
|
218550
218679
|
servers: servers.map(({ valid: _valid, url: _url, ...entry }) => entry)
|
|
218551
218680
|
};
|
|
218552
218681
|
});
|
|
218682
|
+
app.get("/api/registry/raw", async () => {
|
|
218683
|
+
return readRegistryRaw();
|
|
218684
|
+
});
|
|
218553
218685
|
}
|
|
218554
218686
|
var FLUSH_INTERVAL_MS = 5e3;
|
|
218555
218687
|
var RUNTIME_DIR_MAP = {
|
|
@@ -218663,7 +218795,7 @@ var LiveTranscriptWriter = class {
|
|
|
218663
218795
|
}
|
|
218664
218796
|
for (const dir of runtimeDirs) {
|
|
218665
218797
|
const dirPath = join48(agentsDir, dir);
|
|
218666
|
-
const dirStat = await
|
|
218798
|
+
const dirStat = await stat53(dirPath).catch(() => null);
|
|
218667
218799
|
if (!dirStat?.isDirectory()) continue;
|
|
218668
218800
|
let files;
|
|
218669
218801
|
try {
|
|
@@ -218793,11 +218925,11 @@ async function shutdownPairedSteelHost(steelUrl) {
|
|
|
218793
218925
|
}
|
|
218794
218926
|
async function isPortFree(port, host) {
|
|
218795
218927
|
const { createServer: createServer4 } = await import("net");
|
|
218796
|
-
return new Promise((
|
|
218928
|
+
return new Promise((resolve24) => {
|
|
218797
218929
|
const server = createServer4();
|
|
218798
|
-
server.once("error", () =>
|
|
218930
|
+
server.once("error", () => resolve24(false));
|
|
218799
218931
|
server.once("listening", () => {
|
|
218800
|
-
server.close(() =>
|
|
218932
|
+
server.close(() => resolve24(true));
|
|
218801
218933
|
});
|
|
218802
218934
|
server.listen(port, host);
|
|
218803
218935
|
});
|
|
@@ -218842,7 +218974,7 @@ async function waitForCliHostDeregister(flintPath, flintId, timeoutMs = 5e3) {
|
|
|
218842
218974
|
if (!stillRunning) {
|
|
218843
218975
|
return true;
|
|
218844
218976
|
}
|
|
218845
|
-
await new Promise((
|
|
218977
|
+
await new Promise((resolve24) => setTimeout(resolve24, 150));
|
|
218846
218978
|
}
|
|
218847
218979
|
return false;
|
|
218848
218980
|
}
|
|
@@ -218909,7 +219041,7 @@ async function startFlintServer(options3 = {}) {
|
|
|
218909
219041
|
const __dirname7 = path72.dirname(fileURLToPath7(import.meta.url));
|
|
218910
219042
|
const dashboardDist = path72.resolve(__dirname7, "..", "..", "..", "apps", "orbh-dashboard", "dist");
|
|
218911
219043
|
try {
|
|
218912
|
-
await
|
|
219044
|
+
await stat63(dashboardDist);
|
|
218913
219045
|
await app.register(fastifyStatic, {
|
|
218914
219046
|
root: dashboardDist,
|
|
218915
219047
|
prefix: "/",
|
|
@@ -219080,7 +219212,7 @@ async function startFlintServer(options3 = {}) {
|
|
|
219080
219212
|
console.log(`[flint-server] ${needsBuild.length} plate(s) need building...`);
|
|
219081
219213
|
for (const plate of needsBuild) {
|
|
219082
219214
|
try {
|
|
219083
|
-
const nodeModulesExists = await
|
|
219215
|
+
const nodeModulesExists = await stat63(join54(plate.path, "node_modules")).then(() => true, () => false);
|
|
219084
219216
|
if (!nodeModulesExists) {
|
|
219085
219217
|
console.log(`[flint-server] installing deps for ${plate.manifest.title}...`);
|
|
219086
219218
|
const installResult = await installPlateDeps(flintPath, plate.manifest.name);
|
|
@@ -220150,30 +220282,48 @@ async function listFlints() {
|
|
|
220150
220282
|
return a.name.localeCompare(b.name);
|
|
220151
220283
|
});
|
|
220152
220284
|
}
|
|
220153
|
-
function
|
|
220154
|
-
const
|
|
220155
|
-
|
|
220156
|
-
|
|
220157
|
-
|
|
220158
|
-
|
|
220285
|
+
async function liveServers() {
|
|
220286
|
+
const all = await readAllServers();
|
|
220287
|
+
return all.filter((s) => isProcessAlive2(s.pid));
|
|
220288
|
+
}
|
|
220289
|
+
function resolveLaunchTarget2(servers, selector) {
|
|
220290
|
+
if (selector.flintId) {
|
|
220291
|
+
const id = selector.flintId.trim();
|
|
220292
|
+
const match2 = servers.find((s) => s.flintId === id);
|
|
220293
|
+
if (match2) return match2;
|
|
220294
|
+
}
|
|
220295
|
+
if (selector.flintPath) {
|
|
220296
|
+
const targetPath = path29.resolve(selector.flintPath.trim());
|
|
220297
|
+
const match2 = servers.find((s) => path29.resolve(s.flintPath) === targetPath);
|
|
220298
|
+
if (match2) return match2;
|
|
220299
|
+
}
|
|
220300
|
+
if (selector.flintName) {
|
|
220301
|
+
const target = selector.flintName.trim().toLowerCase();
|
|
220302
|
+
const withPrefix2 = target.startsWith("(flint)") ? target : `(flint) ${target}`;
|
|
220303
|
+
const match2 = servers.find((s) => {
|
|
220304
|
+
const n = s.name.toLowerCase();
|
|
220305
|
+
const v = (s.vault ?? "").toLowerCase();
|
|
220306
|
+
return n === target || n === withPrefix2 || v === target || v === withPrefix2;
|
|
220307
|
+
});
|
|
220308
|
+
if (match2) return match2;
|
|
220159
220309
|
}
|
|
220160
220310
|
return null;
|
|
220161
220311
|
}
|
|
220162
220312
|
function readBody(req) {
|
|
220163
|
-
return new Promise((
|
|
220313
|
+
return new Promise((resolve24, reject) => {
|
|
220164
220314
|
let data = "";
|
|
220165
220315
|
req.on("data", (chunk) => data += chunk);
|
|
220166
|
-
req.on("end", () =>
|
|
220316
|
+
req.on("end", () => resolve24(data));
|
|
220167
220317
|
req.on("error", reject);
|
|
220168
220318
|
});
|
|
220169
220319
|
}
|
|
220170
|
-
async function proxyLaunch(
|
|
220320
|
+
async function proxyLaunch(targetPort, body) {
|
|
220171
220321
|
const payload = JSON.stringify({ profile: body.profile, prompt: body.prompt });
|
|
220172
|
-
return new Promise((
|
|
220322
|
+
return new Promise((resolve24, reject) => {
|
|
220173
220323
|
const req = http.request(
|
|
220174
220324
|
{
|
|
220175
220325
|
host: "127.0.0.1",
|
|
220176
|
-
port:
|
|
220326
|
+
port: targetPort,
|
|
220177
220327
|
path: "/workspace/orbh/launch",
|
|
220178
220328
|
method: "POST",
|
|
220179
220329
|
headers: {
|
|
@@ -220184,7 +220334,7 @@ async function proxyLaunch(record, body) {
|
|
|
220184
220334
|
(res) => {
|
|
220185
220335
|
let data = "";
|
|
220186
220336
|
res.on("data", (chunk) => data += chunk);
|
|
220187
|
-
res.on("end", () =>
|
|
220337
|
+
res.on("end", () => resolve24({ status: res.statusCode ?? 502, body: data }));
|
|
220188
220338
|
res.on("error", reject);
|
|
220189
220339
|
}
|
|
220190
220340
|
);
|
|
@@ -220233,12 +220383,17 @@ async function handleRequest(req, res, port) {
|
|
|
220233
220383
|
res.end(JSON.stringify({ ok: false, error: "invalid JSON body" }));
|
|
220234
220384
|
return;
|
|
220235
220385
|
}
|
|
220236
|
-
const
|
|
220386
|
+
const flintId = typeof parsed.flintId === "string" && parsed.flintId.trim() ? parsed.flintId : void 0;
|
|
220387
|
+
const flintPath = typeof parsed.flintPath === "string" && parsed.flintPath.trim() ? parsed.flintPath : void 0;
|
|
220388
|
+
const flintName = typeof parsed.flintName === "string" && parsed.flintName.trim() ? parsed.flintName : void 0;
|
|
220237
220389
|
const profile2 = parsed.profile;
|
|
220238
220390
|
const prompt6 = parsed.prompt;
|
|
220239
|
-
if (
|
|
220391
|
+
if (!flintId && !flintPath && !flintName) {
|
|
220240
220392
|
res.statusCode = 400;
|
|
220241
|
-
res.end(JSON.stringify({
|
|
220393
|
+
res.end(JSON.stringify({
|
|
220394
|
+
ok: false,
|
|
220395
|
+
error: "one of flintId, flintPath, or flintName required (non-empty string)"
|
|
220396
|
+
}));
|
|
220242
220397
|
return;
|
|
220243
220398
|
}
|
|
220244
220399
|
if (typeof profile2 !== "string" || !profile2.trim()) {
|
|
@@ -220246,24 +220401,25 @@ async function handleRequest(req, res, port) {
|
|
|
220246
220401
|
res.end(JSON.stringify({ ok: false, error: "profile required (non-empty string)" }));
|
|
220247
220402
|
return;
|
|
220248
220403
|
}
|
|
220249
|
-
|
|
220250
|
-
|
|
220251
|
-
|
|
220252
|
-
return;
|
|
220253
|
-
}
|
|
220254
|
-
const vaults = await liveVaults();
|
|
220255
|
-
const match2 = matchVault(vaults, flintName);
|
|
220404
|
+
const normalizedPrompt = typeof prompt6 === "string" ? prompt6 : "";
|
|
220405
|
+
const servers = await liveServers();
|
|
220406
|
+
const match2 = resolveLaunchTarget2(servers, { flintId, flintPath, flintName });
|
|
220256
220407
|
if (!match2) {
|
|
220408
|
+
const selector = flintId ?? flintPath ?? flintName;
|
|
220257
220409
|
res.statusCode = 404;
|
|
220258
220410
|
res.end(JSON.stringify({
|
|
220259
220411
|
ok: false,
|
|
220260
|
-
error: `no live
|
|
220261
|
-
available:
|
|
220412
|
+
error: `no live flint matching "${selector}"`,
|
|
220413
|
+
available: servers.map((s) => ({
|
|
220414
|
+
flintId: s.flintId,
|
|
220415
|
+
name: s.name,
|
|
220416
|
+
flintPath: s.flintPath
|
|
220417
|
+
}))
|
|
220262
220418
|
}));
|
|
220263
220419
|
return;
|
|
220264
220420
|
}
|
|
220265
220421
|
try {
|
|
220266
|
-
const proxied = await proxyLaunch(match2, { profile: profile2, prompt:
|
|
220422
|
+
const proxied = await proxyLaunch(match2.port, { profile: profile2, prompt: normalizedPrompt });
|
|
220267
220423
|
res.statusCode = proxied.status;
|
|
220268
220424
|
res.end(proxied.body);
|
|
220269
220425
|
} catch (err) {
|
|
@@ -220302,7 +220458,7 @@ var routerCommand = new Command("router").description("Local HTTP broker that pr
|
|
|
220302
220458
|
console.log(export_pc.dim(" GET /health \u2014 liveness check"));
|
|
220303
220459
|
console.log(export_pc.dim(" GET /vaults \u2014 list live Obsidian vaults"));
|
|
220304
220460
|
console.log(export_pc.dim(" GET /flints \u2014 list all registered flints with reachability"));
|
|
220305
|
-
console.log(export_pc.dim(" POST /launch \u2014 { flintName, profile, prompt } \u2192 proxies to vault"));
|
|
220461
|
+
console.log(export_pc.dim(" POST /launch \u2014 { flintId | flintPath | flintName, profile, prompt } \u2192 proxies to vault"));
|
|
220306
220462
|
console.log(export_pc.dim("Ctrl-C to stop."));
|
|
220307
220463
|
});
|
|
220308
220464
|
const shutdown = () => {
|
|
@@ -220412,13 +220568,13 @@ async function copyToClipboard(text) {
|
|
|
220412
220568
|
cmd = process.env.WAYLAND_DISPLAY ? "wl-copy" : "xclip";
|
|
220413
220569
|
if (cmd === "xclip") args = ["-selection", "clipboard"];
|
|
220414
220570
|
}
|
|
220415
|
-
await new Promise((
|
|
220571
|
+
await new Promise((resolve24, reject) => {
|
|
220416
220572
|
const child = spawn12(cmd, args, { stdio: ["pipe", "ignore", "pipe"] });
|
|
220417
220573
|
let stderr = "";
|
|
220418
220574
|
child.stderr.on("data", (chunk) => stderr += chunk.toString());
|
|
220419
220575
|
child.on("error", (err) => reject(new Error(`failed to launch ${cmd}: ${err.message}`)));
|
|
220420
220576
|
child.on("close", (code) => {
|
|
220421
|
-
if (code === 0)
|
|
220577
|
+
if (code === 0) resolve24();
|
|
220422
220578
|
else reject(new Error(`${cmd} exited with code ${code}: ${stderr.trim()}`));
|
|
220423
220579
|
});
|
|
220424
220580
|
child.stdin.end(text, "utf8");
|