@nelsonlongxiang/dsh-open-a2a-net 0.6.33 → 0.6.35
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/README.md +5 -2
- package/README_zh.md +5 -2
- package/assets/nexusDist/assets/index-Du2E6DJL.js +9 -0
- package/assets/nexusDist/assets/index-z33lHtLw.css +1 -0
- package/assets/nexusDist/index.html +2 -2
- package/cli/a2a.mjs +3 -1
- package/lib/a2a-client.js +9 -2
- package/lib/auth-observer.js +1 -1
- package/lib/canvas-store.js +64 -6
- package/lib/card.js +2 -1
- package/lib/cli-home.js +44 -0
- package/lib/client/A2aControl.js +1 -1
- package/lib/client.js +65 -65
- package/lib/client.js.map +1 -1
- package/lib/direct-forward.js +61 -0
- package/lib/faces/admin.js +43 -6
- package/lib/faces/wire.js +57 -40
- package/lib/flood-guard.js +7 -1
- package/lib/index.js +117 -65
- package/lib/outbound-scope.js +25 -0
- package/lib/queue-guard.js +37 -0
- package/lib/response-fields.js +27 -0
- package/lib/skill/references/cli.md +11 -4
- package/lib/skill/references/pitfalls.md +5 -4
- package/lib/skill/references/routing.md +4 -0
- package/lib/task-auth.js +52 -3
- package/lib/task-ledger.js +4 -1
- package/lib/tools/info.js +19 -3
- package/lib/types/a2a-client.d.ts +1 -1
- package/lib/types/auth-observer.d.ts +2 -2
- package/lib/types/canvas-store.d.ts +15 -1
- package/lib/types/cli-home.d.ts +24 -0
- package/lib/types/client/A2aControl.d.ts +1 -1
- package/lib/types/direct-forward.d.ts +32 -0
- package/lib/types/faces/admin.d.ts +8 -1
- package/lib/types/faces/wire.d.ts +12 -4
- package/lib/types/flood-guard.d.ts +5 -0
- package/lib/types/index.d.ts +4 -0
- package/lib/types/outbound-scope.d.ts +21 -0
- package/lib/types/queue-guard.d.ts +32 -0
- package/lib/types/response-fields.d.ts +3 -0
- package/lib/types/runtime.d.ts +1 -1
- package/lib/types/task-auth.d.ts +17 -2
- package/lib/types/task-ledger.d.ts +6 -1
- package/lib/types/types.d.ts +8 -0
- package/nexus-stage/src/cli-home-picker.ts +42 -0
- package/nexus-stage/src/main.ts +9 -2
- package/nexus-stage/src/planning-card.ts +61 -0
- package/nexus-stage/src/planning-menus.ts +42 -7
- package/nexus-stage/src/planning-view.ts +14 -32
- package/nexus-stage/src/planning.css +17 -0
- package/nexus-stage/src/workbench.css +4 -0
- package/nexus-stage/src/workbench.ts +28 -5
- package/nexus-stage/src/world.ts +5 -1
- package/package.json +2 -1
- package/assets/nexusDist/assets/index-BACVZe0j.css +0 -1
- package/assets/nexusDist/assets/index-Bbxnpf2p.js +0 -9
package/lib/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","names":["css","Button","IconGlobeOutlineRegular","_Fragment"],"sources":["../node_modules/.pnpm/clsx@2.1.1/node_modules/clsx/dist/clsx.mjs","client/A2aControl.js","client/locales.js","client/index.js"],"sourcesContent":["function r(e){var t,f,n=\"\";if(\"string\"==typeof e||\"number\"==typeof e)n+=e;else if(\"object\"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=\" \"),n+=f)}else for(f in e)e[f]&&(n&&(n+=\" \"),n+=f);return n}export function clsx(){for(var e,t,f=0,n=\"\",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=\" \"),n+=t);return n}export default clsx;","import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from \"react/jsx-runtime\";\n/**\n * A2A network control: a footer action opening this host's recent network\n * activity feed. The feed is the panel's whole content — in-flight routes,\n * owed receipts, and the routing activity ring. Session/team management\n * lives in the planning view (design: docs/design/panel-activity-feed.md):\n * the stage links row above the feed is the explicit navigation to it.\n * Probes the host's state route at registration time (the seat renders only\n * on a host that serves it). While open, the feed polls so it visibly\n * follows each turn; the closed trigger's unread badge rides a slow poll.\n */\nimport { useCallback, useEffect, useRef, useState } from 'react';\nimport clsx from 'clsx';\nimport { Button, IconGlobeOutlineRegular } from '@deepseek-ai/dsh-client-ui-primitives';\nimport css from './A2aControl.module.css';\n/** Fetch the host's network state; undefined means the route is absent. */\nasync function fetchState() {\n const response = await fetch('/__dsh_a2a/state', { cache: 'no-store' });\n if (!response.ok)\n return undefined;\n const body = await response.json();\n if (body.nodes !== true || !Array.isArray(body.sessions))\n return undefined;\n return {\n sessions: body.sessions,\n activity: Array.isArray(body.activity) ? body.activity : [],\n inFlight: Array.isArray(body.inFlight) ? body.inFlight : [],\n tasks: Array.isArray(body.tasks) ? body.tasks : [],\n ...(typeof body.tasksStaleCount === 'number' ? { tasksStaleCount: body.tasksStaleCount } : {}),\n ...(typeof body.version === 'string' ? { version: body.version } : {}),\n };\n}\n/** Compact relative time for an activity row. */\nfunction relativeTime(ts) {\n const seconds = Math.max(0, Math.round((Date.now() - ts) / 1000));\n if (seconds < 60)\n return `${String(seconds)}s`;\n const minutes = Math.round(seconds / 60);\n if (minutes < 60)\n return `${String(minutes)}m`;\n return `${String(Math.round(minutes / 60))}h`;\n}\n/** One feed row: direction glyph (aria-labelled), team, peer host, age, fail mark. */\nfunction FeedRow({ dir, team, peer, ts, ok, target, openSession, t }) {\n const fresh = Date.now() - ts < 5_000;\n return (_jsxs(\"div\", { className: clsx(css.activityRow, fresh && css.fresh), \"data-ok\": ok === undefined ? undefined : String(ok), \"data-jump\": target !== undefined, title: target !== undefined ? t('a2a.jump') : undefined, onClick: () => { if (target !== undefined)\n openSession(target.id); }, role: target !== undefined ? 'button' : undefined, children: [_jsx(\"span\", { className: clsx(css.activityDir, dir), \"aria-label\": dir === 'in' ? 'inbound' : 'outbound', children: dir === 'in' ? '←' : '→' }), _jsx(\"span\", { className: css.activityTeam, title: team, children: team }), _jsx(\"span\", { className: css.activityPeer, title: peer, children: peer === '' || peer === 'local' ? '' : peer.replace(/^https?:\\/\\//, '').replace(/\\/.*$/, '') }), ok === false ? _jsx(\"span\", { className: css.failMark, \"aria-label\": \"failed\", children: \"\\u2715\" }) : null, _jsx(\"span\", { className: css.activityTime, children: relativeTime(ts) })] }));\n}\n/**\n * Render the network toggle and its activity feed.\n * @param props - composed slot props.\n * @returns the control element tree.\n */\nexport function A2aControl({ wide, t, openSession }) {\n const [open, setOpen] = useState(false);\n const [state, setState] = useState({ sessions: [], activity: [], inFlight: [], tasks: [] });\n const [seenActivity, setSeenActivity] = useState(0);\n const stopped = useRef(false);\n useEffect(() => () => { stopped.current = true; }, []);\n const wrap = useRef(null);\n // The popover anchors to the trigger's viewport rect: the sidebar column\n // clips its descendants (the collapse slide), so an in-column absolute\n // popover is cut at the column edge whenever the column is narrower than\n // the popover; fixed positioning escapes the clip at rest (the ui-settings\n // panel precedent). The left edge clamps so a narrow viewport never hides\n // the popover's right side.\n const [anchor, setAnchor] = useState(null);\n // The unread badge counts inbound activity entries that arrived while the\n // panel was closed; opening the panel clears it.\n const unread = Math.max(0, state.activity.filter(entry => entry.dir === 'in').length - seenActivity);\n const toggleOpen = () => {\n if (open) {\n setOpen(false);\n return;\n }\n const rect = wrap.current?.getBoundingClientRect();\n if (rect !== undefined) {\n setAnchor({\n left: Math.max(8, Math.min(rect.left, window.innerWidth - 336)),\n bottom: window.innerHeight - rect.top + 8,\n });\n }\n setSeenActivity(state.activity.filter(entry => entry.dir === 'in').length);\n setOpen(true);\n };\n const refresh = useCallback(() => {\n void fetchState().then((next) => {\n if (!stopped.current && next !== undefined)\n setState(next);\n }).catch(() => { });\n }, []);\n useEffect(() => {\n if (open)\n refresh();\n }, [open, refresh]);\n useEffect(() => {\n // The unread badge lives on the closed trigger, so the state must move\n // even while the panel is closed — a slow poll keeps it fresh; the open\n // panel's faster poll below takes over while visible.\n const slow = setInterval(refresh, 10_000);\n refresh();\n return () => { clearInterval(slow); };\n }, [refresh]);\n useEffect(() => {\n if (!open)\n return;\n // While the feed is open, it polls so the ring visibly follows turns.\n const poll = setInterval(refresh, 2_000);\n return () => { clearInterval(poll); };\n }, [open, refresh]);\n useEffect(() => {\n if (!open)\n return;\n const onPointerDown = (event) => {\n if (event.target.closest(`.${css.wrap}`) === null)\n setOpen(false);\n };\n document.addEventListener('pointerdown', onPointerDown);\n return () => { document.removeEventListener('pointerdown', onPointerDown); };\n }, [open]);\n // 0.6.10: the receive face of click-to-reach (0.6.7 BroadcastChannel,\n // 0.6.8 ?dsh-a2a-open deep link) is removed by ruling — 禁止任何跳转,\n // 全部使用响应式布局. The workbench's 快派 form is the only cross-surface\n // reach primitive and it stays on the workbench page; this panel's\n // FeedRow openSession remains (it switches a conversation in place inside\n // the GUI — no navigation).\n const { sessions, activity, inFlight, tasks } = state;\n return (_jsxs(\"div\", { ref: wrap, className: clsx(css.wrap, wide ? css.wide : css.rail), children: [_jsx(Button, { variant: \"ghost\", size: \"sm\", title: t('a2a.label'), \"aria-label\": t('a2a.label'), \"aria-expanded\": open, onClick: () => { toggleOpen(); }, children: _jsxs(\"span\", { className: css.trigger, children: [_jsx(IconGlobeOutlineRegular, {}), wide ? _jsx(\"span\", { children: t('a2a.label') }) : null, unread > 0 ? _jsx(\"span\", { className: css.unreadBadge, \"aria-label\": String(unread), children: unread > 9 ? '9+' : String(unread) }) : null] }) }), open\n ? (_jsxs(\"div\", { className: css.popover, role: \"dialog\", \"aria-label\": t('a2a.title'), style: anchor === null ? undefined : { left: `${String(anchor.left)}px`, bottom: `${String(anchor.bottom)}px` }, children: [_jsxs(\"div\", { className: css.title, children: [t('a2a.title'), state.version !== undefined ? _jsxs(\"span\", { className: css.versionTag, title: state.version, children: [\"v\", state.version] }) : null] }), _jsxs(\"div\", { className: css.stageRow, children: [_jsx(\"span\", { className: css.stageTitle, children: t('a2a.stageTitle') }), _jsx(\"span\", { className: css.stageLinks, children: _jsx(\"a\", { className: css.stageLink, href: \"/__dsh_a2a_nexus/\", target: \"_blank\", rel: \"noreferrer\", title: t('a2a.stageWorkbench'), children: t('a2a.stageWorkbench') }) })] }), _jsxs(\"div\", { \"aria-live\": \"polite\", children: [inFlight.length > 0 && (_jsx(\"div\", { className: css.inFlightList, \"aria-label\": t('a2a.inFlight'), children: inFlight.map((route) => (_jsxs(\"div\", { className: clsx(css.inFlightRow, Date.now() - route.startedAt > 120_000 && css.inFlightStale), title: Date.now() - route.startedAt > 120_000 ? t('a2a.inFlightStale') : undefined, children: [_jsx(\"span\", { className: css.inFlightPulse, \"aria-hidden\": true }), _jsx(FeedRow, { dir: \"out\", team: route.team, peer: route.peer, ts: route.startedAt, openSession: openSession, t: t })] }, `${route.team}-${String(route.startedAt)}`))) })), (() => {\n // C-ruling: render only settleable debt; the stale tail is a\n // count line, never a row-per-noise listing.\n const settleableTasks = tasks.filter(task => task.settleable !== false);\n const staleCount = state.tasksStaleCount ?? (tasks.length - settleableTasks.length);\n if (settleableTasks.length === 0 && staleCount === 0)\n return null;\n return (_jsxs(_Fragment, { children: [settleableTasks.length > 0 && (_jsxs(_Fragment, { children: [_jsx(\"div\", { className: css.sectionTitle, children: t('a2a.tasks') }), _jsx(\"div\", { className: css.inFlightList, \"aria-label\": t('a2a.tasks'), children: settleableTasks.map((task) => (_jsx(\"div\", { className: css.inFlightRow, title: t('a2a.tasksNote'), children: _jsx(FeedRow, { dir: \"out\", team: task.team, peer: task.peer, ts: task.startedAt, openSession: openSession, t: t }) }, task.taskId))) })] })), staleCount > 0 && (_jsxs(\"div\", { className: css.staleNote, title: t('a2a.tasksNote'), children: [t('a2a.tasksStale'), \" \\u00B7 \", String(staleCount)] }))] }));\n })(), _jsx(\"div\", { className: css.sectionTitle, children: t('a2a.activity') }), activity.length === 0\n ? _jsx(\"div\", { className: css.empty, children: t('a2a.activityEmpty') })\n : (_jsx(\"div\", { className: css.activityList, children: [...activity].reverse().slice(0, 10).map((entry, index) => {\n // A same-host session team resolves to its session row;\n // clicking the activity line jumps there (the linkage\n // into an ongoing collaboration).\n const target = sessions.find(row => row.team === entry.team);\n return (_jsx(FeedRow, { dir: entry.dir, team: entry.team, peer: entry.peer, ts: entry.ts, ok: entry.ok, ...(target !== undefined ? { target } : {}), openSession: openSession, t: t }, `${String(entry.ts)}-${String(index)}`));\n }) }))] })] }))\n : null] }));\n}\n","/** Locale dictionaries for the A2A network sidebar control (namespace `a2aNet`). */\n/** Simplified Chinese dictionary. */\nexport const zh = {\n 'a2a.label': 'A2A 网络',\n 'a2a.title': 'A2A 网络动态',\n 'a2a.activity': '最近动态',\n 'a2a.activityEmpty': '暂无网络动态——加入网络即可开始协作',\n 'a2a.inFlight': '进行中的路由',\n 'a2a.inFlightStale': '等待回执超时(对端处理慢或回执丢失);180 秒后自动解除并按已送达处理',\n 'a2a.tasks': '欠回执的异步任务',\n 'a2a.tasksNote': '异步欠账分三段:未决(等回执)→ 死信(超期自动标注,目标恢复后仍可补回执结算)→ 归档(结算留痕不蒸发)',\n 'a2a.tasksStale': '对话式已送达未答(非欠账,24h 自动死信)',\n 'a2a.jump': '点击跳转到该会话',\n 'a2a.stageTitle': 'A2A 工作台(目录 · 台账 · 活动 · 规划)',\n 'a2a.stageWorkbench': '打开工作台',\n};\n/** English dictionary. */\nexport const en = {\n 'a2a.label': 'A2A network',\n 'a2a.title': 'A2A network activity',\n 'a2a.activity': 'Recent activity',\n 'a2a.activityEmpty': 'No network activity yet — join sessions to the network to start collaborating',\n 'a2a.inFlight': 'Routes in flight',\n 'a2a.inFlightStale': 'Reply wait past 120s (slow or lost receipt); auto-releases as delivered at 180s',\n 'a2a.tasks': 'Owed receipts',\n 'a2a.tasksNote': 'Async debts in three tiers: pending (awaiting receipt) → dead-lettered (auto-flagged past the stale TTL; a revived target can still settle late) → archived (settled records kept for audit)',\n 'a2a.tasksStale': 'Delivered conversationally, no formal receipt (not debt; auto-dead-letters at the TTL)',\n 'a2a.jump': 'Click to open this session',\n 'a2a.stageTitle': 'A2A workbench (directory · ledger · activity · plan)',\n 'a2a.stageWorkbench': 'Open workbench',\n};\n","import { A2aControl } from \"./A2aControl.js\";\nimport { en, zh } from \"./locales.js\";\n/** Dictionary namespace owned by this plugin (network control copy). */\nconst NS = 'a2aNet';\n/** Services required by the browser half: the slot system, the sessions\n * flow used to wake cold rows, and the locale dictionaries. */\nexport const inject = ['slots', 'sessions', 'locale'];\n/** Registers the network control's dictionaries and its sidebar seat.\n * @param ctx - Client root context.\n */\nexport function apply(ctx) {\n ctx.effect(() => ctx.locale.register(NS, { zh, en }), 'a2a-net: dictionaries');\n // The network control renders only on a host that serves the session-node\n // state route (a2a host half + session nodes composed); the probe keeps\n // the seat quiet everywhere else.\n void fetch('/__dsh_a2a/state', { cache: 'no-store' })\n .then(response => (response.ok ? response.json() : undefined))\n .then((info) => {\n if (info?.nodes !== true)\n return;\n ctx.slots.inject('sidebar.footer.action', () => ctx.slots.register({\n name: 'sidebar.footer.action',\n id: 'a2a',\n order: 10,\n locale: NS,\n // Wake = the standard session-open flow: the host materializes the\n // session's agent and the a2a host half's persisted intent remounts\n // the node, so the cold row flips live on the next poll.\n inject: () => ({\n openSession: (id) => { ctx.sessions.open(id); },\n }),\n }, A2aControl));\n })\n .catch(() => { });\n}\n"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;EAAA,SAAS,EAAE,GAAE;GAAC,IAAI,GAAE,GAAE,IAAE;GAAG,IAAG,YAAU,OAAO,KAAG,YAAU,OAAO,GAAE,KAAG;QAAO,IAAG,YAAU,OAAO,GAAE,IAAG,MAAM,QAAQ,CAAC,GAAE;IAAC,IAAI,IAAE,EAAE;IAAO,KAAI,IAAE,GAAE,IAAE,GAAE,KAAI,EAAE,OAAK,IAAE,EAAE,EAAE,EAAE,OAAK,MAAI,KAAG,MAAK,KAAG;GAAE,OAAM,KAAI,KAAK,GAAE,EAAE,OAAK,MAAI,KAAG,MAAK,KAAG;GAAG,OAAO;EAAC;EAAC,SAAgB,OAAM;GAAC,KAAI,IAAI,GAAE,GAAE,IAAE,GAAE,IAAE,IAAG,IAAE,UAAU,QAAO,IAAE,GAAE,KAAI,CAAC,IAAE,UAAU,QAAM,IAAE,EAAE,CAAC,OAAK,MAAI,KAAG,MAAK,KAAG;GAAG,OAAO;E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AAG,CAAC,GAAG,uBAAuB;GAI7E,MAAW,oBAAoB,EAAE,OAAO,WAAW,CAAC,CAAC,CAChD,MAAK,aAAa,SAAS,KAAK,SAAS,KAAK,IAAI,KAAA,CAAU,CAAC,CAC7D,MAAM,SAAS;IAChB,IAAI,MAAM,UAAU,MAChB;IACJ,IAAI,MAAM,OAAO,+BAA+B,IAAI,MAAM,SAAS;KAC/D,MAAM;KACN,IAAI;KACJ,OAAO;KACP,QAAQ;KAIR,eAAe,EACX,cAAc,OAAO;MAAE,IAAI,SAAS,KAAK,EAAE;KAAG,EAClD;IACJ,GAAG,UAAU,CAAC;GAClB,CAAC,CAAC,CACG,YAAY,CAAE,CAAC;EACxB"}
|
|
1
|
+
{"version":3,"file":"client.js","names":["css","Button","IconGlobeOutlineRegular","_Fragment"],"sources":["../node_modules/.pnpm/clsx@2.1.1/node_modules/clsx/dist/clsx.mjs","client/A2aControl.js","client/locales.js","client/index.js"],"sourcesContent":["function r(e){var t,f,n=\"\";if(\"string\"==typeof e||\"number\"==typeof e)n+=e;else if(\"object\"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=\" \"),n+=f)}else for(f in e)e[f]&&(n&&(n+=\" \"),n+=f);return n}export function clsx(){for(var e,t,f=0,n=\"\",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=\" \"),n+=t);return n}export default clsx;","import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from \"react/jsx-runtime\";\n/**\n * A2A network control: a footer action opening this host's recent network\n * activity feed. The feed is the panel's whole content — in-flight routes,\n * owed receipts, and the routing activity ring. Session/team management\n * lives in the planning view (design: docs/design/panel-activity-feed.md):\n * the stage links row above the feed is the explicit navigation to it.\n * Probes the host's state route at registration time (the seat renders only\n * on a host that serves it). While open, the feed polls so it visibly\n * follows each turn; the closed trigger's unread badge rides a slow poll.\n */\nimport { useCallback, useEffect, useRef, useState } from 'react';\nimport clsx from 'clsx';\nimport { Button, IconGlobeOutlineRegular } from '@deepseek-ai/dsh-client-ui-primitives';\nimport css from './A2aControl.module.css';\n/** Fetch the host's network state; undefined means the route is absent. */\nasync function fetchState() {\n const response = await fetch('/__dsh_a2a/state', { cache: 'no-store' });\n if (!response.ok)\n return undefined;\n const body = await response.json();\n if (body.nodes !== true || !Array.isArray(body.sessions))\n return undefined;\n return {\n sessions: body.sessions,\n activity: Array.isArray(body.activity) ? body.activity : [],\n inFlight: Array.isArray(body.inFlight) ? body.inFlight : [],\n tasks: Array.isArray(body.tasks) ? body.tasks : [],\n ...(typeof body.tasksStaleCount === 'number' ? { tasksStaleCount: body.tasksStaleCount } : {}),\n ...(typeof body.version === 'string' ? { version: body.version } : {}),\n };\n}\n/** Compact relative time for an activity row. */\nfunction relativeTime(ts) {\n const seconds = Math.max(0, Math.round((Date.now() - ts) / 1000));\n if (seconds < 60)\n return `${String(seconds)}s`;\n const minutes = Math.round(seconds / 60);\n if (minutes < 60)\n return `${String(minutes)}m`;\n return `${String(Math.round(minutes / 60))}h`;\n}\n/** One feed row: direction glyph (aria-labelled), team, peer host, age, fail mark. */\nfunction FeedRow({ dir, team, peer, ts, ok, target, openSession, t }) {\n const fresh = Date.now() - ts < 5_000;\n return (_jsxs(\"div\", { className: clsx(css.activityRow, fresh && css.fresh), \"data-ok\": ok === undefined ? undefined : String(ok), \"data-jump\": target !== undefined, title: target !== undefined ? t('a2a.jump') : undefined, onClick: () => { if (target !== undefined)\n openSession(target.id); }, role: target !== undefined ? 'button' : undefined, children: [_jsx(\"span\", { className: clsx(css.activityDir, dir), \"aria-label\": dir === 'fwd' ? 'forwarded' : dir === 'in' ? 'inbound' : 'outbound', children: dir === 'fwd' ? '⇢' : dir === 'in' ? '←' : '→' }), _jsx(\"span\", { className: css.activityTeam, title: team, children: team }), _jsx(\"span\", { className: css.activityPeer, title: peer, children: peer === '' || peer === 'local' ? '' : peer.replace(/^https?:\\/\\//, '').replace(/\\/.*$/, '') }), ok === false ? _jsx(\"span\", { className: css.failMark, \"aria-label\": \"failed\", children: \"\\u2715\" }) : null, _jsx(\"span\", { className: css.activityTime, children: relativeTime(ts) })] }));\n}\n/**\n * Render the network toggle and its activity feed.\n * @param props - composed slot props.\n * @returns the control element tree.\n */\nexport function A2aControl({ wide, t, openSession }) {\n const [open, setOpen] = useState(false);\n const [state, setState] = useState({ sessions: [], activity: [], inFlight: [], tasks: [] });\n const [seenActivity, setSeenActivity] = useState(0);\n const stopped = useRef(false);\n useEffect(() => () => { stopped.current = true; }, []);\n const wrap = useRef(null);\n // The popover anchors to the trigger's viewport rect: the sidebar column\n // clips its descendants (the collapse slide), so an in-column absolute\n // popover is cut at the column edge whenever the column is narrower than\n // the popover; fixed positioning escapes the clip at rest (the ui-settings\n // panel precedent). The left edge clamps so a narrow viewport never hides\n // the popover's right side.\n const [anchor, setAnchor] = useState(null);\n // The unread badge counts inbound activity entries that arrived while the\n // panel was closed; opening the panel clears it.\n const unread = Math.max(0, state.activity.filter(entry => entry.dir === 'in').length - seenActivity);\n const toggleOpen = () => {\n if (open) {\n setOpen(false);\n return;\n }\n const rect = wrap.current?.getBoundingClientRect();\n if (rect !== undefined) {\n setAnchor({\n left: Math.max(8, Math.min(rect.left, window.innerWidth - 336)),\n bottom: window.innerHeight - rect.top + 8,\n });\n }\n setSeenActivity(state.activity.filter(entry => entry.dir === 'in').length);\n setOpen(true);\n };\n const refresh = useCallback(() => {\n void fetchState().then((next) => {\n if (!stopped.current && next !== undefined)\n setState(next);\n }).catch(() => { });\n }, []);\n useEffect(() => {\n if (open)\n refresh();\n }, [open, refresh]);\n useEffect(() => {\n // The unread badge lives on the closed trigger, so the state must move\n // even while the panel is closed — a slow poll keeps it fresh; the open\n // panel's faster poll below takes over while visible.\n const slow = setInterval(refresh, 10_000);\n refresh();\n return () => { clearInterval(slow); };\n }, [refresh]);\n useEffect(() => {\n if (!open)\n return;\n // While the feed is open, it polls so the ring visibly follows turns.\n const poll = setInterval(refresh, 2_000);\n return () => { clearInterval(poll); };\n }, [open, refresh]);\n useEffect(() => {\n if (!open)\n return;\n const onPointerDown = (event) => {\n if (event.target.closest(`.${css.wrap}`) === null)\n setOpen(false);\n };\n document.addEventListener('pointerdown', onPointerDown);\n return () => { document.removeEventListener('pointerdown', onPointerDown); };\n }, [open]);\n // 0.6.10: the receive face of click-to-reach (0.6.7 BroadcastChannel,\n // 0.6.8 ?dsh-a2a-open deep link) is removed by ruling — 禁止任何跳转,\n // 全部使用响应式布局. The workbench's 快派 form is the only cross-surface\n // reach primitive and it stays on the workbench page; this panel's\n // FeedRow openSession remains (it switches a conversation in place inside\n // the GUI — no navigation).\n const { sessions, activity, inFlight, tasks } = state;\n return (_jsxs(\"div\", { ref: wrap, className: clsx(css.wrap, wide ? css.wide : css.rail), children: [_jsx(Button, { variant: \"ghost\", size: \"sm\", title: t('a2a.label'), \"aria-label\": t('a2a.label'), \"aria-expanded\": open, onClick: () => { toggleOpen(); }, children: _jsxs(\"span\", { className: css.trigger, children: [_jsx(IconGlobeOutlineRegular, {}), wide ? _jsx(\"span\", { children: t('a2a.label') }) : null, unread > 0 ? _jsx(\"span\", { className: css.unreadBadge, \"aria-label\": String(unread), children: unread > 9 ? '9+' : String(unread) }) : null] }) }), open\n ? (_jsxs(\"div\", { className: css.popover, role: \"dialog\", \"aria-label\": t('a2a.title'), style: anchor === null ? undefined : { left: `${String(anchor.left)}px`, bottom: `${String(anchor.bottom)}px` }, children: [_jsxs(\"div\", { className: css.title, children: [t('a2a.title'), state.version !== undefined ? _jsxs(\"span\", { className: css.versionTag, title: state.version, children: [\"v\", state.version] }) : null] }), _jsxs(\"div\", { className: css.stageRow, children: [_jsx(\"span\", { className: css.stageTitle, children: t('a2a.stageTitle') }), _jsx(\"span\", { className: css.stageLinks, children: _jsx(\"a\", { className: css.stageLink, href: \"/__dsh_a2a_nexus/\", target: \"_blank\", rel: \"noreferrer\", title: t('a2a.stageWorkbench'), children: t('a2a.stageWorkbench') }) })] }), _jsxs(\"div\", { \"aria-live\": \"polite\", children: [inFlight.length > 0 && (_jsx(\"div\", { className: css.inFlightList, \"aria-label\": t('a2a.inFlight'), children: inFlight.map((route) => (_jsxs(\"div\", { className: clsx(css.inFlightRow, Date.now() - route.startedAt > 120_000 && css.inFlightStale), title: Date.now() - route.startedAt > 120_000 ? t('a2a.inFlightStale') : undefined, children: [_jsx(\"span\", { className: css.inFlightPulse, \"aria-hidden\": true }), _jsx(FeedRow, { dir: \"out\", team: route.team, peer: route.peer, ts: route.startedAt, openSession: openSession, t: t })] }, `${route.team}-${String(route.startedAt)}`))) })), (() => {\n // C-ruling: render only settleable debt; the stale tail is a\n // count line, never a row-per-noise listing.\n const settleableTasks = tasks.filter(task => task.settleable !== false);\n const staleCount = state.tasksStaleCount ?? (tasks.length - settleableTasks.length);\n if (settleableTasks.length === 0 && staleCount === 0)\n return null;\n return (_jsxs(_Fragment, { children: [settleableTasks.length > 0 && (_jsxs(_Fragment, { children: [_jsx(\"div\", { className: css.sectionTitle, children: t('a2a.tasks') }), _jsx(\"div\", { className: css.inFlightList, \"aria-label\": t('a2a.tasks'), children: settleableTasks.map((task) => (_jsx(\"div\", { className: css.inFlightRow, title: t('a2a.tasksNote'), children: _jsx(FeedRow, { dir: \"out\", team: task.team, peer: task.peer, ts: task.startedAt, openSession: openSession, t: t }) }, task.taskId))) })] })), staleCount > 0 && (_jsxs(\"div\", { className: css.staleNote, title: t('a2a.tasksNote'), children: [t('a2a.tasksStale'), \" \\u00B7 \", String(staleCount)] }))] }));\n })(), _jsx(\"div\", { className: css.sectionTitle, children: t('a2a.activity') }), activity.length === 0\n ? _jsx(\"div\", { className: css.empty, children: t('a2a.activityEmpty') })\n : (_jsx(\"div\", { className: css.activityList, children: [...activity].reverse().slice(0, 10).map((entry, index) => {\n // A same-host session team resolves to its session row;\n // clicking the activity line jumps there (the linkage\n // into an ongoing collaboration).\n const target = sessions.find(row => row.team === entry.team);\n return (_jsx(FeedRow, { dir: entry.dir, team: entry.team, peer: entry.peer, ts: entry.ts, ok: entry.ok, ...(target !== undefined ? { target } : {}), openSession: openSession, t: t }, `${String(entry.ts)}-${String(index)}`));\n }) }))] })] }))\n : null] }));\n}\n","/** Locale dictionaries for the A2A network sidebar control (namespace `a2aNet`). */\n/** Simplified Chinese dictionary. */\nexport const zh = {\n 'a2a.label': 'A2A 网络',\n 'a2a.title': 'A2A 网络动态',\n 'a2a.activity': '最近动态',\n 'a2a.activityEmpty': '暂无网络动态——加入网络即可开始协作',\n 'a2a.inFlight': '进行中的路由',\n 'a2a.inFlightStale': '等待回执超时(对端处理慢或回执丢失);180 秒后自动解除并按已送达处理',\n 'a2a.tasks': '欠回执的异步任务',\n 'a2a.tasksNote': '异步欠账分三段:未决(等回执)→ 死信(超期自动标注,目标恢复后仍可补回执结算)→ 归档(结算留痕不蒸发)',\n 'a2a.tasksStale': '对话式已送达未答(非欠账,24h 自动死信)',\n 'a2a.jump': '点击跳转到该会话',\n 'a2a.stageTitle': 'A2A 工作台(目录 · 台账 · 活动 · 规划)',\n 'a2a.stageWorkbench': '打开工作台',\n};\n/** English dictionary. */\nexport const en = {\n 'a2a.label': 'A2A network',\n 'a2a.title': 'A2A network activity',\n 'a2a.activity': 'Recent activity',\n 'a2a.activityEmpty': 'No network activity yet — join sessions to the network to start collaborating',\n 'a2a.inFlight': 'Routes in flight',\n 'a2a.inFlightStale': 'Reply wait past 120s (slow or lost receipt); auto-releases as delivered at 180s',\n 'a2a.tasks': 'Owed receipts',\n 'a2a.tasksNote': 'Async debts in three tiers: pending (awaiting receipt) → dead-lettered (auto-flagged past the stale TTL; a revived target can still settle late) → archived (settled records kept for audit)',\n 'a2a.tasksStale': 'Delivered conversationally, no formal receipt (not debt; auto-dead-letters at the TTL)',\n 'a2a.jump': 'Click to open this session',\n 'a2a.stageTitle': 'A2A workbench (directory · ledger · activity · plan)',\n 'a2a.stageWorkbench': 'Open workbench',\n};\n","import { A2aControl } from \"./A2aControl.js\";\nimport { en, zh } from \"./locales.js\";\n/** Dictionary namespace owned by this plugin (network control copy). */\nconst NS = 'a2aNet';\n/** Services required by the browser half: the slot system, the sessions\n * flow used to wake cold rows, and the locale dictionaries. */\nexport const inject = ['slots', 'sessions', 'locale'];\n/** Registers the network control's dictionaries and its sidebar seat.\n * @param ctx - Client root context.\n */\nexport function apply(ctx) {\n ctx.effect(() => ctx.locale.register(NS, { zh, en }), 'a2a-net: dictionaries');\n // The network control renders only on a host that serves the session-node\n // state route (a2a host half + session nodes composed); the probe keeps\n // the seat quiet everywhere else.\n void fetch('/__dsh_a2a/state', { cache: 'no-store' })\n .then(response => (response.ok ? response.json() : undefined))\n .then((info) => {\n if (info?.nodes !== true)\n return;\n ctx.slots.inject('sidebar.footer.action', () => ctx.slots.register({\n name: 'sidebar.footer.action',\n id: 'a2a',\n order: 10,\n locale: NS,\n // Wake = the standard session-open flow: the host materializes the\n // session's agent and the a2a host half's persisted intent remounts\n // the node, so the cold row flips live on the next poll.\n inject: () => ({\n openSession: (id) => { ctx.sessions.open(id); },\n }),\n }, A2aControl));\n })\n .catch(() => { });\n}\n"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;EAAA,SAAS,EAAE,GAAE;GAAC,IAAI,GAAE,GAAE,IAAE;GAAG,IAAG,YAAU,OAAO,KAAG,YAAU,OAAO,GAAE,KAAG;QAAO,IAAG,YAAU,OAAO,GAAE,IAAG,MAAM,QAAQ,CAAC,GAAE;IAAC,IAAI,IAAE,EAAE;IAAO,KAAI,IAAE,GAAE,IAAE,GAAE,KAAI,EAAE,OAAK,IAAE,EAAE,EAAE,EAAE,OAAK,MAAI,KAAG,MAAK,KAAG;GAAE,OAAM,KAAI,KAAK,GAAE,EAAE,OAAK,MAAI,KAAG,MAAK,KAAG;GAAG,OAAO;EAAC;EAAC,SAAgB,OAAM;GAAC,KAAI,IAAI,GAAE,GAAE,IAAE,GAAE,IAAE,IAAG,IAAE,UAAU,QAAO,IAAE,GAAE,KAAI,CAAC,IAAE,UAAU,QAAM,IAAE,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Y;EAAQ;;;;EAIpD,SAAgB,MAAM,KAAK;GACvB,IAAI,aAAa,IAAI,OAAO,SAAS,IAAI;IAAE;IAAI;GAAG,CAAC,GAAG,uBAAuB;GAI7E,MAAW,oBAAoB,EAAE,OAAO,WAAW,CAAC,CAAC,CAChD,MAAK,aAAa,SAAS,KAAK,SAAS,KAAK,IAAI,KAAA,CAAU,CAAC,CAC7D,MAAM,SAAS;IAChB,IAAI,MAAM,UAAU,MAChB;IACJ,IAAI,MAAM,OAAO,+BAA+B,IAAI,MAAM,SAAS;KAC/D,MAAM;KACN,IAAI;KACJ,OAAO;KACP,QAAQ;KAIR,eAAe,EACX,cAAc,OAAO;MAAE,IAAI,SAAS,KAAK,EAAE;KAAG,EAClD;IACJ,GAAG,UAAU,CAAC;GAClB,CAAC,CAAC,CACG,YAAY,CAAE,CAAC;EACxB"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/** H-side one-hop forwarding. Never resolves or dispatches local candidates again. */
|
|
2
|
+
import { DEFAULT_HOP_BUDGET, guardHeader, mintGuard } from "./recursion-guard.js";
|
|
3
|
+
import { briefOf } from "./task-ledger.js";
|
|
4
|
+
import { parseReceipt } from "./receipt.js";
|
|
5
|
+
export function createDirectForward(d) {
|
|
6
|
+
return async (request) => {
|
|
7
|
+
const refuse = (why) => ({ ok: false, code: -32000, task_id: request.taskId, error: 'not forwarded: ' + why });
|
|
8
|
+
if (!d.enabled())
|
|
9
|
+
return refuse('forwardDirect is off');
|
|
10
|
+
if (d.isolated())
|
|
11
|
+
return refuse('host is isolated');
|
|
12
|
+
if (request.guarded)
|
|
13
|
+
return refuse('an inbound X-A2A-Guard is present; already forwarded');
|
|
14
|
+
if (!request.localCliProof || !d.deposited(request.caller))
|
|
15
|
+
return refuse('caller is not a proven online local CLI deposit');
|
|
16
|
+
const scope = await d.scope(request.caller, request.team);
|
|
17
|
+
if (!scope.ok)
|
|
18
|
+
return refuse('target is outside sender scope: ' + scope.error);
|
|
19
|
+
const failures = [];
|
|
20
|
+
const directory = await d.candidates(request.team, failures, request.caller);
|
|
21
|
+
const guard = guardHeader({ ...mintGuard(), hopBudget: DEFAULT_HOP_BUDGET - 1 });
|
|
22
|
+
for (const url of directory.urls) {
|
|
23
|
+
if (!d.deposited(request.caller))
|
|
24
|
+
return refuse('local CLI deposit expired before dispatch');
|
|
25
|
+
if (request.team.includes('/canvas/')) {
|
|
26
|
+
const card = await directory.card(url);
|
|
27
|
+
const org = card?.canvasOrg?.find(row => row.team === request.team);
|
|
28
|
+
const receivers = org?.members.filter(member => member !== request.caller) ?? [];
|
|
29
|
+
if (receivers.length === 0 || receivers.some(member => !d.memberLinked(member))) {
|
|
30
|
+
failures.push(url + ': forwarding a canvas requires a direct operator link to every receiving member for its receipt return path');
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const answer = await d.dispatch(url, request, guard);
|
|
35
|
+
const result = !answer.ok && answer.ownBudgetExhausted === true ? { ...answer, code: -32005 } : answer;
|
|
36
|
+
d.activity(request.team, url, result.ok);
|
|
37
|
+
if (result.ok || result.code === -32005) {
|
|
38
|
+
// A receipt owes no receipt; native bridge rounds have no A2A receipt contract.
|
|
39
|
+
// Match routeTrunk/trackOwedTask rather than manufacturing an unpayable debt.
|
|
40
|
+
if (parseReceipt(request.message) !== null)
|
|
41
|
+
return { ...result, receipt: 'none' };
|
|
42
|
+
if (result.ok && result.bridge !== undefined)
|
|
43
|
+
return { ...result, receipt: 'none' };
|
|
44
|
+
const card = await directory.card(url);
|
|
45
|
+
const birth = { forwarded: true, ...(card?.publicKey ? { peerKey: card.publicKey } : {}), ...(card?.session ? { peerHost: card.session } : {}), deliveredTo: result.ok ? result.deliveredTo ?? request.team : request.team };
|
|
46
|
+
// Exactly one outbound row. A completed sync response is receiptless bookkeeping.
|
|
47
|
+
if (result.ok && (result.task_status === 'TASK_STATE_COMPLETED' || result.receipt === 'none'))
|
|
48
|
+
d.ledger.trackReceiptless(request.taskId, request.team, url, request.contextId, briefOf(request.message), { kind: 'cli', id: request.caller }, birth);
|
|
49
|
+
else
|
|
50
|
+
d.ledger.track(request.taskId, request.team, url, request.contextId, briefOf(request.message), { kind: 'cli', id: request.caller }, birth);
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
53
|
+
// The shared dispatcher's sync recovery query may prove a definitive failed
|
|
54
|
+
// outcome; like routeTrunk, that is an eligible miss, not an uncertain -32005.
|
|
55
|
+
failures.push(url + ': ' + result.error);
|
|
56
|
+
if (result.code === -32002 || result.code === -32003)
|
|
57
|
+
return { ...result, task_id: request.taskId };
|
|
58
|
+
}
|
|
59
|
+
return { ok: false, code: -32004, task_id: request.taskId, error: 'forwarding to "' + request.team + '" failed: ' + (failures.join('; ') || 'no eligible peer candidate') };
|
|
60
|
+
};
|
|
61
|
+
}
|
package/lib/faces/admin.js
CHANGED
|
@@ -20,11 +20,13 @@ import { join } from 'node:path';
|
|
|
20
20
|
import { fileURLToPath } from 'node:url';
|
|
21
21
|
import { canvasNameReserved as reservedCanvasName, isRemoteMemberRef, validRemoteMemberRef } from "../canvas-store.js";
|
|
22
22
|
import { refreshPeerCard, registerCanvasNotify } from "./canvas-notify.js";
|
|
23
|
+
import { CLI_HANDLE_RE } from "../cli-deposit.js";
|
|
23
24
|
import { applyOwnerSettings } from "../owner-settings.js";
|
|
24
25
|
import { rosterOp } from "../roster-op.js";
|
|
25
26
|
import { resolveStageMount } from "../stage-mount.js";
|
|
26
27
|
import { ARCHIVE_CAP, archivedEndedBy } from "../task-ledger.js";
|
|
27
28
|
import { MAX_LAYOUT_BODY_BYTES } from "../transport-caps.js";
|
|
29
|
+
import { queuedFor } from "../queue-guard.js";
|
|
28
30
|
/**
|
|
29
31
|
* Register the admin faces on a settled web server.
|
|
30
32
|
* @param webServer - the settled host web server.
|
|
@@ -54,6 +56,14 @@ export function registerAdminFaces(webServer, d) {
|
|
|
54
56
|
// or not. (The prune above already took their join intents; this
|
|
55
57
|
// covers never-joined live roots and any intent a restart left.)
|
|
56
58
|
const isArchived = archivedSessionFilter();
|
|
59
|
+
const liveStatusOf = (agent) => {
|
|
60
|
+
try {
|
|
61
|
+
return agent.status === 'running' ? 'running' : agent.status === 'idle' ? 'idle' : undefined;
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
57
67
|
const tFacts0 = Date.now();
|
|
58
68
|
const sessions = [...liveRoots.values()]
|
|
59
69
|
.filter(agent => isArchived?.(String(agent.id)) !== true)
|
|
@@ -68,6 +78,10 @@ export function registerAdminFaces(webServer, d) {
|
|
|
68
78
|
...nodeMetadataOf(agent),
|
|
69
79
|
joined: sessionNodes.has(String(agent.id)),
|
|
70
80
|
live: true,
|
|
81
|
+
// Owner 2026-11-03: whether the session is mid-turn right now, and how many
|
|
82
|
+
// receipt-owing tasks wait on it (the gh#224 queue count) — the board's 工作中/空闲.
|
|
83
|
+
status: liveStatusOf(agent),
|
|
84
|
+
queued: queuedFor(taskLedger.list(), sessionTeamOf(agent)),
|
|
71
85
|
teams: [...teamMemberships.teamsOf(String(agent.id))],
|
|
72
86
|
// #19 D3: the session's exposure tier (linked floor /
|
|
73
87
|
// fleet opt-up) — readable on the state face.
|
|
@@ -138,7 +152,7 @@ export function registerAdminFaces(webServer, d) {
|
|
|
138
152
|
rows.push({ id: localId, team: `${config.team}/${id8(localId)}`, joined: sessionNodes.has(localId) || joinedSessions.has(localId), live: sessionNodes.has(localId) });
|
|
139
153
|
continue;
|
|
140
154
|
}
|
|
141
|
-
rows.push({ id, team: id, remote: true });
|
|
155
|
+
rows.push({ id, team: id, remote: true, ...(CLI_HANDLE_RE.test(id) ? { cliHome: canvasStore.cliHomeOf(id) ?? null, cliHeld: cliDeposits.directoryRows().some(row => row.team === id), ...(canvasStore.wasCliHomeCleared(id) ? { cliHomeCleared: true } : {}) } : {}) });
|
|
142
156
|
continue;
|
|
143
157
|
}
|
|
144
158
|
if (seenLocal.has(id))
|
|
@@ -238,6 +252,7 @@ export function registerAdminFaces(webServer, d) {
|
|
|
238
252
|
...(row.brief !== undefined ? { brief: row.brief } : {}),
|
|
239
253
|
...(row.summary !== undefined && row.summary !== '' ? { summary: row.summary.slice(0, 160) } : {}),
|
|
240
254
|
...(row.sender !== undefined ? { sender: row.sender } : {}),
|
|
255
|
+
...(row.forwarded === true ? { forwarded: true } : {}),
|
|
241
256
|
...(row.auth !== undefined ? { auth: row.auth } : {}),
|
|
242
257
|
// #114 S4: who settled it and how they stood on the chain.
|
|
243
258
|
...(row.settledBy !== undefined ? { settledBy: row.settledBy } : {}),
|
|
@@ -454,8 +469,9 @@ export function registerAdminFaces(webServer, d) {
|
|
|
454
469
|
return '';
|
|
455
470
|
} })();
|
|
456
471
|
const out = name === config.team ? { ok: false, error: `a CLI identity may not be named after this host's zone "${config.team}" — choose another agent name` } : cliDeposits.deposit(card);
|
|
472
|
+
const homeCleared = out.ok && canvasStore.clearCliHomeForLocal(out.handle);
|
|
457
473
|
payload = JSON.stringify(out.ok
|
|
458
|
-
? { ok: true, handle: out.handle, expiresAt: out.expiresAt, cardUrl: `${d.ownCardUrl}/a2a/cli/${encodeURIComponent(out.handle)}` }
|
|
474
|
+
? { ok: true, handle: out.handle, expiresAt: out.expiresAt, ...(homeCleared ? { homeCleared: true } : {}), cardUrl: `${d.ownCardUrl}/a2a/cli/${encodeURIComponent(out.handle)}` }
|
|
459
475
|
: { ok: false, error: out.error });
|
|
460
476
|
}
|
|
461
477
|
else if (action === 'revoke') {
|
|
@@ -688,10 +704,24 @@ export function registerAdminFaces(webServer, d) {
|
|
|
688
704
|
kind: 'exact',
|
|
689
705
|
path: '/__dsh_a2a/canvas',
|
|
690
706
|
handler: controlRoute((req, res) => {
|
|
691
|
-
readJsonBody(req, res, (body) => {
|
|
707
|
+
readJsonBody(req, res, async (body) => {
|
|
692
708
|
const action = body.action;
|
|
693
709
|
let payload;
|
|
694
|
-
if (action === '
|
|
710
|
+
if (action === 'cli-home-options') {
|
|
711
|
+
const name = typeof body.name === 'string' ? body.name : '';
|
|
712
|
+
const id = typeof body.id === 'string' ? body.id : '';
|
|
713
|
+
if (!CLI_HANDLE_RE.test(id) || !canvasStore.membersOf(name).includes(id))
|
|
714
|
+
payload = JSON.stringify({ ok: false, error: 'an existing canvas CLI member is required' });
|
|
715
|
+
else {
|
|
716
|
+
try {
|
|
717
|
+
payload = JSON.stringify({ ok: true, ...await d.cliHomeOptions(id) });
|
|
718
|
+
}
|
|
719
|
+
catch {
|
|
720
|
+
payload = JSON.stringify({ ok: false, error: 'fresh home card lookup failed' });
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
else if (action === 'create') {
|
|
695
725
|
const name = typeof body.name === 'string' ? body.name : '';
|
|
696
726
|
const stored = canvasNameReserved(name) ? undefined : canvasStore.create(name);
|
|
697
727
|
payload = JSON.stringify(stored === undefined ? { ok: false, error: 'invalid, roster-reserved name or team cap reached' } : { ok: true, name: stored, teams: canvasStore.list() });
|
|
@@ -717,8 +747,15 @@ export function registerAdminFaces(webServer, d) {
|
|
|
717
747
|
payload = JSON.stringify({ ok: false, error: 'name and a member (joined session id, or a zone-qualified remote team handle like zone/a1b2c3d4) are required' });
|
|
718
748
|
}
|
|
719
749
|
else {
|
|
720
|
-
|
|
721
|
-
|
|
750
|
+
const pin = await d.cliHomeForAdd(id, body.home).catch(() => ({ ok: false, error: 'linked home card lookup failed' }));
|
|
751
|
+
if (!pin.ok)
|
|
752
|
+
payload = JSON.stringify({ ok: false, error: pin.error });
|
|
753
|
+
else {
|
|
754
|
+
canvasStore.create(name);
|
|
755
|
+
const explicitHome = body.home !== undefined;
|
|
756
|
+
const home = explicitHome ? pin.home : canvasStore.cliHomeOf(id) ?? pin.home;
|
|
757
|
+
payload = JSON.stringify({ ok: canvasStore.addMember(name, id, home, { replaceHome: explicitHome }), teams: canvasStore.list(), members: canvasStore.membersOf(name) });
|
|
758
|
+
}
|
|
722
759
|
}
|
|
723
760
|
}
|
|
724
761
|
else if (action === 'remove-member') {
|
package/lib/faces/wire.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isRemoteMemberRef, validRemoteMemberRef } from "../canvas-store.js";
|
|
2
|
+
import { CLI_HANDLE_RE } from "../cli-deposit.js";
|
|
2
3
|
import { TRANSCRIPT_DEFAULT_LIMIT, TRANSCRIPT_MAX_LIMIT } from "../session-transcript.js";
|
|
3
4
|
import { refuseIfBudgetExhausted } from "../recursion-guard.js";
|
|
4
5
|
import { peerPayloadFingerprint, WIRE_ERROR_IDEMPOTENCY_CONFLICT, WIRE_ERROR_REPLAY_REJECTED } from "../idempotency-store.js";
|
|
@@ -6,6 +7,7 @@ import { briefOf } from "../task-ledger.js";
|
|
|
6
7
|
import { parseReceipt, taskIdRefusal } from "../receipt.js";
|
|
7
8
|
import { buildAuthorization, claimCovers, refusalOf } from "../task-auth.js";
|
|
8
9
|
import { isRootOriginUrl } from "../origin-claim.js";
|
|
10
|
+
import { withResponseFields } from "../response-fields.js";
|
|
9
11
|
import { WIRE_ERROR_PAYLOAD_TOO_LARGE, withinRouteBodyCap } from "../transport-caps.js";
|
|
10
12
|
/**
|
|
11
13
|
* #139 (design §4.4): add `settlement: {status:'refused', reason, task_id}`
|
|
@@ -15,30 +17,7 @@ import { WIRE_ERROR_PAYLOAD_TOO_LARGE, withinRouteBodyCap } from "../transport-c
|
|
|
15
17
|
* body is sent unchanged.
|
|
16
18
|
*/
|
|
17
19
|
export function withSettlementField(res, settlement) {
|
|
18
|
-
|
|
19
|
-
const end = res.end.bind(res);
|
|
20
|
-
let head;
|
|
21
|
-
res.writeHead = (status, headers) => {
|
|
22
|
-
head = { status, headers: { ...(headers ?? {}) } };
|
|
23
|
-
return res;
|
|
24
|
-
};
|
|
25
|
-
res.end = (body) => {
|
|
26
|
-
let out = body;
|
|
27
|
-
if (typeof body === 'string') {
|
|
28
|
-
try {
|
|
29
|
-
const parsed = JSON.parse(body);
|
|
30
|
-
if (parsed !== null && typeof parsed === 'object' && !Array.isArray(parsed))
|
|
31
|
-
out = JSON.stringify({ ...parsed, settlement });
|
|
32
|
-
}
|
|
33
|
-
catch { /* not JSON: unchanged */ }
|
|
34
|
-
}
|
|
35
|
-
if (head !== undefined) {
|
|
36
|
-
if (out !== undefined && 'Content-Length' in head.headers)
|
|
37
|
-
head.headers['Content-Length'] = Buffer.byteLength(out);
|
|
38
|
-
writeHead(head.status, head.headers);
|
|
39
|
-
}
|
|
40
|
-
return end(out);
|
|
41
|
-
};
|
|
20
|
+
withResponseFields(res, { settlement });
|
|
42
21
|
}
|
|
43
22
|
/** The origin of a card URL for the authorization record; the raw text, bounded, when it does not parse. */
|
|
44
23
|
const originOf = (url) => {
|
|
@@ -74,7 +53,7 @@ export function settlerClaimFields(claim, originOf) {
|
|
|
74
53
|
* @param d - the captures listed on {@link WireDeps}.
|
|
75
54
|
*/
|
|
76
55
|
export function registerWireFaces(webServer, d) {
|
|
77
|
-
const { ctx, logger, config, cliDeposits, canvasStore, canvasNameReserved, sessionNodes, joinedSessions, idempotencyStore, verifyOriginClaim, callerLinkedToThisHost, recordActivity, secretEqual, a2aCallerRefusal, a2aCallerAdmission, allowlistVersionNow, observeAuthorization, scanSessionLogList, readSessionLogTail, taskLedger, refuseIfFlooded, settleAndAnnounce, session, resolveAgentForTeam, parseCanvasTeamName, canvasLiveAgent, wakeColdTeam, probeConsumption, sessionTeamOf, localSessionOfHandle, steerRelay, fromClause, sanitizeFromClause, armReceiptAutosend, eventCountOf, receiptExpectationOf, armAsyncNudge, liveAgent, callerIsAgent, selfRouteText, noWakeFaceText, archivedColdMatchText, noColdMatchText, nativeTeamsPrepare, nativeTeamsRound, routeIntoAgent, } = d;
|
|
56
|
+
const { ctx, logger, config, cliDeposits, canvasStore, canvasNameReserved, sessionNodes, joinedSessions, idempotencyStore, verifyOriginClaim, remoteCliProof, callerLinkedToThisHost, recordActivity, secretEqual, a2aCallerRefusal, a2aCallerAdmission, allowlistVersionNow, observeAuthorization, scanSessionLogList, readSessionLogTail, taskLedger, refuseIfFlooded, refuseIfQueueFull, settleAndAnnounce, session, resolveAgentForTeam, parseCanvasTeamName, canvasLiveAgent, wakeColdTeam, probeConsumption, sessionTeamOf, localSessionOfHandle, steerRelay, fromClause, sanitizeFromClause, armReceiptAutosend, eventCountOf, receiptExpectationOf, armAsyncNudge, liveAgent, callerIsAgent, selfRouteText, noWakeFaceText, archivedColdMatchText, noColdMatchText, nativeTeamsPrepare, nativeTeamsRound, routeIntoAgent, } = d;
|
|
78
57
|
// gh#45 CLI 户口卡面 (peer face, unsigned card serve): the deposited
|
|
79
58
|
// CLI's SIGNED card is served verbatim under its own base URL — an
|
|
80
59
|
// OriginClaim verification of a CLI envelope fetches exactly here
|
|
@@ -168,11 +147,19 @@ export function registerWireFaces(webServer, d) {
|
|
|
168
147
|
// gh#131: a handle is stored as sent, even one of this host's own — the
|
|
169
148
|
// local tiers read it as the session it names at route time.
|
|
170
149
|
const memberValid = isRemoteMemberRef(rawId) ? validRemoteMemberRef(rawId) : rawId !== '' && (sessionNodes.has(rawId) || joinedSessions.has(rawId));
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
150
|
+
if (!canvasStore.hasTeam(name) && canvasNameReserved(name))
|
|
151
|
+
payload = { ok: false, error: 'roster reserves this canvas name' };
|
|
152
|
+
else if (name === '' || !memberValid)
|
|
153
|
+
payload = { ok: false, error: 'name and a member (joined session id, or a zone-qualified remote team handle) are required' };
|
|
154
|
+
else {
|
|
155
|
+
// A peer may compose references, never decide this operator's CLI home pin.
|
|
156
|
+
if (body.home !== undefined)
|
|
157
|
+
payload = { ok: false, error: 'CLI home pins may only be set by this host local control route' };
|
|
158
|
+
else {
|
|
159
|
+
canvasStore.create(name);
|
|
160
|
+
payload = { ok: canvasStore.addMember(name, rawId), members: canvasStore.membersOf(name) };
|
|
161
|
+
}
|
|
162
|
+
}
|
|
176
163
|
}
|
|
177
164
|
else if (op === 'remove-member') {
|
|
178
165
|
// Either shape may be stored (an older edit kept the handle): remove both (review of PR #151 P2-1).
|
|
@@ -484,7 +471,12 @@ export function registerWireFaces(webServer, d) {
|
|
|
484
471
|
// (0.6.15: the rule now lives in a2aCallerRefusal so the
|
|
485
472
|
// read-only /a2a/log face admits callers by exactly the same
|
|
486
473
|
// standard as message delivery.)
|
|
487
|
-
|
|
474
|
+
// F1: only a FOREIGN CLI handle needs a bound host claim and live home card
|
|
475
|
+
// before admission. Every other caller keeps the existing admission-first order.
|
|
476
|
+
const foreignCli = config.teamScopeRouting && CLI_HANDLE_RE.test(caller) && cliDeposits.get(caller) === undefined;
|
|
477
|
+
const earlyClaim = foreignCli ? await verifyOriginClaim(req, { cli: true }) : undefined;
|
|
478
|
+
const cliProof = foreignCli && earlyClaim?.ok ? await remoteCliProof(caller, earlyClaim).catch(() => undefined) : undefined;
|
|
479
|
+
const admission = a2aCallerAdmission(caller, team, cliProof);
|
|
488
480
|
const callerRefusal = refusalOf(admission);
|
|
489
481
|
if (callerRefusal !== undefined || !admission.ok) {
|
|
490
482
|
recordActivity('in', team, caller === '' ? 'anonymous' : caller, false);
|
|
@@ -504,7 +496,7 @@ export function registerWireFaces(webServer, d) {
|
|
|
504
496
|
// after the window closes it rejects like a failed signature —
|
|
505
497
|
// N3 proves a NAME's linkability, never key possession.
|
|
506
498
|
// gh#133: the delivery face is where a deposited CLI identity signs its routes.
|
|
507
|
-
const claim = await verifyOriginClaim(req, { cli: true });
|
|
499
|
+
const claim = earlyClaim ?? await verifyOriginClaim(req, { cli: true });
|
|
508
500
|
if (!claim.ok) {
|
|
509
501
|
if (claim.reason !== 'absent' || config.originClaimWindow === false) {
|
|
510
502
|
recordActivity('in', team, caller, false);
|
|
@@ -518,11 +510,12 @@ export function registerWireFaces(webServer, d) {
|
|
|
518
510
|
// A verified claim proves the caller only when its signed zone covers it (review of PR #134 P1),
|
|
519
511
|
// and the host face only when it was signed from this very host (round 2: a zone name is not an origin).
|
|
520
512
|
const callerProof = !claim.ok ? 'legacy-window'
|
|
521
|
-
:
|
|
522
|
-
: claim.
|
|
523
|
-
:
|
|
524
|
-
:
|
|
525
|
-
:
|
|
513
|
+
: admission.rule === 'remote-ref-cli' ? 'origin-claim'
|
|
514
|
+
: claim.cli === true ? (claimCovers(caller, claim.caller) ? 'cli-identity' : 'claim-mismatch')
|
|
515
|
+
: claim.bound !== true ? 'unbound'
|
|
516
|
+
: !isRootOriginUrl(claim.callerUrl) ? 'claim-mismatch'
|
|
517
|
+
: admission.rule === 'host-face' && originOf(claim.callerUrl) !== originOf(d.ownCardUrl) ? 'claim-mismatch'
|
|
518
|
+
: claimCovers(caller, claim.caller) ? 'origin-claim' : 'claim-mismatch';
|
|
526
519
|
const proofClause = callerProof === 'origin-claim' && claim.ok ? `已验证来源 ${originOf(claim.callerUrl)}`
|
|
527
520
|
: callerProof === 'cli-identity' ? '未验证(cli-identity)' : `未验证(${callerProof})`;
|
|
528
521
|
const directHeader = (from) => `[A2A direct] (task ${taskId}) ${proofClause} ${sanitizeFromClause(from)} (routed to ${team}) sent:`;
|
|
@@ -551,6 +544,8 @@ export function registerWireFaces(webServer, d) {
|
|
|
551
544
|
}
|
|
552
545
|
if (refuseIfFlooded(caller, message, team, taskId, res))
|
|
553
546
|
return;
|
|
547
|
+
if (refuseIfQueueFull(caller, message, team, taskId, cliDeposits.get(team) !== undefined, res))
|
|
548
|
+
return;
|
|
554
549
|
// The caller-side receipt correlation: a message shaped as a
|
|
555
550
|
// receipt resolves the task it echoes, whichever wait semantics
|
|
556
551
|
// carried it here. Correlation is bookkeeping only — the message
|
|
@@ -585,6 +580,17 @@ export function registerWireFaces(webServer, d) {
|
|
|
585
580
|
// Inbound routing is foreground demand: boot prewarm yields for a
|
|
586
581
|
// quiet window around it.
|
|
587
582
|
d.touchWakeDemand();
|
|
583
|
+
const forwardMiss = async (original) => {
|
|
584
|
+
const result = await d.forwardDirect({ team, message, caller, taskId, contextId, noWait,
|
|
585
|
+
localCliProof: claim.ok && claim.cli === true && claim.bound && claim.caller === caller, guarded: req.headers['x-a2a-guard'] !== undefined }).catch((error) => ({ ok: false, error: `forwarding unavailable: ${String(error)}`, code: -32000, task_id: taskId }));
|
|
586
|
+
if (!result.ok && result.code !== -32005)
|
|
587
|
+
idempotencyStore.recordOutcome(taskId, { status: 'failed', error: original + ' — ' + result.error });
|
|
588
|
+
else if (result.ok && result.task_status === 'TASK_STATE_COMPLETED')
|
|
589
|
+
idempotencyStore.recordOutcome(taskId, { status: 'completed', reply: result.reply });
|
|
590
|
+
const payload = JSON.stringify(result.ok ? { routed: true, ...(result.task_status === 'TASK_STATE_DELIVERED' ? { delivered: true } : { result: { text: result.reply } }), team, task_id: taskId, context_id: contextId, task_status: result.task_status, consumed: result.consumed, bridge: result.bridge, receipt: result.receipt, forwarded: true } : { error: original + ' — ' + result.error, code: result.code ?? -32000, receipt: result.receipt, task_id: taskId, team, task_status: result.code === -32005 ? 'TASK_STATE_DELIVERED' : 'TASK_STATE_FAILED' });
|
|
591
|
+
res.writeHead(200, { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(payload) });
|
|
592
|
+
res.end(payload);
|
|
593
|
+
};
|
|
588
594
|
// wait:false delivers without the final-reply hold: steer resolves
|
|
589
595
|
// synchronously inside routeIntoAgentFor, so by the time the agent
|
|
590
596
|
// lookup settles the message is already in — answer delivered and
|
|
@@ -675,6 +681,7 @@ export function registerWireFaces(webServer, d) {
|
|
|
675
681
|
caller,
|
|
676
682
|
proof: callerProof,
|
|
677
683
|
...(claim.ok ? { claim: { caller: claim.caller, origin: originOf(claim.callerUrl) } } : {}),
|
|
684
|
+
...(admission.rule === 'remote-ref-cli' && claim.ok ? { carrierUrl: originOf(claim.callerUrl) } : {}),
|
|
678
685
|
ingress: 'wire',
|
|
679
686
|
allowlistVersion: admittedAt.version,
|
|
680
687
|
target: team,
|
|
@@ -702,6 +709,7 @@ export function registerWireFaces(webServer, d) {
|
|
|
702
709
|
task_status: 'TASK_STATE_DELIVERED',
|
|
703
710
|
artifacts: [],
|
|
704
711
|
consumed: consumedProbe,
|
|
712
|
+
...(req.headers['x-a2a-guard'] !== undefined ? { delivered_to: deliveredTo } : {}),
|
|
705
713
|
receipt: receiptExpectation === 'process-label' || deliveredReceipt ? 'none' : 'routed',
|
|
706
714
|
});
|
|
707
715
|
res.writeHead(200, { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(payload) });
|
|
@@ -739,7 +747,7 @@ export function registerWireFaces(webServer, d) {
|
|
|
739
747
|
// success. Past prepare, the round fires detached (noWait means
|
|
740
748
|
// delivery, not settlement); its late outcome corrects the
|
|
741
749
|
// activity ring and the log.
|
|
742
|
-
const standardMiss = () => {
|
|
750
|
+
const standardMiss = async () => {
|
|
743
751
|
if (team === config.team) {
|
|
744
752
|
const live = liveAgent();
|
|
745
753
|
if (live !== undefined) {
|
|
@@ -755,6 +763,10 @@ export function registerWireFaces(webServer, d) {
|
|
|
755
763
|
return;
|
|
756
764
|
}
|
|
757
765
|
}
|
|
766
|
+
if (wake?.kind === 'no-match') {
|
|
767
|
+
await forwardMiss(noColdMatchText(team));
|
|
768
|
+
return;
|
|
769
|
+
}
|
|
758
770
|
refuseNoWait(wake?.kind === 'no-face' ? noWakeFaceText(team) : wake?.kind === 'archived' ? archivedColdMatchText(team) : noColdMatchText(team), false);
|
|
759
771
|
};
|
|
760
772
|
const prepared = await nativeTeamsPrepare(team);
|
|
@@ -763,7 +775,7 @@ export function registerWireFaces(webServer, d) {
|
|
|
763
775
|
refuseNoWait(prepared.error);
|
|
764
776
|
return;
|
|
765
777
|
}
|
|
766
|
-
standardMiss();
|
|
778
|
+
await standardMiss();
|
|
767
779
|
return;
|
|
768
780
|
}
|
|
769
781
|
recordActivity('in', team, caller, true);
|
|
@@ -791,7 +803,11 @@ export function registerWireFaces(webServer, d) {
|
|
|
791
803
|
})();
|
|
792
804
|
return;
|
|
793
805
|
}
|
|
794
|
-
void routeIntoAgent(team, message, caller, taskId, proofClause, directHeader).then((outcome) => {
|
|
806
|
+
void routeIntoAgent(team, message, caller, taskId, proofClause, directHeader).then(async (outcome) => {
|
|
807
|
+
if (!outcome.ok && outcome.localMiss) {
|
|
808
|
+
await forwardMiss(outcome.error);
|
|
809
|
+
return;
|
|
810
|
+
}
|
|
795
811
|
recordActivity('in', team, caller, outcome.ok);
|
|
796
812
|
// W7 slice-2 hook 1: record the settled outcome on the claim row.
|
|
797
813
|
// Ruling: a non-COMPLETED status (TASK_STATE_DELIVERED — the
|
|
@@ -818,6 +834,7 @@ export function registerWireFaces(webServer, d) {
|
|
|
818
834
|
team,
|
|
819
835
|
session,
|
|
820
836
|
result: { text: outcome.reply },
|
|
837
|
+
...(req.headers['x-a2a-guard'] !== undefined ? ((target) => target === undefined ? {} : { delivered_to: sessionTeamOf(target) })(resolveAgentForTeam(team) ?? canvasLiveAgent(parseCanvasTeamName(team))) : {}),
|
|
821
838
|
task_id: taskId,
|
|
822
839
|
context_id: contextId,
|
|
823
840
|
task_status: outcome.status ?? 'TASK_STATE_COMPLETED',
|
package/lib/flood-guard.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { withResponseFields } from "./response-fields.js";
|
|
2
|
+
export const FILE_CHANNEL_ADVICE = { reason: 'use-file-channel', message: 'Files must use the file channel, not session messages: a2a_file_send { paths, team }; CLI: a2a-net file send <path…> <team>.' };
|
|
3
|
+
export const fileChannelAdvice = (message) => message.includes('[JPFILE-PART') ? FILE_CHANNEL_ADVICE : undefined;
|
|
1
4
|
export const WIRE_ERROR_RATE_LIMITED = -32008;
|
|
2
5
|
export const MAX_PARTS_PER_TRANSFER = 16;
|
|
3
6
|
// Matches the current L9 threshold; per-sender across ALL targets is stricter.
|
|
@@ -92,10 +95,13 @@ export class FloodGuard {
|
|
|
92
95
|
export function createFloodGuard(outcomes, recordActivity) {
|
|
93
96
|
const guard = new FloodGuard();
|
|
94
97
|
return (caller, message, team, taskId, res) => {
|
|
98
|
+
const advice = fileChannelAdvice(message);
|
|
99
|
+
if (advice !== undefined)
|
|
100
|
+
withResponseFields(res, { advice });
|
|
95
101
|
const reason = guard.check(caller, message);
|
|
96
102
|
if (reason === undefined)
|
|
97
103
|
return false;
|
|
98
|
-
const error = 'flood-guard: ' + reason + ' (gh#91): file data must use an independent channel; no delivery occurred';
|
|
104
|
+
const error = 'flood-guard: ' + reason + ' (gh#91): file data must use an independent channel; no delivery occurred' + (advice === undefined ? '' : '; use-file-channel: ' + advice.message);
|
|
99
105
|
outcomes.recordOutcome(taskId, { status: 'failed', error });
|
|
100
106
|
recordActivity('in', team, caller, false);
|
|
101
107
|
const payload = JSON.stringify({ error, reason, code: WIRE_ERROR_RATE_LIMITED, task_id: taskId, team, delivered: false, task_status: 'TASK_STATE_FAILED' });
|