@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.
- package/LICENSE +21 -0
- package/README.md +696 -0
- package/bin/flowdular-sandbox.mjs +394 -0
- package/bin/register-types.mjs +53 -0
- package/dist/client/assets/App-ClMOrpyg.js +11 -0
- package/dist/client/assets/PreviewHost-BHiHrfbQ.js +1 -0
- package/dist/client/assets/auto-buGEq6de.js +3 -0
- package/dist/client/assets/ibm-plex-mono-cyrillic-400-normal-BSMlKf0J.woff2 +0 -0
- package/dist/client/assets/ibm-plex-mono-cyrillic-400-normal-CEL4l2ZJ.woff +0 -0
- package/dist/client/assets/ibm-plex-mono-cyrillic-500-normal-Ael50iVv.woff +0 -0
- package/dist/client/assets/ibm-plex-mono-cyrillic-500-normal-Bq9vWWag.woff2 +0 -0
- package/dist/client/assets/ibm-plex-mono-cyrillic-ext-400-normal-DMdlQ8Kv.woff +0 -0
- package/dist/client/assets/ibm-plex-mono-cyrillic-ext-400-normal-xuaO2J-f.woff2 +0 -0
- package/dist/client/assets/ibm-plex-mono-cyrillic-ext-500-normal-BIfNGwUT.woff +0 -0
- package/dist/client/assets/ibm-plex-mono-cyrillic-ext-500-normal-BqneJy0T.woff2 +0 -0
- package/dist/client/assets/ibm-plex-mono-latin-400-normal-CvHOgSBP.woff +0 -0
- package/dist/client/assets/ibm-plex-mono-latin-400-normal-DMJ8VG8y.woff2 +0 -0
- package/dist/client/assets/ibm-plex-mono-latin-500-normal-CB9ihrfo.woff +0 -0
- package/dist/client/assets/ibm-plex-mono-latin-500-normal-DSY6xOcd.woff2 +0 -0
- package/dist/client/assets/ibm-plex-mono-latin-ext-400-normal-BmRBH3aV.woff2 +0 -0
- package/dist/client/assets/ibm-plex-mono-latin-ext-400-normal-D3D2R8hC.woff +0 -0
- package/dist/client/assets/ibm-plex-mono-latin-ext-500-normal-CAhNIIs5.woff2 +0 -0
- package/dist/client/assets/ibm-plex-mono-latin-ext-500-normal-CZ70TYgx.woff +0 -0
- package/dist/client/assets/ibm-plex-mono-vietnamese-400-normal-BulugwFq.woff2 +0 -0
- package/dist/client/assets/ibm-plex-mono-vietnamese-400-normal-DDuiU_S-.woff +0 -0
- package/dist/client/assets/ibm-plex-mono-vietnamese-500-normal-C8zxqsMH.woff +0 -0
- package/dist/client/assets/ibm-plex-mono-vietnamese-500-normal-DZ4AoWbu.woff2 +0 -0
- package/dist/client/assets/ibm-plex-sans-cyrillic-ext-wght-normal-d45eAU9y.woff2 +0 -0
- package/dist/client/assets/ibm-plex-sans-cyrillic-wght-normal-BAAhND-U.woff2 +0 -0
- package/dist/client/assets/ibm-plex-sans-greek-wght-normal-CmyJS8uq.woff2 +0 -0
- package/dist/client/assets/ibm-plex-sans-latin-ext-wght-normal-CIII54If.woff2 +0 -0
- package/dist/client/assets/ibm-plex-sans-latin-wght-normal-IvpUvPa2.woff2 +0 -0
- package/dist/client/assets/ibm-plex-sans-vietnamese-wght-normal-Dg1JeJN0.woff2 +0 -0
- package/dist/client/assets/index-CvwhlQ87.js +4 -0
- package/dist/client/assets/styles-BPWaGf55.js +3 -0
- package/dist/client/assets/styles-Dx1_KOag.css +1 -0
- package/dist/client/favicon.svg +1 -0
- package/dist/server/assets/auto-CVGNYyb3.js +12785 -0
- package/dist/server/assets/chunk-DDJLRBDX-3OUNo51g.js +4125 -0
- package/dist/server/assets/nodefs-DVSI7kG0.js +24 -0
- package/dist/server/assets/opfs-ahp-D56iokt1.js +388 -0
- package/dist/server/assets/token-Bvaq7Anz.js +55 -0
- package/dist/server/assets/token-util-BqSvdIPQ.js +3 -0
- package/dist/server/assets/token-util-CktFFT4z.js +494 -0
- package/dist/server/entry.js +91671 -0
- package/dist/server/favicon.svg +1 -0
- package/dist/server/index.html +161 -0
- package/index.html +159 -0
- package/internal/coding-agent/package.json +44 -0
- package/internal/coding-agent/src/drivers/byok.ts +322 -0
- package/internal/coding-agent/src/drivers/claude-code.ts +290 -0
- package/internal/coding-agent/src/drivers/codex.ts +281 -0
- package/internal/coding-agent/src/index.ts +56 -0
- package/internal/coding-agent/src/registry.ts +119 -0
- package/internal/coding-agent/src/roles/contract.ts +60 -0
- package/internal/coding-agent/src/roles/defaults.ts +134 -0
- package/internal/coding-agent/src/roles/handoff.ts +41 -0
- package/internal/coding-agent/src/roles/registry.ts +156 -0
- package/internal/coding-agent/src/roles/skills.ts +72 -0
- package/internal/coding-agent/src/roles/sync.ts +88 -0
- package/internal/coding-agent/src/types.ts +102 -0
- package/internal/coding-agent/src/workspace.ts +275 -0
- package/octane.config.ts +36 -0
- package/package.json +68 -0
- package/public/favicon.svg +1 -0
- package/public/og.png +0 -0
- package/src/App.tsrx +924 -0
- package/src/client/ApprovalHandoff.tsrx +39 -0
- package/src/client/ChatPane.tsrx +694 -0
- package/src/client/ConnectView.tsrx +86 -0
- package/src/client/DiffPane.tsrx +150 -0
- package/src/client/EjectModal.tsrx +571 -0
- package/src/client/GateResults.tsrx +60 -0
- package/src/client/GitHubSettingsModal.tsrx +219 -0
- package/src/client/NewSessionForm.tsrx +214 -0
- package/src/client/SessionBar.tsrx +151 -0
- package/src/client/SessionPicker.tsrx +472 -0
- package/src/client/SpecEditor.tsrx +109 -0
- package/src/client/SpecReviewCard.tsrx +321 -0
- package/src/client/WorkCard.tsrx +128 -0
- package/src/client/WorkbenchModal.tsrx +161 -0
- package/src/client/WorkspaceMenu.tsrx +100 -0
- package/src/client/api.ts +797 -0
- package/src/client/attachments.ts +73 -0
- package/src/client/dashboard.ts +46 -0
- package/src/client/github-settings.ts +48 -0
- package/src/client/highlight.ts +105 -0
- package/src/client/i18n.ts +32 -0
- package/src/client/locales/en.json +466 -0
- package/src/client/locales/pl.json +466 -0
- package/src/client/session-labels.ts +77 -0
- package/src/client/state.ts +108 -0
- package/src/index.ts +10 -0
- package/src/preview/PreviewHost.tsrx +373 -0
- package/src/preview/load-module.ts +16 -0
- package/src/server/attachments.ts +308 -0
- package/src/server/auto-review.ts +181 -0
- package/src/server/checkpoints.ts +90 -0
- package/src/server/config.ts +460 -0
- package/src/server/dashboard.ts +245 -0
- package/src/server/delivery/configuration.ts +193 -0
- package/src/server/delivery/git-pr.ts +1473 -0
- package/src/server/delivery/index.ts +83 -0
- package/src/server/delivery/local.ts +151 -0
- package/src/server/delivery/official-modules.ts +516 -0
- package/src/server/delivery/plan.ts +218 -0
- package/src/server/delivery/policies.ts +239 -0
- package/src/server/delivery/record.ts +41 -0
- package/src/server/delivery/steps.ts +464 -0
- package/src/server/delivery/types.ts +158 -0
- package/src/server/dependencies.ts +88 -0
- package/src/server/diff.ts +230 -0
- package/src/server/gates.ts +388 -0
- package/src/server/index.ts +139 -0
- package/src/server/path-guard.ts +282 -0
- package/src/server/planning.ts +749 -0
- package/src/server/platform-client.ts +189 -0
- package/src/server/preview-database-host.ts +340 -0
- package/src/server/preview-database-protocol.ts +163 -0
- package/src/server/preview-database-proxy.ts +356 -0
- package/src/server/preview-database.ts +109 -0
- package/src/server/preview-ipc.ts +15 -0
- package/src/server/preview-modules.ts +83 -0
- package/src/server/preview-revision.ts +44 -0
- package/src/server/preview-runtime.ts +467 -0
- package/src/server/preview-worker-manager.ts +477 -0
- package/src/server/preview-worker.ts +168 -0
- package/src/server/reference.ts +251 -0
- package/src/server/routes.ts +2258 -0
- package/src/server/runtime.ts +188 -0
- package/src/server/session-owner.ts +23 -0
- package/src/server/sessions.ts +849 -0
- package/src/server/spec.ts +471 -0
- package/src/server/turn-lifecycle.ts +56 -0
- package/src/server/turns.ts +993 -0
- package/src/server/workspace-install.ts +266 -0
- package/src/server/workspace-root.ts +73 -0
- package/src/styles.css +1573 -0
- package/vite.config.ts +134 -0
package/vite.config.ts
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { flowdularEnvironment } from '@flowdular/sdk/kernel/runtime-config';
|
|
2
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
3
|
+
import { dirname, join, resolve } from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import { octane } from '@octanejs/vite-plugin';
|
|
6
|
+
import type { Plugin } from 'vite';
|
|
7
|
+
import { defineConfig } from 'vite';
|
|
8
|
+
import { sandboxDirectory } from './src/server/config.ts';
|
|
9
|
+
import { findFlowdularWorkspace } from './src/server/workspace-root.ts';
|
|
10
|
+
import { resolvePreviewModules } from './src/server/preview-modules.ts';
|
|
11
|
+
import type { SandboxSession } from './src/server/sessions.ts';
|
|
12
|
+
|
|
13
|
+
Object.assign(process.env, flowdularEnvironment(process.env));
|
|
14
|
+
|
|
15
|
+
const appRoot = dirname(fileURLToPath(import.meta.url));
|
|
16
|
+
const workspace = await findFlowdularWorkspace(
|
|
17
|
+
process.env.FD_SANDBOX_WORKSPACE ?? process.cwd(),
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
const PREVIEW_MODULE =
|
|
21
|
+
/^\/preview-module\/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\/([a-z][a-z0-9-]*)\/(.+)$/;
|
|
22
|
+
|
|
23
|
+
/* The preview imports draft sources by session and module directory. This
|
|
24
|
+
plugin maps that URL onto the session workspace, so the browser never learns
|
|
25
|
+
where the workspace lives on disk and cannot ask for anything outside a
|
|
26
|
+
session's module directory. */
|
|
27
|
+
function previewModules(workspaceRoot: string): Plugin {
|
|
28
|
+
return {
|
|
29
|
+
name: 'flowdular-preview-modules',
|
|
30
|
+
enforce: 'pre',
|
|
31
|
+
async resolveId(source) {
|
|
32
|
+
const support =
|
|
33
|
+
/^\/preview-support\/([0-9a-f-]{36})\/([a-z][a-z0-9-]*)\/(.+)$/.exec(
|
|
34
|
+
source,
|
|
35
|
+
);
|
|
36
|
+
if (support) {
|
|
37
|
+
const [, sessionId, directory, rest] = support;
|
|
38
|
+
if (rest!.split('/').some((part) => part === '..' || !part))
|
|
39
|
+
return null;
|
|
40
|
+
try {
|
|
41
|
+
const session = JSON.parse(
|
|
42
|
+
readFileSync(
|
|
43
|
+
join(
|
|
44
|
+
sandboxDirectory(workspaceRoot),
|
|
45
|
+
'sessions',
|
|
46
|
+
sessionId!,
|
|
47
|
+
'session.json',
|
|
48
|
+
),
|
|
49
|
+
'utf8',
|
|
50
|
+
),
|
|
51
|
+
) as SandboxSession;
|
|
52
|
+
const selected = (
|
|
53
|
+
await resolvePreviewModules(workspaceRoot, session)
|
|
54
|
+
).find((module) => module.support && module.directory === directory);
|
|
55
|
+
if (!selected) return null;
|
|
56
|
+
const file = join(selected.path, rest!);
|
|
57
|
+
return existsSync(file) ? file : null;
|
|
58
|
+
} catch {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const match = PREVIEW_MODULE.exec(source);
|
|
63
|
+
if (!match) return null;
|
|
64
|
+
const [, sessionId, directory, rest] = match;
|
|
65
|
+
if (rest!.split('/').some((segment) => segment === '..' || !segment)) {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
const sessionRoot = join(
|
|
69
|
+
sandboxDirectory(workspaceRoot),
|
|
70
|
+
'sessions',
|
|
71
|
+
sessionId!,
|
|
72
|
+
);
|
|
73
|
+
let modules: readonly { readonly directory: string }[] = [];
|
|
74
|
+
try {
|
|
75
|
+
const record = JSON.parse(
|
|
76
|
+
readFileSync(join(sessionRoot, 'session.json'), 'utf8'),
|
|
77
|
+
) as {
|
|
78
|
+
modules?: readonly { readonly directory: string }[];
|
|
79
|
+
moduleSuffix?: string;
|
|
80
|
+
};
|
|
81
|
+
modules =
|
|
82
|
+
record.modules ??
|
|
83
|
+
(record.moduleSuffix ? [{ directory: record.moduleSuffix }] : []);
|
|
84
|
+
} catch {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
if (!modules.some((module) => module.directory === directory)) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
const file = join(sessionRoot, 'workspace', 'modules', directory!, rest!);
|
|
91
|
+
return existsSync(file) ? file : null;
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const config = {
|
|
97
|
+
root: appRoot,
|
|
98
|
+
plugins: [previewModules(workspace.root), octane()],
|
|
99
|
+
resolve: {
|
|
100
|
+
/* Draft module code is loaded from a session workspace outside this app.
|
|
101
|
+
It resolves the workspace packages through the node_modules link the
|
|
102
|
+
session gets, and these must stay single instances or the preview would
|
|
103
|
+
run on a second runtime. */
|
|
104
|
+
dedupe: [
|
|
105
|
+
'octane',
|
|
106
|
+
'segment-state',
|
|
107
|
+
'@flowdular/sdk',
|
|
108
|
+
'@flowdular/sdk/client',
|
|
109
|
+
'@flowdular/sdk/ui',
|
|
110
|
+
'@flowdular/sdk/server',
|
|
111
|
+
'@flowdular/sdk/contracts',
|
|
112
|
+
],
|
|
113
|
+
extensions: ['.tsrx', '.ts', '.tsx', '.mjs', '.js', '.jsx', '.json'],
|
|
114
|
+
},
|
|
115
|
+
build: { target: 'esnext' },
|
|
116
|
+
/* Suites here boot the embedded PostgreSQL, which costs well past the 5s
|
|
117
|
+
vitest default under a full workspace run. Vitest reads this file, so the
|
|
118
|
+
timeouts live here rather than in a vitest.config.ts that would shadow it
|
|
119
|
+
and take the preview plugins with it. */
|
|
120
|
+
test: { testTimeout: 30_000, hookTimeout: 30_000 },
|
|
121
|
+
server: {
|
|
122
|
+
host: '127.0.0.1',
|
|
123
|
+
port: 4320,
|
|
124
|
+
strictPort: true,
|
|
125
|
+
/* Draft module files change on every agent turn and are served from
|
|
126
|
+
outside this app's root. The preview reloads itself instead, and a Vite
|
|
127
|
+
overlay must never cover a module someone is reviewing. */
|
|
128
|
+
hmr: { overlay: false },
|
|
129
|
+
fs: { allow: [appRoot, workspace.root] },
|
|
130
|
+
watch: { ignored: ['**/.flowdular/data/**', '**/.coreloom/data/**'] },
|
|
131
|
+
},
|
|
132
|
+
} satisfies import('vitest/config').UserWorkspaceConfig;
|
|
133
|
+
|
|
134
|
+
export default defineConfig(config);
|