@flowdular/sdk 0.1.0 → 0.2.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/.ai/skills/test-hardening/SKILL.md +1 -1
- package/README.md +69 -12
- package/assets/flowdular-banner.png +0 -0
- package/modules/agents/package.json +1 -1
- package/modules/auth/package.json +1 -1
- package/modules/auth/src/client/AuthenticationCore.tsrx +3 -1
- package/modules/auth/src/server/endpoints.ts +3 -1
- package/modules/auth/src/server/runtime.ts +4 -0
- package/modules/automations/package.json +1 -1
- package/modules/automations-workflows-integration/package.json +1 -1
- package/modules/profile/package.json +1 -1
- package/modules/sandbox/package.json +1 -1
- package/modules/system/package.json +1 -1
- package/modules/users/package.json +1 -1
- package/modules/workflows/package.json +1 -1
- package/package.json +5 -13
- package/packages/ai-provider/package.json +1 -1
- package/packages/cli-protocol/package.json +1 -1
- package/packages/client/package.json +1 -1
- package/packages/client/src/routing.ts +39 -2
- package/packages/client/src/shell/BrandMark.tsrx +5 -1
- package/packages/client/src/shell/navigation.ts +3 -1
- package/packages/client/src/state.ts +6 -2
- package/packages/contracts/package.json +1 -1
- package/packages/contracts/schemas/project.schema.json +16 -42
- package/packages/database/package.json +1 -1
- package/packages/database-pglite/package.json +2 -2
- package/packages/database-pglite/src/driver.ts +21 -3
- package/packages/database-testing/package.json +1 -1
- package/packages/dev-console/package.json +1 -1
- package/packages/harness/package.json +1 -1
- package/packages/kernel/package.json +1 -1
- package/packages/server/package.json +1 -1
- package/packages/server/src/application-routes.ts +80 -8
- package/packages/server/src/index.ts +4 -1
- package/packages/server/src/web-html.ts +9 -5
- package/packages/server/src/web.ts +59 -7
- package/packages/ui/package.json +1 -1
- package/packages/coding-agent/package.json +0 -44
- package/packages/coding-agent/src/drivers/byok.ts +0 -322
- package/packages/coding-agent/src/drivers/claude-code.ts +0 -290
- package/packages/coding-agent/src/drivers/codex.ts +0 -281
- package/packages/coding-agent/src/index.ts +0 -56
- package/packages/coding-agent/src/registry.ts +0 -119
- package/packages/coding-agent/src/roles/contract.ts +0 -60
- package/packages/coding-agent/src/roles/defaults.ts +0 -134
- package/packages/coding-agent/src/roles/handoff.ts +0 -41
- package/packages/coding-agent/src/roles/registry.ts +0 -156
- package/packages/coding-agent/src/roles/skills.ts +0 -72
- package/packages/coding-agent/src/roles/sync.ts +0 -88
- package/packages/coding-agent/src/types.ts +0 -102
- package/packages/coding-agent/src/workspace.ts +0 -275
- package/packages/sandbox/README.md +0 -691
- package/packages/sandbox/bin/flowdular-sandbox.mjs +0 -393
- package/packages/sandbox/dist/client/assets/App-ClMOrpyg.js +0 -11
- package/packages/sandbox/dist/client/assets/PreviewHost-BHiHrfbQ.js +0 -1
- package/packages/sandbox/dist/client/assets/auto-buGEq6de.js +0 -3
- package/packages/sandbox/dist/client/assets/ibm-plex-mono-cyrillic-400-normal-BSMlKf0J.woff2 +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-mono-cyrillic-400-normal-CEL4l2ZJ.woff +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-mono-cyrillic-500-normal-Ael50iVv.woff +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-mono-cyrillic-500-normal-Bq9vWWag.woff2 +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-mono-cyrillic-ext-400-normal-DMdlQ8Kv.woff +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-mono-cyrillic-ext-400-normal-xuaO2J-f.woff2 +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-mono-cyrillic-ext-500-normal-BIfNGwUT.woff +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-mono-cyrillic-ext-500-normal-BqneJy0T.woff2 +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-mono-latin-400-normal-CvHOgSBP.woff +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-mono-latin-400-normal-DMJ8VG8y.woff2 +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-mono-latin-500-normal-CB9ihrfo.woff +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-mono-latin-500-normal-DSY6xOcd.woff2 +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-mono-latin-ext-400-normal-BmRBH3aV.woff2 +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-mono-latin-ext-400-normal-D3D2R8hC.woff +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-mono-latin-ext-500-normal-CAhNIIs5.woff2 +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-mono-latin-ext-500-normal-CZ70TYgx.woff +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-mono-vietnamese-400-normal-BulugwFq.woff2 +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-mono-vietnamese-400-normal-DDuiU_S-.woff +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-mono-vietnamese-500-normal-C8zxqsMH.woff +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-mono-vietnamese-500-normal-DZ4AoWbu.woff2 +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-sans-cyrillic-ext-wght-normal-d45eAU9y.woff2 +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-sans-cyrillic-wght-normal-BAAhND-U.woff2 +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-sans-greek-wght-normal-CmyJS8uq.woff2 +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-sans-latin-ext-wght-normal-CIII54If.woff2 +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-sans-latin-wght-normal-IvpUvPa2.woff2 +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-sans-vietnamese-wght-normal-Dg1JeJN0.woff2 +0 -0
- package/packages/sandbox/dist/client/assets/index-CvwhlQ87.js +0 -4
- package/packages/sandbox/dist/client/assets/styles-BPWaGf55.js +0 -3
- package/packages/sandbox/dist/client/assets/styles-Dx1_KOag.css +0 -1
- package/packages/sandbox/dist/client/favicon.svg +0 -1
- package/packages/sandbox/dist/server/assets/auto-CVGNYyb3.js +0 -12785
- package/packages/sandbox/dist/server/assets/chunk-DDJLRBDX-3OUNo51g.js +0 -4125
- package/packages/sandbox/dist/server/assets/nodefs-DVSI7kG0.js +0 -24
- package/packages/sandbox/dist/server/assets/opfs-ahp-D56iokt1.js +0 -388
- package/packages/sandbox/dist/server/assets/token-Bvaq7Anz.js +0 -55
- package/packages/sandbox/dist/server/assets/token-util-BqSvdIPQ.js +0 -3
- package/packages/sandbox/dist/server/assets/token-util-CktFFT4z.js +0 -494
- package/packages/sandbox/dist/server/entry.js +0 -91671
- package/packages/sandbox/dist/server/favicon.svg +0 -1
- package/packages/sandbox/dist/server/index.html +0 -161
- package/packages/sandbox/index.html +0 -159
- package/packages/sandbox/octane.config.ts +0 -36
- package/packages/sandbox/package.json +0 -83
- package/packages/sandbox/public/favicon.svg +0 -1
- package/packages/sandbox/public/og.png +0 -0
- package/packages/sandbox/src/App.tsrx +0 -924
- package/packages/sandbox/src/client/ApprovalHandoff.tsrx +0 -39
- package/packages/sandbox/src/client/ChatPane.tsrx +0 -694
- package/packages/sandbox/src/client/ConnectView.tsrx +0 -86
- package/packages/sandbox/src/client/DiffPane.tsrx +0 -150
- package/packages/sandbox/src/client/EjectModal.tsrx +0 -571
- package/packages/sandbox/src/client/GateResults.tsrx +0 -60
- package/packages/sandbox/src/client/GitHubSettingsModal.tsrx +0 -219
- package/packages/sandbox/src/client/NewSessionForm.tsrx +0 -214
- package/packages/sandbox/src/client/SessionBar.tsrx +0 -151
- package/packages/sandbox/src/client/SessionPicker.tsrx +0 -472
- package/packages/sandbox/src/client/SpecEditor.tsrx +0 -109
- package/packages/sandbox/src/client/SpecReviewCard.tsrx +0 -321
- package/packages/sandbox/src/client/WorkCard.tsrx +0 -128
- package/packages/sandbox/src/client/WorkbenchModal.tsrx +0 -161
- package/packages/sandbox/src/client/WorkspaceMenu.tsrx +0 -100
- package/packages/sandbox/src/client/api.ts +0 -797
- package/packages/sandbox/src/client/attachments.ts +0 -73
- package/packages/sandbox/src/client/dashboard.ts +0 -46
- package/packages/sandbox/src/client/github-settings.ts +0 -48
- package/packages/sandbox/src/client/highlight.ts +0 -105
- package/packages/sandbox/src/client/i18n.ts +0 -32
- package/packages/sandbox/src/client/locales/en.json +0 -466
- package/packages/sandbox/src/client/locales/pl.json +0 -466
- package/packages/sandbox/src/client/session-labels.ts +0 -77
- package/packages/sandbox/src/client/state.ts +0 -108
- package/packages/sandbox/src/index.ts +0 -10
- package/packages/sandbox/src/preview/PreviewHost.tsrx +0 -373
- package/packages/sandbox/src/preview/load-module.ts +0 -16
- package/packages/sandbox/src/server/attachments.ts +0 -308
- package/packages/sandbox/src/server/auto-review.ts +0 -181
- package/packages/sandbox/src/server/checkpoints.ts +0 -90
- package/packages/sandbox/src/server/config.ts +0 -460
- package/packages/sandbox/src/server/dashboard.ts +0 -245
- package/packages/sandbox/src/server/delivery/configuration.ts +0 -193
- package/packages/sandbox/src/server/delivery/git-pr.ts +0 -1473
- package/packages/sandbox/src/server/delivery/index.ts +0 -83
- package/packages/sandbox/src/server/delivery/local.ts +0 -151
- package/packages/sandbox/src/server/delivery/official-modules.ts +0 -516
- package/packages/sandbox/src/server/delivery/plan.ts +0 -218
- package/packages/sandbox/src/server/delivery/policies.ts +0 -239
- package/packages/sandbox/src/server/delivery/record.ts +0 -41
- package/packages/sandbox/src/server/delivery/steps.ts +0 -464
- package/packages/sandbox/src/server/delivery/types.ts +0 -158
- package/packages/sandbox/src/server/dependencies.ts +0 -88
- package/packages/sandbox/src/server/diff.ts +0 -230
- package/packages/sandbox/src/server/gates.ts +0 -388
- package/packages/sandbox/src/server/index.ts +0 -139
- package/packages/sandbox/src/server/path-guard.ts +0 -282
- package/packages/sandbox/src/server/planning.ts +0 -749
- package/packages/sandbox/src/server/platform-client.ts +0 -189
- package/packages/sandbox/src/server/preview-database-host.ts +0 -340
- package/packages/sandbox/src/server/preview-database-protocol.ts +0 -163
- package/packages/sandbox/src/server/preview-database-proxy.ts +0 -356
- package/packages/sandbox/src/server/preview-database.ts +0 -109
- package/packages/sandbox/src/server/preview-ipc.ts +0 -15
- package/packages/sandbox/src/server/preview-modules.ts +0 -83
- package/packages/sandbox/src/server/preview-revision.ts +0 -44
- package/packages/sandbox/src/server/preview-runtime.ts +0 -467
- package/packages/sandbox/src/server/preview-worker-manager.ts +0 -436
- package/packages/sandbox/src/server/preview-worker.ts +0 -168
- package/packages/sandbox/src/server/reference.ts +0 -251
- package/packages/sandbox/src/server/routes.ts +0 -2258
- package/packages/sandbox/src/server/runtime.ts +0 -188
- package/packages/sandbox/src/server/session-owner.ts +0 -23
- package/packages/sandbox/src/server/sessions.ts +0 -849
- package/packages/sandbox/src/server/spec.ts +0 -471
- package/packages/sandbox/src/server/turn-lifecycle.ts +0 -56
- package/packages/sandbox/src/server/turns.ts +0 -993
- package/packages/sandbox/src/server/workspace-install.ts +0 -266
- package/packages/sandbox/src/server/workspace-root.ts +0 -73
- package/packages/sandbox/src/styles.css +0 -1573
- package/packages/sandbox/vite.config.ts +0 -133
|
@@ -1,266 +0,0 @@
|
|
|
1
|
-
import { spawn } from 'node:child_process';
|
|
2
|
-
import { createHash } from 'node:crypto';
|
|
3
|
-
import { access, cp, readFile, readdir, writeFile } from 'node:fs/promises';
|
|
4
|
-
import { dirname, join } from 'node:path';
|
|
5
|
-
import { createRequire } from 'node:module';
|
|
6
|
-
import type { SessionModule } from './sessions.ts';
|
|
7
|
-
|
|
8
|
-
export interface InstallResult {
|
|
9
|
-
readonly ran: boolean;
|
|
10
|
-
readonly ok: boolean;
|
|
11
|
-
readonly durationMs: number;
|
|
12
|
-
readonly output: string;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const OUTPUT_LIMIT = 6_000;
|
|
16
|
-
const INSTALL_TIMEOUT_MS = 5 * 60 * 1000;
|
|
17
|
-
const SIGNATURE_FILE = 'install-signature';
|
|
18
|
-
|
|
19
|
-
async function exists(path: string): Promise<boolean> {
|
|
20
|
-
try {
|
|
21
|
-
await access(path);
|
|
22
|
-
return true;
|
|
23
|
-
} catch {
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
async function packageName(directory: string): Promise<string | null> {
|
|
29
|
-
try {
|
|
30
|
-
const manifest = JSON.parse(
|
|
31
|
-
await readFile(join(directory, 'package.json'), 'utf8'),
|
|
32
|
-
) as { name?: string };
|
|
33
|
-
return manifest.name ?? null;
|
|
34
|
-
} catch {
|
|
35
|
-
return null;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function yamlString(value: string): string {
|
|
40
|
-
return `'${value.replace(/'/g, "''")}'`;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/* A session workspace is a pnpm workspace of its own: the draft modules are its
|
|
44
|
-
projects, every other workspace package is linked to the live checkout, and
|
|
45
|
-
the host lockfile seeds the resolution so the session installs exactly the
|
|
46
|
-
versions the platform runs. A draft that depends on another draft resolves
|
|
47
|
-
the session copy, because both are projects of this workspace. */
|
|
48
|
-
export async function materializeSessionWorkspace(options: {
|
|
49
|
-
readonly workspaceRoot: string;
|
|
50
|
-
readonly sessionWorkspace: string;
|
|
51
|
-
readonly modules: readonly SessionModule[];
|
|
52
|
-
}): Promise<void> {
|
|
53
|
-
const draft = new Set<string>();
|
|
54
|
-
for (const module of options.modules) {
|
|
55
|
-
const name = await packageName(
|
|
56
|
-
join(options.sessionWorkspace, 'modules', module.directory),
|
|
57
|
-
);
|
|
58
|
-
if (name) draft.add(name);
|
|
59
|
-
}
|
|
60
|
-
const overrides: string[] = [];
|
|
61
|
-
for (const group of ['packages', 'modules']) {
|
|
62
|
-
let entries: readonly string[] = [];
|
|
63
|
-
try {
|
|
64
|
-
entries = await readdir(join(options.workspaceRoot, group));
|
|
65
|
-
} catch {
|
|
66
|
-
continue;
|
|
67
|
-
}
|
|
68
|
-
for (const entry of [...entries].sort()) {
|
|
69
|
-
const directory = join(options.workspaceRoot, group, entry);
|
|
70
|
-
const name = await packageName(directory);
|
|
71
|
-
if (!name || draft.has(name)) continue;
|
|
72
|
-
overrides.push(
|
|
73
|
-
` ${yamlString(name)}: ${yamlString(`link:${directory}`)}`,
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// A generated application installs the SDK under platform/. Make that exact
|
|
79
|
-
// SDK discoverable in a new session before its first module is scaffolded.
|
|
80
|
-
let sdkVersion: string | undefined;
|
|
81
|
-
try {
|
|
82
|
-
const require = createRequire(
|
|
83
|
-
join(options.workspaceRoot, 'platform/package.json'),
|
|
84
|
-
);
|
|
85
|
-
const sdkRoot = dirname(require.resolve('@flowdular/sdk/modules.json'));
|
|
86
|
-
const sdk = JSON.parse(
|
|
87
|
-
await readFile(join(sdkRoot, 'package.json'), 'utf8'),
|
|
88
|
-
);
|
|
89
|
-
if (typeof sdk.version !== 'string')
|
|
90
|
-
throw new Error('Invalid installed SDK version.');
|
|
91
|
-
sdkVersion = sdk.version;
|
|
92
|
-
overrides.push(` '@flowdular/sdk': ${yamlString(`link:${sdkRoot}`)}`);
|
|
93
|
-
} catch (error) {
|
|
94
|
-
if (
|
|
95
|
-
!['MODULE_NOT_FOUND', 'ERR_PACKAGE_PATH_NOT_EXPORTED'].includes(
|
|
96
|
-
(error as NodeJS.ErrnoException).code ?? '',
|
|
97
|
-
)
|
|
98
|
-
)
|
|
99
|
-
throw error;
|
|
100
|
-
}
|
|
101
|
-
let host: Record<string, unknown> = {};
|
|
102
|
-
try {
|
|
103
|
-
host = JSON.parse(
|
|
104
|
-
await readFile(join(options.workspaceRoot, 'package.json'), 'utf8'),
|
|
105
|
-
) as Record<string, unknown>;
|
|
106
|
-
} catch {
|
|
107
|
-
host = {};
|
|
108
|
-
}
|
|
109
|
-
await writeFile(
|
|
110
|
-
join(options.sessionWorkspace, 'package.json'),
|
|
111
|
-
`${JSON.stringify(
|
|
112
|
-
{
|
|
113
|
-
name: 'flowdular-session',
|
|
114
|
-
...(sdkVersion
|
|
115
|
-
? { dependencies: { '@flowdular/sdk': sdkVersion } }
|
|
116
|
-
: {}),
|
|
117
|
-
private: true,
|
|
118
|
-
type: 'module',
|
|
119
|
-
...(typeof host.packageManager === 'string'
|
|
120
|
-
? { packageManager: host.packageManager }
|
|
121
|
-
: {}),
|
|
122
|
-
},
|
|
123
|
-
null,
|
|
124
|
-
'\t',
|
|
125
|
-
)}\n`,
|
|
126
|
-
'utf8',
|
|
127
|
-
);
|
|
128
|
-
|
|
129
|
-
/* Build permissions, release-age exclusions and patches travel from the
|
|
130
|
-
host workspace file; the host lockfile pins the versions. */
|
|
131
|
-
const hostWorkspace = await readFile(
|
|
132
|
-
join(options.workspaceRoot, 'pnpm-workspace.yaml'),
|
|
133
|
-
'utf8',
|
|
134
|
-
).catch(() => '');
|
|
135
|
-
const carried = hostWorkspace
|
|
136
|
-
.split('\n')
|
|
137
|
-
.filter(
|
|
138
|
-
(line) =>
|
|
139
|
-
!/^(packages|overrides):/.test(line) &&
|
|
140
|
-
!/^\s+-\s+(platform|modules\/\*|packages\/\*)\s*$/.test(line),
|
|
141
|
-
)
|
|
142
|
-
.join('\n')
|
|
143
|
-
.trim();
|
|
144
|
-
await writeFile(
|
|
145
|
-
join(options.sessionWorkspace, 'pnpm-workspace.yaml'),
|
|
146
|
-
`${[
|
|
147
|
-
'packages:',
|
|
148
|
-
' - modules/*',
|
|
149
|
-
/* Host patches travel along even when no draft depends on the patched
|
|
150
|
-
package; pnpm must not treat that as an error. */
|
|
151
|
-
'allowUnusedPatches: true',
|
|
152
|
-
carried,
|
|
153
|
-
'overrides:',
|
|
154
|
-
...overrides,
|
|
155
|
-
]
|
|
156
|
-
.filter(Boolean)
|
|
157
|
-
.join('\n')}\n`,
|
|
158
|
-
'utf8',
|
|
159
|
-
);
|
|
160
|
-
for (const shared of ['pnpm-lock.yaml', 'patches']) {
|
|
161
|
-
const target = join(options.sessionWorkspace, shared);
|
|
162
|
-
if (await exists(target)) continue;
|
|
163
|
-
await cp(join(options.workspaceRoot, shared), target, {
|
|
164
|
-
recursive: true,
|
|
165
|
-
}).catch(() => undefined);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
async function dependencySignature(
|
|
170
|
-
sessionWorkspace: string,
|
|
171
|
-
modules: readonly SessionModule[],
|
|
172
|
-
): Promise<string> {
|
|
173
|
-
const hash = createHash('sha256');
|
|
174
|
-
for (const module of modules) {
|
|
175
|
-
hash.update(module.directory);
|
|
176
|
-
hash.update(
|
|
177
|
-
await readFile(
|
|
178
|
-
join(sessionWorkspace, 'modules', module.directory, 'package.json'),
|
|
179
|
-
'utf8',
|
|
180
|
-
).catch(() => ''),
|
|
181
|
-
);
|
|
182
|
-
}
|
|
183
|
-
return hash.digest('hex');
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
function runPnpm(
|
|
187
|
-
cwd: string,
|
|
188
|
-
args: readonly string[],
|
|
189
|
-
): Promise<{ code: number | null; output: string }> {
|
|
190
|
-
return new Promise((resolvePromise) => {
|
|
191
|
-
const child = spawn('pnpm', [...args], {
|
|
192
|
-
cwd,
|
|
193
|
-
env: { ...process.env, FORCE_COLOR: '0' },
|
|
194
|
-
stdio: ['ignore', 'pipe', 'pipe'],
|
|
195
|
-
});
|
|
196
|
-
let output = '';
|
|
197
|
-
const append = (chunk: string) => {
|
|
198
|
-
output = (output + chunk).slice(-OUTPUT_LIMIT);
|
|
199
|
-
};
|
|
200
|
-
child.stdout.setEncoding('utf8');
|
|
201
|
-
child.stderr.setEncoding('utf8');
|
|
202
|
-
child.stdout.on('data', append);
|
|
203
|
-
child.stderr.on('data', append);
|
|
204
|
-
const timer = setTimeout(() => {
|
|
205
|
-
append('\nThe install exceeded its time budget and was stopped.');
|
|
206
|
-
child.kill('SIGKILL');
|
|
207
|
-
}, INSTALL_TIMEOUT_MS);
|
|
208
|
-
timer.unref();
|
|
209
|
-
child.on('error', (error) => {
|
|
210
|
-
clearTimeout(timer);
|
|
211
|
-
resolvePromise({ code: null, output: `${output}\n${error.message}` });
|
|
212
|
-
});
|
|
213
|
-
child.on('close', (code) => {
|
|
214
|
-
clearTimeout(timer);
|
|
215
|
-
resolvePromise({ code, output });
|
|
216
|
-
});
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
/* Installs the session workspace when a draft module's package.json changed
|
|
221
|
-
since the last install, or when nothing was installed yet. The store on this
|
|
222
|
-
machine answers first; the registry is consulted only for a package the host
|
|
223
|
-
workspace never fetched. */
|
|
224
|
-
export async function ensureSessionDependencies(options: {
|
|
225
|
-
readonly sessionRoot: string;
|
|
226
|
-
readonly sessionWorkspace: string;
|
|
227
|
-
readonly modules: readonly SessionModule[];
|
|
228
|
-
readonly force?: boolean;
|
|
229
|
-
}): Promise<InstallResult> {
|
|
230
|
-
const startedAt = Date.now();
|
|
231
|
-
const signature = await dependencySignature(
|
|
232
|
-
options.sessionWorkspace,
|
|
233
|
-
options.modules,
|
|
234
|
-
);
|
|
235
|
-
const signaturePath = join(options.sessionRoot, SIGNATURE_FILE);
|
|
236
|
-
const previous = await readFile(signaturePath, 'utf8').catch(() => '');
|
|
237
|
-
const installed = await exists(
|
|
238
|
-
join(options.sessionWorkspace, 'node_modules'),
|
|
239
|
-
);
|
|
240
|
-
if (!options.force && installed && previous.trim() === signature) {
|
|
241
|
-
return { ran: false, ok: true, durationMs: 0, output: '' };
|
|
242
|
-
}
|
|
243
|
-
/* The seeded lockfile describes the host projects, so a frozen install would
|
|
244
|
-
refuse it; the session always re-resolves its own importers. */
|
|
245
|
-
let result = await runPnpm(options.sessionWorkspace, [
|
|
246
|
-
'install',
|
|
247
|
-
'--offline',
|
|
248
|
-
'--no-frozen-lockfile',
|
|
249
|
-
]);
|
|
250
|
-
if (result.code !== 0) {
|
|
251
|
-
result = await runPnpm(options.sessionWorkspace, [
|
|
252
|
-
'install',
|
|
253
|
-
'--prefer-offline',
|
|
254
|
-
'--no-frozen-lockfile',
|
|
255
|
-
]);
|
|
256
|
-
}
|
|
257
|
-
if (result.code === 0) {
|
|
258
|
-
await writeFile(signaturePath, signature, 'utf8');
|
|
259
|
-
}
|
|
260
|
-
return {
|
|
261
|
-
ran: true,
|
|
262
|
-
ok: result.code === 0,
|
|
263
|
-
durationMs: Date.now() - startedAt,
|
|
264
|
-
output: result.output.trim(),
|
|
265
|
-
};
|
|
266
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { access, readFile } from 'node:fs/promises';
|
|
2
|
-
import { dirname, resolve } from 'node:path';
|
|
3
|
-
|
|
4
|
-
export interface FlowdularWorkspace {
|
|
5
|
-
readonly root: string;
|
|
6
|
-
readonly configPath: string;
|
|
7
|
-
readonly config: Record<string, unknown>;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export class SandboxSetupError extends Error {
|
|
11
|
-
constructor(
|
|
12
|
-
readonly code: string,
|
|
13
|
-
message: string,
|
|
14
|
-
) {
|
|
15
|
-
super(message);
|
|
16
|
-
this.name = 'SandboxSetupError';
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/* The sandbox is always started from a Flowdular workspace, the same way the
|
|
21
|
-
CLI finds it: walk up until flowdular.json is found. */
|
|
22
|
-
export async function findFlowdularWorkspace(
|
|
23
|
-
start: string,
|
|
24
|
-
): Promise<FlowdularWorkspace> {
|
|
25
|
-
let directory = resolve(start);
|
|
26
|
-
for (;;) {
|
|
27
|
-
const configPath = resolve(directory, 'flowdular.json');
|
|
28
|
-
try {
|
|
29
|
-
await access(configPath);
|
|
30
|
-
return {
|
|
31
|
-
root: directory,
|
|
32
|
-
configPath,
|
|
33
|
-
config: JSON.parse(await readFile(configPath, 'utf8')) as Record<
|
|
34
|
-
string,
|
|
35
|
-
unknown
|
|
36
|
-
>,
|
|
37
|
-
};
|
|
38
|
-
} catch (error) {
|
|
39
|
-
if (error instanceof SyntaxError) {
|
|
40
|
-
throw new SandboxSetupError(
|
|
41
|
-
'WORKSPACE_CONFIG_INVALID',
|
|
42
|
-
`flowdular.json in ${directory} is not valid JSON.`,
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
const parent = dirname(directory);
|
|
47
|
-
if (parent === directory) {
|
|
48
|
-
throw new SandboxSetupError(
|
|
49
|
-
'WORKSPACE_NOT_FOUND',
|
|
50
|
-
'No flowdular.json was found in this directory or any parent. Start the sandbox from a Flowdular workspace.',
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
directory = parent;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export function enabledModules(
|
|
58
|
-
workspace: FlowdularWorkspace,
|
|
59
|
-
): readonly string[] {
|
|
60
|
-
const modules = workspace.config.modules as
|
|
61
|
-
| { enabled?: readonly string[] }
|
|
62
|
-
| undefined;
|
|
63
|
-
return modules?.enabled ?? [];
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export function moduleRootsOf(
|
|
67
|
-
workspace: FlowdularWorkspace,
|
|
68
|
-
): readonly string[] {
|
|
69
|
-
const modules = workspace.config.modules as
|
|
70
|
-
| { roots?: readonly string[] }
|
|
71
|
-
| undefined;
|
|
72
|
-
return modules?.roots ?? ['modules'];
|
|
73
|
-
}
|