qlogicagent 2.18.6 → 2.18.8

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 (129) hide show
  1. package/dist/agent.js +30 -30
  2. package/dist/cli.js +1 -1
  3. package/dist/host-contract.js +1 -0
  4. package/dist/index.js +538 -528
  5. package/dist/orchestration.js +4 -4
  6. package/dist/permissions.js +1 -1
  7. package/dist/plugin-marketplace-compute.js +1 -0
  8. package/dist/protocol.js +1 -1
  9. package/dist/skills/mcp/astraclaw-native-mcp-server.js +4 -4
  10. package/dist/tunables.js +1 -0
  11. package/dist/types/agent/runtime-vars.d.ts +1 -2
  12. package/dist/types/agent/tool-loop.d.ts +6 -0
  13. package/dist/types/agent/tool-loop.test-harness.d.ts +20 -0
  14. package/dist/types/agent/types.d.ts +2 -0
  15. package/dist/types/cli/acp-extended-handlers.d.ts +7 -0
  16. package/dist/types/cli/acp-extended-host-adapter.d.ts +2 -0
  17. package/dist/types/cli/acp-session-host.d.ts +15 -2
  18. package/dist/types/cli/base-tool-bootstrap.d.ts +1 -0
  19. package/dist/types/cli/community-skill-installer.d.ts +2 -0
  20. package/dist/types/cli/core-tool-coordinator.d.ts +4 -0
  21. package/dist/types/cli/core-tools/config-tool-bootstrap.d.ts +3 -1
  22. package/dist/types/cli/core-tools/config-tool-service.d.ts +7 -5
  23. package/dist/types/cli/default-project-bootstrap.d.ts +1 -0
  24. package/dist/types/cli/handlers/agents-handler.d.ts +4 -1
  25. package/dist/types/cli/handlers/community-handler.d.ts +2 -0
  26. package/dist/types/cli/handlers/config-handler.d.ts +2 -15
  27. package/dist/types/cli/handlers/pet-handler.d.ts +3 -2
  28. package/dist/types/cli/handlers/session-handler.d.ts +1 -1
  29. package/dist/types/cli/handlers/skills-handler.d.ts +12 -10
  30. package/dist/types/cli/handlers/solo-handler.d.ts +3 -0
  31. package/dist/types/cli/handlers/turn-handler.d.ts +47 -33
  32. package/dist/types/cli/handlers/workflow-handler.d.ts +6 -0
  33. package/dist/types/cli/mcp-bootstrap.d.ts +0 -2
  34. package/dist/types/cli/media-inline.d.ts +14 -0
  35. package/dist/types/cli/media-understanding.d.ts +65 -8
  36. package/dist/types/cli/memory-coordinator.d.ts +8 -0
  37. package/dist/types/cli/multi-agent-handler-host.d.ts +2 -0
  38. package/dist/types/cli/permission-bootstrap.d.ts +2 -0
  39. package/dist/types/cli/pet-runtime.d.ts +0 -1
  40. package/dist/types/cli/plugin-bootstrap.d.ts +2 -1
  41. package/dist/types/cli/product-coordinator.d.ts +4 -1
  42. package/dist/types/cli/rpc-registry.d.ts +1 -3
  43. package/dist/types/cli/runtime-watcher-bootstrap.d.ts +0 -2
  44. package/dist/types/cli/session-context.d.ts +4 -2
  45. package/dist/types/cli/skill-invocation-service.d.ts +2 -0
  46. package/dist/types/cli/skill-tools-bootstrap.d.ts +2 -0
  47. package/dist/types/cli/skills-query-service.d.ts +2 -1
  48. package/dist/types/cli/stdio-acp-protocol-coordinator.d.ts +9 -0
  49. package/dist/types/cli/stdio-acp-request-host.d.ts +11 -2
  50. package/dist/types/cli/stdio-rpc-handler-hosts.d.ts +1 -1
  51. package/dist/types/cli/stdio-runtime-bootstrap.d.ts +6 -0
  52. package/dist/types/cli/stdio-runtime-services.d.ts +6 -1
  53. package/dist/types/cli/stdio-server.d.ts +33 -4
  54. package/dist/types/cli/task-distillation-coordinator.d.ts +9 -4
  55. package/dist/types/cli/tool-bootstrap-core-registration.d.ts +3 -0
  56. package/dist/types/cli/tool-bootstrap-media-registration.d.ts +10 -0
  57. package/dist/types/cli/tool-bootstrap-web-registration.d.ts +1 -0
  58. package/dist/types/cli/tool-bootstrap.d.ts +9 -0
  59. package/dist/types/cli/turn-core.d.ts +2 -0
  60. package/dist/types/cli/turn-preview-browser-setup.d.ts +15 -0
  61. package/dist/types/cli/turn-project-router.d.ts +1 -1
  62. package/dist/types/cli/workflow-host-adapter.d.ts +2 -0
  63. package/dist/types/contracts/structured-planner.d.ts +2 -0
  64. package/dist/types/host-contract/index.d.ts +1475 -0
  65. package/dist/types/host-contract/project-id.d.ts +5 -0
  66. package/dist/types/host-contract/provider-profile.d.ts +46 -0
  67. package/dist/types/orchestration/agent-instance.d.ts +6 -0
  68. package/dist/types/orchestration/delegation-coordinator.d.ts +40 -0
  69. package/dist/types/orchestration/goal-mode-adapters.d.ts +3 -0
  70. package/dist/types/orchestration/product-planner.d.ts +3 -0
  71. package/dist/types/orchestration/solo-evaluator.d.ts +19 -5
  72. package/dist/types/orchestration/solo-persistence.d.ts +2 -0
  73. package/dist/types/orchestration/testing/delegate-test-bridge.d.ts +4 -0
  74. package/dist/types/permissions.d.ts +2 -0
  75. package/dist/types/protocol/methods.d.ts +0 -199
  76. package/dist/types/protocol/wire/acp-protocol.d.ts +16 -1
  77. package/dist/types/protocol/wire/agent-methods.d.ts +1 -173
  78. package/dist/types/protocol/wire/chat-types.d.ts +6 -0
  79. package/dist/types/runtime/config/tunable-defaults.d.ts +13 -3
  80. package/dist/types/runtime/execution/dream-agent.d.ts +9 -8
  81. package/dist/types/runtime/infra/agent-paths.d.ts +3 -3
  82. package/dist/types/runtime/infra/astraclaw-capabilities.d.ts +1 -1
  83. package/dist/types/runtime/infra/clixml-sanitize.d.ts +16 -0
  84. package/dist/types/runtime/infra/external-agent-approvals.d.ts +18 -0
  85. package/dist/types/runtime/infra/feedback-distillation.d.ts +3 -1
  86. package/dist/types/runtime/infra/feedback-host-authority.d.ts +4 -0
  87. package/dist/types/runtime/infra/llmrouter-catalog.d.ts +2 -13
  88. package/dist/types/runtime/infra/model-registry.d.ts +3 -1
  89. package/dist/types/runtime/infra/project-authority-facade.d.ts +11 -0
  90. package/dist/types/runtime/infra/project-host-authority.d.ts +10 -0
  91. package/dist/types/runtime/ports/memory-provider.d.ts +11 -7
  92. package/dist/types/runtime/ports/tool-contracts.d.ts +2 -0
  93. package/dist/types/runtime/prompt/fresh-workspace-evidence.d.ts +2 -2
  94. package/dist/types/runtime/session/session-persistence.d.ts +29 -10
  95. package/dist/types/runtime/session/session-recovery.d.ts +4 -0
  96. package/dist/types/runtime/session/session-summary.d.ts +3 -1
  97. package/dist/types/runtime/session/session-transcript-store.d.ts +7 -0
  98. package/dist/types/skills/memory/host-memory-provider.d.ts +148 -0
  99. package/dist/types/skills/memory/local-memory-provider.d.ts +19 -10
  100. package/dist/types/skills/memory/task-distillation.d.ts +6 -0
  101. package/dist/types/skills/plugins/plugin-marketplace.d.ts +23 -57
  102. package/dist/types/skills/tools/media-understand-tool.d.ts +28 -0
  103. package/dist/types/skills/tools/preview-browser-tool.d.ts +136 -0
  104. package/dist/types/skills/tools/shell/task-output.d.ts +10 -1
  105. package/dist/types/skills/tools/skill-tool.d.ts +1 -1
  106. package/dist/types/skills/web-search/brave-source.d.ts +2 -1
  107. package/dist/types/skills/web-search/crawl4ai-extractor.d.ts +3 -2
  108. package/dist/types/skills/web-search/exa-source.d.ts +2 -1
  109. package/dist/types/skills/web-search/search-svc-source.d.ts +4 -3
  110. package/dist/types/skills/web-search/searxng-source.d.ts +3 -1
  111. package/dist/types/skills/web-search/serper-source.d.ts +2 -1
  112. package/dist/types/skills/web-search/source-factory.d.ts +2 -1
  113. package/dist/types/skills/web-search/web-tunable-resolver.d.ts +16 -0
  114. package/dist/types/test-support/global-home-setup.d.ts +2 -0
  115. package/dist/types/transport/acp-server.d.ts +29 -0
  116. package/dist/types/transport/delegate-client.d.ts +82 -0
  117. package/dist/types/transport/host-capability-client.d.ts +21 -0
  118. package/dist/types/transport/host-feedback-client.d.ts +25 -0
  119. package/dist/types/transport/host-profile-client.d.ts +19 -0
  120. package/dist/types/transport/host-project-client.d.ts +16 -0
  121. package/dist/types/transport/host-request-client.d.ts +38 -0
  122. package/dist/types/transport/host-session-client.d.ts +29 -0
  123. package/dist/types/tunables.d.ts +2 -0
  124. package/package.json +26 -3
  125. package/dist/types/cli/handlers/settings-handler.d.ts +0 -19
  126. package/dist/types/cli/permission-rule-persistence.d.ts +0 -16
  127. package/dist/types/cli/tunable-store.d.ts +0 -26
  128. package/dist/types/skills/permissions/settings-watcher.d.ts +0 -26
  129. /package/dist/types/{skills/memory → host-contract}/fts-segment.d.ts +0 -0
