qlogicagent 2.12.7 → 2.12.9

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 (106) hide show
  1. package/README.md +91 -157
  2. package/dist/agent.js +6 -6
  3. package/dist/cli.js +411 -426
  4. package/dist/index.js +410 -425
  5. package/dist/orchestration.js +6 -6
  6. package/dist/protocol.js +1 -1
  7. package/dist/types/agent/memory-recall-injection.d.ts +34 -0
  8. package/dist/types/agent/tool-loop/budget-continuation-policy.d.ts +22 -0
  9. package/dist/types/agent/tool-loop/completion-action-policy.d.ts +19 -0
  10. package/dist/types/agent/tool-loop/completion-stop-policy.d.ts +19 -0
  11. package/dist/types/agent/tool-loop/compression-pipeline.d.ts +44 -0
  12. package/dist/types/agent/tool-loop/skill-instruction-policy.d.ts +7 -0
  13. package/dist/types/agent/tool-loop/stream-error-recovery.d.ts +59 -0
  14. package/dist/types/agent/tool-loop/tool-failure-policy.d.ts +22 -0
  15. package/dist/types/agent/types.d.ts +2 -2
  16. package/dist/types/cli/acp-message-router.d.ts +8 -0
  17. package/dist/types/cli/acp-session-host.d.ts +20 -4
  18. package/dist/types/cli/cli-agent-builder.d.ts +1 -1
  19. package/dist/types/cli/core-tool-coordinator.d.ts +1 -0
  20. package/dist/types/cli/core-tools/config-tool-bootstrap.d.ts +1 -5
  21. package/dist/types/cli/core-tools/config-tool-service.d.ts +9 -5
  22. package/dist/types/cli/core-tools/registry.d.ts +1 -2
  23. package/dist/types/cli/core-tools/session-tool-manifest.d.ts +11 -0
  24. package/dist/types/cli/core-tools/team-registry.d.ts +8 -8
  25. package/dist/types/cli/core-tools/team-tool-service.d.ts +6 -3
  26. package/dist/types/cli/dev-tools/dev-tool-registry.d.ts +1 -2
  27. package/dist/types/cli/gateway-rpc-connection.d.ts +50 -0
  28. package/dist/types/cli/handlers/session-handler.d.ts +2 -1
  29. package/dist/types/cli/handlers/workflow-handler.d.ts +10 -0
  30. package/dist/types/cli/model-client-resolver.d.ts +12 -3
  31. package/dist/types/cli/resolved-agent-cache.d.ts +47 -0
  32. package/dist/types/cli/rpc-registry.d.ts +59 -5
  33. package/dist/types/cli/session-context.d.ts +32 -0
  34. package/dist/types/cli/skill-meta-tool-bootstrap.d.ts +7 -0
  35. package/dist/types/cli/stdio-acp-protocol-coordinator.d.ts +18 -0
  36. package/dist/types/cli/stdio-acp-request-host.d.ts +3 -0
  37. package/dist/types/cli/stdio-rpc-handler-hosts.d.ts +50 -0
  38. package/dist/types/cli/stdio-server.d.ts +103 -178
  39. package/dist/types/cli/stdio-session-runtime-coordinator.d.ts +19 -0
  40. package/dist/types/cli/tool-bootstrap-core-registration.d.ts +30 -0
  41. package/dist/types/cli/tool-bootstrap-media-registration.d.ts +8 -0
  42. package/dist/types/cli/tool-bootstrap-paths.d.ts +7 -0
  43. package/dist/types/cli/tool-bootstrap-web-registration.d.ts +13 -0
  44. package/dist/types/cli/tool-bootstrap-workflow-registration.d.ts +7 -0
  45. package/dist/types/cli/tool-bootstrap.d.ts +5 -22
  46. package/dist/types/cli/tunable-store.d.ts +26 -0
  47. package/dist/types/cli/workflow-host-adapter.d.ts +29 -0
  48. package/dist/types/contracts/hooks.d.ts +6 -0
  49. package/dist/types/orchestration/workflow/run-history-store.d.ts +58 -0
  50. package/dist/types/orchestration/workflow/workflow-controller.d.ts +23 -1
  51. package/dist/types/orchestration/workflow/workflow-store.d.ts +24 -0
  52. package/dist/types/protocol/wire/acp-protocol.d.ts +1 -2
  53. package/dist/types/protocol/wire/gateway-rpc.d.ts +0 -112
  54. package/dist/types/runtime/config/tunable-defaults.d.ts +6 -0
  55. package/dist/types/runtime/infra/agent-paths.d.ts +0 -2
  56. package/dist/types/runtime/infra/agent-process.d.ts +12 -9
  57. package/dist/types/runtime/infra/default-path-service.d.ts +0 -1
  58. package/dist/types/runtime/infra/index.d.ts +1 -1
  59. package/dist/types/runtime/infra/key-pool.d.ts +1 -0
  60. package/dist/types/runtime/infra/llmrouter-catalog.d.ts +8 -0
  61. package/dist/types/runtime/ports/path-service.d.ts +0 -1
  62. package/dist/types/runtime/ports/tool-contracts.d.ts +1 -1
  63. package/dist/types/runtime/prompt/environment-context.d.ts +13 -0
  64. package/dist/types/runtime/prompt/index.d.ts +1 -0
  65. package/dist/types/runtime/prompt/prompt-policy.d.ts +2 -0
  66. package/dist/types/runtime/prompt/system-prompt-sections.d.ts +2 -0
  67. package/dist/types/runtime/session/session-catalog.d.ts +4 -0
  68. package/dist/types/runtime/session/session-metadata-store.d.ts +8 -0
  69. package/dist/types/runtime/session/session-paths.d.ts +9 -0
  70. package/dist/types/runtime/session/session-persistence.d.ts +14 -159
  71. package/dist/types/runtime/session/session-resume.d.ts +4 -0
  72. package/dist/types/runtime/session/session-schema.d.ts +10 -0
  73. package/dist/types/runtime/session/session-summary.d.ts +5 -0
  74. package/dist/types/runtime/session/session-transcript-store.d.ts +13 -0
  75. package/dist/types/runtime/session/session-types.d.ts +77 -0
  76. package/dist/types/runtime/session/session-write-queue.d.ts +2 -0
  77. package/dist/types/runtime/tasks/task-types.d.ts +1 -1
  78. package/dist/types/skills/mcp/index.d.ts +1 -3
  79. package/dist/types/skills/mcp/mcp-manager.d.ts +14 -38
  80. package/dist/types/skills/permissions/rule-engine.d.ts +1 -0
  81. package/dist/types/skills/plugins/plugin-api.d.ts +0 -1
  82. package/dist/types/skills/plugins/plugin-loader.d.ts +0 -4
  83. package/dist/types/skills/portable-tool.d.ts +2 -2
  84. package/dist/types/skills/tools/config-tool.d.ts +1 -3
  85. package/dist/types/skills/tools/skill-tool.d.ts +2 -2
  86. package/dist/types/skills/tools/team-tool.d.ts +44 -4
  87. package/dist/types/skills/tools/tool-search-tool.d.ts +11 -0
  88. package/package.json +3 -2
  89. package/dist/types/assistants/assistant-registry.d.ts +0 -4
  90. package/dist/types/assistants/assistant-store.d.ts +0 -23
  91. package/dist/types/assistants/assistant-turn-context.d.ts +0 -20
  92. package/dist/types/assistants/assistant-types.d.ts +0 -38
  93. package/dist/types/assistants/plugin-assistant-registry.d.ts +0 -16
  94. package/dist/types/cli/core-tools/utility-tool-bootstrap.d.ts +0 -12
  95. package/dist/types/cli/dev-tools/repl-tool-service.d.ts +0 -5
  96. package/dist/types/cli/handlers/assistants-handler.d.ts +0 -13
  97. package/dist/types/skills/mcp/mcp-http-client.d.ts +0 -68
  98. package/dist/types/skills/mcp/mcp-stdio-client.d.ts +0 -86
  99. package/dist/types/skills/think-tool.d.ts +0 -16
  100. package/dist/types/skills/tools/apply-patch-tool.d.ts +0 -29
  101. package/dist/types/skills/tools/mcp-client-types.d.ts +0 -269
  102. package/dist/types/skills/tools/mcp-resource-tools.d.ts +0 -14
  103. package/dist/types/skills/tools/mcp-tool.d.ts +0 -249
  104. package/dist/types/skills/tools/project-switch-tool.d.ts +0 -24
  105. package/dist/types/skills/tools/repl-tool.d.ts +0 -70
  106. package/dist/types/skills/tools/send-message-tool.d.ts +0 -57
