@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.
- package/CHANGELOG.md +10 -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 +64 -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,32 @@
|
|
|
1
|
+
const SUFFIXES = new Set(['jr', 'jr.', 'sr', 'sr.', 'ii', 'iii', 'iv', 'phd', 'md']);
|
|
2
|
+
const EMOJI = /\p{Extended_Pictographic}/u;
|
|
3
|
+
/** The first user-perceived character of a word, so an emoji or accented letter stays whole. */
|
|
4
|
+
function firstGrapheme(word) {
|
|
5
|
+
if (typeof Intl.Segmenter === 'function') {
|
|
6
|
+
const [first] = new Intl.Segmenter(undefined, { granularity: 'grapheme' }).segment(word);
|
|
7
|
+
return first?.segment ?? '';
|
|
8
|
+
}
|
|
9
|
+
return Array.from(word)[0] ?? '';
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Up to two initials for a person: the first and last word of their name, leaving out suffixes
|
|
13
|
+
* such as "III". A name that starts with an emoji is shown as that emoji alone, and a name that
|
|
14
|
+
* is only an email address uses the part before the `@`. Returns nothing when there is no name.
|
|
15
|
+
*/
|
|
16
|
+
export function initials(name) {
|
|
17
|
+
const trimmed = (name ?? '').trim();
|
|
18
|
+
const source = trimmed.includes('@') ? (trimmed.split('@')[0] ?? '') : trimmed;
|
|
19
|
+
// An address has no spaces, so its dots and dashes are what separate the words.
|
|
20
|
+
const words = source.split(trimmed.includes('@') ? /[\s._-]+/ : /\s+/).filter(Boolean);
|
|
21
|
+
const meaningful = words.length > 1 ? words.filter((word) => !SUFFIXES.has(word.toLowerCase())) : words;
|
|
22
|
+
const first = meaningful[0];
|
|
23
|
+
const last = meaningful.length > 1 ? meaningful.at(-1) : undefined;
|
|
24
|
+
if (!first) {
|
|
25
|
+
return '';
|
|
26
|
+
}
|
|
27
|
+
const lead = firstGrapheme(first);
|
|
28
|
+
if (EMOJI.test(lead)) {
|
|
29
|
+
return lead;
|
|
30
|
+
}
|
|
31
|
+
return `${lead}${last ? firstGrapheme(last) : ''}`.toLocaleUpperCase();
|
|
32
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type JsonObject, type JsonValue } from '@swirls/looms/core';
|
|
2
|
+
export type JsonNode = {
|
|
3
|
+
readonly kind: 'object';
|
|
4
|
+
readonly value: JsonObject;
|
|
5
|
+
} | {
|
|
6
|
+
readonly kind: 'array';
|
|
7
|
+
readonly value: readonly JsonValue[];
|
|
8
|
+
} | {
|
|
9
|
+
readonly kind: 'string';
|
|
10
|
+
readonly value: string;
|
|
11
|
+
} | {
|
|
12
|
+
readonly kind: 'number';
|
|
13
|
+
readonly value: number;
|
|
14
|
+
} | {
|
|
15
|
+
readonly kind: 'boolean';
|
|
16
|
+
readonly value: boolean;
|
|
17
|
+
} | {
|
|
18
|
+
readonly kind: 'null';
|
|
19
|
+
};
|
|
20
|
+
export declare function jsonNode(value: JsonValue): JsonNode;
|
|
21
|
+
/** Fields of a JSON object, or no fields for any other value. */
|
|
22
|
+
export declare function jsonFields(value: JsonValue | null | undefined): JsonObject;
|
|
23
|
+
export declare function jsonText(value: JsonValue | undefined): string | undefined;
|
|
24
|
+
export declare function jsonNumber(value: JsonValue | undefined): number | undefined;
|
|
25
|
+
/** Parses text that holds a JSON object or array; plain strings and scalars stay text. */
|
|
26
|
+
export declare function parseStructuredJson(text: string): JsonObject | readonly JsonValue[] | undefined;
|
|
27
|
+
export declare function jsonEntries(node: JsonNode): readonly (readonly [string, JsonValue])[];
|
|
28
|
+
/** One-line summary shown beside a collapsed object or array. */
|
|
29
|
+
export declare function jsonPreview(node: JsonNode, budget?: number): string;
|
|
30
|
+
/** True for a plain, non-array object. Its values stay `unknown` until each is checked. */
|
|
31
|
+
export declare function isRecord(value: unknown): value is {
|
|
32
|
+
readonly [key: string]: unknown;
|
|
33
|
+
};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { isJsonNumber, isJsonObject, isJsonString, } from '@swirls/looms/core';
|
|
2
|
+
export function jsonNode(value) {
|
|
3
|
+
if (value === null) {
|
|
4
|
+
return { kind: 'null' };
|
|
5
|
+
}
|
|
6
|
+
if (Array.isArray(value)) {
|
|
7
|
+
return { kind: 'array', value };
|
|
8
|
+
}
|
|
9
|
+
if (isJsonString(value)) {
|
|
10
|
+
return { kind: 'string', value };
|
|
11
|
+
}
|
|
12
|
+
if (isJsonNumber(value)) {
|
|
13
|
+
return { kind: 'number', value };
|
|
14
|
+
}
|
|
15
|
+
if (value === true || value === false) {
|
|
16
|
+
return { kind: 'boolean', value };
|
|
17
|
+
}
|
|
18
|
+
return { kind: 'object', value: isJsonObject(value) ? value : {} };
|
|
19
|
+
}
|
|
20
|
+
/** Fields of a JSON object, or no fields for any other value. */
|
|
21
|
+
export function jsonFields(value) {
|
|
22
|
+
return isJsonObject(value) ? value : {};
|
|
23
|
+
}
|
|
24
|
+
export function jsonText(value) {
|
|
25
|
+
return isJsonString(value) ? value : undefined;
|
|
26
|
+
}
|
|
27
|
+
export function jsonNumber(value) {
|
|
28
|
+
return isJsonNumber(value) ? value : undefined;
|
|
29
|
+
}
|
|
30
|
+
/** Parses text that holds a JSON object or array; plain strings and scalars stay text. */
|
|
31
|
+
export function parseStructuredJson(text) {
|
|
32
|
+
const trimmed = text.trimStart();
|
|
33
|
+
if (!trimmed.startsWith('{') && !trimmed.startsWith('[')) {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
let value;
|
|
37
|
+
try {
|
|
38
|
+
value = JSON.parse(text);
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
return Array.isArray(value) || isJsonObject(value) ? value : undefined;
|
|
44
|
+
}
|
|
45
|
+
export function jsonEntries(node) {
|
|
46
|
+
switch (node.kind) {
|
|
47
|
+
case 'object':
|
|
48
|
+
return Object.entries(node.value);
|
|
49
|
+
case 'array':
|
|
50
|
+
return node.value.map((item, index) => [String(index), item]);
|
|
51
|
+
case 'string':
|
|
52
|
+
case 'number':
|
|
53
|
+
case 'boolean':
|
|
54
|
+
case 'null':
|
|
55
|
+
return [];
|
|
56
|
+
default: {
|
|
57
|
+
const exhaustive = node;
|
|
58
|
+
return exhaustive;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function scalarPreview(value) {
|
|
63
|
+
const node = jsonNode(value);
|
|
64
|
+
switch (node.kind) {
|
|
65
|
+
case 'object':
|
|
66
|
+
return Object.keys(node.value).length === 0 ? '{}' : '{…}';
|
|
67
|
+
case 'array':
|
|
68
|
+
return `[${node.value.length}]`;
|
|
69
|
+
case 'string':
|
|
70
|
+
return JSON.stringify(node.value.length > 24 ? `${node.value.slice(0, 24)}…` : node.value);
|
|
71
|
+
case 'number':
|
|
72
|
+
case 'boolean':
|
|
73
|
+
return String(node.value);
|
|
74
|
+
case 'null':
|
|
75
|
+
return 'null';
|
|
76
|
+
default: {
|
|
77
|
+
const exhaustive = node;
|
|
78
|
+
return exhaustive;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/** One-line summary shown beside a collapsed object or array. */
|
|
83
|
+
export function jsonPreview(node, budget = 72) {
|
|
84
|
+
const entries = jsonEntries(node);
|
|
85
|
+
const open = node.kind === 'array' ? '[' : '{';
|
|
86
|
+
const close = node.kind === 'array' ? ']' : '}';
|
|
87
|
+
let text = '';
|
|
88
|
+
for (const [key, value] of entries) {
|
|
89
|
+
const part = node.kind === 'array' ? scalarPreview(value) : `${key}: ${scalarPreview(value)}`;
|
|
90
|
+
const next = text ? `${text}, ${part}` : part;
|
|
91
|
+
if (next.length > budget) {
|
|
92
|
+
return `${open} ${text ? `${text}, ` : ''}… ${close}`;
|
|
93
|
+
}
|
|
94
|
+
text = next;
|
|
95
|
+
}
|
|
96
|
+
return text ? `${open} ${text} ${close}` : `${open}${close}`;
|
|
97
|
+
}
|
|
98
|
+
/** True for a plain, non-array object. Its values stay `unknown` until each is checked. */
|
|
99
|
+
export function isRecord(value) {
|
|
100
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
101
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Run ids start with a base36 millisecond timestamp (`run_<ms36>_<counter>_<entropy>`). */
|
|
2
|
+
export declare function runCreatedAt(runId: string): number | undefined;
|
|
3
|
+
export declare function relativeTime(then: number, now: number): string;
|
|
4
|
+
/** Compact sidebar stamp: `now`, `1m`, `3h`, `6d`, `2w`, `11mo`, `3y`. */
|
|
5
|
+
export declare function compactRelativeTime(then: number, now: number): string;
|
|
6
|
+
/** Absolute timestamp for tooltips next to compact stamps. */
|
|
7
|
+
export declare function fullDateTime(ts: number): string;
|
|
8
|
+
export declare function clockTime(ts: number): string;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/** Run ids start with a base36 millisecond timestamp (`run_<ms36>_<counter>_<entropy>`). */
|
|
2
|
+
export function runCreatedAt(runId) {
|
|
3
|
+
const stamp = runId.split('_')[1];
|
|
4
|
+
if (!stamp) {
|
|
5
|
+
return undefined;
|
|
6
|
+
}
|
|
7
|
+
const ms = Number.parseInt(stamp, 36);
|
|
8
|
+
return Number.isFinite(ms) ? ms : undefined;
|
|
9
|
+
}
|
|
10
|
+
export function relativeTime(then, now) {
|
|
11
|
+
const seconds = Math.max(0, Math.round((now - then) / 1000));
|
|
12
|
+
if (seconds < 45) {
|
|
13
|
+
return 'just now';
|
|
14
|
+
}
|
|
15
|
+
const minutes = Math.round(seconds / 60);
|
|
16
|
+
if (minutes < 60) {
|
|
17
|
+
return `${minutes}m ago`;
|
|
18
|
+
}
|
|
19
|
+
const hours = Math.round(minutes / 60);
|
|
20
|
+
if (hours < 24) {
|
|
21
|
+
return `${hours}h ago`;
|
|
22
|
+
}
|
|
23
|
+
return `${Math.round(hours / 24)}d ago`;
|
|
24
|
+
}
|
|
25
|
+
/** Compact sidebar stamp: `now`, `1m`, `3h`, `6d`, `2w`, `11mo`, `3y`. */
|
|
26
|
+
export function compactRelativeTime(then, now) {
|
|
27
|
+
const seconds = Math.max(0, Math.round((now - then) / 1000));
|
|
28
|
+
if (seconds < 45) {
|
|
29
|
+
return 'now';
|
|
30
|
+
}
|
|
31
|
+
const minutes = Math.round(seconds / 60);
|
|
32
|
+
if (minutes < 60) {
|
|
33
|
+
return `${minutes}m`;
|
|
34
|
+
}
|
|
35
|
+
const hours = Math.round(minutes / 60);
|
|
36
|
+
if (hours < 24) {
|
|
37
|
+
return `${hours}h`;
|
|
38
|
+
}
|
|
39
|
+
const days = Math.round(hours / 24);
|
|
40
|
+
if (days < 7) {
|
|
41
|
+
return `${days}d`;
|
|
42
|
+
}
|
|
43
|
+
if (days < 30) {
|
|
44
|
+
return `${Math.floor(days / 7)}w`;
|
|
45
|
+
}
|
|
46
|
+
if (days < 365) {
|
|
47
|
+
return `${Math.floor(days / 30)}mo`;
|
|
48
|
+
}
|
|
49
|
+
return `${Math.floor(days / 365)}y`;
|
|
50
|
+
}
|
|
51
|
+
/** Absolute timestamp for tooltips next to compact stamps. */
|
|
52
|
+
export function fullDateTime(ts) {
|
|
53
|
+
return new Date(ts).toLocaleString([], { dateStyle: 'medium', timeStyle: 'short' });
|
|
54
|
+
}
|
|
55
|
+
export function clockTime(ts) {
|
|
56
|
+
return new Date(ts).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
|
|
57
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useMediaQuery(query: string): boolean;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { useCallback, useSyncExternalStore } from 'react';
|
|
2
|
+
export function useMediaQuery(query) {
|
|
3
|
+
const subscribe = useCallback((notify) => {
|
|
4
|
+
const list = window.matchMedia(query);
|
|
5
|
+
list.addEventListener('change', notify);
|
|
6
|
+
return () => list.removeEventListener('change', notify);
|
|
7
|
+
}, [query]);
|
|
8
|
+
return useSyncExternalStore(subscribe, () => window.matchMedia(query).matches);
|
|
9
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
/** Wall clock that re-renders on an interval, for relative timestamps. */
|
|
3
|
+
export function useNow(intervalMs = 30_000) {
|
|
4
|
+
const [now, setNow] = useState(() => Date.now());
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
const timer = window.setInterval(() => setNow(Date.now()), intervalMs);
|
|
7
|
+
return () => window.clearInterval(timer);
|
|
8
|
+
}, [intervalMs]);
|
|
9
|
+
return now;
|
|
10
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How many of the ascending `thresholds` an element's width has reached. It re-renders only
|
|
3
|
+
* when the width crosses a threshold, not on every pixel of a resize. Until the element
|
|
4
|
+
* mounts it reports the widest bucket.
|
|
5
|
+
*/
|
|
6
|
+
export declare function useWidthBucket<T extends HTMLElement>(thresholds: readonly number[]): [(node: T | null) => void, number];
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { useCallback, useState } from 'react';
|
|
2
|
+
function bucketFor(width, thresholds) {
|
|
3
|
+
return thresholds.filter((threshold) => width >= threshold).length;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* How many of the ascending `thresholds` an element's width has reached. It re-renders only
|
|
7
|
+
* when the width crosses a threshold, not on every pixel of a resize. Until the element
|
|
8
|
+
* mounts it reports the widest bucket.
|
|
9
|
+
*/
|
|
10
|
+
export function useWidthBucket(thresholds) {
|
|
11
|
+
const [bucket, setBucket] = useState(thresholds.length);
|
|
12
|
+
const [observer] = useState(() => typeof ResizeObserver === 'undefined'
|
|
13
|
+
? null
|
|
14
|
+
: new ResizeObserver((entries) => {
|
|
15
|
+
const entry = entries.at(-1);
|
|
16
|
+
if (entry) {
|
|
17
|
+
setBucket(bucketFor(entry.contentRect.width, thresholds));
|
|
18
|
+
}
|
|
19
|
+
}));
|
|
20
|
+
const ref = useCallback((node) => {
|
|
21
|
+
observer?.disconnect();
|
|
22
|
+
if (node) {
|
|
23
|
+
setBucket(bucketFor(node.getBoundingClientRect().width, thresholds));
|
|
24
|
+
observer?.observe(node);
|
|
25
|
+
}
|
|
26
|
+
}, [observer, thresholds]);
|
|
27
|
+
return [ref, bucket];
|
|
28
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Session } from '../features/sessions/session.js';
|
|
2
|
+
import { SessionHeader } from '../features/sessions/session-header.js';
|
|
3
|
+
import { SessionLayout } from '../features/sessions/session-layout.js';
|
|
4
|
+
/**
|
|
5
|
+
* Shuttle, as parts. A host puts them together however it likes:
|
|
6
|
+
*
|
|
7
|
+
* <Shuttle.Provider host={host} router={router} identity={identity}>
|
|
8
|
+
* <Shuttle.Session id={sessionId}>
|
|
9
|
+
* <Shuttle.SessionHeader />
|
|
10
|
+
* <Shuttle.Conversation />
|
|
11
|
+
* <Shuttle.Composer />
|
|
12
|
+
* <Shuttle.Artifacts />
|
|
13
|
+
* </Shuttle.Session>
|
|
14
|
+
* </Shuttle.Provider>
|
|
15
|
+
*
|
|
16
|
+
* `Shuttle.SessionLayout` is Shuttle's own arrangement of the session's parts, for a host that
|
|
17
|
+
* wants the whole thing. A part reads the session from `useSession()`, so anything a host
|
|
18
|
+
* writes itself can sit beside them and read the same.
|
|
19
|
+
*/
|
|
20
|
+
import { SessionAgents, SessionArtifacts, SessionComposer, SessionConversation, SessionEvents, SessionPalette } from '../features/sessions/session-parts.js';
|
|
21
|
+
import { AppSidebarShell } from '../features/workspace/app-sidebar.js';
|
|
22
|
+
import { ShuttleProvider } from '../shuttle/index.js';
|
|
23
|
+
export declare const Shuttle: {
|
|
24
|
+
Provider: typeof ShuttleProvider;
|
|
25
|
+
/**
|
|
26
|
+
* The frame Shuttle's pages sit in: folders and sessions down the side, the page beside
|
|
27
|
+
* them. A host with its own navigation leaves it out.
|
|
28
|
+
*/
|
|
29
|
+
Shell: typeof AppSidebarShell;
|
|
30
|
+
/** Follows one session and gives it to the parts inside. */
|
|
31
|
+
Session: typeof Session;
|
|
32
|
+
/** Shuttle's own arrangement of everything below. */
|
|
33
|
+
SessionLayout: typeof SessionLayout;
|
|
34
|
+
SessionHeader: typeof SessionHeader;
|
|
35
|
+
Agents: typeof SessionAgents;
|
|
36
|
+
Conversation: typeof SessionConversation;
|
|
37
|
+
Composer: typeof SessionComposer;
|
|
38
|
+
Artifacts: typeof SessionArtifacts;
|
|
39
|
+
Events: typeof SessionEvents;
|
|
40
|
+
Palette: typeof SessionPalette;
|
|
41
|
+
};
|
|
42
|
+
export { defaultArtifactTypes, type ArtifactType, type ArtifactViewProps, } from '../features/artifacts/artifact-types.js';
|
|
43
|
+
export { useSession, type SessionProps, type SessionValue } from '../features/sessions/session.js';
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Session } from '../features/sessions/session.js';
|
|
2
|
+
import { SessionHeader } from '../features/sessions/session-header.js';
|
|
3
|
+
import { SessionLayout } from '../features/sessions/session-layout.js';
|
|
4
|
+
/**
|
|
5
|
+
* Shuttle, as parts. A host puts them together however it likes:
|
|
6
|
+
*
|
|
7
|
+
* <Shuttle.Provider host={host} router={router} identity={identity}>
|
|
8
|
+
* <Shuttle.Session id={sessionId}>
|
|
9
|
+
* <Shuttle.SessionHeader />
|
|
10
|
+
* <Shuttle.Conversation />
|
|
11
|
+
* <Shuttle.Composer />
|
|
12
|
+
* <Shuttle.Artifacts />
|
|
13
|
+
* </Shuttle.Session>
|
|
14
|
+
* </Shuttle.Provider>
|
|
15
|
+
*
|
|
16
|
+
* `Shuttle.SessionLayout` is Shuttle's own arrangement of the session's parts, for a host that
|
|
17
|
+
* wants the whole thing. A part reads the session from `useSession()`, so anything a host
|
|
18
|
+
* writes itself can sit beside them and read the same.
|
|
19
|
+
*/
|
|
20
|
+
import { SessionAgents, SessionArtifacts, SessionComposer, SessionConversation, SessionEvents, SessionPalette, } from '../features/sessions/session-parts.js';
|
|
21
|
+
import { AppSidebarShell } from '../features/workspace/app-sidebar.js';
|
|
22
|
+
import { ShuttleProvider } from '../shuttle/index.js';
|
|
23
|
+
export const Shuttle = {
|
|
24
|
+
Provider: ShuttleProvider,
|
|
25
|
+
/**
|
|
26
|
+
* The frame Shuttle's pages sit in: folders and sessions down the side, the page beside
|
|
27
|
+
* them. A host with its own navigation leaves it out.
|
|
28
|
+
*/
|
|
29
|
+
Shell: AppSidebarShell,
|
|
30
|
+
/** Follows one session and gives it to the parts inside. */
|
|
31
|
+
Session,
|
|
32
|
+
/** Shuttle's own arrangement of everything below. */
|
|
33
|
+
SessionLayout,
|
|
34
|
+
SessionHeader,
|
|
35
|
+
Agents: SessionAgents,
|
|
36
|
+
Conversation: SessionConversation,
|
|
37
|
+
Composer: SessionComposer,
|
|
38
|
+
Artifacts: SessionArtifacts,
|
|
39
|
+
Events: SessionEvents,
|
|
40
|
+
Palette: SessionPalette,
|
|
41
|
+
};
|
|
42
|
+
export { defaultArtifactTypes, } from '../features/artifacts/artifact-types.js';
|
|
43
|
+
export { useSession } from '../features/sessions/session.js';
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The machine Shuttle is running on, when it has one: a desktop app with a runner that keeps a
|
|
3
|
+
* sandbox on the device. A host with no machine (a browser tab, another product's page) leaves
|
|
4
|
+
* it out, and everything that depends on it stays out of the way.
|
|
5
|
+
*/
|
|
6
|
+
export interface ShuttleDevice {
|
|
7
|
+
/** Names this machine's sandbox. Stable across launches. */
|
|
8
|
+
readonly deviceId: string;
|
|
9
|
+
readonly deviceName: string;
|
|
10
|
+
readonly platform: string;
|
|
11
|
+
/** What the app's runner last reported, such as `online` or `preparing`. */
|
|
12
|
+
runnerStatus(): Promise<DeviceRunnerStatus>;
|
|
13
|
+
/** Whether a new session starts on this machine. A setting in the app's Sandbox menu. */
|
|
14
|
+
startsLocally(): Promise<boolean>;
|
|
15
|
+
/** Calls back whenever that changes. Returns a function that stops it. */
|
|
16
|
+
onRunnerStatus(listener: (status: DeviceRunnerStatus) => void): () => void;
|
|
17
|
+
/**
|
|
18
|
+
* The rest came with a later build of the app, so an older one that is still installed does
|
|
19
|
+
* not have them. Ask before calling.
|
|
20
|
+
*/
|
|
21
|
+
/** How many sessions are waiting on this person, shown on the app's Dock icon. */
|
|
22
|
+
setBadge?(count: number): void;
|
|
23
|
+
/** A system notification. Clicking it opens `path` in the app. */
|
|
24
|
+
notify?(notice: {
|
|
25
|
+
title: string;
|
|
26
|
+
body: string;
|
|
27
|
+
path?: string;
|
|
28
|
+
}): void;
|
|
29
|
+
/** Calls back when the app wants the page somewhere: a menu item, a notification, a link. */
|
|
30
|
+
onNavigate?(listener: (path: string) => void): () => void;
|
|
31
|
+
}
|
|
32
|
+
export interface DeviceRunnerStatus {
|
|
33
|
+
readonly status: 'starting' | 'preparing' | 'connecting' | 'online' | 'offline' | 'unauthorized' | 'error';
|
|
34
|
+
readonly message?: string;
|
|
35
|
+
readonly backend?: {
|
|
36
|
+
readonly id: string;
|
|
37
|
+
readonly label: string;
|
|
38
|
+
readonly isolation: string;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/** How a local sandbox is kept apart from the machine, in a few words. */
|
|
42
|
+
export declare function isolationLabel(isolation: string | undefined): string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const ISOLATION = {
|
|
2
|
+
microvm: 'in its own virtual machine',
|
|
3
|
+
vm: 'in a virtual machine',
|
|
4
|
+
container: 'in a container',
|
|
5
|
+
process: 'as a sandboxed process',
|
|
6
|
+
};
|
|
7
|
+
/** How a local sandbox is kept apart from the machine, in a few words. */
|
|
8
|
+
export function isolationLabel(isolation) {
|
|
9
|
+
return (isolation && ISOLATION[isolation]) || 'in a sandbox';
|
|
10
|
+
}
|