echo-cli-agent 0.1.7 → 0.1.9
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 +11 -2
- package/dist/src/dispatch/dispatcher.d.ts +19 -3
- package/dist/src/dispatch/dispatcher.js +98 -4
- package/dist/src/dispatch/dispatcher.js.map +1 -1
- package/dist/src/health/server.d.ts +5 -1
- package/dist/src/health/server.js +8 -1
- package/dist/src/health/server.js.map +1 -1
- package/dist/src/index.js +8 -3
- package/dist/src/index.js.map +1 -1
- package/dist/src/providers/codex.js +25 -0
- package/dist/src/providers/codex.js.map +1 -1
- package/dist/src/providers/detection.d.ts +11 -0
- package/dist/src/providers/detection.js +96 -0
- package/dist/src/providers/detection.js.map +1 -0
- package/dist/src/providers/registry.d.ts +23 -0
- package/dist/src/providers/registry.js +59 -29
- package/dist/src/providers/registry.js.map +1 -1
- package/dist/src/runtime/agent-runtime.js +22 -10
- package/dist/src/runtime/agent-runtime.js.map +1 -1
- package/dist/src/session/session-manager.d.ts +41 -2
- package/dist/src/session/session-manager.js +178 -34
- package/dist/src/session/session-manager.js.map +1 -1
- package/dist/src/session/terminal-line-sanitizer.d.ts +7 -0
- package/dist/src/session/terminal-line-sanitizer.js +21 -0
- package/dist/src/session/terminal-line-sanitizer.js.map +1 -0
- package/dist/src/session/terminal-tail-buffer.d.ts +70 -0
- package/dist/src/session/terminal-tail-buffer.js +149 -0
- package/dist/src/session/terminal-tail-buffer.js.map +1 -0
- package/dist/src/shared/cli-detection-types.d.ts +19 -0
- package/dist/src/shared/cli-detection-types.js +2 -0
- package/dist/src/shared/cli-detection-types.js.map +1 -0
- package/dist/src/shared/node-cli-command-resolution.d.ts +8 -0
- package/dist/src/shared/node-cli-command-resolution.js +11 -1
- package/dist/src/shared/node-cli-command-resolution.js.map +1 -1
- package/dist/src/transport/taskmcp-client.d.ts +3 -1
- package/dist/src/transport/taskmcp-client.js +4 -0
- package/dist/src/transport/taskmcp-client.js.map +1 -1
- package/dist/src/types/protocol.d.ts +53 -1
- package/dist/src/types/protocol.js +33 -1
- package/dist/src/types/protocol.js.map +1 -1
- package/dist/tests/cli-detection.test.d.ts +1 -0
- package/dist/tests/cli-detection.test.js +62 -0
- package/dist/tests/cli-detection.test.js.map +1 -0
- package/dist/tests/providers.test.js +1 -0
- package/dist/tests/providers.test.js.map +1 -1
- package/dist/tests/session-manager.test.d.ts +1 -0
- package/dist/tests/session-manager.test.js +115 -0
- package/dist/tests/session-manager.test.js.map +1 -0
- package/dist/tests/terminal-tail-buffer.test.d.ts +1 -0
- package/dist/tests/terminal-tail-buffer.test.js +68 -0
- package/dist/tests/terminal-tail-buffer.test.js.map +1 -0
- package/package.json +1 -1
- package/scripts/service.mjs +25 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
import { hydrateShellPath, mergePathSegments } from '../runtime/cli/hydrate-shell-path.js';
|
|
3
|
+
import { getProviderDetectionProbeCommands, PROVIDER_CONFIGS, resolveDetectedProviderCommands } from './registry.js';
|
|
4
|
+
import { resolveCliCommandDetailed } from '../shared/node-cli-command-resolution.js';
|
|
5
|
+
function probeVersion(path, args) {
|
|
6
|
+
if (args.length === 0)
|
|
7
|
+
return Promise.resolve({});
|
|
8
|
+
return new Promise((resolve) => {
|
|
9
|
+
const child = spawn(path, [...args], { stdio: ['ignore', 'pipe', 'pipe'], shell: false });
|
|
10
|
+
let stdout = '';
|
|
11
|
+
let stderr = '';
|
|
12
|
+
let settled = false;
|
|
13
|
+
let timer;
|
|
14
|
+
const finish = (result) => {
|
|
15
|
+
if (settled)
|
|
16
|
+
return;
|
|
17
|
+
settled = true;
|
|
18
|
+
if (timer)
|
|
19
|
+
clearTimeout(timer);
|
|
20
|
+
resolve(result);
|
|
21
|
+
};
|
|
22
|
+
timer = setTimeout(() => {
|
|
23
|
+
child.kill('SIGKILL');
|
|
24
|
+
finish({ detail: 'version probe timeout' });
|
|
25
|
+
}, 5_000);
|
|
26
|
+
child.stdout.on('data', (chunk) => { stdout += chunk.toString(); });
|
|
27
|
+
child.stderr.on('data', (chunk) => { stderr += chunk.toString(); });
|
|
28
|
+
child.on('error', (error) => finish({ detail: error.message }));
|
|
29
|
+
child.on('close', (code) => {
|
|
30
|
+
const detail = (stdout || stderr || `exit ${code ?? 'unknown'}`).trim().slice(0, 200);
|
|
31
|
+
const version = stdout.split(/\r?\n/).map((line) => line.trim()).find(Boolean);
|
|
32
|
+
finish(version ? { version, detail } : { detail });
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
export class CliDetectionService {
|
|
37
|
+
snapshot;
|
|
38
|
+
pending;
|
|
39
|
+
async detect(forceRefresh = false) {
|
|
40
|
+
if (this.pending)
|
|
41
|
+
return this.pending;
|
|
42
|
+
if (!forceRefresh && this.snapshot)
|
|
43
|
+
return this.snapshot;
|
|
44
|
+
this.pending = this.detectNow(forceRefresh).finally(() => {
|
|
45
|
+
this.pending = undefined;
|
|
46
|
+
});
|
|
47
|
+
return this.pending;
|
|
48
|
+
}
|
|
49
|
+
async detectNow(forceRefresh) {
|
|
50
|
+
const hydration = await hydrateShellPath({ force: forceRefresh });
|
|
51
|
+
const addedPathSegments = hydration.ok ? mergePathSegments(hydration.segments) : [];
|
|
52
|
+
const commands = getProviderDetectionProbeCommands();
|
|
53
|
+
const resolved = new Map(commands.map((command) => [command, resolveCliCommandDetailed(command)]));
|
|
54
|
+
const foundCommands = new Set(commands.filter((command) => resolved.get(command)?.found));
|
|
55
|
+
const detected = resolveDetectedProviderCommands(foundCommands);
|
|
56
|
+
const providers = await Promise.all(PROVIDER_CONFIGS.map(async (config) => {
|
|
57
|
+
const matchedDetectionCommand = detected.get(config.id);
|
|
58
|
+
const result = matchedDetectionCommand ? resolved.get(matchedDetectionCommand) : undefined;
|
|
59
|
+
const executablePath = result?.found ? result.path : undefined;
|
|
60
|
+
const installed = Boolean(executablePath);
|
|
61
|
+
const unsupported = config.detectUnsupportedRuntimes?.includes(process.platform) ?? false;
|
|
62
|
+
const diagnostic = executablePath ? await probeVersion(executablePath, config.versionArguments ?? []) : {};
|
|
63
|
+
const detail = installed
|
|
64
|
+
? diagnostic.detail
|
|
65
|
+
: unsupported
|
|
66
|
+
? 'unsupported runtime'
|
|
67
|
+
: config.detectRequiredCommands?.length
|
|
68
|
+
? 'command or required command not found'
|
|
69
|
+
: 'command not found';
|
|
70
|
+
return {
|
|
71
|
+
id: config.id,
|
|
72
|
+
installed,
|
|
73
|
+
available: installed,
|
|
74
|
+
...(matchedDetectionCommand ? { matchedDetectionCommand } : {}),
|
|
75
|
+
...(result?.path ? { resolvedPath: result.path } : {}),
|
|
76
|
+
...(diagnostic.version ? { version: diagnostic.version } : {}),
|
|
77
|
+
...(detail ? { detail } : {})
|
|
78
|
+
};
|
|
79
|
+
}));
|
|
80
|
+
this.snapshot = {
|
|
81
|
+
providers,
|
|
82
|
+
detectedIds: providers.filter((provider) => provider.installed).map((provider) => provider.id),
|
|
83
|
+
addedPathSegments,
|
|
84
|
+
shellHydrationOk: hydration.ok,
|
|
85
|
+
pathSource: hydration.ok ? 'shell_hydrated' : 'process_path',
|
|
86
|
+
pathFailureReason: hydration.failureReason,
|
|
87
|
+
refreshedAt: new Date().toISOString()
|
|
88
|
+
};
|
|
89
|
+
return this.snapshot;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
export const cliDetection = new CliDetectionService();
|
|
93
|
+
export function providerCapabilityIds(snapshot) {
|
|
94
|
+
return snapshot.detectedIds;
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=detection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detection.js","sourceRoot":"","sources":["../../../src/providers/detection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC1C,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAA;AAC1F,OAAO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G,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC9F,iBAAiB;YACjB,gBAAgB,EAAE,SAAS,CAAC,EAAE;YAC9B,UAAU,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,cAAc;YAC5D,iBAAiB,EAAE,SAAS,CAAC,aAAa;YAC1C,WAAW,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SACtC,CAAA;QACD,OAAO,IAAI,CAAC,QAAQ,CAAA;IACtB,CAAC;CACF;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,mBAAmB,EAAE,CAAA;AAErD,MAAM,UAAU,qBAAqB,CAAC,QAA8B;IAClE,OAAO,QAAQ,CAAC,WAAW,CAAA;AAC7B,CAAC"}
|
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
import type { AgentProvider } from './provider.js';
|
|
2
|
+
export type ProviderRuntime = NodeJS.Platform | 'wsl';
|
|
3
|
+
export type ProviderConfig = {
|
|
4
|
+
id: string;
|
|
5
|
+
aliases: readonly string[];
|
|
6
|
+
detectCmd: string;
|
|
7
|
+
detectCmdAliases?: readonly string[];
|
|
8
|
+
detectRequiredCommands?: readonly string[];
|
|
9
|
+
detectUnsupportedRuntimes?: readonly ProviderRuntime[];
|
|
10
|
+
implementation: AgentProvider;
|
|
11
|
+
versionArguments?: readonly string[];
|
|
12
|
+
};
|
|
13
|
+
export declare const PROVIDER_CONFIGS: readonly ProviderConfig[];
|
|
14
|
+
export type ProviderDetectionCommand = {
|
|
15
|
+
id: string;
|
|
16
|
+
cmd: string;
|
|
17
|
+
requiredCommands?: readonly string[];
|
|
18
|
+
unsupportedRuntimes?: readonly ProviderRuntime[];
|
|
19
|
+
};
|
|
20
|
+
export declare const PROVIDER_DETECTION_COMMANDS: ProviderDetectionCommand[];
|
|
21
|
+
export declare function providerConfig(idOrAlias: string): ProviderConfig;
|
|
22
|
+
export declare function buildProviderDetectionCommands(configs: readonly ProviderConfig[]): ProviderDetectionCommand[];
|
|
23
|
+
export declare function getProviderDetectionProbeCommands(commands?: readonly ProviderDetectionCommand[], runtime?: ProviderRuntime): string[];
|
|
24
|
+
export declare function resolveDetectedProviderCommands(foundCommands: ReadonlySet<string>, commands?: readonly ProviderDetectionCommand[], runtime?: ProviderRuntime): Map<string, string>;
|
|
2
25
|
export declare function resolveProvider(agentType: string): AgentProvider;
|
|
3
26
|
export declare function probeProviders(): Array<{
|
|
4
27
|
id: string;
|
|
@@ -1,14 +1,52 @@
|
|
|
1
|
-
import { spawnSync } from 'node:child_process';
|
|
2
1
|
import { claudeProvider } from './claude.js';
|
|
3
2
|
import { codexProvider } from './codex.js';
|
|
4
3
|
import { kiroProvider } from './kiro.js';
|
|
5
|
-
import {
|
|
6
|
-
const
|
|
7
|
-
['claude', claudeProvider],
|
|
8
|
-
['
|
|
9
|
-
['
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
import { resolveCliCommandDetailed } from '../shared/node-cli-command-resolution.js';
|
|
5
|
+
export const PROVIDER_CONFIGS = [
|
|
6
|
+
{ id: 'claude', aliases: ['claude-code'], detectCmd: 'claude', implementation: claudeProvider, versionArguments: ['--version'] },
|
|
7
|
+
{ id: 'codex', aliases: [], detectCmd: 'codex', implementation: codexProvider, versionArguments: ['--version'] },
|
|
8
|
+
{ id: 'kiro', aliases: ['kiro-cli'], detectCmd: 'kiro-cli', implementation: kiroProvider, versionArguments: ['--version'] }
|
|
9
|
+
];
|
|
10
|
+
export const PROVIDER_DETECTION_COMMANDS = buildProviderDetectionCommands(PROVIDER_CONFIGS);
|
|
11
|
+
const providers = new Map(PROVIDER_CONFIGS.flatMap((config) => [config.id, ...config.aliases].map((alias) => [alias, config.implementation])));
|
|
12
|
+
export function providerConfig(idOrAlias) {
|
|
13
|
+
const normalized = idOrAlias.trim().toLowerCase();
|
|
14
|
+
const config = PROVIDER_CONFIGS.find((item) => item.id === normalized || item.aliases.includes(normalized));
|
|
15
|
+
if (!config)
|
|
16
|
+
throw new Error(`unsupported agent type: ${idOrAlias}`);
|
|
17
|
+
return config;
|
|
18
|
+
}
|
|
19
|
+
export function buildProviderDetectionCommands(configs) {
|
|
20
|
+
return configs.flatMap((config) => [config.detectCmd, ...(config.detectCmdAliases ?? [])].map((cmd) => ({
|
|
21
|
+
id: config.id,
|
|
22
|
+
cmd,
|
|
23
|
+
...(config.detectRequiredCommands?.length
|
|
24
|
+
? { requiredCommands: config.detectRequiredCommands }
|
|
25
|
+
: {}),
|
|
26
|
+
...(config.detectUnsupportedRuntimes?.length
|
|
27
|
+
? { unsupportedRuntimes: config.detectUnsupportedRuntimes }
|
|
28
|
+
: {})
|
|
29
|
+
})));
|
|
30
|
+
}
|
|
31
|
+
export function getProviderDetectionProbeCommands(commands = PROVIDER_DETECTION_COMMANDS, runtime = process.platform) {
|
|
32
|
+
return [...new Set(commands
|
|
33
|
+
.filter((command) => !command.unsupportedRuntimes?.includes(runtime))
|
|
34
|
+
.flatMap((command) => [command.cmd, ...(command.requiredCommands ?? [])]))];
|
|
35
|
+
}
|
|
36
|
+
export function resolveDetectedProviderCommands(foundCommands, commands = PROVIDER_DETECTION_COMMANDS, runtime = process.platform) {
|
|
37
|
+
const detected = new Map();
|
|
38
|
+
for (const command of commands) {
|
|
39
|
+
if (command.unsupportedRuntimes?.includes(runtime))
|
|
40
|
+
continue;
|
|
41
|
+
if (!foundCommands.has(command.cmd))
|
|
42
|
+
continue;
|
|
43
|
+
if (!(command.requiredCommands ?? []).every((required) => foundCommands.has(required)))
|
|
44
|
+
continue;
|
|
45
|
+
if (!detected.has(command.id))
|
|
46
|
+
detected.set(command.id, command.cmd);
|
|
47
|
+
}
|
|
48
|
+
return detected;
|
|
49
|
+
}
|
|
12
50
|
export function resolveProvider(agentType) {
|
|
13
51
|
const provider = providers.get(agentType.toLowerCase());
|
|
14
52
|
if (!provider)
|
|
@@ -16,28 +54,20 @@ export function resolveProvider(agentType) {
|
|
|
16
54
|
return provider;
|
|
17
55
|
}
|
|
18
56
|
export function probeProviders() {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
timeout: 5_000,
|
|
29
|
-
shell: false
|
|
30
|
-
});
|
|
31
|
-
const detail = result.error
|
|
32
|
-
? result.error.message
|
|
33
|
-
: (result.stdout || result.stderr || `exit ${result.status ?? 'unknown'}`).trim().slice(0, 200);
|
|
34
|
-
const version = (result.stdout || '').split(/\r?\n/).map((line) => line.trim()).find(Boolean);
|
|
57
|
+
const resolved = new Map(getProviderDetectionProbeCommands().map((command) => [
|
|
58
|
+
command,
|
|
59
|
+
resolveCliCommandDetailed(command)
|
|
60
|
+
]));
|
|
61
|
+
const found = new Set([...resolved].filter(([, result]) => result.found).map(([command]) => command));
|
|
62
|
+
const detected = resolveDetectedProviderCommands(found);
|
|
63
|
+
return PROVIDER_CONFIGS.map((config) => {
|
|
64
|
+
const matchedCommand = detected.get(config.id);
|
|
65
|
+
const result = matchedCommand ? resolved.get(matchedCommand) : undefined;
|
|
35
66
|
return {
|
|
36
|
-
id:
|
|
37
|
-
available: result
|
|
38
|
-
...(result
|
|
39
|
-
|
|
40
|
-
detail
|
|
67
|
+
id: config.id,
|
|
68
|
+
available: Boolean(result?.found),
|
|
69
|
+
...(result?.path ? { path: result.path } : {}),
|
|
70
|
+
detail: result?.found ? 'filesystem detection' : 'command not found'
|
|
41
71
|
};
|
|
42
72
|
});
|
|
43
73
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../src/providers/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../src/providers/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,EAA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AAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,CAAA;IACrG,MAAM,QAAQ,GAAG,+BAA+B,CAAC,KAAK,CAAC,CAAA;IACvD,OAAO,gBAAgB,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;QACrC,MAAM,cAAc,GAAG,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;QAC9C,MAAM,MAAM,GAAG,cAAc,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;QACxE,OAAO;YACL,EAAE,EAAE,MAAM,CAAC,EAAE;YACb,SAAS,EAAE,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC;YACjC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC9C,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,mBAAmB;SACrE,CAAA;IACH,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
import { Dispatcher } from '../dispatch/dispatcher.js';
|
|
2
2
|
import { HealthServer } from '../health/server.js';
|
|
3
3
|
import { createDiagnosticLogger } from '../logging/diagnostic-log.js';
|
|
4
|
-
import {
|
|
4
|
+
import { cliDetection } from '../providers/detection.js';
|
|
5
|
+
import { providerConfig } from '../providers/registry.js';
|
|
5
6
|
import { SessionManager } from '../session/session-manager.js';
|
|
6
7
|
import { StateStore } from '../state/state-store.js';
|
|
7
8
|
import { TaskMcpClient } from '../transport/taskmcp-client.js';
|
|
8
|
-
import { hydrateShellPath, mergePathSegments } from './cli/hydrate-shell-path.js';
|
|
9
9
|
export function selectCapabilities(configured, probes) {
|
|
10
|
-
const explicit = [...new Set(configured.map((value) =>
|
|
10
|
+
const explicit = [...new Set(configured.map((value) => {
|
|
11
|
+
try {
|
|
12
|
+
return providerConfig(value).id;
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
return value.trim().toLowerCase();
|
|
16
|
+
}
|
|
17
|
+
}).filter(Boolean))];
|
|
11
18
|
if (explicit.length > 0)
|
|
12
19
|
return explicit;
|
|
13
20
|
return [...new Set(probes.filter((probe) => probe.available).map((probe) => probe.id.trim().toLowerCase()).filter(Boolean))];
|
|
@@ -29,15 +36,19 @@ export class AgentRuntime {
|
|
|
29
36
|
this.state = new StateStore(config.stateFile);
|
|
30
37
|
}
|
|
31
38
|
async start() {
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
39
|
+
const configuredCapabilities = [...this.config.capabilities];
|
|
40
|
+
let currentDetection = await cliDetection.detect();
|
|
41
|
+
this.config.capabilities = selectCapabilities(configuredCapabilities, currentDetection.providers);
|
|
42
|
+
const refreshDetection = async (refresh) => {
|
|
43
|
+
currentDetection = await cliDetection.detect(refresh);
|
|
44
|
+
this.config.capabilities = selectCapabilities(configuredCapabilities, currentDetection.providers);
|
|
45
|
+
return currentDetection;
|
|
46
|
+
};
|
|
36
47
|
await this.state.initialize();
|
|
37
48
|
const deviceId = this.config.deviceId;
|
|
38
49
|
this.sessions = new SessionManager(this.config, this.state, this.logger);
|
|
39
50
|
this.client = new TaskMcpClient(this.config, deviceId, this.logger);
|
|
40
|
-
const dispatcher = new Dispatcher(this.sessions, this.state, this.client, this.logger, this.config);
|
|
51
|
+
const dispatcher = new Dispatcher(this.sessions, this.state, this.client, this.logger, this.config, refreshDetection);
|
|
41
52
|
this.client.on('message', (message) => dispatcher.accept(message));
|
|
42
53
|
this.health = new HealthServer(this.config.healthHost, this.config.healthPort, () => ({
|
|
43
54
|
deviceId,
|
|
@@ -46,8 +57,9 @@ export class AgentRuntime {
|
|
|
46
57
|
activeSessions: this.sessions?.activeCount ?? 0,
|
|
47
58
|
storedRuns: this.state.snapshot().runs,
|
|
48
59
|
startedAt: this.startedAt,
|
|
49
|
-
runs: this.state.recentRuns()
|
|
50
|
-
|
|
60
|
+
runs: this.state.recentRuns(),
|
|
61
|
+
detection: currentDetection
|
|
62
|
+
}), this.config.logFile, this.logger, refreshDetection);
|
|
51
63
|
await this.health.start();
|
|
52
64
|
this.client.start();
|
|
53
65
|
this.logger.info('agent-started', {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-runtime.js","sourceRoot":"","sources":["../../../src/runtime/agent-runtime.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAA;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAA;
|
|
1
|
+
{"version":3,"file":"agent-runtime.js","sourceRoot":"","sources":["../../../src/runtime/agent-runtime.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAA;AACrE,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AAC9D,OAAO,E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AC,CAAA;QACjC,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAA;IACrB,CAAC;CACF"}
|
|
@@ -2,6 +2,27 @@ import type { AgentConfig } from '../config.js';
|
|
|
2
2
|
import type { DiagnosticLogger } from '../logging/diagnostic-log.js';
|
|
3
3
|
import type { CliWindowRecord, StateStore } from '../state/state-store.js';
|
|
4
4
|
import type { AgentCliRequest, DeliveryResult } from '../types/protocol.js';
|
|
5
|
+
import { type TerminalTailReadOptions } from './terminal-tail-buffer.js';
|
|
6
|
+
export type TerminalTailQuery = {
|
|
7
|
+
runId?: string;
|
|
8
|
+
taskId?: string;
|
|
9
|
+
agentType?: string;
|
|
10
|
+
};
|
|
11
|
+
export type TerminalTailSnapshot = {
|
|
12
|
+
runId: string;
|
|
13
|
+
sessionId: string;
|
|
14
|
+
agentType: string;
|
|
15
|
+
lines: string[];
|
|
16
|
+
startCursor: number;
|
|
17
|
+
nextCursor: number;
|
|
18
|
+
oldestCursor: number;
|
|
19
|
+
latestCursor: number;
|
|
20
|
+
hasMore: boolean;
|
|
21
|
+
truncated: boolean;
|
|
22
|
+
limited: boolean;
|
|
23
|
+
idleMs: number | undefined;
|
|
24
|
+
markers: string[];
|
|
25
|
+
};
|
|
5
26
|
export type CliProcessExit = {
|
|
6
27
|
exitCode: number;
|
|
7
28
|
signal?: number;
|
|
@@ -23,16 +44,34 @@ export declare class SessionManager {
|
|
|
23
44
|
constructor(config: AgentConfig, state: StateStore, logger: DiagnosticLogger);
|
|
24
45
|
get activeCount(): number;
|
|
25
46
|
/**
|
|
26
|
-
* Register a
|
|
27
|
-
*
|
|
47
|
+
* Register a stable local window before its first prompt. This mirrors Orca's
|
|
48
|
+
* host-owned terminal identity: the provider-native session id is learned only
|
|
49
|
+
* after the CLI has actually started and emitted it.
|
|
28
50
|
*/
|
|
29
51
|
createWindow(request: AgentCliRequest): Promise<CliWindowRecord>;
|
|
30
52
|
listWindows(agentType?: string): CliWindowRecord[];
|
|
31
53
|
deliver(request: AgentCliRequest, hooks: DeliveryHooks): Promise<DeliveryResult>;
|
|
32
54
|
dispose(): void;
|
|
55
|
+
/**
|
|
56
|
+
* Read the newest terminal rows of a live session, or page backwards from a
|
|
57
|
+
* cursor a previous read returned. Nothing is persisted and nothing is logged:
|
|
58
|
+
* the rows are sanitized, handed to the caller, and forgotten.
|
|
59
|
+
*
|
|
60
|
+
* A run id is matched first. Sessions outlive a single run, so a task plus
|
|
61
|
+
* agent type still resolves after a later prompt has taken over the session.
|
|
62
|
+
*/
|
|
63
|
+
peekOutput(query: TerminalTailQuery, options?: TerminalTailReadOptions): TerminalTailSnapshot | undefined;
|
|
64
|
+
private findSession;
|
|
65
|
+
/**
|
|
66
|
+
* Look for the provider-native session id in a bounded rolling window instead
|
|
67
|
+
* of the retained tail. CLIs print the id during startup, so the window is
|
|
68
|
+
* released after the first hit rather than re-scanned for the whole session.
|
|
69
|
+
*/
|
|
70
|
+
private discoverProviderSession;
|
|
33
71
|
/** Stop the PTY that owns the requested remote run. */
|
|
34
72
|
cancelRun(runId: string): boolean;
|
|
35
73
|
private writePrompt;
|
|
74
|
+
private waitForProviderSession;
|
|
36
75
|
private waitForStartupOutput;
|
|
37
76
|
private autoApproveTrustPrompt;
|
|
38
77
|
private outputMarkers;
|