qlogicagent 2.18.2 → 2.18.3

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 (69) hide show
  1. package/dist/agent.js +38 -24
  2. package/dist/cli.js +1 -1
  3. package/dist/index.js +515 -465
  4. package/dist/orchestration.js +11 -11
  5. package/dist/protocol.js +1 -1
  6. package/dist/skills/mcp/astraclaw-native-mcp-server.js +8 -6
  7. package/dist/types/agent/memory-recall-injection.d.ts +2 -1
  8. package/dist/types/agent/tool-loop/budget-continuation-policy.d.ts +4 -0
  9. package/dist/types/agent/tool-loop/completion-action-policy.d.ts +9 -1
  10. package/dist/types/cli/credential-vault.d.ts +6 -0
  11. package/dist/types/cli/handlers/turn-handler.d.ts +50 -1
  12. package/dist/types/cli/memory-coordinator.d.ts +4 -0
  13. package/dist/types/cli/pet-runtime.d.ts +2 -0
  14. package/dist/types/cli/rpc-registry.d.ts +11 -0
  15. package/dist/types/cli/runtime-hook-bootstrap.d.ts +2 -0
  16. package/dist/types/cli/skill-tools-bootstrap.d.ts +5 -0
  17. package/dist/types/cli/stdio-acp-request-host.d.ts +2 -1
  18. package/dist/types/cli/stdio-rpc-handler-hosts.d.ts +1 -0
  19. package/dist/types/cli/stdio-server.d.ts +4 -0
  20. package/dist/types/cli/task-distillation-coordinator.d.ts +79 -0
  21. package/dist/types/cli/tool-bootstrap-core-registration.d.ts +24 -0
  22. package/dist/types/cli/turn-core.d.ts +0 -6
  23. package/dist/types/cli/turn-project-router.d.ts +9 -0
  24. package/dist/types/contracts/hooks.d.ts +3 -0
  25. package/dist/types/contracts/turn-event.d.ts +8 -4
  26. package/dist/types/orchestration/agent-instance.d.ts +4 -0
  27. package/dist/types/orchestration/context/reactive-compact.d.ts +4 -6
  28. package/dist/types/orchestration/error-handling/retry-loop.d.ts +0 -22
  29. package/dist/types/orchestration/goal-loop-coordinator.d.ts +6 -0
  30. package/dist/types/orchestration/goal-mode-adapters.d.ts +20 -1
  31. package/dist/types/orchestration/goal-run-types.d.ts +10 -0
  32. package/dist/types/orchestration/skill-improvement.d.ts +7 -2
  33. package/dist/types/orchestration/workflow/run-history-store.d.ts +2 -0
  34. package/dist/types/orchestration/workflow/workflow-runtime.d.ts +8 -0
  35. package/dist/types/protocol/wire/acp-agent-management.d.ts +3 -0
  36. package/dist/types/protocol/wire/agent-events.d.ts +2 -2
  37. package/dist/types/protocol/wire/memory-provider-lifecycle.d.ts +3 -0
  38. package/dist/types/protocol/wire/notification-payloads.d.ts +27 -0
  39. package/dist/types/runtime/config/tunable-defaults.d.ts +6 -0
  40. package/dist/types/runtime/execution/memory-decay.d.ts +5 -1
  41. package/dist/types/runtime/hooks/context-compression.d.ts +5 -0
  42. package/dist/types/runtime/hooks/memory-hooks.d.ts +10 -0
  43. package/dist/types/runtime/infra/acp-detector.d.ts +8 -0
  44. package/dist/types/runtime/infra/acp-protocol-adapter.d.ts +10 -0
  45. package/dist/types/runtime/infra/agent-process.d.ts +6 -0
  46. package/dist/types/runtime/infra/astraclaw-capabilities.d.ts +9 -0
  47. package/dist/types/runtime/infra/working-materials-store.d.ts +8 -14
  48. package/dist/types/runtime/pet/pet-profile-service.d.ts +7 -0
  49. package/dist/types/runtime/pet/petdex-forge-service.d.ts +3 -1
  50. package/dist/types/runtime/ports/memory-provider.d.ts +2 -0
  51. package/dist/types/runtime/ports/project-memory-store.d.ts +2 -0
  52. package/dist/types/runtime/prompt/environment-context.d.ts +15 -3
  53. package/dist/types/runtime/prompt/fresh-workspace-evidence.d.ts +7 -0
  54. package/dist/types/runtime/prompt/instruction-loader.d.ts +0 -1
  55. package/dist/types/runtime/session/inbound-upload-persistence.d.ts +4 -0
  56. package/dist/types/runtime/session/session-catalog.d.ts +8 -0
  57. package/dist/types/runtime/session/session-resume.d.ts +5 -0
  58. package/dist/types/runtime/session/session-transcript-store.d.ts +8 -1
  59. package/dist/types/skills/mcp/mcp-manager.d.ts +25 -1
  60. package/dist/types/skills/memory/local-memory-provider.d.ts +14 -0
  61. package/dist/types/skills/memory/local-store.d.ts +2 -0
  62. package/dist/types/skills/memory/memdir.d.ts +8 -0
  63. package/dist/types/skills/memory/task-distillation.d.ts +148 -0
  64. package/dist/types/skills/tools/search-tool.d.ts +6 -0
  65. package/dist/types/skills/tools/shell/task-output.d.ts +2 -0
  66. package/package.json +1 -1
  67. package/dist/types/agent/tool-loop/skill-instruction-policy.d.ts +0 -7
  68. package/dist/types/agent/tool-loop/tool-guardrails.d.ts +0 -24
  69. package/dist/types/cli/turn-skill-autopersist.d.ts +0 -22
