@agentskit/cli 0.13.46 → 0.13.47

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/bin.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { createCli } from './chunk-M3DE267Q.js';
2
+ import { createCli } from './chunk-V6BBACSI.js';
3
3
 
4
4
  // src/bin.ts
5
5
  async function main() {
@@ -21,6 +21,7 @@ import { spawn } from 'child_process';
21
21
  import { createRequire } from 'module';
22
22
  import chokidar from 'chokidar';
23
23
  import kleur3 from 'kleur';
24
+ import { readText, readJson, NetError, readBody, NetErrorCodes } from '@agentskit/net';
24
25
  import { createRAG } from '@agentskit/rag';
25
26
  import { Command } from 'commander';
26
27
  import { input, select, checkbox, confirm } from '@inquirer/prompts';
@@ -3628,8 +3629,8 @@ async function startTunnel(options) {
3628
3629
  requests: () => requests
3629
3630
  };
3630
3631
  }
3631
-
3632
- // src/extensibility/rag/embedders.ts
3632
+ var MAX_EMBEDDER_RESPONSE_BYTES = 16 * 1024 * 1024;
3633
+ var MAX_EMBEDDER_ERROR_BYTES = 1024 * 1024;
3633
3634
  function createOpenAiEmbedder(config) {
3634
3635
  const model = config.model ?? "text-embedding-3-small";
3635
3636
  const baseUrl = (config.baseUrl ?? "https://api.openai.com").replace(/\/$/, "");
@@ -3643,10 +3644,24 @@ function createOpenAiEmbedder(config) {
3643
3644
  body: JSON.stringify({ model, input: text })
3644
3645
  });
3645
3646
  if (!res.ok) {
3646
- const body = await res.text().catch(() => "");
3647
- throw new Error(`embedder ${model} HTTP ${res.status}: ${body}`);
3647
+ let body = "";
3648
+ let cause;
3649
+ try {
3650
+ body = await readText(res, { maxBytes: MAX_EMBEDDER_ERROR_BYTES });
3651
+ } catch (error2) {
3652
+ if (error2 instanceof NetError) cause = error2;
3653
+ }
3654
+ const error = new Error(`embedder ${model} HTTP ${res.status}: ${body}`);
3655
+ if (cause) Object.assign(error, { cause });
3656
+ throw error;
3657
+ }
3658
+ let json;
3659
+ try {
3660
+ json = await readJson(res, { maxBytes: MAX_EMBEDDER_RESPONSE_BYTES });
3661
+ } catch (error) {
3662
+ if (error instanceof NetError) throw Object.assign(new Error(error.message), { cause: error });
3663
+ throw error;
3648
3664
  }
3649
- const json = await res.json();
3650
3665
  const first = json.data?.[0]?.embedding;
3651
3666
  if (!first) throw new Error(`embedder ${model}: response missing data[0].embedding`);
3652
3667
  return first;
@@ -3702,7 +3717,7 @@ async function indexSources(rag, config, cwd) {
3702
3717
 
3703
3718
  // package.json
3704
3719
  var package_default = {
3705
- version: "0.13.46"};
3720
+ version: "0.13.47"};
3706
3721
 
3707
3722
  // src/commands/shared.ts
