agent-sh 0.12.1 → 0.12.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.
Files changed (39) hide show
  1. package/README.md +10 -4
  2. package/dist/agent/agent-loop.js +34 -16
  3. package/dist/agent/conversation-state.d.ts +4 -0
  4. package/dist/agent/conversation-state.js +44 -0
  5. package/dist/agent/skills.js +2 -2
  6. package/dist/agent/system-prompt.js +2 -3
  7. package/dist/agent/tools/bash.js +10 -3
  8. package/dist/agent/types.d.ts +3 -1
  9. package/dist/core.d.ts +2 -0
  10. package/dist/core.js +5 -3
  11. package/dist/event-bus.d.ts +22 -0
  12. package/dist/event-bus.js +51 -3
  13. package/dist/extension-loader.js +1 -0
  14. package/dist/extensions/agent-backend.js +4 -1
  15. package/dist/extensions/openrouter.js +32 -0
  16. package/dist/index.js +1 -0
  17. package/dist/init.js +1 -2
  18. package/dist/settings.d.ts +8 -0
  19. package/dist/settings.js +7 -3
  20. package/dist/shell/input-handler.d.ts +8 -18
  21. package/dist/shell/input-handler.js +57 -227
  22. package/dist/shell/output-parser.d.ts +2 -1
  23. package/dist/shell/output-parser.js +33 -18
  24. package/dist/shell/shell.d.ts +1 -0
  25. package/dist/shell/shell.js +9 -7
  26. package/dist/shell/tui-input-view.d.ts +37 -0
  27. package/dist/shell/tui-input-view.js +140 -0
  28. package/dist/types.d.ts +6 -0
  29. package/dist/utils/compositor.d.ts +7 -1
  30. package/dist/utils/compositor.js +13 -1
  31. package/dist/utils/floating-panel.d.ts +6 -2
  32. package/dist/utils/floating-panel.js +17 -17
  33. package/dist/utils/ref-counter.d.ts +9 -0
  34. package/dist/utils/ref-counter.js +9 -0
  35. package/package.json +3 -1
  36. package/dist/utils/frame-renderer.d.ts +0 -26
  37. package/dist/utils/frame-renderer.js +0 -76
  38. package/dist/utils/output-writer.d.ts +0 -36
  39. package/dist/utils/output-writer.js +0 -45
