@hanzo/app 0.2.58 → 0.3.1

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.
Files changed (129) hide show
  1. package/README.md +8 -8
  2. package/dist/{Me.d.ts → Account.d.ts} +1 -1
  3. package/dist/{Me.js → Account.js} +3 -3
  4. package/dist/App.d.ts +2 -2
  5. package/dist/App.js +16 -16
  6. package/dist/{Top.d.ts → Bar.d.ts} +1 -1
  7. package/dist/{Top.js → Bar.js} +3 -3
  8. package/dist/Betas.js +1 -1
  9. package/dist/Board.js +4 -4
  10. package/dist/Chat.d.ts +4 -4
  11. package/dist/Chat.js +96 -96
  12. package/dist/Contacts.js +17 -15
  13. package/dist/Directory.js +7 -21
  14. package/dist/Drive.js +6 -6
  15. package/dist/{Orgs.d.ts → Gate.d.ts} +1 -1
  16. package/dist/{Orgs.js → Gate.js} +32 -32
  17. package/dist/{Chrome.d.ts → Header.d.ts} +1 -1
  18. package/dist/{Chrome.js → Header.js} +1 -1
  19. package/dist/Home.d.ts +3 -3
  20. package/dist/Home.js +30 -30
  21. package/dist/Inbox.js +29 -33
  22. package/dist/Meet.js +22 -22
  23. package/dist/Rail.js +6 -6
  24. package/dist/RightPane.js +2 -2
  25. package/dist/{Palette.d.ts → Search.d.ts} +1 -1
  26. package/dist/{Palette.js → Search.js} +1 -1
  27. package/dist/Settings.d.ts +3 -3
  28. package/dist/Settings.js +5 -5
  29. package/dist/SettingsPane.d.ts +2 -2
  30. package/dist/SettingsPane.js +5 -5
  31. package/dist/Setup.js +2 -2
  32. package/dist/Shell.d.ts +22 -31
  33. package/dist/Shell.js +167 -114
  34. package/dist/{Column.d.ts → Sidebar.d.ts} +1 -1
  35. package/dist/{Column.js → Sidebar.js} +5 -5
  36. package/dist/Support.js +2 -2
  37. package/dist/Talk.d.ts +3 -3
  38. package/dist/Talk.js +18 -18
  39. package/dist/TeamPreview.js +26 -26
  40. package/dist/TeamStory.js +1 -1
  41. package/dist/Usage.js +2 -2
  42. package/dist/Work.js +2 -2
  43. package/dist/bots/Bots.js +2 -2
  44. package/dist/bots/Lights.d.ts +1 -1
  45. package/dist/bots/Lights.js +1 -1
  46. package/dist/bots/api.d.ts +8 -7
  47. package/dist/bots/api.js +4 -4
  48. package/dist/bots/ink.js +3 -3
  49. package/dist/bots/kit.d.ts +2 -2
  50. package/dist/bots/kit.js +4 -4
  51. package/dist/bots/runtime.js +12 -12
  52. package/dist/cast.d.ts +14 -14
  53. package/dist/cast.js +12 -12
  54. package/dist/channels.d.ts +132 -0
  55. package/dist/{rooms.js → channels.js} +56 -55
  56. package/dist/conversations.d.ts +8 -8
  57. package/dist/conversations.js +18 -17
  58. package/dist/crew.d.ts +1 -1
  59. package/dist/crew.js +12 -12
  60. package/dist/dev.js +6 -6
  61. package/dist/failure.d.ts +2 -2
  62. package/dist/failure.js +6 -6
  63. package/dist/ground.d.ts +1 -1
  64. package/dist/ground.js +1 -1
  65. package/dist/help.d.ts +1 -1
  66. package/dist/help.js +2 -2
  67. package/dist/hint.d.ts +1 -1
  68. package/dist/hint.js +1 -1
  69. package/dist/host.d.ts +15 -15
  70. package/dist/host.js +13 -13
  71. package/dist/index.d.ts +5 -5
  72. package/dist/index.js +4 -4
  73. package/dist/lib/ai.js +1 -1
  74. package/dist/lib/api.d.ts +1 -1
  75. package/dist/lib/api.js +1 -1
  76. package/dist/lib/destination.d.ts +3 -3
  77. package/dist/lib/destination.js +3 -3
  78. package/dist/lib/home.d.ts +2 -2
  79. package/dist/lib/home.js +2 -2
  80. package/dist/lib/host.d.ts +17 -16
  81. package/dist/lib/host.js +19 -18
  82. package/dist/lib/hostname.d.ts +1 -1
  83. package/dist/lib/hostname.js +1 -1
  84. package/dist/lib/list.d.ts +1 -1
  85. package/dist/lib/list.js +1 -1
  86. package/dist/lib/models.js +1 -1
  87. package/dist/lib/org.d.ts +1 -1
  88. package/dist/lib/org.js +1 -1
  89. package/dist/lib/orgname.d.ts +1 -1
  90. package/dist/lib/orgname.js +1 -1
  91. package/dist/lib/session.d.ts +4 -4
  92. package/dist/lib/session.js +6 -6
  93. package/dist/lib/tier.d.ts +4 -4
  94. package/dist/lib/tier.js +5 -5
  95. package/dist/lib/tiers.d.ts +1 -1
  96. package/dist/lib/tiers.js +10 -10
  97. package/dist/lib/web.d.ts +1 -1
  98. package/dist/lib/web.js +1 -1
  99. package/dist/look.js +7 -9
  100. package/dist/network.d.ts +18 -18
  101. package/dist/network.js +28 -28
  102. package/dist/open.d.ts +24 -22
  103. package/dist/open.js +19 -19
  104. package/dist/pane.d.ts +6 -6
  105. package/dist/pane.js +10 -10
  106. package/dist/roster.d.ts +2 -2
  107. package/dist/roster.js +1 -1
  108. package/dist/seek.js +1 -1
  109. package/dist/slide.d.ts +1 -1
  110. package/dist/slide.js +1 -1
  111. package/dist/span.js +1 -1
  112. package/dist/stars.d.ts +4 -4
  113. package/dist/stars.js +8 -10
  114. package/dist/tabs.d.ts +1 -1
  115. package/dist/tabs.js +1 -1
  116. package/dist/team.js +1 -1
  117. package/dist/thread.d.ts +3 -3
  118. package/dist/thread.js +4 -4
  119. package/dist/ui.d.ts +1 -1
  120. package/dist/ui.js +1 -1
  121. package/dist/where.d.ts +7 -7
  122. package/dist/where.js +2 -2
  123. package/dist/workday.d.ts +26 -26
  124. package/dist/workday.js +187 -187
  125. package/package.json +8 -8
  126. package/dist/Room.d.ts +0 -8
  127. package/dist/Room.js +0 -51
  128. package/dist/rooms.d.ts +0 -131
  129. /package/dist/lib/{rooms.json → routes.json} +0 -0
