@dirgha/code 1.42.14 → 1.43.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/interactive.js +1 -1
- package/dist/cli/interactive.js.map +1 -1
- package/dist/cli/main.js +18 -3
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/subcommands/ask.js +3 -3
- package/dist/cli/subcommands/ask.js.map +1 -1
- package/dist/cli/subcommands/index.js +1 -1
- package/dist/cli/subcommands/index.js.map +1 -1
- package/dist/cli/subcommands/verify.js +3 -3
- package/dist/cli/subcommands/verify.js.map +1 -1
- package/dist/intelligence/prices.js +4 -2
- package/dist/intelligence/prices.js.map +1 -1
- package/dist/kernel/agent-loop.d.ts +18 -0
- package/dist/kernel/agent-loop.js +84 -64
- package/dist/kernel/agent-loop.js.map +1 -1
- package/dist/orchestra/agent/dirgha.d.ts +21 -0
- package/dist/orchestra/agent/dirgha.js +36 -0
- package/dist/orchestra/agent/dirgha.js.map +1 -0
- package/dist/orchestra/agent/manager.d.ts +44 -0
- package/dist/orchestra/agent/manager.js +153 -0
- package/dist/orchestra/agent/manager.js.map +1 -0
- package/dist/orchestra/bin.d.ts +23 -0
- package/dist/orchestra/bin.js +225 -0
- package/dist/orchestra/bin.js.map +1 -0
- package/dist/orchestra/core/registry.d.ts +27 -0
- package/dist/orchestra/core/registry.js +100 -0
- package/dist/orchestra/core/registry.js.map +1 -0
- package/dist/orchestra/core/store.d.ts +15 -0
- package/dist/orchestra/core/store.js +44 -0
- package/dist/orchestra/core/store.js.map +1 -0
- package/dist/orchestra/core/types.d.ts +62 -0
- package/dist/orchestra/core/types.js +10 -0
- package/dist/orchestra/core/types.js.map +1 -0
- package/dist/orchestra/orchestration/log.d.ts +21 -0
- package/dist/orchestra/orchestration/log.js +68 -0
- package/dist/orchestra/orchestration/log.js.map +1 -0
- package/dist/providers/deepseek-catalogue.js +5 -3
- package/dist/providers/deepseek-catalogue.js.map +1 -1
- package/dist/subagents/delegator.d.ts +10 -1
- package/dist/subagents/delegator.js +28 -6
- package/dist/subagents/delegator.js.map +1 -1
- package/dist/tools/shell.js +21 -8
- package/dist/tools/shell.js.map +1 -1
- package/dist/tui/ink/App.js +70 -34
- package/dist/tui/ink/App.js.map +1 -1
- package/dist/tui/ink/components/InputBox.d.ts +2 -3
- package/dist/tui/ink/components/InputBox.js +46 -54
- package/dist/tui/ink/components/InputBox.js.map +1 -1
- package/dist/tui/ink/components/PasteCollapse.d.ts +2 -2
- package/dist/tui/ink/components/PasteCollapse.js +4 -2
- package/dist/tui/ink/components/PasteCollapse.js.map +1 -1
- package/dist/tui/ink/components/SubagentDashboard.d.ts +20 -0
- package/dist/tui/ink/components/SubagentDashboard.js +159 -0
- package/dist/tui/ink/components/SubagentDashboard.js.map +1 -0
- package/dist/tui/ink/components/VirtualTranscript.d.ts +6 -5
- package/dist/tui/ink/components/VirtualTranscript.js +12 -10
- package/dist/tui/ink/components/VirtualTranscript.js.map +1 -1
- package/dist/tui/ink/use-event-projection.js +32 -8
- package/dist/tui/ink/use-event-projection.js.map +1 -1
- package/dist/tui/ink/use-tool-progress.d.ts +1 -0
- package/dist/tui/ink/use-tool-progress.js +63 -23
- package/dist/tui/ink/use-tool-progress.js.map +1 -1
- package/dist/tui/ink/use-transcript-scroll.d.ts +14 -5
- package/dist/tui/ink/use-transcript-scroll.js +46 -28
- package/dist/tui/ink/use-transcript-scroll.js.map +1 -1
- package/package.json +3 -2
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* orchestra/core/types.ts — Types for the dirgha orchestra multi-agent system.
|
|
3
|
+
*
|
|
4
|
+
* An "orchestration" is a named collection of N agent subprocesses managed
|
|
5
|
+
* by the dirgha CLI itself. Each agent runs in its own subprocess
|
|
6
|
+
* (child_process.spawn), its stdout/stderr is piped into an Ink TUI pane.
|
|
7
|
+
* The parent process is the multiplexer — no tmux, no external window mgr.
|
|
8
|
+
*/
|
|
9
|
+
export interface AgentSlot {
|
|
10
|
+
/** Short unique id ("agent-1" or short uuid). */
|
|
11
|
+
id: string;
|
|
12
|
+
/** Human-readable label shown in the TUI pane border. */
|
|
13
|
+
label: string;
|
|
14
|
+
/** The task/prompt this agent was given. */
|
|
15
|
+
task: string;
|
|
16
|
+
/** Agent adapter kind. */
|
|
17
|
+
adapter: "dirgha" | "claude" | "codex" | "generic";
|
|
18
|
+
/** Child process PID (0 if not yet spawned). */
|
|
19
|
+
pid: number;
|
|
20
|
+
/** Current lifecycle status. */
|
|
21
|
+
status: AgentStatus;
|
|
22
|
+
/** Exit code (null while running). */
|
|
23
|
+
exitCode: number | null;
|
|
24
|
+
/** Spawn timestamp (epoch ms). */
|
|
25
|
+
startedAt: number;
|
|
26
|
+
/** Wall time in ms (set on exit). */
|
|
27
|
+
elapsedMs: number | null;
|
|
28
|
+
/** Model name reported by the agent, if known. */
|
|
29
|
+
model?: string;
|
|
30
|
+
/** Cost in USD, if tracked. */
|
|
31
|
+
cost?: number;
|
|
32
|
+
/** Token count, if tracked. */
|
|
33
|
+
tokens?: number;
|
|
34
|
+
/** Last N lines of output (ring buffer for TUI display). */
|
|
35
|
+
outputBuffer: string[];
|
|
36
|
+
/** Whether this agent accepts keyboard input. */
|
|
37
|
+
hasFocus: boolean;
|
|
38
|
+
}
|
|
39
|
+
export type AgentStatus = "pending" | "spawning" | "running" | "done" | "failed" | "killed";
|
|
40
|
+
export interface OrchestraSession {
|
|
41
|
+
/** Short unique id. */
|
|
42
|
+
id: string;
|
|
43
|
+
/** Human title. */
|
|
44
|
+
title: string;
|
|
45
|
+
/** All agent slots in this orchestration. */
|
|
46
|
+
agents: AgentSlot[];
|
|
47
|
+
/** Whether the TUI dashboard is active. */
|
|
48
|
+
active: boolean;
|
|
49
|
+
/** Creation timestamp (epoch ms). */
|
|
50
|
+
createdAt: number;
|
|
51
|
+
/** Last update timestamp (epoch ms). */
|
|
52
|
+
updatedAt: number;
|
|
53
|
+
}
|
|
54
|
+
export interface LogEntry {
|
|
55
|
+
timestamp: string;
|
|
56
|
+
sessionId: string;
|
|
57
|
+
agentId: string;
|
|
58
|
+
event: "spawn" | "output" | "exit" | "error" | "watcher" | "system";
|
|
59
|
+
payload: Record<string, unknown>;
|
|
60
|
+
}
|
|
61
|
+
/** Verb for the orchestra subcommand. */
|
|
62
|
+
export type OrchestraVerb = "up" | "attach" | "list" | "kill" | "down" | "log" | "web";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* orchestra/core/types.ts — Types for the dirgha orchestra multi-agent system.
|
|
3
|
+
*
|
|
4
|
+
* An "orchestration" is a named collection of N agent subprocesses managed
|
|
5
|
+
* by the dirgha CLI itself. Each agent runs in its own subprocess
|
|
6
|
+
* (child_process.spawn), its stdout/stderr is piped into an Ink TUI pane.
|
|
7
|
+
* The parent process is the multiplexer — no tmux, no external window mgr.
|
|
8
|
+
*/
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/orchestra/core/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* orchestra/orchestration/log.ts — Structured NDJSON orchestration log.
|
|
3
|
+
*
|
|
4
|
+
* Every agent event (spawn, output, exit, error, watcher) is written as
|
|
5
|
+
* a newline-delimited JSON line to /tmp/orchestra-{sessionId}.ndjson.
|
|
6
|
+
* This is the single source of truth for observability — the TUI reads
|
|
7
|
+
* this file for replay, the web bridge streams it, and the CLI tails it.
|
|
8
|
+
*/
|
|
9
|
+
import type { LogEntry } from "../core/types.js";
|
|
10
|
+
/** Return the log file path for a session. */
|
|
11
|
+
export declare function logPath(sessionId: string): string;
|
|
12
|
+
/** Create a fresh log file (overwrites any existing). */
|
|
13
|
+
export declare function createLog(sessionId: string): string;
|
|
14
|
+
/** Append a single log entry to the session log. */
|
|
15
|
+
export declare function appendLog(entry: LogEntry): void;
|
|
16
|
+
/** Convenience: build and write a structured entry in one call. */
|
|
17
|
+
export declare function writeLog(sessionId: string, agentId: string, event: LogEntry["event"], payload?: Record<string, unknown>): void;
|
|
18
|
+
/** Read all entries from a session log file. */
|
|
19
|
+
export declare function readLog(sessionId: string): LogEntry[];
|
|
20
|
+
/** Stream log entries matching a filter (returns latest N). */
|
|
21
|
+
export declare function tailLog(sessionId: string, n?: number, filter?: (e: LogEntry) => boolean): LogEntry[];
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* orchestra/orchestration/log.ts — Structured NDJSON orchestration log.
|
|
3
|
+
*
|
|
4
|
+
* Every agent event (spawn, output, exit, error, watcher) is written as
|
|
5
|
+
* a newline-delimited JSON line to /tmp/orchestra-{sessionId}.ndjson.
|
|
6
|
+
* This is the single source of truth for observability — the TUI reads
|
|
7
|
+
* this file for replay, the web bridge streams it, and the CLI tails it.
|
|
8
|
+
*/
|
|
9
|
+
import { appendFileSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
10
|
+
import { tmpdir } from "node:os";
|
|
11
|
+
import { join } from "node:path";
|
|
12
|
+
/** Return the log file path for a session. */
|
|
13
|
+
export function logPath(sessionId) {
|
|
14
|
+
return join(tmpdir(), `orchestra-${sessionId}.ndjson`);
|
|
15
|
+
}
|
|
16
|
+
/** Create a fresh log file (overwrites any existing). */
|
|
17
|
+
export function createLog(sessionId) {
|
|
18
|
+
const path = logPath(sessionId);
|
|
19
|
+
const dir = tmpdir();
|
|
20
|
+
if (!existsSync(dir))
|
|
21
|
+
mkdirSync(dir, { recursive: true });
|
|
22
|
+
writeFileSync(path, "", "utf-8");
|
|
23
|
+
return path;
|
|
24
|
+
}
|
|
25
|
+
/** Append a single log entry to the session log. */
|
|
26
|
+
export function appendLog(entry) {
|
|
27
|
+
try {
|
|
28
|
+
const path = logPath(entry.sessionId);
|
|
29
|
+
appendFileSync(path, JSON.stringify(entry) + "\n", "utf-8");
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
// Non-fatal — log writes must never crash the orchestrator.
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/** Convenience: build and write a structured entry in one call. */
|
|
36
|
+
export function writeLog(sessionId, agentId, event, payload = {}) {
|
|
37
|
+
appendLog({
|
|
38
|
+
timestamp: new Date().toISOString(),
|
|
39
|
+
sessionId,
|
|
40
|
+
agentId,
|
|
41
|
+
event,
|
|
42
|
+
payload,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
/** Read all entries from a session log file. */
|
|
46
|
+
export function readLog(sessionId) {
|
|
47
|
+
try {
|
|
48
|
+
const path = logPath(sessionId);
|
|
49
|
+
if (!existsSync(path))
|
|
50
|
+
return [];
|
|
51
|
+
const raw = readFileSync(path, "utf-8");
|
|
52
|
+
return raw
|
|
53
|
+
.trim()
|
|
54
|
+
.split("\n")
|
|
55
|
+
.filter(Boolean)
|
|
56
|
+
.map((line) => JSON.parse(line));
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return [];
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/** Stream log entries matching a filter (returns latest N). */
|
|
63
|
+
export function tailLog(sessionId, n = 50, filter) {
|
|
64
|
+
const all = readLog(sessionId);
|
|
65
|
+
const filtered = filter ? all.filter(filter) : all;
|
|
66
|
+
return filtered.slice(-n);
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=log.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.js","sourceRoot":"","sources":["../../../src/orchestra/orchestration/log.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7F,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAA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,EAAE,CAAC;QACjC,MAAM,GAAG,GAAG,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACxC,OAAO,GAAG;aACP,IAAI,EAAE;aACN,KAAK,CAAC,IAAI,CAAC;aACX,MAAM,CAAC,OAAO,CAAC;aACf,GAAG,CAAC,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAa,CAAC,CAAC;IACzD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC;AAED,+DAA+D;AAC/D,MAAM,UAAU,OAAO,CACrB,SAAiB,EACjB,IAAY,EAAE,EACd,MAAiC;IAEjC,MAAM,GAAG,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;IAC/B,MAAM,QAAQ,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;IACnD,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AAC5B,CAAC"}
|
|
@@ -52,9 +52,10 @@ export const DEEPSEEK_CATALOGUE = [
|
|
|
52
52
|
vision: false,
|
|
53
53
|
thinkingMode: 'opt-in',
|
|
54
54
|
thinkingParam: DEEPSEEK_THINKING_PARAM,
|
|
55
|
-
inputPerM: 0.
|
|
56
|
-
outputPerM:
|
|
57
|
-
cachedInputPerM: 0.
|
|
55
|
+
inputPerM: 0.43,
|
|
56
|
+
outputPerM: 0.87,
|
|
57
|
+
cachedInputPerM: 0.11,
|
|
58
|
+
notes: 'flagship v4 model; api.deepseek.com direct',
|
|
58
59
|
tags: ['agents'],
|
|
59
60
|
},
|
|
60
61
|
{
|
|
@@ -70,6 +71,7 @@ export const DEEPSEEK_CATALOGUE = [
|
|
|
70
71
|
inputPerM: 0.07,
|
|
71
72
|
outputPerM: 0.28,
|
|
72
73
|
cachedInputPerM: 0.02,
|
|
74
|
+
notes: 'fast v4 variant; api.deepseek.com direct',
|
|
73
75
|
tags: ['fast'],
|
|
74
76
|
},
|
|
75
77
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deepseek-catalogue.js","sourceRoot":"","sources":["../../src/providers/deepseek-catalogue.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEvE,MAAM,uBAAuB,GAAG,EAAE,oBAAoB,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAC;AAE7E,MAAM,CAAC,MAAM,kBAAkB,GAAsB;IACnD;QACE,EAAE,EAAE,eAAe;QACnB,KAAK,EAAE,oBAAoB;QAC3B,MAAM,EAAE,UAAU;QAClB,aAAa,EAAE,MAAM;QACrB,eAAe,EAAE,KAAK;QACtB,KAAK,EAAE,IAAI;QACX,MAAM,EAAE,KAAK;QACb,YAAY,EAAE,MAAM;QACpB,aAAa,EAAE,IAAI;QACnB,SAAS,EAAE,IAAI;QACf,UAAU,EAAE,IAAI;QAChB,eAAe,EAAE,IAAI;QACrB,YAAY,EAAE,IAAI;QAClB,KAAK,EAAE,2CAA2C;QAClD,IAAI,EAAE,CAAC,QAAQ,CAAC;KACjB;IACD;QACE,EAAE,EAAE,mBAAmB;QACvB,KAAK,EAAE,wBAAwB;QAC/B,MAAM,EAAE,UAAU;QAClB,aAAa,EAAE,MAAM;QACrB,eAAe,EAAE,MAAM;QACvB,KAAK,EAAE,IAAI;QACX,MAAM,EAAE,KAAK;QACb,YAAY,EAAE,WAAW;QACzB,aAAa,EAAE,IAAI;QACnB,SAAS,EAAE,IAAI;QACf,UAAU,EAAE,IAAI;QAChB,eAAe,EAAE,IAAI;QACrB,KAAK,EAAE,6CAA6C;QACpD,IAAI,EAAE,CAAC,WAAW,CAAC;KACpB;IACD;QACE,EAAE,EAAE,iBAAiB;QACrB,KAAK,EAAE,iBAAiB;QACxB,MAAM,EAAE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K,EAAE,mBAAmB;QAC1B,MAAM,EAAE,UAAU;QAClB,aAAa,EAAE,MAAM;QACrB,eAAe,EAAE,MAAM;QACvB,KAAK,EAAE,IAAI;QACX,MAAM,EAAE,KAAK;QACb,YAAY,EAAE,QAAQ;QACtB,aAAa,EAAE,uBAAuB;QACtC,SAAS,EAAE,IAAI;QACf,UAAU,EAAE,IAAI;QAChB,eAAe,EAAE,IAAI;QACrB,KAAK,EAAE,0CAA0C;QACjD,IAAI,EAAE,CAAC,MAAM,CAAC;KACf;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,SAAS,CAAC,kBAAkB,CAAC,CAAC;AAC5D,MAAM,CAAC,MAAM,gBAAgB,GAAG,YAAY,CAAC,kBAAkB,CAAC,CAAC;AACjE,MAAM,CAAC,MAAM,eAAe,GAAG,YAAY,CAAC,kBAAkB,CAAC,CAAC;AAEhE,mDAAmD;AACnD,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC"}
|
|
@@ -8,11 +8,15 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import type { Provider, UsageTotal, Message } from "../kernel/types.js";
|
|
10
10
|
import type { ToolRegistry } from "../tools/registry.js";
|
|
11
|
+
import type { ProviderRegistry } from "../providers/index.js";
|
|
11
12
|
/**
|
|
12
13
|
* Safe default tool allowlist for sub-agents. Covers read/write/search and
|
|
13
14
|
* common dev operations while excluding high-privilege tools (e.g. network
|
|
14
15
|
* requests, approval bypass, registry mutation). A parent agent can grant
|
|
15
16
|
* additional tools by supplying an explicit toolAllowlist on SubagentRequest.
|
|
17
|
+
*
|
|
18
|
+
* NOTE: these names MUST match the actual tool.name in the registry.
|
|
19
|
+
* See src/tools/registry.ts for the canonical list.
|
|
16
20
|
*/
|
|
17
21
|
export declare const DEFAULT_SUBAGENT_TOOLS: Set<string>;
|
|
18
22
|
export interface SubagentRequest {
|
|
@@ -32,7 +36,12 @@ export interface SubagentResult {
|
|
|
32
36
|
}
|
|
33
37
|
export interface DelegatorOptions {
|
|
34
38
|
registry: ToolRegistry;
|
|
35
|
-
provider
|
|
39
|
+
/** ProviderRegistry for model-aware routing. When set, `provider` is
|
|
40
|
+
* ignored and the provider is resolved via `providers.forModel()`. */
|
|
41
|
+
providers?: ProviderRegistry;
|
|
42
|
+
/** @deprecated use providers instead — kept for backward compat with
|
|
43
|
+
* callers that resolve a single Provider upfront (e.g. slash/spawn.ts). */
|
|
44
|
+
provider?: Provider;
|
|
36
45
|
defaultModel: string;
|
|
37
46
|
cwd: string;
|
|
38
47
|
parentSessionId: string;
|
|
@@ -18,11 +18,14 @@ import { createSessionStore } from "../context/session.js";
|
|
|
18
18
|
* common dev operations while excluding high-privilege tools (e.g. network
|
|
19
19
|
* requests, approval bypass, registry mutation). A parent agent can grant
|
|
20
20
|
* additional tools by supplying an explicit toolAllowlist on SubagentRequest.
|
|
21
|
+
*
|
|
22
|
+
* NOTE: these names MUST match the actual tool.name in the registry.
|
|
23
|
+
* See src/tools/registry.ts for the canonical list.
|
|
21
24
|
*/
|
|
22
25
|
export const DEFAULT_SUBAGENT_TOOLS = new Set([
|
|
23
|
-
'
|
|
24
|
-
'shell', 'browser', 'go_to_definition', 'find_references', '
|
|
25
|
-
'
|
|
26
|
+
'fs_read', 'fs_write', 'fs_edit', 'search_grep', 'search_glob',
|
|
27
|
+
'shell', 'browser', 'go_to_definition', 'find_references', 'hover_documentation',
|
|
28
|
+
'document_symbols', 'git', 'task', 'rtk',
|
|
26
29
|
]);
|
|
27
30
|
export class SubagentDelegator {
|
|
28
31
|
opts;
|
|
@@ -72,13 +75,20 @@ export class SubagentDelegator {
|
|
|
72
75
|
// Append the initial user prompt so the session has a recoverable prefix.
|
|
73
76
|
void subSession.append({ type: "message", ts: new Date().toISOString(), message: messages[messages.length - 1] });
|
|
74
77
|
const loopDetector = new LoopDetector();
|
|
78
|
+
// Resolve the provider for the requested model. When providers is given,
|
|
79
|
+
// route through the registry so different models reach different providers.
|
|
80
|
+
// Fall back to the deprecated single-provider field for backward compat.
|
|
81
|
+
const resolvedModel = req.model ?? this.opts.defaultModel;
|
|
82
|
+
const provider = this.opts.providers
|
|
83
|
+
? this.opts.providers.forModel(resolvedModel)
|
|
84
|
+
: this.opts.provider;
|
|
75
85
|
const result = await runAgentLoop({
|
|
76
86
|
sessionId,
|
|
77
|
-
model:
|
|
87
|
+
model: resolvedModel,
|
|
78
88
|
messages,
|
|
79
89
|
tools: sanitized.definitions,
|
|
80
90
|
maxTurns: req.maxTurns ?? 6,
|
|
81
|
-
provider
|
|
91
|
+
provider,
|
|
82
92
|
toolExecutor: executor,
|
|
83
93
|
events,
|
|
84
94
|
session: subSession,
|
|
@@ -92,8 +102,20 @@ export class SubagentDelegator {
|
|
|
92
102
|
const lastAssistant = [...result.messages]
|
|
93
103
|
.reverse()
|
|
94
104
|
.find((m) => m.role === "assistant");
|
|
105
|
+
// Include the raw error message when the loop errored with no output
|
|
106
|
+
let output = "";
|
|
107
|
+
if (lastAssistant) {
|
|
108
|
+
output = extractText(lastAssistant);
|
|
109
|
+
}
|
|
110
|
+
else if (result.stopReason === "error") {
|
|
111
|
+
// Try to extract an error message from the last user/tool messages
|
|
112
|
+
const lastMsg = result.messages[result.messages.length - 1];
|
|
113
|
+
output = lastMsg && lastMsg.role === "tool"
|
|
114
|
+
? `[sub-agent error] ${extractText(lastMsg).slice(0, 500)}`
|
|
115
|
+
: `[sub-agent error] loop stopped with reason: ${result.stopReason}`;
|
|
116
|
+
}
|
|
95
117
|
const returnValue = {
|
|
96
|
-
output
|
|
118
|
+
output,
|
|
97
119
|
usage: result.usage,
|
|
98
120
|
transcript: result.messages,
|
|
99
121
|
stopReason: result.stopReason,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delegator.js","sourceRoot":"","sources":["../../src/subagents/delegator.ts"],"names":[],"mappings":"AAAA;;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AAC,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,KAAK;oBAC9C,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC;gBACvB,WAAW,CAAC,IAAI,CAAC;oBACf,IAAI,EAAE,IAAI,CAAC,IAAI;oBACf,WAAW;oBACX,WAAW,EAAE,IAAI,CAAC,WAAW;iBAC9B,CAAC,CAAC;gBACH,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACzB,CAAC;YACD,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC;QAClC,CAAC;KACyB,CAAC;AAC/B,CAAC"}
|
package/dist/tools/shell.js
CHANGED
|
@@ -63,7 +63,7 @@ async function resolveWindowsShell() {
|
|
|
63
63
|
return windowsShellPromise;
|
|
64
64
|
}
|
|
65
65
|
const DEFAULT_TIMEOUT_MS = 120_000;
|
|
66
|
-
const MAX_OUTPUT_BYTES =
|
|
66
|
+
const MAX_OUTPUT_BYTES = 32 * 1024; // 32 KB — keeps 2 shell calls per context window
|
|
67
67
|
export const shellTool = {
|
|
68
68
|
name: "shell",
|
|
69
69
|
description: process.platform === "win32"
|
|
@@ -183,6 +183,7 @@ export const shellTool = {
|
|
|
183
183
|
cwd,
|
|
184
184
|
env: ctx.env,
|
|
185
185
|
stdio: ["pipe", "pipe", "pipe"],
|
|
186
|
+
detached: true, // own process group — kill(-pgid) reaches piped descendants
|
|
186
187
|
});
|
|
187
188
|
const childProcess = await (child instanceof Promise
|
|
188
189
|
? child
|
|
@@ -227,21 +228,33 @@ export const shellTool = {
|
|
|
227
228
|
childProcess.stderr.on("data", onData(stderrChunks, stderrDecoder, (n) => {
|
|
228
229
|
stderrBytes += n;
|
|
229
230
|
}, "STDERR"));
|
|
230
|
-
/**
|
|
231
|
-
|
|
232
|
-
|
|
231
|
+
/**
|
|
232
|
+
* Terminate the child. Kills the entire process group (via -pgid) so
|
|
233
|
+
* piped commands (sh -c "curl … | jq …") don't orphan descendants.
|
|
234
|
+
*
|
|
235
|
+
* Grace period: 250 ms on user abort (ESC feels instant), 2 s on
|
|
236
|
+
* timeout (child may be mid-network-call, needs a moment to flush).
|
|
237
|
+
*/
|
|
238
|
+
const killChild = (reason) => {
|
|
239
|
+
try {
|
|
240
|
+
process.kill(-childProcess.pid, "SIGTERM");
|
|
241
|
+
}
|
|
242
|
+
catch {
|
|
243
|
+
/* already gone */
|
|
244
|
+
}
|
|
245
|
+
const graceMs = reason === "abort" ? 250 : 2_000;
|
|
233
246
|
setTimeout(() => {
|
|
234
247
|
try {
|
|
235
|
-
|
|
248
|
+
process.kill(-childProcess.pid, "SIGKILL");
|
|
236
249
|
}
|
|
237
250
|
catch {
|
|
238
251
|
/* already gone */
|
|
239
252
|
}
|
|
240
|
-
},
|
|
253
|
+
}, graceMs);
|
|
241
254
|
};
|
|
242
|
-
const timer = setTimeout(killChild, timeoutMs);
|
|
255
|
+
const timer = setTimeout(() => killChild("timeout"), timeoutMs);
|
|
243
256
|
const onAbort = () => {
|
|
244
|
-
killChild();
|
|
257
|
+
killChild("abort");
|
|
245
258
|
};
|
|
246
259
|
if (ctx.signal) {
|
|
247
260
|
ctx.signal.addEventListener("abort", onAbort, { once: true });
|
package/dist/tools/shell.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shell.js","sourceRoot":"","sources":["../../src/tools/shell.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAItC,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAU1C,0EAA0E;AAC1E,IAAI,kBAAkB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qBAAqB,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;QAC3E,MAAM,IAAI,GAAG;YACX,MAAM;YACN,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,YAAY,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE;YAC7C,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,YAAY,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE;SAC9C;aACE,MAAM,CAAC,OAAO,CAAC;aACf,IAAI,CAAC,MAAM,CAAC,CAAC;QAEhB,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM;YACxC,IAAI,EAAE,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE;YACvD,OAAO,EAAE,QAAQ,KAAK,CAAC;SACxB,CAAC;IACJ,CAAC;CACF,CAAC"}
|
package/dist/tui/ink/App.js
CHANGED
|
@@ -45,6 +45,7 @@ import { InputBox } from "./components/InputBox.js";
|
|
|
45
45
|
import { PromptQueueIndicator } from "./components/PromptQueueIndicator.js";
|
|
46
46
|
// TaskIndicator removed from persistent UI — stale cross-session tasks cluttered bootup
|
|
47
47
|
import { SubagentPanel } from "./components/SubagentPanel.js";
|
|
48
|
+
import { SubagentDashboard } from "./components/SubagentDashboard.js";
|
|
48
49
|
import { GPUJobIndicator } from "./components/GPUJobIndicator.js";
|
|
49
50
|
import { ModelPicker } from "./components/ModelPicker.js";
|
|
50
51
|
import { ModelSwitchPrompt } from "./components/ModelSwitchPrompt.js";
|
|
@@ -73,6 +74,7 @@ import { useToolProgress } from "./use-tool-progress.js";
|
|
|
73
74
|
import { useDeclinedVersions } from "./use-declined-versions.js";
|
|
74
75
|
import { useStartupHealth } from "./use-startup-health.js";
|
|
75
76
|
import { useFlickerDetector } from "./use-flicker-detector.js";
|
|
77
|
+
import { useTranscriptScroll } from "./use-transcript-scroll.js";
|
|
76
78
|
import { useRenderMetrics, } from "./use-render-metrics.js";
|
|
77
79
|
import { getRemoteConfig, isVersionBelowMin, } from "../../intelligence/remote-config.js";
|
|
78
80
|
import { createRequire } from "node:module";
|
|
@@ -296,25 +298,27 @@ export function App(props) {
|
|
|
296
298
|
// Flicker detector — compares estimated tree height to terminal rows.
|
|
297
299
|
const estimatedLineCount = (transcript.length + projection.liveItems.length) * 2 + 15;
|
|
298
300
|
const flicker = useFlickerDetector(estimatedLineCount);
|
|
299
|
-
//
|
|
300
|
-
//
|
|
301
|
-
//
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
//
|
|
310
|
-
|
|
311
|
-
const
|
|
312
|
-
const
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
301
|
+
// Hoisted early: input is focused when no overlays (except @-file / slash
|
|
302
|
+
// completions) are open and no pending approval/key prompts are showing.
|
|
303
|
+
// Defined here so useTranscriptScroll below can reference it.
|
|
304
|
+
const scrInputFocus = pendingKey === null &&
|
|
305
|
+
pendingApproval === null &&
|
|
306
|
+
(overlays.active === null ||
|
|
307
|
+
overlays.active === "atfile" ||
|
|
308
|
+
overlays.active === "slash");
|
|
309
|
+
// Transcript scroll state — pinned-absolute-index virtual scrolling.
|
|
310
|
+
// Uses terminal rows to determine the visible window size. Auto-scrolls
|
|
311
|
+
// to follow new content only when the user is at the bottom.
|
|
312
|
+
const { stdout: scrStdout } = useStdout();
|
|
313
|
+
const _termRows = scrStdout?.rows ?? 24;
|
|
314
|
+
const visibleCount = Math.max(4, Math.floor((_termRows - 6) / 1.5));
|
|
315
|
+
const scroll = useTranscriptScroll(projection.liveItems.length, visibleCount, true, // autoScroll — follow live tail when user has not scrolled up
|
|
316
|
+
scrInputFocus);
|
|
317
|
+
// Visible window into live items based on scroll position.
|
|
318
|
+
// pinnedEndIdx is the absolute end index; we take up to `visibleCount`
|
|
319
|
+
// items ending at that position.
|
|
320
|
+
const scrollStart = Math.max(0, scroll.pinnedEndIdx - visibleCount);
|
|
321
|
+
const _visibleLiveItems = projection.liveItems.slice(scrollStart, scroll.pinnedEndIdx);
|
|
318
322
|
// Render performance metrics — track frame timing, expose for StatusBar.
|
|
319
323
|
const renderMetrics = useRenderMetrics();
|
|
320
324
|
const [showRenderMetrics, setShowRenderMetrics] = React.useState(false);
|
|
@@ -337,7 +341,7 @@ export function App(props) {
|
|
|
337
341
|
const ema = frameEmaRef.current;
|
|
338
342
|
const floor = minFlushMs();
|
|
339
343
|
if (ema > floor * 1.5) {
|
|
340
|
-
adaptiveFlushRef.current.floorMs = Math.min(ema * 1.2,
|
|
344
|
+
adaptiveFlushRef.current.floorMs = Math.min(ema * 1.2, 200);
|
|
341
345
|
}
|
|
342
346
|
else if (ema < floor * 0.8) {
|
|
343
347
|
const current = adaptiveFlushRef.current.floorMs;
|
|
@@ -1058,6 +1062,20 @@ export function App(props) {
|
|
|
1058
1062
|
abortRef.current.abort();
|
|
1059
1063
|
}
|
|
1060
1064
|
});
|
|
1065
|
+
// End key scrolls transcript back to the live tail (shows latest items).
|
|
1066
|
+
// When input is focused, require Ctrl+End to avoid interfering with
|
|
1067
|
+
// text insertion/IME. Uses a ref to keep the key-holding callback stable
|
|
1068
|
+
// across renders (avoids Ink's useInput re-registration churn).
|
|
1069
|
+
const scrollRef = React.useRef(scroll);
|
|
1070
|
+
scrollRef.current = scroll;
|
|
1071
|
+
useInput((_ch, key) => {
|
|
1072
|
+
if (!key.end)
|
|
1073
|
+
return;
|
|
1074
|
+
// With focused input only intercept Ctrl+End; unfocused accepts plain End.
|
|
1075
|
+
if (scrInputFocus && !key.ctrl)
|
|
1076
|
+
return;
|
|
1077
|
+
scrollRef.current.scrollToBottom();
|
|
1078
|
+
});
|
|
1061
1079
|
const handleModelPick = React.useCallback((id) => {
|
|
1062
1080
|
overlays.closeOverlay();
|
|
1063
1081
|
// Dedupe: a stale picker callback firing after the model is already
|
|
@@ -1188,11 +1206,7 @@ export function App(props) {
|
|
|
1188
1206
|
setTimeout(() => handleSubmit(spliced || `/${name}`), 0);
|
|
1189
1207
|
}
|
|
1190
1208
|
}, [overlays, ARGLESS_SLASH, handleSubmit]);
|
|
1191
|
-
const inputFocus =
|
|
1192
|
-
pendingApproval === null &&
|
|
1193
|
-
(overlays.active === null ||
|
|
1194
|
-
overlays.active === "atfile" ||
|
|
1195
|
-
overlays.active === "slash");
|
|
1209
|
+
const inputFocus = scrInputFocus;
|
|
1196
1210
|
// Active theme name — driven by local state so the picker can flip it
|
|
1197
1211
|
// live. Initial value comes from config; subsequent changes are
|
|
1198
1212
|
// persisted to ~/.dirgha/config.json so future sessions pick it up.
|
|
@@ -1245,7 +1259,7 @@ export function App(props) {
|
|
|
1245
1259
|
}
|
|
1246
1260
|
})();
|
|
1247
1261
|
}, [overlays]);
|
|
1248
|
-
const liveJsx = React.useMemo(() => (_jsxs(_Fragment, { children: [
|
|
1262
|
+
const liveJsx = React.useMemo(() => (_jsxs(_Fragment, { children: [scroll.belowCount > 0 && (_jsx(Box, { paddingX: 1, children: _jsxs(Text, { color: "gray", italic: true, children: ["[\u2193 ", scroll.belowCount, " more item", scroll.belowCount === 1 ? "" : "s", " below \u2014 scroll down]"] }) })), renderTranscript(_visibleLiveItems, thinkingStreaming)] })), [_visibleLiveItems, thinkingStreaming, scroll.belowCount]);
|
|
1249
1263
|
const providerEntries = React.useMemo(() => buildProviderEntries(models, currentModel), [models, currentModel]);
|
|
1250
1264
|
const spinnerCtx = React.useMemo(() => ({ busy }), [busy]);
|
|
1251
1265
|
const renderTranscriptItem = React.useCallback((item) => _jsx(TranscriptRow, { item: item }, item.id), []);
|
|
@@ -1318,7 +1332,7 @@ export function App(props) {
|
|
|
1318
1332
|
// the logo) on every overflow redraw, repainting it on every chat
|
|
1319
1333
|
// turn that fills the screen. `use-flicker-detector` already warns
|
|
1320
1334
|
// when this is about to happen.
|
|
1321
|
-
return (_jsx(ThemeProvider, { activeTheme: themeName, children: _jsx(SpinnerContext.Provider, { value: spinnerCtx, children: _jsxs(Box, { flexDirection: "column", children: [_jsx(Static, { items: transcript, children: (item) => (_jsx(Box, { flexDirection: "column", children: renderTranscriptItem(item) }, item.id)) }), _jsx(Box, { flexDirection: "column", flexGrow: 1, children: liveJsx }), busy &&
|
|
1335
|
+
return (_jsx(ThemeProvider, { activeTheme: themeName, children: _jsx(SpinnerContext.Provider, { value: spinnerCtx, children: _jsxs(Box, { flexDirection: "column", children: [_jsx(Static, { items: transcript, children: (item) => (_jsx(Box, { flexDirection: "column", children: renderTranscriptItem(item) }, item.id)) }), _jsx(Box, { flexDirection: "column", flexGrow: 1, children: liveJsx }), busy && (_jsx(ActivityIndicator, { activeTools: activeTools, liveOutputTokens: liveOutputTokens, liveDurationMs: liveDurationMs, hasLiveItems: projection.liveItems.length > 0 })), pendingApproval !== null && approvalBusRef.current && (_jsx(ApprovalPrompt, { request: pendingApproval, onResolve: onResolveApproval })), pendingFailover !== null && (_jsx(ModelSwitchPrompt, { failedModel: pendingFailover.failedModel, failoverModel: pendingFailover.failoverModel, onAccept: onAcceptFailover, onReject: onRejectFailover, onPicker: onPickerFailover })), _jsx(SubagentPanel, { events: props.events }), _jsx(SubagentDashboard, { events: props.events }), _jsx(GPUJobIndicator, {}), _jsx(PromptQueueIndicator, { queued: promptQueue }), _jsx(Divider, {}), _jsx(InputBox, { value: input, onChange: setInput, onSubmit: handleSubmit, vimMode: props.config.vimMode === true, onAtQueryChange: overlays.setAtQuery, onSlashQueryChange: overlays.setSlashQuery, onRequestOverlay: overlays.openOverlay, promptHistory: promptHistory, onRequestYoloToggle: () => {
|
|
1322
1336
|
const next = mode === "yolo" ? "act" : "yolo";
|
|
1323
1337
|
setMode(next);
|
|
1324
1338
|
// Wire the approval bus so mid-turn tool calls are immediately
|
|
@@ -1483,14 +1497,36 @@ function TranscriptRow({ item, isStreaming = false, }) {
|
|
|
1483
1497
|
return (_jsx(Box, { marginBottom: 1, children: _jsx(Text, { color: "yellow", children: item.text }) }));
|
|
1484
1498
|
}
|
|
1485
1499
|
}
|
|
1486
|
-
|
|
1500
|
+
/**
|
|
1501
|
+
* ActivityIndicator — verb-based status line above the Divider.
|
|
1502
|
+
*
|
|
1503
|
+
* Shows what the agent is doing right now in a single line, following
|
|
1504
|
+
* the Claude Code pattern (Thinking…, Reading file…, Running shell…).
|
|
1505
|
+
*
|
|
1506
|
+
* States:
|
|
1507
|
+
* - Warming up (busy, no output, no tools) → "Thinking… · 8s"
|
|
1508
|
+
* - Streaming text (liveItems, no tools) → "Generating… · 12s"
|
|
1509
|
+
* - Tool running (active tools) → "Running {tool}… · 15s · esc cancel"
|
|
1510
|
+
*/
|
|
1511
|
+
function ActivityIndicator(props) {
|
|
1487
1512
|
const palette = useTheme();
|
|
1488
|
-
const elapsedSec = Math.round(props.
|
|
1489
|
-
const
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1513
|
+
const elapsedSec = Math.round(props.liveDurationMs / 1000);
|
|
1514
|
+
const elapsedLabel = elapsedSec < 60
|
|
1515
|
+
? `${elapsedSec}s`
|
|
1516
|
+
: `${Math.floor(elapsedSec / 60)}m ${elapsedSec % 60}s`;
|
|
1517
|
+
let verb = "Thinking…";
|
|
1518
|
+
if (props.activeTools.length > 0) {
|
|
1519
|
+
const t = props.activeTools[0];
|
|
1520
|
+
verb = `Running ${t.name}…`;
|
|
1521
|
+
}
|
|
1522
|
+
else if (props.hasLiveItems) {
|
|
1523
|
+
verb = "Generating…";
|
|
1524
|
+
}
|
|
1525
|
+
else if (elapsedSec >= 5 && props.liveOutputTokens === 0) {
|
|
1526
|
+
verb = "Warming up…";
|
|
1527
|
+
}
|
|
1528
|
+
const escHint = props.activeTools.length > 0 ? " · esc cancel" : "";
|
|
1529
|
+
return (_jsxs(Box, { gap: 1, marginBottom: 1, children: [(props.activeTools.length > 0 || (!props.hasLiveItems && props.liveOutputTokens === 0)) && (_jsx(SpinnerGlyph, { isActive: true, color: palette.text.secondary })), _jsxs(Text, { color: palette.text.secondary, dimColor: true, children: [verb, " \u00B7 ", elapsedLabel, escHint] })] }));
|
|
1494
1530
|
}
|
|
1495
1531
|
function initialHistory(props) {
|
|
1496
1532
|
if (_cachedInitialMessages !== null)
|