friend-assistant 0.1.91 → 0.1.93

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/BUILD.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "friend-assistant",
3
- "version": "0.1.91",
4
- "builtAt": "2026-11-25T03:25:16.324Z"
3
+ "version": "0.1.93",
4
+ "builtAt": "2026-11-26T15:33:00.535Z"
5
5
  }
package/dist/friend.mjs CHANGED
@@ -1441,8 +1441,8 @@ var TOOL_DEFS = [
1441
1441
  },
1442
1442
  {
1443
1443
  name: "view.set",
1444
- description: "Change what the owner's screen shows besides your pictures: minimal (only the voice presence), companion (plus a status line and a clock) or workspace (plus the chat and the schedule panels). Use it when the owner asks for a cleaner or fuller screen.",
1445
- input: z5.object({ view: ViewPreset }),
1444
+ description: "Change what the owner's screen shows besides your pictures: minimal (only the voice presence), companion (plus a status line and a clock) or workspace (plus the chat and the schedule panels). Use it when the owner asks for a cleaner or fuller screen. layout switches the whole screen between classic (the corner widgets and panels) and orbital (the round HUD with nodes around the presence): use it when the owner asks to change the layout, the look of the home screen, or to go back to the old one. Give view, layout, or both.",
1445
+ input: z5.object({ view: ViewPreset.optional(), layout: z5.enum(["classic", "orbital"]).optional() }).refine((a) => a.view !== void 0 || a.layout !== void 0, { message: "Give a view, a layout, or both." }),
1446
1446
  baseTier: "T1",
1447
1447
  target: "gateway"
1448
1448
  },
@@ -2003,7 +2003,7 @@ ${visible(clip(String(a.text ?? ""), 600))}`;
2003
2003
  case "look.set":
2004
2004
  return `Change the look: ${visible(clip(JSON.stringify(a), 300))}`;
2005
2005
  case "view.set":
2006
- return `Change the view to ${visible(String(a.view ?? ""))}`;
2006
+ return a.layout ? `Change the screen layout to ${visible(String(a.layout))}` : `Change the view to ${visible(String(a.view ?? ""))}`;
2007
2007
  case "connectors.list":
2008
2008
  return "List the connectors";
2009
2009
  case "connectors.add": {
@@ -3779,7 +3779,7 @@ var LAYOUT_GUIDE = `Screen layout (follow this when you decide where things go)
3779
3779
  - Check your work. After you draw more than one object, or a Jarvis drawing, call stage.check once. It reports in words what overlaps, is cut off, is empty, or is too crowded or has no focus; fix exactly what it names (move, resize or redraw it) and stop. Do not call it again and again, and do not describe the check to the owner.
3780
3780
  - Temporary and pinned. What you show for a task is temporary: when the task is done and the owner has what they need, take it off the screen (stage.hide for one, stage.clear for all) so the screen goes back to how the owner keeps it. Pinned widgets are the owner's: they stay across refreshes, logins and restarts, in the place the owner dragged them to, and stage.clear leaves them alone. Pin something with stage.pin only when the owner asks for it to stay, or when you offer and they agree (for example a clock, a to-do list, a status gauge). Never hide, move or unpin a pinned widget unless the owner asks. To change what a pinned widget shows, stage.update it by its id.
3781
3781
  - Pick the object by the data: one number gauge or stat, a few numbers side by side stat, a trend chart, items with details table, a to-do or schedule list or timeline, relationships graph, a short note card, anything else a sandbox page. Keep text short; the pictures carry the answer and your voice adds one or two sentences.
3782
- - The owner can open a chat panel (right edge) and a schedule panel (upper left); the request's screen description lists them when open. Keep your pictures out of their way and do not repeat what they already show. The owner arranges the corner widgets and panels themselves; never try to move them. Change what the screen shows with view.set only when the owner asks for a cleaner or fuller screen.
3782
+ - The owner can open a chat panel (right edge) and a schedule panel (upper left); the request's screen description lists them when open. Keep your pictures out of their way and do not repeat what they already show. The owner arranges the corner widgets and panels themselves; never try to move them. Change what the screen shows with view.set only when the owner asks for a cleaner or fuller screen. When the owner asks to change the layout of the whole screen (the round orbital HUD or the classic corner-widget screen, "the old layout", "switch the layout"), call view.set with layout orbital or classic: that is allowed and takes effect at once. Moving or resizing single widgets is still the owner's: say so and offer the layout switch or a new composition instead.
3783
3783
  - The look of the voice presence (style, colour, brightness, size) belongs to the owner. If stage.presence or stage.mood say the look is fixed, accept it. Use look.set only when the owner asks you to change it.
