@dirgha/code 1.5.1 → 1.7.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.
Files changed (65) hide show
  1. package/CHANGELOG.md +5 -5
  2. package/LICENSE +21 -101
  3. package/README.md +4 -3
  4. package/dist_v2/cli/config.d.ts +0 -1
  5. package/dist_v2/cli/config.js.map +1 -1
  6. package/dist_v2/cli/flows/wizard.js +142 -0
  7. package/dist_v2/cli/flows/wizard.js.map +1 -1
  8. package/dist_v2/cli/main.js +4 -8
  9. package/dist_v2/cli/main.js.map +1 -1
  10. package/dist_v2/cli/slash/theme.js +12 -4
  11. package/dist_v2/cli/slash/theme.js.map +1 -1
  12. package/dist_v2/cli/subcommands/doctor.js +21 -0
  13. package/dist_v2/cli/subcommands/doctor.js.map +1 -1
  14. package/dist_v2/cli/subcommands/hardware.d.ts +6 -0
  15. package/dist_v2/cli/subcommands/hardware.js +41 -0
  16. package/dist_v2/cli/subcommands/hardware.js.map +1 -0
  17. package/dist_v2/cli/subcommands/index.js +2 -0
  18. package/dist_v2/cli/subcommands/index.js.map +1 -1
  19. package/dist_v2/kernel/agent-loop.d.ts +38 -8
  20. package/dist_v2/kernel/agent-loop.js +57 -18
  21. package/dist_v2/kernel/agent-loop.js.map +1 -1
  22. package/dist_v2/kernel/index.d.ts +1 -0
  23. package/dist_v2/kernel/index.js +1 -0
  24. package/dist_v2/kernel/index.js.map +1 -1
  25. package/dist_v2/kernel/message.d.ts +17 -1
  26. package/dist_v2/kernel/message.js +26 -0
  27. package/dist_v2/kernel/message.js.map +1 -1
  28. package/dist_v2/kernel/queues.d.ts +82 -0
  29. package/dist_v2/kernel/queues.js +105 -0
  30. package/dist_v2/kernel/queues.js.map +1 -0
  31. package/dist_v2/kernel/types.d.ts +29 -0
  32. package/dist_v2/providers/dispatch.d.ts +1 -1
  33. package/dist_v2/providers/dispatch.js +2 -1
  34. package/dist_v2/providers/dispatch.js.map +1 -1
  35. package/dist_v2/providers/faux.d.ts +99 -0
  36. package/dist_v2/providers/faux.js +153 -0
  37. package/dist_v2/providers/faux.js.map +1 -0
  38. package/dist_v2/providers/index.d.ts +2 -0
  39. package/dist_v2/providers/index.js +3 -0
  40. package/dist_v2/providers/index.js.map +1 -1
  41. package/dist_v2/providers/llamacpp.d.ts +16 -0
  42. package/dist_v2/providers/llamacpp.js +39 -0
  43. package/dist_v2/providers/llamacpp.js.map +1 -0
  44. package/dist_v2/setup/hardware-detect.d.ts +16 -0
  45. package/dist_v2/setup/hardware-detect.js +69 -0
  46. package/dist_v2/setup/hardware-detect.js.map +1 -0
  47. package/dist_v2/setup/model-curator.d.ts +26 -0
  48. package/dist_v2/setup/model-curator.js +128 -0
  49. package/dist_v2/setup/model-curator.js.map +1 -0
  50. package/dist_v2/tui/ink/App.js +32 -4
  51. package/dist_v2/tui/ink/App.js.map +1 -1
  52. package/dist_v2/tui/ink/components/InputBox.js +1 -1
  53. package/dist_v2/tui/ink/components/InputBox.js.map +1 -1
  54. package/dist_v2/tui/ink/components/Logo.d.ts +6 -3
  55. package/dist_v2/tui/ink/components/Logo.js +38 -12
  56. package/dist_v2/tui/ink/components/Logo.js.map +1 -1
  57. package/dist_v2/tui/ink/components/StatusBar.js +35 -14
  58. package/dist_v2/tui/ink/components/StatusBar.js.map +1 -1
  59. package/dist_v2/tui/ink/components/ThemePicker.d.ts +19 -0
  60. package/dist_v2/tui/ink/components/ThemePicker.js +61 -0
  61. package/dist_v2/tui/ink/components/ThemePicker.js.map +1 -0
  62. package/dist_v2/tui/ink/use-overlays.d.ts +2 -2
  63. package/dist_v2/tui/ink/use-overlays.js.map +1 -1
  64. package/package.json +6 -16
  65. package/CREDITS.md +0 -46
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Steering and follow-up queues for mid-flight agent control.
3
+ *
4
+ * Two queue types with different drain semantics:
5
+ *
6
+ * - SteeringQueue: drain mode 'all'. Every queued message replaces the
7
+ * current turn's prompt mid-flight. Used for "stop and do this instead".
8
+ * When drained, all queued messages are returned and the queue is cleared.
9
+ *
10
+ * - FollowUpQueue: drain mode 'one-at-a-time'. Each queued message becomes
11
+ * the next turn after the current one completes. When drained, only one
12
+ * message is returned (if any), leaving the rest for subsequent drains.
13
+ *
14
+ * Both queues accept `AgentMessage` (user messages to inject into the
15
+ * conversation) and expose the standard queue operations: enqueue, drain,
16
+ * peek, and clear.
17
+ */
18
+ import type { AgentMessage } from './types.js';
19
+ /**
20
+ * Drain mode determines how many messages are removed on drain.
21
+ * - 'all': drain removes every queued message.
22
+ * - 'one': drain removes at most one message.
23
+ */
24
+ type DrainMode = 'all' | 'one';
25
+ /**
26
+ * Base queue implementation with configurable drain behaviour.
27
+ */
28
+ declare class MessageQueue {
29
+ protected readonly messages: AgentMessage[];
30
+ protected readonly mode: DrainMode;
31
+ constructor(mode: DrainMode);
32
+ /**
33
+ * Append a message to the end of the queue.
34
+ */
35
+ enqueue(msg: AgentMessage): void;
36
+ /**
37
+ * Remove and return messages according to the drain mode.
38
+ *
39
+ * - 'all': returns all messages (or null if empty), clears the queue.
40
+ * - 'one': returns the oldest message as a single-element array (or null
41
+ * if empty), removes only that message.
42
+ */
43
+ drain(): AgentMessage[] | null;
44
+ /**
45
+ * Peek at queued messages without removing them.
46
+ *
47
+ * - 'all': returns all messages (or null if empty).
48
+ * - 'one': returns the oldest message as a single-element array (or null
49
+ * if empty).
50
+ */
51
+ peek(): AgentMessage[] | null;
52
+ /**
53
+ * Remove all messages from the queue.
54
+ */
55
+ clear(): void;
56
+ /**
57
+ * Number of messages currently in the queue.
58
+ */
59
+ get length(): number;
60
+ }
61
+ /**
62
+ * SteeringQueue: drain mode 'all'.
63
+ *
64
+ * Used for mid-flight steering — "stop and do this instead". When drained,
65
+ * all queued messages are returned and the queue is cleared. The agent loop
66
+ * should push these messages into history and continue looping (i.e. not
67
+ * break on end_turn).
68
+ */
69
+ export declare class SteeringQueue extends MessageQueue {
70
+ constructor();
71
+ }
72
+ /**
73
+ * FollowUpQueue: drain mode 'one-at-a-time'.
74
+ *
75
+ * Used for scheduling follow-up turns. Each queued message becomes the next
76
+ * turn after the current one completes. When drained, only one message is
77
+ * returned (if any), leaving the rest for subsequent drains.
78
+ */
79
+ export declare class FollowUpQueue extends MessageQueue {
80
+ constructor();
81
+ }
82
+ export {};
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Steering and follow-up queues for mid-flight agent control.
3
+ *
4
+ * Two queue types with different drain semantics:
5
+ *
6
+ * - SteeringQueue: drain mode 'all'. Every queued message replaces the
7
+ * current turn's prompt mid-flight. Used for "stop and do this instead".
8
+ * When drained, all queued messages are returned and the queue is cleared.
9
+ *
10
+ * - FollowUpQueue: drain mode 'one-at-a-time'. Each queued message becomes
11
+ * the next turn after the current one completes. When drained, only one
12
+ * message is returned (if any), leaving the rest for subsequent drains.
13
+ *
14
+ * Both queues accept `AgentMessage` (user messages to inject into the
15
+ * conversation) and expose the standard queue operations: enqueue, drain,
16
+ * peek, and clear.
17
+ */
18
+ /**
19
+ * Base queue implementation with configurable drain behaviour.
20
+ */
21
+ class MessageQueue {
22
+ messages = [];
23
+ mode;
24
+ constructor(mode) {
25
+ this.mode = mode;
26
+ }
27
+ /**
28
+ * Append a message to the end of the queue.
29
+ */
30
+ enqueue(msg) {
31
+ this.messages.push(msg);
32
+ }
33
+ /**
34
+ * Remove and return messages according to the drain mode.
35
+ *
36
+ * - 'all': returns all messages (or null if empty), clears the queue.
37
+ * - 'one': returns the oldest message as a single-element array (or null
38
+ * if empty), removes only that message.
39
+ */
40
+ drain() {
41
+ if (this.messages.length === 0)
42
+ return null;
43
+ if (this.mode === 'all') {
44
+ const drained = [...this.messages];
45
+ this.messages.length = 0;
46
+ return drained;
47
+ }
48
+ // mode === 'one'
49
+ return [this.messages.shift()];
50
+ }
51
+ /**
52
+ * Peek at queued messages without removing them.
53
+ *
54
+ * - 'all': returns all messages (or null if empty).
55
+ * - 'one': returns the oldest message as a single-element array (or null
56
+ * if empty).
57
+ */
58
+ peek() {
59
+ if (this.messages.length === 0)
60
+ return null;
61
+ if (this.mode === 'all') {
62
+ return [...this.messages];
63
+ }
64
+ // mode === 'one'
65
+ return [this.messages[0]];
66
+ }
67
+ /**
68
+ * Remove all messages from the queue.
69
+ */
70
+ clear() {
71
+ this.messages.length = 0;
72
+ }
73
+ /**
74
+ * Number of messages currently in the queue.
75
+ */
76
+ get length() {
77
+ return this.messages.length;
78
+ }
79
+ }
80
+ /**
81
+ * SteeringQueue: drain mode 'all'.
82
+ *
83
+ * Used for mid-flight steering — "stop and do this instead". When drained,
84
+ * all queued messages are returned and the queue is cleared. The agent loop
85
+ * should push these messages into history and continue looping (i.e. not
86
+ * break on end_turn).
87
+ */
88
+ export class SteeringQueue extends MessageQueue {
89
+ constructor() {
90
+ super('all');
91
+ }
92
+ }
93
+ /**
94
+ * FollowUpQueue: drain mode 'one-at-a-time'.
95
+ *
96
+ * Used for scheduling follow-up turns. Each queued message becomes the next
97
+ * turn after the current one completes. When drained, only one message is
98
+ * returned (if any), leaving the rest for subsequent drains.
99
+ */
100
+ export class FollowUpQueue extends MessageQueue {
101
+ constructor() {
102
+ super('one');
103
+ }
104
+ }
105
+ //# sourceMappingURL=queues.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queues.js","sourceRoot":"","sources":["../../src_v2/kernel/queues.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAWH;;GAEG;AACH,MAAM,YAAY;IACG,QAAQ,GAAmB,EAAE,CAAC;IAC9B,IAAI,CAAY;IAEnC,YAAY,IAAe;QACzB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED;;OAEG;IACH,OAAO,CAAC,GAAiB;QACvB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC1B,CAAC;IAED;;;;;;OAMG;IACH,KAAK;QACH,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,IAAI,CAAC;QAC5C,IAAI,IAAI,CAAC,IAAI,KAAK,KAAK,EAAE,CAAC;YACxB,MAAM,OAAO,GAAG,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC;YACnC,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;YACzB,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,iBAAiB;QACjB,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAG,CAAC,CAAC;IAClC,CAAC;IAED;;;;;;OAMG;IACH,IAAI;QACF,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,IAAI,CAAC;QAC5C,IAAI,IAAI,CAAC,IAAI,KAAK,KAAK,EAAE,CAAC;YACxB,OAAO,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC5B,CAAC;QACD,iBAAiB;QACjB,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;IAC9B,CAAC;CACF;AAED;;;;;;;GAOG;AACH,MAAM,OAAO,aAAc,SAAQ,YAAY;IAC7C;QACE,KAAK,CAAC,KAAK,CAAC,CAAC;IACf,CAAC;CACF;AAED;;;;;;GAMG;AACH,MAAM,OAAO,aAAc,SAAQ,YAAY;IAC7C;QACE,KAAK,CAAC,KAAK,CAAC,CAAC;IACf,CAAC;CACF"}
@@ -33,6 +33,35 @@ export interface Message {
33
33
  content: string | ContentPart[];
34
34
  name?: string;
35
35
  }
