@agimon-ai/po-session 0.0.0-alpha.181 → 0.0.0-alpha.183

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.
@@ -1,7 +1,7 @@
1
- import { defineFill, defineHostStore, defineNativePlugin, defineWebLifecycle } from "@agimon-ai/po-core/native";
1
+ import { defineFill, defineHostStore, defineNativePlugin, defineToolRenderer, defineWebLifecycle } from "@agimon-ai/po-core/native";
2
2
  import { View } from "react-native-unistyles/components/native/View";
3
3
  import { Text } from "react-native-unistyles/components/native/Text";
4
- import { Button, Dot, Input, ListRow, SheetBody, SheetDescription, SheetFooter, fontOf } from "@agimon-ai/po-native-components";
4
+ import { Button, Dot, Input, ListRow, MessageItem, MessageItemBody, MessageItemHeader, MessageItemStatus, SheetBody, SheetDescription, SheetFooter, fontOf, resultTextLines, toolTone } from "@agimon-ai/po-native-components";
5
5
  import { useEffect, useMemo, useRef, useState } from "react";
6
6
  import { StyleSheet } from "react-native-unistyles";
7
7
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
@@ -167,11 +167,11 @@ function SendToSessionView({ sessions, to, busy, error, onPick, onSend }) {
167
167
  /* @__PURE__ */ jsx(SheetDescription, { children: "Send what you typed to another session. It arrives there from you." }),
168
168
  error === "" ? null : /* @__PURE__ */ jsx(Text, {
169
169
  accessibilityRole: "alert",
170
- style: styles.alert,
170
+ style: styles$1.alert,
171
171
  children: error
172
172
  }),
173
173
  sessions.length === 0 ? /* @__PURE__ */ jsx(Text, {
174
- style: styles.empty,
174
+ style: styles$1.empty,
175
175
  children: "No other session is running. Open one, then send."
176
176
  }) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Input, {
177
177
  accessibilityLabel: "Filter sessions",
@@ -179,17 +179,17 @@ function SendToSessionView({ sessions, to, busy, error, onPick, onSend }) {
179
179
  value: filter,
180
180
  onChangeText: setFilter
181
181
  }), shown.length === 0 ? /* @__PURE__ */ jsx(Text, {
182
- style: styles.empty,
182
+ style: styles$1.empty,
183
183
  children: "Nothing matches that filter"
184
184
  }) : /* @__PURE__ */ jsx(View, {
185
- style: styles.rows,
186
- children: shown.map((session, index) => /* @__PURE__ */ jsxs(View, { children: [index > 0 ? /* @__PURE__ */ jsx(View, { style: styles.separator }) : null, /* @__PURE__ */ jsx(ListRow, {
185
+ style: styles$1.rows,
186
+ children: shown.map((session, index) => /* @__PURE__ */ jsxs(View, { children: [index > 0 ? /* @__PURE__ */ jsx(View, { style: styles$1.separator }) : null, /* @__PURE__ */ jsx(ListRow, {
187
187
  accessibilityLabel: `${session.name}, ${session.detail}`,
188
188
  selected: session.id === to,
189
189
  disabled: busy,
190
190
  onPress: () => onPick(session.id),
191
191
  disclosure: false,
192
- style: styles.row,
192
+ style: styles$1.row,
193
193
  leading: /* @__PURE__ */ jsx(Dot, {
194
194
  tone: TONE[session.state],
195
195
  size: "md"
@@ -197,7 +197,7 @@ function SendToSessionView({ sessions, to, busy, error, onPick, onSend }) {
197
197
  title: session.name,
198
198
  description: /* @__PURE__ */ jsx(Text, {
199
199
  numberOfLines: 1,
200
- style: styles.detail,
200
+ style: styles$1.detail,
201
201
  children: session.detail
202
202
  })
203
203
  })] }, session.id))
@@ -209,7 +209,7 @@ function SendToSessionView({ sessions, to, busy, error, onPick, onSend }) {
209
209
  children: busy ? "Sending…" : target === void 0 ? "Pick a session" : `Send to ${target.name}`
210
210
  }) })] });
211
211
  }
212
- const styles = StyleSheet.create((theme) => {
212
+ const styles$1 = StyleSheet.create((theme) => {
213
213
  const small = {
214
214
  fontFamily: fontOf(theme.fontFamily.sans),
215
215
  fontSize: theme.fontSize.sm,
@@ -264,6 +264,108 @@ var SendToSession_composer_menu_native_default = defineFill({
264
264
  //#region src/extensions/workspaces/sessions/(frontend)/lifecycle/start.native.ts
265
265
  var start_native_default = defineWebLifecycle(startSendToSessionRuntime);
266
266
  //#endregion
267
+ //#region src/extensions/workspaces/sessions/(frontend)/tool/_lib/networkActivity.ts
268
+ const ACTIVITY_CHARS = 72;
269
+ function asString(value) {
270
+ return typeof value === "string" ? value : "";
271
+ }
272
+ function clip(text) {
273
+ const flat = text.replace(/\s+/g, " ").trim();
274
+ return flat.length > ACTIVITY_CHARS ? `${flat.slice(0, 71)}…` : flat;
275
+ }
276
+ /** Who a message is for, or what it answers. */
277
+ function networkSummary(toolName, args) {
278
+ const verb = toolName.split(".").at(-1) ?? toolName;
279
+ return toolName === "network.reply" ? "reply" : `${verb} ${asString(args.to)}`.trim();
280
+ }
281
+ /** One line per outgoing session message: who it went to and what it said. */
282
+ function networkActivity({ toolName, args, isError }) {
283
+ const text = clip(asString(args.text));
284
+ if (isError || !text) return [];
285
+ if (toolName === "network.reply") return [`Replied "${text}"`];
286
+ return [`→ ${asString(args.to) || "session"}${toolName === "network.ask" ? " asks" : ""} "${text}"`];
287
+ }
288
+ //#endregion
289
+ //#region src/extensions/workspaces/sessions/(frontend)/tool/_components/NetworkToolMessage.native.tsx
290
+ /** A network.send, network.ask or network.reply recorded inside an exec. Collapsed to its summary; the body is the result text. */
291
+ function NetworkToolMessage({ args, result, output, running, isError, toolName }) {
292
+ const lines = resultTextLines(result, output);
293
+ return /* @__PURE__ */ jsx(MessageItem, {
294
+ tone: toolTone({
295
+ running,
296
+ isError
297
+ }),
298
+ expandable: lines.length > 0,
299
+ children: ({ expanded }) => /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(MessageItemHeader, {
300
+ title: "network",
301
+ children: /* @__PURE__ */ jsx(View, {
302
+ testID: "tool-call-network",
303
+ style: styles.summary,
304
+ children: /* @__PURE__ */ jsx(Text, {
305
+ numberOfLines: 1,
306
+ style: styles.primary,
307
+ children: networkSummary(toolName, args)
308
+ })
309
+ })
310
+ }), expanded ? /* @__PURE__ */ jsxs(MessageItemBody, {
311
+ testID: "tool-result-network",
312
+ style: styles.body,
313
+ children: [running ? /* @__PURE__ */ jsx(MessageItemStatus, {
314
+ tone: "running",
315
+ children: "working"
316
+ }) : null, lines.map((line, index) => /* @__PURE__ */ jsx(Text, {
317
+ selectable: true,
318
+ style: isError ? styles.error : styles.dim,
319
+ children: line
320
+ }, `${String(index)}-${line}`))]
321
+ }) : null] })
322
+ });
323
+ }
324
+ const styles = StyleSheet.create((theme) => ({
325
+ summary: {
326
+ flex: 1,
327
+ flexDirection: "row",
328
+ alignItems: "center",
329
+ minWidth: 0
330
+ },
331
+ primary: {
332
+ flexShrink: 1,
333
+ minWidth: 0,
334
+ color: theme.colors.text,
335
+ fontFamily: fontOf(theme.fontFamily.sans),
336
+ fontSize: theme.fontSize.base,
337
+ uni__dependencies: [0]
338
+ },
339
+ body: {
340
+ gap: theme.spacing(1),
341
+ uni__dependencies: [0]
342
+ },
343
+ dim: {
344
+ color: theme.colors.dim,
345
+ fontFamily: fontOf(theme.fontFamily.sans),
346
+ fontSize: theme.fontSize.base,
347
+ uni__dependencies: [0]
348
+ },
349
+ error: {
350
+ color: theme.colors.red,
351
+ fontFamily: fontOf(theme.fontFamily.sans),
352
+ fontSize: theme.fontSize.base,
353
+ uni__dependencies: [0]
354
+ }
355
+ }));
356
+ //#endregion
357
+ //#region src/extensions/workspaces/sessions/(frontend)/tool/network.native.tsx
358
+ /** The network namespace's recorded calls. Named by hand: the dotted tool names are not a filename. */
359
+ var network_native_default = defineToolRenderer({
360
+ tools: [
361
+ "network.send",
362
+ "network.ask",
363
+ "network.reply"
364
+ ],
365
+ message: NetworkToolMessage,
366
+ activity: networkActivity
367
+ });
368
+ //#endregion
267
369
  //#region generated/native.ts
268
370
  const via = (identity, value) => value === void 0 ? void 0 : {
269
371
  ...identity,
@@ -281,6 +383,9 @@ const nativePlugin = defineNativePlugin({
281
383
  },
282
384
  get start() {
283
385
  return start_native_default;
386
+ },
387
+ get toolRenderers() {
388
+ return [via({ tools: ["network"] }, network_native_default)];
284
389
  }
285
390
  }
286
391
  });
@@ -1 +1 @@
1
- {"version":3,"file":"native.mjs","names":["WebPluginSessionOption","WebPluginSlotProps","Button","Dot","fontOf","Input","ListRow","SheetBody","SheetDescription","SheetFooter","useEffect","useMemo","useRef","useState","StyleSheet","sendToSession","TONE","running","waiting","idle","const","SendToSessionPanel","sessionId","listSessions","takeComposerDraft","appendComposerDraft","sessions","to","setTo","busy","setBusy","error","setError","held","text","inFlight","live","giveBack","current","state","undefined","send","Promise","trim","refusal","from","SendToSessionViewProps","onPick","id","onSend","SendToSessionView","filter","setFilter","shown","query","toLowerCase","session","name","detail","includes","target","find","styles","alert","length","empty","rows","map","index","separator","row","create","theme","small","fontFamily","sans","fontSize","sm","lineHeight","borderTopWidth","hairlineWidth","borderBottomWidth","borderColor","colors","uni__dependencies","paddingHorizontal","spacing","height","backgroundColor","color","dim","paddingVertical","textAlign","red","fillSendToSession","lifecycleStart"],"sources":["../../src/extensions/workspaces/sessions/(frontend)/_lib/sendToSessionDelivery.ts","../../src/extensions/workspaces/sessions/(frontend)/_lib/sendToSessionRequest.native.ts","../../src/extensions/workspaces/sessions/(frontend)/fill/_components/SendToSessionPanel.native.tsx","../../src/extensions/workspaces/sessions/(frontend)/fill/SendToSession.composer-menu.native.tsx","../../src/extensions/workspaces/sessions/(frontend)/lifecycle/start.native.ts","../../generated/native.ts"],"sourcesContent":["import type { WebPluginRuntime } from '@agimon-ai/po-core/web';\n\n/**\n * Delivers one send through the started runtime that owns the sending session.\n *\n * DESIGN PATTERNS:\n * - Host-neutral and stateless: the web and native request files each keep\n * their own runtime list (from their own po-core entry) and pass it in.\n * The phone starts one runtime per computer; a send goes through the one\n * that owns the sending session, with that computer's local ids.\n *\n * AVOID:\n * - Value imports from a po-core entry here. Native plugins may not import\n * `po-core/web`, and web plugins may not import `po-core/native`.\n */\n\n/** The runtime that owns `from`, with both ids as its computer knows them; undefined when none does. */\nfunction route(runtimes: readonly WebPluginRuntime[], input: { from: string; to: string }) {\n const owners = runtimes.flatMap((runtime) => {\n try {\n const from = runtime.localSessionId?.(input.from) ?? input.from;\n const to = runtime.localSessionId?.(input.to) ?? input.to;\n // An unqualified id belongs to the computer that would leave it unqualified (the local hub).\n const owns = from !== input.from || (runtime.qualifySessionId?.(input.from) ?? input.from) === input.from;\n return owns ? [{ runtime, from, to }] : [];\n } catch {\n // localSessionId refuses an id of another computer: this runtime does not own the send.\n return [];\n }\n });\n return owners.at(-1);\n}\n\n/** Steers `text` into session `to`. Resolves to the reason shown when it was refused, or undefined once delivered. */\nexport async function deliverToSession(\n runtimes: readonly WebPluginRuntime[],\n input: { from: string; to: string; text: string },\n): Promise<string | undefined> {\n const owner = route(runtimes, input);\n if (!owner) return 'Po is not connected. Your text is kept; try again.';\n try {\n await owner.runtime.invokeServerMethod({\n mount: { scope: 'host' },\n service: 'sessions',\n method: 'sendToSession',\n input: { from: owner.from, to: owner.to, text: input.text },\n });\n return undefined;\n } catch (error) {\n return error instanceof Error && error.message !== '' ? error.message : 'The message was not delivered.';\n }\n}\n","import { defineHostStore, type WebPluginRuntime } from '@agimon-ai/po-core/native';\n\nimport { deliverToSession } from './sendToSessionDelivery';\n\n/**\n * The phone's started runtimes, one per computer, for the send-to-session panel.\n *\n * DESIGN PATTERNS:\n * - The native twin of sendToSessionRequest.ts: a native plugin may import\n * po-core/native only. The phone has no menu-to-overlay handoff, so only the\n * runtime list and the send live here.\n */\n\nconst runtimes = defineHostStore<readonly WebPluginRuntime[]>([]);\n\nexport function startSendToSessionRuntime(runtime: WebPluginRuntime): () => void {\n runtimes.update((current) => [...current, runtime]);\n return () => runtimes.update((current) => current.filter((entry) => entry !== runtime));\n}\n\n/** Steers `text` into session `to`. Resolves to the reason shown when it was refused, or undefined once delivered. */\nexport function sendToSession(input: { from: string; to: string; text: string }): Promise<string | undefined> {\n return deliverToSession(runtimes.store.state, input);\n}\n","import type { WebPluginSessionOption, WebPluginSlotProps } from '@agimon-ai/po-core/native';\nimport {\n Button,\n Dot,\n fontOf,\n Input,\n ListRow,\n SheetBody,\n SheetDescription,\n SheetFooter,\n} from '@agimon-ai/po-native-components';\nimport { useEffect, useMemo, useRef, useState } from 'react';\nimport { Text, View } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nimport { sendToSession } from '../../_lib/sendToSessionRequest.native';\n\n/**\n * The phone's \"Send to session…\" page of the composer's Insert sheet: pick a\n * live session, then Send steers what the person typed into it.\n *\n * DESIGN PATTERNS:\n * - The draft is taken only at Send, so opening and leaving the page never\n * touches it. A refused send keeps the taken text for a retry and hands it\n * back to the composer when the page goes away.\n * - The sheet closes when the page appends to the draft; an empty append\n * closes it and leaves the draft alone.\n *\n * AVOID:\n * - Sending on a row tap. On a phone a mis-tap would send; Send is its own button.\n */\n\nconst TONE = { running: 'green', waiting: 'magenta', idle: 'neutral' } as const;\n\n/** The Insert sheet page: lists the computer's live sessions and steers the composer's text into one. */\nexport function SendToSessionPanel({\n sessionId,\n listSessions,\n takeComposerDraft,\n appendComposerDraft,\n}: WebPluginSlotProps) {\n const [sessions] = useState(() => listSessions?.() ?? []);\n const [to, setTo] = useState<string>();\n const [busy, setBusy] = useState(false);\n const [error, setError] = useState('');\n // Text taken from the composer and not yet delivered; `live` is false once the page is gone.\n const held = useRef<{ text?: string; inFlight: boolean; live: boolean }>({ inFlight: false, live: true });\n const giveBack = useRef(appendComposerDraft);\n useEffect(() => {\n giveBack.current = appendComposerDraft;\n }, [appendComposerDraft]);\n useEffect(() => {\n const state = held.current;\n state.live = true;\n return () => {\n state.live = false;\n if (state.text !== undefined && !state.inFlight) giveBack.current(state.text);\n };\n }, []);\n\n const send = async (): Promise<void> => {\n if (to === undefined || sessionId === null) return;\n const state = held.current;\n const text = state.text ?? takeComposerDraft?.() ?? '';\n if (text.trim() === '') {\n setError('Write something to send.');\n return;\n }\n state.text = text;\n state.inFlight = true;\n setBusy(true);\n setError('');\n const refusal = await sendToSession({ from: sessionId, to, text: text.trim() });\n state.inFlight = false;\n if (refusal === undefined) state.text = undefined;\n if (!state.live) {\n if (state.text !== undefined) giveBack.current(state.text);\n return;\n }\n if (refusal === undefined) {\n giveBack.current('');\n return;\n }\n setBusy(false);\n setError(refusal);\n };\n\n return (\n <SendToSessionView\n sessions={sessions}\n to={to}\n busy={busy}\n error={error}\n onPick={setTo}\n onSend={() => void send()}\n />\n );\n}\n\nexport interface SendToSessionViewProps {\n sessions: readonly WebPluginSessionOption[];\n to: string | undefined;\n busy: boolean;\n /** The server's refusal, shown above the list; empty when there is none. */\n error: string;\n onPick: (id: string) => void;\n onSend: () => void;\n}\n\nexport function SendToSessionView({ sessions, to, busy, error, onPick, onSend }: SendToSessionViewProps) {\n const [filter, setFilter] = useState('');\n const shown = useMemo(() => {\n const query = filter.trim().toLowerCase();\n return query === ''\n ? sessions\n : sessions.filter((session) => `${session.name} ${session.detail}`.toLowerCase().includes(query));\n }, [filter, sessions]);\n const target = sessions.find((session) => session.id === to);\n\n return (\n <>\n <SheetBody>\n <SheetDescription>Send what you typed to another session. It arrives there from you.</SheetDescription>\n {error === '' ? null : (\n <Text accessibilityRole=\"alert\" style={styles.alert}>\n {error}\n </Text>\n )}\n {sessions.length === 0 ? (\n <Text style={styles.empty}>No other session is running. Open one, then send.</Text>\n ) : (\n <>\n <Input\n accessibilityLabel=\"Filter sessions\"\n placeholder=\"Filter sessions\"\n value={filter}\n onChangeText={setFilter}\n />\n {shown.length === 0 ? (\n <Text style={styles.empty}>Nothing matches that filter</Text>\n ) : (\n <View style={styles.rows}>\n {shown.map((session, index) => (\n <View key={session.id}>\n {index > 0 ? <View style={styles.separator} /> : null}\n <ListRow\n accessibilityLabel={`${session.name}, ${session.detail}`}\n selected={session.id === to}\n disabled={busy}\n onPress={() => onPick(session.id)}\n disclosure={false}\n style={styles.row}\n leading={<Dot tone={TONE[session.state]} size=\"md\" />}\n title={session.name}\n description={\n <Text numberOfLines={1} style={styles.detail}>\n {session.detail}\n </Text>\n }\n />\n </View>\n ))}\n </View>\n )}\n </>\n )}\n </SheetBody>\n <SheetFooter>\n <Button variant=\"primary\" disabled={busy || target === undefined} onPress={onSend}>\n {busy ? 'Sending…' : target === undefined ? 'Pick a session' : `Send to ${target.name}`}\n </Button>\n </SheetFooter>\n </>\n );\n}\n\nconst styles = StyleSheet.create((theme) => {\n const small = {\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeight.sm,\n };\n return {\n rows: {\n borderTopWidth: StyleSheet.hairlineWidth,\n borderBottomWidth: StyleSheet.hairlineWidth,\n borderColor: theme.colors['border-soft'],\n },\n row: { paddingHorizontal: theme.spacing(1) },\n separator: { height: StyleSheet.hairlineWidth, backgroundColor: theme.colors['border-soft'] },\n detail: { ...small, color: theme.colors.dim },\n empty: { ...small, paddingVertical: theme.spacing(6), textAlign: 'center', color: theme.colors.dim },\n alert: { ...small, color: theme.colors.red },\n };\n});\n","import { defineFill } from '@agimon-ai/po-core/native';\n\nimport { SendToSessionPanel } from './_components/SendToSessionPanel.native';\n\n/** The phone's Insert sheet draws `data` as the row and `component` as the page it opens. */\nexport default defineFill({\n data: { title: 'Send to session…', hint: 'Steer another session with what you typed' },\n component: SendToSessionPanel,\n});\n","import { defineWebLifecycle } from '@agimon-ai/po-core/native';\n\nimport { startSendToSessionRuntime } from '../_lib/sendToSessionRequest.native';\n\nexport default defineWebLifecycle(startSendToSessionRuntime);\n","// Generated by @agimon-ai/po-build. Do not edit by hand.\nimport { defineNativePlugin, type WebPluginContributions } from '@agimon-ai/po-core/native';\n\nimport fillSendToSession from '../src/extensions/workspaces/sessions/(frontend)/fill/SendToSession.composer-menu.native';\nimport lifecycleStart from '../src/extensions/workspaces/sessions/(frontend)/lifecycle/start.native';\n\nconst via = <T>(identity: Record<string, unknown>, value: unknown): T =>\n (value === undefined ? undefined : { ...identity, ...(value as object) }) as T;\n\nexport const nativePlugin = defineNativePlugin({\n id: 'sessions',\n packageName: '@agimon-ai/po-session',\n session: {\n get fills(): WebPluginContributions['fills'] { return [via({ slot: 'composer-menu', id: 'send-to-session' }, fillSendToSession)]; },\n get start(): WebPluginContributions['start'] { return lifecycleStart; },\n },\n});\n"],"mappings":";;;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1B,QAAQ;GAAE,GAAGe;GAAOgB,OAAOjB,MAAMW,OAAOO;GAAGN,mBAAA,CAAA,CAAA;EAAC;EAC5CnB,OAAO;GAAE,GAAGQ;GAAOkB,iBAAiBnB,MAAMc,QAAQ,CAAC;GAAGM,WAAW;GAAUH,OAAOjB,MAAMW,OAAOO;GAAGN,mBAAA,CAAA,CAAA;EAAC;EACnGrB,OAAO;GAAE,GAAGU;GAAOgB,OAAOjB,MAAMW,OAAOU;GAAGT,mBAAA,CAAA,CAAA;EAAC;CAC7C;AACF,CAAC;;;;AC7LD,IAAA,6CAAe,WAAW;CACxB,MAAM;EAAE,OAAO;EAAoB,MAAM;CAA4C;CACrF,WAAW;AACb,CAAC;;;ACJD,IAAA,uBAAe,mBAAmB,yBAAyB;;;ACE3D,MAAM,OAAU,UAAmC,UAChD,UAAU,KAAA,IAAY,KAAA,IAAY;CAAE,GAAG;CAAU,GAAI;AAAiB;AAEzE,MAAa,eAAe,mBAAmB;CAC7C,IAAI;CACJ,aAAa;CACb,SAAS;EACP,IAAI,QAAyC;GAAE,OAAO,CAAC,IAAI;IAAE,MAAM;IAAiB,IAAI;GAAkB,GAAGU,0CAAiB,CAAC;EAAG;EAClI,IAAI,QAAyC;GAAE,OAAOC;EAAgB;CACxE;AACF,CAAC"}
1
+ {"version":3,"file":"native.mjs","names":["WebPluginSessionOption","WebPluginSlotProps","Button","Dot","fontOf","Input","ListRow","SheetBody","SheetDescription","SheetFooter","useEffect","useMemo","useRef","useState","StyleSheet","sendToSession","TONE","running","waiting","idle","const","SendToSessionPanel","sessionId","listSessions","takeComposerDraft","appendComposerDraft","sessions","to","setTo","busy","setBusy","error","setError","held","text","inFlight","live","giveBack","current","state","undefined","send","Promise","trim","refusal","from","SendToSessionViewProps","onPick","id","onSend","SendToSessionView","filter","setFilter","shown","query","toLowerCase","session","name","detail","includes","target","find","styles","alert","length","empty","rows","map","index","separator","row","create","theme","small","fontFamily","sans","fontSize","sm","lineHeight","borderTopWidth","hairlineWidth","borderBottomWidth","borderColor","colors","uni__dependencies","paddingHorizontal","spacing","height","backgroundColor","color","dim","paddingVertical","textAlign","red","styles","ToolMessageRenderProps","fontOf","MessageItem","MessageItemBody","MessageItemHeader","MessageItemStatus","resultTextLines","toolTone","PoNativeTheme","StyleSheet","networkSummary","NetworkToolMessage","args","result","output","running","isError","toolName","lines","length","expanded","styles","summary","primary","body","map","line","index","String","error","dim","create","theme","flex","flexDirection","alignItems","minWidth","flexShrink","color","colors","text","fontFamily","sans","fontSize","base","uni__dependencies","gap","spacing","red","fillSendToSession","lifecycleStart","toolNetwork"],"sources":["../../src/extensions/workspaces/sessions/(frontend)/_lib/sendToSessionDelivery.ts","../../src/extensions/workspaces/sessions/(frontend)/_lib/sendToSessionRequest.native.ts","../../src/extensions/workspaces/sessions/(frontend)/fill/_components/SendToSessionPanel.native.tsx","../../src/extensions/workspaces/sessions/(frontend)/fill/SendToSession.composer-menu.native.tsx","../../src/extensions/workspaces/sessions/(frontend)/lifecycle/start.native.ts","../../src/extensions/workspaces/sessions/(frontend)/tool/_lib/networkActivity.ts","../../src/extensions/workspaces/sessions/(frontend)/tool/_components/NetworkToolMessage.native.tsx","../../src/extensions/workspaces/sessions/(frontend)/tool/network.native.tsx","../../generated/native.ts"],"sourcesContent":["import type { WebPluginRuntime } from '@agimon-ai/po-core/web';\n\n/**\n * Delivers one send through the started runtime that owns the sending session.\n *\n * DESIGN PATTERNS:\n * - Host-neutral and stateless: the web and native request files each keep\n * their own runtime list (from their own po-core entry) and pass it in.\n * The phone starts one runtime per computer; a send goes through the one\n * that owns the sending session, with that computer's local ids.\n *\n * AVOID:\n * - Value imports from a po-core entry here. Native plugins may not import\n * `po-core/web`, and web plugins may not import `po-core/native`.\n */\n\n/** The runtime that owns `from`, with both ids as its computer knows them; undefined when none does. */\nfunction route(runtimes: readonly WebPluginRuntime[], input: { from: string; to: string }) {\n const owners = runtimes.flatMap((runtime) => {\n try {\n const from = runtime.localSessionId?.(input.from) ?? input.from;\n const to = runtime.localSessionId?.(input.to) ?? input.to;\n // An unqualified id belongs to the computer that would leave it unqualified (the local hub).\n const owns = from !== input.from || (runtime.qualifySessionId?.(input.from) ?? input.from) === input.from;\n return owns ? [{ runtime, from, to }] : [];\n } catch {\n // localSessionId refuses an id of another computer: this runtime does not own the send.\n return [];\n }\n });\n return owners.at(-1);\n}\n\n/** Steers `text` into session `to`. Resolves to the reason shown when it was refused, or undefined once delivered. */\nexport async function deliverToSession(\n runtimes: readonly WebPluginRuntime[],\n input: { from: string; to: string; text: string },\n): Promise<string | undefined> {\n const owner = route(runtimes, input);\n if (!owner) return 'Po is not connected. Your text is kept; try again.';\n try {\n await owner.runtime.invokeServerMethod({\n mount: { scope: 'host' },\n service: 'sessions',\n method: 'sendToSession',\n input: { from: owner.from, to: owner.to, text: input.text },\n });\n return undefined;\n } catch (error) {\n return error instanceof Error && error.message !== '' ? error.message : 'The message was not delivered.';\n }\n}\n","import { defineHostStore, type WebPluginRuntime } from '@agimon-ai/po-core/native';\n\nimport { deliverToSession } from './sendToSessionDelivery';\n\n/**\n * The phone's started runtimes, one per computer, for the send-to-session panel.\n *\n * DESIGN PATTERNS:\n * - The native twin of sendToSessionRequest.ts: a native plugin may import\n * po-core/native only. The phone has no menu-to-overlay handoff, so only the\n * runtime list and the send live here.\n */\n\nconst runtimes = defineHostStore<readonly WebPluginRuntime[]>([]);\n\nexport function startSendToSessionRuntime(runtime: WebPluginRuntime): () => void {\n runtimes.update((current) => [...current, runtime]);\n return () => runtimes.update((current) => current.filter((entry) => entry !== runtime));\n}\n\n/** Steers `text` into session `to`. Resolves to the reason shown when it was refused, or undefined once delivered. */\nexport function sendToSession(input: { from: string; to: string; text: string }): Promise<string | undefined> {\n return deliverToSession(runtimes.store.state, input);\n}\n","import type { WebPluginSessionOption, WebPluginSlotProps } from '@agimon-ai/po-core/native';\nimport {\n Button,\n Dot,\n fontOf,\n Input,\n ListRow,\n SheetBody,\n SheetDescription,\n SheetFooter,\n} from '@agimon-ai/po-native-components';\nimport { useEffect, useMemo, useRef, useState } from 'react';\nimport { Text, View } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nimport { sendToSession } from '../../_lib/sendToSessionRequest.native';\n\n/**\n * The phone's \"Send to session…\" page of the composer's Insert sheet: pick a\n * live session, then Send steers what the person typed into it.\n *\n * DESIGN PATTERNS:\n * - The draft is taken only at Send, so opening and leaving the page never\n * touches it. A refused send keeps the taken text for a retry and hands it\n * back to the composer when the page goes away.\n * - The sheet closes when the page appends to the draft; an empty append\n * closes it and leaves the draft alone.\n *\n * AVOID:\n * - Sending on a row tap. On a phone a mis-tap would send; Send is its own button.\n */\n\nconst TONE = { running: 'green', waiting: 'magenta', idle: 'neutral' } as const;\n\n/** The Insert sheet page: lists the computer's live sessions and steers the composer's text into one. */\nexport function SendToSessionPanel({\n sessionId,\n listSessions,\n takeComposerDraft,\n appendComposerDraft,\n}: WebPluginSlotProps) {\n const [sessions] = useState(() => listSessions?.() ?? []);\n const [to, setTo] = useState<string>();\n const [busy, setBusy] = useState(false);\n const [error, setError] = useState('');\n // Text taken from the composer and not yet delivered; `live` is false once the page is gone.\n const held = useRef<{ text?: string; inFlight: boolean; live: boolean }>({ inFlight: false, live: true });\n const giveBack = useRef(appendComposerDraft);\n useEffect(() => {\n giveBack.current = appendComposerDraft;\n }, [appendComposerDraft]);\n useEffect(() => {\n const state = held.current;\n state.live = true;\n return () => {\n state.live = false;\n if (state.text !== undefined && !state.inFlight) giveBack.current(state.text);\n };\n }, []);\n\n const send = async (): Promise<void> => {\n if (to === undefined || sessionId === null) return;\n const state = held.current;\n const text = state.text ?? takeComposerDraft?.() ?? '';\n if (text.trim() === '') {\n setError('Write something to send.');\n return;\n }\n state.text = text;\n state.inFlight = true;\n setBusy(true);\n setError('');\n const refusal = await sendToSession({ from: sessionId, to, text: text.trim() });\n state.inFlight = false;\n if (refusal === undefined) state.text = undefined;\n if (!state.live) {\n if (state.text !== undefined) giveBack.current(state.text);\n return;\n }\n if (refusal === undefined) {\n giveBack.current('');\n return;\n }\n setBusy(false);\n setError(refusal);\n };\n\n return (\n <SendToSessionView\n sessions={sessions}\n to={to}\n busy={busy}\n error={error}\n onPick={setTo}\n onSend={() => void send()}\n />\n );\n}\n\nexport interface SendToSessionViewProps {\n sessions: readonly WebPluginSessionOption[];\n to: string | undefined;\n busy: boolean;\n /** The server's refusal, shown above the list; empty when there is none. */\n error: string;\n onPick: (id: string) => void;\n onSend: () => void;\n}\n\nexport function SendToSessionView({ sessions, to, busy, error, onPick, onSend }: SendToSessionViewProps) {\n const [filter, setFilter] = useState('');\n const shown = useMemo(() => {\n const query = filter.trim().toLowerCase();\n return query === ''\n ? sessions\n : sessions.filter((session) => `${session.name} ${session.detail}`.toLowerCase().includes(query));\n }, [filter, sessions]);\n const target = sessions.find((session) => session.id === to);\n\n return (\n <>\n <SheetBody>\n <SheetDescription>Send what you typed to another session. It arrives there from you.</SheetDescription>\n {error === '' ? null : (\n <Text accessibilityRole=\"alert\" style={styles.alert}>\n {error}\n </Text>\n )}\n {sessions.length === 0 ? (\n <Text style={styles.empty}>No other session is running. Open one, then send.</Text>\n ) : (\n <>\n <Input\n accessibilityLabel=\"Filter sessions\"\n placeholder=\"Filter sessions\"\n value={filter}\n onChangeText={setFilter}\n />\n {shown.length === 0 ? (\n <Text style={styles.empty}>Nothing matches that filter</Text>\n ) : (\n <View style={styles.rows}>\n {shown.map((session, index) => (\n <View key={session.id}>\n {index > 0 ? <View style={styles.separator} /> : null}\n <ListRow\n accessibilityLabel={`${session.name}, ${session.detail}`}\n selected={session.id === to}\n disabled={busy}\n onPress={() => onPick(session.id)}\n disclosure={false}\n style={styles.row}\n leading={<Dot tone={TONE[session.state]} size=\"md\" />}\n title={session.name}\n description={\n <Text numberOfLines={1} style={styles.detail}>\n {session.detail}\n </Text>\n }\n />\n </View>\n ))}\n </View>\n )}\n </>\n )}\n </SheetBody>\n <SheetFooter>\n <Button variant=\"primary\" disabled={busy || target === undefined} onPress={onSend}>\n {busy ? 'Sending…' : target === undefined ? 'Pick a session' : `Send to ${target.name}`}\n </Button>\n </SheetFooter>\n </>\n );\n}\n\nconst styles = StyleSheet.create((theme) => {\n const small = {\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeight.sm,\n };\n return {\n rows: {\n borderTopWidth: StyleSheet.hairlineWidth,\n borderBottomWidth: StyleSheet.hairlineWidth,\n borderColor: theme.colors['border-soft'],\n },\n row: { paddingHorizontal: theme.spacing(1) },\n separator: { height: StyleSheet.hairlineWidth, backgroundColor: theme.colors['border-soft'] },\n detail: { ...small, color: theme.colors.dim },\n empty: { ...small, paddingVertical: theme.spacing(6), textAlign: 'center', color: theme.colors.dim },\n alert: { ...small, color: theme.colors.red },\n };\n});\n","import { defineFill } from '@agimon-ai/po-core/native';\n\nimport { SendToSessionPanel } from './_components/SendToSessionPanel.native';\n\n/** The phone's Insert sheet draws `data` as the row and `component` as the page it opens. */\nexport default defineFill({\n data: { title: 'Send to session…', hint: 'Steer another session with what you typed' },\n component: SendToSessionPanel,\n});\n","import { defineWebLifecycle } from '@agimon-ai/po-core/native';\n\nimport { startSendToSessionRuntime } from '../_lib/sendToSessionRequest.native';\n\nexport default defineWebLifecycle(startSendToSessionRuntime);\n","import type { ToolMessageRenderProps } from '@agimon-ai/po-core/web';\n\nconst ACTIVITY_CHARS = 72;\n\nfunction asString(value: unknown): string {\n return typeof value === 'string' ? value : '';\n}\n\nfunction clip(text: string): string {\n const flat = text.replace(/\\s+/g, ' ').trim();\n return flat.length > ACTIVITY_CHARS ? `${flat.slice(0, ACTIVITY_CHARS - 1)}…` : flat;\n}\n\n/** Who a message is for, or what it answers. */\nexport function networkSummary(toolName: string, args: Record<string, unknown>): string {\n const verb = toolName.split('.').at(-1) ?? toolName;\n return toolName === 'network.reply' ? 'reply' : `${verb} ${asString(args.to)}`.trim();\n}\n\n/** One line per outgoing session message: who it went to and what it said. */\nexport function networkActivity({\n toolName,\n args,\n isError,\n}: Pick<ToolMessageRenderProps, 'toolName' | 'args' | 'isError'>): string[] {\n const text = clip(asString(args.text));\n if (isError || !text) return [];\n if (toolName === 'network.reply') return [`Replied \"${text}\"`];\n const to = asString(args.to) || 'session';\n return [`→ ${to}${toolName === 'network.ask' ? ' asks' : ''} \"${text}\"`];\n}\n","import type { ToolMessageRenderProps } from '@agimon-ai/po-core/native';\nimport {\n fontOf,\n MessageItem,\n MessageItemBody,\n MessageItemHeader,\n MessageItemStatus,\n resultTextLines,\n toolTone,\n} from '@agimon-ai/po-native-components';\nimport type { PoNativeTheme } from '@agimon-ai/po-web-components/nativeTheme';\nimport { Text, View } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nimport { networkSummary } from '../_lib/networkActivity';\n\n/** A network.send, network.ask or network.reply recorded inside an exec. Collapsed to its summary; the body is the result text. */\nexport function NetworkToolMessage({ args, result, output, running, isError, toolName }: ToolMessageRenderProps) {\n const lines = resultTextLines(result, output);\n return (\n <MessageItem tone={toolTone({ running, isError })} expandable={lines.length > 0}>\n {({ expanded }) => (\n <>\n <MessageItemHeader title=\"network\">\n <View testID=\"tool-call-network\" style={styles.summary}>\n <Text numberOfLines={1} style={styles.primary}>\n {networkSummary(toolName, args)}\n </Text>\n </View>\n </MessageItemHeader>\n {expanded ? (\n <MessageItemBody testID=\"tool-result-network\" style={styles.body}>\n {running ? <MessageItemStatus tone=\"running\">working</MessageItemStatus> : null}\n {lines.map((line, index) => (\n <Text key={`${String(index)}-${line}`} selectable style={isError ? styles.error : styles.dim}>\n {line}\n </Text>\n ))}\n </MessageItemBody>\n ) : null}\n </>\n )}\n </MessageItem>\n );\n}\n\nconst styles = StyleSheet.create((theme: PoNativeTheme) => ({\n summary: { flex: 1, flexDirection: 'row', alignItems: 'center', minWidth: 0 },\n primary: {\n flexShrink: 1,\n minWidth: 0,\n color: theme.colors.text,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.base,\n },\n body: { gap: theme.spacing(1) },\n dim: { color: theme.colors.dim, fontFamily: fontOf(theme.fontFamily.sans), fontSize: theme.fontSize.base },\n error: { color: theme.colors.red, fontFamily: fontOf(theme.fontFamily.sans), fontSize: theme.fontSize.base },\n}));\n","import { defineToolRenderer } from '@agimon-ai/po-core/native';\n\nimport { NetworkToolMessage } from './_components/NetworkToolMessage.native';\nimport { networkActivity } from './_lib/networkActivity';\n\n/** The network namespace's recorded calls. Named by hand: the dotted tool names are not a filename. */\nexport default defineToolRenderer({\n tools: ['network.send', 'network.ask', 'network.reply'],\n message: NetworkToolMessage,\n activity: networkActivity,\n});\n","// Generated by @agimon-ai/po-build. Do not edit by hand.\nimport { defineNativePlugin, type WebPluginContributions } from '@agimon-ai/po-core/native';\n\nimport fillSendToSession from '../src/extensions/workspaces/sessions/(frontend)/fill/SendToSession.composer-menu.native';\nimport lifecycleStart from '../src/extensions/workspaces/sessions/(frontend)/lifecycle/start.native';\nimport toolNetwork from '../src/extensions/workspaces/sessions/(frontend)/tool/network.native';\n\nconst via = <T>(identity: Record<string, unknown>, value: unknown): T =>\n (value === undefined ? undefined : { ...identity, ...(value as object) }) as T;\n\nexport const nativePlugin = defineNativePlugin({\n id: 'sessions',\n packageName: '@agimon-ai/po-session',\n session: {\n get fills(): WebPluginContributions['fills'] { return [via({ slot: 'composer-menu', id: 'send-to-session' }, fillSendToSession)]; },\n get start(): WebPluginContributions['start'] { return lifecycleStart; },\n get toolRenderers(): WebPluginContributions['toolRenderers'] { return [via({ tools: ['network'] }, toolNetwork)]; },\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAiBA,SAAS,MAAM,UAAuC,OAAqC;CAazF,OAZe,SAAS,SAAS,YAAY;EAC3C,IAAI;GACF,MAAM,OAAO,QAAQ,iBAAiB,MAAM,IAAI,KAAK,MAAM;GAC3D,MAAM,KAAK,QAAQ,iBAAiB,MAAM,EAAE,KAAK,MAAM;GAGvD,OADa,SAAS,MAAM,SAAS,QAAQ,mBAAmB,MAAM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ASC;EAAIC,mBAAA,CAAA,CAAA;CAAC;AAC7G,EAAE;;;;ACpDF,IAAA,yBAAe,mBAAmB;CAChC,OAAO;EAAC;EAAgB;EAAe;CAAe;CACtD,SAAS;CACT,UAAU;AACZ,CAAC;;;ACHD,MAAM,OAAU,UAAmC,UAChD,UAAU,KAAA,IAAY,KAAA,IAAY;CAAE,GAAG;CAAU,GAAI;AAAiB;AAEzE,MAAa,eAAe,mBAAmB;CAC7C,IAAI;CACJ,aAAa;CACb,SAAS;EACP,IAAI,QAAyC;GAAE,OAAO,CAAC,IAAI;IAAE,MAAM;IAAiB,IAAI;GAAkB,GAAGI,0CAAiB,CAAC;EAAG;EAClI,IAAI,QAAyC;GAAE,OAAOC;EAAgB;EACtE,IAAI,gBAAyD;GAAE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,SAAS,EAAE,GAAGC,sBAAW,CAAC;EAAG;CACpH;AACF,CAAC"}
@@ -309,6 +309,44 @@ function parseSend(raw, lanes) {
309
309
  urgent: urgent === true
310
310
  };
311
311
  }
312
+ /** Records one outgoing message in the run, so a view of the exec call can show what was said and to whom. */
313
+ async function recorded(run, name, input, call) {
314
+ const started = Date.now();
315
+ const base = {
316
+ name,
317
+ tool: name,
318
+ args: typeof input === "object" && input !== null && !Array.isArray(input) ? { ...input } : {}
319
+ };
320
+ try {
321
+ const value = await call();
322
+ run.record?.({
323
+ ...base,
324
+ ok: true,
325
+ ms: Date.now() - started,
326
+ result: {
327
+ content: [{
328
+ type: "text",
329
+ text: JSON.stringify(value, null, 2) ?? ""
330
+ }],
331
+ details: value
332
+ }
333
+ });
334
+ return value;
335
+ } catch (error) {
336
+ const message = error instanceof Error ? error.message : String(error);
337
+ run.record?.({
338
+ ...base,
339
+ ok: false,
340
+ ms: Date.now() - started,
341
+ error: message,
342
+ result: { content: [{
343
+ type: "text",
344
+ text: message
345
+ }] }
346
+ });
347
+ throw error;
348
+ }
349
+ }
312
350
  /** Messaging between sessions on this host and linked hosts, with Team intercom's send, ask, reply and pending. */
313
351
  function createNetworkNamespace(options) {
314
352
  (0, _agimon_ai_po_core_codemode.assertCodemodeNamespaceName)("network");
@@ -352,21 +390,21 @@ function createNetworkNamespace(options) {
352
390
  check();
353
391
  return require_type.detach(result);
354
392
  };
355
- methods.send = async (raw) => {
393
+ methods.send = (raw) => recorded(run, "network.send", raw, async () => {
356
394
  check();
357
395
  const { to, text, urgent } = parseSend(raw, operations.lanes === true);
358
396
  return require_type.detach(await (urgent ? operations.send(to, text, signal, { urgent }) : operations.send(to, text, signal)));
359
- };
360
- if (operations.ask) methods.ask = async (raw) => {
397
+ });
398
+ if (operations.ask) methods.ask = (raw) => recorded(run, "network.ask", raw, async () => {
361
399
  check();
362
400
  const { to, text } = require_type.fields(raw, ["to", "text"]);
363
401
  return require_type.detach(await operations.ask(to, text, signal));
364
- };
365
- if (operations.reply) methods.reply = async (raw) => {
402
+ });
403
+ if (operations.reply) methods.reply = (raw) => recorded(run, "network.reply", raw, async () => {
366
404
  check();
367
405
  const { requestId, text } = require_type.fields(raw, ["requestId", "text"]);
368
406
  return require_type.detach(await operations.reply(requestId, text, signal));
369
- };
407
+ });
370
408
  if (operations.pending) methods.pending = async () => {
371
409
  check();
372
410
  const result = await operations.pending(signal);