qlogicagent 2.19.13 → 2.20.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/README.md +0 -1
  2. package/dist/agent-contract.js +1 -1
  3. package/dist/agent.js +31 -31
  4. package/dist/cli.js +1 -1
  5. package/dist/host-contract.js +1 -1
  6. package/dist/index.js +457 -453
  7. package/dist/orchestration.js +13 -13
  8. package/dist/project-memory-host.js +19 -18
  9. package/dist/protocol.js +1 -1
  10. package/dist/tunables.js +1 -1
  11. package/dist/types/cli/acp-extended-handlers.d.ts +5 -10
  12. package/dist/types/cli/acp-extended-host-adapter.d.ts +1 -1
  13. package/dist/types/cli/community-workflow-installer.d.ts +2 -2
  14. package/dist/types/cli/handlers/dream-handler.d.ts +6 -0
  15. package/dist/types/cli/handlers/goal-handler.d.ts +1 -13
  16. package/dist/types/cli/handlers/product-handler.d.ts +6 -9
  17. package/dist/types/cli/handlers/solo-handler.d.ts +3 -6
  18. package/dist/types/cli/handlers/workflow-compute-handler.d.ts +1 -1
  19. package/dist/types/cli/memory-coordinator.d.ts +0 -2
  20. package/dist/types/cli/multi-agent-handler-host.d.ts +1 -1
  21. package/dist/types/cli/orchestration-memory-context.d.ts +1 -0
  22. package/dist/types/cli/product-coordinator.d.ts +2 -5
  23. package/dist/types/cli/rpc-registry.d.ts +0 -3
  24. package/dist/types/cli/runtime-hook-bootstrap.d.ts +0 -2
  25. package/dist/types/cli/stdio-rpc-handler-hosts.d.ts +2 -1
  26. package/dist/types/cli/stdio-server.d.ts +2 -3
  27. package/dist/types/cli/task-distillation-coordinator.d.ts +0 -3
  28. package/dist/types/contracts/hooks.d.ts +2 -0
  29. package/dist/types/host-contract/index.d.ts +3 -13
  30. package/dist/types/index.d.ts +0 -1
  31. package/dist/types/orchestration/agent-instance.d.ts +30 -15
  32. package/dist/types/orchestration/agent-roster.d.ts +2 -2
  33. package/dist/types/orchestration/goal-loop-coordinator.d.ts +18 -8
  34. package/dist/types/orchestration/goal-mode-adapters.d.ts +6 -1
  35. package/dist/types/orchestration/goal-run-persistence.d.ts +12 -10
  36. package/dist/types/orchestration/goal-run-types.d.ts +3 -21
  37. package/dist/types/orchestration/index.d.ts +0 -1
  38. package/dist/types/orchestration/product-checkpoint.d.ts +10 -6
  39. package/dist/types/orchestration/product-persistence.d.ts +47 -20
  40. package/dist/types/orchestration/product-planner.d.ts +30 -10
  41. package/dist/types/orchestration/product-run-coordinator.d.ts +4 -3
  42. package/dist/types/orchestration/solo-evaluator.d.ts +10 -16
  43. package/dist/types/orchestration/solo-persistence.d.ts +10 -10
  44. package/dist/types/orchestration/workflow/budget-permission-gate.d.ts +1 -1
  45. package/dist/types/orchestration/workflow/capability-catalog.d.ts +11 -34
  46. package/dist/types/orchestration/workflow/host-executors.d.ts +3 -3
  47. package/dist/types/orchestration/workflow/n8n-import.d.ts +0 -1
  48. package/dist/types/orchestration/workflow/node-schema.d.ts +5 -18
  49. package/dist/types/orchestration/workflow/params-schema.d.ts +7 -16
  50. package/dist/types/orchestration/workflow/qla-executor-host.d.ts +4 -27
  51. package/dist/types/orchestration/workflow/workflow-bundle.d.ts +10 -28
  52. package/dist/types/orchestration/workflow/workflow-controller.d.ts +14 -8
  53. package/dist/types/orchestration/workflow/workflow-error.d.ts +1 -1
  54. package/dist/types/orchestration/workflow/workflow-render.d.ts +1 -1
  55. package/dist/types/orchestration/workflow/workflow-scheduler.d.ts +8 -8
  56. package/dist/types/orchestration/workflow/workflow-store.d.ts +7 -8
  57. package/dist/types/orchestration/workflow-chat-builder.d.ts +1 -1
  58. package/dist/types/protocol/agent-contract.d.ts +7 -7
  59. package/dist/types/protocol/methods.d.ts +1 -129
  60. package/dist/types/protocol/notifications.d.ts +1 -1
  61. package/dist/types/protocol/wire/acp-agent-management.d.ts +45 -24
  62. package/dist/types/protocol/wire/acp-protocol.d.ts +3 -8
  63. package/dist/types/protocol/wire/agent-methods.d.ts +2 -468
  64. package/dist/types/protocol/wire/index.d.ts +1 -1
  65. package/dist/types/protocol/wire/notification-payloads.d.ts +0 -6
  66. package/dist/types/protocol/wire/thread-protocol.d.ts +1 -1
  67. package/dist/types/runtime/config/tunable-defaults.d.ts +0 -9
  68. package/dist/types/runtime/hooks/memory-hooks.d.ts +11 -4
  69. package/dist/types/runtime/infra/acp-protocol-adapter.d.ts +1 -2
  70. package/dist/types/runtime/memory/implicit-extraction.d.ts +4 -1
  71. package/dist/types/runtime/memory/recall-category-filter.d.ts +0 -12
  72. package/dist/types/runtime/ports/memory-recall-source.d.ts +1 -0
  73. package/dist/types/runtime/ports/project-memory-store.d.ts +3 -0
  74. package/dist/types/skills/memory/host-memory-provider.d.ts +7 -0
  75. package/dist/types/skills/memory/memdir.d.ts +1 -2
  76. package/dist/types/skills/memory/task-distillation.d.ts +18 -4
  77. package/dist/types/skills/skill-system/skill-lifecycle.d.ts +0 -17
  78. package/dist/types/skills/skill-system/skill-validation.d.ts +1 -1
  79. package/dist/types/transport/acp-server.d.ts +1 -5
  80. package/dist/types/workflow-host.d.ts +2 -4
  81. package/dist/workflow-host.js +7 -9
  82. package/package.json +1 -1
  83. package/dist/types/cli/credential-vault.d.ts +0 -68
  84. package/dist/types/orchestration/skill-improvement.d.ts +0 -97
  85. package/dist/types/skills/memory/local-store-records.d.ts +0 -206
  86. package/dist/types/skills/memory/local-store.d.ts +0 -376
  87. package/dist/types/skills/memory/memory-attachment-store.d.ts +0 -62
  88. package/dist/types/skills/memory/memory-consolidation.d.ts +0 -64
  89. package/dist/types/skills/memory/memory-db-path.d.ts +0 -13
  90. package/dist/types/skills/memory/proposal-consumer.d.ts +0 -51
  91. package/dist/types/skills/memory/sqlite-memory-mappers.d.ts +0 -7
  92. package/dist/types/skills/memory/sqlite-memory-schema.d.ts +0 -11