@@ -1,76 +0,0 @@
1
- export class FrameRenderer {
2
- writer;
3
- prevLines = [];
4
- constructor(writer) {
5
- this.writer = writer;
6
- }
7
- /**
8
- * Render a new frame, writing only the diff to the output.
9
- * Each line in `lines` should NOT include a trailing newline.
10
- */
11
- update(lines) {
12
- const prev = this.prevLines;
13
- if (prev.length === 0) {
14
- // Fast path 1: first render
15
- for (const line of lines) {
16
- this.writer.write(line + "\n");
17
- }
18
- this.prevLines = lines.slice();
19
- return;
20
- }
21
- // Find first and last changed indices
22
- const minLen = Math.min(prev.length, lines.length);
23
- let firstChanged = -1;
24
- let lastChanged = -1;
25
- for (let i = 0; i < minLen; i++) {
26
- if (prev[i] !== lines[i]) {
27
- if (firstChanged === -1)
28
- firstChanged = i;
29
- lastChanged = i;
30
- }
31
- }
32
- // Check for appended or removed lines
33
- const appended = lines.length > prev.length;
34
- const truncated = lines.length < prev.length;
35
- if (firstChanged === -1 && !appended && !truncated) {
36
- // No changes at all
37
- this.prevLines = lines.slice();
38
- return;
39
- }
40
- if (firstChanged === -1 && appended) {
41
- // Fast path 2: only new lines appended, existing unchanged
42
- for (let i = prev.length; i < lines.length; i++) {
43
- this.writer.write(lines[i] + "\n");
44
- }
45
- this.prevLines = lines.slice();
46
- return;
47
- }
48
- // General diff: move cursor up to first changed line, rewrite
49
- const linesFromBottom = prev.length - (firstChanged === -1 ? prev.length : firstChanged);
50
- if (linesFromBottom > 0) {
51
- this.writer.write(`\x1b[${linesFromBottom}A`); // cursor up
52
- }
53
- this.writer.write("\r"); // start of line
54
- // Rewrite from firstChanged to end of new frame
55
- const start = firstChanged === -1 ? prev.length : firstChanged;
56
- for (let i = start; i < lines.length; i++) {
57
- this.writer.write(`\x1b[2K${lines[i]}\n`); // clear line + write + newline
58
- }
59
- // If new frame is shorter, clear remaining old lines
60
- if (truncated) {
61
- for (let i = lines.length; i < prev.length; i++) {
62
- this.writer.write("\x1b[2K\n");
63
- }
64
- // Move cursor back up to end of new content
65
- const extra = prev.length - lines.length;
66
- if (extra > 0) {
67
- this.writer.write(`\x1b[${extra}A`);
68
- }
69
- }
70
- this.prevLines = lines.slice();
71
- }
72
- /** Reset state — next update will be treated as a first render. */
73
- reset() {
74
- this.prevLines = [];
75
- }
76
- }
@@ -1,36 +0,0 @@
1
- /**
2
- * Abstraction over terminal output.
3
- *
4
- * All TUI rendering goes through an OutputWriter instead of calling
5
- * process.stdout.write directly. This enables testing (BufferWriter),
6
- * alternative frontends, and a single point of control for output.
7
- */
8
- /** Simple ref-counted counter. Increment/decrement never goes below zero. */
9
- export declare class RefCounter {
10
- private count;
11
- increment(): void;
12
- decrement(): void;
13
- reset(): void;
14
- get active(): boolean;
15
- get value(): number;
16
- }
17
- export interface OutputWriter {
18
- write(text: string): void;
19
- get columns(): number;
20
- }
21
- /** Default writer that forwards to process.stdout. */
22
- export declare class StdoutWriter implements OutputWriter {
23
- /** When > 0, all writes are silently dropped. Ref-counted. */
24
- private readonly _hold;
25
- hold(): void;
26
- release(): void;
27
- get held(): boolean;
28
- write(text: string): void;
29
- get columns(): number;
30
- }
31
- /** Captures all output in memory. Useful for testing. */
32
- export declare class BufferWriter implements OutputWriter {
33
- output: string[];
34
- columns: number;
35
- write(text: string): void;
36
- }
@@ -1,45 +0,0 @@
1
- /**
2
- * Abstraction over terminal output.
3
- *
4
- * All TUI rendering goes through an OutputWriter instead of calling
5
- * process.stdout.write directly. This enables testing (BufferWriter),
6
- * alternative frontends, and a single point of control for output.
7
- */
8
- /** Simple ref-counted counter. Increment/decrement never goes below zero. */
9
- export class RefCounter {
10
- count = 0;
11
- increment() { this.count++; }
12
- decrement() { this.count = Math.max(0, this.count - 1); }
13
- reset() { this.count = 0; }
14
- get active() { return this.count > 0; }
15
- get value() { return this.count; }
16
- }
17
- /** Default writer that forwards to process.stdout. */
18
- export class StdoutWriter {
19
- /** When > 0, all writes are silently dropped. Ref-counted. */
20
- _hold = new RefCounter();
21
- hold() { this._hold.increment(); }
22
- release() { this._hold.decrement(); }
23
- get held() { return this._hold.active; }
24
- write(text) {
25
- if (this._hold.active)
26
- return;
27
- if (process.stdout.writable) {
28
- try {
29
- process.stdout.write(text);
30
- }
31
- catch { }
32
- }
33
- }
34
- get columns() {
35
- return process.stdout.columns || 80;
36
- }
37
- }
38
- /** Captures all output in memory. Useful for testing. */
39
- export class BufferWriter {
40
- output = [];
41
- columns = 80;
42
- write(text) {
43
- this.output.push(text);
44
- }
45
- }