@piagent/platform 1.37.1 → 1.38.1

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 (283) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/README.md +5 -3
  3. package/README.vi.md +2 -2
  4. package/catalog/capabilities.json +2 -2
  5. package/docs/command-reference-vietnamese.md +4 -3
  6. package/docs/distribution-standard.md +6 -6
  7. package/docs/en/maintainer-guide.md +8 -0
  8. package/docs/en/workspace-editor.md +222 -0
  9. package/docs/languages.json +13 -4
  10. package/docs/operator-manual-vietnamese.md +7 -7
  11. package/docs/publishing-for-teams.md +2 -0
  12. package/docs/release-install-policy.md +2 -2
  13. package/docs/research/ide-m0-spike.md +101 -0
  14. package/docs/team-onboarding.md +2 -2
  15. package/docs/vi/maintainer-guide.md +8 -0
  16. package/docs/vi/workspace-editor.md +217 -0
  17. package/docs-site/architecture.html +1 -1
  18. package/docs-site/benchmark.html +1 -1
  19. package/docs-site/commands.html +1 -1
  20. package/docs-site/content/en/index.html +4 -4
  21. package/docs-site/content/en/whats-new.html +17 -0
  22. package/docs-site/content/index.html +4 -4
  23. package/docs-site/content/whats-new.html +17 -0
  24. package/docs-site/context-engine.html +1 -1
  25. package/docs-site/ecosystem.html +1 -1
  26. package/docs-site/en/architecture.html +1 -1
  27. package/docs-site/en/benchmark.html +1 -1
  28. package/docs-site/en/commands.html +1 -1
  29. package/docs-site/en/context-engine.html +1 -1
  30. package/docs-site/en/ecosystem.html +1 -1
  31. package/docs-site/en/index.html +5 -5
  32. package/docs-site/en/mcp-approval.html +1 -1
  33. package/docs-site/en/mcp-auth.html +1 -1
  34. package/docs-site/en/mcp-servers.html +1 -1
  35. package/docs-site/en/mcp.html +1 -1
  36. package/docs-site/en/permissions.html +1 -1
  37. package/docs-site/en/profiles.html +1 -1
  38. package/docs-site/en/quickstart.html +1 -1
  39. package/docs-site/en/runtime.html +1 -1
  40. package/docs-site/en/scope.html +1 -1
  41. package/docs-site/en/security.html +1 -1
  42. package/docs-site/en/team.html +1 -1
  43. package/docs-site/en/whats-new.html +18 -1
  44. package/docs-site/en/windows.html +1 -1
  45. package/docs-site/en/workflows.html +1 -1
  46. package/docs-site/index.html +5 -5
  47. package/docs-site/mcp-approval.html +1 -1
  48. package/docs-site/mcp-auth.html +1 -1
  49. package/docs-site/mcp-servers.html +1 -1
  50. package/docs-site/mcp.html +1 -1
  51. package/docs-site/permissions.html +1 -1
  52. package/docs-site/profiles.html +1 -1
  53. package/docs-site/quickstart.html +1 -1
  54. package/docs-site/runtime.html +1 -1
  55. package/docs-site/scope.html +1 -1
  56. package/docs-site/security.html +1 -1
  57. package/docs-site/team.html +1 -1
  58. package/docs-site/whats-new.html +18 -1
  59. package/docs-site/windows.html +1 -1
  60. package/docs-site/workflows.html +1 -1
  61. package/evals/fixtures/piagent-webui/checkpoint-v1.invalid.json +21 -0
  62. package/evals/fixtures/piagent-webui/checkpoint-v1.valid.json +20 -0
  63. package/evals/fixtures/piagent-webui/terminal-v1.invalid.json +17 -0
  64. package/evals/fixtures/piagent-webui/terminal-v1.valid.json +16 -0
  65. package/evals/fixtures/piagent-webui/workspace-file-v1.invalid.json +24 -0
  66. package/evals/fixtures/piagent-webui/workspace-file-v1.valid.json +23 -0
  67. package/evals/fixtures/piagent-webui/workspace-paths-v1.invalid.json +24 -0
  68. package/evals/fixtures/piagent-webui/workspace-paths-v1.valid.json +24 -0
  69. package/evals/fixtures/piagent-webui/workspace-search-v1.invalid.json +26 -0
  70. package/evals/fixtures/piagent-webui/workspace-search-v1.valid.json +26 -0
  71. package/evals/fixtures/piagent-webui/workspace-tree-v1.invalid.json +28 -0
  72. package/evals/fixtures/piagent-webui/workspace-tree-v1.valid.json +27 -0
  73. package/evals/fixtures/piagent-webui/workspace-write-v1.invalid.json +19 -0
  74. package/evals/fixtures/piagent-webui/workspace-write-v1.valid.json +19 -0
  75. package/evals/long-task-soak-v1/README.md +17 -0
  76. package/evals/long-task-soak-v1/lib/session-loop.mjs +19 -3
  77. package/evals/long-task-soak-v1/scenarios/ide-editor-terminal.json +19 -0
  78. package/evals/long-task-soak-v1/surfaces/webui-gateway.mjs +17 -2
  79. package/evals/long-task-soak-v1/surfaces/workspace-actions.mjs +95 -0
  80. package/evals/private-holdout-v1/public-exposure.v2.json +2 -2
  81. package/package.json +7 -3
  82. package/packages/piagent-core/extensions/fallback-base-policy.ts +1 -1
  83. package/packages/piagent-core/extensions/guard-types.ts +3 -1
  84. package/packages/piagent-core/extensions/path-suggestions.ts +137 -0
  85. package/packages/piagent-core/extensions/piagent-guard.ts +85 -7
  86. package/packages/piagent-core/extensions/workspace-inspection.ts +145 -0
  87. package/packages/piagent-core/extensions/workspace-policy.d.ts +7 -0
  88. package/packages/piagent-core/extensions/workspace-policy.js +3 -0
  89. package/packages/piagent-core/extensions/workspace-search-index.mjs +8 -0
  90. package/packages/piagent-core/extensions/workspace-search.ts +74 -0
  91. package/packages/piagent-core/extensions/workspace-write.ts +116 -0
  92. package/packages/piagent-core/managed/background-process.mjs +9 -4
  93. package/packages/piagent-core/managed/boundary-package-proxy.mjs +21 -0
  94. package/packages/piagent-core/managed/boundary-queue.mjs +24 -0
  95. package/packages/piagent-core/managed/checkpoint-git.mjs +16 -0
  96. package/packages/piagent-core/managed/checkpoints.mjs +17 -64
  97. package/packages/piagent-core/managed/command-tools.mjs +6 -6
  98. package/packages/piagent-core/managed/continuation.mjs +3 -0
  99. package/packages/piagent-core/managed/dist/workspace/assets/adapters/backend-api/profile.json +88 -0
  100. package/packages/piagent-core/managed/dist/workspace/assets/adapters/be-readonly-fe/profile.json +130 -0
  101. package/packages/piagent-core/managed/dist/workspace/assets/adapters/data/profile.json +88 -0
  102. package/packages/piagent-core/managed/dist/workspace/assets/adapters/devops/profile.json +90 -0
  103. package/packages/piagent-core/managed/dist/workspace/assets/adapters/docs/profile.json +74 -0
  104. package/packages/piagent-core/managed/dist/workspace/assets/adapters/fullstack/profile.json +92 -0
  105. package/packages/piagent-core/managed/dist/workspace/assets/adapters/generic/profile.json +95 -0
  106. package/packages/piagent-core/managed/dist/workspace/assets/adapters/mobile/profile.json +86 -0
  107. package/packages/piagent-core/managed/dist/workspace/assets/adapters/node-typescript/profile.json +74 -0
  108. package/packages/piagent-core/managed/dist/workspace/assets/adapters/python/profile.json +75 -0
  109. package/packages/piagent-core/managed/dist/workspace/assets/adapters/web-frontend/profile.json +99 -0
  110. package/packages/piagent-core/managed/dist/workspace/assets/local-state-path-BrmghxEZ.js +284 -0
  111. package/packages/piagent-core/managed/dist/workspace/assets/packages/piagent-core/policies/base-policy.json +351 -0
  112. package/packages/piagent-core/managed/dist/workspace/manifest.json +65 -0
  113. package/packages/piagent-core/managed/dist/workspace/worker.mjs +7374 -0
  114. package/packages/piagent-core/managed/dist/workspace/workspace-search-index.mjs +1007 -0
  115. package/packages/piagent-core/managed/patch-snapshot.mjs +6 -8
  116. package/packages/piagent-core/managed/permission.mjs +29 -6
  117. package/packages/piagent-core/managed/repository-operation.mjs +2 -1
  118. package/packages/piagent-core/managed/review-snapshot-request.mjs +21 -0
  119. package/packages/piagent-core/managed/sandbox-diagnostic.mjs +2 -0
  120. package/packages/piagent-core/managed/session-mutation-observations.mjs +37 -0
  121. package/packages/piagent-core/managed/session.mjs +2 -2
  122. package/packages/piagent-core/managed/source-revert-requests.mjs +21 -0
  123. package/packages/piagent-core/managed/terminal-boundary.mjs +88 -0
  124. package/packages/piagent-core/managed/terminal-channel.mjs +66 -0
  125. package/packages/piagent-core/managed/terminal-runtime.mjs +64 -0
  126. package/packages/piagent-core/managed/terminal-seatbelt.mjs +48 -0
  127. package/packages/piagent-core/managed/terminal-worker.mjs +70 -0
  128. package/packages/piagent-core/managed/tool-boundary.mjs +45 -35
  129. package/packages/piagent-core/managed/tool-freshness.mjs +47 -0
  130. package/packages/piagent-core/managed/tool-worker.mjs +18 -3
  131. package/packages/piagent-core/managed/workspace-worker-pins.mjs +26 -0
  132. package/packages/piagent-core/package.json +1 -1
  133. package/packages/piagent-core/policies/base-policy.json +2 -1
  134. package/packages/piagent-core/runtime/checkpoints/checkpoint-authority.ts +43 -0
  135. package/packages/piagent-core/runtime/checkpoints/checkpoint-refs.mjs +51 -0
  136. package/packages/piagent-core/runtime/checkpoints/checkpoint-store.mjs +179 -0
  137. package/packages/piagent-core/runtime/checkpoints/checkpoint-worker.ts +28 -0
  138. package/packages/piagent-core/runtime/checkpoints/git-adapter.mjs +36 -0
  139. package/packages/piagent-core/runtime/checkpoints/persistent-history.mjs +96 -0
  140. package/packages/piagent-core/runtime/checkpoints/personal-git.ts +272 -0
  141. package/packages/piagent-core/runtime/checkpoints/personal-runtime.ts +158 -0
  142. package/packages/piagent-core/runtime/checkpoints/prune.mjs +29 -0
  143. package/packages/piagent-core/runtime/checkpoints/restore-preview.mjs +46 -0
  144. package/packages/piagent-core/runtime/checkpoints/turn-checkpoints.mjs +167 -0
  145. package/packages/piagent-core/runtime/hooks/session-hooks.ts +19 -16
  146. package/packages/piagent-core/runtime/hooks/session-start-hook.ts +3 -0
  147. package/packages/piagent-core/runtime/hooks/tool-call-hook.ts +2 -2
  148. package/packages/piagent-core/runtime/inspection/diff-projection.ts +2 -1
  149. package/packages/piagent-core/runtime/inspection/managed-source-revert.ts +90 -0
  150. package/packages/piagent-core/runtime/inspection/review-state-projection.ts +19 -8
  151. package/packages/piagent-core/runtime/inspection/session-diff-projection.ts +47 -0
  152. package/packages/piagent-core/runtime/inspection/session-hunk-provenance.ts +56 -0
  153. package/packages/piagent-core/runtime/inspection/session-mutation-observer.ts +125 -0
  154. package/packages/piagent-core/runtime/inspection/source-action-contract.ts +123 -0
  155. package/packages/piagent-core/runtime/inspection/source-change-projection.ts +3 -9
  156. package/packages/piagent-core/runtime/inspection/source-mutation-projection.ts +3 -41
  157. package/packages/piagent-core/runtime/inspection/source-mutation-store.ts +6 -36
  158. package/packages/piagent-core/runtime/inspection/source-revert-projection.ts +36 -30
  159. package/packages/piagent-core/runtime/inspection/text-diff.ts +5 -4
  160. package/packages/piagent-core/runtime/inspection/workspace-worker.ts +79 -0
  161. package/packages/piagent-core/runtime/policy/source-index-transaction.ts +3 -10
  162. package/packages/piagent-core/runtime/policy/source-mutation-guard-binding.ts +27 -2
  163. package/packages/piagent-core/runtime/policy/source-mutation-guard.ts +42 -12
  164. package/packages/piagent-core/runtime/policy/source-worktree-transaction.ts +10 -5
  165. package/packages/piagent-core/runtime/policy/workspace-write-authority.ts +51 -0
  166. package/packages/piagent-core/runtime/process-owner.mjs +20 -0
  167. package/packages/piagent-core/runtime/process-tree-watch.mjs +46 -0
  168. package/packages/piagent-core/runtime/quality/model-mutation-proof.ts +8 -5
  169. package/packages/piagent-core/runtime/registration/permission-commands.ts +10 -2
  170. package/packages/piagent-core/runtime/registration/task-evidence-tools.ts +1 -1
  171. package/packages/piagent-core/runtime/session/workspace-member-edits.d.mts +7 -0
  172. package/packages/piagent-core/runtime/session/workspace-member-edits.mjs +41 -0
  173. package/packages/piagent-core/security/workspace-file-reader.ts +2 -1
  174. package/packages/piagent-webui/dist/client/assets/Alert-DXF8-XqE.js +1 -0
  175. package/packages/piagent-webui/dist/client/assets/Button-DZJosXQi.js +1 -0
  176. package/packages/piagent-webui/dist/client/assets/DialogTitle-CL-fzCnT.js +3 -0
  177. package/packages/piagent-webui/dist/client/assets/MarkdownMessage-k4tq1y8s.js +29 -0
  178. package/packages/piagent-webui/dist/client/assets/TerminalPanel-DvOPgrGI.js +2 -0
  179. package/packages/piagent-webui/dist/client/assets/TerminalView-B_a16moC.js +9 -0
  180. package/packages/piagent-webui/dist/client/assets/TerminalView-kHJ-D0s7.css +1 -0
  181. package/packages/piagent-webui/dist/client/assets/Typography-DMZL1kLS.js +1 -0
  182. package/packages/piagent-webui/dist/client/assets/WorkspaceCodeEditor-BCiYM9NA.js +2 -0
  183. package/packages/piagent-webui/dist/client/assets/WorkspaceExplorer-DttpQtpf.js +5 -0
  184. package/packages/piagent-webui/dist/client/assets/WorkspaceQuickOpen-fgXwQ46B.js +1 -0
  185. package/packages/piagent-webui/dist/client/assets/bootstrap-CedkNtRG.js +1 -0
  186. package/packages/piagent-webui/dist/client/assets/dist-B1M7IjfA.js +10 -0
  187. package/packages/piagent-webui/dist/client/assets/dist-BUYtGaUP.js +1 -0
  188. package/packages/piagent-webui/dist/client/assets/dist-C82AtDDT.js +6 -0
  189. package/packages/piagent-webui/dist/client/assets/dist-D9b8j6pJ.js +1 -0
  190. package/packages/piagent-webui/dist/client/assets/dist-DLfpWwLs.js +23 -0
  191. package/packages/piagent-webui/dist/client/assets/dist-DcEu_WYV.js +1 -0
  192. package/packages/piagent-webui/dist/client/assets/dist-_JsfplOG.js +9 -0
  193. package/packages/piagent-webui/dist/client/assets/dist-idN8f9Fc.js +1 -0
  194. package/packages/piagent-webui/dist/client/assets/dist-nvgpa2Us.js +1 -0
  195. package/packages/piagent-webui/dist/client/assets/index-BW8-BUMx.js +102 -0
  196. package/packages/piagent-webui/dist/client/assets/index-Brs_HjIo.css +1 -0
  197. package/packages/piagent-webui/dist/client/assets/rolldown-runtime-hePW80VL.js +1 -0
  198. package/packages/piagent-webui/dist/client/assets/tab-close-HE0XxoJf.js +1 -0
  199. package/packages/piagent-webui/dist/client/assets/ui-preferences-DiddStu0.js +124 -0
  200. package/packages/piagent-webui/dist/client/assets/useTheme-_ESOj7MI.js +10 -0
  201. package/packages/piagent-webui/dist/client/assets/workspace-api-O7auv_td.js +1 -0
  202. package/packages/piagent-webui/dist/client/index.html +10 -2
  203. package/packages/piagent-webui/extension/same-session-bridge.ts +2 -3
  204. package/packages/piagent-webui/extension/source-revert-controller.ts +14 -208
  205. package/packages/piagent-webui/gateway/checkpoint-sessions.ts +99 -0
  206. package/packages/piagent-webui/gateway/checkpoint-store.ts +6 -0
  207. package/packages/piagent-webui/gateway/company-relay.ts +5 -0
  208. package/packages/piagent-webui/gateway/company-terminal-cache.ts +54 -0
  209. package/packages/piagent-webui/gateway/company-terminal-channel.ts +117 -0
  210. package/packages/piagent-webui/gateway/company-terminal-relay.ts +75 -0
  211. package/packages/piagent-webui/gateway/gateway-protocol-service.ts +12 -0
  212. package/packages/piagent-webui/gateway/gateway-service.ts +48 -4
  213. package/packages/piagent-webui/gateway/managed-gateway.mjs +30 -3
  214. package/packages/piagent-webui/gateway/managed-projection.ts +5 -3
  215. package/packages/piagent-webui/gateway/managed-source-revert-controller.ts +45 -0
  216. package/packages/piagent-webui/gateway/managed-source-revert-sessions.ts +74 -0
  217. package/packages/piagent-webui/gateway/managed-terminal-binding.ts +30 -0
  218. package/packages/piagent-webui/gateway/managed-terminal-processes.ts +74 -0
  219. package/packages/piagent-webui/gateway/managed-terminal-sessions.ts +9 -0
  220. package/packages/piagent-webui/gateway/path-suggestions.ts +1 -124
  221. package/packages/piagent-webui/gateway/personal-terminal-binding.ts +36 -0
  222. package/packages/piagent-webui/gateway/personal-terminal-diagnostic.mjs +16 -0
  223. package/packages/piagent-webui/gateway/personal-terminal-processes.ts +119 -0
  224. package/packages/piagent-webui/gateway/personal-terminal-sessions.ts +22 -0
  225. package/packages/piagent-webui/gateway/runtime-session-controls.ts +2 -1
  226. package/packages/piagent-webui/gateway/session-catalog.ts +3 -2
  227. package/packages/piagent-webui/gateway/session-command-controller.ts +4 -4
  228. package/packages/piagent-webui/gateway/session-inspection-registry.ts +29 -5
  229. package/packages/piagent-webui/gateway/session-runtime-supervisor.ts +8 -8
  230. package/packages/piagent-webui/gateway/signed-session-journal.ts +77 -0
  231. package/packages/piagent-webui/gateway/source-revert-sessions.ts +74 -0
  232. package/packages/piagent-webui/gateway/source-revert-store.ts +47 -0
  233. package/packages/piagent-webui/gateway/terminal-command-ledger.ts +33 -0
  234. package/packages/piagent-webui/gateway/terminal-mentions.ts +29 -0
  235. package/packages/piagent-webui/gateway/terminal-output-buffer.ts +58 -0
  236. package/packages/piagent-webui/gateway/terminal-router.ts +12 -0
  237. package/packages/piagent-webui/gateway/terminal-sessions.ts +247 -0
  238. package/packages/piagent-webui/gateway/workspace-write-sessions.ts +69 -0
  239. package/packages/piagent-webui/gateway/workspace-write-store.ts +6 -0
  240. package/packages/piagent-webui/package.json +14 -2
  241. package/packages/piagent-webui/server/checkpoint-command.ts +30 -0
  242. package/packages/piagent-webui/server/checkpoint-controller.ts +87 -0
  243. package/packages/piagent-webui/server/checkpoint-routes.ts +38 -0
  244. package/packages/piagent-webui/server/control-command-digest.ts +5 -0
  245. package/packages/piagent-webui/server/core-inspection-provider.ts +16 -22
  246. package/packages/piagent-webui/server/gateway-websocket.ts +36 -8
  247. package/packages/piagent-webui/server/loopback-server.ts +9 -0
  248. package/packages/piagent-webui/server/read-model-provider.ts +3 -0
  249. package/packages/piagent-webui/server/read-only-router.ts +3 -0
  250. package/packages/piagent-webui/server/session-auth.ts +4 -1
  251. package/packages/piagent-webui/server/session-source-revert-routes.ts +54 -0
  252. package/packages/piagent-webui/server/source-projection-binding.ts +18 -0
  253. package/packages/piagent-webui/server/source-revert-controller.ts +225 -0
  254. package/packages/piagent-webui/server/terminal-command.ts +35 -0
  255. package/packages/piagent-webui/server/terminal-websocket-stream.ts +56 -0
  256. package/packages/piagent-webui/server/transcript-projection.ts +2 -1
  257. package/packages/piagent-webui/server/workspace-read-routes.ts +32 -0
  258. package/packages/piagent-webui/server/workspace-reader.ts +23 -0
  259. package/packages/piagent-webui/server/workspace-write-controller.ts +118 -0
  260. package/packages/piagent-webui/server/workspace-write-routes.ts +38 -0
  261. package/packages/piagent-webui/shared/terminal-message.ts +23 -0
  262. package/schemas/piagent-webui/catalog-v1.json +63 -0
  263. package/schemas/piagent-webui/checkpoint-v1.schema.json +466 -0
  264. package/schemas/piagent-webui/control-command-v1.schema.json +68 -3
  265. package/schemas/piagent-webui/diff-v1.schema.json +4 -0
  266. package/schemas/piagent-webui/gateway-protocol-v1.schema.json +123 -3
  267. package/schemas/piagent-webui/session-catalog-v1.schema.json +1 -1
  268. package/schemas/piagent-webui/session-command-v1.schema.json +1 -1
  269. package/schemas/piagent-webui/snapshot-v1.schema.json +2 -1
  270. package/schemas/piagent-webui/source-revert-v1.schema.json +22 -3
  271. package/schemas/piagent-webui/terminal-v1.schema.json +495 -0
  272. package/schemas/piagent-webui/workspace-file-v1.schema.json +79 -0
  273. package/schemas/piagent-webui/workspace-paths-v1.schema.json +71 -0
  274. package/schemas/piagent-webui/workspace-search-v1.schema.json +80 -0
  275. package/schemas/piagent-webui/workspace-tree-v1.schema.json +87 -0
  276. package/schemas/piagent-webui/workspace-write-v1.schema.json +276 -0
  277. package/schemas/project-profile.schema.json +8 -3
  278. package/scripts/company-terminal.mjs +16 -11
  279. package/scripts/pi-auto.sh +5 -1
  280. package/scripts/team-doctor.sh +8 -0
  281. package/packages/piagent-webui/dist/client/assets/MarkdownMessage-CfgyQQbW.js +0 -29
  282. package/packages/piagent-webui/dist/client/assets/index-HyzWKvDu.js +0 -234
  283. package/packages/piagent-webui/dist/client/assets/index-_0nGP2n3.css +0 -1
