qlogicagent 1.1.1 → 1.2.1
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 +8 -6
- package/dist/cli.js +258 -214
- package/dist/index.js +258 -214
- package/dist/orchestration.js +12 -9
- package/dist/types/agent/tool-loop.d.ts +22 -0
- package/dist/types/agent/types.d.ts +33 -1
- package/dist/types/cli/stdio-server.d.ts +96 -1
- package/dist/types/cli/tool-bootstrap.d.ts +8 -1
- package/dist/types/llm/gemini-schema-utils.d.ts +17 -0
- package/dist/types/llm/index.d.ts +11 -2
- package/dist/types/llm/media-transport.d.ts +28 -3
- package/dist/types/llm/model-detection.d.ts +22 -0
- package/dist/types/llm/provider-def.d.ts +17 -4
- package/dist/types/llm/transport.d.ts +60 -2
- package/dist/types/llm/transports/gemini-cache-api.d.ts +86 -0
- package/dist/types/llm/transports/gemini-file-api.d.ts +90 -0
- package/dist/types/llm/transports/gemini-generatecontent.d.ts +52 -0
- package/dist/types/llm/transports/gemini-lyria-realtime.d.ts +117 -0
- package/dist/types/llm/transports/gemini-media.d.ts +40 -8
- package/dist/types/llm/transports/minimax-media.d.ts +34 -5
- package/dist/types/llm/transports/openai-responses.d.ts +60 -0
- package/dist/types/llm/transports/qwen-media.d.ts +32 -7
- package/dist/types/llm/transports/realtime-transport.d.ts +1 -1
- package/dist/types/llm/transports/volcengine-media.d.ts +10 -2
- package/dist/types/llm/transports/zhipu-media.d.ts +24 -2
- package/dist/types/orchestration/agent-instance.d.ts +58 -0
- package/dist/types/orchestration/dag-scheduler.d.ts +72 -0
- package/dist/types/orchestration/product-budget.d.ts +56 -0
- package/dist/types/orchestration/product-checkpoint.d.ts +46 -0
- package/dist/types/orchestration/product-persistence.d.ts +40 -0
- package/dist/types/orchestration/product-worktree.d.ts +13 -0
- package/dist/types/orchestration/solo-evaluator.d.ts +59 -0
- package/dist/types/orchestration/subagent/fork-subagent.d.ts +2 -0
- package/dist/types/orchestration/subagent/task-types.d.ts +4 -0
- package/dist/types/orchestration/tool-cascade.d.ts +2 -2
- package/dist/types/protocol/methods.d.ts +92 -0
- package/dist/types/protocol/notifications.d.ts +163 -1
- package/dist/types/runtime/infra/acp-detector.d.ts +36 -0
- package/dist/types/runtime/infra/acp-detector.test.d.ts +1 -0
- package/dist/types/runtime/infra/acp-protocol-adapter.d.ts +73 -0
- package/dist/types/runtime/infra/acp-protocol-adapter.test.d.ts +1 -0
- package/dist/types/runtime/infra/acp-types.d.ts +397 -0
- package/dist/types/runtime/infra/acp-usage-tracker.d.ts +46 -0
- package/dist/types/runtime/infra/acp-usage-tracker.test.d.ts +1 -0
- package/dist/types/runtime/infra/agent-config-store.d.ts +30 -0
- package/dist/types/runtime/infra/agent-config-store.test.d.ts +1 -0
- package/dist/types/runtime/infra/agent-paths.d.ts +8 -0
- package/dist/types/runtime/infra/agent-process.d.ts +280 -0
- package/dist/types/runtime/infra/agent-process.test.d.ts +1 -0
- package/dist/types/runtime/infra/index.d.ts +10 -0
- package/dist/types/runtime/infra/mcp-bridge.d.ts +166 -0
- package/dist/types/runtime/infra/mcp-bridge.test.d.ts +1 -0
- package/dist/types/runtime/infra/model-id-translator.d.ts +22 -0
- package/dist/types/runtime/infra/model-id-translator.test.d.ts +1 -0
- package/dist/types/runtime/infra/skill-injector.d.ts +51 -0
- package/dist/types/runtime/infra/skill-injector.test.d.ts +1 -0
- package/dist/types/runtime/infra/worktree-backend.d.ts +1 -0
- package/dist/types/runtime/prompt/environment-context.d.ts +6 -0
- package/dist/types/runtime/session/session-persistence.d.ts +9 -8
- package/dist/types/runtime/session/session-state.d.ts +3 -31
- package/dist/types/skills/index.d.ts +2 -10
- package/dist/types/skills/tools/skill-tool.d.ts +101 -0
- package/dist/types/skills/tools/team-tool.d.ts +23 -1
- package/package.json +1 -1
- package/dist/types/runtime/session/session-memory.d.ts +0 -90
- package/dist/types/skills/memory/memory-extractor.d.ts +0 -64
|
@@ -1,25 +1,50 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Qwen (DashScope) Media Transport — TTS
|
|
2
|
+
* Qwen (DashScope) Media Transport — TTS + Video Generation.
|
|
3
3
|
*
|
|
4
|
-
* DashScope
|
|
5
|
-
* Submit: POST /api/v1/services/aigc
|
|
4
|
+
* DashScope async task API pattern:
|
|
5
|
+
* Submit: POST /api/v1/services/aigc/<service>/generation (X-DashScope-Async: enable)
|
|
6
6
|
* Poll: GET /api/v1/tasks/{taskId}
|
|
7
7
|
*
|
|
8
8
|
* Auth: Authorization: Bearer $DASHSCOPE_API_KEY
|
|
9
|
-
* Docs: https://help.aliyun.com/zh/model-studio/developer-reference/
|
|
9
|
+
* Docs: https://help.aliyun.com/zh/model-studio/developer-reference/
|
|
10
|
+
*
|
|
11
|
+
* Video models: wan2.7-t2v (text-to-video), wan2.7-i2v (image-to-video)
|
|
12
|
+
* TTS models: qwen3-tts-voicedesign, cosyvoice-v2
|
|
10
13
|
*/
|
|
11
|
-
import type {
|
|
14
|
+
import type { AsyncMediaTransport, MediaRequest, MediaResult, MediaType } from "../media-transport.js";
|
|
12
15
|
export interface QwenMediaConfig {
|
|
13
16
|
/** Base URL, e.g. "https://dashscope.aliyuncs.com" */
|
|
14
17
|
baseUrl: string;
|
|
15
18
|
timeoutMs?: number;
|
|
16
19
|
}
|
|
17
|
-
export declare class QwenMediaTransport implements
|
|
20
|
+
export declare class QwenMediaTransport implements AsyncMediaTransport {
|
|
18
21
|
readonly supportedTypes: readonly MediaType[];
|
|
19
22
|
private baseUrl;
|
|
20
23
|
private timeoutMs;
|
|
21
24
|
constructor(config: QwenMediaConfig);
|
|
22
25
|
generate(request: MediaRequest, apiKey: string, signal?: AbortSignal): Promise<MediaResult>;
|
|
23
26
|
private pollTask;
|
|
24
|
-
private
|
|
27
|
+
private generateVideo;
|
|
28
|
+
/**
|
|
29
|
+
* Query a single task by ID using DashScope unified task endpoint.
|
|
30
|
+
* GET /api/v1/tasks/{taskId}
|
|
31
|
+
*/
|
|
32
|
+
getTaskStatus(taskId: string, apiKey: string, signal?: AbortSignal): Promise<{
|
|
33
|
+
status: string;
|
|
34
|
+
task: Record<string, unknown>;
|
|
35
|
+
}>;
|
|
36
|
+
/**
|
|
37
|
+
* List tasks — DashScope has a task list API.
|
|
38
|
+
* GET /api/v1/tasks?page_no=1&page_size=20&status=RUNNING
|
|
39
|
+
*/
|
|
40
|
+
listVideoTasks(apiKey: string, options?: {
|
|
41
|
+
after?: string;
|
|
42
|
+
limit?: number;
|
|
43
|
+
status?: string;
|
|
44
|
+
}, signal?: AbortSignal): Promise<Record<string, unknown>>;
|
|
45
|
+
/**
|
|
46
|
+
* Cancel/delete — DashScope does not have a public task cancellation API.
|
|
47
|
+
*/
|
|
48
|
+
deleteVideoTask(_taskId: string, _apiKey: string, _signal?: AbortSignal): Promise<void>;
|
|
49
|
+
private extractMediaUrl;
|
|
25
50
|
}
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
export interface RealtimeConfig {
|
|
42
42
|
/** WebSocket endpoint (e.g. "wss://api.openai.com/v1/realtime") */
|
|
43
43
|
baseUrl: string;
|
|
44
|
-
/** Model to use (e.g. "gpt-
|
|
44
|
+
/** Model to use (e.g. "gpt-realtime-2", "glm-realtime") */
|
|
45
45
|
model: string;
|
|
46
46
|
/** API key */
|
|
47
47
|
apiKey: string;
|
|
@@ -9,13 +9,13 @@
|
|
|
9
9
|
* Auth: Authorization: Bearer $ARK_API_KEY
|
|
10
10
|
* Docs: https://www.volcengine.com/docs/82379/1330310
|
|
11
11
|
*/
|
|
12
|
-
import type {
|
|
12
|
+
import type { AsyncMediaTransport, MediaRequest, MediaResult, MediaType } from "../media-transport.js";
|
|
13
13
|
export interface VolcengineMediaConfig {
|
|
14
14
|
/** Base URL, e.g. "https://ark.cn-beijing.volces.com/api" */
|
|
15
15
|
baseUrl: string;
|
|
16
16
|
timeoutMs?: number;
|
|
17
17
|
}
|
|
18
|
-
export declare class VolcengineMediaTransport implements
|
|
18
|
+
export declare class VolcengineMediaTransport implements AsyncMediaTransport {
|
|
19
19
|
readonly supportedTypes: readonly MediaType[];
|
|
20
20
|
private baseUrl;
|
|
21
21
|
private timeoutMs;
|
|
@@ -34,6 +34,14 @@ export declare class VolcengineMediaTransport implements MediaTransport {
|
|
|
34
34
|
private parseStreamingImage;
|
|
35
35
|
private generateVideo;
|
|
36
36
|
private generate3D;
|
|
37
|
+
/**
|
|
38
|
+
* Query a single video generation task by ID.
|
|
39
|
+
* GET /v3/contents/generations/tasks/{taskId}
|
|
40
|
+
*/
|
|
41
|
+
getTaskStatus(taskId: string, apiKey: string, signal?: AbortSignal): Promise<{
|
|
42
|
+
status: string;
|
|
43
|
+
task: Record<string, unknown>;
|
|
44
|
+
}>;
|
|
37
45
|
/**
|
|
38
46
|
* List video generation tasks with optional filters.
|
|
39
47
|
* GET /v3/contents/generations/tasks
|
|
@@ -13,13 +13,13 @@
|
|
|
13
13
|
* Base URL: https://open.bigmodel.cn/api/paas/v4
|
|
14
14
|
* Auth: Authorization: Bearer $ZHIPU_API_KEY
|
|
15
15
|
*/
|
|
16
|
-
import type {
|
|
16
|
+
import type { AsyncMediaTransport, MediaRequest, MediaResult, MediaType } from "../media-transport.js";
|
|
17
17
|
export interface ZhipuMediaConfig {
|
|
18
18
|
/** Base URL, e.g. "https://open.bigmodel.cn/api/paas/v4" */
|
|
19
19
|
baseUrl: string;
|
|
20
20
|
timeoutMs?: number;
|
|
21
21
|
}
|
|
22
|
-
export declare class ZhipuMediaTransport implements
|
|
22
|
+
export declare class ZhipuMediaTransport implements AsyncMediaTransport {
|
|
23
23
|
readonly supportedTypes: readonly MediaType[];
|
|
24
24
|
private baseUrl;
|
|
25
25
|
private timeoutMs;
|
|
@@ -44,6 +44,28 @@ export declare class ZhipuMediaTransport implements MediaTransport {
|
|
|
44
44
|
* Throws on "FAIL" or timeout.
|
|
45
45
|
*/
|
|
46
46
|
private pollAsyncResult;
|
|
47
|
+
/**
|
|
48
|
+
* Query a single task status — GET /async-result/{id}
|
|
49
|
+
* Zhipu uses a unified async result endpoint for all task types.
|
|
50
|
+
*/
|
|
51
|
+
getTaskStatus(taskId: string, apiKey: string, signal?: AbortSignal): Promise<{
|
|
52
|
+
status: string;
|
|
53
|
+
task: Record<string, unknown>;
|
|
54
|
+
}>;
|
|
55
|
+
/**
|
|
56
|
+
* List recent tasks — Zhipu does not have a native list endpoint.
|
|
57
|
+
* Returns empty since individual task query via getTaskStatus() is the primary API.
|
|
58
|
+
*/
|
|
59
|
+
listVideoTasks(_apiKey: string, _options?: {
|
|
60
|
+
after?: string;
|
|
61
|
+
limit?: number;
|
|
62
|
+
status?: string;
|
|
63
|
+
}, _signal?: AbortSignal): Promise<Record<string, unknown>>;
|
|
64
|
+
/**
|
|
65
|
+
* Cancel/delete is not supported by Zhipu's async API — throws informative error.
|
|
66
|
+
* The /async-result/{id} endpoint is read-only.
|
|
67
|
+
*/
|
|
68
|
+
deleteVideoTask(_taskId: string, _apiKey: string, _signal?: AbortSignal): Promise<void>;
|
|
47
69
|
/**
|
|
48
70
|
* List cloned voices — GET /voice/
|
|
49
71
|
* Returns all voice clones for the current user.
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Instance — Product Mode orchestrator.
|
|
3
|
+
*
|
|
4
|
+
* Manages the lifecycle of a Product: creating instances (agents),
|
|
5
|
+
* scheduling tasks via DAG, enforcing budget, checkpointing state.
|
|
6
|
+
*
|
|
7
|
+
* Flow:
|
|
8
|
+
* 1. product.create → validate DAG, create instances, start scheduling
|
|
9
|
+
* 2. DAG readyTasks → spawn agent → sendTask → on complete → markCompleted → checkpoint
|
|
10
|
+
* 3. product.pause → pause all, checkpoint
|
|
11
|
+
* 4. product.resume → load state, resume scheduling
|
|
12
|
+
* 5. product.checkpoint → manual checkpoint
|
|
13
|
+
*/
|
|
14
|
+
import type { AgentProcessManager } from "../runtime/infra/agent-process.js";
|
|
15
|
+
import type { AcpDetector } from "../runtime/infra/acp-detector.js";
|
|
16
|
+
import type { AgentConfigStore } from "../runtime/infra/agent-config-store.js";
|
|
17
|
+
import type { ProductCreateParams, ProductStatus, ProductSummary } from "../runtime/infra/acp-types.js";
|
|
18
|
+
export interface ProductCallbacks {
|
|
19
|
+
log?: {
|
|
20
|
+
info(msg: string): void;
|
|
21
|
+
warn(msg: string): void;
|
|
22
|
+
};
|
|
23
|
+
onTaskStarted?: (productId: string, taskId: string, assignee: string) => void;
|
|
24
|
+
onTaskCompleted?: (productId: string, taskId: string, result: string) => void;
|
|
25
|
+
onTaskFailed?: (productId: string, taskId: string, error: string) => void;
|
|
26
|
+
onCheckpointed?: (productId: string, timestamp: string) => void;
|
|
27
|
+
onBudgetWarning?: (productId: string, usedTokens: number, maxTotalTokens: number, percentage: number) => void;
|
|
28
|
+
onCompleted?: (productId: string, summary: string) => void;
|
|
29
|
+
}
|
|
30
|
+
export declare class ProductOrchestrator {
|
|
31
|
+
private processManager;
|
|
32
|
+
private acpDetector;
|
|
33
|
+
private configStore;
|
|
34
|
+
private callbacks;
|
|
35
|
+
private sessions;
|
|
36
|
+
constructor(processManager: AgentProcessManager, acpDetector: AcpDetector, configStore: AgentConfigStore | null, callbacks?: ProductCallbacks);
|
|
37
|
+
/**
|
|
38
|
+
* Create a new Product Mode session.
|
|
39
|
+
*/
|
|
40
|
+
create(params: ProductCreateParams): Promise<string>;
|
|
41
|
+
/** Resume a product from persisted state. */
|
|
42
|
+
resume(productId: string, cwd?: string): Promise<void>;
|
|
43
|
+
/** Pause a running product. */
|
|
44
|
+
pause(productId: string): Promise<void>;
|
|
45
|
+
/** Manual checkpoint. */
|
|
46
|
+
checkpoint(productId: string): Promise<void>;
|
|
47
|
+
/** Delete a product session, pausing first if active. */
|
|
48
|
+
delete(productId: string): Promise<void>;
|
|
49
|
+
/** Get product status. */
|
|
50
|
+
getStatus(productId: string): ProductStatus | null;
|
|
51
|
+
/** List all products (in-memory + on-disk). */
|
|
52
|
+
list(cwd?: string): Promise<ProductSummary[]>;
|
|
53
|
+
private scheduleNext;
|
|
54
|
+
private dispatchTask;
|
|
55
|
+
private runTask;
|
|
56
|
+
private finishProduct;
|
|
57
|
+
private buildPersistedState;
|
|
58
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DAG Scheduler — topological task scheduling for Product Mode.
|
|
3
|
+
*
|
|
4
|
+
* Manages a directed acyclic graph of tasks with dependencies.
|
|
5
|
+
* Ensures tasks only execute when all prerequisites are satisfied.
|
|
6
|
+
*/
|
|
7
|
+
import type { ProductTaskDef, ProductTaskStatus } from "../runtime/infra/acp-types.js";
|
|
8
|
+
export interface TaskNode {
|
|
9
|
+
taskId: string;
|
|
10
|
+
assignee: string;
|
|
11
|
+
prompt: string;
|
|
12
|
+
dependsOn: string[];
|
|
13
|
+
status: ProductTaskStatus;
|
|
14
|
+
result?: string;
|
|
15
|
+
error?: string;
|
|
16
|
+
startedAt?: number;
|
|
17
|
+
completedAt?: number;
|
|
18
|
+
}
|
|
19
|
+
export declare class DagScheduler {
|
|
20
|
+
private nodes;
|
|
21
|
+
constructor(tasks: ProductTaskDef[]);
|
|
22
|
+
/** Get all task nodes. */
|
|
23
|
+
getAllTasks(): TaskNode[];
|
|
24
|
+
/** Get a single task node by ID. */
|
|
25
|
+
getTask(taskId: string): TaskNode | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Get tasks ready to run: status=pending and all dependencies completed.
|
|
28
|
+
*/
|
|
29
|
+
getReadyTasks(): TaskNode[];
|
|
30
|
+
/** Mark a task as running. */
|
|
31
|
+
markRunning(taskId: string): void;
|
|
32
|
+
/** Mark a task as completed with result. */
|
|
33
|
+
markCompleted(taskId: string, result: string): void;
|
|
34
|
+
/** Mark a task as failed with error. */
|
|
35
|
+
markFailed(taskId: string, error: string): void;
|
|
36
|
+
/** Mark a task as paused. */
|
|
37
|
+
markPaused(taskId: string): void;
|
|
38
|
+
/** Resume a paused task back to pending. */
|
|
39
|
+
resumePaused(taskId: string): void;
|
|
40
|
+
/** Check if all tasks are terminal (completed, failed, or blocked by failed deps). */
|
|
41
|
+
isFinished(): boolean;
|
|
42
|
+
/** Check if the product completed successfully (all tasks completed). */
|
|
43
|
+
isAllCompleted(): boolean;
|
|
44
|
+
/** Get tasks that are blocked by failed dependencies. */
|
|
45
|
+
getBlockedTasks(): TaskNode[];
|
|
46
|
+
/** Pause all running tasks. */
|
|
47
|
+
pauseAll(): void;
|
|
48
|
+
/** Resume all paused tasks back to pending. */
|
|
49
|
+
resumeAll(): void;
|
|
50
|
+
/** Serialize for persistence. */
|
|
51
|
+
serialize(): Array<{
|
|
52
|
+
taskId: string;
|
|
53
|
+
assignee: string;
|
|
54
|
+
prompt: string;
|
|
55
|
+
dependsOn: string[];
|
|
56
|
+
status: ProductTaskStatus;
|
|
57
|
+
result?: string;
|
|
58
|
+
error?: string;
|
|
59
|
+
startedAt?: number;
|
|
60
|
+
completedAt?: number;
|
|
61
|
+
}>;
|
|
62
|
+
/** Restore from persisted data. */
|
|
63
|
+
restore(data: Array<{
|
|
64
|
+
taskId: string;
|
|
65
|
+
status: ProductTaskStatus;
|
|
66
|
+
result?: string;
|
|
67
|
+
error?: string;
|
|
68
|
+
startedAt?: number;
|
|
69
|
+
completedAt?: number;
|
|
70
|
+
}>): void;
|
|
71
|
+
private validateDag;
|
|
72
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Product Budget — token/time budget enforcement for Product Mode.
|
|
3
|
+
*
|
|
4
|
+
* Tracks cumulative token usage and elapsed time across all agent instances.
|
|
5
|
+
* Emits 80% warning and enforces 100% hard limit.
|
|
6
|
+
*/
|
|
7
|
+
import type { ProductBudget } from "../runtime/infra/acp-types.js";
|
|
8
|
+
import type { AcpUsageTracker } from "../runtime/infra/acp-usage-tracker.js";
|
|
9
|
+
/** Budget state and enforcement result. */
|
|
10
|
+
export type BudgetAction = "ok" | "warning" | "exceeded";
|
|
11
|
+
export interface BudgetCheck {
|
|
12
|
+
action: BudgetAction;
|
|
13
|
+
percentage: number;
|
|
14
|
+
usedTokens: number;
|
|
15
|
+
maxTotalTokens?: number;
|
|
16
|
+
elapsed: number;
|
|
17
|
+
maxDuration?: number;
|
|
18
|
+
}
|
|
19
|
+
export declare class ProductBudgetTracker {
|
|
20
|
+
private maxTotalTokens?;
|
|
21
|
+
private maxDuration?;
|
|
22
|
+
private usedTokens;
|
|
23
|
+
private startedAt;
|
|
24
|
+
private warningEmitted;
|
|
25
|
+
constructor(budget?: {
|
|
26
|
+
maxTotalTokens?: number;
|
|
27
|
+
maxDuration?: number;
|
|
28
|
+
});
|
|
29
|
+
/** Add tokens from a usage tracker snapshot. */
|
|
30
|
+
addUsage(inputTokens: number, outputTokens: number): void;
|
|
31
|
+
/** Add tokens from an ACP usage tracker. */
|
|
32
|
+
addFromTracker(tracker: AcpUsageTracker): void;
|
|
33
|
+
/** Get current elapsed time in ms. */
|
|
34
|
+
getElapsed(): number;
|
|
35
|
+
/** Get the budget snapshot. */
|
|
36
|
+
getBudget(): ProductBudget;
|
|
37
|
+
/**
|
|
38
|
+
* Check budget status. Returns:
|
|
39
|
+
* - "ok": within budget
|
|
40
|
+
* - "warning": 80%+ but not exceeded
|
|
41
|
+
* - "exceeded": over 100%, should pause
|
|
42
|
+
*/
|
|
43
|
+
check(): BudgetCheck;
|
|
44
|
+
/** Restore from persisted budget data. */
|
|
45
|
+
restore(data: {
|
|
46
|
+
usedTokens: number;
|
|
47
|
+
startedAt: number;
|
|
48
|
+
warningEmitted: boolean;
|
|
49
|
+
}): void;
|
|
50
|
+
/** Serialize for persistence. */
|
|
51
|
+
serialize(): {
|
|
52
|
+
usedTokens: number;
|
|
53
|
+
startedAt: number;
|
|
54
|
+
warningEmitted: boolean;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Product Checkpoint — automatic and manual checkpoint triggers.
|
|
3
|
+
*
|
|
4
|
+
* Rules:
|
|
5
|
+
* - Auto-checkpoint on task completion
|
|
6
|
+
* - 5 min fallback timer for active products
|
|
7
|
+
* - 30 min timer for long-running products (>48h)
|
|
8
|
+
* - Manual checkpoint via product.checkpoint RPC
|
|
9
|
+
*/
|
|
10
|
+
import type { PersistedProductState } from "./product-persistence.js";
|
|
11
|
+
export interface CheckpointCallbacks {
|
|
12
|
+
/** Called after each checkpoint save. */
|
|
13
|
+
onCheckpoint?: (productId: string, timestamp: string) => void;
|
|
14
|
+
/** Return current state snapshot for periodic auto-saves. */
|
|
15
|
+
getState?: () => PersistedProductState | null;
|
|
16
|
+
log?: {
|
|
17
|
+
info(msg: string): void;
|
|
18
|
+
warn(msg: string): void;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export declare class ProductCheckpointManager {
|
|
22
|
+
private callbacks;
|
|
23
|
+
/** Fallback interval (5 min default, 30 min for >48h long-running). */
|
|
24
|
+
private static readonly DEFAULT_INTERVAL;
|
|
25
|
+
private static readonly LONG_RUNNING_INTERVAL;
|
|
26
|
+
private static readonly LONG_RUNNING_THRESHOLD;
|
|
27
|
+
private timer;
|
|
28
|
+
private lastCheckpointAt;
|
|
29
|
+
private cwd?;
|
|
30
|
+
constructor(callbacks?: CheckpointCallbacks);
|
|
31
|
+
/** Start periodic checkpointing for a product. */
|
|
32
|
+
start(cwd?: string): void;
|
|
33
|
+
/** Stop periodic checkpointing. */
|
|
34
|
+
stop(): void;
|
|
35
|
+
/** Get the appropriate checkpoint interval based on elapsed time. */
|
|
36
|
+
getInterval(elapsedMs: number): number;
|
|
37
|
+
/** Check if a checkpoint is due based on elapsed time since last checkpoint. */
|
|
38
|
+
isDue(elapsedMs: number): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Perform a checkpoint: save state to disk and notify.
|
|
41
|
+
* Called on task completion or by periodic timer.
|
|
42
|
+
*/
|
|
43
|
+
checkpoint(state: PersistedProductState): Promise<void>;
|
|
44
|
+
/** Get the time of last checkpoint. */
|
|
45
|
+
getLastCheckpointAt(): number;
|
|
46
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Product Persistence — read/write Product Mode state to disk.
|
|
3
|
+
*
|
|
4
|
+
* State is stored at `<project>/.qlogicagent/products/<productId>/product-state.json`.
|
|
5
|
+
* Product listing is done by enumerating subdirectories.
|
|
6
|
+
*/
|
|
7
|
+
import type { ProductPhase, ProductTaskStatus, ProductInstanceDef } from "../runtime/infra/acp-types.js";
|
|
8
|
+
export interface PersistedProductState {
|
|
9
|
+
productId: string;
|
|
10
|
+
name: string;
|
|
11
|
+
phase: ProductPhase;
|
|
12
|
+
cwd: string;
|
|
13
|
+
instances: ProductInstanceDef[];
|
|
14
|
+
tasks: Array<{
|
|
15
|
+
taskId: string;
|
|
16
|
+
assignee: string;
|
|
17
|
+
prompt: string;
|
|
18
|
+
dependsOn: string[];
|
|
19
|
+
status: ProductTaskStatus;
|
|
20
|
+
result?: string;
|
|
21
|
+
error?: string;
|
|
22
|
+
startedAt?: number;
|
|
23
|
+
completedAt?: number;
|
|
24
|
+
}>;
|
|
25
|
+
budget: {
|
|
26
|
+
maxTotalTokens?: number;
|
|
27
|
+
maxDuration?: number;
|
|
28
|
+
usedTokens: number;
|
|
29
|
+
startedAt: number;
|
|
30
|
+
warningEmitted: boolean;
|
|
31
|
+
};
|
|
32
|
+
createdAt: string;
|
|
33
|
+
lastCheckpointAt: string;
|
|
34
|
+
}
|
|
35
|
+
/** Save product state to disk. */
|
|
36
|
+
export declare function saveProductState(state: PersistedProductState, cwd?: string): Promise<void>;
|
|
37
|
+
/** Load product state from disk. Returns undefined if not found. */
|
|
38
|
+
export declare function loadProductState(productId: string, cwd?: string): Promise<PersistedProductState | undefined>;
|
|
39
|
+
/** List all product IDs with their persisted state. */
|
|
40
|
+
export declare function listProducts(cwd?: string): Promise<PersistedProductState[]>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Product Worktree — shared git worktree helpers for Solo and Product Mode.
|
|
3
|
+
*/
|
|
4
|
+
/** Find the git repository root from a working directory. */
|
|
5
|
+
export declare function findGitRoot(cwd: string): Promise<string | null>;
|
|
6
|
+
/** Create an isolated git worktree. Returns the worktree path. */
|
|
7
|
+
export declare function createWorktree(gitRoot: string, name: string, baseBranch?: string): Promise<string>;
|
|
8
|
+
/** Get a git diff stat from a worktree. */
|
|
9
|
+
export declare function getWorktreeDiff(worktreePath: string): Promise<string>;
|
|
10
|
+
/** Remove a git worktree. */
|
|
11
|
+
export declare function removeWorktree(gitRoot: string, path: string): Promise<void>;
|
|
12
|
+
/** Merge a worktree branch into the current branch. */
|
|
13
|
+
export declare function mergeWorktree(gitRoot: string, worktreeBranch: string): Promise<string>;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Solo Mode Evaluator — parallel N-agent PK with leader evaluation.
|
|
3
|
+
*
|
|
4
|
+
* Flow:
|
|
5
|
+
* 1. solo.start → create N isolated git worktrees, spawn N agents in parallel
|
|
6
|
+
* 2. Each agent receives the same task prompt in its own worktree
|
|
7
|
+
* 3. On completion, collect each agent's resultText + git diff
|
|
8
|
+
* 4. Leader agent evaluates all results → picks winner
|
|
9
|
+
* 5. solo.select → merge winning worktree, clean up others
|
|
10
|
+
*
|
|
11
|
+
* Degradation: if K agents fail but ≥1 succeeds, evaluation still proceeds.
|
|
12
|
+
*/
|
|
13
|
+
import type { AgentProcessManager } from "../runtime/infra/agent-process.js";
|
|
14
|
+
import type { AcpDetector } from "../runtime/infra/acp-detector.js";
|
|
15
|
+
import type { AgentConfigStore } from "../runtime/infra/agent-config-store.js";
|
|
16
|
+
import type { SoloAgentState, SoloEvaluation, SoloStatus, SoloStartParams, SoloSelectParams } from "../runtime/infra/acp-types.js";
|
|
17
|
+
export interface SoloCallbacks {
|
|
18
|
+
log?: {
|
|
19
|
+
info(msg: string): void;
|
|
20
|
+
warn(msg: string): void;
|
|
21
|
+
debug?(msg: string): void;
|
|
22
|
+
};
|
|
23
|
+
onProgress?: (soloId: string, agentId: string, state: SoloAgentState, progress?: string) => void;
|
|
24
|
+
onEvaluation?: (soloId: string, evaluation: SoloEvaluation) => void;
|
|
25
|
+
/** Streaming text delta from a competing agent (forwarded from child process). */
|
|
26
|
+
onAgentDelta?: (soloId: string, agentId: string, text: string) => void;
|
|
27
|
+
}
|
|
28
|
+
export declare class SoloEvaluator {
|
|
29
|
+
private processManager;
|
|
30
|
+
private acpDetector;
|
|
31
|
+
private configStore;
|
|
32
|
+
private callbacks;
|
|
33
|
+
private sessions;
|
|
34
|
+
constructor(processManager: AgentProcessManager, acpDetector: AcpDetector, configStore: AgentConfigStore | null, callbacks?: SoloCallbacks);
|
|
35
|
+
/**
|
|
36
|
+
* Start a Solo Mode PK session.
|
|
37
|
+
* Creates worktrees, spawns agents in parallel, waits for completion, then evaluates.
|
|
38
|
+
*/
|
|
39
|
+
start(params: SoloStartParams): Promise<string>;
|
|
40
|
+
/** Get the current status of a solo session. */
|
|
41
|
+
getStatus(soloId: string): SoloStatus | null;
|
|
42
|
+
/** Cancel a running solo session. Kill all agents and clean up worktrees. */
|
|
43
|
+
cancel(soloId: string): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Select a winner and merge their worktree into the main branch.
|
|
46
|
+
*/
|
|
47
|
+
select(params: SoloSelectParams): Promise<string>;
|
|
48
|
+
/** List all solo sessions. */
|
|
49
|
+
listSessions(): SoloStatus[];
|
|
50
|
+
/** Delete a solo session, killing agents and cleaning up worktrees if still active. */
|
|
51
|
+
delete(soloId: string): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Build an evaluation prompt and send to the leader agent (first successful).
|
|
54
|
+
* Returns evaluation result.
|
|
55
|
+
*/
|
|
56
|
+
private evaluate;
|
|
57
|
+
private parseEvaluationResponse;
|
|
58
|
+
private cleanupWorktrees;
|
|
59
|
+
}
|
|
@@ -28,6 +28,8 @@ export interface ForkContext {
|
|
|
28
28
|
abortSignal?: AbortSignal;
|
|
29
29
|
/** Parent's agent ID for lineage tracking. */
|
|
30
30
|
parentAgentId: string;
|
|
31
|
+
/** Isolated worktree path for this fork child (CC team worktree parity). */
|
|
32
|
+
worktreePath?: string;
|
|
31
33
|
}
|
|
32
34
|
export interface ForkChildConfig {
|
|
33
35
|
/** The agent definition to run. */
|
|
@@ -101,6 +101,10 @@ export interface InProcessTeammateTaskState extends TaskStateBase {
|
|
|
101
101
|
permissionMode: string;
|
|
102
102
|
/** Async mailbox for coordinator ↔ worker communication. */
|
|
103
103
|
mailboxId?: string;
|
|
104
|
+
/** Isolated git worktree path for this teammate (CC team worktree parity). */
|
|
105
|
+
worktreePath?: string;
|
|
106
|
+
/** Worktree branch name (for cleanup). */
|
|
107
|
+
worktreeBranch?: string;
|
|
104
108
|
}
|
|
105
109
|
/** A single dream agent turn — text output + tool use count. */
|
|
106
110
|
export interface DreamTurn {
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
* Two levels of provider tool integration:
|
|
11
11
|
*
|
|
12
12
|
* 1. **D-level (builtin tools)**: Injected directly into chat completion request
|
|
13
|
-
* via `builtinWebSearch` / `builtinCodeInterpreter` quirks.
|
|
13
|
+
* via `builtinWebSearch` / `builtinCodeInterpreter` / `builtinUrlContext` / `builtinMapsGrounding` / `builtinFileSearch` quirks.
|
|
14
14
|
* The LLM decides to use these inline during generation — no agent intervention.
|
|
15
|
-
* → Handled by openai-chat.ts transport
|
|
15
|
+
* → Handled by openai-chat.ts (GLM/Kimi) and gemini-generatecontent.ts (Google) transport layers.
|
|
16
16
|
*
|
|
17
17
|
* 2. **C-level (independent APIs)**: Discrete API endpoints the agent calls explicitly
|
|
18
18
|
* as tool steps (web_search, reader, tokenizer, moderations).
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import type { ChatMessage, ToolDefinition } from "../agent/types.js";
|
|
10
10
|
import type { TodoItem } from "../contracts/todo.js";
|
|
11
|
+
import type { AgentDescriptor, AgentConfig, AgentsScanParams, AgentsConfigParams, AgentsSetConfigParams, AgentsGetConfigParams, AgentsRemoveConfigParams, AgentsSetGatewayParams, SoloStatus, SoloStartParams, SoloIdParams, SoloSelectParams, ProductCreateParams, ProductIdParams, ProductStatus, ProductSummary } from "../runtime/infra/acp-types.js";
|
|
11
12
|
export interface InitializeParams {
|
|
12
13
|
protocolVersion: string;
|
|
13
14
|
host?: {
|
|
@@ -392,6 +393,97 @@ export interface RpcMethodMap {
|
|
|
392
393
|
received: boolean;
|
|
393
394
|
};
|
|
394
395
|
};
|
|
396
|
+
"agents.scan": {
|
|
397
|
+
params: AgentsScanParams;
|
|
398
|
+
result: AgentDescriptor[];
|
|
399
|
+
};
|
|
400
|
+
"agents.list": {
|
|
401
|
+
params: undefined;
|
|
402
|
+
result: AgentDescriptor[];
|
|
403
|
+
};
|
|
404
|
+
"agents.config": {
|
|
405
|
+
params: AgentsConfigParams;
|
|
406
|
+
result: {
|
|
407
|
+
ok: true;
|
|
408
|
+
};
|
|
409
|
+
};
|
|
410
|
+
"agents.setConfig": {
|
|
411
|
+
params: AgentsSetConfigParams;
|
|
412
|
+
result: {
|
|
413
|
+
ok: true;
|
|
414
|
+
};
|
|
415
|
+
};
|
|
416
|
+
"agents.getConfig": {
|
|
417
|
+
params: AgentsGetConfigParams;
|
|
418
|
+
result: AgentConfig | null;
|
|
419
|
+
};
|
|
420
|
+
"agents.removeConfig": {
|
|
421
|
+
params: AgentsRemoveConfigParams;
|
|
422
|
+
result: {
|
|
423
|
+
ok: true;
|
|
424
|
+
};
|
|
425
|
+
};
|
|
426
|
+
"agents.setGateway": {
|
|
427
|
+
params: AgentsSetGatewayParams;
|
|
428
|
+
result: {
|
|
429
|
+
ok: true;
|
|
430
|
+
};
|
|
431
|
+
};
|
|
432
|
+
"solo.start": {
|
|
433
|
+
params: SoloStartParams;
|
|
434
|
+
result: {
|
|
435
|
+
soloId: string;
|
|
436
|
+
};
|
|
437
|
+
};
|
|
438
|
+
"solo.status": {
|
|
439
|
+
params: SoloIdParams;
|
|
440
|
+
result: SoloStatus | null;
|
|
441
|
+
};
|
|
442
|
+
"solo.cancel": {
|
|
443
|
+
params: SoloIdParams;
|
|
444
|
+
result: {
|
|
445
|
+
ok: true;
|
|
446
|
+
};
|
|
447
|
+
};
|
|
448
|
+
"solo.select": {
|
|
449
|
+
params: SoloSelectParams;
|
|
450
|
+
result: {
|
|
451
|
+
ok: true;
|
|
452
|
+
mergedBranch: string;
|
|
453
|
+
};
|
|
454
|
+
};
|
|
455
|
+
"product.create": {
|
|
456
|
+
params: ProductCreateParams;
|
|
457
|
+
result: {
|
|
458
|
+
productId: string;
|
|
459
|
+
};
|
|
460
|
+
};
|
|
461
|
+
"product.resume": {
|
|
462
|
+
params: ProductIdParams;
|
|
463
|
+
result: {
|
|
464
|
+
ok: true;
|
|
465
|
+
};
|
|
466
|
+
};
|
|
467
|
+
"product.pause": {
|
|
468
|
+
params: ProductIdParams;
|
|
469
|
+
result: {
|
|
470
|
+
ok: true;
|
|
471
|
+
};
|
|
472
|
+
};
|
|
473
|
+
"product.checkpoint": {
|
|
474
|
+
params: ProductIdParams;
|
|
475
|
+
result: {
|
|
476
|
+
ok: true;
|
|
477
|
+
};
|
|
478
|
+
};
|
|
479
|
+
"product.status": {
|
|
480
|
+
params: ProductIdParams;
|
|
481
|
+
result: ProductStatus | null;
|
|
482
|
+
};
|
|
483
|
+
"product.list": {
|
|
484
|
+
params: undefined;
|
|
485
|
+
result: ProductSummary[];
|
|
486
|
+
};
|
|
395
487
|
}
|
|
396
488
|
/** All known RPC method names. */
|
|
397
489
|
export type RpcMethod = keyof RpcMethodMap;
|