@octopi-agent/engine 0.70.7 → 0.86.38

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 (362) hide show
  1. package/LICENSE +201 -201
  2. package/NOTICE +7 -7
  3. package/README.md +64 -26
  4. package/dist/config-schema/agent.d.ts +89 -1
  5. package/dist/config-schema/agent.js +69 -0
  6. package/dist/config-schema/context.d.ts +23 -4
  7. package/dist/config-schema/context.js +28 -1
  8. package/dist/config-schema/engine.d.ts +201 -9
  9. package/dist/config-schema/engine.js +31 -2
  10. package/dist/config-schema/governance.d.ts +95 -0
  11. package/dist/config-schema/governance.js +91 -0
  12. package/dist/config-schema/models.d.ts +1 -1
  13. package/dist/config-schema/observability.d.ts +6 -0
  14. package/dist/config-schema/observability.js +16 -0
  15. package/dist/config-schema/run.d.ts +10 -0
  16. package/dist/config-schema/run.js +18 -0
  17. package/dist/config-schema/shared.d.ts +10 -0
  18. package/dist/config-schema/shared.js +10 -0
  19. package/dist/config-schema/substrate.d.ts +1 -1
  20. package/dist/config-schema/subsystems.d.ts +1 -1
  21. package/dist/config-schema/subsystems.js +2 -1
  22. package/dist/config.d.ts +178 -7
  23. package/dist/config.js +113 -3
  24. package/dist/harness/activation/compiler.js +3 -0
  25. package/dist/harness/activation/runtime.d.ts +7 -0
  26. package/dist/harness/activation/runtime.js +60 -2
  27. package/dist/harness/activation/sources/agent-signal.d.ts +11 -0
  28. package/dist/harness/activation/sources/agent-signal.js +33 -0
  29. package/dist/harness/activation/types.d.ts +6 -1
  30. package/dist/harness/agent/builder.d.ts +47 -3
  31. package/dist/harness/agent/builder.js +180 -54
  32. package/dist/harness/agent/config-bridge.d.ts +33 -25
  33. package/dist/harness/agent/config-bridge.js +81 -291
  34. package/dist/harness/agent/index.d.ts +3 -1
  35. package/dist/harness/agent/index.js +2 -1
  36. package/dist/harness/agent/tool-purpose.d.ts +38 -0
  37. package/dist/harness/agent/tool-purpose.js +118 -0
  38. package/dist/harness/agent/wire-agent-builder.d.ts +133 -0
  39. package/dist/harness/agent/wire-agent-builder.js +363 -0
  40. package/dist/harness/collaboration/autonomous-subsystem/runtime.d.ts +4 -1
  41. package/dist/harness/collaboration/autonomous-subsystem/runtime.js +14 -8
  42. package/dist/harness/collaboration/autonomous-subsystem/sense/metrics.d.ts +12 -0
  43. package/dist/harness/collaboration/autonomous-subsystem/sense/metrics.js +19 -0
  44. package/dist/harness/collaboration/autonomous-subsystem/sense/session-lifecycle-bridge.d.ts +6 -0
  45. package/dist/harness/collaboration/autonomous-subsystem/sense/session-lifecycle-bridge.js +24 -7
  46. package/dist/harness/collaboration/autonomous-subsystem/think/executor.d.ts +5 -2
  47. package/dist/harness/collaboration/autonomous-subsystem/think/executor.js +11 -3
  48. package/dist/harness/collaboration/autonomous-subsystem/think/index.d.ts +1 -1
  49. package/dist/harness/collaboration/autonomous-subsystem/think/index.js +1 -1
  50. package/dist/harness/collaboration/autonomous-subsystem/think/llm-port.d.ts +7 -4
  51. package/dist/harness/collaboration/autonomous-subsystem/think/llm-port.js +8 -9
  52. package/dist/harness/collaboration/autonomous-subsystem/think/model-resolver.d.ts +36 -10
  53. package/dist/harness/collaboration/autonomous-subsystem/think/model-resolver.js +60 -7
  54. package/dist/harness/collaboration/delegation/child-run.d.ts +144 -0
  55. package/dist/harness/collaboration/delegation/child-run.js +241 -0
  56. package/dist/harness/collaboration/delegation/index.d.ts +26 -0
  57. package/dist/harness/collaboration/delegation/index.js +25 -0
  58. package/dist/harness/collaboration/delegation/notifier.d.ts +46 -0
  59. package/dist/harness/collaboration/delegation/notifier.js +84 -0
  60. package/dist/harness/collaboration/delegation/registry-types.d.ts +200 -0
  61. package/dist/harness/collaboration/delegation/registry-types.js +61 -0
  62. package/dist/harness/collaboration/delegation/registry.d.ts +110 -0
  63. package/dist/harness/collaboration/delegation/registry.js +220 -0
  64. package/dist/harness/collaboration/delegation/service.d.ts +249 -0
  65. package/dist/harness/collaboration/delegation/service.js +499 -0
  66. package/dist/harness/collaboration/delegation/store.d.ts +155 -0
  67. package/dist/harness/collaboration/delegation/store.js +271 -0
  68. package/dist/harness/collaboration/delegation/transport.d.ts +73 -0
  69. package/dist/harness/collaboration/delegation/transport.js +61 -0
  70. package/dist/harness/collaboration/delegation/types.d.ts +231 -0
  71. package/dist/harness/collaboration/delegation/types.js +70 -0
  72. package/dist/harness/collaboration/delegation/wiring.d.ts +111 -0
  73. package/dist/harness/collaboration/delegation/wiring.js +145 -0
  74. package/dist/harness/collaboration/orchestration/index.d.ts +11 -13
  75. package/dist/harness/collaboration/orchestration/index.js +11 -11
  76. package/dist/harness/context/assembler.d.ts +2 -2
  77. package/dist/harness/context/assembler.js +12 -7
  78. package/dist/harness/context/capabilities/compact/engine.js +80 -38
  79. package/dist/harness/context/capabilities/compact/types.d.ts +12 -1
  80. package/dist/harness/context/capabilities/summary/registry.js +10 -0
  81. package/dist/harness/context/constitution/default-agents.md +230 -228
  82. package/dist/harness/context/default-context-engine.d.ts +101 -23
  83. package/dist/harness/context/default-context-engine.js +483 -172
  84. package/dist/harness/context/hybrid-compressor.d.ts +3 -3
  85. package/dist/harness/context/hybrid-compressor.js +18 -23
  86. package/dist/harness/context/index.d.ts +5 -1
  87. package/dist/harness/context/index.js +2 -0
  88. package/dist/harness/context/layer-snapshot.d.ts +4 -0
  89. package/dist/harness/context/layer-snapshot.js +30 -18
  90. package/dist/harness/context/layer-types.d.ts +49 -1
  91. package/dist/harness/context/layer-types.js +72 -4
  92. package/dist/harness/context/layers.d.ts +5 -2
  93. package/dist/harness/context/layers.js +11 -5
  94. package/dist/harness/context/llm-summarizer.d.ts +15 -1
  95. package/dist/harness/context/llm-summarizer.js +107 -56
  96. package/dist/harness/context/message-selector.js +6 -2
  97. package/dist/harness/context/root-instructions.d.ts +72 -0
  98. package/dist/harness/context/root-instructions.js +227 -0
  99. package/dist/harness/context/runtime-datetime.d.ts +34 -7
  100. package/dist/harness/context/runtime-datetime.js +66 -10
  101. package/dist/harness/context/smart-router.d.ts +1 -1
  102. package/dist/harness/context/smart-router.js +1 -1
  103. package/dist/harness/context/system-prompt-assembler.d.ts +30 -0
  104. package/dist/harness/context/system-prompt-assembler.js +67 -6
  105. package/dist/harness/context/token-constants.d.ts +2 -2
  106. package/dist/harness/context/token-constants.js +2 -2
  107. package/dist/harness/context/token-estimate-fns.d.ts +1 -3
  108. package/dist/harness/context/token-estimate-fns.js +2 -4
  109. package/dist/harness/context/token-estimator.d.ts +1 -1
  110. package/dist/harness/context/token-estimator.js +14 -6
  111. package/dist/harness/context/tool-result-aging.d.ts +140 -0
  112. package/dist/harness/context/tool-result-aging.js +331 -0
  113. package/dist/harness/context/tool-result-body.d.ts +10 -0
  114. package/dist/harness/context/tool-result-body.js +27 -0
  115. package/dist/harness/context/turn-envelope.d.ts +123 -0
  116. package/dist/harness/context/turn-envelope.js +188 -0
  117. package/dist/harness/context/types.d.ts +35 -47
  118. package/dist/harness/extension/execution-environment/effect-policy.d.ts +248 -0
  119. package/dist/harness/extension/execution-environment/effect-policy.js +334 -0
  120. package/dist/harness/extension/execution-environment/index.d.ts +18 -2
  121. package/dist/harness/extension/execution-environment/index.js +11 -2
  122. package/dist/harness/extension/execution-environment/memory-undo.d.ts +101 -0
  123. package/dist/harness/extension/execution-environment/memory-undo.js +192 -0
  124. package/dist/harness/extension/execution-environment/process-isolation.d.ts +84 -0
  125. package/dist/harness/extension/execution-environment/process-isolation.js +315 -0
  126. package/dist/harness/extension/execution-environment/resource-limits.d.ts +36 -0
  127. package/dist/harness/extension/execution-environment/resource-limits.js +84 -0
  128. package/dist/harness/extension/execution-environment/sandbox.d.ts +125 -4
  129. package/dist/harness/extension/execution-environment/sandbox.js +493 -51
  130. package/dist/harness/extension/execution-environment/shell-journal.d.ts +100 -0
  131. package/dist/harness/extension/execution-environment/shell-journal.js +299 -0
  132. package/dist/harness/extension/execution-environment/tool-capabilities.d.ts +45 -0
  133. package/dist/harness/extension/execution-environment/tool-capabilities.js +126 -0
  134. package/dist/harness/extension/execution-environment/types.d.ts +67 -39
  135. package/dist/harness/extension/execution-environment/types.js +2 -2
  136. package/dist/harness/extension/execution-environment/undo-log.d.ts +203 -0
  137. package/dist/harness/extension/execution-environment/undo-log.js +627 -0
  138. package/dist/harness/extension/execution-environment/undo-merge.d.ts +40 -0
  139. package/dist/harness/extension/execution-environment/undo-merge.js +167 -0
  140. package/dist/harness/extension/plugin-ecosystem/client-tools/index.d.ts +1 -1
  141. package/dist/harness/extension/plugin-ecosystem/client-tools/types.d.ts +9 -0
  142. package/dist/harness/extension/plugin-ecosystem/mcp/bridge.js +2 -0
  143. package/dist/harness/extension/plugin-ecosystem/plugins/api.d.ts +1 -6
  144. package/dist/harness/extension/plugin-ecosystem/plugins/api.js +3 -8
  145. package/dist/harness/extension/plugin-ecosystem/plugins/capability.d.ts +0 -3
  146. package/dist/harness/extension/plugin-ecosystem/plugins/capability.js +0 -3
  147. package/dist/harness/extension/plugin-ecosystem/plugins/entry.d.ts +2 -10
  148. package/dist/harness/extension/plugin-ecosystem/plugins/entry.js +2 -9
  149. package/dist/harness/extension/plugin-ecosystem/plugins/index.d.ts +1 -3
  150. package/dist/harness/extension/plugin-ecosystem/plugins/index.js +1 -3
  151. package/dist/harness/extension/plugin-ecosystem/plugins/loader.d.ts +2 -4
  152. package/dist/harness/extension/plugin-ecosystem/plugins/loader.js +4 -21
  153. package/dist/harness/extension/plugin-ecosystem/plugins/manager.d.ts +3 -9
  154. package/dist/harness/extension/plugin-ecosystem/plugins/manager.js +4 -8
  155. package/dist/harness/extension/plugin-ecosystem/plugins/manifest.d.ts +1 -4
  156. package/dist/harness/extension/plugin-ecosystem/plugins/manifest.js +1 -3
  157. package/dist/harness/extension/plugin-ecosystem/skills/manager.d.ts +1 -1
  158. package/dist/harness/extension/plugin-ecosystem/skills/manager.js +1 -1
  159. package/dist/harness/extension/plugin-ecosystem/tools/allowlisted-run.d.ts +45 -0
  160. package/dist/harness/extension/plugin-ecosystem/tools/allowlisted-run.js +136 -0
  161. package/dist/harness/extension/plugin-ecosystem/tools/ask-user.js +1 -0
  162. package/dist/harness/extension/plugin-ecosystem/tools/builtin.d.ts +18 -3
  163. package/dist/harness/extension/plugin-ecosystem/tools/builtin.js +277 -81
  164. package/dist/harness/extension/plugin-ecosystem/tools/delegation.d.ts +31 -0
  165. package/dist/harness/extension/plugin-ecosystem/tools/delegation.js +291 -0
  166. package/dist/harness/extension/plugin-ecosystem/tools/document-tools.js +10 -2
  167. package/dist/harness/extension/plugin-ecosystem/tools/env-info.js +1 -0
  168. package/dist/harness/extension/plugin-ecosystem/tools/eol.d.ts +35 -0
  169. package/dist/harness/extension/plugin-ecosystem/tools/eol.js +43 -0
  170. package/dist/harness/extension/plugin-ecosystem/tools/file-edit.js +40 -9
  171. package/dist/harness/extension/plugin-ecosystem/tools/file-ops.d.ts +33 -0
  172. package/dist/harness/extension/plugin-ecosystem/tools/file-ops.js +376 -0
  173. package/dist/harness/extension/plugin-ecosystem/tools/file-search.d.ts +12 -2
  174. package/dist/harness/extension/plugin-ecosystem/tools/file-search.js +239 -61
  175. package/dist/harness/extension/plugin-ecosystem/tools/git-tools.d.ts +27 -0
  176. package/dist/harness/extension/plugin-ecosystem/tools/git-tools.js +554 -0
  177. package/dist/harness/extension/plugin-ecosystem/tools/http.d.ts +10 -6
  178. package/dist/harness/extension/plugin-ecosystem/tools/http.js +41 -47
  179. package/dist/harness/extension/plugin-ecosystem/tools/index.d.ts +2 -0
  180. package/dist/harness/extension/plugin-ecosystem/tools/index.js +2 -0
  181. package/dist/harness/extension/plugin-ecosystem/tools/knowledge.js +4 -0
  182. package/dist/harness/extension/plugin-ecosystem/tools/memory.js +25 -1
  183. package/dist/harness/extension/plugin-ecosystem/tools/package-tools.d.ts +13 -0
  184. package/dist/harness/extension/plugin-ecosystem/tools/package-tools.js +391 -0
  185. package/dist/harness/extension/plugin-ecosystem/tools/platform.d.ts +51 -2
  186. package/dist/harness/extension/plugin-ecosystem/tools/platform.js +151 -12
  187. package/dist/harness/extension/plugin-ecosystem/tools/session-history.js +2 -0
  188. package/dist/harness/extension/plugin-ecosystem/tools/tool-bus.d.ts +10 -1
  189. package/dist/harness/extension/plugin-ecosystem/tools/tool-bus.js +35 -19
  190. package/dist/harness/extension/plugin-ecosystem/tools/tool-set.d.ts +8 -0
  191. package/dist/harness/extension/plugin-ecosystem/tools/tool-set.js +5 -0
  192. package/dist/harness/extension/plugin-ecosystem/tools/web-search.js +1 -0
  193. package/dist/harness/governance/credentials/index.d.ts +1 -1
  194. package/dist/harness/governance/credentials/store.d.ts +16 -4
  195. package/dist/harness/governance/credentials/store.js +33 -6
  196. package/dist/harness/governance/credentials/types.d.ts +11 -0
  197. package/dist/harness/governance/human-in-the-loop/decision-cache.d.ts +105 -0
  198. package/dist/harness/governance/human-in-the-loop/decision-cache.js +184 -0
  199. package/dist/harness/governance/human-in-the-loop/index.d.ts +5 -5
  200. package/dist/harness/governance/human-in-the-loop/index.js +3 -3
  201. package/dist/harness/governance/human-in-the-loop/types.d.ts +7 -62
  202. package/dist/harness/governance/human-in-the-loop/types.js +6 -2
  203. package/dist/harness/governance/security/capability-enforcer.d.ts +9 -1
  204. package/dist/harness/governance/security/capability-enforcer.js +31 -8
  205. package/dist/harness/governance/security/degradation.js +5 -7
  206. package/dist/harness/governance/security/risk-evaluator.d.ts +1 -1
  207. package/dist/harness/governance/security/risk-evaluator.js +4 -82
  208. package/dist/harness/governance/security/temp-path.d.ts +41 -0
  209. package/dist/harness/governance/security/temp-path.js +117 -0
  210. package/dist/harness/governance/session-acl/index.d.ts +1 -0
  211. package/dist/harness/governance/session-acl/index.js +1 -0
  212. package/dist/harness/governance/session-acl/rights.d.ts +12 -0
  213. package/dist/harness/governance/session-acl/rights.js +89 -7
  214. package/dist/harness/governance/session-acl/seed-roles.js +9 -1
  215. package/dist/harness/governance/session-acl/service.js +21 -29
  216. package/dist/harness/governance/session-acl/tool-rights.d.ts +81 -0
  217. package/dist/harness/governance/session-acl/tool-rights.js +238 -0
  218. package/dist/harness/governance/session-acl/types.d.ts +22 -0
  219. package/dist/harness/index.d.ts +14 -12
  220. package/dist/harness/index.js +9 -6
  221. package/dist/harness/knowledge/file-index-store.js +11 -11
  222. package/dist/harness/knowledge/grounding.d.ts +2 -1
  223. package/dist/harness/knowledge/grounding.js +6 -3
  224. package/dist/harness/knowledge/index.d.ts +2 -2
  225. package/dist/harness/knowledge/index.js +1 -1
  226. package/dist/harness/knowledge/ingest.js +4 -1
  227. package/dist/harness/knowledge/job-control-state.js +4 -4
  228. package/dist/harness/knowledge/job-control.js +11 -11
  229. package/dist/harness/knowledge/membership-store.js +11 -11
  230. package/dist/harness/knowledge/network-guard.d.ts +61 -4
  231. package/dist/harness/knowledge/network-guard.js +390 -113
  232. package/dist/harness/knowledge/query-service.js +3 -3
  233. package/dist/harness/knowledge/writer-service.d.ts +2 -0
  234. package/dist/harness/knowledge/writer-service.js +14 -13
  235. package/dist/harness/memory/backfill-trigger.d.ts +2 -2
  236. package/dist/harness/memory/backfill-trigger.js +4 -4
  237. package/dist/harness/memory/index.d.ts +1 -0
  238. package/dist/harness/memory/index.js +1 -0
  239. package/dist/harness/memory/sqlite/agent-db.js +2 -0
  240. package/dist/harness/memory/sqlite/memory-store.d.ts +1 -0
  241. package/dist/harness/memory/sqlite/memory-store.js +14 -4
  242. package/dist/harness/memory/sqlite/wisdom-store.js +9 -9
  243. package/dist/harness/memory/store.d.ts +1 -0
  244. package/dist/harness/memory/store.js +3 -0
  245. package/dist/harness/memory/time-format.d.ts +28 -0
  246. package/dist/harness/memory/time-format.js +52 -0
  247. package/dist/harness/memory/types.d.ts +12 -0
  248. package/dist/harness/observability/observer/hub.js +23 -1
  249. package/dist/harness/observability/observer/index.d.ts +2 -2
  250. package/dist/harness/observability/observer/index.js +1 -1
  251. package/dist/harness/observability/observer/types.d.ts +57 -0
  252. package/dist/harness/observability/observer/types.js +118 -9
  253. package/dist/harness/run/agent/agent.d.ts +18 -0
  254. package/dist/harness/run/agent/agent.js +26 -0
  255. package/dist/harness/run/concurrency/tool-loop-detection-core.d.ts +1 -1
  256. package/dist/harness/run/concurrency/tool-loop-detection-core.js +1 -1
  257. package/dist/harness/run/reliability/harness-events.d.ts +4 -0
  258. package/dist/harness/run/reliability/run-agent.js +110 -18
  259. package/dist/harness/run/reliability/run-metrics-collector.d.ts +28 -2
  260. package/dist/harness/run/reliability/run-metrics-collector.js +92 -2
  261. package/dist/harness/run/run-guard/default-run-guard.d.ts +0 -5
  262. package/dist/harness/run/run-guard/default-run-guard.js +104 -44
  263. package/dist/harness/run/run-scope.d.ts +52 -0
  264. package/dist/harness/run/runner.d.ts +101 -16
  265. package/dist/harness/run/runner.js +556 -158
  266. package/dist/harness/session/attachments/llm-intent.js +17 -17
  267. package/dist/harness/session/history/port.js +1 -0
  268. package/dist/harness/session/in-memory-store.d.ts +1 -0
  269. package/dist/harness/session/in-memory-store.js +22 -1
  270. package/dist/harness/session/schedules/index.d.ts +10 -0
  271. package/dist/harness/session/schedules/index.js +10 -0
  272. package/dist/harness/session/schedules/render.d.ts +13 -0
  273. package/dist/harness/session/schedules/render.js +63 -0
  274. package/dist/harness/session/schedules/service.d.ts +179 -0
  275. package/dist/harness/session/schedules/service.js +695 -0
  276. package/dist/harness/session/schedules/store.d.ts +119 -0
  277. package/dist/harness/session/schedules/store.js +323 -0
  278. package/dist/harness/session/schedules/tools.d.ts +39 -0
  279. package/dist/harness/session/schedules/tools.js +442 -0
  280. package/dist/harness/session/schedules/types.d.ts +104 -0
  281. package/dist/harness/session/schedules/types.js +97 -0
  282. package/dist/harness/session/tasks/tools.js +22 -0
  283. package/dist/harness/session/types.d.ts +35 -0
  284. package/dist/harness/shared/events/agent-event-map.d.ts +13 -0
  285. package/dist/harness/shared/types/agent-definition.d.ts +23 -0
  286. package/dist/index.d.ts +23 -9
  287. package/dist/index.js +10 -2
  288. package/dist/integration/providers/anthropic.d.ts +10 -0
  289. package/dist/integration/providers/anthropic.js +44 -1
  290. package/dist/integration/providers/openai.d.ts +10 -0
  291. package/dist/integration/providers/openai.js +58 -2
  292. package/dist/integration/providers/wire-dump-diff.d.ts +191 -0
  293. package/dist/integration/providers/wire-dump-diff.js +351 -0
  294. package/dist/integration/providers/wire-dump.d.ts +178 -0
  295. package/dist/integration/providers/wire-dump.js +396 -0
  296. package/dist/integration/storage/jsonl.d.ts +11 -0
  297. package/dist/integration/storage/jsonl.js +148 -39
  298. package/dist/integration/storage/session-index.js +63 -8
  299. package/dist/subsystems/cognition-steward/conceptualize/SUBSYSTEM.md +43 -43
  300. package/dist/subsystems/cognition-steward/conceptualize/config.yaml +50 -50
  301. package/dist/subsystems/cognition-steward/consolidate/SUBSYSTEM.md +6 -6
  302. package/dist/subsystems/cognition-steward/consolidate/config.yaml +54 -54
  303. package/dist/subsystems/memory-steward/backfill/handler.js +9 -0
  304. package/dist/subsystems/wisdom-steward/evaluate/config.yaml +50 -50
  305. package/dist/subsystems/wisdom-steward/formation/SUBSYSTEM.md +42 -42
  306. package/dist/subsystems/wisdom-steward/formation/config.yaml +54 -54
  307. package/dist/subsystems/wisdom-steward/govern/config.yaml +55 -55
  308. package/package.json +115 -115
  309. package/dist/harness/collaboration/multi-agent/agent-registry-types.d.ts +0 -144
  310. package/dist/harness/collaboration/multi-agent/agent-registry-types.js +0 -25
  311. package/dist/harness/collaboration/multi-agent/index.d.ts +0 -17
  312. package/dist/harness/collaboration/multi-agent/index.js +0 -15
  313. package/dist/harness/collaboration/multi-agent/process.d.ts +0 -167
  314. package/dist/harness/collaboration/multi-agent/process.js +0 -256
  315. package/dist/harness/collaboration/multi-agent/registry.d.ts +0 -36
  316. package/dist/harness/collaboration/multi-agent/registry.js +0 -137
  317. package/dist/harness/collaboration/multi-agent/swarm.d.ts +0 -135
  318. package/dist/harness/collaboration/multi-agent/swarm.js +0 -317
  319. package/dist/harness/collaboration/multi-agent/types.d.ts +0 -66
  320. package/dist/harness/collaboration/multi-agent/types.js +0 -15
  321. package/dist/harness/collaboration/orchestration/async-task-store.d.ts +0 -107
  322. package/dist/harness/collaboration/orchestration/async-task-store.js +0 -12
  323. package/dist/harness/collaboration/orchestration/async-task.d.ts +0 -156
  324. package/dist/harness/collaboration/orchestration/async-task.js +0 -359
  325. package/dist/harness/collaboration/orchestration/planner/hybrid-planner.d.ts +0 -47
  326. package/dist/harness/collaboration/orchestration/planner/hybrid-planner.js +0 -61
  327. package/dist/harness/collaboration/orchestration/planner/index.d.ts +0 -9
  328. package/dist/harness/collaboration/orchestration/planner/index.js +0 -6
  329. package/dist/harness/collaboration/orchestration/planner/llm-planner.d.ts +0 -54
  330. package/dist/harness/collaboration/orchestration/planner/llm-planner.js +0 -167
  331. package/dist/harness/collaboration/orchestration/planner/rule-planner.d.ts +0 -85
  332. package/dist/harness/collaboration/orchestration/planner/rule-planner.js +0 -175
  333. package/dist/harness/collaboration/orchestration/quality/classifier.d.ts +0 -21
  334. package/dist/harness/collaboration/orchestration/quality/classifier.js +0 -235
  335. package/dist/harness/collaboration/orchestration/quality/gate.d.ts +0 -29
  336. package/dist/harness/collaboration/orchestration/quality/gate.js +0 -409
  337. package/dist/harness/collaboration/orchestration/quality/index.d.ts +0 -9
  338. package/dist/harness/collaboration/orchestration/quality/index.js +0 -8
  339. package/dist/harness/collaboration/orchestration/quality/types.d.ts +0 -159
  340. package/dist/harness/collaboration/orchestration/quality/types.js +0 -33
  341. package/dist/harness/collaboration/orchestration/scheduler/index.d.ts +0 -5
  342. package/dist/harness/collaboration/orchestration/scheduler/index.js +0 -4
  343. package/dist/harness/collaboration/orchestration/scheduler/task-scheduler.d.ts +0 -143
  344. package/dist/harness/collaboration/orchestration/scheduler/task-scheduler.js +0 -297
  345. package/dist/harness/collaboration/orchestration/strategy/classifier.d.ts +0 -12
  346. package/dist/harness/collaboration/orchestration/strategy/classifier.js +0 -81
  347. package/dist/harness/collaboration/orchestration/strategy/index.d.ts +0 -3
  348. package/dist/harness/collaboration/orchestration/strategy/index.js +0 -2
  349. package/dist/harness/collaboration/orchestration/strategy/router.d.ts +0 -28
  350. package/dist/harness/collaboration/orchestration/strategy/router.js +0 -105
  351. package/dist/harness/collaboration/orchestration/strategy/types.d.ts +0 -49
  352. package/dist/harness/collaboration/orchestration/strategy/types.js +0 -4
  353. package/dist/harness/collaboration/orchestration/workflow/engine.d.ts +0 -86
  354. package/dist/harness/collaboration/orchestration/workflow/engine.js +0 -298
  355. package/dist/harness/collaboration/orchestration/workflow/index.d.ts +0 -9
  356. package/dist/harness/collaboration/orchestration/workflow/index.js +0 -7
  357. package/dist/harness/collaboration/orchestration/workflow/types.d.ts +0 -143
  358. package/dist/harness/collaboration/orchestration/workflow/types.js +0 -7
  359. package/dist/harness/governance/human-in-the-loop/approval-manager.d.ts +0 -32
  360. package/dist/harness/governance/human-in-the-loop/approval-manager.js +0 -93
  361. /package/dist/harness/collaboration/{multi-agent → delegation}/message-channel-types.d.ts +0 -0
  362. /package/dist/harness/collaboration/{multi-agent → delegation}/message-channel-types.js +0 -0
