@getpaseo/server 0.1.97 → 0.1.99
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/server/server/agent/agent-manager.d.ts +11 -3
- package/dist/server/server/agent/agent-manager.js +96 -24
- package/dist/server/server/agent/agent-prompt.d.ts +1 -1
- package/dist/server/server/agent/agent-prompt.js +3 -10
- package/dist/server/server/agent/agent-sdk-types.d.ts +20 -9
- package/dist/server/server/agent/create-agent/create.d.ts +2 -0
- package/dist/server/server/agent/create-agent/create.js +8 -7
- package/dist/server/server/agent/lifecycle-command.d.ts +15 -1
- package/dist/server/server/agent/lifecycle-command.js +9 -2
- package/dist/server/server/agent/mcp-server.js +254 -115
- package/dist/server/server/agent/provider-notices.d.ts +3 -0
- package/dist/server/server/agent/provider-notices.js +5 -0
- package/dist/server/server/agent/provider-registry.d.ts +8 -3
- package/dist/server/server/agent/provider-registry.js +58 -25
- package/dist/server/server/agent/provider-snapshot-manager.d.ts +3 -0
- package/dist/server/server/agent/provider-snapshot-manager.js +37 -16
- package/dist/server/server/agent/providers/acp-agent.d.ts +5 -3
- package/dist/server/server/agent/providers/acp-agent.js +32 -19
- package/dist/server/server/agent/providers/claude/agent.d.ts +2 -2
- package/dist/server/server/agent/providers/claude/agent.js +261 -167
- package/dist/server/server/agent/providers/claude/models.js +7 -3
- package/dist/server/server/agent/providers/codex-app-server-agent.d.ts +6 -4
- package/dist/server/server/agent/providers/codex-app-server-agent.js +48 -25
- package/dist/server/server/agent/providers/copilot-acp-agent.js +4 -31
- package/dist/server/server/agent/providers/diagnostic-utils.d.ts +9 -0
- package/dist/server/server/agent/providers/diagnostic-utils.js +188 -0
- package/dist/server/server/agent/providers/generic-acp-agent.d.ts +0 -1
- package/dist/server/server/agent/providers/generic-acp-agent.js +2 -108
- package/dist/server/server/agent/providers/mock-load-test-agent.d.ts +2 -3
- package/dist/server/server/agent/providers/mock-load-test-agent.js +5 -5
- package/dist/server/server/agent/providers/mock-slow-provider.d.ts +2 -3
- package/dist/server/server/agent/providers/mock-slow-provider.js +3 -6
- package/dist/server/server/agent/providers/opencode/server-manager.d.ts +29 -2
- package/dist/server/server/agent/providers/opencode/server-manager.js +83 -17
- package/dist/server/server/agent/providers/opencode-agent.d.ts +6 -3
- package/dist/server/server/agent/providers/opencode-agent.js +61 -107
- package/dist/server/server/agent/providers/pi/agent.d.ts +2 -3
- package/dist/server/server/agent/providers/pi/agent.js +11 -63
- package/dist/server/server/agent/providers/pi/cli-runtime.js +2 -2
- package/dist/server/server/agent/providers/pi/runtime.d.ts +1 -1
- package/dist/server/server/agent/providers/pi/test-utils/fake-pi.d.ts +1 -1
- package/dist/server/server/agent/providers/pi/test-utils/fake-pi.js +1 -1
- package/dist/server/server/bootstrap.d.ts +2 -0
- package/dist/server/server/bootstrap.js +32 -2
- package/dist/server/server/managed-processes/managed-processes.d.ts +76 -0
- package/dist/server/server/managed-processes/managed-processes.js +326 -0
- package/dist/server/server/resolve-worktree-creation-intent.d.ts +3 -0
- package/dist/server/server/resolve-worktree-creation-intent.js +3 -3
- package/dist/server/server/session/agent-config/agent-config-session.d.ts +50 -0
- package/dist/server/server/session/agent-config/agent-config-session.js +98 -0
- package/dist/server/server/session/chat/chat-schedule-loop-session.d.ts +120 -0
- package/dist/server/server/session/chat/chat-schedule-loop-session.js +489 -0
- package/dist/server/server/session/checkout/checkout-session.d.ts +142 -0
- package/dist/server/server/session/checkout/checkout-session.js +925 -0
- package/dist/server/server/session/daemon/daemon-session.d.ts +50 -0
- package/dist/server/server/session/daemon/daemon-session.js +98 -0
- package/dist/server/server/session/files/workspace-files-session.d.ts +43 -0
- package/dist/server/server/session/files/workspace-files-session.js +218 -0
- package/dist/server/server/session/project-config/project-config-session.d.ts +34 -0
- package/dist/server/server/session/project-config/project-config-session.js +125 -0
- package/dist/server/server/session/provider/provider-catalog-session.d.ts +74 -0
- package/dist/server/server/session/provider/provider-catalog-session.js +339 -0
- package/dist/server/server/session/voice/voice-session.d.ts +166 -0
- package/dist/server/server/session/voice/voice-session.js +893 -0
- package/dist/server/server/{voice → session/voice}/voice-turn-controller.d.ts +2 -2
- package/dist/server/server/{voice → session/voice}/voice-turn-controller.js +2 -2
- package/dist/server/server/session.d.ts +23 -207
- package/dist/server/server/session.js +2319 -5102
- package/dist/server/server/speech/providers/openai/runtime.js +3 -4
- package/dist/server/server/websocket-server.d.ts +1 -0
- package/dist/server/server/websocket-server.js +11 -0
- package/dist/server/server/workspace-archive-service.js +2 -3
- package/dist/server/server/workspace-directory.js +5 -5
- package/dist/server/server/workspace-reconciliation-service.js +2 -2
- package/dist/server/server/worktree-core.d.ts +1 -0
- package/dist/server/server/worktree-core.js +5 -1
- package/dist/server/services/quota-fetcher/manifest.d.ts +4 -0
- package/dist/server/services/quota-fetcher/manifest.js +47 -0
- package/dist/server/services/quota-fetcher/provider.d.ts +17 -0
- package/dist/server/services/quota-fetcher/provider.js +2 -0
- package/dist/server/services/quota-fetcher/providers/claude.d.ts +26 -0
- package/dist/server/services/quota-fetcher/providers/claude.js +217 -0
- package/dist/server/services/quota-fetcher/providers/codex.d.ts +23 -0
- package/dist/server/services/quota-fetcher/providers/codex.js +211 -0
- package/dist/server/services/quota-fetcher/providers/copilot.d.ts +17 -0
- package/dist/server/services/quota-fetcher/providers/copilot.js +75 -0
- package/dist/server/services/quota-fetcher/providers/cursor.d.ts +17 -0
- package/dist/server/services/quota-fetcher/providers/cursor.js +123 -0
- package/dist/server/services/quota-fetcher/providers/grok.d.ts +18 -0
- package/dist/server/services/quota-fetcher/providers/grok.js +89 -0
- package/dist/server/services/quota-fetcher/providers/kimi.d.ts +20 -0
- package/dist/server/services/quota-fetcher/providers/kimi.js +89 -0
- package/dist/server/services/quota-fetcher/providers/zai.d.ts +17 -0
- package/dist/server/services/quota-fetcher/providers/zai.js +58 -0
- package/dist/server/services/quota-fetcher/service.d.ts +28 -0
- package/dist/server/services/quota-fetcher/service.js +58 -0
- package/dist/server/services/quota-fetcher/usage.d.ts +22 -0
- package/dist/server/services/quota-fetcher/usage.js +49 -0
- package/dist/server/utils/checkout-git.d.ts +6 -0
- package/dist/server/utils/directory-suggestions.js +98 -2
- package/package.json +5 -5
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type AgentCapabilityFlags, type AgentClient, type AgentCreateSessionOptions, type AgentFeature, type AgentLaunchContext, type AgentMode, type
|
|
1
|
+
import { type AgentCapabilityFlags, type AgentClient, type AgentCreateSessionOptions, type AgentFeature, type AgentLaunchContext, type AgentMode, type AgentPersistenceHandle, type AgentPermissionRequest, type AgentPermissionResponse, type AgentPermissionResult, type AgentProviderNotice, type AgentPromptContentBlock, type AgentPromptInput, type AgentRunOptions, type AgentRunResult, type AgentRuntimeInfo, type AgentSession, type AgentSessionConfig, type AgentSlashCommand, type AgentStreamEvent, type AgentTimelineItem, type ToolCallTimelineItem, type AgentUsage, type FetchCatalogOptions, type ImportableProviderSession, type ImportProviderSessionContext, type ImportProviderSessionInput, type ListImportableSessionsOptions, type ProviderCatalog } from "../agent-sdk-types.js";
|
|
2
2
|
import type { Logger } from "pino";
|
|
3
3
|
import type { ChildProcessWithoutNullStreams } from "node:child_process";
|
|
4
4
|
import { type ProviderRuntimeSettings } from "../provider-launch-config.js";
|
|
@@ -196,9 +196,9 @@ export declare class CodexAppServerAgentSession implements AgentSession {
|
|
|
196
196
|
getRuntimeInfo(): Promise<AgentRuntimeInfo>;
|
|
197
197
|
getAvailableModes(): Promise<AgentMode[]>;
|
|
198
198
|
getCurrentMode(): Promise<string | null>;
|
|
199
|
-
setMode(modeId: string): Promise<void>;
|
|
199
|
+
setMode(modeId: string): Promise<void | AgentProviderNotice>;
|
|
200
200
|
setModel(modelId: string | null): Promise<void>;
|
|
201
|
-
setThinkingOption(thinkingOptionId: string | null): Promise<void>;
|
|
201
|
+
setThinkingOption(thinkingOptionId: string | null): Promise<void | AgentProviderNotice>;
|
|
202
202
|
setFeature(featureId: string, value: unknown): Promise<void>;
|
|
203
203
|
getPendingPermissions(): AgentPermissionRequest[];
|
|
204
204
|
respondToPermission(requestId: string, response: AgentPermissionResponse): Promise<AgentPermissionResult | void>;
|
|
@@ -295,8 +295,10 @@ export declare class CodexAppServerAgentClient implements AgentClient {
|
|
|
295
295
|
}, overrides?: Partial<AgentSessionConfig>, launchContext?: AgentLaunchContext): Promise<AgentSession>;
|
|
296
296
|
listImportableSessions(options?: ListImportableSessionsOptions): Promise<ImportableProviderSession[]>;
|
|
297
297
|
importSession(input: ImportProviderSessionInput, context: ImportProviderSessionContext): Promise<import("../agent-sdk-types.js").ImportedProviderSession>;
|
|
298
|
-
|
|
298
|
+
fetchCatalog(_options: FetchCatalogOptions): Promise<ProviderCatalog>;
|
|
299
|
+
private fetchModelsFromAppServer;
|
|
299
300
|
archiveNativeSession(handle: AgentPersistenceHandle): Promise<void>;
|
|
301
|
+
unarchiveNativeSession(handle: AgentPersistenceHandle): Promise<void>;
|
|
300
302
|
isAvailable(): Promise<boolean>;
|
|
301
303
|
getDiagnostic(): Promise<{
|
|
302
304
|
diagnostic: string;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { getAgentStreamEventTurnId, } from "../agent-sdk-types.js";
|
|
2
2
|
import { importSessionFromPersistence } from "../provider-session-import.js";
|
|
3
|
-
import { homedir } from "node:os";
|
|
4
3
|
import { randomUUID } from "node:crypto";
|
|
5
4
|
import * as fsSync from "node:fs";
|
|
6
5
|
import fs from "node:fs/promises";
|
|
@@ -21,8 +20,9 @@ import { CodexAppServerClient, parseCodexThreadForkResponse, parseCodexThreadRol
|
|
|
21
20
|
import { revertCodexConversation } from "./codex/rewind.js";
|
|
22
21
|
import { renderProviderImageOutputAsAssistantMarkdown, } from "./provider-image-output.js";
|
|
23
22
|
import { normalizeProviderReplayTimestamp } from "../provider-history-timestamps.js";
|
|
24
|
-
import {
|
|
23
|
+
import { formatProviderDiagnostic, formatProviderDiagnosticError, buildBinaryDiagnosticRows, buildCommandResolutionDiagnosticRows, resolveBinaryVersion, } from "./diagnostic-utils.js";
|
|
25
24
|
import { runProviderTurn } from "./provider-runner.js";
|
|
25
|
+
import { SETTING_APPLIES_NEXT_TURN_NOTICE } from "../provider-notices.js";
|
|
26
26
|
function assertChildWithPipes(child) {
|
|
27
27
|
if (!child.stdin || !child.stdout || !child.stderr) {
|
|
28
28
|
throw new Error("Child process did not expose stdio pipes");
|
|
@@ -31,6 +31,10 @@ function assertChildWithPipes(child) {
|
|
|
31
31
|
function isRecord(value) {
|
|
32
32
|
return value != null && typeof value === "object" && !Array.isArray(value);
|
|
33
33
|
}
|
|
34
|
+
function isCodexAlreadyUnarchivedError(error, threadId) {
|
|
35
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
36
|
+
return message.includes(`no archived rollout found for thread id ${threadId}`);
|
|
37
|
+
}
|
|
34
38
|
const TURN_START_TIMEOUT_MS = 90 * 1000;
|
|
35
39
|
const INTERRUPT_TIMEOUT_MS = 2000;
|
|
36
40
|
const CODEX_PROVIDER = "codex";
|
|
@@ -2759,6 +2763,9 @@ export class CodexAppServerAgentSession {
|
|
|
2759
2763
|
validateCodexMode(modeId);
|
|
2760
2764
|
this.currentMode = modeId;
|
|
2761
2765
|
this.cachedRuntimeInfo = null;
|
|
2766
|
+
if (this.activeForegroundTurnId) {
|
|
2767
|
+
return SETTING_APPLIES_NEXT_TURN_NOTICE;
|
|
2768
|
+
}
|
|
2762
2769
|
}
|
|
2763
2770
|
async setModel(modelId) {
|
|
2764
2771
|
this.config.model = modelId ?? undefined;
|
|
@@ -2772,6 +2779,9 @@ export class CodexAppServerAgentSession {
|
|
|
2772
2779
|
this.config.thinkingOptionId = normalizeCodexThinkingOptionId(thinkingOptionId);
|
|
2773
2780
|
this.refreshResolvedCollaborationMode();
|
|
2774
2781
|
this.cachedRuntimeInfo = null;
|
|
2782
|
+
if (this.activeForegroundTurnId) {
|
|
2783
|
+
return SETTING_APPLIES_NEXT_TURN_NOTICE;
|
|
2784
|
+
}
|
|
2775
2785
|
}
|
|
2776
2786
|
async setFeature(featureId, value) {
|
|
2777
2787
|
if (featureId === "fast_mode") {
|
|
@@ -4365,7 +4375,11 @@ export class CodexAppServerAgentClient {
|
|
|
4365
4375
|
resumeSession: this.resumeSession.bind(this),
|
|
4366
4376
|
});
|
|
4367
4377
|
}
|
|
4368
|
-
async
|
|
4378
|
+
async fetchCatalog(_options) {
|
|
4379
|
+
const models = await this.fetchModelsFromAppServer();
|
|
4380
|
+
return { models, modes: CODEX_MODES };
|
|
4381
|
+
}
|
|
4382
|
+
async fetchModelsFromAppServer() {
|
|
4369
4383
|
// Codex model/list is global to the app server in this flow; cwd/force are intentionally ignored.
|
|
4370
4384
|
const child = await this.spawnAppServer();
|
|
4371
4385
|
const client = new CodexAppServerClient(child, this.logger);
|
|
@@ -4406,6 +4420,34 @@ export class CodexAppServerAgentClient {
|
|
|
4406
4420
|
await client.dispose();
|
|
4407
4421
|
}
|
|
4408
4422
|
}
|
|
4423
|
+
async unarchiveNativeSession(handle) {
|
|
4424
|
+
const threadId = handle.nativeHandle ?? handle.sessionId;
|
|
4425
|
+
if (!threadId)
|
|
4426
|
+
return;
|
|
4427
|
+
const child = await this.spawnAppServer();
|
|
4428
|
+
const client = new CodexAppServerClient(child, this.logger);
|
|
4429
|
+
try {
|
|
4430
|
+
await client.request("initialize", buildCodexAppServerInitializeParams());
|
|
4431
|
+
client.notify("initialized", {});
|
|
4432
|
+
try {
|
|
4433
|
+
await client.request("thread/unarchive", { threadId });
|
|
4434
|
+
}
|
|
4435
|
+
catch (error) {
|
|
4436
|
+
if (!isCodexAlreadyUnarchivedError(error, threadId)) {
|
|
4437
|
+
throw error;
|
|
4438
|
+
}
|
|
4439
|
+
try {
|
|
4440
|
+
await client.request("thread/read", { threadId });
|
|
4441
|
+
}
|
|
4442
|
+
catch {
|
|
4443
|
+
throw error;
|
|
4444
|
+
}
|
|
4445
|
+
}
|
|
4446
|
+
}
|
|
4447
|
+
finally {
|
|
4448
|
+
await client.dispose();
|
|
4449
|
+
}
|
|
4450
|
+
}
|
|
4409
4451
|
async isAvailable() {
|
|
4410
4452
|
const launch = await resolveCodexLaunch(this.runtimeSettings);
|
|
4411
4453
|
const availability = await checkCodexLaunchAvailable(launch);
|
|
@@ -4415,31 +4457,12 @@ export class CodexAppServerAgentClient {
|
|
|
4415
4457
|
try {
|
|
4416
4458
|
const launch = await resolveCodexLaunch(this.runtimeSettings);
|
|
4417
4459
|
const availability = await checkCodexLaunchAvailable(launch);
|
|
4418
|
-
const available = availability.available;
|
|
4419
4460
|
const entries = [
|
|
4461
|
+
...(await buildCommandResolutionDiagnosticRows(launch, {
|
|
4462
|
+
knownBinaryNames: ["codex"],
|
|
4463
|
+
})),
|
|
4420
4464
|
...(await buildBinaryDiagnosticRows(launch, availability)),
|
|
4421
4465
|
];
|
|
4422
|
-
let status = formatDiagnosticStatus(available);
|
|
4423
|
-
if (!available) {
|
|
4424
|
-
entries.push({ label: "Models", value: "Not checked" });
|
|
4425
|
-
}
|
|
4426
|
-
else {
|
|
4427
|
-
try {
|
|
4428
|
-
const models = await this.listModels({ cwd: homedir(), force: false });
|
|
4429
|
-
entries.push({ label: "Models", value: String(models.length) });
|
|
4430
|
-
}
|
|
4431
|
-
catch (error) {
|
|
4432
|
-
entries.push({
|
|
4433
|
-
label: "Models",
|
|
4434
|
-
value: `Error - ${toDiagnosticErrorMessage(error)}`,
|
|
4435
|
-
});
|
|
4436
|
-
status = formatDiagnosticStatus(available, {
|
|
4437
|
-
source: "model fetch",
|
|
4438
|
-
cause: error,
|
|
4439
|
-
});
|
|
4440
|
-
}
|
|
4441
|
-
}
|
|
4442
|
-
entries.push({ label: "Status", value: status });
|
|
4443
4466
|
return {
|
|
4444
4467
|
diagnostic: formatProviderDiagnostic("Codex", entries),
|
|
4445
4468
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { homedir } from "node:os";
|
|
2
1
|
import { checkProviderLaunchAvailable, resolveProviderLaunch, } from "../provider-launch-config.js";
|
|
3
2
|
import { ACPAgentClient, } from "./acp-agent.js";
|
|
4
|
-
import {
|
|
3
|
+
import { formatProviderDiagnostic, formatProviderDiagnosticError, buildBinaryDiagnosticRows, buildCommandResolutionDiagnosticRows, } from "./diagnostic-utils.js";
|
|
5
4
|
const COPILOT_CAPABILITIES = {
|
|
6
5
|
supportsStreaming: true,
|
|
7
6
|
supportsSessionPersistence: true,
|
|
@@ -64,38 +63,12 @@ export class CopilotACPAgentClient extends ACPAgentClient {
|
|
|
64
63
|
defaultBinary: "copilot",
|
|
65
64
|
});
|
|
66
65
|
const availability = await checkProviderLaunchAvailable(launch);
|
|
67
|
-
const available = availability.available;
|
|
68
|
-
let modelsValue = "Not checked";
|
|
69
|
-
let status = formatDiagnosticStatus(available);
|
|
70
|
-
if (available) {
|
|
71
|
-
try {
|
|
72
|
-
const models = await this.listModels({ cwd: homedir(), force: false });
|
|
73
|
-
modelsValue = String(models.length);
|
|
74
|
-
}
|
|
75
|
-
catch (error) {
|
|
76
|
-
modelsValue = `Error - ${toDiagnosticErrorMessage(error)}`;
|
|
77
|
-
status = formatDiagnosticStatus(available, {
|
|
78
|
-
source: "model fetch",
|
|
79
|
-
cause: error,
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
if (!modelsValue.startsWith("Error -")) {
|
|
83
|
-
try {
|
|
84
|
-
await this.listModes({ cwd: homedir(), force: false });
|
|
85
|
-
}
|
|
86
|
-
catch (error) {
|
|
87
|
-
status = formatDiagnosticStatus(available, {
|
|
88
|
-
source: "mode fetch",
|
|
89
|
-
cause: error,
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
66
|
return {
|
|
95
67
|
diagnostic: formatProviderDiagnostic("Copilot", [
|
|
68
|
+
...(await buildCommandResolutionDiagnosticRows(launch, {
|
|
69
|
+
knownBinaryNames: ["copilot"],
|
|
70
|
+
})),
|
|
96
71
|
...(await buildBinaryDiagnosticRows(launch, availability)),
|
|
97
|
-
{ label: "Models", value: modelsValue },
|
|
98
|
-
{ label: "Status", value: status },
|
|
99
72
|
]),
|
|
100
73
|
};
|
|
101
74
|
}
|
|
@@ -21,6 +21,15 @@ export interface BinaryDiagnosticRowsOptions {
|
|
|
21
21
|
binaryLabel?: string;
|
|
22
22
|
versionCommand?: BinaryDiagnosticVersionCommand;
|
|
23
23
|
}
|
|
24
|
+
export interface CommandResolutionDiagnosticRowsOptions {
|
|
25
|
+
knownBinaryNames: readonly string[];
|
|
26
|
+
includeCommandProbes?: boolean;
|
|
27
|
+
pathValue?: string;
|
|
28
|
+
pathext?: string;
|
|
29
|
+
platform?: NodeJS.Platform;
|
|
30
|
+
shell?: string;
|
|
31
|
+
}
|
|
32
|
+
export declare function buildCommandResolutionDiagnosticRows(launch: ResolvedProviderLaunch, options: CommandResolutionDiagnosticRowsOptions): Promise<DiagnosticEntry[]>;
|
|
24
33
|
export declare function buildBinaryDiagnosticRows(launch: ResolvedProviderLaunch, availability: ProviderLaunchAvailability, options?: BinaryDiagnosticRowsOptions): Promise<DiagnosticEntry[]>;
|
|
25
34
|
export declare function formatConfiguredCommand(defaultArgv: readonly string[], runtimeSettings?: ProviderRuntimeSettings): string;
|
|
26
35
|
//# sourceMappingURL=diagnostic-utils.d.ts.map
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { constants } from "node:fs";
|
|
2
|
+
import { access, stat } from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
1
4
|
import { createProviderEnvSpec, } from "../provider-launch-config.js";
|
|
2
5
|
import { execCommand } from "../../../utils/spawn.js";
|
|
3
6
|
export function formatProviderDiagnostic(providerName, entries) {
|
|
@@ -114,6 +117,191 @@ export async function resolveBinaryVersion(binaryPath) {
|
|
|
114
117
|
return `error: ${toDiagnosticErrorMessage(error)}`;
|
|
115
118
|
}
|
|
116
119
|
}
|
|
120
|
+
const COMMAND_PROBE_TIMEOUT_MS = 3000;
|
|
121
|
+
const COMMAND_PROBE_MAX_BUFFER = 32 * 1024;
|
|
122
|
+
function resolvePlatform(options) {
|
|
123
|
+
return options?.platform ?? process.platform;
|
|
124
|
+
}
|
|
125
|
+
function resolvePathValue(options) {
|
|
126
|
+
return options?.pathValue ?? process.env["PATH"] ?? process.env["Path"] ?? "";
|
|
127
|
+
}
|
|
128
|
+
function resolveShellValue(options) {
|
|
129
|
+
if (options?.shell) {
|
|
130
|
+
return options.shell;
|
|
131
|
+
}
|
|
132
|
+
if (resolvePlatform(options) === "win32") {
|
|
133
|
+
return process.env["ComSpec"] ?? "cmd.exe";
|
|
134
|
+
}
|
|
135
|
+
return process.env["SHELL"] ?? "/bin/sh";
|
|
136
|
+
}
|
|
137
|
+
async function isExecutableFile(filePath, platform) {
|
|
138
|
+
try {
|
|
139
|
+
const candidate = await stat(filePath);
|
|
140
|
+
if (!candidate.isFile()) {
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
if (platform === "win32") {
|
|
144
|
+
return true;
|
|
145
|
+
}
|
|
146
|
+
await access(filePath, constants.X_OK);
|
|
147
|
+
return true;
|
|
148
|
+
}
|
|
149
|
+
catch {
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
function resolveSearchableNames(binaryNames) {
|
|
154
|
+
return binaryNames.filter((binaryName) => binaryName.trim().length > 0 && !binaryName.includes("/") && !binaryName.includes("\\"));
|
|
155
|
+
}
|
|
156
|
+
function resolveWindowsPathExt(options) {
|
|
157
|
+
const value = options.pathext ?? process.env["PATHEXT"] ?? ".COM;.EXE;.BAT;.CMD";
|
|
158
|
+
return value
|
|
159
|
+
.split(";")
|
|
160
|
+
.map((extension) => extension.trim())
|
|
161
|
+
.filter(Boolean)
|
|
162
|
+
.map((extension) => (extension.startsWith(".") ? extension : `.${extension}`));
|
|
163
|
+
}
|
|
164
|
+
function resolveBinaryCandidateNames(binaryName, options) {
|
|
165
|
+
if (resolvePlatform(options) !== "win32" || path.win32.extname(binaryName)) {
|
|
166
|
+
return [binaryName];
|
|
167
|
+
}
|
|
168
|
+
return [binaryName, ...resolveWindowsPathExt(options).map((extension) => binaryName + extension)];
|
|
169
|
+
}
|
|
170
|
+
async function formatPathMatches(options) {
|
|
171
|
+
const binaryNames = options.knownBinaryNames;
|
|
172
|
+
const searchableNames = resolveSearchableNames(binaryNames);
|
|
173
|
+
if (searchableNames.length === 0) {
|
|
174
|
+
return "not checked";
|
|
175
|
+
}
|
|
176
|
+
const pathDelimiter = resolvePlatform(options) === "win32" ? ";" : path.delimiter;
|
|
177
|
+
const pathEntries = resolvePathValue(options).split(pathDelimiter).filter(Boolean);
|
|
178
|
+
const matches = [];
|
|
179
|
+
const seen = new Set();
|
|
180
|
+
const platform = resolvePlatform(options);
|
|
181
|
+
for (const directory of pathEntries) {
|
|
182
|
+
for (const binaryName of searchableNames) {
|
|
183
|
+
for (const candidateName of resolveBinaryCandidateNames(binaryName, options)) {
|
|
184
|
+
const candidate = path.join(directory, candidateName);
|
|
185
|
+
if (seen.has(candidate)) {
|
|
186
|
+
continue;
|
|
187
|
+
}
|
|
188
|
+
seen.add(candidate);
|
|
189
|
+
if (await isExecutableFile(candidate, platform)) {
|
|
190
|
+
matches.push(candidate);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
return matches.length > 0 ? matches.join("\n ") : "none";
|
|
196
|
+
}
|
|
197
|
+
function shellToken(value) {
|
|
198
|
+
return `'${value.replace(/'/g, "'\\''")}'`;
|
|
199
|
+
}
|
|
200
|
+
function formatCommandProbeOutput(stdout, stderr) {
|
|
201
|
+
const sections = [];
|
|
202
|
+
const trimmedStdout = truncateForDiagnostic(stdout);
|
|
203
|
+
const trimmedStderr = truncateForDiagnostic(stderr);
|
|
204
|
+
if (trimmedStdout.length > 0) {
|
|
205
|
+
sections.push(trimmedStdout);
|
|
206
|
+
}
|
|
207
|
+
if (trimmedStderr.length > 0) {
|
|
208
|
+
sections.push(`stderr: ${trimmedStderr}`);
|
|
209
|
+
}
|
|
210
|
+
return sections.length > 0 ? sections.join("\n") : "(no output)";
|
|
211
|
+
}
|
|
212
|
+
function formatCommandProbeError(error) {
|
|
213
|
+
return toDiagnosticErrorMessage(error);
|
|
214
|
+
}
|
|
215
|
+
async function runCommandProbe(command, args) {
|
|
216
|
+
try {
|
|
217
|
+
const { stdout, stderr } = await execCommand(command, args, {
|
|
218
|
+
timeout: COMMAND_PROBE_TIMEOUT_MS,
|
|
219
|
+
killSignal: "SIGKILL",
|
|
220
|
+
maxBuffer: COMMAND_PROBE_MAX_BUFFER,
|
|
221
|
+
});
|
|
222
|
+
return formatCommandProbeOutput(stdout, stderr);
|
|
223
|
+
}
|
|
224
|
+
catch (error) {
|
|
225
|
+
return formatCommandProbeError(error);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
async function buildPosixCommandProbeRows(binaryName) {
|
|
229
|
+
const shell = resolveShellValue();
|
|
230
|
+
const typeCommand = `type -a ${shellToken(binaryName)}`;
|
|
231
|
+
return [
|
|
232
|
+
{
|
|
233
|
+
label: `which -a ${binaryName}`,
|
|
234
|
+
value: await runCommandProbe("/usr/bin/which", ["-a", binaryName]),
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
label: `${path.basename(shell)} -lc type -a ${binaryName}`,
|
|
238
|
+
value: await runCommandProbe(shell, ["-lc", typeCommand]),
|
|
239
|
+
},
|
|
240
|
+
];
|
|
241
|
+
}
|
|
242
|
+
async function buildWindowsCommandProbeRows(binaryName) {
|
|
243
|
+
const powershellCommand = [
|
|
244
|
+
"$ErrorActionPreference = 'Continue';",
|
|
245
|
+
`Get-Command -All ${JSON.stringify(binaryName)} |`,
|
|
246
|
+
"Select-Object CommandType,Source,Name,Definition |",
|
|
247
|
+
"Format-List",
|
|
248
|
+
].join(" ");
|
|
249
|
+
return [
|
|
250
|
+
{
|
|
251
|
+
label: `where.exe ${binaryName}`,
|
|
252
|
+
value: await runCommandProbe("where.exe", [binaryName]),
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
label: `powershell Get-Command -All ${binaryName}`,
|
|
256
|
+
value: await runCommandProbe("powershell.exe", [
|
|
257
|
+
"-NoProfile",
|
|
258
|
+
"-ExecutionPolicy",
|
|
259
|
+
"Bypass",
|
|
260
|
+
"-Command",
|
|
261
|
+
powershellCommand,
|
|
262
|
+
]),
|
|
263
|
+
},
|
|
264
|
+
];
|
|
265
|
+
}
|
|
266
|
+
async function buildCommandProbeRows(binaryNames) {
|
|
267
|
+
const searchableNames = resolveSearchableNames(binaryNames);
|
|
268
|
+
if (searchableNames.length === 0) {
|
|
269
|
+
return [];
|
|
270
|
+
}
|
|
271
|
+
const rows = [];
|
|
272
|
+
for (const binaryName of searchableNames) {
|
|
273
|
+
rows.push(...(process.platform === "win32"
|
|
274
|
+
? await buildWindowsCommandProbeRows(binaryName)
|
|
275
|
+
: await buildPosixCommandProbeRows(binaryName)));
|
|
276
|
+
}
|
|
277
|
+
return rows;
|
|
278
|
+
}
|
|
279
|
+
export async function buildCommandResolutionDiagnosticRows(launch, options) {
|
|
280
|
+
const includeCommandProbes = options.includeCommandProbes ?? true;
|
|
281
|
+
return [
|
|
282
|
+
{
|
|
283
|
+
label: "Command source",
|
|
284
|
+
value: launch.source,
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
label: "Configured command",
|
|
288
|
+
value: [launch.command, ...launch.args].join(" "),
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
label: "Daemon PATH",
|
|
292
|
+
value: truncateForDiagnostic(resolvePathValue(options)) || "(empty)",
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
label: "Daemon shell",
|
|
296
|
+
value: resolveShellValue(options),
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
label: "PATH matches",
|
|
300
|
+
value: await formatPathMatches(options),
|
|
301
|
+
},
|
|
302
|
+
...(includeCommandProbes ? await buildCommandProbeRows(options.knownBinaryNames) : []),
|
|
303
|
+
];
|
|
304
|
+
}
|
|
117
305
|
async function resolveCommandVersion(invocation) {
|
|
118
306
|
try {
|
|
119
307
|
const { stdout, stderr } = await execCommand(invocation.command, invocation.args, {
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import { homedir } from "node:os";
|
|
2
1
|
import { z } from "zod";
|
|
3
2
|
import { checkProviderLaunchAvailable, resolveProviderLaunch } from "../provider-launch-config.js";
|
|
4
|
-
import { ACPAgentClient, DEFAULT_ACP_CAPABILITIES
|
|
5
|
-
import {
|
|
6
|
-
const ACP_DIAGNOSTIC_INITIALIZE_TIMEOUT_MS = 8000;
|
|
7
|
-
const ACP_DIAGNOSTIC_SESSION_TIMEOUT_MS = 8000;
|
|
3
|
+
import { ACPAgentClient, DEFAULT_ACP_CAPABILITIES } from "./acp-agent.js";
|
|
4
|
+
import { formatProviderDiagnostic, formatProviderDiagnosticError, buildBinaryDiagnosticRows, } from "./diagnostic-utils.js";
|
|
8
5
|
export const GenericACPProviderParamsSchema = z
|
|
9
6
|
.object({
|
|
10
7
|
supportsMcpServers: z.boolean().optional(),
|
|
@@ -43,17 +40,7 @@ export class GenericACPAgentClient extends ACPAgentClient {
|
|
|
43
40
|
try {
|
|
44
41
|
const launch = await this.resolveConfiguredLaunch();
|
|
45
42
|
const availability = await checkProviderLaunchAvailable(launch);
|
|
46
|
-
const available = availability.available;
|
|
47
43
|
const versionProbe = buildVersionProbeCommand(this.command);
|
|
48
|
-
const probeResult = available
|
|
49
|
-
? await this.runDiagnosticACPProbe()
|
|
50
|
-
: {
|
|
51
|
-
status: formatDiagnosticStatus(false),
|
|
52
|
-
initialize: "Not checked",
|
|
53
|
-
session: "Not checked",
|
|
54
|
-
models: "Not checked",
|
|
55
|
-
modes: "Not checked",
|
|
56
|
-
};
|
|
57
44
|
return {
|
|
58
45
|
diagnostic: formatProviderDiagnostic(providerName, [
|
|
59
46
|
{ label: "Provider ID", value: this.providerId ?? "unknown" },
|
|
@@ -70,11 +57,6 @@ export class GenericACPAgentClient extends ACPAgentClient {
|
|
|
70
57
|
label: "Version command",
|
|
71
58
|
value: formatCommand(versionProbe.command, versionProbe.args),
|
|
72
59
|
},
|
|
73
|
-
{ label: "ACP initialize", value: probeResult.initialize },
|
|
74
|
-
{ label: "ACP session/new", value: probeResult.session },
|
|
75
|
-
{ label: "Models", value: probeResult.models },
|
|
76
|
-
{ label: "Modes", value: probeResult.modes },
|
|
77
|
-
{ label: "Status", value: probeResult.status },
|
|
78
60
|
]),
|
|
79
61
|
};
|
|
80
62
|
}
|
|
@@ -90,50 +72,6 @@ export class GenericACPAgentClient extends ACPAgentClient {
|
|
|
90
72
|
defaultBinary: this.command[0],
|
|
91
73
|
});
|
|
92
74
|
}
|
|
93
|
-
async runDiagnosticACPProbe() {
|
|
94
|
-
let initializeValue = "Not checked";
|
|
95
|
-
let sessionValue = "Not checked";
|
|
96
|
-
try {
|
|
97
|
-
const probe = await this.spawnProcess({
|
|
98
|
-
NO_BROWSER: "true",
|
|
99
|
-
NO_OPEN_BROWSER: "1",
|
|
100
|
-
GEMINI_CLI_NO_BROWSER: "true",
|
|
101
|
-
CI: "1",
|
|
102
|
-
}, {
|
|
103
|
-
initializeTimeoutMs: ACP_DIAGNOSTIC_INITIALIZE_TIMEOUT_MS,
|
|
104
|
-
});
|
|
105
|
-
try {
|
|
106
|
-
initializeValue = formatInitializeResult(probe.initialize);
|
|
107
|
-
const response = await withTimeout(probe.connection.newSession({
|
|
108
|
-
cwd: homedir(),
|
|
109
|
-
mcpServers: [],
|
|
110
|
-
}), ACP_DIAGNOSTIC_SESSION_TIMEOUT_MS, "ACP session/new");
|
|
111
|
-
sessionValue = response.sessionId ? `ok (${response.sessionId})` : "ok";
|
|
112
|
-
const transformed = this.transformSessionResponse(response);
|
|
113
|
-
return {
|
|
114
|
-
status: formatDiagnosticStatus(true),
|
|
115
|
-
initialize: initializeValue,
|
|
116
|
-
session: sessionValue,
|
|
117
|
-
...summarizeSessionState(this.provider, transformed),
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
finally {
|
|
121
|
-
await this.closeProbe(probe);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
catch (error) {
|
|
125
|
-
return {
|
|
126
|
-
status: formatDiagnosticStatus(true, {
|
|
127
|
-
source: "ACP probe",
|
|
128
|
-
cause: error,
|
|
129
|
-
}),
|
|
130
|
-
initialize: formatProbeError(initializeValue, error),
|
|
131
|
-
session: initializeValue === "Not checked" ? "Not checked" : formatProbeError(sessionValue, error),
|
|
132
|
-
models: "Not checked",
|
|
133
|
-
modes: "Not checked",
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
75
|
}
|
|
138
76
|
function buildGenericACPCapabilities(options) {
|
|
139
77
|
const params = parseGenericACPProviderParams(options.providerParams);
|
|
@@ -200,48 +138,4 @@ function takePackageSpecPrefix(args) {
|
|
|
200
138
|
}
|
|
201
139
|
return prefix;
|
|
202
140
|
}
|
|
203
|
-
function formatInitializeResult(initialize) {
|
|
204
|
-
const agentInfo = isAgentInfo(initialize.agentInfo)
|
|
205
|
-
? `${initialize.agentInfo.name}${initialize.agentInfo.version ? ` ${initialize.agentInfo.version}` : ""}`
|
|
206
|
-
: "ok";
|
|
207
|
-
return `ok (protocol ${initialize.protocolVersion}, ${agentInfo})`;
|
|
208
|
-
}
|
|
209
|
-
function isAgentInfo(value) {
|
|
210
|
-
return (typeof value === "object" &&
|
|
211
|
-
value !== null &&
|
|
212
|
-
"name" in value &&
|
|
213
|
-
typeof Reflect.get(value, "name") === "string");
|
|
214
|
-
}
|
|
215
|
-
function summarizeSessionState(provider, response) {
|
|
216
|
-
const models = deriveModelDefinitionsFromACP(provider, response.models, response.configOptions);
|
|
217
|
-
const { modes } = deriveModesFromACP([], response.modes, response.configOptions);
|
|
218
|
-
return {
|
|
219
|
-
models: `${models.length}`,
|
|
220
|
-
modes: modes.length > 0 ? modes.map((mode) => mode.label || mode.id).join(", ") : "none reported",
|
|
221
|
-
};
|
|
222
|
-
}
|
|
223
|
-
function formatProbeError(currentValue, error) {
|
|
224
|
-
if (currentValue !== "Not checked") {
|
|
225
|
-
return currentValue;
|
|
226
|
-
}
|
|
227
|
-
return `Error - ${toDiagnosticErrorMessage(error)}`;
|
|
228
|
-
}
|
|
229
|
-
async function withTimeout(promise, timeoutMs, label) {
|
|
230
|
-
let timeout = null;
|
|
231
|
-
try {
|
|
232
|
-
return await Promise.race([
|
|
233
|
-
promise,
|
|
234
|
-
new Promise((_, reject) => {
|
|
235
|
-
timeout = setTimeout(() => {
|
|
236
|
-
reject(new Error(`${label} timed out after ${timeoutMs}ms`));
|
|
237
|
-
}, timeoutMs);
|
|
238
|
-
}),
|
|
239
|
-
]);
|
|
240
|
-
}
|
|
241
|
-
finally {
|
|
242
|
-
if (timeout) {
|
|
243
|
-
clearTimeout(timeout);
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
141
|
//# sourceMappingURL=generic-acp-agent.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Logger } from "pino";
|
|
2
|
-
import type { AgentCapabilityFlags, AgentClient, AgentFeature, AgentLaunchContext, AgentMode,
|
|
2
|
+
import type { AgentCapabilityFlags, AgentClient, AgentFeature, AgentLaunchContext, AgentMode, AgentPersistenceHandle, AgentPermissionRequest, AgentPermissionResponse, AgentPermissionResult, AgentPromptInput, AgentProvider, AgentRunOptions, AgentRunResult, AgentRuntimeInfo, AgentSession, AgentSessionConfig, AgentStreamEvent, FetchCatalogOptions, ImportableProviderSession, ImportProviderSessionContext, ImportProviderSessionInput, ProviderCatalog } from "../agent-sdk-types.js";
|
|
3
3
|
export declare const MOCK_LOAD_TEST_PROVIDER_ID = "mock";
|
|
4
4
|
export declare const MOCK_LOAD_TEST_DEFAULT_MODEL_ID = "five-minute-stream";
|
|
5
5
|
export declare class MockLoadTestAgentClient implements AgentClient {
|
|
@@ -9,8 +9,7 @@ export declare class MockLoadTestAgentClient implements AgentClient {
|
|
|
9
9
|
constructor(logger?: Logger | undefined);
|
|
10
10
|
createSession(config: AgentSessionConfig, _launchContext?: AgentLaunchContext): Promise<AgentSession>;
|
|
11
11
|
resumeSession(handle: AgentPersistenceHandle, overrides?: Partial<AgentSessionConfig>, _launchContext?: AgentLaunchContext): Promise<AgentSession>;
|
|
12
|
-
|
|
13
|
-
listModes(_options: ListModesOptions): Promise<AgentMode[]>;
|
|
12
|
+
fetchCatalog(_options: FetchCatalogOptions): Promise<ProviderCatalog>;
|
|
14
13
|
listImportableSessions(): Promise<ImportableProviderSession[]>;
|
|
15
14
|
importSession(input: ImportProviderSessionInput, context: ImportProviderSessionContext): Promise<import("../agent-sdk-types.js").ImportedProviderSession>;
|
|
16
15
|
isAvailable(): Promise<boolean>;
|
|
@@ -379,11 +379,11 @@ export class MockLoadTestAgentClient {
|
|
|
379
379
|
logger: this.logger,
|
|
380
380
|
});
|
|
381
381
|
}
|
|
382
|
-
async
|
|
383
|
-
return
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
382
|
+
async fetchCatalog(_options) {
|
|
383
|
+
return {
|
|
384
|
+
models: MODELS,
|
|
385
|
+
modes: getAgentProviderDefinition(MOCK_LOAD_TEST_PROVIDER_ID).modes,
|
|
386
|
+
};
|
|
387
387
|
}
|
|
388
388
|
async listImportableSessions() {
|
|
389
389
|
return [];
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import type { AgentCapabilityFlags, AgentClient, AgentLaunchContext,
|
|
1
|
+
import type { AgentCapabilityFlags, AgentClient, AgentLaunchContext, AgentPersistenceHandle, AgentProvider, AgentSession, AgentSessionConfig, FetchCatalogOptions, ProviderCatalog } from "../agent-sdk-types.js";
|
|
2
2
|
export declare const MOCK_SLOW_PROVIDER_ID = "mock-slow";
|
|
3
3
|
export declare class MockSlowProviderClient implements AgentClient {
|
|
4
4
|
readonly provider: AgentProvider;
|
|
5
5
|
readonly capabilities: AgentCapabilityFlags;
|
|
6
6
|
isAvailable(): Promise<boolean>;
|
|
7
|
-
|
|
8
|
-
listModes(_options: ListModesOptions): Promise<AgentMode[]>;
|
|
7
|
+
fetchCatalog(_options: FetchCatalogOptions): Promise<ProviderCatalog>;
|
|
9
8
|
getDiagnostic(): Promise<{
|
|
10
9
|
diagnostic: string;
|
|
11
10
|
}>;
|
|
@@ -19,17 +19,14 @@ export class MockSlowProviderClient {
|
|
|
19
19
|
this.capabilities = CAPABILITIES;
|
|
20
20
|
}
|
|
21
21
|
async isAvailable() {
|
|
22
|
-
return true;
|
|
22
|
+
return process.env.PASEO_ENABLE_MOCK_SLOW === "true";
|
|
23
23
|
}
|
|
24
|
-
|
|
25
|
-
return neverResolves();
|
|
26
|
-
}
|
|
27
|
-
listModes(_options) {
|
|
24
|
+
async fetchCatalog(_options) {
|
|
28
25
|
return neverResolves();
|
|
29
26
|
}
|
|
30
27
|
async getDiagnostic() {
|
|
31
28
|
return {
|
|
32
|
-
diagnostic: "Mock slow provider: dev-only.
|
|
29
|
+
diagnostic: "Mock slow provider: dev-only. fetchCatalog() never resolves so the snapshot manager will time out.",
|
|
33
30
|
};
|
|
34
31
|
}
|
|
35
32
|
createSession(_config, _launchContext) {
|