@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,246 @@
|
|
|
1
|
+
import { oc } from '@orpc/contract';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { Ok } from './common.js';
|
|
4
|
+
/** A GitHub repository a folder works on, reached through one installation of the App. */
|
|
5
|
+
export const LinkedRepo = z.object({
|
|
6
|
+
installationId: z.number(),
|
|
7
|
+
owner: z.string(),
|
|
8
|
+
name: z.string(),
|
|
9
|
+
fullName: z.string(),
|
|
10
|
+
defaultBranch: z.string(),
|
|
11
|
+
private: z.boolean(),
|
|
12
|
+
});
|
|
13
|
+
/** Which pull requests in a folder's repositories Shuttle reviews without being asked. */
|
|
14
|
+
export const AutoReviewMode = z.enum(['off', 'others', 'all']);
|
|
15
|
+
export const WorkspaceFolder = z.object({
|
|
16
|
+
folderId: z.string(),
|
|
17
|
+
name: z.string(),
|
|
18
|
+
createdAt: z.number(),
|
|
19
|
+
archived: z.boolean(),
|
|
20
|
+
// A folder made before repos could be linked has none stored.
|
|
21
|
+
repos: z.array(LinkedRepo).readonly().default([]),
|
|
22
|
+
/** Absent on a folder made before automatic review existed, which means `off`. */
|
|
23
|
+
autoReview: AutoReviewMode.optional(),
|
|
24
|
+
});
|
|
25
|
+
/** What a session is doing, as its listing in a workspace shows it. */
|
|
26
|
+
export const SessionActivity = z.enum(['working', 'needs_input', 'idle', 'error']);
|
|
27
|
+
/** A session as a workspace lists it. */
|
|
28
|
+
export const WorkspaceSession = z.object({
|
|
29
|
+
runId: z.string(),
|
|
30
|
+
folderId: z.string(),
|
|
31
|
+
title: z.string(),
|
|
32
|
+
goal: z.string(),
|
|
33
|
+
/**
|
|
34
|
+
* `requested`, `running`, `completed`, `failed` or `cancelled`. Left open because it is copied
|
|
35
|
+
* from the session's run, which may settle in a state this list does not name.
|
|
36
|
+
*/
|
|
37
|
+
status: z.string(),
|
|
38
|
+
/** A `SessionActivity`. The workspace stores it as text, so it is read back as text. */
|
|
39
|
+
activity: z.string(),
|
|
40
|
+
/** The session's log position the activity was read at, so an older report cannot replace it. */
|
|
41
|
+
activitySeq: z.number().optional(),
|
|
42
|
+
activityAt: z.number().optional(),
|
|
43
|
+
lastCompletedAt: z.number().optional(),
|
|
44
|
+
createdAt: z.number(),
|
|
45
|
+
updatedAt: z.number(),
|
|
46
|
+
archived: z.boolean(),
|
|
47
|
+
/** The person who started the session. Null or absent when Shuttle started it. */
|
|
48
|
+
ownerId: z.string().nullish(),
|
|
49
|
+
/** People the owner shared the session with. */
|
|
50
|
+
memberIds: z.array(z.string()).readonly().optional(),
|
|
51
|
+
});
|
|
52
|
+
export const GithubInstallation = z.object({
|
|
53
|
+
installationId: z.number(),
|
|
54
|
+
account: z.object({
|
|
55
|
+
login: z.string(),
|
|
56
|
+
type: z.string(),
|
|
57
|
+
avatarUrl: z.string(),
|
|
58
|
+
}),
|
|
59
|
+
});
|
|
60
|
+
/** A workspace's folders, the sessions listed in it, and the GitHub installations it can use. */
|
|
61
|
+
export const WorkspaceTree = z.object({
|
|
62
|
+
folderOrder: z.array(z.string()).readonly(),
|
|
63
|
+
folders: z.record(z.string(), WorkspaceFolder).readonly(),
|
|
64
|
+
sessions: z.record(z.string(), WorkspaceSession).readonly(),
|
|
65
|
+
installations: z.record(z.string(), GithubInstallation).readonly(),
|
|
66
|
+
});
|
|
67
|
+
/** The kinds of tab Shuttle itself draws. */
|
|
68
|
+
export const ARTIFACT_TAB_KINDS = [
|
|
69
|
+
'events',
|
|
70
|
+
'files',
|
|
71
|
+
'file',
|
|
72
|
+
'changes',
|
|
73
|
+
'terminal',
|
|
74
|
+
'browser',
|
|
75
|
+
'review',
|
|
76
|
+
'media',
|
|
77
|
+
];
|
|
78
|
+
export const BuiltinArtifactTabKind = z.enum(ARTIFACT_TAB_KINDS);
|
|
79
|
+
/**
|
|
80
|
+
* A kind of tab that whoever put Shuttle's components together draws themself, named
|
|
81
|
+
* `<namespace>:<name>` in lower case, as in `acme:designs`. The namespace keeps it apart from
|
|
82
|
+
* Shuttle's own kinds, present and future. The backend keeps such a tab without knowing what
|
|
83
|
+
* it shows; its `target` is the type's to give meaning to.
|
|
84
|
+
*/
|
|
85
|
+
export const CustomArtifactTabKind = z
|
|
86
|
+
.templateLiteral([
|
|
87
|
+
z.string().regex(/^[a-z][a-z0-9-]*$/),
|
|
88
|
+
':',
|
|
89
|
+
z.string().regex(/^[a-z0-9][a-z0-9-]*$/),
|
|
90
|
+
])
|
|
91
|
+
.refine((kind) => kind.length <= 64, 'A tab kind is at most 64 characters.');
|
|
92
|
+
export const ArtifactTabKind = z.union([BuiltinArtifactTabKind, CustomArtifactTabKind]);
|
|
93
|
+
export function isCustomArtifactTabKind(kind) {
|
|
94
|
+
return CustomArtifactTabKind.safeParse(kind).success;
|
|
95
|
+
}
|
|
96
|
+
/** One tab open beside a session. */
|
|
97
|
+
export const ArtifactTab = z.object({
|
|
98
|
+
tabId: z.string(),
|
|
99
|
+
kind: ArtifactTabKind,
|
|
100
|
+
title: z.string(),
|
|
101
|
+
target: z.string(),
|
|
102
|
+
openedAt: z.number(),
|
|
103
|
+
});
|
|
104
|
+
export const SessionTabSet = z.object({
|
|
105
|
+
order: z.array(z.string()).readonly(),
|
|
106
|
+
tabs: z.record(z.string(), ArtifactTab).readonly(),
|
|
107
|
+
});
|
|
108
|
+
/** The tabs open beside each session, by the session's run id. */
|
|
109
|
+
export const SessionTabsState = z.record(z.string(), SessionTabSet).readonly();
|
|
110
|
+
/**
|
|
111
|
+
* One workspace as it stands: its tree and tabs, and the log position (`tail`) they were read at,
|
|
112
|
+
* so a client can follow the workspace's events from there. `tree` and `tabs` are null when the
|
|
113
|
+
* workspace could not be read.
|
|
114
|
+
*/
|
|
115
|
+
export const WorkspaceSnapshot = z.object({
|
|
116
|
+
runId: z.string(),
|
|
117
|
+
tail: z.number(),
|
|
118
|
+
tree: WorkspaceTree.nullable(),
|
|
119
|
+
tabs: SessionTabsState.nullable(),
|
|
120
|
+
});
|
|
121
|
+
/** The organization's workspace, and inside it the caller's own. */
|
|
122
|
+
export const WorkspaceSnapshotResponse = WorkspaceSnapshot.extend({ personal: WorkspaceSnapshot });
|
|
123
|
+
export const RepoSyncStatus = z.enum(['ok', 'forbidden', 'failed']);
|
|
124
|
+
export const RepoSyncReport = z.object({
|
|
125
|
+
fullName: z.string(),
|
|
126
|
+
status: RepoSyncStatus,
|
|
127
|
+
/** Open PRs GitHub reports for the repo. */
|
|
128
|
+
open: z.number(),
|
|
129
|
+
/** Open PRs Shuttle ingested (capped per repo). */
|
|
130
|
+
synced: z.number(),
|
|
131
|
+
checksHidden: z.boolean(),
|
|
132
|
+
message: z.string().nullable(),
|
|
133
|
+
});
|
|
134
|
+
export const InstallationAccessReport = z.object({
|
|
135
|
+
installationId: z.number(),
|
|
136
|
+
account: z.string(),
|
|
137
|
+
missingPermissions: z.array(z.string()).readonly(),
|
|
138
|
+
settingsUrl: z.string(),
|
|
139
|
+
});
|
|
140
|
+
export const FolderSyncReport = z.object({
|
|
141
|
+
folderId: z.string(),
|
|
142
|
+
upserted: z.number(),
|
|
143
|
+
repos: z.array(RepoSyncReport).readonly(),
|
|
144
|
+
installations: z.array(InstallationAccessReport).readonly(),
|
|
145
|
+
});
|
|
146
|
+
/** The folder a `/workspace/folders/{folderId}/…` path names. */
|
|
147
|
+
const FolderParams = z.object({ folderId: z.string().min(1) });
|
|
148
|
+
/** The pull request a `/workspace/folders/{folderId}/pulls/{fullName}/{number}/…` path names. */
|
|
149
|
+
const PullParams = FolderParams.extend({
|
|
150
|
+
/** `owner/name`, sent as one path segment with its slash encoded. */
|
|
151
|
+
fullName: z.string().min(1),
|
|
152
|
+
number: z.coerce.number().int().nonnegative(),
|
|
153
|
+
});
|
|
154
|
+
const DiffSide = z.enum(['LEFT', 'RIGHT']);
|
|
155
|
+
export const workspaceContract = {
|
|
156
|
+
/**
|
|
157
|
+
* The two workspaces a person sees: the organization's, with its folders and public sessions,
|
|
158
|
+
* and their own, with the sessions that are private to them or shared with them.
|
|
159
|
+
*/
|
|
160
|
+
get: oc.route({ method: 'GET', path: '/workspace' }).output(WorkspaceSnapshotResponse),
|
|
161
|
+
/** Starts a session in a folder. It is private to the caller until they share it. */
|
|
162
|
+
createSession: oc
|
|
163
|
+
.route({ method: 'POST', path: '/workspace/sessions' })
|
|
164
|
+
.input(z.object({
|
|
165
|
+
folderId: z.string().min(1),
|
|
166
|
+
goal: z.string().trim().min(1),
|
|
167
|
+
/** One of the caller's own machines to start on, as the desktop app asks for. */
|
|
168
|
+
deviceId: z.string().nullish(),
|
|
169
|
+
}))
|
|
170
|
+
.output(z.object({ runId: z.string() })),
|
|
171
|
+
repos: {
|
|
172
|
+
/** Links a repository to a folder. Only an installation the organization connected may be used. */
|
|
173
|
+
link: oc
|
|
174
|
+
.route({ method: 'POST', path: '/workspace/folders/{folderId}/repos' })
|
|
175
|
+
.input(FolderParams.extend({
|
|
176
|
+
installationId: z.coerce.number(),
|
|
177
|
+
owner: z.string().min(1),
|
|
178
|
+
name: z.string().min(1),
|
|
179
|
+
}))
|
|
180
|
+
.output(z.object({ folderId: z.string(), repo: LinkedRepo })),
|
|
181
|
+
unlink: oc
|
|
182
|
+
.route({ method: 'DELETE', path: '/workspace/folders/{folderId}/repos' })
|
|
183
|
+
.input(FolderParams.extend({ fullName: z.string().min(1) }))
|
|
184
|
+
.output(z.object({ folderId: z.string(), fullName: z.string(), unlinked: z.literal(true) })),
|
|
185
|
+
},
|
|
186
|
+
pulls: {
|
|
187
|
+
/** Fetches every open pull request on the folder's repositories into the inbox. */
|
|
188
|
+
sync: oc
|
|
189
|
+
.route({ method: 'POST', path: '/workspace/folders/{folderId}/pulls/sync' })
|
|
190
|
+
.input(FolderParams)
|
|
191
|
+
.output(FolderSyncReport),
|
|
192
|
+
/** Fetches a pull request's review threads from GitHub into the mirror people read. */
|
|
193
|
+
syncThreads: oc
|
|
194
|
+
.route({
|
|
195
|
+
method: 'POST',
|
|
196
|
+
path: '/workspace/folders/{folderId}/pulls/{fullName}/{number}/threads/sync',
|
|
197
|
+
})
|
|
198
|
+
.input(PullParams)
|
|
199
|
+
.output(z.object({ threads: z.number(), changed: z.boolean() })),
|
|
200
|
+
/**
|
|
201
|
+
* Posts a comment on a pull request as the signed-in person: a reply when `rootId` names a
|
|
202
|
+
* thread, otherwise a new thread on `path` and `line`.
|
|
203
|
+
*/
|
|
204
|
+
comment: oc
|
|
205
|
+
.route({
|
|
206
|
+
method: 'POST',
|
|
207
|
+
path: '/workspace/folders/{folderId}/pulls/{fullName}/{number}/comments',
|
|
208
|
+
})
|
|
209
|
+
.input(PullParams.extend({
|
|
210
|
+
body: z.string().default(''),
|
|
211
|
+
/** The first comment of the thread being replied to. */
|
|
212
|
+
rootId: z.number().optional(),
|
|
213
|
+
path: z.string().optional(),
|
|
214
|
+
line: z.number().optional(),
|
|
215
|
+
side: DiffSide.optional(),
|
|
216
|
+
/** For a comment about several lines: where they start. `line` is where they end. */
|
|
217
|
+
startLine: z.number().optional(),
|
|
218
|
+
startSide: DiffSide.optional(),
|
|
219
|
+
}))
|
|
220
|
+
.output(Ok.extend({ commentId: z.number() })),
|
|
221
|
+
/** Resolves or reopens a thread on a pull request as the signed-in person. */
|
|
222
|
+
resolveThread: oc
|
|
223
|
+
.route({
|
|
224
|
+
method: 'POST',
|
|
225
|
+
path: '/workspace/folders/{folderId}/pulls/{fullName}/{number}/threads/{rootId}/resolution',
|
|
226
|
+
})
|
|
227
|
+
.input(PullParams.extend({
|
|
228
|
+
rootId: z.coerce.number().int().nonnegative(),
|
|
229
|
+
resolved: z.boolean().default(false),
|
|
230
|
+
}))
|
|
231
|
+
.output(Ok),
|
|
232
|
+
/** Starts a private session that reviews a pull request at the commit given. */
|
|
233
|
+
review: oc
|
|
234
|
+
.route({
|
|
235
|
+
method: 'POST',
|
|
236
|
+
path: '/workspace/folders/{folderId}/pulls/{fullName}/{number}/review',
|
|
237
|
+
})
|
|
238
|
+
.input(PullParams.extend({
|
|
239
|
+
/** The session checks this commit out to read; without it there is nothing to review. */
|
|
240
|
+
headSha: z.string().min(1),
|
|
241
|
+
baseSha: z.string().optional(),
|
|
242
|
+
title: z.string().optional(),
|
|
243
|
+
}))
|
|
244
|
+
.output(z.object({ runId: z.string() })),
|
|
245
|
+
},
|
|
246
|
+
};
|