qlogicagent 1.3.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -0
- package/dist/agent.js +13 -13
- package/dist/cli.js +215 -208
- package/dist/index.js +214 -208
- package/dist/qlogicagent.cmd +2 -0
- package/dist/types/cli/main.d.ts +5 -1
- package/dist/types/cli/stdio-server.d.ts +55 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/llm/index.d.ts +1 -1
- package/dist/types/runtime/infra/acp-protocol-adapter.d.ts +72 -18
- package/dist/types/runtime/infra/acp-types.d.ts +30 -17
- package/dist/types/runtime/infra/agent-paths.d.ts +1 -1
- package/dist/types/runtime/infra/index.d.ts +2 -2
- package/dist/types/transport/acp-event-emitter.d.ts +21 -0
- package/dist/types/transport/acp-server.d.ts +130 -0
- package/dist/types/transport/index.d.ts +6 -0
- package/package.json +1 -1
package/dist/types/cli/main.d.ts
CHANGED
|
@@ -6,6 +6,10 @@
|
|
|
6
6
|
* All log/debug output goes to stderr (never pollutes the protocol).
|
|
7
7
|
*
|
|
8
8
|
* Usage:
|
|
9
|
-
* qlogicagent [--verbose]
|
|
9
|
+
* qlogicagent [--verbose] [--acp]
|
|
10
|
+
*
|
|
11
|
+
* Flags:
|
|
12
|
+
* --verbose Enable debug logging to stderr
|
|
13
|
+
* --acp Enable ACP (Agent-Client Protocol) server alongside legacy protocol
|
|
10
14
|
*/
|
|
11
15
|
export {};
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
* The physical I/O layer is abstracted via the Transport interface.
|
|
10
10
|
*/
|
|
11
11
|
import type { Transport } from "./transport.js";
|
|
12
|
+
import { AcpServer } from "../transport/acp-server.js";
|
|
12
13
|
export interface StdioServerConfig {
|
|
13
14
|
verbose: boolean;
|
|
14
15
|
transport?: Transport;
|
|
@@ -35,6 +36,8 @@ export declare class StdioServer {
|
|
|
35
36
|
private currentTransport;
|
|
36
37
|
private currentApiKey;
|
|
37
38
|
private currentModel;
|
|
39
|
+
private currentProvider;
|
|
40
|
+
private currentBaseUrl;
|
|
38
41
|
private sessionState;
|
|
39
42
|
private currentMediaApiKeys;
|
|
40
43
|
private taskStore;
|
|
@@ -43,6 +46,8 @@ export declare class StdioServer {
|
|
|
43
46
|
/** QMemory adapter (when QMEMORY_BASE_URL env is set). Used by Dream hippocampus bridge. */
|
|
44
47
|
private qmemoryAdapter;
|
|
45
48
|
private qmemoryUserId;
|
|
49
|
+
/** Local memory store for system prompt injection (CC memory parity). */
|
|
50
|
+
private memoryStore;
|
|
46
51
|
private fileWatcher;
|
|
47
52
|
/** Pending ask_user requests waiting for host response */
|
|
48
53
|
private pendingAskUser;
|
|
@@ -59,6 +64,20 @@ export declare class StdioServer {
|
|
|
59
64
|
/** Process managers for solo/product (stored for agents.processes/kill). */
|
|
60
65
|
private soloProcessManager;
|
|
61
66
|
private productProcessManager;
|
|
67
|
+
/** ACP Server instance — handles ACP protocol alongside legacy protocol. */
|
|
68
|
+
private acpServer;
|
|
69
|
+
/** Idle dream timer — fires after configurable idle period to trigger memory consolidation. */
|
|
70
|
+
private idleDreamTimer;
|
|
71
|
+
/** Idle dream config (minutes). Default: 30 min idle = trigger dream. */
|
|
72
|
+
private idleDreamMinutes;
|
|
73
|
+
/** Whether idle dream is enabled. Requires LLM config + memory root to be set. */
|
|
74
|
+
private idleDreamEnabled;
|
|
75
|
+
/** Last dream timestamp to enforce cooldown. */
|
|
76
|
+
private lastDreamAt;
|
|
77
|
+
/** Dream cooldown (ms). Default: 4 hours. */
|
|
78
|
+
private dreamCooldownMs;
|
|
79
|
+
/** Max dream duration (ms). Default: 5 minutes. */
|
|
80
|
+
private dreamMaxDurationMs;
|
|
62
81
|
constructor(config: StdioServerConfig);
|
|
63
82
|
start(): void;
|
|
64
83
|
stop(): void;
|
|
@@ -243,4 +262,40 @@ export declare class StdioServer {
|
|
|
243
262
|
private sendNotification;
|
|
244
263
|
private writeStdout;
|
|
245
264
|
private log;
|
|
265
|
+
/**
|
|
266
|
+
* Enable idle dream scheduling. Called after session setup when LLM config is available.
|
|
267
|
+
*/
|
|
268
|
+
enableIdleDream(minutes?: number): void;
|
|
269
|
+
private resetIdleDreamTimer;
|
|
270
|
+
private cancelIdleDreamTimer;
|
|
271
|
+
private triggerIdleDream;
|
|
272
|
+
/**
|
|
273
|
+
* Initialize the ACP server alongside the legacy protocol.
|
|
274
|
+
* Called once when the host is an ACP-compliant client.
|
|
275
|
+
*/
|
|
276
|
+
initAcpServer(): void;
|
|
277
|
+
/** Get the ACP server instance (for external wiring, e.g., main.ts). */
|
|
278
|
+
getAcpServer(): AcpServer | null;
|
|
279
|
+
private acpHandleInitialize;
|
|
280
|
+
private acpHandleSessionNew;
|
|
281
|
+
private acpHandleSessionPrompt;
|
|
282
|
+
/**
|
|
283
|
+
* Run a turn in ACP mode — streams events via session/update, returns final result.
|
|
284
|
+
* This duplicates the core logic of handleTurn but returns a promise with the final content.
|
|
285
|
+
*/
|
|
286
|
+
private runAcpTurn;
|
|
287
|
+
private acpHandleSessionEnd;
|
|
288
|
+
private acpHandleSessionSetConfig;
|
|
289
|
+
private acpHandleSessionSetModel;
|
|
290
|
+
private acpHandleSessionSetMode;
|
|
291
|
+
private acpHandlePermissionResponse;
|
|
292
|
+
private acpHandleAbort;
|
|
293
|
+
private acpHandleDream;
|
|
294
|
+
private acpHandleSoloStart;
|
|
295
|
+
private acpHandleSoloStatus;
|
|
296
|
+
private acpHandleSoloSelect;
|
|
297
|
+
private acpHandleProductCreate;
|
|
298
|
+
private acpHandleProductResume;
|
|
299
|
+
private acpHandleProductStatus;
|
|
300
|
+
private acpHandleTeamDelegate;
|
|
246
301
|
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export type { AgentConfig } from "./config/config.js";
|
|
|
10
10
|
export type { Transport } from "./cli/transport.js";
|
|
11
11
|
export { StdioTransport } from "./cli/transport.js";
|
|
12
12
|
export { StdioServer, type StdioServerConfig } from "./cli/stdio-server.js";
|
|
13
|
-
export { ProviderRegistry, createLLMClient,
|
|
13
|
+
export { ProviderRegistry, createLLMClient, } from "./llm/index.js";
|
|
14
14
|
export type { LLMTransport, LLMRequest, LLMChunk } from "./llm/index.js";
|
|
15
15
|
export { createHookRegistry } from "./runtime/hooks/hook-registry.js";
|
|
16
16
|
export { buildSkillInstruction, } from "./orchestration/index.js";
|
|
@@ -12,7 +12,7 @@ export { ProviderRegistry } from "./provider-registry.js";
|
|
|
12
12
|
export { BUILTIN_PROVIDERS } from "./builtin-providers.js";
|
|
13
13
|
export { ModelCatalog } from "./model-catalog.js";
|
|
14
14
|
export type { LLMClientConfig, LLMClient } from "./llm-client.js";
|
|
15
|
-
export { createLLMClient
|
|
15
|
+
export { createLLMClient } from "./llm-client.js";
|
|
16
16
|
export { OpenAIChatTransport } from "./transports/openai-chat.js";
|
|
17
17
|
export { AnthropicMessagesTransport } from "./transports/anthropic-messages.js";
|
|
18
18
|
export { GeminiGenerateContentTransport } from "./transports/gemini-generatecontent.js";
|
|
@@ -2,17 +2,54 @@
|
|
|
2
2
|
* ACP Protocol Adapter — translates between qlogicagent's internal JSON-RPC
|
|
3
3
|
* protocol and the ACP (Agent-Client Protocol) wire format.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* session/new → create session with workspaceRoot + mcpServers
|
|
8
|
-
* prompt → send task
|
|
9
|
-
* session/close → abort
|
|
10
|
-
* message notifications → turn.delta / turn.end
|
|
5
|
+
* Aligned with @agentclientprotocol/sdk v0.18.2 (PROTOCOL_VERSION = 1).
|
|
6
|
+
* Reference: AionUI ClientSideConnection, @agentclientprotocol/sdk.
|
|
11
7
|
*
|
|
12
|
-
*
|
|
8
|
+
* ACP = JSON-RPC 2.0 over NDJSON stdio:
|
|
9
|
+
* HOST → AGENT (requests):
|
|
10
|
+
* initialize, session/new, session/prompt, session/close, session/resume
|
|
11
|
+
* AGENT → HOST (notifications):
|
|
12
|
+
* session/update — carries { sessionId, update: { sessionUpdate: "...", ...payload } }
|
|
13
|
+
* AGENT → HOST (requests, host must respond):
|
|
14
|
+
* fs/read_text_file, fs/write_text_file, session/request_permission,
|
|
15
|
+
* session/elicitation, terminal/create, terminal/output, terminal/release,
|
|
16
|
+
* terminal/wait_for_exit, terminal/kill
|
|
13
17
|
*/
|
|
14
18
|
import type { ChildProcess } from "node:child_process";
|
|
15
19
|
import type { AcpInitializeResult, AcpSessionResult, AcpPromptResponse, McpServerConfig } from "./acp-types.js";
|
|
20
|
+
/**
|
|
21
|
+
* Handler for agent→host requests (fs, terminal, permission, elicitation).
|
|
22
|
+
* Host implementations should implement the methods they support.
|
|
23
|
+
*/
|
|
24
|
+
export interface AcpHostRequestHandler {
|
|
25
|
+
/** Read a text file from the host filesystem. */
|
|
26
|
+
readTextFile?(params: {
|
|
27
|
+
path: string;
|
|
28
|
+
}): Promise<{
|
|
29
|
+
content: string;
|
|
30
|
+
} | undefined>;
|
|
31
|
+
/** Write a text file on the host filesystem. */
|
|
32
|
+
writeTextFile?(params: {
|
|
33
|
+
path: string;
|
|
34
|
+
content: string;
|
|
35
|
+
}): Promise<Record<string, unknown> | undefined>;
|
|
36
|
+
/** Request permission for a tool call (return selected option). */
|
|
37
|
+
requestPermission?(params: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
38
|
+
/** Elicitation request (ask user for input). */
|
|
39
|
+
elicitation?(params: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
40
|
+
/** Create a terminal session. */
|
|
41
|
+
createTerminal?(params: Record<string, unknown>): Promise<Record<string, unknown> | undefined>;
|
|
42
|
+
/** Terminal output data. */
|
|
43
|
+
terminalOutput?(params: Record<string, unknown>): Promise<Record<string, unknown> | undefined>;
|
|
44
|
+
/** Release a terminal. */
|
|
45
|
+
releaseTerminal?(params: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
46
|
+
/** Wait for terminal exit. */
|
|
47
|
+
waitForTerminalExit?(params: Record<string, unknown>): Promise<Record<string, unknown> | undefined>;
|
|
48
|
+
/** Kill a terminal. */
|
|
49
|
+
killTerminal?(params: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
50
|
+
/** Extension method (unknown method from agent). */
|
|
51
|
+
extMethod?(method: string, params: unknown): Promise<unknown>;
|
|
52
|
+
}
|
|
16
53
|
/** Internal representation of an ACP notification translated to qlogicagent format. */
|
|
17
54
|
export interface TranslatedNotification {
|
|
18
55
|
method: string;
|
|
@@ -21,45 +58,59 @@ export interface TranslatedNotification {
|
|
|
21
58
|
export declare class AcpProtocolAdapter {
|
|
22
59
|
private pendingRpcs;
|
|
23
60
|
private rl;
|
|
61
|
+
private child;
|
|
24
62
|
private onNotification;
|
|
63
|
+
private hostHandler;
|
|
25
64
|
/**
|
|
26
65
|
* Attach to a child process's stdio for ACP communication.
|
|
27
66
|
* Must be called before any RPC methods.
|
|
67
|
+
*
|
|
68
|
+
* @param child The spawned ACP agent process
|
|
69
|
+
* @param onNotification Callback for agent notifications (session/update, etc.)
|
|
70
|
+
* @param hostHandler Optional handler for agent→host requests (fs, terminal, permission)
|
|
71
|
+
*/
|
|
72
|
+
attach(child: ChildProcess, onNotification?: (method: string, params: unknown) => void, hostHandler?: AcpHostRequestHandler): void;
|
|
73
|
+
/**
|
|
74
|
+
* Handle an incoming JSON-RPC request from the agent (reverse-RPC).
|
|
75
|
+
* Agent calls host for fs operations, terminal, permissions, etc.
|
|
28
76
|
*/
|
|
29
|
-
|
|
77
|
+
private handleAgentRequest;
|
|
30
78
|
/** Detach from the child process. */
|
|
31
79
|
detach(): void;
|
|
32
80
|
/** Send a raw JSON-RPC request and await response. */
|
|
33
81
|
sendRpc(child: ChildProcess, method: string, params?: unknown, timeoutMs?: number): Promise<unknown>;
|
|
34
82
|
/**
|
|
35
83
|
* Perform ACP initialize handshake.
|
|
36
|
-
*
|
|
37
|
-
* Extracts `supportsResume` from capabilities for D-1 session resume.
|
|
84
|
+
* Sends standard clientInfo + clientCapabilities (aligned with SDK).
|
|
38
85
|
*/
|
|
39
86
|
initialize(child: ChildProcess): Promise<AcpInitializeResult>;
|
|
40
87
|
/**
|
|
41
88
|
* Create an ACP session.
|
|
42
|
-
*
|
|
89
|
+
* Official SDK params: { cwd, mcpServers, additionalDirectories? }
|
|
90
|
+
* Optionally injects system prompt as extension field.
|
|
43
91
|
*/
|
|
44
92
|
createSession(child: ChildProcess, options: {
|
|
45
|
-
|
|
93
|
+
cwd: string;
|
|
46
94
|
mcpServers?: McpServerConfig[];
|
|
95
|
+
additionalDirectories?: string[];
|
|
47
96
|
systemPrompt?: string;
|
|
48
97
|
}): Promise<AcpSessionResult>;
|
|
49
98
|
/**
|
|
50
99
|
* Send a prompt to a running ACP session.
|
|
51
|
-
*
|
|
100
|
+
* Official SDK params: { sessionId, prompt: ContentBlock[], messageId? }
|
|
101
|
+
* Official SDK response: { stopReason, usage?, userMessageId? }
|
|
102
|
+
*
|
|
103
|
+
* Note: Actual content is delivered via session/update notifications DURING
|
|
104
|
+
* the prompt execution. The response only signals completion.
|
|
52
105
|
*/
|
|
53
106
|
sendPrompt(child: ChildProcess, sessionId: string, content: string, timeoutMs?: number): Promise<AcpPromptResponse>;
|
|
54
107
|
/**
|
|
55
|
-
* Resume an existing ACP session (
|
|
56
|
-
*
|
|
57
|
-
* Falls back to createSession + summary injection if session/resume fails.
|
|
108
|
+
* Resume an existing ACP session (loadSession capability).
|
|
109
|
+
* Official SDK method: session/load (same schema as session/new + sessionId).
|
|
58
110
|
*/
|
|
59
111
|
resumeSession(child: ChildProcess, sessionId: string, options?: {
|
|
60
|
-
|
|
112
|
+
cwd?: string;
|
|
61
113
|
mcpServers?: McpServerConfig[];
|
|
62
|
-
summary?: string;
|
|
63
114
|
}): Promise<AcpSessionResult>;
|
|
64
115
|
/**
|
|
65
116
|
* Close an ACP session.
|
|
@@ -68,6 +119,9 @@ export declare class AcpProtocolAdapter {
|
|
|
68
119
|
/**
|
|
69
120
|
* Translate an ACP notification into qlogicagent's internal format.
|
|
70
121
|
* Returns null if the notification is not translatable (handled separately).
|
|
122
|
+
*
|
|
123
|
+
* Standard ACP: agent sends "session/update" notification with
|
|
124
|
+
* params: { sessionId, update: { sessionUpdate: "<type>", ...payload } }
|
|
71
125
|
*/
|
|
72
126
|
static translateNotification(method: string, params: unknown): TranslatedNotification | null;
|
|
73
127
|
}
|
|
@@ -136,39 +136,52 @@ export interface AgentConfigStoreData {
|
|
|
136
136
|
/** ACP initialize result (from agent's response). */
|
|
137
137
|
export interface AcpInitializeResult {
|
|
138
138
|
protocolVersion: number;
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
139
|
+
/** Standard ACP agentCapabilities (official SDK field). */
|
|
140
|
+
agentCapabilities: {
|
|
141
|
+
loadSession?: boolean;
|
|
142
|
+
mcpCapabilities?: {
|
|
143
|
+
http?: boolean;
|
|
144
|
+
sse?: boolean;
|
|
145
|
+
};
|
|
146
|
+
promptCapabilities?: {
|
|
147
|
+
audio?: boolean;
|
|
148
|
+
embeddedContext?: boolean;
|
|
149
|
+
image?: boolean;
|
|
150
|
+
};
|
|
151
|
+
sessionCapabilities?: Record<string, unknown>;
|
|
143
152
|
[key: string]: unknown;
|
|
144
153
|
};
|
|
145
|
-
|
|
154
|
+
/** Standard ACP agentInfo (official SDK field). */
|
|
155
|
+
agentInfo?: {
|
|
146
156
|
name: string;
|
|
147
157
|
version?: string;
|
|
148
158
|
};
|
|
159
|
+
authMethods?: Array<{
|
|
160
|
+
type: string;
|
|
161
|
+
[key: string]: unknown;
|
|
162
|
+
}>;
|
|
149
163
|
}
|
|
150
|
-
/** ACP session/new result. */
|
|
164
|
+
/** ACP session/new result (official: { sessionId, configOptions?, models?, modes? }). */
|
|
151
165
|
export interface AcpSessionResult {
|
|
152
|
-
|
|
166
|
+
sessionId: string;
|
|
153
167
|
}
|
|
154
|
-
/** ACP
|
|
155
|
-
export
|
|
156
|
-
|
|
157
|
-
text?: string;
|
|
158
|
-
data?: string;
|
|
159
|
-
mimeType?: string;
|
|
160
|
-
}
|
|
161
|
-
/** ACP prompt response. */
|
|
168
|
+
/** Standard ACP stopReason. */
|
|
169
|
+
export type AcpStopReason = "end_turn" | "max_tokens" | "max_turn_requests" | "refusal" | "cancelled";
|
|
170
|
+
/** ACP prompt response (official: { stopReason, usage?, userMessageId? }). */
|
|
162
171
|
export interface AcpPromptResponse {
|
|
163
|
-
|
|
172
|
+
stopReason: AcpStopReason;
|
|
164
173
|
usage?: AcpPromptResponseUsage;
|
|
174
|
+
userMessageId?: string;
|
|
175
|
+
/** Aggregated text from session/update notifications (populated by adapter). */
|
|
176
|
+
text?: string;
|
|
165
177
|
}
|
|
166
|
-
/** ACP per-turn usage stats. */
|
|
178
|
+
/** ACP per-turn usage stats (aligned with SDK zUsage). */
|
|
167
179
|
export interface AcpPromptResponseUsage {
|
|
168
180
|
inputTokens?: number;
|
|
169
181
|
outputTokens?: number;
|
|
170
182
|
totalTokens?: number;
|
|
171
183
|
cachedReadTokens?: number;
|
|
184
|
+
cachedWriteTokens?: number;
|
|
172
185
|
thoughtTokens?: number;
|
|
173
186
|
}
|
|
174
187
|
/** ACP usage_update notification payload (session-level). */
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
/** Dot-directory name used for both user-level and project-level storage. */
|
|
9
9
|
export declare const AGENT_DOT_DIR = ".qlogicagent";
|
|
10
|
-
/** `~/.qlogicagent/` */
|
|
10
|
+
/** `~/.qlogicagent/` (or QLOGICAGENT_HOME override) */
|
|
11
11
|
export declare function getUserAgentHome(): string;
|
|
12
12
|
/** `~/.qlogicagent/sessions/` */
|
|
13
13
|
export declare function getUserSessionsRoot(): string;
|
|
@@ -7,12 +7,12 @@ export { createWorktreeBackend } from "./worktree-backend.js";
|
|
|
7
7
|
export { registerCleanup, runCleanupFunctions } from "./cleanup-registry.js";
|
|
8
8
|
export { atomicWriteFile, readJsonFile, writeJsonFile, loadPersistedMemory, savePersistedMemory, getMemoryFilePath, type PersistedMemory, } from "./disk-storage.js";
|
|
9
9
|
export { AcpDetector, ACP_BACKENDS } from "./acp-detector.js";
|
|
10
|
-
export { AcpProtocolAdapter, type TranslatedNotification } from "./acp-protocol-adapter.js";
|
|
10
|
+
export { AcpProtocolAdapter, type TranslatedNotification, type AcpHostRequestHandler } from "./acp-protocol-adapter.js";
|
|
11
11
|
export { AcpUsageTracker, type AccumulatedUsage } from "./acp-usage-tracker.js";
|
|
12
12
|
export { AgentConfigStore } from "./agent-config-store.js";
|
|
13
13
|
export { ModelIdTranslator } from "./model-id-translator.js";
|
|
14
14
|
export { SkillInjector } from "./skill-injector.js";
|
|
15
15
|
export { ACP_FAULT_LEVEL, type AcpFaultLevel, buildLlmEnvForTeammate } from "./agent-process.js";
|
|
16
16
|
export { McpBridge, MCP_BRIDGE_TOOLS } from "./mcp-bridge.js";
|
|
17
|
-
export type { AgentCategory, AgentProtocol, AgentStatus, AcpBackendConfig, AgentDescriptor, ExternalAgentDescriptor, CustomAgentDef, AgentConfig, AgentConfigStoreData, AgentCapabilities, AcpInitializeResult, AcpSessionResult, AcpPromptResponse,
|
|
17
|
+
export type { AgentCategory, AgentProtocol, AgentStatus, AcpBackendConfig, AgentDescriptor, ExternalAgentDescriptor, CustomAgentDef, AgentConfig, AgentConfigStoreData, AgentCapabilities, AcpInitializeResult, AcpSessionResult, AcpPromptResponse, AcpPromptResponseUsage, AcpStopReason, AcpUsageUpdatePayload, McpServerConfig, AgentsScanParams, AgentsConfigParams, AgentsSetConfigParams, AgentsGetConfigParams, AgentsRemoveConfigParams, AgentsSetGatewayParams, SoloState, SoloAgentState, SoloAgentResult, SoloEvaluation, SoloStatus, SoloStartParams, SoloIdParams, SoloSelectParams, ProductPhase, ProductInstanceState, ProductTaskStatus, ProductBudget, ProductInstanceDef, ProductTaskDef, ProductCreateParams, ProductIdParams, ProductInstanceStatus, ProductTaskState, ProductStatus, ProductSummary, AgentsGetGatewayResult, AgentsListConfiguredItem, AgentsProcessInfo, AgentsKillParams, AgentsGetLogParams, AgentsGetLogResult, AgentsTestConnectionParams, AgentsTestConnectionResult, SoloDeleteParams, ProductDeleteParams, AgentSource, } from "./acp-types.js";
|
|
18
18
|
export type { AgentsStatusNotification, AgentsErrorNotification, SoloProgressNotification, SoloEvaluationNotification, SoloAgentDeltaNotification, ProductTaskStartedNotification, ProductTaskCompletedNotification, ProductTaskFailedNotification, ProductCheckpointedNotification, ProductBudgetWarningNotification, ProductCompletedNotification, } from "../../protocol/notifications.js";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ACP Event Emitter — translates internal qlogicagent notifications to ACP
|
|
3
|
+
* session/update notifications.
|
|
4
|
+
*
|
|
5
|
+
* Maps the 47+ internal notification methods (turn.delta, turn.tool_call, etc.)
|
|
6
|
+
* to 9 standard + 19 extended ACP sessionUpdate types.
|
|
7
|
+
*
|
|
8
|
+
* Usage: Called by the StdioServer event loop. Instead of (or in addition to)
|
|
9
|
+
* emitting raw notifications, events are translated and emitted through the
|
|
10
|
+
* AcpServer.emitSessionUpdate() method.
|
|
11
|
+
*/
|
|
12
|
+
import type { AcpServer } from "./acp-server.js";
|
|
13
|
+
/**
|
|
14
|
+
* Translates and emits a qlogicagent internal notification as an ACP session/update.
|
|
15
|
+
*
|
|
16
|
+
* @param server The AcpServer instance to emit through
|
|
17
|
+
* @param sessionId Active ACP session ID
|
|
18
|
+
* @param method Internal notification method name
|
|
19
|
+
* @param params Internal notification payload
|
|
20
|
+
*/
|
|
21
|
+
export declare function emitAcpUpdate(server: AcpServer, sessionId: string, method: string, params: Record<string, unknown>): void;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ACP Server — Agent-Client Protocol server layer for qlogicagent.
|
|
3
|
+
*
|
|
4
|
+
* This module implements qlogicagent as an ACP Server, allowing any ACP-compliant
|
|
5
|
+
* host (AionUI, Cursor, openclaw, etc.) to connect and interact with the agent.
|
|
6
|
+
*
|
|
7
|
+
* Protocol: ACP v1 over JSON-RPC 2.0 / stdio (line-delimited JSON).
|
|
8
|
+
*
|
|
9
|
+
* Responsibilities:
|
|
10
|
+
* - Accepts ACP standard methods: initialize, session/new, session/prompt, session/end
|
|
11
|
+
* - Accepts x/ extended methods: x/abort, x/dream, x/solo.*, x/product.*
|
|
12
|
+
* - Emits ACP session/update notifications (standard + x_ extended)
|
|
13
|
+
* - Translates host permission responses back to the agent
|
|
14
|
+
*
|
|
15
|
+
* Architecture: AcpServer wraps a Transport and delegates to an AcpRequestHandler
|
|
16
|
+
* interface. The StdioServer implements this interface by routing ACP methods to
|
|
17
|
+
* existing internal handlers.
|
|
18
|
+
*/
|
|
19
|
+
import type { Transport } from "../cli/transport.js";
|
|
20
|
+
import { type AcpInitializeParams, type AcpInitializeResult, type AcpSessionNewParams, type AcpSessionNewResult, type AcpSessionPromptParams, type AcpSessionPromptResult, type AcpSessionEndParams, type AcpSessionSetConfigParams, type AcpSessionUpdateType, type AcpPermissionRequestParams, type AcpPermissionRequestResult } from "qlogicagent-runtime-contracts";
|
|
21
|
+
export declare const ACP_ERROR_CODES: {
|
|
22
|
+
readonly PARSE_ERROR: -32700;
|
|
23
|
+
readonly INVALID_REQUEST: -32600;
|
|
24
|
+
readonly METHOD_NOT_FOUND: -32601;
|
|
25
|
+
readonly INVALID_PARAMS: -32602;
|
|
26
|
+
readonly INTERNAL_ERROR: -32603;
|
|
27
|
+
/** Protocol version mismatch */
|
|
28
|
+
readonly PROTOCOL_MISMATCH: -32001;
|
|
29
|
+
/** Session not found */
|
|
30
|
+
readonly SESSION_NOT_FOUND: -32002;
|
|
31
|
+
/** Agent busy (turn in progress) */
|
|
32
|
+
readonly AGENT_BUSY: -32003;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Interface that StdioServer (or any backend) implements to handle ACP requests.
|
|
36
|
+
* Each method corresponds to an ACP protocol method.
|
|
37
|
+
*/
|
|
38
|
+
export interface AcpRequestHandler {
|
|
39
|
+
handleAcpInitialize(params: AcpInitializeParams): Promise<AcpInitializeResult>;
|
|
40
|
+
handleAcpSessionNew(params: AcpSessionNewParams): Promise<AcpSessionNewResult>;
|
|
41
|
+
handleAcpSessionPrompt(params: AcpSessionPromptParams): Promise<AcpSessionPromptResult>;
|
|
42
|
+
handleAcpSessionEnd(params: AcpSessionEndParams): Promise<void>;
|
|
43
|
+
handleAcpSessionSetConfig(params: AcpSessionSetConfigParams): Promise<void>;
|
|
44
|
+
handleAcpSessionSetModel(sessionId: string, model: string): Promise<void>;
|
|
45
|
+
handleAcpSessionSetMode(sessionId: string, mode: string): Promise<void>;
|
|
46
|
+
handleAcpPermissionResponse(permissionId: string, optionId: string): void;
|
|
47
|
+
handleAcpAbort(params: {
|
|
48
|
+
sessionId: string;
|
|
49
|
+
}): Promise<void>;
|
|
50
|
+
handleAcpDream(params: {
|
|
51
|
+
sessionId: string;
|
|
52
|
+
config?: Record<string, unknown>;
|
|
53
|
+
}): Promise<{
|
|
54
|
+
ok: boolean;
|
|
55
|
+
summary?: string;
|
|
56
|
+
}>;
|
|
57
|
+
handleAcpSoloStart(params: Record<string, unknown>): Promise<unknown>;
|
|
58
|
+
handleAcpSoloStatus(params: Record<string, unknown>): Promise<unknown>;
|
|
59
|
+
handleAcpSoloSelect(params: Record<string, unknown>): Promise<unknown>;
|
|
60
|
+
handleAcpProductCreate(params: Record<string, unknown>): Promise<unknown>;
|
|
61
|
+
handleAcpProductResume(params: Record<string, unknown>): Promise<unknown>;
|
|
62
|
+
handleAcpProductStatus(params: Record<string, unknown>): Promise<unknown>;
|
|
63
|
+
handleAcpTeamDelegate(params: Record<string, unknown>): Promise<unknown>;
|
|
64
|
+
}
|
|
65
|
+
export interface AcpServerConfig {
|
|
66
|
+
verbose?: boolean;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* AcpServer — manages the ACP protocol state machine.
|
|
70
|
+
*
|
|
71
|
+
* Lifecycle:
|
|
72
|
+
* 1. Host connects (stdio)
|
|
73
|
+
* 2. Host sends `initialize` → agent responds with capabilities
|
|
74
|
+
* 3. Host sends `session/new` → session created
|
|
75
|
+
* 4. Host sends `session/prompt` → agent runs turn, emits session/update notifications
|
|
76
|
+
* 5. Host sends `session/end` → session cleaned up
|
|
77
|
+
*/
|
|
78
|
+
export declare class AcpServer {
|
|
79
|
+
private transport;
|
|
80
|
+
private handler;
|
|
81
|
+
private verbose;
|
|
82
|
+
/** Host capabilities declared during initialize */
|
|
83
|
+
private hostCapabilities;
|
|
84
|
+
/** Whether the host supports x_ extended events */
|
|
85
|
+
private hostSupportsExtendedEvents;
|
|
86
|
+
/** Whether the host supports x/ extended RPC methods */
|
|
87
|
+
private hostSupportsExtendedMethods;
|
|
88
|
+
/** Active session ID (ACP v1 = single session per connection) */
|
|
89
|
+
private activeSessionId;
|
|
90
|
+
/** Pending permission requests (agent → host) waiting for response */
|
|
91
|
+
private pendingPermissions;
|
|
92
|
+
constructor(transport: Transport, handler: AcpRequestHandler, config?: AcpServerConfig);
|
|
93
|
+
/**
|
|
94
|
+
* Route an incoming raw message through ACP protocol handling.
|
|
95
|
+
* Called by the unified message dispatcher in StdioServer.
|
|
96
|
+
* Returns true if the message was handled, false otherwise.
|
|
97
|
+
*/
|
|
98
|
+
dispatchMessage(raw: unknown): boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Emit an ACP session/update notification to the host.
|
|
101
|
+
* Standard update types are always sent; x_ types only if host declared
|
|
102
|
+
* capabilities.extendedEvents = true.
|
|
103
|
+
*/
|
|
104
|
+
emitSessionUpdate(sessionId: string, type: AcpSessionUpdateType, payload: Record<string, unknown>): void;
|
|
105
|
+
/**
|
|
106
|
+
* Send a permission request to the host (agent → host RPC).
|
|
107
|
+
* Returns a promise that resolves with the host's chosen option.
|
|
108
|
+
*/
|
|
109
|
+
requestPermission(params: AcpPermissionRequestParams): Promise<AcpPermissionRequestResult>;
|
|
110
|
+
/** Whether the host supports extended events */
|
|
111
|
+
get supportsExtendedEvents(): boolean;
|
|
112
|
+
/** Whether the host supports extended methods */
|
|
113
|
+
get supportsExtendedMethods(): boolean;
|
|
114
|
+
/** Get the active session ID */
|
|
115
|
+
get sessionId(): string | null;
|
|
116
|
+
private handleRequest;
|
|
117
|
+
private handleNotification;
|
|
118
|
+
private handleResponse;
|
|
119
|
+
private onInitialize;
|
|
120
|
+
private onSessionNew;
|
|
121
|
+
private onSessionPrompt;
|
|
122
|
+
private onSessionEnd;
|
|
123
|
+
private onSessionSetConfig;
|
|
124
|
+
private onAbort;
|
|
125
|
+
private onDream;
|
|
126
|
+
private sendResult;
|
|
127
|
+
private sendError;
|
|
128
|
+
private isJsonRpcResponse;
|
|
129
|
+
private log;
|
|
130
|
+
}
|