qlogicagent 2.4.0 → 2.6.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 +9 -9
- package/dist/cli.js +221 -221
- package/dist/contracts.js +0 -1
- package/dist/index.js +219 -219
- package/dist/types/agent/runtime-vars.d.ts +48 -0
- package/dist/types/agent/tunable-defaults.d.ts +3 -0
- package/dist/types/cli/stdio-server.d.ts +1 -10
- package/dist/types/cli/tool-bootstrap.d.ts +0 -2
- package/dist/types/contracts/index.d.ts +1 -4
- package/dist/types/orchestration/solo-evaluator.d.ts +6 -0
- package/dist/types/orchestration/solo-persistence.d.ts +38 -0
- package/dist/types/protocol/methods.d.ts +32 -2
- package/dist/types/skills/memory/qmemory-adapter.d.ts +1 -1
- package/dist/types/skills/memory/qmemory-http-client.d.ts +16 -0
- package/package.json +2 -3
- package/dist/types/agent/constants.d.ts +0 -8
- package/dist/types/contracts/todo.d.ts +0 -10
- package/dist/types/runtime/execution/dream-category-context.test.d.ts +0 -1
- package/dist/types/runtime/execution/memory-decay.test.d.ts +0 -1
- package/dist/types/runtime/execution/remote-agent.d.ts +0 -63
- package/dist/types/runtime/infra/acp-detector.test.d.ts +0 -1
- package/dist/types/runtime/infra/acp-protocol-adapter.test.d.ts +0 -1
- package/dist/types/runtime/infra/acp-usage-tracker.test.d.ts +0 -1
- package/dist/types/runtime/infra/agent-config-store.test.d.ts +0 -1
- package/dist/types/runtime/infra/agent-process.test.d.ts +0 -1
- package/dist/types/runtime/infra/mcp-bridge.test.d.ts +0 -1
- package/dist/types/runtime/infra/model-id-translator.test.d.ts +0 -1
- package/dist/types/runtime/infra/skill-injector.test.d.ts +0 -1
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RuntimeVars — Unified mutable runtime variables for the agent server.
|
|
3
|
+
*
|
|
4
|
+
* All tunable/configurable runtime state that can be changed via RPC
|
|
5
|
+
* (config.updateTunable) or internal logic should live here. This avoids
|
|
6
|
+
* scattering mutable state as private fields across stdio-server.ts.
|
|
7
|
+
*
|
|
8
|
+
* Categories:
|
|
9
|
+
* 1. Budget — aggregate token usage tracking and limits
|
|
10
|
+
* 2. Dream — idle dream scheduling parameters
|
|
11
|
+
*
|
|
12
|
+
* Usage:
|
|
13
|
+
* import { runtimeVars } from "../agent/runtime-vars.js";
|
|
14
|
+
* runtimeVars.teamTokensUsed += tokens;
|
|
15
|
+
* if (runtimeVars.isTeamBudgetExceeded()) { ... }
|
|
16
|
+
*/
|
|
17
|
+
export interface TeamBudgetState {
|
|
18
|
+
/** Total tokens consumed by all forked sub-agents (accumulated). */
|
|
19
|
+
tokensUsed: number;
|
|
20
|
+
/** Maximum total tokens allowed across all forks. 0 = unlimited. */
|
|
21
|
+
budgetTokens: number;
|
|
22
|
+
}
|
|
23
|
+
export interface DreamState {
|
|
24
|
+
/** Idle threshold before triggering dream (minutes). */
|
|
25
|
+
idleMinutes: number;
|
|
26
|
+
/** Whether idle dream is enabled. */
|
|
27
|
+
enabled: boolean;
|
|
28
|
+
/** Last dream timestamp (ms since epoch). */
|
|
29
|
+
lastDreamAt: number;
|
|
30
|
+
/** Cooldown between dreams (ms). */
|
|
31
|
+
cooldownMs: number;
|
|
32
|
+
/** Max duration for a single dream run (ms). */
|
|
33
|
+
maxDurationMs: number;
|
|
34
|
+
}
|
|
35
|
+
export declare class RuntimeVars {
|
|
36
|
+
readonly teamBudget: TeamBudgetState;
|
|
37
|
+
/** Check if team aggregate budget is exceeded. */
|
|
38
|
+
isTeamBudgetExceeded(): boolean;
|
|
39
|
+
/** Record token consumption from a fork and return updated total. */
|
|
40
|
+
recordForkTokens(tokens: number): number;
|
|
41
|
+
/** Format budget-exceeded error message. */
|
|
42
|
+
teamBudgetExceededError(): string;
|
|
43
|
+
readonly dream: DreamState;
|
|
44
|
+
/** Reset all accumulated state (e.g. on session end). */
|
|
45
|
+
resetAccumulators(): void;
|
|
46
|
+
}
|
|
47
|
+
/** Singleton instance — shared across the server lifetime. */
|
|
48
|
+
export declare const runtimeVars: RuntimeVars;
|
|
@@ -93,6 +93,8 @@ export declare const SKILL_RECALL_MAX_CONTENT_CHARS = 800;
|
|
|
93
93
|
export declare const SKILL_RECALL_CACHE_TTL_MS: number;
|
|
94
94
|
/** Max nested fork depth for sub-agents. */
|
|
95
95
|
export declare const MAX_FORK_DEPTH = 4;
|
|
96
|
+
/** Team aggregate budget (total tokens across all forked sub-agents). 0 = unlimited. */
|
|
97
|
+
export declare const TEAM_BUDGET_TOKENS = 0;
|
|
96
98
|
/** Max historical sessions retained on disk. */
|
|
97
99
|
export declare const MAX_SESSIONS = 50;
|
|
98
100
|
/** Turn count threshold for triggering task summary. */
|
|
@@ -217,6 +219,7 @@ export interface TunableDefaults {
|
|
|
217
219
|
idleDreamMinutes: number;
|
|
218
220
|
dreamCooldownMs: number;
|
|
219
221
|
dreamMaxDurationMs: number;
|
|
222
|
+
teamBudgetTokens: number;
|
|
220
223
|
}
|
|
221
224
|
/**
|
|
222
225
|
* Snapshot of all current tunable values.
|
|
@@ -71,19 +71,10 @@ export declare class StdioServer {
|
|
|
71
71
|
private acpServer;
|
|
72
72
|
/** Idle dream timer — fires after configurable idle period to trigger memory consolidation. */
|
|
73
73
|
private idleDreamTimer;
|
|
74
|
-
/** Idle dream config (minutes). Default: 30 min idle = trigger dream. */
|
|
75
|
-
private idleDreamMinutes;
|
|
76
|
-
/** Whether idle dream is enabled. Requires LLM config + memory root to be set. */
|
|
77
|
-
private idleDreamEnabled;
|
|
78
|
-
/** Last dream timestamp to enforce cooldown. */
|
|
79
|
-
private lastDreamAt;
|
|
80
|
-
/** Dream cooldown (ms). Default: 4 hours. */
|
|
81
|
-
private dreamCooldownMs;
|
|
82
|
-
/** Max dream duration (ms). Default: 5 minutes. */
|
|
83
|
-
private dreamMaxDurationMs;
|
|
84
74
|
constructor(config: StdioServerConfig);
|
|
85
75
|
start(): void;
|
|
86
76
|
stop(): void;
|
|
77
|
+
private readonly methodHandlers;
|
|
87
78
|
private handleMessage;
|
|
88
79
|
/**
|
|
89
80
|
* `initialize` — the sole handshake handler.
|
|
@@ -56,8 +56,6 @@ export interface BootstrapConfig {
|
|
|
56
56
|
* @alias initToolDeps — kept for backward compat with existing call sites.
|
|
57
57
|
*/
|
|
58
58
|
export declare function getAllBaseTools(config?: BootstrapConfig): PortableTool[];
|
|
59
|
-
/** @deprecated Use getAllBaseTools() instead. */
|
|
60
|
-
export declare const initToolDeps: typeof getAllBaseTools;
|
|
61
59
|
/**
|
|
62
60
|
* Update the working directory for all local tool deps.
|
|
63
61
|
* Called when Gateway sends a new workdir via config.
|
|
@@ -39,6 +39,12 @@ export declare class SoloEvaluator {
|
|
|
39
39
|
private callbacks;
|
|
40
40
|
private sessions;
|
|
41
41
|
constructor(processManager: AgentProcessManager, acpDetector: AcpDetector, configStore: AgentConfigStore | null, callbacks?: SoloCallbacks);
|
|
42
|
+
/** Persist current session data to disk (fire-and-forget). */
|
|
43
|
+
private persistSession;
|
|
44
|
+
/** Restore sessions from disk (call once at startup). */
|
|
45
|
+
restoreFromDisk(cwd?: string): Promise<number>;
|
|
46
|
+
/** Delete a solo session from memory and disk. */
|
|
47
|
+
deleteSolo(soloId: string): Promise<boolean>;
|
|
42
48
|
/**
|
|
43
49
|
* Start a Solo Mode PK session.
|
|
44
50
|
* Creates worktrees, spawns agents in parallel, waits for completion, then evaluates.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Solo Persistence — read/write Solo Mode state to disk.
|
|
3
|
+
*
|
|
4
|
+
* State is stored at `<project>/.qlogicagent/solos/<soloId>/solo-state.json`.
|
|
5
|
+
* Mirrors the product-persistence.ts pattern.
|
|
6
|
+
*/
|
|
7
|
+
import type { SoloState, SoloAgentState, SoloEvaluation } from "../runtime/infra/acp-types.js";
|
|
8
|
+
export interface PersistedSoloState {
|
|
9
|
+
soloId: string;
|
|
10
|
+
state: SoloState;
|
|
11
|
+
task: string;
|
|
12
|
+
cwd: string;
|
|
13
|
+
gitRoot: string;
|
|
14
|
+
agents: Array<{
|
|
15
|
+
agentId: string;
|
|
16
|
+
memberId: string;
|
|
17
|
+
worktreePath: string;
|
|
18
|
+
worktreeBranch: string;
|
|
19
|
+
state: SoloAgentState;
|
|
20
|
+
resultText?: string;
|
|
21
|
+
diff?: string;
|
|
22
|
+
usage?: {
|
|
23
|
+
inputTokens: number;
|
|
24
|
+
outputTokens: number;
|
|
25
|
+
};
|
|
26
|
+
error?: string;
|
|
27
|
+
}>;
|
|
28
|
+
evaluation?: SoloEvaluation;
|
|
29
|
+
createdAt: number;
|
|
30
|
+
}
|
|
31
|
+
/** Save solo state to disk. */
|
|
32
|
+
export declare function saveSoloState(state: PersistedSoloState, cwd?: string): Promise<void>;
|
|
33
|
+
/** Load solo state from disk. Returns undefined if not found. */
|
|
34
|
+
export declare function loadSoloState(soloId: string, cwd?: string): Promise<PersistedSoloState | undefined>;
|
|
35
|
+
/** List all solo session IDs with their persisted state. */
|
|
36
|
+
export declare function listSoloSessions(cwd?: string): Promise<PersistedSoloState[]>;
|
|
37
|
+
/** Delete solo state from disk. */
|
|
38
|
+
export declare function deleteSoloState(soloId: string, cwd?: string): Promise<boolean>;
|
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
* Reference: Codex app-server RPC, Claude Code JSON-RPC, GitHub Copilot Agent API.
|
|
8
8
|
*/
|
|
9
9
|
import type { ChatMessage, ToolDefinition } from "../agent/types.js";
|
|
10
|
-
import type { TodoItem } from "../
|
|
10
|
+
import type { TaskItem as TodoItem } from "../skills/tools/task-tool.js";
|
|
11
11
|
import type { AgentDescriptor, AgentConfig, GatewayRpcMethodMap, RpcProjectInfo, RpcProjectType, RpcProjectStatus, SoloStatus, ProductStatus, ProductSummary } from "./wire/index.js";
|
|
12
|
-
import type { AgentsScanParams, AgentsConfigParams, AgentsSetConfigParams, AgentsGetConfigParams, AgentsRemoveConfigParams, AgentsSetGatewayParams, SoloStartParams, SoloIdParams, SoloSelectParams, ProductCreateParams, ProductIdParams } from "../runtime/infra/acp-types.js";
|
|
12
|
+
import type { AgentsScanParams, AgentsConfigParams, AgentsSetConfigParams, AgentsGetConfigParams, AgentsRemoveConfigParams, AgentsSetGatewayParams, SoloStartParams, SoloIdParams, SoloSelectParams, SoloDeleteParams, ProductCreateParams, ProductIdParams, ProductDeleteParams } from "../runtime/infra/acp-types.js";
|
|
13
13
|
export interface InitializeParams {
|
|
14
14
|
protocolVersion: string;
|
|
15
15
|
host?: {
|
|
@@ -512,6 +512,16 @@ export interface RpcMethodMap {
|
|
|
512
512
|
mergedBranch: string;
|
|
513
513
|
};
|
|
514
514
|
};
|
|
515
|
+
"solo.list": {
|
|
516
|
+
params: undefined;
|
|
517
|
+
result: SoloStatus[];
|
|
518
|
+
};
|
|
519
|
+
"solo.delete": {
|
|
520
|
+
params: SoloDeleteParams;
|
|
521
|
+
result: {
|
|
522
|
+
ok: true;
|
|
523
|
+
};
|
|
524
|
+
};
|
|
515
525
|
"product.create": {
|
|
516
526
|
params: ProductCreateParams;
|
|
517
527
|
result: {
|
|
@@ -544,6 +554,26 @@ export interface RpcMethodMap {
|
|
|
544
554
|
params: undefined;
|
|
545
555
|
result: ProductSummary[];
|
|
546
556
|
};
|
|
557
|
+
"product.delete": {
|
|
558
|
+
params: ProductDeleteParams;
|
|
559
|
+
result: {
|
|
560
|
+
ok: true;
|
|
561
|
+
};
|
|
562
|
+
};
|
|
563
|
+
"product.cancel": {
|
|
564
|
+
params: ProductIdParams;
|
|
565
|
+
result: {
|
|
566
|
+
ok: true;
|
|
567
|
+
};
|
|
568
|
+
};
|
|
569
|
+
"product.rollback": {
|
|
570
|
+
params: ProductIdParams & {
|
|
571
|
+
checkpoint?: string;
|
|
572
|
+
};
|
|
573
|
+
result: {
|
|
574
|
+
ok: true;
|
|
575
|
+
};
|
|
576
|
+
};
|
|
547
577
|
"project.create": {
|
|
548
578
|
params: ProjectCreateParams;
|
|
549
579
|
result: ProjectCreateResult;
|
|
@@ -42,7 +42,7 @@ export interface QMemoryHealthStatus {
|
|
|
42
42
|
/**
|
|
43
43
|
* Create a MemoryProvider backed by a QMemory HTTP server.
|
|
44
44
|
*
|
|
45
|
-
* Uses
|
|
45
|
+
* Uses inlined QMemoryHttpClient for HTTP transport (zero external deps).
|
|
46
46
|
*/
|
|
47
47
|
export declare function createQMemoryAdapter(config: QMemoryAdapterConfig): MemoryProvider & {
|
|
48
48
|
health(): Promise<QMemoryHealthStatus>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface QMemoryClientConfig {
|
|
2
|
+
baseUrl: string;
|
|
3
|
+
apiKey?: string;
|
|
4
|
+
timeout?: number;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Lightweight HTTP client for QMemory API.
|
|
8
|
+
* Maps RPC method names to REST endpoints using native fetch.
|
|
9
|
+
*/
|
|
10
|
+
export declare class QMemoryHttpClient {
|
|
11
|
+
private readonly baseUrl;
|
|
12
|
+
private readonly apiKey?;
|
|
13
|
+
private readonly timeout;
|
|
14
|
+
constructor(config: QMemoryClientConfig);
|
|
15
|
+
dispatch(rpc: string, params?: Record<string, any>): Promise<any>;
|
|
16
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qlogicagent",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.0",
|
|
4
4
|
"description": "XiaozhiClaw Agent CLI — subprocess architecture (JSON-RPC over stdio)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -57,8 +57,7 @@
|
|
|
57
57
|
"dotenv": "^17.3.1",
|
|
58
58
|
"nanoid": "^5.1.5",
|
|
59
59
|
"pino": "^9.6.0",
|
|
60
|
-
"pino-pretty": "^13.0.0"
|
|
61
|
-
"qlogicagent-adapter-claw": "^0.2.0"
|
|
60
|
+
"pino-pretty": "^13.0.0"
|
|
62
61
|
},
|
|
63
62
|
"devDependencies": {
|
|
64
63
|
"@types/node": "^22.15.0",
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Centralized agent configuration constants.
|
|
3
|
-
*
|
|
4
|
-
* Re-exports from `tunable-defaults.ts` which is the single source of truth.
|
|
5
|
-
* This file exists for backward compatibility — new consumers should import
|
|
6
|
-
* from `./tunable-defaults.js` directly.
|
|
7
|
-
*/
|
|
8
|
-
export { MAX_ROUNDS_LIMIT, DEFAULT_MAX_ROUNDS, DEFAULT_TEMPERATURE, MAX_TOOL_BUDGET_CAP, DEFAULT_TOOL_BUDGET, MAX_CONSECUTIVE_FAILURES, MAX_IDENTICAL_CALL_REPEATS, DEFAULT_CONTEXT_WINDOW_TOKENS, RESPONSE_BUFFER_TOKENS, DEFAULT_MAX_OUTPUT_TOKENS, DEFAULT_MODEL_MAX_OUTPUT_TOKENS, MAX_OUTPUT_TOKENS_RECOVERY_LIMIT, ESCALATED_MAX_OUTPUT_TOKENS, DIMINISHING_RETURNS_THRESHOLD, DIMINISHING_RETURNS_MIN_CONTINUATIONS, DEFAULT_MAX_RESULT_SIZE_CHARS, MAX_TOOL_RESULTS_PER_MESSAGE_CHARS, TOOL_RESULT_PREVIEW_BYTES, HEARTBEAT_INTERVAL_MS, MAX_529_RETRIES, MAX_API_RETRIES, } from "./tunable-defaults.js";
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { TaskItem, TaskListSummary } from "../skills/tools/task-tool.js";
|
|
2
|
-
import { summarizeTaskList } from "../skills/tools/task-tool.js";
|
|
3
|
-
export declare const TODO_ITEM_STATUS_VALUES: readonly ["not-started", "in-progress", "completed"];
|
|
4
|
-
export type TodoItemStatus = (typeof TODO_ITEM_STATUS_VALUES)[number];
|
|
5
|
-
/** @deprecated Use TaskItem from task-tool.ts */
|
|
6
|
-
export type TodoItem = TaskItem;
|
|
7
|
-
/** @deprecated Use TaskListSummary from task-tool.ts */
|
|
8
|
-
export type TodoListSummary = TaskListSummary;
|
|
9
|
-
/** @deprecated Use summarizeTaskList from task-tool.ts */
|
|
10
|
-
export declare const summarizeTodoList: typeof summarizeTaskList;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Remote Agent Runtime — cloud sandbox execution via HTTP relay.
|
|
3
|
-
*
|
|
4
|
-
* Enables the local agent to delegate tasks to a cloud-hosted sandbox
|
|
5
|
-
* (e.g., qlogicagent-hub GPU workers, CCR-style isolated environments).
|
|
6
|
-
*
|
|
7
|
-
* Protocol:
|
|
8
|
-
* 1. POST /agents/run → start remote execution, returns sessionId
|
|
9
|
-
* 2. GET /agents/:id → poll for status + streaming results
|
|
10
|
-
* 3. POST /agents/:id/abort → cancel remote execution
|
|
11
|
-
*
|
|
12
|
-
* Reference: CC cloudCode / remoteAgent patterns
|
|
13
|
-
*/
|
|
14
|
-
import type { AgentLogger, TokenUsage } from "../../agent/types.js";
|
|
15
|
-
export interface RemoteAgentConfig {
|
|
16
|
-
/** Base URL of the remote execution endpoint (e.g., hub relay). */
|
|
17
|
-
baseUrl: string;
|
|
18
|
-
/** API key for authentication. */
|
|
19
|
-
apiKey: string;
|
|
20
|
-
/** Timeout for HTTP requests in ms (default: 30_000). */
|
|
21
|
-
timeoutMs?: number;
|
|
22
|
-
/** Polling interval in ms (default: 2_000). */
|
|
23
|
-
pollIntervalMs?: number;
|
|
24
|
-
/** Max polling duration in ms (default: 300_000 = 5 min). */
|
|
25
|
-
maxPollDurationMs?: number;
|
|
26
|
-
/** Logger. */
|
|
27
|
-
log: AgentLogger;
|
|
28
|
-
}
|
|
29
|
-
export interface RemoteAgentRequest {
|
|
30
|
-
/** Task prompt for the remote agent. */
|
|
31
|
-
prompt: string;
|
|
32
|
-
/** Model to use on the remote side. */
|
|
33
|
-
model?: string;
|
|
34
|
-
/** Max turns for the remote agent. */
|
|
35
|
-
maxTurns?: number;
|
|
36
|
-
/** Tool restrictions (allowlist). */
|
|
37
|
-
allowedTools?: string[];
|
|
38
|
-
/** Label for tracking. */
|
|
39
|
-
label?: string;
|
|
40
|
-
}
|
|
41
|
-
export interface RemoteAgentResult {
|
|
42
|
-
/** Remote session ID. */
|
|
43
|
-
sessionId: string;
|
|
44
|
-
/** Whether it completed successfully. */
|
|
45
|
-
ok: boolean;
|
|
46
|
-
/** Text output from the remote agent. */
|
|
47
|
-
output?: string;
|
|
48
|
-
/** Error message if failed. */
|
|
49
|
-
error?: string;
|
|
50
|
-
/** Token usage on the remote side. */
|
|
51
|
-
usage?: TokenUsage;
|
|
52
|
-
/** Duration in ms. */
|
|
53
|
-
durationMs: number;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Run a task on a remote agent endpoint.
|
|
57
|
-
*
|
|
58
|
-
* This is a polling-based implementation:
|
|
59
|
-
* 1. POST to start the remote execution
|
|
60
|
-
* 2. Poll GET until completion or timeout
|
|
61
|
-
* 3. Return the aggregated result
|
|
62
|
-
*/
|
|
63
|
-
export declare function runRemoteAgent(config: RemoteAgentConfig, request: RemoteAgentRequest, signal?: AbortSignal): Promise<RemoteAgentResult>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|