@@ -11,7 +11,7 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
11
11
  // is deterministic, so the same disk comes back after a lease ends
12
12
  // its TOOLS `tools[]` — the names this Bot may call, out of the platform's
13
13
  // own MCP surface plus whatever the org has registered
14
- // its CHANNELS the rooms it answers, from /v1/channels/agent
14
+ // its TRANSPORTS the networks it answers on, from /v1/transport/agent
15
15
  // its CODE an autonomous run against one of the org's repos
16
16
  // its SECRETS the KMS names under `bots/<name>`
17
17
  //
@@ -77,7 +77,7 @@ export function Runtime({ bot }) {
77
77
  const [activated, setActivated] = useState([]);
78
78
  const [published, setPublished] = useState([]);
79
79
  const [links, setLinks] = useState([]);
80
- const [rooms, setRooms] = useState([]);
80
+ const [transports, setTransports] = useState([]);
81
81
  const [keys, setKeys] = useState([]);
82
82
  const [repos, setRepos] = useState([]);
83
83
  const [why, setWhy] = useState({});
@@ -95,7 +95,7 @@ export function Runtime({ bot }) {
95
95
  client.tools.activation().then((a) => setActivated(a.enabled ?? [])).catch(() => setActivated([])),
96
96
  readTools(client).then(setPublished).catch((e) => blame('served', e, t('the platform’s tools'))),
97
97
  readConnectors(client).then(setLinks).catch((e) => blame('link', e, t('your connectors'))),
98
- client.channels.list().then(setRooms).catch((e) => blame('room', e, t('this org’s channels'))),
98
+ client.transports.list().then(setTransports).catch((e) => blame('transport', e, t('this org’s transports'))),
99
99
  readSecrets(client, vault(bot.name)).then(setKeys).catch((e) => blame('key', e, t('this bot’s secrets'))),
100
100
  readProjects(client).then(setRepos).catch((e) => blame('repo', e, t('this org’s repos'))),
101
101
  ]);
@@ -112,7 +112,7 @@ export function Runtime({ bot }) {
112
112
  }) }), bot.schedule ? (_jsx(Line, { children: t(bot.executionMode ? 'Wakes on {schedule} ({mode}).' : 'Wakes on {schedule}.', {
113
113
  schedule: _jsx(Text, { color: INK, children: bot.schedule }),
114
114
  mode: modeName(bot.executionMode, t),
115
- }) })) : null] }), _jsx(Machine, { bot: bot, machines: machines, why: why.machine }), _jsx(Computer, { bot: bot, box: boxes[0] ?? null, project: project, why: why.box, onChange: survey }), _jsx(Tools, { bot: bot, servers: servers, skills: skills, published: published, activated: activated, why: why.served ?? why.mcp ?? why.skill }), _jsx(Channels, { bot: bot, rooms: rooms, why: why.room }), _jsx(Code, { bot: bot, repos: repos, why: why.repo }), _jsx(Secrets, { bot: bot, keys: keys, why: why.key }), _jsx(Held, { links: links, why: why.link })] }));
115
+ }) })) : null] }), _jsx(Machine, { bot: bot, machines: machines, why: why.machine }), _jsx(Computer, { bot: bot, box: boxes[0] ?? null, project: project, why: why.box, onChange: survey }), _jsx(Tools, { bot: bot, servers: servers, skills: skills, published: published, activated: activated, why: why.served ?? why.mcp ?? why.skill }), _jsx(Transports, { bot: bot, transports: transports, why: why.transport }), _jsx(Code, { bot: bot, repos: repos, why: why.repo }), _jsx(Secrets, { bot: bot, keys: keys, why: why.key }), _jsx(Held, { links: links, why: why.link })] }));
116
116
  }
