@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/server.js CHANGED
@@ -40201,7 +40201,16 @@ var s3MirrorSchema = external_exports.object({
40201
40201
  connectionId: external_exports.string().min(1),
40202
40202
  prefix: external_exports.string().optional(),
40203
40203
  /** Off by default: reading a bucket on every panel open is somebody's money and latency. */
40204
- enabled: external_exports.boolean().optional()
40204
+ enabled: external_exports.boolean().optional(),
40205
+ /**
40206
+ * New skills written here are also copied up to this folder.
40207
+ *
40208
+ * At most one folder should carry it, and the bridge takes the first that does. The rest are
40209
+ * read-only sources, which is the same split the local folders already have: one place new
40210
+ * skills are saved, and any number of folders they are *also* read from. A list where every
40211
+ * entry was writable would make "where did that skill go" unanswerable.
40212
+ */
40213
+ publish: external_exports.boolean().optional()
40205
40214
  });
40206
40215
  var s3ConfigSchema = external_exports.object({
40207
40216
  connections: external_exports.array(s3ConnectionSchema).max(20).optional(),
@@ -40210,8 +40219,12 @@ var s3ConfigSchema = external_exports.object({
40210
40219
  *
40211
40220
  * Only the *files* move. They are still loaded, watched and indexed exactly as local ones are —
40212
40221
  * indexing stays as configured — so this names a sync, not a second kind of skill.
40222
+ *
40223
+ * A **list**, because it maps onto the split the local folders already have: any number of
40224
+ * folders skills are read from, and one place new ones are saved. A bucket folder is one more
40225
+ * source, so several of them is the ordinary case rather than a special one.
40213
40226
  */
40214
- skills: s3MirrorSchema.optional(),
40227
+ skills: external_exports.array(s3MirrorSchema).max(8).optional(),
40215
40228
  /**
40216
40229
  * The same for Python tools, with one difference that is not a detail.
40217
40230
  *
@@ -40220,7 +40233,7 @@ var s3ConfigSchema = external_exports.object({
40220
40233
  * and approval still happens on each one. Anybody with write access to the bucket would
40221
40234
  * otherwise be running code as this user on every machine that syncs.
40222
40235
  */
40223
- tools: s3MirrorSchema.optional()
40236
+ tools: external_exports.array(s3MirrorSchema).max(8).optional()
40224
40237
  });
40225
40238
  var configSchema = external_exports.object({
40226
40239
  profiles: external_exports.array(providerProfileSchema),
@@ -43570,6 +43583,10 @@ function isValidRoleId(id) {
43570
43583
  function isAgentRole(value, custom2 = []) {
43571
43584
  return AGENT_ROLES.includes(value) || custom2.some((role) => role.id === value);
43572
43585
  }
43586
+ var COLOURED_NON_ROLES = ["claude"];
43587
+ function isColourableAgent(value, custom2 = []) {
43588
+ return isAgentRole(value, custom2) || COLOURED_NON_ROLES.includes(value);
43589
+ }
43573
43590
  function knownRoles(custom2 = []) {
43574
43591
  return [...AGENT_ROLES, ...custom2.map((role) => role.id)];
43575
43592
  }
@@ -58711,8 +58728,8 @@ async function runAgentTurn(provider, conversation, userMessage, toolRegistry, t
58711
58728
  events.onToolResult(toolCall, result);
58712
58729
  const queued = options.drainQueuedMessages?.() ?? [];
58713
58730
  for (const message3 of queued) {
58714
- conversation.addUserMessage(message3);
58715
- events.onQueuedMessageConsumed?.(message3);
58731
+ conversation.addUserMessage(message3.text, message3.images);
58732
+ events.onQueuedMessageConsumed?.(message3.text);
58716
58733
  }
58717
58734
  if (queued.length > 0) {
58718
58735
  iteration = -1;
@@ -62043,7 +62060,7 @@ function wireChatBridge(services) {
62043
62060
  const { transport, secrets, ui, workspaceRoot, storageDir } = services;
62044
62061
  const logger = new Logger({ level: "debug", sink: services.logSink });
62045
62062
  const configManager = new ConfigManager(services.configStore, services.workspaceRoot);
62046
- const httpClient = services.httpClient ?? new FetchHttpClient();
62063
+ const httpClient = services.httpClient ?? new FetchHttpClient({ useEnvProxy: true });
62047
62064
  const conversation = new Conversation(workspaceRoot !== void 0 ? buildSystemPrompt(workspaceRoot) : void 0);
62048
62065
  let cachedSecretValues = [];
62049
62066
  const truncationStore = new RecordingTruncationStore(new DiskTruncationStore(path23.join(storageDir, "tool-results"), () => cachedSecretValues));
@@ -62136,9 +62153,9 @@ ${preview.text}` } : {}
62136
62153
  const defaultSkillsDir = workspaceRoot !== void 0 ? path23.join(workspaceRoot, ".lightcode", "skills") : void 0;
62137
62154
  let skillsDir = defaultSkillsDir;
62138
62155
  let extraSkillDirs = [];
62139
- let mirroredSkillsDir;
62140
- let mirroredToolsDir;
62141
- let cachedSkillMirror;
62156
+ let mirroredSkillsDirs = [];
62157
+ let mirroredToolsDirs = [];
62158
+ let cachedSkillMirrors = [];
62142
62159
  let lastSync = {};
62143
62160
  function resolveSkillDir(entry) {
62144
62161
  const trimmed = entry.trim();
@@ -62341,7 +62358,15 @@ ${preview.text}` } : {}
62341
62358
  }
62342
62359
  let queuedMessages = [];
62343
62360
  function postQueued() {
62344
- post({ type: "queued", messages: [...queuedMessages] });
62361
+ post({
62362
+ type: "queued",
62363
+ // A count, not the attachments: the composer only needs to say one is there, and sending
62364
+ // the bytes back for something already on screen would be waste.
62365
+ messages: queuedMessages.map((entry) => ({
62366
+ text: entry.text,
62367
+ ...entry.images !== void 0 && entry.images.length > 0 ? { images: entry.images.length } : {}
62368
+ }))
62369
+ });
62345
62370
  }
62346
62371
  let activeAbortController;
62347
62372
  let taskCheckpoint;
@@ -62792,20 +62817,20 @@ ${preview.text}` } : {}
62792
62817
  cachedReadRoots = (config2.filesystem?.readRoots ?? []).map((entry) => entry.trim()).filter((entry) => entry.length > 0);
62793
62818
  skillsDir = (config2.skills?.dir !== void 0 ? resolveSkillDir(config2.skills.dir) : void 0) ?? defaultSkillsDir;
62794
62819
  extraSkillDirs = (config2.skills?.paths ?? []).map(resolveSkillDir).filter((dir) => dir !== void 0);
62795
- const skillMirror = config2.s3?.skills;
62796
- cachedSkillMirror = skillMirror;
62797
- if (skillMirror?.enabled === true) {
62798
- mirroredSkillsDir = mirrorFolder({
62799
- storageDir,
62800
- connectionId: skillMirror.connectionId,
62801
- kind: "skills",
62802
- ...skillMirror.prefix !== void 0 ? { prefix: skillMirror.prefix } : {}
62803
- });
62804
- if (mirroredSkillsDir !== void 0)
62805
- extraSkillDirs.push(mirroredSkillsDir);
62806
- } else {
62807
- mirroredSkillsDir = void 0;
62808
- }
62820
+ cachedSkillMirrors = config2.s3?.skills ?? [];
62821
+ mirroredSkillsDirs = cachedSkillMirrors.filter((mirror) => mirror.enabled === true).map((mirror) => mirrorFolder({
62822
+ storageDir,
62823
+ connectionId: mirror.connectionId,
62824
+ kind: "skills",
62825
+ ...mirror.prefix !== void 0 ? { prefix: mirror.prefix } : {}
62826
+ }));
62827
+ extraSkillDirs.push(...mirroredSkillsDirs);
62828
+ mirroredToolsDirs = (config2.s3?.tools ?? []).filter((mirror) => mirror.enabled === true).map((mirror) => mirrorFolder({
62829
+ storageDir,
62830
+ connectionId: mirror.connectionId,
62831
+ kind: "tools",
62832
+ ...mirror.prefix !== void 0 ? { prefix: mirror.prefix } : {}
62833
+ }));
62809
62834
  return config2;
62810
62835
  }
62811
62836
  function announceConfigRecovery() {
@@ -62975,8 +63000,9 @@ ${preview.text}` } : {}
62975
63000
  submitForReview: (request) => services.submitForReview?.({ kind: "skill", ...request }) ?? Promise.resolve("")
62976
63001
  } : {}
62977
63002
  };
62978
- const skillTarget = cachedSkillMirror?.enabled === true ? targetById(cachedS3, cachedSkillMirror.connectionId) : void 0;
62979
- const mirrorPrefix = cachedSkillMirror?.prefix;
63003
+ const publishTo = cachedSkillMirrors.find((mirror) => mirror.enabled === true && mirror.publish === true);
63004
+ const skillTarget = publishTo === void 0 ? void 0 : targetById(cachedS3, publishTo.connectionId);
63005
+ const mirrorPrefix = publishTo?.prefix;
62980
63006
  combined.register(createWriteSkillTool({
62981
63007
  ...context,
62982
63008
  ...skillTarget !== void 0 && skillTarget.readOnly !== true ? {
@@ -63459,7 +63485,25 @@ ${direction}` : attachMentions(text, mentions);
63459
63485
  const drained = queuedMessages;
63460
63486
  queuedMessages = [];
63461
63487
  postQueued();
63462
- return drained;
63488
+ return drained.map((entry) => {
63489
+ const attachments = entry.images ?? [];
63490
+ if (attachments.length === 0)
63491
+ return { text: entry.text };
63492
+ if (!capabilities.supportsVision) {
63493
+ post({
63494
+ type: "error",
63495
+ 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.`
63496
+ });
63497
+ return { text: entry.text };
63498
+ }
63499
+ return {
63500
+ text: entry.text,
63501
+ images: attachments.map((image) => ({
63502
+ mediaType: image.mediaType,
63503
+ data: image.data
63504
+ }))
63505
+ };
63506
+ });
63463
63507
  }
63464
63508
  };