@@ -0,0 +1,148 @@
1
+ /**
2
+ * HostMemoryProvider —— qlogicagent 大脑对 memories.db 的存取反转(Route B B3;X7 brain proxy)。
3
+ *
4
+ * 与 LocalMemoryProvider 同公开面的 **proxy 实现**:大脑逻辑(dream/distill/晋升/consolidation/召回 hook)
5
+ * 零改动,底下的存取经 `x/host.request`(HostRequestClient)打到 gateway 四权威 host 服务(memory 域),
6
+ * store(memories.db)只有 gateway 进程打开。
7
+ *
8
+ * 单一事实源:docs/agent-supervision-authority-migration-spec.md §3.1;契约 host-contract §13
9
+ * (HostRequestParams;wire 形态 = { service:"memory", method, params:<位置参数数组> })。
10
+ *
11
+ * 【PROXY 共享面(16 方法;两仓照此表,一字不差)】
12
+ * search / addText / embedText / ingestExtracted / proposeExtracted / consumePendingProposals /
13
+ * feedback / findRelatedEvents / synthesizeTimeline / getActivitySummary / getAllProfiles /
14
+ * setProfile / getAtlas / setMemoryArchived / triggerDecay / resolveConflicts
15
+ *
16
+ * 面外方法 = fail-loud throw(护栏抓漏):gate 开时 UI RPC 面(atlas 富查询/update/attachments/
17
+ * proposals 消费等)由 gateway host-native 应答,**不该**再落到 qla 的 provider;到达此处 = 路由/
18
+ * wiring bug,绝不静默回落本地(静默回落 = 本进程再开 memories.db = 双权威,正是本工程消灭的形态)。
19
+ *
20
+ * 【单进程铁则】选型本 provider 后,本进程绝不打开 memories.db(零 better-sqlite3 memory 路径引用);
21
+ * userId 参数原样透传(多租户前缀语义归 gateway store-owner)。
22
+ * 纪律:fail-loud;单轨(创建时刻一次选型,非每调用分支);零 mock。
23
+ */
24
+ import type { HostRequestParams } from "../../host-contract/index.js";
25
+ import type { MemoryActivitySummary, MemoryAtlasResult, MemoryConsolidationWriteResult, MemoryDreamRuntimeProvider, MemoryExtractionItem, MemoryHandlerProvider, MemoryIngestOptions, MemoryLearningSink, MemoryRuntimeHookProvider, MemorySearchOptions, MemorySearchResult, MemoryToolProvider } from "../../runtime/ports/index.js";
26
+ /**
27
+ * 最小转发口(结构化契约,由 coordinator-owned HostRequestClient 满足)。
28
+ * 只取 request 一个方法:provider 不持有判活/连接生命周期(那归协议 coordinator/client)。
29
+ */
30
+ export interface HostRequestRequester {
31
+ request(params: HostRequestParams, opts?: {
32
+ timeoutMs?: number;
33
+ signal?: AbortSignal;
34
+ }): Promise<unknown>;
35
+ }
36
+ export interface HostMemoryProviderConfig {
37
+ /** x/host.request client; its service gate runs before send. */
38
+ client: HostRequestRequester;
39
+ }
40
+ export declare class HostMemoryProvider implements MemoryRuntimeHookProvider, MemoryLearningSink, MemoryToolProvider, MemoryHandlerProvider, MemoryDreamRuntimeProvider {
41
+ private readonly config;
42
+ readonly providerId = "qmemory-host";
43
+ constructor(config: HostMemoryProviderConfig);
44
+ /**
45
+ * 16 面统一转发:wire 形态 = { service:"memory", method, params:<位置参数数组> }(契约 §13)。
46
+ * 尾部 undefined 剔除:JSON 会把数组里的 undefined 序列化成 null,gateway 侧按位展开时
47
+ * null ≠ undefined 会击穿方法默认参(如 days=7)——省略实参才能让默认参生效。
48
+ */
49
+ private forward;
50
+ /** 面外方法护栏:fail-loud,绝不静默回落本地(见文件头)。 */
51
+ private unproxied;
52
+ search(query: string, userId: string, options?: MemorySearchOptions): Promise<MemorySearchResult[]>;
53
+ addText(text: string, userId: string, options?: MemoryIngestOptions & {
54
+ category?: string;
55
+ importance?: number;
56
+ }): Promise<{
57
+ memoriesAdded: number;
58
+ }>;
59
+ /** R3 蒸馏签名 embedding(gateway 调 llmrouter 现算);null = 不可用,调用方降级不炸。 */
60
+ embedText(text: string): Promise<number[] | null>;
61
+ ingestExtracted(items: MemoryExtractionItem[], userId: string, options?: MemoryIngestOptions): Promise<MemoryConsolidationWriteResult>;
62
+ proposeExtracted(items: MemoryExtractionItem[], userId: string, options?: MemoryIngestOptions): Promise<MemoryConsolidationWriteResult>;
63
+ consumePendingProposals(userId: string, opts?: {
64
+ now?: number;
65
+ ttlMs?: number;
66
+ maxCommitsPerPass?: number;
67
+ }): Promise<{
68
+ committed: number;
69
+ merged: number;
70
+ expiredIds: string[];
71
+ pendingLeft: number;
72
+ }>;
73
+ feedback(memoryIds: string[], signal: "useful" | "irrelevant" | "outdated" | "wrong"): Promise<{
74
+ affected: number;
75
+ }>;
76
+ findRelatedEvents(text: string, userId: string, options?: {
77
+ maxDaysBack?: number;
78
+ minSimilarity?: number;
79
+ maxSimilarity?: number;
80
+ limit?: number;
81
+ }): Promise<Array<{
82
+ id: string;
83
+ text: string;
84
+ score: number;
85
+ date: string;
86
+ }>>;
87
+ synthesizeTimeline(userId: string, startMs: number, endMs: number): Promise<string>;
88
+ getActivitySummary(userId: string, days?: number): Promise<MemoryActivitySummary>;
89
+ getAllProfiles(userId: string): Promise<Record<string, string>>;
90
+ setProfile(userId: string, key: string, value: string): Promise<void>;
91
+ getAtlas(userId: string, options?: {
92
+ pageSize?: number;
93
+ windowStartAt?: number;
94
+ windowEndAt?: number;
95
+ windowCenterAt?: number;
96
+ bucketCount?: number;
97
+ clusterLimit?: number;
98
+ activeOnly?: boolean;
99
+ }): Promise<MemoryAtlasResult>;
100
+ setMemoryArchived(memoryId: string, archived: boolean): Promise<boolean>;
101
+ triggerDecay(userId: string): Promise<{
102
+ decayed: number;
103
+ }>;
104
+ resolveConflicts(userId: string, opts?: {
105
+ minEvidenceToPromote?: number;
106
+ }): Promise<{
107
+ conflictsResolved: number;
108
+ claimsPromoted: number;
109
+ }>;
110
+ /** 本 provider 不持有 db 句柄/文件资源;close 为 no-op(shutdown 链 closeMemoryProviders 会调)。 */
111
+ close(): void;
112
+ remove(_memoryId: string): never;
113
+ update(_memoryId: string, _input: unknown): never;
114
+ observeExtracted(_items: MemoryExtractionItem[], _userId: string, _options?: MemoryIngestOptions): never;
115
+ listPendingProposals(_userId: string, _limit?: number, _status?: "pending" | "expired"): never;
116
+ resolveProposal(_userId: string, _proposalId: string, _action: "confirm" | "dismiss"): never;
117
+ listClaims(_userId: string): never;
118
+ listConflicts(_userId: string): never;
119
+ getProfile(_userId: string, _key: string): never;
120
+ deleteProfile(_userId: string, _key: string): never;
121
+ getTemporalSlice(_userId: string, _startMs: number, _endMs: number, _options?: {
122
+ category?: string;
123
+ limit?: number;
124
+ }): never;
125
+ list(_userId: string, _options?: {
126
+ page?: number;
127
+ pageSize?: number;
128
+ activeOnly?: boolean;
129
+ }): never;
130
+ listMemoriesByTag(_userId: string, _tag: string): never;
131
+ rerank(_results: unknown[], _options?: unknown): never;
132
+ health(): never;
133
+ count(_userId: string): never;
134
+ resetUser(_userId: string): never;
135
+ adoptAttachment(_input: {
136
+ data?: Buffer;
137
+ sourceUrl?: string;
138
+ filename: string;
139
+ mimeType: string;
140
+ userId: string;
141
+ }): never;
142
+ locateAttachment(_id: string): never;
143
+ purgeOrphanAttachments(): never;
144
+ readAttachmentBytes(_id: string): never;
145
+ setAttachmentText(_id: string, _text: string): never;
146
+ }
147
+ /** 工厂便捷函数(与 createLocalMemoryProvider 对称)。 */
148
+ export declare function createHostMemoryProvider(config: HostMemoryProviderConfig): HostMemoryProvider;
@@ -72,8 +72,11 @@ export declare class LocalMemoryProvider implements MemoryProvider {
72
72
  private buildEmbedding;
73
73
  search(query: string, userId: string, options?: MemorySearchOptions): Promise<MemorySearchResult[]>;
74
74
  /** Public embedding access for task-distillation signatures (R3). Null when
75
- * the embedding provider is unavailable — callers must degrade, not throw. */
76
- embedText(text: string): Promise<Float32Array | null>;
75
+ * the embedding provider is unavailable — callers must degrade, not throw.
76
+ * B3(X7): returns number[] (not Float32Array) this method is on the 16-method
77
+ * host-state proxy surface and its result crosses the x/host.request JSON wire
78
+ * in host mode; typed arrays do not survive JSON serialization. */
79
+ embedText(text: string): Promise<number[] | null>;
77
80
  addText(text: string, userId: string, options?: MemoryIngestOptions & {
78
81
  category?: string;
79
82
  importance?: number;
@@ -152,8 +155,9 @@ export declare class LocalMemoryProvider implements MemoryProvider {
152
155
  * Adjusts importance or archives/deletes based on signal.
153
156
  */
154
157
  /** V3 promote/demote: archive(技能接棒,记忆退役)与 unarchive(降格回归)成对。
155
- * claims 状态随动,防 archived 记忆的 claim 继续参与冲突/召回。 */
156
- setMemoryArchived(memoryId: string, archived: boolean): boolean;
158
+ * claims 状态随动,防 archived 记忆的 claim 继续参与冲突/召回。
159
+ * B3(X7)异步化:16 host-state proxy 方法,签名统一 Promise(实现体仍同步) */
160
+ setMemoryArchived(memoryId: string, archived: boolean): Promise<boolean>;
157
161
  feedback(memoryIds: string[], signal: "useful" | "irrelevant" | "outdated" | "wrong"): Promise<{
158
162
  affected: number;
159
163
  }>;
@@ -163,12 +167,14 @@ export declare class LocalMemoryProvider implements MemoryProvider {
163
167
  getProfile(userId: string, key: string): string | null;
164
168
  /**
165
169
  * Set a user profile value (upsert).
170
+ * B3(X7)异步化:16 面 host-state proxy 方法。
166
171
  */
167
- setProfile(userId: string, key: string, value: string): void;
172
+ setProfile(userId: string, key: string, value: string): Promise<void>;
168
173
  /**
169
174
  * Get all profile entries for a user.
175
+ * B3(X7)异步化:16 面 host-state proxy 方法。
170
176
  */
171
- getAllProfiles(userId: string): Record<string, string>;
177
+ getAllProfiles(userId: string): Promise<Record<string, string>>;
172
178
  /**
173
179
  * Delete a profile entry.
174
180
  */
@@ -191,8 +197,9 @@ export declare class LocalMemoryProvider implements MemoryProvider {
191
197
  }[];
192
198
  /**
193
199
  * Get activity summary over recent N days (daily counts + highlights).
200
+ * B3(X7)异步化:16 面 host-state proxy 方法。
194
201
  */
195
- getActivitySummary(userId: string, days?: number): {
202
+ getActivitySummary(userId: string, days?: number): Promise<{
196
203
  dailyCounts: Array<{
197
204
  date: string;
198
205
  count: number;
@@ -204,7 +211,7 @@ export declare class LocalMemoryProvider implements MemoryProvider {
204
211
  importance: number;
205
212
  date: string;
206
213
  }>;
207
- };
214
+ }>;
208
215
  /**
209
216
  * List full memory records for a user (paginated). Used by the memory atlas
210
217
  * visualization, which needs the complete record shape (confidence, importance,
@@ -218,6 +225,7 @@ export declare class LocalMemoryProvider implements MemoryProvider {
218
225
  /**
219
226
  * Return the final atlas payload: a bounded interactive record window plus
220
227
  * whole-history buckets/clusters for large timelines.
228
+ * B3(X7)异步化:16 面 host-state proxy 方法。
221
229
  */
222
230
  getAtlas(userId: string, options?: {
223
231
  pageSize?: number;
@@ -227,7 +235,7 @@ export declare class LocalMemoryProvider implements MemoryProvider {
227
235
  bucketCount?: number;
228
236
  clusterLimit?: number;
229
237
  activeOnly?: boolean;
230
- }): import("./local-store-records.js").MemoryAtlasResult;
238
+ }): Promise<import("./local-store-records.js").MemoryAtlasResult>;
231
239
  /** Complete tag-scoped listing (resident refresh / onboarding purge) — see store.listByTag. */
232
240
  listMemoriesByTag(userId: string, tag: string): import("./local-store-records.js").MemoryRecord[];
233
241
  /**
@@ -252,8 +260,9 @@ export declare class LocalMemoryProvider implements MemoryProvider {
252
260
  /**
253
261
  * Synthesize a temporal narrative from memories in a time range.
254
262
  * Returns a structured timeline suitable for prompt injection.
263
+ * B3(X7)异步化:16 面 host-state proxy 方法。
255
264
  */
256
- synthesizeTimeline(userId: string, startMs: number, endMs: number): string;
265
+ synthesizeTimeline(userId: string, startMs: number, endMs: number): Promise<string>;
257
266
  /**
258
267
  * Rerank search results by applying recency boost, access frequency,
259
268
  * and importance weighting. No LLM needed - pure scoring heuristics.
@@ -7,6 +7,12 @@
7
7
  * 簇 ≥ 重复阈值才产 1 条 procedure 记忆 → 高复用晋升技能(见 coordinator)。
8
8
  * 成功闸不用 LLM 自评:正常终态 + 同 session 近窗内未被"重做"(在线否决)。
9
9
  * 与 feedback-distillation(反馈域)无关 —— 这里蒸馏的是任务执行模式。
10
+ *
11
+ * 【B3 登记·刻意不动】本文件的 profile 级 JSON store 直写(task-distill-candidates.json /
12
+ * promotion-proposals.json / procedure-usage.json,均 A 域)是 qla 写、gateway 读(gateway
13
+ * MemoryProfileService 已持 promotion-proposals.json)的**文件级共享过渡态**——B3.1 只反转
14
+ * memories.db 存取(LocalMemoryProvider→HostMemoryProvider),这批 JSON 随削藩批次归
15
+ * store-owner(spec §1 X7 裁决第 4 条)。单一事实源 docs/agent-supervision-authority-migration-spec.md。
10
16
  */
11
17
  /** 同模式判定的余弦下限。错聚有害(把不同任务蒸成一份配方),漏聚无害(下次再攒)。 */
12
18
  export declare const TASK_DISTILL_CLUSTER_SIM = 0.86;
@@ -1,77 +1,43 @@
1
1
  import { type ElectronNpm } from "../../runtime/infra/electron-node.js";
2
2
  export interface MarketplaceSource {
3
- /** Source type */
4
3
  type: "npm" | "git" | "url";
5
- /** Package name (npm), git URL, or zip URL */
6
4
  specifier: string;
7
- /** Optional version constraint (npm only) */
8
5
  version?: string;
9
6
  }
10
7
  export interface MarketplaceConfig {
11
- /** Enabled plugins from marketplace */
12
8
  enabledPlugins: MarketplaceSource[];
13
- /**
14
- * Enterprise policy: only allow plugins matching these names.
15
- * If set, any plugin not in the allowlist is blocked.
16
- */
17
9
  allowlist?: string[];
18
- /**
19
- * Enterprise policy: block these plugin names.
20
- */
21
10
  blocklist?: string[];
22
11
  }
23
- export interface MarketplaceCatalogEntry {
24
- /** Plugin name */
25
- name: string;
26
- /** Installed version */
27
- version: string;
28
- /** Source that provided this plugin */
29
- source: MarketplaceSource;
30
- /** Local install path */
31
- installPath: string;
32
- /** Install timestamp */
33
- installedAt: string;
34
- }
35
- export interface InstalledPluginsManifest {
36
- version: 1;
37
- plugins: MarketplaceCatalogEntry[];
38
- }
39
12
  export interface MarketplaceLogger {
40
13
  info(msg: string): void;
41
14
  warn(msg: string): void;
42
15
  }
43
- /**
44
- * Resolve the executable + argv for an npm invocation. The packaged desktop app is usually the ONLY
45
- * Node/npm on a terminal user's machine, so `execFileAsync("npm", …)` fails there with "'npm' is not
46
- * recognized". When the desktop bridge is present we run the bundled npm as `AstraClaw.exe npm-cli.js …`
47
- * with ELECTRON_RUN_AS_NODE=1 (via electronNpmEnv); in dev / CI / server / tests the bridge is null and
48
- * we fall back to the system `npm` unchanged. Same routing as the agent-install runner.
49
- *
50
- * Note: electronNpmEnv pins npm_config_prefix to the GLOBAL prefix only — it does not affect the local
51
- * `npm install --production` this module runs inside each extracted plugin dir.
52
- */
16
+ export interface StageMarketplaceNpmPluginRequest {
17
+ specifier: string;
18
+ version?: string;
19
+ /** Existing directory allocated and owned by the gateway. */
20
+ stageDir: string;
21
+ }
22
+ export interface StagedMarketplacePlugin {
23
+ name: string;
24
+ version: string;
25
+ contentDir: string;
26
+ }
27
+ type ExecResult = {
28
+ stdout: string;
29
+ stderr: string;
30
+ };
31
+ type ExecFile = (file: string, args: string[], options: Record<string, unknown>) => Promise<ExecResult>;
32
+ export interface MarketplaceComputeDeps {
33
+ resolveNpm?: () => ElectronNpm | null;
34
+ execFile?: ExecFile;
35
+ }
53
36
  export declare function resolveNpmExec(bridge: ElectronNpm | null, args: string[]): {
54
37
  file: string;
55
38
  argv: string[];
56
39
  env?: NodeJS.ProcessEnv;
57
40
  };
58
- /**
59
- * Load plugins from cache only (no network). Fast startup path.
60
- * CC parity: loadAllPluginsCacheOnly()
61
- */
62
- export declare function loadCachedPlugins(): string[];
63
- /**
64
- * Install/update marketplace plugins and return their local paths.
65
- * CC parity: loadAllPluginsWithDynamic()
66
- */
67
- export declare function installMarketplacePlugins(config: MarketplaceConfig, log: MarketplaceLogger): Promise<string[]>;
68
- /**
69
- * Get the marketplace config from user settings.
70
- * Reads ~/.qlogicagent/profiles/<owner>/marketplace.json
71
- */
72
- export declare function loadMarketplaceConfig(): MarketplaceConfig | null;
73
- /**
74
- * Combine local plugin dirs + marketplace plugin dirs for PluginLoader.
75
- * CC parity: loadAllPlugins() merges session + marketplace + builtin.
76
- */
77
- export declare function resolveAllPluginDirs(localDirs: string[], log: MarketplaceLogger): Promise<string[]>;
41
+ /** Download and materialize one npm plugin strictly inside the supplied stage. */
42
+ export declare function stageMarketplaceNpmPlugin(request: StageMarketplaceNpmPluginRequest, log: MarketplaceLogger, deps?: MarketplaceComputeDeps): Promise<StagedMarketplacePlugin>;
43
+ export {};
@@ -0,0 +1,28 @@
1
+ import type { PortableTool } from "../portable-tool.js";
2
+ export declare const IMAGE_UNDERSTAND_TOOL_NAME: "image_understand";
3
+ export declare const VIDEO_UNDERSTAND_TOOL_NAME: "video_understand";
4
+ export interface MediaUnderstandToolParams {
5
+ query?: string;
6
+ /** The URL field name varies per tool (image_url / video_url), so it's read via the index. */
7
+ [key: string]: unknown;
8
+ }
9
+ /** What the injected backend returns for one understanding call. */
10
+ export interface MediaUnderstandOutcome {
11
+ /** The model's answer/description (empty ⇔ nothing usable came back — see `failure`). */
12
+ text: string;
13
+ /** Why `text` is empty: "fetch_failed" (medium never reached the model) / "stream_error" /
14
+ * "empty_output" (model saw it, said nothing) / "no_model" (purpose unbound). undefined ⇔ success. */
15
+ failure?: string;
16
+ /** Input tokens billed, if known (diagnostic — a near-zero value on a media request corroborates fetch_failed). */
17
+ promptTokens?: number;
18
+ /** The resolved understanding model id, for the tool details. */
19
+ model?: string;
20
+ }
21
+ export interface MediaUnderstandToolDeps {
22
+ understand(params: {
23
+ url: string;
24
+ query?: string;
25
+ }): Promise<MediaUnderstandOutcome>;
26
+ }
27
+ export declare function createImageUnderstandTool(deps: MediaUnderstandToolDeps): PortableTool<MediaUnderstandToolParams>;
28
+ export declare function createVideoUnderstandTool(deps: MediaUnderstandToolDeps): PortableTool<MediaUnderstandToolParams>;
@@ -0,0 +1,136 @@
1
+ import type { PortableTool } from "../portable-tool.js";
2
+ import { type PreviewBrowserDriveResult, type PreviewBrowserToolParams } from "../../host-contract/index.js";
3
+ export { PREVIEW_BROWSER_ACTIONS } from "../../host-contract/index.js";
4
+ export type { PreviewBrowserAction, PreviewBrowserDriveResult, PreviewBrowserToolParams, } from "../../host-contract/index.js";
5
+ export declare const PREVIEW_BROWSER_TOOL_NAME: "preview_browser";
6
+ export interface PreviewBrowserToolDeps {
7
+ /**
8
+ * Drive the host-side preview view for one action. The host renders/executes it and
9
+ * returns text and/or a screenshot. If the host is not connected or the action fails,
10
+ * it returns `{ error }` (never silently empty). `signal` aborts an in-flight action.
11
+ */
12
+ drive(params: PreviewBrowserToolParams, signal?: AbortSignal): Promise<PreviewBrowserDriveResult>;
13
+ }
14
+ export declare const PREVIEW_BROWSER_TOOL_SCHEMA: {
15
+ readonly type: "object";
16
+ readonly properties: {
17
+ readonly action: {
18
+ readonly type: "string";
19
+ readonly enum: readonly ["navigate", "snapshot", "click", "type", "screenshot", "console", "network"];
20
+ readonly description: string;
21
+ };
22
+ readonly url: {
23
+ readonly type: "string";
24
+ readonly description: "URL to open. Required for action 'navigate'.";
25
+ };
26
+ readonly ref: {
27
+ readonly type: "string";
28
+ readonly description: "aria-ref of the target element, taken from a prior 'snapshot'. Required for 'click' and 'type'.";
29
+ };
30
+ readonly text: {
31
+ readonly type: "string";
32
+ readonly description: "Text to type into the element. Required for action 'type'.";
33
+ };
34
+ readonly submit: {
35
+ readonly type: "boolean";
36
+ readonly description: "For 'type': press Enter after typing to submit. Default false.";
37
+ };
38
+ readonly viewId: {
39
+ readonly type: "string";
40
+ readonly description: string;
41
+ };
42
+ };
43
+ readonly required: readonly ["action"];
44
+ readonly oneOf: readonly [{
45
+ readonly type: "object";
46
+ readonly properties: {
47
+ readonly action: {
48
+ readonly type: "string";
49
+ readonly const: "navigate";
50
+ };
51
+ readonly url: {
52
+ readonly type: "string";
53
+ readonly description: "URL to open.";
54
+ };
55
+ readonly viewId: {
56
+ type: "string";
57
+ description: string;
58
+ };
59
+ };
60
+ readonly required: readonly ["action", "url"];
61
+ readonly additionalProperties: false;
62
+ }, {
63
+ readonly type: "object";
64
+ readonly properties: {
65
+ readonly action: {
66
+ readonly type: "string";
67
+ readonly const: "snapshot";
68
+ };
69
+ readonly viewId: {
70
+ type: "string";
71
+ description: string;
72
+ };
73
+ };
74
+ readonly required: readonly ["action"];
75
+ readonly additionalProperties: false;
76
+ }, {
77
+ readonly type: "object";
78
+ readonly properties: {
79
+ readonly action: {
80
+ readonly type: "string";
81
+ readonly const: "click";
82
+ };
83
+ readonly ref: {
84
+ readonly type: "string";
85
+ readonly description: "aria-ref of the target element.";
86
+ };
87
+ readonly viewId: {
88
+ type: "string";
89
+ description: string;
90
+ };
91
+ };
92
+ readonly required: readonly ["action", "ref"];
93
+ readonly additionalProperties: false;
94
+ }, {
95
+ readonly type: "object";
96
+ readonly properties: {
97
+ readonly action: {
98
+ readonly type: "string";
99
+ readonly const: "type";
100
+ };
101
+ readonly ref: {
102
+ readonly type: "string";
103
+ readonly description: "aria-ref of the target element.";
104
+ };
105
+ readonly text: {
106
+ readonly type: "string";
107
+ readonly description: "Text to type into the element.";
108
+ };
109
+ readonly submit: {
110
+ readonly type: "boolean";
111
+ readonly description: "Press Enter after typing. Default false.";
112
+ };
113
+ readonly viewId: {
114
+ type: "string";
115
+ description: string;
116
+ };
117
+ };
118
+ readonly required: readonly ["action", "ref", "text"];
119
+ readonly additionalProperties: false;
120
+ }, ...{
121
+ type: "object";
122
+ properties: {
123
+ action: {
124
+ type: "string";
125
+ const: "screenshot" | "console" | "network";
126
+ };
127
+ viewId: {
128
+ type: "string";
129
+ description: string;
130
+ };
131
+ };
132
+ required: readonly ["action"];
133
+ additionalProperties: false;
134
+ }[]];
135
+ };
136
+ export declare function createPreviewBrowserTool(deps: PreviewBrowserToolDeps): PortableTool<PreviewBrowserToolParams>;
@@ -25,7 +25,16 @@ export declare class TaskOutput {
25
25
  writeStdout(data: string): void;
26
26
  /** Write stderr data (pipe mode). */
27
27
  writeStderr(data: string): void;
28
- /** Get captured stdout. For file mode, reads from disk. */
28
+ /**
29
+ * Get captured stdout. For file mode, reads from disk.
30
+ *
31
+ * This is the single chokepoint every consumer of a finished command's output flows through —
32
+ * the foreground result (ShellCommand.result) and the background-completed result (the same
33
+ * ShellCommand handle read by BackgroundTaskManager). Sanitizing CLIXML here (a guarded no-op
34
+ * for bash/clean output) is what unifies foreground and background exec: neither surface sees raw
35
+ * `#< CLIXML <Objs>…` noise. `#outputFileSize` tracks the RAW on-disk bytes (drives file-redundancy
36
+ * cleanup), so it is measured before sanitizing.
37
+ */
29
38
  getStdout(): Promise<string>;
30
39
  /** Get captured stderr. In file mode stderr is interleaved with stdout. */
31
40
  getStderr(): string;
@@ -114,7 +114,7 @@ export interface SkillManageResult {
114
114
  }
115
115
  export interface SkillToolDeps {
116
116
  /** List all available skills (Layer 0 metadata). */
117
- listSkills(): WorkspaceSkill[];
117
+ listSkills(): Promise<WorkspaceSkill[]>;
118
118
  /** List skills with full detail (for skills_list). */
119
119
  listSkillsFull(category?: string): Promise<SkillListOutput>;
120
120
  /** Read skill content (Layer 1 instructions). */
@@ -1,2 +1,3 @@
1
1
  import type { SourceProvider } from "../../runtime/ports/source-provider.js";
2
- export declare function createBraveSource(): SourceProvider;
2
+ import { type WebTunableEnvironment, type WebTunableSnapshotResolver } from "./web-tunable-resolver.js";
3
+ export declare function createBraveSource(resolveTunables: WebTunableSnapshotResolver, env?: WebTunableEnvironment): SourceProvider;
@@ -1,3 +1,4 @@
1
+ import { type WebTunableEnvironment, type WebTunableSnapshotResolver } from "./web-tunable-resolver.js";
1
2
  export interface ExtractedContent {
2
3
  content: string;
3
4
  title?: string;
@@ -10,6 +11,6 @@ export interface Crawl4aiExtractor {
10
11
  signal?: AbortSignal;
11
12
  }): Promise<ExtractedContent | null>;
12
13
  /** 是否已配置 base url(诊断用)。 */
13
- isConfigured(): boolean;
14
+ isConfigured(): Promise<boolean>;
14
15
  }
15
- export declare function createCrawl4aiExtractor(): Crawl4aiExtractor;
16
+ export declare function createCrawl4aiExtractor(resolveTunables: WebTunableSnapshotResolver, env?: WebTunableEnvironment): Crawl4aiExtractor;
@@ -1,2 +1,3 @@
1
1
  import type { SourceProvider } from "../../runtime/ports/source-provider.js";
2
- export declare function createExaSource(): SourceProvider;
2
+ import { type WebTunableEnvironment, type WebTunableSnapshotResolver } from "./web-tunable-resolver.js";
3
+ export declare function createExaSource(resolveTunables: WebTunableSnapshotResolver, env?: WebTunableEnvironment): SourceProvider;
@@ -1,4 +1,5 @@
1
1
  import type { SourceProvider } from "../../runtime/ports/source-provider.js";
2
- /** 解析 search-svc base url:settings tunables 环境变量。 */
3
- export declare function resolveSearchSvcBaseUrl(): Promise<string | undefined>;
4
- export declare function createSearchSvcSource(): SourceProvider;
2
+ import { type WebTunableEnvironment, type WebTunableSnapshotResolver } from "./web-tunable-resolver.js";
3
+ /** 解析 search-svc base url:host tunable 非空优先,空 override 才回退环境变量。 */
4
+ export declare function resolveSearchSvcBaseUrl(resolveTunables: WebTunableSnapshotResolver, env?: WebTunableEnvironment): Promise<string | undefined>;
5
+ export declare function createSearchSvcSource(resolveTunables: WebTunableSnapshotResolver, env?: WebTunableEnvironment): SourceProvider;
@@ -1,2 +1,4 @@
1
1
  import type { SourceProvider } from "../../runtime/ports/source-provider.js";
2
- export declare function createSearxngSource(): SourceProvider;
2
+ import { type WebTunableEnvironment, type WebTunableSnapshotResolver } from "./web-tunable-resolver.js";
3
+ /** 解析 SearXNG base url:host tunable 非空优先,空 override 才回退环境变量。 */
4
+ export declare function createSearxngSource(resolveTunables: WebTunableSnapshotResolver, env?: WebTunableEnvironment): SourceProvider;
@@ -1,2 +1,3 @@
1
1
  import type { SourceProvider } from "../../runtime/ports/source-provider.js";
2
- export declare function createSerperSource(): SourceProvider;
2
+ import { type WebTunableEnvironment, type WebTunableSnapshotResolver } from "./web-tunable-resolver.js";
3
+ export declare function createSerperSource(resolveTunables: WebTunableSnapshotResolver, env?: WebTunableEnvironment): SourceProvider;
@@ -1,5 +1,6 @@
1
1
  import type { SourceProvider } from "../../runtime/ports/source-provider.js";
2
+ import type { WebTunableEnvironment, WebTunableSnapshotResolver } from "./web-tunable-resolver.js";
2
3
  /**
3
4
  * 组装 web_search 的 L0 数据源集合(运行期各源自行懒解析配置细节)。
4
5
  */
5
- export declare function buildWebSearchSources(): SourceProvider[];
6
+ export declare function buildWebSearchSources(resolveTunables: WebTunableSnapshotResolver, env?: WebTunableEnvironment): SourceProvider[];
@@ -0,0 +1,16 @@
1
+ import { type TunableDefaults } from "../../tunables.js";
2
+ export type WebTunableSnapshot = Readonly<TunableDefaults>;
3
+ export type WebTunableSnapshotResolver = () => Promise<WebTunableSnapshot>;
4
+ export type WebTunableEnvironment = Record<string, string | undefined>;
5
+ /**
6
+ * Build one lazy snapshot for one web-tool invocation/search. The loader is not touched during
7
+ * synchronous registration; the first consumer starts it and all sibling consumers reuse the
8
+ * exact in-flight/settled Promise. Rejections are cached too so a host failure cannot degrade into
9
+ * a later env/local fallback inside the same invocation. Callers construct a fresh resolver for
10
+ * the next invoke so host updates are hot and a rejected request can retry.
11
+ */
12
+ export declare function createWebTunableSnapshotResolver(loadOverrides: () => Promise<Record<string, unknown>>): WebTunableSnapshotResolver;
13
+ /** Explicit standalone-server mode: shared defaults + source-specific env fallback, no local store. */
14
+ export declare function createEnvOnlyWebTunableResolver(): WebTunableSnapshotResolver;
15
+ /** Non-empty host override wins; an empty shared-default/override alone permits the legacy env fallback. */
16
+ export declare function resolveWebTunableString(resolveSnapshot: WebTunableSnapshotResolver, key: keyof Pick<TunableDefaults, "exaApiKey" | "braveApiKey" | "serperApiKey" | "searxngBaseUrl" | "searchSvcBaseUrl" | "crawl4aiBaseUrl">, envName: string, env: WebTunableEnvironment): Promise<string | undefined>;
@@ -0,0 +1,2 @@
1
+ export declare function setupGlobalTestHome(): () => void;
2
+ export default function globalSetup(): () => void;