@myagentroam/node 0.9.62 → 0.9.65
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/LICENSE +202 -0
- package/NOTICE +4 -0
- package/dist/capabilities.js +110 -2
- package/dist/claude-agent-sdk.js +330 -2
- package/dist/claude-channel.js +44 -2
- package/dist/codex-app-server.js +510 -2
- package/dist/config.js +106 -2
- package/dist/connector/node-connector-options.js +1 -2
- package/dist/connector/node-operation-router.js +22 -2
- package/dist/connector.js +1736 -2
- package/dist/control-outbound-scheduler.js +153 -2
- package/dist/database.js +639 -2
- package/dist/fake-runner.js +129 -2
- package/dist/git-askpass.js +12 -0
- package/dist/git-execution-helper.js +266 -0
- package/dist/health.js +3 -2
- package/dist/main.js +57 -2
- package/dist/mcp-installation-model.js +1 -2
- package/dist/migrations/v004.js +55 -3
- package/dist/migrations/v005.js +13 -3
- package/dist/migrations/v006.js +90 -3
- package/dist/migrations/v007.js +22 -3
- package/dist/migrations/v008.js +18 -3
- package/dist/migrations/v009.js +70 -4
- package/dist/migrations/v010.js +43 -3
- package/dist/migrations/v011.js +20 -3
- package/dist/migrations/v012.js +8 -0
- package/dist/native-jsonl-reader.js +186 -2
- package/dist/native-session-history.js +1143 -2
- package/dist/opencode-runtime.js +80 -2
- package/dist/opencode-server.js +259 -2
- package/dist/operational.js +122 -2
- package/dist/process-tree.js +18 -2
- package/dist/ripgrep-binary.js +31 -2
- package/dist/rotating-log.js +67 -2
- package/dist/runner/abstract-runner.js +260 -2
- package/dist/runner/claude/managed-run-controller.js +355 -2
- package/dist/runner/claude/tool-normalizer.js +120 -2
- package/dist/runner/claude-code-runner.js +303 -2
- package/dist/runner/codex/composer-image-markers.js +8 -2
- package/dist/runner/codex/conversation-parser.js +913 -2
- package/dist/runner/codex/managed-run-controller.js +494 -2
- package/dist/runner/codex/tool-normalizer.js +214 -2
- package/dist/runner/codex-runner.js +585 -2
- package/dist/runner/fake-test-runner.js +47 -2
- package/dist/runner/mar-agent/conversation-normalizer.js +644 -2
- package/dist/runner/mar-agent/executor-stdio-client-transport.js +139 -2
- package/dist/runner/mar-agent/generated-images.js +41 -2
- package/dist/runner/mar-agent/history-projection.js +106 -2
- package/dist/runner/mar-agent/hosted-conversation-runtime.js +446 -2
- package/dist/runner/mar-agent/managed-run-controller.js +785 -2
- package/dist/runner/mar-agent/mcp-client-pool.js +233 -2
- package/dist/runner/mar-agent/runtime-model-factory.js +326 -2
- package/dist/runner/mar-agent-runner.js +458 -2
- package/dist/runner/opencode/conversation-parser.js +221 -2
- package/dist/runner/opencode/managed-run-controller.js +588 -2
- package/dist/runner/opencode/tool-normalizer.js +80 -2
- package/dist/runner/opencode-runner.js +426 -2
- package/dist/runner/runner-registry.js +87 -2
- package/dist/runner-command-engine.js +71 -2
- package/dist/runner-profiles.js +323 -2
- package/dist/runner-usage.js +190 -2
- package/dist/runtime-command-detector.js +73 -2
- package/dist/runtime-model.js +1 -2
- package/dist/runtime-state.js +1509 -2
- package/dist/service/attachment-domain-state.js +7 -2
- package/dist/service/bubblewrap-sandbox-executor.js +543 -2
- package/dist/service/continuous-run-coordinator.js +425 -2
- package/dist/service/conversation-history-service.js +552 -2
- package/dist/service/conversation-hosting-capability-service.js +61 -2
- package/dist/service/conversation-hosting-enablement-service.js +91 -2
- package/dist/service/conversation-hosting-maintenance-service.js +174 -2
- package/dist/service/conversation-segment-service.js +162 -2
- package/dist/service/conversation-template-node-service.js +992 -2
- package/dist/service/external-session-resume-service.js +152 -2
- package/dist/service/fake-managed-run-service.js +60 -2
- package/dist/service/git-execution-service.js +418 -0
- package/dist/service/git-operation-service.js +57 -0
- package/dist/service/hosted-conversation-node-service.js +1982 -2
- package/dist/service/hosted-conversation-store.js +1405 -2
- package/dist/service/managed-runner-session-service.js +35 -2
- package/dist/service/mar-agent-model-transport-test-service.js +88 -2
- package/dist/service/mcp-installation-verifier.js +87 -2
- package/dist/service/mcp-node-operation-service.js +90 -2
- package/dist/service/mission-mcp-server.js +124 -2
- package/dist/service/mission-mcp-stdio.js +40 -2
- package/dist/service/mission-runtime.js +142 -2
- package/dist/service/native-session-projection-service.js +274 -2
- package/dist/service/native-session-watch-service.js +683 -2
- package/dist/service/node-connection-lifecycle-service.js +88 -2
- package/dist/service/node-control-channel.js +85 -2
- package/dist/service/node-control-message-service.js +109 -2
- package/dist/service/node-request-service.js +62 -2
- package/dist/service/node-run-event-bridge.js +88 -2
- package/dist/service/node-terminal-channel.js +202 -2
- package/dist/service/node-upgrade-coordinator.js +137 -2
- package/dist/service/node-workspace-coordinator.js +97 -2
- package/dist/service/recent-run-projection-service.js +99 -2
- package/dist/service/run-attachment-service.js +321 -2
- package/dist/service/run-domain-state.js +4 -2
- package/dist/service/run-event-service.js +246 -2
- package/dist/service/run-ownership-policy.js +22 -2
- package/dist/service/run-workbench-service.js +120 -2
- package/dist/service/runner-channel-message-service.js +20 -2
- package/dist/service/runner-interaction-service.js +243 -2
- package/dist/service/runner-service.js +69 -2
- package/dist/service/runtime-credential-control-service.js +95 -2
- package/dist/service/session-catalog-service.js +404 -2
- package/dist/service/session-command-service.js +125 -2
- package/dist/service/session-context-service.js +128 -2
- package/dist/service/session-domain-state.js +9 -2
- package/dist/service/session-identity-service.js +86 -2
- package/dist/service/session-lifecycle-service.js +248 -2
- package/dist/service/session-message-service.js +270 -2
- package/dist/service/session-presentation-service.js +43 -2
- package/dist/service/session-query-service.js +82 -2
- package/dist/service/session-watch-slot-coordinator.js +21 -2
- package/dist/service/skill-directory-service.js +238 -2
- package/dist/service/skill-install-service.js +434 -2
- package/dist/service/skill-node-operation-service.js +206 -2
- package/dist/service/terminal-relay-state.js +3 -2
- package/dist/service/terminal-service.js +90 -2
- package/dist/service/web-search-error.js +40 -2
- package/dist/service/workbench-event-service.js +21 -2
- package/dist/service/workbench-manifest-service.js +69 -2
- package/dist/service/workspace-change-service.js +290 -2
- package/dist/service/workspace-content-search-service.js +457 -2
- package/dist/service/workspace-domain-state.js +41 -2
- package/dist/service/workspace-file-service.js +150 -2
- package/dist/service/workspace-git-exclude-service.js +119 -2
- package/dist/service/workspace-queue-workbench-service.js +176 -2
- package/dist/service/workspace-service.js +92 -2
- package/dist/service/workspace-session-service.js +154 -2
- package/dist/service/workspace-upload-service.js +262 -2
- package/dist/service/workspace-watch-controller.js +68 -2
- package/dist/service/workspace-watch-service.js +170 -2
- package/dist/service/workspace-watch-snapshot-service.js +218 -2
- package/dist/service/workspace-workbench-service.js +239 -2
- package/dist/service.js +91 -2
- package/dist/storage.js +32 -2
- package/dist/supervisor.js +136 -2
- package/dist/terminal.js +496 -2
- package/dist/util/git-credential-client.js +32 -0
- package/dist/util/node-operation-data.js +9 -2
- package/dist/util/node-operation-parsers.js +382 -2
- package/dist/util/personal-instructions.js +34 -2
- package/dist/util/runner-error.js +70 -2
- package/dist/util/runner-native-session-parsers.js +510 -2
- package/dist/util/safe-error.js +8 -2
- package/dist/util/secret-environment.js +25 -2
- package/dist/workspace.js +1793 -2
- package/package.json +11 -8
- package/vendor/ripgrep/darwin-arm64/rg +0 -0
- package/vendor/ripgrep/darwin-x64/rg +0 -0
- package/vendor/ripgrep/manifest.json +12 -0
- package/README.md +0 -42
- package/dist/event-buffer.js +0 -2
- package/dist/migrations/v001.js +0 -107
- package/dist/migrations/v002.js +0 -2
- package/dist/migrations/v003.js +0 -2
- package/dist/service/mcp-package-installer.js +0 -2
|
@@ -1,2 +1,992 @@
|
|
|
1
|
-
|
|
2
|
-
const _0x10d0f3=_0x560c;(function(_0x377f2e,_0x5d8a03){const _0x5d8e5c=_0x560c,_0xe40166=_0x377f2e();while(!![]){try{const _0x51bc42=-parseInt(_0x5d8e5c(0x91))/(-0xe35+-0x2047+0x2e7d)*(-parseInt(_0x5d8e5c(0xee))/(0x16bf+-0x6*-0x5a9+0x1*-0x38b3))+-parseInt(_0x5d8e5c(0x173))/(0x6*0x58f+-0x1ca4*0x1+-0x4b3*0x1)+-parseInt(_0x5d8e5c(0x168))/(0x13*-0x197+0xa62+0x13d7)+parseInt(_0x5d8e5c(0x8a))/(0x1cd9+-0x1552+-0x782)*(-parseInt(_0x5d8e5c(0xfc))/(-0x1afd+-0x16cb+-0x18e7*-0x2))+parseInt(_0x5d8e5c(0x102))/(-0x1ad7+0x11a6+0x938)*(-parseInt(_0x5d8e5c(0x15d))/(-0x6af+0xcb3+0x4*-0x17f))+-parseInt(_0x5d8e5c(0x8f))/(-0x17a2+-0x1*0x1ee+0x1999*0x1)*(-parseInt(_0x5d8e5c(0x150))/(-0x95*0x26+0x35*0x9f+-0xac3))+parseInt(_0x5d8e5c(0xc8))/(0x445*0x3+-0x1f03+0x1*0x123f)*(parseInt(_0x5d8e5c(0x152))/(0x7*0x15b+0x1308+-0x1c79));if(_0x51bc42===_0x5d8a03)break;else _0xe40166['push'](_0xe40166['shift']());}catch(_0x24001c){_0xe40166['push'](_0xe40166['shift']());}}}(_0x4740,-0x9c04*0x1b+0xcb4b5+0xc74ac));import{createHash,randomUUID}from'node:crypto';import{chmod,copyFile,lstat,mkdir,readFile,readlink,readdir,realpath,rename,rm,statfs,symlink,writeFile}from'node:fs/promises';import{dirname,isAbsolute,join,relative,resolve,sep}from'node:path';import{conversationTemplateDraftSchema,conversationTemplatePublishJobSchema,conversationTemplatePublishRequestSchema,conversationTemplatePublishResultSchema,conversationTemplatePublishStatusInputSchema,conversationTemplateSourceInspectInputSchema,conversationTemplateSourceInspectionSchema,conversationTemplateVersionSchema}from'@myagentroam/protocol';import{safeErrorCode}from'../util/safe-error.js';const HOST_POLICY_VERSION=-0x99b+-0x5d0+-0x524*-0x3,FORCED_EXCLUDED_NAMES=new Set([_0x10d0f3(0xfd),_0x10d0f3(0xcd),_0x10d0f3(0x144),_0x10d0f3(0x10b),_0x10d0f3(0x111),_0x10d0f3(0xb9),_0x10d0f3(0xcf),_0x10d0f3(0x176)]),ROOT_EXCLUDED_NAMES=new Set([_0x10d0f3(0x12c),_0x10d0f3(0xdc),_0x10d0f3(0x125),_0x10d0f3(0xf2)]),ROOT_TEMPLATE_INSTRUCTIONS_SOURCE=_0x10d0f3(0xad),ROOT_TEMPLATE_INSTRUCTIONS_TARGET=_0x10d0f3(0x11c),RUNTIME_LINK_ROOTS=[_0x10d0f3(0x16c),_0x10d0f3(0x14d),_0x10d0f3(0x157),_0x10d0f3(0x104),_0x10d0f3(0xcc)],RESERVED_SANDBOX_ROOTS=[_0x10d0f3(0xbb),_0x10d0f3(0x14f),_0x10d0f3(0x18d),_0x10d0f3(0x16c),_0x10d0f3(0x14d),_0x10d0f3(0x157),_0x10d0f3(0x104),_0x10d0f3(0xcc),_0x10d0f3(0xb7),_0x10d0f3(0x141),_0x10d0f3(0xb8)];export class ConversationTemplateNodeService{[_0x10d0f3(0x8d)];[_0x10d0f3(0xff)];['id'];[_0x10d0f3(0xa7)]=new Map();constructor(_0x22f32e){const _0x39e87e=_0x10d0f3;this[_0x39e87e(0x8d)]=_0x22f32e,this[_0x39e87e(0xff)]=_0x22f32e[_0x39e87e(0xff)]??Date[_0x39e87e(0xff)],this['id']=_0x22f32e['id']??randomUUID;}[_0x10d0f3(0xac)](){const _0x566e6f=_0x10d0f3;return{'conversation.template.source.inspect':_0xceea83=>this[_0x566e6f(0x117)](_0xceea83),'conversation.template.publish':_0x48c536=>this[_0x566e6f(0x147)](_0x48c536),'conversation.template.publish.status':_0x27c51b=>this[_0x566e6f(0x95)](_0x27c51b),'conversation.template.version.inspect':_0x5d44c9=>this[_0x566e6f(0x96)](_0x5d44c9)};}async[_0x10d0f3(0x185)](){const _0x4fc9d6=_0x10d0f3;for(const _0x18bcf5 of await readdir(this[_0x4fc9d6(0x8d)][_0x4fc9d6(0x171)][_0x4fc9d6(0x120)],{'withFileTypes':!![]})){await writableRemove(join(this[_0x4fc9d6(0x8d)][_0x4fc9d6(0x171)][_0x4fc9d6(0x120)],_0x18bcf5[_0x4fc9d6(0xeb)]));}const _0x36874d=new Set(this[_0x4fc9d6(0x8d)][_0x4fc9d6(0x131)][_0x4fc9d6(0x143)][_0x4fc9d6(0x161)](_0x4fc9d6(0x164))[_0x4fc9d6(0x10d)]()[_0x4fc9d6(0x10e)](_0x235e87=>stringValue(_0x235e87,_0x4fc9d6(0x190))));for(const _0x1f25ed of await readdir(this[_0x4fc9d6(0x8d)][_0x4fc9d6(0x171)][_0x4fc9d6(0x8c)],{'withFileTypes':!![]})){if(_0x36874d[_0x4fc9d6(0x18f)](_0x1f25ed[_0x4fc9d6(0xeb)]))continue;await writableRemove(join(this[_0x4fc9d6(0x8d)][_0x4fc9d6(0x171)][_0x4fc9d6(0x8c)],_0x1f25ed[_0x4fc9d6(0xeb)]));}await this[_0x4fc9d6(0x154)](),this[_0x4fc9d6(0x8d)][_0x4fc9d6(0x131)][_0x4fc9d6(0x143)][_0x4fc9d6(0x161)](_0x4fc9d6(0xb2))[_0x4fc9d6(0xc6)](_0x4fc9d6(0xd7),this[_0x4fc9d6(0xff)]());}async[_0x10d0f3(0x117)](_0x3200b5){const _0x3d9f2d=_0x10d0f3,_0x2128d4=conversationTemplateSourceInspectInputSchema[_0x3d9f2d(0xdd)](nodeRequestPayload(_0x3200b5)[_0x3d9f2d(0x94)]),_0x2e0838=this[_0x3d9f2d(0x181)](_0x2128d4[_0x3d9f2d(0x116)][_0x3d9f2d(0x132)]);try{return await this[_0x3d9f2d(0x11b)](_0x2128d4[_0x3d9f2d(0x116)]),this[_0x3d9f2d(0x107)](_0x2128d4[_0x3d9f2d(0x116)]),conversationTemplateSourceInspectionSchema[_0x3d9f2d(0xdd)]({'valid':!![],'code':null,'message':_0x3d9f2d(0x12d),'checkedAt':this[_0x3d9f2d(0xff)](),'mcpServers':_0x2e0838});}catch(_0x3a7020){const _0x22f0dc=safeErrorCode(_0x3a7020,_0x3d9f2d(0x162));return conversationTemplateSourceInspectionSchema[_0x3d9f2d(0xdd)]({'valid':![],'code':_0x22f0dc,'message':_0x3d9f2d(0x12f)+_0x22f0dc+').','checkedAt':this[_0x3d9f2d(0xff)](),'mcpServers':_0x2e0838});}}async[_0x10d0f3(0x147)](_0x12abb6){const _0x248589=_0x10d0f3,_0x3cb0cd=nodeRequestPayload(_0x12abb6),_0x386bb6=conversationTemplatePublishRequestSchema[_0x248589(0xdd)](_0x3cb0cd[_0x248589(0x94)]);if(_0x3cb0cd[_0x248589(0x179)]!==undefined&&_0x3cb0cd[_0x248589(0x179)]!==_0x386bb6[_0x248589(0x122)])throw new Error(_0x248589(0x175));this[_0x248589(0x133)](_0x386bb6[_0x248589(0x116)]);const _0x450142=this[_0x248589(0x115)](_0x386bb6[_0x248589(0x112)]);if(_0x450142!==undefined){if(numberValue(_0x450142,_0x248589(0x14b))!==_0x386bb6[_0x248589(0x122)])throw new Error(_0x248589(0x175));if(stringValue(_0x450142,_0x248589(0x158))!==_0x386bb6[_0x248589(0x17e)]||numberValue(_0x450142,_0x248589(0xd5))!==_0x386bb6[_0x248589(0x116)][_0x248589(0x172)]||stringValue(_0x450142,_0x248589(0x116))!==JSON[_0x248589(0x18c)](_0x386bb6[_0x248589(0x116)]))throw new Error(_0x248589(0x9b));return this[_0x248589(0xce)](_0x450142);}const _0x23271a=this[_0x248589(0xff)]();return this[_0x248589(0x8d)][_0x248589(0x131)][_0x248589(0x143)][_0x248589(0x161)](_0x248589(0x139))[_0x248589(0xc6)](_0x386bb6[_0x248589(0x112)],_0x386bb6[_0x248589(0x17e)],_0x386bb6[_0x248589(0x116)][_0x248589(0x172)],_0x386bb6[_0x248589(0x122)],JSON[_0x248589(0x18c)](_0x386bb6[_0x248589(0x116)]),_0x23271a,_0x23271a),this[_0x248589(0xe4)](_0x386bb6),this[_0x248589(0xce)](this[_0x248589(0x124)](_0x386bb6[_0x248589(0x112)]));}[_0x10d0f3(0xe4)](_0x46b884){queueMicrotask(()=>{const _0x32ba6c=_0x560c,_0x4be6c0=this[_0x32ba6c(0xa7)][_0x32ba6c(0xe8)](_0x46b884[_0x32ba6c(0x17e)])??Promise[_0x32ba6c(0x123)](),_0x4f623e=_0x4be6c0[_0x32ba6c(0x14e)](()=>undefined)[_0x32ba6c(0xfe)](()=>this[_0x32ba6c(0x99)](_0x46b884))[_0x32ba6c(0xb6)](()=>{const _0x4eb3e0=_0x32ba6c;if(this[_0x4eb3e0(0xa7)][_0x4eb3e0(0xe8)](_0x46b884[_0x4eb3e0(0x17e)])===_0x4f623e)this[_0x4eb3e0(0xa7)][_0x4eb3e0(0x105)](_0x46b884[_0x4eb3e0(0x17e)]);});this[_0x32ba6c(0xa7)][_0x32ba6c(0xa9)](_0x46b884[_0x32ba6c(0x17e)],_0x4f623e);});}[_0x10d0f3(0x95)](_0x118625){const _0x3d84ff=_0x10d0f3,_0x3fc5c0=conversationTemplatePublishStatusInputSchema[_0x3d84ff(0xdd)](nodeRequestPayload(_0x118625)[_0x3d84ff(0x94)]),_0x39377e=this[_0x3d84ff(0x124)](_0x3fc5c0[_0x3d84ff(0x112)]);if(stringValue(_0x39377e,_0x3d84ff(0x158))!==_0x3fc5c0[_0x3d84ff(0x17e)])throw new Error(_0x3d84ff(0x17d));return this[_0x3d84ff(0xce)](_0x39377e);}async[_0x10d0f3(0x96)](_0x3554c3){const _0x1bb6a9=_0x10d0f3;_0x3554c3=nodeRequestPayload(_0x3554c3)[_0x1bb6a9(0x94)];if(!record(_0x3554c3)||typeof _0x3554c3[_0x1bb6a9(0x17e)]!==_0x1bb6a9(0x14c)||typeof _0x3554c3[_0x1bb6a9(0xae)]!==_0x1bb6a9(0x14c)||Object[_0x1bb6a9(0x165)](_0x3554c3)[_0x1bb6a9(0x16a)]!==0x1377+-0x1*0x2304+0xf8f)throw new Error(_0x1bb6a9(0x142));const _0x4f7999=this[_0x1bb6a9(0x8d)][_0x1bb6a9(0x131)][_0x1bb6a9(0x143)][_0x1bb6a9(0x161)](_0x1bb6a9(0xbd))[_0x1bb6a9(0xe8)](_0x3554c3[_0x1bb6a9(0xae)],_0x3554c3[_0x1bb6a9(0x17e)]);if(_0x4f7999===undefined)throw new Error(_0x1bb6a9(0xf9));const _0x3a8a0f=templateVersion(_0x4f7999);try{await this[_0x1bb6a9(0x166)](_0x4f7999);if(_0x3a8a0f[_0x1bb6a9(0xbc)]===_0x1bb6a9(0xea))throw new Error(_0x1bb6a9(0x156));return{'valid':!![],'code':null,'message':_0x1bb6a9(0x136),'checkedAt':this[_0x1bb6a9(0xff)](),'version':_0x3a8a0f};}catch(_0x2ccba5){const _0x49ad97=safeErrorCode(_0x2ccba5,_0x1bb6a9(0x156));return this[_0x1bb6a9(0x8d)][_0x1bb6a9(0x131)][_0x1bb6a9(0x143)][_0x1bb6a9(0x161)](_0x1bb6a9(0x101))[_0x1bb6a9(0xc6)](_0x3a8a0f['id']),{'valid':![],'code':_0x49ad97,'message':_0x1bb6a9(0x11e)+_0x49ad97+').','checkedAt':this[_0x1bb6a9(0xff)](),'version':{..._0x3a8a0f,'status':_0x1bb6a9(0xea)}};}}async[_0x10d0f3(0x99)](_0x4cac41){const _0x15e782=_0x10d0f3,_0x1f6a47=_0x15e782(0x103)+createHash(_0x15e782(0x9c))[_0x15e782(0x198)](_0x4cac41[_0x15e782(0x112)])[_0x15e782(0xa6)](_0x15e782(0x182)),_0xd37bf2=this[_0x15e782(0x8d)][_0x15e782(0x171)][_0x15e782(0x153)](_0x1f6a47);let _0x5842ec,_0x1f5671=_0x15e782(0x113);try{await this[_0x15e782(0x154)](_0x4cac41[_0x15e782(0x17e)]),this[_0x15e782(0x121)](_0x4cac41[_0x15e782(0x112)],_0x1f5671,_0x15e782(0x135));const _0x232e7e=await this[_0x15e782(0x11b)](_0x4cac41[_0x15e782(0x116)]),_0x3bdc3e=_0x232e7e[_0x15e782(0x13d)],_0x5164eb=this[_0x15e782(0x107)](_0x4cac41[_0x15e782(0x116)]),_0x369f70=hashText(JSON[_0x15e782(0x18c)](_0x5164eb));_0x1f5671=_0x15e782(0x16b),this[_0x15e782(0x121)](_0x4cac41[_0x15e782(0x112)],_0x1f5671,_0x15e782(0x135)),await rm(_0xd37bf2,{'recursive':!![],'force':!![]});const _0x58f0d0=join(_0xd37bf2,_0x15e782(0x108));await mkdir(_0x58f0d0,{'recursive':!![],'mode':0x1c0});for(const _0x331743 of _0x232e7e[_0x15e782(0x11f)])await mkdir(join(_0x58f0d0,..._0x331743[_0x15e782(0x15b)]('/')),{'recursive':!![],'mode':0x1c0});_0x1f5671=_0x15e782(0x178),this[_0x15e782(0x121)](_0x4cac41[_0x15e782(0x112)],_0x1f5671,_0x15e782(0x135));for(const _0x19e885 of _0x3bdc3e){const _0x272c2e=join(_0x58f0d0,..._0x19e885[_0x15e782(0x18e)][_0x15e782(0x15b)]('/'));await mkdir(dirname(_0x272c2e),{'recursive':!![],'mode':0x1c0});if(_0x19e885[_0x15e782(0xab)]===_0x15e782(0xf5)){const _0x298902=await lstat(_0x19e885[_0x15e782(0x17c)]);if(!_0x298902[_0x15e782(0x93)]()||await readlink(_0x19e885[_0x15e782(0x17c)])!==_0x19e885[_0x15e782(0x151)])throw new Error(_0x15e782(0x167));await symlink(_0x19e885[_0x15e782(0x151)],_0x272c2e);const _0x7d3ef5=await readlink(_0x272c2e);if(_0x7d3ef5!==_0x19e885[_0x15e782(0x151)])throw new Error(_0x15e782(0x167));continue;}await copyFile(_0x19e885[_0x15e782(0x17c)],_0x272c2e);const _0x18a146=await lstat(_0x272c2e);if(!_0x18a146[_0x15e782(0xa8)]()||_0x18a146[_0x15e782(0x93)]()||_0x18a146[_0x15e782(0xa0)]!==-0xb*-0x17e+-0x1dcc+-0x1*-0xd63)throw new Error(_0x15e782(0x16d));await chmod(_0x272c2e,_0x19e885[_0x15e782(0x140)]?0x1a2f+0x22eb+-0x3bad:-0x1f*-0xef+-0x20e4+0x517);}await Promise[_0x15e782(0x10d)]([_0x15e782(0x130),_0x15e782(0xc7)][_0x15e782(0x10e)](_0x18f6ad=>mkdir(join(_0x58f0d0,_0x18f6ad),{'recursive':!![],'mode':0x1c0}))),await sealDirectories(_0x58f0d0),_0x1f5671=_0x15e782(0xdb),this[_0x15e782(0x121)](_0x4cac41[_0x15e782(0x112)],_0x1f5671,_0x15e782(0x135)),await verifyCopiedSnapshot(_0x58f0d0,_0x232e7e[_0x15e782(0x11f)],_0x3bdc3e,!![]);const _0x307625=this[_0x15e782(0xfa)](_0x4cac41[_0x15e782(0x17e)]),_0x491fb4=this['id'](),_0xabdcd2=this[_0x15e782(0xff)](),_0x1eafe1=snapshotContentHash(_0x232e7e[_0x15e782(0x11f)],_0x3bdc3e),_0x4d472a={'schemaVersion':0x2,'templateId':_0x4cac41[_0x15e782(0x17e)],'versionId':_0x491fb4,'versionNumber':_0x307625,'draftRevision':_0x4cac41[_0x15e782(0x116)][_0x15e782(0x172)],'hostPolicyVersion':HOST_POLICY_VERSION,'publishedByUserId':_0x4cac41[_0x15e782(0x122)],'publishedAt':_0xabdcd2,'sourceWorkspacePath':_0x232e7e[_0x15e782(0x92)],'draft':_0x4cac41[_0x15e782(0x116)],'directories':_0x232e7e[_0x15e782(0x11f)],'entries':_0x3bdc3e[_0x15e782(0x10e)](_0x2dec13=>_0x2dec13[_0x15e782(0xab)]===_0x15e782(0x195)?{'kind':_0x2dec13[_0x15e782(0xab)],'relativePath':_0x2dec13[_0x15e782(0x18e)],'size':_0x2dec13[_0x15e782(0x191)],'executable':_0x2dec13[_0x15e782(0x140)],'sha256':_0x2dec13[_0x15e782(0x9c)]}:{'kind':_0x2dec13[_0x15e782(0xab)],'relativePath':_0x2dec13[_0x15e782(0x18e)],'size':_0x2dec13[_0x15e782(0x191)],'linkTarget':_0x2dec13[_0x15e782(0x151)],'targetKind':_0x2dec13[_0x15e782(0xe7)],'resolvedTarget':_0x2dec13[_0x15e782(0xbf)]}),'contentHash':_0x1eafe1,'mcpServers':_0x5164eb,'mcpConfigHash':_0x369f70};_0x1f5671=_0x15e782(0x17f),this[_0x15e782(0x121)](_0x4cac41[_0x15e782(0x112)],_0x1f5671,_0x15e782(0x135));const _0x2e1459=JSON[_0x15e782(0x18c)](_0x4d472a),_0x92b91=hashText(_0x2e1459);await writeFile(join(_0xd37bf2,_0x15e782(0x11a)),_0x2e1459+'\x0a',{'mode':0x180}),await chmod(join(_0xd37bf2,_0x15e782(0x11a)),0x10b8+0x184*-0x12+0xbb4),_0x5842ec=this[_0x15e782(0x8d)][_0x15e782(0x171)][_0x15e782(0xf1)](_0x1f6a47),await rename(_0xd37bf2,_0x5842ec),await chmod(_0x5842ec,-0x17*0xcb+0x1*-0x15fb+0x29a5),_0x1f5671=_0x15e782(0x174),this[_0x15e782(0x121)](_0x4cac41[_0x15e782(0x112)],_0x1f5671,_0x15e782(0x135));const _0x1a6da9=conversationTemplateVersionSchema[_0x15e782(0xdd)]({'id':_0x491fb4,'templateId':_0x4cac41[_0x15e782(0x17e)],'version':_0x307625,'status':_0x15e782(0xbe),'contentHash':_0x1eafe1,'manifestHash':_0x92b91,'mcpConfigHash':_0x369f70,'fileCount':_0x3bdc3e[_0x15e782(0x16a)],'totalBytes':_0x3bdc3e[_0x15e782(0x186)]((_0x502c4d,_0x4501ca)=>_0x502c4d+_0x4501ca[_0x15e782(0x191)],-0xf86+-0x1*0x97+-0x7d*-0x21),'hostPolicyVersion':HOST_POLICY_VERSION,'publishedByUserId':_0x4cac41[_0x15e782(0x122)],'publishedAt':_0xabdcd2});this[_0x15e782(0xb0)](_0x4cac41[_0x15e782(0x112)],_0x1f6a47,_0x2e1459,_0x1a6da9),_0x1f5671=_0x15e782(0x188),await this[_0x15e782(0x15a)](_0x4cac41[_0x15e782(0x112)]);}catch(_0x460dd4){if(_0x1f5671===_0x15e782(0x188))return;await writableRemove(_0xd37bf2);if(_0x5842ec!==undefined)await writableRemove(_0x5842ec);const _0x2590aa=safeErrorCode(_0x460dd4,_0x15e782(0x119));this[_0x15e782(0x8d)][_0x15e782(0x131)][_0x15e782(0x143)][_0x15e782(0x161)](_0x15e782(0xc9))[_0x15e782(0xc6)](_0x1f5671,_0x2590aa,_0x15e782(0x138)+_0x2590aa+').',this[_0x15e782(0xff)](),_0x4cac41[_0x15e782(0x112)]);}}async[_0x10d0f3(0x11b)](_0x24a57f){const _0x3c34b4=_0x10d0f3;this[_0x3c34b4(0x133)](_0x24a57f);const _0x22ed78=this[_0x3c34b4(0x8d)][_0x3c34b4(0x131)][_0x3c34b4(0xba)](_0x24a57f[_0x3c34b4(0x132)]);if(_0x22ed78===undefined)throw new Error(_0x3c34b4(0xc3));const _0x678b79=await realpath(_0x22ed78[_0x3c34b4(0x127)]),_0x4be485=this[_0x3c34b4(0x8d)][_0x3c34b4(0x92)]?.(_0x678b79)??_0x678b79;validateSourceWorkspacePath(_0x4be485);const _0x272345=new Set(),_0x4ae3c6=new Map();let _0x5d8d02=-0x501+0x4d8+0x29*0x1;const _0x235b2d=await hostedFilesystemAvailableBytes(this[_0x3c34b4(0x8d)][_0x3c34b4(0x171)][_0x3c34b4(0x145)]);return await walkWorkspace(_0x678b79,'',{'directory':_0x405f25=>{const _0x213379=_0x3c34b4;_0x272345[_0x213379(0x13e)](_0x405f25);},'file':async(_0x1b5c11,_0x4ef9c4,_0x5230f4)=>{const _0x1ce952=_0x3c34b4;if(_0x4ae3c6[_0x1ce952(0x18f)](_0x4ef9c4))return;const _0x3732c1=Number(_0x5230f4[_0x1ce952(0x191)]);_0x5d8d02+=_0x3732c1;if(!Number[_0x1ce952(0x160)](_0x5d8d02)||_0x5d8d02>_0x235b2d)throw new Error(_0x1ce952(0xa1));_0x4ae3c6[_0x1ce952(0xa9)](_0x4ef9c4,{'kind':_0x1ce952(0x195),'relativePath':_0x4ef9c4,'sourcePath':_0x1b5c11,'size':_0x3732c1,'executable':(Number(_0x5230f4[_0x1ce952(0x13a)])&0x13eb+-0x562*0x4+0x1e6)!==-0x13c1*-0x1+0x1f81+-0x3342,'sha256':hashBuffer(await readFile(_0x1b5c11))});},'symlink':async(_0x110e11,_0x3e9314,_0x480f04)=>{const _0x1fe396=_0x3c34b4;if(_0x4ae3c6[_0x1fe396(0x18f)](_0x3e9314))return;const _0x320808=await publishedSymlink(_0x678b79,_0x110e11,_0x3e9314,_0x480f04);_0x5d8d02+=_0x320808[_0x1fe396(0x191)];if(!Number[_0x1fe396(0x160)](_0x5d8d02)||_0x5d8d02>_0x235b2d)throw new Error(_0x1fe396(0xa1));_0x4ae3c6[_0x1fe396(0xa9)](_0x3e9314,_0x320808);}}),{'sourceWorkspacePath':_0x4be485,'directories':[..._0x272345][_0x3c34b4(0x114)]((_0x5a0e85,_0x222cc4)=>_0x5a0e85[_0x3c34b4(0xc5)](_0x222cc4,_0x3c34b4(0xd0))),'entries':[..._0x4ae3c6[_0x3c34b4(0x134)]()][_0x3c34b4(0x114)]((_0x5db361,_0x29a4a5)=>_0x5db361[_0x3c34b4(0x18e)][_0x3c34b4(0xc5)](_0x29a4a5[_0x3c34b4(0x18e)],_0x3c34b4(0xd0)))};}[_0x10d0f3(0x181)](_0x58c610){const _0xc8b882=_0x10d0f3;return this[_0xc8b882(0x8d)][_0xc8b882(0x131)][_0xc8b882(0x15e)](_0x58c610)[_0xc8b882(0x10e)](_0x3d9175=>({'id':_0x3d9175[_0xc8b882(0x13c)],'serverName':_0x3d9175[_0xc8b882(0xcb)],'displayName':_0x3d9175[_0xc8b882(0x149)],'transport':_0x3d9175[_0xc8b882(0xfb)][_0xc8b882(0x109)],'origin':_0x3d9175[_0xc8b882(0xe7)]}));}[_0x10d0f3(0x107)](_0x1efedb){const _0x52df9e=_0x10d0f3,_0x163228=new Map(this[_0x52df9e(0x8d)][_0x52df9e(0x131)][_0x52df9e(0x15e)](_0x1efedb[_0x52df9e(0x132)])[_0x52df9e(0x10e)](_0x56bd71=>[_0x56bd71[_0x52df9e(0x13c)],_0x56bd71]));return _0x1efedb[_0x52df9e(0xca)][_0x52df9e(0x10e)](_0x1189cb=>{const _0x8d8e43=_0x52df9e,_0x425d0a=_0x163228[_0x8d8e43(0xe8)](_0x1189cb);if(_0x425d0a===undefined||_0x425d0a[_0x8d8e43(0xfb)][_0x8d8e43(0x109)]===_0x8d8e43(0x183)&&_0x1efedb[_0x8d8e43(0xe5)]!==_0x8d8e43(0x137))throw new Error(_0x8d8e43(0x9d));return{'id':_0x425d0a[_0x8d8e43(0x13c)],'serverName':_0x425d0a[_0x8d8e43(0xcb)],'displayName':_0x425d0a[_0x8d8e43(0x149)],'version':_0x425d0a[_0x8d8e43(0xd9)],'origin':_0x425d0a[_0x8d8e43(0xe7)],'transport':_0x425d0a[_0x8d8e43(0xfb)][_0x8d8e43(0x109)],'runtime':_0x425d0a[_0x8d8e43(0xfb)],'configuration':_0x425d0a[_0x8d8e43(0xde)]};});}[_0x10d0f3(0x133)](_0x3df188){const _0x4922c7=_0x10d0f3,_0x36c8ab=conversationTemplateDraftSchema[_0x4922c7(0xdd)](_0x3df188);if(_0x36c8ab[_0x4922c7(0x148)]!==this[_0x4922c7(0x8d)][_0x4922c7(0x148)]())throw new Error(_0x4922c7(0x162));}[_0x10d0f3(0xfa)](_0x3e99e7){const _0x2d0481=_0x10d0f3,_0x5ee2ac=this[_0x2d0481(0x8d)][_0x2d0481(0x131)][_0x2d0481(0x143)][_0x2d0481(0x161)](_0x2d0481(0x155))[_0x2d0481(0xe8)](_0x3e99e7);return numberValue(_0x5ee2ac,_0x2d0481(0x15f))+(-0x1c1+-0x573+0x735);}[_0x10d0f3(0xb0)](_0x118293,_0x1115b4,_0x30c568,_0x1fbe8e){const _0x291e08=_0x10d0f3,_0x29a3ee=this[_0x291e08(0x8d)][_0x291e08(0x131)][_0x291e08(0x143)];_0x29a3ee[_0x291e08(0x98)](_0x291e08(0x169));try{const _0x197045=this[_0x291e08(0x124)](_0x118293);if(stringValue(_0x197045,_0x291e08(0x158))!==_0x1fbe8e[_0x291e08(0x17e)]||stringValue(_0x197045,_0x291e08(0x194))!==_0x291e08(0x174)||stringValue(_0x197045,_0x291e08(0xbc))!==_0x291e08(0x135)||_0x197045[_0x291e08(0x17a)]!==null||numberValue(_0x197045,_0x291e08(0x14b))!==_0x1fbe8e[_0x291e08(0x10f)])throw new Error(_0x291e08(0x156));const _0x23799f=_0x29a3ee[_0x291e08(0x161)](_0x291e08(0xf0))[_0x291e08(0xc6)](_0x1fbe8e['id'],_0x1fbe8e[_0x291e08(0x17e)],_0x1fbe8e[_0x291e08(0xd9)],numberValue(_0x197045,_0x291e08(0xd5)),_0x1fbe8e[_0x291e08(0xbc)],_0x1115b4,_0x30c568,_0x1fbe8e[_0x291e08(0x14a)],_0x1fbe8e[_0x291e08(0x17b)],_0x1fbe8e[_0x291e08(0xe0)],_0x1fbe8e[_0x291e08(0xb5)],_0x1fbe8e[_0x291e08(0xe6)],_0x1fbe8e[_0x291e08(0xaa)],_0x1fbe8e[_0x291e08(0x10f)],_0x1fbe8e[_0x291e08(0x16f)]);if(Number(_0x23799f[_0x291e08(0x129)])!==0x9f5+0x37b+-0xd6f)throw new Error(_0x291e08(0x156));const _0x2bb858=_0x29a3ee[_0x291e08(0x161)](_0x291e08(0x12a))[_0x291e08(0xc6)](_0x1fbe8e['id'],_0x1fbe8e[_0x291e08(0x16f)],_0x118293,_0x1fbe8e[_0x291e08(0x17e)],numberValue(_0x197045,_0x291e08(0xd5)),_0x1fbe8e[_0x291e08(0x10f)]);if(Number(_0x2bb858[_0x291e08(0x129)])!==-0x23bf*-0x1+-0x1615+0x1*-0xda9)throw new Error(_0x291e08(0x156));_0x29a3ee[_0x291e08(0x98)](_0x291e08(0x187));}catch(_0x21c9da){_0x29a3ee[_0x291e08(0x98)](_0x291e08(0xf4));throw _0x21c9da;}}async[_0x10d0f3(0x15a)](_0x4cd562){const _0x128570=_0x10d0f3,_0x179a2f=this[_0x128570(0x124)](_0x4cd562);if(stringValue(_0x179a2f,_0x128570(0x194))!==_0x128570(0x188)||stringValue(_0x179a2f,_0x128570(0xbc))!==_0x128570(0x135)||_0x179a2f[_0x128570(0x17a)]===null)throw new Error(_0x128570(0x156));const _0xbbe1b=stringValue(_0x179a2f,_0x128570(0x17a)),_0x2adfce=this[_0x128570(0x8d)][_0x128570(0x131)][_0x128570(0x143)][_0x128570(0x161)](_0x128570(0xdf))[_0x128570(0xe8)](_0xbbe1b);if(_0x2adfce===undefined||stringValue(_0x2adfce,_0x128570(0x158))!==stringValue(_0x179a2f,_0x128570(0x158)))throw new Error(_0x128570(0x156));const _0x217e83=this[_0x128570(0x8d)][_0x128570(0x131)][_0x128570(0x143)][_0x128570(0x161)](_0x128570(0x9a))[_0x128570(0xc6)](this[_0x128570(0xff)](),_0x4cd562,_0xbbe1b);if(Number(_0x217e83[_0x128570(0x129)])!==-0x3*-0x8c9+0x236f+-0x1*0x3dc9)throw new Error(_0x128570(0x156));}async[_0x10d0f3(0x154)](_0x32e02f){const _0x3cc11c=_0x10d0f3,_0x4e2a7b=_0x32e02f===undefined?this[_0x3cc11c(0x8d)][_0x3cc11c(0x131)][_0x3cc11c(0x143)][_0x3cc11c(0x161)](_0x3cc11c(0xd4))[_0x3cc11c(0x10d)]():this[_0x3cc11c(0x8d)][_0x3cc11c(0x131)][_0x3cc11c(0x143)][_0x3cc11c(0x161)](_0x3cc11c(0xa4))[_0x3cc11c(0x10d)](_0x32e02f);for(const _0x9e0bb6 of _0x4e2a7b)await this[_0x3cc11c(0x15a)](stringValue(_0x9e0bb6,'id'));}[_0x10d0f3(0x121)](_0x4c3177,_0xeced95,_0x196a25){const _0x3d5d6f=_0x10d0f3;this[_0x3d5d6f(0x8d)][_0x3d5d6f(0x131)][_0x3d5d6f(0x143)][_0x3d5d6f(0x161)](_0x3d5d6f(0x10c))[_0x3d5d6f(0xc6)](_0xeced95,_0x196a25,this[_0x3d5d6f(0xff)](),_0x4c3177);}[_0x10d0f3(0xce)](_0xd6a48f){const _0x46919c=_0x10d0f3,_0x3c90cf=publishJob(_0xd6a48f),_0x55cd4a=_0x3c90cf[_0x46919c(0xbc)]!==_0x46919c(0x18b)||_0x3c90cf[_0x46919c(0xae)]===undefined?undefined:this[_0x46919c(0x8d)][_0x46919c(0x131)][_0x46919c(0x143)][_0x46919c(0x161)](_0x46919c(0xb1))[_0x46919c(0xe8)](_0x3c90cf[_0x46919c(0xae)]);return conversationTemplatePublishResultSchema[_0x46919c(0xdd)]({'job':_0x3c90cf,..._0x55cd4a===undefined?{}:{'version':templateVersion(_0x55cd4a)}});}[_0x10d0f3(0x115)](_0x33d888){const _0x470675=_0x10d0f3;return this[_0x470675(0x8d)][_0x470675(0x131)][_0x470675(0x143)][_0x470675(0x161)](_0x470675(0x128))[_0x470675(0xe8)](_0x33d888);}[_0x10d0f3(0x124)](_0x4317bb){const _0x32300e=_0x10d0f3,_0x4bea90=this[_0x32300e(0x115)](_0x4317bb);if(_0x4bea90===undefined)throw new Error(_0x32300e(0x17d));return _0x4bea90;}async[_0x10d0f3(0x166)](_0x56c1ef){const _0x2a638d=_0x10d0f3,_0x426f66=stringValue(_0x56c1ef,_0x2a638d(0x190)),_0x6ab0d2=this[_0x2a638d(0x8d)][_0x2a638d(0x171)][_0x2a638d(0xf1)](_0x426f66),_0x269803=await readFile(join(_0x6ab0d2,_0x2a638d(0x11a)),_0x2a638d(0x15c)),_0x1674fa=_0x269803[_0x2a638d(0x88)]('\x0a')?_0x269803[_0x2a638d(0x118)](-0xce5*0x1+0x109*-0x11+-0x3*-0xa2a,-(-0x16e8+0x20f1+-0x282*0x4)):_0x269803;if(hashText(_0x1674fa)!==stringValue(_0x56c1ef,_0x2a638d(0xef)))throw new Error(_0x2a638d(0x156));const _0x3e2cea=templateVersionManifest(JSON[_0x2a638d(0xdd)](_0x1674fa));if(_0x3e2cea[_0x2a638d(0xe0)]!==stringValue(_0x56c1ef,_0x2a638d(0xda))||hashText(JSON[_0x2a638d(0x18c)](_0x3e2cea[_0x2a638d(0xa3)]))!==_0x3e2cea[_0x2a638d(0xe0)]||_0x3e2cea[_0x2a638d(0x14a)]!==stringValue(_0x56c1ef,_0x2a638d(0x97))||_0x3e2cea[_0x2a638d(0x13d)][_0x2a638d(0x16a)]!==numberValue(_0x56c1ef,_0x2a638d(0x9f))||_0x3e2cea[_0x2a638d(0x13d)][_0x2a638d(0x186)]((_0x283887,_0x1f1880)=>_0x283887+_0x1f1880[_0x2a638d(0x191)],-0x1159+-0x1bb4*0x1+0x2d0d)!==numberValue(_0x56c1ef,_0x2a638d(0xd3))||snapshotContentHash(_0x3e2cea[_0x2a638d(0x11f)],_0x3e2cea[_0x2a638d(0x13d)],_0x3e2cea[_0x2a638d(0xe9)])!==_0x3e2cea[_0x2a638d(0x14a)])throw new Error(_0x2a638d(0x156));const _0x551f9b=new Map(_0x3e2cea[_0x2a638d(0x13d)][_0x2a638d(0x10e)](_0x5167fa=>[_0x5167fa[_0x2a638d(0x18e)],_0x5167fa])),_0x1dff34=new Set([..._0x3e2cea[_0x2a638d(0x11f)],_0x2a638d(0x130),_0x2a638d(0xc7)]),_0x2a5820=new Set(),_0x12468a=await listSnapshotEntries(join(_0x6ab0d2,_0x2a638d(0x108)),_0x1dff34,_0x2a5820,!![],_0x2a638d(0x156));if(_0x12468a[_0x2a638d(0x16a)]!==_0x551f9b[_0x2a638d(0x191)]||_0x2a5820[_0x2a638d(0x191)]!==_0x1dff34[_0x2a638d(0x191)])throw new Error(_0x2a638d(0x156));for(const _0x3d028c of _0x12468a){const _0x8b4d9f=_0x551f9b[_0x2a638d(0xe8)](_0x3d028c[_0x2a638d(0x18e)]);if(_0x8b4d9f===undefined||_0x8b4d9f[_0x2a638d(0xab)]!==_0x3d028c[_0x2a638d(0xab)])throw new Error(_0x2a638d(0x156));if(_0x8b4d9f[_0x2a638d(0xab)]===_0x2a638d(0x195)&&_0x3d028c[_0x2a638d(0xab)]===_0x2a638d(0x195)){if(_0x8b4d9f[_0x2a638d(0x191)]!==_0x3d028c[_0x2a638d(0x191)]||_0x8b4d9f[_0x2a638d(0x140)]!==_0x3d028c[_0x2a638d(0x140)]||((await lstat(_0x3d028c[_0x2a638d(0x17c)]))[_0x2a638d(0x13a)]&-0x1ab3*-0x1+0x9*0x260+-0xf5c*0x3)!==(_0x8b4d9f[_0x2a638d(0x140)]?0xd38+0x26b+-0xe36:0x9*-0x143+-0x8ed*-0x2+0x1*-0x55b)||_0x8b4d9f[_0x2a638d(0x9c)]!==_0x3d028c[_0x2a638d(0x9c)])throw new Error(_0x2a638d(0x156));continue;}if(_0x8b4d9f[_0x2a638d(0xab)]!==_0x2a638d(0xf5)||_0x3d028c[_0x2a638d(0xab)]!==_0x2a638d(0xf5)||_0x8b4d9f[_0x2a638d(0x191)]!==_0x3d028c[_0x2a638d(0x191)]||_0x8b4d9f[_0x2a638d(0x151)]!==_0x3d028c[_0x2a638d(0x151)])throw new Error(_0x2a638d(0x156));await verifySymlinkResolution(join(_0x6ab0d2,_0x2a638d(0x108)),_0x8b4d9f,_0x3d028c[_0x2a638d(0x17c)],_0x2a638d(0x156));}}}function publishJob(_0x1db048){const _0x46160b=_0x10d0f3;return conversationTemplatePublishJobSchema[_0x46160b(0xdd)]({'id':stringValue(_0x1db048,'id'),'templateId':stringValue(_0x1db048,_0x46160b(0x158)),'draftRevision':numberValue(_0x1db048,_0x46160b(0xd5)),'stage':stringValue(_0x1db048,_0x46160b(0x194)),'status':stringValue(_0x1db048,_0x46160b(0xbc)),..._0x1db048[_0x46160b(0x17a)]===null?{}:{'versionId':stringValue(_0x1db048,_0x46160b(0x17a))},'errorCode':_0x1db048[_0x46160b(0xc4)]===null?null:stringValue(_0x1db048,_0x46160b(0xc4)),..._0x1db048[_0x46160b(0x126)]===null?{}:{'errorSummary':stringValue(_0x1db048,_0x46160b(0x126))},'createdAt':numberValue(_0x1db048,_0x46160b(0x10a)),'updatedAt':numberValue(_0x1db048,_0x46160b(0x18a))});}function templateVersion(_0x275a13){const _0x367938=_0x10d0f3;return conversationTemplateVersionSchema[_0x367938(0xdd)]({'id':stringValue(_0x275a13,'id'),'templateId':stringValue(_0x275a13,_0x367938(0x158)),'version':numberValue(_0x275a13,_0x367938(0x15f)),'status':stringValue(_0x275a13,_0x367938(0xbc)),'contentHash':stringValue(_0x275a13,_0x367938(0x97)),'manifestHash':stringValue(_0x275a13,_0x367938(0xef)),'mcpConfigHash':stringValue(_0x275a13,_0x367938(0xda)),'fileCount':numberValue(_0x275a13,_0x367938(0x9f)),'totalBytes':numberValue(_0x275a13,_0x367938(0xd3)),'hostPolicyVersion':numberValue(_0x275a13,_0x367938(0x146)),'publishedByUserId':numberValue(_0x275a13,_0x367938(0xa5)),'publishedAt':numberValue(_0x275a13,_0x367938(0x12e))});}async function walkWorkspace(_0x3cc48a,_0x1c5d76,_0x1d550b){const _0xd3b755=_0x10d0f3,_0x2ccf1a=await lstat(_0x3cc48a)[_0xd3b755(0x14e)](_0x3da07b=>{const _0x470333=_0xd3b755;if(_0x3da07b[_0x470333(0xe2)]===_0x470333(0xd8))throw new Error(_0x470333(0xaf));throw _0x3da07b;});if(_0x2ccf1a[_0xd3b755(0x93)]()){if(_0x1c5d76[_0xd3b755(0x16a)]===-0x34*0x40+-0x1a4+-0xea4*-0x1)throw new Error(_0xd3b755(0x16d));await _0x1d550b[_0xd3b755(0xed)](_0x3cc48a,_0x1c5d76,_0x2ccf1a);return;}if(_0x2ccf1a[_0xd3b755(0xa8)]()){if(_0x1c5d76[_0xd3b755(0x16a)]===-0x197f+-0xb*-0x1ed+-0xb8*-0x6)throw new Error(_0xd3b755(0x162));await _0x1d550b[_0xd3b755(0x110)](_0x3cc48a,_0x1c5d76,_0x2ccf1a);return;}if(!_0x2ccf1a[_0xd3b755(0x8b)]())throw new Error(_0xd3b755(0x159));if(_0x1c5d76[_0xd3b755(0x16a)]>-0x1b*0x69+0x9c*-0x3a+-0x2e6b*-0x1)_0x1d550b[_0xd3b755(0xf8)](_0x1c5d76);for(const _0xf78de5 of(await readdir(_0x3cc48a,{'withFileTypes':!![]}))[_0xd3b755(0x114)]((_0x80db54,_0xb4f8ab)=>_0x80db54[_0xd3b755(0xeb)][_0xd3b755(0xc5)](_0xb4f8ab[_0xd3b755(0xeb)],_0xd3b755(0xd0)))){const _0x384fd7=join(_0x3cc48a,_0xf78de5[_0xd3b755(0xeb)]),_0x8fcfbf=_0x1c5d76[_0xd3b755(0x16a)]===0xb2e*-0x3+0x14bc+0x1*0xcce?_0xf78de5[_0xd3b755(0xeb)]:_0x1c5d76+'/'+_0xf78de5[_0xd3b755(0xeb)];if(_0x1c5d76[_0xd3b755(0x16a)]===0xe*-0x16d+-0x1*-0x3f8+-0x2*-0x7ff&&(_0xf78de5[_0xd3b755(0xeb)]===_0xd3b755(0x130)||_0xf78de5[_0xd3b755(0xeb)]===_0xd3b755(0xc7)))throw new Error(_0xd3b755(0xd1));if(forcedExcluded(_0x8fcfbf))continue;if(_0x1c5d76[_0xd3b755(0x16a)]===-0x195a+0x487+0x14d3&&_0xf78de5[_0xd3b755(0xeb)]===ROOT_TEMPLATE_INSTRUCTIONS_SOURCE){const _0x3b8ef9=await lstat(_0x384fd7);if(!_0x3b8ef9[_0xd3b755(0xa8)]()||_0x3b8ef9[_0xd3b755(0x93)]())throw new Error(_0xd3b755(0x159));await _0x1d550b[_0xd3b755(0x110)](_0x384fd7,ROOT_TEMPLATE_INSTRUCTIONS_TARGET,_0x3b8ef9);continue;}await walkWorkspace(_0x384fd7,_0x8fcfbf,_0x1d550b);}}async function sealDirectories(_0xc4202f,_0xd4ccf0=!![]){const _0x518dc9=_0x10d0f3,_0x4e5e76=await readdir(_0xc4202f,{'withFileTypes':!![]});for(const _0x19d8e4 of _0x4e5e76)if(_0x19d8e4[_0x518dc9(0x8b)]())await sealDirectories(join(_0xc4202f,_0x19d8e4[_0x518dc9(0xeb)]));if(_0xd4ccf0)await chmod(_0xc4202f,-0x489+0x1*-0x1d6b+0x2361);}async function writableRemove(_0x1f6319){const _0x113f4f=_0x10d0f3;await chmodTree(_0x1f6319)[_0x113f4f(0x14e)](()=>undefined),await rm(_0x1f6319,{'recursive':!![],'force':!![]});}async function chmodTree(_0x47d3f9){const _0x345712=_0x10d0f3,_0x47cf17=await lstat(_0x47d3f9);if(_0x47cf17[_0x345712(0x93)]())return;if(_0x47cf17[_0x345712(0x8b)]()){await chmod(_0x47d3f9,-0x2641+-0x9ad+0x1*0x31ae);for(const _0x511ad6 of await readdir(_0x47d3f9))await chmodTree(join(_0x47d3f9,_0x511ad6));}else await chmod(_0x47d3f9,-0x664*-0x3+0x1841+-0x29ed);}async function verifyCopiedSnapshot(_0x2f0ea7,_0x3ff9a7,_0x359800,_0x1c4cbe){const _0x51cbe3=_0x10d0f3,_0x5925f0=new Map(_0x359800[_0x51cbe3(0x10e)](_0x3239e6=>[_0x3239e6[_0x51cbe3(0x18e)],_0x3239e6])),_0xa0509=new Set([..._0x3ff9a7,_0x51cbe3(0x130),_0x51cbe3(0xc7)]),_0xc8c211=new Set(),_0x428dae=await listSnapshotEntries(_0x2f0ea7,_0xa0509,_0xc8c211,_0x1c4cbe,_0x51cbe3(0x167));if(_0xc8c211[_0x51cbe3(0x191)]!==_0xa0509[_0x51cbe3(0x191)])throw new Error(_0x51cbe3(0x167));if(_0x428dae[_0x51cbe3(0x16a)]!==_0x5925f0[_0x51cbe3(0x191)])throw new Error(_0x51cbe3(0x167));for(const _0x46105c of _0x428dae){const _0x16d189=_0x5925f0[_0x51cbe3(0xe8)](_0x46105c[_0x51cbe3(0x18e)]);if(_0x16d189===undefined||_0x16d189[_0x51cbe3(0xab)]!==_0x46105c[_0x51cbe3(0xab)])throw new Error(_0x51cbe3(0x167));if(_0x16d189[_0x51cbe3(0xab)]===_0x51cbe3(0x195)&&_0x46105c[_0x51cbe3(0xab)]===_0x51cbe3(0x195)){if(_0x16d189[_0x51cbe3(0x191)]!==_0x46105c[_0x51cbe3(0x191)]||_0x16d189[_0x51cbe3(0x140)]!==_0x46105c[_0x51cbe3(0x140)]||_0x16d189[_0x51cbe3(0x9c)]!==_0x46105c[_0x51cbe3(0x9c)])throw new Error(_0x51cbe3(0x167));continue;}if(_0x16d189[_0x51cbe3(0xab)]!==_0x51cbe3(0xf5)||_0x46105c[_0x51cbe3(0xab)]!==_0x51cbe3(0xf5)||_0x16d189[_0x51cbe3(0x191)]!==_0x46105c[_0x51cbe3(0x191)]||_0x16d189[_0x51cbe3(0x151)]!==_0x46105c[_0x51cbe3(0x151)])throw new Error(_0x51cbe3(0x167));await verifySymlinkResolution(_0x2f0ea7,_0x16d189,_0x46105c[_0x51cbe3(0x17c)],_0x51cbe3(0x167));}}async function verifySymlinkResolution(_0x5b5609,_0x10faf5,_0x33dafc,_0x9950d0){const _0x421163=_0x10d0f3;let _0x21eb59;try{_0x21eb59=await realpath(_0x33dafc);}catch{throw new Error(_0x9950d0);}if(_0x10faf5[_0x421163(0xe7)]===_0x421163(0xc0)){if(_0x21eb59!==_0x10faf5[_0x421163(0xbf)])throw new Error(_0x9950d0);return;}let _0x3be18f;try{_0x3be18f=await realpath(join(_0x5b5609,..._0x10faf5[_0x421163(0xbf)][_0x421163(0x15b)]('/')));}catch{throw new Error(_0x9950d0);}if(_0x21eb59!==_0x3be18f||!within(await realpath(_0x5b5609),_0x21eb59))throw new Error(_0x9950d0);}async function listSnapshotEntries(_0x9b2aae,_0x5c858a,_0x5e065e,_0x4e44ee,_0x4986e4,_0x582a6c=''){const _0xee1aaf=_0x10d0f3,_0x3114b7=await lstat(_0x9b2aae);if(!_0x3114b7[_0xee1aaf(0x8b)]()||_0x3114b7[_0xee1aaf(0x93)]()||_0x4e44ee&&(_0x3114b7[_0xee1aaf(0x13a)]&-0x2*0xea+-0x2+-0x1*-0x3d5)!==0x1161+0x9d9+0x5*-0x529)throw new Error(_0x4986e4);const _0x2aa816=[];for(const _0x161e5b of await readdir(_0x9b2aae,{'withFileTypes':!![]})){const _0x3c383c=join(_0x9b2aae,_0x161e5b[_0xee1aaf(0xeb)]),_0x1dfcfd=_0x582a6c[_0xee1aaf(0x16a)]===-0x90b+-0x23d*0x2+0xd85?_0x161e5b[_0xee1aaf(0xeb)]:_0x582a6c+'/'+_0x161e5b[_0xee1aaf(0xeb)],_0x52149e=await lstat(_0x3c383c);if(_0x52149e[_0xee1aaf(0x93)]()){const _0x548533=await readlink(_0x3c383c);_0x2aa816[_0xee1aaf(0xe3)]({'kind':_0xee1aaf(0xf5),'relativePath':_0x1dfcfd,'sourcePath':_0x3c383c,'size':Buffer[_0xee1aaf(0x170)](_0x548533),'linkTarget':_0x548533});continue;}if(_0x52149e[_0xee1aaf(0x8b)]()){if(!_0x5c858a[_0xee1aaf(0x18f)](_0x1dfcfd))throw new Error(_0x4986e4);_0x5e065e[_0xee1aaf(0x13e)](_0x1dfcfd),_0x2aa816[_0xee1aaf(0xe3)](...await listSnapshotEntries(_0x3c383c,_0x5c858a,_0x5e065e,_0x4e44ee,_0x4986e4,_0x1dfcfd));continue;}if(!_0x52149e[_0xee1aaf(0xa8)]()||_0x52149e[_0xee1aaf(0xa0)]!==0xa12*-0x1+-0xeb0+0x18c3||_0x4e44ee&&(_0x52149e[_0xee1aaf(0x13a)]&0x1d3d+0x2167*-0x1+0x629)!==(_0x52149e[_0xee1aaf(0x13a)]&-0x212*-0x9+-0xd8c+-0x4cd?0x35*-0x81+0xe15+0x1*0xe0d:0x4a3*0x1+-0x19cf+0xee*0x18))throw new Error(_0x4986e4);_0x2aa816[_0xee1aaf(0xe3)]({'kind':_0xee1aaf(0x195),'relativePath':_0x1dfcfd,'sourcePath':_0x3c383c,'size':Number(_0x52149e[_0xee1aaf(0x191)]),'executable':(_0x52149e[_0xee1aaf(0x13a)]&-0x97a+0x19d5+-0x16*0xbb)!==-0x1*0x1447+0x7d*-0x1d+0x2270,'sha256':hashBuffer(await readFile(_0x3c383c))});}return _0x2aa816;}function legacyPublishedDirectories(_0x426079){const _0x1ead71=_0x10d0f3,_0x5cafa7=new Set([_0x1ead71(0x130),_0x1ead71(0xc7)]);for(const _0x296a97 of _0x426079){const _0x39c9c8=_0x296a97[_0x1ead71(0x18e)][_0x1ead71(0x15b)]('/');for(let _0x38cee3=-0x197+0x2109+-0x1f71;_0x38cee3<_0x39c9c8[_0x1ead71(0x16a)];_0x38cee3+=0x548*0x5+-0x1393+0x13*-0x5c)_0x5cafa7[_0x1ead71(0x13e)](_0x39c9c8[_0x1ead71(0x118)](-0x399*-0x9+0xca3+-0x2d04,_0x38cee3)[_0x1ead71(0x106)]('/'));}return _0x5cafa7[_0x1ead71(0x105)](_0x1ead71(0x130)),_0x5cafa7[_0x1ead71(0x105)](_0x1ead71(0xc7)),[..._0x5cafa7][_0x1ead71(0x114)]((_0x1d18a7,_0x33d693)=>_0x1d18a7[_0x1ead71(0xc5)](_0x33d693,_0x1ead71(0xd0)));}function forcedExcluded(_0x124aa1){const _0x3f3911=_0x10d0f3,_0x48988c=_0x124aa1[_0x3f3911(0x15b)]('/');if(_0x48988c[_0x3f3911(0x90)](_0x5f4139=>{const _0x4ca5bc=_0x3f3911,_0x4bdf60=_0x5f4139[_0x4ca5bc(0x189)](_0x4ca5bc(0xd0));return FORCED_EXCLUDED_NAMES[_0x4ca5bc(0x18f)](_0x4bdf60)||_0x4bdf60[_0x4ca5bc(0x11d)](_0x4ca5bc(0xcd));}))return!![];const _0x23891b=_0x48988c['at'](-(-0x1c04+-0x74f*-0x1+-0x2*-0xa5b))?.[_0x3f3911(0x189)](_0x3f3911(0xd0))??'';return _0x48988c[_0x3f3911(0x16a)]===-0x1285+-0x1663+0x28e9&&(ROOT_EXCLUDED_NAMES[_0x3f3911(0x18f)](_0x23891b)||_0x23891b[_0x3f3911(0x88)](_0x3f3911(0xf3))||_0x23891b[_0x3f3911(0x88)](_0x3f3911(0xd2))||_0x23891b===_0x3f3911(0x9e)||_0x23891b===_0x3f3911(0x180))||_0x23891b[_0x3f3911(0x88)](_0x3f3911(0xb3));}async function publishedSymlink(_0x237a1f,_0x566233,_0x21241a,_0x2f1ec0){const _0x364d9c=_0x10d0f3;if(!_0x2f1ec0[_0x364d9c(0x93)]())throw new Error(_0x364d9c(0x16d));const _0x3f1f2b=await readlink(_0x566233);let _0x15d89c;try{_0x15d89c=await realpath(_0x566233);}catch{throw new Error(_0x364d9c(0x16d));}if(_0x15d89c===_0x237a1f||within(_0x237a1f,_0x15d89c)){const _0x21bc1b=await lstat(_0x15d89c)[_0x364d9c(0x14e)](()=>undefined);if(_0x21bc1b===undefined||_0x21bc1b[_0x364d9c(0x8b)]()&&(_0x15d89c===_0x237a1f||within(_0x15d89c,_0x566233)))throw new Error(_0x364d9c(0x16d));const _0x1119ad=relative(_0x237a1f,_0x15d89c)[_0x364d9c(0x15b)](sep)[_0x364d9c(0x106)]('/');if(_0x1119ad[_0x364d9c(0x16a)]===0x139e+-0x165b+0x2bd||forcedExcluded(_0x1119ad))throw new Error(_0x364d9c(0x16d));return{'kind':_0x364d9c(0xf5),'relativePath':_0x21241a,'sourcePath':_0x566233,'size':Buffer[_0x364d9c(0x170)](_0x3f1f2b),'linkTarget':_0x3f1f2b,'targetKind':_0x364d9c(0x184),'resolvedTarget':_0x1119ad};}const _0x2afd8a=RUNTIME_LINK_ROOTS[_0x364d9c(0x13f)](_0x18dc8f=>_0x15d89c===_0x18dc8f||within(_0x18dc8f,_0x15d89c));if(_0x2afd8a===undefined)throw new Error(_0x364d9c(0x16d));return{'kind':_0x364d9c(0xf5),'relativePath':_0x21241a,'sourcePath':_0x566233,'size':Buffer[_0x364d9c(0x170)](_0x3f1f2b),'linkTarget':_0x3f1f2b,'targetKind':_0x364d9c(0xc0),'resolvedTarget':_0x15d89c};}function templateVersionManifest(_0x5069d7){const _0x4f6e6a=_0x10d0f3;if(!record(_0x5069d7))throw new Error(_0x4f6e6a(0x156));const _0xf3610d=Array[_0x4f6e6a(0x13b)](_0x5069d7[_0x4f6e6a(0xa3)])?_0x5069d7[_0x4f6e6a(0xa3)]:undefined;if(_0xf3610d===undefined||typeof _0x5069d7[_0x4f6e6a(0xe0)]!==_0x4f6e6a(0x14c)||typeof _0x5069d7[_0x4f6e6a(0x14a)]!==_0x4f6e6a(0x14c))throw new Error(_0x4f6e6a(0x156));if(_0x5069d7[_0x4f6e6a(0xe9)]===-0xaa*0x10+0xeb3*0x1+0x412*-0x1){if(!Array[_0x4f6e6a(0x13b)](_0x5069d7[_0x4f6e6a(0xa2)]))throw new Error(_0x4f6e6a(0x156));const _0x10064b=_0x5069d7[_0x4f6e6a(0xa2)][_0x4f6e6a(0x10e)](_0xb26832=>manifestFile(_0xb26832));return{'schemaVersion':0x1,'directories':legacyPublishedDirectories(_0x10064b),'entries':_0x10064b,'contentHash':_0x5069d7[_0x4f6e6a(0x14a)],'mcpServers':_0xf3610d,'mcpConfigHash':_0x5069d7[_0x4f6e6a(0xe0)]};}if(_0x5069d7[_0x4f6e6a(0xe9)]!==-0x20a3+0xd*0x2bc+0x1*-0x2e7||typeof _0x5069d7[_0x4f6e6a(0x92)]!==_0x4f6e6a(0x14c)||!Array[_0x4f6e6a(0x13b)](_0x5069d7[_0x4f6e6a(0x11f)])||!Array[_0x4f6e6a(0x13b)](_0x5069d7[_0x4f6e6a(0x13d)]))throw new Error(_0x4f6e6a(0x156));validateSourceWorkspacePath(_0x5069d7[_0x4f6e6a(0x92)]);const _0x3777d0=_0x5069d7[_0x4f6e6a(0x11f)][_0x4f6e6a(0x10e)](_0x34f640=>safeManifestRelativePath(_0x34f640));if(new Set(_0x3777d0)[_0x4f6e6a(0x191)]!==_0x3777d0[_0x4f6e6a(0x16a)]||_0x3777d0[_0x4f6e6a(0x8e)](_0x4f6e6a(0x130))||_0x3777d0[_0x4f6e6a(0x8e)](_0x4f6e6a(0xc7)))throw new Error(_0x4f6e6a(0x156));const _0x3af002=_0x5069d7[_0x4f6e6a(0x13d)][_0x4f6e6a(0x10e)](_0x1efbd4=>manifestEntry(_0x1efbd4));if(new Set(_0x3af002[_0x4f6e6a(0x10e)](_0x1f0d24=>_0x1f0d24[_0x4f6e6a(0x18e)]))[_0x4f6e6a(0x191)]!==_0x3af002[_0x4f6e6a(0x16a)])throw new Error(_0x4f6e6a(0x156));return{'schemaVersion':0x2,'sourceWorkspacePath':_0x5069d7[_0x4f6e6a(0x92)],'directories':_0x3777d0,'entries':_0x3af002,'contentHash':_0x5069d7[_0x4f6e6a(0x14a)],'mcpServers':_0xf3610d,'mcpConfigHash':_0x5069d7[_0x4f6e6a(0xe0)]};}function _0x4740(){const _0x1cc669=['BwfW','ChvIBgLZAgvKqNLvC2vYswq','zMLSzq','lNnZAa','AM9Iswq','vKfmsurbveLorW','C29YDa','ChvIBgLZAePVyLjVDW','zhjHzNq','Aw5ZCgvJDfnVDxjJzq','C2XPy2u','q09ovKvsu0fusu9ox1rftvbmqvrfx1bvqKXju0HFrKfjteve','BwfUAwzLC3qUANnVBG','y29SBgvJDfnUyxbZAg90','quDftLrtlM1K','C3rHCNrZv2L0Aa','vgHLignVBNzLCNnHDgLVBIb0zw1WBgf0zsb2zxjZAw9UigLZigLUDMfSAwqGka','zgLYzwn0B3jPzxm','DgvTCgXHDgvZuhvIBgLZAgLUz0rPCMvJDg9YEq','DxbKyxrLsM9I','CMvXDwvZDgvKqNLvC2vYswq','CMvZB2X2zq','CMvXDwLYzvb1yMXPC2HkB2jsB3C','CMvHzg1LlM1K','zxjYB3jFC3vTBwfYEq','Cgf0Aa','u0vmrunuicOGrLjptsbJB252zxjZyxrPB25FDgvTCgXHDgvFChvIBgLZAf9QB2jZifDirvjfigLKpt8','y2HHBMDLCW','vvbeqvrfignVBNzLCNnHDgLVBL90zw1WBgf0zv9WDwjSAxnOx2PVyNmkicaGicaGicaGicbtrvqGC3rHz2u9j1jfr0LtvevsruqNlhn0yxr1CZ0NuLvotKLorYCSDMvYC2LVBL9Pzd0/lgvYCM9Yx2nVzgu9tLvmtcXLCNjVCL9ZDw1Tyxj5pu5vteWScIaGicaGicaGicaGicaGihvWzgf0zwrFyxq9pWOGicaGicaGicaGifDirvjfigLKpt8Gqu5eihrLBxbSyxrLx2LKpt8Gqu5eigrYywz0x3jLDMLZAw9Upt8Gqu5eihjLCxvLC3rLzf9IEv91C2vYx2LKpt8kicaGicaGicaGicaGieforcbZDgfNzt0Nu0vbtevejYbbtKqGC3rHDhvZpsDsvu5osu5hjYbbtKqGDMvYC2LVBL9PzcbjuYbovuXm','BwLU','y3jLzgvUDgLHBhm','vgHLignVBNzLCNnHDgLVBIb0zw1WBgf0zsbZB3vYy2uGAxmGDMfSAwqU','ChvIBgLZAgvKx2f0','vgHLignVBNzLCNnHDgLVBIb0zw1WBgf0zsbZB3vYy2uGAxmGAw52ywXPzcaO','Aw5IB3G','zgf0ywjHC2u','D29YA3nWywnLswq','yxnZzxj0tg9JywXeCMfMDa','DMfSDwvZ','uLvotKLorW','vgHLignVBNzLCNnHDgLVBIb0zw1WBgf0zsb2zxjZAw9UigLZihzHBgLKlG','vu5srvnuuKLdveve','vgHLihb1yMXPC2GGCMvXDwvZDcbMywLSzwqGka','su5trvjuieLove8Gy29UDMvYC2f0Aw9Ux3rLBxbSyxrLx3b1yMXPC2HFAM9ICWOGicaGicaGicaOAwqSDgvTCgXHDgvFAwqSzhjHzNrFCMv2AxnPB24SC3rHz2uSC3rHDhvZlhzLCNnPB25FAwqSzxjYB3jFy29KzsXLCNjVCL9ZDw1Tyxj5laOGicaGicaGicaGCMvXDwvZDgvKx2j5x3vZzxjFAwqSzhjHzNqSy3jLyxrLzf9HDcX1CgrHDgvKx2f0kqOGicaGicaGicbwquXvrvmGkd8SpYW/lcDwquXjrefusu5hjYWNuvvfvuvejYXovuXmle5vteWStLvmtcW/ld8SpYW/kq','Bw9Kzq','AxnbCNjHEq','y2f0ywXVz0vUDhj5swq','zw50CMLLCW','ywrK','zMLUza','zxHLy3v0ywjSzq','l2rLDG','q09ovKvsu0fusu9ox1rftvbmqvrfx0Loufvux0LovKfmsuq','CMf3','lM5WBxjJ','CM9VDerPCMvJDg9YEq','Ag9ZDf9WB2XPy3LFDMvYC2LVBG','ChvIBgLZAa','BM9KzuLK','zgLZCgXHEu5HBwu','y29UDgvUDeHHC2G','CMvXDwvZDgvKx2j5x3vZzxjFAwq','C3rYAw5N','l2jPBG','y2f0y2G','l2HVBwuVBwfY','mty5mgTmrNneyW','BgLUA1rHCMDLDa','ndq5ode4oezmEMT3va','DgvTCgXHDgvqDwjSAxnOAw5NrgLYzwn0B3j5','zMLUAxnOuMvNAxn0zxjLzfb1yMXPy2f0Aw9UCW','u0vmrunuienpquXfu0nfke1bwcH2zxjZAw9Ux251BwjLCIKSmcKGqvmGDMvYC2LVBL9UDw1IzxiGrLjptsbJB252zxjZyxrPB25FDgvTCgXHDgvFDMvYC2LVBNmGv0HfuKuGDgvTCgXHDgvFAwq9pW','q09ovKvsu0fusu9ox1rftvbmqvrfx1zfuLnjt05Fq09suLvqveve','l3nIAw4','DgvTCgXHDgvFAwq','q09ovKvsu0fusu9ox1rftvbmqvrfx1npvvjdrv9uwvbfx0LovKfmsuq','zMLUAxnOuMvNAxn0zxjLzfb1yMXPy2f0Aw9U','C3bSAxq','DxrMoa','odG5ntmZnMnNthvwyG','zwzMzwn0AxzLtwnWsw5ZDgfSBgf0Aw9UCW','DMvYC2LVBL9UDw1Izxi','AxntywzLsw50zwDLCG','ChjLCgfYzq','q09ovKvsu0fusu9ox1rftvbmqvrfx1npvvjdrv9jtLzbteLe','tufyx1nbrKvFsu5uruDfuG','u0vmrunuihn0B3jHz2vFA2v5iezst00Gy29UDMvYC2f0Aw9Ux3rLBxbSyxrLx3zLCNnPB25Z','A2v5CW','DMvYAwz5vMvYC2LVBG','q09ovKvsu0fusu9ox1rftvbmqvrfx1npvvjdrv9dsefor0ve','nJKWmJaWz0HbzKDO','qKvhsu4Gsu1nrurjqvrf','BgvUz3rO','ru5vtuvsqvrjtKC','l3vZCG','q09ovKvsu0fusu9ox1rftvbmqvrfx1npvvjdrv9msu5lx0LovKfmsuq','BNvTyMvY','ChvIBgLZAgvKqxq','yNL0zuXLBMD0Aa','C3rVCMu','CMv2AxnPB24','nZeWotG4D21bq2Do','u0vbteve','q09ovKvsu0fusu9ox1rftvbmqvrfx05pvf9bvvrit1jjwKve','lM1HCG','yMLNAw50','q09qwuLorW','CMvXDwvZDfvZzxjjza','DMvYC2LVBL9Pza','BwfUAwzLC3riyxnO','C291CMnLugf0Aa','q09ovKvsu0fusu9ox1rftvbmqvrfx1bvqKXju0HFsK9cx05pvf9gt1vora','DgvTCgXHDgvjza','tufosuzfu1q','AwrFzwqYntuXoq','BwnWt3b0Aw9UCW','yMfZzty0DxjS','sfruua','u05bufnit1q','CMvJB3zLCKLUDgvYCNvWDgvKuhvIBgLJyxrPB25Z','CMvKDwnL','q09ntuLu','uKvhsvnurvjfra','Dg9mB2nHBgvmB3DLCKnHC2u','DxbKyxrLzf9HDa','u1vdq0vfreve','C3rYAw5NAwz5','l3j1BNrPBwu','CMvSyxrPDMvqyxrO','AgfZ','C3rVCMfNzv9RzxK','C2L6zq','yNnPEMu','x193B3jRC3bHy2vxyxrJAfnLC3nPB25iyxnO','C3rHz2u','rKLmrq','DgvZDa','refuqujbu0vFvKfmvuvFsu5wquXjrdO','DxbKyxrL','zw5KC1DPDgG','B2jQzwn0','nxnmsgfWzG','AxneAxjLy3rVCNK','DgvTCgXHDgvZvMvYC2LVBNneAxjLy3rVCNK','B3b0Aw9UCW','Aw5JBhvKzxm','nJaWntDOtvfAvxq','C29Tzq','mJy2nJeZyM5QtLvQ','C291CMnLv29YA3nWywnLugf0Aa','AxntEw1IB2XPy0XPBMS','zgf0yq','ChvIBgLZAfn0yxr1CW','Aw5ZCgvJDfzLCNnPB24','y29UDgvUDf9OyxnO','zxHLyW','CgvYzM9YBvb1yMXPC2G','vvbeqvrfignVBNzLCNnHDgLVBL90zw1WBgf0zv9WDwjSAxnOx2PVyNmkicaGicaGicaGu0vuihn0yxr1CZ0Nu1vdq0vfrevejYXLCNjVCL9JB2rLpu5vteWSzxjYB3jFC3vTBwfYEt1ovuXmlhvWzgf0zwrFyxq9pWOGicaGicaGicbxsevsrsbPzd0/ieforcbZDgfNzt0NuKvhsvnurvjfrcCGqu5eihn0yxr1CZ0NuLvotKLorYCGqu5eihzLCNnPB25FAwq9pW','q09ovKvsu0fusu9ox1rftvbmqvrfx1jfvKLtsu9ox0nptKzmsunu','C2HHmJu2','q09ovKvsu0fusu9ox1rftvbmqvrfx01duf9jtLzbteLe','AwrFCNnH','zMLSzv9JB3vUDa','BMXPBMS','q09ovKvsu0fusu9ox0Hpu1rjtKDFu1rpuKfhrv9gvuXm','zMLSzxm','BwnWu2vYDMvYCW','u0vmrunuigLKiezst00Gy29UDMvYC2f0Aw9Ux3rLBxbSyxrLx3b1yMXPC2HFAM9ICWOGicaGicaGicaGicaGicbxsevsrsb0zw1WBgf0zv9Pzd0/ieforcbZDgfNzt0NuKvhsvnurvjfrcCGqu5eihn0yxr1CZ0NuLvotKLorYCkicaGicaGicaGicaGicaGt1jerviGqLKGy3jLyxrLzf9HDcXPza','ChvIBgLZAgvKx2j5x3vZzxjFAwq','zgLNzxn0','ChvIBgLZAff1zxvLCW','AxngAwXL','C2v0','Ag9ZDfbVBgLJEvzLCNnPB24','A2LUza','B3bLCMf0Aw9UCW','quDftLrtlNrLBxbSyxrLlM1K','DMvYC2LVBKLK','q09ovKvsu0fusu9ox1rftvbmqvrfx1npvvjdrv9nsvntsu5h','CMvNAxn0zxjwzxjZAw9U','u0vmrunuicOGrLjptsbJB252zxjZyxrPB25FDgvTCgXHDgvFDMvYC2LVBNmGv0HfuKuGAwq9pW','vvbeqvrfignVBNzLCNnHDgLVBL90zw1WBgf0zv9WDwjSAxnOx2PVyNmkicaGicaGicaGu0vuihn0yxr1CZ0NrKfjtevejYX2zxjZAw9Ux2LKpu5vteWSzxjYB3jFy29Kzt0Nq09ovKvsu0fusu9ox1rftvbmqvrfx1bvqKXju0HFsu5urvjsvvburuqNlaOGicaGicaGicaGicaGzxjYB3jFC3vTBwfYEt0/lhvWzgf0zwrFyxq9pWOGicaGicaGicbxsevsrsbZDgf0DxmGsu4GkcDrvuvvruqNlcDsvu5osu5hjYKGqu5eihn0ywDLpd4NuKvhsvnurvjfrcC','lNnVy2S','reLsrunut1jzaa','zMLSzunVDw50','zMLUywXSEq','l3bYB2m','l3j1BG','lMf3CW','z2v0v29YA3nWywnL','l3DVCMTZCgfJzq','C3rHDhvZ','u0vmrunuicOGrLjptsbJB252zxjZyxrPB25FDgvTCgXHDgvFDMvYC2LVBNmGv0HfuKuGAwq9pYbbtKqGDgvTCgXHDgvFAwq9pW','qvzbsuXbqKXf','CMvZB2X2zwruyxjNzxq','uLvoveLnrq','q09ovKvsu0fusu9ox0Hpu1rjtKDFu1rpuKfhrv9vtKfwquLmqujmrq','yMf2ywLS','v09ss1nqqunfx05pvf9gt1vora','zxjYB3jFy29Kzq','Bg9JywXLq29TCgfYzq','CNvU','B3v0Chv0','mZnWDe1LAKm','vvbeqvrfignVBNzLCNnHDgLVBL90zw1WBgf0zv9WDwjSAxnOx2PVyNmkicaGicaGicaGicbtrvqGC3rHz2u9pYXZDgf0Dxm9j0zbsuXfrcCSDMvYC2LVBL9Pzd1ovuXmlgvYCM9Yx2nVzgu9pYXLCNjVCL9ZDw1Tyxj5pt8SDxbKyxrLzf9HDd0/ifDirvjfigLKpt8','BwnWswrZ','C2vYDMvYtMfTzq','l2XPyJy0','lMvUDG','ChvIBgLZAfjLC3vSDa','lMf6DxjL','zw4Tvvm','q09ovKvsu0fusu9ox1rftvbmqvrfx1jfu0vsvKvex1bbveG','lMTLEq','Dg90ywXFyNL0zxm','u0vmrunuigLKiezst00Gy29UDMvYC2f0Aw9Ux3rLBxbSyxrLx3b1yMXPC2HFAM9ICWOGicaGicaGicaGicaGicbxsevsrsbZDgfNzt0NuKvhsvnurvjfrcCGqu5eihn0yxr1CZ0NuLvotKLorYCkicaGicaGicaGicaGicaGt1jerviGqLKGy3jLyxrLzf9HDcXPza','zhjHzNrFCMv2AxnPB24','yM9VBgvHBG','vgHLihb1yMXPC2GGCMvXDwvZDcb3yxmGAw50zxjYDxb0zwqGyMvMB3jLihrOzsb0zw1WBgf0zsb2zxjZAw9UihDHCYbYzwDPC3rLCMvKlG','ru5pru5u','DMvYC2LVBG','BwnWx2nVBMzPz19OyxnO','u0nbtK5jtKC','C2vJCMv0CW','CgfYC2u','y29UzMLNDxjHDgLVBG','u0vmrunuihrLBxbSyxrLx2LKiezst00Gy29UDMvYC2f0Aw9Ux3rLBxbSyxrLx3zLCNnPB25ZifDirvjfigLKpt8','BwnWq29UzMLNsgfZAa','l3rTCa','y29Kzq','ChvZAa','zw5XDwv1zvb1yMXPC2G','BMv0D29YA01Vzgu','Dg90ywXcExrLCW','DgfYz2v0s2LUza','z2v0','C2nOzw1HvMvYC2LVBG','q09suLvqveve','BMfTzq','zMXVB3i','C3LTBgLUAW','nMzbq01oAa','BwfUAwzLC3rFAgfZAa','su5trvjuieLove8Gy29UDMvYC2f0Aw9Ux3rLBxbSyxrLx3zLCNnPB25ZcIaGicaGicaGicaGkgLKlhrLBxbSyxrLx2LKlhzLCNnPB25FBNvTyMvYlgrYywz0x3jLDMLZAw9Ulhn0yxr1CYXZDg9YywDLx2TLEsXTyw5PzMvZDcXJB250zw50x2HHC2GScIaGicaGicaGicaGig1HBMLMzxn0x2HHC2GSBwnWx2nVBMzPz19OyxnOlgzPBgvFy291BNqSDg90ywXFyNL0zxmSAg9ZDf9WB2XPy3LFDMvYC2LVBIWkicaGicaGicaGicaGChvIBgLZAgvKx2j5x3vZzxjFAwqSChvIBgLZAgvKx2f0lhjLzMvYzw5Jzv9JB3vUDcKkicaGicaGicaGicbwquXvrvmGkd8SpYW/ld8SpYW/ld8SpYW/ld8SpYW/ld8SpYW/ldaP','DgvTCgXHDgvwzxjZAw9UrgLYzwn0B3j5','ywDLBNrZlM1K','lNbLBq','uK9mtejbq0S','u1LnteLosW','Agv4','BwvZC2fNzq','zgLYzwn0B3j5','q09ovKvsu0fusu9ox1rftvbmqvrfx05pvf9gt1vora','BMv4DfzLCNnPB25oDw1Izxi','CNvUDgLTzq','ntC2mdi4mMjZr0r2EG','lMDPDa','DgHLBG','BM93','AxngAw5PDgu','vvbeqvrfignVBNzLCNnHDgLVBL90zw1WBgf0zv92zxjZAw9UCYbtrvqGC3rHDhvZpsDdt1jsvvburuqNifDirvjfigLKpt8','n0r1zLD2Ca','DgvTCgXHDgvF','l2XPyG','zgvSzxrL','AM9PBG','C2vSzwn0zwrny3btzxj2zxjZ','y29UDgvUDa','DhjHBNnWB3j0','y3jLyxrLzf9HDa','lNb5CgLYyW','vvbeqvrfignVBNzLCNnHDgLVBL90zw1WBgf0zv9WDwjSAxnOx2PVyNmGu0vuihn0ywDLpt8SC3rHDhvZpt8SDxbKyxrLzf9HDd0/ifDirvjfigLKpt8','ywXS'];_0x4740=function(){return _0x1cc669;};return _0x4740();}function manifestEntry(_0x1eaa26){const _0x4af6e6=_0x10d0f3;if(!record(_0x1eaa26))throw new Error(_0x4af6e6(0x156));if(_0x1eaa26[_0x4af6e6(0xab)]===_0x4af6e6(0x195))return manifestFile(_0x1eaa26,!![]);if(_0x1eaa26[_0x4af6e6(0xab)]!==_0x4af6e6(0xf5)||typeof _0x1eaa26[_0x4af6e6(0x151)]!==_0x4af6e6(0x14c)||_0x1eaa26[_0x4af6e6(0x151)][_0x4af6e6(0x16a)]===0x2*0xb7+-0x1f05*0x1+-0x1*-0x1d97||_0x1eaa26[_0x4af6e6(0x151)][_0x4af6e6(0x8e)]('\x00')||_0x1eaa26[_0x4af6e6(0xe7)]!==_0x4af6e6(0x184)&&_0x1eaa26[_0x4af6e6(0xe7)]!==_0x4af6e6(0xc0)||typeof _0x1eaa26[_0x4af6e6(0xbf)]!==_0x4af6e6(0x14c))throw new Error(_0x4af6e6(0x156));const _0x1b4f4b=safeManifestRelativePath(_0x1eaa26[_0x4af6e6(0x18e)]),_0x5c4ae7=safeNonNegativeInteger(_0x1eaa26[_0x4af6e6(0x191)]),_0xb049bd=_0x1eaa26[_0x4af6e6(0x151)],_0x5d3ca4=_0x1eaa26[_0x4af6e6(0xe7)],_0x1fcf5b=_0x1eaa26[_0x4af6e6(0xbf)];if(_0x5c4ae7!==Buffer[_0x4af6e6(0x170)](_0xb049bd))throw new Error(_0x4af6e6(0x156));if(_0x5d3ca4===_0x4af6e6(0x184))safeManifestRelativePath(_0x1fcf5b);else{if(!isAbsolute(_0x1fcf5b)||!RUNTIME_LINK_ROOTS[_0x4af6e6(0x90)](_0x237b9e=>_0x1fcf5b===_0x237b9e||within(_0x237b9e,_0x1fcf5b)))throw new Error(_0x4af6e6(0x156));}return{'kind':_0x4af6e6(0xf5),'relativePath':_0x1b4f4b,'size':_0x5c4ae7,'linkTarget':_0xb049bd,'targetKind':_0x5d3ca4,'resolvedTarget':_0x1fcf5b};}function manifestFile(_0x41e067,_0x2445c1=![]){const _0x3d56fb=_0x10d0f3;if(!record(_0x41e067)||_0x2445c1&&_0x41e067[_0x3d56fb(0xab)]!==_0x3d56fb(0x195)||typeof _0x41e067[_0x3d56fb(0x140)]!==_0x3d56fb(0xd6)||typeof _0x41e067[_0x3d56fb(0x9c)]!==_0x3d56fb(0x14c)||!/^[a-f0-9]{64}$/u[_0x3d56fb(0x196)](_0x41e067[_0x3d56fb(0x9c)]))throw new Error(_0x3d56fb(0x156));return{'kind':_0x3d56fb(0x195),'relativePath':safeManifestRelativePath(_0x41e067[_0x3d56fb(0x18e)]),'size':safeNonNegativeInteger(_0x41e067[_0x3d56fb(0x191)]),'executable':_0x41e067[_0x3d56fb(0x140)],'sha256':_0x41e067[_0x3d56fb(0x9c)]};}function safeManifestRelativePath(_0x33138c){const _0x2d6e1b=_0x10d0f3;if(typeof _0x33138c!==_0x2d6e1b(0x14c)||_0x33138c[_0x2d6e1b(0x16a)]===0x692+0x7*0x1ba+-0x12a8||_0x33138c[_0x2d6e1b(0x11d)]('/')||_0x33138c[_0x2d6e1b(0x8e)]('\x5c')||_0x33138c[_0x2d6e1b(0x15b)]('/')[_0x2d6e1b(0x90)](_0x432028=>_0x432028[_0x2d6e1b(0x16a)]===0x1505*-0x1+-0x10dd+0x25e2||_0x432028==='.'||_0x432028==='..'))throw new Error(_0x2d6e1b(0x156));return _0x33138c;}function safeNonNegativeInteger(_0x51bd6e){const _0x497fc5=_0x10d0f3;if(!Number[_0x497fc5(0x160)](_0x51bd6e)||_0x51bd6e<0x2dc+0x1*-0x1abb+0x369*0x7)throw new Error(_0x497fc5(0x156));return _0x51bd6e;}function snapshotContentHash(_0x41d6df,_0x49298c,_0x3a7f1d=0x21b3+-0x1*0x1735+0x16*-0x7a){const _0x4c2f9b=_0x10d0f3;if(_0x3a7f1d===-0x1acf+-0x1b6+0x1c86)return hashText(_0x49298c[_0x4c2f9b(0x10e)](_0x76bec0=>{const _0x5945ad=_0x4c2f9b;if(_0x76bec0[_0x5945ad(0xab)]!==_0x5945ad(0x195))throw new Error(_0x5945ad(0x156));return _0x76bec0[_0x5945ad(0x18e)]+'\x00'+_0x76bec0[_0x5945ad(0x191)]+'\x00'+_0x76bec0[_0x5945ad(0x9c)];})[_0x4c2f9b(0x106)]('\x0a'));return hashText([..._0x41d6df[_0x4c2f9b(0x10e)](_0x42893b=>_0x4c2f9b(0xb4)+_0x42893b),..._0x49298c[_0x4c2f9b(0x10e)](_0x3e8cbc=>_0x3e8cbc[_0x4c2f9b(0xab)]===_0x4c2f9b(0x195)?_0x3e8cbc[_0x4c2f9b(0xab)]+'\x00'+_0x3e8cbc[_0x4c2f9b(0x18e)]+'\x00'+_0x3e8cbc[_0x4c2f9b(0x191)]+'\x00'+(_0x3e8cbc[_0x4c2f9b(0x140)]?-0x612*-0x1+0x3d*0x1f+-0xe*0xf6:-0x716+0x3*-0x463+0x143f)+'\x00'+_0x3e8cbc[_0x4c2f9b(0x9c)]:_0x3e8cbc[_0x4c2f9b(0xab)]+'\x00'+_0x3e8cbc[_0x4c2f9b(0x18e)]+'\x00'+_0x3e8cbc[_0x4c2f9b(0x191)]+'\x00'+_0x3e8cbc[_0x4c2f9b(0x151)]+'\x00'+_0x3e8cbc[_0x4c2f9b(0xe7)]+'\x00'+_0x3e8cbc[_0x4c2f9b(0xbf)])][_0x4c2f9b(0x106)]('\x0a'));}async function hostedFilesystemAvailableBytes(_0x5b7309){const _0x1fc129=_0x10d0f3;try{const _0xe9c050=await statfs(_0x5b7309),_0xfe8d60=Number(_0xe9c050[_0x1fc129(0xc2)])*Number(_0xe9c050[_0x1fc129(0x192)]);if(!Number[_0x1fc129(0x100)](_0xfe8d60)||_0xfe8d60<-0x4ab+-0x204a+0x24f5)throw new Error(_0x1fc129(0xc1));return Math[_0x1fc129(0x12b)](Math[_0x1fc129(0xec)](_0xfe8d60),Number[_0x1fc129(0x163)]);}catch(_0x55f7f9){if(_0x55f7f9 instanceof Error&&_0x55f7f9[_0x1fc129(0xf7)]===_0x1fc129(0xc1))throw _0x55f7f9;throw new Error(_0x1fc129(0xc1));}}function validateSourceWorkspacePath(_0x4a9b29){const _0x42fc2e=_0x10d0f3;if(!isAbsolute(_0x4a9b29)||resolve(_0x4a9b29)!==_0x4a9b29||_0x4a9b29==='/'||_0x4a9b29===_0x42fc2e(0xe1))throw new Error(_0x42fc2e(0x162));if(RESERVED_SANDBOX_ROOTS[_0x42fc2e(0x90)](_0x12a514=>_0x4a9b29===_0x12a514||within(_0x12a514,_0x4a9b29)||within(_0x4a9b29,_0x12a514)))throw new Error(_0x42fc2e(0x162));}function within(_0x35cc47,_0x34b031){const _0x52a005=_0x10d0f3,_0x59c98a=relative(_0x35cc47,_0x34b031);return _0x59c98a[_0x52a005(0x16a)]>-0x173*-0xe+-0x2597+0x114d&&_0x59c98a!=='..'&&!_0x59c98a[_0x52a005(0x11d)]('..'+sep);}function hashText(_0x2df0e6){const _0x5dfa56=_0x10d0f3;return createHash(_0x5dfa56(0x9c))[_0x5dfa56(0x198)](_0x2df0e6)[_0x5dfa56(0xa6)](_0x5dfa56(0xf6));}function hashBuffer(_0x36a0cd){const _0x59bb33=_0x10d0f3;return createHash(_0x59bb33(0x9c))[_0x59bb33(0x198)](_0x36a0cd)[_0x59bb33(0xa6)](_0x59bb33(0xf6));}function stringValue(_0x3bb316,_0x57116c){const _0x4ffd18=_0x10d0f3,_0x3716d2=_0x3bb316[_0x57116c];if(typeof _0x3716d2!==_0x4ffd18(0x14c))throw new Error(_0x4ffd18(0x197)+_0x57116c);return _0x3716d2;}function _0x560c(_0x5b50d1,_0x14bd41){_0x5b50d1=_0x5b50d1-(0x88b*-0x3+0x1b7d+-0x154);const _0x499d34=_0x4740();let _0xfb241a=_0x499d34[_0x5b50d1];if(_0x560c['IgXbKC']===undefined){var _0xabdceb=function(_0x4fdbae){const _0x5af023='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x4f96a2='',_0x2823d4='';for(let _0xdbcc12=0x183d+-0x4*0xb9+-0x1559,_0x4bfff2,_0x19cb74,_0x1ff38f=-0xb67*0x3+-0x16cf*0x1+0x3904;_0x19cb74=_0x4fdbae['charAt'](_0x1ff38f++);~_0x19cb74&&(_0x4bfff2=_0xdbcc12%(0x68e+-0x36*0x4+-0x6*0xf3)?_0x4bfff2*(-0x1da4+0x168b*0x1+0x759)+_0x19cb74:_0x19cb74,_0xdbcc12++%(-0x82b*0x3+-0x32*0x58+0x29b5))?_0x4f96a2+=String['fromCharCode'](-0x1e0c+0x10b8+0xc1*0x13&_0x4bfff2>>(-(-0x407+-0x17*0xcb+0x1*0x1646)*_0xdbcc12&-0x18c2+-0xf86+-0x4d*-0x86)):0x6ba+-0x16af*0x1+0xff5){_0x19cb74=_0x5af023['indexOf'](_0x19cb74);}for(let _0x1a3666=-0x8f*-0x27+0x2236+-0xb33*0x5,_0x3359d3=_0x4f96a2['length'];_0x1a3666<_0x3359d3;_0x1a3666++){_0x2823d4+='%'+('00'+_0x4f96a2['charCodeAt'](_0x1a3666)['toString'](0x1204*-0x1+0x13c1+-0x1ad))['slice'](-(-0x560+-0x1c1+0x723));}return decodeURIComponent(_0x2823d4);};_0x560c['fLdxAV']=_0xabdceb,_0x560c['sYxebT']={},_0x560c['IgXbKC']=!![];}const _0x5cbc8d=_0x499d34[-0x3*0xcfe+0x9f5+0x1d05];_0x560c['ccKvlB']!==_0x5cbc8d&&(_0x560c['sYxebT']={},_0x560c['ccKvlB']=_0x5cbc8d);const _0x2fc9bb=_0x560c['sYxebT'][_0x5b50d1];return _0x2fc9bb===undefined?(_0xfb241a=_0x560c['fLdxAV'](_0xfb241a),_0x560c['sYxebT'][_0x5b50d1]=_0xfb241a):_0xfb241a=_0x2fc9bb,_0xfb241a;}function numberValue(_0x57af3a,_0x28cda5){const _0x3cdc79=_0x10d0f3,_0x8ed6d=_0x57af3a[_0x28cda5];if(typeof _0x8ed6d!==_0x3cdc79(0x16e)&&typeof _0x8ed6d!==_0x3cdc79(0x177))throw new Error(_0x3cdc79(0x197)+_0x28cda5);const _0x2509f1=Number(_0x8ed6d);if(!Number[_0x3cdc79(0x160)](_0x2509f1))throw new Error(_0x3cdc79(0x197)+_0x28cda5);return _0x2509f1;}function nodeRequestPayload(_0x4122f9){const _0x109212=_0x10d0f3;if(!record(_0x4122f9))return{'data':_0x4122f9};const {__requestUserId:_0x22ad87,..._0x573ebb}=_0x4122f9;delete _0x573ebb[_0x109212(0x193)];if(_0x22ad87===undefined)return{'data':_0x573ebb};if(typeof _0x22ad87!==_0x109212(0x16e)||!Number[_0x109212(0x160)](_0x22ad87)||_0x22ad87<=-0x2*-0x132a+-0x1966+-0xcee)throw new Error(_0x109212(0x175));return{'data':_0x573ebb,'requestUserId':_0x22ad87};}function record(_0x4ecd9d){const _0x585593=_0x10d0f3;return typeof _0x4ecd9d===_0x585593(0x89)&&_0x4ecd9d!==null&&!Array[_0x585593(0x13b)](_0x4ecd9d);}
|
|
1
|
+
import { createHash, randomUUID } from 'node:crypto';
|
|
2
|
+
import { chmod, copyFile, lstat, mkdir, readFile, readlink, readdir, realpath, rename, rm, statfs, symlink, writeFile } from 'node:fs/promises';
|
|
3
|
+
import { dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
|
|
4
|
+
import { conversationTemplateDraftSchema, conversationTemplatePublishJobSchema, conversationTemplatePublishRequestSchema, conversationTemplatePublishResultSchema, conversationTemplatePublishStatusInputSchema, conversationTemplateSourceInspectInputSchema, conversationTemplateSourceInspectionSchema, conversationTemplateVersionSchema } from '@myagentroam/protocol';
|
|
5
|
+
import { safeErrorCode } from '../util/safe-error.js';
|
|
6
|
+
const HOST_POLICY_VERSION = 1;
|
|
7
|
+
const FORCED_EXCLUDED_NAMES = new Set([
|
|
8
|
+
'.git',
|
|
9
|
+
'.env',
|
|
10
|
+
'.npmrc',
|
|
11
|
+
'.pypirc',
|
|
12
|
+
'.ssh',
|
|
13
|
+
'.aws',
|
|
14
|
+
'.azure',
|
|
15
|
+
'.mar'
|
|
16
|
+
]);
|
|
17
|
+
const ROOT_EXCLUDED_NAMES = new Set(['credentials', 'secrets', 'readme.md', 'agents.md']);
|
|
18
|
+
const ROOT_TEMPLATE_INSTRUCTIONS_SOURCE = 'AGENTS.template.md';
|
|
19
|
+
const ROOT_TEMPLATE_INSTRUCTIONS_TARGET = 'AGENTS.md';
|
|
20
|
+
const RUNTIME_LINK_ROOTS = ['/usr', '/bin', '/sbin', '/lib', '/lib64'];
|
|
21
|
+
const RESERVED_SANDBOX_ROOTS = [
|
|
22
|
+
'/workspace',
|
|
23
|
+
'/home/mar',
|
|
24
|
+
'/runtime',
|
|
25
|
+
'/usr',
|
|
26
|
+
'/bin',
|
|
27
|
+
'/sbin',
|
|
28
|
+
'/lib',
|
|
29
|
+
'/lib64',
|
|
30
|
+
'/proc',
|
|
31
|
+
'/dev',
|
|
32
|
+
'/run',
|
|
33
|
+
'/tmp'
|
|
34
|
+
];
|
|
35
|
+
/** Handles the four closed template-management operations owned by Node. */
|
|
36
|
+
export class ConversationTemplateNodeService {
|
|
37
|
+
options;
|
|
38
|
+
now;
|
|
39
|
+
id;
|
|
40
|
+
publishQueues = new Map();
|
|
41
|
+
constructor(options) {
|
|
42
|
+
this.options = options;
|
|
43
|
+
this.now = options.now ?? Date.now;
|
|
44
|
+
this.id = options.id ?? randomUUID;
|
|
45
|
+
}
|
|
46
|
+
operations() {
|
|
47
|
+
return {
|
|
48
|
+
'conversation.template.source.inspect': (data) => this.inspectSource(data),
|
|
49
|
+
'conversation.template.publish': (data) => this.publish(data),
|
|
50
|
+
'conversation.template.publish.status': (data) => this.publishStatus(data),
|
|
51
|
+
'conversation.template.version.inspect': (data) => this.inspectVersion(data)
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
async recoverInterruptedPublications() {
|
|
55
|
+
for (const entry of await readdir(this.options.store.templatesPublishingDirectory, {
|
|
56
|
+
withFileTypes: true
|
|
57
|
+
})) {
|
|
58
|
+
await writableRemove(join(this.options.store.templatesPublishingDirectory, entry.name));
|
|
59
|
+
}
|
|
60
|
+
const registeredStorageKeys = new Set(this.options.database.raw
|
|
61
|
+
.prepare('SELECT storage_key FROM conversation_template_versions')
|
|
62
|
+
.all().map((row) => stringValue(row, 'storage_key')));
|
|
63
|
+
for (const entry of await readdir(this.options.store.templatesVersionsDirectory, {
|
|
64
|
+
withFileTypes: true
|
|
65
|
+
})) {
|
|
66
|
+
if (registeredStorageKeys.has(entry.name))
|
|
67
|
+
continue;
|
|
68
|
+
await writableRemove(join(this.options.store.templatesVersionsDirectory, entry.name));
|
|
69
|
+
}
|
|
70
|
+
await this.finishRegisteredPublications();
|
|
71
|
+
this.options.database.raw
|
|
72
|
+
.prepare(`UPDATE conversation_template_publish_jobs
|
|
73
|
+
SET status='FAILED',version_id=NULL,error_code='CONVERSATION_TEMPLATE_PUBLISH_INTERRUPTED',
|
|
74
|
+
error_summary=?,updated_at=?
|
|
75
|
+
WHERE status IN ('QUEUED','RUNNING') AND stage<>'REGISTERED'`)
|
|
76
|
+
.run('The publish request was interrupted before the template version was registered.', this.now());
|
|
77
|
+
}
|
|
78
|
+
async inspectSource(raw) {
|
|
79
|
+
const input = conversationTemplateSourceInspectInputSchema.parse(nodeRequestPayload(raw).data);
|
|
80
|
+
const mcpServers = this.mcpOptions(input.draft.workspaceId);
|
|
81
|
+
try {
|
|
82
|
+
await this.collectSnapshot(input.draft);
|
|
83
|
+
this.selectedMcpServers(input.draft);
|
|
84
|
+
return conversationTemplateSourceInspectionSchema.parse({
|
|
85
|
+
valid: true,
|
|
86
|
+
code: null,
|
|
87
|
+
message: 'The conversation template source is valid.',
|
|
88
|
+
checkedAt: this.now(),
|
|
89
|
+
mcpServers
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
const code = safeErrorCode(error, 'CONVERSATION_TEMPLATE_SOURCE_INVALID');
|
|
94
|
+
return conversationTemplateSourceInspectionSchema.parse({
|
|
95
|
+
valid: false,
|
|
96
|
+
code,
|
|
97
|
+
message: `The conversation template source is invalid (${code}).`,
|
|
98
|
+
checkedAt: this.now(),
|
|
99
|
+
mcpServers
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
async publish(raw) {
|
|
104
|
+
const payload = nodeRequestPayload(raw);
|
|
105
|
+
const request = conversationTemplatePublishRequestSchema.parse(payload.data);
|
|
106
|
+
if (payload.requestUserId !== undefined && payload.requestUserId !== request.requestedByUserId)
|
|
107
|
+
throw new Error('CONVERSATION_TEMPLATE_NOT_AUTHORIZED');
|
|
108
|
+
this.assertLocalDraft(request.draft);
|
|
109
|
+
const existing = this.publishJobRow(request.jobId);
|
|
110
|
+
if (existing !== undefined) {
|
|
111
|
+
if (numberValue(existing, 'requested_by_user_id') !== request.requestedByUserId)
|
|
112
|
+
throw new Error('CONVERSATION_TEMPLATE_NOT_AUTHORIZED');
|
|
113
|
+
if (stringValue(existing, 'template_id') !== request.templateId ||
|
|
114
|
+
numberValue(existing, 'draft_revision') !== request.draft.revision ||
|
|
115
|
+
stringValue(existing, 'draft') !== JSON.stringify(request.draft))
|
|
116
|
+
throw new Error('CONVERSATION_TEMPLATE_REVISION_CONFLICT');
|
|
117
|
+
return this.publishResult(existing);
|
|
118
|
+
}
|
|
119
|
+
const createdAt = this.now();
|
|
120
|
+
this.options.database.raw
|
|
121
|
+
.prepare(`INSERT INTO conversation_template_publish_jobs
|
|
122
|
+
(id,template_id,draft_revision,stage,status,version_id,error_code,error_summary,
|
|
123
|
+
requested_by_user_id,draft,created_at,updated_at)
|
|
124
|
+
VALUES (?,?,?,'VALIDATING','QUEUED',NULL,NULL,NULL,?,?,?,?)`)
|
|
125
|
+
.run(request.jobId, request.templateId, request.draft.revision, request.requestedByUserId, JSON.stringify(request.draft), createdAt, createdAt);
|
|
126
|
+
this.enqueuePublish(request);
|
|
127
|
+
return this.publishResult(this.requirePublishJobRow(request.jobId));
|
|
128
|
+
}
|
|
129
|
+
enqueuePublish(request) {
|
|
130
|
+
queueMicrotask(() => {
|
|
131
|
+
const previous = this.publishQueues.get(request.templateId) ?? Promise.resolve();
|
|
132
|
+
const current = previous
|
|
133
|
+
.catch(() => undefined)
|
|
134
|
+
.then(() => this.performPublish(request))
|
|
135
|
+
.finally(() => {
|
|
136
|
+
if (this.publishQueues.get(request.templateId) === current)
|
|
137
|
+
this.publishQueues.delete(request.templateId);
|
|
138
|
+
});
|
|
139
|
+
this.publishQueues.set(request.templateId, current);
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
publishStatus(raw) {
|
|
143
|
+
const input = conversationTemplatePublishStatusInputSchema.parse(nodeRequestPayload(raw).data);
|
|
144
|
+
const row = this.requirePublishJobRow(input.jobId);
|
|
145
|
+
if (stringValue(row, 'template_id') !== input.templateId)
|
|
146
|
+
throw new Error('CONVERSATION_TEMPLATE_PUBLISH_JOB_NOT_FOUND');
|
|
147
|
+
return this.publishResult(row);
|
|
148
|
+
}
|
|
149
|
+
async inspectVersion(raw) {
|
|
150
|
+
raw = nodeRequestPayload(raw).data;
|
|
151
|
+
if (!record(raw) ||
|
|
152
|
+
typeof raw['templateId'] !== 'string' ||
|
|
153
|
+
typeof raw['versionId'] !== 'string' ||
|
|
154
|
+
Object.keys(raw).length !== 2)
|
|
155
|
+
throw new Error('CONVERSATION_TEMPLATE_INPUT_INVALID');
|
|
156
|
+
const row = this.options.database.raw
|
|
157
|
+
.prepare('SELECT * FROM conversation_template_versions WHERE id=? AND template_id=?')
|
|
158
|
+
.get(raw['versionId'], raw['templateId']);
|
|
159
|
+
if (row === undefined)
|
|
160
|
+
throw new Error('CONVERSATION_TEMPLATE_NOT_FOUND');
|
|
161
|
+
const version = templateVersion(row);
|
|
162
|
+
try {
|
|
163
|
+
await this.verifyVersion(row);
|
|
164
|
+
if (version.status === 'CORRUPTED')
|
|
165
|
+
throw new Error('CONVERSATION_TEMPLATE_VERSION_CORRUPTED');
|
|
166
|
+
return {
|
|
167
|
+
valid: true,
|
|
168
|
+
code: null,
|
|
169
|
+
message: 'The conversation template version is valid.',
|
|
170
|
+
checkedAt: this.now(),
|
|
171
|
+
version
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
catch (error) {
|
|
175
|
+
const code = safeErrorCode(error, 'CONVERSATION_TEMPLATE_VERSION_CORRUPTED');
|
|
176
|
+
this.options.database.raw
|
|
177
|
+
.prepare("UPDATE conversation_template_versions SET status='CORRUPTED' WHERE id=?")
|
|
178
|
+
.run(version.id);
|
|
179
|
+
return {
|
|
180
|
+
valid: false,
|
|
181
|
+
code,
|
|
182
|
+
message: `The conversation template version is invalid (${code}).`,
|
|
183
|
+
checkedAt: this.now(),
|
|
184
|
+
version: { ...version, status: 'CORRUPTED' }
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
async performPublish(request) {
|
|
189
|
+
const storageKey = `template_${createHash('sha256').update(request.jobId).digest('base64url')}`;
|
|
190
|
+
const candidate = this.options.store.templatePublishingDirectory(storageKey);
|
|
191
|
+
let sealed;
|
|
192
|
+
let stage = 'VALIDATING';
|
|
193
|
+
try {
|
|
194
|
+
await this.finishRegisteredPublications(request.templateId);
|
|
195
|
+
this.updateJob(request.jobId, stage, 'RUNNING');
|
|
196
|
+
const snapshot = await this.collectSnapshot(request.draft);
|
|
197
|
+
const entries = snapshot.entries;
|
|
198
|
+
const mcpServers = this.selectedMcpServers(request.draft);
|
|
199
|
+
const mcpConfigHash = hashText(JSON.stringify(mcpServers));
|
|
200
|
+
stage = 'ENUMERATING';
|
|
201
|
+
this.updateJob(request.jobId, stage, 'RUNNING');
|
|
202
|
+
await rm(candidate, { recursive: true, force: true });
|
|
203
|
+
const contentDirectory = join(candidate, 'content');
|
|
204
|
+
await mkdir(contentDirectory, { recursive: true, mode: 0o700 });
|
|
205
|
+
for (const directory of snapshot.directories)
|
|
206
|
+
await mkdir(join(contentDirectory, ...directory.split('/')), {
|
|
207
|
+
recursive: true,
|
|
208
|
+
mode: 0o700
|
|
209
|
+
});
|
|
210
|
+
stage = 'COPYING';
|
|
211
|
+
this.updateJob(request.jobId, stage, 'RUNNING');
|
|
212
|
+
for (const entry of entries) {
|
|
213
|
+
const destination = join(contentDirectory, ...entry.relativePath.split('/'));
|
|
214
|
+
await mkdir(dirname(destination), { recursive: true, mode: 0o700 });
|
|
215
|
+
if (entry.kind === 'SYMLINK') {
|
|
216
|
+
const sourceMetadata = await lstat(entry.sourcePath);
|
|
217
|
+
if (!sourceMetadata.isSymbolicLink() ||
|
|
218
|
+
(await readlink(entry.sourcePath)) !== entry.linkTarget)
|
|
219
|
+
throw new Error('CONVERSATION_TEMPLATE_SOURCE_CHANGED');
|
|
220
|
+
await symlink(entry.linkTarget, destination);
|
|
221
|
+
const copiedTarget = await readlink(destination);
|
|
222
|
+
if (copiedTarget !== entry.linkTarget)
|
|
223
|
+
throw new Error('CONVERSATION_TEMPLATE_SOURCE_CHANGED');
|
|
224
|
+
continue;
|
|
225
|
+
}
|
|
226
|
+
await copyFile(entry.sourcePath, destination);
|
|
227
|
+
const copied = await lstat(destination);
|
|
228
|
+
if (!copied.isFile() || copied.isSymbolicLink() || copied.nlink !== 1)
|
|
229
|
+
throw new Error('CONVERSATION_TEMPLATE_SOURCE_LINK_INVALID');
|
|
230
|
+
await chmod(destination, entry.executable ? 0o555 : 0o444);
|
|
231
|
+
}
|
|
232
|
+
await Promise.all(['inbox', 'output'].map((name) => mkdir(join(contentDirectory, name), { recursive: true, mode: 0o700 })));
|
|
233
|
+
await sealDirectories(contentDirectory);
|
|
234
|
+
stage = 'SCANNING';
|
|
235
|
+
this.updateJob(request.jobId, stage, 'RUNNING');
|
|
236
|
+
await verifyCopiedSnapshot(contentDirectory, snapshot.directories, entries, true);
|
|
237
|
+
const versionNumber = this.nextVersionNumber(request.templateId);
|
|
238
|
+
const versionId = this.id();
|
|
239
|
+
const publishedAt = this.now();
|
|
240
|
+
const contentHash = snapshotContentHash(snapshot.directories, entries);
|
|
241
|
+
const manifest = {
|
|
242
|
+
schemaVersion: 2,
|
|
243
|
+
templateId: request.templateId,
|
|
244
|
+
versionId,
|
|
245
|
+
versionNumber,
|
|
246
|
+
draftRevision: request.draft.revision,
|
|
247
|
+
hostPolicyVersion: HOST_POLICY_VERSION,
|
|
248
|
+
publishedByUserId: request.requestedByUserId,
|
|
249
|
+
publishedAt,
|
|
250
|
+
sourceWorkspacePath: snapshot.sourceWorkspacePath,
|
|
251
|
+
draft: request.draft,
|
|
252
|
+
directories: snapshot.directories,
|
|
253
|
+
entries: entries.map((entry) => entry.kind === 'FILE'
|
|
254
|
+
? {
|
|
255
|
+
kind: entry.kind,
|
|
256
|
+
relativePath: entry.relativePath,
|
|
257
|
+
size: entry.size,
|
|
258
|
+
executable: entry.executable,
|
|
259
|
+
sha256: entry.sha256
|
|
260
|
+
}
|
|
261
|
+
: {
|
|
262
|
+
kind: entry.kind,
|
|
263
|
+
relativePath: entry.relativePath,
|
|
264
|
+
size: entry.size,
|
|
265
|
+
linkTarget: entry.linkTarget,
|
|
266
|
+
targetKind: entry.targetKind,
|
|
267
|
+
resolvedTarget: entry.resolvedTarget
|
|
268
|
+
}),
|
|
269
|
+
contentHash,
|
|
270
|
+
mcpServers,
|
|
271
|
+
mcpConfigHash
|
|
272
|
+
};
|
|
273
|
+
stage = 'MANIFEST';
|
|
274
|
+
this.updateJob(request.jobId, stage, 'RUNNING');
|
|
275
|
+
const manifestJson = JSON.stringify(manifest);
|
|
276
|
+
const manifestHash = hashText(manifestJson);
|
|
277
|
+
await writeFile(join(candidate, 'manifest.json'), `${manifestJson}\n`, { mode: 0o600 });
|
|
278
|
+
await chmod(join(candidate, 'manifest.json'), 0o444);
|
|
279
|
+
sealed = this.options.store.templateVersionDirectory(storageKey);
|
|
280
|
+
await rename(candidate, sealed);
|
|
281
|
+
await chmod(sealed, 0o555);
|
|
282
|
+
stage = 'SEALED';
|
|
283
|
+
this.updateJob(request.jobId, stage, 'RUNNING');
|
|
284
|
+
const version = conversationTemplateVersionSchema.parse({
|
|
285
|
+
id: versionId,
|
|
286
|
+
templateId: request.templateId,
|
|
287
|
+
version: versionNumber,
|
|
288
|
+
status: 'AVAILABLE',
|
|
289
|
+
contentHash,
|
|
290
|
+
manifestHash,
|
|
291
|
+
mcpConfigHash,
|
|
292
|
+
fileCount: entries.length,
|
|
293
|
+
totalBytes: entries.reduce((total, entry) => total + entry.size, 0),
|
|
294
|
+
hostPolicyVersion: HOST_POLICY_VERSION,
|
|
295
|
+
publishedByUserId: request.requestedByUserId,
|
|
296
|
+
publishedAt
|
|
297
|
+
});
|
|
298
|
+
this.registerVersion(request.jobId, storageKey, manifestJson, version);
|
|
299
|
+
stage = 'REGISTERED';
|
|
300
|
+
await this.finishRegisteredPublication(request.jobId);
|
|
301
|
+
}
|
|
302
|
+
catch (error) {
|
|
303
|
+
if (stage === 'REGISTERED')
|
|
304
|
+
return;
|
|
305
|
+
await writableRemove(candidate);
|
|
306
|
+
if (sealed !== undefined)
|
|
307
|
+
await writableRemove(sealed);
|
|
308
|
+
const code = safeErrorCode(error, 'CONVERSATION_TEMPLATE_PUBLISH_FAILED');
|
|
309
|
+
this.options.database.raw
|
|
310
|
+
.prepare(`UPDATE conversation_template_publish_jobs
|
|
311
|
+
SET stage=?,status='FAILED',version_id=NULL,error_code=?,error_summary=?,updated_at=? WHERE id=?`)
|
|
312
|
+
.run(stage, code, `The publish request failed (${code}).`, this.now(), request.jobId);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
async collectSnapshot(draft) {
|
|
316
|
+
this.assertLocalDraft(draft);
|
|
317
|
+
const workspace = this.options.database.getWorkspace(draft.workspaceId);
|
|
318
|
+
if (workspace === undefined)
|
|
319
|
+
throw new Error('WORKSPACE_NOT_FOUND');
|
|
320
|
+
const root = await realpath(workspace.path);
|
|
321
|
+
const sourceWorkspacePath = this.options.sourceWorkspacePath?.(root) ?? root;
|
|
322
|
+
validateSourceWorkspacePath(sourceWorkspacePath);
|
|
323
|
+
const directories = new Set();
|
|
324
|
+
const entries = new Map();
|
|
325
|
+
let totalBytes = 0;
|
|
326
|
+
const availableBytes = await hostedFilesystemAvailableBytes(this.options.store.rootDirectory);
|
|
327
|
+
await walkWorkspace(root, '', {
|
|
328
|
+
directory: (relativePath) => {
|
|
329
|
+
directories.add(relativePath);
|
|
330
|
+
},
|
|
331
|
+
file: async (filePath, relativePath, metadata) => {
|
|
332
|
+
if (entries.has(relativePath))
|
|
333
|
+
return;
|
|
334
|
+
const size = Number(metadata.size);
|
|
335
|
+
totalBytes += size;
|
|
336
|
+
if (!Number.isSafeInteger(totalBytes) || totalBytes > availableBytes)
|
|
337
|
+
throw new Error('CONVERSATION_HOSTING_STORAGE_FULL');
|
|
338
|
+
entries.set(relativePath, {
|
|
339
|
+
kind: 'FILE',
|
|
340
|
+
relativePath,
|
|
341
|
+
sourcePath: filePath,
|
|
342
|
+
size,
|
|
343
|
+
executable: (Number(metadata.mode) & 0o111) !== 0,
|
|
344
|
+
sha256: hashBuffer(await readFile(filePath))
|
|
345
|
+
});
|
|
346
|
+
},
|
|
347
|
+
symlink: async (filePath, relativePath, metadata) => {
|
|
348
|
+
if (entries.has(relativePath))
|
|
349
|
+
return;
|
|
350
|
+
const link = await publishedSymlink(root, filePath, relativePath, metadata);
|
|
351
|
+
totalBytes += link.size;
|
|
352
|
+
if (!Number.isSafeInteger(totalBytes) || totalBytes > availableBytes)
|
|
353
|
+
throw new Error('CONVERSATION_HOSTING_STORAGE_FULL');
|
|
354
|
+
entries.set(relativePath, link);
|
|
355
|
+
}
|
|
356
|
+
});
|
|
357
|
+
return {
|
|
358
|
+
sourceWorkspacePath,
|
|
359
|
+
directories: [...directories].sort((left, right) => left.localeCompare(right, 'en-US')),
|
|
360
|
+
entries: [...entries.values()].sort((left, right) => left.relativePath.localeCompare(right.relativePath, 'en-US'))
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
mcpOptions(workspaceId) {
|
|
364
|
+
return this.options.database.effectiveMcpInstallations(workspaceId).map((installation) => ({
|
|
365
|
+
id: installation.catalogEntryId,
|
|
366
|
+
serverName: installation.serverName,
|
|
367
|
+
displayName: installation.displayName,
|
|
368
|
+
transport: installation.runtime.transport,
|
|
369
|
+
origin: installation.targetKind
|
|
370
|
+
}));
|
|
371
|
+
}
|
|
372
|
+
selectedMcpServers(draft) {
|
|
373
|
+
const effective = new Map(this.options.database
|
|
374
|
+
.effectiveMcpInstallations(draft.workspaceId)
|
|
375
|
+
.map((installation) => [installation.catalogEntryId, installation]));
|
|
376
|
+
return draft.mcpIds.map((id) => {
|
|
377
|
+
const installation = effective.get(id);
|
|
378
|
+
if (installation === undefined ||
|
|
379
|
+
(installation.runtime.transport === 'HTTP' && draft.networkMode !== 'UNRESTRICTED'))
|
|
380
|
+
throw new Error('CONVERSATION_TEMPLATE_MCP_INVALID');
|
|
381
|
+
return {
|
|
382
|
+
id: installation.catalogEntryId,
|
|
383
|
+
serverName: installation.serverName,
|
|
384
|
+
displayName: installation.displayName,
|
|
385
|
+
version: installation.version,
|
|
386
|
+
origin: installation.targetKind,
|
|
387
|
+
transport: installation.runtime.transport,
|
|
388
|
+
runtime: installation.runtime,
|
|
389
|
+
configuration: installation.configuration
|
|
390
|
+
};
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
assertLocalDraft(raw) {
|
|
394
|
+
const draft = conversationTemplateDraftSchema.parse(raw);
|
|
395
|
+
if (draft.nodeId !== this.options.nodeId())
|
|
396
|
+
throw new Error('CONVERSATION_TEMPLATE_SOURCE_INVALID');
|
|
397
|
+
}
|
|
398
|
+
nextVersionNumber(templateId) {
|
|
399
|
+
const row = this.options.database.raw
|
|
400
|
+
.prepare('SELECT COALESCE(MAX(version_number),0) AS version_number FROM conversation_template_versions WHERE template_id=?')
|
|
401
|
+
.get(templateId);
|
|
402
|
+
return numberValue(row, 'version_number') + 1;
|
|
403
|
+
}
|
|
404
|
+
registerVersion(jobId, storageKey, manifest, version) {
|
|
405
|
+
const database = this.options.database.raw;
|
|
406
|
+
database.exec('BEGIN IMMEDIATE');
|
|
407
|
+
try {
|
|
408
|
+
const job = this.requirePublishJobRow(jobId);
|
|
409
|
+
if (stringValue(job, 'template_id') !== version.templateId ||
|
|
410
|
+
stringValue(job, 'stage') !== 'SEALED' ||
|
|
411
|
+
stringValue(job, 'status') !== 'RUNNING' ||
|
|
412
|
+
job['version_id'] !== null ||
|
|
413
|
+
numberValue(job, 'requested_by_user_id') !== version.publishedByUserId)
|
|
414
|
+
throw new Error('CONVERSATION_TEMPLATE_VERSION_CORRUPTED');
|
|
415
|
+
const inserted = database
|
|
416
|
+
.prepare(`INSERT INTO conversation_template_versions
|
|
417
|
+
(id,template_id,version_number,draft_revision,status,storage_key,manifest,content_hash,
|
|
418
|
+
manifest_hash,mcp_config_hash,file_count,total_bytes,host_policy_version,
|
|
419
|
+
published_by_user_id,published_at,reference_count)
|
|
420
|
+
VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,0)`)
|
|
421
|
+
.run(version.id, version.templateId, version.version, numberValue(job, 'draft_revision'), version.status, storageKey, manifest, version.contentHash, version.manifestHash, version.mcpConfigHash, version.fileCount, version.totalBytes, version.hostPolicyVersion, version.publishedByUserId, version.publishedAt);
|
|
422
|
+
if (Number(inserted.changes) !== 1)
|
|
423
|
+
throw new Error('CONVERSATION_TEMPLATE_VERSION_CORRUPTED');
|
|
424
|
+
const registered = database
|
|
425
|
+
.prepare(`UPDATE conversation_template_publish_jobs
|
|
426
|
+
SET stage='REGISTERED',status='RUNNING',version_id=?,error_code=NULL,error_summary=NULL,
|
|
427
|
+
updated_at=?
|
|
428
|
+
WHERE id=? AND template_id=? AND draft_revision=? AND requested_by_user_id=?
|
|
429
|
+
AND stage='SEALED' AND status='RUNNING' AND version_id IS NULL`)
|
|
430
|
+
.run(version.id, version.publishedAt, jobId, version.templateId, numberValue(job, 'draft_revision'), version.publishedByUserId);
|
|
431
|
+
if (Number(registered.changes) !== 1)
|
|
432
|
+
throw new Error('CONVERSATION_TEMPLATE_VERSION_CORRUPTED');
|
|
433
|
+
database.exec('COMMIT');
|
|
434
|
+
}
|
|
435
|
+
catch (error) {
|
|
436
|
+
database.exec('ROLLBACK');
|
|
437
|
+
throw error;
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
async finishRegisteredPublication(jobId) {
|
|
441
|
+
const job = this.requirePublishJobRow(jobId);
|
|
442
|
+
if (stringValue(job, 'stage') !== 'REGISTERED' ||
|
|
443
|
+
stringValue(job, 'status') !== 'RUNNING' ||
|
|
444
|
+
job['version_id'] === null)
|
|
445
|
+
throw new Error('CONVERSATION_TEMPLATE_VERSION_CORRUPTED');
|
|
446
|
+
const versionId = stringValue(job, 'version_id');
|
|
447
|
+
const version = this.options.database.raw
|
|
448
|
+
.prepare('SELECT template_id FROM conversation_template_versions WHERE id=?')
|
|
449
|
+
.get(versionId);
|
|
450
|
+
if (version === undefined ||
|
|
451
|
+
stringValue(version, 'template_id') !== stringValue(job, 'template_id'))
|
|
452
|
+
throw new Error('CONVERSATION_TEMPLATE_VERSION_CORRUPTED');
|
|
453
|
+
const completed = this.options.database.raw
|
|
454
|
+
.prepare(`UPDATE conversation_template_publish_jobs
|
|
455
|
+
SET status='SUCCEEDED',error_code=NULL,error_summary=NULL,updated_at=?
|
|
456
|
+
WHERE id=? AND stage='REGISTERED' AND status='RUNNING' AND version_id=?`)
|
|
457
|
+
.run(this.now(), jobId, versionId);
|
|
458
|
+
if (Number(completed.changes) !== 1)
|
|
459
|
+
throw new Error('CONVERSATION_TEMPLATE_VERSION_CORRUPTED');
|
|
460
|
+
}
|
|
461
|
+
async finishRegisteredPublications(templateId) {
|
|
462
|
+
const jobs = templateId === undefined
|
|
463
|
+
? this.options.database.raw
|
|
464
|
+
.prepare(`SELECT id FROM conversation_template_publish_jobs
|
|
465
|
+
WHERE stage='REGISTERED' AND status='RUNNING'
|
|
466
|
+
ORDER BY created_at,id`)
|
|
467
|
+
.all()
|
|
468
|
+
: this.options.database.raw
|
|
469
|
+
.prepare(`SELECT id FROM conversation_template_publish_jobs
|
|
470
|
+
WHERE template_id=? AND stage='REGISTERED' AND status='RUNNING'
|
|
471
|
+
ORDER BY created_at,id`)
|
|
472
|
+
.all(templateId);
|
|
473
|
+
for (const job of jobs)
|
|
474
|
+
await this.finishRegisteredPublication(stringValue(job, 'id'));
|
|
475
|
+
}
|
|
476
|
+
updateJob(jobId, stage, status) {
|
|
477
|
+
this.options.database.raw
|
|
478
|
+
.prepare('UPDATE conversation_template_publish_jobs SET stage=?,status=?,updated_at=? WHERE id=?')
|
|
479
|
+
.run(stage, status, this.now(), jobId);
|
|
480
|
+
}
|
|
481
|
+
publishResult(row) {
|
|
482
|
+
const job = publishJob(row);
|
|
483
|
+
const version = job.status !== 'SUCCEEDED' || job.versionId === undefined
|
|
484
|
+
? undefined
|
|
485
|
+
: this.options.database.raw
|
|
486
|
+
.prepare('SELECT * FROM conversation_template_versions WHERE id=?')
|
|
487
|
+
.get(job.versionId);
|
|
488
|
+
return conversationTemplatePublishResultSchema.parse({
|
|
489
|
+
job,
|
|
490
|
+
...(version === undefined ? {} : { version: templateVersion(version) })
|
|
491
|
+
});
|
|
492
|
+
}
|
|
493
|
+
publishJobRow(jobId) {
|
|
494
|
+
return this.options.database.raw
|
|
495
|
+
.prepare('SELECT * FROM conversation_template_publish_jobs WHERE id=?')
|
|
496
|
+
.get(jobId);
|
|
497
|
+
}
|
|
498
|
+
requirePublishJobRow(jobId) {
|
|
499
|
+
const row = this.publishJobRow(jobId);
|
|
500
|
+
if (row === undefined)
|
|
501
|
+
throw new Error('CONVERSATION_TEMPLATE_PUBLISH_JOB_NOT_FOUND');
|
|
502
|
+
return row;
|
|
503
|
+
}
|
|
504
|
+
async verifyVersion(row) {
|
|
505
|
+
const storageKey = stringValue(row, 'storage_key');
|
|
506
|
+
const root = this.options.store.templateVersionDirectory(storageKey);
|
|
507
|
+
const manifestText = await readFile(join(root, 'manifest.json'), 'utf8');
|
|
508
|
+
const manifestJson = manifestText.endsWith('\n') ? manifestText.slice(0, -1) : manifestText;
|
|
509
|
+
if (hashText(manifestJson) !== stringValue(row, 'manifest_hash'))
|
|
510
|
+
throw new Error('CONVERSATION_TEMPLATE_VERSION_CORRUPTED');
|
|
511
|
+
const manifest = templateVersionManifest(JSON.parse(manifestJson));
|
|
512
|
+
if (manifest.mcpConfigHash !== stringValue(row, 'mcp_config_hash') ||
|
|
513
|
+
hashText(JSON.stringify(manifest.mcpServers)) !== manifest.mcpConfigHash ||
|
|
514
|
+
manifest.contentHash !== stringValue(row, 'content_hash') ||
|
|
515
|
+
manifest.entries.length !== numberValue(row, 'file_count') ||
|
|
516
|
+
manifest.entries.reduce((total, entry) => total + entry.size, 0) !==
|
|
517
|
+
numberValue(row, 'total_bytes') ||
|
|
518
|
+
snapshotContentHash(manifest.directories, manifest.entries, manifest.schemaVersion) !==
|
|
519
|
+
manifest.contentHash)
|
|
520
|
+
throw new Error('CONVERSATION_TEMPLATE_VERSION_CORRUPTED');
|
|
521
|
+
const expected = new Map(manifest.entries.map((entry) => [entry.relativePath, entry]));
|
|
522
|
+
const expectedDirectories = new Set([...manifest.directories, 'inbox', 'output']);
|
|
523
|
+
const actualDirectories = new Set();
|
|
524
|
+
const actual = await listSnapshotEntries(join(root, 'content'), expectedDirectories, actualDirectories, true, 'CONVERSATION_TEMPLATE_VERSION_CORRUPTED');
|
|
525
|
+
if (actual.length !== expected.size || actualDirectories.size !== expectedDirectories.size)
|
|
526
|
+
throw new Error('CONVERSATION_TEMPLATE_VERSION_CORRUPTED');
|
|
527
|
+
for (const entry of actual) {
|
|
528
|
+
const expectation = expected.get(entry.relativePath);
|
|
529
|
+
if (expectation === undefined || expectation.kind !== entry.kind)
|
|
530
|
+
throw new Error('CONVERSATION_TEMPLATE_VERSION_CORRUPTED');
|
|
531
|
+
if (expectation.kind === 'FILE' && entry.kind === 'FILE') {
|
|
532
|
+
if (expectation.size !== entry.size ||
|
|
533
|
+
expectation.executable !== entry.executable ||
|
|
534
|
+
((await lstat(entry.sourcePath)).mode & 0o777) !==
|
|
535
|
+
(expectation.executable ? 0o555 : 0o444) ||
|
|
536
|
+
expectation.sha256 !== entry.sha256)
|
|
537
|
+
throw new Error('CONVERSATION_TEMPLATE_VERSION_CORRUPTED');
|
|
538
|
+
continue;
|
|
539
|
+
}
|
|
540
|
+
if (expectation.kind !== 'SYMLINK' ||
|
|
541
|
+
entry.kind !== 'SYMLINK' ||
|
|
542
|
+
expectation.size !== entry.size ||
|
|
543
|
+
expectation.linkTarget !== entry.linkTarget)
|
|
544
|
+
throw new Error('CONVERSATION_TEMPLATE_VERSION_CORRUPTED');
|
|
545
|
+
await verifySymlinkResolution(join(root, 'content'), expectation, entry.sourcePath, 'CONVERSATION_TEMPLATE_VERSION_CORRUPTED');
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
function publishJob(row) {
|
|
550
|
+
return conversationTemplatePublishJobSchema.parse({
|
|
551
|
+
id: stringValue(row, 'id'),
|
|
552
|
+
templateId: stringValue(row, 'template_id'),
|
|
553
|
+
draftRevision: numberValue(row, 'draft_revision'),
|
|
554
|
+
stage: stringValue(row, 'stage'),
|
|
555
|
+
status: stringValue(row, 'status'),
|
|
556
|
+
...(row['version_id'] === null ? {} : { versionId: stringValue(row, 'version_id') }),
|
|
557
|
+
errorCode: row['error_code'] === null ? null : stringValue(row, 'error_code'),
|
|
558
|
+
...(row['error_summary'] === null ? {} : { errorSummary: stringValue(row, 'error_summary') }),
|
|
559
|
+
createdAt: numberValue(row, 'created_at'),
|
|
560
|
+
updatedAt: numberValue(row, 'updated_at')
|
|
561
|
+
});
|
|
562
|
+
}
|
|
563
|
+
function templateVersion(row) {
|
|
564
|
+
return conversationTemplateVersionSchema.parse({
|
|
565
|
+
id: stringValue(row, 'id'),
|
|
566
|
+
templateId: stringValue(row, 'template_id'),
|
|
567
|
+
version: numberValue(row, 'version_number'),
|
|
568
|
+
status: stringValue(row, 'status'),
|
|
569
|
+
contentHash: stringValue(row, 'content_hash'),
|
|
570
|
+
manifestHash: stringValue(row, 'manifest_hash'),
|
|
571
|
+
mcpConfigHash: stringValue(row, 'mcp_config_hash'),
|
|
572
|
+
fileCount: numberValue(row, 'file_count'),
|
|
573
|
+
totalBytes: numberValue(row, 'total_bytes'),
|
|
574
|
+
hostPolicyVersion: numberValue(row, 'host_policy_version'),
|
|
575
|
+
publishedByUserId: numberValue(row, 'published_by_user_id'),
|
|
576
|
+
publishedAt: numberValue(row, 'published_at')
|
|
577
|
+
});
|
|
578
|
+
}
|
|
579
|
+
async function walkWorkspace(path, relativePath, walker) {
|
|
580
|
+
const metadata = await lstat(path).catch((error) => {
|
|
581
|
+
if (error.code === 'ENOENT')
|
|
582
|
+
throw new Error('CONVERSATION_TEMPLATE_SOURCE_MISSING');
|
|
583
|
+
throw error;
|
|
584
|
+
});
|
|
585
|
+
if (metadata.isSymbolicLink()) {
|
|
586
|
+
if (relativePath.length === 0)
|
|
587
|
+
throw new Error('CONVERSATION_TEMPLATE_SOURCE_LINK_INVALID');
|
|
588
|
+
await walker.symlink(path, relativePath, metadata);
|
|
589
|
+
return;
|
|
590
|
+
}
|
|
591
|
+
if (metadata.isFile()) {
|
|
592
|
+
if (relativePath.length === 0)
|
|
593
|
+
throw new Error('CONVERSATION_TEMPLATE_SOURCE_INVALID');
|
|
594
|
+
await walker.file(path, relativePath, metadata);
|
|
595
|
+
return;
|
|
596
|
+
}
|
|
597
|
+
if (!metadata.isDirectory())
|
|
598
|
+
throw new Error('CONVERSATION_TEMPLATE_SOURCE_TYPE_INVALID');
|
|
599
|
+
if (relativePath.length > 0)
|
|
600
|
+
walker.directory(relativePath);
|
|
601
|
+
for (const entry of (await readdir(path, { withFileTypes: true })).sort((left, right) => left.name.localeCompare(right.name, 'en-US'))) {
|
|
602
|
+
const childPath = join(path, entry.name);
|
|
603
|
+
const childRelative = relativePath.length === 0 ? entry.name : `${relativePath}/${entry.name}`;
|
|
604
|
+
if (relativePath.length === 0 && (entry.name === 'inbox' || entry.name === 'output'))
|
|
605
|
+
throw new Error('CONVERSATION_TEMPLATE_RESERVED_PATH');
|
|
606
|
+
if (forcedExcluded(childRelative))
|
|
607
|
+
continue;
|
|
608
|
+
if (relativePath.length === 0 && entry.name === ROOT_TEMPLATE_INSTRUCTIONS_SOURCE) {
|
|
609
|
+
const templateInstructions = await lstat(childPath);
|
|
610
|
+
if (!templateInstructions.isFile() || templateInstructions.isSymbolicLink())
|
|
611
|
+
throw new Error('CONVERSATION_TEMPLATE_SOURCE_TYPE_INVALID');
|
|
612
|
+
await walker.file(childPath, ROOT_TEMPLATE_INSTRUCTIONS_TARGET, templateInstructions);
|
|
613
|
+
continue;
|
|
614
|
+
}
|
|
615
|
+
await walkWorkspace(childPath, childRelative, walker);
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
async function sealDirectories(root, sealRoot = true) {
|
|
619
|
+
const entries = await readdir(root, { withFileTypes: true });
|
|
620
|
+
for (const entry of entries)
|
|
621
|
+
if (entry.isDirectory())
|
|
622
|
+
await sealDirectories(join(root, entry.name));
|
|
623
|
+
if (sealRoot)
|
|
624
|
+
await chmod(root, 0o555);
|
|
625
|
+
}
|
|
626
|
+
async function writableRemove(path) {
|
|
627
|
+
await chmodTree(path).catch(() => undefined);
|
|
628
|
+
await rm(path, { recursive: true, force: true });
|
|
629
|
+
}
|
|
630
|
+
async function chmodTree(path) {
|
|
631
|
+
const metadata = await lstat(path);
|
|
632
|
+
if (metadata.isSymbolicLink())
|
|
633
|
+
return;
|
|
634
|
+
if (metadata.isDirectory()) {
|
|
635
|
+
await chmod(path, 0o700);
|
|
636
|
+
for (const entry of await readdir(path))
|
|
637
|
+
await chmodTree(join(path, entry));
|
|
638
|
+
}
|
|
639
|
+
else
|
|
640
|
+
await chmod(path, 0o600);
|
|
641
|
+
}
|
|
642
|
+
async function verifyCopiedSnapshot(contentDirectory, publishedDirectories, expectedEntries, sealed) {
|
|
643
|
+
const expected = new Map(expectedEntries.map((entry) => [entry.relativePath, entry]));
|
|
644
|
+
const expectedDirectories = new Set([...publishedDirectories, 'inbox', 'output']);
|
|
645
|
+
const actualDirectories = new Set();
|
|
646
|
+
const actual = await listSnapshotEntries(contentDirectory, expectedDirectories, actualDirectories, sealed, 'CONVERSATION_TEMPLATE_SOURCE_CHANGED');
|
|
647
|
+
if (actualDirectories.size !== expectedDirectories.size)
|
|
648
|
+
throw new Error('CONVERSATION_TEMPLATE_SOURCE_CHANGED');
|
|
649
|
+
if (actual.length !== expected.size)
|
|
650
|
+
throw new Error('CONVERSATION_TEMPLATE_SOURCE_CHANGED');
|
|
651
|
+
for (const entry of actual) {
|
|
652
|
+
const expectedEntry = expected.get(entry.relativePath);
|
|
653
|
+
if (expectedEntry === undefined || expectedEntry.kind !== entry.kind)
|
|
654
|
+
throw new Error('CONVERSATION_TEMPLATE_SOURCE_CHANGED');
|
|
655
|
+
if (expectedEntry.kind === 'FILE' && entry.kind === 'FILE') {
|
|
656
|
+
if (expectedEntry.size !== entry.size ||
|
|
657
|
+
expectedEntry.executable !== entry.executable ||
|
|
658
|
+
expectedEntry.sha256 !== entry.sha256)
|
|
659
|
+
throw new Error('CONVERSATION_TEMPLATE_SOURCE_CHANGED');
|
|
660
|
+
continue;
|
|
661
|
+
}
|
|
662
|
+
if (expectedEntry.kind !== 'SYMLINK' ||
|
|
663
|
+
entry.kind !== 'SYMLINK' ||
|
|
664
|
+
expectedEntry.size !== entry.size ||
|
|
665
|
+
expectedEntry.linkTarget !== entry.linkTarget)
|
|
666
|
+
throw new Error('CONVERSATION_TEMPLATE_SOURCE_CHANGED');
|
|
667
|
+
await verifySymlinkResolution(contentDirectory, expectedEntry, entry.sourcePath, 'CONVERSATION_TEMPLATE_SOURCE_CHANGED');
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
async function verifySymlinkResolution(contentDirectory, expected, path, errorCode) {
|
|
671
|
+
let actualTarget;
|
|
672
|
+
try {
|
|
673
|
+
actualTarget = await realpath(path);
|
|
674
|
+
}
|
|
675
|
+
catch {
|
|
676
|
+
throw new Error(errorCode);
|
|
677
|
+
}
|
|
678
|
+
if (expected.targetKind === 'RUNTIME') {
|
|
679
|
+
if (actualTarget !== expected.resolvedTarget)
|
|
680
|
+
throw new Error(errorCode);
|
|
681
|
+
return;
|
|
682
|
+
}
|
|
683
|
+
let expectedTarget;
|
|
684
|
+
try {
|
|
685
|
+
expectedTarget = await realpath(join(contentDirectory, ...expected.resolvedTarget.split('/')));
|
|
686
|
+
}
|
|
687
|
+
catch {
|
|
688
|
+
throw new Error(errorCode);
|
|
689
|
+
}
|
|
690
|
+
if (actualTarget !== expectedTarget || !within(await realpath(contentDirectory), actualTarget))
|
|
691
|
+
throw new Error(errorCode);
|
|
692
|
+
}
|
|
693
|
+
async function listSnapshotEntries(root, expectedDirectories, actualDirectories, sealed, errorCode, prefix = '') {
|
|
694
|
+
const rootMetadata = await lstat(root);
|
|
695
|
+
if (!rootMetadata.isDirectory() ||
|
|
696
|
+
rootMetadata.isSymbolicLink() ||
|
|
697
|
+
(sealed && (rootMetadata.mode & 0o777) !== 0o555))
|
|
698
|
+
throw new Error(errorCode);
|
|
699
|
+
const entries = [];
|
|
700
|
+
for (const entry of await readdir(root, { withFileTypes: true })) {
|
|
701
|
+
const path = join(root, entry.name);
|
|
702
|
+
const relativePath = prefix.length === 0 ? entry.name : `${prefix}/${entry.name}`;
|
|
703
|
+
const metadata = await lstat(path);
|
|
704
|
+
if (metadata.isSymbolicLink()) {
|
|
705
|
+
const linkTarget = await readlink(path);
|
|
706
|
+
entries.push({
|
|
707
|
+
kind: 'SYMLINK',
|
|
708
|
+
relativePath,
|
|
709
|
+
sourcePath: path,
|
|
710
|
+
size: Buffer.byteLength(linkTarget),
|
|
711
|
+
linkTarget
|
|
712
|
+
});
|
|
713
|
+
continue;
|
|
714
|
+
}
|
|
715
|
+
if (metadata.isDirectory()) {
|
|
716
|
+
if (!expectedDirectories.has(relativePath))
|
|
717
|
+
throw new Error(errorCode);
|
|
718
|
+
actualDirectories.add(relativePath);
|
|
719
|
+
entries.push(...(await listSnapshotEntries(path, expectedDirectories, actualDirectories, sealed, errorCode, relativePath)));
|
|
720
|
+
continue;
|
|
721
|
+
}
|
|
722
|
+
if (!metadata.isFile() ||
|
|
723
|
+
metadata.nlink !== 1 ||
|
|
724
|
+
(sealed && (metadata.mode & 0o777) !== (metadata.mode & 0o111 ? 0o555 : 0o444)))
|
|
725
|
+
throw new Error(errorCode);
|
|
726
|
+
entries.push({
|
|
727
|
+
kind: 'FILE',
|
|
728
|
+
relativePath,
|
|
729
|
+
sourcePath: path,
|
|
730
|
+
size: Number(metadata.size),
|
|
731
|
+
executable: (metadata.mode & 0o111) !== 0,
|
|
732
|
+
sha256: hashBuffer(await readFile(path))
|
|
733
|
+
});
|
|
734
|
+
}
|
|
735
|
+
return entries;
|
|
736
|
+
}
|
|
737
|
+
function legacyPublishedDirectories(entries) {
|
|
738
|
+
const directories = new Set(['inbox', 'output']);
|
|
739
|
+
for (const entry of entries) {
|
|
740
|
+
const parts = entry.relativePath.split('/');
|
|
741
|
+
for (let index = 1; index < parts.length; index += 1)
|
|
742
|
+
directories.add(parts.slice(0, index).join('/'));
|
|
743
|
+
}
|
|
744
|
+
directories.delete('inbox');
|
|
745
|
+
directories.delete('output');
|
|
746
|
+
return [...directories].sort((left, right) => left.localeCompare(right, 'en-US'));
|
|
747
|
+
}
|
|
748
|
+
function forcedExcluded(relativePath) {
|
|
749
|
+
const parts = relativePath.split('/');
|
|
750
|
+
if (parts.some((part) => {
|
|
751
|
+
const lower = part.toLocaleLowerCase('en-US');
|
|
752
|
+
return FORCED_EXCLUDED_NAMES.has(lower) || lower.startsWith('.env');
|
|
753
|
+
}))
|
|
754
|
+
return true;
|
|
755
|
+
const leaf = parts.at(-1)?.toLocaleLowerCase('en-US') ?? '';
|
|
756
|
+
return ((parts.length === 1 &&
|
|
757
|
+
(ROOT_EXCLUDED_NAMES.has(leaf) ||
|
|
758
|
+
leaf.endsWith('.pem') ||
|
|
759
|
+
leaf.endsWith('.key') ||
|
|
760
|
+
leaf === 'id_rsa' ||
|
|
761
|
+
leaf === 'id_ed25519')) ||
|
|
762
|
+
leaf.endsWith('.sock'));
|
|
763
|
+
}
|
|
764
|
+
async function publishedSymlink(workspaceRoot, path, relativePath, metadata) {
|
|
765
|
+
if (!metadata.isSymbolicLink())
|
|
766
|
+
throw new Error('CONVERSATION_TEMPLATE_SOURCE_LINK_INVALID');
|
|
767
|
+
const linkTarget = await readlink(path);
|
|
768
|
+
let resolvedTarget;
|
|
769
|
+
try {
|
|
770
|
+
resolvedTarget = await realpath(path);
|
|
771
|
+
}
|
|
772
|
+
catch {
|
|
773
|
+
throw new Error('CONVERSATION_TEMPLATE_SOURCE_LINK_INVALID');
|
|
774
|
+
}
|
|
775
|
+
if (resolvedTarget === workspaceRoot || within(workspaceRoot, resolvedTarget)) {
|
|
776
|
+
const targetMetadata = await lstat(resolvedTarget).catch(() => undefined);
|
|
777
|
+
if (targetMetadata === undefined ||
|
|
778
|
+
(targetMetadata.isDirectory() &&
|
|
779
|
+
(resolvedTarget === workspaceRoot || within(resolvedTarget, path))))
|
|
780
|
+
throw new Error('CONVERSATION_TEMPLATE_SOURCE_LINK_INVALID');
|
|
781
|
+
const targetRelative = relative(workspaceRoot, resolvedTarget).split(sep).join('/');
|
|
782
|
+
if (targetRelative.length === 0 || forcedExcluded(targetRelative))
|
|
783
|
+
throw new Error('CONVERSATION_TEMPLATE_SOURCE_LINK_INVALID');
|
|
784
|
+
return {
|
|
785
|
+
kind: 'SYMLINK',
|
|
786
|
+
relativePath,
|
|
787
|
+
sourcePath: path,
|
|
788
|
+
size: Buffer.byteLength(linkTarget),
|
|
789
|
+
linkTarget,
|
|
790
|
+
targetKind: 'SNAPSHOT',
|
|
791
|
+
resolvedTarget: targetRelative
|
|
792
|
+
};
|
|
793
|
+
}
|
|
794
|
+
const runtimeTarget = RUNTIME_LINK_ROOTS.find((root) => resolvedTarget === root || within(root, resolvedTarget));
|
|
795
|
+
if (runtimeTarget === undefined)
|
|
796
|
+
throw new Error('CONVERSATION_TEMPLATE_SOURCE_LINK_INVALID');
|
|
797
|
+
return {
|
|
798
|
+
kind: 'SYMLINK',
|
|
799
|
+
relativePath,
|
|
800
|
+
sourcePath: path,
|
|
801
|
+
size: Buffer.byteLength(linkTarget),
|
|
802
|
+
linkTarget,
|
|
803
|
+
targetKind: 'RUNTIME',
|
|
804
|
+
resolvedTarget
|
|
805
|
+
};
|
|
806
|
+
}
|
|
807
|
+
function templateVersionManifest(input) {
|
|
808
|
+
if (!record(input))
|
|
809
|
+
throw new Error('CONVERSATION_TEMPLATE_VERSION_CORRUPTED');
|
|
810
|
+
const mcpServers = Array.isArray(input['mcpServers'])
|
|
811
|
+
? input['mcpServers']
|
|
812
|
+
: undefined;
|
|
813
|
+
if (mcpServers === undefined ||
|
|
814
|
+
typeof input['mcpConfigHash'] !== 'string' ||
|
|
815
|
+
typeof input['contentHash'] !== 'string')
|
|
816
|
+
throw new Error('CONVERSATION_TEMPLATE_VERSION_CORRUPTED');
|
|
817
|
+
if (input['schemaVersion'] === 1) {
|
|
818
|
+
if (!Array.isArray(input['files']))
|
|
819
|
+
throw new Error('CONVERSATION_TEMPLATE_VERSION_CORRUPTED');
|
|
820
|
+
const entries = input['files'].map((value) => manifestFile(value));
|
|
821
|
+
return {
|
|
822
|
+
schemaVersion: 1,
|
|
823
|
+
directories: legacyPublishedDirectories(entries),
|
|
824
|
+
entries,
|
|
825
|
+
contentHash: input['contentHash'],
|
|
826
|
+
mcpServers,
|
|
827
|
+
mcpConfigHash: input['mcpConfigHash']
|
|
828
|
+
};
|
|
829
|
+
}
|
|
830
|
+
if (input['schemaVersion'] !== 2 ||
|
|
831
|
+
typeof input['sourceWorkspacePath'] !== 'string' ||
|
|
832
|
+
!Array.isArray(input['directories']) ||
|
|
833
|
+
!Array.isArray(input['entries']))
|
|
834
|
+
throw new Error('CONVERSATION_TEMPLATE_VERSION_CORRUPTED');
|
|
835
|
+
validateSourceWorkspacePath(input['sourceWorkspacePath']);
|
|
836
|
+
const directories = input['directories'].map((value) => safeManifestRelativePath(value));
|
|
837
|
+
if (new Set(directories).size !== directories.length ||
|
|
838
|
+
directories.includes('inbox') ||
|
|
839
|
+
directories.includes('output'))
|
|
840
|
+
throw new Error('CONVERSATION_TEMPLATE_VERSION_CORRUPTED');
|
|
841
|
+
const entries = input['entries'].map((value) => manifestEntry(value));
|
|
842
|
+
if (new Set(entries.map((entry) => entry.relativePath)).size !== entries.length)
|
|
843
|
+
throw new Error('CONVERSATION_TEMPLATE_VERSION_CORRUPTED');
|
|
844
|
+
return {
|
|
845
|
+
schemaVersion: 2,
|
|
846
|
+
sourceWorkspacePath: input['sourceWorkspacePath'],
|
|
847
|
+
directories,
|
|
848
|
+
entries,
|
|
849
|
+
contentHash: input['contentHash'],
|
|
850
|
+
mcpServers,
|
|
851
|
+
mcpConfigHash: input['mcpConfigHash']
|
|
852
|
+
};
|
|
853
|
+
}
|
|
854
|
+
function manifestEntry(input) {
|
|
855
|
+
if (!record(input))
|
|
856
|
+
throw new Error('CONVERSATION_TEMPLATE_VERSION_CORRUPTED');
|
|
857
|
+
if (input['kind'] === 'FILE')
|
|
858
|
+
return manifestFile(input, true);
|
|
859
|
+
if (input['kind'] !== 'SYMLINK' ||
|
|
860
|
+
typeof input['linkTarget'] !== 'string' ||
|
|
861
|
+
input['linkTarget'].length === 0 ||
|
|
862
|
+
input['linkTarget'].includes('\0') ||
|
|
863
|
+
(input['targetKind'] !== 'SNAPSHOT' && input['targetKind'] !== 'RUNTIME') ||
|
|
864
|
+
typeof input['resolvedTarget'] !== 'string')
|
|
865
|
+
throw new Error('CONVERSATION_TEMPLATE_VERSION_CORRUPTED');
|
|
866
|
+
const relativePath = safeManifestRelativePath(input['relativePath']);
|
|
867
|
+
const size = safeNonNegativeInteger(input['size']);
|
|
868
|
+
const linkTarget = input['linkTarget'];
|
|
869
|
+
const targetKind = input['targetKind'];
|
|
870
|
+
const resolvedTarget = input['resolvedTarget'];
|
|
871
|
+
if (size !== Buffer.byteLength(linkTarget))
|
|
872
|
+
throw new Error('CONVERSATION_TEMPLATE_VERSION_CORRUPTED');
|
|
873
|
+
if (targetKind === 'SNAPSHOT')
|
|
874
|
+
safeManifestRelativePath(resolvedTarget);
|
|
875
|
+
else if (!isAbsolute(resolvedTarget) ||
|
|
876
|
+
!RUNTIME_LINK_ROOTS.some((root) => resolvedTarget === root || within(root, resolvedTarget)))
|
|
877
|
+
throw new Error('CONVERSATION_TEMPLATE_VERSION_CORRUPTED');
|
|
878
|
+
return {
|
|
879
|
+
kind: 'SYMLINK',
|
|
880
|
+
relativePath,
|
|
881
|
+
size,
|
|
882
|
+
linkTarget,
|
|
883
|
+
targetKind,
|
|
884
|
+
resolvedTarget
|
|
885
|
+
};
|
|
886
|
+
}
|
|
887
|
+
function manifestFile(input, requireKind = false) {
|
|
888
|
+
if (!record(input) ||
|
|
889
|
+
(requireKind && input['kind'] !== 'FILE') ||
|
|
890
|
+
typeof input['executable'] !== 'boolean' ||
|
|
891
|
+
typeof input['sha256'] !== 'string' ||
|
|
892
|
+
!/^[a-f0-9]{64}$/u.test(input['sha256']))
|
|
893
|
+
throw new Error('CONVERSATION_TEMPLATE_VERSION_CORRUPTED');
|
|
894
|
+
return {
|
|
895
|
+
kind: 'FILE',
|
|
896
|
+
relativePath: safeManifestRelativePath(input['relativePath']),
|
|
897
|
+
size: safeNonNegativeInteger(input['size']),
|
|
898
|
+
executable: input['executable'],
|
|
899
|
+
sha256: input['sha256']
|
|
900
|
+
};
|
|
901
|
+
}
|
|
902
|
+
function safeManifestRelativePath(input) {
|
|
903
|
+
if (typeof input !== 'string' ||
|
|
904
|
+
input.length === 0 ||
|
|
905
|
+
input.startsWith('/') ||
|
|
906
|
+
input.includes('\\') ||
|
|
907
|
+
input.split('/').some((segment) => segment.length === 0 || segment === '.' || segment === '..'))
|
|
908
|
+
throw new Error('CONVERSATION_TEMPLATE_VERSION_CORRUPTED');
|
|
909
|
+
return input;
|
|
910
|
+
}
|
|
911
|
+
function safeNonNegativeInteger(input) {
|
|
912
|
+
if (!Number.isSafeInteger(input) || input < 0)
|
|
913
|
+
throw new Error('CONVERSATION_TEMPLATE_VERSION_CORRUPTED');
|
|
914
|
+
return input;
|
|
915
|
+
}
|
|
916
|
+
function snapshotContentHash(directories, entries, schemaVersion = 2) {
|
|
917
|
+
if (schemaVersion === 1)
|
|
918
|
+
return hashText(entries
|
|
919
|
+
.map((entry) => {
|
|
920
|
+
if (entry.kind !== 'FILE')
|
|
921
|
+
throw new Error('CONVERSATION_TEMPLATE_VERSION_CORRUPTED');
|
|
922
|
+
return `${entry.relativePath}\0${entry.size}\0${entry.sha256}`;
|
|
923
|
+
})
|
|
924
|
+
.join('\n'));
|
|
925
|
+
return hashText([
|
|
926
|
+
...directories.map((directory) => `DIRECTORY\0${directory}`),
|
|
927
|
+
...entries.map((entry) => entry.kind === 'FILE'
|
|
928
|
+
? `${entry.kind}\0${entry.relativePath}\0${entry.size}\0${entry.executable ? 1 : 0}\0${entry.sha256}`
|
|
929
|
+
: `${entry.kind}\0${entry.relativePath}\0${entry.size}\0${entry.linkTarget}\0${entry.targetKind}\0${entry.resolvedTarget}`)
|
|
930
|
+
].join('\n'));
|
|
931
|
+
}
|
|
932
|
+
async function hostedFilesystemAvailableBytes(path) {
|
|
933
|
+
try {
|
|
934
|
+
const filesystem = await statfs(path);
|
|
935
|
+
const available = Number(filesystem.bavail) * Number(filesystem.bsize);
|
|
936
|
+
if (!Number.isFinite(available) || available < 0)
|
|
937
|
+
throw new Error('CONVERSATION_HOSTING_STORAGE_UNAVAILABLE');
|
|
938
|
+
return Math.min(Math.floor(available), Number.MAX_SAFE_INTEGER);
|
|
939
|
+
}
|
|
940
|
+
catch (error) {
|
|
941
|
+
if (error instanceof Error && error.message === 'CONVERSATION_HOSTING_STORAGE_UNAVAILABLE')
|
|
942
|
+
throw error;
|
|
943
|
+
throw new Error('CONVERSATION_HOSTING_STORAGE_UNAVAILABLE');
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
function validateSourceWorkspacePath(path) {
|
|
947
|
+
if (!isAbsolute(path) || resolve(path) !== path || path === '/')
|
|
948
|
+
throw new Error('CONVERSATION_TEMPLATE_SOURCE_INVALID');
|
|
949
|
+
if (RESERVED_SANDBOX_ROOTS.some((root) => path === root || within(root, path) || within(path, root)))
|
|
950
|
+
throw new Error('CONVERSATION_TEMPLATE_SOURCE_INVALID');
|
|
951
|
+
}
|
|
952
|
+
function within(parent, candidate) {
|
|
953
|
+
const relation = relative(parent, candidate);
|
|
954
|
+
return relation.length > 0 && relation !== '..' && !relation.startsWith(`..${sep}`);
|
|
955
|
+
}
|
|
956
|
+
function hashText(value) {
|
|
957
|
+
return createHash('sha256').update(value).digest('hex');
|
|
958
|
+
}
|
|
959
|
+
function hashBuffer(value) {
|
|
960
|
+
return createHash('sha256').update(value).digest('hex');
|
|
961
|
+
}
|
|
962
|
+
function stringValue(row, key) {
|
|
963
|
+
const value = row[key];
|
|
964
|
+
if (typeof value !== 'string')
|
|
965
|
+
throw new Error(`DATABASE_VALUE_INVALID:${key}`);
|
|
966
|
+
return value;
|
|
967
|
+
}
|
|
968
|
+
function numberValue(row, key) {
|
|
969
|
+
const value = row[key];
|
|
970
|
+
if (typeof value !== 'number' && typeof value !== 'bigint')
|
|
971
|
+
throw new Error(`DATABASE_VALUE_INVALID:${key}`);
|
|
972
|
+
const number = Number(value);
|
|
973
|
+
if (!Number.isSafeInteger(number))
|
|
974
|
+
throw new Error(`DATABASE_VALUE_INVALID:${key}`);
|
|
975
|
+
return number;
|
|
976
|
+
}
|
|
977
|
+
function nodeRequestPayload(raw) {
|
|
978
|
+
if (!record(raw))
|
|
979
|
+
return { data: raw };
|
|
980
|
+
const { __requestUserId, ...data } = raw;
|
|
981
|
+
delete data.__workspaceWatchSessionHash;
|
|
982
|
+
if (__requestUserId === undefined)
|
|
983
|
+
return { data };
|
|
984
|
+
if (typeof __requestUserId !== 'number' ||
|
|
985
|
+
!Number.isSafeInteger(__requestUserId) ||
|
|
986
|
+
__requestUserId <= 0)
|
|
987
|
+
throw new Error('CONVERSATION_TEMPLATE_NOT_AUTHORIZED');
|
|
988
|
+
return { data, requestUserId: __requestUserId };
|
|
989
|
+
}
|
|
990
|
+
function record(value) {
|
|
991
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
992
|
+
}
|