qlogicagent 2.3.0 → 2.4.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/dist/agent.js +6 -6
- package/dist/cli.js +212 -211
- package/dist/index.js +211 -210
- package/dist/orchestration.js +2 -2
- package/dist/protocol.js +1 -0
- package/dist/types/agent/tunable-defaults.d.ts +4 -0
- package/dist/types/agent/types.d.ts +24 -100
- package/dist/types/cli/stdio-server.d.ts +7 -0
- package/dist/types/cli/tool-bootstrap.d.ts +6 -0
- package/dist/types/contracts/index.d.ts +2 -3
- package/dist/types/llm/provider-def.d.ts +3 -0
- package/dist/types/llm/transport.d.ts +25 -25
- package/dist/types/llm/transports/anthropic-messages.d.ts +2 -2
- package/dist/types/llm/transports/gemini-generatecontent.d.ts +2 -2
- package/dist/types/llm/transports/openai-chat.d.ts +2 -2
- package/dist/types/llm/transports/openai-responses.d.ts +9 -9
- package/dist/types/llm/transports/volcengine-responses.d.ts +11 -11
- package/dist/types/orchestration/agent-instance.d.ts +15 -0
- package/dist/types/orchestration/solo-evaluator.d.ts +7 -0
- package/dist/types/orchestration/tool-loop/tool-choice-policy.d.ts +1 -1
- package/dist/types/protocol/methods.d.ts +143 -53
- package/dist/types/protocol/notifications.d.ts +4 -514
- package/dist/types/protocol/wire/acp-protocol.d.ts +411 -0
- package/dist/types/protocol/wire/agent-events.d.ts +32 -0
- package/dist/types/protocol/wire/agent-methods.d.ts +587 -0
- package/dist/types/protocol/wire/agent-rpc.d.ts +97 -0
- package/dist/types/protocol/wire/capability-manifest.d.ts +111 -0
- package/dist/types/protocol/wire/capability-transport.d.ts +207 -0
- package/dist/types/protocol/wire/channel-ingress.d.ts +29 -0
- package/dist/types/protocol/wire/channel.d.ts +89 -0
- package/dist/types/protocol/wire/chat-types.d.ts +87 -0
- package/dist/types/protocol/wire/checkpoint-runtime.d.ts +61 -0
- package/dist/types/protocol/wire/checkpoint.d.ts +72 -0
- package/dist/types/protocol/wire/execution.d.ts +391 -0
- package/dist/types/protocol/wire/gateway-rpc.d.ts +314 -0
- package/dist/types/protocol/wire/gateway.d.ts +62 -0
- package/dist/types/protocol/wire/hook-protocol.d.ts +37 -0
- package/dist/types/protocol/wire/index.d.ts +25 -0
- package/dist/types/protocol/wire/memory-provider-lifecycle.d.ts +80 -0
- package/dist/types/protocol/wire/notification-payloads.d.ts +581 -0
- package/dist/types/protocol/wire/provider-runtime-contract.d.ts +66 -0
- package/dist/types/protocol/wire/provider-runtime-core.d.ts +147 -0
- package/dist/types/protocol/wire/provider-runtime-io.d.ts +20 -0
- package/dist/types/protocol/wire/resource-manifest.d.ts +68 -0
- package/dist/types/protocol/wire/session.d.ts +32 -0
- package/dist/types/protocol/wire/thread-protocol.d.ts +157 -0
- package/dist/types/protocol/wire/transport.d.ts +57 -0
- package/dist/types/protocol/wire/turn.d.ts +208 -0
- package/dist/types/protocol/wire/web-capability.d.ts +51 -0
- package/dist/types/runtime/hooks/memory-hooks.d.ts +2 -2
- package/dist/types/runtime/infra/acp-types.d.ts +3 -142
- package/dist/types/runtime/infra/token-budget.d.ts +3 -3
- package/dist/types/runtime/session/index.d.ts +1 -1
- package/dist/types/runtime/session/session-memory.d.ts +46 -0
- package/dist/types/runtime/session/session-persistence.d.ts +34 -8
- package/dist/types/runtime/session/session-state.d.ts +4 -4
- package/dist/types/skills/memory/memory-tool.d.ts +1 -1
- package/dist/types/skills/memory/qmemory-adapter.d.ts +1 -1
- package/dist/types/skills/permissions/hook-runner.d.ts +4 -4
- package/dist/types/skills/permissions/permission-classifier.d.ts +2 -2
- package/dist/types/skills/tools/project-switch-tool.d.ts +24 -0
- package/dist/types/skills/tools.d.ts +5 -5
- package/dist/types/transport/acp-event-emitter.d.ts +1 -1
- package/dist/types/transport/acp-server.d.ts +17 -10
- package/package.json +14 -3
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export declare const WEB_CAPABILITY_ID_VALUES: readonly ["web_search", "web_fetch", "deep_research", "browser_execution"];
|
|
2
|
+
export type WebCapabilityId = (typeof WEB_CAPABILITY_ID_VALUES)[number];
|
|
3
|
+
export declare const WEB_CAPABILITY_FAMILY_VALUES: readonly ["web-intelligence", "browser-execution"];
|
|
4
|
+
export type WebCapabilityFamily = (typeof WEB_CAPABILITY_FAMILY_VALUES)[number];
|
|
5
|
+
export declare const WEB_TASK_MODE_VALUES: readonly ["discovery", "read-url", "multi-source-research", "interactive-browser"];
|
|
6
|
+
export type WebTaskMode = (typeof WEB_TASK_MODE_VALUES)[number];
|
|
7
|
+
export declare const WEB_EXECUTION_MODE_VALUES: readonly ["stateless", "render-backend", "interactive-session"];
|
|
8
|
+
export type WebExecutionMode = (typeof WEB_EXECUTION_MODE_VALUES)[number];
|
|
9
|
+
export declare const WEB_STATEFULNESS_VALUES: readonly ["stateless", "stateless-single-step", "stateful-session-required"];
|
|
10
|
+
export type WebStatefulness = (typeof WEB_STATEFULNESS_VALUES)[number];
|
|
11
|
+
export declare const WEB_APPROVAL_DEFAULT_VALUES: readonly ["required", "conditional", "none"];
|
|
12
|
+
export type WebApprovalDefault = (typeof WEB_APPROVAL_DEFAULT_VALUES)[number];
|
|
13
|
+
export declare const WEB_POLICY_RISK_CLASS_VALUES: readonly ["browser-read", "browser-authenticated-read", "browser-state-changing"];
|
|
14
|
+
export type WebPolicyRiskClass = (typeof WEB_POLICY_RISK_CLASS_VALUES)[number];
|
|
15
|
+
export declare const WEB_ACTION_SCOPE_VALUES: readonly ["read-page", "read-authenticated-page", "fill-form", "submit-form", "download-file", "reuse-session"];
|
|
16
|
+
export type WebActionScope = (typeof WEB_ACTION_SCOPE_VALUES)[number];
|
|
17
|
+
export declare const WEB_DEGRADATION_TARGET_VALUES: readonly ["web_search", "web_fetch", "deep_research", "blocked"];
|
|
18
|
+
export type WebDegradationTarget = (typeof WEB_DEGRADATION_TARGET_VALUES)[number];
|
|
19
|
+
export declare const WEB_ESCALATION_REASON_VALUES: readonly ["requires-interaction", "requires-login-state", "requires-rendered-dom", "requires-persistent-session", "requires-state-changing-action"];
|
|
20
|
+
export type WebEscalationReason = (typeof WEB_ESCALATION_REASON_VALUES)[number];
|
|
21
|
+
export declare const WEB_RETRY_POLICY_VALUES: readonly ["none", "same-capability-once", "degrade-only"];
|
|
22
|
+
export type WebRetryPolicy = (typeof WEB_RETRY_POLICY_VALUES)[number];
|
|
23
|
+
export interface WebCapabilityDescriptorContract {
|
|
24
|
+
capabilityId?: WebCapabilityId;
|
|
25
|
+
capabilityFamily?: WebCapabilityFamily;
|
|
26
|
+
taskMode?: WebTaskMode;
|
|
27
|
+
executionMode?: WebExecutionMode;
|
|
28
|
+
statefulness?: WebStatefulness;
|
|
29
|
+
approvalDefault?: WebApprovalDefault;
|
|
30
|
+
policyRiskClass?: WebPolicyRiskClass;
|
|
31
|
+
requiresRuntimeBackend?: boolean;
|
|
32
|
+
requiresHostBridge?: boolean;
|
|
33
|
+
supportsRenderBackend?: boolean;
|
|
34
|
+
supportsLoginState?: boolean;
|
|
35
|
+
supportsPersistentProfile?: boolean;
|
|
36
|
+
supportsSharedSessionReuse?: boolean;
|
|
37
|
+
supportsTransactionality?: "read-only" | "state-changing";
|
|
38
|
+
allowedActionScopes?: WebActionScope[];
|
|
39
|
+
degradationTarget?: WebDegradationTarget;
|
|
40
|
+
upgradeTargets?: WebCapabilityId[];
|
|
41
|
+
fallbackChain?: Array<"render-backend">;
|
|
42
|
+
escalationReasons?: WebEscalationReason[];
|
|
43
|
+
auditRequired?: boolean;
|
|
44
|
+
requiresUserVisibleStep?: boolean;
|
|
45
|
+
retryPolicy?: WebRetryPolicy;
|
|
46
|
+
repairAfterDenied?: boolean;
|
|
47
|
+
repairAfterUnavailable?: boolean;
|
|
48
|
+
displayRiskLabel?: string;
|
|
49
|
+
displayBlockedLabel?: string;
|
|
50
|
+
displayFallbackLabel?: string;
|
|
51
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { HookRegistry } from "../../contracts/hooks.js";
|
|
2
|
-
import type { MemoryProvider } from "
|
|
2
|
+
import type { MemoryProvider } from "../../protocol/wire/index.js";
|
|
3
3
|
import type { Memdir } from "../../skills/memory/memdir.js";
|
|
4
4
|
export declare const MEMORY_PREFETCH_CONFIG: {
|
|
5
5
|
readonly MAX_SESSION_BYTES: number;
|
|
@@ -43,7 +43,7 @@ export declare function createMemoryPrefetchState(): MemoryPrefetchState;
|
|
|
43
43
|
* Returns a cleanup function to unregister.
|
|
44
44
|
*/
|
|
45
45
|
export declare function registerMemoryHooks(hooks: HookRegistry, deps: MemoryHooksDeps,
|
|
46
|
-
/** Shared state
|
|
46
|
+
/** Shared state 鈥?pass the same object across hook re-registrations in a session. */
|
|
47
47
|
prefetchState?: MemoryPrefetchState): () => void;
|
|
48
48
|
export interface MemdirRecallHookDeps {
|
|
49
49
|
/** MEMDIR instance (lazy: may be null at registration time). */
|
|
@@ -4,16 +4,8 @@
|
|
|
4
4
|
* These types define the contract for discovering, registering, and managing
|
|
5
5
|
* external ACP-compatible agent CLIs alongside qlogicagent's internal agents.
|
|
6
6
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
* - sub-agent: internal qlogicagent instance, budget/tool restricted
|
|
10
|
-
* - teammate: external ACP CLI agent, full capability
|
|
11
|
-
*/
|
|
12
|
-
export type AgentCategory = "sub-agent" | "teammate";
|
|
13
|
-
/** Communication protocol with the agent. */
|
|
14
|
-
export type AgentProtocol = "internal" | "acp";
|
|
15
|
-
/** Agent availability status. */
|
|
16
|
-
export type AgentStatus = "available" | "unavailable" | "handshake_failed" | "not_installed";
|
|
7
|
+
import type { AgentCapabilities, CustomAgentDef, AgentConfig, ProductTaskStatus, ProductInstanceDef, ProductTaskDef } from "../../protocol/wire/index.js";
|
|
8
|
+
export type { AgentCategory, AgentProtocol, AgentStatus, AgentCapabilities, AgentDescriptor, CustomAgentDef, AgentConfig, SoloState, SoloAgentState, SoloAgentResult, SoloStatus, ProductPhase, ProductTaskStatus, ProductInstanceDef, ProductTaskDef, ProductStatus, ProductSummary, } from "../../protocol/wire/index.js";
|
|
17
9
|
/** Pre-defined configuration for a known ACP backend. */
|
|
18
10
|
export interface AcpBackendConfig {
|
|
19
11
|
/** Backend ID, e.g. "claude" | "codex" | "goose". */
|
|
@@ -39,45 +31,6 @@ export interface AcpBackendConfig {
|
|
|
39
31
|
/** Environment variable name for the base URL. */
|
|
40
32
|
baseUrlEnvVar?: string;
|
|
41
33
|
}
|
|
42
|
-
/** Capabilities discovered during ACP handshake. */
|
|
43
|
-
export interface AgentCapabilities {
|
|
44
|
-
/** Whether the agent supports MCP server injection via session/new. */
|
|
45
|
-
supportsMcp: boolean;
|
|
46
|
-
/** Whether the agent supports session/resume. */
|
|
47
|
-
supportsResume: boolean;
|
|
48
|
-
/** Whether the agent sends usage_update notifications. */
|
|
49
|
-
supportsUsageUpdate: boolean;
|
|
50
|
-
/** Native skill directories, if any. */
|
|
51
|
-
skillsDirs?: string[];
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Descriptor for a discovered or registered agent.
|
|
55
|
-
* Returned by `agents.scan` and `agents.list` RPCs.
|
|
56
|
-
*/
|
|
57
|
-
export interface AgentDescriptor {
|
|
58
|
-
/** Backend ID, e.g. "claude", "codex", "qlogicagent". */
|
|
59
|
-
id: string;
|
|
60
|
-
/** Display name. */
|
|
61
|
-
name: string;
|
|
62
|
-
/** sub-agent (internal) or teammate (external). */
|
|
63
|
-
category: AgentCategory;
|
|
64
|
-
/** Communication protocol. */
|
|
65
|
-
protocol: AgentProtocol;
|
|
66
|
-
/** Current availability. */
|
|
67
|
-
status: AgentStatus;
|
|
68
|
-
/** Resolved CLI binary path (teammates only). */
|
|
69
|
-
cliPath?: string;
|
|
70
|
-
/** CLI version string (teammates only). */
|
|
71
|
-
version?: string;
|
|
72
|
-
/** Capabilities (populated after handshake). */
|
|
73
|
-
capabilities?: AgentCapabilities;
|
|
74
|
-
/** Whether auth is required. */
|
|
75
|
-
authRequired: boolean;
|
|
76
|
-
/** Whether user has configured this agent (apiKey / baseUrl). */
|
|
77
|
-
hasConfig: boolean;
|
|
78
|
-
/** Whether this agent supports LLM base URL redirection. */
|
|
79
|
-
supportsBaseUrlOverride: boolean;
|
|
80
|
-
}
|
|
81
34
|
/**
|
|
82
35
|
* Extended descriptor for external agents,
|
|
83
36
|
* used internally by AgentProcessManager to spawn.
|
|
@@ -94,36 +47,6 @@ export interface ExternalAgentDescriptor {
|
|
|
94
47
|
/** Communication protocol. */
|
|
95
48
|
protocol: "acp";
|
|
96
49
|
}
|
|
97
|
-
/** User-provided custom agent definition for agents.config RPC. */
|
|
98
|
-
export interface CustomAgentDef {
|
|
99
|
-
/** Unique ID (user-chosen). */
|
|
100
|
-
id: string;
|
|
101
|
-
/** Display name. */
|
|
102
|
-
name: string;
|
|
103
|
-
/** CLI command or absolute path. */
|
|
104
|
-
cliCommand: string;
|
|
105
|
-
/** ACP mode launch arguments. */
|
|
106
|
-
acpArgs: string[];
|
|
107
|
-
/** Additional environment variables. */
|
|
108
|
-
env?: Record<string, string>;
|
|
109
|
-
/** Whether auth is required. */
|
|
110
|
-
authRequired?: boolean;
|
|
111
|
-
/** Native skill directories. */
|
|
112
|
-
skillsDirs?: string[];
|
|
113
|
-
/** Whether base URL override is supported. */
|
|
114
|
-
supportsBaseUrlOverride?: boolean;
|
|
115
|
-
}
|
|
116
|
-
/** Persisted per-agent configuration. */
|
|
117
|
-
export interface AgentConfig {
|
|
118
|
-
apiKey?: string;
|
|
119
|
-
baseUrl?: string;
|
|
120
|
-
model?: string;
|
|
121
|
-
env?: Record<string, string>;
|
|
122
|
-
customArgs?: string[];
|
|
123
|
-
customCliPath?: string;
|
|
124
|
-
/** Model ID translation: qlogicModelId → externalModelId. */
|
|
125
|
-
modelIdMap?: Record<string, string>;
|
|
126
|
-
}
|
|
127
50
|
/** Root config store schema (persisted to JSON). */
|
|
128
51
|
export interface AgentConfigStoreData {
|
|
129
52
|
/** Global gateway proxy URL. */
|
|
@@ -226,31 +149,10 @@ export interface AgentsRemoveConfigParams {
|
|
|
226
149
|
export interface AgentsSetGatewayParams {
|
|
227
150
|
url: string;
|
|
228
151
|
}
|
|
229
|
-
export type SoloState = "running" | "evaluating" | "completed" | "cancelled" | "failed";
|
|
230
|
-
export type SoloAgentState = "pending" | "running" | "completed" | "failed";
|
|
231
|
-
export interface SoloAgentResult {
|
|
232
|
-
id: string;
|
|
233
|
-
state: SoloAgentState;
|
|
234
|
-
progress?: string;
|
|
235
|
-
resultText?: string;
|
|
236
|
-
diff?: string;
|
|
237
|
-
usage?: {
|
|
238
|
-
inputTokens: number;
|
|
239
|
-
outputTokens: number;
|
|
240
|
-
};
|
|
241
|
-
error?: string;
|
|
242
|
-
worktreePath?: string;
|
|
243
|
-
}
|
|
244
152
|
export interface SoloEvaluation {
|
|
245
153
|
winnerId: string;
|
|
246
154
|
reasoning: string;
|
|
247
155
|
}
|
|
248
|
-
export interface SoloStatus {
|
|
249
|
-
soloId: string;
|
|
250
|
-
state: SoloState;
|
|
251
|
-
agents: SoloAgentResult[];
|
|
252
|
-
evaluation?: SoloEvaluation;
|
|
253
|
-
}
|
|
254
156
|
/** solo.start RPC params. */
|
|
255
157
|
export interface SoloStartParams {
|
|
256
158
|
task: string;
|
|
@@ -266,9 +168,7 @@ export interface SoloSelectParams {
|
|
|
266
168
|
soloId: string;
|
|
267
169
|
winnerId: string;
|
|
268
170
|
}
|
|
269
|
-
export type ProductPhase = "active" | "paused" | "completed" | "failed";
|
|
270
171
|
export type ProductInstanceState = "idle" | "running" | "completed" | "failed" | "paused";
|
|
271
|
-
export type ProductTaskStatus = "pending" | "running" | "completed" | "failed" | "paused";
|
|
272
172
|
/** Product budget configuration & runtime counters. */
|
|
273
173
|
export interface ProductBudget {
|
|
274
174
|
maxTotalTokens?: number;
|
|
@@ -276,19 +176,6 @@ export interface ProductBudget {
|
|
|
276
176
|
usedTokens: number;
|
|
277
177
|
elapsed: number;
|
|
278
178
|
}
|
|
279
|
-
/** Instance definition within a product. */
|
|
280
|
-
export interface ProductInstanceDef {
|
|
281
|
-
name: string;
|
|
282
|
-
role: string;
|
|
283
|
-
agentId: string;
|
|
284
|
-
}
|
|
285
|
-
/** Task definition within a product DAG. */
|
|
286
|
-
export interface ProductTaskDef {
|
|
287
|
-
taskId: string;
|
|
288
|
-
assignee: string;
|
|
289
|
-
prompt: string;
|
|
290
|
-
dependsOn?: string[];
|
|
291
|
-
}
|
|
292
179
|
/** product.create RPC params. */
|
|
293
180
|
export interface ProductCreateParams {
|
|
294
181
|
name: string;
|
|
@@ -326,27 +213,6 @@ export interface ProductTaskState {
|
|
|
326
213
|
startedAt?: string;
|
|
327
214
|
completedAt?: string;
|
|
328
215
|
}
|
|
329
|
-
/** Full product status (product.status response). */
|
|
330
|
-
export interface ProductStatus {
|
|
331
|
-
productId: string;
|
|
332
|
-
name: string;
|
|
333
|
-
phase: ProductPhase;
|
|
334
|
-
instances: ProductInstanceStatus[];
|
|
335
|
-
tasks: ProductTaskState[];
|
|
336
|
-
budget: ProductBudget;
|
|
337
|
-
lastCheckpointAt: string;
|
|
338
|
-
}
|
|
339
|
-
/** Summary for product.list response. */
|
|
340
|
-
export interface ProductSummary {
|
|
341
|
-
productId: string;
|
|
342
|
-
name: string;
|
|
343
|
-
phase: ProductPhase;
|
|
344
|
-
instanceCount: number;
|
|
345
|
-
taskCount: number;
|
|
346
|
-
completedTasks: number;
|
|
347
|
-
createdAt: string;
|
|
348
|
-
lastCheckpointAt: string;
|
|
349
|
-
}
|
|
350
216
|
/** agents.getGateway response. */
|
|
351
217
|
export interface AgentsGetGatewayResult {
|
|
352
218
|
url?: string;
|
|
@@ -402,9 +268,4 @@ export interface SoloDeleteParams {
|
|
|
402
268
|
export interface ProductDeleteParams {
|
|
403
269
|
productId: string;
|
|
404
270
|
}
|
|
405
|
-
|
|
406
|
-
export interface AgentSource {
|
|
407
|
-
id: string;
|
|
408
|
-
name: string;
|
|
409
|
-
role: "main" | "teammate";
|
|
410
|
-
}
|
|
271
|
+
export type { AgentSource } from "../../protocol/wire/index.js";
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Sub-agent Token Budget Enforcer
|
|
2
|
+
* Sub-agent Token Budget Enforcer 鈥?CC-aligned budget limits.
|
|
3
3
|
*
|
|
4
4
|
* Prevents sub-agents from consuming infinite tokens by:
|
|
5
5
|
* 1. Per-task token budget (from TaskStateBase.tokenBudget)
|
|
6
6
|
* 2. Session-level aggregate budget (all tasks combined)
|
|
7
7
|
* 3. Budget continuation messages (CC tokenBudget.ts pattern)
|
|
8
|
-
* 4. Graceful degradation (warn
|
|
8
|
+
* 4. Graceful degradation (warn 鈫?force-stop, never hard-crash)
|
|
9
9
|
*
|
|
10
10
|
* CC reference: utils/tokenBudget.ts, main.tsx --max-budget-usd / --task-budget
|
|
11
11
|
*
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* CC has no explicit per-sub-agent budget; they rely on session-level maxBudgetUsd.
|
|
14
14
|
* We add per-task enforcement to prevent a single sub-agent from exhausting the budget.
|
|
15
15
|
*/
|
|
16
|
-
import type { TokenUsage } from "../../
|
|
16
|
+
import type { WireTokenUsage as TokenUsage } from "../../protocol/wire/index.js";
|
|
17
17
|
export interface BudgetConfig {
|
|
18
18
|
/** Per-task token budget (prompt + completion). 0 = unlimited. */
|
|
19
19
|
taskBudgetTokens: number;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { SessionState, type SessionUsageSnapshot, type SessionCostSnapshot } from "./session-state.js";
|
|
2
|
-
export { appendMessage, saveSessionState, loadSessionForResume, listSessions, deleteSession, pruneOldSessions, shouldGenerateTaskSummary, maybeGenerateTaskSummary, type SessionMetadata, type PersistedSession, type SessionListEntry, type TaskSummaryDeps, } from "./session-persistence.js";
|
|
2
|
+
export { appendMessage, saveSessionState, updateSessionMetadata, loadSessionForResume, listSessions, deleteSession, pruneOldSessions, shouldGenerateTaskSummary, maybeGenerateTaskSummary, type SessionMetadata, type PersistedSession, type SessionListEntry, type TaskSummaryDeps, } from "./session-persistence.js";
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SessionMemory 鈥?In-memory session message store with JSONL persistence.
|
|
3
|
+
*
|
|
4
|
+
* CC alignment: messages live in memory during the session lifetime.
|
|
5
|
+
* JSONL is the sole persistent source of truth (for crash recovery).
|
|
6
|
+
* Gateway never owns message data 鈥?Agent is the single authority.
|
|
7
|
+
*
|
|
8
|
+
* Design:
|
|
9
|
+
* - Map<sessionId, ChatMessage[]> holds active session messages
|
|
10
|
+
* - On first access, lazy-loads from transcript.jsonl
|
|
11
|
+
* - appendMessage() writes to memory AND appends to JSONL atomically
|
|
12
|
+
* - getMessages() returns from memory (no disk I/O on hot path)
|
|
13
|
+
*/
|
|
14
|
+
import type { ChatMessage } from "../../protocol/wire/index.js";
|
|
15
|
+
export declare class SessionMemory {
|
|
16
|
+
private sessions;
|
|
17
|
+
private projectRoot;
|
|
18
|
+
constructor(projectRoot?: string);
|
|
19
|
+
setProjectRoot(projectRoot: string): void;
|
|
20
|
+
/**
|
|
21
|
+
* Get messages for a session. Lazy-loads from JSONL on first access.
|
|
22
|
+
*/
|
|
23
|
+
getMessages(sessionId: string): ChatMessage[];
|
|
24
|
+
/**
|
|
25
|
+
* Append a message to session memory and persist to JSONL.
|
|
26
|
+
*/
|
|
27
|
+
appendMessage(sessionId: string, message: ChatMessage, turnId?: string): void;
|
|
28
|
+
/**
|
|
29
|
+
* Check if a session is loaded in memory.
|
|
30
|
+
*/
|
|
31
|
+
hasSession(sessionId: string): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Initialize an empty session (for newly created sessions).
|
|
34
|
+
*/
|
|
35
|
+
initSession(sessionId: string): void;
|
|
36
|
+
/**
|
|
37
|
+
* Drop a session from memory (e.g., on session.ended).
|
|
38
|
+
* Does NOT delete JSONL 鈥?data persists for future resume.
|
|
39
|
+
*/
|
|
40
|
+
evictSession(sessionId: string): void;
|
|
41
|
+
/**
|
|
42
|
+
* Get the count of messages in a session.
|
|
43
|
+
*/
|
|
44
|
+
getMessageCount(sessionId: string): number;
|
|
45
|
+
private loadFromDisk;
|
|
46
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Session Persistence
|
|
2
|
+
* Session Persistence 鈥?CC sessionRestore.ts + conversationRecovery.ts parity.
|
|
3
3
|
*
|
|
4
4
|
* Enables conversation resume by persisting:
|
|
5
5
|
* 1. Message transcript (JSONL-based, append-only)
|
|
@@ -9,18 +9,18 @@
|
|
|
9
9
|
* Storage layout:
|
|
10
10
|
* <project>/.qlogicagent/sessions/<session-id>/ (when projectRoot provided)
|
|
11
11
|
* ~/.qlogicagent/sessions/<session-id>/ (fallback)
|
|
12
|
-
* transcript.jsonl
|
|
13
|
-
* state.json
|
|
12
|
+
* transcript.jsonl 鈥?append-only message log
|
|
13
|
+
* state.json 鈥?cost snapshot + metadata
|
|
14
14
|
*
|
|
15
15
|
* Resume flow (CC processResumedConversation parity):
|
|
16
|
-
* 1. loadSessionForResume(sessionId)
|
|
16
|
+
* 1. loadSessionForResume(sessionId) 鈫?messages + cost
|
|
17
17
|
* 2. Restore cost state into SessionState
|
|
18
18
|
* 3. Feed messages as initial context to agent
|
|
19
19
|
*
|
|
20
20
|
* Reference: claude-code src/utils/sessionRestore.ts
|
|
21
21
|
* claude-code src/utils/conversationRecovery.ts
|
|
22
22
|
*/
|
|
23
|
-
import type { ChatMessage } from "../../
|
|
23
|
+
import type { ChatMessage } from "../../protocol/wire/index.js";
|
|
24
24
|
import type { SessionCostSnapshot } from "./session-state.js";
|
|
25
25
|
export interface SessionMetadata {
|
|
26
26
|
sessionId: string;
|
|
@@ -36,6 +36,22 @@ export interface SessionMetadata {
|
|
|
36
36
|
taskSummary?: string;
|
|
37
37
|
/** Timestamp of last task summary generation */
|
|
38
38
|
taskSummaryGeneratedAt?: number;
|
|
39
|
+
/** ISO timestamp 鈥?session pinned in UI */
|
|
40
|
+
pinnedAt?: string;
|
|
41
|
+
/** ISO timestamp 鈥?session archived (soft-deleted) */
|
|
42
|
+
archivedAt?: string;
|
|
43
|
+
/** Project ID this session belongs to */
|
|
44
|
+
projectId?: string;
|
|
45
|
+
/** Session type: personal or group */
|
|
46
|
+
type?: "personal" | "group";
|
|
47
|
+
/** Owner user ID */
|
|
48
|
+
ownerId?: string;
|
|
49
|
+
/** Group key for group sessions */
|
|
50
|
+
groupKey?: string;
|
|
51
|
+
/** Group display name */
|
|
52
|
+
groupName?: string;
|
|
53
|
+
/** Group platform (wechat, dingtalk, etc.) */
|
|
54
|
+
groupPlatform?: string;
|
|
39
55
|
}
|
|
40
56
|
export interface PersistedSession {
|
|
41
57
|
metadata: SessionMetadata;
|
|
@@ -48,6 +64,11 @@ export interface SessionListEntry {
|
|
|
48
64
|
lastActiveAt: number;
|
|
49
65
|
messageCount: number;
|
|
50
66
|
model?: string;
|
|
67
|
+
pinnedAt?: string;
|
|
68
|
+
archivedAt?: string;
|
|
69
|
+
projectId?: string;
|
|
70
|
+
type?: "personal" | "group";
|
|
71
|
+
createdAt?: number;
|
|
51
72
|
}
|
|
52
73
|
/**
|
|
53
74
|
* Append a message to the session transcript.
|
|
@@ -61,13 +82,18 @@ export declare function appendMessage(sessionId: string, message: ChatMessage, p
|
|
|
61
82
|
*/
|
|
62
83
|
export declare function saveSessionState(sessionId: string, costSnapshot: SessionCostSnapshot, metadata: Partial<SessionMetadata>, projectRoot?: string): Promise<void>;
|
|
63
84
|
/**
|
|
64
|
-
*
|
|
85
|
+
* Update specific metadata fields of a session without touching cost data.
|
|
86
|
+
* Used by session CRUD RPC (rename, pin, archive, move-to-project).
|
|
87
|
+
*/
|
|
88
|
+
export declare function updateSessionMetadata(sessionId: string, patch: Partial<SessionMetadata>, projectRoot?: string): Promise<SessionMetadata | null>;
|
|
89
|
+
/**
|
|
90
|
+
* Load a persisted session for resume 鈥?CC loadConversationForResume parity.
|
|
65
91
|
*
|
|
66
92
|
* Returns null if the session doesn't exist or is corrupted.
|
|
67
93
|
*/
|
|
68
94
|
export declare function loadSessionForResume(sessionId: string, projectRoot?: string): Promise<PersistedSession | null>;
|
|
69
95
|
/**
|
|
70
|
-
* List available sessions for resume
|
|
96
|
+
* List available sessions for resume 鈥?CC ResumeConversation picker.
|
|
71
97
|
* Returns most-recent-first, up to `limit` entries.
|
|
72
98
|
*/
|
|
73
99
|
export declare function listSessions(limit?: number, projectRoot?: string): Promise<SessionListEntry[]>;
|
|
@@ -92,6 +118,6 @@ export interface TaskSummaryDeps {
|
|
|
92
118
|
export declare function shouldGenerateTaskSummary(metadata: SessionMetadata): boolean;
|
|
93
119
|
/**
|
|
94
120
|
* Generate and persist a task summary for a long session.
|
|
95
|
-
* Fire-and-forget
|
|
121
|
+
* Fire-and-forget 鈥?errors are swallowed.
|
|
96
122
|
*/
|
|
97
123
|
export declare function maybeGenerateTaskSummary(sessionId: string, metadata: SessionMetadata, recentMessages: ChatMessage[], deps: TaskSummaryDeps, projectRoot?: string): Promise<string | null>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Session State
|
|
2
|
+
* Session State 鈥?CC session state parity.
|
|
3
3
|
*
|
|
4
4
|
* Unified state container for a single agent session:
|
|
5
5
|
* - Token usage / cost accumulation across turns
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
*
|
|
14
14
|
* Reference: claude-code src/bootstrap/state.ts, src/cost-tracker.ts
|
|
15
15
|
*/
|
|
16
|
-
import type { TokenUsage } from "../../
|
|
17
|
-
/** Per-model usage accumulation
|
|
16
|
+
import type { WireTokenUsage as TokenUsage } from "../../protocol/wire/index.js";
|
|
17
|
+
/** Per-model usage accumulation 鈥?CC modelUsage parity */
|
|
18
18
|
export interface ModelUsage {
|
|
19
19
|
inputTokens: number;
|
|
20
20
|
outputTokens: number;
|
|
@@ -59,7 +59,7 @@ export declare class SessionState {
|
|
|
59
59
|
/** Get all model usages as a plain object */
|
|
60
60
|
getAllModelUsage(): Record<string, ModelUsage>;
|
|
61
61
|
/**
|
|
62
|
-
* Add usage from an API response
|
|
62
|
+
* Add usage from an API response 鈥?CC addToTotalSessionCost() parity.
|
|
63
63
|
* Tracks token counts only; pricing is handled by Hub/Admin.
|
|
64
64
|
*
|
|
65
65
|
* @param usage - Token counts from the API response
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { MemoryProvider, MemorySearchResult } from "
|
|
1
|
+
import type { MemoryProvider, MemorySearchResult } from "../../protocol/wire/index.js";
|
|
2
2
|
import type { Memdir } from "./memdir.js";
|
|
3
3
|
export declare const MEMORY_TOOL_NAME: "memory";
|
|
4
4
|
export declare const MEMORY_TOOL_LABEL = "Memory";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { MemoryIngestOptions, MemoryProvider } from "
|
|
1
|
+
import type { MemoryIngestOptions, MemoryProvider } from "../../protocol/wire/index.js";
|
|
2
2
|
/** A pre-extracted memory item ready to be stored (no LLM needed). */
|
|
3
3
|
export interface ExtractedMemoryItem {
|
|
4
4
|
text: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { HookRegistry } from "../../contracts/hooks.js";
|
|
2
|
-
import type { ToolDefinition } from "../../
|
|
2
|
+
import type { ToolDefinition } from "../../protocol/wire/index.js";
|
|
3
3
|
import { PermissionRuleEngine } from "./rule-engine.js";
|
|
4
4
|
import type { PermissionUpdate, ApprovalRequest, ApprovalResponse } from "./types.js";
|
|
5
5
|
import { type ClassifierLLMCall } from "./permission-classifier.js";
|
|
@@ -47,11 +47,11 @@ export declare class PermissionChecker {
|
|
|
47
47
|
private readonly permissionRole;
|
|
48
48
|
private readonly pendingApprovals;
|
|
49
49
|
private unregisterHook;
|
|
50
|
-
/** Tool meta cache
|
|
50
|
+
/** Tool meta cache 鈥?populated from ToolDefinition[] at agent creation */
|
|
51
51
|
private toolMetaCache;
|
|
52
|
-
/** Classifier result cache
|
|
52
|
+
/** Classifier result cache 鈥?avoids redundant LLM calls (CC permissionCache parity) */
|
|
53
53
|
private classifierCache;
|
|
54
|
-
/** Denial tracking state
|
|
54
|
+
/** Denial tracking state 鈥?CC denialTracking.ts parity */
|
|
55
55
|
private denialTracking;
|
|
56
56
|
constructor(deps: PermissionCheckerDeps);
|
|
57
57
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ChatMessage } from "../../
|
|
1
|
+
import type { ChatMessage } from "../../protocol/wire/index.js";
|
|
2
2
|
export interface ClassifierResult {
|
|
3
3
|
shouldBlock: boolean;
|
|
4
4
|
reason: string;
|
|
@@ -6,7 +6,7 @@ export interface ClassifierResult {
|
|
|
6
6
|
durationMs: number;
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
|
-
* LLM call interface
|
|
9
|
+
* LLM call interface 鈥?injected by the host so the classifier
|
|
10
10
|
* doesn't depend on a specific LLM client.
|
|
11
11
|
*/
|
|
12
12
|
export interface ClassifierLLMCall {
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { PortableTool } from "../portable-tool.js";
|
|
2
|
+
export declare const PROJECT_SWITCH_TOOL_NAME: "project_switch";
|
|
3
|
+
export interface ProjectSwitchToolParams {
|
|
4
|
+
projectName: string;
|
|
5
|
+
}
|
|
6
|
+
export interface ProjectSwitchToolDeps {
|
|
7
|
+
listProjects: () => Array<{
|
|
8
|
+
id: string;
|
|
9
|
+
name: string;
|
|
10
|
+
workspaceDir: string;
|
|
11
|
+
}>;
|
|
12
|
+
switchProject: (projectId: string) => {
|
|
13
|
+
id: string;
|
|
14
|
+
name: string;
|
|
15
|
+
workspaceDir: string;
|
|
16
|
+
} | null;
|
|
17
|
+
/** Called after a successful switch so the host can update cwd/notifications. */
|
|
18
|
+
onSwitched?: (project: {
|
|
19
|
+
id: string;
|
|
20
|
+
name: string;
|
|
21
|
+
workspaceDir: string;
|
|
22
|
+
}) => void;
|
|
23
|
+
}
|
|
24
|
+
export declare function createProjectSwitchTool(deps: ProjectSwitchToolDeps): PortableTool<ProjectSwitchToolParams>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Tool Registry
|
|
2
|
+
* Tool Registry 鈥?CC-aligned getAllBaseTools() pattern.
|
|
3
3
|
*
|
|
4
4
|
* CC reference: claude-code-haha/src/tools.ts
|
|
5
5
|
*
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* The registration pattern is aligned: pure function returns array.
|
|
13
13
|
*/
|
|
14
14
|
import type { PortableTool } from "./portable-tool.js";
|
|
15
|
-
import type { ToolDefinition } from "../
|
|
15
|
+
import type { ToolDefinition } from "../protocol/wire/index.js";
|
|
16
16
|
import { AGENT_DISALLOWED_TOOLS, CUSTOM_AGENT_DISALLOWED_TOOLS, filterToolsForAgent } from "../agent/tool-access.js";
|
|
17
17
|
export { AGENT_DISALLOWED_TOOLS, CUSTOM_AGENT_DISALLOWED_TOOLS, filterToolsForAgent };
|
|
18
18
|
/**
|
|
@@ -52,14 +52,14 @@ export declare function getToolCount(): number;
|
|
|
52
52
|
*/
|
|
53
53
|
export declare function executeTool(name: string, toolCallId: string, args: Record<string, unknown>, signal?: AbortSignal): Promise<import("./portable-tool.js").PortableToolResult>;
|
|
54
54
|
/**
|
|
55
|
-
* CC: getTools()
|
|
55
|
+
* CC: getTools() 鈥?return all enabled tools.
|
|
56
56
|
* Filters the pool by isEnabled() gate; disabled tools are invisible to callers.
|
|
57
57
|
* CC reference: claude-code-haha/src/tools.ts getTools()
|
|
58
58
|
*/
|
|
59
59
|
export declare function getTools(): PortableTool[];
|
|
60
60
|
/**
|
|
61
61
|
* Activate a deferred tool so it appears in subsequent LLM manifests.
|
|
62
|
-
* CC parity: tool_search select:
|
|
62
|
+
* CC parity: tool_search select: 鈫?activateTool 鈫?tool included in manifest.
|
|
63
63
|
* Returns true if the tool exists, is enabled, and was activated.
|
|
64
64
|
*/
|
|
65
65
|
export declare function activateTool(name: string): boolean;
|
|
@@ -73,7 +73,7 @@ export declare function isToolActivated(name: string): boolean;
|
|
|
73
73
|
export declare function clearActivatedTools(): void;
|
|
74
74
|
/**
|
|
75
75
|
* Generate ToolDefinition[] manifest for LLM tool_use.
|
|
76
|
-
* Filters by isEnabled()
|
|
76
|
+
* Filters by isEnabled() 鈥?disabled tools never reach the model.
|
|
77
77
|
* Deferred tools are excluded UNLESS they have been activated via tool_search.
|
|
78
78
|
* CC: getTools() + manifest generation combined.
|
|
79
79
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* ACP Event Emitter
|
|
2
|
+
* ACP Event Emitter 鈥?translates internal qlogicagent notifications to ACP
|
|
3
3
|
* session/update notifications.
|
|
4
4
|
*
|
|
5
5
|
* Maps the 47+ internal notification methods (turn.delta, turn.tool_call, etc.)
|