@agentskit/cli 0.13.46 → 0.13.48

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 CHANGED
@@ -25,6 +25,7 @@ var kleur = require('kleur');
25
25
  var child_process = require('child_process');
26
26
  var module$1 = require('module');
27
27
  var chokidar = require('chokidar');
28
+ var net = require('@agentskit/net');
28
29
  var rag = require('@agentskit/rag');
29
30
  var agentSchema = require('@agentskit/core/agent-schema');
30
31
  var yaml = require('yaml');
@@ -41,7 +42,7 @@ var chokidar__default = /*#__PURE__*/_interopDefault(chokidar);
41
42
 
42
43
  // package.json
43
44
  var package_default = {
44
- version: "0.13.46"};
45
+ version: "0.13.48"};
45
46
  async function loadJsonConfig(path6) {
46
47
  try {
47
48
  const raw = await promises.readFile(path6, "utf8");
@@ -4198,8 +4199,8 @@ function registerTunnelCommand(program) {
4198
4199
  }
4199
4200
  });
4200
4201
  }
4201
-
4202
- // src/extensibility/rag/embedders.ts
4202
+ var MAX_EMBEDDER_RESPONSE_BYTES = 16 * 1024 * 1024;
4203
+ var MAX_EMBEDDER_ERROR_BYTES = 1024 * 1024;
4203
4204
  function createOpenAiEmbedder(config) {
4204
4205
  const model = config.model ?? "text-embedding-3-small";
4205
4206
  const baseUrl = (config.baseUrl ?? "https://api.openai.com").replace(/\/$/, "");
@@ -4213,10 +4214,24 @@ function createOpenAiEmbedder(config) {
4213
4214
  body: JSON.stringify({ model, input: text })
4214
4215
  });
4215
4216
  if (!res.ok) {
4216
- const body = await res.text().catch(() => "");
4217
- throw new Error(`embedder ${model} HTTP ${res.status}: ${body}`);
4217
+ let body = "";
4218
+ let cause;
4219
+ try {
4220
+ body = await net.readText(res, { maxBytes: MAX_EMBEDDER_ERROR_BYTES });
4221
+ } catch (error2) {
4222
+ if (error2 instanceof net.NetError) cause = error2;
4223
+ }
4224
+ const error = new Error(`embedder ${model} HTTP ${res.status}: ${body}`);
4225
+ if (cause) Object.assign(error, { cause });
4226
+ throw error;
4227
+ }
4228
+ let json;
4229
+ try {
4230
+ json = await net.readJson(res, { maxBytes: MAX_EMBEDDER_RESPONSE_BYTES });
4231
+ } catch (error) {
4232
+ if (error instanceof net.NetError) throw Object.assign(new Error(error.message), { cause: error });
4233
+ throw error;
4218
4234
  }
4219
- const json = await res.json();
4220
4235
  const first = json.data?.[0]?.embedding;
4221
4236
  if (!first) throw new Error(`embedder ${model}: response missing data[0].embedding`);
4222
4237
  return first;
@@ -5082,22 +5097,27 @@ async function fetchWithLimits(url, fetchImpl) {
5082
5097
  try {
5083
5098
  const response = await fetchImpl(url, { signal: controller.signal });
5084
5099
  if (!response.ok) throw new Error(`${response.status} ${response.statusText}`);
5085
- const body = await response.arrayBuffer();
5086
- if (body.byteLength > MAX_RESPONSE_BYTES) {
5087
- throw new Error(`Registry response exceeded ${MAX_RESPONSE_BYTES} bytes`);
5100
+ let body;
5101
+ try {
5102
+ body = await net.readBody(response, { maxBytes: MAX_RESPONSE_BYTES });
5103
+ } catch (error) {
5104
+ if (error instanceof net.NetError && error.code === net.NetErrorCodes.AK_NET_BODY_TOO_LARGE) {
5105
+ throw Object.assign(new Error(`Registry response exceeded ${MAX_RESPONSE_BYTES} bytes`), { cause: error });
5106
+ }
5107
+ throw error;
5088
5108
  }
5089
- return new Response(body, { status: response.status, headers: response.headers });
5109
+ return new Response(Uint8Array.from(body), { status: response.status, headers: response.headers });
5090
5110
  } finally {
5091
5111
  clearTimeout(timer);
5092
5112
  }
5093
5113
  }
5094
5114
  async function getJson(url, fetchImpl) {
5095
5115
  const res = await fetchWithLimits(url, fetchImpl);
5096
- return JSON.parse(await res.text());
5116
+ return net.readJson(res, { maxBytes: MAX_RESPONSE_BYTES });
5097
5117
  }
5098
5118
  async function getText(url, fetchImpl) {
5099
5119
  const res = await fetchWithLimits(url, fetchImpl);
5100
- return res.text();
5120
+ return net.readText(res, { maxBytes: MAX_RESPONSE_BYTES });
5101
5121
  }
5102
5122
  async function fetchAgent(id, options = {}) {
5103
5123
  assertSafeId(id);
@@ -5235,7 +5255,7 @@ function allDeps(pkg) {
5235
5255
  if (!pkg) return {};
5236
5256
  return { ...pkg.peerDependencies, ...pkg.devDependencies, ...pkg.dependencies };
5237
5257
  }
5238
- function readJson(fs, path6) {
5258
+ function readJson3(fs, path6) {
5239
5259
  const raw = fs.readFile(path6);
5240
5260
  if (raw == null) return null;
5241
5261
  try {
@@ -5284,7 +5304,7 @@ function detectMetaFramework(fs, root, deps, uiBinding) {
5284
5304
  return "none";
5285
5305
  }
5286
5306
  function detectImportAlias(fs, root) {
5287
- const tsconfig = readJson(
5307
+ const tsconfig = readJson3(
5288
5308
  fs,
5289
5309
  path.join(root, "tsconfig.json")
5290
5310
  );
@@ -5323,7 +5343,7 @@ function detectMonorepo(fs, root) {
5323
5343
  return null;
5324
5344
  }
5325
5345
  function scanProject(fs, root = ".") {
5326
- const pkg = readJson(fs, path.join(root, "package.json"));
5346
+ const pkg = readJson3(fs, path.join(root, "package.json"));
5327
5347
  const deps = allDeps(pkg);
5328
5348
  const uiBinding = detectUiBinding(deps);
5329
5349
  const metaFramework = detectMetaFramework(fs, root, deps, uiBinding);