agent-nuvira 3.1.3 → 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 +116 -6
- 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/trace.d.ts.map +1 -1
- package/dist/cli/trace.js +27 -0
- package/dist/cli/trace.js.map +1 -1
- package/dist/gateway/registry.d.ts +31 -0
- package/dist/gateway/registry.d.ts.map +1 -1
- package/dist/gateway/registry.js +143 -13
- 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/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/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 +27 -0
- package/dist/learning/model-first-router.js.map +1 -1
- package/dist/learning/model-registry.d.ts +66 -4
- package/dist/learning/model-registry.d.ts.map +1 -1
- package/dist/learning/model-registry.js +67 -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 +80 -5
- 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 +24 -0
- package/dist/nlu/conversation-gate.d.ts.map +1 -1
- package/dist/nlu/conversation-gate.js +47 -3
- package/dist/nlu/conversation-gate.js.map +1 -1
- 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 +141 -1
- package/dist/tools/tool-loop.js.map +1 -1
- package/dist/web-dashboard/chat-console.d.ts +6 -0
- package/dist/web-dashboard/chat-console.d.ts.map +1 -1
- package/dist/web-dashboard/chat-console.js.map +1 -1
- package/dist/web-dashboard/chat-retry.d.ts.map +1 -1
- package/dist/web-dashboard/chat-retry.js +10 -2
- package/dist/web-dashboard/chat-retry.js.map +1 -1
- package/dist/web-dashboard/server.d.ts.map +1 -1
- package/dist/web-dashboard/server.js +80 -8
- 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-Co7Hk2FT.js → index-kCUkORm7.js} +2 -2
- package/src/web-dashboard/public/assets/{index-Co7Hk2FT.js.map → index-kCUkORm7.js.map} +1 -1
- package/src/web-dashboard/public/index.html +1 -1
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Autonomy policy — may the agent decide for itself, or must it ask?
|
|
3
|
+
* (enterprise-grade hardening, G11.)
|
|
4
|
+
*
|
|
5
|
+
* WHY THIS EXISTS (the WhatsApp story audit + the "manual cadence" complaint):
|
|
6
|
+
* Two failure modes sit on opposite sides of the same missing rule.
|
|
7
|
+
*
|
|
8
|
+
* 1. STALLING ON AN ANSWERABLE QUESTION. The story session asked/implied
|
|
9
|
+
* decisions it could have made itself ("should I keep going?", "which
|
|
10
|
+
* file?"), and every one of those turned into a turn that ended without
|
|
11
|
+
* delivered work. An agent that consults on a choice it can make is not
|
|
12
|
+
* careful — it is a bottleneck, and it is how 32 minutes produced zero
|
|
13
|
+
* words.
|
|
14
|
+
* 2. DECIDING SOMETHING THAT WAS NEVER ITS CALL. The opposite failure, where
|
|
15
|
+
* an agent silently picks a direction the user cared about (which
|
|
16
|
+
* provider to bill, whether to overwrite existing work, what to delete).
|
|
17
|
+
*
|
|
18
|
+
* The enterprise behaviour is a POLICY, not a mood: decide by default, consult
|
|
19
|
+
* only when the decision is (a) genuinely the user's, (b) not implied by the
|
|
20
|
+
* ask, (c) irreversible or expensive to get wrong, and (d) has no sensible
|
|
21
|
+
* default. Everything else is the agent's job.
|
|
22
|
+
*
|
|
23
|
+
* This module is deterministic and LLM-free on purpose: it is the guard rail
|
|
24
|
+
* around a model's own "should I ask?" instinct, which skews towards asking.
|
|
25
|
+
*/
|
|
26
|
+
/** How much damage a wrong choice does. */
|
|
27
|
+
export type DecisionImpact = 'low' | 'medium' | 'high';
|
|
28
|
+
/** One decision the agent is facing. */
|
|
29
|
+
export interface DecisionRequest {
|
|
30
|
+
/** What is being decided, phrased for the user (used verbatim if we consult). */
|
|
31
|
+
question: string;
|
|
32
|
+
/** Candidate answers, best-first. Empty means the answer is free-form. */
|
|
33
|
+
options?: string[];
|
|
34
|
+
/** What the agent would pick on its own. Presence = "a sensible default exists". */
|
|
35
|
+
defaultChoice?: string;
|
|
36
|
+
/** How much a wrong pick costs. Defaults to `medium`. */
|
|
37
|
+
impact?: DecisionImpact;
|
|
38
|
+
/**
|
|
39
|
+
* Can the choice be undone cheaply? Overwriting a file that exists, deleting
|
|
40
|
+
* data, spending money and publishing are NOT reversible; picking a library
|
|
41
|
+
* or a layout usually is.
|
|
42
|
+
*/
|
|
43
|
+
reversible?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Does the original ask already imply this choice? "a web-based book with
|
|
46
|
+
* voice narration" has already answered "should it have audio?" and "should
|
|
47
|
+
* it be a website?" — re-asking is a non-delivery dressed as diligence.
|
|
48
|
+
*/
|
|
49
|
+
impliedByAsk?: boolean;
|
|
50
|
+
/** Minutes of rework a wrong choice would add. */
|
|
51
|
+
reworkMinutes?: number;
|
|
52
|
+
/**
|
|
53
|
+
* True when the run cannot continue at all without an answer.
|
|
54
|
+
*
|
|
55
|
+
* A non-blocking decision is a PREFERENCE: the agent proceeds with its
|
|
56
|
+
* default and the user can redirect later, so consulting would only add a
|
|
57
|
+
* round trip with no benefit.
|
|
58
|
+
*/
|
|
59
|
+
blocking?: boolean;
|
|
60
|
+
}
|
|
61
|
+
/** The ruling. */
|
|
62
|
+
export interface DecisionVerdict {
|
|
63
|
+
action: 'proceed' | 'consult';
|
|
64
|
+
/** The choice to take when proceeding. */
|
|
65
|
+
choice?: string;
|
|
66
|
+
/** Why — recorded in the trace/log so the call is auditable, not vibes. */
|
|
67
|
+
reason: string;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Rework above this many minutes makes a defaulted choice expensive enough to
|
|
71
|
+
* be worth a round trip even when the choice is reversible.
|
|
72
|
+
*/
|
|
73
|
+
export declare const REWORK_CONSULT_THRESHOLD_MINUTES = 45;
|
|
74
|
+
/**
|
|
75
|
+
* Decide whether the agent proceeds on its own or asks the user.
|
|
76
|
+
*
|
|
77
|
+
* Order matters. The cheap, obviously-ours cases are settled first so that a
|
|
78
|
+
* later rule can never turn an easy call into a consultation:
|
|
79
|
+
*
|
|
80
|
+
* 1. NOT BLOCKING, NOT HIGH-IMPACT -> proceed. Nothing is waiting on an
|
|
81
|
+
* answer, and the user can redirect at any time. Asking is pure latency.
|
|
82
|
+
* 2. THE ASK ALREADY SAID SO -> proceed with the implied choice. Re-asking a
|
|
83
|
+
* question the user answered in their own request is the "cheap shortcut"
|
|
84
|
+
* in reverse: it looks like diligence and delivers nothing.
|
|
85
|
+
* 3. A BLOCKING, HIGH-IMPACT, IRREVERSIBLE DECISION WITH NO DEFAULT -> this is
|
|
86
|
+
* the user's call. Consult — with a defaulted recommendation, so the reply
|
|
87
|
+
* is a one-word confirmation rather than an essay.
|
|
88
|
+
* 4. OTHERWISE -> proceed with the default, unless the rework a wrong pick
|
|
89
|
+
* would cost is large enough to justify asking (rule 5).
|
|
90
|
+
* 5. EXPENSIVE + NO DEFAULT -> consult.
|
|
91
|
+
*
|
|
92
|
+
* A blocking decision with a sensible default proceeds. That is the whole
|
|
93
|
+
* point of the policy: "which file should I write to" has a default (the one
|
|
94
|
+
* named in the ask, or a predictable one), so it must never stop a run.
|
|
95
|
+
*/
|
|
96
|
+
export declare function decideAutonomously(request: DecisionRequest): DecisionVerdict;
|
|
97
|
+
/** The ruling on whether the user's own request authorized file writes. */
|
|
98
|
+
export interface WriteAuthorization {
|
|
99
|
+
authorized: boolean;
|
|
100
|
+
/** Why — recorded so the judgment is auditable rather than a vibe. */
|
|
101
|
+
reason: string;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Does this request authorize the agent to CREATE files?
|
|
105
|
+
*
|
|
106
|
+
* This is the input the write gate was missing. The gate was binary — "confirm
|
|
107
|
+
* or refuse" — with no notion of a request that had ALREADY authorized the
|
|
108
|
+
* work, so an unattended run whose ask was literally "write a 12 page story"
|
|
109
|
+
* stopped to ask "Do you want me to create the files?". That is not caution;
|
|
110
|
+
* it is the manual cadence, and over a chat surface it is a round trip that
|
|
111
|
+
* produces nothing.
|
|
112
|
+
*
|
|
113
|
+
* Evidence order: an explicit confirmation of proposed work, then a
|
|
114
|
+
* continuation, then a named destination path, then a creation verb applied to
|
|
115
|
+
* a file-shaped deliverable. An analysis/interrogative opener vetoes the last
|
|
116
|
+
* two, so "explain how to write a story to a file" stays a question.
|
|
117
|
+
*
|
|
118
|
+
* Deliberately conservative: anything it does not recognise is NOT authorized,
|
|
119
|
+
* which keeps today's confirm-or-refuse gate exactly as strict as it was.
|
|
120
|
+
*/
|
|
121
|
+
export declare function requestAuthorizesWrites(request: string): WriteAuthorization;
|
|
122
|
+
/**
|
|
123
|
+
* A request that asks for the work to be recorded in git history.
|
|
124
|
+
*
|
|
125
|
+
* `git commit` was gated behind `confirm:true` "after the user approved via
|
|
126
|
+
* ask_user" — but when the user's ask IS "commit these changes", they have
|
|
127
|
+
* already approved and the gate is a round trip in the most common dev flow.
|
|
128
|
+
* Like every other rule here, the evidence has to come from the request text.
|
|
129
|
+
*
|
|
130
|
+
* A NEGATED commit ("don't commit yet") is explicitly not a request for one,
|
|
131
|
+
* and an analysis opener ("how do I commit?") is asking ABOUT it.
|
|
132
|
+
*/
|
|
133
|
+
export declare function requestRequestsCommit(request: string): boolean;
|
|
134
|
+
/**
|
|
135
|
+
* Does the request name THIS file?
|
|
136
|
+
*
|
|
137
|
+
* The evidence an edit gate needs: "fix calc.ts" names the file, "update the
|
|
138
|
+
* README" names it. Compared on the BASENAME too, because a request says
|
|
139
|
+
* `calc.ts` for `src/lib/calc.ts` — that is how people actually write, and
|
|
140
|
+
* requiring the full path would make the rule dead on arrival.
|
|
141
|
+
*
|
|
142
|
+
* Deliberately literal (the basename or the path, as a whole word): a fuzzy
|
|
143
|
+
* match would let "write a story" claim `story.md` and turn a create into an
|
|
144
|
+
* unreviewed overwrite.
|
|
145
|
+
*/
|
|
146
|
+
export declare function requestNamesPath(request: string, path: string): boolean;
|
|
147
|
+
/**
|
|
148
|
+
* Above this share of a file being rewritten, an edit is a REPLACEMENT rather
|
|
149
|
+
* than a surgical change — and replacing most of what exists is the user's call,
|
|
150
|
+
* for the same reason write_file's overwrite case is.
|
|
151
|
+
*/
|
|
152
|
+
export declare const EDIT_SURGICAL_MAX_FRACTION = 0.5;
|
|
153
|
+
/**
|
|
154
|
+
* Is this edit surgical — does it preserve most of the file it touches?
|
|
155
|
+
*
|
|
156
|
+
* The measurable line between "a fix inside a file" and "a rewrite of the
|
|
157
|
+
* file". A surgical edit is the iteration the verify loop is built around
|
|
158
|
+
* (run → read the failure → edit → re-run); a rewrite is a judgment call.
|
|
159
|
+
*/
|
|
160
|
+
export declare function isSurgicalEdit(fileChars: number, oldChars: number, newChars: number): boolean;
|
|
161
|
+
/** Is this ONE sentence a request for permission / a proposal to do the work? */
|
|
162
|
+
export declare function isPermissionSeekingSentence(sentence: string): boolean;
|
|
163
|
+
/**
|
|
164
|
+
* True when the answer CLOSES by asking permission to do work, rather than
|
|
165
|
+
* delivering it.
|
|
166
|
+
*
|
|
167
|
+
* The distinction that matters: "should I proceed?" is a stall, while "which
|
|
168
|
+
* title do you prefer?" is a genuine question. This detector only claims the
|
|
169
|
+
* permission-seeking half — callers AND it with an authorization verdict, so a
|
|
170
|
+
* question about work that was never authorized is untouched.
|
|
171
|
+
*
|
|
172
|
+
* Only the closing sentences are judged: a question mid-answer followed by the
|
|
173
|
+
* actual deliverable is narration, not a stall.
|
|
174
|
+
*/
|
|
175
|
+
export declare function detectPermissionSeeking(content: string): boolean;
|
|
176
|
+
/**
|
|
177
|
+
* Remove the trailing permission-seeking sentences from an answer, keeping
|
|
178
|
+
* everything before them VERBATIM (deliverables are prose — re-joining split
|
|
179
|
+
* sentences would reformat the work itself).
|
|
180
|
+
*
|
|
181
|
+
* Used when a turn is nudged to proceed: the real work in that step must stay
|
|
182
|
+
* a candidate answer, but the question around it must not be what the user is
|
|
183
|
+
* handed — otherwise a longer "…Do you want me to…?" outranks a shorter, real
|
|
184
|
+
* follow-up answer under the loop's longest-substantive rule.
|
|
185
|
+
*/
|
|
186
|
+
export declare function stripTrailingPermissionSeek(content: string): string;
|
|
187
|
+
/**
|
|
188
|
+
* Actions that cannot be undone by re-running the agent. A question that names
|
|
189
|
+
* one of these is NEVER treated as reflexive permission-seeking, because the
|
|
190
|
+
* user genuinely has to own it.
|
|
191
|
+
*/
|
|
192
|
+
export declare const IRREVERSIBLE_ACTION_RE: RegExp;
|
|
193
|
+
/**
|
|
194
|
+
* Should a state-changing write go ahead, or is it the user's call?
|
|
195
|
+
*
|
|
196
|
+
* The scoped rule (from the audit): creating a file the request asked for, at a
|
|
197
|
+
* path where NOTHING EXISTS, cannot destroy anything and is undone by deleting
|
|
198
|
+
* the file — so making the user confirm it is pure latency. Everything else
|
|
199
|
+
* keeps the gate it has today:
|
|
200
|
+
*
|
|
201
|
+
* - a request that never authorized file creation (gate stays as strict);
|
|
202
|
+
* - overwriting content that already exists (a re-run cannot recover it).
|
|
203
|
+
*
|
|
204
|
+
* Note the asymmetry is deliberate and load-bearing: the safety property the
|
|
205
|
+
* original gate protected (never clobber existing work without a human) is
|
|
206
|
+
* untouched, while the property it lacked (do not stall on work the user
|
|
207
|
+
* already ordered) is added.
|
|
208
|
+
*/
|
|
209
|
+
export interface WriteConfirmationRequest {
|
|
210
|
+
/** Tool being attempted (`write_file`, `edit_file`, …) — for the audit line. */
|
|
211
|
+
tool: string;
|
|
212
|
+
/** The target path, already workspace-relative for display. */
|
|
213
|
+
path: string;
|
|
214
|
+
/** Does content already exist at the target, so this write REPLACES it? */
|
|
215
|
+
exists: boolean;
|
|
216
|
+
/** The verdict from {@link requestAuthorizesWrites} for the current request. */
|
|
217
|
+
authorizedByRequest: boolean;
|
|
218
|
+
}
|
|
219
|
+
/** The ruling on a state-changing write. */
|
|
220
|
+
export interface WriteConfirmationVerdict {
|
|
221
|
+
action: 'proceed' | 'ask';
|
|
222
|
+
reason: string;
|
|
223
|
+
}
|
|
224
|
+
/** Decide whether a state-changing write proceeds or asks the user. */
|
|
225
|
+
export declare function decideWriteConfirmation(request: WriteConfirmationRequest): WriteConfirmationVerdict;
|
|
226
|
+
/**
|
|
227
|
+
* What kind of change an action makes to the world.
|
|
228
|
+
*
|
|
229
|
+
* Every confirmation-gated tool was asking the same question — "has the user
|
|
230
|
+
* authorized this?" — with no way to answer it, so each one could only refuse
|
|
231
|
+
* and route the model to `ask_user`. Naming the classes makes the rule table
|
|
232
|
+
* explicit and keeps the two classes that must NEVER run autonomously in one
|
|
233
|
+
* place instead of four.
|
|
234
|
+
*
|
|
235
|
+
* - `create` adds something that did not exist;
|
|
236
|
+
* - `modify` changes content that already exists (a surgical edit, a
|
|
237
|
+
* workspace mutation);
|
|
238
|
+
* - `local-state` this machine's repo/process/service state — recoverable by
|
|
239
|
+
* re-running or by starting the service again;
|
|
240
|
+
* - `external` leaves this machine, or is seen or billed by someone else;
|
|
241
|
+
* - `destructive` removes or irrecoverably replaces what already exists.
|
|
242
|
+
*/
|
|
243
|
+
export type StateChangeClass = 'create' | 'modify' | 'local-state' | 'external' | 'destructive';
|
|
244
|
+
/** One gated state change, with the evidence the acting tool could measure. */
|
|
245
|
+
export interface StateChangeRequest {
|
|
246
|
+
/** Tool being attempted (`edit_file`, `run_terminal`, …) — for the audit line. */
|
|
247
|
+
tool: string;
|
|
248
|
+
/** One line describing what will happen, phrased for the refusal text. */
|
|
249
|
+
action: string;
|
|
250
|
+
/** Which kind of change this is. */
|
|
251
|
+
changeClass: StateChangeClass;
|
|
252
|
+
/**
|
|
253
|
+
* Does the user's OWN REQUEST name this specific action or target (the file,
|
|
254
|
+
* the command, the intent)? The strongest evidence short of a confirmation.
|
|
255
|
+
*/
|
|
256
|
+
namedByRequest?: boolean;
|
|
257
|
+
/**
|
|
258
|
+
* A tool-MEASURED property that makes the change recoverable — a surgical
|
|
259
|
+
* edit that preserves most of the file, a workspace-local install.
|
|
260
|
+
*/
|
|
261
|
+
recoverable?: boolean;
|
|
262
|
+
/**
|
|
263
|
+
* Did the request authorize this class of work at all
|
|
264
|
+
* ({@link requestAuthorizesWrites})? Absent evidence means NOT authorized.
|
|
265
|
+
*/
|
|
266
|
+
authorizedByRequest?: boolean;
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Decide whether a state-changing action proceeds or asks the user.
|
|
270
|
+
*
|
|
271
|
+
* Order matters, and the two never-autonomous classes are settled first so no
|
|
272
|
+
* later rule can turn them into an autonomous action:
|
|
273
|
+
*
|
|
274
|
+
* 1. DESTRUCTIVE -> ask. Permanent, so it stays the user's call even when
|
|
275
|
+
* they named it: one round trip is cheap, being wrong is not.
|
|
276
|
+
* 2. EXTERNAL -> ask. Someone else sees it, or it is billed.
|
|
277
|
+
* 3. NEITHER AUTHORIZED NOR NAMED -> ask. This is the original strictness
|
|
278
|
+
* (and the no-loop-context default) untouched.
|
|
279
|
+
* 4. NAMED BY THE REQUEST -> proceed. The user's own words are the
|
|
280
|
+
* authorization; re-asking is a round trip with no new information.
|
|
281
|
+
* 5. AUTHORIZED + RECOVERABLE -> proceed. The work was ordered and the change
|
|
282
|
+
* cannot strand the user.
|
|
283
|
+
* 6. OTHERWISE -> ask. Authorized but neither named nor measurably
|
|
284
|
+
* recoverable is exactly the case where a surprise is possible.
|
|
285
|
+
*/
|
|
286
|
+
export declare function decideStateChange(request: StateChangeRequest): WriteConfirmationVerdict;
|
|
287
|
+
/**
|
|
288
|
+
* Confirmation-gated CLI intents that cannot be undone by re-running the
|
|
289
|
+
* agent: irreversible data loss, or an effect outside this machine.
|
|
290
|
+
*
|
|
291
|
+
* These keep their gate even when the request names them. One round trip is a
|
|
292
|
+
* small price for a decision that cannot be taken back.
|
|
293
|
+
*/
|
|
294
|
+
export declare const IRREVERSIBLE_CLI_INTENTS: ReadonlySet<string>;
|
|
295
|
+
/**
|
|
296
|
+
* Confirmation-gated CLI intents that ARE recoverable: a service that can be
|
|
297
|
+
* started again, config that can be re-added, a cache that rebuilds, a skill
|
|
298
|
+
* that reinstalls.
|
|
299
|
+
*
|
|
300
|
+
* These proceed when the user's own request resolves to the exact command. The
|
|
301
|
+
* manifest flag exists because the ACTION is stateful, not because the user
|
|
302
|
+
* needs to approve what they just asked for.
|
|
303
|
+
*/
|
|
304
|
+
export declare const RECOVERABLE_CLI_INTENTS: ReadonlySet<string>;
|
|
305
|
+
/**
|
|
306
|
+
* Decide a confirmation-gated CLI intent.
|
|
307
|
+
*
|
|
308
|
+
* Note what this does NOT consult: {@link requestAuthorizesWrites}. That verdict
|
|
309
|
+
* answers "did the request ask for files to be created" — the wrong lens for a
|
|
310
|
+
* system ask like "stop the dashboard", which would read as unauthorized and
|
|
311
|
+
* defeat the whole rule. The evidence that matters here is whether the USER'S
|
|
312
|
+
* OWN WORDS resolve to this exact command (the caller resolves them with the
|
|
313
|
+
* same router, so the tool's ask and the user's ask are compared like for like).
|
|
314
|
+
*/
|
|
315
|
+
export declare function decideCliIntentConfirmation(request: {
|
|
316
|
+
intent: string;
|
|
317
|
+
/** Does the user's own request resolve to this exact command? */
|
|
318
|
+
namedByRequest: boolean;
|
|
319
|
+
}): WriteConfirmationVerdict;
|
|
320
|
+
/**
|
|
321
|
+
* The line shown when the agent decides something on the user's behalf.
|
|
322
|
+
*
|
|
323
|
+
* Reported, never silent: the user must be able to see and reverse a judgment
|
|
324
|
+
* call. A decision that is invisible is indistinguishable from a bug.
|
|
325
|
+
*/
|
|
326
|
+
export declare function autonomouslyDecidedLine(question: string, choice: string, reason: string): string;
|
|
327
|
+
/**
|
|
328
|
+
* The line shown when the agent genuinely cannot decide for the user.
|
|
329
|
+
*
|
|
330
|
+
* Deliberately shaped for a one-word reply: the recommendation and the
|
|
331
|
+
* fallback are both named, so the user is confirming rather than composing.
|
|
332
|
+
*/
|
|
333
|
+
export declare function consultLine(request: DecisionRequest, verdict: DecisionVerdict): string;
|
|
334
|
+
//# sourceMappingURL=autonomy-policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"autonomy-policy.d.ts","sourceRoot":"","sources":["../../src/learning/autonomy-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,2CAA2C;AAC3C,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;AAEvD,wCAAwC;AACxC,MAAM,WAAW,eAAe;IAC9B,iFAAiF;IACjF,QAAQ,EAAE,MAAM,CAAC;IACjB,0EAA0E;IAC1E,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,oFAAoF;IACpF,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,yDAAyD;IACzD,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO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