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