@hasna/assistants 0.6.25 → 0.6.26

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.js CHANGED
@@ -18167,6 +18167,40 @@ var require_tiktoken_bg = __commonJS((exports, module) => {
18167
18167
  };
18168
18168
  });
18169
18169
 
18170
+ // node_modules/.pnpm/tiktoken@1.0.22/node_modules/tiktoken/tiktoken.cjs
18171
+ var require_tiktoken = __commonJS((exports) => {
18172
+ var __dirname = "/Users/hasna/Workspace/dev/hasna/opensource/opensourcedev/opensource-oldpal/node_modules/.pnpm/tiktoken@1.0.22/node_modules/tiktoken";
18173
+ var wasm = require_tiktoken_bg();
18174
+ var imports = {};
18175
+ imports["./tiktoken_bg.js"] = wasm;
18176
+ var path = __require("path");
18177
+ var fs2 = __require("fs");
18178
+ var candidates = __dirname.split(path.sep).reduce((memo, _, index, array) => {
18179
+ const prefix = array.slice(0, index + 1).join(path.sep) + path.sep;
18180
+ if (!prefix.includes("node_modules" + path.sep)) {
18181
+ memo.unshift(path.join(prefix, "node_modules", "tiktoken", "", "./tiktoken_bg.wasm"));
18182
+ }
18183
+ return memo;
18184
+ }, []);
18185
+ candidates.unshift(path.join(__dirname, "./tiktoken_bg.wasm"));
18186
+ var bytes = null;
18187
+ for (const candidate of candidates) {
18188
+ try {
18189
+ bytes = fs2.readFileSync(candidate);
18190
+ break;
18191
+ } catch {}
18192
+ }
18193
+ if (bytes == null)
18194
+ throw new Error("Missing tiktoken_bg.wasm");
18195
+ var wasmModule = new WebAssembly.Module(bytes);
18196
+ var wasmInstance = new WebAssembly.Instance(wasmModule, imports);
18197
+ wasm.__wbg_set_wasm(wasmInstance.exports);
18198
+ exports.get_encoding = wasm["get_encoding"];
18199
+ exports.encoding_for_model = wasm["encoding_for_model"];
18200
+ exports.get_encoding_name_for_model = wasm["get_encoding_name_for_model"];
18201
+ exports.Tiktoken = wasm["Tiktoken"];
18202
+ });
18203
+
18170
18204
  // packages/core/src/errors/codes.ts
18171
18205
  var ErrorCodes;
