@chosengeneration/light-code 0.77.0 → 0.80.1

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/cli.js CHANGED
@@ -40350,7 +40350,16 @@ var s3MirrorSchema = external_exports.object({
40350
40350
  connectionId: external_exports.string().min(1),
40351
40351
  prefix: external_exports.string().optional(),
40352
40352
  /** Off by default: reading a bucket on every panel open is somebody's money and latency. */
40353
- enabled: external_exports.boolean().optional()
40353
+ enabled: external_exports.boolean().optional(),
40354
+ /**
40355
+ * New skills written here are also copied up to this folder.
40356
+ *
40357
+ * At most one folder should carry it, and the bridge takes the first that does. The rest are
40358
+ * read-only sources, which is the same split the local folders already have: one place new
40359
+ * skills are saved, and any number of folders they are *also* read from. A list where every
40360
+ * entry was writable would make "where did that skill go" unanswerable.
40361
+ */
40362
+ publish: external_exports.boolean().optional()
40354
40363
  });
40355
40364
  var s3ConfigSchema = external_exports.object({
40356
40365
  connections: external_exports.array(s3ConnectionSchema).max(20).optional(),
@@ -40359,8 +40368,12 @@ var s3ConfigSchema = external_exports.object({
40359
40368
  *
40360
40369
  * Only the *files* move. They are still loaded, watched and indexed exactly as local ones are —
40361
40370
  * indexing stays as configured — so this names a sync, not a second kind of skill.
40371
+ *
40372
+ * A **list**, because it maps onto the split the local folders already have: any number of
40373
+ * folders skills are read from, and one place new ones are saved. A bucket folder is one more
40374
+ * source, so several of them is the ordinary case rather than a special one.
40362
40375
  */
40363
- skills: s3MirrorSchema.optional(),
40376
+ skills: external_exports.array(s3MirrorSchema).max(8).optional(),
40364
40377
  /**
40365
40378
  * The same for Python tools, with one difference that is not a detail.
40366
40379
  *
@@ -40369,7 +40382,7 @@ var s3ConfigSchema = external_exports.object({
40369
40382
  * and approval still happens on each one. Anybody with write access to the bucket would
40370
40383
  * otherwise be running code as this user on every machine that syncs.
40371
40384
  */
40372
- tools: s3MirrorSchema.optional()
40385
+ tools: external_exports.array(s3MirrorSchema).max(8).optional()
40373
40386
  });
40374
40387
  var configSchema = external_exports.object({
40375
40388
  profiles: external_exports.array(providerProfileSchema),
@@ -43712,6 +43725,10 @@ function isValidRoleId(id) {
43712
43725
  function isAgentRole(value, custom2 = []) {
43713
43726
  return AGENT_ROLES.includes(value) || custom2.some((role) => role.id === value);
43714
43727
  }
43728
+ var COLOURED_NON_ROLES = ["claude"];
43729
+ function isColourableAgent(value, custom2 = []) {
43730
+ return isAgentRole(value, custom2) || COLOURED_NON_ROLES.includes(value);
43731
+ }
43715
43732
  function knownRoles(custom2 = []) {
43716
43733
  return [...AGENT_ROLES, ...custom2.map((role) => role.id)];
43717
43734
  }
@@ -58853,8 +58870,8 @@ async function runAgentTurn(provider, conversation, userMessage, toolRegistry, t
58853
58870
  events.onToolResult(toolCall, result);
58854
58871
  const queued = options.drainQueuedMessages?.() ?? [];
58855
58872
  for (const message3 of queued) {
58856
- conversation.addUserMessage(message3);
58857
- events.onQueuedMessageConsumed?.(message3);
58873
+ conversation.addUserMessage(message3.text, message3.images);
58874
+ events.onQueuedMessageConsumed?.(message3.text);
58858
58875
  }
58859
58876
  if (queued.length > 0) {
58860
58877
  iteration = -1;
@@ -62185,7 +62202,7 @@ function wireChatBridge(services) {
62185
62202
  const { transport, secrets, ui, workspaceRoot, storageDir } = services;
62186
62203
  const logger = new Logger({ level: "debug", sink: services.logSink });
62187
62204
  const configManager = new ConfigManager(services.configStore, services.workspaceRoot);
62188
- const httpClient = services.httpClient ?? new FetchHttpClient();
62205
+ const httpClient = services.httpClient ?? new FetchHttpClient({ useEnvProxy: true });
62189
62206
  const conversation = new Conversation(workspaceRoot !== void 0 ? buildSystemPrompt(workspaceRoot) : void 0);
62190
62207
  let cachedSecretValues = [];
62191
62208
  const truncationStore = new RecordingTruncationStore(new DiskTruncationStore(path24.join(storageDir, "tool-results"), () => cachedSecretValues));
@@ -62278,9 +62295,9 @@ ${preview.text}` } : {}
62278
62295
  const defaultSkillsDir = workspaceRoot !== void 0 ? path24.join(workspaceRoot, ".lightcode", "skills") : void 0;
62279
62296
  let skillsDir = defaultSkillsDir;
62280
62297
  let extraSkillDirs = [];
62281
- let mirroredSkillsDir;
62282
- let mirroredToolsDir;
62283
- let cachedSkillMirror;
62298
+ let mirroredSkillsDirs = [];
62299
+ let mirroredToolsDirs = [];
62300
+ let cachedSkillMirrors = [];
62284
62301
  let lastSync = {};
62285
62302
  function resolveSkillDir(entry) {
62286
62303
  const trimmed = entry.trim();
@@ -62483,7 +62500,15 @@ ${preview.text}` } : {}
62483
62500
  }
62484
62501
  let queuedMessages = [];
62485
62502
  function postQueued() {
62486
- post({ type: "queued", messages: [...queuedMessages] });
62503
+ post({
62504
+ type: "queued",
62505
+ // A count, not the attachments: the composer only needs to say one is there, and sending
62506
+ // the bytes back for something already on screen would be waste.
62507
+ messages: queuedMessages.map((entry) => ({
62508
+ text: entry.text,
62509
+ ...entry.images !== void 0 && entry.images.length > 0 ? { images: entry.images.length } : {}
62510
+ }))
62511
+ });
62487
62512
  }
62488
62513
  let activeAbortController;
62489
62514
  let taskCheckpoint;
@@ -62934,20 +62959,20 @@ ${preview.text}` } : {}
62934
62959
  cachedReadRoots = (config2.filesystem?.readRoots ?? []).map((entry) => entry.trim()).filter((entry) => entry.length > 0);
62935
62960
  skillsDir = (config2.skills?.dir !== void 0 ? resolveSkillDir(config2.skills.dir) : void 0) ?? defaultSkillsDir;
62936
62961
  extraSkillDirs = (config2.skills?.paths ?? []).map(resolveSkillDir).filter((dir) => dir !== void 0);
62937
- const skillMirror = config2.s3?.skills;
62938
- cachedSkillMirror = skillMirror;
62939
- if (skillMirror?.enabled === true) {
62940
- mirroredSkillsDir = mirrorFolder({
62941
- storageDir,
62942
- connectionId: skillMirror.connectionId,
62943
- kind: "skills",
62944
- ...skillMirror.prefix !== void 0 ? { prefix: skillMirror.prefix } : {}
62945
- });
62946
- if (mirroredSkillsDir !== void 0)
62947
- extraSkillDirs.push(mirroredSkillsDir);
62948
- } else {
62949
- mirroredSkillsDir = void 0;
62950
- }
62962
+ cachedSkillMirrors = config2.s3?.skills ?? [];
62963
+ mirroredSkillsDirs = cachedSkillMirrors.filter((mirror) => mirror.enabled === true).map((mirror) => mirrorFolder({
62964
+ storageDir,
62965
+ connectionId: mirror.connectionId,
62966
+ kind: "skills",
62967
+ ...mirror.prefix !== void 0 ? { prefix: mirror.prefix } : {}
62968
+ }));
62969
+ extraSkillDirs.push(...mirroredSkillsDirs);
62970
+ mirroredToolsDirs = (config2.s3?.tools ?? []).filter((mirror) => mirror.enabled === true).map((mirror) => mirrorFolder({
62971
+ storageDir,
62972
+ connectionId: mirror.connectionId,
62973
+ kind: "tools",
62974
+ ...mirror.prefix !== void 0 ? { prefix: mirror.prefix } : {}
62975
+ }));
62951
62976
  return config2;
62952
62977
  }
62953
62978
  function announceConfigRecovery() {
@@ -63117,8 +63142,9 @@ ${preview.text}` } : {}
63117
63142
  submitForReview: (request) => services.submitForReview?.({ kind: "skill", ...request }) ?? Promise.resolve("")
63118
63143
  } : {}
63119
63144
  };
63120
- const skillTarget = cachedSkillMirror?.enabled === true ? targetById(cachedS3, cachedSkillMirror.connectionId) : void 0;
63121
- const mirrorPrefix = cachedSkillMirror?.prefix;
63145
+ const publishTo = cachedSkillMirrors.find((mirror) => mirror.enabled === true && mirror.publish === true);
63146
+ const skillTarget = publishTo === void 0 ? void 0 : targetById(cachedS3, publishTo.connectionId);
63147
+ const mirrorPrefix = publishTo?.prefix;
63122
63148
  combined.register(createWriteSkillTool({
63123
63149
  ...context,
63124
63150
  ...skillTarget !== void 0 && skillTarget.readOnly !== true ? {
@@ -63601,7 +63627,25 @@ ${direction}` : attachMentions(text, mentions);
63601
63627
  const drained = queuedMessages;
63602
63628
  queuedMessages = [];
63603
63629
  postQueued();
63604
- return drained;
63630
+ return drained.map((entry) => {
63631
+ const attachments = entry.images ?? [];
63632
+ if (attachments.length === 0)
63633
+ return { text: entry.text };
63634
+ if (!capabilities.supportsVision) {
63635
+ post({
63636
+ type: "error",
63637
+ message: `${profile.model} does not accept images. The attachment on a queued message was not sent \u2014 set "Supports images" in the profile's advanced settings if that is wrong.`
63638
+ });
63639
+ return { text: entry.text };
63640
+ }
63641
+ return {
63642
+ text: entry.text,
63643
+ images: attachments.map((image) => ({
63644
+ mediaType: image.mediaType,
63645
+ data: image.data
63646
+ }))
63647
+ };
63648
+ });
63605
63649
  }
63606
63650
  };
