agentroam-runtime-win32-x64 0.2.0-preview.32 → 0.2.0-preview.33
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/manifest.json +1 -1
- package/package.json +1 -1
- package/runtime/.next/BUILD_ID +1 -1
- package/runtime/.next/app-path-routes-manifest.json +1 -1
- package/runtime/.next/build-manifest.json +2 -2
- package/runtime/.next/prerender-manifest.json +1 -1
- package/runtime/.next/server/app/_not-found.html +1 -1
- package/runtime/.next/server/app/_not-found.rsc +1 -1
- package/runtime/.next/server/app/api/agent/run/route.js +1 -1
- package/runtime/.next/server/app/api/flow/v1/catalog/route.js +1 -1
- package/runtime/.next/server/app/api/flow/v1/runs/[runId]/cancel/route.js +1 -1
- package/runtime/.next/server/app/api/flow/v1/runs/[runId]/events/route.js +3 -3
- package/runtime/.next/server/app/api/flow/v1/runs/route.js +1 -1
- package/runtime/.next/server/app/api/tool-policies/[policyId]/route.js +1 -1
- package/runtime/.next/server/app/api/tool-policies/route.js +1 -1
- package/runtime/.next/server/app/web.html +1 -1
- package/runtime/.next/server/app/web.rsc +1 -1
- package/runtime/.next/server/app-paths-manifest.json +30 -30
- package/runtime/.next/server/chunks/1773.js +3 -3
- package/runtime/.next/server/pages/404.html +1 -1
- package/runtime/.next/server/pages/500.html +1 -1
- package/runtime/.next/server/pages-manifest.json +1 -1
- package/runtime/.next/server/server-reference-manifest.json +1 -1
- package/runtime/lib/remote-control/macos-display-bridge.mjs +75 -0
- package/runtime/lib/remote-control/remote-authorization.mjs +50 -13
- package/runtime/node_modules/.package-lock.json +3 -3
- package/runtime/node_modules/@agent/native-runtime/dist/index.js +22 -4
- package/runtime/node_modules/mediabunny/dist/bundles/mediabunny.cjs +56 -30
- package/runtime/node_modules/mediabunny/dist/bundles/mediabunny.min.cjs +17 -17
- package/runtime/node_modules/mediabunny/dist/bundles/mediabunny.min.mjs +17 -17
- package/runtime/node_modules/mediabunny/dist/bundles/mediabunny.mjs +56 -30
- package/runtime/node_modules/mediabunny/dist/bundles/mediabunny.node.cjs +56 -30
- package/runtime/node_modules/mediabunny/dist/modules/src/codec.js +1 -1
- package/runtime/node_modules/mediabunny/dist/modules/src/conversion.js +2 -0
- package/runtime/node_modules/mediabunny/dist/modules/src/hls/hls-muxer.js +33 -3
- package/runtime/node_modules/mediabunny/dist/modules/src/matroska/matroska-demuxer.js +4 -15
- package/runtime/node_modules/mediabunny/dist/modules/src/matroska/matroska-muxer.js +15 -17
- package/runtime/node_modules/mediabunny/dist/modules/src/output.js +6 -0
- package/runtime/node_modules/mediabunny/dist/modules/src/tsconfig.tsbuildinfo +1 -1
- package/runtime/node_modules/mediabunny/package.json +1 -1
- package/runtime/node_modules/mediabunny/src/codec.ts +1 -1
- package/runtime/node_modules/mediabunny/src/conversion.ts +2 -0
- package/runtime/node_modules/mediabunny/src/hls/hls-muxer.ts +42 -3
- package/runtime/node_modules/mediabunny/src/matroska/matroska-demuxer.ts +4 -17
- package/runtime/node_modules/mediabunny/src/matroska/matroska-muxer.ts +19 -18
- package/runtime/node_modules/mediabunny/src/output.ts +11 -0
- package/runtime/package-lock.json +3 -3
- package/runtime/webapp/dist/assets/App-Ca0WadsD.js +466 -0
- package/runtime/webapp/dist/assets/{abnfDiagram-VCTEODGH-kiXF0EOS.js → abnfDiagram-VCTEODGH-BDpkyhAZ.js} +1 -1
- package/runtime/webapp/dist/assets/{arc-DLOYXSxU.js → arc-CoonOPJ4.js} +1 -1
- package/runtime/webapp/dist/assets/{architectureDiagram-5GKGNRK7-B_lcxKne.js → architectureDiagram-5GKGNRK7-wuwPBVHW.js} +1 -1
- package/runtime/webapp/dist/assets/{blockDiagram-I7D4REHJ-DjqqqvVj.js → blockDiagram-I7D4REHJ-Euqw1exH.js} +1 -1
- package/runtime/webapp/dist/assets/{c4Diagram-7LVT6UL2-CODP1iDY.js → c4Diagram-7LVT6UL2-BZHvYj6y.js} +1 -1
- package/runtime/webapp/dist/assets/channel-C24_pGE1.js +1 -0
- package/runtime/webapp/dist/assets/{chunk-2Q5K7J3B-C6HBlJUd.js → chunk-2Q5K7J3B-xT62y3wQ.js} +1 -1
- package/runtime/webapp/dist/assets/{chunk-5VM5RSS4-DNXwyz9n.js → chunk-5VM5RSS4-DlPRNiGt.js} +1 -1
- package/runtime/webapp/dist/assets/{chunk-F27PBJKO-B4ChByJ5.js → chunk-F27PBJKO-CHfSMpxl.js} +1 -1
- package/runtime/webapp/dist/assets/{chunk-IMKFNOWR-DBJpcH73.js → chunk-IMKFNOWR-D9VJCA0z.js} +1 -1
- package/runtime/webapp/dist/assets/{chunk-JWPE2WC7-6fo4swqM.js → chunk-JWPE2WC7-DWgKLgPn.js} +1 -1
- package/runtime/webapp/dist/assets/{chunk-POPQ4Y6H-tuBSaVU3.js → chunk-POPQ4Y6H-DvvKwtyT.js} +1 -1
- package/runtime/webapp/dist/assets/{chunk-SVP7TREG-Dw6ARyG-.js → chunk-SVP7TREG-Co4mbeuU.js} +1 -1
- package/runtime/webapp/dist/assets/{chunk-TICWLB2K-DbBF_5yf.js → chunk-TICWLB2K-DWlVCBWn.js} +1 -1
- package/runtime/webapp/dist/assets/{chunk-XXDRQBXY-DT9w3Lol.js → chunk-XXDRQBXY-aWK0bDdf.js} +1 -1
- package/runtime/webapp/dist/assets/classDiagram-ZZMXUADV-DBqDZpzz.js +1 -0
- package/runtime/webapp/dist/assets/classDiagram-v2-VYDZK3BY-DBqDZpzz.js +1 -0
- package/runtime/webapp/dist/assets/{cose-bilkent-JH36ORCC-C9VAFI4s.js → cose-bilkent-JH36ORCC-BwyPX8p0.js} +1 -1
- package/runtime/webapp/dist/assets/{cynefin-OW5HDTMX-m9pEhlym.js → cynefin-OW5HDTMX-CptUmfbX.js} +1 -1
- package/runtime/webapp/dist/assets/{cynefinDiagram-5FMLGOSQ-Bv0S96vV.js → cynefinDiagram-5FMLGOSQ-C2eq2Hu9.js} +1 -1
- package/runtime/webapp/dist/assets/{dagre-GXQ25YYZ-BTE_R2UK.js → dagre-GXQ25YYZ-Dprq5nEX.js} +1 -1
- package/runtime/webapp/dist/assets/{diagram-S7CK7UJ4-BuopSoHC.js → diagram-S7CK7UJ4-sh1ZPP9m.js} +1 -1
- package/runtime/webapp/dist/assets/{diagram-UQ7AKVKN-aovG-t5R.js → diagram-UQ7AKVKN-BQaObqKH.js} +1 -1
- package/runtime/webapp/dist/assets/{diagram-VSXAHHWV-qzvRHE22.js → diagram-VSXAHHWV-CtzUlo-n.js} +1 -1
- package/runtime/webapp/dist/assets/{diagram-VX7I27RA-CQEG6P66.js → diagram-VX7I27RA-9vcFUH8Z.js} +1 -1
- package/runtime/webapp/dist/assets/{diagram-Z3DM3KII-B22Wnz0M.js → diagram-Z3DM3KII-DjYuent5.js} +1 -1
- package/runtime/webapp/dist/assets/{ebnfDiagram-PWID7BFC-DBBSliz-.js → ebnfDiagram-PWID7BFC-C6_4YUCW.js} +1 -1
- package/runtime/webapp/dist/assets/{erDiagram-RLTQ6QDP-CPUZJ4Ym.js → erDiagram-RLTQ6QDP-Hwn1lZwh.js} +1 -1
- package/runtime/webapp/dist/assets/{flowDiagram-HODETNUW-BV9XM3rT.js → flowDiagram-HODETNUW-C9UrtPhP.js} +1 -1
- package/runtime/webapp/dist/assets/{ganttDiagram-EL5Y4UJY-D2sbPOC6.js → ganttDiagram-EL5Y4UJY-as-gjhju.js} +1 -1
- package/runtime/webapp/dist/assets/{gitGraphDiagram-WWUBYQGX-pRRRu-Yk.js → gitGraphDiagram-WWUBYQGX-Cg5RyZdN.js} +1 -1
- package/runtime/webapp/dist/assets/{index-Cc0W70yE.js → index-BLq6a3Ak.js} +26 -26
- package/runtime/webapp/dist/assets/index-DSKRyyLo.css +1 -0
- package/runtime/webapp/dist/assets/{infoDiagram-27XIBGKW-Ds2ihp_0.js → infoDiagram-27XIBGKW-BkdHkG1X.js} +1 -1
- package/runtime/webapp/dist/assets/{ishikawaDiagram-5VMMS53U-DK2ApntG.js → ishikawaDiagram-5VMMS53U-C_YGZnKZ.js} +1 -1
- package/runtime/webapp/dist/assets/{journeyDiagram-3NMN7TZE-Cd4mGqFJ.js → journeyDiagram-3NMN7TZE-DYPDxTGx.js} +1 -1
- package/runtime/webapp/dist/assets/{kanban-definition-UXKFOSKX-BXk_BwB7.js → kanban-definition-UXKFOSKX-FsgjwhbY.js} +1 -1
- package/runtime/webapp/dist/assets/{layout-Cs8RA1qE.js → layout-DTtvyqVc.js} +1 -1
- package/runtime/webapp/dist/assets/{linear-BIZcERa2.js → linear-ty-wH9rK.js} +1 -1
- package/runtime/webapp/dist/assets/{mermaid.core-CVdHC_lA.js → mermaid.core-D7iudgSG.js} +5 -5
- package/runtime/webapp/dist/assets/{mindmap-definition-YA3MSWOX-BDNXbFgP.js → mindmap-definition-YA3MSWOX-_Xo6nzac.js} +1 -1
- package/runtime/webapp/dist/assets/{pegDiagram-XKGWAZYB-BBqoJGdC.js → pegDiagram-XKGWAZYB-CvWvncJ-.js} +1 -1
- package/runtime/webapp/dist/assets/{pieDiagram-E7YTZNPT-Ct6klm4D.js → pieDiagram-E7YTZNPT-Cub5U9la.js} +1 -1
- package/runtime/webapp/dist/assets/{quadrantDiagram-AXDQQJYC-B1EHBQZa.js → quadrantDiagram-AXDQQJYC-DMRK-tzO.js} +1 -1
- package/runtime/webapp/dist/assets/{railroadDiagram-O6MQD6OU-Km1srO_R.js → railroadDiagram-O6MQD6OU-DzN_Dh96.js} +1 -1
- package/runtime/webapp/dist/assets/{requirementDiagram-BXWQKSXE-CQBVuMhl.js → requirementDiagram-BXWQKSXE-DCwv3UY2.js} +1 -1
- package/runtime/webapp/dist/assets/{sankeyDiagram-P5KCCOFB-BGC0Kf2M.js → sankeyDiagram-P5KCCOFB-DyQDWv9w.js} +1 -1
- package/runtime/webapp/dist/assets/{sequenceDiagram-WJ2MYXX4-B_OLbyy2.js → sequenceDiagram-WJ2MYXX4-DCSuH_KO.js} +1 -1
- package/runtime/webapp/dist/assets/{sizeCapture-INFHLROL-BYtazXqN.js → sizeCapture-INFHLROL-CWHQNFiZ.js} +1 -1
- package/runtime/webapp/dist/assets/{stateDiagram-D77RDMKH-COVC80j1.js → stateDiagram-D77RDMKH-Kao_in5d.js} +1 -1
- package/runtime/webapp/dist/assets/stateDiagram-v2-MP3YSRHH-Cd7ycLTo.js +1 -0
- package/runtime/webapp/dist/assets/{swimlanes-42K2YHIH-i3JoZJqW.js → swimlanes-42K2YHIH-CbT_lTB4.js} +1 -1
- package/runtime/webapp/dist/assets/swimlanesDiagram-VR7AAH4N-CV6ZKqFC.js +8 -0
- package/runtime/webapp/dist/assets/{timeline-definition-24CTP7MA-Cdr3r9sY.js → timeline-definition-24CTP7MA-DrWqbjYL.js} +1 -1
- package/runtime/webapp/dist/assets/{vennDiagram-4TSXK5OY-DlDVPB2p.js → vennDiagram-4TSXK5OY-BxwvuhgN.js} +1 -1
- package/runtime/webapp/dist/assets/{wardleyDiagram-VM6X3IG4-CQeyjrzG.js → wardleyDiagram-VM6X3IG4-C8431raJ.js} +1 -1
- package/runtime/webapp/dist/assets/{web-BhIIPzjV.js → web-C2wfynqH.js} +1 -1
- package/runtime/webapp/dist/assets/{web-CwyKhHsY.js → web-CaG-BHyZ.js} +1 -1
- package/runtime/webapp/dist/assets/{xychartDiagram-S5SC5T6Z-bXRnQIK9.js → xychartDiagram-S5SC5T6Z-D1S6pJj4.js} +1 -1
- package/runtime/webapp/dist/index.html +2 -2
- package/runtime/webapp/dist/assets/App-HDWwQok9.js +0 -466
- package/runtime/webapp/dist/assets/channel-ECutZLwo.js +0 -1
- package/runtime/webapp/dist/assets/classDiagram-ZZMXUADV-BRsnP6Uo.js +0 -1
- package/runtime/webapp/dist/assets/classDiagram-v2-VYDZK3BY-BRsnP6Uo.js +0 -1
- package/runtime/webapp/dist/assets/index-Cd9aSuLC.css +0 -1
- package/runtime/webapp/dist/assets/stateDiagram-v2-MP3YSRHH-Bc74Oyzz.js +0 -1
- package/runtime/webapp/dist/assets/swimlanesDiagram-VR7AAH4N-QfszQ--p.js +0 -8
- /package/runtime/.next/static/{VvfEjQhZtTBIuUl6k7xKg → iTewNFIZtv6Wt6WCv8Scy}/_buildManifest.js +0 -0
- /package/runtime/.next/static/{VvfEjQhZtTBIuUl6k7xKg → iTewNFIZtv6Wt6WCv8Scy}/_ssgManifest.js +0 -0
package/manifest.json
CHANGED
package/package.json
CHANGED
package/runtime/.next/BUILD_ID
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
iTewNFIZtv6Wt6WCv8Scy
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"/_not-found/page":"/_not-found","/api/flow/v1/runs/[runId]/events/route":"/api/flow/v1/runs/[runId]/events","/api/
|
|
1
|
+
{"/_not-found/page":"/_not-found","/api/flow/v1/runs/[runId]/events/route":"/api/flow/v1/runs/[runId]/events","/api/auth/verify/route":"/api/auth/verify","/api/flow/v1/runs/[runId]/cancel/route":"/api/flow/v1/runs/[runId]/cancel","/api/mcp/connect/route":"/api/mcp/connect","/api/flow/v1/runs/route":"/api/flow/v1/runs","/api/mcp/disconnect/route":"/api/mcp/disconnect","/api/memory/[key]/route":"/api/memory/[key]","/api/memory/route":"/api/memory","/api/projects/[id]/route":"/api/projects/[id]","/api/mcp/servers/route":"/api/mcp/servers","/api/plugins/load/route":"/api/plugins/load","/api/projects/roots/route":"/api/projects/roots","/api/push/subscribe/route":"/api/push/subscribe","/api/projects/check/route":"/api/projects/check","/api/projects/route":"/api/projects","/api/projects/directories/route":"/api/projects/directories","/api/push/unsubscribe/route":"/api/push/unsubscribe","/api/push/vapid/route":"/api/push/vapid","/api/remote-tools/register/route":"/api/remote-tools/register","/api/skills/route":"/api/skills","/api/tools/route":"/api/tools","/api/web-auth/login/route":"/api/web-auth/login","/api/tool-policies/[policyId]/route":"/api/tool-policies/[policyId]","/api/web-auth/revoke-all/route":"/api/web-auth/revoke-all","/api/web-auth/setup/route":"/api/web-auth/setup","/api/web-auth/logout/route":"/api/web-auth/logout","/api/web-console/preferences/route":"/api/web-console/preferences","/api/web-console/history/route":"/api/web-console/history","/api/agent/abort/route":"/api/agent/abort","/api/agent/harness/status/route":"/api/agent/harness/status","/api/agent-workspaces/[workspaceId]/sessions/route":"/api/agent-workspaces/[workspaceId]/sessions","/web/page":"/web","/api/agent/model/route":"/api/agent/model","/api/agent/models/route":"/api/agent/models","/api/agent/answer/route":"/api/agent/answer","/api/agent-workspaces/route":"/api/agent-workspaces","/api/business/route":"/api/business","/api/flow/v1/catalog/route":"/api/flow/v1/catalog","/api/agent/steer/route":"/api/agent/steer","/api/agent/runtime-health/route":"/api/agent/runtime-health","/api/client-logs/route":"/api/client-logs","/api/sessions/[id]/changes/route":"/api/sessions/[id]/changes","/api/sessions/[id]/fork/route":"/api/sessions/[id]/fork","/api/sessions/[id]/query-index/route":"/api/sessions/[id]/query-index","/api/agent/run/route":"/api/agent/run","/api/sessions/[id]/thread-goal/route":"/api/sessions/[id]/thread-goal","/api/sessions/[id]/tool-result/route":"/api/sessions/[id]/tool-result","/api/agent/stream/route":"/api/agent/stream","/api/sessions/[id]/goals/route":"/api/sessions/[id]/goals","/api/sessions/[id]/route":"/api/sessions/[id]","/api/sessions/route":"/api/sessions","/api/sessions/[id]/release/route":"/api/sessions/[id]/release","/api/update/status/route":"/api/update/status","/api/settings/route":"/api/settings","/api/update/check/route":"/api/update/check","/api/tool-policies/route":"/api/tool-policies","/api/update/install/route":"/api/update/install","/api/web-console/bootstrap/route":"/api/web-console/bootstrap","/api/web-auth/status/route":"/api/web-auth/status","/api/web-console/device-state/route":"/api/web-console/device-state","/api/sessions/[id]/handoff/route":"/api/sessions/[id]/handoff"}
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
"devFiles": [],
|
|
6
6
|
"ampDevFiles": [],
|
|
7
7
|
"lowPriorityFiles": [
|
|
8
|
-
"static/
|
|
9
|
-
"static/
|
|
8
|
+
"static/iTewNFIZtv6Wt6WCv8Scy/_buildManifest.js",
|
|
9
|
+
"static/iTewNFIZtv6Wt6WCv8Scy/_ssgManifest.js"
|
|
10
10
|
],
|
|
11
11
|
"rootMainFiles": [
|
|
12
12
|
"static/chunks/webpack-005b9ea17f53f126.js",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":4,"routes":{"/api/mcp/servers":{"initialHeaders":{"content-type":"application/json","x-next-cache-tags":"_N_T_/layout,_N_T_/api/layout,_N_T_/api/mcp/layout,_N_T_/api/mcp/servers/layout,_N_T_/api/mcp/servers/route,_N_T_/api/mcp/servers"},"experimentalBypassFor":[{"type":"header","key":"Next-Action"},{"type":"header","key":"content-type","value":"multipart/form-data;.*"}],"initialRevalidateSeconds":false,"srcRoute":"/api/mcp/servers","dataRoute":null},"/api/projects/roots":{"initialHeaders":{"cache-control":"no-store","content-type":"application/json","x-next-cache-tags":"_N_T_/layout,_N_T_/api/layout,_N_T_/api/projects/layout,_N_T_/api/projects/roots/layout,_N_T_/api/projects/roots/route,_N_T_/api/projects/roots"},"experimentalBypassFor":[{"type":"header","key":"Next-Action"},{"type":"header","key":"content-type","value":"multipart/form-data;.*"}],"initialRevalidateSeconds":false,"srcRoute":"/api/projects/roots","dataRoute":null},"/api/
|
|
1
|
+
{"version":4,"routes":{"/api/mcp/servers":{"initialHeaders":{"content-type":"application/json","x-next-cache-tags":"_N_T_/layout,_N_T_/api/layout,_N_T_/api/mcp/layout,_N_T_/api/mcp/servers/layout,_N_T_/api/mcp/servers/route,_N_T_/api/mcp/servers"},"experimentalBypassFor":[{"type":"header","key":"Next-Action"},{"type":"header","key":"content-type","value":"multipart/form-data;.*"}],"initialRevalidateSeconds":false,"srcRoute":"/api/mcp/servers","dataRoute":null},"/api/projects/roots":{"initialHeaders":{"cache-control":"no-store","content-type":"application/json","x-next-cache-tags":"_N_T_/layout,_N_T_/api/layout,_N_T_/api/projects/layout,_N_T_/api/projects/roots/layout,_N_T_/api/projects/roots/route,_N_T_/api/projects/roots"},"experimentalBypassFor":[{"type":"header","key":"Next-Action"},{"type":"header","key":"content-type","value":"multipart/form-data;.*"}],"initialRevalidateSeconds":false,"srcRoute":"/api/projects/roots","dataRoute":null},"/api/tools":{"initialHeaders":{"content-type":"application/json","x-next-cache-tags":"_N_T_/layout,_N_T_/api/layout,_N_T_/api/tools/layout,_N_T_/api/tools/route,_N_T_/api/tools"},"experimentalBypassFor":[{"type":"header","key":"Next-Action"},{"type":"header","key":"content-type","value":"multipart/form-data;.*"}],"initialRevalidateSeconds":false,"srcRoute":"/api/tools","dataRoute":null},"/web":{"experimentalBypassFor":[{"type":"header","key":"Next-Action"},{"type":"header","key":"content-type","value":"multipart/form-data;.*"}],"initialRevalidateSeconds":false,"srcRoute":"/web","dataRoute":"/web.rsc"},"/api/push/vapid":{"initialHeaders":{"content-type":"application/json","x-next-cache-tags":"_N_T_/layout,_N_T_/api/layout,_N_T_/api/push/layout,_N_T_/api/push/vapid/layout,_N_T_/api/push/vapid/route,_N_T_/api/push/vapid"},"experimentalBypassFor":[{"type":"header","key":"Next-Action"},{"type":"header","key":"content-type","value":"multipart/form-data;.*"}],"initialRevalidateSeconds":false,"srcRoute":"/api/push/vapid","dataRoute":null}},"dynamicRoutes":{},"notFoundRoutes":[],"preview":{"previewModeId":"a1ee9a7076634e8e432d329493d45b09","previewModeSigningKey":"fc0c8656b9727b286281ff89c08bdc6da72c88b17dde4a59fec992366f20175f","previewModeEncryptionKey":"ec4ff89711f5b04ee900b0a767bc3ccebeae81fb875652a55fde830ca564b3f8"}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="preload" as="script" fetchPriority="low" href="/_next/static/chunks/webpack-005b9ea17f53f126.js"/><script src="/_next/static/chunks/3cc391f0-d7ec74603652803d.js" async=""></script><script src="/_next/static/chunks/183-d2f78a21998813ba.js" async=""></script><script src="/_next/static/chunks/main-app-6226257cbf59e19d.js" async=""></script><meta name="robots" content="noindex"/><title>404: This page could not be found.</title><meta name="theme-color" content="#f5f6fa"/><title>AgentRoam</title><meta name="description" content="General-purpose AI agent API server"/><link rel="manifest" href="/manifest.webmanifest" crossorigin="use-credentials"/><meta name="apple-mobile-web-app-capable" content="yes"/><meta name="apple-mobile-web-app-title" content="AgentRoam"/><meta name="apple-mobile-web-app-status-bar-style" content="default"/><link rel="icon" href="/pwa/icon-192.png"/><link rel="apple-touch-icon" href="/pwa/icon-192.png"/><script src="/_next/static/chunks/polyfills-42372ed130431b0a.js" noModule=""></script></head><body><div style="font-family:system-ui,"Segoe UI",Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center"><div><style>body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}</style><h1 class="next-error-h1" style="display:inline-block;margin:0 20px 0 0;padding:0 23px 0 0;font-size:24px;font-weight:500;vertical-align:top;line-height:49px">404</h1><div style="display:inline-block"><h2 style="font-size:14px;font-weight:400;line-height:49px;margin:0">This page could not be found.</h2></div></div></div><script src="/pwa/install.js" defer=""></script><script src="/_next/static/chunks/webpack-005b9ea17f53f126.js" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0]);self.__next_f.push([2,null])</script><script>self.__next_f.push([1,"1:I[7709,[],\"\"]\n3:I[1338,[],\"\"]\n4:I[1573,[],\"\"]\na:I[6554,[],\"\"]\n5:{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"}\n6:{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"padding\":\"0 23px 0 0\",\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\",\"lineHeight\":\"49px\"}\n7:{\"display\":\"inline-block\"}\n8:{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"49px\",\"margin\":0}\nb:[]\n"])</script><script>self.__next_f.push([1,"0:[\"$\",\"$L1\",null,{\"buildId\":\"
|
|
1
|
+
<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="preload" as="script" fetchPriority="low" href="/_next/static/chunks/webpack-005b9ea17f53f126.js"/><script src="/_next/static/chunks/3cc391f0-d7ec74603652803d.js" async=""></script><script src="/_next/static/chunks/183-d2f78a21998813ba.js" async=""></script><script src="/_next/static/chunks/main-app-6226257cbf59e19d.js" async=""></script><meta name="robots" content="noindex"/><title>404: This page could not be found.</title><meta name="theme-color" content="#f5f6fa"/><title>AgentRoam</title><meta name="description" content="General-purpose AI agent API server"/><link rel="manifest" href="/manifest.webmanifest" crossorigin="use-credentials"/><meta name="apple-mobile-web-app-capable" content="yes"/><meta name="apple-mobile-web-app-title" content="AgentRoam"/><meta name="apple-mobile-web-app-status-bar-style" content="default"/><link rel="icon" href="/pwa/icon-192.png"/><link rel="apple-touch-icon" href="/pwa/icon-192.png"/><script src="/_next/static/chunks/polyfills-42372ed130431b0a.js" noModule=""></script></head><body><div style="font-family:system-ui,"Segoe UI",Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center"><div><style>body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}</style><h1 class="next-error-h1" style="display:inline-block;margin:0 20px 0 0;padding:0 23px 0 0;font-size:24px;font-weight:500;vertical-align:top;line-height:49px">404</h1><div style="display:inline-block"><h2 style="font-size:14px;font-weight:400;line-height:49px;margin:0">This page could not be found.</h2></div></div></div><script src="/pwa/install.js" defer=""></script><script src="/_next/static/chunks/webpack-005b9ea17f53f126.js" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0]);self.__next_f.push([2,null])</script><script>self.__next_f.push([1,"1:I[7709,[],\"\"]\n3:I[1338,[],\"\"]\n4:I[1573,[],\"\"]\na:I[6554,[],\"\"]\n5:{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"}\n6:{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"padding\":\"0 23px 0 0\",\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\",\"lineHeight\":\"49px\"}\n7:{\"display\":\"inline-block\"}\n8:{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"49px\",\"margin\":0}\nb:[]\n"])</script><script>self.__next_f.push([1,"0:[\"$\",\"$L1\",null,{\"buildId\":\"iTewNFIZtv6Wt6WCv8Scy\",\"assetPrefix\":\"\",\"urlParts\":[\"\",\"_not-found\"],\"initialTree\":[\"\",{\"children\":[\"/_not-found\",{\"children\":[\"__PAGE__\",{}]}]},\"$undefined\",\"$undefined\",true],\"initialSeedData\":[\"\",{\"children\":[\"/_not-found\",{\"children\":[\"__PAGE__\",{},[[\"$L2\",[[\"$\",\"title\",null,{\"children\":\"404: This page could not be found.\"}],[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"padding\":\"0 23px 0 0\",\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\",\"lineHeight\":\"49px\"},\"children\":\"404\"}],[\"$\",\"div\",null,{\"style\":{\"display\":\"inline-block\"},\"children\":[\"$\",\"h2\",null,{\"style\":{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"49px\",\"margin\":0},\"children\":\"This page could not be found.\"}]}]]}]}]],null],null],null]},[null,[\"$\",\"$L3\",null,{\"parallelRouterKey\":\"children\",\"segmentPath\":[\"children\",\"/_not-found\",\"children\"],\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L4\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"notFoundStyles\":\"$undefined\"}]],null]},[[null,[\"$\",\"html\",null,{\"lang\":\"en\",\"children\":[\"$\",\"body\",null,{\"children\":[[\"$\",\"$L3\",null,{\"parallelRouterKey\":\"children\",\"segmentPath\":[\"children\"],\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L4\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":[[\"$\",\"title\",null,{\"children\":\"404: This page could not be found.\"}],[\"$\",\"div\",null,{\"style\":\"$5\",\"children\":[\"$\",\"div\",null,{\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":\"$6\",\"children\":\"404\"}],[\"$\",\"div\",null,{\"style\":\"$7\",\"children\":[\"$\",\"h2\",null,{\"style\":\"$8\",\"children\":\"This page could not be found.\"}]}]]}]}]],\"notFoundStyles\":[]}],[\"$\",\"script\",null,{\"src\":\"/pwa/install.js\",\"defer\":true}]]}]}]],null],null],\"couldBeIntercepted\":false,\"initialHead\":[[\"$\",\"meta\",null,{\"name\":\"robots\",\"content\":\"noindex\"}],\"$L9\"],\"globalErrorComponent\":\"$a\",\"missingSlots\":\"$Wb\"}]\n"])</script><script>self.__next_f.push([1,"9:[[\"$\",\"meta\",\"0\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}],[\"$\",\"meta\",\"1\",{\"name\":\"theme-color\",\"content\":\"#f5f6fa\"}],[\"$\",\"meta\",\"2\",{\"charSet\":\"utf-8\"}],[\"$\",\"title\",\"3\",{\"children\":\"AgentRoam\"}],[\"$\",\"meta\",\"4\",{\"name\":\"description\",\"content\":\"General-purpose AI agent API server\"}],[\"$\",\"link\",\"5\",{\"rel\":\"manifest\",\"href\":\"/manifest.webmanifest\",\"crossOrigin\":\"use-credentials\"}],[\"$\",\"meta\",\"6\",{\"name\":\"apple-mobile-web-app-capable\",\"content\":\"yes\"}],[\"$\",\"meta\",\"7\",{\"name\":\"apple-mobile-web-app-title\",\"content\":\"AgentRoam\"}],[\"$\",\"meta\",\"8\",{\"name\":\"apple-mobile-web-app-status-bar-style\",\"content\":\"default\"}],[\"$\",\"link\",\"9\",{\"rel\":\"icon\",\"href\":\"/pwa/icon-192.png\"}],[\"$\",\"link\",\"10\",{\"rel\":\"apple-touch-icon\",\"href\":\"/pwa/icon-192.png\"}]]\n2:null\n"])</script></body></html>
|
|
@@ -4,6 +4,6 @@
|
|
|
4
4
|
5:{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"}
|
|
5
5
|
6:{"display":"inline-block"}
|
|
6
6
|
7:{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0}
|
|
7
|
-
0:["
|
|
7
|
+
0:["iTewNFIZtv6Wt6WCv8Scy",[[["",{"children":["/_not-found",{"children":["__PAGE__",{}]}]},"$undefined","$undefined",true],["",{"children":["/_not-found",{"children":["__PAGE__",{},[["$L1",[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":"404"}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],null],null],null]},[null,["$","$L2",null,{"parallelRouterKey":"children","segmentPath":["children","/_not-found","children"],"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L3",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":"$undefined","notFoundStyles":"$undefined"}]],null]},[[null,["$","html",null,{"lang":"en","children":["$","body",null,{"children":[["$","$L2",null,{"parallelRouterKey":"children","segmentPath":["children"],"error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L3",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":"$4","children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":"$5","children":"404"}],["$","div",null,{"style":"$6","children":["$","h2",null,{"style":"$7","children":"This page could not be found."}]}]]}]}]],"notFoundStyles":[]}],["$","script",null,{"src":"/pwa/install.js","defer":true}]]}]}]],null],null],["$L8",["$","meta",null,{"name":"robots","content":"noindex"}]]]]]
|
|
8
8
|
8:[["$","meta","0",{"name":"viewport","content":"width=device-width, initial-scale=1"}],["$","meta","1",{"name":"theme-color","content":"#f5f6fa"}],["$","meta","2",{"charSet":"utf-8"}],["$","title","3",{"children":"AgentRoam"}],["$","meta","4",{"name":"description","content":"General-purpose AI agent API server"}],["$","link","5",{"rel":"manifest","href":"/manifest.webmanifest","crossOrigin":"use-credentials"}],["$","meta","6",{"name":"apple-mobile-web-app-capable","content":"yes"}],["$","meta","7",{"name":"apple-mobile-web-app-title","content":"AgentRoam"}],["$","meta","8",{"name":"apple-mobile-web-app-status-bar-style","content":"default"}],["$","link","9",{"rel":"icon","href":"/pwa/icon-192.png"}],["$","link","10",{"rel":"apple-touch-icon","href":"/pwa/icon-192.png"}]]
|
|
9
9
|
1:null
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";(()=>{var e={};e.id=2616,e.ids=[2616],e.modules={7728:e=>{e.exports=require("@anthropic-ai/claude-agent-sdk")},5890:e=>{e.exports=require("better-sqlite3")},399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},1282:e=>{e.exports=require("child_process")},2048:e=>{e.exports=require("fs")},9801:e=>{e.exports=require("os")},5315:e=>{e.exports=require("path")},7718:e=>{e.exports=require("node:child_process")},6005:e=>{e.exports=require("node:crypto")},5673:e=>{e.exports=require("node:events")},7561:e=>{e.exports=require("node:fs")},3977:e=>{e.exports=require("node:fs/promises")},8849:e=>{e.exports=require("node:http")},2286:e=>{e.exports=require("node:https")},2033:e=>{e.exports=require("node:module")},7503:e=>{e.exports=require("node:net")},612:e=>{e.exports=require("node:os")},9411:e=>{e.exports=require("node:path")},1747:e=>{e.exports=require("node:readline")},4492:e=>{e.exports=require("node:stream")},6915:e=>{e.exports=require("node:string_decoder")},1041:e=>{e.exports=require("node:url")},7261:e=>{e.exports=require("node:util")},7236:(e,t,s)=>{s.r(t),s.d(t,{originalPathname:()=>v,patchFetch:()=>w,requestAsyncStorage:()=>y,routeModule:()=>E,serverHooks:()=>N,staticGenerationAsyncStorage:()=>T});var r={};s.r(r),s.d(r,{POST:()=>I});var i=s(7786),n=s(5042),o=s(2184),a=s(1890),u=s(1322),l=s(6279),d=s(7519),c=s(1614),p=s(535),h=s(1079),m=s(4621),g=s(1982),f=s(8615);async function I(e){try{var t,s;(0,h.j)();let r=await e.json();if(!r.input)return a.NextResponse.json({error:"input is required"},{status:400});if(void 0!==r.agentIds&&(!Array.isArray(r.agentIds)||r.agentIds.length>20||r.agentIds.some(e=>"string"!=typeof e||!e.trim())))return a.NextResponse.json({error:"agentIds must contain at most 20 non-empty IDs"},{status:400});if(void 0!==r.agentId&&void 0!==r.agentIds)return a.NextResponse.json({error:"agentId and agentIds are mutually exclusive"},{status:400});if(void 0!==r.profileId&&("string"!=typeof r.profileId||!r.profileId.trim()||r.profileId.length>200))return a.NextResponse.json({error:"profileId must be a non-empty string"},{status:400});if(r.sessionId&&(0,c.V_)(r.sessionId)){let e=r.sessionId,t=(0,c.NL)(),s=await t.startRun(e,r.input,r.images,"web",{...r.nativeModel?.id?{model:r.nativeModel}:{},...r.nativeReasoningEffort?{reasoningEffort:r.nativeReasoningEffort}:{}});d.agentHost.resetExternalStream(e),d.agentHost.publishExternal(e,{type:"run_admitted",_nativeRunId:s.runId,_nativeSequence:s.snapshotRevision});let i=null,n=!1;return t.subscribe(e,0,({event:t})=>{d.agentHost.publishExternal(e,t),("done"===t.type||"error"===t.type)&&(n=!0,i?.())}).then(e=>{i=e,n&&e()}).catch(t=>{let s=t instanceof l.no?t.code:void 0;(0,p.L)().error("native run subscription failed",t,{sessionId:e,code:s}),d.agentHost.publishExternal(e,{type:"error",message:t instanceof Error?t.message:"Native run subscription failed",...s?{code:s}:{}})}),a.NextResponse.json({sessionId:e,streamUrl:`/api/agent/stream?sessionId=${e}`,runId:s.runId,snapshotRevision:s.snapshotRevision})}let i=d.agentHost.getSessionStore(),n={maxIterations:"number"!=typeof(t=r.maxIterations)||!Number.isFinite(t)||t<0?10:Math.trunc(t),maxTokens:"number"==typeof(s=r.maxTokens)&&Number.isFinite(s)?Math.min(2e6,Math.max(8e3,Math.trunc(s))):1e5},o=r.agentId??(r.agentIds?.length===1?r.agentIds[0]:void 0),I=(0,m.i)(),E=new u.R0$(i,{getAgent:e=>I.agents.get(e),getSkill:async e=>I.skills.get(e)??(await I.call("listSkills",[])).find(t=>t.name===e)??null,hasModelProfile:e=>(0,g.dp)().read().profiles.some(t=>t.id===e),getToolExecutionPolicy:e=>(0,f.cm)().get(e)},{assertAvailable:e=>{if(d.agentHost.isSessionRunning(e))throw new d.A(e)},start:e=>{let t=d.agentHost.startRun(e.message,e.sessionId,e.images,{...r.model?{model:r.model}:{},...e.modelProfileId?{profileId:e.modelProfileId}:{},...r.reasoningEffort?{reasoningEffort:r.reasoningEffort}:{},...void 0===r.maxIterations?{}:{maxIterations:n.maxIterations},...void 0===r.maxTokens?{}:{maxTokens:n.maxTokens},...r.agentIds?{agentIds:r.agentIds}:e.agent?{agentIds:[e.agent.id]}:{},...e.skill?{activatedSkills:[e.skill.name]}:{},...Object.keys(e.context).length?{context:e.context}:{},toolExecutionPolicy:e.toolExecutionPolicy});return t.completion.catch(t=>{(0,p.L)().error("agent run error",t,{sessionId:e.sessionId}),console.error("Agent run error:",t)}),{sessionId:e.sessionId,runId:t.runId,streamRef:`/api/agent/stream?sessionId=${e.sessionId}`}}}),y=await E.execute({message:r.input,...r.sessionId?{sessionId:r.sessionId}:{},...o?{agentId:o}:{},...r.skillName?{skillName:r.skillName}:{},...r.profileId?{modelProfileId:r.profileId}:{},...r.images?.length?{images:r.images}:{},...r.context?{context:r.context}:{},...r.toolPolicyId?{capabilities:{toolPolicyId:r.toolPolicyId}}:{},session:{...r.projectId?{projectId:r.projectId}:{},...r.title?{title:r.title}:{},...r.metadata?{metadata:r.metadata}:{}},source:r.source??"webapp"});return a.NextResponse.json({sessionId:y.sessionId,streamUrl:y.streamRef,runId:y.runId})}catch(n){(0,p.L)().error("agent run request failed",n,{status:n instanceof l.no?n.code:void 0});let e=n instanceof l.no?n.code:void 0,t=n instanceof d.A?n.code:void 0,s=n instanceof u.KZx?n.code:void 0,r=e??t??s,i="SESSION_OCCUPIED"===r||"SESSION_ALREADY_RUNNING"===r;return a.NextResponse.json({error:n instanceof Error?n.message:"Internal error",...r?{code:r}:{}},{status:i?409:("AGENT_NOT_FOUND"===s||"SKILL_NOT_FOUND"===s||"MODEL_PROFILE_NOT_FOUND"===s||"TOOL_POLICY_NOT_FOUND"===s?404:"SKILL_NOT_ALLOWED"===s||"TOOL_POLICY_DISABLED"===s?422:s?400:void 0)??500})}}let E=new i.AppRouteRouteModule({definition:{kind:n.x.APP_ROUTE,page:"/api/agent/run/route",pathname:"/api/agent/run",filename:"route",bundlePath:"app/api/agent/run/route"},resolvedPagePath:"/Volumes/ext/project/team-agent/packages/server/app/api/agent/run/route.ts",nextConfigOutput:"standalone",userland:r}),{requestAsyncStorage:y,staticGenerationAsyncStorage:T,serverHooks:N}=E,v="/api/agent/run/route";function w(){return(0,o.patchFetch)({serverHooks:N,staticGenerationAsyncStorage:T})}},1614:(e,t,s)=>{s.d(t,{NL:()=>E,V_:()=>v,WW:()=>w});var r=s(7561),i=s(612),n=s(9411),o=s(7718),a=s(1322);function u(e){if(!e.trim())return!1;try{return(0,r.accessSync)(e,r.constants.X_OK),!0}catch{return!1}}function l(e){try{return(0,a.wyD)((0,o.execFileSync)(e,["--version"],{encoding:"utf8",timeout:5e3,stdio:["ignore","pipe","pipe"]}))}catch{return}}function d(e){let t=[],s=process.env[e.environmentVariable]?.trim();if(s){let r=u(s);t.push({source:"pin",path:s,executable:r,version:r?l(s):void 0,error:r?void 0:`${e.environmentVariable} "${s}" is not executable`})}let r=function(e){for(let t of(process.env.PATH??"").split(n.delimiter).filter(Boolean)){let s=(0,n.resolve)(t,e);if(u(s))return s}}(e.name);return r&&r!==s&&t.push({source:"path",path:r,executable:!0,version:l(r)}),(0,a.neJ)(t,{name:e.name,minimumVersion:e.minimumVersion})}var c=s(535),p=s(6279),h=s(785);let m=globalThis;class g{constructor(e,t=async()=>[],s=process.platform){this.runtime=e,this.listProjects=t,this.platform=s,this.pendingCreations=new Map}health(){return this.runtime.health()}listModels(e){return this.runtime.listModels(e)}listWorkspaces(e,t){return this.runtime.listWorkspaces(e,t)}importWorkspace(e,t,s){if(!this.runtime.importWorkspace)throw new p.no("Native workspace import is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.importWorkspace(e,t,s)}async listWorkspaceSessions(e,t,s){let r=await this.runtime.listWorkspaceSessions(e,t,s);if(s?.cursor)return r;let i=new Set(r.data.map(e=>e.id)),n=r.data.map(e=>{let t=this.pendingCreations.get(e.id);return t?(this.pendingCreations.delete(e.id),f(e,t)):e});for(let s of this.pendingCreations.values())s.agentType!==e||s.projectId!==t||i.has(s.id)||n.unshift(s);return{...r,data:n}}async list(e){let[t,s]=await Promise.all([this.runtime.list(),this.listProjects()]);return N(this.withPendingCreations(t).map(e=>y(e,s,this.platform)),e)}async refresh(e){let[t,s]=await Promise.all([this.runtime.refresh(),this.listProjects()]);return N(this.withPendingCreations(t).map(e=>y(e,s,this.platform)),e)}async create(e){let t=y(await this.runtime.create(e),await this.listProjects(),this.platform),s=e.projectId?{...t,projectId:e.projectId}:t;return this.pendingCreations.set(s.id,s),s}async fork(e){if(!v(e))throw new p.no("Customer Agent sessions do not support native forks","OPERATION_NOT_SUPPORTED");let t=y(await this.runtime.fork(e),await this.listProjects(),this.platform);return this.pendingCreations.set(t.id,t),t}async delete(e){await this.runtime.delete(e),this.pendingCreations.delete(e)}async get(e,t){let s;try{s=await this.runtime.get(e,t)}catch(r){let s=this.pendingCreations.get(e);if(!s)throw r;return t?{...s,messages:[],events:[],history:{nextCursor:null,hasMore:!1,pageSize:0,totalItems:0}}:{...s,messages:[],events:[]}}return y(s,await this.listProjects(),this.platform)}async getQueryIndex(e){if(this.runtime.getQueryIndex)return this.runtime.getQueryIndex(e);let t=await this.runtime.get(e),{buildSessionQueryIndex:r}=await Promise.resolve().then(s.bind(s,1322));return r(e,t.messages)}getSessionToolResult(e,t){return this.runtime.getSessionToolResult(e,t)}getSessionWatchPath(e){return this.runtime.getSessionWatchPath(e)}run(e,t,s,r,i){return this.runtime.run(e,t,s,r,i)}steer(e,t){return this.runtime.steer(e,t)}abort(e){return this.runtime.abort(e)}async release(e){if(!this.runtime.release)throw new p.no("Native runtime release is unavailable","RUNTIME_UNAVAILABLE");await this.runtime.release(e)}answerQuestion(e,t){return this.runtime.answerQuestion(e,t)}async startRun(e,t,s,r="web",i){if(!this.runtime.startRun)throw new p.no("Native runtime broker is unavailable","RUNTIME_UNAVAILABLE");return this.runtime.startRun(e,t,s,r,i)}async subscribe(e,t,s){if(!this.runtime.subscribe)throw new p.no("Native runtime broker is unavailable","RUNTIME_UNAVAILABLE");return this.runtime.subscribe(e,t,s)}async snapshot(e,t=0){if(!this.runtime.snapshot)throw new p.no("Native runtime broker is unavailable","RUNTIME_UNAVAILABLE");return this.runtime.snapshot(e,t)}async setPermissionMode(e,t){if(!this.runtime.setPermissionMode)throw new p.no("Native runtime broker is unavailable","RUNTIME_UNAVAILABLE");return this.runtime.setPermissionMode(e,t)}async handoff(e,t){if(!this.runtime.handoff)throw new p.no("Native runtime broker is unavailable","RUNTIME_UNAVAILABLE");return this.runtime.handoff(e,t)}async getGoals(e,t="web"){if(!this.runtime.getGoals)throw new p.no("Goal mode is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.getGoals(e,t)}async enqueueGoal(e,t,s,r="web"){if(!this.runtime.enqueueGoal)throw new p.no("Goal mode is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.enqueueGoal(e,t,s,r)}async reorderGoals(e,t){if(!this.runtime.reorderGoals)throw new p.no("Goal mode is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.reorderGoals(e,t)}async cancelGoal(e,t){if(!this.runtime.cancelGoal)throw new p.no("Goal mode is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.cancelGoal(e,t,"web")}async enqueueMessage(e,t,s="web"){if(!this.runtime.enqueueMessage)throw new p.no("Message queue is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.enqueueMessage(e,t,s)}async reorderMessages(e,t){if(!this.runtime.reorderMessages)throw new p.no("Message queue is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.reorderMessages(e,t)}async updateMessage(e,t,s,r){if(!this.runtime.updateMessage)throw new p.no("Message queue is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.updateMessage(e,t,s,r)}async cancelMessage(e,t){if(!this.runtime.cancelMessage)throw new p.no("Message queue is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.cancelMessage(e,t)}async steerMessage(e,t){if(!this.runtime.steerMessage)throw new p.no("Message queue is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.steerMessage(e,t)}withPendingCreations(e){let t=new Set,s=e.map(e=>{t.add(e.id);let s=this.pendingCreations.get(e.id);return this.pendingCreations.delete(e.id),s?f(e,s):e});return[...[...this.pendingCreations.values()].filter(e=>!t.has(e.id)).sort((e,t)=>t.updated.localeCompare(e.updated)),...s]}}function f(e,t){return{...e,cwd:e.cwd||t.cwd,projectId:e.projectId??t.projectId}}function I(e,t){t.executable?delete process.env[e]:process.env[e]=t.detail}function E(){if(!m.__nativeRuntimeService){!function(){let e=[(0,n.join)((0,i.homedir)(),".local","bin"),"/opt/homebrew/bin","/usr/local/bin"],t=(process.env.PATH??"").split(n.delimiter),s=e.filter(e=>(0,r.existsSync)(e)&&!t.includes(e));s.length>0&&(process.env.PATH=[...t,...s].join(n.delimiter))}();let e=new a.XWE((0,h.kO)());m.__nativeRuntimeService=new g((0,p.v6)({runtimeFactory:e=>{let t=d({name:"codex",environmentVariable:"AGENT_CODEX_BIN",minimumVersion:a.hix}),s=d({name:"opencode",environmentVariable:"AGENT_OPENCODE_BIN"});return process.pid,I("AGENT_CODEX_RUNTIME_ERROR",t),I("AGENT_OPENCODE_RUNTIME_ERROR",s),(0,c.L)().info("native runtime host elected",{pid:process.pid,codex:t.executable??null,codexSource:t.source??null,codexDetail:t.detail,opencode:s.executable??null,opencodeDetail:s.detail}),(0,p.WH)(t.executable??"codex",e,s.executable??"opencode")}}),()=>e.list())}return m.__nativeRuntimeService}function y(e,t,s=process.platform){let{projectId:r,...i}=e;if(!e.cwd)return i;let o=T(e.cwd,s),a="win32"===s?n.win32.sep:n.sep,u=t.filter(e=>e.description).map(e=>({project:e,path:T(e.description,s)})).filter(({path:e})=>o===e||o.startsWith(`${e}${a}`)).sort((e,t)=>t.path.length-e.path.length)[0];return u?{...i,projectId:u.project.id}:i}function T(e,t=process.platform){if("win32"!==t)return(0,n.resolve)(e);let s=n.win32.resolve(e),r=n.win32.parse(s).root;return(s.length>r.length?s.replace(/[\\/]+$/,""):s).toLowerCase()}function N(e,t){return void 0===t?e:e.filter(e=>e.projectId===t)}function v(e){try{return"customer-agent"!==(0,p.Vu)(e).agentType}catch{return!1}}function w(e){if(e instanceof p.no)switch(e.code){case"SESSION_NOT_FOUND":return 404;case"SESSION_OCCUPIED":case"SESSION_ALREADY_RUNNING":case"APPROVAL_EXPIRED":case"CODEX_SESSION_VERSION_INCOMPATIBLE":case"STALE_SESSION_ANCHOR":return 409;case"RUNTIME_UNAVAILABLE":return 503;case"OPERATION_NOT_SUPPORTED":return 405;default:return 400}return 500}},1079:(e,t,s)=>{s.d(t,{j:()=>a});var r=s(7519),i=s(3931),n=s(535);let o=!1;function a(){o||(o=!0,r.agentHost.setGlobalEventObserver((e,t)=>{try{if("ask_user"===t.type){(0,i.i)().notifySession({sessionId:e,kind:"approval",title:"需要你的审批",body:"string"==typeof t.question&&t.question.trim()?t.question.trim().slice(0,160):"会话正在等待确认",url:"/app/"});return}if("done"===t.type){(0,i.i)().notifySession({sessionId:e,kind:"done",title:"会话已完成",body:"string"==typeof t.finalText&&t.finalText.trim()?t.finalText.trim().slice(0,160):"运行已结束",url:"/app/"});return}"error"===t.type&&(0,i.i)().notifySession({sessionId:e,kind:"error",title:"会话出错",body:"string"==typeof t.message&&t.message.trim()?t.message.trim().slice(0,160):"运行失败",url:"/app/"})}catch(t){(0,n.L)().warn("web push notify failed",{sessionId:e,error:t instanceof Error?t.message:String(t)})}}))}},6361:(e,t,s)=>{s.d(t,{Q:()=>o,e:()=>n});var r=s(1322),i=s(7519);function n(){let e=new r.S3T;(0,r._5y)(e);let t=new r.OqQ;for(let s of(e.register(new r.Q8u(t,null)),e.register(new r.URd(t,null)),i.agentHost.getBuilder().getToolRegistry().getAll()))e.register(s);return e}function o(){return n().getAll().map(e=>e.name).sort()}},1489:(e,t,s)=>{s.d(t,{N:()=>u});var r=s(1322),i=s(6279),n=s(785);class o{constructor(){this.tasks=new r.vo4((0,n.kO)()),this.scheduler=new i.ST(this.tasks,e=>{this.fire(e).catch(e=>console.error("Scheduled Customer Agent run failed",e))},()=>{}),this.scheduler.start()}async fire(e){let{agentHost:t}=await s.e(7519).then(s.bind(s,7519)),{getCustomerGoalCoordinator:r}=await Promise.all([s.e(7519),s.e(732)]).then(s.bind(s,5038)),i=e.sessionId;i&&await t.getSessionStore().get(i)||(i=(await t.createSession(e.label||"定时任务")).id,this.tasks.update(e.id,{sessionId:i})),await r().enqueue(i,e.prompt)}call(e,t){let s=String(t[0]||"");switch(e){case"cronList":return this.tasks.list();case"cronCreate":{if("string"!=typeof t[0]||"string"!=typeof t[1]||!t[1].trim())throw Error("cron and prompt required");let e=t[2]&&"object"==typeof t[2]?t[2]:{};return this.tasks.create({cron:t[0],prompt:t[1],recurring:!1!==e.recurring,enabled:!0,durable:!0,..."string"==typeof e.sessionId?{sessionId:e.sessionId}:{},..."string"==typeof e.label?{label:e.label}:{}})}case"cronPause":return this.tasks.pause(s);case"cronResume":return this.tasks.resume(s);case"cronDelete":return this.tasks.delete(s);case"cronDeleteAll":return this.tasks.deleteAll(),{ok:!0};default:throw Error("Unsupported schedule operation")}}}let a=globalThis;function u(){return a.__sharedCronService??=new o}},8615:(e,t,s)=>{let r;s.d(t,{H5:()=>d,cm:()=>u,jw:()=>l});var i=s(1322),n=s(785),o=s(6361);class a{constructor(e=(0,n.kO)()){this.store=new i.RQW(e)}list(){return this.store.list()}get(e){return this.store.get(e)}async summaries(){return(await this.store.list()).filter(e=>e.enabled).map(i._0R)}save(e,t){let s=(0,i.IJh)(e,{knownTools:t,requireExecutables:!0});return this.store.save(s)}delete(e){return this.store.delete(e)}}function u(){return r??=new a}function l(){return(0,o.Q)()}function d(e){let t=e instanceof i.DlR?422:400;return Response.json({error:e instanceof Error?e.message:"Tool policy request failed",code:e instanceof i.DlR?e.code:"INVALID_TOOL_POLICY"},{status:t})}},3931:(e,t,s)=>{s.d(t,{i:()=>p});var r=s(6005),i=s(7561),n=s(9411),o=s(5890);let a=require("web-push"),u=e=>JSON.stringify(e??null);class l{constructor(e,t=Date.now){this.now=t;let s=(0,n.resolve)(e,".agentroam-auth");(0,i.mkdirSync)(s,{recursive:!0,mode:448});let r=(0,n.join)(s,"push.sqlite");this.db=new o(r),(0,i.chmodSync)(r,384),this.db.pragma("busy_timeout = 5000"),this.db.exec(`
|
|
1
|
+
"use strict";(()=>{var e={};e.id=2616,e.ids=[2616],e.modules={7728:e=>{e.exports=require("@anthropic-ai/claude-agent-sdk")},5890:e=>{e.exports=require("better-sqlite3")},399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},1282:e=>{e.exports=require("child_process")},2048:e=>{e.exports=require("fs")},9801:e=>{e.exports=require("os")},5315:e=>{e.exports=require("path")},7718:e=>{e.exports=require("node:child_process")},6005:e=>{e.exports=require("node:crypto")},5673:e=>{e.exports=require("node:events")},7561:e=>{e.exports=require("node:fs")},3977:e=>{e.exports=require("node:fs/promises")},8849:e=>{e.exports=require("node:http")},2286:e=>{e.exports=require("node:https")},2033:e=>{e.exports=require("node:module")},7503:e=>{e.exports=require("node:net")},612:e=>{e.exports=require("node:os")},9411:e=>{e.exports=require("node:path")},1747:e=>{e.exports=require("node:readline")},4492:e=>{e.exports=require("node:stream")},6915:e=>{e.exports=require("node:string_decoder")},1041:e=>{e.exports=require("node:url")},7261:e=>{e.exports=require("node:util")},7236:(e,t,s)=>{s.r(t),s.d(t,{originalPathname:()=>v,patchFetch:()=>w,requestAsyncStorage:()=>y,routeModule:()=>E,serverHooks:()=>T,staticGenerationAsyncStorage:()=>N});var r={};s.r(r),s.d(r,{POST:()=>I});var i=s(7786),n=s(5042),o=s(2184),a=s(1890),u=s(1322),l=s(6279),d=s(7519),c=s(1614),p=s(535),h=s(1079),m=s(4621),g=s(1982),f=s(8615);async function I(e){try{var t,s;(0,h.j)();let r=await e.json();if(!r.input)return a.NextResponse.json({error:"input is required"},{status:400});if(void 0!==r.agentIds&&(!Array.isArray(r.agentIds)||r.agentIds.length>20||r.agentIds.some(e=>"string"!=typeof e||!e.trim())))return a.NextResponse.json({error:"agentIds must contain at most 20 non-empty IDs"},{status:400});if(void 0!==r.agentId&&void 0!==r.agentIds)return a.NextResponse.json({error:"agentId and agentIds are mutually exclusive"},{status:400});if(void 0!==r.profileId&&("string"!=typeof r.profileId||!r.profileId.trim()||r.profileId.length>200))return a.NextResponse.json({error:"profileId must be a non-empty string"},{status:400});if(r.sessionId&&(0,c.V_)(r.sessionId)){let e=r.sessionId,t=(0,c.NL)(),s=await t.startRun(e,r.input,r.images,"web",{...r.nativeModel?.id?{model:r.nativeModel}:{},...r.nativeReasoningEffort?{reasoningEffort:r.nativeReasoningEffort}:{}});d.agentHost.resetExternalStream(e),d.agentHost.publishExternal(e,{type:"run_admitted",_nativeRunId:s.runId,_nativeSequence:s.snapshotRevision});let i=null,n=!1;return t.subscribe(e,0,({event:t})=>{d.agentHost.publishExternal(e,t),("done"===t.type||"error"===t.type)&&(n=!0,i?.())}).then(e=>{i=e,n&&e()}).catch(t=>{let s=t instanceof l.no?t.code:void 0;(0,p.L)().error("native run subscription failed",t,{sessionId:e,code:s}),d.agentHost.publishExternal(e,{type:"error",message:t instanceof Error?t.message:"Native run subscription failed",...s?{code:s}:{}})}),a.NextResponse.json({sessionId:e,streamUrl:`/api/agent/stream?sessionId=${e}`,runId:s.runId,snapshotRevision:s.snapshotRevision})}let i=d.agentHost.getSessionStore(),n={maxIterations:"number"!=typeof(t=r.maxIterations)||!Number.isFinite(t)||t<0?10:Math.trunc(t),maxTokens:"number"==typeof(s=r.maxTokens)&&Number.isFinite(s)?Math.min(2e6,Math.max(8e3,Math.trunc(s))):1e5},o=r.agentId??(r.agentIds?.length===1?r.agentIds[0]:void 0),I=(0,m.i)(),E=new u.R0$(i,{getAgent:e=>I.agents.get(e),getSkill:async e=>I.skills.get(e)??(await I.call("listSkills",[])).find(t=>t.name===e)??null,hasModelProfile:e=>(0,g.dp)().read().profiles.some(t=>t.id===e),getToolExecutionPolicy:e=>(0,f.cm)().get(e)},{assertAvailable:e=>{if(d.agentHost.isSessionRunning(e))throw new d.A(e)},start:e=>{let t=d.agentHost.startRun(e.message,e.sessionId,e.images,{...r.model?{model:r.model}:{},...e.modelProfileId?{profileId:e.modelProfileId}:{},...r.reasoningEffort?{reasoningEffort:r.reasoningEffort}:{},...void 0===r.maxIterations?{}:{maxIterations:n.maxIterations},...void 0===r.maxTokens?{}:{maxTokens:n.maxTokens},...r.agentIds?{agentIds:r.agentIds}:e.agent?{agentIds:[e.agent.id]}:{},...e.skill?{activatedSkills:[e.skill.name]}:{},...Object.keys(e.context).length?{context:e.context}:{},toolExecutionPolicy:e.toolExecutionPolicy});return t.completion.catch(t=>{(0,p.L)().error("agent run error",t,{sessionId:e.sessionId}),console.error("Agent run error:",t)}),{sessionId:e.sessionId,runId:t.runId,streamRef:`/api/agent/stream?sessionId=${e.sessionId}`}}}),y=await E.execute({message:r.input,...r.sessionId?{sessionId:r.sessionId}:{},...o?{agentId:o}:{},...r.skillName?{skillName:r.skillName}:{},...r.profileId?{modelProfileId:r.profileId}:{},...r.images?.length?{images:r.images}:{},...r.context?{context:r.context}:{},...r.toolPolicyId?{capabilities:{toolPolicyId:r.toolPolicyId}}:{},session:{...r.projectId?{projectId:r.projectId}:{},...r.title?{title:r.title}:{},...r.metadata?{metadata:r.metadata}:{}},source:r.source??"webapp"});return a.NextResponse.json({sessionId:y.sessionId,streamUrl:y.streamRef,runId:y.runId})}catch(n){(0,p.L)().error("agent run request failed",n,{status:n instanceof l.no?n.code:void 0});let e=n instanceof l.no?n.code:void 0,t=n instanceof d.A?n.code:void 0,s=n instanceof u.KZx?n.code:void 0,r=e??t??s,i="SESSION_OCCUPIED"===r||"SESSION_ALREADY_RUNNING"===r;return a.NextResponse.json({error:n instanceof Error?n.message:"Internal error",...r?{code:r}:{}},{status:i?409:("AGENT_NOT_FOUND"===s||"SKILL_NOT_FOUND"===s||"MODEL_PROFILE_NOT_FOUND"===s||"TOOL_POLICY_NOT_FOUND"===s?404:"SKILL_NOT_ALLOWED"===s||"TOOL_POLICY_DISABLED"===s?422:s?400:void 0)??500})}}let E=new i.AppRouteRouteModule({definition:{kind:n.x.APP_ROUTE,page:"/api/agent/run/route",pathname:"/api/agent/run",filename:"route",bundlePath:"app/api/agent/run/route"},resolvedPagePath:"/Volumes/ext/project/team-agent/packages/server/app/api/agent/run/route.ts",nextConfigOutput:"standalone",userland:r}),{requestAsyncStorage:y,staticGenerationAsyncStorage:N,serverHooks:T}=E,v="/api/agent/run/route";function w(){return(0,o.patchFetch)({serverHooks:T,staticGenerationAsyncStorage:N})}},1614:(e,t,s)=>{s.d(t,{NL:()=>E,V_:()=>v,WW:()=>w});var r=s(7561),i=s(612),n=s(9411),o=s(7718),a=s(1322);function u(e){if(!e.trim())return!1;try{return(0,r.accessSync)(e,r.constants.X_OK),!0}catch{return!1}}function l(e){try{return(0,a.wyD)((0,o.execFileSync)(e,["--version"],{encoding:"utf8",timeout:5e3,stdio:["ignore","pipe","pipe"]}))}catch{return}}function d(e){let t=[],s=process.env[e.environmentVariable]?.trim();if(s){let r=u(s);t.push({source:"pin",path:s,executable:r,version:r?l(s):void 0,error:r?void 0:`${e.environmentVariable} "${s}" is not executable`})}let r=function(e){for(let t of(process.env.PATH??"").split(n.delimiter).filter(Boolean)){let s=(0,n.resolve)(t,e);if(u(s))return s}}(e.name);return r&&r!==s&&t.push({source:"path",path:r,executable:!0,version:l(r)}),(0,a.neJ)(t,{name:e.name,minimumVersion:e.minimumVersion})}var c=s(535),p=s(6279),h=s(785);let m=globalThis;class g{constructor(e,t=async()=>[],s=process.platform){this.runtime=e,this.listProjects=t,this.platform=s,this.pendingCreations=new Map}health(){return this.runtime.health()}listModels(e){return this.runtime.listModels(e)}listWorkspaces(e,t){return this.runtime.listWorkspaces(e,t)}importWorkspace(e,t,s){if(!this.runtime.importWorkspace)throw new p.no("Native workspace import is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.importWorkspace(e,t,s)}async listWorkspaceSessions(e,t,s){let r=await this.runtime.listWorkspaceSessions(e,t,s);if(s?.cursor)return r;let i=new Set(r.data.map(e=>e.id)),n=r.data.map(e=>{let t=this.pendingCreations.get(e.id);return t?(this.pendingCreations.delete(e.id),f(e,t)):e});for(let s of this.pendingCreations.values())s.agentType!==e||s.projectId!==t||i.has(s.id)||n.unshift(s);return{...r,data:n}}async list(e){let[t,s]=await Promise.all([this.runtime.list(),this.listProjects()]);return T(this.withPendingCreations(t).map(e=>y(e,s,this.platform)),e)}async refresh(e){let[t,s]=await Promise.all([this.runtime.refresh(),this.listProjects()]);return T(this.withPendingCreations(t).map(e=>y(e,s,this.platform)),e)}async create(e){let t=y(await this.runtime.create(e),await this.listProjects(),this.platform),s=e.projectId?{...t,projectId:e.projectId}:t;return this.pendingCreations.set(s.id,s),s}async fork(e){if(!v(e))throw new p.no("Customer Agent sessions do not support native forks","OPERATION_NOT_SUPPORTED");let t=y(await this.runtime.fork(e),await this.listProjects(),this.platform);return this.pendingCreations.set(t.id,t),t}async delete(e){await this.runtime.delete(e),this.pendingCreations.delete(e)}async get(e,t){let s;try{s=await this.runtime.get(e,t)}catch(r){let s=this.pendingCreations.get(e);if(!s)throw r;return t?{...s,messages:[],events:[],history:{nextCursor:null,hasMore:!1,pageSize:0,totalItems:0}}:{...s,messages:[],events:[]}}return y(s,await this.listProjects(),this.platform)}async getQueryIndex(e){if(this.runtime.getQueryIndex)return this.runtime.getQueryIndex(e);let t=await this.runtime.get(e),{buildSessionQueryIndex:r}=await Promise.resolve().then(s.bind(s,1322));return r(e,t.messages)}getSessionToolResult(e,t){return this.runtime.getSessionToolResult(e,t)}getSessionWatchPath(e){return this.runtime.getSessionWatchPath(e)}run(e,t,s,r,i){return this.runtime.run(e,t,s,r,i)}steer(e,t){return this.runtime.steer(e,t)}abort(e){return this.runtime.abort(e)}async release(e){if(!this.runtime.release)throw new p.no("Native runtime release is unavailable","RUNTIME_UNAVAILABLE");await this.runtime.release(e)}answerQuestion(e,t){return this.runtime.answerQuestion(e,t)}async startRun(e,t,s,r="web",i){if(!this.runtime.startRun)throw new p.no("Native runtime broker is unavailable","RUNTIME_UNAVAILABLE");return this.runtime.startRun(e,t,s,r,i)}async subscribe(e,t,s){if(!this.runtime.subscribe)throw new p.no("Native runtime broker is unavailable","RUNTIME_UNAVAILABLE");return this.runtime.subscribe(e,t,s)}async snapshot(e,t=0){if(!this.runtime.snapshot)throw new p.no("Native runtime broker is unavailable","RUNTIME_UNAVAILABLE");return this.runtime.snapshot(e,t)}async setPermissionMode(e,t){if(!this.runtime.setPermissionMode)throw new p.no("Native runtime broker is unavailable","RUNTIME_UNAVAILABLE");return this.runtime.setPermissionMode(e,t)}async handoff(e,t){if(!this.runtime.handoff)throw new p.no("Native runtime broker is unavailable","RUNTIME_UNAVAILABLE");return this.runtime.handoff(e,t)}async getGoals(e,t="web"){if(!this.runtime.getGoals)throw new p.no("Goal mode is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.getGoals(e,t)}async enqueueGoal(e,t,s,r="web"){if(!this.runtime.enqueueGoal)throw new p.no("Goal mode is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.enqueueGoal(e,t,s,r)}async reorderGoals(e,t){if(!this.runtime.reorderGoals)throw new p.no("Goal mode is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.reorderGoals(e,t)}async cancelGoal(e,t){if(!this.runtime.cancelGoal)throw new p.no("Goal mode is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.cancelGoal(e,t,"web")}async enqueueMessage(e,t,s="web"){if(!this.runtime.enqueueMessage)throw new p.no("Message queue is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.enqueueMessage(e,t,s)}async reorderMessages(e,t){if(!this.runtime.reorderMessages)throw new p.no("Message queue is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.reorderMessages(e,t)}async updateMessage(e,t,s,r){if(!this.runtime.updateMessage)throw new p.no("Message queue is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.updateMessage(e,t,s,r)}async cancelMessage(e,t){if(!this.runtime.cancelMessage)throw new p.no("Message queue is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.cancelMessage(e,t)}async steerMessage(e,t){if(!this.runtime.steerMessage)throw new p.no("Message queue is unavailable","OPERATION_NOT_SUPPORTED");return this.runtime.steerMessage(e,t)}withPendingCreations(e){let t=new Set,s=e.map(e=>{t.add(e.id);let s=this.pendingCreations.get(e.id);return this.pendingCreations.delete(e.id),s?f(e,s):e});return[...[...this.pendingCreations.values()].filter(e=>!t.has(e.id)).sort((e,t)=>t.updated.localeCompare(e.updated)),...s]}}function f(e,t){return{...e,cwd:e.cwd||t.cwd,projectId:e.projectId??t.projectId}}function I(e,t){t.executable?delete process.env[e]:process.env[e]=t.detail}function E(){if(!m.__nativeRuntimeService){!function(){let e=[(0,n.join)((0,i.homedir)(),".local","bin"),"/opt/homebrew/bin","/usr/local/bin"],t=(process.env.PATH??"").split(n.delimiter),s=e.filter(e=>(0,r.existsSync)(e)&&!t.includes(e));s.length>0&&(process.env.PATH=[...t,...s].join(n.delimiter))}();let e=new a.XWE((0,h.kO)());m.__nativeRuntimeService=new g((0,p.v6)({runtimeFactory:e=>{let t=d({name:"codex",environmentVariable:"AGENT_CODEX_BIN",minimumVersion:a.hix}),s=d({name:"opencode",environmentVariable:"AGENT_OPENCODE_BIN"});return process.pid,I("AGENT_CODEX_RUNTIME_ERROR",t),I("AGENT_OPENCODE_RUNTIME_ERROR",s),(0,c.L)().info("native runtime host elected",{pid:process.pid,codex:t.executable??null,codexSource:t.source??null,codexDetail:t.detail,opencode:s.executable??null,opencodeDetail:s.detail}),(0,p.WH)(t.executable??"codex",e,s.executable??"opencode")}}),()=>e.list())}return m.__nativeRuntimeService}function y(e,t,s=process.platform){let{projectId:r,...i}=e;if(!e.cwd)return i;let o=N(e.cwd,s),a="win32"===s?n.win32.sep:n.sep,u=t.filter(e=>e.description).map(e=>({project:e,path:N(e.description,s)})).filter(({path:e})=>o===e||o.startsWith(`${e}${a}`)).sort((e,t)=>t.path.length-e.path.length)[0];return u?{...i,projectId:u.project.id}:i}function N(e,t=process.platform){if("win32"!==t)return(0,n.resolve)(e);let s=n.win32.resolve(e),r=n.win32.parse(s).root;return(s.length>r.length?s.replace(/[\\/]+$/,""):s).toLowerCase()}function T(e,t){return void 0===t?e:e.filter(e=>e.projectId===t)}function v(e){try{return"customer-agent"!==(0,p.Vu)(e).agentType}catch{return!1}}function w(e){if(e instanceof p.no)switch(e.code){case"SESSION_NOT_FOUND":return 404;case"SESSION_OCCUPIED":case"SESSION_ALREADY_RUNNING":case"APPROVAL_EXPIRED":case"CODEX_SESSION_VERSION_INCOMPATIBLE":case"STALE_SESSION_ANCHOR":return 409;case"RUNTIME_UNAVAILABLE":return 503;case"OPERATION_NOT_SUPPORTED":return 405;default:return 400}return 500}},1079:(e,t,s)=>{s.d(t,{j:()=>a});var r=s(7519),i=s(3931),n=s(535);let o=!1;function a(){o||(o=!0,r.agentHost.setGlobalEventObserver((e,t)=>{try{if("ask_user"===t.type){(0,i.i)().notifySession({sessionId:e,kind:"approval",title:"需要你的审批",body:"string"==typeof t.question&&t.question.trim()?t.question.trim().slice(0,160):"会话正在等待确认",url:"/app/"});return}if("done"===t.type){(0,i.i)().notifySession({sessionId:e,kind:"done",title:"会话已完成",body:"string"==typeof t.finalText&&t.finalText.trim()?t.finalText.trim().slice(0,160):"运行已结束",url:"/app/"});return}"error"===t.type&&(0,i.i)().notifySession({sessionId:e,kind:"error",title:"会话出错",body:"string"==typeof t.message&&t.message.trim()?t.message.trim().slice(0,160):"运行失败",url:"/app/"})}catch(t){(0,n.L)().warn("web push notify failed",{sessionId:e,error:t instanceof Error?t.message:String(t)})}}))}},6361:(e,t,s)=>{s.d(t,{Q:()=>o,e:()=>n});var r=s(1322),i=s(7519);function n(){let e=new r.S3T;(0,r._5y)(e);let t=new r.OqQ;for(let s of(e.register(new r.Q8u(t,null)),e.register(new r.URd(t,null)),i.agentHost.getBuilder().getToolRegistry().getAll()))e.register(s);return e.register(new r.gBG(async()=>({status:"failed",agentName:"",subSessionId:"",error:"catalog listing only; dispatch runs inside a Customer Agent session"}))),e.register(new r.HbQ(async()=>({status:"failed",agentName:"",subSessionId:"",error:"catalog listing only; dispatch runs inside a Customer Agent session"}))),e}function o(){return n().getAll().map(e=>e.name).sort()}},1489:(e,t,s)=>{s.d(t,{N:()=>u});var r=s(1322),i=s(6279),n=s(785);class o{constructor(){this.tasks=new r.vo4((0,n.kO)()),this.scheduler=new i.ST(this.tasks,e=>{this.fire(e).catch(e=>console.error("Scheduled Customer Agent run failed",e))},()=>{}),this.scheduler.start()}async fire(e){let{agentHost:t}=await s.e(7519).then(s.bind(s,7519)),{getCustomerGoalCoordinator:r}=await Promise.all([s.e(7519),s.e(732)]).then(s.bind(s,5038)),i=e.sessionId;i&&await t.getSessionStore().get(i)||(i=(await t.createSession(e.label||"定时任务")).id,this.tasks.update(e.id,{sessionId:i})),await r().enqueue(i,e.prompt)}call(e,t){let s=String(t[0]||"");switch(e){case"cronList":return this.tasks.list();case"cronCreate":{if("string"!=typeof t[0]||"string"!=typeof t[1]||!t[1].trim())throw Error("cron and prompt required");let e=t[2]&&"object"==typeof t[2]?t[2]:{};return this.tasks.create({cron:t[0],prompt:t[1],recurring:!1!==e.recurring,enabled:!0,durable:!0,..."string"==typeof e.sessionId?{sessionId:e.sessionId}:{},..."string"==typeof e.label?{label:e.label}:{}})}case"cronPause":return this.tasks.pause(s);case"cronResume":return this.tasks.resume(s);case"cronDelete":return this.tasks.delete(s);case"cronDeleteAll":return this.tasks.deleteAll(),{ok:!0};default:throw Error("Unsupported schedule operation")}}}let a=globalThis;function u(){return a.__sharedCronService??=new o}},8615:(e,t,s)=>{let r;s.d(t,{H5:()=>d,cm:()=>u,jw:()=>l});var i=s(1322),n=s(785),o=s(6361);class a{constructor(e=(0,n.kO)()){this.store=new i.RQW(e)}list(){return this.store.list()}get(e){return this.store.get(e)}async summaries(){return(await this.store.list()).filter(e=>e.enabled).map(i._0R)}save(e,t){let s=(0,i.IJh)(e,{knownTools:t,requireExecutables:!0});return this.store.save(s)}delete(e){return this.store.delete(e)}}function u(){return r??=new a}function l(){return(0,o.Q)()}function d(e){let t=e instanceof i.DlR?422:400;return Response.json({error:e instanceof Error?e.message:"Tool policy request failed",code:e instanceof i.DlR?e.code:"INVALID_TOOL_POLICY"},{status:t})}},3931:(e,t,s)=>{s.d(t,{i:()=>p});var r=s(6005),i=s(7561),n=s(9411),o=s(5890);let a=require("web-push"),u=e=>JSON.stringify(e??null);class l{constructor(e,t=Date.now){this.now=t;let s=(0,n.resolve)(e,".agentroam-auth");(0,i.mkdirSync)(s,{recursive:!0,mode:448});let r=(0,n.join)(s,"push.sqlite");this.db=new o(r),(0,i.chmodSync)(r,384),this.db.pragma("busy_timeout = 5000"),this.db.exec(`
|
|
2
2
|
CREATE TABLE IF NOT EXISTS push_keys (id INTEGER PRIMARY KEY CHECK(id=1), public_key TEXT NOT NULL, private_key TEXT NOT NULL);
|
|
3
3
|
CREATE TABLE IF NOT EXISTS push_subscriptions (
|
|
4
4
|
endpoint_hash TEXT PRIMARY KEY,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(()=>{var e={};e.id=2549,e.ids=[2549],e.modules={7728:e=>{e.exports=require("@anthropic-ai/claude-agent-sdk")},5890:e=>{e.exports=require("better-sqlite3")},399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},1282:e=>{e.exports=require("child_process")},2048:e=>{e.exports=require("fs")},9801:e=>{e.exports=require("os")},5315:e=>{e.exports=require("path")},7718:e=>{e.exports=require("node:child_process")},6005:e=>{e.exports=require("node:crypto")},5673:e=>{e.exports=require("node:events")},7561:e=>{e.exports=require("node:fs")},3977:e=>{e.exports=require("node:fs/promises")},8849:e=>{e.exports=require("node:http")},2286:e=>{e.exports=require("node:https")},2033:e=>{e.exports=require("node:module")},7503:e=>{e.exports=require("node:net")},612:e=>{e.exports=require("node:os")},9411:e=>{e.exports=require("node:path")},1747:e=>{e.exports=require("node:readline")},4492:e=>{e.exports=require("node:stream")},6915:e=>{e.exports=require("node:string_decoder")},1041:e=>{e.exports=require("node:url")},7261:e=>{e.exports=require("node:util")},7228:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>f,patchFetch:()=>I,requestAsyncStorage:()=>u,routeModule:()=>c,serverHooks:()=>m,staticGenerationAsyncStorage:()=>p});var o={};r.r(o),r.d(o,{GET:()=>d,dynamic:()=>l});var s=r(7786),n=r(5042),i=r(2184),a=r(6089);let l="force-dynamic";async function d(e){try{return(0,a.Pj)(e),Response.json(await (0,a.Wt)(),{headers:{"cache-control":"no-store"}})}catch(e){return(0,a.u4)(e)}}let c=new s.AppRouteRouteModule({definition:{kind:n.x.APP_ROUTE,page:"/api/flow/v1/catalog/route",pathname:"/api/flow/v1/catalog",filename:"route",bundlePath:"app/api/flow/v1/catalog/route"},resolvedPagePath:"/Volumes/ext/project/team-agent/packages/server/app/api/flow/v1/catalog/route.ts",nextConfigOutput:"standalone",userland:o}),{requestAsyncStorage:u,staticGenerationAsyncStorage:p,serverHooks:m}=c,f="/api/flow/v1/catalog/route";function I(){return(0,i.patchFetch)({serverHooks:m,staticGenerationAsyncStorage:p})}},7786:(e,t,r)=>{e.exports=r(517)},6089:(e,t,r)=>{r.d(t,{Cm:()=>f,NB:()=>I,Pj:()=>c,WA:()=>h,Wt:()=>p,k8:()=>m,u4:()=>u,v9:()=>g});var o=r(6005),s=r(4621),n=r(1982),i=r(8615),a=r(6361);class l extends Error{constructor(e,t,r=400){super(t),this.code=e,this.status=r,this.name="FlowProtocolError"}}let d=new Map;function c(e){let t=(process.env.AGENT_RUN_TOKEN||process.env.PORTFOLIO_SKILL_TOKEN)?.trim();if(!t)return;let r=e.headers.get("authorization")??"",s=r.startsWith("Bearer ")?r.slice(7):"",n=Buffer.from(s),i=Buffer.from(t);if(n.length!==i.length||!(0,o.timingSafeEqual)(n,i))throw new l("UNAUTHORIZED","Flow protocol authentication failed",401)}function u(e){if(e instanceof l)return Response.json({error:e.message,code:e.code},{status:e.status});let t=e instanceof Error?e.message:"Flow protocol request failed",r="object"==typeof e&&null!==e&&"code"in e?String(e.code):"";if("SESSION_OCCUPIED"===r||"SESSION_ALREADY_RUNNING"===r)return Response.json({error:t,code:"SESSION_OCCUPIED"},{status:409});let o={AGENT_NOT_FOUND:404,SKILL_NOT_FOUND:404,MODEL_PROFILE_NOT_FOUND:404,SKILL_NOT_ALLOWED:422,TOOL_POLICY_NOT_FOUND:404,TOOL_POLICY_DISABLED:422};return r in o?Response.json({error:t,code:"INVALID_CAPABILITY"},{status:o[r]}):"INVALID_RUN_REQUEST"===r?Response.json({error:t,code:"INVALID_REQUEST"},{status:400}):Response.json({error:t,code:"RUN_FAILED"},{status:500})}async function p(){let e=(0,n.dp)().publicView(),t=(0,s.i)(),r=await t.call("listSkills",[]),o=(0,a.e)().getAll(),l=await t.mcp.listAll();return{protocolVersion:"1",provider:{id:"customer-agent",name:"Customer Agent"},features:{streaming:!0,memory:!0,cancellation:!0},models:e.profiles.map(e=>({id:e.id,name:e.name,provider:e.provider,modelId:e.modelId})),skills:r.filter(e=>!1!==e.enabled).map(e=>({id:e.name,name:e.name,description:e.description??""})),tools:o.map(e=>({id:e.name,name:e.name,description:e.description,inputSchema:e.parameters})),mcpServers:l.map(e=>({id:e.id,name:e.name||e.id,status:"available"})),toolPolicies:await (0,i.cm)().summaries()}}function m(e){let t=S(e,"request"),r=E(t.input,"input",1e5),o=function(e,t,r){if(void 0!==e)return E(e,t,32e3)}(t.instructions,"instructions",0),s=_(t.agentId,"agentId"),n=_(t.sessionId,"sessionId"),i=void 0===t.context?{}:S(t.context,"context");if(JSON.stringify(i).length>12e4)throw new l("INVALID_REQUEST","context is too large");let a=void 0===t.selection?{}:S(t.selection,"selection"),d={};for(let[e,t]of(d.modelId=_(a.modelId,"selection.modelId"),d.toolPolicyId=_(a.toolPolicyId,"selection.toolPolicyId"),[["skillIds","skillIds"],["activatedSkillIds","activatedSkillIds"],["toolIds","toolIds"],["mcpServerIds","mcpServerIds"]])){let r=function(e,t){if(void 0===e)return;if(!Array.isArray(e)||e.length>200)throw new l("INVALID_REQUEST",`${t} must contain at most 200 identifiers`);let r=e.map(e=>E(e,t));if(new Set(r).size!==r.length)throw new l("INVALID_REQUEST",`${t} contains duplicate identifiers`);return r}(a[e],`selection.${e}`);void 0!==r&&(d[t]=r)}if(void 0!==a.memoryEnabled){if("boolean"!=typeof a.memoryEnabled)throw new l("INVALID_REQUEST","selection.memoryEnabled must be boolean");d.memoryEnabled=a.memoryEnabled}if(d.skillIds&&d.activatedSkillIds){let e=new Set(d.skillIds);if(d.activatedSkillIds.some(t=>!e.has(t)))throw new l("INVALID_REQUEST","activatedSkillIds must be a subset of skillIds")}return{input:r,...o?{instructions:o}:{},...s?{agentId:s}:{},...n?{sessionId:n}:{},context:i,selection:d}}async function f(e){let t=await p();if(e.agentId&&!await (0,s.i)().agents.get(e.agentId))throw new l("INVALID_CAPABILITY",`Unknown Agent: ${e.agentId}`,404);v(e.selection.modelId?[e.selection.modelId]:void 0,t.models,"model"),v(e.selection.skillIds,t.skills,"Skill"),v(e.selection.activatedSkillIds,t.skills,"activated Skill"),v(e.selection.toolIds,t.tools,"Tool"),v(e.selection.mcpServerIds,t.mcpServers,"MCP server"),v(e.selection.toolPolicyId?[e.selection.toolPolicyId]:void 0,t.toolPolicies,"tool policy")}function I(e,t){for(w(),d.set(e,{runId:e,sessionId:t,createdAt:Date.now()});d.size>500;)d.delete(d.keys().next().value)}function h(e){w();let t=d.get(e);if(!t)throw new l("RUN_NOT_FOUND","Flow protocol run not found",404);return t}function g(e,t,r,o){let s={runId:e,sessionId:t,timestamp:new Date().toISOString()};return"text_chunk"===o.type?{id:r,event:"assistant.delta",data:{...s,text:o.text}}:"tool_call"===o.type?{id:r,event:"tool.started",data:{...s,callId:o.toolCall.id,name:o.toolCall.name,arguments:o.toolCall.arguments}}:"tool_result"===o.type?{id:r,event:"tool.completed",data:{...s,callId:o.result.toolCallId,content:o.result.content,isError:!0===o.result.isError}}:"done"===o.type?{id:r,event:"run.completed",data:{...s,text:o.finalText,durationMs:o.durationMs,usage:o.usage}}:"error"===o.type?{id:r,event:"run.failed",data:{...s,code:o.code||"RUN_FAILED",message:o.message}}:"turn_aborted"===o.type?{id:r,event:"run.failed",data:{...s,code:"RUN_CANCELLED",message:"Run cancelled"}}:null}function w(){let e=Date.now()-36e5;for(let[t,r]of d)r.createdAt<e&&d.delete(t)}function v(e,t,r){if(void 0===e)return;let o=new Set(t.map(e=>e.id)),s=e.find(e=>!o.has(e));if(s)throw new l("INVALID_CAPABILITY",`Unknown ${r}: ${s}`,422)}function S(e,t){if(!e||"object"!=typeof e||Array.isArray(e))throw new l("INVALID_REQUEST",`${t} must be an object`);return e}function E(e,t,r=200){if("string"!=typeof e||!e.trim()||e.length>r)throw new l("INVALID_REQUEST",`${t} must be a non-empty string no longer than ${r} characters`);return e.trim()}function _(e,t){if(void 0!==e)return E(e,t)}},6361:(e,t,r)=>{r.d(t,{Q:()=>i,e:()=>n});var o=r(1322),s=r(7519);function n(){let e=new o.S3T;(0,o._5y)(e);let t=new o.OqQ;for(let r of(e.register(new o.Q8u(t,null)),e.register(new o.URd(t,null)),s.agentHost.getBuilder().getToolRegistry().getAll()))e.register(r);return e}function i(){return n().getAll().map(e=>e.name).sort()}},1489:(e,t,r)=>{r.d(t,{N:()=>l});var o=r(1322),s=r(6279),n=r(785);class i{constructor(){this.tasks=new o.vo4((0,n.kO)()),this.scheduler=new s.ST(this.tasks,e=>{this.fire(e).catch(e=>console.error("Scheduled Customer Agent run failed",e))},()=>{}),this.scheduler.start()}async fire(e){let{agentHost:t}=await r.e(7519).then(r.bind(r,7519)),{getCustomerGoalCoordinator:o}=await Promise.all([r.e(7519),r.e(732)]).then(r.bind(r,5038)),s=e.sessionId;s&&await t.getSessionStore().get(s)||(s=(await t.createSession(e.label||"定时任务")).id,this.tasks.update(e.id,{sessionId:s})),await o().enqueue(s,e.prompt)}call(e,t){let r=String(t[0]||"");switch(e){case"cronList":return this.tasks.list();case"cronCreate":{if("string"!=typeof t[0]||"string"!=typeof t[1]||!t[1].trim())throw Error("cron and prompt required");let e=t[2]&&"object"==typeof t[2]?t[2]:{};return this.tasks.create({cron:t[0],prompt:t[1],recurring:!1!==e.recurring,enabled:!0,durable:!0,..."string"==typeof e.sessionId?{sessionId:e.sessionId}:{},..."string"==typeof e.label?{label:e.label}:{}})}case"cronPause":return this.tasks.pause(r);case"cronResume":return this.tasks.resume(r);case"cronDelete":return this.tasks.delete(r);case"cronDeleteAll":return this.tasks.deleteAll(),{ok:!0};default:throw Error("Unsupported schedule operation")}}}let a=globalThis;function l(){return a.__sharedCronService??=new i}},8615:(e,t,r)=>{let o;r.d(t,{H5:()=>c,cm:()=>l,jw:()=>d});var s=r(1322),n=r(785),i=r(6361);class a{constructor(e=(0,n.kO)()){this.store=new s.RQW(e)}list(){return this.store.list()}get(e){return this.store.get(e)}async summaries(){return(await this.store.list()).filter(e=>e.enabled).map(s._0R)}save(e,t){let r=(0,s.IJh)(e,{knownTools:t,requireExecutables:!0});return this.store.save(r)}delete(e){return this.store.delete(e)}}function l(){return o??=new a}function d(){return(0,i.Q)()}function c(e){let t=e instanceof s.DlR?422:400;return Response.json({error:e instanceof Error?e.message:"Tool policy request failed",code:e instanceof s.DlR?e.code:"INVALID_TOOL_POLICY"},{status:t})}}};var t=require("../../../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),o=t.X(0,[8375,6244,1322,1773,4621,7519],()=>r(7228));module.exports=o})();
|
|
1
|
+
"use strict";(()=>{var e={};e.id=2549,e.ids=[2549],e.modules={7728:e=>{e.exports=require("@anthropic-ai/claude-agent-sdk")},5890:e=>{e.exports=require("better-sqlite3")},399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},1282:e=>{e.exports=require("child_process")},2048:e=>{e.exports=require("fs")},9801:e=>{e.exports=require("os")},5315:e=>{e.exports=require("path")},7718:e=>{e.exports=require("node:child_process")},6005:e=>{e.exports=require("node:crypto")},5673:e=>{e.exports=require("node:events")},7561:e=>{e.exports=require("node:fs")},3977:e=>{e.exports=require("node:fs/promises")},8849:e=>{e.exports=require("node:http")},2286:e=>{e.exports=require("node:https")},2033:e=>{e.exports=require("node:module")},7503:e=>{e.exports=require("node:net")},612:e=>{e.exports=require("node:os")},9411:e=>{e.exports=require("node:path")},1747:e=>{e.exports=require("node:readline")},4492:e=>{e.exports=require("node:stream")},6915:e=>{e.exports=require("node:string_decoder")},1041:e=>{e.exports=require("node:url")},7261:e=>{e.exports=require("node:util")},7228:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>f,patchFetch:()=>I,requestAsyncStorage:()=>u,routeModule:()=>c,serverHooks:()=>m,staticGenerationAsyncStorage:()=>p});var o={};r.r(o),r.d(o,{GET:()=>d,dynamic:()=>l});var s=r(7786),n=r(5042),i=r(2184),a=r(6089);let l="force-dynamic";async function d(e){try{return(0,a.Pj)(e),Response.json(await (0,a.Wt)(),{headers:{"cache-control":"no-store"}})}catch(e){return(0,a.u4)(e)}}let c=new s.AppRouteRouteModule({definition:{kind:n.x.APP_ROUTE,page:"/api/flow/v1/catalog/route",pathname:"/api/flow/v1/catalog",filename:"route",bundlePath:"app/api/flow/v1/catalog/route"},resolvedPagePath:"/Volumes/ext/project/team-agent/packages/server/app/api/flow/v1/catalog/route.ts",nextConfigOutput:"standalone",userland:o}),{requestAsyncStorage:u,staticGenerationAsyncStorage:p,serverHooks:m}=c,f="/api/flow/v1/catalog/route";function I(){return(0,i.patchFetch)({serverHooks:m,staticGenerationAsyncStorage:p})}},7786:(e,t,r)=>{e.exports=r(517)},6089:(e,t,r)=>{r.d(t,{Cm:()=>f,NB:()=>I,Pj:()=>c,WA:()=>g,Wt:()=>p,k8:()=>m,u4:()=>u,v9:()=>h});var o=r(6005),s=r(4621),n=r(1982),i=r(8615),a=r(6361);class l extends Error{constructor(e,t,r=400){super(t),this.code=e,this.status=r,this.name="FlowProtocolError"}}let d=new Map;function c(e){let t=(process.env.AGENT_RUN_TOKEN||process.env.PORTFOLIO_SKILL_TOKEN)?.trim();if(!t)return;let r=e.headers.get("authorization")??"",s=r.startsWith("Bearer ")?r.slice(7):"",n=Buffer.from(s),i=Buffer.from(t);if(n.length!==i.length||!(0,o.timingSafeEqual)(n,i))throw new l("UNAUTHORIZED","Flow protocol authentication failed",401)}function u(e){if(e instanceof l)return Response.json({error:e.message,code:e.code},{status:e.status});let t=e instanceof Error?e.message:"Flow protocol request failed",r="object"==typeof e&&null!==e&&"code"in e?String(e.code):"";if("SESSION_OCCUPIED"===r||"SESSION_ALREADY_RUNNING"===r)return Response.json({error:t,code:"SESSION_OCCUPIED"},{status:409});let o={AGENT_NOT_FOUND:404,SKILL_NOT_FOUND:404,MODEL_PROFILE_NOT_FOUND:404,SKILL_NOT_ALLOWED:422,TOOL_POLICY_NOT_FOUND:404,TOOL_POLICY_DISABLED:422};return r in o?Response.json({error:t,code:"INVALID_CAPABILITY"},{status:o[r]}):"INVALID_RUN_REQUEST"===r?Response.json({error:t,code:"INVALID_REQUEST"},{status:400}):Response.json({error:t,code:"RUN_FAILED"},{status:500})}async function p(){let e=(0,n.dp)().publicView(),t=(0,s.i)(),r=await t.call("listSkills",[]),o=(0,a.e)().getAll(),l=await t.mcp.listAll();return{protocolVersion:"1",provider:{id:"customer-agent",name:"Customer Agent"},features:{streaming:!0,memory:!0,cancellation:!0},models:e.profiles.map(e=>({id:e.id,name:e.name,provider:e.provider,modelId:e.modelId})),skills:r.filter(e=>!1!==e.enabled).map(e=>({id:e.name,name:e.name,description:e.description??""})),tools:o.map(e=>({id:e.name,name:e.name,description:e.description,inputSchema:e.parameters})),mcpServers:l.map(e=>({id:e.id,name:e.name||e.id,status:"available"})),toolPolicies:await (0,i.cm)().summaries()}}function m(e){let t=S(e,"request"),r=E(t.input,"input",1e5),o=function(e,t,r){if(void 0!==e)return E(e,t,32e3)}(t.instructions,"instructions",0),s=_(t.agentId,"agentId"),n=_(t.sessionId,"sessionId"),i=void 0===t.context?{}:S(t.context,"context");if(JSON.stringify(i).length>12e4)throw new l("INVALID_REQUEST","context is too large");let a=void 0===t.selection?{}:S(t.selection,"selection"),d={};for(let[e,t]of(d.modelId=_(a.modelId,"selection.modelId"),d.toolPolicyId=_(a.toolPolicyId,"selection.toolPolicyId"),[["skillIds","skillIds"],["activatedSkillIds","activatedSkillIds"],["toolIds","toolIds"],["mcpServerIds","mcpServerIds"]])){let r=function(e,t){if(void 0===e)return;if(!Array.isArray(e)||e.length>200)throw new l("INVALID_REQUEST",`${t} must contain at most 200 identifiers`);let r=e.map(e=>E(e,t));if(new Set(r).size!==r.length)throw new l("INVALID_REQUEST",`${t} contains duplicate identifiers`);return r}(a[e],`selection.${e}`);void 0!==r&&(d[t]=r)}if(void 0!==a.memoryEnabled){if("boolean"!=typeof a.memoryEnabled)throw new l("INVALID_REQUEST","selection.memoryEnabled must be boolean");d.memoryEnabled=a.memoryEnabled}if(d.skillIds&&d.activatedSkillIds){let e=new Set(d.skillIds);if(d.activatedSkillIds.some(t=>!e.has(t)))throw new l("INVALID_REQUEST","activatedSkillIds must be a subset of skillIds")}return{input:r,...o?{instructions:o}:{},...s?{agentId:s}:{},...n?{sessionId:n}:{},context:i,selection:d}}async function f(e){let t=await p();if(e.agentId&&!await (0,s.i)().agents.get(e.agentId))throw new l("INVALID_CAPABILITY",`Unknown Agent: ${e.agentId}`,404);v(e.selection.modelId?[e.selection.modelId]:void 0,t.models,"model"),v(e.selection.skillIds,t.skills,"Skill"),v(e.selection.activatedSkillIds,t.skills,"activated Skill"),v(e.selection.toolIds,t.tools,"Tool"),v(e.selection.mcpServerIds,t.mcpServers,"MCP server"),v(e.selection.toolPolicyId?[e.selection.toolPolicyId]:void 0,t.toolPolicies,"tool policy")}function I(e,t){for(w(),d.set(e,{runId:e,sessionId:t,createdAt:Date.now()});d.size>500;)d.delete(d.keys().next().value)}function g(e){w();let t=d.get(e);if(!t)throw new l("RUN_NOT_FOUND","Flow protocol run not found",404);return t}function h(e,t,r,o){let s={runId:e,sessionId:t,timestamp:new Date().toISOString()};return"text_chunk"===o.type?{id:r,event:"assistant.delta",data:{...s,text:o.text}}:"tool_call"===o.type?{id:r,event:"tool.started",data:{...s,callId:o.toolCall.id,name:o.toolCall.name,arguments:o.toolCall.arguments}}:"tool_result"===o.type?{id:r,event:"tool.completed",data:{...s,callId:o.result.toolCallId,content:o.result.content,isError:!0===o.result.isError}}:"done"===o.type?{id:r,event:"run.completed",data:{...s,text:o.finalText,durationMs:o.durationMs,usage:o.usage}}:"error"===o.type?{id:r,event:"run.failed",data:{...s,code:o.code||"RUN_FAILED",message:o.message}}:"turn_aborted"===o.type?{id:r,event:"run.failed",data:{...s,code:"RUN_CANCELLED",message:"Run cancelled"}}:null}function w(){let e=Date.now()-36e5;for(let[t,r]of d)r.createdAt<e&&d.delete(t)}function v(e,t,r){if(void 0===e)return;let o=new Set(t.map(e=>e.id)),s=e.find(e=>!o.has(e));if(s)throw new l("INVALID_CAPABILITY",`Unknown ${r}: ${s}`,422)}function S(e,t){if(!e||"object"!=typeof e||Array.isArray(e))throw new l("INVALID_REQUEST",`${t} must be an object`);return e}function E(e,t,r=200){if("string"!=typeof e||!e.trim()||e.length>r)throw new l("INVALID_REQUEST",`${t} must be a non-empty string no longer than ${r} characters`);return e.trim()}function _(e,t){if(void 0!==e)return E(e,t)}},6361:(e,t,r)=>{r.d(t,{Q:()=>i,e:()=>n});var o=r(1322),s=r(7519);function n(){let e=new o.S3T;(0,o._5y)(e);let t=new o.OqQ;for(let r of(e.register(new o.Q8u(t,null)),e.register(new o.URd(t,null)),s.agentHost.getBuilder().getToolRegistry().getAll()))e.register(r);return e.register(new o.gBG(async()=>({status:"failed",agentName:"",subSessionId:"",error:"catalog listing only; dispatch runs inside a Customer Agent session"}))),e.register(new o.HbQ(async()=>({status:"failed",agentName:"",subSessionId:"",error:"catalog listing only; dispatch runs inside a Customer Agent session"}))),e}function i(){return n().getAll().map(e=>e.name).sort()}},1489:(e,t,r)=>{r.d(t,{N:()=>l});var o=r(1322),s=r(6279),n=r(785);class i{constructor(){this.tasks=new o.vo4((0,n.kO)()),this.scheduler=new s.ST(this.tasks,e=>{this.fire(e).catch(e=>console.error("Scheduled Customer Agent run failed",e))},()=>{}),this.scheduler.start()}async fire(e){let{agentHost:t}=await r.e(7519).then(r.bind(r,7519)),{getCustomerGoalCoordinator:o}=await Promise.all([r.e(7519),r.e(732)]).then(r.bind(r,5038)),s=e.sessionId;s&&await t.getSessionStore().get(s)||(s=(await t.createSession(e.label||"定时任务")).id,this.tasks.update(e.id,{sessionId:s})),await o().enqueue(s,e.prompt)}call(e,t){let r=String(t[0]||"");switch(e){case"cronList":return this.tasks.list();case"cronCreate":{if("string"!=typeof t[0]||"string"!=typeof t[1]||!t[1].trim())throw Error("cron and prompt required");let e=t[2]&&"object"==typeof t[2]?t[2]:{};return this.tasks.create({cron:t[0],prompt:t[1],recurring:!1!==e.recurring,enabled:!0,durable:!0,..."string"==typeof e.sessionId?{sessionId:e.sessionId}:{},..."string"==typeof e.label?{label:e.label}:{}})}case"cronPause":return this.tasks.pause(r);case"cronResume":return this.tasks.resume(r);case"cronDelete":return this.tasks.delete(r);case"cronDeleteAll":return this.tasks.deleteAll(),{ok:!0};default:throw Error("Unsupported schedule operation")}}}let a=globalThis;function l(){return a.__sharedCronService??=new i}},8615:(e,t,r)=>{let o;r.d(t,{H5:()=>c,cm:()=>l,jw:()=>d});var s=r(1322),n=r(785),i=r(6361);class a{constructor(e=(0,n.kO)()){this.store=new s.RQW(e)}list(){return this.store.list()}get(e){return this.store.get(e)}async summaries(){return(await this.store.list()).filter(e=>e.enabled).map(s._0R)}save(e,t){let r=(0,s.IJh)(e,{knownTools:t,requireExecutables:!0});return this.store.save(r)}delete(e){return this.store.delete(e)}}function l(){return o??=new a}function d(){return(0,i.Q)()}function c(e){let t=e instanceof s.DlR?422:400;return Response.json({error:e instanceof Error?e.message:"Tool policy request failed",code:e instanceof s.DlR?e.code:"INVALID_TOOL_POLICY"},{status:t})}}};var t=require("../../../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),o=t.X(0,[8375,6244,1322,1773,4621,7519],()=>r(7228));module.exports=o})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(()=>{var e={};e.id=6522,e.ids=[6522],e.modules={7728:e=>{e.exports=require("@anthropic-ai/claude-agent-sdk")},5890:e=>{e.exports=require("better-sqlite3")},399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},1282:e=>{e.exports=require("child_process")},2048:e=>{e.exports=require("fs")},9801:e=>{e.exports=require("os")},5315:e=>{e.exports=require("path")},7718:e=>{e.exports=require("node:child_process")},6005:e=>{e.exports=require("node:crypto")},5673:e=>{e.exports=require("node:events")},7561:e=>{e.exports=require("node:fs")},3977:e=>{e.exports=require("node:fs/promises")},8849:e=>{e.exports=require("node:http")},2286:e=>{e.exports=require("node:https")},2033:e=>{e.exports=require("node:module")},7503:e=>{e.exports=require("node:net")},612:e=>{e.exports=require("node:os")},9411:e=>{e.exports=require("node:path")},1747:e=>{e.exports=require("node:readline")},4492:e=>{e.exports=require("node:stream")},6915:e=>{e.exports=require("node:string_decoder")},1041:e=>{e.exports=require("node:url")},7261:e=>{e.exports=require("node:util")},8085:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>I,patchFetch:()=>f,requestAsyncStorage:()=>c,routeModule:()=>u,serverHooks:()=>m,staticGenerationAsyncStorage:()=>p});var o={};r.r(o),r.d(o,{POST:()=>d});var s=r(7786),n=r(5042),i=r(2184),l=r(7519),a=r(6089);async function d(e,{params:t}){try{(0,a.Pj)(e);let r=(0,a.WA)(t.runId);if(!l.agentHost.isSessionRunning(r.sessionId))return Response.json({error:"Flow protocol run is not active",code:"RUN_NOT_ACTIVE"},{status:409});return l.agentHost.abort(r.sessionId),Response.json({ok:!0,runId:r.runId})}catch(e){return(0,a.u4)(e)}}let u=new s.AppRouteRouteModule({definition:{kind:n.x.APP_ROUTE,page:"/api/flow/v1/runs/[runId]/cancel/route",pathname:"/api/flow/v1/runs/[runId]/cancel",filename:"route",bundlePath:"app/api/flow/v1/runs/[runId]/cancel/route"},resolvedPagePath:"/Volumes/ext/project/team-agent/packages/server/app/api/flow/v1/runs/[runId]/cancel/route.ts",nextConfigOutput:"standalone",userland:o}),{requestAsyncStorage:c,staticGenerationAsyncStorage:p,serverHooks:m}=u,I="/api/flow/v1/runs/[runId]/cancel/route";function f(){return(0,i.patchFetch)({serverHooks:m,staticGenerationAsyncStorage:p})}},7786:(e,t,r)=>{e.exports=r(517)},6089:(e,t,r)=>{r.d(t,{Cm:()=>I,NB:()=>f,Pj:()=>u,WA:()=>h,Wt:()=>p,k8:()=>m,u4:()=>c,v9:()=>g});var o=r(6005),s=r(4621),n=r(1982),i=r(8615),l=r(6361);class a extends Error{constructor(e,t,r=400){super(t),this.code=e,this.status=r,this.name="FlowProtocolError"}}let d=new Map;function u(e){let t=(process.env.AGENT_RUN_TOKEN||process.env.PORTFOLIO_SKILL_TOKEN)?.trim();if(!t)return;let r=e.headers.get("authorization")??"",s=r.startsWith("Bearer ")?r.slice(7):"",n=Buffer.from(s),i=Buffer.from(t);if(n.length!==i.length||!(0,o.timingSafeEqual)(n,i))throw new a("UNAUTHORIZED","Flow protocol authentication failed",401)}function c(e){if(e instanceof a)return Response.json({error:e.message,code:e.code},{status:e.status});let t=e instanceof Error?e.message:"Flow protocol request failed",r="object"==typeof e&&null!==e&&"code"in e?String(e.code):"";if("SESSION_OCCUPIED"===r||"SESSION_ALREADY_RUNNING"===r)return Response.json({error:t,code:"SESSION_OCCUPIED"},{status:409});let o={AGENT_NOT_FOUND:404,SKILL_NOT_FOUND:404,MODEL_PROFILE_NOT_FOUND:404,SKILL_NOT_ALLOWED:422,TOOL_POLICY_NOT_FOUND:404,TOOL_POLICY_DISABLED:422};return r in o?Response.json({error:t,code:"INVALID_CAPABILITY"},{status:o[r]}):"INVALID_RUN_REQUEST"===r?Response.json({error:t,code:"INVALID_REQUEST"},{status:400}):Response.json({error:t,code:"RUN_FAILED"},{status:500})}async function p(){let e=(0,n.dp)().publicView(),t=(0,s.i)(),r=await t.call("listSkills",[]),o=(0,l.e)().getAll(),a=await t.mcp.listAll();return{protocolVersion:"1",provider:{id:"customer-agent",name:"Customer Agent"},features:{streaming:!0,memory:!0,cancellation:!0},models:e.profiles.map(e=>({id:e.id,name:e.name,provider:e.provider,modelId:e.modelId})),skills:r.filter(e=>!1!==e.enabled).map(e=>({id:e.name,name:e.name,description:e.description??""})),tools:o.map(e=>({id:e.name,name:e.name,description:e.description,inputSchema:e.parameters})),mcpServers:a.map(e=>({id:e.id,name:e.name||e.id,status:"available"})),toolPolicies:await (0,i.cm)().summaries()}}function m(e){let t=S(e,"request"),r=_(t.input,"input",1e5),o=function(e,t,r){if(void 0!==e)return _(e,t,32e3)}(t.instructions,"instructions",0),s=E(t.agentId,"agentId"),n=E(t.sessionId,"sessionId"),i=void 0===t.context?{}:S(t.context,"context");if(JSON.stringify(i).length>12e4)throw new a("INVALID_REQUEST","context is too large");let l=void 0===t.selection?{}:S(t.selection,"selection"),d={};for(let[e,t]of(d.modelId=E(l.modelId,"selection.modelId"),d.toolPolicyId=E(l.toolPolicyId,"selection.toolPolicyId"),[["skillIds","skillIds"],["activatedSkillIds","activatedSkillIds"],["toolIds","toolIds"],["mcpServerIds","mcpServerIds"]])){let r=function(e,t){if(void 0===e)return;if(!Array.isArray(e)||e.length>200)throw new a("INVALID_REQUEST",`${t} must contain at most 200 identifiers`);let r=e.map(e=>_(e,t));if(new Set(r).size!==r.length)throw new a("INVALID_REQUEST",`${t} contains duplicate identifiers`);return r}(l[e],`selection.${e}`);void 0!==r&&(d[t]=r)}if(void 0!==l.memoryEnabled){if("boolean"!=typeof l.memoryEnabled)throw new a("INVALID_REQUEST","selection.memoryEnabled must be boolean");d.memoryEnabled=l.memoryEnabled}if(d.skillIds&&d.activatedSkillIds){let e=new Set(d.skillIds);if(d.activatedSkillIds.some(t=>!e.has(t)))throw new a("INVALID_REQUEST","activatedSkillIds must be a subset of skillIds")}return{input:r,...o?{instructions:o}:{},...s?{agentId:s}:{},...n?{sessionId:n}:{},context:i,selection:d}}async function I(e){let t=await p();if(e.agentId&&!await (0,s.i)().agents.get(e.agentId))throw new a("INVALID_CAPABILITY",`Unknown Agent: ${e.agentId}`,404);v(e.selection.modelId?[e.selection.modelId]:void 0,t.models,"model"),v(e.selection.skillIds,t.skills,"Skill"),v(e.selection.activatedSkillIds,t.skills,"activated Skill"),v(e.selection.toolIds,t.tools,"Tool"),v(e.selection.mcpServerIds,t.mcpServers,"MCP server"),v(e.selection.toolPolicyId?[e.selection.toolPolicyId]:void 0,t.toolPolicies,"tool policy")}function f(e,t){for(w(),d.set(e,{runId:e,sessionId:t,createdAt:Date.now()});d.size>500;)d.delete(d.keys().next().value)}function h(e){w();let t=d.get(e);if(!t)throw new a("RUN_NOT_FOUND","Flow protocol run not found",404);return t}function g(e,t,r,o){let s={runId:e,sessionId:t,timestamp:new Date().toISOString()};return"text_chunk"===o.type?{id:r,event:"assistant.delta",data:{...s,text:o.text}}:"tool_call"===o.type?{id:r,event:"tool.started",data:{...s,callId:o.toolCall.id,name:o.toolCall.name,arguments:o.toolCall.arguments}}:"tool_result"===o.type?{id:r,event:"tool.completed",data:{...s,callId:o.result.toolCallId,content:o.result.content,isError:!0===o.result.isError}}:"done"===o.type?{id:r,event:"run.completed",data:{...s,text:o.finalText,durationMs:o.durationMs,usage:o.usage}}:"error"===o.type?{id:r,event:"run.failed",data:{...s,code:o.code||"RUN_FAILED",message:o.message}}:"turn_aborted"===o.type?{id:r,event:"run.failed",data:{...s,code:"RUN_CANCELLED",message:"Run cancelled"}}:null}function w(){let e=Date.now()-36e5;for(let[t,r]of d)r.createdAt<e&&d.delete(t)}function v(e,t,r){if(void 0===e)return;let o=new Set(t.map(e=>e.id)),s=e.find(e=>!o.has(e));if(s)throw new a("INVALID_CAPABILITY",`Unknown ${r}: ${s}`,422)}function S(e,t){if(!e||"object"!=typeof e||Array.isArray(e))throw new a("INVALID_REQUEST",`${t} must be an object`);return e}function _(e,t,r=200){if("string"!=typeof e||!e.trim()||e.length>r)throw new a("INVALID_REQUEST",`${t} must be a non-empty string no longer than ${r} characters`);return e.trim()}function E(e,t){if(void 0!==e)return _(e,t)}},6361:(e,t,r)=>{r.d(t,{Q:()=>i,e:()=>n});var o=r(1322),s=r(7519);function n(){let e=new o.S3T;(0,o._5y)(e);let t=new o.OqQ;for(let r of(e.register(new o.Q8u(t,null)),e.register(new o.URd(t,null)),s.agentHost.getBuilder().getToolRegistry().getAll()))e.register(r);return e}function i(){return n().getAll().map(e=>e.name).sort()}},1489:(e,t,r)=>{r.d(t,{N:()=>a});var o=r(1322),s=r(6279),n=r(785);class i{constructor(){this.tasks=new o.vo4((0,n.kO)()),this.scheduler=new s.ST(this.tasks,e=>{this.fire(e).catch(e=>console.error("Scheduled Customer Agent run failed",e))},()=>{}),this.scheduler.start()}async fire(e){let{agentHost:t}=await r.e(7519).then(r.bind(r,7519)),{getCustomerGoalCoordinator:o}=await Promise.all([r.e(7519),r.e(732)]).then(r.bind(r,5038)),s=e.sessionId;s&&await t.getSessionStore().get(s)||(s=(await t.createSession(e.label||"定时任务")).id,this.tasks.update(e.id,{sessionId:s})),await o().enqueue(s,e.prompt)}call(e,t){let r=String(t[0]||"");switch(e){case"cronList":return this.tasks.list();case"cronCreate":{if("string"!=typeof t[0]||"string"!=typeof t[1]||!t[1].trim())throw Error("cron and prompt required");let e=t[2]&&"object"==typeof t[2]?t[2]:{};return this.tasks.create({cron:t[0],prompt:t[1],recurring:!1!==e.recurring,enabled:!0,durable:!0,..."string"==typeof e.sessionId?{sessionId:e.sessionId}:{},..."string"==typeof e.label?{label:e.label}:{}})}case"cronPause":return this.tasks.pause(r);case"cronResume":return this.tasks.resume(r);case"cronDelete":return this.tasks.delete(r);case"cronDeleteAll":return this.tasks.deleteAll(),{ok:!0};default:throw Error("Unsupported schedule operation")}}}let l=globalThis;function a(){return l.__sharedCronService??=new i}},8615:(e,t,r)=>{let o;r.d(t,{H5:()=>u,cm:()=>a,jw:()=>d});var s=r(1322),n=r(785),i=r(6361);class l{constructor(e=(0,n.kO)()){this.store=new s.RQW(e)}list(){return this.store.list()}get(e){return this.store.get(e)}async summaries(){return(await this.store.list()).filter(e=>e.enabled).map(s._0R)}save(e,t){let r=(0,s.IJh)(e,{knownTools:t,requireExecutables:!0});return this.store.save(r)}delete(e){return this.store.delete(e)}}function a(){return o??=new l}function d(){return(0,i.Q)()}function u(e){let t=e instanceof s.DlR?422:400;return Response.json({error:e instanceof Error?e.message:"Tool policy request failed",code:e instanceof s.DlR?e.code:"INVALID_TOOL_POLICY"},{status:t})}}};var t=require("../../../../../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),o=t.X(0,[8375,6244,1322,1773,4621,7519],()=>r(8085));module.exports=o})();
|
|
1
|
+
"use strict";(()=>{var e={};e.id=6522,e.ids=[6522],e.modules={7728:e=>{e.exports=require("@anthropic-ai/claude-agent-sdk")},5890:e=>{e.exports=require("better-sqlite3")},399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},1282:e=>{e.exports=require("child_process")},2048:e=>{e.exports=require("fs")},9801:e=>{e.exports=require("os")},5315:e=>{e.exports=require("path")},7718:e=>{e.exports=require("node:child_process")},6005:e=>{e.exports=require("node:crypto")},5673:e=>{e.exports=require("node:events")},7561:e=>{e.exports=require("node:fs")},3977:e=>{e.exports=require("node:fs/promises")},8849:e=>{e.exports=require("node:http")},2286:e=>{e.exports=require("node:https")},2033:e=>{e.exports=require("node:module")},7503:e=>{e.exports=require("node:net")},612:e=>{e.exports=require("node:os")},9411:e=>{e.exports=require("node:path")},1747:e=>{e.exports=require("node:readline")},4492:e=>{e.exports=require("node:stream")},6915:e=>{e.exports=require("node:string_decoder")},1041:e=>{e.exports=require("node:url")},7261:e=>{e.exports=require("node:util")},8085:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>I,patchFetch:()=>f,requestAsyncStorage:()=>c,routeModule:()=>u,serverHooks:()=>m,staticGenerationAsyncStorage:()=>p});var o={};r.r(o),r.d(o,{POST:()=>d});var s=r(7786),n=r(5042),i=r(2184),a=r(7519),l=r(6089);async function d(e,{params:t}){try{(0,l.Pj)(e);let r=(0,l.WA)(t.runId);if(!a.agentHost.isSessionRunning(r.sessionId))return Response.json({error:"Flow protocol run is not active",code:"RUN_NOT_ACTIVE"},{status:409});return a.agentHost.abort(r.sessionId),Response.json({ok:!0,runId:r.runId})}catch(e){return(0,l.u4)(e)}}let u=new s.AppRouteRouteModule({definition:{kind:n.x.APP_ROUTE,page:"/api/flow/v1/runs/[runId]/cancel/route",pathname:"/api/flow/v1/runs/[runId]/cancel",filename:"route",bundlePath:"app/api/flow/v1/runs/[runId]/cancel/route"},resolvedPagePath:"/Volumes/ext/project/team-agent/packages/server/app/api/flow/v1/runs/[runId]/cancel/route.ts",nextConfigOutput:"standalone",userland:o}),{requestAsyncStorage:c,staticGenerationAsyncStorage:p,serverHooks:m}=u,I="/api/flow/v1/runs/[runId]/cancel/route";function f(){return(0,i.patchFetch)({serverHooks:m,staticGenerationAsyncStorage:p})}},7786:(e,t,r)=>{e.exports=r(517)},6089:(e,t,r)=>{r.d(t,{Cm:()=>I,NB:()=>f,Pj:()=>u,WA:()=>g,Wt:()=>p,k8:()=>m,u4:()=>c,v9:()=>h});var o=r(6005),s=r(4621),n=r(1982),i=r(8615),a=r(6361);class l extends Error{constructor(e,t,r=400){super(t),this.code=e,this.status=r,this.name="FlowProtocolError"}}let d=new Map;function u(e){let t=(process.env.AGENT_RUN_TOKEN||process.env.PORTFOLIO_SKILL_TOKEN)?.trim();if(!t)return;let r=e.headers.get("authorization")??"",s=r.startsWith("Bearer ")?r.slice(7):"",n=Buffer.from(s),i=Buffer.from(t);if(n.length!==i.length||!(0,o.timingSafeEqual)(n,i))throw new l("UNAUTHORIZED","Flow protocol authentication failed",401)}function c(e){if(e instanceof l)return Response.json({error:e.message,code:e.code},{status:e.status});let t=e instanceof Error?e.message:"Flow protocol request failed",r="object"==typeof e&&null!==e&&"code"in e?String(e.code):"";if("SESSION_OCCUPIED"===r||"SESSION_ALREADY_RUNNING"===r)return Response.json({error:t,code:"SESSION_OCCUPIED"},{status:409});let o={AGENT_NOT_FOUND:404,SKILL_NOT_FOUND:404,MODEL_PROFILE_NOT_FOUND:404,SKILL_NOT_ALLOWED:422,TOOL_POLICY_NOT_FOUND:404,TOOL_POLICY_DISABLED:422};return r in o?Response.json({error:t,code:"INVALID_CAPABILITY"},{status:o[r]}):"INVALID_RUN_REQUEST"===r?Response.json({error:t,code:"INVALID_REQUEST"},{status:400}):Response.json({error:t,code:"RUN_FAILED"},{status:500})}async function p(){let e=(0,n.dp)().publicView(),t=(0,s.i)(),r=await t.call("listSkills",[]),o=(0,a.e)().getAll(),l=await t.mcp.listAll();return{protocolVersion:"1",provider:{id:"customer-agent",name:"Customer Agent"},features:{streaming:!0,memory:!0,cancellation:!0},models:e.profiles.map(e=>({id:e.id,name:e.name,provider:e.provider,modelId:e.modelId})),skills:r.filter(e=>!1!==e.enabled).map(e=>({id:e.name,name:e.name,description:e.description??""})),tools:o.map(e=>({id:e.name,name:e.name,description:e.description,inputSchema:e.parameters})),mcpServers:l.map(e=>({id:e.id,name:e.name||e.id,status:"available"})),toolPolicies:await (0,i.cm)().summaries()}}function m(e){let t=S(e,"request"),r=_(t.input,"input",1e5),o=function(e,t,r){if(void 0!==e)return _(e,t,32e3)}(t.instructions,"instructions",0),s=E(t.agentId,"agentId"),n=E(t.sessionId,"sessionId"),i=void 0===t.context?{}:S(t.context,"context");if(JSON.stringify(i).length>12e4)throw new l("INVALID_REQUEST","context is too large");let a=void 0===t.selection?{}:S(t.selection,"selection"),d={};for(let[e,t]of(d.modelId=E(a.modelId,"selection.modelId"),d.toolPolicyId=E(a.toolPolicyId,"selection.toolPolicyId"),[["skillIds","skillIds"],["activatedSkillIds","activatedSkillIds"],["toolIds","toolIds"],["mcpServerIds","mcpServerIds"]])){let r=function(e,t){if(void 0===e)return;if(!Array.isArray(e)||e.length>200)throw new l("INVALID_REQUEST",`${t} must contain at most 200 identifiers`);let r=e.map(e=>_(e,t));if(new Set(r).size!==r.length)throw new l("INVALID_REQUEST",`${t} contains duplicate identifiers`);return r}(a[e],`selection.${e}`);void 0!==r&&(d[t]=r)}if(void 0!==a.memoryEnabled){if("boolean"!=typeof a.memoryEnabled)throw new l("INVALID_REQUEST","selection.memoryEnabled must be boolean");d.memoryEnabled=a.memoryEnabled}if(d.skillIds&&d.activatedSkillIds){let e=new Set(d.skillIds);if(d.activatedSkillIds.some(t=>!e.has(t)))throw new l("INVALID_REQUEST","activatedSkillIds must be a subset of skillIds")}return{input:r,...o?{instructions:o}:{},...s?{agentId:s}:{},...n?{sessionId:n}:{},context:i,selection:d}}async function I(e){let t=await p();if(e.agentId&&!await (0,s.i)().agents.get(e.agentId))throw new l("INVALID_CAPABILITY",`Unknown Agent: ${e.agentId}`,404);v(e.selection.modelId?[e.selection.modelId]:void 0,t.models,"model"),v(e.selection.skillIds,t.skills,"Skill"),v(e.selection.activatedSkillIds,t.skills,"activated Skill"),v(e.selection.toolIds,t.tools,"Tool"),v(e.selection.mcpServerIds,t.mcpServers,"MCP server"),v(e.selection.toolPolicyId?[e.selection.toolPolicyId]:void 0,t.toolPolicies,"tool policy")}function f(e,t){for(w(),d.set(e,{runId:e,sessionId:t,createdAt:Date.now()});d.size>500;)d.delete(d.keys().next().value)}function g(e){w();let t=d.get(e);if(!t)throw new l("RUN_NOT_FOUND","Flow protocol run not found",404);return t}function h(e,t,r,o){let s={runId:e,sessionId:t,timestamp:new Date().toISOString()};return"text_chunk"===o.type?{id:r,event:"assistant.delta",data:{...s,text:o.text}}:"tool_call"===o.type?{id:r,event:"tool.started",data:{...s,callId:o.toolCall.id,name:o.toolCall.name,arguments:o.toolCall.arguments}}:"tool_result"===o.type?{id:r,event:"tool.completed",data:{...s,callId:o.result.toolCallId,content:o.result.content,isError:!0===o.result.isError}}:"done"===o.type?{id:r,event:"run.completed",data:{...s,text:o.finalText,durationMs:o.durationMs,usage:o.usage}}:"error"===o.type?{id:r,event:"run.failed",data:{...s,code:o.code||"RUN_FAILED",message:o.message}}:"turn_aborted"===o.type?{id:r,event:"run.failed",data:{...s,code:"RUN_CANCELLED",message:"Run cancelled"}}:null}function w(){let e=Date.now()-36e5;for(let[t,r]of d)r.createdAt<e&&d.delete(t)}function v(e,t,r){if(void 0===e)return;let o=new Set(t.map(e=>e.id)),s=e.find(e=>!o.has(e));if(s)throw new l("INVALID_CAPABILITY",`Unknown ${r}: ${s}`,422)}function S(e,t){if(!e||"object"!=typeof e||Array.isArray(e))throw new l("INVALID_REQUEST",`${t} must be an object`);return e}function _(e,t,r=200){if("string"!=typeof e||!e.trim()||e.length>r)throw new l("INVALID_REQUEST",`${t} must be a non-empty string no longer than ${r} characters`);return e.trim()}function E(e,t){if(void 0!==e)return _(e,t)}},6361:(e,t,r)=>{r.d(t,{Q:()=>i,e:()=>n});var o=r(1322),s=r(7519);function n(){let e=new o.S3T;(0,o._5y)(e);let t=new o.OqQ;for(let r of(e.register(new o.Q8u(t,null)),e.register(new o.URd(t,null)),s.agentHost.getBuilder().getToolRegistry().getAll()))e.register(r);return e.register(new o.gBG(async()=>({status:"failed",agentName:"",subSessionId:"",error:"catalog listing only; dispatch runs inside a Customer Agent session"}))),e.register(new o.HbQ(async()=>({status:"failed",agentName:"",subSessionId:"",error:"catalog listing only; dispatch runs inside a Customer Agent session"}))),e}function i(){return n().getAll().map(e=>e.name).sort()}},1489:(e,t,r)=>{r.d(t,{N:()=>l});var o=r(1322),s=r(6279),n=r(785);class i{constructor(){this.tasks=new o.vo4((0,n.kO)()),this.scheduler=new s.ST(this.tasks,e=>{this.fire(e).catch(e=>console.error("Scheduled Customer Agent run failed",e))},()=>{}),this.scheduler.start()}async fire(e){let{agentHost:t}=await r.e(7519).then(r.bind(r,7519)),{getCustomerGoalCoordinator:o}=await Promise.all([r.e(7519),r.e(732)]).then(r.bind(r,5038)),s=e.sessionId;s&&await t.getSessionStore().get(s)||(s=(await t.createSession(e.label||"定时任务")).id,this.tasks.update(e.id,{sessionId:s})),await o().enqueue(s,e.prompt)}call(e,t){let r=String(t[0]||"");switch(e){case"cronList":return this.tasks.list();case"cronCreate":{if("string"!=typeof t[0]||"string"!=typeof t[1]||!t[1].trim())throw Error("cron and prompt required");let e=t[2]&&"object"==typeof t[2]?t[2]:{};return this.tasks.create({cron:t[0],prompt:t[1],recurring:!1!==e.recurring,enabled:!0,durable:!0,..."string"==typeof e.sessionId?{sessionId:e.sessionId}:{},..."string"==typeof e.label?{label:e.label}:{}})}case"cronPause":return this.tasks.pause(r);case"cronResume":return this.tasks.resume(r);case"cronDelete":return this.tasks.delete(r);case"cronDeleteAll":return this.tasks.deleteAll(),{ok:!0};default:throw Error("Unsupported schedule operation")}}}let a=globalThis;function l(){return a.__sharedCronService??=new i}},8615:(e,t,r)=>{let o;r.d(t,{H5:()=>u,cm:()=>l,jw:()=>d});var s=r(1322),n=r(785),i=r(6361);class a{constructor(e=(0,n.kO)()){this.store=new s.RQW(e)}list(){return this.store.list()}get(e){return this.store.get(e)}async summaries(){return(await this.store.list()).filter(e=>e.enabled).map(s._0R)}save(e,t){let r=(0,s.IJh)(e,{knownTools:t,requireExecutables:!0});return this.store.save(r)}delete(e){return this.store.delete(e)}}function l(){return o??=new a}function d(){return(0,i.Q)()}function u(e){let t=e instanceof s.DlR?422:400;return Response.json({error:e instanceof Error?e.message:"Tool policy request failed",code:e instanceof s.DlR?e.code:"INVALID_TOOL_POLICY"},{status:t})}}};var t=require("../../../../../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),o=t.X(0,[8375,6244,1322,1773,4621,7519],()=>r(8085));module.exports=o})();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";(()=>{var e={};e.id=5671,e.ids=[5671],e.modules={7728:e=>{e.exports=require("@anthropic-ai/claude-agent-sdk")},5890:e=>{e.exports=require("better-sqlite3")},399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},1282:e=>{e.exports=require("child_process")},2048:e=>{e.exports=require("fs")},9801:e=>{e.exports=require("os")},5315:e=>{e.exports=require("path")},7718:e=>{e.exports=require("node:child_process")},6005:e=>{e.exports=require("node:crypto")},5673:e=>{e.exports=require("node:events")},7561:e=>{e.exports=require("node:fs")},3977:e=>{e.exports=require("node:fs/promises")},8849:e=>{e.exports=require("node:http")},2286:e=>{e.exports=require("node:https")},2033:e=>{e.exports=require("node:module")},7503:e=>{e.exports=require("node:net")},612:e=>{e.exports=require("node:os")},9411:e=>{e.exports=require("node:path")},1747:e=>{e.exports=require("node:readline")},4492:e=>{e.exports=require("node:stream")},6915:e=>{e.exports=require("node:string_decoder")},1041:e=>{e.exports=require("node:url")},7261:e=>{e.exports=require("node:util")},8998:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>I,patchFetch:()=>f,requestAsyncStorage:()=>c,routeModule:()=>u,serverHooks:()=>m,staticGenerationAsyncStorage:()=>p});var
|
|
1
|
+
"use strict";(()=>{var e={};e.id=5671,e.ids=[5671],e.modules={7728:e=>{e.exports=require("@anthropic-ai/claude-agent-sdk")},5890:e=>{e.exports=require("better-sqlite3")},399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},1282:e=>{e.exports=require("child_process")},2048:e=>{e.exports=require("fs")},9801:e=>{e.exports=require("os")},5315:e=>{e.exports=require("path")},7718:e=>{e.exports=require("node:child_process")},6005:e=>{e.exports=require("node:crypto")},5673:e=>{e.exports=require("node:events")},7561:e=>{e.exports=require("node:fs")},3977:e=>{e.exports=require("node:fs/promises")},8849:e=>{e.exports=require("node:http")},2286:e=>{e.exports=require("node:https")},2033:e=>{e.exports=require("node:module")},7503:e=>{e.exports=require("node:net")},612:e=>{e.exports=require("node:os")},9411:e=>{e.exports=require("node:path")},1747:e=>{e.exports=require("node:readline")},4492:e=>{e.exports=require("node:stream")},6915:e=>{e.exports=require("node:string_decoder")},1041:e=>{e.exports=require("node:url")},7261:e=>{e.exports=require("node:util")},8998:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>I,patchFetch:()=>f,requestAsyncStorage:()=>c,routeModule:()=>u,serverHooks:()=>m,staticGenerationAsyncStorage:()=>p});var s={};r.r(s),r.d(s,{GET:()=>d});var n=r(7786),o=r(5042),i=r(2184),a=r(7519),l=r(6089);async function d(e,{params:t}){try{(0,l.Pj)(e);let r=(0,l.WA)(t.runId),s=!1,n=null,o=new ReadableStream({start(t){let o=new TextEncoder,i=()=>{if(!s){s=!0,n?.();try{t.close()}catch{}}},d=(e,r,n)=>{s||t.enqueue(o.encode(`id: ${e}
|
|
2
2
|
event: ${r}
|
|
3
|
-
data: ${JSON.stringify(
|
|
3
|
+
data: ${JSON.stringify(n)}
|
|
4
4
|
|
|
5
|
-
`))},u=Number.parseInt(e.headers.get("last-event-id")??"",10),c=Number.parseInt(new URL(e.url).searchParams.get("afterEventId")??"",10),p=Number.isSafeInteger(u)?u:Number.isSafeInteger(c)?c:-1;p<0&&d(0,"run.started",{runId:r.runId,sessionId:r.sessionId,timestamp:new Date().toISOString()}),
|
|
5
|
+
`))},u=Number.parseInt(e.headers.get("last-event-id")??"",10),c=Number.parseInt(new URL(e.url).searchParams.get("afterEventId")??"",10),p=Number.isSafeInteger(u)?u:Number.isSafeInteger(c)?c:-1;p<0&&d(0,"run.started",{runId:r.runId,sessionId:r.sessionId,timestamp:new Date().toISOString()}),n=a.agentHost.subscribe(r.sessionId,(e,t)=>{let s=(0,l.v9)(r.runId,r.sessionId,t,e);s&&(d(s.id,s.event,s.data),("run.completed"===s.event||"run.failed"===s.event)&&i())},Math.max(0,p)),e.signal.aborted?i():e.signal.addEventListener("abort",i,{once:!0})},cancel(){s=!0,n?.()}});return new Response(o,{headers:{"content-type":"text/event-stream","cache-control":"no-cache",connection:"keep-alive"}})}catch(e){return(0,l.u4)(e)}}let u=new n.AppRouteRouteModule({definition:{kind:o.x.APP_ROUTE,page:"/api/flow/v1/runs/[runId]/events/route",pathname:"/api/flow/v1/runs/[runId]/events",filename:"route",bundlePath:"app/api/flow/v1/runs/[runId]/events/route"},resolvedPagePath:"/Volumes/ext/project/team-agent/packages/server/app/api/flow/v1/runs/[runId]/events/route.ts",nextConfigOutput:"standalone",userland:s}),{requestAsyncStorage:c,staticGenerationAsyncStorage:p,serverHooks:m}=u,I="/api/flow/v1/runs/[runId]/events/route";function f(){return(0,i.patchFetch)({serverHooks:m,staticGenerationAsyncStorage:p})}},7786:(e,t,r)=>{e.exports=r(517)},6089:(e,t,r)=>{r.d(t,{Cm:()=>I,NB:()=>f,Pj:()=>u,WA:()=>g,Wt:()=>p,k8:()=>m,u4:()=>c,v9:()=>h});var s=r(6005),n=r(4621),o=r(1982),i=r(8615),a=r(6361);class l extends Error{constructor(e,t,r=400){super(t),this.code=e,this.status=r,this.name="FlowProtocolError"}}let d=new Map;function u(e){let t=(process.env.AGENT_RUN_TOKEN||process.env.PORTFOLIO_SKILL_TOKEN)?.trim();if(!t)return;let r=e.headers.get("authorization")??"",n=r.startsWith("Bearer ")?r.slice(7):"",o=Buffer.from(n),i=Buffer.from(t);if(o.length!==i.length||!(0,s.timingSafeEqual)(o,i))throw new l("UNAUTHORIZED","Flow protocol authentication failed",401)}function c(e){if(e instanceof l)return Response.json({error:e.message,code:e.code},{status:e.status});let t=e instanceof Error?e.message:"Flow protocol request failed",r="object"==typeof e&&null!==e&&"code"in e?String(e.code):"";if("SESSION_OCCUPIED"===r||"SESSION_ALREADY_RUNNING"===r)return Response.json({error:t,code:"SESSION_OCCUPIED"},{status:409});let s={AGENT_NOT_FOUND:404,SKILL_NOT_FOUND:404,MODEL_PROFILE_NOT_FOUND:404,SKILL_NOT_ALLOWED:422,TOOL_POLICY_NOT_FOUND:404,TOOL_POLICY_DISABLED:422};return r in s?Response.json({error:t,code:"INVALID_CAPABILITY"},{status:s[r]}):"INVALID_RUN_REQUEST"===r?Response.json({error:t,code:"INVALID_REQUEST"},{status:400}):Response.json({error:t,code:"RUN_FAILED"},{status:500})}async function p(){let e=(0,o.dp)().publicView(),t=(0,n.i)(),r=await t.call("listSkills",[]),s=(0,a.e)().getAll(),l=await t.mcp.listAll();return{protocolVersion:"1",provider:{id:"customer-agent",name:"Customer Agent"},features:{streaming:!0,memory:!0,cancellation:!0},models:e.profiles.map(e=>({id:e.id,name:e.name,provider:e.provider,modelId:e.modelId})),skills:r.filter(e=>!1!==e.enabled).map(e=>({id:e.name,name:e.name,description:e.description??""})),tools:s.map(e=>({id:e.name,name:e.name,description:e.description,inputSchema:e.parameters})),mcpServers:l.map(e=>({id:e.id,name:e.name||e.id,status:"available"})),toolPolicies:await (0,i.cm)().summaries()}}function m(e){let t=S(e,"request"),r=E(t.input,"input",1e5),s=function(e,t,r){if(void 0!==e)return E(e,t,32e3)}(t.instructions,"instructions",0),n=_(t.agentId,"agentId"),o=_(t.sessionId,"sessionId"),i=void 0===t.context?{}:S(t.context,"context");if(JSON.stringify(i).length>12e4)throw new l("INVALID_REQUEST","context is too large");let a=void 0===t.selection?{}:S(t.selection,"selection"),d={};for(let[e,t]of(d.modelId=_(a.modelId,"selection.modelId"),d.toolPolicyId=_(a.toolPolicyId,"selection.toolPolicyId"),[["skillIds","skillIds"],["activatedSkillIds","activatedSkillIds"],["toolIds","toolIds"],["mcpServerIds","mcpServerIds"]])){let r=function(e,t){if(void 0===e)return;if(!Array.isArray(e)||e.length>200)throw new l("INVALID_REQUEST",`${t} must contain at most 200 identifiers`);let r=e.map(e=>E(e,t));if(new Set(r).size!==r.length)throw new l("INVALID_REQUEST",`${t} contains duplicate identifiers`);return r}(a[e],`selection.${e}`);void 0!==r&&(d[t]=r)}if(void 0!==a.memoryEnabled){if("boolean"!=typeof a.memoryEnabled)throw new l("INVALID_REQUEST","selection.memoryEnabled must be boolean");d.memoryEnabled=a.memoryEnabled}if(d.skillIds&&d.activatedSkillIds){let e=new Set(d.skillIds);if(d.activatedSkillIds.some(t=>!e.has(t)))throw new l("INVALID_REQUEST","activatedSkillIds must be a subset of skillIds")}return{input:r,...s?{instructions:s}:{},...n?{agentId:n}:{},...o?{sessionId:o}:{},context:i,selection:d}}async function I(e){let t=await p();if(e.agentId&&!await (0,n.i)().agents.get(e.agentId))throw new l("INVALID_CAPABILITY",`Unknown Agent: ${e.agentId}`,404);w(e.selection.modelId?[e.selection.modelId]:void 0,t.models,"model"),w(e.selection.skillIds,t.skills,"Skill"),w(e.selection.activatedSkillIds,t.skills,"activated Skill"),w(e.selection.toolIds,t.tools,"Tool"),w(e.selection.mcpServerIds,t.mcpServers,"MCP server"),w(e.selection.toolPolicyId?[e.selection.toolPolicyId]:void 0,t.toolPolicies,"tool policy")}function f(e,t){for(v(),d.set(e,{runId:e,sessionId:t,createdAt:Date.now()});d.size>500;)d.delete(d.keys().next().value)}function g(e){v();let t=d.get(e);if(!t)throw new l("RUN_NOT_FOUND","Flow protocol run not found",404);return t}function h(e,t,r,s){let n={runId:e,sessionId:t,timestamp:new Date().toISOString()};return"text_chunk"===s.type?{id:r,event:"assistant.delta",data:{...n,text:s.text}}:"tool_call"===s.type?{id:r,event:"tool.started",data:{...n,callId:s.toolCall.id,name:s.toolCall.name,arguments:s.toolCall.arguments}}:"tool_result"===s.type?{id:r,event:"tool.completed",data:{...n,callId:s.result.toolCallId,content:s.result.content,isError:!0===s.result.isError}}:"done"===s.type?{id:r,event:"run.completed",data:{...n,text:s.finalText,durationMs:s.durationMs,usage:s.usage}}:"error"===s.type?{id:r,event:"run.failed",data:{...n,code:s.code||"RUN_FAILED",message:s.message}}:"turn_aborted"===s.type?{id:r,event:"run.failed",data:{...n,code:"RUN_CANCELLED",message:"Run cancelled"}}:null}function v(){let e=Date.now()-36e5;for(let[t,r]of d)r.createdAt<e&&d.delete(t)}function w(e,t,r){if(void 0===e)return;let s=new Set(t.map(e=>e.id)),n=e.find(e=>!s.has(e));if(n)throw new l("INVALID_CAPABILITY",`Unknown ${r}: ${n}`,422)}function S(e,t){if(!e||"object"!=typeof e||Array.isArray(e))throw new l("INVALID_REQUEST",`${t} must be an object`);return e}function E(e,t,r=200){if("string"!=typeof e||!e.trim()||e.length>r)throw new l("INVALID_REQUEST",`${t} must be a non-empty string no longer than ${r} characters`);return e.trim()}function _(e,t){if(void 0!==e)return E(e,t)}},6361:(e,t,r)=>{r.d(t,{Q:()=>i,e:()=>o});var s=r(1322),n=r(7519);function o(){let e=new s.S3T;(0,s._5y)(e);let t=new s.OqQ;for(let r of(e.register(new s.Q8u(t,null)),e.register(new s.URd(t,null)),n.agentHost.getBuilder().getToolRegistry().getAll()))e.register(r);return e.register(new s.gBG(async()=>({status:"failed",agentName:"",subSessionId:"",error:"catalog listing only; dispatch runs inside a Customer Agent session"}))),e.register(new s.HbQ(async()=>({status:"failed",agentName:"",subSessionId:"",error:"catalog listing only; dispatch runs inside a Customer Agent session"}))),e}function i(){return o().getAll().map(e=>e.name).sort()}},1489:(e,t,r)=>{r.d(t,{N:()=>l});var s=r(1322),n=r(6279),o=r(785);class i{constructor(){this.tasks=new s.vo4((0,o.kO)()),this.scheduler=new n.ST(this.tasks,e=>{this.fire(e).catch(e=>console.error("Scheduled Customer Agent run failed",e))},()=>{}),this.scheduler.start()}async fire(e){let{agentHost:t}=await r.e(7519).then(r.bind(r,7519)),{getCustomerGoalCoordinator:s}=await Promise.all([r.e(7519),r.e(732)]).then(r.bind(r,5038)),n=e.sessionId;n&&await t.getSessionStore().get(n)||(n=(await t.createSession(e.label||"定时任务")).id,this.tasks.update(e.id,{sessionId:n})),await s().enqueue(n,e.prompt)}call(e,t){let r=String(t[0]||"");switch(e){case"cronList":return this.tasks.list();case"cronCreate":{if("string"!=typeof t[0]||"string"!=typeof t[1]||!t[1].trim())throw Error("cron and prompt required");let e=t[2]&&"object"==typeof t[2]?t[2]:{};return this.tasks.create({cron:t[0],prompt:t[1],recurring:!1!==e.recurring,enabled:!0,durable:!0,..."string"==typeof e.sessionId?{sessionId:e.sessionId}:{},..."string"==typeof e.label?{label:e.label}:{}})}case"cronPause":return this.tasks.pause(r);case"cronResume":return this.tasks.resume(r);case"cronDelete":return this.tasks.delete(r);case"cronDeleteAll":return this.tasks.deleteAll(),{ok:!0};default:throw Error("Unsupported schedule operation")}}}let a=globalThis;function l(){return a.__sharedCronService??=new i}},8615:(e,t,r)=>{let s;r.d(t,{H5:()=>u,cm:()=>l,jw:()=>d});var n=r(1322),o=r(785),i=r(6361);class a{constructor(e=(0,o.kO)()){this.store=new n.RQW(e)}list(){return this.store.list()}get(e){return this.store.get(e)}async summaries(){return(await this.store.list()).filter(e=>e.enabled).map(n._0R)}save(e,t){let r=(0,n.IJh)(e,{knownTools:t,requireExecutables:!0});return this.store.save(r)}delete(e){return this.store.delete(e)}}function l(){return s??=new a}function d(){return(0,i.Q)()}function u(e){let t=e instanceof n.DlR?422:400;return Response.json({error:e instanceof Error?e.message:"Tool policy request failed",code:e instanceof n.DlR?e.code:"INVALID_TOOL_POLICY"},{status:t})}}};var t=require("../../../../../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),s=t.X(0,[8375,6244,1322,1773,4621,7519],()=>r(8998));module.exports=s})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(()=>{var e={};e.id=9108,e.ids=[9108],e.modules={7728:e=>{e.exports=require("@anthropic-ai/claude-agent-sdk")},5890:e=>{e.exports=require("better-sqlite3")},399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},1282:e=>{e.exports=require("child_process")},2048:e=>{e.exports=require("fs")},9801:e=>{e.exports=require("os")},5315:e=>{e.exports=require("path")},7718:e=>{e.exports=require("node:child_process")},6005:e=>{e.exports=require("node:crypto")},5673:e=>{e.exports=require("node:events")},7561:e=>{e.exports=require("node:fs")},3977:e=>{e.exports=require("node:fs/promises")},8849:e=>{e.exports=require("node:http")},2286:e=>{e.exports=require("node:https")},2033:e=>{e.exports=require("node:module")},7503:e=>{e.exports=require("node:net")},612:e=>{e.exports=require("node:os")},9411:e=>{e.exports=require("node:path")},1747:e=>{e.exports=require("node:readline")},4492:e=>{e.exports=require("node:stream")},6915:e=>{e.exports=require("node:string_decoder")},1041:e=>{e.exports=require("node:url")},7261:e=>{e.exports=require("node:util")},7585:(e,t,o)=>{o.r(t),o.d(t,{originalPathname:()=>w,patchFetch:()=>v,requestAsyncStorage:()=>f,routeModule:()=>I,serverHooks:()=>h,staticGenerationAsyncStorage:()=>g});var r={};o.r(r),o.d(r,{POST:()=>m});var s=o(7786),n=o(5042),i=o(2184),l=o(1322),a=o(7519),d=o(4621),c=o(6089),u=o(1982),p=o(8615);async function m(e){try{(0,c.Pj)(e);let t=(0,c.k8)(await e.json());await (0,c.Cm)(t);let o=(0,d.i)(),r=new l.R0$(a.agentHost.getSessionStore(),{getAgent:e=>o.agents.get(e),getSkill:e=>o.skills.get(e),hasModelProfile:e=>(0,u.dp)().read().profiles.some(t=>t.id===e),getToolExecutionPolicy:e=>(0,p.cm)().get(e)},{assertAvailable:e=>{if(a.agentHost.isSessionRunning(e))throw new a.A(e)},start:e=>{let o=a.agentHost.startRun(e.message,e.sessionId,e.images,{...e.modelProfileId?{profileId:e.modelProfileId}:{},agentIds:e.agent?[e.agent.id]:[],enabledTools:e.capabilities.enabledTools,enabledSkills:e.capabilities.enabledSkills,activatedSkills:e.capabilities.activatedSkills,enabledMCPServers:e.capabilities.enabledMCPServers,memoryEnabled:e.capabilities.memoryEnabled,toolExecutionPolicy:e.toolExecutionPolicy,instructions:t.instructions,...Object.keys(e.context).length?{context:e.context}:{}});return o.completion.catch(()=>void 0),{sessionId:e.sessionId,runId:o.runId,streamRef:`/api/flow/v1/runs/${o.runId}/events`}}}),s=t.selection,n=await r.execute({message:t.input,...t.sessionId?{sessionId:t.sessionId}:{},...t.agentId?{agentId:t.agentId}:{},...s.modelId?{modelProfileId:s.modelId}:{},context:t.context,capabilities:{enabledTools:s.toolIds,enabledSkills:s.skillIds,activatedSkills:s.activatedSkillIds,enabledMCPServers:s.mcpServerIds,memoryEnabled:s.memoryEnabled,toolPolicyId:s.toolPolicyId},session:{title:`Flow: ${t.input.slice(0,48)}`,metadata:{flowProtocolVersion:"1"}},source:"flow-studio"});return(0,c.NB)(n.runId,n.sessionId),Response.json({runId:n.runId,sessionId:n.sessionId,eventsUrl:n.streamRef})}catch(e){return(0,c.u4)(e)}}let I=new s.AppRouteRouteModule({definition:{kind:n.x.APP_ROUTE,page:"/api/flow/v1/runs/route",pathname:"/api/flow/v1/runs",filename:"route",bundlePath:"app/api/flow/v1/runs/route"},resolvedPagePath:"/Volumes/ext/project/team-agent/packages/server/app/api/flow/v1/runs/route.ts",nextConfigOutput:"standalone",userland:r}),{requestAsyncStorage:f,staticGenerationAsyncStorage:g,serverHooks:h}=I,w="/api/flow/v1/runs/route";function v(){return(0,i.patchFetch)({serverHooks:h,staticGenerationAsyncStorage:g})}},7786:(e,t,o)=>{e.exports=o(517)},6089:(e,t,o)=>{o.d(t,{Cm:()=>I,NB:()=>f,Pj:()=>c,WA:()=>g,Wt:()=>p,k8:()=>m,u4:()=>u,v9:()=>h});var r=o(6005),s=o(4621),n=o(1982),i=o(8615),l=o(6361);class a extends Error{constructor(e,t,o=400){super(t),this.code=e,this.status=o,this.name="FlowProtocolError"}}let d=new Map;function c(e){let t=(process.env.AGENT_RUN_TOKEN||process.env.PORTFOLIO_SKILL_TOKEN)?.trim();if(!t)return;let o=e.headers.get("authorization")??"",s=o.startsWith("Bearer ")?o.slice(7):"",n=Buffer.from(s),i=Buffer.from(t);if(n.length!==i.length||!(0,r.timingSafeEqual)(n,i))throw new a("UNAUTHORIZED","Flow protocol authentication failed",401)}function u(e){if(e instanceof a)return Response.json({error:e.message,code:e.code},{status:e.status});let t=e instanceof Error?e.message:"Flow protocol request failed",o="object"==typeof e&&null!==e&&"code"in e?String(e.code):"";if("SESSION_OCCUPIED"===o||"SESSION_ALREADY_RUNNING"===o)return Response.json({error:t,code:"SESSION_OCCUPIED"},{status:409});let r={AGENT_NOT_FOUND:404,SKILL_NOT_FOUND:404,MODEL_PROFILE_NOT_FOUND:404,SKILL_NOT_ALLOWED:422,TOOL_POLICY_NOT_FOUND:404,TOOL_POLICY_DISABLED:422};return o in r?Response.json({error:t,code:"INVALID_CAPABILITY"},{status:r[o]}):"INVALID_RUN_REQUEST"===o?Response.json({error:t,code:"INVALID_REQUEST"},{status:400}):Response.json({error:t,code:"RUN_FAILED"},{status:500})}async function p(){let e=(0,n.dp)().publicView(),t=(0,s.i)(),o=await t.call("listSkills",[]),r=(0,l.e)().getAll(),a=await t.mcp.listAll();return{protocolVersion:"1",provider:{id:"customer-agent",name:"Customer Agent"},features:{streaming:!0,memory:!0,cancellation:!0},models:e.profiles.map(e=>({id:e.id,name:e.name,provider:e.provider,modelId:e.modelId})),skills:o.filter(e=>!1!==e.enabled).map(e=>({id:e.name,name:e.name,description:e.description??""})),tools:r.map(e=>({id:e.name,name:e.name,description:e.description,inputSchema:e.parameters})),mcpServers:a.map(e=>({id:e.id,name:e.name||e.id,status:"available"})),toolPolicies:await (0,i.cm)().summaries()}}function m(e){let t=S(e,"request"),o=E(t.input,"input",1e5),r=function(e,t,o){if(void 0!==e)return E(e,t,32e3)}(t.instructions,"instructions",0),s=y(t.agentId,"agentId"),n=y(t.sessionId,"sessionId"),i=void 0===t.context?{}:S(t.context,"context");if(JSON.stringify(i).length>12e4)throw new a("INVALID_REQUEST","context is too large");let l=void 0===t.selection?{}:S(t.selection,"selection"),d={};for(let[e,t]of(d.modelId=y(l.modelId,"selection.modelId"),d.toolPolicyId=y(l.toolPolicyId,"selection.toolPolicyId"),[["skillIds","skillIds"],["activatedSkillIds","activatedSkillIds"],["toolIds","toolIds"],["mcpServerIds","mcpServerIds"]])){let o=function(e,t){if(void 0===e)return;if(!Array.isArray(e)||e.length>200)throw new a("INVALID_REQUEST",`${t} must contain at most 200 identifiers`);let o=e.map(e=>E(e,t));if(new Set(o).size!==o.length)throw new a("INVALID_REQUEST",`${t} contains duplicate identifiers`);return o}(l[e],`selection.${e}`);void 0!==o&&(d[t]=o)}if(void 0!==l.memoryEnabled){if("boolean"!=typeof l.memoryEnabled)throw new a("INVALID_REQUEST","selection.memoryEnabled must be boolean");d.memoryEnabled=l.memoryEnabled}if(d.skillIds&&d.activatedSkillIds){let e=new Set(d.skillIds);if(d.activatedSkillIds.some(t=>!e.has(t)))throw new a("INVALID_REQUEST","activatedSkillIds must be a subset of skillIds")}return{input:o,...r?{instructions:r}:{},...s?{agentId:s}:{},...n?{sessionId:n}:{},context:i,selection:d}}async function I(e){let t=await p();if(e.agentId&&!await (0,s.i)().agents.get(e.agentId))throw new a("INVALID_CAPABILITY",`Unknown Agent: ${e.agentId}`,404);v(e.selection.modelId?[e.selection.modelId]:void 0,t.models,"model"),v(e.selection.skillIds,t.skills,"Skill"),v(e.selection.activatedSkillIds,t.skills,"activated Skill"),v(e.selection.toolIds,t.tools,"Tool"),v(e.selection.mcpServerIds,t.mcpServers,"MCP server"),v(e.selection.toolPolicyId?[e.selection.toolPolicyId]:void 0,t.toolPolicies,"tool policy")}function f(e,t){for(w(),d.set(e,{runId:e,sessionId:t,createdAt:Date.now()});d.size>500;)d.delete(d.keys().next().value)}function g(e){w();let t=d.get(e);if(!t)throw new a("RUN_NOT_FOUND","Flow protocol run not found",404);return t}function h(e,t,o,r){let s={runId:e,sessionId:t,timestamp:new Date().toISOString()};return"text_chunk"===r.type?{id:o,event:"assistant.delta",data:{...s,text:r.text}}:"tool_call"===r.type?{id:o,event:"tool.started",data:{...s,callId:r.toolCall.id,name:r.toolCall.name,arguments:r.toolCall.arguments}}:"tool_result"===r.type?{id:o,event:"tool.completed",data:{...s,callId:r.result.toolCallId,content:r.result.content,isError:!0===r.result.isError}}:"done"===r.type?{id:o,event:"run.completed",data:{...s,text:r.finalText,durationMs:r.durationMs,usage:r.usage}}:"error"===r.type?{id:o,event:"run.failed",data:{...s,code:r.code||"RUN_FAILED",message:r.message}}:"turn_aborted"===r.type?{id:o,event:"run.failed",data:{...s,code:"RUN_CANCELLED",message:"Run cancelled"}}:null}function w(){let e=Date.now()-36e5;for(let[t,o]of d)o.createdAt<e&&d.delete(t)}function v(e,t,o){if(void 0===e)return;let r=new Set(t.map(e=>e.id)),s=e.find(e=>!r.has(e));if(s)throw new a("INVALID_CAPABILITY",`Unknown ${o}: ${s}`,422)}function S(e,t){if(!e||"object"!=typeof e||Array.isArray(e))throw new a("INVALID_REQUEST",`${t} must be an object`);return e}function E(e,t,o=200){if("string"!=typeof e||!e.trim()||e.length>o)throw new a("INVALID_REQUEST",`${t} must be a non-empty string no longer than ${o} characters`);return e.trim()}function y(e,t){if(void 0!==e)return E(e,t)}},6361:(e,t,o)=>{o.d(t,{Q:()=>i,e:()=>n});var r=o(1322),s=o(7519);function n(){let e=new r.S3T;(0,r._5y)(e);let t=new r.OqQ;for(let o of(e.register(new r.Q8u(t,null)),e.register(new r.URd(t,null)),s.agentHost.getBuilder().getToolRegistry().getAll()))e.register(o);return e}function i(){return n().getAll().map(e=>e.name).sort()}},1489:(e,t,o)=>{o.d(t,{N:()=>a});var r=o(1322),s=o(6279),n=o(785);class i{constructor(){this.tasks=new r.vo4((0,n.kO)()),this.scheduler=new s.ST(this.tasks,e=>{this.fire(e).catch(e=>console.error("Scheduled Customer Agent run failed",e))},()=>{}),this.scheduler.start()}async fire(e){let{agentHost:t}=await o.e(7519).then(o.bind(o,7519)),{getCustomerGoalCoordinator:r}=await Promise.all([o.e(7519),o.e(732)]).then(o.bind(o,5038)),s=e.sessionId;s&&await t.getSessionStore().get(s)||(s=(await t.createSession(e.label||"定时任务")).id,this.tasks.update(e.id,{sessionId:s})),await r().enqueue(s,e.prompt)}call(e,t){let o=String(t[0]||"");switch(e){case"cronList":return this.tasks.list();case"cronCreate":{if("string"!=typeof t[0]||"string"!=typeof t[1]||!t[1].trim())throw Error("cron and prompt required");let e=t[2]&&"object"==typeof t[2]?t[2]:{};return this.tasks.create({cron:t[0],prompt:t[1],recurring:!1!==e.recurring,enabled:!0,durable:!0,..."string"==typeof e.sessionId?{sessionId:e.sessionId}:{},..."string"==typeof e.label?{label:e.label}:{}})}case"cronPause":return this.tasks.pause(o);case"cronResume":return this.tasks.resume(o);case"cronDelete":return this.tasks.delete(o);case"cronDeleteAll":return this.tasks.deleteAll(),{ok:!0};default:throw Error("Unsupported schedule operation")}}}let l=globalThis;function a(){return l.__sharedCronService??=new i}},8615:(e,t,o)=>{let r;o.d(t,{H5:()=>c,cm:()=>a,jw:()=>d});var s=o(1322),n=o(785),i=o(6361);class l{constructor(e=(0,n.kO)()){this.store=new s.RQW(e)}list(){return this.store.list()}get(e){return this.store.get(e)}async summaries(){return(await this.store.list()).filter(e=>e.enabled).map(s._0R)}save(e,t){let o=(0,s.IJh)(e,{knownTools:t,requireExecutables:!0});return this.store.save(o)}delete(e){return this.store.delete(e)}}function a(){return r??=new l}function d(){return(0,i.Q)()}function c(e){let t=e instanceof s.DlR?422:400;return Response.json({error:e instanceof Error?e.message:"Tool policy request failed",code:e instanceof s.DlR?e.code:"INVALID_TOOL_POLICY"},{status:t})}}};var t=require("../../../../../webpack-runtime.js");t.C(e);var o=e=>t(t.s=e),r=t.X(0,[8375,6244,1322,1773,4621,7519],()=>o(7585));module.exports=r})();
|
|
1
|
+
"use strict";(()=>{var e={};e.id=9108,e.ids=[9108],e.modules={7728:e=>{e.exports=require("@anthropic-ai/claude-agent-sdk")},5890:e=>{e.exports=require("better-sqlite3")},399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},1282:e=>{e.exports=require("child_process")},2048:e=>{e.exports=require("fs")},9801:e=>{e.exports=require("os")},5315:e=>{e.exports=require("path")},7718:e=>{e.exports=require("node:child_process")},6005:e=>{e.exports=require("node:crypto")},5673:e=>{e.exports=require("node:events")},7561:e=>{e.exports=require("node:fs")},3977:e=>{e.exports=require("node:fs/promises")},8849:e=>{e.exports=require("node:http")},2286:e=>{e.exports=require("node:https")},2033:e=>{e.exports=require("node:module")},7503:e=>{e.exports=require("node:net")},612:e=>{e.exports=require("node:os")},9411:e=>{e.exports=require("node:path")},1747:e=>{e.exports=require("node:readline")},4492:e=>{e.exports=require("node:stream")},6915:e=>{e.exports=require("node:string_decoder")},1041:e=>{e.exports=require("node:url")},7261:e=>{e.exports=require("node:util")},7585:(e,t,s)=>{s.r(t),s.d(t,{originalPathname:()=>w,patchFetch:()=>v,requestAsyncStorage:()=>f,routeModule:()=>I,serverHooks:()=>h,staticGenerationAsyncStorage:()=>g});var o={};s.r(o),s.d(o,{POST:()=>m});var r=s(7786),n=s(5042),i=s(2184),l=s(1322),a=s(7519),d=s(4621),c=s(6089),u=s(1982),p=s(8615);async function m(e){try{(0,c.Pj)(e);let t=(0,c.k8)(await e.json());await (0,c.Cm)(t);let s=(0,d.i)(),o=new l.R0$(a.agentHost.getSessionStore(),{getAgent:e=>s.agents.get(e),getSkill:e=>s.skills.get(e),hasModelProfile:e=>(0,u.dp)().read().profiles.some(t=>t.id===e),getToolExecutionPolicy:e=>(0,p.cm)().get(e)},{assertAvailable:e=>{if(a.agentHost.isSessionRunning(e))throw new a.A(e)},start:e=>{let s=a.agentHost.startRun(e.message,e.sessionId,e.images,{...e.modelProfileId?{profileId:e.modelProfileId}:{},agentIds:e.agent?[e.agent.id]:[],enabledTools:e.capabilities.enabledTools,enabledSkills:e.capabilities.enabledSkills,activatedSkills:e.capabilities.activatedSkills,enabledMCPServers:e.capabilities.enabledMCPServers,memoryEnabled:e.capabilities.memoryEnabled,toolExecutionPolicy:e.toolExecutionPolicy,instructions:t.instructions,...Object.keys(e.context).length?{context:e.context}:{}});return s.completion.catch(()=>void 0),{sessionId:e.sessionId,runId:s.runId,streamRef:`/api/flow/v1/runs/${s.runId}/events`}}}),r=t.selection,n=await o.execute({message:t.input,...t.sessionId?{sessionId:t.sessionId}:{},...t.agentId?{agentId:t.agentId}:{},...r.modelId?{modelProfileId:r.modelId}:{},context:t.context,capabilities:{enabledTools:r.toolIds,enabledSkills:r.skillIds,activatedSkills:r.activatedSkillIds,enabledMCPServers:r.mcpServerIds,memoryEnabled:r.memoryEnabled,toolPolicyId:r.toolPolicyId},session:{title:`Flow: ${t.input.slice(0,48)}`,metadata:{flowProtocolVersion:"1"}},source:"flow-studio"});return(0,c.NB)(n.runId,n.sessionId),Response.json({runId:n.runId,sessionId:n.sessionId,eventsUrl:n.streamRef})}catch(e){return(0,c.u4)(e)}}let I=new r.AppRouteRouteModule({definition:{kind:n.x.APP_ROUTE,page:"/api/flow/v1/runs/route",pathname:"/api/flow/v1/runs",filename:"route",bundlePath:"app/api/flow/v1/runs/route"},resolvedPagePath:"/Volumes/ext/project/team-agent/packages/server/app/api/flow/v1/runs/route.ts",nextConfigOutput:"standalone",userland:o}),{requestAsyncStorage:f,staticGenerationAsyncStorage:g,serverHooks:h}=I,w="/api/flow/v1/runs/route";function v(){return(0,i.patchFetch)({serverHooks:h,staticGenerationAsyncStorage:g})}},7786:(e,t,s)=>{e.exports=s(517)},6089:(e,t,s)=>{s.d(t,{Cm:()=>I,NB:()=>f,Pj:()=>c,WA:()=>g,Wt:()=>p,k8:()=>m,u4:()=>u,v9:()=>h});var o=s(6005),r=s(4621),n=s(1982),i=s(8615),l=s(6361);class a extends Error{constructor(e,t,s=400){super(t),this.code=e,this.status=s,this.name="FlowProtocolError"}}let d=new Map;function c(e){let t=(process.env.AGENT_RUN_TOKEN||process.env.PORTFOLIO_SKILL_TOKEN)?.trim();if(!t)return;let s=e.headers.get("authorization")??"",r=s.startsWith("Bearer ")?s.slice(7):"",n=Buffer.from(r),i=Buffer.from(t);if(n.length!==i.length||!(0,o.timingSafeEqual)(n,i))throw new a("UNAUTHORIZED","Flow protocol authentication failed",401)}function u(e){if(e instanceof a)return Response.json({error:e.message,code:e.code},{status:e.status});let t=e instanceof Error?e.message:"Flow protocol request failed",s="object"==typeof e&&null!==e&&"code"in e?String(e.code):"";if("SESSION_OCCUPIED"===s||"SESSION_ALREADY_RUNNING"===s)return Response.json({error:t,code:"SESSION_OCCUPIED"},{status:409});let o={AGENT_NOT_FOUND:404,SKILL_NOT_FOUND:404,MODEL_PROFILE_NOT_FOUND:404,SKILL_NOT_ALLOWED:422,TOOL_POLICY_NOT_FOUND:404,TOOL_POLICY_DISABLED:422};return s in o?Response.json({error:t,code:"INVALID_CAPABILITY"},{status:o[s]}):"INVALID_RUN_REQUEST"===s?Response.json({error:t,code:"INVALID_REQUEST"},{status:400}):Response.json({error:t,code:"RUN_FAILED"},{status:500})}async function p(){let e=(0,n.dp)().publicView(),t=(0,r.i)(),s=await t.call("listSkills",[]),o=(0,l.e)().getAll(),a=await t.mcp.listAll();return{protocolVersion:"1",provider:{id:"customer-agent",name:"Customer Agent"},features:{streaming:!0,memory:!0,cancellation:!0},models:e.profiles.map(e=>({id:e.id,name:e.name,provider:e.provider,modelId:e.modelId})),skills:s.filter(e=>!1!==e.enabled).map(e=>({id:e.name,name:e.name,description:e.description??""})),tools:o.map(e=>({id:e.name,name:e.name,description:e.description,inputSchema:e.parameters})),mcpServers:a.map(e=>({id:e.id,name:e.name||e.id,status:"available"})),toolPolicies:await (0,i.cm)().summaries()}}function m(e){let t=S(e,"request"),s=y(t.input,"input",1e5),o=function(e,t,s){if(void 0!==e)return y(e,t,32e3)}(t.instructions,"instructions",0),r=E(t.agentId,"agentId"),n=E(t.sessionId,"sessionId"),i=void 0===t.context?{}:S(t.context,"context");if(JSON.stringify(i).length>12e4)throw new a("INVALID_REQUEST","context is too large");let l=void 0===t.selection?{}:S(t.selection,"selection"),d={};for(let[e,t]of(d.modelId=E(l.modelId,"selection.modelId"),d.toolPolicyId=E(l.toolPolicyId,"selection.toolPolicyId"),[["skillIds","skillIds"],["activatedSkillIds","activatedSkillIds"],["toolIds","toolIds"],["mcpServerIds","mcpServerIds"]])){let s=function(e,t){if(void 0===e)return;if(!Array.isArray(e)||e.length>200)throw new a("INVALID_REQUEST",`${t} must contain at most 200 identifiers`);let s=e.map(e=>y(e,t));if(new Set(s).size!==s.length)throw new a("INVALID_REQUEST",`${t} contains duplicate identifiers`);return s}(l[e],`selection.${e}`);void 0!==s&&(d[t]=s)}if(void 0!==l.memoryEnabled){if("boolean"!=typeof l.memoryEnabled)throw new a("INVALID_REQUEST","selection.memoryEnabled must be boolean");d.memoryEnabled=l.memoryEnabled}if(d.skillIds&&d.activatedSkillIds){let e=new Set(d.skillIds);if(d.activatedSkillIds.some(t=>!e.has(t)))throw new a("INVALID_REQUEST","activatedSkillIds must be a subset of skillIds")}return{input:s,...o?{instructions:o}:{},...r?{agentId:r}:{},...n?{sessionId:n}:{},context:i,selection:d}}async function I(e){let t=await p();if(e.agentId&&!await (0,r.i)().agents.get(e.agentId))throw new a("INVALID_CAPABILITY",`Unknown Agent: ${e.agentId}`,404);v(e.selection.modelId?[e.selection.modelId]:void 0,t.models,"model"),v(e.selection.skillIds,t.skills,"Skill"),v(e.selection.activatedSkillIds,t.skills,"activated Skill"),v(e.selection.toolIds,t.tools,"Tool"),v(e.selection.mcpServerIds,t.mcpServers,"MCP server"),v(e.selection.toolPolicyId?[e.selection.toolPolicyId]:void 0,t.toolPolicies,"tool policy")}function f(e,t){for(w(),d.set(e,{runId:e,sessionId:t,createdAt:Date.now()});d.size>500;)d.delete(d.keys().next().value)}function g(e){w();let t=d.get(e);if(!t)throw new a("RUN_NOT_FOUND","Flow protocol run not found",404);return t}function h(e,t,s,o){let r={runId:e,sessionId:t,timestamp:new Date().toISOString()};return"text_chunk"===o.type?{id:s,event:"assistant.delta",data:{...r,text:o.text}}:"tool_call"===o.type?{id:s,event:"tool.started",data:{...r,callId:o.toolCall.id,name:o.toolCall.name,arguments:o.toolCall.arguments}}:"tool_result"===o.type?{id:s,event:"tool.completed",data:{...r,callId:o.result.toolCallId,content:o.result.content,isError:!0===o.result.isError}}:"done"===o.type?{id:s,event:"run.completed",data:{...r,text:o.finalText,durationMs:o.durationMs,usage:o.usage}}:"error"===o.type?{id:s,event:"run.failed",data:{...r,code:o.code||"RUN_FAILED",message:o.message}}:"turn_aborted"===o.type?{id:s,event:"run.failed",data:{...r,code:"RUN_CANCELLED",message:"Run cancelled"}}:null}function w(){let e=Date.now()-36e5;for(let[t,s]of d)s.createdAt<e&&d.delete(t)}function v(e,t,s){if(void 0===e)return;let o=new Set(t.map(e=>e.id)),r=e.find(e=>!o.has(e));if(r)throw new a("INVALID_CAPABILITY",`Unknown ${s}: ${r}`,422)}function S(e,t){if(!e||"object"!=typeof e||Array.isArray(e))throw new a("INVALID_REQUEST",`${t} must be an object`);return e}function y(e,t,s=200){if("string"!=typeof e||!e.trim()||e.length>s)throw new a("INVALID_REQUEST",`${t} must be a non-empty string no longer than ${s} characters`);return e.trim()}function E(e,t){if(void 0!==e)return y(e,t)}},6361:(e,t,s)=>{s.d(t,{Q:()=>i,e:()=>n});var o=s(1322),r=s(7519);function n(){let e=new o.S3T;(0,o._5y)(e);let t=new o.OqQ;for(let s of(e.register(new o.Q8u(t,null)),e.register(new o.URd(t,null)),r.agentHost.getBuilder().getToolRegistry().getAll()))e.register(s);return e.register(new o.gBG(async()=>({status:"failed",agentName:"",subSessionId:"",error:"catalog listing only; dispatch runs inside a Customer Agent session"}))),e.register(new o.HbQ(async()=>({status:"failed",agentName:"",subSessionId:"",error:"catalog listing only; dispatch runs inside a Customer Agent session"}))),e}function i(){return n().getAll().map(e=>e.name).sort()}},1489:(e,t,s)=>{s.d(t,{N:()=>a});var o=s(1322),r=s(6279),n=s(785);class i{constructor(){this.tasks=new o.vo4((0,n.kO)()),this.scheduler=new r.ST(this.tasks,e=>{this.fire(e).catch(e=>console.error("Scheduled Customer Agent run failed",e))},()=>{}),this.scheduler.start()}async fire(e){let{agentHost:t}=await s.e(7519).then(s.bind(s,7519)),{getCustomerGoalCoordinator:o}=await Promise.all([s.e(7519),s.e(732)]).then(s.bind(s,5038)),r=e.sessionId;r&&await t.getSessionStore().get(r)||(r=(await t.createSession(e.label||"定时任务")).id,this.tasks.update(e.id,{sessionId:r})),await o().enqueue(r,e.prompt)}call(e,t){let s=String(t[0]||"");switch(e){case"cronList":return this.tasks.list();case"cronCreate":{if("string"!=typeof t[0]||"string"!=typeof t[1]||!t[1].trim())throw Error("cron and prompt required");let e=t[2]&&"object"==typeof t[2]?t[2]:{};return this.tasks.create({cron:t[0],prompt:t[1],recurring:!1!==e.recurring,enabled:!0,durable:!0,..."string"==typeof e.sessionId?{sessionId:e.sessionId}:{},..."string"==typeof e.label?{label:e.label}:{}})}case"cronPause":return this.tasks.pause(s);case"cronResume":return this.tasks.resume(s);case"cronDelete":return this.tasks.delete(s);case"cronDeleteAll":return this.tasks.deleteAll(),{ok:!0};default:throw Error("Unsupported schedule operation")}}}let l=globalThis;function a(){return l.__sharedCronService??=new i}},8615:(e,t,s)=>{let o;s.d(t,{H5:()=>c,cm:()=>a,jw:()=>d});var r=s(1322),n=s(785),i=s(6361);class l{constructor(e=(0,n.kO)()){this.store=new r.RQW(e)}list(){return this.store.list()}get(e){return this.store.get(e)}async summaries(){return(await this.store.list()).filter(e=>e.enabled).map(r._0R)}save(e,t){let s=(0,r.IJh)(e,{knownTools:t,requireExecutables:!0});return this.store.save(s)}delete(e){return this.store.delete(e)}}function a(){return o??=new l}function d(){return(0,i.Q)()}function c(e){let t=e instanceof r.DlR?422:400;return Response.json({error:e instanceof Error?e.message:"Tool policy request failed",code:e instanceof r.DlR?e.code:"INVALID_TOOL_POLICY"},{status:t})}}};var t=require("../../../../../webpack-runtime.js");t.C(e);var s=e=>t(t.s=e),o=t.X(0,[8375,6244,1322,1773,4621,7519],()=>s(7585));module.exports=o})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(()=>{var e={};e.id=2489,e.ids=[2489],e.modules={7728:e=>{e.exports=require("@anthropic-ai/claude-agent-sdk")},5890:e=>{e.exports=require("better-sqlite3")},399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},1282:e=>{e.exports=require("child_process")},2048:e=>{e.exports=require("fs")},9801:e=>{e.exports=require("os")},5315:e=>{e.exports=require("path")},7718:e=>{e.exports=require("node:child_process")},6005:e=>{e.exports=require("node:crypto")},5673:e=>{e.exports=require("node:events")},7561:e=>{e.exports=require("node:fs")},3977:e=>{e.exports=require("node:fs/promises")},8849:e=>{e.exports=require("node:http")},2286:e=>{e.exports=require("node:https")},2033:e=>{e.exports=require("node:module")},7503:e=>{e.exports=require("node:net")},612:e=>{e.exports=require("node:os")},9411:e=>{e.exports=require("node:path")},1747:e=>{e.exports=require("node:readline")},4492:e=>{e.exports=require("node:stream")},6915:e=>{e.exports=require("node:string_decoder")},1041:e=>{e.exports=require("node:url")},7261:e=>{e.exports=require("node:util")},5994:(e,r,t)=>{t.r(r),t.d(r,{originalPathname:()=>
|
|
1
|
+
"use strict";(()=>{var e={};e.id=2489,e.ids=[2489],e.modules={7728:e=>{e.exports=require("@anthropic-ai/claude-agent-sdk")},5890:e=>{e.exports=require("better-sqlite3")},399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},1282:e=>{e.exports=require("child_process")},2048:e=>{e.exports=require("fs")},9801:e=>{e.exports=require("os")},5315:e=>{e.exports=require("path")},7718:e=>{e.exports=require("node:child_process")},6005:e=>{e.exports=require("node:crypto")},5673:e=>{e.exports=require("node:events")},7561:e=>{e.exports=require("node:fs")},3977:e=>{e.exports=require("node:fs/promises")},8849:e=>{e.exports=require("node:http")},2286:e=>{e.exports=require("node:https")},2033:e=>{e.exports=require("node:module")},7503:e=>{e.exports=require("node:net")},612:e=>{e.exports=require("node:os")},9411:e=>{e.exports=require("node:path")},1747:e=>{e.exports=require("node:readline")},4492:e=>{e.exports=require("node:stream")},6915:e=>{e.exports=require("node:string_decoder")},1041:e=>{e.exports=require("node:url")},7261:e=>{e.exports=require("node:util")},5994:(e,r,t)=>{t.r(r),t.d(r,{originalPathname:()=>f,patchFetch:()=>m,requestAsyncStorage:()=>p,routeModule:()=>d,serverHooks:()=>g,staticGenerationAsyncStorage:()=>h});var s={};t.r(s),t.d(s,{DELETE:()=>c,PUT:()=>u});var o=t(7786),n=t(5042),i=t(2184),a=t(9001),l=t(8615);async function u(e,{params:r}){let t=(0,a.o)(e);if(t)return t;try{if(!await (0,l.cm)().get(r.policyId))return Response.json({error:"Tool policy not found",code:"TOOL_POLICY_NOT_FOUND"},{status:404});let t=await e.json();if(!t||"object"!=typeof t||Array.isArray(t))return Response.json({error:"Tool policy must be an object",code:"INVALID_TOOL_POLICY"},{status:422});if("id"in t&&t.id!==r.policyId)return Response.json({error:"Tool policy ID cannot be changed",code:"INVALID_TOOL_POLICY"},{status:422});return Response.json(await (0,l.cm)().save({...t,id:r.policyId},(0,l.jw)()))}catch(e){return(0,l.H5)(e)}}async function c(e,{params:r}){return(0,a.o)(e)||(await (0,l.cm)().delete(r.policyId)?Response.json({deleted:!0,policyId:r.policyId}):Response.json({error:"Tool policy not found",code:"TOOL_POLICY_NOT_FOUND"},{status:404}))}let d=new o.AppRouteRouteModule({definition:{kind:n.x.APP_ROUTE,page:"/api/tool-policies/[policyId]/route",pathname:"/api/tool-policies/[policyId]",filename:"route",bundlePath:"app/api/tool-policies/[policyId]/route"},resolvedPagePath:"/Volumes/ext/project/team-agent/packages/server/app/api/tool-policies/[policyId]/route.ts",nextConfigOutput:"standalone",userland:s}),{requestAsyncStorage:p,staticGenerationAsyncStorage:h,serverHooks:g}=d,f="/api/tool-policies/[policyId]/route";function m(){return(0,i.patchFetch)({serverHooks:g,staticGenerationAsyncStorage:h})}},7786:(e,r,t)=>{e.exports=t(517)},6361:(e,r,t)=>{t.d(r,{Q:()=>i,e:()=>n});var s=t(1322),o=t(7519);function n(){let e=new s.S3T;(0,s._5y)(e);let r=new s.OqQ;for(let t of(e.register(new s.Q8u(r,null)),e.register(new s.URd(r,null)),o.agentHost.getBuilder().getToolRegistry().getAll()))e.register(t);return e.register(new s.gBG(async()=>({status:"failed",agentName:"",subSessionId:"",error:"catalog listing only; dispatch runs inside a Customer Agent session"}))),e.register(new s.HbQ(async()=>({status:"failed",agentName:"",subSessionId:"",error:"catalog listing only; dispatch runs inside a Customer Agent session"}))),e}function i(){return n().getAll().map(e=>e.name).sort()}},1489:(e,r,t)=>{t.d(r,{N:()=>l});var s=t(1322),o=t(6279),n=t(785);class i{constructor(){this.tasks=new s.vo4((0,n.kO)()),this.scheduler=new o.ST(this.tasks,e=>{this.fire(e).catch(e=>console.error("Scheduled Customer Agent run failed",e))},()=>{}),this.scheduler.start()}async fire(e){let{agentHost:r}=await t.e(7519).then(t.bind(t,7519)),{getCustomerGoalCoordinator:s}=await Promise.all([t.e(7519),t.e(732)]).then(t.bind(t,5038)),o=e.sessionId;o&&await r.getSessionStore().get(o)||(o=(await r.createSession(e.label||"定时任务")).id,this.tasks.update(e.id,{sessionId:o})),await s().enqueue(o,e.prompt)}call(e,r){let t=String(r[0]||"");switch(e){case"cronList":return this.tasks.list();case"cronCreate":{if("string"!=typeof r[0]||"string"!=typeof r[1]||!r[1].trim())throw Error("cron and prompt required");let e=r[2]&&"object"==typeof r[2]?r[2]:{};return this.tasks.create({cron:r[0],prompt:r[1],recurring:!1!==e.recurring,enabled:!0,durable:!0,..."string"==typeof e.sessionId?{sessionId:e.sessionId}:{},..."string"==typeof e.label?{label:e.label}:{}})}case"cronPause":return this.tasks.pause(t);case"cronResume":return this.tasks.resume(t);case"cronDelete":return this.tasks.delete(t);case"cronDeleteAll":return this.tasks.deleteAll(),{ok:!0};default:throw Error("Unsupported schedule operation")}}}let a=globalThis;function l(){return a.__sharedCronService??=new i}},9001:(e,r,t)=>{t.d(r,{o:()=>o});let s=new Set(["capacitor://localhost","ionic://localhost"]);function o(e){if(!e.headers.get("content-type")?.toLowerCase().startsWith("application/json"))return Response.json({error:"JSON required"},{status:415});let r=e.headers.get("origin");if(!r||s.has(r))return null;let t=new URL(e.url),o="1"===process.env.AGENT_TRUST_TUNNEL_PROXY,n=o?e.headers.get("x-forwarded-host")?.split(",")[0].trim()||e.headers.get("host")||t.host:e.headers.get("host")||t.host,i=o&&e.headers.get("x-forwarded-proto")?.split(",")[0].trim()||t.protocol.slice(0,-1);return r!==`${i}://${n}`?Response.json({error:"Cross-origin write denied"},{status:403}):null}},8615:(e,r,t)=>{let s;t.d(r,{H5:()=>c,cm:()=>l,jw:()=>u});var o=t(1322),n=t(785),i=t(6361);class a{constructor(e=(0,n.kO)()){this.store=new o.RQW(e)}list(){return this.store.list()}get(e){return this.store.get(e)}async summaries(){return(await this.store.list()).filter(e=>e.enabled).map(o._0R)}save(e,r){let t=(0,o.IJh)(e,{knownTools:r,requireExecutables:!0});return this.store.save(t)}delete(e){return this.store.delete(e)}}function l(){return s??=new a}function u(){return(0,i.Q)()}function c(e){let r=e instanceof o.DlR?422:400;return Response.json({error:e instanceof Error?e.message:"Tool policy request failed",code:e instanceof o.DlR?e.code:"INVALID_TOOL_POLICY"},{status:r})}}};var r=require("../../../../webpack-runtime.js");r.C(e);var t=e=>r(r.s=e),s=r.X(0,[8375,6244,1322,1773,4621,7519],()=>t(5994));module.exports=s})();
|