117
117
  /** The machine this Bot runs on. The list is the org's; the binding is the Bot's. */
118
118
  function Machine({ bot, machines, why }) {
@@ -280,13 +280,13 @@ function Tools({ bot, servers, skills, published, activated, why, }) {
280
280
  }, gap: 6, children: [_jsx(Picker, { ...PICK, value: pick, onChange: (e) => setPick(e.target.value), "aria-label": t('Tool to call'), children: held.map((h) => (_jsx("option", { value: h, children: h }, h))) }), _jsxs(XStack, { gap: 6, children: [_jsx(Input, { ...BOXED, flex: 1, minW: 0, "data-hz": "op", value: op, onChange: (e) => setOp(e.target.value), placeholder: t('Operation'), "aria-label": t('Operation to run') }), _jsx(Text, { ...TAB, type: 'submit', "data-hz": "call", disabled: busy || !op.trim(), children: t(busy ? 'Calling…' : 'Call') })] })] })) : null, ran ? _jsx(Text, { ...OUT, "data-hz": "called", children: ran }) : null, failed ? _jsx(Line, { children: failed }) : null] }));
281
281
  }
282
282
  /**
283
- * The rooms this Bot answers.
283
+ * The transports this Bot answers on.
284
284
  *
285
- * `/v1/channels/agent` binds ONE agent per channel as the org's default
285
+ * `/v1/transport/agent` binds ONE agent per transport as the org's default
286
286
  * answerer, so this is a per-Bot binding and not an account-wide list: pressing
287
- * Answer here moves that channel from whichever bot holds it to this one.
287
+ * Answer here moves that transport from whichever bot holds it to this one.
288
288
  */