63465
63509
  if (images !== void 0 && images.length > 0 && capabilities.supportsVision) {
@@ -63655,10 +63699,11 @@ ${direction}` : attachMentions(text, mentions);
63655
63699
  await persistActiveTask();
63656
63700
  await postTasks();
63657
63701
  if (queuedMessages.length > 0 && activeAbortController === void 0) {
63658
- const next = queuedMessages.join("\n\n");
63702
+ const next = queuedMessages.map((entry) => entry.text).join("\n\n");
63703
+ const images2 = queuedMessages.flatMap((entry) => entry.images ?? []);
63659
63704
  queuedMessages = [];
63660
63705
  postQueued();
63661
- void handleSendMessage(next);
63706
+ void handleSendMessage(next, images2.length > 0 ? images2 : void 0);
63662
63707
  }
63663
63708
  }
63664
63709
  }
@@ -65180,10 +65225,10 @@ ${direction}` : attachMentions(text, mentions);
65180
65225
  type: "s3",
65181
65226
  connections,
65182
65227
  problems: cachedS3.problems,
65183
- ...config2.s3?.skills !== void 0 ? { skills: config2.s3.skills } : {},
65184
- ...config2.s3?.tools !== void 0 ? { tools: config2.s3.tools } : {},
65185
- ...mirroredSkillsDir !== void 0 ? { skillsFolder: mirroredSkillsDir } : {},
65186
- ...mirroredToolsDir !== void 0 ? { toolsFolder: mirroredToolsDir } : {},
65228
+ skills: config2.s3?.skills ?? [],
65229
+ tools: config2.s3?.tools ?? [],
65230
+ skillsFolders: mirroredSkillsDirs,
65231
+ toolsFolders: mirroredToolsDirs,
65187
65232
  ...lastSync.skills !== void 0 ? { lastSkillsSync: lastSync.skills } : {},
65188
65233
  ...lastSync.tools !== void 0 ? { lastToolsSync: lastSync.tools } : {}
65189
65234
  });