@@ -23,6 +23,7 @@ import type { WorkflowDef } from "./node-schema.js";
23
23
  import { type PatchEnvelope, type WorkflowPatch } from "./workflow-patch.js";
24
24
  import { type RenderOptions } from "./workflow-render.js";
25
25
  import { WorkflowStore, type ConcurrencyPolicy, type WorkflowRecord } from "./workflow-store.js";
26
+ import { type WorkflowRunHistoryStore } from "./run-history-store.js";
26
27
  export interface TriggerEvent {
27
28
  type: WorkflowTriggerKind;
28
29
  payload?: Record<string, unknown>;
@@ -46,6 +47,8 @@ export interface RunOutcome {
46
47
  status: "completed" | "failed" | "paused" | "skipped";
47
48
  /** Absent when status === "skipped" (a busy run under the "skip" policy). */
48
49
  result?: RunResult;
50
+ /** Durable run-history id (present when a run-history store is wired). */
51
+ runId?: string;
49
52
  }
50
53
  export interface CreateInput {
51
54
  id: string;
@@ -68,11 +71,24 @@ export type PatchOutcome = {
68
71
  export declare class WorkflowController {
69
72
  private readonly store;
70
73
  private readonly runtimeFactory;
74
+ /** Optional durable run-history recorder. Wired here (not the handler) so every
75
+ * trigger path — manual RPC, cron scheduler, IM, webhook — is captured alike. */
76
+ private readonly runHistory?;
71
77
  private readonly slots;
72
- constructor(store: WorkflowStore, runtimeFactory: RuntimeFactory);
78
+ constructor(store: WorkflowStore, runtimeFactory: RuntimeFactory,
79
+ /** Optional durable run-history recorder. Wired here (not the handler) so every
80
+ * trigger path — manual RPC, cron scheduler, IM, webhook — is captured alike. */
81
+ runHistory?: WorkflowRunHistoryStore | undefined);
73
82
  create(input: CreateInput): Promise<WorkflowRecord>;
74
83
  update(id: string, patch: Partial<Pick<WorkflowRecord, "name" | "def" | "concurrency" | "active">>): Promise<WorkflowRecord>;
75
84
  setActive(id: string, active: boolean): Promise<WorkflowRecord>;
85
+ /**
86
+ * Revert a workflow to a stored revision snapshot (undo 基座). Git-revert semantics:
87
+ * the snapshot's def/name/trigger are re-applied as a NEW revision (rev bumps), so
88
+ * history stays forward-only and optimistic-concurrency baseRev checks keep working.
89
+ * fail-loud: unknown id or pruned/absent revision throws.
90
+ */
91
+ revertTo(id: string, rev: number): Promise<WorkflowRecord>;
76
92
  /**
77
93
  * Import an n8n workflow JSON (read-format only, plan M5 §2.1) into the single store. Converts
78
94
  * via the deterministic translator then routes through `create`, so the graph passes the same
@@ -102,6 +118,12 @@ export declare class WorkflowController {
102
118
  patch(id: string, env: PatchEnvelope): Promise<PatchOutcome>;
103
119
  /** Trigger a run, honoring the workflow's concurrency policy (spec §B5). */
104
120
  run(id: string, trigger?: TriggerEvent): Promise<RunOutcome>;
121
+ /**
122
+ * Wrap a run with durable history recording (when wired). Lives at this choke point —
123
+ * not in the RPC handler — so cron/IM/webhook runs are recorded identically to manual
124
+ * ones. History writes are best-effort: a recording failure never blocks the run.
125
+ */
126
+ private recordRun;
105
127
  /** Cooperatively pause the in-flight run; it suspends before the next node (cache retained). */
106
128
  pause(id: string): void;
107
129
  /** Resume a paused workflow: re-run the same runtime so cached nodes hit and only the
@@ -26,10 +26,34 @@ export interface WorkflowRecord {
26
26
  createdAt: string;
27
27
  updatedAt: string;
28
28
  }
29
+ /** Root dir of all workflow records for a project (shared with the run-history store). */
30
+ export declare function workflowsDir(cwd: string): string;
31
+ /** Bounded def-revision history depth — enough for undo, small enough to never matter on disk. */
32
+ export declare const MAX_REVISIONS = 20;
33
+ /** Summary row for revision lists (full snapshot stays behind loadRevision). */
34
+ export interface RevisionSummary {
35
+ rev: number;
36
+ updatedAt: string;
37
+ name: string;
38
+ nodeCount: number;
39
+ }
29
40
  export declare class WorkflowStore {
30
41
  private readonly cwd;
31
42
  constructor(cwd: string);
32
43
  save(record: WorkflowRecord): Promise<void>;
44
+ /**
45
+ * Persist a per-rev snapshot alongside the live record (undo/revert 基座).
46
+ * Keyed by rev: a meta-only update (same rev, e.g. setActive) overwrites its own
47
+ * snapshot; a patch (rev bump) appends a new one. Bounded to MAX_REVISIONS.
48
+ * fail-soft: snapshot/prune errors must never block the primary save.
49
+ */
50
+ private snapshotRevision;
51
+ /** Revision numbers, newest first. */
52
+ private revisionNumbers;
53
+ /** Newest-first revision summaries for the undo/history UI. */
54
+ listRevisions(id: string): Promise<RevisionSummary[]>;
55
+ /** Full record snapshot at a given rev (undefined when pruned/absent). */
56
+ loadRevision(id: string, rev: number): Promise<WorkflowRecord | undefined>;
33
57
  load(id: string): Promise<WorkflowRecord | undefined>;
34
58
  /** Load a record or throw (fail-loud lookup for callers that require existence). */
35
59
  require(id: string): Promise<WorkflowRecord>;
@@ -106,7 +106,6 @@ export interface AcpSessionMeta {
106
106
  sessionType?: string;
107
107
  groupKey?: string;
108
108
  groupName?: string;
109
- assistantId?: string;
110
109
  permissions?: Record<string, unknown>;
111
110
  reasoning?: {
112
111
  effort?: string;
@@ -158,7 +157,7 @@ export interface AcpSessionPromptParams {
158
157
  sessionId: string;
159
158
  /** User prompt content blocks (standard ACP field). */
160
159
  prompt: AcpContentBlock[];
161
- /** Per-turn context overrides (assistantId/permissions/reasoning/mcpServers/...), merged over session _meta. */
160
+ /** Per-turn context overrides (permissions/reasoning/mcpServers/...), merged over session _meta. */
162
161
  _meta?: AcpSessionMeta;
163
162
  }
164
163
  export interface AcpSessionPromptResult {
@@ -74,54 +74,6 @@ export interface MemoryConsolidationResult {
74
74
  claimIds?: string[];
75
75
  conflictIds?: string[];
76
76
  }
77
- export interface AssistantPromptTemplateWire {
78
- id: string;
79
- title: string;
80
- titleI18n?: Record<string, string>;
81
- description?: string;
82
- descriptionI18n?: Record<string, string>;
83
- prompt: string;
84
- promptI18n?: Record<string, string>;
85
- icon?: string;
86
- }
87
- export interface AssistantPresetWire {
88
- kind: "assistant-preset";
89
- id: string;
90
- source: "builtin" | "user" | "plugin";
91
- name: string;
92
- nameI18n?: Record<string, string>;
93
- description?: string;
94
- descriptionI18n?: Record<string, string>;
95
- avatar?: string;
96
- enabled: boolean;
97
- sortOrder: number;
98
- enabledSkills: string[];
99
- disabledBuiltinSkills: string[];
100
- context?: string;
101
- prompts: AssistantPromptTemplateWire[];
102
- modelHints: string[];
103
- pluginId?: string;
104
- readonly?: boolean;
105
- }
106
- export interface PluginAssistantDiagnosticWire {
107
- pluginId: string;
108
- manifestPath?: string;
109
- severity: "error" | "warning";
110
- message: string;
111
- assistantId?: string;
112
- }
113
- export interface AssistantRuntimeContextWire {
114
- assistantId: string;
115
- context?: string;
116
- enabledSkillNames: string[];
117
- disabledBuiltinSkillNames: string[];
118
- modelHints: string[];
119
- prompts: AssistantPromptTemplateWire[];
120
- }
121
- export type AssistantPresetInputWire = Partial<AssistantPresetWire> & {
122
- name: string;
123
- prompts: AssistantPromptTemplateWire[];
124
- };
125
77
  export interface GatewayRpcMethodMap {
126
78
  "agent.health": {
127
79
  params: {};
@@ -504,70 +456,6 @@ export interface GatewayRpcMethodMap {
504
456
  }>;
505
457
  };
506
458
  };
507
- "assistants.list": {
508
- params: {};
509
- result: {
510
- assistants: AssistantPresetWire[];
511
- diagnostics?: PluginAssistantDiagnosticWire[];
512
- };
513
- };
514
- "assistants.resolve": {
515
- params: {
516
- assistantId: string;
517
- };
518
- result: AssistantRuntimeContextWire;
519
- };
520
- "assistants.cloneBuiltin": {
521
- params: {
522
- assistantId: string;
523
- };
524
- result: {
525
- assistant: AssistantPresetWire;
526
- };
527
- };
528
- "assistants.upsert": {
529
- params: {
530
- assistant: AssistantPresetInputWire;
531
- };
532
- result: {
533
- assistant: AssistantPresetWire;
534
- };
535
- };
536
- "assistants.create": {
537
- params: {
538
- assistant: AssistantPresetInputWire;
539
- };
540
- result: {
541
- assistant: AssistantPresetWire;
542
- };
543
- };
544
- "assistants.update": {
545
- params: {
546
- assistant: AssistantPresetInputWire;
547
- };
548
- result: {
549
- assistant: AssistantPresetWire;
550
- };
551
- };
552
- "assistants.delete": {
553
- params: {
554
- assistantId: string;
555
- };
556
- result: {
557
- ok: boolean;
558
- };
559
- };
560
- "assistants.setState": {
561
- params: {
562
- assistantId: string;
563
- enabled?: boolean;
564
- sortOrder?: number;
565
- modelHints?: string[];
566
- };
567
- result: {
568
- assistant: AssistantPresetWire;
569
- };
570
- };
571
459
  "memory.list-files": {
572
460
  params: {
573
461
  projectId?: string;
@@ -241,6 +241,12 @@ export interface TunableDefaults {
241
241
  dreamCooldownMs: number;
242
242
  dreamMaxDurationMs: number;
243
243
  teamBudgetTokens: number;
244
+ braveApiKey: string;
245
+ exaApiKey: string;
246
+ serperApiKey: string;
247
+ searxngBaseUrl: string;
248
+ crawl4aiBaseUrl: string;
249
+ searchSvcBaseUrl: string;
244
250
  }
245
251
  /**
246
252
  * Snapshot of all current tunable values.
@@ -37,8 +37,6 @@ export declare function getUserPluginCacheDir(): string;
37
37
  export declare function getUserMcpConfigPath(): string;
38
38
  /** `~/.qlogicagent/profiles/<owner>/marketplace.json` */
39
39
  export declare function getUserMarketplaceConfigPath(): string;
40
- /** `~/.qlogicagent/profiles/<owner>/assistant-presets.json` */
41
- export declare function getUserAssistantPresetsPath(): string;
42
40
  /** `~/.qlogicagent/profiles/<owner>/workflows/` */
43
41
  export declare function getUserWorkflowsDir(): string;
44
42
  /** `~/.qlogicagent/profiles/<owner>/INSTRUCTIONS.md` */
@@ -29,11 +29,20 @@ export interface AgentProcessConfig {
29
29
  env?: Record<string, string>;
30
30
  /** Agent type hint for the child (sets system prompt behavior). */
31
31
  agentType?: string;
32
- /** Model override for the child. */
32
+ /**
33
+ * Standing LLM config for an internal child. Pushed via session/set_config_option
34
+ * right after session/new so every turn (initial task, team send replies)
35
+ * resolves provider/model/apiKey explicitly. A standalone child has no llmrouter
36
+ * directory to hydrate a model catalog from — without this push its first turn
37
+ * dies with NO_PROVIDER. provider+apiKey are what the child's turn resolution
38
+ * requires (resolveTextGenerationConfig); model rides along for determinism.
39
+ */
40
+ provider?: string;
41
+ /** Model for the child's turns (see provider). */
33
42
  model?: string;
34
- /** API key (forwarded via env). */
43
+ /** API key for the child's turns (see provider). */
35
44
  apiKey?: string;
36
- /** Base URL for LLM API. */
45
+ /** Base URL for the child's LLM API (see provider). */
37
46
  baseUrl?: string;
38
47
  /** Enable verbose logging in child. */
39
48
  verbose?: boolean;
@@ -159,9 +168,6 @@ export declare class AgentProcessManager {
159
168
  * Returns the JSON-RPC result (content/usage carried on the response).
160
169
  */
161
170
  sendTask(memberId: string, prompt: string, options?: {
162
- model?: string;
163
- apiKey?: string;
164
- baseUrl?: string;
165
171
  sessionId?: string;
166
172
  timeout?: number;
167
173
  }): Promise<unknown>;
@@ -181,9 +187,6 @@ export declare class AgentProcessManager {
181
187
  * `pingTimeout`, the task is considered failed.
182
188
  */
183
189
  sendTaskAsync(memberId: string, prompt: string, options?: {
184
- model?: string;
185
- apiKey?: string;
186
- baseUrl?: string;
187
190
  sessionId?: string;
188
191
  /** Total timeout for the task (default: unlimited, 0 = no timeout) */
189
192
  timeout?: number;
@@ -23,7 +23,6 @@ export declare class DefaultPathService implements PathService {
23
23
  getUserMcpConfigPath(): string;
24
24
  getUserPluginCacheDir(): string;
25
25
  getUserMarketplaceConfigPath(): string;
26
- getUserAssistantPresetsPath(): string;
27
26
  getProjectAgentDir(projectRoot?: string): string;
28
27
  getProjectSettingsPath(projectRoot?: string): string;
29
28
  getProjectInstructionsPath(projectRoot?: string): string;
@@ -1,4 +1,4 @@
1
- export { AGENT_DOT_DIR, getUserAgentHome, getUserCredentialsPath, getUserPluginsDir, getUserSkillsDir, getUserSettingsPath, getUserCacheDir, getUserDebugLogsDir, getUserPluginCacheDir, getUserMcpConfigPath, getUserMarketplaceConfigPath, getUserAssistantPresetsPath, getUserWorkflowsDir, getProjectAgentDir, getProjectWorkflowsDir, getProjectPluginsDir, getProjectSkillManifestPath, getProjectSettingsPath, getProjectInstructionsPath, getProjectRulesDir, getGitRootHooksDir, } from "./agent-paths.js";
1
+ export { AGENT_DOT_DIR, getUserAgentHome, getUserCredentialsPath, getUserPluginsDir, getUserSkillsDir, getUserSettingsPath, getUserCacheDir, getUserDebugLogsDir, getUserPluginCacheDir, getUserMcpConfigPath, getUserMarketplaceConfigPath, getUserWorkflowsDir, getProjectAgentDir, getProjectWorkflowsDir, getProjectPluginsDir, getProjectSkillManifestPath, getProjectSettingsPath, getProjectInstructionsPath, getProjectRulesDir, getGitRootHooksDir, } from "./agent-paths.js";
2
2
  export { getBudgetContinuationMessage } from "./token-budget.js";
3
3
  export { type SecureStorage, saveApiKey, loadApiKey } from "./secure-storage.js";
4
4
  export { ProjectInstructionsStore, type InstructionFile } from "./project-instructions-store.js";
@@ -117,5 +117,6 @@ export declare class KeyPool {
117
117
  private weightedRandom;
118
118
  private leastBusy;
119
119
  private pruneWindow;
120
+ private pruneTokenWindow;
120
121
  private buildPoolStatus;
121
122
  }
@@ -71,6 +71,14 @@ export declare function refreshRegistryFromLlmrouterApiKey(registry: ModelRegist
71
71
  forceCatalog?: boolean;
72
72
  }): Promise<ModelEntry[]>;
73
73
  export declare function resetLlmrouterCatalogClientCache(): void;
74
+ /**
75
+ * 零配置默认模型:全新安装(无 textGeneration binding)且网关注入了设备账号推理 key 时,
76
+ * 自动把默认文本模型设为一个 DeepSeek(经 llmrouter)。调用方需先刷新过目录(this.models 里要有
77
+ * `llmrouter:deepseek-*` 条目)。已有 binding 则尊重用户配置、不覆盖。返回是否设置了默认。
78
+ *
79
+ * key 不在此注册 —— ModelRegistry 取 llmrouter key 时会回退到 QLOGIC_LLMROUTER_INFERENCE_KEY env。
80
+ */
81
+ export declare function ensureLlmrouterDefaultBinding(registry: ModelRegistry, configPort?: ConfigPort): boolean;
74
82
  export declare function toModelEntry(model: LlmrouterCatalogModel): ModelEntry | null;
75
83
  export declare function toModelEntries(model: LlmrouterCatalogModel): ModelEntry[];
76
84
  export {};
@@ -22,7 +22,6 @@ export interface PathService {
22
22
  getUserMcpConfigPath(): string;
23
23
  getUserPluginCacheDir(): string;
24
24
  getUserMarketplaceConfigPath(): string;
25
- getUserAssistantPresetsPath(): string;
26
25
  getProjectAgentDir(projectRoot?: string): string;
27
26
  getProjectSettingsPath(projectRoot?: string): string;
28
27
  getProjectInstructionsPath(projectRoot?: string): string;
@@ -78,7 +78,7 @@ export interface ToolBootstrapProvider {
78
78
  kind?: ToolRegistrationModuleKind;
79
79
  register(tools: RuntimeToolContract[], context: ToolBootstrapProviderContext): void;
80
80
  }
81
- export type ToolRegistrationModuleKind = "core" | "dev" | "mcp" | "plugin" | "skill" | "local" | "media" | "compat";
81
+ export type ToolRegistrationModuleKind = "core" | "dev" | "web" | "mcp" | "plugin" | "skill" | "local" | "media" | "workflow" | "compat";
82
82
  export interface ToolRegistrationModule<TContext extends object = Record<string, unknown>> {
83
83
  id: string;
84
84
  kind: ToolRegistrationModuleKind;
@@ -35,6 +35,19 @@ export declare function createTaskGuidanceSection(domain?: TaskDomain): SystemPr
35
35
  * Tells the LLM when to use specialized tools vs. primitives.
36
36
  */
37
37
  export declare function createToolGuidanceSection(): SystemPromptSection;
38
+ /**
39
+ * Index of deferred tools so the model KNOWS these capabilities exist even
40
+ * though their schemas are not loaded. Without this the model sees only the
41
+ * non-deferred tool list and will wrongly claim it lacks e.g. video generation.
42
+ *
43
+ * Volatile (recomputed each turn) because the deferred set can change when
44
+ * dynamic registrations (MCP, session bootstrap) land; the rendered text is
45
+ * stable across turns otherwise, so prompt cache is preserved in practice.
46
+ */
47
+ export declare function createDeferredToolIndexSection(listDeferredTools: () => Array<{
48
+ name: string;
49
+ description: string;
50
+ }>): SystemPromptSection;
38
51
  /**
39
52
  * Create a system prompt section that instructs the model on response language.
40
53
  * CC parity: only injected when language is explicitly set; when absent,
@@ -1,4 +1,5 @@
1
1
  export { assembleSystemPrompt, clearSystemPromptSections, systemPromptSection, type SystemPromptSection, } from "./system-prompt-sections.js";
2
+ export { PROMPT_POLICY_VERSION, createPromptPolicyHeader } from "./prompt-policy.js";
2
3
  export { getInstructions, buildInstructionsPrompt, resetInstructionCache, } from "./instruction-loader.js";
3
4
  export { createEnvironmentContextSection, createTaskGuidanceSection, createToolGuidanceSection, createLanguageSection } from "./environment-context.js";
4
5
  export { detectTaskDomain, resolveTaskDomain, loadProjectTaskDomain, persistTaskDomain, shouldPersistDomain, type TaskDomain, type DomainResolutionContext } from "./task-domain.js";
@@ -0,0 +1,2 @@
1
+ export declare const PROMPT_POLICY_VERSION = 1;
2
+ export declare function createPromptPolicyHeader(version?: number): string;
@@ -39,6 +39,8 @@ export declare function resolveSystemPromptSections(sections: SystemPromptSectio
39
39
  */
40
40
  export declare function clearSystemPromptSections(): void;
41
41
  export interface SystemPromptAssemblyOptions {
42
+ /** Include the current prompt policy version header. Defaults to true. */
43
+ includePromptPolicy?: boolean;
42
44
  /** Base system prompt (from Gateway config) */
43
45
  basePrompt?: string;
44
46
  /** Prepended instruction block (from INSTRUCTIONS.md files) */
@@ -0,0 +1,4 @@
1
+ import type { SessionListEntry } from "./session-types.js";
2
+ export declare function listSessions(limit: number | undefined, projectRoot: string): Promise<SessionListEntry[]>;
3
+ export declare function deleteSession(sessionId: string, projectRoot: string): Promise<void>;
4
+ export declare function pruneOldSessions(projectRoot: string): Promise<number>;
@@ -0,0 +1,8 @@
1
+ import type { SessionMetadata, SessionMetadataPatch, SessionStateSaveMetadata, SessionUsageSnapshot } from "./session-types.js";
2
+ export declare function getSessionMetadata(sessionId: string, projectRoot: string): SessionMetadata | null;
3
+ export declare function readSessionMetadata(sessionId: string, projectRoot: string, defaults?: {
4
+ messageCount?: number;
5
+ }): Promise<SessionMetadata>;
6
+ export declare function saveSessionState(sessionId: string, usageSnapshot: SessionUsageSnapshot, metadata: SessionStateSaveMetadata, projectRoot: string): Promise<void>;
7
+ export declare function updateSessionMetadata(sessionId: string, patch: SessionMetadataPatch, projectRoot: string): Promise<SessionMetadata | null>;
8
+ export declare function persistTaskSummary(sessionId: string, projectRoot: string, summary: string, generatedAtTurn: number): Promise<void>;
@@ -0,0 +1,9 @@
1
+ export declare const TRANSCRIPT_FILE = "transcript.jsonl";
2
+ export declare const METADATA_FILE = "metadata.json";
3
+ export declare const LEGACY_STATE_FILE = "state.json";
4
+ export declare function sanitizeSessionId(sessionId: string): string;
5
+ export declare function getSessionsRoot(projectRoot: string): string;
6
+ export declare function getSessionDir(sessionId: string, projectRoot: string): string;
7
+ export declare function getMetadataPath(sessionId: string, projectRoot: string): string;
8
+ export declare function getTranscriptPath(sessionId: string, projectRoot: string): string;
9
+ export declare function findExistingSessionDir(sessionId: string, projectRoot: string): string | undefined;
@@ -1,161 +1,16 @@
1
1
  /**
2
- * Session Persistence CC sessionRestore.ts + conversationRecovery.ts parity.
2
+ * Compatibility facade for session persistence.
3
3
  *
4
- * Enables conversation resume by persisting:
5
- * 1. Message transcript (JSONL-based, append-only)
6
- * 2. Session metadata (flat JSON, atomic write)
7
- *
8
- * Storage layout (ALL data lives under project workspace, NEVER global):
9
- * <project>/.qlogicagent/sessions/<session-id>/
10
- * transcript.jsonl — append-only message log
11
- * metadata.json — flat session metadata + usage stats
12
- *
13
- * Resume flow (CC processResumedConversation parity):
14
- * 1. loadSessionForResume(sessionId) messages + metadata
15
- * 2. Restore usage state into SessionState
16
- * 3. Feed messages as initial context to agent
17
- */
18
- import type { ChatMessage } from "../../protocol/wire/index.js";
19
- import type { TokenUsage } from "../../agent/types.js";
20
- import type { SessionUsageSnapshot } from "./session-state.js";
21
- export interface SessionMetadata {
22
- sessionId: string;
23
- projectId: string;
24
- createdAt: string;
25
- lastActiveAt: string;
26
- model?: string;
27
- /** Agent that owns this session (e.g. "qlogicagent", "codex"). Locked on the first message so
28
- * re-entering the session always resumes with the same agent, never falling back to default. */
29
- agentId?: string;
30
- cwd?: string;
31
- turnCount: number;
32
- messageCount: number;
33
- title?: string;
34
- taskSummary?: string;
35
- taskSummaryGeneratedAt?: number;
36
- pinnedAt?: string;
37
- archivedAt?: string;
38
- sealedAt?: string;
39
- previousSessionId?: string;
40
- carryoverSummary?: string;
41
- type?: "personal" | "group";
42
- ownerPlatform?: string;
43
- ownerId?: string;
44
- groupKey?: string;
45
- groupName?: string;
46
- groupPlatform?: string;
47
- assistant?: {
48
- id: string;
49
- name: string;
50
- source: "builtin" | "user" | "plugin";
51
- contextHash: string;
52
- enabledSkills: string[];
53
- disabledBuiltinSkills: string[];
54
- };
55
- totalInputTokens?: number;
56
- totalOutputTokens?: number;
57
- }
58
- export interface PersistedSession {
59
- metadata: SessionMetadata;
60
- messages: PersistedChatMessage[];
61
- }
62
- export interface MessageDisplayMetadata {
63
- messageId?: string;
64
- platform?: string;
65
- sourceChannel?: string;
66
- source?: string;
67
- chatId?: string;
68
- userId?: string;
69
- userName?: string;
70
- }
71
- export interface PersistedChatMessage extends ChatMessage {
72
- timestamp?: string;
73
- turnId?: string;
74
- usage?: TokenUsage;
75
- displayMetadata?: MessageDisplayMetadata;
76
- }
77
- export interface SessionListEntry {
78
- sessionId: string;
79
- title?: string;
80
- lastActiveAt: string;
81
- messageCount: number;
82
- model?: string;
83
- agentId?: string;
84
- pinnedAt?: string;
85
- archivedAt?: string;
86
- sealedAt?: string;
87
- projectId: string;
88
- type?: "personal" | "group";
89
- createdAt: string;
90
- groupKey?: string;
91
- previousSessionId?: string;
92
- carryoverSummary?: string | null;
93
- }
94
- /**
95
- * Load session metadata only (lightweight — no transcript loading).
96
- * Returns null if session doesn't exist or metadata is unreadable.
97
- */
98
- export declare function getSessionMetadata(sessionId: string, projectRoot: string): SessionMetadata | null;
99
- /**
100
- * Append a message to the session transcript.
101
- * Creates the session directory if it doesn't exist.
102
- * When turnId is provided, it acts as a per-turn boundary marker enabling
103
- * reconciliation with Gateway's token_usage records.
104
- *
105
- * Robustness: catches disk-full and I/O errors without crashing the agent.
106
- * Returns false if the write fails.
107
- */
108
- export declare function appendMessage(sessionId: string, message: ChatMessage, projectRoot: string, turnId?: string, metadata?: {
109
- usage?: TokenUsage;
110
- displayMetadata?: MessageDisplayMetadata;
111
- }): Promise<boolean>;
112
- /**
113
- * Save session metadata + usage stats atomically (flat structure).
114
- */
115
- export declare function saveSessionState(sessionId: string, usageSnapshot: SessionUsageSnapshot, metadata: Partial<SessionMetadata>, projectRoot: string): Promise<void>;
116
- /**
117
- * Update specific metadata fields of a session without touching cost data.
118
- * Used by session CRUD RPC (rename, pin, archive, move-to-project).
119
- *
120
- * Concurrency-bounded via withSessionWriteLimit (see above) so a burst of parallel
121
- * updates cannot exhaust the fs thread pool and wedge the RPC channel.
122
- */
123
- export declare function updateSessionMetadata(sessionId: string, patch: Partial<Record<keyof SessionMetadata, SessionMetadata[keyof SessionMetadata] | null>>, projectRoot: string): Promise<SessionMetadata | null>;
124
- /**
125
- * Load a persisted session for resume — CC loadConversationForResume parity.
126
- *
127
- * Returns null if the session doesn't exist or is corrupted.
128
- */
129
- export declare function loadSessionForResume(sessionId: string, projectRoot: string, options?: {
130
- includeDisplayMetadata?: boolean;
131
- }): Promise<PersistedSession | null>;
132
- /**
133
- * List available sessions for resume CC ResumeConversation picker.
134
- * Returns most-recent-first, up to `limit` entries.
135
- */
136
- export declare function listSessions(limit: number | undefined, projectRoot: string): Promise<SessionListEntry[]>;
137
- /**
138
- * Delete a session (cleanup).
139
- */
140
- export declare function deleteSession(sessionId: string, projectRoot: string): Promise<void>;
141
- /**
142
- * Prune old sessions beyond MAX_SESSIONS limit.
143
- * Deletes oldest sessions first.
144
- */
145
- export declare function pruneOldSessions(projectRoot: string): Promise<number>;
146
- export interface TaskSummaryDeps {
147
- transport: import("../ports/index.js").LLMTransport;
148
- apiKey: string;
149
- model: string;
150
- }
151
- /**
152
- * Check if a task summary should be generated for this session.
153
- * Triggers after TASK_SUMMARY_TURN_THRESHOLD turns, then every REGEN_INTERVAL turns.
154
- */
155
- export declare function shouldGenerateTaskSummary(metadata: SessionMetadata): boolean;
156
- /**
157
- * Generate a concise session title from the user's first message.
158
- * Lightweight LLM call — one-shot, no tool loop.
159
- */
160
- export declare function generateSessionTitle(userMessage: string, deps: TaskSummaryDeps): Promise<string | null>;
161
- export declare function maybeGenerateTaskSummary(sessionId: string, metadata: SessionMetadata, recentMessages: ChatMessage[], deps: TaskSummaryDeps, projectRoot: string): Promise<string | null>;
4
+ * The implementation lives in focused modules:
5
+ * - session-transcript-store.ts: append-only transcript JSONL
6
+ * - session-metadata-store.ts: metadata schema, migration, atomic writes
7
+ * - session-resume.ts: resume assembly
8
+ * - session-catalog.ts: list/delete/prune
9
+ * - session-summary.ts: title and task-summary generation
10
+ */
11
+ export { appendMessage } from "./session-transcript-store.js";
12
+ export { getSessionMetadata, readSessionMetadata, saveSessionState, updateSessionMetadata, } from "./session-metadata-store.js";
13
+ export { loadSessionForResume } from "./session-resume.js";
14
+ export { deleteSession, listSessions, pruneOldSessions } from "./session-catalog.js";
15
+ export { generateSessionTitle, maybeGenerateTaskSummary, shouldGenerateTaskSummary, } from "./session-summary.js";
16
+ export { SESSION_SCHEMA_VERSION, type MessageDisplayMetadata, type PersistedChatMessage, type PersistedSession, type SessionListEntry, type SessionMetadata, type TaskSummaryDeps, } from "./session-types.js";
@@ -0,0 +1,4 @@
1
+ import type { PersistedSession } from "./session-types.js";
2
+ export declare function loadSessionForResume(sessionId: string, projectRoot: string, options?: {
3
+ includeDisplayMetadata?: boolean;
4
+ }): Promise<PersistedSession | null>;
@@ -0,0 +1,10 @@
1
+ import type { SessionMetadata } from "./session-types.js";
2
+ export interface SessionMetadataDefaults {
3
+ projectId?: string;
4
+ createdAt?: string;
5
+ lastActiveAt?: string;
6
+ turnCount?: number;
7
+ messageCount?: number;
8
+ }
9
+ export declare function normalizeSessionMetadata(sessionId: string, input: Partial<SessionMetadata> | null | undefined, defaults?: SessionMetadataDefaults): SessionMetadata;
10
+ export declare function metadataNeedsMigration(input: Partial<SessionMetadata> | null | undefined): boolean;
@@ -0,0 +1,5 @@
1
+ import type { ChatMessage } from "../../protocol/wire/index.js";
2
+ import type { SessionMetadata, TaskSummaryDeps } from "./session-types.js";
3
+ export declare function shouldGenerateTaskSummary(metadata: SessionMetadata): boolean;
4
+ export declare function generateSessionTitle(userMessage: string, deps: TaskSummaryDeps): Promise<string | null>;
5
+ export declare function maybeGenerateTaskSummary(sessionId: string, metadata: SessionMetadata, recentMessages: ChatMessage[], deps: TaskSummaryDeps, projectRoot: string): Promise<string | null>;
@@ -0,0 +1,13 @@
1
+ import type { ChatMessage } from "../../protocol/wire/index.js";
2
+ import type { MessageDisplayMetadata, PersistedChatMessage, TokenUsage } from "./session-types.js";
3
+ export interface TranscriptLoadResult {
4
+ messages: PersistedChatMessage[];
5
+ corruptLines: number;
6
+ }
7
+ export declare function appendMessage(sessionId: string, message: ChatMessage, projectRoot: string, turnId?: string, metadata?: {
8
+ usage?: TokenUsage;
9
+ displayMetadata?: MessageDisplayMetadata;
10
+ }): Promise<boolean>;
11
+ export declare function loadTranscript(sessionId: string, projectRoot: string, options?: {
12
+ includeDisplayMetadata?: boolean;
13
+ }): Promise<TranscriptLoadResult | null>;