replicas-cli 0.3.429 → 0.3.430
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 +437 -234
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -22942,10 +22942,11 @@ var init_types5 = __esm({
|
|
|
22942
22942
|
});
|
|
22943
22943
|
|
|
22944
22944
|
// ../shared/src/subagent-mcp.ts
|
|
22945
|
-
var SUBAGENT_MCP_TOOLS, SUBAGENT_MCP_TOOL_NAMES;
|
|
22945
|
+
var SUBAGENT_MCP_SERVER_NAME, SUBAGENT_MCP_TOOLS, SUBAGENT_MCP_TOOL_NAMES;
|
|
22946
22946
|
var init_subagent_mcp = __esm({
|
|
22947
22947
|
"../shared/src/subagent-mcp.ts"() {
|
|
22948
22948
|
"use strict";
|
|
22949
|
+
SUBAGENT_MCP_SERVER_NAME = "subagents";
|
|
22949
22950
|
SUBAGENT_MCP_TOOLS = {
|
|
22950
22951
|
getProviders: "get_providers",
|
|
22951
22952
|
spawnAgent: "spawn_agent",
|
|
@@ -23027,26 +23028,256 @@ var init_workspace_identity = __esm({
|
|
|
23027
23028
|
}
|
|
23028
23029
|
});
|
|
23029
23030
|
|
|
23031
|
+
// ../shared/src/format.ts
|
|
23032
|
+
function relativeParts(input2, now = Date.now()) {
|
|
23033
|
+
const then = new Date(input2).getTime();
|
|
23034
|
+
if (Number.isNaN(then)) return null;
|
|
23035
|
+
const seconds = Math.max(0, Math.floor((now - then) / 1e3));
|
|
23036
|
+
const minutes = Math.floor(seconds / 60);
|
|
23037
|
+
const hours = Math.floor(minutes / 60);
|
|
23038
|
+
const days = Math.floor(hours / 24);
|
|
23039
|
+
const months = Math.floor(days / 30);
|
|
23040
|
+
return { then, seconds, minutes, hours, days, months, years: Math.floor(months / 12) };
|
|
23041
|
+
}
|
|
23042
|
+
function compactTimeAgo(input2, options) {
|
|
23043
|
+
const p = relativeParts(input2, options?.now);
|
|
23044
|
+
if (!p) return "";
|
|
23045
|
+
if (p.seconds < 60) return options?.seconds === false ? "now" : `${p.seconds}s`;
|
|
23046
|
+
if (p.minutes < 60) return `${p.minutes}m`;
|
|
23047
|
+
if (p.hours < 24) return `${p.hours}h`;
|
|
23048
|
+
if (p.days < 30) return `${p.days}d`;
|
|
23049
|
+
if (p.months < 12) return `${p.months}mo`;
|
|
23050
|
+
return `${p.years}y`;
|
|
23051
|
+
}
|
|
23052
|
+
function formatCompactRelativeTime(input2, now = Date.now()) {
|
|
23053
|
+
const then = new Date(input2).getTime();
|
|
23054
|
+
if (Number.isNaN(then)) return "";
|
|
23055
|
+
if (Math.abs(then - now) < 6e4) return "just now";
|
|
23056
|
+
const future = then > now;
|
|
23057
|
+
const compact = compactTimeAgo(future ? now - (then - now) : then, { now });
|
|
23058
|
+
return future ? `in ${compact}` : `${compact} ago`;
|
|
23059
|
+
}
|
|
23060
|
+
var init_format = __esm({
|
|
23061
|
+
"../shared/src/format.ts"() {
|
|
23062
|
+
"use strict";
|
|
23063
|
+
}
|
|
23064
|
+
});
|
|
23065
|
+
|
|
23066
|
+
// ../shared/src/routes/environment-setups.ts
|
|
23067
|
+
function isEnvironmentSetupStepKey(value) {
|
|
23068
|
+
return ENVIRONMENT_SETUP_STEPS.some((step) => step.key === value);
|
|
23069
|
+
}
|
|
23070
|
+
function isEnvironmentSetupStepStatus(value) {
|
|
23071
|
+
return ENVIRONMENT_SETUP_STEP_STATUSES.some((status) => status === value);
|
|
23072
|
+
}
|
|
23073
|
+
function isEnvironmentSetupAuthoredTriggerType(type) {
|
|
23074
|
+
return ENVIRONMENT_SETUP_AUTHORED_TRIGGER_TYPES.some((authored) => authored === type);
|
|
23075
|
+
}
|
|
23076
|
+
function automationSchema(limits) {
|
|
23077
|
+
const authored = external_exports.object({
|
|
23078
|
+
name: text2(limits.nameChars),
|
|
23079
|
+
description: text2(limits.descriptionChars),
|
|
23080
|
+
prompt: text2(limits.automationPromptChars),
|
|
23081
|
+
triggers: list(proposalTriggerSchema, limits.automationTriggers)
|
|
23082
|
+
});
|
|
23083
|
+
const updated = authored.extend({ triggers: list(external_exports.union([proposalTriggerSchema, carriedTriggerSchema]), limits.automationTriggers) });
|
|
23084
|
+
return external_exports.object({
|
|
23085
|
+
key: requiredText(limits.automationKeyChars),
|
|
23086
|
+
action: external_exports.enum(ENVIRONMENT_SETUP_AUTOMATION_ACTIONS).default("create"),
|
|
23087
|
+
automation_id: external_exports.string().regex(UUID_RE, "must be an automation id").nullable().default(null),
|
|
23088
|
+
name: text2().default(""),
|
|
23089
|
+
description: optionalText2().transform((value) => value ?? ""),
|
|
23090
|
+
prompt: text2().default(""),
|
|
23091
|
+
triggers: list(existingTriggerSchema).default([]),
|
|
23092
|
+
note: optionalText2(limits.automationNoteChars)
|
|
23093
|
+
}).superRefine((automation2, ctx) => {
|
|
23094
|
+
if (automation2.action === "create" && automation2.automation_id) {
|
|
23095
|
+
ctx.addIssue({ code: "custom", path: ["automation_id"], message: "belongs on an update, keep, or disable entry" });
|
|
23096
|
+
}
|
|
23097
|
+
if (automation2.action !== "create" && !automation2.automation_id) {
|
|
23098
|
+
ctx.addIssue({ code: "custom", path: ["automation_id"], message: "must be the id of an automation attached to this environment" });
|
|
23099
|
+
}
|
|
23100
|
+
if (automation2.action === "create" || automation2.action === "update") {
|
|
23101
|
+
if (!automation2.name) ctx.addIssue({ code: "custom", path: ["name"], message: "must not be empty" });
|
|
23102
|
+
if (!automation2.prompt) ctx.addIssue({ code: "custom", path: ["prompt"], message: "must not be empty" });
|
|
23103
|
+
if (automation2.triggers.length === 0) ctx.addIssue({ code: "custom", path: ["triggers"], message: "must not be empty" });
|
|
23104
|
+
}
|
|
23105
|
+
}).transform((automation2, ctx) => {
|
|
23106
|
+
if (automation2.action === "keep" || automation2.action === "disable") return automation2;
|
|
23107
|
+
const content = (automation2.action === "update" ? updated : authored).safeParse(automation2);
|
|
23108
|
+
if (content.success) return { ...automation2, ...content.data };
|
|
23109
|
+
for (const issue2 of content.error.issues) ctx.addIssue({ ...issue2, code: "custom" });
|
|
23110
|
+
return external_exports.NEVER;
|
|
23111
|
+
});
|
|
23112
|
+
}
|
|
23113
|
+
function automationListSchema(limits) {
|
|
23114
|
+
return list(automationSchema(limits)).default([]).superRefine((automations, ctx) => {
|
|
23115
|
+
if (new Set(automations.map((automation2) => automation2.key)).size !== automations.length) {
|
|
23116
|
+
ctx.addIssue({ code: "custom", message: "must have unique keys" });
|
|
23117
|
+
}
|
|
23118
|
+
const targets = automations.flatMap((automation2) => automation2.automation_id ?? []);
|
|
23119
|
+
if (new Set(targets).size !== targets.length) {
|
|
23120
|
+
ctx.addIssue({ code: "custom", message: "must mention each existing automation once" });
|
|
23121
|
+
}
|
|
23122
|
+
if (limits.automations !== void 0 && automations.filter((automation2) => automation2.action === "create").length > limits.automations) {
|
|
23123
|
+
ctx.addIssue({ code: "custom", message: `must create at most ${limits.automations} new automations` });
|
|
23124
|
+
}
|
|
23125
|
+
});
|
|
23126
|
+
}
|
|
23127
|
+
function environmentSchema(limits) {
|
|
23128
|
+
return external_exports.object({
|
|
23129
|
+
name: optionalText2(limits.nameChars).transform((value) => value ?? void 0),
|
|
23130
|
+
description: clearableText(limits.descriptionChars),
|
|
23131
|
+
system_prompt: clearableText(limits.systemPromptChars),
|
|
23132
|
+
start_hook: clearableText(limits.hookChars),
|
|
23133
|
+
warm_hook: clearableText(limits.hookChars)
|
|
23134
|
+
});
|
|
23135
|
+
}
|
|
23136
|
+
function proposalSchema(limits) {
|
|
23137
|
+
return external_exports.object({
|
|
23138
|
+
summary: requiredText(limits.summaryChars),
|
|
23139
|
+
stack: list(text2(), limits.stackItems).default([]).transform((items) => items.filter(Boolean)),
|
|
23140
|
+
environment: environmentSchema(limits),
|
|
23141
|
+
variables: list(external_exports.object({
|
|
23142
|
+
key: external_exports.string().regex(VARIABLE_KEY_RE, "must be a valid environment variable name").max(limits.variableKeyChars ?? Number.POSITIVE_INFINITY),
|
|
23143
|
+
description: optionalText2(limits.variableDescriptionChars).transform((value) => value ?? ""),
|
|
23144
|
+
required: external_exports.boolean().default(false)
|
|
23145
|
+
}), limits.variables).default([]),
|
|
23146
|
+
automations: automationListSchema(limits),
|
|
23147
|
+
verification: list(external_exports.object({
|
|
23148
|
+
label: requiredText(limits.nameChars),
|
|
23149
|
+
status: external_exports.enum(ENVIRONMENT_SETUP_VERIFICATION_STATUSES),
|
|
23150
|
+
detail: optionalText2(limits.verificationDetailChars).transform((value) => value ?? void 0)
|
|
23151
|
+
}), limits.verificationItems).default([]),
|
|
23152
|
+
media: list(external_exports.object({
|
|
23153
|
+
media_id: external_exports.string().regex(UUID_RE, "must be a media id"),
|
|
23154
|
+
title: requiredText(limits.nameChars)
|
|
23155
|
+
}), limits.mediaItems).default([])
|
|
23156
|
+
});
|
|
23157
|
+
}
|
|
23158
|
+
var ENVIRONMENT_SETUP_STEPS, ENVIRONMENT_SETUP_STEP_STATUSES, ENVIRONMENT_SETUP_RUN_STATUSES, ENVIRONMENT_SETUP_AUTOMATION_ACTIONS, ENVIRONMENT_SETUP_VERIFICATION_STATUSES, ENVIRONMENT_SETUP_LIMITS, VARIABLE_KEY_RE, text2, requiredText, optionalText2, clearableText, list, ENVIRONMENT_SETUP_AUTHORED_TRIGGER_TYPES, proposalTriggerSchema, existingTriggerSchema, carriedTriggerSchema, environmentSetupProposalSchema, environmentSetupProposalSubmissionSchema, environmentSetupRunStateSchema, applyEnvironmentSetupRequestSchema;
|
|
23159
|
+
var init_environment_setups = __esm({
|
|
23160
|
+
"../shared/src/routes/environment-setups.ts"() {
|
|
23161
|
+
"use strict";
|
|
23162
|
+
init_zod();
|
|
23163
|
+
init_trigger_schemas();
|
|
23164
|
+
init_format();
|
|
23165
|
+
init_type_guards();
|
|
23166
|
+
init_uuid();
|
|
23167
|
+
ENVIRONMENT_SETUP_STEPS = [
|
|
23168
|
+
{ key: "understand", label: "Understand the codebase" },
|
|
23169
|
+
{ key: "install", label: "Install dependencies and run the app" },
|
|
23170
|
+
{ key: "verify", label: "Verify checks and record a walkthrough" },
|
|
23171
|
+
{ key: "configure", label: "Draft hooks, system prompt, and automations" },
|
|
23172
|
+
{ key: "propose", label: "Propose the configuration for review" }
|
|
23173
|
+
];
|
|
23174
|
+
ENVIRONMENT_SETUP_STEP_STATUSES = ["pending", "in_progress", "completed", "skipped"];
|
|
23175
|
+
ENVIRONMENT_SETUP_RUN_STATUSES = ["running", "proposed", "applied", "failed", "cancelled", "expired"];
|
|
23176
|
+
ENVIRONMENT_SETUP_AUTOMATION_ACTIONS = ["create", "update", "keep", "disable"];
|
|
23177
|
+
ENVIRONMENT_SETUP_VERIFICATION_STATUSES = ["passed", "failed", "skipped"];
|
|
23178
|
+
ENVIRONMENT_SETUP_LIMITS = {
|
|
23179
|
+
summaryChars: 600,
|
|
23180
|
+
stackItems: 30,
|
|
23181
|
+
nameChars: 120,
|
|
23182
|
+
descriptionChars: 1e3,
|
|
23183
|
+
systemPromptChars: 2e4,
|
|
23184
|
+
hookChars: 5e4,
|
|
23185
|
+
variables: 50,
|
|
23186
|
+
variableKeyChars: 128,
|
|
23187
|
+
variableDescriptionChars: 500,
|
|
23188
|
+
automations: 8,
|
|
23189
|
+
automationKeyChars: 80,
|
|
23190
|
+
automationPromptChars: 1e4,
|
|
23191
|
+
automationTriggers: 5,
|
|
23192
|
+
automationNoteChars: 300,
|
|
23193
|
+
verificationItems: 8,
|
|
23194
|
+
verificationDetailChars: 300,
|
|
23195
|
+
mediaItems: 8,
|
|
23196
|
+
repositories: 20
|
|
23197
|
+
};
|
|
23198
|
+
VARIABLE_KEY_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
23199
|
+
text2 = (max) => max === void 0 ? external_exports.string().trim() : external_exports.string().trim().max(max);
|
|
23200
|
+
requiredText = (max) => text2(max).min(1, "must not be empty");
|
|
23201
|
+
optionalText2 = (max) => text2(max).nullish().transform((value) => value || null);
|
|
23202
|
+
clearableText = (max) => text2(max).nullish().transform((value) => value === void 0 ? void 0 : value || null);
|
|
23203
|
+
list = (item, max) => max === void 0 ? external_exports.array(item) : external_exports.array(item).max(max);
|
|
23204
|
+
ENVIRONMENT_SETUP_AUTHORED_TRIGGER_TYPES = ["cron", "github", "gitlab"];
|
|
23205
|
+
proposalTriggerSchema = external_exports.discriminatedUnion("type", [cronTriggerSchema, githubTriggerSchema, gitlabTriggerSchema]);
|
|
23206
|
+
existingTriggerSchema = external_exports.custom(
|
|
23207
|
+
(value) => isRecord(value) && typeof value.type === "string" && isRecord(value.config),
|
|
23208
|
+
"must be an automation trigger"
|
|
23209
|
+
);
|
|
23210
|
+
carriedTriggerSchema = existingTriggerSchema.refine(
|
|
23211
|
+
(trigger) => !isEnvironmentSetupAuthoredTriggerType(trigger.type)
|
|
23212
|
+
);
|
|
23213
|
+
environmentSetupProposalSchema = proposalSchema({});
|
|
23214
|
+
environmentSetupProposalSubmissionSchema = proposalSchema(ENVIRONMENT_SETUP_LIMITS);
|
|
23215
|
+
environmentSetupRunStateSchema = external_exports.object({
|
|
23216
|
+
status: external_exports.enum(ENVIRONMENT_SETUP_RUN_STATUSES),
|
|
23217
|
+
steps: external_exports.partialRecord(external_exports.enum(ENVIRONMENT_SETUP_STEPS.map((step) => step.key)), external_exports.enum(ENVIRONMENT_SETUP_STEP_STATUSES)).default({}),
|
|
23218
|
+
proposal: environmentSetupProposalSchema.nullable().default(null),
|
|
23219
|
+
applied: external_exports.object({
|
|
23220
|
+
applied_at: external_exports.string(),
|
|
23221
|
+
automation_ids: external_exports.array(external_exports.string())
|
|
23222
|
+
}).nullable().default(null)
|
|
23223
|
+
});
|
|
23224
|
+
applyEnvironmentSetupRequestSchema = external_exports.object({
|
|
23225
|
+
environment: environmentSchema(ENVIRONMENT_SETUP_LIMITS).extend({ name: requiredText(ENVIRONMENT_SETUP_LIMITS.nameChars) }),
|
|
23226
|
+
variables: list(external_exports.object({ key: external_exports.string().regex(VARIABLE_KEY_RE), value: external_exports.string() }), ENVIRONMENT_SETUP_LIMITS.variables).default([]).refine((variables) => new Set(variables.map((variable) => variable.key)).size === variables.length, "must have unique keys").transform((variables) => variables.filter((variable) => variable.value.length > 0)),
|
|
23227
|
+
automations: automationListSchema(ENVIRONMENT_SETUP_LIMITS)
|
|
23228
|
+
});
|
|
23229
|
+
}
|
|
23230
|
+
});
|
|
23231
|
+
|
|
23030
23232
|
// ../shared/src/routes/environment.ts
|
|
23031
|
-
|
|
23233
|
+
function validateEnvironmentMcpAuthentication(transport, config3) {
|
|
23234
|
+
if (!config3.auth) return createSuccessResult();
|
|
23235
|
+
const url2 = new URL(config3.url);
|
|
23236
|
+
if (url2.search || url2.protocol !== "https:") {
|
|
23237
|
+
return createErrorResult({ code: "url", message: "OAuth and workspace identity authentication require an HTTPS MCP URL without query parameters" });
|
|
23238
|
+
}
|
|
23239
|
+
const dropped = getMcpProxyDroppedHeader({ ...config3.headers, ...config3.headersFrom });
|
|
23240
|
+
if (dropped) {
|
|
23241
|
+
return createErrorResult({ code: "headers", message: `Remove the ${dropped} header: OAuth and workspace identity MCPs don't send it` });
|
|
23242
|
+
}
|
|
23243
|
+
if (config3.auth.type === "oauth" && transport === "sse") {
|
|
23244
|
+
return createErrorResult({ code: "transport", message: "OAuth requires the HTTP transport" });
|
|
23245
|
+
}
|
|
23246
|
+
return createSuccessResult();
|
|
23247
|
+
}
|
|
23248
|
+
function isReservedMcpName(name) {
|
|
23249
|
+
return RESERVED_MCP_NAME_PREFIXES.some((prefix) => name.startsWith(prefix));
|
|
23250
|
+
}
|
|
23251
|
+
var ENVIRONMENT_MCP_TRANSPORTS, MCP_NAME_PATTERN, environmentMcpVariableReferenceSchema, getMcpProxyDroppedHeader, stringMap, environmentMcpStdioConfigSchema, environmentMcpHttpConfigSchema, createEnvironmentMcpRequestSchema, updateEnvironmentMcpRequestSchema, RESERVED_MCP_NAME_PREFIXES, screenPasswordSchema, hostSchema, createEnvironmentDeviceRequestSchema, updateEnvironmentDeviceRequestSchema, DEVICE_ONLINE_WINDOW_MS, isDeviceOnline, deviceConnectionResponseSchema, deviceHostKeysRequestSchema, DEVICE_CONNECT_COMMAND, provisionedDeviceSchema;
|
|
23032
23252
|
var init_environment = __esm({
|
|
23033
23253
|
"../shared/src/routes/environment.ts"() {
|
|
23034
23254
|
"use strict";
|
|
23035
23255
|
init_subagent_mcp();
|
|
23036
23256
|
init_zod();
|
|
23037
23257
|
init_workspace_identity();
|
|
23258
|
+
init_environment_setups();
|
|
23259
|
+
init_result();
|
|
23038
23260
|
init_urls();
|
|
23039
23261
|
ENVIRONMENT_MCP_TRANSPORTS = ["stdio", "http", "sse"];
|
|
23262
|
+
MCP_NAME_PATTERN = /^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/;
|
|
23263
|
+
environmentMcpVariableReferenceSchema = external_exports.strictObject({
|
|
23264
|
+
env: external_exports.string().regex(VARIABLE_KEY_RE, "must be a valid environment variable name"),
|
|
23265
|
+
prefix: external_exports.string().optional()
|
|
23266
|
+
});
|
|
23267
|
+
getMcpProxyDroppedHeader = (headers) => Object.keys(headers).find((name) => ["authorization", "proxy-authorization", "cookie"].includes(name.toLowerCase()));
|
|
23040
23268
|
stringMap = external_exports.record(external_exports.string(), external_exports.string());
|
|
23269
|
+
environmentMcpStdioConfigSchema = external_exports.object({ command: external_exports.string().min(1), args: external_exports.array(external_exports.string()).optional(), env: stringMap.optional(), envFrom: external_exports.record(external_exports.string().regex(VARIABLE_KEY_RE), environmentMcpVariableReferenceSchema).optional() });
|
|
23270
|
+
environmentMcpHttpConfigSchema = external_exports.object({ url: external_exports.url(), headers: stringMap.optional(), headersFrom: external_exports.record(external_exports.string(), environmentMcpVariableReferenceSchema).optional(), auth: mcpAuthSchema.optional() });
|
|
23041
23271
|
createEnvironmentMcpRequestSchema = external_exports.object({
|
|
23042
23272
|
name: external_exports.string(),
|
|
23043
23273
|
transport: external_exports.enum(ENVIRONMENT_MCP_TRANSPORTS),
|
|
23044
23274
|
config: external_exports.union([
|
|
23045
|
-
|
|
23046
|
-
|
|
23275
|
+
environmentMcpStdioConfigSchema,
|
|
23276
|
+
environmentMcpHttpConfigSchema
|
|
23047
23277
|
]).describe("stdio: `{ command, args, env }`. http/sse: `{ url, headers }`.")
|
|
23048
23278
|
});
|
|
23049
23279
|
updateEnvironmentMcpRequestSchema = createEnvironmentMcpRequestSchema.partial();
|
|
23280
|
+
RESERVED_MCP_NAME_PREFIXES = ["replicas-", SUBAGENT_MCP_SERVER_NAME];
|
|
23050
23281
|
screenPasswordSchema = external_exports.string().min(1, "Enter the screen password").max(256).describe('Screen Sharing password, for `replicas computer screen`. On a Mac, the "VNC viewers may control screen with password" password. Never returned.');
|
|
23051
23282
|
hostSchema = external_exports.string().max(253).regex(/^(?:[A-Za-z0-9](?:[A-Za-z0-9.-]*[A-Za-z0-9])?|[0-9A-Fa-f:]+)$/, "Enter a hostname or IP address");
|
|
23052
23283
|
createEnvironmentDeviceRequestSchema = external_exports.object({
|
|
@@ -23082,8 +23313,22 @@ var init_environment = __esm({
|
|
|
23082
23313
|
}
|
|
23083
23314
|
});
|
|
23084
23315
|
|
|
23316
|
+
// ../shared/src/routes/environment-config-source.ts
|
|
23317
|
+
var previewEnvironmentConfigSourceRequestSchema, applyEnvironmentConfigSourceRequestSchema;
|
|
23318
|
+
var init_environment_config_source = __esm({
|
|
23319
|
+
"../shared/src/routes/environment-config-source.ts"() {
|
|
23320
|
+
"use strict";
|
|
23321
|
+
init_zod();
|
|
23322
|
+
previewEnvironmentConfigSourceRequestSchema = external_exports.strictObject({ repository_id: external_exports.string().min(1).optional() });
|
|
23323
|
+
applyEnvironmentConfigSourceRequestSchema = previewEnvironmentConfigSourceRequestSchema.extend({
|
|
23324
|
+
commit_sha: external_exports.string().min(1),
|
|
23325
|
+
fingerprint: external_exports.string().min(1)
|
|
23326
|
+
});
|
|
23327
|
+
}
|
|
23328
|
+
});
|
|
23329
|
+
|
|
23085
23330
|
// ../shared/src/replicas-mcp.ts
|
|
23086
|
-
var REPLICAS_MCP_TOOLS, automationToolInputSchema, credentialUserIdDescription, automationBackgroundSchema, automationCreateToolInputSchema, automationUpdateToolInputSchema, chatPath, provider, model, thinkingLevel, title, message, createChatToolInputSchema, forkChatToolInputSchema, renameChatToolInputSchema, runCommandToolInputSchema, environmentMcpPath, createEnvironmentMcpToolInputSchema, updateEnvironmentMcpToolInputSchema, createEnvironmentDeviceToolInputSchema;
|
|
23331
|
+
var REPLICAS_MCP_TOOLS, automationToolInputSchema, credentialUserIdDescription, automationBackgroundSchema, automationCreateToolInputSchema, automationUpdateToolInputSchema, chatPath, provider, model, thinkingLevel, title, message, createChatToolInputSchema, forkChatToolInputSchema, renameChatToolInputSchema, runCommandToolInputSchema, environmentMcpPath, createEnvironmentMcpToolInputSchema, updateEnvironmentMcpToolInputSchema, createEnvironmentDeviceToolInputSchema, previewEnvironmentConfigSourceToolInputSchema, applyEnvironmentConfigSourceToolInputSchema;
|
|
23087
23332
|
var init_replicas_mcp = __esm({
|
|
23088
23333
|
"../shared/src/replicas-mcp.ts"() {
|
|
23089
23334
|
"use strict";
|
|
@@ -23095,6 +23340,7 @@ var init_replicas_mcp = __esm({
|
|
|
23095
23340
|
init_chat_fork();
|
|
23096
23341
|
init_v1();
|
|
23097
23342
|
init_environment();
|
|
23343
|
+
init_environment_config_source();
|
|
23098
23344
|
init_workspaces();
|
|
23099
23345
|
init_sandbox();
|
|
23100
23346
|
REPLICAS_MCP_TOOLS = {
|
|
@@ -23205,6 +23451,8 @@ var init_replicas_mcp = __esm({
|
|
|
23205
23451
|
...updateEnvironmentMcpRequestSchema.shape
|
|
23206
23452
|
});
|
|
23207
23453
|
createEnvironmentDeviceToolInputSchema = external_exports.object({ ...environmentMcpPath, ...createEnvironmentDeviceRequestSchema.shape });
|
|
23454
|
+
previewEnvironmentConfigSourceToolInputSchema = external_exports.object({ ...environmentMcpPath, ...previewEnvironmentConfigSourceRequestSchema.shape });
|
|
23455
|
+
applyEnvironmentConfigSourceToolInputSchema = external_exports.object({ ...environmentMcpPath, ...applyEnvironmentConfigSourceRequestSchema.shape });
|
|
23208
23456
|
}
|
|
23209
23457
|
});
|
|
23210
23458
|
|
|
@@ -23670,207 +23918,6 @@ until docker info >/dev/null 2>&1; do sleep 0.2; done
|
|
|
23670
23918
|
}
|
|
23671
23919
|
});
|
|
23672
23920
|
|
|
23673
|
-
// ../shared/src/format.ts
|
|
23674
|
-
function relativeParts(input2, now = Date.now()) {
|
|
23675
|
-
const then = new Date(input2).getTime();
|
|
23676
|
-
if (Number.isNaN(then)) return null;
|
|
23677
|
-
const seconds = Math.max(0, Math.floor((now - then) / 1e3));
|
|
23678
|
-
const minutes = Math.floor(seconds / 60);
|
|
23679
|
-
const hours = Math.floor(minutes / 60);
|
|
23680
|
-
const days = Math.floor(hours / 24);
|
|
23681
|
-
const months = Math.floor(days / 30);
|
|
23682
|
-
return { then, seconds, minutes, hours, days, months, years: Math.floor(months / 12) };
|
|
23683
|
-
}
|
|
23684
|
-
function compactTimeAgo(input2, options) {
|
|
23685
|
-
const p = relativeParts(input2, options?.now);
|
|
23686
|
-
if (!p) return "";
|
|
23687
|
-
if (p.seconds < 60) return options?.seconds === false ? "now" : `${p.seconds}s`;
|
|
23688
|
-
if (p.minutes < 60) return `${p.minutes}m`;
|
|
23689
|
-
if (p.hours < 24) return `${p.hours}h`;
|
|
23690
|
-
if (p.days < 30) return `${p.days}d`;
|
|
23691
|
-
if (p.months < 12) return `${p.months}mo`;
|
|
23692
|
-
return `${p.years}y`;
|
|
23693
|
-
}
|
|
23694
|
-
function formatCompactRelativeTime(input2, now = Date.now()) {
|
|
23695
|
-
const then = new Date(input2).getTime();
|
|
23696
|
-
if (Number.isNaN(then)) return "";
|
|
23697
|
-
if (Math.abs(then - now) < 6e4) return "just now";
|
|
23698
|
-
const future = then > now;
|
|
23699
|
-
const compact = compactTimeAgo(future ? now - (then - now) : then, { now });
|
|
23700
|
-
return future ? `in ${compact}` : `${compact} ago`;
|
|
23701
|
-
}
|
|
23702
|
-
var init_format = __esm({
|
|
23703
|
-
"../shared/src/format.ts"() {
|
|
23704
|
-
"use strict";
|
|
23705
|
-
}
|
|
23706
|
-
});
|
|
23707
|
-
|
|
23708
|
-
// ../shared/src/routes/environment-setups.ts
|
|
23709
|
-
function isEnvironmentSetupStepKey(value) {
|
|
23710
|
-
return ENVIRONMENT_SETUP_STEPS.some((step) => step.key === value);
|
|
23711
|
-
}
|
|
23712
|
-
function isEnvironmentSetupStepStatus(value) {
|
|
23713
|
-
return ENVIRONMENT_SETUP_STEP_STATUSES.some((status) => status === value);
|
|
23714
|
-
}
|
|
23715
|
-
function isEnvironmentSetupAuthoredTriggerType(type) {
|
|
23716
|
-
return ENVIRONMENT_SETUP_AUTHORED_TRIGGER_TYPES.some((authored) => authored === type);
|
|
23717
|
-
}
|
|
23718
|
-
function automationSchema(limits) {
|
|
23719
|
-
const authored = external_exports.object({
|
|
23720
|
-
name: text2(limits.nameChars),
|
|
23721
|
-
description: text2(limits.descriptionChars),
|
|
23722
|
-
prompt: text2(limits.automationPromptChars),
|
|
23723
|
-
triggers: list(proposalTriggerSchema, limits.automationTriggers)
|
|
23724
|
-
});
|
|
23725
|
-
const updated = authored.extend({ triggers: list(external_exports.union([proposalTriggerSchema, carriedTriggerSchema]), limits.automationTriggers) });
|
|
23726
|
-
return external_exports.object({
|
|
23727
|
-
key: requiredText(limits.automationKeyChars),
|
|
23728
|
-
action: external_exports.enum(ENVIRONMENT_SETUP_AUTOMATION_ACTIONS).default("create"),
|
|
23729
|
-
automation_id: external_exports.string().regex(UUID_RE, "must be an automation id").nullable().default(null),
|
|
23730
|
-
name: text2().default(""),
|
|
23731
|
-
description: optionalText2().transform((value) => value ?? ""),
|
|
23732
|
-
prompt: text2().default(""),
|
|
23733
|
-
triggers: list(existingTriggerSchema).default([]),
|
|
23734
|
-
note: optionalText2(limits.automationNoteChars)
|
|
23735
|
-
}).superRefine((automation2, ctx) => {
|
|
23736
|
-
if (automation2.action === "create" && automation2.automation_id) {
|
|
23737
|
-
ctx.addIssue({ code: "custom", path: ["automation_id"], message: "belongs on an update, keep, or disable entry" });
|
|
23738
|
-
}
|
|
23739
|
-
if (automation2.action !== "create" && !automation2.automation_id) {
|
|
23740
|
-
ctx.addIssue({ code: "custom", path: ["automation_id"], message: "must be the id of an automation attached to this environment" });
|
|
23741
|
-
}
|
|
23742
|
-
if (automation2.action === "create" || automation2.action === "update") {
|
|
23743
|
-
if (!automation2.name) ctx.addIssue({ code: "custom", path: ["name"], message: "must not be empty" });
|
|
23744
|
-
if (!automation2.prompt) ctx.addIssue({ code: "custom", path: ["prompt"], message: "must not be empty" });
|
|
23745
|
-
if (automation2.triggers.length === 0) ctx.addIssue({ code: "custom", path: ["triggers"], message: "must not be empty" });
|
|
23746
|
-
}
|
|
23747
|
-
}).transform((automation2, ctx) => {
|
|
23748
|
-
if (automation2.action === "keep" || automation2.action === "disable") return automation2;
|
|
23749
|
-
const content = (automation2.action === "update" ? updated : authored).safeParse(automation2);
|
|
23750
|
-
if (content.success) return { ...automation2, ...content.data };
|
|
23751
|
-
for (const issue2 of content.error.issues) ctx.addIssue({ ...issue2, code: "custom" });
|
|
23752
|
-
return external_exports.NEVER;
|
|
23753
|
-
});
|
|
23754
|
-
}
|
|
23755
|
-
function automationListSchema(limits) {
|
|
23756
|
-
return list(automationSchema(limits)).default([]).superRefine((automations, ctx) => {
|
|
23757
|
-
if (new Set(automations.map((automation2) => automation2.key)).size !== automations.length) {
|
|
23758
|
-
ctx.addIssue({ code: "custom", message: "must have unique keys" });
|
|
23759
|
-
}
|
|
23760
|
-
const targets = automations.flatMap((automation2) => automation2.automation_id ?? []);
|
|
23761
|
-
if (new Set(targets).size !== targets.length) {
|
|
23762
|
-
ctx.addIssue({ code: "custom", message: "must mention each existing automation once" });
|
|
23763
|
-
}
|
|
23764
|
-
if (limits.automations !== void 0 && automations.filter((automation2) => automation2.action === "create").length > limits.automations) {
|
|
23765
|
-
ctx.addIssue({ code: "custom", message: `must create at most ${limits.automations} new automations` });
|
|
23766
|
-
}
|
|
23767
|
-
});
|
|
23768
|
-
}
|
|
23769
|
-
function environmentSchema(limits) {
|
|
23770
|
-
return external_exports.object({
|
|
23771
|
-
name: optionalText2(limits.nameChars).transform((value) => value ?? void 0),
|
|
23772
|
-
description: clearableText(limits.descriptionChars),
|
|
23773
|
-
system_prompt: clearableText(limits.systemPromptChars),
|
|
23774
|
-
start_hook: clearableText(limits.hookChars),
|
|
23775
|
-
warm_hook: clearableText(limits.hookChars)
|
|
23776
|
-
});
|
|
23777
|
-
}
|
|
23778
|
-
function proposalSchema(limits) {
|
|
23779
|
-
return external_exports.object({
|
|
23780
|
-
summary: requiredText(limits.summaryChars),
|
|
23781
|
-
stack: list(text2(), limits.stackItems).default([]).transform((items) => items.filter(Boolean)),
|
|
23782
|
-
environment: environmentSchema(limits),
|
|
23783
|
-
variables: list(external_exports.object({
|
|
23784
|
-
key: external_exports.string().regex(VARIABLE_KEY_RE, "must be a valid environment variable name").max(limits.variableKeyChars ?? Number.POSITIVE_INFINITY),
|
|
23785
|
-
description: optionalText2(limits.variableDescriptionChars).transform((value) => value ?? ""),
|
|
23786
|
-
required: external_exports.boolean().default(false)
|
|
23787
|
-
}), limits.variables).default([]),
|
|
23788
|
-
automations: automationListSchema(limits),
|
|
23789
|
-
verification: list(external_exports.object({
|
|
23790
|
-
label: requiredText(limits.nameChars),
|
|
23791
|
-
status: external_exports.enum(ENVIRONMENT_SETUP_VERIFICATION_STATUSES),
|
|
23792
|
-
detail: optionalText2(limits.verificationDetailChars).transform((value) => value ?? void 0)
|
|
23793
|
-
}), limits.verificationItems).default([]),
|
|
23794
|
-
media: list(external_exports.object({
|
|
23795
|
-
media_id: external_exports.string().regex(UUID_RE, "must be a media id"),
|
|
23796
|
-
title: requiredText(limits.nameChars)
|
|
23797
|
-
}), limits.mediaItems).default([])
|
|
23798
|
-
});
|
|
23799
|
-
}
|
|
23800
|
-
var ENVIRONMENT_SETUP_STEPS, ENVIRONMENT_SETUP_STEP_STATUSES, ENVIRONMENT_SETUP_RUN_STATUSES, ENVIRONMENT_SETUP_AUTOMATION_ACTIONS, ENVIRONMENT_SETUP_VERIFICATION_STATUSES, ENVIRONMENT_SETUP_LIMITS, VARIABLE_KEY_RE, text2, requiredText, optionalText2, clearableText, list, ENVIRONMENT_SETUP_AUTHORED_TRIGGER_TYPES, proposalTriggerSchema, existingTriggerSchema, carriedTriggerSchema, environmentSetupProposalSchema, environmentSetupProposalSubmissionSchema, environmentSetupRunStateSchema, applyEnvironmentSetupRequestSchema;
|
|
23801
|
-
var init_environment_setups = __esm({
|
|
23802
|
-
"../shared/src/routes/environment-setups.ts"() {
|
|
23803
|
-
"use strict";
|
|
23804
|
-
init_zod();
|
|
23805
|
-
init_trigger_schemas();
|
|
23806
|
-
init_format();
|
|
23807
|
-
init_type_guards();
|
|
23808
|
-
init_uuid();
|
|
23809
|
-
ENVIRONMENT_SETUP_STEPS = [
|
|
23810
|
-
{ key: "understand", label: "Understand the codebase" },
|
|
23811
|
-
{ key: "install", label: "Install dependencies and run the app" },
|
|
23812
|
-
{ key: "verify", label: "Verify checks and record a walkthrough" },
|
|
23813
|
-
{ key: "configure", label: "Draft hooks, system prompt, and automations" },
|
|
23814
|
-
{ key: "propose", label: "Propose the configuration for review" }
|
|
23815
|
-
];
|
|
23816
|
-
ENVIRONMENT_SETUP_STEP_STATUSES = ["pending", "in_progress", "completed", "skipped"];
|
|
23817
|
-
ENVIRONMENT_SETUP_RUN_STATUSES = ["running", "proposed", "applied", "failed", "cancelled", "expired"];
|
|
23818
|
-
ENVIRONMENT_SETUP_AUTOMATION_ACTIONS = ["create", "update", "keep", "disable"];
|
|
23819
|
-
ENVIRONMENT_SETUP_VERIFICATION_STATUSES = ["passed", "failed", "skipped"];
|
|
23820
|
-
ENVIRONMENT_SETUP_LIMITS = {
|
|
23821
|
-
summaryChars: 600,
|
|
23822
|
-
stackItems: 30,
|
|
23823
|
-
nameChars: 120,
|
|
23824
|
-
descriptionChars: 1e3,
|
|
23825
|
-
systemPromptChars: 2e4,
|
|
23826
|
-
hookChars: 5e4,
|
|
23827
|
-
variables: 50,
|
|
23828
|
-
variableKeyChars: 128,
|
|
23829
|
-
variableDescriptionChars: 500,
|
|
23830
|
-
automations: 8,
|
|
23831
|
-
automationKeyChars: 80,
|
|
23832
|
-
automationPromptChars: 1e4,
|
|
23833
|
-
automationTriggers: 5,
|
|
23834
|
-
automationNoteChars: 300,
|
|
23835
|
-
verificationItems: 8,
|
|
23836
|
-
verificationDetailChars: 300,
|
|
23837
|
-
mediaItems: 8,
|
|
23838
|
-
repositories: 20
|
|
23839
|
-
};
|
|
23840
|
-
VARIABLE_KEY_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
23841
|
-
text2 = (max) => max === void 0 ? external_exports.string().trim() : external_exports.string().trim().max(max);
|
|
23842
|
-
requiredText = (max) => text2(max).min(1, "must not be empty");
|
|
23843
|
-
optionalText2 = (max) => text2(max).nullish().transform((value) => value || null);
|
|
23844
|
-
clearableText = (max) => text2(max).nullish().transform((value) => value === void 0 ? void 0 : value || null);
|
|
23845
|
-
list = (item, max) => max === void 0 ? external_exports.array(item) : external_exports.array(item).max(max);
|
|
23846
|
-
ENVIRONMENT_SETUP_AUTHORED_TRIGGER_TYPES = ["cron", "github", "gitlab"];
|
|
23847
|
-
proposalTriggerSchema = external_exports.discriminatedUnion("type", [cronTriggerSchema, githubTriggerSchema, gitlabTriggerSchema]);
|
|
23848
|
-
existingTriggerSchema = external_exports.custom(
|
|
23849
|
-
(value) => isRecord(value) && typeof value.type === "string" && isRecord(value.config),
|
|
23850
|
-
"must be an automation trigger"
|
|
23851
|
-
);
|
|
23852
|
-
carriedTriggerSchema = existingTriggerSchema.refine(
|
|
23853
|
-
(trigger) => !isEnvironmentSetupAuthoredTriggerType(trigger.type)
|
|
23854
|
-
);
|
|
23855
|
-
environmentSetupProposalSchema = proposalSchema({});
|
|
23856
|
-
environmentSetupProposalSubmissionSchema = proposalSchema(ENVIRONMENT_SETUP_LIMITS);
|
|
23857
|
-
environmentSetupRunStateSchema = external_exports.object({
|
|
23858
|
-
status: external_exports.enum(ENVIRONMENT_SETUP_RUN_STATUSES),
|
|
23859
|
-
steps: external_exports.partialRecord(external_exports.enum(ENVIRONMENT_SETUP_STEPS.map((step) => step.key)), external_exports.enum(ENVIRONMENT_SETUP_STEP_STATUSES)).default({}),
|
|
23860
|
-
proposal: environmentSetupProposalSchema.nullable().default(null),
|
|
23861
|
-
applied: external_exports.object({
|
|
23862
|
-
applied_at: external_exports.string(),
|
|
23863
|
-
automation_ids: external_exports.array(external_exports.string())
|
|
23864
|
-
}).nullable().default(null)
|
|
23865
|
-
});
|
|
23866
|
-
applyEnvironmentSetupRequestSchema = external_exports.object({
|
|
23867
|
-
environment: environmentSchema(ENVIRONMENT_SETUP_LIMITS).extend({ name: requiredText(ENVIRONMENT_SETUP_LIMITS.nameChars) }),
|
|
23868
|
-
variables: list(external_exports.object({ key: external_exports.string().regex(VARIABLE_KEY_RE), value: external_exports.string() }), ENVIRONMENT_SETUP_LIMITS.variables).default([]).refine((variables) => new Set(variables.map((variable) => variable.key)).size === variables.length, "must have unique keys").transform((variables) => variables.filter((variable) => variable.value.length > 0)),
|
|
23869
|
-
automations: automationListSchema(ENVIRONMENT_SETUP_LIMITS)
|
|
23870
|
-
});
|
|
23871
|
-
}
|
|
23872
|
-
});
|
|
23873
|
-
|
|
23874
23921
|
// ../shared/src/default-skills/replicas-agent/abilities/environment-setup.ts
|
|
23875
23922
|
var SECTION3, REFERENCE3, ENVIRONMENT_SETUP_ABILITY;
|
|
23876
23923
|
var init_environment_setup = __esm({
|
|
@@ -38276,6 +38323,63 @@ var init_warm_hooks = __esm({
|
|
|
38276
38323
|
}
|
|
38277
38324
|
});
|
|
38278
38325
|
|
|
38326
|
+
// ../shared/src/environment-config.ts
|
|
38327
|
+
var variableNameSchema, mcpValueSchema, mcpValuesSchema, httpConfigSchema, replicasMcpDefinitionSchema, replicasEnvironmentConfigSchema;
|
|
38328
|
+
var init_environment_config = __esm({
|
|
38329
|
+
"../shared/src/environment-config.ts"() {
|
|
38330
|
+
"use strict";
|
|
38331
|
+
init_zod();
|
|
38332
|
+
init_environment();
|
|
38333
|
+
init_environment_setups();
|
|
38334
|
+
variableNameSchema = external_exports.string().regex(VARIABLE_KEY_RE, "must be a valid environment variable name");
|
|
38335
|
+
mcpValueSchema = external_exports.union([
|
|
38336
|
+
external_exports.string(),
|
|
38337
|
+
environmentMcpVariableReferenceSchema
|
|
38338
|
+
]);
|
|
38339
|
+
mcpValuesSchema = external_exports.record(external_exports.string(), mcpValueSchema);
|
|
38340
|
+
httpConfigSchema = environmentMcpHttpConfigSchema.pick({ url: true, auth: true }).extend({
|
|
38341
|
+
headers: mcpValuesSchema.default({})
|
|
38342
|
+
}).strict();
|
|
38343
|
+
replicasMcpDefinitionSchema = external_exports.discriminatedUnion("transport", [
|
|
38344
|
+
external_exports.strictObject({
|
|
38345
|
+
transport: external_exports.literal("stdio"),
|
|
38346
|
+
config: environmentMcpStdioConfigSchema.pick({ command: true }).extend({
|
|
38347
|
+
args: environmentMcpStdioConfigSchema.shape.args.unwrap().default([]),
|
|
38348
|
+
env: external_exports.record(variableNameSchema, mcpValueSchema).default({})
|
|
38349
|
+
}).strict()
|
|
38350
|
+
}),
|
|
38351
|
+
external_exports.strictObject({ transport: external_exports.literal("http"), config: httpConfigSchema }),
|
|
38352
|
+
external_exports.strictObject({ transport: external_exports.literal("sse"), config: httpConfigSchema })
|
|
38353
|
+
]).superRefine((definition, context) => {
|
|
38354
|
+
if (definition.transport === "stdio") return;
|
|
38355
|
+
const result = validateEnvironmentMcpAuthentication(definition.transport, definition.config);
|
|
38356
|
+
if (!result.ok) context.addIssue({ code: "custom", path: result.error.code === "transport" ? ["transport"] : ["config", result.error.code ?? "auth"], message: result.error.message });
|
|
38357
|
+
});
|
|
38358
|
+
replicasEnvironmentConfigSchema = external_exports.strictObject({
|
|
38359
|
+
systemPrompt: external_exports.string().optional(),
|
|
38360
|
+
warmHook: external_exports.string().optional(),
|
|
38361
|
+
startHook: external_exports.string().optional(),
|
|
38362
|
+
variables: external_exports.record(variableNameSchema, external_exports.string()).optional(),
|
|
38363
|
+
requiredSecrets: external_exports.array(variableNameSchema).optional(),
|
|
38364
|
+
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()
|
|
38365
|
+
}).superRefine((config3, context) => {
|
|
38366
|
+
const names = /* @__PURE__ */ new Set();
|
|
38367
|
+
for (const name of Object.keys(config3.mcps ?? {})) {
|
|
38368
|
+
const normalized = name.toLowerCase();
|
|
38369
|
+
if (names.has(normalized)) {
|
|
38370
|
+
context.addIssue({ code: "custom", path: ["mcps", name], message: "MCP names must be unique regardless of case" });
|
|
38371
|
+
}
|
|
38372
|
+
names.add(normalized);
|
|
38373
|
+
}
|
|
38374
|
+
for (const key of config3.requiredSecrets ?? []) {
|
|
38375
|
+
if (config3.variables && Object.hasOwn(config3.variables, key)) {
|
|
38376
|
+
context.addIssue({ code: "custom", path: ["requiredSecrets"], message: `"${key}" cannot also be declared as a non-secret variable` });
|
|
38377
|
+
}
|
|
38378
|
+
}
|
|
38379
|
+
});
|
|
38380
|
+
}
|
|
38381
|
+
});
|
|
38382
|
+
|
|
38279
38383
|
// ../shared/src/replicas-config.ts
|
|
38280
38384
|
var import_yaml2, REPLICAS_CONFIG_FILENAMES;
|
|
38281
38385
|
var init_replicas_config = __esm({
|
|
@@ -38283,6 +38387,7 @@ var init_replicas_config = __esm({
|
|
|
38283
38387
|
"use strict";
|
|
38284
38388
|
import_yaml2 = __toESM(require_dist());
|
|
38285
38389
|
init_warm_hooks();
|
|
38390
|
+
init_environment_config();
|
|
38286
38391
|
REPLICAS_CONFIG_FILENAMES = ["replicas.json", "replicas.yaml", "replicas.yml"];
|
|
38287
38392
|
}
|
|
38288
38393
|
});
|
|
@@ -38392,7 +38497,7 @@ var CLI_VERSION;
|
|
|
38392
38497
|
var init_cli_version = __esm({
|
|
38393
38498
|
"../shared/src/cli-version.ts"() {
|
|
38394
38499
|
"use strict";
|
|
38395
|
-
CLI_VERSION = "0.3.
|
|
38500
|
+
CLI_VERSION = "0.3.430";
|
|
38396
38501
|
}
|
|
38397
38502
|
});
|
|
38398
38503
|
|
|
@@ -49628,6 +49733,8 @@ var init_src = __esm({
|
|
|
49628
49733
|
init_image_attachments();
|
|
49629
49734
|
init_scout();
|
|
49630
49735
|
init_replicas_config();
|
|
49736
|
+
init_environment_config();
|
|
49737
|
+
init_environment_config_source();
|
|
49631
49738
|
init_warm_hooks();
|
|
49632
49739
|
init_hook_failure();
|
|
49633
49740
|
init_start_hook_network();
|
|
@@ -55653,6 +55760,95 @@ var init_gpu2 = __esm({
|
|
|
55653
55760
|
}
|
|
55654
55761
|
});
|
|
55655
55762
|
|
|
55763
|
+
// src/commands/environment-config.ts
|
|
55764
|
+
function printSource({ source }) {
|
|
55765
|
+
if (!source) {
|
|
55766
|
+
console.log("No Git configuration linked. Use replicas environment config link <env> --repository <name-or-id>.");
|
|
55767
|
+
return;
|
|
55768
|
+
}
|
|
55769
|
+
console.log(`${source.repository_name}/${source.filename} @ ${source.commit_sha}`);
|
|
55770
|
+
console.log(source.source_url);
|
|
55771
|
+
console.log(`Synced: ${source.synced_at}`);
|
|
55772
|
+
console.log(`Managed settings: ${source.managed.fields.join(", ") || "(none)"}`);
|
|
55773
|
+
console.log(`Managed variables: ${source.managed.variables.join(", ") || "(none)"}`);
|
|
55774
|
+
console.log(`Managed MCPs: ${source.managed.mcps.join(", ") || "(none)"}`);
|
|
55775
|
+
if (source.required_secrets.length) console.log(`Required secrets: ${source.required_secrets.join(", ")}`);
|
|
55776
|
+
if (source.pending_rebuild) console.log(import_chalk29.default.yellow("Configuration saved; environment rebuild pending."));
|
|
55777
|
+
if (source.last_error) console.log(import_chalk29.default.red(source.last_error));
|
|
55778
|
+
}
|
|
55779
|
+
function printPreview({ preview: preview2 }) {
|
|
55780
|
+
console.log(`${preview2.repository_name}/${preview2.filename} @ ${preview2.commit_sha}`);
|
|
55781
|
+
console.log(preview2.source_url);
|
|
55782
|
+
if (!preview2.changes.length) console.log("No setting changes. Applying records this commit.");
|
|
55783
|
+
for (const change of preview2.changes) console.log(` ${change.operation}: ${change.kind} ${change.key}`);
|
|
55784
|
+
if (preview2.missing_secrets.length) console.log(import_chalk29.default.yellow(`Missing required secrets: ${preview2.missing_secrets.join(", ")}`));
|
|
55785
|
+
for (const blocker of preview2.blockers) console.log(import_chalk29.default.red(` Cannot apply: ${blocker}`));
|
|
55786
|
+
}
|
|
55787
|
+
async function previewSource(id, repository) {
|
|
55788
|
+
const [repositoryId] = repository ? await resolveRepositoryIds([repository]) : [];
|
|
55789
|
+
return orgAuthenticatedFetch(`/v1/environments/${id}/config-source/preview`, {
|
|
55790
|
+
method: "POST",
|
|
55791
|
+
body: repositoryId ? { repository_id: repositoryId } : {}
|
|
55792
|
+
});
|
|
55793
|
+
}
|
|
55794
|
+
async function environmentConfigGetCommand(environment2) {
|
|
55795
|
+
ensureOrgApiAuthenticated();
|
|
55796
|
+
const id = await resolveEnvironmentId(environment2);
|
|
55797
|
+
output2(await orgAuthenticatedFetch(`/v1/environments/${id}/config-source`), printSource);
|
|
55798
|
+
}
|
|
55799
|
+
async function environmentConfigPreviewCommand(environment2, options) {
|
|
55800
|
+
ensureOrgApiAuthenticated();
|
|
55801
|
+
output2(await previewSource(await resolveEnvironmentId(environment2), options.repository), printPreview);
|
|
55802
|
+
}
|
|
55803
|
+
async function applySource(environment2, options, operation) {
|
|
55804
|
+
ensureOrgApiAuthenticated();
|
|
55805
|
+
const id = await resolveEnvironmentId(environment2);
|
|
55806
|
+
const response = await previewSource(id, options.repository);
|
|
55807
|
+
if (!isJsonMode()) printPreview(response);
|
|
55808
|
+
const { preview: preview2 } = response;
|
|
55809
|
+
if (preview2.blockers.length || preview2.missing_secrets.length) {
|
|
55810
|
+
throw new Error([
|
|
55811
|
+
...preview2.blockers,
|
|
55812
|
+
...preview2.missing_secrets.length ? [`Missing required secrets: ${preview2.missing_secrets.join(", ")}`] : []
|
|
55813
|
+
].join("; "));
|
|
55814
|
+
}
|
|
55815
|
+
if (!options.yes) {
|
|
55816
|
+
if (!isInteractive()) throw new Error("Preview the changes with replicas environment config preview, then pass --yes to apply without a terminal.");
|
|
55817
|
+
if (!await confirmAction(`${operation === "link" ? "Link and apply" : "Apply"} this configuration to ${environment2}?`)) return;
|
|
55818
|
+
}
|
|
55819
|
+
const body = { repository_id: preview2.repository_id, commit_sha: preview2.commit_sha, fingerprint: preview2.fingerprint };
|
|
55820
|
+
output2(await orgAuthenticatedFetch(`/v1/environments/${id}/config-source${operation === "sync" ? "/sync" : ""}`, { method: "POST", body }), printSource);
|
|
55821
|
+
}
|
|
55822
|
+
async function environmentConfigLinkCommand(environment2, options) {
|
|
55823
|
+
await applySource(environment2, options, "link");
|
|
55824
|
+
}
|
|
55825
|
+
async function environmentConfigSyncCommand(environment2, options) {
|
|
55826
|
+
await applySource(environment2, options, "sync");
|
|
55827
|
+
}
|
|
55828
|
+
async function environmentConfigDisconnectCommand(environment2, options) {
|
|
55829
|
+
ensureOrgApiAuthenticated();
|
|
55830
|
+
const id = await resolveEnvironmentId(environment2);
|
|
55831
|
+
if (!options.yes) {
|
|
55832
|
+
if (!isInteractive()) throw new Error("Pass --yes to disconnect without a terminal. Current settings will be preserved.");
|
|
55833
|
+
if (!await confirmAction(`Disconnect Git configuration for ${environment2}? Current settings will be preserved.`)) return;
|
|
55834
|
+
}
|
|
55835
|
+
output2(await orgAuthenticatedFetch(`/v1/environments/${id}/config-source`, { method: "DELETE" }), () => {
|
|
55836
|
+
console.log("Git configuration disconnected. Current settings preserved.");
|
|
55837
|
+
});
|
|
55838
|
+
}
|
|
55839
|
+
var import_chalk29;
|
|
55840
|
+
var init_environment_config2 = __esm({
|
|
55841
|
+
"src/commands/environment-config.ts"() {
|
|
55842
|
+
"use strict";
|
|
55843
|
+
import_chalk29 = __toESM(require("chalk"));
|
|
55844
|
+
init_api2();
|
|
55845
|
+
init_command_utils();
|
|
55846
|
+
init_output();
|
|
55847
|
+
init_environment3();
|
|
55848
|
+
init_repositories2();
|
|
55849
|
+
}
|
|
55850
|
+
});
|
|
55851
|
+
|
|
55656
55852
|
// src/commands/history.ts
|
|
55657
55853
|
async function historyTranscriptCommand(name) {
|
|
55658
55854
|
const session = name.trim().replace(/\.md$/, "");
|
|
@@ -55696,12 +55892,12 @@ async function skillsSuggestCommand(file2, options) {
|
|
|
55696
55892
|
async function skillsListCommand() {
|
|
55697
55893
|
output2(await orgAuthenticatedFetch("/v1/learned-skills"), ({ skills: skills2, suggestions }) => {
|
|
55698
55894
|
for (const skill of skills2) console.log(`${skill.id} ${skill.name} ${skill.title}`);
|
|
55699
|
-
if (suggestions.length > 0) console.log(
|
|
55895
|
+
if (suggestions.length > 0) console.log(import_chalk30.default.gray(`${suggestions.length} pending suggestion(s) to review in the dashboard.`));
|
|
55700
55896
|
});
|
|
55701
55897
|
}
|
|
55702
55898
|
async function skillsCreateCommand(file2, options) {
|
|
55703
55899
|
const body = { content: (0, import_node_fs4.readFileSync)(file2, "utf-8"), title: options.title };
|
|
55704
|
-
output2(await orgAuthenticatedFetch("/v1/learned-skills", { method: "POST", body }), ({ id, name }) => console.log(
|
|
55900
|
+
output2(await orgAuthenticatedFetch("/v1/learned-skills", { method: "POST", body }), ({ id, name }) => console.log(import_chalk30.default.green(`Saved learning '${name}' (${id})`)));
|
|
55705
55901
|
}
|
|
55706
55902
|
async function skillsUpdateCommand(id, options) {
|
|
55707
55903
|
const { skills: skills2 } = await orgAuthenticatedFetch("/v1/learned-skills");
|
|
@@ -55711,18 +55907,18 @@ async function skillsUpdateCommand(id, options) {
|
|
|
55711
55907
|
title: options.title ?? existing.title,
|
|
55712
55908
|
content: options.file ? (0, import_node_fs4.readFileSync)(options.file, "utf-8") : existing.content
|
|
55713
55909
|
};
|
|
55714
|
-
output2(await orgAuthenticatedFetch(`/v1/learned-skills/${existing.id}`, { method: "PUT", body }), ({ name }) => console.log(
|
|
55910
|
+
output2(await orgAuthenticatedFetch(`/v1/learned-skills/${existing.id}`, { method: "PUT", body }), ({ name }) => console.log(import_chalk30.default.green(`Updated learning '${name}'`)));
|
|
55715
55911
|
}
|
|
55716
55912
|
async function skillsDeleteCommand(id) {
|
|
55717
55913
|
await orgAuthenticatedFetch(`/v1/learned-skills/${id}`, { method: "DELETE" });
|
|
55718
55914
|
outputSuccess(`Deleted learning ${id}`);
|
|
55719
55915
|
}
|
|
55720
|
-
var import_node_fs4,
|
|
55916
|
+
var import_node_fs4, import_chalk30;
|
|
55721
55917
|
var init_skills = __esm({
|
|
55722
55918
|
"src/commands/skills.ts"() {
|
|
55723
55919
|
"use strict";
|
|
55724
55920
|
import_node_fs4 = require("fs");
|
|
55725
|
-
|
|
55921
|
+
import_chalk30 = __toESM(require("chalk"));
|
|
55726
55922
|
init_agent_api();
|
|
55727
55923
|
init_api2();
|
|
55728
55924
|
init_monolith_url();
|
|
@@ -55748,10 +55944,10 @@ async function attachThread(request) {
|
|
|
55748
55944
|
body: request
|
|
55749
55945
|
});
|
|
55750
55946
|
output2(response, ({ thread, workspace }) => {
|
|
55751
|
-
console.log(
|
|
55752
|
-
console.log(
|
|
55753
|
-
console.log(
|
|
55754
|
-
console.log(
|
|
55947
|
+
console.log(import_chalk31.default.green("Slack thread attached."));
|
|
55948
|
+
console.log(import_chalk31.default.gray(` Channel: ${thread.channel_id}`));
|
|
55949
|
+
console.log(import_chalk31.default.gray(` Thread: ${thread.thread_ts}`));
|
|
55950
|
+
console.log(import_chalk31.default.gray(` Workspace: ${workspace.name} (${workspace.id})`));
|
|
55755
55951
|
});
|
|
55756
55952
|
}
|
|
55757
55953
|
async function slackThreadAttachCommand(options) {
|
|
@@ -55779,11 +55975,11 @@ async function slackThreadSwitchCommand(workspace, options) {
|
|
|
55779
55975
|
workspace_id: workspaceId
|
|
55780
55976
|
});
|
|
55781
55977
|
}
|
|
55782
|
-
var
|
|
55978
|
+
var import_chalk31;
|
|
55783
55979
|
var init_slack4 = __esm({
|
|
55784
55980
|
"src/commands/slack.ts"() {
|
|
55785
55981
|
"use strict";
|
|
55786
|
-
|
|
55982
|
+
import_chalk31 = __toESM(require("chalk"));
|
|
55787
55983
|
init_api2();
|
|
55788
55984
|
init_config();
|
|
55789
55985
|
init_output();
|
|
@@ -55938,7 +56134,7 @@ async function serviceListCommand() {
|
|
|
55938
56134
|
return;
|
|
55939
56135
|
}
|
|
55940
56136
|
for (const service of services) {
|
|
55941
|
-
const status = service.running ?
|
|
56137
|
+
const status = service.running ? import_chalk32.default.green("running") : import_chalk32.default.red("stopped");
|
|
55942
56138
|
console.log(`${service.name} ${status} pid ${service.pid} started ${service.startedAt}`);
|
|
55943
56139
|
console.log(` command: ${service.command} (cwd: ${service.cwd})`);
|
|
55944
56140
|
console.log(` logs: ${service.logFile}`);
|
|
@@ -55958,11 +56154,11 @@ async function serviceLogsCommand(name, options) {
|
|
|
55958
56154
|
console.log(logs || "(no log output yet)");
|
|
55959
56155
|
});
|
|
55960
56156
|
}
|
|
55961
|
-
var
|
|
56157
|
+
var import_chalk32, import_node_child_process3, import_node_fs5, import_node_os3, import_node_path4, SERVICES_DIR, NAME_PATTERN, LOG_KEEP_BYTES, LOG_TRIM_LOOP;
|
|
55962
56158
|
var init_service = __esm({
|
|
55963
56159
|
"src/commands/service.ts"() {
|
|
55964
56160
|
"use strict";
|
|
55965
|
-
|
|
56161
|
+
import_chalk32 = __toESM(require("chalk"));
|
|
55966
56162
|
import_node_child_process3 = require("child_process");
|
|
55967
56163
|
import_node_fs5 = require("fs");
|
|
55968
56164
|
import_node_os3 = require("os");
|
|
@@ -56019,7 +56215,7 @@ async function deviceConnectCommand() {
|
|
|
56019
56215
|
stream.destroy();
|
|
56020
56216
|
};
|
|
56021
56217
|
sshd.once("error", (error62) => {
|
|
56022
|
-
console.log(
|
|
56218
|
+
console.log(import_chalk33.default.yellow(`A workspace couldn't reach SSH on port ${port} here (${error62.message}). ${REMOTE_LOGIN_HINT}`));
|
|
56023
56219
|
});
|
|
56024
56220
|
sshd.on("error", close).on("close", close);
|
|
56025
56221
|
stream.on("error", close).on("close", close);
|
|
@@ -56063,16 +56259,16 @@ async function deviceConnectCommand() {
|
|
|
56063
56259
|
}
|
|
56064
56260
|
}
|
|
56065
56261
|
const next = problem ?? `\u2713 ${device?.name}: ready for ${waiting.size} ${waiting.size === 1 ? "workspace" : "workspaces"}, forwarding to SSH on port ${port}`;
|
|
56066
|
-
if (next !== summary) console.log(problem ?
|
|
56262
|
+
if (next !== summary) console.log(problem ? import_chalk33.default.yellow(next) : import_chalk33.default.green(next));
|
|
56067
56263
|
summary = next;
|
|
56068
56264
|
await (0, import_promises2.setTimeout)(POLL_INTERVAL_MS);
|
|
56069
56265
|
}
|
|
56070
56266
|
}
|
|
56071
|
-
var
|
|
56267
|
+
var import_chalk33, import_node_child_process4, import_node_net, import_promises2, import_node_util, import_ws, POLL_INTERVAL_MS, HEARTBEAT_MS, MAX_RETRY_DELAY_MS, REMOTE_LOGIN_HINT;
|
|
56072
56268
|
var init_device = __esm({
|
|
56073
56269
|
"src/commands/device.ts"() {
|
|
56074
56270
|
"use strict";
|
|
56075
|
-
|
|
56271
|
+
import_chalk33 = __toESM(require("chalk"));
|
|
56076
56272
|
import_node_child_process4 = require("child_process");
|
|
56077
56273
|
import_node_net = require("net");
|
|
56078
56274
|
import_promises2 = require("timers/promises");
|
|
@@ -56103,8 +56299,8 @@ async function localControlRequestCommand(options) {
|
|
|
56103
56299
|
await orgAuthenticatedFetch("/v1/local-control-request", { method: "DELETE" });
|
|
56104
56300
|
output2({ status: "connected", computers: computers2 }, () => {
|
|
56105
56301
|
console.log(`
|
|
56106
|
-
${
|
|
56107
|
-
console.log(
|
|
56302
|
+
${import_chalk34.default.green("Connected:")} ${computers2.join(", ")}`);
|
|
56303
|
+
console.log(import_chalk34.default.gray(` Run commands there with: ssh ${computers2[0]} '<command>'
|
|
56108
56304
|
`));
|
|
56109
56305
|
});
|
|
56110
56306
|
};
|
|
@@ -56132,10 +56328,10 @@ async function localControlRequestCommand(options) {
|
|
|
56132
56328
|
}
|
|
56133
56329
|
output2({ status: pending ? "pending" : "declined", computers: [], url: created.url }, () => {
|
|
56134
56330
|
if (!pending) {
|
|
56135
|
-
console.log(
|
|
56331
|
+
console.log(import_chalk34.default.yellow("\n The user declined. Continue without their computer, or ask how they want to proceed.\n"));
|
|
56136
56332
|
return;
|
|
56137
56333
|
}
|
|
56138
|
-
console.log(
|
|
56334
|
+
console.log(import_chalk34.default.gray(options.wait === false ? `
|
|
56139
56335
|
Asked above the chat composer (${created.url}). Keep working, and run this command again when you need the computer.
|
|
56140
56336
|
` : created.wait ? `
|
|
56141
56337
|
The request stays open above the chat composer (${created.url}). End your turn and say what you need the computer for. When the user answers, you get a message; run this command again then.
|
|
@@ -56145,7 +56341,7 @@ async function localControlRequestCommand(options) {
|
|
|
56145
56341
|
`));
|
|
56146
56342
|
});
|
|
56147
56343
|
}
|
|
56148
|
-
var import_child_process6, import_fs11, import_os5, import_path10, import_util10,
|
|
56344
|
+
var import_child_process6, import_fs11, import_os5, import_path10, import_util10, import_chalk34, execFileAsync2;
|
|
56149
56345
|
var init_local_control = __esm({
|
|
56150
56346
|
"src/commands/local-control.ts"() {
|
|
56151
56347
|
"use strict";
|
|
@@ -56154,7 +56350,7 @@ var init_local_control = __esm({
|
|
|
56154
56350
|
import_os5 = __toESM(require("os"));
|
|
56155
56351
|
import_path10 = __toESM(require("path"));
|
|
56156
56352
|
import_util10 = require("util");
|
|
56157
|
-
|
|
56353
|
+
import_chalk34 = __toESM(require("chalk"));
|
|
56158
56354
|
init_src();
|
|
56159
56355
|
init_api2();
|
|
56160
56356
|
init_command_utils();
|
|
@@ -56196,7 +56392,7 @@ function registerEnvironmentHookCommands(parent, config3) {
|
|
|
56196
56392
|
}
|
|
56197
56393
|
hooks.command("repository-hooks <env>").description(`List per-repo ${config3.kind} hooks defined in replicas.json / replicas.yaml`).action(run(config3.repositoryHooks));
|
|
56198
56394
|
}
|
|
56199
|
-
var import_config20, import_commander, collect, program, organizationOptionalCommands, interactiveCommands, org, config2, chat, chatQueue, share, pr, canvas, credentials, automation, repos, plugins, skills, media, environment, envVars, envFiles, envSkills, envMcps, parsePortOption, envDevices, envWarmPool, preview, authenticatedPreviewHelp;
|
|
56395
|
+
var import_config20, import_commander, collect, program, organizationOptionalCommands, interactiveCommands, org, config2, chat, chatQueue, share, pr, canvas, credentials, automation, repos, plugins, skills, media, environment, envConfig, envVars, envFiles, envSkills, envMcps, parsePortOption, envDevices, envWarmPool, preview, authenticatedPreviewHelp;
|
|
56200
56396
|
var init_src2 = __esm({
|
|
56201
56397
|
"src/index.ts"() {
|
|
56202
56398
|
"use strict";
|
|
@@ -56229,6 +56425,7 @@ var init_src2 = __esm({
|
|
|
56229
56425
|
init_media_gif();
|
|
56230
56426
|
init_visualize();
|
|
56231
56427
|
init_gpu2();
|
|
56428
|
+
init_environment_config2();
|
|
56232
56429
|
init_history();
|
|
56233
56430
|
init_skills();
|
|
56234
56431
|
init_slack4();
|
|
@@ -56397,6 +56594,12 @@ var init_src2 = __esm({
|
|
|
56397
56594
|
environment.command("create [name]").description("Create a new environment").option("-d, --description <description>", "Environment description").option("-r, --repository <names>", "Repositories to clone (comma-separated names or IDs)").option("--system-prompt <prompt>", "System prompt for agents started in this environment").action(run(environmentCreateCommand));
|
|
56398
56595
|
environment.command("edit <id-or-name>").description("Edit an environment").option("-n, --name <name>", "New name").option("-d, --description <description>", "New description").option("-r, --repository <names>", "Replace the repositories (comma-separated names or IDs; empty string for none)").option("--system-prompt <prompt>", "System prompt").action(run(environmentEditCommand));
|
|
56399
56596
|
environment.command("delete <id-or-name>").description("Delete an environment").option("-f, --force", "Skip confirmation prompt").action(run(environmentDeleteCommand));
|
|
56597
|
+
envConfig = environment.command("config").description("Link and sync environment configuration from Git");
|
|
56598
|
+
envConfig.command("get <env>").description("Show the linked configuration source and sync status").action(run(environmentConfigGetCommand));
|
|
56599
|
+
envConfig.command("preview <env>").description("Preview committed configuration changes without applying them").option("-r, --repository <name-or-id>", "Repository containing the configuration").action(run(environmentConfigPreviewCommand));
|
|
56600
|
+
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));
|
|
56601
|
+
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));
|
|
56602
|
+
envConfig.command("disconnect <env>").description("Disconnect Git configuration and preserve current settings").option("-y, --yes", "Disconnect without a confirmation prompt").action(run(environmentConfigDisconnectCommand));
|
|
56400
56603
|
envVars = environment.command("vars").description("Manage environment variables");
|
|
56401
56604
|
envVars.command("list <env>").description("List variables in an environment (values masked by default)").option("--reveal", "Show full variable values instead of masking them").action(run(envVarsListCommand));
|
|
56402
56605
|
envVars.command("set <env> <key> <value>").description("Create or update a variable").action(run(envVarsSetCommand));
|
|
@@ -56561,11 +56764,11 @@ ${VISUAL_PAGE_RULES}`).action(run(visualizeCommand));
|
|
|
56561
56764
|
|
|
56562
56765
|
// src/bin.ts
|
|
56563
56766
|
var import_node_child_process5 = require("child_process");
|
|
56564
|
-
var
|
|
56767
|
+
var import_chalk35 = __toESM(require("chalk"));
|
|
56565
56768
|
init_config();
|
|
56566
56769
|
if (process.argv[2] === "computer" && isAgentMode()) {
|
|
56567
56770
|
const result = (0, import_node_child_process5.spawnSync)("replicas-computer", process.argv.slice(3), { stdio: "inherit" });
|
|
56568
|
-
if (result.error) console.error(
|
|
56771
|
+
if (result.error) console.error(import_chalk35.default.red(`
|
|
56569
56772
|
\u2717 replicas-computer is unavailable in this workspace image
|
|
56570
56773
|
`));
|
|
56571
56774
|
process.exitCode = result.error ? 1 : result.status ?? 1;
|