@element47/ag 4.5.1 → 4.5.3
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 +184 -8
- package/dist/cli/__tests__/repl-rawmode.test.d.ts +2 -0
- package/dist/cli/__tests__/repl-rawmode.test.d.ts.map +1 -0
- package/dist/cli/__tests__/repl-rawmode.test.js +46 -0
- package/dist/cli/__tests__/repl-rawmode.test.js.map +1 -0
- package/dist/cli/repl.d.ts +7 -2
- package/dist/cli/repl.d.ts.map +1 -1
- package/dist/cli/repl.js +203 -25
- package/dist/cli/repl.js.map +1 -1
- package/dist/cli.js +10 -8
- package/dist/cli.js.map +1 -1
- package/dist/core/__tests__/agent.test.js +42 -1
- package/dist/core/__tests__/agent.test.js.map +1 -1
- package/dist/core/__tests__/context.test.js +81 -0
- package/dist/core/__tests__/context.test.js.map +1 -1
- package/dist/core/__tests__/events.test.d.ts +2 -0
- package/dist/core/__tests__/events.test.d.ts.map +1 -0
- package/dist/core/__tests__/events.test.js +131 -0
- package/dist/core/__tests__/events.test.js.map +1 -0
- package/dist/core/__tests__/extensions.test.d.ts +2 -0
- package/dist/core/__tests__/extensions.test.d.ts.map +1 -0
- package/dist/core/__tests__/extensions.test.js +59 -0
- package/dist/core/__tests__/extensions.test.js.map +1 -0
- package/dist/core/__tests__/guardrails.test.d.ts +2 -0
- package/dist/core/__tests__/guardrails.test.d.ts.map +1 -0
- package/dist/core/__tests__/guardrails.test.js +418 -0
- package/dist/core/__tests__/guardrails.test.js.map +1 -0
- package/dist/core/__tests__/permission-manager.test.d.ts +2 -0
- package/dist/core/__tests__/permission-manager.test.d.ts.map +1 -0
- package/dist/core/__tests__/permission-manager.test.js +246 -0
- package/dist/core/__tests__/permission-manager.test.js.map +1 -0
- package/dist/core/__tests__/streaming.test.js +8 -1
- package/dist/core/__tests__/streaming.test.js.map +1 -1
- package/dist/core/agent.d.ts +27 -0
- package/dist/core/agent.d.ts.map +1 -1
- package/dist/core/agent.js +263 -121
- package/dist/core/agent.js.map +1 -1
- package/dist/core/context.d.ts.map +1 -1
- package/dist/core/context.js +14 -6
- package/dist/core/context.js.map +1 -1
- package/dist/core/events.d.ts +62 -0
- package/dist/core/events.d.ts.map +1 -0
- package/dist/core/events.js +23 -0
- package/dist/core/events.js.map +1 -0
- package/dist/core/extensions.d.ts +10 -0
- package/dist/core/extensions.d.ts.map +1 -0
- package/dist/core/extensions.js +66 -0
- package/dist/core/extensions.js.map +1 -0
- package/dist/core/guardrails.d.ts +32 -0
- package/dist/core/guardrails.d.ts.map +1 -0
- package/dist/core/guardrails.js +149 -0
- package/dist/core/guardrails.js.map +1 -0
- package/dist/core/loader.d.ts +6 -2
- package/dist/core/loader.d.ts.map +1 -1
- package/dist/core/loader.js +23 -9
- package/dist/core/loader.js.map +1 -1
- package/dist/core/permissions.d.ts +60 -0
- package/dist/core/permissions.d.ts.map +1 -0
- package/dist/core/permissions.js +252 -0
- package/dist/core/permissions.js.map +1 -0
- package/dist/core/registry.d.ts.map +1 -1
- package/dist/core/registry.js +16 -0
- package/dist/core/registry.js.map +1 -1
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +26 -3
- package/dist/core/skills.js.map +1 -1
- package/dist/core/types.d.ts +15 -1
- package/dist/core/types.d.ts.map +1 -1
- package/dist/memory/__tests__/memory.test.js +28 -0
- package/dist/memory/__tests__/memory.test.js.map +1 -1
- package/dist/memory/memory.js +1 -1
- package/dist/memory/memory.js.map +1 -1
- package/dist/tools/__tests__/bash.test.js +4 -0
- package/dist/tools/__tests__/bash.test.js.map +1 -1
- package/dist/tools/__tests__/file.test.js +7 -1
- package/dist/tools/__tests__/file.test.js.map +1 -1
- package/package.json +1 -4
package/README.md
CHANGED
|
@@ -7,14 +7,14 @@ Built as a tool-calling loop with bash — inspired by [How does Claude Code act
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
npx @
|
|
11
|
-
npm install -g @
|
|
10
|
+
npx @element47/ag # run directly (prompts for API key on first use)
|
|
11
|
+
npm install -g @element47/ag # or install globally
|
|
12
12
|
```
|
|
13
13
|
|
|
14
14
|
Or from source:
|
|
15
15
|
|
|
16
16
|
```bash
|
|
17
|
-
git clone
|
|
17
|
+
git clone https://github.com/element47/simple-agent
|
|
18
18
|
cd simple-agent
|
|
19
19
|
npm install && npm run build && npm link
|
|
20
20
|
```
|
|
@@ -127,6 +127,46 @@ export default {
|
|
|
127
127
|
|
|
128
128
|
That's it. No config, no registry. Use `/tools` in the REPL to see what's loaded.
|
|
129
129
|
|
|
130
|
+
### Permission Keys
|
|
131
|
+
|
|
132
|
+
By default, custom tools require approval for every call (or you allow all calls with `toolname(*)`). To enable fine-grained permission patterns, add a `permissionKey` to your tool:
|
|
133
|
+
|
|
134
|
+
```js
|
|
135
|
+
// .ag/tools/deploy.mjs
|
|
136
|
+
export default {
|
|
137
|
+
type: "function",
|
|
138
|
+
function: {
|
|
139
|
+
name: "deploy",
|
|
140
|
+
description: "Deploy to an environment",
|
|
141
|
+
parameters: {
|
|
142
|
+
type: "object",
|
|
143
|
+
properties: {
|
|
144
|
+
target: { type: "string", enum: ["staging", "production"] },
|
|
145
|
+
branch: { type: "string" }
|
|
146
|
+
},
|
|
147
|
+
required: ["target"]
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
permissionKey: { qualifier: "target" },
|
|
151
|
+
execute: async ({ target, branch }) => { /* ... */ }
|
|
152
|
+
};
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Now permission patterns can target specific argument values:
|
|
156
|
+
|
|
157
|
+
| Pattern | Effect |
|
|
158
|
+
|---------|--------|
|
|
159
|
+
| `deploy(staging)` | Allow staging deploys |
|
|
160
|
+
| `deploy(production)` | Allow production deploys |
|
|
161
|
+
| `deploy(*)` | Allow all deploys |
|
|
162
|
+
|
|
163
|
+
**`permissionKey` fields:**
|
|
164
|
+
|
|
165
|
+
- `qualifier` (required) — arg name whose value becomes the pattern qualifier. E.g., `{ qualifier: "target" }` + `target: "staging"` produces `deploy(staging)`.
|
|
166
|
+
- `value` (optional) — arg name whose value is matched by the glob portion. E.g., `{ qualifier: "action", value: "path" }` produces `mytool(read:configs/**)`.
|
|
167
|
+
|
|
168
|
+
Without `permissionKey`, the only available pattern is `toolname(*)`.
|
|
169
|
+
|
|
130
170
|
## Skills
|
|
131
171
|
|
|
132
172
|
Skills are reusable prompt instructions (with optional tools) that the agent activates on-demand. Browse and install from [skills.sh](https://skills.sh):
|
|
@@ -158,6 +198,76 @@ Frontmatter fields: `name` (required), `description` (required), `tools: true` (
|
|
|
158
198
|
|
|
159
199
|
The agent sees skill names + descriptions in every prompt. When a task matches, it activates the skill automatically via the `skill` tool, loading the full instructions into context.
|
|
160
200
|
|
|
201
|
+
## Extensions
|
|
202
|
+
|
|
203
|
+
Extensions hook into the agent's lifecycle to intercept, modify, or extend behavior. Place TypeScript files in `.ag/extensions/` (project) or `~/.ag/extensions/` (global).
|
|
204
|
+
|
|
205
|
+
```typescript
|
|
206
|
+
// .ag/extensions/log-tools.ts
|
|
207
|
+
export const name = 'log-tools';
|
|
208
|
+
export const description = 'Logs tool calls and errors';
|
|
209
|
+
|
|
210
|
+
export default function(agent: any) {
|
|
211
|
+
agent.on('tool_call', (event: any) => {
|
|
212
|
+
agent.log(`[log-tools] ${event.toolName}(${JSON.stringify(event.args).slice(0, 80)})`);
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
agent.on('tool_result', (event: any) => {
|
|
216
|
+
if (event.isError) agent.log(`[log-tools] error in ${event.toolName}: ${event.content.slice(0, 100)}`);
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
Extensions export `name` and `description` for the startup display. Use `agent.log()` instead of `process.stderr.write()` for spinner-safe output.
|
|
222
|
+
|
|
223
|
+
At startup you'll see:
|
|
224
|
+
```
|
|
225
|
+
Loaded: global, 3 skill(s), 1 extension(s)
|
|
226
|
+
+ log-tools [extension] Logs tool calls and errors
|
|
227
|
+
```
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### Available Events
|
|
231
|
+
|
|
232
|
+
| Event | When | Mutable? |
|
|
233
|
+
|-------|------|----------|
|
|
234
|
+
| `input` | User message arrives | content, skip |
|
|
235
|
+
| `turn_start` | Top of each iteration | Read-only |
|
|
236
|
+
| `before_request` | Before LLM API call | messages, systemPrompt |
|
|
237
|
+
| `after_response` | After LLM response parsed | message |
|
|
238
|
+
| `tool_call` | Before tool executes | args, block, blockReason |
|
|
239
|
+
| `tool_result` | After tool executes | content, isError |
|
|
240
|
+
| `before_compact` | Before context compaction | cancel, customSummary |
|
|
241
|
+
| `turn_end` | After iteration completes | Read-only |
|
|
242
|
+
|
|
243
|
+
Handlers run sequentially — each handler sees mutations from previous handlers. Use `agent.on(event, handler)` which returns an unsubscribe function. Use `agent.log(message)` for spinner-safe output.
|
|
244
|
+
|
|
245
|
+
### Examples
|
|
246
|
+
|
|
247
|
+
Block dangerous commands:
|
|
248
|
+
```typescript
|
|
249
|
+
agent.on('tool_call', (event: any) => {
|
|
250
|
+
if (event.toolName === 'bash' && event.args.command?.includes('rm -rf /')) {
|
|
251
|
+
event.block = true;
|
|
252
|
+
event.blockReason = 'Blocked: dangerous command';
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
Inject context before every LLM call:
|
|
258
|
+
```typescript
|
|
259
|
+
agent.on('before_request', (event: any) => {
|
|
260
|
+
event.systemPrompt += '\n\nAlways respond in Spanish.';
|
|
261
|
+
});
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
Custom compaction:
|
|
265
|
+
```typescript
|
|
266
|
+
agent.on('before_compact', (event: any) => {
|
|
267
|
+
event.customSummary = 'Working on auth feature. Files: src/auth.ts, src/middleware.ts';
|
|
268
|
+
});
|
|
269
|
+
```
|
|
270
|
+
|
|
161
271
|
## Configuration
|
|
162
272
|
|
|
163
273
|
Persistent settings are stored in `~/.ag/config.json`:
|
|
@@ -234,22 +344,84 @@ Or set it permanently:
|
|
|
234
344
|
|
|
235
345
|
## Permissions
|
|
236
346
|
|
|
237
|
-
In REPL mode, ag prompts before executing mutating operations:
|
|
347
|
+
In REPL mode, ag prompts before executing mutating operations. You can allow once, remember for the session, or save to the project:
|
|
238
348
|
|
|
239
349
|
```
|
|
240
|
-
? bash: npm test (y/n)
|
|
350
|
+
? bash: npm test (y)es / (a)lways / (p)roject / (n)o a
|
|
351
|
+
+ Session rule: bash(npm:*)
|
|
241
352
|
✓ [bash] All tests passed
|
|
242
|
-
? file(write): src/utils.ts (y/n)
|
|
353
|
+
? file(write): src/utils.ts (y)es / (a)lways / (p)roject / (n)o p
|
|
354
|
+
+ Saved to .ag/permissions.json: file(write:src/**)
|
|
243
355
|
✓ [file] Wrote src/utils.ts (24 lines, 680B)
|
|
244
356
|
```
|
|
245
357
|
|
|
358
|
+
**Prompt options:**
|
|
359
|
+
- **y** — allow this one time
|
|
360
|
+
- **a** — allow and remember the pattern for this session
|
|
361
|
+
- **p** — allow and save the pattern to project (`.ag/permissions.json`)
|
|
362
|
+
- **n** — deny this one time
|
|
363
|
+
|
|
364
|
+
### Pattern Syntax
|
|
365
|
+
|
|
366
|
+
Patterns use `Tool(qualifier:glob)` format:
|
|
367
|
+
|
|
368
|
+
| Pattern | Matches |
|
|
369
|
+
|---------|---------|
|
|
370
|
+
| `bash(npm:*)` | Any bash command starting with `npm` |
|
|
371
|
+
| `bash(git:*)` | Any bash command starting with `git` |
|
|
372
|
+
| `file(write:src/**)` | File writes anywhere under `src/` |
|
|
373
|
+
| `file(edit:*)` | All file edits |
|
|
374
|
+
| `git(commit)` | Git commit |
|
|
375
|
+
| `web(fetch:*github.com*)` | Fetch from GitHub domains |
|
|
376
|
+
| `bash(*)` | All bash commands |
|
|
377
|
+
| `*` | Everything |
|
|
378
|
+
|
|
379
|
+
### Rule Scopes
|
|
380
|
+
|
|
381
|
+
| Scope | Storage | Lifetime |
|
|
382
|
+
|-------|---------|----------|
|
|
383
|
+
| Session | In-memory | Until REPL exits |
|
|
384
|
+
| Project | `.ag/permissions.json` | Persists across sessions |
|
|
385
|
+
| Global | `~/.ag/permissions.json` | Persists everywhere |
|
|
386
|
+
|
|
387
|
+
Deny rules always override allow rules. Use `/permissions` to manage rules interactively.
|
|
388
|
+
|
|
389
|
+
### Built-in Classifications
|
|
390
|
+
|
|
246
391
|
**Always allowed (no prompt):** `file(read)`, `file(list)`, `grep(*)`, `memory(*)`, `plan(*)`, `skill(*)`, `git(status)`, `web(search)`
|
|
247
392
|
|
|
248
393
|
**Prompted:** `bash`, `file(write)`, `file(edit)`, `git(commit/push/branch)`, `web(fetch)`
|
|
249
394
|
|
|
250
395
|
**Always blocked:** `rm -rf /`, fork bombs, `sudo rm`, pipe-to-shell (enforced in code regardless of approval)
|
|
251
396
|
|
|
252
|
-
Skip prompts with `ag -y` or `--yes`. One-shot mode (`ag "query"`) auto-approves.
|
|
397
|
+
Skip all prompts with `ag -y` or `--yes`. One-shot mode (`ag "query"`) auto-approves.
|
|
398
|
+
|
|
399
|
+
## Guardrails
|
|
400
|
+
|
|
401
|
+
All externally-loaded tools and skills are scanned at load time for prompt injection and other security issues. This applies to:
|
|
402
|
+
|
|
403
|
+
- Custom tools (`.mjs` files in `~/.ag/tools/` and `.ag/tools/`)
|
|
404
|
+
- Skills (`SKILL.md` files in `~/.ag/skills/` and `.ag/skills/`)
|
|
405
|
+
- Skills installed from the registry via `/skill add`
|
|
406
|
+
|
|
407
|
+
**What gets checked:**
|
|
408
|
+
|
|
409
|
+
| Category | Severity | Examples |
|
|
410
|
+
|----------|----------|---------|
|
|
411
|
+
| Direct injection | Block | "ignore previous instructions", "system override", "reveal prompt" |
|
|
412
|
+
| Encoded payloads | Block | Base64-encoded injection attempts, HTML entity obfuscation |
|
|
413
|
+
| Hidden content | Block | HTML comments with instructions, zero-width characters, control chars |
|
|
414
|
+
| Exfiltration | Block/Warn | `fetch()` calls in descriptions (block), URLs/emails (warn) |
|
|
415
|
+
| Suspicious overrides | Warn | "bypass security", "auto-approve", "run without permission" |
|
|
416
|
+
|
|
417
|
+
**Blocked** items are skipped entirely with a warning. **Warned** items still load but emit a warning to stderr:
|
|
418
|
+
|
|
419
|
+
```
|
|
420
|
+
Warning: evil-tool.mjs blocked by guardrails: tool "evil" description: prompt injection: "ignore previous instructions"
|
|
421
|
+
Warning: shady-tool.mjs: tool "shady" description: description contains URL
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
When installing a skill from the registry, files are scanned before being written to disk. If the core `SKILL.md` is blocked, the entire installation is aborted.
|
|
253
425
|
|
|
254
426
|
## Streaming
|
|
255
427
|
|
|
@@ -275,7 +447,7 @@ Tools execute in parallel when the model returns multiple tool calls.
|
|
|
275
447
|
- For multi-step coding tasks, the agent creates a plan before starting and updates it as it goes.
|
|
276
448
|
- For simple questions, it just answers directly.
|
|
277
449
|
- At 25 iterations the REPL asks if you want to continue.
|
|
278
|
-
- At 90% context window usage, ag automatically summarizes older conversation messages to free space. Use `/compact` to trigger manually. Only message history is compacted — system prompt, tools, and skills are unaffected.
|
|
450
|
+
- At 90% context window usage, ag automatically summarizes older conversation messages to free space. Use `/context compact` to trigger manually. Only message history is compacted — system prompt, tools, and skills are unaffected.
|
|
279
451
|
|
|
280
452
|
## When to use something else
|
|
281
453
|
|
|
@@ -300,6 +472,10 @@ src/
|
|
|
300
472
|
core/types.ts # interfaces
|
|
301
473
|
core/colors.ts # ANSI colors (respects NO_COLOR)
|
|
302
474
|
core/version.ts # version from package.json
|
|
475
|
+
core/constants.ts # AG_DIR, ignore patterns, binary detection
|
|
476
|
+
core/guardrails.ts # prompt injection scanning (5 threat categories)
|
|
477
|
+
core/loader.ts # custom tool loader (~/.ag/tools/, .ag/tools/)
|
|
478
|
+
core/permissions.ts # permission manager with glob pattern matching
|
|
303
479
|
memory/memory.ts # three-tier file memory
|
|
304
480
|
tools/file.ts # file reading + directory listing
|
|
305
481
|
tools/bash.ts # shell execution (with command safeguards)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repl-rawmode.test.d.ts","sourceRoot":"","sources":["../../../src/cli/__tests__/repl-rawmode.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { readFileSync } from 'node:fs';
|
|
3
|
+
import { resolve } from 'node:path';
|
|
4
|
+
/**
|
|
5
|
+
* Structural tests for the REPL's raw-mode / interrupt handling.
|
|
6
|
+
*
|
|
7
|
+
* The REPL relies on readline managing raw mode (set at construction,
|
|
8
|
+
* cleared at close). The interrupt-detection code (escape key listener)
|
|
9
|
+
* must NOT toggle setRawMode itself — doing so leaves stdin in cooked
|
|
10
|
+
* mode after the agent run, causing readline to double-echo user input.
|
|
11
|
+
*
|
|
12
|
+
* These tests read the source to enforce that invariant so the bug
|
|
13
|
+
* cannot silently regress.
|
|
14
|
+
*/
|
|
15
|
+
const replSource = readFileSync(resolve(import.meta.dirname, '..', 'repl.ts'), 'utf-8');
|
|
16
|
+
describe('REPL interrupt handling — raw mode invariant', () => {
|
|
17
|
+
// Extract the runAgent closure body (between `const runAgent` and the next
|
|
18
|
+
// top-level `await runAgent`). We look for setRawMode calls inside it.
|
|
19
|
+
const runAgentMatch = replSource.match(/const runAgent = async[\s\S]*?finally\s*\{[\s\S]*?\}\s*\}/);
|
|
20
|
+
const runAgentBody = runAgentMatch?.[0] ?? '';
|
|
21
|
+
it('runAgent body is found in source', () => {
|
|
22
|
+
expect(runAgentBody.length).toBeGreaterThan(100);
|
|
23
|
+
});
|
|
24
|
+
it('does NOT call setRawMode(true) inside runAgent', () => {
|
|
25
|
+
// readline manages raw mode; the interrupt setup must not override it
|
|
26
|
+
expect(runAgentBody).not.toMatch(/setRawMode\s*\(\s*true\s*\)/);
|
|
27
|
+
});
|
|
28
|
+
it('does NOT call setRawMode(false) inside runAgent', () => {
|
|
29
|
+
// Turning raw mode off after agent run breaks readline's next question()
|
|
30
|
+
expect(runAgentBody).not.toMatch(/setRawMode\s*\(\s*false\s*\)/);
|
|
31
|
+
});
|
|
32
|
+
it('pauses readline before adding keypress listener', () => {
|
|
33
|
+
// Must pause rl to detach its keypress handler before we add ours
|
|
34
|
+
const pauseIdx = runAgentBody.indexOf('.rl.pause()');
|
|
35
|
+
const onKeypressIdx = runAgentBody.indexOf("on('keypress'");
|
|
36
|
+
expect(pauseIdx).toBeGreaterThan(-1);
|
|
37
|
+
expect(onKeypressIdx).toBeGreaterThan(-1);
|
|
38
|
+
expect(pauseIdx).toBeLessThan(onKeypressIdx);
|
|
39
|
+
});
|
|
40
|
+
it('removes keypress listener in finally block', () => {
|
|
41
|
+
const finallyMatch = runAgentBody.match(/finally\s*\{[\s\S]*\}/);
|
|
42
|
+
expect(finallyMatch).not.toBeNull();
|
|
43
|
+
expect(finallyMatch[0]).toMatch(/removeListener\s*\(\s*['"]keypress['"]/);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
//# sourceMappingURL=repl-rawmode.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repl-rawmode.test.js","sourceRoot":"","sources":["../../../src/cli/__tests__/repl-rawmode.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC;;;;;;;;;;GAUG;AAEH,MAAM,UAAU,GAAG,YAAY,CAC7B,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,SAAS,CAAC,EAC7C,OAAO,CACR,CAAC;AAEF,QAAQ,CAAC,8CAA8C,EAAE,GAAG,EAAE;IAC5D,2EAA2E;IAC3E,wEAAwE;IACxE,MAAM,aAAa,GAAG,UAAU,CAAC,KAAK,CACpC,2DAA2D,CAC5D,CAAC;IACF,MAAM,YAAY,GAAG,aAAa,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAE9C,EAAE,CAAC,kCAAkC,EAAE,GAAG,EAAE;QAC1C,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;IACnD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,gDAAgD,EAAE,GAAG,EAAE;QACxD,sEAAsE;QACtE,MAAM,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,6BAA6B,CAAC,CAAC;IAClE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iDAAiD,EAAE,GAAG,EAAE;QACzD,yEAAyE;QACzE,MAAM,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,8BAA8B,CAAC,CAAC;IACnE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iDAAiD,EAAE,GAAG,EAAE;QACzD,kEAAkE;QAClE,MAAM,QAAQ,GAAG,YAAY,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;QACrD,MAAM,aAAa,GAAG,YAAY,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;QAC5D,MAAM,CAAC,QAAQ,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;QACrC,MAAM,CAAC,aAAa,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1C,MAAM,CAAC,QAAQ,CAAC,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;IAC/C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,4CAA4C,EAAE,GAAG,EAAE;QACpD,MAAM,YAAY,GAAG,YAAY,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC;QACjE,MAAM,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;QACpC,MAAM,CAAC,YAAa,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,wCAAwC,CAAC,CAAC;IAC7E,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/cli/repl.d.ts
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
import { Interface } from 'node:readline';
|
|
2
2
|
import { Agent } from '../core/agent.js';
|
|
3
|
+
import { PermissionManager } from '../core/permissions.js';
|
|
3
4
|
import type { ConfirmToolCall } from '../core/types.js';
|
|
4
5
|
export declare function createConfirmCallback(sharedRl?: Interface): ConfirmToolCall & {
|
|
5
6
|
pauseSpinner: (() => void) | null;
|
|
6
7
|
};
|
|
8
|
+
export declare function createPermissionCallback(pm: PermissionManager, sharedRl?: Interface): ConfirmToolCall & {
|
|
9
|
+
pauseSpinner: (() => void) | null;
|
|
10
|
+
};
|
|
7
11
|
export declare class REPL {
|
|
8
12
|
private readonly agent;
|
|
9
13
|
private readonly rl;
|
|
10
|
-
private readonly
|
|
11
|
-
|
|
14
|
+
private readonly pm;
|
|
15
|
+
private confirmCb;
|
|
16
|
+
constructor(agent: Agent, pm?: PermissionManager, confirmCb?: ReturnType<typeof createPermissionCallback>);
|
|
12
17
|
start(): Promise<void>;
|
|
13
18
|
private handleCommand;
|
|
14
19
|
private ask;
|
package/dist/cli/repl.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repl.d.ts","sourceRoot":"","sources":["../../src/cli/repl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,SAAS,EAAsB,MAAM,eAAe,CAAC;AAC/E,OAAO,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"repl.d.ts","sourceRoot":"","sources":["../../src/cli/repl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,SAAS,EAAsB,MAAM,eAAe,CAAC;AAC/E,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAKzC,OAAO,EAAE,iBAAiB,EAAgB,MAAM,wBAAwB,CAAC;AACzE,OAAO,KAAK,EAAE,eAAe,EAAiB,MAAM,kBAAkB,CAAC;AAqCvE,wBAAgB,qBAAqB,CAAC,QAAQ,CAAC,EAAE,SAAS,GAAG,eAAe,GAAG;IAAE,YAAY,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI,CAAA;CAAE,CAgBnH;AAED,wBAAgB,wBAAwB,CAAC,EAAE,EAAE,iBAAiB,EAAE,QAAQ,CAAC,EAAE,SAAS,GAAG,eAAe,GAAG;IAAE,YAAY,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI,CAAA;CAAE,CAiD7I;AA8GD,qBAAa,IAAI;IACf,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAQ;IAC9B,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAY;IAC/B,OAAO,CAAC,QAAQ,CAAC,EAAE,CAA2B;IAC9C,OAAO,CAAC,SAAS,CAAqD;gBAE1D,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,EAAE,iBAAiB,EAAE,SAAS,CAAC,EAAE,UAAU,CAAC,OAAO,wBAAwB,CAAC;IAqBnG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;YAwNd,aAAa;IA+Y3B,OAAO,CAAC,GAAG;CAGZ"}
|