@swirls/shuttle 0.0.0-stage → 0.1.0

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 +10 -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 +64 -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,8 @@
1
+ import { type SessionFeed } from './session-feed.js';
2
+ /**
3
+ * The brief the agents are working from, as one chip under the composer. Its sheet also holds
4
+ * the playbook lessons the session started with. The version shows only once it was amended.
5
+ */
6
+ export declare function SessionContextButtons({ feed }: {
7
+ feed: SessionFeed;
8
+ }): import("react").JSX.Element | null;
@@ -0,0 +1,98 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useQuery } from '@tanstack/react-query';
3
+ import { ArrowRight, BookOpen, FileText, LoaderCircle } from 'lucide-react';
4
+ import { useMemo, useState } from 'react';
5
+ import { Markdown } from '../../components/markdown.js';
6
+ import { Badge } from '../../components/ui/badge.js';
7
+ import { Button } from '../../components/ui/button.js';
8
+ import { EmptyState } from '../../components/ui/panel.js';
9
+ import { Sheet, SheetContent, SheetDescription, SheetTitle } from '../../components/ui/sheet.js';
10
+ import { Tabs, TabsContent, TabsList, TabsTrigger } from '../../components/ui/tabs.js';
11
+ import { cn, shortId } from '../../lib/cn.js';
12
+ import { fullDateTime, relativeTime } from '../../lib/time.js';
13
+ import { useNow } from '../../lib/use-now.js';
14
+ import { Link, useShuttleHost } from '../../shuttle/index.js';
15
+ import { playbookQuery } from '../playbook/playbook-query.js';
16
+ import { currentBrief, } from './session-feed.js';
17
+ const QUOTE_MAX = 140;
18
+ function isContextTab(value) {
19
+ return value === 'brief' || value === 'playbook';
20
+ }
21
+ function lessonCountLabel(count) {
22
+ return count === 1 ? '1 lesson' : `${count} lessons`;
23
+ }
24
+ function quote(text) {
25
+ const chars = Array.from(text.replace(/\s+/g, ' ').trim());
26
+ return chars.length > QUOTE_MAX ? `${chars.slice(0, QUOTE_MAX - 1).join('')}…` : chars.join('');
27
+ }
28
+ /**
29
+ * The brief the agents are working from, as one chip under the composer. Its sheet also holds
30
+ * the playbook lessons the session started with. The version shows only once it was amended.
31
+ */
32
+ export function SessionContextButtons({ feed }) {
33
+ const host = useShuttleHost();
34
+ const [open, setOpen] = useState(false);
35
+ const [tab, setTab] = useState('brief');
36
+ const brief = currentBrief(feed);
37
+ const lessons = feed.playbook.lessons;
38
+ // Read only once the playbook tab is showing lessons to say more about.
39
+ const playbook = useQuery({
40
+ ...playbookQuery(host),
41
+ enabled: open && tab === 'playbook' && lessons.length > 0,
42
+ });
43
+ const liveLessons = useMemo(() => new Map((playbook.data?.playbook.lessons ?? []).map((lesson) => [lesson.id, lesson])), [playbook.data]);
44
+ const live = playbook.data
45
+ ? { state: 'ready', lessons: liveLessons }
46
+ : playbook.isFetching
47
+ ? { state: 'loading' }
48
+ : playbook.error
49
+ ? { state: 'failed', error: playbook.error.message }
50
+ : { state: 'idle' };
51
+ function show(next) {
52
+ setTab(next);
53
+ setOpen(true);
54
+ }
55
+ if (!brief) {
56
+ return null;
57
+ }
58
+ return (_jsxs(_Fragment, { children: [_jsxs(Button, { variant: "ghost", size: "sm", onClick: () => show('brief'), title: "Brief", "aria-label": lessons.length > 0
59
+ ? `Brief, with ${lessonCountLabel(lessons.length)} from the playbook`
60
+ : 'Brief', children: [_jsx(FileText, {}), _jsx("span", { className: "hidden @md:inline", children: "Brief" }), feed.brief.length > 1 ? (_jsxs("span", { className: "text-route-idea font-mono text-[10px] tabular-nums", children: ["v", brief.version] })) : null] }), _jsx(Sheet, { open: open, onOpenChange: setOpen, children: _jsx(SheetContent, { children: _jsxs(Tabs, { value: tab, onValueChange: (value) => {
61
+ if (isContextTab(value)) {
62
+ show(value);
63
+ }
64
+ }, className: "min-h-0 flex-1 gap-0", children: [_jsxs("div", { className: "border-b px-5 pt-5 pb-4", children: [_jsx(SheetTitle, { className: "pr-8", children: "Session context" }), _jsx(SheetDescription, { className: "mt-1 pr-8", children: "What the conductor and its workers were told to work from." }), _jsxs(TabsList, { className: "mt-4", children: [_jsxs(TabsTrigger, { value: "brief", children: [_jsx(FileText, {}), "Brief"] }), _jsxs(TabsTrigger, { value: "playbook", children: [_jsx(BookOpen, {}), "Playbook", _jsx("span", { className: "text-muted-foreground font-mono text-[10px] tabular-nums", children: lessons.length })] })] })] }), _jsx(TabsContent, { value: "brief", className: "overflow-y-auto overscroll-contain", children: _jsx(BriefHistory, { current: brief, feed: feed }) }), _jsx(TabsContent, { value: "playbook", className: "overflow-y-auto overscroll-contain", children: _jsx(PlaybookLessons, { version: feed.playbook.version, lessons: lessons, live: live, onRetry: () => void playbook.refetch() }) })] }) }) })] }));
65
+ }
66
+ function BriefHistory({ current, feed }) {
67
+ const now = useNow();
68
+ const earlier = feed.brief
69
+ .filter((revision) => revision.version !== current.version)
70
+ .toSorted((left, right) => right.version - left.version);
71
+ const trigger = current.sourceMessageId ? feed.messageText[current.sourceMessageId] : undefined;
72
+ return (_jsxs("div", { className: "flex flex-col gap-6 p-5", children: [_jsxs("section", { children: [_jsx(RevisionMeta, { revision: current, label: earlier.length > 0 ? 'Current' : 'Original goal', now: now, emphasis: true }), _jsx("p", { dir: "auto", className: "bg-card mt-2 rounded-xl border p-4 text-[13px] leading-relaxed wrap-anywhere whitespace-pre-wrap", children: current.text }), trigger ? (_jsxs("p", { className: "text-muted-foreground mt-2 text-xs leading-relaxed wrap-anywhere", children: ["Amended after you said ", _jsxs("span", { className: "text-foreground/80", children: ["\u201C", quote(trigger), "\u201D"] })] })) : null] }), earlier.length > 0 ? (_jsxs("section", { children: [_jsx("h3", { className: "text-muted-foreground mb-3 text-[11px] font-medium", children: "Earlier versions" }), _jsx("ol", { className: "ml-1 flex flex-col gap-4 border-l pl-4", children: earlier.map((revision) => (_jsxs("li", { children: [_jsx(RevisionMeta, { revision: revision, label: revision.version === 1 ? 'Original goal' : 'Amended', now: now }), _jsx("p", { dir: "auto", className: "text-muted-foreground mt-1 line-clamp-4 text-xs leading-relaxed wrap-anywhere whitespace-pre-wrap", title: revision.text, children: revision.text })] }, revision.version))) })] })) : null] }));
73
+ }
74
+ function RevisionMeta({ revision, label, now, emphasis = false, }) {
75
+ return (_jsxs("div", { className: "flex items-center gap-1.5 text-[11px]", children: [_jsx("span", { className: cn('font-medium', emphasis ? 'text-foreground' : 'text-muted-foreground'), children: label }), _jsxs("span", { className: "text-muted-foreground font-mono tabular-nums", children: ["v", revision.version] }), _jsx("span", { className: "text-muted-foreground/60", children: "\u00B7" }), _jsx("time", { className: "text-muted-foreground", dateTime: new Date(revision.ts).toISOString(), title: fullDateTime(revision.ts), children: relativeTime(revision.ts, now) })] }));
76
+ }
77
+ function PlaybookLessons({ version, lessons, live, onRetry, }) {
78
+ if (lessons.length === 0) {
79
+ return (_jsxs("div", { className: "flex flex-col items-center gap-3 p-5", children: [_jsx(EmptyState, { icon: _jsx(BookOpen, {}), title: "No lessons loaded", className: "h-auto", children: "This session started from an empty playbook. When sessions go idle, the reflector proposes lessons, and approved ones ship with the next session." }), _jsx(OpenPlaybookLink, {})] }));
80
+ }
81
+ return (_jsxs("div", { className: "flex flex-col gap-3 p-5", children: [_jsxs("div", { className: "text-muted-foreground flex items-center gap-2 text-xs", children: [_jsxs("span", { children: [lessonCountLabel(lessons.length), " from playbook", ' ', _jsxs("span", { className: "font-mono tabular-nums", children: ["v", version] }), ", loaded when this session started."] }), live.state === 'loading' ? (_jsx(LoaderCircle, { "aria-label": "Loading lesson details", className: "size-3 animate-spin" })) : null] }), live.state === 'failed' ? (_jsxs("p", { className: "text-status-failed text-xs", children: ["Couldn\u2019t load lesson details. ", live.error, ' ', _jsx("button", { type: "button", className: "underline underline-offset-2", onClick: onRetry, children: "Retry" })] })) : null, _jsx("ul", { className: "flex flex-col gap-2", children: lessons.map((lesson) => (_jsx(LessonCard, { lesson: lesson, detail: live.state === 'ready' ? (live.lessons.get(lesson.id) ?? null) : undefined }, lesson.id))) }), _jsx(OpenPlaybookLink, {})] }));
82
+ }
83
+ function LessonCard({ lesson, detail, }) {
84
+ const scope = lesson.scope ?? detail?.scope;
85
+ const retired = detail === null;
86
+ const sources = evidenceByRun(detail?.evidence ?? []);
87
+ return (_jsxs("li", { className: "bg-card/60 rounded-xl border p-3.5", children: [_jsx(Markdown, { text: lesson.text, className: "text-[13px] leading-relaxed wrap-anywhere" }), scope || retired || sources.length > 0 ? (_jsxs("div", { className: "mt-3 flex flex-wrap items-center gap-1.5", children: [scope ? _jsx(Badge, { variant: "outline", children: scope }) : null, retired ? (_jsx(Badge, { variant: "outline", className: "text-status-waiting", title: "No longer in the active playbook", children: "Retired since" })) : null, sources.length > 0 ? (_jsxs("span", { className: "text-muted-foreground ml-auto flex flex-wrap items-center justify-end gap-1.5 text-[11px]", children: ["Learned from", sources.map(({ runId, seqs }) => (_jsxs(Link, { to: { page: 'session', sessionId: runId }, className: "hover:text-foreground hover:bg-accent inline-flex h-5 items-center gap-1 rounded-full border px-2 transition-colors duration-100", title: `${runId}\nEvents ${seqs.map((seq) => `#${seq}`).join(', ')}`, children: [_jsx("span", { className: "font-mono text-[10px]", children: shortId(runId) }), seqs.length > 1 ? (_jsxs("span", { className: "text-muted-foreground/70 text-[10px] tabular-nums", children: ["\u00D7", seqs.length] })) : null] }, runId)))] })) : null] })) : null] }));
88
+ }
89
+ function evidenceByRun(evidence) {
90
+ const byRun = new Map();
91
+ for (const item of evidence) {
92
+ byRun.set(item.runId, [...(byRun.get(item.runId) ?? []), item.seq]);
93
+ }
94
+ return [...byRun].map(([runId, seqs]) => ({ runId, seqs: seqs.toSorted((a, b) => a - b) }));
95
+ }
96
+ function OpenPlaybookLink() {
97
+ return (_jsx(Button, { variant: "ghost", size: "sm", className: "self-start", asChild: true, children: _jsxs(Link, { to: { page: 'playbook' }, children: ["Open playbook", _jsx(ArrowRight, {})] }) }));
98
+ }
@@ -0,0 +1,243 @@
1
+ import type { JsonValue, ProjectionDefinition } from '@swirls/looms/core';
2
+ import type { LiveFoldDefinition } from '@swirls/looms/react';
3
+ import type { SessionEvent } from '../events/event-catalog.js';
4
+ import { type MediaAsset, type SessionMedia } from './media.js';
5
+ export declare const interjectionKinds: readonly ['question', 'idea', 'constraint', 'correction', 'task', 'stop'];
6
+ export type InterjectionKind = (typeof interjectionKinds)[number];
7
+ export declare function isInterjectionKind(value: string | undefined): value is InterjectionKind;
8
+ export interface RouteDelivery {
9
+ readonly threadId: string;
10
+ readonly interrupt: boolean;
11
+ }
12
+ export interface RouteInfo {
13
+ readonly kind: InterjectionKind;
14
+ readonly summary: string;
15
+ readonly targetThreadId: string | null;
16
+ readonly briefVersion?: number;
17
+ }
18
+ export interface ToolCallItem {
19
+ readonly toolCallId: string;
20
+ readonly name: string;
21
+ readonly args: JsonValue;
22
+ readonly seq: number;
23
+ readonly status: 'running' | 'ok' | 'error';
24
+ readonly startedAt?: number;
25
+ readonly result?: JsonValue;
26
+ readonly error?: string;
27
+ }
28
+ export interface ThoughtInfo {
29
+ readonly id: string;
30
+ readonly text: string;
31
+ readonly durationMs?: number;
32
+ readonly seq: number;
33
+ readonly ts: number;
34
+ readonly turn: number;
35
+ }
36
+ export type ActivityStep = {
37
+ readonly kind: 'thought';
38
+ readonly thought: ThoughtInfo;
39
+ } | {
40
+ readonly kind: 'call';
41
+ readonly call: ToolCallItem;
42
+ };
43
+ export type FeedItem = {
44
+ readonly kind: 'user';
45
+ readonly id: string;
46
+ readonly seq: number;
47
+ readonly ts: number;
48
+ readonly messageId: string;
49
+ readonly text: string;
50
+ readonly goal: boolean;
51
+ readonly forced?: InterjectionKind;
52
+ /** Who sent it. Absent on the goal and on messages from before people signed in. */
53
+ readonly author?: MessageAuthor;
54
+ /** Files sent with the message. */
55
+ readonly attachments?: readonly MediaAsset[];
56
+ } | {
57
+ /** Files an agent shared for the people in the session to see. */
58
+ readonly kind: 'media';
59
+ readonly id: string;
60
+ readonly seq: number;
61
+ readonly ts: number;
62
+ readonly threadId: string;
63
+ readonly assets: readonly MediaAsset[];
64
+ } | {
65
+ readonly kind: 'agent';
66
+ readonly id: string;
67
+ readonly seq: number;
68
+ readonly ts: number;
69
+ readonly threadId: string;
70
+ readonly text: string;
71
+ readonly replyTo?: string;
72
+ readonly thought?: ThoughtInfo;
73
+ } | {
74
+ readonly kind: 'thought';
75
+ readonly id: string;
76
+ readonly seq: number;
77
+ readonly ts: number;
78
+ readonly threadId: string;
79
+ readonly turn: number;
80
+ readonly text: string;
81
+ readonly durationMs?: number;
82
+ } | {
83
+ readonly kind: 'tools';
84
+ readonly id: string;
85
+ readonly seq: number;
86
+ readonly ts: number;
87
+ readonly threadId: string;
88
+ readonly calls: readonly ToolCallItem[];
89
+ readonly thoughts: readonly ThoughtInfo[];
90
+ readonly steps: readonly ActivityStep[];
91
+ } | {
92
+ readonly kind: 'question';
93
+ readonly id: string;
94
+ readonly seq: number;
95
+ readonly ts: number;
96
+ readonly threadId: string;
97
+ readonly approvalId: string;
98
+ readonly title: string;
99
+ readonly thought?: ThoughtInfo;
100
+ readonly decision?: {
101
+ readonly answer: string | null;
102
+ readonly ts?: number;
103
+ };
104
+ /** Values the agent proposed, from the approval schema's field defaults. */
105
+ readonly defaults?: Readonly<Record<string, JsonValue>>;
106
+ /** What happened after a PR publish approval. */
107
+ readonly publish?: {
108
+ readonly status: 'published';
109
+ readonly pulls: readonly PublishedPull[];
110
+ } | {
111
+ readonly status: 'failed';
112
+ readonly error: string;
113
+ };
114
+ } | {
115
+ readonly kind: 'notice';
116
+ readonly id: string;
117
+ readonly seq: number;
118
+ readonly ts: number;
119
+ readonly tone: 'info' | 'success' | 'error';
120
+ readonly text: string;
121
+ readonly threadId?: string;
122
+ readonly runId?: string;
123
+ };
124
+ export interface BriefRevision {
125
+ readonly version: number;
126
+ readonly text: string;
127
+ readonly ts: number;
128
+ readonly sourceMessageId?: string;
129
+ }
130
+ export interface PublishedPull {
131
+ readonly fullName: string;
132
+ readonly number: number;
133
+ readonly url: string;
134
+ readonly draft: boolean;
135
+ /** Agent thread that proposed the PR. */
136
+ readonly threadId?: string;
137
+ /** Shuttle stack membership; absent when the PR can't be placed in a stack. */
138
+ readonly stack?: PullStackPosition;
139
+ }
140
+ export interface PullStackPosition {
141
+ /** Independent stack within the repo; a one-layer stack is a standalone PR. */
142
+ readonly id: number;
143
+ readonly layer: number;
144
+ }
145
+ export type ReviewVerdict = 'approve' | 'request_changes' | 'comment';
146
+ export interface DraftReviewComment {
147
+ readonly commentId: string;
148
+ readonly path: string;
149
+ readonly line: number;
150
+ readonly side: 'LEFT' | 'RIGHT';
151
+ readonly severity: 'info' | 'warning' | 'error';
152
+ readonly body: string;
153
+ readonly suggestion?: string;
154
+ }
155
+ export interface SessionFeed {
156
+ readonly items: readonly FeedItem[];
157
+ readonly routes: Readonly<Record<string, RouteInfo>>;
158
+ /** Steers and narrator spawns land before `shuttle.routed`, so they key on message id alone. */
159
+ readonly deliveries: Readonly<Record<string, readonly RouteDelivery[]>>;
160
+ readonly narratorFor: Readonly<Record<string, string>>;
161
+ readonly classifying: Readonly<Record<string, true>>;
162
+ readonly messageText: Readonly<Record<string, string>>;
163
+ readonly brief: readonly BriefRevision[];
164
+ readonly playbook: {
165
+ readonly version: number;
166
+ readonly lessons: readonly PlaybookLessonRef[];
167
+ };
168
+ readonly reflectionRunId?: string;
169
+ readonly rootThreadId?: string;
170
+ readonly narrators: Readonly<Record<string, string>>;
171
+ readonly toolIndex: Readonly<Record<string, number>>;
172
+ readonly questionIndex: Readonly<Record<string, number>>;
173
+ /** Holds a turn's thought until its message, tool call, or approval arrives. */
174
+ readonly pendingThoughts: Readonly<Record<string, ThoughtInfo>>;
175
+ /** Threads with a model turn in progress. */
176
+ readonly openTurns: Readonly<Record<string, true>>;
177
+ /**
178
+ * Messages, by id, that reached an agent in the middle of a turn, with the thread they wait
179
+ * for. The agent reads them when that turn ends, so that is where they belong in the feed.
180
+ */
181
+ readonly queued: Readonly<Record<string, string>>;
182
+ /** Every file in the session, oldest first: those people attached and those agents shared. */
183
+ readonly media: readonly SessionMedia[];
184
+ /** PRs this session opened (from shuttle.pr.published). */
185
+ readonly publishedPulls: readonly PublishedPull[];
186
+ /** Inline review comments drafted during a review session. */
187
+ readonly draftReviewComments: readonly DraftReviewComment[];
188
+ /** Open submit-review approval, if any. */
189
+ readonly pendingReviewApprovalId?: string;
190
+ /** The summary and verdict the reviewer proposed when it asked to submit. */
191
+ readonly reviewProposal?: {
192
+ readonly summary?: string;
193
+ readonly verdict?: ReviewVerdict;
194
+ };
195
+ /** What became of the last review that was sent to GitHub. */
196
+ readonly reviewOutcome?: {
197
+ readonly status: 'submitted';
198
+ readonly verdict: ReviewVerdict;
199
+ readonly commentCount: number;
200
+ /** Comments GitHub could not place on a line, sent in the review's body instead. */
201
+ readonly unanchoredCount: number;
202
+ } | {
203
+ readonly status: 'failed';
204
+ readonly error: string;
205
+ };
206
+ /** Threads run by a vendor agent (Codex, Claude Code), keyed by thread id. */
207
+ readonly vendorAgents: Readonly<Record<string, VendorAgent>>;
208
+ }
209
+ export interface VendorAgent {
210
+ readonly harness: string;
211
+ readonly label: string;
212
+ readonly model?: string;
213
+ /** The person whose subscription the agent is running on. */
214
+ readonly billedTo?: string;
215
+ }
216
+ export interface MessageAuthor {
217
+ readonly id: string;
218
+ readonly name: string;
219
+ }
220
+ export interface PlaybookLessonRef {
221
+ readonly id: string;
222
+ readonly text: string;
223
+ readonly scope?: string;
224
+ }
225
+ export declare const sessionFeed: ProjectionDefinition<SessionFeed>;
226
+ /**
227
+ * What each vendor agent has done so far in a turn that is still running, as a small feed per
228
+ * thread. A vendor turn's steps only become durable when the turn ends, so this is what shows
229
+ * the agent working in the meantime. It empties for a thread once that turn's result lands.
230
+ */
231
+ export declare const vendorLiveFeed: LiveFoldDefinition<Readonly<Record<string, SessionFeed>>, SessionEvent>;
232
+ /** The durable feed with every running vendor turn's steps so far appended. */
233
+ export declare function withLiveVendorSteps(feed: SessionFeed, live: Readonly<Record<string, SessionFeed>>): SessionFeed;
234
+ export interface StreamingTurn {
235
+ readonly turn: number;
236
+ readonly thinking: string;
237
+ readonly text: string;
238
+ readonly thinkingStartedAt?: number;
239
+ readonly thinkingEndedAt?: number;
240
+ }
241
+ /** Live thinking + reply text each agent has streamed since its last durable message. */
242
+ export declare const streamingTurns: LiveFoldDefinition<Readonly<Record<string, StreamingTurn>>, SessionEvent>;
243
+ export declare function currentBrief(feed: SessionFeed): BriefRevision | undefined;