@flowdular/sandbox 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +696 -0
  3. package/bin/flowdular-sandbox.mjs +394 -0
  4. package/bin/register-types.mjs +53 -0
  5. package/dist/client/assets/App-ClMOrpyg.js +11 -0
  6. package/dist/client/assets/PreviewHost-BHiHrfbQ.js +1 -0
  7. package/dist/client/assets/auto-buGEq6de.js +3 -0
  8. package/dist/client/assets/ibm-plex-mono-cyrillic-400-normal-BSMlKf0J.woff2 +0 -0
  9. package/dist/client/assets/ibm-plex-mono-cyrillic-400-normal-CEL4l2ZJ.woff +0 -0
  10. package/dist/client/assets/ibm-plex-mono-cyrillic-500-normal-Ael50iVv.woff +0 -0
  11. package/dist/client/assets/ibm-plex-mono-cyrillic-500-normal-Bq9vWWag.woff2 +0 -0
  12. package/dist/client/assets/ibm-plex-mono-cyrillic-ext-400-normal-DMdlQ8Kv.woff +0 -0
  13. package/dist/client/assets/ibm-plex-mono-cyrillic-ext-400-normal-xuaO2J-f.woff2 +0 -0
  14. package/dist/client/assets/ibm-plex-mono-cyrillic-ext-500-normal-BIfNGwUT.woff +0 -0
  15. package/dist/client/assets/ibm-plex-mono-cyrillic-ext-500-normal-BqneJy0T.woff2 +0 -0
  16. package/dist/client/assets/ibm-plex-mono-latin-400-normal-CvHOgSBP.woff +0 -0
  17. package/dist/client/assets/ibm-plex-mono-latin-400-normal-DMJ8VG8y.woff2 +0 -0
  18. package/dist/client/assets/ibm-plex-mono-latin-500-normal-CB9ihrfo.woff +0 -0
  19. package/dist/client/assets/ibm-plex-mono-latin-500-normal-DSY6xOcd.woff2 +0 -0
  20. package/dist/client/assets/ibm-plex-mono-latin-ext-400-normal-BmRBH3aV.woff2 +0 -0
  21. package/dist/client/assets/ibm-plex-mono-latin-ext-400-normal-D3D2R8hC.woff +0 -0
  22. package/dist/client/assets/ibm-plex-mono-latin-ext-500-normal-CAhNIIs5.woff2 +0 -0
  23. package/dist/client/assets/ibm-plex-mono-latin-ext-500-normal-CZ70TYgx.woff +0 -0
  24. package/dist/client/assets/ibm-plex-mono-vietnamese-400-normal-BulugwFq.woff2 +0 -0
  25. package/dist/client/assets/ibm-plex-mono-vietnamese-400-normal-DDuiU_S-.woff +0 -0
  26. package/dist/client/assets/ibm-plex-mono-vietnamese-500-normal-C8zxqsMH.woff +0 -0
  27. package/dist/client/assets/ibm-plex-mono-vietnamese-500-normal-DZ4AoWbu.woff2 +0 -0
  28. package/dist/client/assets/ibm-plex-sans-cyrillic-ext-wght-normal-d45eAU9y.woff2 +0 -0
  29. package/dist/client/assets/ibm-plex-sans-cyrillic-wght-normal-BAAhND-U.woff2 +0 -0
  30. package/dist/client/assets/ibm-plex-sans-greek-wght-normal-CmyJS8uq.woff2 +0 -0
  31. package/dist/client/assets/ibm-plex-sans-latin-ext-wght-normal-CIII54If.woff2 +0 -0
  32. package/dist/client/assets/ibm-plex-sans-latin-wght-normal-IvpUvPa2.woff2 +0 -0
  33. package/dist/client/assets/ibm-plex-sans-vietnamese-wght-normal-Dg1JeJN0.woff2 +0 -0
  34. package/dist/client/assets/index-CvwhlQ87.js +4 -0
  35. package/dist/client/assets/styles-BPWaGf55.js +3 -0
  36. package/dist/client/assets/styles-Dx1_KOag.css +1 -0
  37. package/dist/client/favicon.svg +1 -0
  38. package/dist/server/assets/auto-CVGNYyb3.js +12785 -0
  39. package/dist/server/assets/chunk-DDJLRBDX-3OUNo51g.js +4125 -0
  40. package/dist/server/assets/nodefs-DVSI7kG0.js +24 -0
  41. package/dist/server/assets/opfs-ahp-D56iokt1.js +388 -0
  42. package/dist/server/assets/token-Bvaq7Anz.js +55 -0
  43. package/dist/server/assets/token-util-BqSvdIPQ.js +3 -0
  44. package/dist/server/assets/token-util-CktFFT4z.js +494 -0
  45. package/dist/server/entry.js +91671 -0
  46. package/dist/server/favicon.svg +1 -0
  47. package/dist/server/index.html +161 -0
  48. package/index.html +159 -0
  49. package/internal/coding-agent/package.json +44 -0
  50. package/internal/coding-agent/src/drivers/byok.ts +322 -0
  51. package/internal/coding-agent/src/drivers/claude-code.ts +290 -0
  52. package/internal/coding-agent/src/drivers/codex.ts +281 -0
  53. package/internal/coding-agent/src/index.ts +56 -0
  54. package/internal/coding-agent/src/registry.ts +119 -0
  55. package/internal/coding-agent/src/roles/contract.ts +60 -0
  56. package/internal/coding-agent/src/roles/defaults.ts +134 -0
  57. package/internal/coding-agent/src/roles/handoff.ts +41 -0
  58. package/internal/coding-agent/src/roles/registry.ts +156 -0
  59. package/internal/coding-agent/src/roles/skills.ts +72 -0
  60. package/internal/coding-agent/src/roles/sync.ts +88 -0
  61. package/internal/coding-agent/src/types.ts +102 -0
  62. package/internal/coding-agent/src/workspace.ts +275 -0
  63. package/octane.config.ts +36 -0
  64. package/package.json +68 -0
  65. package/public/favicon.svg +1 -0
  66. package/public/og.png +0 -0
  67. package/src/App.tsrx +924 -0
  68. package/src/client/ApprovalHandoff.tsrx +39 -0
  69. package/src/client/ChatPane.tsrx +694 -0
  70. package/src/client/ConnectView.tsrx +86 -0
  71. package/src/client/DiffPane.tsrx +150 -0
  72. package/src/client/EjectModal.tsrx +571 -0
  73. package/src/client/GateResults.tsrx +60 -0
  74. package/src/client/GitHubSettingsModal.tsrx +219 -0
  75. package/src/client/NewSessionForm.tsrx +214 -0
  76. package/src/client/SessionBar.tsrx +151 -0
  77. package/src/client/SessionPicker.tsrx +472 -0
  78. package/src/client/SpecEditor.tsrx +109 -0
  79. package/src/client/SpecReviewCard.tsrx +321 -0
  80. package/src/client/WorkCard.tsrx +128 -0
  81. package/src/client/WorkbenchModal.tsrx +161 -0
  82. package/src/client/WorkspaceMenu.tsrx +100 -0
  83. package/src/client/api.ts +797 -0
  84. package/src/client/attachments.ts +73 -0
  85. package/src/client/dashboard.ts +46 -0
  86. package/src/client/github-settings.ts +48 -0
  87. package/src/client/highlight.ts +105 -0
  88. package/src/client/i18n.ts +32 -0
  89. package/src/client/locales/en.json +466 -0
  90. package/src/client/locales/pl.json +466 -0
  91. package/src/client/session-labels.ts +77 -0
  92. package/src/client/state.ts +108 -0
  93. package/src/index.ts +10 -0
  94. package/src/preview/PreviewHost.tsrx +373 -0
  95. package/src/preview/load-module.ts +16 -0
  96. package/src/server/attachments.ts +308 -0
  97. package/src/server/auto-review.ts +181 -0
  98. package/src/server/checkpoints.ts +90 -0
  99. package/src/server/config.ts +460 -0
  100. package/src/server/dashboard.ts +245 -0
  101. package/src/server/delivery/configuration.ts +193 -0
  102. package/src/server/delivery/git-pr.ts +1473 -0
  103. package/src/server/delivery/index.ts +83 -0
  104. package/src/server/delivery/local.ts +151 -0
  105. package/src/server/delivery/official-modules.ts +516 -0
  106. package/src/server/delivery/plan.ts +218 -0
  107. package/src/server/delivery/policies.ts +239 -0
  108. package/src/server/delivery/record.ts +41 -0
  109. package/src/server/delivery/steps.ts +464 -0
  110. package/src/server/delivery/types.ts +158 -0
  111. package/src/server/dependencies.ts +88 -0
  112. package/src/server/diff.ts +230 -0
  113. package/src/server/gates.ts +388 -0
  114. package/src/server/index.ts +139 -0
  115. package/src/server/path-guard.ts +282 -0
  116. package/src/server/planning.ts +749 -0
  117. package/src/server/platform-client.ts +189 -0
  118. package/src/server/preview-database-host.ts +340 -0
  119. package/src/server/preview-database-protocol.ts +163 -0
  120. package/src/server/preview-database-proxy.ts +356 -0
  121. package/src/server/preview-database.ts +109 -0
  122. package/src/server/preview-ipc.ts +15 -0
  123. package/src/server/preview-modules.ts +83 -0
  124. package/src/server/preview-revision.ts +44 -0
  125. package/src/server/preview-runtime.ts +467 -0
  126. package/src/server/preview-worker-manager.ts +477 -0
  127. package/src/server/preview-worker.ts +168 -0
  128. package/src/server/reference.ts +251 -0
  129. package/src/server/routes.ts +2258 -0
  130. package/src/server/runtime.ts +188 -0
  131. package/src/server/session-owner.ts +23 -0
  132. package/src/server/sessions.ts +849 -0
  133. package/src/server/spec.ts +471 -0
  134. package/src/server/turn-lifecycle.ts +56 -0
  135. package/src/server/turns.ts +993 -0
  136. package/src/server/workspace-install.ts +266 -0
  137. package/src/server/workspace-root.ts +73 -0
  138. package/src/styles.css +1573 -0
  139. package/vite.config.ts +134 -0