3784
3784
  - The theme is a HUD, like the screens in science-fiction films: a near-black blue background, translucent glass panels with thin glowing edges, one bright accent colour, small upper-case letter-spaced labels, and monospace for numbers and code. Nothing is white, nothing is solid or rounded and cheerful. The colours are: accent (the current one is in each request as accent=#rrggbb; default cyan #3fd8ff), ink #d4ecf7 for text, muted #7fa3b6 for labels, ok #5ef0b0 for good, warn #ffb454 for caution, bad #ff6b7a for errors, background #050b10, glass rgba(6,20,28,0.62). Use warn and bad only for real warnings. Do not invent other colours, and never put dark text on a dark background. In a sandbox page do not write colours at all: use var(--accent), var(--ink), var(--muted), var(--ok), var(--warn), var(--bad), var(--glass), var(--edge), var(--ui) and var(--mono); they follow the owner's theme and accent exactly. Draw with thin lines (1px), a soft glow (box-shadow or drop-shadow of var(--accent)) and transparent backgrounds.
3785
3785
  - What is already on the screen decides how you show something new. A short explanation or quick answer while something is showing: role note (it moves nothing). Something IMPORTANT or urgent (an error, a warning, something the owner must act on): role alert, shown alone. A new topic: mode replace. More of the same topic: mode add, or update the objects you have. Call stage.guide (topics widgets, layout, overlay, theme, files, recipes) for the full manual before building a screen you have not built before.
@@ -5788,7 +5788,7 @@ ${r.stderr}` : ""}`);
5788
5788
  if (call.name === "settings.get" || call.name === "settings.set" || call.name === "view.set" || call.name === "look.set") {
5789
5789
  if (!d.settings) return fail3("Settings are not available.");
5790
5790
  try {
5791
- const text6 = call.name === "settings.get" ? JSON.stringify(d.settings.get()) : call.name === "view.set" ? d.settings.setView(args.view) : call.name === "look.set" ? d.settings.setLook(args) : await d.settings.set(args.settings);
5791
+ const text6 = call.name === "settings.get" ? JSON.stringify(d.settings.get()) : call.name === "view.set" ? [args.layout ? d.settings.setLayout ? d.settings.setLayout(args.layout) : "The layout cannot be changed here." : "", args.view ? d.settings.setView(args.view) : ""].filter(Boolean).join(" ") : call.name === "look.set" ? d.settings.setLook(args) : await d.settings.set(args.settings);
5792
5792
  d.audit.log("agent", "tool.call", { tool: call.name, args: call.name === "settings.set" ? { fields: Object.keys(args.settings ?? {}) } : clipArgs(args), tier, ok: true });
5793
5793
  return { text: text6, isError: false };
5794
5794
  } catch (e) {
@@ -23281,7 +23281,16 @@ function applySettings(config, raw) {
23281
23281
  if (p.ollama) Object.assign(config.ollama, p.ollama);
23282
23282
  if (p.openai) {
23283
23283
  const { apiKey, ...rest } = p.openai;
23284
+ const sameHost = (a, b) => {
23285
+ try {
23286
+ return new URL(a).origin === new URL(b).origin;
23287
+ } catch {
23288
+ return false;
23289
+ }
23290
+ };
23291
+ const moved = rest.url !== void 0 && !sameHost(rest.url, config.openai.url);
23284
23292
  Object.assign(config.openai, rest);
23293
+ if (moved) config.openai.apiKey = null;
23285
23294
  if (apiKey) config.openai.apiKey = apiKey;
23286
23295
  }
23287
23296
  if (p.claudeCode) Object.assign(config.claudeCode, p.claudeCode);
@@ -23985,7 +23994,7 @@ function currentSelf() {
23985
23994
  // ../server/src/system/npm.ts
23986
23995
  import { spawn as spawn10 } from "node:child_process";
23987
23996
  var PACKAGE = "friend-assistant";
23988
- var runningVersion = () => true ? "0.1.91" : "development";
23997
+ var runningVersion = () => true ? "0.1.93" : "development";
23989
23998
  async function npmLatest(fetchFn = fetch, timeoutMs = 1e4) {
23990
23999
  try {
23991
24000
  const res = await fetchFn(`https://registry.npmjs.org/${PACKAGE}/latest`, { headers: { accept: "application/json" }, signal: AbortSignal.timeout(timeoutMs) });
@@ -25314,6 +25323,10 @@ async function createApp(opts) {
25314
25323
  commitSettings({ view }, { actor: "agent" });
25315
25324
  return `The view is now ${view}.`;
25316
25325
  },
25326
+ setLayout: (layout) => {
25327
+ commitSettings({ hud: { layout } }, { actor: "agent" });
25328
+ return `The screen layout is now ${layout}.`;
25329
+ },
25317
25330
  setLook: (look2) => {
25318
25331
  commitSettings({ look: look2 }, { actor: "agent" });
25319
25332
  return "The look is updated and saved.";
@@ -25544,6 +25557,17 @@ First check the work: read the whole report (office.report) and, when it changed
25544
25557
  const broadcast = (m) => {
25545
25558
  for (const c of clients) c.send(m);
25546
25559
  };
25560
+ const cameraDenials = /* @__PURE__ */ new Map();
25561
+ const screenDenials = /* @__PURE__ */ new Map();
25562
+ const allDenied = (seen, id2, conn) => {
25563
+ const who = seen.get(id2) ?? /* @__PURE__ */ new Set();
25564
+ who.add(conn);
25565
+ seen.set(id2, who);
25566
+ while (seen.size > 20) seen.delete(seen.keys().next().value);
25567
+ for (const c of clients) if (!who.has(c)) return false;
25568
+ seen.delete(id2);
25569
+ return true;
25570
+ };
25547
25571
  broadcastLate = broadcast;
25548
25572
  hostEmit = (state) => broadcast({ type: "music.host", state });
25549
25573
  const alexaHub = new AlexaHub({
@@ -26608,6 +26632,7 @@ ${url}`);
26608
26632
  break;
26609
26633
  }
26610
26634
  case "camera.denied":
26635
+ if (!allDenied(cameraDenials, msg.id, conn)) break;
26611
26636
  if (camera.deny(msg.id, msg.reason)) {
26612
26637
  audit.log("owner", "camera.denied", { reason: msg.reason });
26613
26638
  broadcast({ type: "camera.cancel", id: msg.id });
@@ -26617,6 +26642,7 @@ ${url}`);
26617
26642
  screenCheck.reply(msg.id, msg.lines);
26618
26643
  break;
26619
26644
  case "screen.denied":
26645
+ if (!allDenied(screenDenials, msg.id, conn)) break;
26620
26646
  if (screenShot.deny(msg.id, msg.reason)) {
26621
26647
  audit.log("owner", "screen.denied", { reason: msg.reason });
26622
26648
  broadcast({ type: "screen.cancel", id: msg.id });
@@ -29650,7 +29676,7 @@ import { appendFileSync } from "node:fs";
29650
29676
  import { join as join42 } from "node:path";
29651
29677
  var PACKAGE2 = "friend-assistant";
29652
29678
  var real2 = {
29653
- current: () => true ? "0.1.91" : "development",
29679
+ current: () => true ? "0.1.93" : "development",
29654
29680
  latest: () => new Promise((resolve13) => {
29655
29681
  const child = crossSpawn5("npm", ["view", PACKAGE2, "version", "--prefer-online"], { stdio: ["ignore", "pipe", "ignore"] });
29656
29682
  let out = "";
@@ -29968,7 +29994,7 @@ async function run(argv, io2) {
29968
29994
  case "version":
29969
29995
  case "--version":
29970
29996
  case "-v":
29971
- io2.out(true ? "0.1.91" : "development");
29997
+ io2.out(true ? "0.1.93" : "development");
29972
29998
  return 0;
29973
29999
  case "lan":
29974
30000
  return await lanCommand(rest, io2);
@@ -1 +1 @@
1
- import{i as e,l as t,o as n,t as r}from"./index-L9B7BU-1.js";import{a as i,n as a,r as o,t as s}from"./jarvis-ui-CvToZv-V.js";var c=t(n(),1),l=350,u=174,d=.25,f=2.5,p=96;function m(e){let t=r(e),n=e=>Math.round(e.y/134),i=e=>({x:n(e)===0?0:260+(n(e)-1)*l,y:Math.round(e.x/216*u)}),a=t.nodes.map(e=>({id:e.id,worker:e.worker,w:e.worker?240:150,...i(e)})),o=new Map(a.map(e=>[e.id,e])),s=t.edges.map(e=>{let t=o.get(e.from),n=o.get(e.to);return{from:e.from,to:e.to,x1:t.x+t.w,y1:t.y+70,x2:n.x,y2:n.y+70}}),c=Math.min(...a.map(e=>e.y));for(let e of a)e.y-=c;for(let e of s)e.y1-=c,e.y2-=c;return{nodes:a,edges:s,width:Math.max(...a.map(e=>e.x+e.w)),height:Math.max(...a.map(e=>e.y))+140}}var h=e=>Math.min(f,Math.max(d,e));function g(e,t){let n=h(Math.min((t.width-56)/e.width,(t.height-56)/e.height,1.25));return{k:n,x:(t.width-e.width*n)/2,y:(t.height-e.height*n)/2}}function _(e,t,n){let r=h(e.k*n),i=r/e.k;return{k:r,x:t.x-(t.x-e.x)*i,y:t.y-(t.y-e.y)*i}}function v(e,t,n){let r=t.width*e.k,i=t.height*e.k,a=Math.min(p,r),o=Math.min(p,i);return{k:e.k,x:Math.min(n.width-a,Math.max(a-r,e.x)),y:Math.min(n.height-o,Math.max(o-i,e.y))}}var y=e(),b={starting:`green`,running:`green`,waiting:`amber`,idle:`cyan`,paused:`ghost`,stopped:`ghost`,failed:`red`},x={starting:`active`,running:`active`,waiting:`warning`,idle:`success`,paused:`warning`,stopped:`warning`,failed:`error`},S={starting:`running`,running:`running`,waiting:`waiting`,idle:`idle`,paused:`idle`,stopped:`idle`,failed:`failed`},C=e=>e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e),w=1.25;function T({workers:e,name:t,onWorker:n}){let r=(0,c.useRef)(null),l=(0,c.useMemo)(()=>m(e),[e]),u=(0,c.useMemo)(()=>({width:l.width,height:l.height}),[l.width,l.height]),[d,f]=(0,c.useState)({width:640,height:420}),[p,h]=(0,c.useState)(()=>g(u,d)),T=(0,c.useRef)(!1),E=(0,c.useRef)(!1),D=(0,c.useRef)(null),O=new Map(e.map(e=>[e.id,e.status])),k=(0,c.useCallback)(e=>h(v(e,u,d)),[u,d]),A=(0,c.useCallback)(()=>{T.current=!1,h(g(u,d))},[u,d]);(0,c.useEffect)(()=>{let e=r.current;if(!e)return;let t=()=>{let t=e.getBoundingClientRect();t.width>40&&t.height>40&&f({width:Math.floor(t.width),height:Math.floor(t.height)})};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]),(0,c.useEffect)(()=>{T.current||h(g(u,d))},[u,d]),(0,c.useEffect)(()=>{let e=r.current;if(!e)return;let t=t=>{t.preventDefault();let n=e.getBoundingClientRect();T.current=!0,h(e=>v(_(e,{x:t.clientX-n.left,y:t.clientY-n.top},Math.exp(-t.deltaY*.0015)),u,d))};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[u,d]);let j={x:d.width/2,y:d.height/2},M=e=>{T.current=!0,k(_(p,j,e))};return(0,y.jsxs)(`div`,{className:`ob-canvas-room`,ref:r,children:[(0,y.jsx)(`div`,{className:`ob-canvas-pan`,onPointerDown:e=>{e.button===0&&(E.current=!1,D.current={x:e.clientX,y:e.clientY,vx:p.x,vy:p.y,id:e.pointerId,far:!1})},onPointerMove:e=>{let t=D.current;if(!t)return;let n=e.clientX-t.x,r=e.clientY-t.y;!t.far&&Math.hypot(n,r)<5||(t.far||e.currentTarget.setPointerCapture?.(t.id),t.far=!0,E.current=!0,T.current=!0,k({k:p.k,x:t.vx+n,y:t.vy+r}))},onPointerUp:e=>{D.current=null,e.currentTarget.releasePointerCapture?.(e.pointerId)},onPointerCancel:()=>D.current=null,children:(0,y.jsxs)(`div`,{className:`ob-canvas-world`,style:{width:l.width,height:l.height,transform:`translate(${p.x}px, ${p.y}px) scale(${p.k})`},children:[(0,y.jsxs)(`svg`,{className:`ob-canvas-edges`,width:l.width,height:l.height,"aria-hidden":`true`,children:[(0,y.jsx)(`defs`,{children:(0,y.jsx)(`marker`,{id:`ob-arrow`,viewBox:`0 0 10 10`,refX:`9`,refY:`5`,markerWidth:`7`,markerHeight:`7`,orient:`auto-start-reverse`,children:(0,y.jsx)(`path`,{d:`M0 0L10 5L0 10z`,className:`ob-arrow`})})}),l.edges.map(e=>{let t=O.get(e.to),n=(e.x1+e.x2)/2;return(0,y.jsx)(`path`,{d:`M${e.x1} ${e.y1}C${n} ${e.y1} ${n} ${e.y2} ${e.x2} ${e.y2}`,markerEnd:`url(#ob-arrow)`,"data-flow":t===`running`||t===`starting`?`on`:t===`waiting`?`wait`:`off`},`${e.from}>${e.to}`)})]}),l.nodes.map(e=>{let r=e.worker;if(!r)return(0,y.jsxs)(`div`,{className:`ob-cnode ob-cnode-root`,"data-node":`friend`,style:{left:e.x,top:e.y,width:e.w,height:140},children:[(0,y.jsx)(a,{size:92,color:`cyan`,label:t.toUpperCase(),animated:!0}),(0,y.jsx)(`small`,{children:`the assistant`})]},e.id);let c=r.budget&&r.budget>0?Math.min(100,100*r.tokens/r.budget):void 0;return(0,y.jsx)(`div`,{className:`ob-cnode`,role:`button`,tabIndex:0,"data-node":e.id,"data-status":S[r.status],"aria-label":`${r.name}, ${r.title}, ${r.detail||r.status}`,style:{left:e.x,top:e.y,width:240,height:140},onClick:()=>{E.current?E.current=!1:n(e.id)},onKeyDown:t=>(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),n(e.id)),children:(0,y.jsxs)(s,{cardStyle:`SideRail`,color:b[r.status],padding:`8px 12px`,header:(0,y.jsxs)(`div`,{className:`ob-cnode-head`,children:[(0,y.jsx)(`b`,{children:r.name}),(0,y.jsx)(i,{state:x[r.status],children:r.status.toUpperCase()})]}),children:[(0,y.jsx)(o,{label:`JOB`,value:r.title}),(0,y.jsx)(o,{label:`DOING`,value:r.detail||r.status}),(0,y.jsx)(o,{label:`TOKENS`,value:C(r.tokens),...c===void 0?{}:{barPercent:c}})]})},e.id)})]})}),(0,y.jsxs)(`div`,{className:`ob-canvas-tools`,role:`toolbar`,"aria-label":`View of the team`,children:[(0,y.jsx)(`button`,{type:`button`,"aria-label":`Zoom in`,onClick:()=>M(w),children:`+`}),(0,y.jsx)(`button`,{type:`button`,"aria-label":`Zoom out`,onClick:()=>M(1/w),children:`−`}),(0,y.jsx)(`button`,{type:`button`,"aria-label":`Fit the team`,onClick:A,children:`⤢`}),(0,y.jsxs)(`span`,{"aria-hidden":`true`,children:[Math.round(p.k*100),`%`]})]})]})}export{T as OrgCanvas};
1
+ import{i as e,l as t,o as n,t as r}from"./index-DL_4YDP5.js";import{a as i,n as a,r as o,t as s}from"./jarvis-ui-Csg1Py5-.js";var c=t(n(),1),l=350,u=174,d=.25,f=2.5,p=96;function m(e){let t=r(e),n=e=>Math.round(e.y/134),i=e=>({x:n(e)===0?0:260+(n(e)-1)*l,y:Math.round(e.x/216*u)}),a=t.nodes.map(e=>({id:e.id,worker:e.worker,w:e.worker?240:150,...i(e)})),o=new Map(a.map(e=>[e.id,e])),s=t.edges.map(e=>{let t=o.get(e.from),n=o.get(e.to);return{from:e.from,to:e.to,x1:t.x+t.w,y1:t.y+70,x2:n.x,y2:n.y+70}}),c=Math.min(...a.map(e=>e.y));for(let e of a)e.y-=c;for(let e of s)e.y1-=c,e.y2-=c;return{nodes:a,edges:s,width:Math.max(...a.map(e=>e.x+e.w)),height:Math.max(...a.map(e=>e.y))+140}}var h=e=>Math.min(f,Math.max(d,e));function g(e,t){let n=h(Math.min((t.width-56)/e.width,(t.height-56)/e.height,1.25));return{k:n,x:(t.width-e.width*n)/2,y:(t.height-e.height*n)/2}}function _(e,t,n){let r=h(e.k*n),i=r/e.k;return{k:r,x:t.x-(t.x-e.x)*i,y:t.y-(t.y-e.y)*i}}function v(e,t,n){let r=t.width*e.k,i=t.height*e.k,a=Math.min(p,r),o=Math.min(p,i);return{k:e.k,x:Math.min(n.width-a,Math.max(a-r,e.x)),y:Math.min(n.height-o,Math.max(o-i,e.y))}}var y=e(),b={starting:`green`,running:`green`,waiting:`amber`,idle:`cyan`,paused:`ghost`,stopped:`ghost`,failed:`red`},x={starting:`active`,running:`active`,waiting:`warning`,idle:`success`,paused:`warning`,stopped:`warning`,failed:`error`},S={starting:`running`,running:`running`,waiting:`waiting`,idle:`idle`,paused:`idle`,stopped:`idle`,failed:`failed`},C=e=>e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e),w=1.25;function T({workers:e,name:t,onWorker:n}){let r=(0,c.useRef)(null),l=(0,c.useMemo)(()=>m(e),[e]),u=(0,c.useMemo)(()=>({width:l.width,height:l.height}),[l.width,l.height]),[d,f]=(0,c.useState)({width:640,height:420}),[p,h]=(0,c.useState)(()=>g(u,d)),T=(0,c.useRef)(!1),E=(0,c.useRef)(!1),D=(0,c.useRef)(null),O=new Map(e.map(e=>[e.id,e.status])),k=(0,c.useCallback)(e=>h(v(e,u,d)),[u,d]),A=(0,c.useCallback)(()=>{T.current=!1,h(g(u,d))},[u,d]);(0,c.useEffect)(()=>{let e=r.current;if(!e)return;let t=()=>{let t=e.getBoundingClientRect();t.width>40&&t.height>40&&f({width:Math.floor(t.width),height:Math.floor(t.height)})};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]),(0,c.useEffect)(()=>{T.current||h(g(u,d))},[u,d]),(0,c.useEffect)(()=>{let e=r.current;if(!e)return;let t=t=>{t.preventDefault();let n=e.getBoundingClientRect();T.current=!0,h(e=>v(_(e,{x:t.clientX-n.left,y:t.clientY-n.top},Math.exp(-t.deltaY*.0015)),u,d))};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[u,d]);let j={x:d.width/2,y:d.height/2},M=e=>{T.current=!0,k(_(p,j,e))};return(0,y.jsxs)(`div`,{className:`ob-canvas-room`,ref:r,children:[(0,y.jsx)(`div`,{className:`ob-canvas-pan`,onPointerDown:e=>{e.button===0&&(E.current=!1,D.current={x:e.clientX,y:e.clientY,vx:p.x,vy:p.y,id:e.pointerId,far:!1})},onPointerMove:e=>{let t=D.current;if(!t)return;let n=e.clientX-t.x,r=e.clientY-t.y;!t.far&&Math.hypot(n,r)<5||(t.far||e.currentTarget.setPointerCapture?.(t.id),t.far=!0,E.current=!0,T.current=!0,k({k:p.k,x:t.vx+n,y:t.vy+r}))},onPointerUp:e=>{D.current=null,e.currentTarget.releasePointerCapture?.(e.pointerId)},onPointerCancel:()=>D.current=null,children:(0,y.jsxs)(`div`,{className:`ob-canvas-world`,style:{width:l.width,height:l.height,transform:`translate(${p.x}px, ${p.y}px) scale(${p.k})`},children:[(0,y.jsxs)(`svg`,{className:`ob-canvas-edges`,width:l.width,height:l.height,"aria-hidden":`true`,children:[(0,y.jsx)(`defs`,{children:(0,y.jsx)(`marker`,{id:`ob-arrow`,viewBox:`0 0 10 10`,refX:`9`,refY:`5`,markerWidth:`7`,markerHeight:`7`,orient:`auto-start-reverse`,children:(0,y.jsx)(`path`,{d:`M0 0L10 5L0 10z`,className:`ob-arrow`})})}),l.edges.map(e=>{let t=O.get(e.to),n=(e.x1+e.x2)/2;return(0,y.jsx)(`path`,{d:`M${e.x1} ${e.y1}C${n} ${e.y1} ${n} ${e.y2} ${e.x2} ${e.y2}`,markerEnd:`url(#ob-arrow)`,"data-flow":t===`running`||t===`starting`?`on`:t===`waiting`?`wait`:`off`},`${e.from}>${e.to}`)})]}),l.nodes.map(e=>{let r=e.worker;if(!r)return(0,y.jsxs)(`div`,{className:`ob-cnode ob-cnode-root`,"data-node":`friend`,style:{left:e.x,top:e.y,width:e.w,height:140},children:[(0,y.jsx)(a,{size:92,color:`cyan`,label:t.toUpperCase(),animated:!0}),(0,y.jsx)(`small`,{children:`the assistant`})]},e.id);let c=r.budget&&r.budget>0?Math.min(100,100*r.tokens/r.budget):void 0;return(0,y.jsx)(`div`,{className:`ob-cnode`,role:`button`,tabIndex:0,"data-node":e.id,"data-status":S[r.status],"aria-label":`${r.name}, ${r.title}, ${r.detail||r.status}`,style:{left:e.x,top:e.y,width:240,height:140},onClick:()=>{E.current?E.current=!1:n(e.id)},onKeyDown:t=>(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),n(e.id)),children:(0,y.jsxs)(s,{cardStyle:`SideRail`,color:b[r.status],padding:`8px 12px`,header:(0,y.jsxs)(`div`,{className:`ob-cnode-head`,children:[(0,y.jsx)(`b`,{children:r.name}),(0,y.jsx)(i,{state:x[r.status],children:r.status.toUpperCase()})]}),children:[(0,y.jsx)(o,{label:`JOB`,value:r.title}),(0,y.jsx)(o,{label:`DOING`,value:r.detail||r.status}),(0,y.jsx)(o,{label:`TOKENS`,value:C(r.tokens),...c===void 0?{}:{barPercent:c}})]})},e.id)})]})}),(0,y.jsxs)(`div`,{className:`ob-canvas-tools`,role:`toolbar`,"aria-label":`View of the team`,children:[(0,y.jsx)(`button`,{type:`button`,"aria-label":`Zoom in`,onClick:()=>M(w),children:`+`}),(0,y.jsx)(`button`,{type:`button`,"aria-label":`Zoom out`,onClick:()=>M(1/w),children:`−`}),(0,y.jsx)(`button`,{type:`button`,"aria-label":`Fit the team`,onClick:A,children:`⤢`}),(0,y.jsxs)(`span`,{"aria-hidden":`true`,children:[Math.round(p.k*100),`%`]})]})]})}export{T as OrgCanvas};