@alook/daemon 0.1.45 → 0.1.47
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/cli/index.js +873 -565
- package/dist/index.js +639 -348
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -174,6 +174,18 @@ function resolveLaunchFieldsOrDefault(input) {
|
|
|
174
174
|
// agent-driver/dist/internal/cliLink.js
|
|
175
175
|
import * as fs from "fs";
|
|
176
176
|
import * as path from "path";
|
|
177
|
+
function shellQuote(value) {
|
|
178
|
+
return `'${value.replaceAll("'", "'\\''")}'`;
|
|
179
|
+
}
|
|
180
|
+
function writeWindowsBashEnv(binDir, cliName, envPrefix, previous) {
|
|
181
|
+
const startup = path.join(binDir, `${cliName}.bash-env`).replaceAll("\\", "/");
|
|
182
|
+
const envValue = startup.replace(/[$`]/g, "\\$&");
|
|
183
|
+
const source = previous && previous !== envValue && previous.replaceAll("\\", "/") !== startup ? `. ${shellQuote(previous.replaceAll("\\", "/"))}
|
|
184
|
+
` : "";
|
|
185
|
+
fs.writeFileSync(startup, source + `export ${shellQuote(`${envPrefix}_CLI=${path.join(binDir, cliName).replaceAll("\\", "/")}`)}
|
|
186
|
+
`);
|
|
187
|
+
return envValue;
|
|
188
|
+
}
|
|
177
189
|
function writeCliLink(stateDir, cliName, hostCliPath, platform = process.platform) {
|
|
178
190
|
const binDir = path.join(stateDir, "bin");
|
|
179
191
|
fs.mkdirSync(binDir, { recursive: true });
|
|
@@ -181,10 +193,15 @@ function writeCliLink(stateDir, cliName, hostCliPath, platform = process.platfor
|
|
|
181
193
|
return binDir;
|
|
182
194
|
if (platform === "win32") {
|
|
183
195
|
const cmdFile = path.join(binDir, `${cliName}.cmd`);
|
|
196
|
+
const executable = /\.(?:c|m)?js$/i.test(hostCliPath) ? `"${process.execPath}" "${hostCliPath}"` : `"${hostCliPath}"`;
|
|
184
197
|
const body = `@echo off\r
|
|
185
|
-
|
|
198
|
+
${executable} %*\r
|
|
186
199
|
`;
|
|
187
200
|
fs.writeFileSync(cmdFile, body);
|
|
201
|
+
const bashExecutable = /\.(?:c|m)?js$/i.test(hostCliPath) ? `${shellQuote(process.execPath.replaceAll("\\", "/"))} ${shellQuote(hostCliPath.replaceAll("\\", "/"))}` : shellQuote(hostCliPath.replaceAll("\\", "/"));
|
|
202
|
+
fs.writeFileSync(path.join(binDir, cliName), `#!/bin/sh
|
|
203
|
+
MSYS2_ARG_CONV_EXCL='*' exec ${bashExecutable} "$@"
|
|
204
|
+
`, { mode: 493 });
|
|
188
205
|
return binDir;
|
|
189
206
|
}
|
|
190
207
|
const linkPath = path.join(binDir, cliName);
|
|
@@ -252,7 +269,12 @@ async function prepareCliTransport(ctx, extraEnv = {}, cli = DEFAULT_CLI_CONFIG,
|
|
|
252
269
|
{
|
|
253
270
|
name: "platformProtected",
|
|
254
271
|
precedence: 40,
|
|
255
|
-
vars: {
|
|
272
|
+
vars: {
|
|
273
|
+
...resource.platformProtected,
|
|
274
|
+
...platform === "win32" && hostCliPath ? { [`${cli.envPrefix}_CLI`]: path2.join(binDir, `${cli.cliName}.cmd`).replaceAll("\\", "/") } : {},
|
|
275
|
+
FORCE_COLOR: "0",
|
|
276
|
+
NO_COLOR: "1"
|
|
277
|
+
}
|
|
256
278
|
},
|
|
257
279
|
{ name: "runtimeProtected", precedence: 50, vars: resource.runtimeProtected },
|
|
258
280
|
{
|
|
@@ -269,15 +291,143 @@ async function prepareCliTransport(ctx, extraEnv = {}, cli = DEFAULT_CLI_CONFIG,
|
|
|
269
291
|
}
|
|
270
292
|
];
|
|
271
293
|
const { env: spawnEnv } = mergeEnvLayers(resource.base, layers);
|
|
294
|
+
if (platform === "win32" && hostCliPath) {
|
|
295
|
+
spawnEnv.BASH_ENV = writeWindowsBashEnv(binDir, cli.cliName, cli.envPrefix, spawnEnv.BASH_ENV);
|
|
296
|
+
}
|
|
272
297
|
const tokenFile = String(resource.credentialSensitive.ALOOK_PROXY_TOKEN_FILE ?? "");
|
|
273
298
|
return { stateDir, tokenFile, spawnEnv };
|
|
274
299
|
}
|
|
275
300
|
|
|
276
301
|
// agent-driver/dist/internal/killTree.js
|
|
277
|
-
import { execFileSync, spawn } from "child_process";
|
|
302
|
+
import { execFileSync as execFileSync2, spawn } from "child_process";
|
|
278
303
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
279
304
|
import { createServer } from "node:net";
|
|
280
305
|
import { PassThrough } from "node:stream";
|
|
306
|
+
|
|
307
|
+
// agent-driver/dist/internal/probe.js
|
|
308
|
+
import { execFileSync } from "child_process";
|
|
309
|
+
import * as fs3 from "fs";
|
|
310
|
+
import * as path3 from "path";
|
|
311
|
+
import { homedir } from "os";
|
|
312
|
+
var PROBE_TIMEOUT_MS = 5000;
|
|
313
|
+
var PROBE_OUTPUT_MAX_BYTES = 1024 * 1024;
|
|
314
|
+
function resolveCommandOnPath(command, deps = {}) {
|
|
315
|
+
if (deps.which)
|
|
316
|
+
return deps.which(command);
|
|
317
|
+
try {
|
|
318
|
+
if (process.platform === "win32") {
|
|
319
|
+
const out2 = execFileSync("where", [command], { encoding: "utf8", timeout: PROBE_TIMEOUT_MS });
|
|
320
|
+
const first = out2.split(/\r?\n/).map((line) => line.trim()).find((line) => /\.(exe|com|cmd|bat)$/i.test(line));
|
|
321
|
+
return first || null;
|
|
322
|
+
}
|
|
323
|
+
const out = execFileSync("which", [command], { encoding: "utf8", timeout: PROBE_TIMEOUT_MS });
|
|
324
|
+
return out.trim() || null;
|
|
325
|
+
} catch {
|
|
326
|
+
return null;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
function firstExistingPath(candidates) {
|
|
330
|
+
for (const c of candidates) {
|
|
331
|
+
if (c && fs3.existsSync(c))
|
|
332
|
+
return c;
|
|
333
|
+
}
|
|
334
|
+
return null;
|
|
335
|
+
}
|
|
336
|
+
function looksLikeVersion(line) {
|
|
337
|
+
return /\d+\.\d+/.test(line);
|
|
338
|
+
}
|
|
339
|
+
function needsWindowsShimShell(command, platform) {
|
|
340
|
+
return platform === "win32" && /\.(cmd|bat)$/i.test(command);
|
|
341
|
+
}
|
|
342
|
+
function quoteWindowsShimCommand(command, platform = process.platform) {
|
|
343
|
+
return needsWindowsShimShell(command, platform) && /\s/.test(command) ? `"${command}"` : command;
|
|
344
|
+
}
|
|
345
|
+
function probeCommandVersion(command, args = [], deps = {}, platform = process.platform) {
|
|
346
|
+
try {
|
|
347
|
+
const shell = needsWindowsShimShell(command, platform);
|
|
348
|
+
const out = execFileSync(quoteWindowsShimCommand(command, platform), [...args, "--version"], {
|
|
349
|
+
encoding: "utf8",
|
|
350
|
+
timeout: PROBE_TIMEOUT_MS,
|
|
351
|
+
shell,
|
|
352
|
+
input: "",
|
|
353
|
+
env: { ...process.env, CI: "1" }
|
|
354
|
+
});
|
|
355
|
+
const line = out.split(`
|
|
356
|
+
`)[0]?.trim();
|
|
357
|
+
if (!line)
|
|
358
|
+
return { ok: false, error: "empty_version_output" };
|
|
359
|
+
if (!looksLikeVersion(line))
|
|
360
|
+
return { ok: false, error: "invalid_version_output" };
|
|
361
|
+
return { ok: true, version: line };
|
|
362
|
+
} catch (err) {
|
|
363
|
+
const code = err?.code ?? err?.code ?? "version_probe_failed";
|
|
364
|
+
return { ok: false, error: String(code) };
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
function probeCommandOutput(command, args, platform = process.platform) {
|
|
368
|
+
try {
|
|
369
|
+
const output = execFileSync(quoteWindowsShimCommand(command, platform), args, {
|
|
370
|
+
encoding: "utf8",
|
|
371
|
+
timeout: PROBE_TIMEOUT_MS,
|
|
372
|
+
maxBuffer: PROBE_OUTPUT_MAX_BYTES,
|
|
373
|
+
shell: needsWindowsShimShell(command, platform),
|
|
374
|
+
stdio: ["pipe", "pipe", "ignore"],
|
|
375
|
+
input: "",
|
|
376
|
+
env: { ...process.env, CI: "1" }
|
|
377
|
+
});
|
|
378
|
+
return { ok: true, output };
|
|
379
|
+
} catch (err) {
|
|
380
|
+
const code = err?.code ?? "command_probe_failed";
|
|
381
|
+
return { ok: false, error: String(code) };
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
function resolveHomePath(relativePath, deps = {}) {
|
|
385
|
+
return path3.join(deps.homeDir || process.env.HOME || ".", relativePath);
|
|
386
|
+
}
|
|
387
|
+
function resolveSpawnSpec(command, args, override, deps = {}, platform = process.platform) {
|
|
388
|
+
const trimmed = override?.trim();
|
|
389
|
+
const target = trimmed && trimmed.length > 0 ? trimmed : command;
|
|
390
|
+
const looksLikePath = trimmed !== undefined && trimmed.length > 0 && /[\\/]/.test(trimmed);
|
|
391
|
+
const resolved = looksLikePath ? target : resolveCommandOnPath(target, deps) ?? target;
|
|
392
|
+
return { command: resolved, args, shell: needsWindowsShimShell(resolved, platform) };
|
|
393
|
+
}
|
|
394
|
+
function resolveClaudeCommand(deps = {}) {
|
|
395
|
+
const onPath = resolveCommandOnPath("claude", deps);
|
|
396
|
+
if (onPath)
|
|
397
|
+
return onPath;
|
|
398
|
+
if (process.platform === "win32") {
|
|
399
|
+
const home = deps.homeDir || process.env.USERPROFILE || process.env.HOME || homedir();
|
|
400
|
+
return firstExistingPath([path3.join(home, ".local", "bin", "claude.exe")]);
|
|
401
|
+
}
|
|
402
|
+
if (process.platform === "darwin") {
|
|
403
|
+
return firstExistingPath([
|
|
404
|
+
resolveHomePath("Applications/Claude Code URL Handler.app/Contents/MacOS/claude", deps),
|
|
405
|
+
"/Applications/Claude Code URL Handler.app/Contents/MacOS/claude"
|
|
406
|
+
]);
|
|
407
|
+
}
|
|
408
|
+
return null;
|
|
409
|
+
}
|
|
410
|
+
function probeClaude(deps = {}) {
|
|
411
|
+
const command = resolveClaudeCommand(deps);
|
|
412
|
+
if (!command)
|
|
413
|
+
return { status: "unhealthy", lastError: "not_on_path" };
|
|
414
|
+
const r = probeCommandVersion(command, [], deps);
|
|
415
|
+
if (!r.ok)
|
|
416
|
+
return { status: "unhealthy", lastError: r.error };
|
|
417
|
+
return { status: "healthy", version: r.version };
|
|
418
|
+
}
|
|
419
|
+
function probeCliRuntime(binary, deps = {}, override) {
|
|
420
|
+
const explicit = override?.trim();
|
|
421
|
+
const command = explicit || resolveCommandOnPath(binary, deps);
|
|
422
|
+
if (!command)
|
|
423
|
+
return { status: "unhealthy", lastError: "not_on_path" };
|
|
424
|
+
const r = probeCommandVersion(command, [], deps);
|
|
425
|
+
if (!r.ok)
|
|
426
|
+
return { status: "unhealthy", lastError: r.error };
|
|
427
|
+
return { status: "healthy", version: r.version };
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
// agent-driver/dist/internal/killTree.js
|
|
281
431
|
var POLL_MS = 100;
|
|
282
432
|
var FORCE_EXIT_WAIT_MS = 2000;
|
|
283
433
|
var TASKKILL_WAIT_MS = 2000;
|
|
@@ -627,7 +777,7 @@ function spawnAgentProcess(command, args, opts) {
|
|
|
627
777
|
const env = {
|
|
628
778
|
...opts.env,
|
|
629
779
|
[WINDOWS_JOB_NODE_ENV]: process.execPath,
|
|
630
|
-
[WINDOWS_JOB_PAYLOAD_ENV]: Buffer.from(JSON.stringify({ command, args, cwd: opts.cwd, shell: opts.shell ?? false })).toString("base64"),
|
|
780
|
+
[WINDOWS_JOB_PAYLOAD_ENV]: Buffer.from(JSON.stringify({ command: opts.shell ? quoteWindowsShimCommand(command) : command, args, cwd: opts.cwd, shell: opts.shell ?? false })).toString("base64"),
|
|
631
781
|
[WINDOWS_JOB_RUNNER_ENV]: WINDOWS_JOB_RUNNER,
|
|
632
782
|
...stdinPipe ? { [WINDOWS_JOB_STDIN_PIPE_ENV]: stdinPipe } : {}
|
|
633
783
|
};
|
|
@@ -689,7 +839,7 @@ function capturePosixTreeTargets(rootPid, rootOwnsProcessGroup) {
|
|
|
689
839
|
});
|
|
690
840
|
let output;
|
|
691
841
|
try {
|
|
692
|
-
output =
|
|
842
|
+
output = execFileSync2("ps", ["-axo", "pid=,ppid=,pgid="], {
|
|
693
843
|
encoding: "utf8",
|
|
694
844
|
timeout: POSIX_TREE_CAPTURE_TIMEOUT_MS,
|
|
695
845
|
maxBuffer: POSIX_TREE_CAPTURE_MAX_BUFFER
|
|
@@ -753,6 +903,9 @@ function signalPosixTargets(targets, signal) {
|
|
|
753
903
|
} catch {}
|
|
754
904
|
}
|
|
755
905
|
}
|
|
906
|
+
|
|
907
|
+
class WindowsTreeExitError extends Error {
|
|
908
|
+
}
|
|
756
909
|
function taskkillTree(pid) {
|
|
757
910
|
return new Promise((resolve, reject) => {
|
|
758
911
|
const killer = spawn("taskkill.exe", ["/pid", String(pid), "/t", "/f"], {
|
|
@@ -783,17 +936,24 @@ function taskkillTree(pid) {
|
|
|
783
936
|
settle("resolve");
|
|
784
937
|
return;
|
|
785
938
|
}
|
|
786
|
-
settle("reject", new
|
|
939
|
+
settle("reject", new WindowsTreeExitError(`Windows process-tree termination failed (exit=${String(code)}, signal=${String(signal)})`));
|
|
787
940
|
});
|
|
788
941
|
});
|
|
789
942
|
}
|
|
790
943
|
async function killWindowsProcessTree(pid) {
|
|
791
944
|
if (!isAlive(pid))
|
|
792
945
|
return;
|
|
793
|
-
|
|
946
|
+
let terminationError;
|
|
947
|
+
try {
|
|
948
|
+
await taskkillTree(pid);
|
|
949
|
+
} catch (error) {
|
|
950
|
+
if (!(error instanceof WindowsTreeExitError))
|
|
951
|
+
throw error;
|
|
952
|
+
terminationError = error;
|
|
953
|
+
}
|
|
794
954
|
await waitForProcessExit(pid, FORCE_EXIT_WAIT_MS);
|
|
795
955
|
if (isAlive(pid))
|
|
796
|
-
throw new Error(`Windows process tree ${pid} remained alive after taskkill completed`);
|
|
956
|
+
throw terminationError ?? new Error(`Windows process tree ${pid} remained alive after taskkill completed`);
|
|
797
957
|
}
|
|
798
958
|
async function waitForProcessExit(pid, timeoutMs) {
|
|
799
959
|
const deadline = Date.now() + timeoutMs;
|
|
@@ -836,8 +996,8 @@ async function killProcessTree(pid, opts) {
|
|
|
836
996
|
|
|
837
997
|
// agent-driver/dist/adapters/antigravity/usage.js
|
|
838
998
|
import { createHash } from "node:crypto";
|
|
839
|
-
import { homedir } from "node:os";
|
|
840
|
-
import { resolve, join as
|
|
999
|
+
import { homedir as homedir2 } from "node:os";
|
|
1000
|
+
import { resolve, join as join4 } from "node:path";
|
|
841
1001
|
|
|
842
1002
|
// agent-driver/dist/adapters/antigravity/local-data.js
|
|
843
1003
|
async function readLocalCommand(command, args, limit = 256 * 1024) {
|
|
@@ -935,7 +1095,7 @@ function parseNativeGeneration(data) {
|
|
|
935
1095
|
return { usage: { input: count(usage, 2), output: count(usage, 3), cache: count(usage, 5) }, occurredAt };
|
|
936
1096
|
}
|
|
937
1097
|
function nativeUsageHome(env, cwd) {
|
|
938
|
-
return resolve(cwd, env.GEMINI_HOME?.replace(/^~(?=[/\\]|$)/,
|
|
1098
|
+
return resolve(cwd, env.GEMINI_HOME?.replace(/^~(?=[/\\]|$)/, homedir2()) || join4(homedir2(), ".gemini"));
|
|
939
1099
|
}
|
|
940
1100
|
var QUERY = "WITH pending AS (SELECT idx,data FROM gen_metadata WHERE idx>? ORDER BY idx LIMIT 128), batch AS (SELECT idx,data,sum(length(data)) OVER (ORDER BY idx) AS bytes FROM pending) SELECT idx,hex(substr(data,1,4194305)) AS data,(SELECT COUNT(*) FROM steps WHERE has_subtrajectory=1) AS has_children FROM batch WHERE bytes<=4194304 OR idx=(SELECT min(idx) FROM batch) ORDER BY idx";
|
|
941
1101
|
|
|
@@ -953,12 +1113,12 @@ class NativeUsageReader {
|
|
|
953
1113
|
throw new Error("Invalid native usage session identity");
|
|
954
1114
|
}
|
|
955
1115
|
async read() {
|
|
956
|
-
const
|
|
1116
|
+
const path4 = join4(this.home, "antigravity-acp", "conversations", `${this.sessionId}.db`);
|
|
957
1117
|
let cursor = this.cursor;
|
|
958
1118
|
let complete = false;
|
|
959
1119
|
const result = [];
|
|
960
1120
|
for (let batch = 0;batch < 16; batch++) {
|
|
961
|
-
const rows = await this.readRows(
|
|
1121
|
+
const rows = await this.readRows(path4, cursor);
|
|
962
1122
|
for (const row of rows) {
|
|
963
1123
|
if (!Number.isSafeInteger(row.idx) || row.idx <= cursor || !/^(?:[a-f0-9]{2})*$/i.test(row.data) || row.data.length > 8 * 1024 * 1024)
|
|
964
1124
|
throw new Error("Invalid native usage row");
|
|
@@ -979,11 +1139,11 @@ class NativeUsageReader {
|
|
|
979
1139
|
return { samples: result, complete, ...this.childTrajectories ? { incompleteScope: true } : {} };
|
|
980
1140
|
}
|
|
981
1141
|
}
|
|
982
|
-
async function queryNativeRowsWithCli(
|
|
983
|
-
const output = await readLocalCommand("sqlite3", ["-readonly", "-json",
|
|
1142
|
+
async function queryNativeRowsWithCli(path4, cursor) {
|
|
1143
|
+
const output = await readLocalCommand("sqlite3", ["-readonly", "-json", path4, QUERY.replace("idx>?", `idx>${cursor}`)], 16 * 1024 * 1024);
|
|
984
1144
|
return output.trim() ? JSON.parse(output) : [];
|
|
985
1145
|
}
|
|
986
|
-
async function queryNativeRows(
|
|
1146
|
+
async function queryNativeRows(path4, cursor, loadSqlite = async () => {
|
|
987
1147
|
const module = "node:sqlite";
|
|
988
1148
|
return await import(module);
|
|
989
1149
|
}) {
|
|
@@ -991,9 +1151,9 @@ async function queryNativeRows(path3, cursor, loadSqlite = async () => {
|
|
|
991
1151
|
try {
|
|
992
1152
|
sqlite = await loadSqlite();
|
|
993
1153
|
} catch {
|
|
994
|
-
return queryNativeRowsWithCli(
|
|
1154
|
+
return queryNativeRowsWithCli(path4, cursor);
|
|
995
1155
|
}
|
|
996
|
-
const db = new sqlite.DatabaseSync(
|
|
1156
|
+
const db = new sqlite.DatabaseSync(path4, { readOnly: true });
|
|
997
1157
|
try {
|
|
998
1158
|
return db.prepare(QUERY).all(cursor);
|
|
999
1159
|
} finally {
|
|
@@ -1002,7 +1162,7 @@ async function queryNativeRows(path3, cursor, loadSqlite = async () => {
|
|
|
1002
1162
|
}
|
|
1003
1163
|
|
|
1004
1164
|
// agent-driver/dist/internal/modelCatalog.js
|
|
1005
|
-
var RUNTIME_MODEL_CATALOG_MAX =
|
|
1165
|
+
var RUNTIME_MODEL_CATALOG_MAX = 1024;
|
|
1006
1166
|
var RUNTIME_MODEL_ID_MAX = 100;
|
|
1007
1167
|
function normalizeRuntimeModelId(value) {
|
|
1008
1168
|
if (typeof value !== "string")
|
|
@@ -1020,7 +1180,7 @@ function catalogFromIds(ids) {
|
|
|
1020
1180
|
if (!id || seen.has(id))
|
|
1021
1181
|
continue;
|
|
1022
1182
|
if (models.length >= RUNTIME_MODEL_CATALOG_MAX)
|
|
1023
|
-
|
|
1183
|
+
break;
|
|
1024
1184
|
seen.add(id);
|
|
1025
1185
|
models.push({ id, supportedReasoningEfforts: [] });
|
|
1026
1186
|
}
|
|
@@ -1070,26 +1230,28 @@ function tryParseJsonRecord(line) {
|
|
|
1070
1230
|
|
|
1071
1231
|
// agent-driver/dist/adapters/antigravity/catalog.js
|
|
1072
1232
|
function choices(value) {
|
|
1073
|
-
if (!Array.isArray(value)
|
|
1233
|
+
if (!Array.isArray(value))
|
|
1074
1234
|
return [];
|
|
1075
1235
|
const rows = [];
|
|
1236
|
+
const seen = new Set;
|
|
1076
1237
|
for (const item of value) {
|
|
1077
1238
|
const row = asRecord(item);
|
|
1078
1239
|
if (!row)
|
|
1079
1240
|
continue;
|
|
1080
1241
|
const nested2 = Array.isArray(row.options) ? row.options : [row];
|
|
1081
|
-
if (nested2.length + rows.length > RUNTIME_MODEL_CATALOG_MAX)
|
|
1082
|
-
return [];
|
|
1083
1242
|
for (const child of nested2) {
|
|
1084
1243
|
const option = asRecord(child);
|
|
1085
1244
|
const id = normalizeRuntimeModelId(option?.value ?? option?.modelId);
|
|
1086
|
-
if (!id)
|
|
1245
|
+
if (!id || seen.has(id))
|
|
1087
1246
|
continue;
|
|
1247
|
+
seen.add(id);
|
|
1088
1248
|
const name = option?.name;
|
|
1089
1249
|
rows.push({ id, ...typeof name === "string" && name.length <= 256 ? { displayName: name } : {} });
|
|
1250
|
+
if (rows.length >= RUNTIME_MODEL_CATALOG_MAX)
|
|
1251
|
+
return rows;
|
|
1090
1252
|
}
|
|
1091
1253
|
}
|
|
1092
|
-
return rows
|
|
1254
|
+
return rows;
|
|
1093
1255
|
}
|
|
1094
1256
|
function parseAntigravityCatalog(value) {
|
|
1095
1257
|
const session = asRecord(value);
|
|
@@ -1879,132 +2041,15 @@ class AntigravityAcpLane {
|
|
|
1879
2041
|
// agent-driver/dist/adapters/antigravity/probe.js
|
|
1880
2042
|
import { createHash as createHash2, randomUUID as randomUUID4 } from "node:crypto";
|
|
1881
2043
|
import { mkdirSync as mkdirSync2, readFileSync, renameSync, writeFileSync as writeFileSync2 } from "node:fs";
|
|
1882
|
-
import { homedir as
|
|
2044
|
+
import { homedir as homedir3 } from "node:os";
|
|
1883
2045
|
import { join as join5 } from "node:path";
|
|
1884
|
-
|
|
1885
|
-
// agent-driver/dist/internal/probe.js
|
|
1886
|
-
import { execFileSync as execFileSync2 } from "child_process";
|
|
1887
|
-
import * as fs3 from "fs";
|
|
1888
|
-
import * as path3 from "path";
|
|
1889
|
-
var PROBE_TIMEOUT_MS = 5000;
|
|
1890
|
-
var PROBE_OUTPUT_MAX_BYTES = 1024 * 1024;
|
|
1891
|
-
function resolveCommandOnPath(command, deps = {}) {
|
|
1892
|
-
if (deps.which)
|
|
1893
|
-
return deps.which(command);
|
|
1894
|
-
try {
|
|
1895
|
-
if (process.platform === "win32") {
|
|
1896
|
-
const out2 = execFileSync2("where", [command], { encoding: "utf8", timeout: PROBE_TIMEOUT_MS });
|
|
1897
|
-
const first = out2.split(/\r?\n/).find((line) => line.trim().length > 0);
|
|
1898
|
-
return first?.trim() || null;
|
|
1899
|
-
}
|
|
1900
|
-
const out = execFileSync2("which", [command], { encoding: "utf8", timeout: PROBE_TIMEOUT_MS });
|
|
1901
|
-
return out.trim() || null;
|
|
1902
|
-
} catch {
|
|
1903
|
-
return null;
|
|
1904
|
-
}
|
|
1905
|
-
}
|
|
1906
|
-
function firstExistingPath(candidates) {
|
|
1907
|
-
for (const c of candidates) {
|
|
1908
|
-
if (c && fs3.existsSync(c))
|
|
1909
|
-
return c;
|
|
1910
|
-
}
|
|
1911
|
-
return null;
|
|
1912
|
-
}
|
|
1913
|
-
function looksLikeVersion(line) {
|
|
1914
|
-
return /\d+\.\d+/.test(line);
|
|
1915
|
-
}
|
|
1916
|
-
function needsWindowsShimShell(command, platform) {
|
|
1917
|
-
return platform === "win32" && /\.(cmd|bat)$/i.test(command);
|
|
1918
|
-
}
|
|
1919
|
-
function probeCommandVersion(command, args = [], deps = {}, platform = process.platform) {
|
|
1920
|
-
try {
|
|
1921
|
-
const shell = needsWindowsShimShell(command, platform);
|
|
1922
|
-
const out = execFileSync2(command, [...args, "--version"], {
|
|
1923
|
-
encoding: "utf8",
|
|
1924
|
-
timeout: PROBE_TIMEOUT_MS,
|
|
1925
|
-
shell,
|
|
1926
|
-
input: "",
|
|
1927
|
-
env: { ...process.env, CI: "1" }
|
|
1928
|
-
});
|
|
1929
|
-
const line = out.split(`
|
|
1930
|
-
`)[0]?.trim();
|
|
1931
|
-
if (!line)
|
|
1932
|
-
return { ok: false, error: "empty_version_output" };
|
|
1933
|
-
if (!looksLikeVersion(line))
|
|
1934
|
-
return { ok: false, error: "invalid_version_output" };
|
|
1935
|
-
return { ok: true, version: line };
|
|
1936
|
-
} catch (err) {
|
|
1937
|
-
const code = err?.code ?? err?.code ?? "version_probe_failed";
|
|
1938
|
-
return { ok: false, error: String(code) };
|
|
1939
|
-
}
|
|
1940
|
-
}
|
|
1941
|
-
function probeCommandOutput(command, args, platform = process.platform) {
|
|
1942
|
-
try {
|
|
1943
|
-
const output = execFileSync2(command, args, {
|
|
1944
|
-
encoding: "utf8",
|
|
1945
|
-
timeout: PROBE_TIMEOUT_MS,
|
|
1946
|
-
maxBuffer: PROBE_OUTPUT_MAX_BYTES,
|
|
1947
|
-
shell: needsWindowsShimShell(command, platform),
|
|
1948
|
-
stdio: ["pipe", "pipe", "ignore"],
|
|
1949
|
-
input: "",
|
|
1950
|
-
env: { ...process.env, CI: "1" }
|
|
1951
|
-
});
|
|
1952
|
-
return { ok: true, output };
|
|
1953
|
-
} catch (err) {
|
|
1954
|
-
const code = err?.code ?? "command_probe_failed";
|
|
1955
|
-
return { ok: false, error: String(code) };
|
|
1956
|
-
}
|
|
1957
|
-
}
|
|
1958
|
-
function resolveHomePath(relativePath, deps = {}) {
|
|
1959
|
-
return path3.join(deps.homeDir || process.env.HOME || ".", relativePath);
|
|
1960
|
-
}
|
|
1961
|
-
function resolveSpawnSpec(command, args, override, deps = {}, platform = process.platform) {
|
|
1962
|
-
const trimmed = override?.trim();
|
|
1963
|
-
const target = trimmed && trimmed.length > 0 ? trimmed : command;
|
|
1964
|
-
const looksLikePath = trimmed !== undefined && trimmed.length > 0 && /[\\/]/.test(trimmed);
|
|
1965
|
-
const resolved = looksLikePath ? target : resolveCommandOnPath(target, deps) ?? target;
|
|
1966
|
-
return { command: resolved, args, shell: needsWindowsShimShell(resolved, platform) };
|
|
1967
|
-
}
|
|
1968
|
-
function resolveClaudeCommand(deps = {}) {
|
|
1969
|
-
const onPath = resolveCommandOnPath("claude", deps);
|
|
1970
|
-
if (onPath)
|
|
1971
|
-
return onPath;
|
|
1972
|
-
if (process.platform === "darwin") {
|
|
1973
|
-
return firstExistingPath([
|
|
1974
|
-
resolveHomePath("Applications/Claude Code URL Handler.app/Contents/MacOS/claude", deps),
|
|
1975
|
-
"/Applications/Claude Code URL Handler.app/Contents/MacOS/claude"
|
|
1976
|
-
]);
|
|
1977
|
-
}
|
|
1978
|
-
return null;
|
|
1979
|
-
}
|
|
1980
|
-
function probeClaude(deps = {}) {
|
|
1981
|
-
const command = resolveClaudeCommand(deps);
|
|
1982
|
-
if (!command)
|
|
1983
|
-
return { status: "unhealthy", lastError: "not_on_path" };
|
|
1984
|
-
const r = probeCommandVersion(command, [], deps);
|
|
1985
|
-
if (!r.ok)
|
|
1986
|
-
return { status: "unhealthy", lastError: r.error };
|
|
1987
|
-
return { status: "healthy", version: r.version };
|
|
1988
|
-
}
|
|
1989
|
-
function probeCliRuntime(binary, deps = {}, override) {
|
|
1990
|
-
const explicit = override?.trim();
|
|
1991
|
-
const command = explicit || resolveCommandOnPath(binary, deps);
|
|
1992
|
-
if (!command)
|
|
1993
|
-
return { status: "unhealthy", lastError: "not_on_path" };
|
|
1994
|
-
const r = probeCommandVersion(command, [], deps);
|
|
1995
|
-
if (!r.ok)
|
|
1996
|
-
return { status: "unhealthy", lastError: r.error };
|
|
1997
|
-
return { status: "healthy", version: r.version };
|
|
1998
|
-
}
|
|
1999
|
-
|
|
2000
|
-
// agent-driver/dist/adapters/antigravity/probe.js
|
|
2001
2046
|
function antigravitySpawnSpec(command, platform = process.platform) {
|
|
2002
2047
|
return resolveSpawnSpec(platform === "win32" ? "agy_acp_server.exe" : "agy_acp_server.par", platform === "linux" ? ["--uid="] : [], command);
|
|
2003
2048
|
}
|
|
2004
2049
|
async function probeAntigravity(command, options = {}) {
|
|
2005
2050
|
const spec = antigravitySpawnSpec(command);
|
|
2006
2051
|
const identity = createHash2("sha256").update(JSON.stringify([spec.command, process.env.GEMINI_HOME ?? ""])).digest("hex").slice(0, 16);
|
|
2007
|
-
const directory = options.cacheDirectory ?? join5(
|
|
2052
|
+
const directory = options.cacheDirectory ?? join5(homedir3(), ".cache", "alook", "antigravity-probe", identity);
|
|
2008
2053
|
const cacheFile = join5(directory, "session");
|
|
2009
2054
|
let cachedSessionId;
|
|
2010
2055
|
try {
|
|
@@ -2051,7 +2096,7 @@ async function probeAntigravity(command, options = {}) {
|
|
|
2051
2096
|
cleanup(proc).then(() => resolve2(result), () => resolve2({ status: "unhealthy", lastError: "antigravity_acp_cleanup_failed" }));
|
|
2052
2097
|
};
|
|
2053
2098
|
const fail = (lastError) => finish({ status: "unhealthy", lastError });
|
|
2054
|
-
const timer = setTimeout(() => fail("antigravity_acp_timeout"), options.timeoutMs ?? 1e4);
|
|
2099
|
+
const timer = setTimeout(() => fail("antigravity_acp_timeout"), options.timeoutMs ?? (process.platform === "win32" ? 30000 : 1e4));
|
|
2055
2100
|
const write = (value) => {
|
|
2056
2101
|
try {
|
|
2057
2102
|
if (!proc.stdin || proc.stdin.destroyed || proc.stdin.writableEnded || proc.stdin.writable === false) {
|
|
@@ -2956,7 +3001,7 @@ class ClaudeTurnProtocol {
|
|
|
2956
3001
|
|
|
2957
3002
|
// agent-driver/dist/adapters/claude/recent-context.js
|
|
2958
3003
|
import { createReadStream as createReadStream2 } from "node:fs";
|
|
2959
|
-
import { homedir as
|
|
3004
|
+
import { homedir as homedir4 } from "node:os";
|
|
2960
3005
|
import path6 from "node:path";
|
|
2961
3006
|
import { createInterface } from "node:readline";
|
|
2962
3007
|
|
|
@@ -3165,7 +3210,7 @@ async function discoverClaudeRecentContext(request, dependencies = {}) {
|
|
|
3165
3210
|
const collector = new RecentContextCollector(request, "supported");
|
|
3166
3211
|
if (collector.satisfied)
|
|
3167
3212
|
return collector.result();
|
|
3168
|
-
const projectsRoot = path6.resolve(dependencies.projectsRoot ?? path6.join(process.env.CLAUDE_CONFIG_DIR || path6.join(
|
|
3213
|
+
const projectsRoot = path6.resolve(dependencies.projectsRoot ?? path6.join(process.env.CLAUDE_CONFIG_DIR || path6.join(homedir4(), ".claude"), "projects"));
|
|
3169
3214
|
const readProjectPath = dependencies.readProjectPath ?? readClaudeProjectPath;
|
|
3170
3215
|
const candidates = await collectJsonlFileCandidates(projectsRoot, {
|
|
3171
3216
|
includeRootFiles: false,
|
|
@@ -4040,7 +4085,6 @@ class CodexDriver {
|
|
|
4040
4085
|
let listId = 0;
|
|
4041
4086
|
const models = [];
|
|
4042
4087
|
const seenModels = new Set;
|
|
4043
|
-
let overflow = false;
|
|
4044
4088
|
let defaultModelId;
|
|
4045
4089
|
const finish = (catalog) => {
|
|
4046
4090
|
if (settled)
|
|
@@ -4064,10 +4108,6 @@ class CodexDriver {
|
|
|
4064
4108
|
const id = normalizeRuntimeModelId(model.id);
|
|
4065
4109
|
if (!id || seenModels.has(id))
|
|
4066
4110
|
return;
|
|
4067
|
-
if (models.length >= MODEL_LIST_MAX) {
|
|
4068
|
-
overflow = true;
|
|
4069
|
-
return;
|
|
4070
|
-
}
|
|
4071
4111
|
const rawOptions = Array.isArray(model.supportedReasoningEfforts) ? model.supportedReasoningEfforts : [];
|
|
4072
4112
|
const seenEfforts = new Set;
|
|
4073
4113
|
const supportedReasoningEfforts = rawOptions.flatMap((raw) => {
|
|
@@ -4109,14 +4149,13 @@ class CodexDriver {
|
|
|
4109
4149
|
if (message.error || !message.result || typeof message.result !== "object")
|
|
4110
4150
|
return finish();
|
|
4111
4151
|
const result = message.result;
|
|
4112
|
-
for (const model of Array.isArray(result.data) ? result.data : [])
|
|
4152
|
+
for (const model of Array.isArray(result.data) ? result.data : []) {
|
|
4113
4153
|
consumeModel(model);
|
|
4114
|
-
|
|
4115
|
-
|
|
4154
|
+
if (models.length >= MODEL_LIST_MAX)
|
|
4155
|
+
break;
|
|
4156
|
+
}
|
|
4116
4157
|
const cursor = typeof result.nextCursor === "string" ? result.nextCursor : undefined;
|
|
4117
|
-
if (cursor && models.length
|
|
4118
|
-
return finish();
|
|
4119
|
-
if (cursor)
|
|
4158
|
+
if (cursor && models.length < MODEL_LIST_MAX)
|
|
4120
4159
|
return requestModelPage(cursor);
|
|
4121
4160
|
if (models.length === 0)
|
|
4122
4161
|
return finish();
|
|
@@ -4398,7 +4437,7 @@ function parseCursorAcpModelCatalog(session) {
|
|
|
4398
4437
|
if (option.value === "default[]" || seen.has(option.value))
|
|
4399
4438
|
continue;
|
|
4400
4439
|
if (models.length >= RUNTIME_MODEL_CATALOG_MAX)
|
|
4401
|
-
|
|
4440
|
+
break;
|
|
4402
4441
|
seen.add(option.value);
|
|
4403
4442
|
models.push({
|
|
4404
4443
|
id: option.value,
|
|
@@ -5457,7 +5496,7 @@ function parseGrokModelCatalog(value) {
|
|
|
5457
5496
|
if (!model || !id || seen.has(id))
|
|
5458
5497
|
continue;
|
|
5459
5498
|
if (models.length >= RUNTIME_MODEL_CATALOG_MAX)
|
|
5460
|
-
|
|
5499
|
+
break;
|
|
5461
5500
|
seen.add(id);
|
|
5462
5501
|
const displayName = boundedText(model.name, MODEL_DISPLAY_NAME_MAX2);
|
|
5463
5502
|
models.push({ id, ...displayName ? { displayName } : {}, ...reasoningCatalog(model) });
|
|
@@ -6616,7 +6655,6 @@ import { randomBytes as randomBytes4 } from "node:crypto";
|
|
|
6616
6655
|
import { randomBytes as randomBytes3 } from "node:crypto";
|
|
6617
6656
|
import { EventEmitter as EventEmitter5 } from "node:events";
|
|
6618
6657
|
import { createServer as createServer2 } from "node:net";
|
|
6619
|
-
var SUPPORTED_VERSION = "1.17.20";
|
|
6620
6658
|
var HOST = "127.0.0.1";
|
|
6621
6659
|
var START_TIMEOUT_MS = 15000;
|
|
6622
6660
|
var REQUEST_TIMEOUT_MS = 15000;
|
|
@@ -7034,8 +7072,8 @@ class OpenCodeServiceLane {
|
|
|
7034
7072
|
const { response, body } = await this.fetchJsonWithTimeout("/global/health", { method: "GET" }, "health", healthTimeoutMs);
|
|
7035
7073
|
if (response.ok) {
|
|
7036
7074
|
const health = record4(body);
|
|
7037
|
-
if (health?.healthy !== true
|
|
7038
|
-
throw new OpenCodeIncompatibleError(
|
|
7075
|
+
if (health?.healthy !== true) {
|
|
7076
|
+
throw new OpenCodeIncompatibleError("Installed OpenCode service did not report healthy status");
|
|
7039
7077
|
}
|
|
7040
7078
|
await this.verifyOpenApi();
|
|
7041
7079
|
return;
|
|
@@ -7769,6 +7807,59 @@ class OpenCodeServiceLane {
|
|
|
7769
7807
|
}
|
|
7770
7808
|
}
|
|
7771
7809
|
|
|
7810
|
+
// agent-driver/dist/adapters/opencode/legacy-auth.js
|
|
7811
|
+
import { open } from "node:fs/promises";
|
|
7812
|
+
import { homedir as homedir6 } from "node:os";
|
|
7813
|
+
import path9 from "node:path";
|
|
7814
|
+
function record5(value) {
|
|
7815
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : undefined;
|
|
7816
|
+
}
|
|
7817
|
+
function parse(value) {
|
|
7818
|
+
try {
|
|
7819
|
+
return record5(JSON.parse(value));
|
|
7820
|
+
} catch {
|
|
7821
|
+
return;
|
|
7822
|
+
}
|
|
7823
|
+
}
|
|
7824
|
+
async function readJson(filename, maxBytes) {
|
|
7825
|
+
try {
|
|
7826
|
+
const file = await open(filename, "r");
|
|
7827
|
+
try {
|
|
7828
|
+
if ((await file.stat()).size > maxBytes)
|
|
7829
|
+
return;
|
|
7830
|
+
return parse(await file.readFile("utf8"));
|
|
7831
|
+
} finally {
|
|
7832
|
+
await file.close();
|
|
7833
|
+
}
|
|
7834
|
+
} catch {
|
|
7835
|
+
return;
|
|
7836
|
+
}
|
|
7837
|
+
}
|
|
7838
|
+
function xdgRoot(value, fallback) {
|
|
7839
|
+
return value && path9.isAbsolute(value) ? value : fallback;
|
|
7840
|
+
}
|
|
7841
|
+
async function legacyOpenCodeApiEnvironment(environment, model) {
|
|
7842
|
+
if (!model || model.indexOf("/") < 1)
|
|
7843
|
+
return {};
|
|
7844
|
+
if (environment.OPENCODE_MODELS_URL && environment.OPENCODE_MODELS_URL !== "https://models.opencode.ai" && !environment.OPENCODE_MODELS_PATH)
|
|
7845
|
+
return {};
|
|
7846
|
+
const provider = model.slice(0, model.indexOf("/"));
|
|
7847
|
+
const home = (process.platform === "win32" ? environment.USERPROFILE : undefined) || environment.HOME || homedir6();
|
|
7848
|
+
const cache = xdgRoot(environment.XDG_CACHE_HOME, path9.join(home, ".cache"));
|
|
7849
|
+
const catalog = await readJson(environment.OPENCODE_MODELS_PATH || path9.join(cache, "opencode", "models.json"), 16 * 1024 * 1024);
|
|
7850
|
+
const providerInfo = record5(catalog?.[provider]);
|
|
7851
|
+
const names = Array.isArray(providerInfo?.env) ? providerInfo.env.filter((name2) => typeof name2 === "string") : [];
|
|
7852
|
+
if (names.some((name2) => environment[name2] !== undefined))
|
|
7853
|
+
return {};
|
|
7854
|
+
const name = names.find((name2) => /^[A-Z][A-Z0-9_]*(?:_API_KEY|_TOKEN)$/.test(name2));
|
|
7855
|
+
if (!name)
|
|
7856
|
+
return {};
|
|
7857
|
+
const data = xdgRoot(environment.XDG_DATA_HOME, path9.join(home, ".local", "share"));
|
|
7858
|
+
const auth = (environment.OPENCODE_AUTH_CONTENT ? parse(environment.OPENCODE_AUTH_CONTENT) : undefined) ?? await readJson(path9.join(data, "opencode", "auth.json"), 1024 * 1024);
|
|
7859
|
+
const credential = record5(auth?.[provider]);
|
|
7860
|
+
return credential?.type === "api" && typeof credential.key === "string" && credential.key.trim() ? { [name]: credential.key } : {};
|
|
7861
|
+
}
|
|
7862
|
+
|
|
7772
7863
|
// agent-driver/dist/adapters/opencode/recent-context.js
|
|
7773
7864
|
var OPENCODE_DISCOVERY_TIMEOUT_MS = 15000;
|
|
7774
7865
|
var OPENCODE_DISCOVERY_OUTPUT_MAX_BYTES = 4 * 1024 * 1024;
|
|
@@ -7849,7 +7940,7 @@ class OpenCodeDriver {
|
|
|
7849
7940
|
instructionDelivery = { kind: "workspace_file", canonical: "AGENTS.md", aliases: ["CLAUDE.md"] };
|
|
7850
7941
|
execution = {
|
|
7851
7942
|
lifetime: "session",
|
|
7852
|
-
transport: { kind: "http_sse", protocol: "opencode.v2.service
|
|
7943
|
+
transport: { kind: "http_sse", protocol: "opencode.v2.service" },
|
|
7853
7944
|
wakeStart: "immediate",
|
|
7854
7945
|
terminalOwnership: "transport_request"
|
|
7855
7946
|
};
|
|
@@ -7882,7 +7973,9 @@ class OpenCodeDriver {
|
|
|
7882
7973
|
const { spawnEnv } = await prepareCliTransport(ctx, {
|
|
7883
7974
|
OPENCODE_SERVER_PASSWORD: password
|
|
7884
7975
|
});
|
|
7885
|
-
const
|
|
7976
|
+
const fields2 = resolveLaunchFieldsOrDefault(ctx.config.runtimeConfig);
|
|
7977
|
+
Object.assign(spawnEnv, await legacyOpenCodeApiEnvironment(spawnEnv, fields2.model));
|
|
7978
|
+
const override = fields2.command;
|
|
7886
7979
|
const args = [
|
|
7887
7980
|
"serve",
|
|
7888
7981
|
"--pure",
|
|
@@ -7905,8 +7998,8 @@ class OpenCodeDriver {
|
|
|
7905
7998
|
// agent-driver/dist/adapters/pi/index.js
|
|
7906
7999
|
import { createRequire } from "module";
|
|
7907
8000
|
import { existsSync as existsSync3, readdirSync, readFileSync as readFileSync3, realpathSync } from "fs";
|
|
7908
|
-
import { homedir as
|
|
7909
|
-
import * as
|
|
8001
|
+
import { homedir as homedir8 } from "os";
|
|
8002
|
+
import * as path12 from "path";
|
|
7910
8003
|
|
|
7911
8004
|
// agent-driver/dist/controller/sdk-host.js
|
|
7912
8005
|
import { EventEmitter as EventEmitter6 } from "events";
|
|
@@ -8021,7 +8114,7 @@ class SdkLane {
|
|
|
8021
8114
|
|
|
8022
8115
|
// agent-driver/dist/adapters/pi/sessionDeps.js
|
|
8023
8116
|
import { readFileSync as readFileSync2 } from "fs";
|
|
8024
|
-
import * as
|
|
8117
|
+
import * as path10 from "path";
|
|
8025
8118
|
import { pathToFileURL } from "url";
|
|
8026
8119
|
var PI_SDK_PACKAGE_NAME = "@earendil-works/pi-coding-agent";
|
|
8027
8120
|
var cachedSdkPromise = null;
|
|
@@ -8030,9 +8123,9 @@ async function importPiSdkFromGlobalInstall() {
|
|
|
8030
8123
|
if (!dir) {
|
|
8031
8124
|
throw new Error(`${PI_SDK_PACKAGE_NAME} not found — install it (e.g. \`npm install -g ${PI_SDK_PACKAGE_NAME}\`) before launching a pi agent`);
|
|
8032
8125
|
}
|
|
8033
|
-
const pkg = JSON.parse(readFileSync2(
|
|
8126
|
+
const pkg = JSON.parse(readFileSync2(path10.join(dir, "package.json"), "utf-8"));
|
|
8034
8127
|
const entry = pkg.exports?.["."]?.import ?? pkg.main ?? "./dist/index.js";
|
|
8035
|
-
const entryPath =
|
|
8128
|
+
const entryPath = path10.join(dir, entry);
|
|
8036
8129
|
const barrel = await import(pathToFileURL(entryPath).href);
|
|
8037
8130
|
return withSessionDirHelper(barrel, entryPath);
|
|
8038
8131
|
}
|
|
@@ -8040,7 +8133,7 @@ async function withSessionDirHelper(barrel, entryPath) {
|
|
|
8040
8133
|
if (typeof barrel.getDefaultSessionDir === "function")
|
|
8041
8134
|
return barrel;
|
|
8042
8135
|
try {
|
|
8043
|
-
const deepPath =
|
|
8136
|
+
const deepPath = path10.join(path10.dirname(entryPath), "core", "session-manager.js");
|
|
8044
8137
|
const deep = await import(pathToFileURL(deepPath).href);
|
|
8045
8138
|
if (typeof deep.getDefaultSessionDir !== "function")
|
|
8046
8139
|
return barrel;
|
|
@@ -8121,13 +8214,13 @@ function createPiSessionDependencies(ctx, loadSdk = loadPiSdkModule) {
|
|
|
8121
8214
|
}
|
|
8122
8215
|
|
|
8123
8216
|
// agent-driver/dist/adapters/pi/recent-context.js
|
|
8124
|
-
import { homedir as
|
|
8125
|
-
import
|
|
8217
|
+
import { homedir as homedir7 } from "node:os";
|
|
8218
|
+
import path11 from "node:path";
|
|
8126
8219
|
function expandTildePath(value) {
|
|
8127
8220
|
if (value === "~")
|
|
8128
|
-
return
|
|
8221
|
+
return homedir7();
|
|
8129
8222
|
if (value.startsWith("~/"))
|
|
8130
|
-
return
|
|
8223
|
+
return path11.join(homedir7(), value.slice(2));
|
|
8131
8224
|
return value;
|
|
8132
8225
|
}
|
|
8133
8226
|
async function discoverPiRecentContext(request, dependencies = {}) {
|
|
@@ -8135,7 +8228,7 @@ async function discoverPiRecentContext(request, dependencies = {}) {
|
|
|
8135
8228
|
if (collector.satisfied)
|
|
8136
8229
|
return collector.result();
|
|
8137
8230
|
const customSessionDirectory = process.env.PI_CODING_AGENT_SESSION_DIR;
|
|
8138
|
-
const sessionsRoot =
|
|
8231
|
+
const sessionsRoot = path11.resolve(expandTildePath(dependencies.sessionsRoot ?? customSessionDirectory ?? path11.join(process.env.PI_CODING_AGENT_DIR || path11.join(homedir7(), ".pi", "agent"), "sessions")));
|
|
8139
8232
|
const scanDirectSessions = dependencies.sessionsRoot == null && customSessionDirectory != null;
|
|
8140
8233
|
const readHeader = dependencies.readHeader ?? readFirstLine;
|
|
8141
8234
|
const candidates = await collectJsonlFileCandidates(sessionsRoot, {
|
|
@@ -8183,15 +8276,15 @@ function resolvePiSdkPackageDir(deps = {}) {
|
|
|
8183
8276
|
if (!binPath)
|
|
8184
8277
|
return;
|
|
8185
8278
|
try {
|
|
8186
|
-
let dir =
|
|
8279
|
+
let dir = path12.dirname(realpathSync(binPath));
|
|
8187
8280
|
const MAX_DEPTH = 8;
|
|
8188
8281
|
for (let i = 0;i < MAX_DEPTH; i++) {
|
|
8189
|
-
if (isPiSdkPackageJson(
|
|
8282
|
+
if (isPiSdkPackageJson(path12.join(dir, "package.json")))
|
|
8190
8283
|
return dir;
|
|
8191
|
-
const siblingDir =
|
|
8192
|
-
if (isPiSdkPackageJson(
|
|
8284
|
+
const siblingDir = path12.join(dir, "node_modules", PI_SDK_PACKAGE_NAME2);
|
|
8285
|
+
if (isPiSdkPackageJson(path12.join(siblingDir, "package.json")))
|
|
8193
8286
|
return siblingDir;
|
|
8194
|
-
const parent =
|
|
8287
|
+
const parent = path12.dirname(dir);
|
|
8195
8288
|
if (parent === dir)
|
|
8196
8289
|
break;
|
|
8197
8290
|
dir = parent;
|
|
@@ -8208,21 +8301,21 @@ function findPiSessionFile(sessionDir, sessionId) {
|
|
|
8208
8301
|
}
|
|
8209
8302
|
const suffix = `_${sessionId}.jsonl`;
|
|
8210
8303
|
const match = entries.find((entry) => entry.endsWith(suffix));
|
|
8211
|
-
return match ?
|
|
8304
|
+
return match ? path12.join(sessionDir, match) : null;
|
|
8212
8305
|
}
|
|
8213
8306
|
function resolvePiSessionDir(sdk, cwd) {
|
|
8214
8307
|
if (typeof sdk.getDefaultSessionDir === "function")
|
|
8215
8308
|
return sdk.getDefaultSessionDir(cwd);
|
|
8216
|
-
const agentDir = typeof sdk.getAgentDir === "function" ? sdk.getAgentDir() :
|
|
8217
|
-
const encoded = `--${
|
|
8218
|
-
return
|
|
8309
|
+
const agentDir = typeof sdk.getAgentDir === "function" ? sdk.getAgentDir() : path12.join(homedir8(), ".pi", "agent");
|
|
8310
|
+
const encoded = `--${path12.resolve(cwd).replace(/^[/\\]/, "").replace(/[/\\:]/g, "-")}--`;
|
|
8311
|
+
return path12.join(agentDir, "sessions", encoded);
|
|
8219
8312
|
}
|
|
8220
8313
|
function resolvePiSdkVersionFromPath(deps = {}) {
|
|
8221
8314
|
const dir = resolvePiSdkPackageDir(deps);
|
|
8222
8315
|
if (!dir)
|
|
8223
8316
|
return;
|
|
8224
8317
|
try {
|
|
8225
|
-
const pkg = JSON.parse(readFileSync3(
|
|
8318
|
+
const pkg = JSON.parse(readFileSync3(path12.join(dir, "package.json"), "utf-8"));
|
|
8226
8319
|
return pkg.version;
|
|
8227
8320
|
} catch {
|
|
8228
8321
|
return;
|
|
@@ -10449,7 +10542,7 @@ import { createHash as createHash5 } from "crypto";
|
|
|
10449
10542
|
// agent-driver/dist/adapters/antigravity/quota.js
|
|
10450
10543
|
import { createHash as createHash4, randomBytes as randomBytes5 } from "node:crypto";
|
|
10451
10544
|
import { readFile } from "node:fs/promises";
|
|
10452
|
-
import { homedir as
|
|
10545
|
+
import { homedir as homedir9 } from "node:os";
|
|
10453
10546
|
import { isAbsolute, join as join11 } from "node:path";
|
|
10454
10547
|
var PROD = "https://cloudcode-pa.googleapis.com";
|
|
10455
10548
|
var DAILY = "https://daily-cloudcode-pa.googleapis.com";
|
|
@@ -10521,10 +10614,10 @@ function parseAntigravityQuota(value) {
|
|
|
10521
10614
|
}
|
|
10522
10615
|
async function readAntigravityQuota(options = {}) {
|
|
10523
10616
|
const env = options.env ?? process.env;
|
|
10524
|
-
const home = options.home ??
|
|
10617
|
+
const home = options.home ?? homedir9();
|
|
10525
10618
|
const configuredHome = env.GEMINI_HOME?.replace(/^~(?=[/\\]|$)/, home);
|
|
10526
10619
|
const root = configuredHome ? isAbsolute(configuredHome) ? configuredHome : join11(process.cwd(), configuredHome) : join11(home, ".gemini");
|
|
10527
|
-
const read = options.readCredentialsFile ?? ((
|
|
10620
|
+
const read = options.readCredentialsFile ?? ((path13) => readFile(path13, "utf8"));
|
|
10528
10621
|
let credentials = null;
|
|
10529
10622
|
let authType;
|
|
10530
10623
|
let storageUnavailable = false;
|
|
@@ -10643,7 +10736,7 @@ async function readAntigravityQuota(options = {}) {
|
|
|
10643
10736
|
// agent-driver/dist/provider-quota.js
|
|
10644
10737
|
import { execFile } from "node:child_process";
|
|
10645
10738
|
import { readFile as readFile2 } from "node:fs/promises";
|
|
10646
|
-
import { homedir as
|
|
10739
|
+
import { homedir as homedir10 } from "node:os";
|
|
10647
10740
|
import { join as join12 } from "node:path";
|
|
10648
10741
|
import { promisify } from "node:util";
|
|
10649
10742
|
import { randomBytes as randomBytes6 } from "node:crypto";
|
|
@@ -10672,7 +10765,7 @@ async function claudeCredentials(options) {
|
|
|
10672
10765
|
} catch {}
|
|
10673
10766
|
}
|
|
10674
10767
|
const env = options.env ?? process.env;
|
|
10675
|
-
const root = env.CLAUDE_CONFIG_DIR || join12(options.home ??
|
|
10768
|
+
const root = env.CLAUDE_CONFIG_DIR || join12(options.home ?? homedir10(), ".claude");
|
|
10676
10769
|
try {
|
|
10677
10770
|
const value = options.readCredentialsFile ? await options.readCredentialsFile(join12(root, ".credentials.json")) : await readFile2(join12(root, ".credentials.json"), "utf8");
|
|
10678
10771
|
return parseCredentials(value);
|
|
@@ -10761,8 +10854,8 @@ async function readClaudeQuota(options) {
|
|
|
10761
10854
|
if (!body || typeof body !== "object") {
|
|
10762
10855
|
return { status: "error", sourceEpoch: claudeSourceEpoch, code: "invalid_response", retryable: true };
|
|
10763
10856
|
}
|
|
10764
|
-
const
|
|
10765
|
-
const limits = ["five_hour", "seven_day", "seven_day_sonnet", "seven_day_opus"].map((key) => claudeLimit(key,
|
|
10857
|
+
const record6 = body;
|
|
10858
|
+
const limits = ["five_hour", "seven_day", "seven_day_sonnet", "seven_day_opus"].map((key) => claudeLimit(key, record6[key])).filter((limit) => limit !== null);
|
|
10766
10859
|
if (limits.length === 0) {
|
|
10767
10860
|
return { status: "error", sourceEpoch: claudeSourceEpoch, code: "invalid_response", retryable: true };
|
|
10768
10861
|
}
|
|
@@ -11419,10 +11512,10 @@ function stableNormalizeApmHeldFreshness(value) {
|
|
|
11419
11512
|
return value.map((item) => stableNormalizeApmHeldFreshness(item));
|
|
11420
11513
|
if (!value || typeof value !== "object")
|
|
11421
11514
|
return value;
|
|
11422
|
-
const
|
|
11515
|
+
const record6 = value;
|
|
11423
11516
|
const normalized = {};
|
|
11424
|
-
for (const key of Object.keys(
|
|
11425
|
-
normalized[key] = stableNormalizeApmHeldFreshness(
|
|
11517
|
+
for (const key of Object.keys(record6).sort()) {
|
|
11518
|
+
normalized[key] = stableNormalizeApmHeldFreshness(record6[key]);
|
|
11426
11519
|
}
|
|
11427
11520
|
return normalized;
|
|
11428
11521
|
}
|
|
@@ -11538,13 +11631,13 @@ function reduceManager(state, event) {
|
|
|
11538
11631
|
const existing = state.agents[event.agentId];
|
|
11539
11632
|
if (!existing || existing.execution.sessionInstanceId !== event.sessionInstanceId)
|
|
11540
11633
|
return { state, effects: [] };
|
|
11541
|
-
const
|
|
11542
|
-
if (!
|
|
11634
|
+
const record6 = existing.pendingAdmissions.find((entry) => entry.sessionInstanceId === event.sessionInstanceId && entry.commandId === event.commandId);
|
|
11635
|
+
if (!record6)
|
|
11543
11636
|
return { state, effects: [] };
|
|
11544
11637
|
const agent = clone(existing);
|
|
11545
11638
|
agent.pendingAdmissions = agent.pendingAdmissions.filter((entry) => entry.sessionInstanceId !== event.sessionInstanceId || entry.commandId !== event.commandId);
|
|
11546
11639
|
syncExecutionProjection(agent);
|
|
11547
|
-
return commit(state, agent, event.outcome === "failed" ? recoveryEffects(agent, [
|
|
11640
|
+
return commit(state, agent, event.outcome === "failed" ? recoveryEffects(agent, [record6]) : []);
|
|
11548
11641
|
}
|
|
11549
11642
|
case "admission_acknowledged": {
|
|
11550
11643
|
const existing = state.agents[event.agentId];
|
|
@@ -12067,11 +12160,11 @@ function syncExecutionProjection(agent) {
|
|
|
12067
12160
|
agent.lastDeliverAt = agent.pendingAdmissions.length > 0 ? Math.max(...agent.pendingAdmissions.map((entry) => entry.admittedAt)) : null;
|
|
12068
12161
|
}
|
|
12069
12162
|
function recoveryEffects(agent, records) {
|
|
12070
|
-
return records.filter((
|
|
12163
|
+
return records.filter((record6) => record6.requeueOnFailure).map((record6) => ({
|
|
12071
12164
|
type: "requeue_delivery",
|
|
12072
12165
|
agentId: agent.agentId,
|
|
12073
|
-
message:
|
|
12074
|
-
mode:
|
|
12166
|
+
message: record6.exactAgentMsg,
|
|
12167
|
+
mode: record6.mode
|
|
12075
12168
|
}));
|
|
12076
12169
|
}
|
|
12077
12170
|
function commit(state, agent, effects) {
|
|
@@ -12519,14 +12612,14 @@ function createLogger(options = {}) {
|
|
|
12519
12612
|
`));
|
|
12520
12613
|
const err = options.err ?? ((line) => process.stderr.write(line + `
|
|
12521
12614
|
`));
|
|
12522
|
-
const
|
|
12615
|
+
const record6 = options.record;
|
|
12523
12616
|
const emit = (level, message, data) => {
|
|
12524
12617
|
if (LEVEL_RANK[level] < minRank)
|
|
12525
12618
|
return;
|
|
12526
12619
|
const time = now();
|
|
12527
12620
|
const line = `${time} ${header} ${level.toUpperCase().padEnd(5)} ${message}${formatData(data)}`;
|
|
12528
12621
|
try {
|
|
12529
|
-
|
|
12622
|
+
record6?.({ time, header, level, message, fields: recordFields(data) });
|
|
12530
12623
|
} catch {}
|
|
12531
12624
|
(level === "warn" || level === "error" ? err : out)(line);
|
|
12532
12625
|
};
|
|
@@ -14274,7 +14367,7 @@ __export(exports_external, {
|
|
|
14274
14367
|
regexes: () => exports_regexes,
|
|
14275
14368
|
regex: () => _regex,
|
|
14276
14369
|
refine: () => refine,
|
|
14277
|
-
record: () =>
|
|
14370
|
+
record: () => record6,
|
|
14278
14371
|
readonly: () => readonly,
|
|
14279
14372
|
property: () => _property,
|
|
14280
14373
|
properties: () => _properties,
|
|
@@ -14286,7 +14379,7 @@ __export(exports_external, {
|
|
|
14286
14379
|
pipe: () => pipe,
|
|
14287
14380
|
partialRecord: () => partialRecord,
|
|
14288
14381
|
parseAsync: () => parseAsync2,
|
|
14289
|
-
parse: () =>
|
|
14382
|
+
parse: () => parse4,
|
|
14290
14383
|
overwrite: () => _overwrite,
|
|
14291
14384
|
output: () => output,
|
|
14292
14385
|
optional: () => optional,
|
|
@@ -14514,7 +14607,7 @@ __export(exports_core2, {
|
|
|
14514
14607
|
prettifyError: () => prettifyError,
|
|
14515
14608
|
parseURLObject: () => parseURLObject,
|
|
14516
14609
|
parseAsync: () => parseAsync,
|
|
14517
|
-
parse: () =>
|
|
14610
|
+
parse: () => parse2,
|
|
14518
14611
|
meta: () => meta,
|
|
14519
14612
|
mergeValues: () => mergeValues,
|
|
14520
14613
|
memoizer: () => memoizer,
|
|
@@ -15035,10 +15128,10 @@ function mergeDefs(...defs) {
|
|
|
15035
15128
|
function cloneDef(schema) {
|
|
15036
15129
|
return mergeDefs(schema._zod.def);
|
|
15037
15130
|
}
|
|
15038
|
-
function getElementAtPath(obj,
|
|
15039
|
-
if (!
|
|
15131
|
+
function getElementAtPath(obj, path13) {
|
|
15132
|
+
if (!path13)
|
|
15040
15133
|
return obj;
|
|
15041
|
-
return
|
|
15134
|
+
return path13.reduce((acc, key) => acc?.[key], obj);
|
|
15042
15135
|
}
|
|
15043
15136
|
function promiseAllObject(promisesObj) {
|
|
15044
15137
|
const keys = Object.keys(promisesObj);
|
|
@@ -15374,11 +15467,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
15374
15467
|
}
|
|
15375
15468
|
return false;
|
|
15376
15469
|
}
|
|
15377
|
-
function prefixIssues(
|
|
15470
|
+
function prefixIssues(path13, issues) {
|
|
15378
15471
|
return issues.map((iss) => {
|
|
15379
15472
|
var _a;
|
|
15380
15473
|
(_a = iss).path ?? (_a.path = []);
|
|
15381
|
-
iss.path.unshift(
|
|
15474
|
+
iss.path.unshift(path13);
|
|
15382
15475
|
return iss;
|
|
15383
15476
|
});
|
|
15384
15477
|
}
|
|
@@ -15828,16 +15921,16 @@ function flattenError(error, mapper = (issue2) => issue2.message) {
|
|
|
15828
15921
|
}
|
|
15829
15922
|
function formatError(error, mapper = (issue2) => issue2.message) {
|
|
15830
15923
|
const fieldErrors = { _errors: [] };
|
|
15831
|
-
const processError = (error2,
|
|
15924
|
+
const processError = (error2, path13 = []) => {
|
|
15832
15925
|
for (const issue2 of error2.issues) {
|
|
15833
15926
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
15834
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
15927
|
+
issue2.errors.map((issues) => processError({ issues }, [...path13, ...issue2.path]));
|
|
15835
15928
|
} else if (issue2.code === "invalid_key") {
|
|
15836
|
-
processError({ issues: issue2.issues }, [...
|
|
15929
|
+
processError({ issues: issue2.issues }, [...path13, ...issue2.path]);
|
|
15837
15930
|
} else if (issue2.code === "invalid_element") {
|
|
15838
|
-
processError({ issues: issue2.issues }, [...
|
|
15931
|
+
processError({ issues: issue2.issues }, [...path13, ...issue2.path]);
|
|
15839
15932
|
} else {
|
|
15840
|
-
const fullpath = [...
|
|
15933
|
+
const fullpath = [...path13, ...issue2.path];
|
|
15841
15934
|
if (fullpath.length === 0) {
|
|
15842
15935
|
fieldErrors._errors.push(mapper(issue2));
|
|
15843
15936
|
} else {
|
|
@@ -15876,17 +15969,17 @@ function formatError(error, mapper = (issue2) => issue2.message) {
|
|
|
15876
15969
|
}
|
|
15877
15970
|
function treeifyError(error, mapper = (issue2) => issue2.message) {
|
|
15878
15971
|
const result = { errors: [] };
|
|
15879
|
-
const processError = (error2,
|
|
15972
|
+
const processError = (error2, path13 = []) => {
|
|
15880
15973
|
var _a2;
|
|
15881
15974
|
for (const issue2 of error2.issues) {
|
|
15882
15975
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
15883
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
15976
|
+
issue2.errors.map((issues) => processError({ issues }, [...path13, ...issue2.path]));
|
|
15884
15977
|
} else if (issue2.code === "invalid_key") {
|
|
15885
|
-
processError({ issues: issue2.issues }, [...
|
|
15978
|
+
processError({ issues: issue2.issues }, [...path13, ...issue2.path]);
|
|
15886
15979
|
} else if (issue2.code === "invalid_element") {
|
|
15887
|
-
processError({ issues: issue2.issues }, [...
|
|
15980
|
+
processError({ issues: issue2.issues }, [...path13, ...issue2.path]);
|
|
15888
15981
|
} else {
|
|
15889
|
-
const fullpath = [...
|
|
15982
|
+
const fullpath = [...path13, ...issue2.path];
|
|
15890
15983
|
if (fullpath.length === 0) {
|
|
15891
15984
|
result.errors.push(mapper(issue2));
|
|
15892
15985
|
continue;
|
|
@@ -15925,8 +16018,8 @@ function treeifyError(error, mapper = (issue2) => issue2.message) {
|
|
|
15925
16018
|
}
|
|
15926
16019
|
function toDotPath(_path) {
|
|
15927
16020
|
const segs = [];
|
|
15928
|
-
const
|
|
15929
|
-
for (const seg of
|
|
16021
|
+
const path13 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
16022
|
+
for (const seg of path13) {
|
|
15930
16023
|
if (typeof seg === "number")
|
|
15931
16024
|
segs.push(`[${seg}]`);
|
|
15932
16025
|
else if (typeof seg === "symbol")
|
|
@@ -15973,7 +16066,7 @@ var _parse = (_Err) => {
|
|
|
15973
16066
|
};
|
|
15974
16067
|
return fn;
|
|
15975
16068
|
};
|
|
15976
|
-
var
|
|
16069
|
+
var parse2 = /* @__PURE__ */ _parse($ZodRealError);
|
|
15977
16070
|
var _parseAsync = (_Err) => {
|
|
15978
16071
|
const fn = async (schema, value, _ctx, params) => {
|
|
15979
16072
|
const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
|
|
@@ -16061,18 +16154,18 @@ var validateAsync = async (schema, value, _ctx) => {
|
|
|
16061
16154
|
return result.issues.length === 0;
|
|
16062
16155
|
};
|
|
16063
16156
|
var _encode = (_Err) => {
|
|
16064
|
-
const
|
|
16157
|
+
const parse3 = _parse(_Err);
|
|
16065
16158
|
const fn = (schema, value, _ctx, _params) => {
|
|
16066
16159
|
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
16067
|
-
return
|
|
16160
|
+
return parse3(schema, value, ctx, finalizeParams(fn, _params));
|
|
16068
16161
|
};
|
|
16069
16162
|
return fn;
|
|
16070
16163
|
};
|
|
16071
16164
|
var encode = /* @__PURE__ */ _encode($ZodRealError);
|
|
16072
16165
|
var _decode = (_Err) => {
|
|
16073
|
-
const
|
|
16166
|
+
const parse3 = _parse(_Err);
|
|
16074
16167
|
const fn = (schema, value, _ctx, _params) => {
|
|
16075
|
-
return
|
|
16168
|
+
return parse3(schema, value, _ctx, finalizeParams(fn, _params));
|
|
16076
16169
|
};
|
|
16077
16170
|
return fn;
|
|
16078
16171
|
};
|
|
@@ -19087,10 +19180,10 @@ var $ZodFunction = /* @__PURE__ */ $constructor("$ZodFunction", (inst, def) => {
|
|
|
19087
19180
|
throw new Error("implement() must be called with a function");
|
|
19088
19181
|
}
|
|
19089
19182
|
return Object.defineProperty(function(...args) {
|
|
19090
|
-
const parsedArgs = inst._def.input ?
|
|
19183
|
+
const parsedArgs = inst._def.input ? parse2(inst._def.input, args) : args;
|
|
19091
19184
|
const result = Reflect.apply(func, this, parsedArgs);
|
|
19092
19185
|
if (inst._def.output) {
|
|
19093
|
-
return
|
|
19186
|
+
return parse2(inst._def.output, result);
|
|
19094
19187
|
}
|
|
19095
19188
|
return result;
|
|
19096
19189
|
}, "_zod", { value: inst._zod, enumerable: false });
|
|
@@ -19372,7 +19465,7 @@ function bucketFor(state, inst) {
|
|
|
19372
19465
|
return bucket;
|
|
19373
19466
|
}
|
|
19374
19467
|
var handoff;
|
|
19375
|
-
var
|
|
19468
|
+
var open2 = [];
|
|
19376
19469
|
var memo = {
|
|
19377
19470
|
alloc(_inst, payload, empty) {
|
|
19378
19471
|
const bucket = handoff;
|
|
@@ -19381,7 +19474,7 @@ var memo = {
|
|
|
19381
19474
|
handoff = undefined;
|
|
19382
19475
|
const entry = { value: empty, issues: null };
|
|
19383
19476
|
bucket.set(payload.value, entry);
|
|
19384
|
-
|
|
19477
|
+
open2.push(entry);
|
|
19385
19478
|
return empty;
|
|
19386
19479
|
},
|
|
19387
19480
|
guard(inst) {
|
|
@@ -19452,10 +19545,10 @@ var memo = {
|
|
|
19452
19545
|
return payload;
|
|
19453
19546
|
}
|
|
19454
19547
|
handoff = bucket;
|
|
19455
|
-
const depth =
|
|
19548
|
+
const depth = open2.length;
|
|
19456
19549
|
const result = base(payload, ctx);
|
|
19457
19550
|
handoff = undefined;
|
|
19458
|
-
const entry =
|
|
19551
|
+
const entry = open2.length > depth ? open2.pop() : undefined;
|
|
19459
19552
|
if (result instanceof Promise) {
|
|
19460
19553
|
return result.then((r) => {
|
|
19461
19554
|
if (entry)
|
|
@@ -30594,8 +30687,8 @@ function rewriteKeyNames(ctx) {
|
|
|
30594
30687
|
bySchema.set(entry.schema, entry);
|
|
30595
30688
|
}
|
|
30596
30689
|
const rewrites = new Map;
|
|
30597
|
-
for (const
|
|
30598
|
-
const seen = ctx.seen.get(
|
|
30690
|
+
for (const record6 of pendingRecords.get(ctx) ?? []) {
|
|
30691
|
+
const seen = ctx.seen.get(record6);
|
|
30599
30692
|
const names = (seen?.def ?? seen?.schema)?.propertyNames;
|
|
30600
30693
|
if (!names || names === true || rewrites.has(names))
|
|
30601
30694
|
continue;
|
|
@@ -30921,7 +31014,7 @@ __export(exports_schemas2, {
|
|
|
30921
31014
|
strictObject: () => strictObject,
|
|
30922
31015
|
set: () => set,
|
|
30923
31016
|
refine: () => refine,
|
|
30924
|
-
record: () =>
|
|
31017
|
+
record: () => record6,
|
|
30925
31018
|
readonly: () => readonly,
|
|
30926
31019
|
promise: () => promise,
|
|
30927
31020
|
preprocess: () => preprocess,
|
|
@@ -31155,7 +31248,7 @@ var ZodRealError = /* @__PURE__ */ $constructor("ZodError", initializer2, undefi
|
|
|
31155
31248
|
});
|
|
31156
31249
|
|
|
31157
31250
|
// ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/classic/parse.js
|
|
31158
|
-
var
|
|
31251
|
+
var parse4 = /* @__PURE__ */ _parse(ZodRealError);
|
|
31159
31252
|
var parseAsync2 = /* @__PURE__ */ _parseAsync(ZodRealError);
|
|
31160
31253
|
var safeParse2 = /* @__PURE__ */ _safeParse(ZodRealError);
|
|
31161
31254
|
var safeParseAsync2 = /* @__PURE__ */ _safeParseAsync(ZodRealError);
|
|
@@ -31291,7 +31384,7 @@ var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
|
31291
31384
|
exports_util.own(this, "~standard", value);
|
|
31292
31385
|
},
|
|
31293
31386
|
parse: function _parse2(data, params) {
|
|
31294
|
-
return
|
|
31387
|
+
return parse4(this, data, params, { callee: _parse2 });
|
|
31295
31388
|
},
|
|
31296
31389
|
parseAsync: async function _parseAsync2(data, params) {
|
|
31297
31390
|
return await parseAsync2(this, data, params, { callee: _parseAsync2 });
|
|
@@ -32126,7 +32219,7 @@ var ZodRecord = /* @__PURE__ */ $constructor("ZodRecord", (inst, def) => {
|
|
|
32126
32219
|
inst.keyType = def.keyType;
|
|
32127
32220
|
inst.valueType = def.valueType;
|
|
32128
32221
|
});
|
|
32129
|
-
function
|
|
32222
|
+
function record6(keyType, valueType, params) {
|
|
32130
32223
|
if (!valueType || !valueType._zod) {
|
|
32131
32224
|
return new ZodRecord({
|
|
32132
32225
|
type: "record",
|
|
@@ -32599,7 +32692,7 @@ var stringbool = (...args) => _stringbool({
|
|
|
32599
32692
|
}, ...args);
|
|
32600
32693
|
function json(params) {
|
|
32601
32694
|
const jsonSchema = lazy(() => {
|
|
32602
|
-
return union([string2(params), number3(), boolean2(), _null3(), array(jsonSchema),
|
|
32695
|
+
return union([string2(params), number3(), boolean2(), _null3(), array(jsonSchema), record6(string2(), jsonSchema)]);
|
|
32603
32696
|
});
|
|
32604
32697
|
return jsonSchema;
|
|
32605
32698
|
}
|
|
@@ -32747,13 +32840,13 @@ function resolveRef(ref, ctx) {
|
|
|
32747
32840
|
if (!ref.startsWith("#")) {
|
|
32748
32841
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
32749
32842
|
}
|
|
32750
|
-
const
|
|
32751
|
-
if (
|
|
32843
|
+
const path13 = ref.slice(1).split("/").filter(Boolean);
|
|
32844
|
+
if (path13.length === 0) {
|
|
32752
32845
|
return ctx.rootSchema;
|
|
32753
32846
|
}
|
|
32754
32847
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
32755
|
-
if (
|
|
32756
|
-
const key =
|
|
32848
|
+
if (path13[0] === defsKey) {
|
|
32849
|
+
const key = path13[1] === undefined ? undefined : decodeJSONPointerSegment(path13[1]);
|
|
32757
32850
|
if (!key || !ctx.defs[key]) {
|
|
32758
32851
|
throw new Error(`Reference not found: ${ref}`);
|
|
32759
32852
|
}
|
|
@@ -36717,7 +36810,7 @@ import * as fs5 from "fs";
|
|
|
36717
36810
|
import * as http from "http";
|
|
36718
36811
|
import * as https from "https";
|
|
36719
36812
|
import * as os2 from "os";
|
|
36720
|
-
import * as
|
|
36813
|
+
import * as path13 from "path";
|
|
36721
36814
|
import { URL as URL2 } from "url";
|
|
36722
36815
|
var LOCAL_MESSAGE_REMINDER_PATH = "/__alook/local/message-reminder";
|
|
36723
36816
|
var LOCAL_MESSAGE_REMINDER_BODY_MAX_BYTES = 4 * 1024;
|
|
@@ -36749,15 +36842,15 @@ class CredentialBroker {
|
|
|
36749
36842
|
this.voucherPrefix = config2.voucherPrefix ?? "vch_";
|
|
36750
36843
|
this.clientLabel = config2.clientLabel ?? "cli";
|
|
36751
36844
|
this.headerNames = config2.headerNames ?? DEFAULT_HEADER_NAMES;
|
|
36752
|
-
this.voucherDir = config2.voucherDir ??
|
|
36845
|
+
this.voucherDir = config2.voucherDir ?? path13.join(os2.tmpdir(), "agent-vouchers");
|
|
36753
36846
|
}
|
|
36754
36847
|
mint(agentId, launchId, capabilities2, runnerKey) {
|
|
36755
36848
|
if (!runnerKey)
|
|
36756
36849
|
throw new Error("CredentialBroker.mint: runnerKey is required (per-agent tier-2 credential)");
|
|
36757
36850
|
const voucher = randomVoucher(this.voucherPrefix);
|
|
36758
|
-
const dir =
|
|
36851
|
+
const dir = path13.join(this.voucherDir, sanitizeIdSegment(agentId));
|
|
36759
36852
|
fs5.mkdirSync(dir, { recursive: true });
|
|
36760
|
-
const voucherFile =
|
|
36853
|
+
const voucherFile = path13.join(dir, `${sanitizeIdSegment(launchId)}.token`);
|
|
36761
36854
|
fs5.writeFileSync(voucherFile, voucher, { mode: 384 });
|
|
36762
36855
|
this.registrations.set(voucher, {
|
|
36763
36856
|
agentId,
|
|
@@ -36885,20 +36978,20 @@ function parseLocalMessageReminderBody(body, agentId) {
|
|
|
36885
36978
|
}
|
|
36886
36979
|
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
36887
36980
|
return null;
|
|
36888
|
-
const
|
|
36889
|
-
if (Object.keys(
|
|
36981
|
+
const record7 = value;
|
|
36982
|
+
if (Object.keys(record7).sort().join(",") !== "channel,remindAfterMs,sentSeq")
|
|
36890
36983
|
return null;
|
|
36891
|
-
if (typeof
|
|
36984
|
+
if (typeof record7.channel !== "string" || !isCanonicalChannelScope(record7.channel))
|
|
36892
36985
|
return null;
|
|
36893
|
-
if (!Number.isSafeInteger(
|
|
36986
|
+
if (!Number.isSafeInteger(record7.sentSeq) || record7.sentSeq < 1)
|
|
36894
36987
|
return null;
|
|
36895
|
-
if (!Number.isSafeInteger(
|
|
36988
|
+
if (!Number.isSafeInteger(record7.remindAfterMs) || record7.remindAfterMs !== 0 && record7.remindAfterMs < LOCAL_MESSAGE_REMINDER_MIN_MS || record7.remindAfterMs > LOCAL_MESSAGE_REMINDER_MAX_MS)
|
|
36896
36989
|
return null;
|
|
36897
36990
|
return {
|
|
36898
36991
|
agentId,
|
|
36899
|
-
channel:
|
|
36900
|
-
sentSeq:
|
|
36901
|
-
remindAfterMs:
|
|
36992
|
+
channel: record7.channel,
|
|
36993
|
+
sentSeq: record7.sentSeq,
|
|
36994
|
+
remindAfterMs: record7.remindAfterMs
|
|
36902
36995
|
};
|
|
36903
36996
|
}
|
|
36904
36997
|
async function handleLocalMessageReminder(req, res, agentId, onArm) {
|
|
@@ -37203,7 +37296,7 @@ function joinPath(basePath, reqUrl) {
|
|
|
37203
37296
|
return base + reqPath || "/";
|
|
37204
37297
|
}
|
|
37205
37298
|
// src/daemon/createDaemon.ts
|
|
37206
|
-
import { homedir as
|
|
37299
|
+
import { homedir as homedir12 } from "os";
|
|
37207
37300
|
import { appendFileSync as appendFileSync2, mkdirSync as mkdirSync8 } from "node:fs";
|
|
37208
37301
|
|
|
37209
37302
|
// src/util/rotatingFileSink.ts
|
|
@@ -37220,7 +37313,7 @@ import {
|
|
|
37220
37313
|
statSync,
|
|
37221
37314
|
unlinkSync as unlinkSync3
|
|
37222
37315
|
} from "node:fs";
|
|
37223
|
-
function createRotatingFileSink(
|
|
37316
|
+
function createRotatingFileSink(path14, maxBytes, opts = {}) {
|
|
37224
37317
|
const report = (operation, error62) => {
|
|
37225
37318
|
try {
|
|
37226
37319
|
opts.onError?.({ operation, error: error62 });
|
|
@@ -37256,9 +37349,9 @@ function createRotatingFileSink(path13, maxBytes, opts = {}) {
|
|
|
37256
37349
|
};
|
|
37257
37350
|
const rotate = () => {
|
|
37258
37351
|
try {
|
|
37259
|
-
renameSync2(
|
|
37352
|
+
renameSync2(path14, `${path14}.1`);
|
|
37260
37353
|
if (opts.mode !== undefined)
|
|
37261
|
-
chmodSync(`${
|
|
37354
|
+
chmodSync(`${path14}.1`, opts.mode);
|
|
37262
37355
|
return true;
|
|
37263
37356
|
} catch (error62) {
|
|
37264
37357
|
report("rotate", error62);
|
|
@@ -37267,7 +37360,7 @@ function createRotatingFileSink(path13, maxBytes, opts = {}) {
|
|
|
37267
37360
|
};
|
|
37268
37361
|
const currentSize = () => {
|
|
37269
37362
|
try {
|
|
37270
|
-
return existsSync5(
|
|
37363
|
+
return existsSync5(path14) ? statSync(path14).size : 0;
|
|
37271
37364
|
} catch (error62) {
|
|
37272
37365
|
report("stat", error62);
|
|
37273
37366
|
return null;
|
|
@@ -37275,7 +37368,7 @@ function createRotatingFileSink(path13, maxBytes, opts = {}) {
|
|
|
37275
37368
|
};
|
|
37276
37369
|
const sink = {
|
|
37277
37370
|
secure() {
|
|
37278
|
-
return secureGeneration(`${
|
|
37371
|
+
return secureGeneration(`${path14}.1`) && secureGeneration(path14);
|
|
37279
37372
|
},
|
|
37280
37373
|
write(line) {
|
|
37281
37374
|
try {
|
|
@@ -37295,7 +37388,7 @@ function createRotatingFileSink(path13, maxBytes, opts = {}) {
|
|
|
37295
37388
|
const shouldRotate = maxBytes > 0 && (opts.hardMaxBytes ? currentBytes > 0 && currentBytes + serializedBytes > maxBytes : currentBytes >= maxBytes);
|
|
37296
37389
|
if (shouldRotate && !rotate() && opts.hardMaxBytes)
|
|
37297
37390
|
return;
|
|
37298
|
-
appendFileSync(
|
|
37391
|
+
appendFileSync(path14, serialized, opts.mode === undefined ? undefined : { mode: opts.mode });
|
|
37299
37392
|
} catch (error62) {
|
|
37300
37393
|
report("append", error62);
|
|
37301
37394
|
}
|
|
@@ -37303,7 +37396,7 @@ function createRotatingFileSink(path13, maxBytes, opts = {}) {
|
|
|
37303
37396
|
openSnapshot() {
|
|
37304
37397
|
const files = [];
|
|
37305
37398
|
try {
|
|
37306
|
-
for (const candidate of [`${
|
|
37399
|
+
for (const candidate of [`${path14}.1`, path14]) {
|
|
37307
37400
|
if (!existsSync5(candidate))
|
|
37308
37401
|
continue;
|
|
37309
37402
|
if (!secureGeneration(candidate))
|
|
@@ -37464,11 +37557,11 @@ function createTraceSampler(emit, throttleMs = DEFAULT_TRACE_SAMPLE_MS) {
|
|
|
37464
37557
|
|
|
37465
37558
|
// src/util/statusFile.ts
|
|
37466
37559
|
import { writeFileSync as writeFileSync5, renameSync as renameSync3 } from "node:fs";
|
|
37467
|
-
function writeStatusFile(
|
|
37560
|
+
function writeStatusFile(path14, snapshot) {
|
|
37468
37561
|
try {
|
|
37469
|
-
const tmp = `${
|
|
37562
|
+
const tmp = `${path14}.tmp`;
|
|
37470
37563
|
writeFileSync5(tmp, JSON.stringify(snapshot));
|
|
37471
|
-
renameSync3(tmp,
|
|
37564
|
+
renameSync3(tmp, path14);
|
|
37472
37565
|
} catch {}
|
|
37473
37566
|
}
|
|
37474
37567
|
// ../shared/src/community-attention.ts
|
|
@@ -37671,7 +37764,7 @@ var MAX_PROFILE_ABOUT_LENGTH = 1000;
|
|
|
37671
37764
|
var MAX_MESSAGE_CONTENT_LENGTH = 4000;
|
|
37672
37765
|
var MAX_ATTACHMENTS_PER_MESSAGE = 10;
|
|
37673
37766
|
var MAX_ATTACHMENT_SIZE_BYTES = 25 * 1024 * 1024;
|
|
37674
|
-
var MAX_ATTACHMENT_THUMBNAIL_SIZE_BYTES =
|
|
37767
|
+
var MAX_ATTACHMENT_THUMBNAIL_SIZE_BYTES = 256 * 1024;
|
|
37675
37768
|
var MAX_SERVER_ICON_SIZE_BYTES = 5 * 1024 * 1024;
|
|
37676
37769
|
var ALLOWED_ICON_MIME_TYPES = [
|
|
37677
37770
|
"image/png",
|
|
@@ -38347,7 +38440,7 @@ var REASONING_EFFORT_RE = /^[A-Za-z0-9._-]+$/;
|
|
|
38347
38440
|
var COMMUNITY_REASONING_EFFORT_MAX = 32;
|
|
38348
38441
|
var COMMUNITY_REASONING_DESCRIPTION_MAX = 256;
|
|
38349
38442
|
var COMMUNITY_REASONING_OPTIONS_MAX = 16;
|
|
38350
|
-
var COMMUNITY_REASONING_MODELS_MAX =
|
|
38443
|
+
var COMMUNITY_REASONING_MODELS_MAX = 1024;
|
|
38351
38444
|
var ReasoningEffortSchema = exports_external.string().min(1).max(COMMUNITY_REASONING_EFFORT_MAX).regex(REASONING_EFFORT_RE, "invalid reasoning effort charset");
|
|
38352
38445
|
var RuntimeReasoningOptionSchema = exports_external.object({
|
|
38353
38446
|
value: ReasoningEffortSchema,
|
|
@@ -38377,18 +38470,22 @@ var RuntimeReasoningModelSchema = exports_external.object({
|
|
|
38377
38470
|
var RuntimeReasoningCatalogSchema = exports_external.object({
|
|
38378
38471
|
updateMode: exports_external.enum(["live_next_turn", "context_preserving_restart", "unsupported"]),
|
|
38379
38472
|
defaultModelId: exports_external.string().min(1).max(100).optional().catch(undefined),
|
|
38380
|
-
models: exports_external.array(exports_external.unknown()).
|
|
38473
|
+
models: exports_external.array(exports_external.unknown()).transform((models) => {
|
|
38381
38474
|
const seen = new Set;
|
|
38382
|
-
|
|
38475
|
+
const retained = [];
|
|
38476
|
+
for (const candidate of models) {
|
|
38383
38477
|
const parsed = RuntimeReasoningModelSchema.safeParse(candidate);
|
|
38384
38478
|
if (!parsed.success)
|
|
38385
|
-
|
|
38479
|
+
continue;
|
|
38386
38480
|
const model = parsed.data;
|
|
38387
38481
|
if (seen.has(model.id))
|
|
38388
|
-
|
|
38482
|
+
continue;
|
|
38389
38483
|
seen.add(model.id);
|
|
38390
|
-
|
|
38391
|
-
|
|
38484
|
+
retained.push(model);
|
|
38485
|
+
if (retained.length >= COMMUNITY_REASONING_MODELS_MAX)
|
|
38486
|
+
break;
|
|
38487
|
+
}
|
|
38488
|
+
return retained;
|
|
38392
38489
|
})
|
|
38393
38490
|
});
|
|
38394
38491
|
var CommunityMachineRuntimeSchema = exports_external.object({
|
|
@@ -39226,7 +39323,7 @@ function maxRowsPerInsert(paramsPerRow) {
|
|
|
39226
39323
|
|
|
39227
39324
|
// ../shared/src/db/queries/community/message.ts
|
|
39228
39325
|
var log = createLogger2({ service: "community-queries" });
|
|
39229
|
-
var
|
|
39326
|
+
var messageProjection = {
|
|
39230
39327
|
id: communityMessage.id,
|
|
39231
39328
|
authorId: communityMessage.authorId,
|
|
39232
39329
|
content: communityMessage.content,
|
|
@@ -39234,16 +39331,19 @@ var listedMessageProjection = {
|
|
|
39234
39331
|
mentionType: communityMessage.mentionType,
|
|
39235
39332
|
replyToId: communityMessage.replyToId,
|
|
39236
39333
|
embeds: communityMessage.embeds,
|
|
39237
|
-
seq: communityMessage.seq,
|
|
39238
39334
|
createdAt: communityMessage.createdAt,
|
|
39239
39335
|
channelId: communityMessage.channelId,
|
|
39240
|
-
friendshipId: communityMessage.friendshipId,
|
|
39241
|
-
clientNonce: communityMessage.clientNonce,
|
|
39242
39336
|
authorName: user.name,
|
|
39243
|
-
authorEmail: user.email,
|
|
39244
39337
|
authorImage: user.image,
|
|
39245
39338
|
authorAvatarVersion: user.avatarVersion
|
|
39246
39339
|
};
|
|
39340
|
+
var listedMessageProjection = {
|
|
39341
|
+
...messageProjection,
|
|
39342
|
+
seq: communityMessage.seq,
|
|
39343
|
+
friendshipId: communityMessage.friendshipId,
|
|
39344
|
+
clientNonce: communityMessage.clientNonce,
|
|
39345
|
+
authorEmail: user.email
|
|
39346
|
+
};
|
|
39247
39347
|
var wakeContextMessageProjection = {
|
|
39248
39348
|
id: communityMessage.id,
|
|
39249
39349
|
authorId: communityMessage.authorId,
|
|
@@ -39362,26 +39462,207 @@ var AGENT_UNREAD_CHANNEL_CHUNK_SIZE = maxInParams(13);
|
|
|
39362
39462
|
|
|
39363
39463
|
// ../shared/src/db/queries/community/mention.ts
|
|
39364
39464
|
var MENTION_INSERT_MAX_ROWS = maxRowsPerInsert(5);
|
|
39365
|
-
// ../shared/src/community-
|
|
39366
|
-
var
|
|
39367
|
-
|
|
39368
|
-
|
|
39369
|
-
|
|
39370
|
-
|
|
39371
|
-
id: string4,
|
|
39372
|
-
name: string4,
|
|
39373
|
-
discriminator: string4,
|
|
39374
|
-
image: nullableString,
|
|
39465
|
+
// ../shared/src/community-friend-approval.ts
|
|
39466
|
+
var profile = exports_external.strictObject({
|
|
39467
|
+
id: exports_external.string(),
|
|
39468
|
+
name: exports_external.string(),
|
|
39469
|
+
discriminator: exports_external.string(),
|
|
39470
|
+
image: exports_external.string().nullable(),
|
|
39375
39471
|
avatarVersion: exports_external.number().int().nonnegative()
|
|
39376
39472
|
});
|
|
39377
39473
|
var FriendApprovalPayloadSchema = exports_external.strictObject({
|
|
39378
|
-
friendshipId:
|
|
39474
|
+
friendshipId: exports_external.string(),
|
|
39379
39475
|
status: exports_external.enum(["pending", "approved", "denied", "superseded", "cancelled"]),
|
|
39380
39476
|
waitingOn: exports_external.enum(["you", "other-owner", "addressee"]).nullable(),
|
|
39381
|
-
otherProfile:
|
|
39382
|
-
botProfile:
|
|
39383
|
-
waitingOnProfile:
|
|
39477
|
+
otherProfile: profile,
|
|
39478
|
+
botProfile: profile,
|
|
39479
|
+
waitingOnProfile: profile.nullable().optional()
|
|
39480
|
+
});
|
|
39481
|
+
|
|
39482
|
+
// ../shared/src/community-contract.ts
|
|
39483
|
+
var COMMUNITY_CONTRACT_VERSION = 2;
|
|
39484
|
+
|
|
39485
|
+
// ../shared/src/community-resources.ts
|
|
39486
|
+
var id2 = exports_external.string().min(1);
|
|
39487
|
+
var nullableId = id2.nullable();
|
|
39488
|
+
var legacyArchivedSchema = exports_external.union([exports_external.boolean(), exports_external.literal(0), exports_external.literal(1)]).transform((value) => value === true || value === 1);
|
|
39489
|
+
var CommunityChannelResourceSchema = exports_external.strictObject({
|
|
39490
|
+
id: id2,
|
|
39491
|
+
type: exports_external.enum(["text", "forum", "thread", "dm"]),
|
|
39492
|
+
serverId: nullableId,
|
|
39493
|
+
categoryId: nullableId,
|
|
39494
|
+
name: exports_external.string().nullable(),
|
|
39495
|
+
topic: exports_external.string(),
|
|
39496
|
+
parentChannelId: nullableId,
|
|
39497
|
+
parentMessageId: nullableId,
|
|
39498
|
+
creatorId: nullableId,
|
|
39499
|
+
position: exports_external.number(),
|
|
39500
|
+
archived: exports_external.boolean(),
|
|
39501
|
+
createdAt: exports_external.string(),
|
|
39502
|
+
lastMessageAt: exports_external.string().nullable(),
|
|
39503
|
+
messageCount: exports_external.number().int().nonnegative()
|
|
39504
|
+
});
|
|
39505
|
+
var CommunityChannelIdentitySchema = CommunityChannelResourceSchema.pick({
|
|
39506
|
+
id: true,
|
|
39507
|
+
type: true,
|
|
39508
|
+
serverId: true,
|
|
39509
|
+
name: true,
|
|
39510
|
+
parentChannelId: true,
|
|
39511
|
+
parentMessageId: true,
|
|
39512
|
+
creatorId: true,
|
|
39513
|
+
archived: true,
|
|
39514
|
+
lastMessageAt: true,
|
|
39515
|
+
createdAt: true
|
|
39516
|
+
}).partial({ createdAt: true }).strip();
|
|
39517
|
+
var legacyChannelIdentitySchema = CommunityChannelIdentitySchema.extend({
|
|
39518
|
+
archived: legacyArchivedSchema,
|
|
39519
|
+
parentChannelId: nullableId.default(null),
|
|
39520
|
+
parentMessageId: nullableId.default(null),
|
|
39521
|
+
creatorId: nullableId.default(null),
|
|
39522
|
+
lastMessageAt: CommunityChannelResourceSchema.shape.lastMessageAt.default(null)
|
|
39523
|
+
});
|
|
39524
|
+
var CommunityAccessDecisionSchema = exports_external.strictObject({
|
|
39525
|
+
channelId: id2,
|
|
39526
|
+
canRead: exports_external.boolean(),
|
|
39527
|
+
canSend: exports_external.boolean(),
|
|
39528
|
+
canCreateDiscussion: exports_external.boolean()
|
|
39529
|
+
});
|
|
39530
|
+
var CommunityMessageAttachmentSchema = exports_external.strictObject({
|
|
39531
|
+
kind: exports_external.enum(["image", "file"]),
|
|
39532
|
+
name: exports_external.string(),
|
|
39533
|
+
url: exports_external.string(),
|
|
39534
|
+
thumbnailUrl: exports_external.string().optional(),
|
|
39535
|
+
contentType: exports_external.string().optional(),
|
|
39536
|
+
size: exports_external.string().optional(),
|
|
39537
|
+
sizeBytes: exports_external.number().nonnegative().optional(),
|
|
39538
|
+
width: exports_external.number().nonnegative().optional(),
|
|
39539
|
+
height: exports_external.number().nonnegative().optional()
|
|
39540
|
+
});
|
|
39541
|
+
var CommunityMessageResourceSchema = exports_external.strictObject({
|
|
39542
|
+
id: id2,
|
|
39543
|
+
channelId: id2,
|
|
39544
|
+
seq: exports_external.number().int().nonnegative(),
|
|
39545
|
+
authorId: id2,
|
|
39546
|
+
createdAt: exports_external.string(),
|
|
39547
|
+
type: exports_external.enum(["chat", "system"]),
|
|
39548
|
+
content: exports_external.string(),
|
|
39549
|
+
replyToId: nullableId,
|
|
39550
|
+
clientNonce: exports_external.string().nullable(),
|
|
39551
|
+
attachments: exports_external.array(CommunityMessageAttachmentSchema),
|
|
39552
|
+
systemKind: exports_external.literal("thread").optional(),
|
|
39553
|
+
authorName: exports_external.string().optional(),
|
|
39554
|
+
authorAvatar: exports_external.string().optional(),
|
|
39555
|
+
authorAvatarVersion: exports_external.number().int().nonnegative().optional(),
|
|
39556
|
+
mentionType: exports_external.literal("everyone").nullable().optional(),
|
|
39557
|
+
replyTo: exports_external.strictObject({
|
|
39558
|
+
id: id2,
|
|
39559
|
+
authorId: id2.optional(),
|
|
39560
|
+
authorName: exports_external.string(),
|
|
39561
|
+
text: exports_external.string(),
|
|
39562
|
+
deleted: exports_external.boolean().optional()
|
|
39563
|
+
}).optional(),
|
|
39564
|
+
embeds: exports_external.array(exports_external.unknown()).optional(),
|
|
39565
|
+
reactions: exports_external.array(exports_external.strictObject({
|
|
39566
|
+
emoji: exports_external.string(),
|
|
39567
|
+
count: exports_external.number().int().nonnegative(),
|
|
39568
|
+
me: exports_external.boolean(),
|
|
39569
|
+
userIds: exports_external.array(id2)
|
|
39570
|
+
})).optional(),
|
|
39571
|
+
thread: exports_external.strictObject({
|
|
39572
|
+
id: id2,
|
|
39573
|
+
name: exports_external.string(),
|
|
39574
|
+
messageCount: exports_external.number().int().nonnegative(),
|
|
39575
|
+
lastReplyAt: exports_external.string().optional(),
|
|
39576
|
+
tags: exports_external.array(exports_external.string()).optional(),
|
|
39577
|
+
preview: exports_external.string().optional(),
|
|
39578
|
+
participants: exports_external.array(exports_external.strictObject({ id: id2, name: exports_external.string(), avatar: exports_external.string(), avatarVersion: exports_external.number().int().nonnegative() })).optional(),
|
|
39579
|
+
participantCount: exports_external.number().int().nonnegative().optional()
|
|
39580
|
+
}).optional(),
|
|
39581
|
+
approval: FriendApprovalPayloadSchema.optional()
|
|
39384
39582
|
});
|
|
39583
|
+
var CommunityReadStateResourceSchema = exports_external.strictObject({
|
|
39584
|
+
channelId: id2,
|
|
39585
|
+
lastReadMessageId: nullableId,
|
|
39586
|
+
lastReadAt: exports_external.string().nullable(),
|
|
39587
|
+
lastReadSeq: exports_external.number().int().nonnegative()
|
|
39588
|
+
});
|
|
39589
|
+
var CommunityMemberRelationSchema = exports_external.strictObject({
|
|
39590
|
+
channelId: id2,
|
|
39591
|
+
userId: id2,
|
|
39592
|
+
relation: exports_external.enum(["access", "notify"]),
|
|
39593
|
+
source: exports_external.string(),
|
|
39594
|
+
isCreator: exports_external.boolean(),
|
|
39595
|
+
role: exports_external.string().nullable(),
|
|
39596
|
+
memberId: nullableId
|
|
39597
|
+
});
|
|
39598
|
+
var CommunityResourceProfileSchema = exports_external.strictObject({
|
|
39599
|
+
id: id2,
|
|
39600
|
+
name: exports_external.string(),
|
|
39601
|
+
discriminator: exports_external.string().nullable(),
|
|
39602
|
+
avatar: exports_external.string().nullable(),
|
|
39603
|
+
avatarVersion: exports_external.number().int().nonnegative(),
|
|
39604
|
+
statusEmoji: exports_external.string().nullable(),
|
|
39605
|
+
statusText: exports_external.string()
|
|
39606
|
+
});
|
|
39607
|
+
var CommunityPageSchema = exports_external.strictObject({
|
|
39608
|
+
olderCursor: exports_external.string().nullable(),
|
|
39609
|
+
newerCursor: exports_external.string().nullable(),
|
|
39610
|
+
hasMoreOlder: exports_external.boolean(),
|
|
39611
|
+
hasMoreNewer: exports_external.boolean(),
|
|
39612
|
+
latestSeq: exports_external.number().int().nonnegative()
|
|
39613
|
+
});
|
|
39614
|
+
var envelope = { contractVersion: exports_external.literal(COMMUNITY_CONTRACT_VERSION), channelId: id2 };
|
|
39615
|
+
var CommunityChannelReadSchema = exports_external.strictObject({ ...envelope, channel: CommunityChannelResourceSchema, access: CommunityAccessDecisionSchema });
|
|
39616
|
+
var CommunityMessagesReadSchema = exports_external.strictObject({
|
|
39617
|
+
...envelope,
|
|
39618
|
+
messages: exports_external.array(CommunityMessageResourceSchema),
|
|
39619
|
+
page: CommunityPageSchema,
|
|
39620
|
+
surfaceReceipt: exports_external.strictObject({ channelId: id2, surfaceKind: exports_external.enum(["channel", "forum", "thread", "dm"]) })
|
|
39621
|
+
});
|
|
39622
|
+
var CommunityReadStateReadSchema = exports_external.strictObject({ ...envelope, readState: CommunityReadStateResourceSchema });
|
|
39623
|
+
var CommunityMembersReadSchema = exports_external.strictObject({ ...envelope, relation: exports_external.enum(["access", "notify"]), members: exports_external.array(CommunityMemberRelationSchema), profiles: exports_external.array(CommunityResourceProfileSchema) });
|
|
39624
|
+
var CommunityThreadsReadSchema = exports_external.strictObject({
|
|
39625
|
+
...envelope,
|
|
39626
|
+
channel: CommunityChannelResourceSchema,
|
|
39627
|
+
threads: exports_external.array(CommunityChannelResourceSchema),
|
|
39628
|
+
included: exports_external.strictObject({
|
|
39629
|
+
messages: exports_external.array(CommunityMessageResourceSchema),
|
|
39630
|
+
members: exports_external.array(CommunityMemberRelationSchema),
|
|
39631
|
+
profiles: exports_external.array(CommunityResourceProfileSchema),
|
|
39632
|
+
tags: exports_external.array(exports_external.strictObject({ messageId: id2, tag: exports_external.string() })),
|
|
39633
|
+
participantCounts: exports_external.array(exports_external.strictObject({ channelId: id2, count: exports_external.number().int().nonnegative() }))
|
|
39634
|
+
}),
|
|
39635
|
+
page: exports_external.strictObject({ nextCursor: exports_external.string().nullable(), hasMore: exports_external.boolean() })
|
|
39636
|
+
});
|
|
39637
|
+
var CommunityReadAdvanceSchema = exports_external.strictObject({ ...envelope, changed: exports_external.boolean(), targetSeq: exports_external.number().int().nonnegative(), revision: exports_external.number().int().nonnegative() });
|
|
39638
|
+
var CommunityReadErrorSchema = exports_external.strictObject({ contractVersion: exports_external.literal(COMMUNITY_CONTRACT_VERSION), error: exports_external.strictObject({
|
|
39639
|
+
code: exports_external.enum(["invalid_input", "invalid_reply_target", "unauthenticated", "not_found", "not_allowed", "blocked", "idempotency_conflict", "rate_limited", "temporarily_unavailable"]),
|
|
39640
|
+
message: exports_external.string(),
|
|
39641
|
+
retryable: exports_external.boolean()
|
|
39642
|
+
}) });
|
|
39643
|
+
var legacyChannelResourceSchema = CommunityChannelResourceSchema.strip().extend({
|
|
39644
|
+
topic: CommunityChannelResourceSchema.shape.topic.nullish().transform((value) => value ?? ""),
|
|
39645
|
+
position: CommunityChannelResourceSchema.shape.position.nullish().transform((value) => value ?? 0),
|
|
39646
|
+
messageCount: CommunityChannelResourceSchema.shape.messageCount.nullish().transform((value) => value ?? 0),
|
|
39647
|
+
categoryId: nullableId.default(null),
|
|
39648
|
+
parentChannelId: nullableId.default(null),
|
|
39649
|
+
parentMessageId: nullableId.default(null),
|
|
39650
|
+
creatorId: nullableId.default(null),
|
|
39651
|
+
lastMessageAt: CommunityChannelResourceSchema.shape.lastMessageAt.default(null),
|
|
39652
|
+
archived: legacyArchivedSchema
|
|
39653
|
+
});
|
|
39654
|
+
var legacyMessageResourceSchema = CommunityMessageResourceSchema.strip().extend({
|
|
39655
|
+
channelId: id2.optional(),
|
|
39656
|
+
replyToId: nullableId.optional(),
|
|
39657
|
+
clientNonce: CommunityMessageResourceSchema.shape.clientNonce.default(null),
|
|
39658
|
+
attachments: CommunityMessageResourceSchema.shape.attachments.default([]),
|
|
39659
|
+
embeds: CommunityMessageResourceSchema.shape.embeds.nullable().transform((value) => value ?? undefined)
|
|
39660
|
+
});
|
|
39661
|
+
|
|
39662
|
+
// ../shared/src/community-ws-events.ts
|
|
39663
|
+
var string4 = exports_external.string();
|
|
39664
|
+
var nullableString = string4.nullable();
|
|
39665
|
+
var channelTypeSchema = CommunityChannelResourceSchema.shape.type.extract(["text", "forum"]);
|
|
39385
39666
|
var messageAttachmentSchema = exports_external.strictObject({
|
|
39386
39667
|
id: string4,
|
|
39387
39668
|
filename: string4,
|
|
@@ -39392,30 +39673,29 @@ var messageAttachmentSchema = exports_external.strictObject({
|
|
|
39392
39673
|
width: exports_external.number().nullable().optional(),
|
|
39393
39674
|
height: exports_external.number().nullable().optional()
|
|
39394
39675
|
});
|
|
39395
|
-
var messageSchema =
|
|
39676
|
+
var messageSchema = CommunityMessageResourceSchema.pick({
|
|
39677
|
+
content: true,
|
|
39678
|
+
type: true,
|
|
39679
|
+
systemKind: true,
|
|
39680
|
+
authorAvatar: true,
|
|
39681
|
+
authorAvatarVersion: true,
|
|
39682
|
+
mentionType: true,
|
|
39683
|
+
embeds: true,
|
|
39684
|
+
createdAt: true,
|
|
39685
|
+
approval: true
|
|
39686
|
+
}).extend({
|
|
39396
39687
|
id: string4,
|
|
39397
39688
|
seq: exports_external.number(),
|
|
39398
39689
|
authorId: string4,
|
|
39399
39690
|
authorName: string4,
|
|
39400
|
-
|
|
39401
|
-
authorAvatarVersion: exports_external.number().int().nonnegative(),
|
|
39402
|
-
content: string4,
|
|
39403
|
-
type: exports_external.enum(["chat", "system"]),
|
|
39404
|
-
systemKind: exports_external.literal("thread").optional(),
|
|
39405
|
-
mentionType: mentionTypeSchema.nullable().optional(),
|
|
39691
|
+
authorAvatarVersion: CommunityMessageResourceSchema.shape.authorAvatarVersion.unwrap(),
|
|
39406
39692
|
replyToId: nullableString.optional(),
|
|
39407
|
-
replyTo:
|
|
39693
|
+
replyTo: CommunityMessageResourceSchema.shape.replyTo.unwrap().extend({
|
|
39408
39694
|
id: string4,
|
|
39409
|
-
authorId: string4.optional()
|
|
39410
|
-
authorName: string4,
|
|
39411
|
-
text: string4,
|
|
39412
|
-
deleted: exports_external.boolean().optional()
|
|
39695
|
+
authorId: string4.optional()
|
|
39413
39696
|
}).optional(),
|
|
39414
|
-
embeds: exports_external.array(exports_external.unknown()).optional(),
|
|
39415
39697
|
attachments: exports_external.array(messageAttachmentSchema).optional(),
|
|
39416
|
-
|
|
39417
|
-
clientNonce: string4.optional(),
|
|
39418
|
-
approval: FriendApprovalPayloadSchema.optional()
|
|
39698
|
+
clientNonce: string4.optional()
|
|
39419
39699
|
});
|
|
39420
39700
|
var communityMessageCreateSchema = exports_external.strictObject({
|
|
39421
39701
|
type: exports_external.literal("community:message.create"),
|
|
@@ -39562,6 +39842,14 @@ var communityChannelMemberRemoveSchema = exports_external.strictObject({
|
|
|
39562
39842
|
channelId: string4,
|
|
39563
39843
|
userId: string4
|
|
39564
39844
|
});
|
|
39845
|
+
var communityChannelMembershipChangeSchema = exports_external.strictObject({
|
|
39846
|
+
type: exports_external.literal("community:channel.membership.change"),
|
|
39847
|
+
channelId: string4,
|
|
39848
|
+
serverId: string4.nullable(),
|
|
39849
|
+
userId: string4,
|
|
39850
|
+
relation: CommunityMemberRelationSchema.shape.relation,
|
|
39851
|
+
present: exports_external.boolean()
|
|
39852
|
+
});
|
|
39565
39853
|
var communityCategoryCreateSchema = exports_external.strictObject({
|
|
39566
39854
|
type: exports_external.literal("community:category.create"),
|
|
39567
39855
|
serverId: string4,
|
|
@@ -39646,7 +39934,8 @@ var communityFriendRemoveSchema = exports_external.strictObject({
|
|
|
39646
39934
|
});
|
|
39647
39935
|
var communityFriendBlockSchema = exports_external.strictObject({
|
|
39648
39936
|
type: exports_external.literal("community:friend.block"),
|
|
39649
|
-
userId: string4
|
|
39937
|
+
userId: string4,
|
|
39938
|
+
blockedByViewer: exports_external.boolean().optional()
|
|
39650
39939
|
});
|
|
39651
39940
|
var communityInviteCreateSchema = exports_external.strictObject({
|
|
39652
39941
|
type: exports_external.literal("community:invite.create"),
|
|
@@ -39789,6 +40078,7 @@ var CommunityWsEventDiscriminatedSchema = exports_external.discriminatedUnion("t
|
|
|
39789
40078
|
communityChannelReorderSchema,
|
|
39790
40079
|
communityChannelMemberAddSchema,
|
|
39791
40080
|
communityChannelMemberRemoveSchema,
|
|
40081
|
+
communityChannelMembershipChangeSchema,
|
|
39792
40082
|
communityCategoryCreateSchema,
|
|
39793
40083
|
communityCategoryUpdateSchema,
|
|
39794
40084
|
communityCategoryDeleteSchema,
|
|
@@ -39837,6 +40127,7 @@ var WS_EVENTS = {
|
|
|
39837
40127
|
CHANNEL_REORDER: "community:channel.reorder",
|
|
39838
40128
|
CHANNEL_MEMBER_ADD: "community:channel.member_add",
|
|
39839
40129
|
CHANNEL_MEMBER_REMOVE: "community:channel.member_remove",
|
|
40130
|
+
CHANNEL_MEMBERSHIP_CHANGE: "community:channel.membership.change",
|
|
39840
40131
|
CATEGORY_CREATE: "community:category.create",
|
|
39841
40132
|
CATEGORY_UPDATE: "community:category.update",
|
|
39842
40133
|
CATEGORY_DELETE: "community:category.delete",
|
|
@@ -39906,6 +40197,8 @@ var batchShape = exports_external.strictObject({
|
|
|
39906
40197
|
unreadMentionUserIds: targetList,
|
|
39907
40198
|
mentionUserIds: targetList,
|
|
39908
40199
|
memberAdded: memberAddedSchema.optional(),
|
|
40200
|
+
joinedParticipantUserIds: targetList.optional(),
|
|
40201
|
+
rosterRefreshUserId: target.optional(),
|
|
39909
40202
|
parentProjection: exports_external.unknown().optional(),
|
|
39910
40203
|
parentProjectionUserIds: targetList.optional()
|
|
39911
40204
|
});
|
|
@@ -41029,9 +41322,9 @@ function compactLines(input2) {
|
|
|
41029
41322
|
}
|
|
41030
41323
|
return suffix;
|
|
41031
41324
|
}
|
|
41032
|
-
function isRealDirectory(
|
|
41325
|
+
function isRealDirectory(path14) {
|
|
41033
41326
|
try {
|
|
41034
|
-
return fs7.lstatSync(
|
|
41327
|
+
return fs7.lstatSync(path14).isDirectory();
|
|
41035
41328
|
} catch {
|
|
41036
41329
|
return false;
|
|
41037
41330
|
}
|
|
@@ -42097,26 +42390,26 @@ function createTimelineRecorder(opts) {
|
|
|
42097
42390
|
}
|
|
42098
42391
|
}
|
|
42099
42392
|
// src/discovery.ts
|
|
42100
|
-
import * as
|
|
42393
|
+
import * as path14 from "path";
|
|
42101
42394
|
import * as fs8 from "fs";
|
|
42102
42395
|
import { fileURLToPath } from "url";
|
|
42103
42396
|
function resolveAlookCliPath(moduleDir) {
|
|
42104
|
-
const thisDir = moduleDir ??
|
|
42105
|
-
const target2 =
|
|
42397
|
+
const thisDir = moduleDir ?? path14.dirname(fileURLToPath(import.meta.url));
|
|
42398
|
+
const target2 = path14.basename(thisDir) === "dist" ? path14.resolve(thisDir, "cli", "index.js") : path14.resolve(thisDir, "..", "scripts", "alook-shim.mjs");
|
|
42106
42399
|
return fs8.existsSync(target2) ? target2 : null;
|
|
42107
42400
|
}
|
|
42108
42401
|
function deriveCliFallbackCandidates(cliPath) {
|
|
42109
42402
|
if (!cliPath)
|
|
42110
42403
|
return [];
|
|
42111
|
-
const normalized = cliPath.split(
|
|
42404
|
+
const normalized = cliPath.split(path14.sep).join("/");
|
|
42112
42405
|
const marker = "/node_modules/";
|
|
42113
42406
|
const idx = normalized.indexOf(marker);
|
|
42114
42407
|
if (idx === -1)
|
|
42115
42408
|
return [];
|
|
42116
42409
|
const globalRoot = cliPath.slice(0, idx + marker.length - 1);
|
|
42117
|
-
const tail =
|
|
42410
|
+
const tail = path14.join("dist", "cli", "index.js");
|
|
42118
42411
|
return [
|
|
42119
|
-
|
|
42412
|
+
path14.join(globalRoot, "@alook", "daemon", tail)
|
|
42120
42413
|
].filter((candidate) => candidate !== cliPath);
|
|
42121
42414
|
}
|
|
42122
42415
|
function resolveAlookCliPathWithFallback(primary) {
|
|
@@ -42136,20 +42429,20 @@ async function detectRuntimes() {
|
|
|
42136
42429
|
const ids = listRuntimeIds();
|
|
42137
42430
|
const results = [];
|
|
42138
42431
|
const nowIso = new Date().toISOString();
|
|
42139
|
-
for (const
|
|
42432
|
+
for (const id3 of ids) {
|
|
42140
42433
|
try {
|
|
42141
|
-
const driver = getDriver(
|
|
42434
|
+
const driver = getDriver(id3);
|
|
42142
42435
|
const probe = await driver.probe();
|
|
42143
42436
|
if (probe.status === "healthy") {
|
|
42144
42437
|
results.push({
|
|
42145
|
-
id:
|
|
42438
|
+
id: id3,
|
|
42146
42439
|
status: "healthy",
|
|
42147
42440
|
version: probe.version,
|
|
42148
42441
|
reasoning: probe.reasoning
|
|
42149
42442
|
});
|
|
42150
42443
|
} else {
|
|
42151
42444
|
results.push({
|
|
42152
|
-
id:
|
|
42445
|
+
id: id3,
|
|
42153
42446
|
status: "unhealthy",
|
|
42154
42447
|
lastError: probe.error.code ?? "probe_failed",
|
|
42155
42448
|
lastErrorAt: nowIso
|
|
@@ -42157,7 +42450,7 @@ async function detectRuntimes() {
|
|
|
42157
42450
|
}
|
|
42158
42451
|
} catch (err) {
|
|
42159
42452
|
results.push({
|
|
42160
|
-
id:
|
|
42453
|
+
id: id3,
|
|
42161
42454
|
status: "unhealthy",
|
|
42162
42455
|
lastError: err?.code ?? "probe_threw",
|
|
42163
42456
|
lastErrorAt: nowIso
|
|
@@ -42251,15 +42544,15 @@ class MessageReminderScheduler {
|
|
|
42251
42544
|
const startedAt = this.now();
|
|
42252
42545
|
const dueAt = startedAt + input2.remindAfterMs;
|
|
42253
42546
|
const sentRef = `${input2.channel}#${input2.sentSeq}`;
|
|
42254
|
-
const
|
|
42547
|
+
const record7 = {
|
|
42255
42548
|
...input2,
|
|
42256
42549
|
sentRef,
|
|
42257
42550
|
startedAt,
|
|
42258
42551
|
dueAt,
|
|
42259
42552
|
timer: undefined
|
|
42260
42553
|
};
|
|
42261
|
-
|
|
42262
|
-
if (this.reminders.get(key) !==
|
|
42554
|
+
record7.timer = this.setTimer(() => {
|
|
42555
|
+
if (this.reminders.get(key) !== record7)
|
|
42263
42556
|
return;
|
|
42264
42557
|
this.reminders.delete(key);
|
|
42265
42558
|
try {
|
|
@@ -42270,8 +42563,8 @@ class MessageReminderScheduler {
|
|
|
42270
42563
|
Promise.resolve(delivery).catch(() => {});
|
|
42271
42564
|
} catch {}
|
|
42272
42565
|
}, input2.remindAfterMs);
|
|
42273
|
-
|
|
42274
|
-
this.reminders.set(key,
|
|
42566
|
+
record7.timer.unref?.();
|
|
42567
|
+
this.reminders.set(key, record7);
|
|
42275
42568
|
return { armed: true, dueAt };
|
|
42276
42569
|
}
|
|
42277
42570
|
observe(agentId, channel2, latestSeq) {
|
|
@@ -42311,7 +42604,7 @@ class MessageReminderScheduler {
|
|
|
42311
42604
|
|
|
42312
42605
|
// src/manager/agentDriverHost.ts
|
|
42313
42606
|
import { randomUUID as randomUUID8 } from "node:crypto";
|
|
42314
|
-
import { homedir as
|
|
42607
|
+
import { homedir as homedir11 } from "node:os";
|
|
42315
42608
|
import { join as join16 } from "node:path";
|
|
42316
42609
|
|
|
42317
42610
|
// src/drivers/gitIdentityEnv.ts
|
|
@@ -42437,7 +42730,7 @@ function createDaemonAgentDriverHost(ctx, onRawLine) {
|
|
|
42437
42730
|
hostUser: readHostGitIdentity() ?? undefined
|
|
42438
42731
|
}),
|
|
42439
42732
|
platformProtected: {
|
|
42440
|
-
ALOOK_HOME: process.env.ALOOK_HOME ?? join16(
|
|
42733
|
+
ALOOK_HOME: process.env.ALOOK_HOME ?? join16(homedir11(), ".alook"),
|
|
42441
42734
|
ALOOK_ID: ctx.agentId,
|
|
42442
42735
|
ALOOK_CLI: ctx.agentCliPath,
|
|
42443
42736
|
ALOOK_SERVER_URL: ctx.config.serverUrl,
|
|
@@ -42543,7 +42836,7 @@ class DaemonSelfSleepScheduler {
|
|
|
42543
42836
|
}
|
|
42544
42837
|
|
|
42545
42838
|
// src/telemetry/dailyTokenUsage.ts
|
|
42546
|
-
import { chmod, mkdir, open as
|
|
42839
|
+
import { chmod, mkdir, open as open3, readFile as readFile3, rename, rm } from "node:fs/promises";
|
|
42547
42840
|
import { dirname as dirname5, join as join17 } from "node:path";
|
|
42548
42841
|
import { randomUUID as randomUUID9 } from "node:crypto";
|
|
42549
42842
|
var TOKEN_USAGE_WINDOW_DAYS = 30;
|
|
@@ -42796,7 +43089,7 @@ class DailyTokenUsageStore {
|
|
|
42796
43089
|
await mkdir(directory, { recursive: true, mode: 448 });
|
|
42797
43090
|
const temporary = `${this.filePath}.${randomUUID9()}.tmp`;
|
|
42798
43091
|
try {
|
|
42799
|
-
const file2 = await
|
|
43092
|
+
const file2 = await open3(temporary, "wx", 384);
|
|
42800
43093
|
try {
|
|
42801
43094
|
await file2.writeFile(JSON.stringify(this.data), { encoding: "utf8" });
|
|
42802
43095
|
await file2.sync();
|
|
@@ -42806,7 +43099,7 @@ class DailyTokenUsageStore {
|
|
|
42806
43099
|
await rename(temporary, this.filePath);
|
|
42807
43100
|
await chmod(this.filePath, 384);
|
|
42808
43101
|
try {
|
|
42809
|
-
const directoryHandle = await
|
|
43102
|
+
const directoryHandle = await open3(directory, "r");
|
|
42810
43103
|
try {
|
|
42811
43104
|
await directoryHandle.sync();
|
|
42812
43105
|
} finally {
|
|
@@ -42857,7 +43150,7 @@ function appendRecentContextToPrompt(prompt, result) {
|
|
|
42857
43150
|
return lines.join(`
|
|
42858
43151
|
`);
|
|
42859
43152
|
}
|
|
42860
|
-
function createRecentContextPromptAppender(discover, recentSessionFilesTopK =
|
|
43153
|
+
function createRecentContextPromptAppender(discover, recentSessionFilesTopK = 20, recentProjectsTopK = 5) {
|
|
42861
43154
|
return async (prompt, runtimeConfig) => {
|
|
42862
43155
|
const selected = toAgentBackendSelection(runtimeConfig);
|
|
42863
43156
|
const command = selected.config.command;
|
|
@@ -42891,8 +43184,6 @@ var RUNTIME_RAW_TRACE_MAX_BYTES = 8 * 1024 * 1024;
|
|
|
42891
43184
|
var RUNTIME_RAW_TRACE_AGENT_IDS_ENV = "ALOOK_RUNTIME_RAW_TRACE_AGENT_IDS";
|
|
42892
43185
|
var STATUS_WRITE_INTERVAL_MS = 5000;
|
|
42893
43186
|
var TOKEN_USAGE_BACKENDS = new Set(["claude", "codex", "grok", "opencode", "pi", "antigravity"]);
|
|
42894
|
-
var ONBOARDING_RECENT_SESSION_FILES_TOP_K = 10;
|
|
42895
|
-
var ONBOARDING_RECENT_PROJECTS_TOP_K = 5;
|
|
42896
43187
|
function parseRuntimeRawTraceAgentIds(value) {
|
|
42897
43188
|
return new Set((value ?? "").split(",").map((agentId) => agentId.trim()).filter((agentId) => agentId.length > 0 && agentId !== "*"));
|
|
42898
43189
|
}
|
|
@@ -42903,13 +43194,13 @@ function createRuntimeRawLineTap(args) {
|
|
|
42903
43194
|
const maxBytes = args.maxBytes ?? RUNTIME_RAW_TRACE_MAX_BYTES;
|
|
42904
43195
|
const sinks = new Map;
|
|
42905
43196
|
const warned = new Set;
|
|
42906
|
-
const warnOnce = (agentId,
|
|
43197
|
+
const warnOnce = (agentId, path15, operation, error62) => {
|
|
42907
43198
|
if (warned.has(agentId))
|
|
42908
43199
|
return;
|
|
42909
43200
|
warned.add(agentId);
|
|
42910
43201
|
args.logger.warn("runtime raw trace sink failed", {
|
|
42911
43202
|
agentId,
|
|
42912
|
-
path:
|
|
43203
|
+
path: path15,
|
|
42913
43204
|
operation,
|
|
42914
43205
|
error: error62 instanceof Error ? error62.message : String(error62)
|
|
42915
43206
|
});
|
|
@@ -42918,10 +43209,10 @@ function createRuntimeRawLineTap(args) {
|
|
|
42918
43209
|
if (!args.enabledAgentIds.has(agentId))
|
|
42919
43210
|
return;
|
|
42920
43211
|
const encodedAgentId = encodeURIComponent(agentId).replace(/\./g, "%2E");
|
|
42921
|
-
const
|
|
43212
|
+
const path15 = `${traceDir}/runtime-raw-events-${encodedAgentId}.jsonl`;
|
|
42922
43213
|
const serializedBytes = Buffer.byteLength(line, "utf8") + 1;
|
|
42923
43214
|
if (serializedBytes > maxBytes) {
|
|
42924
|
-
warnOnce(agentId,
|
|
43215
|
+
warnOnce(agentId, path15, "oversize", new Error(`raw line is ${serializedBytes} bytes; max is ${maxBytes}`));
|
|
42925
43216
|
return;
|
|
42926
43217
|
}
|
|
42927
43218
|
let sink = sinks.get(agentId);
|
|
@@ -42929,12 +43220,12 @@ function createRuntimeRawLineTap(args) {
|
|
|
42929
43220
|
try {
|
|
42930
43221
|
mkdirSync8(traceDir, { recursive: true });
|
|
42931
43222
|
} catch (error62) {
|
|
42932
|
-
warnOnce(agentId,
|
|
43223
|
+
warnOnce(agentId, path15, "mkdir", error62);
|
|
42933
43224
|
}
|
|
42934
|
-
sink = createRotatingFileSink(
|
|
43225
|
+
sink = createRotatingFileSink(path15, maxBytes, {
|
|
42935
43226
|
mode: 384,
|
|
42936
43227
|
hardMaxBytes: true,
|
|
42937
|
-
onError: ({ operation, error: error62 }) => warnOnce(agentId,
|
|
43228
|
+
onError: ({ operation, error: error62 }) => warnOnce(agentId, path15, operation, error62)
|
|
42938
43229
|
});
|
|
42939
43230
|
sinks.set(agentId, sink);
|
|
42940
43231
|
}
|
|
@@ -43027,8 +43318,8 @@ function createBuiltinDaemonSessionFactory(onRuntimeRawLine) {
|
|
|
43027
43318
|
async function createDaemon(opts) {
|
|
43028
43319
|
const log2 = opts.logger ?? createLogger({ header: "@alook/daemon" });
|
|
43029
43320
|
const recentContextSdk = createAgentDriverSdk();
|
|
43030
|
-
const appendRecentContext = createRecentContextPromptAppender((input2) => recentContextSdk.discoverRecentContext(input2)
|
|
43031
|
-
const fallbackBase = (process.env.ALOOK_PROJECT_ROOT || `${
|
|
43321
|
+
const appendRecentContext = createRecentContextPromptAppender((input2) => recentContextSdk.discoverRecentContext(input2));
|
|
43322
|
+
const fallbackBase = (process.env.ALOOK_PROJECT_ROOT || `${homedir12()}/.alook`) + "/daemon";
|
|
43032
43323
|
const workingDirectoryBase = opts.workingDirectoryBase ?? fallbackBase;
|
|
43033
43324
|
const workdirFor = (agentId) => `${workingDirectoryBase}/${agentId}`;
|
|
43034
43325
|
const dailyTokenUsage2 = new DailyTokenUsageStore(workingDirectoryBase);
|