@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.
- package/CHANGELOG.md +18 -0
- package/LICENSE +190 -0
- package/NOTICE +5 -0
- package/README.md +42 -2
- package/dist/api/auth.d.ts +18 -0
- package/dist/api/auth.js +15 -0
- package/dist/api/common.d.ts +8 -0
- package/dist/api/common.js +4 -0
- package/dist/api/connections.d.ts +292 -0
- package/dist/api/connections.js +114 -0
- package/dist/api/github.d.ts +20 -0
- package/dist/api/github.js +13 -0
- package/dist/api/harness.d.ts +97 -0
- package/dist/api/harness.js +47 -0
- package/dist/api/index.d.ts +2059 -0
- package/dist/api/index.js +37 -0
- package/dist/api/runners.d.ts +93 -0
- package/dist/api/runners.js +45 -0
- package/dist/api/sandbox.d.ts +550 -0
- package/dist/api/sandbox.js +210 -0
- package/dist/api/sessions.d.ts +318 -0
- package/dist/api/sessions.js +154 -0
- package/dist/api/tenant.d.ts +54 -0
- package/dist/api/tenant.js +19 -0
- package/dist/api/timings.d.ts +36 -0
- package/dist/api/timings.js +48 -0
- package/dist/api/workspace.d.ts +738 -0
- package/dist/api/workspace.js +246 -0
- package/dist/core/pulls.d.ts +1001 -0
- package/dist/core/pulls.js +170 -0
- package/dist/core/workspace.d.ts +985 -0
- package/dist/core/workspace.js +174 -0
- package/dist/react/components/command-palette.d.ts +22 -0
- package/dist/react/components/command-palette.js +66 -0
- package/dist/react/components/follow-list.d.ts +20 -0
- package/dist/react/components/follow-list.js +98 -0
- package/dist/react/components/json-tree.d.ts +11 -0
- package/dist/react/components/json-tree.js +120 -0
- package/dist/react/components/markdown.d.ts +5 -0
- package/dist/react/components/markdown.js +29 -0
- package/dist/react/components/shuttle-mark.d.ts +7 -0
- package/dist/react/components/shuttle-mark.js +9 -0
- package/dist/react/components/status-dot.d.ts +9 -0
- package/dist/react/components/status-dot.js +27 -0
- package/dist/react/components/status.d.ts +6 -0
- package/dist/react/components/status.js +66 -0
- package/dist/react/components/ui/badge.d.ts +7 -0
- package/dist/react/components/ui/badge.js +19 -0
- package/dist/react/components/ui/button.d.ts +10 -0
- package/dist/react/components/ui/button.js +40 -0
- package/dist/react/components/ui/dialog.d.ts +19 -0
- package/dist/react/components/ui/dialog.js +34 -0
- package/dist/react/components/ui/dropdown-menu.d.ts +14 -0
- package/dist/react/components/ui/dropdown-menu.js +33 -0
- package/dist/react/components/ui/input.d.ts +3 -0
- package/dist/react/components/ui/input.js +6 -0
- package/dist/react/components/ui/panel.d.ts +18 -0
- package/dist/react/components/ui/panel.js +22 -0
- package/dist/react/components/ui/popover.d.ts +7 -0
- package/dist/react/components/ui/popover.js +16 -0
- package/dist/react/components/ui/resizable.d.ts +7 -0
- package/dist/react/components/ui/resizable.js +14 -0
- package/dist/react/components/ui/scroll-area.d.ts +14 -0
- package/dist/react/components/ui/scroll-area.js +12 -0
- package/dist/react/components/ui/select.d.ts +10 -0
- package/dist/react/components/ui/select.js +20 -0
- package/dist/react/components/ui/sheet.d.ts +8 -0
- package/dist/react/components/ui/sheet.js +20 -0
- package/dist/react/components/ui/tabs.d.ts +7 -0
- package/dist/react/components/ui/tabs.js +16 -0
- package/dist/react/components/ui/textarea.d.ts +3 -0
- package/dist/react/components/ui/textarea.js +6 -0
- package/dist/react/components/ui/tooltip.d.ts +8 -0
- package/dist/react/components/ui/tooltip.js +17 -0
- package/dist/react/features/artifacts/artifact-links.d.ts +9 -0
- package/dist/react/features/artifacts/artifact-links.js +38 -0
- package/dist/react/features/artifacts/artifact-pane.d.ts +19 -0
- package/dist/react/features/artifacts/artifact-pane.js +75 -0
- package/dist/react/features/artifacts/artifact-types.d.ts +59 -0
- package/dist/react/features/artifacts/artifact-types.js +69 -0
- package/dist/react/features/artifacts/browser-viewer.d.ts +5 -0
- package/dist/react/features/artifacts/browser-viewer.js +60 -0
- package/dist/react/features/artifacts/diff-style.d.ts +10 -0
- package/dist/react/features/artifacts/diff-style.js +21 -0
- package/dist/react/features/artifacts/file-pane.d.ts +13 -0
- package/dist/react/features/artifacts/file-pane.js +305 -0
- package/dist/react/features/artifacts/file-quick-open.d.ts +15 -0
- package/dist/react/features/artifacts/file-quick-open.js +74 -0
- package/dist/react/features/artifacts/file-search.d.ts +12 -0
- package/dist/react/features/artifacts/file-search.js +90 -0
- package/dist/react/features/artifacts/media-viewer.d.ts +8 -0
- package/dist/react/features/artifacts/media-viewer.js +41 -0
- package/dist/react/features/artifacts/review-diff.d.ts +19 -0
- package/dist/react/features/artifacts/review-diff.js +59 -0
- package/dist/react/features/artifacts/review-viewer.d.ts +4 -0
- package/dist/react/features/artifacts/review-viewer.js +337 -0
- package/dist/react/features/artifacts/sandbox.d.ts +43 -0
- package/dist/react/features/artifacts/sandbox.js +109 -0
- package/dist/react/features/artifacts/tab-strip.d.ts +11 -0
- package/dist/react/features/artifacts/tab-strip.js +55 -0
- package/dist/react/features/artifacts/terminal-theme.d.ts +34 -0
- package/dist/react/features/artifacts/terminal-theme.js +62 -0
- package/dist/react/features/artifacts/terminal-viewer.d.ts +5 -0
- package/dist/react/features/artifacts/terminal-viewer.js +209 -0
- package/dist/react/features/artifacts/unified-diff.d.ts +16 -0
- package/dist/react/features/artifacts/unified-diff.js +55 -0
- package/dist/react/features/artifacts/workspace-viewer.d.ts +16 -0
- package/dist/react/features/artifacts/workspace-viewer.js +275 -0
- package/dist/react/features/connections/agent-sign-in.d.ts +71 -0
- package/dist/react/features/connections/agent-sign-in.js +251 -0
- package/dist/react/features/connections/connections-panel.d.ts +8 -0
- package/dist/react/features/connections/connections-panel.js +42 -0
- package/dist/react/features/connections/login.d.ts +24 -0
- package/dist/react/features/connections/login.js +35 -0
- package/dist/react/features/connections/places.d.ts +20 -0
- package/dist/react/features/connections/places.js +27 -0
- package/dist/react/features/connections/queries.d.ts +28 -0
- package/dist/react/features/connections/queries.js +8 -0
- package/dist/react/features/events/event-cache.d.ts +4 -0
- package/dist/react/features/events/event-cache.js +29 -0
- package/dist/react/features/events/event-catalog.d.ts +17 -0
- package/dist/react/features/events/event-catalog.js +261 -0
- package/dist/react/features/events/event-inspector.d.ts +7 -0
- package/dist/react/features/events/event-inspector.js +29 -0
- package/dist/react/features/events/event-row.d.ts +21 -0
- package/dist/react/features/events/event-row.js +34 -0
- package/dist/react/features/events/event-stream.d.ts +18 -0
- package/dist/react/features/events/event-stream.js +58 -0
- package/dist/react/features/events/global-events.d.ts +122 -0
- package/dist/react/features/events/global-events.js +329 -0
- package/dist/react/features/events/shuttle-events.d.ts +7 -0
- package/dist/react/features/events/shuttle-events.js +1 -0
- package/dist/react/features/playbook/playbook-page.d.ts +2 -0
- package/dist/react/features/playbook/playbook-page.js +36 -0
- package/dist/react/features/playbook/playbook-query.d.ts +111 -0
- package/dist/react/features/playbook/playbook-query.js +17 -0
- package/dist/react/features/pulls/linked-session.d.ts +12 -0
- package/dist/react/features/pulls/linked-session.js +22 -0
- package/dist/react/features/pulls/pull-detail-sheet.d.ts +10 -0
- package/dist/react/features/pulls/pull-detail-sheet.js +41 -0
- package/dist/react/features/pulls/pull-fixtures.d.ts +8 -0
- package/dist/react/features/pulls/pull-fixtures.js +258 -0
- package/dist/react/features/pulls/pull-glyphs.d.ts +24 -0
- package/dist/react/features/pulls/pull-glyphs.js +89 -0
- package/dist/react/features/pulls/pull-inbox-list.d.ts +13 -0
- package/dist/react/features/pulls/pull-inbox-list.js +230 -0
- package/dist/react/features/pulls/pull-inbox-pref.d.ts +2 -0
- package/dist/react/features/pulls/pull-inbox-pref.js +19 -0
- package/dist/react/features/pulls/pull-inbox.d.ts +30 -0
- package/dist/react/features/pulls/pull-inbox.js +110 -0
- package/dist/react/features/pulls/pull-threads.d.ts +39 -0
- package/dist/react/features/pulls/pull-threads.js +145 -0
- package/dist/react/features/pulls/pulls.d.ts +120 -0
- package/dist/react/features/pulls/pulls.js +414 -0
- package/dist/react/features/pulls/session-pull-groups.d.ts +14 -0
- package/dist/react/features/pulls/session-pull-groups.js +29 -0
- package/dist/react/features/pulls/stack-ladder.d.ts +9 -0
- package/dist/react/features/pulls/stack-ladder.js +32 -0
- package/dist/react/features/sessions/agent-tree.d.ts +16 -0
- package/dist/react/features/sessions/agent-tree.js +100 -0
- package/dist/react/features/sessions/agents.d.ts +34 -0
- package/dist/react/features/sessions/agents.js +146 -0
- package/dist/react/features/sessions/attention.d.ts +32 -0
- package/dist/react/features/sessions/attention.js +42 -0
- package/dist/react/features/sessions/composer-attachments.d.ts +33 -0
- package/dist/react/features/sessions/composer-attachments.js +126 -0
- package/dist/react/features/sessions/composer.d.ts +15 -0
- package/dist/react/features/sessions/composer.js +327 -0
- package/dist/react/features/sessions/context-usage-meter.d.ts +5 -0
- package/dist/react/features/sessions/context-usage-meter.js +122 -0
- package/dist/react/features/sessions/context-usage.d.ts +54 -0
- package/dist/react/features/sessions/context-usage.js +206 -0
- package/dist/react/features/sessions/conversation.d.ts +21 -0
- package/dist/react/features/sessions/conversation.js +549 -0
- package/dist/react/features/sessions/harness-switcher.d.ts +26 -0
- package/dist/react/features/sessions/harness-switcher.js +118 -0
- package/dist/react/features/sessions/intake-heuristic.d.ts +5 -0
- package/dist/react/features/sessions/intake-heuristic.js +28 -0
- package/dist/react/features/sessions/interjection-routes.d.ts +13 -0
- package/dist/react/features/sessions/interjection-routes.js +72 -0
- package/dist/react/features/sessions/llm-models.d.ts +128 -0
- package/dist/react/features/sessions/llm-models.js +174 -0
- package/dist/react/features/sessions/media-strip.d.ts +25 -0
- package/dist/react/features/sessions/media-strip.js +56 -0
- package/dist/react/features/sessions/media.d.ts +43 -0
- package/dist/react/features/sessions/media.js +115 -0
- package/dist/react/features/sessions/model-search.d.ts +6 -0
- package/dist/react/features/sessions/model-search.js +16 -0
- package/dist/react/features/sessions/model-switcher.d.ts +16 -0
- package/dist/react/features/sessions/model-switcher.js +262 -0
- package/dist/react/features/sessions/open-pull-request.d.ts +20 -0
- package/dist/react/features/sessions/open-pull-request.js +92 -0
- package/dist/react/features/sessions/pull-publish-card.d.ts +14 -0
- package/dist/react/features/sessions/pull-publish-card.js +88 -0
- package/dist/react/features/sessions/recent-sessions.d.ts +11 -0
- package/dist/react/features/sessions/recent-sessions.js +29 -0
- package/dist/react/features/sessions/seen-sessions.d.ts +16 -0
- package/dist/react/features/sessions/seen-sessions.js +108 -0
- package/dist/react/features/sessions/session-activity.d.ts +95 -0
- package/dist/react/features/sessions/session-activity.js +785 -0
- package/dist/react/features/sessions/session-context.d.ts +8 -0
- package/dist/react/features/sessions/session-context.js +98 -0
- package/dist/react/features/sessions/session-feed.d.ts +243 -0
- package/dist/react/features/sessions/session-feed.js +883 -0
- package/dist/react/features/sessions/session-header.d.ts +24 -0
- package/dist/react/features/sessions/session-header.js +97 -0
- package/dist/react/features/sessions/session-layout.d.ts +7 -0
- package/dist/react/features/sessions/session-layout.js +87 -0
- package/dist/react/features/sessions/session-panes.d.ts +49 -0
- package/dist/react/features/sessions/session-panes.js +142 -0
- package/dist/react/features/sessions/session-parts.d.ts +35 -0
- package/dist/react/features/sessions/session-parts.js +74 -0
- package/dist/react/features/sessions/session-place.d.ts +9 -0
- package/dist/react/features/sessions/session-place.js +109 -0
- package/dist/react/features/sessions/session-pr-pills.d.ts +7 -0
- package/dist/react/features/sessions/session-pr-pills.js +28 -0
- package/dist/react/features/sessions/session-queries.d.ts +172 -0
- package/dist/react/features/sessions/session-queries.js +90 -0
- package/dist/react/features/sessions/session-repos.d.ts +8 -0
- package/dist/react/features/sessions/session-repos.js +15 -0
- package/dist/react/features/sessions/session-share.d.ts +8 -0
- package/dist/react/features/sessions/session-share.js +112 -0
- package/dist/react/features/sessions/session-tabs.d.ts +38 -0
- package/dist/react/features/sessions/session-tabs.js +191 -0
- package/dist/react/features/sessions/session.d.ts +103 -0
- package/dist/react/features/sessions/session.js +216 -0
- package/dist/react/features/sessions/signals.d.ts +13 -0
- package/dist/react/features/sessions/signals.js +34 -0
- package/dist/react/features/sessions/tab-set.d.ts +20 -0
- package/dist/react/features/sessions/tab-set.js +58 -0
- package/dist/react/features/sessions/team.d.ts +16 -0
- package/dist/react/features/sessions/team.js +35 -0
- package/dist/react/features/sessions/timeline.d.ts +53 -0
- package/dist/react/features/sessions/timeline.js +153 -0
- package/dist/react/features/sessions/use-session-tabs.d.ts +18 -0
- package/dist/react/features/sessions/use-session-tabs.js +119 -0
- package/dist/react/features/sessions/vendor-models.d.ts +23 -0
- package/dist/react/features/sessions/vendor-models.js +61 -0
- package/dist/react/features/workspace/activity-dot.d.ts +15 -0
- package/dist/react/features/workspace/activity-dot.js +36 -0
- package/dist/react/features/workspace/app-sidebar.d.ts +16 -0
- package/dist/react/features/workspace/app-sidebar.js +227 -0
- package/dist/react/features/workspace/fixture-toggle.d.ts +2 -0
- package/dist/react/features/workspace/fixture-toggle.js +72 -0
- package/dist/react/features/workspace/folder-group.d.ts +18 -0
- package/dist/react/features/workspace/folder-group.js +83 -0
- package/dist/react/features/workspace/inline-name-input.d.ts +10 -0
- package/dist/react/features/workspace/inline-name-input.js +33 -0
- package/dist/react/features/workspace/link-repo-dialog.d.ts +9 -0
- package/dist/react/features/workspace/link-repo-dialog.js +76 -0
- package/dist/react/features/workspace/repo-chip.d.ts +13 -0
- package/dist/react/features/workspace/repo-chip.js +15 -0
- package/dist/react/features/workspace/session-row.d.ts +20 -0
- package/dist/react/features/workspace/session-row.js +23 -0
- package/dist/react/features/workspace/use-debounced.d.ts +2 -0
- package/dist/react/features/workspace/use-debounced.js +10 -0
- package/dist/react/features/workspace/workspace-context.d.ts +45 -0
- package/dist/react/features/workspace/workspace-context.js +245 -0
- package/dist/react/features/workspace/workspace-fixtures.d.ts +16 -0
- package/dist/react/features/workspace/workspace-fixtures.js +175 -0
- package/dist/react/features/workspace/workspace-tree.d.ts +30 -0
- package/dist/react/features/workspace/workspace-tree.js +69 -0
- package/dist/react/features/workspace/workspace.d.ts +107 -0
- package/dist/react/features/workspace/workspace.js +458 -0
- package/dist/react/index.d.ts +33 -0
- package/dist/react/index.js +35 -0
- package/dist/react/lib/cn.d.ts +6 -0
- package/dist/react/lib/cn.js +20 -0
- package/dist/react/lib/initials.d.ts +6 -0
- package/dist/react/lib/initials.js +32 -0
- package/dist/react/lib/json.d.ts +33 -0
- package/dist/react/lib/json.js +101 -0
- package/dist/react/lib/time.d.ts +8 -0
- package/dist/react/lib/time.js +57 -0
- package/dist/react/lib/use-media-query.d.ts +1 -0
- package/dist/react/lib/use-media-query.js +9 -0
- package/dist/react/lib/use-now.d.ts +2 -0
- package/dist/react/lib/use-now.js +10 -0
- package/dist/react/lib/use-width-bucket.d.ts +6 -0
- package/dist/react/lib/use-width-bucket.js +28 -0
- package/dist/react/parts/index.d.ts +43 -0
- package/dist/react/parts/index.js +43 -0
- package/dist/react/shuttle/device.d.ts +42 -0
- package/dist/react/shuttle/device.js +10 -0
- package/dist/react/shuttle/host.d.ts +1126 -0
- package/dist/react/shuttle/host.js +93 -0
- package/dist/react/shuttle/identity.d.ts +31 -0
- package/dist/react/shuttle/identity.js +20 -0
- package/dist/react/shuttle/index.d.ts +14 -0
- package/dist/react/shuttle/index.js +13 -0
- package/dist/react/shuttle/provider.d.ts +41 -0
- package/dist/react/shuttle/provider.js +59 -0
- package/dist/react/shuttle/router.d.ts +43 -0
- package/dist/react/shuttle/router.js +1 -0
- package/dist/react/theme.css +456 -0
- package/dist/react/ui.d.ts +19 -0
- package/dist/react/ui.js +19 -0
- package/package.json +100 -4
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useMutation, useQueryClient, useSuspenseQuery } from '@tanstack/react-query';
|
|
3
|
+
import { Cloud, Laptop } from 'lucide-react';
|
|
4
|
+
import { Button } from '../../components/ui/button.js';
|
|
5
|
+
import { cn } from '../../lib/cn.js';
|
|
6
|
+
import { useApi, useShuttleHost } from '../../shuttle/index.js';
|
|
7
|
+
import { SignInProgress, useSignIn } from './agent-sign-in.js';
|
|
8
|
+
import { placeContext, signedInAt } from './places.js';
|
|
9
|
+
import { connectionsQuery } from './queries.js';
|
|
10
|
+
/**
|
|
11
|
+
* Connect, check and remove coding agent subscriptions. Each agent shows every place it can be
|
|
12
|
+
* signed in at once: in the desktop app that is this machine and the cloud, which keep separate
|
|
13
|
+
* sign-ins because a session uses the one where it runs.
|
|
14
|
+
*
|
|
15
|
+
* The page's loader has the connections ready before this renders.
|
|
16
|
+
*/
|
|
17
|
+
export function ConnectionsPanel() {
|
|
18
|
+
const host = useShuttleHost();
|
|
19
|
+
const { data: state, error } = useSuspenseQuery(connectionsQuery(host));
|
|
20
|
+
const places = state.machine ? ['local', 'cloud'] : ['cloud'];
|
|
21
|
+
return (_jsxs("div", { className: "flex flex-col gap-3", children: [state.machine ? (_jsx("p", { className: "text-muted-foreground text-xs text-pretty", children: "A session uses the sign-in where it runs, so sign in at each place you work. A sign-in on this machine stays in its sandbox here." })) : null, error ? _jsx("p", { className: "text-status-failed text-xs wrap-anywhere", children: error.message }) : null, state.mode !== 'container' ? (_jsxs(Notice, { children: ["Subscriptions need the container sandbox. Set", ' ', _jsx("code", { className: "text-foreground", children: "SHUTTLE_WORKSPACE_MODE=container" }), " in", ' ', _jsx("code", { className: "text-foreground", children: "apps/worker/.dev.vars" }), " and restart."] })) : null, !state.canStore ? (_jsxs(Notice, { children: [_jsx("code", { className: "text-foreground", children: "SHUTTLE_CREDENTIALS_KEY" }), " is not set, so sign-ins cannot be stored. Restart with ", _jsx("code", { className: "text-foreground", children: "bun run dev" }), " to generate one."] })) : null, state.connections.map((connection) => (_jsxs("div", { className: "bg-card rounded-xl border", children: [_jsx("p", { className: "text-foreground px-4 pt-3.5 pb-1 text-sm font-medium", children: connection.label }), _jsx("div", { className: "divide-y", children: places.map((place) => (_jsx(PlaceRow, { connection: connection, place: place, showPlace: places.length > 1, disabled: state.mode !== 'container' || !state.canStore }, place))) })] }, connection.harness)))] }));
|
|
22
|
+
}
|
|
23
|
+
function Notice({ children }) {
|
|
24
|
+
return (_jsx("p", { className: "text-muted-foreground bg-muted/40 rounded-lg border px-3 py-2 text-xs leading-relaxed", children: children }));
|
|
25
|
+
}
|
|
26
|
+
/** One agent at one place: whether it is signed in there, and the way to change that. */
|
|
27
|
+
function PlaceRow({ connection, place, showPlace, disabled, }) {
|
|
28
|
+
const host = useShuttleHost();
|
|
29
|
+
const api = useApi();
|
|
30
|
+
const queryClient = useQueryClient();
|
|
31
|
+
const flow = useSignIn(connection.harness, place);
|
|
32
|
+
const signedIn = signedInAt(connection, place) === true;
|
|
33
|
+
const updatedAt = place === 'cloud' ? connection.updatedAt : null;
|
|
34
|
+
const disconnect = useMutation(api.connections.disconnect.mutationOptions({
|
|
35
|
+
context: placeContext(host, place),
|
|
36
|
+
// Whether or not it worked, show where the agent is signed in now.
|
|
37
|
+
onSettled: () => queryClient.invalidateQueries({ queryKey: api.connections.key() }),
|
|
38
|
+
}));
|
|
39
|
+
return (_jsxs("div", { className: "px-4 py-2.5", children: [_jsxs("div", { className: "flex min-h-8 items-center gap-3", children: [showPlace ? (place === 'local' ? (_jsx(Laptop, { className: "text-muted-foreground size-3.5 shrink-0" })) : (_jsx(Cloud, { className: "text-muted-foreground size-3.5 shrink-0" }))) : null, _jsxs("div", { className: "flex min-w-0 flex-1 items-baseline gap-2", children: [showPlace ? (_jsx("span", { className: "text-foreground w-24 shrink-0 text-xs", children: place === 'local' ? 'This machine' : 'Cloud' })) : null, _jsxs("span", { className: cn('inline-flex min-w-0 items-center gap-1.5 truncate text-xs', signedIn ? 'text-foreground' : 'text-muted-foreground'), children: [_jsx("span", { "aria-hidden": true, className: cn('size-1.5 shrink-0 rounded-full', signedIn ? 'bg-emerald-500' : 'bg-muted-foreground/40') }), signedIn
|
|
40
|
+
? `Signed in${updatedAt ? ` · ${new Date(updatedAt).toLocaleDateString()}` : ''}`
|
|
41
|
+
: 'Not signed in'] })] }), flow.busy ? (_jsx(Button, { size: "sm", variant: "ghost", onClick: flow.cancel, children: "Cancel" })) : signedIn ? (_jsxs(_Fragment, { children: [_jsx(Button, { size: "sm", variant: "ghost", disabled: disabled, onClick: flow.start, children: "Sign in again" }), _jsx(Button, { size: "sm", variant: "ghost", disabled: disconnect.isPending, onClick: () => disconnect.mutate({ harness: connection.harness }), children: "Disconnect" })] })) : (_jsx(Button, { size: "sm", disabled: disabled, onClick: flow.start, children: flow.signIn?.step === 'failed' ? 'Try again' : 'Sign in' }))] }), flow.signIn ? (_jsx("div", { className: "mt-2", children: _jsx(SignInProgress, { label: connection.label, place: place, signIn: flow.signIn, onSubmitCode: flow.submitCode }) })) : null, disconnect.error ? (_jsx("p", { className: "text-status-failed mt-2 text-xs wrap-anywhere", children: disconnect.error.message })) : null] }));
|
|
42
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { LoginEvent, LoginProgress } from '@swirls/shuttle/api';
|
|
2
|
+
/** The page to open, and the code to enter there or bring back, as the vendor CLI printed it. */
|
|
3
|
+
export type LoginPrompt = Extract<LoginEvent, {
|
|
4
|
+
type: 'login_prompt';
|
|
5
|
+
}>;
|
|
6
|
+
/** Where a sign-in stands, from everything it has said so far. */
|
|
7
|
+
export type LoginOutcome = {
|
|
8
|
+
readonly status: 'waiting';
|
|
9
|
+
readonly prompt: LoginPrompt | null;
|
|
10
|
+
} | {
|
|
11
|
+
readonly status: 'connected';
|
|
12
|
+
} | {
|
|
13
|
+
readonly status: 'failed';
|
|
14
|
+
readonly error: string;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Adds a read made from `soFar.offset` to what earlier reads returned. The result is what one
|
|
18
|
+
* read from the start would have returned: every event once, in order, with the newest offset.
|
|
19
|
+
* An event already held is left out, so making the same read twice changes nothing.
|
|
20
|
+
*/
|
|
21
|
+
export declare function mergeProgress(soFar: LoginProgress | undefined, page: LoginProgress): LoginProgress;
|
|
22
|
+
export declare function loginOutcome(progress: LoginProgress): LoginOutcome;
|
|
23
|
+
/** True once nothing more will come of the sign-in, so there is nothing left to ask for. */
|
|
24
|
+
export declare function loginSettled(progress: LoginProgress): boolean;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adds a read made from `soFar.offset` to what earlier reads returned. The result is what one
|
|
3
|
+
* read from the start would have returned: every event once, in order, with the newest offset.
|
|
4
|
+
* An event already held is left out, so making the same read twice changes nothing.
|
|
5
|
+
*/
|
|
6
|
+
export function mergeProgress(soFar, page) {
|
|
7
|
+
if (!soFar) {
|
|
8
|
+
return page;
|
|
9
|
+
}
|
|
10
|
+
const last = soFar.events.at(-1)?.seq ?? 0;
|
|
11
|
+
return { ...page, events: [...soFar.events, ...page.events.filter((event) => event.seq > last)] };
|
|
12
|
+
}
|
|
13
|
+
export function loginOutcome(progress) {
|
|
14
|
+
const failure = progress.events.find((event) => event.type === 'login_done' && !event.success);
|
|
15
|
+
if (failure?.type === 'login_done') {
|
|
16
|
+
return { status: 'failed', error: failure.error ?? 'Sign-in did not complete.' };
|
|
17
|
+
}
|
|
18
|
+
if (progress.connected) {
|
|
19
|
+
return { status: 'connected' };
|
|
20
|
+
}
|
|
21
|
+
if (progress.error) {
|
|
22
|
+
return { status: 'failed', error: progress.error };
|
|
23
|
+
}
|
|
24
|
+
// Ended without connecting the agent or saying why. Nothing follows, so waiting would never end.
|
|
25
|
+
if (progress.done) {
|
|
26
|
+
return { status: 'failed', error: 'Sign-in did not complete.' };
|
|
27
|
+
}
|
|
28
|
+
// The CLI can ask again, after a wrong code for one. Only its latest prompt still stands.
|
|
29
|
+
const prompt = progress.events.findLast((event) => event.type === 'login_prompt');
|
|
30
|
+
return { status: 'waiting', prompt: prompt?.type === 'login_prompt' ? prompt : null };
|
|
31
|
+
}
|
|
32
|
+
/** True once nothing more will come of the sign-in, so there is nothing left to ask for. */
|
|
33
|
+
export function loginSettled(progress) {
|
|
34
|
+
return loginOutcome(progress).status !== 'waiting';
|
|
35
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Connection } from '@swirls/shuttle/api';
|
|
2
|
+
import { type CallContext, type ShuttleHost } from '../../shuttle/index.js';
|
|
3
|
+
/** Where a session runs, and so which sign-in it uses. */
|
|
4
|
+
export type SignInPlace = 'local' | 'cloud';
|
|
5
|
+
/** Whether the agent is signed in at `place`. Null when that cannot be known from here. */
|
|
6
|
+
export declare function signedInAt(connection: Connection, place: SignInPlace): boolean | null;
|
|
7
|
+
/**
|
|
8
|
+
* Whether an agent can run at `place`. False only when it is known not to be signed in there,
|
|
9
|
+
* so a place that cannot be checked from here never blocks anyone.
|
|
10
|
+
*/
|
|
11
|
+
export declare function needsSignIn(connection: Connection | undefined, place: SignInPlace | null): connection is Connection;
|
|
12
|
+
/** The words for a place, as in "signed in on this machine". */
|
|
13
|
+
export declare function placeName(place: SignInPlace): string;
|
|
14
|
+
/** "on this machine" or "in the cloud". */
|
|
15
|
+
export declare function atPlace(place: SignInPlace): string;
|
|
16
|
+
/**
|
|
17
|
+
* What a sign-in, disconnect or follow at `place` sends. One at `local` names this machine, so
|
|
18
|
+
* it happens in this machine's sandbox. One at `cloud` names none, even from the desktop app.
|
|
19
|
+
*/
|
|
20
|
+
export declare function placeContext(host: ShuttleHost, place: SignInPlace): CallContext;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {} from '../../shuttle/index.js';
|
|
2
|
+
/** Whether the agent is signed in at `place`. Null when that cannot be known from here. */
|
|
3
|
+
export function signedInAt(connection, place) {
|
|
4
|
+
return place === 'cloud' ? connection.cloud : connection.local;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Whether an agent can run at `place`. False only when it is known not to be signed in there,
|
|
8
|
+
* so a place that cannot be checked from here never blocks anyone.
|
|
9
|
+
*/
|
|
10
|
+
export function needsSignIn(connection, place) {
|
|
11
|
+
return Boolean(connection && place && signedInAt(connection, place) === false);
|
|
12
|
+
}
|
|
13
|
+
/** The words for a place, as in "signed in on this machine". */
|
|
14
|
+
export function placeName(place) {
|
|
15
|
+
return place === 'local' ? 'this machine' : 'the cloud';
|
|
16
|
+
}
|
|
17
|
+
/** "on this machine" or "in the cloud". */
|
|
18
|
+
export function atPlace(place) {
|
|
19
|
+
return place === 'local' ? 'on this machine' : 'in the cloud';
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* What a sign-in, disconnect or follow at `place` sends. One at `local` names this machine, so
|
|
23
|
+
* it happens in this machine's sandbox. One at `cloud` names none, even from the desktop app.
|
|
24
|
+
*/
|
|
25
|
+
export function placeContext(host, place) {
|
|
26
|
+
return place === 'local' ? host.deviceContext() : {};
|
|
27
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type ShuttleHost } from '../../shuttle/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* The viewer's connections. From a host with a machine the listing covers this machine as well as
|
|
4
|
+
* the cloud. Everything that shows connections reads this one query.
|
|
5
|
+
*/
|
|
6
|
+
export declare function connectionsQuery(host: ShuttleHost): NoInfer<{
|
|
7
|
+
context: import("../../index.js").CallContext;
|
|
8
|
+
} & Omit<import("@orpc/tanstack-query").QueryOptionsBase<{
|
|
9
|
+
machine: boolean;
|
|
10
|
+
defaultHarness: "claude-code" | "codex" | "cursor" | "shuttle" | `acp:${string}`;
|
|
11
|
+
defaultTeam: {
|
|
12
|
+
workers: boolean;
|
|
13
|
+
codex: boolean;
|
|
14
|
+
claudeCode: boolean;
|
|
15
|
+
cursor: boolean;
|
|
16
|
+
preset: "claude-builds-codex-reviews" | "claude-plans-codex-implements" | "codex-builds-claude-reviews" | "none";
|
|
17
|
+
};
|
|
18
|
+
mode: "container" | "memory";
|
|
19
|
+
canStore: boolean;
|
|
20
|
+
connections: readonly {
|
|
21
|
+
harness: "claude-code" | "codex" | "cursor";
|
|
22
|
+
label: string;
|
|
23
|
+
connected: boolean;
|
|
24
|
+
cloud: boolean;
|
|
25
|
+
local: boolean | null;
|
|
26
|
+
updatedAt: number | null;
|
|
27
|
+
}[];
|
|
28
|
+
}, Error>, "context">>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import {} from '../../shuttle/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* The viewer's connections. From a host with a machine the listing covers this machine as well as
|
|
4
|
+
* the cloud. Everything that shows connections reads this one query.
|
|
5
|
+
*/
|
|
6
|
+
export function connectionsQuery(host) {
|
|
7
|
+
return host.api.connections.list.queryOptions({ context: host.deviceContext() });
|
|
8
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { indexedDbEventCache } from '@swirls/looms/react';
|
|
2
|
+
/**
|
|
3
|
+
* Each run's events are kept on the device, so opening a session again downloads only what is
|
|
4
|
+
* new. The store is one person's: a session kept for one sign-in is never shown to another on
|
|
5
|
+
* the same browser, and signing out removes it.
|
|
6
|
+
*/
|
|
7
|
+
function databaseName(userId) {
|
|
8
|
+
return `shuttle-events:${userId}`;
|
|
9
|
+
}
|
|
10
|
+
const caches = new Map();
|
|
11
|
+
export function eventCacheFor(userId) {
|
|
12
|
+
const existing = caches.get(userId);
|
|
13
|
+
if (existing) {
|
|
14
|
+
return existing;
|
|
15
|
+
}
|
|
16
|
+
const cache = indexedDbEventCache({ name: databaseName(userId) });
|
|
17
|
+
caches.set(userId, cache);
|
|
18
|
+
return cache;
|
|
19
|
+
}
|
|
20
|
+
/** Removes what was kept for `userId`. Called when they sign out. */
|
|
21
|
+
export function forgetEventCache(userId) {
|
|
22
|
+
caches.delete(userId);
|
|
23
|
+
try {
|
|
24
|
+
window.indexedDB.deleteDatabase(databaseName(userId));
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
// No storage to clear.
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { AnyEventEnvelope } from '@swirls/looms/core';
|
|
2
|
+
export type SessionEvent = AnyEventEnvelope;
|
|
3
|
+
export interface EventSummary {
|
|
4
|
+
readonly title: string;
|
|
5
|
+
readonly detail?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function summarizeEvent(event: SessionEvent): EventSummary;
|
|
8
|
+
export declare const eventFamilies: readonly string[];
|
|
9
|
+
export declare function familyOf(type: string): string;
|
|
10
|
+
export declare function familyColor(family: string): string;
|
|
11
|
+
interface CachedMeta {
|
|
12
|
+
readonly summary: EventSummary;
|
|
13
|
+
readonly family: string;
|
|
14
|
+
readonly searchText: string;
|
|
15
|
+
}
|
|
16
|
+
export declare function eventMeta(event: SessionEvent): CachedMeta;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import { compactJson } from '../../lib/cn.js';
|
|
2
|
+
import { jsonFields, jsonNumber, jsonText } from '../../lib/json.js';
|
|
3
|
+
/** Longest prefix wins, so `runtime.wait` beats `runtime`. */
|
|
4
|
+
const families = [
|
|
5
|
+
{ family: 'shuttle', prefix: 'shuttle.', color: 'oklch(0.74 0.13 245)' },
|
|
6
|
+
{ family: 'reflect', prefix: 'reflect.', color: 'oklch(0.74 0.12 300)' },
|
|
7
|
+
{ family: 'agent', prefix: 'agent.', color: 'oklch(0.78 0.12 200)' },
|
|
8
|
+
{ family: 'evaluator', prefix: 'evaluator.', color: 'oklch(0.8 0.12 120)' },
|
|
9
|
+
{ family: 'approval', prefix: 'approval.', color: 'oklch(0.8 0.14 70)' },
|
|
10
|
+
{ family: 'wait', prefix: 'runtime.wait', color: 'oklch(0.8 0.14 85)' },
|
|
11
|
+
{ family: 'effect', prefix: 'runtime.effect', color: 'oklch(0.66 0.02 265)' },
|
|
12
|
+
{ family: 'runtime', prefix: 'runtime.', color: 'oklch(0.76 0.13 155)' },
|
|
13
|
+
].toSorted((left, right) => right.prefix.length - left.prefix.length);
|
|
14
|
+
const fallbackFamily = { family: 'other', prefix: '', color: 'oklch(0.6 0.01 265)' };
|
|
15
|
+
function familyFor(type) {
|
|
16
|
+
return families.find((entry) => type.startsWith(entry.prefix)) ?? fallbackFamily;
|
|
17
|
+
}
|
|
18
|
+
function messageContent(payload) {
|
|
19
|
+
return jsonText(jsonFields(jsonFields(payload).message).content) || undefined;
|
|
20
|
+
}
|
|
21
|
+
function definitionLabel(payload) {
|
|
22
|
+
const fields = jsonFields(payload);
|
|
23
|
+
return `${jsonText(fields.kind) ?? 'thread'}:${jsonText(fields.definitionName) ?? 'unknown'}`;
|
|
24
|
+
}
|
|
25
|
+
function summarizeAgent(event) {
|
|
26
|
+
const payload = jsonFields(event.payload);
|
|
27
|
+
switch (event.type) {
|
|
28
|
+
case 'agent.message.received':
|
|
29
|
+
return { title: 'message received', detail: messageContent(event.payload) };
|
|
30
|
+
case 'agent.turn.started':
|
|
31
|
+
return { title: 'turn started', detail: `turn ${jsonNumber(payload.turn) ?? ''}` };
|
|
32
|
+
case 'agent.turn.text_delta':
|
|
33
|
+
return { title: 'text delta', detail: jsonText(payload.delta) };
|
|
34
|
+
case 'agent.message': {
|
|
35
|
+
const message = jsonFields(payload.message);
|
|
36
|
+
const calls = Array.isArray(message.toolCalls) ? message.toolCalls.length : 0;
|
|
37
|
+
const text = messageContent(event.payload);
|
|
38
|
+
return {
|
|
39
|
+
title: 'agent message',
|
|
40
|
+
detail: text ?? (calls > 0 ? `${calls} tool call${calls === 1 ? '' : 's'}` : undefined),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
case 'agent.tool_call.requested': {
|
|
44
|
+
const call = jsonFields(payload.toolCall);
|
|
45
|
+
return {
|
|
46
|
+
title: `tool ${jsonText(call.name) ?? ''}`,
|
|
47
|
+
detail: compactJson(call.arguments ?? null),
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
case 'agent.tool.result': {
|
|
51
|
+
const error = jsonText(payload.error);
|
|
52
|
+
return {
|
|
53
|
+
title: `${error ? 'tool error' : 'tool result'} ${jsonText(payload.name) ?? ''}`,
|
|
54
|
+
detail: error ?? compactJson(payload.result ?? null),
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
case 'agent.steered':
|
|
58
|
+
return {
|
|
59
|
+
title: payload.interrupt === true ? 'steered (interrupt)' : 'steered',
|
|
60
|
+
detail: messageContent(event.payload),
|
|
61
|
+
};
|
|
62
|
+
case 'agent.turn.stopped':
|
|
63
|
+
return { title: 'turn stopped' };
|
|
64
|
+
case 'agent.turn.usage':
|
|
65
|
+
return {
|
|
66
|
+
title: 'token usage',
|
|
67
|
+
detail: `in ${jsonNumber(payload.input) ?? 0} · out ${jsonNumber(payload.output) ?? 0}`,
|
|
68
|
+
};
|
|
69
|
+
case 'agent.effects.requested': {
|
|
70
|
+
const effects = Array.isArray(payload.effects) ? payload.effects : [];
|
|
71
|
+
return {
|
|
72
|
+
title: 'effects requested',
|
|
73
|
+
detail: effects.map((effect) => jsonText(jsonFields(effect).type) ?? '?').join(', '),
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
case 'agent.spawn.requested':
|
|
77
|
+
return { title: 'spawn', detail: definitionLabel(event.payload) };
|
|
78
|
+
default:
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
function summarizeRuntime(event) {
|
|
83
|
+
const payload = jsonFields(event.payload);
|
|
84
|
+
switch (event.type) {
|
|
85
|
+
case 'runtime.run.started':
|
|
86
|
+
return { title: 'run started', detail: definitionLabel(event.payload) };
|
|
87
|
+
case 'runtime.run.completed':
|
|
88
|
+
return {
|
|
89
|
+
title: jsonText(payload.error) ? 'run failed' : 'run completed',
|
|
90
|
+
detail: jsonText(payload.error) ?? compactJson(payload.output ?? null),
|
|
91
|
+
};
|
|
92
|
+
case 'runtime.run.launched':
|
|
93
|
+
return {
|
|
94
|
+
title: 'run launched',
|
|
95
|
+
detail: `${definitionLabel(event.payload)} · ${jsonText(payload.runId) ?? ''}`,
|
|
96
|
+
};
|
|
97
|
+
case 'runtime.thread.started':
|
|
98
|
+
return { title: 'thread started', detail: definitionLabel(event.payload) };
|
|
99
|
+
case 'runtime.thread.completed':
|
|
100
|
+
return { title: 'thread completed', detail: compactJson(payload.output ?? null) };
|
|
101
|
+
case 'runtime.thread.failed':
|
|
102
|
+
return { title: 'thread failed', detail: jsonText(payload.error) };
|
|
103
|
+
case 'runtime.thread.cancelled':
|
|
104
|
+
return { title: 'thread cancelled', detail: jsonText(payload.reason) };
|
|
105
|
+
case 'runtime.wait.registered': {
|
|
106
|
+
const on = jsonFields(payload.on);
|
|
107
|
+
const type = on.type;
|
|
108
|
+
const detail = Array.isArray(type) ? type.map(String).join(', ') : jsonText(type);
|
|
109
|
+
return { title: 'wait registered', detail };
|
|
110
|
+
}
|
|
111
|
+
case 'runtime.wait.satisfied':
|
|
112
|
+
return { title: 'wait satisfied', detail: jsonText(jsonFields(payload.event).type) };
|
|
113
|
+
case 'runtime.effect.failed':
|
|
114
|
+
return { title: 'effect failed', detail: jsonText(payload.error) };
|
|
115
|
+
case 'runtime.signal.received':
|
|
116
|
+
return { title: 'signal', detail: compactJson(event.payload) };
|
|
117
|
+
default:
|
|
118
|
+
return undefined;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
function summarizeShuttle(event) {
|
|
122
|
+
const payload = jsonFields(event.payload);
|
|
123
|
+
switch (event.type) {
|
|
124
|
+
case 'shuttle.user.said':
|
|
125
|
+
return { title: 'user said', detail: jsonText(payload.text) };
|
|
126
|
+
case 'shuttle.routed':
|
|
127
|
+
return {
|
|
128
|
+
title: `routed → ${jsonText(payload.kind) ?? '?'}`,
|
|
129
|
+
detail: jsonText(payload.summary),
|
|
130
|
+
};
|
|
131
|
+
case 'shuttle.brief.amended':
|
|
132
|
+
return {
|
|
133
|
+
title: `brief v${jsonNumber(payload.version) ?? '?'}`,
|
|
134
|
+
detail: jsonText(payload.text),
|
|
135
|
+
};
|
|
136
|
+
case 'shuttle.playbook.loaded':
|
|
137
|
+
return {
|
|
138
|
+
title: `playbook v${jsonNumber(payload.version) ?? 0} loaded`,
|
|
139
|
+
detail: `${Array.isArray(payload.lessons) ? payload.lessons.length : 0} lessons`,
|
|
140
|
+
};
|
|
141
|
+
case 'shuttle.intake.started':
|
|
142
|
+
return { title: 'intake started', detail: jsonText(payload.messageId) };
|
|
143
|
+
case 'shuttle.conductor.spawned':
|
|
144
|
+
return { title: 'conductor spawned', detail: jsonText(payload.childThreadId) };
|
|
145
|
+
case 'shuttle.narrator.spawned':
|
|
146
|
+
return { title: 'narrator spawned', detail: jsonText(payload.childThreadId) };
|
|
147
|
+
case 'shuttle.reroute':
|
|
148
|
+
return {
|
|
149
|
+
title: `reroute → ${jsonText(payload.kind) ?? '?'}`,
|
|
150
|
+
detail: jsonText(payload.messageId),
|
|
151
|
+
};
|
|
152
|
+
case 'shuttle.reflection.launched':
|
|
153
|
+
return { title: 'reflection launched', detail: jsonText(payload.runId) };
|
|
154
|
+
case 'shuttle.turn.thinking_delta':
|
|
155
|
+
return {
|
|
156
|
+
title: 'thinking delta',
|
|
157
|
+
detail: jsonText(payload.delta),
|
|
158
|
+
};
|
|
159
|
+
case 'shuttle.sandbox.moved':
|
|
160
|
+
return {
|
|
161
|
+
title: 'sandbox moved',
|
|
162
|
+
detail: `${String(payload.from)} → ${String(payload.to)}${payload.fromSave === true ? ' (from last save)' : ''}`,
|
|
163
|
+
};
|
|
164
|
+
case 'shuttle.team.changed':
|
|
165
|
+
return {
|
|
166
|
+
title: 'team changed',
|
|
167
|
+
detail: [
|
|
168
|
+
payload.workers === true ? 'workers' : null,
|
|
169
|
+
payload.codex === true ? 'codex' : null,
|
|
170
|
+
payload.claudeCode === true ? 'claude-code' : null,
|
|
171
|
+
payload.cursor === true ? 'cursor' : null,
|
|
172
|
+
]
|
|
173
|
+
.filter(Boolean)
|
|
174
|
+
.join(', '),
|
|
175
|
+
};
|
|
176
|
+
case 'shuttle.vendor.turn_started': {
|
|
177
|
+
const model = jsonText(payload.model);
|
|
178
|
+
return {
|
|
179
|
+
title: `${jsonText(payload.label) ?? 'agent'} turn started`,
|
|
180
|
+
detail: model ? `turn ${jsonNumber(payload.turn) ?? ''} · ${model}` : undefined,
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
case 'shuttle.vendor.message':
|
|
184
|
+
return { title: 'agent said', detail: jsonText(payload.text) };
|
|
185
|
+
case 'shuttle.vendor.tool_started': {
|
|
186
|
+
const call = jsonFields(payload.toolCall);
|
|
187
|
+
const args = jsonFields(call.arguments);
|
|
188
|
+
return {
|
|
189
|
+
title: `ran ${jsonText(call.name) ?? 'tool'}`,
|
|
190
|
+
detail: jsonText(args.command) ?? jsonText(args.path) ?? jsonText(args.query),
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
case 'shuttle.vendor.tool_finished': {
|
|
194
|
+
const error = jsonText(payload.error);
|
|
195
|
+
return {
|
|
196
|
+
title: error ? 'tool failed' : 'tool finished',
|
|
197
|
+
detail: error ?? jsonText(payload.result),
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
case 'shuttle.turn.thought': {
|
|
201
|
+
const durationMs = jsonNumber(payload.durationMs);
|
|
202
|
+
return {
|
|
203
|
+
title: durationMs !== undefined ? `thought (${(durationMs / 1000).toFixed(1)}s)` : 'thought',
|
|
204
|
+
detail: jsonText(payload.text),
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
default:
|
|
208
|
+
return undefined;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
function summarizeApproval(event) {
|
|
212
|
+
const payload = jsonFields(event.payload);
|
|
213
|
+
switch (event.type) {
|
|
214
|
+
case 'approval.requested':
|
|
215
|
+
return { title: 'approval requested', detail: jsonText(payload.title) };
|
|
216
|
+
case 'approval.decided':
|
|
217
|
+
return {
|
|
218
|
+
title: `approval ${payload.outcome === 'approve' ? 'granted' : 'declined'}`,
|
|
219
|
+
detail: jsonText(jsonFields(payload.payload).answer) ?? jsonText(payload.actionId),
|
|
220
|
+
};
|
|
221
|
+
case 'approval.timed_out':
|
|
222
|
+
return { title: 'approval timed out', detail: jsonText(payload.approvalId) };
|
|
223
|
+
default:
|
|
224
|
+
return undefined;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
export function summarizeEvent(event) {
|
|
228
|
+
return (summarizeShuttle(event) ??
|
|
229
|
+
summarizeAgent(event) ??
|
|
230
|
+
summarizeApproval(event) ??
|
|
231
|
+
summarizeRuntime(event) ?? {
|
|
232
|
+
title: event.type.replace(/^[a-z]+\./, ''),
|
|
233
|
+
detail: compactJson(event.payload),
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
export const eventFamilies = [
|
|
237
|
+
...new Set([...families.map((entry) => entry.family), fallbackFamily.family]),
|
|
238
|
+
];
|
|
239
|
+
export function familyOf(type) {
|
|
240
|
+
return familyFor(type).family;
|
|
241
|
+
}
|
|
242
|
+
export function familyColor(family) {
|
|
243
|
+
return families.find((entry) => entry.family === family)?.color ?? fallbackFamily.color;
|
|
244
|
+
}
|
|
245
|
+
const metaCache = new WeakMap();
|
|
246
|
+
export function eventMeta(event) {
|
|
247
|
+
const cached = metaCache.get(event);
|
|
248
|
+
if (cached) {
|
|
249
|
+
return cached;
|
|
250
|
+
}
|
|
251
|
+
const summary = summarizeEvent(event);
|
|
252
|
+
const meta = {
|
|
253
|
+
summary,
|
|
254
|
+
family: familyOf(event.type),
|
|
255
|
+
searchText: [event.type, event.threadId ?? '', summary.title, summary.detail ?? '']
|
|
256
|
+
.join(' ')
|
|
257
|
+
.toLowerCase(),
|
|
258
|
+
};
|
|
259
|
+
metaCache.set(event, meta);
|
|
260
|
+
return meta;
|
|
261
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type SessionEvent } from './event-catalog.js';
|
|
2
|
+
export declare function EventInspector({ event, threadLabel, onClose, className, }: {
|
|
3
|
+
event: SessionEvent;
|
|
4
|
+
threadLabel?: string;
|
|
5
|
+
onClose?: () => void;
|
|
6
|
+
className?: string;
|
|
7
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { X } from 'lucide-react';
|
|
3
|
+
import { asJson } from '@swirls/looms/core';
|
|
4
|
+
import { JsonTree } from '../../components/json-tree.js';
|
|
5
|
+
import { Button } from '../../components/ui/button.js';
|
|
6
|
+
import { ScrollArea } from '../../components/ui/scroll-area.js';
|
|
7
|
+
import { Tabs, TabsContent, TabsList, TabsTrigger } from '../../components/ui/tabs.js';
|
|
8
|
+
import { cn } from '../../lib/cn.js';
|
|
9
|
+
import { eventMeta, familyColor } from './event-catalog.js';
|
|
10
|
+
function Pane({ value, children }) {
|
|
11
|
+
return (_jsx(TabsContent, { value: value, className: "min-h-0", children: _jsx(ScrollArea, { className: "h-full", children: _jsx("div", { className: "px-3 pt-1 pb-3", children: children }) }) }));
|
|
12
|
+
}
|
|
13
|
+
export function EventInspector({ event, threadLabel, onClose, className, }) {
|
|
14
|
+
const meta = eventMeta(event);
|
|
15
|
+
return (_jsx("div", { className: cn('bg-sidebar flex h-[46%] min-h-44 shrink-0 flex-col border-t', className), children: _jsxs(Tabs, { defaultValue: "payload", className: "min-h-0 flex-1 gap-0", children: [_jsxs("div", { className: "flex h-10 shrink-0 items-center gap-2 pr-2 pl-3", children: [_jsx("span", { "aria-hidden": true, className: "size-1.5 shrink-0 rounded-full", style: { backgroundColor: familyColor(meta.family) } }), _jsxs("span", { className: "text-muted-foreground font-mono text-[11px] tabular-nums", children: ["#", event.seq] }), _jsx("span", { className: "min-w-0 flex-1 truncate font-mono text-xs", title: event.type, children: event.type }), _jsxs(TabsList, { children: [_jsx(TabsTrigger, { value: "payload", children: "Payload" }), _jsx(TabsTrigger, { value: "envelope", children: "Envelope" })] }), onClose ? (_jsx(Button, { variant: "ghost", size: "icon-sm", "aria-label": "Close inspector", onClick: onClose, children: _jsx(X, {}) })) : null] }), threadLabel ? (_jsxs("p", { className: "text-muted-foreground -mt-1 truncate px-3 pb-1.5 text-[11px]", children: ["on ", _jsx("span", { className: "text-foreground", children: threadLabel })] })) : null, _jsx(Pane, { value: "payload", children: _jsx(JsonTree, { value: event.payload, defaultExpandDepth: 2 }) }), _jsx(Pane, { value: "envelope", children: _jsx(JsonTree, { value: asJson({
|
|
16
|
+
id: event.id,
|
|
17
|
+
runId: event.runId,
|
|
18
|
+
seq: event.seq,
|
|
19
|
+
ts: event.ts,
|
|
20
|
+
type: event.type,
|
|
21
|
+
threadId: event.threadId,
|
|
22
|
+
parentThreadId: event.parentThreadId ?? null,
|
|
23
|
+
causationId: event.causationId ?? null,
|
|
24
|
+
correlationId: event.correlationId ?? null,
|
|
25
|
+
effectId: event.effectId ?? null,
|
|
26
|
+
origin: event.origin,
|
|
27
|
+
ephemeral: event.ephemeral ?? false,
|
|
28
|
+
}) }) })] }) }));
|
|
29
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type SessionEvent } from './event-catalog.js';
|
|
2
|
+
/** Which optional columns a row shows. Leave it out for the default set. */
|
|
3
|
+
export interface EventRowColumns {
|
|
4
|
+
readonly seq: boolean;
|
|
5
|
+
readonly time: boolean;
|
|
6
|
+
readonly session: boolean;
|
|
7
|
+
readonly detail: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare function EventRow({ event, startedAt, threadLabel, runLabel, runId, timeMode, columns, selected, onSelectSeq, }: {
|
|
10
|
+
event: SessionEvent;
|
|
11
|
+
startedAt?: number;
|
|
12
|
+
threadLabel?: string;
|
|
13
|
+
/** Optional session / run chip shown on the global log. */
|
|
14
|
+
runLabel?: string;
|
|
15
|
+
runId?: string;
|
|
16
|
+
timeMode?: 'offset' | 'absolute';
|
|
17
|
+
/** Explicit column choices. Without them the time column follows the container's width. */
|
|
18
|
+
columns?: EventRowColumns;
|
|
19
|
+
selected: boolean;
|
|
20
|
+
onSelectSeq: (seq: number | undefined) => void;
|
|
21
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cn, shortId } from '../../lib/cn.js';
|
|
3
|
+
import { Link } from '../../shuttle/index.js';
|
|
4
|
+
import { eventMeta, familyColor } from './event-catalog.js';
|
|
5
|
+
export function EventRow({ event, startedAt, threadLabel, runLabel, runId, timeMode = 'offset', columns, selected, onSelectSeq, }) {
|
|
6
|
+
const meta = eventMeta(event);
|
|
7
|
+
const offset = startedAt !== undefined ? Math.max(0, event.ts - startedAt) : undefined;
|
|
8
|
+
return (_jsxs("button", { type: "button", onClick: () => onSelectSeq(selected ? undefined : event.seq), title: [meta.summary.title, meta.summary.detail].filter(Boolean).join(' — '), className: cn('flex h-[26px] w-full items-center gap-2 rounded-sm px-1.5 text-left font-mono text-[11px] transition-colors duration-100', selected ? 'bg-accent' : 'hover:bg-accent/40', event.ephemeral && 'opacity-50'), children: [_jsx("span", { className: "size-1.5 shrink-0 rounded-full", style: { backgroundColor: familyColor(meta.family) } }), (columns?.seq ?? true) ? (_jsx("span", { className: "text-muted-foreground w-7 shrink-0 text-right tabular-nums", children: event.seq })) : null, (columns?.time ?? true) ? (_jsx("span", { className: cn('text-muted-foreground/60 w-14 shrink-0 text-right tabular-nums', !columns && 'event-offset'), children: timeMode === 'absolute'
|
|
9
|
+
? formatAbsolute(event.ts)
|
|
10
|
+
: offset !== undefined
|
|
11
|
+
? formatOffset(offset)
|
|
12
|
+
: '' })) : null, (columns?.session ?? true) && (runLabel || runId) ? (runId ? (_jsx(Link, { to: { page: 'session', sessionId: runId, thread: event.threadId ?? undefined }, onClick: (click) => click.stopPropagation(), className: "text-muted-foreground hover:text-foreground max-w-28 shrink-0 truncate font-sans underline-offset-2 hover:underline", title: runId, children: runLabel ?? shortId(runId) })) : (_jsx("span", { className: "text-muted-foreground/70 max-w-28 shrink-0 truncate font-sans", children: runLabel }))) : null, _jsxs("span", { className: "min-w-0 flex-1 truncate whitespace-nowrap", children: [_jsx("span", { className: "text-foreground", children: meta.summary.title }), (columns?.detail ?? true) && meta.summary.detail ? (_jsx("span", { className: "text-muted-foreground ml-1.5", children: meta.summary.detail })) : null] }), threadLabel ? (_jsx("span", { className: "event-thread text-muted-foreground/70 max-w-24 shrink-0 truncate font-sans", children: threadLabel })) : null] }));
|
|
13
|
+
}
|
|
14
|
+
function formatOffset(ms) {
|
|
15
|
+
if (ms < 1000) {
|
|
16
|
+
return `+${ms}ms`;
|
|
17
|
+
}
|
|
18
|
+
if (ms < 60_000) {
|
|
19
|
+
return `+${(ms / 1000).toFixed(1)}s`;
|
|
20
|
+
}
|
|
21
|
+
return `+${Math.floor(ms / 60_000)}m`;
|
|
22
|
+
}
|
|
23
|
+
function formatAbsolute(ts) {
|
|
24
|
+
const date = new Date(ts);
|
|
25
|
+
if (!Number.isFinite(date.getTime())) {
|
|
26
|
+
return '';
|
|
27
|
+
}
|
|
28
|
+
return date.toLocaleTimeString(undefined, {
|
|
29
|
+
hour: '2-digit',
|
|
30
|
+
minute: '2-digit',
|
|
31
|
+
second: '2-digit',
|
|
32
|
+
hour12: false,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type SessionEvent } from './event-catalog.js';
|
|
2
|
+
export declare function EventStream({ events, startedAt, threadId, threadLabel, labelFor, onClearThread, selectedSeq, onSelectSeq, toolbar, title, split, onClose, }: {
|
|
3
|
+
events: readonly SessionEvent[];
|
|
4
|
+
startedAt?: number;
|
|
5
|
+
threadId?: string;
|
|
6
|
+
threadLabel?: string;
|
|
7
|
+
labelFor: (threadId: string | null) => string | undefined;
|
|
8
|
+
onClearThread?: () => void;
|
|
9
|
+
selectedSeq?: number;
|
|
10
|
+
onSelectSeq: (seq: number | undefined) => void;
|
|
11
|
+
/** When true, drop the panel title. */
|
|
12
|
+
toolbar?: boolean;
|
|
13
|
+
title?: string;
|
|
14
|
+
/** Puts the inspector beside the list instead of under it, for a wide and short panel. */
|
|
15
|
+
split?: boolean;
|
|
16
|
+
/** Adds a close button to the header. */
|
|
17
|
+
onClose?: () => void;
|
|
18
|
+
}): import("react").JSX.Element;
|