63607
63651
  if (images !== void 0 && images.length > 0 && capabilities.supportsVision) {
@@ -63797,10 +63841,11 @@ ${direction}` : attachMentions(text, mentions);
63797
63841
  await persistActiveTask();
63798
63842
  await postTasks();
63799
63843
  if (queuedMessages.length > 0 && activeAbortController === void 0) {
63800
- const next = queuedMessages.join("\n\n");
63844
+ const next = queuedMessages.map((entry) => entry.text).join("\n\n");
63845
+ const images2 = queuedMessages.flatMap((entry) => entry.images ?? []);
63801
63846
  queuedMessages = [];
63802
63847
  postQueued();
63803
- void handleSendMessage(next);
63848
+ void handleSendMessage(next, images2.length > 0 ? images2 : void 0);
63804
63849
  }
63805
63850
  }
63806
63851
  }
@@ -65322,10 +65367,10 @@ ${direction}` : attachMentions(text, mentions);
65322
65367
  type: "s3",
65323
65368
  connections,
65324
65369
  problems: cachedS3.problems,
65325
- ...config2.s3?.skills !== void 0 ? { skills: config2.s3.skills } : {},
65326
- ...config2.s3?.tools !== void 0 ? { tools: config2.s3.tools } : {},
65327
- ...mirroredSkillsDir !== void 0 ? { skillsFolder: mirroredSkillsDir } : {},
65328
- ...mirroredToolsDir !== void 0 ? { toolsFolder: mirroredToolsDir } : {},
65370
+ skills: config2.s3?.skills ?? [],
65371
+ tools: config2.s3?.tools ?? [],
65372
+ skillsFolders: mirroredSkillsDirs,
65373
+ toolsFolders: mirroredToolsDirs,
65329
65374
  ...lastSync.skills !== void 0 ? { lastSkillsSync: lastSync.skills } : {},
65330
65375
  ...lastSync.tools !== void 0 ? { lastToolsSync: lastSync.tools } : {}
65331
65376
  });
