@fased/fased 0.1.9 → 0.1.10
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/dist/{agents-C4jz1huI.js → agents-CsxQP5xg.js} +8 -8
- package/dist/{attachment-normalize-C-VpVpLd.js → attachment-normalize-CSxeaVcP.js} +1 -1
- package/dist/{attachment-normalize-DijgHIHy.js → attachment-normalize-f9lQXrZo.js} +1 -1
- package/dist/{audio-preflight-CI7BIPwS.js → audio-preflight-BeJd4YPQ.js} +2 -2
- package/dist/{audio-preflight-U5m63Clr.js → audio-preflight-CVU3GLti.js} +2 -2
- package/dist/{audio-preflight-oqlL2Kux.js → audio-preflight-C_g_wQAc.js} +1 -1
- package/dist/{audio-preflight-C6Lb4XU1.js → audio-preflight-DBtzpOL_.js} +1 -1
- package/dist/{audio-preflight-DLGJBu9O.js → audio-preflight-DD1zXhwM.js} +2 -2
- package/dist/{audit-DwbVJt3i.js → audit-BB2lDlNb.js} +1 -1
- package/dist/{audit-BCtx-_dH.js → audit-CDgqnjys.js} +1 -1
- package/dist/{auth-DIBzLQ-S.js → auth-Bfgwy6TQ.js} +5 -5
- package/dist/{auth-choice-CEeiz47B.js → auth-choice-DbEAsUsi.js} +1 -1
- package/dist/{auth-choice-DOqXUqF_.js → auth-choice-DlcbJgp_.js} +1 -1
- package/dist/{auth-choice-prompt-yqlvFI-_.js → auth-choice-prompt-CcOEzXoi.js} +1 -1
- package/dist/{auth-choice-prompt-FJDk83bS.js → auth-choice-prompt-DMlwK9kF.js} +1 -1
- package/dist/build-info.json +3 -3
- package/dist/bundled/boot-md/handler.js +1 -1
- package/dist/bundled/session-memory/handler.js +1 -1
- package/dist/canvas-host/a2ui/.bundle.hash +1 -1
- package/dist/{channel-web-CBfPvCCy.js → channel-web-CMZFjZzU.js} +1 -1
- package/dist/{channel-web-DaircVlX.js → channel-web-qHKfuCHE.js} +1 -1
- package/dist/{channels-BygboZOV.js → channels-BoOF2dAy.js} +6 -6
- package/dist/{channels-DgozxTBh.js → channels-DvT6s1kl.js} +6 -6
- package/dist/{channels-cli-DNz7gmOI.js → channels-cli-CNhEFKbn.js} +5 -5
- package/dist/{channels-cli-CY4n5HcO.js → channels-cli-NoUnbEgC.js} +5 -5
- package/dist/cli/daemon-cli.js +1 -1
- package/dist/{cli-CFgX3wef.js → cli-CE8pVYeA.js} +2 -2
- package/dist/{cli-63C0cETT.js → cli-Ctvy4-cz.js} +2 -2
- package/dist/{command-registry-DEiX9EPg.js → command-registry-fqlYdOTI.js} +9 -9
- package/dist/{completion-cli-CRwAyWQL.js → completion-cli-Bd9iPo4A.js} +1 -1
- package/dist/{completion-cli-BzQetGgr.js → completion-cli-CKzB1lB1.js} +2 -2
- package/dist/{config-cli-CPl1vPz0.js → config-cli-CQpqSVFS.js} +1 -1
- package/dist/{config-cli-C7vsh8Fg.js → config-cli-DUNkddbL.js} +1 -1
- package/dist/{configure-BEI_pe6B.js → configure-B2WT8-lE.js} +12 -12
- package/dist/{configure-C8lxNKpB.js → configure-DxDNasaD.js} +12 -12
- package/dist/control-ui/assets/app-wpJSg6bV.js.map +1 -1
- package/dist/{cron-cli-BqD_ZSEC.js → cron-cli-D3Dznk0V.js} +2 -2
- package/dist/{cron-cli-C7i4-Whp.js → cron-cli-DYWW7cv1.js} +2 -2
- package/dist/{daemon-cli-DFYzYoB8.js → daemon-cli-DDUjmEow.js} +1 -1
- package/dist/{daemon-cli-D0AP3mOg.js → daemon-cli-DFjCvbUo.js} +1 -1
- package/dist/daemon-cli.js +1 -1
- package/dist/{deps-D9aJvXyD.js → deps-4rCQ5SBd.js} +1 -1
- package/dist/{deps-ddWLkZAO.js → deps-CBapZnsi.js} +1 -1
- package/dist/entry.js +1 -1
- package/dist/extensionAPI.js +2 -2
- package/dist/{gateway-cli-D_Yd_yWi.js → gateway-cli-BXl9lmch.js} +27 -27
- package/dist/{gateway-cli-BJkYYsGs.js → gateway-cli-CNCA_gcT.js} +27 -27
- package/dist/{health-DCFLGVDU.js → health-C_g99tp_.js} +2 -2
- package/dist/{health-gyJixAyN.js → health-DTTfLYjl.js} +2 -2
- package/dist/{heartbeat-runner-Bn9N5npL.js → heartbeat-runner-D04n14H-.js} +1 -1
- package/dist/{heartbeat-runner-BFUvc4Y_.js → heartbeat-runner-DXh84Wuy.js} +1 -1
- package/dist/{hooks-cli-CGj2FDai.js → hooks-cli-BDpBNlPV.js} +3 -3
- package/dist/{hooks-cli-BGFJQWmK.js → hooks-cli-FhVd5CE-.js} +3 -3
- package/dist/index.js +7 -7
- package/dist/{ipv4-CjO0_Ry3.js → ipv4-Citn8Cno.js} +2 -2
- package/dist/{ipv4-CBSPFYQB.js → ipv4-P47TSJIK.js} +2 -2
- package/dist/{lifecycle-DFvIF7r0.js → lifecycle-B4RibYD4.js} +1 -1
- package/dist/{lifecycle-BBNnNoX_.js → lifecycle-Bgh3V8Jt.js} +1 -1
- package/dist/{list.auth-overview-DySKd1cu.js → list.auth-overview-BQzrIpgk.js} +1 -1
- package/dist/{list.auth-overview-CpmtoN2D.js → list.auth-overview-fBVXihg0.js} +1 -1
- package/dist/llm-slug-generator.js +1 -1
- package/dist/{model-catalog-DfLJlqO8.js → model-catalog-B2mRe6cZ.js} +6 -6
- package/dist/{models-BbfLyMBF.js → models-D8MTK6SG.js} +4 -4
- package/dist/{models-cli-Bu09lWlb.js → models-cli-Bl8xk6-0.js} +4 -4
- package/dist/{models-cli-DpmciZv6.js → models-cli-CXdCnyks.js} +5 -5
- package/dist/{node-cli-D6iG4Fev.js → node-cli-Cqh8buCU.js} +2 -2
- package/dist/{node-cli-GbiqR_FY.js → node-cli-DkgKrYS1.js} +2 -2
- package/dist/{onboard-BgU-rNfl.js → onboard-BD0MOrv7.js} +6 -6
- package/dist/{onboard-CViA2g_j.js → onboard-Dz8z4vBi.js} +6 -6
- package/dist/{onboard-channels-gHaSwzTd.js → onboard-channels-CPh2EJOi.js} +2 -2
- package/dist/{onboard-channels-BeKekf-a.js → onboard-channels-DUa2qkms.js} +2 -2
- package/dist/{onboard-search-DkOnHZm9.js → onboard-search-BnHMgV2k.js} +5 -5
- package/dist/{onboard-search-COuzKj6_.js → onboard-search-CqiDzWQw.js} +5 -5
- package/dist/{onboarding-CowfhJUD.js → onboarding-BC-5Pv9o.js} +7 -7
- package/dist/{onboarding-nabyJljA.js → onboarding-DgTB_zq7.js} +7 -7
- package/dist/{openresponses-http-D42SXipZ.js → openresponses-http-BQa9rI-N.js} +1 -1
- package/dist/{openresponses-http-C66CR36w.js → openresponses-http-BYiaPg-e.js} +2 -2
- package/dist/{openresponses-http-CdO4hFg_.js → openresponses-http-BirGBJTm.js} +2 -2
- package/dist/{openresponses-http-One5KNo8.js → openresponses-http-BsQmM8zM.js} +1 -1
- package/dist/{openresponses-http-BBydvP41.js → openresponses-http-CcawkBY4.js} +2 -2
- package/dist/{parent-default-help-82dOtJ5b.js → parent-default-help-CpfuGajV.js} +1 -1
- package/dist/{parent-default-help-iR__S_d8.js → parent-default-help-DbMf7NQe.js} +1 -1
- package/dist/{paths-Dwg5yVao.js → paths-BxKqczZV.js} +9 -9
- package/dist/{pi-embedded-BqhMzKsb.js → pi-embedded-Bapdl5Mb.js} +5 -5
- package/dist/{pi-embedded-DLEbV2ey.js → pi-embedded-DlBsi5bC.js} +14 -14
- package/dist/{plugin-registry-DgLnDYKc.js → plugin-registry-2aqMgXpl.js} +1 -1
- package/dist/{plugin-registry-DgnprUWu.js → plugin-registry-C7oTQytM.js} +1 -1
- package/dist/plugin-sdk/{audio-preflight-bl33qm06.js → audio-preflight-BbjERcpR.js} +1 -1
- package/dist/plugin-sdk/{audio-preflight-B3yRlgpY.js → audio-preflight-Vg4EuYfg.js} +1 -1
- package/dist/plugin-sdk/channel-plugin-common.js +1 -1
- package/dist/plugin-sdk/{channel-web-BmhttJUt.js → channel-web-JBsCrpEe.js} +1 -1
- package/dist/plugin-sdk/command-status.js +1 -1
- package/dist/plugin-sdk/index.js +2 -2
- package/dist/plugin-sdk/{openresponses-http-BkfMH5vT.js → openresponses-http-dj-a8V7Z.js} +1 -1
- package/dist/plugin-sdk/{openresponses-http-DVsmkLyj.js → openresponses-http-ihpGpya5.js} +1 -1
- package/dist/plugin-sdk/{pi-model-discovery-runtime-Cv_H-NDs.js → pi-model-discovery-runtime-CddkbYKA.js} +1 -1
- package/dist/plugin-sdk/{registry-Dpq_OloZ.js → registry-BhjWgT6A.js} +8 -8
- package/dist/plugin-sdk/{reply-ceu7kXX1.js → reply-CvmqbVx1.js} +5 -5
- package/dist/plugin-sdk/src/brand.d.ts +2 -2
- package/dist/plugin-sdk/{status-BcZw5R2P.js → status-DsTgMPSP.js} +5 -5
- package/dist/plugin-sdk/{web-DE0yQyjF.js → web-CLXmBst6.js} +1 -1
- package/dist/plugin-sdk/{web-D_ze88LT.js → web-DHSHEbWK.js} +2 -2
- package/dist/{plugins-cli-gUow1y1s.js → plugins-cli-CXa9m7-A.js} +5 -5
- package/dist/{plugins-cli-Bw8rkcLm.js → plugins-cli-Dj-p00ob.js} +5 -5
- package/dist/{program-D7MpzAVA.js → program-B3cXsVO0.js} +7 -7
- package/dist/{program-context-BnMmmcLR.js → program-context-Di7qiwOM.js} +24 -24
- package/dist/{prompt-select-styled-CZx9cLwR.js → prompt-select-styled-8KBIPNro.js} +4 -4
- package/dist/{prompt-select-styled-DEZExK7l.js → prompt-select-styled-C5o0Ff06.js} +4 -4
- package/dist/{pw-ai-Cjyb5RBL.js → pw-ai-BzOzOwqG.js} +1 -1
- package/dist/{register.agent-B9A7SDz_.js → register.agent-BYkIkPHf.js} +8 -8
- package/dist/{register.agent-DlatKWlA.js → register.agent-ll5ykI9x.js} +9 -9
- package/dist/{register.configure-Tez2eNbW.js → register.configure-C0GU1zbA.js} +12 -12
- package/dist/{register.configure-yNuOFQX6.js → register.configure-DubkYh7h.js} +12 -12
- package/dist/{register.maintenance-Q6YI5mk9.js → register.maintenance-Corgqhj5.js} +8 -8
- package/dist/{register.maintenance-BzVw1_e5.js → register.maintenance-Pz6desR4.js} +9 -9
- package/dist/{register.message-Cda69Xe6.js → register.message-COK8wYD_.js} +3 -3
- package/dist/{register.message-D9LYOvON.js → register.message-oi2ewJpl.js} +3 -3
- package/dist/{register.onboard-D1a2rQDh.js → register.onboard-C7ysxMn6.js} +14 -14
- package/dist/{register.onboard-BoLP06ui.js → register.onboard-zwRY0Dsh.js} +14 -14
- package/dist/{register.setup-DhppZhR2.js → register.setup-B1YGF1bz.js} +14 -14
- package/dist/{register.setup-D_qD7Gvk.js → register.setup-J2tUgD6C.js} +14 -14
- package/dist/{register.status-health-sessions-Csah3svc.js → register.status-health-sessions-DCazjMZa.js} +6 -6
- package/dist/{register.status-health-sessions-C0IsjCxS.js → register.status-health-sessions-DmjjMrJZ.js} +6 -6
- package/dist/{register.subclis-C4Dh6aQK.js → register.subclis-Bj8pFyAT.js} +16 -16
- package/dist/{reply-C3PsVpeQ.js → reply-DQfPM5ia.js} +6 -6
- package/dist/{run-main-XXpwNNGn.js → run-main-Cf6N-U3j.js} +14 -14
- package/dist/{runtime-helper-grants-BTCk3CzW.js → runtime-helper-grants-DONSfqWx.js} +1 -1
- package/dist/{runtime-helper-grants-C10OJEih.js → runtime-helper-grants-DzP6dgWv.js} +1 -1
- package/dist/{sandbox-cli-2MuBwFbv.js → sandbox-cli-CqUHfq55.js} +2 -2
- package/dist/{sandbox-cli-Bft002rK.js → sandbox-cli-DHHAXWD8.js} +2 -2
- package/dist/{security-cli-6CmGeQ7I.js → security-cli-CAEEYR8C.js} +3 -3
- package/dist/{security-cli-DpQep_pt.js → security-cli-DNlCSlQR.js} +3 -3
- package/dist/{server-OidOCKoj.js → server-B67PKank.js} +2 -2
- package/dist/{server-D62kYBqw.js → server-RYyJ2HTj.js} +2 -2
- package/dist/{server-cron-DYKXfeLU.js → server-cron-D7rN6EY6.js} +2 -2
- package/dist/{server-cron--g6K0O5V.js → server-cron-V9GBrg1S.js} +2 -2
- package/dist/{server-node-events-DSvH0zky.js → server-node-events-CAG2ic6e.js} +3 -3
- package/dist/{server-node-events-Csbl1Sw5.js → server-node-events-eh5LuLg6.js} +3 -3
- package/dist/{status-CEqTBWFX.js → status-BuGyo-1M.js} +4 -4
- package/dist/{status-cY8_nNEN.js → status-CTveTSuF.js} +1 -1
- package/dist/{status-DDWMOp5e.js → status-DIkbKBxH.js} +4 -4
- package/dist/{status-e52jwOFE.js → status-jb8w0SwX.js} +1 -1
- package/dist/{tui-K3OJBQvo.js → tui-Dinku0o-.js} +1 -1
- package/dist/{tui-cli-DEHMUby1.js → tui-cli-dq7xafwR.js} +3 -3
- package/dist/{tui-cli-CNL0cM4e.js → tui-cli-z5WV3SVg.js} +3 -3
- package/dist/{tui-B5xfA4bO.js → tui-lmdDZi6Y.js} +1 -1
- package/dist/{update-cli-BqiZ9j4m.js → update-cli-BdQ3mRGs.js} +10 -10
- package/dist/{update-cli-Cr7BTqe1.js → update-cli-Cq47v0X_.js} +9 -9
- package/dist/{update-runner-CycjY65W.js → update-runner-BnRMhKva.js} +1 -1
- package/dist/{update-runner-DcpjVgBR.js → update-runner-C0SU1jGT.js} +1 -1
- package/dist/{web-CLOmxVxX.js → web-B9YrSF5u.js} +2 -2
- package/dist/{web-6MnkoZyD.js → web-BmjUKJI0.js} +3 -3
- package/dist/{web-ChgN9rvX.js → web-D9wmjTDC.js} +3 -3
- package/dist/{web-D6CU81WZ.js → web-DaMiLN7K.js} +1 -1
- package/dist/{web-DhwWGdvc.js → web-sBExtZCA.js} +1 -1
- package/dist/{web-search-providers.runtime-D-uepqZ5.js → web-search-providers.runtime-TGCiBzhv.js} +1 -1
- package/dist/{web-search-providers.runtime-u6_OyUd6.js → web-search-providers.runtime-gM-8LIxg.js} +1 -1
- package/package.json +3 -1
- package/scripts/run-node.mjs +294 -0
- package/scripts/start-managed.sh +1528 -0
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { spawn, spawnSync } from "node:child_process";
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import process from "node:process";
|
|
6
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
7
|
+
|
|
8
|
+
const compiler = "tsdown";
|
|
9
|
+
const compilerArgs = ["exec", compiler, "--no-clean"];
|
|
10
|
+
|
|
11
|
+
export const runNodeWatchedPaths = ["src", "extensions", "tsconfig.json", "package.json"];
|
|
12
|
+
const scriptDir = path.dirname(fileURLToPath(import.meta.url));
|
|
13
|
+
const defaultRunnerCwd = path.resolve(scriptDir, "..");
|
|
14
|
+
|
|
15
|
+
const statMtime = (filePath, fsImpl = fs) => {
|
|
16
|
+
try {
|
|
17
|
+
return fsImpl.statSync(filePath).mtimeMs;
|
|
18
|
+
} catch {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const isExcludedSource = (filePath, srcRoot) => {
|
|
24
|
+
const relativePath = path.relative(srcRoot, filePath);
|
|
25
|
+
if (relativePath.startsWith("..")) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
return (
|
|
29
|
+
relativePath.endsWith(".test.ts") ||
|
|
30
|
+
relativePath.endsWith(".test.tsx") ||
|
|
31
|
+
relativePath.endsWith(`test-helpers.ts`)
|
|
32
|
+
);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const findLatestMtime = (dirPath, shouldSkip, deps) => {
|
|
36
|
+
let latest = null;
|
|
37
|
+
const queue = [dirPath];
|
|
38
|
+
while (queue.length > 0) {
|
|
39
|
+
const current = queue.pop();
|
|
40
|
+
if (!current) {
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
let entries = [];
|
|
44
|
+
try {
|
|
45
|
+
entries = deps.fs.readdirSync(current, { withFileTypes: true });
|
|
46
|
+
} catch {
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
for (const entry of entries) {
|
|
50
|
+
const fullPath = path.join(current, entry.name);
|
|
51
|
+
if (entry.isDirectory()) {
|
|
52
|
+
queue.push(fullPath);
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
if (!entry.isFile()) {
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
if (shouldSkip?.(fullPath)) {
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
const mtime = statMtime(fullPath, deps.fs);
|
|
62
|
+
if (mtime == null) {
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
if (latest == null || mtime > latest) {
|
|
66
|
+
latest = mtime;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return latest;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const runGit = (gitArgs, deps) => {
|
|
74
|
+
try {
|
|
75
|
+
const result = deps.spawnSync("git", gitArgs, {
|
|
76
|
+
cwd: deps.cwd,
|
|
77
|
+
encoding: "utf8",
|
|
78
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
79
|
+
});
|
|
80
|
+
if (result.status !== 0) {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
return (result.stdout ?? "").trim();
|
|
84
|
+
} catch {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const resolveGitHead = (deps) => {
|
|
90
|
+
const head = runGit(["rev-parse", "HEAD"], deps);
|
|
91
|
+
return head || null;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const hasDirtySourceTree = (deps) => {
|
|
95
|
+
const output = runGit(
|
|
96
|
+
["status", "--porcelain", "--untracked-files=normal", "--", ...runNodeWatchedPaths],
|
|
97
|
+
deps,
|
|
98
|
+
);
|
|
99
|
+
if (output === null) {
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
return output.length > 0;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
const readBuildStamp = (deps) => {
|
|
106
|
+
const mtime = statMtime(deps.buildStampPath, deps.fs);
|
|
107
|
+
if (mtime == null) {
|
|
108
|
+
return { mtime: null, head: null };
|
|
109
|
+
}
|
|
110
|
+
try {
|
|
111
|
+
const raw = deps.fs.readFileSync(deps.buildStampPath, "utf8").trim();
|
|
112
|
+
if (!raw.startsWith("{")) {
|
|
113
|
+
return { mtime, head: null };
|
|
114
|
+
}
|
|
115
|
+
const parsed = JSON.parse(raw);
|
|
116
|
+
const head = typeof parsed?.head === "string" && parsed.head.trim() ? parsed.head.trim() : null;
|
|
117
|
+
return { mtime, head };
|
|
118
|
+
} catch {
|
|
119
|
+
return { mtime, head: null };
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
const findLatestWatchedMtime = (deps) => {
|
|
124
|
+
let latest = null;
|
|
125
|
+
for (const watchedPath of runNodeWatchedPaths) {
|
|
126
|
+
const fullPath = path.join(deps.cwd, watchedPath);
|
|
127
|
+
let stat = null;
|
|
128
|
+
try {
|
|
129
|
+
stat = deps.fs.statSync(fullPath);
|
|
130
|
+
} catch {
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
const mtime = stat.isDirectory()
|
|
134
|
+
? findLatestMtime(fullPath, (candidate) => isExcludedSource(candidate, fullPath), deps)
|
|
135
|
+
: stat.mtimeMs;
|
|
136
|
+
if (mtime == null) {
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
if (latest == null || mtime > latest) {
|
|
140
|
+
latest = mtime;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return latest;
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
const hasWatchedMtimeChanged = (stampMtime, deps) => {
|
|
147
|
+
const watchedMtime = findLatestWatchedMtime(deps);
|
|
148
|
+
return watchedMtime != null && watchedMtime > stampMtime;
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
const shouldBuild = (deps) => {
|
|
152
|
+
if (deps.env.FASED_SKIP_BUILD === "1") {
|
|
153
|
+
return false;
|
|
154
|
+
}
|
|
155
|
+
if (deps.env.FASED_FORCE_BUILD === "1") {
|
|
156
|
+
return true;
|
|
157
|
+
}
|
|
158
|
+
const stamp = readBuildStamp(deps);
|
|
159
|
+
if (stamp.mtime == null) {
|
|
160
|
+
return true;
|
|
161
|
+
}
|
|
162
|
+
if (statMtime(deps.distEntry, deps.fs) == null) {
|
|
163
|
+
return true;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
for (const filePath of deps.configFiles) {
|
|
167
|
+
const mtime = statMtime(filePath, deps.fs);
|
|
168
|
+
if (mtime != null && mtime > stamp.mtime) {
|
|
169
|
+
return true;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const currentHead = resolveGitHead(deps);
|
|
174
|
+
if (currentHead && !stamp.head) {
|
|
175
|
+
return hasWatchedMtimeChanged(stamp.mtime, deps);
|
|
176
|
+
}
|
|
177
|
+
if (currentHead && stamp.head && currentHead !== stamp.head) {
|
|
178
|
+
return hasWatchedMtimeChanged(stamp.mtime, deps);
|
|
179
|
+
}
|
|
180
|
+
if (currentHead) {
|
|
181
|
+
const dirty = hasDirtySourceTree(deps);
|
|
182
|
+
if (dirty === true) {
|
|
183
|
+
return hasWatchedMtimeChanged(stamp.mtime, deps);
|
|
184
|
+
}
|
|
185
|
+
if (dirty === false) {
|
|
186
|
+
return false;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
if (hasWatchedMtimeChanged(stamp.mtime, deps)) {
|
|
191
|
+
return true;
|
|
192
|
+
}
|
|
193
|
+
return false;
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
const logRunner = (message, deps) => {
|
|
197
|
+
if (deps.env.FASED_RUNNER_LOG === "0") {
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
deps.stderr.write(`[fased] ${message}\n`);
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
const shouldUseJsonOnlyOutput = (args) => args.includes("--json");
|
|
204
|
+
|
|
205
|
+
const runFasedAgent = async (deps) => {
|
|
206
|
+
const nodeProcess = deps.spawn(deps.execPath, ["fased.mjs", ...deps.args], {
|
|
207
|
+
cwd: deps.cwd,
|
|
208
|
+
env: deps.env,
|
|
209
|
+
stdio: "inherit",
|
|
210
|
+
});
|
|
211
|
+
const res = await new Promise((resolve) => {
|
|
212
|
+
nodeProcess.on("exit", (exitCode, exitSignal) => {
|
|
213
|
+
resolve({ exitCode, exitSignal });
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
if (res.exitSignal) {
|
|
217
|
+
return 1;
|
|
218
|
+
}
|
|
219
|
+
return res.exitCode ?? 1;
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
const writeBuildStamp = (deps) => {
|
|
223
|
+
try {
|
|
224
|
+
deps.fs.mkdirSync(deps.distRoot, { recursive: true });
|
|
225
|
+
const stamp = {
|
|
226
|
+
builtAt: Date.now(),
|
|
227
|
+
head: resolveGitHead(deps),
|
|
228
|
+
};
|
|
229
|
+
deps.fs.writeFileSync(deps.buildStampPath, `${JSON.stringify(stamp)}\n`);
|
|
230
|
+
} catch (error) {
|
|
231
|
+
// Best-effort stamp; still allow the runner to start.
|
|
232
|
+
logRunner(`Failed to write build stamp: ${error?.message ?? "unknown error"}`, deps);
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
export async function runNodeMain(params = {}) {
|
|
237
|
+
const deps = {
|
|
238
|
+
spawn: params.spawn ?? spawn,
|
|
239
|
+
spawnSync: params.spawnSync ?? spawnSync,
|
|
240
|
+
fs: params.fs ?? fs,
|
|
241
|
+
stderr: params.stderr ?? process.stderr,
|
|
242
|
+
execPath: params.execPath ?? process.execPath,
|
|
243
|
+
cwd: params.cwd ?? defaultRunnerCwd,
|
|
244
|
+
args: params.args ?? process.argv.slice(2),
|
|
245
|
+
env: params.env ? { ...params.env } : { ...process.env },
|
|
246
|
+
platform: params.platform ?? process.platform,
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
deps.distRoot = path.join(deps.cwd, "dist");
|
|
250
|
+
deps.distEntry = path.join(deps.distRoot, "/entry.js");
|
|
251
|
+
deps.buildStampPath = path.join(deps.distRoot, ".buildstamp");
|
|
252
|
+
deps.srcRoot = path.join(deps.cwd, "src");
|
|
253
|
+
deps.configFiles = [path.join(deps.cwd, "tsconfig.json"), path.join(deps.cwd, "package.json")];
|
|
254
|
+
|
|
255
|
+
if (!shouldBuild(deps)) {
|
|
256
|
+
return await runFasedAgent(deps);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
logRunner("Building TypeScript (dist is stale).", deps);
|
|
260
|
+
const buildCmd = deps.platform === "win32" ? "cmd.exe" : "pnpm";
|
|
261
|
+
const buildArgs =
|
|
262
|
+
deps.platform === "win32" ? ["/d", "/s", "/c", "pnpm", ...compilerArgs] : compilerArgs;
|
|
263
|
+
const buildStdio = shouldUseJsonOnlyOutput(deps.args) ? ["ignore", "pipe", "pipe"] : "inherit";
|
|
264
|
+
const build = deps.spawn(buildCmd, buildArgs, {
|
|
265
|
+
cwd: deps.cwd,
|
|
266
|
+
env: deps.env,
|
|
267
|
+
stdio: buildStdio,
|
|
268
|
+
});
|
|
269
|
+
if (buildStdio !== "inherit") {
|
|
270
|
+
build.stdout?.on("data", (chunk) => deps.stderr.write(chunk));
|
|
271
|
+
build.stderr?.on("data", (chunk) => deps.stderr.write(chunk));
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
const buildRes = await new Promise((resolve) => {
|
|
275
|
+
build.on("exit", (exitCode, exitSignal) => resolve({ exitCode, exitSignal }));
|
|
276
|
+
});
|
|
277
|
+
if (buildRes.exitSignal) {
|
|
278
|
+
return 1;
|
|
279
|
+
}
|
|
280
|
+
if (buildRes.exitCode !== 0 && buildRes.exitCode !== null) {
|
|
281
|
+
return buildRes.exitCode;
|
|
282
|
+
}
|
|
283
|
+
writeBuildStamp(deps);
|
|
284
|
+
return await runFasedAgent(deps);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
if (import.meta.url === pathToFileURL(process.argv[1] ?? "").href) {
|
|
288
|
+
void runNodeMain()
|
|
289
|
+
.then((code) => process.exit(code))
|
|
290
|
+
.catch((err) => {
|
|
291
|
+
console.error(err);
|
|
292
|
+
process.exit(1);
|
|
293
|
+
});
|
|
294
|
+
}
|