@lunora/config 1.0.0-alpha.8 → 1.0.0-alpha.80
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.md +6 -0
- package/__assets__/package-og.svg +1 -1
- package/dist/index.d.mts +885 -461
- package/dist/index.d.ts +885 -461
- package/dist/index.mjs +17 -9
- package/dist/packem_shared/AGENT_MODE_ENV-B5R7jpY7.mjs +17 -0
- package/dist/packem_shared/DEV_DAEMON_ENV-FIEtW7Fz.mjs +163 -0
- package/dist/packem_shared/{LUNORA_EVENT_SOURCE-D2fDeGB6.mjs → LUNORA_EVENT_SOURCE-M1KM9_pR.mjs} +28 -2
- package/dist/packem_shared/PACKAGE_SECRETS_REGISTRY-NCTSphDk.mjs +138 -0
- package/dist/packem_shared/{POLICY_SCAFFOLD_ENDPOINT-CiC2IGKx.mjs → POLICY_SCAFFOLD_ENDPOINT-CvTZpaZF.mjs} +7 -10
- package/dist/packem_shared/{REMOTE_ELIGIBLE_KEYS-BC7_e9Bz.mjs → REMOTE_ELIGIBLE_KEYS-C-F_Flgy.mjs} +1 -6
- package/dist/packem_shared/{REQUIRED_COMPATIBILITY_DATE-DRSNSOOp.mjs → REQUIRED_COMPATIBILITY_DATE-DP0SFVy9.mjs} +134 -3
- package/dist/packem_shared/{SCHEMA_EDIT_ENDPOINT-Df-Wrix-.mjs → SCHEMA_EDIT_ENDPOINT-Bt2SNkpV.mjs} +4 -8
- package/dist/packem_shared/{SEED_ENDPOINT-DVCjaGO-.mjs → SEED_ENDPOINT-7izz_Jao.mjs} +1 -1
- package/dist/packem_shared/WORKERS_CACHE_MIN_DATE-CaXbS7CX.mjs +11 -0
- package/dist/packem_shared/assetContentType-ByZjeV3D.mjs +72 -0
- package/dist/packem_shared/{buildPackageSecretsBlock-S74dgmwy.mjs → buildPackageSecretsBlock-BxOcyaAY.mjs} +115 -21
- package/dist/packem_shared/collectWranglerSecretVariables-BRWIvT-e.mjs +56 -0
- package/dist/packem_shared/{createConfirm-fvpdgJ9s.mjs → createConfirm-BMikeJC9.mjs} +22 -5
- package/dist/packem_shared/{detectFramework-Br-BcPBq.mjs → detectFramework-U08038Yp.mjs} +3 -3
- package/dist/packem_shared/discoverAgentInfo-eXA3hF4v.mjs +19 -0
- package/dist/packem_shared/{inferLunoraBindings-DIku9mTN.mjs → inferLunoraBindings-BcvvtpSG.mjs} +145 -50
- package/dist/packem_shared/jsonc-edit-SbcD7MAe.mjs +9 -0
- package/dist/packem_shared/parseDevVariable-B0FEvfHC.mjs +21 -0
- package/dist/packem_shared/{policy-scaffold.d-DCmwn7zQ.d.ts → policy-scaffold.d-CFd2FlqG.d.mts} +22 -22
- package/dist/packem_shared/{policy-scaffold.d-DCmwn7zQ.d.mts → policy-scaffold.d-CFd2FlqG.d.ts} +22 -22
- package/dist/packem_shared/{reconcileWranglerBindings-DTHmqTbL.mjs → reconcileWranglerBindings-2Cww5VLa.mjs} +114 -29
- package/dist/packem_shared/reconcileWranglerCompatibilityDate-C8c497ag.mjs +31 -0
- package/dist/packem_shared/reconcileWranglerCrons-DvsceVFz.mjs +29 -0
- package/dist/packem_shared/{serveJsonHandler-B4OLTGLS.mjs → serveJsonHandler-Cl2Wqkv8.mjs} +2 -2
- package/dist/packem_shared/streamContainerLogs-BZ4cOZwH.mjs +157 -0
- package/dist/packem_shared/write-atomic-B2REqapi.mjs +14 -0
- package/dist/studio-host/index.d.mts +134 -92
- package/dist/studio-host/index.d.ts +134 -92
- package/dist/studio-host/index.mjs +6 -6
- package/package.json +11 -8
- package/dist/packem_shared/PACKAGE_SECRETS_REGISTRY-CySy5vR_.mjs +0 -62
- package/dist/packem_shared/loadStudioAssets-Csk5RS4E.mjs +0 -28
- package/dist/packem_shared/parseDevVariable-CJiq2IwE.mjs +0 -30
package/dist/index.mjs
CHANGED
|
@@ -1,22 +1,30 @@
|
|
|
1
|
+
export { AGENT_MODE_ENV, detectAiAgent } from './packem_shared/AGENT_MODE_ENV-B5R7jpY7.mjs';
|
|
2
|
+
export { discoverAgentInfo } from './packem_shared/discoverAgentInfo-eXA3hF4v.mjs';
|
|
1
3
|
export { AGENT_RULES_DIR, AGENT_RULES_HINT, AGENT_RULES_HINT_ENV, LUNORA_SKILL_NAMES, ROOT_SKILL_NAME, claimAgentRulesHint, detectAgentRules } from './packem_shared/AGENT_RULES_DIR-lcgC08aE.mjs';
|
|
2
4
|
export { discoverContainerInfo } from './packem_shared/discoverContainerInfo-BXFs6Wav.mjs';
|
|
3
|
-
export {
|
|
5
|
+
export { streamContainerLogs } from './packem_shared/streamContainerLogs-BZ4cOZwH.mjs';
|
|
6
|
+
export { detectFramework, readProjectDependencyNames } from './packem_shared/detectFramework-U08038Yp.mjs';
|
|
7
|
+
export { DEV_DAEMON_ENV, DEV_HANDOFF_ENV, DEV_LOG_FILE, DEV_LOG_FILE_ENV, DEV_STATE_DIR, DEV_STATE_FILE, claimDevServerState, clearDevServerState, isProcessAlive, isRecordedProcessCurrent, readDevServerState, readLiveDevServerState, updateDevServerState, writeDevServerState } from './packem_shared/DEV_DAEMON_ENV-FIEtW7Fz.mjs';
|
|
4
8
|
export { DEV_VARS_EXAMPLE_FILE, DEV_VARS_FILE, DEV_VARS_KEY_PATTERN, parseDevVariableEntries } from './packem_shared/DEV_VARS_EXAMPLE_FILE-dJPNTEnK.mjs';
|
|
5
|
-
export { inferLunoraBindings, packageNamesFromBindings } from './packem_shared/inferLunoraBindings-
|
|
9
|
+
export { inferLunoraBindings, packageNamesFromBindings } from './packem_shared/inferLunoraBindings-BcvvtpSG.mjs';
|
|
6
10
|
export { LINKED_PROJECT_DIR, LINKED_PROJECT_FILE, readLinkedProject, writeLinkedProject } from './packem_shared/LINKED_PROJECT_DIR-CXwXzV_C.mjs';
|
|
7
|
-
export { LUNORA_EVENT_SOURCE, formatLunoraEvent } from './packem_shared/LUNORA_EVENT_SOURCE-
|
|
11
|
+
export { LUNORA_EVENT_SOURCE, formatLunoraEvent } from './packem_shared/LUNORA_EVENT_SOURCE-M1KM9_pR.mjs';
|
|
8
12
|
export { default as LunoraReporter } from './packem_shared/LunoraReporter-Ci-bDCK9.mjs';
|
|
9
|
-
export { PACKAGE_SECRETS_REGISTRY, secretsForPackages } from './packem_shared/PACKAGE_SECRETS_REGISTRY-
|
|
13
|
+
export { PACKAGE_SECRETS_REGISTRY, secretsForPackages } from './packem_shared/PACKAGE_SECRETS_REGISTRY-NCTSphDk.mjs';
|
|
10
14
|
export { LUNORA_CONFIG_FILE, interpretRemote, readProjectRemotePreference } from './packem_shared/LUNORA_CONFIG_FILE-CtcIcB5-.mjs';
|
|
11
|
-
export { createConfirm, isInteractive, promptMultiSelect, promptSelect, promptYesNo } from './packem_shared/createConfirm-
|
|
12
|
-
export { reconcileWranglerBindings } from './packem_shared/reconcileWranglerBindings-
|
|
13
|
-
export {
|
|
14
|
-
export {
|
|
15
|
+
export { createConfirm, isInteractive, promptMultiSelect, promptSelect, promptText, promptYesNo } from './packem_shared/createConfirm-BMikeJC9.mjs';
|
|
16
|
+
export { reconcileWranglerBindings } from './packem_shared/reconcileWranglerBindings-2Cww5VLa.mjs';
|
|
17
|
+
export { reconcileWranglerCompatibilityDate } from './packem_shared/reconcileWranglerCompatibilityDate-C8c497ag.mjs';
|
|
18
|
+
export { reconcileWranglerCrons } from './packem_shared/reconcileWranglerCrons-DvsceVFz.mjs';
|
|
19
|
+
export { REMOTE_ELIGIBLE_KEYS, injectRemoteFlags, isRemoteEnvEnabled, materializeRemoteWranglerConfig, planRemoteBindings, resolveRemoteEnabled } from './packem_shared/REMOTE_ELIGIBLE_KEYS-C-F_Flgy.mjs';
|
|
20
|
+
export { buildPackageSecretsBlock, ensureDevVariables, ensureDevVarsExample, fillDevSecrets, generateSecretValue, isMintableSecretKey, isPlaceholderValue, planDevSecretsFill, planDevVariablesAugment, planDevVariablesScaffold, requiredSecrets } from './packem_shared/buildPackageSecretsBlock-BxOcyaAY.mjs';
|
|
15
21
|
export { applyAdditiveEdit, classifyEdit } from './packem_shared/applyAdditiveEdit-C-snTFEV.mjs';
|
|
16
22
|
export { parseSchema } from './packem_shared/parseSchema-DSeyktvG.mjs';
|
|
17
23
|
export { classifyPolicyEdit, scaffoldPolicyFile, wireRlsIntoProcedure } from './packem_shared/classifyPolicyEdit-BHeAqF8P.mjs';
|
|
18
24
|
export { discoverSchemaInfo } from './packem_shared/discoverSchemaInfo-BB-CKlTK.mjs';
|
|
19
25
|
export { ACCENT, BADGES, BADGE_COLUMN_WIDTH, LUNA_ART, LUNA_BUNNY, LUNA_NAME, LUNA_SIGNOFF, STEP_BADGE_NAMES, badgeLead, badgeWidth, padBadge, paintAnswer, paintBadge } from './packem_shared/ACCENT-DW1XJn8i.mjs';
|
|
26
|
+
export { WORKERS_CACHE_MIN_DATE, isCacheEnabled } from './packem_shared/WORKERS_CACHE_MIN_DATE-CaXbS7CX.mjs';
|
|
20
27
|
export { discoverWorkflowInfo } from './packem_shared/discoverWorkflowInfo-CedvR0mn.mjs';
|
|
21
28
|
export { WRANGLER_FILES, findWranglerFile, readWranglerJsonc } from './packem_shared/WRANGLER_FILES-DwSuC-Kn.mjs';
|
|
22
|
-
export {
|
|
29
|
+
export { collectWranglerSecretVariables, scanWranglerVariablesForSecrets } from './packem_shared/collectWranglerSecretVariables-BRWIvT-e.mjs';
|
|
30
|
+
export { REQUIRED_COMPATIBILITY_DATE, REQUIRED_FLAG, validateWrangler, validateWranglerConfig, validateWranglerProject, withTailConsumer } from './packem_shared/REQUIRED_COMPATIBILITY_DATE-DP0SFVy9.mjs';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { detectAiSession } from '@visulima/find-ai-runner';
|
|
2
|
+
|
|
3
|
+
const AGENT_MODE_ENV = "LUNORA_AGENT_MODE";
|
|
4
|
+
const isDisabled = (value) => {
|
|
5
|
+
const normalized = value.trim().toLowerCase();
|
|
6
|
+
return normalized === "0" || normalized === "false";
|
|
7
|
+
};
|
|
8
|
+
const detectAiAgent = (env = process.env) => {
|
|
9
|
+
const override = env[AGENT_MODE_ENV];
|
|
10
|
+
if (override !== void 0 && override !== "") {
|
|
11
|
+
return isDisabled(override) ? void 0 : { name: "agent (forced)", variable: AGENT_MODE_ENV };
|
|
12
|
+
}
|
|
13
|
+
const session = detectAiSession(env);
|
|
14
|
+
return session === void 0 ? void 0 : { name: session.agent, variable: session.signal };
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export { AGENT_MODE_ENV, detectAiAgent };
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { mkdirSync, writeFileSync, rmSync, existsSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
|
|
4
|
+
const DEV_STATE_DIR = ".lunora";
|
|
5
|
+
const DEV_STATE_FILE = join(DEV_STATE_DIR, "dev.json");
|
|
6
|
+
const DEV_LOG_FILE = join(DEV_STATE_DIR, "dev.log");
|
|
7
|
+
const DEV_DAEMON_ENV = "LUNORA_DEV_DAEMON";
|
|
8
|
+
const DEV_LOG_FILE_ENV = "LUNORA_DEV_LOG_FILE";
|
|
9
|
+
const DEV_HANDOFF_ENV = "LUNORA_DEV_HANDOFF_PID";
|
|
10
|
+
const isObject = (value) => value !== null && typeof value === "object";
|
|
11
|
+
const stringField = (record, key) => {
|
|
12
|
+
const value = record[key];
|
|
13
|
+
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
14
|
+
};
|
|
15
|
+
const isProcessAlive = (pid) => {
|
|
16
|
+
if (!Number.isInteger(pid) || pid <= 0) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
try {
|
|
20
|
+
process.kill(pid, 0);
|
|
21
|
+
return true;
|
|
22
|
+
} catch {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const START_TIME_SKEW_MS = 1e4;
|
|
27
|
+
const LINUX_CLOCK_TICKS_PER_SECOND = 100;
|
|
28
|
+
const processStartTimeMs = (pid) => {
|
|
29
|
+
if (process.platform !== "linux") {
|
|
30
|
+
return void 0;
|
|
31
|
+
}
|
|
32
|
+
try {
|
|
33
|
+
const stat = readFileSync(`/proc/${String(pid)}/stat`, "utf8");
|
|
34
|
+
const fields = stat.slice(stat.lastIndexOf(")") + 2).split(" ");
|
|
35
|
+
const startTicks = Number(fields[19]);
|
|
36
|
+
const bootLine = readFileSync("/proc/stat", "utf8").split("\n").find((line) => line.startsWith("btime "));
|
|
37
|
+
const bootSeconds = Number(bootLine?.slice("btime ".length));
|
|
38
|
+
if (!Number.isFinite(startTicks) || !Number.isFinite(bootSeconds)) {
|
|
39
|
+
return void 0;
|
|
40
|
+
}
|
|
41
|
+
return bootSeconds * 1e3 + startTicks / LINUX_CLOCK_TICKS_PER_SECOND * 1e3;
|
|
42
|
+
} catch {
|
|
43
|
+
return void 0;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
const isRecordedProcessCurrent = (state) => {
|
|
47
|
+
if (!isProcessAlive(state.pid)) {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
const recordedAtMs = state.startedAt === void 0 ? Number.NaN : Date.parse(state.startedAt);
|
|
51
|
+
if (Number.isNaN(recordedAtMs)) {
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
const actualStartMs = processStartTimeMs(state.pid);
|
|
55
|
+
return actualStartMs === void 0 || actualStartMs <= recordedAtMs + START_TIME_SKEW_MS;
|
|
56
|
+
};
|
|
57
|
+
const readDevServerState = (projectRoot) => {
|
|
58
|
+
const path = join(projectRoot, DEV_STATE_FILE);
|
|
59
|
+
if (!existsSync(path)) {
|
|
60
|
+
return void 0;
|
|
61
|
+
}
|
|
62
|
+
let parsed;
|
|
63
|
+
try {
|
|
64
|
+
parsed = JSON.parse(readFileSync(path, "utf8"));
|
|
65
|
+
} catch {
|
|
66
|
+
return void 0;
|
|
67
|
+
}
|
|
68
|
+
if (!isObject(parsed) || typeof parsed["pid"] !== "number") {
|
|
69
|
+
return void 0;
|
|
70
|
+
}
|
|
71
|
+
const url = stringField(parsed, "url");
|
|
72
|
+
if (url === void 0) {
|
|
73
|
+
return void 0;
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
background: parsed["background"] === true,
|
|
77
|
+
logFile: stringField(parsed, "logFile"),
|
|
78
|
+
mode: parsed["mode"] === "vite" ? "vite" : "cli",
|
|
79
|
+
pid: parsed["pid"],
|
|
80
|
+
startedAt: stringField(parsed, "startedAt"),
|
|
81
|
+
studioUrl: stringField(parsed, "studioUrl"),
|
|
82
|
+
url
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
const writeDevServerState = (projectRoot, state) => {
|
|
86
|
+
try {
|
|
87
|
+
mkdirSync(join(projectRoot, DEV_STATE_DIR), { recursive: true });
|
|
88
|
+
const path = join(projectRoot, DEV_STATE_FILE);
|
|
89
|
+
writeFileSync(path, `${JSON.stringify(state, void 0, 2)}
|
|
90
|
+
`, "utf8");
|
|
91
|
+
return path;
|
|
92
|
+
} catch {
|
|
93
|
+
return void 0;
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
const updateDevServerState = (projectRoot, patch) => {
|
|
97
|
+
const existing = readDevServerState(projectRoot);
|
|
98
|
+
if (existing === void 0) {
|
|
99
|
+
return void 0;
|
|
100
|
+
}
|
|
101
|
+
const merged = { ...existing, ...patch };
|
|
102
|
+
writeDevServerState(projectRoot, merged);
|
|
103
|
+
return merged;
|
|
104
|
+
};
|
|
105
|
+
const clearDevServerState = (projectRoot, expectedPid) => {
|
|
106
|
+
try {
|
|
107
|
+
if (expectedPid !== void 0) {
|
|
108
|
+
const current = readDevServerState(projectRoot);
|
|
109
|
+
if (current !== void 0 && current.pid !== expectedPid) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
rmSync(join(projectRoot, DEV_STATE_FILE), { force: true });
|
|
114
|
+
} catch {
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
const readLiveDevServerState = (projectRoot) => {
|
|
118
|
+
const state = readDevServerState(projectRoot);
|
|
119
|
+
if (state === void 0) {
|
|
120
|
+
return void 0;
|
|
121
|
+
}
|
|
122
|
+
if (isRecordedProcessCurrent(state)) {
|
|
123
|
+
return state;
|
|
124
|
+
}
|
|
125
|
+
clearDevServerState(projectRoot, state.pid);
|
|
126
|
+
return void 0;
|
|
127
|
+
};
|
|
128
|
+
const resolveClaimConflict = (projectRoot, state, supersedePid) => {
|
|
129
|
+
const existing = readLiveDevServerState(projectRoot);
|
|
130
|
+
if (existing === void 0) {
|
|
131
|
+
return void 0;
|
|
132
|
+
}
|
|
133
|
+
if (supersedePid !== void 0 && existing.pid === supersedePid) {
|
|
134
|
+
return { ok: writeDevServerState(projectRoot, state) !== void 0 };
|
|
135
|
+
}
|
|
136
|
+
if (existing.pid !== state.pid) {
|
|
137
|
+
return { existing, ok: false };
|
|
138
|
+
}
|
|
139
|
+
return { ok: writeDevServerState(projectRoot, state) !== void 0 };
|
|
140
|
+
};
|
|
141
|
+
const claimDevServerState = (projectRoot, state, options) => {
|
|
142
|
+
const path = join(projectRoot, DEV_STATE_FILE);
|
|
143
|
+
const payload = `${JSON.stringify(state, void 0, 2)}
|
|
144
|
+
`;
|
|
145
|
+
for (let attempt = 0; attempt < 2; attempt += 1) {
|
|
146
|
+
try {
|
|
147
|
+
mkdirSync(join(projectRoot, DEV_STATE_DIR), { recursive: true });
|
|
148
|
+
writeFileSync(path, payload, { encoding: "utf8", flag: "wx" });
|
|
149
|
+
return { ok: true };
|
|
150
|
+
} catch (error) {
|
|
151
|
+
if (error.code !== "EEXIST") {
|
|
152
|
+
return { ok: writeDevServerState(projectRoot, state) !== void 0 };
|
|
153
|
+
}
|
|
154
|
+
const resolved = resolveClaimConflict(projectRoot, state, options?.supersedePid);
|
|
155
|
+
if (resolved !== void 0) {
|
|
156
|
+
return resolved;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return { ok: writeDevServerState(projectRoot, state) !== void 0 };
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
export { DEV_DAEMON_ENV, DEV_HANDOFF_ENV, DEV_LOG_FILE, DEV_LOG_FILE_ENV, DEV_STATE_DIR, DEV_STATE_FILE, claimDevServerState, clearDevServerState, isProcessAlive, isRecordedProcessCurrent, readDevServerState, readLiveDevServerState, updateDevServerState, writeDevServerState };
|
package/dist/packem_shared/{LUNORA_EVENT_SOURCE-D2fDeGB6.mjs → LUNORA_EVENT_SOURCE-M1KM9_pR.mjs}
RENAMED
|
@@ -1,10 +1,27 @@
|
|
|
1
|
+
const stringifyFieldValue = (value) => {
|
|
2
|
+
if (typeof value === "string") {
|
|
3
|
+
return value;
|
|
4
|
+
}
|
|
5
|
+
try {
|
|
6
|
+
return JSON.stringify(value) ?? String(value);
|
|
7
|
+
} catch {
|
|
8
|
+
return String(value);
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
const formatLogFields = (fields) => {
|
|
12
|
+
if (typeof fields !== "object" || fields === null || Array.isArray(fields)) {
|
|
13
|
+
return "";
|
|
14
|
+
}
|
|
15
|
+
return Object.entries(fields).map(([key, value]) => `${key}=${stringifyFieldValue(value)}`).join(" ");
|
|
16
|
+
};
|
|
17
|
+
|
|
1
18
|
const LUNORA_EVENT_SOURCE = "lunora";
|
|
2
19
|
const ROOT_SHARD_NAME = "__root__";
|
|
3
20
|
const asString = (value) => typeof value === "string" ? value : "";
|
|
4
21
|
const asStringList = (value) => Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
|
|
5
22
|
const formatDuration = (value) => typeof value === "number" && Number.isFinite(value) ? `${String(Math.round(value))}ms` : "?ms";
|
|
6
23
|
const toLineLevel = (rawLevel) => {
|
|
7
|
-
if (rawLevel === "error") {
|
|
24
|
+
if (rawLevel === "error" || rawLevel === "fatal") {
|
|
8
25
|
return "error";
|
|
9
26
|
}
|
|
10
27
|
if (rawLevel === "warn") {
|
|
@@ -72,7 +89,16 @@ const formatLunoraEvent = (line) => {
|
|
|
72
89
|
}
|
|
73
90
|
const functionPath = asString(event.function) || "<unknown>";
|
|
74
91
|
if (event.type === "log") {
|
|
75
|
-
|
|
92
|
+
const parts = [`${labelFor(functionPath, event)} ${asString(event.message)}`.trimEnd()];
|
|
93
|
+
const fields = formatLogFields(event.fields);
|
|
94
|
+
if (fields !== "") {
|
|
95
|
+
parts.push(fields);
|
|
96
|
+
}
|
|
97
|
+
const traceId = asString(event.traceId);
|
|
98
|
+
if (traceId !== "") {
|
|
99
|
+
parts.push(`trace=${traceId.slice(0, 8)}`);
|
|
100
|
+
}
|
|
101
|
+
return { kind: "log", level: toLineLevel(asString(event.level)), text: parts.join(" ") };
|
|
76
102
|
}
|
|
77
103
|
if (event.type === "request") {
|
|
78
104
|
return formatRequest(event, functionPath);
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
const CORE_SECRETS = [
|
|
2
|
+
{
|
|
3
|
+
description: "Bearer token the local Lunora Studio uses to call the worker's admin endpoints (data browser, schema edits) in dev. Generate with: openssl rand -hex 32",
|
|
4
|
+
docsUrl: "https://lunora.sh/docs/packages/studio",
|
|
5
|
+
key: "LUNORA_ADMIN_TOKEN",
|
|
6
|
+
placeholderValue: "replace-with-openssl-rand-hex-32"
|
|
7
|
+
}
|
|
8
|
+
];
|
|
9
|
+
const PACKAGE_SECRETS_REGISTRY = {
|
|
10
|
+
"@lunora/auth": [
|
|
11
|
+
{
|
|
12
|
+
description: "32-byte random secret used to sign sessions and tokens. Generate with: openssl rand -hex 32",
|
|
13
|
+
docsUrl: "https://lunora.sh/docs/packages/auth#secrets",
|
|
14
|
+
key: "AUTH_SECRET",
|
|
15
|
+
placeholderValue: "replace-with-openssl-rand-hex-32"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
description: "Public base URL of your worker (used by better-auth for redirects and cookie domain). For local dev this is typically http://localhost:8787",
|
|
19
|
+
docsUrl: "https://lunora.sh/docs/packages/auth#secrets",
|
|
20
|
+
key: "AUTH_URL",
|
|
21
|
+
placeholderValue: "http://localhost:8787"
|
|
22
|
+
}
|
|
23
|
+
],
|
|
24
|
+
"@lunora/mail": [
|
|
25
|
+
{
|
|
26
|
+
description: "Resend API key for sending transactional email via @lunora/mail. Obtain at https://resend.com/api-keys",
|
|
27
|
+
docsUrl: "https://lunora.sh/docs/packages/mail#secrets",
|
|
28
|
+
key: "RESEND_API_KEY",
|
|
29
|
+
placeholderValue: "<your-resend-api-key>"
|
|
30
|
+
}
|
|
31
|
+
],
|
|
32
|
+
"@lunora/notify": [
|
|
33
|
+
{
|
|
34
|
+
description: "Public VAPID key (base64url) for Web Push. Generate a keypair once with: npx web-push generate-vapid-keys — the public key is also shipped to the browser to subscribe.",
|
|
35
|
+
docsUrl: "https://lunora.sh/docs/packages/notify#web-push",
|
|
36
|
+
key: "VAPID_PUBLIC_KEY",
|
|
37
|
+
placeholderValue: "<your-vapid-public-key>"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
description: "Private VAPID key (base64url) for Web Push — the application-server signing key. Generate with: npx web-push generate-vapid-keys",
|
|
41
|
+
docsUrl: "https://lunora.sh/docs/packages/notify#web-push",
|
|
42
|
+
key: "VAPID_PRIVATE_KEY",
|
|
43
|
+
placeholderValue: "<your-vapid-private-key>"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
description: "VAPID `sub` contact — a mailto: or https: URL identifying the application server (e.g. mailto:you@example.com).",
|
|
47
|
+
docsUrl: "https://lunora.sh/docs/packages/notify#web-push",
|
|
48
|
+
key: "VAPID_SUBJECT",
|
|
49
|
+
placeholderValue: "mailto:you@example.com"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
description: "Firebase project id for FCM (HTTP v1) push. Found in the Firebase console project settings.",
|
|
53
|
+
docsUrl: "https://lunora.sh/docs/packages/notify#fcm",
|
|
54
|
+
key: "FCM_PROJECT_ID",
|
|
55
|
+
placeholderValue: "<your-firebase-project-id>"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
description: "OAuth2 access token for FCM (HTTP v1). Convenient for dev but expires — in production supply a getAccessToken() in defineNotify instead. Obtain via the Google Cloud SDK / a service account.",
|
|
59
|
+
docsUrl: "https://lunora.sh/docs/packages/notify#fcm",
|
|
60
|
+
key: "FCM_ACCESS_TOKEN",
|
|
61
|
+
placeholderValue: "<your-fcm-access-token>"
|
|
62
|
+
}
|
|
63
|
+
],
|
|
64
|
+
"@lunora/payment": [
|
|
65
|
+
{
|
|
66
|
+
description: "Stripe secret key (sk_test_…). Required when using the Stripe adapter. Obtain at https://dashboard.stripe.com/apikeys",
|
|
67
|
+
docsUrl: "https://lunora.sh/docs/packages/payment#stripe",
|
|
68
|
+
key: "STRIPE_SECRET_KEY",
|
|
69
|
+
placeholderValue: "<your-stripe-secret-key>"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
description: "Stripe webhook signing secret (whsec_…) for verifying event payloads. Obtain at https://dashboard.stripe.com/webhooks",
|
|
73
|
+
docsUrl: "https://lunora.sh/docs/packages/payment#stripe",
|
|
74
|
+
key: "STRIPE_WEBHOOK_SECRET",
|
|
75
|
+
placeholderValue: "<your-stripe-webhook-secret>"
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
description: "Polar access token for the Polar payment adapter. Obtain at https://polar.sh/settings/tokens",
|
|
79
|
+
docsUrl: "https://lunora.sh/docs/packages/payment#polar",
|
|
80
|
+
key: "POLAR_ACCESS_TOKEN",
|
|
81
|
+
placeholderValue: "<your-polar-access-token>"
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
description: "Polar webhook secret for verifying event payloads from Polar. Obtain at https://polar.sh/settings/webhooks",
|
|
85
|
+
docsUrl: "https://lunora.sh/docs/packages/payment#polar",
|
|
86
|
+
key: "POLAR_WEBHOOK_SECRET",
|
|
87
|
+
placeholderValue: "<your-polar-webhook-secret>"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
description: "Autumn secret key (am_sk_…) for the Autumn payment adapter. Obtain at https://app.useautumn.com/dev",
|
|
91
|
+
docsUrl: "https://lunora.sh/docs/packages/payment#autumn",
|
|
92
|
+
key: "AUTUMN_SECRET_KEY",
|
|
93
|
+
placeholderValue: "<your-autumn-secret-key>"
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
description: "Autumn webhook signing secret for verifying Standard Webhooks event payloads. Obtain from your Autumn dashboard webhook settings.",
|
|
97
|
+
docsUrl: "https://lunora.sh/docs/packages/payment#autumn",
|
|
98
|
+
key: "AUTUMN_WEBHOOK_SECRET",
|
|
99
|
+
placeholderValue: "<your-autumn-webhook-secret>"
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
description: "Dodo Payments API key (bearer token) for the Dodo Payments adapter. Obtain at https://app.dodopayments.com/developer/api-keys",
|
|
103
|
+
docsUrl: "https://lunora.sh/docs/packages/payment#dodo-payments",
|
|
104
|
+
key: "DODO_PAYMENTS_API_KEY",
|
|
105
|
+
placeholderValue: "<your-dodo-payments-api-key>"
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
description: "Dodo Payments webhook signing secret (whsec_…) for verifying event payloads. Obtain at https://app.dodopayments.com/developer/webhooks",
|
|
109
|
+
docsUrl: "https://lunora.sh/docs/packages/payment#dodo-payments",
|
|
110
|
+
key: "DODO_PAYMENTS_WEBHOOK_KEY",
|
|
111
|
+
placeholderValue: "<your-dodo-payments-webhook-secret>"
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
description: "Creem API key for the Creem payment adapter. Obtain at https://www.creem.io/dashboard/developers",
|
|
115
|
+
docsUrl: "https://lunora.sh/docs/packages/payment#creem",
|
|
116
|
+
key: "CREEM_API_KEY",
|
|
117
|
+
placeholderValue: "<your-creem-api-key>"
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
description: "Creem webhook signing secret for verifying the creem-signature header. Obtain from your Creem dashboard webhook settings.",
|
|
121
|
+
docsUrl: "https://lunora.sh/docs/packages/payment#creem",
|
|
122
|
+
key: "CREEM_WEBHOOK_SECRET",
|
|
123
|
+
placeholderValue: "<your-creem-webhook-secret>"
|
|
124
|
+
}
|
|
125
|
+
]
|
|
126
|
+
};
|
|
127
|
+
const secretsForPackages = (packageNames) => {
|
|
128
|
+
const result = [];
|
|
129
|
+
for (const name of packageNames) {
|
|
130
|
+
const entries = PACKAGE_SECRETS_REGISTRY[name];
|
|
131
|
+
if (entries !== void 0) {
|
|
132
|
+
result.push(...entries);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return result;
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
export { CORE_SECRETS, PACKAGE_SECRETS_REGISTRY, secretsForPackages };
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { existsSync, readFileSync
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
2
2
|
import { join, isAbsolute, relative } from 'node:path';
|
|
3
3
|
import { runCodegen, CodegenDiagnosticError } from '@lunora/codegen';
|
|
4
|
+
import { LunoraError } from '@lunora/errors';
|
|
4
5
|
import { classifyPolicyEdit, scaffoldPolicyFile, wireRlsIntoProcedure } from './classifyPolicyEdit-BHeAqF8P.mjs';
|
|
6
|
+
import { w as writeFileAtomic } from './write-atomic-B2REqapi.mjs';
|
|
5
7
|
|
|
6
8
|
const POLICY_SCAFFOLD_ENDPOINT = "/__lunora/policy-scaffold";
|
|
7
9
|
const statusForFailure = (reason) => {
|
|
@@ -13,11 +15,6 @@ const statusForFailure = (reason) => {
|
|
|
13
15
|
}
|
|
14
16
|
return reason === "destructive" ? 409 : 422;
|
|
15
17
|
};
|
|
16
|
-
const writeAtomic = (path, text) => {
|
|
17
|
-
const temporaryPath = `${path}.lunora-tmp`;
|
|
18
|
-
writeFileSync(temporaryPath, text, "utf8");
|
|
19
|
-
renameSync(temporaryPath, path);
|
|
20
|
-
};
|
|
21
18
|
const runCodegenForResponse = (request, okBody) => {
|
|
22
19
|
let diagnostics = [];
|
|
23
20
|
try {
|
|
@@ -52,7 +49,7 @@ const handleScaffoldPolicy = (request, edit) => {
|
|
|
52
49
|
if (existsSync(targetPath)) {
|
|
53
50
|
return { body: { error: "file-exists", fileName: result.fileName, ok: false }, status: 409 };
|
|
54
51
|
}
|
|
55
|
-
|
|
52
|
+
writeFileAtomic(targetPath, result.source);
|
|
56
53
|
return runCodegenForResponse(request, { fileName: result.fileName });
|
|
57
54
|
};
|
|
58
55
|
const resolveProcedureFile = (projectRoot, lunoraDirectory, filePath) => {
|
|
@@ -76,7 +73,7 @@ const handleWireRls = (request, edit) => {
|
|
|
76
73
|
if (!wired.ok) {
|
|
77
74
|
return { body: { error: wired.reason, ok: false }, status: statusForFailure(wired.reason) };
|
|
78
75
|
}
|
|
79
|
-
|
|
76
|
+
writeFileAtomic(procedurePath, wired.text);
|
|
80
77
|
return runCodegenForResponse(request, { exportName: edit.exportName });
|
|
81
78
|
};
|
|
82
79
|
const handlePolicyScaffoldRequest = (request) => {
|
|
@@ -84,7 +81,7 @@ const handlePolicyScaffoldRequest = (request) => {
|
|
|
84
81
|
return { body: { error: "method-not-allowed", ok: false }, status: 405 };
|
|
85
82
|
}
|
|
86
83
|
const { body } = request;
|
|
87
|
-
if (body === void 0 || typeof body !== "object" || typeof body.kind !== "string") {
|
|
84
|
+
if (body === void 0 || body === null || typeof body !== "object" || typeof body.kind !== "string") {
|
|
88
85
|
return { body: { error: "invalid-edit", ok: false }, status: 400 };
|
|
89
86
|
}
|
|
90
87
|
const edit = body;
|
|
@@ -97,7 +94,7 @@ const handlePolicyScaffoldRequest = (request) => {
|
|
|
97
94
|
if (edit.kind === "wireRls") {
|
|
98
95
|
return handleWireRls(request, edit);
|
|
99
96
|
}
|
|
100
|
-
throw new
|
|
97
|
+
throw new LunoraError("INTERNAL", `unhandled additive policy edit kind: ${String(edit.kind)}`);
|
|
101
98
|
};
|
|
102
99
|
|
|
103
100
|
export { POLICY_SCAFFOLD_ENDPOINT, handlePolicyScaffoldRequest };
|
package/dist/packem_shared/{REMOTE_ELIGIBLE_KEYS-BC7_e9Bz.mjs → REMOTE_ELIGIBLE_KEYS-C-F_Flgy.mjs}
RENAMED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { writeFileSync, rmSync } from 'node:fs';
|
|
2
|
-
import {
|
|
2
|
+
import { a as applyModify } from './jsonc-edit-SbcD7MAe.mjs';
|
|
3
3
|
import { findWranglerFile, readWranglerJsonc } from './WRANGLER_FILES-DwSuC-Kn.mjs';
|
|
4
4
|
import { join } from 'node:path';
|
|
5
5
|
|
|
6
|
-
const FORMATTING = { formattingOptions: { insertSpaces: true, tabSize: 4 } };
|
|
7
6
|
const REMOTE_ELIGIBLE_KEYS = {
|
|
8
7
|
ai: { label: "AI", shape: "object" },
|
|
9
8
|
d1_databases: { label: "D1", shape: "array" },
|
|
@@ -38,10 +37,6 @@ const planSection = (section, parsed) => {
|
|
|
38
37
|
return entry === null || entry === void 0 ? [] : [{ binding: entryName(entry, section), kind: label, path: [], section }];
|
|
39
38
|
};
|
|
40
39
|
const planRemoteBindings = (parsed) => REMOTE_ELIGIBLE_KEY_LIST.flatMap((section) => planSection(section, parsed));
|
|
41
|
-
const applyModify = (text, path, value) => {
|
|
42
|
-
const edits = modify(text, [...path], value, FORMATTING);
|
|
43
|
-
return edits.length > 0 ? applyEdits(text, edits) : text;
|
|
44
|
-
};
|
|
45
40
|
const injectRemoteFlags = (text, plans) => {
|
|
46
41
|
let next = text;
|
|
47
42
|
for (const plan of plans) {
|