@@ -0,0 +1,299 @@
1
+ /**
2
+ * Shell 账本(ToolEffectPolicy §5.6)
3
+ *
4
+ * 无 L4 时由 shell 工具在 spawn 前后制造记账边界:
5
+ * before 快照(内容寻址)→ 执行 → after diff → 注入 TurnFileUndoLog。
6
+ * 清点范围外不装懂;预算撞顶停采 before、业务跑完,标 truncated。
7
+ */
8
+ import { createHash } from 'node:crypto';
9
+ import { readdir, readFile, stat } from 'node:fs/promises';
10
+ import { join, relative } from 'node:path';
11
+ import { pathKey } from './undo-merge.js';
12
+ const DEFAULT_EXCLUDES = new Set([
13
+ 'node_modules',
14
+ '.git',
15
+ '.hg',
16
+ '.svn',
17
+ 'dist',
18
+ 'build',
19
+ '.next',
20
+ '.turbo',
21
+ '.venv',
22
+ 'venv',
23
+ '__pycache__',
24
+ '.octopi',
25
+ 'coverage',
26
+ ]);
27
+ function sha256Hex(data) {
28
+ return createHash('sha256').update(data).digest('hex');
29
+ }
30
+ /**
31
+ * 遍历 roots,收集文件内容哈希(供 before/after 对比)。
32
+ *
33
+ * @param options - 根与预算
34
+ * @returns 采集结果;truncated=true 表示撞顶未扫全
35
+ */
36
+ export async function captureShellInventory(options) {
37
+ const map = new Map();
38
+ const exclude = new Set(options.excludeDirs ?? [...DEFAULT_EXCLUDES]);
39
+ const limit = options.limit ?? {};
40
+ let scanned = 0;
41
+ let bytes = 0;
42
+ let truncated = false;
43
+ const walk = async (dir) => {
44
+ if (truncated)
45
+ return;
46
+ let items;
47
+ try {
48
+ items = await readdir(dir, { withFileTypes: true });
49
+ }
50
+ catch {
51
+ return;
52
+ }
53
+ for (const item of items) {
54
+ if (truncated)
55
+ return;
56
+ const full = join(dir, item.name);
57
+ if (item.isDirectory()) {
58
+ if (exclude.has(item.name))
59
+ continue;
60
+ await walk(full);
61
+ continue;
62
+ }
63
+ if (!item.isFile())
64
+ continue;
65
+ if (limit.maxFiles !== undefined && limit.maxFiles > 0 && scanned >= limit.maxFiles) {
66
+ truncated = true;
67
+ return;
68
+ }
69
+ const st = await stat(full).catch(() => undefined);
70
+ if (!st)
71
+ continue;
72
+ if (limit.maxFileSize !== undefined && limit.maxFileSize > 0 && st.size > limit.maxFileSize) {
73
+ continue;
74
+ }
75
+ if (limit.maxBytes !== undefined && limit.maxBytes > 0 && bytes + st.size > limit.maxBytes) {
76
+ truncated = true;
77
+ return;
78
+ }
79
+ const data = await readFile(full).catch(() => undefined);
80
+ if (!data)
81
+ continue;
82
+ scanned += 1;
83
+ bytes += data.length;
84
+ map.set(pathKey(full), {
85
+ path: full,
86
+ hash: sha256Hex(data),
87
+ size: data.length,
88
+ });
89
+ }
90
+ };
91
+ for (const root of options.roots) {
92
+ const st = await stat(root).catch(() => undefined);
93
+ if (!st)
94
+ continue;
95
+ if (st.isDirectory())
96
+ await walk(root);
97
+ else if (st.isFile()) {
98
+ const data = await readFile(root).catch(() => undefined);
99
+ if (data) {
100
+ scanned += 1;
101
+ bytes += data.length;
102
+ map.set(pathKey(root), { path: root, hash: sha256Hex(data), size: data.length });
103
+ }
104
+ }
105
+ }
106
+ return { map, truncated, scannedFiles: scanned };
107
+ }
108
+ /**
109
+ * 对比 before/after 清单。
110
+ *
111
+ * @param before - shell 前
112
+ * @param after - shell 后
113
+ * @returns 变更集
114
+ */
115
+ export function diffShellInventory(before, after) {
116
+ const created = [];
117
+ const modified = [];
118
+ const deleted = [];
119
+ for (const [key, entry] of after.map) {
120
+ const prev = before.map.get(key);
121
+ if (!prev)
122
+ created.push(entry.path);
123
+ else if (prev.hash !== entry.hash)
124
+ modified.push(entry.path);
125
+ }
126
+ for (const [key, entry] of before.map) {
127
+ if (!after.map.has(key))
128
+ deleted.push(entry.path);
129
+ }
130
+ return { created, modified, deleted };
131
+ }
132
+ export function createShellSnapshotStore() {
133
+ const byPath = new Map();
134
+ const hashes = new Map();
135
+ return {
136
+ async get(path) {
137
+ return byPath.get(pathKey(path));
138
+ },
139
+ async put(path, data) {
140
+ const key = pathKey(path);
141
+ byPath.set(key, data);
142
+ hashes.set(key, sha256Hex(data));
143
+ },
144
+ hashOf(path) {
145
+ return hashes.get(pathKey(path));
146
+ },
147
+ };
148
+ }
149
+ /**
150
+ * shell 前:快照 roots 内文件字节(供 undo)。
151
+ *
152
+ * @param options - roots + 预算
153
+ * @returns 采集 + 字节库
154
+ */
155
+ export async function snapshotShellRoots(options) {
156
+ const store = createShellSnapshotStore();
157
+ const exclude = new Set(options.excludeDirs ?? [...DEFAULT_EXCLUDES]);
158
+ const limit = options.limit ?? {};
159
+ const map = new Map();
160
+ let scanned = 0;
161
+ let bytes = 0;
162
+ let truncated = false;
163
+ const walk = async (dir) => {
164
+ if (truncated)
165
+ return;
166
+ let items;
167
+ try {
168
+ items = await readdir(dir, { withFileTypes: true });
169
+ }
170
+ catch {
171
+ return;
172
+ }
173
+ for (const item of items) {
174
+ if (truncated)
175
+ return;
176
+ const full = join(dir, item.name);
177
+ if (item.isDirectory()) {
178
+ if (exclude.has(item.name))
179
+ continue;
180
+ await walk(full);
181
+ continue;
182
+ }
183
+ if (!item.isFile())
184
+ continue;
185
+ if (limit.maxFiles !== undefined && limit.maxFiles > 0 && scanned >= limit.maxFiles) {
186
+ truncated = true;
187
+ return;
188
+ }
189
+ const st = await stat(full).catch(() => undefined);
190
+ if (!st)
191
+ continue;
192
+ if (limit.maxFileSize !== undefined && limit.maxFileSize > 0 && st.size > limit.maxFileSize) {
193
+ continue;
194
+ }
195
+ if (limit.maxBytes !== undefined && limit.maxBytes > 0 && bytes + st.size > limit.maxBytes) {
196
+ truncated = true;
197
+ return;
198
+ }
199
+ const data = await readFile(full).catch(() => undefined);
200
+ if (!data)
201
+ continue;
202
+ scanned += 1;
203
+ bytes += data.length;
204
+ await store.put(full, data);
205
+ map.set(pathKey(full), {
206
+ path: full,
207
+ hash: sha256Hex(data),
208
+ size: data.length,
209
+ });
210
+ }
211
+ };
212
+ for (const root of options.roots) {
213
+ const st = await stat(root).catch(() => undefined);
214
+ if (!st)
215
+ continue;
216
+ if (st.isDirectory())
217
+ await walk(root);
218
+ else if (st.isFile()) {
219
+ const data = await readFile(root).catch(() => undefined);
220
+ if (data) {
221
+ scanned += 1;
222
+ bytes += data.length;
223
+ await store.put(root, data);
224
+ map.set(pathKey(root), { path: root, hash: sha256Hex(data), size: data.length });
225
+ }
226
+ }
227
+ }
228
+ return { capture: { map, truncated, scannedFiles: scanned }, store };
229
+ }
230
+ /**
231
+ * shell 后:diff 并写入效应账本。
232
+ *
233
+ * @param effects - undo log
234
+ * @param before - 前清单
235
+ * @param after - 后清单
236
+ * @param store - before 字节
237
+ * @returns 变更与是否已入账
238
+ */
239
+ export async function journalShellDiff(effects, before, after, store) {
240
+ // 截断的 before 不得把「未扫到的旧文件」推断成 create(否则 discard 会误删)
241
+ const beforeIncomplete = before.truncated;
242
+ const diff = diffShellInventory(before, after);
243
+ const notInventable = [];
244
+ const created = [];
245
+ const modified = [];
246
+ const deleted = [];
247
+ for (const p of diff.created) {
248
+ if (beforeIncomplete) {
249
+ notInventable.push(p);
250
+ continue;
251
+ }
252
+ const data = await readFile(p).catch(() => undefined);
253
+ await effects.recordCreate(p, data);
254
+ created.push(p);
255
+ }
256
+ for (const p of diff.modified) {
257
+ const beforeBytes = await store.get(p);
258
+ const afterBytes = await readFile(p).catch(() => undefined);
259
+ if (beforeBytes !== undefined) {
260
+ await effects.recordOverwrite(p, beforeBytes, afterBytes);
261
+ modified.push(p);
262
+ }
263
+ else if (beforeIncomplete || before.truncated) {
264
+ notInventable.push(p);
265
+ }
266
+ }
267
+ for (const p of diff.deleted) {
268
+ const beforeBytes = await store.get(p);
269
+ if (beforeBytes !== undefined) {
270
+ await effects.recordDelete(p, beforeBytes);
271
+ deleted.push(p);
272
+ }
273
+ else {
274
+ notInventable.push(p);
275
+ }
276
+ }
277
+ // after 也不完整时,未覆盖范围视为不可逆
278
+ if (after.truncated) {
279
+ // 未扫到的路径未知;标记预算截断供 noteNotReversed
280
+ }
281
+ return { created, modified, deleted, journaled: true, notInventable };
282
+ }
283
+ /** 相对路径辅助(诊断用) */
284
+ export function relToRoot(root, path) {
285
+ return relative(root, path) || path;
286
+ }
287
+ /** 供 discard 读取的不可逆清单文件名 */
288
+ export const NOT_REVERSED_FILE = 'not-reversed.json';
289
+ /**
290
+ * 落盘不可逆效应清单(不进 log.jsonl)。
291
+ *
292
+ * @param undoRoot - sessions/<sid>/undo
293
+ * @param payload - 原因 + 路径清单
294
+ */
295
+ export async function writeNotReversed(undoRoot, payload) {
296
+ const { mkdir, writeFile } = await import('node:fs/promises');
297
+ await mkdir(undoRoot, { recursive: true });
298
+ await writeFile(join(undoRoot, NOT_REVERSED_FILE), JSON.stringify(payload) + '\n', 'utf8');
299
+ }
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Tool capability tags (D5-a). Reduced surface strips `exec` / `egress` /
3
+ * `send` / `dynamic-code` / `runner`. Name-based fallback is only for builtins
4
+ * that are listed here; unknown tools are rejected on reduced (unknown-reject).
5
+ *
6
+ * `vcs` is intentionally **not** stripped: local git porcelain (fixed argv
7
+ * allowlist, hooks disabled) stays available so workspace/untrusted agents can
8
+ * still commit/diff without a shell.
9
+ */
10
+ import type { ToolCapability } from '@octopi-agent/core/types.js';
11
+ export type { ToolCapability };
12
+ /** Capabilities that are denied on the reduced tool surface. */
13
+ export declare const REDUCED_DENIED_CAPABILITIES: readonly ["exec", "egress", "send", "dynamic-code", "runner"];
14
+ /**
15
+ * Builtin name → capability tags. Keep in sync with each tool definition's
16
+ * `capabilities` field (backfilled for every builtin).
17
+ */
18
+ export declare const BUILTIN_TOOL_CAPABILITIES: Record<string, ToolCapability[]>;
19
+ /**
20
+ * Record capabilities for a registered tool (called from ToolBus.register).
21
+ * Untagged registration is stored as `unknown` so a third-party tool cannot
22
+ * inherit the builtin name map by shadowing a builtin name (P1-2 residual).
23
+ *
24
+ * @param toolName - registered name
25
+ * @param capabilities - definition.capabilities (undefined = untagged → unknown)
26
+ */
27
+ export declare function registerToolCapabilities(toolName: string, capabilities?: readonly string[] | null): void;
28
+ /**
29
+ * Resolve capabilities for a tool.
30
+ *
31
+ * Precedence: explicit arg → runtime registry → builtin name map.
32
+ * Explicit `[]` is authoritative (no dangerous caps). Unknown → null.
33
+ *
34
+ * @param toolName - registered tool name
35
+ * @param explicit - capabilities from ToolDefinition (preferred)
36
+ * @returns tags, or null when unknown
37
+ */
38
+ export declare function resolveToolCapabilities(toolName: string, explicit?: readonly string[] | null): ToolCapability[] | null;
39
+ /**
40
+ * Whether any capability is denied on the reduced surface.
41
+ *
42
+ * @param caps - resolved capability tags
43
+ * @returns true when the tool must be stripped
44
+ */
45
+ export declare function deniesReducedSurface(caps: readonly string[]): boolean;
@@ -0,0 +1,126 @@
1
+ /**
2
+ * Tool capability tags (D5-a). Reduced surface strips `exec` / `egress` /
3
+ * `send` / `dynamic-code` / `runner`. Name-based fallback is only for builtins
4
+ * that are listed here; unknown tools are rejected on reduced (unknown-reject).
5
+ *
6
+ * `vcs` is intentionally **not** stripped: local git porcelain (fixed argv
7
+ * allowlist, hooks disabled) stays available so workspace/untrusted agents can
8
+ * still commit/diff without a shell.
9
+ */
10
+ /** Capabilities that are denied on the reduced tool surface. */
11
+ export const REDUCED_DENIED_CAPABILITIES = [
12
+ 'exec',
13
+ 'egress',
14
+ 'send',
15
+ 'dynamic-code',
16
+ /** project_run executes workspace-defined scripts (code execution) */
17
+ 'runner',
18
+ ];
19
+ /**
20
+ * Builtin name → capability tags. Keep in sync with each tool definition's
21
+ * `capabilities` field (backfilled for every builtin).
22
+ */
23
+ export const BUILTIN_TOOL_CAPABILITIES = {
24
+ shell: ['exec'],
25
+ file_read: ['fs-read'],
26
+ file_write: ['fs-write'],
27
+ file_edit: ['fs-write', 'fs-read'],
28
+ file_delete: ['fs-write'],
29
+ file_list: ['fs-read'],
30
+ file_search: ['fs-read'],
31
+ file_mkdir: ['fs-write'],
32
+ file_rmdir: ['fs-write'],
33
+ file_rename: ['fs-write'],
34
+ file_copy: ['fs-write', 'fs-read'],
35
+ file_stat: ['fs-read'],
36
+ // Local VCS porcelain (spawn git argv allowlist; hooks disabled)
37
+ git_status: ['vcs', 'fs-read'],
38
+ git_diff: ['vcs', 'fs-read'],
39
+ git_log: ['vcs', 'fs-read'],
40
+ git_show: ['vcs', 'fs-read'],
41
+ git_commit: ['vcs', 'fs-write'],
42
+ git_branch: ['vcs', 'fs-write'],
43
+ git_restore: ['vcs', 'fs-write'],
44
+ // Package / project tooling
45
+ package_edit: ['fs-write', 'fs-read'],
46
+ project_run: ['runner'],
47
+ package_install: ['egress', 'runner'],
48
+ document_read: ['fs-read'],
49
+ document_probe: ['fs-read'],
50
+ env_info: ['fs-read'],
51
+ http_request: ['egress'],
52
+ web_search: ['egress'],
53
+ ask_user: [],
54
+ memory_store: ['memory'],
55
+ memory_search: ['memory'],
56
+ knowledge_search: ['fs-read'],
57
+ knowledge_read: ['fs-read'],
58
+ session_search: ['fs-read'],
59
+ session_read: ['fs-read'],
60
+ // Session task tools (session/tasks/tools.ts) — tagged via resolve as needed
61
+ task_create: ['fs-write'],
62
+ task_list: ['fs-read'],
63
+ task_plan: ['fs-write'],
64
+ task_complete: ['fs-write'],
65
+ task_pause: ['fs-write'],
66
+ task_resume: ['fs-write'],
67
+ task_drop: ['fs-write'],
68
+ task_note: ['fs-write'],
69
+ };
70
+ const registeredCapabilities = new Map();
71
+ /**
72
+ * Record capabilities for a registered tool (called from ToolBus.register).
73
+ * Untagged registration is stored as `unknown` so a third-party tool cannot
74
+ * inherit the builtin name map by shadowing a builtin name (P1-2 residual).
75
+ *
76
+ * @param toolName - registered name
77
+ * @param capabilities - definition.capabilities (undefined = untagged → unknown)
78
+ */
79
+ export function registerToolCapabilities(toolName, capabilities) {
80
+ const n = toolName.toLowerCase();
81
+ if (capabilities && capabilities.length > 0) {
82
+ registeredCapabilities.set(n, [...capabilities]);
83
+ return;
84
+ }
85
+ if (capabilities && capabilities.length === 0) {
86
+ registeredCapabilities.set(n, []);
87
+ return;
88
+ }
89
+ // Untagged: do not fall back to BUILTIN_TOOL_CAPABILITIES for this name
90
+ registeredCapabilities.set(n, 'unknown');
91
+ }
92
+ /**
93
+ * Resolve capabilities for a tool.
94
+ *
95
+ * Precedence: explicit arg → runtime registry → builtin name map.
96
+ * Explicit `[]` is authoritative (no dangerous caps). Unknown → null.
97
+ *
98
+ * @param toolName - registered tool name
99
+ * @param explicit - capabilities from ToolDefinition (preferred)
100
+ * @returns tags, or null when unknown
101
+ */
102
+ export function resolveToolCapabilities(toolName, explicit) {
103
+ if (explicit !== undefined && explicit !== null) {
104
+ return [...explicit];
105
+ }
106
+ const n = toolName.toLowerCase();
107
+ const reg = registeredCapabilities.get(n);
108
+ if (reg === 'unknown')
109
+ return null;
110
+ if (reg)
111
+ return [...reg];
112
+ // Unregistered: builtin name map only (tests / pre-register probes)
113
+ const builtin = BUILTIN_TOOL_CAPABILITIES[n];
114
+ if (builtin)
115
+ return [...builtin];
116
+ return null;
117
+ }
118
+ /**
119
+ * Whether any capability is denied on the reduced surface.
120
+ *
121
+ * @param caps - resolved capability tags
122
+ * @returns true when the tool must be stripped
123
+ */
124
+ export function deniesReducedSurface(caps) {
125
+ return caps.some((c) => REDUCED_DENIED_CAPABILITIES.includes(c));
126
+ }
@@ -1,80 +1,108 @@
1
1
  /**
2
- * Execution Environment 接口定义
2
+ * Execution Environment interface contracts
3
3
  *
4
- * @layer harness/extension/execution-environment — 执行环境契约。
4
+ * @layer harness/extension/execution-environment
5
5
  */