3708
3723
  function mergeWithConfig(options, config) {
@@ -5073,22 +5088,27 @@ async function fetchWithLimits(url, fetchImpl) {
5073
5088
  try {
5074
5089
  const response = await fetchImpl(url, { signal: controller.signal });
5075
5090
  if (!response.ok) throw new Error(`${response.status} ${response.statusText}`);
5076
- const body = await response.arrayBuffer();
5077
- if (body.byteLength > MAX_RESPONSE_BYTES) {
5078
- throw new Error(`Registry response exceeded ${MAX_RESPONSE_BYTES} bytes`);
5091
+ let body;
5092
+ try {
5093
+ body = await readBody(response, { maxBytes: MAX_RESPONSE_BYTES });
5094
+ } catch (error) {
5095
+ if (error instanceof NetError && error.code === NetErrorCodes.AK_NET_BODY_TOO_LARGE) {
5096
+ throw Object.assign(new Error(`Registry response exceeded ${MAX_RESPONSE_BYTES} bytes`), { cause: error });
5097
+ }
5098
+ throw error;
5079
5099
  }
5080
- return new Response(body, { status: response.status, headers: response.headers });
5100
+ return new Response(Uint8Array.from(body), { status: response.status, headers: response.headers });
5081
5101
  } finally {
5082
5102
  clearTimeout(timer);
5083
5103
  }
5084
5104
  }
5085
5105
  async function getJson(url, fetchImpl) {
5086
5106
  const res = await fetchWithLimits(url, fetchImpl);
5087
- return JSON.parse(await res.text());
5107
+ return readJson(res, { maxBytes: MAX_RESPONSE_BYTES });
5088
5108
  }
5089
5109
  async function getText(url, fetchImpl) {
5090
5110
  const res = await fetchWithLimits(url, fetchImpl);
5091
- return res.text();
5111
+ return readText(res, { maxBytes: MAX_RESPONSE_BYTES });
5092
5112
  }
5093
5113
  async function fetchAgent(id, options = {}) {
5094
5114
  assertSafeId(id);
@@ -5226,7 +5246,7 @@ function allDeps(pkg) {
5226
5246
  if (!pkg) return {};
5227
5247
  return { ...pkg.peerDependencies, ...pkg.devDependencies, ...pkg.dependencies };
5228
5248
  }
5229
- function readJson(fs, path6) {
5249
+ function readJson3(fs, path6) {
5230
5250
  const raw = fs.readFile(path6);
5231
5251
  if (raw == null) return null;
5232
5252
  try {
@@ -5275,7 +5295,7 @@ function detectMetaFramework(fs, root, deps, uiBinding) {
5275
5295
  return "none";
5276
5296
  }
5277
5297
  function detectImportAlias(fs, root) {
5278
- const tsconfig = readJson(
5298
+ const tsconfig = readJson3(
5279
5299
  fs,
5280
5300
  join(root, "tsconfig.json")
5281
5301
  );
@@ -5314,7 +5334,7 @@ function detectMonorepo(fs, root) {
5314
5334
  return null;
5315
5335
  }
5316
5336
  function scanProject(fs, root = ".") {
5317
- const pkg = readJson(fs, join(root, "package.json"));
5337
+ const pkg = readJson3(fs, join(root, "package.json"));
5318
5338
  const deps = allDeps(pkg);
5319
5339
  const uiBinding = detectUiBinding(deps);
5320
5340
  const metaFramework = detectMetaFramework(fs, root, deps, uiBinding);
@@ -6131,5 +6151,5 @@ function createCli() {
6131
6151
  }
6132
6152
 
6133
6153
  export { ChatApp, HookDispatcher, McpClient, applyPolicyToTool, applyPolicyToTools, bridgeMcpServers, buildRagFromConfig, computeCost, configHooksToHandlers, createCli, createOpenAiEmbedder, defaultPolicy, derivePreview, disposeMcpClients, evaluatePolicy, findLatestSession, findSession, forkSession, generateSessionId, getPricing, indexSources, listSessions, loadConfig, loadPlugins, mergePluginsIntoBundle, registerPricing, renameSession, renderChatHeader, renderReport, resolveChatProvider, resolveSession, runAgent, runDoctor, sessionFilePath, startDev, startTunnel, writeSessionMeta, writeStarterProject2 as writeStarterProject };
6134
- //# sourceMappingURL=chunk-M3DE267Q.js.map
6135
- //# sourceMappingURL=chunk-M3DE267Q.js.map
6154
+ //# sourceMappingURL=chunk-V6BBACSI.js.map
6155
+ //# sourceMappingURL=chunk-V6BBACSI.js.map