@octopi-agent/engine 0.102.10 → 0.121.10

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 (317) hide show
  1. package/dist/builtin-model-info.js +28 -7
  2. package/dist/config-admin/agent-presets.d.ts +32 -0
  3. package/dist/config-admin/agent-presets.js +133 -0
  4. package/dist/config-admin/discover.d.ts +33 -4
  5. package/dist/config-admin/discover.js +101 -6
  6. package/dist/config-admin/env.d.ts +11 -0
  7. package/dist/config-admin/env.js +41 -0
  8. package/dist/config-admin/error-copy.d.ts +106 -0
  9. package/dist/config-admin/error-copy.js +287 -0
  10. package/dist/config-admin/i18n.d.ts +21 -0
  11. package/dist/config-admin/i18n.js +19 -0
  12. package/dist/config-admin/index.d.ts +6 -2
  13. package/dist/config-admin/index.js +3 -1
  14. package/dist/config-admin/model-presets.d.ts +14 -0
  15. package/dist/config-admin/model-presets.js +595 -70
  16. package/dist/config-admin/onboarding-apply.d.ts +71 -0
  17. package/dist/config-admin/onboarding-apply.js +235 -0
  18. package/dist/config-admin/onboarding.d.ts +154 -0
  19. package/dist/config-admin/onboarding.js +270 -0
  20. package/dist/config-admin/redact.d.ts +42 -9
  21. package/dist/config-admin/redact.js +69 -5
  22. package/dist/config-schema/agent.d.ts +5 -1
  23. package/dist/config-schema/agent.js +20 -2
  24. package/dist/config-schema/browser.d.ts +62 -0
  25. package/dist/config-schema/browser.js +89 -0
  26. package/dist/config-schema/context.d.ts +7 -2
  27. package/dist/config-schema/context.js +6 -3
  28. package/dist/config-schema/engine.d.ts +86 -7
  29. package/dist/config-schema/engine.js +9 -2
  30. package/dist/config-schema/governance.d.ts +12 -1
  31. package/dist/config-schema/governance.js +10 -2
  32. package/dist/config-schema/models.d.ts +12 -8
  33. package/dist/config-schema/models.js +16 -1
  34. package/dist/config-schema/run.d.ts +4 -0
  35. package/dist/config-schema/run.js +10 -0
  36. package/dist/config-schema/shared.d.ts +1 -0
  37. package/dist/config-schema/shared.js +4 -2
  38. package/dist/config-schema/substrate.d.ts +5 -0
  39. package/dist/config-schema/substrate.js +8 -0
  40. package/dist/config.d.ts +116 -10
  41. package/dist/config.js +109 -13
  42. package/dist/file-mode.d.ts +67 -0
  43. package/dist/file-mode.js +182 -0
  44. package/dist/fork-child.d.ts +82 -0
  45. package/dist/fork-child.js +123 -0
  46. package/dist/harness/activation/delegated-run.d.ts +42 -0
  47. package/dist/harness/activation/delegated-run.js +71 -0
  48. package/dist/harness/activation/dispatcher.js +4 -0
  49. package/dist/harness/activation/index.d.ts +1 -0
  50. package/dist/harness/activation/run-backend.d.ts +92 -0
  51. package/dist/harness/activation/run-backend.js +16 -0
  52. package/dist/harness/activation/run-protocol.d.ts +392 -0
  53. package/dist/harness/activation/run-protocol.js +19 -0
  54. package/dist/harness/activation/runtime.d.ts +33 -0
  55. package/dist/harness/activation/runtime.js +119 -28
  56. package/dist/harness/activation/types.d.ts +19 -2
  57. package/dist/harness/agent/builder.d.ts +12 -0
  58. package/dist/harness/agent/builder.js +78 -22
  59. package/dist/harness/agent/config-bridge.d.ts +10 -1
  60. package/dist/harness/agent/config-bridge.js +15 -3
  61. package/dist/harness/agent/registered-tool-adapter.d.ts +27 -0
  62. package/dist/harness/agent/registered-tool-adapter.js +67 -0
  63. package/dist/harness/agent/wire-agent-builder.d.ts +2 -0
  64. package/dist/harness/agent/wire-agent-builder.js +9 -2
  65. package/dist/harness/capabilities/document/backends/plain.js +2 -1
  66. package/dist/harness/capabilities/document/legacy/factory.js +3 -2
  67. package/dist/harness/collaboration/autonomous-subsystem/audit/reader.d.ts +17 -0
  68. package/dist/harness/collaboration/autonomous-subsystem/audit/reader.js +66 -36
  69. package/dist/harness/collaboration/autonomous-subsystem/audit/writer.d.ts +6 -2
  70. package/dist/harness/collaboration/autonomous-subsystem/audit/writer.js +27 -7
  71. package/dist/harness/collaboration/autonomous-subsystem/boundary/validator.js +13 -0
  72. package/dist/harness/collaboration/autonomous-subsystem/loader.js +1 -0
  73. package/dist/harness/collaboration/autonomous-subsystem/runtime.d.ts +11 -0
  74. package/dist/harness/collaboration/autonomous-subsystem/runtime.js +17 -0
  75. package/dist/harness/collaboration/autonomous-subsystem/sense/engine.d.ts +13 -3
  76. package/dist/harness/collaboration/autonomous-subsystem/sense/engine.js +48 -39
  77. package/dist/harness/collaboration/autonomous-subsystem/think/executor.js +3 -0
  78. package/dist/harness/collaboration/autonomous-subsystem/types.d.ts +4 -0
  79. package/dist/harness/collaboration/delegation/child-run.d.ts +9 -0
  80. package/dist/harness/collaboration/delegation/child-run.js +34 -2
  81. package/dist/harness/collaboration/delegation/registry-types.d.ts +2 -0
  82. package/dist/harness/collaboration/delegation/service.d.ts +9 -4
  83. package/dist/harness/collaboration/delegation/service.js +33 -12
  84. package/dist/harness/collaboration/delegation/store.d.ts +2 -0
  85. package/dist/harness/collaboration/delegation/store.js +1 -0
  86. package/dist/harness/collaboration/delegation/types.d.ts +11 -0
  87. package/dist/harness/collaboration/delegation/wiring.d.ts +2 -0
  88. package/dist/harness/collaboration/delegation/wiring.js +1 -0
  89. package/dist/harness/context/capabilities/compact/engine.d.ts +44 -5
  90. package/dist/harness/context/capabilities/compact/engine.js +127 -39
  91. package/dist/harness/context/capabilities/compact/index.d.ts +2 -1
  92. package/dist/harness/context/capabilities/compact/index.js +1 -1
  93. package/dist/harness/context/capabilities/compact/types.d.ts +59 -9
  94. package/dist/harness/context/capabilities/summary/gate.d.ts +19 -2
  95. package/dist/harness/context/capabilities/summary/gate.js +53 -6
  96. package/dist/harness/context/capabilities/summary/registry.js +20 -0
  97. package/dist/harness/context/capabilities/summary/tool-binding.js +16 -12
  98. package/dist/harness/context/capabilities/summary/tool-bindings.d.ts +13 -0
  99. package/dist/harness/context/capabilities/summary/tool-bindings.js +22 -0
  100. package/dist/harness/context/capabilities/summary/types.d.ts +16 -0
  101. package/dist/harness/context/constitution/default-agents.md +85 -0
  102. package/dist/harness/context/context-size-ledger.js +8 -1
  103. package/dist/harness/context/default-context-engine.d.ts +100 -6
  104. package/dist/harness/context/default-context-engine.js +382 -89
  105. package/dist/harness/context/index.d.ts +2 -1
  106. package/dist/harness/context/index.js +1 -0
  107. package/dist/harness/context/layer-health.d.ts +4 -0
  108. package/dist/harness/context/layer-health.js +4 -0
  109. package/dist/harness/context/layer-types.d.ts +57 -0
  110. package/dist/harness/context/layer-types.js +73 -1
  111. package/dist/harness/context/layers.d.ts +3 -0
  112. package/dist/harness/context/layers.js +13 -6
  113. package/dist/harness/context/prefix-fingerprint.d.ts +46 -0
  114. package/dist/harness/context/prefix-fingerprint.js +52 -0
  115. package/dist/harness/context/summarize.js +18 -0
  116. package/dist/harness/context/system-prompt-assembler.d.ts +2 -0
  117. package/dist/harness/context/system-prompt-assembler.js +5 -2
  118. package/dist/harness/context/tool-result-aging.d.ts +104 -16
  119. package/dist/harness/context/tool-result-aging.js +211 -57
  120. package/dist/harness/context/types.d.ts +71 -4
  121. package/dist/harness/context/types.js +25 -1
  122. package/dist/harness/extension/execution-environment/effect-policy.d.ts +4 -3
  123. package/dist/harness/extension/execution-environment/effect-policy.js +2 -2
  124. package/dist/harness/extension/execution-environment/privileged-exec.js +4 -1
  125. package/dist/harness/extension/execution-environment/workspace.js +1 -1
  126. package/dist/harness/extension/plugin-ecosystem/channel-types.d.ts +27 -1
  127. package/dist/harness/extension/plugin-ecosystem/channel-types.js +11 -2
  128. package/dist/harness/extension/plugin-ecosystem/client-tools/registry.d.ts +12 -0
  129. package/dist/harness/extension/plugin-ecosystem/client-tools/registry.js +25 -0
  130. package/dist/harness/extension/plugin-ecosystem/commands/builtin.js +28 -1
  131. package/dist/harness/extension/plugin-ecosystem/index.d.ts +1 -0
  132. package/dist/harness/extension/plugin-ecosystem/index.js +1 -0
  133. package/dist/harness/extension/plugin-ecosystem/plugins/api.d.ts +168 -1
  134. package/dist/harness/extension/plugin-ecosystem/plugins/api.js +156 -15
  135. package/dist/harness/extension/plugin-ecosystem/plugins/contribution-instances.d.ts +95 -0
  136. package/dist/harness/extension/plugin-ecosystem/plugins/contribution-instances.js +170 -0
  137. package/dist/harness/extension/plugin-ecosystem/plugins/contribution-kinds.d.ts +178 -0
  138. package/dist/harness/extension/plugin-ecosystem/plugins/contribution-kinds.js +314 -0
  139. package/dist/harness/extension/plugin-ecosystem/plugins/contribution-registry.d.ts +40 -5
  140. package/dist/harness/extension/plugin-ecosystem/plugins/contribution-registry.js +45 -26
  141. package/dist/harness/extension/plugin-ecosystem/plugins/index.d.ts +1 -1
  142. package/dist/harness/extension/plugin-ecosystem/plugins/loader.d.ts +11 -1
  143. package/dist/harness/extension/plugin-ecosystem/plugins/loader.js +42 -76
  144. package/dist/harness/extension/plugin-ecosystem/plugins/manager.d.ts +30 -1
  145. package/dist/harness/extension/plugin-ecosystem/plugins/manager.js +46 -0
  146. package/dist/harness/extension/plugin-ecosystem/plugins/manifest.d.ts +9 -0
  147. package/dist/harness/extension/plugin-ecosystem/plugins/manifest.js +19 -14
  148. package/dist/harness/extension/plugin-ecosystem/plugins/staging.d.ts +3 -1
  149. package/dist/harness/extension/plugin-ecosystem/plugins/staging.js +1 -1
  150. package/dist/harness/extension/plugin-ecosystem/tools/browser-types.d.ts +333 -0
  151. package/dist/harness/extension/plugin-ecosystem/tools/browser-types.js +16 -0
  152. package/dist/harness/extension/plugin-ecosystem/tools/browser.d.ts +64 -0
  153. package/dist/harness/extension/plugin-ecosystem/tools/browser.js +692 -0
  154. package/dist/harness/extension/plugin-ecosystem/tools/builtin.d.ts +0 -37
  155. package/dist/harness/extension/plugin-ecosystem/tools/builtin.js +108 -4
  156. package/dist/harness/extension/plugin-ecosystem/tools/delegation.js +18 -0
  157. package/dist/harness/extension/plugin-ecosystem/tools/file-edit.js +34 -0
  158. package/dist/harness/extension/plugin-ecosystem/tools/file-search.d.ts +0 -6
  159. package/dist/harness/extension/plugin-ecosystem/tools/file-search.js +57 -4
  160. package/dist/harness/extension/plugin-ecosystem/tools/git-tools.js +81 -13
  161. package/dist/harness/extension/plugin-ecosystem/tools/http.js +5 -0
  162. package/dist/harness/extension/plugin-ecosystem/tools/knowledge.js +13 -7
  163. package/dist/harness/extension/plugin-ecosystem/tools/package-tools.js +126 -14
  164. package/dist/harness/extension/plugin-ecosystem/tools/platform.d.ts +1 -1
  165. package/dist/harness/extension/plugin-ecosystem/tools/platform.js +44 -5
  166. package/dist/harness/extension/plugin-ecosystem/tools/tool-bus.js +10 -24
  167. package/dist/harness/extension/plugin-ecosystem/tools/tool-set.d.ts +7 -0
  168. package/dist/harness/extension/plugin-ecosystem/tools/tool-set.js +4 -0
  169. package/dist/harness/governance/credentials/db.d.ts +9 -0
  170. package/dist/harness/governance/credentials/db.js +122 -31
  171. package/dist/harness/governance/credentials/store.d.ts +68 -7
  172. package/dist/harness/governance/credentials/store.js +177 -64
  173. package/dist/harness/governance/credentials/types.d.ts +13 -2
  174. package/dist/harness/governance/index.d.ts +1 -0
  175. package/dist/harness/governance/index.js +1 -0
  176. package/dist/harness/governance/registry/db.d.ts +32 -0
  177. package/dist/harness/governance/registry/db.js +142 -0
  178. package/dist/harness/governance/registry/index.d.ts +9 -0
  179. package/dist/harness/governance/registry/index.js +9 -0
  180. package/dist/harness/governance/registry/service.d.ts +381 -0
  181. package/dist/harness/governance/registry/service.js +825 -0
  182. package/dist/harness/governance/registry/types.d.ts +77 -0
  183. package/dist/harness/governance/registry/types.js +7 -0
  184. package/dist/harness/governance/security/default-security-guard.d.ts +3 -0
  185. package/dist/harness/governance/security/default-security-guard.js +12 -1
  186. package/dist/harness/governance/security/risk-evaluator.d.ts +13 -3
  187. package/dist/harness/governance/security/risk-evaluator.js +307 -21
  188. package/dist/harness/governance/security/shell-parser-treesitter.js +12 -4
  189. package/dist/harness/governance/session-acl/tool-rights.d.ts +1 -0
  190. package/dist/harness/index.d.ts +5 -3
  191. package/dist/harness/index.js +2 -2
  192. package/dist/harness/knowledge/boot-config.d.ts +2 -0
  193. package/dist/harness/knowledge/boot-config.js +2 -0
  194. package/dist/harness/knowledge/client.d.ts +53 -7
  195. package/dist/harness/knowledge/client.js +77 -20
  196. package/dist/harness/knowledge/db.d.ts +16 -0
  197. package/dist/harness/knowledge/db.js +107 -41
  198. package/dist/harness/knowledge/engine-thread.js +5 -7
  199. package/dist/harness/knowledge/grounding.js +4 -1
  200. package/dist/harness/knowledge/http-app.d.ts +15 -0
  201. package/dist/harness/knowledge/http-app.js +82 -21
  202. package/dist/harness/knowledge/http-bridge.d.ts +15 -0
  203. package/dist/harness/knowledge/http-bridge.js +19 -0
  204. package/dist/harness/knowledge/knowledge-serve-child.js +2 -3
  205. package/dist/harness/knowledge/query-service.d.ts +12 -2
  206. package/dist/harness/knowledge/query-service.js +75 -41
  207. package/dist/harness/knowledge/query-worker-client.d.ts +5 -1
  208. package/dist/harness/knowledge/query-worker-client.js +4 -1
  209. package/dist/harness/knowledge/query-worker.js +5 -3
  210. package/dist/harness/knowledge/read-http.d.ts +2 -0
  211. package/dist/harness/knowledge/read-http.js +9 -2
  212. package/dist/harness/knowledge/retriever.d.ts +1 -1
  213. package/dist/harness/knowledge/retriever.js +1 -2
  214. package/dist/harness/knowledge/serve.d.ts +6 -1
  215. package/dist/harness/knowledge/serve.js +5 -6
  216. package/dist/harness/knowledge/source-store.d.ts +101 -5
  217. package/dist/harness/knowledge/source-store.js +297 -71
  218. package/dist/harness/knowledge/start-service-process.d.ts +27 -8
  219. package/dist/harness/knowledge/start-service-process.js +49 -90
  220. package/dist/harness/knowledge/tenant-gate.d.ts +81 -0
  221. package/dist/harness/knowledge/tenant-gate.js +167 -0
  222. package/dist/harness/knowledge/writer-service.d.ts +18 -2
  223. package/dist/harness/knowledge/writer-service.js +80 -16
  224. package/dist/harness/knowledge/writer-worker-client.d.ts +9 -2
  225. package/dist/harness/knowledge/writer-worker-client.js +20 -3
  226. package/dist/harness/knowledge/writer-worker.js +11 -4
  227. package/dist/harness/memory/backfill-trigger.d.ts +10 -3
  228. package/dist/harness/memory/backfill-trigger.js +19 -19
  229. package/dist/harness/memory/cognition-seeds.d.ts +45 -0
  230. package/dist/harness/memory/cognition-seeds.js +67 -0
  231. package/dist/harness/memory/cognition.d.ts +12 -3
  232. package/dist/harness/memory/cognition.js +55 -35
  233. package/dist/harness/memory/conceptualizer.d.ts +11 -1
  234. package/dist/harness/memory/conceptualizer.js +10 -1
  235. package/dist/harness/memory/context-slice.d.ts +42 -0
  236. package/dist/harness/memory/context-slice.js +197 -0
  237. package/dist/harness/memory/health-probe.d.ts +8 -2
  238. package/dist/harness/memory/health-probe.js +10 -13
  239. package/dist/harness/memory/index.d.ts +5 -1
  240. package/dist/harness/memory/index.js +3 -1
  241. package/dist/harness/memory/sqlite/agent-db.d.ts +1 -0
  242. package/dist/harness/memory/sqlite/agent-db.js +9 -8
  243. package/dist/harness/memory/sqlite/cognition-store.d.ts +26 -3
  244. package/dist/harness/memory/sqlite/cognition-store.js +103 -45
  245. package/dist/harness/memory/sqlite/memory-store.js +4 -0
  246. package/dist/harness/memory/sqlite/sqlite-vec.d.ts +24 -1
  247. package/dist/harness/memory/sqlite/sqlite-vec.js +37 -1
  248. package/dist/harness/memory/types.d.ts +18 -2
  249. package/dist/harness/observability/observer/hub.d.ts +10 -0
  250. package/dist/harness/observability/observer/hub.js +95 -2
  251. package/dist/harness/run/agent/agent.js +3 -2
  252. package/dist/harness/run/concurrency/tool-validator.js +4 -3
  253. package/dist/harness/run/reliability/run-agent.d.ts +22 -0
  254. package/dist/harness/run/reliability/run-agent.js +79 -10
  255. package/dist/harness/run/run-host.d.ts +302 -0
  256. package/dist/harness/run/run-host.js +978 -0
  257. package/dist/harness/run/run-scope.d.ts +11 -0
  258. package/dist/harness/run/run-scope.js +19 -1
  259. package/dist/harness/run/runner.d.ts +149 -22
  260. package/dist/harness/run/runner.js +352 -35
  261. package/dist/harness/session/in-memory-store.js +13 -1
  262. package/dist/harness/session/schedules/service.d.ts +10 -2
  263. package/dist/harness/session/schedules/service.js +13 -2
  264. package/dist/harness/session/tasks/tools.js +12 -0
  265. package/dist/harness/session/types.d.ts +10 -14
  266. package/dist/harness/shared/events/agent-event-map.d.ts +29 -0
  267. package/dist/harness/shared/types/agent-definition.d.ts +6 -0
  268. package/dist/index.d.ts +3 -2
  269. package/dist/index.js +2 -1
  270. package/dist/integration/agent-runtime/channel-message-source.d.ts +3 -1
  271. package/dist/integration/agent-runtime/channel-message-source.js +4 -3
  272. package/dist/integration/browser/camoufox.d.ts +40 -0
  273. package/dist/integration/browser/camoufox.js +80 -0
  274. package/dist/integration/browser/index.d.ts +91 -0
  275. package/dist/integration/browser/index.js +110 -0
  276. package/dist/integration/browser/install.d.ts +47 -0
  277. package/dist/integration/browser/install.js +214 -0
  278. package/dist/integration/browser/playwright.d.ts +224 -0
  279. package/dist/integration/browser/playwright.js +925 -0
  280. package/dist/integration/browser/service.d.ts +41 -0
  281. package/dist/integration/browser/service.js +181 -0
  282. package/dist/integration/browser/stealth.d.ts +42 -0
  283. package/dist/integration/browser/stealth.js +104 -0
  284. package/dist/integration/providers/anthropic-message-normalize.d.ts +20 -0
  285. package/dist/integration/providers/anthropic-message-normalize.js +48 -0
  286. package/dist/integration/providers/anthropic.js +27 -2
  287. package/dist/integration/providers/fetch-timeout.d.ts +17 -0
  288. package/dist/integration/providers/fetch-timeout.js +24 -0
  289. package/dist/integration/providers/openai.d.ts +8 -0
  290. package/dist/integration/providers/openai.js +41 -1
  291. package/dist/integration/providers/wire-dump-diff.js +2 -1
  292. package/dist/integration/providers/wire-dump.d.ts +56 -2
  293. package/dist/integration/providers/wire-dump.js +119 -6
  294. package/dist/integration/storage/archive-manager.d.ts +14 -2
  295. package/dist/integration/storage/archive-manager.js +24 -8
  296. package/dist/integration/storage/atomic-tmp.d.ts +12 -0
  297. package/dist/integration/storage/atomic-tmp.js +36 -0
  298. package/dist/integration/storage/jsonl.d.ts +9 -0
  299. package/dist/integration/storage/jsonl.js +137 -38
  300. package/dist/integration/storage/session-index.d.ts +5 -0
  301. package/dist/integration/storage/session-index.js +25 -4
  302. package/dist/integration/tools/assemble.d.ts +50 -0
  303. package/dist/integration/tools/assemble.js +137 -0
  304. package/dist/paths.d.ts +18 -0
  305. package/dist/paths.js +36 -0
  306. package/dist/subsystems/cognition-steward/conceptualize/config.yaml +3 -1
  307. package/dist/subsystems/cognition-steward/conceptualize/handler.js +74 -5
  308. package/dist/subsystems/cognition-steward/consolidate/SUBSYSTEM.md +3 -2
  309. package/dist/subsystems/cognition-steward/consolidate/config.yaml +11 -2
  310. package/dist/subsystems/cognition-steward/consolidate/handler.d.ts +6 -3
  311. package/dist/subsystems/cognition-steward/consolidate/handler.js +266 -28
  312. package/dist/subsystems/memory-steward/backfill/handler.js +3 -2
  313. package/dist/subsystems/memory-steward/govern/config.yaml +6 -1
  314. package/dist/subsystems/wisdom-steward/attribute/config.yaml +5 -1
  315. package/dist/subsystems/wisdom-steward/formation/config.yaml +3 -0
  316. package/dist/subsystems/wisdom-steward/govern/config.yaml +6 -1
  317. package/package.json +5 -3
