@superatomai/sdk-node 0.0.90-dsp → 0.0.92-dsp
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +16 -2
- package/dist/index.d.ts +16 -2
- package/dist/index.js +102 -55
- package/dist/index.mjs +182 -138
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -24591,6 +24591,9 @@ async function handleDashboardAgentRequest(data, collections, sendMessage) {
|
|
|
24591
24591
|
}
|
|
24592
24592
|
|
|
24593
24593
|
// src/codingAgent/drivers/codex.ts
|
|
24594
|
+
import * as fs8 from "fs";
|
|
24595
|
+
import * as os2 from "os";
|
|
24596
|
+
import * as path9 from "path";
|
|
24594
24597
|
var dynamicImport = new Function("specifier", "return import(specifier)");
|
|
24595
24598
|
var codexModulePromise = null;
|
|
24596
24599
|
function loadCodex() {
|
|
@@ -24688,17 +24691,51 @@ function markerFor(event) {
|
|
|
24688
24691
|
return null;
|
|
24689
24692
|
}
|
|
24690
24693
|
}
|
|
24691
|
-
function buildEnv(opts) {
|
|
24692
|
-
|
|
24694
|
+
function buildEnv(opts, provider = null) {
|
|
24695
|
+
const extra = { ...provider?.env ?? {}, ...opts.env ?? {} };
|
|
24696
|
+
if (opts.inheritEnv) return Object.keys(extra).length ? { ...process.env, ...extra } : void 0;
|
|
24693
24697
|
const env = {};
|
|
24694
24698
|
for (const [k, v] of Object.entries(process.env)) {
|
|
24695
24699
|
if (v === void 0) continue;
|
|
24696
24700
|
if (envAllowed(k)) env[k] = v;
|
|
24697
24701
|
}
|
|
24698
|
-
return { ...env, ...
|
|
24702
|
+
return { ...env, ...extra };
|
|
24699
24703
|
}
|
|
24700
24704
|
var CODEX_DOC_MAX_BYTES = 256 * 1024;
|
|
24701
|
-
|
|
24705
|
+
var CODEX_OPENROUTER_KEY_ENV = "CODEX_OPENROUTER_API_KEY";
|
|
24706
|
+
function tomlTopLevel(toml) {
|
|
24707
|
+
const i = toml.search(/^\s*\[/m);
|
|
24708
|
+
return i < 0 ? toml : toml.slice(0, i);
|
|
24709
|
+
}
|
|
24710
|
+
function readCodexConfig(env) {
|
|
24711
|
+
try {
|
|
24712
|
+
return fs8.readFileSync(path9.join(env.CODEX_HOME || path9.join(os2.homedir(), ".codex"), "config.toml"), "utf-8");
|
|
24713
|
+
} catch {
|
|
24714
|
+
return "";
|
|
24715
|
+
}
|
|
24716
|
+
}
|
|
24717
|
+
function codexDefaultProvider(env = process.env, configToml) {
|
|
24718
|
+
const choice = env.CODEX_MODEL_PROVIDER?.trim();
|
|
24719
|
+
if (choice && choice !== "openrouter") return null;
|
|
24720
|
+
if (!choice && /^\s*model_provider\s*=/m.test(tomlTopLevel(configToml ?? readCodexConfig(env)))) return null;
|
|
24721
|
+
const key = env.OPENROUTER_API_KEY?.trim();
|
|
24722
|
+
if (!key) return null;
|
|
24723
|
+
const root = env.SUPERATOM_LLM_PROXY_URL?.trim();
|
|
24724
|
+
const baseUrl = env.OPENROUTER_BASE_URL?.trim() || (root ? `${root.replace(/\/+$/, "")}/openrouter` : "https://openrouter.ai/api/v1");
|
|
24725
|
+
return {
|
|
24726
|
+
config: {
|
|
24727
|
+
model_provider: "openrouter",
|
|
24728
|
+
model_providers: { openrouter: { name: "OpenRouter", base_url: baseUrl, env_key: CODEX_OPENROUTER_KEY_ENV, wire_api: "responses" } },
|
|
24729
|
+
// codex's default compacts at ~112k tokens, well short of the model's window.
|
|
24730
|
+
model_auto_compact_token_limit: 23e4
|
|
24731
|
+
},
|
|
24732
|
+
env: { [CODEX_OPENROUTER_KEY_ENV]: key }
|
|
24733
|
+
};
|
|
24734
|
+
}
|
|
24735
|
+
function codexModelFor(model, provider) {
|
|
24736
|
+
return provider && model && !model.includes("/") ? `openai/${model}` : model;
|
|
24737
|
+
}
|
|
24738
|
+
function codexRunConfig(opts, provider = null) {
|
|
24702
24739
|
return {
|
|
24703
24740
|
// Tools reach codex as MCP servers; each server's name shows up on
|
|
24704
24741
|
// every tool event, so the runner can tell ours from codex's own.
|
|
@@ -24707,12 +24744,16 @@ function codexRunConfig(opts) {
|
|
|
24707
24744
|
// the agent with no instructions at all. AGENTS.md still wins if present.
|
|
24708
24745
|
...opts.instructionsFile && opts.instructionsFile !== "AGENTS.md" ? { project_doc_fallback_filenames: [opts.instructionsFile] } : {},
|
|
24709
24746
|
project_doc_max_bytes: CODEX_DOC_MAX_BYTES,
|
|
24747
|
+
// Without it reasoning items arrive empty, so a run shows no thinking.
|
|
24748
|
+
model_reasoning_summary: "detailed",
|
|
24749
|
+
...provider?.config ?? {},
|
|
24710
24750
|
// Last: a deployment's own value wins.
|
|
24711
24751
|
...opts.extraConfig ?? {}
|
|
24712
24752
|
};
|
|
24713
24753
|
}
|
|
24714
24754
|
function createCodexSession(opts) {
|
|
24715
|
-
const
|
|
24755
|
+
const provider = opts.apiKey || opts.baseUrl ? null : codexDefaultProvider();
|
|
24756
|
+
const model = codexModelFor(opts.model ?? process.env.CODEX_AGENT_MODEL, provider);
|
|
24716
24757
|
let thread = null;
|
|
24717
24758
|
let resumeId = opts.resumeId;
|
|
24718
24759
|
let threadId = opts.resumeId;
|
|
@@ -24733,11 +24774,11 @@ function createCodexSession(opts) {
|
|
|
24733
24774
|
async function ensureThread() {
|
|
24734
24775
|
if (thread) return thread;
|
|
24735
24776
|
const { Codex } = await loadCodex();
|
|
24736
|
-
const config2 = codexRunConfig(opts);
|
|
24777
|
+
const config2 = codexRunConfig(opts, provider);
|
|
24737
24778
|
const codex = new Codex({
|
|
24738
24779
|
...opts.apiKey ? { apiKey: opts.apiKey } : {},
|
|
24739
24780
|
...opts.baseUrl ? { baseUrl: opts.baseUrl } : {},
|
|
24740
|
-
env: buildEnv(opts),
|
|
24781
|
+
env: buildEnv(opts, provider),
|
|
24741
24782
|
config: config2
|
|
24742
24783
|
});
|
|
24743
24784
|
thread = resumeId ? codex.resumeThread(resumeId, threadOptions()) : codex.startThread(threadOptions());
|
|
@@ -24900,8 +24941,8 @@ ${marker}
|
|
|
24900
24941
|
|
|
24901
24942
|
// src/codingAgent/drivers/pi.ts
|
|
24902
24943
|
import * as crypto3 from "crypto";
|
|
24903
|
-
import * as
|
|
24904
|
-
import * as
|
|
24944
|
+
import * as fs9 from "fs";
|
|
24945
|
+
import * as path10 from "path";
|
|
24905
24946
|
var dynamicImport2 = new Function("specifier", "return import(specifier)");
|
|
24906
24947
|
var piModulePromise = null;
|
|
24907
24948
|
function loadPi() {
|
|
@@ -25068,9 +25109,9 @@ function startSweeper() {
|
|
|
25068
25109
|
}
|
|
25069
25110
|
function readInstructions(opts) {
|
|
25070
25111
|
if (!opts.instructionsFile) return void 0;
|
|
25071
|
-
const file =
|
|
25112
|
+
const file = path10.resolve(opts.cwd, opts.instructionsFile);
|
|
25072
25113
|
try {
|
|
25073
|
-
return { file, content:
|
|
25114
|
+
return { file, content: fs9.readFileSync(file, "utf-8") };
|
|
25074
25115
|
} catch {
|
|
25075
25116
|
return void 0;
|
|
25076
25117
|
}
|
|
@@ -25093,7 +25134,7 @@ function createPiSession(opts) {
|
|
|
25093
25134
|
agentsFilesOverride: (base) => instructions ? { agentsFiles: [{ path: instructions.file, content: instructions.content }] } : base
|
|
25094
25135
|
});
|
|
25095
25136
|
await resourceLoader.reload();
|
|
25096
|
-
const sessionManager = resumeFile &&
|
|
25137
|
+
const sessionManager = resumeFile && fs9.existsSync(resumeFile) ? pi.SessionManager.open(resumeFile) : pi.SessionManager.create(opts.cwd);
|
|
25097
25138
|
const live = {
|
|
25098
25139
|
running: false,
|
|
25099
25140
|
transcript: [],
|
|
@@ -25312,11 +25353,11 @@ function createCodingAgentSession(harness, opts) {
|
|
|
25312
25353
|
}
|
|
25313
25354
|
|
|
25314
25355
|
// src/codingAgent/registry.ts
|
|
25315
|
-
import * as
|
|
25356
|
+
import * as path11 from "path";
|
|
25316
25357
|
var agents = /* @__PURE__ */ new Map();
|
|
25317
25358
|
var config = {
|
|
25318
|
-
promptRoot:
|
|
25319
|
-
runtimeDir:
|
|
25359
|
+
promptRoot: path11.join(process.cwd(), ".prompts", "coding-agents"),
|
|
25360
|
+
runtimeDir: path11.join(process.cwd(), ".coding-agent-runtime"),
|
|
25320
25361
|
harness: "codex",
|
|
25321
25362
|
keepRuns: 20,
|
|
25322
25363
|
keepThreads: 200
|
|
@@ -25355,13 +25396,13 @@ function getCodingAgentsConfig() {
|
|
|
25355
25396
|
return config;
|
|
25356
25397
|
}
|
|
25357
25398
|
function resolvePromptDir(def) {
|
|
25358
|
-
return def.promptDir ||
|
|
25399
|
+
return def.promptDir || path11.join(config.promptRoot, def.id);
|
|
25359
25400
|
}
|
|
25360
25401
|
|
|
25361
25402
|
// src/codingAgent/runner.ts
|
|
25362
|
-
import * as
|
|
25403
|
+
import * as fs10 from "fs";
|
|
25363
25404
|
import * as fsp from "fs/promises";
|
|
25364
|
-
import * as
|
|
25405
|
+
import * as path12 from "path";
|
|
25365
25406
|
var DEFAULT_TIMEOUT_MS = 15 * 60 * 1e3;
|
|
25366
25407
|
var inFlight = /* @__PURE__ */ new Set();
|
|
25367
25408
|
function slug(v) {
|
|
@@ -25371,11 +25412,11 @@ function resolveScope(def, opts) {
|
|
|
25371
25412
|
const scope = def.scope ?? (def.mode === "chat" ? "thread" : "project");
|
|
25372
25413
|
if (scope === "thread") {
|
|
25373
25414
|
const id = slug(opts.threadId || "default");
|
|
25374
|
-
return { key: `thread:${id}`, dirName:
|
|
25415
|
+
return { key: `thread:${id}`, dirName: path12.join("threads", id) };
|
|
25375
25416
|
}
|
|
25376
25417
|
if (scope === "user") {
|
|
25377
25418
|
const id = slug(opts.userId || "anonymous");
|
|
25378
|
-
return { key: `user:${id}`, dirName:
|
|
25419
|
+
return { key: `user:${id}`, dirName: path12.join("users", id) };
|
|
25379
25420
|
}
|
|
25380
25421
|
return { key: "project", dirName: "_project" };
|
|
25381
25422
|
}
|
|
@@ -25384,30 +25425,30 @@ function makeRunId() {
|
|
|
25384
25425
|
return `${t}-${Math.random().toString(36).slice(2, 8)}`;
|
|
25385
25426
|
}
|
|
25386
25427
|
function statePath(scopeDir) {
|
|
25387
|
-
return
|
|
25428
|
+
return path12.join(scopeDir, "_state.json");
|
|
25388
25429
|
}
|
|
25389
25430
|
function loadState(scopeDir) {
|
|
25390
25431
|
try {
|
|
25391
|
-
return JSON.parse(
|
|
25432
|
+
return JSON.parse(fs10.readFileSync(statePath(scopeDir), "utf-8"));
|
|
25392
25433
|
} catch {
|
|
25393
25434
|
return { turns: 0, updatedAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
25394
25435
|
}
|
|
25395
25436
|
}
|
|
25396
25437
|
function saveState(scopeDir, state) {
|
|
25397
25438
|
try {
|
|
25398
|
-
|
|
25399
|
-
|
|
25439
|
+
fs10.mkdirSync(scopeDir, { recursive: true });
|
|
25440
|
+
fs10.writeFileSync(statePath(scopeDir), JSON.stringify({ ...state, updatedAt: (/* @__PURE__ */ new Date()).toISOString() }, null, 2));
|
|
25400
25441
|
} catch (err) {
|
|
25401
25442
|
logger.warn(`[CodingAgent] failed to persist session state: ${err?.message ?? err}`);
|
|
25402
25443
|
}
|
|
25403
25444
|
}
|
|
25404
25445
|
async function clearTransient(dir) {
|
|
25405
|
-
await fsp.rm(
|
|
25446
|
+
await fsp.rm(path12.join(dir, "input"), { recursive: true, force: true });
|
|
25406
25447
|
}
|
|
25407
25448
|
function createWorkspace(dir, runId) {
|
|
25408
|
-
const abs = (rel) =>
|
|
25449
|
+
const abs = (rel) => path12.join(dir, rel);
|
|
25409
25450
|
const ensureDir = async (rel) => {
|
|
25410
|
-
await fsp.mkdir(
|
|
25451
|
+
await fsp.mkdir(path12.dirname(abs(rel)), { recursive: true });
|
|
25411
25452
|
};
|
|
25412
25453
|
return {
|
|
25413
25454
|
dir,
|
|
@@ -25436,7 +25477,7 @@ function createWorkspace(dir, runId) {
|
|
|
25436
25477
|
}
|
|
25437
25478
|
var INSTRUCTIONS_FILE = "system.md";
|
|
25438
25479
|
async function installInstructions(def, ws) {
|
|
25439
|
-
const src =
|
|
25480
|
+
const src = path12.join(resolvePromptDir(def), "system.md");
|
|
25440
25481
|
try {
|
|
25441
25482
|
await ws.write(INSTRUCTIONS_FILE, await fsp.readFile(src, "utf-8"));
|
|
25442
25483
|
} catch {
|
|
@@ -25450,7 +25491,7 @@ async function pruneThreads(agentId, threadsDir, keep) {
|
|
|
25450
25491
|
const dirs = (await fsp.readdir(threadsDir, { withFileTypes: true })).filter((e) => e.isDirectory());
|
|
25451
25492
|
if (dirs.length <= keep) return;
|
|
25452
25493
|
const aged = await Promise.all(dirs.map(async (e) => {
|
|
25453
|
-
const dir =
|
|
25494
|
+
const dir = path12.join(threadsDir, e.name);
|
|
25454
25495
|
const stat2 = await fsp.stat(statePath(dir)).catch(() => fsp.stat(dir));
|
|
25455
25496
|
return { name: e.name, dir, used: stat2.mtimeMs };
|
|
25456
25497
|
}));
|
|
@@ -25470,7 +25511,7 @@ async function pruneRuns(agentDir, keep) {
|
|
|
25470
25511
|
try {
|
|
25471
25512
|
const entries = (await fsp.readdir(agentDir, { withFileTypes: true })).filter((e) => e.isDirectory()).map((e) => e.name).sort();
|
|
25472
25513
|
for (const name of entries.slice(0, Math.max(0, entries.length - keep))) {
|
|
25473
|
-
await fsp.rm(
|
|
25514
|
+
await fsp.rm(path12.join(agentDir, name), { recursive: true, force: true });
|
|
25474
25515
|
}
|
|
25475
25516
|
} catch {
|
|
25476
25517
|
}
|
|
@@ -25488,17 +25529,17 @@ async function runCodingAgent(agentId, options = {}) {
|
|
|
25488
25529
|
}
|
|
25489
25530
|
const cfg = getCodingAgentsConfig();
|
|
25490
25531
|
const runId = makeRunId();
|
|
25491
|
-
const agentDir =
|
|
25532
|
+
const agentDir = path12.join(cfg.runtimeDir, def.id);
|
|
25492
25533
|
const policy = def.session ?? {};
|
|
25493
25534
|
const persistentWorkspace = policy.workspace === "persistent";
|
|
25494
25535
|
const persistentSession = policy.scope === "persistent";
|
|
25495
25536
|
const runAsJob = !(options.chat === true && def.mode === "task");
|
|
25496
25537
|
const { key: scopeKey, dirName } = resolveScope(def, { userId: options.userId, threadId: options.threadId });
|
|
25497
|
-
const scopeDir =
|
|
25498
|
-
const dir = options.workspaceDir || (persistentWorkspace ? scopeDir :
|
|
25499
|
-
|
|
25538
|
+
const scopeDir = path12.join(agentDir, dirName);
|
|
25539
|
+
const dir = options.workspaceDir || (persistentWorkspace ? scopeDir : path12.join(scopeDir, "runs", runId));
|
|
25540
|
+
fs10.mkdirSync(dir, { recursive: true });
|
|
25500
25541
|
if (persistentWorkspace && !options.workspaceDir) {
|
|
25501
|
-
|
|
25542
|
+
fs10.mkdirSync(path12.join(dir, "memory"), { recursive: true });
|
|
25502
25543
|
if (runAsJob) await clearTransient(dir);
|
|
25503
25544
|
}
|
|
25504
25545
|
const lockKey = persistentWorkspace || persistentSession ? `${def.id}:${scopeKey}` : `dir:${dir}`;
|
|
@@ -25607,7 +25648,7 @@ async function runCodingAgent(agentId, options = {}) {
|
|
|
25607
25648
|
onUsage: ctx.onUsage,
|
|
25608
25649
|
// Opt-in only: see stopOnDeliverable. Letting the turn end naturally
|
|
25609
25650
|
// is what makes usage reporting work at all.
|
|
25610
|
-
...outputPath && def.stopOnDeliverable ? { doneWhen: () =>
|
|
25651
|
+
...outputPath && def.stopOnDeliverable ? { doneWhen: () => fs10.existsSync(outputPath) } : {}
|
|
25611
25652
|
},
|
|
25612
25653
|
timeout.signal
|
|
25613
25654
|
);
|
|
@@ -25712,9 +25753,9 @@ Fix ONLY that, and rewrite the same file at the same path. Do not re-run any que
|
|
|
25712
25753
|
logger.info(
|
|
25713
25754
|
`[CodingAgent:${def.id}] ${runAsJob ? "run" : "chat"}=${runId} status=${record.status} ms=${record.ms} tokens=${record.usage.inputTokens}/${record.usage.outputTokens} tools=${record.usage.toolCalls}` + (record.applied ? ` applied="${record.applied.summary}"` : "") + (record.error ? ` error="${record.error}"` : "")
|
|
25714
25755
|
);
|
|
25715
|
-
if (!options.workspaceDir && !persistentWorkspace) await pruneRuns(
|
|
25716
|
-
if (!options.workspaceDir && dirName.startsWith(`threads${
|
|
25717
|
-
await pruneThreads(def.id,
|
|
25756
|
+
if (!options.workspaceDir && !persistentWorkspace) await pruneRuns(path12.join(scopeDir, "runs"), cfg.keepRuns);
|
|
25757
|
+
if (!options.workspaceDir && dirName.startsWith(`threads${path12.sep}`)) {
|
|
25758
|
+
await pruneThreads(def.id, path12.join(agentDir, "threads"), cfg.keepThreads);
|
|
25718
25759
|
}
|
|
25719
25760
|
}
|
|
25720
25761
|
}
|
|
@@ -25774,14 +25815,14 @@ ${assertReadOnlySql.toString().replace("export function", "function")}
|
|
|
25774
25815
|
`;
|
|
25775
25816
|
|
|
25776
25817
|
// src/codingAgent/tools/shims.ts
|
|
25777
|
-
import * as
|
|
25778
|
-
import * as
|
|
25779
|
-
var resolve3 = (target, name) => typeof target === "string" ?
|
|
25818
|
+
import * as fs11 from "fs";
|
|
25819
|
+
import * as path13 from "path";
|
|
25820
|
+
var resolve3 = (target, name) => typeof target === "string" ? path13.join(target, name) : target.pathTo(name);
|
|
25780
25821
|
function writeShims(defs, target) {
|
|
25781
25822
|
for (const def of defs) {
|
|
25782
25823
|
const file = resolve3(target, def.name);
|
|
25783
|
-
|
|
25784
|
-
|
|
25824
|
+
fs11.writeFileSync(file, def.body, "utf-8");
|
|
25825
|
+
fs11.chmodSync(file, 493);
|
|
25785
25826
|
}
|
|
25786
25827
|
return defs.map((def) => ({ name: `./${def.name}`, summary: def.summary }));
|
|
25787
25828
|
}
|
|
@@ -26048,17 +26089,17 @@ console.log(${JSON.stringify(
|
|
|
26048
26089
|
}
|
|
26049
26090
|
|
|
26050
26091
|
// src/codingAgent/triggers.ts
|
|
26051
|
-
import * as
|
|
26052
|
-
import * as
|
|
26092
|
+
import * as fs12 from "fs";
|
|
26093
|
+
import * as path14 from "path";
|
|
26053
26094
|
var EVENT_BURST_CAP = 200;
|
|
26054
26095
|
var capEvents = (events) => events.length > EVENT_BURST_CAP ? events.slice(-EVENT_BURST_CAP) : events;
|
|
26055
26096
|
function statePath2(agentId) {
|
|
26056
|
-
return
|
|
26097
|
+
return path14.join(getCodingAgentsConfig().runtimeDir, agentId, "_triggers.json");
|
|
26057
26098
|
}
|
|
26058
26099
|
function loadTriggerState(agentId) {
|
|
26059
26100
|
let raw;
|
|
26060
26101
|
try {
|
|
26061
|
-
raw = JSON.parse(
|
|
26102
|
+
raw = JSON.parse(fs12.readFileSync(statePath2(agentId), "utf-8"));
|
|
26062
26103
|
} catch {
|
|
26063
26104
|
return { counts: {}, pending: {} };
|
|
26064
26105
|
}
|
|
@@ -26078,8 +26119,8 @@ function loadTriggerState(agentId) {
|
|
|
26078
26119
|
function saveTriggerState(agentId, state) {
|
|
26079
26120
|
try {
|
|
26080
26121
|
const p = statePath2(agentId);
|
|
26081
|
-
|
|
26082
|
-
|
|
26122
|
+
fs12.mkdirSync(path14.dirname(p), { recursive: true });
|
|
26123
|
+
fs12.writeFileSync(p, JSON.stringify(state, null, 2));
|
|
26083
26124
|
} catch (err) {
|
|
26084
26125
|
logger.warn(`[CodingAgent:${agentId}] failed to persist trigger state: ${err?.message ?? err}`);
|
|
26085
26126
|
}
|
|
@@ -26215,13 +26256,13 @@ function describeTriggers() {
|
|
|
26215
26256
|
}
|
|
26216
26257
|
|
|
26217
26258
|
// src/codingAgent/collection.ts
|
|
26218
|
-
import * as
|
|
26219
|
-
import * as
|
|
26259
|
+
import * as fs13 from "fs";
|
|
26260
|
+
import * as path15 from "path";
|
|
26220
26261
|
function isChattable(agent) {
|
|
26221
26262
|
return agent.mode !== "task";
|
|
26222
26263
|
}
|
|
26223
26264
|
function registerCodingAgentCollection(sdk, config2 = {}) {
|
|
26224
|
-
const runtimeDir = config2.runtimeDir || process.env.CODING_AGENT_RUNTIME_DIR ||
|
|
26265
|
+
const runtimeDir = config2.runtimeDir || process.env.CODING_AGENT_RUNTIME_DIR || path15.join(process.cwd(), ".coding-agent-runtime");
|
|
26225
26266
|
const defaultHarness = config2.harness || process.env.CODING_AGENT_HARNESS || "codex";
|
|
26226
26267
|
const sessions = /* @__PURE__ */ new Map();
|
|
26227
26268
|
const running = /* @__PURE__ */ new Set();
|
|
@@ -26281,8 +26322,8 @@ function registerCodingAgentCollection(sdk, config2 = {}) {
|
|
|
26281
26322
|
...record.status === "skipped" ? { error: `${def.title} is in the middle of a run \u2014 try again in a moment.` } : record.error ? { error: record.error } : {}
|
|
26282
26323
|
};
|
|
26283
26324
|
}
|
|
26284
|
-
const cwd =
|
|
26285
|
-
|
|
26325
|
+
const cwd = path15.join(runtimeDir, "threads", threadId);
|
|
26326
|
+
fs13.mkdirSync(cwd, { recursive: true });
|
|
26286
26327
|
let session = sessions.get(threadId);
|
|
26287
26328
|
if (!session) {
|
|
26288
26329
|
session = createCodingAgentSession(harness || defaultHarness, {
|
|
@@ -27561,9 +27602,9 @@ function getLLMProviders() {
|
|
|
27561
27602
|
}
|
|
27562
27603
|
|
|
27563
27604
|
// src/auth/user-manager.ts
|
|
27564
|
-
import
|
|
27565
|
-
import
|
|
27566
|
-
import
|
|
27605
|
+
import fs14 from "fs";
|
|
27606
|
+
import path16 from "path";
|
|
27607
|
+
import os3 from "os";
|
|
27567
27608
|
var UserManager = class {
|
|
27568
27609
|
/**
|
|
27569
27610
|
* Initialize UserManager with file path and sync interval
|
|
@@ -27575,7 +27616,7 @@ var UserManager = class {
|
|
|
27575
27616
|
this.hasChanged = false;
|
|
27576
27617
|
this.syncInterval = null;
|
|
27577
27618
|
this.isInitialized = false;
|
|
27578
|
-
this.filePath =
|
|
27619
|
+
this.filePath = path16.join(os3.homedir(), ".superatom", "projects", projectId, "users.json");
|
|
27579
27620
|
this.syncIntervalMs = syncIntervalMs;
|
|
27580
27621
|
}
|
|
27581
27622
|
/**
|
|
@@ -27600,20 +27641,20 @@ var UserManager = class {
|
|
|
27600
27641
|
*/
|
|
27601
27642
|
async loadUsersFromFile() {
|
|
27602
27643
|
try {
|
|
27603
|
-
const dir =
|
|
27604
|
-
if (!
|
|
27644
|
+
const dir = path16.dirname(this.filePath);
|
|
27645
|
+
if (!fs14.existsSync(dir)) {
|
|
27605
27646
|
logger.info(`Creating directory structure: ${dir}`);
|
|
27606
|
-
|
|
27647
|
+
fs14.mkdirSync(dir, { recursive: true });
|
|
27607
27648
|
}
|
|
27608
|
-
if (!
|
|
27649
|
+
if (!fs14.existsSync(this.filePath)) {
|
|
27609
27650
|
logger.info(`Users file does not exist at ${this.filePath}, creating with empty users`);
|
|
27610
27651
|
const initialData = { users: [] };
|
|
27611
|
-
|
|
27652
|
+
fs14.writeFileSync(this.filePath, JSON.stringify(initialData, null, 4));
|
|
27612
27653
|
this.users = [];
|
|
27613
27654
|
this.hasChanged = false;
|
|
27614
27655
|
return;
|
|
27615
27656
|
}
|
|
27616
|
-
const fileContent =
|
|
27657
|
+
const fileContent = fs14.readFileSync(this.filePath, "utf-8");
|
|
27617
27658
|
const rawData = JSON.parse(fileContent);
|
|
27618
27659
|
const validatedData = UsersDataSchema.parse(rawData);
|
|
27619
27660
|
this.users = validatedData.users;
|
|
@@ -27632,16 +27673,16 @@ var UserManager = class {
|
|
|
27632
27673
|
return;
|
|
27633
27674
|
}
|
|
27634
27675
|
try {
|
|
27635
|
-
const dir =
|
|
27636
|
-
if (!
|
|
27637
|
-
|
|
27676
|
+
const dir = path16.dirname(this.filePath);
|
|
27677
|
+
if (!fs14.existsSync(dir)) {
|
|
27678
|
+
fs14.mkdirSync(dir, { recursive: true });
|
|
27638
27679
|
}
|
|
27639
27680
|
const usersToSave = this.users.map((user) => {
|
|
27640
27681
|
const { wsIds, ...userWithoutWsIds } = user;
|
|
27641
27682
|
return userWithoutWsIds;
|
|
27642
27683
|
});
|
|
27643
27684
|
const data = { users: usersToSave };
|
|
27644
|
-
|
|
27685
|
+
fs14.writeFileSync(this.filePath, JSON.stringify(data, null, 4));
|
|
27645
27686
|
this.hasChanged = false;
|
|
27646
27687
|
logger.debug(`Synced ${this.users.length} users to file (wsIds excluded)`);
|
|
27647
27688
|
} catch (error) {
|
|
@@ -27859,9 +27900,9 @@ var UserManager = class {
|
|
|
27859
27900
|
};
|
|
27860
27901
|
|
|
27861
27902
|
// src/dashboards/dashboard-manager.ts
|
|
27862
|
-
import
|
|
27863
|
-
import
|
|
27864
|
-
import
|
|
27903
|
+
import fs15 from "fs";
|
|
27904
|
+
import path17 from "path";
|
|
27905
|
+
import os4 from "os";
|
|
27865
27906
|
var DashboardManager = class {
|
|
27866
27907
|
/**
|
|
27867
27908
|
* Initialize DashboardManager with project ID
|
|
@@ -27869,8 +27910,8 @@ var DashboardManager = class {
|
|
|
27869
27910
|
*/
|
|
27870
27911
|
constructor(projectId = "snowflake-dataset") {
|
|
27871
27912
|
this.projectId = projectId;
|
|
27872
|
-
this.dashboardsBasePath =
|
|
27873
|
-
|
|
27913
|
+
this.dashboardsBasePath = path17.join(
|
|
27914
|
+
os4.homedir(),
|
|
27874
27915
|
".superatom",
|
|
27875
27916
|
"projects",
|
|
27876
27917
|
projectId,
|
|
@@ -27883,7 +27924,7 @@ var DashboardManager = class {
|
|
|
27883
27924
|
* @returns Full path to dashboard data.json file
|
|
27884
27925
|
*/
|
|
27885
27926
|
getDashboardPath(dashboardId) {
|
|
27886
|
-
return
|
|
27927
|
+
return path17.join(this.dashboardsBasePath, dashboardId, "data.json");
|
|
27887
27928
|
}
|
|
27888
27929
|
/**
|
|
27889
27930
|
* Create a new dashboard
|
|
@@ -27893,13 +27934,13 @@ var DashboardManager = class {
|
|
|
27893
27934
|
*/
|
|
27894
27935
|
createDashboard(dashboardId, dashboard) {
|
|
27895
27936
|
const dashboardPath = this.getDashboardPath(dashboardId);
|
|
27896
|
-
const dashboardDir =
|
|
27897
|
-
if (
|
|
27937
|
+
const dashboardDir = path17.dirname(dashboardPath);
|
|
27938
|
+
if (fs15.existsSync(dashboardPath)) {
|
|
27898
27939
|
throw new Error(`Dashboard '${dashboardId}' already exists`);
|
|
27899
27940
|
}
|
|
27900
27941
|
const validated = DSLRendererPropsSchema.parse(dashboard);
|
|
27901
|
-
|
|
27902
|
-
|
|
27942
|
+
fs15.mkdirSync(dashboardDir, { recursive: true });
|
|
27943
|
+
fs15.writeFileSync(dashboardPath, JSON.stringify(validated, null, 4));
|
|
27903
27944
|
logger.info(`Dashboard created: ${dashboardId}`);
|
|
27904
27945
|
return validated;
|
|
27905
27946
|
}
|
|
@@ -27910,12 +27951,12 @@ var DashboardManager = class {
|
|
|
27910
27951
|
*/
|
|
27911
27952
|
getDashboard(dashboardId) {
|
|
27912
27953
|
const dashboardPath = this.getDashboardPath(dashboardId);
|
|
27913
|
-
if (!
|
|
27954
|
+
if (!fs15.existsSync(dashboardPath)) {
|
|
27914
27955
|
logger.warn(`Dashboard not found: ${dashboardId}`);
|
|
27915
27956
|
return null;
|
|
27916
27957
|
}
|
|
27917
27958
|
try {
|
|
27918
|
-
const fileContent =
|
|
27959
|
+
const fileContent = fs15.readFileSync(dashboardPath, "utf-8");
|
|
27919
27960
|
const dashboard = JSON.parse(fileContent);
|
|
27920
27961
|
const validated = DSLRendererPropsSchema.parse(dashboard);
|
|
27921
27962
|
return validated;
|
|
@@ -27929,16 +27970,16 @@ var DashboardManager = class {
|
|
|
27929
27970
|
* @returns Array of dashboard objects with their IDs
|
|
27930
27971
|
*/
|
|
27931
27972
|
getAllDashboards() {
|
|
27932
|
-
if (!
|
|
27933
|
-
|
|
27973
|
+
if (!fs15.existsSync(this.dashboardsBasePath)) {
|
|
27974
|
+
fs15.mkdirSync(this.dashboardsBasePath, { recursive: true });
|
|
27934
27975
|
return [];
|
|
27935
27976
|
}
|
|
27936
27977
|
const dashboards = [];
|
|
27937
27978
|
try {
|
|
27938
|
-
const dashboardDirs =
|
|
27979
|
+
const dashboardDirs = fs15.readdirSync(this.dashboardsBasePath);
|
|
27939
27980
|
for (const dashboardId of dashboardDirs) {
|
|
27940
27981
|
const dashboardPath = this.getDashboardPath(dashboardId);
|
|
27941
|
-
if (
|
|
27982
|
+
if (fs15.existsSync(dashboardPath)) {
|
|
27942
27983
|
const dashboard = this.getDashboard(dashboardId);
|
|
27943
27984
|
if (dashboard) {
|
|
27944
27985
|
dashboards.push({ dashboardId, dashboard });
|
|
@@ -27960,13 +28001,13 @@ var DashboardManager = class {
|
|
|
27960
28001
|
*/
|
|
27961
28002
|
updateDashboard(dashboardId, dashboard) {
|
|
27962
28003
|
const dashboardPath = this.getDashboardPath(dashboardId);
|
|
27963
|
-
if (!
|
|
28004
|
+
if (!fs15.existsSync(dashboardPath)) {
|
|
27964
28005
|
logger.warn(`Dashboard not found for update: ${dashboardId}`);
|
|
27965
28006
|
return null;
|
|
27966
28007
|
}
|
|
27967
28008
|
try {
|
|
27968
28009
|
const validated = DSLRendererPropsSchema.parse(dashboard);
|
|
27969
|
-
|
|
28010
|
+
fs15.writeFileSync(dashboardPath, JSON.stringify(validated, null, 4));
|
|
27970
28011
|
logger.info(`Dashboard updated: ${dashboardId}`);
|
|
27971
28012
|
return validated;
|
|
27972
28013
|
} catch (error) {
|
|
@@ -27981,13 +28022,13 @@ var DashboardManager = class {
|
|
|
27981
28022
|
*/
|
|
27982
28023
|
deleteDashboard(dashboardId) {
|
|
27983
28024
|
const dashboardPath = this.getDashboardPath(dashboardId);
|
|
27984
|
-
const dashboardDir =
|
|
27985
|
-
if (!
|
|
28025
|
+
const dashboardDir = path17.dirname(dashboardPath);
|
|
28026
|
+
if (!fs15.existsSync(dashboardPath)) {
|
|
27986
28027
|
logger.warn(`Dashboard not found for deletion: ${dashboardId}`);
|
|
27987
28028
|
return false;
|
|
27988
28029
|
}
|
|
27989
28030
|
try {
|
|
27990
|
-
|
|
28031
|
+
fs15.rmSync(dashboardDir, { recursive: true, force: true });
|
|
27991
28032
|
logger.info(`Dashboard deleted: ${dashboardId}`);
|
|
27992
28033
|
return true;
|
|
27993
28034
|
} catch (error) {
|
|
@@ -28002,21 +28043,21 @@ var DashboardManager = class {
|
|
|
28002
28043
|
*/
|
|
28003
28044
|
dashboardExists(dashboardId) {
|
|
28004
28045
|
const dashboardPath = this.getDashboardPath(dashboardId);
|
|
28005
|
-
return
|
|
28046
|
+
return fs15.existsSync(dashboardPath);
|
|
28006
28047
|
}
|
|
28007
28048
|
/**
|
|
28008
28049
|
* Get dashboard count
|
|
28009
28050
|
* @returns Number of dashboards
|
|
28010
28051
|
*/
|
|
28011
28052
|
getDashboardCount() {
|
|
28012
|
-
if (!
|
|
28053
|
+
if (!fs15.existsSync(this.dashboardsBasePath)) {
|
|
28013
28054
|
return 0;
|
|
28014
28055
|
}
|
|
28015
28056
|
try {
|
|
28016
|
-
const dashboardDirs =
|
|
28057
|
+
const dashboardDirs = fs15.readdirSync(this.dashboardsBasePath);
|
|
28017
28058
|
return dashboardDirs.filter((dir) => {
|
|
28018
28059
|
const dashboardPath = this.getDashboardPath(dir);
|
|
28019
|
-
return
|
|
28060
|
+
return fs15.existsSync(dashboardPath);
|
|
28020
28061
|
}).length;
|
|
28021
28062
|
} catch (error) {
|
|
28022
28063
|
logger.error("Failed to get dashboard count:", error);
|
|
@@ -28026,9 +28067,9 @@ var DashboardManager = class {
|
|
|
28026
28067
|
};
|
|
28027
28068
|
|
|
28028
28069
|
// src/reports/report-manager.ts
|
|
28029
|
-
import
|
|
28030
|
-
import
|
|
28031
|
-
import
|
|
28070
|
+
import fs16 from "fs";
|
|
28071
|
+
import path18 from "path";
|
|
28072
|
+
import os5 from "os";
|
|
28032
28073
|
var ReportManager = class {
|
|
28033
28074
|
/**
|
|
28034
28075
|
* Initialize ReportManager with project ID
|
|
@@ -28036,8 +28077,8 @@ var ReportManager = class {
|
|
|
28036
28077
|
*/
|
|
28037
28078
|
constructor(projectId = "snowflake-dataset") {
|
|
28038
28079
|
this.projectId = projectId;
|
|
28039
|
-
this.reportsBasePath =
|
|
28040
|
-
|
|
28080
|
+
this.reportsBasePath = path18.join(
|
|
28081
|
+
os5.homedir(),
|
|
28041
28082
|
".superatom",
|
|
28042
28083
|
"projects",
|
|
28043
28084
|
projectId,
|
|
@@ -28050,7 +28091,7 @@ var ReportManager = class {
|
|
|
28050
28091
|
* @returns Full path to report data.json file
|
|
28051
28092
|
*/
|
|
28052
28093
|
getReportPath(reportId) {
|
|
28053
|
-
return
|
|
28094
|
+
return path18.join(this.reportsBasePath, reportId, "data.json");
|
|
28054
28095
|
}
|
|
28055
28096
|
/**
|
|
28056
28097
|
* Create a new report
|
|
@@ -28060,13 +28101,13 @@ var ReportManager = class {
|
|
|
28060
28101
|
*/
|
|
28061
28102
|
createReport(reportId, report) {
|
|
28062
28103
|
const reportPath = this.getReportPath(reportId);
|
|
28063
|
-
const reportDir =
|
|
28064
|
-
if (
|
|
28104
|
+
const reportDir = path18.dirname(reportPath);
|
|
28105
|
+
if (fs16.existsSync(reportPath)) {
|
|
28065
28106
|
throw new Error(`Report '${reportId}' already exists`);
|
|
28066
28107
|
}
|
|
28067
28108
|
const validated = DSLRendererPropsSchema2.parse(report);
|
|
28068
|
-
|
|
28069
|
-
|
|
28109
|
+
fs16.mkdirSync(reportDir, { recursive: true });
|
|
28110
|
+
fs16.writeFileSync(reportPath, JSON.stringify(validated, null, 4));
|
|
28070
28111
|
logger.info(`Report created: ${reportId}`);
|
|
28071
28112
|
return validated;
|
|
28072
28113
|
}
|
|
@@ -28077,12 +28118,12 @@ var ReportManager = class {
|
|
|
28077
28118
|
*/
|
|
28078
28119
|
getReport(reportId) {
|
|
28079
28120
|
const reportPath = this.getReportPath(reportId);
|
|
28080
|
-
if (!
|
|
28121
|
+
if (!fs16.existsSync(reportPath)) {
|
|
28081
28122
|
logger.warn(`Report not found: ${reportId}`);
|
|
28082
28123
|
return null;
|
|
28083
28124
|
}
|
|
28084
28125
|
try {
|
|
28085
|
-
const fileContent =
|
|
28126
|
+
const fileContent = fs16.readFileSync(reportPath, "utf-8");
|
|
28086
28127
|
const report = JSON.parse(fileContent);
|
|
28087
28128
|
const validated = DSLRendererPropsSchema2.parse(report);
|
|
28088
28129
|
return validated;
|
|
@@ -28096,16 +28137,16 @@ var ReportManager = class {
|
|
|
28096
28137
|
* @returns Array of report objects with their IDs
|
|
28097
28138
|
*/
|
|
28098
28139
|
getAllReports() {
|
|
28099
|
-
if (!
|
|
28100
|
-
|
|
28140
|
+
if (!fs16.existsSync(this.reportsBasePath)) {
|
|
28141
|
+
fs16.mkdirSync(this.reportsBasePath, { recursive: true });
|
|
28101
28142
|
return [];
|
|
28102
28143
|
}
|
|
28103
28144
|
const reports = [];
|
|
28104
28145
|
try {
|
|
28105
|
-
const reportDirs =
|
|
28146
|
+
const reportDirs = fs16.readdirSync(this.reportsBasePath);
|
|
28106
28147
|
for (const reportId of reportDirs) {
|
|
28107
28148
|
const reportPath = this.getReportPath(reportId);
|
|
28108
|
-
if (
|
|
28149
|
+
if (fs16.existsSync(reportPath)) {
|
|
28109
28150
|
const report = this.getReport(reportId);
|
|
28110
28151
|
if (report) {
|
|
28111
28152
|
reports.push({ reportId, report });
|
|
@@ -28127,13 +28168,13 @@ var ReportManager = class {
|
|
|
28127
28168
|
*/
|
|
28128
28169
|
updateReport(reportId, report) {
|
|
28129
28170
|
const reportPath = this.getReportPath(reportId);
|
|
28130
|
-
if (!
|
|
28171
|
+
if (!fs16.existsSync(reportPath)) {
|
|
28131
28172
|
logger.warn(`Report not found for update: ${reportId}`);
|
|
28132
28173
|
return null;
|
|
28133
28174
|
}
|
|
28134
28175
|
try {
|
|
28135
28176
|
const validated = DSLRendererPropsSchema2.parse(report);
|
|
28136
|
-
|
|
28177
|
+
fs16.writeFileSync(reportPath, JSON.stringify(validated, null, 4));
|
|
28137
28178
|
logger.info(`Report updated: ${reportId}`);
|
|
28138
28179
|
return validated;
|
|
28139
28180
|
} catch (error) {
|
|
@@ -28148,13 +28189,13 @@ var ReportManager = class {
|
|
|
28148
28189
|
*/
|
|
28149
28190
|
deleteReport(reportId) {
|
|
28150
28191
|
const reportPath = this.getReportPath(reportId);
|
|
28151
|
-
const reportDir =
|
|
28152
|
-
if (!
|
|
28192
|
+
const reportDir = path18.dirname(reportPath);
|
|
28193
|
+
if (!fs16.existsSync(reportPath)) {
|
|
28153
28194
|
logger.warn(`Report not found for deletion: ${reportId}`);
|
|
28154
28195
|
return false;
|
|
28155
28196
|
}
|
|
28156
28197
|
try {
|
|
28157
|
-
|
|
28198
|
+
fs16.rmSync(reportDir, { recursive: true, force: true });
|
|
28158
28199
|
logger.info(`Report deleted: ${reportId}`);
|
|
28159
28200
|
return true;
|
|
28160
28201
|
} catch (error) {
|
|
@@ -28169,21 +28210,21 @@ var ReportManager = class {
|
|
|
28169
28210
|
*/
|
|
28170
28211
|
reportExists(reportId) {
|
|
28171
28212
|
const reportPath = this.getReportPath(reportId);
|
|
28172
|
-
return
|
|
28213
|
+
return fs16.existsSync(reportPath);
|
|
28173
28214
|
}
|
|
28174
28215
|
/**
|
|
28175
28216
|
* Get report count
|
|
28176
28217
|
* @returns Number of reports
|
|
28177
28218
|
*/
|
|
28178
28219
|
getReportCount() {
|
|
28179
|
-
if (!
|
|
28220
|
+
if (!fs16.existsSync(this.reportsBasePath)) {
|
|
28180
28221
|
return 0;
|
|
28181
28222
|
}
|
|
28182
28223
|
try {
|
|
28183
|
-
const reportDirs =
|
|
28224
|
+
const reportDirs = fs16.readdirSync(this.reportsBasePath);
|
|
28184
28225
|
return reportDirs.filter((dir) => {
|
|
28185
28226
|
const reportPath = this.getReportPath(dir);
|
|
28186
|
-
return
|
|
28227
|
+
return fs16.existsSync(reportPath);
|
|
28187
28228
|
}).length;
|
|
28188
28229
|
} catch (error) {
|
|
28189
28230
|
logger.error("Failed to get report count:", error);
|
|
@@ -28677,8 +28718,8 @@ var CleanupService = class _CleanupService {
|
|
|
28677
28718
|
};
|
|
28678
28719
|
|
|
28679
28720
|
// src/dashboardAgent/collection.ts
|
|
28680
|
-
import
|
|
28681
|
-
import
|
|
28721
|
+
import path19 from "path";
|
|
28722
|
+
import fs17 from "fs";
|
|
28682
28723
|
|
|
28683
28724
|
// src/dashboardAgent/tools.ts
|
|
28684
28725
|
import { Type } from "typebox";
|
|
@@ -29010,16 +29051,16 @@ function textDelta(event) {
|
|
|
29010
29051
|
}
|
|
29011
29052
|
var runningDashboards = /* @__PURE__ */ new Set();
|
|
29012
29053
|
function registerDashboardAgentCollection(sdk, config2 = {}) {
|
|
29013
|
-
const piCwd = config2.cwd || process.env.PI_AGENT_DIR ||
|
|
29014
|
-
const runtimeDir = config2.runtimeDir || process.env.PI_AGENT_RUNTIME_DIR ||
|
|
29054
|
+
const piCwd = config2.cwd || process.env.PI_AGENT_DIR || path19.join(process.cwd(), ".prompts", "dashboard-agent");
|
|
29055
|
+
const runtimeDir = config2.runtimeDir || process.env.PI_AGENT_RUNTIME_DIR || path19.join(process.cwd(), ".pi-dashboard-agent-runtime");
|
|
29015
29056
|
const freshSession = config2.freshSession ?? process.env.PI_AGENT_FRESH_SESSION !== "false";
|
|
29016
|
-
const SESSIONS_FILE =
|
|
29017
|
-
const DRAFTS_DIR =
|
|
29018
|
-
const DASHBOARD_LOG_FILE =
|
|
29057
|
+
const SESSIONS_FILE = path19.join(runtimeDir, ".pi-dashboard-sessions.json");
|
|
29058
|
+
const DRAFTS_DIR = path19.join(runtimeDir, "drafts");
|
|
29059
|
+
const DASHBOARD_LOG_FILE = path19.join(runtimeDir, "dashboard.log");
|
|
29019
29060
|
function appendLog(text) {
|
|
29020
29061
|
try {
|
|
29021
|
-
|
|
29022
|
-
|
|
29062
|
+
fs17.mkdirSync(runtimeDir, { recursive: true });
|
|
29063
|
+
fs17.appendFileSync(DASHBOARD_LOG_FILE, text);
|
|
29023
29064
|
} catch (err) {
|
|
29024
29065
|
console.warn(`[DashboardAgent] Failed to write dashboard.log: ${err?.message ?? err}`);
|
|
29025
29066
|
}
|
|
@@ -29031,15 +29072,15 @@ ${fullPrompt}
|
|
|
29031
29072
|
--- Response ---
|
|
29032
29073
|
`;
|
|
29033
29074
|
try {
|
|
29034
|
-
|
|
29035
|
-
|
|
29075
|
+
fs17.mkdirSync(runtimeDir, { recursive: true });
|
|
29076
|
+
fs17.writeFileSync(DASHBOARD_LOG_FILE, header);
|
|
29036
29077
|
} catch (err) {
|
|
29037
29078
|
console.warn(`[DashboardAgent] Failed to write dashboard.log: ${err?.message ?? err}`);
|
|
29038
29079
|
}
|
|
29039
29080
|
}
|
|
29040
29081
|
function readDraft(dashboardId) {
|
|
29041
29082
|
try {
|
|
29042
|
-
const raw =
|
|
29083
|
+
const raw = fs17.readFileSync(path19.join(DRAFTS_DIR, `${dashboardId}.json`), "utf-8");
|
|
29043
29084
|
return JSON.parse(raw);
|
|
29044
29085
|
} catch (err) {
|
|
29045
29086
|
console.warn(`[DashboardAgent] Failed to read draft for ${dashboardId}: ${err?.message ?? err}`);
|
|
@@ -29048,7 +29089,7 @@ ${fullPrompt}
|
|
|
29048
29089
|
}
|
|
29049
29090
|
function loadSessionMap() {
|
|
29050
29091
|
try {
|
|
29051
|
-
return JSON.parse(
|
|
29092
|
+
return JSON.parse(fs17.readFileSync(SESSIONS_FILE, "utf-8"));
|
|
29052
29093
|
} catch {
|
|
29053
29094
|
return {};
|
|
29054
29095
|
}
|
|
@@ -29057,8 +29098,8 @@ ${fullPrompt}
|
|
|
29057
29098
|
const map = loadSessionMap();
|
|
29058
29099
|
map[dashboardId] = sessionFile;
|
|
29059
29100
|
try {
|
|
29060
|
-
|
|
29061
|
-
|
|
29101
|
+
fs17.mkdirSync(piCwd, { recursive: true });
|
|
29102
|
+
fs17.writeFileSync(SESSIONS_FILE, JSON.stringify(map, null, 2));
|
|
29062
29103
|
} catch (err) {
|
|
29063
29104
|
console.warn(`[DashboardAgent] Failed to persist session file for ${dashboardId}: ${err?.message ?? err}`);
|
|
29064
29105
|
}
|
|
@@ -29234,7 +29275,7 @@ ${turn.responseText ?? ""}`).join("\n\n");
|
|
|
29234
29275
|
console.warn(`[DashboardAgent] Failed to fetch previous responses for ${dashboardId}: ${err?.message ?? err}`);
|
|
29235
29276
|
}
|
|
29236
29277
|
}
|
|
29237
|
-
const draftPath =
|
|
29278
|
+
const draftPath = path19.join(DRAFTS_DIR, `${dashboardId}.json`);
|
|
29238
29279
|
const fullPrompt = [
|
|
29239
29280
|
`Dashboard ID: ${dashboardId}.`,
|
|
29240
29281
|
projectId ? `Project ID: ${projectId}.` : null,
|
|
@@ -29266,7 +29307,7 @@ ${previousResponseText}` : null,
|
|
|
29266
29307
|
let sessionManager;
|
|
29267
29308
|
if (!freshSession) {
|
|
29268
29309
|
const existingSessionFile = loadSessionMap()[dashboardId];
|
|
29269
|
-
if (existingSessionFile &&
|
|
29310
|
+
if (existingSessionFile && fs17.existsSync(existingSessionFile)) {
|
|
29270
29311
|
sessionManager = SessionManager.open(existingSessionFile, runtimeDir);
|
|
29271
29312
|
console.log(`[DashboardAgent] Resuming session file ${existingSessionFile} for dashboard ${dashboardId}`);
|
|
29272
29313
|
} else {
|
|
@@ -29345,7 +29386,7 @@ ${description}
|
|
|
29345
29386
|
};
|
|
29346
29387
|
signal?.addEventListener("abort", onAbort, { once: true });
|
|
29347
29388
|
try {
|
|
29348
|
-
|
|
29389
|
+
fs17.unlinkSync(draftPath);
|
|
29349
29390
|
} catch {
|
|
29350
29391
|
}
|
|
29351
29392
|
let result;
|
|
@@ -29365,7 +29406,7 @@ ${description}
|
|
|
29365
29406
|
signal?.removeEventListener("abort", onAbort);
|
|
29366
29407
|
if (freshSession && session.sessionFile) {
|
|
29367
29408
|
try {
|
|
29368
|
-
|
|
29409
|
+
fs17.unlinkSync(session.sessionFile);
|
|
29369
29410
|
} catch (err) {
|
|
29370
29411
|
console.warn(`[DashboardAgent] Failed to delete fresh-session file ${session.sessionFile}: ${err?.message ?? err}`);
|
|
29371
29412
|
}
|
|
@@ -30234,6 +30275,7 @@ export {
|
|
|
30234
30275
|
BM25L,
|
|
30235
30276
|
CATEGORY_KEYS,
|
|
30236
30277
|
CODEX_DOC_MAX_BYTES,
|
|
30278
|
+
CODEX_OPENROUTER_KEY_ENV,
|
|
30237
30279
|
CONTEXT_CONFIG,
|
|
30238
30280
|
CleanupService,
|
|
30239
30281
|
DEFAULT_AGENT_CONFIG,
|
|
@@ -30262,6 +30304,8 @@ export {
|
|
|
30262
30304
|
bridgePreamble,
|
|
30263
30305
|
captureContext,
|
|
30264
30306
|
clearContextTokens,
|
|
30307
|
+
codexDefaultProvider,
|
|
30308
|
+
codexModelFor,
|
|
30265
30309
|
codexRunConfig,
|
|
30266
30310
|
constraintPoliciesFromConfig,
|
|
30267
30311
|
contextTokenCount,
|