qlogicagent 2.19.13 → 2.20.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/README.md +0 -1
- package/dist/agent-contract.js +1 -1
- package/dist/agent.js +31 -31
- package/dist/cli.js +1 -1
- package/dist/host-contract.js +1 -1
- package/dist/index.js +457 -453
- package/dist/orchestration.js +13 -13
- package/dist/project-memory-host.js +19 -18
- package/dist/protocol.js +1 -1
- package/dist/tunables.js +1 -1
- package/dist/types/cli/acp-extended-handlers.d.ts +5 -10
- package/dist/types/cli/acp-extended-host-adapter.d.ts +1 -1
- package/dist/types/cli/community-workflow-installer.d.ts +2 -2
- package/dist/types/cli/handlers/dream-handler.d.ts +6 -0
- package/dist/types/cli/handlers/goal-handler.d.ts +1 -13
- package/dist/types/cli/handlers/product-handler.d.ts +6 -9
- package/dist/types/cli/handlers/solo-handler.d.ts +3 -6
- package/dist/types/cli/handlers/workflow-compute-handler.d.ts +1 -1
- package/dist/types/cli/memory-coordinator.d.ts +0 -2
- package/dist/types/cli/multi-agent-handler-host.d.ts +1 -1
- package/dist/types/cli/orchestration-memory-context.d.ts +1 -0
- package/dist/types/cli/product-coordinator.d.ts +2 -5
- package/dist/types/cli/rpc-registry.d.ts +0 -3
- package/dist/types/cli/runtime-hook-bootstrap.d.ts +0 -2
- package/dist/types/cli/stdio-rpc-handler-hosts.d.ts +2 -1
- package/dist/types/cli/stdio-server.d.ts +2 -3
- package/dist/types/cli/task-distillation-coordinator.d.ts +0 -3
- package/dist/types/contracts/hooks.d.ts +2 -0
- package/dist/types/host-contract/index.d.ts +3 -13
- package/dist/types/index.d.ts +0 -1
- package/dist/types/orchestration/agent-instance.d.ts +30 -15
- package/dist/types/orchestration/agent-roster.d.ts +2 -2
- package/dist/types/orchestration/goal-loop-coordinator.d.ts +18 -8
- package/dist/types/orchestration/goal-mode-adapters.d.ts +6 -1
- package/dist/types/orchestration/goal-run-persistence.d.ts +12 -10
- package/dist/types/orchestration/goal-run-types.d.ts +3 -21
- package/dist/types/orchestration/index.d.ts +0 -1
- package/dist/types/orchestration/product-checkpoint.d.ts +10 -6
- package/dist/types/orchestration/product-persistence.d.ts +47 -20
- package/dist/types/orchestration/product-planner.d.ts +30 -10
- package/dist/types/orchestration/product-run-coordinator.d.ts +4 -3
- package/dist/types/orchestration/solo-evaluator.d.ts +10 -16
- package/dist/types/orchestration/solo-persistence.d.ts +10 -10
- package/dist/types/orchestration/workflow/budget-permission-gate.d.ts +1 -1
- package/dist/types/orchestration/workflow/capability-catalog.d.ts +11 -34
- package/dist/types/orchestration/workflow/host-executors.d.ts +3 -3
- package/dist/types/orchestration/workflow/n8n-import.d.ts +0 -1
- package/dist/types/orchestration/workflow/node-schema.d.ts +5 -18
- package/dist/types/orchestration/workflow/params-schema.d.ts +7 -16
- package/dist/types/orchestration/workflow/qla-executor-host.d.ts +4 -27
- package/dist/types/orchestration/workflow/workflow-bundle.d.ts +10 -28
- package/dist/types/orchestration/workflow/workflow-controller.d.ts +14 -8
- package/dist/types/orchestration/workflow/workflow-error.d.ts +1 -1
- package/dist/types/orchestration/workflow/workflow-render.d.ts +1 -1
- package/dist/types/orchestration/workflow/workflow-scheduler.d.ts +8 -8
- package/dist/types/orchestration/workflow/workflow-store.d.ts +7 -8
- package/dist/types/orchestration/workflow-chat-builder.d.ts +1 -1
- package/dist/types/protocol/agent-contract.d.ts +7 -7
- package/dist/types/protocol/methods.d.ts +1 -129
- package/dist/types/protocol/notifications.d.ts +1 -1
- package/dist/types/protocol/wire/acp-agent-management.d.ts +45 -24
- package/dist/types/protocol/wire/acp-protocol.d.ts +3 -8
- package/dist/types/protocol/wire/agent-methods.d.ts +2 -468
- package/dist/types/protocol/wire/index.d.ts +1 -1
- package/dist/types/protocol/wire/notification-payloads.d.ts +0 -6
- package/dist/types/protocol/wire/thread-protocol.d.ts +1 -1
- package/dist/types/runtime/config/tunable-defaults.d.ts +0 -9
- package/dist/types/runtime/hooks/memory-hooks.d.ts +11 -4
- package/dist/types/runtime/infra/acp-protocol-adapter.d.ts +1 -2
- package/dist/types/runtime/memory/implicit-extraction.d.ts +4 -1
- package/dist/types/runtime/memory/recall-category-filter.d.ts +0 -12
- package/dist/types/runtime/ports/memory-recall-source.d.ts +1 -0
- package/dist/types/runtime/ports/project-memory-store.d.ts +3 -0
- package/dist/types/skills/memory/host-memory-provider.d.ts +7 -0
- package/dist/types/skills/memory/memdir.d.ts +1 -2
- package/dist/types/skills/memory/task-distillation.d.ts +18 -4
- package/dist/types/skills/skill-system/skill-lifecycle.d.ts +0 -17
- package/dist/types/skills/skill-system/skill-validation.d.ts +1 -1
- package/dist/types/transport/acp-server.d.ts +1 -5
- package/dist/types/workflow-host.d.ts +2 -4
- package/dist/workflow-host.js +7 -9
- package/package.json +1 -1
- package/dist/types/cli/credential-vault.d.ts +0 -68
- package/dist/types/orchestration/skill-improvement.d.ts +0 -97
- package/dist/types/skills/memory/local-store-records.d.ts +0 -206
- package/dist/types/skills/memory/local-store.d.ts +0 -376
- package/dist/types/skills/memory/memory-attachment-store.d.ts +0 -62
- package/dist/types/skills/memory/memory-consolidation.d.ts +0 -64
- package/dist/types/skills/memory/memory-db-path.d.ts +0 -13
- package/dist/types/skills/memory/proposal-consumer.d.ts +0 -51
- package/dist/types/skills/memory/sqlite-memory-mappers.d.ts +0 -7
- package/dist/types/skills/memory/sqlite-memory-schema.d.ts +0 -11
|
@@ -12,10 +12,11 @@
|
|
|
12
12
|
* 5. product.checkpoint → manual checkpoint
|
|
13
13
|
*/
|
|
14
14
|
import type { HostAgentProviderDirectory } from "../runtime/infra/host-agent-provider-directory.js";
|
|
15
|
-
import type { ProductPhase, ProductCreateParams, ProductStatus
|
|
15
|
+
import type { ProductPhase, ProductCreateParams, ProductStatus } from "../protocol/wire/acp-agent-management.js";
|
|
16
16
|
import { type PlannerMemoryContext } from "./planner-memory-brief.js";
|
|
17
17
|
import type { DagMutation } from "./product-planner.js";
|
|
18
18
|
import type { ProductLeaderCoordinator } from "./product-run-coordinator.js";
|
|
19
|
+
import { type HostRunStateAuthority } from "./run-state-host-authority.js";
|
|
19
20
|
import type { DelegateBridge } from "./delegate-bridge.js";
|
|
20
21
|
export type { ProductLeaderCoordinator } from "./product-run-coordinator.js";
|
|
21
22
|
export interface ProductCallbacks {
|
|
@@ -41,7 +42,9 @@ export interface ProductCallbacks {
|
|
|
41
42
|
* warning notified the user while the actual auto-pause was log-only — the strongest budget
|
|
42
43
|
* intervention must be at least as loud as its warning. `reason` says WHICH limit tripped. */
|
|
43
44
|
onBudgetExceeded?: (productId: string, usedTokens: number, maxTotalTokens: number | undefined, reason: string) => void;
|
|
44
|
-
onCompleted?: (productId: string, summary: string, phase: Extract<ProductPhase, "completed" | "failed"
|
|
45
|
+
onCompleted?: (productId: string, summary: string, phase: Extract<ProductPhase, "completed" | "failed">, projectId: string) => void | Promise<void>;
|
|
46
|
+
/** Host RunState writes are lifecycle barriers; failures stop the run and surface explicitly. */
|
|
47
|
+
onPersistenceError?: (productId: string, error: string, projectId: string) => void;
|
|
45
48
|
/** DAG topology resolved and sent to client for visualization. */
|
|
46
49
|
onDagTopology?: (productId: string, nodes: {
|
|
47
50
|
id: string;
|
|
@@ -55,8 +58,7 @@ export interface ProductCallbacks {
|
|
|
55
58
|
onBudgetUpdate?: (productId: string, inputTokens: number, outputTokens: number, elapsed: number, maxTotalTokens?: number) => void;
|
|
56
59
|
/** Streaming text output from a running task. */
|
|
57
60
|
onTaskOutputDelta?: (productId: string, taskId: string, text: string) => void;
|
|
58
|
-
/** Per-task tool activity heartbeat
|
|
59
|
-
* turn.tool_call 在 product-coordinator 转 product.agentActivity,PM 在 delegate 路径看不见 worker)。 */
|
|
61
|
+
/** Per-task tool activity heartbeat emitted from the supervised delegate event sink. */
|
|
60
62
|
onTaskActivity?: (productId: string, taskId: string, toolName: string) => void;
|
|
61
63
|
/** Team roster resolved at run start — fired once (engine-driven) for both initial start and resume,
|
|
62
64
|
* so the run view's 团队成员 panel populates live instead of only on a history reopen. */
|
|
@@ -64,8 +66,8 @@ export interface ProductCallbacks {
|
|
|
64
66
|
agentId: string;
|
|
65
67
|
role: string;
|
|
66
68
|
name: string;
|
|
67
|
-
}[]) => void;
|
|
68
|
-
/**
|
|
69
|
+
}[], projectId: string) => void;
|
|
70
|
+
/** Required Gateway delegate access; orchestration fails loud when the Host rail is unavailable. */
|
|
69
71
|
getDelegateBridge?: () => DelegateBridge | undefined;
|
|
70
72
|
}
|
|
71
73
|
/**
|
|
@@ -97,13 +99,18 @@ export declare class ProductOrchestrator {
|
|
|
97
99
|
/**
|
|
98
100
|
* Create a new Product Mode session.
|
|
99
101
|
*/
|
|
100
|
-
create(params: ProductCreateParams
|
|
102
|
+
create(params: ProductCreateParams, options?: {
|
|
103
|
+
authority?: HostRunStateAuthority;
|
|
104
|
+
}): Promise<string>;
|
|
101
105
|
/** Resume a product from persisted state. */
|
|
102
|
-
resume(productId: string,
|
|
106
|
+
resume(productId: string, opts?: {
|
|
103
107
|
additionalBudget?: {
|
|
104
108
|
maxTotalTokens?: number;
|
|
105
109
|
maxDuration?: number;
|
|
106
110
|
};
|
|
111
|
+
authority?: HostRunStateAuthority;
|
|
112
|
+
projectId?: string;
|
|
113
|
+
cwd?: string;
|
|
107
114
|
}): Promise<void>;
|
|
108
115
|
/**
|
|
109
116
|
* Pause a running product — the SINGLE pause path (I9).
|
|
@@ -126,11 +133,16 @@ export declare class ProductOrchestrator {
|
|
|
126
133
|
private waitForInFlightSettle;
|
|
127
134
|
/** Manual checkpoint. */
|
|
128
135
|
checkpoint(productId: string): Promise<void>;
|
|
129
|
-
applyDagMutations(productId: string, mutations: readonly DagMutation[]): void
|
|
130
|
-
/** Delete a product session,
|
|
131
|
-
delete(productId: string
|
|
132
|
-
|
|
136
|
+
applyDagMutations(productId: string, mutations: readonly DagMutation[]): Promise<void>;
|
|
137
|
+
/** Delete a product session, including a persisted execution run after process restart. */
|
|
138
|
+
delete(productId: string, options?: {
|
|
139
|
+
authority?: HostRunStateAuthority;
|
|
140
|
+
projectId?: string;
|
|
141
|
+
cwd?: string;
|
|
142
|
+
}): Promise<void>;
|
|
143
|
+
/** Roll back a Product to a Host checkpoint and resume it through the same execution path. */
|
|
133
144
|
rollback(productId: string, checkpoint?: string): Promise<void>;
|
|
145
|
+
private stopSessionForTeardown;
|
|
134
146
|
/**
|
|
135
147
|
* Replay from an arbitrary completed/failed task (CrewAI Crew.replay(taskId) parity).
|
|
136
148
|
*
|
|
@@ -142,6 +154,7 @@ export declare class ProductOrchestrator {
|
|
|
142
154
|
*/
|
|
143
155
|
replayTask(productId: string, taskId: string): Promise<void>;
|
|
144
156
|
getStatus(productId: string): ProductStatus | null;
|
|
157
|
+
getProjectId(productId: string): string | undefined;
|
|
145
158
|
/** Live DAG progress snapshot for a product (for the planner's execution-phase leader). */
|
|
146
159
|
getProgressSnapshot(productId: string): {
|
|
147
160
|
total: number;
|
|
@@ -149,16 +162,18 @@ export declare class ProductOrchestrator {
|
|
|
149
162
|
running: number;
|
|
150
163
|
failed: number;
|
|
151
164
|
} | null;
|
|
152
|
-
getPersistedStatus(productId: string, cwd?: string): Promise<ProductStatus | null>;
|
|
153
|
-
/** List all products (in-memory + on-disk). */
|
|
154
|
-
list(cwd?: string): Promise<ProductSummary[]>;
|
|
155
165
|
private scheduleNext;
|
|
166
|
+
private pauseForBudget;
|
|
167
|
+
private publishBudgetWarning;
|
|
156
168
|
private isInstanceBusy;
|
|
157
169
|
private dispatchTask;
|
|
170
|
+
private publishUnassignedTaskFailure;
|
|
158
171
|
private runTask;
|
|
159
172
|
private consultLeaderAfterFailure;
|
|
160
173
|
private applyDagMutationsToSession;
|
|
161
174
|
private finishProduct;
|
|
175
|
+
private failRunStatePersistence;
|
|
176
|
+
private publishNotification;
|
|
162
177
|
private emitDagTopology;
|
|
163
178
|
private cleanupInstanceWorktree;
|
|
164
179
|
private buildPersistedState;
|
|
@@ -4,8 +4,8 @@ import type { AgentRosterEntry } from "../protocol/wire/acp-agent-management.js"
|
|
|
4
4
|
* strengths hint + its backing model. Leader-only soft hints — NOT a capability contract.
|
|
5
5
|
*
|
|
6
6
|
* `allowedAgents` is PRESENCE-based (an explicit `[]` is meaningful, NOT the same as omitted):
|
|
7
|
-
* - `undefined` / omitted → ALL ready agents
|
|
8
|
-
*
|
|
7
|
+
* - `undefined` / omitted → ALL ready agents. The allow-set is `null` and the catalog filter applies
|
|
8
|
+
* no constraint.
|
|
9
9
|
* - `[]` (explicit empty array) → ONLY the leader 小智 (qlogicagent): the allow-set is an empty Set, so
|
|
10
10
|
* the catalog filter drops every non-leader entry; the leader is force-included below → roster = just
|
|
11
11
|
* 小智. This is the user deliberately deselecting every worker.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type HostRunStateAuthority } from "./run-state-host-authority.js";
|
|
1
2
|
import { type AcceptanceChecklist, type AcceptanceCriterion, type AcceptanceDelta, type GoalQueuedMessage, type PersistedGoalRunState, type PhaseSpec } from "./goal-run-types.js";
|
|
2
3
|
export interface LeaderPort {
|
|
3
4
|
deriveChecklist(goal: string): Promise<AcceptanceCriterion[]>;
|
|
@@ -26,18 +27,27 @@ export interface PhaseRunnerPort {
|
|
|
26
27
|
}>;
|
|
27
28
|
}
|
|
28
29
|
export type GoalNotifier = (method: string, payload: Record<string, unknown>) => void;
|
|
30
|
+
export interface GoalLoopCoordinatorDeps {
|
|
31
|
+
leader: LeaderPort;
|
|
32
|
+
runner: PhaseRunnerPort;
|
|
33
|
+
cwd: string;
|
|
34
|
+
projectId: string;
|
|
35
|
+
canonicalSessionId: string;
|
|
36
|
+
runStateAuthority?: HostRunStateAuthority;
|
|
37
|
+
notify?: GoalNotifier;
|
|
38
|
+
log?: {
|
|
39
|
+
warn(message: string): void;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
29
42
|
export declare class GoalLoopCoordinator {
|
|
30
43
|
private readonly deps;
|
|
31
44
|
private seq;
|
|
32
45
|
private opChain;
|
|
33
46
|
private activeAbort;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
runner: PhaseRunnerPort;
|
|
37
|
-
cwd: string;
|
|
38
|
-
notify?: GoalNotifier;
|
|
39
|
-
});
|
|
47
|
+
private readonly persistenceContext;
|
|
48
|
+
constructor(deps: GoalLoopCoordinatorDeps);
|
|
40
49
|
private serialize;
|
|
50
|
+
private notify;
|
|
41
51
|
private append;
|
|
42
52
|
private persist;
|
|
43
53
|
/** Launch a goal-run (instant, Codex-style). Returns the goalRunId. */
|
|
@@ -55,8 +65,8 @@ export declare class GoalLoopCoordinator {
|
|
|
55
65
|
* in-flight breadcrumb, then run the terminal checks. Called by BOTH the normal path and crash-recovery
|
|
56
66
|
* so neither duplicates this logic. Assess throwing propagates to the caller's failure handling. */
|
|
57
67
|
private finishPhase;
|
|
58
|
-
/** B (crash-resume): re-attach to a Product that started before a crash.
|
|
59
|
-
*
|
|
68
|
+
/** B (crash-resume): re-attach to a Product that started before a crash. Restore its Host RunState
|
|
69
|
+
* checkpoint and re-drive it to terminal (runner.resumePhase), then run the SAME phase tail
|
|
60
70
|
* (finishPhase). Honest-fail ONLY if resume itself throws — a started phase is recovered, never lost,
|
|
61
71
|
* but progress is never fabricated. Bounded by an abort handle so pause() can still drain it. */
|
|
62
72
|
private recoverCrashedPhase;
|
|
@@ -2,6 +2,7 @@ import type { HostAgentProviderDirectory } from "../runtime/infra/host-agent-pro
|
|
|
2
2
|
import type { DelegateBridge } from "./delegate-bridge.js";
|
|
3
3
|
import { type PlannerMemoryContext } from "./planner-memory-brief.js";
|
|
4
4
|
import type { ProductOrchestrator } from "./agent-instance.js";
|
|
5
|
+
import type { HostRunStateAuthority } from "./run-state-host-authority.js";
|
|
5
6
|
import type { LeaderPort, PhaseRunnerPort } from "./goal-loop-coordinator.js";
|
|
6
7
|
import { type AcceptanceCriterion, type AcceptanceDelta, type PhaseSpec } from "./goal-run-types.js";
|
|
7
8
|
/**
|
|
@@ -54,6 +55,8 @@ export interface LeaderAdapterDeps {
|
|
|
54
55
|
leaderAgentId: string;
|
|
55
56
|
/** Project workspaceDir — the leader process cwd. */
|
|
56
57
|
cwd: string;
|
|
58
|
+
projectId: string;
|
|
59
|
+
canonicalSessionId: string;
|
|
57
60
|
/** Live Product engine — assess() reads task outputs/changedFiles via getStatus. */
|
|
58
61
|
orchestrator: ProductOrchestrator;
|
|
59
62
|
/** Stable id used as the leader process memberId (one persistent leader per goal-run). */
|
|
@@ -65,13 +68,15 @@ export interface LeaderAdapterDeps {
|
|
|
65
68
|
info(msg: string): void;
|
|
66
69
|
warn(msg: string): void;
|
|
67
70
|
};
|
|
68
|
-
/**
|
|
71
|
+
/** Required Gateway delegate access; Goal leader turns fail loud when unavailable. */
|
|
69
72
|
getDelegateBridge?: () => DelegateBridge | undefined;
|
|
70
73
|
}
|
|
71
74
|
export declare function createLeaderAdapter(deps: LeaderAdapterDeps): LeaderPort;
|
|
72
75
|
export interface PhaseRunnerAdapterDeps {
|
|
73
76
|
/** The live Product engine (same one ProductRunCoordinator.confirmAndStart drives — I3). */
|
|
74
77
|
orchestrator: ProductOrchestrator;
|
|
78
|
+
projectId: string;
|
|
79
|
+
runStateAuthority: HostRunStateAuthority;
|
|
75
80
|
/** Optional per-phase budget passed through to ProductOrchestrator.create. */
|
|
76
81
|
budget?: {
|
|
77
82
|
maxTotalTokens?: number;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import type { PathService } from "../runtime/ports/index.js";
|
|
2
1
|
import type { GoalRunEvent, PersistedGoalRunState } from "./goal-run-types.js";
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import type { HostRunStateAuthority } from "./run-state-host-authority.js";
|
|
3
|
+
export interface GoalPersistenceContext {
|
|
4
|
+
projectId: string;
|
|
5
|
+
canonicalSessionId: string;
|
|
6
|
+
authority: HostRunStateAuthority;
|
|
5
7
|
}
|
|
6
|
-
/** Append one event
|
|
7
|
-
export declare function appendGoalRunEvent(goalRunId: string, event: GoalRunEvent,
|
|
8
|
-
export declare function readGoalRunEvents(goalRunId: string,
|
|
9
|
-
export declare function saveGoalRunSnapshot(state: PersistedGoalRunState,
|
|
10
|
-
export declare function loadGoalRunSnapshot(goalRunId: string,
|
|
11
|
-
/** Replay the event log into a snapshot
|
|
12
|
-
export declare function rebuildSnapshotFromEvents(goalRunId: string,
|
|
8
|
+
/** Append one event to the Gateway-owned durable RunState event log. */
|
|
9
|
+
export declare function appendGoalRunEvent(goalRunId: string, event: GoalRunEvent, context: GoalPersistenceContext): Promise<void>;
|
|
10
|
+
export declare function readGoalRunEvents(goalRunId: string, context: GoalPersistenceContext): Promise<GoalRunEvent[]>;
|
|
11
|
+
export declare function saveGoalRunSnapshot(state: PersistedGoalRunState, context: GoalPersistenceContext): Promise<void>;
|
|
12
|
+
export declare function loadGoalRunSnapshot(goalRunId: string, context: GoalPersistenceContext): Promise<PersistedGoalRunState | undefined>;
|
|
13
|
+
/** Replay the Host event log into a snapshot. Returns undefined before goal_started. */
|
|
14
|
+
export declare function rebuildSnapshotFromEvents(goalRunId: string, context: GoalPersistenceContext): Promise<PersistedGoalRunState | undefined>;
|
|
@@ -74,9 +74,11 @@ export interface GoalRunEvent {
|
|
|
74
74
|
type: "goal_started" | "phase_planned" | "phase_started" | "task_settled" | "phase_assessed" | "progress_compacted" | "goal_edited" | "message_queued" | "paused" | "resumed" | "stopped" | "phase_boundary" | "ended";
|
|
75
75
|
payload: Record<string, unknown>;
|
|
76
76
|
}
|
|
77
|
-
/** Derived
|
|
77
|
+
/** Derived Goal checkpoint stored by Gateway RunState, rebuildable by replaying events. */
|
|
78
78
|
export interface PersistedGoalRunState {
|
|
79
79
|
goalRunId: string;
|
|
80
|
+
projectId: string;
|
|
81
|
+
canonicalSessionId: string;
|
|
80
82
|
originalGoal: string;
|
|
81
83
|
currentGoal: string;
|
|
82
84
|
goalUpdatedAt?: string;
|
|
@@ -102,23 +104,3 @@ export interface PersistedGoalRunState {
|
|
|
102
104
|
projectWorkspaceDir: string;
|
|
103
105
|
lastEventSeq: number;
|
|
104
106
|
}
|
|
105
|
-
/** Pull-status shape returned by x/goal.status (GoalStatus, §5.1). */
|
|
106
|
-
export interface GoalStatus {
|
|
107
|
-
goalRunId: string;
|
|
108
|
-
status: GoalRunStatus;
|
|
109
|
-
pauseState: GoalPauseState;
|
|
110
|
-
goalLabel: string;
|
|
111
|
-
currentGoal: string;
|
|
112
|
-
phaseIndex: number;
|
|
113
|
-
wallClockStartedAt: string;
|
|
114
|
-
progressSummary: string;
|
|
115
|
-
acceptance: {
|
|
116
|
-
passed: number;
|
|
117
|
-
total: number;
|
|
118
|
-
criteria: AcceptanceCriterion[];
|
|
119
|
-
};
|
|
120
|
-
queuedMessageCount: number;
|
|
121
|
-
noProgressCount: number;
|
|
122
|
-
endReason?: GoalEndReason;
|
|
123
|
-
failedReason?: string;
|
|
124
|
-
}
|
|
@@ -3,7 +3,6 @@ export { classifyError, isRetryableCategory, type ErrorCategory, } from "./error
|
|
|
3
3
|
export { composeStrategies, composeAsyncStrategies, SlidingWindowStrategy, SummarizeOldStrategy, ToolResultTrimStrategy, HeadTailProtectedStrategy, IncrementalCompactStrategy, CacheAwareCompressionStrategy, CompressionMetricsCollector, ContextEngineRegistry, MicroCompactStrategy, postCompactFileRecovery, type PostCompactRecoveryConfig, buildStructuredSummaryPrompt, computeAdaptiveBudget, isAsyncCompressionStrategy, selectCompressionTier, DEFAULT_ADAPTIVE_BUDGET_CONFIG, type AdaptiveBudgetConfig, type AsyncCompressionStrategy, type CacheAwareCompressionConfig, type CompressibleMessage, type CompressionEvent, type CompressionMetrics, type CompressionMetricsSnapshot, type CompressionResult, type CompressionStrategy, type CompressionTier, type ContextEngine, type HeadTailProtectionConfig, type IncrementalCompactConfig, type SummarizeFn, } from "../runtime/context/context-compression-strategies.js";
|
|
4
4
|
export { snipCompactIfNeeded, type SnipResult, } from "../runtime/context/context-compression-strategies.js";
|
|
5
5
|
export { applyCollapsesIfNeeded as applyContextCollapsesIfNeeded, recoverFromOverflow as recoverContextCollapseFromOverflow, createCollapseStore, type CollapseStore, type CollapseStage, } from "./context/context-collapse.js";
|
|
6
|
-
export { buildSkillInstruction, recordPatternAndCheckThreshold, getPatternStats, buildToolSignature, type SkillCreateInstruction, type SkillImproveInstruction, type SkillInstruction, type SkillTurnResult, } from "./skill-improvement.js";
|
|
7
6
|
export { applyToolChoicePolicy, type ApplyToolChoicePolicyInput, type ApplyToolChoicePolicyResult, } from "./tool-loop/tool-choice-policy.js";
|
|
8
7
|
export { repairOpenAiChatConversation, type ConversationRepairOptions, type OpenAiChatMessageLike, type OpenAiToolCall, } from "./tool-loop/conversation-repair.js";
|
|
9
8
|
export { advanceToolLoopState, recoverToolLoopStateFromChatConversation, recoverToolLoopStateFromResponsesItems, settleToolLoopState, type RepairToolLoopStateResult, type ToolLoopRepairAction, type ToolLoopState, } from "./tool-loop/tool-loop-state.js";
|
|
@@ -3,14 +3,17 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Rules:
|
|
5
5
|
* - Auto-checkpoint on task completion
|
|
6
|
-
* - 5 min
|
|
6
|
+
* - 5 min periodic safety checkpoint for active products
|
|
7
7
|
* - 30 min timer for long-running products (>48h)
|
|
8
8
|
* - Manual checkpoint via product.checkpoint RPC
|
|
9
9
|
*/
|
|
10
10
|
import type { PersistedProductState } from "./product-persistence.js";
|
|
11
|
+
import type { HostRunStateAuthority } from "./run-state-host-authority.js";
|
|
11
12
|
export interface CheckpointCallbacks {
|
|
12
13
|
/** Called after each checkpoint save. */
|
|
13
14
|
onCheckpoint?: (productId: string, timestamp: string) => void;
|
|
15
|
+
/** Called when an unattended periodic checkpoint cannot reach the Host authority. */
|
|
16
|
+
onError?: (productId: string, error: unknown) => void;
|
|
14
17
|
/** Return current state snapshot for periodic auto-saves. */
|
|
15
18
|
getState?: () => PersistedProductState | null;
|
|
16
19
|
log?: {
|
|
@@ -20,16 +23,17 @@ export interface CheckpointCallbacks {
|
|
|
20
23
|
}
|
|
21
24
|
export declare class ProductCheckpointManager {
|
|
22
25
|
private callbacks;
|
|
23
|
-
|
|
26
|
+
private readonly runStateAuthority;
|
|
27
|
+
/** Safety interval (5 min default, 30 min for >48h long-running). */
|
|
24
28
|
private static readonly DEFAULT_INTERVAL;
|
|
25
29
|
private static readonly LONG_RUNNING_INTERVAL;
|
|
26
30
|
private static readonly LONG_RUNNING_THRESHOLD;
|
|
27
31
|
private timer;
|
|
28
32
|
private lastCheckpointAt;
|
|
29
|
-
private
|
|
30
|
-
constructor(callbacks
|
|
33
|
+
private checkpointTail;
|
|
34
|
+
constructor(callbacks: CheckpointCallbacks | undefined, runStateAuthority: HostRunStateAuthority);
|
|
31
35
|
/** Start periodic checkpointing for a product. */
|
|
32
|
-
start(
|
|
36
|
+
start(): void;
|
|
33
37
|
/** Stop periodic checkpointing. */
|
|
34
38
|
stop(): void;
|
|
35
39
|
/** Get the appropriate checkpoint interval based on elapsed time. */
|
|
@@ -37,7 +41,7 @@ export declare class ProductCheckpointManager {
|
|
|
37
41
|
/** Check if a checkpoint is due based on elapsed time since last checkpoint. */
|
|
38
42
|
isDue(elapsedMs: number): boolean;
|
|
39
43
|
/**
|
|
40
|
-
* Perform a checkpoint
|
|
44
|
+
* Perform a checkpoint through the captured Host RunState authority and notify.
|
|
41
45
|
* Called on task completion or by periodic timer.
|
|
42
46
|
*/
|
|
43
47
|
checkpoint(state: PersistedProductState): Promise<void>;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Product persistence facade over the Gateway-owned RunStateStore.
|
|
3
3
|
*/
|
|
4
|
-
import type { PathService } from "../runtime/ports/index.js";
|
|
5
4
|
import type { ProductPhase, ProductInstanceDef } from "../protocol/wire/acp-agent-management.js";
|
|
6
5
|
import type { SerializedNode } from "./dag-scheduler.js";
|
|
7
6
|
import type { PlanningSession } from "./product-planner.js";
|
|
7
|
+
import { type HostRunStateAuthority } from "./run-state-host-authority.js";
|
|
8
8
|
export interface PersistedProductState {
|
|
9
9
|
productId: string;
|
|
10
|
+
projectId: string;
|
|
10
11
|
name: string;
|
|
11
12
|
phase: ProductPhase;
|
|
12
13
|
cwd: string;
|
|
@@ -21,43 +22,69 @@ export interface PersistedProductState {
|
|
|
21
22
|
};
|
|
22
23
|
createdAt: string;
|
|
23
24
|
lastCheckpointAt: string;
|
|
25
|
+
/** Last durably announced attempt number for each stable task id. */
|
|
26
|
+
taskAttempts?: Record<string, number>;
|
|
24
27
|
/**
|
|
25
28
|
* Snapshot of the leader's multi-turn planning dialogue, so the leader regains its planning
|
|
26
|
-
* context after a resume
|
|
29
|
+
* context after a resume. JSON-safe:
|
|
27
30
|
* PlanningSession is strings / arrays / plain objects (no functions, dates, or class instances).
|
|
28
31
|
*/
|
|
29
32
|
leaderDialogue?: PlanningSession;
|
|
30
33
|
}
|
|
34
|
+
/** Host checkpoint used before a Product plan transitions into DAG execution. */
|
|
35
|
+
export interface PersistedProductPlanningState {
|
|
36
|
+
stateKind: "planning";
|
|
37
|
+
productId: string;
|
|
38
|
+
projectId: string;
|
|
39
|
+
canonicalSessionId: string;
|
|
40
|
+
name: string;
|
|
41
|
+
phase: PlanningSession["phase"];
|
|
42
|
+
cwd: string;
|
|
43
|
+
instances: ProductInstanceDef[];
|
|
44
|
+
tasks: SerializedNode[];
|
|
45
|
+
budget: {
|
|
46
|
+
maxTotalTokens?: number;
|
|
47
|
+
maxDuration?: number;
|
|
48
|
+
usedTokens: number;
|
|
49
|
+
startedAt: number;
|
|
50
|
+
warningEmitted: boolean;
|
|
51
|
+
};
|
|
52
|
+
createdAt: string;
|
|
53
|
+
lastCheckpointAt: string;
|
|
54
|
+
planningSession: PlanningSession;
|
|
55
|
+
}
|
|
31
56
|
export interface ProductPersistenceOptions {
|
|
32
|
-
|
|
57
|
+
authority?: HostRunStateAuthority;
|
|
33
58
|
}
|
|
34
|
-
/** Save
|
|
35
|
-
export declare function saveProductState(state: PersistedProductState,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
export declare function
|
|
59
|
+
/** Save Product execution state through the Gateway-owned RunState service. */
|
|
60
|
+
export declare function saveProductState(state: PersistedProductState, options?: ProductPersistenceOptions): Promise<void>;
|
|
61
|
+
export declare function saveProductPlanningState(session: PlanningSession, options?: ProductPersistenceOptions): Promise<PersistedProductPlanningState>;
|
|
62
|
+
/** Load Product execution state through the Gateway-owned RunState service. */
|
|
63
|
+
export declare function loadProductState(productId: string, options?: ProductPersistenceOptions): Promise<PersistedProductState | undefined>;
|
|
64
|
+
export declare function loadProductPlanningState(productId: string, owner: {
|
|
65
|
+
projectId: string;
|
|
66
|
+
canonicalSessionId: string;
|
|
67
|
+
cwd: string;
|
|
68
|
+
}, options?: ProductPersistenceOptions): Promise<PersistedProductPlanningState | undefined>;
|
|
69
|
+
/** Delete a Product run through Gateway authority. */
|
|
70
|
+
export declare function deleteProductState(productId: string, options?: ProductPersistenceOptions): Promise<boolean>;
|
|
40
71
|
/**
|
|
41
|
-
* Save a full state snapshot into
|
|
72
|
+
* Save a full state snapshot into Gateway checkpoint history.
|
|
42
73
|
* Uses `state.lastCheckpointAt` as the logical id (must be set before calling).
|
|
43
74
|
* Prunes old snapshots to keep at most MAX_CHECKPOINT_SNAPSHOTS entries.
|
|
44
75
|
*/
|
|
45
|
-
export declare function saveProductCheckpointSnapshot(state: PersistedProductState,
|
|
76
|
+
export declare function saveProductCheckpointSnapshot(state: PersistedProductState, options?: ProductPersistenceOptions): Promise<void>;
|
|
46
77
|
/**
|
|
47
78
|
* Load a specific checkpoint snapshot by its original ISO timestamp.
|
|
48
79
|
* Returns undefined if the snapshot does not exist.
|
|
49
80
|
*/
|
|
50
|
-
export declare function loadProductCheckpointSnapshot(productId: string, timestamp: string,
|
|
81
|
+
export declare function loadProductCheckpointSnapshot(productId: string, timestamp: string, options?: ProductPersistenceOptions): Promise<PersistedProductState | undefined>;
|
|
51
82
|
/**
|
|
52
83
|
* List all checkpoint timestamps for a product, sorted ascending (oldest first).
|
|
53
|
-
* Reads each snapshot file to recover the original ISO timestamp from state.lastCheckpointAt.
|
|
54
|
-
* Returns an empty array if the checkpoints directory does not exist.
|
|
55
84
|
*/
|
|
56
|
-
export declare function listProductCheckpointTimestamps(productId: string,
|
|
85
|
+
export declare function listProductCheckpointTimestamps(productId: string, options?: ProductPersistenceOptions): Promise<string[]>;
|
|
57
86
|
/**
|
|
58
|
-
* Restore a specific checkpoint as the latest
|
|
59
|
-
*
|
|
60
|
-
* and returns the restored state. Returns undefined if the snapshot is not found
|
|
61
|
-
* (caller should fall back to the existing latest state).
|
|
87
|
+
* Restore a specific checkpoint as the latest Product state.
|
|
88
|
+
* Returns undefined if the Host no longer has that checkpoint.
|
|
62
89
|
*/
|
|
63
|
-
export declare function restoreProductCheckpoint(productId: string, timestamp: string,
|
|
90
|
+
export declare function restoreProductCheckpoint(productId: string, timestamp: string, options?: ProductPersistenceOptions): Promise<PersistedProductState | undefined>;
|
|
@@ -26,7 +26,8 @@
|
|
|
26
26
|
import type { HostAgentProviderDirectory } from "../runtime/infra/host-agent-provider-directory.js";
|
|
27
27
|
import type { DelegateBridge } from "./delegate-bridge.js";
|
|
28
28
|
import type { ProductPlanParams, ProductPlan, ProductConfirmParams } from "../protocol/wire/acp-agent-management.js";
|
|
29
|
-
|
|
29
|
+
import { type HostRunStateAuthority } from "./run-state-host-authority.js";
|
|
30
|
+
export type PlanningPhase = "planning" | "awaiting_confirmation" | "confirmed" | "executing" | "paused" | "completed" | "failed" | "cancelled";
|
|
30
31
|
export interface PlanningMessage {
|
|
31
32
|
role: "leader" | "user";
|
|
32
33
|
content: string;
|
|
@@ -34,6 +35,8 @@ export interface PlanningMessage {
|
|
|
34
35
|
}
|
|
35
36
|
export interface PlanningSession {
|
|
36
37
|
productId: string;
|
|
38
|
+
projectId: string;
|
|
39
|
+
canonicalSessionId: string;
|
|
37
40
|
goal: string;
|
|
38
41
|
cwd: string;
|
|
39
42
|
leaderAgentId: string;
|
|
@@ -41,6 +44,8 @@ export interface PlanningSession {
|
|
|
41
44
|
activeDelegationId?: string;
|
|
42
45
|
phase: PlanningPhase;
|
|
43
46
|
plan?: ProductPlan;
|
|
47
|
+
/** Final user-approved execution payload, durably captured before DAG creation starts. */
|
|
48
|
+
confirmedExecution?: Pick<ProductConfirmParams, "instances" | "tasks" | "budget">;
|
|
44
49
|
/** Multi-turn conversation history during planning. */
|
|
45
50
|
dialogue: PlanningMessage[];
|
|
46
51
|
budget?: {
|
|
@@ -60,6 +65,13 @@ export interface PlanningSession {
|
|
|
60
65
|
lastCheckpoint?: string;
|
|
61
66
|
/** A leader turn is currently running (planning is async/fire-and-forget) — block concurrent turns. */
|
|
62
67
|
turnInFlight?: boolean;
|
|
68
|
+
failedReason?: string;
|
|
69
|
+
}
|
|
70
|
+
export interface ProductPlanningOwner {
|
|
71
|
+
projectId: string;
|
|
72
|
+
canonicalSessionId: string;
|
|
73
|
+
cwd: string;
|
|
74
|
+
authority?: HostRunStateAuthority;
|
|
63
75
|
}
|
|
64
76
|
export interface ProductPlanAskQuestion {
|
|
65
77
|
question: string;
|
|
@@ -76,15 +88,15 @@ export interface PlannerCallbacks {
|
|
|
76
88
|
warn(msg: string): void;
|
|
77
89
|
};
|
|
78
90
|
/** Leader produced a structured plan — client presents to user. */
|
|
79
|
-
onPlanReady?: (productId: string, plan: ProductPlan) => void
|
|
91
|
+
onPlanReady?: (productId: string, plan: ProductPlan) => void | Promise<void>;
|
|
80
92
|
/** Planning failed. */
|
|
81
|
-
onPlanFailed?: (productId: string, error: string) => void
|
|
93
|
+
onPlanFailed?: (productId: string, error: string) => void | Promise<void>;
|
|
82
94
|
/** Streaming text from leader during planning dialogue. */
|
|
83
95
|
onPlanningDelta?: (productId: string, text: string) => void;
|
|
84
96
|
/** Leader sent a message to user (multi-turn). */
|
|
85
|
-
onLeaderMessage?: (productId: string, message: string) => void
|
|
97
|
+
onLeaderMessage?: (productId: string, message: string) => void | Promise<void>;
|
|
86
98
|
/** Leader asked a structured clarifying question (turn-boundary); client renders an ask panel. */
|
|
87
|
-
onLeaderAsk?: (productId: string, askId: string, questions: ProductPlanAskQuestion[]) => void
|
|
99
|
+
onLeaderAsk?: (productId: string, askId: string, questions: ProductPlanAskQuestion[]) => void | Promise<void>;
|
|
88
100
|
/** Leader dynamically mutated the DAG during execution. */
|
|
89
101
|
onDagMutated?: (productId: string, mutation: DagMutation) => void;
|
|
90
102
|
/** Live DAG progress for the execution-phase leader (filled by the orchestrator). */
|
|
@@ -94,7 +106,7 @@ export interface PlannerCallbacks {
|
|
|
94
106
|
running: number;
|
|
95
107
|
failed: number;
|
|
96
108
|
};
|
|
97
|
-
/**
|
|
109
|
+
/** Required Gateway delegate access; planning fails loud when the Host rail is unavailable. */
|
|
98
110
|
getDelegateBridge?: () => DelegateBridge | undefined;
|
|
99
111
|
}
|
|
100
112
|
/** Describes a DAG mutation performed by the leader. */
|
|
@@ -107,7 +119,13 @@ export declare class ProductPlanner {
|
|
|
107
119
|
private providerDirectory;
|
|
108
120
|
private callbacks;
|
|
109
121
|
private sessions;
|
|
122
|
+
private sessionAuthorities;
|
|
110
123
|
constructor(providerDirectory: HostAgentProviderDirectory, callbacks?: PlannerCallbacks);
|
|
124
|
+
private resolveOwnerAuthority;
|
|
125
|
+
private assertSessionOwner;
|
|
126
|
+
private getOrRestoreSession;
|
|
127
|
+
private checkpointPlanningSession;
|
|
128
|
+
private publishNotification;
|
|
111
129
|
/**
|
|
112
130
|
* Start an interactive planning session (Phase 1).
|
|
113
131
|
* Spawns the leader agent and begins multi-turn dialogue.
|
|
@@ -141,7 +159,7 @@ export declare class ProductPlanner {
|
|
|
141
159
|
* Send a user message to the leader (works in planning and execution phases).
|
|
142
160
|
* Returns the leader's response and optionally a finalized plan.
|
|
143
161
|
*/
|
|
144
|
-
message(productId: string, content: string): Promise<{
|
|
162
|
+
message(productId: string, content: string, owner?: ProductPlanningOwner): Promise<{
|
|
145
163
|
response: string;
|
|
146
164
|
plan?: ProductPlan;
|
|
147
165
|
mutations?: DagMutation[];
|
|
@@ -153,14 +171,16 @@ export declare class ProductPlanner {
|
|
|
153
171
|
productId: string;
|
|
154
172
|
ok: true;
|
|
155
173
|
}>;
|
|
156
|
-
/** Transition session
|
|
174
|
+
/** Transition the in-memory leader session before the first execution checkpoint is written. */
|
|
157
175
|
markExecuting(productId: string): void;
|
|
176
|
+
markAwaitingConfirmation(productId: string): Promise<void>;
|
|
177
|
+
getRunStateAuthority(productId: string): HostRunStateAuthority | undefined;
|
|
158
178
|
/** Mark as completed. */
|
|
159
179
|
markCompleted(productId: string): void;
|
|
160
180
|
/** Get planning session by ID. */
|
|
161
181
|
getSession(productId: string): PlanningSession | undefined;
|
|
162
182
|
/** Cancel and kill leader process. */
|
|
163
|
-
cancel(productId: string): Promise<void>;
|
|
183
|
+
cancel(productId: string, owner?: ProductPlanningOwner): Promise<void>;
|
|
164
184
|
/** List active sessions. */
|
|
165
185
|
listSessions(): PlanningSession[];
|
|
166
186
|
/**
|
|
@@ -206,7 +226,7 @@ export declare class ProductPlanner {
|
|
|
206
226
|
/**
|
|
207
227
|
* Restore session from checkpoint (crash recovery).
|
|
208
228
|
*/
|
|
209
|
-
restoreSession(data: PlanningSession): void;
|
|
229
|
+
restoreSession(data: PlanningSession, authority?: HostRunStateAuthority): void;
|
|
210
230
|
private handlePlanningMessage;
|
|
211
231
|
private handleExecutionMessage;
|
|
212
232
|
private sendToLeader;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { ProductConfirmParams, ProductPlan } from "../protocol/wire/acp-agent-management.js";
|
|
1
|
+
import type { ProductConfirmParams, ProductMessageParams, ProductPlan } from "../protocol/wire/acp-agent-management.js";
|
|
2
2
|
import type { ProductOrchestrator } from "./agent-instance.js";
|
|
3
3
|
import type { DagMutation, PlanningSession, ProductPlanner } from "./product-planner.js";
|
|
4
|
+
import type { HostRunStateAuthority } from "./run-state-host-authority.js";
|
|
4
5
|
export interface ProductLeaderCoordinator {
|
|
5
6
|
consultLeader(productId: string, context: {
|
|
6
7
|
progress: {
|
|
@@ -30,7 +31,7 @@ export interface ProductLeaderCoordinator {
|
|
|
30
31
|
/** Snapshot the leader's PlanningSession for checkpoint persistence (durable execution). */
|
|
31
32
|
serializeSession(productId: string): PlanningSession | null;
|
|
32
33
|
/** Restore the leader's PlanningSession from a checkpoint (crash/resume recovery). */
|
|
33
|
-
restoreSession(data: PlanningSession): void;
|
|
34
|
+
restoreSession(data: PlanningSession, authority?: HostRunStateAuthority): void;
|
|
34
35
|
}
|
|
35
36
|
export declare class ProductRunCoordinator {
|
|
36
37
|
private planner;
|
|
@@ -40,7 +41,7 @@ export declare class ProductRunCoordinator {
|
|
|
40
41
|
productId: string;
|
|
41
42
|
ok: true;
|
|
42
43
|
}>;
|
|
43
|
-
message(
|
|
44
|
+
message(params: ProductMessageParams, authority?: HostRunStateAuthority): Promise<{
|
|
44
45
|
response: string;
|
|
45
46
|
plan?: ProductPlan;
|
|
46
47
|
mutations?: DagMutation[];
|