@@ -5,13 +5,18 @@
5
5
  * 语料命中为不可信资料,不得当指令执行。
6
6
  * 可见性与 session 必须来自 Run context,禁止参数伪造。
7
7
  */
8
+ import { DEFAULT_TENANT_ID } from '@octopi-agent/core/types.js';
8
9
  import { asSourceId } from '../../../knowledge/types.js';
9
10
  import { wrapUntrustedKnowledgeBlock } from '../../../knowledge/grounding.js';
11
+ import { getRunScope } from '../../../run/run-scope.js';
10
12
  function resolveIds(context) {
11
13
  const ctx = (context ?? {});
12
14
  return {
13
15
  agentId: ctx.agentId?.trim() || 'default',
14
16
  sessionId: ctx.sessionId?.trim() || undefined,
17
+ // 归属锚(arch/multi-tenancy.md §4/§6):run 归属租户(禁止参数伪造);
18
+ // 未接身份层 = DEFAULT 域(存量语义)
19
+ tenantId: getRunScope()?.principal?.tenantId ?? DEFAULT_TENANT_ID,
15
20
  };
16
21
  }
17
22
  export function createKnowledgeTools(options) {
@@ -54,12 +59,13 @@ export function createKnowledgeSearchTool(options) {
54
59
  if (!query)
55
60
  return { hits: [], error: 'query is required' };
56
61
  const limit = Math.min(Number(args.limit) || maxResults, 20);
57
- const { agentId, sessionId } = resolveIds(context);
62
+ const { agentId, sessionId, tenantId } = resolveIds(context);
58
63
  const sourceId = args.source_id ? String(args.source_id).trim() : '';
59
64
  const sourceName = args.source ? String(args.source).trim() : '';
60
65
  const result = await options.retriever.search(query, {
61
66
  agentId,
62
67
  sessionId,
68
+ tenantId,
63
69
  limit,
64
70
  sourceIds: sourceId ? [sourceId] : undefined,
65
71
  source: sourceName || undefined,
@@ -110,11 +116,11 @@ export function createKnowledgeReadTool(options) {
110
116
  },
111
117
  handler: async (args, context) => {
112
118
  const maxChars = Math.min(Number(args.max_chars) || maxReadChars, 32_000);
113
- const { agentId, sessionId } = resolveIds(context);
119
+ const { agentId, sessionId, tenantId } = resolveIds(context);
114
120
  const chunkId = args.chunk_id ? String(args.chunk_id) : '';
115
121
  const canSee = (sourceId) => {
116
122
  const src = options.sourceStore.get(sourceId);
117
- return src ? options.sourceStore.isVisible(src, agentId, sessionId) : false;
123
+ return src ? options.sourceStore.isVisible(src, agentId, sessionId, { tenantId }) : false;
118
124
  };
119
125
  if (chunkId) {
120
126
  const row = options.indexStore.getChunk(chunkId);
@@ -200,11 +206,11 @@ export function createKnowledgeClientTools(options) {
200
206
  const query = String(args.query ?? '').trim();
201
207
  if (!query)
202
208
  return { hits: [], error: 'query is required' };
203
- const { agentId, sessionId } = resolveIds(context);
209
+ const { agentId, sessionId, tenantId } = resolveIds(context);
204
210
  const limit = Math.min(Number(args.limit) || maxResults, 20);
205
211
  try {
206
212
  await client.ensurePrincipal(agentId).catch(() => undefined);
207
- const result = await client.search(agentId, query, { sessionId, limit });
213
+ const result = await client.search(agentId, query, { sessionId, limit, tenantId });
208
214
  const hits = (result.hits ?? []);
209
215
  return {
210
216
  usedVector: result.usedVector,
@@ -243,7 +249,7 @@ export function createKnowledgeClientTools(options) {
243
249
  },
244
250
  handler: async (args, context) => {
245
251
  const maxChars = Math.min(Number(args.max_chars) || maxReadChars, 32_000);
246
- const { agentId } = resolveIds(context);
252
+ const { agentId, tenantId } = resolveIds(context);
247
253
  try {
248
254
  await client.ensurePrincipal(agentId).catch(() => undefined);
249
255
  const chunkId = args.chunk_id ? String(args.chunk_id) : '';
@@ -251,7 +257,7 @@ export function createKnowledgeClientTools(options) {
251
257
  const sourceId = args.source_id ? String(args.source_id) : '';
252
258
  const data = await client.read(agentId, chunkId
253
259
  ? { chunkId }
254
- : { sourceId, path });
260
+ : { sourceId, path }, { tenantId });
255
261
  if (!data?.found) {
256
262
  return { found: false, error: 'chunk not found' };
257
263
  }
@@ -9,14 +9,23 @@
9
9
  * when networkPolicy is not open (prompt the user to install manually).
10
10
  */
11
11
  import { tmpdir } from 'node:os';
12
- import { join } from 'node:path';
12
+ import { dirname, join } from 'node:path';
13
13
  import { gateEffect } from '../../execution-environment/effect-policy.js';
14
14
  import { containmentOptions, findExecutable, isUnderAttachmentRoot, isUnderSessionUndoRoot, resolveToolPath, } from './platform.js';
15
15
  import { runAllowlistedArgv } from './allowlisted-run.js';
16
16
  import { resolveNodeToolCommand } from './platform.js';
17
+ /**
18
+ * 解析并校验项目目录(containment / attachment / undo 保护)。
19
+ *
20
+ * `raw` 必传、无缺省:三个 package 工具的 cwd 都是必填入参,这里不再提供
21
+ * 「回落到会话 workspace」的路径——否则静默错靶会从这里重新长出来。
22
+ *
23
+ * @param context - 工具执行上下文(提供 containment 根)
24
+ * @param raw - 已由 `requireCwd` 校验非空的项目目录
25
+ * @returns 已解析并做过 containment 校验的项目目录
26
+ */
17
27
  function resolveCwd(context, raw) {
18
- const cwd = raw ?? context?.cwd ?? process.cwd();
19
- const abs = resolveToolPath(cwd, context?.cwd, containmentOptions(context));
28
+ const abs = resolveToolPath(raw, context?.cwd, containmentOptions(context));
20
29
  if (isUnderAttachmentRoot(abs, context?.attachmentRoots)) {
21
30
  throw new Error('session attachments are read-only; cannot run package tools under attachments root');
22
31
  }
@@ -25,8 +34,36 @@ function resolveCwd(context, raw) {
25
34
  }
26
35
  return abs;
27
36
  }
28
- function assertPathSafe(raw, context, label) {
29
- const abs = resolveToolPath(raw, context?.cwd, containmentOptions(context));
37
+ /**
38
+ * 三个 package 工具共用的 cwd 契约:必填,缺省绝不回落到会话 workspace。
39
+ *
40
+ * 依据:workspace 通常不是目标项目——`project_run` 会对着另一个仓库的同名脚本执行,
41
+ * `package_edit` 会改 workspace 自己的 package.json,`package_install` 会往错误目录装依赖。
42
+ * 静默错靶(改错文件/装错仓库)比显式报错代价高得多,所以这里 fail loud。
43
+ *
44
+ * @param context - 工具执行上下文(提供 containment 根)
45
+ * @param raw - 工具入参 cwd
46
+ * @param tool - 工具名,用于错误前缀(`<tool>_cwd_required`)
47
+ * @returns 已解析并做过 containment 校验的项目目录
48
+ */
49
+ function requireCwd(context, raw, tool) {
50
+ const value = typeof raw === 'string' ? raw.trim() : '';
51
+ if (!value) {
52
+ throw new Error(`${tool}_cwd_required: pass the project directory containing package.json; it is never inferred from the workspace cwd`);
53
+ }
54
+ return resolveCwd(context, value);
55
+ }
56
+ /**
57
+ * 把工具入参路径解析到**本次操作的项目目录**,而不是会话 workspace。
58
+ *
59
+ * @param raw - 工具入参中的相对/绝对路径
60
+ * @param context - 工具执行上下文
61
+ * @param label - 动作标签,用于错误信息
62
+ * @param baseCwd - 相对路径的基准目录(项目目录)
63
+ * @returns 已解析并做过 containment / denylist 校验的绝对路径
64
+ */
65
+ function assertPathSafe(raw, context, label, baseCwd) {
66
+ const abs = resolveToolPath(raw, baseCwd, containmentOptions(context));
30
67
  if (isUnderAttachmentRoot(abs, context?.attachmentRoots)) {
31
68
  throw new Error(`session attachments are read-only; cannot ${label} under attachments root`);
32
69
  }
@@ -139,9 +176,14 @@ export function createPackageEditTool() {
139
176
  capabilities: ['fs-write', 'fs-read'],
140
177
  description: 'Structurally edit package.json (scripts, dependencies, metadata) via dotted paths. Undoable. Prefer this over rewriting the whole file.',
141
178
  parameters: {
179
+ cwd: {
180
+ type: 'string',
181
+ description: 'Project directory containing the package.json to edit (required; relative paths resolve against it, never against the workspace cwd)',
182
+ required: true,
183
+ },
142
184
  path: {
143
185
  type: 'string',
144
- description: 'Path to package.json (default: <cwd>/package.json)',
186
+ description: 'Path to package.json, relative to `cwd` (default: package.json in `cwd`)',
145
187
  },
146
188
  set: {
147
189
  type: 'object',
@@ -157,9 +199,9 @@ export function createPackageEditTool() {
157
199
  // 整文件读改写无合并语义:所在 tool_call 批次整体串行,防同路径并发读改写互相覆盖
158
200
  executionMode: 'sequential',
159
201
  handler: async (args, context) => {
160
- const cwd = resolveCwd(context);
202
+ const cwd = requireCwd(context, args.cwd, 'package_edit');
161
203
  const rawPath = args.path ?? 'package.json';
162
- const pkgPath = assertPathSafe(rawPath, context, 'edit');
204
+ const pkgPath = assertPathSafe(rawPath, context, 'edit', cwd);
163
205
  const { pkg, raw: originalText } = await readPackageJson(pkgPath);
164
206
  const set = args.set ?? {};
165
207
  const remove = Array.isArray(args.remove) ? args.remove : [];
@@ -187,24 +229,88 @@ export function createPackageEditTool() {
187
229
  }
188
230
  const after = stringifyPreservingEol(pkg, originalText);
189
231
  await effects.writeFile(pkgPath, after);
190
- return { path: pkgPath, changed, packageManager: await detectPm(cwd) };
232
+ // 包管理器由**被编辑文件所在目录**判定(cwd 只是相对 path 的基准);
233
+ // 否则 path 指向别处时会报错仓库的 lockfile。
234
+ return { path: pkgPath, changed, packageManager: await detectPm(dirname(pkgPath)) };
191
235
  },
192
236
  };
193
237
  }
238
+ /**
239
+ * 结果老化:回到「这次脚本跑成没跑成、结论是什么」
240
+ *
241
+ * 依据(default-web-1794346953041 实测,43 次 278,106 字符):
242
+ * - `stdout` 64%:ANSI 转义码 13,980 字符是纯噪声;结论(测试汇总/构建结果)在**末尾**;
243
+ * - `stderr` 29%:34 条 exit=0 的 stderr 共 37,002 字符,内容全是 `[AgentBuilder]`、
244
+ * `[overflow]`、`[Knowledge]` 这类**用例自身日志**,92% 不是错误行 → 成功时无诊断价值;
245
+ * - `isolation` 5%:43/43 完全相同(与 shell ager 已删的同一字段);
246
+ * - `scriptBody`/`cwd` 是入参或 package.json 可重读。
247
+ *
248
+ * 保留:退出码、脚本名、是否截断/终止、(失败时的)stderr 尾部、(成功与失败都保留的)
249
+ * stdout 尾部——尾部才是结论所在。
250
+ *
251
+ * @param result - project_run 的原始结果
252
+ * @returns 老化指针;结构不符时返回 undefined
253
+ */
254
+ function ageProjectRunResult(result) {
255
+ if (!result || typeof result !== 'object')
256
+ return undefined;
257
+ const r = result;
258
+ const exitCode = typeof r.exitCode === 'number' ? r.exitCode : undefined;
259
+ if (exitCode === undefined)
260
+ return undefined;
261
+ // 剥 ANSI(0x1b[...m),它是纯渲染控制码,历史回看无意义
262
+ const stripAnsi = (s) => s.replace(/\u001b\[[0-9;]*m/g, '');
263
+ const stdout = stripAnsi(typeof r.stdout === 'string' ? r.stdout : '');
264
+ const stderr = stripAnsi(typeof r.stderr === 'string' ? r.stderr : '');
265
+ const outLen = typeof r.rawStdoutLength === 'number' ? r.rawStdoutLength : stdout.length;
266
+ const flags = [`exit ${exitCode}`];
267
+ if (r.truncated === true)
268
+ flags.push(`stdout capped, ${outLen} chars total`);
269
+ if (r.terminated === true) {
270
+ const why = typeof r.terminateReason === 'string' ? r.terminateReason : 'unknown';
271
+ flags.push(`terminated (${why})`);
272
+ }
273
+ const head = `[aged] project_run ${flags.join(', ')}`;
274
+ const TAIL = 900;
275
+ const tailLines = (s) => {
276
+ const trimmed = s.replace(/^\n+|\n+$/g, '');
277
+ if (!trimmed)
278
+ return '';
279
+ const lines = trimmed.split('\n');
280
+ if (trimmed.length <= TAIL)
281
+ return trimmed;
282
+ return lines.slice(-12).join('\n').slice(-TAIL);
283
+ };
284
+ const parts = [head];
285
+ // 失败时 stderr 是诊断主体;成功时(日志噪音)不保留
286
+ if (exitCode !== 0) {
287
+ const se = tailLines(stderr);
288
+ if (se)
289
+ parts.push(`stderr tail: ${se}`);
290
+ }
291
+ const out = tailLines(stdout);
292
+ if (out)
293
+ parts.push(`stdout tail: ${out}`);
294
+ return parts.join('\n');
295
+ }
194
296
  /** project_run — run a named package.json script (runner; stripped on reduced) */
195
297
  export function createProjectRunTool() {
196
298
  return {
197
299
  definition: {
198
300
  name: 'project_run',
199
301
  capabilities: ['runner'],
200
- description: 'Run a named script from package.json#scripts (e.g. test, lint, build). Pass the script name only — never an arbitrary command string. Executes workspace code; blocked when the tool surface is reduced.',
302
+ description: 'Run a named script from package.json#scripts (e.g. test, lint, build). Pass the script name only — never an arbitrary command string. `cwd` is required: it is the project directory holding package.json and is never inferred from the session workspace. Executes workspace code; blocked when the tool surface is reduced.',
201
303
  parameters: {
202
304
  script: {
203
305
  type: 'string',
204
306
  description: 'Script name defined in package.json#scripts',
205
307
  required: true,
206
308
  },
207
- cwd: { type: 'string', description: 'Project directory (default: workspace cwd)' },
309
+ cwd: {
310
+ type: 'string',
311
+ description: 'Project directory containing package.json (required; relative paths resolve against it, never against the workspace cwd)',
312
+ required: true,
313
+ },
208
314
  args: {
209
315
  type: 'array',
210
316
  description: 'Extra args passed after the script (npm run <script> -- <args>)',
@@ -223,8 +329,10 @@ export function createProjectRunTool() {
223
329
  },
224
330
  },
225
331
  },
332
+ // 历史视图收敛为「成败 + 尾部结论」(stdout 结论在末尾;成功时 stderr 是日志噪音)
333
+ ageResult: ({ result }) => ageProjectRunResult(result),
226
334
  handler: async (args, context) => {
227
- const cwd = resolveCwd(context, args.cwd);
335
+ const cwd = requireCwd(context, args.cwd, 'project_run');
228
336
  const script = String(args.script ?? '').trim();
229
337
  if (!script || !/^[A-Za-z0-9][A-Za-z0-9:._-]*$/.test(script)) {
230
338
  throw new Error(`project_run: invalid script name "${script}"`);
@@ -287,7 +395,11 @@ export function createPackageInstallTool() {
287
395
  items: { type: 'string', description: 'Package spec' },
288
396
  },
289
397
  dev: { type: 'boolean', description: 'add as devDependency' },
290
- cwd: { type: 'string', description: 'Project directory' },
398
+ cwd: {
399
+ type: 'string',
400
+ description: 'Project directory to install into (required; its lockfile selects the package manager, never inferred from the workspace cwd)',
401
+ required: true,
402
+ },
291
403
  packageManager: {
292
404
  type: 'string',
293
405
  description: 'Force package manager (default: detect from lockfile)',
@@ -306,7 +418,7 @@ export function createPackageInstallTool() {
306
418
  if (!['install', 'add', 'remove', 'ci'].includes(action)) {
307
419
  throw new Error(`package_install: unsupported action "${action}"`);
308
420
  }
309
- const cwd = resolveCwd(context, args.cwd);
421
+ const cwd = requireCwd(context, args.cwd, 'package_install');
310
422
  const packages = Array.isArray(args.packages) ? args.packages.map(String) : [];
311
423
  if ((action === 'add' || action === 'remove') && packages.length === 0) {
312
424
  throw new Error(`package_install: action=${action} requires packages`);
@@ -49,7 +49,7 @@ export interface ResolveToolPathOptions {
49
49
  denyPatterns?: readonly string[];
50
50
  }
51
51
  /**
52
- * 解析工具入参路径:绝对路径原样返回,相对路径相对 cwd
52
+ * 解析工具入参路径:`~` 展开到用户目录,绝对路径原样返回,相对路径相对 cwd
53
53
  *
54
54
  * 使用 path.isAbsolute,同时覆盖 POSIX /foo、Windows 盘符与 UNC。
55
55
  *
@@ -7,6 +7,7 @@
7
7
  import { accessSync, constants, existsSync, statSync } from 'node:fs';
8
8
  import { delimiter, dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
9
9
  import { isPathUnderRoots, lexicalUnderRoots, realpathAllowMissing, } from '../../../shared/paths/index.js';
10
+ import { expandHomePath } from '../../../../paths.js';
10
11
  import { matchesDenyPattern } from '../../../shared/paths/glob.js';
11
12
  export { isPathUnderRoots };
12
13
  /**
@@ -133,7 +134,42 @@ function denyPath(absPath, rawPath, options, denyPatterns) {
133
134
  }
134
135
  }
135
136
  /**
136
- * 解析工具入参路径:绝对路径原样返回,相对路径相对 cwd
137
+ * Expand a tool-input `~` prefix to the user home directory.
138
+ *
139
+ * `~`, `~/rest`, `~\rest` expand via the shared {@link expandHomePath}. The
140
+ * `~user/rest` form has no portable expansion; leaving it unexpanded would
141
+ * silently resolve it against the tool cwd — the exact mis-target this surface
142
+ * forbids — so it fails loud instead (use an absolute path, or `./~user/…` for
143
+ * a literal name).
144
+ *
145
+ * @param rawPath - caller-supplied path
146
+ * @returns expanded path (unchanged when there is no `~` prefix)
147
+ */
148
+ function expandToolTilde(rawPath) {
149
+ // Surrounding whitespace around a `~` spelling is an ambiguity, not a name:
150
+ // `" ~/x"` would silently resolve against the cwd — the exact mis-target this
151
+ // surface forbids. Fail loud instead of picking a side (tool input is not a
152
+ // shell line; strip the whitespace yourself or use "./…" for a literal name).
153
+ const trimmed = rawPath.trim();
154
+ if (trimmed !== rawPath && trimmed.startsWith('~')) {
155
+ throw new Error(`path_invalid: "${rawPath}" has surrounding whitespace and would not expand to the user home; strip the whitespace, or pass "./${trimmed}" for a literal name`);
156
+ }
157
+ let expanded;
158
+ try {
159
+ expanded = expandHomePath(rawPath);
160
+ }
161
+ catch (error) {
162
+ // homedir() fails when HOME/USERPROFILE are unset and the passwd lookup
163
+ // fails; surface it as an actionable path_invalid, not a raw os error.
164
+ throw new Error(`path_invalid: cannot expand "${rawPath}": user home directory unavailable (${error instanceof Error ? error.message : String(error)})`);
165
+ }
166
+ if (expanded === rawPath && rawPath.startsWith('~')) {
167
+ throw new Error(`path_invalid: cannot expand "${rawPath}": ~user home lookup has no portable meaning; pass an absolute path, or "./${rawPath}" for a literal name`);
168
+ }
169
+ return expanded;
170
+ }
171
+ /**
172
+ * 解析工具入参路径:`~` 展开到用户目录,绝对路径原样返回,相对路径相对 cwd
137
173
  *
138
174
  * 使用 path.isAbsolute,同时覆盖 POSIX /foo、Windows 盘符与 UNC。
139
175
  *
@@ -143,7 +179,8 @@ function denyPath(absPath, rawPath, options, denyPatterns) {
143
179
  * @returns 规范化后的绝对路径;containment 生效时为符号链接解析后的真实路径
144
180
  */
145
181
  export function resolveToolPath(rawPath, cwd, options) {
146
- const abs = isAbsolute(rawPath) ? resolve(rawPath) : resolve(cwd ?? process.cwd(), rawPath);
182
+ const expanded = expandToolTilde(rawPath);
183
+ const abs = isAbsolute(expanded) ? resolve(expanded) : resolve(cwd ?? process.cwd(), expanded);
147
184
  return containPath(abs, rawPath, options);
148
185
  }
149
186
  /**
@@ -156,9 +193,11 @@ export function resolveToolPath(rawPath, cwd, options) {
156
193
  */
157
194
  export function resolveReadableToolPath(rawPath, cwd, attachmentRoots, options) {
158
195
  const roots = attachmentRoots ?? [];
159
- // 绝对路径原样;相对路径先试 attachments 根(文件名直呼)
160
- if (!isAbsolute(rawPath) && roots.length > 0) {
161
- const cleaned = rawPath.replace(/^[/\\]+/, '');
196
+ // `~` 先展开到用户目录(home 形态不是附件文件名);绝对路径原样,
197
+ // 相对路径先试 attachments 根(文件名直呼)
198
+ const expanded = expandToolTilde(rawPath);
199
+ if (!isAbsolute(expanded) && roots.length > 0) {
200
+ const cleaned = expanded.replace(/^[/\\]+/, '');
162
201
  for (const root of roots) {
163
202
  const rootResolved = resolve(root);
164
203
  const candidate = resolve(rootResolved, cleaned);
@@ -16,7 +16,8 @@
16
16
  *
17
17
  * @module harness/extension/plugin-ecosystem/tools/tool-bus
18
18
  */
19
- import { registerToolCapabilities } from '../../execution-environment/tool-capabilities.js';
19
+ import { registerToolCapabilities, resolveToolCapabilities, } from '../../execution-environment/tool-capabilities.js';
20
+ import { isToolPermitted } from '../../../governance/session-acl/tool-rights.js';
20
21
  import { buildToolLlmParameters } from '../../../agent/tool-purpose.js';
21
22
  import { isPluginToolPermitted } from './plugin-tool.js';
22
23
  /**
@@ -94,28 +95,10 @@ export class DefaultToolBus {
94
95
  }
95
96
  // ── 解析 ──
96
97
  resolve(agentId, policy) {
97
- let tools = this.listForAgent(agentId).filter((tool) => isPluginToolPermitted(tool, policy));
98
- if (policy) {
99
- if (policy.allow && policy.allow.length > 0) {
100
- const allowSet = new Set(policy.allow);
101
- // "*" 表示放行全部(配置常见写法),不得只匹配字面量 "*"
102
- const allowAll = allowSet.has('*');
103
- if (!allowAll) {
104
- tools = tools.filter(t => allowSet.has(t.definition.name));
105
- }
106
- }
107
- if (policy.deny && policy.deny.length > 0) {
108
- const denySet = new Set(policy.deny);
109
- // deny '*' = deny every tool (mirror allow '*')
110
- if (denySet.has('*')) {
111
- tools = [];
112
- }
113
- else {
114
- tools = tools.filter(t => !denySet.has(t.definition.name));
115
- }
116
- }
117
- }
118
- return tools;
98
+ // 双闸:isPluginToolPermitted 保留源别默认(agent 级插件工具无策略=不暴露,全局内置默认暴露);
99
+ // isToolPermitted 补能力漏斗(denyCapabilities + 未知标签 fail-closed,与 runner 列表闸同语义)
100
+ return this.listForAgent(agentId).filter((tool) => isPluginToolPermitted(tool, policy) &&
101
+ isToolPermitted(tool.definition.name, resolveToolCapabilities(tool.definition.name), [policy]));
119
102
  }
120
103
  toLLMDefinitions(agentId, policy) {
121
104
  return this.resolve(agentId, policy).map(definition => ({
@@ -165,7 +148,10 @@ export class DefaultToolBus {
165
148
  }
166
149
  const { getRunScope } = await import('../../../run/run-scope.js');
167
150
  const effectivePolicy = getRunScope()?.toolRuntime?.agentToolPolicy ?? policy;
168
- if (!isPluginToolPermitted(tool, effectivePolicy)) {
151
+ if (!isPluginToolPermitted(tool, effectivePolicy) ||
152
+ !isToolPermitted(tool.definition.name, resolveToolCapabilities(tool.definition.name), [
153
+ effectivePolicy,
154
+ ])) {
169
155
  throw new Error(`Plugin tool "${name}" is not allowed for agent "${context.agentId}"`);
170
156
  }
171
157
  this.validateArgs(name, args, tool.definition);
@@ -4,6 +4,8 @@ import type { SessionTaskService } from '../../../session/tasks/service.js';
4
4
  import type { SessionHistoryPort } from '../../../session/history/index.js';
5
5
  import type { WebSearchProvider } from './web-search-types.js';
6
6
  import type { AskUserCallback } from './ask-user.js';
7
+ import type { BrowserService } from './browser-types.js';
8
+ import type { BrowserToolOptions } from './browser.js';
7
9
  export interface ToolSetConfig {
8
10
  memoryStore?: MemoryStore;
9
11
  /** memory 工具的 confidence/gates 覆盖(与 octopi.json memory 段对齐) */
@@ -21,6 +23,11 @@ export interface ToolSetConfig {
21
23
  defaultLimit?: number;
22
24
  timeoutMs?: number;
23
25
  };
26
+ /** 浏览器会话服务;未提供时不注册 browser_* */
27
+ browser?: {
28
+ service: BrowserService;
29
+ options?: BrowserToolOptions;
30
+ };
24
31
  /** Summary 公用能力(http_request / file_read L1/L2) */
25
32
  summary?: import('../../../context/capabilities/summary/index.js').ToolSummarySupport;
26
33
  /** CredentialStore — http_request.credential(绑定强制见 store.resolve) */
@@ -3,6 +3,7 @@ import { createMemoryTools } from './memory.js';
3
3
  import { createSessionTaskTools } from '../../../session/tasks/tools.js';
4
4
  import { createAskUserTool } from './ask-user.js';
5
5
  import { createWebSearchTool } from './web-search.js';
6
+ import { createBrowserTools } from './browser.js';
6
7
  import { createSessionHistoryTools } from './session-history.js';
7
8
  import { createDelegationTools } from './delegation.js';
8
9
  export function createToolSet(config) {
@@ -26,6 +27,9 @@ export function createToolSet(config) {
26
27
  }),
27
28
  ]
28
29
  : []),
30
+ ...(config?.browser
31
+ ? createBrowserTools(config.browser.service, config.browser.options)
32
+ : []),
29
33
  ...(config?.sessionHistory
30
34
  ? createSessionHistoryTools({
31
35
  history: config.sessionHistory,
@@ -8,6 +8,15 @@ export interface CredentialDatabaseOptions {
8
8
  dbPath?: string;
9
9
  wal?: boolean;
10
10
  busyTimeoutMs?: number;
11
+ /**
12
+ * 把 `dbPath` 所在目录收紧到当前用户(POSIX 0700 / Windows ACL)。
13
+ *
14
+ * 默认 `false`:`dbPath` 是公开选项,调用方可能指向共享目录(`/var/lib/foo/app.db`),
15
+ * 不打招呼就 `chmod 700` 会把别人的服务状态一起锁掉。产品路径经
16
+ * {@link resolveCredentialPaths} 产出的专用目录,由 `CredentialStore.openDefault`
17
+ * 显式打开该开关;嵌入方指定自己的路径时自行负责目录权限。
18
+ */
19
+ hardenDir?: boolean;
11
20
  }
12
21
  export interface CredentialPaths {
13
22
  root: string;