qlogicagent 2.10.22 → 2.10.23
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 +29 -4
- package/dist/agent.js +11 -11
- package/dist/cli.js +701 -604
- package/dist/index.js +700 -603
- package/dist/permissions.js +1 -0
- package/dist/protocol.js +1 -1
- package/dist/types/agent/tool-access.d.ts +1 -30
- package/dist/types/agent/tunable-defaults.d.ts +1 -249
- package/dist/types/agent/types.d.ts +7 -0
- package/dist/types/cli/acp-extended-handlers.d.ts +41 -0
- package/dist/types/cli/acp-extended-host-adapter.d.ts +28 -0
- package/dist/types/cli/acp-extended-host-adapter.test.d.ts +1 -0
- package/dist/types/cli/acp-session-handlers.d.ts +39 -0
- package/dist/types/cli/acp-session-handlers.test.d.ts +1 -0
- package/dist/types/cli/agent-config-coordinator.d.ts +13 -0
- package/dist/types/cli/agent-config-runtime.d.ts +11 -0
- package/dist/types/cli/agent-runner-factory.d.ts +2 -0
- package/dist/types/cli/agent-runtime-bootstrap.d.ts +64 -0
- package/dist/types/cli/agent-status-notifier.d.ts +11 -0
- package/dist/types/cli/agent-status-notifier.test.d.ts +1 -0
- package/dist/types/cli/base-tool-bootstrap.d.ts +7 -0
- package/dist/types/cli/cli-acp-request-handler.d.ts +9 -0
- package/dist/types/cli/cli-acp-request-handler.test.d.ts +1 -0
- package/dist/types/cli/cli-agent-builder.d.ts +35 -0
- package/dist/types/cli/community-skill-installer.d.ts +12 -0
- package/dist/types/cli/community-skill-installer.test.d.ts +1 -0
- package/dist/types/cli/core-tool-coordinator.d.ts +30 -0
- package/dist/types/cli/core-tools/agent-tool-bootstrap.d.ts +10 -0
- package/dist/types/cli/core-tools/agent-tool-service.d.ts +18 -0
- package/dist/types/cli/core-tools/checkpoint-tool-bootstrap.d.ts +7 -0
- package/dist/types/cli/core-tools/checkpoint-tool-service.d.ts +7 -0
- package/dist/types/cli/core-tools/config-tool-bootstrap.d.ts +7 -0
- package/dist/types/cli/core-tools/config-tool-service.d.ts +7 -0
- package/dist/types/cli/core-tools/cron-tool-bootstrap.d.ts +7 -0
- package/dist/types/cli/core-tools/cron-tool-service.d.ts +22 -0
- package/dist/types/cli/core-tools/cron-tool-service.test.d.ts +1 -0
- package/dist/types/cli/core-tools/monitor-tool-bootstrap.d.ts +5 -0
- package/dist/types/cli/core-tools/monitor-tool-service.d.ts +6 -0
- package/dist/types/cli/core-tools/registry.d.ts +9 -0
- package/dist/types/cli/core-tools/team-tool-bootstrap.d.ts +7 -0
- package/dist/types/cli/core-tools/team-tool-service.d.ts +21 -0
- package/dist/types/cli/core-tools/utility-tool-bootstrap.d.ts +8 -0
- package/dist/types/cli/default-project-bootstrap.d.ts +8 -0
- package/dist/types/cli/dev-tool-bootstrap.d.ts +4 -0
- package/dist/types/cli/dev-tools/lsp-tool-service.d.ts +5 -0
- package/dist/types/cli/dev-tools/repl-lsp-tool-services.test.d.ts +1 -0
- package/dist/types/cli/dev-tools/repl-tool-service.d.ts +5 -0
- package/dist/types/cli/dream-host-adapter.d.ts +19 -0
- package/dist/types/cli/handlers/agents-handler.d.ts +28 -14
- package/dist/types/cli/handlers/community-handler.d.ts +25 -0
- package/dist/types/cli/handlers/community-handler.test.d.ts +1 -0
- package/dist/types/cli/handlers/config-handler.d.ts +15 -9
- package/dist/types/cli/handlers/config-handler.test.d.ts +1 -0
- package/dist/types/cli/handlers/control-handler.d.ts +23 -0
- package/dist/types/cli/handlers/dream-handler.d.ts +21 -1
- package/dist/types/cli/handlers/files-handler.d.ts +15 -9
- package/dist/types/cli/handlers/files-handler.instructions.test.d.ts +1 -0
- package/dist/types/cli/handlers/media-handler.d.ts +10 -4
- package/dist/types/cli/handlers/media-handler.test.d.ts +1 -0
- package/dist/types/cli/handlers/memory-handler.d.ts +39 -12
- package/dist/types/cli/handlers/pet-confirm-handler.d.ts +7 -0
- package/dist/types/cli/handlers/pet-handler.d.ts +29 -4
- package/dist/types/cli/handlers/pet-handler.test.d.ts +1 -0
- package/dist/types/cli/handlers/product-handler.d.ts +40 -14
- package/dist/types/cli/handlers/project-handler.d.ts +23 -14
- package/dist/types/cli/handlers/session-handler.d.ts +36 -17
- package/dist/types/cli/handlers/session-handler.resume.test.d.ts +1 -0
- package/dist/types/cli/handlers/settings-handler.d.ts +16 -12
- package/dist/types/cli/handlers/skills-handler.d.ts +19 -10
- package/dist/types/cli/handlers/skills-handler.profile.test.d.ts +1 -0
- package/dist/types/cli/handlers/solo-handler.d.ts +31 -9
- package/dist/types/cli/handlers/turn-handler.approval.test.d.ts +1 -0
- package/dist/types/cli/handlers/turn-handler.d.ts +17 -11
- package/dist/types/cli/idle-dream-coordinator.d.ts +46 -0
- package/dist/types/cli/idle-dream-coordinator.test.d.ts +1 -0
- package/dist/types/cli/mcp-plugin-bootstrap.d.ts +27 -0
- package/dist/types/cli/mcp-plugin-bootstrap.test.d.ts +1 -0
- package/dist/types/cli/mcp-tool-proxy.d.ts +7 -0
- package/dist/types/cli/media-file-api-service.d.ts +73 -0
- package/dist/types/cli/media-file-api-service.test.d.ts +1 -0
- package/dist/types/cli/media-file-tool-service.d.ts +13 -0
- package/dist/types/cli/memory-coordinator.d.ts +36 -0
- package/dist/types/cli/model-client-resolver.d.ts +22 -0
- package/dist/types/cli/multi-agent-handler-host.d.ts +27 -0
- package/dist/types/cli/multi-agent-handler-host.test.d.ts +1 -0
- package/dist/types/cli/multi-agent-state-coordinator.d.ts +11 -0
- package/dist/types/cli/permission-bootstrap.d.ts +33 -0
- package/dist/types/cli/permission-bootstrap.test.d.ts +1 -0
- package/dist/types/cli/permission-settings-store.d.ts +2 -0
- package/dist/types/cli/permission-settings-store.test.d.ts +1 -0
- package/dist/types/cli/pet-confirm-coordinator.d.ts +20 -0
- package/dist/types/cli/pet-confirm-coordinator.test.d.ts +1 -0
- package/dist/types/cli/pet-runtime.d.ts +34 -0
- package/dist/types/cli/pet-runtime.test.d.ts +1 -0
- package/dist/types/cli/project-context.d.ts +1 -0
- package/dist/types/cli/project-memory-store-factory.d.ts +2 -0
- package/dist/types/cli/project-template-seeder.d.ts +5 -0
- package/dist/types/cli/provider-core-facade.d.ts +27 -0
- package/dist/types/cli/rpc-registry.community.test.d.ts +1 -0
- package/dist/types/cli/rpc-registry.d.ts +8 -0
- package/dist/types/cli/runtime-hook-bootstrap.d.ts +34 -0
- package/dist/types/cli/runtime-watcher-bootstrap.d.ts +15 -0
- package/dist/types/cli/session-coordinator.d.ts +10 -0
- package/dist/types/cli/session-coordinator.test.d.ts +1 -0
- package/dist/types/cli/session-history-coordinator.d.ts +11 -0
- package/dist/types/cli/session-history-coordinator.test.d.ts +1 -0
- package/dist/types/cli/skill-meta-tool-bootstrap.d.ts +25 -0
- package/dist/types/cli/skill-meta-tool-bootstrap.test.d.ts +1 -0
- package/dist/types/cli/stdio-server.d.ts +17 -134
- package/dist/types/cli/tool-bootstrap.d.ts +1 -4
- package/dist/types/cli/tool-bootstrap.instructions.test.d.ts +1 -0
- package/dist/types/cli/tool-bootstrap.media-provider-alias.test.d.ts +1 -0
- package/dist/types/cli/tool-catalog.d.ts +2 -0
- package/dist/types/cli/tool-invoker-factory.d.ts +10 -0
- package/dist/types/cli/tool-result-processor.d.ts +14 -0
- package/dist/types/cli/transport.d.ts +2 -12
- package/dist/types/cli/turn-ask-user-setup.d.ts +9 -0
- package/dist/types/cli/turn-event-forwarder.d.ts +10 -0
- package/dist/types/cli/turn-lifecycle.d.ts +19 -0
- package/dist/types/cli/turn-lifecycle.test.d.ts +1 -0
- package/dist/types/cli/turn-media-setup.d.ts +16 -0
- package/dist/types/cli/turn-permission-sync.d.ts +7 -0
- package/dist/types/cli/turn-permission-sync.test.d.ts +1 -0
- package/dist/types/cli/turn-project-router.d.ts +22 -0
- package/dist/types/cli/turn-project-router.test.d.ts +1 -0
- package/dist/types/cli/turn-skill-autopersist.d.ts +47 -0
- package/dist/types/cli/turn-skill-autopersist.test.d.ts +1 -0
- package/dist/types/cli/turn-suggestion-generator.d.ts +15 -0
- package/dist/types/orchestration/agent-instance.d.ts +1 -1
- package/dist/types/orchestration/dag-scheduler.d.ts +135 -86
- package/dist/types/orchestration/index.d.ts +2 -2
- package/dist/types/orchestration/product-budget.d.ts +1 -1
- package/dist/types/orchestration/product-persistence.d.ts +3 -12
- package/dist/types/orchestration/product-planner.d.ts +1 -1
- package/dist/types/orchestration/skill-improvement.d.ts +1 -1
- package/dist/types/orchestration/solo-evaluator.d.ts +1 -1
- package/dist/types/orchestration/solo-persistence.d.ts +1 -1
- package/dist/types/orchestration/subagent/fork-subagent.d.ts +1 -1
- package/dist/types/orchestration/subagent/task-types.d.ts +1 -146
- package/dist/types/orchestration/tool-cascade.d.ts +2 -2
- package/dist/types/orchestration/workflow/budget-permission-gate.d.ts +85 -0
- package/dist/types/orchestration/workflow/builtin-executors.d.ts +12 -0
- package/dist/types/orchestration/workflow/cron-schedule.d.ts +37 -0
- package/dist/types/orchestration/workflow/data-item.d.ts +39 -0
- package/dist/types/orchestration/workflow/expression.d.ts +52 -0
- package/dist/types/orchestration/workflow/host-executors.d.ts +15 -0
- package/dist/types/orchestration/workflow/n8n-import.d.ts +35 -0
- package/dist/types/orchestration/workflow/node-registry.d.ts +19 -0
- package/dist/types/orchestration/workflow/node-schema.d.ts +119 -0
- package/dist/types/orchestration/workflow/run-checkpoint-store.d.ts +53 -0
- package/dist/types/orchestration/workflow/trigger-validation.d.ts +22 -0
- package/dist/types/orchestration/workflow/workflow-controller.d.ts +143 -0
- package/dist/types/orchestration/workflow/workflow-patch.d.ts +101 -0
- package/dist/types/orchestration/workflow/workflow-render.d.ts +41 -0
- package/dist/types/orchestration/workflow/workflow-runtime.d.ts +127 -0
- package/dist/types/orchestration/workflow/workflow-scheduler.d.ts +83 -0
- package/dist/types/orchestration/workflow/workflow-store.d.ts +40 -0
- package/dist/types/orchestration/workflow/workflow-trigger.d.ts +14 -0
- package/dist/types/permissions.d.ts +2 -0
- package/dist/types/permissions.public-api.test.d.ts +1 -0
- package/dist/types/protocol/methods.d.ts +262 -11
- package/dist/types/{runtime/infra/acp-types.d.ts → protocol/wire/acp-agent-management.d.ts} +3 -3
- package/dist/types/protocol/wire/agent-methods.d.ts +15 -11
- package/dist/types/protocol/wire/agent-rpc.d.ts +11 -0
- package/dist/types/protocol/wire/chat-types.d.ts +9 -0
- package/dist/types/protocol/wire/gateway-rpc.d.ts +13 -0
- package/dist/types/protocol/wire/index.d.ts +2 -1
- package/dist/types/protocol/wire/notification-payloads.d.ts +18 -3
- package/dist/types/runtime/community/community-consent-client.d.ts +117 -0
- package/dist/types/runtime/community/community-consent-client.test.d.ts +1 -0
- package/dist/types/runtime/community/community-desensitization-red-team-cli.d.ts +7 -0
- package/dist/types/runtime/community/community-desensitization-red-team-cli.test.d.ts +1 -0
- package/dist/types/runtime/community/community-desensitization.d.ts +29 -0
- package/dist/types/runtime/community/community-desensitization.test.d.ts +1 -0
- package/dist/types/runtime/community/community-telemetry-recorder.d.ts +6 -0
- package/dist/types/runtime/config/tunable-defaults.d.ts +249 -0
- package/dist/types/runtime/execution/dream-agent.d.ts +4 -2
- package/dist/types/runtime/execution/dream-category-context.d.ts +1 -1
- package/dist/types/runtime/execution/forked-agent.d.ts +3 -1
- package/dist/types/runtime/execution/streaming-tool-executor.d.ts +4 -2
- package/dist/types/runtime/execution/tool-eligibility.d.ts +1 -1
- package/dist/types/runtime/hooks/context-compression.d.ts +2 -2
- package/dist/types/runtime/hooks/memory-hooks.d.ts +6 -6
- package/dist/types/runtime/infra/acp-detector.d.ts +2 -2
- package/dist/types/runtime/infra/acp-protocol-adapter.d.ts +1 -1
- package/dist/types/runtime/infra/acp-usage-tracker.d.ts +1 -1
- package/dist/types/runtime/infra/agent-config-store.d.ts +2 -2
- package/dist/types/runtime/infra/agent-paths.d.ts +14 -10
- package/dist/types/runtime/infra/agent-paths.test.d.ts +1 -0
- package/dist/types/runtime/infra/agent-process.d.ts +2 -2
- package/dist/types/runtime/infra/checkpoint-backend.d.ts +2 -2
- package/dist/types/runtime/infra/index.d.ts +1 -1
- package/dist/types/runtime/infra/llmrouter-catalog.d.ts +10 -0
- package/dist/types/runtime/infra/mcp-bridge.d.ts +1 -1
- package/dist/types/runtime/infra/model-registry.d.ts +2 -1
- package/dist/types/runtime/infra/profile-storage.test.d.ts +1 -0
- package/dist/types/runtime/infra/skill-injector.d.ts +3 -2
- package/dist/types/runtime/infra/skill-injector.test.d.ts +1 -0
- package/dist/types/runtime/infra/task-runtime.d.ts +1 -1
- package/dist/types/runtime/infra/worktree-backend.d.ts +2 -2
- package/dist/types/runtime/memory/categories.d.ts +5 -0
- package/dist/types/runtime/memory/find-relevant-memories.d.ts +70 -0
- package/dist/types/runtime/memory/implicit-extraction.d.ts +58 -0
- package/dist/types/runtime/memory/recall-category-filter.d.ts +54 -0
- package/dist/types/runtime/pet/index.d.ts +1 -1
- package/dist/types/runtime/pet/pet-growth-engine.d.ts +10 -9
- package/dist/types/runtime/pet/pet-growth-engine.test.d.ts +1 -0
- package/dist/types/runtime/pet/pet-soul-service.d.ts +1 -2
- package/dist/types/runtime/pet/pet-soul-service.test.d.ts +1 -0
- package/dist/types/runtime/ports/agent-execution-contracts.d.ts +182 -0
- package/dist/types/runtime/ports/checkpoint-contracts.d.ts +19 -0
- package/dist/types/runtime/ports/index.d.ts +13 -0
- package/dist/types/runtime/ports/memory-provider.d.ts +146 -0
- package/dist/types/runtime/ports/memory-recall-source.d.ts +3 -0
- package/dist/types/runtime/ports/memory-writer.d.ts +21 -0
- package/dist/types/runtime/ports/path-service.d.ts +5 -0
- package/dist/types/runtime/ports/permission-contracts.d.ts +107 -0
- package/dist/types/runtime/ports/project-memory-store.d.ts +44 -0
- package/dist/types/runtime/ports/tool-call-contracts.d.ts +16 -0
- package/dist/types/runtime/ports/tool-contracts.d.ts +23 -0
- package/dist/types/runtime/ports/web-search-contracts.d.ts +17 -0
- package/dist/types/runtime/ports/worktree-contracts.d.ts +22 -0
- package/dist/types/runtime/prompt/environment-context.test.d.ts +1 -0
- package/dist/types/runtime/prompt/fresh-workspace-evidence.d.ts +19 -0
- package/dist/types/runtime/prompt/fresh-workspace-evidence.test.d.ts +1 -0
- package/dist/types/runtime/prompt/instruction-loader.d.ts +9 -3
- package/dist/types/runtime/prompt/instruction-loader.test.d.ts +1 -0
- package/dist/types/runtime/session/session-persistence.test.d.ts +1 -0
- package/dist/types/runtime/tasks/task-types.d.ts +146 -0
- package/dist/types/skills/index.d.ts +2 -2
- package/dist/types/skills/mcp/mcp-http-client.d.ts +2 -0
- package/dist/types/skills/mcp/mcp-manager.d.ts +7 -4
- package/dist/types/skills/mcp/mcp-stdio-client.d.ts +2 -0
- package/dist/types/skills/mcp/mcp-tool-metadata.d.ts +18 -0
- package/dist/types/skills/memory/categories.d.ts +1 -5
- package/dist/types/skills/memory/find-relevant-memories.d.ts +1 -70
- package/dist/types/skills/memory/implicit-extraction.d.ts +1 -58
- package/dist/types/skills/memory/local-memory-provider.d.ts +4 -10
- package/dist/types/skills/memory/local-store.d.ts +4 -4
- package/dist/types/skills/memory/memory-consolidation.d.ts +9 -1
- package/dist/types/skills/memory/memory-provider-factory.d.ts +2 -0
- package/dist/types/skills/memory/memory-tool.d.ts +4 -6
- package/dist/types/skills/memory/recall-category-filter.d.ts +1 -54
- package/dist/types/skills/permissions/community-sandbox-policy.d.ts +3 -0
- package/dist/types/skills/permissions/community-sandbox-red-team-cli.d.ts +7 -0
- package/dist/types/skills/permissions/community-sandbox-red-team.d.ts +30 -0
- package/dist/types/skills/permissions/hook-runner.d.ts +15 -2
- package/dist/types/skills/permissions/settings-watcher.d.ts +2 -0
- package/dist/types/skills/permissions/types.d.ts +2 -113
- package/dist/types/skills/portable-tool.d.ts +22 -0
- package/dist/types/skills/skill-system/skill-lifecycle.d.ts +5 -0
- package/dist/types/skills/skill-system/skill-source.d.ts +2 -148
- package/dist/types/skills/tool-access.d.ts +30 -0
- package/dist/types/skills/tools/skill-tool.d.ts +2 -10
- package/dist/types/skills/tools/web-search-tool.d.ts +3 -20
- package/dist/types/skills/tools.d.ts +1 -1
- package/dist/types/transport/acp-server.d.ts +1 -1
- package/dist/types/transport/index.d.ts +1 -0
- package/dist/types/transport/io-transport.d.ts +19 -0
- package/package.json +93 -80
- package/dist/types/llm/index.d.ts +0 -1
- /package/dist/types/{orchestration/context/context-compression.d.ts → runtime/context/context-compression-strategies.d.ts} +0 -0
|
@@ -1,118 +1,167 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* DAG Scheduler —
|
|
2
|
+
* DAG Scheduler v2 — unified scheduling for Product + Automation modes.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Single-track model: one algorithm, no compat shims, no legacy paths.
|
|
5
|
+
* Product mode = flat DAG (kind:"agent", no conditions, no loops) — strict subset.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
7
|
+
* Spec: docs/dag-scheduler-v2-spec.md
|
|
8
8
|
*/
|
|
9
|
-
import type {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
import type { ProductTaskStatus } from "../protocol/wire/acp-agent-management.js";
|
|
10
|
+
/**
|
|
11
|
+
* Loop safety hard ceiling (plan D15): a loop controller's `maxIterations` is required and may
|
|
12
|
+
* never exceed this. Unattended/triggered runs must not be able to declare an effectively
|
|
13
|
+
* unbounded loop, so a value above the cap is rejected fail-loud at construction — not clamped.
|
|
14
|
+
*/
|
|
15
|
+
export declare const LOOP_MAX_ITERATIONS_HARD_CAP = 1000;
|
|
16
|
+
/** Unified node status; "skipped" is a terminal success (intentionally not run). */
|
|
17
|
+
export type NodeStatus = ProductTaskStatus;
|
|
18
|
+
/**
|
|
19
|
+
* Fully-materialized runtime node (constructed from NodeDef, never partial).
|
|
20
|
+
* Internal to the scheduler — do not mutate directly outside DagScheduler.
|
|
21
|
+
*/
|
|
22
|
+
export interface Node {
|
|
23
|
+
id: string;
|
|
24
|
+
kind: string;
|
|
25
|
+
params: Record<string, unknown>;
|
|
26
|
+
status: NodeStatus;
|
|
27
|
+
outPorts: string[];
|
|
28
|
+
joinPolicy: "all" | "any";
|
|
29
|
+
firedPorts?: string[];
|
|
30
|
+
output?: unknown;
|
|
17
31
|
error?: string;
|
|
18
32
|
startedAt?: number;
|
|
19
33
|
completedAt?: number;
|
|
34
|
+
runIndex: number;
|
|
35
|
+
maxIterations?: number;
|
|
36
|
+
iteration?: number;
|
|
37
|
+
}
|
|
38
|
+
/** Declarative input for the constructor. Edges derived from dependsOn. */
|
|
39
|
+
export interface NodeDef {
|
|
40
|
+
id: string;
|
|
41
|
+
kind?: string;
|
|
42
|
+
params?: Record<string, unknown>;
|
|
43
|
+
dependsOn?: string[];
|
|
44
|
+
outPorts?: string[];
|
|
45
|
+
joinPolicy?: "all" | "any";
|
|
46
|
+
maxIterations?: number;
|
|
47
|
+
}
|
|
48
|
+
export interface Edge {
|
|
49
|
+
from: string;
|
|
50
|
+
to: string;
|
|
51
|
+
fromPort?: string;
|
|
52
|
+
loopBack?: boolean;
|
|
20
53
|
}
|
|
21
54
|
export declare class DagScheduler {
|
|
22
55
|
private nodes;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
getTask(taskId: string): TaskNode | undefined;
|
|
56
|
+
private edges;
|
|
57
|
+
constructor(defs: NodeDef[]);
|
|
58
|
+
getNode(id: string): Node | undefined;
|
|
59
|
+
getAllNodes(): Node[];
|
|
28
60
|
/**
|
|
29
|
-
*
|
|
61
|
+
* Ready = pending + all forward incoming edges satisfied (or no incoming edges).
|
|
62
|
+
* Spec §3.1.
|
|
30
63
|
*/
|
|
31
|
-
|
|
32
|
-
/** Mark a task as running. */
|
|
33
|
-
markRunning(taskId: string): void;
|
|
34
|
-
/** Mark a task as completed with result. */
|
|
35
|
-
markCompleted(taskId: string, result: string): void;
|
|
36
|
-
/** Mark a task as failed with error. */
|
|
37
|
-
markFailed(taskId: string, error: string): void;
|
|
38
|
-
/** Mark a task as paused. */
|
|
39
|
-
markPaused(taskId: string): void;
|
|
40
|
-
/** Resume a paused task back to pending. */
|
|
41
|
-
resumePaused(taskId: string): void;
|
|
42
|
-
/** Check if all tasks are terminal (completed, failed, or blocked by failed deps). */
|
|
64
|
+
getReadyNodes(): Node[];
|
|
43
65
|
isFinished(): boolean;
|
|
44
|
-
/**
|
|
66
|
+
/** All nodes completed or skipped (skipped = intentionally not run, counts as success). */
|
|
45
67
|
isAllCompleted(): boolean;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
dependsOn: string[];
|
|
58
|
-
status: ProductTaskStatus;
|
|
59
|
-
result?: string;
|
|
60
|
-
error?: string;
|
|
61
|
-
startedAt?: number;
|
|
62
|
-
completedAt?: number;
|
|
63
|
-
}>;
|
|
64
|
-
/** Restore from persisted data. */
|
|
65
|
-
restore(data: Array<{
|
|
66
|
-
taskId: string;
|
|
67
|
-
status: ProductTaskStatus;
|
|
68
|
-
result?: string;
|
|
69
|
-
error?: string;
|
|
70
|
-
startedAt?: number;
|
|
71
|
-
completedAt?: number;
|
|
72
|
-
}>): void;
|
|
68
|
+
getBlockedNodes(): Node[];
|
|
69
|
+
getProgress(): {
|
|
70
|
+
total: number;
|
|
71
|
+
completed: number;
|
|
72
|
+
running: number;
|
|
73
|
+
failed: number;
|
|
74
|
+
pending: number;
|
|
75
|
+
paused: number;
|
|
76
|
+
skipped: number;
|
|
77
|
+
};
|
|
78
|
+
markRunning(id: string): void;
|
|
73
79
|
/**
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
* Validates that the addition doesn't create cycles.
|
|
80
|
+
* Mark completed. firedPorts omitted → all outPorts fire (agent/tool nodes).
|
|
81
|
+
* Triggers skip propagation (§3.2).
|
|
77
82
|
*/
|
|
78
|
-
|
|
83
|
+
markCompleted(id: string, out: {
|
|
84
|
+
output?: unknown;
|
|
85
|
+
firedPorts?: string[];
|
|
86
|
+
}): void;
|
|
87
|
+
markFailed(id: string, error: string): void;
|
|
88
|
+
markPaused(id: string): void;
|
|
89
|
+
resumePaused(id: string): void;
|
|
90
|
+
markSkipped(id: string): void;
|
|
91
|
+
pauseAll(): void;
|
|
92
|
+
resumeAll(): void;
|
|
79
93
|
/**
|
|
80
|
-
*
|
|
94
|
+
* Loop controller decision (§3.3).
|
|
95
|
+
* If again && iterations remain → reset loop body, fire "loop" port.
|
|
96
|
+
* Otherwise → fire "done" port (exit).
|
|
81
97
|
*/
|
|
82
|
-
|
|
98
|
+
decideLoop(loopId: string, again: boolean): void;
|
|
99
|
+
addNode(def: NodeDef): void;
|
|
100
|
+
/** Add multiple nodes atomically. All-or-nothing. */
|
|
101
|
+
addNodes(defs: NodeDef[]): void;
|
|
83
102
|
/**
|
|
84
|
-
* Remove a pending
|
|
85
|
-
*
|
|
86
|
-
* Removes the task from other tasks' dependsOn lists.
|
|
103
|
+
* Remove a pending node. Cannot remove running or completed nodes.
|
|
104
|
+
* Removes all edges incident to this node.
|
|
87
105
|
*/
|
|
88
|
-
|
|
106
|
+
removeNode(id: string): void;
|
|
89
107
|
/**
|
|
90
|
-
*
|
|
91
|
-
* Optionally update the prompt (leader may refine instructions).
|
|
108
|
+
* Reset a failed node to pending. Optionally patches params (e.g. revised prompt).
|
|
92
109
|
*/
|
|
93
|
-
|
|
110
|
+
retryNode(id: string, paramsPatch?: Record<string, unknown>): void;
|
|
111
|
+
/** Merge patch into node.params. Node must be pending. */
|
|
112
|
+
updateNodeParams(id: string, patch: Record<string, unknown>): void;
|
|
113
|
+
/** Add an explicit edge. Validates no cycle. Validates ports exist on source. */
|
|
114
|
+
addEdge(edge: Edge): void;
|
|
115
|
+
removeEdge(from: string, to: string, fromPort?: string): void;
|
|
116
|
+
serialize(): SerializedNode[];
|
|
94
117
|
/**
|
|
95
|
-
*
|
|
118
|
+
* Restore status from persisted snapshot.
|
|
119
|
+
* Running nodes become pending (need re-execution after crash).
|
|
120
|
+
* Missing fields use defaults.
|
|
96
121
|
*/
|
|
97
|
-
|
|
122
|
+
restore(data: SerializedNode[]): void;
|
|
123
|
+
/** §3.1 edge predicate: source completed AND this port fired. */
|
|
124
|
+
private edgeSatisfied;
|
|
125
|
+
/** An edge is "dead" if the source is skipped, OR source completed but did NOT fire this port. */
|
|
126
|
+
private edgeDead;
|
|
127
|
+
private incomingForwardEdges;
|
|
128
|
+
private isBlockedByFailed;
|
|
129
|
+
/** A pending node is "skippable" if all its forward edges are dead. */
|
|
130
|
+
private isSkippable;
|
|
98
131
|
/**
|
|
99
|
-
*
|
|
132
|
+
* §3.2 Skip propagation.
|
|
133
|
+
* After markCompleted/markFailed/markSkipped, repeatedly mark pending nodes
|
|
134
|
+
* whose incoming edges are all dead as skipped.
|
|
135
|
+
* Product mode (no conditional edges) → no-op.
|
|
100
136
|
*/
|
|
101
|
-
|
|
137
|
+
private propagateSkips;
|
|
102
138
|
/**
|
|
103
|
-
*
|
|
139
|
+
* §3.3 Reset all loop-body nodes back to pending for next iteration.
|
|
104
140
|
*/
|
|
105
|
-
|
|
141
|
+
private resetLoopScope;
|
|
106
142
|
/**
|
|
107
|
-
*
|
|
143
|
+
* Compute the loop body: nodes reachable from the loop controller's "loop" outPort
|
|
144
|
+
* via non-loopBack forward edges, up to (but not including) the loop controller itself.
|
|
145
|
+
* The controller's "done" port leads OUT of the loop and is not part of the body.
|
|
108
146
|
*/
|
|
109
|
-
|
|
110
|
-
total: number;
|
|
111
|
-
completed: number;
|
|
112
|
-
running: number;
|
|
113
|
-
failed: number;
|
|
114
|
-
pending: number;
|
|
115
|
-
paused: number;
|
|
116
|
-
};
|
|
147
|
+
private loopBodyNodes;
|
|
117
148
|
private validateDag;
|
|
149
|
+
private requireNode;
|
|
150
|
+
}
|
|
151
|
+
export interface SerializedNode {
|
|
152
|
+
id: string;
|
|
153
|
+
kind: string;
|
|
154
|
+
params: Record<string, unknown>;
|
|
155
|
+
dependsOn: string[];
|
|
156
|
+
outPorts: string[];
|
|
157
|
+
joinPolicy: "all" | "any";
|
|
158
|
+
status: NodeStatus;
|
|
159
|
+
firedPorts?: string[];
|
|
160
|
+
output?: unknown;
|
|
161
|
+
error?: string;
|
|
162
|
+
startedAt?: number;
|
|
163
|
+
completedAt?: number;
|
|
164
|
+
runIndex: number;
|
|
165
|
+
maxIterations?: number;
|
|
166
|
+
iteration?: number;
|
|
118
167
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { buildAssistantToolCallMessage, buildToolResultMessage, type FunctionToolDefinition, } from "./tool-loop/tool-schema.js";
|
|
2
2
|
export { classifyError, isRetryableCategory, type ErrorCategory, } from "./error-handling/error-classification.js";
|
|
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 "
|
|
4
|
-
export { snipCompactIfNeeded, type SnipResult, } from "
|
|
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
|
+
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
6
|
export { buildSkillInstruction, recordPatternAndCheckThreshold, getPatternStats, buildToolSignature, type SkillCreateInstruction, type SkillImproveInstruction, type SkillInstruction, type SkillTurnResult, } from "./skill-improvement.js";
|
|
7
7
|
export { applyToolChoicePolicy, type ApplyToolChoicePolicyInput, type ApplyToolChoicePolicyResult, } from "./tool-loop/tool-choice-policy.js";
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Tracks cumulative token usage and elapsed time across all agent instances.
|
|
5
5
|
* Emits 80% warning and enforces 100% hard limit.
|
|
6
6
|
*/
|
|
7
|
-
import type { ProductBudget } from "../
|
|
7
|
+
import type { ProductBudget } from "../protocol/wire/acp-agent-management.js";
|
|
8
8
|
import type { AcpUsageTracker } from "../runtime/infra/acp-usage-tracker.js";
|
|
9
9
|
/** Budget state and enforcement result. */
|
|
10
10
|
export type BudgetAction = "ok" | "warning" | "exceeded";
|
|
@@ -4,24 +4,15 @@
|
|
|
4
4
|
* State is stored at `<project>/.qlogicagent/products/<productId>/product-state.json`.
|
|
5
5
|
* Product listing is done by enumerating subdirectories.
|
|
6
6
|
*/
|
|
7
|
-
import type { ProductPhase,
|
|
7
|
+
import type { ProductPhase, ProductInstanceDef } from "../protocol/wire/acp-agent-management.js";
|
|
8
|
+
import type { SerializedNode } from "./dag-scheduler.js";
|
|
8
9
|
export interface PersistedProductState {
|
|
9
10
|
productId: string;
|
|
10
11
|
name: string;
|
|
11
12
|
phase: ProductPhase;
|
|
12
13
|
cwd: string;
|
|
13
14
|
instances: ProductInstanceDef[];
|
|
14
|
-
tasks:
|
|
15
|
-
taskId: string;
|
|
16
|
-
assignee: string;
|
|
17
|
-
prompt: string;
|
|
18
|
-
dependsOn: string[];
|
|
19
|
-
status: ProductTaskStatus;
|
|
20
|
-
result?: string;
|
|
21
|
-
error?: string;
|
|
22
|
-
startedAt?: number;
|
|
23
|
-
completedAt?: number;
|
|
24
|
-
}>;
|
|
15
|
+
tasks: SerializedNode[];
|
|
25
16
|
budget: {
|
|
26
17
|
maxTotalTokens?: number;
|
|
27
18
|
maxDuration?: number;
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
import type { AgentProcessManager } from "../runtime/infra/agent-process.js";
|
|
27
27
|
import type { AcpDetector } from "../runtime/infra/acp-detector.js";
|
|
28
28
|
import type { AgentConfigStore } from "../runtime/infra/agent-config-store.js";
|
|
29
|
-
import type { ProductPlanParams, ProductPlan, ProductConfirmParams } from "../
|
|
29
|
+
import type { ProductPlanParams, ProductPlan, ProductConfirmParams } from "../protocol/wire/acp-agent-management.js";
|
|
30
30
|
export type PlanningPhase = "planning" | "awaiting_confirmation" | "confirmed" | "executing" | "paused" | "completed" | "cancelled";
|
|
31
31
|
export interface PlanningMessage {
|
|
32
32
|
role: "leader" | "user";
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* - Dedup check: compares tool-set signature against existing skills
|
|
10
10
|
* - Cooldown: prevents rapid-fire creation within a session
|
|
11
11
|
*/
|
|
12
|
-
import { MAX_SKILLS_PER_PROJECT, MAX_SKILLS_GLOBAL } from "../
|
|
12
|
+
import { MAX_SKILLS_PER_PROJECT, MAX_SKILLS_GLOBAL } from "../runtime/config/tunable-defaults.js";
|
|
13
13
|
export { MAX_SKILLS_PER_PROJECT, MAX_SKILLS_GLOBAL };
|
|
14
14
|
export interface SkillTurnResult {
|
|
15
15
|
ok: boolean;
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
import type { AgentProcessManager } from "../runtime/infra/agent-process.js";
|
|
22
22
|
import type { AcpDetector } from "../runtime/infra/acp-detector.js";
|
|
23
23
|
import type { AgentConfigStore } from "../runtime/infra/agent-config-store.js";
|
|
24
|
-
import type { SoloAgentState, SoloEvaluation, SoloStatus, SoloStartParams, SoloSelectParams } from "../
|
|
24
|
+
import type { SoloAgentState, SoloEvaluation, SoloStatus, SoloStartParams, SoloSelectParams } from "../protocol/wire/acp-agent-management.js";
|
|
25
25
|
export interface SoloCallbacks {
|
|
26
26
|
log?: {
|
|
27
27
|
info(msg: string): void;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* State is stored at `<project>/.qlogicagent/solos/<soloId>/solo-state.json`.
|
|
5
5
|
* Mirrors the product-persistence.ts pattern.
|
|
6
6
|
*/
|
|
7
|
-
import type { SoloState, SoloAgentState, SoloEvaluation } from "../
|
|
7
|
+
import type { SoloState, SoloAgentState, SoloEvaluation } from "../protocol/wire/acp-agent-management.js";
|
|
8
8
|
export interface PersistedSoloState {
|
|
9
9
|
soloId: string;
|
|
10
10
|
state: SoloState;
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* 5. Depth control via in-memory counter (not DB-based)
|
|
10
10
|
*/
|
|
11
11
|
import type { AgentDefinition } from "./agent-registry.js";
|
|
12
|
-
import { MAX_FORK_DEPTH } from "../../
|
|
12
|
+
import { MAX_FORK_DEPTH } from "../../runtime/config/tunable-defaults.js";
|
|
13
13
|
/** Sentinel tag injected into fork children to prevent recursive forking. */
|
|
14
14
|
export declare const FORK_SENTINEL_TAG = "<fork-child-context>";
|
|
15
15
|
/** Placeholder text used for all tool_results in shared prefix (ensures byte-identical prefix). */
|
|
@@ -1,146 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Task Type Taxonomy — CC-aligned sub-agent task state system.
|
|
3
|
-
*
|
|
4
|
-
* CC defines 7 task types for sub-agent dispatch. Each type has different:
|
|
5
|
-
* - Execution model (in-process, subprocess, remote)
|
|
6
|
-
* - Isolation level (shared, worktree, container)
|
|
7
|
-
* - Permission handling (interactive, coordinator, worker)
|
|
8
|
-
* - Tool access (full, restricted, read-only)
|
|
9
|
-
*
|
|
10
|
-
* Reference: claude-code src/tasks/types.ts
|
|
11
|
-
*/
|
|
12
|
-
/**
|
|
13
|
-
* The 7 task types from CC's sub-agent architecture.
|
|
14
|
-
*
|
|
15
|
-
* - local_bash: Subprocess shell execution (bash/powershell)
|
|
16
|
-
* - local_agent: Background forked Node process with its own tool loop
|
|
17
|
-
* - remote_agent: Cloud environment (polling-based, e.g., CCR sandbox)
|
|
18
|
-
* - in_process_teammate: Same process, AsyncLocalStorage-isolated agent
|
|
19
|
-
* - local_workflow: DAG/pipeline execution (planned)
|
|
20
|
-
* - monitor_mcp: MCP server monitoring agent (planned)
|
|
21
|
-
* - dream: Background memory consolidation agent
|
|
22
|
-
*/
|
|
23
|
-
export type TaskType = "local_bash" | "local_agent" | "remote_agent" | "in_process_teammate" | "local_workflow" | "monitor_mcp" | "dream";
|
|
24
|
-
/**
|
|
25
|
-
* How a sub-agent is isolated from the parent execution.
|
|
26
|
-
*
|
|
27
|
-
* - shared: Same working directory, same filesystem (default fork)
|
|
28
|
-
* - worktree: Git worktree checkout — separate branch, merges back
|
|
29
|
-
* - container: Container sandbox (docker/remote)
|
|
30
|
-
*/
|
|
31
|
-
export type IsolationMode = "shared" | "worktree" | "container";
|
|
32
|
-
/**
|
|
33
|
-
* Permission context for sub-agent execution.
|
|
34
|
-
* Determines which PermissionChecker variant is used.
|
|
35
|
-
*
|
|
36
|
-
* CC reference: 3 permission handler variants
|
|
37
|
-
* - interactive: User-facing agent, prompts for approval
|
|
38
|
-
* - coordinator: Orchestrator agent, auto-approves most non-destructive ops
|
|
39
|
-
* - worker: Headless worker, classifier-only (no user prompts)
|
|
40
|
-
*/
|
|
41
|
-
export type PermissionRole = "interactive" | "coordinator" | "worker";
|
|
42
|
-
/** Common state fields shared by all task types. */
|
|
43
|
-
export interface TaskStateBase {
|
|
44
|
-
/** Unique task ID. */
|
|
45
|
-
taskId: string;
|
|
46
|
-
/** Task type discriminant. */
|
|
47
|
-
type: TaskType;
|
|
48
|
-
/** Human-readable label. */
|
|
49
|
-
label: string;
|
|
50
|
-
/** The permission role for this task's agent. */
|
|
51
|
-
permissionRole: PermissionRole;
|
|
52
|
-
/** Isolation mode. */
|
|
53
|
-
isolation: IsolationMode;
|
|
54
|
-
/** Current lifecycle state. */
|
|
55
|
-
lifecycle: TaskLifecycle;
|
|
56
|
-
/** Parent task ID (for nested sub-agents). */
|
|
57
|
-
parentTaskId?: string;
|
|
58
|
-
/** Execution depth (0 = root). */
|
|
59
|
-
depth: number;
|
|
60
|
-
/** Maximum turns before forced stop. */
|
|
61
|
-
maxTurns: number;
|
|
62
|
-
/** Token budget for this task. */
|
|
63
|
-
tokenBudget: number;
|
|
64
|
-
/** Start timestamp (ms). */
|
|
65
|
-
startedAt: number;
|
|
66
|
-
/** End timestamp (ms), set when completed/failed. */
|
|
67
|
-
endedAt?: number;
|
|
68
|
-
}
|
|
69
|
-
export type TaskLifecycle = "pending" | "running" | "completed" | "failed" | "cancelled" | "timeout";
|
|
70
|
-
/** Local bash task — subprocess shell execution. */
|
|
71
|
-
export interface LocalBashTaskState extends TaskStateBase {
|
|
72
|
-
type: "local_bash";
|
|
73
|
-
command: string;
|
|
74
|
-
cwd: string;
|
|
75
|
-
pid?: number;
|
|
76
|
-
}
|
|
77
|
-
/** Local agent task — forked agent with its own tool loop. */
|
|
78
|
-
export interface LocalAgentTaskState extends TaskStateBase {
|
|
79
|
-
type: "local_agent";
|
|
80
|
-
agentName: string;
|
|
81
|
-
systemPrompt: string;
|
|
82
|
-
/** Restricted tool set (empty = inherit parent). */
|
|
83
|
-
allowedTools: string[];
|
|
84
|
-
/** Worktree branch name (if isolation === "worktree"). */
|
|
85
|
-
worktreeBranch?: string;
|
|
86
|
-
}
|
|
87
|
-
/** Remote agent task — cloud sandbox execution. */
|
|
88
|
-
export interface RemoteAgentTaskState extends TaskStateBase {
|
|
89
|
-
type: "remote_agent";
|
|
90
|
-
/** Remote session/environment ID. */
|
|
91
|
-
remoteSessionId: string;
|
|
92
|
-
/** Polling endpoint for status checks. */
|
|
93
|
-
pollEndpoint?: string;
|
|
94
|
-
}
|
|
95
|
-
/** In-process teammate — AsyncLocalStorage-isolated, same process. */
|
|
96
|
-
export interface InProcessTeammateTaskState extends TaskStateBase {
|
|
97
|
-
type: "in_process_teammate";
|
|
98
|
-
teamName: string;
|
|
99
|
-
agentName: string;
|
|
100
|
-
/** Teammate's independent permission mode. */
|
|
101
|
-
permissionMode: string;
|
|
102
|
-
/** Async mailbox for coordinator ↔ worker communication. */
|
|
103
|
-
mailboxId?: string;
|
|
104
|
-
/** Isolated git worktree path for this teammate (CC team worktree parity). */
|
|
105
|
-
worktreePath?: string;
|
|
106
|
-
/** Worktree branch name (for cleanup). */
|
|
107
|
-
worktreeBranch?: string;
|
|
108
|
-
}
|
|
109
|
-
/** A single dream agent turn — text output + tool use count. */
|
|
110
|
-
export interface DreamTurn {
|
|
111
|
-
text: string;
|
|
112
|
-
toolUseCount: number;
|
|
113
|
-
}
|
|
114
|
-
/** Dream phase lifecycle — CC alignment. */
|
|
115
|
-
export type DreamPhase = "starting" | "updating" | "completed" | "failed";
|
|
116
|
-
/** Dream task — background memory consolidation agent (CC autoDream parity). */
|
|
117
|
-
export interface DreamTaskState extends TaskStateBase {
|
|
118
|
-
type: "dream";
|
|
119
|
-
sessionId: string;
|
|
120
|
-
/** Current dream phase. */
|
|
121
|
-
phase: DreamPhase;
|
|
122
|
-
/** Number of sessions being reviewed. */
|
|
123
|
-
sessionsReviewing: number;
|
|
124
|
-
/** Memory files touched by the dream agent. */
|
|
125
|
-
filesTouched: string[];
|
|
126
|
-
/** Dream agent turn history (capped). */
|
|
127
|
-
turns: DreamTurn[];
|
|
128
|
-
/** Stashed lock mtime for rollback on failure. */
|
|
129
|
-
priorLockMtime: number;
|
|
130
|
-
}
|
|
131
|
-
/** Placeholder for planned task types. */
|
|
132
|
-
export interface PlannedTaskState extends TaskStateBase {
|
|
133
|
-
type: "local_workflow" | "monitor_mcp";
|
|
134
|
-
}
|
|
135
|
-
/** Union of all concrete task states. */
|
|
136
|
-
export type TaskState = LocalBashTaskState | LocalAgentTaskState | RemoteAgentTaskState | InProcessTeammateTaskState | DreamTaskState | PlannedTaskState;
|
|
137
|
-
/**
|
|
138
|
-
* Filter available tools by permission role.
|
|
139
|
-
*
|
|
140
|
-
* @param role - The agent's permission role
|
|
141
|
-
* @param availableTools - Full set of tool names
|
|
142
|
-
* @returns Filtered tool names appropriate for the role
|
|
143
|
-
*/
|
|
144
|
-
export declare function filterToolsByRole(role: PermissionRole, availableTools: string[]): string[];
|
|
145
|
-
/** Create a new task state with defaults populated. */
|
|
146
|
-
export declare function createTaskState(overrides: Pick<TaskStateBase, "taskId" | "type" | "label"> & Partial<TaskStateBase>): TaskStateBase;
|
|
1
|
+
export * from "../../runtime/tasks/task-types.js";
|
|
@@ -31,10 +31,10 @@
|
|
|
31
31
|
* ```
|
|
32
32
|
*/
|
|
33
33
|
import type { ProviderToolAPI } from "@xiaozhiclaw/provider-core";
|
|
34
|
-
import type {
|
|
34
|
+
import type { WebSearchBackend } from "../runtime/ports/web-search-contracts.js";
|
|
35
35
|
/**
|
|
36
36
|
* Cascade web search: provider-native search → host fallback.
|
|
37
37
|
* Returns a WebSearchToolDeps.search function that tries the provider's
|
|
38
38
|
* webSearch API first, falling back to the host's search on error.
|
|
39
39
|
*/
|
|
40
|
-
export declare function cascadeWebSearch(providerApi: ProviderToolAPI | undefined, fallbackSearch:
|
|
40
|
+
export declare function cascadeWebSearch(providerApi: ProviderToolAPI | undefined, fallbackSearch: WebSearchBackend["search"]): WebSearchBackend["search"];
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Budget + permission ExecutionGate — the engine half of plan D15 ("无人值守触发须过 budget+权限闸门")
|
|
3
|
+
* and the M2 acceptance "触发式运行受 budget+权限闸门拦截".
|
|
4
|
+
*
|
|
5
|
+
* A workflow run is either ATTENDED (trigger "manual": a human is present and authorizes
|
|
6
|
+
* interactively) or UNATTENDED (trigger "schedule" / "im-message" / "webhook": fired by the
|
|
7
|
+
* trigger layer with nobody watching). This gate enforces two independent guarantees on every
|
|
8
|
+
* node, before it executes:
|
|
9
|
+
*
|
|
10
|
+
* 1. Permission (security, HARD fail-loud) — an unattended run may only execute side-effecting
|
|
11
|
+
* ("sensitive") node kinds that were EXPLICITLY authorized via `allowUnattendedKinds`. A
|
|
12
|
+
* sensitive kind that was not pre-authorized throws `WorkflowPermissionDenied` and halts the
|
|
13
|
+
* run (status "failed"). Pure / control-flow kinds (set/if/loop/merge/passthrough/trigger)
|
|
14
|
+
* are always allowed. Manual runs skip permission entirely (the user is the authorization).
|
|
15
|
+
* 2. Budget (resumable pause) — every node must pass the per-run budget (D15 "每轮过 budget"):
|
|
16
|
+
* a hard cap on node executions and an optional wall-clock cap. Exceeding either throws
|
|
17
|
+
* `WorkflowBudgetExceeded`, which extends the runtime's pause signal, so the run SUSPENDS
|
|
18
|
+
* with its cache intact (raise the budget, then resume) rather than failing — mirroring the
|
|
19
|
+
* existing ProductBudgetTracker "exceeded → pause" semantics.
|
|
20
|
+
*
|
|
21
|
+
* Pure and deterministic: no I/O, an injectable clock. fail-loud construction: a non-positive
|
|
22
|
+
* `maxNodeExecutions` (or non-positive `maxDurationMs`) throws — a budget with no ceiling is a
|
|
23
|
+
* silent way to disable the gate, which D15 forbids.
|
|
24
|
+
*/
|
|
25
|
+
import { WorkflowPauseSignal, type ExecutionGate } from "./workflow-runtime.js";
|
|
26
|
+
/** The trigger kinds that can start a run. Single source of the union (consumed by the controller). */
|
|
27
|
+
export type WorkflowTriggerKind = "manual" | "schedule" | "im-message" | "webhook";
|
|
28
|
+
/**
|
|
29
|
+
* Node kinds that reach the outside world (network calls, channel sends, agent/tool/mcp side
|
|
30
|
+
* effects). These require explicit authorization to run unattended. Control / data-shaping kinds
|
|
31
|
+
* (set / if / loop / merge / passthrough / trigger) are NOT here — they cannot escape the engine.
|
|
32
|
+
*/
|
|
33
|
+
export declare const SENSITIVE_KINDS: ReadonlySet<string>;
|
|
34
|
+
/** Hard, non-resumable denial: an unauthorized side-effecting kind under an unattended trigger. */
|
|
35
|
+
export declare class WorkflowPermissionDenied extends Error {
|
|
36
|
+
readonly nodeId: string;
|
|
37
|
+
readonly kind: string;
|
|
38
|
+
readonly trigger: WorkflowTriggerKind;
|
|
39
|
+
constructor(nodeId: string, kind: string, trigger: WorkflowTriggerKind);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Budget ceiling reached. Extends WorkflowPauseSignal so the runtime treats it as a graceful,
|
|
43
|
+
* resumable suspension (cache retained) rather than a failure — the caller raises the budget and
|
|
44
|
+
* resumes, and already-completed nodes hit cache.
|
|
45
|
+
*/
|
|
46
|
+
export declare class WorkflowBudgetExceeded extends WorkflowPauseSignal {
|
|
47
|
+
readonly reason: "executions" | "duration";
|
|
48
|
+
readonly limit: number;
|
|
49
|
+
constructor(atNodeId: string, reason: "executions" | "duration", limit: number);
|
|
50
|
+
}
|
|
51
|
+
export interface BudgetPermissionGateOptions {
|
|
52
|
+
/** Trigger kind of THIS run. "manual" = attended (permission skipped); others = unattended. */
|
|
53
|
+
trigger: WorkflowTriggerKind;
|
|
54
|
+
/** Hard cap on node executions per run (D15 loop hard-cap is separate, in the scheduler). */
|
|
55
|
+
maxNodeExecutions: number;
|
|
56
|
+
/** Optional wall-clock cap in ms; the run pauses once elapsed reaches it. */
|
|
57
|
+
maxDurationMs?: number;
|
|
58
|
+
/** Sensitive kinds an UNATTENDED run is allowed to execute. Ignored for manual runs. */
|
|
59
|
+
allowUnattendedKinds?: readonly string[];
|
|
60
|
+
/** Injectable clock (ms epoch) for deterministic tests. */
|
|
61
|
+
now?: () => number;
|
|
62
|
+
}
|
|
63
|
+
export declare class BudgetPermissionGate implements ExecutionGate {
|
|
64
|
+
private readonly trigger;
|
|
65
|
+
private maxNodeExecutions;
|
|
66
|
+
private maxDurationMs?;
|
|
67
|
+
private readonly allow;
|
|
68
|
+
private readonly now;
|
|
69
|
+
private executions;
|
|
70
|
+
private startedAt;
|
|
71
|
+
constructor(opts: BudgetPermissionGateOptions);
|
|
72
|
+
private get unattended();
|
|
73
|
+
/** Invoked by the runtime before each node executes. Throws to deny (hard) or pause (budget). */
|
|
74
|
+
check(nodeId: string, kind: string): void;
|
|
75
|
+
/**
|
|
76
|
+
* Raise the remaining allowance so a budget-paused run can resume (D15 "抬预算后 resume").
|
|
77
|
+
* Deltas are ADDED to the current ceilings. fail-loud: a non-positive delta is rejected, and
|
|
78
|
+
* extending duration is only valid when a duration cap exists (extending an absent cap is a
|
|
79
|
+
* silent no-op the caller likely did not intend).
|
|
80
|
+
*/
|
|
81
|
+
extend(delta: {
|
|
82
|
+
executions?: number;
|
|
83
|
+
durationMs?: number;
|
|
84
|
+
}): void;
|
|
85
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in deterministic NodeExecutors (M2).
|
|
3
|
+
*
|
|
4
|
+
* These are REAL node implementations (not mocks): pure data transforms used by automation
|
|
5
|
+
* workflows. Host-backed kinds (agent/tool/http/mcp/channel) are injected separately so the
|
|
6
|
+
* engine stays a pure executor (plan D12/D13).
|
|
7
|
+
*
|
|
8
|
+
* Note: "loop" is NOT here — loop control is owned by the runtime (DagScheduler.decideLoop),
|
|
9
|
+
* not a user executor.
|
|
10
|
+
*/
|
|
11
|
+
import type { NodeExecutor } from "./node-schema.js";
|
|
12
|
+
export declare const builtinExecutors: Record<string, NodeExecutor>;
|