@skydiveai/pi-extensions 0.1.258-beta.13 → 0.1.258-beta.131
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.mjs +322 -110
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -265,7 +265,7 @@ function createHealthHandler({ metadata }) {
|
|
|
265
265
|
const CAPABILITY_SOUL_NUDGE = "New capability gained — once the current task is done, if this changes what you can do for the user, record it in `soul.md` so it carries into future conversations rather than being rediscovered from scratch (then commit and push).";
|
|
266
266
|
//#endregion
|
|
267
267
|
//#region src/extensions/tool-call-summary.ts
|
|
268
|
-
const log$
|
|
268
|
+
const log$21 = logger.child({ module: "tool-call-summary-extension" });
|
|
269
269
|
/**
|
|
270
270
|
* The injected parameter name. Deliberately markdown-safe: the previous wire
|
|
271
271
|
* name (`__skydive_summary__`, now `TOOL_CALL_SUMMARY_FIELD_LEGACY`) carried
|
|
@@ -499,7 +499,7 @@ function withSummaryStrippedBeforeValidation(tool) {
|
|
|
499
499
|
try {
|
|
500
500
|
stripped = withoutInjectedSummary(args);
|
|
501
501
|
} catch (err) {
|
|
502
|
-
log$
|
|
502
|
+
log$21.error({
|
|
503
503
|
err,
|
|
504
504
|
event: "tool_call_summary_prepare_strip_failed",
|
|
505
505
|
toolName: tool.name
|
|
@@ -530,7 +530,7 @@ function stripInjectedSummary(pi, toolName, input) {
|
|
|
530
530
|
if (toolDeclaresSummaryParam(pi, toolName)) return;
|
|
531
531
|
for (const field of TOOL_CALL_SUMMARY_FIELDS) delete input[field];
|
|
532
532
|
} catch (err) {
|
|
533
|
-
log$
|
|
533
|
+
log$21.error({
|
|
534
534
|
err,
|
|
535
535
|
event: "tool_call_summary_strip_failed",
|
|
536
536
|
toolName
|
|
@@ -546,7 +546,7 @@ function buildInjectedPayload(pi, payload) {
|
|
|
546
546
|
try {
|
|
547
547
|
return injectToolCallSummary(payload, getStrictToolNames(pi));
|
|
548
548
|
} catch (err) {
|
|
549
|
-
log$
|
|
549
|
+
log$21.error({
|
|
550
550
|
err,
|
|
551
551
|
event: "tool_call_summary_injection_failed"
|
|
552
552
|
}, "tool_call_summary injection failed; passing payload through unchanged");
|
|
@@ -565,7 +565,7 @@ const toolCallSummaryExtension = (pi) => {
|
|
|
565
565
|
pi.registerTool(withSummaryStrippedBeforeValidation(createEditToolDefinition(ctx.cwd)));
|
|
566
566
|
editOverrideRegistered = true;
|
|
567
567
|
} catch (err) {
|
|
568
|
-
log$
|
|
568
|
+
log$21.error({
|
|
569
569
|
err,
|
|
570
570
|
event: "tool_call_summary_edit_override_failed"
|
|
571
571
|
}, "failed to register summary-tolerant edit tool; built-in remains active");
|
|
@@ -596,7 +596,7 @@ const toolCallSummaryExtension = (pi) => {
|
|
|
596
596
|
* or `ToolDefinition[]`. Files starting with `_` or `.` are skipped, so
|
|
597
597
|
* `tools/_example.ts` documents the shape without registering.
|
|
598
598
|
*/
|
|
599
|
-
const log$
|
|
599
|
+
const log$20 = logger.child({ module: "local-tools-extension" });
|
|
600
600
|
const TOOLS_DIRNAME = "tools";
|
|
601
601
|
const fileState = /* @__PURE__ */ new Map();
|
|
602
602
|
let pendingLocalToolsUpdate = null;
|
|
@@ -740,7 +740,7 @@ async function reconcileAndQueue({ pi, dir, reason }) {
|
|
|
740
740
|
dir
|
|
741
741
|
});
|
|
742
742
|
if (reason !== "session_start" && summaryHasChanges$1(summary)) pendingLocalToolsUpdate = summary;
|
|
743
|
-
log$
|
|
743
|
+
log$20.info({
|
|
744
744
|
event: "local_tools_reconcile",
|
|
745
745
|
reason,
|
|
746
746
|
total_tools: summary.totalTools,
|
|
@@ -762,7 +762,7 @@ const localToolsExtension = (pi) => {
|
|
|
762
762
|
reason: "session_start"
|
|
763
763
|
});
|
|
764
764
|
} catch (err) {
|
|
765
|
-
log$
|
|
765
|
+
log$20.error({
|
|
766
766
|
err,
|
|
767
767
|
event: "local_tools_reconcile_failed"
|
|
768
768
|
}, "local tools reconcile failed");
|
|
@@ -774,7 +774,7 @@ const localToolsExtension = (pi) => {
|
|
|
774
774
|
try {
|
|
775
775
|
current = await listToolFiles(dir);
|
|
776
776
|
} catch (err) {
|
|
777
|
-
log$
|
|
777
|
+
log$20.warn({
|
|
778
778
|
err,
|
|
779
779
|
event: "local_tools_listing_failed"
|
|
780
780
|
}, "tools/ listing failed");
|
|
@@ -796,7 +796,7 @@ const localToolsExtension = (pi) => {
|
|
|
796
796
|
reason: "auto_reload"
|
|
797
797
|
});
|
|
798
798
|
} catch (err) {
|
|
799
|
-
log$
|
|
799
|
+
log$20.error({
|
|
800
800
|
err,
|
|
801
801
|
event: "local_tools_auto_reload_failed"
|
|
802
802
|
}, "auto-reload after tools/ change failed");
|
|
@@ -1288,17 +1288,23 @@ function legacyMcpToolName({ serverName, toolName }) {
|
|
|
1288
1288
|
* a small, focused unit-test surface (typebox validation, error formatting).
|
|
1289
1289
|
*/
|
|
1290
1290
|
const MCP_CONFIG_FILENAME = "mcp.config.json";
|
|
1291
|
+
const ToolSelectionSchema = {
|
|
1292
|
+
tools: Type.Optional(Type.Union([Type.Array(Type.String()), Type.Null()])),
|
|
1293
|
+
excludeTools: Type.Optional(Type.Union([Type.Array(Type.String()), Type.Null()]))
|
|
1294
|
+
};
|
|
1291
1295
|
const StdioServerSchema = Type.Object({
|
|
1292
1296
|
transport: Type.Literal("stdio"),
|
|
1293
1297
|
command: Type.String(),
|
|
1294
1298
|
args: Type.Array(Type.String()),
|
|
1295
1299
|
env: Type.Optional(Type.Union([Type.Record(Type.String(), Type.String()), Type.Null()])),
|
|
1296
|
-
cwd: Type.Optional(Type.Union([Type.String(), Type.Null()]))
|
|
1300
|
+
cwd: Type.Optional(Type.Union([Type.String(), Type.Null()])),
|
|
1301
|
+
...ToolSelectionSchema
|
|
1297
1302
|
});
|
|
1298
1303
|
const HttpServerSchema = Type.Object({
|
|
1299
1304
|
transport: Type.Literal("http"),
|
|
1300
1305
|
url: Type.String(),
|
|
1301
|
-
headers: Type.Optional(Type.Union([Type.Record(Type.String(), Type.String()), Type.Null()]))
|
|
1306
|
+
headers: Type.Optional(Type.Union([Type.Record(Type.String(), Type.String()), Type.Null()])),
|
|
1307
|
+
...ToolSelectionSchema
|
|
1302
1308
|
});
|
|
1303
1309
|
const ServerSchema = Type.Union([StdioServerSchema, HttpServerSchema]);
|
|
1304
1310
|
const McpConfigSchema = Type.Object({ servers: Type.Record(Type.String(), ServerSchema) });
|
|
@@ -1325,11 +1331,15 @@ async function loadMcpConfig(path) {
|
|
|
1325
1331
|
for (const [id, server] of Object.entries(json.servers)) if (server.transport === "stdio") servers[id] = {
|
|
1326
1332
|
...server,
|
|
1327
1333
|
env: server.env ?? null,
|
|
1328
|
-
cwd: server.cwd ?? null
|
|
1334
|
+
cwd: server.cwd ?? null,
|
|
1335
|
+
tools: server.tools ?? null,
|
|
1336
|
+
excludeTools: server.excludeTools ?? null
|
|
1329
1337
|
};
|
|
1330
1338
|
else servers[id] = {
|
|
1331
1339
|
...server,
|
|
1332
|
-
headers: server.headers ?? null
|
|
1340
|
+
headers: server.headers ?? null,
|
|
1341
|
+
tools: server.tools ?? null,
|
|
1342
|
+
excludeTools: server.excludeTools ?? null
|
|
1333
1343
|
};
|
|
1334
1344
|
return { servers };
|
|
1335
1345
|
}
|
|
@@ -1490,7 +1500,55 @@ function toProviderSafeSchema(inputSchema) {
|
|
|
1490
1500
|
* Clients are keyed by JSON-stringified config and reused across
|
|
1491
1501
|
* reloads — only changed configs reconnect.
|
|
1492
1502
|
*/
|
|
1493
|
-
const log$
|
|
1503
|
+
const log$19 = logger.child({ module: "mcp-extension" });
|
|
1504
|
+
function resolveToolSelection(server) {
|
|
1505
|
+
return {
|
|
1506
|
+
allow: server?.tools?.length ? new Set(server.tools) : null,
|
|
1507
|
+
deny: new Set(server?.excludeTools ?? [])
|
|
1508
|
+
};
|
|
1509
|
+
}
|
|
1510
|
+
/**
|
|
1511
|
+
* Connection identity of a server config: everything except the per-server
|
|
1512
|
+
* tool selection. `tools`/`excludeTools` only filter the advertised list at
|
|
1513
|
+
* registration time, so an edit to them must re-register tools, not tear
|
|
1514
|
+
* down and re-handshake the client (kills the stdio process, re-runs the
|
|
1515
|
+
* http OAuth/handshake for an identical connection).
|
|
1516
|
+
*/
|
|
1517
|
+
function connectionKey(serverConfig) {
|
|
1518
|
+
const { tools: _tools, excludeTools: _excludeTools, ...connection } = serverConfig;
|
|
1519
|
+
return JSON.stringify(connection);
|
|
1520
|
+
}
|
|
1521
|
+
/**
|
|
1522
|
+
* Apply a server's configured tool selection to its advertised list.
|
|
1523
|
+
* Runs BEFORE the budget allocator: a filtered set is what competes for
|
|
1524
|
+
* the per-server / total / token caps, so an allowlisted tool wins the
|
|
1525
|
+
* budget contest instead of being truncated behind tools the config
|
|
1526
|
+
* never asked for. Intentional exclusions are NOT budget drops — they
|
|
1527
|
+
* don't count toward `droppedTools` and produce no truncation warning.
|
|
1528
|
+
*/
|
|
1529
|
+
function applyToolSelection(tools, selection) {
|
|
1530
|
+
if (selection.allow === null && selection.deny.size === 0) return {
|
|
1531
|
+
list: tools,
|
|
1532
|
+
filteredOut: 0,
|
|
1533
|
+
unknownTools: [],
|
|
1534
|
+
unknownExcludeTools: []
|
|
1535
|
+
};
|
|
1536
|
+
const kept = [];
|
|
1537
|
+
for (const tool of tools) {
|
|
1538
|
+
if (selection.allow !== null && !selection.allow.has(tool.name)) continue;
|
|
1539
|
+
if (selection.deny.has(tool.name)) continue;
|
|
1540
|
+
kept.push(tool);
|
|
1541
|
+
}
|
|
1542
|
+
const notAdvertised = (names) => [...names].filter((name) => !tools.some((tool) => tool.name === name));
|
|
1543
|
+
const unknownTools = selection.allow === null ? [] : notAdvertised(selection.allow);
|
|
1544
|
+
const unknownExcludeTools = selection.deny.size === 0 ? [] : notAdvertised(selection.deny);
|
|
1545
|
+
return {
|
|
1546
|
+
list: kept,
|
|
1547
|
+
filteredOut: tools.length - kept.length,
|
|
1548
|
+
unknownTools,
|
|
1549
|
+
unknownExcludeTools
|
|
1550
|
+
};
|
|
1551
|
+
}
|
|
1494
1552
|
async function closeConnected(connected) {
|
|
1495
1553
|
try {
|
|
1496
1554
|
await connected.client.close();
|
|
@@ -1640,7 +1698,7 @@ function providerSafeTools({ serverId, tools }) {
|
|
|
1640
1698
|
for (const tool of tools) {
|
|
1641
1699
|
const result = toProviderSafeSchema(tool.inputSchema);
|
|
1642
1700
|
if (!result.ok) {
|
|
1643
|
-
log$
|
|
1701
|
+
log$19.warn({
|
|
1644
1702
|
event: "mcp_tool_schema_unsupported",
|
|
1645
1703
|
server_id: serverId,
|
|
1646
1704
|
tool_name: tool.name,
|
|
@@ -1797,9 +1855,11 @@ var McpExtension = class {
|
|
|
1797
1855
|
else if (outcome.change === "refreshed") summary.refreshed.push(id);
|
|
1798
1856
|
}
|
|
1799
1857
|
const alloc = outcomes.filter((o) => Boolean(o.tools)).map((o) => {
|
|
1858
|
+
const selection = resolveToolSelection(config.servers[o.id]);
|
|
1859
|
+
const picked = applyToolSelection(o.tools.list, selection);
|
|
1800
1860
|
const { tools: list, skipped } = providerSafeTools({
|
|
1801
1861
|
serverId: o.id,
|
|
1802
|
-
tools:
|
|
1862
|
+
tools: picked.list
|
|
1803
1863
|
});
|
|
1804
1864
|
return {
|
|
1805
1865
|
id: o.id,
|
|
@@ -1807,6 +1867,9 @@ var McpExtension = class {
|
|
|
1807
1867
|
list,
|
|
1808
1868
|
advertised: o.tools.list.length,
|
|
1809
1869
|
skipped,
|
|
1870
|
+
filtered: picked.filteredOut,
|
|
1871
|
+
unknownTools: picked.unknownTools,
|
|
1872
|
+
unknownExcludeTools: picked.unknownExcludeTools,
|
|
1810
1873
|
room: Math.min(list.length, limits.maxToolsPerServer),
|
|
1811
1874
|
registered: 0,
|
|
1812
1875
|
serverTokens: 0,
|
|
@@ -1850,7 +1913,10 @@ var McpExtension = class {
|
|
|
1850
1913
|
registered: s.registered,
|
|
1851
1914
|
tokens: s.serverTokens,
|
|
1852
1915
|
droppedReason,
|
|
1853
|
-
skipped: s.skipped
|
|
1916
|
+
skipped: s.skipped,
|
|
1917
|
+
filtered: s.filtered,
|
|
1918
|
+
unknownTools: s.unknownTools,
|
|
1919
|
+
unknownExcludeTools: s.unknownExcludeTools
|
|
1854
1920
|
};
|
|
1855
1921
|
}
|
|
1856
1922
|
return summary;
|
|
@@ -1862,10 +1928,10 @@ var McpExtension = class {
|
|
|
1862
1928
|
* map/summary, so callers can run these concurrently.
|
|
1863
1929
|
*/
|
|
1864
1930
|
async reconcileServer({ id, serverConfig, existing, connectTimeoutMs }) {
|
|
1865
|
-
const configKey =
|
|
1931
|
+
const configKey = connectionKey(serverConfig);
|
|
1866
1932
|
let action;
|
|
1867
1933
|
let connected;
|
|
1868
|
-
if (existing && existing.
|
|
1934
|
+
if (existing && existing.connectionKey === configKey) {
|
|
1869
1935
|
connected = existing;
|
|
1870
1936
|
action = "reused";
|
|
1871
1937
|
} else {
|
|
@@ -1891,7 +1957,7 @@ var McpExtension = class {
|
|
|
1891
1957
|
id,
|
|
1892
1958
|
store: {
|
|
1893
1959
|
client: result.client,
|
|
1894
|
-
configKey,
|
|
1960
|
+
connectionKey: configKey,
|
|
1895
1961
|
status: "pending_auth",
|
|
1896
1962
|
stderrBuffer: result.stderrBuffer,
|
|
1897
1963
|
cliHint: result.cliHint
|
|
@@ -1909,7 +1975,7 @@ var McpExtension = class {
|
|
|
1909
1975
|
id,
|
|
1910
1976
|
store: {
|
|
1911
1977
|
client: result.client,
|
|
1912
|
-
configKey,
|
|
1978
|
+
connectionKey: configKey,
|
|
1913
1979
|
status: "timeout",
|
|
1914
1980
|
stderrBuffer: result.stderrBuffer,
|
|
1915
1981
|
cliHint: null
|
|
@@ -1925,7 +1991,7 @@ var McpExtension = class {
|
|
|
1925
1991
|
};
|
|
1926
1992
|
connected = {
|
|
1927
1993
|
client: result.client,
|
|
1928
|
-
configKey,
|
|
1994
|
+
connectionKey: configKey,
|
|
1929
1995
|
status: "connected",
|
|
1930
1996
|
stderrBuffer: result.stderr,
|
|
1931
1997
|
cliHint: null
|
|
@@ -1939,7 +2005,7 @@ var McpExtension = class {
|
|
|
1939
2005
|
id,
|
|
1940
2006
|
store: {
|
|
1941
2007
|
client: retry.client,
|
|
1942
|
-
configKey,
|
|
2008
|
+
connectionKey: configKey,
|
|
1943
2009
|
status: "pending_auth",
|
|
1944
2010
|
stderrBuffer: null,
|
|
1945
2011
|
cliHint: retry.cliHint
|
|
@@ -1957,7 +2023,7 @@ var McpExtension = class {
|
|
|
1957
2023
|
id,
|
|
1958
2024
|
store: {
|
|
1959
2025
|
client: retry.client,
|
|
1960
|
-
configKey,
|
|
2026
|
+
connectionKey: configKey,
|
|
1961
2027
|
status: "timeout",
|
|
1962
2028
|
stderrBuffer: retry.stderrBuffer,
|
|
1963
2029
|
cliHint: null
|
|
@@ -1985,7 +2051,7 @@ var McpExtension = class {
|
|
|
1985
2051
|
};
|
|
1986
2052
|
connected = {
|
|
1987
2053
|
client: retry.client,
|
|
1988
|
-
configKey,
|
|
2054
|
+
connectionKey: configKey,
|
|
1989
2055
|
status: "connected",
|
|
1990
2056
|
stderrBuffer: retry.stderr,
|
|
1991
2057
|
cliHint: null
|
|
@@ -2017,7 +2083,7 @@ var McpExtension = class {
|
|
|
2017
2083
|
id,
|
|
2018
2084
|
store: {
|
|
2019
2085
|
client: retry.client,
|
|
2020
|
-
configKey,
|
|
2086
|
+
connectionKey: configKey,
|
|
2021
2087
|
status: "pending_auth",
|
|
2022
2088
|
stderrBuffer: null,
|
|
2023
2089
|
cliHint: retry.cliHint
|
|
@@ -2049,7 +2115,7 @@ var McpExtension = class {
|
|
|
2049
2115
|
if (retry.status === "connected") {
|
|
2050
2116
|
connected = {
|
|
2051
2117
|
client: retry.client,
|
|
2052
|
-
configKey,
|
|
2118
|
+
connectionKey: configKey,
|
|
2053
2119
|
status: "connected",
|
|
2054
2120
|
stderrBuffer: retry.stderr,
|
|
2055
2121
|
cliHint: null
|
|
@@ -2106,7 +2172,7 @@ var McpExtension = class {
|
|
|
2106
2172
|
});
|
|
2107
2173
|
this.lastConfigMtimeMs = await readConfigMtimeMs(configPath);
|
|
2108
2174
|
if (reason !== "session_start" && summaryHasChanges(summary)) this.pendingMcpUpdate = summary;
|
|
2109
|
-
log$
|
|
2175
|
+
log$19.info({
|
|
2110
2176
|
event: "mcp_reconcile",
|
|
2111
2177
|
reason,
|
|
2112
2178
|
total_tools: summary.totalTools,
|
|
@@ -2133,7 +2199,7 @@ var McpExtension = class {
|
|
|
2133
2199
|
contextWindow: ctx.model?.contextWindow
|
|
2134
2200
|
});
|
|
2135
2201
|
} catch (err) {
|
|
2136
|
-
log$
|
|
2202
|
+
log$19.error({
|
|
2137
2203
|
err,
|
|
2138
2204
|
event: "mcp_reconcile_failed"
|
|
2139
2205
|
}, "MCP reconcile failed");
|
|
@@ -2147,7 +2213,7 @@ var McpExtension = class {
|
|
|
2147
2213
|
for (const legacy of renamed) {
|
|
2148
2214
|
if (this.loggedLegacyToolNames.has(legacy)) continue;
|
|
2149
2215
|
this.loggedLegacyToolNames.add(legacy);
|
|
2150
|
-
log$
|
|
2216
|
+
log$19.info({
|
|
2151
2217
|
event: "mcp_tool_legacy_name",
|
|
2152
2218
|
legacy_name: legacy,
|
|
2153
2219
|
tool_name: this.legacyToolNames.get(legacy)
|
|
@@ -2161,7 +2227,7 @@ var McpExtension = class {
|
|
|
2161
2227
|
try {
|
|
2162
2228
|
mtime = await readConfigMtimeMs(configPath);
|
|
2163
2229
|
} catch (err) {
|
|
2164
|
-
log$
|
|
2230
|
+
log$19.warn({
|
|
2165
2231
|
err,
|
|
2166
2232
|
event: "mcp_mtime_check_failed"
|
|
2167
2233
|
}, "mtime check on mcp.config.json failed");
|
|
@@ -2176,7 +2242,7 @@ var McpExtension = class {
|
|
|
2176
2242
|
contextWindow: ctx.model?.contextWindow
|
|
2177
2243
|
});
|
|
2178
2244
|
} catch (err) {
|
|
2179
|
-
log$
|
|
2245
|
+
log$19.error({
|
|
2180
2246
|
err,
|
|
2181
2247
|
event: "mcp_auto_reload_failed"
|
|
2182
2248
|
}, "auto-reload after mcp.config.json change failed");
|
|
@@ -2304,11 +2370,27 @@ function skippedSchemaLines(summary) {
|
|
|
2304
2370
|
for (const [id, count] of entries) for (const { name, reason } of count.skipped) lines.push(` - ${id}/${name}: ${reason}`);
|
|
2305
2371
|
return lines;
|
|
2306
2372
|
}
|
|
2373
|
+
/**
|
|
2374
|
+
* Lines naming allowlist entries in mcp.config.json that matched no tool the
|
|
2375
|
+
* server advertises — almost always a typo, and silent otherwise: the agent
|
|
2376
|
+
* just sees a narrower tool set and can't tell the config is wrong.
|
|
2377
|
+
*/
|
|
2378
|
+
function unknownToolLines(summary) {
|
|
2379
|
+
const entries = Object.entries(summary.toolCounts).filter(([, count]) => count.unknownTools.length > 0 || count.unknownExcludeTools.length > 0);
|
|
2380
|
+
if (entries.length === 0) return [];
|
|
2381
|
+
const lines = [];
|
|
2382
|
+
for (const [id, count] of entries) {
|
|
2383
|
+
if (count.unknownTools.length > 0) lines.push(` NOTE: ${id}.tools in mcp.config.json names tool(s) the server does not advertise: ${count.unknownTools.join(", ")}.`);
|
|
2384
|
+
if (count.unknownExcludeTools.length > 0) lines.push(` NOTE: ${id}.excludeTools in mcp.config.json names tool(s) the server does not advertise: ${count.unknownExcludeTools.join(", ")}.`);
|
|
2385
|
+
}
|
|
2386
|
+
return lines;
|
|
2387
|
+
}
|
|
2307
2388
|
function summaryText(summary) {
|
|
2308
2389
|
const lines = [];
|
|
2309
2390
|
lines.push(`MCP reconcile complete: ${summary.totalTools} tool(s) live.`);
|
|
2310
2391
|
lines.push(...truncationLines(summary));
|
|
2311
2392
|
lines.push(...skippedSchemaLines(summary));
|
|
2393
|
+
lines.push(...unknownToolLines(summary));
|
|
2312
2394
|
if (summary.added.length > 0) lines.push(` Added: ${summary.added.join(", ")}`);
|
|
2313
2395
|
if (summary.refreshed.length > 0) lines.push(` Refreshed: ${summary.refreshed.join(", ")}`);
|
|
2314
2396
|
if (summary.removed.length > 0) lines.push(` Removed: ${summary.removed.join(", ")}`);
|
|
@@ -2526,11 +2608,43 @@ const assistantSchema = z.object({
|
|
|
2526
2608
|
id: z.string(),
|
|
2527
2609
|
model: z.string()
|
|
2528
2610
|
});
|
|
2611
|
+
const sdkToolResultSchema = z.object({ content: z.array(z.object({ type: z.literal("tool_result") })).min(1) });
|
|
2529
2612
|
function assistantMessage(entry) {
|
|
2530
2613
|
if (entry.type !== "assistant") return null;
|
|
2531
2614
|
const parsed = assistantSchema.safeParse(entry.message);
|
|
2532
2615
|
return parsed.success ? parsed.data : null;
|
|
2533
2616
|
}
|
|
2617
|
+
/**
|
|
2618
|
+
* Claude Code answers some tool_use blocks itself mid-stream (e.g. "No such
|
|
2619
|
+
* tool available") and persists that result between the response's blocks.
|
|
2620
|
+
* Pi owns tool execution and replays its own results, so these never belong
|
|
2621
|
+
* in the accepted prefix.
|
|
2622
|
+
*/
|
|
2623
|
+
function isSdkToolResult(entry) {
|
|
2624
|
+
return entry.type === "user" && sdkToolResultSchema.safeParse(entry.message).success;
|
|
2625
|
+
}
|
|
2626
|
+
/**
|
|
2627
|
+
* On resume, the pinned CLI inserts a `<synthetic>` "No response requested."
|
|
2628
|
+
* assistant turn after a trailing tool_result, before the continuation prompt.
|
|
2629
|
+
* Each tool step therefore stores one placeholder pair. Inside the current turn
|
|
2630
|
+
* the pair must stay so the cached prefix is byte-identical between steps, but
|
|
2631
|
+
* once a newer user message exists it is dropped: otherwise the model rereads
|
|
2632
|
+
* itself saying "No response requested." once per historical tool step.
|
|
2633
|
+
*/
|
|
2634
|
+
function withoutResumePlaceholders(entries) {
|
|
2635
|
+
let dropPrompt = false;
|
|
2636
|
+
return entries.filter((entry) => {
|
|
2637
|
+
if (assistantMessage(entry)?.model === "<synthetic>") {
|
|
2638
|
+
dropPrompt = true;
|
|
2639
|
+
return false;
|
|
2640
|
+
}
|
|
2641
|
+
if (dropPrompt && entry.type === "user") {
|
|
2642
|
+
dropPrompt = false;
|
|
2643
|
+
return false;
|
|
2644
|
+
}
|
|
2645
|
+
return true;
|
|
2646
|
+
});
|
|
2647
|
+
}
|
|
2534
2648
|
function contentHash(message) {
|
|
2535
2649
|
return createHash("sha256").update(JSON.stringify(message.content)).digest("hex");
|
|
2536
2650
|
}
|
|
@@ -2588,7 +2702,7 @@ async function captureSeatTranscript({ configDir, sessionId, boundaryId, lastAss
|
|
|
2588
2702
|
const entry = byId.get(id);
|
|
2589
2703
|
if (!entry) break;
|
|
2590
2704
|
const assistant = assistantMessage(entry);
|
|
2591
|
-
if (!assistant || assistant.model === "<synthetic>" || acceptedIds.has(assistant.id)) entries.push(entry);
|
|
2705
|
+
if (!isSdkToolResult(entry) && (!assistant || assistant.model === "<synthetic>" || acceptedIds.has(assistant.id))) entries.push(entry);
|
|
2592
2706
|
id = entry.parentUuid;
|
|
2593
2707
|
}
|
|
2594
2708
|
if (id === boundaryId && entries.length) return entries.reverse();
|
|
@@ -2688,6 +2802,7 @@ async function prepareSeatHistory({ context, configDir, cwd, toolName, model })
|
|
|
2688
2802
|
resume: null,
|
|
2689
2803
|
boundaryId: null
|
|
2690
2804
|
};
|
|
2805
|
+
const lastUserIndex = context.messages.findLastIndex((message) => message.role === "user");
|
|
2691
2806
|
const sessionId = randomUUID();
|
|
2692
2807
|
let parentUuid = null;
|
|
2693
2808
|
const entries = messages.flatMap((message, index) => {
|
|
@@ -2697,7 +2812,7 @@ async function prepareSeatHistory({ context, configDir, cwd, toolName, model })
|
|
|
2697
2812
|
const nextHash = hashes[index + 1];
|
|
2698
2813
|
if (message.role === "user" && next?.role === "assistant" && nextHash && seatTranscript(next, nextHash)?.replacesUser) return [];
|
|
2699
2814
|
const preserved = message.role === "assistant" ? seatTranscript(message, prefixHash) : null;
|
|
2700
|
-
if (preserved) return preserved.entries.map((entry) => {
|
|
2815
|
+
if (preserved) return (index < lastUserIndex ? withoutResumePlaceholders(preserved.entries) : preserved.entries).map((entry) => {
|
|
2701
2816
|
const uuid = randomUUID();
|
|
2702
2817
|
const replay = {
|
|
2703
2818
|
...entry,
|
|
@@ -2866,7 +2981,7 @@ const SEAT_QUERY_TIMEOUTS = {
|
|
|
2866
2981
|
preparation: 3e4
|
|
2867
2982
|
};
|
|
2868
2983
|
const PI_TOOLS_SERVER = "custom-tools";
|
|
2869
|
-
const log$
|
|
2984
|
+
const log$18 = logger.child({ module: "claude-seat-sdk" });
|
|
2870
2985
|
/** Preserve existing MCP names; only ordinary Pi tools need a server prefix. */
|
|
2871
2986
|
function toolBindings(context) {
|
|
2872
2987
|
const parsed = (context.tools ?? []).map((definition) => {
|
|
@@ -2924,7 +3039,7 @@ var SeatQuery = class {
|
|
|
2924
3039
|
this.deadline = setTimeout(() => {
|
|
2925
3040
|
const err = /* @__PURE__ */ new Error(`Claude seat SDK timed out waiting for ${phase}`);
|
|
2926
3041
|
err.name = "TimeoutError";
|
|
2927
|
-
log$
|
|
3042
|
+
log$18.error({
|
|
2928
3043
|
err,
|
|
2929
3044
|
phase
|
|
2930
3045
|
}, "Claude seat SDK wait deadline exceeded");
|
|
@@ -3105,7 +3220,7 @@ var SeatQuery = class {
|
|
|
3105
3220
|
}
|
|
3106
3221
|
} catch (err) {
|
|
3107
3222
|
this.failure = err;
|
|
3108
|
-
if (!this.controller.signal.aborted) log$
|
|
3223
|
+
if (!this.controller.signal.aborted) log$18.error({
|
|
3109
3224
|
err,
|
|
3110
3225
|
sessionId
|
|
3111
3226
|
}, "Claude seat SDK query failed");
|
|
@@ -3120,7 +3235,7 @@ var SeatQuery = class {
|
|
|
3120
3235
|
force: true
|
|
3121
3236
|
});
|
|
3122
3237
|
} catch (err) {
|
|
3123
|
-
log$
|
|
3238
|
+
log$18.error({
|
|
3124
3239
|
err,
|
|
3125
3240
|
sessionId
|
|
3126
3241
|
}, "Could not remove Claude seat SDK config");
|
|
@@ -3153,10 +3268,26 @@ function mapUsage(usage) {
|
|
|
3153
3268
|
//#endregion
|
|
3154
3269
|
//#region src/extensions/claude-seat-response.ts
|
|
3155
3270
|
const toolInput = z.record(z.string(), z.unknown());
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3271
|
+
const log$17 = logger.child({ module: "claude-seat-sdk" });
|
|
3272
|
+
/**
|
|
3273
|
+
* Claude sometimes calls a tool by the name it had outside the bridge (Pi's
|
|
3274
|
+
* own name from non-seat history, or a bare MCP tool name). Resolve those when
|
|
3275
|
+
* unambiguous; anything else passes through unbound so Pi's executor returns
|
|
3276
|
+
* its normal not-found error result and the model can recover.
|
|
3277
|
+
*/
|
|
3278
|
+
function piToolName({ name, context, sessionId }) {
|
|
3279
|
+
const bindings = toolBindings(context);
|
|
3280
|
+
const exact = bindings.find((binding) => binding.sdkName === name) ?? bindings.find((binding) => binding.definition.name === name);
|
|
3281
|
+
if (exact) return exact.definition.name;
|
|
3282
|
+
const bare = bindings.filter((binding) => binding.toolName === name);
|
|
3283
|
+
const [only] = bare;
|
|
3284
|
+
if (only && bare.length === 1) return only.definition.name;
|
|
3285
|
+
log$17.warn({
|
|
3286
|
+
sessionId,
|
|
3287
|
+
toolName: name,
|
|
3288
|
+
candidates: bare.length
|
|
3289
|
+
}, "Claude requested a tool outside the Pi bridge");
|
|
3290
|
+
return name;
|
|
3160
3291
|
}
|
|
3161
3292
|
/** Commit only the accepted SDK attempt: Pi deltas cannot retract retried output. */
|
|
3162
3293
|
var ModelResponse = class {
|
|
@@ -3164,9 +3295,10 @@ var ModelResponse = class {
|
|
|
3164
3295
|
pending = [];
|
|
3165
3296
|
messageId = null;
|
|
3166
3297
|
stopReason = null;
|
|
3167
|
-
constructor(model, context, events) {
|
|
3298
|
+
constructor(model, context, events, sessionId) {
|
|
3168
3299
|
this.context = context;
|
|
3169
3300
|
this.events = events;
|
|
3301
|
+
this.sessionId = sessionId;
|
|
3170
3302
|
this.message = {
|
|
3171
3303
|
role: "assistant",
|
|
3172
3304
|
content: [],
|
|
@@ -3261,7 +3393,11 @@ var ModelResponse = class {
|
|
|
3261
3393
|
block = {
|
|
3262
3394
|
type: "toolCall",
|
|
3263
3395
|
id: sdkBlock.id,
|
|
3264
|
-
name: piToolName(
|
|
3396
|
+
name: piToolName({
|
|
3397
|
+
name: sdkBlock.name,
|
|
3398
|
+
context: this.context,
|
|
3399
|
+
sessionId: this.sessionId
|
|
3400
|
+
}),
|
|
3265
3401
|
arguments: toolInput.parse(sdkBlock.input)
|
|
3266
3402
|
};
|
|
3267
3403
|
break;
|
|
@@ -3337,7 +3473,7 @@ var ModelResponse = class {
|
|
|
3337
3473
|
* each step resumes a private structured snapshot after Pi extensions run.
|
|
3338
3474
|
* Initially adapted from elidickinson/pi-claude-bridge (MIT).
|
|
3339
3475
|
*/
|
|
3340
|
-
const log$
|
|
3476
|
+
const log$16 = logger.child({ module: "claude-seat-sdk" });
|
|
3341
3477
|
const SEAT_SDK_ACTIVITY_EVENT = "claude-seat-sdk:activity";
|
|
3342
3478
|
/** Session-scoped adapter; only the flagged provider dispatches here. */
|
|
3343
3479
|
var SeatSdkBridge = class {
|
|
@@ -3355,7 +3491,7 @@ var SeatSdkBridge = class {
|
|
|
3355
3491
|
}
|
|
3356
3492
|
stream(model, context, options = {}) {
|
|
3357
3493
|
const events = createAssistantMessageEventStream();
|
|
3358
|
-
const response = new ModelResponse(model, context, events);
|
|
3494
|
+
const response = new ModelResponse(model, context, events, this.deps.sessionId);
|
|
3359
3495
|
const signal = AbortSignal.any([this.controller.signal, ...options.signal ? [options.signal] : []]);
|
|
3360
3496
|
(async () => {
|
|
3361
3497
|
let seatQuery = null;
|
|
@@ -3388,7 +3524,7 @@ var SeatSdkBridge = class {
|
|
|
3388
3524
|
} else if (message.type === "result") {
|
|
3389
3525
|
const hasTools = response.hasTools;
|
|
3390
3526
|
if (message.is_error && !(message.subtype === "error_max_turns" && hasTools)) throw new Error("errors" in message ? message.errors.join("; ") : message.result);
|
|
3391
|
-
log$
|
|
3527
|
+
log$16.info({
|
|
3392
3528
|
sessionId: this.deps.sessionId,
|
|
3393
3529
|
queryUsage: mapUsage(message.usage),
|
|
3394
3530
|
requestUsage: response.message.usage
|
|
@@ -3409,7 +3545,7 @@ var SeatSdkBridge = class {
|
|
|
3409
3545
|
}
|
|
3410
3546
|
} catch (err) {
|
|
3411
3547
|
const reason = (seatQuery?.controller.signal.aborted || signal.aborted) && !(err instanceof Error && err.name === "TimeoutError") ? "aborted" : "error";
|
|
3412
|
-
if (reason === "error") log$
|
|
3548
|
+
if (reason === "error") log$16.error({
|
|
3413
3549
|
err,
|
|
3414
3550
|
sessionId: this.deps.sessionId
|
|
3415
3551
|
}, "Claude seat SDK response failed");
|
|
@@ -3480,7 +3616,7 @@ const HEARTBEAT_THROTTLE_MS = 6e4;
|
|
|
3480
3616
|
const TOOL_HEARTBEAT_INTERVAL_MS = 5e3;
|
|
3481
3617
|
const MAX_TOOL_HEARTBEATS = 1440 * 60 * 1e3 / TOOL_HEARTBEAT_INTERVAL_MS;
|
|
3482
3618
|
const DAEMON_URL = "http://localhost:38994";
|
|
3483
|
-
const log$
|
|
3619
|
+
const log$15 = logger.child({ module: "platform-ext" });
|
|
3484
3620
|
function sandboxClient() {
|
|
3485
3621
|
const apiUrl = apiBaseUrl();
|
|
3486
3622
|
if (!apiUrl) return null;
|
|
@@ -3548,7 +3684,7 @@ async function fetchHarnessFlags() {
|
|
|
3548
3684
|
try {
|
|
3549
3685
|
const res = await client["feature-flags"].$get();
|
|
3550
3686
|
if (!res.ok) {
|
|
3551
|
-
log$
|
|
3687
|
+
log$15.debug({
|
|
3552
3688
|
status: res.status,
|
|
3553
3689
|
event: "feature_flags_fetch_failed"
|
|
3554
3690
|
}, "feature-flags fetch failed");
|
|
@@ -3560,7 +3696,7 @@ async function fetchHarnessFlags() {
|
|
|
3560
3696
|
closingText: body.closingText ?? null
|
|
3561
3697
|
};
|
|
3562
3698
|
} catch (err) {
|
|
3563
|
-
log$
|
|
3699
|
+
log$15.debug({
|
|
3564
3700
|
err,
|
|
3565
3701
|
event: "feature_flags_fetch_error"
|
|
3566
3702
|
}, "feature-flags request errored");
|
|
@@ -3571,7 +3707,7 @@ function postHeartbeat({ messageId }) {
|
|
|
3571
3707
|
const client = sandboxClient();
|
|
3572
3708
|
if (!client) return;
|
|
3573
3709
|
client.heartbeat.$post({ json: { messageId } }).catch((err) => {
|
|
3574
|
-
log$
|
|
3710
|
+
log$15.debug({
|
|
3575
3711
|
err,
|
|
3576
3712
|
event: "heartbeat_failed"
|
|
3577
3713
|
}, "heartbeat failed");
|
|
@@ -3583,7 +3719,7 @@ async function resolveConversationFromApi(messageId) {
|
|
|
3583
3719
|
try {
|
|
3584
3720
|
const res = await client["message-conversation"].$get({ query: { messageId } });
|
|
3585
3721
|
if (!res.ok) {
|
|
3586
|
-
log$
|
|
3722
|
+
log$15.warn({
|
|
3587
3723
|
status: res.status,
|
|
3588
3724
|
messageId,
|
|
3589
3725
|
event: "resolve_conversation_failed"
|
|
@@ -3592,7 +3728,7 @@ async function resolveConversationFromApi(messageId) {
|
|
|
3592
3728
|
}
|
|
3593
3729
|
return (await res.json()).conversationId ?? null;
|
|
3594
3730
|
} catch (err) {
|
|
3595
|
-
log$
|
|
3731
|
+
log$15.warn({
|
|
3596
3732
|
err,
|
|
3597
3733
|
messageId,
|
|
3598
3734
|
event: "resolve_conversation_error"
|
|
@@ -3617,13 +3753,13 @@ async function putBackgroundTaskJournalSpec({ messageId, spec }) {
|
|
|
3617
3753
|
messageId,
|
|
3618
3754
|
spec
|
|
3619
3755
|
} });
|
|
3620
|
-
if (!res.ok) log$
|
|
3756
|
+
if (!res.ok) log$15.warn({
|
|
3621
3757
|
status: res.status,
|
|
3622
3758
|
taskId: spec.id,
|
|
3623
3759
|
event: "bg_journal_put_failed"
|
|
3624
3760
|
}, "bg-task journal PUT failed");
|
|
3625
3761
|
} catch (err) {
|
|
3626
|
-
log$
|
|
3762
|
+
log$15.warn({
|
|
3627
3763
|
err,
|
|
3628
3764
|
taskId: spec.id,
|
|
3629
3765
|
event: "bg_journal_put_failed"
|
|
@@ -3639,7 +3775,7 @@ async function deleteBackgroundTaskJournalSpec({ messageId, taskId }) {
|
|
|
3639
3775
|
taskId
|
|
3640
3776
|
} });
|
|
3641
3777
|
} catch (err) {
|
|
3642
|
-
log$
|
|
3778
|
+
log$15.debug({
|
|
3643
3779
|
err,
|
|
3644
3780
|
taskId,
|
|
3645
3781
|
event: "bg_journal_delete_failed"
|
|
@@ -3654,7 +3790,7 @@ async function listBackgroundTaskJournalSpecs({ messageId }) {
|
|
|
3654
3790
|
if (!res.ok) return [];
|
|
3655
3791
|
return (await res.json()).specs ?? [];
|
|
3656
3792
|
} catch (err) {
|
|
3657
|
-
log$
|
|
3793
|
+
log$15.debug({
|
|
3658
3794
|
err,
|
|
3659
3795
|
event: "bg_journal_list_failed"
|
|
3660
3796
|
}, "bg-task journal GET failed");
|
|
@@ -3668,7 +3804,7 @@ function postBackgroundTasksSnapshot({ messageId, tasks }) {
|
|
|
3668
3804
|
messageId,
|
|
3669
3805
|
tasks
|
|
3670
3806
|
} }).catch((err) => {
|
|
3671
|
-
log$
|
|
3807
|
+
log$15.debug({
|
|
3672
3808
|
err,
|
|
3673
3809
|
event: "bg_tasks_snapshot_failed"
|
|
3674
3810
|
}, "bg-tasks snapshot publish failed");
|
|
@@ -3766,7 +3902,7 @@ function createToolHeartbeat({ messageId }) {
|
|
|
3766
3902
|
}
|
|
3767
3903
|
heartbeatCount++;
|
|
3768
3904
|
if (heartbeatCount > MAX_TOOL_HEARTBEATS) {
|
|
3769
|
-
log$
|
|
3905
|
+
log$15.warn({
|
|
3770
3906
|
heartbeatCount,
|
|
3771
3907
|
activeToolCalls: [...activeToolCalls]
|
|
3772
3908
|
}, "tool heartbeat max reached, stopping");
|
|
@@ -3797,7 +3933,7 @@ function postToDaemon(path, body) {
|
|
|
3797
3933
|
headers: { "content-type": "application/json" },
|
|
3798
3934
|
body: JSON.stringify(body)
|
|
3799
3935
|
}).catch((err) => {
|
|
3800
|
-
log$
|
|
3936
|
+
log$15.debug({
|
|
3801
3937
|
err,
|
|
3802
3938
|
path,
|
|
3803
3939
|
event: "daemon_post_failed"
|
|
@@ -3806,7 +3942,7 @@ function postToDaemon(path, body) {
|
|
|
3806
3942
|
}
|
|
3807
3943
|
function createPlatformExtensions({ sessionId, channelContext }) {
|
|
3808
3944
|
return (pi) => {
|
|
3809
|
-
log$
|
|
3945
|
+
log$15.info({
|
|
3810
3946
|
sessionId,
|
|
3811
3947
|
hasChannelContext: Boolean(channelContext)
|
|
3812
3948
|
}, "platform extension initialized");
|
|
@@ -3860,7 +3996,7 @@ function createPlatformExtensions({ sessionId, channelContext }) {
|
|
|
3860
3996
|
});
|
|
3861
3997
|
});
|
|
3862
3998
|
pi.on("agent_end", () => {
|
|
3863
|
-
log$
|
|
3999
|
+
log$15.info({ sessionId }, "session ending");
|
|
3864
4000
|
postToDaemon("/session/end", { sessionId });
|
|
3865
4001
|
});
|
|
3866
4002
|
};
|
|
@@ -3892,6 +4028,14 @@ const toolCallEnvExtension = (pi) => {
|
|
|
3892
4028
|
});
|
|
3893
4029
|
};
|
|
3894
4030
|
//#endregion
|
|
4031
|
+
//#region src/extensions/oom-neutral-bash.ts
|
|
4032
|
+
const OOM_NEUTRAL_PREFIX = "{ echo 0 > /proc/self/oom_score_adj; } 2>/dev/null\n";
|
|
4033
|
+
/** pi's local bash backend with every command reset to a neutral OOM score. */
|
|
4034
|
+
function createOomNeutralBashOperations({ shellPath }) {
|
|
4035
|
+
const local = createLocalBashOperations({ shellPath });
|
|
4036
|
+
return { exec: (command, cwd, options) => local.exec(`${OOM_NEUTRAL_PREFIX}${command}`, cwd, options) };
|
|
4037
|
+
}
|
|
4038
|
+
//#endregion
|
|
3895
4039
|
//#region src/extensions/background-tasks.ts
|
|
3896
4040
|
/**
|
|
3897
4041
|
* Background bash tasks as a pi extension.
|
|
@@ -3996,8 +4140,8 @@ const toolCallEnvExtension = (pi) => {
|
|
|
3996
4140
|
* semantics; once promoted, the command inherits background-task lifecycle
|
|
3997
4141
|
* (its own controller) and the foreground kill timeout no longer applies.
|
|
3998
4142
|
*/
|
|
3999
|
-
const log$
|
|
4000
|
-
const ops =
|
|
4143
|
+
const log$14 = logger.child({ module: "background-tasks-ext" });
|
|
4144
|
+
const ops = createOomNeutralBashOperations({ shellPath: void 0 });
|
|
4001
4145
|
const STEER_BACKGROUND_DEFAULT_SECONDS = 60;
|
|
4002
4146
|
const STEER_BACKGROUND_ENV_KEYS = ["BASH_STEER_BACKGROUND_SECONDS", "SKYDIVE_BASH_STEER_BACKGROUND_SECONDS"];
|
|
4003
4147
|
/**
|
|
@@ -4011,7 +4155,7 @@ function steerBackgroundThresholdMs() {
|
|
|
4011
4155
|
if (raw === void 0 || raw.trim() === "") continue;
|
|
4012
4156
|
const parsed = Number(raw);
|
|
4013
4157
|
if (!Number.isFinite(parsed) || parsed < 0) {
|
|
4014
|
-
log$
|
|
4158
|
+
log$14.warn({
|
|
4015
4159
|
envKey: key,
|
|
4016
4160
|
raw
|
|
4017
4161
|
}, "invalid BASH_STEER_BACKGROUND_SECONDS, using default");
|
|
@@ -4040,7 +4184,7 @@ async function notifyBashSteerArrival(args) {
|
|
|
4040
4184
|
try {
|
|
4041
4185
|
await listener();
|
|
4042
4186
|
} catch (err) {
|
|
4043
|
-
log$
|
|
4187
|
+
log$14.error({
|
|
4044
4188
|
err,
|
|
4045
4189
|
sessionId: args.sessionId
|
|
4046
4190
|
}, "bash steer promotion failed");
|
|
@@ -4135,14 +4279,14 @@ function watchdogTick(now) {
|
|
|
4135
4279
|
const overSize = meta.logBytes > MAX_LOG_BYTES;
|
|
4136
4280
|
if (!overRuntime && !overSize) continue;
|
|
4137
4281
|
const reason = overSize ? `output exceeded ${MAX_LOG_BYTES / (1024 * 1024)}MiB` : `exceeded ${KEEPALIVE_MAX_MS / 6e4}m max runtime`;
|
|
4138
|
-
log$
|
|
4282
|
+
log$14.warn({
|
|
4139
4283
|
taskId: meta.id,
|
|
4140
4284
|
reason
|
|
4141
4285
|
}, "watchdog killing bg task");
|
|
4142
4286
|
try {
|
|
4143
4287
|
killTask(meta, reason);
|
|
4144
4288
|
} catch (err) {
|
|
4145
|
-
log$
|
|
4289
|
+
log$14.warn({
|
|
4146
4290
|
err,
|
|
4147
4291
|
taskId: meta.id
|
|
4148
4292
|
}, "watchdog kill failed");
|
|
@@ -4201,7 +4345,7 @@ function createBackgroundTasksExtension({ channelContext, sessionId }) {
|
|
|
4201
4345
|
const now = Date.now();
|
|
4202
4346
|
const promotable = [...foregroundBash.values()].filter((call) => now - call.startedAt >= thresholdMs);
|
|
4203
4347
|
if (promotable.length === 0) return;
|
|
4204
|
-
log$
|
|
4348
|
+
log$14.info({
|
|
4205
4349
|
event: "bash_steer_promotion",
|
|
4206
4350
|
count: promotable.length,
|
|
4207
4351
|
thresholdSeconds: Math.round(thresholdMs / 1e3),
|
|
@@ -4226,7 +4370,7 @@ function createBackgroundTasksExtension({ channelContext, sessionId }) {
|
|
|
4226
4370
|
try {
|
|
4227
4371
|
await mkdir(tasksDir(), { recursive: true });
|
|
4228
4372
|
} catch (err) {
|
|
4229
|
-
log$
|
|
4373
|
+
log$14.error({ err }, "bg task adopt: mkdir failed");
|
|
4230
4374
|
}
|
|
4231
4375
|
const logStream = createWriteStream(logPath(id), { flags: "a" });
|
|
4232
4376
|
logStream.on("error", () => {});
|
|
@@ -4253,7 +4397,7 @@ function createBackgroundTasksExtension({ channelContext, sessionId }) {
|
|
|
4253
4397
|
tasks.set(id, meta);
|
|
4254
4398
|
ensureWatchdog();
|
|
4255
4399
|
schedulePublishSnapshot();
|
|
4256
|
-
log$
|
|
4400
|
+
log$14.info({
|
|
4257
4401
|
taskId: id,
|
|
4258
4402
|
conversationId,
|
|
4259
4403
|
startedAt: args.startedAt
|
|
@@ -4276,7 +4420,7 @@ function createBackgroundTasksExtension({ channelContext, sessionId }) {
|
|
|
4276
4420
|
* handling, timeout kill, and abort semantics.
|
|
4277
4421
|
*/
|
|
4278
4422
|
function createSteerAwareOperations(base) {
|
|
4279
|
-
const localOps =
|
|
4423
|
+
const localOps = createOomNeutralBashOperations({ shellPath: base.shellPath });
|
|
4280
4424
|
return { async exec(command, cwd, execOptions) {
|
|
4281
4425
|
const thresholdMs = steerBackgroundThresholdMs();
|
|
4282
4426
|
const toolOnData = execOptions?.onData;
|
|
@@ -4406,7 +4550,7 @@ function createBackgroundTasksExtension({ channelContext, sessionId }) {
|
|
|
4406
4550
|
try {
|
|
4407
4551
|
shellPath = SettingsManager.create(ctx.cwd, getAgentDir()).getShellPath();
|
|
4408
4552
|
} catch (err) {
|
|
4409
|
-
log$
|
|
4553
|
+
log$14.warn({
|
|
4410
4554
|
err,
|
|
4411
4555
|
cwd: ctx.cwd
|
|
4412
4556
|
}, "bash steer promotion: shell settings unavailable, using default shell");
|
|
@@ -4421,7 +4565,7 @@ function createBackgroundTasksExtension({ channelContext, sessionId }) {
|
|
|
4421
4565
|
...definition,
|
|
4422
4566
|
description: `${definition.description}\n\nLong-running bash commands are automatically moved to a background task when a new message arrives while the command has already been running for at least a minute: you get the task id immediately, are woken on completion, and must not depend on the command's output until that wake arrives. Shorter commands finish in the foreground like they always have.`
|
|
4423
4567
|
});
|
|
4424
|
-
log$
|
|
4568
|
+
log$14.info({
|
|
4425
4569
|
event: "bash_steer_promotion_enabled",
|
|
4426
4570
|
thresholdSeconds: Math.round(thresholdMs / 1e3)
|
|
4427
4571
|
}, "supervised bash tool registered (steer-triggered backgrounding)");
|
|
@@ -4464,7 +4608,7 @@ or if you were explicitly waiting to report it.`,
|
|
|
4464
4608
|
triggerTurn: true,
|
|
4465
4609
|
deliverAs: "followUp"
|
|
4466
4610
|
});
|
|
4467
|
-
log$
|
|
4611
|
+
log$14.info({
|
|
4468
4612
|
taskId: meta.id,
|
|
4469
4613
|
conversationId
|
|
4470
4614
|
}, "bg task completion delivered live (followUp)");
|
|
@@ -4472,7 +4616,7 @@ or if you were explicitly waiting to report it.`,
|
|
|
4472
4616
|
}
|
|
4473
4617
|
if (meta.messageId) {
|
|
4474
4618
|
meta.notified = true;
|
|
4475
|
-
log$
|
|
4619
|
+
log$14.info({
|
|
4476
4620
|
taskId: meta.id,
|
|
4477
4621
|
messageId: meta.messageId
|
|
4478
4622
|
}, "posting idle bg-task-done wake");
|
|
@@ -4482,12 +4626,12 @@ or if you were explicitly waiting to report it.`,
|
|
|
4482
4626
|
content: message.content
|
|
4483
4627
|
}).catch((err) => {
|
|
4484
4628
|
meta.notified = false;
|
|
4485
|
-
log$
|
|
4629
|
+
log$14.warn({
|
|
4486
4630
|
err,
|
|
4487
4631
|
taskId: meta.id
|
|
4488
4632
|
}, "bg-task-done wake failed; will retry at next session_start");
|
|
4489
4633
|
});
|
|
4490
|
-
} else log$
|
|
4634
|
+
} else log$14.info({ taskId: meta.id }, "bg task completed idle with no origin message; deferring to next session_start");
|
|
4491
4635
|
}
|
|
4492
4636
|
const SNAPSHOT_TAIL_LINES = 40;
|
|
4493
4637
|
let lastPublishedSignature = null;
|
|
@@ -4524,7 +4668,7 @@ or if you were explicitly waiting to report it.`,
|
|
|
4524
4668
|
tasks: snapshot
|
|
4525
4669
|
});
|
|
4526
4670
|
} catch (err) {
|
|
4527
|
-
log$
|
|
4671
|
+
log$14.debug({
|
|
4528
4672
|
err,
|
|
4529
4673
|
event: "bg_tasks_snapshot_build_failed"
|
|
4530
4674
|
}, "building bg-tasks snapshot failed");
|
|
@@ -4567,7 +4711,7 @@ or if you were explicitly waiting to report it.`,
|
|
|
4567
4711
|
logStream.end();
|
|
4568
4712
|
await finished(logStream).catch(() => {});
|
|
4569
4713
|
meta.running = false;
|
|
4570
|
-
log$
|
|
4714
|
+
log$14.info({
|
|
4571
4715
|
taskId: meta.id,
|
|
4572
4716
|
exitCode: meta.exitCode
|
|
4573
4717
|
}, "bg task finished");
|
|
@@ -4584,14 +4728,14 @@ or if you were explicitly waiting to report it.`,
|
|
|
4584
4728
|
try {
|
|
4585
4729
|
await mkdir(tasksDir(), { recursive: true });
|
|
4586
4730
|
} catch (err) {
|
|
4587
|
-
log$
|
|
4731
|
+
log$14.error({
|
|
4588
4732
|
err,
|
|
4589
4733
|
taskId: id
|
|
4590
4734
|
}, "background task dir unavailable");
|
|
4591
4735
|
}
|
|
4592
4736
|
const logStream = createWriteStream(logPath(id), { flags: "a" });
|
|
4593
4737
|
logStream.on("error", (err) => {
|
|
4594
|
-
log$
|
|
4738
|
+
log$14.warn({
|
|
4595
4739
|
err,
|
|
4596
4740
|
taskId: id
|
|
4597
4741
|
}, "bg task log write failed");
|
|
@@ -4641,7 +4785,7 @@ or if you were explicitly waiting to report it.`,
|
|
|
4641
4785
|
}).catch((err) => {
|
|
4642
4786
|
if (!meta.controller.signal.aborted) {
|
|
4643
4787
|
meta.error = err instanceof Error ? err.message : String(err);
|
|
4644
|
-
log$
|
|
4788
|
+
log$14.warn({
|
|
4645
4789
|
err,
|
|
4646
4790
|
taskId: id
|
|
4647
4791
|
}, "bg task exec error");
|
|
@@ -4650,7 +4794,7 @@ or if you were explicitly waiting to report it.`,
|
|
|
4650
4794
|
await finishTask(meta, logStream);
|
|
4651
4795
|
});
|
|
4652
4796
|
ensureWatchdog();
|
|
4653
|
-
log$
|
|
4797
|
+
log$14.info({
|
|
4654
4798
|
taskId: id,
|
|
4655
4799
|
conversationId
|
|
4656
4800
|
}, "bg task started");
|
|
@@ -4669,7 +4813,7 @@ or if you were explicitly waiting to report it.`,
|
|
|
4669
4813
|
for (const spec of specs) {
|
|
4670
4814
|
const live = tasks.get(spec.id);
|
|
4671
4815
|
if (live && sameScope(live, scopeKey())) continue;
|
|
4672
|
-
log$
|
|
4816
|
+
log$14.info({
|
|
4673
4817
|
taskId: spec.id,
|
|
4674
4818
|
conversationId
|
|
4675
4819
|
}, "relaunching journaled resumable bg task after restart");
|
|
@@ -4687,7 +4831,7 @@ or if you were explicitly waiting to report it.`,
|
|
|
4687
4831
|
stream.write(`<resumed-after-restart>requeued and relaunched on a new sandbox after the previous one was drained; this is a fresh execution of the command from the start, not a continuation</resumed-after-restart>\n`);
|
|
4688
4832
|
stream.end();
|
|
4689
4833
|
} catch (err) {
|
|
4690
|
-
log$
|
|
4834
|
+
log$14.debug({
|
|
4691
4835
|
err,
|
|
4692
4836
|
taskId: meta.id
|
|
4693
4837
|
}, "resume banner write failed");
|
|
@@ -4707,7 +4851,7 @@ or if you were explicitly waiting to report it.`,
|
|
|
4707
4851
|
meta.notified = true;
|
|
4708
4852
|
pi.sendMessage(await taskDoneMessage(meta));
|
|
4709
4853
|
}
|
|
4710
|
-
if (unnotified.length > 0) log$
|
|
4854
|
+
if (unnotified.length > 0) log$14.info({
|
|
4711
4855
|
conversationId,
|
|
4712
4856
|
count: unnotified.length
|
|
4713
4857
|
}, "injected completed bg tasks at session_start");
|
|
@@ -4902,7 +5046,7 @@ or if you were explicitly waiting to report it.`,
|
|
|
4902
5046
|
* read on the hot path before every LLM call), it falls back to the default
|
|
4903
5047
|
* for that knob and logs once.
|
|
4904
5048
|
*/
|
|
4905
|
-
const log$
|
|
5049
|
+
const log$13 = logger.child({ module: "context-management-config" });
|
|
4906
5050
|
const DEFAULT_CONTEXT_MANAGEMENT_CONFIG = {
|
|
4907
5051
|
enabled: false,
|
|
4908
5052
|
perResultMaxBytes: 16 * 1024,
|
|
@@ -4947,7 +5091,7 @@ function resolveContextManagementConfig(env = process.env) {
|
|
|
4947
5091
|
clearAtLeastTokens: env.SKYDIVE_CTX_CLEAR_AT_LEAST_TOKENS
|
|
4948
5092
|
});
|
|
4949
5093
|
if (!parsed.success) {
|
|
4950
|
-
log$
|
|
5094
|
+
log$13.warn({
|
|
4951
5095
|
event: "context_management_config_invalid",
|
|
4952
5096
|
err: parsed.error
|
|
4953
5097
|
}, "falling back to default context-management config");
|
|
@@ -5031,7 +5175,7 @@ function hasFlagSource(env = process.env) {
|
|
|
5031
5175
|
* alive and an indeterminate result (no api url / transient failure) leaves the
|
|
5032
5176
|
* last-known values untouched so a blip can't silently flip behavior.
|
|
5033
5177
|
*/
|
|
5034
|
-
const log$
|
|
5178
|
+
const log$12 = logger.child({ module: "feature-flags-poll" });
|
|
5035
5179
|
const FLAG_POLL_INTERVAL_MS = 6e4;
|
|
5036
5180
|
let contextManagement = null;
|
|
5037
5181
|
let closingText = null;
|
|
@@ -5071,7 +5215,7 @@ function apply(name, next) {
|
|
|
5071
5215
|
if (next !== prev) for (const cb of subscribers[name]) try {
|
|
5072
5216
|
cb(next);
|
|
5073
5217
|
} catch (err) {
|
|
5074
|
-
log$
|
|
5218
|
+
log$12.warn({
|
|
5075
5219
|
err,
|
|
5076
5220
|
flag: name
|
|
5077
5221
|
}, "flag subscriber threw");
|
|
@@ -5084,7 +5228,7 @@ async function pollOnce() {
|
|
|
5084
5228
|
apply("contextManagement", flags.contextManagement ?? null);
|
|
5085
5229
|
apply("closingText", flags.closingText ?? null);
|
|
5086
5230
|
} catch (err) {
|
|
5087
|
-
log$
|
|
5231
|
+
log$12.debug({ err }, "feature-flag poll threw");
|
|
5088
5232
|
}
|
|
5089
5233
|
}
|
|
5090
5234
|
/**
|
|
@@ -5286,7 +5430,7 @@ const bashDefaultTimeoutExtension = (pi) => {
|
|
|
5286
5430
|
* turn over an observability feature.
|
|
5287
5431
|
*/
|
|
5288
5432
|
const execFileAsync = promisify(execFile);
|
|
5289
|
-
const log$
|
|
5433
|
+
const log$11 = logger.child({ module: "resource-pressure-warning" });
|
|
5290
5434
|
const POLL_INTERVAL_MS = 1e4;
|
|
5291
5435
|
function envOverride(name) {
|
|
5292
5436
|
for (const prefix of ["SKYDIVE_", "ANYONE_"]) {
|
|
@@ -5483,7 +5627,7 @@ const resourcePressureWarningExtension = (pi) => {
|
|
|
5483
5627
|
warnedDiskThisTurn = true;
|
|
5484
5628
|
}
|
|
5485
5629
|
if (trigger === null) return;
|
|
5486
|
-
log$
|
|
5630
|
+
log$11.warn({
|
|
5487
5631
|
trigger,
|
|
5488
5632
|
mem,
|
|
5489
5633
|
cpuPct,
|
|
@@ -5521,7 +5665,7 @@ const resourcePressureWarningExtension = (pi) => {
|
|
|
5521
5665
|
if (!timer) {
|
|
5522
5666
|
timer = setInterval(() => {
|
|
5523
5667
|
checkOnce().catch((err) => {
|
|
5524
|
-
log$
|
|
5668
|
+
log$11.error({ err }, "resource pressure check failed");
|
|
5525
5669
|
});
|
|
5526
5670
|
}, POLL_INTERVAL_MS);
|
|
5527
5671
|
timer.unref?.();
|
|
@@ -5537,7 +5681,7 @@ const resourcePressureWarningExtension = (pi) => {
|
|
|
5537
5681
|
};
|
|
5538
5682
|
//#endregion
|
|
5539
5683
|
//#region src/extensions/disk-guard.ts
|
|
5540
|
-
const log$
|
|
5684
|
+
const log$10 = logger.child({ module: "disk-guard" });
|
|
5541
5685
|
/**
|
|
5542
5686
|
* In-band bypass. The guard is a safety net, not a jail: when the agent knows
|
|
5543
5687
|
* a flagged command is genuinely safe (writing to a different mount, a tiny
|
|
@@ -5559,7 +5703,7 @@ const BYPASS_HINT$2 = "# disk-guard: allow";
|
|
|
5559
5703
|
* first; the SKYDIVE_/ANYONE_ prefixes are accepted too for consistency with
|
|
5560
5704
|
* the other env overrides. Empty/unset/"0"/"false" leave the guard on.
|
|
5561
5705
|
*/
|
|
5562
|
-
function guardDisabledByEnv$
|
|
5706
|
+
function guardDisabledByEnv$3() {
|
|
5563
5707
|
for (const name of [
|
|
5564
5708
|
"DISK_GUARD_DISABLE",
|
|
5565
5709
|
"SKYDIVE_DISK_GUARD_DISABLE",
|
|
@@ -5670,14 +5814,14 @@ function diskBlockReason(command, diskPct) {
|
|
|
5670
5814
|
const diskGuardExtension = (pi) => {
|
|
5671
5815
|
pi.on("tool_call", async (event) => {
|
|
5672
5816
|
if (event.toolName !== "bash") return;
|
|
5673
|
-
if (guardDisabledByEnv$
|
|
5817
|
+
if (guardDisabledByEnv$3()) return;
|
|
5674
5818
|
const command = event.input.command;
|
|
5675
5819
|
if (typeof command !== "string" || command.length === 0) return;
|
|
5676
5820
|
if (hasBypassMarker$2(command)) return;
|
|
5677
5821
|
if (!isSpaceHungryCommand(command)) return;
|
|
5678
5822
|
const diskPct = await readDiskUsePct();
|
|
5679
5823
|
if (!shouldBlockForDisk(command, diskPct)) return;
|
|
5680
|
-
log$
|
|
5824
|
+
log$10.warn({
|
|
5681
5825
|
diskPct,
|
|
5682
5826
|
command: command.slice(0, 200)
|
|
5683
5827
|
}, "blocked space-hungry bash command on near-full disk");
|
|
@@ -5689,7 +5833,7 @@ const diskGuardExtension = (pi) => {
|
|
|
5689
5833
|
};
|
|
5690
5834
|
//#endregion
|
|
5691
5835
|
//#region src/extensions/noop-loop-guard.ts
|
|
5692
|
-
const log$
|
|
5836
|
+
const log$9 = logger.child({ module: "noop-loop-guard" });
|
|
5693
5837
|
/** Length of the rolling window that counts silence commands across streak resets. */
|
|
5694
5838
|
const SILENCE_WINDOW_MS = 300 * 1e3;
|
|
5695
5839
|
/** Bare shell no-op: `true` or `:` (case-insensitive). */
|
|
@@ -5705,9 +5849,9 @@ const ECHO_ARG_MAX_LEN = 64;
|
|
|
5705
5849
|
/** Marker that forces a single command through the guard. */
|
|
5706
5850
|
const BYPASS_HINT$1 = "noop-guard: allow";
|
|
5707
5851
|
/** Env vars that turn the guard off for the process. */
|
|
5708
|
-
const KILL_SWITCH_KEYS = ["NOOP_LOOP_GUARD_DISABLE", "SKYDIVE_NOOP_LOOP_GUARD_DISABLE"];
|
|
5709
|
-
function guardDisabledByEnv$
|
|
5710
|
-
return KILL_SWITCH_KEYS.some((key) => {
|
|
5852
|
+
const KILL_SWITCH_KEYS$1 = ["NOOP_LOOP_GUARD_DISABLE", "SKYDIVE_NOOP_LOOP_GUARD_DISABLE"];
|
|
5853
|
+
function guardDisabledByEnv$2() {
|
|
5854
|
+
return KILL_SWITCH_KEYS$1.some((key) => {
|
|
5711
5855
|
const value = process.env[key];
|
|
5712
5856
|
return value !== void 0 && value !== "" && value !== "0";
|
|
5713
5857
|
});
|
|
@@ -5831,17 +5975,20 @@ const noopLoopGuardExtension = (pi) => {
|
|
|
5831
5975
|
};
|
|
5832
5976
|
pi.on("tool_call", async (event, ctx) => {
|
|
5833
5977
|
if (event.toolName !== "bash") return;
|
|
5834
|
-
if (guardDisabledByEnv$
|
|
5835
|
-
const
|
|
5836
|
-
if (typeof
|
|
5978
|
+
if (guardDisabledByEnv$2()) return;
|
|
5979
|
+
const rawCommand = event.input.command;
|
|
5980
|
+
if (typeof rawCommand !== "string" || rawCommand.length === 0) return;
|
|
5981
|
+
const command = stripPlatformExportsForDisplay(rawCommand);
|
|
5837
5982
|
const now = Date.now();
|
|
5838
|
-
const
|
|
5983
|
+
const silence = isSilenceCommand(command);
|
|
5984
|
+
const bypassed = silence && hasBypassMarker$1(command);
|
|
5839
5985
|
const streak = recordNoopCommand(state, command, now);
|
|
5986
|
+
if (!silence) return;
|
|
5840
5987
|
const windowCount = countSilenceInWindow(state, now);
|
|
5841
5988
|
if (bypassed) return;
|
|
5842
5989
|
if (streak < 3 && windowCount < 8) return;
|
|
5843
5990
|
const aborted = streak >= 25 || windowCount >= 40;
|
|
5844
|
-
log$
|
|
5991
|
+
log$9.warn({
|
|
5845
5992
|
streak,
|
|
5846
5993
|
windowCount,
|
|
5847
5994
|
aborted,
|
|
@@ -5859,6 +6006,70 @@ const noopLoopGuardExtension = (pi) => {
|
|
|
5859
6006
|
});
|
|
5860
6007
|
};
|
|
5861
6008
|
//#endregion
|
|
6009
|
+
//#region src/extensions/repeat-call-guard.ts
|
|
6010
|
+
const log$8 = logger.child({ module: "repeat-call-guard" });
|
|
6011
|
+
const KILL_SWITCH_KEYS = ["REPEAT_CALL_GUARD_DISABLE", "SKYDIVE_REPEAT_CALL_GUARD_DISABLE"];
|
|
6012
|
+
function guardDisabledByEnv$1() {
|
|
6013
|
+
return KILL_SWITCH_KEYS.some((key) => {
|
|
6014
|
+
const value = process.env[key];
|
|
6015
|
+
return value !== void 0 && value !== "" && value !== "0";
|
|
6016
|
+
});
|
|
6017
|
+
}
|
|
6018
|
+
/**
|
|
6019
|
+
* Identity of a tool call for repeat detection: tool name plus arguments,
|
|
6020
|
+
* minus the fields the platform adds per call.
|
|
6021
|
+
*/
|
|
6022
|
+
function toolCallKey({ toolName, input }) {
|
|
6023
|
+
const normalized = {};
|
|
6024
|
+
for (const [key, value] of Object.entries(input)) {
|
|
6025
|
+
if (TOOL_CALL_SUMMARY_FIELDS.includes(key)) continue;
|
|
6026
|
+
normalized[key] = key === "command" && typeof value === "string" ? stripPlatformExportsForDisplay(value) : value;
|
|
6027
|
+
}
|
|
6028
|
+
return `${toolName}\u0000${JSON.stringify(normalized)}`;
|
|
6029
|
+
}
|
|
6030
|
+
/** Count one call against the streak; returns the new streak length. */
|
|
6031
|
+
function recordToolCall(state, key) {
|
|
6032
|
+
state.streak = key === state.lastKey ? state.streak + 1 : 1;
|
|
6033
|
+
state.lastKey = key;
|
|
6034
|
+
return state.streak;
|
|
6035
|
+
}
|
|
6036
|
+
function repeatBlockReason({ toolName, streak, aborted }) {
|
|
6037
|
+
const head = `Repeated call: ${streak} consecutive \`${toolName}\` calls with exactly the same arguments. Repeating it will not change the outcome. If you are done, END THE TURN (reply, or emit nothing to stay silent). If you are waiting on a background task, end the turn: it wakes you when it finishes. Otherwise change approach.`;
|
|
6038
|
+
if (aborted) return `${head} The harness is now stopping this run.`;
|
|
6039
|
+
const remaining = 40 - streak;
|
|
6040
|
+
return `${head} ${remaining} more identical call${remaining === 1 ? "" : "s"} and the harness stops the run.`;
|
|
6041
|
+
}
|
|
6042
|
+
const repeatCallGuardExtension = (pi) => {
|
|
6043
|
+
const state = {
|
|
6044
|
+
lastKey: null,
|
|
6045
|
+
streak: 0
|
|
6046
|
+
};
|
|
6047
|
+
pi.on("tool_call", async (event, ctx) => {
|
|
6048
|
+
if (guardDisabledByEnv$1()) return;
|
|
6049
|
+
const streak = recordToolCall(state, toolCallKey({
|
|
6050
|
+
toolName: event.toolName,
|
|
6051
|
+
input: event.input
|
|
6052
|
+
}));
|
|
6053
|
+
if (streak < 20) return;
|
|
6054
|
+
const aborted = streak >= 40;
|
|
6055
|
+
log$8.warn({
|
|
6056
|
+
toolName: event.toolName,
|
|
6057
|
+
streak,
|
|
6058
|
+
aborted,
|
|
6059
|
+
toolCallId: event.toolCallId
|
|
6060
|
+
}, "repeat-call guard fired");
|
|
6061
|
+
if (aborted) ctx.abort();
|
|
6062
|
+
return {
|
|
6063
|
+
block: true,
|
|
6064
|
+
reason: repeatBlockReason({
|
|
6065
|
+
toolName: event.toolName,
|
|
6066
|
+
streak,
|
|
6067
|
+
aborted
|
|
6068
|
+
})
|
|
6069
|
+
};
|
|
6070
|
+
});
|
|
6071
|
+
};
|
|
6072
|
+
//#endregion
|
|
5862
6073
|
//#region src/extensions/sleep-guard.ts
|
|
5863
6074
|
/**
|
|
5864
6075
|
* Foreground sleep guard: block `sleep` commands that hold the turn open.
|
|
@@ -7471,6 +7682,7 @@ const all = [
|
|
|
7471
7682
|
bashDefaultTimeoutExtension,
|
|
7472
7683
|
diskGuardExtension,
|
|
7473
7684
|
noopLoopGuardExtension,
|
|
7685
|
+
repeatCallGuardExtension,
|
|
7474
7686
|
sleepGuardExtension,
|
|
7475
7687
|
toolCallSummaryExtension
|
|
7476
7688
|
];
|