@xenosystem/agent-sdk 0.9.21 → 0.9.24

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 (60) hide show
  1. package/README.md +18 -8
  2. package/dist/artifacts/index.cjs +1 -1
  3. package/dist/artifacts/index.js +1 -1
  4. package/dist/automation/index.cjs +16 -3
  5. package/dist/automation/index.d.cts +367 -1
  6. package/dist/automation/index.d.ts +367 -1
  7. package/dist/automation/index.js +16 -3
  8. package/dist/automation/metafile-cjs.json +1 -1
  9. package/dist/automation/metafile-esm.json +1 -1
  10. package/dist/control-plane/index.cjs +1 -1
  11. package/dist/control-plane/index.js +1 -1
  12. package/dist/control-room/index.d.cts +1 -1
  13. package/dist/control-room/index.d.ts +1 -1
  14. package/dist/control-room/metafile-cjs.json +1 -1
  15. package/dist/control-room/metafile-esm.json +1 -1
  16. package/dist/coordination/index.cjs +2 -0
  17. package/dist/coordination/index.d.cts +395 -0
  18. package/dist/coordination/index.d.ts +395 -0
  19. package/dist/coordination/index.js +2 -0
  20. package/dist/coordination/metafile-cjs.json +1 -0
  21. package/dist/coordination/metafile-esm.json +1 -0
  22. package/dist/electron/index.cjs +123 -119
  23. package/dist/electron/index.d.cts +61 -0
  24. package/dist/electron/index.d.ts +61 -0
  25. package/dist/electron/index.js +118 -114
  26. package/dist/electron/metafile-cjs.json +1 -1
  27. package/dist/electron/metafile-esm.json +1 -1
  28. package/dist/governance/index.d.cts +29 -0
  29. package/dist/governance/index.d.ts +29 -0
  30. package/dist/hosted/index.cjs +1 -1
  31. package/dist/hosted/index.js +1 -1
  32. package/dist/hosted/metafile-cjs.json +1 -1
  33. package/dist/hosted/metafile-esm.json +1 -1
  34. package/dist/index.cjs +359 -351
  35. package/dist/index.d.cts +1964 -1254
  36. package/dist/index.d.ts +1964 -1254
  37. package/dist/index.js +359 -351
  38. package/dist/mcp/index.d.cts +28 -0
  39. package/dist/mcp/index.d.ts +28 -0
  40. package/dist/metafile-cjs.json +1 -1
  41. package/dist/metafile-esm.json +1 -1
  42. package/dist/providers/metafile-cjs.json +1 -1
  43. package/dist/providers/metafile-esm.json +1 -1
  44. package/dist/session/index.cjs +56 -54
  45. package/dist/session/index.d.cts +69 -1
  46. package/dist/session/index.d.ts +69 -1
  47. package/dist/session/index.js +56 -54
  48. package/dist/session/metafile-cjs.json +1 -1
  49. package/dist/session/metafile-esm.json +1 -1
  50. package/dist/skills/index.d.cts +28 -0
  51. package/dist/skills/index.d.ts +28 -0
  52. package/dist/ui/index.d.cts +28 -0
  53. package/dist/ui/index.d.ts +28 -0
  54. package/dist/utils/index.cjs +17 -16
  55. package/dist/utils/index.d.cts +31 -1
  56. package/dist/utils/index.d.ts +31 -1
  57. package/dist/utils/index.js +14 -13
  58. package/dist/utils/metafile-cjs.json +1 -1
  59. package/dist/utils/metafile-esm.json +1 -1
  60. package/package.json +6 -1