@@ -11,7 +11,7 @@
11
11
  * 6. solo.select → merge winning worktree, clean up others
12
12
  *
13
13
  * Key design:
14
- * - Solo = special project type (persisted in .qlogicagent/solos/)
14
+ * - Solo = special project type persisted by the Gateway RunState authority
15
15
  * - Agents share the same initial config but operate in isolated worktrees
16
16
  * - User controls the evaluation timing (not automatic)
17
17
  * - Follow-up instructions to individual agents supported
@@ -20,30 +20,28 @@
20
20
  */
21
21
  import type { DelegateBridge } from "./delegate-bridge.js";
22
22
  import type { SoloState, SoloAgentState, SoloEvaluation, SoloStatus, SoloStartParams, SoloSelectParams, SoloSpec } from "../protocol/wire/acp-agent-management.js";
23
- export declare function deriveSoloDelegateProjectId(registeredProjectRoot: string): string;
24
23
  export interface SoloCallbacks {
25
24
  log?: {
26
25
  info(msg: string): void;
27
26
  warn(msg: string): void;
28
27
  debug?(msg: string): void;
29
28
  };
30
- onProgress?: (soloId: string, agentId: string, state: SoloAgentState, progress?: string, worktreePath?: string) => void;
31
- onEvaluation?: (soloId: string, evaluation: SoloEvaluation) => void | Promise<void>;
29
+ onProgress?: (soloId: string, agentId: string, state: SoloAgentState, progress: string | undefined, worktreePath: string | undefined, projectId: string) => void;
30
+ onEvaluation?: (soloId: string, evaluation: SoloEvaluation, projectId: string) => void | Promise<void>;
32
31
  /** Streaming text delta from a competing agent (forwarded from child process). */
33
32
  onAgentDelta?: (soloId: string, agentId: string, text: string) => void;
34
- /** Live tool-activity heartbeat(delegate 路径由 sink.onToolCall 单发;旧路径经共享 PM 的
35
- * turn.tool_call 在 solo-handler 转 solo.agentActivity,PM 在 delegate 路径看不见竞速者)。 */
33
+ /** Live tool-activity heartbeat emitted from the supervised delegate event sink. */
36
34
  onAgentActivity?: (soloId: string, agentId: string, toolName: string) => void;
37
35
  /** Token usage report after agent completes. */
38
36
  onAgentUsage?: (soloId: string, agentId: string, inputTokens: number, outputTokens: number) => void;
39
- /** 激活层(S3c §1.5):gateway-routed delegate 桥(gate 关/未挂 = undefined 旧本地 spawn 路径)。 */
37
+ /** Required Gateway delegate access; Solo fails loud when the Host rail is unavailable. */
40
38
  getDelegateBridge?: () => DelegateBridge | undefined;
41
39
  /**
42
40
  * Race reached a terminal state WITHOUT an evaluation winner (all agents failed, or cancelled).
43
41
  * The success path uses onEvaluation; this lets the host write back the plan project's planStatus
44
42
  * (failed/cancelled) so 历史方案 is correct and recovery doesn't restore a dead run.
45
43
  */
46
- onTerminal?: (soloId: string, state: SoloState) => void | Promise<void>;
44
+ onTerminal?: (soloId: string, state: SoloState, projectId: string) => void | Promise<void>;
47
45
  }
48
46
  /**
49
47
  * Solo is an explicit user-launched coding race and every racer is confined to its own disposable
@@ -75,13 +73,11 @@ export declare function buildEvaluationPrompt(originalTask: string, spec: SoloSp
75
73
  export declare class SoloEvaluator {
76
74
  private callbacks;
77
75
  private sessions;
76
+ private persistenceTails;
78
77
  constructor(callbacks?: SoloCallbacks);
79
- /** Persist current session data to disk (fire-and-forget). */
80
- private persistSession;
81
- /** Restore sessions from disk (call once at startup). */
82
- restoreFromDisk(cwd?: string): Promise<number>;
83
- /** Delete a solo session from memory and disk. */
84
- deleteSolo(soloId: string): Promise<boolean>;
78
+ private snapshotSession;
79
+ private queuePersistSession;
80
+ private publishNotification;
85
81
  /**
86
82
  * Start a Solo Mode PK session.
87
83
  * Creates worktrees, spawns agents in parallel, waits for completion, then evaluates.
@@ -131,8 +127,6 @@ export declare class SoloEvaluator {
131
127
  * Select a winner and merge their worktree into the main branch.
132
128
  */
