@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,393 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
// ../sandbox/bin/flowdular-sandbox.mjs
|
|
4
|
-
import process2 from "node:process";
|
|
5
|
-
import { dirname, resolve } from "node:path";
|
|
6
|
-
import { fileURLToPath } from "node:url";
|
|
7
|
-
import { createServer } from "vite";
|
|
8
|
-
|
|
9
|
-
// ../dev-console/src/index.mjs
|
|
10
|
-
import { createLogger } from "vite";
|
|
11
|
-
var ansiPattern = /\u001B\[[0-?]*[ -/]*[@-~]/g;
|
|
12
|
-
var ansi = {
|
|
13
|
-
reset: "\x1B[0m",
|
|
14
|
-
brand: "\x1B[1;38;5;42m",
|
|
15
|
-
label: "\x1B[2;37m",
|
|
16
|
-
text: "\x1B[37m",
|
|
17
|
-
success: "\x1B[38;5;42m",
|
|
18
|
-
info: "\x1B[36m",
|
|
19
|
-
warning: "\x1B[33m",
|
|
20
|
-
error: "\x1B[31m",
|
|
21
|
-
muted: "\x1B[90m"
|
|
22
|
-
};
|
|
23
|
-
function shouldUseColor(environment = process.env, isTerminal = process.stdout.isTTY) {
|
|
24
|
-
if (Object.hasOwn(environment, "FORCE_COLOR") && environment.FORCE_COLOR !== "0") {
|
|
25
|
-
return true;
|
|
26
|
-
}
|
|
27
|
-
if (Object.hasOwn(environment, "NO_COLOR")) return false;
|
|
28
|
-
if (environment.TERM === "dumb") return false;
|
|
29
|
-
return Boolean(
|
|
30
|
-
isTerminal || environment.COLORTERM || environment.TERM_PROGRAM
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
function createTheme(enabled) {
|
|
34
|
-
const paint = (code) => enabled ? (value) => `${code}${String(value)}${ansi.reset}` : (value) => String(value);
|
|
35
|
-
return {
|
|
36
|
-
enabled,
|
|
37
|
-
brand: paint(ansi.brand),
|
|
38
|
-
label: paint(ansi.label),
|
|
39
|
-
text: paint(ansi.text),
|
|
40
|
-
success: paint(ansi.success),
|
|
41
|
-
info: paint(ansi.info),
|
|
42
|
-
warning: paint(ansi.warning),
|
|
43
|
-
error: paint(ansi.error),
|
|
44
|
-
muted: paint(ansi.muted)
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
function formatDevEvent(kind, message, useColor = shouldUseColor()) {
|
|
48
|
-
const theme = createTheme(useColor);
|
|
49
|
-
const label = kind === "process" ? "[octane]" : `[octane:${kind}]`;
|
|
50
|
-
const tone = kind === "error" ? theme.error : kind === "notice" ? theme.warning : kind === "routes" ? theme.success : kind === "reload" ? theme.info : theme.muted;
|
|
51
|
-
return `${tone(label)} ${tone(message)}`;
|
|
52
|
-
}
|
|
53
|
-
function clean(message) {
|
|
54
|
-
return String(message).replace(ansiPattern, "").trim();
|
|
55
|
-
}
|
|
56
|
-
function statusLine(theme, label, value, tone = "text") {
|
|
57
|
-
return ` ${theme.label(label.padEnd(12))}${theme[tone](value)}`;
|
|
58
|
-
}
|
|
59
|
-
function printReady({ title, subtitle, lines, theme }) {
|
|
60
|
-
console.log("");
|
|
61
|
-
console.log(` ${theme.brand(title)} ${theme.muted(subtitle)}`);
|
|
62
|
-
for (const [label, value, tone = "text"] of lines) {
|
|
63
|
-
if (value === null || value === void 0) continue;
|
|
64
|
-
console.log(statusLine(theme, label, value, tone));
|
|
65
|
-
}
|
|
66
|
-
console.log("");
|
|
67
|
-
}
|
|
68
|
-
function createOctaneLogger(verbose, useColor) {
|
|
69
|
-
const viteLogger = createLogger("info", { allowClearScreen: false });
|
|
70
|
-
const warnings = /* @__PURE__ */ new Set();
|
|
71
|
-
let hasWarned = false;
|
|
72
|
-
const warn = (message, options) => {
|
|
73
|
-
hasWarned = true;
|
|
74
|
-
if (verbose) {
|
|
75
|
-
viteLogger.warn(message, options);
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
const normalized = clean(message);
|
|
79
|
-
if (warnings.has(normalized)) return;
|
|
80
|
-
warnings.add(normalized);
|
|
81
|
-
if (warnings.size === 1) {
|
|
82
|
-
console.warn(
|
|
83
|
-
formatDevEvent(
|
|
84
|
-
"notice",
|
|
85
|
-
"Tool warnings are hidden. Restart with --verbose to inspect them.",
|
|
86
|
-
useColor
|
|
87
|
-
)
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
return {
|
|
92
|
-
get hasWarned() {
|
|
93
|
-
return hasWarned;
|
|
94
|
-
},
|
|
95
|
-
info(message, options) {
|
|
96
|
-
if (verbose) viteLogger.info(message, options);
|
|
97
|
-
},
|
|
98
|
-
warn,
|
|
99
|
-
warnOnce(message, options) {
|
|
100
|
-
if (verbose) {
|
|
101
|
-
hasWarned = true;
|
|
102
|
-
viteLogger.warnOnce(message, options);
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
if (!warnings.has(clean(message))) warn(message, options);
|
|
106
|
-
},
|
|
107
|
-
error(message, options) {
|
|
108
|
-
console.error(formatDevEvent("error", clean(message), useColor));
|
|
109
|
-
if (verbose && options?.error?.stack) {
|
|
110
|
-
console.error(options.error.stack);
|
|
111
|
-
}
|
|
112
|
-
},
|
|
113
|
-
clearScreen() {
|
|
114
|
-
},
|
|
115
|
-
hasErrorLogged(error) {
|
|
116
|
-
return viteLogger.hasErrorLogged(error);
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
function isClientDisconnectLog(values) {
|
|
121
|
-
if (typeof values[0] !== "string") return false;
|
|
122
|
-
if (!values[0].startsWith("[octane] SSR render error:")) return false;
|
|
123
|
-
return values.slice(1).some(
|
|
124
|
-
(value) => value instanceof Error && value.message.includes("client disconnected")
|
|
125
|
-
);
|
|
126
|
-
}
|
|
127
|
-
function installOctaneConsoleBridge(verbose, useColor) {
|
|
128
|
-
const originalLog = console.log.bind(console);
|
|
129
|
-
const originalError = console.error.bind(console);
|
|
130
|
-
console.log = (...values) => {
|
|
131
|
-
const message = values[0];
|
|
132
|
-
if (!verbose && typeof message === "string" && message.startsWith("[@octanejs/vite-plugin]")) {
|
|
133
|
-
const loaded = message.match(/Loaded (\d+) routes/);
|
|
134
|
-
const reloaded = message.match(/Reloaded (\d+) routes/);
|
|
135
|
-
if (loaded) {
|
|
136
|
-
originalLog(
|
|
137
|
-
formatDevEvent("routes", `${loaded[1]} routes loaded`, useColor)
|
|
138
|
-
);
|
|
139
|
-
} else if (reloaded) {
|
|
140
|
-
originalLog(
|
|
141
|
-
formatDevEvent("routes", `${reloaded[1]} routes reloaded`, useColor)
|
|
142
|
-
);
|
|
143
|
-
}
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
originalLog(...values);
|
|
147
|
-
};
|
|
148
|
-
console.error = (...values) => {
|
|
149
|
-
const message = values[0];
|
|
150
|
-
if (!verbose && isClientDisconnectLog(values)) return;
|
|
151
|
-
if (typeof message === "string" && message.startsWith("[@octanejs/vite-plugin]")) {
|
|
152
|
-
originalError(
|
|
153
|
-
formatDevEvent(
|
|
154
|
-
"error",
|
|
155
|
-
message.slice("[@octanejs/vite-plugin]".length).trim(),
|
|
156
|
-
useColor
|
|
157
|
-
),
|
|
158
|
-
...values.slice(1)
|
|
159
|
-
);
|
|
160
|
-
return;
|
|
161
|
-
}
|
|
162
|
-
originalError(...values);
|
|
163
|
-
};
|
|
164
|
-
return () => {
|
|
165
|
-
console.log = originalLog;
|
|
166
|
-
console.error = originalError;
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
function watchReloads(server, root, useColor) {
|
|
170
|
-
let lastChange = "";
|
|
171
|
-
let lastChangeAt = 0;
|
|
172
|
-
server.watcher.on("change", (path) => {
|
|
173
|
-
const changed = path.startsWith(root) ? path.slice(root.length + 1) : path;
|
|
174
|
-
const now = Date.now();
|
|
175
|
-
if (changed === lastChange && now - lastChangeAt < 100) return;
|
|
176
|
-
lastChange = changed;
|
|
177
|
-
lastChangeAt = now;
|
|
178
|
-
console.log(formatDevEvent("reload", changed, useColor));
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
// ../sandbox/bin/flowdular-sandbox.mjs
|
|
183
|
-
var appRoot = resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
|
184
|
-
function parseSandboxArguments(argv = []) {
|
|
185
|
-
const options = {
|
|
186
|
-
host: "127.0.0.1",
|
|
187
|
-
port: 4320,
|
|
188
|
-
mode: "loopback",
|
|
189
|
-
workspace: process2.cwd(),
|
|
190
|
-
verbose: process2.env.FD_SANDBOX_VERBOSE === "true",
|
|
191
|
-
help: false
|
|
192
|
-
};
|
|
193
|
-
for (let index = 0; index < argv.length; index += 1) {
|
|
194
|
-
const argument = argv[index];
|
|
195
|
-
if (argument === "--help" || argument === "-h") {
|
|
196
|
-
options.help = true;
|
|
197
|
-
continue;
|
|
198
|
-
}
|
|
199
|
-
if (argument === "--verbose" || argument === "-v") {
|
|
200
|
-
options.verbose = true;
|
|
201
|
-
continue;
|
|
202
|
-
}
|
|
203
|
-
const take = (name) => {
|
|
204
|
-
const inline = argument.startsWith(`--${name}=`) ? argument.slice(name.length + 3) : void 0;
|
|
205
|
-
if (inline !== void 0) return inline;
|
|
206
|
-
if (argument !== `--${name}`) return void 0;
|
|
207
|
-
const value = argv[index + 1];
|
|
208
|
-
if (!value || value.startsWith("--")) {
|
|
209
|
-
throw new Error(`--${name} requires a value.`);
|
|
210
|
-
}
|
|
211
|
-
index += 1;
|
|
212
|
-
return value;
|
|
213
|
-
};
|
|
214
|
-
const host = take("host");
|
|
215
|
-
if (host !== void 0) {
|
|
216
|
-
options.host = host;
|
|
217
|
-
continue;
|
|
218
|
-
}
|
|
219
|
-
const port = take("port");
|
|
220
|
-
if (port !== void 0) {
|
|
221
|
-
options.port = Number(port);
|
|
222
|
-
continue;
|
|
223
|
-
}
|
|
224
|
-
const workspace = take("workspace");
|
|
225
|
-
if (workspace !== void 0) {
|
|
226
|
-
options.workspace = resolve(workspace);
|
|
227
|
-
continue;
|
|
228
|
-
}
|
|
229
|
-
const mode = take("mode");
|
|
230
|
-
if (mode !== void 0) {
|
|
231
|
-
if (mode !== "loopback" && mode !== "self-hosted") {
|
|
232
|
-
throw new Error("--mode must be loopback or self-hosted.");
|
|
233
|
-
}
|
|
234
|
-
options.mode = mode;
|
|
235
|
-
continue;
|
|
236
|
-
}
|
|
237
|
-
throw new Error(`Unknown sandbox option: ${argument}`);
|
|
238
|
-
}
|
|
239
|
-
if (!Number.isInteger(options.port) || options.port < 1 || options.port > 65535) {
|
|
240
|
-
throw new Error("--port must be an integer between 1 and 65535.");
|
|
241
|
-
}
|
|
242
|
-
if (options.mode === "loopback" && !isLoopbackHost(options.host)) {
|
|
243
|
-
options.mode = "self-hosted";
|
|
244
|
-
}
|
|
245
|
-
return options;
|
|
246
|
-
}
|
|
247
|
-
function isLoopbackHost(host) {
|
|
248
|
-
return host === "127.0.0.1" || host === "localhost" || host === "::1";
|
|
249
|
-
}
|
|
250
|
-
function printHelp() {
|
|
251
|
-
console.log(`Flowdular sandbox
|
|
252
|
-
|
|
253
|
-
Usage: npx @flowdular/sandbox [options]
|
|
254
|
-
|
|
255
|
-
Options:
|
|
256
|
-
--workspace <path> Flowdular workspace to use (default: current directory)
|
|
257
|
-
--host <host> Bind address (default: 127.0.0.1)
|
|
258
|
-
--port <port> HTTP port (default: 4320)
|
|
259
|
-
--mode <mode> loopback or self-hosted (default: loopback)
|
|
260
|
-
-v, --verbose Show Vite and tool warnings
|
|
261
|
-
-h, --help Show this help`);
|
|
262
|
-
}
|
|
263
|
-
async function sandboxStatus(server, workspace) {
|
|
264
|
-
const local = server.resolvedUrls?.local?.[0] ?? "http://127.0.0.1:4320/";
|
|
265
|
-
try {
|
|
266
|
-
const state = await fetch(new URL("/sandbox/api/state", local), {
|
|
267
|
-
headers: { accept: "application/json" }
|
|
268
|
-
}).then((response) => response.json());
|
|
269
|
-
if (state.error) {
|
|
270
|
-
return {
|
|
271
|
-
platform: `${state.configuration?.platformUrl ?? "not configured"} \xB7 sign in required`,
|
|
272
|
-
connected: false,
|
|
273
|
-
agents: "after sign-in",
|
|
274
|
-
hasAgents: false,
|
|
275
|
-
sessions: 0
|
|
276
|
-
};
|
|
277
|
-
}
|
|
278
|
-
const offered = (state.drivers ?? []).filter((driver) => driver.offered).map((driver) => driver.label);
|
|
279
|
-
const tenant = state.connection?.authority?.principal?.tenantName ?? "connected";
|
|
280
|
-
return {
|
|
281
|
-
platform: state.connection?.connected ? `${state.configuration.platformUrl} \xB7 ${tenant}` : `${state.configuration?.platformUrl ?? "not configured"} \xB7 not connected`,
|
|
282
|
-
connected: Boolean(state.connection?.connected),
|
|
283
|
-
agents: offered.length > 0 ? offered.join(" \xB7 ") : "none available",
|
|
284
|
-
hasAgents: offered.length > 0,
|
|
285
|
-
sessions: (state.sessions ?? []).length
|
|
286
|
-
};
|
|
287
|
-
} catch {
|
|
288
|
-
return {
|
|
289
|
-
platform: "unavailable",
|
|
290
|
-
connected: false,
|
|
291
|
-
agents: "unknown",
|
|
292
|
-
hasAgents: false,
|
|
293
|
-
sessions: 0
|
|
294
|
-
};
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
async function startSandbox(argv = process2.argv.slice(2)) {
|
|
298
|
-
const options = parseSandboxArguments(argv);
|
|
299
|
-
const useColor = shouldUseColor();
|
|
300
|
-
const theme = createTheme(useColor);
|
|
301
|
-
if (options.help) {
|
|
302
|
-
printHelp(theme);
|
|
303
|
-
return null;
|
|
304
|
-
}
|
|
305
|
-
process2.env.FD_SANDBOX_WORKSPACE = options.workspace;
|
|
306
|
-
process2.env.FD_SANDBOX_MODE = options.mode;
|
|
307
|
-
process2.env.FD_SANDBOX_PORT = String(options.port);
|
|
308
|
-
const startedAt = performance.now();
|
|
309
|
-
const restoreConsole = installOctaneConsoleBridge(options.verbose, useColor);
|
|
310
|
-
const logger = createOctaneLogger(options.verbose, useColor);
|
|
311
|
-
let server;
|
|
312
|
-
try {
|
|
313
|
-
server = await createServer({
|
|
314
|
-
root: appRoot,
|
|
315
|
-
configFile: resolve(appRoot, "vite.config.ts"),
|
|
316
|
-
customLogger: logger,
|
|
317
|
-
clearScreen: false,
|
|
318
|
-
server: { host: options.host, port: options.port, strictPort: true }
|
|
319
|
-
});
|
|
320
|
-
await server.listen();
|
|
321
|
-
} catch (error) {
|
|
322
|
-
restoreConsole();
|
|
323
|
-
throw error;
|
|
324
|
-
}
|
|
325
|
-
const status = await sandboxStatus(server, options.workspace);
|
|
326
|
-
printReady({
|
|
327
|
-
title: "FLOWDULAR SANDBOX",
|
|
328
|
-
subtitle: "agentic workspace",
|
|
329
|
-
theme,
|
|
330
|
-
lines: [
|
|
331
|
-
["ready", `${Math.round(performance.now() - startedAt)} ms`, "success"],
|
|
332
|
-
[
|
|
333
|
-
"local",
|
|
334
|
-
server.resolvedUrls?.local?.[0] ?? `http://${options.host}:${options.port}/`,
|
|
335
|
-
"info"
|
|
336
|
-
],
|
|
337
|
-
...(server.resolvedUrls?.network ?? []).map((url) => [
|
|
338
|
-
"network",
|
|
339
|
-
url,
|
|
340
|
-
"info"
|
|
341
|
-
]),
|
|
342
|
-
[
|
|
343
|
-
"mode",
|
|
344
|
-
options.mode,
|
|
345
|
-
options.mode === "loopback" ? "success" : "warning"
|
|
346
|
-
],
|
|
347
|
-
["workspace", options.workspace, "muted"],
|
|
348
|
-
[
|
|
349
|
-
"sessions",
|
|
350
|
-
status.sessions === 1 ? "1 open" : `${status.sessions} open`,
|
|
351
|
-
"text"
|
|
352
|
-
],
|
|
353
|
-
["platform", status.platform, status.connected ? "success" : "warning"],
|
|
354
|
-
["agents", status.agents, status.hasAgents ? "success" : "warning"],
|
|
355
|
-
["reload", "TSRX \xB7 TypeScript \xB7 CSS", "info"],
|
|
356
|
-
[
|
|
357
|
-
"diagnostics",
|
|
358
|
-
options.verbose ? "verbose" : "quiet \xB7 use --verbose",
|
|
359
|
-
options.verbose ? "warning" : "muted"
|
|
360
|
-
]
|
|
361
|
-
]
|
|
362
|
-
});
|
|
363
|
-
watchReloads(server, appRoot, useColor);
|
|
364
|
-
const close = async () => {
|
|
365
|
-
console.log(`
|
|
366
|
-
${formatDevEvent("process", "Sandbox stopped.", useColor)}`);
|
|
367
|
-
await server.close();
|
|
368
|
-
restoreConsole();
|
|
369
|
-
process2.exit(0);
|
|
370
|
-
};
|
|
371
|
-
process2.once("SIGINT", () => void close());
|
|
372
|
-
process2.once("SIGTERM", () => void close());
|
|
373
|
-
return server;
|
|
374
|
-
}
|
|
375
|
-
if (process2.argv[1] && resolve(process2.argv[1]) === fileURLToPath(import.meta.url)) {
|
|
376
|
-
startSandbox().catch((error) => {
|
|
377
|
-
console.error(
|
|
378
|
-
formatDevEvent(
|
|
379
|
-
"error",
|
|
380
|
-
error instanceof Error ? error.message : String(error)
|
|
381
|
-
)
|
|
382
|
-
);
|
|
383
|
-
if (process2.argv.includes("--verbose") && error instanceof Error) {
|
|
384
|
-
console.error(error.stack);
|
|
385
|
-
}
|
|
386
|
-
process2.exitCode = 1;
|
|
387
|
-
});
|
|
388
|
-
}
|
|
389
|
-
export {
|
|
390
|
-
isLoopbackHost,
|
|
391
|
-
parseSandboxArguments,
|
|
392
|
-
startSandbox
|
|
393
|
-
};
|