agent-nuvira 3.1.1 → 3.2.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/dist/agents/agents/reasoner.d.ts +8 -0
- package/dist/agents/agents/reasoner.d.ts.map +1 -1
- package/dist/agents/agents/reasoner.js +53 -2
- package/dist/agents/agents/reasoner.js.map +1 -1
- package/dist/agents/agents/writer.d.ts +24 -0
- package/dist/agents/agents/writer.d.ts.map +1 -1
- package/dist/agents/agents/writer.js +194 -0
- package/dist/agents/agents/writer.js.map +1 -1
- package/dist/agents/composite-plan.d.ts +143 -0
- package/dist/agents/composite-plan.d.ts.map +1 -0
- package/dist/agents/composite-plan.js +399 -0
- package/dist/agents/composite-plan.js.map +1 -0
- package/dist/agents/long-form-plan.d.ts +156 -0
- package/dist/agents/long-form-plan.d.ts.map +1 -0
- package/dist/agents/long-form-plan.js +274 -0
- package/dist/agents/long-form-plan.js.map +1 -0
- package/dist/agents/orchestrator.d.ts +107 -0
- package/dist/agents/orchestrator.d.ts.map +1 -1
- package/dist/agents/orchestrator.js +501 -35
- package/dist/agents/orchestrator.js.map +1 -1
- package/dist/agents/prompt-assembly.d.ts +8 -0
- package/dist/agents/prompt-assembly.d.ts.map +1 -1
- package/dist/agents/prompt-assembly.js +17 -0
- package/dist/agents/prompt-assembly.js.map +1 -1
- package/dist/cli/chat.d.ts +27 -0
- package/dist/cli/chat.d.ts.map +1 -1
- package/dist/cli/chat.js +133 -8
- package/dist/cli/chat.js.map +1 -1
- package/dist/cli/execute.d.ts +12 -0
- package/dist/cli/execute.d.ts.map +1 -1
- package/dist/cli/execute.js +105 -2
- package/dist/cli/execute.js.map +1 -1
- package/dist/cli/models.d.ts.map +1 -1
- package/dist/cli/models.js +10 -0
- package/dist/cli/models.js.map +1 -1
- package/dist/cli/nlu.d.ts +8 -0
- package/dist/cli/nlu.d.ts.map +1 -1
- package/dist/cli/nlu.js +57 -0
- package/dist/cli/nlu.js.map +1 -1
- package/dist/cli/trace.d.ts.map +1 -1
- package/dist/cli/trace.js +27 -0
- package/dist/cli/trace.js.map +1 -1
- package/dist/gateway/gateway-log.d.ts +1 -1
- package/dist/gateway/gateway-log.d.ts.map +1 -1
- package/dist/gateway/gateway-log.js.map +1 -1
- package/dist/gateway/registry.d.ts +116 -1
- package/dist/gateway/registry.d.ts.map +1 -1
- package/dist/gateway/registry.js +575 -52
- package/dist/gateway/registry.js.map +1 -1
- package/dist/inference/model-entitlement.d.ts +46 -0
- package/dist/inference/model-entitlement.d.ts.map +1 -0
- package/dist/inference/model-entitlement.js +98 -0
- package/dist/inference/model-entitlement.js.map +1 -0
- package/dist/inference/tool-call-utils.d.ts.map +1 -1
- package/dist/inference/tool-call-utils.js +70 -1
- package/dist/inference/tool-call-utils.js.map +1 -1
- package/dist/learning/autonomy-policy.d.ts +334 -0
- package/dist/learning/autonomy-policy.d.ts.map +1 -0
- package/dist/learning/autonomy-policy.js +500 -0
- package/dist/learning/autonomy-policy.js.map +1 -0
- package/dist/learning/credential-fingerprint.d.ts +58 -0
- package/dist/learning/credential-fingerprint.d.ts.map +1 -0
- package/dist/learning/credential-fingerprint.js +126 -0
- package/dist/learning/credential-fingerprint.js.map +1 -0
- package/dist/learning/deferred-task.d.ts +159 -0
- package/dist/learning/deferred-task.d.ts.map +1 -0
- package/dist/learning/deferred-task.js +451 -0
- package/dist/learning/deferred-task.js.map +1 -0
- package/dist/learning/deliverable-class.d.ts +130 -0
- package/dist/learning/deliverable-class.d.ts.map +1 -0
- package/dist/learning/deliverable-class.js +432 -0
- package/dist/learning/deliverable-class.js.map +1 -0
- package/dist/learning/long-form.d.ts +252 -0
- package/dist/learning/long-form.d.ts.map +1 -0
- package/dist/learning/long-form.js +510 -0
- package/dist/learning/long-form.js.map +1 -0
- package/dist/learning/model-first-router.d.ts +17 -0
- package/dist/learning/model-first-router.d.ts.map +1 -1
- package/dist/learning/model-first-router.js +35 -0
- package/dist/learning/model-first-router.js.map +1 -1
- package/dist/learning/model-registry.d.ts +96 -4
- package/dist/learning/model-registry.d.ts.map +1 -1
- package/dist/learning/model-registry.js +128 -6
- package/dist/learning/model-registry.js.map +1 -1
- package/dist/learning/model-warmup.d.ts +97 -2
- package/dist/learning/model-warmup.d.ts.map +1 -1
- package/dist/learning/model-warmup.js +165 -60
- package/dist/learning/model-warmup.js.map +1 -1
- package/dist/learning/prompt-layers.d.ts +61 -0
- package/dist/learning/prompt-layers.d.ts.map +1 -0
- package/dist/learning/prompt-layers.js +140 -0
- package/dist/learning/prompt-layers.js.map +1 -0
- package/dist/learning/provider-limits.d.ts +66 -0
- package/dist/learning/provider-limits.d.ts.map +1 -0
- package/dist/learning/provider-limits.js +184 -0
- package/dist/learning/provider-limits.js.map +1 -0
- package/dist/learning/reasoning-trace.d.ts +36 -1
- package/dist/learning/reasoning-trace.d.ts.map +1 -1
- package/dist/learning/reasoning-trace.js +36 -2
- package/dist/learning/reasoning-trace.js.map +1 -1
- package/dist/learning/resilient-call.d.ts +36 -1
- package/dist/learning/resilient-call.d.ts.map +1 -1
- package/dist/learning/resilient-call.js +118 -8
- package/dist/learning/resilient-call.js.map +1 -1
- package/dist/learning/unattended-job.d.ts +293 -0
- package/dist/learning/unattended-job.d.ts.map +1 -0
- package/dist/learning/unattended-job.js +544 -0
- package/dist/learning/unattended-job.js.map +1 -0
- package/dist/learning/unattended-progress.d.ts +95 -0
- package/dist/learning/unattended-progress.d.ts.map +1 -0
- package/dist/learning/unattended-progress.js +147 -0
- package/dist/learning/unattended-progress.js.map +1 -0
- package/dist/learning/working-state.d.ts +109 -0
- package/dist/learning/working-state.d.ts.map +1 -0
- package/dist/learning/working-state.js +244 -0
- package/dist/learning/working-state.js.map +1 -0
- package/dist/nlu/conversation-gate.d.ts +46 -0
- package/dist/nlu/conversation-gate.d.ts.map +1 -1
- package/dist/nlu/conversation-gate.js +73 -6
- package/dist/nlu/conversation-gate.js.map +1 -1
- package/dist/nlu/intent-confirm.d.ts +82 -0
- package/dist/nlu/intent-confirm.d.ts.map +1 -0
- package/dist/nlu/intent-confirm.js +146 -0
- package/dist/nlu/intent-confirm.js.map +1 -0
- package/dist/nlu/learnings.d.ts +101 -0
- package/dist/nlu/learnings.d.ts.map +1 -0
- package/dist/nlu/learnings.js +283 -0
- package/dist/nlu/learnings.js.map +1 -0
- package/dist/tools/coding-tools.d.ts.map +1 -1
- package/dist/tools/coding-tools.js +95 -19
- package/dist/tools/coding-tools.js.map +1 -1
- package/dist/tools/edit-verification.d.ts +125 -0
- package/dist/tools/edit-verification.d.ts.map +1 -0
- package/dist/tools/edit-verification.js +237 -0
- package/dist/tools/edit-verification.js.map +1 -0
- package/dist/tools/git-tool.d.ts.map +1 -1
- package/dist/tools/git-tool.js +37 -4
- package/dist/tools/git-tool.js.map +1 -1
- package/dist/tools/registry.d.ts +30 -2
- package/dist/tools/registry.d.ts.map +1 -1
- package/dist/tools/registry.js +40 -11
- package/dist/tools/registry.js.map +1 -1
- package/dist/tools/run-cli.d.ts.map +1 -1
- package/dist/tools/run-cli.js +40 -13
- package/dist/tools/run-cli.js.map +1 -1
- package/dist/tools/run-terminal.d.ts +6 -1
- package/dist/tools/run-terminal.d.ts.map +1 -1
- package/dist/tools/run-terminal.js +158 -18
- package/dist/tools/run-terminal.js.map +1 -1
- package/dist/tools/tool-loop.d.ts +35 -0
- package/dist/tools/tool-loop.d.ts.map +1 -1
- package/dist/tools/tool-loop.js +157 -3
- package/dist/tools/tool-loop.js.map +1 -1
- package/dist/web-dashboard/chat-console.d.ts +35 -0
- package/dist/web-dashboard/chat-console.d.ts.map +1 -1
- package/dist/web-dashboard/chat-console.js +97 -18
- package/dist/web-dashboard/chat-console.js.map +1 -1
- package/dist/web-dashboard/chat-retry.d.ts +143 -0
- package/dist/web-dashboard/chat-retry.d.ts.map +1 -0
- package/dist/web-dashboard/chat-retry.js +227 -0
- package/dist/web-dashboard/chat-retry.js.map +1 -0
- package/dist/web-dashboard/server.d.ts +17 -0
- package/dist/web-dashboard/server.d.ts.map +1 -1
- package/dist/web-dashboard/server.js +200 -9
- package/dist/web-dashboard/server.js.map +1 -1
- package/dist/web-dashboard/src/types.d.ts +81 -4
- package/dist/web-dashboard/src/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/web-dashboard/public/assets/{index-CQW0qv1r.js → index-kCUkORm7.js} +27 -27
- package/src/web-dashboard/public/assets/index-kCUkORm7.js.map +1 -0
- package/src/web-dashboard/public/index.html +1 -1
- package/src/web-dashboard/public/assets/index-CQW0qv1r.js.map +0 -1
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Edit-verification guards (enterprise-grade hardening, G1 + G2).
|
|
3
|
+
*
|
|
4
|
+
* The calculator audit found the sharpest agent-side gap: across 99 LLM calls
|
|
5
|
+
* the loop never once ran `run_terminal`/`test`/`browser` — it edited files
|
|
6
|
+
* and *asserted* they worked ("successfully fixed", "now fully operational")
|
|
7
|
+
* eight turns in a row while the user kept reporting the same breakage. The
|
|
8
|
+
* loop's existing honesty guards only cover DELIVERY claims (`gateway_send`),
|
|
9
|
+
* so a false claim about a CODE change passed unflagged.
|
|
10
|
+
*
|
|
11
|
+
* This module is the single source of truth for two questions:
|
|
12
|
+
*
|
|
13
|
+
* 1. Which tool calls MUTATE the workspace, and which ones can VERIFY a
|
|
14
|
+
* mutation? (G1 — the verification gate consumes this.)
|
|
15
|
+
* 2. Does the final answer CLAIM an edit that no verification backed?
|
|
16
|
+
* (G2 — `detectUnverifiedEditClaim`.)
|
|
17
|
+
*
|
|
18
|
+
* Both are pure + deterministic (no LLM, no I/O), so they can be unit-tested
|
|
19
|
+
* exhaustively and behave identically across the CLI, dashboard, and gateway.
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* Tools that CHANGE the workspace. A turn that ran one of these has produced
|
|
23
|
+
* a claim about reality that only a verification run can support.
|
|
24
|
+
*
|
|
25
|
+
* Deliberately an ALLOWLIST: a write-capable tool added to the registry later
|
|
26
|
+
* is NOT assumed to be a mutation until it is reviewed here (the same
|
|
27
|
+
* fail-safe direction as `PARALLEL_SAFE_TOOL_NAMES`).
|
|
28
|
+
*/
|
|
29
|
+
export declare const MUTATION_TOOLS: ReadonlySet<string>;
|
|
30
|
+
/**
|
|
31
|
+
* Tools that can PROVE a mutation works — they observe the artifact rather
|
|
32
|
+
* than assert it. `run_terminal` (typecheck/tests/build), the `test` pipeline,
|
|
33
|
+
* a real `browser` run, and `run_cli` (e.g. `nuvira test`) all qualify.
|
|
34
|
+
*
|
|
35
|
+
* `delegate` is intentionally excluded: a sub-agent's prose summary is not an
|
|
36
|
+
* observed artifact, and treating it as verification would let the exact
|
|
37
|
+
* failure mode we are closing through the back door.
|
|
38
|
+
*/
|
|
39
|
+
export declare const VERIFICATION_TOOLS: ReadonlySet<string>;
|
|
40
|
+
/** Whether a tool call changes the workspace. */
|
|
41
|
+
export declare function isMutationTool(name: string): boolean;
|
|
42
|
+
/** Whether a tool call can verify a mutation (observe the artifact). */
|
|
43
|
+
export declare function isVerificationTool(name: string): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Classify a turn's tools into mutations + verifications. Only tools that
|
|
46
|
+
* actually RAN SUCCESSFULLY should be passed in (an `Error:` refusal is not a
|
|
47
|
+
* mutation and not a verification — see `ToolLoopProgress.successfulToolCalls`).
|
|
48
|
+
*/
|
|
49
|
+
export declare function classifyEditActivity(toolsRun: readonly string[]): {
|
|
50
|
+
mutations: string[];
|
|
51
|
+
verifications: string[];
|
|
52
|
+
needsVerification: boolean;
|
|
53
|
+
};
|
|
54
|
+
/** One executed tool call, as observed by the loop (args + result text). */
|
|
55
|
+
export interface ToolCallEvidence {
|
|
56
|
+
tool: string;
|
|
57
|
+
args?: Record<string, unknown>;
|
|
58
|
+
/** The tool-result text (the loop feeds this to the model verbatim). */
|
|
59
|
+
result?: string;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Did this turn's verification actually EXERCISE the artifact it changed?
|
|
63
|
+
*
|
|
64
|
+
* The first cut accepted ANY successful `run_terminal` — so `echo hi` or `ls`
|
|
65
|
+
* marked a turn "verified" (the same class of false positive the gate exists to
|
|
66
|
+
* prevent). A run counts only when it:
|
|
67
|
+
* - is the `test` pipeline or a real `browser` run (inherently project-wide), OR
|
|
68
|
+
* - runs a generic project check (`npm test`, typecheck, build, linter), OR
|
|
69
|
+
* - names one of the files the turn changed (e.g. `grep … style.css`,
|
|
70
|
+
* `node --check script.js`).
|
|
71
|
+
*
|
|
72
|
+
* When the turn's changed paths are UNKNOWN, it falls back to "any successful
|
|
73
|
+
* verification counts" — the pre-strictening behaviour — so an unidentifiable
|
|
74
|
+
* mutation is never falsely flagged.
|
|
75
|
+
*/
|
|
76
|
+
export declare function verificationExercisedArtifact(evidence: readonly ToolCallEvidence[], changedFiles: readonly string[]): boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Full edit assessment for a turn: what mutated, what verified, and whether a
|
|
79
|
+
* verification still OWED. This is the single call the loop uses so the gate,
|
|
80
|
+
* the nudge and the honesty flag can never disagree.
|
|
81
|
+
*/
|
|
82
|
+
export declare function assessEditActivity(toolsRun: readonly string[], evidence?: readonly ToolCallEvidence[], changedFiles?: readonly string[]): {
|
|
83
|
+
mutations: string[];
|
|
84
|
+
verifications: string[];
|
|
85
|
+
needsVerification: boolean;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* True when the answer asserts a completed CODE change that no verification
|
|
89
|
+
* backed.
|
|
90
|
+
*
|
|
91
|
+
* The claim is judged ONLY when the turn actually mutated the workspace and
|
|
92
|
+
* ran nothing that could observe the result. If a verification tool ran
|
|
93
|
+
* successfully, the assertion is (at least) grounded in an observed artifact
|
|
94
|
+
* and the flag stays quiet — crying wolf on a verified edit would erode the
|
|
95
|
+
* flag the way an over-eager linter gets ignored.
|
|
96
|
+
*
|
|
97
|
+
* Sentence-scoped so a negation or a conditional elsewhere in the answer
|
|
98
|
+
* never turns a truthful statement into a flag (and vice-versa).
|
|
99
|
+
*/
|
|
100
|
+
export declare function detectUnverifiedEditClaim(content: string, mutationsRun: readonly string[], verificationsRun: readonly string[]): boolean;
|
|
101
|
+
/**
|
|
102
|
+
* The nudge sent when a turn mutated the workspace and verified nothing.
|
|
103
|
+
* Deliberately concrete (names the tools) so a weak model can act on it
|
|
104
|
+
* without inventing a syntax — the same principle as `TOOL_FALLBACK_HINTS`.
|
|
105
|
+
*/
|
|
106
|
+
export declare const VERIFICATION_NUDGE: string;
|
|
107
|
+
/**
|
|
108
|
+
* The nudge sent when a turn ended asking PERMISSION for work the user's own
|
|
109
|
+
* request already authorized (G13 — the manual-cadence complaint).
|
|
110
|
+
*
|
|
111
|
+
* Deliberately states the authorization and the expected behaviour, and names
|
|
112
|
+
* the one case where asking is still right, so the model does not read this as
|
|
113
|
+
* "never consult" — a blanket no-asking rule would produce silent wrong turns
|
|
114
|
+
* instead of stalls, which is worse. The vocabulary is the autonomy policy's:
|
|
115
|
+
* proceed unless the decision is blocking, high-impact, irreversible and has
|
|
116
|
+
* no sensible default.
|
|
117
|
+
*/
|
|
118
|
+
export declare const AUTHORIZED_WORK_NUDGE: string;
|
|
119
|
+
/**
|
|
120
|
+
* The correction appended to a delivered answer whose code-change claim was
|
|
121
|
+
* never verified. Kept short and honest — it states what is known, not a
|
|
122
|
+
* verdict about whether the edit is correct.
|
|
123
|
+
*/
|
|
124
|
+
export declare const UNVERIFIED_EDIT_NOTE: string;
|
|
125
|
+
//# sourceMappingURL=edit-verification.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edit-verification.d.ts","sourceRoot":"","sources":["../../src/tools/edit-verification.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,EAAE,WAAW,CAAC,MAAM,CAAwC,CAAC;AAExF;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,EAAE,WAAW,CAAC,MAAM,CAKjD,CAAC;AAEH,iDAAiD;AACjD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E1D;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,QAGf,CAAC"}
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Edit-verification guards (enterprise-grade hardening, G1 + G2).
|
|
3
|
+
*
|
|
4
|
+
* The calculator audit found the sharpest agent-side gap: across 99 LLM calls
|
|
5
|
+
* the loop never once ran `run_terminal`/`test`/`browser` — it edited files
|
|
6
|
+
* and *asserted* they worked ("successfully fixed", "now fully operational")
|
|
7
|
+
* eight turns in a row while the user kept reporting the same breakage. The
|
|
8
|
+
* loop's existing honesty guards only cover DELIVERY claims (`gateway_send`),
|
|
9
|
+
* so a false claim about a CODE change passed unflagged.
|
|
10
|
+
*
|
|
11
|
+
* This module is the single source of truth for two questions:
|
|
12
|
+
*
|
|
13
|
+
* 1. Which tool calls MUTATE the workspace, and which ones can VERIFY a
|
|
14
|
+
* mutation? (G1 — the verification gate consumes this.)
|
|
15
|
+
* 2. Does the final answer CLAIM an edit that no verification backed?
|
|
16
|
+
* (G2 — `detectUnverifiedEditClaim`.)
|
|
17
|
+
*
|
|
18
|
+
* Both are pure + deterministic (no LLM, no I/O), so they can be unit-tested
|
|
19
|
+
* exhaustively and behave identically across the CLI, dashboard, and gateway.
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* Tools that CHANGE the workspace. A turn that ran one of these has produced
|
|
23
|
+
* a claim about reality that only a verification run can support.
|
|
24
|
+
*
|
|
25
|
+
* Deliberately an ALLOWLIST: a write-capable tool added to the registry later
|
|
26
|
+
* is NOT assumed to be a mutation until it is reviewed here (the same
|
|
27
|
+
* fail-safe direction as `PARALLEL_SAFE_TOOL_NAMES`).
|
|
28
|
+
*/
|
|
29
|
+
export const MUTATION_TOOLS = new Set(['edit_file', 'write_file']);
|
|
30
|
+
/**
|
|
31
|
+
* Tools that can PROVE a mutation works — they observe the artifact rather
|
|
32
|
+
* than assert it. `run_terminal` (typecheck/tests/build), the `test` pipeline,
|
|
33
|
+
* a real `browser` run, and `run_cli` (e.g. `nuvira test`) all qualify.
|
|
34
|
+
*
|
|
35
|
+
* `delegate` is intentionally excluded: a sub-agent's prose summary is not an
|
|
36
|
+
* observed artifact, and treating it as verification would let the exact
|
|
37
|
+
* failure mode we are closing through the back door.
|
|
38
|
+
*/
|
|
39
|
+
export const VERIFICATION_TOOLS = new Set([
|
|
40
|
+
'run_terminal',
|
|
41
|
+
'test',
|
|
42
|
+
'browser',
|
|
43
|
+
'run_cli',
|
|
44
|
+
]);
|
|
45
|
+
/** Whether a tool call changes the workspace. */
|
|
46
|
+
export function isMutationTool(name) {
|
|
47
|
+
return MUTATION_TOOLS.has(name);
|
|
48
|
+
}
|
|
49
|
+
/** Whether a tool call can verify a mutation (observe the artifact). */
|
|
50
|
+
export function isVerificationTool(name) {
|
|
51
|
+
return VERIFICATION_TOOLS.has(name);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Classify a turn's tools into mutations + verifications. Only tools that
|
|
55
|
+
* actually RAN SUCCESSFULLY should be passed in (an `Error:` refusal is not a
|
|
56
|
+
* mutation and not a verification — see `ToolLoopProgress.successfulToolCalls`).
|
|
57
|
+
*/
|
|
58
|
+
export function classifyEditActivity(toolsRun) {
|
|
59
|
+
const mutations = [];
|
|
60
|
+
const verifications = [];
|
|
61
|
+
for (const name of toolsRun) {
|
|
62
|
+
if (isMutationTool(name))
|
|
63
|
+
mutations.push(name);
|
|
64
|
+
else if (isVerificationTool(name))
|
|
65
|
+
verifications.push(name);
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
mutations,
|
|
69
|
+
verifications,
|
|
70
|
+
// A mutated workspace with nothing observed is the unverified case.
|
|
71
|
+
needsVerification: mutations.length > 0 && verifications.length === 0,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Commands that exercise the WHOLE project, so any change in it is covered.
|
|
76
|
+
* `npm test`, a typecheck, a build, a linter — these observe the artifact even
|
|
77
|
+
* when they never name the changed file.
|
|
78
|
+
*/
|
|
79
|
+
const GENERIC_VERIFY_RE = /\b(?:npm|pnpm|yarn|bun)\s+(?:run\s+)?(?:test|build|lint|typecheck|check|ci)\b|\b(?:tsc|vitest|jest|pytest|mocha|cargo\s+test|go\s+test|gradle|mvn|make|node\s+--check)\b/i;
|
|
80
|
+
/**
|
|
81
|
+
* Did this turn's verification actually EXERCISE the artifact it changed?
|
|
82
|
+
*
|
|
83
|
+
* The first cut accepted ANY successful `run_terminal` — so `echo hi` or `ls`
|
|
84
|
+
* marked a turn "verified" (the same class of false positive the gate exists to
|
|
85
|
+
* prevent). A run counts only when it:
|
|
86
|
+
* - is the `test` pipeline or a real `browser` run (inherently project-wide), OR
|
|
87
|
+
* - runs a generic project check (`npm test`, typecheck, build, linter), OR
|
|
88
|
+
* - names one of the files the turn changed (e.g. `grep … style.css`,
|
|
89
|
+
* `node --check script.js`).
|
|
90
|
+
*
|
|
91
|
+
* When the turn's changed paths are UNKNOWN, it falls back to "any successful
|
|
92
|
+
* verification counts" — the pre-strictening behaviour — so an unidentifiable
|
|
93
|
+
* mutation is never falsely flagged.
|
|
94
|
+
*/
|
|
95
|
+
export function verificationExercisedArtifact(evidence, changedFiles) {
|
|
96
|
+
if (evidence.length === 0)
|
|
97
|
+
return false;
|
|
98
|
+
// Unknown changed paths → cannot judge relevance; don't cry wolf.
|
|
99
|
+
if (changedFiles.length === 0)
|
|
100
|
+
return true;
|
|
101
|
+
const names = new Set();
|
|
102
|
+
for (const f of changedFiles) {
|
|
103
|
+
if (!f)
|
|
104
|
+
continue;
|
|
105
|
+
names.add(f);
|
|
106
|
+
const base = f.split(/[\\/]/).pop();
|
|
107
|
+
if (base)
|
|
108
|
+
names.add(base);
|
|
109
|
+
}
|
|
110
|
+
for (const e of evidence) {
|
|
111
|
+
if (e.tool === 'test' || e.tool === 'browser')
|
|
112
|
+
return true;
|
|
113
|
+
let text = e.result ?? '';
|
|
114
|
+
if (e.args) {
|
|
115
|
+
try {
|
|
116
|
+
text += ` ${JSON.stringify(e.args)}`;
|
|
117
|
+
}
|
|
118
|
+
catch {
|
|
119
|
+
// Unserializable args — the result text alone is still usable.
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
if (GENERIC_VERIFY_RE.test(text))
|
|
123
|
+
return true;
|
|
124
|
+
for (const n of names) {
|
|
125
|
+
if (n && text.includes(n))
|
|
126
|
+
return true;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Full edit assessment for a turn: what mutated, what verified, and whether a
|
|
133
|
+
* verification still OWED. This is the single call the loop uses so the gate,
|
|
134
|
+
* the nudge and the honesty flag can never disagree.
|
|
135
|
+
*/
|
|
136
|
+
export function assessEditActivity(toolsRun, evidence = [], changedFiles = []) {
|
|
137
|
+
const base = classifyEditActivity(toolsRun);
|
|
138
|
+
if (base.mutations.length === 0)
|
|
139
|
+
return { ...base, needsVerification: false };
|
|
140
|
+
return { ...base, needsVerification: !verificationExercisedArtifact(evidence, changedFiles) };
|
|
141
|
+
}
|
|
142
|
+
/** A sentence that is future/interrogative/negated is NOT a completed claim. */
|
|
143
|
+
const NON_CLAIM_CONTEXT_RE = /\b(?:not|n't|never|unable|cannot|can't|couldn't|didn't|won't|will|would|should|could|can|may|might|going to|about to|try(?:ing)? to|attempt|if you|let me|shall i|should i|do you want|i'?ll|next|then)\b/i;
|
|
144
|
+
/**
|
|
145
|
+
* Past-tense sentences that ASSERT a completed code change. Grouped, because
|
|
146
|
+
* the audit surfaced several distinct phrasings the model used:
|
|
147
|
+
* - "I have successfully secured the calculator…"
|
|
148
|
+
* - "The inline event handlers have been successfully removed…"
|
|
149
|
+
* - "I have applied the requested changes…"
|
|
150
|
+
* - "The converter is now fully operational…"
|
|
151
|
+
*/
|
|
152
|
+
const EDIT_CLAIM_RES = [
|
|
153
|
+
// First-person completed change: "I have fixed / updated / refactored …"
|
|
154
|
+
/\bi(?:'ve| have)\s+(?:just\s+|now\s+|also\s+|already\s+|successfully\s+)*(?:fixed|updated|refactored|implemented|applied|added|created|removed|corrected|replaced|rewritten|rewrote|changed|modified|enhanced|completed|adjusted|introduced|resolved|rebuilt|migrated|secured|cleaned\s+up|wired\s+up|hooked\s+up)\b/i,
|
|
155
|
+
// Bare verb form: "I fixed / updated …"
|
|
156
|
+
/\bi\s+(?:just\s+|already\s+|successfully\s+|now\s+)*(?:fixed|updated|refactored|implemented|applied|corrected|replaced|removed|resolved|rewrote|rebuilt)\b/i,
|
|
157
|
+
// Adverb-led success: "successfully updated / properly fixed / fully implemented"
|
|
158
|
+
/\b(?:successfully|properly|fully|correctly)\s+(?:fixed|updated|refactored|implemented|applied|added|created|removed|corrected|replaced|changed|modified|moderni[sz]ed|improved|polished|styled|reworked|optimi[sz]ed|simplified|hardened|enhanced|completed|resolved|rewired|restored|cleaned|secured|wired|hooked)\b/i,
|
|
159
|
+
// Passive change: "the fix / changes / edits have been applied"
|
|
160
|
+
/\b(?:the\s+)?(?:fix|change|changes|update|updates|edit|edits|issue|bug|problem|error|refactor|patch)\s+(?:has|have|is|are)\s+(?:now\s+)?(?:been\s+)?(?:applied|made|implemented|fixed|completed|resolved|added|removed|corrected|patched)\b/i,
|
|
161
|
+
// State assertion: "it is now fully operational / working / fixed"
|
|
162
|
+
/\b(?:is|are|it'?s|this\s+is|that\s+is)\s+(?:now\s+)?(?:fully\s+|properly\s+|already\s+)?(?:operational|functional|working(?:\s+(?:correctly|now|fine|as\s+expected))?|fixed|complete|completed|done|ready|in\s+place|up\s+to\s+date)\b/i,
|
|
163
|
+
// "I have applied the requested changes"
|
|
164
|
+
/\bi(?:'ve| have)\s+(?:now\s+|just\s+)*(?:applied|made)\s+the\s+(?:changes|requested\s+changes|fix|edits|updates|modifications)\b/i,
|
|
165
|
+
// "the changes are applied / complete"
|
|
166
|
+
/\b(?:changes|edits|updates|modifications)\s+(?:are|have\s+been)\s+(?:applied|made|complete|completed|done)\b/i,
|
|
167
|
+
];
|
|
168
|
+
/**
|
|
169
|
+
* True when the answer asserts a completed CODE change that no verification
|
|
170
|
+
* backed.
|
|
171
|
+
*
|
|
172
|
+
* The claim is judged ONLY when the turn actually mutated the workspace and
|
|
173
|
+
* ran nothing that could observe the result. If a verification tool ran
|
|
174
|
+
* successfully, the assertion is (at least) grounded in an observed artifact
|
|
175
|
+
* and the flag stays quiet — crying wolf on a verified edit would erode the
|
|
176
|
+
* flag the way an over-eager linter gets ignored.
|
|
177
|
+
*
|
|
178
|
+
* Sentence-scoped so a negation or a conditional elsewhere in the answer
|
|
179
|
+
* never turns a truthful statement into a flag (and vice-versa).
|
|
180
|
+
*/
|
|
181
|
+
export function detectUnverifiedEditClaim(content, mutationsRun, verificationsRun) {
|
|
182
|
+
const text = (content || '').trim();
|
|
183
|
+
if (!text)
|
|
184
|
+
return false;
|
|
185
|
+
// Nothing was changed → no code-change claim can be "unverified".
|
|
186
|
+
if (!mutationsRun.some(isMutationTool))
|
|
187
|
+
return false;
|
|
188
|
+
// Something observed the artifact → the claim is grounded.
|
|
189
|
+
if (verificationsRun.some(isVerificationTool))
|
|
190
|
+
return false;
|
|
191
|
+
const sentences = text.split(/(?<=[.!?\u3002\uff01\uff1f])\s+|\n+/);
|
|
192
|
+
for (const sentence of sentences) {
|
|
193
|
+
const s = sentence.trim();
|
|
194
|
+
if (!s || NON_CLAIM_CONTEXT_RE.test(s))
|
|
195
|
+
continue;
|
|
196
|
+
if (EDIT_CLAIM_RES.some((re) => re.test(s)))
|
|
197
|
+
return true;
|
|
198
|
+
}
|
|
199
|
+
return false;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* The nudge sent when a turn mutated the workspace and verified nothing.
|
|
203
|
+
* Deliberately concrete (names the tools) so a weak model can act on it
|
|
204
|
+
* without inventing a syntax — the same principle as `TOOL_FALLBACK_HINTS`.
|
|
205
|
+
*/
|
|
206
|
+
export const VERIFICATION_NUDGE = 'You changed files this turn but nothing VERIFIED the change — an edit is not ' +
|
|
207
|
+
'evidence that it works. Before finishing, run the check that actually observes ' +
|
|
208
|
+
'the artifact (e.g. run_terminal for a typecheck/test/build, the test pipeline, ' +
|
|
209
|
+
'or a browser run), then report what that check showed. If no such check is ' +
|
|
210
|
+
'possible here, say so explicitly and do NOT claim the change works.';
|
|
211
|
+
/**
|
|
212
|
+
* The nudge sent when a turn ended asking PERMISSION for work the user's own
|
|
213
|
+
* request already authorized (G13 — the manual-cadence complaint).
|
|
214
|
+
*
|
|
215
|
+
* Deliberately states the authorization and the expected behaviour, and names
|
|
216
|
+
* the one case where asking is still right, so the model does not read this as
|
|
217
|
+
* "never consult" — a blanket no-asking rule would produce silent wrong turns
|
|
218
|
+
* instead of stalls, which is worse. The vocabulary is the autonomy policy's:
|
|
219
|
+
* proceed unless the decision is blocking, high-impact, irreversible and has
|
|
220
|
+
* no sensible default.
|
|
221
|
+
*/
|
|
222
|
+
export const AUTHORIZED_WORK_NUDGE = 'The user\u2019s own request already asked for this work, so asking whether to ' +
|
|
223
|
+
'proceed is a round trip that delivers nothing. Do NOT end the turn on a request ' +
|
|
224
|
+
'for permission: carry the work out with the tools available, decide anything that ' +
|
|
225
|
+
'is yours to decide, and state the decision in your answer so the user can redirect. ' +
|
|
226
|
+
'Reserve `ask_user` for a decision that is genuinely theirs — one that cannot ' +
|
|
227
|
+
'proceed without an answer, is high-impact and irreversible, and has no sensible ' +
|
|
228
|
+
'default — and never ask for permission in plain text.';
|
|
229
|
+
/**
|
|
230
|
+
* The correction appended to a delivered answer whose code-change claim was
|
|
231
|
+
* never verified. Kept short and honest — it states what is known, not a
|
|
232
|
+
* verdict about whether the edit is correct.
|
|
233
|
+
*/
|
|
234
|
+
export const UNVERIFIED_EDIT_NOTE = '\u26a0\ufe0f Note: files were changed this turn but no verification (test / ' +
|
|
235
|
+
'typecheck / build / browser run) confirmed the result — treat the claim above ' +
|
|
236
|
+
'as unverified.';
|
|
237
|
+
//# sourceMappingURL=edit-verification.js.map
|
|
@@ -0,0 +1 @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C,MAAM,CAAC,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC;QAC1B,IAAI,CAAC,CAAC,IAAI,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC;YAAE,SAAS;QACjD,IAAI,cAAc,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAAE,OAAO,IAAI,CAAC;IAC3D,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAC7B,+EAA+E;IAC/E,iFAAiF;IACjF,iFAAiF;IACjF,6EAA6E;IAC7E,qEAAqE,CAAC;AAExE;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAChC,gFAAgF;IAChF,kFAAkF;IAClF,oFAAoF;IACpF,sFAAsF;IACtF,+EAA+E;IAC/E,kFAAkF;IAClF,uDAAuD,CAAC;AAE1D;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAC/B,8EAA8E;IAC9E,gFAAgF;IAChF,gBAAgB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git-tool.d.ts","sourceRoot":"","sources":["../../src/tools/git-tool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"git-tool.d.ts","sourceRoot":"","sources":["../../src/tools/git-tool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAGjD,uDAAuD;AACvD,MAAM,WAAW,WAAW;IAC1B,kBAAkB;IAClB,MAAM,EAAE,QAAQ,GAAG,KAAK,GAAG,MAAM,GAAG,QAAQ,CAAC;IAC7C,gDAAgD;IAChD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,oEAAoE;IACpE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,oCAAoC;IACpC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,6DAA6D;AAC7D,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC7C,OAAO,EAAE,MAAM,CAAC;CACjB;AAkCD,8EAA8E;AAC9E,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAgBzF;AAED,qFAAqF;AACrF,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAE7D;AAED,wBAAsB,UAAU,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,CA0GrF"}
|
package/dist/tools/git-tool.js
CHANGED
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
* Never throws: every failure returns a helpful string.
|
|
34
34
|
*/
|
|
35
35
|
import { execFileSync } from 'node:child_process';
|
|
36
|
+
import { decideStateChange, requestRequestsCommit } from '../learning/autonomy-policy.js';
|
|
36
37
|
/** Action names that map to denied git commands (parity with run_terminal). */
|
|
37
38
|
const DENIED_ACTIONS = {
|
|
38
39
|
push: 'git push is denied — pushing is a human decision, never an autonomous loop.',
|
|
@@ -136,10 +137,36 @@ export async function runGitTool(args, ctx) {
|
|
|
136
137
|
if (!message) {
|
|
137
138
|
return 'Error: git commit needs a message (git refuses empty messages — it would open an editor). Call ask_user for the commit message, then re-call with it.';
|
|
138
139
|
}
|
|
140
|
+
// ── G16: the gate's missing input is whether the USER asked for the commit ─
|
|
141
|
+
// "Commit these changes" IS the approval, and asking for it again is a round
|
|
142
|
+
// trip in the most common dev flow. Note the asymmetry, and why it is right:
|
|
143
|
+
// the commit is local and recoverable (a reflog entry, not a lost file), but
|
|
144
|
+
// it is NOT marked `recoverable` here — only the request NAMING a commit
|
|
145
|
+
// unlocks it, so a commit the model decided on its own still asks.
|
|
146
|
+
let decidedAutonomously = false;
|
|
147
|
+
let autonomyReason = '';
|
|
139
148
|
if (!args.confirm) {
|
|
140
|
-
|
|
141
|
-
'
|
|
142
|
-
'
|
|
149
|
+
const verdict = decideStateChange({
|
|
150
|
+
tool: 'git commit',
|
|
151
|
+
action: 'recording a commit in this repository',
|
|
152
|
+
changeClass: 'local-state',
|
|
153
|
+
namedByRequest: requestRequestsCommit(ctx.authorizationRequest ?? ''),
|
|
154
|
+
authorizedByRequest: ctx.writesAuthorized?.authorized === true,
|
|
155
|
+
});
|
|
156
|
+
if (verdict.action !== 'proceed') {
|
|
157
|
+
return ('git commit: this changes the repository history and needs explicit confirmation ' +
|
|
158
|
+
`(${verdict.reason}). ` +
|
|
159
|
+
'Call ask_user (yes/no — show the diff card first so the user sees exactly what will be committed), ' +
|
|
160
|
+
'then re-call git commit with the SAME message plus confirm:true only if the user agreed.');
|
|
161
|
+
}
|
|
162
|
+
decidedAutonomously = true;
|
|
163
|
+
autonomyReason = verdict.reason;
|
|
164
|
+
ctx.emit?.('autonomy:write-applied', {
|
|
165
|
+
tool: 'git commit',
|
|
166
|
+
message,
|
|
167
|
+
files: args.files ?? [],
|
|
168
|
+
reason: verdict.reason,
|
|
169
|
+
}, 'tool-loop');
|
|
143
170
|
}
|
|
144
171
|
if (SHELL_METACHARS.test(message)) {
|
|
145
172
|
return 'Error: git commit message contains shell metacharacters — denied (argv exec would still be safe, but refuse anyway).';
|
|
@@ -159,6 +186,12 @@ export async function runGitTool(args, ctx) {
|
|
|
159
186
|
return `git commit failed: ${committed.out}`;
|
|
160
187
|
}
|
|
161
188
|
const what = files.length > 0 ? files.join(', ') : 'all changes';
|
|
162
|
-
|
|
189
|
+
const result = `✅ Committed (${what}):\n${committed.out.slice(0, 800)}`;
|
|
190
|
+
if (!decidedAutonomously)
|
|
191
|
+
return result;
|
|
192
|
+
// Reported, never silent: the user must be able to see (and undo) a commit
|
|
193
|
+
// they did not explicitly request in this turn's wording.
|
|
194
|
+
return (`${result}\n💡 Committed without asking: ${autonomyReason}. ` +
|
|
195
|
+
'State the commit in your answer so the user can amend or reset it.');
|
|
163
196
|
}
|
|
164
197
|
//# sourceMappingURL=git-tool.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git-tool.js","sourceRoot":"","sources":["../../src/tools/git-tool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"git-tool.js","sourceRoot":"","sources":["../../src/tools/git-tool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAyB1F,+EAA+E;AAC/E,MAAM,cAAc,GAA2B;IAC7C,IAAI,EAAE,6EAA6E;IACnF,cAAc,EAAE,yEAAyE;IACzF,KAAK,EAAE,gEAAgE;IACvE,eAAe,EAAE,8EAA8E;IAC/F,aAAa,EAAE,8EAA8E;CAC9F,CAAC;AAEF,0EAA0E;AAC1E,0EAA0E;AAC1E,6EAA6E;AAC7E,wDAAwD;AACxD,MAAM,eAAe,GAAG,iBAAiB,CAAC;AAE1C,+EAA+E;AAC/E,SAAS,GAAG,CAAC,IAAc,EAAE,GAAgB;IAC3C,IAAI,CAAC;QACH,MAAM,GAAG,GAAG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CAAC,CAAC,QAAQ,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,GAAG,CAAC,CAAC;IACtD,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,CAAC;QAClB,OAAO,sBAAsB,SAAS,CAAC,GAAG,EAAE,CAAC;IAC/C,CAAC;IACD,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC;IACjE,MAAM,MAAM,GAAG,gBAAgB,IAAI,OAAO,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC;IACxE,IAAI,CAAC,mBAAmB;QAAE,OAAO,MAAM,CAAC;IACxC,2EAA2E;IAC3E,0DAA0D;IAC1D,OAAO,CACL,GAAG,MAAM,kCAAkC,cAAc,IAAI;QAC7D,oEAAoE,CACrE,CAAC;AACJ,CAAC"}
|
package/dist/tools/registry.d.ts
CHANGED
|
@@ -80,6 +80,34 @@ export interface ToolContext {
|
|
|
80
80
|
* Returns the user's answer(s).
|
|
81
81
|
*/
|
|
82
82
|
askUser?: (question: string, choices: AskUserChoice[], multiSelect: boolean) => Promise<AskUserAnswer>;
|
|
83
|
+
/**
|
|
84
|
+
* G13 — does the CURRENT request authorize file writes?
|
|
85
|
+
*
|
|
86
|
+
* Set once per turn by the tool loop from the last user message (see
|
|
87
|
+
* `requestAuthorizesWrites` in learning/autonomy-policy.ts). The
|
|
88
|
+
* confirm-before-write gate and `ask_user` read it to tell "the user already
|
|
89
|
+
* ordered this" apart from "this would be a surprise", so an unattended run
|
|
90
|
+
* does not stop to ask permission for the work it was asked to do.
|
|
91
|
+
*
|
|
92
|
+
* `undefined` (no loop, direct tool invocation, a test) keeps the original
|
|
93
|
+
* confirm-or-refuse behaviour exactly.
|
|
94
|
+
*/
|
|
95
|
+
writesAuthorized?: import('../learning/autonomy-policy.js').WriteAuthorization;
|
|
96
|
+
/**
|
|
97
|
+
* The raw last user message the verdict above was derived from.
|
|
98
|
+
*
|
|
99
|
+
* The verdict answers "did the request ask for FILES" — but each gate needs
|
|
100
|
+
* the evidence ITS OWN question requires, and that evidence lives in the
|
|
101
|
+
* request text: whether the request names the file being edited
|
|
102
|
+
* (`edit_file`), asks for a commit (`git commit`), or resolves to the exact
|
|
103
|
+
* CLI command being run (`run_cli`). Handing the gates the text lets each one
|
|
104
|
+
* measure for itself instead of guessing from a boolean that was computed for
|
|
105
|
+
* a different question.
|
|
106
|
+
*
|
|
107
|
+
* `undefined` (no loop, a direct tool call, a test) means every gate keeps
|
|
108
|
+
* its original confirm-or-refuse behaviour exactly.
|
|
109
|
+
*/
|
|
110
|
+
authorizationRequest?: string;
|
|
83
111
|
/** Emit an event on the observability bus (for pipeline runs). */
|
|
84
112
|
emit?: (event: string, data: unknown, source?: string) => void;
|
|
85
113
|
/** LLM call fn for C2 verify (resolved provider already chosen). */
|
|
@@ -296,9 +324,9 @@ export declare function toolJsonSchemas(toolNames?: string[]): ToolJsonSchema[];
|
|
|
296
324
|
* calling suggest_followups with exactly 3 followups, and clarifies ambiguous
|
|
297
325
|
* requests via ask_user instead of guessing.
|
|
298
326
|
*/
|
|
299
|
-
export declare const TOOL_CONTRACT = "You have tools available. Call them when appropriate.\n\n- If a request is ambiguous or incomplete, call `ask_user` with a question and 2\u20134 choices \u2014 never guess, never ask in plain text.\n- If a request needs code written, debugged, or prior work resumed, call `build`, `repair`, or `resume` with the goal.\n- If a request needs documentation, a website, analysis of a project, or running tests, call `document`, `website`, `analyze`, or `test` with the goal.\n- If a request asks to publish a release (npm/GitHub), call `publish`. It is irreversible \u2014 confirm the bump type and target with the user via `ask_user` first unless they already specified them.\n- If a request's completeness is uncertain, call `verify_requirement` first.\n- If a request asks to deliver a message or result to a DIFFERENT contact/channel than the one you are currently chatting on (WhatsApp, Telegram, Slack, email, \u2026), call `gateway_send` with the target (e.g. `whatsapp:Alex`) and the text. Do NOT call gateway_send to reply to the CURRENT conversation \u2014 your text response is automatically delivered back. If the target contact is not configured, tell the user what to set up.\n- If a request asks to manage the system/agent itself in plain English \u2014 start/stop the dashboard or gateway, check status, add/remove a verified sender, configure a platform (telegram/whatsapp), run evals, show stats \u2014 call `run_cli` with the plain-English ask. It resolves the exact `buff` command and runs it. If the
|
|
327
|
+
export declare const TOOL_CONTRACT = "You have tools available. Call them when appropriate.\n\n- If a request is ambiguous or incomplete, call `ask_user` with a question and 2\u20134 choices \u2014 never guess, never ask in plain text.\n- If a request needs code written, debugged, or prior work resumed, call `build`, `repair`, or `resume` with the goal.\n- If a request needs documentation, a website, analysis of a project, or running tests, call `document`, `website`, `analyze`, or `test` with the goal.\n- If a request asks to publish a release (npm/GitHub), call `publish`. It leaves this machine and is irreversible \u2014 confirm the bump type and target with the user via `ask_user` first unless they already specified them.\n- If a request's completeness is uncertain, call `verify_requirement` first.\n- If a request asks to deliver a message or result to a DIFFERENT contact/channel than the one you are currently chatting on (WhatsApp, Telegram, Slack, email, \u2026), call `gateway_send` with the target (e.g. `whatsapp:Alex`) and the text. Do NOT call gateway_send to reply to the CURRENT conversation \u2014 your text response is automatically delivered back. If the target contact is not configured, tell the user what to set up.\n- If a request asks to manage the system/agent itself in plain English \u2014 start/stop the dashboard or gateway, check status, add/remove a verified sender, configure a platform (telegram/whatsapp), run evals, show stats \u2014 call `run_cli` with the plain-English ask. It resolves the exact `buff` command and runs it. If the user's own request already resolves to that command (\"stop the dashboard\"), it just runs \u2014 do not ask for permission to do what was just asked. If it reports AMBIGUOUS, call `ask_user` with the two choices; if the intent is one YOU chose rather than the user (or is irreversible: history.clear, memory.prune, stats.cost.clear, publish), call `ask_user` first and retry with confirm:true.\n- If a subtask can be delegated to a specialized sub-agent (gather context, review, security scan, run tests), call `delegate` with the agent type, a focused prompt, and optional file paths.\n- To find code matching a pattern (context gathering, locating definitions/usages), call `code_search` with the pattern and optional globs.\n- To READ the project: call `read_file` to open a file (with line numbers), `list_dir` to see a directory's contents, or `glob` to find files by pattern. Always prefer reading the actual file over assuming its contents \u2014 a large file reports a line range, continue with offset/limit.\n- To CHANGE code (after reading it): call `edit_file` for a surgical exact-text replacement, or `write_file` to create/replace a file. CREATING a file the request asked for is applied directly \u2014 no confirmation needed, so just call it. An `edit_file` that is surgical (small relative to the file) also applies directly, as does one on a file the request names \u2014 the verify loop must not need a human between iterations. A whole-file write over existing content, or an edit that rewrites most of a file, refuses without confirm \u2014 call `ask_user` with a one-line summary, then retry with confirm:true.\n- NEVER ask for permission to do work the user already asked for \u2014 not via `ask_user` and never in plain text. Decide it yourself, state the decision in your answer, and continue. Reserve `ask_user` for a decision that is genuinely the user's: it cannot proceed without an answer, it is high-impact AND irreversible, and there is no sensible default (overwriting existing work, deleting data, spending money, publishing).\n- To VERIFY code by actual invocation: call `run_terminal` with the real command (`npx vitest run tests/x.test.ts`, `npx tsc --noEmit`, `npm run build`, `git diff`). Read-only verify commands run directly, and so do recoverable workspace commands (`npm/pnpm/yarn/bun install`, `pip install`, `mkdir`, `touch`, `cp`, `mv`, `git add`, `npm init`) when the request authorized the work \u2014 the build you were asked for is your job to set up. Everything else state-changing (network fetches, arbitrary code, global installs, anything leaving the machine) needs confirm:true after the user approves via ask_user. Never guess that a test passes \u2014 run it and read the output. Use run_cli (not run_terminal) for buff/agent-nuvira control commands, and the `git` tool (not run_terminal) to commit.\n- END EVERY RESPONSE by calling `suggest_followups` with exactly 3 followups the user is likely to want next \u2014 natural next questions, deeper dives, or related directions that build on what you just said; specific to this conversation, not generic.\n- If you have nothing to add, answer directly and still end with suggest_followups.\n- ORDERING (non-negotiable): deliver the user's answer FIRST, then suggest_followups. The followup call must come only AFTER the complete answer is written \u2014 never before it, never instead of it. A bare lead-in (\"Sure, I can help!\") is NOT an answer; write the full answer in the same step as the followup call.";
|
|
300
328
|
/** The JSON-fallback tool contract — for providers WITHOUT native tool-calling. */
|
|
301
|
-
export declare const TOOL_CONTRACT_JSON = "You have tools available. Call them when appropriate.\n\n- If a request is ambiguous or incomplete, call `ask_user` with a question and 2\u20134 choices \u2014 never guess, never ask in plain text.\n- If a request needs code written, debugged, or prior work resumed, call `build`, `repair`, or `resume` with the goal.\n- If a request needs documentation, a website, analysis of a project, or running tests, call `document`, `website`, `analyze`, or `test` with the goal.\n- If a request asks to publish a release (npm/GitHub), call `publish`. It is irreversible \u2014 confirm the bump type and target with the user via `ask_user` first unless they already specified them.\n- If a request's completeness is uncertain, call `verify_requirement` first.\n- If a request asks to deliver a message or result to a DIFFERENT contact/channel than the one you are currently chatting on (WhatsApp, Telegram, Slack, email, \u2026), call `gateway_send` with the target (e.g. `whatsapp:Alex`) and the text. Do NOT call gateway_send to reply to the CURRENT conversation \u2014 your text response is automatically delivered back. If the target contact is not configured, tell the user what to set up.\n- If a request asks to manage the system/agent itself in plain English \u2014 start/stop the dashboard or gateway, check status, add/remove a verified sender, configure a platform (telegram/whatsapp), run evals, show stats \u2014 call `run_cli` with the plain-English ask. It resolves the exact `buff` command and runs it. If the
|
|
329
|
+
export declare const TOOL_CONTRACT_JSON = "You have tools available. Call them when appropriate.\n\n- If a request is ambiguous or incomplete, call `ask_user` with a question and 2\u20134 choices \u2014 never guess, never ask in plain text.\n- If a request needs code written, debugged, or prior work resumed, call `build`, `repair`, or `resume` with the goal.\n- If a request needs documentation, a website, analysis of a project, or running tests, call `document`, `website`, `analyze`, or `test` with the goal.\n- If a request asks to publish a release (npm/GitHub), call `publish`. It leaves this machine and is irreversible \u2014 confirm the bump type and target with the user via `ask_user` first unless they already specified them.\n- If a request's completeness is uncertain, call `verify_requirement` first.\n- If a request asks to deliver a message or result to a DIFFERENT contact/channel than the one you are currently chatting on (WhatsApp, Telegram, Slack, email, \u2026), call `gateway_send` with the target (e.g. `whatsapp:Alex`) and the text. Do NOT call gateway_send to reply to the CURRENT conversation \u2014 your text response is automatically delivered back. If the target contact is not configured, tell the user what to set up.\n- If a request asks to manage the system/agent itself in plain English \u2014 start/stop the dashboard or gateway, check status, add/remove a verified sender, configure a platform (telegram/whatsapp), run evals, show stats \u2014 call `run_cli` with the plain-English ask. It resolves the exact `buff` command and runs it. If the user's own request already resolves to that command (\"stop the dashboard\"), it just runs \u2014 do not ask for permission to do what was just asked. If it reports AMBIGUOUS, call `ask_user` with the two choices; if the intent is one YOU chose rather than the user (or is irreversible: history.clear, memory.prune, stats.cost.clear, publish), call `ask_user` first and retry with confirm:true.\n- If a subtask can be delegated to a specialized sub-agent (gather context, review, security scan, run tests), call `delegate` with the agent type, a focused prompt, and optional file paths.\n- To find code matching a pattern (context gathering, locating definitions/usages), call `code_search` with the pattern and optional globs.\n- To READ the project: call `read_file` to open a file (with line numbers), `list_dir` to see a directory's contents, or `glob` to find files by pattern. Always prefer reading the actual file over assuming its contents \u2014 a large file reports a line range, continue with offset/limit.\n- To CHANGE code (after reading it): call `edit_file` for a surgical exact-text replacement, or `write_file` to create/replace a file. CREATING a file the request asked for is applied directly \u2014 no confirmation needed, so just call it. An `edit_file` that is surgical (small relative to the file) also applies directly, as does one on a file the request names \u2014 the verify loop must not need a human between iterations. A whole-file write over existing content, or an edit that rewrites most of a file, refuses without confirm \u2014 call `ask_user` with a one-line summary, then retry with confirm:true.\n- NEVER ask for permission to do work the user already asked for \u2014 not via `ask_user` and never in plain text. Decide it yourself, state the decision in your answer, and continue. Reserve `ask_user` for a decision that is genuinely the user's: it cannot proceed without an answer, it is high-impact AND irreversible, and there is no sensible default (overwriting existing work, deleting data, spending money, publishing).\n- To VERIFY code by actual invocation: call `run_terminal` with the real command (`npx vitest run tests/x.test.ts`, `npx tsc --noEmit`, `npm run build`, `git diff`). Read-only verify commands run directly, and so do recoverable workspace commands (`npm/pnpm/yarn/bun install`, `pip install`, `mkdir`, `touch`, `cp`, `mv`, `git add`, `npm init`) when the request authorized the work \u2014 the build you were asked for is your job to set up. Everything else state-changing (network fetches, arbitrary code, global installs, anything leaving the machine) needs confirm:true after the user approves via ask_user. Never guess that a test passes \u2014 run it and read the output. Use run_cli (not run_terminal) for buff/agent-nuvira control commands, and the `git` tool (not run_terminal) to commit.\n- END EVERY RESPONSE by calling `suggest_followups` with exactly 3 followups the user is likely to want next \u2014 natural next questions, deeper dives, or related directions that build on what you just said; specific to this conversation, not generic.\n- If you have nothing to add, answer directly and still end with suggest_followups.\n- ORDERING (non-negotiable): deliver the user's answer FIRST, then suggest_followups. The followup call must come only AFTER the complete answer is written \u2014 never before it, never instead of it. A bare lead-in (\"Sure, I can help!\") is NOT an answer; write the full answer in the same step as the followup call.\n\nTOOL CALL FORMAT (JSON fallback transport):\nWhen calling a tool, emit its JSON AFTER your response text, in this exact shape:\n{\"tool\":\"<name>\",\"arguments\":{...}}\nOne tool call per block. The final block may be a suggest_followups call.";
|
|
302
330
|
/**
|
|
303
331
|
* Parse + validate a model's followups output against the shared
|
|
304
332
|
* suggest_followups schema. Accepts both the tool shape `[{prompt,label?}]`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/tools/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAIH,OAAO,EAAE,CAAC,EAAgB,KAAK,OAAO,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/tools/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAIH,OAAO,EAAE,CAAC,EAAgB,KAAK,OAAO,EAAE,MAAM,KAAK,CAAC;AAMpD,MAAM,MAAM,YAAY,GAAG,UAAU,GAAG,YAAY,GAAG,UAAU,CAAC;AAElE,oEAAoE;AACpE,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,kEAAkE;IAClE,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACrC;AAED;;;;GAIG;AACH,MAAM,WAAW,IAAI;IACnB,4EAA4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