@@ -0,0 +1,99 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "projectId": "web-frontend",
4
+ "displayName": "Web Frontend Project",
5
+ "mode": "web-frontend",
6
+ "permissionProfile": "workspace-write",
7
+ "rootMarkers": [
8
+ "AGENTS.md",
9
+ "package.json"
10
+ ],
11
+ "protectedPaths": [
12
+ ".git/**",
13
+ "**/auth.json",
14
+ "**/.env",
15
+ "**/.env.*",
16
+ "**/node_modules/**",
17
+ "**/dist/**",
18
+ "**/.next/**"
19
+ ],
20
+ "requiredContext": [
21
+ "AGENTS.md",
22
+ ".pi/project-context.md",
23
+ "README.md",
24
+ "package.json"
25
+ ],
26
+ "taskModes": {
27
+ "readOnly": {
28
+ "tools": [
29
+ "read",
30
+ "grep",
31
+ "find",
32
+ "ls"
33
+ ]
34
+ },
35
+ "sourceWrite": {
36
+ "requiresPlan": true,
37
+ "requiresVerify": true
38
+ }
39
+ },
40
+ "verifyCommands": {
41
+ "docsOnly": [
42
+ "test -s README.md"
43
+ ],
44
+ "source": [
45
+ "node -e \"const s=require('./package.json').scripts||{}; const n=['type-check','typecheck','lint','test']; if(!n.some(k=>s[k])){console.error('No Node source verifier is configured');process.exit(2)}\" && npm run type-check --if-present && npm run typecheck --if-present && npm run lint --if-present && npm test --if-present"
46
+ ],
47
+ "runtime": [
48
+ "node -e \"const s=require('./package.json').scripts||{}; if(!s['test:e2e']){console.error('No web frontend runtime verifier is configured');process.exit(2)}\" && npm run test:e2e"
49
+ ]
50
+ },
51
+ "mcpCapabilities": [
52
+ "filesystem-readonly",
53
+ "filesystem-write",
54
+ "shell",
55
+ "github",
56
+ "browser",
57
+ "memory"
58
+ ],
59
+ "capabilityPacks": [
60
+ {
61
+ "name": "web-delivery",
62
+ "version": "0.1.1"
63
+ }
64
+ ],
65
+ "capabilityPolicy": {
66
+ "allowedOwners": [
67
+ "platform-maintainers"
68
+ ],
69
+ "allowedLifecycles": [
70
+ "experimental"
71
+ ],
72
+ "allowedFilesystemRead": [
73
+ "**/*"
74
+ ],
75
+ "allowedFilesystemWrite": [
76
+ "**/*"
77
+ ],
78
+ "allowedNetworkDomains": [],
79
+ "allowedExternalActions": []
80
+ },
81
+ "memory": {
82
+ "enabled": true,
83
+ "mode": "manual",
84
+ "scope": "project",
85
+ "summaryFile": ".pi/memory/memory_summary.md",
86
+ "handbookFile": ".pi/memory/MEMORY.md",
87
+ "localDir": ".pi/memory/local",
88
+ "readBeforeTask": true,
89
+ "writePolicy": "explicit-only",
90
+ "maxInjectedChars": 4000,
91
+ "externalPackages": []
92
+ },
93
+ "runtimePolicy": {
94
+ "execPolicy": "enforce",
95
+ "contextBudget": "enforce",
96
+ "toolRegistry": "advisory",
97
+ "finalGate": "enforce"
98
+ }
99
+ }
@@ -0,0 +1,284 @@
1
+ import path from "node:path";
2
+ import crypto from "node:crypto";
3
+ import fs from "node:fs";
4
+ import "node:child_process";
5
+ //#region ../piagent-core/capabilities/project-profile.js
6
+ var ADAPTER_NAME = /^[a-z0-9][a-z0-9-]{0,63}$/;
7
+ var ProjectProfileError = class extends Error {};
8
+ function adapterProfileFile(platformRoot, name) {
9
+ if (typeof name !== "string") return void 0;
10
+ const trimmed = name.trim();
11
+ if (!ADAPTER_NAME.test(trimmed)) return void 0;
12
+ const candidate = path.join(platformRoot, "adapters", trimmed, "profile.json");
13
+ return fs.existsSync(candidate) ? candidate : void 0;
14
+ }
15
+ function readJson(file) {
16
+ try {
17
+ return JSON.parse(fs.readFileSync(file, "utf8"));
18
+ } catch {
19
+ return;
20
+ }
21
+ }
22
+ /**
23
+ * Resolve a stored project profile document against the installed adapters.
24
+ * Returns the document to enforce, plus the adapter it came from when one was
25
+ * named. Any key the project states replaces the adapter's key whole — there is
26
+ * no per-entry merging of lists, because a half-merged protectedPaths is harder
27
+ * to reason about than a stated one.
28
+ */
29
+ function resolveProjectProfileDocument(platformRoot, stored) {
30
+ if (!stored || typeof stored !== "object" || Array.isArray(stored)) return {
31
+ profile: stored,
32
+ base: void 0
33
+ };
34
+ if (stored.extends === void 0) return {
35
+ profile: stored,
36
+ base: void 0
37
+ };
38
+ const file = adapterProfileFile(platformRoot, stored.extends);
39
+ if (!file) throw new ProjectProfileError(`project profile extends "${String(stored.extends)}", which is not an adapter in the installed platform`);
40
+ const adapter = readJson(file);
41
+ if (!adapter) throw new ProjectProfileError(`adapter profile is unreadable: ${file}`);
42
+ const { extends: base, ...overrides } = stored;
43
+ return {
44
+ profile: {
45
+ ...adapter,
46
+ ...overrides
47
+ },
48
+ base
49
+ };
50
+ }
51
+ //#endregion
52
+ //#region ../piagent-core/extensions/workspace-evidence-roots.js
53
+ var WORKSPACE_PRIVATE_STATE_PATTERNS = Object.freeze([
54
+ "**/.git/**",
55
+ "**/.hg/**",
56
+ "**/.svn/**",
57
+ "**/.pi/**",
58
+ "**/.aws/**",
59
+ "**/.azure/**",
60
+ "**/.docker/**",
61
+ "**/.gnupg/**",
62
+ "**/.kube/**",
63
+ "**/.ssh/**",
64
+ "**/.git-credentials",
65
+ "**/.netrc",
66
+ "**/.npmrc",
67
+ "**/.pypirc",
68
+ "**/.env",
69
+ "**/.env.*",
70
+ "**/auth.json",
71
+ "**/credential.json",
72
+ "**/credentials.json",
73
+ "**/secret.json",
74
+ "**/secrets.json",
75
+ "**/token.json",
76
+ "**/tokens.json"
77
+ ]);
78
+ //#endregion
79
+ //#region ../piagent-core/extensions/context-index-policy.js
80
+ var DEFAULT_CONTEXT_INDEX_PATH = ".pi/context-index.json";
81
+ var CONTEXT_ENGINE_STATE_PATTERN = ".pi/piagent-state/**";
82
+ var EXCLUDE_POLICY_VERSION = 2;
83
+ function stringArray(value) {
84
+ return Array.isArray(value) ? value.filter((item) => typeof item === "string" && item.trim().length > 0) : [];
85
+ }
86
+ function uniqueStrings(values) {
87
+ return [...new Set(values.map((value) => value.trim()).filter(Boolean))];
88
+ }
89
+ function compareCodePoints(left, right) {
90
+ return left < right ? -1 : left > right ? 1 : 0;
91
+ }
92
+ function normalizePattern(value) {
93
+ return String(value ?? "").trim().replaceAll("\\", "/").replace(/^\.\/+/, "").replace(/\/+/g, "/");
94
+ }
95
+ function readJsonObject(file, label, { optional = false } = {}) {
96
+ if (!fs.existsSync(file)) {
97
+ if (optional) return void 0;
98
+ throw new Error(`${label} is missing at ${file}`);
99
+ }
100
+ let parsed;
101
+ try {
102
+ parsed = JSON.parse(fs.readFileSync(file, "utf8"));
103
+ } catch {
104
+ throw new Error(`${label} is not valid JSON: ${file}`);
105
+ }
106
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) throw new Error(`${label} must contain a JSON object: ${file}`);
107
+ return parsed;
108
+ }
109
+ function contextIndexStatePath(profile) {
110
+ const configured = profile?.contextIndex?.path;
111
+ return typeof configured === "string" && configured.trim() ? configured.trim() : DEFAULT_CONTEXT_INDEX_PATH;
112
+ }
113
+ function effectiveProtectedPaths(policy = {}, profile = {}) {
114
+ const policyProtectedPaths = stringArray(policy.protectedPaths);
115
+ const baseReadProtectedPaths = Array.isArray(policy.shellProtectedPaths) ? stringArray(policy.shellProtectedPaths) : policyProtectedPaths;
116
+ const profileProtectedPaths = stringArray(profile.protectedPaths);
117
+ const profileShellProtectedPaths = Array.isArray(profile.shellProtectedPaths) ? stringArray(profile.shellProtectedPaths) : profileProtectedPaths;
118
+ const readOnlyPaths = stringArray(profile.readOnlyPaths);
119
+ const contextIndexPath = contextIndexStatePath(profile);
120
+ return {
121
+ readProtectedPaths: uniqueStrings([
122
+ ...WORKSPACE_PRIVATE_STATE_PATTERNS,
123
+ ...baseReadProtectedPaths,
124
+ ...profileProtectedPaths,
125
+ contextIndexPath
126
+ ]),
127
+ writeProtectedPaths: uniqueStrings([
128
+ ...WORKSPACE_PRIVATE_STATE_PATTERNS,
129
+ ...policyProtectedPaths,
130
+ ...profileProtectedPaths,
131
+ ...readOnlyPaths,
132
+ contextIndexPath
133
+ ]),
134
+ shellProtectedPaths: uniqueStrings([
135
+ ...WORKSPACE_PRIVATE_STATE_PATTERNS,
136
+ ...baseReadProtectedPaths,
137
+ ...profileShellProtectedPaths,
138
+ ...readOnlyPaths,
139
+ contextIndexPath
140
+ ]),
141
+ readOnlyPaths: uniqueStrings(readOnlyPaths)
142
+ };
143
+ }
144
+ function normalizeContextIndexExcludePatterns(patterns) {
145
+ return uniqueStrings(stringArray(patterns).map(normalizePattern)).sort(compareCodePoints);
146
+ }
147
+ function contextIndexExcludePatterns(policy, profile) {
148
+ const effective = effectiveProtectedPaths(policy, profile);
149
+ return normalizeContextIndexExcludePatterns([
150
+ ...effective.readProtectedPaths,
151
+ ...effective.writeProtectedPaths,
152
+ ...effective.shellProtectedPaths,
153
+ CONTEXT_ENGINE_STATE_PATTERN
154
+ ]);
155
+ }
156
+ function contextIndexExcludeDigest(patterns) {
157
+ return crypto.createHash("sha256").update(JSON.stringify({
158
+ version: EXCLUDE_POLICY_VERSION,
159
+ patterns: normalizeContextIndexExcludePatterns(patterns)
160
+ })).digest("hex");
161
+ }
162
+ function loadProjectContextIndexPolicy(platformRoot, projectPath, options = {}) {
163
+ const policy = readJsonObject(path.join(platformRoot, "packages", "piagent-core", "policies", "base-policy.json"), "Piagent base policy");
164
+ const explicitProfilePath = typeof options.profilePath === "string" && options.profilePath.trim() ? path.resolve(options.profilePath) : void 0;
165
+ const profilePath = explicitProfilePath ?? path.join(projectPath, ".pi", "piagent-profile.json");
166
+ const stored = readJsonObject(profilePath, "Piagent project profile", { optional: !explicitProfilePath });
167
+ const profile = stored ? resolveProjectProfileDocument(platformRoot, stored).profile : {};
168
+ return {
169
+ policy,
170
+ profile,
171
+ profilePath,
172
+ profileSource: explicitProfilePath ? "env" : stored ? "project" : "fallback",
173
+ excludePatterns: contextIndexExcludePatterns(policy, profile)
174
+ };
175
+ }
176
+ //#endregion
177
+ //#region ../piagent-core/extensions/policy-core.js
178
+ function escapeRegex(value) {
179
+ return value.replace(/[.+^${}()|[\]\\]/g, "\\$&");
180
+ }
181
+ function normalizePathCandidate(candidate) {
182
+ if (typeof candidate !== "string") return "";
183
+ const raw = candidate.trim().replace(/^['"]|['"]$/g, "");
184
+ if (/^\/+$/.test(raw)) return "/";
185
+ return raw.replace(/\\/g, "/").replace(/^\.\//, "").replace(/\/+/g, "/").replace(/\/$/, "");
186
+ }
187
+ function segmentMatches(patternSegment, candidateSegment) {
188
+ if (patternSegment === "*") return candidateSegment.length > 0;
189
+ return new RegExp(`^${escapeRegex(patternSegment).replace(/\*/g, "[^/]*")}$`).test(candidateSegment);
190
+ }
191
+ function globMatchesPath(pattern, candidate) {
192
+ const normalizedPattern = normalizePathCandidate(pattern);
193
+ const normalizedCandidate = normalizePathCandidate(candidate);
194
+ if (!normalizedPattern || !normalizedCandidate) return false;
195
+ const patternSegments = normalizedPattern.split("/").filter(Boolean);
196
+ const candidateSegments = normalizedCandidate.split("/").filter(Boolean);
197
+ function match(patternIndex, candidateIndex) {
198
+ if (patternIndex === patternSegments.length) return candidateIndex === candidateSegments.length;
199
+ const patternSegment = patternSegments[patternIndex];
200
+ if (patternSegment === "**") {
201
+ if (match(patternIndex + 1, candidateIndex)) return true;
202
+ for (let nextCandidate = candidateIndex; nextCandidate < candidateSegments.length; nextCandidate += 1) if (match(patternIndex + 1, nextCandidate + 1)) return true;
203
+ return false;
204
+ }
205
+ if (candidateIndex >= candidateSegments.length) return false;
206
+ if (!segmentMatches(patternSegment, candidateSegments[candidateIndex])) return false;
207
+ return match(patternIndex + 1, candidateIndex + 1);
208
+ }
209
+ return match(0, 0);
210
+ }
211
+ function matchesProtectedPath(candidate, patterns) {
212
+ const normalizedCandidate = normalizePathCandidate(candidate).toLocaleLowerCase("en-US");
213
+ if (!normalizedCandidate) return void 0;
214
+ return patterns.find((pattern) => {
215
+ const normalizedPattern = normalizePathCandidate(pattern).toLocaleLowerCase("en-US");
216
+ if (globMatchesPath(normalizedPattern, normalizedCandidate)) return true;
217
+ if (normalizedPattern.endsWith("/**")) return globMatchesPath(normalizedPattern.slice(0, -3), normalizedCandidate);
218
+ return false;
219
+ });
220
+ }
221
+ //#endregion
222
+ //#region ../piagent-core/extensions/local-state-path.js
223
+ function statePathError(label, reason) {
224
+ return /* @__PURE__ */ new Error(`${label} ${reason}`);
225
+ }
226
+ function resolveLocalStatePath(projectRoot, target, options = {}) {
227
+ const label = options.label ?? "Local state path";
228
+ const lexicalRoot = path.resolve(projectRoot);
229
+ const absoluteTarget = path.resolve(target);
230
+ const canonicalRoot = fs.realpathSync.native(lexicalRoot);
231
+ let relative = path.relative(lexicalRoot, absoluteTarget);
232
+ if (relative === ".." || relative.startsWith(`..${path.sep}`) || path.isAbsolute(relative)) relative = path.relative(canonicalRoot, absoluteTarget);
233
+ if (relative === ".." || relative.startsWith(`..${path.sep}`) || path.isAbsolute(relative)) throw statePathError(label, "must stay inside the project");
234
+ const segments = relative.split(path.sep).filter(Boolean);
235
+ let current = canonicalRoot;
236
+ for (let index = 0; index < segments.length; index += 1) {
237
+ current = path.join(current, segments[index]);
238
+ let stat;
239
+ try {
240
+ stat = fs.lstatSync(current);
241
+ } catch (error) {
242
+ if (error?.code === "ENOENT") return path.join(canonicalRoot, ...segments);
243
+ throw error;
244
+ }
245
+ if (stat.isSymbolicLink()) throw statePathError(label, `must not traverse a symbolic link (${segments.slice(0, index + 1).join("/")})`);
246
+ const final = index === segments.length - 1;
247
+ if (!final && !stat.isDirectory()) throw statePathError(label, `has a non-directory ancestor (${segments.slice(0, index + 1).join("/")})`);
248
+ if (final && options.kind === "directory" && !stat.isDirectory()) throw statePathError(label, "must be a directory");
249
+ if (final && options.kind === "file" && !stat.isFile()) throw statePathError(label, "must be a regular file");
250
+ }
251
+ return path.join(canonicalRoot, ...segments);
252
+ }
253
+ var STATE_ROOT_IGNORE = "# Piagent runtime state: local only, never committed.\n*\n";
254
+ function ensureStateRootIgnored(projectRoot) {
255
+ try {
256
+ const root = resolveLocalStatePath(projectRoot, path.join(projectRoot, ".pi", "piagent-state"), { label: "Piagent state root" });
257
+ fs.mkdirSync(root, {
258
+ recursive: true,
259
+ mode: 448
260
+ });
261
+ fs.writeFileSync(path.join(root, ".gitignore"), STATE_ROOT_IGNORE, {
262
+ flag: "wx",
263
+ mode: 384
264
+ });
265
+ } catch {}
266
+ }
267
+ function ensurePrivateStateDirectory(projectRoot, directory, label = "Local state directory") {
268
+ const target = resolveLocalStatePath(projectRoot, directory, { label });
269
+ fs.mkdirSync(target, {
270
+ recursive: true,
271
+ mode: 448
272
+ });
273
+ if (path.relative(path.join(fs.realpathSync.native(path.resolve(projectRoot)), ".pi", "piagent-state"), target).split(path.sep)[0] !== "..") ensureStateRootIgnored(projectRoot);
274
+ const verified = resolveLocalStatePath(projectRoot, directory, {
275
+ label,
276
+ kind: "directory"
277
+ });
278
+ try {
279
+ fs.chmodSync(verified, 448);
280
+ } catch {}
281
+ return verified;
282
+ }
283
+ //#endregion
284
+ export { effectiveProtectedPaths as a, contextIndexExcludeDigest as i, resolveLocalStatePath as n, loadProjectContextIndexPolicy as o, matchesProtectedPath as r, normalizeContextIndexExcludePatterns as s, ensurePrivateStateDirectory as t };