clementine-agent 1.18.168 → 1.18.169
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.
|
@@ -111,7 +111,7 @@ export interface RunAgentOptions {
|
|
|
111
111
|
* team-task) keep the prompt small. When unset, falls back to
|
|
112
112
|
* profile.systemPromptBody (legacy single-source behavior). */
|
|
113
113
|
systemPromptAppend?: string;
|
|
114
|
-
/** Per-run override for the tool-output-guard config (1.18.
|
|
114
|
+
/** Per-run override for the tool-output-guard config (1.18.169).
|
|
115
115
|
* Defaults come from src/config.ts TOOL_OUTPUT_GUARD (env +
|
|
116
116
|
* clementine.json). Pass null to disable the guard for this run
|
|
117
117
|
* (rarely needed — almost always a sign that perTool overrides
|
package/dist/agent/run-agent.js
CHANGED
|
@@ -279,7 +279,7 @@ export async function runAgent(prompt, opts) {
|
|
|
279
279
|
}
|
|
280
280
|
}
|
|
281
281
|
// PRD §6 / 1.18.85: stable run id created before sdkOptions so the
|
|
282
|
-
// tool-output guard (1.18.
|
|
282
|
+
// tool-output guard (1.18.169) can namespace its on-disk archive by
|
|
283
283
|
// runId. EventLog writers below also reference this id.
|
|
284
284
|
const runId = randomUUID();
|
|
285
285
|
const eventLog = new EventLog();
|
|
@@ -294,7 +294,7 @@ export async function runAgent(prompt, opts) {
|
|
|
294
294
|
}
|
|
295
295
|
catch { /* never block */ }
|
|
296
296
|
};
|
|
297
|
-
// ── Tool-output guard hooks (1.18.
|
|
297
|
+
// ── Tool-output guard hooks (1.18.169) ─────────────────────────────
|
|
298
298
|
// Bounds the per-tool-call output that reaches the model so SDK
|
|
299
299
|
// auto-compaction never thrashes on a runaway MCP result. The hook
|
|
300
300
|
// ALSO mirrors compression events into the run's EventLog so the Run
|
|
@@ -380,7 +380,7 @@ export async function runAgent(prompt, opts) {
|
|
|
380
380
|
...(opts.additionalDirectories && opts.additionalDirectories.length > 0
|
|
381
381
|
? { additionalDirectories: opts.additionalDirectories }
|
|
382
382
|
: {}),
|
|
383
|
-
// 1.18.
|
|
383
|
+
// 1.18.169 — install the tool-output guard hooks. SDK types accept
|
|
384
384
|
// `hooks` keyed by HookEvent; the empty object is a no-op when the
|
|
385
385
|
// guard is disabled.
|
|
386
386
|
...(Object.keys(guard.hooks).length > 0 ? { hooks: guard.hooks } : {}),
|
|
@@ -443,7 +443,7 @@ export async function runAgent(prompt, opts) {
|
|
|
443
443
|
}
|
|
444
444
|
if (message.type === 'assistant') {
|
|
445
445
|
const am = message;
|
|
446
|
-
// 1.18.
|
|
446
|
+
// 1.18.169 — capture this turn's usage so the tool-output guard can
|
|
447
447
|
// adaptively tighten its cap as cumulative context climbs. We sum
|
|
448
448
|
// input + cache_read + cache_creation because all three count
|
|
449
449
|
// against the model's window for the NEXT turn. Output_tokens isn't
|
|
@@ -631,7 +631,7 @@ export async function runAgent(prompt, opts) {
|
|
|
631
631
|
totalCostUsd: Number(totalCostUsd.toFixed(4)),
|
|
632
632
|
durationMs: Date.now() - startedAt,
|
|
633
633
|
finalTextChars: finalText.length,
|
|
634
|
-
// 1.18.
|
|
634
|
+
// 1.18.169 — tool-output guard summary, surfaced for observability.
|
|
635
635
|
// Non-zero `compressed` means the guard kept the SDK from thrashing.
|
|
636
636
|
guard: guard.stats.inspected > 0 ? {
|
|
637
637
|
inspected: guard.stats.inspected,
|
|
@@ -141,6 +141,8 @@ export interface GuardHookOptions {
|
|
|
141
141
|
* guard calls this once per tool result to adapt the cap. When
|
|
142
142
|
* absent, ratio is assumed 0 (full soft cap is always used). */
|
|
143
143
|
usageRatio?: () => number;
|
|
144
|
+
/** Optional archive root override for tests. Defaults to Clementine home. */
|
|
145
|
+
archiveBaseDir?: string;
|
|
144
146
|
}
|
|
145
147
|
export interface GuardHookHandles {
|
|
146
148
|
/** Hook map suitable for SDK `query({ options: { hooks } })`. */
|
|
@@ -184,9 +184,9 @@ function formatBytes(n) {
|
|
|
184
184
|
/** Persist the full payload so the agent can `Read` it later if needed.
|
|
185
185
|
* Returns the absolute path, or null on any failure (archive is opt-in
|
|
186
186
|
* convenience — never blocks compression). */
|
|
187
|
-
function archivePayload(runId, toolUseId, toolName, payload) {
|
|
187
|
+
function archivePayload(baseDir, runId, toolUseId, toolName, payload) {
|
|
188
188
|
try {
|
|
189
|
-
const dir = join(
|
|
189
|
+
const dir = join(baseDir, 'tool-archive', runId);
|
|
190
190
|
mkdirSync(dir, { recursive: true });
|
|
191
191
|
const safeName = toolName.replace(/[^a-zA-Z0-9_-]+/g, '_').slice(0, 80);
|
|
192
192
|
const file = join(dir, `${safeName}__${toolUseId}.json`);
|
|
@@ -304,7 +304,7 @@ export function buildGuardHooks(opts) {
|
|
|
304
304
|
// a real file. We don't fail compression if archive fails — the
|
|
305
305
|
// payload just becomes irretrievable; the model still gets a
|
|
306
306
|
// truncation marker and can re-call the tool.
|
|
307
|
-
const archivePath = archivePayload(opts.runId, toolUseId, toolName, rawOutput);
|
|
307
|
+
const archivePath = archivePayload(opts.archiveBaseDir ?? BASE_DIR, opts.runId, toolUseId, toolName, rawOutput);
|
|
308
308
|
const outcome = compressToolOutput(toolName, rawOutput, {
|
|
309
309
|
toolName,
|
|
310
310
|
toolUseId,
|
|
@@ -68,7 +68,7 @@ export const clementineJsonSchema = z.object({
|
|
|
68
68
|
chat: z.number().nonnegative().optional(),
|
|
69
69
|
}).optional(),
|
|
70
70
|
/**
|
|
71
|
-
* Tool-output context-protection caps (1.18.
|
|
71
|
+
* Tool-output context-protection caps (1.18.169).
|
|
72
72
|
*
|
|
73
73
|
* Every SDK `tool_result` larger than the limit gets compressed in a
|
|
74
74
|
* PostToolUse hook before the model sees it. The full result is archived
|
package/dist/config.js
CHANGED
|
@@ -428,7 +428,7 @@ export const TASK_BUDGET_TOKENS = {
|
|
|
428
428
|
// Interactive chat: off by default — let the user and maxTurns drive it.
|
|
429
429
|
chat: optionalTokenEnv('TASK_BUDGET_CHAT', undefined),
|
|
430
430
|
};
|
|
431
|
-
// ── Tool-output context guard (1.18.
|
|
431
|
+
// ── Tool-output context guard (1.18.169) ─────────────────────────────
|
|
432
432
|
// Caps the per-tool-call size that reaches the model's context window.
|
|
433
433
|
// Implements Anthropic's recommended PostToolUse hook pattern to prevent
|
|
434
434
|
// runaway MCP-tool outputs (Outlook inbox dumps, iMessage history,
|