replicas-cli 0.3.519 → 0.3.521
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 +106 -19
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -24579,11 +24579,45 @@ replicas gpu delete
|
|
|
24579
24579
|
});
|
|
24580
24580
|
|
|
24581
24581
|
// ../shared/src/routes/issues.ts
|
|
24582
|
-
|
|
24582
|
+
function readUnknownIssueValues(parse3) {
|
|
24583
|
+
const unknown2 = [];
|
|
24584
|
+
unknownValues = unknown2;
|
|
24585
|
+
try {
|
|
24586
|
+
return { result: parse3(), unknown: unknown2 };
|
|
24587
|
+
} finally {
|
|
24588
|
+
unknownValues = null;
|
|
24589
|
+
}
|
|
24590
|
+
}
|
|
24591
|
+
function parseIssueContractRecord(schema, value, at, report) {
|
|
24592
|
+
const { result, unknown: unknown2 } = readUnknownIssueValues(() => external_exports.safeParse(schema, value, { reportInput: true }));
|
|
24593
|
+
if (result.success) {
|
|
24594
|
+
if (unknown2.length) report.kept++;
|
|
24595
|
+
for (const raw of unknown2) report.problems.add(`${at || "snapshot"} unknown_value ${raw.slice(0, 40)}`);
|
|
24596
|
+
return result.data;
|
|
24597
|
+
}
|
|
24598
|
+
for (const issue3 of result.error.issues) {
|
|
24599
|
+
const path12 = [at, ...issue3.path.map((key) => typeof key === "number" || UUID_RE.test(String(key)) ? "*" : String(key))].filter(Boolean).join(".");
|
|
24600
|
+
report.problems.add(`${path12} ${issue3.code}${issue3.code === "invalid_value" ? ` ${String(issue3.input).slice(0, 40)}` : ""}`);
|
|
24601
|
+
}
|
|
24602
|
+
report.dropped++;
|
|
24603
|
+
return void 0;
|
|
24604
|
+
}
|
|
24605
|
+
function parseIssueContractResponse(schema, value, report) {
|
|
24606
|
+
const rows = isRecord(value) ? Object.fromEntries(Object.entries(value).map(([key, raw]) => {
|
|
24607
|
+
const field2 = schema.shape[key];
|
|
24608
|
+
return [key, field2 instanceof external_exports.ZodArray && Array.isArray(raw) ? raw.filter((row) => parseIssueContractRecord(field2.element, row, key, report) !== void 0) : raw];
|
|
24609
|
+
})) : value;
|
|
24610
|
+
const parsed = external_exports.safeParse(schema, rows);
|
|
24611
|
+
if (!parsed.success) for (const issue3 of parsed.error.issues) report.problems.add(`${issue3.path.join(".")} ${issue3.code}`);
|
|
24612
|
+
return parsed.data;
|
|
24613
|
+
}
|
|
24614
|
+
var ISSUE_STATUSES, ISSUE_PRIORITIES, ISSUE_ACTOR_TYPES, ISSUE_SUBSCRIBER_ROLES, ISSUE_RELATION_TYPES, ISSUE_PULL_REQUEST_STATES, normalizeIssueStatus, ISSUE_STATUSES_HEADER, issueStatusSchema, issuePrioritySchema, issueSubscriberRoleSchema, issueRelationTypeSchema, issuePullRequestStateSchema, ISSUE_STATUS_LABELS, ISSUE_PRIORITY_LABELS, unknownValues, knownOrRaw, createIssueContractReport, knownIssueActorSchema, issueActorSchema, ISSUE_KEY_RE, timestamp, nullableTimestamp, issueSchema, issueSubscriberSchema, issueRelationSchema, issuePullRequestSchema, issueCommentSchema, change, nullableId, issueEventDataSchemas, issueEventBase, v, issueEventVariants, created, laterVariants, issueEventSchema, clientMutationId, title, description, body, createIssueRequestSchema, updateIssueRequestSchema, issueActorRequestSchema, createIssueCommentRequestSchema, updateIssueCommentRequestSchema, createIssueRelationRequestSchema, linkIssuePullRequestRequestSchema, updateIssuePullRequestRequestSchema, issueMutationRequestSchema, updateIssueSettingsRequestSchema, listIssuesQuerySchema, issueDetailResponseSchema, listIssuesResponseSchema, issueDirectoryUserSchema, issueDirectoryWorkspaceSchema, issuesBootstrapResponseSchema, issuesDeltaQuerySchema, issuesDeltaResponseSchema, issueInboxQuerySchema, markIssueInboxReadRequestSchema, ISSUE_COMMANDS;
|
|
24583
24615
|
var init_issues = __esm({
|
|
24584
24616
|
"../shared/src/routes/issues.ts"() {
|
|
24585
24617
|
"use strict";
|
|
24586
24618
|
init_zod();
|
|
24619
|
+
init_type_guards();
|
|
24620
|
+
init_uuid();
|
|
24587
24621
|
init_manager();
|
|
24588
24622
|
init_workspaces();
|
|
24589
24623
|
ISSUE_STATUSES = ["backlog", "todo", "in_progress", "review", "approved", "done", "canceled", "duplicate"];
|
|
@@ -24607,10 +24641,12 @@ var init_issues = __esm({
|
|
|
24607
24641
|
unknownValues?.push(value);
|
|
24608
24642
|
return true;
|
|
24609
24643
|
})]);
|
|
24610
|
-
|
|
24644
|
+
createIssueContractReport = () => ({ problems: /* @__PURE__ */ new Set(), dropped: 0, kept: 0 });
|
|
24645
|
+
knownIssueActorSchema = external_exports.object({
|
|
24611
24646
|
type: external_exports.enum(ISSUE_ACTOR_TYPES),
|
|
24612
24647
|
id: external_exports.string().toLowerCase().uuid()
|
|
24613
24648
|
});
|
|
24649
|
+
issueActorSchema = knownIssueActorSchema.extend({ type: knownOrRaw(knownIssueActorSchema.shape.type) });
|
|
24614
24650
|
ISSUE_KEY_RE = /^[A-Z][A-Z0-9]{0,9}$/;
|
|
24615
24651
|
timestamp = external_exports.string();
|
|
24616
24652
|
nullableTimestamp = timestamp.nullable();
|
|
@@ -24724,8 +24760,8 @@ var init_issues = __esm({
|
|
|
24724
24760
|
parent_id: external_exports.string().uuid().optional(),
|
|
24725
24761
|
manager_id: external_exports.string().uuid().optional(),
|
|
24726
24762
|
sort_order: external_exports.number().finite().optional(),
|
|
24727
|
-
assignees: external_exports.array(
|
|
24728
|
-
subscribers: external_exports.array(
|
|
24763
|
+
assignees: external_exports.array(knownIssueActorSchema).max(20).optional(),
|
|
24764
|
+
subscribers: external_exports.array(knownIssueActorSchema).max(50).optional(),
|
|
24729
24765
|
client_mutation_id: clientMutationId
|
|
24730
24766
|
});
|
|
24731
24767
|
updateIssueRequestSchema = external_exports.object({
|
|
@@ -24739,7 +24775,7 @@ var init_issues = __esm({
|
|
|
24739
24775
|
sort_order: external_exports.number().finite().optional(),
|
|
24740
24776
|
client_mutation_id: clientMutationId
|
|
24741
24777
|
});
|
|
24742
|
-
issueActorRequestSchema =
|
|
24778
|
+
issueActorRequestSchema = knownIssueActorSchema.partial().extend({ client_mutation_id: clientMutationId });
|
|
24743
24779
|
createIssueCommentRequestSchema = external_exports.object({
|
|
24744
24780
|
id: external_exports.string().uuid().optional(),
|
|
24745
24781
|
body,
|
|
@@ -27358,7 +27394,7 @@ var init_environment_config = __esm({
|
|
|
27358
27394
|
});
|
|
27359
27395
|
|
|
27360
27396
|
// ../shared/src/routes/environment-config-source.ts
|
|
27361
|
-
var ENVIRONMENT_CONFIG_PREFERENCES, ENVIRONMENT_CONFIG_SETTING_FIELDS, environmentConfigLocationSchema, sourceInput, previewEnvironmentConfigSourceRequestSchema, applyEnvironmentConfigSourceRequestSchema;
|
|
27397
|
+
var ENVIRONMENT_CONFIG_PREFERENCES, ENVIRONMENT_CONFIG_SETTING_FIELDS, environmentConfigLocationSchema, sourceInput, previewEnvironmentConfigSourceRequestSchema, applyEnvironmentConfigSourceRequestSchema, validateEnvironmentConfigRequestSchema;
|
|
27362
27398
|
var init_environment_config_source = __esm({
|
|
27363
27399
|
"../shared/src/routes/environment-config-source.ts"() {
|
|
27364
27400
|
"use strict";
|
|
@@ -27402,6 +27438,7 @@ var init_environment_config_source = __esm({
|
|
|
27402
27438
|
}).refine((input2) => input2.file ? !input2.repository_id && !input2.commit_sha : !!input2.commit_sha, {
|
|
27403
27439
|
message: "File configuration requires file contents; Git configuration requires a reviewed commit"
|
|
27404
27440
|
});
|
|
27441
|
+
validateEnvironmentConfigRequestSchema = external_exports.strictObject({ environment: replicasEnvironmentConfigSchema });
|
|
27405
27442
|
}
|
|
27406
27443
|
});
|
|
27407
27444
|
|
|
@@ -40203,7 +40240,7 @@ var CLI_VERSION;
|
|
|
40203
40240
|
var init_cli_version = __esm({
|
|
40204
40241
|
"../shared/src/cli-version.ts"() {
|
|
40205
40242
|
"use strict";
|
|
40206
|
-
CLI_VERSION = "0.3.
|
|
40243
|
+
CLI_VERSION = "0.3.521";
|
|
40207
40244
|
}
|
|
40208
40245
|
});
|
|
40209
40246
|
|
|
@@ -56395,6 +56432,46 @@ var init_preview = __esm({
|
|
|
56395
56432
|
}
|
|
56396
56433
|
});
|
|
56397
56434
|
|
|
56435
|
+
// ../shared/src/media-url.ts
|
|
56436
|
+
function readImageSize(read) {
|
|
56437
|
+
let bytes = read(0);
|
|
56438
|
+
let view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
56439
|
+
const ascii = (at, length) => String.fromCharCode(...bytes.subarray(at, at + length));
|
|
56440
|
+
const size = (width, height, exif2 = false) => width > 0 && height > 0 ? { width, height, exif: exif2 } : null;
|
|
56441
|
+
if (bytes.length >= 24 && ascii(1, 3) === "PNG") return size(view.getUint32(16), view.getUint32(20));
|
|
56442
|
+
if (bytes.length >= 10 && ascii(0, 3) === "GIF") return size(view.getUint16(6, true), view.getUint16(8, true));
|
|
56443
|
+
if (bytes.length >= 31 && ascii(0, 4) === "RIFF" && ascii(8, 4) === "WEBP") {
|
|
56444
|
+
const chunk = ascii(12, 4);
|
|
56445
|
+
if (chunk === "VP8X") return size(1 + (view.getUint32(24, true) & 16777215), 1 + (view.getUint32(27, true) & 16777215));
|
|
56446
|
+
if (chunk === "VP8 ") return size(view.getUint16(26, true) & 16383, view.getUint16(28, true) & 16383);
|
|
56447
|
+
if (chunk === "VP8L") {
|
|
56448
|
+
const bits = view.getUint32(21, true);
|
|
56449
|
+
return size(1 + (bits & 16383), 1 + (bits >> 14 & 16383));
|
|
56450
|
+
}
|
|
56451
|
+
return null;
|
|
56452
|
+
}
|
|
56453
|
+
if (bytes[0] !== 255 || bytes[1] !== 216) return null;
|
|
56454
|
+
let exif = false;
|
|
56455
|
+
for (let at = 2; ; ) {
|
|
56456
|
+
bytes = read(at);
|
|
56457
|
+
view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
56458
|
+
if (bytes.length < 9 || bytes[0] !== 255) return null;
|
|
56459
|
+
const marker = bytes[1];
|
|
56460
|
+
if (marker === 225) exif = true;
|
|
56461
|
+
if (marker >= 192 && marker <= 207 && marker !== 196 && marker !== 200 && marker !== 204) return size(view.getUint16(7), view.getUint16(5), exif);
|
|
56462
|
+
at += 2 + view.getUint16(2);
|
|
56463
|
+
}
|
|
56464
|
+
}
|
|
56465
|
+
var REPLICAS_WEB_ORIGIN, withImageSize;
|
|
56466
|
+
var init_media_url = __esm({
|
|
56467
|
+
"../shared/src/media-url.ts"() {
|
|
56468
|
+
"use strict";
|
|
56469
|
+
init_urls();
|
|
56470
|
+
REPLICAS_WEB_ORIGIN = new URL(DEFAULT_WEB_APP_URL).origin;
|
|
56471
|
+
withImageSize = (url2, size) => size ? `${url2}#w=${size.width}&h=${size.height}` : url2;
|
|
56472
|
+
}
|
|
56473
|
+
});
|
|
56474
|
+
|
|
56398
56475
|
// src/commands/media.ts
|
|
56399
56476
|
function publicMediaUrl(mediaId, token) {
|
|
56400
56477
|
return `${MONOLITH_URL}/v1/media/public/${mediaId}/${token}`;
|
|
@@ -56455,11 +56532,13 @@ async function uploadOne(filePath, displayName, kind, options) {
|
|
|
56455
56532
|
const fileName = import_path6.default.basename(absPath);
|
|
56456
56533
|
const ext = import_path6.default.extname(absPath).slice(1).toLowerCase();
|
|
56457
56534
|
const contentType = mediaInfo(ext)?.contentType ?? "application/octet-stream";
|
|
56458
|
-
|
|
56535
|
+
const body2 = import_fs7.default.readFileSync(absPath);
|
|
56536
|
+
const media2 = await uploadMedia(new Blob([body2], { type: contentType }), fileName, {
|
|
56459
56537
|
kind,
|
|
56460
56538
|
display_name: displayName,
|
|
56461
56539
|
session_id: options.sessionId || void 0
|
|
56462
56540
|
});
|
|
56541
|
+
return { media: media2, imageSize: kind === MEDIA_KIND.IMAGE ? readImageSize((offset) => body2.subarray(offset)) : null };
|
|
56463
56542
|
}
|
|
56464
56543
|
async function mediaUploadCommand(filePaths, options) {
|
|
56465
56544
|
if (filePaths.length === 0) {
|
|
@@ -56497,7 +56576,7 @@ async function mediaUploadCommand(filePaths, options) {
|
|
|
56497
56576
|
);
|
|
56498
56577
|
const shareResults = await Promise.allSettled(
|
|
56499
56578
|
results.map(
|
|
56500
|
-
(result, i) => result.status === "fulfilled" && shared[i] ? shareMedia(result.value.id) : Promise.resolve(null)
|
|
56579
|
+
(result, i) => result.status === "fulfilled" && shared[i] ? shareMedia(result.value.media.id) : Promise.resolve(null)
|
|
56501
56580
|
)
|
|
56502
56581
|
);
|
|
56503
56582
|
const config3 = readAgentConfig();
|
|
@@ -56506,7 +56585,7 @@ async function mediaUploadCommand(filePaths, options) {
|
|
|
56506
56585
|
for (let i = 0; i < results.length; i++) {
|
|
56507
56586
|
const result = results[i];
|
|
56508
56587
|
if (result.status === "fulfilled") {
|
|
56509
|
-
const media2 = result.value;
|
|
56588
|
+
const { media: media2, imageSize } = result.value;
|
|
56510
56589
|
const shareResult = shareResults[i];
|
|
56511
56590
|
const publicUrl = shareResult?.status === "fulfilled" ? shareResult.value ?? void 0 : void 0;
|
|
56512
56591
|
if (shared[i]) {
|
|
@@ -56526,7 +56605,7 @@ async function mediaUploadCommand(filePaths, options) {
|
|
|
56526
56605
|
name: names[i],
|
|
56527
56606
|
media: media2,
|
|
56528
56607
|
public_url: publicUrl,
|
|
56529
|
-
embed: !shared[i] || publicUrl ? formatMediaEmbed(names[i], media2, publicUrl) : void 0,
|
|
56608
|
+
embed: !shared[i] || publicUrl ? formatMediaEmbed(names[i], media2, publicUrl && withImageSize(publicUrl, imageSize && !imageSize.exif ? imageSize : null)) : void 0,
|
|
56530
56609
|
organization_url: options.access === "organization" && !shared[i] ? getOrganizationMediaUrl(media2.organization_id, media2.id) : void 0,
|
|
56531
56610
|
dashboard_url: config3?.workspace_id ? getWorkspaceDashboardUrl(config3.workspace_id, { mode: "media", mediaId: media2.id }) : void 0
|
|
56532
56611
|
});
|
|
@@ -56596,6 +56675,7 @@ var init_media3 = __esm({
|
|
|
56596
56675
|
init_api2();
|
|
56597
56676
|
init_config();
|
|
56598
56677
|
init_monolith_url();
|
|
56678
|
+
init_media_url();
|
|
56599
56679
|
init_output();
|
|
56600
56680
|
init_src();
|
|
56601
56681
|
MEDIA_ACCESS_VALUES = ["organization", "public"];
|
|
@@ -56695,18 +56775,24 @@ var init_media_gif = __esm({
|
|
|
56695
56775
|
// src/commands/issue.ts
|
|
56696
56776
|
async function callIssueTool(name, args, schema) {
|
|
56697
56777
|
if (!isAgentMode() && !getApiKey()) throw new Error("replicas issue needs an API key: run `replicas login --api-key`, or use it inside a workspace.");
|
|
56778
|
+
let response;
|
|
56698
56779
|
try {
|
|
56699
|
-
|
|
56780
|
+
response = await orgAuthenticatedFetch(`/v1/issue-commands/${name}`, { method: "POST", body: args, headers: { [ISSUE_STATUSES_HEADER]: "1" } });
|
|
56700
56781
|
} catch (error62) {
|
|
56701
56782
|
if (error62 instanceof ApiError && error62.status === 404 && error62.message === "Not found") throw new Error("Issues are not enabled for this organization");
|
|
56702
56783
|
throw error62;
|
|
56703
56784
|
}
|
|
56785
|
+
const report = createIssueContractReport();
|
|
56786
|
+
const parsed = parseIssueContractResponse(schema, response, report);
|
|
56787
|
+
if (parsed === void 0) throw new Error(`Unexpected response from the server: ${[...report.problems].join("; ")}`);
|
|
56788
|
+
if (report.dropped) console.error(import_chalk29.default.yellow(`Skipped ${report.dropped} record(s) this CLI can't read: ${[...report.problems].filter((problem) => !problem.includes("unknown_value")).join("; ")}`));
|
|
56789
|
+
return parsed;
|
|
56704
56790
|
}
|
|
56705
56791
|
async function uploadAttachments(files) {
|
|
56706
56792
|
if (!files?.length) return void 0;
|
|
56707
56793
|
if (!isAgentMode()) throw new Error("--attach works inside a workspace. Elsewhere, embed an image URL in the markdown.");
|
|
56708
56794
|
const uploaded = await Promise.all(files.map((file2) => uploadOne(file2, import_node_path2.default.basename(file2), resolveKind(import_node_path2.default.extname(file2).slice(1).toLowerCase()), {})));
|
|
56709
|
-
return uploaded.map((media2) => media2.id);
|
|
56795
|
+
return uploaded.map(({ media: media2 }) => media2.id);
|
|
56710
56796
|
}
|
|
56711
56797
|
function readText(inline, file2, what) {
|
|
56712
56798
|
if (inline !== void 0 && file2 !== void 0) throw new Error(`Pass either --${what} or --${what}-file, not both`);
|
|
@@ -56776,23 +56862,23 @@ async function issueCommentCommand(issue3, body2, options) {
|
|
|
56776
56862
|
const text4 = readText(body2, options.file, "file") ?? "";
|
|
56777
56863
|
const media_ids = await uploadAttachments(options.attach);
|
|
56778
56864
|
if (!text4.trim() && !media_ids) throw new Error("Pass the comment text, --file, or --attach");
|
|
56779
|
-
output2(await callIssueTool(ISSUE_COMMANDS.comment, { issue: issue3, body: text4, media_ids },
|
|
56865
|
+
output2(await callIssueTool(ISSUE_COMMANDS.comment, { issue: issue3, body: text4, media_ids }, noData), () => console.log(`${import_chalk29.default.green("\u2713")} Commented on ${issue3}`));
|
|
56780
56866
|
}
|
|
56781
56867
|
function issueActorCommand(tool, done) {
|
|
56782
56868
|
return async (issue3, who) => {
|
|
56783
|
-
output2(await callIssueTool(tool, { issue: issue3, who },
|
|
56869
|
+
output2(await callIssueTool(tool, { issue: issue3, who }, noData), () => console.log(`${import_chalk29.default.green("\u2713")} ${done} ${who ?? "you"} ${tool.startsWith("un") ? "from" : "to"} ${issue3}`));
|
|
56784
56870
|
};
|
|
56785
56871
|
}
|
|
56786
56872
|
async function issueLinkPrCommand(issue3, url2) {
|
|
56787
|
-
output2(await callIssueTool(ISSUE_COMMANDS.linkPr, { issue: issue3, url: url2 },
|
|
56873
|
+
output2(await callIssueTool(ISSUE_COMMANDS.linkPr, { issue: issue3, url: url2 }, noData), () => console.log(`${import_chalk29.default.green("\u2713")} Linked ${url2} to ${issue3}`));
|
|
56788
56874
|
}
|
|
56789
56875
|
async function issueUnlinkPrCommand(issue3, url2) {
|
|
56790
|
-
output2(await callIssueTool(ISSUE_COMMANDS.unlinkPr, { issue: issue3, url: url2 },
|
|
56876
|
+
output2(await callIssueTool(ISSUE_COMMANDS.unlinkPr, { issue: issue3, url: url2 }, noData), () => console.log(`${import_chalk29.default.green("\u2713")} Unlinked ${url2} from ${issue3}`));
|
|
56791
56877
|
}
|
|
56792
56878
|
async function issueRelateCommand(issue3, type, related) {
|
|
56793
|
-
output2(await callIssueTool(ISSUE_COMMANDS.relate, { issue: issue3, type, related_issue: related },
|
|
56879
|
+
output2(await callIssueTool(ISSUE_COMMANDS.relate, { issue: issue3, type, related_issue: related }, noData), () => console.log(`${import_chalk29.default.green("\u2713")} ${issue3} ${type.replace("_", " ")} ${related}`));
|
|
56794
56880
|
}
|
|
56795
|
-
var import_node_fs2, import_node_path2, import_chalk29, mutationSchema, csv, printMutation;
|
|
56881
|
+
var import_node_fs2, import_node_path2, import_chalk29, mutationSchema, noData, csv, printMutation;
|
|
56796
56882
|
var init_issue = __esm({
|
|
56797
56883
|
"src/commands/issue.ts"() {
|
|
56798
56884
|
"use strict";
|
|
@@ -56806,6 +56892,7 @@ var init_issue = __esm({
|
|
|
56806
56892
|
init_output();
|
|
56807
56893
|
init_media3();
|
|
56808
56894
|
mutationSchema = external_exports.object({ issue: issueSchema });
|
|
56895
|
+
noData = external_exports.looseObject({});
|
|
56809
56896
|
csv = (value) => value?.split(",").map((entry) => entry.trim()).filter(Boolean).join(",");
|
|
56810
56897
|
printMutation = ({ issue: issue3 }) => console.log(`${import_chalk29.default.green("\u2713")} ${import_chalk29.default.cyan(issue3.identifier)} ${issue3.title} (${issue3.status})`);
|
|
56811
56898
|
}
|