replicas-cli 0.3.435 → 0.3.437
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/index.cjs +283 -126
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -4958,7 +4958,7 @@ function isRef(value) {
|
|
|
4958
4958
|
function cloneIssues(issues) {
|
|
4959
4959
|
return issues.map((iss) => iss.path ? { ...iss, path: iss.path.slice() } : { ...iss });
|
|
4960
4960
|
}
|
|
4961
|
-
function isRecursive(inst, stack,
|
|
4961
|
+
function isRecursive(inst, stack, resolve4) {
|
|
4962
4962
|
const cached2 = recursive.get(inst);
|
|
4963
4963
|
if (cached2 !== void 0)
|
|
4964
4964
|
return cached2 ? PROVEN : NONE;
|
|
@@ -4968,7 +4968,7 @@ function isRecursive(inst, stack, resolve3) {
|
|
|
4968
4968
|
let result = NONE;
|
|
4969
4969
|
const check2 = (child) => {
|
|
4970
4970
|
if (result !== PROVEN && child?._zod) {
|
|
4971
|
-
const answer = isRecursive(child, stack,
|
|
4971
|
+
const answer = isRecursive(child, stack, resolve4);
|
|
4972
4972
|
if (answer > result)
|
|
4973
4973
|
result = answer;
|
|
4974
4974
|
}
|
|
@@ -4979,7 +4979,7 @@ function isRecursive(inst, stack, resolve3) {
|
|
|
4979
4979
|
const desc = Object.getOwnPropertyDescriptor(sh, key);
|
|
4980
4980
|
if (spread && !desc.enumerable)
|
|
4981
4981
|
continue;
|
|
4982
|
-
const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack,
|
|
4982
|
+
const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve4) : NONE;
|
|
4983
4983
|
if (child > answer)
|
|
4984
4984
|
answer = child;
|
|
4985
4985
|
}
|
|
@@ -5043,7 +5043,7 @@ function isRecursive(inst, stack, resolve3) {
|
|
|
5043
5043
|
break;
|
|
5044
5044
|
// `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
|
|
5045
5045
|
case "lazy": {
|
|
5046
|
-
const inner = def._cachedInner ?? (
|
|
5046
|
+
const inner = def._cachedInner ?? (resolve4 ? inst._zod.innerType : void 0);
|
|
5047
5047
|
merge2(inner ? isRecursive(inner, stack, false) : ASSUMED);
|
|
5048
5048
|
break;
|
|
5049
5049
|
}
|
|
@@ -23326,16 +23326,105 @@ var init_environment = __esm({
|
|
|
23326
23326
|
}
|
|
23327
23327
|
});
|
|
23328
23328
|
|
|
23329
|
+
// ../shared/src/environment-config.ts
|
|
23330
|
+
var variableNameSchema, mcpValueSchema, mcpValuesSchema, httpConfigSchema, replicasMcpDefinitionSchema, replicasEnvironmentConfigSchema;
|
|
23331
|
+
var init_environment_config = __esm({
|
|
23332
|
+
"../shared/src/environment-config.ts"() {
|
|
23333
|
+
"use strict";
|
|
23334
|
+
init_zod();
|
|
23335
|
+
init_environment();
|
|
23336
|
+
init_environment_setups();
|
|
23337
|
+
variableNameSchema = external_exports.string().regex(VARIABLE_KEY_RE, "must be a valid environment variable name");
|
|
23338
|
+
mcpValueSchema = external_exports.union([
|
|
23339
|
+
external_exports.string(),
|
|
23340
|
+
environmentMcpVariableReferenceSchema
|
|
23341
|
+
]);
|
|
23342
|
+
mcpValuesSchema = external_exports.record(external_exports.string(), mcpValueSchema);
|
|
23343
|
+
httpConfigSchema = environmentMcpHttpConfigSchema.pick({ url: true, auth: true }).extend({
|
|
23344
|
+
headers: mcpValuesSchema.default({})
|
|
23345
|
+
}).strict();
|
|
23346
|
+
replicasMcpDefinitionSchema = external_exports.discriminatedUnion("transport", [
|
|
23347
|
+
external_exports.strictObject({
|
|
23348
|
+
transport: external_exports.literal("stdio"),
|
|
23349
|
+
config: environmentMcpStdioConfigSchema.pick({ command: true }).extend({
|
|
23350
|
+
args: environmentMcpStdioConfigSchema.shape.args.unwrap().default([]),
|
|
23351
|
+
env: external_exports.record(variableNameSchema, mcpValueSchema).default({})
|
|
23352
|
+
}).strict()
|
|
23353
|
+
}),
|
|
23354
|
+
external_exports.strictObject({ transport: external_exports.literal("http"), config: httpConfigSchema }),
|
|
23355
|
+
external_exports.strictObject({ transport: external_exports.literal("sse"), config: httpConfigSchema })
|
|
23356
|
+
]).superRefine((definition, context) => {
|
|
23357
|
+
if (definition.transport === "stdio") return;
|
|
23358
|
+
const result = validateEnvironmentMcpAuthentication(definition.transport, definition.config);
|
|
23359
|
+
if (!result.ok) context.addIssue({ code: "custom", path: result.error.code === "transport" ? ["transport"] : ["config", result.error.code ?? "auth"], message: result.error.message });
|
|
23360
|
+
});
|
|
23361
|
+
replicasEnvironmentConfigSchema = external_exports.strictObject({
|
|
23362
|
+
systemPrompt: external_exports.string().optional(),
|
|
23363
|
+
warmHook: external_exports.string().optional(),
|
|
23364
|
+
startHook: external_exports.string().optional(),
|
|
23365
|
+
variables: external_exports.record(variableNameSchema, external_exports.string()).optional(),
|
|
23366
|
+
requiredSecrets: external_exports.array(variableNameSchema).optional(),
|
|
23367
|
+
mcps: external_exports.record(external_exports.string().regex(MCP_NAME_PATTERN, "must be 1\u201364 letters, digits, underscores or hyphens, starting with a letter or digit").refine((name) => !isReservedMcpName(name), "is reserved for Replicas"), replicasMcpDefinitionSchema).optional()
|
|
23368
|
+
}).superRefine((config3, context) => {
|
|
23369
|
+
const names = /* @__PURE__ */ new Set();
|
|
23370
|
+
for (const name of Object.keys(config3.mcps ?? {})) {
|
|
23371
|
+
const normalized = name.toLowerCase();
|
|
23372
|
+
if (names.has(normalized)) {
|
|
23373
|
+
context.addIssue({ code: "custom", path: ["mcps", name], message: "MCP names must be unique regardless of case" });
|
|
23374
|
+
}
|
|
23375
|
+
names.add(normalized);
|
|
23376
|
+
}
|
|
23377
|
+
for (const key of config3.requiredSecrets ?? []) {
|
|
23378
|
+
if (config3.variables && Object.hasOwn(config3.variables, key)) {
|
|
23379
|
+
context.addIssue({ code: "custom", path: ["requiredSecrets"], message: `"${key}" cannot also be declared as a non-secret variable` });
|
|
23380
|
+
}
|
|
23381
|
+
}
|
|
23382
|
+
});
|
|
23383
|
+
}
|
|
23384
|
+
});
|
|
23385
|
+
|
|
23329
23386
|
// ../shared/src/routes/environment-config-source.ts
|
|
23330
|
-
var previewEnvironmentConfigSourceRequestSchema, applyEnvironmentConfigSourceRequestSchema;
|
|
23387
|
+
var environmentConfigLocationSchema, sourceInput, previewEnvironmentConfigSourceRequestSchema, applyEnvironmentConfigSourceRequestSchema;
|
|
23331
23388
|
var init_environment_config_source = __esm({
|
|
23332
23389
|
"../shared/src/routes/environment-config-source.ts"() {
|
|
23333
23390
|
"use strict";
|
|
23334
23391
|
init_zod();
|
|
23335
|
-
|
|
23336
|
-
|
|
23337
|
-
|
|
23392
|
+
init_environment_config();
|
|
23393
|
+
environmentConfigLocationSchema = external_exports.union([
|
|
23394
|
+
external_exports.object({
|
|
23395
|
+
kind: external_exports.literal("git").default("git"),
|
|
23396
|
+
entrypoint_filename: external_exports.string().optional(),
|
|
23397
|
+
repository_id: external_exports.string(),
|
|
23398
|
+
repository_name: external_exports.string(),
|
|
23399
|
+
filename: external_exports.string(),
|
|
23400
|
+
commit_sha: external_exports.string(),
|
|
23401
|
+
source_url: external_exports.string(),
|
|
23402
|
+
file_sha: external_exports.undefined().optional()
|
|
23403
|
+
}),
|
|
23404
|
+
external_exports.object({
|
|
23405
|
+
kind: external_exports.literal("file"),
|
|
23406
|
+
repository_id: external_exports.null(),
|
|
23407
|
+
repository_name: external_exports.null(),
|
|
23408
|
+
filename: external_exports.string(),
|
|
23409
|
+
commit_sha: external_exports.null(),
|
|
23410
|
+
source_url: external_exports.null(),
|
|
23411
|
+
file_sha: external_exports.string()
|
|
23412
|
+
})
|
|
23413
|
+
]);
|
|
23414
|
+
sourceInput = {
|
|
23415
|
+
repository_id: external_exports.string().min(1).optional(),
|
|
23416
|
+
file: external_exports.strictObject({ filename: external_exports.string().min(1).max(1024), environment: replicasEnvironmentConfigSchema }).optional()
|
|
23417
|
+
};
|
|
23418
|
+
previewEnvironmentConfigSourceRequestSchema = external_exports.strictObject(sourceInput).refine(
|
|
23419
|
+
(input2) => !input2.file || !input2.repository_id,
|
|
23420
|
+
{ message: "Choose either a repository or a file" }
|
|
23421
|
+
);
|
|
23422
|
+
applyEnvironmentConfigSourceRequestSchema = external_exports.strictObject({
|
|
23423
|
+
...sourceInput,
|
|
23424
|
+
commit_sha: external_exports.string().min(1).optional(),
|
|
23338
23425
|
fingerprint: external_exports.string().min(1)
|
|
23426
|
+
}).refine((input2) => input2.file ? !input2.repository_id && !input2.commit_sha : !!input2.commit_sha, {
|
|
23427
|
+
message: "File configuration requires file contents; Git configuration requires a reviewed commit"
|
|
23339
23428
|
});
|
|
23340
23429
|
}
|
|
23341
23430
|
});
|
|
@@ -23464,8 +23553,8 @@ var init_replicas_mcp = __esm({
|
|
|
23464
23553
|
...updateEnvironmentMcpRequestSchema.shape
|
|
23465
23554
|
});
|
|
23466
23555
|
createEnvironmentDeviceToolInputSchema = external_exports.object({ ...environmentMcpPath, ...createEnvironmentDeviceRequestSchema.shape });
|
|
23467
|
-
previewEnvironmentConfigSourceToolInputSchema =
|
|
23468
|
-
applyEnvironmentConfigSourceToolInputSchema =
|
|
23556
|
+
previewEnvironmentConfigSourceToolInputSchema = previewEnvironmentConfigSourceRequestSchema.safeExtend(environmentMcpPath);
|
|
23557
|
+
applyEnvironmentConfigSourceToolInputSchema = applyEnvironmentConfigSourceRequestSchema.safeExtend(environmentMcpPath);
|
|
23469
23558
|
}
|
|
23470
23559
|
});
|
|
23471
23560
|
|
|
@@ -26207,7 +26296,7 @@ function injectVisualBootstrap(html) {
|
|
|
26207
26296
|
const at = htmlOpen ? htmlOpen.index + htmlOpen[0].length : doctype ? doctype[0].length : 0;
|
|
26208
26297
|
return `${prefix}${html.slice(0, at)}<head>${markup}</head>${html.slice(at)}`;
|
|
26209
26298
|
}
|
|
26210
|
-
var VISUAL_MEASURE_WIDTHS, VISUAL_COLUMN_WIDTH, VISUAL_PHONE_WIDTH, VISUAL_MIN_HEIGHT, VISUAL_MAX_HEIGHT, VISUAL_FONT_PATH, FONT_SANS, FONT_MONO, VISUAL_PAGE_RULES, THEME_FRAGMENT_KEY, HOST_CONTEXT_CHANGED_METHOD, SIZE_CHANGED_METHOD, OPEN_LINK_METHOD, OPEN_IMAGE_METHOD, VISUAL_CONTENT_HEIGHT_EXPRESSION, BASE_CSS, THEME_STYLE_ID, BOOTSTRAP_SCRIPT, blankNonMarkup;
|
|
26299
|
+
var VISUAL_MEASURE_WIDTHS, VISUAL_COLUMN_WIDTH, VISUAL_PHONE_WIDTH, VISUAL_MIN_HEIGHT, VISUAL_MAX_HEIGHT, VISUAL_FONT_PATH, FONT_FAMILIES, FONT_SANS, FONT_MONO, VISUAL_PAGE_RULES, THEME_FRAGMENT_KEY, HOST_CONTEXT_CHANGED_METHOD, SIZE_CHANGED_METHOD, OPEN_LINK_METHOD, OPEN_IMAGE_METHOD, VISUAL_CONTENT_HEIGHT_EXPRESSION, BASE_CSS, THEME_STYLE_ID, BOOTSTRAP_SCRIPT, blankNonMarkup;
|
|
26211
26300
|
var init_visuals = __esm({
|
|
26212
26301
|
"../shared/src/visuals.ts"() {
|
|
26213
26302
|
"use strict";
|
|
@@ -26218,14 +26307,15 @@ var init_visuals = __esm({
|
|
|
26218
26307
|
VISUAL_PHONE_WIDTH = 390;
|
|
26219
26308
|
VISUAL_MIN_HEIGHT = 24;
|
|
26220
26309
|
VISUAL_MAX_HEIGHT = 2e4;
|
|
26221
|
-
VISUAL_FONT_PATH = "/fonts/
|
|
26222
|
-
|
|
26310
|
+
VISUAL_FONT_PATH = "/fonts/InterVariable.woff2";
|
|
26311
|
+
FONT_FAMILIES = ["Inter", "General Sans"];
|
|
26312
|
+
FONT_SANS = `${FONT_FAMILIES.map((family) => `"${family}"`).join(", ")}, system-ui, -apple-system, "Segoe UI", sans-serif`;
|
|
26223
26313
|
FONT_MONO = '"Geist Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace';
|
|
26224
26314
|
VISUAL_PAGE_RULES = `- Write one self-contained HTML file with inline <style> and <script>; a fragment without <html> or <head> is fine. Put data inline instead of fetching it. Libraries may load from public CDNs such as cdn.jsdelivr.net. Local images written as absolute paths (src="/abs/shot.png", url(/abs/bg.webp)) are inlined when you publish.
|
|
26225
26315
|
- The page sits directly on the chat background, as wide as your reply (about ${VISUAL_COLUMN_WIDTH}px on desktop, ${VISUAL_PHONE_WIDTH - 30}px on phones), with its left edge aligned to your text. Leave html and body transparent, use a fluid width with no outer padding, and add no outer card, border, or title banner: the page is part of your reply.
|
|
26226
26316
|
- Let content set the height. Never use 100vh, height:100%, or min-height:100vh on html, body, or the outer element; publishing refuses a page whose height follows the frame. Give charts fixed pixel heights.
|
|
26227
26317
|
- Color everything with the theme variables so the page follows light and dark mode live: --foreground, --muted-foreground (secondary text), --background, --muted (subtle fills), --accent, --border, --primary and --primary-foreground (the brand accent, for emphasis), --success (passed, done, or added), --destructive, --warning, --code-background, --code-foreground, and --chart-1 to --chart-8 for series (use them in order and label series directly). Never hardcode a light or dark palette. A canvas or chart library that needs literal colors can read them with getComputedStyle(document.documentElement) and redraw on matchMedia("(prefers-color-scheme: dark)") changes.
|
|
26228
|
-
- Text is 13px
|
|
26318
|
+
- Text is 13px Inter, like the chat; --font-sans and --font-mono are set. Keep Replicas' flat look: separate sections with 1px var(--border) lines or var(--muted) fills, without shadows or rounded cards. Use var(--radius) only on small controls.
|
|
26229
26319
|
- A mockup of a specific product's UI, such as a client's app or a competitor's screen, is the exception: give it its own panel with at least 16px of padding and use that product's real colors, fonts, corners, and shadows inside it, so it looks like the product. Everything around the panel follows the rules above.
|
|
26230
26320
|
- Interaction is welcome: hover details, tabs, toggles, sliders. Links open in a new browser tab.
|
|
26231
26321
|
- Keep the top-right corner (about 110\xD740px) free of anything essential: the chat shows the visual's actions there on hover.`;
|
|
@@ -26245,7 +26335,7 @@ var init_visuals = __esm({
|
|
|
26245
26335
|
const post = (message) => nativeView ? nativeView.postMessage(JSON.stringify(message)) : window.parent.postMessage(message, '*');
|
|
26246
26336
|
const applyTheme = (theme) => {
|
|
26247
26337
|
const variables = Object.entries(theme.variables).map(([name, value]) => name + ':' + value + ';').join('');
|
|
26248
|
-
const font = theme.fontUrl ? '@font-face{font-family:"
|
|
26338
|
+
const font = theme.fontUrl ? ${JSON.stringify(FONT_FAMILIES)}.map((family) => '@font-face{font-family:"' + family + '";src:url("' + theme.fontUrl + '") format("woff2");font-weight:100 900;font-display:swap}').join('') : '';
|
|
26249
26339
|
style.textContent = ':root{color-scheme:' + theme.appearance + ';' + variables + '}' + font + ${JSON.stringify(BASE_CSS)};
|
|
26250
26340
|
};
|
|
26251
26341
|
try {
|
|
@@ -38325,6 +38415,31 @@ var init_hook_config = __esm({
|
|
|
38325
38415
|
});
|
|
38326
38416
|
|
|
38327
38417
|
// ../shared/src/warm-hooks.ts
|
|
38418
|
+
function isRecord2(value) {
|
|
38419
|
+
return typeof value === "object" && value !== null;
|
|
38420
|
+
}
|
|
38421
|
+
function parseWarmHookConfig(value, filename = "replicas.json") {
|
|
38422
|
+
if (typeof value === "string") {
|
|
38423
|
+
return value;
|
|
38424
|
+
}
|
|
38425
|
+
if (!isRecord2(value)) {
|
|
38426
|
+
throw new Error(`Invalid ${filename}: "warmHook" must be a string or object`);
|
|
38427
|
+
}
|
|
38428
|
+
if (!Array.isArray(value.commands) || !value.commands.every((entry) => typeof entry === "string")) {
|
|
38429
|
+
throw new Error(`Invalid ${filename}: "warmHook.commands" must be an array of shell commands`);
|
|
38430
|
+
}
|
|
38431
|
+
if (value.timeout !== void 0 && (typeof value.timeout !== "number" || value.timeout <= 0)) {
|
|
38432
|
+
throw new Error(`Invalid ${filename}: "warmHook.timeout" must be a positive number`);
|
|
38433
|
+
}
|
|
38434
|
+
if (value.separate !== void 0 && typeof value.separate !== "boolean") {
|
|
38435
|
+
throw new Error(`Invalid ${filename}: "warmHook.separate" must be a boolean`);
|
|
38436
|
+
}
|
|
38437
|
+
return {
|
|
38438
|
+
commands: value.commands,
|
|
38439
|
+
timeout: value.timeout,
|
|
38440
|
+
separate: value.separate
|
|
38441
|
+
};
|
|
38442
|
+
}
|
|
38328
38443
|
var DEFAULT_WARM_HOOK_TIMEOUT_MS, MAX_WARM_HOOK_TIMEOUT_MS, DEFAULT_START_HOOK_TIMEOUT_MS, HOOK_EXEC_MAX_BUFFER_BYTES;
|
|
38329
38444
|
var init_warm_hooks = __esm({
|
|
38330
38445
|
"../shared/src/warm-hooks.ts"() {
|
|
@@ -38337,69 +38452,90 @@ var init_warm_hooks = __esm({
|
|
|
38337
38452
|
}
|
|
38338
38453
|
});
|
|
38339
38454
|
|
|
38340
|
-
// ../shared/src/environment-config.ts
|
|
38341
|
-
var variableNameSchema, mcpValueSchema, mcpValuesSchema, httpConfigSchema, replicasMcpDefinitionSchema, replicasEnvironmentConfigSchema;
|
|
38342
|
-
var init_environment_config = __esm({
|
|
38343
|
-
"../shared/src/environment-config.ts"() {
|
|
38344
|
-
"use strict";
|
|
38345
|
-
init_zod();
|
|
38346
|
-
init_environment();
|
|
38347
|
-
init_environment_setups();
|
|
38348
|
-
variableNameSchema = external_exports.string().regex(VARIABLE_KEY_RE, "must be a valid environment variable name");
|
|
38349
|
-
mcpValueSchema = external_exports.union([
|
|
38350
|
-
external_exports.string(),
|
|
38351
|
-
environmentMcpVariableReferenceSchema
|
|
38352
|
-
]);
|
|
38353
|
-
mcpValuesSchema = external_exports.record(external_exports.string(), mcpValueSchema);
|
|
38354
|
-
httpConfigSchema = environmentMcpHttpConfigSchema.pick({ url: true, auth: true }).extend({
|
|
38355
|
-
headers: mcpValuesSchema.default({})
|
|
38356
|
-
}).strict();
|
|
38357
|
-
replicasMcpDefinitionSchema = external_exports.discriminatedUnion("transport", [
|
|
38358
|
-
external_exports.strictObject({
|
|
38359
|
-
transport: external_exports.literal("stdio"),
|
|
38360
|
-
config: environmentMcpStdioConfigSchema.pick({ command: true }).extend({
|
|
38361
|
-
args: environmentMcpStdioConfigSchema.shape.args.unwrap().default([]),
|
|
38362
|
-
env: external_exports.record(variableNameSchema, mcpValueSchema).default({})
|
|
38363
|
-
}).strict()
|
|
38364
|
-
}),
|
|
38365
|
-
external_exports.strictObject({ transport: external_exports.literal("http"), config: httpConfigSchema }),
|
|
38366
|
-
external_exports.strictObject({ transport: external_exports.literal("sse"), config: httpConfigSchema })
|
|
38367
|
-
]).superRefine((definition, context) => {
|
|
38368
|
-
if (definition.transport === "stdio") return;
|
|
38369
|
-
const result = validateEnvironmentMcpAuthentication(definition.transport, definition.config);
|
|
38370
|
-
if (!result.ok) context.addIssue({ code: "custom", path: result.error.code === "transport" ? ["transport"] : ["config", result.error.code ?? "auth"], message: result.error.message });
|
|
38371
|
-
});
|
|
38372
|
-
replicasEnvironmentConfigSchema = external_exports.strictObject({
|
|
38373
|
-
systemPrompt: external_exports.string().optional(),
|
|
38374
|
-
warmHook: external_exports.string().optional(),
|
|
38375
|
-
startHook: external_exports.string().optional(),
|
|
38376
|
-
variables: external_exports.record(variableNameSchema, external_exports.string()).optional(),
|
|
38377
|
-
requiredSecrets: external_exports.array(variableNameSchema).optional(),
|
|
38378
|
-
mcps: external_exports.record(external_exports.string().regex(MCP_NAME_PATTERN, "must be 1\u201364 letters, digits, underscores or hyphens, starting with a letter or digit").refine((name) => !isReservedMcpName(name), "is reserved for Replicas"), replicasMcpDefinitionSchema).optional()
|
|
38379
|
-
}).superRefine((config3, context) => {
|
|
38380
|
-
const names = /* @__PURE__ */ new Set();
|
|
38381
|
-
for (const name of Object.keys(config3.mcps ?? {})) {
|
|
38382
|
-
const normalized = name.toLowerCase();
|
|
38383
|
-
if (names.has(normalized)) {
|
|
38384
|
-
context.addIssue({ code: "custom", path: ["mcps", name], message: "MCP names must be unique regardless of case" });
|
|
38385
|
-
}
|
|
38386
|
-
names.add(normalized);
|
|
38387
|
-
}
|
|
38388
|
-
for (const key of config3.requiredSecrets ?? []) {
|
|
38389
|
-
if (config3.variables && Object.hasOwn(config3.variables, key)) {
|
|
38390
|
-
context.addIssue({ code: "custom", path: ["requiredSecrets"], message: `"${key}" cannot also be declared as a non-secret variable` });
|
|
38391
|
-
}
|
|
38392
|
-
}
|
|
38393
|
-
});
|
|
38394
|
-
}
|
|
38395
|
-
});
|
|
38396
|
-
|
|
38397
38455
|
// ../shared/src/replicas-config.ts
|
|
38456
|
+
function isRecord3(value) {
|
|
38457
|
+
return typeof value === "object" && value !== null;
|
|
38458
|
+
}
|
|
38459
|
+
function parseReplicasConfig(value, filename = "replicas.json") {
|
|
38460
|
+
if (!isRecord3(value)) {
|
|
38461
|
+
throw new Error(`Invalid ${filename}: expected an object`);
|
|
38462
|
+
}
|
|
38463
|
+
const config3 = {};
|
|
38464
|
+
if ("infra" in value) {
|
|
38465
|
+
if (typeof value.infra !== "string" || !value.infra.trim()) {
|
|
38466
|
+
throw new Error(`Invalid ${filename}: "infra" must be a non-empty file path`);
|
|
38467
|
+
}
|
|
38468
|
+
if ("environment" in value) throw new Error(`Invalid ${filename}: use either "infra" or "environment", not both`);
|
|
38469
|
+
config3.infra = value.infra;
|
|
38470
|
+
}
|
|
38471
|
+
if ("organizationId" in value) {
|
|
38472
|
+
if (typeof value.organizationId !== "string") {
|
|
38473
|
+
throw new Error(`Invalid ${filename}: "organizationId" must be a string`);
|
|
38474
|
+
}
|
|
38475
|
+
config3.organizationId = value.organizationId;
|
|
38476
|
+
}
|
|
38477
|
+
if ("systemPrompt" in value) {
|
|
38478
|
+
if (typeof value.systemPrompt !== "string") {
|
|
38479
|
+
throw new Error(`Invalid ${filename}: "systemPrompt" must be a string`);
|
|
38480
|
+
}
|
|
38481
|
+
config3.systemPrompt = value.systemPrompt;
|
|
38482
|
+
}
|
|
38483
|
+
if ("startHook" in value) {
|
|
38484
|
+
if (!isRecord3(value.startHook)) {
|
|
38485
|
+
throw new Error(`Invalid ${filename}: "startHook" must be an object with "commands" array`);
|
|
38486
|
+
}
|
|
38487
|
+
const { commands, timeout, separate } = value.startHook;
|
|
38488
|
+
if (!Array.isArray(commands) || !commands.every((entry) => typeof entry === "string")) {
|
|
38489
|
+
throw new Error(`Invalid ${filename}: "startHook.commands" must be an array of shell commands`);
|
|
38490
|
+
}
|
|
38491
|
+
if (timeout !== void 0 && (typeof timeout !== "number" || timeout <= 0)) {
|
|
38492
|
+
throw new Error(`Invalid ${filename}: "startHook.timeout" must be a positive number`);
|
|
38493
|
+
}
|
|
38494
|
+
if (separate !== void 0 && typeof separate !== "boolean") {
|
|
38495
|
+
throw new Error(`Invalid ${filename}: "startHook.separate" must be a boolean`);
|
|
38496
|
+
}
|
|
38497
|
+
config3.startHook = { commands, timeout, separate };
|
|
38498
|
+
}
|
|
38499
|
+
if ("warmHook" in value) {
|
|
38500
|
+
config3.warmHook = parseWarmHookConfig(value.warmHook, filename);
|
|
38501
|
+
}
|
|
38502
|
+
if ("environment" in value) {
|
|
38503
|
+
const parsed = replicasEnvironmentConfigSchema.safeParse(value.environment);
|
|
38504
|
+
if (!parsed.success) {
|
|
38505
|
+
const issue2 = parsed.error.issues[0];
|
|
38506
|
+
throw new Error(`Invalid ${filename}: "environment${issue2.path.length ? `.${issue2.path.join(".")}` : ""}" ${issue2.message}`);
|
|
38507
|
+
}
|
|
38508
|
+
config3.environment = parsed.data;
|
|
38509
|
+
}
|
|
38510
|
+
return config3;
|
|
38511
|
+
}
|
|
38512
|
+
function parseReplicasConfigString(content, filename) {
|
|
38513
|
+
const isYaml = filename.endsWith(".yaml") || filename.endsWith(".yml");
|
|
38514
|
+
let parsed;
|
|
38515
|
+
if (isYaml) {
|
|
38516
|
+
parsed = (0, import_yaml2.parse)(content);
|
|
38517
|
+
} else {
|
|
38518
|
+
parsed = JSON.parse(content);
|
|
38519
|
+
}
|
|
38520
|
+
return parseReplicasConfig(parsed, filename);
|
|
38521
|
+
}
|
|
38522
|
+
async function resolveReplicasEnvironmentConfig(entrypoint, loadInfra) {
|
|
38523
|
+
let selected = entrypoint;
|
|
38524
|
+
if (entrypoint.config.infra) {
|
|
38525
|
+
const target = await loadInfra(entrypoint.config.infra);
|
|
38526
|
+
if (!target.ok) return target;
|
|
38527
|
+
selected = target.data;
|
|
38528
|
+
if (selected.config.infra) return createErrorResult({ message: `${selected.filename}: nested infra pointers are not supported; declare an "environment" section`, code: 400 });
|
|
38529
|
+
}
|
|
38530
|
+
if (!selected.config.environment) return createErrorResult({ message: `${selected.filename} needs an "environment" section before it can manage an environment`, code: 400 });
|
|
38531
|
+
return createSuccessResult({ filename: selected.filename, config: { ...entrypoint.config, environment: selected.config.environment } });
|
|
38532
|
+
}
|
|
38398
38533
|
var import_yaml2, REPLICAS_CONFIG_FILENAMES;
|
|
38399
38534
|
var init_replicas_config = __esm({
|
|
38400
38535
|
"../shared/src/replicas-config.ts"() {
|
|
38401
38536
|
"use strict";
|
|
38402
38537
|
import_yaml2 = __toESM(require_dist());
|
|
38538
|
+
init_result();
|
|
38403
38539
|
init_warm_hooks();
|
|
38404
38540
|
init_environment_config();
|
|
38405
38541
|
REPLICAS_CONFIG_FILENAMES = ["replicas.json", "replicas.yaml", "replicas.yml"];
|
|
@@ -38511,7 +38647,7 @@ var CLI_VERSION;
|
|
|
38511
38647
|
var init_cli_version = __esm({
|
|
38512
38648
|
"../shared/src/cli-version.ts"() {
|
|
38513
38649
|
"use strict";
|
|
38514
|
-
CLI_VERSION = "0.3.
|
|
38650
|
+
CLI_VERSION = "0.3.437";
|
|
38515
38651
|
}
|
|
38516
38652
|
});
|
|
38517
38653
|
|
|
@@ -48713,8 +48849,8 @@ var require_CronFileParser = __commonJS({
|
|
|
48713
48849
|
*/
|
|
48714
48850
|
static async parseFile(filePath) {
|
|
48715
48851
|
var _a3;
|
|
48716
|
-
const { readFile } = await Promise.resolve().then(() => __importStar(require("fs/promises")));
|
|
48717
|
-
const data = await
|
|
48852
|
+
const { readFile: readFile2 } = await Promise.resolve().then(() => __importStar(require("fs/promises")));
|
|
48853
|
+
const data = await readFile2(filePath, "utf8");
|
|
48718
48854
|
return __privateMethod(_a3 = _CronFileParser, _CronFileParser_static, parseContent_fn).call(_a3, data);
|
|
48719
48855
|
}
|
|
48720
48856
|
/**
|
|
@@ -50566,7 +50702,7 @@ async function apiKeyLoginCommand(key) {
|
|
|
50566
50702
|
}
|
|
50567
50703
|
async function loginCommand() {
|
|
50568
50704
|
const state = generateState();
|
|
50569
|
-
return new Promise((
|
|
50705
|
+
return new Promise((resolve4, reject) => {
|
|
50570
50706
|
let authTimeout;
|
|
50571
50707
|
let hasHandledCallback = false;
|
|
50572
50708
|
let lastRedirectUrl = null;
|
|
@@ -50716,7 +50852,7 @@ async function loginCommand() {
|
|
|
50716
50852
|
setImmediate(() => {
|
|
50717
50853
|
server.closeAllConnections?.();
|
|
50718
50854
|
server.close();
|
|
50719
|
-
|
|
50855
|
+
resolve4();
|
|
50720
50856
|
});
|
|
50721
50857
|
} catch (error63) {
|
|
50722
50858
|
const errorUrl = `${WEB_APP_URL}/cli-login/error?message=${encodeURIComponent("Failed to verify authentication.")}`;
|
|
@@ -50982,7 +51118,7 @@ async function waitForUser(params) {
|
|
|
50982
51118
|
let value = params.initial;
|
|
50983
51119
|
const deadline = Date.now() + timeoutMs;
|
|
50984
51120
|
while (!params.settled(value) && Date.now() < deadline) {
|
|
50985
|
-
await new Promise((
|
|
51121
|
+
await new Promise((resolve4) => setTimeout(resolve4, VARIABLE_REQUEST_WAIT.pollMs));
|
|
50986
51122
|
value = await params.poll(true);
|
|
50987
51123
|
}
|
|
50988
51124
|
return params.settled(value) ? value : params.poll(false);
|
|
@@ -51017,7 +51153,7 @@ function buildSSHArgs(token, host, proxyCommand, localForward) {
|
|
|
51017
51153
|
];
|
|
51018
51154
|
}
|
|
51019
51155
|
async function connectSSH(token, host, proxyCommand, localForward) {
|
|
51020
|
-
return new Promise((
|
|
51156
|
+
return new Promise((resolve4, reject) => {
|
|
51021
51157
|
const ssh = (0, import_child_process.spawn)("ssh", buildSSHArgs(token, host, proxyCommand, localForward), {
|
|
51022
51158
|
stdio: "inherit"
|
|
51023
51159
|
});
|
|
@@ -51025,7 +51161,7 @@ async function connectSSH(token, host, proxyCommand, localForward) {
|
|
|
51025
51161
|
if (localForward && code) {
|
|
51026
51162
|
reject(new Error(`SSH tunnel exited with code ${code}`));
|
|
51027
51163
|
} else {
|
|
51028
|
-
|
|
51164
|
+
resolve4();
|
|
51029
51165
|
}
|
|
51030
51166
|
});
|
|
51031
51167
|
ssh.on("error", reject);
|
|
@@ -51600,7 +51736,7 @@ async function exchangeCodeForTokens(code, codeVerifier) {
|
|
|
51600
51736
|
};
|
|
51601
51737
|
}
|
|
51602
51738
|
function startCallbackServer(expectedState, codeVerifier, save) {
|
|
51603
|
-
return new Promise((
|
|
51739
|
+
return new Promise((resolve4, reject) => {
|
|
51604
51740
|
const server = import_http2.default.createServer(async (req, res) => {
|
|
51605
51741
|
try {
|
|
51606
51742
|
if (!req.url) {
|
|
@@ -51644,7 +51780,7 @@ function startCallbackServer(expectedState, codeVerifier, save) {
|
|
|
51644
51780
|
res.writeHead(302, { "Location": completionUrl });
|
|
51645
51781
|
res.end();
|
|
51646
51782
|
server.close();
|
|
51647
|
-
|
|
51783
|
+
resolve4();
|
|
51648
51784
|
} catch (tokenError) {
|
|
51649
51785
|
const errorMessage = encodeURIComponent(tokenError instanceof Error ? tokenError.message : "Unknown error");
|
|
51650
51786
|
res.writeHead(302, { "Location": `${WEB_APP_URL2}/codex/oauth/error?message=${errorMessage}` });
|
|
@@ -51678,7 +51814,7 @@ async function runCodexOAuthFlow(totalSteps, save) {
|
|
|
51678
51814
|
const state = generateState2();
|
|
51679
51815
|
const authUrl = buildAuthorizationUrl(pkce.codeChallenge, state);
|
|
51680
51816
|
const tokensPromise = startCallbackServer(state, pkce.codeVerifier, save);
|
|
51681
|
-
await new Promise((
|
|
51817
|
+
await new Promise((resolve4) => setTimeout(resolve4, 500));
|
|
51682
51818
|
renderAuthFlowStep(1, totalSteps, "Approve access in your browser");
|
|
51683
51819
|
await openForApproval("auth.openai.com", authUrl);
|
|
51684
51820
|
renderAuthFlowDetail("waiting for sign-in\u2026");
|
|
@@ -51862,10 +51998,10 @@ async function promptForAuthorizationCode() {
|
|
|
51862
51998
|
process.stdin.setRawMode(false);
|
|
51863
51999
|
process.stdin.resume();
|
|
51864
52000
|
const rl = import_readline.default.createInterface({ input: process.stdin, output: process.stdout });
|
|
51865
|
-
return new Promise((
|
|
51866
|
-
rl.on("close", () =>
|
|
52001
|
+
return new Promise((resolve4) => {
|
|
52002
|
+
rl.on("close", () => resolve4(""));
|
|
51867
52003
|
rl.question(import_chalk15.default.gray(" Paste code here: "), (answer) => {
|
|
51868
|
-
|
|
52004
|
+
resolve4(answer.trim());
|
|
51869
52005
|
rl.close();
|
|
51870
52006
|
});
|
|
51871
52007
|
});
|
|
@@ -52035,7 +52171,7 @@ async function runMuseOAuthFlow(totalSteps) {
|
|
|
52035
52171
|
const deadline = Date.now() + (typeof device.expires_in === "number" ? device.expires_in : 900) * 1e3;
|
|
52036
52172
|
let intervalMs = Math.max(1, typeof device.interval === "number" ? device.interval : 5) * 1e3;
|
|
52037
52173
|
while (Date.now() < deadline) {
|
|
52038
|
-
await new Promise((
|
|
52174
|
+
await new Promise((resolve4) => setTimeout(resolve4, intervalMs));
|
|
52039
52175
|
const response = await post("/oidc/device/token/", new URLSearchParams({
|
|
52040
52176
|
grant_type: "urn:ietf:params:oauth:grant-type:device_code",
|
|
52041
52177
|
device_code: device.device_code,
|
|
@@ -55333,14 +55469,14 @@ function launchChrome() {
|
|
|
55333
55469
|
}
|
|
55334
55470
|
}
|
|
55335
55471
|
});
|
|
55336
|
-
const send = (method, params = {}, sessionId) => new Promise((
|
|
55472
|
+
const send = (method, params = {}, sessionId) => new Promise((resolve4, reject) => {
|
|
55337
55473
|
if (exitError) return reject(exitError);
|
|
55338
55474
|
const id = nextId++;
|
|
55339
55475
|
const timer = setTimeout(() => {
|
|
55340
55476
|
pending.delete(id);
|
|
55341
55477
|
reject(new Error(`Chrome did not answer ${method} within ${COMMAND_TIMEOUT_MS / 1e3}s`));
|
|
55342
55478
|
}, COMMAND_TIMEOUT_MS);
|
|
55343
|
-
pending.set(id, { resolve:
|
|
55479
|
+
pending.set(id, { resolve: resolve4, reject, timer });
|
|
55344
55480
|
input2.write(`${JSON.stringify({ id, method, params, ...sessionId ? { sessionId } : {} })}\0`);
|
|
55345
55481
|
});
|
|
55346
55482
|
return {
|
|
@@ -55367,7 +55503,7 @@ function launchChrome() {
|
|
|
55367
55503
|
// Callers exit the process right after, and Chrome's helper processes write into the profile until Chrome exits.
|
|
55368
55504
|
async close() {
|
|
55369
55505
|
if (child.exitCode === null && child.signalCode === null) {
|
|
55370
|
-
const exited = new Promise((
|
|
55506
|
+
const exited = new Promise((resolve4) => child.once("exit", resolve4));
|
|
55371
55507
|
const kill = setTimeout(() => child.kill("SIGKILL"), CLOSE_TIMEOUT_MS);
|
|
55372
55508
|
send("Browser.close").catch(() => child.kill("SIGKILL"));
|
|
55373
55509
|
await exited;
|
|
@@ -55423,21 +55559,21 @@ async function servePage(html) {
|
|
|
55423
55559
|
response.writeHead(200, { "Content-Type": "text/html; charset=utf-8", "Content-Security-Policy": "sandbox allow-scripts" });
|
|
55424
55560
|
response.end(html);
|
|
55425
55561
|
});
|
|
55426
|
-
await new Promise((
|
|
55562
|
+
await new Promise((resolve4) => server.listen(0, "127.0.0.1", resolve4));
|
|
55427
55563
|
const address = server.address();
|
|
55428
55564
|
const origin = `http://127.0.0.1:${typeof address === "object" && address ? address.port : 0}`;
|
|
55429
55565
|
return { server, pageUrl: `${origin}/page.html`, fontUrl: font ? `${origin}${VISUAL_FONT_PATH}` : void 0 };
|
|
55430
55566
|
}
|
|
55431
55567
|
function waitFor(page, method, timeoutMs) {
|
|
55432
|
-
return new Promise((
|
|
55568
|
+
return new Promise((resolve4) => {
|
|
55433
55569
|
const stop = page.on(method, () => {
|
|
55434
55570
|
clearTimeout(timer);
|
|
55435
55571
|
stop();
|
|
55436
|
-
|
|
55572
|
+
resolve4(true);
|
|
55437
55573
|
});
|
|
55438
55574
|
const timer = setTimeout(() => {
|
|
55439
55575
|
stop();
|
|
55440
|
-
|
|
55576
|
+
resolve4(false);
|
|
55441
55577
|
}, timeoutMs);
|
|
55442
55578
|
});
|
|
55443
55579
|
}
|
|
@@ -55886,11 +56022,11 @@ var init_gpu2 = __esm({
|
|
|
55886
56022
|
// src/commands/environment-config.ts
|
|
55887
56023
|
function printSource({ source }) {
|
|
55888
56024
|
if (!source) {
|
|
55889
|
-
console.log("No
|
|
56025
|
+
console.log("No configuration source. Use replicas environment config apply <env> --file <path>, or config link with --repository.");
|
|
55890
56026
|
return;
|
|
55891
56027
|
}
|
|
55892
|
-
console.log(`${source.repository_name}/${source.filename} @ ${source.commit_sha}`);
|
|
55893
|
-
console.log(source.source_url);
|
|
56028
|
+
console.log(source.kind === "file" ? `${source.filename} @ ${source.file_sha}` : `${source.repository_name}/${source.filename} @ ${source.commit_sha}`);
|
|
56029
|
+
if (source.source_url) console.log(source.source_url);
|
|
55894
56030
|
console.log(`Synced: ${source.synced_at}`);
|
|
55895
56031
|
console.log(`Managed settings: ${source.managed.fields.join(", ") || "(none)"}`);
|
|
55896
56032
|
console.log(`Managed variables: ${source.managed.variables.join(", ") || "(none)"}`);
|
|
@@ -55900,19 +56036,30 @@ function printSource({ source }) {
|
|
|
55900
56036
|
if (source.last_error) console.log(import_chalk29.default.red(source.last_error));
|
|
55901
56037
|
}
|
|
55902
56038
|
function printPreview({ preview: preview2 }) {
|
|
55903
|
-
console.log(`${preview2.repository_name}/${preview2.filename} @ ${preview2.commit_sha}`);
|
|
55904
|
-
console.log(preview2.source_url);
|
|
55905
|
-
if (!preview2.changes.length) console.log("No setting changes. Applying records this
|
|
56039
|
+
console.log(preview2.kind === "file" ? `${preview2.filename} @ ${preview2.file_sha}` : `${preview2.repository_name}/${preview2.filename} @ ${preview2.commit_sha}`);
|
|
56040
|
+
if (preview2.source_url) console.log(preview2.source_url);
|
|
56041
|
+
if (!preview2.changes.length) console.log("No setting changes. Applying records this configuration.");
|
|
55906
56042
|
for (const change of preview2.changes) console.log(` ${change.operation}: ${change.kind} ${change.key}`);
|
|
55907
56043
|
if (preview2.missing_secrets.length) console.log(import_chalk29.default.yellow(`Missing required secrets: ${preview2.missing_secrets.join(", ")}`));
|
|
55908
56044
|
for (const blocker of preview2.blockers) console.log(import_chalk29.default.red(` Cannot apply: ${blocker}`));
|
|
55909
56045
|
}
|
|
55910
|
-
async function
|
|
55911
|
-
|
|
55912
|
-
|
|
55913
|
-
|
|
55914
|
-
|
|
55915
|
-
|
|
56046
|
+
async function sourceInput2(options) {
|
|
56047
|
+
if (options.file && options.repository) throw new Error("Choose either --file or --repository");
|
|
56048
|
+
if (options.file) {
|
|
56049
|
+
const filename = options.file;
|
|
56050
|
+
const config3 = parseReplicasConfigString(await (0, import_promises2.readFile)(filename, "utf8"), filename);
|
|
56051
|
+
const result = await resolveReplicasEnvironmentConfig({ filename, config: config3 }, async (pointer) => {
|
|
56052
|
+
const target = (0, import_node_path3.resolve)((0, import_node_path3.dirname)(filename), pointer);
|
|
56053
|
+
return createSuccessResult({ filename: target, config: parseReplicasConfigString(await (0, import_promises2.readFile)(target, "utf8"), target) });
|
|
56054
|
+
});
|
|
56055
|
+
if (!result.ok) throw new Error(result.error.message);
|
|
56056
|
+
return { file: { filename: result.data.filename, environment: result.data.config.environment } };
|
|
56057
|
+
}
|
|
56058
|
+
const [repositoryId] = options.repository ? await resolveRepositoryIds([options.repository]) : [];
|
|
56059
|
+
return repositoryId ? { repository_id: repositoryId } : {};
|
|
56060
|
+
}
|
|
56061
|
+
async function previewSource(id, input2) {
|
|
56062
|
+
return orgAuthenticatedFetch(`/v1/environments/${id}/config-source/preview`, { method: "POST", body: input2 });
|
|
55916
56063
|
}
|
|
55917
56064
|
async function environmentConfigGetCommand(environment2) {
|
|
55918
56065
|
ensureOrgApiAuthenticated();
|
|
@@ -55921,12 +56068,14 @@ async function environmentConfigGetCommand(environment2) {
|
|
|
55921
56068
|
}
|
|
55922
56069
|
async function environmentConfigPreviewCommand(environment2, options) {
|
|
55923
56070
|
ensureOrgApiAuthenticated();
|
|
55924
|
-
|
|
56071
|
+
const input2 = await sourceInput2(options);
|
|
56072
|
+
output2(await previewSource(await resolveEnvironmentId(environment2), input2), printPreview);
|
|
55925
56073
|
}
|
|
55926
56074
|
async function applySource(environment2, options, operation) {
|
|
55927
56075
|
ensureOrgApiAuthenticated();
|
|
55928
56076
|
const id = await resolveEnvironmentId(environment2);
|
|
55929
|
-
const
|
|
56077
|
+
const input2 = await sourceInput2(options);
|
|
56078
|
+
const response = await previewSource(id, input2);
|
|
55930
56079
|
if (!isJsonMode()) printPreview(response);
|
|
55931
56080
|
const { preview: preview2 } = response;
|
|
55932
56081
|
if (preview2.blockers.length || preview2.missing_secrets.length) {
|
|
@@ -55939,9 +56088,13 @@ async function applySource(environment2, options, operation) {
|
|
|
55939
56088
|
if (!isInteractive()) throw new Error("Preview the changes with replicas environment config preview, then pass --yes to apply without a terminal.");
|
|
55940
56089
|
if (!await confirmAction(`${operation === "link" ? "Link and apply" : "Apply"} this configuration to ${environment2}?`)) return;
|
|
55941
56090
|
}
|
|
55942
|
-
|
|
56091
|
+
if (options.file && JSON.stringify(await sourceInput2(options)) !== JSON.stringify(input2)) throw new Error("The configuration file changed after preview. Preview it again before applying");
|
|
56092
|
+
const body = { ...preview2.kind !== "file" ? { repository_id: preview2.repository_id, commit_sha: preview2.commit_sha } : input2, fingerprint: preview2.fingerprint };
|
|
55943
56093
|
output2(await orgAuthenticatedFetch(`/v1/environments/${id}/config-source${operation === "sync" ? "/sync" : ""}`, { method: "POST", body }), printSource);
|
|
55944
56094
|
}
|
|
56095
|
+
async function environmentConfigApplyCommand(environment2, options) {
|
|
56096
|
+
await applySource(environment2, options, "file");
|
|
56097
|
+
}
|
|
55945
56098
|
async function environmentConfigLinkCommand(environment2, options) {
|
|
55946
56099
|
await applySource(environment2, options, "link");
|
|
55947
56100
|
}
|
|
@@ -55953,17 +56106,20 @@ async function environmentConfigDisconnectCommand(environment2, options) {
|
|
|
55953
56106
|
const id = await resolveEnvironmentId(environment2);
|
|
55954
56107
|
if (!options.yes) {
|
|
55955
56108
|
if (!isInteractive()) throw new Error("Pass --yes to disconnect without a terminal. Current settings will be preserved.");
|
|
55956
|
-
if (!await confirmAction(`Disconnect
|
|
56109
|
+
if (!await confirmAction(`Disconnect configuration source for ${environment2}? Current settings will be preserved.`)) return;
|
|
55957
56110
|
}
|
|
55958
56111
|
output2(await orgAuthenticatedFetch(`/v1/environments/${id}/config-source`, { method: "DELETE" }), () => {
|
|
55959
|
-
console.log("
|
|
56112
|
+
console.log("Configuration source disconnected. Current settings preserved.");
|
|
55960
56113
|
});
|
|
55961
56114
|
}
|
|
55962
|
-
var import_chalk29;
|
|
56115
|
+
var import_chalk29, import_promises2, import_node_path3;
|
|
55963
56116
|
var init_environment_config2 = __esm({
|
|
55964
56117
|
"src/commands/environment-config.ts"() {
|
|
55965
56118
|
"use strict";
|
|
55966
56119
|
import_chalk29 = __toESM(require("chalk"));
|
|
56120
|
+
import_promises2 = require("fs/promises");
|
|
56121
|
+
import_node_path3 = require("path");
|
|
56122
|
+
init_src();
|
|
55967
56123
|
init_api2();
|
|
55968
56124
|
init_command_utils();
|
|
55969
56125
|
init_output();
|
|
@@ -55979,18 +56135,18 @@ async function historyTranscriptCommand(name) {
|
|
|
55979
56135
|
throw new Error(`Invalid session name '${name}'. Use the name from INDEX.md, e.g. 2026-01-31-<id>`);
|
|
55980
56136
|
}
|
|
55981
56137
|
const response = await agentRequest(`/v1/engine/history/transcripts/${session}`);
|
|
55982
|
-
const dir = (0,
|
|
56138
|
+
const dir = (0, import_node_path4.join)(HISTORY_ROOT, "transcripts");
|
|
55983
56139
|
(0, import_node_fs3.mkdirSync)(dir, { recursive: true });
|
|
55984
|
-
const file2 = (0,
|
|
56140
|
+
const file2 = (0, import_node_path4.join)(dir, `${session}.jsonl`);
|
|
55985
56141
|
(0, import_node_fs3.writeFileSync)(file2, Buffer.from(await response.arrayBuffer()));
|
|
55986
56142
|
output2({ path: file2 }, () => console.log(file2));
|
|
55987
56143
|
}
|
|
55988
|
-
var import_node_fs3,
|
|
56144
|
+
var import_node_fs3, import_node_path4;
|
|
55989
56145
|
var init_history = __esm({
|
|
55990
56146
|
"src/commands/history.ts"() {
|
|
55991
56147
|
"use strict";
|
|
55992
56148
|
import_node_fs3 = require("fs");
|
|
55993
|
-
|
|
56149
|
+
import_node_path4 = require("path");
|
|
55994
56150
|
init_src();
|
|
55995
56151
|
init_agent_api();
|
|
55996
56152
|
init_output();
|
|
@@ -56120,7 +56276,7 @@ function tailLines(content, lines) {
|
|
|
56120
56276
|
return all.slice(-lines).join("\n").trim();
|
|
56121
56277
|
}
|
|
56122
56278
|
function statePath(name) {
|
|
56123
|
-
return (0,
|
|
56279
|
+
return (0, import_node_path5.join)(SERVICES_DIR, `${name}.json`);
|
|
56124
56280
|
}
|
|
56125
56281
|
function isServiceState(value) {
|
|
56126
56282
|
if (typeof value !== "object" || value === null) return false;
|
|
@@ -56190,8 +56346,8 @@ async function serviceStartCommand(name, commandParts, options) {
|
|
|
56190
56346
|
await killServiceGroup(existing.pid);
|
|
56191
56347
|
}
|
|
56192
56348
|
(0, import_node_fs5.mkdirSync)(SERVICES_DIR, { recursive: true });
|
|
56193
|
-
const cwd = (0,
|
|
56194
|
-
const logFile = (0,
|
|
56349
|
+
const cwd = (0, import_node_path5.resolve)(options.cwd ?? process.cwd());
|
|
56350
|
+
const logFile = (0, import_node_path5.join)(SERVICES_DIR, `${name}.log`);
|
|
56195
56351
|
const logFd = (0, import_node_fs5.openSync)(logFile, "a");
|
|
56196
56352
|
(0, import_node_fs5.writeFileSync)(logFd, `
|
|
56197
56353
|
=== [replicas service] "${name}" started ${(/* @__PURE__ */ new Date()).toISOString()} in ${cwd}: ${command} ===
|
|
@@ -56277,7 +56433,7 @@ async function serviceLogsCommand(name, options) {
|
|
|
56277
56433
|
console.log(logs || "(no log output yet)");
|
|
56278
56434
|
});
|
|
56279
56435
|
}
|
|
56280
|
-
var import_chalk32, import_node_child_process3, import_node_fs5, import_node_os3,
|
|
56436
|
+
var import_chalk32, import_node_child_process3, import_node_fs5, import_node_os3, import_node_path5, SERVICES_DIR, NAME_PATTERN, LOG_KEEP_BYTES, LOG_TRIM_LOOP;
|
|
56281
56437
|
var init_service = __esm({
|
|
56282
56438
|
"src/commands/service.ts"() {
|
|
56283
56439
|
"use strict";
|
|
@@ -56285,10 +56441,10 @@ var init_service = __esm({
|
|
|
56285
56441
|
import_node_child_process3 = require("child_process");
|
|
56286
56442
|
import_node_fs5 = require("fs");
|
|
56287
56443
|
import_node_os3 = require("os");
|
|
56288
|
-
|
|
56444
|
+
import_node_path5 = require("path");
|
|
56289
56445
|
init_src();
|
|
56290
56446
|
init_output();
|
|
56291
|
-
SERVICES_DIR = (0,
|
|
56447
|
+
SERVICES_DIR = (0, import_node_path5.join)((0, import_node_os3.homedir)(), ".replicas", "services");
|
|
56292
56448
|
NAME_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9._-]*$/;
|
|
56293
56449
|
LOG_KEEP_BYTES = 5 * 1024 * 1024;
|
|
56294
56450
|
LOG_TRIM_LOOP = `trim() { ${trimLogTailCommand('"$1"', 10 * 1024 * 1024, LOG_KEEP_BYTES)}; }
|
|
@@ -56384,17 +56540,17 @@ async function deviceConnectCommand() {
|
|
|
56384
56540
|
const next = problem ?? `\u2713 ${device?.name}: ready for ${waiting.size} ${waiting.size === 1 ? "workspace" : "workspaces"}, forwarding to SSH on port ${port}`;
|
|
56385
56541
|
if (next !== summary) console.log(problem ? import_chalk33.default.yellow(next) : import_chalk33.default.green(next));
|
|
56386
56542
|
summary = next;
|
|
56387
|
-
await (0,
|
|
56543
|
+
await (0, import_promises3.setTimeout)(POLL_INTERVAL_MS);
|
|
56388
56544
|
}
|
|
56389
56545
|
}
|
|
56390
|
-
var import_chalk33, import_node_child_process4, import_node_net,
|
|
56546
|
+
var import_chalk33, import_node_child_process4, import_node_net, import_promises3, import_node_util, import_ws, POLL_INTERVAL_MS, HEARTBEAT_MS, MAX_RETRY_DELAY_MS, REMOTE_LOGIN_HINT;
|
|
56391
56547
|
var init_device = __esm({
|
|
56392
56548
|
"src/commands/device.ts"() {
|
|
56393
56549
|
"use strict";
|
|
56394
56550
|
import_chalk33 = __toESM(require("chalk"));
|
|
56395
56551
|
import_node_child_process4 = require("child_process");
|
|
56396
56552
|
import_node_net = require("net");
|
|
56397
|
-
|
|
56553
|
+
import_promises3 = require("timers/promises");
|
|
56398
56554
|
import_node_util = require("util");
|
|
56399
56555
|
import_ws = __toESM(require("ws"));
|
|
56400
56556
|
init_src();
|
|
@@ -56719,7 +56875,8 @@ var init_src2 = __esm({
|
|
|
56719
56875
|
environment.command("delete <id-or-name>").description("Delete an environment").option("-f, --force", "Skip confirmation prompt").action(run(environmentDeleteCommand));
|
|
56720
56876
|
envConfig = environment.command("config").description("Link and sync environment configuration from Git");
|
|
56721
56877
|
envConfig.command("get <env>").description("Show the linked configuration source and sync status").action(run(environmentConfigGetCommand));
|
|
56722
|
-
envConfig.command("preview <env>").description("Preview
|
|
56878
|
+
envConfig.command("preview <env>").description("Preview configuration changes from Git or a local file without applying them").option("--file <path>", "Read the environment block from a local JSON or YAML file").option("-r, --repository <name-or-id>", "Repository containing the configuration").action(run(environmentConfigPreviewCommand));
|
|
56879
|
+
envConfig.command("apply <env>").description("Preview and apply environment configuration from a local file").requiredOption("--file <path>", "Read the environment block from a local JSON or YAML file").option("-y, --yes", "Apply the preview without a confirmation prompt").action(run(environmentConfigApplyCommand));
|
|
56723
56880
|
envConfig.command("link <env>").description("Preview, link, and apply configuration from a repository").option("-r, --repository <name-or-id>", "Repository containing the configuration").option("-y, --yes", "Apply the preview without a confirmation prompt").action(run(environmentConfigLinkCommand));
|
|
56724
56881
|
envConfig.command("sync <env>").description("Preview and apply changes from the linked configuration").option("-y, --yes", "Apply the preview without a confirmation prompt").action(run(environmentConfigSyncCommand));
|
|
56725
56882
|
envConfig.command("disconnect <env>").description("Disconnect Git configuration and preserve current settings").option("-y, --yes", "Disconnect without a confirmation prompt").action(run(environmentConfigDisconnectCommand));
|