@swirls/shuttle 0.0.0-stage → 0.1.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 (298) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/LICENSE +190 -0
  3. package/NOTICE +5 -0
  4. package/README.md +42 -2
  5. package/dist/api/auth.d.ts +18 -0
  6. package/dist/api/auth.js +15 -0
  7. package/dist/api/common.d.ts +8 -0
  8. package/dist/api/common.js +4 -0
  9. package/dist/api/connections.d.ts +292 -0
  10. package/dist/api/connections.js +114 -0
  11. package/dist/api/github.d.ts +20 -0
  12. package/dist/api/github.js +13 -0
  13. package/dist/api/harness.d.ts +97 -0
  14. package/dist/api/harness.js +47 -0
  15. package/dist/api/index.d.ts +2059 -0
  16. package/dist/api/index.js +37 -0
  17. package/dist/api/runners.d.ts +93 -0
  18. package/dist/api/runners.js +45 -0
  19. package/dist/api/sandbox.d.ts +550 -0
  20. package/dist/api/sandbox.js +210 -0
  21. package/dist/api/sessions.d.ts +318 -0
  22. package/dist/api/sessions.js +154 -0
  23. package/dist/api/tenant.d.ts +54 -0
  24. package/dist/api/tenant.js +19 -0
  25. package/dist/api/timings.d.ts +36 -0
  26. package/dist/api/timings.js +48 -0
  27. package/dist/api/workspace.d.ts +738 -0
  28. package/dist/api/workspace.js +246 -0
  29. package/dist/core/pulls.d.ts +1001 -0
  30. package/dist/core/pulls.js +170 -0
  31. package/dist/core/workspace.d.ts +985 -0
  32. package/dist/core/workspace.js +174 -0
  33. package/dist/react/components/command-palette.d.ts +22 -0
  34. package/dist/react/components/command-palette.js +66 -0
  35. package/dist/react/components/follow-list.d.ts +20 -0
  36. package/dist/react/components/follow-list.js +98 -0
  37. package/dist/react/components/json-tree.d.ts +11 -0
  38. package/dist/react/components/json-tree.js +120 -0
  39. package/dist/react/components/markdown.d.ts +5 -0
  40. package/dist/react/components/markdown.js +29 -0
  41. package/dist/react/components/shuttle-mark.d.ts +7 -0
  42. package/dist/react/components/shuttle-mark.js +9 -0
  43. package/dist/react/components/status-dot.d.ts +9 -0
  44. package/dist/react/components/status-dot.js +27 -0
  45. package/dist/react/components/status.d.ts +6 -0
  46. package/dist/react/components/status.js +66 -0
  47. package/dist/react/components/ui/badge.d.ts +7 -0
  48. package/dist/react/components/ui/badge.js +19 -0
  49. package/dist/react/components/ui/button.d.ts +10 -0
  50. package/dist/react/components/ui/button.js +40 -0
  51. package/dist/react/components/ui/dialog.d.ts +19 -0
  52. package/dist/react/components/ui/dialog.js +34 -0
  53. package/dist/react/components/ui/dropdown-menu.d.ts +14 -0
  54. package/dist/react/components/ui/dropdown-menu.js +33 -0
  55. package/dist/react/components/ui/input.d.ts +3 -0
  56. package/dist/react/components/ui/input.js +6 -0
  57. package/dist/react/components/ui/panel.d.ts +18 -0
  58. package/dist/react/components/ui/panel.js +22 -0
  59. package/dist/react/components/ui/popover.d.ts +7 -0
  60. package/dist/react/components/ui/popover.js +16 -0
  61. package/dist/react/components/ui/resizable.d.ts +7 -0
  62. package/dist/react/components/ui/resizable.js +14 -0
  63. package/dist/react/components/ui/scroll-area.d.ts +14 -0
  64. package/dist/react/components/ui/scroll-area.js +12 -0
  65. package/dist/react/components/ui/select.d.ts +10 -0
  66. package/dist/react/components/ui/select.js +20 -0
  67. package/dist/react/components/ui/sheet.d.ts +8 -0
  68. package/dist/react/components/ui/sheet.js +20 -0
  69. package/dist/react/components/ui/tabs.d.ts +7 -0
  70. package/dist/react/components/ui/tabs.js +16 -0
  71. package/dist/react/components/ui/textarea.d.ts +3 -0
  72. package/dist/react/components/ui/textarea.js +6 -0
  73. package/dist/react/components/ui/tooltip.d.ts +8 -0
  74. package/dist/react/components/ui/tooltip.js +17 -0
  75. package/dist/react/features/artifacts/artifact-links.d.ts +9 -0
  76. package/dist/react/features/artifacts/artifact-links.js +38 -0
  77. package/dist/react/features/artifacts/artifact-pane.d.ts +19 -0
  78. package/dist/react/features/artifacts/artifact-pane.js +75 -0
  79. package/dist/react/features/artifacts/artifact-types.d.ts +59 -0
  80. package/dist/react/features/artifacts/artifact-types.js +69 -0
  81. package/dist/react/features/artifacts/browser-viewer.d.ts +5 -0
  82. package/dist/react/features/artifacts/browser-viewer.js +60 -0
  83. package/dist/react/features/artifacts/diff-style.d.ts +10 -0
  84. package/dist/react/features/artifacts/diff-style.js +21 -0
  85. package/dist/react/features/artifacts/file-pane.d.ts +13 -0
  86. package/dist/react/features/artifacts/file-pane.js +305 -0
  87. package/dist/react/features/artifacts/file-quick-open.d.ts +15 -0
  88. package/dist/react/features/artifacts/file-quick-open.js +74 -0
  89. package/dist/react/features/artifacts/file-search.d.ts +12 -0
  90. package/dist/react/features/artifacts/file-search.js +90 -0
  91. package/dist/react/features/artifacts/media-viewer.d.ts +8 -0
  92. package/dist/react/features/artifacts/media-viewer.js +41 -0
  93. package/dist/react/features/artifacts/review-diff.d.ts +19 -0
  94. package/dist/react/features/artifacts/review-diff.js +59 -0
  95. package/dist/react/features/artifacts/review-viewer.d.ts +4 -0
  96. package/dist/react/features/artifacts/review-viewer.js +337 -0
  97. package/dist/react/features/artifacts/sandbox.d.ts +43 -0
  98. package/dist/react/features/artifacts/sandbox.js +109 -0
  99. package/dist/react/features/artifacts/tab-strip.d.ts +11 -0
  100. package/dist/react/features/artifacts/tab-strip.js +55 -0
  101. package/dist/react/features/artifacts/terminal-theme.d.ts +34 -0
  102. package/dist/react/features/artifacts/terminal-theme.js +62 -0
  103. package/dist/react/features/artifacts/terminal-viewer.d.ts +5 -0
  104. package/dist/react/features/artifacts/terminal-viewer.js +209 -0
  105. package/dist/react/features/artifacts/unified-diff.d.ts +16 -0
  106. package/dist/react/features/artifacts/unified-diff.js +55 -0
  107. package/dist/react/features/artifacts/workspace-viewer.d.ts +16 -0
  108. package/dist/react/features/artifacts/workspace-viewer.js +275 -0
  109. package/dist/react/features/connections/agent-sign-in.d.ts +71 -0
  110. package/dist/react/features/connections/agent-sign-in.js +251 -0
  111. package/dist/react/features/connections/connections-panel.d.ts +8 -0
  112. package/dist/react/features/connections/connections-panel.js +42 -0
  113. package/dist/react/features/connections/login.d.ts +24 -0
  114. package/dist/react/features/connections/login.js +35 -0
  115. package/dist/react/features/connections/places.d.ts +20 -0
  116. package/dist/react/features/connections/places.js +27 -0
  117. package/dist/react/features/connections/queries.d.ts +28 -0
  118. package/dist/react/features/connections/queries.js +8 -0
  119. package/dist/react/features/events/event-cache.d.ts +4 -0
  120. package/dist/react/features/events/event-cache.js +29 -0
  121. package/dist/react/features/events/event-catalog.d.ts +17 -0
  122. package/dist/react/features/events/event-catalog.js +261 -0
  123. package/dist/react/features/events/event-inspector.d.ts +7 -0
  124. package/dist/react/features/events/event-inspector.js +29 -0
  125. package/dist/react/features/events/event-row.d.ts +21 -0
  126. package/dist/react/features/events/event-row.js +34 -0
  127. package/dist/react/features/events/event-stream.d.ts +18 -0
  128. package/dist/react/features/events/event-stream.js +58 -0
  129. package/dist/react/features/events/global-events.d.ts +122 -0
  130. package/dist/react/features/events/global-events.js +329 -0
  131. package/dist/react/features/events/shuttle-events.d.ts +7 -0
  132. package/dist/react/features/events/shuttle-events.js +1 -0
  133. package/dist/react/features/playbook/playbook-page.d.ts +2 -0
  134. package/dist/react/features/playbook/playbook-page.js +36 -0
  135. package/dist/react/features/playbook/playbook-query.d.ts +111 -0
  136. package/dist/react/features/playbook/playbook-query.js +17 -0
  137. package/dist/react/features/pulls/linked-session.d.ts +12 -0
  138. package/dist/react/features/pulls/linked-session.js +22 -0
  139. package/dist/react/features/pulls/pull-detail-sheet.d.ts +10 -0
  140. package/dist/react/features/pulls/pull-detail-sheet.js +41 -0
  141. package/dist/react/features/pulls/pull-fixtures.d.ts +8 -0
  142. package/dist/react/features/pulls/pull-fixtures.js +258 -0
  143. package/dist/react/features/pulls/pull-glyphs.d.ts +24 -0
  144. package/dist/react/features/pulls/pull-glyphs.js +89 -0
  145. package/dist/react/features/pulls/pull-inbox-list.d.ts +13 -0
  146. package/dist/react/features/pulls/pull-inbox-list.js +230 -0
  147. package/dist/react/features/pulls/pull-inbox-pref.d.ts +2 -0
  148. package/dist/react/features/pulls/pull-inbox-pref.js +19 -0
  149. package/dist/react/features/pulls/pull-inbox.d.ts +30 -0
  150. package/dist/react/features/pulls/pull-inbox.js +110 -0
  151. package/dist/react/features/pulls/pull-threads.d.ts +39 -0
  152. package/dist/react/features/pulls/pull-threads.js +145 -0
  153. package/dist/react/features/pulls/pulls.d.ts +120 -0
  154. package/dist/react/features/pulls/pulls.js +414 -0
  155. package/dist/react/features/pulls/session-pull-groups.d.ts +14 -0
  156. package/dist/react/features/pulls/session-pull-groups.js +29 -0
  157. package/dist/react/features/pulls/stack-ladder.d.ts +9 -0
  158. package/dist/react/features/pulls/stack-ladder.js +32 -0
  159. package/dist/react/features/sessions/agent-tree.d.ts +16 -0
  160. package/dist/react/features/sessions/agent-tree.js +100 -0
  161. package/dist/react/features/sessions/agents.d.ts +34 -0
  162. package/dist/react/features/sessions/agents.js +146 -0
  163. package/dist/react/features/sessions/attention.d.ts +32 -0
  164. package/dist/react/features/sessions/attention.js +42 -0
  165. package/dist/react/features/sessions/composer-attachments.d.ts +33 -0
  166. package/dist/react/features/sessions/composer-attachments.js +126 -0
  167. package/dist/react/features/sessions/composer.d.ts +15 -0
  168. package/dist/react/features/sessions/composer.js +327 -0
  169. package/dist/react/features/sessions/context-usage-meter.d.ts +5 -0
  170. package/dist/react/features/sessions/context-usage-meter.js +122 -0
  171. package/dist/react/features/sessions/context-usage.d.ts +54 -0
  172. package/dist/react/features/sessions/context-usage.js +206 -0
  173. package/dist/react/features/sessions/conversation.d.ts +21 -0
  174. package/dist/react/features/sessions/conversation.js +549 -0
  175. package/dist/react/features/sessions/harness-switcher.d.ts +26 -0
  176. package/dist/react/features/sessions/harness-switcher.js +118 -0
  177. package/dist/react/features/sessions/intake-heuristic.d.ts +5 -0
  178. package/dist/react/features/sessions/intake-heuristic.js +28 -0
  179. package/dist/react/features/sessions/interjection-routes.d.ts +13 -0
  180. package/dist/react/features/sessions/interjection-routes.js +72 -0
  181. package/dist/react/features/sessions/llm-models.d.ts +128 -0
  182. package/dist/react/features/sessions/llm-models.js +174 -0
  183. package/dist/react/features/sessions/media-strip.d.ts +25 -0
  184. package/dist/react/features/sessions/media-strip.js +56 -0
  185. package/dist/react/features/sessions/media.d.ts +43 -0
  186. package/dist/react/features/sessions/media.js +115 -0
  187. package/dist/react/features/sessions/model-search.d.ts +6 -0
  188. package/dist/react/features/sessions/model-search.js +16 -0
  189. package/dist/react/features/sessions/model-switcher.d.ts +16 -0
  190. package/dist/react/features/sessions/model-switcher.js +262 -0
  191. package/dist/react/features/sessions/open-pull-request.d.ts +20 -0
  192. package/dist/react/features/sessions/open-pull-request.js +92 -0
  193. package/dist/react/features/sessions/pull-publish-card.d.ts +14 -0
  194. package/dist/react/features/sessions/pull-publish-card.js +88 -0
  195. package/dist/react/features/sessions/recent-sessions.d.ts +11 -0
  196. package/dist/react/features/sessions/recent-sessions.js +29 -0
  197. package/dist/react/features/sessions/seen-sessions.d.ts +16 -0
  198. package/dist/react/features/sessions/seen-sessions.js +108 -0
  199. package/dist/react/features/sessions/session-activity.d.ts +95 -0
  200. package/dist/react/features/sessions/session-activity.js +785 -0
  201. package/dist/react/features/sessions/session-context.d.ts +8 -0
  202. package/dist/react/features/sessions/session-context.js +98 -0
  203. package/dist/react/features/sessions/session-feed.d.ts +243 -0
  204. package/dist/react/features/sessions/session-feed.js +883 -0
  205. package/dist/react/features/sessions/session-header.d.ts +24 -0
  206. package/dist/react/features/sessions/session-header.js +97 -0
  207. package/dist/react/features/sessions/session-layout.d.ts +7 -0
  208. package/dist/react/features/sessions/session-layout.js +87 -0
  209. package/dist/react/features/sessions/session-panes.d.ts +49 -0
  210. package/dist/react/features/sessions/session-panes.js +142 -0
  211. package/dist/react/features/sessions/session-parts.d.ts +35 -0
  212. package/dist/react/features/sessions/session-parts.js +74 -0
  213. package/dist/react/features/sessions/session-place.d.ts +9 -0
  214. package/dist/react/features/sessions/session-place.js +109 -0
  215. package/dist/react/features/sessions/session-pr-pills.d.ts +7 -0
  216. package/dist/react/features/sessions/session-pr-pills.js +28 -0
  217. package/dist/react/features/sessions/session-queries.d.ts +172 -0
  218. package/dist/react/features/sessions/session-queries.js +90 -0
  219. package/dist/react/features/sessions/session-repos.d.ts +8 -0
  220. package/dist/react/features/sessions/session-repos.js +15 -0
  221. package/dist/react/features/sessions/session-share.d.ts +8 -0
  222. package/dist/react/features/sessions/session-share.js +112 -0
  223. package/dist/react/features/sessions/session-tabs.d.ts +38 -0
  224. package/dist/react/features/sessions/session-tabs.js +191 -0
  225. package/dist/react/features/sessions/session.d.ts +103 -0
  226. package/dist/react/features/sessions/session.js +216 -0
  227. package/dist/react/features/sessions/signals.d.ts +13 -0
  228. package/dist/react/features/sessions/signals.js +34 -0
  229. package/dist/react/features/sessions/tab-set.d.ts +20 -0
  230. package/dist/react/features/sessions/tab-set.js +58 -0
  231. package/dist/react/features/sessions/team.d.ts +16 -0
  232. package/dist/react/features/sessions/team.js +35 -0
  233. package/dist/react/features/sessions/timeline.d.ts +53 -0
  234. package/dist/react/features/sessions/timeline.js +153 -0
  235. package/dist/react/features/sessions/use-session-tabs.d.ts +18 -0
  236. package/dist/react/features/sessions/use-session-tabs.js +119 -0
  237. package/dist/react/features/sessions/vendor-models.d.ts +23 -0
  238. package/dist/react/features/sessions/vendor-models.js +61 -0
  239. package/dist/react/features/workspace/activity-dot.d.ts +15 -0
  240. package/dist/react/features/workspace/activity-dot.js +36 -0
  241. package/dist/react/features/workspace/app-sidebar.d.ts +16 -0
  242. package/dist/react/features/workspace/app-sidebar.js +227 -0
  243. package/dist/react/features/workspace/fixture-toggle.d.ts +2 -0
  244. package/dist/react/features/workspace/fixture-toggle.js +72 -0
  245. package/dist/react/features/workspace/folder-group.d.ts +18 -0
  246. package/dist/react/features/workspace/folder-group.js +83 -0
  247. package/dist/react/features/workspace/inline-name-input.d.ts +10 -0
  248. package/dist/react/features/workspace/inline-name-input.js +33 -0
  249. package/dist/react/features/workspace/link-repo-dialog.d.ts +9 -0
  250. package/dist/react/features/workspace/link-repo-dialog.js +76 -0
  251. package/dist/react/features/workspace/repo-chip.d.ts +13 -0
  252. package/dist/react/features/workspace/repo-chip.js +15 -0
  253. package/dist/react/features/workspace/session-row.d.ts +20 -0
  254. package/dist/react/features/workspace/session-row.js +23 -0
  255. package/dist/react/features/workspace/use-debounced.d.ts +2 -0
  256. package/dist/react/features/workspace/use-debounced.js +10 -0
  257. package/dist/react/features/workspace/workspace-context.d.ts +45 -0
  258. package/dist/react/features/workspace/workspace-context.js +245 -0
  259. package/dist/react/features/workspace/workspace-fixtures.d.ts +16 -0
  260. package/dist/react/features/workspace/workspace-fixtures.js +175 -0
  261. package/dist/react/features/workspace/workspace-tree.d.ts +30 -0
  262. package/dist/react/features/workspace/workspace-tree.js +69 -0
  263. package/dist/react/features/workspace/workspace.d.ts +107 -0
  264. package/dist/react/features/workspace/workspace.js +458 -0
  265. package/dist/react/index.d.ts +33 -0
  266. package/dist/react/index.js +35 -0
  267. package/dist/react/lib/cn.d.ts +6 -0
  268. package/dist/react/lib/cn.js +20 -0
  269. package/dist/react/lib/initials.d.ts +6 -0
  270. package/dist/react/lib/initials.js +32 -0
  271. package/dist/react/lib/json.d.ts +33 -0
  272. package/dist/react/lib/json.js +101 -0
  273. package/dist/react/lib/time.d.ts +8 -0
  274. package/dist/react/lib/time.js +57 -0
  275. package/dist/react/lib/use-media-query.d.ts +1 -0
  276. package/dist/react/lib/use-media-query.js +9 -0
  277. package/dist/react/lib/use-now.d.ts +2 -0
  278. package/dist/react/lib/use-now.js +10 -0
  279. package/dist/react/lib/use-width-bucket.d.ts +6 -0
  280. package/dist/react/lib/use-width-bucket.js +28 -0
  281. package/dist/react/parts/index.d.ts +43 -0
  282. package/dist/react/parts/index.js +43 -0
  283. package/dist/react/shuttle/device.d.ts +42 -0
  284. package/dist/react/shuttle/device.js +10 -0
  285. package/dist/react/shuttle/host.d.ts +1126 -0
  286. package/dist/react/shuttle/host.js +93 -0
  287. package/dist/react/shuttle/identity.d.ts +31 -0
  288. package/dist/react/shuttle/identity.js +20 -0
  289. package/dist/react/shuttle/index.d.ts +14 -0
  290. package/dist/react/shuttle/index.js +13 -0
  291. package/dist/react/shuttle/provider.d.ts +41 -0
  292. package/dist/react/shuttle/provider.js +59 -0
  293. package/dist/react/shuttle/router.d.ts +43 -0
  294. package/dist/react/shuttle/router.js +1 -0
  295. package/dist/react/theme.css +456 -0
  296. package/dist/react/ui.d.ts +19 -0
  297. package/dist/react/ui.js +19 -0
  298. package/package.json +100 -4
