@namzu/sdk 69.2.0 → 69.4.0
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/CHANGELOG.md +25 -0
- package/dist/authorization/readonly-commands.d.ts.map +1 -1
- package/dist/authorization/readonly-commands.js +30 -2
- package/dist/authorization/readonly-commands.js.map +1 -1
- package/dist/constants/plugin/index.d.ts +8 -0
- package/dist/constants/plugin/index.d.ts.map +1 -1
- package/dist/constants/plugin/index.js +8 -0
- package/dist/constants/plugin/index.js.map +1 -1
- package/dist/plugin/common-layout/index.d.ts +5 -0
- package/dist/plugin/common-layout/index.d.ts.map +1 -0
- package/dist/plugin/common-layout/index.js +3 -0
- package/dist/plugin/common-layout/index.js.map +1 -0
- package/dist/plugin/common-layout/mcp.d.ts +21 -0
- package/dist/plugin/common-layout/mcp.d.ts.map +1 -0
- package/dist/plugin/common-layout/mcp.js +305 -0
- package/dist/plugin/common-layout/mcp.js.map +1 -0
- package/dist/plugin/common-layout/paths.d.ts +27 -0
- package/dist/plugin/common-layout/paths.d.ts.map +1 -0
- package/dist/plugin/common-layout/paths.js +48 -0
- package/dist/plugin/common-layout/paths.js.map +1 -0
- package/dist/plugin/common-layout/read.d.ts +25 -0
- package/dist/plugin/common-layout/read.d.ts.map +1 -0
- package/dist/plugin/common-layout/read.js +1155 -0
- package/dist/plugin/common-layout/read.js.map +1 -0
- package/dist/plugin/common-layout/types.d.ts +66 -0
- package/dist/plugin/common-layout/types.d.ts.map +1 -0
- package/dist/plugin/common-layout/types.js +2 -0
- package/dist/plugin/common-layout/types.js.map +1 -0
- package/dist/plugin/common-layout-names.d.ts +65 -0
- package/dist/plugin/common-layout-names.d.ts.map +1 -0
- package/dist/plugin/common-layout-names.js +94 -0
- package/dist/plugin/common-layout-names.js.map +1 -0
- package/dist/plugin/hook-module/capabilities.d.ts +41 -0
- package/dist/plugin/hook-module/capabilities.d.ts.map +1 -0
- package/dist/plugin/hook-module/capabilities.js +438 -0
- package/dist/plugin/hook-module/capabilities.js.map +1 -0
- package/dist/plugin/hook-module/consent.d.ts +39 -0
- package/dist/plugin/hook-module/consent.d.ts.map +1 -0
- package/dist/plugin/hook-module/consent.js +59 -0
- package/dist/plugin/hook-module/consent.js.map +1 -0
- package/dist/plugin/hook-module/events.d.ts +33 -0
- package/dist/plugin/hook-module/events.d.ts.map +1 -0
- package/dist/plugin/hook-module/events.js +149 -0
- package/dist/plugin/hook-module/events.js.map +1 -0
- package/dist/plugin/hook-module/host.d.ts +79 -0
- package/dist/plugin/hook-module/host.d.ts.map +1 -0
- package/dist/plugin/hook-module/host.js +546 -0
- package/dist/plugin/hook-module/host.js.map +1 -0
- package/dist/plugin/hook-module/index.d.ts +11 -0
- package/dist/plugin/hook-module/index.d.ts.map +1 -0
- package/dist/plugin/hook-module/index.js +6 -0
- package/dist/plugin/hook-module/index.js.map +1 -0
- package/dist/plugin/hook-module/scan.d.ts +99 -0
- package/dist/plugin/hook-module/scan.d.ts.map +1 -0
- package/dist/plugin/hook-module/scan.js +789 -0
- package/dist/plugin/hook-module/scan.js.map +1 -0
- package/dist/plugin/hook-module/worker-source.d.ts +31 -0
- package/dist/plugin/hook-module/worker-source.d.ts.map +1 -0
- package/dist/plugin/hook-module/worker-source.js +498 -0
- package/dist/plugin/hook-module/worker-source.js.map +1 -0
- package/dist/plugin/index.d.ts +5 -2
- package/dist/plugin/index.d.ts.map +1 -1
- package/dist/plugin/index.js +4 -1
- package/dist/plugin/index.js.map +1 -1
- package/dist/plugin/lifecycle.d.ts +57 -0
- package/dist/plugin/lifecycle.d.ts.map +1 -1
- package/dist/plugin/lifecycle.js +92 -11
- package/dist/plugin/lifecycle.js.map +1 -1
- package/dist/plugin/loader.d.ts +30 -0
- package/dist/plugin/loader.d.ts.map +1 -1
- package/dist/plugin/loader.js +76 -19
- package/dist/plugin/loader.js.map +1 -1
- package/dist/plugin/shell-hook-env.d.ts +7 -0
- package/dist/plugin/shell-hook-env.d.ts.map +1 -1
- package/dist/plugin/shell-hook-env.js.map +1 -1
- package/dist/plugin/shell-hook.d.ts +10 -1
- package/dist/plugin/shell-hook.d.ts.map +1 -1
- package/dist/plugin/shell-hook.js +81 -70
- package/dist/plugin/shell-hook.js.map +1 -1
- package/dist/prompt/coding-agent-doctrine.d.ts +1 -1
- package/dist/prompt/coding-agent-doctrine.d.ts.map +1 -1
- package/dist/prompt/coding-agent-doctrine.js +1 -1
- package/dist/provider/side-request-reasoning.d.ts.map +1 -1
- package/dist/provider/side-request-reasoning.js +5 -1
- package/dist/provider/side-request-reasoning.js.map +1 -1
- package/dist/public-runtime.d.ts +3 -2
- package/dist/public-runtime.d.ts.map +1 -1
- package/dist/public-runtime.js +2 -2
- package/dist/public-runtime.js.map +1 -1
- package/dist/runtime/query/auto-review/classifier.d.ts.map +1 -1
- package/dist/runtime/query/auto-review/classifier.js +13 -2
- package/dist/runtime/query/auto-review/classifier.js.map +1 -1
- package/dist/runtime/query/auto-review/failure.d.ts +12 -5
- package/dist/runtime/query/auto-review/failure.d.ts.map +1 -1
- package/dist/runtime/query/auto-review/failure.js +42 -7
- package/dist/runtime/query/auto-review/failure.js.map +1 -1
- package/dist/runtime/query/review-policy.d.ts.map +1 -1
- package/dist/runtime/query/review-policy.js +22 -6
- package/dist/runtime/query/review-policy.js.map +1 -1
- package/dist/runtime/query/turn/check-scope.d.ts +18 -0
- package/dist/runtime/query/turn/check-scope.d.ts.map +1 -0
- package/dist/runtime/query/turn/check-scope.js +90 -0
- package/dist/runtime/query/turn/check-scope.js.map +1 -0
- package/dist/runtime/query/turn/outcome-ledger.d.ts.map +1 -1
- package/dist/runtime/query/turn/outcome-ledger.js +13 -0
- package/dist/runtime/query/turn/outcome-ledger.js.map +1 -1
- package/dist/skills/loader.d.ts +8 -2
- package/dist/skills/loader.d.ts.map +1 -1
- package/dist/skills/loader.js +22 -11
- package/dist/skills/loader.js.map +1 -1
- package/dist/skills/registry.d.ts.map +1 -1
- package/dist/skills/registry.js +9 -1
- package/dist/skills/registry.js.map +1 -1
- package/dist/tools/builtins/job.d.ts.map +1 -1
- package/dist/tools/builtins/job.js +4 -1
- package/dist/tools/builtins/job.js.map +1 -1
- package/dist/tools/builtins/wait-for-job.d.ts.map +1 -1
- package/dist/tools/builtins/wait-for-job.js +2 -1
- package/dist/tools/builtins/wait-for-job.js.map +1 -1
- package/dist/types/plugin/index.d.ts +73 -0
- package/dist/types/plugin/index.d.ts.map +1 -1
- package/dist/types/plugin/index.js +28 -6
- package/dist/types/plugin/index.js.map +1 -1
- package/dist/types/skills/index.d.ts +6 -0
- package/dist/types/skills/index.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/authorization/readonly-commands.ts +30 -2
- package/src/constants/plugin/index.ts +9 -0
- package/src/plugin/common-layout/index.ts +19 -0
- package/src/plugin/common-layout/mcp.ts +362 -0
- package/src/plugin/common-layout/paths.ts +70 -0
- package/src/plugin/common-layout/read.ts +1282 -0
- package/src/plugin/common-layout/types.ts +77 -0
- package/src/plugin/common-layout-names.ts +108 -0
- package/src/plugin/hook-module/capabilities.ts +500 -0
- package/src/plugin/hook-module/consent.ts +96 -0
- package/src/plugin/hook-module/events.ts +177 -0
- package/src/plugin/hook-module/host.ts +649 -0
- package/src/plugin/hook-module/index.ts +52 -0
- package/src/plugin/hook-module/scan.ts +1004 -0
- package/src/plugin/hook-module/worker-source.ts +500 -0
- package/src/plugin/index.ts +13 -1
- package/src/plugin/lifecycle.ts +179 -17
- package/src/plugin/loader.ts +97 -18
- package/src/plugin/shell-hook-env.ts +7 -0
- package/src/plugin/shell-hook.ts +91 -70
- package/src/prompt/coding-agent-doctrine.ts +1 -1
- package/src/provider/side-request-reasoning.ts +5 -1
- package/src/public-runtime.ts +35 -0
- package/src/runtime/query/auto-review/classifier.ts +14 -2
- package/src/runtime/query/auto-review/failure.ts +52 -7
- package/src/runtime/query/review-policy.ts +30 -6
- package/src/runtime/query/turn/check-scope.ts +90 -0
- package/src/runtime/query/turn/outcome-ledger.ts +11 -0
- package/src/skills/loader.ts +26 -9
- package/src/skills/registry.ts +9 -1
- package/src/tools/builtins/job.ts +4 -1
- package/src/tools/builtins/wait-for-job.ts +3 -1
- package/src/types/plugin/index.ts +81 -24
- package/src/types/skills/index.ts +7 -0
package/src/plugin/shell-hook.ts
CHANGED
|
@@ -108,6 +108,11 @@
|
|
|
108
108
|
import { spawn } from 'node:child_process'
|
|
109
109
|
import { constants, accessSync, mkdirSync, statSync } from 'node:fs'
|
|
110
110
|
import { basename, delimiter } from 'node:path'
|
|
111
|
+
import {
|
|
112
|
+
COMMON_DATA_VARIABLE,
|
|
113
|
+
COMMON_PROJECT_VARIABLE,
|
|
114
|
+
COMMON_ROOT_VARIABLE,
|
|
115
|
+
} from './common-layout-names.js'
|
|
111
116
|
|
|
112
117
|
import { decodedCommands, decomposeCommandLine } from '../authorization/command-line.js'
|
|
113
118
|
import {
|
|
@@ -1011,6 +1016,13 @@ export function runShellHook(
|
|
|
1011
1016
|
...(input.plugin !== undefined
|
|
1012
1017
|
? { NAMZU_PLUGIN_ROOT: input.plugin.root, NAMZU_PLUGIN_DATA: input.plugin.dataDir }
|
|
1013
1018
|
: {}),
|
|
1019
|
+
...(input.plugin?.layout === 'common'
|
|
1020
|
+
? {
|
|
1021
|
+
[COMMON_ROOT_VARIABLE]: input.plugin.root,
|
|
1022
|
+
[COMMON_DATA_VARIABLE]: input.plugin.dataDir,
|
|
1023
|
+
[COMMON_PROJECT_VARIABLE]: projectDir,
|
|
1024
|
+
}
|
|
1025
|
+
: {}),
|
|
1014
1026
|
...(input.turnId !== undefined ? { NAMZU_TURN_ID: input.turnId } : {}),
|
|
1015
1027
|
...(input.envFile !== undefined ? { NAMZU_ENV_FILE: input.envFile } : {}),
|
|
1016
1028
|
...(input.toolName !== undefined
|
|
@@ -2239,6 +2251,83 @@ async function runWorktreeHook(
|
|
|
2239
2251
|
*/
|
|
2240
2252
|
let nextHookEnvSlot = 0
|
|
2241
2253
|
|
|
2254
|
+
/**
|
|
2255
|
+
* What a hook is told about an event: the context the kernel dispatched, turned
|
|
2256
|
+
* into the input every kind of hook reads. A command gets it as JSON on stdin,
|
|
2257
|
+
* a module as its `e`.
|
|
2258
|
+
*/
|
|
2259
|
+
export function shellHookInputFor(
|
|
2260
|
+
event: ShellHookEvent,
|
|
2261
|
+
context: PluginHookContext,
|
|
2262
|
+
options: ShellHookOptions,
|
|
2263
|
+
extra: { readonly envFile?: string; readonly toolNames?: ShellHookToolNames } = {},
|
|
2264
|
+
): ShellHookInput {
|
|
2265
|
+
const transcriptPath = options.transcriptPath?.(String(context.sessionId))
|
|
2266
|
+
const permissionMode = options.permissionMode?.()
|
|
2267
|
+
return {
|
|
2268
|
+
event,
|
|
2269
|
+
// A hook told the folder changed runs in the folder entered.
|
|
2270
|
+
cwd: event === 'cwd_changed' && context.newCwd !== undefined ? context.newCwd : options.cwd,
|
|
2271
|
+
...(extra.envFile !== undefined ? { envFile: extra.envFile } : {}),
|
|
2272
|
+
...(context.filePath !== undefined ? { filePath: context.filePath } : {}),
|
|
2273
|
+
...(context.change !== undefined ? { change: context.change } : {}),
|
|
2274
|
+
...(context.oldCwd !== undefined ? { oldCwd: context.oldCwd } : {}),
|
|
2275
|
+
...(context.newCwd !== undefined ? { newCwd: context.newCwd } : {}),
|
|
2276
|
+
...(context.worktreeName !== undefined ? { worktreeName: context.worktreeName } : {}),
|
|
2277
|
+
...(context.worktreeRoot !== undefined ? { worktreeRoot: context.worktreeRoot } : {}),
|
|
2278
|
+
...(context.worktreeBaseRef !== undefined ? { worktreeBaseRef: context.worktreeBaseRef } : {}),
|
|
2279
|
+
...(context.worktreePath !== undefined ? { worktreePath: context.worktreePath } : {}),
|
|
2280
|
+
...(context.modelSwitch !== undefined ? { modelSwitch: context.modelSwitch } : {}),
|
|
2281
|
+
...(context.elicitation !== undefined ? { elicitation: context.elicitation } : {}),
|
|
2282
|
+
...(context.directory !== undefined ? { directory: context.directory } : {}),
|
|
2283
|
+
...(context.directorySource !== undefined ? { directorySource: context.directorySource } : {}),
|
|
2284
|
+
...(context.instructions !== undefined ? { instructions: context.instructions } : {}),
|
|
2285
|
+
...(context.expansion !== undefined ? { expansion: context.expansion } : {}),
|
|
2286
|
+
...(context.skillShell !== undefined ? { skillShell: context.skillShell } : {}),
|
|
2287
|
+
...(context.task !== undefined ? { task: context.task } : {}),
|
|
2288
|
+
...(context.teammateName !== undefined ? { teammateName: context.teammateName } : {}),
|
|
2289
|
+
...(context.teamName !== undefined ? { teamName: context.teamName } : {}),
|
|
2290
|
+
...(options.projectDir !== undefined ? { projectDir: options.projectDir } : {}),
|
|
2291
|
+
...(options.plugin !== undefined ? { plugin: options.plugin } : {}),
|
|
2292
|
+
sessionId: String(context.sessionId),
|
|
2293
|
+
...(context.source !== undefined ? { sessionSource: context.source } : {}),
|
|
2294
|
+
...(context.endReason !== undefined ? { endReason: context.endReason } : {}),
|
|
2295
|
+
...(context.turnId !== undefined ? { turnId: String(context.turnId) } : {}),
|
|
2296
|
+
...(context.parentSessionId !== undefined
|
|
2297
|
+
? { parentSessionId: String(context.parentSessionId) }
|
|
2298
|
+
: {}),
|
|
2299
|
+
...(context.parentTurnId !== undefined ? { parentTurnId: String(context.parentTurnId) } : {}),
|
|
2300
|
+
...(context.agentType !== undefined ? { agentType: context.agentType } : {}),
|
|
2301
|
+
...(context.prompt !== undefined ? { prompt: context.prompt } : {}),
|
|
2302
|
+
...(context.compaction !== undefined ? { compaction: context.compaction } : {}),
|
|
2303
|
+
...(context.toolName !== undefined ? { toolName: context.toolName } : {}),
|
|
2304
|
+
...(extra.toolNames !== undefined ? { toolNames: extra.toolNames } : {}),
|
|
2305
|
+
...(context.toolCallId !== undefined ? { toolCallId: context.toolCallId } : {}),
|
|
2306
|
+
...(context.toolInput !== undefined ? { toolInput: context.toolInput } : {}),
|
|
2307
|
+
...(context.toolResult !== undefined
|
|
2308
|
+
? {
|
|
2309
|
+
toolResult: {
|
|
2310
|
+
success: context.toolResult.success,
|
|
2311
|
+
output: context.toolResult.output,
|
|
2312
|
+
...(context.toolResult.error !== undefined ? { error: context.toolResult.error } : {}),
|
|
2313
|
+
},
|
|
2314
|
+
}
|
|
2315
|
+
: {}),
|
|
2316
|
+
...(context.toolCalls !== undefined ? { toolCalls: context.toolCalls } : {}),
|
|
2317
|
+
...(context.reason !== undefined ? { reason: context.reason } : {}),
|
|
2318
|
+
...(context.error !== undefined ? { error: context.error } : {}),
|
|
2319
|
+
...(context.notification !== undefined ? { notification: context.notification } : {}),
|
|
2320
|
+
...(context.stopHookActive === true ? { stopHookActive: true } : {}),
|
|
2321
|
+
...(context.lastAssistantMessage !== undefined
|
|
2322
|
+
? { lastAssistantMessage: context.lastAssistantMessage }
|
|
2323
|
+
: {}),
|
|
2324
|
+
...(transcriptPath !== undefined ? { transcriptPath } : {}),
|
|
2325
|
+
...(permissionMode !== undefined ? { permissionMode } : {}),
|
|
2326
|
+
...(options.extraEnv !== undefined ? { extraEnv: options.extraEnv } : {}),
|
|
2327
|
+
...(options.skillRoot !== undefined ? { skillRoot: options.skillRoot } : {}),
|
|
2328
|
+
}
|
|
2329
|
+
}
|
|
2330
|
+
|
|
2242
2331
|
/** One entry as a hook definition the lifecycle manager accepts. */
|
|
2243
2332
|
export function createShellHook(
|
|
2244
2333
|
event: ShellHookEvent,
|
|
@@ -2343,8 +2432,6 @@ export function createShellHook(
|
|
|
2343
2432
|
}
|
|
2344
2433
|
if (entry.once === true && !doesTheWork) spent = true
|
|
2345
2434
|
options.onRun?.({ event })
|
|
2346
|
-
const transcriptPath = options.transcriptPath?.(String(context.sessionId))
|
|
2347
|
-
const permissionMode = options.permissionMode?.()
|
|
2348
2435
|
const envEvent =
|
|
2349
2436
|
event === 'session_start' || event === 'cwd_changed' || event === 'file_changed'
|
|
2350
2437
|
? event
|
|
@@ -2354,76 +2441,10 @@ export function createShellHook(
|
|
|
2354
2441
|
envEvent !== undefined && runsACommand
|
|
2355
2442
|
? options.hookEnv?.fileFor(envEvent, envSlot)
|
|
2356
2443
|
: undefined
|
|
2357
|
-
const hookInput
|
|
2358
|
-
event,
|
|
2359
|
-
// A hook told the folder changed runs in the folder entered.
|
|
2360
|
-
cwd: event === 'cwd_changed' && context.newCwd !== undefined ? context.newCwd : options.cwd,
|
|
2444
|
+
const hookInput = shellHookInputFor(event, context, options, {
|
|
2361
2445
|
...(envFile !== undefined ? { envFile } : {}),
|
|
2362
|
-
...(context.filePath !== undefined ? { filePath: context.filePath } : {}),
|
|
2363
|
-
...(context.change !== undefined ? { change: context.change } : {}),
|
|
2364
|
-
...(context.oldCwd !== undefined ? { oldCwd: context.oldCwd } : {}),
|
|
2365
|
-
...(context.newCwd !== undefined ? { newCwd: context.newCwd } : {}),
|
|
2366
|
-
...(context.worktreeName !== undefined ? { worktreeName: context.worktreeName } : {}),
|
|
2367
|
-
...(context.worktreeRoot !== undefined ? { worktreeRoot: context.worktreeRoot } : {}),
|
|
2368
|
-
...(context.worktreeBaseRef !== undefined
|
|
2369
|
-
? { worktreeBaseRef: context.worktreeBaseRef }
|
|
2370
|
-
: {}),
|
|
2371
|
-
...(context.worktreePath !== undefined ? { worktreePath: context.worktreePath } : {}),
|
|
2372
|
-
...(context.modelSwitch !== undefined ? { modelSwitch: context.modelSwitch } : {}),
|
|
2373
|
-
...(context.elicitation !== undefined ? { elicitation: context.elicitation } : {}),
|
|
2374
|
-
...(context.directory !== undefined ? { directory: context.directory } : {}),
|
|
2375
|
-
...(context.directorySource !== undefined
|
|
2376
|
-
? { directorySource: context.directorySource }
|
|
2377
|
-
: {}),
|
|
2378
|
-
...(context.instructions !== undefined ? { instructions: context.instructions } : {}),
|
|
2379
|
-
...(context.expansion !== undefined ? { expansion: context.expansion } : {}),
|
|
2380
|
-
...(context.skillShell !== undefined ? { skillShell: context.skillShell } : {}),
|
|
2381
|
-
...(context.task !== undefined ? { task: context.task } : {}),
|
|
2382
|
-
...(context.teammateName !== undefined ? { teammateName: context.teammateName } : {}),
|
|
2383
|
-
...(context.teamName !== undefined ? { teamName: context.teamName } : {}),
|
|
2384
|
-
...(options.projectDir !== undefined ? { projectDir: options.projectDir } : {}),
|
|
2385
|
-
...(options.plugin !== undefined ? { plugin: options.plugin } : {}),
|
|
2386
|
-
sessionId: String(context.sessionId),
|
|
2387
|
-
...(context.source !== undefined ? { sessionSource: context.source } : {}),
|
|
2388
|
-
...(context.endReason !== undefined ? { endReason: context.endReason } : {}),
|
|
2389
|
-
...(context.turnId !== undefined ? { turnId: String(context.turnId) } : {}),
|
|
2390
|
-
...(context.parentSessionId !== undefined
|
|
2391
|
-
? { parentSessionId: String(context.parentSessionId) }
|
|
2392
|
-
: {}),
|
|
2393
|
-
...(context.parentTurnId !== undefined
|
|
2394
|
-
? { parentTurnId: String(context.parentTurnId) }
|
|
2395
|
-
: {}),
|
|
2396
|
-
...(context.agentType !== undefined ? { agentType: context.agentType } : {}),
|
|
2397
|
-
...(context.prompt !== undefined ? { prompt: context.prompt } : {}),
|
|
2398
|
-
...(context.compaction !== undefined ? { compaction: context.compaction } : {}),
|
|
2399
|
-
...(context.toolName !== undefined ? { toolName: context.toolName } : {}),
|
|
2400
2446
|
...(entry.toolNames !== undefined ? { toolNames: entry.toolNames } : {}),
|
|
2401
|
-
|
|
2402
|
-
...(context.toolInput !== undefined ? { toolInput: context.toolInput } : {}),
|
|
2403
|
-
...(context.toolResult !== undefined
|
|
2404
|
-
? {
|
|
2405
|
-
toolResult: {
|
|
2406
|
-
success: context.toolResult.success,
|
|
2407
|
-
output: context.toolResult.output,
|
|
2408
|
-
...(context.toolResult.error !== undefined
|
|
2409
|
-
? { error: context.toolResult.error }
|
|
2410
|
-
: {}),
|
|
2411
|
-
},
|
|
2412
|
-
}
|
|
2413
|
-
: {}),
|
|
2414
|
-
...(context.toolCalls !== undefined ? { toolCalls: context.toolCalls } : {}),
|
|
2415
|
-
...(context.reason !== undefined ? { reason: context.reason } : {}),
|
|
2416
|
-
...(context.error !== undefined ? { error: context.error } : {}),
|
|
2417
|
-
...(context.notification !== undefined ? { notification: context.notification } : {}),
|
|
2418
|
-
...(context.stopHookActive === true ? { stopHookActive: true } : {}),
|
|
2419
|
-
...(context.lastAssistantMessage !== undefined
|
|
2420
|
-
? { lastAssistantMessage: context.lastAssistantMessage }
|
|
2421
|
-
: {}),
|
|
2422
|
-
...(transcriptPath !== undefined ? { transcriptPath } : {}),
|
|
2423
|
-
...(permissionMode !== undefined ? { permissionMode } : {}),
|
|
2424
|
-
...(options.extraEnv !== undefined ? { extraEnv: options.extraEnv } : {}),
|
|
2425
|
-
...(options.skillRoot !== undefined ? { skillRoot: options.skillRoot } : {}),
|
|
2426
|
-
}
|
|
2447
|
+
})
|
|
2427
2448
|
const verdictCall: ShellHookCall = {
|
|
2428
2449
|
...(context.toolName !== undefined ? { toolName: context.toolName } : {}),
|
|
2429
2450
|
...(context.toolInput !== undefined ? { toolInput: context.toolInput } : {}),
|
|
@@ -69,7 +69,7 @@ export const CODING_AGENT_WORKING_DOCTRINE = `## How you work
|
|
|
69
69
|
This section applies only when you were asked to change something.
|
|
70
70
|
- Begin editing once you know the first change; the requested scope is the deliverable, at the size asked. Match the surrounding idiom.
|
|
71
71
|
- Prefer the dedicated tools over shell equivalents (\`read\` over \`cat\`, \`grep\` over a shell grep, \`glob\` over \`find\`, \`edit\` over \`sed -i\`, \`write\` over a redirect); use \`bash\` for the rest.
|
|
72
|
-
- For a defect, reproduce it first with a small script or a failing test; a script stays in the scratch folder unless it becomes a test. After the change, rerun it. Run the project's tests and lint or format check, and add tests for behaviour you introduced. Claim only the checks you ran.
|
|
72
|
+
- For a defect, reproduce it first with a small script or a failing test; a script stays in the scratch folder unless it becomes a test. After the change, rerun it. Run the project's tests and lint or format check, and add tests for behaviour you introduced. Claim only the checks you ran; name what you skipped, and call a partial count partial.
|
|
73
73
|
- Say where any throwaway file you made is, and which files outside the request you touched.
|
|
74
74
|
|
|
75
75
|
### Working with git
|
|
@@ -71,9 +71,13 @@ function refusesReasoningControls(error: unknown): boolean {
|
|
|
71
71
|
// request nor switch the controls off for the model.
|
|
72
72
|
if (/rate.?limit|too many requests|overloaded|timed? ?out|\b(429|5\d\d)\b/i.test(text))
|
|
73
73
|
return false
|
|
74
|
+
// A driver that checks the request itself before sending it (the Codex
|
|
75
|
+
// subscription driver refuses `thinking: disabled` beside any effort but
|
|
76
|
+
// `none`) refuses with a plain error that says "requires" or "would not
|
|
77
|
+
// prove"; it is a refusal of the controls all the same.
|
|
74
78
|
const names = /\b(thinking|reasoning|effort)\b/i.test(text)
|
|
75
79
|
const rejects =
|
|
76
|
-
/unsupported|not supported|unsupport|invalid|unknown|unrecogni[sz]ed|unexpected|not allowed|not permitted|does not (?:accept|support|allow)|not accept|extra inputs|bad request|\b400\b|\b422\b/i.test(
|
|
80
|
+
/unsupported|not supported|unsupport|invalid|unknown|unrecogni[sz]ed|unexpected|not allowed|not permitted|does not (?:accept|support|allow)|not accept|extra inputs|bad request|\b400\b|\b422\b|\brequires\b|would not prove/i.test(
|
|
77
81
|
text,
|
|
78
82
|
)
|
|
79
83
|
return names && rejects
|
package/src/public-runtime.ts
CHANGED
|
@@ -846,6 +846,40 @@ export {
|
|
|
846
846
|
worktreeHookVerdict,
|
|
847
847
|
worktreeHookPrinted,
|
|
848
848
|
WORKTREE_HOOK_SHOWN_CHARS,
|
|
849
|
+
expandPluginPaths,
|
|
850
|
+
expandPluginRootText,
|
|
851
|
+
COMMON_MARKETPLACE_DIR,
|
|
852
|
+
COMMON_MARKETPLACE_FILE,
|
|
853
|
+
findCommonLayoutRoot,
|
|
854
|
+
isOfficialLookingMarketplaceName,
|
|
855
|
+
loadPluginManifestWithFindings,
|
|
856
|
+
readCommonLayout,
|
|
857
|
+
hookModuleConsentEntry,
|
|
858
|
+
hookModuleConsentLines,
|
|
859
|
+
locateHookModule,
|
|
860
|
+
scanHookModule,
|
|
861
|
+
startHookModule,
|
|
862
|
+
summarizeHookModule,
|
|
863
|
+
} from './plugin/index.js'
|
|
864
|
+
export type {
|
|
865
|
+
CommonLayoutOptions,
|
|
866
|
+
CommonLayoutRead,
|
|
867
|
+
CommonLayoutSource,
|
|
868
|
+
ExpandedPaths,
|
|
869
|
+
LayoutFinding,
|
|
870
|
+
LayoutFindingLevel,
|
|
871
|
+
HookModuleConsentEntry,
|
|
872
|
+
HookModuleHandle,
|
|
873
|
+
HookModuleLocation,
|
|
874
|
+
HookModuleScan,
|
|
875
|
+
HookModuleSummary,
|
|
876
|
+
LayoutSetupServer,
|
|
877
|
+
LoadedPluginManifest,
|
|
878
|
+
PluginPathValues,
|
|
879
|
+
ScanRefusal,
|
|
880
|
+
ScannedCall,
|
|
881
|
+
ScannedHook,
|
|
882
|
+
StartHookModuleOptions,
|
|
849
883
|
} from './plugin/index.js'
|
|
850
884
|
export type { DefinedPlugin, DefinePluginOptions } from './plugin/define.js'
|
|
851
885
|
|
|
@@ -1480,6 +1514,7 @@ export {
|
|
|
1480
1514
|
assertPluginStatus,
|
|
1481
1515
|
PluginManifestSchema,
|
|
1482
1516
|
PluginMCPServerConfigSchema,
|
|
1517
|
+
PluginRemoteMCPServerConfigSchema,
|
|
1483
1518
|
RENAMED_PLUGIN_HOOK_EVENTS,
|
|
1484
1519
|
} from './types/plugin/index.js'
|
|
1485
1520
|
export { toMemoryCandidate } from './types/session/memory-promotion.js'
|
|
@@ -198,6 +198,12 @@ export {
|
|
|
198
198
|
autoReviewUnavailableFeedback,
|
|
199
199
|
} from './feedback.js'
|
|
200
200
|
|
|
201
|
+
/** The HTTP status the failure carried, as the one log attribute it is kept under. */
|
|
202
|
+
function statusOf(error: unknown): { 'namzu.auto_review.error_status'?: number } {
|
|
203
|
+
const status = classifyProviderError(error).status
|
|
204
|
+
return status !== undefined ? { 'namzu.auto_review.error_status': status } : {}
|
|
205
|
+
}
|
|
206
|
+
|
|
201
207
|
class DeadlineError extends Error {
|
|
202
208
|
readonly retryable = true
|
|
203
209
|
constructor() {
|
|
@@ -430,11 +436,14 @@ export function createAutoReviewClassifier(
|
|
|
430
436
|
if (request.signal?.aborted) {
|
|
431
437
|
return blocked(started, 0, 'aborted', 'the review was cancelled before it finished')
|
|
432
438
|
}
|
|
433
|
-
const why = describeCheckFailure(error, options.quickDeadlineMs ?? 60_000)
|
|
439
|
+
const why = describeCheckFailure(error, options.quickDeadlineMs ?? 60_000, options.model)
|
|
434
440
|
log.warn('auto review could not complete', {
|
|
435
441
|
'namzu.auto_review.stage': 1,
|
|
436
442
|
'namzu.auto_review.failure': why,
|
|
443
|
+
'namzu.auto_review.model': options.model,
|
|
437
444
|
'namzu.auto_review.error': error instanceof Error ? error.message : String(error),
|
|
445
|
+
'namzu.auto_review.error_code': classifyProviderError(error).code,
|
|
446
|
+
...statusOf(error),
|
|
438
447
|
})
|
|
439
448
|
return blocked(
|
|
440
449
|
started,
|
|
@@ -457,11 +466,14 @@ export function createAutoReviewClassifier(
|
|
|
457
466
|
if (request.signal?.aborted) {
|
|
458
467
|
return blocked(started, 1, 'aborted', 'the review was cancelled before it finished')
|
|
459
468
|
}
|
|
460
|
-
const why = describeCheckFailure(error, options.reasonedDeadlineMs ?? 120_000)
|
|
469
|
+
const why = describeCheckFailure(error, options.reasonedDeadlineMs ?? 120_000, options.model)
|
|
461
470
|
log.warn('auto review could not complete', {
|
|
462
471
|
'namzu.auto_review.stage': 2,
|
|
463
472
|
'namzu.auto_review.failure': why,
|
|
473
|
+
'namzu.auto_review.model': options.model,
|
|
464
474
|
'namzu.auto_review.error': error instanceof Error ? error.message : String(error),
|
|
475
|
+
'namzu.auto_review.error_code': classifyProviderError(error).code,
|
|
476
|
+
...statusOf(error),
|
|
465
477
|
})
|
|
466
478
|
return blocked(
|
|
467
479
|
started,
|
|
@@ -1,16 +1,57 @@
|
|
|
1
|
+
import { LOG_SECRET_PATTERNS } from '../../../constants/secret-patterns.js'
|
|
1
2
|
import { classifyProviderError } from '../../../types/provider/errors.js'
|
|
2
3
|
|
|
4
|
+
/** The most characters of the provider's own wording that are shown. */
|
|
5
|
+
const DETAIL_CHARS = 140
|
|
6
|
+
|
|
7
|
+
/** A query-parameter or field name that says its value is a credential. */
|
|
8
|
+
const SENSITIVE_NAME = String.raw`[A-Za-z0-9_.-]*(?:key|token|secret|passw(?:or)?d|pwd|sig|signature|auth|credential|cookie|session)[A-Za-z0-9_.-]*`
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Credential shapes that carry no vendor prefix: URL userinfo, a query
|
|
12
|
+
* parameter or `name: value` / `name=value` pair whose name says secret, and
|
|
13
|
+
* an `x-api-key` style header.
|
|
14
|
+
*/
|
|
15
|
+
function scrubCredentialShapes(input: string): string {
|
|
16
|
+
return input
|
|
17
|
+
.replace(/(\/\/)[^/@\s]+@/g, '$1[REDACTED:userinfo]@')
|
|
18
|
+
.replace(
|
|
19
|
+
new RegExp(
|
|
20
|
+
String.raw`(\b${SENSITIVE_NAME}\b)(\s*[:=]\s*)(?:"[^"]*"|'[^']*'|[^\s&;,"']+)`,
|
|
21
|
+
'gi',
|
|
22
|
+
),
|
|
23
|
+
'$1$2[REDACTED:secret]',
|
|
24
|
+
)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The provider's own wording, fit to show: one line, anything shaped like a
|
|
29
|
+
* credential replaced, and cut short. A refusal that says only "provider
|
|
30
|
+
* error" hides the one fact that tells a person what to change.
|
|
31
|
+
*/
|
|
32
|
+
export function checkFailureDetail(error: unknown): string {
|
|
33
|
+
let text = error instanceof Error ? error.message : String(error)
|
|
34
|
+
for (const [label, pattern] of LOG_SECRET_PATTERNS) {
|
|
35
|
+
pattern.lastIndex = 0
|
|
36
|
+
text = text.replace(pattern, `[REDACTED:${label}]`)
|
|
37
|
+
}
|
|
38
|
+
text = scrubCredentialShapes(text)
|
|
39
|
+
text = text.replace(/\s+/g, ' ').trim()
|
|
40
|
+
return text.length > DETAIL_CHARS ? `${text.slice(0, DETAIL_CHARS - 1)}…` : text
|
|
41
|
+
}
|
|
42
|
+
|
|
3
43
|
/**
|
|
4
44
|
* The class of a failure to complete the safety check, in a few plain words:
|
|
5
|
-
* `no credential for the check model`, `
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* to
|
|
45
|
+
* `no credential for the check model`, `timed out after 60 s`, or, when the
|
|
46
|
+
* class alone says nothing, the status, the model and a short, scrubbed piece
|
|
47
|
+
* of the provider's own wording: `provider returned 400 (gpt-6.2-sol): ...`.
|
|
48
|
+
* The text is cut to one short line with anything shaped like a credential
|
|
49
|
+
* replaced; the whole of it goes to the log.
|
|
9
50
|
*
|
|
10
51
|
* `deadlineMs` is the deadline the pass ran under, when the failure was the
|
|
11
52
|
* deadline expiring.
|
|
12
53
|
*/
|
|
13
|
-
export function describeCheckFailure(error: unknown, deadlineMs?: number): string {
|
|
54
|
+
export function describeCheckFailure(error: unknown, deadlineMs?: number, model?: string): string {
|
|
14
55
|
if (error instanceof Error && error.name === 'DeadlineError') {
|
|
15
56
|
return deadlineMs !== undefined
|
|
16
57
|
? `timed out after ${Math.round(deadlineMs / 1000)} s`
|
|
@@ -44,7 +85,11 @@ export function describeCheckFailure(error: unknown, deadlineMs?: number): strin
|
|
|
44
85
|
return 'could not reach the provider'
|
|
45
86
|
case 'not_found':
|
|
46
87
|
return 'the check model was not found'
|
|
47
|
-
default:
|
|
48
|
-
|
|
88
|
+
default: {
|
|
89
|
+
const head = status !== undefined ? `provider returned ${status}` : 'provider error'
|
|
90
|
+
const where = model !== undefined && model !== '' ? ` (${model})` : ''
|
|
91
|
+
const detail = checkFailureDetail(error)
|
|
92
|
+
return detail === '' ? `${head}${where}` : `${head}${where}: ${detail}`
|
|
93
|
+
}
|
|
49
94
|
}
|
|
50
95
|
}
|
|
@@ -1219,12 +1219,15 @@ export function createReviewHandler(options: ReviewPolicyOptions = {}): ResumeHa
|
|
|
1219
1219
|
// below shows the whole batch, so its yes also answers any question
|
|
1220
1220
|
// the rest of this function would ask; nobody is asked twice.
|
|
1221
1221
|
let answered: ToolReviewAnswer | undefined
|
|
1222
|
-
const ask = async (
|
|
1222
|
+
const ask = async (
|
|
1223
|
+
screenConsent?: true,
|
|
1224
|
+
shown?: readonly ToolCallSummary[],
|
|
1225
|
+
): Promise<ToolReviewAnswer> =>
|
|
1223
1226
|
answered ??
|
|
1224
1227
|
(prompt as ToolReviewPrompt)({
|
|
1225
1228
|
sessionId: request.sessionId,
|
|
1226
1229
|
turnId: request.turnId,
|
|
1227
|
-
toolCalls: request.toolCalls,
|
|
1230
|
+
toolCalls: shown ?? request.toolCalls,
|
|
1228
1231
|
...(screenConsent ? { screenConsent } : {}),
|
|
1229
1232
|
...(request.perCall ? { perCall: true as const } : {}),
|
|
1230
1233
|
...(request.perCall && context?.signal ? { signal: context.signal } : {}),
|
|
@@ -1330,8 +1333,11 @@ export function createReviewHandler(options: ReviewPolicyOptions = {}): ResumeHa
|
|
|
1330
1333
|
if (isPermissive(mode)) {
|
|
1331
1334
|
// A person's answer on the whole batch, as a decision. An escape is
|
|
1332
1335
|
// confirmed by id only here, only for a person's yes.
|
|
1333
|
-
const askPerson = async (
|
|
1334
|
-
|
|
1336
|
+
const askPerson = async (
|
|
1337
|
+
escapes: readonly string[],
|
|
1338
|
+
shown?: readonly ToolCallSummary[],
|
|
1339
|
+
): Promise<HITLResumeDecision> => {
|
|
1340
|
+
const answer = await ask(undefined, shown)
|
|
1335
1341
|
if (answer.kind === 'reject') {
|
|
1336
1342
|
return {
|
|
1337
1343
|
action: 'reject_tools',
|
|
@@ -1351,6 +1357,24 @@ export function createReviewHandler(options: ReviewPolicyOptions = {}): ResumeHa
|
|
|
1351
1357
|
if (mode === 'classify' && !classified) {
|
|
1352
1358
|
const classifier = options.classifier as AutoReviewClassifier
|
|
1353
1359
|
const transcript = context?.transcript() ?? []
|
|
1360
|
+
// When the check cannot give a verdict and a person is asked, the
|
|
1361
|
+
// question is about the calls nothing else settled. A read the static
|
|
1362
|
+
// rules already allow runs without a prompt; it is not put to the
|
|
1363
|
+
// person beside the call that is, so one outage does not turn every
|
|
1364
|
+
// glob and grep of a batch into something to approve.
|
|
1365
|
+
const unsettled = async (): Promise<readonly ToolCallSummary[]> => {
|
|
1366
|
+
const kept: ToolCallSummary[] = []
|
|
1367
|
+
for (const call of request.toolCalls) {
|
|
1368
|
+
if (
|
|
1369
|
+
call.authorization?.decision === 'deny' ||
|
|
1370
|
+
isBypassImmune(call) ||
|
|
1371
|
+
!(await neverSent(call, request.sessionId))
|
|
1372
|
+
) {
|
|
1373
|
+
kept.push(call)
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
return kept
|
|
1377
|
+
}
|
|
1354
1378
|
for (const tc of live) {
|
|
1355
1379
|
// The questions a person must answer are asked of a person, never of a model.
|
|
1356
1380
|
if (isBypassImmune(tc) || (await neverSent(tc, request.sessionId))) continue
|
|
@@ -1382,7 +1406,7 @@ export function createReviewHandler(options: ReviewPolicyOptions = {}): ResumeHa
|
|
|
1382
1406
|
reason: 'auto mode stopped: the conversation is too long for the safety check',
|
|
1383
1407
|
}
|
|
1384
1408
|
}
|
|
1385
|
-
return askPerson(escapes)
|
|
1409
|
+
return askPerson(escapes, await unsettled())
|
|
1386
1410
|
}
|
|
1387
1411
|
transcriptTooLong = false
|
|
1388
1412
|
// A check that could not be completed says nothing about the call,
|
|
@@ -1393,7 +1417,7 @@ export function createReviewHandler(options: ReviewPolicyOptions = {}): ResumeHa
|
|
|
1393
1417
|
if (decision.cause === 'unavailable' || decision.cause === 'unreadable') {
|
|
1394
1418
|
if (prompt) {
|
|
1395
1419
|
options.onClassifierFellBack?.({ reason: decision.reason })
|
|
1396
|
-
return askPerson(escapes)
|
|
1420
|
+
return askPerson(escapes, await unsettled())
|
|
1397
1421
|
}
|
|
1398
1422
|
}
|
|
1399
1423
|
// With nobody to ask, a check that keeps giving no verdict ends the
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether a later run of a check says what an earlier failed run of it would
|
|
3
|
+
* have said, had it passed.
|
|
4
|
+
*
|
|
5
|
+
* The outcome record keys a check by its command line, so the same suite run
|
|
6
|
+
* once for a single file and later for its whole folder, or once with a
|
|
7
|
+
* reporter flag and once with an environment variable, reads as two commands
|
|
8
|
+
* and the first failure would stand for the rest of the turn beside a final
|
|
9
|
+
* state that passes. A pass of a run that includes everything the failed run
|
|
10
|
+
* ran, with nothing narrowing it, settles the failure. Anything the reading
|
|
11
|
+
* cannot place (a different program, a different option, a path outside the
|
|
12
|
+
* later run's paths, a filter the later run adds) leaves the failure standing. A
|
|
13
|
+
* run under a different program prefix (a root-level `pnpm exec biome check` against an
|
|
14
|
+
* in-package `biome check`) is not matched and also leaves it standing.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/** Words of a command line; a quoted run is one word. */
|
|
18
|
+
function words(line: string): string[] {
|
|
19
|
+
const out: string[] = []
|
|
20
|
+
for (const match of line.matchAll(/'[^']*'|"[^"]*"|\S+/gu)) out.push(match[0])
|
|
21
|
+
return out
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Flags that narrow what a test run runs, with a value in the next word. */
|
|
25
|
+
const FILTER_WITH_VALUE = new Set(['-t', '--testNamePattern', '-k', '--grep', '-g'])
|
|
26
|
+
|
|
27
|
+
/** A file or folder; `@scope/package` names a workspace package, not a path. */
|
|
28
|
+
const looksLikePath = (word: string): boolean =>
|
|
29
|
+
!word.startsWith('-') &&
|
|
30
|
+
!word.startsWith('@') &&
|
|
31
|
+
(word.includes('/') || /\.[cm]?[jt]sx?$/u.test(word))
|
|
32
|
+
|
|
33
|
+
interface Scope {
|
|
34
|
+
readonly program: string
|
|
35
|
+
readonly options: readonly string[]
|
|
36
|
+
readonly paths: readonly string[]
|
|
37
|
+
readonly filtered: boolean
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function scopeOf(command: string): Scope | undefined {
|
|
41
|
+
const all = words(command)
|
|
42
|
+
while (all.length > 0 && /^[A-Za-z_]\w*=/u.test(all[0] as string)) all.shift()
|
|
43
|
+
const program: string[] = []
|
|
44
|
+
const options: string[] = []
|
|
45
|
+
const paths: string[] = []
|
|
46
|
+
let filtered = false
|
|
47
|
+
let seenPath = false
|
|
48
|
+
for (let at = 0; at < all.length; at++) {
|
|
49
|
+
const word = all[at] as string
|
|
50
|
+
if (word === '--') continue
|
|
51
|
+
if (FILTER_WITH_VALUE.has(word)) {
|
|
52
|
+
filtered = true
|
|
53
|
+
at++
|
|
54
|
+
continue
|
|
55
|
+
}
|
|
56
|
+
if (/^--(?:testNamePattern|grep)=/u.test(word)) {
|
|
57
|
+
filtered = true
|
|
58
|
+
continue
|
|
59
|
+
}
|
|
60
|
+
if (word.startsWith('--reporter')) {
|
|
61
|
+
// `--reporter=dot` and `--reporter dot` change how the answer is drawn, not what runs.
|
|
62
|
+
if (!word.includes('=')) at++
|
|
63
|
+
continue
|
|
64
|
+
}
|
|
65
|
+
if (looksLikePath(word)) {
|
|
66
|
+
seenPath = true
|
|
67
|
+
paths.push(word.replace(/\/+$/u, ''))
|
|
68
|
+
} else if (word.startsWith('-') && program.length > 0) options.push(word)
|
|
69
|
+
else if (!seenPath) program.push(word)
|
|
70
|
+
else return undefined
|
|
71
|
+
}
|
|
72
|
+
if (program.length === 0) return undefined
|
|
73
|
+
return { program: program.join(' '), options: options.sort(), paths, filtered }
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** True when a passing `later` run covers everything a failed `earlier` run ran. */
|
|
77
|
+
export function laterRunCovers(later: string, earlier: string): boolean {
|
|
78
|
+
const after = scopeOf(later)
|
|
79
|
+
const before = scopeOf(earlier)
|
|
80
|
+
if (after === undefined || before === undefined) return false
|
|
81
|
+
if (after.filtered || after.program !== before.program) return false
|
|
82
|
+
if (before.options.some((option) => !after.options.includes(option))) return false
|
|
83
|
+
// A run with no path names the whole of what its program checks, so it covers any
|
|
84
|
+
// earlier run of that program; an earlier path-less run is covered only by another.
|
|
85
|
+
if (after.paths.length === 0) return true
|
|
86
|
+
if (before.paths.length === 0) return false
|
|
87
|
+
return before.paths.every((path) =>
|
|
88
|
+
after.paths.some((held) => path === held || path.startsWith(`${held}/`)),
|
|
89
|
+
)
|
|
90
|
+
}
|
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
type TurnOutcomeVerdict,
|
|
27
27
|
} from '../../../types/session/outcome.js'
|
|
28
28
|
import type { ToolFacts } from '../../../types/tool/index.js'
|
|
29
|
+
import { laterRunCovers } from './check-scope.js'
|
|
29
30
|
import { WRITING_TOOLS, isVerificationCommand } from './completion-audit.js'
|
|
30
31
|
|
|
31
32
|
/** A finished tool call as the ledger sees it. */
|
|
@@ -611,6 +612,13 @@ export class OutcomeLedger {
|
|
|
611
612
|
// Latest run of each distinct command, ordered by when it last ran.
|
|
612
613
|
this.checks.delete(key)
|
|
613
614
|
this.checks.set(key, state)
|
|
615
|
+
// A pass of a run that includes what an earlier failed run ran settles that
|
|
616
|
+
// failure: the line must not name it beside a final state that passes.
|
|
617
|
+
if (state.result === 'passed') {
|
|
618
|
+
for (const [held, check] of this.checks) {
|
|
619
|
+
if (check.result === 'failed' && laterRunCovers(key, held)) this.checks.delete(held)
|
|
620
|
+
}
|
|
621
|
+
}
|
|
614
622
|
if (this.checks.size > MAX_REMEMBERED_CHECKS) {
|
|
615
623
|
// A failing check is never the one forgotten.
|
|
616
624
|
for (const [candidate, held] of this.checks) {
|
|
@@ -639,6 +647,9 @@ export class OutcomeLedger {
|
|
|
639
647
|
if (facts.background === true || facts.continued === true || facts.timedOut === true) {
|
|
640
648
|
return { result: 'unsettled', ...withCode }
|
|
641
649
|
}
|
|
650
|
+
// Stopped by a signal (a job the operator or the model killed): it was cut
|
|
651
|
+
// short, not found wanting, so it neither passes nor fails.
|
|
652
|
+
if (facts.signal !== undefined && exitCode === undefined) return { result: 'unsettled' }
|
|
642
653
|
if (exitCode === undefined) {
|
|
643
654
|
return { result: call.isError === true ? 'failed' : 'unsettled' }
|
|
644
655
|
}
|