6
- /** 沙箱隔离级别 */
6
+ import type { ProcessIsolationProfile } from './process-isolation.js';
7
+ /** Legacy coarse isolation level (prefer ProcessIsolationProfile) */
7
8
  export type IsolationLevel = 'none' | 'process' | 'container';
8
- /** 沙箱配置 */
9
+ /** Sandbox config */
9
10
  export interface SandboxConfig {
10
- /** 隔离级别 */
11
- isolationLevel: IsolationLevel;
12
- /** 工作目录 */
11
+ /** Requested isolation level (legacy knob) */
12
+ isolationLevel?: IsolationLevel;
13
+ /** Working directory */
13
14
  cwd?: string;
14
- /** 环境变量 */
15
+ /**
16
+ * Explicit environment. Merged on top of the scrubbed allowlist.
17
+ * Never spreads `process.env` — secrets must not ride along.
18
+ */
15
19
  env?: Record<string, string>;
16
- /** 资源限制 */
20
+ /** Resource limits */
17
21
  limits?: ResourceLimits;
18
- /** 允许的网络访问(CIDR 或 hostname) */
19
- allowedNetwork?: string[];
20
- /** 允许的文件系统路径 */
21
- allowedPaths?: string[];
22
+ /**
23
+ * Network posture for jail backends (bwrap / Seatbelt).
24
+ * Default when omitted: `deny` (D4-c). `allowlist` is interface-only this release
25
+ * and is enforced as `deny` with an honest note.
26
+ */
27
+ networkPolicy?: 'open' | 'deny' | 'allowlist';
28
+ /**
29
+ * Absolute roots the jail may read/write (bind mounts / Seatbelt write-allow).
30
+ * Falls back to `[cwd]` when omitted. Not a substitute for L2 path policy.
31
+ */
32
+ allowRoots?: string[];
33
+ /**
34
+ * D7: when true (untrusted / L4-required), jail backend must actually apply.
35
+ * Setup failure throws instead of falling back to supervised spawn.
36
+ */
37
+ requireJail?: boolean;
38
+ /**
39
+ * Allow `$HOME` writes inside the jail (project/host only per 2b).
40
+ * tmpdir and, on POSIX, shared `/tmp` + `/var/tmp` are always writable (2a);
41
+ * tmp writes are not journaled (2c notReversed).
42
+ */
43
+ homeWrite?: boolean;
44
+ /** Run-level hook for execute-time degradation (falls back to isolation.notes). */
45
+ noteSecurityDegraded?: (reason: string) => void;
46
+ /** Abort in-flight execution */
47
+ signal?: AbortSignal;
22
48
  }