@@ -13,7 +13,7 @@
13
13
  * Turn-lifecycle events relayed to the Control UI WebSocket.
14
14
  * These are the "chat session" events that every UI client needs.
15
15
  */
16
- export declare const AGENT_WS_EVENT_NAMES: readonly ["turn.start", "turn.delta", "turn.end", "turn.error", "turn.recovery", "turn.file_changes", "turn.tool_call", "turn.tool_result", "turn.tool_blocked", "turn.reasoning_delta", "turn.approval_request", "turn.skill_instruction", "turn.ask_user", "turn.media_result", "turn.media_progress", "turn.media_usage", "turn.media_capability_check", "turn.plan_update", "turn.suggestions", "turn.sidechain_started", "turn.subagent_started", "turn.subagent_delta", "turn.subagent_ended", "turn.sidechain_completed", "turn.task_updated", "turn.todos_updated", "turn.exec_progress", "turn.progress", "turn.tool_use_summary", "turn.tool_selection_policy", "turn.lifecycle", "turn.document_maintenance", "turn.artifact_contract", "turn.usage_update", "team.member.notification", "session.info", "session.recovery_pending", "memory.updated", "skills.updated", "pet.soul_ready", "pet.reaction", "pet.growth", "pet.state", "pet.confirm", "pet.asset.updated", "system.activity", "workflow.created", "workflow.updated", "workflow.deleted", "workflow.runStarted", "workflow.runCompleted", "workflow.runFailed", "workflow.nodeStatus", "workflow.triggerDropped", "workflow.alert", "workflow.approvalRequested", "workflow.approvalTimedOut"];
16
+ export declare const AGENT_WS_EVENT_NAMES: readonly ["turn.start", "turn.delta", "turn.end", "turn.error", "turn.recovery", "turn.file_changes", "turn.tool_call", "turn.tool_result", "turn.tool_blocked", "turn.reasoning_delta", "turn.approval_request", "turn.skill_instruction", "turn.ask_user", "turn.media_result", "turn.media_progress", "turn.media_usage", "turn.media_capability_check", "turn.plan_update", "turn.suggestions", "turn.sidechain_started", "turn.subagent_started", "turn.subagent_delta", "turn.subagent_ended", "turn.sidechain_completed", "turn.task_updated", "turn.todos_updated", "turn.exec_progress", "turn.progress", "turn.tool_use_summary", "turn.tool_selection_policy", "turn.lifecycle", "turn.document_maintenance", "turn.artifact_contract", "turn.usage_update", "team.member.notification", "session.info", "session.recovery_pending", "memory.updated", "skills.updated", "turn.memory_recall", "turn.memory_written", "pet.soul_ready", "pet.reaction", "pet.growth", "pet.state", "pet.confirm", "pet.asset.updated", "system.activity", "workflow.created", "workflow.updated", "workflow.deleted", "workflow.runStarted", "workflow.runCompleted", "workflow.runFailed", "workflow.nodeStatus", "workflow.triggerDropped", "workflow.alert", "workflow.approvalRequested", "workflow.approvalTimedOut"];
17
17
  /**
18
18
  * Agent Team events (Solo Mode, Product Mode, Plan lifecycle).
19
19
  * Relayed to the UI's team/orchestration panel.
@@ -23,7 +23,7 @@ export declare const AGENT_TEAM_WS_EVENT_NAMES: readonly ["solo.progress", "solo
23
23
  * All agent notifications that Gateway should relay to WS clients.
24
24
  * Union of session events + team events.
25
25
  */
