qlogicagent 2.24.1 → 2.24.2
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 +52 -324
- package/dist/agent.js +38 -43
- package/dist/cli.js +7 -7
- package/dist/default-project-knowledge/INSTRUCTIONS.md +7 -7
- package/dist/default-project-knowledge/rules/project-workflow.md +6 -6
- package/dist/index.js +265 -1018
- package/dist/orchestration.js +10 -10
- package/dist/types/agent/runtime-vars.d.ts +1 -16
- package/dist/types/agent/tool-loop/compression-pipeline.d.ts +0 -2
- package/dist/types/agent/tool-loop.d.ts +0 -6
- package/dist/types/agent/types.d.ts +3 -22
- package/dist/types/cli/acp-commands.d.ts +4 -5
- package/dist/types/cli/acp-message-router.d.ts +1 -2
- package/dist/types/cli/acp-session-handlers.d.ts +6 -12
- package/dist/types/cli/acp-session-host.d.ts +5 -48
- package/dist/types/cli/adapter-launch-config.d.ts +14 -0
- package/dist/types/cli/agent-runtime-bootstrap.d.ts +2 -23
- package/dist/types/cli/agent-runtime-session-state.d.ts +1 -6
- package/dist/types/cli/base-tool-bootstrap.d.ts +0 -2
- package/dist/types/cli/cli-acp-request-handler.d.ts +3 -5
- package/dist/types/cli/core-tool-coordinator.d.ts +0 -4
- package/dist/types/cli/core-tools/agent-tool-service.d.ts +0 -3
- package/dist/types/cli/core-tools/fork-system-prompt.d.ts +1 -5
- package/dist/types/cli/handlers/files-handler.d.ts +0 -6
- package/dist/types/cli/handlers/turn-handler.d.ts +7 -83
- package/dist/types/cli/main.d.ts +2 -4
- package/dist/types/cli/permission-approval-bridge.d.ts +2 -6
- package/dist/types/cli/permission-bootstrap.d.ts +2 -12
- package/dist/types/cli/plugin-bootstrap.d.ts +2 -4
- package/dist/types/cli/runtime-hook-bootstrap.d.ts +0 -21
- package/dist/types/cli/session-context.d.ts +4 -14
- package/dist/types/cli/session-coordinator.d.ts +1 -9
- package/dist/types/cli/stdio-acp-protocol-coordinator.d.ts +2 -9
- package/dist/types/cli/stdio-acp-request-host.d.ts +3 -15
- package/dist/types/cli/stdio-agent-session-bootstrap.d.ts +3 -23
- package/dist/types/cli/stdio-runtime-bootstrap.d.ts +0 -8
- package/dist/types/cli/stdio-runtime-services.d.ts +2 -13
- package/dist/types/cli/stdio-server.d.ts +6 -128
- package/dist/types/cli/tool-bootstrap.d.ts +4 -8
- package/dist/types/cli/tool-catalog.d.ts +2 -2
- package/dist/types/cli/tool-invoker-factory.d.ts +0 -2
- package/dist/types/cli/tool-registry-adapter.d.ts +3 -7
- package/dist/types/cli/tool-result-processor.d.ts +0 -1
- package/dist/types/cli/turn-core.d.ts +6 -10
- package/dist/types/cli/turn-event-forwarder.d.ts +6 -3
- package/dist/types/cli/turn-lifecycle.d.ts +0 -3
- package/dist/types/cli/turn-project-router.d.ts +0 -7
- package/dist/types/contracts/hooks.d.ts +1 -20
- package/dist/types/contracts/tool-execution-evidence.d.ts +20 -1
- package/dist/types/contracts/turn-event.d.ts +2 -2
- package/dist/types/orchestration/index.d.ts +1 -1
- package/dist/types/protocol/notifications.d.ts +2 -9
- package/dist/types/protocol/wire/acp-protocol.d.ts +12 -186
- package/dist/types/protocol/wire/capability-transport.d.ts +0 -2
- package/dist/types/protocol/wire/index.d.ts +2 -10
- package/dist/types/protocol/wire/notification-payloads.d.ts +4 -989
- package/dist/types/protocol/wire/thread-protocol.d.ts +24 -3
- package/dist/types/runtime/config/tunable-defaults.d.ts +3 -75
- package/dist/types/runtime/execution/forked-agent.d.ts +2 -5
- package/dist/types/runtime/execution/streaming-tool-executor.d.ts +0 -2
- package/dist/types/runtime/execution/tool-result-storage.d.ts +13 -4
- package/dist/types/runtime/infra/agent-paths.d.ts +4 -54
- package/dist/types/runtime/infra/agent-project-projection.d.ts +20 -0
- package/dist/types/runtime/infra/background-tasks.d.ts +3 -3
- package/dist/types/runtime/infra/default-path-service.d.ts +0 -7
- package/dist/types/runtime/infra/llmrouter-catalog.d.ts +1 -1
- package/dist/types/runtime/infra/model-registry.d.ts +6 -9
- package/dist/types/runtime/infra/project-store.d.ts +3 -3
- package/dist/types/runtime/infra/subagent-turn-snapshot.d.ts +54 -7
- package/dist/types/runtime/infra/task-runtime.d.ts +1 -1
- package/dist/types/runtime/ports/agent-runtime-ports.d.ts +1 -3
- package/dist/types/runtime/ports/index.d.ts +0 -4
- package/dist/types/runtime/ports/path-service.d.ts +1 -9
- package/dist/types/runtime/ports/tool-contracts.d.ts +0 -1
- package/dist/types/runtime/session/agent-session-projection.d.ts +37 -0
- package/dist/types/runtime/tasks/task-types.d.ts +2 -25
- package/dist/types/skills/mcp/mcp-manager.d.ts +2 -2
- package/dist/types/skills/plugins/plugin-loader.d.ts +1 -1
- package/dist/types/skills/skill-system/skill-category.d.ts +4 -2
- package/dist/types/skills/tools.d.ts +1 -18
- package/dist/types/test-support/project-store-fixture.d.ts +4 -4
- package/dist/types/transport/acp-event-emitter.d.ts +1 -20
- package/dist/types/transport/acp-server.d.ts +8 -88
- package/package.json +4 -96
- package/dist/agent-contract.js +0 -1
- package/dist/host-contract.js +0 -1
- package/dist/host-session-collection-contract.js +0 -1
- package/dist/memory-category-contract.js +0 -1
- package/dist/permissions.js +0 -1
- package/dist/plugin-marketplace-compute.js +0 -1
- package/dist/project-memory-host.js +0 -38
- package/dist/protocol.js +0 -1
- package/dist/skill-category-contract.js +0 -1
- package/dist/tunables.js +0 -1
- package/dist/types/agent/memory-recall-context.d.ts +0 -22
- package/dist/types/agent/memory-recall-injection.d.ts +0 -32
- package/dist/types/cli/acp-extended-handlers.d.ts +0 -110
- package/dist/types/cli/acp-extended-host-adapter.d.ts +0 -20
- package/dist/types/cli/community-resource-installer.d.ts +0 -39
- package/dist/types/cli/community-skill-installer.d.ts +0 -18
- package/dist/types/cli/community-workflow-installer.d.ts +0 -29
- package/dist/types/cli/default-project-bootstrap.d.ts +0 -12
- package/dist/types/cli/dream-host-adapter.d.ts +0 -24
- package/dist/types/cli/gateway-rpc-connection.d.ts +0 -50
- package/dist/types/cli/handlers/community-handler.d.ts +0 -14
- package/dist/types/cli/handlers/config-handler.d.ts +0 -19
- package/dist/types/cli/handlers/control-handler.d.ts +0 -29
- package/dist/types/cli/handlers/dream-handler.d.ts +0 -41
- package/dist/types/cli/handlers/goal-handler.d.ts +0 -66
- package/dist/types/cli/handlers/memory-handler.d.ts +0 -23
- package/dist/types/cli/handlers/product-handler.d.ts +0 -35
- package/dist/types/cli/handlers/session-handler.d.ts +0 -29
- package/dist/types/cli/handlers/skill-curator-handler.d.ts +0 -8
- package/dist/types/cli/handlers/solo-handler.d.ts +0 -25
- package/dist/types/cli/handlers/turn-baseline-handler.d.ts +0 -8
- package/dist/types/cli/handlers/workflow-compute-handler.d.ts +0 -8
- package/dist/types/cli/handlers/working-materials-handler.d.ts +0 -9
- package/dist/types/cli/idle-dream-coordinator.d.ts +0 -57
- package/dist/types/cli/memory-background-coordinator.d.ts +0 -26
- package/dist/types/cli/memory-candidate-service.d.ts +0 -75
- package/dist/types/cli/memory-coordinator.d.ts +0 -40
- package/dist/types/cli/multi-agent-handler-host.d.ts +0 -16
- package/dist/types/cli/multi-agent-state-coordinator.d.ts +0 -8
- package/dist/types/cli/orchestration-memory-context.d.ts +0 -23
- package/dist/types/cli/product-acp-params.d.ts +0 -30
- package/dist/types/cli/product-coordinator.d.ts +0 -21
- package/dist/types/cli/project-memory-store-factory.d.ts +0 -12
- package/dist/types/cli/project-template-seeder.d.ts +0 -5
- package/dist/types/cli/rpc-registry.d.ts +0 -56
- package/dist/types/cli/session-history-coordinator.d.ts +0 -8
- package/dist/types/cli/session-query-service.d.ts +0 -27
- package/dist/types/cli/stdio-rpc-handler-hosts.d.ts +0 -56
- package/dist/types/cli/stdio-session-runtime-coordinator.d.ts +0 -17
- package/dist/types/cli/task-distillation-coordinator.d.ts +0 -146
- package/dist/types/cli/turn-ask-user-setup.d.ts +0 -24
- package/dist/types/cli/turn-suggestion-generator.d.ts +0 -15
- package/dist/types/contracts/memory-recall-packet.d.ts +0 -31
- package/dist/types/contracts/memory-response-contract.d.ts +0 -2
- package/dist/types/host-contract/fts-segment.d.ts +0 -20
- package/dist/types/host-contract/index.d.ts +0 -1819
- package/dist/types/host-contract/memory-category.d.ts +0 -8
- package/dist/types/host-contract/skill-category.d.ts +0 -5
- package/dist/types/host-session-collection-contract.d.ts +0 -65
- package/dist/types/orchestration/agent-instance.d.ts +0 -215
- package/dist/types/orchestration/agent-roster.d.ts +0 -32
- package/dist/types/orchestration/dag-scheduler.d.ts +0 -219
- package/dist/types/orchestration/delegate-approval-policy.d.ts +0 -8
- package/dist/types/orchestration/delegate-bridge.d.ts +0 -8
- package/dist/types/orchestration/goal-acceptance.d.ts +0 -17
- package/dist/types/orchestration/goal-context-envelope.d.ts +0 -7
- package/dist/types/orchestration/goal-loop-coordinator.d.ts +0 -151
- package/dist/types/orchestration/goal-mode-adapters.d.ts +0 -152
- package/dist/types/orchestration/goal-run-persistence.d.ts +0 -21
- package/dist/types/orchestration/goal-run-types.d.ts +0 -225
- package/dist/types/orchestration/planner-memory-brief.d.ts +0 -39
- package/dist/types/orchestration/product-budget.d.ts +0 -94
- package/dist/types/orchestration/product-checkpoint.d.ts +0 -50
- package/dist/types/orchestration/product-dag-mutation-applier.d.ts +0 -10
- package/dist/types/orchestration/product-persistence.d.ts +0 -90
- package/dist/types/orchestration/product-planner.d.ts +0 -332
- package/dist/types/orchestration/product-run-coordinator.d.ts +0 -49
- package/dist/types/orchestration/product-worktree.d.ts +0 -19
- package/dist/types/orchestration/run-state-host-authority.d.ts +0 -7
- package/dist/types/orchestration/solo-evaluator.d.ts +0 -179
- package/dist/types/orchestration/solo-persistence.d.ts +0 -47
- package/dist/types/orchestration/solo-spec-builder.d.ts +0 -58
- package/dist/types/orchestration/testing/delegate-test-bridge.d.ts +0 -23
- package/dist/types/orchestration/testing/host-agent-provider-directory-fixture.d.ts +0 -7
- package/dist/types/orchestration/testing/run-state-client-double.d.ts +0 -13
- package/dist/types/orchestration/workflow/budget-permission-gate.d.ts +0 -94
- package/dist/types/orchestration/workflow/builtin-capabilities.d.ts +0 -3
- package/dist/types/orchestration/workflow/builtin-executors.d.ts +0 -18
- package/dist/types/orchestration/workflow/capability-catalog.d.ts +0 -72
- package/dist/types/orchestration/workflow/cron-schedule.d.ts +0 -36
- package/dist/types/orchestration/workflow/data-item.d.ts +0 -39
- package/dist/types/orchestration/workflow/expression.d.ts +0 -60
- package/dist/types/orchestration/workflow/host-executors.d.ts +0 -15
- package/dist/types/orchestration/workflow/n8n-expression.d.ts +0 -48
- package/dist/types/orchestration/workflow/n8n-import.d.ts +0 -64
- package/dist/types/orchestration/workflow/n8n-template-compat.d.ts +0 -5
- package/dist/types/orchestration/workflow/node-registry.d.ts +0 -32
- package/dist/types/orchestration/workflow/node-schema.d.ts +0 -249
- package/dist/types/orchestration/workflow/params-schema.d.ts +0 -69
- package/dist/types/orchestration/workflow/qla-executor-host.d.ts +0 -63
- package/dist/types/orchestration/workflow/run-checkpoint-store.d.ts +0 -53
- package/dist/types/orchestration/workflow/run-history-store.d.ts +0 -103
- package/dist/types/orchestration/workflow/semantic-acceptance.d.ts +0 -65
- package/dist/types/orchestration/workflow/trigger-validation.d.ts +0 -22
- package/dist/types/orchestration/workflow/workflow-audit-store.d.ts +0 -31
- package/dist/types/orchestration/workflow/workflow-authoring.d.ts +0 -74
- package/dist/types/orchestration/workflow/workflow-bundle.d.ts +0 -51
- package/dist/types/orchestration/workflow/workflow-controller.d.ts +0 -237
- package/dist/types/orchestration/workflow/workflow-edit-context.d.ts +0 -46
- package/dist/types/orchestration/workflow/workflow-error.d.ts +0 -28
- package/dist/types/orchestration/workflow/workflow-intent-contract.d.ts +0 -56
- package/dist/types/orchestration/workflow/workflow-patch.d.ts +0 -122
- package/dist/types/orchestration/workflow/workflow-render.d.ts +0 -40
- package/dist/types/orchestration/workflow/workflow-runtime.d.ts +0 -184
- package/dist/types/orchestration/workflow/workflow-scheduler.d.ts +0 -122
- package/dist/types/orchestration/workflow/workflow-store.d.ts +0 -85
- package/dist/types/orchestration/workflow/workflow-template-setup.d.ts +0 -65
- package/dist/types/orchestration/workflow/workflow-trigger.d.ts +0 -43
- package/dist/types/orchestration/workflow-chat-builder.d.ts +0 -152
- package/dist/types/orchestration/worktree-task-prompt.d.ts +0 -1
- package/dist/types/permissions.d.ts +0 -4
- package/dist/types/project-memory-host.d.ts +0 -4
- package/dist/types/protocol/agent-contract.d.ts +0 -93
- package/dist/types/protocol/methods.d.ts +0 -645
- package/dist/types/protocol/wire/acp-agent-management.d.ts +0 -533
- package/dist/types/protocol/wire/agent-events.d.ts +0 -1
- package/dist/types/protocol/wire/agent-methods.d.ts +0 -500
- package/dist/types/protocol/wire/agent-rpc.d.ts +0 -100
- package/dist/types/protocol/wire/gateway-contract.d.ts +0 -61
- package/dist/types/protocol/wire/gateway-rpc.d.ts +0 -1177
- package/dist/types/protocol/wire/memory-provider-lifecycle.d.ts +0 -31
- package/dist/types/protocol/wire/turn.d.ts +0 -208
- package/dist/types/runtime/community/autonomy-budget.d.ts +0 -26
- package/dist/types/runtime/community/community-consent-client.d.ts +0 -55
- package/dist/types/runtime/community/package-materialize.d.ts +0 -19
- package/dist/types/runtime/community/ranged-download.d.ts +0 -21
- package/dist/types/runtime/community/registry-signature.d.ts +0 -48
- package/dist/types/runtime/execution/dream-agent.d.ts +0 -273
- package/dist/types/runtime/execution/dream-category-context.d.ts +0 -47
- package/dist/types/runtime/execution/memory-decay.d.ts +0 -73
- package/dist/types/runtime/execution/turn-progress-notifier.d.ts +0 -16
- package/dist/types/runtime/hooks/memory-hooks.d.ts +0 -111
- package/dist/types/runtime/infra/acp-host-handler.d.ts +0 -31
- package/dist/types/runtime/infra/acp-protocol-adapter.d.ts +0 -209
- package/dist/types/runtime/infra/acp-usage-tracker.d.ts +0 -46
- package/dist/types/runtime/infra/cloud-auth-host-authority.d.ts +0 -4
- package/dist/types/runtime/infra/feedback-distillation-worker.d.ts +0 -20
- package/dist/types/runtime/infra/feedback-distillation.d.ts +0 -32
- package/dist/types/runtime/infra/feedback-event-store.d.ts +0 -179
- package/dist/types/runtime/infra/feedback-host-authority.d.ts +0 -4
- package/dist/types/runtime/infra/feedback-outbox.d.ts +0 -26
- package/dist/types/runtime/infra/feedback-redaction.d.ts +0 -71
- package/dist/types/runtime/infra/feedback-upload-client.d.ts +0 -39
- package/dist/types/runtime/infra/feedback-upload-worker.d.ts +0 -11
- package/dist/types/runtime/infra/host-agent-provider-directory.d.ts +0 -17
- package/dist/types/runtime/infra/project-authority-facade.d.ts +0 -11
- package/dist/types/runtime/infra/project-data-paths.d.ts +0 -24
- package/dist/types/runtime/infra/project-host-authority.d.ts +0 -11
- package/dist/types/runtime/infra/project-instructions-store.d.ts +0 -30
- package/dist/types/runtime/infra/turn-baseline-store.d.ts +0 -102
- package/dist/types/runtime/infra/turn-telemetry-store.d.ts +0 -100
- package/dist/types/runtime/infra/working-materials-store.d.ts +0 -29
- package/dist/types/runtime/memory/find-relevant-memories.d.ts +0 -26
- package/dist/types/runtime/memory/implicit-extraction.d.ts +0 -69
- package/dist/types/runtime/memory/memory-recall-attribution.d.ts +0 -24
- package/dist/types/runtime/ports/memory-provider.d.ts +0 -219
- package/dist/types/runtime/ports/memory-recall-source.d.ts +0 -14
- package/dist/types/runtime/ports/memory-writer.d.ts +0 -70
- package/dist/types/runtime/ports/project-memory-store.d.ts +0 -49
- package/dist/types/runtime/prompt/host-skill-directory.d.ts +0 -16
- package/dist/types/runtime/session/group-session-split.d.ts +0 -38
- package/dist/types/runtime/session/inbound-upload-persistence.d.ts +0 -47
- package/dist/types/runtime/session/session-catalog.d.ts +0 -12
- package/dist/types/runtime/session/session-deletion-guard.d.ts +0 -4
- package/dist/types/runtime/session/session-locator.d.ts +0 -26
- package/dist/types/runtime/session/session-metadata-store.d.ts +0 -8
- package/dist/types/runtime/session/session-paths.d.ts +0 -8
- package/dist/types/runtime/session/session-permission-store.d.ts +0 -6
- package/dist/types/runtime/session/session-persistence.d.ts +0 -37
- package/dist/types/runtime/session/session-recovery.d.ts +0 -62
- package/dist/types/runtime/session/session-resource-key.d.ts +0 -28
- package/dist/types/runtime/session/session-resume.d.ts +0 -9
- package/dist/types/runtime/session/session-schema.d.ts +0 -10
- package/dist/types/runtime/session/session-summary.d.ts +0 -7
- package/dist/types/runtime/session/session-title.d.ts +0 -9
- package/dist/types/runtime/session/session-transcript-store.d.ts +0 -30
- package/dist/types/runtime/session/session-types.d.ts +0 -113
- package/dist/types/runtime/session/session-write-queue.d.ts +0 -3
- package/dist/types/skills/memory/host-memory-provider.d.ts +0 -235
- package/dist/types/skills/memory/memdir.d.ts +0 -111
- package/dist/types/skills/memory/memory-content-safety.d.ts +0 -1
- package/dist/types/skills/memory/memory-vector-utils.d.ts +0 -2
- package/dist/types/skills/memory/task-distillation.d.ts +0 -183
- package/dist/types/skills/plugins/plugin-marketplace.d.ts +0 -43
- package/dist/types/skills/skill-system/skill-bundles.d.ts +0 -8
- package/dist/types/skills/skill-system/skill-lifecycle.d.ts +0 -89
- package/dist/types/test-support/run-state-authority-setup.d.ts +0 -1
- package/dist/types/transport/delegate-client.d.ts +0 -82
- package/dist/types/transport/host-capability-client.d.ts +0 -21
- package/dist/types/transport/host-cloud-auth-client.d.ts +0 -10
- package/dist/types/transport/host-community-client.d.ts +0 -7
- package/dist/types/transport/host-feedback-client.d.ts +0 -25
- package/dist/types/transport/host-profile-client.d.ts +0 -19
- package/dist/types/transport/host-project-client.d.ts +0 -16
- package/dist/types/transport/host-request-client.d.ts +0 -42
- package/dist/types/transport/host-run-state-client.d.ts +0 -23
- package/dist/types/transport/host-session-client.d.ts +0 -30
- package/dist/types/tunables.d.ts +0 -2
- package/dist/types/workflow-host.d.ts +0 -38
- package/dist/workflow-host.js +0 -11
- /package/dist/types/{host-contract → protocol/wire}/acp-content.d.ts +0 -0
- /package/dist/types/{host-contract → runtime/infra}/project-id.d.ts +0 -0
- /package/dist/types/{host-contract → runtime/infra}/provider-profile.d.ts +0 -0
|
@@ -1,94 +0,0 @@
|
|
|
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 "../protocol/wire/acp-agent-management.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
|
-
/**
|
|
20
|
-
* The persisted budget shape — SINGLE source of truth, owned here and consumed by
|
|
21
|
-
* product-persistence's execution and planning snapshots.
|
|
22
|
-
*
|
|
23
|
-
* It must stay round-trippable: `serialize()` is the only writer and `resume()` rebuilds the tracker
|
|
24
|
-
* from these exact fields. The ceilings are live state (raiseBudget mutates them), not construction
|
|
25
|
-
* config, so dropping them from the snapshot silently removes every guard from a resumed run.
|
|
26
|
-
*/
|
|
27
|
-
export interface PersistedBudgetState {
|
|
28
|
-
maxTotalTokens?: number;
|
|
29
|
-
maxDuration?: number;
|
|
30
|
-
usedTokens: number;
|
|
31
|
-
startedAt: number;
|
|
32
|
-
warningEmitted: boolean;
|
|
33
|
-
/**
|
|
34
|
-
* Absent on a planning snapshot: a planning session carries only the ceilings, and nothing has run
|
|
35
|
-
* yet, so there is no in/out split to record. Present on every execution snapshot.
|
|
36
|
-
*/
|
|
37
|
-
inputTokens?: number;
|
|
38
|
-
outputTokens?: number;
|
|
39
|
-
}
|
|
40
|
-
export declare class ProductBudgetTracker {
|
|
41
|
-
private maxTotalTokens?;
|
|
42
|
-
private maxDuration?;
|
|
43
|
-
private usedTokens;
|
|
44
|
-
private inputTokens;
|
|
45
|
-
private outputTokens;
|
|
46
|
-
private startedAt;
|
|
47
|
-
private warningEmitted;
|
|
48
|
-
constructor(budget?: {
|
|
49
|
-
maxTotalTokens?: number;
|
|
50
|
-
maxDuration?: number;
|
|
51
|
-
});
|
|
52
|
-
/** Add tokens from a usage tracker snapshot. */
|
|
53
|
-
addUsage(inputTokens: number, outputTokens: number): void;
|
|
54
|
-
/** Add tokens from an ACP usage tracker. */
|
|
55
|
-
addFromTracker(tracker: AcpUsageTracker): void;
|
|
56
|
-
/** Get current elapsed time in ms. */
|
|
57
|
-
getElapsed(): number;
|
|
58
|
-
/** Get the budget snapshot. */
|
|
59
|
-
getBudget(): ProductBudget;
|
|
60
|
-
/**
|
|
61
|
-
* Check budget status. Returns:
|
|
62
|
-
* - "ok": within budget
|
|
63
|
-
* - "warning": 80%+ but not exceeded
|
|
64
|
-
* - "exceeded": over 100%, should pause
|
|
65
|
-
*/
|
|
66
|
-
check(): BudgetCheck;
|
|
67
|
-
/**
|
|
68
|
-
* Grant additional budget headroom — the escape hatch out of a budget-exhausted pause. Without it,
|
|
69
|
-
* resume just restores usedTokens (already >= max), re-checks, and immediately re-pauses forever
|
|
70
|
-
* (a permanent deadlock with no "add budget" entry). With no explicit amount, grants one more of the
|
|
71
|
-
* current quota's worth of headroom measured from where usage stands now; an explicit amount adds
|
|
72
|
-
* exactly that. Re-arms the 80% warning so the fresh quota warns again. Time budgets get a fresh
|
|
73
|
-
* window from now (elapsed already includes paused wall-clock, so extending the raw ceiling wouldn't
|
|
74
|
-
* help). The user's act of resuming a paused-at-budget run IS the decision to spend more.
|
|
75
|
-
*/
|
|
76
|
-
raiseBudget(additional?: {
|
|
77
|
-
maxTotalTokens?: number;
|
|
78
|
-
maxDuration?: number;
|
|
79
|
-
}): void;
|
|
80
|
-
/**
|
|
81
|
-
* Restore from persisted budget data. Also re-applies the persisted ceilings so a single
|
|
82
|
-
* `restore()` fully rebuilds the tracker — callers that already passed them to the constructor
|
|
83
|
-
* are unaffected (same values), and callers that forget can no longer end up unbounded.
|
|
84
|
-
* A planning snapshot has no in/out split yet, so those default to 0 rather than being required.
|
|
85
|
-
*/
|
|
86
|
-
restore(data: PersistedBudgetState): void;
|
|
87
|
-
/**
|
|
88
|
-
* Serialize for persistence. MUST emit the ceilings: they are live state (raiseBudget mutates
|
|
89
|
-
* them) and resume() rebuilds the tracker from this snapshot alone. Omitting them made every
|
|
90
|
-
* resumed or rolled-back run unbounded, because check() short-circuits on a falsy ceiling.
|
|
91
|
-
* Absent ceilings stay absent so an unbudgeted run is not accidentally given one.
|
|
92
|
-
*/
|
|
93
|
-
serialize(): PersistedBudgetState;
|
|
94
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Product Checkpoint — automatic and manual checkpoint triggers.
|
|
3
|
-
*
|
|
4
|
-
* Rules:
|
|
5
|
-
* - Auto-checkpoint on task completion
|
|
6
|
-
* - 5 min periodic safety checkpoint 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
|
-
import type { HostRunStateAuthority } from "./run-state-host-authority.js";
|
|
12
|
-
export interface CheckpointCallbacks {
|
|
13
|
-
/** Called after each checkpoint save. */
|
|
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;
|
|
17
|
-
/** Return current state snapshot for periodic auto-saves. */
|
|
18
|
-
getState?: () => PersistedProductState | null;
|
|
19
|
-
log?: {
|
|
20
|
-
info(msg: string): void;
|
|
21
|
-
warn(msg: string): void;
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
export declare class ProductCheckpointManager {
|
|
25
|
-
private callbacks;
|
|
26
|
-
private readonly runStateAuthority;
|
|
27
|
-
/** Safety interval (5 min default, 30 min for >48h long-running). */
|
|
28
|
-
private static readonly DEFAULT_INTERVAL;
|
|
29
|
-
private static readonly LONG_RUNNING_INTERVAL;
|
|
30
|
-
private static readonly LONG_RUNNING_THRESHOLD;
|
|
31
|
-
private timer;
|
|
32
|
-
private lastCheckpointAt;
|
|
33
|
-
private checkpointTail;
|
|
34
|
-
constructor(callbacks: CheckpointCallbacks | undefined, runStateAuthority: HostRunStateAuthority);
|
|
35
|
-
/** Start periodic checkpointing for a product. */
|
|
36
|
-
start(): void;
|
|
37
|
-
/** Stop periodic checkpointing. */
|
|
38
|
-
stop(): void;
|
|
39
|
-
/** Get the appropriate checkpoint interval based on elapsed time. */
|
|
40
|
-
getInterval(elapsedMs: number): number;
|
|
41
|
-
/** Check if a checkpoint is due based on elapsed time since last checkpoint. */
|
|
42
|
-
isDue(elapsedMs: number): boolean;
|
|
43
|
-
/**
|
|
44
|
-
* Perform a checkpoint through the captured Host RunState authority and notify.
|
|
45
|
-
* Called on task completion or by periodic timer.
|
|
46
|
-
*/
|
|
47
|
-
checkpoint(state: PersistedProductState): Promise<void>;
|
|
48
|
-
/** Get the time of last checkpoint. */
|
|
49
|
-
getLastCheckpointAt(): number;
|
|
50
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { DagMutation } from "./product-planner.js";
|
|
2
|
-
import type { DagScheduler } from "./dag-scheduler.js";
|
|
3
|
-
export interface ProductDagMutationApplyResult {
|
|
4
|
-
applied: DagMutation[];
|
|
5
|
-
errors: Array<{
|
|
6
|
-
mutation: DagMutation;
|
|
7
|
-
error: string;
|
|
8
|
-
}>;
|
|
9
|
-
}
|
|
10
|
-
export declare function applyProductDagMutations(dag: DagScheduler, mutations: readonly DagMutation[]): ProductDagMutationApplyResult;
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Product persistence facade over the Gateway-owned RunStateStore.
|
|
3
|
-
*/
|
|
4
|
-
import type { ProductCreateParams, ProductPhase, ProductInstanceDef } from "../protocol/wire/acp-agent-management.js";
|
|
5
|
-
import type { PersistedBudgetState } from "./product-budget.js";
|
|
6
|
-
import type { SerializedNode } from "./dag-scheduler.js";
|
|
7
|
-
import type { PlanningSession } from "./product-planner.js";
|
|
8
|
-
import { type HostRunStateAuthority } from "./run-state-host-authority.js";
|
|
9
|
-
export interface PersistedProductState {
|
|
10
|
-
productId: string;
|
|
11
|
-
projectId: string;
|
|
12
|
-
name: string;
|
|
13
|
-
phase: ProductPhase;
|
|
14
|
-
cwd: string;
|
|
15
|
-
instances: ProductInstanceDef[];
|
|
16
|
-
tasks: SerializedNode[];
|
|
17
|
-
/** Owned by ProductBudgetTracker — see PersistedBudgetState for the round-trip contract. */
|
|
18
|
-
budget: PersistedBudgetState;
|
|
19
|
-
createdAt: string;
|
|
20
|
-
lastCheckpointAt: string;
|
|
21
|
-
/** Last durably announced attempt number for each stable task id. */
|
|
22
|
-
taskAttempts?: Record<string, number>;
|
|
23
|
-
/** Host-owned abnormal-worker handoffs, retained across Gateway restarts for bounded retry/audit. */
|
|
24
|
-
taskHandoffs?: Record<string, Array<{
|
|
25
|
-
from: string;
|
|
26
|
-
to: string;
|
|
27
|
-
error: string;
|
|
28
|
-
at: string;
|
|
29
|
-
}>>;
|
|
30
|
-
/** Parent Goal turn policy, retained so recovered Product workers do not change execution policy. */
|
|
31
|
-
turnContext?: ProductCreateParams["turnContext"];
|
|
32
|
-
/**
|
|
33
|
-
* Snapshot of the leader's multi-turn planning dialogue, so the leader regains its planning
|
|
34
|
-
* context after a resume. JSON-safe:
|
|
35
|
-
* PlanningSession is strings / arrays / plain objects (no functions, dates, or class instances).
|
|
36
|
-
*/
|
|
37
|
-
leaderDialogue?: PlanningSession;
|
|
38
|
-
}
|
|
39
|
-
/** Host checkpoint used before a Product plan transitions into DAG execution. */
|
|
40
|
-
export interface PersistedProductPlanningState {
|
|
41
|
-
stateKind: "planning";
|
|
42
|
-
productId: string;
|
|
43
|
-
projectId: string;
|
|
44
|
-
canonicalSessionId: string;
|
|
45
|
-
name: string;
|
|
46
|
-
phase: PlanningSession["phase"];
|
|
47
|
-
cwd: string;
|
|
48
|
-
instances: ProductInstanceDef[];
|
|
49
|
-
tasks: SerializedNode[];
|
|
50
|
-
/** Owned by ProductBudgetTracker — see PersistedBudgetState for the round-trip contract. */
|
|
51
|
-
budget: PersistedBudgetState;
|
|
52
|
-
createdAt: string;
|
|
53
|
-
lastCheckpointAt: string;
|
|
54
|
-
planningSession: PlanningSession;
|
|
55
|
-
}
|
|
56
|
-
export interface ProductPersistenceOptions {
|
|
57
|
-
authority?: HostRunStateAuthority;
|
|
58
|
-
}
|
|
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>;
|
|
71
|
-
/**
|
|
72
|
-
* Save a full state snapshot into Gateway checkpoint history.
|
|
73
|
-
* Uses `state.lastCheckpointAt` as the logical id (must be set before calling).
|
|
74
|
-
* Prunes old snapshots to keep at most MAX_CHECKPOINT_SNAPSHOTS entries.
|
|
75
|
-
*/
|
|
76
|
-
export declare function saveProductCheckpointSnapshot(state: PersistedProductState, options?: ProductPersistenceOptions): Promise<void>;
|
|
77
|
-
/**
|
|
78
|
-
* Load a specific checkpoint snapshot by its original ISO timestamp.
|
|
79
|
-
* Returns undefined if the snapshot does not exist.
|
|
80
|
-
*/
|
|
81
|
-
export declare function loadProductCheckpointSnapshot(productId: string, timestamp: string, options?: ProductPersistenceOptions): Promise<PersistedProductState | undefined>;
|
|
82
|
-
/**
|
|
83
|
-
* List all checkpoint timestamps for a product, sorted ascending (oldest first).
|
|
84
|
-
*/
|
|
85
|
-
export declare function listProductCheckpointTimestamps(productId: string, options?: ProductPersistenceOptions): Promise<string[]>;
|
|
86
|
-
/**
|
|
87
|
-
* Restore a specific checkpoint as the latest Product state.
|
|
88
|
-
* Returns undefined if the Host no longer has that checkpoint.
|
|
89
|
-
*/
|
|
90
|
-
export declare function restoreProductCheckpoint(productId: string, timestamp: string, options?: ProductPersistenceOptions): Promise<PersistedProductState | undefined>;
|
|
@@ -1,332 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Product Planner — Interactive multi-turn planning + persistent leader management.
|
|
3
|
-
*
|
|
4
|
-
* Architecture (aligned with CrewAI hierarchical + LangGraph durable execution):
|
|
5
|
-
*
|
|
6
|
-
* Phase 1 — PLANNING (multi-turn dialogue):
|
|
7
|
-
* 1. product.plan → spawn leader agent → leader engages user in multi-turn dialogue
|
|
8
|
-
* 2. Leader asks clarifying questions, proposes module decomposition
|
|
9
|
-
* 3. User responds via product.message → leader refines plan
|
|
10
|
-
* 4. Leader outputs structured plan → client presents to user
|
|
11
|
-
*
|
|
12
|
-
* Phase 2 — CONFIRMATION:
|
|
13
|
-
* 5. product.confirm → user confirms/modifies plan → transition to execution
|
|
14
|
-
*
|
|
15
|
-
* Phase 3 — EXECUTION (leader as persistent manager):
|
|
16
|
-
* 6. Leader manages DAG: dispatches tasks, monitors, handles failures
|
|
17
|
-
* 7. Leader can dynamically mutate DAG: add/retry/reassign tasks
|
|
18
|
-
* 8. User can intervene via product.message at any time
|
|
19
|
-
* 9. Each state transition is checkpointed for crash recovery
|
|
20
|
-
*
|
|
21
|
-
* Key mechanisms from reference projects:
|
|
22
|
-
* - CrewAI: hierarchical process (manager auto-delegates/verifies)
|
|
23
|
-
* - CrewAI: checkpoint serialization (mid-task state)
|
|
24
|
-
* - LangGraph: durable execution (persist after each node)
|
|
25
|
-
*/
|
|
26
|
-
import type { HostAgentProviderDirectory } from "../runtime/infra/host-agent-provider-directory.js";
|
|
27
|
-
import type { DelegateBridge } from "./delegate-bridge.js";
|
|
28
|
-
import type { ProductPlanParams, ProductPlan, ProductConfirmParams } from "../protocol/wire/acp-agent-management.js";
|
|
29
|
-
import { type HostRunStateAuthority } from "./run-state-host-authority.js";
|
|
30
|
-
export type PlanningPhase = "planning" | "awaiting_confirmation" | "confirmed" | "executing" | "paused" | "completed" | "failed" | "cancelled";
|
|
31
|
-
export interface PlanningMessage {
|
|
32
|
-
role: "leader" | "user";
|
|
33
|
-
content: string;
|
|
34
|
-
timestamp: string;
|
|
35
|
-
}
|
|
36
|
-
export interface PlanningSession {
|
|
37
|
-
productId: string;
|
|
38
|
-
projectId: string;
|
|
39
|
-
canonicalSessionId: string;
|
|
40
|
-
goal: string;
|
|
41
|
-
cwd: string;
|
|
42
|
-
leaderAgentId: string;
|
|
43
|
-
leaderMemberId?: string;
|
|
44
|
-
activeDelegationId?: string;
|
|
45
|
-
phase: PlanningPhase;
|
|
46
|
-
plan?: ProductPlan;
|
|
47
|
-
/** Final user-approved execution payload, durably captured before DAG creation starts. */
|
|
48
|
-
confirmedExecution?: Pick<ProductConfirmParams, "instances" | "tasks" | "budget">;
|
|
49
|
-
/** Multi-turn conversation history during planning. */
|
|
50
|
-
dialogue: PlanningMessage[];
|
|
51
|
-
budget?: {
|
|
52
|
-
maxTotalTokens?: number;
|
|
53
|
-
maxDuration?: number;
|
|
54
|
-
};
|
|
55
|
-
/**
|
|
56
|
-
* User-supplied allow-list of agent ids the leader may assign tasks to (planning AND execution-phase
|
|
57
|
-
* reassignment). Persisted AS-IS so the execution phase reuses the SAME constraint and a failure-driven
|
|
58
|
-
* reassign cannot pull in a non-participating agent. PRESENCE-based (must survive uncollapsed end to
|
|
59
|
-
* end): undefined → all ready agents; `[]` → ONLY the selected leader (user deselected every worker);
|
|
60
|
-
* `[ids]` → those + selected leader. See buildAgentRoster for the always-include-leader rule.
|
|
61
|
-
*/
|
|
62
|
-
allowedAgents?: string[];
|
|
63
|
-
createdAt: string;
|
|
64
|
-
/** Last checkpoint timestamp for durable execution. */
|
|
65
|
-
lastCheckpoint?: string;
|
|
66
|
-
/** A leader turn is currently running (planning is async/fire-and-forget) — block concurrent turns. */
|
|
67
|
-
turnInFlight?: boolean;
|
|
68
|
-
failedReason?: string;
|
|
69
|
-
}
|
|
70
|
-
export interface ProductPlanningOwner {
|
|
71
|
-
projectId: string;
|
|
72
|
-
canonicalSessionId: string;
|
|
73
|
-
cwd: string;
|
|
74
|
-
authority?: HostRunStateAuthority;
|
|
75
|
-
}
|
|
76
|
-
export interface ProductPlanAskQuestion {
|
|
77
|
-
question: string;
|
|
78
|
-
header: string;
|
|
79
|
-
options?: Array<{
|
|
80
|
-
label: string;
|
|
81
|
-
description?: string;
|
|
82
|
-
}>;
|
|
83
|
-
multiSelect?: boolean;
|
|
84
|
-
}
|
|
85
|
-
export interface PlannerCallbacks {
|
|
86
|
-
log?: {
|
|
87
|
-
info(msg: string): void;
|
|
88
|
-
warn(msg: string): void;
|
|
89
|
-
};
|
|
90
|
-
/** Leader produced a structured plan — client presents to user. */
|
|
91
|
-
onPlanReady?: (productId: string, plan: ProductPlan) => void | Promise<void>;
|
|
92
|
-
/** Planning failed. */
|
|
93
|
-
onPlanFailed?: (productId: string, error: string) => void | Promise<void>;
|
|
94
|
-
/** Streaming text from leader during planning dialogue. */
|
|
95
|
-
onPlanningDelta?: (productId: string, text: string) => void;
|
|
96
|
-
/** Leader sent a message to user (multi-turn). */
|
|
97
|
-
onLeaderMessage?: (productId: string, message: string) => void | Promise<void>;
|
|
98
|
-
/** Leader asked a structured clarifying question (turn-boundary); client renders an ask panel. */
|
|
99
|
-
onLeaderAsk?: (productId: string, askId: string, questions: ProductPlanAskQuestion[]) => void | Promise<void>;
|
|
100
|
-
/** Leader dynamically mutated the DAG during execution. */
|
|
101
|
-
onDagMutated?: (productId: string, mutation: DagMutation) => void;
|
|
102
|
-
/** Live DAG progress for the execution-phase leader (filled by the orchestrator). */
|
|
103
|
-
getProgress?: (productId: string) => {
|
|
104
|
-
total: number;
|
|
105
|
-
completed: number;
|
|
106
|
-
running: number;
|
|
107
|
-
failed: number;
|
|
108
|
-
};
|
|
109
|
-
/** Required Gateway delegate access; planning fails loud when the Host rail is unavailable. */
|
|
110
|
-
getDelegateBridge?: () => DelegateBridge | undefined;
|
|
111
|
-
}
|
|
112
|
-
/** Describes a DAG mutation performed by the leader. */
|
|
113
|
-
export interface DagMutation {
|
|
114
|
-
type: "add_task" | "remove_task" | "retry_task" | "reassign_task" | "update_prompt" | "add_dependency" | "remove_dependency";
|
|
115
|
-
taskId: string;
|
|
116
|
-
details?: Record<string, unknown>;
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Human-readable form of an execution-phase leader reply.
|
|
120
|
-
*
|
|
121
|
-
* The raw reply is prose plus a JSON mutation array. Showing it verbatim puts machine payload in the
|
|
122
|
-
* conversation; showing nothing leaves the user's question unanswered. So: prose without the JSON
|
|
123
|
-
* block, and when the leader answered only in JSON, a line naming what it actually changed.
|
|
124
|
-
*/
|
|
125
|
-
export declare function describeExecutionReply(response: string, mutations: DagMutation[]): string;
|
|
126
|
-
export declare class ProductPlanner {
|
|
127
|
-
private providerDirectory;
|
|
128
|
-
private callbacks;
|
|
129
|
-
private sessions;
|
|
130
|
-
private sessionAuthorities;
|
|
131
|
-
/** Issues from the most recent plan semantic check, quoted back in the reprompt (empty = passed). */
|
|
132
|
-
private lastPlanIssues;
|
|
133
|
-
constructor(providerDirectory: HostAgentProviderDirectory, callbacks?: PlannerCallbacks);
|
|
134
|
-
private resolveOwnerAuthority;
|
|
135
|
-
private assertSessionOwner;
|
|
136
|
-
private getOrRestoreSession;
|
|
137
|
-
/**
|
|
138
|
-
* Phases where the ORCHESTRATOR owns this run's RunState key. The planner and the orchestrator write
|
|
139
|
-
* the SAME key for the same productId; ownership hands over at markExecuting() and never comes back
|
|
140
|
-
* (markAwaitingConfirmation only rolls back a create() that never started executing).
|
|
141
|
-
*/
|
|
142
|
-
private static readonly EXECUTION_OWNED_PHASES;
|
|
143
|
-
/** True once execution owns the checkpoint — the planner must neither write it nor mutate phase. */
|
|
144
|
-
private executionHasTakenOver;
|
|
145
|
-
/**
|
|
146
|
-
* Persist the planning snapshot — unless execution has taken the key over.
|
|
147
|
-
*
|
|
148
|
-
* A leader turn is dispatched detached (`void runLeaderTurn`) with a 10-minute ceiling, so it can land
|
|
149
|
-
* long after the user confirmed and the DAG started. It used to write unconditionally, stamping a
|
|
150
|
-
* `stateKind:"planning"` snapshot over the live execution checkpoint — after which loadProductState()
|
|
151
|
-
* returns undefined for that run (it rejects planning snapshots), so a crash in that window made the
|
|
152
|
-
* executing run unresumable and reset usedTokens/task states. Dropping the stale write is correct:
|
|
153
|
-
* the planning dialogue it carried is no longer the authority for this run.
|
|
154
|
-
*/
|
|
155
|
-
private checkpointPlanningSession;
|
|
156
|
-
private publishNotification;
|
|
157
|
-
/**
|
|
158
|
-
* Start an interactive planning session (Phase 1).
|
|
159
|
-
* Spawns the leader agent and begins multi-turn dialogue.
|
|
160
|
-
*/
|
|
161
|
-
plan(params: ProductPlanParams): Promise<{
|
|
162
|
-
productId: string;
|
|
163
|
-
plan: ProductPlan;
|
|
164
|
-
}>;
|
|
165
|
-
/**
|
|
166
|
-
* Run one leader planning turn DETACHED from the RPC. Tokens stream live via product.planningDelta
|
|
167
|
-
* (the member turn.delta relay in product-coordinator); on completion this fires onPlanReady (parsed
|
|
168
|
-
* a structured plan), onLeaderAsk (a clarifying question), or onLeaderMessage (a non-plan reply).
|
|
169
|
-
* Never rejects into the caller — planning is fire-and-forget. Concurrent turns on the same session
|
|
170
|
-
* are blocked (a second prompt would cancel the in-flight one — the source of earlier "cancelled"
|
|
171
|
-
* turns) — EXCEPT the internal single-shot reprompt (isReprompt=true), which is allowed to run while
|
|
172
|
-
* turnInFlight is held by its parent turn and is itself guarded against further recursion.
|
|
173
|
-
*/
|
|
174
|
-
private runLeaderTurn;
|
|
175
|
-
/**
|
|
176
|
-
* Route one leader response: plan → onPlanReady, ask → onLeaderAsk, else free-text → onLeaderMessage.
|
|
177
|
-
*
|
|
178
|
-
* Crucially, when the response LOOKS LIKE a plan (has a ```json fence or a "tasks" key) but fails to
|
|
179
|
-
* parse as one — the embedded-fence / unescaped-quote failure modes — we do NOT dump the raw JSON into
|
|
180
|
-
* the chat bubble. We re-prompt the leader EXACTLY ONCE with a strict "valid JSON only" instruction
|
|
181
|
-
* (guarded by `isReprompt` so it can't loop), and if that ALSO fails we emit a clean, user-facing
|
|
182
|
-
* fallback message instead of the raw JSON. A response only reaches onLeaderMessage verbatim when it
|
|
183
|
-
* does NOT look like a plan (genuine clarification / free-text).
|
|
184
|
-
*/
|
|
185
|
-
private routeLeaderResponse;
|
|
186
|
-
/**
|
|
187
|
-
* Send a user message to the leader (works in planning and execution phases).
|
|
188
|
-
* Returns the leader's response and optionally a finalized plan.
|
|
189
|
-
*/
|
|
190
|
-
message(productId: string, content: string, owner?: ProductPlanningOwner): Promise<{
|
|
191
|
-
response: string;
|
|
192
|
-
plan?: ProductPlan;
|
|
193
|
-
mutations?: DagMutation[];
|
|
194
|
-
}>;
|
|
195
|
-
/**
|
|
196
|
-
* Confirm the plan → transition to execution (Phase 2 → Phase 3).
|
|
197
|
-
*/
|
|
198
|
-
confirm(params: ProductConfirmParams): Promise<{
|
|
199
|
-
productId: string;
|
|
200
|
-
ok: true;
|
|
201
|
-
}>;
|
|
202
|
-
/** Transition the in-memory leader session before the first execution checkpoint is written. */
|
|
203
|
-
markExecuting(productId: string): void;
|
|
204
|
-
markAwaitingConfirmation(productId: string): Promise<void>;
|
|
205
|
-
getRunStateAuthority(productId: string): HostRunStateAuthority | undefined;
|
|
206
|
-
/** Mark as completed. */
|
|
207
|
-
markCompleted(productId: string): void;
|
|
208
|
-
/** Get planning session by ID. */
|
|
209
|
-
getSession(productId: string): PlanningSession | undefined;
|
|
210
|
-
/** Cancel and kill leader process. */
|
|
211
|
-
cancel(productId: string, owner?: ProductPlanningOwner): Promise<void>;
|
|
212
|
-
/** List active sessions. */
|
|
213
|
-
listSessions(): PlanningSession[];
|
|
214
|
-
/**
|
|
215
|
-
* Ask the leader to judge whether a worker task's output satisfies its acceptanceCriteria.
|
|
216
|
-
*
|
|
217
|
-
* Distinguishes a VERIFIED pass (the judge ran and returned PASS) from an UNVERIFIED pass
|
|
218
|
-
* (`unverified: true`) — the run continues rather than blocking, but the caller must NOT report
|
|
219
|
-
* an unverified pass as if the work were checked. Unverified means we could not judge at all: no
|
|
220
|
-
* leader session, or the judge response was unparseable/errored. (The judging *prompt* itself is
|
|
221
|
-
* deliberately lenient/evidence-aware — that is a real PASS, not an unverified one.)
|
|
222
|
-
*/
|
|
223
|
-
reviewTaskOutput(productId: string, review: {
|
|
224
|
-
taskId: string;
|
|
225
|
-
instruction: string;
|
|
226
|
-
acceptanceCriteria: string;
|
|
227
|
-
output: string;
|
|
228
|
-
changedFiles?: string[];
|
|
229
|
-
}): Promise<{
|
|
230
|
-
pass: boolean;
|
|
231
|
-
feedback?: string;
|
|
232
|
-
unverified?: boolean;
|
|
233
|
-
}>;
|
|
234
|
-
/**
|
|
235
|
-
* Ask leader to evaluate execution state and propose DAG mutations.
|
|
236
|
-
* Called by ProductOrchestrator when tasks fail or progress stalls.
|
|
237
|
-
*/
|
|
238
|
-
consultLeader(productId: string, context: {
|
|
239
|
-
progress: {
|
|
240
|
-
total: number;
|
|
241
|
-
completed: number;
|
|
242
|
-
running: number;
|
|
243
|
-
failed: number;
|
|
244
|
-
};
|
|
245
|
-
failedTasks?: Array<{
|
|
246
|
-
taskId: string;
|
|
247
|
-
error: string;
|
|
248
|
-
}>;
|
|
249
|
-
}): Promise<DagMutation[]>;
|
|
250
|
-
/**
|
|
251
|
-
* Serialize session for checkpoint persistence (durable execution).
|
|
252
|
-
*/
|
|
253
|
-
serializeSession(productId: string): PlanningSession | null;
|
|
254
|
-
/**
|
|
255
|
-
* Restore session from checkpoint (crash recovery).
|
|
256
|
-
*/
|
|
257
|
-
restoreSession(data: PlanningSession, authority?: HostRunStateAuthority): void;
|
|
258
|
-
private handlePlanningMessage;
|
|
259
|
-
private handleExecutionMessage;
|
|
260
|
-
/**
|
|
261
|
-
* One leader turn over the Gateway delegate.
|
|
262
|
-
*
|
|
263
|
-
* `stream` opts INTO product.planningDelta and defaults to off. Only turns the user actually asked
|
|
264
|
-
* for belong in the conversation: the planning turn and a run-time steering message. The acceptance
|
|
265
|
-
* judge and the automatic failure consultation are internal machinery — they used to stream too, so
|
|
266
|
-
* every task acceptance pushed `VERDICT: PASS FEEDBACK: -` into the leader conversation. Nothing
|
|
267
|
-
* rendered that channel during a run, so the pollution stayed invisible until the run window
|
|
268
|
-
* surfaced it. Defaulting to silent means a future internal call site cannot leak by omission.
|
|
269
|
-
*/
|
|
270
|
-
private sendToLeader;
|
|
271
|
-
/**
|
|
272
|
-
* Extract a JSON object from the leader's reply. The leader (an LLM) formats the block
|
|
273
|
-
* inconsistently: ```json on its own line, ```json with the object inline, no language tag, or no
|
|
274
|
-
* fence at all. A non-greedy fence regex (`/```(?:json)?\s*([\s\S]*?)```/`) is fatally fragile: when a
|
|
275
|
-
* task/module prompt STRING embeds its own code fence (e.g. a ```bash example inside a task prompt),
|
|
276
|
-
* the non-greedy match stops at that EMBEDDED closing ```, truncating the block BEFORE the "tasks"
|
|
277
|
-
* key → a shape-valid-but-incomplete object → plan lost → raw JSON leaks into the chat bubble.
|
|
278
|
-
*
|
|
279
|
-
* Instead, scan for a balanced JSON object with string-awareness:
|
|
280
|
-
* - Pick a start index: the first `{` AT OR AFTER a ```json (or bare ```) fence opener if present,
|
|
281
|
-
* else the first `{` anywhere.
|
|
282
|
-
* - From that `{`, walk forward tracking brace depth AND JSON string state (an unescaped `"` toggles
|
|
283
|
-
* inString; a `\` inside a string escapes the next char). Count `{`/`}` only when NOT inString.
|
|
284
|
-
* Backticks/braces inside string values are thus ignored — embedded ```bash fences can't truncate.
|
|
285
|
-
* - When depth returns to 0, return the balanced `{`…`}` substring (trimmed).
|
|
286
|
-
* - If no balanced close is found, fall back to first-`{`…last-`}` (jsonrepair still gets a shot).
|
|
287
|
-
* - Return null if there is no `{` at all.
|
|
288
|
-
*/
|
|
289
|
-
private extractJsonBlock;
|
|
290
|
-
/**
|
|
291
|
-
* Parse a JSON block that an LLM emitted. LLMs (DeepSeek especially, on Chinese content) routinely
|
|
292
|
-
* produce JSON with unescaped double quotes inside string values (e.g. 默认有"销售收入""其他收入"),
|
|
293
|
-
* trailing commas, etc. — strictly invalid, so JSON.parse throws and the whole plan is lost. Fall back
|
|
294
|
-
* to jsonrepair, which fixes these common LLM mistakes heuristically. Returns null only if even the
|
|
295
|
-
* repaired text won't parse.
|
|
296
|
-
*/
|
|
297
|
-
private parseJsonLenient;
|
|
298
|
-
/**
|
|
299
|
-
* Build a canonicalizer that maps a leader-written agent identifier (which may be a display NAME like
|
|
300
|
-
* "小智"/"Claude" OR a canonical catalog id like "qlogicagent"/"claude") to the canonical catalog id.
|
|
301
|
-
*
|
|
302
|
-
* WHY: the leader prompt asks for `instances[].agentId` = "花名册里的 id", but leaders routinely emit
|
|
303
|
-
* the display NAME instead (e.g. agentId:"小智"). Downstream — the confirm pre-check
|
|
304
|
-
* (isAgentReady) and dispatch (buildExternalDescriptor) — both require a CANONICAL id; a name like
|
|
305
|
-
* "小智" makes isAgentReady fail (the qlogicagent always-ready short-circuit only matches the id, not
|
|
306
|
-
* the name) → leader-only Product wrongly blocked. Canonicalizing at parse time guarantees
|
|
307
|
-
* instances[].agentId is a catalog id regardless of what the leader wrote.
|
|
308
|
-
*
|
|
309
|
-
* The map is keyed by BOTH lowercased `id` AND lowercased `name` → canonical `id`, plus the explicit
|
|
310
|
-
* leader aliases "小智"→"qlogicagent" and "self"→"qlogicagent". Matching is EXACT (trim+lowercase) on
|
|
311
|
-
* id-or-name only — no partial/fuzzy matching, to avoid mis-mapping one agent onto another.
|
|
312
|
-
*/
|
|
313
|
-
private buildAgentIdResolver;
|
|
314
|
-
/**
|
|
315
|
-
* Normalize every `task.assignee` so it ALWAYS equals an existing `instance.name` (the canonical
|
|
316
|
-
* convention the execution dispatch keys on — see agent-instance.ts `instances.find(i => i.name === …)`).
|
|
317
|
-
*
|
|
318
|
-
* Mutates `instances`/`tasks` in place. For each task:
|
|
319
|
-
* - assignee already === some instance.name → keep.
|
|
320
|
-
* - else assignee resolves to an agentId that some instance carries → repoint assignee to THAT
|
|
321
|
-
* instance's name (pick the first matching instance, preferring a non-leader/worker role when the
|
|
322
|
-
* same agentId backs several instances — leaders usually shouldn't also be doing leaf work).
|
|
323
|
-
* - else (assignee references an agent with no instance) → append a fresh worker instance
|
|
324
|
-
* `{ name: assignee, agentId: resolveAgentId(assignee) ?? assignee, role: "worker" }` and keep
|
|
325
|
-
* assignee = that new name (now it matches).
|
|
326
|
-
* Blank assignees are left untouched (confirm-time validation surfaces them).
|
|
327
|
-
*/
|
|
328
|
-
private normalizeAssigneesToInstanceName;
|
|
329
|
-
private tryParsePlan;
|
|
330
|
-
private tryParseAsk;
|
|
331
|
-
private parseDagMutations;
|
|
332
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import type { ProductConfirmParams, ProductMessageParams, ProductPlan } from "../protocol/wire/acp-agent-management.js";
|
|
2
|
-
import type { ProductOrchestrator } from "./agent-instance.js";
|
|
3
|
-
import type { DagMutation, PlanningSession, ProductPlanner } from "./product-planner.js";
|
|
4
|
-
import type { HostRunStateAuthority } from "./run-state-host-authority.js";
|
|
5
|
-
export interface ProductLeaderCoordinator {
|
|
6
|
-
consultLeader(productId: string, context: {
|
|
7
|
-
progress: {
|
|
8
|
-
total: number;
|
|
9
|
-
completed: number;
|
|
10
|
-
running: number;
|
|
11
|
-
failed: number;
|
|
12
|
-
};
|
|
13
|
-
failedTasks?: Array<{
|
|
14
|
-
taskId: string;
|
|
15
|
-
error: string;
|
|
16
|
-
}>;
|
|
17
|
-
}): Promise<DagMutation[]>;
|
|
18
|
-
reviewTaskOutput(productId: string, review: {
|
|
19
|
-
taskId: string;
|
|
20
|
-
instruction: string;
|
|
21
|
-
acceptanceCriteria: string;
|
|
22
|
-
output: string;
|
|
23
|
-
/** Relative paths the worker created/changed in its worktree — evidence the text-only judge
|
|
24
|
-
* cannot otherwise see. Lets the judge confirm the expected artifacts exist (lenient judging). */
|
|
25
|
-
changedFiles?: string[];
|
|
26
|
-
}): Promise<{
|
|
27
|
-
pass: boolean;
|
|
28
|
-
feedback?: string;
|
|
29
|
-
unverified?: boolean;
|
|
30
|
-
}>;
|
|
31
|
-
/** Snapshot the leader's PlanningSession for checkpoint persistence (durable execution). */
|
|
32
|
-
serializeSession(productId: string): PlanningSession | null;
|
|
33
|
-
/** Restore the leader's PlanningSession from a checkpoint (crash/resume recovery). */
|
|
34
|
-
restoreSession(data: PlanningSession, authority?: HostRunStateAuthority): void;
|
|
35
|
-
}
|
|
36
|
-
export declare class ProductRunCoordinator {
|
|
37
|
-
private planner;
|
|
38
|
-
private orchestrator;
|
|
39
|
-
constructor(planner: ProductPlanner, orchestrator: ProductOrchestrator);
|
|
40
|
-
confirmAndStart(params: ProductConfirmParams): Promise<{
|
|
41
|
-
productId: string;
|
|
42
|
-
ok: true;
|
|
43
|
-
}>;
|
|
44
|
-
message(params: ProductMessageParams, authority?: HostRunStateAuthority): Promise<{
|
|
45
|
-
response: string;
|
|
46
|
-
plan?: ProductPlan;
|
|
47
|
-
mutations?: DagMutation[];
|
|
48
|
-
}>;
|
|
49
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
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
|
-
export declare function getWorktreeDiff(worktreePath: string): Promise<string>;
|
|
9
|
-
/** List the relative paths of files changed in a worktree (tracked diff vs HEAD + untracked).
|
|
10
|
-
* Used to surface "produced files" on a Product task before the worktree is torn down. */
|
|
11
|
-
export declare function listWorktreeChangedFiles(worktreePath: string): Promise<string[]>;
|
|
12
|
-
/** Copy the changed files from a task worktree back into the product workspace. */
|
|
13
|
-
export declare function materializeWorktreeChanges(worktreePath: string, targetRoot: string): Promise<void>;
|
|
14
|
-
/** Remove a git worktree. When `branch` is given, also delete the worktree's throwaway branch
|
|
15
|
-
* (created by createWorktree's `-B solo/<name>`); best effort — the branch never carries commits
|
|
16
|
-
* of its own, but leaving it behind litters the user's repo with one `solo/*` ref per racer. */
|
|
17
|
-
export declare function removeWorktree(gitRoot: string, path: string, branch?: string): Promise<void>;
|
|
18
|
-
/** Merge a worktree branch into the current branch. */
|
|
19
|
-
export declare function mergeWorktree(gitRoot: string, worktreeBranch: string): Promise<string>;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { HostRunStateClient } from "../transport/host-run-state-client.js";
|
|
2
|
-
export interface HostRunStateAuthority {
|
|
3
|
-
client: HostRunStateClient;
|
|
4
|
-
sessionId: string;
|
|
5
|
-
}
|
|
6
|
-
export declare function configureHostRunStateAuthority(resolver: (() => HostRunStateAuthority | undefined) | null): void;
|
|
7
|
-
export declare function requireHostRunStateAuthority(): HostRunStateAuthority;
|