23
- /** 资源限制 */
49
+ /** Resource limits */
24
50
  export interface ResourceLimits {
25
- /** 最大执行时间(毫秒) */
51
+ /** Max wall time (ms) */
26
52
  timeoutMs?: number;
27
- /** 最大内存(字节) */
53
+ /** Max memory (bytes) */
28
54
  maxMemoryBytes?: number;
29
- /** 最大输出大小(字节) */
55
+ /** Max captured output (bytes) */
30
56
  maxOutputBytes?: number;
31
- /** 最大 CPU 时间(毫秒) */
57
+ /** Max CPU time (ms) */
32
58
  maxCpuTimeMs?: number;
33
59
  }
34
- /** 资源使用统计 */
60
+ /** Resource usage */
35
61
  export interface ResourceUsage {
36
- /** 实际执行时间(毫秒) */
62
+ /** Elapsed wall time (ms) */
37
63
  elapsedMs: number;
38
- /** 内存使用峰值(字节,-1 表示未知) */
64
+ /** Peak memory (bytes, -1 unknown) */
39
65
  peakMemoryBytes: number;
40
- /** CPU 时间(毫秒,-1 表示未知) */
66
+ /** CPU time (ms, -1 unknown) */
41
67
  cpuTimeMs: number;
42
- /** 输出大小(字节) */
68
+ /** Output size (bytes) */
43
69
  outputBytes: number;
44
70
  }