@@ -0,0 +1,35 @@
1
+ import { signedInAt } from '../connections/places.js';
2
+ /** The team a session has before anyone chooses one: Shuttle's own workers and nobody else. */
3
+ export const DEFAULT_TEAM = {
4
+ workers: true,
5
+ codex: false,
6
+ claudeCode: false,
7
+ cursor: false,
8
+ preset: 'none',
9
+ };
10
+ /** A team always has someone to do the work, and a preset needs both agents it names. */
11
+ export function withTeamChange(team, change) {
12
+ const next = { ...team, ...change };
13
+ const workers = next.workers || (!next.codex && !next.claudeCode && !next.cursor);
14
+ return { ...next, workers, preset: next.codex && next.claudeCode ? next.preset : 'none' };
15
+ }
16
+ /**
17
+ * Whether an agent can run where the session does. Where that place is unknown, or the agent's
18
+ * sign-in there cannot be checked from here, being signed in anywhere is enough.
19
+ */
20
+ export function canRunAt(connection, place) {
21
+ const there = place ? signedInAt(connection, place) : null;
22
+ return there ?? connection.connected;
23
+ }
24
+ /**
25
+ * The team as it will actually run: a saved team can name a vendor agent whose sign-in is gone,
26
+ * or was never this person's, and the worker leaves that agent out.
27
+ */
28
+ export function effectiveTeam(team, connections, place) {
29
+ const connected = new Set(connections.filter((entry) => canRunAt(entry, place)).map((entry) => entry.harness));
30
+ return withTeamChange(team, {
31
+ codex: team.codex && connected.has('codex'),
32
+ claudeCode: team.claudeCode && connected.has('claude-code'),
33
+ cursor: team.cursor && connected.has('cursor'),
34
+ });
35
+ }
@@ -0,0 +1,53 @@
1
+ import type { FeedItem } from './session-feed.js';
2
+ /** A thread and the threads under it, as far as the timeline needs to know them. */
3
+ export interface TimelineThread {
4
+ readonly threadId: string;
5
+ readonly children: readonly TimelineThread[];
6
+ }
7
+ /** Everything an agent and the agents under it did, folded into one row of the timeline. */
8
+ export interface DelegationRow {
9
+ readonly kind: 'delegation';
10
+ readonly id: string;
11
+ /** The delegated agent. Opening the row shows its own timeline. */
12
+ readonly threadId: string;
13
+ readonly seq: number;
14
+ readonly ts: number;
15
+ /** How many agents the work involved: the delegated one and any it delegated to in turn. */
16
+ readonly agents: number;
17
+ readonly toolCalls: number;
18
+ readonly failed: number;
19
+ readonly changedFiles: number;
20
+ /** The last thing the agent said. */
21
+ readonly lastText?: string;
22
+ }
23
+ export type TimelineRow = FeedItem | DelegationRow;
24
+ /** Each thread's parent, with `null` for the root. */
25
+ export declare function threadParents(root: TimelineThread | null): ReadonlyMap<string, string | null>;
26
+ /** The thread's ancestors from the top down, then the thread, leaving out the root. */
27
+ export declare function threadPath(threadId: string, parents: ReadonlyMap<string, string | null>): string[];
28
+ /**
29
+ * Whether a thread speaks for itself in a timeline, rather than being folded into a row or
30
+ * left out.
31
+ *
32
+ * The session's top level keeps the session's own thread and the agents directly under it: the
33
+ * one doing the work, and the ones that answer and route messages. An agent's own timeline
34
+ * keeps that agent alone.
35
+ *
36
+ * @param openThreadId The agent whose timeline is open. Left out, it is the top level.
37
+ */
38
+ export declare function threadSpeaks(threadId: string, parents: ReadonlyMap<string, string | null>, openThreadId?: string): boolean;
39
+ /**
40
+ * The rows a timeline shows: the session's top level, or one agent's own. Work by an agent that
41
+ * does not speak in it is folded into one row for the agent it was delegated to, placed where
42
+ * that work began.
43
+ *
44
+ * Questions for the reader are never folded at the top level: whoever asked, they need an
45
+ * answer.
46
+ */
47
+ export declare function projectTimeline(items: readonly FeedItem[], parents: ReadonlyMap<string, string | null>, openThreadId?: string): TimelineRow[];
48
+ /**
49
+ * The agent messages that say, word for word, what an earlier agent message in the session
50
+ * already said. The conversation folds these to one line, so the same notice sent in answer to
51
+ * several messages is read once.
52
+ */
53
+ export declare function repeatedMessages(items: readonly FeedItem[]): ReadonlySet<string>;
@@ -0,0 +1,153 @@
1
+ import { changedPaths } from '../artifacts/artifact-links.js';
2
+ /** Thoughts shorter than this are routine and say nothing, so the timeline leaves them out. */
3
+ const BRIEF_THOUGHT_MS = 2000;
4
+ /** Each thread's parent, with `null` for the root. */
5
+ export function threadParents(root) {
6
+ const parents = new Map();
7
+ function visit(node, parent) {
8
+ parents.set(node.threadId, parent);
9
+ for (const child of node.children) {
10
+ visit(child, node.threadId);
11
+ }
12
+ }
13
+ if (root) {
14
+ visit(root, null);
15
+ }
16
+ return parents;
17
+ }
18
+ /** The thread and its ancestors, nearest first, ending at the root. */
19
+ function lineage(threadId, parents) {
20
+ const chain = [];
21
+ let current = threadId;
22
+ while (current && !chain.includes(current)) {
23
+ chain.push(current);
24
+ current = parents.get(current);
25
+ }
26
+ return chain;
27
+ }
28
+ /** The thread's ancestors from the top down, then the thread, leaving out the root. */
29
+ export function threadPath(threadId, parents) {
30
+ return lineage(threadId, parents)
31
+ .filter((id) => parents.get(id) !== null)
32
+ .toReversed();
33
+ }
34
+ /**
35
+ * Whether a thread speaks for itself in a timeline, rather than being folded into a row or
36
+ * left out.
37
+ *
38
+ * The session's top level keeps the session's own thread and the agents directly under it: the
39
+ * one doing the work, and the ones that answer and route messages. An agent's own timeline
40
+ * keeps that agent alone.
41
+ *
42
+ * @param openThreadId The agent whose timeline is open. Left out, it is the top level.
43
+ */
44
+ export function threadSpeaks(threadId, parents, openThreadId) {
45
+ if (openThreadId !== undefined) {
46
+ return threadId === openThreadId;
47
+ }
48
+ // A thread the tree has not reported yet is shown rather than lost.
49
+ return !parents.has(threadId) || lineage(threadId, parents).length <= 2;
50
+ }
51
+ function itemThreadId(item) {
52
+ return item.kind === 'user' ? undefined : item.threadId;
53
+ }
54
+ /**
55
+ * The rows a timeline shows: the session's top level, or one agent's own. Work by an agent that
56
+ * does not speak in it is folded into one row for the agent it was delegated to, placed where
57
+ * that work began.
58
+ *
59
+ * Questions for the reader are never folded at the top level: whoever asked, they need an
60
+ * answer.
61
+ */
62
+ export function projectTimeline(items, parents, openThreadId) {
63
+ const rows = [];
64
+ const folded = new Map();
65
+ const top = openThreadId === undefined;
66
+ for (const item of items) {
67
+ const threadId = itemThreadId(item);
68
+ if (threadId === undefined) {
69
+ // Messages from people, and notices about the session, belong to the top level.
70
+ if (top) {
71
+ rows.push(item);
72
+ }
73
+ continue;
74
+ }
75
+ // Questions need an answer and shared files are meant to be seen, whoever they came from.
76
+ const surfaced = top && (item.kind === 'question' || item.kind === 'media');
77
+ if (threadSpeaks(threadId, parents, openThreadId) || surfaced) {
78
+ if (item.kind === 'thought' && (item.durationMs ?? 0) < BRIEF_THOUGHT_MS) {
79
+ continue;
80
+ }
81
+ rows.push(item);
82
+ continue;
83
+ }
84
+ // The agent this work was delegated to: the one just below a thread that speaks here.
85
+ const chain = lineage(threadId, parents);
86
+ const speaker = chain.findIndex((id, index) => index > 0 && threadSpeaks(id, parents, openThreadId));
87
+ const delegate = speaker > 0 ? chain[speaker - 1] : undefined;
88
+ if (!delegate) {
89
+ continue;
90
+ }
91
+ let fold = folded.get(delegate);
92
+ if (!fold) {
93
+ fold = { index: rows.length, threads: new Set() };
94
+ folded.set(delegate, fold);
95
+ rows.push({
96
+ kind: 'delegation',
97
+ id: `delegation_${delegate}`,
98
+ threadId: delegate,
99
+ seq: item.seq,
100
+ ts: item.ts,
101
+ agents: 0,
102
+ toolCalls: 0,
103
+ failed: 0,
104
+ changedFiles: 0,
105
+ });
106
+ }
107
+ fold.threads.add(threadId);
108
+ const row = rows[fold.index];
109
+ if (row?.kind !== 'delegation') {
110
+ continue;
111
+ }
112
+ rows[fold.index] = {
113
+ ...row,
114
+ agents: fold.threads.size,
115
+ ...(item.kind === 'tools'
116
+ ? {
117
+ toolCalls: row.toolCalls + item.calls.length,
118
+ failed: row.failed + item.calls.filter((call) => call.status === 'error').length,
119
+ changedFiles: row.changedFiles + changedPaths(item.calls).length,
120
+ }
121
+ : {}),
122
+ ...(item.kind === 'agent' && threadId === delegate ? { lastText: item.text } : {}),
123
+ };
124
+ }
125
+ return rows;
126
+ }
127
+ /** Shorter messages than this ("Done.", "On it.") repeat naturally and are left alone. */
128
+ const MIN_REPEAT_LENGTH = 24;
129
+ /**
130
+ * The agent messages that say, word for word, what an earlier agent message in the session
131
+ * already said. The conversation folds these to one line, so the same notice sent in answer to
132
+ * several messages is read once.
133
+ */
134
+ export function repeatedMessages(items) {
135
+ const said = new Set();
136
+ const repeats = new Set();
137
+ for (const item of items) {
138
+ if (item.kind !== 'agent') {
139
+ continue;
140
+ }
141
+ const text = item.text.replace(/\s+/g, ' ').trim();
142
+ if (text.length < MIN_REPEAT_LENGTH) {
143
+ continue;
144
+ }
145
+ if (said.has(text)) {
146
+ repeats.add(item.id);
147
+ }
148
+ else {
149
+ said.add(text);
150
+ }
151
+ }
152
+ return repeats;
153
+ }
@@ -0,0 +1,18 @@
1
+ import { type ArtifactType } from '../artifacts/artifact-types.js';
2
+ import { type ArtifactTabKind, type SessionTabSet } from '../workspace/workspace.js';
3
+ export interface SessionTabsController {
4
+ readonly tabs: SessionTabSet;
5
+ readonly activeTabId: string | null;
6
+ readonly setActiveTabId: (tabId: string) => void;
7
+ readonly openTab: (input: {
8
+ kind: ArtifactTabKind;
9
+ title?: string;
10
+ target?: string;
11
+ tabId?: string;
12
+ }) => Promise<string>;
13
+ readonly closeTab: (tabId: string) => Promise<void>;
14
+ readonly reorderTabs: (tabIds: string[]) => Promise<void>;
15
+ readonly retargetTab: (tabId: string, title: string, target: string) => Promise<void>;
16
+ readonly focusKind: (kind: ArtifactTabKind) => Promise<string>;
17
+ }
18
+ export declare function useSessionTabs(sessionRunId: string, types?: readonly ArtifactType[]): SessionTabsController;
@@ -0,0 +1,119 @@
1
+ import { useCallback, useEffect, useRef, useState } from 'react';
2
+ import { isCustomArtifactTabKind } from '@swirls/shuttle/api';
3
+ import { useShuttleHost } from '../../shuttle/index.js';
4
+ import { artifactTypeFor, defaultArtifactTypes, } from '../artifacts/artifact-types.js';
5
+ import { closeSessionTab, openSessionTab, reorderSessionTabs, retargetSessionTab, } from '../workspace/workspace.js';
6
+ import { useOptionalWorkspace } from '../workspace/workspace-context.js';
7
+ import { applyPendingOps, neighborAfterClose, prunePendingOps, readActiveTabId, resolveActiveTabId, resolveTabSet, singletonTabId, tabTitleForKind, writeActiveTabId, } from './session-tabs.js';
8
+ export function useSessionTabs(sessionRunId, types = defaultArtifactTypes) {
9
+ const host = useShuttleHost();
10
+ // With no workspace above, nothing keeps the tabs: they last as long as the page does.
11
+ const workspace = useOptionalWorkspace();
12
+ const projected = workspace?.tabs[sessionRunId];
13
+ const [pendingRaw, setPendingRaw] = useState([]);
14
+ const [activeByRun, setActiveByRun] = useState({});
15
+ const pending = prunePendingOps(projected, pendingRaw);
16
+ // Clear absorbed optimistic ops during render (React-approved props→state adjust).
17
+ if (pending.length === 0 && pendingRaw.length > 0) {
18
+ setPendingRaw([]);
19
+ }
20
+ const base = resolveTabSet(projected);
21
+ const tabs = applyPendingOps(base, pending);
22
+ const preferred = activeByRun[sessionRunId] ?? readActiveTabId(sessionRunId);
23
+ const resolvedActive = resolveActiveTabId(tabs, preferred);
24
+ // Keep latest tabs in a ref so open/close callbacks stay identity-stable.
25
+ // Otherwise effects that depend on them re-run every render.
26
+ const tabsRef = useRef(tabs);
27
+ const preferredRef = useRef(preferred);
28
+ const resolvedActiveRef = useRef(resolvedActive);
29
+ useEffect(() => {
30
+ tabsRef.current = tabs;
31
+ preferredRef.current = preferred;
32
+ resolvedActiveRef.current = resolvedActive;
33
+ }, [tabs, preferred, resolvedActive]);
34
+ const setActiveTabId = useCallback((tabId) => {
35
+ setActiveByRun((prev) => ({ ...prev, [sessionRunId]: tabId }));
36
+ writeActiveTabId(sessionRunId, tabId);
37
+ }, [sessionRunId]);
38
+ const openTab = useCallback(async (input) => {
39
+ const current = tabsRef.current;
40
+ const type = isCustomArtifactTabKind(input.kind)
41
+ ? artifactTypeFor(types, input.kind)
42
+ : undefined;
43
+ // One of the host's kinds says for itself whether it has one tab, and what to call it.
44
+ const singleton = type?.single ? input.kind : singletonTabId(input.kind);
45
+ if (singleton && current.tabs[singleton]) {
46
+ setActiveTabId(singleton);
47
+ return singleton;
48
+ }
49
+ const tabId = input.tabId ?? singleton ?? crypto.randomUUID();
50
+ const target = input.target ?? '';
51
+ const title = input.title ?? type?.title?.(target) ?? type?.label ?? tabTitleForKind(input.kind, target);
52
+ const tab = {
53
+ tabId,
54
+ kind: input.kind,
55
+ title,
56
+ target,
57
+ openedAt: Date.now(),
58
+ };
59
+ setPendingRaw((prev) => [...prev, { kind: 'open', tab }]);
60
+ setActiveTabId(tabId);
61
+ if (workspace) {
62
+ await openSessionTab(host, workspace.listingRunId(sessionRunId), {
63
+ runId: sessionRunId,
64
+ tabId,
65
+ kind: input.kind,
66
+ title,
67
+ target,
68
+ at: tab.openedAt,
69
+ });
70
+ }
71
+ return tabId;
72
+ }, [host, sessionRunId, setActiveTabId, types, workspace]);
73
+ const closeTab = useCallback(async (tabId) => {
74
+ const current = tabsRef.current;
75
+ const nextActive = neighborAfterClose(current.order, tabId);
76
+ setPendingRaw((prev) => [...prev, { kind: 'close', tabId }]);
77
+ if (preferredRef.current === tabId || resolvedActiveRef.current === tabId) {
78
+ setActiveByRun((prev) => ({ ...prev, [sessionRunId]: nextActive }));
79
+ writeActiveTabId(sessionRunId, nextActive);
80
+ }
81
+ if (workspace) {
82
+ await closeSessionTab(host, workspace.listingRunId(sessionRunId), {
83
+ runId: sessionRunId,
84
+ tabId,
85
+ });
86
+ }
87
+ }, [host, sessionRunId, workspace]);
88
+ const reorderTabs = useCallback(async (tabIds) => {
89
+ setPendingRaw((prev) => [...prev, { kind: 'reorder', tabIds }]);
90
+ if (workspace) {
91
+ await reorderSessionTabs(host, workspace.listingRunId(sessionRunId), {
92
+ runId: sessionRunId,
93
+ tabIds,
94
+ });
95
+ }
96
+ }, [host, sessionRunId, workspace]);
97
+ const retargetTab = useCallback(async (tabId, title, target) => {
98
+ setPendingRaw((prev) => [...prev, { kind: 'retarget', tabId, title, target }]);
99
+ if (workspace) {
100
+ await retargetSessionTab(host, workspace.listingRunId(sessionRunId), {
101
+ runId: sessionRunId,
102
+ tabId,
103
+ title,
104
+ target,
105
+ });
106
+ }
107
+ }, [host, sessionRunId, workspace]);
108
+ const focusKind = useCallback(async (kind) => openTab({ kind }), [openTab]);
109
+ return {
110
+ tabs,
111
+ activeTabId: resolvedActive,
112
+ setActiveTabId,
113
+ openTab,
114
+ closeTab,
115
+ reorderTabs,
116
+ retargetTab,
117
+ focusKind,
118
+ };
119
+ }
@@ -0,0 +1,23 @@
1
+ import type { HarnessId, Team, VendorHarnessId, VendorModel, VendorModelChoice } from '@swirls/shuttle/api';
2
+ /**
3
+ * Whose models the picker offers. `openrouter` is Shuttle's own loop (the conductor and its
4
+ * workers); the others are vendor agents, which run on the developer's subscription.
5
+ */
6
+ export type ModelSection = 'openrouter' | VendorHarnessId;
7
+ /**
8
+ * What to call a section. An agent reached over the Agent Client Protocol has no name of its own
9
+ * here, so it goes by the one its deployment gave it: `acp:gemini` reads as "gemini".
10
+ */
11
+ export declare function sectionLabel(section: ModelSection): string;
12
+ /**
13
+ * The sections that matter for a session: the one agent running it, or, for a Shuttle session,
14
+ * Shuttle's own models followed by each vendor agent on its team.
15
+ */
16
+ export declare function modelSections(harness: HarnessId, team: Team): ModelSection[];
17
+ export declare function effortLabel(effort: string): string;
18
+ /** The model a choice runs on: the chosen one, else the one the agent uses by default. */
19
+ export declare function chosenVendorModel(choice: VendorModelChoice | undefined, models: readonly VendorModel[]): VendorModel | undefined;
20
+ /** Short text for a choice, such as "GPT-6.1-Sol · High". */
21
+ export declare function vendorChoiceLabel(choice: VendorModelChoice | undefined, models: readonly VendorModel[]): string;
22
+ /** Moves a choice to another model, keeping the effort only when the new model accepts it. */
23
+ export declare function withVendorModel(choice: VendorModelChoice | undefined, model: VendorModel | undefined, defaultModel: VendorModel | undefined): VendorModelChoice;
@@ -0,0 +1,61 @@
1
+ const BUILT_IN_LABELS = {
2
+ openrouter: 'Shuttle',
3
+ codex: 'Codex',
4
+ 'claude-code': 'Claude Code',
5
+ cursor: 'Cursor',
6
+ };
7
+ function isBuiltInSection(section) {
8
+ return section in BUILT_IN_LABELS;
9
+ }
10
+ /**
11
+ * What to call a section. An agent reached over the Agent Client Protocol has no name of its own
12
+ * here, so it goes by the one its deployment gave it: `acp:gemini` reads as "gemini".
13
+ */
14
+ export function sectionLabel(section) {
15
+ return isBuiltInSection(section) ? BUILT_IN_LABELS[section] : section.replace(/^acp:/, '');
16
+ }
17
+ /**
18
+ * The sections that matter for a session: the one agent running it, or, for a Shuttle session,
19
+ * Shuttle's own models followed by each vendor agent on its team.
20
+ */
21
+ export function modelSections(harness, team) {
22
+ if (harness !== 'shuttle') {
23
+ return [harness];
24
+ }
25
+ return [
26
+ 'openrouter',
27
+ ...(team.codex ? ['codex'] : []),
28
+ ...(team.claudeCode ? ['claude-code'] : []),
29
+ ...(team.cursor ? ['cursor'] : []),
30
+ ];
31
+ }
32
+ const EFFORT_LABELS = {
33
+ minimal: 'Minimal',
34
+ low: 'Low',
35
+ medium: 'Medium',
36
+ high: 'High',
37
+ xhigh: 'Extra High',
38
+ max: 'Max',
39
+ ultra: 'Ultra',
40
+ };
41
+ export function effortLabel(effort) {
42
+ return EFFORT_LABELS[effort] ?? effort.charAt(0).toUpperCase() + effort.slice(1);
43
+ }
44
+ /** The model a choice runs on: the chosen one, else the one the agent uses by default. */
45
+ export function chosenVendorModel(choice, models) {
46
+ return choice?.model
47
+ ? models.find((model) => model.id === choice.model)
48
+ : models.find((model) => model.isDefault);
49
+ }
50
+ /** Short text for a choice, such as "GPT-6.1-Sol · High". */
51
+ export function vendorChoiceLabel(choice, models) {
52
+ const model = chosenVendorModel(choice, models);
53
+ const name = model?.label ?? choice?.model ?? 'Default model';
54
+ return choice?.effort ? `${name} · ${effortLabel(choice.effort)}` : name;
55
+ }
56
+ /** Moves a choice to another model, keeping the effort only when the new model accepts it. */
57
+ export function withVendorModel(choice, model, defaultModel) {
58
+ const efforts = (model ?? defaultModel)?.efforts ?? [];
59
+ const effort = choice?.effort && efforts.includes(choice.effort) ? choice.effort : undefined;
60
+ return { ...(model ? { model: model.id } : {}), ...(effort ? { effort } : {}) };
61
+ }
@@ -0,0 +1,15 @@
1
+ import { type SessionIndicatorTone } from '../sessions/session-activity.js';
2
+ type ActivityDotProps = {
3
+ readonly tone: SessionIndicatorTone;
4
+ readonly label?: string;
5
+ readonly className?: string;
6
+ } | {
7
+ readonly tone?: undefined;
8
+ readonly activity: string;
9
+ readonly status: string;
10
+ readonly unread?: boolean;
11
+ readonly label?: string;
12
+ readonly className?: string;
13
+ };
14
+ export declare function ActivityDot(props: ActivityDotProps): import("react").JSX.Element;
15
+ export {};
@@ -0,0 +1,36 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { cn } from '../../lib/cn.js';
3
+ import { resolveSessionIndicator, sessionIndicatorLabel, } from '../sessions/session-activity.js';
4
+ function IndicatorGlyph({ tone }) {
5
+ switch (tone) {
6
+ case 'starting':
7
+ case 'working':
8
+ return (_jsxs("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, className: "text-brand spinner-ring size-3", children: [_jsx("circle", { cx: "8", cy: "8", r: "5.5", stroke: "currentColor", strokeOpacity: "0.22", strokeWidth: "1.75" }), _jsx("path", { d: "M8 2.5a5.5 5.5 0 0 1 5.5 5.5", stroke: "currentColor", strokeWidth: "1.75", strokeLinecap: "round" })] }));
9
+ case 'needs_input':
10
+ return (_jsxs("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, className: "text-status-waiting size-3", children: [_jsx("circle", { cx: "8", cy: "8", r: "5.75", stroke: "currentColor", strokeOpacity: "0.6", strokeWidth: "1.5" }), _jsx("circle", { cx: "8", cy: "8", r: "2.65", fill: "currentColor" })] }));
11
+ case 'ready':
12
+ return (_jsxs("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, className: "text-status-completed size-3", children: [_jsx("circle", { cx: "8", cy: "8", r: "5.75", stroke: "currentColor", strokeOpacity: "0.55", strokeWidth: "1.5" }), _jsx("path", { d: "M5.5 8.1 7.2 9.8 10.6 6.3", stroke: "currentColor", strokeWidth: "1.65", strokeLinecap: "round", strokeLinejoin: "round" })] }));
13
+ case 'failed':
14
+ return (_jsxs("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, className: "text-status-failed size-3", children: [_jsx("circle", { cx: "8", cy: "8", r: "5.75", stroke: "currentColor", strokeOpacity: "0.6", strokeWidth: "1.5" }), _jsx("path", { d: "M8 5.2v3.3", stroke: "currentColor", strokeWidth: "1.65", strokeLinecap: "round" }), _jsx("circle", { cx: "8", cy: "10.9", r: "0.9", fill: "currentColor" })] }));
15
+ case 'idle':
16
+ return (_jsx("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, className: "text-muted-foreground/40 size-3", children: _jsx("circle", { cx: "8", cy: "8", r: "4.75", stroke: "currentColor", strokeWidth: "1.5" }) }));
17
+ case 'completed':
18
+ return (_jsxs("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, className: "text-muted-foreground/55 size-3", children: [_jsx("circle", { cx: "8", cy: "8", r: "5.25", stroke: "currentColor", strokeOpacity: "0.5", strokeWidth: "1.5" }), _jsx("path", { d: "M5.75 8.1 7.3 9.65 10.4 6.5", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" })] }));
19
+ case 'cancelled':
20
+ return (_jsxs("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, className: "text-muted-foreground/40 size-3", children: [_jsx("circle", { cx: "8", cy: "8", r: "5.25", stroke: "currentColor", strokeWidth: "1.5" }), _jsx("path", { d: "M4.5 11.5 11.5 4.5", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" })] }));
21
+ default: {
22
+ const exhaustive = tone;
23
+ return exhaustive;
24
+ }
25
+ }
26
+ }
27
+ export function ActivityDot(props) {
28
+ const tone = props.tone ??
29
+ resolveSessionIndicator({
30
+ activity: props.activity,
31
+ status: props.status,
32
+ unread: props.unread,
33
+ });
34
+ const label = props.label ?? sessionIndicatorLabel(tone);
35
+ return (_jsx("span", { role: "img", "aria-label": label, title: label, className: cn('inline-flex size-3.5 shrink-0 items-center justify-center', props.className), children: _jsx(IndicatorGlyph, { tone: tone }) }));
36
+ }
@@ -0,0 +1,16 @@
1
+ /** What a host puts into the sidebar that is its own. Each is left out when not given. */
2
+ export interface SidebarSlots {
3
+ /** Above the GitHub footer: something about where sessions run, such as this machine. */
4
+ readonly status?: React.ReactNode;
5
+ /** At the very bottom: who is signed in, and the way out. */
6
+ readonly account?: React.ReactNode;
7
+ }
8
+ /**
9
+ * The frame Shuttle's pages sit in: the workspace's folders and sessions down the side, and
10
+ * the page beside them. It follows the workspace, so everything inside can read it.
11
+ */
12
+ export declare function AppSidebarShell({ children, status, account, background, }: SidebarSlots & {
13
+ children: React.ReactNode;
14
+ /** Things that draw nothing but need the workspace, such as a badge on the app's icon. */
15
+ background?: React.ReactNode;
16
+ }): import("react").JSX.Element;