@sapienx/agentos 0.4.1 → 0.4.6
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 +21 -0
- package/README.md +2 -0
- package/bundle/.next/BUILD_ID +1 -1
- package/bundle/.next/app-path-routes-manifest.json +12 -9
- package/bundle/.next/build-manifest.json +6 -6
- package/bundle/.next/prerender-manifest.json +3 -3
- package/bundle/.next/react-loadable-manifest.json +4 -4
- package/bundle/.next/routes-manifest.json +20 -0
- package/bundle/.next/server/app/_global-error/page.js +3 -3
- package/bundle/.next/server/app/_global-error/page.js.nft.json +1 -1
- package/bundle/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/bundle/.next/server/app/_global-error.html +1 -1
- package/bundle/.next/server/app/_global-error.rsc +7 -7
- package/bundle/.next/server/app/_global-error.segments/_full.segment.rsc +7 -7
- package/bundle/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +2 -2
- package/bundle/.next/server/app/_global-error.segments/_global-error.segment.rsc +3 -3
- package/bundle/.next/server/app/_global-error.segments/_head.segment.rsc +3 -3
- package/bundle/.next/server/app/_global-error.segments/_index.segment.rsc +3 -3
- package/bundle/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/bundle/.next/server/app/_not-found/page.js +2 -2
- package/bundle/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/bundle/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/bundle/.next/server/app/_not-found.html +1 -1
- package/bundle/.next/server/app/_not-found.rsc +11 -11
- package/bundle/.next/server/app/_not-found.segments/_full.segment.rsc +11 -11
- package/bundle/.next/server/app/_not-found.segments/_head.segment.rsc +4 -4
- package/bundle/.next/server/app/_not-found.segments/_index.segment.rsc +5 -5
- package/bundle/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +2 -2
- package/bundle/.next/server/app/_not-found.segments/_not-found.segment.rsc +3 -3
- package/bundle/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/bundle/.next/server/app/api/agents/[agentId]/chat/route.js +5 -5
- package/bundle/.next/server/app/api/agents/[agentId]/chat/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/agents/route.js +1 -1
- package/bundle/.next/server/app/api/agents/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/diagnostics/route.js +1 -1
- package/bundle/.next/server/app/api/diagnostics/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/files/reveal/route.js +1 -1
- package/bundle/.next/server/app/api/files/reveal/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/gateway/control/route.js +1 -1
- package/bundle/.next/server/app/api/gateway/control/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/mission/route.js +1 -1
- package/bundle/.next/server/app/api/mission/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/models/catalog/route.js +2 -1
- package/bundle/.next/server/app/api/models/catalog/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/models/providers/route.js +2 -2
- package/bundle/.next/server/app/api/models/providers/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/onboarding/models/route.js +5 -5
- package/bundle/.next/server/app/api/onboarding/models/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/onboarding/route.js +6 -6
- package/bundle/.next/server/app/api/onboarding/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/openclaw/capabilities/route.js +1 -3
- package/bundle/.next/server/app/api/openclaw/capabilities/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/planner/[planId]/deploy/route.js +2 -2
- package/bundle/.next/server/app/api/planner/[planId]/deploy/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/planner/[planId]/document-rewrite/route.js +1 -1
- package/bundle/.next/server/app/api/planner/[planId]/document-rewrite/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/planner/[planId]/route.js +1 -1
- package/bundle/.next/server/app/api/planner/[planId]/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/planner/[planId]/simulate/route.js +1 -1
- package/bundle/.next/server/app/api/planner/[planId]/simulate/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/planner/[planId]/turn/route.js +1 -1
- package/bundle/.next/server/app/api/planner/[planId]/turn/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/planner/route.js +1 -1
- package/bundle/.next/server/app/api/planner/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/reset/route.js +3 -3
- package/bundle/.next/server/app/api/reset/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/runtimes/[runtimeId]/route.js +1 -1
- package/bundle/.next/server/app/api/runtimes/[runtimeId]/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/settings/gateway/route.js +1 -1
- package/bundle/.next/server/app/api/settings/gateway/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/settings/openclaw-binary/route.js +1 -0
- package/bundle/.next/server/app/api/settings/openclaw-binary/route.js.nft.json +1 -0
- package/bundle/.next/server/app/api/settings/openclaw-binary/route_client-reference-manifest.js +1 -0
- package/bundle/.next/server/app/api/settings/workspace-root/route.js +1 -1
- package/bundle/.next/server/app/api/settings/workspace-root/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/snapshot/route.js +1 -1
- package/bundle/.next/server/app/api/snapshot/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/stream/route.js +2 -2
- package/bundle/.next/server/app/api/stream/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/system/open-terminal/route.js +1 -1
- package/bundle/.next/server/app/api/system/open-terminal/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/tasks/[taskId]/abort/route.js +1 -1
- package/bundle/.next/server/app/api/tasks/[taskId]/abort/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/tasks/[taskId]/stream/route.js +2 -2
- package/bundle/.next/server/app/api/tasks/[taskId]/stream/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/update/route.js +7 -4
- package/bundle/.next/server/app/api/update/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/workspaces/[workspaceId]/channels/discovered-groups/route.js +1 -1
- package/bundle/.next/server/app/api/workspaces/[workspaceId]/channels/discovered-groups/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/workspaces/[workspaceId]/channels/route.js +1 -1
- package/bundle/.next/server/app/api/workspaces/[workspaceId]/channels/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/workspaces/[workspaceId]/edit-draft/route.js +1 -1
- package/bundle/.next/server/app/api/workspaces/[workspaceId]/edit-draft/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/workspaces/[workspaceId]/files/route.js +1 -0
- package/bundle/.next/server/app/api/workspaces/[workspaceId]/files/route.js.nft.json +1 -0
- package/bundle/.next/server/app/api/workspaces/[workspaceId]/files/route_client-reference-manifest.js +1 -0
- package/bundle/.next/server/app/api/workspaces/[workspaceId]/surfaces/discovery/route.js +1 -1
- package/bundle/.next/server/app/api/workspaces/[workspaceId]/surfaces/discovery/route.js.nft.json +1 -1
- package/bundle/.next/server/app/api/workspaces/route.js +2 -2
- package/bundle/.next/server/app/api/workspaces/route.js.nft.json +1 -1
- package/bundle/.next/server/app/page.js +2 -194
- package/bundle/.next/server/app/page.js.nft.json +1 -1
- package/bundle/.next/server/app/page_client-reference-manifest.js +1 -1
- package/bundle/.next/server/app/settings/page.js +2 -0
- package/bundle/.next/server/app/settings/page.js.nft.json +1 -0
- package/bundle/.next/server/app/settings/page_client-reference-manifest.js +1 -0
- package/bundle/.next/server/app-paths-manifest.json +12 -9
- package/bundle/.next/server/chunks/1721.js +186 -0
- package/bundle/.next/server/chunks/1813.js +1 -0
- package/bundle/.next/server/chunks/2908.js +1 -0
- package/bundle/.next/server/chunks/4741.js +18 -0
- package/bundle/.next/server/chunks/63.js +45 -0
- package/bundle/.next/server/chunks/6645.js +11 -0
- package/bundle/.next/server/chunks/6892.js +98 -0
- package/bundle/.next/server/chunks/707.js +1 -0
- package/bundle/.next/server/chunks/737.js +173 -0
- package/bundle/.next/server/chunks/8064.js +2 -0
- package/bundle/.next/server/chunks/8884.js +255 -0
- package/bundle/.next/server/chunks/9281.js +15 -0
- package/bundle/.next/server/functions-config-manifest.json +2 -0
- package/bundle/.next/server/middleware-build-manifest.js +1 -1
- package/bundle/.next/server/middleware-react-loadable-manifest.js +1 -1
- package/bundle/.next/server/pages/404.html +1 -1
- package/bundle/.next/server/pages/500.html +1 -1
- package/bundle/.next/server/server-reference-manifest.json +1 -1
- package/bundle/.next/server/webpack-runtime.js +1 -1
- package/bundle/.next/static/chunks/1287.facd47073fd9ee28.js +1 -0
- package/bundle/.next/static/chunks/1a258343.31cec7fec82d82e7.js +1 -0
- package/bundle/.next/static/chunks/3272.c112ebf2cc12c74d.js +1 -0
- package/bundle/.next/static/chunks/3513-9f504a6f64a919df.js +15 -0
- package/bundle/.next/static/chunks/3794-318642842e814c21.js +32 -0
- package/bundle/.next/static/chunks/4bd1b696-c2f6e0877b6c10aa.js +1 -0
- package/bundle/.next/static/chunks/6609-1948800b7ad9f570.js +1 -0
- package/bundle/.next/static/chunks/9281-33f8488964e956b3.js +186 -0
- package/bundle/.next/static/chunks/app/_global-error/page-b0e9d273dcff17f5.js +1 -0
- package/bundle/.next/static/chunks/app/_not-found/page-b0e9d273dcff17f5.js +1 -0
- package/bundle/.next/static/chunks/app/api/agents/[agentId]/chat/route-b0e9d273dcff17f5.js +1 -0
- package/bundle/.next/static/chunks/app/api/agents/route-b0e9d273dcff17f5.js +1 -0
- package/bundle/.next/static/chunks/app/api/diagnostics/route-b0e9d273dcff17f5.js +1 -0
- package/bundle/.next/static/chunks/app/api/files/reveal/route-b0e9d273dcff17f5.js +1 -0
- package/bundle/.next/static/chunks/app/api/gateway/control/route-b0e9d273dcff17f5.js +1 -0
- package/bundle/.next/static/chunks/app/api/mission/route-b0e9d273dcff17f5.js +1 -0
- package/bundle/.next/static/chunks/app/api/models/catalog/route-b0e9d273dcff17f5.js +1 -0
- package/bundle/.next/static/chunks/app/api/models/providers/route-b0e9d273dcff17f5.js +1 -0
- package/bundle/.next/static/chunks/app/api/onboarding/models/route-b0e9d273dcff17f5.js +1 -0
- package/bundle/.next/static/chunks/app/api/onboarding/route-b0e9d273dcff17f5.js +1 -0
- package/bundle/.next/static/chunks/app/api/openclaw/capabilities/route-b0e9d273dcff17f5.js +1 -0
- package/bundle/.next/static/chunks/app/api/planner/[planId]/deploy/route-b0e9d273dcff17f5.js +1 -0
- package/bundle/.next/static/chunks/app/api/planner/[planId]/document-rewrite/route-b0e9d273dcff17f5.js +1 -0
- package/bundle/.next/static/chunks/app/api/planner/[planId]/route-b0e9d273dcff17f5.js +1 -0
- package/bundle/.next/static/chunks/app/api/planner/[planId]/simulate/route-b0e9d273dcff17f5.js +1 -0
- package/bundle/.next/static/chunks/app/api/planner/[planId]/turn/route-b0e9d273dcff17f5.js +1 -0
- package/bundle/.next/static/chunks/app/api/planner/route-b0e9d273dcff17f5.js +1 -0
- package/bundle/.next/static/chunks/app/api/reset/route-b0e9d273dcff17f5.js +1 -0
- package/bundle/.next/static/chunks/app/api/runtimes/[runtimeId]/route-b0e9d273dcff17f5.js +1 -0
- package/bundle/.next/static/chunks/app/api/settings/gateway/route-b0e9d273dcff17f5.js +1 -0
- package/bundle/.next/static/chunks/app/api/settings/openclaw-binary/route-b0e9d273dcff17f5.js +1 -0
- package/bundle/.next/static/chunks/app/api/settings/workspace-root/route-b0e9d273dcff17f5.js +1 -0
- package/bundle/.next/static/chunks/app/api/snapshot/route-b0e9d273dcff17f5.js +1 -0
- package/bundle/.next/static/chunks/app/api/stream/route-b0e9d273dcff17f5.js +1 -0
- package/bundle/.next/static/chunks/app/api/system/open-terminal/route-b0e9d273dcff17f5.js +1 -0
- package/bundle/.next/static/chunks/app/api/tasks/[taskId]/abort/route-b0e9d273dcff17f5.js +1 -0
- package/bundle/.next/static/chunks/app/api/tasks/[taskId]/stream/route-b0e9d273dcff17f5.js +1 -0
- package/bundle/.next/static/chunks/app/api/update/route-b0e9d273dcff17f5.js +1 -0
- package/bundle/.next/static/chunks/app/api/workspaces/[workspaceId]/channels/discovered-groups/route-b0e9d273dcff17f5.js +1 -0
- package/bundle/.next/static/chunks/app/api/workspaces/[workspaceId]/channels/route-b0e9d273dcff17f5.js +1 -0
- package/bundle/.next/static/chunks/app/api/workspaces/[workspaceId]/edit-draft/route-b0e9d273dcff17f5.js +1 -0
- package/bundle/.next/static/chunks/app/api/workspaces/[workspaceId]/files/route-b0e9d273dcff17f5.js +1 -0
- package/bundle/.next/static/chunks/app/api/workspaces/[workspaceId]/surfaces/discovery/route-b0e9d273dcff17f5.js +1 -0
- package/bundle/.next/static/chunks/app/api/workspaces/route-b0e9d273dcff17f5.js +1 -0
- package/bundle/.next/static/chunks/app/layout-7e58cd41078411bc.js +1 -0
- package/bundle/.next/static/chunks/app/not-found-b0e9d273dcff17f5.js +1 -0
- package/bundle/.next/static/chunks/app/page-f7cd75289fd01742.js +1 -0
- package/bundle/.next/static/chunks/app/settings/page-8b8870f1f797eded.js +1 -0
- package/bundle/.next/static/chunks/ede5dfc2-bfa57fc44787fda0.js +1 -0
- package/bundle/.next/static/chunks/framework-d1de002210ddaaef.js +1 -0
- package/bundle/.next/static/chunks/main-app-e5953317e55d16ab.js +1 -0
- package/bundle/.next/static/chunks/main-cdd9e49cf451f30f.js +5 -0
- package/bundle/.next/static/chunks/next/dist/client/components/builtin/app-error-b0e9d273dcff17f5.js +1 -0
- package/bundle/.next/static/chunks/next/dist/client/components/builtin/forbidden-b0e9d273dcff17f5.js +1 -0
- package/bundle/.next/static/chunks/next/dist/client/components/builtin/global-error-bd2008378c5c1f7c.js +1 -0
- package/bundle/.next/static/chunks/next/dist/client/components/builtin/unauthorized-b0e9d273dcff17f5.js +1 -0
- package/bundle/.next/static/chunks/{webpack-e0accbaa78fb0b56.js → webpack-18bf7c24ea50f9e6.js} +1 -1
- package/bundle/.next/static/css/e7b71a4de4ff8d92.css +3 -0
- package/bundle/.next/static/mwHPYd8h5FgBicMwCH---/_buildManifest.js +1 -0
- package/bundle/package.json +4 -0
- package/bundle/public/assets/openclaw.png +0 -0
- package/bundle/public/assets/screenshots/0.jpeg +0 -0
- package/bundle/public/assets/screenshots/1.jpeg +0 -0
- package/bundle/public/assets/screenshots/2.jpeg +0 -0
- package/bundle/public/assets/screenshots/3.jpeg +0 -0
- package/bundle/public/assets/screenshots/4_1.jpeg +0 -0
- package/bundle/public/assets/screenshots/5.jpeg +0 -0
- package/bundle/public/assets/screenshots/6.jpeg +0 -0
- package/bundle/public/assets/screenshots/7.jpeg +0 -0
- package/bundle/public/readme/readme.jpeg +0 -0
- package/package.json +2 -1
- package/bundle/.next/server/chunks/199.js +0 -412
- package/bundle/.next/server/chunks/35.js +0 -45
- package/bundle/.next/server/chunks/408.js +0 -18
- package/bundle/.next/server/chunks/639.js +0 -98
- package/bundle/.next/server/chunks/661.js +0 -1
- package/bundle/.next/server/chunks/678.js +0 -1
- package/bundle/.next/server/chunks/825.js +0 -1
- package/bundle/.next/static/9OX9mutnH1gpbuj6hICVB/_buildManifest.js +0 -1
- package/bundle/.next/static/chunks/2999.fef298fbe30cd4bd.js +0 -1
- package/bundle/.next/static/chunks/4424-08671f25c8f9ae84.js +0 -32
- package/bundle/.next/static/chunks/4a846800.17bbc9efb621dbb7.js +0 -1
- package/bundle/.next/static/chunks/5261.29ae1e1fe185a617.js +0 -1
- package/bundle/.next/static/chunks/7963-6bd42810c5733ae8.js +0 -15
- package/bundle/.next/static/chunks/8583-0efb0aa0937b762c.js +0 -1
- package/bundle/.next/static/chunks/app/_global-error/page-cde9c645dcfceb9f.js +0 -1
- package/bundle/.next/static/chunks/app/_not-found/page-cde9c645dcfceb9f.js +0 -1
- package/bundle/.next/static/chunks/app/api/agents/[agentId]/chat/route-cde9c645dcfceb9f.js +0 -1
- package/bundle/.next/static/chunks/app/api/agents/route-cde9c645dcfceb9f.js +0 -1
- package/bundle/.next/static/chunks/app/api/diagnostics/route-cde9c645dcfceb9f.js +0 -1
- package/bundle/.next/static/chunks/app/api/files/reveal/route-cde9c645dcfceb9f.js +0 -1
- package/bundle/.next/static/chunks/app/api/gateway/control/route-cde9c645dcfceb9f.js +0 -1
- package/bundle/.next/static/chunks/app/api/mission/route-cde9c645dcfceb9f.js +0 -1
- package/bundle/.next/static/chunks/app/api/models/catalog/route-cde9c645dcfceb9f.js +0 -1
- package/bundle/.next/static/chunks/app/api/models/providers/route-cde9c645dcfceb9f.js +0 -1
- package/bundle/.next/static/chunks/app/api/onboarding/models/route-cde9c645dcfceb9f.js +0 -1
- package/bundle/.next/static/chunks/app/api/onboarding/route-cde9c645dcfceb9f.js +0 -1
- package/bundle/.next/static/chunks/app/api/openclaw/capabilities/route-cde9c645dcfceb9f.js +0 -1
- package/bundle/.next/static/chunks/app/api/planner/[planId]/deploy/route-cde9c645dcfceb9f.js +0 -1
- package/bundle/.next/static/chunks/app/api/planner/[planId]/document-rewrite/route-cde9c645dcfceb9f.js +0 -1
- package/bundle/.next/static/chunks/app/api/planner/[planId]/route-cde9c645dcfceb9f.js +0 -1
- package/bundle/.next/static/chunks/app/api/planner/[planId]/simulate/route-cde9c645dcfceb9f.js +0 -1
- package/bundle/.next/static/chunks/app/api/planner/[planId]/turn/route-cde9c645dcfceb9f.js +0 -1
- package/bundle/.next/static/chunks/app/api/planner/route-cde9c645dcfceb9f.js +0 -1
- package/bundle/.next/static/chunks/app/api/reset/route-cde9c645dcfceb9f.js +0 -1
- package/bundle/.next/static/chunks/app/api/runtimes/[runtimeId]/route-cde9c645dcfceb9f.js +0 -1
- package/bundle/.next/static/chunks/app/api/settings/gateway/route-cde9c645dcfceb9f.js +0 -1
- package/bundle/.next/static/chunks/app/api/settings/workspace-root/route-cde9c645dcfceb9f.js +0 -1
- package/bundle/.next/static/chunks/app/api/snapshot/route-cde9c645dcfceb9f.js +0 -1
- package/bundle/.next/static/chunks/app/api/stream/route-cde9c645dcfceb9f.js +0 -1
- package/bundle/.next/static/chunks/app/api/system/open-terminal/route-cde9c645dcfceb9f.js +0 -1
- package/bundle/.next/static/chunks/app/api/tasks/[taskId]/abort/route-cde9c645dcfceb9f.js +0 -1
- package/bundle/.next/static/chunks/app/api/tasks/[taskId]/stream/route-cde9c645dcfceb9f.js +0 -1
- package/bundle/.next/static/chunks/app/api/update/route-cde9c645dcfceb9f.js +0 -1
- package/bundle/.next/static/chunks/app/api/workspaces/[workspaceId]/channels/discovered-groups/route-cde9c645dcfceb9f.js +0 -1
- package/bundle/.next/static/chunks/app/api/workspaces/[workspaceId]/channels/route-cde9c645dcfceb9f.js +0 -1
- package/bundle/.next/static/chunks/app/api/workspaces/[workspaceId]/edit-draft/route-cde9c645dcfceb9f.js +0 -1
- package/bundle/.next/static/chunks/app/api/workspaces/[workspaceId]/surfaces/discovery/route-cde9c645dcfceb9f.js +0 -1
- package/bundle/.next/static/chunks/app/api/workspaces/route-cde9c645dcfceb9f.js +0 -1
- package/bundle/.next/static/chunks/app/layout-7c2d7e515f68248b.js +0 -1
- package/bundle/.next/static/chunks/app/not-found-cde9c645dcfceb9f.js +0 -1
- package/bundle/.next/static/chunks/app/page-7bc93c9b4ee30f58.js +0 -179
- package/bundle/.next/static/chunks/d08e407b-a7a2691dd8d9de6b.js +0 -1
- package/bundle/.next/static/chunks/f6503f1c-7df4e7c4564148dc.js +0 -1
- package/bundle/.next/static/chunks/framework-c8a5f18418cd0e86.js +0 -1
- package/bundle/.next/static/chunks/main-app-9a4481b0ab7b57f6.js +0 -1
- package/bundle/.next/static/chunks/main-eb49e7f5b314b5dc.js +0 -5
- package/bundle/.next/static/chunks/next/dist/client/components/builtin/app-error-cde9c645dcfceb9f.js +0 -1
- package/bundle/.next/static/chunks/next/dist/client/components/builtin/forbidden-cde9c645dcfceb9f.js +0 -1
- package/bundle/.next/static/chunks/next/dist/client/components/builtin/global-error-38aa72b47d0b8f99.js +0 -1
- package/bundle/.next/static/chunks/next/dist/client/components/builtin/unauthorized-cde9c645dcfceb9f.js +0 -1
- package/bundle/.next/static/css/9f1b31fd4086df59.css +0 -3
- /package/bundle/.next/static/{9OX9mutnH1gpbuj6hICVB → mwHPYd8h5FgBicMwCH---}/_ssgManifest.js +0 -0
- /package/bundle/node_modules/{postcss → next/node_modules/postcss}/lib/at-rule.js +0 -0
- /package/bundle/node_modules/{postcss → next/node_modules/postcss}/lib/comment.js +0 -0
- /package/bundle/node_modules/{postcss → next/node_modules/postcss}/lib/container.js +0 -0
- /package/bundle/node_modules/{postcss → next/node_modules/postcss}/lib/css-syntax-error.js +0 -0
- /package/bundle/node_modules/{postcss → next/node_modules/postcss}/lib/declaration.js +0 -0
- /package/bundle/node_modules/{postcss → next/node_modules/postcss}/lib/document.js +0 -0
- /package/bundle/node_modules/{postcss → next/node_modules/postcss}/lib/fromJSON.js +0 -0
- /package/bundle/node_modules/{postcss → next/node_modules/postcss}/lib/input.js +0 -0
- /package/bundle/node_modules/{postcss → next/node_modules/postcss}/lib/lazy-result.js +0 -0
- /package/bundle/node_modules/{postcss → next/node_modules/postcss}/lib/list.js +0 -0
- /package/bundle/node_modules/{postcss → next/node_modules/postcss}/lib/map-generator.js +0 -0
- /package/bundle/node_modules/{postcss → next/node_modules/postcss}/lib/no-work-result.js +0 -0
- /package/bundle/node_modules/{postcss → next/node_modules/postcss}/lib/node.js +0 -0
- /package/bundle/node_modules/{postcss → next/node_modules/postcss}/lib/parse.js +0 -0
- /package/bundle/node_modules/{postcss → next/node_modules/postcss}/lib/parser.js +0 -0
- /package/bundle/node_modules/{postcss → next/node_modules/postcss}/lib/postcss.js +0 -0
- /package/bundle/node_modules/{postcss → next/node_modules/postcss}/lib/previous-map.js +0 -0
- /package/bundle/node_modules/{postcss → next/node_modules/postcss}/lib/processor.js +0 -0
- /package/bundle/node_modules/{postcss → next/node_modules/postcss}/lib/result.js +0 -0
- /package/bundle/node_modules/{postcss → next/node_modules/postcss}/lib/root.js +0 -0
- /package/bundle/node_modules/{postcss → next/node_modules/postcss}/lib/rule.js +0 -0
- /package/bundle/node_modules/{postcss → next/node_modules/postcss}/lib/stringifier.js +0 -0
- /package/bundle/node_modules/{postcss → next/node_modules/postcss}/lib/stringify.js +0 -0
- /package/bundle/node_modules/{postcss → next/node_modules/postcss}/lib/symbols.js +0 -0
- /package/bundle/node_modules/{postcss → next/node_modules/postcss}/lib/terminal-highlight.js +0 -0
- /package/bundle/node_modules/{postcss → next/node_modules/postcss}/lib/tokenize.js +0 -0
- /package/bundle/node_modules/{postcss → next/node_modules/postcss}/lib/warn-once.js +0 -0
- /package/bundle/node_modules/{postcss → next/node_modules/postcss}/lib/warning.js +0 -0
- /package/bundle/node_modules/{postcss → next/node_modules/postcss}/package.json +0 -0
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
"use strict";exports.id=8884,exports.ids=[8884],exports.modules={6347:(a,b,c)=>{c.d(b,{Z:()=>o});var d=c(94457),e=c(57824),f=c(50550);function g(a){return Array.from(new Set(a.filter(Boolean)))}function h(a){let b=new Map;for(let c of a)c.chatId&&b.set(c.chatId,c);return Array.from(b.values())}function i(a){return a.title&&a.title!==a.chatId?`${a.title} (\`${a.chatId}\`)`:`\`${a.chatId}\``}function j(a){if(!a)return"no capability snapshot";let b=[(0,f._P)(a.policy.preset)],c=a.profile.purpose?.trim();c&&b.push(c);let d=g(a.skills).slice(0,2);d.length>0&&b.push(`skills: ${d.join(", ")}`);let e=g(a.tools).slice(0,2);return e.length>0&&b.push(`tools: ${e.join(", ")}`),b.join(" \xb7 ")}function k(a){return Array.from(new Set(a.filter(Boolean)))}function l(a){let b=new Map;for(let c of a)c.chatId&&b.set(c.chatId,c);return Array.from(b.values())}function m(a,b,c){let e=new Map(a?.agents.map(a=>[a.id,(0,d.CK)(a)])??[]),f=new Map(a?.agents.map(a=>[a.id,a])??[]);return k(b.filter(a=>!c.includes(a))).map(a=>{let b=f.get(a)??null;return{agentId:a,name:e.get(a)??a,summary:function(a){if(!a)return"no capability snapshot";let b=[(0,d.CK)(a)],c=a.profile.purpose?.trim();c&&b.push(c);let e=k(a.skills).slice(0,2);e.length>0&&b.push(`skills: ${e.join(", ")}`);let f=k(a.tools).slice(0,2);return f.length>0&&b.push(`tools: ${f.join(", ")}`),b.join(" \xb7 ")}(b)}})}function n(a){let b=(0,e.S)(a.chatId),c=b?.kind==="role"?`@${b.targetId}`:b?.kind==="thread"?`Thread ${b.targetId}`:b?.kind==="channel"?`#${b.targetId}`:a.chatId;return{routeId:a.chatId,label:a.title?.trim()||c,kind:b?.kind??"channel",guildId:b?.guildId??null}}function o(a,b,c=b?.channelRegistry??null){let e=[function(a){if(!a||0===a.primaryChannels.length&&0===a.ownedGroups.length&&0===a.delegateChannels.length)return null;let b=["## Telegram coordination"];if(b.push("- Telegram credentials are managed by OpenClaw for the listed channels. Do not ask the operator for `TELEGRAM_BOT_TOKEN` or `channels.telegram.botToken` when sending to listed groups."),b.push('- To send or post, call the `message` tool with `action: "send"`, `channel: "telegram"`, `target: "<chatId>"`, and the exact message text. Use the listed chat id as `target`.'),b.push("- If sending fails, report the actual tool error instead of inventing a missing-token error."),a.primaryChannels.length>0){for(let c of(b.push("- You are the public Telegram fallback for these channels:"),a.primaryChannels)){let a=c.groups.length>0?c.groups.map(i).join(", "):"no allowed groups yet";if(b.push(` - ${c.channelName} (\`${c.channelId}\`) \xb7 fallback groups: ${a}.`),c.peers.length>0)for(let a of(b.push(" - Internal assistants:"),c.peers))b.push(` - ${a.name} (\`${a.agentId}\`) \xb7 ${a.summary}.`)}b.push("- Keep public Telegram replies under your own voice for unassigned groups, even when you ask another agent for help."),b.push("- For specialist help, call another agent from the workspace terminal with:"),b.push("```bash"),b.push('node .openclaw/tools/telegram-delegate-agent.mjs --agent <delegate-agent-id> --message "Summarize what I need from you"'),b.push("```"),b.push("- Use delegate turns for internal research, drafting, or analysis only. Do not ask them to answer Telegram directly."),b.push("- After a delegate responds, decide what to share publicly and send the final Telegram reply yourself.")}if(a.ownedGroups.length>0){for(let c of(b.push("- You are the public Telegram voice for these assigned groups:"),a.ownedGroups))if(b.push(` - ${c.channelName} (\`${c.channelId}\`) \xb7 ${c.title??c.chatId} (\`${c.chatId}\`) \xb7 primary ${c.primaryAgentName} (\`${c.primaryAgentId}\`).`),c.peers.length>0)for(let a of(b.push(" - Internal assistants for this group:"),c.peers))b.push(` - ${a.name} (\`${a.agentId}\`) \xb7 ${a.summary}.`);b.push("- Reply directly to those groups as the public voice. Use other agents only for internal help.")}if(a.delegateChannels.length>0){for(let c of(b.push("- You can assist these Telegram admin channels when the primary agent asks:"),a.delegateChannels)){let a=c.groups.length>0?c.groups.map(i).join(", "):"no allowed groups yet";if(b.push(` - ${c.channelName} (\`${c.channelId}\`) \xb7 primary ${c.primaryAgentName} (\`${c.primaryAgentId}\`) \xb7 groups: ${a}.`),c.peers.length>0)for(let a of(b.push(" - Nearby assistants:"),c.peers))b.push(` - ${a.name} (\`${a.agentId}\`) \xb7 ${a.summary}.`)}b.push("- When helping with Telegram work for groups not assigned to you, return concise internal findings or draft language. Do not speak as the public Telegram agent for those unassigned groups.")}return b.join("\n")}(function(a,b,c=b?.channelRegistry??null){if(!c)return null;let e=new Map(b?.agents.map(a=>[a.id,(0,d.CK)(a)])??[]),f=new Map(b?.agents.map(a=>[a.id,a])??[]),i=f.get(a)??null,k=i?.workspaceId??null,l=[],m=[],n=[];for(let b of c.channels.filter(a=>"telegram"===a.type)){let c=b.workspaces.filter(a=>a.workspaceId===k);if(0===c.length)continue;let i=h(c.flatMap(a=>a.groupAssignments.filter(a=>!1!==a.enabled))).map(a=>({chatId:a.chatId,title:a.title??null})),o=h(c.flatMap(b=>b.groupAssignments.filter(b=>!1!==b.enabled&&b.agentId===a))),p=i.filter(a=>!o.some(b=>b.chatId===a.chatId)&&!c.some(b=>b.groupAssignments.some(b=>!1!==b.enabled&&b.chatId===a.chatId&&b.agentId)));if(b.primaryAgentId===a){let d=g(c.flatMap(b=>b.agentIds.filter(b=>b!==a))).map(a=>{let b=f.get(a)??null;return{agentId:a,name:e.get(a)??a,summary:j(b)}});l.push({channelId:b.id,channelName:b.name,groups:p,peers:d})}for(let d of o){let h=g(c.flatMap(c=>c.agentIds.filter(c=>c!==a&&c!==b.primaryAgentId))).map(a=>{let b=f.get(a)??null;return{agentId:a,name:e.get(a)??a,summary:j(b)}});m.push({channelId:b.id,channelName:b.name,chatId:d.chatId,title:d.title??null,primaryAgentId:b.primaryAgentId??a,primaryAgentName:e.get(b.primaryAgentId??a)??b.primaryAgentId??a,peers:h})}if(b.primaryAgentId&&b.primaryAgentId!==a&&0===o.length){let h=f.get(b.primaryAgentId)??null,i=g(c.flatMap(c=>c.agentIds.filter(c=>c!==b.primaryAgentId&&c!==a))).map(a=>{let b=f.get(a)??null;return{agentId:a,name:e.get(a)??a,summary:j(b)}});n.push({channelId:b.id,channelName:b.name,groups:p,peers:i,primaryAgentId:b.primaryAgentId,primaryAgentName:e.get(b.primaryAgentId)??(h?(0,d.CK)(h):b.primaryAgentId)})}}return{primaryChannels:l.sort((a,b)=>a.channelName.localeCompare(b.channelName)),ownedGroups:m.sort((a,b)=>{let c=`${a.channelName}:${a.title??a.chatId}`,d=`${b.channelName}:${b.title??b.chatId}`;return c.localeCompare(d)}),delegateChannels:n.sort((a,b)=>a.channelName.localeCompare(b.channelName))}}(a,b,c)),function(a){if(!a||0===a.primaryChannels.length&&0===a.ownedRoutes.length&&0===a.delegateChannels.length)return null;let b=["## Discord coordination"];if(a.primaryChannels.length>0){for(let c of(b.push("- You are the public Discord fallback for these channels:"),a.primaryChannels)){let a=c.routes.length>0?c.routes.map(a=>`${a.label} (\`${a.routeId}\`)`).join(", "):"no allowed routes yet";if(b.push(` - ${c.channelName} (\`${c.channelId}\`) \xb7 fallback routes: ${a}.`),c.peers.length>0)for(let a of(b.push(" - Internal assistants:"),c.peers))b.push(` - ${a.name} (\`${a.agentId}\`) \xb7 ${a.summary}.`)}b.push("- Keep public Discord replies under your own voice for unassigned routes, even when you ask another agent for help.")}if(a.ownedRoutes.length>0){for(let c of(b.push("- You are the public Discord voice for these assigned routes:"),a.ownedRoutes))if(b.push(` - ${c.channelName} (\`${c.channelId}\`) \xb7 ${c.label} (\`${c.routeId}\`) \xb7 primary ${c.primaryAgentName} (\`${c.primaryAgentId}\`).`),c.peers.length>0)for(let a of(b.push(" - Internal assistants for this route:"),c.peers))b.push(` - ${a.name} (\`${a.agentId}\`) \xb7 ${a.summary}.`);b.push("- Reply directly to those routes as the public voice. Use other agents only for internal help.")}if(a.delegateChannels.length>0){for(let c of(b.push("- You can assist these Discord admin channels when the primary agent asks:"),a.delegateChannels)){let a=c.routes.length>0?c.routes.map(a=>`${a.label} (\`${a.routeId}\`)`).join(", "):"no allowed routes yet";if(b.push(` - ${c.channelName} (\`${c.channelId}\`) \xb7 primary ${c.primaryAgentName} (\`${c.primaryAgentId}\`) \xb7 routes: ${a}.`),c.peers.length>0)for(let a of(b.push(" - Nearby assistants:"),c.peers))b.push(` - ${a.name} (\`${a.agentId}\`) \xb7 ${a.summary}.`)}b.push("- When helping with Discord work, return concise internal findings or draft language. Do not speak as the public Discord agent.")}return b.join("\n")}(function(a,b,c=b?.channelRegistry??null){if(!c)return null;let e=b?.agents.find(b=>b.id===a)??null,f=e?.workspaceId??null,g=[],h=[],i=[];for(let e of c.channels.filter(a=>"discord"===a.type)){var j,k,o,p;let c=e.workspaces.filter(a=>a.workspaceId===f);if(0===c.length)continue;let q=l(c.flatMap(a=>a.groupAssignments.filter(a=>!1!==a.enabled))).map(n),r=l(c.flatMap(b=>b.groupAssignments.filter(b=>!1!==b.enabled&&b.agentId===a))).map(n),s=q.filter(a=>!r.some(b=>b.routeId===a.routeId)&&!c.some(b=>b.groupAssignments.some(b=>!1!==b.enabled&&b.chatId===a.routeId&&b.agentId)));if(e.primaryAgentId===a){let d=m(b,c.flatMap(b=>b.agentIds.filter(b=>b!==a)),[a]);g.push({channelId:e.id,channelName:e.name,routes:s,peers:d})}for(let f of r){let g=m(b,c.flatMap(b=>b.agentIds.filter(b=>b!==a&&b!==e.primaryAgentId)),[a,e.primaryAgentId??""]);h.push({channelId:e.id,channelName:e.name,routeId:f.routeId,label:f.label,kind:f.kind,guildId:f.guildId,primaryAgentId:e.primaryAgentId??a,primaryAgentName:(j=b?.agents.find(b=>b.id===(e.primaryAgentId??a))??null,k=e.primaryAgentId??a,j?(0,d.CK)(j):k),peers:g})}if(e.primaryAgentId&&e.primaryAgentId!==a){let f=m(b,c.flatMap(b=>b.agentIds.filter(b=>b!==e.primaryAgentId&&b!==a)),[a,e.primaryAgentId]);i.push({channelId:e.id,channelName:e.name,routes:s,peers:f,primaryAgentId:e.primaryAgentId,primaryAgentName:(o=b?.agents.find(a=>a.id===e.primaryAgentId)??null,p=e.primaryAgentId,o?(0,d.CK)(o):p)})}}return{primaryChannels:g.sort((a,b)=>a.channelName.localeCompare(b.channelName)),ownedRoutes:h.sort((a,b)=>{let c=`${a.channelName}:${a.label}`,d=`${b.channelName}:${b.label}`;return c.localeCompare(d)}),delegateChannels:i.sort((a,b)=>a.channelName.localeCompare(b.channelName))}}(a,b,c))].filter(a=>!!a);return e.length>0?e.join("\n\n"):null}},39463:(a,b,c)=>{function d(a){let b="clone"===a.sourceMode?{label:"Cloning repository",description:"The repository is being cloned before workspace files are added."}:"existing"===a.sourceMode?{label:"Attaching existing folder",description:"AgentOS is validating the existing directory and preparing it for bootstrap."}:{label:"Preparing workspace folder",description:"A fresh workspace directory is being created inside the configured workspace root."};return{title:"Provisioning workspace",description:"AgentOS is creating the workspace and reporting each real bootstrap step as it finishes.",steps:[{id:"validate",label:"Checking input and target path",description:"Workspace input, agent ids, and the destination directory are being validated."},{id:"source",label:b.label,description:b.description},{id:"scaffold",label:"Scaffolding workspace files",description:"Core docs, local state, starter memory, and shared workspace metadata are being written."},{id:"agents",label:1===a.agentCount?"Creating the first agent":"Creating workspace agents",description:1===a.agentCount?"The primary agent is being provisioned and linked to the workspace.":"Each enabled agent is being provisioned and linked to the workspace."},{id:"kickoff",label:a.kickoffMission?"Running kickoff mission":"Finalizing workspace",description:a.kickoffMission?"The primary agent is inspecting the new workspace and refining the initial setup.":"Workspace bootstrap is wrapping up without a kickoff mission."}]}}function e(a){return{title:"Deploying workspace",description:"The planner is turning the blueprint into a live workspace and streaming each deploy stage.",steps:[{id:"plan",label:"Locking deploy plan",description:"Deploy blockers are being checked and the planner state is being locked for launch."},...d({sourceMode:a.sourceMode,agentCount:a.agentCount,kickoffMission:a.kickoffMission}).steps,{id:"blueprint",label:"Writing planner files",description:"Planner blueprint, company notes, and workflow docs are being written into the workspace."},{id:"channels",label:a.hasChannels?"Provisioning channels":"Checking channels",description:a.hasChannels?"Enabled external channels are being provisioned and connected.":"No external channels are enabled, so this stage will pass quickly."},{id:"automations",label:a.hasAutomations?"Provisioning automations":"Checking automation loops",description:a.hasAutomations?"Enabled recurring loops are being attached to their target agents.":"No recurring automations are enabled, so this stage is mostly validation."},{id:"planner-kickoff",label:a.hasPlannerKickoffs?"Running planner kickoff missions":"Finalizing deploy",description:a.hasPlannerKickoffs?"The first missions are being dispatched so the new workspace starts with clear momentum.":"The workspace is being finalized and the deploy request is wrapping up."}]}}function f({template:a,onProgress:b}){let c={title:a.title,description:a.description,percent:0,steps:a.steps.map(a=>({...a,status:"pending",percent:0,activities:[]}))},d=0,e=a=>{let b=c.steps.find(b=>b.id===a);if(!b)throw Error(`Unknown operation progress step: ${a}`);return b},i=async()=>{c.percent=g(c.steps),await b?.(structuredClone(c))},j=(a,b)=>{let c=e(a);"string"==typeof b.label&&(c.label=b.label),"string"==typeof b.description&&(c.description=b.description),"string"==typeof b.detail&&(c.detail=b.detail),"number"==typeof b.percent&&(c.percent=h(b.percent)),b.status&&(c.status=b.status)};return{snapshot:()=>(c.percent=g(c.steps),structuredClone(c)),async startStep(a,b){j(a,{status:"active",percent:Math.max(e(a).percent,2),detail:b}),await i()},async updateStep(a,b){j(a,b),await i()},async addActivity(a,b,c="active"){let f=e(a),g={id:`${a}-${d}`,message:b,status:c};d+=1,f.activities.push(g),"pending"===f.status&&"active"===c&&(f.status="active"),await i()},async completeStep(a,b){j(a,{status:"done",percent:100,detail:b}),await i()},async failStep(a,b){j(a,{status:"error",percent:100,detail:b}),await i()},async syncStep(a){let b=e(a.id);b.label=a.label,b.description=a.description,b.status=a.status,b.percent=h(a.percent),b.detail=a.detail,b.activities=structuredClone(a.activities),await i()}}}function g(a){return 0===a.length?0:Math.round(a.reduce((a,b)=>a+h(b.percent),0)/a.length)}function h(a){return Number.isFinite(a)?Math.min(100,Math.max(0,Math.round(a))):0}c.d(b,{Bb:()=>e,X6:()=>f,fV:()=>d})},39754:(a,b,c)=>{function d(a){return a.diagnostics.installed&&a.diagnostics.rpcOk}function e(a){var b;return a.diagnostics.installed&&a.diagnostics.rpcOk&&(b=a).diagnostics.runtime.stateWritable&&b.diagnostics.runtime.sessionStoreWritable}function f(a){var b;return e(a)&&d(b=a)&&b.diagnostics.modelReadiness.ready&&"passed"===a.diagnostics.runtime.smokeTest.status}function g(a){return e(a)?a.diagnostics.modelReadiness.ready?null:"OpenClaw model setup is incomplete. Configure a usable default model before dispatching missions.":"OpenClaw system setup is incomplete. Verify the CLI, gateway, and runtime state before dispatching missions."}c.d(b,{Bt:()=>f,h6:()=>d,iN:()=>e,l9:()=>g})},96015:(a,b,c)=>{c.d(b,{o:()=>l});var d=c(51455),e=c(48161),f=c.n(e),g=c(76760),h=c.n(g),i=c(92925),j=c(6828);let k=new Map;async function l({agentId:a,modelId:b,agentDir:c}){let d;if(!a.trim()||!b||!(0,j.JC)(b))return{repaired:!1,reason:"not-codex-model"};try{d=await (0,i.rw)().getAgentModelStatus({agentId:a},{timeoutMs:8e3})}catch(b){let a=c?await o(c).catch(()=>[]):[];return{repaired:a.length>0,reason:a.length>0?"profile-copy-fallback":"status-failed",profileIds:a,error:b}}let e=function(a){let b=a.auth?.oauth?.providers?.find(a=>"openai-codex"===a.provider),c=(Array.isArray(b?.profiles)?b.profiles:[]).filter(s).map(a=>t(a.profileId)).filter(u);if(0===c.length)return{needsRepair:!1,profileIds:[],reason:"no-usable-profile"};let d=(Array.isArray(b?.effectiveProfiles)?b.effectiveProfiles:[]).find(v),e=d?t(d.profileId):null;return"ok"===t(b?.status)?.toLowerCase()&&e&&c.includes(e)?{needsRepair:!1,profileIds:c,reason:"not-needed"}:{needsRepair:!0,profileIds:c,reason:"needs-order"}}(d);if(!e.needsRepair)return{repaired:!1,reason:e.reason};let f=e.profileIds.join("\n"),g=`${a}:${f}`,h=k.get(g);if(h&&h.expiresAt>Date.now())return{repaired:!1,reason:"recently-repaired"};let p=t(d.agentDir)??c??null;p&&await n(p,e.profileIds).catch(()=>void 0);try{return"main"!==a&&await m("main",e.profileIds).catch(()=>void 0),await m(a,e.profileIds),k.set(g,{expiresAt:Date.now()+3e5,profileKey:f}),{repaired:!0,reason:"order-set",profileIds:e.profileIds}}catch(a){return{repaired:!1,reason:"repair-failed",error:a}}}async function m(a,b){let c=null;for(let d of[0,750,1500]){d>0&&await function(a){return new Promise(b=>globalThis.setTimeout(b,a))}(d);try{await (0,i.rw)().setModelAuthOrder({provider:"openai-codex",agentId:a,profileIds:b},{timeoutMs:8e3});return}catch(a){c=a}}throw c}async function n(a,b){let c=await q(p()),e=h().join(a,"auth-profiles.json"),f=await q(e),g=!1;for(let a of(f.version=1,f.profiles=f.profiles??{},b)){let b=c.profiles?.[a];r(b)&&JSON.stringify(f.profiles[a])!==JSON.stringify(b)&&(f.profiles[a]=b,g=!0)}g&&(await (0,d.mkdir)(h().dirname(e),{recursive:!0}),await (0,d.writeFile)(e,`${JSON.stringify(f,null,2)}
|
|
2
|
+
`,"utf8"))}async function o(a){let b=Object.entries((await q(p())).profiles??{}).filter(([,a])=>r(a)).map(([a])=>a);return 0===b.length?[]:(await n(a,b),b)}function p(){return h().join(f().homedir(),".openclaw","agents","main","agent","auth-profiles.json")}async function q(a){try{let b=await (0,d.readFile)(a,"utf8"),c=JSON.parse(b);if(v(c))return{version:"number"==typeof c.version?c.version:1,profiles:v(c.profiles)?Object.fromEntries(Object.entries(c.profiles).filter(a=>v(a[1]))):{}}}catch{}return{version:1,profiles:{}}}function r(a){return v(a)&&"oauth"===a.type&&"openai-codex"===a.provider&&v(a.oauthRef)}function s(a){if(!v(a)||!t(a.profileId))return!1;let b=t(a.status)?.toLowerCase();return!b||!["expired","missing","invalid","error","disabled","revoked"].includes(b)}function t(a){return"string"==typeof a&&a.trim()?a.trim():null}function u(a){return!!a}function v(a){return!!a&&"object"==typeof a&&!Array.isArray(a)}},98884:(a,b,c)=>{c.d(b,{yw:()=>bG,DM:()=>ck,er:()=>d.er,Sn:()=>ah,MP:()=>cn,zw:()=>bg,RB:()=>aj,kd:()=>ch,qu:()=>bi,B5:()=>cg,H6:()=>cc.H6,lC:()=>cc.lC,dM:()=>ba,MQ:()=>bV,W6:()=>bT,GM:()=>cV,Y9:()=>bb,pf:()=>bc,FJ:()=>bj,f5:()=>bX,MG:()=>bU,W9:()=>cj,lT:()=>ci,xE:()=>bF,ct:()=>a9,o6:()=>cl,x4:()=>ai,Vg:()=>bR,sQ:()=>bh,PR:()=>bS,Oz:()=>cf});var d=c(30737),e=c(51455),f=c(76760),g=c.n(f),h=c(50550);function i(a,b){let c="monitoring"===a?{enabled:!0,every:"30m"}:{enabled:!1,every:"30m"},d="string"==typeof b?.every&&b.every.trim()&&"disabled"!==b.every?b.every.trim():c.every;return"boolean"==typeof b?.enabled?{enabled:b.enabled,every:d}:b?.every==="disabled"?{enabled:!1,every:d}:c}function j(a){return a?.enabled?{every:"string"==typeof a.every&&a.every.trim()?a.every.trim():"30m"}:null}var k=c(92925),l=c(594),m=c(94457),n=c(90002),o=c(31421),p=c(57975),q=c(11139),r=c(8406),s=c(8826);let t=(0,p.promisify)(o.execFile);function u(a){return"string"==typeof a&&a.trim().length>0?a.trim():null}function v(a){return Array.from(new Set(a.filter(Boolean)))}function w(a){return v([...(a.skillIds??[]).map(a=>u(a)??""),u(a.skillId)??""])}function x(a){return a.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}async function y(a){try{return await (0,e.access)(a),!0}catch{return!1}}async function z(a,b,c={}){try{await t(a,b,{cwd:c.cwd??process.cwd(),timeout:c.timeoutMs??12e4,maxBuffer:8388608})}catch(a){throw Error("object"==typeof a&&a&&"stderr"in a&&"string"==typeof a.stderr&&a.stderr.trim()?a.stderr.trim():a instanceof Error?a.message:"Unknown system command failure.")}}async function A(a,b){try{await (0,e.access)(a)}catch{await (0,e.mkdir)(g().dirname(a),{recursive:!0}),await (0,e.writeFile)(a,b,"utf8")}}async function B(a,b){await (0,e.mkdir)(g().dirname(a),{recursive:!0}),await (0,e.writeFile)(a,b,"utf8")}async function C(a){try{throw await (0,e.access)(a),Error("Target workspace directory already exists.")}catch(a){if("ENOENT"===("object"==typeof a&&a&&"code"in a?a.code:void 0))return;if(a instanceof Error)throw a;throw Error("Unable to verify target workspace directory.")}}async function D(a){try{if(!(await (0,e.stat)(a)).isDirectory())throw Error("Target workspace path exists and is not a directory.");if((await (0,e.readdir)(a)).length>0)throw Error("Target workspace directory already contains files. Use Existing folder instead.")}catch(b){if("ENOENT"===("object"==typeof b&&b&&"code"in b?b.code:void 0))return void await (0,e.mkdir)(a,{recursive:!0});if(b instanceof Error)throw b;throw Error("Unable to prepare the workspace directory.")}await (0,e.mkdir)(a,{recursive:!0})}async function E(a){try{if(!(await (0,e.stat)(a)).isDirectory())throw Error("The selected existing path is not a directory.")}catch(a){if("ENOENT"===("object"==typeof a&&a&&"code"in a?a.code:void 0))throw Error("The selected existing folder does not exist.");if(a instanceof Error)throw a;throw Error("Unable to access the selected existing folder.")}}async function F(a,b){let c=u(b);return c?c.split("@")[0]:await y(g().join(a,"pnpm-lock.yaml"))?"pnpm":await y(g().join(a,"yarn.lock"))?"yarn":"npm"}async function G(a){let b=g().join(a,"package.json");try{let c=await (0,e.readFile)(b,"utf8"),d=JSON.parse(c),f=d.scripts??{},g=await F(a,d.packageManager),h=[`Use \`${g} install\` before the first local run.`];for(let a of["dev","start","test","lint","build"])f[a]&&h.push(`Use \`${"yarn"===g?`yarn ${a}`:`${g} run ${a}`}\` for the ${a} workflow.`);return h}catch{return[]}}async function H(a){let b=g().join(a,"Makefile");try{return((await (0,e.readFile)(b,"utf8")).match(/^(dev|test|lint|build|run):/gm)??[]).map(a=>`Use \`make ${a.replace(/:$/,"")}\` if the Makefile is the primary entry point.`)}catch{return[]}}async function I(a){let b=[];return await y(g().join(a,"pyproject.toml"))&&b.push("Use `pytest` for Python verification if the project exposes a test suite."),await y(g().join(a,"requirements.txt"))&&b.push("Install Python dependencies in a virtualenv before running project commands."),b}async function J(a){let b=[],c=await G(a),d=await H(a),e=await I(a);return b.push(...c,...d,...e),0===b.length&&b.push("Use repository-local scripts or documented commands for repeatable workflows.","Update this file when the project exposes a cleaner build, test, or release path."),v(b).slice(0,6)}function K(a,b){switch(a){case"project-builder":return`# Project Builder
|
|
3
|
+
|
|
4
|
+
Use this skill when implementing changes in the current project.
|
|
5
|
+
|
|
6
|
+
- Prefer direct code or artifact changes over speculative planning.
|
|
7
|
+
- Respect AGENTS.md, TOOLS.md, MEMORY.md, and memory/*.md before large edits.
|
|
8
|
+
- Put task-specific artifacts under the current deliverables run folder instead of the workspace root.
|
|
9
|
+
- Verify impact before finishing and leave the workspace in a clearer state.
|
|
10
|
+
`;case"project-reviewer":return`# Project Reviewer
|
|
11
|
+
|
|
12
|
+
Use this skill when reviewing changes in the current project.
|
|
13
|
+
|
|
14
|
+
- Prioritize correctness, regressions, edge cases, and missing tests.
|
|
15
|
+
- Prefer concrete findings with file and behavior references.
|
|
16
|
+
- Keep summaries brief after findings.
|
|
17
|
+
`;case"project-tester":return`# Project Tester
|
|
18
|
+
|
|
19
|
+
Use this skill when validating behavior in the current project.
|
|
20
|
+
|
|
21
|
+
- Prefer reproducible checks over assumptions.
|
|
22
|
+
- Focus on failures, regressions, missing coverage, and environment constraints.
|
|
23
|
+
- Report exactly what was verified and what could not be verified.
|
|
24
|
+
`;case"project-learner":return`# Project Learner
|
|
25
|
+
|
|
26
|
+
Use this skill when consolidating durable project knowledge.
|
|
27
|
+
|
|
28
|
+
- Capture stable conventions, architecture decisions, and delivery notes.
|
|
29
|
+
- Prefer updating MEMORY.md or memory/*.md with concise, durable facts.
|
|
30
|
+
- Avoid ephemeral chatter and duplicated notes.
|
|
31
|
+
`;case"project-browser":return`# Project Browser
|
|
32
|
+
|
|
33
|
+
Use this skill when validating browser flows in the current workspace.
|
|
34
|
+
|
|
35
|
+
- Exercise real user paths, not only component-level assumptions.
|
|
36
|
+
- Capture screenshots, repro steps, and UI regressions with concrete evidence.
|
|
37
|
+
- Hand off findings that need code changes back to the implementation agent.
|
|
38
|
+
`;case"project-researcher":return`# Project Researcher
|
|
39
|
+
|
|
40
|
+
Use this skill when investigating, synthesizing, or pressure-testing a problem space.
|
|
41
|
+
|
|
42
|
+
- Start with explicit questions, evidence sources, and output goals.
|
|
43
|
+
- Distinguish verified facts from inference.
|
|
44
|
+
- Convert durable findings into MEMORY.md or memory/*.md.
|
|
45
|
+
`;case"project-strategist":return`# Project Strategist
|
|
46
|
+
|
|
47
|
+
Use this skill when shaping positioning, campaign direction, or editorial priorities.
|
|
48
|
+
|
|
49
|
+
- Tie recommendations to audience, channel, and measurable goals.
|
|
50
|
+
- Prefer explicit tradeoffs over vague guidance.
|
|
51
|
+
- Save task-specific briefs, plans, and campaign artifacts inside the current deliverables run folder.
|
|
52
|
+
- Leave a clear next-step plan other agents can execute.
|
|
53
|
+
`;case"project-writer":return`# Project Writer
|
|
54
|
+
|
|
55
|
+
Use this skill when drafting messaging, copy, or narrative assets.
|
|
56
|
+
|
|
57
|
+
- Write for the target audience and channel rather than internal shorthand.
|
|
58
|
+
- Keep tone and structure consistent with the workspace brief.
|
|
59
|
+
- Save publishable drafts and task-specific docs inside the current deliverables run folder.
|
|
60
|
+
- Flag assumptions that need strategic review before publication.
|
|
61
|
+
`;case"project-analyst":return`# Project Analyst
|
|
62
|
+
|
|
63
|
+
Use this skill when evaluating results, experiments, or performance signals.
|
|
64
|
+
|
|
65
|
+
- Prefer measurable baselines and explicit comparisons.
|
|
66
|
+
- Separate observed performance from speculation about causality.
|
|
67
|
+
- Keep task-specific reports and analysis artifacts inside the current deliverables run folder.
|
|
68
|
+
- Write down recommendations that can be actioned by the team.
|
|
69
|
+
`;default:return`# ${b}
|
|
70
|
+
|
|
71
|
+
Use this skill when operating in the current workspace.
|
|
72
|
+
|
|
73
|
+
- Stay grounded in the shared workspace context.
|
|
74
|
+
- Produce durable artifacts when the work needs to be handed off.
|
|
75
|
+
- Put task-specific artifacts in the current deliverables run folder and keep notes in memory/.
|
|
76
|
+
- Keep outputs specific, reviewable, and easy for other agents to extend.
|
|
77
|
+
`}}function L(a,b){let c=[`- Preset: ${(0,h._P)(a.preset)}.`];switch("browser"===a.preset?c.push("- Prefer browser-native evidence capture, screenshots, and reproducible user-path validation."):"monitoring"===a.preset?c.push("- Periodically inspect the workspace, surface blockers, and leave concise triage handoffs without broad implementation changes."):"setup"===a.preset?c.push("- Prepare the environment, unblock other agents, and keep mutations minimal and explicit."):"worker"===a.preset?c.push("- Focus on producing deliverables, reviews, analysis, or code without unnecessary environment mutation."):c.push("- Operate with the selected policy, keep artifacts reviewable, and avoid surprising side effects."),a.missingToolBehavior){case"fallback":c.push("- If required tooling is unavailable, do not install it. Produce the closest viable fallback artifact, such as .md or .txt, and state the limitation.");break;case"ask-setup":c.push("- If required tooling is unavailable, stop before installing anything and report the missing capability clearly.");break;case"route-setup":c.push(b?`- If required tooling is unavailable, do not install it yourself. Leave a concrete handoff for setup agent \`${b}\` with the exact missing tools or commands.`:"- If required tooling is unavailable, do not install it yourself. Leave a concrete setup handoff with the exact missing tools or commands.");break;case"allow-install":c.push("- If required tooling is unavailable, you may install it when the install scope below permits it.")}switch(a.installScope){case"none":c.push("- Install scope: none. Do not run package installation commands.");break;case"workspace":c.push("- Install scope: workspace only. Limit installs to project-local or workspace-local dependencies and avoid system package managers.");break;case"system":c.push("- Install scope: system. System-wide installs are allowed when necessary, but keep them minimal and report what changed.")}return c.push("workspace-only"===a.fileAccess?"- File access: workspace only. Keep file operations inside the attached workspace.":"- File access: extended. Prefer the workspace, but you may touch adjacent paths when the task explicitly needs them."),c.push("enabled"===a.networkAccess?"- Network access: enabled when the task requires external information or downloads.":"- Network access: restricted. Avoid network access unless the task explicitly depends on it."),c}async function M(a){if("existing"===a.sourceMode)return void await E(a.targetDir);if("clone"===a.sourceMode){let b=u(a.repoUrl);if(!b)throw Error("Repository URL is required when cloning a repo.");await C(a.targetDir),await (0,e.mkdir)(g().dirname(a.targetDir),{recursive:!0}),await z("git",["clone",b,a.targetDir]);return}await D(a.targetDir)}async function N(a,b){let c=(0,r.hh)(b.template),d=new Date().toISOString(),f=await J(a),h=x(b.name);for(let i of(await P(a),await (0,e.mkdir)(g().join(a,"skills"),{recursive:!0}),await (0,e.mkdir)(g().join(a,".openclaw","project-shell","runs"),{recursive:!0}),await (0,e.mkdir)(g().join(a,".openclaw","project-shell","tasks"),{recursive:!0}),await A(g().join(a,".openclaw","project-shell","events.jsonl"),""),await A(g().join(a,".openclaw","project.json"),`${JSON.stringify({version:1,slug:x(b.name),name:b.name,icon:c.icon,createdAt:d,updatedAt:d,template:b.template,sourceMode:b.sourceMode,teamPreset:b.teamPreset,modelProfile:b.modelProfile,agentTemplate:"solo"===b.teamPreset?"solo":"core-team",rules:{workspaceOnly:b.rules.workspaceOnly,generateStarterDocs:b.rules.generateStarterDocs,generateMemory:b.rules.generateMemory,kickoffMission:b.rules.kickoffMission},contextSources:b.contextSources,agents:b.agents.map(a=>{var b;let c,d=w(a);return{id:(c=x(b=a.id)||"agent",b.startsWith(`${h}-`)?b:`${h}-${c}`),name:a.name,role:a.role,enabled:a.enabled,emoji:u(a.emoji)??null,theme:u(a.theme)??null,isPrimary:!!a.isPrimary,skillId:d[0]??null,skillIds:d,modelId:u(a.modelId)??null,policy:a.policy??null}})},null,2)}
|
|
78
|
+
`),(0,q.Q5)({name:b.name,brief:b.brief,template:b.template,sourceMode:b.sourceMode,rules:b.rules,agents:b.agents,toolExamples:f,docOverrides:b.docOverrides,contextSources:b.contextSources})))await A(g().join(a,i.path),i.content);for(let c of(await (0,s.u)(a),b.agents))for(let b of w(c))await (0,e.mkdir)(g().join(a,"skills",b),{recursive:!0}),await A(g().join(a,"skills",b,"SKILL.md"),`${K(b,c.role)}
|
|
79
|
+
`)}function O(a,b){return"clone"===a?`Cloning the source repository into ${b}.`:"existing"===a?`Preparing the existing workspace folder at ${b}.`:`Creating a fresh workspace folder at ${b}.`}async function P(a){let b=g().join(a,".gitignore"),c="";try{c=await (0,e.readFile)(b,"utf8")}catch{c=""}let d=Q.filter(a=>!c.includes(a));if(0===d.length)return;let f=["# OpenClaw local runtime state",...d].join("\n"),h=c.trim().length>0?`${c.trimEnd()}
|
|
80
|
+
|
|
81
|
+
${f}
|
|
82
|
+
`:`${f}
|
|
83
|
+
`;await B(b,h)}let Q=[".openclaw/agents/",".openclaw/project-shell/events.jsonl",".openclaw/project-shell/runs/",".openclaw/project-shell/tasks/"];function R(a){return a?a.split(/[-_]+/g).filter(Boolean).map(a=>a.charAt(0).toUpperCase()+a.slice(1)).join(" "):"Agent"}var S=c(59855);let T=["project-builder","project-reviewer","project-tester","project-learner","project-browser","project-researcher","project-strategist","project-writer","project-analyst"];function U(a){return"string"==typeof a&&a.trim().length>0?a.trim():null}function V(a){return Array.from(new Set(a.filter(Boolean)))}function W(a){return a.title&&a.title!==a.chatId?`${a.title} (\`${a.chatId}\`)`:`\`${a.chatId}\``}function X(a,b){return`${a}-${b.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"agent"}`}async function Y(a){let b=X(a.workspaceSlug,a.agent.id),c=(0,l.N2)(a.workspacePath,b),d=U(a.agent.modelId)??U(a.workspaceModelId),e=V([...(a.agent.skillIds??[]).map(a=>U(a)??""),U(a.agent.skillId)??""]),f=(0,h.g0)(a.agent.policy?.preset??(0,h.qF)({skills:e,id:b,name:a.agent.name}),a.agent.policy);await (0,k.rw)().addAgent({id:b,workspace:a.workspacePath,agentDir:c,model:d,name:U(a.agent.name)});let g=await Z({workspacePath:a.workspacePath,agentId:b,agentName:a.agent.name,policy:f});return await (0,l.jq)(b,a.workspacePath,{agentDir:c,name:U(a.agent.name)??void 0,model:d??void 0,heartbeat:j(a.agent.heartbeat),skills:[...e,g],tools:"workspace-only"===f.fileAccess?{fs:{workspaceOnly:!0}}:null,identity:{name:U(a.agent.name),emoji:U(a.agent.emoji),theme:U(a.agent.theme)}}),await (0,s.u)(a.workspacePath),await (0,l.rH)(b,a.workspacePath,c),b}async function Z(a){let b=(0,l.Uo)(a.agentId);await (0,n.rh)(a.timings,"agent-policy.ensure-telegram-helper",()=>ab(a.workspacePath));let c=await (0,n.rh)(a.timings,"agent-policy.build-team-context",()=>ad(a.workspacePath,a.agentId,a.snapshot??null)),d=await (0,n.rh)(a.timings,"agent-policy.build-telegram-coordination",()=>(function(a,b,c){if(!c)return null;let d=new Map(b?.agents.map(a=>[a.id,(0,m.CK)(a)])??[]),e=new Map(b?.agents.map(a=>[a.id,a])??[]),f=e.get(a)??null,g=f?.workspaceId??null,h=[],i=[],j=[];for(let b of c.channels.filter(a=>"telegram"===a.type)){let c=b.workspaces.filter(a=>a.workspaceId===g);if(0===c.length)continue;let f=(0,S.qc)(c.flatMap(a=>a.groupAssignments.filter(a=>!1!==a.enabled))).map(a=>({chatId:a.chatId,title:a.title??null})),k=(0,S.qc)(c.flatMap(b=>b.groupAssignments.filter(b=>!1!==b.enabled&&b.agentId===a))),l=f.filter(a=>!k.some(b=>b.chatId===a.chatId)&&!c.some(b=>b.groupAssignments.some(b=>!1!==b.enabled&&b.chatId===a.chatId&&b.agentId)));if(b.primaryAgentId===a){let f=V(c.flatMap(b=>b.agentIds.filter(b=>b!==a))).map(a=>{let b=e.get(a)??null;return{agentId:a,name:d.get(a)??a,summary:ac(b)}});h.push({channelId:b.id,channelName:b.name,groups:l,peers:f})}for(let f of k){let g=V(c.flatMap(c=>c.agentIds.filter(c=>c!==a&&c!==b.primaryAgentId))).map(a=>{let b=e.get(a)??null;return{agentId:a,name:d.get(a)??a,summary:ac(b)}});i.push({channelId:b.id,channelName:b.name,chatId:f.chatId,title:f.title??null,primaryAgentId:b.primaryAgentId??a,primaryAgentName:d.get(b.primaryAgentId??a)??b.primaryAgentId??a,peers:g})}if(b.primaryAgentId&&b.primaryAgentId!==a&&0===k.length){let f=e.get(b.primaryAgentId)??null,g=V(c.flatMap(c=>c.agentIds.filter(c=>c!==b.primaryAgentId&&c!==a))).map(a=>{let b=e.get(a)??null;return{agentId:a,name:d.get(a)??a,summary:ac(b)}});j.push({channelId:b.id,channelName:b.name,groups:l,peers:g,primaryAgentId:b.primaryAgentId,primaryAgentName:d.get(b.primaryAgentId)??(f?(0,m.CK)(f):b.primaryAgentId)})}}return{primaryChannels:h.sort((a,b)=>a.channelName.localeCompare(b.channelName)),ownedGroups:i.sort((a,b)=>{let c=`${a.channelName}:${a.title??a.chatId}`,d=`${b.channelName}:${b.title??b.chatId}`;return c.localeCompare(d)}),delegateChannels:j.sort((a,b)=>a.channelName.localeCompare(b.channelName))}})(a.agentId,a.snapshot??null,a.channelRegistry??a.snapshot?.channelRegistry??null));return await (0,n.rh)(a.timings,"agent-policy.write-skill",()=>{var e,f,i,j,k;let l,m,n;return B(g().join(a.workspacePath,"skills",b,"SKILL.md"),`${(e=a.agentName,f=a.policy,i=a.setupAgentId,j=c,k=d,l=(0,h._P)(f.preset),m=function(a){if(!a||0===a.members.length)return null;let b=["## Workspace team","- This workspace currently includes these agents. Do not assume you are the only agent unless you verify the roster again.","- Use these exact agent ids when referring to teammates or handing work off:"];for(let c of a.members){let a=[c.isCurrent?"you":null,c.isPrimary?"primary":null,c.role].filter(a=>!!a);b.push(`- ${c.name} (\`${c.agentId}\`) \xb7 ${a.join(" \xb7 ")}.`)}return b.push("- If you are asked who is in this workspace, answer from this roster or re-check `.openclaw/project.json` before replying."),b.join("\n")}(j),n=function(a){if(!a||0===a.primaryChannels.length&&0===a.ownedGroups.length&&0===a.delegateChannels.length)return null;let b=["## Telegram coordination"];if(b.push("- Telegram credentials are managed by OpenClaw for the listed channels. Do not ask the operator for `TELEGRAM_BOT_TOKEN` or `channels.telegram.botToken` when sending to listed groups."),b.push('- To send or post, call the `message` tool with `action: "send"`, `channel: "telegram"`, `target: "<chatId>"`, and the exact message text. Use the listed chat id as `target`.'),b.push("- If sending fails, report the actual tool error instead of inventing a missing-token error."),a.primaryChannels.length>0){for(let c of(b.push("- You are the public Telegram fallback for these channels:"),a.primaryChannels)){let a=c.groups.length>0?c.groups.map(W).join(", "):"no allowed groups yet";if(b.push(` - ${c.channelName} (\`${c.channelId}\`) \xb7 fallback groups: ${a}.`),c.peers.length>0)for(let a of(b.push(" - Internal assistants:"),c.peers))b.push(` - ${a.name} (\`${a.agentId}\`) \xb7 ${a.summary}.`)}b.push("- Keep public Telegram replies under your own voice for unassigned groups, even when you ask another agent for help."),b.push("- For specialist help, call another agent from the workspace terminal with:"),b.push("```bash"),b.push('node .openclaw/tools/telegram-delegate-agent.mjs --agent <delegate-agent-id> --message "Summarize what I need from you"'),b.push("```"),b.push("- Use delegate turns for internal research, drafting, or analysis only. Do not ask them to answer Telegram directly."),b.push("- After a delegate responds, decide what to share publicly and send the final Telegram reply yourself.")}if(a.ownedGroups.length>0){for(let c of(b.push("- You are the public Telegram voice for these assigned groups:"),a.ownedGroups))if(b.push(` - ${c.channelName} (\`${c.channelId}\`) \xb7 ${c.title??c.chatId} (\`${c.chatId}\`) \xb7 primary ${c.primaryAgentName} (\`${c.primaryAgentId}\`).`),c.peers.length>0)for(let a of(b.push(" - Internal assistants for this group:"),c.peers))b.push(` - ${a.name} (\`${a.agentId}\`) \xb7 ${a.summary}.`);b.push("- Reply directly to those groups as the public voice. Use other agents only for internal help.")}if(a.delegateChannels.length>0){for(let c of(b.push("- You can assist these Telegram admin channels when the primary agent asks:"),a.delegateChannels)){let a=c.groups.length>0?c.groups.map(W).join(", "):"no allowed groups yet";if(b.push(` - ${c.channelName} (\`${c.channelId}\`) \xb7 primary ${c.primaryAgentName} (\`${c.primaryAgentId}\`) \xb7 groups: ${a}.`),c.peers.length>0)for(let a of(b.push(" - Nearby assistants:"),c.peers))b.push(` - ${a.name} (\`${a.agentId}\`) \xb7 ${a.summary}.`)}b.push("- When helping with Telegram work for groups not assigned to you, return concise internal findings or draft language. Do not speak as the public Telegram agent for those unassigned groups.")}return b.join("\n")}(k),`# ${e} Policy
|
|
84
|
+
|
|
85
|
+
Preset: ${l}
|
|
86
|
+
|
|
87
|
+
## Output routing
|
|
88
|
+
- Final deliverables belong in the current deliverables run folder for the task.
|
|
89
|
+
- Keep temporary notes and durable workspace memory inside memory/.
|
|
90
|
+
- Treat MEMORY.md, memory/*.md, docs/brief.md, docs/architecture.md, and any template-specific docs under docs/ as shared workspace context before large edits.
|
|
91
|
+
- Avoid writing final artifacts to the workspace root unless the task explicitly asks for it.
|
|
92
|
+
|
|
93
|
+
## Operating rules
|
|
94
|
+
${L(f,i).map(a=>a.replace(/^- /,"- ")).join("\n")}
|
|
95
|
+
${m?`
|
|
96
|
+
|
|
97
|
+
${m}`:""}${n?`
|
|
98
|
+
|
|
99
|
+
${n}`:""}
|
|
100
|
+
`)}
|
|
101
|
+
`)}),b}async function $(a,b){let[c]=(0,h._Y)([b]);if(!c)return;let d=g().join(a,"skills",b);await (0,e.mkdir)(d,{recursive:!0}),await A(g().join(d,"SKILL.md"),`${K(c,(0,h.aB)(c))}
|
|
102
|
+
`)}async function _(a,b=[]){let c=new Set([...(await (0,S.OL)(a)).agents.flatMap(a=>a.skillIds),...b]);await Promise.all(T.filter(a=>!c.has(a)).map(b=>aa(a,b)))}async function aa(a,b){let c=g().join(a,"skills",b),d=g().join(c,"SKILL.md");try{let a=await (0,e.readFile)(d,"utf8"),f=`${K(b,(0,h.aB)(b))}
|
|
103
|
+
`;if(a.trimEnd()!==f.trimEnd())return;await (0,e.rm)(c,{recursive:!0,force:!0})}catch{}}async function ab(a){let b=g().join(a,".openclaw","tools","telegram-delegate-agent.mjs");await B(b,`${String.raw`#!/usr/bin/env node
|
|
104
|
+
import { execFile } from "node:child_process";
|
|
105
|
+
import { promisify } from "node:util";
|
|
106
|
+
|
|
107
|
+
const execFileAsync = promisify(execFile);
|
|
108
|
+
|
|
109
|
+
function parseArgs(argv) {
|
|
110
|
+
const options = {
|
|
111
|
+
agentId: "",
|
|
112
|
+
message: "",
|
|
113
|
+
thinking: "low",
|
|
114
|
+
json: false,
|
|
115
|
+
stdin: false
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
119
|
+
const arg = argv[index];
|
|
120
|
+
|
|
121
|
+
if (arg === "--agent") {
|
|
122
|
+
options.agentId = argv[index + 1] ?? "";
|
|
123
|
+
index += 1;
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (arg === "--message") {
|
|
128
|
+
options.message = argv[index + 1] ?? "";
|
|
129
|
+
index += 1;
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (arg === "--thinking") {
|
|
134
|
+
options.thinking = argv[index + 1] ?? "low";
|
|
135
|
+
index += 1;
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (arg === "--json") {
|
|
140
|
+
options.json = true;
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (arg === "--stdin") {
|
|
145
|
+
options.stdin = true;
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return options;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function usage() {
|
|
154
|
+
process.stderr.write(
|
|
155
|
+
"Usage: node .openclaw/tools/telegram-delegate-agent.mjs --agent <id> --message <text> [--thinking low|medium|high] [--json]\n"
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function extractText(payload) {
|
|
160
|
+
if (!payload || typeof payload !== "object") {
|
|
161
|
+
return "";
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (typeof payload.summary === "string" && payload.summary.trim()) {
|
|
165
|
+
return payload.summary.trim();
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (Array.isArray(payload.payloads)) {
|
|
169
|
+
for (const entry of payload.payloads) {
|
|
170
|
+
if (entry && typeof entry === "object") {
|
|
171
|
+
if (typeof entry.text === "string" && entry.text.trim()) {
|
|
172
|
+
return entry.text.trim();
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (typeof entry.content === "string" && entry.content.trim()) {
|
|
176
|
+
return entry.content.trim();
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
if (payload.result && typeof payload.result === "object") {
|
|
183
|
+
return extractText(payload.result);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return "";
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
async function readStdin() {
|
|
190
|
+
const chunks = [];
|
|
191
|
+
for await (const chunk of process.stdin) {
|
|
192
|
+
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk)));
|
|
193
|
+
}
|
|
194
|
+
return Buffer.concat(chunks).toString("utf8").trim();
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
async function main() {
|
|
198
|
+
const options = parseArgs(process.argv.slice(2));
|
|
199
|
+
if (options.stdin) {
|
|
200
|
+
options.message = await readStdin();
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
if (!options.agentId || !options.message.trim()) {
|
|
204
|
+
usage();
|
|
205
|
+
process.exit(1);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
const args = [
|
|
209
|
+
"agent",
|
|
210
|
+
"--agent",
|
|
211
|
+
options.agentId,
|
|
212
|
+
"--message",
|
|
213
|
+
options.message.trim(),
|
|
214
|
+
"--thinking",
|
|
215
|
+
options.thinking,
|
|
216
|
+
"--json"
|
|
217
|
+
];
|
|
218
|
+
|
|
219
|
+
try {
|
|
220
|
+
const { stdout } = await execFileAsync("openclaw", args, {
|
|
221
|
+
cwd: process.cwd(),
|
|
222
|
+
maxBuffer: 4 * 1024 * 1024
|
|
223
|
+
});
|
|
224
|
+
const parsed = JSON.parse(stdout);
|
|
225
|
+
|
|
226
|
+
if (options.json) {
|
|
227
|
+
process.stdout.write(JSON.stringify(parsed, null, 2) + "\n");
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
const text = extractText(parsed);
|
|
232
|
+
process.stdout.write((text || JSON.stringify(parsed, null, 2)) + "\n");
|
|
233
|
+
} catch (error) {
|
|
234
|
+
const message =
|
|
235
|
+
error && typeof error === "object" && "stderr" in error && typeof error.stderr === "string"
|
|
236
|
+
? error.stderr.trim()
|
|
237
|
+
: error instanceof Error
|
|
238
|
+
? error.message
|
|
239
|
+
: "Telegram delegation failed.";
|
|
240
|
+
process.stderr.write(String(message) + "\n");
|
|
241
|
+
process.exit(1);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
await main();
|
|
246
|
+
`}
|
|
247
|
+
`)}function ac(a){if(!a)return"no capability snapshot";let b=[(0,h._P)(a.policy.preset)],c=a.profile.purpose?.trim();c&&b.push(c);let d=V(a.skills).slice(0,2);d.length>0&&b.push(`skills: ${d.join(", ")}`);let e=V(a.tools).slice(0,2);return e.length>0&&b.push(`tools: ${e.join(", ")}`),b.join(" \xb7 ")}async function ad(a,b,c){if(!c)return null;let d=c.agents.find(a=>a.id===b);if(!d)return null;let e=new Map((await (0,S.OL)(a)).agents.map(a=>[a.id,a])),f=c.agents.filter(a=>a.workspaceId===d.workspaceId).sort((a,c)=>{if(a.id===b&&c.id!==b)return -1;if(c.id===b&&a.id!==b)return 1;let d=e.get(a.id),f=e.get(c.id),g=d?.isPrimary??!1;return g!==(f?.isPrimary??!1)?g?-1:1:(0,m.CK)(a).localeCompare((0,m.CK)(c))}).map(a=>{let c=e.get(a.id);return{agentId:a.id,name:(0,m.CK)(a),role:c?.role?.trim()||(0,h._P)(a.policy.preset),isPrimary:c?.isPrimary??!1,isCurrent:a.id===b}});return f.length>0?{members:f}:null}var ae=c(58770),af=c(43639);let ag=["project-researcher","project-builder","project-analyst"];async function ah(a){let b=as(a.id.trim());if(!b)throw Error("Agent id is required.");let c=await (0,d.GM)({includeHidden:!0}),e=ar(c,a.workspaceId),f=(0,ae.Nk)(a.workspacePath)??e?.path;f||(e=ar(c=await (0,d.GM)({force:!0,includeHidden:!0}),a.workspaceId),f=(0,ae.Nk)(a.workspacePath)??e?.path);let m=e?.id??(f?(0,af.S_)(f):a.workspaceId||null);if(function(a,b,c){var d,e;let f=a.agents.find(a=>a.id===b);if(!f)return;let h=(d=a,e=f,d.workspaces.find(a=>a.id===e.workspaceId)?.name??g().basename(e.workspacePath));if(f.workspaceId===c)throw Error(`Agent id "${b}" already exists in workspace "${h}".`);throw Error(`Agent id "${b}" is already used by workspace "${h}". Choose a different id.`)}(c,b,m),!f||!m)throw Error("Workspace was not found for this agent.");let n=(0,h.g0)(a.policy?.preset??h.iN,a.policy),o=(0,h.Cf)(n.preset),p=(0,h._Y)(o.skillIds),q=(0,h.X0)(o.tools),r=void 0===a.skills?p:(0,h._Y)((0,l.AB)(a.skills)),t=void 0===a.tools?q:(0,l.at)(a.tools),u=(0,ae.Nk)(a.name)??o.defaultName,v=(0,ae.Nk)(a.emoji)??o.defaultEmoji,w=(0,ae.Nk)(a.theme)??o.defaultTheme,x=(0,ae.Nk)(a.avatar),y=j(i(n.preset,a.heartbeat)),z=c.agents.find(a=>a.workspaceId===m&&"setup"===a.policy.preset)?.id??null,A=(0,l.N2)(f,b),B=(0,ae.Nk)(a.modelId)??ak(c);await (0,k.rw)().addAgent({id:b,workspace:f,agentDir:A,model:B,name:u,emoji:v,avatar:x});let C=await Z({workspacePath:f,agentId:b,agentName:u,policy:n,setupAgentId:z,snapshot:c});for(let a of r)await $(f,a);return await (0,l.jq)(b,f,{agentDir:A,name:u,model:B,heartbeat:y,skills:ap([...r,C]),tools:"workspace-only"===n.fileAccess?{fs:{workspaceOnly:!0}}:null,identity:{name:u,emoji:v,theme:w,avatar:x}},c),await an(f,{id:b,name:u,role:(0,h._P)(n.preset),emoji:v,theme:w,enabled:!0,skillId:r[0]??null,skillIds:r,toolIds:t,modelId:B,isPrimary:!1,policy:n,channelIds:a.channelIds??[]}),await (0,s.u)(f),await _(f,aq(c,f,new Map([[b,r]]))),await (0,l.rH)(b,f,A),(0,d.ZZ)(),await am(f),{agentId:b,workspaceId:m}}async function ai(a){var b,c;let e,f,g=a.id.trim();if(!g)throw Error("Agent id is required.");let m=await (0,d.GM)({includeHidden:!0}),n=m.agents.find(a=>a.id===g);if(n||(n=(m=await (0,d.GM)({force:!0,includeHidden:!0})).agents.find(a=>a.id===g)),!n)throw Error("Agent was not found.");let o=ar(m,a.workspaceId||n.workspaceId),p=(0,ae.Nk)(a.workspacePath)??o?.path??n.workspacePath,q=o?.id??(p?(0,af.S_)(p):a.workspaceId||n.workspaceId);if(!p||!q)throw Error("Workspace was not found for this agent.");let r=(0,h.g0)(a.policy?.preset??n.policy.preset,a.policy??n.policy),t=(0,h.Cf)(r.preset),u=(0,h._Y)(t.skillIds),v=(0,h.X0)(t.tools),w=(0,ae.Nk)(n.name),x=(0,ae.Nk)(n.identity.emoji),y=(0,ae.Nk)(n.identity.theme),z=j(i(r.preset,a.heartbeat??(0,l.D9)(n.heartbeat))),A=m.agents.find(a=>a.workspaceId===q&&"setup"===a.policy.preset&&a.id!==g)?.id??null,B=void 0!==a.modelId?(0,ae.Nk)(a.modelId):"unassigned"===n.modelId?ak(m):n.modelId;if(void 0!==a.modelId&&void 0===a.name&&void 0===a.emoji&&void 0===a.theme&&void 0===a.avatar&&void 0===a.policy&&void 0===a.heartbeat&&void 0===a.channelIds&&void 0===a.skills&&void 0===a.tools)return await (0,k.rw)().updateAgent({id:g,workspace:p,model:B},{timeoutMs:15e3}),await (0,l.jq)(g,p,{agentDir:n.agentDir??(0,l.N2)(p,g),model:B},m),await an(p,{id:g,name:w??n.name??g,emoji:x,theme:y,enabled:!0,modelId:B,isPrimary:n.isDefault,policy:r}),await (0,s.u)(p),await (0,l.rH)(g,p,n.agentDir??(0,l.N2)(p,g)),(0,d.ZZ)(),{agentId:g,workspaceId:q};let C=await Z({workspacePath:p,agentId:g,agentName:(0,ae.Nk)(a.name)??w??g,policy:r,setupAgentId:A,snapshot:m}),D=(0,l.AB)(n.skills),E=(0,l.at)(n.tools),F=r.preset!==n.policy.preset||0===D.length,G=r.preset!==n.policy.preset||0===E.length,H=void 0===a.skills&&"custom"===r.preset&&(b=D,c=ag,e=new Set(b),f=new Set(c),e.size===f.size&&Array.from(e).every(a=>f.has(a))),I=void 0===a.skills?H?[]:F?u:D:(0,h._Y)((0,l.AB)(a.skills));for(let a of I)await $(p,a);await (0,k.rw)().updateAgent({id:g,workspace:p,model:B},{timeoutMs:15e3});let J=await (0,l.jq)(g,p,{agentDir:n.agentDir??(0,l.N2)(p,g),name:void 0!==a.name?(0,ae.Nk)(a.name):void 0,model:B,heartbeat:z,skills:ap([...I,C]),tools:"workspace-only"===r.fileAccess?{fs:{workspaceOnly:!0}}:null,identity:{name:(0,ae.Nk)(a.name)??w??g,emoji:(0,ae.Nk)(a.emoji)??x,theme:(0,ae.Nk)(a.theme)??y,avatar:(0,ae.Nk)(a.avatar)}},m),K=void 0===a.tools?G?v:void 0:(0,l.at)(a.tools);return await an(p,{id:g,name:(0,ae.Nk)(a.name)??w??J.name??g,emoji:(0,ae.Nk)(a.emoji)??x,theme:(0,ae.Nk)(a.theme)??y,enabled:!0,modelId:B,isPrimary:n.isDefault,policy:r,channelIds:a.channelIds,skillId:I[0]??null,skillIds:I,toolIds:K}),await (0,s.u)(p),await _(p,aq(m,p,new Map([[g,I]]))),await (0,l.rH)(g,p,n.agentDir??(0,l.N2)(p,g)),(0,d.ZZ)(),await am(p),{agentId:g,workspaceId:q}}async function aj(a){let b=a.agentId.trim();if(!b)throw Error("Agent id is required.");let c=await (0,d.GM)({includeHidden:!0}),f=c.agents.find(a=>a.id===b);if(f||(f=(c=await (0,d.GM)({force:!0,includeHidden:!0})).agents.find(a=>a.id===b)),!f)throw Error("Agent was not found.");let h=c.workspaces.find(a=>a.id===f.workspaceId)??null,i=c.runtimes.filter(a=>a.agentId===f.id).length;await (0,k.rw)().deleteAgent(f.id);try{let a=await (0,l.CI)(c),b=a.filter(a=>a.id!==f.id);b.length!==a.length&&await (0,l.ZF)(b)}catch{}if(h){await ao(h.path,f.id),await (0,s.u)(h.path),await _(h.path,aq(c,h.path,new Map([[f.id,[]]]))),await (0,l.rH)(f.id,h.path,f.agentDir);try{await (0,e.rm)(g().join(h.path,"skills",(0,l.Uo)(f.id)),{recursive:!0,force:!0})}catch{}(0,d.ZZ)(),await am(h.path)}return(0,d.b7)(),{agentId:f.id,workspaceId:f.workspaceId,workspacePath:f.workspacePath,deletedRuntimeCount:i}}function ak(a){if(a.diagnostics.modelReadiness.defaultModelReady)return(0,ae.Nk)(a.diagnostics.modelReadiness.resolvedDefaultModel)??(0,ae.Nk)(a.diagnostics.modelReadiness.defaultModel)??void 0}async function al(a,b){let c=ap(a);if(0===c.length)return;let e=b??await (0,d.GM)({includeHidden:!0});for(let a of c){let b=e.agents.find(b=>b.id===a);if(!b)continue;let c=e.agents.find(a=>a.workspaceId===b.workspaceId&&"setup"===a.policy.preset&&a.id!==b.id)?.id??null,d=await Z({workspacePath:b.workspacePath,agentId:b.id,agentName:b.name,policy:b.policy,setupAgentId:c,snapshot:e});await (0,l.jq)(b.id,b.workspacePath,{agentDir:b.agentDir??(0,l.N2)(b.workspacePath,b.id),name:b.name,model:(0,ae.Nk)(b.modelId),heartbeat:b.heartbeat.enabled&&b.heartbeat.every?{every:b.heartbeat.every}:null,skills:[...(0,l.AB)(b.skills),d],tools:b.tools.includes("fs.workspaceOnly")?{fs:{workspaceOnly:!0}}:null,identity:{name:b.identityName??b.name,emoji:b.identity.emoji,theme:b.identity.theme,avatar:b.identity.avatar}},e)}}async function am(a,b){let c=b??await (0,d.GM)({includeHidden:!0}),e=c.agents.filter(b=>b.workspacePath===a).map(a=>a.id);await al(e,c)}async function an(a,b){let c=g().join(a,".openclaw","project.json"),d={},f=null;try{let a=await (0,e.readFile)(c,"utf8"),g=JSON.parse(a);d=at(g)?g:{},Array.isArray(d.agents)&&(f=d.agents.map(a=>(0,S.aW)(a)).filter(a=>!!a).find(a=>a.id===b.id)??null)}catch{d={}}let h=Array.isArray(b.skillIds)?ap(b.skillIds.map(a=>a.trim()).filter(Boolean)):void 0!==b.skillId?[(0,ae.Nk)(b.skillId)].filter(a=>!!a):f?.skillIds??(f?.skillId?[f.skillId]:[]),i={id:b.id,name:b.name??f?.name??null,role:b.role??f?.role??null,isPrimary:b.isPrimary??f?.isPrimary??!1,enabled:b.enabled??f?.enabled??!0,emoji:b.emoji??f?.emoji??null,theme:b.theme??f?.theme??null,skillId:h[0]??null,skillIds:h,toolIds:Array.isArray(b.toolIds)?ap(b.toolIds.map(a=>a.trim()).filter(a=>!!a&&"fs.workspaceOnly"!==a)):f?.toolIds??[],modelId:b.modelId??f?.modelId??null,policy:b.policy,channelIds:Array.isArray(b.channelIds)?Array.from(new Set(b.channelIds.filter(a=>"string"==typeof a&&a.trim()))):f?.channelIds??[]},j=Array.isArray(d.agents)?d.agents.filter(a=>at(a)&&"string"==typeof a.id&&a.id!==b.id):[];j.push(i),d.version="number"==typeof d.version?d.version:1,d.slug="string"==typeof d.slug?d.slug:as(g().basename(a)),d.name="string"==typeof d.name?d.name:g().basename(a),d.updatedAt=new Date().toISOString(),d.agents=j,await B(c,`${JSON.stringify(d,null,2)}
|
|
248
|
+
`)}async function ao(a,b){let c=g().join(a,".openclaw","project.json"),d={};try{let a=await (0,e.readFile)(c,"utf8"),b=JSON.parse(a);d=at(b)?b:{}}catch{return}if(!Array.isArray(d.agents))return;let f=d.agents.map(a=>(0,S.aW)(a)).filter(a=>!!a),h=f.filter(a=>a.id!==b);h.length!==f.length&&(h.length>0&&!h.some(a=>a.isPrimary)&&(h[0]={...h[0],isPrimary:!0}),d.updatedAt=new Date().toISOString(),d.agents=h,await B(c,`${JSON.stringify(d,null,2)}
|
|
249
|
+
`))}function ap(a){return Array.from(new Set(a.filter(Boolean)))}function aq(a,b,c){return ap([...a.agents.flatMap(a=>a.workspacePath!==b?[]:c.has(a.id)?c.get(a.id)??[]:a.skills),...Array.from(c.values()).flat()])}function ar(a,b){if(b)return a.workspaces.find(a=>a.id===b)??a.workspaces.find(a=>(0,af.xV)(a.path,b))}function as(a){return a.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function at(a){return"object"==typeof a&&null!==a}var au=c(48161),av=c.n(au),aw=c(43785),ax=c(89521),ay=c(96015),az=c(87016),aA=c(17324),aB=c(51871);let aC=/\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/gi;function aD(a){if(!a)return!1;let b=a.trim().toLowerCase();return"ready"===b||"completed"===b||"complete"===b||"ok"===b||"success"===b}async function aE(a){var b,c,d,e;let f,{task:g,dispatchRecord:h,createdFiles:i,snapshot:j}=a,k=await aH(h?.outputDir??null),l=h?await aF(h,j,a.runs):[],m=g.mission||h?.mission||null,n=m&&l.length>0?l.filter(a=>(0,aA.Dm)(a.prompt,m)):l,o=[...n].sort((a,b)=>Date.parse(b.updatedAt)-Date.parse(a.updatedAt))[0]??null,p=o?.finalText?.trim()||null,q=h?aD(f=((b=h.result)&&"object"==typeof b?(Array.isArray(b.result?.payloads)?b.result.payloads:Array.isArray(b.payloads)?b.payloads:[]).filter(a=>!!a&&"string"==typeof a.text):[]).find(a=>a.text.trim().length>0)?.text.trim()??null)?null:f:null,r=p||q||null,s=p?"runtime":q?"dispatch":"none",t=!!(h&&l.length>0&&0===n.length),u=(0,aB.xZ)(n),v=function(a){let b=new Set;for(let c of a)if(c)for(let a of c.match(aC)??[])b.add(a.toLowerCase());return[...b]}([r,q,...n.flatMap(a=>a.items.map(a=>a.text))]),w=[],x=aD(r),y=!!(c=m)&&(/\.(txt|md|json|csv|html|pdf|docx?)\b/i.test(c)||/\b(file|files|artifact|artifacts|report|document|save|export|attachment)\b/i.test(c)||/\b(dosya|dosyasi|kaydet|kaydi|cikti)\b/i.test(c)),z=!!(d=m)&&/\b(email|e-mail|mail|mail address|mail adres|eposta|e-posta)\b/i.test(d),A=!!(e=m)&&(/https?:\/\//i.test(e)||/\b[a-z0-9-]+\.(com|net|org|io|ai|co|tr|app|dev|me|info|biz|edu|gov)\b/i.test(e)||/\b(site|website|web|browser|browse|fetch|sitesine|siteye|siteyi)\b/i.test(e));return h?.outputDir&&!k.exists&&w.push({id:"missing-output-dir",severity:"warning",title:"Output folder is missing",detail:`The dispatch points at ${h.outputDirRelative||h.outputDir}, but that folder is not accessible now.`}),"completed"===g.status&&y&&h?.outputDir&&k.exists&&0===k.fileCount&&0===i.length&&w.push({id:"empty-output-dir",severity:"error",title:"Deliverables folder is empty",detail:"The task asked for a file deliverable, but the assigned deliverables folder does not contain any files."}),"completed"===g.status&&0===l.length&&w.push({id:"missing-transcript",severity:"warning",title:"No runtime transcript was captured",detail:"AgentOS could not verify what the agent actually did because no transcript was recovered for this dispatch."}),"cancelled"===g.status&&w.push({id:"task-cancelled",severity:"warning",title:"Task was cancelled by the operator",detail:h?.error||"The mission dispatch was stopped before completion, so the captured evidence is intentionally incomplete."}),t&&h?.agentId&&w.push({id:"session-mismatch",severity:"error",title:"Recovered session does not match the mission",detail:"The linked transcript session exists, but none of its user turns match this task mission. The dispatch likely reused or attached the wrong session."}),"completed"!==g.status||r?"stalled"===g.status&&r?w.push({id:"partial-final-response",severity:"warning",title:"Final response came from an incomplete runtime",detail:"The assistant produced output, but the runtime stalled before the task completed. Treat this as the last captured response, not a verified completion."}):"completed"===g.status&&x&&r&&w.push({id:"placeholder-final-response",severity:0===k.fileCount&&0===i.length&&0===n.length?"error":"warning",title:"Completion response looks like a placeholder",detail:`The captured final response was "${r}", which is not enough evidence that the requested work actually finished.`}):w.push({id:"missing-final-response",severity:"warning",title:"No final answer was captured",detail:"The task completed without a final assistant response in either the runtime transcript or the dispatch payload."}),"completed"===g.status&&A&&n.length>0&&0===u.length&&w.push({id:"missing-tool-evidence",severity:"warning",title:"No tool usage was recovered",detail:"This mission looks like it needed external lookup or browsing, but the matching transcript turn does not show any recovered tool calls."}),"completed"===g.status&&z&&0===v.length&&w.push({id:"missing-email",severity:"warning",title:"Requested email address was not captured",detail:"The task appears to ask for an email address, but none was detected in the final response or the matching transcript."}),{status:w.some(a=>"error"===a.severity)?"error":w.length>0?"warning":"verified",outputDir:h?.outputDir??null,outputDirRelative:h?.outputDirRelative??null,outputDirExists:k.exists,outputFileCount:k.fileCount,transcriptTurnCount:l.length,matchingTranscriptTurnCount:n.length,finalResponseText:r,finalResponseSource:s,dispatchSessionId:h?aG(h,a.runs)[0]??null:null,sessionMismatch:t,toolNames:u,emails:v,issues:w}}async function aF(a,b,c){let d=aG(a,c);if(0===d.length)return[];let f=b.agents.find(b=>b.id===a.agentId);for(let b of d){let c=await (0,aB.WU)(a.agentId,b,a.workspacePath??f?.workspacePath);if(c)try{let d=await (0,e.readFile)(c,"utf8"),g={id:`runtime:dispatch:${a.id}`,sessionId:b,agentId:a.agentId,taskId:a.id,metadata:{dispatchSubmittedAt:a.submittedAt}},h=(0,aB.qv)(g,(0,aB.SI)(d,g,a.workspacePath??f?.workspacePath));if(h.length>0)return h}catch{continue}}return[]}function aG(a,b){var c;let d;return Array.from(new Set([...b.filter(b=>{var c,d;let e,f;return c=a,e="string"==typeof(d=b).metadata.dispatchId?d.metadata.dispatchId.trim():"",f=d.runId?.trim()||"",e===c.id||f===c.id}).map(a=>a.sessionId?.trim()||null),(a.sessionId?.trim()||null)??(c=function(a){var b;let c=((b=a).result&&"object"==typeof b.result?b.result:null)?.meta;if(!c||"object"!=typeof c){let b=a.meta;return b&&"object"==typeof b?aJ(b):null}return aJ(c)}(a),"string"==typeof(d=c?.sessionId)&&d.trim().length>0?d:null)??function(a){let b=a?.trim();if(!b?.startsWith("runtime:"))return null;let c=b.split(":")[1];return c&&"dispatch"!==c?c:null}(a.observation.runtimeId)].filter(a=>!!a)))}async function aH(a){if(!a)return{exists:!1,fileCount:0};try{if(!(await (0,e.stat)(a)).isDirectory())return{exists:!0,fileCount:1};return{exists:!0,fileCount:await aI(a)}}catch{return{exists:!1,fileCount:0}}}async function aI(a){let b=await (0,e.readdir)(a,{withFileTypes:!0}),c=0;for(let d of b){let b=g().join(a,d.name);if(d.isDirectory()){c+=await aI(b);continue}d.isFile()&&(c+=1)}return c}function aJ(a){if(!a||"object"!=typeof a)return null;let b=a.agentMeta;return b&&"object"==typeof b?b:null}var aK=c(97297);let aL=new Set(["cause","code","details","error","message","reason","stack","stderr","stdout","warning"]);async function aM(a,b=18){let c=a.runner.logPath?.trim();if(!c)return[];try{return(await (0,e.readFile)(c,"utf8")).split(/\r?\n/).map(a=>(function(a){let b=a.trim();if(!b)return null;try{var c;let a=JSON.parse(b);if(!a||"string"!=typeof a.id||"string"!=typeof a.timestamp||"string"!=typeof a.text||(c=a.stream,"status"!==c&&"stdout"!==c&&"stderr"!==c))return null;return{id:a.id,timestamp:a.timestamp,stream:a.stream,text:a.text}}catch{return null}})(a)).filter(a=>!!a).map(a=>{var b;let c;return b=a,(c=aN(b.text))?{...b,text:c}:null}).filter(a=>!!a).slice(-b)}catch{return[]}}function aN(a){let b=a.trim();if(!b||function(a){if(/^[\[\]{}(),]+$/.test(a))return!0;let b=a.match(/^"([^"]+)"\s*:\s*(.+?)(,)?$/);return b?!aL.has(b[1].toLowerCase()):(a.match(/^([A-Za-z0-9_.-]+)\s*:\s*(.+)$/),!1)}(b))return null;let c=b.match(/^"([^"]+)"\s*:\s*(.+?)(,)?$/);if(c){let[,a,b]=c;return aL.has(a.toLowerCase())?`${aO(a)}: ${aP(b)}`:null}let d=b.match(/^([A-Za-z0-9_.-]+)\s*:\s*(.+)$/);return d&&aL.has(d[1].toLowerCase())?`${aO(d[1])}: ${aP(d[2])}`:b}function aO(a){return a.charAt(0).toUpperCase()+a.slice(1)}function aP(a){let b=a.trim().replace(/,$/,"");if(!b)return"";try{let a=JSON.parse(b);if("string"==typeof a)return a;if("number"==typeof a||"boolean"==typeof a)return String(a)}catch{}return b.replace(/^"(.*)"$/,"$1")}var aQ=c(10636),aR=c(87076);async function aS(a,b,c){if(!b)return[];let d=(0,m.CK)(c.agents.find(b=>b.id===a.primaryAgentId)??{name:"OpenClaw"}),e=await aM(b),f=b.runner.logPath&&b.runner.logPath.trim()?{path:b.runner.logPath,displayPath:g().basename(b.runner.logPath)}:null,h=[aT({id:`${b.id}:accepted`,kind:"user",timestamp:b.submittedAt,title:"Mission accepted",detail:aX(a.mission||b.mission||"Mission queued for dispatch.",220),agentId:a.primaryAgentId},{urlSources:[a.mission,b.mission,b.routedMission]})];if((b.runner.startedAt||b.runner.pid)&&h.push(aT({id:`${b.id}:runner-started`,kind:"status",timestamp:b.runner.startedAt??b.updatedAt,title:"Dispatch runner started",detail:b.outputDirRelative?`Preparing the first OpenClaw runtime in ${b.outputDirRelative}.`:"Preparing the first OpenClaw runtime."},{file:b.outputDir&&b.outputDirRelative?{path:b.outputDir,displayPath:b.outputDirRelative}:null})),b.runner.lastHeartbeatAt&&(b.observation.observedAt||"completed"===b.status||h.push(aT({id:`${b.id}:heartbeat`,kind:"status",timestamp:b.runner.lastHeartbeatAt,title:"Heartbeat received",detail:`${d} is online. Waiting for the first runtime session.`},{urlSources:[d,b.outputDirRelative]}))),b.observation.observedAt&&"completed"!==b.status&&h.push(aT({id:`${b.id}:runtime-observed`,kind:"status",timestamp:b.observation.observedAt,title:"Runtime observed",detail:"The task is now live. Runtime updates will continue below."},{urlSources:[b.outputDirRelative]})),"completed"===b.status){let c="string"==typeof a.metadata.finalResponseText?a.metadata.finalResponseText.trim():"",d=(0,aK.Bx)(b)||(0,aK.v0)(b)||c,e=(0,aK.E_)(b);h.push(aT({id:`${b.id}:completed`,kind:"status",timestamp:b.runner.finishedAt??b.updatedAt,title:d?"Mission finished":"Dispatch runner finished",detail:aX(d||(0,aK.kc)(b),220)},{urlSources:[d,(0,aK.kc)(b),b.outputDirRelative],file:e??(b.outputDir&&b.outputDirRelative?{path:b.outputDir,displayPath:b.outputDirRelative}:null)}))}"cancelled"===b.status&&h.push(aT({id:`${b.id}:cancelled`,kind:"warning",timestamp:b.runner.finishedAt??b.updatedAt,title:"Mission cancelled",detail:aX((0,aK.kc)(b),220),isError:!1},{urlSources:[b.error,b.outputDirRelative],file:b.outputDir&&b.outputDirRelative?{path:b.outputDir,displayPath:b.outputDirRelative}:null}));let i=(0,aK.gv)(b);for(let c of(i&&h.push(aT({id:`${b.id}:integrity-warning`,kind:"warning",timestamp:b.runner.finishedAt??b.updatedAt,title:"Result needs review",detail:aX(i,220),isError:!0},{urlSources:[b.outputDirRelative],file:b.outputDir&&b.outputDirRelative?{path:b.outputDir,displayPath:b.outputDirRelative}:null})),"stalled"===b.status&&h.push(aT({id:`${b.id}:stalled`,kind:"warning",timestamp:b.updatedAt,title:b.error?"Dispatch error":"Dispatch stalled",detail:aX(b.error||(b.runner.lastHeartbeatAt?"OpenClaw stopped reporting progress while waiting for the first runtime.":"OpenClaw did not produce the first heartbeat in time."),220),isError:!0},{urlSources:[b.error,b.outputDirRelative]})),e)){let b=function(a){let b=aN(a.text);if(!b)return null;if("status"===a.stream)return{kind:"status",title:"Dispatch runner",detail:b,isError:!1};if("stdout"===a.stream)return{kind:"status",title:"Runner output",detail:b,isError:!1};let c=function(a){let b=a.trim().toLowerCase();return!(!b||b.includes("exited successfully")||b.includes("booted for agent")||b.includes("launched openclaw agent process"))&&/(aborted|denied|enoent|eacces|error|exception|failed|failure|invalid|killed|not found|panic|refused|stalled|timeout|timed out|traceback)/i.test(a)}(b);return{kind:c?"warning":"status",title:c?"Runner warning":"Runner note",detail:b,isError:c}}(c);b&&h.push(aT({id:c.id,kind:b.kind,timestamp:c.timestamp,title:b.title,detail:aX(b.detail,220),agentId:a.primaryAgentId,isError:b.isError},{file:f}))}return h}function aT(a,b){let c=function(a){for(let b of a){if("string"!=typeof b)continue;let a=b.match(/https?:\/\/[^\s<>"'`]+/i);if(!a)continue;let c=a[0].replace(/[)\].,;:!?]+$/g,"");if(c)return c}return null}(b?.urlSources??[]);return{...a,...c?{url:c}:{},...b?.file?{filePath:b.file.path,displayPath:b.file.displayPath}:{}}}function aU(a){return"available"===a.status||a.items.length>0||!!a.finalText?.trim()||a.createdFiles.length>0}function aV(a){return a.map(a=>(a??"").replace(/\s+/g," ").trim().toLowerCase()).join("|")}function aW(a){return"number"==typeof a&&Number.isFinite(a)?new Date(a).toISOString():new Date().toISOString()}function aX(a,b){let c=a.replace(/\s+/g," ").trim();return c.length<=b?c:`${c.slice(0,Math.max(b-1,1)).trimEnd()}…`}var aY=c(96476);async function aZ(a,b,c){let d=a.runtimeIds.map(a=>b.runtimes.find(b=>b.id===a)).filter(a=>!!a).sort(a0);return a_(a,d,b,c)}async function a$(a,b){let c=new Map(b.agents.map(a=>[a.id,(0,m.CK)(a)])),d=b.runtimes.filter(b=>(function(a,b){if(("string"==typeof a.metadata.dispatchId?a.metadata.dispatchId.trim():"")===b.id)return!0;let c=(0,aK.Xy)(b);return!!c&&a.sessionId===c&&a.agentId===b.agentId})(b,a)).sort(a0),e=d[0]??await (0,aY.DO)(a)??(0,aQ.Bi)(a,Date.now()),f=d.length>0?d:[e];return a_((0,aR.bE)(`dispatch:${a.id}`,f,c),f,b,a)}async function a_(a,b,c,d){var e,f,g,h;let i,j,k,l,n,o=await Promise.all(b.map(a=>(0,aB.pY)(a,c))),p=new Map(o.map(a=>[a.runtimeId,a])),q=(0,aR.T$)(o.flatMap(a=>a.createdFiles).concat(b.flatMap(a=>(0,aR.Y8)(a)))),r=Array.from(new Set(o.flatMap(a=>a.warnings).concat(b.flatMap(a=>(0,aR.qA)(a))).map(a=>a.trim()).filter(Boolean))),s=(e=d?(0,aK.Ck)(a,d):a,f=o,g=q,h=r,i=[...f].reverse().find(a=>a.finalText?.trim()||a.errorMessage?.trim())??null,k=(j=i?.finalText?.trim()||null)||("string"==typeof e.metadata.resultPreview?e.metadata.resultPreview.trim():"")||e.subtitle,l=f.filter(a=>a.items.length>0).length,{...e,subtitle:j?(n=j.replace(/\s+/g," ").trim()).length<=160?n:`${n.slice(0,Math.max(159,1)).trimEnd()}…`:e.subtitle,artifactCount:g.length,warningCount:h.length,metadata:{...e.metadata,resultPreview:k,turnCount:l||e.metadata.turnCount,finalResponseText:j,finalResponseRuntimeId:i?.runtimeId??null}}),t=await aS(s,d,c),u=function(a,b,c,d){let e=new Map(d.agents.map(a=>[a.id,(0,m.CK)(a)])),f=[],g=[...b].sort((a,b)=>(a.updatedAt??0)-(b.updatedAt??0)),h=Array.from(c.values()).some(aU),i=new Set,j=new Set,k=new Set,l=new Set;for(let b of g){var n,o,p,q;if(a.dispatchId&&(0,aQ.U8)(b))continue;let d=c.get(b.id),g=b.agentId?e.get(b.agentId)??null:null,m=(n=b,(o=d?.finalTimestamp)||aW(n.updatedAt));if(d?.items.length)for(let a of d.items){let c=aX(a.text.trim()||d.errorMessage||b.subtitle,220),e=aV(["item",a.role,a.toolName??"",a.timestamp,c]);i.has(e)||(i.add(e),f.push(aT({id:`${b.id}:${a.id}`,kind:"assistant"===a.role?"assistant":"toolCall"===a.role||"toolResult"===a.role?"tool":"user",timestamp:a.timestamp,title:"assistant"===a.role?g||"Agent update":"toolCall"===a.role||"toolResult"===a.role?a.toolName?`Tool \xb7 ${a.toolName}`:"Tool update":"Mission",detail:c,runtimeId:b.id,agentId:b.agentId,toolName:a.toolName,isError:a.isError},{urlSources:[a.text,d?.finalText,d?.errorMessage,b.subtitle]})))}else{let a=aX(d?.errorMessage||b.subtitle,220);if(h&&(p=d,q=a,p?.status==="missing"||/No transcript file was found for this runtime session/i.test(q)))continue;let c=aV(["status",b.status,a]);if(j.has(c))continue;j.add(c),f.push(aT({id:`${b.id}:status`,kind:"status",timestamp:m,title:g?`${g} \xb7 ${b.status}`:`Run \xb7 ${b.status}`,detail:a,runtimeId:b.id,agentId:b.agentId,isError:"stalled"===b.status},{urlSources:[d?.errorMessage,b.subtitle]}))}for(let a of Array.from(new Set((d?.warnings??[]).concat((0,aR.qA)(b)).map(a=>a.trim()).filter(Boolean)))){let c=aV(["warning",a]);k.has(c)||(k.add(c),f.push(aT({id:`${b.id}:warning:${(0,aR.vC)(a)}`,kind:"warning",timestamp:m,title:"Fallback",detail:aX(a,220),runtimeId:b.id,agentId:b.agentId},{urlSources:[a]})))}for(let a of function(a){let b=new Set,c=[];for(let d of a)!d.path||b.has(d.path)||(b.add(d.path),c.push(d));return c}((d?.createdFiles??[]).concat((0,aR.Y8)(b))))l.has(a.path)||(l.add(a.path),f.push(aT({id:`${b.id}:artifact:${(0,aR.vC)(a.path)}`,kind:"artifact",timestamp:m,title:"Created file",detail:a.displayPath,runtimeId:b.id,agentId:b.agentId},{file:a})))}return 0===f.length&&a.mission&&!a.dispatchId&&f.push(aT({id:`${a.id}:mission`,kind:"user",timestamp:aW(a.updatedAt),title:"Mission",detail:aX(a.mission,220),agentId:a.primaryAgentId},{urlSources:[a.mission]})),f.sort((a,b)=>Date.parse(a.timestamp)-Date.parse(b.timestamp)).slice(-36)}(s,b,p,c),v=await aE({task:s,runs:b,outputs:o,createdFiles:q,dispatchRecord:d,snapshot:c});return{task:s,runs:b,outputs:o,liveFeed:function(...a){let b=new Map;for(let c of a.flat())b.set(c.id,c);return[...b.values()].sort((a,b)=>Date.parse(a.timestamp)-Date.parse(b.timestamp)).slice(-48)}(t,u),createdFiles:q,warnings:r,integrity:v}}function a0(a,b){return(b.updatedAt??0)-(a.updatedAt??0)}var a1=c(31474),a2=c(42088),a3=c(62712),a4=c(62596),a5=c(12844);function a6(){(0,d.ZZ)()}function a7(){(0,d.b7)()}async function a8(a,b){let c=await (0,a5.t)(a4.wh,a?[a]:[],{agentDirs:a?{[a]:b}:void 0,touch:!0});if(c.issues.length>0)throw a6(),Error(`OpenClaw runtime state is not writable. AgentOS needs write access to ${c.stateRoot} and the agent session store before missions can run.`)}async function a9(a={}){await a8(a.agentId??null,a.agentDir),a6()}async function ba(a={}){var b;let c=await (0,d.GM)({force:!0,includeHidden:!0}),e=(b=a.agentId)&&c.agents.some(a=>a.id===b)?b:c.agents.find(a=>a.isDefault)?.id||c.agents[0]?.id||null;if(!e)return{status:"not-run",checkedAt:null,agentId:null,runId:null,summary:null,error:"AgentOS could not find an OpenClaw agent for the runtime smoke test."};let f=await (0,a1.tl)(),g=(0,a1.Yt)(f,e);if(!a.force&&(0,a1.SK)(g))return(0,a1.Az)(e,g);let h=c.agents.find(a=>a.id===e);await a8(e,h?.agentDir);try{await (0,ay.o)({agentId:e,modelId:h?.modelId,agentDir:h?.agentDir});let a=await (0,k.rw)().runAgentTurn({agentId:e,message:"AgentOS runtime smoke test. Reply with a brief READY status.",thinking:"off",timeoutSeconds:45},{timeoutMs:5e4}),b={status:"passed",checkedAt:new Date().toISOString(),agentId:e,runId:a.runId??null,summary:a.summary||(0,aK.Ym)(a)[0]?.text||"AgentOS verified a real OpenClaw turn.",error:null};return await (0,a1.go)(b),a6(),b}catch(d){let a=(0,az.t)(d)||"OpenClaw runtime smoke test failed.",b=(0,a2.YG)(a)?(0,a2.ox)((0,a2.MF)(await (0,a3.XP)().catch(()=>"openclaw"))):a,c={status:"failed",checkedAt:new Date().toISOString(),agentId:e,runId:null,summary:null,error:b};return await (0,a1.go)(c),a6(),c}}async function bb(a){let b=await (0,d.GM)({includeHidden:!0}),c=b.runtimes.find(b=>b.id===a);return(c||(c=(b=await (0,d.GM)({force:!0,includeHidden:!0})).runtimes.find(b=>b.id===a)),c)?(0,aB.pY)(c,b):{runtimeId:a,status:"missing",finalText:null,finalTimestamp:null,stopReason:null,errorMessage:"Runtime was not found in the current OpenClaw snapshot.",items:[],createdFiles:[],warnings:[],warningSummary:null}}async function bc(a,b={}){let c=await (0,d.GM)({includeHidden:!0}),e=c.tasks.find(b=>b.id===a);if(!e&&b.dispatchId&&(e=c.tasks.find(a=>a.dispatchId===b.dispatchId)),!e&&((e=(c=await (0,d.GM)({force:!0,includeHidden:!0})).tasks.find(b=>b.id===a))||!b.dispatchId||(e=c.tasks.find(a=>a.dispatchId===b.dispatchId))),!e){let a="string"==typeof b.dispatchId?b.dispatchId.trim():"";if(a){let b=await (0,aY.O1)(a);if(b)return a$(b,c)}throw Error("Task was not found in the current OpenClaw snapshot.")}let f=e.dispatchId?await (0,aY.O1)(e.dispatchId):null;return aZ(e,c,f)}var bd=c(39463),be=c(49662);function bf(){(0,d.ZZ)()}async function bg(a,b={}){var c,e;let f,j,k,l=function(a){let b=a.name.trim();if(!b)throw Error("Workspace name is required.");let c=x(b);if(!c)throw Error("Workspace name must include letters or numbers.");let d=a.template??"software",e=a.teamPreset??"core",f=a.sourceMode??"empty",g=a.modelProfile??"balanced",j={...r.eY,...a.rules??{}},k=(a.agents?.length?a.agents:(0,r.P0)(d,e,b)).map(a=>{let c=w(a),d=a.policy?.preset??(0,h.qF)({skills:c,id:a.id,name:a.name});return{id:x(a.id)||"agent",role:a.role.trim()||R(a.id),name:u(a.name)??(a.isPrimary?(0,r.sg)(b,a.role,R(a.id)):R(a.id)),enabled:!1!==a.enabled,emoji:u(a.emoji)??void 0,theme:u(a.theme)??void 0,skillId:c[0]??void 0,skillIds:c,modelId:u(a.modelId)??void 0,isPrimary:!!a.isPrimary,heartbeat:i(d,a.heartbeat),policy:(0,h.g0)(d,{...a.policy,fileAccess:j.workspaceOnly?a.policy?.fileAccess??"workspace-only":"extended"})}});if(!k.some(a=>a.enabled&&a.isPrimary)){let a=k.find(a=>a.enabled);a&&(a.isPrimary=!0)}let l=function(a){let b=new Set,c=new Set;for(let d of a){if(b.has(d)){c.add(d);continue}b.add(d)}return Array.from(c).sort((a,b)=>a.localeCompare(b))}(k.filter(a=>a.enabled).map(a=>a.id));if(l.length>0)throw Error(`Enabled agents must have unique ids. Conflicts: ${l.join(", ")}.`);return{name:b,slug:c,brief:u(a.brief)??void 0,directory:u(a.directory)??void 0,modelId:u(a.modelId)??void 0,repoUrl:u(a.repoUrl)??void 0,existingPath:u(a.existingPath)??void 0,sourceMode:f,template:d,teamPreset:e,modelProfile:g,rules:j,docOverrides:(0,q.Iy)(a.docOverrides),agents:k,contextSources:(a.contextSources??[]).flatMap(a=>{var b;if(!a||"object"!=typeof a)return[];let c="prompt"===(b=a.kind)||"website"===b||"repo"===b||"folder"===b?a.kind:"prompt",d=u(a.label)??c,e=u(a.summary)??d,f="error"===a.status?"error":"ready",g=u(a.createdAt)??new Date().toISOString();if(!d||!e)return[];let h={id:u(a.id)??`${c}-${x(d)||"context"}`,kind:c,label:d,summary:e,details:Array.isArray(a.details)?a.details.map(a=>u(a)??"").filter(a=>!!a):[],status:f,createdAt:g},i="number"==typeof a.confidence?a.confidence:void 0,j=u(a.error)??void 0,k=u(a.url)??void 0;return void 0!==i&&(h.confidence=i),void 0!==j&&(h.error=j),void 0!==k&&(h.url=k),[h]})}}(a),m=l.agents.filter(a=>a.enabled),n=(0,bd.X6)({template:(0,bd.fV)({sourceMode:l.sourceMode,agentCount:m.length,kickoffMission:l.rules.kickoffMission}),onProgress:b.onProgress});if(0===m.length)throw Error("Enable at least one agent for the workspace.");await n.startStep("validate","Resolving workspace settings and reserving the target directory."),await n.addActivity("validate",`Validated workspace name "${l.name}".`);let o=await function(a,b){if("existing"===a.sourceMode){let b=a.existingPath||a.directory;if(!b)throw Error("Choose an existing folder for this workspace.");return g().isAbsolute(b)?b:g().resolve(b)}return a.directory?g().isAbsolute(a.directory)?a.directory:g().join(b,a.directory):g().join(b,a.slug)}(l,await (0,a1.wL)()||g().join(av().homedir(),"Documents","Shared","projects"));await n.updateStep("validate",{percent:38,detail:`Reserved target directory at ${o}.`}),await n.addActivity("validate",`Reserved target directory ${o}.`,"done");let p=await (0,d.GM)({force:!0,includeHidden:!0});await n.updateStep("validate",{percent:72,detail:"Checking current OpenClaw snapshot and agent ids."}),function(a,b,c){let d=c.map(a=>X(b,a.id)),e=function(a){let b=new Set,c=new Set;for(let d of a){if(b.has(d)){c.add(d);continue}b.add(d)}return Array.from(c).sort((a,b)=>a.localeCompare(b))}(d);if(e.length>0)throw Error(`Workspace bootstrap would create duplicate agent ids: ${e.join(", ")}.`);for(let b of d){let c=a.agents.find(a=>a.id===b);if(c)throw Error(`Workspace bootstrap would create agent id "${b}", but it already exists in workspace "${function(a,b){return a.workspaces.find(a=>a.id===b.workspaceId)?.name??g().basename(b.workspacePath)}(a,c)}". Rename the workspace or adjust the agent ids.`)}}(p,l.slug,m),await n.completeStep("validate",`Workspace input and ${m.length} agent configuration${1===m.length?"":"s"} are ready.`);let t=await bt(o,p,l.slug);if(t)return await n.startStep("source",O(l.sourceMode,o)),await n.addActivity("source","Workspace already exists. Reusing the existing folder.","done"),await n.completeStep("source","Existing workspace folder reused."),await n.startStep("scaffold","Writing the initial workspace scaffold and local metadata."),await n.addActivity("scaffold","Workspace scaffold already exists. Reusing existing files.","done"),await n.completeStep("scaffold","Workspace files and starter docs are already in place."),await n.startStep("agents",1===t.agentIds.length?"Reusing the existing workspace agent.":`Reusing ${t.agentIds.length} workspace agents.`),await n.addActivity("agents",`${t.agentIds.length} agent${1===t.agentIds.length?"":"s"} already linked to the workspace.`,"done"),await n.completeStep("agents",`${t.agentIds.length} agent${1===t.agentIds.length?"":"s"} already linked to the workspace.`),await n.startStep("kickoff","Finalizing workspace bootstrap."),await n.addActivity("kickoff","Kickoff was already handled by the existing workspace.","done"),await n.completeStep("kickoff","Workspace bootstrap is already complete."),bf(),a7(),t;await n.startStep("source",O(l.sourceMode,o)),await n.addActivity("source",(c=l.sourceMode,"clone"===c?l.repoUrl?`Cloning ${l.repoUrl}.`:"Cloning the requested repository.":"existing"===c?l.existingPath?`Attaching ${l.existingPath}.`:"Attaching the requested folder.":"Preparing an empty workspace scaffold."),"active"),await M({targetDir:o,sourceMode:l.sourceMode,repoUrl:l.repoUrl}),await n.completeStep("source",(e=l.sourceMode,"clone"===e?`Repository content is available at ${o}.`:"existing"===e?`Existing folder linked and ready at ${o}.`:`Fresh workspace folder created at ${o}.`)),await n.startStep("scaffold","Writing the initial workspace scaffold and local metadata."),await n.addActivity("scaffold","Generating workspace docs, memory, and configuration files."),await N(o,{name:l.name,brief:l.brief,template:l.template,teamPreset:l.teamPreset,modelProfile:l.modelProfile,rules:l.rules,docOverrides:l.docOverrides,sourceMode:l.sourceMode,agents:m,contextSources:l.contextSources}),await n.completeStep("scaffold","Workspace files and starter docs are in place.");let v=[],y=l.modelId??function(a){if(a.diagnostics.modelReadiness.defaultModelReady)return(0,ae.Nk)(a.diagnostics.modelReadiness.resolvedDefaultModel)??(0,ae.Nk)(a.diagnostics.modelReadiness.defaultModel)??void 0}(await (0,d.GM)({includeHidden:!0}));for(let a of(await n.startStep("agents",1===m.length?"Provisioning the first workspace agent.":`Provisioning ${m.length} workspace agents.`),m)){let b=v.length,c=b+1;await n.updateStep("agents",{percent:Math.round(b/m.length*100),detail:`Creating agent ${c} of ${m.length}: ${a.name}.`}),await n.addActivity("agents",`Creating ${a.name} (${a.role}).`);let d=await Y({workspacePath:o,workspaceSlug:l.slug,workspaceModelId:y,agent:a});v.push(d),await n.addActivity("agents",`Created ${a.name} as ${d}.`,"done"),await n.updateStep("agents",{percent:Math.round(v.length/m.length*100),detail:`${v.length} of ${m.length} agent${1===m.length?"":"s"} ready.`})}await n.completeStep("agents",`${v.length} agent${1===v.length?"":"s"} linked to the workspace.`),bf(),await bv(o),await (0,s.u)(o);let z=v.find(a=>m.some(b=>b.isPrimary&&X(l.slug,b.id)===a))??v[0];if(l.rules.kickoffMission){await n.startStep("kickoff",`Dispatching the kickoff mission to ${z}.`),await n.addActivity("kickoff",`Selected ${z} as the primary agent.`);try{let a=await bw({agentId:z,brief:l.brief,modelProfile:l.modelProfile,template:l.template,rules:l.rules},{onProgress:async({message:a,percent:b})=>{await n.updateStep("kickoff",{percent:b,detail:a}),await n.addActivity("kickoff",a,b>=100?"done":"active")}});f=a.runId,j=a.status,await n.completeStep("kickoff",`Kickoff mission finished with status ${j||"unknown"}.`)}catch(a){k=a instanceof Error?a.message:"Kickoff mission could not be started.",await n.addActivity("kickoff",k,"error"),await n.failStep("kickoff",k)}}else await n.startStep("kickoff","Finalizing workspace bootstrap."),await n.addActivity("kickoff","Kickoff mission is disabled for this workspace.","done"),await n.completeStep("kickoff","Workspace bootstrap finished without kickoff.");return bf(),a7(),{workspaceId:bp(p.workspaces,o),workspacePath:o,agentIds:v,primaryAgentId:z,kickoffRunId:f,kickoffStatus:j,kickoffError:k}}async function bh(a){let b=a.workspaceId.trim();if(!b)throw Error("Workspace id is required.");if(a.plan){let c=a.baseline??await bj(b);return bn((0,be.co)(c),a.plan,{name:a.name,directory:a.directory,baseline:c})}let c=await (0,d.GM)({force:!0}),f=bo(c.workspaces,b);if(!f)throw Error("Workspace was not found.");let h=bs(f.path,a.name,a.directory);if(h!==f.path){await br(h,f.path);try{await (0,e.rename)(f.path,h)}catch(a){throw Error(a instanceof Error?`Unable to move workspace directory. ${a.message}`:"Unable to move workspace directory.")}let a=(await (0,l.CI)(c)).map(a=>a.workspace===f.path?{...a,workspace:h,agentDir:"string"==typeof a.agentDir&&a.agentDir.startsWith(`${f.path}${g().sep}`)?g().join(h,g().relative(f.path,a.agentDir)):a.agentDir}:a);await (0,l.ZF)(a)}return bf(),a7(),{workspaceId:bp(c.workspaces,h,f.path),previousWorkspaceId:f.id,workspacePath:h}}async function bi(a){let b=a.workspaceId.trim();if(!b)throw Error("Workspace id is required.");let c=await (0,d.GM)({force:!0,includeHidden:!0}),f=bo(c.workspaces,b);if(!f)throw Error("Workspace was not found.");let g=c.agents.filter(a=>a.workspaceId===f.id),h=c.runtimes.filter(a=>a.workspaceId===f.id).length;for(let a of g)await (0,k.rw)().deleteAgent(a.id);try{let a=await (0,l.CI)(c),b=a.filter(a=>a.workspace!==f.path&&!g.some(b=>b.id===a.id));b.length!==a.length&&await (0,l.ZF)(b)}catch{}return await (0,e.rm)(f.path,{recursive:!0,force:!0}),(0,d.er)(),{workspaceId:f.id,workspacePath:f.path,deletedAgentIds:g.map(a=>a.id),deletedRuntimeCount:h}}async function bj(a){let b=await (0,d.GM)({force:!0,includeHidden:!0}),c=bo(b.workspaces,a);if(!c)throw Error("Workspace was not found.");let f=await (0,S.OL)(c.path),i=f.name??c.name,j=b.agents.filter(a=>a.workspaceId===c.id),k=bl(j.flatMap(a=>a.skills)),l=bl(j.flatMap(a=>a.tools)),m=f.template??c.bootstrap.template??"software",n=f.sourceMode??c.bootstrap.sourceMode??"empty",o=f.teamPreset??(j.length<=1?"solo":"core"),p=f.modelProfile??"balanced",s=f.rules??r.eY,t=await (0,ax.xL)(c.path,f.template,f.rules??r.eY),u=await (0,aw.L)(c.path,{agentId:j[0]?.id??c.id,agentName:j[0]?.name??i,configuredSkills:k,configuredTools:l,template:m,rules:s,workspaceBootstrapProfile:t}),v=f.agents.length>0?f.agents.map(a=>{let b=bk(j,c.slug,a.id),d=(0,h.g0)(a.policy?.preset??b?.policy.preset??h.iN,a.policy??b?.policy);return{id:a.id,role:a.role??(0,h._P)(d.preset),name:a.name??b?.name??a.role??a.id,enabled:a.enabled,emoji:a.emoji??b?.identity.emoji,theme:a.theme??b?.identity.theme,skillId:a.skillId??void 0,modelId:a.modelId??(b?.modelId&&"unassigned"!==b.modelId?b.modelId:void 0),isPrimary:a.isPrimary,policy:d,channelIds:a.channelIds??[],heartbeat:{enabled:b?.heartbeat.enabled??!1,...b?.heartbeat.every?{every:b.heartbeat.every}:{}}}}):(0,r.P0)(m,o,i),w=(0,q.Q5)({name:i,brief:u.purpose||i,template:m,sourceMode:n,rules:s,agents:v,toolExamples:await J(c.path),docOverrides:[],contextSources:f.contextSources??[]}),x=[],y=new Set(w.map(a=>a.path)),z=await (0,be.wZ)(c.path);for(let a of w){let b=g().join(c.path,a.path);try{let c=await (0,e.readFile)(b,"utf8");c!==a.baseContent&&x.push({path:a.path,content:c})}catch{continue}}for(let a of z){if(y.has(a))continue;let b=g().join(c.path,a);try{let c=await (0,e.readFile)(b,"utf8");x.push({path:a,content:c})}catch{continue}}return{workspaceId:c.id,workspacePath:c.path,name:i,directory:c.path,template:m,sourceMode:n,teamPreset:o,modelProfile:p,modelId:c.modelIds[0]&&"unassigned"!==c.modelIds[0]?c.modelIds[0]:void 0,rules:s,docOverrides:x,agents:v,brief:u.purpose||i,contextSources:f.contextSources??[]}}function bk(a,b,c){let d=bm(c),e=`${b}-`;return a.find(a=>{var d,e;return a.id===(d=b,e=c,`${d}-${bm(e)||"agent"}`)})??a.find(a=>a.id===`${e}${d}`)??a.find(a=>d.length>0&&a.id.endsWith(`-${d}`))??a.find(a=>a.id===d)??null}function bl(a){return Array.from(new Set(a.filter(Boolean)))}function bm(a){return a.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}async function bn(a,b,c){let f=(0,ae.Nk)(c.name)??(0,ae.Nk)(b.workspace.name)??a.name,h=(0,ae.Nk)(c.directory),i=(0,ae.Nk)(c.baseline.directory)??a.path,j=(0,ae.Nk)(c.baseline.name)??a.name,k=(0,ae.Nk)(c.baseline.brief)??"",m=(0,ae.Nk)(b.company.mission)??(0,ae.Nk)(b.product.offer)??"",n=(0,q.Iy)(b.workspace.docOverrides),o=(0,q.Iy)(c.baseline.docOverrides),p=new Map(n.map(a=>[a.path,a.content])),t=new Map(o.map(a=>[a.path,a.content])),u=b.team.persistentAgents.filter(a=>a.enabled),v=c.baseline.agents.filter(a=>a.enabled),w=f.trim()!==j.trim(),x=w||m!==k||b.workspace.template!==c.baseline.template||b.workspace.sourceMode!==c.baseline.sourceMode||!(0,be.Rp)(b.workspace.rules,c.baseline.rules)||!(0,be.cD)(u,v),y=h&&h!==i?bs(a.path,void 0,h):w?bs(a.path,f,void 0):a.path,z=y!==a.path,A=z?await (0,d.GM)({force:!0,includeHidden:!0}):null;if(z){await br(y,a.path);try{await (0,e.rename)(a.path,y)}catch(a){throw Error(a instanceof Error?`Unable to move workspace directory. ${a.message}`:"Unable to move workspace directory.")}let b=(await (0,l.CI)(A??void 0)).map(b=>b.workspace===a.path?{...b,workspace:y,agentDir:"string"==typeof b.agentDir&&b.agentDir.startsWith(`${a.path}${g().sep}`)?g().join(y,g().relative(a.path,b.agentDir)):b.agentDir}:b);await (0,l.ZF)(b)}let C=g().join(y,".openclaw","project.json"),D=new Date().toISOString(),E=!1,F=null;try{var G;let a=await (0,e.readFile)(C,"utf8"),b=JSON.parse(a);G=b,"object"!=typeof G||null===G||Array.isArray(G)||(D="string"==typeof b.createdAt?b.createdAt:D,E=!0===b.hidden,F="string"==typeof b.systemTag?b.systemTag:null)}catch{}let H=b.team.persistentAgents.map(a=>({id:a.id,name:a.name,role:a.role,enabled:a.enabled,emoji:(0,ae.Nk)(a.emoji)??null,theme:(0,ae.Nk)(a.theme)??null,isPrimary:!!a.isPrimary,skillId:(0,ae.Nk)(a.skillId)??null,modelId:(0,ae.Nk)(a.modelId)??null,policy:a.policy??null,channelIds:Array.from(new Set((a.channelIds??[]).map(a=>"string"==typeof a?a.trim():"").filter(a=>!!a)))})),I=H.length<=1?"solo":H.every(a=>a.enabled)?"core":"custom",K={version:1,slug:bm(g().basename(y)),name:f,directory:y,icon:(0,r.hh)(b.workspace.template).icon,createdAt:D,updatedAt:new Date().toISOString(),template:b.workspace.template,sourceMode:b.workspace.sourceMode,teamPreset:I,modelProfile:b.workspace.modelProfile,agentTemplate:"solo"===I?"solo":"core-team",rules:{workspaceOnly:b.workspace.rules.workspaceOnly,generateStarterDocs:b.workspace.rules.generateStarterDocs,generateMemory:b.workspace.rules.generateMemory,kickoffMission:b.workspace.rules.kickoffMission},contextSources:b.intake.sources,hidden:E,systemTag:F,agents:H};if(x){let a=(0,q.Q5)({name:f,brief:m||f,template:b.workspace.template,sourceMode:b.workspace.sourceMode,rules:b.workspace.rules,agents:u,toolExamples:await J(y),docOverrides:n,contextSources:b.intake.sources}),c=new Set(a.map(a=>a.path));for(let b of a)await B(g().join(y,b.path),b.content);for(let a of n)c.has(a.path)||await B(g().join(y,a.path),a.content)}else{let a=(0,q.Q5)({name:j,brief:k||j,template:c.baseline.template,sourceMode:c.baseline.sourceMode,rules:c.baseline.rules,agents:v,toolExamples:[],docOverrides:[],contextSources:c.baseline.contextSources??[]}),b=new Set(a.map(a=>a.path));for(let a of n)t.get(a.path)!==a.content&&await B(g().join(y,a.path),a.content);for(let c of o){if(p.has(c.path))continue;let d=a.find(a=>a.path===c.path);d&&b.has(d.path)&&await B(g().join(y,d.path),d.baseContent)}}if(z||!(0,be.cD)(u,v)){let d=z?bp(A?.workspaces??[],y,a.path):a.id,e={...a,id:d,path:y};await bq({currentWorkspace:e,desiredAgents:b.team.persistentAgents,workspaceSlug:bm(g().basename(y)),previousWorkspaceId:c.baseline.workspaceId,previousWorkspacePath:c.baseline.workspacePath})}return await B(C,`${JSON.stringify(K,null,2)}
|
|
250
|
+
`),await (0,s.u)(y),bf(),a7(),{workspaceId:z?bp(A?.workspaces??[],y,a.path):a.id,previousWorkspaceId:a.id,workspacePath:y}}function bo(a,b){return a.find(a=>a.id===b)??a.find(a=>(0,af.xV)(a.path,b))}function bp(a,b,c){let d=c?g().resolve(c):null,e=[...a.map(a=>a.path).filter(a=>!d||g().resolve(a)!==d),b];return(0,af.hv)(b,e)}async function bq(a){let b=Array.from(new Map((await (0,d.GM)({force:!0,includeHidden:!0})).agents.filter(b=>b.workspaceId===a.currentWorkspace.id||!!a.previousWorkspaceId&&b.workspaceId===a.previousWorkspaceId||!!(a.previousWorkspacePath&&b.workspacePath===a.previousWorkspacePath)).map(a=>[a.id,a])).values()),c=new Set;for(let d of a.desiredAgents){let e=bk(b,a.workspaceSlug,d.id);if(!d.enabled){e&&(c.add(e.id),await aj({agentId:e.id}));continue}if(e){c.add(e.id),await ai({id:e.id,workspaceId:a.currentWorkspace.id,workspacePath:a.currentWorkspace.path,name:(0,ae.Nk)(d.name)??e.name,emoji:(0,ae.Nk)(d.emoji)??e.identity.emoji,theme:(0,ae.Nk)(d.theme)??e.identity.theme,modelId:(0,ae.Nk)(d.modelId)??("unassigned"===e.modelId?void 0:e.modelId),policy:d.policy,heartbeat:d.heartbeat,channelIds:d.channelIds});continue}let f=await ah({id:X(a.workspaceSlug,d.id),workspaceId:a.currentWorkspace.id,workspacePath:a.currentWorkspace.path,name:(0,ae.Nk)(d.name)??void 0,emoji:(0,ae.Nk)(d.emoji)??void 0,theme:(0,ae.Nk)(d.theme)??void 0,modelId:(0,ae.Nk)(d.modelId)??void 0,policy:d.policy,heartbeat:d.heartbeat,channelIds:d.channelIds});c.add(f.agentId)}for(let a of b)c.has(a.id)||await aj({agentId:a.id})}async function br(a,b){if(a!==b)try{throw await (0,e.access)(a),Error("Target workspace directory already exists.")}catch(a){if("ENOENT"===("object"==typeof a&&a&&"code"in a?a.code:void 0))return;if(a instanceof Error)throw a;throw Error("Unable to verify target workspace directory.")}}function bs(a,b,c){let d=(0,ae.Nk)(c);if(d)return g().isAbsolute(d)?d:g().join(g().dirname(a),d);let e=(0,ae.Nk)(b);if(!e)return a;let f=bm(e);if(!f)throw Error("Workspace name is required.");return g().join(g().dirname(a),f)}async function bt(a,b,c){let d=await (0,S.OL)(a),e=d.agents.filter(a=>a.enabled);if(!(d.name||d.template||d.sourceMode||d.agentTemplate||e.length>0||d.channels.length>0||d.contextSources.length>0))return null;let f=bp(b.workspaces,a),h=bo(b.workspaces,f)??b.workspaces.find(b=>g().resolve(b.path)===g().resolve(a))??null,i=h?.id??f,j=b.agents.filter(b=>b.workspaceId===i||g().resolve(b.workspacePath)===g().resolve(a)),k=new Set(j.map(a=>a.id)),l=e.map(a=>bu(c,a)),m=[];for(let b of l){if(k.has(b.agentId))continue;let d=await Y({workspacePath:a,workspaceSlug:c,workspaceModelId:b.agent.modelId,agent:b.agent});m.push(d),k.add(d)}let n=bl(l.map(a=>a.agentId)),o=bl([...j.map(a=>a.id),...m,...n]);if(0===o.length)return null;let p=d.agents.find(a=>a.enabled&&a.isPrimary)??null,q=p?bu(c,p):null,r=j[0]?.id??q?.agentId??o[0];return{workspaceId:h?.id??i,workspacePath:h?.path??a,agentIds:o,primaryAgentId:r,kickoffRunId:void 0,kickoffStatus:void 0,kickoffError:void 0}}function bu(a,b){let c=`${a}-`,d=(b.id.startsWith(c)?b.id.slice(c.length):b.id)||b.id;return{agentId:b.id.startsWith(c)?b.id:X(a,b.id),agent:{id:d,name:b.name??d,role:b.role??"Agent",enabled:b.enabled,emoji:b.emoji??void 0,theme:b.theme??void 0,skillId:b.skillId??void 0,skillIds:b.skillIds,modelId:b.modelId??void 0,isPrimary:b.isPrimary,policy:b.policy??void 0,channelIds:b.channelIds}}}async function bv(a){let b=await (0,d.GM)({includeHidden:!0});for(let c of bl(b.agents.filter(b=>b.workspacePath===a).map(a=>a.id))){let a=b.agents.find(a=>a.id===c);if(!a)continue;let d=b.agents.find(b=>b.workspaceId===a.workspaceId&&"setup"===b.policy.preset&&b.id!==a.id)?.id??null,e=await Z({workspacePath:a.workspacePath,agentId:a.id,agentName:a.name,policy:a.policy,setupAgentId:d,snapshot:b});await (0,l.jq)(a.id,a.workspacePath,{name:a.name,model:(0,ae.Nk)(a.modelId),heartbeat:a.heartbeat.enabled&&a.heartbeat.every?{every:a.heartbeat.every}:null,skills:[...(0,l.AB)(a.skills),e],tools:a.tools.includes("fs.workspaceOnly")?{fs:{workspaceOnly:!0}}:null},b)}}async function bw(a,b={}){var c,d,e;let f,g,h=(c=a.template,d=a.brief,e=a.rules,f=(0,r.hh)(c),g=(0,q.Q4)(c,e).sections.map(a=>{let b=a.resources.map(a=>a.label).join(", ");return a.enabled?`${a.title}: ${b||"none"}`:`${a.title}: disabled by workspace rules`}).join("\n"),[`You are bootstrapping a newly created ${f.label.toLowerCase()} workspace.`,d?`Project brief: ${d}`:"No detailed project brief was provided yet.","Inspect the current files and improve the starter workspace without rewriting files that already had meaningful content.","Treat the following workspace context manifest as the source of truth:",g,"If those docs exist, refine the brief, architecture, memory, and deliverables guidance based on the real repository state instead of guessing.","Leave the workspace with a concise first task batch and any critical unknowns clearly called out.","Prefer concrete workspace-grounded edits over verbose chat output."].join("\n\n")),i="fast"===a.modelProfile?"low":"quality"===a.modelProfile?"high":"medium",j=new Set;await b.onProgress?.({message:"Submitting the kickoff brief to the primary agent.",percent:18});let l=await (0,k.rw)().streamAgentTurn({agentId:a.agentId,message:h,thinking:i,timeoutSeconds:90},{onStdout:async a=>{let c,d=(c=a.replace(/\u001b\[[0-?]*[ -/]*[@-~]/g,"").trim())?Array.from(new Set(c.split(/\r?\n/).map(a=>a.trim()).filter(Boolean).map(a=>a.replace(/^[>•*-]\s*/,"")).filter(a=>!a.startsWith("{")&&!a.startsWith("[")).filter(a=>!/auth-profiles/i.test(a)))).slice(0,3):[];if(0===d.length&&a.trim())return void await b.onProgress?.({message:"Primary agent responded. Finalizing kickoff output.",percent:82});for(let a of d)await b.onProgress?.({message:a,percent:72})},onStderr:async a=>{let c=a.trim();if(!c)return;let d=function(a){let b,c=a.replace(/\u001b\[[0-?]*[ -/]*[@-~]/g,"").split(/\r?\n/).map(a=>a.trim()).filter(Boolean).join(" ");if(!c)return null;let d=c.toLowerCase();return d.includes("scope upgrade pending approval")||d.includes("pairing required")||d.includes("more scopes than currently approved")?"Gateway permissions need approval; continuing with the embedded runtime.":d.includes("falling back to embedded")?"Gateway agent is unavailable; continuing with the embedded runtime.":d.includes("gateway connect failed")?"Gateway connection is not ready; continuing with the embedded runtime.":`Runtime notice: ${(b=c.replace(/\(requestId:\s*[^)]+\)/gi,"").replace(/\brequestId:\s*\S+/gi,"").replace(/\s+/g," ").trim()).length>160?`${b.slice(0,157).trim()}...`:b}`}(c);!d||j.has(d)||(j.add(d),await b.onProgress?.({message:d,percent:64}))}},{timeoutMs:12e4});return await b.onProgress?.({message:"Kickoff mission completed. Recording the resulting run metadata.",percent:100}),l}function bx(a){return a.split(g().sep).join("/")}async function by(a,b){var c;let d,f,h,i=(c=b,f=[(d=new Date).getFullYear(),String(d.getMonth()+1).padStart(2,"0"),String(d.getDate()).padStart(2,"0"),String(d.getHours()).padStart(2,"0"),String(d.getMinutes()).padStart(2,"0"),String(d.getSeconds()).padStart(2,"0")].join("-"),h=c.replace(/^\[[^\]]+\]\s*/i,"").trim().normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48).replace(/^-+|-+$/g,"")||"task",`${f}-${h}`),j=g().join(a,"deliverables",i),k=bx(g().join("deliverables",i)),l=bx("memory");return await (0,e.mkdir)(j,{recursive:!0}),await (0,e.mkdir)(g().join(a,"memory"),{recursive:!0}),{runFolder:i,absoluteOutputDir:j,relativeOutputDir:k,notesDirRelative:l}}var bz=c(17689),bA=c(6347),bB=c(39754);async function bC(a,b){var c,d;let e,f,g=a.mission.trim();if(!g)throw Error("Mission text is required.");let i=await b.getMissionControlSnapshot({includeHidden:!0}),j=a.agentId||b.resolveAgentForMission(i,a.workspaceId);if(!j)throw Error("No OpenClaw agent is available for mission dispatch.");let l=i.agents.find(a=>a.id===j),m=i.workspaces.find(b=>b.id===(a.workspaceId||l?.workspaceId))??(l?{id:l.workspaceId,path:l.workspacePath}:null),n=m?i.agents.filter(a=>a.workspaceId===m.id):[],o=n.find(a=>"setup"===a.policy.preset&&a.id!==l?.id)?.id??null,p=m?await by(m.path,g):null,q=a.thinking??"medium",r=(0,bA.Z)(j,i),s=p?(c=l?.policy,d=l?{id:l.id,name:l.name}:null,e=c??(0,h.g0)(h.iN),[g,...(f=d?["Agent workspace context:",`- Your current OpenClaw agent id is \`${d.id}\`${d.name?` and your AgentOS display name is ${d.name}`:""}.`,"- Use the matching subsection in workspace root `AGENTS.md` as your agent-specific role/persona.","- Treat other `AGENTS.md` agent subsections as teammates in the same workspace.","- Use root `SOUL.md`, `USER.md`, `TOOLS.md`, `MEMORY.md`, `memory/*.md`, and `docs/*.md` as shared workspace/project context."]:[]).length>0?["",...f]:[],"","Task output routing:",`- Put substantial outputs, drafts, reports, docs, and file deliverables under \`${p.relativeOutputDir}/\`.`,`- If a file is requested, default to \`${p.relativeOutputDir}/<descriptive-file-name>\` unless the user explicitly asks for another path.`,`- Use \`${p.notesDirRelative}/\` only for temporary notes or durable workspace memory, not final deliverables.`,"- Avoid writing final artifacts to the workspace root.","- Only update shared workspace docs when the change is durable and workspace-wide; task-specific docs should stay inside this run folder.","","Agent operating policy:",...L(e,o),...r?["",r]:[]].join("\n")):g,t=(0,bB.l9)(i),u=(0,aY._z)({agentId:j,mission:g,routedMission:s,thinking:q,workspaceId:m?.id??null,workspacePath:m?.path??null,outputDir:p?.absoluteOutputDir??null,outputDirRelative:p?.relativeOutputDir??null,notesDirRelative:p?.notesDirRelative??null});if(await (0,aY.lm)(u),t)return u={...u,status:"stalled",updatedAt:new Date().toISOString(),error:t},await (0,aY.lm)(u),b.invalidateMissionControlCaches(),{dispatchId:u.id,runId:null,agentId:j,status:u.status,summary:t,payloads:[],meta:{outputDir:p?.absoluteOutputDir,outputDirRelative:p?.relativeOutputDir,notesDirRelative:p?.notesDirRelative}};try{let a=await (0,bz.N3)().catch(()=>null);if(a?.nativeMissionDispatch!=="unsupported"){let a=await (0,k.rw)().runAgentTurn({agentId:j,sessionId:u.sessionId??void 0,message:s,thinking:q,timeoutSeconds:45,workspace:m?.path??null,dispatchId:u.id},{timeoutMs:6e4}),b=new Date().toISOString();u={...u,status:"completed"===a.status?"completed":"stalled"===a.status?"stalled":"running",updatedAt:b,runner:{...u.runner,startedAt:b,finishedAt:"completed"===a.status||"stalled"===a.status?b:null,lastHeartbeatAt:b},observation:{runtimeId:a.runId?`runtime:gateway:${a.runId}`:u.observation.runtimeId,observedAt:b},result:a,error:"stalled"===a.status?a.summary??"OpenClaw Gateway dispatch stalled.":null},await (0,aY.lm)(u)}else u=await (0,aY.gb)(u)}catch(a){throw u={...u,status:"stalled",updatedAt:new Date().toISOString(),error:(0,az.t)(a)||"Mission dispatch runner could not be started."},await (0,aY.lm)(u),b.invalidateMissionControlCaches(),Error(u.error??"Mission dispatch runner could not be started.")}return b.invalidateMissionControlCaches(),{dispatchId:u.id,runId:u.result?.runId??null,agentId:j,status:u.status,summary:"Mission accepted and queued for OpenClaw execution.",payloads:[],meta:{outputDir:p?.absoluteOutputDir,outputDirRelative:p?.relativeOutputDir,notesDirRelative:p?.notesDirRelative}}}async function bD(a,b,c,d){let e=(await d.getMissionControlSnapshot({includeHidden:!0})).tasks.find(b=>b.id===a),f=e?await (0,aY.ji)(e):c?await (0,aY.O1)(c):null;if(!e&&!f)throw Error("Task was not found in the current OpenClaw snapshot.");if(!f)throw Error("Mission dispatch record was not found for this task.");if((0,aY.VW)(f.status))return{taskId:a,dispatchId:f.id,status:f.status,summary:(0,aK.kc)(f),reason:f.error,runnerPid:f.runner.pid,childPid:f.runner.childPid,abortedAt:f.runner.finishedAt??f.updatedAt};let g=new Date().toISOString(),h=(0,aY.GG)(b),i={...f,status:"cancelled",updatedAt:g,error:h,runner:{...f.runner,finishedAt:g,lastHeartbeatAt:g}};await (0,aY.lm)(i),d.invalidateMissionControlCaches();let j=null,l=f.result?.runId??null;return(l||f.sessionId)&&await (0,k.rw)().abortAgentTurn({runId:l,sessionId:f.sessionId,agentId:f.agentId,reason:h},{timeoutMs:15e3}).catch(()=>null),j=await (0,aY.e4)(i),{taskId:a,dispatchId:i.id,status:i.status,summary:h,reason:h,runnerPid:i.runner.pid,childPid:j??i.runner.childPid,abortedAt:g}}function bE(a,b){if(!b)return a.agents.find(a=>a.isDefault)?.id||a.agents[0]?.id;let c=a.agents.filter(a=>a.workspaceId===b);return c.find(a=>a.isDefault)?.id||c.find(a=>"engaged"===a.status)?.id||c[0]?.id}async function bF(a){return bC(a,{getMissionControlSnapshot:d.GM,resolveAgentForMission:bE,invalidateMissionControlCaches:d.er})}async function bG(a,b,c){return bD(a,b,c,{getMissionControlSnapshot:d.GM,resolveAgentForMission:bE,invalidateMissionControlCaches:d.er})}var bH=c(77598),bI=c(58500),bJ=c(27675);let bK="gateway.remote.url",bL=".env.local",bM="AGENTOS_OPENCLAW_GATEWAY_TOKEN",bN="AGENTOS_OPENCLAW_GATEWAY_PASSWORD",bO=[0,500,1e3,1500,2500,3500],bP=["operator.admin","operator.read","operator.write","operator.approvals","operator.pairing","operator.talk.secrets"];function bQ(){(0,d.ZZ)(),(0,d.b7)()}async function bR(a){let b=(0,a1.Zm)(a.gatewayUrl);return b?await (0,k.rw)().setConfig(bK,b):await (0,k.rw)().hasConfig(bK)&&await (0,k.rw)().unsetConfig(bK),bQ(),(0,d.GM)({force:!0})}async function bS(a){let b=(0,a1.FU)(a.workspaceRoot),c=await (0,a1.tl)();return await (0,a1.wi)({...b?{workspaceRoot:b}:{},...c.runtimePreflight?{runtimePreflight:c.runtimePreflight}:{}}),bQ(),(0,d.GM)({force:!0})}async function bT(a={}){let b,c=a.env??process.env,d=a.cwd??process.cwd(),e=(a.now??(()=>new Date))().toISOString(),f=(0,k.rw)(),g=await bZ(f),h=g.snapshot,[i,j,l,m,n]=h?["string"==typeof(b=b$(h,"gateway.auth.mode"))&&b.trim()?b.trim():null,b4(b$(h,"gateway.auth.token")),b4(b$(h,"gateway.auth.password")),b4(b$(h,"gateway.remote.token")),b4(b$(h,"gateway.remote.password"))]:g.invalidConfig?[null,"unknown","unknown","unknown","unknown"]:await Promise.all([w("gateway.auth.mode"),x("gateway.auth.token"),x("gateway.auth.password"),x("gateway.remote.token"),x("gateway.remote.password")]),o=(a.isNativeDisabled??bJ.JG)(),p=!!(c.AGENTOS_OPENCLAW_GATEWAY_TOKEN?.trim()||c.OPENCLAW_GATEWAY_TOKEN?.trim()),q=!!(c.AGENTOS_OPENCLAW_GATEWAY_PASSWORD?.trim()||c.OPENCLAW_GATEWAY_PASSWORD?.trim()),r={authToken:j,authPassword:l,remoteToken:m,remotePassword:n},s=await b1(d);if(o)return{mode:i,env:{token:p,password:q},config:r,native:{ok:!1,checkedAt:e,kind:"disabled",issue:"Native OpenClaw Gateway WS is disabled by environment configuration.",disabledByEnv:!0},envFile:s,recommendation:"Unset AGENTOS_OPENCLAW_GATEWAY_CLIENT/OPENCLAW_GATEWAY_CLIENT=cli or AGENTOS_OPENCLAW_NATIVE_WS=0, then restart AgentOS."};try{return await (a.nativeProbe??(()=>new bJ.gH().callNative("status",{},{timeoutMs:2500})))(),{mode:i,env:{token:p,password:q},config:r,native:{ok:!0,checkedAt:e,kind:null,issue:null,disabledByEnv:!1},envFile:s,recommendation:"Native OpenClaw Gateway WS auth is ready."}}catch(g){var t,u,v;let a,b,c,d=g instanceof Error?g.message:String(g||"Native Gateway auth check failed."),f=(t=g,u=d,"auth"===(a=t?.kind)||"malformed-response"===a||"scope-limited"===a||"timeout"===a||"unreachable"===a||"unknown"===a?a:/auth|token|password|unauthorized|forbidden/i.test(u)?"auth":/scope|permission|not allowed/i.test(u)?"scope-limited":/invalid json|malformed|schema|payload/i.test(u)?"malformed-response":/timed out|timeout/i.test(u)?"timeout":/connect|closed|unreachable|websocket/i.test(u)?"unreachable":"unknown");return{mode:i,env:{token:p,password:q},config:r,native:{ok:!1,checkedAt:e,kind:f,issue:d,disabledByEnv:!1},envFile:s,recommendation:(b=Object.values((v={kind:f,envToken:p,envPassword:q,config:r}).config).includes("redacted"),c=v.envToken||v.envPassword,"auth"===v.kind&&b&&!c?"Set AGENTOS_OPENCLAW_GATEWAY_TOKEN/PASSWORD or OPENCLAW_GATEWAY_TOKEN/PASSWORD in the AgentOS process environment, then restart AgentOS.":"auth"===v.kind?"Verify the Gateway token/password exported to the AgentOS process, then restart AgentOS.":"unreachable"===v.kind||"timeout"===v.kind?"Start or restart the OpenClaw Gateway, then test native auth again.":"scope-limited"===v.kind?"Repair the local AgentOS device access request so native Gateway WS can use operator scopes. No manual secret entry is required.":"malformed-response"===v.kind?"Update OpenClaw or continue using CLI fallback until the Gateway contract matches AgentOS.":"Review Gateway diagnostics and continue using CLI fallback until native WS can authenticate.")}}async function w(a){try{let b=await f.getConfig(a,{timeoutMs:2500});return"string"==typeof b&&b.trim()?b.trim():null}catch{return null}}async function x(a){try{let b=await f.getConfig(a,{timeoutMs:2500});return b4(b)}catch{return"unknown"}}}async function bU(a){let b=a.value.trim();if(!b)throw Error("Gateway token/password is required.");if(b.length>4096)throw Error("Gateway token/password is too long.");let c=(0,f.join)(a.cwd??process.cwd(),bL),d=function(a,b,c){let d="token"===b?bM:bN,e="token"===b?bN:bM,f=`${d}=${JSON.stringify(c)}`,g=a.split(/\r?\n/),h=[],i=!1;for(let a of g){if(!a.trim()){h.push(a);continue}let b=a.match(/^\s*([A-Za-z_][A-Za-z0-9_]*)\s*=/)?.[1];if(b===d){i||(h.push(f),i=!0);continue}b!==e&&h.push(a)}return i||(h.some(a=>a.trim())&&h.at(-1)?.trim()&&h.push(""),h.push("# OpenClaw Gateway native WebSocket auth for AgentOS"),h.push(f)),`${h.join("\n").replace(/\n+$/,"")}
|
|
251
|
+
`}(await b2(c),a.kind,b);return await (0,e.writeFile)(c,d,"utf8"),"token"===a.kind?(process.env[bM]=b,delete process.env[bN]):(process.env[bN]=b,delete process.env[bM]),{envFile:bL,activeEnvName:"token"===a.kind?bM:bN,restartRecommended:!0}}async function bV(a={}){let b=(0,bH.randomBytes)(32).toString("base64url");await (0,k.rw)().setConfig("gateway.auth.mode","token",{timeoutMs:2500}),await (0,k.rw)().setConfig("gateway.auth.token",b,{timeoutMs:2500});let c=await bU({kind:"token",value:b,cwd:a.cwd}),d=!1,e=null,f=!1,g=null;try{await (0,k.rw)().controlGateway("restart",{timeoutMs:2e4}),d=!0,await (0,bI.setTimeout)(1250),f=!(g=await bW(b,a.verifyNativeAuth))}catch(a){e=a instanceof Error?a.message:"Gateway restart failed."}return bQ(),{envFile:c.envFile,activeEnvName:c.activeEnvName,restarted:d,restartIssue:e,verified:f,verificationIssue:g}}async function bW(a,b){let c=null,d=b??(a=>new bJ.gH({token:a}).callNative("status",{},{timeoutMs:2500}));for(let b of bO){b>0&&await (0,bI.setTimeout)(b);try{return await d(a),null}catch(a){c=a instanceof Error?a.message:"Gateway auth verification failed."}}return c}async function bX(a={}){let b=a.readDeviceAuthToken??b5,c=!1;try{await (a.nativeProbe??(()=>new bJ.gH().callNative("status",{},{timeoutMs:2500})))(),c=!0}catch{}let d=null,e=null,f={approved:!1,requestId:null,deviceId:null,scopes:[],envSynced:!1,activeEnvName:null,approvalIssue:null};try{var g;let c,d;c=(g=await (a.approveLatest??bY)())&&"object"==typeof g?g.device:null,d=cb(c?.approvedScopes).length?cb(c?.approvedScopes):cb(c?.scopes),f={approved:!!c,requestId:ca(g?.requestId),deviceId:ca(c?.deviceId),scopes:d,envSynced:!1,activeEnvName:null,approvalIssue:null},e=await b6()??await b()}catch(a){if(d=a instanceof Error?a.message:"OpenClaw device approval failed.",e=await b6()??await b(),!e?.token||!b9(e.scopes))throw a;f={...f,approved:!0,scopes:e.scopes}}if(!f.approved&&c&&b9(e?.scopes??[])&&(f={...f,approved:!0,scopes:e?.scopes??f.scopes}),f.approved&&b9(e?.scopes??[])&&(f={...f,scopes:e?.scopes??f.scopes}),f.approved&&!b9(e?.scopes??f.scopes))throw Error("OpenClaw device access was approved, but the local CLI device token was not updated with the required operator scopes.");return bQ(),{...f,envSynced:!1,activeEnvName:null,approvalIssue:d}}async function bY(){return(0,k.rw)().approveDeviceAccess({latest:!0},{timeoutMs:1e4})}async function bZ(a){try{let b=await a.call("config.get",{},{timeoutMs:2500});return{snapshot:function(a){if(!b0(a))return null;let b=b0(a.config)?a.config:null,c=b0(a.resolved)?a.resolved:null;return b||c?{config:b??{},resolved:c??{}}:null}(b),invalidConfig:!1}}catch(a){return{snapshot:null,invalidConfig:(0,az.D)(a)}}}function b$(a,b){let c=b_(a.config,b)??b_(a.resolved,b);return void 0===c?null:c}function b_(a,b){if(Object.hasOwn(a,b))return a[b];let c=a;for(let a of b.split(".")){if(!b0(c)||!Object.hasOwn(c,a))return;c=c[a]}return c}function b0(a){return!!a&&"object"==typeof a&&!Array.isArray(a)}async function b1(a){let b=(0,f.join)(a,bL),c=await b2(b),d=await b2((0,f.join)(a,".gitignore"));return{path:bL,token:b3(c,bM),password:b3(c,bN),gitignored:/^\.env\*?\.local$/m.test(d)||/^\.env\.local$/m.test(d)}}async function b2(a){try{return await (0,e.readFile)(a,"utf8")}catch{return""}}function b3(a,b){return RegExp(`^\\s*${b}\\s*=`,"m").test(a)}function b4(a){if(null==a)return"missing";if("string"!=typeof a)return"present";let b=a.trim();return b?"__OPENCLAW_REDACTED__"===b?"redacted":"present":"missing"}async function b5(){let a=await b2((0,f.join)(b8(),"identity","device-auth.json"));if(!a.trim())return null;try{let b=JSON.parse(a),c=ca(b.tokens?.operator?.token);if(!c)return null;return{token:c,scopes:cb(b.tokens?.operator?.scopes)}}catch{return null}}async function b6(){let a=b8(),b=await b7((0,f.join)(a,"identity","device.json")),c=ca(b?.deviceId);if(!c)return null;let d=await b7((0,f.join)(a,"devices","paired.json")),g=d?.[c]?.tokens?.operator,h=ca(g?.token),i=cb(g?.scopes);if(!h)return null;let j=(0,f.join)(a,"identity","device-auth.json"),k=await b7(j),l=k?.deviceId===c&&k.tokens&&"object"==typeof k.tokens?{...k.tokens}:{};return l.operator={token:h,role:ca(g?.role)??"operator",scopes:i,updatedAtMs:Date.now()},await (0,e.mkdir)((0,f.dirname)(j),{recursive:!0}),await (0,e.writeFile)(j,`${JSON.stringify({version:1,deviceId:c,tokens:l},null,2)}
|
|
252
|
+
`,{encoding:"utf8",mode:384}),{token:h,scopes:i}}async function b7(a){let b=await b2(a);if(!b.trim())return null;try{return JSON.parse(b)}catch{return null}}function b8(){let a=process.env.OPENCLAW_STATE_DIR?.trim();return a?a.startsWith("~")?(0,f.join)((0,au.homedir)(),a.slice(1)):a:(0,f.join)((0,au.homedir)(),".openclaw")}function b9(a){let b=new Set(a);return bP.every(a=>b.has(a))}function ca(a){return"string"==typeof a&&a.trim()?a.trim():null}function cb(a){return Array.isArray(a)?a.filter(a=>"string"==typeof a&&!!a.trim()):[]}var cc=c(20619),cd=c(59331);function ce(){(0,d.ZZ)()}async function cf(a,b){let c=cP(a.channelId);if(!c)throw Error("Channel id is required.");return await (0,n.rh)(b,"workspace-channel.registry-upsert",()=>cN(b=>{let d=b.channels.find(a=>a.id===c)??{id:c,type:a.type,name:a.name.trim()||c,primaryAgentId:(0,ae.Nk)(a.primaryAgentId)??null,workspaces:[]},e=a.workspaceId.trim(),f=a.workspacePath.trim(),g=d.workspaces.find(a=>a.workspaceId===e)??{workspaceId:e,workspacePath:f,agentIds:[],groupAssignments:[]},h=cO([...g.agentIds,...(a.agentIds??[]).map(a=>a.trim()).filter(Boolean)]),i=(0,S.qc)([...g.groupAssignments,...(a.groupAssignments??[]).filter(a=>!!a.chatId)]),j={...g,workspacePath:f,agentIds:h,groupAssignments:i},k=d.workspaces.filter(a=>a.workspaceId!==e);k.push(j);let l=(0,ae.Nk)(a.primaryAgentId)??d.primaryAgentId;b.channels=[...b.channels.filter(a=>a.id!==c),{...d,id:c,type:a.type,name:a.name.trim()||d.name||c,primaryAgentId:l||j.agentIds[0]||j.groupAssignments.find(a=>a.agentId)?.agentId||null,workspaces:k}]},{},b)),ce(),(0,cc.VW)()}async function cg(a,b){let c=cP(a.channelId);if(!c)throw Error("Channel id is required.");return await (0,n.rh)(b,"channel-registry.disconnect",()=>cN(b=>{b.channels=b.channels.map(b=>{if(b.id!==c)return b;let d=b.workspaces.filter(b=>b.workspaceId!==a.workspaceId),e=cO([...d.flatMap(a=>a.agentIds),...d.flatMap(a=>a.groupAssignments.filter(a=>!1!==a.enabled&&a.agentId).map(a=>a.agentId))]);return{...b,primaryAgentId:b.primaryAgentId&&e.includes(b.primaryAgentId)?b.primaryAgentId:e[0]??null,workspaces:d}}).filter(a=>a.workspaces.length>0||a.primaryAgentId)},{},b)),ce(),(0,cc.VW)()}async function ch(a,b){let c=cP(a.channelId);if(!c)throw Error("Channel id is required.");let d=(await (0,n.rh)(b,"channel-registry.read-before-delete",()=>(0,cc.vg)())).channels.find(a=>a.id===c);if(!d)throw Error("Channel was not found.");let e=cO(d.workspaces.flatMap(a=>a.groupAssignments.filter(a=>!!a.chatId).map(a=>a.chatId))),f=cO(d.workspaces.map(a=>a.workspacePath));return cQ(d.type)&&"internal"!==d.type&&await (0,n.rh)(b,"channel.delete-openclaw-remove",()=>(0,k.rw)().removeChannelAccount({channel:d.type,account:c,delete:!0},{timeoutMs:6e4})),await (0,n.rh)(b,"channel.delete-registry-sync",()=>cN(a=>{a.channels=a.channels.filter(a=>a.id!==c)},{removedAccountIds:[c],removedGroupIds:e},b)),await (0,n.rh)(b,"channel.delete-project-cleanup",()=>Promise.all(f.map(a=>cq(a,c,b)))),ce(),(0,n.rh)(b,"channel.delete-read-final-registry",()=>(0,cc.VW)())}async function ci(a,b){let c=cP(a.channelId);if(!c)throw Error("Channel id is required.");return await (0,n.rh)(b,"channel.primary-update",()=>cN(b=>{let d=b.channels.find(a=>a.id===c);if(!d)throw Error("Channel was not found.");d.primaryAgentId=(0,ae.Nk)(a.primaryAgentId)??null},{},b)),ce(),(0,cc.VW)()}async function cj(a,b){let c=cP(a.channelId);if(!c)throw Error("Channel id is required.");let d=[];return await (0,n.rh)(b,"channel.groups-update",()=>cN(b=>{let e=b.channels.find(a=>a.id===c);if(!e)throw Error("Channel was not found.");let f=e.workspaces.find(b=>b.workspaceId===a.workspaceId);if(!f)throw Error("Workspace binding was not found for this channel.");let g=new Set(f.groupAssignments.filter(a=>!1!==a.enabled&&!!a.chatId).map(a=>a.chatId));f.groupAssignments=(0,S.qc)(a.groupAssignments.map(a=>({chatId:a.chatId.trim(),agentId:(0,ae.Nk)(a.agentId)??null,title:(0,ae.Nk)(a.title)??null,enabled:!1!==a.enabled}))),f.agentIds=cO([...f.agentIds,...f.groupAssignments.filter(a=>!1!==a.enabled&&a.agentId).map(a=>a.agentId)]);let h=new Set(f.groupAssignments.filter(a=>!1!==a.enabled&&!!a.chatId).map(a=>a.chatId));for(let a of g)h.has(a)||d.push(a)},{removedGroupIds:d},b)),ce(),(0,cc.VW)()}async function ck(a,b){let c=cP(a.channelId),d=cR(a.agentId.trim());if(!c||!d)throw Error("Channel id and agent id are required.");return await (0,n.rh)(b,"channel.bind-agent",()=>cN(b=>{let e=b.channels.find(a=>a.id===c);if(!e)throw Error("Channel was not found.");let f=e.workspaces.find(b=>b.workspaceId===a.workspaceId)??{workspaceId:a.workspaceId,workspacePath:a.workspacePath,agentIds:[],groupAssignments:[]};f.agentIds=cO([...f.agentIds,d]),f.workspacePath=a.workspacePath,e.workspaces=[...e.workspaces.filter(b=>b.workspaceId!==a.workspaceId),f],e.primaryAgentId||(e.primaryAgentId=d)},{},b)),ce(),(0,cc.VW)()}async function cl(a,b){let c=cP(a.channelId),d=cR(a.agentId.trim());if(!c||!d)throw Error("Channel id and agent id are required.");return await (0,n.rh)(b,"channel.unbind-agent",()=>cN(b=>{let e=b.channels.find(a=>a.id===c);if(!e)throw Error("Channel was not found.");let f=e.workspaces.find(b=>b.workspaceId===a.workspaceId);if(f){if(f.agentIds=f.agentIds.filter(a=>a!==d),f.groupAssignments=f.groupAssignments.filter(a=>a.agentId!==d),e.primaryAgentId===d){let a=f.agentIds[0]??f.groupAssignments.find(a=>!1!==a.enabled&&a.agentId)?.agentId??e.workspaces.flatMap(a=>a.agentIds).find(a=>a!==d)??e.workspaces.flatMap(a=>a.groupAssignments).find(a=>!1!==a.enabled&&a.agentId&&a.agentId!==d)?.agentId??null;e.primaryAgentId=a}e.workspaces=[...e.workspaces.filter(b=>b.workspaceId!==a.workspaceId),{...f,agentIds:f.agentIds,groupAssignments:f.groupAssignments}]}},{},b)),ce(),(0,cc.VW)()}async function cm(a,b){if("telegram"===a.provider){if(!a.token?.trim())throw Error("Telegram bot token is required.");return co({name:a.name,token:a.token,accountId:a.accountId},b)}let c=(0,ae.Nk)(a.accountId)??await cs(a.provider,a.name,b),d=new Set((await (0,n.rh)(b,`managed-chat.${a.provider}.read-before`,()=>(0,cc.QT)())).filter(b=>b.type===a.provider).map(a=>a.id)),e=(()=>{switch(a.provider){case"discord":if(!a.token?.trim())throw Error("Discord bot token is required.");return{channel:"discord",account:c,token:a.token,name:a.name};case"slack":if(!a.botToken?.trim())throw Error("Slack bot token is required.");return{channel:"slack",account:c,botToken:a.botToken,name:a.name};case"googlechat":if(!a.webhookUrl?.trim())throw Error("Google Chat webhook URL is required.");return{channel:"googlechat",account:c,webhookUrl:a.webhookUrl,name:a.name};default:throw Error(`OpenClaw provisioning is not implemented for ${a.provider}.`)}})();await (0,n.rh)(b,`managed-chat.${a.provider}.provision-openclaw`,()=>(0,k.rw)().provisionChannelAccount(e,{timeoutMs:6e4}));let f=(await (0,n.rh)(b,`managed-chat.${a.provider}.read-after`,()=>(0,cc.QT)())).filter(b=>b.type===a.provider);return f.find(a=>a.id===c)??f.find(b=>!d.has(b.id)&&b.name===a.name)??f.find(a=>!d.has(a.id))??null??{id:c,type:a.provider,kind:(0,cd.Yx)(a.provider),name:a.name.trim()||c,enabled:!0}}async function cn(a,b){var c;if("telegram"===(c=a.provider)||"discord"===c||"slack"===c||"googlechat"===c)return cm({provider:a.provider,name:a.name,accountId:a.accountId,token:a.token,botToken:a.botToken,webhookUrl:a.webhookUrl},b);let d=function(a){let b={};if(!cr(a))return b;for(let[c,d]of Object.entries(a))cy(b,c,cz(d));return b}(a.config),e=a.name.trim(),f=function(a,b){switch(a){case"gmail":return cA(b.account)??cA(b.email)??cA(b.address);case"email":return cA(b.address)??cA(b.email);case"webhook":case"cron":return cA(b.accountId)??cA(b.name);default:return null}}(a.provider,d),g=(0,ae.Nk)(a.accountId)??f??await cs(a.provider,a.name,b),h=function(a){switch(a){case"gmail":return"hooks.gmail";case"email":return"email";case"webhook":return"hooks";case"cron":return"cron";default:throw Error(`OpenClaw provisioning is not implemented for ${a}.`)}}(a.provider);switch(a.provider){case"gmail":{let a=(0,ae.Nk)(d.account??d.email??d.address);if(!a)throw Error("Gmail account email is required.");await (0,n.rh)(b,"managed-surface.gmail.setup-openclaw",()=>(0,k.rw)().setupGmailWebhook({account:a,config:d},{timeoutMs:6e4}));let c=await (0,n.rh)(b,"managed-surface.gmail.read-config",()=>(0,k.rw)().getConfig(h,{timeoutMs:6e4})),f=await (0,n.rh)(b,"managed-surface.gmail.read-hooks",()=>(0,k.rw)().getConfig("hooks",{timeoutMs:6e4})),i=f?.presets,j=cx(f,{enabled:!0,presets:cO([...Array.isArray(i)?i.filter(a=>"string"==typeof a):[],"gmail"])});await (0,n.rh)(b,"managed-surface.gmail.write-hooks",()=>(0,k.rw)().setConfig("hooks",j,{strictJson:!0,timeoutMs:6e4}));let l=cx(c,{enabled:!0,name:e||a,label:e||a,accountId:g,account:a,email:a,address:a,...d});await (0,n.rh)(b,"managed-surface.gmail.write-config",()=>(0,k.rw)().setConfig(h,l,{strictJson:!0,timeoutMs:6e4}));break}case"webhook":{let a=await (0,n.rh)(b,"managed-surface.webhook.read-config",()=>(0,k.rw)().getConfig(h,{timeoutMs:6e4})),c=cA(d.token);if(!c)throw Error("Webhook token is required.");let f=cx(a,{enabled:!0,name:e||g,label:e||g,accountId:g,token:c,...d});await (0,n.rh)(b,"managed-surface.webhook.write-config",()=>(0,k.rw)().setConfig(h,f,{strictJson:!0,timeoutMs:6e4}));break}case"cron":{let a=await (0,n.rh)(b,"managed-surface.cron.read-config",()=>(0,k.rw)().getConfig(h,{timeoutMs:6e4})),c=cA(d.webhookToken);if(!c)throw Error("Cron webhook token is required.");let f=cx(a,{enabled:!0,name:e||g,label:e||g,accountId:g,webhookToken:c,...d});await (0,n.rh)(b,"managed-surface.cron.write-config",()=>(0,k.rw)().setConfig(h,f,{strictJson:!0,timeoutMs:6e4}));break}case"email":{let a=await (0,n.rh)(b,"managed-surface.email.read-config",()=>(0,k.rw)().getConfig(h,{timeoutMs:6e4})),c=cA(d.address??d.email);if(!c)throw Error("Email address is required.");let f=cx(a,{enabled:!0,name:e||c,label:e||c,accountId:g,address:c,email:c,...d});await (0,n.rh)(b,"managed-surface.email.write-config",()=>(0,k.rw)().setConfig(h,f,{strictJson:!0,timeoutMs:6e4}));break}default:throw Error(`OpenClaw provisioning is not implemented for ${a.provider}.`)}let i=(await (0,n.rh)(b,`managed-surface.${a.provider}.read-after`,()=>(0,cc.QT)())).filter(b=>b.type===a.provider);return i.find(a=>a.id===g)??i.find(b=>b.name.trim().toLowerCase()===a.name.trim().toLowerCase())??i[0]??null??{id:g,type:a.provider,kind:(0,cd.Yx)(a.provider),name:e||g,enabled:!0}}async function co(a,b){let c=(0,ae.Nk)(a.accountId)??await ct(a.name,b),d=new Set((await (0,n.rh)(b,"telegram.read-before",()=>(0,cc.QT)())).filter(a=>"telegram"===a.type).map(a=>a.id));await (0,n.rh)(b,"telegram.openclaw-add",()=>(0,k.rw)().provisionChannelAccount({channel:"telegram",account:c,token:a.token,name:a.name},{timeoutMs:6e4}));let e={id:c,type:"telegram",name:a.name.trim()||c,enabled:!0},f=(await (0,n.rh)(b,"telegram.read-after",()=>(0,cc.QT)())).filter(a=>"telegram"===a.type).find(a=>a.id===c);if(f)return{...f,name:a.name.trim()||f.name};let g=Date.now()+8e3,h=null,i=0;for(;Date.now()<g;){i+=1;let e=(await (0,n.rh)(b,`telegram.resolve.${i}.read-channel-accounts`,()=>(0,cc.QT)())).filter(a=>"telegram"===a.type);if(h=e.find(a=>a.id===c)??e.find(b=>!d.has(b.id)&&b.name===a.name)??e.find(a=>!d.has(a.id))??e.find(b=>b.name===a.name)??null)break;let f=await (0,n.rh)(b,`telegram.resolve.${i}.read-pairing-accounts`,()=>cu());if(h=f.find(b=>!d.has(b.id)&&b.name===a.name)??f.find(a=>!d.has(a.id))??f.find(b=>b.name===a.name)??null)break;await (0,n.rh)(b,`telegram.resolve.${i}.sleep`,()=>new Promise(a=>setTimeout(a,750)))}if(!h){let c=await (0,n.rh)(b,"telegram.resolve.token-lookup",async()=>cw(a.token,(await (0,n.rh)(b,"telegram.resolve.token-lookup.read-channel-accounts",()=>(0,cc.QT)())).filter(a=>"telegram"===a.type),b));h=c||e}return{...h,name:a.name.trim()||h.name}}async function cp(a){await B(a4.q6,`${JSON.stringify(a,null,2)}
|
|
253
|
+
`)}async function cq(a,b,c){let d=g().join(a,".openclaw","project.json"),f={};try{let b=await (0,n.rh)(c,`workspace-project.${g().basename(a)}.read`,()=>(0,e.readFile)(d,"utf8")),h=JSON.parse(b);f=cr(h)?h:{}}catch{return}if(!Array.isArray(f.agents))return;let h=!1,i=f.agents.map(a=>{if(!cr(a)||"string"!=typeof a.id)return a;let c=Array.isArray(a.channelIds)?a.channelIds.filter(a=>"string"==typeof a):[],d=c.filter(a=>a!==b);return d.length===c.length?a:(h=!0,{...a,channelIds:d})});h&&(f.updatedAt=new Date().toISOString(),f.agents=i,await (0,n.rh)(c,`workspace-project.${g().basename(a)}.write`,()=>B(d,`${JSON.stringify(f,null,2)}
|
|
254
|
+
`)))}function cr(a){return"object"==typeof a&&null!==a}async function cs(a,b,c){let d=cR(b.trim())||a,e=`${a}-${d}`,f=await (0,n.rh)(c,`managed-surface.${a}.read-channel-registry`,()=>(0,cc.vg)()),g=await (0,n.rh)(c,`managed-surface.${a}.read-channel-accounts`,()=>(0,cc.QT)()),h=new Set([...f.channels.filter(b=>b.type===a).map(a=>a.id),...g.filter(b=>b.type===a).map(a=>a.id)]);if(!h.has(e))return e;let i=2;for(;h.has(`${e}-${i}`);)i+=1;return`${e}-${i}`}async function ct(a,b){return cs("telegram",a,b)}async function cu(){try{let a=await (0,e.readFile)(g().join(a4.wh,"credentials","telegram-pairing.json"),"utf8"),b=JSON.parse(a),c=Array.isArray(b?.requests)?b.requests:[],d=new Map;for(let a of c){let b=(0,ae.Nk)(a.meta?.accountId);b&&d.set(b,{id:b,type:"telegram",name:(0,ae.Nk)(a.meta?.username)??(0,ae.Nk)(a.meta?.firstName)??b,enabled:!0})}return Array.from(d.values())}catch{return[]}}async function cv(a){try{let b=g().join(a4.wh,"telegram"),c=await (0,n.rh)(a,"telegram.resolve.read-bot-id-files",()=>(0,e.readdir)(b)),d=await Promise.all(c.filter(a=>a.startsWith("update-offset-")&&a.endsWith(".json")).map(async c=>{try{let d=await (0,n.rh)(a,`telegram.resolve.read-bot-id-file.${c}`,()=>(0,e.readFile)(g().join(b,c),"utf8")),f=JSON.parse(d),h=(0,ae.Nk)(f?.botId),i=c.slice(14,-5);if(!h||!i)return null;return[i,h]}catch{return null}}));return new Map(d.filter(a=>!!a))}catch{return new Map}}async function cw(a,b,c){let d=(0,ae.Nk)(a.split(":",1)[0]);if(!d)return null;let e=await (0,n.rh)(c,"telegram.resolve.read-bot-ids",()=>cv(c));return b.find(a=>e.get(a.id)===d)??null}function cx(a,b){var c;let d=cr(c=a)?JSON.parse(JSON.stringify(c)):{};for(let[a,c]of Object.entries(b))cy(d,a,cz(c));return d}function cy(a,b,c){if(void 0===c)return;let d=b.split(".").map(a=>a.trim()).filter(Boolean);if(0===d.length)return;let e=a;for(let a=0;a<d.length-1;a+=1){let b=d[a];cr(e[b])||(e[b]={}),e=e[b]}e[d[d.length-1]]=c}function cz(a){if("string"==typeof a){let b=a.trim();if(!b)return;if(b.startsWith("{")&&b.endsWith("}")||b.startsWith("[")&&b.endsWith("]"))try{return JSON.parse(b)}catch{}return b}if(Array.isArray(a))return a.map(a=>cz(a)).filter(a=>void 0!==a);if(cr(a)){let b={};for(let[c,d]of Object.entries(a)){let a=cz(d);void 0!==a&&(b[c]=a)}return b}return a}function cA(a){return"string"==typeof a&&a.trim().length>0?a.trim():null}function cB(a){return(0,S._E)({version:1,channels:a.channels.map(a=>({...a,workspaces:a.workspaces.map(a=>({...a,agentIds:[...a.agentIds],groupAssignments:a.groupAssignments.map(a=>({...a}))}))}))})}async function cC(a){await cp((0,S._E)(a))}async function cD(a,b={},c){var d;let e,f=await (0,n.rh)(c,"routing.read-bindings",()=>(0,k.rw)().getConfig("bindings").then(a=>a??[])),g=a.channels.filter(a=>cQ(a.type)&&"internal"!==a.type),h=new Set(b.removedAccountIds??[]),i=new Set(b.removedGroupIds??[]),j=new Map;for(let a of g){let b=j.get(a.type)??new Set;b.add(a.id),j.set(a.type,b)}let l=g.filter(a=>"telegram"===a.type),m=g.filter(a=>"discord"===a.type),o=(d=[...f.filter(a=>{if(!cr(a))return!0;let b=cr(a.match)?a.match:null;if(!b||"string"!=typeof b.channel)return!0;let c=j.get(b.channel);return!(c&&"string"==typeof b.accountId&&(c.has(b.accountId)||h.has(b.accountId))||"telegram"===b.channel&&cr(b.peer)&&"string"==typeof b.peer.id&&i.has(b.peer.id))}),...g.filter(a=>!!a.primaryAgentId).map(a=>({agentId:a.primaryAgentId,match:{channel:a.type,accountId:a.id}})),...l.flatMap(a=>a.workspaces.flatMap(b=>b.groupAssignments.filter(a=>!1!==a.enabled&&a.agentId).flatMap(b=>{let c=b.agentId;return[{agentId:c,match:{channel:"telegram",accountId:a.id}},{agentId:c,match:{channel:"telegram",accountId:a.id,peer:{kind:"group",id:b.chatId}}}]}))),...m.flatMap(a=>a.workspaces.flatMap(b=>b.groupAssignments.filter(a=>!1!==a.enabled&&a.agentId).map(b=>(0,cc.$T)(a.id,b)).filter(a=>!!a)))],e=new Set,d.filter(a=>{let b=JSON.stringify(a);return!e.has(b)&&(e.add(b),!0)}));await (0,n.rh)(c,"routing.write-bindings",()=>(0,k.rw)().setConfig("bindings",o,{strictJson:!0})),await (0,n.rh)(c,"routing.sync-telegram-settings",()=>cE(l,c)),await (0,n.rh)(c,"routing.sync-discord-settings",()=>cI(m,c))}async function cE(a,b){await (0,n.rh)(b,"telegram-settings.enabled",()=>(0,k.rw)().setConfig("channels.telegram.enabled",a.length>0,{strictJson:!0}));let c=await (0,n.rh)(b,"telegram-settings.default-account-resolve",()=>cH(a,b));c?await (0,n.rh)(b,"telegram-settings.default-account",()=>(0,k.rw)().setConfig("channels.telegram.defaultAccount",c,{strictJson:!0})):await (0,n.rh)(b,"telegram-settings.default-account-unset",()=>(0,k.rw)().unsetConfig("channels.telegram.defaultAccount").catch(()=>{}));let d=Object.fromEntries(a.flatMap(a=>a.workspaces.flatMap(a=>a.groupAssignments.filter(a=>!1!==a.enabled).map(a=>[a.chatId,{requireMention:!0}]))));await (0,n.rh)(b,"telegram-settings.groups",()=>(0,k.rw)().setConfig("channels.telegram.groups",d,{strictJson:!0})),c&&await (0,n.rh)(b,"telegram-settings.reconcile-session-stores",()=>cG(a,c,b))}async function cF(a,b,c,d){try{let f=await (0,n.rh)(d,`telegram-settings.read-session-store.${g().basename(a)}`,()=>(0,e.readFile)(a,"utf8")),h=JSON.parse(f);if(!cr(h))return!1;let i=!1;for(let a of Object.values(h)){if(!function(a){if(!cr(a))return!1;if("telegram"===a.channel||"telegram"===a.lastChannel)return!0;let b=cr(a.deliveryContext)?a.deliveryContext:null;if(b?.channel==="telegram")return!0;let c=cr(a.origin)?a.origin:null;return c?.provider==="telegram"}(a))continue;let d=function(a){let b=(0,ae.Nk)("string"==typeof a.lastAccountId?a.lastAccountId:null);if(b)return b;let c=cr(a.deliveryContext)?a.deliveryContext:null,d=(0,ae.Nk)("string"==typeof c?.accountId?c.accountId:null);if(d)return d;let e=cr(a.origin)?a.origin:null;return(0,ae.Nk)("string"==typeof e?.accountId?e.accountId:null)}(a);!(d&&c.has(d))&&(a.lastAccountId!==b&&(a.lastAccountId=b,i=!0),cr(a.deliveryContext)&&a.deliveryContext.accountId!==b&&(a.deliveryContext.accountId=b,i=!0),cr(a.origin)&&a.origin.accountId!==b&&(a.origin.accountId=b,i=!0))}if(!i)return!1;return await (0,n.rh)(d,`telegram-settings.write-session-store.${g().basename(a)}`,()=>B(a,`${JSON.stringify(h,null,2)}
|
|
255
|
+
`)),!0}catch{return!1}}async function cG(a,b,c){let d=new Set((await (0,cc.QT)()).filter(a=>"telegram"===a.type).map(a=>a.id));for(let f of(d.add(b),cO([g().join(av().homedir(),".openclaw","agents"),...a.flatMap(a=>a.workspaces.map(a=>g().join(a.workspacePath,".openclaw","agents")))]))){let a;try{a=await (0,n.rh)(c,`telegram-settings.read-agent-root.${g().basename(f)}`,()=>(0,e.readdir)(f,{withFileTypes:!0}))}catch{continue}for(let h of a){if(!h.isDirectory())continue;let a=g().join(f,h.name,"sessions","sessions.json");try{await (0,e.access)(a)}catch{continue}await cF(a,b,d,c)}}}async function cH(a,b){let c=(await (0,n.rh)(b,"telegram-settings.read-channel-accounts",()=>(0,cc.QT)())).filter(a=>"telegram"===a.type),d=c.filter(a=>"string"==typeof a.metadata?.botId&&a.metadata.botId.trim().length>0),e=new Set(a.map(a=>a.id));for(let b of a){let a=d.find(a=>a.id===b.id)??null;if(a)return a.id}if(1===d.length)return d[0].id;if(d.length>1){let a=c.find(a=>e.has(a.id)&&"string"==typeof a.metadata?.botId&&a.metadata.botId.trim().length>0)??null;return a?a.id:d[0].id}return a.find(a=>!!a.primaryAgentId)?.id??a[0]?.id??null}async function cI(a,b){if(0===a.length)return;let c=await (0,n.rh)(b,"discord-settings.read-guilds",()=>(0,k.rw)().getConfig("channels.discord.guilds").then(a=>a??{})),d={};for(let[a,b]of Object.entries(c??{}))d[a]=cr(b)?{...b}:{};let e=!1;for(let b of a)for(let a of b.workspaces)for(let b of a.groupAssignments.filter(a=>!1!==a.enabled)){let a=(0,cc.S4)(b.chatId);if(!a?.guildId)continue;let c=d[a.guildId]??{},f=Array.isArray(c.roles)?c.roles.filter(a=>"string"==typeof a||"number"==typeof a).map(a=>String(a)).map(a=>a.trim()).filter(Boolean):[],g=cr(c.channels)?{...c.channels}:{};if(void 0===c.requireMention&&(c.requireMention=!0,e=!0),"role"===a.kind)f.includes(a.targetId)||(f.push(a.targetId),e=!0),c.roles=f;else{for(let b of cO([a.targetId,"thread"===a.kind?a.parentId??"":""].filter(Boolean))){let a=cr(g[b])?g[b]:{};!0!==a.allow&&(a.allow=!0,e=!0),void 0===a.requireMention&&(a.requireMention=!0,e=!0),g[b]=a}c.channels=g}d[a.guildId]=c}e&&await (0,n.rh)(b,"discord-settings.write-guilds",()=>(0,k.rw)().setConfig("channels.discord.guilds",d,{strictJson:!0}))}function cJ(a){return a?cO([a.primaryAgentId??"",...a.workspaces.flatMap(a=>[...a.agentIds,...a.groupAssignments.filter(a=>!1!==a.enabled&&a.agentId).map(a=>a.agentId)])]):[]}function cK(a){return a?{id:a.id,name:a.name,primaryAgentId:a.primaryAgentId??null,workspaces:a.workspaces.map(a=>({workspaceId:a.workspaceId,workspacePath:a.workspacePath,agentIds:cO([...a.agentIds]).sort(),groupAssignments:a.groupAssignments.map(a=>({chatId:a.chatId,agentId:a.agentId??null,title:a.title??null,enabled:!1!==a.enabled})).sort((a,b)=>{let c=`${a.chatId}:${a.agentId??""}:${a.title??""}:${a.enabled}`,d=`${b.chatId}:${b.agentId??""}:${b.title??""}:${b.enabled}`;return c.localeCompare(d)})})).sort((a,b)=>a.workspaceId.localeCompare(b.workspaceId))}:null}async function cL(a,b={}){let c=cO(a);if(0===c.length)return;let e=b.snapshot??await (0,n.rh)(b.timings,"agent-policy.snapshot",()=>(0,d.GM)({includeHidden:!0})),f=b.channelRegistry?{...e,channelRegistry:b.channelRegistry}:e;for(let a of c)await (0,n.rh)(b.timings,`agent-policy.sync-agent.${a}`,async()=>{let c=f.agents.find(b=>b.id===a);if(!c)return;let d=f.agents.find(a=>a.workspaceId===c.workspaceId&&"setup"===a.policy.preset&&a.id!==c.id)?.id??null,e=await Z({workspacePath:c.workspacePath,agentId:c.id,agentName:c.name,policy:c.policy,setupAgentId:d,snapshot:f,channelRegistry:b.channelRegistry,timings:b.timings});await (0,l.jq)(c.id,c.workspacePath,{name:c.name,model:(0,ae.Nk)(c.modelId),heartbeat:c.heartbeat.enabled&&c.heartbeat.every?{every:c.heartbeat.every}:null,skills:[...(0,l.AB)(c.skills),e],tools:c.tools.includes("fs.workspaceOnly")?{fs:{workspaceOnly:!0}}:null},f,b.timings)})}async function cM(a,b,c){let e=await (0,n.rh)(c,"telegram-coordination.collect-changes",()=>{let c=new Map(a.channels.filter(a=>"telegram"===a.type).map(a=>[a.id,a])),d=new Map(b.channels.filter(a=>"telegram"===a.type).map(a=>[a.id,a]));return cO(cO([...c.keys(),...d.keys()]).flatMap(a=>{let b=c.get(a)??null,e=d.get(a)??null;return JSON.stringify(cK(b))===JSON.stringify(cK(e))?[]:[...cJ(b),...cJ(e)]}))});if(0===e.length)return;let f=await (0,n.rh)(c,"telegram-coordination.snapshot",()=>(0,d.GM)({includeHidden:!0}));await (0,n.rh)(c,"telegram-coordination.sync-agent-policies",()=>cL(e,{snapshot:f,channelRegistry:b,timings:c}))}async function cN(a,b={},c){let d=cB(await (0,n.rh)(c,"channel-registry.read",()=>(0,cc.vg)())),e=cB(d);await (0,n.rh)(c,"channel-registry.mutate",()=>a(d)),await (0,n.rh)(c,"channel-registry.save",()=>cC(d)),await (0,n.rh)(c,"channel-registry.update-routing",()=>cD(d,b,c)),ce(),await (0,n.rh)(c,"channel-registry.sync-telegram-coordination",()=>cM(e,d,c))}function cO(a){return Array.from(new Set(a.filter(Boolean)))}function cP(a){return(0,ae.Nk)(a)??""}function cQ(a){return"internal"===a||"slack"===a||"telegram"===a||"discord"===a||"googlechat"===a}function cR(a){return a.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function cS(a){return Array.from(new Set(a.map(a=>cU(a)).filter(a=>!!a)))}function cT(a){return"string"==typeof a?a.trim():""}function cU(a){if("string"!=typeof a)return null;let b=a.trim();return b.length>0?b:null}let cV=async function(a={}){let b;return{...b=structuredClone(await (0,d.GM)(a)),missionPresets:cS(b.missionPresets),channelAccounts:function(a){let b=new Map;for(let c of a){let a=cT(c.id),d=cT(c.type);if(!a||!d)continue;let e={...c,id:a,type:d,name:cT(c.name)||a,enabled:!1!==c.enabled,metadata:c.metadata?{...c.metadata}:void 0,capabilities:cS(c.capabilities??[])},f=`${d}:${a}`,g=b.get(f);if(!g){b.set(f,e);continue}b.set(f,{...g,name:g.name||e.name,enabled:!1!==g.enabled,kind:g.kind??e.kind,capabilities:cS([...g.capabilities??[],...e.capabilities??[]]),metadata:{...e.metadata??{},...g.metadata??{}}})}return Array.from(b.values())}(b.channelAccounts),channelRegistry:function(a){let b=a.channels.map(a=>{var b;let c,d;return c=cT((b=a).id),d=cT(b.type),c&&d?{...b,id:c,type:d,name:cT(b.name)||c,primaryAgentId:cU(b.primaryAgentId),workspaces:b.workspaces.map(a=>({...a,workspaceId:cT(a.workspaceId),workspacePath:cT(a.workspacePath),agentIds:cS(a.agentIds),groupAssignments:a.groupAssignments.map(a=>({...a,chatId:cT(a.chatId),agentId:cU(a.agentId),title:cU(a.title),enabled:!1!==a.enabled})).filter(a=>!!a.chatId)})).filter(a=>!!a.workspaceId&&!!a.workspacePath)}:null}).filter(a=>!!a),c=new Map;for(let a of b){let b=c.get(a.id);if(!b){c.set(a.id,a);continue}let d=new Map;for(let a of b.workspaces)d.set(a.workspaceId,a);for(let b of a.workspaces){let a=d.get(b.workspaceId);if(!a){d.set(b.workspaceId,b);continue}d.set(b.workspaceId,{...a,agentIds:cS([...a.agentIds,...b.agentIds]),groupAssignments:function(a){let b=new Map;for(let c of a)c.chatId&&b.set(c.chatId,c);return Array.from(b.values())}([...a.groupAssignments,...b.groupAssignments])})}c.set(a.id,{...b,name:b.name||a.name,primaryAgentId:b.primaryAgentId||a.primaryAgentId,workspaces:Array.from(d.values())})}return{version:1,channels:Array.from(c.values())}}(b.channelRegistry)}}}};
|