18172
18206
  var init_codes = __esm(() => {
@@ -21456,8 +21490,8 @@ var require_utils = __commonJS((exports, module) => {
21456
21490
  }
21457
21491
  return ind;
21458
21492
  }
21459
- function removeDotSegments(path2) {
21460
- let input = path2;
21493
+ function removeDotSegments(path) {
21494
+ let input = path;
21461
21495
  const output = [];
21462
21496
  let nextSlash = -1;
21463
21497
  let len = 0;
@@ -21647,8 +21681,8 @@ var require_schemes = __commonJS((exports, module) => {
21647
21681
  wsComponent.secure = undefined;
21648
21682
  }
21649
21683
  if (wsComponent.resourceName) {
21650
- const [path2, query] = wsComponent.resourceName.split("?");
21651
- wsComponent.path = path2 && path2 !== "/" ? path2 : undefined;
21684
+ const [path, query] = wsComponent.resourceName.split("?");
21685
+ wsComponent.path = path && path !== "/" ? path : undefined;
21652
21686
  wsComponent.query = query;
21653
21687
  wsComponent.resourceName = undefined;
21654
21688
  }
@@ -24931,9 +24965,9 @@ function encodeUTF8(str) {
24931
24965
  let encoder;
24932
24966
  return (encodeUTF8_ ?? (encoder = new globalThis.TextEncoder, encodeUTF8_ = encoder.encode.bind(encoder)))(str);
24933
24967
  }
24934
- function decodeUTF8(bytes2) {
24968
+ function decodeUTF8(bytes) {
24935
24969
  let decoder;
24936
- return (decodeUTF8_ ?? (decoder = new globalThis.TextDecoder, decodeUTF8_ = decoder.decode.bind(decoder)))(bytes2);
24970
+ return (decodeUTF8_ ?? (decoder = new globalThis.TextDecoder, decodeUTF8_ = decoder.decode.bind(decoder)))(bytes);
24937
24971
  }
24938
24972
  var encodeUTF8_, decodeUTF8_;
24939
24973
 
@@ -25324,9 +25358,9 @@ var init_streaming = __esm(() => {
25324
25358
  const { value, done } = await iter.next();
25325
25359
  if (done)
25326
25360
  return ctrl.close();
25327
- const bytes2 = encodeUTF8(JSON.stringify(value) + `
25361
+ const bytes = encodeUTF8(JSON.stringify(value) + `
25328
25362
  `);
25329
- ctrl.enqueue(bytes2);
25363
+ ctrl.enqueue(bytes);
25330
25364
  } catch (err) {
25331
25365
  ctrl.error(err);
25332
25366
  }
@@ -25833,7 +25867,7 @@ var EMPTY, createPathTagFunction = (pathEncoder = encodeURIPath) => function pat
25833
25867
  return statics[0];
25834
25868
  let postPath = false;
25835
25869
  const invalidSegments = [];
25836
- const path2 = statics.reduce((previousValue, currentValue, index) => {
25870
+ const path = statics.reduce((previousValue, currentValue, index) => {
25837
25871
  if (/[?#]/.test(currentValue)) {
25838
25872
  postPath = true;
25839
25873
  }
@@ -25849,7 +25883,7 @@ var EMPTY, createPathTagFunction = (pathEncoder = encodeURIPath) => function pat
25849
25883
  }
25850
25884
  return previousValue + currentValue + (index === params.length ? "" : encoded);
25851
25885
  }, "");
25852
- const pathOnly = path2.split(/[?#]/, 1)[0];
25886
+ const pathOnly = path.split(/[?#]/, 1)[0];
25853
25887
  const invalidSegmentPattern = /(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi;
25854
25888
  let match;
25855
25889
  while ((match = invalidSegmentPattern.exec(pathOnly)) !== null) {
@@ -25871,15 +25905,15 @@ var EMPTY, createPathTagFunction = (pathEncoder = encodeURIPath) => function pat
25871
25905
  throw new AnthropicError(`Path parameters result in path with invalid segments:
25872
25906
  ${invalidSegments.map((e) => e.error).join(`
25873
25907
  `)}
25874
- ${path2}
25908
+ ${path}
25875
25909
  ${underline}`);
25876
25910
  }
25877
- return path2;
25878
- }, path2;
25911
+ return path;
25912
+ }, path;
25879
25913
  var init_path = __esm(() => {
25880
25914
  init_error();
25881
25915
  EMPTY = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.create(null));
25882
- path2 = /* @__PURE__ */ createPathTagFunction(encodeURIPath);
25916
+ path = /* @__PURE__ */ createPathTagFunction(encodeURIPath);
25883
25917
  });
25884
25918
 
25885
25919
  // node_modules/.pnpm/@anthropic-ai+sdk@0.72.1/node_modules/@anthropic-ai/sdk/resources/beta/files.mjs
@@ -25904,7 +25938,7 @@ var init_files = __esm(() => {
25904
25938
  }
25905
25939
  delete(fileID, params = {}, options) {
25906
25940
  const { betas } = params ?? {};
25907
- return this._client.delete(path2`/v1/files/${fileID}`, {
25941
+ return this._client.delete(path`/v1/files/${fileID}`, {
25908
25942
  ...options,
25909
25943
  headers: buildHeaders([
25910
25944
  { "anthropic-beta": [...betas ?? [], "files-api-2025-04-14"].toString() },
@@ -25914,7 +25948,7 @@ var init_files = __esm(() => {
25914
25948
  }
25915
25949
  download(fileID, params = {}, options) {
25916
25950
  const { betas } = params ?? {};
25917
- return this._client.get(path2`/v1/files/${fileID}/content`, {
25951
+ return this._client.get(path`/v1/files/${fileID}/content`, {
25918
25952
  ...options,
25919
25953
  headers: buildHeaders([
25920
25954
  {
@@ -25928,7 +25962,7 @@ var init_files = __esm(() => {
25928
25962
  }
25929
25963
  retrieveMetadata(fileID, params = {}, options) {
25930
25964
  const { betas } = params ?? {};
25931
- return this._client.get(path2`/v1/files/${fileID}`, {
25965
+ return this._client.get(path`/v1/files/${fileID}`, {
25932
25966
  ...options,
25933
25967
  headers: buildHeaders([
25934
25968
  { "anthropic-beta": [...betas ?? [], "files-api-2025-04-14"].toString() },
@@ -25960,7 +25994,7 @@ var init_models = __esm(() => {
25960
25994
  Models = class Models extends APIResource {
25961
25995
  retrieve(modelID, params = {}, options) {
25962
25996
  const { betas } = params ?? {};
25963
- return this._client.get(path2`/v1/models/${modelID}?beta=true`, {
25997
+ return this._client.get(path`/v1/models/${modelID}?beta=true`, {
25964
25998
  ...options,
25965
25999
  headers: buildHeaders([
25966
26000
  { ...betas?.toString() != null ? { "anthropic-beta": betas?.toString() } : undefined },
@@ -27171,7 +27205,7 @@ var init_batches = __esm(() => {
27171
27205
  }
27172
27206
  retrieve(messageBatchID, params = {}, options) {
27173
27207
  const { betas } = params ?? {};
27174
- return this._client.get(path2`/v1/messages/batches/${messageBatchID}?beta=true`, {
27208
+ return this._client.get(path`/v1/messages/batches/${messageBatchID}?beta=true`, {
27175
27209
  ...options,
27176
27210
  headers: buildHeaders([
27177
27211
  { "anthropic-beta": [...betas ?? [], "message-batches-2024-09-24"].toString() },
@@ -27192,7 +27226,7 @@ var init_batches = __esm(() => {
27192
27226
  }
27193
27227
  delete(messageBatchID, params = {}, options) {
27194
27228
  const { betas } = params ?? {};
27195
- return this._client.delete(path2`/v1/messages/batches/${messageBatchID}?beta=true`, {
27229
+ return this._client.delete(path`/v1/messages/batches/${messageBatchID}?beta=true`, {
27196
27230
  ...options,
27197
27231
  headers: buildHeaders([
27198
27232
  { "anthropic-beta": [...betas ?? [], "message-batches-2024-09-24"].toString() },
@@ -27202,7 +27236,7 @@ var init_batches = __esm(() => {
27202
27236
  }
27203
27237
  cancel(messageBatchID, params = {}, options) {
27204
27238
  const { betas } = params ?? {};
27205
- return this._client.post(path2`/v1/messages/batches/${messageBatchID}/cancel?beta=true`, {
27239
+ return this._client.post(path`/v1/messages/batches/${messageBatchID}/cancel?beta=true`, {
27206
27240
  ...options,
27207
27241
  headers: buildHeaders([
27208
27242
  { "anthropic-beta": [...betas ?? [], "message-batches-2024-09-24"].toString() },
@@ -27350,7 +27384,7 @@ var init_versions = __esm(() => {
27350
27384
  Versions = class Versions extends APIResource {
27351
27385
  create(skillID, params = {}, options) {
27352
27386
  const { betas, ...body } = params ?? {};
27353
- return this._client.post(path2`/v1/skills/${skillID}/versions?beta=true`, multipartFormRequestOptions({
27387
+ return this._client.post(path`/v1/skills/${skillID}/versions?beta=true`, multipartFormRequestOptions({
27354
27388
  body,
27355
27389
  ...options,
27356
27390
  headers: buildHeaders([
@@ -27361,7 +27395,7 @@ var init_versions = __esm(() => {
27361
27395
  }
27362
27396
  retrieve(version, params, options) {
27363
27397
  const { skill_id, betas } = params;
27364
- return this._client.get(path2`/v1/skills/${skill_id}/versions/${version}?beta=true`, {
27398
+ return this._client.get(path`/v1/skills/${skill_id}/versions/${version}?beta=true`, {
27365
27399
  ...options,
27366
27400
  headers: buildHeaders([
27367
27401
  { "anthropic-beta": [...betas ?? [], "skills-2025-10-02"].toString() },
@@ -27371,7 +27405,7 @@ var init_versions = __esm(() => {
27371
27405
  }
27372
27406
  list(skillID, params = {}, options) {
27373
27407
  const { betas, ...query } = params ?? {};
27374
- return this._client.getAPIList(path2`/v1/skills/${skillID}/versions?beta=true`, PageCursor, {
27408
+ return this._client.getAPIList(path`/v1/skills/${skillID}/versions?beta=true`, PageCursor, {
27375
27409
  query,
27376
27410
  ...options,
27377
27411
  headers: buildHeaders([
@@ -27382,7 +27416,7 @@ var init_versions = __esm(() => {
27382
27416
  }
27383
27417
  delete(version, params, options) {
27384
27418
  const { skill_id, betas } = params;
27385
- return this._client.delete(path2`/v1/skills/${skill_id}/versions/${version}?beta=true`, {
27419
+ return this._client.delete(path`/v1/skills/${skill_id}/versions/${version}?beta=true`, {
27386
27420
  ...options,
27387
27421
  headers: buildHeaders([
27388
27422
  { "anthropic-beta": [...betas ?? [], "skills-2025-10-02"].toString() },
@@ -27420,7 +27454,7 @@ var init_skills = __esm(() => {
27420
27454
  }
27421
27455
  retrieve(skillID, params = {}, options) {
27422
27456
  const { betas } = params ?? {};
27423
- return this._client.get(path2`/v1/skills/${skillID}?beta=true`, {
27457
+ return this._client.get(path`/v1/skills/${skillID}?beta=true`, {
27424
27458
  ...options,
27425
27459
  headers: buildHeaders([
27426
27460
  { "anthropic-beta": [...betas ?? [], "skills-2025-10-02"].toString() },
@@ -27441,7 +27475,7 @@ var init_skills = __esm(() => {
27441
27475
  }
27442
27476
  delete(skillID, params = {}, options) {
27443
27477
  const { betas } = params ?? {};
27444
- return this._client.delete(path2`/v1/skills/${skillID}?beta=true`, {
27478
+ return this._client.delete(path`/v1/skills/${skillID}?beta=true`, {
27445
27479
  ...options,
27446
27480
  headers: buildHeaders([
27447
27481
  { "anthropic-beta": [...betas ?? [], "skills-2025-10-02"].toString() },
@@ -28086,16 +28120,16 @@ var init_batches2 = __esm(() => {
28086
28120
  return this._client.post("/v1/messages/batches", { body, ...options });
28087
28121
  }
28088
28122
  retrieve(messageBatchID, options) {
28089
- return this._client.get(path2`/v1/messages/batches/${messageBatchID}`, options);
28123
+ return this._client.get(path`/v1/messages/batches/${messageBatchID}`, options);
28090
28124
  }
28091
28125
  list(query = {}, options) {
28092
28126
  return this._client.getAPIList("/v1/messages/batches", Page, { query, ...options });
28093
28127
  }
28094
28128
  delete(messageBatchID, options) {
28095
- return this._client.delete(path2`/v1/messages/batches/${messageBatchID}`, options);
28129
+ return this._client.delete(path`/v1/messages/batches/${messageBatchID}`, options);
28096
28130
  }
28097
28131
  cancel(messageBatchID, options) {
28098
- return this._client.post(path2`/v1/messages/batches/${messageBatchID}/cancel`, options);
28132
+ return this._client.post(path`/v1/messages/batches/${messageBatchID}/cancel`, options);
28099
28133
  }
28100
28134
  async results(messageBatchID, options) {
28101
28135
  const batch = await this.retrieve(messageBatchID);
@@ -28183,7 +28217,7 @@ var init_models2 = __esm(() => {
28183
28217
  Models2 = class Models2 extends APIResource {
28184
28218
  retrieve(modelID, params = {}, options) {
28185
28219
  const { betas } = params ?? {};
28186
- return this._client.get(path2`/v1/models/${modelID}`, {
28220
+ return this._client.get(path`/v1/models/${modelID}`, {
28187
28221
  ...options,
28188
28222
  headers: buildHeaders([
28189
28223
  { ...betas?.toString() != null ? { "anthropic-beta": betas?.toString() } : undefined },
@@ -28332,9 +28366,9 @@ new Anthropic({ apiKey, dangerouslyAllowBrowser: true });
28332
28366
  makeStatusError(status, error2, message, headers) {
28333
28367
  return APIError.generate(status, error2, message, headers);
28334
28368
  }
28335
- buildURL(path3, query, defaultBaseURL) {
28369
+ buildURL(path2, query, defaultBaseURL) {
28336
28370
  const baseURL = !__classPrivateFieldGet(this, _BaseAnthropic_instances, "m", _BaseAnthropic_baseURLOverridden).call(this) && defaultBaseURL || this.baseURL;
28337
- const url = isAbsoluteURL(path3) ? new URL(path3) : new URL(baseURL + (baseURL.endsWith("/") && path3.startsWith("/") ? path3.slice(1) : path3));
28371
+ const url = isAbsoluteURL(path2) ? new URL(path2) : new URL(baseURL + (baseURL.endsWith("/") && path2.startsWith("/") ? path2.slice(1) : path2));
28338
28372
  const defaultQuery = this.defaultQuery();
28339
28373
  if (!isEmptyObj(defaultQuery)) {
28340
28374
  query = { ...defaultQuery, ...query };
@@ -28354,24 +28388,24 @@ new Anthropic({ apiKey, dangerouslyAllowBrowser: true });
28354
28388
  }
28355
28389
  async prepareOptions(options) {}
28356
28390
  async prepareRequest(request, { url, options }) {}
28357
- get(path3, opts) {
28358
- return this.methodRequest("get", path3, opts);
28391
+ get(path2, opts) {
28392
+ return this.methodRequest("get", path2, opts);
28359
28393
  }
28360
- post(path3, opts) {
28361
- return this.methodRequest("post", path3, opts);
28394
+ post(path2, opts) {
28395
+ return this.methodRequest("post", path2, opts);
28362
28396
  }
28363
- patch(path3, opts) {
28364
- return this.methodRequest("patch", path3, opts);
28397
+ patch(path2, opts) {
28398
+ return this.methodRequest("patch", path2, opts);
28365
28399
  }
28366
- put(path3, opts) {
28367
- return this.methodRequest("put", path3, opts);
28400
+ put(path2, opts) {
28401
+ return this.methodRequest("put", path2, opts);
28368
28402
  }
28369
- delete(path3, opts) {
28370
- return this.methodRequest("delete", path3, opts);
28403
+ delete(path2, opts) {
28404
+ return this.methodRequest("delete", path2, opts);
28371
28405
  }
28372
- methodRequest(method, path3, opts) {
28406
+ methodRequest(method, path2, opts) {
28373
28407
  return this.request(Promise.resolve(opts).then((opts2) => {
28374
- return { method, path: path3, ...opts2 };
28408
+ return { method, path: path2, ...opts2 };
28375
28409
  }));
28376
28410
  }
28377
28411
  request(options, remainingRetries = null) {
@@ -28475,8 +28509,8 @@ new Anthropic({ apiKey, dangerouslyAllowBrowser: true });
28475
28509
  }));
28476
28510
  return { response, options, controller, requestLogID, retryOfRequestLogID, startTime };
28477
28511
  }
28478
- getAPIList(path3, Page2, opts) {
28479
- return this.requestAPIList(Page2, { method: "get", path: path3, ...opts });
28512
+ getAPIList(path2, Page2, opts) {
28513
+ return this.requestAPIList(Page2, { method: "get", path: path2, ...opts });
28480
28514
  }
28481
28515
  requestAPIList(Page2, options) {
28482
28516
  const request = this.makeRequest(options, null, undefined);
@@ -28563,8 +28597,8 @@ new Anthropic({ apiKey, dangerouslyAllowBrowser: true });
28563
28597
  }
28564
28598
  async buildRequest(inputOptions, { retryCount = 0 } = {}) {
28565
28599
  const options = { ...inputOptions };
28566
- const { method, path: path3, query, defaultBaseURL } = options;
28567
- const url = this.buildURL(path3, query, defaultBaseURL);
28600
+ const { method, path: path2, query, defaultBaseURL } = options;
28601
+ const url = this.buildURL(path2, query, defaultBaseURL);
28568
28602
  if ("timeout" in options)
28569
28603
  validatePositiveInteger("timeout", options.timeout);
28570
28604
  options.timeout = options.timeout ?? this.timeout;
@@ -37129,52 +37163,34 @@ class AgentContext {
37129
37163
  // packages/core/src/context/manager.ts
37130
37164
  init_src();
37131
37165
 
37132
- // node_modules/.pnpm/tiktoken@1.0.22/node_modules/tiktoken/tiktoken.cjs
37133
- var __dirname = "/Users/hasna/Workspace/dev/hasna/opensource/opensourcedev/opensource-oldpal/node_modules/.pnpm/tiktoken@1.0.22/node_modules/tiktoken";
37134
- var wasm = require_tiktoken_bg();
37135
- var imports = {};
37136
- imports["./tiktoken_bg.js"] = wasm;
37137
- var path = __require("path");
37138
- var fs2 = __require("fs");
37139
- var candidates = __dirname.split(path.sep).reduce((memo, _, index, array) => {
37140
- const prefix = array.slice(0, index + 1).join(path.sep) + path.sep;
37141
- if (!prefix.includes("node_modules" + path.sep)) {
37142
- memo.unshift(path.join(prefix, "node_modules", "tiktoken", "", "./tiktoken_bg.wasm"));
37143
- }
37144
- return memo;
37145
- }, []);
37146
- candidates.unshift(path.join(__dirname, "./tiktoken_bg.wasm"));
37147
- var bytes = null;
37148
- for (const candidate of candidates) {
37149
- try {
37150
- bytes = fs2.readFileSync(candidate);
37151
- break;
37152
- } catch {}
37153
- }
37154
- if (bytes == null)
37155
- throw new Error("Missing tiktoken_bg.wasm");
37156
- var wasmModule = new WebAssembly.Module(bytes);
37157
- var wasmInstance = new WebAssembly.Instance(wasmModule, imports);
37158
- wasm.__wbg_set_wasm(wasmInstance.exports);
37159
- var $get_encoding = wasm["get_encoding"];
37160
- var $encoding_for_model = wasm["encoding_for_model"];
37161
- var $get_encoding_name_for_model = wasm["get_encoding_name_for_model"];
37162
- var $Tiktoken = wasm["Tiktoken"];
37163
-
37164
37166
  // packages/core/src/context/token-counter.ts
37165
- var DEFAULT_MODEL = "gpt-4";
37166
37167
  var MESSAGE_OVERHEAD_TOKENS = 4;
37168
+ var CHARS_PER_TOKEN = 4;
37169
+ var tiktokenEncoder = null;
37170
+ var tiktokenLoadAttempted = false;
37171
+ function loadTiktoken() {
37172
+ if (tiktokenLoadAttempted)
37173
+ return tiktokenEncoder;
37174
+ tiktokenLoadAttempted = true;
37175
+ try {
37176
+ const tiktoken = require_tiktoken();
37177
+ try {
37178
+ tiktokenEncoder = tiktoken.encoding_for_model("gpt-4");
37179
+ } catch {
37180
+ tiktokenEncoder = tiktoken.get_encoding("cl100k_base");
37181
+ }
37182
+ } catch (error) {
37183
+ console.warn("Token counting using estimation (tiktoken unavailable)");
37184
+ tiktokenEncoder = null;
37185
+ }
37186
+ return tiktokenEncoder;
37187
+ }
37167
37188
 
37168
37189
  class TokenCounter {
37169
- encoder;
37170
37190
  cache = new Map;
37171
37191
  maxCacheEntries = 1e4;
37172
- constructor(model = DEFAULT_MODEL) {
37173
- try {
37174
- this.encoder = $encoding_for_model(model);
37175
- } catch {
37176
- this.encoder = $get_encoding("cl100k_base");
37177
- }
37192
+ constructor(_model) {
37193
+ loadTiktoken();
37178
37194
  }
37179
37195
  count(text) {
37180
37196
  if (!text)
@@ -37182,7 +37198,13 @@ class TokenCounter {
37182
37198
  const cached = this.cache.get(text);
37183
37199
  if (cached !== undefined)
37184
37200
  return cached;
37185
- const tokens = this.encoder.encode(text).length;
37201
+ let tokens;
37202
+ const encoder = loadTiktoken();
37203
+ if (encoder) {
37204
+ tokens = encoder.encode(text).length;
37205
+ } else {
37206
+ tokens = Math.ceil(text.length / CHARS_PER_TOKEN);
37207
+ }
37186
37208
  if (text.length < 1e4) {
37187
37209
  this.cache.set(text, tokens);
37188
37210
  if (this.cache.size > this.maxCacheEntries) {
@@ -37642,9 +37664,9 @@ function normalizeInput(input) {
37642
37664
  return {};
37643
37665
  }
37644
37666
  function formatAjvError(error) {
37645
- const path2 = error.instancePath ? ` ${error.instancePath}` : "";
37667
+ const path = error.instancePath ? ` ${error.instancePath}` : "";
37646
37668
  const message = error.message || "is invalid";
37647
- return `${path2} ${message}`.trim();
37669
+ return `${path} ${message}`.trim();
37648
37670
  }
37649
37671
 
37650
37672
  // packages/core/src/security/logger.ts
@@ -37852,9 +37874,9 @@ function mergeHooks(target, source) {
37852
37874
  target[event].push(...matchers);
37853
37875
  }
37854
37876
  }
37855
- async function loadJsonFile(path2) {
37877
+ async function loadJsonFile(path) {
37856
37878
  try {
37857
- const file = Bun.file(path2);
37879
+ const file = Bun.file(path);
37858
37880
  if (!await file.exists()) {
37859
37881
  return null;
37860
37882
  }
@@ -37901,9 +37923,9 @@ async function loadSystemPrompt(cwd2 = process.cwd()) {
37901
37923
 
37902
37924
  `);
37903
37925
  }
37904
- async function loadTextFile(path2) {
37926
+ async function loadTextFile(path) {
37905
37927
  try {
37906
- const file = Bun.file(path2);
37928
+ const file = Bun.file(path);
37907
37929
  if (!await file.exists()) {
37908
37930
  return null;
37909
37931
  }
@@ -37920,8 +37942,8 @@ class SecurityLogger {
37920
37942
  constructor(logFile) {
37921
37943
  this.logFile = logFile ?? join2(getConfigDir(), "security.log");
37922
37944
  }
37923
- setLogFile(path2) {
37924
- this.logFile = path2;
37945
+ setLogFile(path) {
37946
+ this.logFile = path;
37925
37947
  }
37926
37948
  log(event) {
37927
37949
  const fullEvent = {
@@ -38921,10 +38943,10 @@ async function validatePath(inputPath, options = {}) {
38921
38943
  }
38922
38944
  return { valid: true, resolved };
38923
38945
  }
38924
- function isWithinAllowed(path2, allowed) {
38946
+ function isWithinAllowed(path, allowed) {
38925
38947
  if (!allowed || allowed.length === 0)
38926
38948
  return true;
38927
- return allowed.some((allowedPath) => path2 === allowedPath || path2.startsWith(`${allowedPath}/`));
38949
+ return allowed.some((allowedPath) => path === allowedPath || path.startsWith(`${allowedPath}/`));
38928
38950
  }
38929
38951
 
38930
38952
  // packages/core/src/security/path-validator.ts
@@ -38976,9 +38998,9 @@ function getScriptsFolder(cwd2, sessionId) {
38976
38998
  const resolvedSessionId = sessionId || currentSessionId;
38977
38999
  return join4(getProjectConfigDir(cwd2), "scripts", resolvedSessionId);
38978
39000
  }
38979
- function isInScriptsFolder(path2, cwd2, sessionId) {
39001
+ function isInScriptsFolder(path, cwd2, sessionId) {
38980
39002
  const scriptsFolder = resolve3(getScriptsFolder(cwd2, sessionId));
38981
- const resolved = resolve3(path2);
39003
+ const resolved = resolve3(path);
38982
39004
  if (resolved === scriptsFolder)
38983
39005
  return true;
38984
39006
  return resolved.startsWith(`${scriptsFolder}${sep}`);
@@ -39026,18 +39048,18 @@ class FilesystemTools {
39026
39048
  };
39027
39049
  static readExecutor = async (input) => {
39028
39050
  const baseCwd = input.cwd || process.cwd();
39029
- const path2 = resolve3(baseCwd, input.path);
39051
+ const path = resolve3(baseCwd, input.path);
39030
39052
  const offset = (input.offset || 1) - 1;
39031
39053
  const limit = input.limit;
39032
39054
  try {
39033
- const safety = await isPathSafe(path2, "read", { cwd: baseCwd });
39055
+ const safety = await isPathSafe(path, "read", { cwd: baseCwd });
39034
39056
  if (!safety.safe) {
39035
39057
  getSecurityLogger().log({
39036
39058
  eventType: "path_violation",
39037
39059
  severity: "high",
39038
39060
  details: {
39039
39061
  tool: "read",
39040
- path: path2,
39062
+ path,
39041
39063
  reason: safety.reason || "Blocked path"
39042
39064
  },
39043
39065
  sessionId: input.sessionId || "unknown"
@@ -39050,7 +39072,7 @@ class FilesystemTools {
39050
39072
  retryable: false
39051
39073
  });
39052
39074
  }
39053
- const validated = await validatePath(path2, { allowSymlinks: true });
39075
+ const validated = await validatePath(path, { allowSymlinks: true });
39054
39076
  if (!validated.valid) {
39055
39077
  throw new ToolExecutionError(validated.error || "Invalid path", {
39056
39078
  toolName: "read",
@@ -39063,7 +39085,7 @@ class FilesystemTools {
39063
39085
  }
39064
39086
  const file = Bun.file(validated.resolved);
39065
39087
  if (!await file.exists()) {
39066
- throw new ToolExecutionError(`File not found: ${path2}`, {
39088
+ throw new ToolExecutionError(`File not found: ${path}`, {
39067
39089
  toolName: "read",
39068
39090
  toolInput: input,
39069
39091
  code: ErrorCodes.TOOL_EXECUTION_FAILED,
@@ -39146,8 +39168,8 @@ class FilesystemTools {
39146
39168
  });
39147
39169
  }
39148
39170
  const sanitizedFilename = filename.replace(/\.\.[/\\]/g, "").replace(/\.\./g, "").replace(/^[/\\]+/, "");
39149
- const path2 = join4(scriptsFolder, sanitizedFilename);
39150
- if (!isInScriptsFolder(path2, baseCwd, input.sessionId)) {
39171
+ const path = join4(scriptsFolder, sanitizedFilename);
39172
+ if (!isInScriptsFolder(path, baseCwd, input.sessionId)) {
39151
39173
  throw new ToolExecutionError(`Cannot write outside scripts folder. Files are saved to ${scriptsFolder}`, {
39152
39174
  toolName: "write",
39153
39175
  toolInput: input,
@@ -39158,7 +39180,7 @@ class FilesystemTools {
39158
39180
  });
39159
39181
  }
39160
39182
  try {
39161
- const validated = await validatePath(path2, { allowSymlinks: false, allowedPaths: [scriptsFolder] });
39183
+ const validated = await validatePath(path, { allowSymlinks: false, allowedPaths: [scriptsFolder] });
39162
39184
  if (!validated.valid) {
39163
39185
  throw new ToolExecutionError(validated.error || "Invalid path", {
39164
39186
  toolName: "write",
@@ -39351,16 +39373,16 @@ class FilesystemTools {
39351
39373
  };
39352
39374
  static readPdfExecutor = async (input) => {
39353
39375
  const baseCwd = input.cwd || process.cwd();
39354
- const path2 = resolve3(baseCwd, input.path);
39376
+ const path = resolve3(baseCwd, input.path);
39355
39377
  try {
39356
- const safety = await isPathSafe(path2, "read", { cwd: baseCwd });
39378
+ const safety = await isPathSafe(path, "read", { cwd: baseCwd });
39357
39379
  if (!safety.safe) {
39358
39380
  getSecurityLogger().log({
39359
39381
  eventType: "path_violation",
39360
39382
  severity: "high",
39361
39383
  details: {
39362
39384
  tool: "read_pdf",
39363
- path: path2,
39385
+ path,
39364
39386
  reason: safety.reason || "Blocked path"
39365
39387
  },
39366
39388
  sessionId: input.sessionId || "unknown"
@@ -39373,7 +39395,7 @@ class FilesystemTools {
39373
39395
  retryable: false
39374
39396
  });
39375
39397
  }
39376
- const validated = await validatePath(path2, { allowSymlinks: true });
39398
+ const validated = await validatePath(path, { allowSymlinks: true });
39377
39399
  if (!validated.valid) {
39378
39400
  throw new ToolExecutionError(validated.error || "Invalid path", {
39379
39401
  toolName: "read_pdf",
@@ -39386,7 +39408,7 @@ class FilesystemTools {
39386
39408
  }
39387
39409
  const file = Bun.file(validated.resolved);
39388
39410
  if (!await file.exists()) {
39389
- throw new ToolExecutionError(`PDF file not found: ${path2}`, {
39411
+ throw new ToolExecutionError(`PDF file not found: ${path}`, {
39390
39412
  toolName: "read_pdf",
39391
39413
  toolInput: input,
39392
39414
  code: ErrorCodes.TOOL_EXECUTION_FAILED,
@@ -39395,8 +39417,8 @@ class FilesystemTools {
39395
39417
  suggestion: "Check the file path and try again."
39396
39418
  });
39397
39419
  }
39398
- if (!path2.toLowerCase().endsWith(".pdf")) {
39399
- throw new ToolExecutionError(`File is not a PDF: ${path2}`, {
39420
+ if (!path.toLowerCase().endsWith(".pdf")) {
39421
+ throw new ToolExecutionError(`File is not a PDF: ${path}`, {
39400
39422
  toolName: "read_pdf",
39401
39423
  toolInput: input,
39402
39424
  code: ErrorCodes.VALIDATION_OUT_OF_RANGE,
@@ -39421,7 +39443,7 @@ class FilesystemTools {
39421
39443
  return JSON.stringify({
39422
39444
  __pdf_attachment__: true,
39423
39445
  path: validated.resolved,
39424
- name: path2.split("/").pop() || "document.pdf",
39446
+ name: path.split("/").pop() || "document.pdf",
39425
39447
  mediaType: "application/pdf",
39426
39448
  data: base64Data,
39427
39449
  size: file.size
@@ -40039,9 +40061,9 @@ function resolveFeedbackDir(cwd2) {
40039
40061
  function saveFeedbackEntry(entry, cwd2) {
40040
40062
  const feedbackDir = resolveFeedbackDir(cwd2);
40041
40063
  mkdirSync2(feedbackDir, { recursive: true });
40042
- const path2 = join5(feedbackDir, `${entry.id}.json`);
40043
- writeFileSync2(path2, JSON.stringify(entry, null, 2));
40044
- return { path: path2 };
40064
+ const path = join5(feedbackDir, `${entry.id}.json`);
40065
+ writeFileSync2(path, JSON.stringify(entry, null, 2));
40066
+ return { path };
40045
40067
  }
40046
40068
  function buildEntry(input, overrides) {
40047
40069
  const typeValue = String(input.type || "feedback").toLowerCase();
@@ -40124,10 +40146,10 @@ class FeedbackTool {
40124
40146
  static executor = async (input) => {
40125
40147
  try {
40126
40148
  const entry = buildEntry(input, { source: input.source || "tool" });
40127
- const { path: path2 } = saveFeedbackEntry(entry, typeof input.cwd === "string" ? input.cwd : undefined);
40149
+ const { path } = saveFeedbackEntry(entry, typeof input.cwd === "string" ? input.cwd : undefined);
40128
40150
  return `Feedback saved locally.
40129
40151
  ID: ${entry.id}
40130
- Path: ${path2}`;
40152
+ Path: ${path}`;
40131
40153
  } catch (error) {
40132
40154
  return `Error: ${error instanceof Error ? error.message : String(error)}`;
40133
40155
  }
@@ -40308,8 +40330,8 @@ async function listSchedules(cwd2) {
40308
40330
  }
40309
40331
  async function saveSchedule(cwd2, schedule) {
40310
40332
  await ensureDirs(cwd2);
40311
- const path2 = schedulePath(cwd2, schedule.id);
40312
- await writeFile(path2, JSON.stringify(schedule, null, 2), "utf-8");
40333
+ const path = schedulePath(cwd2, schedule.id);
40334
+ await writeFile(path, JSON.stringify(schedule, null, 2), "utf-8");
40313
40335
  }
40314
40336
  async function deleteSchedule(cwd2, id) {
40315
40337
  try {
@@ -40357,27 +40379,27 @@ async function updateSchedule(cwd2, id, updater) {
40357
40379
  }
40358
40380
  async function acquireScheduleLock(cwd2, id, ownerId, ttlMs = DEFAULT_LOCK_TTL_MS, allowRetry = true) {
40359
40381
  await ensureDirs(cwd2);
40360
- const path2 = lockPath(cwd2, id);
40382
+ const path = lockPath(cwd2, id);
40361
40383
  const now2 = Date.now();
40362
40384
  try {
40363
- const handle = await open(path2, "wx");
40385
+ const handle = await open(path, "wx");
40364
40386
  await handle.writeFile(JSON.stringify({ ownerId, createdAt: now2, updatedAt: now2, ttlMs }, null, 2), "utf-8");
40365
40387
  await handle.close();
40366
40388
  return true;
40367
40389
  } catch {
40368
40390
  try {
40369
- const raw = await readFile(path2, "utf-8");
40391
+ const raw = await readFile(path, "utf-8");
40370
40392
  const lock = JSON.parse(raw);
40371
40393
  const updatedAt = lock?.updatedAt || lock?.createdAt || 0;
40372
40394
  const ttl = lock?.ttlMs ?? ttlMs;
40373
40395
  if (now2 - updatedAt > ttl) {
40374
- await unlink(path2);
40396
+ await unlink(path);
40375
40397
  return acquireScheduleLock(cwd2, id, ownerId, ttlMs, false);
40376
40398
  }
40377
40399
  } catch {
40378
40400
  if (allowRetry) {
40379
40401
  try {
40380
- await unlink(path2);
40402
+ await unlink(path);
40381
40403
  return acquireScheduleLock(cwd2, id, ownerId, ttlMs, false);
40382
40404
  } catch {
40383
40405
  return false;
@@ -40388,23 +40410,23 @@ async function acquireScheduleLock(cwd2, id, ownerId, ttlMs = DEFAULT_LOCK_TTL_M
40388
40410
  return false;
40389
40411
  }
40390
40412
  async function releaseScheduleLock(cwd2, id, ownerId) {
40391
- const path2 = lockPath(cwd2, id);
40413
+ const path = lockPath(cwd2, id);
40392
40414
  try {
40393
- const raw = await readFile(path2, "utf-8");
40415
+ const raw = await readFile(path, "utf-8");
40394
40416
  const lock = JSON.parse(raw);
40395
40417
  if (lock?.ownerId === ownerId) {
40396
- await unlink(path2);
40418
+ await unlink(path);
40397
40419
  }
40398
40420
  } catch {}
40399
40421
  }
40400
40422
  async function refreshScheduleLock(cwd2, id, ownerId) {
40401
- const path2 = lockPath(cwd2, id);
40423
+ const path = lockPath(cwd2, id);
40402
40424
  try {
40403
- const raw = await readFile(path2, "utf-8");
40425
+ const raw = await readFile(path, "utf-8");
40404
40426
  const lock = JSON.parse(raw);
40405
40427
  if (lock?.ownerId === ownerId) {
40406
40428
  const updated = { ...lock, updatedAt: Date.now() };
40407
- await writeFile(path2, JSON.stringify(updated, null, 2), "utf-8");
40429
+ await writeFile(path, JSON.stringify(updated, null, 2), "utf-8");
40408
40430
  }
40409
40431
  } catch {}
40410
40432
  }
@@ -40632,11 +40654,11 @@ async function getViuPath() {
40632
40654
  "/usr/local/bin/viu",
40633
40655
  "/opt/homebrew/bin/viu"
40634
40656
  ];
40635
- for (const path2 of locations) {
40657
+ for (const path of locations) {
40636
40658
  try {
40637
- const result = await Bun.$`${path2} --version`.quiet().nothrow();
40659
+ const result = await Bun.$`${path} --version`.quiet().nothrow();
40638
40660
  if (result.exitCode === 0) {
40639
- return path2;
40661
+ return path;
40640
40662
  }
40641
40663
  } catch {
40642
40664
  continue;
@@ -43091,6 +43113,10 @@ No context entries for project "${project.name}".
43091
43113
  context.emit("done");
43092
43114
  return { handled: true };
43093
43115
  }
43116
+ context.emit("text", `Failed to clear context entries for "${project.name}".
43117
+ `);
43118
+ context.emit("done");
43119
+ return { handled: true };
43094
43120
  }
43095
43121
  if (sub === "remove") {
43096
43122
  const id = parts[1];
@@ -43118,6 +43144,10 @@ No context entries for project "${project.name}".
43118
43144
  context.emit("done");
43119
43145
  return { handled: true };
43120
43146
  }
43147
+ context.emit("text", `Failed to remove context entry ${id} from "${project.name}".
43148
+ `);
43149
+ context.emit("done");
43150
+ return { handled: true };
43121
43151
  }
43122
43152
  if (sub === "add") {
43123
43153
  const type = parts[1];
@@ -43155,6 +43185,10 @@ No context entries for project "${project.name}".
43155
43185
  context.emit("done");
43156
43186
  return { handled: true };
43157
43187
  }
43188
+ context.emit("text", `Failed to add context entry to "${project.name}".
43189
+ `);
43190
+ context.emit("done");
43191
+ return { handled: true };
43158
43192
  }
43159
43193
  context.emit("text", `Unknown /context command. Use /context help.
43160
43194
  `);
@@ -43313,6 +43347,10 @@ No projects found. Use /projects new <name>.
43313
43347
  context.emit("done");
43314
43348
  return { handled: true };
43315
43349
  }
43350
+ context.emit("text", `Failed to update project "${project.name}".
43351
+ `);
43352
+ context.emit("done");
43353
+ return { handled: true };
43316
43354
  }
43317
43355
  if (sub === "delete" || sub === "rm") {
43318
43356
  const target = parts.slice(1).join(" ").trim();
@@ -43340,6 +43378,10 @@ No projects found. Use /projects new <name>.
43340
43378
  context.emit("done");
43341
43379
  return { handled: true };
43342
43380
  }
43381
+ context.emit("text", `Failed to delete project "${project.name}".
43382
+ `);
43383
+ context.emit("done");
43384
+ return { handled: true };
43343
43385
  }
43344
43386
  context.emit("text", `Unknown /projects command. Use /projects help.
43345
43387
  `);
@@ -43883,9 +43925,9 @@ Format the summary as a brief bullet-point list. This summary will replace the c
43883
43925
  `;
43884
43926
  message += `**Config File Locations:**
43885
43927
  `;
43886
- for (const path2 of configPaths) {
43887
- const exists = existsSync7(path2);
43888
- message += ` ${exists ? "\u2713" : "\u25CB"} ${path2}
43928
+ for (const path of configPaths) {
43929
+ const exists = existsSync7(path);
43930
+ message += ` ${exists ? "\u2713" : "\u25CB"} ${path}
43889
43931
  `;
43890
43932
  }
43891
43933
  const envHome = process.env.HOME || process.env.USERPROFILE;
@@ -44733,9 +44775,9 @@ class HeartbeatManager {
44733
44775
  await writeFile3(this.config.persistPath, JSON.stringify(heartbeat, null, 2));
44734
44776
  } catch {}
44735
44777
  }
44736
- static async checkStale(path3, thresholdMs) {
44778
+ static async checkStale(path2, thresholdMs) {
44737
44779
  try {
44738
- const content = await readFile4(path3, "utf-8");
44780
+ const content = await readFile4(path2, "utf-8");
44739
44781
  const heartbeat = JSON.parse(content);
44740
44782
  const age = Date.now() - new Date(heartbeat.timestamp).getTime();
44741
44783
  return { isStale: age > thresholdMs, lastHeartbeat: heartbeat };
@@ -44751,9 +44793,9 @@ import { readFile as readFile5, writeFile as writeFile4, unlink as unlink3 } fro
44751
44793
 
44752
44794
  class StatePersistence {
44753
44795
  path;
44754
- constructor(path3) {
44755
- this.path = path3;
44756
- mkdirSync6(dirname6(path3), { recursive: true });
44796
+ constructor(path2) {
44797
+ this.path = path2;
44798
+ mkdirSync6(dirname6(path2), { recursive: true });
44757
44799
  }
44758
44800
  async save(state) {
44759
44801
  try {
@@ -44978,9 +45020,9 @@ import { readFile as readFile6, writeFile as writeFile5 } from "fs/promises";
44978
45020
 
44979
45021
  class EnergyStorage {
44980
45022
  path;
44981
- constructor(path3) {
44982
- this.path = path3;
44983
- mkdirSync7(dirname7(path3), { recursive: true });
45023
+ constructor(path2) {
45024
+ this.path = path2;
45025
+ mkdirSync7(dirname7(path2), { recursive: true });
44984
45026
  }
44985
45027
  async save(state) {
44986
45028
  try {
@@ -45739,11 +45781,11 @@ class IdentityManager {
45739
45781
  await writeFile6(this.indexPath, JSON.stringify(index, null, 2));
45740
45782
  }
45741
45783
  async readIdentity(id) {
45742
- const path3 = this.identityPath(id);
45743
- if (!existsSync10(path3))
45784
+ const path2 = this.identityPath(id);
45785
+ if (!existsSync10(path2))
45744
45786
  return null;
45745
45787
  try {
45746
- const raw = await readFile7(path3, "utf-8");
45788
+ const raw = await readFile7(path2, "utf-8");
45747
45789
  return JSON.parse(raw);
45748
45790
  } catch {
45749
45791
  return null;
@@ -49265,8 +49307,8 @@ function getToolContext(toolCall) {
49265
49307
  case "bash":
49266
49308
  return truncate(String(input.command || ""), 20);
49267
49309
  case "read":
49268
- const path3 = String(input.path || input.file_path || "");
49269
- return path3.split("/").pop() || "";
49310
+ const path2 = String(input.path || input.file_path || "");
49311
+ return path2.split("/").pop() || "";
49270
49312
  case "write":
49271
49313
  const writePath = String(input.filename || input.path || input.file_path || "");
49272
49314
  return writePath.split("/").pop() || "";
@@ -49923,7 +49965,7 @@ function SessionSelector({
49923
49965
  const isSelected = index === selectedIndex;
49924
49966
  const prefix = isActive ? "[*]" : " ";
49925
49967
  const time = formatSessionTime(session.updatedAt);
49926
- const path3 = formatPath(session.cwd);
49968
+ const path2 = formatPath(session.cwd);
49927
49969
  const processing = session.isProcessing ? " (processing)" : "";
49928
49970
  return /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(Box_default, {
49929
49971
  children: /* @__PURE__ */ jsx_dev_runtime8.jsxDEV(Text, {
@@ -49937,7 +49979,7 @@ function SessionSelector({
49937
49979
  ". ",
49938
49980
  time,
49939
49981
  " ",
49940
- path3,
49982
+ path2,
49941
49983
  processing
49942
49984
  ]
49943
49985
  }, undefined, true, undefined, this)
@@ -51341,4 +51383,4 @@ if (options.print !== null) {
51341
51383
  });
51342
51384
  }
51343
51385
 
51344
- //# debugId=CB2FADE01C1A298664756E2164756E21
51386
+ //# debugId=753207CF52EF9C5F64756E2164756E21