36
+ /**
37
+ * UI-only metadata that may be attached to a message in agent state but
38
+ * MUST NOT be sent to the LLM. Use `convertToLlm` (see `./message.ts`) at
39
+ * the provider boundary to strip these fields.
40
+ *
41
+ * `kind` is the high-level provenance / role of the entry:
42
+ * - 'notification' : transient UI banner (rate-limit, model-switch, etc.)
43
+ * - 'skill-injection' : marker for a skill-prompt injection event
44
+ * - 'fleet-supervisor': supervisor commentary in fleet/multi-agent runs
45
+ * - 'internal' : free-form internal annotation
46
+ *
47
+ * `data` is opaque to the kernel; consumers (TUI, daemon, fleet) may shape
48
+ * it as they wish.
49
+ */
50
+ export interface AgentMessageUi {
51
+ kind: 'notification' | 'skill-injection' | 'fleet-supervisor' | 'internal';
52
+ data?: unknown;
53
+ }
54
+ /**
55
+ * `AgentMessage` is the in-kernel transcript entry. It is a `Message` plus
56
+ * optional UI-only metadata. The agent loop stores `AgentMessage[]`; only
57
+ * the projected `Message[]` (via `convertToLlm`) is sent to providers.
58
+ *
59
+ * `hidden: true` excludes the message from the LLM context entirely.
60
+ */
61
+ export interface AgentMessage extends Message {
62
+ ui?: AgentMessageUi;
63
+ hidden?: boolean;
64
+ }
36
65
  export type StopReason = 'end_turn' | 'tool_use' | 'max_tokens' | 'stop_sequence' | 'error' | 'aborted';