133
129
  select(params: SoloSelectParams): Promise<string>;
134
- /** List all solo sessions. */
135
- listSessions(): SoloStatus[];
136
130
  /** Delete a solo session, killing agents and cleaning up worktrees if still active. */
137
131
  delete(soloId: string): Promise<void>;
138
132
  /**
@@ -1,19 +1,21 @@
1
1
  /**
2
2
  * Solo persistence facade over the Gateway-owned RunStateStore.
3
3
  */
4
- import type { PathService } from "../runtime/ports/index.js";
5
- import type { SoloState, SoloAgentState, SoloEvaluation, SoloSpec } from "../protocol/wire/acp-agent-management.js";
4
+ import type { SoloAgentState, SoloEvaluation, SoloSpec, SoloState } from "../protocol/wire/acp-agent-management.js";
5
+ import { type HostRunStateAuthority } from "./run-state-host-authority.js";
6
6
  export interface PersistedSoloState {
7
7
  soloId: string;
8
+ projectId: string;
8
9
  state: SoloState;
9
10
  task: string;
10
11
  cwd: string;
11
12
  gitRoot: string;
12
13
  agents: Array<{
13
14
  agentId: string;
15
+ displayId?: string;
14
16
  memberId: string;
15
- /** Handle seq(delegate 路径 MemberHandle 第四元);旧持久化文件缺省时按数组序回填。 */
16
- seq?: number;
17
+ /** Stable delegate handle sequence that distinguishes duplicate agent IDs. */
18
+ seq: number;
17
19
  worktreePath: string;
18
20
  worktreeBranch: string;
19
21
  state: SoloAgentState;
@@ -35,13 +37,11 @@ export interface PersistedSoloState {
35
37
  createdAt: number;
36
38
  }
37
39
  export interface SoloPersistenceOptions {
38
- pathService?: PathService;
40
+ authority?: HostRunStateAuthority;
39
41
  }
40
42
  /** Save the latest Solo snapshot through Gateway authority. */
41
- export declare function saveSoloState(state: PersistedSoloState, cwd?: string, options?: SoloPersistenceOptions): Promise<void>;
43
+ export declare function saveSoloState(state: PersistedSoloState, options?: SoloPersistenceOptions): Promise<void>;
42
44
  /** Load the latest Solo snapshot from Gateway authority. */
43
- export declare function loadSoloState(soloId: string, cwd?: string, options?: SoloPersistenceOptions): Promise<PersistedSoloState | undefined>;
44
- /** List all solo session IDs with their persisted state. */
45
- export declare function listSoloSessions(cwd?: string, options?: SoloPersistenceOptions): Promise<PersistedSoloState[]>;
45
+ export declare function loadSoloState(soloId: string, options?: SoloPersistenceOptions): Promise<PersistedSoloState | undefined>;
46
46
  /** Delete a Solo run through Gateway authority. */
47
- export declare function deleteSoloState(soloId: string, cwd?: string, options?: SoloPersistenceOptions): Promise<boolean>;
47
+ export declare function deleteSoloState(soloId: string, options?: SoloPersistenceOptions): Promise<boolean>;
@@ -26,7 +26,7 @@ import { WorkflowPauseSignal, type ExecutionGate } from "./workflow-runtime.js";
26
26
  /** The trigger kinds that can start a run. Single source of the union (consumed by the controller). */
27
27
  export type WorkflowTriggerKind = "manual" | "schedule" | "im-message" | "webhook" | "intent" | "form";
28
28
  /**
29
- * Node kinds that reach the outside world (network calls, channel sends, agent/tool/mcp side
29
+ * Node kinds that reach the outside world (network calls, channel sends, Agent/Action side
30
30
  * effects). These require explicit authorization to run unattended. Control / data-shaping kinds
31
31
  * (set / if / loop / merge / passthrough / trigger) are NOT here — they cannot escape the engine.
32
32
  */
@@ -1,48 +1,25 @@
1
1
  /**
2
- * Capability Catalog (spec D24) THE single source of truth for "what can a workflow node
3
- * actually reference". One catalog feeds five consumers: the AI graph builder's prompt +
4
- * list_capabilities tool, the canvas "+" suggestions, the advanced node library, the node
5
- * config dropdowns, and Hub bundle `requires` verification.
6
- *
7
- * Channels are deliberately ABSENT here: the engine is channel-opaque (delivery lives in the
8
- * gateway), so the gateway merges its own channel registry into `workflow.capabilities` /
9
- * `x/workflow.chat` responses. Everything else enumerates REAL runtime state — no static lists.
2
+ * Canonical Workflow capability-catalog helpers. Runtime owns and injects the exact catalog;
3
+ * qlogicagent only renders and validates that snapshot for Workflow Chat.
10
4
  */
11
- import type { ToolDefinition } from "../../protocol/wire/chat-types.js";
12
- export type CapabilityCategory = "agent" | "tool" | "skill" | "mcp" | "memory" | "channel" | "control";
5
+ export type CapabilityCategory = "agent" | "action" | "mcp" | "memory" | "channel" | "control";
13
6
  export interface CapabilityEntry {
14
7
  category: CapabilityCategory;
15
- /** Workflow node kind that uses this capability. */
16
8
  kind: string;
17
- /** Concrete reference: tool name / agent id / "server.tool" / memory op / channel name. */
9
+ /** Concrete Agent, MCP plugin/tool, memory, channel, or control reference. */
18
10
  id: string;
19
- /** Human-readable name for pickers and the AI prompt. */
20
11
  label: string;
21
12
  description?: string;
22
- /** JSON schema of the underlying callable's input (tools/mcp), when known. */
23
13
  paramsSchema?: Record<string, unknown>;
24
- /** Prefill for add_node params when the user picks this entry. */
25
14
  paramsTemplate?: Record<string, unknown>;
15
+ pluginId?: string;
16
+ toolName?: string;
17
+ server?: string;
18
+ tool?: string;
26
19
  }
27
- export interface CapabilityCatalogDeps {
28
- getToolManifest(): ToolDefinition[];
29
- /** Available agent ids a workflow `agent` node can target (self first). */
30
- listAgentIds(): {
31
- id: string;
32
- name?: string;
33
- }[];
34
- /** Project root for project-scoped skill resolution. */
35
- projectRoot: string;
36
- }
37
- /** Enumerate every capability a workflow in `projectRoot` can reference right now. */
38
- export declare function buildCapabilityCatalog(deps: CapabilityCatalogDeps): Promise<CapabilityEntry[]>;
39
- /**
40
- * Compact catalog text for the AI graph builder's system prompt: category headers + `id — desc`
41
- * lines, hard-capped per category so huge tool sets don't blow the prompt (the agent uses the
42
- * list_capabilities tool for the long tail).
43
- */
20
+ /** Render the Host-owned catalog for the AI graph builder prompt. */
44
21
  export declare function renderCatalogForPrompt(entries: CapabilityEntry[], perCategoryCap?: number): string;
45
- /** Refs the validator extracts from a def to check against the catalog (anti-hallucination). */
22
+ /** Extract canonical references for anti-hallucination validation. */
46
23
  export declare function collectCapabilityRefs(def: {
47
24
  nodes: {
48
25
  id: string;
@@ -54,7 +31,7 @@ export declare function collectCapabilityRefs(def: {
54
31
  ref: string;
55
32
  nodeId: string;
56
33
  }[];
57
- /** Validate def refs against the catalog. Returns human-readable errors (empty = clean). */
34
+ /** Validate canonical references against the Host-owned catalog. */
58
35
  export declare function validateCapabilityRefs(def: {
59
36
  nodes: {
60
37
  id: string;
@@ -1,15 +1,15 @@
1
1
  /**
2
2
  * Host-backed NodeExecutors (M3 bridge contract; plan D12/D13, spec §B).
3
3
  *
4
- * The engine is a pure executor: kinds that need real-world capabilities (agent / tool / http /
5
- * mcp / channel) are fulfilled by an injected `ExecutorHost`. In production the xiaozhiclaw gateway
4
+ * The engine is a pure executor: kinds that need real-world capabilities (agent / http / channel)
5
+ * are fulfilled by an injected `ExecutorHost`. Canonical Action execution is injected by Runtime.
6
6
  * (or the qlogicagent CLI host) provides a real host; the engine never imports those subsystems.
7
7
  *
8
8
  * These executors are REAL (not mocks): they read the node's resolved params + inputs and delegate
9
9
  * to the host. fail-loud — invoking a host-backed kind with no host throws (no silent fallback).
10
10
  */
11
11
  import type { NodeExecutor } from "./node-schema.js";
12
- /** The host-backed kinds. Register these into a NodeRegistry to enable agent/tool/http/mcp/channel/skill/memory/subworkflow/approval. */
12
+ /** Host-backed canonical and imported node kinds. Runtime injects the canonical Action executor. */
13
13
  export declare const hostExecutors: Record<string, NodeExecutor>;
14
14
  /** Host-backed kind names (used by callers to know which kinds need a host). */
15
15
  export declare const HOST_BACKED_KINDS: string[];
@@ -12,7 +12,6 @@ export interface N8nCredentialRequirement {
12
12
  nodeId: string;
13
13
  n8nCredentialType: string;
14
14
  label?: string;
15
- suggestedVaultType: string;
16
15
  }
17
16
  export interface N8nBindingRequirement {
18
17
  models: Array<{
@@ -101,24 +101,21 @@ export interface ExecutorContext {
101
101
  info(m: string): void;
102
102
  warn(m: string): void;
103
103
  };
104
- /** Host capabilities for host-backed node kinds (agent/tool/http/mcp/channel), D13. */
104
+ /** Host capabilities for host-backed and Runtime-injected node kinds. */
105
105
  host?: ExecutorHost;
106
106
  /** Cooperative cancellation for long-running host calls. */
107
107
  signal?: AbortSignal;
108
108
  }
109
109
  /**
110
- * Capabilities the HOST (xiaozhiclaw gateway, or the qlogicagent CLI host) provides to back node
111
- * kinds the engine cannot fulfil on its own. The engine stays a pure executor (plan D12/D13):
112
- * agent/tool/mcp/http are qlogicagent-owned host capabilities; channel/IM call back into the
113
- * xiaozhiclaw channel layer. fail-loud: a host-backed kind with no host throws.
110
+ * Capabilities the embedding HOST provides for node kinds the engine cannot fulfil on its own.
111
+ * Production composition belongs to the xiaozhiclaw Gateway Host; qlogicagent exports the inert
112
+ * executor contract and test/CLI adapters. A host-backed kind with no host fails loud.
114
113
  */
115
114
  export interface ExecutorHost {
116
115
  /** Run an agent turn. Returns the agent's structured output as DataItem(s). */
117
116
  runAgent(req: AgentHostRequest): Promise<DataItem[]>;
118
117
  /** Run the currently configured workflow/text model. The host resolves provider/API key/model. */
119
118
  runModel?(req: ModelHostRequest): Promise<DataItem[]>;
120
- /** Invoke a qlogicagent tool by name. */
121
- invokeTool(req: ToolHostRequest): Promise<DataItem[]>;
122
119
  /** Perform an HTTP request (credentials resolved host-side). */
123
120
  httpRequest(req: HttpHostRequest): Promise<DataItem[]>;
124
121
  /** Invoke an MCP server tool. */
@@ -161,21 +158,11 @@ export interface ModelHostRequest {
161
158
  input: DataItem[];
162
159
  signal?: AbortSignal;
163
160
  }
164
- export interface ToolHostRequest {
165
- tool: string;
166
- args: Record<string, unknown>;
167
- /** True when this run's trigger is unattended — the host applies fine-grained audits (IT-7b). */
168
- unattended?: boolean;
169
- input: DataItem[];
170
- signal?: AbortSignal;
171
- }
172
161
  export interface HttpHostRequest {
173
162
  method: string;
174
163
  url: string;
175
164
  headers?: Record<string, string>;
176
165
  body?: unknown;
177
- /** Vault credential to inject as auth headers at execution time (D29; resolved host-side). */
178
- credentialId?: string;
179
166
  signal?: AbortSignal;
180
167
  }
181
168
  export interface McpHostRequest {
@@ -211,7 +198,7 @@ export interface ApprovalHostRequest {
211
198
  /** Deadline for a decision; default 24h. What happens at the deadline is timeoutAction (default reject). */
212
199
  timeoutMs?: number;
213
200
  /** Timeout policy (default "reject"): "reject" fails the node but ANNOUNCES it (not a silent auto-deny);
214
- * "approve" auto-continues; "keepPending" stays suspended (persisted; re-prompts on restart). */
201
+ * "approve" auto-continues; "keepPending" stays suspended in the current Gateway process only. */
215
202
  timeoutAction?: "approve" | "reject" | "keepPending";
216
203
  input: DataItem[];
217
204
  signal?: AbortSignal;
@@ -1,11 +1,8 @@
1
1
  /**
2
2
  * Node params schema — single source for "what params does each node kind take" (spec R6 / D45).
3
3
  *
4
- * Two schema sources, one resolver:
5
- * - tool / mcp → per-capability `paramsSchema` on the CapabilityEntry (the tool's own arg schema,
6
- * validates node.params.args).
7
- * - everything else (http/agent/channel/memory/if/filter/switch/transform/wait/...) → a per-KIND
8
- * schema here (KIND_PARAM_SCHEMAS), validates node.params directly.
4
+ * Each canonical node kind has one schema in KIND_PARAM_SCHEMAS. MCP tool argument schemas are
5
+ * attached to Agent plugins or canonical Action choices by Runtime's Host-owned catalog.
9
6
  *
10
7
  * The schemas are a JSON-Schema subset aligned with the canvas SchemaArgsForm consumer
11
8
  * (type/enum/default/minimum/maximum/multipleOf/format/x-widget). `required` mirrors what the REAL
@@ -19,7 +16,7 @@
19
16
  * not a hallucination) — surfaced by collectClarifications for the 待补 badge + activation gate.
20
17
  */
21
18
  import type { CapabilityEntry } from "./capability-catalog.js";
22
- /** Per-kind params schemas for non tool/mcp kinds. `trigger` (workflow-level trigger def) and
19
+ /** Per-kind params schemas. `trigger` (workflow-level trigger def) and
23
20
  * `manual` (n8n import placeholder that always fails) are intentionally excluded. */
24
21
  export declare const KIND_PARAM_SCHEMAS: Record<string, Record<string, unknown>>;
25
22
  /** An `__ASK__: 问题` sentinel — the agent honestly marking an unknown required value (AI-2).
@@ -31,13 +28,9 @@ type NodeLike = {
31
28
  params?: Record<string, unknown>;
32
29
  };
33
30
  /**
34
- * The schema that governs a node's params:
35
- * - tool → the tool capability's paramsSchema (governs params.args).
36
- * - mcp → the "server.tool" capability's paramsSchema (governs params.args).
37
- * - else → KIND_PARAM_SCHEMAS[kind] (governs params directly).
38
- * Returns undefined when no schema is known (e.g. a tool ref outside the catalog).
31
+ * Resolve the schema governing a canonical node's params.
39
32
  */
40
- export declare function resolveNodeParamsSchema(node: NodeLike, entries: CapabilityEntry[]): Record<string, unknown> | undefined;
33
+ export declare function resolveNodeParamsSchema(node: NodeLike, _entries: CapabilityEntry[]): Record<string, unknown> | undefined;
41
34
  /**
42
35
  * Validate every node's params against its resolved schema. Returns human-readable Chinese errors
43
36
  * (empty = clean). Skips `trigger` (trigger def is validated elsewhere) and `manual` (placeholder).
@@ -45,7 +38,7 @@ export declare function resolveNodeParamsSchema(node: NodeLike, entries: Capabil
45
38
  */
46
39
  export declare function validateParamsAgainstSchema(def: {
47
40
  nodes: NodeLike[];
48
- }, entries: CapabilityEntry[]): string[];
41
+ }, _entries: CapabilityEntry[]): string[];
49
42
  /**
50
43
  * Collect every `{{ __ASK__ }}` placeholder in a def (top-level params + one level into `args`).
51
44
  * Drives the canvas "待补" badge and the activation gate (a workflow with pending asks cannot be
@@ -69,9 +62,7 @@ export declare function collectClarifications(def: {
69
62
  question: string;
70
63
  }[];
71
64
  /**
72
- * Compact per-kind params hint for the AI graph-builder prompt, derived from KIND_PARAM_SCHEMAS
73
- * (single source — the prompt never hand-duplicates param names). tool/mcp carry per-capability
74
- * arg schemas (the agent reads them via list_capabilities), so they get a pointer not a field list.
65
+ * Compact per-kind params hint for the AI graph-builder prompt, derived from KIND_PARAM_SCHEMAS.
75
66
  */
76
67
  export declare function renderKindParamsForPrompt(): string;
77
68
  export {};
@@ -1,15 +1,13 @@
1
1
  /**
2
- * QlogicagentExecutorHost the REAL host backing host-executors (agent/tool/http/mcp/channel)
2
+ * QlogicagentExecutorHost backing canonical host executors and Runtime-injected Action nodes
3
3
  * with qlogicagent's actual capabilities. No mocks, no stubs (plan §1.5).
4
4
  *
5
5
  * Boundary capabilities (runAgent / invokeMcp / sendChannel) are injected so this file stays
6
- * decoupled from the handler host that owns Gateway delegation and the xiaozhiclaw channel
7
- * callback. Tool invocation goes straight through the single-source-of-truth tool registry
8
- * (`findTool`). fail-loud everywhere: unknown tool, missing channel host, or any rejection throws.
6
+ * decoupled from the Gateway Host. Missing capabilities and downstream rejections fail loudly.
9
7
  */
10
- import type { LLMTransport, RuntimeToolContract } from "../../runtime/ports/index.js";
8
+ import type { LLMTransport } from "../../runtime/ports/index.js";
11
9
  import { type DataItem } from "./data-item.js";
12
- import type { ExecutorHost, ToolHostRequest, MemoryHostRequest, SubworkflowHostRequest, ApprovalHostRequest, WebhookWaitHostRequest } from "./node-schema.js";
10
+ import type { ExecutorHost, MemoryHostRequest, SubworkflowHostRequest, ApprovalHostRequest, WebhookWaitHostRequest } from "./node-schema.js";
13
11
  /** Injected boundary capabilities — supplied by the handler host that owns the real runners. */
14
12
  export interface QlaExecutorHostDeps {
15
13
  /** Run one agent turn (spawn external ACP agent + sendTask). Returns the agent's text output. */
@@ -41,8 +39,6 @@ export interface QlaExecutorHostDeps {
41
39
  payload: unknown;
42
40
  signal?: AbortSignal;
43
41
  }) => Promise<unknown>;
44
- /** Tool lookup supplied by the runtime host. */
45
- findTool: (name: string) => RuntimeToolContract | undefined;
46
42
  /**
47
43
  * Project-scoped memory backend for the `memory` kind (spec D25). The handler host wires
48
44
  * the owning project root's memdir; absent → memory nodes fail-loud.
@@ -58,26 +54,7 @@ export interface QlaExecutorHostDeps {
58
54
  }>;
59
55
  /** D34 wait-until-webhook: suspend until the path is hit (handler owns the wake registry). */
60
56
  waitWebhook?: (req: WebhookWaitHostRequest) => Promise<Record<string, unknown>>;
61
- /**
62
- * IT-7b fine-grained unattended audit (unified permission engine's operation classifier).
63
- * Called for every tool invocation in an UNATTENDED run; throw to refuse (fail-loud).
64
- */
65
- auditUnattendedTool?: (req: ToolHostRequest) => void;
66
- /**
67
- * Vault credential → auth headers, resolved at EXECUTION time only (D29). Absent ⇒ http
68
- * nodes carrying credentialId fail-loud (never silently unauthenticated).
69
- */
70
- resolveCredentialHeaders?: (credentialId: string) => Record<string, string>;
71
57
  /** fetch impl; defaults to global fetch. Injectable for tests. */
72
58
  fetchImpl?: typeof fetch;
73
- /**
74
- * Owning workflow root (multi-root, R5):tool 节点的 cwd 必须钉在所属项目工作区。
75
- * in-process 工具注册表跟随 agent 的"活动项目"全局 cwd —— 不钉的话,项目 A 的
76
- * tool 节点会在项目 B 的目录里动文件(跨项目写,真机踩过:产物落错工作区)。
77
- * 注入方式 = exec 工具既有的 `workdir` 参数(作者显式指定时尊重);其余工具无
78
- * per-call cwd 通道,仍循全局 cwd —— 工作流里写文件的正路是 agent 节点(子进程
79
- * 带根 cwd)与 exec;若需全工具 cwd 线程化,另立决策改 RuntimeToolContract。
80
- */
81
- workspaceCwd?: string;
82
59
  }
83
60
  export declare function createQlaExecutorHost(deps: QlaExecutorHostDeps): ExecutorHost;
@@ -1,32 +1,18 @@
1
1
  /**
2
- * Portable workflow bundle (spec D23) THE single serialization format shared by
3
- * export / import / save-as(duplicate) / Hub publish / Hub apply. Two invariants:
4
- *
5
- * 1. SANITIZED: credentials never leave the machine inside a bundle. Any params key that
6
- * looks credential-shaped has its VALUE stripped and is recorded as a CredentialRequirement
7
- * the importer must re-bind. Unknown-but-suspicious shapes fail toward stripping (§1.5:
8
- * never silently carry a secret out).
9
- * 2. SELF-DESCRIBING: `requires` lists the capabilities (tool/agent/mcp/channel/skill) the
10
- * graph references, so an importer (or the Hub apply checklist) can verify bindings
11
- * BEFORE activating instead of failing mid-run.
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.
12
5
  */
13
6
  import { type WorkflowDef } from "./node-schema.js";
14
7
  import type { TriggerDef } from "./workflow-trigger.js";
15
8
  import type { ConcurrencyPolicy, WorkflowRecord } from "./workflow-store.js";
16
- export declare const WORKFLOW_BUNDLE_SCHEMA_VERSION = 2;
9
+ export declare const WORKFLOW_BUNDLE_SCHEMA_VERSION = 3;
17
10
  export interface CapabilityRequirement {
18
- category: "agent" | "tool" | "skill" | "mcp" | "memory" | "channel";
11
+ category: "agent" | "mcp" | "memory" | "channel";
19
12
  kind: string;
20
- /** Concrete capability reference (tool name / agent id / "server.tool" / channel name). */
13
+ /** Concrete capability reference, such as an Agent id or MCP plugin/tool id. */
21
14
  ref: string;
22
- /** Human-readable label shown in the apply/bind checklist. */
23
- label: string;
24
- nodeIds: string[];
25
- }
26
- export interface CredentialRequirement {
27
- /** Best-effort type hint; v1 marks all stripped values "custom" (vault types land in IT-7). */
28
- type: "apiKey" | "bearer" | "basic" | "oauth2" | "custom";
29
- /** Where the value was stripped from, e.g. `节点「发飞书」 params.headers.Authorization`. */
15
+ /** Human-readable label shown in the apply checklist. */
30
16
  label: string;
31
17
  nodeIds: string[];
32
18
  }
@@ -38,7 +24,6 @@ export interface WorkflowBundle {
38
24
  trigger?: TriggerDef;
39
25
  concurrency?: ConcurrencyPolicy;
40
26
  requires: CapabilityRequirement[];
41
- credentialsRequired: CredentialRequirement[];
42
27
  meta?: {
43
28
  author?: string;
44
29
  tags?: string[];
@@ -47,11 +32,9 @@ export interface WorkflowBundle {
47
32
  source?: "native" | "n8n";
48
33
  };
49
34
  }
50
- /** Placeholder left where a credential value was stripped (visibly broken > silently leaked). */
51
- export declare const STRIPPED_CREDENTIAL_PLACEHOLDER = "__CREDENTIAL_REQUIRED__";
52
- /** Derive the capability requirements a graph references (host-backed kinds only). */
35
+ /** Derive capability requirements from canonical Agent attachments and Action nodes. */
53
36
  export declare function deriveRequirements(def: WorkflowDef): CapabilityRequirement[];
54
- /** Serialize a stored record into a sanitized, self-describing portable bundle. */
37
+ /** Serialize a stored record into the canonical, credential-free bundle. */
55
38
  export declare function toWorkflowBundle(record: WorkflowRecord): WorkflowBundle;
56
39
  export interface ParsedBundle {
57
40
  name: string;
@@ -59,7 +42,6 @@ export interface ParsedBundle {
59
42
  trigger?: TriggerDef;
60
43
  concurrency?: ConcurrencyPolicy;
61
44
  requires: CapabilityRequirement[];
62
- credentialsRequired: CredentialRequirement[];
63
45
  }
64
- /** Parse + validate an incoming bundle payload. fail-loud on malformed shapes (§1.5). */
46
+ /** Parse and validate an incoming canonical bundle. */
65
47
  export declare function fromWorkflowBundle(payload: unknown): ParsedBundle;
@@ -1,7 +1,8 @@
1
1
  /**
2
- * Workflow Controller automation driver: create / run / pause / resume + concurrency (spec §B4/B5).
2
+ * Workflow Controller: reusable automation lifecycle and execution engine.
3
3
  *
4
- * Owns workflow lifecycle on top of the WorkflowStore (persistence) and WorkflowRuntime (execution).
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.
5
6
  * Concurrency (spec §B5): when a workflow is triggered while a previous run is still in-flight, the
6
7
  * record's `concurrency` policy decides:
7
8
  * - "skip" -> drop the new trigger (returns status "skipped")
@@ -29,6 +30,11 @@ export interface TriggerEvent {
29
30
  type: WorkflowTriggerKind;
30
31
  payload?: Record<string, unknown>;
31
32
  }
33
+ export interface WorkflowRunStarted {
34
+ workflowId: string;
35
+ runId: string;
36
+ triggerType: WorkflowTriggerKind;
37
+ }
32
38
  /**
33
39
  * Per-run context handed to the RuntimeFactory: the trigger KIND (so the factory can wire the D15
34
40
  * permission gate — unattended kinds are restricted) plus its payload (exposed to expressions).
@@ -130,9 +136,9 @@ export declare class WorkflowController {
130
136
  /** Load a single record or throw (fail-loud lookup; used by the scheduler to re-read triggers). */
131
137
  get(id: string): Promise<WorkflowRecord>;
132
138
  /**
133
- * Render a workflow as compact agent-context text (spec §B / §A `get`). Fail-loud on unknown id.
134
- * This is the engine half of the agent `workflow.get`/describe action: the agent reads this and
135
- * emits a WorkflowPatch against the shown `rev`.
139
+ * Render a workflow as compact planning context (spec §B / §A `get`). Fail-loud on unknown id.
140
+ * Runtime Host supplies the authoritative record; stateless planning may use this rendering to
141
+ * propose a WorkflowPatch against the shown `rev`.
136
142
  */
137
143
  describe(id: string, opts?: RenderOptions): Promise<string>;
138
144
  /**
@@ -150,11 +156,11 @@ export declare class WorkflowController {
150
156
  run(id: string, trigger?: TriggerEvent, opts?: {
151
157
  recordHistory?: boolean;
152
158
  reuseCache?: boolean;
159
+ onStarted?: (run: WorkflowRunStarted) => void | Promise<void>;
153
160
  }): Promise<RunOutcome>;
154
161
  /**
155
- * Wrap a run with durable history recording (when wired). Lives at this choke point —
156
- * not in the RPC handler so cron/IM/webhook runs are recorded identically to manual
157
- * ones. History writes are best-effort: a recording failure never blocks the run.
162
+ * Wrap a run with durable history recording (when wired). The running checkpoint is the
163
+ * publication barrier for lifecycle observers, and terminal history is fail-loud.
158
164
  */
159
165
  private recordRun;
160
166
  /** Cooperatively pause the in-flight run; it suspends before the next node (cache retained). */
@@ -7,7 +7,7 @@
7
7
  */
8
8
  export type WorkflowErrorClass = "user" | "capability" | "network" | "system";
9
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" | "open_credentials" | "swap_capability";
10
+ export type WorkflowErrorAction = "ai_fix" | "rerun_node" | "rerun_all" | "swap_capability";
11
11
  export interface WorkflowError {
12
12
  class: WorkflowErrorClass;
13
13
  /** Plain-language Chinese explanation (NO stack trace). */
@@ -10,7 +10,7 @@
10
10
  *
11
11
  * Determinism (§1.5): node order follows the def's node array (stable, persisted order); param
12
12
  * keys are sorted; expressions (`{{ }}`) render verbatim so the agent can copy them into bindings.
13
- * Large graphs truncate with an explicit hint to call `workflow.get` for the full definition.
13
+ * Large graphs truncate with an explicit hint to fetch the full definition from the Gateway Host.
14
14
  */
15
15
  import type { WorkflowDef } from "./node-schema.js";
16
16
  import type { TriggerDef } from "./workflow-patch.js";
@@ -1,11 +1,10 @@
1
1
  /**
2
- * In-process workflow trigger scheduler (plan M3 trigger layer).
2
+ * Reusable in-process Workflow trigger scheduler (plan M3 trigger layer).
3
3
  *
4
- * Architecture note: scheduling lives INSIDE qlogicagent, not the gateway. This mirrors the
5
- * established precedent the idle "dream" timer was deliberately moved out of the xiaozhiclaw gateway
6
- * into qlogicagent so the Agent owns its own timed lifecycle ("Agent 是唯一状态拥有者"). The gateway
7
- * remains a pure relay: it terminates external ingress (webhook HTTP, inbound IM) and forwards those
8
- * events here via `onWebhook` / `onImMessage`; the cron clock and the run decision are the Agent's.
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.
9
8
  *
10
9
  * The scheduler is the consumer of WorkflowController: on `start()` it loads every active workflow
11
10
  * (`listActive`, spec §B4 restart re-registration) and arms a timer per `schedule` trigger; on fire
@@ -35,7 +34,7 @@ export interface SchedulerDeps {
35
34
  * triggers (webhook/IM/manual) propagate their errors to the caller instead.
36
35
  */
37
36
  onError: (err: unknown, workflowId: string) => void;
38
- onRunStarted?: (workflowId: string, triggerType: string) => void;
37
+ onRunStarted?: (workflowId: string, triggerType: string, runId: string) => void | Promise<void>;
39
38
  onRunCompleted?: (outcome: RunOutcome, triggerType: string) => void;
40
39
  onRunFailed?: (workflowId: string, triggerType: string, err: unknown) => void;
41
40
  /**
@@ -96,7 +95,7 @@ export declare class WorkflowScheduler {
96
95
  * into the run payload so downstream nodes can reference `$trigger`.
97
96
  */
98
97
  onImMessage(channel: string, text: string, payload?: Record<string, unknown>): Promise<RunOutcome[]>;
99
- /** Manually trigger a single workflow (the agent's `workflow.run`). Errors propagate to caller. */
98
+ /** Manually trigger a single workflow for the owning Runtime Host. Errors propagate to caller. */
100
99
  triggerManual(id: string, payload?: Record<string, unknown>): Promise<RunOutcome>;
101
100
  private matchingIds;
102
101
  private registerTrigger;
@@ -108,4 +107,5 @@ export declare class WorkflowScheduler {
108
107
  */
109
108
  private passesRateLimit;
110
109
  private runWithLifecycle;
110
+ private reportLifecycleCallbackError;
111
111
  }
@@ -1,10 +1,9 @@
1
1
  /**
2
- * Workflow Store persist workflow definitions + lifecycle state to disk (spec §B4).
2
+ * Workflow Store: project-scoped persistence used by Runtime's Gateway Workflow Host.
3
3
  *
4
- * Stored at `<project>/.qlogicagent/workflows/<workflowId>/workflow.json`. Listing enumerates
5
- * subdirectories (mirrors product-persistence.ts). The store is the single source of truth for a
6
- * workflow's definition, its active flag, and its concurrency policy; the gateway re-registers
7
- * triggers for every active workflow on restart (spec §B4).
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.
8
7
  *
9
8
  * fail-loud: missing id on save throws; load returns undefined only for a genuinely absent record.
10
9
  */
@@ -15,10 +14,10 @@ export type ConcurrencyPolicy = "queue" | "skip" | "parallel";
15
14
  export interface WorkflowRecord {
16
15
  id: string;
17
16
  name: string;
18
- /** Owning user (llmrouter id via resolveActiveOwnerUserId, D38). Absent on legacy records. */
17
+ /** Owning user, resolved by the Runtime Host. */
19
18
  owner?: string;
20
19
  def: WorkflowDef;
21
- /** Active workflows have their triggers registered by the gateway (spec §B4). */
20
+ /** Active workflows have their triggers registered by the Runtime Gateway Host. */
22
21
  active: boolean;
23
22
  concurrency: ConcurrencyPolicy;
24
23
  /** The workflow's trigger (set via a WorkflowPatch set_trigger op; spec §C/D7). */
@@ -75,7 +74,7 @@ export declare class WorkflowStore {
75
74
  /** Load a record or throw (fail-loud lookup for callers that require existence). */
76
75
  require(id: string): Promise<WorkflowRecord>;
77
76
  list(): Promise<WorkflowRecord[]>;
78
- /** Active workflows the gateway must re-register triggers for after a restart (spec §B4). */
77
+ /** Active workflows the Runtime Gateway Host re-registers when the project service starts. */
79
78
  listActive(): Promise<WorkflowRecord[]>;
80
79
  delete(id: string): Promise<void>;
81
80
  }