@@ -65368,81 +65413,84 @@ ${direction}` : attachMentions(text, mentions);
65368
65413
  await secrets.delete(s3TokenRef(id)).catch(() => void 0);
65369
65414
  const s3 = { ...config2.s3 ?? {} };
65370
65415
  s3.connections = (s3.connections ?? []).filter((connection) => connection.id !== id);
65371
- if (s3.skills?.connectionId === id)
65416
+ s3.skills = (s3.skills ?? []).filter((mirror) => mirror.connectionId !== id);
65417
+ s3.tools = (s3.tools ?? []).filter((mirror) => mirror.connectionId !== id);
65418
+ if (s3.skills.length === 0)
65372
65419
  delete s3.skills;
65373
- if (s3.tools?.connectionId === id)
65420
+ if (s3.tools.length === 0)
65374
65421
  delete s3.tools;
65375
65422
  await configManager.save("user", { s3 });
65376
65423
  await loadSettings();
65377
65424
  await postS3();
65378
65425
  }
65379
- async function handleSaveS3Mirror(kind, connectionId, prefix, enabled) {
65426
+ async function handleSaveS3Mirrors(kind, mirrors) {
65380
65427
  const { config: config2 } = await configManager.load();
65381
65428
  const s3 = { ...config2.s3 ?? {} };
65382
- if (connectionId.trim().length === 0)
65429
+ const cleaned = mirrors.filter((mirror) => mirror.connectionId.trim().length > 0).map((mirror) => ({
65430
+ connectionId: mirror.connectionId.trim(),
65431
+ ...mirror.prefix !== void 0 && mirror.prefix.trim().length > 0 ? { prefix: mirror.prefix.trim() } : {},
65432
+ ...mirror.enabled === true ? { enabled: true } : {},
65433
+ ...mirror.publish === true ? { publish: true } : {}
65434
+ }));
65435
+ if (cleaned.length === 0)
65383
65436
  delete s3[kind];
65384
- else {
65385
- s3[kind] = {
65386
- connectionId: connectionId.trim(),
65387
- ...prefix !== void 0 && prefix.trim().length > 0 ? { prefix: prefix.trim() } : {},
65388
- enabled
65389
- };
65390
- }
65437
+ else
65438
+ s3[kind] = cleaned;
65391
65439
  await configManager.save("user", { s3 });
65392
65440
  await loadSettings();
65393
- if (enabled && connectionId.trim().length > 0)
65441
+ if (cleaned.some((mirror) => mirror.enabled === true))
65394
65442
  await handleSyncS3(kind);
65395
65443
  else
65396
65444
  await postS3();
65397
65445
  }
65398
65446
  async function handleSyncS3(kind) {
65399
65447
  const { config: config2 } = await configManager.load();
65400
- const mirror = config2.s3?.[kind];
65401
- if (mirror === void 0) {
65448
+ const mirrors = (config2.s3?.[kind] ?? []).filter((mirror) => mirror.enabled === true);
65449
+ if (mirrors.length === 0) {
65402
65450
  lastSync = { ...lastSync, [kind]: "No bucket folder is configured." };
65403
65451
  await postS3();
65404
65452
  return;
65405
65453
  }
65406
- const target = targetById(cachedS3, mirror.connectionId);
65407
- if (target === void 0) {
65408
- lastSync = {
65409
- ...lastSync,
65410
- [kind]: "That connection is not usable - check its key in the list above."
65411
- };
65412
- await postS3();
65413
- return;
65414
- }
65415
- const localDir = mirrorFolder({
65416
- storageDir,
65417
- connectionId: mirror.connectionId,
65418
- kind,
65419
- ...mirror.prefix !== void 0 ? { prefix: mirror.prefix } : {}
65420
- });
65421
- if (kind === "tools")
65422
- mirroredToolsDir = localDir;
65423
- try {
65424
- const result = await syncFromS3({
65425
- target,
65426
- ...mirror.prefix !== void 0 ? { prefix: mirror.prefix } : {},
65427
- localDir,
65428
- fs: new NodeFileSystem(),
65429
- extensions: kind === "skills" ? [".md"] : [".py"]
65454
+ const lines = [];
65455
+ for (const mirror of mirrors) {
65456
+ const target = targetById(cachedS3, mirror.connectionId);
65457
+ const where = `${mirror.connectionId}/${mirror.prefix ?? ""}`;
65458
+ if (target === void 0) {
65459
+ lines.push(`${where}: connection unusable - check its key above`);
65460
+ continue;
65461
+ }
65462
+ const localDir = mirrorFolder({
65463
+ storageDir,
65464
+ connectionId: mirror.connectionId,
65465
+ kind,
65466
+ ...mirror.prefix !== void 0 ? { prefix: mirror.prefix } : {}
65430
65467
  });
65431
- const parts = [
65432
- `${String(result.written.length)} updated`,
65433
- `${String(result.unchanged)} unchanged`
65434
- ];
65435
- if (result.failed.length > 0)
65436
- parts.push(`${String(result.failed.length)} failed`);
65437
- lastSync = { ...lastSync, [kind]: `${(/* @__PURE__ */ new Date()).toLocaleTimeString()} - ${parts.join(", ")}` };
65438
- for (const failure of result.failed)
65439
- logger.warn(`s3 ${kind}: ${failure.key}`, failure.problem);
65440
- if (kind === "skills") {
65441
- await refreshSkills();
65442
- postSkills();
65468
+ try {
65469
+ const result = await syncFromS3({
65470
+ target,
65471
+ ...mirror.prefix !== void 0 ? { prefix: mirror.prefix } : {},
65472
+ localDir,
65473
+ fs: new NodeFileSystem(),
65474
+ extensions: kind === "skills" ? [".md"] : [".py"]
65475
+ });
65476
+ const parts = [
65477
+ `${String(result.written.length)} updated`,
65478
+ `${String(result.unchanged)} unchanged`
65479
+ ];
65480
+ if (result.failed.length > 0)
65481
+ parts.push(`${String(result.failed.length)} failed`);
65482
+ lines.push(`${target.label}${mirror.prefix === void 0 ? "" : `/${mirror.prefix}`}: ${parts.join(", ")}`);
65483
+ for (const failure of result.failed) {
65484
+ logger.warn(`s3 ${kind}: ${failure.key}`, failure.problem);
65485
+ }
65486
+ } catch (error51) {
65487
+ lines.push(`${target.label}: ${error51 instanceof Error ? error51.message : String(error51)}`);
65443
65488
  }
65444
- } catch (error51) {
65445
- lastSync = { ...lastSync, [kind]: error51 instanceof Error ? error51.message : String(error51) };
65489
+ }
65490
+ lastSync = { ...lastSync, [kind]: `${(/* @__PURE__ */ new Date()).toLocaleTimeString()} - ${lines.join("; ")}` };
65491
+ if (kind === "skills") {
65492
+ await refreshSkills();
65493
+ postSkills();
65446
65494
  }
65447
65495
  await postS3();
65448
65496
  }
@@ -67041,7 +67089,10 @@ ${direction}` : attachMentions(text, mentions);
67041
67089
  } else if (message3.type === "requestMentionCandidates") {
67042
67090
  reportFailure("handleMentionCandidates", handleMentionCandidates(message3.query));
67043
67091
  } else if (message3.type === "queueMessage") {
67044
- queuedMessages.push(message3.text);
67092
+ queuedMessages.push({
67093
+ text: message3.text,
67094
+ ...message3.images !== void 0 && message3.images.length > 0 ? { images: message3.images } : {}
67095
+ });
67045
67096
  postQueued();
67046
67097
  } else if (message3.type === "unqueueMessage") {
67047
67098
  queuedMessages.splice(message3.index, 1);
@@ -67274,8 +67325,8 @@ ${direction}` : attachMentions(text, mentions);
67274
67325
  reportFailure("handleSaveS3Connection", handleSaveS3Connection(message3.connection, message3.secret, message3.sessionToken));
67275
67326
  } else if (message3.type === "deleteS3Connection") {
67276
67327
  reportFailure("handleDeleteS3Connection", handleDeleteS3Connection(message3.id));
67277
- } else if (message3.type === "saveS3Mirror") {
67278
- reportFailure("handleSaveS3Mirror", handleSaveS3Mirror(message3.kind, message3.connectionId, message3.prefix, message3.enabled));
67328
+ } else if (message3.type === "saveS3Mirrors") {
67329
+ reportFailure("handleSaveS3Mirrors", handleSaveS3Mirrors(message3.kind, message3.mirrors));
67279
67330
  } else if (message3.type === "syncS3") {
67280
67331
  reportFailure("handleSyncS3", handleSyncS3(message3.kind));
67281
67332
  } else if (message3.type === "saveSkillsAlias") {
@@ -67513,7 +67564,7 @@ ${direction}` : attachMentions(text, mentions);
67513
67564
  } else if (message3.type === "setAgentColor") {
67514
67565
  const role = message3.role;
67515
67566
  const color = message3.color;
67516
- if (!isAgentRole(role, cachedAgentDefinitions)) {
67567
+ if (!isColourableAgent(role, cachedAgentDefinitions)) {
67517
67568
  post({ type: "error", message: `There is no "${role}" role.` });
67518
67569
  return;
67519
67570
  }
@@ -68124,6 +68175,10 @@ function deriveTitle(messages) {
68124
68175
  return `${cut.trimEnd()}\u2026`;
68125
68176
  }
68126
68177
 
68178
+ // ../../packages/core/dist/display/size.js
68179
+ var DISPLAY_SIZES = ["small", "medium", "large", "full"];
68180
+ var DISPLAY_SIZE_DESCRIPTION = "How wide to draw it: small (an aside), medium (the ordinary case), large (worth studying), or full (the whole width available). Use a smaller one when the user says it is too big, and small or medium for something beside a paragraph of text rather than the point of the answer.";
68181
+
68127
68182
  // ../../packages/core/dist/charts/types.js
68128
68183
  var CHART_TYPES = ["bar", "stackedBar", "groupedBar", "line", "multiLine", "pie"];
68129
68184
  var MAX_CATEGORIES = 200;
@@ -68146,6 +68201,8 @@ var chartSpecSchema = external_exports.object({
68146
68201
  title: external_exports.string().max(200).optional(),
68147
68202
  categories: external_exports.array(external_exports.string()).min(1).max(MAX_CATEGORIES).describe("The x axis, or the pie slice labels. One per value in every series."),
68148
68203
  series: external_exports.array(chartSeriesSchema).min(1).max(MAX_SERIES),
68204
+ /** See `display/size.ts` — the same field and the same words as a diagram's. */
68205
+ size: external_exports.enum(DISPLAY_SIZES).optional().describe(DISPLAY_SIZE_DESCRIPTION),
68149
68206
  xLabel: external_exports.string().max(80).optional(),
68150
68207
  yLabel: external_exports.string().max(80).optional(),
68151
68208
  note: external_exports.string().max(500).optional().describe("A line under the chart. Say where the numbers came from, and what they exclude.")
@@ -68266,6 +68323,8 @@ var diagramSpecSchema = external_exports.object({
68266
68323
  title: external_exports.string().max(120).optional(),
68267
68324
  textSize: external_exports.enum(TEXT_SIZES).optional().describe("The size for every box that does not set its own. Use it when the user says the diagram is too small or too large to read comfortably."),
68268
68325
  legend: external_exports.array(diagramLegendSchema).max(DIAGRAM_MAX_LEGEND).optional().describe("A key under the diagram. Give an entry only where the meaning is not obvious from the label \u2014 a colour that stands for something, a shape used in a particular way. Explain the diagram, not the palette."),
68326
+ /** See `display/size.ts` — the same field and the same words as a chart's. */
68327
+ size: external_exports.enum(DISPLAY_SIZES).optional().describe(DISPLAY_SIZE_DESCRIPTION),
68269
68328
  direction: external_exports.enum(["down", "right"]).optional().describe("Which way the flow runs. down is the default and suits most flows."),
68270
68329
  nodes: external_exports.array(diagramNodeSchema).min(1).max(DIAGRAM_MAX_NODES),
68271
68330
  edges: external_exports.array(diagramEdgeSchema).max(DIAGRAM_MAX_EDGES),
@@ -68407,7 +68466,7 @@ function toolCallSummary(call, outcome) {
68407
68466
  function consultationFromToolCall(name, rawArguments) {
68408
68467
  const call = throughDispatch(name, rawArguments);
68409
68468
  if (call.name === ASK_CLAUDE_TOOL || call.name === LEGACY_ASK_EXPERT_TOOL)
68410
- return "expert";
68469
+ return "claude";
68411
68470
  if (call.name !== "ask_agent")
68412
68471
  return void 0;
68413
68472
  const decoded = call.args;
@@ -70065,8 +70124,10 @@ var S3Client = class {
70065
70124
  const { bucket, region, endpoint, pathStyle } = this.connection;
70066
70125
  const origin = new URL(endpoint ?? `https://s3.${region}.amazonaws.com`);
70067
70126
  const key = call.key ?? "";
70068
- const host = pathStyle === true ? origin.host : `${bucket}.${origin.host}`;
70069
- const prefix = pathStyle === true ? `/${bucket}` : "";
70127
+ const inPath = usesPathStyle(pathStyle, origin.host);
70128
+ const host = inPath ? origin.host : `${bucket}.${origin.host}`;
70129
+ const mount = origin.pathname === "/" ? "" : origin.pathname.replace(/\/+$/, "");
70130
+ const prefix = inPath ? `${mount}/${bucket}` : mount;
70070
70131
  const path36 = key === "" ? "" : `/${key.split("/").map((part) => encodeURIComponent(part)).join("/")}`;
70071
70132
  const url2 = new URL(`${origin.protocol}//${host}${prefix}${path36}`);
70072
70133
  for (const [name, value] of Object.entries(call.query ?? {}))
@@ -70085,13 +70146,18 @@ var S3Client = class {
70085
70146
  secretAccessKey: this.connection.secretAccessKey,
70086
70147
  ...this.connection.sessionToken !== void 0 ? { sessionToken: this.connection.sessionToken } : {}
70087
70148
  });
70088
- const response = await this.http.request(url2, {
70089
- method: call.method,
70090
- headers: signed.headers,
70091
- ...call.bodyBytes !== void 0 ? { bodyBytes: call.bodyBytes } : {},
70092
- ...call.signal !== void 0 ? { signal: call.signal } : {},
70093
- ...this.tls !== void 0 ? { tls: this.tls } : {}
70094
- });
70149
+ let response;
70150
+ try {
70151
+ response = await this.http.request(url2, {
70152
+ method: call.method,
70153
+ headers: signed.headers,
70154
+ ...call.bodyBytes !== void 0 ? { bodyBytes: call.bodyBytes } : {},
70155
+ ...call.signal !== void 0 ? { signal: call.signal } : {},
70156
+ ...this.tls !== void 0 ? { tls: this.tls } : {}
70157
+ });
70158
+ } catch (error51) {
70159
+ throw new Error(`Could not reach ${new URL(url2).host}: ${describeTlsError(error51)}`, { cause: error51 });
70160
+ }
70095
70161
  const bytes = await readAll(response);
70096
70162
  return { status: response.status, text: bytes.toString("utf8"), bytes };
70097
70163
  }
@@ -70193,6 +70259,11 @@ function parseListing(xml) {
70193
70259
  function decodeEntities3(value) {
70194
70260
  return value.replaceAll("&lt;", "<").replaceAll("&gt;", ">").replaceAll("&quot;", '"').replaceAll("&#39;", String.fromCharCode(39)).replaceAll("&amp;", "&");
70195
70261
  }
70262
+ function usesPathStyle(configured, host) {
70263
+ if (configured !== void 0)
70264
+ return configured;
70265
+ return !/(^|\.)amazonaws\.com$/i.test(host);
70266
+ }
70196
70267
 
70197
70268
  // ../../packages/core/dist/s3/keys.js
70198
70269
  function normalisePrefix(prefix) {
@@ -72733,7 +72804,7 @@ function respondJson(response, status, body) {
72733
72804
  }
72734
72805
 
72735
72806
  // src/cli.ts
72736
- var VERSION = true ? "0.77.0" : "unknown (not a packaged build)";
72807
+ var VERSION = true ? "0.80.1" : "unknown (not a packaged build)";
72737
72808
  var compat = installNodeCompat();
72738
72809
  function lastMeaningfulLine(problem) {
72739
72810
  const lines = problem.split(String.fromCharCode(10)).map((line) => line.trim()).filter((line) => line.length > 0 && !line.endsWith(":"));