@agentconnect/host 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/host.d.ts +1 -0
- package/dist/host.js +2 -1
- package/dist/providers/claude.js +8 -1
- package/dist/providers/codex.js +8 -1
- package/dist/providers/cursor.js +8 -1
- package/dist/providers/local.js +7 -0
- package/dist/providers/utils.d.ts +9 -0
- package/dist/providers/utils.js +29 -0
- package/package.json +1 -1
package/dist/host.d.ts
CHANGED
package/dist/host.js
CHANGED
|
@@ -6,7 +6,7 @@ import { promises as fsp } from 'fs';
|
|
|
6
6
|
import net from 'net';
|
|
7
7
|
import path from 'path';
|
|
8
8
|
import { listModels, listRecentModels, providers, resolveProviderForModel } from './providers/index.js';
|
|
9
|
-
import { debugLog } from './providers/utils.js';
|
|
9
|
+
import { debugLog, setSpawnLogging } from './providers/utils.js';
|
|
10
10
|
import { createObservedTracker } from './observed.js';
|
|
11
11
|
function send(socket, payload) {
|
|
12
12
|
socket.send(JSON.stringify(payload));
|
|
@@ -68,6 +68,7 @@ function createHostRuntime(options) {
|
|
|
68
68
|
const hostId = options.hostId || (mode === 'dev' ? 'agentconnect-dev' : 'agentconnect-host');
|
|
69
69
|
const hostName = options.hostName || (mode === 'dev' ? 'AgentConnect Dev Host' : 'AgentConnect Host');
|
|
70
70
|
const hostVersion = options.hostVersion || '0.1.0';
|
|
71
|
+
setSpawnLogging(Boolean(options.logSpawn));
|
|
71
72
|
function resolveAppPathInternal(input) {
|
|
72
73
|
if (!input)
|
|
73
74
|
return basePath;
|
package/dist/providers/claude.js
CHANGED
|
@@ -3,7 +3,7 @@ import { access, mkdir, readFile, rm, writeFile } from 'fs/promises';
|
|
|
3
3
|
import https from 'https';
|
|
4
4
|
import os from 'os';
|
|
5
5
|
import path from 'path';
|
|
6
|
-
import { buildInstallCommand, buildInstallCommandAuto, buildLoginCommand, buildStatusCommand, checkCommandVersion, commandExists, createLineParser, debugLog, resolveWindowsCommand, resolveCommandPath, resolveCommandRealPath, runCommand, } from './utils.js';
|
|
6
|
+
import { buildInstallCommand, buildInstallCommandAuto, buildLoginCommand, buildStatusCommand, checkCommandVersion, commandExists, createLineParser, debugLog, logProviderSpawn, resolveWindowsCommand, resolveCommandPath, resolveCommandRealPath, runCommand, } from './utils.js';
|
|
7
7
|
const CLAUDE_PACKAGE = '@anthropic-ai/claude-code';
|
|
8
8
|
const INSTALL_UNIX = 'curl -fsSL https://claude.ai/install.sh | bash';
|
|
9
9
|
const INSTALL_WINDOWS_PS = 'irm https://claude.ai/install.ps1 | iex';
|
|
@@ -977,6 +977,13 @@ export function runClaudePrompt({ prompt, resumeSessionId, model, cwd, providerD
|
|
|
977
977
|
if (resumeSessionId)
|
|
978
978
|
args.push('--resume', resumeSessionId);
|
|
979
979
|
args.push(prompt);
|
|
980
|
+
logProviderSpawn({
|
|
981
|
+
provider: 'claude',
|
|
982
|
+
command,
|
|
983
|
+
args,
|
|
984
|
+
cwd: cwd || process.cwd(),
|
|
985
|
+
resumeSessionId,
|
|
986
|
+
});
|
|
980
987
|
const child = spawn(command, args, {
|
|
981
988
|
cwd,
|
|
982
989
|
env: { ...process.env },
|
package/dist/providers/codex.js
CHANGED
|
@@ -3,7 +3,7 @@ import { readFile } from 'fs/promises';
|
|
|
3
3
|
import https from 'https';
|
|
4
4
|
import os from 'os';
|
|
5
5
|
import path from 'path';
|
|
6
|
-
import { buildInstallCommandAuto, buildLoginCommand, buildStatusCommand, checkCommandVersion, commandExists, createLineParser, debugLog, resolveWindowsCommand, resolveCommandPath, resolveCommandRealPath, runCommand, } from './utils.js';
|
|
6
|
+
import { buildInstallCommandAuto, buildLoginCommand, buildStatusCommand, checkCommandVersion, commandExists, createLineParser, debugLog, logProviderSpawn, resolveWindowsCommand, resolveCommandPath, resolveCommandRealPath, runCommand, } from './utils.js';
|
|
7
7
|
const CODEX_PACKAGE = '@openai/codex';
|
|
8
8
|
const DEFAULT_LOGIN = 'codex login';
|
|
9
9
|
const DEFAULT_STATUS = 'codex login status';
|
|
@@ -661,6 +661,13 @@ export function runCodexPrompt({ prompt, resumeSessionId, model, reasoningEffort
|
|
|
661
661
|
providerDetailLevel,
|
|
662
662
|
mode,
|
|
663
663
|
});
|
|
664
|
+
logProviderSpawn({
|
|
665
|
+
provider: 'codex',
|
|
666
|
+
command,
|
|
667
|
+
args,
|
|
668
|
+
cwd: runDir,
|
|
669
|
+
resumeSessionId,
|
|
670
|
+
});
|
|
664
671
|
const argsPreview = [...args];
|
|
665
672
|
if (argsPreview.length > 0) {
|
|
666
673
|
argsPreview[argsPreview.length - 1] = '[prompt]';
|
package/dist/providers/cursor.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { spawn } from 'child_process';
|
|
2
2
|
import path from 'path';
|
|
3
|
-
import { buildInstallCommand, buildLoginCommand, buildStatusCommand, checkCommandVersion, commandExists, createLineParser, debugLog, resolveWindowsCommand, resolveCommandPath, resolveCommandRealPath, runCommand, } from './utils.js';
|
|
3
|
+
import { buildInstallCommand, buildLoginCommand, buildStatusCommand, checkCommandVersion, commandExists, createLineParser, debugLog, logProviderSpawn, resolveWindowsCommand, resolveCommandPath, resolveCommandRealPath, runCommand, } from './utils.js';
|
|
4
4
|
const INSTALL_UNIX = 'curl https://cursor.com/install -fsS | bash';
|
|
5
5
|
const DEFAULT_LOGIN = 'cursor-agent login';
|
|
6
6
|
const DEFAULT_STATUS = 'cursor-agent status';
|
|
@@ -631,6 +631,13 @@ export function runCursorPrompt({ prompt, resumeSessionId, model, repoRoot, cwd,
|
|
|
631
631
|
args.push('--endpoint', endpoint);
|
|
632
632
|
}
|
|
633
633
|
args.push(prompt);
|
|
634
|
+
logProviderSpawn({
|
|
635
|
+
provider: 'cursor',
|
|
636
|
+
command,
|
|
637
|
+
args,
|
|
638
|
+
cwd: runDir,
|
|
639
|
+
resumeSessionId,
|
|
640
|
+
});
|
|
634
641
|
const argsPreview = [...args];
|
|
635
642
|
if (argsPreview.length > 0) {
|
|
636
643
|
argsPreview[argsPreview.length - 1] = '[prompt]';
|
package/dist/providers/local.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { logProviderSpawn } from './utils.js';
|
|
1
2
|
function getLocalBaseUrl() {
|
|
2
3
|
const base = process.env.AGENTCONNECT_LOCAL_BASE_URL || 'http://localhost:11434/v1';
|
|
3
4
|
return base.replace(/\/+$/, '');
|
|
@@ -83,6 +84,12 @@ export async function runLocalPrompt({ prompt, model, onEvent, }) {
|
|
|
83
84
|
onEvent({ type: 'error', message: 'Local provider model is not configured.' });
|
|
84
85
|
return { sessionId: null };
|
|
85
86
|
}
|
|
87
|
+
logProviderSpawn({
|
|
88
|
+
provider: 'local',
|
|
89
|
+
command: 'local',
|
|
90
|
+
args: ['--base-url', base, '--model', resolvedModel, prompt],
|
|
91
|
+
cwd: process.cwd(),
|
|
92
|
+
});
|
|
86
93
|
const payload = {
|
|
87
94
|
model: resolvedModel,
|
|
88
95
|
messages: [{ role: 'user', content: prompt }],
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { type SpawnOptions } from 'child_process';
|
|
2
2
|
import type { CommandResult } from '../types.js';
|
|
3
|
+
export declare function setSpawnLogging(enabled: boolean): void;
|
|
4
|
+
export declare function logProviderSpawn(options: {
|
|
5
|
+
provider: string;
|
|
6
|
+
command: string;
|
|
7
|
+
args: string[];
|
|
8
|
+
cwd?: string;
|
|
9
|
+
resumeSessionId?: string | null;
|
|
10
|
+
redactIndex?: number;
|
|
11
|
+
}): void;
|
|
3
12
|
export declare function debugLog(scope: string, message: string, details?: Record<string, unknown>): void;
|
|
4
13
|
export interface SplitCommandResult {
|
|
5
14
|
command: string;
|
package/dist/providers/utils.js
CHANGED
|
@@ -3,6 +3,35 @@ import { existsSync, realpathSync } from 'fs';
|
|
|
3
3
|
import os from 'os';
|
|
4
4
|
import path from 'path';
|
|
5
5
|
const DEBUG_ENABLED = Boolean(process.env.AGENTCONNECT_DEBUG?.trim());
|
|
6
|
+
let SPAWN_LOG_ENABLED = false;
|
|
7
|
+
export function setSpawnLogging(enabled) {
|
|
8
|
+
SPAWN_LOG_ENABLED = enabled;
|
|
9
|
+
}
|
|
10
|
+
export function logProviderSpawn(options) {
|
|
11
|
+
if (!SPAWN_LOG_ENABLED)
|
|
12
|
+
return;
|
|
13
|
+
const redacted = [...options.args];
|
|
14
|
+
const idx = typeof options.redactIndex === 'number' ? options.redactIndex : redacted.length - 1;
|
|
15
|
+
if (idx >= 0 && idx < redacted.length) {
|
|
16
|
+
redacted[idx] = '[prompt]';
|
|
17
|
+
}
|
|
18
|
+
const cwd = options.cwd || process.cwd();
|
|
19
|
+
const formatted = formatShellCommand(options.command, redacted);
|
|
20
|
+
const fullCommand = cwd
|
|
21
|
+
? `${formatShellCommand('cd', [cwd])} && ${formatted}`
|
|
22
|
+
: formatted;
|
|
23
|
+
console.log(`AgentConnect: ${fullCommand}`);
|
|
24
|
+
}
|
|
25
|
+
function formatShellCommand(command, args) {
|
|
26
|
+
return [command, ...args].map(formatShellArg).join(' ');
|
|
27
|
+
}
|
|
28
|
+
function formatShellArg(value) {
|
|
29
|
+
if (!value)
|
|
30
|
+
return "''";
|
|
31
|
+
if (/^[A-Za-z0-9_./:@+=,-]+$/.test(value))
|
|
32
|
+
return value;
|
|
33
|
+
return `'${value.replace(/'/g, `'\\''`)}'`;
|
|
34
|
+
}
|
|
6
35
|
export function debugLog(scope, message, details) {
|
|
7
36
|
if (!DEBUG_ENABLED)
|
|
8
37
|
return;
|