brass-runtime 1.12.0 → 1.13.2
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/README.md +58 -188
- package/dist/agent/cli/main.cjs +16 -0
- package/dist/agent/cli/main.d.mts +1 -0
- package/dist/agent/cli/main.d.ts +1 -0
- package/dist/agent/cli/main.js +16 -0
- package/dist/agent/index.cjs +1 -0
- package/dist/agent/index.d.mts +688 -0
- package/dist/agent/index.d.ts +688 -0
- package/dist/agent/index.js +1 -0
- package/dist/chunk-6OUI6UGZ.cjs +25 -0
- package/dist/chunk-JAQUSSUV.js +1 -0
- package/dist/chunk-K47BP5A2.cjs +2 -0
- package/dist/chunk-LTHJNW5A.js +2 -0
- package/dist/chunk-W6TVAMYC.js +25 -0
- package/dist/chunk-XPOARCND.cjs +1 -0
- package/dist/effect-ISvXPLgc.d.mts +797 -0
- package/dist/effect-ISvXPLgc.d.ts +797 -0
- package/dist/http/index.cjs +1 -0
- package/dist/http/index.d.mts +2 -1
- package/dist/http/index.d.ts +2 -1
- package/dist/http/index.js +1 -1
- package/dist/index.cjs +1 -0
- package/dist/index.d.mts +159 -39
- package/dist/index.d.ts +159 -39
- package/dist/index.js +1 -1
- package/dist/stream-BvukHxCv.d.ts +66 -0
- package/dist/stream-C0-LWnUP.d.mts +66 -0
- package/package.json +52 -14
- package/dist/chunk-5PIZGM6Q.js +0 -1
- package/dist/chunk-CNA5AQHG.mjs +0 -1
- package/dist/http/index.mjs +0 -1
- package/dist/index.mjs +0 -1
- package/dist/stream-DVfZWtYZ.d.mts +0 -430
- package/dist/stream-DVfZWtYZ.d.ts +0 -430
|
@@ -0,0 +1,688 @@
|
|
|
1
|
+
import { A as Async, a3 as Runtime, S as Scope } from '../effect-ISvXPLgc.js';
|
|
2
|
+
|
|
3
|
+
type AgentMode = "read-only" | "propose" | "write" | "autonomous";
|
|
4
|
+
type AgentPackageManager = "npm" | "pnpm" | "yarn" | "bun";
|
|
5
|
+
type AgentPackageManagerConfig = AgentPackageManager | "auto";
|
|
6
|
+
type AgentResponseLanguage = "auto" | "match-user" | "en" | "es" | "pt" | "fr" | "de" | "it" | "custom";
|
|
7
|
+
type AgentLanguageConfig = {
|
|
8
|
+
/** Natural language used for LLM-facing responses. Default: auto, which matches the user goal when possible. */
|
|
9
|
+
readonly response?: AgentResponseLanguage;
|
|
10
|
+
/** Human-readable language name used when response is custom, e.g. "Argentinian Spanish". */
|
|
11
|
+
readonly custom?: string;
|
|
12
|
+
};
|
|
13
|
+
type AgentContextConfig = {
|
|
14
|
+
/** Enable or disable context discovery before the first LLM planning call. Default: true. */
|
|
15
|
+
readonly enabled?: boolean;
|
|
16
|
+
/** Maximum searchText actions to run before planning. Default: 3. */
|
|
17
|
+
readonly maxSearchQueries?: number;
|
|
18
|
+
/** Maximum distinct files to read from direct error paths and search results. Default: 4. */
|
|
19
|
+
readonly maxFiles?: number;
|
|
20
|
+
/** Maximum matches to consider from search results when selecting files. Default: 40. */
|
|
21
|
+
readonly maxSearchResults?: number;
|
|
22
|
+
/** Ripgrep globs used for context searches. */
|
|
23
|
+
readonly globs?: readonly string[];
|
|
24
|
+
/** Glob-like paths excluded from context reads/searches, e.g. secrets/** or *.pem. */
|
|
25
|
+
readonly excludeGlobs?: readonly string[];
|
|
26
|
+
};
|
|
27
|
+
type AgentRedactionConfig = {
|
|
28
|
+
/** Redact likely secrets before prompts/protocol summaries. Default: true. */
|
|
29
|
+
readonly enabled?: boolean;
|
|
30
|
+
/** Extra regular-expression source strings to redact. Invalid patterns are ignored. */
|
|
31
|
+
readonly additionalPatterns?: readonly string[];
|
|
32
|
+
};
|
|
33
|
+
type AgentPatchQualityConfig = {
|
|
34
|
+
/** Enable repair attempts after generated patches fail to apply or fail validation. Default: true. */
|
|
35
|
+
readonly enabled?: boolean;
|
|
36
|
+
/** Number of llm.patch repair calls after the initial generated patch. Default: 1. */
|
|
37
|
+
readonly maxRepairAttempts?: number;
|
|
38
|
+
};
|
|
39
|
+
type AgentRollbackConfig = {
|
|
40
|
+
/** Enable automatic rollback safety for generated patches. Default: true. */
|
|
41
|
+
readonly enabled?: boolean;
|
|
42
|
+
/** Roll back generated patches when final validation still fails and no repair remains. Default: true. */
|
|
43
|
+
readonly onFinalValidationFailure?: boolean;
|
|
44
|
+
/** Roll back only the latest patch or the full generated patch stack. Default: all. */
|
|
45
|
+
readonly strategy?: "last" | "all";
|
|
46
|
+
/** Maximum automatic rollback actions in one run. Default: 8. */
|
|
47
|
+
readonly maxRollbackDepth?: number;
|
|
48
|
+
/** Re-run validation after automatic rollback completes. Default: true. */
|
|
49
|
+
readonly runValidationAfterRollback?: boolean;
|
|
50
|
+
/** Allow automatic rollback for exact supplied patches. Default: false. */
|
|
51
|
+
readonly allowForSuppliedPatches?: boolean;
|
|
52
|
+
};
|
|
53
|
+
type AgentProjectConfig = {
|
|
54
|
+
/** Force a package manager or let the agent infer it from package.json and lockfiles. */
|
|
55
|
+
readonly packageManager?: AgentPackageManagerConfig;
|
|
56
|
+
/** Exact validation commands to run. When present, discovery from package.json is skipped. */
|
|
57
|
+
readonly validationCommands?: readonly string[];
|
|
58
|
+
/** Ordered script names to consider as the primary test command. */
|
|
59
|
+
readonly testScriptNames?: readonly string[];
|
|
60
|
+
/** Include a typecheck/check script even when the goal does not mention it. */
|
|
61
|
+
readonly includeTypecheck?: boolean;
|
|
62
|
+
/** Include a lint script even when the goal does not mention it. */
|
|
63
|
+
readonly includeLint?: boolean;
|
|
64
|
+
/** Bound the amount of validation work discovered automatically. Default: 2. */
|
|
65
|
+
readonly maxValidationCommands?: number;
|
|
66
|
+
};
|
|
67
|
+
type AgentGoal = {
|
|
68
|
+
readonly id: string;
|
|
69
|
+
readonly cwd: string;
|
|
70
|
+
readonly text: string;
|
|
71
|
+
readonly mode: AgentMode;
|
|
72
|
+
readonly project?: AgentProjectConfig;
|
|
73
|
+
readonly context?: AgentContextConfig;
|
|
74
|
+
readonly patchQuality?: AgentPatchQualityConfig;
|
|
75
|
+
readonly rollback?: AgentRollbackConfig;
|
|
76
|
+
readonly redaction?: AgentRedactionConfig;
|
|
77
|
+
readonly language?: AgentLanguageConfig;
|
|
78
|
+
/** Optional precomputed unified diff. Used by trusted clients after a patch preview approval. */
|
|
79
|
+
readonly initialPatch?: string;
|
|
80
|
+
/** How to materialize initialPatch in write/autonomous mode. Default: apply. */
|
|
81
|
+
readonly initialPatchMode?: "apply" | "rollback";
|
|
82
|
+
};
|
|
83
|
+
type AgentPhase = "boot" | "discovering" | "planning" | "validating" | "proposing" | "done" | "failed";
|
|
84
|
+
type AgentState = {
|
|
85
|
+
readonly goal: AgentGoal;
|
|
86
|
+
readonly phase: AgentPhase;
|
|
87
|
+
readonly observations: readonly Observation[];
|
|
88
|
+
readonly errors: readonly AgentError[];
|
|
89
|
+
readonly steps: number;
|
|
90
|
+
};
|
|
91
|
+
type AgentEvent = {
|
|
92
|
+
readonly type: "agent.run.started";
|
|
93
|
+
readonly goal: AgentGoal;
|
|
94
|
+
readonly at: number;
|
|
95
|
+
} | {
|
|
96
|
+
readonly type: "agent.action.started";
|
|
97
|
+
readonly action: AgentAction;
|
|
98
|
+
readonly step: number;
|
|
99
|
+
readonly phase: AgentPhase;
|
|
100
|
+
readonly at: number;
|
|
101
|
+
} | {
|
|
102
|
+
readonly type: "agent.action.completed";
|
|
103
|
+
readonly action: AgentAction;
|
|
104
|
+
readonly observation: Observation;
|
|
105
|
+
readonly step: number;
|
|
106
|
+
readonly phase: AgentPhase;
|
|
107
|
+
readonly durationMs: number;
|
|
108
|
+
readonly at: number;
|
|
109
|
+
} | {
|
|
110
|
+
readonly type: "agent.action.failed";
|
|
111
|
+
readonly action: AgentAction;
|
|
112
|
+
readonly error: AgentError;
|
|
113
|
+
readonly step: number;
|
|
114
|
+
readonly phase: AgentPhase;
|
|
115
|
+
readonly durationMs: number;
|
|
116
|
+
readonly at: number;
|
|
117
|
+
} | {
|
|
118
|
+
readonly type: "agent.observation.recorded";
|
|
119
|
+
readonly observation: Observation;
|
|
120
|
+
readonly step: number;
|
|
121
|
+
readonly phase: AgentPhase;
|
|
122
|
+
readonly at: number;
|
|
123
|
+
} | {
|
|
124
|
+
readonly type: "agent.tool.timeout";
|
|
125
|
+
readonly action: AgentAction;
|
|
126
|
+
readonly step: number;
|
|
127
|
+
readonly phase: AgentPhase;
|
|
128
|
+
readonly timeoutMs: number;
|
|
129
|
+
readonly at: number;
|
|
130
|
+
} | {
|
|
131
|
+
readonly type: "agent.permission.denied";
|
|
132
|
+
readonly action: AgentAction;
|
|
133
|
+
readonly step: number;
|
|
134
|
+
readonly phase: AgentPhase;
|
|
135
|
+
readonly reason: string;
|
|
136
|
+
readonly at: number;
|
|
137
|
+
} | {
|
|
138
|
+
readonly type: "agent.approval.requested";
|
|
139
|
+
readonly action: AgentAction;
|
|
140
|
+
readonly step: number;
|
|
141
|
+
readonly phase: AgentPhase;
|
|
142
|
+
readonly reason: string;
|
|
143
|
+
readonly risk: ApprovalRisk;
|
|
144
|
+
readonly defaultAnswer: ApprovalDefaultAnswer;
|
|
145
|
+
readonly at: number;
|
|
146
|
+
} | {
|
|
147
|
+
readonly type: "agent.approval.resolved";
|
|
148
|
+
readonly action: AgentAction;
|
|
149
|
+
readonly step: number;
|
|
150
|
+
readonly phase: AgentPhase;
|
|
151
|
+
readonly approved: boolean;
|
|
152
|
+
readonly reason?: string;
|
|
153
|
+
readonly at: number;
|
|
154
|
+
} | {
|
|
155
|
+
readonly type: "agent.patch.applied";
|
|
156
|
+
readonly step: number;
|
|
157
|
+
readonly phase: AgentPhase;
|
|
158
|
+
readonly changedFiles: readonly string[];
|
|
159
|
+
readonly automaticRollbackEligible?: boolean;
|
|
160
|
+
readonly at: number;
|
|
161
|
+
} | {
|
|
162
|
+
readonly type: "agent.patch.rolledBack";
|
|
163
|
+
readonly step: number;
|
|
164
|
+
readonly phase: AgentPhase;
|
|
165
|
+
readonly changedFiles: readonly string[];
|
|
166
|
+
readonly automatic?: boolean;
|
|
167
|
+
readonly reason?: string;
|
|
168
|
+
readonly at: number;
|
|
169
|
+
} | {
|
|
170
|
+
readonly type: "agent.run.completed";
|
|
171
|
+
readonly goal: AgentGoal;
|
|
172
|
+
readonly status: "done" | "failed";
|
|
173
|
+
readonly phase: AgentPhase;
|
|
174
|
+
readonly steps: number;
|
|
175
|
+
readonly durationMs: number;
|
|
176
|
+
readonly at: number;
|
|
177
|
+
};
|
|
178
|
+
type AgentEventSink = {
|
|
179
|
+
readonly emit: (event: AgentEvent) => void;
|
|
180
|
+
};
|
|
181
|
+
type LLMPurpose = "plan" | "patch" | "explain";
|
|
182
|
+
type AgentAction = {
|
|
183
|
+
readonly type: "fs.readFile";
|
|
184
|
+
readonly path: string;
|
|
185
|
+
} | {
|
|
186
|
+
readonly type: "fs.exists";
|
|
187
|
+
readonly path: string;
|
|
188
|
+
} | {
|
|
189
|
+
readonly type: "fs.searchText";
|
|
190
|
+
readonly query: string;
|
|
191
|
+
readonly globs?: readonly string[];
|
|
192
|
+
} | {
|
|
193
|
+
readonly type: "shell.exec";
|
|
194
|
+
readonly command: readonly string[];
|
|
195
|
+
readonly cwd?: string;
|
|
196
|
+
} | {
|
|
197
|
+
readonly type: "llm.complete";
|
|
198
|
+
readonly purpose: LLMPurpose;
|
|
199
|
+
readonly prompt: string;
|
|
200
|
+
} | {
|
|
201
|
+
readonly type: "patch.propose";
|
|
202
|
+
readonly patch: string;
|
|
203
|
+
} | {
|
|
204
|
+
readonly type: "patch.apply";
|
|
205
|
+
readonly patch: string;
|
|
206
|
+
} | {
|
|
207
|
+
readonly type: "patch.rollback";
|
|
208
|
+
readonly patch: string;
|
|
209
|
+
readonly automatic?: boolean;
|
|
210
|
+
readonly reason?: string;
|
|
211
|
+
} | {
|
|
212
|
+
readonly type: "agent.finish";
|
|
213
|
+
readonly summary: string;
|
|
214
|
+
} | {
|
|
215
|
+
readonly type: "agent.fail";
|
|
216
|
+
readonly reason: string;
|
|
217
|
+
};
|
|
218
|
+
type AgentActionType = AgentAction["type"];
|
|
219
|
+
type AgentToolPolicyOverride = {
|
|
220
|
+
readonly timeoutMs?: number;
|
|
221
|
+
readonly retries?: number;
|
|
222
|
+
};
|
|
223
|
+
type AgentToolPolicyConfig = Partial<Record<AgentActionType, AgentToolPolicyOverride>>;
|
|
224
|
+
type Observation = {
|
|
225
|
+
readonly type: "fs.fileRead";
|
|
226
|
+
readonly path: string;
|
|
227
|
+
readonly content: string;
|
|
228
|
+
} | {
|
|
229
|
+
readonly type: "fs.exists";
|
|
230
|
+
readonly path: string;
|
|
231
|
+
readonly exists: boolean;
|
|
232
|
+
} | {
|
|
233
|
+
readonly type: "fs.searchResult";
|
|
234
|
+
readonly query: string;
|
|
235
|
+
readonly matches: readonly SearchMatch[];
|
|
236
|
+
} | {
|
|
237
|
+
readonly type: "shell.result";
|
|
238
|
+
readonly command: readonly string[];
|
|
239
|
+
readonly exitCode: number;
|
|
240
|
+
readonly stdout: string;
|
|
241
|
+
readonly stderr: string;
|
|
242
|
+
} | {
|
|
243
|
+
readonly type: "llm.response";
|
|
244
|
+
readonly purpose: LLMPurpose;
|
|
245
|
+
readonly content: string;
|
|
246
|
+
} | {
|
|
247
|
+
readonly type: "patch.proposed";
|
|
248
|
+
readonly patch: string;
|
|
249
|
+
} | {
|
|
250
|
+
readonly type: "patch.applied";
|
|
251
|
+
readonly changedFiles: readonly string[];
|
|
252
|
+
readonly patch?: string;
|
|
253
|
+
} | {
|
|
254
|
+
readonly type: "patch.rolledBack";
|
|
255
|
+
readonly changedFiles: readonly string[];
|
|
256
|
+
readonly patch?: string;
|
|
257
|
+
readonly automatic?: boolean;
|
|
258
|
+
readonly reason?: string;
|
|
259
|
+
} | {
|
|
260
|
+
readonly type: "agent.done";
|
|
261
|
+
readonly summary: string;
|
|
262
|
+
} | {
|
|
263
|
+
readonly type: "agent.error";
|
|
264
|
+
readonly error: AgentError;
|
|
265
|
+
};
|
|
266
|
+
type SearchMatch = {
|
|
267
|
+
readonly path: string;
|
|
268
|
+
readonly line: number;
|
|
269
|
+
readonly text: string;
|
|
270
|
+
};
|
|
271
|
+
type ExecResult = {
|
|
272
|
+
readonly exitCode: number;
|
|
273
|
+
readonly stdout: string;
|
|
274
|
+
readonly stderr: string;
|
|
275
|
+
};
|
|
276
|
+
type LLMRequest = {
|
|
277
|
+
readonly purpose: LLMPurpose;
|
|
278
|
+
readonly prompt: string;
|
|
279
|
+
};
|
|
280
|
+
type LLMResponse = {
|
|
281
|
+
readonly content: string;
|
|
282
|
+
};
|
|
283
|
+
type AgentError = {
|
|
284
|
+
readonly _tag: "FsError";
|
|
285
|
+
readonly operation: string;
|
|
286
|
+
readonly cause: unknown;
|
|
287
|
+
} | {
|
|
288
|
+
readonly _tag: "ShellError";
|
|
289
|
+
readonly operation: string;
|
|
290
|
+
readonly command?: readonly string[];
|
|
291
|
+
readonly cause: unknown;
|
|
292
|
+
} | {
|
|
293
|
+
readonly _tag: "LLMError";
|
|
294
|
+
readonly cause: unknown;
|
|
295
|
+
} | {
|
|
296
|
+
readonly _tag: "PatchError";
|
|
297
|
+
readonly operation: string;
|
|
298
|
+
readonly cause: unknown;
|
|
299
|
+
readonly patch?: string;
|
|
300
|
+
} | {
|
|
301
|
+
readonly _tag: "PermissionDenied";
|
|
302
|
+
readonly action: AgentAction;
|
|
303
|
+
readonly reason: string;
|
|
304
|
+
} | {
|
|
305
|
+
readonly _tag: "ApprovalRejected";
|
|
306
|
+
readonly action: AgentAction;
|
|
307
|
+
readonly reason: string;
|
|
308
|
+
} | {
|
|
309
|
+
readonly _tag: "ToolTimeout";
|
|
310
|
+
readonly timeoutMs: number;
|
|
311
|
+
} | {
|
|
312
|
+
readonly _tag: "AgentLoopError";
|
|
313
|
+
readonly message: string;
|
|
314
|
+
} | {
|
|
315
|
+
readonly _tag: "PathOutsideWorkspace";
|
|
316
|
+
readonly path: string;
|
|
317
|
+
readonly cwd: string;
|
|
318
|
+
};
|
|
319
|
+
type FileSystem = {
|
|
320
|
+
readonly readFile: (path: string) => Async<unknown, AgentError, string>;
|
|
321
|
+
readonly exists: (path: string) => Async<unknown, AgentError, boolean>;
|
|
322
|
+
readonly searchText: (cwd: string, query: string, options?: {
|
|
323
|
+
readonly globs?: readonly string[];
|
|
324
|
+
}) => Async<unknown, AgentError, readonly SearchMatch[]>;
|
|
325
|
+
};
|
|
326
|
+
type Shell = {
|
|
327
|
+
readonly exec: (command: readonly string[], options: {
|
|
328
|
+
readonly cwd: string;
|
|
329
|
+
readonly stdin?: string;
|
|
330
|
+
}) => Async<unknown, AgentError, ExecResult>;
|
|
331
|
+
};
|
|
332
|
+
type LLM = {
|
|
333
|
+
readonly complete: (request: LLMRequest) => Async<unknown, AgentError, LLMResponse>;
|
|
334
|
+
};
|
|
335
|
+
type PatchApplyResult = {
|
|
336
|
+
readonly changedFiles: readonly string[];
|
|
337
|
+
};
|
|
338
|
+
type PatchService = {
|
|
339
|
+
readonly apply: (cwd: string, patch: string) => Async<unknown, AgentError, PatchApplyResult>;
|
|
340
|
+
/** Reverse-apply a unified diff, usually for manual rollback of an approved patch. */
|
|
341
|
+
readonly rollback: (cwd: string, patch: string) => Async<unknown, AgentError, PatchApplyResult>;
|
|
342
|
+
};
|
|
343
|
+
type ApprovalRisk = "low" | "medium" | "high";
|
|
344
|
+
type ApprovalDefaultAnswer = "approve" | "reject";
|
|
345
|
+
type ApprovalRequest = {
|
|
346
|
+
readonly action: AgentAction;
|
|
347
|
+
readonly state: AgentState;
|
|
348
|
+
readonly reason: string;
|
|
349
|
+
readonly risk: ApprovalRisk;
|
|
350
|
+
readonly defaultAnswer: ApprovalDefaultAnswer;
|
|
351
|
+
};
|
|
352
|
+
type ApprovalResponse = {
|
|
353
|
+
readonly type: "approved";
|
|
354
|
+
} | {
|
|
355
|
+
readonly type: "rejected";
|
|
356
|
+
readonly reason?: string;
|
|
357
|
+
};
|
|
358
|
+
type ApprovalService = {
|
|
359
|
+
readonly request: (request: ApprovalRequest) => Async<AgentEnv, AgentError, ApprovalResponse>;
|
|
360
|
+
};
|
|
361
|
+
type PermissionDecision = {
|
|
362
|
+
readonly type: "allow";
|
|
363
|
+
} | {
|
|
364
|
+
readonly type: "deny";
|
|
365
|
+
readonly reason: string;
|
|
366
|
+
} | {
|
|
367
|
+
readonly type: "ask";
|
|
368
|
+
readonly reason: string;
|
|
369
|
+
readonly risk: ApprovalRisk;
|
|
370
|
+
readonly defaultAnswer?: ApprovalDefaultAnswer;
|
|
371
|
+
};
|
|
372
|
+
type PermissionService = {
|
|
373
|
+
readonly check: (action: AgentAction, state: AgentState) => Async<AgentEnv, AgentError, PermissionDecision>;
|
|
374
|
+
};
|
|
375
|
+
type AgentEnv = {
|
|
376
|
+
readonly fs: FileSystem;
|
|
377
|
+
readonly shell: Shell;
|
|
378
|
+
readonly llm: LLM;
|
|
379
|
+
readonly patch: PatchService;
|
|
380
|
+
readonly permissions: PermissionService;
|
|
381
|
+
readonly approvals?: ApprovalService;
|
|
382
|
+
readonly events?: AgentEventSink;
|
|
383
|
+
readonly toolPolicies?: AgentToolPolicyConfig;
|
|
384
|
+
};
|
|
385
|
+
|
|
386
|
+
declare const initialAgentState: (goal: AgentGoal) => AgentState;
|
|
387
|
+
|
|
388
|
+
declare const reduceAgentState: (state: AgentState, observation: Observation) => AgentState;
|
|
389
|
+
declare const isTerminal: (state: AgentState) => boolean;
|
|
390
|
+
|
|
391
|
+
declare const decideNextAction: (state: AgentState) => Async<AgentEnv, AgentError, AgentAction>;
|
|
392
|
+
|
|
393
|
+
declare const runAgent: (runtime: Runtime<AgentEnv>, goal: AgentGoal) => Async<AgentEnv, AgentError, AgentState>;
|
|
394
|
+
|
|
395
|
+
declare const nowMillis: () => Async<unknown, never, number>;
|
|
396
|
+
declare const emitAgentEvent: (event: AgentEvent) => Async<AgentEnv, never, void>;
|
|
397
|
+
declare const emitAgentEvents: (events: readonly AgentEvent[]) => Async<AgentEnv, never, void>;
|
|
398
|
+
declare const summarizeAgentAction: (action: AgentAction) => string;
|
|
399
|
+
declare const summarizeAgentObservation: (observation: Observation) => string;
|
|
400
|
+
declare const observationStatus: (observation: Observation) => "ok" | "warn" | "fail";
|
|
401
|
+
declare const errorEventFor: (action: AgentAction, state: AgentState, error: AgentError, at: number) => AgentEvent | undefined;
|
|
402
|
+
declare const observationEventFor: (state: AgentState, observation: Observation, at: number) => AgentEvent | undefined;
|
|
403
|
+
declare const runStatusFor: (phase: AgentPhase) => "done" | "failed";
|
|
404
|
+
|
|
405
|
+
type AgentPreset = "fix-tests" | "inspect" | "typecheck" | "lint";
|
|
406
|
+
type AgentBatchGoal = string | {
|
|
407
|
+
readonly goal?: string;
|
|
408
|
+
readonly preset?: AgentPreset;
|
|
409
|
+
readonly mode?: AgentMode;
|
|
410
|
+
readonly cwd?: string;
|
|
411
|
+
readonly patchFile?: string;
|
|
412
|
+
readonly patchFileMode?: "apply" | "rollback";
|
|
413
|
+
readonly saveRunDir?: string;
|
|
414
|
+
};
|
|
415
|
+
type AgentBatchConfig = {
|
|
416
|
+
/** Goals to execute sequentially when no --batch-file is provided. */
|
|
417
|
+
readonly goals?: readonly AgentBatchGoal[];
|
|
418
|
+
/** Stop after the first failed run. Default: true in --ci mode, false otherwise. */
|
|
419
|
+
readonly stopOnFailure?: boolean;
|
|
420
|
+
};
|
|
421
|
+
declare const isAgentPreset: (value: string) => value is AgentPreset;
|
|
422
|
+
declare const goalForAgentPreset: (preset: AgentPreset) => string;
|
|
423
|
+
|
|
424
|
+
type AgentConfigApprovalMode = "auto" | "interactive" | "approve" | "deny";
|
|
425
|
+
type AgentConfigLLMProvider = "fake" | "google" | "gemini" | "openai" | "openai-compatible";
|
|
426
|
+
type AgentLLMConfig = {
|
|
427
|
+
readonly provider?: AgentConfigLLMProvider;
|
|
428
|
+
readonly model?: string;
|
|
429
|
+
readonly endpoint?: string;
|
|
430
|
+
readonly baseUrl?: string;
|
|
431
|
+
readonly apiVersion?: string;
|
|
432
|
+
readonly apiKeyEnv?: string;
|
|
433
|
+
readonly systemInstruction?: string;
|
|
434
|
+
readonly temperature?: number;
|
|
435
|
+
readonly topP?: number;
|
|
436
|
+
readonly topK?: number;
|
|
437
|
+
readonly maxOutputTokens?: number;
|
|
438
|
+
readonly fakeResponse?: string;
|
|
439
|
+
};
|
|
440
|
+
type ShellAskRule = string | {
|
|
441
|
+
readonly pattern: string;
|
|
442
|
+
readonly reason?: string;
|
|
443
|
+
readonly risk?: ApprovalRisk;
|
|
444
|
+
readonly defaultAnswer?: ApprovalDefaultAnswer;
|
|
445
|
+
};
|
|
446
|
+
type ShellPermissionConfig = {
|
|
447
|
+
/**
|
|
448
|
+
* When true or omitted, the built-in safe read/validation commands remain
|
|
449
|
+
* allowed. Set to false for a strict allowlist defined only by this file.
|
|
450
|
+
*/
|
|
451
|
+
readonly inheritDefaults?: boolean;
|
|
452
|
+
readonly allow?: readonly string[];
|
|
453
|
+
readonly ask?: readonly ShellAskRule[];
|
|
454
|
+
readonly deny?: readonly string[];
|
|
455
|
+
};
|
|
456
|
+
type PatchApplyPermissionConfig = "allow" | "ask" | "deny" | {
|
|
457
|
+
readonly decision?: "allow" | "ask" | "deny";
|
|
458
|
+
readonly reason?: string;
|
|
459
|
+
readonly risk?: ApprovalRisk;
|
|
460
|
+
readonly defaultAnswer?: ApprovalDefaultAnswer;
|
|
461
|
+
};
|
|
462
|
+
type AgentPermissionConfig = {
|
|
463
|
+
readonly shell?: ShellPermissionConfig;
|
|
464
|
+
readonly patchApply?: PatchApplyPermissionConfig;
|
|
465
|
+
};
|
|
466
|
+
type AgentConfig = {
|
|
467
|
+
readonly mode?: AgentMode;
|
|
468
|
+
readonly approval?: AgentConfigApprovalMode;
|
|
469
|
+
readonly llm?: AgentLLMConfig;
|
|
470
|
+
readonly project?: AgentProjectConfig;
|
|
471
|
+
readonly context?: AgentContextConfig;
|
|
472
|
+
readonly patchQuality?: AgentPatchQualityConfig;
|
|
473
|
+
readonly rollback?: AgentRollbackConfig;
|
|
474
|
+
readonly redaction?: AgentRedactionConfig;
|
|
475
|
+
readonly language?: AgentLanguageConfig;
|
|
476
|
+
readonly permissions?: AgentPermissionConfig;
|
|
477
|
+
readonly tools?: AgentToolPolicyConfig;
|
|
478
|
+
readonly batch?: AgentBatchConfig;
|
|
479
|
+
};
|
|
480
|
+
type LoadedAgentConfig = {
|
|
481
|
+
readonly path?: string;
|
|
482
|
+
readonly config: AgentConfig;
|
|
483
|
+
};
|
|
484
|
+
declare const isAgentConfigMode: (value: string) => value is AgentMode;
|
|
485
|
+
declare const isAgentConfigApprovalMode: (value: string) => value is AgentConfigApprovalMode;
|
|
486
|
+
declare const isAgentConfigLLMProvider: (value: string) => value is AgentConfigLLMProvider;
|
|
487
|
+
declare const AGENT_CONFIG_FILE_NAMES: readonly [".brass-agent.json", "brass-agent.config.json"];
|
|
488
|
+
|
|
489
|
+
type ProjectCommand = readonly string[];
|
|
490
|
+
type ProjectCommandDiscovery = {
|
|
491
|
+
readonly packageManager: AgentPackageManager;
|
|
492
|
+
readonly validationCommands: readonly ProjectCommand[];
|
|
493
|
+
readonly source: "config" | "package-json" | "fallback";
|
|
494
|
+
readonly notes: readonly string[];
|
|
495
|
+
readonly profileSummary?: string;
|
|
496
|
+
};
|
|
497
|
+
declare const PROJECT_LOCKFILE_PROBES: readonly ["pnpm-lock.yaml", "yarn.lock", "bun.lockb", "bun.lock", "package-lock.json", "npm-shrinkwrap.json"];
|
|
498
|
+
declare const parseProjectPackageJson: (state: AgentState) => Record<string, unknown> | undefined;
|
|
499
|
+
declare const nextProjectProbeAction: (state: AgentState) => AgentAction | undefined;
|
|
500
|
+
declare const discoverPackageManager: (state: AgentState) => AgentPackageManager;
|
|
501
|
+
declare const splitCommand: (value: string) => readonly string[];
|
|
502
|
+
declare const commandForScript: (packageManager: AgentPackageManager, scriptName: string) => ProjectCommand;
|
|
503
|
+
declare const discoverValidationCommands: (state: AgentState) => ProjectCommandDiscovery;
|
|
504
|
+
declare const nextUnrunValidationCommand: (commands: readonly ProjectCommand[], observations: readonly Observation[]) => ProjectCommand | undefined;
|
|
505
|
+
declare const describeCommandDiscovery: (discovery: ProjectCommandDiscovery) => string;
|
|
506
|
+
|
|
507
|
+
type AgentProjectStack = "node" | "rust" | "tauri" | "desktop" | "bridge" | "monorepo";
|
|
508
|
+
type AgentWorkspaceStyle = "single-package" | "monorepo" | "mixed" | "unknown";
|
|
509
|
+
type AgentProjectProfile = {
|
|
510
|
+
readonly kind: "unknown" | "node" | "rust" | "tauri" | "mixed";
|
|
511
|
+
readonly packageManager: AgentPackageManager;
|
|
512
|
+
readonly stacks: readonly AgentProjectStack[];
|
|
513
|
+
readonly workspaceStyle: AgentWorkspaceStyle;
|
|
514
|
+
readonly markers: readonly string[];
|
|
515
|
+
readonly scripts: readonly string[];
|
|
516
|
+
readonly candidateValidationScripts: readonly string[];
|
|
517
|
+
readonly candidateValidationCommands: readonly string[];
|
|
518
|
+
readonly notes: readonly string[];
|
|
519
|
+
};
|
|
520
|
+
declare const PROJECT_PROFILE_PROBES: readonly ["Cargo.toml", "Cargo.lock", "src-tauri/tauri.conf.json", "src-tauri/Cargo.toml", "apps/desktop/package.json", "apps/desktop/src-tauri/tauri.conf.json", "apps/desktop/src-tauri/Cargo.toml", "bridges/whatsmeow-bridge/Cargo.toml", "bridges/whatsmeow-bridge/package.json", "apps", "packages", "bridges", "turbo.json", "nx.json", "pnpm-workspace.yaml"];
|
|
521
|
+
declare const projectProfileProbePending: (state: AgentState) => string | undefined;
|
|
522
|
+
declare const discoverProjectProfile: (state: AgentState, packageManager: AgentPackageManager) => AgentProjectProfile;
|
|
523
|
+
declare const describeProjectProfile: (profile: AgentProjectProfile) => string;
|
|
524
|
+
|
|
525
|
+
type ContextDiscoverySummary = {
|
|
526
|
+
readonly enabled: boolean;
|
|
527
|
+
readonly searchedQueries: readonly string[];
|
|
528
|
+
readonly pendingQueries: readonly string[];
|
|
529
|
+
readonly discoveredPaths: readonly string[];
|
|
530
|
+
readonly readPaths: readonly string[];
|
|
531
|
+
readonly remainingFileBudget: number;
|
|
532
|
+
};
|
|
533
|
+
declare const extractLikelyFilePaths: (state: AgentState) => readonly string[];
|
|
534
|
+
declare const deriveContextSearchQueries: (state: AgentState) => readonly string[];
|
|
535
|
+
declare const describeContextDiscovery: (state: AgentState) => string;
|
|
536
|
+
declare const summarizeContextDiscovery: (state: AgentState) => ContextDiscoverySummary;
|
|
537
|
+
declare const nextContextDiscoveryAction: (state: AgentState) => AgentAction | undefined;
|
|
538
|
+
|
|
539
|
+
type PatchQualitySummary = {
|
|
540
|
+
readonly enabled: boolean;
|
|
541
|
+
readonly maxRepairAttempts: number;
|
|
542
|
+
readonly repairAttemptsUsed: number;
|
|
543
|
+
readonly repairsRemaining: number;
|
|
544
|
+
readonly exactSuppliedPatch: boolean;
|
|
545
|
+
};
|
|
546
|
+
declare const patchRepairAttemptsUsed: (state: AgentState) => number;
|
|
547
|
+
declare const patchQualitySummary: (state: AgentState) => PatchQualitySummary;
|
|
548
|
+
declare const canRequestPatchRepair: (state: AgentState) => boolean;
|
|
549
|
+
type PatchValidationStatus = {
|
|
550
|
+
readonly type: "not-run";
|
|
551
|
+
} | {
|
|
552
|
+
readonly type: "pending";
|
|
553
|
+
readonly completed: number;
|
|
554
|
+
readonly total: number;
|
|
555
|
+
} | {
|
|
556
|
+
readonly type: "passed" | "failed";
|
|
557
|
+
readonly results: readonly Extract<Observation, {
|
|
558
|
+
type: "shell.result";
|
|
559
|
+
}>[];
|
|
560
|
+
};
|
|
561
|
+
declare const patchValidationStatus: (commands: readonly ProjectCommand[], observationsAfterPatch: readonly Observation[]) => PatchValidationStatus;
|
|
562
|
+
declare const describePatchQuality: (state: AgentState) => string;
|
|
563
|
+
|
|
564
|
+
type AgentRollbackStrategy = "last" | "all";
|
|
565
|
+
type RollbackSafetySummary = {
|
|
566
|
+
readonly enabled: boolean;
|
|
567
|
+
readonly onFinalValidationFailure: boolean;
|
|
568
|
+
readonly strategy: AgentRollbackStrategy;
|
|
569
|
+
readonly maxRollbackDepth: number;
|
|
570
|
+
readonly runValidationAfterRollback: boolean;
|
|
571
|
+
readonly allowForSuppliedPatches: boolean;
|
|
572
|
+
readonly rollbackCount: number;
|
|
573
|
+
readonly appliedStackDepth: number;
|
|
574
|
+
readonly exactSuppliedPatch: boolean;
|
|
575
|
+
};
|
|
576
|
+
type AppliedPatchEntry = {
|
|
577
|
+
readonly index: number;
|
|
578
|
+
readonly patch: string;
|
|
579
|
+
readonly changedFiles: readonly string[];
|
|
580
|
+
};
|
|
581
|
+
declare const rollbackSafetySummary: (state: AgentState) => RollbackSafetySummary;
|
|
582
|
+
declare const unappliedPatchStack: (state: AgentState) => readonly AppliedPatchEntry[];
|
|
583
|
+
declare const latestUnappliedPatch: (state: AgentState) => AppliedPatchEntry | undefined;
|
|
584
|
+
declare const canAutoRollback: (state: AgentState) => boolean;
|
|
585
|
+
declare const shouldContinueRollbackStack: (state: AgentState) => boolean;
|
|
586
|
+
type WorkspaceValidationStatus = {
|
|
587
|
+
readonly type: "not-run";
|
|
588
|
+
} | {
|
|
589
|
+
readonly type: "pending";
|
|
590
|
+
readonly completed: number;
|
|
591
|
+
readonly total: number;
|
|
592
|
+
} | {
|
|
593
|
+
readonly type: "passed" | "failed";
|
|
594
|
+
readonly results: readonly Extract<Observation, {
|
|
595
|
+
type: "shell.result";
|
|
596
|
+
}>[];
|
|
597
|
+
};
|
|
598
|
+
declare const workspaceValidationStatus: (commands: readonly ProjectCommand[], observationsAfterWorkspaceChange: readonly Observation[]) => WorkspaceValidationStatus;
|
|
599
|
+
declare const describeRollbackSafety: (state: AgentState) => string;
|
|
600
|
+
|
|
601
|
+
declare const isRedactionEnabled: (config: AgentRedactionConfig | undefined) => boolean;
|
|
602
|
+
declare const redactText: (value: string, config?: AgentRedactionConfig) => string;
|
|
603
|
+
|
|
604
|
+
declare const inferUserLanguage: (text: string) => string | undefined;
|
|
605
|
+
declare const responseLanguageName: (goal: AgentGoal) => string | undefined;
|
|
606
|
+
declare const describeLanguagePolicy: (goal: AgentGoal) => string;
|
|
607
|
+
declare const spanishLike: (goal: AgentGoal) => boolean;
|
|
608
|
+
|
|
609
|
+
declare const makeConfiguredPermissions: (config?: AgentPermissionConfig) => PermissionService;
|
|
610
|
+
declare const defaultPermissions: PermissionService;
|
|
611
|
+
|
|
612
|
+
declare const autoApproveApprovals: ApprovalService;
|
|
613
|
+
declare const makeAutoDenyApprovals: (reason?: string) => ApprovalService;
|
|
614
|
+
|
|
615
|
+
declare const invokeAction: (action: AgentAction, state: AgentState, scope: Scope<AgentEnv>) => Async<AgentEnv, AgentError, Observation>;
|
|
616
|
+
|
|
617
|
+
declare const retry: <R, E, A>(make: () => Async<R, E, A>, options: {
|
|
618
|
+
readonly times: number;
|
|
619
|
+
readonly while: (error: E) => boolean;
|
|
620
|
+
}) => Async<R, E, A>;
|
|
621
|
+
|
|
622
|
+
declare const sleep: (ms: number) => Async<unknown, never, void>;
|
|
623
|
+
declare const timeout: <R, E, A>(effect: Async<R, E, A>, ms: number, scope: Scope<R>) => Async<R, E | AgentError, A>;
|
|
624
|
+
|
|
625
|
+
declare const extractUnifiedDiff: (content: string) => string | undefined;
|
|
626
|
+
declare const extractPatchPaths: (patch: string) => readonly string[];
|
|
627
|
+
|
|
628
|
+
declare const NodeShell: Shell;
|
|
629
|
+
|
|
630
|
+
declare const makeNodeFileSystem: (shell: Shell) => FileSystem;
|
|
631
|
+
|
|
632
|
+
declare const makeNodePatchService: (shell: Shell) => PatchService;
|
|
633
|
+
|
|
634
|
+
declare const loadNodeAgentConfig: (options: {
|
|
635
|
+
readonly cwd: string;
|
|
636
|
+
readonly configPath?: string;
|
|
637
|
+
readonly noConfig?: boolean;
|
|
638
|
+
}) => Promise<LoadedAgentConfig>;
|
|
639
|
+
|
|
640
|
+
declare const makeOpenAICompatibleLLM: (config: {
|
|
641
|
+
readonly endpoint: string;
|
|
642
|
+
readonly apiKey: string;
|
|
643
|
+
readonly model: string;
|
|
644
|
+
}) => LLM;
|
|
645
|
+
|
|
646
|
+
type GoogleGenerativeAIConfig = {
|
|
647
|
+
/** API key for the Gemini API / Generative Language API. */
|
|
648
|
+
readonly apiKey: string;
|
|
649
|
+
/** Model id, with or without the `models/` prefix. Example: `gemini-2.5-flash`. */
|
|
650
|
+
readonly model?: string;
|
|
651
|
+
/** API version segment. Defaults to `v1beta` for broad Gemini feature coverage. */
|
|
652
|
+
readonly apiVersion?: "v1" | "v1beta" | string;
|
|
653
|
+
/** Base URL for the Generative Language API. Useful for tests/proxies. */
|
|
654
|
+
readonly baseUrl?: string;
|
|
655
|
+
/** Full generateContent endpoint override. If provided, baseUrl/apiVersion/model are ignored. */
|
|
656
|
+
readonly endpoint?: string;
|
|
657
|
+
/** Optional developer instruction. Gemini currently supports text system instructions. */
|
|
658
|
+
readonly systemInstruction?: string;
|
|
659
|
+
/** Optional generation config passthroughs. */
|
|
660
|
+
readonly temperature?: number;
|
|
661
|
+
readonly topP?: number;
|
|
662
|
+
readonly topK?: number;
|
|
663
|
+
readonly maxOutputTokens?: number;
|
|
664
|
+
readonly stopSequences?: readonly string[];
|
|
665
|
+
readonly responseMimeType?: string;
|
|
666
|
+
/** Escape hatch for newer Gemini generationConfig fields without changing this adapter. */
|
|
667
|
+
readonly extraGenerationConfig?: Record<string, unknown>;
|
|
668
|
+
};
|
|
669
|
+
declare const makeGoogleGenerativeAILLM: (config: GoogleGenerativeAIConfig) => LLM;
|
|
670
|
+
|
|
671
|
+
type FakeLLMOptions = {
|
|
672
|
+
readonly content?: string | ((request: LLMRequest) => string);
|
|
673
|
+
};
|
|
674
|
+
declare const makeFakeLLM: (options?: FakeLLMOptions) => LLM;
|
|
675
|
+
|
|
676
|
+
type AgentWorkspaceDiscoveryResult = {
|
|
677
|
+
readonly inputCwd: string;
|
|
678
|
+
readonly cwd: string;
|
|
679
|
+
readonly marker?: string;
|
|
680
|
+
readonly markerPath?: string;
|
|
681
|
+
readonly changed: boolean;
|
|
682
|
+
readonly disabled?: boolean;
|
|
683
|
+
};
|
|
684
|
+
declare const discoverNodeWorkspaceRoot: (cwd: string, options?: {
|
|
685
|
+
readonly enabled?: boolean;
|
|
686
|
+
}) => AgentWorkspaceDiscoveryResult;
|
|
687
|
+
|
|
688
|
+
export { AGENT_CONFIG_FILE_NAMES, type AgentAction, type AgentActionType, type AgentBatchConfig, type AgentBatchGoal, type AgentConfig, type AgentConfigApprovalMode, type AgentConfigLLMProvider, type AgentContextConfig, type AgentEnv, type AgentError, type AgentEvent, type AgentEventSink, type AgentGoal, type AgentLLMConfig, type AgentLanguageConfig, type AgentMode, type AgentPackageManager, type AgentPackageManagerConfig, type AgentPatchQualityConfig, type AgentPermissionConfig, type AgentPhase, type AgentPreset, type AgentProjectConfig, type AgentProjectProfile, type AgentProjectStack, type AgentRedactionConfig, type AgentResponseLanguage, type AgentRollbackConfig, type AgentRollbackStrategy, type AgentState, type AgentToolPolicyConfig, type AgentToolPolicyOverride, type AgentWorkspaceDiscoveryResult, type AgentWorkspaceStyle, type AppliedPatchEntry, type ApprovalDefaultAnswer, type ApprovalRequest, type ApprovalResponse, type ApprovalRisk, type ApprovalService, type ContextDiscoverySummary, type ExecResult, type FakeLLMOptions, type FileSystem, type GoogleGenerativeAIConfig, type LLM, type LLMPurpose, type LLMRequest, type LLMResponse, type LoadedAgentConfig, NodeShell, type Observation, PROJECT_LOCKFILE_PROBES, PROJECT_PROFILE_PROBES, type PatchApplyPermissionConfig, type PatchApplyResult, type PatchQualitySummary, type PatchService, type PatchValidationStatus, type PermissionDecision, type PermissionService, type ProjectCommand, type ProjectCommandDiscovery, type RollbackSafetySummary, type SearchMatch, type Shell, type ShellAskRule, type ShellPermissionConfig, type WorkspaceValidationStatus, autoApproveApprovals, canAutoRollback, canRequestPatchRepair, commandForScript, decideNextAction, defaultPermissions, deriveContextSearchQueries, describeCommandDiscovery, describeContextDiscovery, describeLanguagePolicy, describePatchQuality, describeProjectProfile, describeRollbackSafety, discoverNodeWorkspaceRoot, discoverPackageManager, discoverProjectProfile, discoverValidationCommands, emitAgentEvent, emitAgentEvents, errorEventFor, extractLikelyFilePaths, extractPatchPaths, extractUnifiedDiff, goalForAgentPreset, inferUserLanguage, initialAgentState, invokeAction, isAgentConfigApprovalMode, isAgentConfigLLMProvider, isAgentConfigMode, isAgentPreset, isRedactionEnabled, isTerminal, latestUnappliedPatch, loadNodeAgentConfig, makeAutoDenyApprovals, makeConfiguredPermissions, makeFakeLLM, makeGoogleGenerativeAILLM, makeNodeFileSystem, makeNodePatchService, makeOpenAICompatibleLLM, nextContextDiscoveryAction, nextProjectProbeAction, nextUnrunValidationCommand, nowMillis, observationEventFor, observationStatus, parseProjectPackageJson, patchQualitySummary, patchRepairAttemptsUsed, patchValidationStatus, projectProfileProbePending, redactText, reduceAgentState, responseLanguageName, retry, rollbackSafetySummary, runAgent, runStatusFor, shouldContinueRollbackStack, sleep, spanishLike, splitCommand, summarizeAgentAction, summarizeAgentObservation, summarizeContextDiscovery, timeout, unappliedPatchStack, workspaceValidationStatus };
|