26
- export declare const ALL_AGENT_WS_EVENT_NAMES: readonly ["turn.start", "turn.delta", "turn.end", "turn.error", "turn.recovery", "turn.file_changes", "turn.tool_call", "turn.tool_result", "turn.tool_blocked", "turn.reasoning_delta", "turn.approval_request", "turn.skill_instruction", "turn.ask_user", "turn.media_result", "turn.media_progress", "turn.media_usage", "turn.media_capability_check", "turn.plan_update", "turn.suggestions", "turn.sidechain_started", "turn.subagent_started", "turn.subagent_delta", "turn.subagent_ended", "turn.sidechain_completed", "turn.task_updated", "turn.todos_updated", "turn.exec_progress", "turn.progress", "turn.tool_use_summary", "turn.tool_selection_policy", "turn.lifecycle", "turn.document_maintenance", "turn.artifact_contract", "turn.usage_update", "team.member.notification", "session.info", "session.recovery_pending", "memory.updated", "skills.updated", "pet.soul_ready", "pet.reaction", "pet.growth", "pet.state", "pet.confirm", "pet.asset.updated", "system.activity", "workflow.created", "workflow.updated", "workflow.deleted", "workflow.runStarted", "workflow.runCompleted", "workflow.runFailed", "workflow.nodeStatus", "workflow.triggerDropped", "workflow.alert", "workflow.approvalRequested", "workflow.approvalTimedOut", "solo.progress", "solo.specProgress", "solo.agentDelta", "solo.agentActivity", "solo.agentUsage", "solo.evaluation", "product.taskStarted", "product.taskOutput", "product.members", "product.agentActivity", "product.taskCompleted", "product.taskFailed", "product.budgetUpdate", "product.budgetWarning", "product.checkpointed", "product.completed", "product.dagTopology", "plan.interrupted", "goal.run_state_changed", "goal.phase_boundary", "goal.goal_edited", "goal.message_queued", "goal.acceptance_updated"];
26
+ export declare const ALL_AGENT_WS_EVENT_NAMES: readonly ["turn.start", "turn.delta", "turn.end", "turn.error", "turn.recovery", "turn.file_changes", "turn.tool_call", "turn.tool_result", "turn.tool_blocked", "turn.reasoning_delta", "turn.approval_request", "turn.skill_instruction", "turn.ask_user", "turn.media_result", "turn.media_progress", "turn.media_usage", "turn.media_capability_check", "turn.plan_update", "turn.suggestions", "turn.sidechain_started", "turn.subagent_started", "turn.subagent_delta", "turn.subagent_ended", "turn.sidechain_completed", "turn.task_updated", "turn.todos_updated", "turn.exec_progress", "turn.progress", "turn.tool_use_summary", "turn.tool_selection_policy", "turn.lifecycle", "turn.document_maintenance", "turn.artifact_contract", "turn.usage_update", "team.member.notification", "session.info", "session.recovery_pending", "memory.updated", "skills.updated", "turn.memory_recall", "turn.memory_written", "pet.soul_ready", "pet.reaction", "pet.growth", "pet.state", "pet.confirm", "pet.asset.updated", "system.activity", "workflow.created", "workflow.updated", "workflow.deleted", "workflow.runStarted", "workflow.runCompleted", "workflow.runFailed", "workflow.nodeStatus", "workflow.triggerDropped", "workflow.alert", "workflow.approvalRequested", "workflow.approvalTimedOut", "solo.progress", "solo.specProgress", "solo.agentDelta", "solo.agentActivity", "solo.agentUsage", "solo.evaluation", "product.taskStarted", "product.taskOutput", "product.members", "product.agentActivity", "product.taskCompleted", "product.taskFailed", "product.budgetUpdate", "product.budgetWarning", "product.checkpointed", "product.completed", "product.dagTopology", "plan.interrupted", "goal.run_state_changed", "goal.phase_boundary", "goal.goal_edited", "goal.message_queued", "goal.acceptance_updated"];
27
27
  /** Type-level event name for session events. */
28
28
  export type AgentWsEventName = (typeof AGENT_WS_EVENT_NAMES)[number];
29
29
  /** Type-level event name for team events. */
@@ -58,6 +58,9 @@ export interface MemorySearchOptions {
58
58
  llmConfig?: MemoryLlmConfig;
59
59
  /** Categories to boost during reranking (e.g. ["lesson", "preference"]). */
60
60
  preferredCategories?: string[];
61
+ /** Drop hits whose tags contain ALL strings of any group (resident-layer exclusion:
62
+ * entries already injected verbatim via the global INDEX must not be recalled again). */
63
+ excludeTagGroups?: string[][];
61
64
  }
62
65
  export interface MemoryIngestOptions {
63
66
  llmConfig?: MemoryLlmConfig;
@@ -163,6 +163,22 @@ export interface TurnSuggestionsNotification {
163
163
  action?: string;
164
164
  }>;
165
165
  }
166
+ /** Memory recall visibility (Part B): fired when turn-time recall injected memories,
167
+ * so the UI can render a "based on N memories" disclosure row (recall was invisible before). */
168
+ export interface TurnMemoryRecallNotification {
169
+ sessionId: string;
170
+ turnId: string;
171
+ count: number;
172
+ /** Truncated texts of the memories actually injected (post-cap), for the expanded list. */
173
+ titles: string[];
174
+ }
175
+ /** Memory write visibility (Part B): fired on the synchronous agent-remember tool path.
176
+ * Dream/async consolidation deliberately does NOT emit this (it surfaces via next-turn recall). */
177
+ export interface TurnMemoryWrittenNotification {
178
+ items: Array<{
179
+ title: string;
180
+ }>;
181
+ }
166
182
  /** Sidechain started execution. */
167
183
  export interface TurnSidechainStartedNotification {
168
184
  turnId: string;
@@ -250,6 +266,15 @@ export interface TurnMediaPersistedNotification {
250
266
  bytes: number;
251
267
  mimeType: string;
252
268
  }>;
269
+ /**
270
+ * URLs that FAILED to persist locally this turn (result keeps the remote URL / dangling temp
271
+ * path, which may expire). Present only when at least one file failed — persistence stays
272
+ * fail-open, but the degradation is surfaced instead of silently swallowed.
273
+ */
274
+ failures?: Array<{
275
+ remoteUrl: string;
276
+ error?: string;
277
+ }>;
253
278
  }
254
279
  /** Task state change. */
