agent-nuvira 3.5.7 → 3.5.9
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/agents/agents/package-agent.d.ts +22 -0
- package/dist/agents/agents/package-agent.d.ts.map +1 -1
- package/dist/agents/agents/package-agent.js +92 -4
- package/dist/agents/agents/package-agent.js.map +1 -1
- package/dist/agents/release-preflight.d.ts +42 -5
- package/dist/agents/release-preflight.d.ts.map +1 -1
- package/dist/agents/release-preflight.js +82 -5
- package/dist/agents/release-preflight.js.map +1 -1
- package/dist/cli/chat.d.ts.map +1 -1
- package/dist/cli/chat.js +99 -9
- package/dist/cli/chat.js.map +1 -1
- package/dist/cli/code-map.d.ts +51 -0
- package/dist/cli/code-map.d.ts.map +1 -1
- package/dist/cli/code-map.js +174 -2
- package/dist/cli/code-map.js.map +1 -1
- package/dist/cli/credentials.d.ts.map +1 -1
- package/dist/cli/credentials.js +4 -1
- package/dist/cli/credentials.js.map +1 -1
- package/dist/cli/execute.js +5 -5
- package/dist/cli/execute.js.map +1 -1
- package/dist/cli/loop-executor.d.ts.map +1 -1
- package/dist/cli/loop-executor.js +76 -13
- package/dist/cli/loop-executor.js.map +1 -1
- package/dist/config/process-env.d.ts.map +1 -1
- package/dist/config/process-env.js +2 -2
- package/dist/config/process-env.js.map +1 -1
- package/dist/editing/types.d.ts +23 -1
- package/dist/editing/types.d.ts.map +1 -1
- package/dist/editing/types.js +51 -7
- package/dist/editing/types.js.map +1 -1
- package/dist/inference/route-resolver.d.ts +39 -0
- package/dist/inference/route-resolver.d.ts.map +1 -1
- package/dist/inference/route-resolver.js +51 -2
- package/dist/inference/route-resolver.js.map +1 -1
- package/dist/inference/thinking-replay.d.ts +86 -0
- package/dist/inference/thinking-replay.d.ts.map +1 -0
- package/dist/inference/thinking-replay.js +110 -0
- package/dist/inference/thinking-replay.js.map +1 -0
- package/dist/inference/tools.d.ts +9 -0
- package/dist/inference/tools.d.ts.map +1 -1
- package/dist/inference/tools.js +12 -1
- package/dist/inference/tools.js.map +1 -1
- package/dist/learning/assessment-protocol.d.ts +120 -0
- package/dist/learning/assessment-protocol.d.ts.map +1 -0
- package/dist/learning/assessment-protocol.js +236 -0
- package/dist/learning/assessment-protocol.js.map +1 -0
- package/dist/learning/assessment-turn-context.d.ts +54 -0
- package/dist/learning/assessment-turn-context.d.ts.map +1 -0
- package/dist/learning/assessment-turn-context.js +71 -0
- package/dist/learning/assessment-turn-context.js.map +1 -0
- package/dist/learning/exhaustion-report.d.ts +24 -1
- package/dist/learning/exhaustion-report.d.ts.map +1 -1
- package/dist/learning/exhaustion-report.js +18 -6
- package/dist/learning/exhaustion-report.js.map +1 -1
- package/dist/learning/perf-probe.d.ts +140 -0
- package/dist/learning/perf-probe.d.ts.map +1 -0
- package/dist/learning/perf-probe.js +316 -0
- package/dist/learning/perf-probe.js.map +1 -0
- package/dist/learning/self-check-discovery.d.ts +117 -0
- package/dist/learning/self-check-discovery.d.ts.map +1 -0
- package/dist/learning/self-check-discovery.js +334 -0
- package/dist/learning/self-check-discovery.js.map +1 -0
- package/dist/tools/child-agent-runtime.js +19 -1
- package/dist/tools/child-agent-runtime.js.map +1 -1
- package/dist/tools/credentials-tool.d.ts.map +1 -1
- package/dist/tools/credentials-tool.js +4 -1
- package/dist/tools/credentials-tool.js.map +1 -1
- package/dist/tools/loop-project-context.d.ts +7 -0
- package/dist/tools/loop-project-context.d.ts.map +1 -1
- package/dist/tools/loop-project-context.js +44 -0
- package/dist/tools/loop-project-context.js.map +1 -1
- package/dist/tools/pipeline-tool.d.ts.map +1 -1
- package/dist/tools/pipeline-tool.js +19 -1
- package/dist/tools/pipeline-tool.js.map +1 -1
- package/dist/tools/plan-store.d.ts +90 -6
- package/dist/tools/plan-store.d.ts.map +1 -1
- package/dist/tools/plan-store.js +140 -13
- package/dist/tools/plan-store.js.map +1 -1
- package/dist/tools/publish-tool.d.ts.map +1 -1
- package/dist/tools/publish-tool.js +9 -0
- package/dist/tools/publish-tool.js.map +1 -1
- package/dist/tools/registry.d.ts.map +1 -1
- package/dist/tools/registry.js +25 -3
- package/dist/tools/registry.js.map +1 -1
- package/dist/tools/tool-loop.d.ts +17 -0
- package/dist/tools/tool-loop.d.ts.map +1 -1
- package/dist/tools/tool-loop.js +4 -1
- package/dist/tools/tool-loop.js.map +1 -1
- package/dist/web-dashboard/chat-console.d.ts.map +1 -1
- package/dist/web-dashboard/chat-console.js +11 -1
- package/dist/web-dashboard/chat-console.js.map +1 -1
- package/dist/web-dashboard/project-context.js +6 -0
- package/dist/web-dashboard/project-context.js.map +1 -1
- package/dist/web-dashboard/server.d.ts.map +1 -1
- package/dist/web-dashboard/server.js +25 -3
- package/dist/web-dashboard/server.js.map +1 -1
- package/package.json +1 -1
- package/src/web-dashboard/public/assets/{index-V0rIqVbg.js → index-CGYIlLpO.js} +3 -3
- package/src/web-dashboard/public/assets/index-CGYIlLpO.js.map +1 -0
- package/src/web-dashboard/public/index.html +1 -1
- package/src/web-dashboard/public/assets/index-V0rIqVbg.js.map +0 -1
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THINKING-MODE REASONING REPLAY — the wire invariant DeepSeek's tool-calling
|
|
3
|
+
* thinking mode enforces, kept true by the harness instead of by luck.
|
|
4
|
+
*
|
|
5
|
+
* THE CONTRACT (DeepSeek's own docs, quoted in full because the exact wording is
|
|
6
|
+
* the whole argument): "For turns that do perform tool calls, the
|
|
7
|
+
* `reasoning_content` must be fully passed back to the API in all subsequent
|
|
8
|
+
* requests. If your code does not correctly pass back `reasoning_content`, the
|
|
9
|
+
* API will return a 400 error."
|
|
10
|
+
*
|
|
11
|
+
* OBSERVED FAILURE (2026-10-16, a real assessment run on this repository —
|
|
12
|
+
* `~/.nuvira/debug-logs/cli-chat-1792147116253.log`, provider `deepseek`,
|
|
13
|
+
* model `deepseek-flash`, transport `native`). Late in the turn, after the loop
|
|
14
|
+
* recovered a tool call the model had written as TEXT, four consecutive requests
|
|
15
|
+
* were rejected:
|
|
16
|
+
*
|
|
17
|
+
* 400 {"error":{"message":"The `reasoning_content` in the thinking mode must
|
|
18
|
+
* be passed back to the API. (request_id: ffd98335-…)"}}
|
|
19
|
+
*
|
|
20
|
+
* …each with a DIFFERENT request_id and an identical body, so all four were the
|
|
21
|
+
* same invalid request re-sent: the loop's bounded mid-turn continuation retried
|
|
22
|
+
* the identical thread four times (`continuation 2/4` … `4/4`) and the turn only
|
|
23
|
+
* completed because the provider walk eventually reached a candidate that
|
|
24
|
+
* tolerated the thread. Nothing repaired the request, because nothing could see
|
|
25
|
+
* what was wrong with it.
|
|
26
|
+
*
|
|
27
|
+
* WHAT WAS WRONG. The loop records `reasoningContent` on an assistant turn only
|
|
28
|
+
* when that step's response carried one (`tool-loop.ts`: `...(response.reasoningContent
|
|
29
|
+
* ? { reasoningContent: response.reasoningContent } : {})`), which is correct and
|
|
30
|
+
* is not the bug. The bug is that a conversation can end up INCONSISTENT — some
|
|
31
|
+
* assistant turns with reasoning, one tool-call turn without — because a single
|
|
32
|
+
* step returned no reasoning (a provider/gateway that omits it for a tool call, or
|
|
33
|
+
* a tool call recovered from text rather than a native `tool_calls` field).
|
|
34
|
+
* Demonstrated deterministically against this repository's own loop: a mock
|
|
35
|
+
* provider that reasons on step 1 and not on step 2 makes step 3's request carry
|
|
36
|
+
* `toolCalls: [c2]` with no reasoning, while the sibling turn still has it.
|
|
37
|
+
* Reported identically by other harnesses (opencode #24722, claude-code-router
|
|
38
|
+
* #1378): "if ALL assistant messages consistently include `reasoning_content`
|
|
39
|
+
* (including the `tool_calls` message), the request succeeds".
|
|
40
|
+
*
|
|
41
|
+
* THE REPAIR, AND WHY THIS ONE. The API accepts either consistent extreme, and
|
|
42
|
+
* this module picks the one that never discards the model's own reasoning: a gap
|
|
43
|
+
* is FILLED so the conversation stays uniform, rather than the whole thread being
|
|
44
|
+
* stripped to match the gap. Stripping would throw away real reasoning from every
|
|
45
|
+
* earlier turn (which the contract says the endpoint wants), so filling is both
|
|
46
|
+
* the smaller loss and the remedy the API's own bug report suggests.
|
|
47
|
+
*
|
|
48
|
+
* MEASURED SAFE (2026-10-16, live, `api.deepseek.com`, model `deepseek-flash`,
|
|
49
|
+
* via this repository's configured provider): a tool-call turn carrying the
|
|
50
|
+
* placeholder below is accepted — HTTP 200 with a normal completion — exactly
|
|
51
|
+
* like the same conversation with the gap unfilled and with all reasoning
|
|
52
|
+
* stripped. So on today's endpoint this is a NO-OP for a thread that would
|
|
53
|
+
* otherwise be served, and it closes the gap for the endpoint that enforces the
|
|
54
|
+
* rule (the run above shows that endpoint exists and that we can meet it).
|
|
55
|
+
*
|
|
56
|
+
* NARROWNESS. Nothing is added unless the conversation ALREADY carries reasoning
|
|
57
|
+
* on some assistant turn — a non-thinking provider's thread is untouched, and the
|
|
58
|
+
* wire stays byte-identical. Only turns that carry `tool_calls` are filled, which
|
|
59
|
+
* is the turn class the contract names; a content-only assistant turn is left
|
|
60
|
+
* alone because no rule requires it and inventing text there would be noise.
|
|
61
|
+
*/
|
|
62
|
+
import type { ToolMessage } from './interface.js';
|
|
63
|
+
/**
|
|
64
|
+
* What a gap is filled with.
|
|
65
|
+
*
|
|
66
|
+
* Deliberately a statement of FACT about our own bookkeeping rather than an
|
|
67
|
+
* invented chain of thought: the endpoint requires the field's presence on a
|
|
68
|
+
* tool-call turn, and the model reading it back must not be told a plausible lie
|
|
69
|
+
* about what it was thinking. A thinking model that sees this knows only that the
|
|
70
|
+
* reasoning for that call was not retained — which is true.
|
|
71
|
+
*/
|
|
72
|
+
export declare const REASONING_NOT_RETAINED = "(reasoning for this tool call was not retained)";
|
|
73
|
+
/**
|
|
74
|
+
* Apply the invariant to a conversation, returning a NEW array only when a gap
|
|
75
|
+
* had to be filled (otherwise the caller's array is returned unchanged, so a
|
|
76
|
+
* valid conversation keeps the exact wire shape it had).
|
|
77
|
+
*
|
|
78
|
+
* Returns the messages plus how many gaps were filled, so a caller can log that
|
|
79
|
+
* it happened — a repair nobody can see is indistinguishable from a request that
|
|
80
|
+
* was always valid.
|
|
81
|
+
*/
|
|
82
|
+
export declare function applyThinkingReplayInvariant(messages: readonly ToolMessage[]): {
|
|
83
|
+
messages: readonly ToolMessage[];
|
|
84
|
+
filled: number;
|
|
85
|
+
};
|
|
86
|
+
//# sourceMappingURL=thinking-replay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thinking-replay.d.ts","sourceRoot":"","sources":["../../src/inference/thinking-replay.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD;;;;;;;;GAQG;AACH,eAAO,MAAM,sBAAsB,oDAAoD,CAAC;AAgBxF;;;;;;;;GAQG;AACH,wBAAgB,4BAA4B,CAC1C,QAAQ,EAAE,SAAS,WAAW,EAAE,GAC/B;IAAE,QAAQ,EAAE,SAAS,WAAW,EAAE,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAatD"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THINKING-MODE REASONING REPLAY — the wire invariant DeepSeek's tool-calling
|
|
3
|
+
* thinking mode enforces, kept true by the harness instead of by luck.
|
|
4
|
+
*
|
|
5
|
+
* THE CONTRACT (DeepSeek's own docs, quoted in full because the exact wording is
|
|
6
|
+
* the whole argument): "For turns that do perform tool calls, the
|
|
7
|
+
* `reasoning_content` must be fully passed back to the API in all subsequent
|
|
8
|
+
* requests. If your code does not correctly pass back `reasoning_content`, the
|
|
9
|
+
* API will return a 400 error."
|
|
10
|
+
*
|
|
11
|
+
* OBSERVED FAILURE (2026-10-16, a real assessment run on this repository —
|
|
12
|
+
* `~/.nuvira/debug-logs/cli-chat-1792147116253.log`, provider `deepseek`,
|
|
13
|
+
* model `deepseek-flash`, transport `native`). Late in the turn, after the loop
|
|
14
|
+
* recovered a tool call the model had written as TEXT, four consecutive requests
|
|
15
|
+
* were rejected:
|
|
16
|
+
*
|
|
17
|
+
* 400 {"error":{"message":"The `reasoning_content` in the thinking mode must
|
|
18
|
+
* be passed back to the API. (request_id: ffd98335-…)"}}
|
|
19
|
+
*
|
|
20
|
+
* …each with a DIFFERENT request_id and an identical body, so all four were the
|
|
21
|
+
* same invalid request re-sent: the loop's bounded mid-turn continuation retried
|
|
22
|
+
* the identical thread four times (`continuation 2/4` … `4/4`) and the turn only
|
|
23
|
+
* completed because the provider walk eventually reached a candidate that
|
|
24
|
+
* tolerated the thread. Nothing repaired the request, because nothing could see
|
|
25
|
+
* what was wrong with it.
|
|
26
|
+
*
|
|
27
|
+
* WHAT WAS WRONG. The loop records `reasoningContent` on an assistant turn only
|
|
28
|
+
* when that step's response carried one (`tool-loop.ts`: `...(response.reasoningContent
|
|
29
|
+
* ? { reasoningContent: response.reasoningContent } : {})`), which is correct and
|
|
30
|
+
* is not the bug. The bug is that a conversation can end up INCONSISTENT — some
|
|
31
|
+
* assistant turns with reasoning, one tool-call turn without — because a single
|
|
32
|
+
* step returned no reasoning (a provider/gateway that omits it for a tool call, or
|
|
33
|
+
* a tool call recovered from text rather than a native `tool_calls` field).
|
|
34
|
+
* Demonstrated deterministically against this repository's own loop: a mock
|
|
35
|
+
* provider that reasons on step 1 and not on step 2 makes step 3's request carry
|
|
36
|
+
* `toolCalls: [c2]` with no reasoning, while the sibling turn still has it.
|
|
37
|
+
* Reported identically by other harnesses (opencode #24722, claude-code-router
|
|
38
|
+
* #1378): "if ALL assistant messages consistently include `reasoning_content`
|
|
39
|
+
* (including the `tool_calls` message), the request succeeds".
|
|
40
|
+
*
|
|
41
|
+
* THE REPAIR, AND WHY THIS ONE. The API accepts either consistent extreme, and
|
|
42
|
+
* this module picks the one that never discards the model's own reasoning: a gap
|
|
43
|
+
* is FILLED so the conversation stays uniform, rather than the whole thread being
|
|
44
|
+
* stripped to match the gap. Stripping would throw away real reasoning from every
|
|
45
|
+
* earlier turn (which the contract says the endpoint wants), so filling is both
|
|
46
|
+
* the smaller loss and the remedy the API's own bug report suggests.
|
|
47
|
+
*
|
|
48
|
+
* MEASURED SAFE (2026-10-16, live, `api.deepseek.com`, model `deepseek-flash`,
|
|
49
|
+
* via this repository's configured provider): a tool-call turn carrying the
|
|
50
|
+
* placeholder below is accepted — HTTP 200 with a normal completion — exactly
|
|
51
|
+
* like the same conversation with the gap unfilled and with all reasoning
|
|
52
|
+
* stripped. So on today's endpoint this is a NO-OP for a thread that would
|
|
53
|
+
* otherwise be served, and it closes the gap for the endpoint that enforces the
|
|
54
|
+
* rule (the run above shows that endpoint exists and that we can meet it).
|
|
55
|
+
*
|
|
56
|
+
* NARROWNESS. Nothing is added unless the conversation ALREADY carries reasoning
|
|
57
|
+
* on some assistant turn — a non-thinking provider's thread is untouched, and the
|
|
58
|
+
* wire stays byte-identical. Only turns that carry `tool_calls` are filled, which
|
|
59
|
+
* is the turn class the contract names; a content-only assistant turn is left
|
|
60
|
+
* alone because no rule requires it and inventing text there would be noise.
|
|
61
|
+
*/
|
|
62
|
+
/**
|
|
63
|
+
* What a gap is filled with.
|
|
64
|
+
*
|
|
65
|
+
* Deliberately a statement of FACT about our own bookkeeping rather than an
|
|
66
|
+
* invented chain of thought: the endpoint requires the field's presence on a
|
|
67
|
+
* tool-call turn, and the model reading it back must not be told a plausible lie
|
|
68
|
+
* about what it was thinking. A thinking model that sees this knows only that the
|
|
69
|
+
* reasoning for that call was not retained — which is true.
|
|
70
|
+
*/
|
|
71
|
+
export const REASONING_NOT_RETAINED = '(reasoning for this tool call was not retained)';
|
|
72
|
+
/**
|
|
73
|
+
* True when any assistant turn in the conversation carries reasoning.
|
|
74
|
+
*
|
|
75
|
+
* That is the signal that this is a thinking-mode conversation: the endpoint is
|
|
76
|
+
* already receiving `reasoning_content` on some turns, so it is entitled to
|
|
77
|
+
* require it on the tool-call turns too (and does, per the contract above).
|
|
78
|
+
* A thread with no reasoning anywhere is a non-thinking conversation and is left
|
|
79
|
+
* completely untouched — missing reasoning is NOT an error by itself; the API
|
|
80
|
+
* accepts a thread that never had any.
|
|
81
|
+
*/
|
|
82
|
+
function conversationCarriesReasoning(messages) {
|
|
83
|
+
return messages.some((m) => m.role === 'assistant' && Boolean(m.reasoningContent));
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Apply the invariant to a conversation, returning a NEW array only when a gap
|
|
87
|
+
* had to be filled (otherwise the caller's array is returned unchanged, so a
|
|
88
|
+
* valid conversation keeps the exact wire shape it had).
|
|
89
|
+
*
|
|
90
|
+
* Returns the messages plus how many gaps were filled, so a caller can log that
|
|
91
|
+
* it happened — a repair nobody can see is indistinguishable from a request that
|
|
92
|
+
* was always valid.
|
|
93
|
+
*/
|
|
94
|
+
export function applyThinkingReplayInvariant(messages) {
|
|
95
|
+
if (!conversationCarriesReasoning(messages))
|
|
96
|
+
return { messages, filled: 0 };
|
|
97
|
+
let filled = 0;
|
|
98
|
+
const out = messages.map((m) => {
|
|
99
|
+
if (m.role !== 'assistant')
|
|
100
|
+
return m;
|
|
101
|
+
if (!m.toolCalls || m.toolCalls.length === 0)
|
|
102
|
+
return m;
|
|
103
|
+
if (m.reasoningContent)
|
|
104
|
+
return m;
|
|
105
|
+
filled += 1;
|
|
106
|
+
return { ...m, reasoningContent: REASONING_NOT_RETAINED };
|
|
107
|
+
});
|
|
108
|
+
return { messages: filled > 0 ? out : messages, filled };
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=thinking-replay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thinking-replay.js","sourceRoot":"","sources":["../../src/inference/thinking-replay.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AAIH;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,iDAAiD,CAAC;AAExF;;;;;;;;;GASG;AACH,SAAS,4BAA4B,CAAC,QAAgC;IACpE,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,WAAW,IAAI,OAAO,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC;AACrF,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,4BAA4B,CAC1C,QAAgC;IAEhC,IAAI,CAAC,4BAA4B,CAAC,QAAQ,CAAC;QAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;IAE5E,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,MAAM,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QAC7B,IAAI,CAAC,CAAC,IAAI,KAAK,WAAW;YAAE,OAAO,CAAC,CAAC;QACrC,IAAI,CAAC,CAAC,CAAC,SAAS,IAAI,CAAC,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,CAAC,CAAC;QACvD,IAAI,CAAC,CAAC,gBAAgB;YAAE,OAAO,CAAC,CAAC;QACjC,MAAM,IAAI,CAAC,CAAC;QACZ,OAAO,EAAE,GAAG,CAAC,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,CAAC;IAC5D,CAAC,CAAC,CAAC;IAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC;AAC3D,CAAC"}
|
|
@@ -38,6 +38,15 @@ interface WireResponse {
|
|
|
38
38
|
/**
|
|
39
39
|
* Build the wire `messages` array: assistant messages carry `tool_calls`,
|
|
40
40
|
* tool messages carry `tool_call_id`.
|
|
41
|
+
*
|
|
42
|
+
* This is the ONE place every tool conversation is rendered for the wire (both
|
|
43
|
+
* the streaming and non-streaming helpers below), so it is also the one place the
|
|
44
|
+
* thinking-mode REPLAY INVARIANT has to hold: in a conversation that already
|
|
45
|
+
* carries reasoning, every tool-call turn must carry it too, or the endpoint
|
|
46
|
+
* rejects the request — see {@link applyThinkingReplayInvariant}, which fills the
|
|
47
|
+
* gap the loop can leave behind. A conversation with no reasoning anywhere is
|
|
48
|
+
* returned exactly as given, so nothing here changes a shape that was already
|
|
49
|
+
* valid.
|
|
41
50
|
*/
|
|
42
51
|
export declare function buildWireMessages(messages: ToolMessage[]): Array<Record<string, unknown>>;
|
|
43
52
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/inference/tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/inference/tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAKpG,oEAAoE;AACpE,UAAU,YAAY;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;CAC/C;AAED,UAAU,YAAY;IACpB,OAAO,CAAC,EAAE,KAAK,CAAC;QACd,OAAO,CAAC,EAAE;YAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;YAAC,UAAU,CAAC,EAAE,YAAY,EAAE,CAAC;YAAC,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;SAAE,CAAC;QACtG,0EAA0E;QAC1E,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;KAC/B,C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AAgB,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IAC3I;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACzC,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAuD5B;AA+CD;;;;;;GAMG;AACH,wBAAsB,8BAA8B,CAClD,IAAI,EAAE,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAC,CAAC,CAAC,EACpD,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,GAC/B,OAAO,CAAC,gBAAgB,CAAC,CAkL3B"}
|
package/dist/inference/tools.js
CHANGED
|
@@ -10,12 +10,23 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import { attachHttpContext } from './http-error.js';
|
|
12
12
|
import { parseSSELine } from './sse.js';
|
|
13
|
+
import { applyThinkingReplayInvariant } from './thinking-replay.js';
|
|
13
14
|
/**
|
|
14
15
|
* Build the wire `messages` array: assistant messages carry `tool_calls`,
|
|
15
16
|
* tool messages carry `tool_call_id`.
|
|
17
|
+
*
|
|
18
|
+
* This is the ONE place every tool conversation is rendered for the wire (both
|
|
19
|
+
* the streaming and non-streaming helpers below), so it is also the one place the
|
|
20
|
+
* thinking-mode REPLAY INVARIANT has to hold: in a conversation that already
|
|
21
|
+
* carries reasoning, every tool-call turn must carry it too, or the endpoint
|
|
22
|
+
* rejects the request — see {@link applyThinkingReplayInvariant}, which fills the
|
|
23
|
+
* gap the loop can leave behind. A conversation with no reasoning anywhere is
|
|
24
|
+
* returned exactly as given, so nothing here changes a shape that was already
|
|
25
|
+
* valid.
|
|
16
26
|
*/
|
|
17
27
|
export function buildWireMessages(messages) {
|
|
18
|
-
|
|
28
|
+
const { messages: replayable } = applyThinkingReplayInvariant(messages);
|
|
29
|
+
return replayable.map((m) => {
|
|
19
30
|
// Reasoning replay: a thinking model (DeepSeek v4) requires its prior
|
|
20
31
|
// `reasoning_content` echoed on the assistant turn that carried the tool
|
|
21
32
|
// calls, or the NEXT request is rejected. Emitted only when present, so
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../../src/inference/tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAmBxC;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,QAAuB;IACvD,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QACxB,sEAAsE;QACtE,yEAAyE;QACzE,wEAAwE;QACxE,sEAAsE;QACtE,MAAM,SAAS,GAAG,CAAC,CAAC,IAAI,KAAK,WAAW,IAAI,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,iBAAiB,EAAE,CAAC,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAChH,IAAI,CAAC,CAAC,IAAI,KAAK,WAAW,IAAI,CAAC,CAAC,SAAS,EAAE,MAAM,EAAE,CAAC;YAClD,OAAO;gBACL,IAAI,EAAE,WAAW;gBACjB,OAAO,EAAE,CAAC,CAAC,OAAO,IAAI,IAAI;gBAC1B,UAAU,EAAE,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;oBACnC,EAAE,EAAE,EAAE,CAAC,EAAE;oBACT,IAAI,EAAE,UAAU;oBAChB,QAAQ,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,CAAC,SAAS,EAAE;iBACrD,CAAC,CAAC;gBACH,GAAG,SAAS;aACb,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;YACtB,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,Y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,IAAI,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IACjH,CAAC;IACD,MAAM,OAAO,GAAG,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACtC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;QAChB,IAAI,CAAC;YACH,IAAI,CAAC,MAAM,CACT,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAC9D,OAAO,EACP,WAAW,CACZ,CAAC;QACJ,CAAC;QAAC,MAAM,CAAC;YACP,8CAA8C;QAChD,CAAC;IACH,CAAC;IACD,MAAM,gBAAgB,GAAG,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACjD,OAAO;QACL,OAAO;QACP,SAAS,EAAE,WAAW;QACtB,GAAG,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,gBAAgB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACjD,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC1C,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PROJECT-ASSESSMENT PROTOCOL — the evidence rules for "assess this codebase"
|
|
3
|
+
* asks (audit / code review / "find the bugs").
|
|
4
|
+
*
|
|
5
|
+
* WHY THIS EXISTS (the side-by-side audit, 2026-10-16). Two agents on the SAME
|
|
6
|
+
* model (DeepSeek V4.1 Flash), the same prompt, the same small project
|
|
7
|
+
* (`/Users/dheeraj/Documents/cal`, 12 files, ~276 LOC), told not to change
|
|
8
|
+
* anything. One ran the project's own modules and the real page in a browser;
|
|
9
|
+
* the other — this CLI — reasoned over what it had read, re-created the engine
|
|
10
|
+
* by hand inside `code_execution`, and published the copy's output as the app's
|
|
11
|
+
* behaviour. The comparison isolates four defects that are NOT about model
|
|
12
|
+
* quality, because the model was identical:
|
|
13
|
+
*
|
|
14
|
+
* 1. A COPY WAS REPORTED AS THE ARTIFACT. Its top-severity finding said
|
|
15
|
+
* "typing `alert(1)` into the display and pressing `=` runs the code",
|
|
16
|
+
* "verified" against a hand-copied engine — while the shipped display
|
|
17
|
+
* input is `disabled`, the keyboard filter drops every letter, and no
|
|
18
|
+
* button emits one, so that input cannot be produced at all. The sink is
|
|
19
|
+
* real and LATENT; the reachability claim was false. Worse, its remediation
|
|
20
|
+
* ("reject identifiers in the whitelist") does not close the sink, because
|
|
21
|
+
* a char-code `Function(...)` escape needs only letters, digits, commas and
|
|
22
|
+
* parens — measured against the real module.
|
|
23
|
+
* 2. NO MEASUREMENT. "`999999999!` hangs the tab indefinitely" — measured on
|
|
24
|
+
* the real engine it is ~31 s (3.09 s at n=1e8, linear), and the indefinite
|
|
25
|
+
* case needs more digits than that. A magnitude nobody measured is a
|
|
26
|
+
* guess wearing a severity label.
|
|
27
|
+
* 3. GREEN TESTS READ AS COVERAGE. The project's 10 tests all pass, and all 10
|
|
28
|
+
* drive `evaluateExpression` — while the UI buttons call
|
|
29
|
+
* `evaluateScientific`, which is missing cases for 8 of the 14 buttons. The
|
|
30
|
+
* tested path is not the shipped path; that gap IS the root cause, and the
|
|
31
|
+
* audit that stopped at "tests pass" could not see it.
|
|
32
|
+
* 4. THE ANSWER STOPPED MID-SENTENCE. Its report forward-referenced a
|
|
33
|
+
* "dead code — noted at the end" section, ran out of output budget two
|
|
34
|
+
* findings later, and ended inside a word. A dangling forward reference in a
|
|
35
|
+
* truncated answer costs the reader the whole tail of the report.
|
|
36
|
+
*
|
|
37
|
+
* WHAT THIS MODULE IS. A deterministic, LLM-free classifier plus one block of
|
|
38
|
+
* text. It changes what the agent must be able to SHOW for a finding, not the
|
|
39
|
+
* shape of the report: the strengths that run already had — severity labels,
|
|
40
|
+
* exact `file:line`, mechanism, a fix recipe, the artifact-inheritance check
|
|
41
|
+
* (does the built bundle carry the same bug?), and finishing in seconds — are
|
|
42
|
+
* kept and are named in the block as the format to keep.
|
|
43
|
+
*
|
|
44
|
+
* ROUND TWO (the head-to-head audit, 2026-10-16). A second side-by-side run —
|
|
45
|
+
* same model, same prompt, same snapshot, this time on a Python desktop app
|
|
46
|
+
* (`/Users/dheeraj/Documents/anuj_voice`, 60 modules) — scored this CLI's audit
|
|
47
|
+
* against another agent's. It found six defects the five rules above did not
|
|
48
|
+
* cover, and every one is a SHAPE OF CHECK rather than a missing fact:
|
|
49
|
+
*
|
|
50
|
+
* 6. IT READ THE MODULES AND NOT THE SEAMS. The three findings it missed all
|
|
51
|
+
* lived in the joins: a constant compared against the wrong version
|
|
52
|
+
* (`_MIN_APP_VERSION = '0.1.0'` gating every real add-on out), a manifest
|
|
53
|
+
* field parsed and consumed nowhere (`dependencies`), and a recursive
|
|
54
|
+
* merge that silently drops nested defaults when the file is partial.
|
|
55
|
+
* 7. IT DID NOT RUN THE PROJECT'S OWN TOOLING. The tree shipped
|
|
56
|
+
* `tools/dead_code_audit.py` and a packaging validator, its plan NAMED the
|
|
57
|
+
* tools directory, and it ran neither — while a shipped checker was the
|
|
58
|
+
* artifact that reported the release defect. See `self-check-discovery.ts`.
|
|
59
|
+
* 8. IT CITED A FILE IN THE REPO AS EVIDENCE. It repeated a claim from a
|
|
60
|
+
* prior `ASSESSMENT.md` sitting in the tree without resolving that file's
|
|
61
|
+
* own `file:line` references — which were, on measurement, pointing at the
|
|
62
|
+
* accelerator table rather than the code the claim described.
|
|
63
|
+
* 9. IT ASSERTED A MEASUREMENT IT HAD NOT TAKEN. Its plan reported
|
|
64
|
+
* `14 failed / 422 passed` before any command in the transcript had run,
|
|
65
|
+
* and its appendix documented a command that does not reproduce those
|
|
66
|
+
* numbers. Both are provenance failures, not the model being wrong.
|
|
67
|
+
* 10. IT ASKED A USER WHO WAS NOT THERE for permission to run a read-only
|
|
68
|
+
* probe, and self-answered only because the run was unattended.
|
|
69
|
+
* 11. IT LEFT ITS SCRATCH FILES IN THE TREE IT WAS AUDITING.
|
|
70
|
+
*
|
|
71
|
+
* Rules 6-11 are the mechanical half of that gap: four of them are checks the
|
|
72
|
+
* agent can perform on its own output before delivering it.
|
|
73
|
+
*
|
|
74
|
+
* NARROWNESS IS THE DESIGN. The block is injected ONLY for an assessment ask: a
|
|
75
|
+
* change request ("fix the bug", "add tests") must be byte-identical to a build
|
|
76
|
+
* without this feature, which is why {@link isProjectAssessmentGoal} requires an
|
|
77
|
+
* explicit finding/audit shape rather than the word "review" on its own. An
|
|
78
|
+
* authored ask is excluded via the existing deliverable taxonomy, so "write a
|
|
79
|
+
* review of this novel" never gets a bug-hunting protocol.
|
|
80
|
+
*/
|
|
81
|
+
/**
|
|
82
|
+
* The block's rules, written as one message. Kept deterministic (an array of
|
|
83
|
+
* lines joined here) so tests assert on the rules rather than on prose
|
|
84
|
+
* formatting, and so a truncated edit cannot silently drop a rule.
|
|
85
|
+
*/
|
|
86
|
+
export declare const ASSESSMENT_PROTOCOL_RULES: readonly string[];
|
|
87
|
+
/**
|
|
88
|
+
* The injected block. Returns '' for every non-assessment ask (the caller then
|
|
89
|
+
* injects nothing, so the turn is byte-identical to one from a build without
|
|
90
|
+
* this module).
|
|
91
|
+
*
|
|
92
|
+
* It deliberately does NOT prescribe a report template: the findings format from
|
|
93
|
+
* a normal run — severity, `file:line`, mechanism, fix — is named as the thing to
|
|
94
|
+
* KEEP, so the protocol adds evidence discipline without flattening the answer.
|
|
95
|
+
*/
|
|
96
|
+
export declare function assessmentProtocolBlock(goal: string, opts?: {
|
|
97
|
+
selfChecks?: string;
|
|
98
|
+
}): string;
|
|
99
|
+
/**
|
|
100
|
+
* Is this goal a PROJECT ASSESSMENT — a request for findings about existing code,
|
|
101
|
+
* rather than a change to it or an authored document?
|
|
102
|
+
*
|
|
103
|
+
* Two shapes qualify, and nothing else does:
|
|
104
|
+
* - an explicit finding request ("identify the bugs in the project", "what's
|
|
105
|
+
* broken here") — the shape the side-by-side audit took;
|
|
106
|
+
* - an assessment verb aimed at code ("assess the project at …", "review the
|
|
107
|
+
* codebase", "audit this API").
|
|
108
|
+
*
|
|
109
|
+
* The exclusions are as load-bearing as the matches: requiring a code target keeps
|
|
110
|
+
* "review this sentence" and "review my notes" out, and a LONG-FORM authored ask is
|
|
111
|
+
* excluded so "write a 20 page review of this codebase" stays a document task.
|
|
112
|
+
*
|
|
113
|
+
* The authored exclusion is deliberately the NARROW one (`isLongFormAuthoredGoal`,
|
|
114
|
+
* not `isAuthoredGoal`): the broad predicate is claimed by the word "report", and
|
|
115
|
+
* the verbatim audit goal ends "…report the file and line … this is an assessment
|
|
116
|
+
* only" — a broad guard silently drops exactly the ask this module exists for. The
|
|
117
|
+
* code-target requirement already keeps prose asks that never mention code out.
|
|
118
|
+
*/
|
|
119
|
+
export declare function isProjectAssessmentGoal(goal: string): boolean;
|
|
120
|
+
//# sourceMappingURL=assessment-protocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assessment-protocol.d.ts","sourceRoot":"","sources":["../../src/learning/assessment-protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+EG;AAyBH;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,EAAE,SAAS,MAAM,EAsEtD,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,MAAM,EACZ,IAAI,GAAE;IAAE,UAAU,CAAC,EAAE,MAAM,CAAA;CAAO,GACjC,MAAM,CAqBR;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAO7D"}
|