@@ -1 +1 @@
1
- {"inputs":{"src/automation/types.ts":{"bytes":7223,"imports":[],"format":"esm"},"src/automation/operations.ts":{"bytes":3367,"imports":[],"format":"esm"},"src/automation/errors.ts":{"bytes":866,"imports":[],"format":"esm"},"src/security/path-policy.ts":{"bytes":5541,"imports":[{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true}],"format":"esm"},"src/security/windows-process-containment.ts":{"bytes":51557,"imports":[{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:child_process","kind":"import-statement","external":true},{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:os","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true}],"format":"esm"},"src/security/linux-process-containment.ts":{"bytes":5665,"imports":[{"path":"node:child_process","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true}],"format":"esm"},"src/security/containment-certification.ts":{"bytes":13312,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true}],"format":"esm"},"src/security/environment-policy.ts":{"bytes":1195,"imports":[],"format":"esm"},"src/security/mxc-containment.ts":{"bytes":28272,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:os","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"node:child_process","kind":"import-statement","external":true},{"path":"node:url","kind":"import-statement","external":true},{"path":"src/security/environment-policy.ts","kind":"import-statement","original":"./environment-policy.js"},{"path":"src/security/path-policy.ts","kind":"import-statement","original":"./path-policy.js"}],"format":"esm"},"src/security/process-containment.ts":{"bytes":17360,"imports":[{"path":"src/security/windows-process-containment.ts","kind":"import-statement","original":"./windows-process-containment.js"},{"path":"src/security/linux-process-containment.ts","kind":"import-statement","original":"./linux-process-containment.js"},{"path":"src/security/path-policy.ts","kind":"import-statement","original":"./path-policy.js"},{"path":"src/security/containment-certification.ts","kind":"import-statement","original":"./containment-certification.js"},{"path":"src/security/mxc-containment.ts","kind":"import-statement","original":"./mxc-containment.js"}],"format":"esm"},"src/security/secure-execution-contract.ts":{"bytes":24510,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:os","kind":"import-statement","external":true},{"path":"src/security/path-policy.ts","kind":"import-statement","original":"./path-policy.js"},{"path":"src/security/process-containment.ts","kind":"import-statement","original":"./process-containment.js"}],"format":"esm"},"src/automation/policy.ts":{"bytes":15653,"imports":[{"path":"src/security/secure-execution-contract.ts","kind":"import-statement","original":"../security/secure-execution-contract.js"},{"path":"src/automation/errors.ts","kind":"import-statement","original":"./errors.js"},{"path":"src/automation/operations.ts","kind":"import-statement","original":"./operations.js"},{"path":"src/automation/types.ts","kind":"import-statement","original":"./types.js"}],"format":"esm"},"src/artifacts/types.ts":{"bytes":11224,"imports":[],"format":"esm"},"src/artifacts/hash.ts":{"bytes":1489,"imports":[{"path":"node:crypto","kind":"import-statement","external":true}],"format":"esm"},"src/utils/custom-names.ts":{"bytes":2210,"imports":[],"format":"esm"},"src/artifacts/validation.ts":{"bytes":25271,"imports":[{"path":"src/artifacts/types.ts","kind":"import-statement","original":"./types.js"},{"path":"node:buffer","kind":"import-statement","external":true},{"path":"src/artifacts/hash.ts","kind":"import-statement","original":"./hash.js"},{"path":"src/utils/custom-names.ts","kind":"import-statement","original":"../utils/custom-names.js"},{"path":"src/artifacts/types.ts","kind":"import-statement","original":"./types.js"}],"format":"esm"},"src/artifacts/repository.ts":{"bytes":29289,"imports":[{"path":"src/artifacts/types.ts","kind":"import-statement","original":"./types.js"},{"path":"src/artifacts/validation.ts","kind":"import-statement","original":"./validation.js"}],"format":"esm"},"src/automation/evidence.ts":{"bytes":8618,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"src/artifacts/repository.ts","kind":"import-statement","original":"../artifacts/repository.js"},{"path":"src/artifacts/hash.ts","kind":"import-statement","original":"../artifacts/hash.js"},{"path":"src/artifacts/types.ts","kind":"import-statement","original":"../artifacts/types.js"},{"path":"src/automation/errors.ts","kind":"import-statement","original":"./errors.js"}],"format":"esm"},"src/automation/executor.ts":{"bytes":14249,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"src/automation/errors.ts","kind":"import-statement","original":"./errors.js"},{"path":"src/automation/evidence.ts","kind":"import-statement","original":"./evidence.js"},{"path":"src/automation/operations.ts","kind":"import-statement","original":"./operations.js"},{"path":"src/automation/policy.ts","kind":"import-statement","original":"./policy.js"}],"format":"esm"},"src/automation/conformance.ts":{"bytes":4331,"imports":[{"path":"src/automation/errors.ts","kind":"import-statement","original":"./errors.js"},{"path":"src/automation/policy.ts","kind":"import-statement","original":"./policy.js"},{"path":"src/automation/types.ts","kind":"import-statement","original":"./types.js"}],"format":"esm"},"src/automation/http-adapter.ts":{"bytes":8862,"imports":[{"path":"src/automation/errors.ts","kind":"import-statement","original":"./errors.js"}],"format":"esm"},"src/automation/tool-pack.ts":{"bytes":19206,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"src/automation/operations.ts","kind":"import-statement","original":"./operations.js"}],"format":"esm"},"src/automation/index.ts":{"bytes":282,"imports":[{"path":"src/automation/types.ts","kind":"import-statement","original":"./types.js"},{"path":"src/automation/operations.ts","kind":"import-statement","original":"./operations.js"},{"path":"src/automation/errors.ts","kind":"import-statement","original":"./errors.js"},{"path":"src/automation/policy.ts","kind":"import-statement","original":"./policy.js"},{"path":"src/automation/evidence.ts","kind":"import-statement","original":"./evidence.js"},{"path":"src/automation/executor.ts","kind":"import-statement","original":"./executor.js"},{"path":"src/automation/conformance.ts","kind":"import-statement","original":"./conformance.js"},{"path":"src/automation/http-adapter.ts","kind":"import-statement","original":"./http-adapter.js"},{"path":"src/automation/tool-pack.ts","kind":"import-statement","original":"./tool-pack.js"}],"format":"esm"}},"outputs":{"dist/automation/index.cjs":{"imports":[{"path":"node:crypto","kind":"require-call","external":true},{"path":"node:crypto","kind":"require-call","external":true},{"path":"node:crypto","kind":"require-call","external":true},{"path":"node:crypto","kind":"require-call","external":true},{"path":"node:crypto","kind":"require-call","external":true}],"exports":[],"entryPoint":"src/automation/index.ts","inputs":{"src/automation/index.ts":{"bytesInOutput":737},"src/automation/types.ts":{"bytesInOutput":8},"src/automation/operations.ts":{"bytesInOutput":1638},"src/automation/errors.ts":{"bytesInOutput":129},"src/security/secure-execution-contract.ts":{"bytesInOutput":3310},"src/security/windows-process-containment.ts":{"bytesInOutput":47238},"src/security/containment-certification.ts":{"bytesInOutput":442},"src/security/mxc-containment.ts":{"bytesInOutput":709},"src/security/process-containment.ts":{"bytesInOutput":999},"src/automation/policy.ts":{"bytesInOutput":7870},"src/automation/evidence.ts":{"bytesInOutput":4445},"src/artifacts/types.ts":{"bytesInOutput":818},"src/artifacts/hash.ts":{"bytesInOutput":129},"src/artifacts/validation.ts":{"bytesInOutput":146},"src/artifacts/repository.ts":{"bytesInOutput":137},"src/automation/executor.ts":{"bytesInOutput":6079},"src/automation/conformance.ts":{"bytesInOutput":2191},"src/automation/http-adapter.ts":{"bytesInOutput":4320},"src/automation/tool-pack.ts":{"bytesInOutput":10033}},"bytes":92419}}}
1
+ {"inputs":{"src/automation/types.ts":{"bytes":7223,"imports":[],"format":"esm"},"src/automation/operations.ts":{"bytes":3367,"imports":[],"format":"esm"},"src/automation/errors.ts":{"bytes":866,"imports":[],"format":"esm"},"src/security/path-policy.ts":{"bytes":5541,"imports":[{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true}],"format":"esm"},"src/security/windows-process-containment.ts":{"bytes":51557,"imports":[{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:child_process","kind":"import-statement","external":true},{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:os","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true}],"format":"esm"},"src/security/linux-process-containment.ts":{"bytes":5665,"imports":[{"path":"node:child_process","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true}],"format":"esm"},"src/security/containment-certification.ts":{"bytes":13312,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true}],"format":"esm"},"src/security/environment-policy.ts":{"bytes":1195,"imports":[],"format":"esm"},"src/security/mxc-containment.ts":{"bytes":28272,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:os","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"node:child_process","kind":"import-statement","external":true},{"path":"node:url","kind":"import-statement","external":true},{"path":"src/security/environment-policy.ts","kind":"import-statement","original":"./environment-policy.js"},{"path":"src/security/path-policy.ts","kind":"import-statement","original":"./path-policy.js"}],"format":"esm"},"src/security/process-containment.ts":{"bytes":17360,"imports":[{"path":"src/security/windows-process-containment.ts","kind":"import-statement","original":"./windows-process-containment.js"},{"path":"src/security/linux-process-containment.ts","kind":"import-statement","original":"./linux-process-containment.js"},{"path":"src/security/path-policy.ts","kind":"import-statement","original":"./path-policy.js"},{"path":"src/security/containment-certification.ts","kind":"import-statement","original":"./containment-certification.js"},{"path":"src/security/mxc-containment.ts","kind":"import-statement","original":"./mxc-containment.js"}],"format":"esm"},"src/security/secure-execution-contract.ts":{"bytes":24510,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:os","kind":"import-statement","external":true},{"path":"src/security/path-policy.ts","kind":"import-statement","original":"./path-policy.js"},{"path":"src/security/process-containment.ts","kind":"import-statement","original":"./process-containment.js"}],"format":"esm"},"src/automation/policy.ts":{"bytes":15653,"imports":[{"path":"src/security/secure-execution-contract.ts","kind":"import-statement","original":"../security/secure-execution-contract.js"},{"path":"src/automation/errors.ts","kind":"import-statement","original":"./errors.js"},{"path":"src/automation/operations.ts","kind":"import-statement","original":"./operations.js"},{"path":"src/automation/types.ts","kind":"import-statement","original":"./types.js"}],"format":"esm"},"src/artifacts/types.ts":{"bytes":11224,"imports":[],"format":"esm"},"src/artifacts/hash.ts":{"bytes":1489,"imports":[{"path":"node:crypto","kind":"import-statement","external":true}],"format":"esm"},"src/utils/custom-names.ts":{"bytes":2210,"imports":[],"format":"esm"},"src/artifacts/validation.ts":{"bytes":25271,"imports":[{"path":"src/artifacts/types.ts","kind":"import-statement","original":"./types.js"},{"path":"node:buffer","kind":"import-statement","external":true},{"path":"src/artifacts/hash.ts","kind":"import-statement","original":"./hash.js"},{"path":"src/utils/custom-names.ts","kind":"import-statement","original":"../utils/custom-names.js"},{"path":"src/artifacts/types.ts","kind":"import-statement","original":"./types.js"}],"format":"esm"},"src/artifacts/repository.ts":{"bytes":29289,"imports":[{"path":"src/artifacts/types.ts","kind":"import-statement","original":"./types.js"},{"path":"src/artifacts/validation.ts","kind":"import-statement","original":"./validation.js"}],"format":"esm"},"src/automation/evidence.ts":{"bytes":8618,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"src/artifacts/repository.ts","kind":"import-statement","original":"../artifacts/repository.js"},{"path":"src/artifacts/hash.ts","kind":"import-statement","original":"../artifacts/hash.js"},{"path":"src/artifacts/types.ts","kind":"import-statement","original":"../artifacts/types.js"},{"path":"src/automation/errors.ts","kind":"import-statement","original":"./errors.js"}],"format":"esm"},"src/automation/executor.ts":{"bytes":14249,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"src/automation/errors.ts","kind":"import-statement","original":"./errors.js"},{"path":"src/automation/evidence.ts","kind":"import-statement","original":"./evidence.js"},{"path":"src/automation/operations.ts","kind":"import-statement","original":"./operations.js"},{"path":"src/automation/policy.ts","kind":"import-statement","original":"./policy.js"}],"format":"esm"},"src/automation/conformance.ts":{"bytes":4331,"imports":[{"path":"src/automation/errors.ts","kind":"import-statement","original":"./errors.js"},{"path":"src/automation/policy.ts","kind":"import-statement","original":"./policy.js"},{"path":"src/automation/types.ts","kind":"import-statement","original":"./types.js"}],"format":"esm"},"src/automation/http-adapter.ts":{"bytes":8862,"imports":[{"path":"src/automation/errors.ts","kind":"import-statement","original":"./errors.js"}],"format":"esm"},"src/automation/browser-control-plane-adapter.ts":{"bytes":17420,"imports":[{"path":"node:crypto","kind":"import-statement","external":true}],"format":"esm"},"src/control-plane/lock.ts":{"bytes":2496,"imports":[{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:os","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true}],"format":"esm"},"src/version.ts":{"bytes":37,"imports":[],"format":"esm"},"src/artifacts/file-repository.ts":{"bytes":16334,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:fs/promises","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"src/control-plane/lock.ts","kind":"import-statement","original":"../control-plane/lock.js"},{"path":"src/version.ts","kind":"import-statement","original":"../version.js"},{"path":"src/artifacts/hash.ts","kind":"import-statement","original":"./hash.js"},{"path":"src/artifacts/repository.ts","kind":"import-statement","original":"./repository.js"},{"path":"src/artifacts/types.ts","kind":"import-statement","original":"./types.js"}],"format":"esm"},"src/utils/yaml.ts":{"bytes":5506,"imports":[],"format":"esm"},"src/utils/platform.ts":{"bytes":5600,"imports":[{"path":"node:os","kind":"import-statement","external":true},{"path":"node:child_process","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true}],"format":"esm"},"src/agents/definitions.ts":{"bytes":20961,"imports":[{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"src/utils/yaml.ts","kind":"import-statement","original":"../utils/yaml.js"},{"path":"src/utils/platform.ts","kind":"import-statement","original":"../utils/platform.js"}],"format":"esm"},"src/agents/profiles.ts":{"bytes":33625,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"src/agents/definitions.ts","kind":"import-statement","original":"./definitions.js"}],"format":"esm"},"src/security/capability-lease.ts":{"bytes":25286,"imports":[{"path":"src/agents/profiles.ts","kind":"import-statement","original":"../agents/profiles.js"},{"path":"src/utils/custom-names.ts","kind":"import-statement","original":"../utils/custom-names.js"}],"format":"esm"},"src/automation/tool-pack.ts":{"bytes":19206,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"src/automation/operations.ts","kind":"import-statement","original":"./operations.js"}],"format":"esm"},"src/automation/host-runtime.ts":{"bytes":30630,"imports":[{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:os","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"src/artifacts/file-repository.ts","kind":"import-statement","original":"../artifacts/file-repository.js"},{"path":"src/security/capability-lease.ts","kind":"import-statement","original":"../security/capability-lease.js"},{"path":"src/security/secure-execution-contract.ts","kind":"import-statement","original":"../security/secure-execution-contract.js"},{"path":"src/automation/types.ts","kind":"import-statement","original":"./types.js"},{"path":"src/automation/executor.ts","kind":"import-statement","original":"./executor.js"},{"path":"src/automation/operations.ts","kind":"import-statement","original":"./operations.js"},{"path":"src/automation/tool-pack.ts","kind":"import-statement","original":"./tool-pack.js"},{"path":"src/automation/browser-control-plane-adapter.ts","kind":"import-statement","original":"./browser-control-plane-adapter.js"}],"format":"esm"},"src/automation/index.ts":{"bytes":369,"imports":[{"path":"src/automation/types.ts","kind":"import-statement","original":"./types.js"},{"path":"src/automation/operations.ts","kind":"import-statement","original":"./operations.js"},{"path":"src/automation/errors.ts","kind":"import-statement","original":"./errors.js"},{"path":"src/automation/policy.ts","kind":"import-statement","original":"./policy.js"},{"path":"src/automation/evidence.ts","kind":"import-statement","original":"./evidence.js"},{"path":"src/automation/executor.ts","kind":"import-statement","original":"./executor.js"},{"path":"src/automation/conformance.ts","kind":"import-statement","original":"./conformance.js"},{"path":"src/automation/http-adapter.ts","kind":"import-statement","original":"./http-adapter.js"},{"path":"src/automation/browser-control-plane-adapter.ts","kind":"import-statement","original":"./browser-control-plane-adapter.js"},{"path":"src/automation/host-runtime.ts","kind":"import-statement","original":"./host-runtime.js"},{"path":"src/automation/tool-pack.ts","kind":"import-statement","original":"./tool-pack.js"}],"format":"esm"}},"outputs":{"dist/automation/index.cjs":{"imports":[{"path":"node:crypto","kind":"require-call","external":true},{"path":"node:os","kind":"require-call","external":true},{"path":"node:fs","kind":"require-call","external":true},{"path":"node:path","kind":"require-call","external":true},{"path":"node:fs","kind":"require-call","external":true},{"path":"node:path","kind":"require-call","external":true},{"path":"node:child_process","kind":"require-call","external":true},{"path":"node:fs","kind":"require-call","external":true},{"path":"node:path","kind":"require-call","external":true},{"path":"node:crypto","kind":"require-call","external":true},{"path":"node:fs","kind":"require-call","external":true},{"path":"node:path","kind":"require-call","external":true},{"path":"node:crypto","kind":"require-call","external":true},{"path":"node:fs","kind":"require-call","external":true},{"path":"node:os","kind":"require-call","external":true},{"path":"node:path","kind":"require-call","external":true},{"path":"node:child_process","kind":"require-call","external":true},{"path":"node:url","kind":"require-call","external":true},{"path":"node:crypto","kind":"require-call","external":true},{"path":"node:buffer","kind":"require-call","external":true},{"path":"node:crypto","kind":"require-call","external":true},{"path":"node:crypto","kind":"require-call","external":true},{"path":"node:crypto","kind":"require-call","external":true},{"path":"node:fs","kind":"require-call","external":true},{"path":"node:os","kind":"require-call","external":true},{"path":"node:path","kind":"require-call","external":true},{"path":"node:crypto","kind":"require-call","external":true},{"path":"node:fs/promises","kind":"require-call","external":true},{"path":"node:path","kind":"require-call","external":true},{"path":"node:fs","kind":"require-call","external":true},{"path":"node:os","kind":"require-call","external":true},{"path":"node:path","kind":"require-call","external":true},{"path":"node:os","kind":"require-call","external":true},{"path":"node:crypto","kind":"require-call","external":true}],"exports":[],"entryPoint":"src/automation/index.ts","inputs":{"src/automation/index.ts":{"bytesInOutput":1294},"src/automation/types.ts":{"bytesInOutput":8},"src/automation/operations.ts":{"bytesInOutput":1656},"src/automation/errors.ts":{"bytesInOutput":129},"src/security/secure-execution-contract.ts":{"bytesInOutput":10454},"src/security/path-policy.ts":{"bytesInOutput":2592},"src/security/windows-process-containment.ts":{"bytesInOutput":47581},"src/security/linux-process-containment.ts":{"bytesInOutput":1926},"src/security/containment-certification.ts":{"bytesInOutput":6147},"src/security/mxc-containment.ts":{"bytesInOutput":6578},"src/security/process-containment.ts":{"bytesInOutput":6526},"src/automation/policy.ts":{"bytesInOutput":7901},"src/automation/evidence.ts":{"bytesInOutput":4454},"src/artifacts/types.ts":{"bytesInOutput":818},"src/artifacts/validation.ts":{"bytesInOutput":13385},"src/artifacts/hash.ts":{"bytesInOutput":130},"src/utils/custom-names.ts":{"bytesInOutput":125},"src/artifacts/repository.ts":{"bytesInOutput":13761},"src/automation/executor.ts":{"bytesInOutput":6092},"src/automation/conformance.ts":{"bytesInOutput":2199},"src/automation/http-adapter.ts":{"bytesInOutput":4320},"src/automation/browser-control-plane-adapter.ts":{"bytesInOutput":9665},"src/automation/host-runtime.ts":{"bytesInOutput":12873},"src/artifacts/file-repository.ts":{"bytesInOutput":6761},"src/control-plane/lock.ts":{"bytesInOutput":1067},"src/version.ts":{"bytesInOutput":16},"src/utils/platform.ts":{"bytesInOutput":95},"src/agents/profiles.ts":{"bytesInOutput":8624},"src/security/capability-lease.ts":{"bytesInOutput":11970},"src/automation/tool-pack.ts":{"bytesInOutput":10038}},"bytes":200679}}}
@@ -1 +1 @@
1
- {"inputs":{"src/automation/types.ts":{"bytes":7223,"imports":[],"format":"esm"},"src/automation/operations.ts":{"bytes":3367,"imports":[],"format":"esm"},"src/automation/errors.ts":{"bytes":866,"imports":[],"format":"esm"},"src/security/path-policy.ts":{"bytes":5541,"imports":[{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true}],"format":"esm"},"src/security/windows-process-containment.ts":{"bytes":51557,"imports":[{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:child_process","kind":"import-statement","external":true},{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:os","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true}],"format":"esm"},"src/security/linux-process-containment.ts":{"bytes":5665,"imports":[{"path":"node:child_process","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true}],"format":"esm"},"src/security/containment-certification.ts":{"bytes":13312,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true}],"format":"esm"},"src/security/environment-policy.ts":{"bytes":1195,"imports":[],"format":"esm"},"src/security/mxc-containment.ts":{"bytes":28272,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:os","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"node:child_process","kind":"import-statement","external":true},{"path":"node:url","kind":"import-statement","external":true},{"path":"src/security/environment-policy.ts","kind":"import-statement","original":"./environment-policy.js"},{"path":"src/security/path-policy.ts","kind":"import-statement","original":"./path-policy.js"}],"format":"esm"},"src/security/process-containment.ts":{"bytes":17360,"imports":[{"path":"src/security/windows-process-containment.ts","kind":"import-statement","original":"./windows-process-containment.js"},{"path":"src/security/linux-process-containment.ts","kind":"import-statement","original":"./linux-process-containment.js"},{"path":"src/security/path-policy.ts","kind":"import-statement","original":"./path-policy.js"},{"path":"src/security/containment-certification.ts","kind":"import-statement","original":"./containment-certification.js"},{"path":"src/security/mxc-containment.ts","kind":"import-statement","original":"./mxc-containment.js"}],"format":"esm"},"src/security/secure-execution-contract.ts":{"bytes":24510,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:os","kind":"import-statement","external":true},{"path":"src/security/path-policy.ts","kind":"import-statement","original":"./path-policy.js"},{"path":"src/security/process-containment.ts","kind":"import-statement","original":"./process-containment.js"}],"format":"esm"},"src/automation/policy.ts":{"bytes":15653,"imports":[{"path":"src/security/secure-execution-contract.ts","kind":"import-statement","original":"../security/secure-execution-contract.js"},{"path":"src/automation/errors.ts","kind":"import-statement","original":"./errors.js"},{"path":"src/automation/operations.ts","kind":"import-statement","original":"./operations.js"},{"path":"src/automation/types.ts","kind":"import-statement","original":"./types.js"}],"format":"esm"},"src/artifacts/types.ts":{"bytes":11224,"imports":[],"format":"esm"},"src/artifacts/hash.ts":{"bytes":1489,"imports":[{"path":"node:crypto","kind":"import-statement","external":true}],"format":"esm"},"src/utils/custom-names.ts":{"bytes":2210,"imports":[],"format":"esm"},"src/artifacts/validation.ts":{"bytes":25271,"imports":[{"path":"src/artifacts/types.ts","kind":"import-statement","original":"./types.js"},{"path":"node:buffer","kind":"import-statement","external":true},{"path":"src/artifacts/hash.ts","kind":"import-statement","original":"./hash.js"},{"path":"src/utils/custom-names.ts","kind":"import-statement","original":"../utils/custom-names.js"},{"path":"src/artifacts/types.ts","kind":"import-statement","original":"./types.js"}],"format":"esm"},"src/artifacts/repository.ts":{"bytes":29289,"imports":[{"path":"src/artifacts/types.ts","kind":"import-statement","original":"./types.js"},{"path":"src/artifacts/validation.ts","kind":"import-statement","original":"./validation.js"}],"format":"esm"},"src/automation/evidence.ts":{"bytes":8618,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"src/artifacts/repository.ts","kind":"import-statement","original":"../artifacts/repository.js"},{"path":"src/artifacts/hash.ts","kind":"import-statement","original":"../artifacts/hash.js"},{"path":"src/artifacts/types.ts","kind":"import-statement","original":"../artifacts/types.js"},{"path":"src/automation/errors.ts","kind":"import-statement","original":"./errors.js"}],"format":"esm"},"src/automation/executor.ts":{"bytes":14249,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"src/automation/errors.ts","kind":"import-statement","original":"./errors.js"},{"path":"src/automation/evidence.ts","kind":"import-statement","original":"./evidence.js"},{"path":"src/automation/operations.ts","kind":"import-statement","original":"./operations.js"},{"path":"src/automation/policy.ts","kind":"import-statement","original":"./policy.js"}],"format":"esm"},"src/automation/conformance.ts":{"bytes":4331,"imports":[{"path":"src/automation/errors.ts","kind":"import-statement","original":"./errors.js"},{"path":"src/automation/policy.ts","kind":"import-statement","original":"./policy.js"},{"path":"src/automation/types.ts","kind":"import-statement","original":"./types.js"}],"format":"esm"},"src/automation/http-adapter.ts":{"bytes":8862,"imports":[{"path":"src/automation/errors.ts","kind":"import-statement","original":"./errors.js"}],"format":"esm"},"src/automation/tool-pack.ts":{"bytes":19206,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"src/automation/operations.ts","kind":"import-statement","original":"./operations.js"}],"format":"esm"},"src/automation/index.ts":{"bytes":282,"imports":[{"path":"src/automation/types.ts","kind":"import-statement","original":"./types.js"},{"path":"src/automation/operations.ts","kind":"import-statement","original":"./operations.js"},{"path":"src/automation/errors.ts","kind":"import-statement","original":"./errors.js"},{"path":"src/automation/policy.ts","kind":"import-statement","original":"./policy.js"},{"path":"src/automation/evidence.ts","kind":"import-statement","original":"./evidence.js"},{"path":"src/automation/executor.ts","kind":"import-statement","original":"./executor.js"},{"path":"src/automation/conformance.ts","kind":"import-statement","original":"./conformance.js"},{"path":"src/automation/http-adapter.ts","kind":"import-statement","original":"./http-adapter.js"},{"path":"src/automation/tool-pack.ts","kind":"import-statement","original":"./tool-pack.js"}],"format":"esm"}},"outputs":{"dist/automation/index.js":{"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:crypto","kind":"import-statement","external":true}],"exports":["XENO_AUTOMATION_OPERATIONS","XENO_AUTOMATION_PROTOCOL_VERSION","XenoAutomationError","XenoGovernedAutomationExecutor","XenoLoopbackAutomationAdapter","assertRequiredXenoAutomationEvidence","assertValidXenoAutomationAdapterManifest","assertValidXenoAutomationRequest","assertXenoAutomationAdapterConformant","assertXenoAutomationAuthority","buildXenoAutomationCapabilityUse","createXenoAutomationConformanceReport","createXenoGovernedAutomationTools","describeXenoAutomationOperation","isXenoAutomationOperation","materializeXenoAutomationEvidence","persistXenoAutomationEvidence","resolveXenoAutomationEvidencePolicy"],"entryPoint":"src/automation/index.ts","inputs":{"src/automation/types.ts":{"bytesInOutput":8},"src/automation/index.ts":{"bytesInOutput":0},"src/automation/operations.ts":{"bytesInOutput":1638},"src/automation/errors.ts":{"bytesInOutput":129},"src/security/secure-execution-contract.ts":{"bytesInOutput":3308},"src/security/windows-process-containment.ts":{"bytesInOutput":47238},"src/security/containment-certification.ts":{"bytesInOutput":442},"src/security/mxc-containment.ts":{"bytesInOutput":709},"src/security/process-containment.ts":{"bytesInOutput":999},"src/automation/policy.ts":{"bytesInOutput":7873},"src/automation/evidence.ts":{"bytesInOutput":4442},"src/artifacts/types.ts":{"bytesInOutput":818},"src/artifacts/hash.ts":{"bytesInOutput":126},"src/artifacts/validation.ts":{"bytesInOutput":146},"src/artifacts/repository.ts":{"bytesInOutput":137},"src/automation/executor.ts":{"bytesInOutput":6074},"src/automation/conformance.ts":{"bytesInOutput":2191},"src/automation/http-adapter.ts":{"bytesInOutput":4316},"src/automation/tool-pack.ts":{"bytesInOutput":10028}},"bytes":91312}}}
1
+ {"inputs":{"src/automation/types.ts":{"bytes":7223,"imports":[],"format":"esm"},"src/automation/operations.ts":{"bytes":3367,"imports":[],"format":"esm"},"src/automation/errors.ts":{"bytes":866,"imports":[],"format":"esm"},"src/security/path-policy.ts":{"bytes":5541,"imports":[{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true}],"format":"esm"},"src/security/windows-process-containment.ts":{"bytes":51557,"imports":[{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:child_process","kind":"import-statement","external":true},{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:os","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true}],"format":"esm"},"src/security/linux-process-containment.ts":{"bytes":5665,"imports":[{"path":"node:child_process","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true}],"format":"esm"},"src/security/containment-certification.ts":{"bytes":13312,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true}],"format":"esm"},"src/security/environment-policy.ts":{"bytes":1195,"imports":[],"format":"esm"},"src/security/mxc-containment.ts":{"bytes":28272,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:os","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"node:child_process","kind":"import-statement","external":true},{"path":"node:url","kind":"import-statement","external":true},{"path":"src/security/environment-policy.ts","kind":"import-statement","original":"./environment-policy.js"},{"path":"src/security/path-policy.ts","kind":"import-statement","original":"./path-policy.js"}],"format":"esm"},"src/security/process-containment.ts":{"bytes":17360,"imports":[{"path":"src/security/windows-process-containment.ts","kind":"import-statement","original":"./windows-process-containment.js"},{"path":"src/security/linux-process-containment.ts","kind":"import-statement","original":"./linux-process-containment.js"},{"path":"src/security/path-policy.ts","kind":"import-statement","original":"./path-policy.js"},{"path":"src/security/containment-certification.ts","kind":"import-statement","original":"./containment-certification.js"},{"path":"src/security/mxc-containment.ts","kind":"import-statement","original":"./mxc-containment.js"}],"format":"esm"},"src/security/secure-execution-contract.ts":{"bytes":24510,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:os","kind":"import-statement","external":true},{"path":"src/security/path-policy.ts","kind":"import-statement","original":"./path-policy.js"},{"path":"src/security/process-containment.ts","kind":"import-statement","original":"./process-containment.js"}],"format":"esm"},"src/automation/policy.ts":{"bytes":15653,"imports":[{"path":"src/security/secure-execution-contract.ts","kind":"import-statement","original":"../security/secure-execution-contract.js"},{"path":"src/automation/errors.ts","kind":"import-statement","original":"./errors.js"},{"path":"src/automation/operations.ts","kind":"import-statement","original":"./operations.js"},{"path":"src/automation/types.ts","kind":"import-statement","original":"./types.js"}],"format":"esm"},"src/artifacts/types.ts":{"bytes":11224,"imports":[],"format":"esm"},"src/artifacts/hash.ts":{"bytes":1489,"imports":[{"path":"node:crypto","kind":"import-statement","external":true}],"format":"esm"},"src/utils/custom-names.ts":{"bytes":2210,"imports":[],"format":"esm"},"src/artifacts/validation.ts":{"bytes":25271,"imports":[{"path":"src/artifacts/types.ts","kind":"import-statement","original":"./types.js"},{"path":"node:buffer","kind":"import-statement","external":true},{"path":"src/artifacts/hash.ts","kind":"import-statement","original":"./hash.js"},{"path":"src/utils/custom-names.ts","kind":"import-statement","original":"../utils/custom-names.js"},{"path":"src/artifacts/types.ts","kind":"import-statement","original":"./types.js"}],"format":"esm"},"src/artifacts/repository.ts":{"bytes":29289,"imports":[{"path":"src/artifacts/types.ts","kind":"import-statement","original":"./types.js"},{"path":"src/artifacts/validation.ts","kind":"import-statement","original":"./validation.js"}],"format":"esm"},"src/automation/evidence.ts":{"bytes":8618,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"src/artifacts/repository.ts","kind":"import-statement","original":"../artifacts/repository.js"},{"path":"src/artifacts/hash.ts","kind":"import-statement","original":"../artifacts/hash.js"},{"path":"src/artifacts/types.ts","kind":"import-statement","original":"../artifacts/types.js"},{"path":"src/automation/errors.ts","kind":"import-statement","original":"./errors.js"}],"format":"esm"},"src/automation/executor.ts":{"bytes":14249,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"src/automation/errors.ts","kind":"import-statement","original":"./errors.js"},{"path":"src/automation/evidence.ts","kind":"import-statement","original":"./evidence.js"},{"path":"src/automation/operations.ts","kind":"import-statement","original":"./operations.js"},{"path":"src/automation/policy.ts","kind":"import-statement","original":"./policy.js"}],"format":"esm"},"src/automation/conformance.ts":{"bytes":4331,"imports":[{"path":"src/automation/errors.ts","kind":"import-statement","original":"./errors.js"},{"path":"src/automation/policy.ts","kind":"import-statement","original":"./policy.js"},{"path":"src/automation/types.ts","kind":"import-statement","original":"./types.js"}],"format":"esm"},"src/automation/http-adapter.ts":{"bytes":8862,"imports":[{"path":"src/automation/errors.ts","kind":"import-statement","original":"./errors.js"}],"format":"esm"},"src/automation/browser-control-plane-adapter.ts":{"bytes":17420,"imports":[{"path":"node:crypto","kind":"import-statement","external":true}],"format":"esm"},"src/control-plane/lock.ts":{"bytes":2496,"imports":[{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:os","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true}],"format":"esm"},"src/version.ts":{"bytes":37,"imports":[],"format":"esm"},"src/artifacts/file-repository.ts":{"bytes":16334,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:fs/promises","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"src/control-plane/lock.ts","kind":"import-statement","original":"../control-plane/lock.js"},{"path":"src/version.ts","kind":"import-statement","original":"../version.js"},{"path":"src/artifacts/hash.ts","kind":"import-statement","original":"./hash.js"},{"path":"src/artifacts/repository.ts","kind":"import-statement","original":"./repository.js"},{"path":"src/artifacts/types.ts","kind":"import-statement","original":"./types.js"}],"format":"esm"},"src/utils/yaml.ts":{"bytes":5506,"imports":[],"format":"esm"},"src/utils/platform.ts":{"bytes":5600,"imports":[{"path":"node:os","kind":"import-statement","external":true},{"path":"node:child_process","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true}],"format":"esm"},"src/agents/definitions.ts":{"bytes":20961,"imports":[{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"src/utils/yaml.ts","kind":"import-statement","original":"../utils/yaml.js"},{"path":"src/utils/platform.ts","kind":"import-statement","original":"../utils/platform.js"}],"format":"esm"},"src/agents/profiles.ts":{"bytes":33625,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"src/agents/definitions.ts","kind":"import-statement","original":"./definitions.js"}],"format":"esm"},"src/security/capability-lease.ts":{"bytes":25286,"imports":[{"path":"src/agents/profiles.ts","kind":"import-statement","original":"../agents/profiles.js"},{"path":"src/utils/custom-names.ts","kind":"import-statement","original":"../utils/custom-names.js"}],"format":"esm"},"src/automation/tool-pack.ts":{"bytes":19206,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"src/automation/operations.ts","kind":"import-statement","original":"./operations.js"}],"format":"esm"},"src/automation/host-runtime.ts":{"bytes":30630,"imports":[{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:os","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"src/artifacts/file-repository.ts","kind":"import-statement","original":"../artifacts/file-repository.js"},{"path":"src/security/capability-lease.ts","kind":"import-statement","original":"../security/capability-lease.js"},{"path":"src/security/secure-execution-contract.ts","kind":"import-statement","original":"../security/secure-execution-contract.js"},{"path":"src/automation/types.ts","kind":"import-statement","original":"./types.js"},{"path":"src/automation/executor.ts","kind":"import-statement","original":"./executor.js"},{"path":"src/automation/operations.ts","kind":"import-statement","original":"./operations.js"},{"path":"src/automation/tool-pack.ts","kind":"import-statement","original":"./tool-pack.js"},{"path":"src/automation/browser-control-plane-adapter.ts","kind":"import-statement","original":"./browser-control-plane-adapter.js"}],"format":"esm"},"src/automation/index.ts":{"bytes":369,"imports":[{"path":"src/automation/types.ts","kind":"import-statement","original":"./types.js"},{"path":"src/automation/operations.ts","kind":"import-statement","original":"./operations.js"},{"path":"src/automation/errors.ts","kind":"import-statement","original":"./errors.js"},{"path":"src/automation/policy.ts","kind":"import-statement","original":"./policy.js"},{"path":"src/automation/evidence.ts","kind":"import-statement","original":"./evidence.js"},{"path":"src/automation/executor.ts","kind":"import-statement","original":"./executor.js"},{"path":"src/automation/conformance.ts","kind":"import-statement","original":"./conformance.js"},{"path":"src/automation/http-adapter.ts","kind":"import-statement","original":"./http-adapter.js"},{"path":"src/automation/browser-control-plane-adapter.ts","kind":"import-statement","original":"./browser-control-plane-adapter.js"},{"path":"src/automation/host-runtime.ts","kind":"import-statement","original":"./host-runtime.js"},{"path":"src/automation/tool-pack.ts","kind":"import-statement","original":"./tool-pack.js"}],"format":"esm"}},"outputs":{"dist/automation/index.js":{"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:os","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"node:child_process","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:os","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"node:child_process","kind":"import-statement","external":true},{"path":"node:url","kind":"import-statement","external":true},{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:buffer","kind":"import-statement","external":true},{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:os","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:fs/promises","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:os","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"node:os","kind":"import-statement","external":true},{"path":"node:crypto","kind":"import-statement","external":true}],"exports":["CliGovernedAutomationRuntime","XENO_AUTOMATION_OPERATIONS","XENO_AUTOMATION_PROTOCOL_VERSION","XENO_BROWSER_CONTROL_PLANE_OPERATIONS","XenoAutomationError","XenoBrowserControlPlaneAdapter","XenoGovernedAutomationExecutor","XenoHostGovernedAutomationRuntime","XenoLoopbackAutomationAdapter","assertRequiredXenoAutomationEvidence","assertValidXenoAutomationAdapterManifest","assertValidXenoAutomationRequest","assertXenoAutomationAdapterConformant","assertXenoAutomationAuthority","buildXenoAutomationCapabilityUse","createCliAutomationAuditSink","createCliGovernedAutomationRuntime","createXenoAutomationConformanceReport","createXenoGovernedAutomationTools","createXenoHostAutomationAuditSink","createXenoHostGovernedAutomationRuntime","describeXenoAutomationOperation","inspectCliAutomationStatus","inspectXenoHostAutomationStatus","isXenoAutomationOperation","materializeXenoAutomationEvidence","persistXenoAutomationEvidence","readCliAutomationEnvironment","readXenoHostAutomationEnvironment","renderCliAutomationStatus","renderXenoHostAutomationStatus","resolveXenoAutomationEvidencePolicy"],"entryPoint":"src/automation/index.ts","inputs":{"src/automation/types.ts":{"bytesInOutput":8},"src/automation/index.ts":{"bytesInOutput":0},"src/automation/operations.ts":{"bytesInOutput":1656},"src/automation/errors.ts":{"bytesInOutput":129},"src/security/secure-execution-contract.ts":{"bytesInOutput":10446},"src/security/path-policy.ts":{"bytesInOutput":2570},"src/security/windows-process-containment.ts":{"bytesInOutput":47621},"src/security/linux-process-containment.ts":{"bytesInOutput":1948},"src/security/containment-certification.ts":{"bytesInOutput":6156},"src/security/mxc-containment.ts":{"bytesInOutput":6366},"src/security/process-containment.ts":{"bytesInOutput":6520},"src/automation/policy.ts":{"bytesInOutput":7893},"src/automation/evidence.ts":{"bytesInOutput":4449},"src/artifacts/types.ts":{"bytesInOutput":818},"src/artifacts/validation.ts":{"bytesInOutput":13370},"src/artifacts/hash.ts":{"bytesInOutput":126},"src/utils/custom-names.ts":{"bytesInOutput":125},"src/artifacts/repository.ts":{"bytesInOutput":13753},"src/automation/executor.ts":{"bytesInOutput":6090},"src/automation/conformance.ts":{"bytesInOutput":2199},"src/automation/http-adapter.ts":{"bytesInOutput":4320},"src/automation/browser-control-plane-adapter.ts":{"bytesInOutput":9666},"src/automation/host-runtime.ts":{"bytesInOutput":12795},"src/artifacts/file-repository.ts":{"bytesInOutput":6733},"src/control-plane/lock.ts":{"bytesInOutput":1054},"src/version.ts":{"bytesInOutput":16},"src/utils/platform.ts":{"bytesInOutput":96},"src/agents/profiles.ts":{"bytesInOutput":8624},"src/security/capability-lease.ts":{"bytesInOutput":11954},"src/automation/tool-pack.ts":{"bytesInOutput":10038}},"bytes":198769}}}
@@ -1,4 +1,4 @@
1
- "use strict";var L=Object.defineProperty;var Re=Object.getOwnPropertyDescriptor;var we=Object.getOwnPropertyNames;var ve=Object.prototype.hasOwnProperty;var ke=(n,e)=>{for(var t in e)L(n,t,{get:e[t],enumerable:!0})},Ae=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of we(e))!ve.call(n,o)&&o!==t&&L(n,o,{get:()=>e[o],enumerable:!(r=Re(e,o))||r.enumerable});return n};var ye=n=>Ae(L({},"__esModule",{value:!0}),n);var Je={};ke(Je,{AGENT_DAEMON_PROTOCOL_VERSION:()=>S,AgentDaemonClient:()=>G,AgentDaemonServer:()=>B,AgentEventStore:()=>P,AgentRunController:()=>z,AgentRunStore:()=>T,MonitorManager:()=>K,MonitorStopTool:()=>ee,MonitorTool:()=>Y,OtelExporter:()=>re,UsageAccumulator:()=>N,UsageLedger:()=>te,WorkflowPlanner:()=>E,WorkflowRuntime:()=>Z,WorkflowStore:()=>M,acquireControlPlaneLock:()=>I,createAgentRunId:()=>pe,getAgentRunDir:()=>Le,getAgentRunStoreDir:()=>$e});module.exports=ye(Je);var le=require("node:crypto"),d=require("node:fs"),u=require("node:path");var x="0.9.21";var h=require("node:fs"),F=require("node:os"),se=require("node:path");function Se(){return new Date().toISOString()}function Ee(){return new Date(Date.now()-Math.floor(process.uptime()*1e3)).toISOString()}function ie(n){try{return JSON.parse((0,h.readFileSync)(n,"utf8"))}catch{return null}}function De(n){if(!n||n<=0)return!1;try{return process.kill(n,0),!0}catch{return!1}}function xe(n){return n.hostname!==(0,F.hostname)()?!0:De(n.pid)}function oe(n,e){(0,h.mkdirSync)((0,se.dirname)(n),{recursive:!0}),(0,h.writeFileSync)(n,JSON.stringify(e,null,2)+`
1
+ "use strict";var L=Object.defineProperty;var Re=Object.getOwnPropertyDescriptor;var we=Object.getOwnPropertyNames;var ve=Object.prototype.hasOwnProperty;var ke=(n,e)=>{for(var t in e)L(n,t,{get:e[t],enumerable:!0})},Ae=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of we(e))!ve.call(n,o)&&o!==t&&L(n,o,{get:()=>e[o],enumerable:!(r=Re(e,o))||r.enumerable});return n};var ye=n=>Ae(L({},"__esModule",{value:!0}),n);var Je={};ke(Je,{AGENT_DAEMON_PROTOCOL_VERSION:()=>S,AgentDaemonClient:()=>G,AgentDaemonServer:()=>B,AgentEventStore:()=>P,AgentRunController:()=>z,AgentRunStore:()=>T,MonitorManager:()=>K,MonitorStopTool:()=>ee,MonitorTool:()=>Y,OtelExporter:()=>re,UsageAccumulator:()=>N,UsageLedger:()=>te,WorkflowPlanner:()=>E,WorkflowRuntime:()=>Z,WorkflowStore:()=>M,acquireControlPlaneLock:()=>I,createAgentRunId:()=>pe,getAgentRunDir:()=>Le,getAgentRunStoreDir:()=>$e});module.exports=ye(Je);var le=require("node:crypto"),d=require("node:fs"),u=require("node:path");var x="0.9.24";var h=require("node:fs"),F=require("node:os"),se=require("node:path");function Se(){return new Date().toISOString()}function Ee(){return new Date(Date.now()-Math.floor(process.uptime()*1e3)).toISOString()}function ie(n){try{return JSON.parse((0,h.readFileSync)(n,"utf8"))}catch{return null}}function De(n){if(!n||n<=0)return!1;try{return process.kill(n,0),!0}catch{return!1}}function xe(n){return n.hostname!==(0,F.hostname)()?!0:De(n.pid)}function oe(n,e){(0,h.mkdirSync)((0,se.dirname)(n),{recursive:!0}),(0,h.writeFileSync)(n,JSON.stringify(e,null,2)+`
2
2
  `,{encoding:"utf8",flag:"wx"})}function Ie(n,e){let t=ie(n);t?.pid!==e.pid||t.hostname!==e.hostname||(0,h.rmSync)(n,{force:!0})}function I(n,e,t){let r=Se(),o={schemaVersion:1,name:e,pid:process.pid,hostname:(0,F.hostname)(),processStartedAt:Ee(),version:t,acquiredAt:r,updatedAt:r};try{oe(n,o)}catch(i){if(i.code!=="EEXIST")throw i;let a=ie(n);if(a&&xe(a))throw new Error(`${e} is already locked by PID ${a.pid} on ${a.hostname}.`);(0,h.rmSync)(n,{force:!0}),oe(n,o)}return{record:o,release:()=>{Ie(n,o)}}}var de=require("node:crypto"),R=require("node:fs"),A=require("node:path");function ae(n){return(0,A.basename)(n).replace(/[^A-Za-z0-9_.-]/g,"_").slice(0,96)}function ue(n){return(0,R.existsSync)(n)?(0,R.readFileSync)(n,"utf8").split(/\r?\n/).map(e=>e.trim()).filter(Boolean).map(e=>{try{return JSON.parse(e)}catch{return null}}).filter(e=>e!==null):[]}var P=class{constructor(e){this.runsDir=e;(0,R.mkdirSync)(this.runsDir,{recursive:!0})}runsDir;pathFor(e){return(0,A.join)(this.runsDir,ae(e),"events.jsonl")}append(e,t,r={},o=new Date().toISOString()){let i=this.pathFor(e);(0,R.mkdirSync)((0,A.dirname)(i),{recursive:!0});let s=I(`${i}.lock`,`events:${ae(e)}`,x);try{let a=ue(i).reduce((W,m,b)=>Math.max(W,m.sequence??b),-1)+1,f={schemaVersion:1,eventId:`event_${(0,de.randomUUID)()}`,sequence:a,runId:e,type:t,timestamp:o,payload:r};return(0,R.appendFileSync)(i,`${JSON.stringify(f)}
3
3
  `,"utf8"),f}finally{s.release()}}read(e){return ue(this.pathFor(e))}tail(e,t=100){let r=Math.max(0,Math.min(1e4,Math.trunc(t)));return r===0?[]:this.read(e).slice(-r)}};var k=require("node:os");var j=require("node:path"),Ze=(0,k.platform)();var Ke=(0,k.release)(),Ye=(0,k.homedir)();function y(){let n=process.env.XENO_AGENT_HOME?.trim();return n?(0,j.resolve)(n):(0,j.resolve)((0,k.homedir)(),".xeno-agent")}var Pe=1,Te=(0,u.join)(y(),"daemon"),H=(0,u.join)(Te,"runs");function p(){return new Date().toISOString()}function be(n=new Date){return n.toISOString().replace(/[^0-9]/g,"").slice(0,14)}function J(n){return n.replace(/[^A-Za-z0-9_.-]/g,"_").slice(0,80)}function q(n){return(0,u.resolve)(n)}function C(n){return q(n).toLowerCase()}function ce(n,e){let t=C(n),r=C(e);return t===r||t.startsWith(`${r}\\`)||t.startsWith(`${r}/`)}function Oe(n,e){return!!(C(n.cwd)===C(e)||n.git?.root&&ce(e,n.git.root)||n.git?.worktree&&ce(e,n.git.worktree))}function Ce(n){return J(Buffer.from(q(n)).toString("base64url"))}function _e(){return{input:0,output:0,total:0}}function O(n){try{return JSON.parse((0,d.readFileSync)(n,"utf8"))}catch{return null}}function Ue(n){return n instanceof Error&&/\balready locked by PID\b/.test(n.message)}function Me(n,e){(0,d.mkdirSync)((0,u.dirname)(n),{recursive:!0});let t=`${n}.${process.pid}.${Date.now()}.tmp`;(0,d.writeFileSync)(t,JSON.stringify(e,null,2)+`
4
4
  `,"utf8"),(0,d.renameSync)(t,n)}function Ne(n){if(!n||n<=0)return!1;try{return process.kill(n,0),!0}catch{return!1}}function Ve(n){return n==="completed"||n==="failed"||n==="cancelled"||n==="interrupted"}function We(n,e){return n.pinned!==e.pinned?n.pinned?-1:1:Date.parse(e.updatedAt)-Date.parse(n.updatedAt)}function $e(){return H}function Le(n){return(0,u.join)(H,n)}function pe(n=new Date){return`run_${be(n)}_${(0,le.randomUUID)().slice(0,8)}`}var T=class{constructor(e=H){this.runsDir=e;(0,d.mkdirSync)(this.runsDir,{recursive:!0}),this.eventStore=new P(this.runsDir)}runsDir;eventStore;create(e){let t=pe(),r=(0,u.join)(this.runsDir,t);(0,d.mkdirSync)(r,{recursive:!0});let o=p(),i=(0,u.join)(r,"events.jsonl"),s={schemaVersion:Pe,runId:t,sessionId:t,rootRunId:t,cwd:q(e.cwd),workspaceId:Ce(e.cwd),prompt:e.prompt,...e.title?{title:e.title}:{},status:"starting",model:e.model,...e.effort?{effort:e.effort}:{},...e.agent?{agent:e.agent}:{},...e.git?{git:e.git}:{},permissionMode:e.permissionMode,...e.cliVersion?{createdByCliVersion:e.cliVersion}:{},createdBySdkVersion:e.sdkVersion??x,createdAt:o,updatedAt:o,lastActivityAt:o,pinned:!!e.pinned,attachedClients:0,...e.cliVersion?{cliVersion:e.cliVersion}:{},...e.sdkVersion?{sdkVersion:e.sdkVersion}:{},stdoutPath:(0,u.join)(r,"stdout.log"),stderrPath:(0,u.join)(r,"stderr.log"),eventsPath:i,usage:_e(),children:[],tags:[]};return(0,d.writeFileSync)(s.stdoutPath,"","utf8"),(0,d.writeFileSync)(s.stderrPath,"","utf8"),(0,d.writeFileSync)(s.eventsPath,"","utf8"),this.write(s),this.appendEvent(t,"run_created",{cwd:s.cwd,model:s.model,...s.agent?{agent:s.agent}:{},...s.git?{git:s.git}:{},permissionMode:s.permissionMode,pinned:s.pinned}),s}get(e){let t=O(this.recordPath(e));return t?this.refreshRecordStatus(t):null}list(e={}){if(!(0,d.existsSync)(this.runsDir))return[];let t=(0,d.readdirSync)(this.runsDir,{withFileTypes:!0}).filter(r=>r.isDirectory()).map(r=>{try{return this.get(r.name)}catch(o){if(Ue(o))return O(this.recordPath(r.name));throw o}}).filter(r=>r!==null).filter(r=>e.all||!e.cwd||Oe(r,e.cwd)).filter(r=>!e.status||e.status.includes(r.status)).sort(We);return typeof e.limit=="number"&&e.limit>0?t.slice(0,e.limit):t}markSpawned(e,t,r){return this.update(e,o=>({...o,status:"running",workerPid:t,...r?{workerVersion:r}:{},startedAt:o.startedAt??p(),lastActivityAt:p()}))}markStarted(e,t){return this.update(e,r=>({...r,status:"running",workerPid:t.pid,...t.workerVersion?{workerVersion:t.workerVersion}:{},...t.model?{model:t.model}:{},...t.effort?{effort:t.effort}:{},startedAt:r.startedAt??p(),lastActivityAt:p()}))}markCompleted(e,t){return this.update(e,r=>({...r,status:t.status,...t.statusReason?{statusReason:t.statusReason}:{},exitCode:t.exitCode??null,usage:t.usage??r.usage,endedAt:p(),lastActivityAt:p()}))}markCancelled(e,t){return this.update(e,r=>({...r,status:"cancelled",statusReason:t,endedAt:p(),lastActivityAt:p()}))}markPaused(e,t="Paused by user."){let r=this.update(e,o=>({...o,status:"paused",statusReason:t,lastActivityAt:p()}));return r&&this.appendEvent(e,"run_paused",{reason:t}),r}markResumed(e,t="Resumed by user."){let r=this.update(e,o=>{let i={...o,status:"running",statusReason:t,lastActivityAt:p()};return delete i.endedAt,delete i.exitCode,i});return r&&this.appendEvent(e,"run_resumed",{reason:t}),r}setPinned(e,t){let r=this.update(e,o=>({...o,pinned:t,lastActivityAt:p()}));return r&&this.appendEvent(e,t?"run_pinned":"run_unpinned",{pinned:t}),r}appendEvent(e,t,r={}){let o=O(this.recordPath(e)),i=this.eventStore.append(e,t,r);o&&this.update(e,s=>({...s,lastActivityAt:i.timestamp}))}readEvents(e){return this.get(e)?this.eventStore.read(e):[]}delete(e){(0,d.rmSync)((0,u.join)(this.runsDir,e),{recursive:!0,force:!0})}refreshRecordStatus(e){if(Ve(e.status))return e;if(e.workerPid&&!Ne(e.workerPid)){let t={...e,status:"failed",statusReason:"Worker process is no longer running and did not record a terminal status.",endedAt:e.endedAt??p(),updatedAt:p()};return this.write(t),t}return e}update(e,t){let r=O(this.recordPath(e));if(!r)return null;let o=t(r);return o.updatedAt=p(),this.write(o),o}write(e){let t=I((0,u.join)(this.runDir(e.runId),"run.lock"),`run:${e.runId}`,x);try{Me(this.recordPath(e.runId),e)}finally{t.release()}}recordPath(e){return(0,u.join)(this.runsDir,J((0,u.basename)(e)),"run.json")}runDir(e){return(0,u.join)(this.runsDir,J((0,u.basename)(e)))}};function ge(n){return n==="completed"||n==="failed"||n==="cancelled"||n==="interrupted"}var z=class{constructor(e={}){this.options=e;this.store=e.store??new T}options;store;create(e){return this.store.create(e)}async start(e){let t=this.create(e);if(!this.options.spawn)return t;try{let r=await this.options.spawn(t),o=this.store.markSpawned(t.runId,r.pid,r.workerVersion);if(!o)throw new Error(`Run disappeared during spawn: ${t.runId}`);return this.store.appendEvent(t.runId,"run_started",{pid:r.pid}),o}catch(r){let o=r instanceof Error?r.message:String(r);throw this.store.markCompleted(t.runId,{status:"failed",statusReason:o,exitCode:null}),this.store.appendEvent(t.runId,"run_start_failed",{reason:o}),r}}get(e){return this.store.get(e)}list(e={}){return this.store.list(e)}events(e,t){let r=this.store.readEvents(e);return t===void 0?r:r.slice(-Math.max(0,Math.trunc(t)))}async stop(e,t="Stopped by user."){let r=this.store.get(e);if(!r||ge(r.status))return r;await this.options.stop?.(r,t);let o=this.store.markCancelled(e,t);return o&&this.store.appendEvent(e,"run_cancelled",{reason:t}),o}async pause(e,t="Paused by user."){let r=this.store.get(e);return!r||ge(r.status)||r.status==="paused"?r:(await this.options.pause?.(r,t),this.store.markPaused(e,t))}async resume(e,t="Resumed by user."){let r=this.store.get(e);return!r||r.status!=="paused"?r:(await this.options.resume?.(r,t),this.store.markResumed(e,t))}complete(e,t,r={}){let o=this.store.markCompleted(e,{status:t,...r.reason?{statusReason:r.reason}:{},...r.exitCode!==void 0?{exitCode:r.exitCode}:{},...r.usage?{usage:r.usage}:{}});return o&&this.store.appendEvent(e,`run_${t}`,{...r.reason?{reason:r.reason}:{}}),o}};var _=require("node:crypto"),S=1;function Fe(n,e){if(!n)return!1;let t=Buffer.from(n),r=Buffer.from(e);return t.length===r.length&&(0,_.timingSafeEqual)(t,r)}var B=class{constructor(e={}){this.options=e}options;handlers=new Map;register(e,t){let r=e.trim();if(!r)throw new Error("Daemon method name cannot be empty.");if(this.handlers.has(r))throw new Error(`Daemon method already registered: ${r}`);return this.handlers.set(r,t),this}registerController(e){return this.register("runs.start",t=>e.start(t)).register("runs.get",t=>e.get(t.runId)).register("runs.list",t=>e.list(t??{})).register("runs.events",t=>{let r=t;return e.events(r.runId,r.limit)}).register("runs.stop",t=>{let r=t;return e.stop(r.runId,r.reason)}).register("runs.pause",t=>{let r=t;return e.pause(r.runId,r.reason)}).register("runs.resume",t=>{let r=t;return e.resume(r.runId,r.reason)})}async handle(e){if(e.protocolVersion!==S)return this.error(e.id,"PROTOCOL_MISMATCH",`Unsupported protocol version: ${e.protocolVersion}`);if(this.options.authToken&&!Fe(e.authToken,this.options.authToken))return this.error(e.id,"UNAUTHORIZED","Daemon authentication failed.");let t=this.handlers.get(e.method);if(!t)return this.error(e.id,"METHOD_NOT_FOUND",`Unknown daemon method: ${e.method}`);try{return{protocolVersion:S,id:e.id,result:await t(e.params,e)}}catch(r){return this.error(e.id,"INTERNAL_ERROR",r instanceof Error?r.message:String(r))}}error(e,t,r){return{protocolVersion:S,id:e,error:{code:t,message:r}}}},G=class{constructor(e,t={}){this.transport=e;this.options=t}transport;options;async request(e,t){let r={protocolVersion:S,id:`request_${(0,_.randomUUID)()}`,method:e,params:t,...this.options.authToken?{authToken:this.options.authToken}:{}},o=await this.transport(r);if(o.protocolVersion!==S||o.id!==r.id)throw new Error("Invalid daemon response identity.");if("error"in o){let i=new Error(o.error.message);throw i.code=o.error.code,i}return o.result}};var X=require("node:crypto"),c=require("node:fs"),g=require("node:path");function U(n){return(0,g.basename)(n).replace(/[^A-Za-z0-9_.-]/g,"_").slice(0,96)}function Q(n){try{return JSON.parse((0,c.readFileSync)(n,"utf8"))}catch{return null}}function me(n,e){(0,c.mkdirSync)((0,g.dirname)(n),{recursive:!0});let t=`${n}.${process.pid}.${Date.now()}.tmp`;(0,c.writeFileSync)(t,`${JSON.stringify(e,null,2)}
@@ -1,4 +1,4 @@
1
- import{randomUUID as Pe}from"node:crypto";import{existsSync as Te,mkdirSync as O,readFileSync as be,readdirSync as Oe,renameSync as Ce,rmSync as _e,writeFileSync as E}from"node:fs";import{basename as G,dirname as Ue,join as l,resolve as Me}from"node:path";var R="0.9.21";import{mkdirSync as ce,readFileSync as le,rmSync as L,writeFileSync as pe}from"node:fs";import{hostname as F}from"node:os";import{dirname as ge}from"node:path";function me(){return new Date().toISOString()}function fe(){return new Date(Date.now()-Math.floor(process.uptime()*1e3)).toISOString()}function j(n){try{return JSON.parse(le(n,"utf8"))}catch{return null}}function he(n){if(!n||n<=0)return!1;try{return process.kill(n,0),!0}catch{return!1}}function Re(n){return n.hostname!==F()?!0:he(n.pid)}function $(n,e){ce(ge(n),{recursive:!0}),pe(n,JSON.stringify(e,null,2)+`
1
+ import{randomUUID as Pe}from"node:crypto";import{existsSync as Te,mkdirSync as O,readFileSync as be,readdirSync as Oe,renameSync as Ce,rmSync as _e,writeFileSync as E}from"node:fs";import{basename as G,dirname as Ue,join as l,resolve as Me}from"node:path";var R="0.9.24";import{mkdirSync as ce,readFileSync as le,rmSync as L,writeFileSync as pe}from"node:fs";import{hostname as F}from"node:os";import{dirname as ge}from"node:path";function me(){return new Date().toISOString()}function fe(){return new Date(Date.now()-Math.floor(process.uptime()*1e3)).toISOString()}function j(n){try{return JSON.parse(le(n,"utf8"))}catch{return null}}function he(n){if(!n||n<=0)return!1;try{return process.kill(n,0),!0}catch{return!1}}function Re(n){return n.hostname!==F()?!0:he(n.pid)}function $(n,e){ce(ge(n),{recursive:!0}),pe(n,JSON.stringify(e,null,2)+`
2
2
  `,{encoding:"utf8",flag:"wx"})}function we(n,e){let t=j(n);t?.pid!==e.pid||t.hostname!==e.hostname||L(n,{force:!0})}function A(n,e,t){let r=me(),o={schemaVersion:1,name:e,pid:process.pid,hostname:F(),processStartedAt:fe(),version:t,acquiredAt:r,updatedAt:r};try{$(n,o)}catch(i){if(i.code!=="EEXIST")throw i;let a=j(n);if(a&&Re(a))throw new Error(`${e} is already locked by PID ${a.pid} on ${a.hostname}.`);L(n,{force:!0}),$(n,o)}return{record:o,release:()=>{we(n,o)}}}import{randomUUID as ve}from"node:crypto";import{appendFileSync as ke,existsSync as Ae,mkdirSync as J,readFileSync as ye}from"node:fs";import{basename as Se,dirname as Ee,join as De}from"node:path";function H(n){return Se(n).replace(/[^A-Za-z0-9_.-]/g,"_").slice(0,96)}function q(n){return Ae(n)?ye(n,"utf8").split(/\r?\n/).map(e=>e.trim()).filter(Boolean).map(e=>{try{return JSON.parse(e)}catch{return null}}).filter(e=>e!==null):[]}var y=class{constructor(e){this.runsDir=e;J(this.runsDir,{recursive:!0})}runsDir;pathFor(e){return De(this.runsDir,H(e),"events.jsonl")}append(e,t,r={},o=new Date().toISOString()){let i=this.pathFor(e);J(Ee(i),{recursive:!0});let s=A(`${i}.lock`,`events:${H(e)}`,R);try{let a=q(i).reduce((T,c,k)=>Math.max(T,c.sequence??k),-1)+1,p={schemaVersion:1,eventId:`event_${ve()}`,sequence:a,runId:e,type:t,timestamp:o,payload:r};return ke(i,`${JSON.stringify(p)}
3
3
  `,"utf8"),p}finally{s.release()}}read(e){return q(this.pathFor(e))}tail(e,t=100){let r=Math.max(0,Math.min(1e4,Math.trunc(t)));return r===0?[]:this.read(e).slice(-r)}};import{homedir as B,platform as xe,release as Ie}from"node:os";import{resolve as z}from"node:path";var xt=xe();var It=Ie(),Pt=B();function f(){let n=process.env.XENO_AGENT_HOME?.trim();return n?z(n):z(B(),".xeno-agent")}var Ne=1,Ve=l(f(),"daemon"),_=l(Ve,"runs");function d(){return new Date().toISOString()}function We(n=new Date){return n.toISOString().replace(/[^0-9]/g,"").slice(0,14)}function C(n){return n.replace(/[^A-Za-z0-9_.-]/g,"_").slice(0,80)}function U(n){return Me(n)}function D(n){return U(n).toLowerCase()}function Q(n,e){let t=D(n),r=D(e);return t===r||t.startsWith(`${r}\\`)||t.startsWith(`${r}/`)}function $e(n,e){return!!(D(n.cwd)===D(e)||n.git?.root&&Q(e,n.git.root)||n.git?.worktree&&Q(e,n.git.worktree))}function Le(n){return C(Buffer.from(U(n)).toString("base64url"))}function Fe(){return{input:0,output:0,total:0}}function S(n){try{return JSON.parse(be(n,"utf8"))}catch{return null}}function je(n){return n instanceof Error&&/\balready locked by PID\b/.test(n.message)}function Je(n,e){O(Ue(n),{recursive:!0});let t=`${n}.${process.pid}.${Date.now()}.tmp`;E(t,JSON.stringify(e,null,2)+`
4
4
  `,"utf8"),Ce(t,n)}function He(n){if(!n||n<=0)return!1;try{return process.kill(n,0),!0}catch{return!1}}function qe(n){return n==="completed"||n==="failed"||n==="cancelled"||n==="interrupted"}function ze(n,e){return n.pinned!==e.pinned?n.pinned?-1:1:Date.parse(e.updatedAt)-Date.parse(n.updatedAt)}function Vt(){return _}function Wt(n){return l(_,n)}function Be(n=new Date){return`run_${We(n)}_${Pe().slice(0,8)}`}var x=class{constructor(e=_){this.runsDir=e;O(this.runsDir,{recursive:!0}),this.eventStore=new y(this.runsDir)}runsDir;eventStore;create(e){let t=Be(),r=l(this.runsDir,t);O(r,{recursive:!0});let o=d(),i=l(r,"events.jsonl"),s={schemaVersion:Ne,runId:t,sessionId:t,rootRunId:t,cwd:U(e.cwd),workspaceId:Le(e.cwd),prompt:e.prompt,...e.title?{title:e.title}:{},status:"starting",model:e.model,...e.effort?{effort:e.effort}:{},...e.agent?{agent:e.agent}:{},...e.git?{git:e.git}:{},permissionMode:e.permissionMode,...e.cliVersion?{createdByCliVersion:e.cliVersion}:{},createdBySdkVersion:e.sdkVersion??R,createdAt:o,updatedAt:o,lastActivityAt:o,pinned:!!e.pinned,attachedClients:0,...e.cliVersion?{cliVersion:e.cliVersion}:{},...e.sdkVersion?{sdkVersion:e.sdkVersion}:{},stdoutPath:l(r,"stdout.log"),stderrPath:l(r,"stderr.log"),eventsPath:i,usage:Fe(),children:[],tags:[]};return E(s.stdoutPath,"","utf8"),E(s.stderrPath,"","utf8"),E(s.eventsPath,"","utf8"),this.write(s),this.appendEvent(t,"run_created",{cwd:s.cwd,model:s.model,...s.agent?{agent:s.agent}:{},...s.git?{git:s.git}:{},permissionMode:s.permissionMode,pinned:s.pinned}),s}get(e){let t=S(this.recordPath(e));return t?this.refreshRecordStatus(t):null}list(e={}){if(!Te(this.runsDir))return[];let t=Oe(this.runsDir,{withFileTypes:!0}).filter(r=>r.isDirectory()).map(r=>{try{return this.get(r.name)}catch(o){if(je(o))return S(this.recordPath(r.name));throw o}}).filter(r=>r!==null).filter(r=>e.all||!e.cwd||$e(r,e.cwd)).filter(r=>!e.status||e.status.includes(r.status)).sort(ze);return typeof e.limit=="number"&&e.limit>0?t.slice(0,e.limit):t}markSpawned(e,t,r){return this.update(e,o=>({...o,status:"running",workerPid:t,...r?{workerVersion:r}:{},startedAt:o.startedAt??d(),lastActivityAt:d()}))}markStarted(e,t){return this.update(e,r=>({...r,status:"running",workerPid:t.pid,...t.workerVersion?{workerVersion:t.workerVersion}:{},...t.model?{model:t.model}:{},...t.effort?{effort:t.effort}:{},startedAt:r.startedAt??d(),lastActivityAt:d()}))}markCompleted(e,t){return this.update(e,r=>({...r,status:t.status,...t.statusReason?{statusReason:t.statusReason}:{},exitCode:t.exitCode??null,usage:t.usage??r.usage,endedAt:d(),lastActivityAt:d()}))}markCancelled(e,t){return this.update(e,r=>({...r,status:"cancelled",statusReason:t,endedAt:d(),lastActivityAt:d()}))}markPaused(e,t="Paused by user."){let r=this.update(e,o=>({...o,status:"paused",statusReason:t,lastActivityAt:d()}));return r&&this.appendEvent(e,"run_paused",{reason:t}),r}markResumed(e,t="Resumed by user."){let r=this.update(e,o=>{let i={...o,status:"running",statusReason:t,lastActivityAt:d()};return delete i.endedAt,delete i.exitCode,i});return r&&this.appendEvent(e,"run_resumed",{reason:t}),r}setPinned(e,t){let r=this.update(e,o=>({...o,pinned:t,lastActivityAt:d()}));return r&&this.appendEvent(e,t?"run_pinned":"run_unpinned",{pinned:t}),r}appendEvent(e,t,r={}){let o=S(this.recordPath(e)),i=this.eventStore.append(e,t,r);o&&this.update(e,s=>({...s,lastActivityAt:i.timestamp}))}readEvents(e){return this.get(e)?this.eventStore.read(e):[]}delete(e){_e(l(this.runsDir,e),{recursive:!0,force:!0})}refreshRecordStatus(e){if(qe(e.status))return e;if(e.workerPid&&!He(e.workerPid)){let t={...e,status:"failed",statusReason:"Worker process is no longer running and did not record a terminal status.",endedAt:e.endedAt??d(),updatedAt:d()};return this.write(t),t}return e}update(e,t){let r=S(this.recordPath(e));if(!r)return null;let o=t(r);return o.updatedAt=d(),this.write(o),o}write(e){let t=A(l(this.runDir(e.runId),"run.lock"),`run:${e.runId}`,R);try{Je(this.recordPath(e.runId),e)}finally{t.release()}}recordPath(e){return l(this.runsDir,C(G(e)),"run.json")}runDir(e){return l(this.runsDir,C(G(e)))}};function X(n){return n==="completed"||n==="failed"||n==="cancelled"||n==="interrupted"}var Z=class{constructor(e={}){this.options=e;this.store=e.store??new x}options;store;create(e){return this.store.create(e)}async start(e){let t=this.create(e);if(!this.options.spawn)return t;try{let r=await this.options.spawn(t),o=this.store.markSpawned(t.runId,r.pid,r.workerVersion);if(!o)throw new Error(`Run disappeared during spawn: ${t.runId}`);return this.store.appendEvent(t.runId,"run_started",{pid:r.pid}),o}catch(r){let o=r instanceof Error?r.message:String(r);throw this.store.markCompleted(t.runId,{status:"failed",statusReason:o,exitCode:null}),this.store.appendEvent(t.runId,"run_start_failed",{reason:o}),r}}get(e){return this.store.get(e)}list(e={}){return this.store.list(e)}events(e,t){let r=this.store.readEvents(e);return t===void 0?r:r.slice(-Math.max(0,Math.trunc(t)))}async stop(e,t="Stopped by user."){let r=this.store.get(e);if(!r||X(r.status))return r;await this.options.stop?.(r,t);let o=this.store.markCancelled(e,t);return o&&this.store.appendEvent(e,"run_cancelled",{reason:t}),o}async pause(e,t="Paused by user."){let r=this.store.get(e);return!r||X(r.status)||r.status==="paused"?r:(await this.options.pause?.(r,t),this.store.markPaused(e,t))}async resume(e,t="Resumed by user."){let r=this.store.get(e);return!r||r.status!=="paused"?r:(await this.options.resume?.(r,t),this.store.markResumed(e,t))}complete(e,t,r={}){let o=this.store.markCompleted(e,{status:t,...r.reason?{statusReason:r.reason}:{},...r.exitCode!==void 0?{exitCode:r.exitCode}:{},...r.usage?{usage:r.usage}:{}});return o&&this.store.appendEvent(e,`run_${t}`,{...r.reason?{reason:r.reason}:{}}),o}};import{randomUUID as Ge,timingSafeEqual as Qe}from"node:crypto";var w=1;function Xe(n,e){if(!n)return!1;let t=Buffer.from(n),r=Buffer.from(e);return t.length===r.length&&Qe(t,r)}var K=class{constructor(e={}){this.options=e}options;handlers=new Map;register(e,t){let r=e.trim();if(!r)throw new Error("Daemon method name cannot be empty.");if(this.handlers.has(r))throw new Error(`Daemon method already registered: ${r}`);return this.handlers.set(r,t),this}registerController(e){return this.register("runs.start",t=>e.start(t)).register("runs.get",t=>e.get(t.runId)).register("runs.list",t=>e.list(t??{})).register("runs.events",t=>{let r=t;return e.events(r.runId,r.limit)}).register("runs.stop",t=>{let r=t;return e.stop(r.runId,r.reason)}).register("runs.pause",t=>{let r=t;return e.pause(r.runId,r.reason)}).register("runs.resume",t=>{let r=t;return e.resume(r.runId,r.reason)})}async handle(e){if(e.protocolVersion!==w)return this.error(e.id,"PROTOCOL_MISMATCH",`Unsupported protocol version: ${e.protocolVersion}`);if(this.options.authToken&&!Xe(e.authToken,this.options.authToken))return this.error(e.id,"UNAUTHORIZED","Daemon authentication failed.");let t=this.handlers.get(e.method);if(!t)return this.error(e.id,"METHOD_NOT_FOUND",`Unknown daemon method: ${e.method}`);try{return{protocolVersion:w,id:e.id,result:await t(e.params,e)}}catch(r){return this.error(e.id,"INTERNAL_ERROR",r instanceof Error?r.message:String(r))}}error(e,t,r){return{protocolVersion:w,id:e,error:{code:t,message:r}}}},Y=class{constructor(e,t={}){this.transport=e;this.options=t}transport;options;async request(e,t){let r={protocolVersion:w,id:`request_${Ge()}`,method:e,params:t,...this.options.authToken?{authToken:this.options.authToken}:{}},o=await this.transport(r);if(o.protocolVersion!==w||o.id!==r.id)throw new Error("Invalid daemon response identity.");if("error"in o){let i=new Error(o.error.message);throw i.code=o.error.code,i}return o.result}};import{randomUUID as ee}from"node:crypto";import{appendFileSync as Ze,existsSync as Ke,mkdirSync as P,readFileSync as ne,readdirSync as Ye,renameSync as et,writeFileSync as tt}from"node:fs";import{basename as rt,dirname as oe,join as g}from"node:path";function I(n){return rt(n).replace(/[^A-Za-z0-9_.-]/g,"_").slice(0,96)}function M(n){try{return JSON.parse(ne(n,"utf8"))}catch{return null}}function te(n,e){P(oe(n),{recursive:!0});let t=`${n}.${process.pid}.${Date.now()}.tmp`;tt(t,`${JSON.stringify(e,null,2)}
@@ -106,7 +106,7 @@ interface XenoControlRoomMonitorInput {
106
106
  }
107
107
  interface XenoControlRoomGoalInput {
108
108
  goalId: string;
109
- status: "active" | "complete" | "blocked" | "cancelled" | "expired";
109
+ status: "active" | "complete" | "blocked" | "cancelled" | "failed" | "expired";
110
110
  condition: string;
111
111
  runId?: string;
112
112
  updatedAt: string;
@@ -106,7 +106,7 @@ interface XenoControlRoomMonitorInput {
106
106
  }
107
107
  interface XenoControlRoomGoalInput {
108
108
  goalId: string;
109
- status: "active" | "complete" | "blocked" | "cancelled" | "expired";
109
+ status: "active" | "complete" | "blocked" | "cancelled" | "failed" | "expired";
110
110
  condition: string;
111
111
  runId?: string;
112
112
  updatedAt: string;
@@ -1 +1 @@
1
- {"inputs":{"src/control-room/types.ts":{"bytes":6865,"imports":[],"format":"esm"},"src/control-room/projector.ts":{"bytes":21356,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"src/control-room/types.ts","kind":"import-statement","original":"./types.js"}],"format":"esm"},"src/control-room/index.ts":{"bytes":60,"imports":[{"path":"src/control-room/types.ts","kind":"import-statement","original":"./types.js"},{"path":"src/control-room/projector.ts","kind":"import-statement","original":"./projector.js"}],"format":"esm"}},"outputs":{"dist/control-room/index.cjs":{"imports":[{"path":"node:crypto","kind":"require-call","external":true}],"exports":[],"entryPoint":"src/control-room/index.ts","inputs":{"src/control-room/index.ts":{"bytesInOutput":214},"src/control-room/types.ts":{"bytesInOutput":29},"src/control-room/projector.ts":{"bytesInOutput":11006}},"bytes":11842}}}
1
+ {"inputs":{"src/control-room/types.ts":{"bytes":6876,"imports":[],"format":"esm"},"src/control-room/projector.ts":{"bytes":21356,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"src/control-room/types.ts","kind":"import-statement","original":"./types.js"}],"format":"esm"},"src/control-room/index.ts":{"bytes":60,"imports":[{"path":"src/control-room/types.ts","kind":"import-statement","original":"./types.js"},{"path":"src/control-room/projector.ts","kind":"import-statement","original":"./projector.js"}],"format":"esm"}},"outputs":{"dist/control-room/index.cjs":{"imports":[{"path":"node:crypto","kind":"require-call","external":true}],"exports":[],"entryPoint":"src/control-room/index.ts","inputs":{"src/control-room/index.ts":{"bytesInOutput":214},"src/control-room/types.ts":{"bytesInOutput":29},"src/control-room/projector.ts":{"bytesInOutput":11006}},"bytes":11842}}}
@@ -1 +1 @@
1
- {"inputs":{"src/control-room/types.ts":{"bytes":6865,"imports":[],"format":"esm"},"src/control-room/projector.ts":{"bytes":21356,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"src/control-room/types.ts","kind":"import-statement","original":"./types.js"}],"format":"esm"},"src/control-room/index.ts":{"bytes":60,"imports":[{"path":"src/control-room/types.ts","kind":"import-statement","original":"./types.js"},{"path":"src/control-room/projector.ts","kind":"import-statement","original":"./projector.js"}],"format":"esm"}},"outputs":{"dist/control-room/index.js":{"imports":[{"path":"node:crypto","kind":"import-statement","external":true}],"exports":["XENO_CONTROL_ROOM_SCHEMA_VERSION","XenoControlRoomValidationError","planXenoControlRoomAction","projectXenoControlRoom","validateXenoControlRoomSnapshot"],"entryPoint":"src/control-room/index.ts","inputs":{"src/control-room/types.ts":{"bytesInOutput":29},"src/control-room/index.ts":{"bytesInOutput":0},"src/control-room/projector.ts":{"bytesInOutput":10991}},"bytes":11201}}}
1
+ {"inputs":{"src/control-room/types.ts":{"bytes":6876,"imports":[],"format":"esm"},"src/control-room/projector.ts":{"bytes":21356,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"src/control-room/types.ts","kind":"import-statement","original":"./types.js"}],"format":"esm"},"src/control-room/index.ts":{"bytes":60,"imports":[{"path":"src/control-room/types.ts","kind":"import-statement","original":"./types.js"},{"path":"src/control-room/projector.ts","kind":"import-statement","original":"./projector.js"}],"format":"esm"}},"outputs":{"dist/control-room/index.js":{"imports":[{"path":"node:crypto","kind":"import-statement","external":true}],"exports":["XENO_CONTROL_ROOM_SCHEMA_VERSION","XenoControlRoomValidationError","planXenoControlRoomAction","projectXenoControlRoom","validateXenoControlRoomSnapshot"],"entryPoint":"src/control-room/index.ts","inputs":{"src/control-room/types.ts":{"bytesInOutput":29},"src/control-room/index.ts":{"bytesInOutput":0},"src/control-room/projector.ts":{"bytesInOutput":10991}},"bytes":11201}}}
@@ -0,0 +1,2 @@
1
+ "use strict";var $=Object.create;var A=Object.defineProperty;var V=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var U=Object.getPrototypeOf,j=Object.prototype.hasOwnProperty;var J=(a,t)=>{for(var r in t)A(a,r,{get:t[r],enumerable:!0})},G=(a,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of q(t))!j.call(a,e)&&e!==r&&A(a,e,{get:()=>t[e],enumerable:!(s=V(t,e))||s.enumerable});return a};var L=(a,t,r)=>(r=a!=null?$(U(a)):{},G(t||!a||!a.__esModule?A(r,"default",{value:a,enumerable:!0}):r,a)),B=a=>G(A({},"__esModule",{value:!0}),a);var se={};J(se,{DurableXenoCoordinationStore:()=>b,XENO_COORDINATION_SCHEMA_VERSION:()=>I,XenoCoordinationError:()=>p,XenoExecutionLeaseSession:()=>T,executeXenoCoordinationAction:()=>re});module.exports=B(se);var I=1,p=class extends Error{constructor(r,s,e={}){super(s);this.code=r;this.details=e;this.name="XenoCoordinationError"}code;details};var y=require("node:crypto"),f=L(require("node:fs/promises"),1),x=L(require("node:os"),1),m=L(require("node:path"),1);var v=require("node:os");var N=require("node:path"),de=(0,v.platform)();var ce=(0,v.release)(),le=(0,v.homedir)();function M(){let a=process.env.XENO_AGENT_HOME?.trim();return a?(0,N.resolve)(a):(0,N.resolve)((0,v.homedir)(),".xeno-agent")}var W=3e4,K=3e4,Q=6e4,Y=2e4,S=new Set(["EACCES","EBUSY","EPERM"]),P=[5,10,20,40,80,160,320],z=[5,10,20,40,80,160,320];function u(a,t,r=16384){let s=a.trim();if(!s||s.length>r)throw new p("INVALID",`${t} must be non-empty and no longer than ${r} characters`);return s}function C(a,t){return[...new Set((a??[]).map(r=>u(r,t)))]}function Z(a){if(!a)return;let t={};for(let[r,s]of Object.entries(a))if(s!==void 0){if(!Number.isSafeInteger(s)||s<=0)throw new p("INVALID",`${r} must be a positive safe integer when provided`);t[r]=s}return t}function ee(a){if(a){if(a.kind!=="fixed-interval"&&a.kind!=="dynamic")throw new p("INVALID","schedule.kind must be fixed-interval or dynamic");if(a.kind==="fixed-interval"&&(!Number.isSafeInteger(a.intervalMs)||(a.intervalMs??0)<=0))throw new p("INVALID","Fixed-interval schedules require a positive safe intervalMs");if(a.intervalMs!==void 0&&(!Number.isSafeInteger(a.intervalMs)||a.intervalMs<=0))throw new p("INVALID","schedule.intervalMs must be a positive safe integer when provided");for(let t of["nextRunAt","expiresAt"]){let r=a[t];if(r!==void 0&&!Number.isFinite(Date.parse(r)))throw new p("INVALID",`schedule.${t} must be an ISO timestamp when provided`)}return w(a)}}function w(a){return structuredClone(a)}function X(a){let t=Date.parse(a);return Number.isFinite(t)?t:0}function _(a){if(!Number.isInteger(a)||a<=0)return!1;try{return process.kill(a,0),!0}catch(t){return t.code==="EPERM"}}function te(a){return{summary:"Goal created; work has not started.",completedTaskCount:0,totalTaskCount:0,outstanding:[],decisions:[],updatedAt:a}}function ne(){return{status:"pending",criteria:[],evidence:[]}}function oe(a){return(0,y.createHash)("sha256").update(a).digest("hex")}var b=class{rootDirectory;now;idFactory;ownerLeaseMs;lockTimeoutMs;lockStaleMs;maximumEventsPerSession;constructor(t={}){this.rootDirectory=t.rootDirectory??m.join(M(),"coordination"),this.now=t.now??(()=>new Date().toISOString()),this.idFactory=t.idFactory??(r=>`${r}_${(0,y.randomUUID)()}`),this.ownerLeaseMs=t.ownerLeaseMs??W,this.lockTimeoutMs=t.lockTimeoutMs??K,this.lockStaleMs=t.lockStaleMs??Q,this.maximumEventsPerSession=t.maximumEventsPerSession??Y}async getSessionState(t){let r=u(t,"sessionId",1024);return w(await this.readState(r))}async listSessionStates(){let t=m.join(this.rootDirectory,"sessions"),r;try{r=await f.readdir(t)}catch(e){if(e.code==="ENOENT")return[];throw e}return(await Promise.all(r.filter(e=>e.endsWith(".json")).map(async e=>{try{let n=JSON.parse(await f.readFile(m.join(t,e),"utf8"));return n.schemaVersion!==1||typeof n.sessionId!="string"?void 0:((!Number.isSafeInteger(n.ownershipEpoch)||n.ownershipEpoch<0)&&(n.ownershipEpoch=Math.max(n.owner?.epoch??0,...n.handoffs.map(o=>o.targetLeaseEpoch??o.sourceLeaseEpoch??0))),n)}catch{return}}))).filter(e=>e!==void 0).sort((e,n)=>X(n.updatedAt)-X(e.updatedAt)).map(e=>w(e))}async createGoal(t){let r=u(t.sessionId,"sessionId",1024),s=Z(t.limits);return this.mutate(r,e=>{let n=e.goals.find(c=>["active","paused","waiting","blocked"].includes(c.status));if(n)throw new p("CONFLICT",`Session ${r} already has active goal ${n.id}`);let o=this.now(),i=(t.successCriteria??[]).map(c=>typeof c=="string"?{id:this.idFactory("criterion"),description:u(c,"successCriteria"),required:!0}:{id:c.id?u(c.id,"successCriteria.id",512):this.idFactory("criterion"),description:u(c.description,"successCriteria.description"),required:c.required}),d={schemaVersion:1,id:this.idFactory("goal"),version:1,sessionId:r,objective:u(t.objective,"objective"),...t.why?{why:u(t.why,"why")}:{},successCriteria:i,constraints:C(t.constraints,"constraints"),...s?{limits:s}:{},metadata:w(t.metadata??{}),status:"active",milestones:[],tasks:[],progress:te(o),verification:ne(),steering:[],createdAt:o,updatedAt:o};return e.goals.push(d),this.appendEvent(e,"goal.created",{goalId:d.id,data:{objective:d.objective}}),d})}async getGoal(t,r){let s=await this.getSessionState(t),e=r?s.goals.find(n=>n.id===r):[...s.goals].reverse().find(n=>["active","paused","waiting","blocked"].includes(n.status));return e?w(e):void 0}async updateGoal(t,r,s,e){return this.mutate(t,n=>{let o=this.requireGoal(n,r);if(this.assertVersion(o.id,o.version,s),["completed","cancelled","failed"].includes(o.status))throw new p("CONFLICT",`Goal ${o.id} is terminal (${o.status})`);return e.status==="active"&&o.status==="blocked"?o.status="active":e.status&&(o.status=e.status),e.objective!==void 0&&(o.objective=u(e.objective,"objective")),e.why!==void 0&&(o.why=u(e.why,"why")),e.constraints&&(o.constraints=C(e.constraints,"constraints")),e.successCriteria&&(o.successCriteria=w(e.successCriteria)),e.progress&&(o.progress={...o.progress,...w(e.progress),outstanding:C(e.progress.outstanding??o.progress.outstanding,"progress.outstanding"),decisions:C(e.progress.decisions??o.progress.decisions,"progress.decisions"),updatedAt:this.now()}),e.verification&&(o.verification=w(e.verification)),e.metadata&&(o.metadata=w(e.metadata)),o.version+=1,o.updatedAt=this.now(),this.appendEvent(n,"goal.updated",{goalId:o.id,data:{status:o.status,version:o.version}}),o})}async addMilestone(t,r,s,e){return this.mutateGoal(t,r,s,(n,o)=>{let i={id:this.idFactory("milestone"),title:u(e.title,"milestone.title"),...e.description?{description:u(e.description,"milestone.description")}:{},status:n.milestones.some(d=>d.status==="active")?"pending":"active",taskIds:[],createdAt:o,updatedAt:o};n.milestones.push(i),n.progress.currentMilestoneId??=i.id,n.progress.updatedAt=o})}async addTask(t,r,s,e){return this.mutateGoal(t,r,s,(n,o)=>{let i=n.milestones.find(l=>l.id===e.milestoneId);if(!i)throw new p("NOT_FOUND",`Milestone ${e.milestoneId} was not found`);if(e.parentTaskId&&!n.tasks.some(l=>l.id===e.parentTaskId))throw new p("NOT_FOUND",`Parent task ${e.parentTaskId} was not found`);let d=[...new Set(e.dependsOn??[])];for(let l of d)if(!n.tasks.some(g=>g.id===l))throw new p("NOT_FOUND",`Task dependency ${l} was not found`);let c={id:this.idFactory("task"),milestoneId:i.id,...e.parentTaskId?{parentTaskId:e.parentTaskId}:{},title:u(e.title,"task.title"),...e.description?{description:u(e.description,"task.description")}:{},status:d.length===0?"ready":"pending",...e.assignedAgentId?{assignedAgentId:u(e.assignedAgentId,"task.assignedAgentId",512)}:{},...d.length?{dependsOn:d}:{},createdAt:o,updatedAt:o};n.tasks.push(c),i.taskIds.push(c.id),i.updatedAt=o,n.progress.totalTaskCount=n.tasks.length,n.progress.outstanding=n.tasks.filter(l=>l.status!=="completed").map(l=>l.title),n.progress.updatedAt=o})}async updateTask(t,r,s,e,n){return this.mutateGoal(t,r,e,(o,i)=>{let d=o.tasks.find(l=>l.id===s);if(!d)throw new p("NOT_FOUND",`Task ${s} was not found`);d.status=n.status,n.progress!==void 0&&(d.progress=u(n.progress,"task.progress")),n.resultEventId!==void 0&&(d.resultEventId=u(n.resultEventId,"task.resultEventId",512)),n.assignedAgentId!==void 0&&(d.assignedAgentId=u(n.assignedAgentId,"task.assignedAgentId",512)),d.updatedAt=i,d.status==="completed"&&(d.completedAt=i);let c=o.milestones.find(l=>l.id===d.milestoneId);if(c){let l=o.tasks.filter(g=>g.milestoneId===c.id);l.length>0&&l.every(g=>g.status==="completed")?(c.status="completed",c.completedAt=i):l.some(g=>g.status==="running")?c.status="active":l.some(g=>g.status==="blocked")&&(c.status="blocked"),c.updatedAt=i}for(let l of o.tasks)l.status!=="pending"||!l.dependsOn?.length||l.dependsOn.every(g=>o.tasks.find(O=>O.id===g)?.status==="completed")&&(l.status="ready",l.updatedAt=i);this.recalculateProgress(o,i)})}async steerGoal(t,r,s,e){return this.mutateGoal(t,r,s,(n,o,i)=>{let d=this.idFactory("steer");n.steering.push({id:d,instruction:u(e,"instruction"),createdAt:o}),this.appendEvent(i,"goal.steered",{goalId:r,data:{steeringId:d}})},!1)}async consumeGoalSteering(t,r,s){let e=[];return{goal:await this.mutateGoal(t,r,s,(o,i)=>{e=o.steering.filter(d=>!d.consumedAt).map(({id:d,instruction:c,createdAt:l})=>({id:d,instruction:c,createdAt:l}));for(let d of o.steering)d.consumedAt||(d.consumedAt=i)}),instructions:e}}async completeGoal(t,r,s,e){if(e.status!=="passed")throw new p("VERIFICATION_REQUIRED","Goal completion requires passed verification");return this.mutate(t,n=>{let o=this.requireGoal(n,r);this.assertVersion(o.id,o.version,s);let i=o.successCriteria.filter(l=>l.required),d=i.filter(l=>{let g=e.criteria.find(O=>O.criterionId===l.id);return!g?.satisfied||g.evidence.length===0});if(d.length>0)throw new p("VERIFICATION_REQUIRED","Required success criteria lack passing evidence",{unmetCriteria:d.map(l=>l.id)});if(i.length===0&&e.evidence.length===0)throw new p("VERIFICATION_REQUIRED","Goal completion requires at least one durable evidence reference");let c=this.now();return o.status="completed",o.verification=w(e),o.verification.verifiedAt??=c,o.completedAt=c,o.updatedAt=c,o.version+=1,this.appendEvent(n,"goal.completed",{goalId:r,data:{evidence:o.verification.evidence}}),o})}async cancelGoal(t,r,s,e){return this.mutate(t,n=>{let o=this.requireGoal(n,r);if(this.assertVersion(o.id,o.version,s),["completed","cancelled","failed"].includes(o.status))return o;o.status="cancelled",o.updatedAt=this.now(),o.version+=1,this.appendEvent(n,"goal.cancelled",{goalId:r,data:{reason:u(e,"reason")}});for(let i of n.loops.filter(d=>d.goalId===r&&["running","paused","waiting"].includes(d.status)))i.status="stopped",i.stopReason=`Goal cancelled: ${e}`,i.stoppedAt=this.now(),i.updatedAt=i.stoppedAt,i.version+=1;return o})}async startLoop(t){return this.mutate(t.sessionId,r=>{if(t.kind==="goal-continuation"&&!t.goalId)throw new p("INVALID","Goal-continuation loops require a goalId");if(t.goalId){let i=this.requireGoal(r,t.goalId);if(["completed","cancelled","failed"].includes(i.status))throw new p("CONFLICT",`Cannot start a loop for terminal goal ${i.id}`)}if(t.kind==="scheduled"&&!t.schedule)throw new p("INVALID","Scheduled loops require schedule metadata");if(t.kind!=="scheduled"&&t.schedule)throw new p("INVALID","Only scheduled loops may carry schedule metadata");let s=ee(t.schedule),e=r.loops.find(i=>i.goalId===t.goalId&&i.kind===t.kind&&["running","paused","waiting"].includes(i.status));if(e)throw new p("CONFLICT",`Loop ${e.id} is already active`);let n=this.now(),o={schemaVersion:1,id:this.idFactory("loop"),version:1,sessionId:r.sessionId,...t.goalId?{goalId:t.goalId}:{},kind:t.kind,status:"running",...t.activity?{currentActivity:u(t.activity,"activity")}:{},iterations:[],...s?{schedule:s}:{},createdAt:n,updatedAt:n};return r.loops.push(o),this.appendEvent(r,"loop.started",{loopId:o.id,goalId:o.goalId,data:{kind:o.kind}}),o})}async getLoop(t,r){let s=await this.getSessionState(t),e=r?s.loops.find(n=>n.id===r):[...s.loops].reverse().find(n=>["running","paused","waiting"].includes(n.status));return e?w(e):void 0}async beginLoopIteration(t,r,s,e,n){return this.mutateLoop(t,r,s,(o,i,d)=>{if(o.status!=="running")throw new p("CONFLICT",`Loop ${o.id} is ${o.status}`);if(o.iterations.some(l=>l.status==="running"))throw new p("CONFLICT",`Loop ${o.id} already has a running iteration`);let c=(o.iterations.at(-1)?.number??0)+1;o.currentActivity=u(e,"activity"),o.iterations.push({number:c,startedAt:i,status:"running",activity:o.currentActivity,...n?{taskId:u(n,"taskId",512)}:{}}),this.appendEvent(d,"loop.iteration",{loopId:r,goalId:o.goalId,data:{number:c,phase:"started",activity:o.currentActivity}})},!1)}async finishLoopIteration(t,r,s,e){return this.mutateLoop(t,r,s,(n,o,i)=>{let d=[...n.iterations].reverse().find(c=>c.status==="running");if(!d)throw new p("CONFLICT",`Loop ${n.id} has no running iteration`);d.status=e.status,d.completedAt=o,e.verificationEventId&&(d.verificationEventId=u(e.verificationEventId,"verificationEventId",512)),e.error&&(d.error=u(e.error,"error")),n.status=e.nextStatus??(n.status==="paused"||n.status==="waiting"?n.status:"running"),this.appendEvent(i,"loop.iteration",{loopId:r,goalId:n.goalId,data:{number:d.number,phase:"finished",status:e.status}})},!1)}async setLoopStatus(t,r,s,e,n){return this.mutateLoop(t,r,s,(o,i,d)=>{let c=o.status;if(["stopped","completed","failed"].includes(c))throw new p("CONFLICT",`Loop ${o.id} is terminal (${c})`);let l=[...o.iterations].reverse().find(O=>O.status==="running");if(l&&e==="completed")throw new p("CONFLICT",`Loop ${o.id} cannot complete while iteration ${l.number} is running`);l&&(e==="stopped"||e==="failed")&&(l.status=e==="failed"?"failed":"interrupted",l.completedAt=i,l.error=u(n??e,"reason")),o.status=e,["stopped","completed","failed"].includes(e)&&(o.stoppedAt=i,o.stopReason=u(n??e,"reason"));let g=e==="paused"?"loop.paused":e==="waiting"?"loop.waiting":e==="running"&&(c==="paused"||c==="waiting")?"loop.resumed":e==="completed"?"loop.completed":e==="failed"?"loop.failed":"loop.stopped";this.appendEvent(d,g,{loopId:r,goalId:o.goalId,data:{previous:c,status:e,...n?{reason:n}:{}}})},!1)}async acquireOwnership(t,r,s={}){return this.mutate(t,e=>{let n=this.now();if(e.owner&&!this.ownerExpired(e.owner,n)){if(e.owner.ownerId===r&&s.processId!==void 0&&e.owner.processId===s.processId&&(s.host===void 0||e.owner.host===s.host))return e.owner;throw new p("CONFLICT",`Session ${t} is owned by ${e.owner.ownerId}`,{owner:e.owner})}let o=e.owner&&this.ownerExpired(e.owner,n)?e.owner:void 0;if(o&&o.ownerId!==r)for(let c of e.handoffs.filter(l=>l.status==="claimed"&&l.claimedBy===o.ownerId))c.status="failed",c.failureReason=`Claimed owner ${o.ownerId} lost its execution lease before completing the handoff.`,c.failedAt=n,c.updatedAt=n,c.version+=1,this.appendEvent(e,"handoff.failed",{handoffId:c.id,goalId:c.goalId,loopId:c.loopId,data:{reason:c.failureReason,expiredLeaseId:o.leaseId}});let i=e.ownershipEpoch+1,d=this.newOwner(r,i,s,n);return e.owner=d,e.ownershipEpoch=i,this.appendEvent(e,"ownership.acquired",{ownerId:r,data:{epoch:i,leaseId:d.leaseId}}),d})}async renewOwnership(t,r,s,e=this.ownerLeaseMs){return this.mutate(t,n=>{let o=this.requireOwner(n,r,s);if(this.ownerExpired(o,this.now()))throw new p("LEASE_EXPIRED",`Ownership lease ${s} expired`);return o.heartbeatAt=this.now(),o.expiresAt=new Date(X(o.heartbeatAt)+e).toISOString(),this.appendEvent(n,"ownership.renewed",{ownerId:r,data:{epoch:o.epoch,leaseId:s}}),o})}async releaseOwnership(t,r,s){return this.mutate(t,e=>{let n=this.requireOwner(e,r,s);return e.owner=void 0,this.appendEvent(e,"ownership.released",{ownerId:r,data:{epoch:n.epoch}}),n})}async createHandoff(t){return this.mutate(t.sessionId,r=>{let s=this.requireOwner(r,t.sourceOwnerId,t.sourceLeaseId);if(this.ownerExpired(s,this.now()))throw new p("LEASE_EXPIRED",`Ownership lease ${s.leaseId} expired`);let e=(t.operations??[]).filter(d=>d.status==="running"&&d.sideEffecting&&d.recovery==="retry");if(e.length>0)throw new p("UNSAFE_HANDOFF","Running side-effecting operations cannot be transferred with automatic retry",{operationIds:e.map(d=>d.operationId)});if(t.goalId&&this.requireGoal(r,t.goalId),t.loopId&&!r.loops.some(d=>d.id===t.loopId))throw new p("NOT_FOUND",`Loop ${t.loopId} was not found`);let n=r.handoffs.find(d=>["prepared","available","claimed"].includes(d.status));if(n)throw new p("CONFLICT",`Handoff ${n.id} is already active`);let o=this.now(),i={schemaVersion:1,id:this.idFactory("handoff"),version:1,sessionId:r.sessionId,...t.goalId?{goalId:t.goalId}:{},...t.loopId?{loopId:t.loopId}:{},status:"available",sourceOwnerId:s.ownerId,...t.targetOwnerId?{targetOwnerId:u(t.targetOwnerId,"targetOwnerId",512)}:{},sourceLeaseEpoch:s.epoch,...t.workspace?{workspace:u(t.workspace,"workspace",32768)}:{},...t.branch?{branch:u(t.branch,"branch",1024)}:{},...t.currentMilestoneId?{currentMilestoneId:t.currentMilestoneId}:{},...t.currentTaskId?{currentTaskId:t.currentTaskId}:{},agentIds:[...new Set(t.agentIds??[])],operations:w(t.operations??[]),...t.contextDigest?{contextDigest:u(t.contextDigest,"contextDigest",512)}:{},createdAt:o,updatedAt:o};return r.handoffs.push(i),this.appendEvent(r,"handoff.created",{handoffId:i.id,goalId:i.goalId,loopId:i.loopId,ownerId:s.ownerId,data:{targetOwnerId:i.targetOwnerId}}),i})}async claimHandoff(t){let r;return{handoff:await this.mutate(t.sessionId,e=>{let n=e.handoffs.find(d=>d.id===t.handoffId);if(!n)throw new p("NOT_FOUND",`Handoff ${t.handoffId} was not found`);if(n.status!=="available")throw new p("CONFLICT",`Handoff ${n.id} is ${n.status}`,{claimedBy:n.claimedBy});if(n.targetOwnerId&&n.targetOwnerId!==t.targetOwnerId)throw new p("CONFLICT",`Handoff ${n.id} is reserved for ${n.targetOwnerId}`);let o=e.owner;if(!o||o.ownerId!==n.sourceOwnerId||o.epoch!==n.sourceLeaseEpoch)throw new p("CONFLICT",`Handoff ${n.id} no longer matches the source ownership epoch`);let i=this.now();return r=this.newOwner(t.targetOwnerId,o.epoch+1,{processId:t.processId,host:t.host},i),e.owner=r,e.ownershipEpoch=r.epoch,n.status="claimed",n.claimedBy=t.targetOwnerId,n.targetOwnerId=t.targetOwnerId,n.targetLeaseEpoch=r.epoch,n.claimedAt=i,n.updatedAt=i,n.version+=1,this.appendEvent(e,"handoff.claimed",{handoffId:n.id,goalId:n.goalId,loopId:n.loopId,ownerId:t.targetOwnerId,data:{sourceOwnerId:n.sourceOwnerId,epoch:r.epoch}}),n}),owner:w(r)}}async completeHandoff(t,r,s,e){return this.mutate(t,n=>{this.requireOwner(n,s,e);let o=n.handoffs.find(i=>i.id===r);if(!o)throw new p("NOT_FOUND",`Handoff ${r} was not found`);if(o.status!=="claimed"||o.claimedBy!==s)throw new p("CONFLICT",`Handoff ${o.id} cannot be completed by ${s}`);return o.status="completed",o.completedAt=this.now(),o.updatedAt=o.completedAt,o.version+=1,this.appendEvent(n,"handoff.completed",{handoffId:r,goalId:o.goalId,loopId:o.loopId,ownerId:s,data:{epoch:n.owner?.epoch}}),o})}async failHandoff(t,r,s){return this.mutate(t,e=>{let n=e.handoffs.find(o=>o.id===r);if(!n)throw new p("NOT_FOUND",`Handoff ${r} was not found`);return["completed","cancelled","failed"].includes(n.status)||(n.status="failed",n.failureReason=u(s,"reason"),n.failedAt=this.now(),n.updatedAt=n.failedAt,n.version+=1,this.appendEvent(e,"handoff.failed",{handoffId:r,goalId:n.goalId,loopId:n.loopId,data:{reason:n.failureReason}})),n})}async mutateGoal(t,r,s,e,n=!0){return this.mutate(t,o=>{let i=this.requireGoal(o,r);this.assertVersion(i.id,i.version,s);let d=this.now();return e(i,d,o),i.version+=1,i.updatedAt=d,n&&this.appendEvent(o,"goal.updated",{goalId:r,data:{status:i.status,version:i.version}}),i})}async mutateLoop(t,r,s,e,n=!0){return this.mutate(t,o=>{let i=o.loops.find(c=>c.id===r);if(!i)throw new p("NOT_FOUND",`Loop ${r} was not found`);this.assertVersion(i.id,i.version,s);let d=this.now();return e(i,d,o),i.version+=1,i.updatedAt=d,n&&this.appendEvent(o,"loop.iteration",{loopId:r,goalId:i.goalId,data:{status:i.status,version:i.version}}),i})}recalculateProgress(t,r){let s=t.tasks.filter(e=>e.status==="completed").length;t.progress.completedTaskCount=s,t.progress.totalTaskCount=t.tasks.length,t.progress.percent=t.tasks.length?Math.round(s/t.tasks.length*100):void 0,t.progress.outstanding=t.tasks.filter(e=>!["completed","cancelled"].includes(e.status)).map(e=>e.title),t.progress.updatedAt=r}requireGoal(t,r){let s=t.goals.find(e=>e.id===r);if(!s)throw new p("NOT_FOUND",`Goal ${r} was not found`);return s}requireOwner(t,r,s){let e=t.owner;if(!e||e.ownerId!==r||e.leaseId!==s)throw new p("NOT_OWNER",`${r} does not own session ${t.sessionId}`,{owner:e});return e}assertVersion(t,r,s){if(!Number.isInteger(s)||s<1||r!==s)throw new p("CONFLICT",`Expected ${t} version ${s}, found ${r}`,{expected:s,actual:r})}newOwner(t,r,s,e){let n=s.leaseMs??this.ownerLeaseMs;if(!Number.isSafeInteger(n)||n<1)throw new p("INVALID","leaseMs must be a positive safe integer");return{ownerId:u(t,"ownerId",512),leaseId:this.idFactory("owner"),epoch:r,acquiredAt:e,heartbeatAt:e,expiresAt:new Date(X(e)+n).toISOString(),...s.processId!==void 0?{processId:s.processId}:{},...s.host?{host:u(s.host,"host",512)}:{}}}ownerExpired(t,r){return X(t.expiresAt)<=X(r)?!0:t.processId!==void 0&&t.host===x.hostname()&&!_(t.processId)}appendEvent(t,r,s){let e={schemaVersion:1,id:this.idFactory("event"),sequence:(t.events.at(-1)?.sequence??0)+1,type:r,sessionId:t.sessionId,...s.goalId?{goalId:s.goalId}:{},...s.loopId?{loopId:s.loopId}:{},...s.handoffId?{handoffId:s.handoffId}:{},...s.ownerId?{ownerId:s.ownerId}:{},timestamp:this.now(),data:w(s.data)};t.events.push(e),t.events.length>this.maximumEventsPerSession&&t.events.splice(0,t.events.length-this.maximumEventsPerSession)}async mutate(t,r){let s=u(t,"sessionId",1024);return this.withSessionLock(s,async()=>{let e=await this.readState(s),n=r(e);return e.version+=1,e.updatedAt=this.now(),await this.writeState(e),w(n)})}statePath(t){return m.join(this.rootDirectory,"sessions",`${oe(t)}.json`)}lockPath(t){return`${this.statePath(t)}.lock`}async readState(t){let r=this.statePath(t);try{let s=await f.readFile(r,"utf8"),e=JSON.parse(s);if(e.schemaVersion!==1||e.sessionId!==t)throw new p("INVALID",`Coordination state at ${r} does not match session ${t}`);return(!Number.isSafeInteger(e.ownershipEpoch)||e.ownershipEpoch<0)&&(e.ownershipEpoch=Math.max(e.owner?.epoch??0,...e.handoffs.map(n=>n.targetLeaseEpoch??n.sourceLeaseEpoch??0))),e}catch(s){if(s.code!=="ENOENT")throw s;let e=this.now();return{schemaVersion:1,sessionId:t,version:0,ownershipEpoch:0,goals:[],loops:[],handoffs:[],events:[],createdAt:e,updatedAt:e}}}async writeState(t){let r=this.statePath(t.sessionId),s=m.dirname(r);await f.mkdir(s,{recursive:!0});let e=`${r}.${process.pid}.${(0,y.randomUUID)()}.tmp`,n=await f.open(e,"wx");try{await n.writeFile(`${JSON.stringify(t,null,2)}
2
+ `,"utf8"),await n.sync()}finally{await n.close()}try{await this.renameReplacing(e,r);try{let o=await f.open(s,"r");try{await o.sync()}finally{await o.close()}}catch{}}finally{await f.unlink(e).catch(()=>{})}}async renameReplacing(t,r){for(let s=0;;s+=1)try{await f.rename(t,r);return}catch(e){let n=e.code,o=P[s];if(process.platform!=="win32"||!n||!S.has(n)||o===void 0)throw e;await new Promise(i=>setTimeout(i,o))}}async withSessionLock(t,r){let s=this.lockPath(t),e=m.join(s,"owner.json"),n=(0,y.randomUUID)(),o=`${s}.candidate.${n}`,i=Date.now();await f.mkdir(m.dirname(s),{recursive:!0});let d={schemaVersion:1,token:n,pid:process.pid,host:x.hostname(),acquiredAt:this.now()};await f.mkdir(o),await f.writeFile(m.join(o,"owner.json"),JSON.stringify(d),{encoding:"utf8",flag:"wx"});for(let c=0;;c+=1)try{await f.rename(o,s);break}catch(l){let g=l.code;if(!(g==="EEXIST"||process.platform==="win32"&&!!g&&S.has(g)))throw await f.rm(o,{recursive:!0,force:!0}).catch(()=>{}),l;let R=await this.staleLockOwner(s,e);if(R){await this.quarantineLock(s,R.token,"stale");continue}if(Date.now()-i>=this.lockTimeoutMs)throw await f.rm(o,{recursive:!0,force:!0}).catch(()=>{}),new p("CONFLICT",`Timed out waiting for coordination lock for session ${t}`);await new Promise(H=>setTimeout(H,Math.min(100,5+c*5)+Math.floor(Math.random()*10)))}try{return await r()}finally{await this.quarantineLock(s,n,"released"),await f.rm(o,{recursive:!0,force:!0}).catch(()=>{})}}async staleLockOwner(t,r){try{let[s,e]=await Promise.all([f.readFile(r,"utf8").catch(()=>""),f.stat(t)]),n=s?JSON.parse(s):void 0;return!n||n.host===x.hostname()&&_(n.pid)?void 0:Date.now()-e.mtimeMs>this.lockStaleMs?n:void 0}catch{return}}async quarantineLock(t,r,s){let e=m.join(t,"owner.json"),n=`${t}.${s}.${r}.${(0,y.randomUUID)()}`;for(let o=0;;o+=1){let i;try{i=JSON.parse(await f.readFile(e,"utf8"))}catch(d){if(d.code==="ENOENT")return;throw d}if(i.token!==r)return;try{await f.rename(t,n);break}catch(d){let c=d.code;if(c==="ENOENT"||c==="EEXIST")return;let l=P[o];if(process.platform!=="win32"||!c||!S.has(c)||l===void 0)throw d;await new Promise(g=>setTimeout(g,l))}}for(let o=0;;o+=1)try{await f.rm(n,{recursive:!0});return}catch(i){let d=i.code;if(d==="ENOENT")return;let c=z[o];if(process.platform!=="win32"||!d||!S.has(d)||c===void 0)throw i;await new Promise(l=>setTimeout(l,c))}}};function k(a,t){if(!a||typeof a!="object"||Array.isArray(a))throw new Error(`${t} must be an object`);return a}function h(a,t){if(typeof a!="string"||!a.trim())throw new Error(`${t} must be a non-empty string`);return a}function E(a,t){if(typeof a!="number"||!Number.isInteger(a))throw new Error(`${t} must be an integer`);return a}async function re(a,t){let{action:r,sessionId:s}=t,e=t.payload??{},n;switch(r){case"state.get":n=await a.getSessionState(s);break;case"goal.create":n=await a.createGoal({sessionId:s,...e});break;case"goal.update":n=await a.updateGoal(s,h(e.goalId,"goalId"),E(e.expectedVersion,"expectedVersion"),k(e.update,"update"));break;case"goal.complete":n=await a.completeGoal(s,h(e.goalId,"goalId"),E(e.expectedVersion,"expectedVersion"),k(e.verification,"verification"));break;case"goal.cancel":n=await a.cancelGoal(s,h(e.goalId,"goalId"),E(e.expectedVersion,"expectedVersion"),h(e.reason,"reason"));break;case"goal.steer":n=await a.steerGoal(s,h(e.goalId,"goalId"),E(e.expectedVersion,"expectedVersion"),h(e.instruction,"instruction"));break;case"loop.start":n=await a.startLoop({sessionId:s,kind:h(e.kind,"kind"),...typeof e.goalId=="string"?{goalId:e.goalId}:{},...typeof e.activity=="string"?{activity:e.activity}:{},...e.schedule?{schedule:k(e.schedule,"schedule")}:{}});break;case"loop.get":n=await a.getLoop(s,typeof e.loopId=="string"?e.loopId:void 0);break;case"loop.begin":n=await a.beginLoopIteration(s,h(e.loopId,"loopId"),E(e.expectedVersion,"expectedVersion"),h(e.activity,"activity"),typeof e.taskId=="string"?e.taskId:void 0);break;case"loop.finish":n=await a.finishLoopIteration(s,h(e.loopId,"loopId"),E(e.expectedVersion,"expectedVersion"),k(e.result,"result"));break;case"loop.set_status":n=await a.setLoopStatus(s,h(e.loopId,"loopId"),E(e.expectedVersion,"expectedVersion"),h(e.status,"status"),typeof e.reason=="string"?e.reason:void 0);break;case"ownership.acquire":n=await a.acquireOwnership(s,h(e.ownerId,"ownerId"),k(e.options??{},"options"));break;case"ownership.renew":n=await a.renewOwnership(s,h(e.ownerId,"ownerId"),h(e.leaseId,"leaseId"),typeof e.leaseMs=="number"?e.leaseMs:void 0);break;case"ownership.release":n=await a.releaseOwnership(s,h(e.ownerId,"ownerId"),h(e.leaseId,"leaseId"));break;case"handoff.create":n=await a.createHandoff({sessionId:s,...e});break;case"handoff.claim":n=await a.claimHandoff({sessionId:s,handoffId:h(e.handoffId,"handoffId"),targetOwnerId:h(e.targetOwnerId,"targetOwnerId"),...typeof e.processId=="number"?{processId:e.processId}:{},...typeof e.host=="string"?{host:e.host}:{}});break;case"handoff.complete":n=await a.completeHandoff(s,h(e.handoffId,"handoffId"),h(e.ownerId,"ownerId"),h(e.leaseId,"leaseId"));break;case"handoff.fail":n=await a.failHandoff(s,h(e.handoffId,"handoffId"),h(e.reason,"reason"));break}let o=await a.getSessionState(s),i=r==="state.get"||r==="loop.get"?void 0:o.events.at(-1);return{action:r,sessionId:s,result:n,state:o,...i?{event:i}:{}}}var D=require("node:crypto"),F=require("node:os");var T=class{sessionId;ownerId;store;processId;host;leaseMs;heartbeatMs;claimHandoffId;onOwnershipLost;timer;heartbeatInFlight=!1;owner;stopped=!1;lostError;preparedHandoffId;constructor(t){if(this.store=t.store??new b,this.sessionId=t.sessionId,this.processId=t.processId??process.pid,this.host=t.host??(0,F.hostname)(),this.ownerId=t.ownerId??`runtime:${this.host}:${this.processId}:${(0,D.randomUUID)().slice(0,8)}`,this.leaseMs=t.leaseMs??3e4,this.heartbeatMs=t.heartbeatMs??Math.max(250,Math.floor(this.leaseMs/3)),this.heartbeatMs>=this.leaseMs)throw new Error("heartbeatMs must be shorter than leaseMs");this.claimHandoffId=t.claimHandoffId,this.onOwnershipLost=t.onOwnershipLost}get currentOwner(){return this.owner?structuredClone(this.owner):void 0}get active(){return!!this.owner&&!this.stopped&&this.lostError===void 0}async start(){if(this.owner)return structuredClone(this.owner);if(this.stopped)throw new Error("Execution lease session has already stopped");if(this.claimHandoffId){let t=await this.store.claimHandoff({sessionId:this.sessionId,handoffId:this.claimHandoffId,targetOwnerId:this.ownerId,processId:this.processId,host:this.host});this.owner=t.owner,await this.store.completeHandoff(this.sessionId,this.claimHandoffId,this.ownerId,this.owner.leaseId)}else this.owner=await this.store.acquireOwnership(this.sessionId,this.ownerId,{processId:this.processId,host:this.host,leaseMs:this.leaseMs});return this.timer=setInterval(()=>{this.heartbeat()},this.heartbeatMs),this.timer.unref?.(),structuredClone(this.owner)}async assertOwned(){if(this.stopped)throw new Error("Execution surface is detached");if(this.lostError)throw this.lostError;if(this.preparedHandoffId)throw new Error(`Execution surface prepared handoff ${this.preparedHandoffId} and is detached from mutation`);if(!this.owner)throw new Error("Execution ownership was not started");return this.renewHeldLease()}async renewHeldLease(){if(!this.owner)throw new Error("Execution ownership was not started");try{return this.owner=await this.store.renewOwnership(this.sessionId,this.ownerId,this.owner.leaseId,this.leaseMs),structuredClone(this.owner)}catch(t){throw this.markLost(t),t}}async prepareHandoff(t={}){if(this.preparedHandoffId)throw new Error(`Handoff ${this.preparedHandoffId} is already prepared`);let r=await this.assertOwned(),s=await this.store.createHandoff({...t,sessionId:this.sessionId,sourceOwnerId:r.ownerId,sourceLeaseId:r.leaseId});return this.preparedHandoffId=s.id,s}async stop(t={}){if(this.stopped)return;this.stopped=!0,this.timer&&clearInterval(this.timer),this.timer=void 0;let r=this.owner;if(this.owner=void 0,!(t.release===!1||this.preparedHandoffId||!r||this.lostError))try{await this.store.releaseOwnership(this.sessionId,r.ownerId,r.leaseId)}catch{}}async heartbeat(){if(!(!this.active||this.heartbeatInFlight)){this.heartbeatInFlight=!0;try{await this.renewHeldLease()}catch(t){this.markLost(t)}finally{this.heartbeatInFlight=!1}}}markLost(t){this.lostError===void 0&&(this.lostError=t,this.timer&&clearInterval(this.timer),this.timer=void 0,this.onOwnershipLost?.(t))}};0&&(module.exports={DurableXenoCoordinationStore,XENO_COORDINATION_SCHEMA_VERSION,XenoCoordinationError,XenoExecutionLeaseSession,executeXenoCoordinationAction});