45
- /** 沙箱执行结果 */
71
+ /** Sandbox execution result */
46
72
  export interface SandboxResult {
47
- /** 退出码 */
73
+ /** Exit code */
48
74
  exitCode: number;
49
- /** 标准输出 */
75
+ /** stdout */
50
76
  stdout: string;
51
- /** 标准错误 */
77
+ /** stderr */
52
78
  stderr: string;
53
- /** 是否被沙箱终止(超时、OOM 等) */
79
+ /** Terminated by sandbox (timeout, OOM, output cap) */
54
80
  terminated: boolean;
55
- /** 终止原因 */
81
+ /** Terminate reason */
56
82
  terminateReason?: string;
57
- /** 资源使用统计 */
83
+ /** Resource usage */
58
84
  usage: ResourceUsage;
85
+ /** Honest isolation actually applied for this run */
86
+ isolation: ProcessIsolationProfile;
59
87
  }
60
88
  /**
61
- * SandboxProvider — 沙箱提供者接口
62
- *
63
- * 在隔离环境中执行命令。不同实现可以提供不同级别的隔离:
64
- * - none: 直接执行(开发模式)
65
- * - process: 进程级隔离(spawn + resource limits)
66
- * - container: 容器级隔离(Docker/firejail)
89
+ * SandboxProvider — execute commands under an isolation profile.
90
+ * Implementations must report real capabilities via `isolation` / `probe()`.
67
91
  */
68
92
  export interface SandboxProvider {
69
- /** 隔离级别 */
93
+ /** Legacy coarse level */
70
94
  readonly level: IsolationLevel;
95
+ /** Honest isolation profile for this provider */
96
+ probe(): Promise<ProcessIsolationProfile>;
71
97
  /**
72
- * 在沙箱中执行命令
98
+ * Execute a shell command line (platform shell) under isolation.
73
99
  */
74
100
  execute(command: string, config?: SandboxConfig): Promise<SandboxResult>;
75
101
  /**
76
- * 检查沙箱是否可用
102
+ * Execute an argv vector (preferred — no shell string parsing).
77
103
  */
104
+ executeArgv?(argv: string[], config?: SandboxConfig): Promise<SandboxResult>;
105
+ /** Whether this provider can run on the current host */
78
106
  isAvailable(): Promise<boolean>;
79
107
  }
80
108
  /** 工作区配置 */
@@ -1,6 +1,6 @@
1
1
  /**
2
- * Execution Environment 接口定义
2
+ * Execution Environment interface contracts
3
3
  *
4
- * @layer harness/extension/execution-environment — 执行环境契约。
4
+ * @layer harness/extension/execution-environment
5
5
  */
6
6
  export {};