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,103 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Run History Store — durable per-workflow run records (闭环 "察" 半场).
|
|
3
|
-
*
|
|
4
|
-
* The checkpoint store (run-checkpoint-store.ts) is an execution cache that is
|
|
5
|
-
* DELETED when a run completes — it cannot answer "what did the last run do?".
|
|
6
|
-
* This store keeps a bounded, append-style history per workflow so the canvas
|
|
7
|
-
* can show past runs and per-node outputs:
|
|
8
|
-
*
|
|
9
|
-
* `<project>/.qlogicagent/workflows/<workflowId>/runs/history.json`
|
|
10
|
-
*
|
|
11
|
-
* Recording happens in WorkflowController.run() — the single choke point every
|
|
12
|
-
* trigger path goes through (manual RPC, cron scheduler, IM, webhook) — so
|
|
13
|
-
* scheduled runs are captured identically to manual ones.
|
|
14
|
-
*
|
|
15
|
-
* Node outputs are stored as TRUNCATED JSON previews (default-port items'
|
|
16
|
-
* `json`), not full PortMaps: history is for inspection, the checkpoint cache
|
|
17
|
-
* remains the execution-fidelity layer. Bounded to the most recent
|
|
18
|
-
* MAX_RUN_HISTORY entries; corrupt/missing history degrades to empty (history
|
|
19
|
-
* must never block a run).
|
|
20
|
-
*/
|
|
21
|
-
import type { RunResult } from "./workflow-runtime.js";
|
|
22
|
-
import { type WorkflowError } from "./workflow-error.js";
|
|
23
|
-
export declare const MAX_RUN_HISTORY = 20;
|
|
24
|
-
export type RunHistoryStatus = "running" | "completed" | "failed" | "paused" | "skipped" | "canceled";
|
|
25
|
-
export interface RunNodeActivity {
|
|
26
|
-
ts: string;
|
|
27
|
-
phase: "started" | "waiting" | "generating" | "tool_call" | "tool_result" | "completed" | "failed";
|
|
28
|
-
label: string;
|
|
29
|
-
detail?: string;
|
|
30
|
-
}
|
|
31
|
-
export interface RunNodeRecord {
|
|
32
|
-
/** Whether the node's executor actually ran (false = checkpoint cache hit). */
|
|
33
|
-
executed: boolean;
|
|
34
|
-
/** Truncated JSON preview of the node's output items (port → items[].json). */
|
|
35
|
-
preview: string;
|
|
36
|
-
seq?: number;
|
|
37
|
-
startedAt?: string;
|
|
38
|
-
durationMs?: number;
|
|
39
|
-
attempts?: number;
|
|
40
|
-
cacheHit?: boolean;
|
|
41
|
-
/** Per-node disposition; "failed" with a surviving run = onError errorPort/continue (D32). */
|
|
42
|
-
nodeStatus?: "running" | "completed" | "failed";
|
|
43
|
-
/** Safe execution-stage timeline. Never contains model chain-of-thought or raw tool arguments. */
|
|
44
|
-
activities?: RunNodeActivity[];
|
|
45
|
-
/** Live/terminal node error, when available. */
|
|
46
|
-
error?: string;
|
|
47
|
-
/** Engine-imposed limit surfaced on this node (e.g. a loop forced out at its iteration cap). */
|
|
48
|
-
warning?: string;
|
|
49
|
-
}
|
|
50
|
-
export interface RunHistoryEntry {
|
|
51
|
-
runId: string;
|
|
52
|
-
status: RunHistoryStatus;
|
|
53
|
-
triggerType: string;
|
|
54
|
-
startedAt: string;
|
|
55
|
-
finishedAt?: string;
|
|
56
|
-
durationMs?: number;
|
|
57
|
-
error?: string;
|
|
58
|
-
/** AI-5 (D49): classified, human-readable form of `error` (人话 + class + 0-死端 next-step actions). */
|
|
59
|
-
errorInfo?: WorkflowError;
|
|
60
|
-
/** AI-5: node that caused a "failed" run — precise canvas attribution. Hard-stop failures reject
|
|
61
|
-
* without node records, so the runtime tags the failing node onto the thrown error. */
|
|
62
|
-
failedNodeId?: string;
|
|
63
|
-
/** nodeId → output record. Present once the run settles (not while running). */
|
|
64
|
-
nodes?: Record<string, RunNodeRecord>;
|
|
65
|
-
}
|
|
66
|
-
export interface RecoverableWorkflowRun {
|
|
67
|
-
runId: string;
|
|
68
|
-
triggerType: string;
|
|
69
|
-
startedAt: string;
|
|
70
|
-
triggerPayload?: Record<string, unknown>;
|
|
71
|
-
}
|
|
72
|
-
export type RunHistorySummary = Omit<RunHistoryEntry, "nodes">;
|
|
73
|
-
/** Build per-node output previews (+ D33 trace stats) from a settled RunResult. */
|
|
74
|
-
export declare function buildNodeRecords(result: RunResult): Record<string, RunNodeRecord>;
|
|
75
|
-
export declare class WorkflowRunHistoryStore {
|
|
76
|
-
private readonly cwd;
|
|
77
|
-
private readonly mutationChains;
|
|
78
|
-
constructor(cwd: string);
|
|
79
|
-
/** Record a run start. Prepends a "running" entry and prunes to the bound. */
|
|
80
|
-
begin(workflowId: string, entry: Pick<RunHistoryEntry, "runId" | "triggerType" | "startedAt"> & {
|
|
81
|
-
triggerPayload?: Record<string, unknown>;
|
|
82
|
-
}): Promise<void>;
|
|
83
|
-
/** Settle a run entry (status/outputs/error). Unknown runId is a no-op (pruned entry). */
|
|
84
|
-
finish(workflowId: string, runId: string, patch: Partial<Pick<RunHistoryEntry, "status" | "finishedAt" | "durationMs" | "error" | "failedNodeId" | "nodes">>): Promise<void>;
|
|
85
|
-
/** Persist live node state so a refreshed/reconnected UI can reconstruct the active run. */
|
|
86
|
-
recordNodeStatus(workflowId: string, runId: string, nodeId: string, status: "running" | "completed" | "failed", error?: string): Promise<void>;
|
|
87
|
-
/** Append a redacted, user-facing execution stage for a running node. */
|
|
88
|
-
recordNodeActivity(workflowId: string, runId: string, nodeId: string, activity: Omit<RunNodeActivity, "ts"> & {
|
|
89
|
-
ts?: string;
|
|
90
|
-
}): Promise<void>;
|
|
91
|
-
/** Most-recent-first run summaries (no node outputs — those stay behind get()). */
|
|
92
|
-
list(workflowId: string): Promise<RunHistorySummary[]>;
|
|
93
|
-
/** Full entry incl. per-node output previews. */
|
|
94
|
-
get(workflowId: string, runId: string): Promise<RunHistoryEntry | undefined>;
|
|
95
|
-
/** Host-only view for reconstructing runs left in-flight by an abrupt process exit. */
|
|
96
|
-
recoverableRunning(workflowId: string): Promise<RecoverableWorkflowRun[]>;
|
|
97
|
-
/** Reclassify on read so historical records benefit from newer user-facing diagnostics. */
|
|
98
|
-
private withCurrentErrorInfo;
|
|
99
|
-
private waitForMutations;
|
|
100
|
-
private mutate;
|
|
101
|
-
private read;
|
|
102
|
-
private write;
|
|
103
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import type { CapabilityEntry } from "./capability-catalog.js";
|
|
2
|
-
import type { WorkflowDef } from "./node-schema.js";
|
|
3
|
-
import type { TriggerDef } from "./workflow-patch.js";
|
|
4
|
-
import type { WorkflowIntentContract } from "./workflow-intent-contract.js";
|
|
5
|
-
export type WorkflowSemanticCheck = {
|
|
6
|
-
type: "trigger_type";
|
|
7
|
-
triggerType: TriggerDef["type"];
|
|
8
|
-
} | {
|
|
9
|
-
type: "capability_present";
|
|
10
|
-
capabilityId: string;
|
|
11
|
-
minCount?: number;
|
|
12
|
-
} | {
|
|
13
|
-
type: "node_kind_count";
|
|
14
|
-
kind: string;
|
|
15
|
-
min?: number;
|
|
16
|
-
max?: number;
|
|
17
|
-
} | {
|
|
18
|
-
type: "path";
|
|
19
|
-
from: string;
|
|
20
|
-
to: string;
|
|
21
|
-
ordered?: string[];
|
|
22
|
-
} | {
|
|
23
|
-
type: "terminal_kind";
|
|
24
|
-
kind: string;
|
|
25
|
-
} | {
|
|
26
|
-
type: "param_equals";
|
|
27
|
-
node: string;
|
|
28
|
-
field: string;
|
|
29
|
-
value: unknown;
|
|
30
|
-
};
|
|
31
|
-
export interface WorkflowSemanticCriterion {
|
|
32
|
-
id: string;
|
|
33
|
-
description: string;
|
|
34
|
-
check: WorkflowSemanticCheck;
|
|
35
|
-
/** Optional evidence link; it does not turn an intent fact into a completion gate. */
|
|
36
|
-
intentFactId?: string;
|
|
37
|
-
}
|
|
38
|
-
export interface WorkflowSemanticAcceptance {
|
|
39
|
-
status: "passed" | "needs_attention";
|
|
40
|
-
passed: number;
|
|
41
|
-
total: number;
|
|
42
|
-
criteria: Array<{
|
|
43
|
-
id: string;
|
|
44
|
-
description: string;
|
|
45
|
-
status: "passed" | "failed" | "unverified";
|
|
46
|
-
evidence: string;
|
|
47
|
-
intentFactId?: string;
|
|
48
|
-
}>;
|
|
49
|
-
/** Active conversational intent facts and whether a deterministic criterion supplied evidence. */
|
|
50
|
-
intentCoverage: Array<{
|
|
51
|
-
factId: string;
|
|
52
|
-
statement: string;
|
|
53
|
-
status: "verified" | "failed" | "unverified";
|
|
54
|
-
evidence: string;
|
|
55
|
-
}>;
|
|
56
|
-
}
|
|
57
|
-
/** Flow-level semantic checks are evidence, not a save/finish hard gate. */
|
|
58
|
-
export declare function assessWorkflowSemantics(input: {
|
|
59
|
-
def: WorkflowDef;
|
|
60
|
-
trigger?: TriggerDef | null;
|
|
61
|
-
criteria?: WorkflowSemanticCriterion[];
|
|
62
|
-
catalog?: CapabilityEntry[];
|
|
63
|
-
aliases?: Record<string, string>;
|
|
64
|
-
intentContract?: WorkflowIntentContract;
|
|
65
|
-
}): WorkflowSemanticAcceptance;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Trigger validation — deterministic, fail-loud gate for workflow trigger configs (plan D7/D15).
|
|
3
|
-
*
|
|
4
|
-
* Triggers are the unattended entry points to a workflow (schedule/im-message/webhook/manual). A
|
|
5
|
-
* malformed trigger (an unparseable cron, a non-path webhook, an uncompilable IM match regex) must
|
|
6
|
-
* be rejected at the SINGLE mutation channel (`applyPatch` set_trigger), not silently persisted to
|
|
7
|
-
* fail later inside the gateway trigger layer where it is unreachable to fix. This keeps §1.5
|
|
8
|
-
* fail-loud and satisfies D15 ("schedule 须有效 cron / webhook 鉴权+限流" preconditions).
|
|
9
|
-
*
|
|
10
|
-
* Pure functions, no I/O, no side effects — the gateway still owns actual registration/auth/rate
|
|
11
|
-
* limiting; this only guarantees the stored config is structurally valid and runnable.
|
|
12
|
-
*/
|
|
13
|
-
import type { TriggerDef } from "./workflow-trigger.js";
|
|
14
|
-
/** Returns a list of human-readable errors; empty ⇒ the trigger is valid. */
|
|
15
|
-
export declare function validateTrigger(trigger: TriggerDef): string[];
|
|
16
|
-
/**
|
|
17
|
-
* Validate a 5-field (min hour dom month dow) or 6-field (sec + the same) cron expression.
|
|
18
|
-
* Each field accepts a star, a star-step (every-N), a single value, a range, a stepped range, and
|
|
19
|
-
* comma-lists of those. Month and day-of-week additionally accept their 3-letter names.
|
|
20
|
-
* Day-of-week allows 0 and 7 for Sunday.
|
|
21
|
-
*/
|
|
22
|
-
export declare function validateCron(cron: string): string[];
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Workflow audit log (IT-12, spec D38): WHO did WHAT to WHICH workflow WHEN —
|
|
3
|
-
* configuration/lifecycle changes only. Runs are deliberately NOT duplicated here:
|
|
4
|
-
* WorkflowRunHistoryStore is already the complete run audit (trigger/timing/status/per-node);
|
|
5
|
-
* a timeline UI merges both sources.
|
|
6
|
-
*
|
|
7
|
-
* Storage: append-only JSONL at `<project>/.qlogicagent/workflows/audit.jsonl` (project-level
|
|
8
|
-
* single file — the natural unit for a cross-workflow timeline). Entries are never rewritten.
|
|
9
|
-
*/
|
|
10
|
-
export interface WorkflowAuditEntry {
|
|
11
|
-
ts: string;
|
|
12
|
-
/** Owning user id (resolveActiveOwnerUserId) at the time of the action. */
|
|
13
|
-
actor: string;
|
|
14
|
-
/** e.g. created / updated / patched / activated / deactivated / published / archived /
|
|
15
|
-
* reverted / deleted / imported / duplicated / permissionGranted / publishedToHub */
|
|
16
|
-
action: string;
|
|
17
|
-
workflowId: string;
|
|
18
|
-
detail?: Record<string, unknown>;
|
|
19
|
-
}
|
|
20
|
-
export declare class WorkflowAuditStore {
|
|
21
|
-
private readonly file;
|
|
22
|
-
/** `rootDir` = the project's workflows dir (same root the WorkflowStore uses). */
|
|
23
|
-
constructor(rootDir: string);
|
|
24
|
-
/**
|
|
25
|
-
* Append one entry. Failures are LOUD on stderr but never break the business write that
|
|
26
|
-
* triggered them (an audit-log disk error must not corrupt a successful state change).
|
|
27
|
-
*/
|
|
28
|
-
append(entry: WorkflowAuditEntry): void;
|
|
29
|
-
/** Newest-first entries, optionally filtered to one workflow. Malformed lines are skipped loud. */
|
|
30
|
-
list(workflowId?: string, limit?: number): WorkflowAuditEntry[];
|
|
31
|
-
}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import type { CapabilityEntry } from "./capability-catalog.js";
|
|
2
|
-
import type { WorkflowDef } from "./node-schema.js";
|
|
3
|
-
import type { TriggerDef, WorkflowPatch } from "./workflow-patch.js";
|
|
4
|
-
export type WorkflowAuthoringOperation = {
|
|
5
|
-
op: "add";
|
|
6
|
-
key: string;
|
|
7
|
-
capabilityId: string;
|
|
8
|
-
name?: string;
|
|
9
|
-
params?: Record<string, unknown>;
|
|
10
|
-
} | {
|
|
11
|
-
op: "insert_after";
|
|
12
|
-
after: string;
|
|
13
|
-
key: string;
|
|
14
|
-
capabilityId: string;
|
|
15
|
-
name?: string;
|
|
16
|
-
params?: Record<string, unknown>;
|
|
17
|
-
} | {
|
|
18
|
-
op: "replace_capability";
|
|
19
|
-
nodeId: string;
|
|
20
|
-
capabilityId: string;
|
|
21
|
-
name?: string;
|
|
22
|
-
params?: Record<string, unknown>;
|
|
23
|
-
} | {
|
|
24
|
-
op: "update";
|
|
25
|
-
nodeId: string;
|
|
26
|
-
params: Record<string, unknown>;
|
|
27
|
-
} | {
|
|
28
|
-
op: "rename";
|
|
29
|
-
nodeId: string;
|
|
30
|
-
name: string;
|
|
31
|
-
} | {
|
|
32
|
-
op: "remove";
|
|
33
|
-
nodeId: string;
|
|
34
|
-
} | {
|
|
35
|
-
op: "connect";
|
|
36
|
-
from: string;
|
|
37
|
-
to: string;
|
|
38
|
-
fromPort?: string;
|
|
39
|
-
toPort?: string;
|
|
40
|
-
} | {
|
|
41
|
-
op: "connect_path";
|
|
42
|
-
nodes: string[];
|
|
43
|
-
} | {
|
|
44
|
-
op: "disconnect";
|
|
45
|
-
from: string;
|
|
46
|
-
to: string;
|
|
47
|
-
fromPort?: string;
|
|
48
|
-
} | {
|
|
49
|
-
op: "set_trigger";
|
|
50
|
-
trigger: TriggerDef;
|
|
51
|
-
} | {
|
|
52
|
-
op: "set_node_options";
|
|
53
|
-
nodeId: string;
|
|
54
|
-
retry?: {
|
|
55
|
-
maxTries: number;
|
|
56
|
-
backoffMs?: number;
|
|
57
|
-
} | null;
|
|
58
|
-
timeoutMs?: number | null;
|
|
59
|
-
onError?: "stop" | "continue" | "errorPort" | null;
|
|
60
|
-
};
|
|
61
|
-
export interface CompiledWorkflowOperations {
|
|
62
|
-
patch: WorkflowPatch[];
|
|
63
|
-
aliasToNodeId: Record<string, string>;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Compile the Agent's bounded authoring operations into the canonical WorkflowPatch protocol.
|
|
67
|
-
* Node kinds, capability references, parameter templates and collision-free ids are Host/catalog
|
|
68
|
-
* derived rather than freehand graph JSON.
|
|
69
|
-
*/
|
|
70
|
-
export declare function compileWorkflowOperations(input: {
|
|
71
|
-
operations: WorkflowAuthoringOperation[];
|
|
72
|
-
current: WorkflowDef;
|
|
73
|
-
catalog: CapabilityEntry[];
|
|
74
|
-
}): CompiledWorkflowOperations;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Canonical portable Workflow bundle shared by export, import, duplicate, Hub publish,
|
|
3
|
-
* and Hub apply. Bundles contain graph structure and capability references only. Runtime
|
|
4
|
-
* authentication remains owned by MCP and Provider modules and is never serialized here.
|
|
5
|
-
*/
|
|
6
|
-
import { type WorkflowDef } from "./node-schema.js";
|
|
7
|
-
import type { TriggerDef } from "./workflow-trigger.js";
|
|
8
|
-
import type { ConcurrencyPolicy, WorkflowRecord } from "./workflow-store.js";
|
|
9
|
-
import { type WorkflowTemplateSetupManifest } from "./workflow-template-setup.js";
|
|
10
|
-
export declare const WORKFLOW_BUNDLE_SCHEMA_VERSION = 3;
|
|
11
|
-
export interface CapabilityRequirement {
|
|
12
|
-
category: "agent" | "mcp" | "memory" | "channel";
|
|
13
|
-
kind: string;
|
|
14
|
-
/** Concrete capability reference, such as an Agent id or MCP plugin/tool id. */
|
|
15
|
-
ref: string;
|
|
16
|
-
/** Human-readable label shown in the apply checklist. */
|
|
17
|
-
label: string;
|
|
18
|
-
nodeIds: string[];
|
|
19
|
-
}
|
|
20
|
-
export interface WorkflowBundle {
|
|
21
|
-
schemaVersion: typeof WORKFLOW_BUNDLE_SCHEMA_VERSION;
|
|
22
|
-
name: string;
|
|
23
|
-
description?: string;
|
|
24
|
-
def: WorkflowDef;
|
|
25
|
-
trigger?: TriggerDef;
|
|
26
|
-
concurrency?: ConcurrencyPolicy;
|
|
27
|
-
requires: CapabilityRequirement[];
|
|
28
|
-
/** Optional centralized setup form. Values and credentials are never serialized. */
|
|
29
|
-
setup?: WorkflowTemplateSetupManifest;
|
|
30
|
-
meta?: {
|
|
31
|
-
author?: string;
|
|
32
|
-
tags?: string[];
|
|
33
|
-
category?: string;
|
|
34
|
-
version?: string;
|
|
35
|
-
source?: "native" | "n8n";
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
/** Derive capability requirements from canonical Agent attachments and Action nodes. */
|
|
39
|
-
export declare function deriveRequirements(def: WorkflowDef): CapabilityRequirement[];
|
|
40
|
-
/** Serialize a stored record into the canonical, credential-free bundle. */
|
|
41
|
-
export declare function toWorkflowBundle(record: WorkflowRecord): WorkflowBundle;
|
|
42
|
-
export interface ParsedBundle {
|
|
43
|
-
name: string;
|
|
44
|
-
def: WorkflowDef;
|
|
45
|
-
trigger?: TriggerDef;
|
|
46
|
-
concurrency?: ConcurrencyPolicy;
|
|
47
|
-
requires: CapabilityRequirement[];
|
|
48
|
-
setup?: WorkflowTemplateSetupManifest;
|
|
49
|
-
}
|
|
50
|
-
/** Parse and validate an incoming canonical bundle. */
|
|
51
|
-
export declare function fromWorkflowBundle(payload: unknown): ParsedBundle;
|
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Workflow Controller: reusable automation lifecycle and execution engine.
|
|
3
|
-
*
|
|
4
|
-
* Runtime's Gateway Host owns and constructs this controller with a project-scoped WorkflowStore.
|
|
5
|
-
* The qlogicagent executable publishes the engine but never constructs a Workflow owner.
|
|
6
|
-
* Concurrency (spec §B5): when a workflow is triggered while a previous run is still in-flight, the
|
|
7
|
-
* record's `concurrency` policy decides:
|
|
8
|
-
* - "skip" -> drop the new trigger (returns status "skipped")
|
|
9
|
-
* - "queue" -> run after the current one finishes. Each trigger gets a fresh runtime/cache;
|
|
10
|
-
* only pause/resume of the SAME run reuses runtime state.
|
|
11
|
-
* - "parallel" -> start a fresh independent runtime concurrently (own cache)
|
|
12
|
-
*
|
|
13
|
-
* The caller supplies a `runtimeFactory` so host capabilities (D13), the node registry, the
|
|
14
|
-
* budget/permission gate (D15), and the clock are injected per workflow — the controller never
|
|
15
|
-
* imports those subsystems (engine stays a pure executor; plan D12).
|
|
16
|
-
*
|
|
17
|
-
* fail-loud: unknown workflow ids throw; executor/gate errors propagate out of run().
|
|
18
|
-
*/
|
|
19
|
-
import type { RunCheckpoint } from "./run-checkpoint-store.js";
|
|
20
|
-
import { type RunResult, type WorkflowRuntime } from "./workflow-runtime.js";
|
|
21
|
-
import type { NodeRegistry } from "./node-registry.js";
|
|
22
|
-
import type { ExecutorHost } from "./node-schema.js";
|
|
23
|
-
import { type WorkflowTriggerKind } from "./budget-permission-gate.js";
|
|
24
|
-
import type { WorkflowDef } from "./node-schema.js";
|
|
25
|
-
import { type PatchEnvelope, type WorkflowPatch } from "./workflow-patch.js";
|
|
26
|
-
import { type RenderOptions } from "./workflow-render.js";
|
|
27
|
-
import { WorkflowStore, type ConcurrencyPolicy, type WorkflowRecord } from "./workflow-store.js";
|
|
28
|
-
import { type WorkflowTemplateSetupManifest, type WorkflowTemplateSetupState } from "./workflow-template-setup.js";
|
|
29
|
-
import { type WorkflowRunHistoryStore } from "./run-history-store.js";
|
|
30
|
-
export interface TriggerEvent {
|
|
31
|
-
type: WorkflowTriggerKind;
|
|
32
|
-
payload?: Record<string, unknown>;
|
|
33
|
-
}
|
|
34
|
-
export interface WorkflowRunStarted {
|
|
35
|
-
workflowId: string;
|
|
36
|
-
runId: string;
|
|
37
|
-
triggerType: WorkflowTriggerKind;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Per-run context handed to the RuntimeFactory: the trigger KIND (so the factory can wire the D15
|
|
41
|
-
* permission gate — unattended kinds are restricted) plus its payload (exposed to expressions).
|
|
42
|
-
*/
|
|
43
|
-
export interface RunContext {
|
|
44
|
-
/** The workflow record id (so the runtime factory can tag per-node status notifications). */
|
|
45
|
-
workflowId: string;
|
|
46
|
-
/** Stable id for this run, used by history, checkpointing, pause/resume, and cancellation. */
|
|
47
|
-
runId: string;
|
|
48
|
-
type: WorkflowTriggerKind;
|
|
49
|
-
payload?: Record<string, unknown>;
|
|
50
|
-
/** Cancellation propagated to the runtime and host-backed node executors. */
|
|
51
|
-
signal?: AbortSignal;
|
|
52
|
-
/** The record's unattended capability grant at run start (D30; feeds the permission gate). */
|
|
53
|
-
permissionScope?: WorkflowRecord["permissionScope"];
|
|
54
|
-
/**
|
|
55
|
-
* R5 媒体工作室(D44):跨 run 内容寻址缓存 —— 本 run 从工作流级共享 checkpoint seed,
|
|
56
|
-
* 完成后保留(不清),下次"改参数只重跑下游"(ComfyUI 语义:未变节点命中缓存被跳过)。
|
|
57
|
-
* 默认关:自动化的副作用节点(发消息/HTTP POST)绝不能因"没变"被静默跳过;
|
|
58
|
-
* 工作室画布的"运行"显式带上(纯数据流面,跳过未变工序正是期望)。
|
|
59
|
-
*/
|
|
60
|
-
reuseCache?: boolean;
|
|
61
|
-
}
|
|
62
|
-
/** Per-node lifecycle status surfaced for live canvas coloring (not durable; fire-and-forget). */
|
|
63
|
-
export type NodeRunStatus = "running" | "completed" | "failed";
|
|
64
|
-
/** Builds a runtime for a workflow run. `ctx` carries the run's trigger kind + payload (spec §B3). */
|
|
65
|
-
export type RuntimeFactory = (def: WorkflowDef, ctx: RunContext) => WorkflowRuntime;
|
|
66
|
-
export interface RunOutcome {
|
|
67
|
-
workflowId: string;
|
|
68
|
-
status: "completed" | "failed" | "paused" | "skipped" | "canceled";
|
|
69
|
-
/** Absent when status === "skipped" (a busy run under the "skip" policy). */
|
|
70
|
-
result?: RunResult;
|
|
71
|
-
/** Durable run-history id (present when a run-history store is wired). */
|
|
72
|
-
runId?: string;
|
|
73
|
-
}
|
|
74
|
-
export interface CreateInput {
|
|
75
|
-
id: string;
|
|
76
|
-
name: string;
|
|
77
|
-
def: WorkflowDef;
|
|
78
|
-
concurrency?: ConcurrencyPolicy;
|
|
79
|
-
active?: boolean;
|
|
80
|
-
/** Owning user (D38); the handler stamps resolveActiveOwnerUserId(). */
|
|
81
|
-
owner?: string;
|
|
82
|
-
setup?: WorkflowTemplateSetupManifest;
|
|
83
|
-
setupState?: WorkflowTemplateSetupState;
|
|
84
|
-
}
|
|
85
|
-
/** Result of a `patch()` call (spec §C `WorkflowToolResult`). */
|
|
86
|
-
export type PatchOutcome = {
|
|
87
|
-
ok: true;
|
|
88
|
-
rev: number;
|
|
89
|
-
applied: WorkflowPatch[];
|
|
90
|
-
} | {
|
|
91
|
-
ok: false;
|
|
92
|
-
conflict: {
|
|
93
|
-
latestRev: number;
|
|
94
|
-
};
|
|
95
|
-
};
|
|
96
|
-
export declare class WorkflowController {
|
|
97
|
-
private readonly store;
|
|
98
|
-
private readonly runtimeFactory;
|
|
99
|
-
/** Optional durable run-history recorder. Wired here (not the handler) so every
|
|
100
|
-
* trigger path — manual RPC, cron scheduler, IM, webhook — is captured alike. */
|
|
101
|
-
private readonly runHistory?;
|
|
102
|
-
private readonly slots;
|
|
103
|
-
private readonly activeRuns;
|
|
104
|
-
private readonly activeRunIdsByWorkflow;
|
|
105
|
-
private readonly suppressedHistoryRunIds;
|
|
106
|
-
constructor(store: WorkflowStore, runtimeFactory: RuntimeFactory,
|
|
107
|
-
/** Optional durable run-history recorder. Wired here (not the handler) so every
|
|
108
|
-
* trigger path — manual RPC, cron scheduler, IM, webhook — is captured alike. */
|
|
109
|
-
runHistory?: WorkflowRunHistoryStore | undefined);
|
|
110
|
-
create(input: CreateInput): Promise<WorkflowRecord>;
|
|
111
|
-
update(id: string, patch: Partial<Pick<WorkflowRecord, "name" | "def" | "concurrency" | "active" | "permissionScope" | "setup" | "setupState">>): Promise<WorkflowRecord>;
|
|
112
|
-
/** Apply all template answers to their node/trigger bindings in one CAS-protected revision. */
|
|
113
|
-
configureTemplate(id: string, input: {
|
|
114
|
-
baseRev: number;
|
|
115
|
-
values: Record<string, unknown>;
|
|
116
|
-
}): Promise<PatchOutcome & {
|
|
117
|
-
missingRequired?: string[];
|
|
118
|
-
}>;
|
|
119
|
-
setActive(id: string, active: boolean): Promise<WorkflowRecord>;
|
|
120
|
-
/**
|
|
121
|
-
* Publish (D31): snapshot the current draft (`def`) as the version triggers execute.
|
|
122
|
-
* Editing the draft afterwards never touches the running version until the next publish.
|
|
123
|
-
*/
|
|
124
|
-
publish(id: string): Promise<WorkflowRecord>;
|
|
125
|
-
/** Archive (D31): keep the data, kill the lifecycle (deactivates; activation/publish refuse). */
|
|
126
|
-
archive(id: string, archived: boolean): Promise<WorkflowRecord>;
|
|
127
|
-
/**
|
|
128
|
-
* Revert a workflow to a stored revision snapshot (undo 基座). Git-revert semantics:
|
|
129
|
-
* the snapshot's def/name/trigger are re-applied as a NEW revision (rev bumps), so
|
|
130
|
-
* history stays forward-only and optimistic-concurrency baseRev checks keep working.
|
|
131
|
-
* fail-loud: unknown id or pruned/absent revision throws.
|
|
132
|
-
*/
|
|
133
|
-
revertTo(id: string, rev: number): Promise<WorkflowRecord>;
|
|
134
|
-
/**
|
|
135
|
-
* Import an n8n workflow JSON into the single store. Native mappings stay native; compatible
|
|
136
|
-
* installed ecosystem nodes are resolved by the Host, while unsupported nodes remain explicit
|
|
137
|
-
* fail-loud placeholders. Every graph still passes the same canonical write validation.
|
|
138
|
-
*/
|
|
139
|
-
importN8n(id: string, json: string | unknown, opts?: {
|
|
140
|
-
concurrency?: ConcurrencyPolicy;
|
|
141
|
-
owner?: string;
|
|
142
|
-
}): Promise<{
|
|
143
|
-
record: WorkflowRecord;
|
|
144
|
-
report: import("./n8n-import.js").N8nConversionReport;
|
|
145
|
-
}>;
|
|
146
|
-
/** Load a single record or throw (fail-loud lookup; used by the scheduler to re-read triggers). */
|
|
147
|
-
get(id: string): Promise<WorkflowRecord>;
|
|
148
|
-
/**
|
|
149
|
-
* Render a workflow as compact planning context (spec §B / §A `get`). Fail-loud on unknown id.
|
|
150
|
-
* Runtime Host supplies the authoritative record; stateless planning may use this rendering to
|
|
151
|
-
* propose a WorkflowPatch against the shown `rev`.
|
|
152
|
-
*/
|
|
153
|
-
describe(id: string, opts?: RenderOptions): Promise<string>;
|
|
154
|
-
/**
|
|
155
|
-
* Apply a WorkflowPatch — the single mutation channel for agent edits and canvas hand-edits
|
|
156
|
-
* (spec §C). Loads the latest record, applies the patch transactionally through the engine
|
|
157
|
-
* (scope enforcement + validateDag), bumps `rev`, and persists. Optimistic concurrency (LWW):
|
|
158
|
-
* - baseRev omitted or == current rev → apply against the latest.
|
|
159
|
-
* - baseRev < current rev (someone edited in between) → replay onto the latest; if every op
|
|
160
|
-
* still references valid nodes/edges it applies (last-write-wins), otherwise a conflict is
|
|
161
|
-
* returned so the caller can redo against the latest rendering.
|
|
162
|
-
* A rejected patch (illegal op / scope violation / invalid graph) throws PatchError unchanged.
|
|
163
|
-
*/
|
|
164
|
-
patch(id: string, env: PatchEnvelope): Promise<PatchOutcome>;
|
|
165
|
-
/** Trigger a run, honoring the workflow's concurrency policy (spec §B5). */
|
|
166
|
-
run(id: string, trigger?: TriggerEvent, opts?: {
|
|
167
|
-
recordHistory?: boolean;
|
|
168
|
-
reuseCache?: boolean;
|
|
169
|
-
/** Host-only crash recovery: preserve the original run identity and history row. */
|
|
170
|
-
recoverRunId?: string;
|
|
171
|
-
onStarted?: (run: WorkflowRunStarted) => void | Promise<void>;
|
|
172
|
-
}): Promise<RunOutcome>;
|
|
173
|
-
/**
|
|
174
|
-
* Wrap a run with durable history recording (when wired). The running checkpoint is the
|
|
175
|
-
* publication barrier for lifecycle observers, and terminal history is fail-loud.
|
|
176
|
-
*/
|
|
177
|
-
private recordRun;
|
|
178
|
-
/** Cooperatively pause the in-flight run; it suspends before the next node (cache retained). */
|
|
179
|
-
pause(id: string, opts?: {
|
|
180
|
-
runId?: string;
|
|
181
|
-
}): void;
|
|
182
|
-
/** Resume a paused workflow: re-run the same runtime so cached nodes hit and only the
|
|
183
|
-
* unfinished remainder executes. When the run paused on an exhausted budget, pass `extraBudget`
|
|
184
|
-
* to raise the gate's ceiling first (D15 "抬预算后 resume"); otherwise the first not-yet-run
|
|
185
|
-
* node would immediately re-trip the same budget and pause again. */
|
|
186
|
-
resume(id: string, opts?: {
|
|
187
|
-
runId?: string;
|
|
188
|
-
extraBudget?: {
|
|
189
|
-
executions?: number;
|
|
190
|
-
durationMs?: number;
|
|
191
|
-
};
|
|
192
|
-
}): Promise<RunOutcome>;
|
|
193
|
-
cancelRun(id: string, opts?: {
|
|
194
|
-
runId?: string;
|
|
195
|
-
reason?: string;
|
|
196
|
-
}): Promise<RunOutcome>;
|
|
197
|
-
delete(id: string): Promise<void>;
|
|
198
|
-
/** Active workflows whose triggers the gateway should re-register after restart (spec §B4). */
|
|
199
|
-
listActive(): Promise<WorkflowRecord[]>;
|
|
200
|
-
private slotFor;
|
|
201
|
-
private registerActiveRun;
|
|
202
|
-
private unregisterActiveRun;
|
|
203
|
-
private requireActiveRun;
|
|
204
|
-
private finishRunHistory;
|
|
205
|
-
/**
|
|
206
|
-
* Track a fresh or queued run on the slot. `chained` runs wait for the slot's tail (the prior
|
|
207
|
-
* run) before starting → strict serialization for the "queue" policy. `pending` is incremented
|
|
208
|
-
* synchronously so concurrent triggers observe the slot as busy across the run→queue handoff.
|
|
209
|
-
*/
|
|
210
|
-
private track;
|
|
211
|
-
private startParallel;
|
|
212
|
-
private startTrackedRuntime;
|
|
213
|
-
}
|
|
214
|
-
/**
|
|
215
|
-
* The production RuntimeFactory: builds a WorkflowRuntime wired with the D15 BudgetPermissionGate
|
|
216
|
-
* derived from the run's trigger kind. This is the consumer that turns the gate from a bare
|
|
217
|
-
* interface into an enforced guarantee — every run the controller starts through this factory has
|
|
218
|
-
* its per-run budget and (for unattended triggers) its permission allowlist checked before each
|
|
219
|
-
* node. Hosts supply the registry/host capabilities and the budget ceilings; the gate wiring is
|
|
220
|
-
* fixed so no run can accidentally execute ungated.
|
|
221
|
-
*/
|
|
222
|
-
export declare function defaultRuntimeFactory(opts: {
|
|
223
|
-
registry?: NodeRegistry;
|
|
224
|
-
host?: ExecutorHost;
|
|
225
|
-
/** Per-run budget ceilings (D15 "每轮过 budget"). maxNodeExecutions is required and must be > 0. */
|
|
226
|
-
budget: {
|
|
227
|
-
maxNodeExecutions: number;
|
|
228
|
-
maxDurationMs?: number;
|
|
229
|
-
};
|
|
230
|
-
/** Sensitive kinds an unattended run may execute (D15 permission gate). */
|
|
231
|
-
allowUnattendedKinds?: readonly string[];
|
|
232
|
-
/** Optional durable cache for crash/restart replay, keyed by workflow id + run id. */
|
|
233
|
-
checkpoint?: (workflowId: string, runId: string) => RunCheckpoint | undefined;
|
|
234
|
-
now?: () => Date;
|
|
235
|
-
/** Per-node lifecycle for live canvas coloring; workflowId comes from the run ctx. */
|
|
236
|
-
emitNodeStatus?: (workflowId: string, nodeId: string, status: NodeRunStatus, error?: string) => void;
|
|
237
|
-
}): RuntimeFactory;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import type { CapabilityEntry } from "./capability-catalog.js";
|
|
2
|
-
import type { WorkflowDef, WorkflowNodeDef } from "./node-schema.js";
|
|
3
|
-
import type { TriggerDef } from "./workflow-patch.js";
|
|
4
|
-
export interface WorkflowEditContextCapsule {
|
|
5
|
-
workflowId: string;
|
|
6
|
-
trigger?: TriggerDef | null;
|
|
7
|
-
selectedNodeIds: string[];
|
|
8
|
-
nodes: WorkflowNodeDef[];
|
|
9
|
-
edges: WorkflowDef["edges"];
|
|
10
|
-
omittedNodeCount: number;
|
|
11
|
-
lineage: Record<string, {
|
|
12
|
-
upstream: Array<{
|
|
13
|
-
nodeId: string;
|
|
14
|
-
name?: string;
|
|
15
|
-
fields: string[];
|
|
16
|
-
expressionExamples: string[];
|
|
17
|
-
}>;
|
|
18
|
-
}>;
|
|
19
|
-
latestRun?: {
|
|
20
|
-
status: string;
|
|
21
|
-
failedNodeId?: string;
|
|
22
|
-
error?: string;
|
|
23
|
-
nodeEvidence: Array<{
|
|
24
|
-
nodeId: string;
|
|
25
|
-
preview?: string;
|
|
26
|
-
error?: string;
|
|
27
|
-
}>;
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
export interface WorkflowRunEvidence {
|
|
31
|
-
status: string;
|
|
32
|
-
failedNodeId?: string;
|
|
33
|
-
error?: string;
|
|
34
|
-
nodes?: Record<string, {
|
|
35
|
-
preview?: string;
|
|
36
|
-
error?: string;
|
|
37
|
-
}>;
|
|
38
|
-
}
|
|
39
|
-
export declare function buildWorkflowEditContextCapsule(input: {
|
|
40
|
-
def: WorkflowDef;
|
|
41
|
-
trigger?: TriggerDef | null;
|
|
42
|
-
scope?: string[];
|
|
43
|
-
catalog?: CapabilityEntry[];
|
|
44
|
-
latestRun?: WorkflowRunEvidence;
|
|
45
|
-
maxNodes?: number;
|
|
46
|
-
}): WorkflowEditContextCapsule;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Workflow run-error classification (spec R6 / D49 / AI-5).
|
|
3
|
-
*
|
|
4
|
-
* Turns a raw thrown Error message into a human-readable, classified WorkflowError so the canvas can
|
|
5
|
-
* show 人话 (never a stack) + the right next-step buttons (0 死端). Pure & deterministic — unit
|
|
6
|
-
* tested. The executors throw plain Error(message); this maps those messages to a class + 中文说明.
|
|
7
|
-
*/
|
|
8
|
-
export type WorkflowErrorClass = "user" | "capability" | "network" | "system";
|
|
9
|
-
/** Next-step buttons the canvas offers for an error (0 死端 — every failure has a way forward). */
|
|
10
|
-
export type WorkflowErrorAction = "ai_fix" | "rerun_node" | "rerun_all" | "swap_capability";
|
|
11
|
-
export interface WorkflowError {
|
|
12
|
-
class: WorkflowErrorClass;
|
|
13
|
-
/** Plain-language Chinese explanation (NO stack trace). */
|
|
14
|
-
message: string;
|
|
15
|
-
/** What to do about it, in one line. */
|
|
16
|
-
hint?: string;
|
|
17
|
-
/** Ordered next-step actions for the UI (first = primary). */
|
|
18
|
-
actions: WorkflowErrorAction[];
|
|
19
|
-
/** Truncated raw message, for the advanced/debug view only. */
|
|
20
|
-
detail?: string;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Classify a node failure. `raw` is the thrown error's message; `opts.nodeKind` refines wording.
|
|
24
|
-
* Order matters: credential/auth and capability checks run before the generic "param" check.
|
|
25
|
-
*/
|
|
26
|
-
export declare function classifyWorkflowError(raw: string, opts?: {
|
|
27
|
-
nodeKind?: string;
|
|
28
|
-
}): WorkflowError;
|