@@ -0,0 +1,73 @@
1
+ import { activeLocale, t } from './i18n.ts';
2
+
3
+ /* The composer's mirror of the limits server/attachments.ts enforces. The
4
+ server stays the authority; refusing here only saves an upload that would be
5
+ rejected, and the two lists must move together. */
6
+ export const ATTACHMENT_EXTENSIONS = [
7
+ 'png',
8
+ 'jpg',
9
+ 'jpeg',
10
+ 'gif',
11
+ 'webp',
12
+ 'md',
13
+ 'txt',
14
+ 'json',
15
+ 'csv',
16
+ 'pdf',
17
+ 'svg',
18
+ ];
19
+
20
+ export const MAX_ATTACHMENTS = 10;
21
+ export const MAX_ATTACHMENT_BYTES = 5 * 1024 * 1024;
22
+
23
+ export const ATTACH_ACCEPT =
24
+ 'image/png,image/jpeg,image/gif,image/webp,image/svg+xml,.png,.jpg,.jpeg,.gif,.webp,.svg,.md,.txt,.json,.csv,.pdf';
25
+
26
+ export function formatBytes(size: number): string {
27
+ const value =
28
+ size < 1024
29
+ ? size
30
+ : size < 1024 * 1024
31
+ ? size / 1024
32
+ : size / (1024 * 1024);
33
+ const count = new Intl.NumberFormat(activeLocale(), {
34
+ maximumFractionDigits: size < 1024 * 1024 ? 0 : 1,
35
+ }).format(value);
36
+ return size < 1024
37
+ ? t('sandbox.attachments.bytes', { count })
38
+ : size < 1024 * 1024
39
+ ? t('sandbox.attachments.kilobytes', { count })
40
+ : t('sandbox.attachments.megabytes', { count });
41
+ }
42
+
43
+ export function attachmentKind(file: File): 'image' | 'file' {
44
+ return file.type.startsWith('image/') && file.type !== 'image/svg+xml'
45
+ ? 'image'
46
+ : 'file';
47
+ }
48
+
49
+ /* Why this file cannot be attached, or null when it can. `held` is how many the
50
+ composer already holds. */
51
+ export function attachmentRefusal(file: File, held: number): string | null {
52
+ if (held >= MAX_ATTACHMENTS) {
53
+ return t('sandbox.attachments.limit', { count: MAX_ATTACHMENTS });
54
+ }
55
+ const dot = file.name.lastIndexOf('.');
56
+ const extension = dot > 0 ? file.name.slice(dot + 1).toLowerCase() : '';
57
+ if (!ATTACHMENT_EXTENSIONS.includes(extension)) {
58
+ return t('sandbox.attachments.type', {
59
+ name: file.name,
60
+ types: ATTACHMENT_EXTENSIONS.join(', '),
61
+ });
62
+ }
63
+ if (file.size === 0) {
64
+ return t('sandbox.attachments.empty', { name: file.name });
65
+ }
66
+ if (file.size > MAX_ATTACHMENT_BYTES) {
67
+ return t('sandbox.attachments.tooLarge', {
68
+ name: file.name,
69
+ size: MAX_ATTACHMENT_BYTES / (1024 * 1024),
70
+ });
71
+ }
72
+ return null;
73
+ }
@@ -0,0 +1,46 @@
1
+ import type { DashboardRow, WorkUsage } from '../server/dashboard.ts';
2
+
3
+ export function filterWork(
4
+ rows: readonly DashboardRow[],
5
+ query: string,
6
+ status: string,
7
+ archived: boolean,
8
+ locale: string,
9
+ ): readonly DashboardRow[] {
10
+ const term = query.trim().toLocaleLowerCase(locale);
11
+ return rows.filter(
12
+ (row) =>
13
+ (!status || row.status === status) &&
14
+ (archived || status === 'archived' || row.status !== 'archived') &&
15
+ (!term ||
16
+ [
17
+ row.session.title,
18
+ row.session.brief,
19
+ ...row.session.modules.map((module) => module.id),
20
+ ].some((value) => value.toLocaleLowerCase(locale).includes(term))),
21
+ );
22
+ }
23
+
24
+ export function formatTokens(usage: WorkUsage, locale: string): string {
25
+ if (!usage.reportedTurns && usage.missingUsage) return '?';
26
+ return (
27
+ new Intl.NumberFormat(locale).format(usage.totalTokens) +
28
+ (usage.missingUsage ? ' +' : '')
29
+ );
30
+ }
31
+
32
+ export function formatCost(usage: WorkUsage, locale: string): string {
33
+ if (
34
+ !usage.pricedTurns &&
35
+ (usage.unpricedTurns || usage.reportedTurns || usage.missingUsage)
36
+ )
37
+ return '?';
38
+ return (
39
+ new Intl.NumberFormat(locale, {
40
+ style: 'currency',
41
+ currency: 'USD',
42
+ minimumFractionDigits: 2,
43
+ maximumFractionDigits: 4,
44
+ }).format(usage.knownCostUsd) + (usage.unpricedTurns ? ' +' : '')
45
+ );
46
+ }
@@ -0,0 +1,48 @@
1
+ import type { SafeSandboxConfiguration } from '../server/config.ts';
2
+ import type { GitHubSettingsInput } from './GitHubSettingsModal.tsrx';
3
+
4
+ /* Hidden custom fields must not erase the saved local settings when switching
5
+ back to repository defaults. A blank credential preserves the sealed token. */
6
+ export function githubSettingsInput(
7
+ form: FormData,
8
+ current: SafeSandboxConfiguration['github'],
9
+ ): GitHubSettingsInput {
10
+ const value = (name: string, fallback = '') => {
11
+ const entry = form.get(name);
12
+ return typeof entry === 'string' ? entry.trim() : fallback;
13
+ };
14
+ const custom = form.get('githubOverridesProject') === 'on';
15
+ const token = value('githubToken');
16
+ return {
17
+ githubEnabled: form.get('githubEnabled') === 'on',
18
+ githubOverridesProject: custom,
19
+ githubRemote: custom
20
+ ? value('githubRemote', current.remote)
21
+ : current.remote,
22
+ githubRepository: custom
23
+ ? value('githubRepository', current.repository ?? '')
24
+ : (current.repository ?? ''),
25
+ githubBaseBranch: custom
26
+ ? value('githubBaseBranch', current.baseBranch)
27
+ : current.baseBranch,
28
+ githubBranchPrefix: custom
29
+ ? value('githubBranchPrefix', current.branchPrefix)
30
+ : current.branchPrefix,
31
+ githubMode: custom
32
+ ? (value('githubMode', current.mode) as GitHubSettingsInput['githubMode'])
33
+ : current.mode,
34
+ githubForkOwner: custom
35
+ ? value('githubForkOwner', current.forkOwner ?? '')
36
+ : (current.forkOwner ?? ''),
37
+ githubReviewers: custom
38
+ ? value('githubReviewers', current.reviewers.join(','))
39
+ .split(',')
40
+ .map((entry) => entry.trim())
41
+ .filter(Boolean)
42
+ : current.reviewers,
43
+ ...(token ? { githubToken: token } : {}),
44
+ ...(form.get('githubClearToken') === 'on'
45
+ ? { githubClearToken: true }
46
+ : {}),
47
+ };
48
+ }
@@ -0,0 +1,105 @@
1
+ export interface Token {
2
+ /* Position in the line, so a rendered token has a stable key. */
3
+ readonly id: number;
4
+ readonly text: string;
5
+ readonly kind: 'plain' | 'keyword' | 'string' | 'comment' | 'number' | 'type';
6
+ }
7
+
8
+ const KEYWORDS = new Set([
9
+ 'import',
10
+ 'export',
11
+ 'from',
12
+ 'const',
13
+ 'let',
14
+ 'var',
15
+ 'function',
16
+ 'return',
17
+ 'if',
18
+ 'else',
19
+ 'for',
20
+ 'of',
21
+ 'in',
22
+ 'while',
23
+ 'class',
24
+ 'extends',
25
+ 'implements',
26
+ 'interface',
27
+ 'type',
28
+ 'enum',
29
+ 'new',
30
+ 'await',
31
+ 'async',
32
+ 'try',
33
+ 'catch',
34
+ 'finally',
35
+ 'throw',
36
+ 'typeof',
37
+ 'instanceof',
38
+ 'readonly',
39
+ 'public',
40
+ 'private',
41
+ 'protected',
42
+ 'static',
43
+ 'true',
44
+ 'false',
45
+ 'null',
46
+ 'undefined',
47
+ 'this',
48
+ 'super',
49
+ 'as',
50
+ 'satisfies',
51
+ 'default',
52
+ 'CREATE',
53
+ 'TABLE',
54
+ 'SELECT',
55
+ 'INSERT',
56
+ 'UPDATE',
57
+ 'DELETE',
58
+ 'FROM',
59
+ 'WHERE',
60
+ 'INDEX',
61
+ 'NOT',
62
+ 'NULL',
63
+ 'PRIMARY',
64
+ 'KEY',
65
+ 'REFERENCES',
66
+ ]);
67
+
68
+ const PATTERN =
69
+ /(\/\/[^\n]*|\/\*[\s\S]*?\*\/|--[^\n]*)|('(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*`)|(\b\d[\d_.]*\b)|([A-Za-z_$][\w$]*)/g;
70
+
71
+ /* A deliberately small highlighter: the sandbox diff shows TypeScript, TSRX,
72
+ JSON, YAML, CSS, and SQL, and a dependency-free tokenizer keeps the preview
73
+ free of third-party runtime code. */
74
+ export function tokenize(line: string): readonly Token[] {
75
+ const tokens: Token[] = [];
76
+ const push = (value: string, kind: Token['kind']) => {
77
+ tokens.push({ id: tokens.length, text: value, kind });
78
+ };
79
+ let lastIndex = 0;
80
+ PATTERN.lastIndex = 0;
81
+ for (;;) {
82
+ const match = PATTERN.exec(line);
83
+ if (!match) break;
84
+ if (match.index > lastIndex) {
85
+ push(line.slice(lastIndex, match.index), 'plain');
86
+ }
87
+ const [value, comment, string, number, word] = match;
88
+ if (comment) push(value, 'comment');
89
+ else if (string) push(value, 'string');
90
+ else if (number) push(value, 'number');
91
+ else if (word) {
92
+ push(
93
+ value,
94
+ KEYWORDS.has(word) ? 'keyword' : /^[A-Z]/.test(word) ? 'type' : 'plain',
95
+ );
96
+ }
97
+ lastIndex = match.index + value.length;
98
+ }
99
+ if (lastIndex < line.length) push(line.slice(lastIndex), 'plain');
100
+ return tokens;
101
+ }
102
+
103
+ export function tokenClass(kind: Token['kind']): string {
104
+ return kind === 'plain' ? '' : `tok-${kind}`;
105
+ }
@@ -0,0 +1,32 @@
1
+ import {
2
+ activeLocale,
3
+ registerModuleTranslations,
4
+ restorePersistedLocale,
5
+ setActiveLocale,
6
+ SUPPORTED_LOCALES,
7
+ t,
8
+ useTranslation,
9
+ } from '@flowdular/sdk/client';
10
+ import en from './locales/en.json';
11
+ import pl from './locales/pl.json';
12
+
13
+ /** The standalone sandbox shares the platform translation runtime and keys. */
14
+ export function registerSandboxTranslations(): void {
15
+ /* The translation runtime may be replaced independently by Vite HMR. The
16
+ catalog is the source of truth, so a stale local boolean must not suppress
17
+ recovery and expose raw keys in the workspace menu. */
18
+ if (t('sandbox.workspace.language.en') !== 'sandbox.workspace.language.en')
19
+ return;
20
+ registerModuleTranslations([
21
+ {
22
+ moduleId: 'sandbox.app',
23
+ translations: { en, pl },
24
+ },
25
+ ]);
26
+ }
27
+
28
+ export function restoreSandboxLocale(): void {
29
+ restorePersistedLocale();
30
+ }
31
+
32
+ export { activeLocale, setActiveLocale, SUPPORTED_LOCALES, t, useTranslation };