289
- function Channels({ bot, rooms, why }) {
289
+ function Transports({ bot, transports, why }) {
290
290
  const { t, locale } = useI18n();
291
291
  const { client } = useAi();
292
292
  const [bound, setBound] = useState({});
@@ -294,7 +294,7 @@ function Channels({ bot, rooms, why }) {
294
294
  const read = useCallback(async () => {
295
295
  if (!client)
296
296
  return;
297
- const pairs = await Promise.all(rooms.map(async (r) => {
297
+ const pairs = await Promise.all(transports.map(async (r) => {
298
298
  try {
299
299
  return [r.id, (await answering(client, r.id)).default ?? ''];
300
300
  }
@@ -303,11 +303,11 @@ function Channels({ bot, rooms, why }) {
303
303
  }
304
304
  }));
305
305
  setBound(Object.fromEntries(pairs));
306
- }, [client, rooms]);
306
+ }, [client, transports]);
307
307
  useEffect(() => {
308
308
  void read();
309
309
  }, [read]);
310
- return (_jsxs(Part, { title: t('Channels'), children: [why ? _jsx(Line, { children: why }) : null, rooms.length === 0 && !why ? _jsx(Line, { children: t('This org has no channels.') }) : null, rooms.map((r) => {
310
+ return (_jsxs(Part, { title: t('Transports'), children: [why ? _jsx(Line, { children: why }) : null, transports.length === 0 && !why ? _jsx(Line, { children: t('This org has no transports.') }) : null, transports.map((r) => {
311
311
  const mine = bound[r.id] === bot.name;
312
312
  return (_jsxs(Row, { children: [_jsx(Text, { fontSize: "$2", color: INK, children: r.id }), _jsxs(XStack, { items: "center", gap: 8, children: [_jsx(Text, { fontSize: "$1", color: FAINT, children: r.connected ? bound[r.id] || t('unbound') : t('not connected') }), _jsx(Text, { ...TAB, opacity: mine ? 0.5 : 1, disabled: mine, onClick: async () => {
313
313
  if (!client)
@@ -318,7 +318,7 @@ function Channels({ bot, rooms, why }) {
318
318
  await read();
319
319
  }
320
320
  catch (e) {
321
- setFailed(say(e, t('this channel'), 'save', t));
321
+ setFailed(say(e, t('this transport'), 'save', t));
322
322
  }
323
323
  }, children: t(mine ? 'Answers' : 'Answer') })] })] }, r.id));
324
324
  }), failed ? _jsx(Line, { children: failed }) : null] }));
package/dist/cast.d.ts CHANGED
@@ -29,9 +29,9 @@ interface Role {
29
29
  * voice id, sent to /v1/audio/speech as it is. The first letter is the accent
30
30
  * (a American, b British), the second the register (f female, m male).
31
31
  *
32
- * ONE VOICE PER CHARACTER, and never two who would be in the same room. A
33
- * house part shares the voice of the character whose face it wears, so Hanzo
34
- * Coder sounds like Dev; no two characters share one.
32
+ * ONE VOICE PER CHARACTER, and never two who would be in the same
33
+ * conversation. A house part shares the voice of the character whose face it
34
+ * wears, so Hanzo Coder sounds like Dev; no two characters share one.
35
35
  *
36
36
  * CAST, NOT COPIED. These are the speech service's own voices, chosen for fit
37
37
  * — a playful reader for the physicist, something low and measured for the
@@ -50,14 +50,14 @@ export declare const speaksOf: (name: string | undefined) => string | undefined;
50
50
  /** Names as a sentence lists them: "Feynman", "Feynman & Einstein", "Feynman, Einstein & Vi". */
51
51
  export declare const join: (names: string[], t?: Say) => string;
52
52
  /**
53
- * The room's system turn.
53
+ * The conversation's system turn.
54
54
  *
55
55
  * One person's brief rides as it is, under their name. Several ride together:
56
- * who is in the room, who answers — the ones the user names, or everyone when
57
- * nobody is named (Chat.tsx `addressed` draws the same rule) — the one rule that
58
- * lets a reader tell them apart — each contribution opens with a name and a
59
- * colon — and then each brief under its name. Null for a room with nobody to
60
- * describe, which is the plain model.
56
+ * who is in the conversation, who answers — the ones the user names, or
57
+ * everyone when nobody is named (Chat.tsx `addressed` draws the same rule) —
58
+ * the one rule that lets a reader tell them apart — each contribution opens
59
+ * with a name and a colon — and then each brief under its name. Null for a
60
+ * conversation with nobody to describe, which is the plain model.
61
61
  */
62
62
  export declare function brief(cast: {
63
63
  name: string;
@@ -65,19 +65,19 @@ export declare function brief(cast: {
65
65
  }[]): string | null;
66
66
  /**
67
67
  * The line a conversation records to say who is in it. The thread keeps it as a
68
- * system turn, so reopening the thread anywhere seats the same room. Names are
68
+ * system turn, so reopening the thread anywhere seats the same cast. Names are
69
69
  * the agents' handles, which carry no comma (the agents API's name pattern).
70
70
  */
71
71
  export declare const roster: (names: string[]) => string;
72
72
  /** The names a recorded roster line holds, or null for a turn that is not one. */
73
73
  export declare function rosterOf(content: string): string[] | null;
74
74
  /**
75
- * The system turn a room sends: the roster line, then the brief. Null for an
76
- * empty room, which is the plain model.
75
+ * The system turn a conversation sends: the roster line, then the brief. Null
76
+ * for an empty conversation, which is the plain model.
77
77
  */
78
- export declare function roomTurn(names: string[], said: string | null): string | null;
78
+ export declare function castTurn(names: string[], said: string | null): string | null;
79
79
  /**
80
- * A room's reply, split by who said what.
80
+ * A conversation's reply, split by who said what.
81
81
  *
82
82
  * A line that opens with a member's name and a colon — plain or bold — starts
83
83
  * that member's part; lines before any such line belong to nobody, and a reply
package/dist/cast.js CHANGED
@@ -57,14 +57,14 @@ export const speaksOf = (name) => member(name)?.instructions;
57
57
  /** Names as a sentence lists them: "Feynman", "Feynman & Einstein", "Feynman, Einstein & Vi". */
58
58
  export const join = (names, t = english) => names.length < 2 ? (names[0] ?? '') : t('{names} & {last}', { names: names.slice(0, -1).join(', '), last: names[names.length - 1] });
59
59
  /**
60
- * The room's system turn.
60
+ * The conversation's system turn.
61
61
  *
62
62
  * One person's brief rides as it is, under their name. Several ride together:
63
- * who is in the room, who answers — the ones the user names, or everyone when
64
- * nobody is named (Chat.tsx `addressed` draws the same rule) — the one rule that
65
- * lets a reader tell them apart — each contribution opens with a name and a
66
- * colon — and then each brief under its name. Null for a room with nobody to
67
- * describe, which is the plain model.
63
+ * who is in the conversation, who answers — the ones the user names, or
64
+ * everyone when nobody is named (Chat.tsx `addressed` draws the same rule) —
65
+ * the one rule that lets a reader tell them apart — each contribution opens
66
+ * with a name and a colon — and then each brief under its name. Null for a
67
+ * conversation with nobody to describe, which is the plain model.
68
68
  */
69
69
  export function brief(cast) {
70
70
  if (!cast.length || cast.every((one) => !one.says))
@@ -79,11 +79,11 @@ export function brief(cast) {
79
79
  ...cast.map((one) => `## ${one.name}\n\n${one.says ?? `${one.name} answers as ${one.name}.`}`),
80
80
  ].join('\n\n');
81
81
  }
82
- /** The first line of a room's system turn: who is in the conversation, by name. */
82
+ /** The first line of a conversation's system turn: who is in it, by name. */
83
83
  const ROSTER = 'Agents in this conversation: ';
84
84
  /**
85
85
  * The line a conversation records to say who is in it. The thread keeps it as a
86
- * system turn, so reopening the thread anywhere seats the same room. Names are
86
+ * system turn, so reopening the thread anywhere seats the same cast. Names are
87
87
  * the agents' handles, which carry no comma (the agents API's name pattern).
88
88
  */
89
89
  export const roster = (names) => `${ROSTER}${names.length ? names.join(', ') : 'none'}`;
@@ -96,16 +96,16 @@ export function rosterOf(content) {
96
96
  return names === 'none' ? [] : names.split(',').map((one) => one.trim()).filter(Boolean);
97
97
  }
98
98
  /**
99
- * The system turn a room sends: the roster line, then the brief. Null for an
100
- * empty room, which is the plain model.
99
+ * The system turn a conversation sends: the roster line, then the brief. Null
100
+ * for an empty conversation, which is the plain model.
101
101
  */
102
- export function roomTurn(names, said) {
102
+ export function castTurn(names, said) {
103
103
  if (!names.length)
104
104
  return null;
105
105
  return said ? `${roster(names)}\n\n${said}` : roster(names);
106
106
  }
107
107
  /**
108
- * A room's reply, split by who said what.
108
+ * A conversation's reply, split by who said what.
109
109
  *
110
110
  * A line that opens with a member's name and a colon — plain or bold — starts
111
111
  * that member's part; lines before any such line belong to nobody, and a reply
@@ -0,0 +1,132 @@
1
+ /**
2
+ * A channel as Team keeps it: an open one, a direct message, or one bound to
3
+ * work.
4
+ *
5
+ * `direct` is the distinction the sidebar draws — a channel anyone in the org
6
+ * can read against a conversation between two people — so it decides the sigil
7
+ * and the section rather than a guess from the name.
8
+ *
9
+ * `space` is half of a channel's address: two spaces of one org may each hold a
10
+ * #general, so the pair identifies one and the id alone does not. It is also
11
+ * the box a file goes in — `/v1/team/files/{space}` is addressed by space, never
12
+ * by channel. The field is the server's own name for it.
13
+ */
14
+ export interface Channel {
15
+ id: string;
16
+ space: string;
17
+ name: string;
18
+ topic?: string;
19
+ desc?: string;
20
+ direct: boolean;
21
+ private: boolean;
22
+ visibility?: 'public' | 'org' | 'private';
23
+ orgId?: string;
24
+ archived: boolean;
25
+ members: string[];
26
+ count?: number;
27
+ /**
28
+ * What the channel is FOR — "standing" for one meant to outlive any task,
29
+ * "bound" for one opened for a single piece of work. Absent reads standing.
30
+ * It is intent, not state: whether the channel is open now is `archived`.
31
+ */
32
+ life?: string;
33
+ /**
34
+ * What the channel is ABOUT, each a "<kind>:<ref>" — "repo:hanzoai/cloud",
35
+ * "issue:1010". References, never copies: the app that owns a project is the
36
+ * one that can resolve it.
37
+ */
38
+ bindings?: string[];
39
+ }
40
+ /**
41
+ * The key the workspace selects a channel by, and puts in the address:
42
+ * `team:<space>/<id>`. Both halves, because a channel id is unique within a
43
+ * space and not across the org. Prefixed rather than hashed, because a key a
44
+ * person can read in a URL is one they can report in a bug.
45
+ */
46
+ export declare const teamKey: (channel: Pick<Channel, 'space' | 'id'>) => string;
47
+ /** The address a key names, or null for a key that is not a channel's. */
48
+ export declare function fromKey(key: string | null): {
49
+ space: string;
50
+ id: string;
51
+ } | null;
52
+ /** The page a key opens on: Home, carrying it as the `?channel=` that
53
+ * the host's Home reads on arrival. */
54
+ export declare const channelHref: (key: string) => string;
55
+ /** Asks the platform again. The list held stays on screen until it answers. */
56
+ export declare function reloadChannels(): void;
57
+ /**
58
+ * The org's real channels, from Team, and the way to add one.
59
+ *
60
+ * `/v1/team/channels` is the org's own list and answers only a validated
61
+ * principal. An archived channel is not drawn: it is one the org closed, and a
62
+ * sidebar that lists them makes leaving one meaningless.
63
+ *
64
+ * NULL IS UNKNOWN AND IT IS NOT EMPTY. Three states, and the caller owes a
65
+ * sentence for each: `null` while nothing is known, `[]` for an org that
66
+ * genuinely has no channels, and `wrong` for a service that answered no. A list is
67
+ * never fabricated to cover any of them.
68
+ *
69
+ * `open` posts a channel and HOLDS the one the platform answered with: a 201
70
+ * is `{channel}`, the stored channel, so every view carries it from that moment
71
+ * and the reader can step into it without a second read. The server adds nobody
72
+ * to a channel, so the caller names its own members.
73
+ */
74
+ export declare function useChannels(): {
75
+ channels: Channel[] | null;
76
+ wrong: unknown;
77
+ reload: () => void;
78
+ open: (channel: {
79
+ name: string;
80
+ space?: string;
81
+ members: string[];
82
+ }) => Promise<Channel>;
83
+ };
84
+ /** The channel with that id, or undefined for none open. */
85
+ export declare function channelOf(channels: Channel[] | null, id: string | null): Channel | undefined;
86
+ /**
87
+ * One thing somebody said in a channel.
88
+ *
89
+ * `author` is the team ACCOUNT that wrote it, not a name: what to call somebody
90
+ * is the roster's answer (`roster.ts`), and copying it onto every message is
91
+ * how the two come to disagree. `text` is plain — the platform stores the
92
+ * client's markup and reduces it on the way out, so nothing here parses HTML.
93
+ */
94
+ export interface Message {
95
+ id: string;
96
+ /** The channel's id. */
97
+ channel: string;
98
+ author: string;
99
+ text: string;
100
+ /** Unix MILLIseconds, which is what the platform stamps. */
101
+ createdOn: number;
102
+ }
103
+ /**
104
+ * A channel's conversation, and the way to add to it.
105
+ *
106
+ * READ AND WRITE IN ONE HOOK, because they are one question — a pane that can
107
+ * show a channel and not answer in it is a directory — and because the poller
108
+ * and the sender then cannot disagree about what the channel holds.
109
+ *
110
+ * THE CHANNEL IS POLLED, every two seconds while it is open and the tab is
111
+ * showing. The team plane has no push a browser can read but its transactor
112
+ * socket, which is a binary protocol rather than a line; a read costs a few
113
+ * hundred milliseconds and nothing on the server past the space's own
114
+ * messages, so half a request a second per open channel is the honest price of
115
+ * seeing an answer land. Each read carries its own AbortController, and the
116
+ * cleanup aborts the one in flight and stops the clock — on unmount, and when
117
+ * the channel or its space changes.
118
+ *
119
+ * `send` posts and answers the row the platform stored: a 201 is the message,
120
+ * with its id and stamp, so the hook holds it at once and the next poll finds
121
+ * the same id and keeps one. Nothing the platform did not accept is ever held.
122
+ *
123
+ * `space` is half a channel's address (two spaces of one org may each hold a
124
+ * channel with one id), so both calls carry it and a channel with neither reads
125
+ * empty rather than guessing.
126
+ */
127
+ export declare function useMessages(channel: string | null, space: string | undefined): {
128
+ messages: Message[];
129
+ failed: unknown;
130
+ send: (text: string) => Promise<Message>;
131
+ reload: () => void;
132
+ };
@@ -1,32 +1,33 @@
1
1
  'use client';
2
- // The org's rooms: the one reader and writer for /v1/team.
2
+ // The org's channels: the one reader and writer for /v1/team/channels
3
+ // (HIP-0523 §2.1).
3
4
  //
4
- // A room is not the sidebar's private business. The rail lists them, /home
5
+ // A channel is not the sidebar's private business. The rail lists them, /home
5
6
  // reads one, and the composer needs the space off it to address anything — so
6
7
  // the list, the key, the transcript and the two writes live here, in one shape,
7
- // and no second module holds another opinion about what a room is.
8
+ // and no second module holds another opinion about what a channel is.
8
9
  import { useCallback, useEffect, useState, useSyncExternalStore } from 'react';
9
10
  import { useIam } from '@hanzo/iam/react';
10
11
  import { useAi } from './lib/ai.js';
11
12
  import { where } from './where.js';
12
13
  /**
13
- * The key the workspace selects a room by, and puts in the address:
14
- * `team:<space>/<id>`. Both halves, because a room id is unique within a space
15
- * and not across the org. Prefixed rather than hashed, because a key a person
16
- * can read in a URL is one they can report in a bug.
14
+ * The key the workspace selects a channel by, and puts in the address:
15
+ * `team:<space>/<id>`. Both halves, because a channel id is unique within a
16
+ * space and not across the org. Prefixed rather than hashed, because a key a
17
+ * person can read in a URL is one they can report in a bug.
17
18
  */
18
- export const teamKey = (room) => `team:${room.space}/${room.id}`;
19
- /** The address a key names, or null for a key that is not a room's. */
20
- export function roomKey(key) {
19
+ export const teamKey = (channel) => `team:${channel.space}/${channel.id}`;
20
+ /** The address a key names, or null for a key that is not a channel's. */
21
+ export function fromKey(key) {
21
22
  const found = key?.match(/^team:([^/]+)\/(.+)$/);
22
23
  return found ? { space: found[1], id: found[2] } : null;
23
24
  }
24
- /** The page a key opens on: Home, carrying it as the `?room=` that
25
- * `app/(app)/home/_workspace.tsx` reads on arrival. */
26
- export const roomHref = (key) => `${where().home}?${new URLSearchParams({ room: key })}`;
25
+ /** The page a key opens on: Home, carrying it as the `?channel=` that
26
+ * the host's Home reads on arrival. */
27
+ export const channelHref = (key) => `${where().home}?${new URLSearchParams({ channel: key })}`;
27
28
  /** The prerender's answer, and the first one. A stable reference, because
28
29
  * React compares snapshots by identity. */
29
- const UNKNOWN = { rooms: null, wrong: null };
30
+ const UNKNOWN = { channels: null, wrong: null };
30
31
  let held = UNKNOWN;
31
32
  /** Bumped by `reload`; a read is made once per value. */
32
33
  let epoch = 0;
@@ -44,28 +45,28 @@ function subscribe(one) {
44
45
  };
45
46
  }
46
47
  /** Asks the platform again. The list held stays on screen until it answers. */
47
- export function reloadRooms() {
48
+ export function reloadChannels() {
48
49
  epoch += 1;
49
- publish({ rooms: held.rooms, wrong: null });
50
+ publish({ channels: held.channels, wrong: null });
50
51
  }
51
52
  /**
52
- * The org's real rooms, from Team, and the way to add one.
53
+ * The org's real channels, from Team, and the way to add one.
53
54
  *
54
- * `/v1/team/rooms` is the org's own list and answers only a validated
55
- * principal. An archived room is not drawn: it is a room the org closed, and a
55
+ * `/v1/team/channels` is the org's own list and answers only a validated
56
+ * principal. An archived channel is not drawn: it is one the org closed, and a
56
57
  * sidebar that lists them makes leaving one meaningless.
57
58
  *
58
59
  * NULL IS UNKNOWN AND IT IS NOT EMPTY. Three states, and the caller owes a
59
60
  * sentence for each: `null` while nothing is known, `[]` for an org that
60
- * genuinely has no rooms, and `wrong` for a service that answered no. A list is
61
+ * genuinely has no channels, and `wrong` for a service that answered no. A list is
61
62
  * never fabricated to cover any of them.
62
63
  *
63
- * `open` posts a room and HOLDS the row the platform answered with: a 201 is
64
- * the stored room, so every view carries it from that moment and the reader can
65
- * step into it without a second read. The caller is not added to a room by the
66
- * server, so it names its own members.
64
+ * `open` posts a channel and HOLDS the one the platform answered with: a 201
65
+ * is `{channel}`, the stored channel, so every view carries it from that moment
66
+ * and the reader can step into it without a second read. The server adds nobody
67
+ * to a channel, so the caller names its own members.
67
68
  */
68
- export function useTeamRooms() {
69
+ export function useChannels() {
69
70
  const { client } = useAi();
70
71
  const { user } = useIam();
71
72
  const now = useSyncExternalStore(subscribe, () => held, () => UNKNOWN);
@@ -75,65 +76,65 @@ export function useTeamRooms() {
75
76
  asked = epoch;
76
77
  const mine = epoch;
77
78
  client.http
78
- .json({ path: '/v1/team/rooms' })
79
+ .json({ path: '/v1/team/channels' })
79
80
  .then((page) => {
80
81
  if (mine === epoch)
81
- publish({ rooms: (page.rooms ?? []).filter((r) => !r.archived), wrong: null });
82
+ publish({ channels: (page.channels ?? []).filter((c) => !c.archived), wrong: null });
82
83
  })
83
84
  .catch((e) => {
84
85
  if (mine === epoch)
85
- publish({ rooms: null, wrong: e });
86
+ publish({ channels: null, wrong: e });
86
87
  });
87
88
  }, [client, user, now]);
88
- const open = useCallback(async (room) => {
89
+ const open = useCallback(async (channel) => {
89
90
  if (!client)
90
91
  throw Object.assign(new Error('Sign in to open a channel'), { status: 401 });
91
- const made = await client.http.json({
92
+ const { channel: made } = await client.http.json({
92
93
  method: 'POST',
93
- path: '/v1/team/rooms',
94
- body: room,
94
+ path: '/v1/team/channels',
95
+ body: channel,
95
96
  });
96
- publish({ rooms: [...(held.rooms ?? []), made], wrong: null });
97
+ publish({ channels: [...(held.channels ?? []), made], wrong: null });
97
98
  return made;
98
99
  }, [client]);
99
- return { rooms: now.rooms, wrong: now.wrong, reload: reloadRooms, open };
100
+ return { channels: now.channels, wrong: now.wrong, reload: reloadChannels, open };
100
101
  }
101
- /** The room with that id, or undefined for none open. */
102
- export function roomOf(rooms, id) {
103
- return id && rooms ? rooms.find((r) => r.id === id) : undefined;
102
+ /** The channel with that id, or undefined for none open. */
103
+ export function channelOf(channels, id) {
104
+ return id && channels ? channels.find((c) => c.id === id) : undefined;
104
105
  }
105
106
  /**
106
107
  * One row per id, in the platform's order — `createdOn`, then `id` — so a row
107
108
  * held from a send and the same row read back by the next poll sit in one place.
108
109
  */
109
110
  const order = (rows) => [...new Map(rows.map((one) => [one.id, one])).values()].sort((a, b) => a.createdOn - b.createdOn || (a.id < b.id ? -1 : a.id > b.id ? 1 : 0));
110
- /** How often an open room asks what was said. */
111
+ /** How often an open channel asks what was said. */
111
112
  const PACE = 2000;
112
113
  /**
113
- * A room's conversation, and the way to add to it.
114
+ * A channel's conversation, and the way to add to it.
114
115
  *
115
116
  * READ AND WRITE IN ONE HOOK, because they are one question — a pane that can
116
- * show a room and not answer in it is a directory — and because the poller and
117
- * the sender then cannot disagree about what the room holds.
117
+ * show a channel and not answer in it is a directory — and because the poller
118
+ * and the sender then cannot disagree about what the channel holds.
118
119
  *
119
- * THE ROOM IS POLLED, every two seconds while it is open and the tab is
120
+ * THE CHANNEL IS POLLED, every two seconds while it is open and the tab is
120
121
  * showing. The team plane has no push a browser can read but its transactor
121
122
  * socket, which is a binary protocol rather than a line; a read costs a few
122
123
  * hundred milliseconds and nothing on the server past the space's own
123
- * messages, so half a request a second per open room is the honest price of
124
+ * messages, so half a request a second per open channel is the honest price of
124
125
  * seeing an answer land. Each read carries its own AbortController, and the
125
126
  * cleanup aborts the one in flight and stops the clock — on unmount, and when
126
- * the room or its space changes.
127
+ * the channel or its space changes.
127
128
  *
128
129
  * `send` posts and answers the row the platform stored: a 201 is the message,
129
130
  * with its id and stamp, so the hook holds it at once and the next poll finds
130
131
  * the same id and keeps one. Nothing the platform did not accept is ever held.
131
132
  *
132
- * `space` is half a room's address (two spaces of one org may each hold a room
133
- * with one id), so both calls carry it and a room with neither reads empty
134
- * rather than guessing.
133
+ * `space` is half a channel's address (two spaces of one org may each hold a
134
+ * channel with one id), so both calls carry it and a channel with neither reads
135
+ * empty rather than guessing.
135
136
  */
136
- export function useRoomMessages(room, space) {
137
+ export function useMessages(channel, space) {
137
138
  const { client } = useAi();
138
139
  const { user } = useIam();
139
140
  const [messages, setMessages] = useState(null);
@@ -141,13 +142,13 @@ export function useRoomMessages(room, space) {
141
142
  const [read, setRead] = useState(0);
142
143
  const again = useCallback(() => setRead((n) => n + 1), []);
143
144
  useEffect(() => {
144
- if (!room) {
145
+ if (!channel) {
145
146
  setMessages(null);
146
147
  return;
147
148
  }
148
149
  if (!client || !user || !space)
149
150
  return;
150
- const path = `/v1/team/rooms/${encodeURIComponent(room)}/messages`;
151
+ const path = `/v1/team/channels/${encodeURIComponent(channel)}/messages`;
151
152
  let stop = null;
152
153
  const look = () => {
153
154
  stop?.abort();
@@ -159,7 +160,7 @@ export function useRoomMessages(room, space) {
159
160
  if (signal.aborted)
160
161
  return;
161
162
  setFailed(null);
162
- // An empty room reads empty: `[]` is the answer, not the absence of one.
163
+ // An empty channel reads empty: `[]` is the answer, not the absence of one.
163
164
  setMessages(order(page.messages ?? []));
164
165
  })
165
166
  .catch((e) => {
@@ -176,20 +177,20 @@ export function useRoomMessages(room, space) {
176
177
  clearInterval(clock);
177
178
  stop?.abort();
178
179
  };
179
- }, [client, user, room, space, read]);
180
+ }, [client, user, channel, space, read]);
180
181
  /** Says it and answers the stored row, or throws with the platform's status. */
181
182
  const send = useCallback(async (text) => {
182
- if (!client || !room || !space) {
183
+ if (!client || !channel || !space) {
183
184
  throw Object.assign(new Error('This channel has no address to send to'), { status: 503 });
184
185
  }
185
186
  const row = await client.http.json({
186
187
  method: 'POST',
187
- path: `/v1/team/rooms/${encodeURIComponent(room)}/messages`,
188
+ path: `/v1/team/channels/${encodeURIComponent(channel)}/messages`,
188
189
  body: { space, text },
189
190
  });
190
191
  setMessages((held) => order([...(held ?? []), row]));
191
192
  again();
192
193
  return row;
193
- }, [client, room, space, again]);
194
+ }, [client, channel, space, again]);
194
195
  return { messages, failed, send, reload: again };
195
196
  }
@@ -1,16 +1,16 @@
1
1
  import { useInbox } from '@hanzo/ai/react';
2
2
  import type { AiClient, Thread } from '@hanzo/ai';
3
3
  import type { Member } from './roster.js';
4
- /** An arrival room, as `@hanzo/ai` groups one. Named so this file can speak of
5
- * it without every caller importing the hook's return type. */
6
- type Arrival = ReturnType<typeof useInbox>['rooms'][number];
4
+ /** An arrived channel, as `@hanzo/ai` groups one. Named so this file can speak
5
+ * of it without every caller importing the hook's return type. */
6
+ type Arrival = ReturnType<typeof useInbox>['channels'][number];
7
7
  /** One conversation another network carries. */
8
8
  export interface Conversation {
9
9
  key: string;
10
10
  /** What to call it in a list. */
11
11
  title: string;
12
- /** The network it arrived on. */
13
- channel: string;
12
+ /** The transport it arrived on. */
13
+ transport: string;
14
14
  /** Unix MILLIseconds of the last thing said. The arrival plane stamps
15
15
  * SECONDS, and this is the one place that is reconciled. */
16
16
  lastAt: number;
@@ -18,7 +18,7 @@ export interface Conversation {
18
18
  preview: string;
19
19
  arrival: Arrival;
20
20
  }
21
- /** The key for an arrival. `useInbox` already keys a room; this qualifies it. */
21
+ /** The key for an arrival. `useInbox` already keys a channel; this qualifies it. */
22
22
  export declare const netKey: (arrival: Arrival) => string;
23
23
  /**
24
24
  * Every conversation this reader has been sent, newest first.
@@ -35,11 +35,11 @@ export declare function useConversations(): {
35
35
  export declare function conversationOf(all: Conversation[], key: string | null): Conversation | null;
36
36
  export declare const opening: (members: Member[]) => string;
37
37
  /**
38
- * Writes the room and answers its id.
38
+ * Writes the conversation and answers its id.
39
39
  *
40
40
  * The agents in it go in AHEAD of the opening line as the roster turn
41
41
  * (cast.tsx `roster`), which is how a conversation keeps who is in it: /chat
42
- * seats that room when the thread opens and reads each agent's brief fresh.
42
+ * seats them when the thread opens and reads each agent's brief fresh.
43
43
  * One agent, several, people, or a mix: all open by this one call.
44
44
  */
45
45
  export declare function start(ai: AiClient, members: Member[]): Promise<string>;