@superatomai/sdk-node 0.0.60-dsp → 0.0.61-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 +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +28 -2
- package/dist/index.mjs +28 -2
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -5506,6 +5506,14 @@ interface CodingAgentsConfig {
|
|
|
5506
5506
|
sharedTools?: Record<string, McpServerSpec>;
|
|
5507
5507
|
/** Keep this many run directories per agent; older ones are pruned. 0 keeps everything. */
|
|
5508
5508
|
keepRuns?: number;
|
|
5509
|
+
/**
|
|
5510
|
+
* Keep this many THREAD workspaces per thread-scoped agent; the least
|
|
5511
|
+
* recently used are deleted. A persistent workspace is never pruned by
|
|
5512
|
+
* keepRuns, so without this one directory per UI thread accumulates forever
|
|
5513
|
+
* (~3.4 MB each for the answer agent). 0 keeps everything.
|
|
5514
|
+
* Env: CODING_AGENT_KEEP_THREADS.
|
|
5515
|
+
*/
|
|
5516
|
+
keepThreads?: number;
|
|
5509
5517
|
}
|
|
5510
5518
|
/**
|
|
5511
5519
|
* Register this deployment's agents. Call once at startup.
|
|
@@ -5521,7 +5529,7 @@ declare function listCodingAgents(): Array<{
|
|
|
5521
5529
|
description?: string;
|
|
5522
5530
|
mode: 'task' | 'chat';
|
|
5523
5531
|
}>;
|
|
5524
|
-
declare function getCodingAgentsConfig(): Required<Pick<CodingAgentsConfig, "harness" | "promptRoot" | "runtimeDir" | "keepRuns">> & CodingAgentsConfig;
|
|
5532
|
+
declare function getCodingAgentsConfig(): Required<Pick<CodingAgentsConfig, "harness" | "promptRoot" | "runtimeDir" | "keepRuns" | "keepThreads">> & CodingAgentsConfig;
|
|
5525
5533
|
|
|
5526
5534
|
interface RunAgentOptions<TInput> extends AgentRunContext {
|
|
5527
5535
|
input?: TInput;
|
package/dist/index.d.ts
CHANGED
|
@@ -5506,6 +5506,14 @@ interface CodingAgentsConfig {
|
|
|
5506
5506
|
sharedTools?: Record<string, McpServerSpec>;
|
|
5507
5507
|
/** Keep this many run directories per agent; older ones are pruned. 0 keeps everything. */
|
|
5508
5508
|
keepRuns?: number;
|
|
5509
|
+
/**
|
|
5510
|
+
* Keep this many THREAD workspaces per thread-scoped agent; the least
|
|
5511
|
+
* recently used are deleted. A persistent workspace is never pruned by
|
|
5512
|
+
* keepRuns, so without this one directory per UI thread accumulates forever
|
|
5513
|
+
* (~3.4 MB each for the answer agent). 0 keeps everything.
|
|
5514
|
+
* Env: CODING_AGENT_KEEP_THREADS.
|
|
5515
|
+
*/
|
|
5516
|
+
keepThreads?: number;
|
|
5509
5517
|
}
|
|
5510
5518
|
/**
|
|
5511
5519
|
* Register this deployment's agents. Call once at startup.
|
|
@@ -5521,7 +5529,7 @@ declare function listCodingAgents(): Array<{
|
|
|
5521
5529
|
description?: string;
|
|
5522
5530
|
mode: 'task' | 'chat';
|
|
5523
5531
|
}>;
|
|
5524
|
-
declare function getCodingAgentsConfig(): Required<Pick<CodingAgentsConfig, "harness" | "promptRoot" | "runtimeDir" | "keepRuns">> & CodingAgentsConfig;
|
|
5532
|
+
declare function getCodingAgentsConfig(): Required<Pick<CodingAgentsConfig, "harness" | "promptRoot" | "runtimeDir" | "keepRuns" | "keepThreads">> & CodingAgentsConfig;
|
|
5525
5533
|
|
|
5526
5534
|
interface RunAgentOptions<TInput> extends AgentRunContext {
|
|
5527
5535
|
input?: TInput;
|
package/dist/index.js
CHANGED
|
@@ -24364,7 +24364,8 @@ var config = {
|
|
|
24364
24364
|
promptRoot: path8.join(process.cwd(), ".prompts", "coding-agents"),
|
|
24365
24365
|
runtimeDir: path8.join(process.cwd(), ".coding-agent-runtime"),
|
|
24366
24366
|
harness: "codex",
|
|
24367
|
-
keepRuns: 20
|
|
24367
|
+
keepRuns: 20,
|
|
24368
|
+
keepThreads: 200
|
|
24368
24369
|
};
|
|
24369
24370
|
function registerCodingAgents(definitions, options = {}) {
|
|
24370
24371
|
config = {
|
|
@@ -24373,7 +24374,8 @@ function registerCodingAgents(definitions, options = {}) {
|
|
|
24373
24374
|
promptRoot: options.promptRoot || process.env.CODING_AGENT_PROMPT_DIR || config.promptRoot,
|
|
24374
24375
|
runtimeDir: options.runtimeDir || process.env.CODING_AGENT_RUNTIME_DIR || config.runtimeDir,
|
|
24375
24376
|
harness: options.harness || process.env.CODING_AGENT_HARNESS || config.harness,
|
|
24376
|
-
keepRuns: options.keepRuns ?? config.keepRuns
|
|
24377
|
+
keepRuns: options.keepRuns ?? config.keepRuns,
|
|
24378
|
+
keepThreads: options.keepThreads ?? (process.env.CODING_AGENT_KEEP_THREADS !== void 0 && Number.isFinite(Number(process.env.CODING_AGENT_KEEP_THREADS)) ? Number(process.env.CODING_AGENT_KEEP_THREADS) : config.keepThreads)
|
|
24377
24379
|
};
|
|
24378
24380
|
for (const def of definitions) {
|
|
24379
24381
|
if (!def.id) throw new Error("A coding agent definition must have an id.");
|
|
@@ -24487,6 +24489,27 @@ async function installInstructions(def, ws) {
|
|
|
24487
24489
|
}
|
|
24488
24490
|
}
|
|
24489
24491
|
var REPAIR_TIMEOUT_MS = 3 * 6e4;
|
|
24492
|
+
async function pruneThreads(agentId, threadsDir, keep) {
|
|
24493
|
+
if (keep <= 0) return;
|
|
24494
|
+
try {
|
|
24495
|
+
const dirs = (await fsp.readdir(threadsDir, { withFileTypes: true })).filter((e) => e.isDirectory());
|
|
24496
|
+
if (dirs.length <= keep) return;
|
|
24497
|
+
const aged = await Promise.all(dirs.map(async (e) => {
|
|
24498
|
+
const dir = path9.join(threadsDir, e.name);
|
|
24499
|
+
const stat2 = await fsp.stat(statePath(dir)).catch(() => fsp.stat(dir));
|
|
24500
|
+
return { name: e.name, dir, used: stat2.mtimeMs };
|
|
24501
|
+
}));
|
|
24502
|
+
aged.sort((a, b) => b.used - a.used);
|
|
24503
|
+
let removed = 0;
|
|
24504
|
+
for (const t of aged.slice(keep)) {
|
|
24505
|
+
if (inFlight.has(`${agentId}:thread:${t.name}`)) continue;
|
|
24506
|
+
await fsp.rm(t.dir, { recursive: true, force: true });
|
|
24507
|
+
removed++;
|
|
24508
|
+
}
|
|
24509
|
+
if (removed) logger.info(`[CodingAgent:${agentId}] pruned ${removed} least-recently-used thread workspace(s), keeping ${keep}`);
|
|
24510
|
+
} catch {
|
|
24511
|
+
}
|
|
24512
|
+
}
|
|
24490
24513
|
async function pruneRuns(agentDir, keep) {
|
|
24491
24514
|
if (keep <= 0) return;
|
|
24492
24515
|
try {
|
|
@@ -24718,6 +24741,9 @@ Fix ONLY that, and rewrite the same file at the same path. Do not re-run any que
|
|
|
24718
24741
|
`[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}"` : "")
|
|
24719
24742
|
);
|
|
24720
24743
|
if (!options.workspaceDir && !persistentWorkspace) await pruneRuns(path9.join(scopeDir, "runs"), cfg.keepRuns);
|
|
24744
|
+
if (!options.workspaceDir && dirName.startsWith(`threads${path9.sep}`)) {
|
|
24745
|
+
await pruneThreads(def.id, path9.join(agentDir, "threads"), cfg.keepThreads);
|
|
24746
|
+
}
|
|
24721
24747
|
}
|
|
24722
24748
|
}
|
|
24723
24749
|
|
package/dist/index.mjs
CHANGED
|
@@ -24258,7 +24258,8 @@ var config = {
|
|
|
24258
24258
|
promptRoot: path8.join(process.cwd(), ".prompts", "coding-agents"),
|
|
24259
24259
|
runtimeDir: path8.join(process.cwd(), ".coding-agent-runtime"),
|
|
24260
24260
|
harness: "codex",
|
|
24261
|
-
keepRuns: 20
|
|
24261
|
+
keepRuns: 20,
|
|
24262
|
+
keepThreads: 200
|
|
24262
24263
|
};
|
|
24263
24264
|
function registerCodingAgents(definitions, options = {}) {
|
|
24264
24265
|
config = {
|
|
@@ -24267,7 +24268,8 @@ function registerCodingAgents(definitions, options = {}) {
|
|
|
24267
24268
|
promptRoot: options.promptRoot || process.env.CODING_AGENT_PROMPT_DIR || config.promptRoot,
|
|
24268
24269
|
runtimeDir: options.runtimeDir || process.env.CODING_AGENT_RUNTIME_DIR || config.runtimeDir,
|
|
24269
24270
|
harness: options.harness || process.env.CODING_AGENT_HARNESS || config.harness,
|
|
24270
|
-
keepRuns: options.keepRuns ?? config.keepRuns
|
|
24271
|
+
keepRuns: options.keepRuns ?? config.keepRuns,
|
|
24272
|
+
keepThreads: options.keepThreads ?? (process.env.CODING_AGENT_KEEP_THREADS !== void 0 && Number.isFinite(Number(process.env.CODING_AGENT_KEEP_THREADS)) ? Number(process.env.CODING_AGENT_KEEP_THREADS) : config.keepThreads)
|
|
24271
24273
|
};
|
|
24272
24274
|
for (const def of definitions) {
|
|
24273
24275
|
if (!def.id) throw new Error("A coding agent definition must have an id.");
|
|
@@ -24381,6 +24383,27 @@ async function installInstructions(def, ws) {
|
|
|
24381
24383
|
}
|
|
24382
24384
|
}
|
|
24383
24385
|
var REPAIR_TIMEOUT_MS = 3 * 6e4;
|
|
24386
|
+
async function pruneThreads(agentId, threadsDir, keep) {
|
|
24387
|
+
if (keep <= 0) return;
|
|
24388
|
+
try {
|
|
24389
|
+
const dirs = (await fsp.readdir(threadsDir, { withFileTypes: true })).filter((e) => e.isDirectory());
|
|
24390
|
+
if (dirs.length <= keep) return;
|
|
24391
|
+
const aged = await Promise.all(dirs.map(async (e) => {
|
|
24392
|
+
const dir = path9.join(threadsDir, e.name);
|
|
24393
|
+
const stat2 = await fsp.stat(statePath(dir)).catch(() => fsp.stat(dir));
|
|
24394
|
+
return { name: e.name, dir, used: stat2.mtimeMs };
|
|
24395
|
+
}));
|
|
24396
|
+
aged.sort((a, b) => b.used - a.used);
|
|
24397
|
+
let removed = 0;
|
|
24398
|
+
for (const t of aged.slice(keep)) {
|
|
24399
|
+
if (inFlight.has(`${agentId}:thread:${t.name}`)) continue;
|
|
24400
|
+
await fsp.rm(t.dir, { recursive: true, force: true });
|
|
24401
|
+
removed++;
|
|
24402
|
+
}
|
|
24403
|
+
if (removed) logger.info(`[CodingAgent:${agentId}] pruned ${removed} least-recently-used thread workspace(s), keeping ${keep}`);
|
|
24404
|
+
} catch {
|
|
24405
|
+
}
|
|
24406
|
+
}
|
|
24384
24407
|
async function pruneRuns(agentDir, keep) {
|
|
24385
24408
|
if (keep <= 0) return;
|
|
24386
24409
|
try {
|
|
@@ -24612,6 +24635,9 @@ Fix ONLY that, and rewrite the same file at the same path. Do not re-run any que
|
|
|
24612
24635
|
`[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}"` : "")
|
|
24613
24636
|
);
|
|
24614
24637
|
if (!options.workspaceDir && !persistentWorkspace) await pruneRuns(path9.join(scopeDir, "runs"), cfg.keepRuns);
|
|
24638
|
+
if (!options.workspaceDir && dirName.startsWith(`threads${path9.sep}`)) {
|
|
24639
|
+
await pruneThreads(def.id, path9.join(agentDir, "threads"), cfg.keepThreads);
|
|
24640
|
+
}
|
|
24615
24641
|
}
|
|
24616
24642
|
}
|
|
24617
24643
|
|