255
280
  export interface TurnTaskUpdatedNotification {
@@ -1011,6 +1036,8 @@ export interface NotificationMethodMap {
1011
1036
  "turn.reasoning_delta": TurnReasoningDeltaNotification;
1012
1037
  "turn.plan_update": TurnPlanUpdateNotification;
1013
1038
  "turn.suggestions": TurnSuggestionsNotification;
1039
+ "turn.memory_recall": TurnMemoryRecallNotification;
1040
+ "turn.memory_written": TurnMemoryWrittenNotification;
1014
1041
  "turn.sidechain_started": TurnSidechainStartedNotification;
1015
1042
  "turn.subagent_delta": TurnSubagentDeltaNotification;
1016
1043
  "turn.sidechain_completed": TurnSidechainCompletedNotification;
@@ -143,6 +143,12 @@ export declare const TASK_PANEL_GRACE_MS = 30000;
143
143
  export declare const MEMORY_PREFETCH_MAX_SESSION_BYTES: number;
144
144
  /** Max results per memory recall query. */
145
145
  export declare const MEMORY_PREFETCH_LIMIT_PER_RECALL = 10;
146
+ /** Min hybrid score for recall injection. The old 0.1 default was a no-op filter —
147
+ * top-10 got injected wholesale and weak matches crowded the per-turn byte budget. */
148
+ export declare const MEMORY_RECALL_MIN_SCORE = 0.35;
149
+ /** Adaptive cliff cutoff: stop taking results when the next score drops by more than
150
+ * this ratio vs the previous one (2 relevant hits -> inject 2, don't pad to 10). */
151
+ export declare const MEMORY_RECALL_CLIFF_RATIO = 0.4;
146
152
  /** LRU dedup set size for surfaced memory entries. */
147
153
  export declare const MEMORY_MAX_SURFACED_ENTRIES = 100;
148
154
  /** Min hours between dream consolidation runs. */
@@ -49,8 +49,12 @@ export interface DecayCycleDeps {
49
49
  };
50
50
  }
51
51
  export interface DecayCycleResult {
52
- /** Whether decay actually ran (false = skipped by gate). */
52
+ /** Whether decay actually ran (false = skipped by gate OR failed — see `failed`). */
53
53
  ran: boolean;
54
+ /** True when the cycle was ATTEMPTED and errored — distinguishes a failure from a cooldown skip. */
55
+ failed?: boolean;
56
+ /** Failure reason, present when failed=true. */
57
+ error?: string;
54
58
  /** Number of memories whose importance was reduced. */
55
59
  decayed: number;
56
60
  /** Number of memories archived (below threshold). */
@@ -8,6 +8,11 @@ export declare function estimateTokens(msg: CompressibleMessage): number;
8
8
  export declare function estimateTotalTokens(messages: CompressibleMessage[]): number;
9
9
  export declare function getCompressionMetrics(): import("../context/context-compression-strategies.js").CompressionMetricsSnapshot;
10
10
  export declare function getContextEngineRegistry(): ContextEngineRegistry;
11
+ /**
12
+ * Prefixed onto the sync fallback when the LLM summarize call failed — the model
13
+ * (and anyone reading the compressed history) must know this stretch is low-fidelity.
14
+ */
15
+ export declare const DEGRADED_SUMMARY_MARKER = "[summary degraded: LLM summarization failed]";
11
16
  /**
12
17
  * Create a summarization callback using an injected LLM transport.
13
18
  * For CLI mode: uses the same transport that powers the agent loop.
@@ -25,6 +25,16 @@ export interface MemoryHooksDeps {
25
25
  getLastAssistantMessage?: () => string | undefined;
26
26
  /** Background LLM for implicit extraction. If provided, enables Layer 2. */
27
27
  llmExtract?: (prompt: string) => Promise<string | null>;
28
+ /** Part B write visibility: forwards turn.memory_written on auto-extract commits. */
29
+ sendNotification?: (method: string, params: Record<string, unknown>) => void;
30
+ /** V3.2 usage 仪表:procedure 复用的 session 维度与负反馈计数落盘目录。 */
31
+ profileMemoryDir?: () => string;
32
+ /** V3.2: tag marking a distilled procedure memory (recall filter). cli injects so runtime never imports skills. */
33
+ procedureTag?: string;
34
+ /** V3.2: record distilled procedures recalled this turn (positive reuse signal). cli-injected. */
35
+ recordProcedureRecalls?: (procedureIds: string[], sessionId: string) => void;
36
+ /** V3.2: record negative feedback against distilled procedures (failed turn). cli-injected. */
37
+ recordProcedureNegatives?: (procedureIds: string[]) => void;
28
38
  }
29
39
  /** Session-scoped state for dedup and byte budget (CC parity). */
30
40
  export interface MemoryPrefetchState {
@@ -155,6 +155,9 @@ export declare function assembleBackendDescriptor(backend: AcpBackendConfig, cli
155
155
  export declare function assembleCustomAgentDescriptor(custom: CustomAgentDef, cliPath: string | null, hasConfig: boolean): AgentDescriptor;
156
156
  export declare class AcpDetector {
157
157
  private cache;
158
+ /** Last scan that COMPLETED, surviving clearCache() and failed rescans. list() prefers this
159
+ * over an empty [] so a transient probe failure never reads as "no agents installed". */
160
+ private lastGoodScan;
158
161
  private configStore;
159
162
  private keySources;
160
163
  /** Shared in-flight async scan so concurrent scanAsync() callers (startup warm + a racing RPC)
@@ -188,6 +191,11 @@ export declare class AcpDetector {
188
191
  * Return cached results without IO. 冷缓存时后台预热(scanAsync)并返回 [],
189
192
  * 绝不在 RPC 路径上同步 scan —— 同步探测(11-18s+)会饿死单线程引擎循环
190
193
  * (x/product.confirm 60s 超时的根因)。调用方按"稍后再查"处理空列表。
194
+ *
195
+ * A background-scan failure is reported (console.error), never swallowed: a swallowed
196
+ * failure made list() return [] forever and downstream (product planning) treated
197
+ * "scan failed" as "no agents installed". When the fresh cache is gone but an older
198
+ * scan succeeded, that stale-but-real result is returned instead of [].
191
199
  */
192
200
  list(): AgentDescriptor[];
193
201
  /** Clear the detection cache. */
@@ -114,6 +114,8 @@ export declare class AcpProtocolAdapter {
114
114
  private child;
115
115
  private onNotification;
116
116
  private hostHandler;
117
+ /** Sessions whose session/set_model FAILED — running on the agent's default model, not the managed one. */
118
+ private modelMismatches;
117
119
  /**
118
120
  * Attach to a child process's stdio for ACP communication.
119
121
  * Constructs the official ClientSideConnection over the child's stdin/stdout. The connection's
@@ -172,6 +174,14 @@ export declare class AcpProtocolAdapter {
172
174
  * error is the backstop). Uses the generic sendRequest because the SDK has no typed set_model yet.
173
175
  */
174
176
  private selectSessionModel;
177
+ /**
178
+ * The recorded session/set_model failure for a session, if any — the session is alive but on
179
+ * the agent's DEFAULT model instead of the managed/platform one (wrong vendor/billing/capability).
180
+ */
181
+ getModelMismatch(sessionId: string): {
182
+ desired: string;
183
+ error: string;
184
+ } | undefined;
175
185
  /**
176
186
  * Send a prompt to a running ACP session (session/prompt). Content streams back via session/update
177
187
  * notifications during execution; the response carries only { stopReason, usage? }. On timeout the
@@ -291,6 +291,12 @@ export declare class AgentProcessManager {
291
291
  * Uses the ACP protocol adapter for lifecycle management.
292
292
  */
293
293
  private spawnAcpAgent;
294
+ /**
295
+ * Surface a recorded session/set_model failure: the session is alive but runs the agent's
296
+ * DEFAULT model instead of the managed/platform one (wrong vendor/billing/capability). Same
297
+ * agents.error channel as the other spawn/restart failures.
298
+ */
299
+ private reportModelMismatch;
294
300
  private syncNativeMcpConfig;
295
301
  /** Kill a specific child agent process. */
296
302
  kill(memberId: string): void;
@@ -8,6 +8,15 @@ export interface AstraClawCapabilityToolInput {
8
8
  availableToolNames?: Iterable<string>;
9
9
  currentEnvironment?: string;
10
10
  toolCatalog?: ToolCatalog;
11
+ /**
12
+ * Configured MCP servers serving NO tools this session (invalid config / connect failure).
13
+ * Disclosed in mcp_connectors_list so a failed server is visibly missing, not silently absent.
14
+ */
15
+ mcpServerFailures?: Array<{
16
+ name: string;
17
+ phase?: string;
18
+ error: string;
19
+ }>;
11
20
  }
12
21
  export type AstraClawCapabilityToolResult = {
13
22
  handled: false;
@@ -17,19 +17,13 @@ export declare function getWorkingMaterials(projectId: string, sessionId: string
17
17
  items: WorkingMaterialItem[];
18
18
  missing: WorkingMaterialItem[];
19
19
  }>;
20
- export declare function replaceWorkingMaterials(projectId: string, sessionId: string, items: unknown[]): Promise<{
20
+ export interface WorkingMaterialsWriteResult {
21
21
  ok: true;
22
22
  items: WorkingMaterialItem[];
23
- }>;
24
- export declare function upsertWorkingMaterial(projectId: string, sessionId: string, item: unknown): Promise<{
25
- ok: true;
26
- items: WorkingMaterialItem[];
27
- }>;
28
- export declare function removeWorkingMaterial(projectId: string, sessionId: string, id: string): Promise<{
29
- ok: true;
30
- items: WorkingMaterialItem[];
31
- }>;
32
- export declare function reorderWorkingMaterials(projectId: string, sessionId: string, ids: string[]): Promise<{
33
- ok: true;
34
- items: WorkingMaterialItem[];
35
- }>;
23
+ /** 超过上限被淘汰的项;非空时调用方/UI 必须告知用户(绝不静默丢用户 pin 的数据)。 */
24
+ dropped?: WorkingMaterialItem[];
25
+ }
26
+ export declare function replaceWorkingMaterials(projectId: string, sessionId: string, items: unknown[]): Promise<WorkingMaterialsWriteResult>;
27
+ export declare function upsertWorkingMaterial(projectId: string, sessionId: string, item: unknown): Promise<WorkingMaterialsWriteResult>;
28
+ export declare function removeWorkingMaterial(projectId: string, sessionId: string, id: string): Promise<WorkingMaterialsWriteResult>;
29
+ export declare function reorderWorkingMaterials(projectId: string, sessionId: string, ids: string[]): Promise<WorkingMaterialsWriteResult>;
@@ -81,6 +81,13 @@ export declare class PetProfileService {
81
81
  private readonly profilePath;
82
82
  constructor(ownerUserId: string);
83
83
  loadProfile(): PetProfile;
84
+ /**
85
+ * Load the profile for a read-modify-write cycle. A corrupt profile file must
86
+ * never be replaced by a rebuilt default — throw so the caller fails loudly
87
+ * instead of silently destroying the user's pet data.
88
+ */
89
+ private loadProfileForWrite;
90
+ private readProfileState;
84
91
  updateSoul(soul: PetSoul | null): PetProfile;
85
92
  updatePreferences(update: Partial<PetPreferences>): PetProfile;
86
93
  saveJourneySnapshot(snapshot: JourneySnapshot): PetProfile;
@@ -9,7 +9,9 @@ export interface PetdexForgePackageOutput extends PetdexForgeOutput {
9
9
  validationPath: string;
10
10
  productionRunPath: string;
11
11
  }
12
- export declare function forgePetdexAsset(input: PetdexForgeRequest, generateImage: GeneratePetdexImage, options?: PetdexProductionOptions): Promise<PetdexForgeOutput>;
12
+ export declare function forgePetdexAsset(input: PetdexForgeRequest, generateImage: GeneratePetdexImage, options?: PetdexProductionOptions): Promise<PetdexForgeOutput & {
13
+ qaSkippedJobs?: string[];
14
+ }>;
13
15
  export declare function forgePetdexAssetPackage(params: {
14
16
  input: PetdexForgeRequest;
15
17
  outputDir: string;
@@ -4,6 +4,8 @@ export interface MemorySearchOptions {
4
4
  minScore?: number;
5
5
  preferredCategories?: string[];
6
6
  llmConfig?: unknown;
7
+ /** Drop hits whose tags contain ALL strings of any group (resident-layer exclusion). */
8
+ excludeTagGroups?: string[][];
7
9
  }
8
10
  export interface MemorySearchResult {
9
11
  blockId: string;
@@ -41,4 +41,6 @@ export interface ProjectMemoryStore {
41
41
  export interface ProjectMemoryStoreFactory {
42
42
  getRootPath(projectRoot: string): string;
43
43
  create(projectRoot: string): ProjectMemoryStore;
44
+ /** Read the user-level global memory INDEX for prompt injection (null when absent/empty). */
45
+ readUserIndexForPrompt(): string | null;
44
46
  }
@@ -55,12 +55,24 @@ export declare function shellGuidanceLines(shellInfo: ShellInfo | undefined, she
55
55
  */
56
56
  export declare function createEnvironmentContextSection(cwdOverride?: string, shellInfo?: ShellInfo): SystemPromptSection;
57
57
  /**
58
- * Create the task guidance system prompt section.
59
- * Domain-aware: selects appropriate guidance based on detected or overridden task domain.
58
+ * Domain-specific guidance ONLY — the small, genuinely per-turn-variable block.
59
+ * Excludes universalGuidance() (which is domain-INVARIANT and lives in its own
60
+ * stable section, see createUniversalGuidanceSection). This is the single source
61
+ * of truth for domain content, so the combined section and the split sections
62
+ * never drift.
60
63
  *
61
64
  * @param domain - Task domain from auto-detection or host override.
62
65
  */
63
- export declare function createTaskGuidanceSection(domain?: TaskDomain): SystemPromptSection;
66
+ export declare function renderDomainGuidanceBlock(domain?: TaskDomain): string[];
67
+ /**
68
+ * Universal (domain-INVARIANT) working-approach guidance as a STABLE (memoized)
69
+ * system section. Byte-identical every turn regardless of the detected domain, so
70
+ * it belongs in the cacheable system-prompt prefix. The per-turn domain block
71
+ * (renderDomainGuidanceBlock) is deliberately NOT part of this section — it is
72
+ * injected as a system message right before the last user message so the system
73
+ * prompt stays byte-stable when the detected domain switches.
74
+ */
75
+ export declare function createUniversalGuidanceSection(): SystemPromptSection;
64
76
  /**
65
77
  * Create a system prompt section that provides tool usage guidance.
66
78
  * CC parity: matches claude-code's getUsingYourToolsSection().
@@ -33,4 +33,11 @@ export declare function isExplicitNoToolTurn(messages: readonly PromptMessageLik
33
33
  * stay subject to the normal evidence filter.)
34
34
  */
35
35
  export declare function selectFreshWorkspaceEvidenceTools<TTool extends ToolNameLike>(tools: readonly TTool[], policy: FreshWorkspaceEvidencePolicy): TTool[];
36
+ /**
37
+ * Prompt notice for an explicit "don't use tools" instruction. This INFORMS the
38
+ * model and leaves the judgment to it — the engine no longer strips the tool list
39
+ * (toolChoice="none"), which also silently disabled the reactive guards and
40
+ * misfired on quoted/reported speech ("he said don't use tools").
41
+ */
42
+ export declare function createExplicitNoToolNoticeSection(): SystemPromptSection;
36
43
  export declare function createFreshWorkspaceEvidenceSection(policy: FreshWorkspaceEvidencePolicy): SystemPromptSection | null;
@@ -54,7 +54,6 @@ export declare function loadInstructions(cwd: string, hooks?: HookRegistry): Pro
54
54
  */
55
55
  export declare function buildInstructionsPrompt(files: InstructionFileInfo[]): string;
56
56
  export declare function extractLiteralResponseRequirements(files: InstructionFileInfo[]): LiteralResponseRequirement[];
57
- export declare function applyLiteralResponseRequirements(content: string, requirements: readonly LiteralResponseRequirement[]): string;
58
57
  /**
59
58
  * Get conditional rules that match a target file path.
60
59
  * CC parity: getManagedAndUserConditionalRules() + getMemoryFilesForNestedDirectory()
@@ -34,6 +34,10 @@ export declare function persistInboundUploadUrl(url: string, projectId: string,
34
34
  /**
35
35
  * Persist + rewrite the inbound uploads on the LAST user message of a turn (the new message;
36
36
  * resumed history already carries persisted local URLs). Mutates and returns the message array.
37
+ *
38
+ * Failure parity with the document path (appendLocalDocumentNotesToText): when a media upload
39
+ * could NOT be persisted, the message gets a model-visible note instead of silently keeping a
40
+ * transport URL that expires with the turn — the model must know the reference is short-lived.
37
41
  */
38
42
  export declare function persistInboundUploadsForTurn(messages: ChatMessage[], projectId: string | undefined, sessionId: string | undefined): Promise<ChatMessage[]>;
39
43
  /**
@@ -1,4 +1,12 @@
1
1
  import type { SessionListEntry } from "./session-types.js";
2
2
  export declare function listSessions(limit: number | undefined, projectRoot: string): Promise<SessionListEntry[]>;
3
3
  export declare function deleteSession(sessionId: string, projectRoot: string): Promise<void>;
4
+ /**
5
+ * ⚠️ Destructive cascade with NO user-visible confirmation: every pruned session goes through
6
+ * deleteSession, which permanently removes its transcript + metadata + checkpoints + uploads.
7
+ * Currently has NO caller. If you wire this up, the deletions must be surfaced to the user
8
+ * (count + which sessions) — silently reaping MAX_SESSIONS-overflow would be exactly the kind of
9
+ * invisible data loss docs/judgment-over-mechanism.md forbids. Also note listSessions skips
10
+ * unreadable-metadata sessions, so a prune pass under fs errors could mis-rank what "oldest" is.
11
+ */
4
12
  export declare function pruneOldSessions(projectRoot: string): Promise<number>;
@@ -1,4 +1,9 @@
1
1
  import type { PersistedSession } from "./session-types.js";
2
+ /** Coded error: the session's project root cannot be read at all (deleted dir, unplugged drive,
3
+ * permissions). Distinguishable from the `null` return, which strictly means "this session has no
4
+ * persisted transcript" — conflating the two made every caller silently start a NEW empty session
5
+ * on a read failure (docs/judgment-over-mechanism.md: "read failed" ≠ "does not exist"). */
6
+ export declare const PROJECT_ROOT_UNAVAILABLE = "PROJECT_ROOT_UNAVAILABLE";
2
7
  export declare function loadSessionForResume(sessionId: string, projectRoot: string, options?: {
3
8
  includeDisplayMetadata?: boolean;
4
9
  }): Promise<PersistedSession | null>;
@@ -6,10 +6,17 @@ export interface TranscriptLoadResult {
6
6
  /** 1-based line numbers that failed to parse (bounded to the first MAX_REPORTED_CORRUPT_LINES). */
7
7
  corruptLineNumbers: number[];
8
8
  }
9
+ /**
10
+ * Outcome of an appendMessage call. "skipped-deleted" (the session was deleted — a LEGAL late-write
11
+ * no-op) is deliberately distinguishable from "failed" (the write itself failed — the message is
12
+ * LOST and callers must leave a trace / surface it), per docs/judgment-over-mechanism.md:
13
+ * "does not exist" and "write failed" must never be conflated into one silent boolean.
14
+ */
15
+ export type AppendMessageOutcome = "appended" | "skipped-deleted" | "failed";
9
16
  export declare function appendMessage(sessionId: string, message: ChatMessage, projectRoot: string, turnId?: string, metadata?: {
10
17
  usage?: TokenUsage;
11
18
  displayMetadata?: MessageDisplayMetadata;
12
- }): Promise<boolean>;
19
+ }): Promise<AppendMessageOutcome>;
13
20
  export declare function countTranscriptMessages(sessionId: string, projectRoot: string): Promise<number | null>;
14
21
  export declare function loadTranscript(sessionId: string, projectRoot: string, options?: {
15
22
  includeDisplayMetadata?: boolean;
@@ -1,4 +1,4 @@
1
- import type { PortableTool } from "../portable-tool.js";
1
+ import type { PortableTool, PortableToolResult } from "../portable-tool.js";
2
2
  interface ToolRegistryLike {
3
3
  addTools(tools: PortableTool[]): void;
4
4
  getToolNames(): string[];
@@ -35,6 +35,17 @@ export interface McpSecurityIssue {
35
35
  code: "dangerous_egress" | "persistence" | "ioc_public_key";
36
36
  message: string;
37
37
  }
38
+ /**
39
+ * A configured server that is NOT serving tools this session. Surfaced (not just logged)
40
+ * so capability queries (e.g. mcp_connectors_list) can disclose "configured but unavailable"
41
+ * instead of the server silently vanishing from the tool pool.
42
+ */
43
+ export interface McpServerFailure {
44
+ name: string;
45
+ /** "config" = entry invalid, skipped before connect; "connect" = every connect attempt failed. */
46
+ phase: "config" | "connect";
47
+ error: string;
48
+ }
38
49
  export interface McpManagerConfig {
39
50
  servers: McpServerEntry[];
40
51
  log?: {
@@ -67,7 +78,10 @@ export declare class McpManager {
67
78
  private toolCatalog?;
68
79
  private serverToolFilters;
69
80
  private serverOAuth;
81
+ private failedServers;
70
82
  constructor(config: McpManagerConfig);
83
+ /** Record (and loudly report) a server that will serve NO tools this session. */
84
+ private markServerFailed;
71
85
  private toServerDefinition;
72
86
  /**
73
87
  * Connect to all configured MCP servers and snapshot their tools.
@@ -81,6 +95,8 @@ export declare class McpManager {
81
95
  refreshServerTools(serverName: string): Promise<number>;
82
96
  /** Get names of all connected servers. */
83
97
  getConnectedServers(): string[];
98
+ /** Configured servers serving NO tools this session (invalid config or terminal connect failure). */
99
+ getFailedServers(): McpServerFailure[];
84
100
  /** Get total number of MCP tools across all servers. */
85
101
  getToolCount(): number;
86
102
  /**
@@ -95,6 +111,14 @@ export declare class McpManager {
95
111
  private registerTools;
96
112
  private removeRegisteredTool;
97
113
  }
114
+ /**
115
+ * Flatten an MCP CallToolResult into a text-bearing PortableToolResult.
116
+ * Non-text blocks (image/audio/resource…) cannot be dropped silently: content is
117
+ * the only channel the model sees, so the omission is disclosed in the text —
118
+ * "(no text output)" for a result that DID produce blocks is a lie.
119
+ * Exported for unit tests only.
120
+ */
121
+ export declare function toPortableResult(result: unknown): PortableToolResult;
98
122
  export declare function validateMcpToolWorkspaceBoundary(toolName: string, args: unknown, workspaceRoot: string | undefined): string | null;
99
123
  export declare function parseMcpConfig(json: unknown): McpServerEntry[];
100
124
  export declare function filterMcpTools<T extends {
@@ -32,6 +32,8 @@ export declare class LocalMemoryProvider implements MemoryProvider {
32
32
  private attachmentStore;
33
33
  private userIdPrefix;
34
34
  private dbPath;
35
+ /** One-shot flag: the embedding-degradation trace is logged once per provider instance. */
36
+ private embeddingFailureLogged;
35
37
  constructor(config: LocalMemoryProviderConfig);
36
38
  /** Persist an uploaded attachment (orphan until linked at commit). */
37
39
  adoptAttachment(input: {
@@ -57,9 +59,18 @@ export declare class LocalMemoryProvider implements MemoryProvider {
57
59
  /** Persist the understood/extracted text on an attachment row. */
58
60
  setAttachmentText(id: string, text: string): void;
59
61
  private resolveUserId;
62
+ /**
63
+ * The embedding API failing silently downgrades every search to FTS-only —
64
+ * leave one error-level trace per provider instance (deduped so a broken
65
+ * endpoint does not flood the log on every query).
66
+ */
67
+ private noteEmbeddingFailure;
60
68
  private buildEmbedding;
61
69
  search(query: string, userId: string, options?: MemorySearchOptions): Promise<MemorySearchResult[]>;
62
70
  ingest(messages: MemoryIngestMessage[], userId: string, options?: MemoryIngestOptions): Promise<void>;
71
+ /** Public embedding access for task-distillation signatures (R3). Null when
72
+ * the embedding provider is unavailable — callers must degrade, not throw. */
73
+ embedText(text: string): Promise<Float32Array | null>;
63
74
  addText(text: string, userId: string, options?: MemoryIngestOptions & {
64
75
  category?: string;
65
76
  importance?: number;
@@ -102,6 +113,9 @@ export declare class LocalMemoryProvider implements MemoryProvider {
102
113
  * Apply feedback to a memory (useful/irrelevant/outdated/wrong).
103
114
  * Adjusts importance or archives/deletes based on signal.
104
115
  */
116
+ /** V3 promote/demote: archive(技能接棒,记忆退役)与 unarchive(降格回归)成对。
117
+ * claims 状态随动,防 archived 记忆的 claim 继续参与冲突/召回。 */
118
+ setMemoryArchived(memoryId: string, archived: boolean): boolean;
105
119
  feedback(memoryIds: string[], signal: "useful" | "irrelevant" | "outdated" | "wrong"): Promise<{
106
120
  affected: number;
107
121
  }>;
@@ -103,6 +103,8 @@ export declare class LocalMemoryStore {
103
103
  * Used by dedup gate when a similar but newer memory supersedes an older one.
104
104
  */
105
105
  archive(id: string): boolean;
106
+ /** V3 demote(降格)恢复:archived procedure 回归召回池,与 archive 成对。 */
107
+ unarchive(id: string): boolean;
106
108
  /**
107
109
  * Temporal expiry: archive event/plan memories whose event_date has passed
108
110
  * beyond a grace period (e.g., "meeting tomorrow" 3 days after it happened).
@@ -8,6 +8,14 @@ export declare const TOPIC_FILE_MAX_CHARS = 8192;
8
8
  export declare function getMemdirPath(projectRoot: string): string;
9
9
  /** Full path to INDEX.md */
10
10
  export declare function getIndexPath(projectRoot: string): string;
11
+ /** Global-layer size budget: a cheat-sheet, not a memory store. */
12
+ export declare const USER_INDEX_MAX_CHARS = 2048;
13
+ export declare const USER_INDEX_MAX_LINES = 40;
14
+ /** Full path to the user-level global INDEX.md (QLOGICAGENT_HOME aware). */
15
+ export declare function getUserIndexPath(): string;
16
+ /** Read the global layer for prompt injection, capped by the cheat-sheet budget.
17
+ * Returns null when absent/empty — the section simply doesn't render. */
18
+ export declare function readUserIndexForPrompt(): string | null;
11
19
  export interface MemdirFileInfo {
12
20
  name: string;
13
21
  /** Size in bytes */