@xenosystem/agent-sdk 0.9.24 → 0.9.26
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.
- package/dist/artifacts/index.cjs +1 -1
- package/dist/artifacts/index.js +1 -1
- package/dist/automation/index.cjs +9 -9
- package/dist/automation/index.d.cts +69 -3
- package/dist/automation/index.d.ts +69 -3
- package/dist/automation/index.js +9 -9
- package/dist/automation/metafile-cjs.json +1 -1
- package/dist/automation/metafile-esm.json +1 -1
- package/dist/control-plane/index.cjs +1 -1
- package/dist/control-plane/index.js +1 -1
- package/dist/coordination/index.cjs +2 -2
- package/dist/coordination/index.d.cts +15 -3
- package/dist/coordination/index.d.ts +15 -3
- package/dist/coordination/index.js +2 -2
- package/dist/coordination/metafile-cjs.json +1 -1
- package/dist/coordination/metafile-esm.json +1 -1
- package/dist/electron/index.cjs +157 -153
- package/dist/electron/index.d.cts +22 -3
- package/dist/electron/index.d.ts +22 -3
- package/dist/electron/index.js +157 -153
- package/dist/electron/metafile-cjs.json +1 -1
- package/dist/electron/metafile-esm.json +1 -1
- package/dist/governance/index.d.cts +2 -0
- package/dist/governance/index.d.ts +2 -0
- package/dist/hosted/index.cjs +1 -1
- package/dist/hosted/index.js +1 -1
- package/dist/hosted/metafile-cjs.json +1 -1
- package/dist/hosted/metafile-esm.json +1 -1
- package/dist/index.cjs +473 -343
- package/dist/index.d.cts +314 -31
- package/dist/index.d.ts +314 -31
- package/dist/index.js +473 -343
- package/dist/mcp/index.d.cts +3 -0
- package/dist/mcp/index.d.ts +3 -0
- package/dist/metafile-cjs.json +1 -1
- package/dist/metafile-esm.json +1 -1
- package/dist/providers/index.cjs +10 -10
- package/dist/providers/index.d.cts +92 -17
- package/dist/providers/index.d.ts +92 -17
- package/dist/providers/index.js +10 -10
- package/dist/providers/metafile-cjs.json +1 -1
- package/dist/providers/metafile-esm.json +1 -1
- package/dist/session/index.cjs +1 -1
- package/dist/session/index.d.cts +2 -0
- package/dist/session/index.d.ts +2 -0
- package/dist/session/index.js +1 -1
- package/dist/session/metafile-cjs.json +1 -1
- package/dist/session/metafile-esm.json +1 -1
- package/dist/skills/index.d.cts +3 -0
- package/dist/skills/index.d.ts +3 -0
- package/dist/ui/index.d.cts +2 -0
- package/dist/ui/index.d.ts +2 -0
- package/dist/utils/index.d.cts +2 -0
- package/dist/utils/index.d.ts +2 -0
- package/package.json +10 -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/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
|
+
{"inputs":{"src/automation/types.ts":{"bytes":7431,"imports":[],"format":"esm"},"src/automation/operations.ts":{"bytes":3367,"imports":[],"format":"esm"},"src/automation/errors.ts":{"bytes":899,"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/durable-execution.ts":{"bytes":4647,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"src/automation/evidence.ts","kind":"import-statement","original":"./evidence.js"},{"path":"src/automation/errors.ts","kind":"import-statement","original":"./errors.js"}],"format":"esm"},"src/automation/executor.ts":{"bytes":16288,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"src/automation/errors.ts","kind":"import-statement","original":"./errors.js"},{"path":"src/automation/durable-execution.ts","kind":"import-statement","original":"./durable-execution.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/execution-journal.ts":{"bytes":7254,"imports":[{"path":"node:path","kind":"import-statement","external":true},{"path":"src/automation/errors.ts","kind":"import-statement","original":"./errors.js"},{"path":"node:sqlite","kind":"dynamic-import","external":true}],"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":29318,"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":449,"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/execution-journal.ts","kind":"import-statement","original":"./execution-journal.js"},{"path":"src/automation/durable-execution.ts","kind":"import-statement","original":"./durable-execution.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:path","kind":"require-call","external":true},{"path":"node:sqlite","kind":"dynamic-import","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":1420},"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":10455},"src/security/path-policy.ts":{"bytesInOutput":2595},"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":6527},"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":7134},"src/automation/durable-execution.ts":{"bytesInOutput":2222},"src/automation/execution-journal.ts":{"bytesInOutput":4239},"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":14569},"src/automation/tool-pack.ts":{"bytesInOutput":10038}},"bytes":211163}}}
|
|
@@ -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/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
|
+
{"inputs":{"src/automation/types.ts":{"bytes":7431,"imports":[],"format":"esm"},"src/automation/operations.ts":{"bytes":3367,"imports":[],"format":"esm"},"src/automation/errors.ts":{"bytes":899,"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/durable-execution.ts":{"bytes":4647,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"src/automation/evidence.ts","kind":"import-statement","original":"./evidence.js"},{"path":"src/automation/errors.ts","kind":"import-statement","original":"./errors.js"}],"format":"esm"},"src/automation/executor.ts":{"bytes":16288,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"src/automation/errors.ts","kind":"import-statement","original":"./errors.js"},{"path":"src/automation/durable-execution.ts","kind":"import-statement","original":"./durable-execution.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/execution-journal.ts":{"bytes":7254,"imports":[{"path":"node:path","kind":"import-statement","external":true},{"path":"src/automation/errors.ts","kind":"import-statement","original":"./errors.js"},{"path":"node:sqlite","kind":"dynamic-import","external":true}],"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":29318,"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":449,"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/execution-journal.ts","kind":"import-statement","original":"./execution-journal.js"},{"path":"src/automation/durable-execution.ts","kind":"import-statement","original":"./durable-execution.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:path","kind":"import-statement","external":true},{"path":"node:sqlite","kind":"dynamic-import","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","SqliteAutomationExecutionJournal","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","openSqliteAutomationExecutionJournal","pending","persistXenoAutomationEvidence","readCliAutomationEnvironment","readXenoHostAutomationEnvironment","renderCliAutomationStatus","renderXenoHostAutomationStatus","resolveXenoAutomationEvidencePolicy","runDurableAutomation"],"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":10453},"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":7132},"src/automation/durable-execution.ts":{"bytesInOutput":2222},"src/automation/execution-journal.ts":{"bytesInOutput":4236},"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":14552},"src/automation/tool-pack.ts":{"bytesInOutput":10038}},"bytes":208996}}}
|
|
@@ -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.
|
|
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.26";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.
|
|
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.26";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)}
|
|
@@ -1,2 +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,
|
|
1
|
+
"use strict";var $=Object.create;var C=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var j=Object.getPrototypeOf,J=Object.prototype.hasOwnProperty;var B=(d,t)=>{for(var s in t)C(d,s,{get:t[s],enumerable:!0})},M=(d,t,s,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of U(t))!J.call(d,e)&&e!==s&&C(d,e,{get:()=>t[e],enumerable:!(r=q(t,e))||r.enumerable});return d};var x=(d,t,s)=>(s=d!=null?$(j(d)):{},M(t||!d||!d.__esModule?C(s,"default",{value:d,enumerable:!0}):s,d)),W=d=>M(C({},"__esModule",{value:!0}),d);var ie={};B(ie,{DurableXenoCoordinationStore:()=>b,XENO_COORDINATION_MANAGED_SESSION_SCHEMA_VERSION:()=>k,XENO_COORDINATION_SCHEMA_VERSION:()=>I,XenoCoordinationError:()=>l,XenoExecutionLeaseSession:()=>G,executeXenoCoordinationAction:()=>se});module.exports=W(ie);var I=1,k=2,l=class extends Error{constructor(s,r,e={}){super(r);this.code=s;this.details=e;this.name="XenoCoordinationError"}code;details};var y=require("node:crypto"),f=x(require("node:fs/promises"),1),A=x(require("node:os"),1),m=x(require("node:path"),1);var v=require("node:os");var T=require("node:path"),ce=(0,v.platform)();var le=(0,v.release)(),ue=(0,v.homedir)();function _(){let d=process.env.XENO_AGENT_HOME?.trim();return d?(0,T.resolve)(d):(0,T.resolve)((0,v.homedir)(),".xeno-agent")}var K=3e4,Q=3e4,Y=6e4,z=2e4,N=new Set(["EACCES","EBUSY","EPERM"]),D=[5,10,20,40,80,160,320],Z=[5,10,20,40,80,160,320];function p(d,t,s=16384){let r=d.trim();if(!r||r.length>s)throw new l("INVALID",`${t} must be non-empty and no longer than ${s} characters`);return r}function L(d,t){return[...new Set((d??[]).map(s=>p(s,t)))]}function ee(d){if(!d)return;let t={};for(let[s,r]of Object.entries(d))if(r!==void 0){if(!Number.isSafeInteger(r)||r<=0)throw new l("INVALID",`${s} must be a positive safe integer when provided`);t[s]=r}return t}function te(d){if(d){if(d.kind!=="fixed-interval"&&d.kind!=="dynamic")throw new l("INVALID","schedule.kind must be fixed-interval or dynamic");if(d.kind==="fixed-interval"&&(!Number.isSafeInteger(d.intervalMs)||(d.intervalMs??0)<=0))throw new l("INVALID","Fixed-interval schedules require a positive safe intervalMs");if(d.intervalMs!==void 0&&(!Number.isSafeInteger(d.intervalMs)||d.intervalMs<=0))throw new l("INVALID","schedule.intervalMs must be a positive safe integer when provided");for(let t of["nextRunAt","expiresAt"]){let s=d[t];if(s!==void 0&&!Number.isFinite(Date.parse(s)))throw new l("INVALID",`schedule.${t} must be an ISO timestamp when provided`)}return w(d)}}function w(d){return structuredClone(d)}function X(d){let t=Date.parse(d);return Number.isFinite(t)?t:0}function R(d){if(!Number.isInteger(d)||d<=0)return!1;try{return process.kill(d,0),!0}catch(t){return t.code==="EPERM"}}function ne(d){return{summary:"Goal created; work has not started.",completedTaskCount:0,totalTaskCount:0,outstanding:[],decisions:[],updatedAt:d}}function oe(){return{status:"pending",criteria:[],evidence:[]}}function re(d){return(0,y.createHash)("sha256").update(d).digest("hex")}var b=class{rootDirectory;now;idFactory;ownerLeaseMs;lockTimeoutMs;lockStaleMs;maximumEventsPerSession;constructor(t={}){this.rootDirectory=t.rootDirectory??m.join(_(),"coordination"),this.now=t.now??(()=>new Date().toISOString()),this.idFactory=t.idFactory??(s=>`${s}_${(0,y.randomUUID)()}`),this.ownerLeaseMs=t.ownerLeaseMs??K,this.lockTimeoutMs=t.lockTimeoutMs??Q,this.lockStaleMs=t.lockStaleMs??Y,this.maximumEventsPerSession=t.maximumEventsPerSession??z}async getSessionState(t){let s=p(t,"sessionId",1024);return w(await this.readState(s))}async fenceAdmission(t,s,r){let e=p(r.authorityId,"authorityId",512),n=p(r.operationId,"operationId",512);if(!Number.isSafeInteger(s)||s<0)throw new l("INVALID","Expected session version must be a nonnegative safe integer");if(r.action!=="archive"&&r.action!=="delete")throw new l("INVALID","Unsupported admission fence action");return this.mutate(t,o=>{let i=o.admissionFence;if(i?.authorityId===e&&i.operationId===n&&i.action===r.action)return i;if(o.version!==s)throw new l("CONFLICT","Session version changed before lifecycle fencing",{expected:s,actual:o.version});if(i?.authorityId===e&&i.action==="archive"&&r.action==="archive")return i;if(i&&!(i.authorityId===e&&i.action==="archive"&&r.action==="delete"))throw new l("CONFLICT","Another lifecycle fence already owns this session");let a={schemaVersion:1,authorityId:e,operationId:n,action:r.action,createdAt:this.now()};return o.admissionFence=a,o.schemaVersion=2,this.appendEvent(o,"admission.fenced",{data:{authorityId:e,operationId:n,action:r.action}}),a},!0)}async clearAdmissionFence(t,s,r,e){await this.mutate(t,n=>{this.assertVersion(t,n.version,s);let o=n.admissionFence;if(!o||o.authorityId!==r||o.operationId!==e)throw new l("CONFLICT","Lifecycle fence identity does not match");if(o.action==="delete")throw new l("CONFLICT","Deleted session admission cannot be restored");if(n.owner)throw new l("CONFLICT","Execution ownership must settle before restoration");n.admissionFence=void 0,this.appendEvent(n,"admission.restored",{data:{authorityId:r,operationId:e}})},!0)}async releaseDeadLifecycleOwner(t,s,r,e){await this.mutate(t,n=>{this.assertVersion(t,n.version,s);let o=n.admissionFence;if(!o||o.authorityId!==r||o.operationId!==e)throw new l("CONFLICT","Lifecycle fence identity does not match");let i=n.owner;if(i){if(i.host!==A.hostname()||!Number.isInteger(i.processId)||(i.processId??0)<=0||R(i.processId))throw new l("CONFLICT","Execution owner exit has not been proved");n.owner=void 0,this.appendEvent(n,"ownership.released",{ownerId:i.ownerId,data:{epoch:i.epoch,reason:"fenced-local-owner-exited"}})}},!0)}async listSessionStates(){let t=m.join(this.rootDirectory,"sessions"),s;try{s=await f.readdir(t)}catch(e){if(e.code==="ENOENT")return[];throw e}return(await Promise.all(s.filter(e=>e.endsWith(".json")).map(async e=>{try{let n=JSON.parse(await f.readFile(m.join(t,e),"utf8"));return![1,2].includes(n.schemaVersion)||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 s=p(t.sessionId,"sessionId",1024),r=ee(t.limits);return this.mutate(s,e=>{let n=e.goals.find(c=>["active","paused","waiting","blocked"].includes(c.status));if(n)throw new l("CONFLICT",`Session ${s} already has active goal ${n.id}`);let o=this.now(),i=(t.successCriteria??[]).map(c=>typeof c=="string"?{id:this.idFactory("criterion"),description:p(c,"successCriteria"),required:!0}:{id:c.id?p(c.id,"successCriteria.id",512):this.idFactory("criterion"),description:p(c.description,"successCriteria.description"),required:c.required}),a={schemaVersion:1,id:this.idFactory("goal"),version:1,sessionId:s,objective:p(t.objective,"objective"),...t.why?{why:p(t.why,"why")}:{},successCriteria:i,constraints:L(t.constraints,"constraints"),...r?{limits:r}:{},metadata:w(t.metadata??{}),status:"active",milestones:[],tasks:[],progress:ne(o),verification:oe(),steering:[],createdAt:o,updatedAt:o};return e.goals.push(a),this.appendEvent(e,"goal.created",{goalId:a.id,data:{objective:a.objective}}),a})}async getGoal(t,s){let r=await this.getSessionState(t),e=s?r.goals.find(n=>n.id===s):[...r.goals].reverse().find(n=>["active","paused","waiting","blocked"].includes(n.status));return e?w(e):void 0}async updateGoal(t,s,r,e){return this.mutate(t,n=>{let o=this.requireGoal(n,s);if(this.assertVersion(o.id,o.version,r),["completed","cancelled","failed"].includes(o.status))throw new l("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=p(e.objective,"objective")),e.why!==void 0&&(o.why=p(e.why,"why")),e.constraints&&(o.constraints=L(e.constraints,"constraints")),e.successCriteria&&(o.successCriteria=w(e.successCriteria)),e.progress&&(o.progress={...o.progress,...w(e.progress),outstanding:L(e.progress.outstanding??o.progress.outstanding,"progress.outstanding"),decisions:L(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},e.status!==void 0&&["paused","cancelled","failed"].includes(e.status))}async addMilestone(t,s,r,e){return this.mutateGoal(t,s,r,(n,o)=>{let i={id:this.idFactory("milestone"),title:p(e.title,"milestone.title"),...e.description?{description:p(e.description,"milestone.description")}:{},status:n.milestones.some(a=>a.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,s,r,e){return this.mutateGoal(t,s,r,(n,o)=>{let i=n.milestones.find(u=>u.id===e.milestoneId);if(!i)throw new l("NOT_FOUND",`Milestone ${e.milestoneId} was not found`);if(e.parentTaskId&&!n.tasks.some(u=>u.id===e.parentTaskId))throw new l("NOT_FOUND",`Parent task ${e.parentTaskId} was not found`);let a=[...new Set(e.dependsOn??[])];for(let u of a)if(!n.tasks.some(g=>g.id===u))throw new l("NOT_FOUND",`Task dependency ${u} was not found`);let c={id:this.idFactory("task"),milestoneId:i.id,...e.parentTaskId?{parentTaskId:e.parentTaskId}:{},title:p(e.title,"task.title"),...e.description?{description:p(e.description,"task.description")}:{},status:a.length===0?"ready":"pending",...e.assignedAgentId?{assignedAgentId:p(e.assignedAgentId,"task.assignedAgentId",512)}:{},...a.length?{dependsOn:a}:{},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(u=>u.status!=="completed").map(u=>u.title),n.progress.updatedAt=o})}async updateTask(t,s,r,e,n){return this.mutateGoal(t,s,e,(o,i)=>{let a=o.tasks.find(u=>u.id===r);if(!a)throw new l("NOT_FOUND",`Task ${r} was not found`);a.status=n.status,n.progress!==void 0&&(a.progress=p(n.progress,"task.progress")),n.resultEventId!==void 0&&(a.resultEventId=p(n.resultEventId,"task.resultEventId",512)),n.assignedAgentId!==void 0&&(a.assignedAgentId=p(n.assignedAgentId,"task.assignedAgentId",512)),a.updatedAt=i,a.status==="completed"&&(a.completedAt=i);let c=o.milestones.find(u=>u.id===a.milestoneId);if(c){let u=o.tasks.filter(g=>g.milestoneId===c.id);u.length>0&&u.every(g=>g.status==="completed")?(c.status="completed",c.completedAt=i):u.some(g=>g.status==="running")?c.status="active":u.some(g=>g.status==="blocked")&&(c.status="blocked"),c.updatedAt=i}for(let u of o.tasks)u.status!=="pending"||!u.dependsOn?.length||u.dependsOn.every(g=>o.tasks.find(O=>O.id===g)?.status==="completed")&&(u.status="ready",u.updatedAt=i);this.recalculateProgress(o,i)})}async steerGoal(t,s,r,e){return this.mutateGoal(t,s,r,(n,o,i)=>{let a=this.idFactory("steer");n.steering.push({id:a,instruction:p(e,"instruction"),createdAt:o}),this.appendEvent(i,"goal.steered",{goalId:s,data:{steeringId:a}})},!1)}async consumeGoalSteering(t,s,r){let e=[];return{goal:await this.mutateGoal(t,s,r,(o,i)=>{e=o.steering.filter(a=>!a.consumedAt).map(({id:a,instruction:c,createdAt:u})=>({id:a,instruction:c,createdAt:u}));for(let a of o.steering)a.consumedAt||(a.consumedAt=i)}),instructions:e}}async completeGoal(t,s,r,e){if(e.status!=="passed")throw new l("VERIFICATION_REQUIRED","Goal completion requires passed verification");return this.mutate(t,n=>{let o=this.requireGoal(n,s);this.assertVersion(o.id,o.version,r);let i=o.successCriteria.filter(u=>u.required),a=i.filter(u=>{let g=e.criteria.find(O=>O.criterionId===u.id);return!g?.satisfied||g.evidence.length===0});if(a.length>0)throw new l("VERIFICATION_REQUIRED","Required success criteria lack passing evidence",{unmetCriteria:a.map(u=>u.id)});if(i.length===0&&e.evidence.length===0)throw new l("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:s,data:{evidence:o.verification.evidence}}),o},!0)}async cancelGoal(t,s,r,e){return this.mutate(t,n=>{let o=this.requireGoal(n,s);if(this.assertVersion(o.id,o.version,r),["completed","cancelled","failed"].includes(o.status))return o;o.status="cancelled",o.updatedAt=this.now(),o.version+=1,this.appendEvent(n,"goal.cancelled",{goalId:s,data:{reason:p(e,"reason")}});for(let i of n.loops.filter(a=>a.goalId===s&&["running","paused","waiting"].includes(a.status)))i.status="stopped",i.stopReason=`Goal cancelled: ${e}`,i.stoppedAt=this.now(),i.updatedAt=i.stoppedAt,i.version+=1;return o},!0)}async startLoop(t){return this.mutate(t.sessionId,s=>{if(t.kind==="goal-continuation"&&!t.goalId)throw new l("INVALID","Goal-continuation loops require a goalId");if(t.goalId){let i=this.requireGoal(s,t.goalId);if(["completed","cancelled","failed"].includes(i.status))throw new l("CONFLICT",`Cannot start a loop for terminal goal ${i.id}`)}if(t.kind==="scheduled"&&!t.schedule)throw new l("INVALID","Scheduled loops require schedule metadata");if(t.kind!=="scheduled"&&t.schedule)throw new l("INVALID","Only scheduled loops may carry schedule metadata");let r=te(t.schedule),e=s.loops.find(i=>i.goalId===t.goalId&&i.kind===t.kind&&["running","paused","waiting"].includes(i.status));if(e)throw new l("CONFLICT",`Loop ${e.id} is already active`);let n=this.now(),o={schemaVersion:1,id:this.idFactory("loop"),version:1,sessionId:s.sessionId,...t.goalId?{goalId:t.goalId}:{},kind:t.kind,status:"running",...t.activity?{currentActivity:p(t.activity,"activity")}:{},iterations:[],...r?{schedule:r}:{},createdAt:n,updatedAt:n};return s.loops.push(o),this.appendEvent(s,"loop.started",{loopId:o.id,goalId:o.goalId,data:{kind:o.kind}}),o})}async getLoop(t,s){let r=await this.getSessionState(t),e=s?r.loops.find(n=>n.id===s):[...r.loops].reverse().find(n=>["running","paused","waiting"].includes(n.status));return e?w(e):void 0}async beginLoopIteration(t,s,r,e,n){return this.mutateLoop(t,s,r,(o,i,a)=>{if(o.status!=="running")throw new l("CONFLICT",`Loop ${o.id} is ${o.status}`);if(o.iterations.some(u=>u.status==="running"))throw new l("CONFLICT",`Loop ${o.id} already has a running iteration`);let c=(o.iterations.at(-1)?.number??0)+1;o.currentActivity=p(e,"activity"),o.iterations.push({number:c,startedAt:i,status:"running",activity:o.currentActivity,...n?{taskId:p(n,"taskId",512)}:{}}),this.appendEvent(a,"loop.iteration",{loopId:s,goalId:o.goalId,data:{number:c,phase:"started",activity:o.currentActivity}})},!1)}async finishLoopIteration(t,s,r,e){return this.mutateLoop(t,s,r,(n,o,i)=>{let a=[...n.iterations].reverse().find(c=>c.status==="running");if(!a)throw new l("CONFLICT",`Loop ${n.id} has no running iteration`);a.status=e.status,a.completedAt=o,e.verificationEventId&&(a.verificationEventId=p(e.verificationEventId,"verificationEventId",512)),e.error&&(a.error=p(e.error,"error")),n.status=i.admissionFence?"paused":e.nextStatus??(n.status==="paused"||n.status==="waiting"?n.status:"running"),this.appendEvent(i,"loop.iteration",{loopId:s,goalId:n.goalId,data:{number:a.number,phase:"finished",status:e.status}})},!1,!0)}async setLoopStatus(t,s,r,e,n){return this.mutateLoop(t,s,r,(o,i,a)=>{let c=o.status;if(["stopped","completed","failed"].includes(c))throw new l("CONFLICT",`Loop ${o.id} is terminal (${c})`);let u=[...o.iterations].reverse().find(O=>O.status==="running");if(u&&e==="completed")throw new l("CONFLICT",`Loop ${o.id} cannot complete while iteration ${u.number} is running`);u&&(e==="stopped"||e==="failed")&&(u.status=e==="failed"?"failed":"interrupted",u.completedAt=i,u.error=p(n??e,"reason")),o.status=e,["stopped","completed","failed"].includes(e)&&(o.stoppedAt=i,o.stopReason=p(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(a,g,{loopId:s,goalId:o.goalId,data:{previous:c,status:e,...n?{reason:n}:{}}})},!1,e!=="running"&&e!=="waiting")}async acquireOwnership(t,s,r={}){return this.mutate(t,e=>{let n=this.now();if(e.owner&&!this.ownerExpired(e.owner,n)){if(e.owner.ownerId===s&&r.processId!==void 0&&e.owner.processId===r.processId&&(r.host===void 0||e.owner.host===r.host))return e.owner;throw new l("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!==s)for(let c of e.handoffs.filter(u=>u.status==="claimed"&&u.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,a=this.newOwner(s,i,r,n);return e.owner=a,e.ownershipEpoch=i,this.appendEvent(e,"ownership.acquired",{ownerId:s,data:{epoch:i,leaseId:a.leaseId}}),a})}async renewOwnership(t,s,r,e=this.ownerLeaseMs){return this.mutate(t,n=>{let o=this.requireOwner(n,s,r);if(this.ownerExpired(o,this.now()))throw new l("LEASE_EXPIRED",`Ownership lease ${r} expired`);return o.heartbeatAt=this.now(),o.expiresAt=new Date(X(o.heartbeatAt)+e).toISOString(),this.appendEvent(n,"ownership.renewed",{ownerId:s,data:{epoch:o.epoch,leaseId:r}}),o})}async releaseOwnership(t,s,r){return this.mutate(t,e=>{let n=this.requireOwner(e,s,r);return e.owner=void 0,this.appendEvent(e,"ownership.released",{ownerId:s,data:{epoch:n.epoch}}),n},!0)}async createHandoff(t){return this.mutate(t.sessionId,s=>{let r=this.requireOwner(s,t.sourceOwnerId,t.sourceLeaseId);if(this.ownerExpired(r,this.now()))throw new l("LEASE_EXPIRED",`Ownership lease ${r.leaseId} expired`);let e=(t.operations??[]).filter(a=>a.status==="running"&&a.sideEffecting&&a.recovery==="retry");if(e.length>0)throw new l("UNSAFE_HANDOFF","Running side-effecting operations cannot be transferred with automatic retry",{operationIds:e.map(a=>a.operationId)});if(t.goalId&&this.requireGoal(s,t.goalId),t.loopId&&!s.loops.some(a=>a.id===t.loopId))throw new l("NOT_FOUND",`Loop ${t.loopId} was not found`);let n=s.handoffs.find(a=>["prepared","available","claimed"].includes(a.status));if(n)throw new l("CONFLICT",`Handoff ${n.id} is already active`);let o=this.now(),i={schemaVersion:1,id:this.idFactory("handoff"),version:1,sessionId:s.sessionId,...t.goalId?{goalId:t.goalId}:{},...t.loopId?{loopId:t.loopId}:{},status:"available",sourceOwnerId:r.ownerId,...t.targetOwnerId?{targetOwnerId:p(t.targetOwnerId,"targetOwnerId",512)}:{},sourceLeaseEpoch:r.epoch,...t.workspace?{workspace:p(t.workspace,"workspace",32768)}:{},...t.branch?{branch:p(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:p(t.contextDigest,"contextDigest",512)}:{},createdAt:o,updatedAt:o};return s.handoffs.push(i),this.appendEvent(s,"handoff.created",{handoffId:i.id,goalId:i.goalId,loopId:i.loopId,ownerId:r.ownerId,data:{targetOwnerId:i.targetOwnerId}}),i})}async claimHandoff(t){let s;return{handoff:await this.mutate(t.sessionId,e=>{let n=e.handoffs.find(a=>a.id===t.handoffId);if(!n)throw new l("NOT_FOUND",`Handoff ${t.handoffId} was not found`);if(n.status!=="available")throw new l("CONFLICT",`Handoff ${n.id} is ${n.status}`,{claimedBy:n.claimedBy});if(n.targetOwnerId&&n.targetOwnerId!==t.targetOwnerId)throw new l("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 l("CONFLICT",`Handoff ${n.id} no longer matches the source ownership epoch`);let i=this.now();return s=this.newOwner(t.targetOwnerId,o.epoch+1,{processId:t.processId,host:t.host},i),e.owner=s,e.ownershipEpoch=s.epoch,n.status="claimed",n.claimedBy=t.targetOwnerId,n.targetOwnerId=t.targetOwnerId,n.targetLeaseEpoch=s.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:s.epoch}}),n}),owner:w(s)}}async completeHandoff(t,s,r,e){return this.mutate(t,n=>{this.requireOwner(n,r,e);let o=n.handoffs.find(i=>i.id===s);if(!o)throw new l("NOT_FOUND",`Handoff ${s} was not found`);if(o.status!=="claimed"||o.claimedBy!==r)throw new l("CONFLICT",`Handoff ${o.id} cannot be completed by ${r}`);return o.status="completed",o.completedAt=this.now(),o.updatedAt=o.completedAt,o.version+=1,this.appendEvent(n,"handoff.completed",{handoffId:s,goalId:o.goalId,loopId:o.loopId,ownerId:r,data:{epoch:n.owner?.epoch}}),o})}async failHandoff(t,s,r){return this.mutate(t,e=>{let n=e.handoffs.find(o=>o.id===s);if(!n)throw new l("NOT_FOUND",`Handoff ${s} was not found`);return["completed","cancelled","failed"].includes(n.status)||(n.status="failed",n.failureReason=p(r,"reason"),n.failedAt=this.now(),n.updatedAt=n.failedAt,n.version+=1,this.appendEvent(e,"handoff.failed",{handoffId:s,goalId:n.goalId,loopId:n.loopId,data:{reason:n.failureReason}})),n},!0)}async mutateGoal(t,s,r,e,n=!0){return this.mutate(t,o=>{let i=this.requireGoal(o,s);this.assertVersion(i.id,i.version,r);let a=this.now();return e(i,a,o),i.version+=1,i.updatedAt=a,n&&this.appendEvent(o,"goal.updated",{goalId:s,data:{status:i.status,version:i.version}}),i})}async mutateLoop(t,s,r,e,n=!0,o=!1){return this.mutate(t,i=>{let a=i.loops.find(u=>u.id===s);if(!a)throw new l("NOT_FOUND",`Loop ${s} was not found`);this.assertVersion(a.id,a.version,r);let c=this.now();return e(a,c,i),a.version+=1,a.updatedAt=c,n&&this.appendEvent(i,"loop.iteration",{loopId:s,goalId:a.goalId,data:{status:a.status,version:a.version}}),a},o)}recalculateProgress(t,s){let r=t.tasks.filter(e=>e.status==="completed").length;t.progress.completedTaskCount=r,t.progress.totalTaskCount=t.tasks.length,t.progress.percent=t.tasks.length?Math.round(r/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=s}requireGoal(t,s){let r=t.goals.find(e=>e.id===s);if(!r)throw new l("NOT_FOUND",`Goal ${s} was not found`);return r}requireOwner(t,s,r){let e=t.owner;if(!e||e.ownerId!==s||e.leaseId!==r)throw new l("NOT_OWNER",`${s} does not own session ${t.sessionId}`,{owner:e});return e}assertVersion(t,s,r){if(!Number.isInteger(r)||r<1||s!==r)throw new l("CONFLICT",`Expected ${t} version ${r}, found ${s}`,{expected:r,actual:s})}newOwner(t,s,r,e){let n=r.leaseMs??this.ownerLeaseMs;if(!Number.isSafeInteger(n)||n<1)throw new l("INVALID","leaseMs must be a positive safe integer");return{ownerId:p(t,"ownerId",512),leaseId:this.idFactory("owner"),epoch:s,acquiredAt:e,heartbeatAt:e,expiresAt:new Date(X(e)+n).toISOString(),...r.processId!==void 0?{processId:r.processId}:{},...r.host?{host:p(r.host,"host",512)}:{}}}ownerExpired(t,s){return X(t.expiresAt)<=X(s)?!0:t.processId!==void 0&&t.host===A.hostname()&&!R(t.processId)}appendEvent(t,s,r){let e={schemaVersion:1,id:this.idFactory("event"),sequence:(t.events.at(-1)?.sequence??0)+1,type:s,sessionId:t.sessionId,...r.goalId?{goalId:r.goalId}:{},...r.loopId?{loopId:r.loopId}:{},...r.handoffId?{handoffId:r.handoffId}:{},...r.ownerId?{ownerId:r.ownerId}:{},timestamp:this.now(),data:w(r.data)};t.events.push(e),t.events.length>this.maximumEventsPerSession&&t.events.splice(0,t.events.length-this.maximumEventsPerSession)}async mutate(t,s,r=!1){let e=p(t,"sessionId",1024);return this.withSessionLock(e,async()=>{let n=await this.readState(e);if(n.admissionFence&&!r)throw new l("CONFLICT","Session execution is blocked by a persisted lifecycle fence");let o=s(n);return n.version+=1,n.updatedAt=this.now(),await this.writeState(n),w(o)})}statePath(t){return m.join(this.rootDirectory,"sessions",`${re(t)}.json`)}lockPath(t){return`${this.statePath(t)}.lock`}async readState(t){let s=this.statePath(t);try{let r=await f.readFile(s,"utf8"),e=JSON.parse(r);if(![1,2].includes(e.schemaVersion)||e.sessionId!==t)throw new l("INVALID",`Coordination state at ${s} does not match session ${t}`);if(e.admissionFence!==void 0){let n=e.admissionFence;if(!n||n.schemaVersion!==1||typeof n.authorityId!="string"||!n.authorityId.trim()||typeof n.operationId!="string"||!n.operationId.trim()||!["archive","delete"].includes(n.action)||!Number.isFinite(Date.parse(n.createdAt)))throw new l("INVALID","Persisted lifecycle fence is corrupt; execution remains unavailable")}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(r){if(r.code!=="ENOENT")throw r;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 s=this.statePath(t.sessionId),r=m.dirname(s);await f.mkdir(r,{recursive:!0});let e=`${s}.${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,s);try{let o=await f.open(r,"r");try{await o.sync()}finally{await o.close()}}catch{}}finally{await f.unlink(e).catch(()=>{})}}async renameReplacing(t,s){for(let r=0;;r+=1)try{await f.rename(t,s);return}catch(e){let n=e.code,o=D[r];if(process.platform!=="win32"||!n||!N.has(n)||o===void 0)throw e;await new Promise(i=>setTimeout(i,o))}}async withSessionLock(t,s){let r=this.lockPath(t),e=m.join(r,"owner.json"),n=(0,y.randomUUID)(),o=`${r}.candidate.${n}`,i=Date.now();await f.mkdir(m.dirname(r),{recursive:!0});let a={schemaVersion:1,token:n,pid:process.pid,host:A.hostname(),acquiredAt:this.now()};await f.mkdir(o),await f.writeFile(m.join(o,"owner.json"),JSON.stringify(a),{encoding:"utf8",flag:"wx"});for(let c=0;;c+=1)try{await f.rename(o,r);break}catch(u){let g=u.code;if(!(g==="EEXIST"||process.platform==="win32"&&!!g&&N.has(g)))throw await f.rm(o,{recursive:!0,force:!0}).catch(()=>{}),u;let F=await this.staleLockOwner(r,e);if(F){await this.quarantineLock(r,F.token,"stale");continue}if(Date.now()-i>=this.lockTimeoutMs)throw await f.rm(o,{recursive:!0,force:!0}).catch(()=>{}),new l("CONFLICT",`Timed out waiting for coordination lock for session ${t}`);await new Promise(V=>setTimeout(V,Math.min(100,5+c*5)+Math.floor(Math.random()*10)))}try{return await s()}finally{await this.quarantineLock(r,n,"released"),await f.rm(o,{recursive:!0,force:!0}).catch(()=>{})}}async staleLockOwner(t,s){try{let[r,e]=await Promise.all([f.readFile(s,"utf8").catch(()=>""),f.stat(t)]),n=r?JSON.parse(r):void 0;return!n||n.host===A.hostname()&&R(n.pid)?void 0:Date.now()-e.mtimeMs>this.lockStaleMs?n:void 0}catch{return}}async quarantineLock(t,s,r){let e=m.join(t,"owner.json"),n=`${t}.${r}.${s}.${(0,y.randomUUID)()}`;for(let o=0;;o+=1){let i;try{i=JSON.parse(await f.readFile(e,"utf8"))}catch(a){if(a.code==="ENOENT")return;throw a}if(i.token!==s)return;try{await f.rename(t,n);break}catch(a){let c=a.code;if(c==="ENOENT"||c==="EEXIST")return;let u=D[o];if(process.platform!=="win32"||!c||!N.has(c)||u===void 0)throw a;await new Promise(g=>setTimeout(g,u))}}for(let o=0;;o+=1)try{await f.rm(n,{recursive:!0});return}catch(i){let a=i.code;if(a==="ENOENT")return;let c=Z[o];if(process.platform!=="win32"||!a||!N.has(a)||c===void 0)throw i;await new Promise(u=>setTimeout(u,c))}}};function S(d,t){if(!d||typeof d!="object"||Array.isArray(d))throw new Error(`${t} must be an object`);return d}function h(d,t){if(typeof d!="string"||!d.trim())throw new Error(`${t} must be a non-empty string`);return d}function E(d,t){if(typeof d!="number"||!Number.isInteger(d))throw new Error(`${t} must be an integer`);return d}async function se(d,t){let{action:s,sessionId:r}=t,e=t.payload??{},n;switch(s){case"state.get":n=await d.getSessionState(r);break;case"goal.create":n=await d.createGoal({sessionId:r,...e});break;case"goal.update":n=await d.updateGoal(r,h(e.goalId,"goalId"),E(e.expectedVersion,"expectedVersion"),S(e.update,"update"));break;case"goal.complete":n=await d.completeGoal(r,h(e.goalId,"goalId"),E(e.expectedVersion,"expectedVersion"),S(e.verification,"verification"));break;case"goal.cancel":n=await d.cancelGoal(r,h(e.goalId,"goalId"),E(e.expectedVersion,"expectedVersion"),h(e.reason,"reason"));break;case"goal.steer":n=await d.steerGoal(r,h(e.goalId,"goalId"),E(e.expectedVersion,"expectedVersion"),h(e.instruction,"instruction"));break;case"loop.start":n=await d.startLoop({sessionId:r,kind:h(e.kind,"kind"),...typeof e.goalId=="string"?{goalId:e.goalId}:{},...typeof e.activity=="string"?{activity:e.activity}:{},...e.schedule?{schedule:S(e.schedule,"schedule")}:{}});break;case"loop.get":n=await d.getLoop(r,typeof e.loopId=="string"?e.loopId:void 0);break;case"loop.begin":n=await d.beginLoopIteration(r,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 d.finishLoopIteration(r,h(e.loopId,"loopId"),E(e.expectedVersion,"expectedVersion"),S(e.result,"result"));break;case"loop.set_status":n=await d.setLoopStatus(r,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 d.acquireOwnership(r,h(e.ownerId,"ownerId"),S(e.options??{},"options"));break;case"ownership.renew":n=await d.renewOwnership(r,h(e.ownerId,"ownerId"),h(e.leaseId,"leaseId"),typeof e.leaseMs=="number"?e.leaseMs:void 0);break;case"ownership.release":n=await d.releaseOwnership(r,h(e.ownerId,"ownerId"),h(e.leaseId,"leaseId"));break;case"handoff.create":n=await d.createHandoff({sessionId:r,...e});break;case"handoff.claim":n=await d.claimHandoff({sessionId:r,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 d.completeHandoff(r,h(e.handoffId,"handoffId"),h(e.ownerId,"ownerId"),h(e.leaseId,"leaseId"));break;case"handoff.fail":n=await d.failHandoff(r,h(e.handoffId,"handoffId"),h(e.reason,"reason"));break}let o=await d.getSessionState(r),i=s==="state.get"||s==="loop.get"?void 0:o.events.at(-1);return{action:s,sessionId:r,result:n,state:o,...i?{event:i}:{}}}var P=require("node:crypto"),H=require("node:os");var G=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,H.hostname)(),this.ownerId=t.ownerId??`runtime:${this.host}:${this.processId}:${(0,P.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 s=await this.assertOwned(),r=await this.store.createHandoff({...t,sessionId:this.sessionId,sourceOwnerId:s.ownerId,sourceLeaseId:s.leaseId});return this.preparedHandoffId=r.id,r}async stop(t={}){if(this.stopped)return;this.stopped=!0,this.timer&&clearInterval(this.timer),this.timer=void 0;let s=this.owner;if(this.owner=void 0,!(t.release===!1||this.preparedHandoffId||!s||this.lostError))try{await this.store.releaseOwnership(this.sessionId,s.ownerId,s.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_MANAGED_SESSION_SCHEMA_VERSION,XENO_COORDINATION_SCHEMA_VERSION,XenoCoordinationError,XenoExecutionLeaseSession,executeXenoCoordinationAction});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
declare const XENO_COORDINATION_SCHEMA_VERSION: 1;
|
|
2
|
+
declare const XENO_COORDINATION_MANAGED_SESSION_SCHEMA_VERSION: 2;
|
|
2
3
|
type XenoGoalStatus = "active" | "paused" | "waiting" | "blocked" | "completed" | "failed" | "cancelled";
|
|
3
4
|
type XenoGoalTaskStatus = "pending" | "ready" | "running" | "blocked" | "failed" | "completed" | "cancelled" | "interrupted";
|
|
4
5
|
interface XenoGoalCriterion {
|
|
@@ -166,7 +167,7 @@ interface XenoExecutionOwner {
|
|
|
166
167
|
processId?: number;
|
|
167
168
|
host?: string;
|
|
168
169
|
}
|
|
169
|
-
type XenoCoordinationEventType = "goal.created" | "goal.updated" | "goal.steered" | "goal.completed" | "goal.cancelled" | "loop.started" | "loop.iteration" | "loop.paused" | "loop.waiting" | "loop.resumed" | "loop.stopped" | "loop.completed" | "loop.failed" | "handoff.created" | "handoff.claimed" | "handoff.completed" | "handoff.failed" | "ownership.acquired" | "ownership.renewed" | "ownership.released";
|
|
170
|
+
type XenoCoordinationEventType = "goal.created" | "goal.updated" | "goal.steered" | "goal.completed" | "goal.cancelled" | "loop.started" | "loop.iteration" | "loop.paused" | "loop.waiting" | "loop.resumed" | "loop.stopped" | "loop.completed" | "loop.failed" | "handoff.created" | "handoff.claimed" | "handoff.completed" | "handoff.failed" | "ownership.acquired" | "admission.fenced" | "admission.restored" | "ownership.renewed" | "ownership.released";
|
|
170
171
|
interface XenoCoordinationEvent {
|
|
171
172
|
schemaVersion: typeof XENO_COORDINATION_SCHEMA_VERSION;
|
|
172
173
|
id: string;
|
|
@@ -181,10 +182,11 @@ interface XenoCoordinationEvent {
|
|
|
181
182
|
data: Record<string, unknown>;
|
|
182
183
|
}
|
|
183
184
|
interface XenoCoordinationSessionState {
|
|
184
|
-
schemaVersion: typeof XENO_COORDINATION_SCHEMA_VERSION;
|
|
185
|
+
schemaVersion: typeof XENO_COORDINATION_SCHEMA_VERSION | typeof XENO_COORDINATION_MANAGED_SESSION_SCHEMA_VERSION;
|
|
185
186
|
sessionId: string;
|
|
186
187
|
version: number;
|
|
187
188
|
ownershipEpoch: number;
|
|
189
|
+
admissionFence?: XenoCoordinationAdmissionFence;
|
|
188
190
|
owner?: XenoExecutionOwner;
|
|
189
191
|
goals: XenoGoalRecord[];
|
|
190
192
|
loops: XenoLoopRecord[];
|
|
@@ -193,6 +195,13 @@ interface XenoCoordinationSessionState {
|
|
|
193
195
|
createdAt: string;
|
|
194
196
|
updatedAt: string;
|
|
195
197
|
}
|
|
198
|
+
interface XenoCoordinationAdmissionFence {
|
|
199
|
+
schemaVersion: 1;
|
|
200
|
+
authorityId: string;
|
|
201
|
+
operationId: string;
|
|
202
|
+
action: "archive" | "delete";
|
|
203
|
+
createdAt: string;
|
|
204
|
+
}
|
|
196
205
|
interface XenoCoordinationStoreOptions {
|
|
197
206
|
rootDirectory?: string;
|
|
198
207
|
now?: () => string;
|
|
@@ -267,6 +276,9 @@ declare class DurableXenoCoordinationStore {
|
|
|
267
276
|
private readonly maximumEventsPerSession;
|
|
268
277
|
constructor(options?: XenoCoordinationStoreOptions);
|
|
269
278
|
getSessionState(sessionId: string): Promise<XenoCoordinationSessionState>;
|
|
279
|
+
fenceAdmission(sessionId: string, expectedVersion: number, input: Omit<XenoCoordinationAdmissionFence, "schemaVersion" | "createdAt">): Promise<XenoCoordinationAdmissionFence>;
|
|
280
|
+
clearAdmissionFence(sessionId: string, expectedVersion: number, authorityId: string, operationId: string): Promise<void>;
|
|
281
|
+
releaseDeadLifecycleOwner(sessionId: string, expectedVersion: number, authorityId: string, operationId: string): Promise<void>;
|
|
270
282
|
listSessionStates(): Promise<XenoCoordinationSessionState[]>;
|
|
271
283
|
createGoal(input: CreateXenoGoalInput): Promise<XenoGoalRecord>;
|
|
272
284
|
getGoal(sessionId: string, goalId?: string): Promise<XenoGoalRecord | undefined>;
|
|
@@ -392,4 +404,4 @@ declare class XenoExecutionLeaseSession {
|
|
|
392
404
|
private heartbeat;
|
|
393
405
|
private markLost;
|
|
394
406
|
}
|
|
395
|
-
export { type ClaimXenoHandoffInput, type CreateXenoGoalInput, type CreateXenoHandoffInput, DurableXenoCoordinationStore, type ExecuteXenoCoordinationActionInput, type ExecuteXenoCoordinationActionResult, type StartXenoLoopInput, type UpdateXenoGoalInput, XENO_COORDINATION_SCHEMA_VERSION, type XenoCoordinationAction, XenoCoordinationError, type XenoCoordinationEvent, type XenoCoordinationEventType, type XenoCoordinationSessionState, type XenoCoordinationStoreOptions, XenoExecutionLeaseSession, type XenoExecutionLeaseSessionOptions, type XenoExecutionOwner, type XenoGoalCriterion, type XenoGoalCriterionResult, type XenoGoalMilestone, type XenoGoalProgress, type XenoGoalRecord, type XenoGoalStatus, type XenoGoalTask, type XenoGoalTaskStatus, type XenoGoalVerification, type XenoHandoffOperation, type XenoHandoffRecord, type XenoHandoffStatus, type XenoLoopIteration, type XenoLoopKind, type XenoLoopRecord, type XenoLoopSchedule, type XenoLoopStatus, executeXenoCoordinationAction };
|
|
407
|
+
export { type ClaimXenoHandoffInput, type CreateXenoGoalInput, type CreateXenoHandoffInput, DurableXenoCoordinationStore, type ExecuteXenoCoordinationActionInput, type ExecuteXenoCoordinationActionResult, type StartXenoLoopInput, type UpdateXenoGoalInput, XENO_COORDINATION_MANAGED_SESSION_SCHEMA_VERSION, XENO_COORDINATION_SCHEMA_VERSION, type XenoCoordinationAction, type XenoCoordinationAdmissionFence, XenoCoordinationError, type XenoCoordinationEvent, type XenoCoordinationEventType, type XenoCoordinationSessionState, type XenoCoordinationStoreOptions, XenoExecutionLeaseSession, type XenoExecutionLeaseSessionOptions, type XenoExecutionOwner, type XenoGoalCriterion, type XenoGoalCriterionResult, type XenoGoalMilestone, type XenoGoalProgress, type XenoGoalRecord, type XenoGoalStatus, type XenoGoalTask, type XenoGoalTaskStatus, type XenoGoalVerification, type XenoHandoffOperation, type XenoHandoffRecord, type XenoHandoffStatus, type XenoLoopIteration, type XenoLoopKind, type XenoLoopRecord, type XenoLoopSchedule, type XenoLoopStatus, executeXenoCoordinationAction };
|