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,56 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Conversation-owned Workflow intent ledger.
|
|
3
|
-
*
|
|
4
|
-
* Deliberately not an acceptance gate: it has no ready/complete/pass field and is never consulted
|
|
5
|
-
* to decide whether a proposal may be saved or whether an Agent turn may finish. It preserves
|
|
6
|
-
* exact user observations plus a revisable interpretation so incomplete conversations work.
|
|
7
|
-
*/
|
|
8
|
-
export interface WorkflowIntentObservation {
|
|
9
|
-
id: string;
|
|
10
|
-
sequence: number;
|
|
11
|
-
text: string;
|
|
12
|
-
}
|
|
13
|
-
export interface WorkflowIntentFact {
|
|
14
|
-
id: string;
|
|
15
|
-
statement: string;
|
|
16
|
-
confidence: "explicit" | "inferred";
|
|
17
|
-
sourceObservationIds: string[];
|
|
18
|
-
status: "active" | "superseded";
|
|
19
|
-
}
|
|
20
|
-
export interface WorkflowIntentQuestion {
|
|
21
|
-
id: string;
|
|
22
|
-
question: string;
|
|
23
|
-
sourceObservationIds: string[];
|
|
24
|
-
status: "open" | "resolved";
|
|
25
|
-
}
|
|
26
|
-
export interface WorkflowIntentContract {
|
|
27
|
-
revision: number;
|
|
28
|
-
observations: WorkflowIntentObservation[];
|
|
29
|
-
facts: WorkflowIntentFact[];
|
|
30
|
-
openQuestions: WorkflowIntentQuestion[];
|
|
31
|
-
diagnostics: string[];
|
|
32
|
-
}
|
|
33
|
-
export interface WorkflowIntentDelta {
|
|
34
|
-
upsertFacts?: Array<{
|
|
35
|
-
id: string;
|
|
36
|
-
statement: string;
|
|
37
|
-
confidence: "explicit" | "inferred";
|
|
38
|
-
sourceObservationIds: string[];
|
|
39
|
-
}>;
|
|
40
|
-
supersedeFactIds?: string[];
|
|
41
|
-
upsertQuestions?: Array<{
|
|
42
|
-
id: string;
|
|
43
|
-
question: string;
|
|
44
|
-
sourceObservationIds: string[];
|
|
45
|
-
}>;
|
|
46
|
-
resolveQuestionIds?: string[];
|
|
47
|
-
}
|
|
48
|
-
export declare function evolveWorkflowIntentContract(input: {
|
|
49
|
-
previous: WorkflowIntentContract | null | undefined;
|
|
50
|
-
newTurns: Array<{
|
|
51
|
-
sequence: number;
|
|
52
|
-
role: "user" | "assistant";
|
|
53
|
-
content: string;
|
|
54
|
-
}>;
|
|
55
|
-
delta?: WorkflowIntentDelta | null;
|
|
56
|
-
}): WorkflowIntentContract;
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WorkflowPatch — the single mutation channel for workflow editing.
|
|
3
|
-
*
|
|
4
|
-
* One change protocol for BOTH agent edits and canvas hand-edits: every edit is a list of
|
|
5
|
-
* `WorkflowPatch` ops applied transactionally to a workflow's graph. This module is the
|
|
6
|
-
* deterministic ENGINE half (no gateway, no UI, no LLM):
|
|
7
|
-
* - applies the 8 ops to a WorkflowDef (+ workflow meta/trigger),
|
|
8
|
-
* - enforces scoped-edit boundaries (框选批注: ops may only touch the selection subgraph,
|
|
9
|
-
* D19) at the PROTOCOL level — not a prompt soft-constraint,
|
|
10
|
-
* - validates the resulting graph through DagScheduler v2's invariants (acyclic minus
|
|
11
|
-
* loopBack, edge integrity, loop maxIterations) — the spec's "patch 落库前过 validateDag".
|
|
12
|
-
*
|
|
13
|
-
* Transactional + fail-loud (§1.5): a patch is all-or-nothing. The candidate is built on a deep
|
|
14
|
-
* clone; if any op is illegal, references a missing node/edge, breaks scope, or yields an invalid
|
|
15
|
-
* graph, the WHOLE patch is rejected via `PatchError` (carrying `errors` for agent self-correction)
|
|
16
|
-
* and the input is never mutated. No partial application, no silent drop.
|
|
17
|
-
*/
|
|
18
|
-
import type { WorkflowDef, WorkflowNodeDef, DataEdge } from "./node-schema.js";
|
|
19
|
-
import type { TriggerDef } from "./workflow-trigger.js";
|
|
20
|
-
export type { TriggerDef } from "./workflow-trigger.js";
|
|
21
|
-
/** A workflow trigger (spec §B / plan D7). Registered by the gateway trigger layer. */
|
|
22
|
-
/** Workflow-global fields a patch can set (kept separate from the node graph). */
|
|
23
|
-
export interface WorkflowMeta {
|
|
24
|
-
name?: string;
|
|
25
|
-
active?: boolean;
|
|
26
|
-
trigger?: TriggerDef | null;
|
|
27
|
-
}
|
|
28
|
-
/** The full mutable target of a patch: the node graph plus workflow-global meta. */
|
|
29
|
-
export interface PatchTarget {
|
|
30
|
-
def: WorkflowDef;
|
|
31
|
-
meta: WorkflowMeta;
|
|
32
|
-
}
|
|
33
|
-
export type WorkflowPatch = {
|
|
34
|
-
op: "add_node";
|
|
35
|
-
node: WorkflowNodeDef;
|
|
36
|
-
} | {
|
|
37
|
-
op: "remove_node";
|
|
38
|
-
nodeId: string;
|
|
39
|
-
} | {
|
|
40
|
-
op: "update_params";
|
|
41
|
-
nodeId: string;
|
|
42
|
-
params: Record<string, unknown>;
|
|
43
|
-
} | {
|
|
44
|
-
op: "rename_node";
|
|
45
|
-
nodeId: string;
|
|
46
|
-
name: string;
|
|
47
|
-
} | {
|
|
48
|
-
op: "add_edge";
|
|
49
|
-
edge: DataEdge;
|
|
50
|
-
} | {
|
|
51
|
-
op: "remove_edge";
|
|
52
|
-
edge: {
|
|
53
|
-
from: string;
|
|
54
|
-
to: string;
|
|
55
|
-
fromPort?: string;
|
|
56
|
-
};
|
|
57
|
-
} | {
|
|
58
|
-
op: "set_trigger";
|
|
59
|
-
trigger: TriggerDef | null;
|
|
60
|
-
} | {
|
|
61
|
-
op: "set_meta";
|
|
62
|
-
meta: {
|
|
63
|
-
name?: string;
|
|
64
|
-
active?: boolean;
|
|
65
|
-
};
|
|
66
|
-
} | {
|
|
67
|
-
op: "set_node_options";
|
|
68
|
-
nodeId: string;
|
|
69
|
-
retry?: {
|
|
70
|
-
maxTries: number;
|
|
71
|
-
backoffMs?: number;
|
|
72
|
-
} | null;
|
|
73
|
-
timeoutMs?: number | null;
|
|
74
|
-
onError?: "stop" | "continue" | "errorPort" | null;
|
|
75
|
-
} | {
|
|
76
|
-
op: "set_node_ui";
|
|
77
|
-
positions: Record<string, {
|
|
78
|
-
x: number;
|
|
79
|
-
y: number;
|
|
80
|
-
} | null>;
|
|
81
|
-
};
|
|
82
|
-
/** A patch + concurrency/scope envelope (spec §C). `scope` present ⇒ scoped (框选) edit. */
|
|
83
|
-
export interface PatchEnvelope {
|
|
84
|
-
patch: WorkflowPatch[];
|
|
85
|
-
/** Optimistic-concurrency base revision (LWW handled by the store layer). */
|
|
86
|
-
baseRev?: number;
|
|
87
|
-
/** Selected node ids for a scoped edit; given ⇒ ops may only touch the selection subgraph. */
|
|
88
|
-
scope?: string[];
|
|
89
|
-
}
|
|
90
|
-
export interface ApplyResult {
|
|
91
|
-
target: PatchTarget;
|
|
92
|
-
applied: WorkflowPatch[];
|
|
93
|
-
/** Non-blocking facts about pre-existing defects outside a scoped edit. */
|
|
94
|
-
diagnostics: WorkflowPatchDiagnostic[];
|
|
95
|
-
}
|
|
96
|
-
export interface WorkflowPatchDiagnostic {
|
|
97
|
-
classification: "preexisting";
|
|
98
|
-
nodeId: string;
|
|
99
|
-
message: string;
|
|
100
|
-
}
|
|
101
|
-
/** Thrown when a patch is rejected. `errors` is the ordered list of reasons (for self-correction). */
|
|
102
|
-
export declare class PatchError extends Error {
|
|
103
|
-
readonly errors: string[];
|
|
104
|
-
constructor(errors: string[]);
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Apply a patch transactionally. Returns a NEW PatchTarget (input untouched) or throws PatchError.
|
|
108
|
-
* Scope enforcement (when `scope` is set, spec §C):
|
|
109
|
-
* - update_params / rename_node / remove_node: the node MUST be in scope.
|
|
110
|
-
* - add_node: allowed; the new node joins the in-scope set for subsequent ops in this patch.
|
|
111
|
-
* - add_edge / remove_edge: at least ONE endpoint must be in scope (selection-boundary edges).
|
|
112
|
-
* - set_trigger / set_meta: workflow-global ⇒ rejected under a scoped edit.
|
|
113
|
-
*/
|
|
114
|
-
export declare function applyPatch(target: PatchTarget, env: PatchEnvelope): ApplyResult;
|
|
115
|
-
/**
|
|
116
|
-
* Validate a standalone WorkflowDef against DagScheduler v2's invariants (acyclic minus loopBack,
|
|
117
|
-
* edge integrity, duplicate ids, loop maxIterations + hard cap). Returns a list of human-readable
|
|
118
|
-
* errors; empty ⇒ valid. This is the SAME graph gate `applyPatch` runs, exported so every
|
|
119
|
-
* persistence path (controller create/update) enforces identical invariants — single-track, no
|
|
120
|
-
* write path may bypass validation (D17 "一个 store").
|
|
121
|
-
*/
|
|
122
|
-
export declare function validateWorkflowDef(def: WorkflowDef): string[];
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Compact workflow renderer — the "workflow-as-context" feeder.
|
|
3
|
-
*
|
|
4
|
-
* Every page-chat user turn injects the LATEST workflow as compact, deterministic text (NOT raw
|
|
5
|
-
* JSON: cheaper tokens, never stale, stable node ids the agent references back in a WorkflowPatch).
|
|
6
|
-
* This module is the deterministic ENGINE half of that loop — the agent reads this rendering and
|
|
7
|
-
* emits a `WorkflowPatch` (workflow-patch.ts) against the shown `rev`. Pure function: no gateway,
|
|
8
|
-
* no LLM, no I/O.
|
|
9
|
-
*
|
|
10
|
-
* Determinism (§1.5): node order follows the def's node array (stable, persisted order); param
|
|
11
|
-
* keys are sorted; expressions (`{{ }}`) render verbatim so the agent can copy them into bindings.
|
|
12
|
-
* Large graphs truncate with an explicit hint to fetch the full definition from the Gateway Host.
|
|
13
|
-
*/
|
|
14
|
-
import type { WorkflowDef } from "./node-schema.js";
|
|
15
|
-
import type { TriggerDef } from "./workflow-patch.js";
|
|
16
|
-
/** The minimal shape needed to render (WorkflowRecord satisfies it). */
|
|
17
|
-
export interface RenderableWorkflow {
|
|
18
|
-
name: string;
|
|
19
|
-
rev: number;
|
|
20
|
-
active: boolean;
|
|
21
|
-
trigger?: TriggerDef | null;
|
|
22
|
-
def: WorkflowDef;
|
|
23
|
-
}
|
|
24
|
-
export interface RenderOptions {
|
|
25
|
-
/** Max nodes to list before truncating (default 50). */
|
|
26
|
-
maxNodes?: number;
|
|
27
|
-
/** Max rendered length of a single param value before eliding (default 60). */
|
|
28
|
-
maxValueLen?: number;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Render a workflow as compact agent-context text. Shape (spec §B):
|
|
32
|
-
*
|
|
33
|
-
* Workflow "晨报" (rev 7, trigger: schedule "0 9 * * *", active)
|
|
34
|
-
* nodes:
|
|
35
|
-
* n1 [agent] prompt="抓取今日新闻要点" out: default
|
|
36
|
-
* n3 [if] cond={{ $json.count > 0 }} out: true,false
|
|
37
|
-
* edges:
|
|
38
|
-
* n1.default→n2.default ; n3.true→n4.default
|
|
39
|
-
*/
|
|
40
|
-
export declare function renderWorkflow(wf: RenderableWorkflow, opts?: RenderOptions): string;
|
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WorkflowRuntime — the automation data-routing driver (M2; plan §M2, spec §A1/§A5).
|
|
3
|
-
*
|
|
4
|
-
* Responsibilities (control/data separation, spec §A1):
|
|
5
|
-
* - DagScheduler v2 owns CONTROL (ready/skip/loop/ports). The runtime owns DATA:
|
|
6
|
-
* for each ready node it collects upstream outputs along data edges (fromPort→toPort),
|
|
7
|
-
* resolves param expressions, invokes the registered NodeExecutor, stores outputs, and
|
|
8
|
-
* reports completion + firedPorts back to the scheduler.
|
|
9
|
-
* - run-from-node + output cache (spec §A5): cache key = hash(kind + resolved params +
|
|
10
|
-
* input signature + runIndex). A clean node hits cache (executor skipped); a changed node
|
|
11
|
-
* and its dirty downstream recompute. This is content-addressed, so successive run() calls
|
|
12
|
-
* after a param change recompute only the dirty subgraph.
|
|
13
|
-
* - loop control is runtime-owned (DagScheduler.decideLoop), not a user executor.
|
|
14
|
-
* - every node passes an injectable budget/permission gate before executing (plan D15).
|
|
15
|
-
*
|
|
16
|
-
* fail-loud: unknown kinds, gate rejections, and executor errors all throw and halt the run.
|
|
17
|
-
*/
|
|
18
|
-
import { DagScheduler } from "../dag-scheduler.js";
|
|
19
|
-
import { type PortMap } from "./data-item.js";
|
|
20
|
-
import { NodeRegistry } from "./node-registry.js";
|
|
21
|
-
import type { RunCheckpoint } from "./run-checkpoint-store.js";
|
|
22
|
-
import type { WorkflowDef, ExecutorHost } from "./node-schema.js";
|
|
23
|
-
/** Gate invoked before each node executes (budget / permission). Throw to halt the run. */
|
|
24
|
-
export interface ExecutionGate {
|
|
25
|
-
check(nodeId: string, kind: string): void;
|
|
26
|
-
/**
|
|
27
|
-
* Optionally raise the gate's remaining allowance so a budget-paused run can resume (D15
|
|
28
|
-
* "抬预算后 resume"). Gates without a budget may omit this. Implementations are fail-loud on
|
|
29
|
-
* non-positive deltas.
|
|
30
|
-
*/
|
|
31
|
-
extend?(delta: {
|
|
32
|
-
executions?: number;
|
|
33
|
-
durationMs?: number;
|
|
34
|
-
}): void;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Thrown by a gate (or `pause()`) to suspend the run gracefully. Unlike a plain error this is
|
|
38
|
-
* not a failure: completed work stays cached, and a later `run()` on the same instance resumes
|
|
39
|
-
* (cached nodes hit, only the not-yet-run remainder executes).
|
|
40
|
-
*/
|
|
41
|
-
export declare class WorkflowPauseSignal extends Error {
|
|
42
|
-
readonly atNodeId?: string | undefined;
|
|
43
|
-
constructor(atNodeId?: string | undefined);
|
|
44
|
-
}
|
|
45
|
-
/** Controlled cancellation requested by the controller/delete path. */
|
|
46
|
-
export declare class WorkflowRunCanceled extends Error {
|
|
47
|
-
constructor(message?: string);
|
|
48
|
-
}
|
|
49
|
-
/** Per-node execution stats for the run trace (D33, IT-9). */
|
|
50
|
-
export interface NodeRunStats {
|
|
51
|
-
/** Execution order (1-based; cache hits count too — they advance the dag). */
|
|
52
|
-
seq: number;
|
|
53
|
-
startedAt: string;
|
|
54
|
-
finishedAt: string;
|
|
55
|
-
durationMs: number;
|
|
56
|
-
/** Executor attempts actually made (≥1; >1 means retries happened). */
|
|
57
|
-
attempts: number;
|
|
58
|
-
/** True when the content-addressed cache satisfied this node (no executor invocation). */
|
|
59
|
-
cacheHit: boolean;
|
|
60
|
-
/** Final per-node disposition (errorPort/continue keep the run alive but mark failed). */
|
|
61
|
-
status: "completed" | "failed";
|
|
62
|
-
/** Engine-imposed limit surfaced on this node (e.g. a loop forced out at its iteration cap) —
|
|
63
|
-
* rendered into the run history so caps are visible in the run record, never silent. */
|
|
64
|
-
warning?: string;
|
|
65
|
-
}
|
|
66
|
-
export interface RunResult {
|
|
67
|
-
status: "completed" | "failed" | "paused";
|
|
68
|
-
/** nodeId → its output PortMap. */
|
|
69
|
-
outputs: Record<string, PortMap>;
|
|
70
|
-
/** nodeIds whose executor actually ran in this run (cache misses). */
|
|
71
|
-
executed: Set<string>;
|
|
72
|
-
progress: ReturnType<DagScheduler["getProgress"]>;
|
|
73
|
-
/** Set when status === "paused": the node the run suspended at. */
|
|
74
|
-
pausedAt?: string;
|
|
75
|
-
/** Ordered per-node trace (D33): timing, attempts, cache hits, disposition. */
|
|
76
|
-
nodeStats: Record<string, NodeRunStats>;
|
|
77
|
-
}
|
|
78
|
-
export interface WorkflowRuntimeOptions {
|
|
79
|
-
registry?: NodeRegistry;
|
|
80
|
-
gate?: ExecutionGate;
|
|
81
|
-
now?: () => Date;
|
|
82
|
-
trigger?: Record<string, unknown>;
|
|
83
|
-
/** This run's trigger KIND (manual/schedule/…) — exposed on ExecutorContext for IT-7b audits. */
|
|
84
|
-
triggerKind?: string;
|
|
85
|
-
/** Durable run identity exposed to Host-backed node executors. */
|
|
86
|
-
runId?: string;
|
|
87
|
-
log?: {
|
|
88
|
-
info(m: string): void;
|
|
89
|
-
warn(m: string): void;
|
|
90
|
-
};
|
|
91
|
-
/** Host capabilities for host-backed kinds (agent/tool/http/mcp/channel), D13. */
|
|
92
|
-
host?: ExecutorHost;
|
|
93
|
-
/** Cancellation propagated to host calls. */
|
|
94
|
-
signal?: AbortSignal;
|
|
95
|
-
/** Durable run checkpoint for crash-restart recovery (plan §M3). */
|
|
96
|
-
checkpoint?: RunCheckpoint;
|
|
97
|
-
/**
|
|
98
|
-
* R5 跨 run 缓存(reuseCache):完成后不清 checkpoint 而是整表回写 —— 同一工作流的
|
|
99
|
-
* 下一个 run seed 它,未变节点(同 kind+params+inputs 签名)命中跳过(ComfyUI 语义)。
|
|
100
|
-
* 默认 false = 既有崩溃恢复语义(完成即清)。
|
|
101
|
-
*/
|
|
102
|
-
preserveCheckpoint?: boolean;
|
|
103
|
-
/** Per-node lifecycle callback for live status (canvas coloring). Fire-and-forget, not durable. */
|
|
104
|
-
onNodeStatus?: (nodeId: string, status: "running" | "completed" | "failed", error?: string) => void;
|
|
105
|
-
}
|
|
106
|
-
export declare class WorkflowRuntime {
|
|
107
|
-
private def;
|
|
108
|
-
private readonly registry;
|
|
109
|
-
private readonly gate?;
|
|
110
|
-
private readonly now;
|
|
111
|
-
private readonly trigger?;
|
|
112
|
-
private readonly triggerKind?;
|
|
113
|
-
private readonly runId?;
|
|
114
|
-
private readonly log?;
|
|
115
|
-
private readonly host?;
|
|
116
|
-
private readonly abortController?;
|
|
117
|
-
private readonly signal;
|
|
118
|
-
private readonly checkpoint?;
|
|
119
|
-
private readonly preserveCheckpoint;
|
|
120
|
-
private readonly onNodeStatus?;
|
|
121
|
-
/** Serializes snapshots so an older slow write cannot land after a newer parallel-node write. */
|
|
122
|
-
private checkpointWriteChain;
|
|
123
|
-
private dag;
|
|
124
|
-
private readonly nodeDefs;
|
|
125
|
-
private readonly nodeOutputs;
|
|
126
|
-
/** Content-addressed output cache; persists across run() calls for run-from-node. */
|
|
127
|
-
private readonly cache;
|
|
128
|
-
/** loopBack source nodeId → loop controller nodeId. */
|
|
129
|
-
private readonly loopBackOf;
|
|
130
|
-
/** Cooperative pause request; honored before the next node executes. */
|
|
131
|
-
private pauseRequested;
|
|
132
|
-
/** Per-node trace (D33): seq/timing/attempts/cacheHit/disposition, keyed by nodeId. */
|
|
133
|
-
private readonly nodeStats;
|
|
134
|
-
private statsSeq;
|
|
135
|
-
/** True once the durable checkpoint has been loaded into `cache` (load once per instance). */
|
|
136
|
-
private checkpointLoaded;
|
|
137
|
-
constructor(def: WorkflowDef, opts?: WorkflowRuntimeOptions);
|
|
138
|
-
/** Patch a node's params (for run-from-node param changes). Invalidates nothing directly —
|
|
139
|
-
* the content-addressed cache recomputes only what changed. */
|
|
140
|
-
setNodeParams(nodeId: string, params: Record<string, unknown>): void;
|
|
141
|
-
/** Request a cooperative pause: the in-flight run suspends before the next node executes. */
|
|
142
|
-
pause(): void;
|
|
143
|
-
/** Cancel the run and abort the signal exposed to long-running executors. */
|
|
144
|
-
cancel(reason?: string): void;
|
|
145
|
-
/**
|
|
146
|
-
* Raise the budget gate's remaining allowance so a budget-paused run can resume (D15
|
|
147
|
-
* "抬预算后 resume"). fail-loud if this runtime was built without an extensible budget gate.
|
|
148
|
-
*/
|
|
149
|
-
extendBudget(delta: {
|
|
150
|
-
executions?: number;
|
|
151
|
-
durationMs?: number;
|
|
152
|
-
}): void;
|
|
153
|
-
/** Execute the workflow to completion (or until the gate halts / a branch fails / a pause). */
|
|
154
|
-
run(): Promise<RunResult>;
|
|
155
|
-
/**
|
|
156
|
-
* Seed the content-addressed cache from a durable checkpoint (once per instance). After a
|
|
157
|
-
* crash-restart a fresh runtime replays the DAG; nodes that completed before the crash hit
|
|
158
|
-
* these entries and their executors are not re-invoked (no duplicate side effects).
|
|
159
|
-
*/
|
|
160
|
-
private loadCheckpoint;
|
|
161
|
-
/** Persist the full content-addressed cache so a crash mid-run can resume from here. */
|
|
162
|
-
private persistCheckpoint;
|
|
163
|
-
private executeNode;
|
|
164
|
-
/** Loop entry: fire the "loop" port once to kick the first iteration. */
|
|
165
|
-
private enterLoop;
|
|
166
|
-
private decideLoopBack;
|
|
167
|
-
/** A loop forced out at its maxIterations cap (the scheduler marks error="loop_cap_reached:N",
|
|
168
|
-
* which previously had NO consumer — the run just took the "done" port as if the loop finished
|
|
169
|
-
* naturally). Surface it as a node-level warning: a warn log line + a trace entry the run history
|
|
170
|
-
* renders (run-history-store.buildNodeRecords), so the engine-imposed cap is visible in the record. */
|
|
171
|
-
private surfaceLoopCap;
|
|
172
|
-
/** Loop again? No condition → loop until the scheduler's maxIterations cap. */
|
|
173
|
-
private evalLoopCondition;
|
|
174
|
-
/** Collect inputs for a node from completed upstream outputs along forward data edges. */
|
|
175
|
-
private collectInputs;
|
|
176
|
-
private buildExprContext;
|
|
177
|
-
private cacheKey;
|
|
178
|
-
private isCanceled;
|
|
179
|
-
private canceledError;
|
|
180
|
-
private throwIfCanceled;
|
|
181
|
-
/** Cancel-aware sleep for retry backoff: aborts immediately when the run is canceled. */
|
|
182
|
-
private cancellableDelay;
|
|
183
|
-
private buildDag;
|
|
184
|
-
}
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Reusable in-process Workflow trigger scheduler (plan M3 trigger layer).
|
|
3
|
-
*
|
|
4
|
-
* Production ownership lives in the Runtime Gateway Host: it constructs one project-scoped instance,
|
|
5
|
-
* owns its clock and lifecycle, and routes cron/webhook/IM/manual triggers through that instance. The
|
|
6
|
-
* qlogicagent executable only publishes this inert engine building block and never constructs a
|
|
7
|
-
* scheduler owner.
|
|
8
|
-
*
|
|
9
|
-
* The scheduler is the consumer of WorkflowController: on `start()` it loads every active workflow
|
|
10
|
-
* (`listActive`, spec §B4 restart re-registration) and arms a timer per `schedule` trigger; on fire
|
|
11
|
-
* it calls `controller.run(id, { type: "schedule" })`. Webhook / IM / manual triggers are
|
|
12
|
-
* caller-driven (the gateway relay or the agent invokes the matching method). Concurrency,
|
|
13
|
-
* budgeting, and permission gating all live in `controller.run` — the scheduler only decides WHEN.
|
|
14
|
-
*
|
|
15
|
-
* Determinism: the clock (now + timers) is injected, so tests pin time exactly and far-future cron
|
|
16
|
-
* delays are handled by chunked re-arming (Node's setTimeout caps at ~24.8 days).
|
|
17
|
-
*/
|
|
18
|
-
import type { WorkflowController, RunOutcome } from "./workflow-controller.js";
|
|
19
|
-
export type TimerHandle = unknown;
|
|
20
|
-
/** Injectable clock + timer surface so the scheduler is fully deterministic under test. */
|
|
21
|
-
export interface SchedulerClock {
|
|
22
|
-
now(): number;
|
|
23
|
-
setTimer(fn: () => void, delayMs: number): TimerHandle;
|
|
24
|
-
clearTimer(handle: TimerHandle): void;
|
|
25
|
-
}
|
|
26
|
-
/** Default clock backed by the real system time and Node timers. */
|
|
27
|
-
export declare const systemClock: SchedulerClock;
|
|
28
|
-
export interface SchedulerDeps {
|
|
29
|
-
controller: WorkflowController;
|
|
30
|
-
clock?: SchedulerClock;
|
|
31
|
-
/**
|
|
32
|
-
* Product-level timezone for legacy schedule records that predate an explicit timezone.
|
|
33
|
-
* The reusable engine remains UTC by default; desktop hosts should pass the user's system zone.
|
|
34
|
-
*/
|
|
35
|
-
defaultTimezone?: string;
|
|
36
|
-
/** Latest durable scheduled-run start, used to detect one missed slot after a cold restart. */
|
|
37
|
-
getLastScheduledAt?: (workflowId: string) => Promise<number | undefined>;
|
|
38
|
-
/**
|
|
39
|
-
* Surfaces an error from a timer-driven (cron) run, which has no caller to throw back to.
|
|
40
|
-
* Required so a failed unattended run is never silently swallowed (§1.5 fail-loud). Caller-driven
|
|
41
|
-
* triggers (webhook/IM/manual) propagate their errors to the caller instead.
|
|
42
|
-
*/
|
|
43
|
-
onError: (err: unknown, workflowId: string) => void;
|
|
44
|
-
onRunStarted?: (workflowId: string, triggerType: string, runId: string) => void | Promise<void>;
|
|
45
|
-
onRunCompleted?: (outcome: RunOutcome, triggerType: string) => void;
|
|
46
|
-
onRunFailed?: (workflowId: string, triggerType: string, err: unknown) => void;
|
|
47
|
-
/**
|
|
48
|
-
* Trigger rate-limit (D32/§B5 防洪): minimum ms between UNATTENDED fires (webhook/IM/cron) of
|
|
49
|
-
* the same workflow. A fire inside the window is DROPPED — loudly, via onTriggerDropped (dead
|
|
50
|
-
* letter), never silently. Manual/intent (attended) fires are exempt. Default 0 (off) — the
|
|
51
|
-
* production assembly (ensureWorkflowRoot) opts in explicitly; rate policy is the host's call.
|
|
52
|
-
*/
|
|
53
|
-
minTriggerIntervalMs?: number;
|
|
54
|
-
/** Dead-letter surface for rate-limited drops. Required when minTriggerIntervalMs > 0. */
|
|
55
|
-
onTriggerDropped?: (workflowId: string, triggerType: string, detail: {
|
|
56
|
-
sinceLastMs: number;
|
|
57
|
-
minIntervalMs: number;
|
|
58
|
-
reason?: "rate-limit" | "misfire";
|
|
59
|
-
scheduledAt?: number;
|
|
60
|
-
}) => void;
|
|
61
|
-
}
|
|
62
|
-
export declare class WorkflowScheduler {
|
|
63
|
-
private readonly controller;
|
|
64
|
-
private readonly clock;
|
|
65
|
-
private readonly onError;
|
|
66
|
-
private readonly onRunStarted?;
|
|
67
|
-
private readonly onRunCompleted?;
|
|
68
|
-
private readonly onRunFailed?;
|
|
69
|
-
private readonly defaultTimezone;
|
|
70
|
-
private readonly getLastScheduledAt?;
|
|
71
|
-
/** Every registered workflow's trigger, keyed by id (the single source for lookups). */
|
|
72
|
-
private readonly triggers;
|
|
73
|
-
/** Active cron arms keyed by workflow id. */
|
|
74
|
-
private readonly cronArms;
|
|
75
|
-
/** Last unattended fire per workflow (rate-limit window anchor, D32). */
|
|
76
|
-
private readonly lastFireAt;
|
|
77
|
-
private readonly minTriggerIntervalMs;
|
|
78
|
-
private readonly onTriggerDropped?;
|
|
79
|
-
private started;
|
|
80
|
-
constructor(deps: SchedulerDeps);
|
|
81
|
-
/** Load every active workflow and arm its trigger (spec §B4 restart re-registration). */
|
|
82
|
-
start(): Promise<void>;
|
|
83
|
-
/** Stop all timers and forget every registration. Idempotent. */
|
|
84
|
-
stop(): void;
|
|
85
|
-
/**
|
|
86
|
-
* Re-read a workflow and (re-)arm its trigger after a create/patch/setActive change. If the
|
|
87
|
-
* workflow no longer exists or is inactive it is unregistered. Active workflows are armed by
|
|
88
|
-
* their current trigger (manual ⇒ lookup-only, no timer).
|
|
89
|
-
*/
|
|
90
|
-
refresh(id: string): Promise<void>;
|
|
91
|
-
/** Drop a workflow's registration and cancel any pending cron timer. */
|
|
92
|
-
unregister(id: string): void;
|
|
93
|
-
/** Workflow ids currently registered (for inspection/tests). */
|
|
94
|
-
registeredIds(): string[];
|
|
95
|
-
/** The epoch ms a scheduled workflow will next fire, or undefined if it has no cron arm. */
|
|
96
|
-
nextFireAt(id: string): number | undefined;
|
|
97
|
-
/**
|
|
98
|
-
* Deliver an external webhook hit. Runs every active workflow whose webhook trigger path equals
|
|
99
|
-
* `path`. Returns the outcomes (empty ⇒ no workflow matched, which the gateway maps to 404).
|
|
100
|
-
* Errors propagate to the caller (the HTTP handler), which is the fail-loud surface here.
|
|
101
|
-
*/
|
|
102
|
-
onWebhook(path: string, payload?: Record<string, unknown>): Promise<RunOutcome[]>;
|
|
103
|
-
/**
|
|
104
|
-
* Deliver an inbound IM message. Runs every active workflow whose im-message trigger is on
|
|
105
|
-
* `channel` and whose optional `match` regex tests `text`. The message text + channel are merged
|
|
106
|
-
* into the run payload so downstream nodes can reference `$trigger`.
|
|
107
|
-
*/
|
|
108
|
-
onImMessage(channel: string, text: string, payload?: Record<string, unknown>): Promise<RunOutcome[]>;
|
|
109
|
-
/** Manually trigger a single workflow for the owning Runtime Host. Errors propagate to caller. */
|
|
110
|
-
triggerManual(id: string, payload?: Record<string, unknown>): Promise<RunOutcome>;
|
|
111
|
-
private matchingIds;
|
|
112
|
-
private registerTrigger;
|
|
113
|
-
private armCron;
|
|
114
|
-
private fireCron;
|
|
115
|
-
/**
|
|
116
|
-
* Unattended-fire rate limit (D32): true ⇒ proceed (and anchor the window); false ⇒ DROPPED,
|
|
117
|
-
* surfaced via onTriggerDropped (dead letter) — never silent.
|
|
118
|
-
*/
|
|
119
|
-
private passesRateLimit;
|
|
120
|
-
private runWithLifecycle;
|
|
121
|
-
private reportLifecycleCallbackError;
|
|
122
|
-
}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Workflow Store: project-scoped persistence used by Runtime's Gateway Workflow Host.
|
|
3
|
-
*
|
|
4
|
-
* Stored at `<project>/.qlogicagent/workflows/<workflowId>/workflow.json`. Within a Runtime Host
|
|
5
|
-
* project service, this is the single source of truth for the workflow definition, active flag,
|
|
6
|
-
* and concurrency policy. Runtime re-registers active triggers when that service starts.
|
|
7
|
-
*
|
|
8
|
-
* fail-loud: missing id on save throws; load returns undefined only for a genuinely absent record.
|
|
9
|
-
*/
|
|
10
|
-
import type { WorkflowDef } from "./node-schema.js";
|
|
11
|
-
import type { TriggerDef } from "./workflow-patch.js";
|
|
12
|
-
import type { WorkflowTemplateSetupManifest, WorkflowTemplateSetupState } from "./workflow-template-setup.js";
|
|
13
|
-
/** What to do when a workflow is triggered while a previous run is still in-flight (spec §B5). */
|
|
14
|
-
export type ConcurrencyPolicy = "queue" | "skip" | "parallel";
|
|
15
|
-
export interface WorkflowRecord {
|
|
16
|
-
id: string;
|
|
17
|
-
name: string;
|
|
18
|
-
/** Owning user, resolved by the Runtime Host. */
|
|
19
|
-
owner?: string;
|
|
20
|
-
def: WorkflowDef;
|
|
21
|
-
/** Active workflows have their triggers registered by the Runtime Gateway Host. */
|
|
22
|
-
active: boolean;
|
|
23
|
-
concurrency: ConcurrencyPolicy;
|
|
24
|
-
/** The workflow's trigger (set via a WorkflowPatch set_trigger op; spec §C/D7). */
|
|
25
|
-
trigger?: TriggerDef | null;
|
|
26
|
-
/** Portable, credential-free inputs shown in the import/template setup panel. */
|
|
27
|
-
setup?: WorkflowTemplateSetupManifest;
|
|
28
|
-
/** Non-secret answers and opaque connection references applied from `setup`. */
|
|
29
|
-
setupState?: WorkflowTemplateSetupState;
|
|
30
|
-
/**
|
|
31
|
-
* Unattended-run capability grant (spec D30, IT-7): sensitive node kinds this workflow may
|
|
32
|
-
* execute under unattended triggers (schedule/im/webhook). Granted explicitly by the owner
|
|
33
|
-
* at activation time; absent ⇒ unattended runs of sensitive kinds are denied by the gate.
|
|
34
|
-
*/
|
|
35
|
-
permissionScope?: {
|
|
36
|
-
allowUnattendedKinds: string[];
|
|
37
|
-
grantedAt: string;
|
|
38
|
-
} | null;
|
|
39
|
-
/** The published (run-by-triggers) snapshot. Absent ⇒ never published ⇒ cannot activate. */
|
|
40
|
-
publishedDef?: WorkflowDef | null;
|
|
41
|
-
/** The draft rev that was published (UI: draft-ahead badge when rev > publishedRev). */
|
|
42
|
-
publishedRev?: number;
|
|
43
|
-
/** Archived workflows keep their data but cannot run or activate (D31 lifecycle). */
|
|
44
|
-
archived?: boolean;
|
|
45
|
-
/** Monotonic revision for optimistic concurrency (LWW); bumped on every patch (spec §C). */
|
|
46
|
-
rev: number;
|
|
47
|
-
createdAt: string;
|
|
48
|
-
updatedAt: string;
|
|
49
|
-
}
|
|
50
|
-
/** Root dir of all workflow records for a project (shared with the run-history store). */
|
|
51
|
-
export declare function workflowsDir(cwd: string): string;
|
|
52
|
-
/** Bounded def-revision history depth — enough for undo, small enough to never matter on disk. */
|
|
53
|
-
export declare const MAX_REVISIONS = 20;
|
|
54
|
-
/** Summary row for revision lists (full snapshot stays behind loadRevision). */
|
|
55
|
-
export interface RevisionSummary {
|
|
56
|
-
rev: number;
|
|
57
|
-
updatedAt: string;
|
|
58
|
-
name: string;
|
|
59
|
-
nodeCount: number;
|
|
60
|
-
}
|
|
61
|
-
export declare class WorkflowStore {
|
|
62
|
-
private readonly cwd;
|
|
63
|
-
constructor(cwd: string);
|
|
64
|
-
save(record: WorkflowRecord): Promise<void>;
|
|
65
|
-
/**
|
|
66
|
-
* Persist a per-rev snapshot alongside the live record (undo/revert 基座).
|
|
67
|
-
* Keyed by rev: a meta-only update (same rev, e.g. setActive) overwrites its own
|
|
68
|
-
* snapshot; a patch (rev bump) appends a new one. Bounded to MAX_REVISIONS.
|
|
69
|
-
* fail-soft: snapshot/prune errors must never block the primary save.
|
|
70
|
-
*/
|
|
71
|
-
private snapshotRevision;
|
|
72
|
-
/** Revision numbers, newest first. */
|
|
73
|
-
private revisionNumbers;
|
|
74
|
-
/** Newest-first revision summaries for the undo/history UI. */
|
|
75
|
-
listRevisions(id: string): Promise<RevisionSummary[]>;
|
|
76
|
-
/** Full record snapshot at a given rev (undefined when pruned/absent). */
|
|
77
|
-
loadRevision(id: string, rev: number): Promise<WorkflowRecord | undefined>;
|
|
78
|
-
load(id: string): Promise<WorkflowRecord | undefined>;
|
|
79
|
-
/** Load a record or throw (fail-loud lookup for callers that require existence). */
|
|
80
|
-
require(id: string): Promise<WorkflowRecord>;
|
|
81
|
-
list(): Promise<WorkflowRecord[]>;
|
|
82
|
-
/** Active workflows the Runtime Gateway Host re-registers when the project service starts. */
|
|
83
|
-
listActive(): Promise<WorkflowRecord[]>;
|
|
84
|
-
delete(id: string): Promise<void>;
|
|
85
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import type { WorkflowDef } from "./node-schema.js";
|
|
2
|
-
import type { TriggerDef } from "./workflow-trigger.js";
|
|
3
|
-
export type WorkflowTemplateSetupValue = string | number | boolean;
|
|
4
|
-
export interface WorkflowTemplateSetupOption {
|
|
5
|
-
label: string;
|
|
6
|
-
value: string;
|
|
7
|
-
}
|
|
8
|
-
export interface WorkflowTemplateSetupField {
|
|
9
|
-
id: string;
|
|
10
|
-
label: string;
|
|
11
|
-
description?: string;
|
|
12
|
-
group?: string;
|
|
13
|
-
type: "text" | "textarea" | "url" | "number" | "boolean" | "select" | "connection";
|
|
14
|
-
required?: boolean;
|
|
15
|
-
placeholder?: string;
|
|
16
|
-
defaultValue?: WorkflowTemplateSetupValue;
|
|
17
|
-
options?: WorkflowTemplateSetupOption[];
|
|
18
|
-
/** Capability/provider family used to filter installed connections. */
|
|
19
|
-
connectionType?: string;
|
|
20
|
-
}
|
|
21
|
-
export interface WorkflowTemplateSetupBinding {
|
|
22
|
-
fieldId: string;
|
|
23
|
-
target: {
|
|
24
|
-
kind: "node";
|
|
25
|
-
nodeId: string;
|
|
26
|
-
path: string;
|
|
27
|
-
} | {
|
|
28
|
-
kind: "trigger";
|
|
29
|
-
path: string;
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
export interface WorkflowTemplateSetupManifest {
|
|
33
|
-
version: 1;
|
|
34
|
-
title?: string;
|
|
35
|
-
description?: string;
|
|
36
|
-
fields: WorkflowTemplateSetupField[];
|
|
37
|
-
bindings: WorkflowTemplateSetupBinding[];
|
|
38
|
-
}
|
|
39
|
-
export interface WorkflowTemplateSetupState {
|
|
40
|
-
values: Record<string, WorkflowTemplateSetupValue>;
|
|
41
|
-
updatedAt?: string;
|
|
42
|
-
completedAt?: string;
|
|
43
|
-
}
|
|
44
|
-
export interface WorkflowTemplateSetupProjection {
|
|
45
|
-
manifest: WorkflowTemplateSetupManifest;
|
|
46
|
-
values: Record<string, WorkflowTemplateSetupValue>;
|
|
47
|
-
status: "pending" | "complete";
|
|
48
|
-
missingRequired: string[];
|
|
49
|
-
}
|
|
50
|
-
export declare function validateWorkflowTemplateSetup(value: unknown, def: WorkflowDef): WorkflowTemplateSetupManifest;
|
|
51
|
-
export declare function projectWorkflowTemplateSetup(manifest: WorkflowTemplateSetupManifest, state?: WorkflowTemplateSetupState): WorkflowTemplateSetupProjection;
|
|
52
|
-
export declare function applyWorkflowTemplateSetup(definition: WorkflowDef, trigger: TriggerDef | null | undefined, manifest: WorkflowTemplateSetupManifest, previous: WorkflowTemplateSetupState | undefined, input: Record<string, unknown>, now?: string): {
|
|
53
|
-
def: WorkflowDef;
|
|
54
|
-
trigger?: TriggerDef | null;
|
|
55
|
-
state: WorkflowTemplateSetupState;
|
|
56
|
-
missingRequired: string[];
|
|
57
|
-
};
|
|
58
|
-
/**
|
|
59
|
-
* Reset every setup-bound destination before a workflow leaves the local Host.
|
|
60
|
-
* The manifest travels with the bundle; user answers and opaque connection ids do not.
|
|
61
|
-
*/
|
|
62
|
-
export declare function resetWorkflowTemplateSetupBindings(definition: WorkflowDef, trigger: TriggerDef | null | undefined, manifest: WorkflowTemplateSetupManifest): {
|
|
63
|
-
def: WorkflowDef;
|
|
64
|
-
trigger?: TriggerDef | null;
|
|
65
|
-
};
|