37
66
  export interface UsageTotal {
38
67
  inputTokens: number;
@@ -6,6 +6,6 @@
6
6
  * "nvidia/..."); bare ids fall through to the catch-all rules at the
7
7
  * end.
8
8
  */
9
- export type ProviderId = 'anthropic' | 'openai' | 'gemini' | 'openrouter' | 'nvidia' | 'ollama' | 'fireworks';
9
+ export type ProviderId = 'anthropic' | 'openai' | 'gemini' | 'openrouter' | 'nvidia' | 'ollama' | 'llamacpp' | 'fireworks';
10
10
  export declare function routeModel(modelId: string): ProviderId;
11
11
  export declare function isKnownProvider(id: string): id is ProviderId;
@@ -26,6 +26,7 @@ const RULES = [
26
26
  { match: id => id.startsWith('gemini-'), provider: 'gemini' },
27
27
  // Local & explicit-prefix providers.
28
28
  { match: id => id.startsWith('ollama/'), provider: 'ollama' },
29
+ { match: id => id.startsWith('llamacpp/'), provider: 'llamacpp' },
29
30
  { match: id => id.startsWith('fireworks/'), provider: 'fireworks' },
30
31
  // Catch-all: any vendor-prefixed slug or `:free` variant goes via
31
32
  // OpenRouter (anthropic/, openai/, google/, deepseek/, moonshotai/,
@@ -42,6 +43,6 @@ export function routeModel(modelId) {
42
43
  export function isKnownProvider(id) {
43
44
  return (id === 'anthropic' || id === 'openai' || id === 'gemini'
44
45
  || id === 'openrouter' || id === 'nvidia' || id === 'ollama'
45
- || id === 'fireworks');
46
+ || id === 'llamacpp' || id === 'fireworks');
46
47
  }
47
48
  //# sourceMappingURL=dispatch.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"dispatch.js","sourceRoot":"","sources":["../../src_v2/providers/dispatch.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAgBH,wEAAwE;AACxE,wEAAwE;AACxE,sEAAsE;AACtE,4DAA4D;AAC5D,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAS;IACxC,6BAA6B;IAC7B,+BAA+B;IAC/B,6BAA6B;IAC7B,kCAAkC;IAClC,6BAA6B;CAC9B,CAAC,CAAC;AAEH,MAAM,KAAK,GAAkB;IAC3B,sEAAsE;IACtE,EAAE,KAAK,EAAE,EAAE,CAAC,EAAE,CAAC,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE;IAC9D,sDAAsD;IACtD,EAAE,KAAK,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,QAAQ,EAAE,WAAW,EAAE;IAChE,EAAE,KAAK,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,mBAAmB,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE;IAC1F,EAAE,KAAK,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE;IAC7D,qCAAqC;IACrC,EAAE,KAAK,EAAE,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IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC;YAAE,OAAO,IAAI,CAAC,QAAQ,CAAC;IAChD,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,qCAAqC,OAAO,iDAAiD,CAAC,CAAC;AACjH,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,EAAU;IACxC,OAAO,CACL,EAAE,KAAK,WAAW,IAAI,EAAE,KAAK,QAAQ,IAAI,EAAE,KAAK,QAAQ;WACrD,EAAE,KAAK,YAAY,IAAI,EAAE,KAAK,QAAQ,IAAI,EAAE,KAAK,QAAQ;WACzD,EAAE,KAAK,UAAU,IAAI,EAAE,KAAK,WAAW,CAC3C,CAAC;AACJ,CAAC"}
@@ -0,0 +1,99 @@
1
+ /**
2
+ * FauxProvider — deterministic, in-process Provider for testing the agent loop.
3
+ *
4
+ * Implements the same `Provider` contract as real providers (anthropic.ts,
5
+ * openai.ts, etc.) but consumes a pre-baked script of step descriptors
6
+ * instead of talking to a network. Each call to `stream()` consumes the
7
+ * NEXT step from the script and emits the corresponding `AgentEvent`s.
8
+ *
9
+ * Use it to drive `runAgentLoop` end-to-end without any I/O.
10
+ *
11
+ * const provider = new FauxProvider([
12
+ * { kind: 'tool-call', id: 'c1', name: 'shell', input: { cmd: 'ls' } },
13
+ * { kind: 'text', chunks: ['done'] },
14
+ * ]);
15
+ *
16
+ * The provider also records `callCount` and `lastMessages` so tests can
17
+ * assert what the loop sent to the LLM (post-projection from AgentMessage[]).
18
+ */
19
+ import type { AgentEvent, Message } from '../kernel/types.js';
20
+ import type { Provider, StreamRequest } from './iface.js';
21
+ export type FauxScriptStep = {
22
+ kind: 'text';
23
+ chunks: string[];
24
+ usage?: {
25
+ inputTokens: number;
26
+ outputTokens: number;
27
+ cachedTokens?: number;
28
+ };
29
+ } | {
30
+ kind: 'tool-call';
31
+ id: string;
32
+ name: string;
33
+ input: unknown;
34
+ usage?: {
35
+ inputTokens: number;
36
+ outputTokens: number;
37
+ cachedTokens?: number;
38
+ };
39
+ } | {
40
+ kind: 'mixed';
41
+ text?: string;
42
+ toolCalls: {
43
+ id: string;
44
+ name: string;
45
+ input: unknown;
46
+ }[];
47
+ usage?: {
48
+ inputTokens: number;
49
+ outputTokens: number;
50
+ cachedTokens?: number;
51
+ };
52
+ } | {
53
+ kind: 'error';
54
+ error: Error;
55
+ } | {
56
+ kind: 'abort';
57
+ afterMs?: number;
58
+ } | {
59
+ kind: 'wait';
60
+ ms: number;
61
+ };
62
+ export interface FauxProviderOptions {
63
+ /** Provider id reported via `provider.id`. Defaults to `'faux'`. */
64
+ id?: string;
65
+ /** Whether `supportsTools` returns true (default: true). */
66
+ supportsTools?: boolean;
67
+ /** Whether `supportsThinking` returns true (default: false). */
68
+ supportsThinking?: boolean;
69
+ }
70
+ /**
71
+ * Synchronous-throwing AbortError. Mirrors the shape Node/undici fetch
72
+ * rejects with when an AbortSignal fires mid-request — `.name === 'AbortError'`
73
+ * is the discriminator real providers and the loop's error path see.
74
+ */
75
+ export declare class FauxAbortError extends Error {
76
+ readonly name = "AbortError";
77
+ constructor(message?: string);
78
+ }
79
+ export declare class FauxProvider implements Provider {
80
+ readonly id: string;
81
+ private readonly script;
82
+ private cursor;
83
+ private readonly _toolsSupported;
84
+ private readonly _thinkingSupported;
85
+ /** Total number of times `stream()` has been called. */
86
+ callCount: number;
87
+ /** The `messages` argument from the most recent `stream()` call. */
88
+ lastMessages: Message[];
89
+ /** All `messages` arguments captured across every `stream()` call, in order. */
90
+ callHistory: Message[][];
91
+ constructor(script: FauxScriptStep[], opts?: FauxProviderOptions);
92
+ supportsTools(_modelId: string): boolean;
93
+ supportsThinking(_modelId: string): boolean;
94
+ /** Number of script steps not yet consumed. */
95
+ get remaining(): number;
96
+ /** Reset call counters and cursor. Useful between assertions in one test. */
97
+ reset(): void;
98
+ stream(req: StreamRequest): AsyncIterable<AgentEvent>;
99
+ }
@@ -0,0 +1,153 @@
1
+ /**
2
+ * FauxProvider — deterministic, in-process Provider for testing the agent loop.
3
+ *
4
+ * Implements the same `Provider` contract as real providers (anthropic.ts,
5
+ * openai.ts, etc.) but consumes a pre-baked script of step descriptors
6
+ * instead of talking to a network. Each call to `stream()` consumes the
7
+ * NEXT step from the script and emits the corresponding `AgentEvent`s.
8
+ *
9
+ * Use it to drive `runAgentLoop` end-to-end without any I/O.
10
+ *
11
+ * const provider = new FauxProvider([
12
+ * { kind: 'tool-call', id: 'c1', name: 'shell', input: { cmd: 'ls' } },
13
+ * { kind: 'text', chunks: ['done'] },
14
+ * ]);
15
+ *
16
+ * The provider also records `callCount` and `lastMessages` so tests can
17
+ * assert what the loop sent to the LLM (post-projection from AgentMessage[]).
18
+ */
19
+ /**
20
+ * Synchronous-throwing AbortError. Mirrors the shape Node/undici fetch
21
+ * rejects with when an AbortSignal fires mid-request — `.name === 'AbortError'`
22
+ * is the discriminator real providers and the loop's error path see.
23
+ */
24
+ export class FauxAbortError extends Error {
25
+ name = 'AbortError';
26
+ constructor(message = 'The operation was aborted') {
27
+ super(message);
28
+ }
29
+ }
30
+ export class FauxProvider {
31
+ id;
32
+ script;
33
+ cursor = 0;
34
+ _toolsSupported;
35
+ _thinkingSupported;
36
+ /** Total number of times `stream()` has been called. */
37
+ callCount = 0;
38
+ /** The `messages` argument from the most recent `stream()` call. */
39
+ lastMessages = [];
40
+ /** All `messages` arguments captured across every `stream()` call, in order. */
41
+ callHistory = [];
42
+ constructor(script, opts = {}) {
43
+ this.script = script;
44
+ this.id = opts.id ?? 'faux';
45
+ this._toolsSupported = opts.supportsTools ?? true;
46
+ this._thinkingSupported = opts.supportsThinking ?? false;
47
+ }
48
+ supportsTools(_modelId) {
49
+ return this._toolsSupported;
50
+ }
51
+ supportsThinking(_modelId) {
52
+ return this._thinkingSupported;
53
+ }
54
+ /** Number of script steps not yet consumed. */
55
+ get remaining() {
56
+ return this.script.length - this.cursor;
57
+ }
58
+ /** Reset call counters and cursor. Useful between assertions in one test. */
59
+ reset() {
60
+ this.cursor = 0;
61
+ this.callCount = 0;
62
+ this.lastMessages = [];
63
+ this.callHistory = [];
64
+ }
65
+ async *stream(req) {
66
+ // Capture the request BEFORE consuming the script so an exhausted-script
67
+ // throw still records the call (helps debugging in tests).
68
+ this.callCount += 1;
69
+ this.lastMessages = req.messages;
70
+ this.callHistory.push(req.messages);
71
+ if (this.cursor >= this.script.length) {
72
+ throw new Error('FauxProvider: script exhausted');
73
+ }
74
+ const step = this.script[this.cursor++];
75
+ switch (step.kind) {
76
+ case 'error':
77
+ // Real providers throw mid-fetch; FauxProvider throws on first
78
+ // iteration. The loop catches inside the `for await` either way.
79
+ throw step.error;
80
+ case 'abort': {
81
+ const ms = step.afterMs ?? 10;
82
+ await delay(ms);
83
+ if (req.signal?.aborted) {
84
+ // If the caller aborted us during the delay, surface that signal's
85
+ // reason instead of a synthetic one.
86
+ throw new FauxAbortError('Aborted by caller signal');
87
+ }
88
+ throw new FauxAbortError();
89
+ }
90
+ case 'wait':
91
+ await delay(step.ms);
92
+ return;
93
+ case 'text': {
94
+ yield { type: 'text_start' };
95
+ for (const chunk of step.chunks) {
96
+ if (req.signal?.aborted)
97
+ throw new FauxAbortError();
98
+ yield { type: 'text_delta', delta: chunk };
99
+ }
100
+ yield { type: 'text_end' };
101
+ if (step.usage) {
102
+ yield {
103
+ type: 'usage',
104
+ inputTokens: step.usage.inputTokens,
105
+ outputTokens: step.usage.outputTokens,
106
+ cachedTokens: step.usage.cachedTokens ?? 0,
107
+ };
108
+ }
109
+ return;
110
+ }
111
+ case 'tool-call': {
112
+ yield { type: 'toolcall_start', id: step.id, name: step.name };
113
+ const json = JSON.stringify(step.input ?? {});
114
+ yield { type: 'toolcall_delta', id: step.id, deltaJson: json };
115
+ yield { type: 'toolcall_end', id: step.id, input: step.input };
116
+ if (step.usage) {
117
+ yield {
118
+ type: 'usage',
119
+ inputTokens: step.usage.inputTokens,
120
+ outputTokens: step.usage.outputTokens,
121
+ cachedTokens: step.usage.cachedTokens ?? 0,
122
+ };
123
+ }
124
+ return;
125
+ }
126
+ case 'mixed': {
127
+ if (step.text && step.text.length > 0) {
128
+ yield { type: 'text_start' };
129
+ yield { type: 'text_delta', delta: step.text };
130
+ yield { type: 'text_end' };
131
+ }
132
+ for (const tc of step.toolCalls) {
133
+ yield { type: 'toolcall_start', id: tc.id, name: tc.name };
134
+ yield { type: 'toolcall_delta', id: tc.id, deltaJson: JSON.stringify(tc.input ?? {}) };
135
+ yield { type: 'toolcall_end', id: tc.id, input: tc.input };
136
+ }
137
+ if (step.usage) {
138
+ yield {
139
+ type: 'usage',
140
+ inputTokens: step.usage.inputTokens,
141
+ outputTokens: step.usage.outputTokens,
142
+ cachedTokens: step.usage.cachedTokens ?? 0,
143
+ };
144
+ }
145
+ return;
146
+ }
147
+ }
148
+ }
149
+ }
150
+ function delay(ms) {
151
+ return new Promise(resolve => setTimeout(resolve, ms));
152
+ }
153
+ //# sourceMappingURL=faux.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"faux.js","sourceRoot":"","sources":["../../src_v2/providers/faux.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AA2BH;;;;GAIG;AACH,MAAM,OAAO,cAAe,SAAQ,KAAK;IAC9B,IAAI,GAAG,YAAY,CAAC;IAC7B,YAAY,OAAO,GAAG,2BAA2B;QAC/C,KAAK,CAAC,OAAO,CAAC,CAAC;IACjB,CAAC;CACF;AAED,MAAM,OAAO,YAAY;IACd,EAAE,CAAS;IACH,MAAM,CAAmB;IAClC,MAAM,GAAG,CAAC,CAAC;IACF,eAAe,CAAU;IACzB,kBAAkB,CAAU;IAE7C,wDAAwD;IACxD,SAAS,GAAG,CAAC,CAAC;IACd,oEAAoE;IACpE,YAAY,GAAc,EAAE,CAAC;IAC7B,gFAAgF;IAChF,WAAW,GAAgB,EAAE,CAAC;IAE9B,YAAY,MAAwB,EAAE,OAA4B,EAAE;QAClE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,E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EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC,EAAE,CAAC;oBACvF,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC;gBAC7D,CAAC;gBACD,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;oBACf,MAAM;wBACJ,IAAI,EAAE,OAAO;wBACb,WAAW,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW;wBACnC,YAAY,EAAE,IAAI,CAAC,KAAK,CAAC,YAAY;wBACrC,YAAY,EAAE,IAAI,CAAC,KAAK,CAAC,YAAY,IAAI,CAAC;qBAC3C,CAAC;gBACJ,CAAC;gBACD,OAAO;YACT,CAAC;QACH,CAAC;IACH,CAAC;CACF;AAED,SAAS,KAAK,CAAC,EAAU;IACvB,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AACzD,CAAC"}
@@ -13,6 +13,7 @@ export { OpenAIProvider } from './openai.js';
13
13
  export { AnthropicProvider } from './anthropic.js';
14
14
  export { GeminiProvider } from './gemini.js';
15
15
  export { OllamaProvider } from './ollama.js';
16
+ export { LlamaCppProvider } from './llamacpp.js';
16
17
  export { FireworksProvider } from './fireworks.js';
17
18
  export interface ProviderRegistryConfig {
18
19
  nvidia?: ProviderConfig;
@@ -28,6 +29,7 @@ export interface ProviderRegistryConfig {
28
29
  };
29
30
  gemini?: ProviderConfig;
30
31
  ollama?: ProviderConfig;
32
+ llamacpp?: ProviderConfig;
31
33
  fireworks?: ProviderConfig;
32
34
  }
33
35
  export declare class ProviderRegistry {
@@ -11,6 +11,7 @@ import { OpenAIProvider } from './openai.js';
11
11
  import { AnthropicProvider } from './anthropic.js';
12
12
  import { GeminiProvider } from './gemini.js';
13
13
  import { OllamaProvider } from './ollama.js';
14
+ import { LlamaCppProvider } from './llamacpp.js';
14
15
  import { FireworksProvider } from './fireworks.js';
15
16
  export * from './iface.js';
16
17
  export * from './dispatch.js';
@@ -20,6 +21,7 @@ export { OpenAIProvider } from './openai.js';
20
21
  export { AnthropicProvider } from './anthropic.js';
21
22
  export { GeminiProvider } from './gemini.js';
22
23
  export { OllamaProvider } from './ollama.js';
24
+ export { LlamaCppProvider } from './llamacpp.js';
23
25
  export { FireworksProvider } from './fireworks.js';
24
26
  export class ProviderRegistry {
25
27
  config;
@@ -44,6 +46,7 @@ export class ProviderRegistry {
44
46
  case 'anthropic': return new AnthropicProvider(this.config.anthropic ?? {});
45
47
  case 'gemini': return new GeminiProvider(this.config.gemini ?? {});
46
48
  case 'ollama': return new OllamaProvider(this.config.ollama ?? {});
49
+ case 'llamacpp': return new LlamaCppProvider(this.config.llamacpp ?? {});
47
50
  case 'fireworks': return new FireworksProvider(this.config.fireworks ?? {});
48
51
  }
49
52
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src_v2/providers/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,UAAU,EAAmB,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,kBAAkB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C,CAAC;YAC5E,KAAK,QAAQ,CAAC,CAAC,OAAO,IAAI,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC;YACnE,KAAK,QAAQ,CAAC,CAAC,OAAO,IAAI,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC;YACnE,KAAK,UAAU,CAAC,CAAC,OAAO,IAAI,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC;YACzE,KAAK,WAAW,CAAC,CAAC,OAAO,IAAI,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC;QAC9E,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * llama.cpp provider — local model runtime via llama-server's
3
+ * OpenAI-compatible /v1/chat/completions endpoint. Default port 8080.
4
+ * Override with LLAMACPP_URL env var or config.baseUrl.
5
+ */
6
+ import type { AgentEvent } from '../kernel/types.js';
7
+ import type { Provider, StreamRequest, ProviderConfig } from './iface.js';
8
+ export declare class LlamaCppProvider implements Provider {
9
+ readonly id = "llamacpp";
10
+ private readonly baseUrl;
11
+ private readonly timeoutMs;
12
+ constructor(config: ProviderConfig);
13
+ supportsTools(_modelId: string): boolean;
14
+ supportsThinking(_modelId: string): boolean;
15
+ stream(req: StreamRequest): AsyncIterable<AgentEvent>;
16
+ }
@@ -0,0 +1,39 @@
1
+ /**
2
+ * llama.cpp provider — local model runtime via llama-server's
3
+ * OpenAI-compatible /v1/chat/completions endpoint. Default port 8080.
4
+ * Override with LLAMACPP_URL env var or config.baseUrl.
5
+ */
6
+ import { streamChatCompletions } from './openai-compat.js';
7
+ const DEFAULT_BASE = 'http://localhost:8080/v1';
8
+ export class LlamaCppProvider {
9
+ id = 'llamacpp';
10
+ baseUrl;
11
+ timeoutMs;
12
+ constructor(config) {
13
+ const envBase = process.env.LLAMACPP_URL;
14
+ this.baseUrl = (config.baseUrl ?? envBase ?? DEFAULT_BASE).replace(/\/+$/, '');
15
+ this.timeoutMs = config.timeoutMs ?? 120_000;
16
+ }
17
+ supportsTools(_modelId) {
18
+ return true;
19
+ }
20
+ supportsThinking(_modelId) {
21
+ return false;
22
+ }
23
+ stream(req) {
24
+ const model = req.model.replace(/^llamacpp\//, '');
25
+ return streamChatCompletions({
26
+ providerName: this.id,
27
+ endpoint: `${this.baseUrl}/chat/completions`,
28
+ apiKey: 'local',
29
+ model,
30
+ messages: req.messages,
31
+ tools: req.tools,
32
+ temperature: req.temperature,
33
+ maxTokens: req.maxTokens,
34
+ signal: req.signal,
35
+ timeoutMs: this.timeoutMs,
36
+ });
37
+ }
38
+ }
39
+ //# sourceMappingURL=llamacpp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"llamacpp.js","sourceRoot":"","sources":["../../src_v2/providers/llamacpp.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,MAAM,YAAY,GAAG,0BAA0B,CAAC;AAEhD,MAAM,OAAO,gBAAgB;IAClB,EAAE,GAAG,UAAU,CAAC;IACR,OAAO,CAAS;IAChB,SAAS,CAAS;IAEnC,YAAY,MAAsB;QAChC,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC;QACzC,IAAI,CAAC,OAAO,GAAG,CAAC,MAAM,CAAC,OAAO,IAAI,OAAO,IAAI,YAAY,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAC/E,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,IAAI,OAAO,CAAC;IAC/C,CAAC;IAED,aAAa,CAAC,QAAgB;QAC5B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,gBAAgB,CAAC,QAAgB;QAC/B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,CAAC,GAAkB;QACvB,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;QACnD,OAAO,qBAAqB,CAAC;YAC3B,YAAY,EAAE,IAAI,CAAC,EAAE;YACrB,QAAQ,EAAE,GAAG,IAAI,CAAC,OAAO,mBAAmB;YAC5C,MAAM,EAAE,OAAO;YACf,KAAK;YACL,QAAQ,EAAE,GAAG,CAAC,QAAQ;YACtB,KAAK,EAAE,GAAG,CAAC,KAAK;YAChB,WAAW,EAAE,GAAG,CAAC,WAAW;YAC5B,SAAS,EAAE,GAAG,CAAC,SAAS;YACxB,MAAM,EAAE,GAAG,CAAC,MAAM;YAClB,SAAS,EAAE,IAAI,CAAC,SAAS;SAC1B,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Hardware probe — Node built-ins only. Returns a typed profile that
3
+ * downstream model-recommendation code uses to filter the catalogue.
4
+ * GPU detection is best-effort: nvidia-smi if present, null otherwise.
5
+ */
6
+ export interface HardwareProfile {
7
+ cpuCores: number;
8
+ totalRamGB: number;
9
+ freeRamGB: number;
10
+ gpuName: string | null;
11
+ vramGB: number | null;
12
+ avx2: boolean;
13
+ platform: 'linux' | 'mac' | 'windows';
14
+ }
15
+ export declare function detectHardware(): Promise<HardwareProfile>;
16
+ export declare function summariseHardware(hw: HardwareProfile): string[];