@@ -65226,81 +65271,84 @@ ${direction}` : attachMentions(text, mentions);
65226
65271
  await secrets.delete(s3TokenRef(id)).catch(() => void 0);
65227
65272
  const s3 = { ...config2.s3 ?? {} };
65228
65273
  s3.connections = (s3.connections ?? []).filter((connection) => connection.id !== id);
65229
- if (s3.skills?.connectionId === id)
65274
+ s3.skills = (s3.skills ?? []).filter((mirror) => mirror.connectionId !== id);
65275
+ s3.tools = (s3.tools ?? []).filter((mirror) => mirror.connectionId !== id);
65276
+ if (s3.skills.length === 0)
65230
65277
  delete s3.skills;
65231
- if (s3.tools?.connectionId === id)
65278
+ if (s3.tools.length === 0)
65232
65279
  delete s3.tools;
65233
65280
  await configManager.save("user", { s3 });
65234
65281
  await loadSettings();
65235
65282
  await postS3();
65236
65283
  }
65237
- async function handleSaveS3Mirror(kind, connectionId, prefix, enabled) {
65284
+ async function handleSaveS3Mirrors(kind, mirrors) {
65238
65285
  const { config: config2 } = await configManager.load();
65239
65286
  const s3 = { ...config2.s3 ?? {} };
65240
- if (connectionId.trim().length === 0)
65287
+ const cleaned = mirrors.filter((mirror) => mirror.connectionId.trim().length > 0).map((mirror) => ({
65288
+ connectionId: mirror.connectionId.trim(),
65289
+ ...mirror.prefix !== void 0 && mirror.prefix.trim().length > 0 ? { prefix: mirror.prefix.trim() } : {},
65290
+ ...mirror.enabled === true ? { enabled: true } : {},
65291
+ ...mirror.publish === true ? { publish: true } : {}
65292
+ }));
65293
+ if (cleaned.length === 0)
65241
65294
  delete s3[kind];
65242
- else {
65243
- s3[kind] = {
65244
- connectionId: connectionId.trim(),
65245
- ...prefix !== void 0 && prefix.trim().length > 0 ? { prefix: prefix.trim() } : {},
65246
- enabled
65247
- };
65248
- }
65295
+ else
65296
+ s3[kind] = cleaned;
65249
65297
  await configManager.save("user", { s3 });
65250
65298
  await loadSettings();
65251
- if (enabled && connectionId.trim().length > 0)
65299
+ if (cleaned.some((mirror) => mirror.enabled === true))
65252
65300
  await handleSyncS3(kind);
65253
65301
  else
65254
65302
  await postS3();
65255
65303
  }
65256
65304
  async function handleSyncS3(kind) {
65257
65305
  const { config: config2 } = await configManager.load();
65258
- const mirror = config2.s3?.[kind];
65259
- if (mirror === void 0) {
65306
+ const mirrors = (config2.s3?.[kind] ?? []).filter((mirror) => mirror.enabled === true);
65307
+ if (mirrors.length === 0) {
65260
65308
  lastSync = { ...lastSync, [kind]: "No bucket folder is configured." };
65261
65309
  await postS3();
65262
65310
  return;
65263
65311
  }
65264
- const target = targetById(cachedS3, mirror.connectionId);
65265
- if (target === void 0) {
65266
- lastSync = {
65267
- ...lastSync,
65268
- [kind]: "That connection is not usable - check its key in the list above."
65269
- };
65270
- await postS3();
65271
- return;
65272
- }
65273
- const localDir = mirrorFolder({
65274
- storageDir,
65275
- connectionId: mirror.connectionId,
65276
- kind,
65277
- ...mirror.prefix !== void 0 ? { prefix: mirror.prefix } : {}
65278
- });
65279
- if (kind === "tools")
65280
- mirroredToolsDir = localDir;
65281
- try {
65282
- const result = await syncFromS3({
65283
- target,
65284
- ...mirror.prefix !== void 0 ? { prefix: mirror.prefix } : {},
65285
- localDir,
65286
- fs: new NodeFileSystem(),
65287
- extensions: kind === "skills" ? [".md"] : [".py"]
65312
+ const lines = [];
65313
+ for (const mirror of mirrors) {
65314
+ const target = targetById(cachedS3, mirror.connectionId);
65315
+ const where = `${mirror.connectionId}/${mirror.prefix ?? ""}`;
65316
+ if (target === void 0) {
65317
+ lines.push(`${where}: connection unusable - check its key above`);
65318
+ continue;
65319
+ }
65320
+ const localDir = mirrorFolder({
65321
+ storageDir,
65322
+ connectionId: mirror.connectionId,
65323
+ kind,
65324
+ ...mirror.prefix !== void 0 ? { prefix: mirror.prefix } : {}
65288
65325
  });
65289
- const parts = [
65290
- `${String(result.written.length)} updated`,
65291
- `${String(result.unchanged)} unchanged`
65292
- ];
65293
- if (result.failed.length > 0)
65294
- parts.push(`${String(result.failed.length)} failed`);
65295
- lastSync = { ...lastSync, [kind]: `${(/* @__PURE__ */ new Date()).toLocaleTimeString()} - ${parts.join(", ")}` };
65296
- for (const failure of result.failed)
65297
- logger.warn(`s3 ${kind}: ${failure.key}`, failure.problem);
65298
- if (kind === "skills") {
65299
- await refreshSkills();
65300
- postSkills();
65326
+ try {
65327
+ const result = await syncFromS3({
65328
+ target,
65329
+ ...mirror.prefix !== void 0 ? { prefix: mirror.prefix } : {},
65330
+ localDir,
65331
+ fs: new NodeFileSystem(),
65332
+ extensions: kind === "skills" ? [".md"] : [".py"]
65333
+ });
65334
+ const parts = [
65335
+ `${String(result.written.length)} updated`,
65336
+ `${String(result.unchanged)} unchanged`
65337
+ ];
65338
+ if (result.failed.length > 0)
65339
+ parts.push(`${String(result.failed.length)} failed`);
65340
+ lines.push(`${target.label}${mirror.prefix === void 0 ? "" : `/${mirror.prefix}`}: ${parts.join(", ")}`);
65341
+ for (const failure of result.failed) {
65342
+ logger.warn(`s3 ${kind}: ${failure.key}`, failure.problem);
65343
+ }
65344
+ } catch (error51) {
65345
+ lines.push(`${target.label}: ${error51 instanceof Error ? error51.message : String(error51)}`);
65301
65346
  }
65302
- } catch (error51) {
65303
- lastSync = { ...lastSync, [kind]: error51 instanceof Error ? error51.message : String(error51) };
65347
+ }
65348
+ lastSync = { ...lastSync, [kind]: `${(/* @__PURE__ */ new Date()).toLocaleTimeString()} - ${lines.join("; ")}` };
65349
+ if (kind === "skills") {
65350
+ await refreshSkills();
65351
+ postSkills();
65304
65352
  }
65305
65353
  await postS3();
65306
65354
  }
@@ -66899,7 +66947,10 @@ ${direction}` : attachMentions(text, mentions);
66899
66947
  } else if (message3.type === "requestMentionCandidates") {
66900
66948
  reportFailure("handleMentionCandidates", handleMentionCandidates(message3.query));
66901
66949
  } else if (message3.type === "queueMessage") {
66902
- queuedMessages.push(message3.text);
66950
+ queuedMessages.push({
66951
+ text: message3.text,
66952
+ ...message3.images !== void 0 && message3.images.length > 0 ? { images: message3.images } : {}
66953
+ });
66903
66954
  postQueued();
66904
66955
  } else if (message3.type === "unqueueMessage") {
66905
66956
  queuedMessages.splice(message3.index, 1);
@@ -67132,8 +67183,8 @@ ${direction}` : attachMentions(text, mentions);
67132
67183
  reportFailure("handleSaveS3Connection", handleSaveS3Connection(message3.connection, message3.secret, message3.sessionToken));
67133
67184
  } else if (message3.type === "deleteS3Connection") {
67134
67185
  reportFailure("handleDeleteS3Connection", handleDeleteS3Connection(message3.id));
67135
- } else if (message3.type === "saveS3Mirror") {
67136
- reportFailure("handleSaveS3Mirror", handleSaveS3Mirror(message3.kind, message3.connectionId, message3.prefix, message3.enabled));
67186
+ } else if (message3.type === "saveS3Mirrors") {
67187
+ reportFailure("handleSaveS3Mirrors", handleSaveS3Mirrors(message3.kind, message3.mirrors));
67137
67188
  } else if (message3.type === "syncS3") {
67138
67189
  reportFailure("handleSyncS3", handleSyncS3(message3.kind));
67139
67190
  } else if (message3.type === "saveSkillsAlias") {
@@ -67371,7 +67422,7 @@ ${direction}` : attachMentions(text, mentions);
67371
67422
  } else if (message3.type === "setAgentColor") {
67372
67423
  const role = message3.role;
67373
67424
  const color = message3.color;
67374
- if (!isAgentRole(role, cachedAgentDefinitions)) {
67425
+ if (!isColourableAgent(role, cachedAgentDefinitions)) {
67375
67426
  post({ type: "error", message: `There is no "${role}" role.` });
67376
67427
  return;
67377
67428
  }
@@ -67982,6 +68033,10 @@ function deriveTitle(messages) {
67982
68033
  return `${cut.trimEnd()}\u2026`;
67983
68034
  }
67984
68035
 
68036
+ // ../../packages/core/dist/display/size.js
68037
+ var DISPLAY_SIZES = ["small", "medium", "large", "full"];
68038
+ 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.";
68039
+
67985
68040
  // ../../packages/core/dist/charts/types.js
67986
68041
  var CHART_TYPES = ["bar", "stackedBar", "groupedBar", "line", "multiLine", "pie"];
67987
68042
  var MAX_CATEGORIES = 200;
@@ -68004,6 +68059,8 @@ var chartSpecSchema = external_exports.object({
68004
68059
  title: external_exports.string().max(200).optional(),
68005
68060
  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."),
68006
68061
  series: external_exports.array(chartSeriesSchema).min(1).max(MAX_SERIES),
68062
+ /** See `display/size.ts` — the same field and the same words as a diagram's. */
68063
+ size: external_exports.enum(DISPLAY_SIZES).optional().describe(DISPLAY_SIZE_DESCRIPTION),
68007
68064
  xLabel: external_exports.string().max(80).optional(),
68008
68065
  yLabel: external_exports.string().max(80).optional(),
68009
68066
  note: external_exports.string().max(500).optional().describe("A line under the chart. Say where the numbers came from, and what they exclude.")
@@ -68124,6 +68181,8 @@ var diagramSpecSchema = external_exports.object({
68124
68181
  title: external_exports.string().max(120).optional(),
68125
68182
  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."),
68126
68183
  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."),
68184
+ /** See `display/size.ts` — the same field and the same words as a chart's. */
68185
+ size: external_exports.enum(DISPLAY_SIZES).optional().describe(DISPLAY_SIZE_DESCRIPTION),
68127
68186
  direction: external_exports.enum(["down", "right"]).optional().describe("Which way the flow runs. down is the default and suits most flows."),
68128
68187
  nodes: external_exports.array(diagramNodeSchema).min(1).max(DIAGRAM_MAX_NODES),
68129
68188
  edges: external_exports.array(diagramEdgeSchema).max(DIAGRAM_MAX_EDGES),
@@ -68265,7 +68324,7 @@ function toolCallSummary(call, outcome) {
68265
68324
  function consultationFromToolCall(name, rawArguments) {
68266
68325
  const call = throughDispatch(name, rawArguments);
68267
68326
  if (call.name === ASK_CLAUDE_TOOL || call.name === LEGACY_ASK_EXPERT_TOOL)
68268
- return "expert";
68327
+ return "claude";
68269
68328
  if (call.name !== "ask_agent")
68270
68329
  return void 0;
68271
68330
  const decoded = call.args;
@@ -69923,8 +69982,10 @@ var S3Client = class {
69923
69982
  const { bucket, region, endpoint, pathStyle } = this.connection;
69924
69983
  const origin = new URL(endpoint ?? `https://s3.${region}.amazonaws.com`);
69925
69984
  const key = call.key ?? "";
69926
- const host = pathStyle === true ? origin.host : `${bucket}.${origin.host}`;
69927
- const prefix = pathStyle === true ? `/${bucket}` : "";
69985
+ const inPath = usesPathStyle(pathStyle, origin.host);
69986
+ const host = inPath ? origin.host : `${bucket}.${origin.host}`;
69987
+ const mount = origin.pathname === "/" ? "" : origin.pathname.replace(/\/+$/, "");
69988
+ const prefix = inPath ? `${mount}/${bucket}` : mount;
69928
69989
  const path32 = key === "" ? "" : `/${key.split("/").map((part) => encodeURIComponent(part)).join("/")}`;
69929
69990
  const url2 = new URL(`${origin.protocol}//${host}${prefix}${path32}`);
69930
69991
  for (const [name, value] of Object.entries(call.query ?? {}))
@@ -69943,13 +70004,18 @@ var S3Client = class {
69943
70004
  secretAccessKey: this.connection.secretAccessKey,
69944
70005
  ...this.connection.sessionToken !== void 0 ? { sessionToken: this.connection.sessionToken } : {}
69945
70006
  });
69946
- const response = await this.http.request(url2, {
69947
- method: call.method,
69948
- headers: signed.headers,
69949
- ...call.bodyBytes !== void 0 ? { bodyBytes: call.bodyBytes } : {},
69950
- ...call.signal !== void 0 ? { signal: call.signal } : {},
69951
- ...this.tls !== void 0 ? { tls: this.tls } : {}
69952
- });
70007
+ let response;
70008
+ try {
70009
+ response = await this.http.request(url2, {
70010
+ method: call.method,
70011
+ headers: signed.headers,
70012
+ ...call.bodyBytes !== void 0 ? { bodyBytes: call.bodyBytes } : {},
70013
+ ...call.signal !== void 0 ? { signal: call.signal } : {},
70014
+ ...this.tls !== void 0 ? { tls: this.tls } : {}
70015
+ });
70016
+ } catch (error51) {
70017
+ throw new Error(`Could not reach ${new URL(url2).host}: ${describeTlsError(error51)}`, { cause: error51 });
70018
+ }
69953
70019
  const bytes = await readAll(response);
69954
70020
  return { status: response.status, text: bytes.toString("utf8"), bytes };
69955
70021
  }
@@ -70051,6 +70117,11 @@ function parseListing(xml) {
70051
70117
  function decodeEntities3(value) {
70052
70118
  return value.replaceAll("&lt;", "<").replaceAll("&gt;", ">").replaceAll("&quot;", '"').replaceAll("&#39;", String.fromCharCode(39)).replaceAll("&amp;", "&");
70053
70119
  }
70120
+ function usesPathStyle(configured, host) {
70121
+ if (configured !== void 0)
70122
+ return configured;
70123
+ return !/(^|\.)amazonaws\.com$/i.test(host);
70124
+ }
70054
70125
 
70055
70126
  // ../../packages/core/dist/s3/keys.js
70056
70127
  function normalisePrefix(prefix) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chosengeneration/light-code",
3
- "version": "0.77.0",
3
+ "version": "0.80.1",
4
4
  "description": "A minimal agentic coding assistant, served to your browser from a local Node server",
5
5
  "license": "MIT",
6
6
  "type": "module",