@bunny-agent/daemon 0.9.29-beta.11 → 0.9.29-beta.13

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/bundle.mjs CHANGED
@@ -206363,6 +206363,53 @@ function ok(data) {
206363
206363
  function fail(error) {
206364
206364
  return { ok: false, data: null, error };
206365
206365
  }
206366
+ function formatUnknownError(err) {
206367
+ const isObjectToStringMessage = (msg) => /^\[object [^\]]+\]$/.test(msg.trim());
206368
+ const collectErrorExtras = (e2) => {
206369
+ const extra = {};
206370
+ for (const key of Object.getOwnPropertyNames(e2)) {
206371
+ if (key === "name" || key === "message" || key === "stack") continue;
206372
+ extra[key] = e2[key];
206373
+ }
206374
+ for (const key of ["code", "status", "response", "body", "data"]) {
206375
+ if (key in e2 && !(key in extra)) {
206376
+ extra[key] = e2[key];
206377
+ }
206378
+ }
206379
+ return extra;
206380
+ };
206381
+ const errorRecord = (e2) => ({
206382
+ name: e2.name,
206383
+ message: e2.message,
206384
+ ...isObjectToStringMessage(e2.message) ? {
206385
+ note: "Upstream error message was stringified object"
206386
+ } : {},
206387
+ ...e2.cause !== void 0 ? { cause: formatUnknownError(e2.cause) } : {},
206388
+ ...Object.keys(collectErrorExtras(e2)).length > 0 ? { extra: collectErrorExtras(e2) } : {}
206389
+ });
206390
+ if (err == null) return String(err);
206391
+ if (typeof err === "string") return err;
206392
+ if (typeof err === "number" || typeof err === "boolean") return String(err);
206393
+ if (err instanceof Error) {
206394
+ try {
206395
+ return JSON.stringify(errorRecord(err));
206396
+ } catch {
206397
+ const message = err.message?.trim() ?? "";
206398
+ return `${err.name}: ${message || "(no message)"}`;
206399
+ }
206400
+ }
206401
+ if (typeof err === "object") {
206402
+ try {
206403
+ return JSON.stringify(err, (_key, value2) => {
206404
+ if (value2 instanceof Error) return errorRecord(value2);
206405
+ return value2;
206406
+ });
206407
+ } catch {
206408
+ return "Unserializable object error";
206409
+ }
206410
+ }
206411
+ return String(err);
206412
+ }
206366
206413
  function resolveVolumeRoot(state, volume) {
206367
206414
  const normalizedRoot = path.resolve(state.root);
206368
206415
  if (!volume) return state.root;
@@ -206787,7 +206834,7 @@ var DaemonRouter = class {
206787
206834
  }
206788
206835
  return {
206789
206836
  status: 500,
206790
- body: fail(err instanceof Error ? err.message : String(err))
206837
+ body: fail(formatUnknownError(err))
206791
206838
  };
206792
206839
  }
206793
206840
  }
@@ -206865,6 +206912,26 @@ function loadSystemPrompt(cwd) {
206865
206912
  // ../../packages/runner-claude/dist/ai-sdk-stream.js
206866
206913
  import { appendFileSync, existsSync as existsSync3, unlinkSync } from "node:fs";
206867
206914
  import { join as join3 } from "node:path";
206915
+ function formatUnknownError2(error) {
206916
+ if (error == null)
206917
+ return String(error);
206918
+ if (typeof error === "string")
206919
+ return error;
206920
+ if (typeof error === "number" || typeof error === "boolean") {
206921
+ return String(error);
206922
+ }
206923
+ if (error instanceof Error) {
206924
+ return error.message || error.name || "Error";
206925
+ }
206926
+ if (typeof error === "object") {
206927
+ try {
206928
+ return JSON.stringify(error);
206929
+ } catch {
206930
+ return "Unserializable object error";
206931
+ }
206932
+ }
206933
+ return String(error);
206934
+ }
206868
206935
  function trace(data, reset = false) {
206869
206936
  if (process.env.DEBUG !== "true")
206870
206937
  return;
@@ -207112,7 +207179,8 @@ var AISDKStreamConverter = class {
207112
207179
  const resultMsg = message;
207113
207180
  if (resultMsg.is_error) {
207114
207181
  this.errorEmitted = true;
207115
- const errorText = resultMsg.result || "Unknown error";
207182
+ const rawResult = resultMsg.result;
207183
+ const errorText = formatUnknownError2(rawResult) || "Unknown error";
207116
207184
  yield this.emit({
207117
207185
  type: "error",
207118
207186
  errorText
@@ -207129,9 +207197,10 @@ var AISDKStreamConverter = class {
207129
207197
  }
207130
207198
  }
207131
207199
  } catch (error) {
207200
+ const formattedError = formatUnknownError2(error);
207132
207201
  if (process.env.DEBUG === "true") {
207133
207202
  const errPayload = {
207134
- error: error instanceof Error ? error.message : String(error)
207203
+ error: formattedError
207135
207204
  };
207136
207205
  if (error instanceof Error) {
207137
207206
  if (error.stack)
@@ -207140,17 +207209,17 @@ var AISDKStreamConverter = class {
207140
207209
  errPayload.cause = error.cause instanceof Error ? {
207141
207210
  message: error.cause.message,
207142
207211
  stack: error.cause.stack
207143
- } : String(error.cause);
207212
+ } : formatUnknownError2(error.cause);
207144
207213
  }
207145
207214
  }
207146
207215
  trace(errPayload);
207147
207216
  } else {
207148
- trace({ error: String(error) });
207217
+ trace({ error: formattedError });
207149
207218
  }
207150
207219
  if (isAbortError(error)) {
207151
207220
  console.error("[AISDKStream] Operation aborted");
207152
207221
  } else {
207153
- const errorMessage = error instanceof Error ? error.message : "Unknown error";
207222
+ const errorMessage = formattedError;
207154
207223
  console.error("[AISDKStream] Error:", errorMessage);
207155
207224
  if (process.env.DEBUG === "true") {
207156
207225
  if (error instanceof Error && error.stack) {
@@ -207421,7 +207490,7 @@ Documentation: https://platform.claude.com/docs/en/agent-sdk/typescript-v2-previ
207421
207490
 
207422
207491
  `;
207423
207492
  } catch (error) {
207424
- const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
207493
+ const errorMessage = formatUnknownError2(error);
207425
207494
  console.error("[ClaudeRunner] Mock agent error:", errorMessage);
207426
207495
  yield formatDataStream({ type: "error", errorText: errorMessage });
207427
207496
  yield formatDataStream({
@@ -264482,6 +264551,26 @@ function buildSecretAwareTools(cwd, secrets) {
264482
264551
 
264483
264552
  // ../../packages/runner-pi/dist/pi-runner.js
264484
264553
  var LOG_PREFIX2 = "[bunny-agent:pi]";
264554
+ function formatUnknownError3(error) {
264555
+ if (error == null)
264556
+ return String(error);
264557
+ if (typeof error === "string")
264558
+ return error;
264559
+ if (typeof error === "number" || typeof error === "boolean") {
264560
+ return String(error);
264561
+ }
264562
+ if (error instanceof Error) {
264563
+ return error.message || error.name || "Error";
264564
+ }
264565
+ if (typeof error === "object") {
264566
+ try {
264567
+ return JSON.stringify(error);
264568
+ } catch {
264569
+ return "Unserializable object error";
264570
+ }
264571
+ }
264572
+ return String(error);
264573
+ }
264485
264574
  function parseModelSpec(model) {
264486
264575
  const trimmed = model.trim();
264487
264576
  const separator = trimmed.indexOf(":");
@@ -264721,7 +264810,7 @@ function createPiRunner(options2 = {}) {
264721
264810
  await promptPromise;
264722
264811
  } catch (error) {
264723
264812
  if (!streamConverter.finished) {
264724
- const message = error instanceof Error ? error.message : "Pi agent run failed.";
264813
+ const message = formatUnknownError3(error);
264725
264814
  for (const chunk of streamConverter.forceError(message)) {
264726
264815
  yield chunk;
264727
264816
  }
@@ -264729,7 +264818,8 @@ function createPiRunner(options2 = {}) {
264729
264818
  return;
264730
264819
  }
264731
264820
  if (!streamConverter.finished && session.agent.state.error) {
264732
- for (const chunk of streamConverter.forceError(session.agent.state.error)) {
264821
+ const errorText = formatUnknownError3(session.agent.state.error);
264822
+ for (const chunk of streamConverter.forceError(errorText)) {
264733
264823
  yield chunk;
264734
264824
  }
264735
264825
  }
@@ -264921,7 +265011,7 @@ async function bunnyAgentRun(req, res, env2) {
264921
265011
  res.write(chunk);
264922
265012
  }
264923
265013
  } catch (err) {
264924
- const msg = err instanceof Error ? err.message : String(err);
265014
+ const msg = formatUnknownError(err);
264925
265015
  res.write(`data: ${JSON.stringify({ type: "error", errorText: msg })}
264926
265016
 
264927
265017
  `);
@@ -264981,7 +265071,7 @@ function createDaemon(config) {
264981
265071
  res.end(JSON.stringify(result2));
264982
265072
  } catch (err) {
264983
265073
  const status2 = err instanceof AppError ? err.status : 500;
264984
- const msg = err instanceof Error ? err.message : String(err);
265074
+ const msg = formatUnknownError(err);
264985
265075
  res.writeHead(status2, { "Content-Type": "application/json" });
264986
265076
  res.end(JSON.stringify(fail(msg)));
264987
265077
  }
@@ -265008,7 +265098,7 @@ function createDaemon(config) {
265008
265098
  res.end(buffer);
265009
265099
  } catch (err) {
265010
265100
  const status2 = err instanceof AppError ? err.status : 500;
265011
- const msg = err instanceof Error ? err.message : String(err);
265101
+ const msg = formatUnknownError(err);
265012
265102
  res.writeHead(status2, { "Content-Type": "application/json" });
265013
265103
  res.end(JSON.stringify(fail(msg)));
265014
265104
  }
@@ -265041,7 +265131,7 @@ function createDaemon(config) {
265041
265131
  sendJson(res, err.status, fail(err.message));
265042
265132
  } else {
265043
265133
  console.error("Unhandled request error:", err);
265044
- const msg = err instanceof Error ? err.message : String(err);
265134
+ const msg = formatUnknownError(err);
265045
265135
  sendJson(res, 500, fail(`Internal server error: ${msg}`));
265046
265136
  }
265047
265137
  } else {
package/dist/index.js CHANGED
@@ -206297,6 +206297,53 @@ function ok(data) {
206297
206297
  function fail(error) {
206298
206298
  return { ok: false, data: null, error };
206299
206299
  }
206300
+ function formatUnknownError(err) {
206301
+ const isObjectToStringMessage = (msg) => /^\[object [^\]]+\]$/.test(msg.trim());
206302
+ const collectErrorExtras = (e2) => {
206303
+ const extra = {};
206304
+ for (const key of Object.getOwnPropertyNames(e2)) {
206305
+ if (key === "name" || key === "message" || key === "stack") continue;
206306
+ extra[key] = e2[key];
206307
+ }
206308
+ for (const key of ["code", "status", "response", "body", "data"]) {
206309
+ if (key in e2 && !(key in extra)) {
206310
+ extra[key] = e2[key];
206311
+ }
206312
+ }
206313
+ return extra;
206314
+ };
206315
+ const errorRecord = (e2) => ({
206316
+ name: e2.name,
206317
+ message: e2.message,
206318
+ ...isObjectToStringMessage(e2.message) ? {
206319
+ note: "Upstream error message was stringified object"
206320
+ } : {},
206321
+ ...e2.cause !== void 0 ? { cause: formatUnknownError(e2.cause) } : {},
206322
+ ...Object.keys(collectErrorExtras(e2)).length > 0 ? { extra: collectErrorExtras(e2) } : {}
206323
+ });
206324
+ if (err == null) return String(err);
206325
+ if (typeof err === "string") return err;
206326
+ if (typeof err === "number" || typeof err === "boolean") return String(err);
206327
+ if (err instanceof Error) {
206328
+ try {
206329
+ return JSON.stringify(errorRecord(err));
206330
+ } catch {
206331
+ const message = err.message?.trim() ?? "";
206332
+ return `${err.name}: ${message || "(no message)"}`;
206333
+ }
206334
+ }
206335
+ if (typeof err === "object") {
206336
+ try {
206337
+ return JSON.stringify(err, (_key, value2) => {
206338
+ if (value2 instanceof Error) return errorRecord(value2);
206339
+ return value2;
206340
+ });
206341
+ } catch {
206342
+ return "Unserializable object error";
206343
+ }
206344
+ }
206345
+ return String(err);
206346
+ }
206300
206347
  function resolveVolumeRoot(state, volume) {
206301
206348
  const normalizedRoot = path.resolve(state.root);
206302
206349
  if (!volume) return state.root;
@@ -206721,7 +206768,7 @@ var DaemonRouter = class {
206721
206768
  }
206722
206769
  return {
206723
206770
  status: 500,
206724
- body: fail(err instanceof Error ? err.message : String(err))
206771
+ body: fail(formatUnknownError(err))
206725
206772
  };
206726
206773
  }
206727
206774
  }
@@ -206861,6 +206908,26 @@ function loadSystemPrompt(cwd) {
206861
206908
  // ../../packages/runner-claude/dist/ai-sdk-stream.js
206862
206909
  import { appendFileSync, existsSync as existsSync3, unlinkSync } from "node:fs";
206863
206910
  import { join as join3 } from "node:path";
206911
+ function formatUnknownError2(error) {
206912
+ if (error == null)
206913
+ return String(error);
206914
+ if (typeof error === "string")
206915
+ return error;
206916
+ if (typeof error === "number" || typeof error === "boolean") {
206917
+ return String(error);
206918
+ }
206919
+ if (error instanceof Error) {
206920
+ return error.message || error.name || "Error";
206921
+ }
206922
+ if (typeof error === "object") {
206923
+ try {
206924
+ return JSON.stringify(error);
206925
+ } catch {
206926
+ return "Unserializable object error";
206927
+ }
206928
+ }
206929
+ return String(error);
206930
+ }
206864
206931
  function trace(data, reset = false) {
206865
206932
  if (process.env.DEBUG !== "true")
206866
206933
  return;
@@ -207108,7 +207175,8 @@ var AISDKStreamConverter = class {
207108
207175
  const resultMsg = message;
207109
207176
  if (resultMsg.is_error) {
207110
207177
  this.errorEmitted = true;
207111
- const errorText = resultMsg.result || "Unknown error";
207178
+ const rawResult = resultMsg.result;
207179
+ const errorText = formatUnknownError2(rawResult) || "Unknown error";
207112
207180
  yield this.emit({
207113
207181
  type: "error",
207114
207182
  errorText
@@ -207125,9 +207193,10 @@ var AISDKStreamConverter = class {
207125
207193
  }
207126
207194
  }
207127
207195
  } catch (error) {
207196
+ const formattedError = formatUnknownError2(error);
207128
207197
  if (process.env.DEBUG === "true") {
207129
207198
  const errPayload = {
207130
- error: error instanceof Error ? error.message : String(error)
207199
+ error: formattedError
207131
207200
  };
207132
207201
  if (error instanceof Error) {
207133
207202
  if (error.stack)
@@ -207136,17 +207205,17 @@ var AISDKStreamConverter = class {
207136
207205
  errPayload.cause = error.cause instanceof Error ? {
207137
207206
  message: error.cause.message,
207138
207207
  stack: error.cause.stack
207139
- } : String(error.cause);
207208
+ } : formatUnknownError2(error.cause);
207140
207209
  }
207141
207210
  }
207142
207211
  trace(errPayload);
207143
207212
  } else {
207144
- trace({ error: String(error) });
207213
+ trace({ error: formattedError });
207145
207214
  }
207146
207215
  if (isAbortError(error)) {
207147
207216
  console.error("[AISDKStream] Operation aborted");
207148
207217
  } else {
207149
- const errorMessage = error instanceof Error ? error.message : "Unknown error";
207218
+ const errorMessage = formattedError;
207150
207219
  console.error("[AISDKStream] Error:", errorMessage);
207151
207220
  if (process.env.DEBUG === "true") {
207152
207221
  if (error instanceof Error && error.stack) {
@@ -207417,7 +207486,7 @@ Documentation: https://platform.claude.com/docs/en/agent-sdk/typescript-v2-previ
207417
207486
 
207418
207487
  `;
207419
207488
  } catch (error) {
207420
- const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
207489
+ const errorMessage = formatUnknownError2(error);
207421
207490
  console.error("[ClaudeRunner] Mock agent error:", errorMessage);
207422
207491
  yield formatDataStream({ type: "error", errorText: errorMessage });
207423
207492
  yield formatDataStream({
@@ -264478,6 +264547,26 @@ function buildSecretAwareTools(cwd, secrets) {
264478
264547
 
264479
264548
  // ../../packages/runner-pi/dist/pi-runner.js
264480
264549
  var LOG_PREFIX2 = "[bunny-agent:pi]";
264550
+ function formatUnknownError3(error) {
264551
+ if (error == null)
264552
+ return String(error);
264553
+ if (typeof error === "string")
264554
+ return error;
264555
+ if (typeof error === "number" || typeof error === "boolean") {
264556
+ return String(error);
264557
+ }
264558
+ if (error instanceof Error) {
264559
+ return error.message || error.name || "Error";
264560
+ }
264561
+ if (typeof error === "object") {
264562
+ try {
264563
+ return JSON.stringify(error);
264564
+ } catch {
264565
+ return "Unserializable object error";
264566
+ }
264567
+ }
264568
+ return String(error);
264569
+ }
264481
264570
  function parseModelSpec(model) {
264482
264571
  const trimmed = model.trim();
264483
264572
  const separator = trimmed.indexOf(":");
@@ -264717,7 +264806,7 @@ function createPiRunner(options2 = {}) {
264717
264806
  await promptPromise;
264718
264807
  } catch (error) {
264719
264808
  if (!streamConverter.finished) {
264720
- const message = error instanceof Error ? error.message : "Pi agent run failed.";
264809
+ const message = formatUnknownError3(error);
264721
264810
  for (const chunk of streamConverter.forceError(message)) {
264722
264811
  yield chunk;
264723
264812
  }
@@ -264725,7 +264814,8 @@ function createPiRunner(options2 = {}) {
264725
264814
  return;
264726
264815
  }
264727
264816
  if (!streamConverter.finished && session.agent.state.error) {
264728
- for (const chunk of streamConverter.forceError(session.agent.state.error)) {
264817
+ const errorText = formatUnknownError3(session.agent.state.error);
264818
+ for (const chunk of streamConverter.forceError(errorText)) {
264729
264819
  yield chunk;
264730
264820
  }
264731
264821
  }
@@ -264917,7 +265007,7 @@ async function bunnyAgentRun(req, res, env2) {
264917
265007
  res.write(chunk);
264918
265008
  }
264919
265009
  } catch (err) {
264920
- const msg = err instanceof Error ? err.message : String(err);
265010
+ const msg = formatUnknownError(err);
264921
265011
  res.write(`data: ${JSON.stringify({ type: "error", errorText: msg })}
264922
265012
 
264923
265013
  `);
@@ -264977,7 +265067,7 @@ function createDaemon(config) {
264977
265067
  res.end(JSON.stringify(result2));
264978
265068
  } catch (err) {
264979
265069
  const status2 = err instanceof AppError ? err.status : 500;
264980
- const msg = err instanceof Error ? err.message : String(err);
265070
+ const msg = formatUnknownError(err);
264981
265071
  res.writeHead(status2, { "Content-Type": "application/json" });
264982
265072
  res.end(JSON.stringify(fail(msg)));
264983
265073
  }
@@ -265004,7 +265094,7 @@ function createDaemon(config) {
265004
265094
  res.end(buffer);
265005
265095
  } catch (err) {
265006
265096
  const status2 = err instanceof AppError ? err.status : 500;
265007
- const msg = err instanceof Error ? err.message : String(err);
265097
+ const msg = formatUnknownError(err);
265008
265098
  res.writeHead(status2, { "Content-Type": "application/json" });
265009
265099
  res.end(JSON.stringify(fail(msg)));
265010
265100
  }
@@ -265037,7 +265127,7 @@ function createDaemon(config) {
265037
265127
  sendJson(res, err.status, fail(err.message));
265038
265128
  } else {
265039
265129
  console.error("Unhandled request error:", err);
265040
- const msg = err instanceof Error ? err.message : String(err);
265130
+ const msg = formatUnknownError(err);
265041
265131
  sendJson(res, 500, fail(`Internal server error: ${msg}`));
265042
265132
  }
265043
265133
  } else {
@@ -1 +1 @@
1
- {"version":3,"file":"nextjs.d.ts","sourceRoot":"","sources":["../src/nextjs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AASH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,IASzD,KAAK,OAAO,KAAG,OAAO,CAAC,QAAQ,CAAC,CAgF/C"}
1
+ {"version":3,"file":"nextjs.d.ts","sourceRoot":"","sources":["../src/nextjs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAeH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,IASzD,KAAK,OAAO,KAAG,OAAO,CAAC,QAAQ,CAAC,CAgF/C"}
package/dist/nextjs.js CHANGED
@@ -206355,6 +206355,53 @@ function ok(data) {
206355
206355
  function fail(error) {
206356
206356
  return { ok: false, data: null, error };
206357
206357
  }
206358
+ function formatUnknownError(err) {
206359
+ const isObjectToStringMessage = (msg) => /^\[object [^\]]+\]$/.test(msg.trim());
206360
+ const collectErrorExtras = (e2) => {
206361
+ const extra = {};
206362
+ for (const key of Object.getOwnPropertyNames(e2)) {
206363
+ if (key === "name" || key === "message" || key === "stack") continue;
206364
+ extra[key] = e2[key];
206365
+ }
206366
+ for (const key of ["code", "status", "response", "body", "data"]) {
206367
+ if (key in e2 && !(key in extra)) {
206368
+ extra[key] = e2[key];
206369
+ }
206370
+ }
206371
+ return extra;
206372
+ };
206373
+ const errorRecord = (e2) => ({
206374
+ name: e2.name,
206375
+ message: e2.message,
206376
+ ...isObjectToStringMessage(e2.message) ? {
206377
+ note: "Upstream error message was stringified object"
206378
+ } : {},
206379
+ ...e2.cause !== void 0 ? { cause: formatUnknownError(e2.cause) } : {},
206380
+ ...Object.keys(collectErrorExtras(e2)).length > 0 ? { extra: collectErrorExtras(e2) } : {}
206381
+ });
206382
+ if (err == null) return String(err);
206383
+ if (typeof err === "string") return err;
206384
+ if (typeof err === "number" || typeof err === "boolean") return String(err);
206385
+ if (err instanceof Error) {
206386
+ try {
206387
+ return JSON.stringify(errorRecord(err));
206388
+ } catch {
206389
+ const message = err.message?.trim() ?? "";
206390
+ return `${err.name}: ${message || "(no message)"}`;
206391
+ }
206392
+ }
206393
+ if (typeof err === "object") {
206394
+ try {
206395
+ return JSON.stringify(err, (_key, value2) => {
206396
+ if (value2 instanceof Error) return errorRecord(value2);
206397
+ return value2;
206398
+ });
206399
+ } catch {
206400
+ return "Unserializable object error";
206401
+ }
206402
+ }
206403
+ return String(err);
206404
+ }
206358
206405
  function resolveVolumeRoot(state, volume) {
206359
206406
  const normalizedRoot = path.resolve(state.root);
206360
206407
  if (!volume) return state.root;
@@ -206779,7 +206826,7 @@ var DaemonRouter = class {
206779
206826
  }
206780
206827
  return {
206781
206828
  status: 500,
206782
- body: fail(err instanceof Error ? err.message : String(err))
206829
+ body: fail(formatUnknownError(err))
206783
206830
  };
206784
206831
  }
206785
206832
  }
@@ -206857,6 +206904,26 @@ function loadSystemPrompt(cwd) {
206857
206904
  // ../../packages/runner-claude/dist/ai-sdk-stream.js
206858
206905
  import { appendFileSync, existsSync as existsSync3, unlinkSync } from "node:fs";
206859
206906
  import { join as join3 } from "node:path";
206907
+ function formatUnknownError2(error) {
206908
+ if (error == null)
206909
+ return String(error);
206910
+ if (typeof error === "string")
206911
+ return error;
206912
+ if (typeof error === "number" || typeof error === "boolean") {
206913
+ return String(error);
206914
+ }
206915
+ if (error instanceof Error) {
206916
+ return error.message || error.name || "Error";
206917
+ }
206918
+ if (typeof error === "object") {
206919
+ try {
206920
+ return JSON.stringify(error);
206921
+ } catch {
206922
+ return "Unserializable object error";
206923
+ }
206924
+ }
206925
+ return String(error);
206926
+ }
206860
206927
  function trace(data, reset = false) {
206861
206928
  if (process.env.DEBUG !== "true")
206862
206929
  return;
@@ -207104,7 +207171,8 @@ var AISDKStreamConverter = class {
207104
207171
  const resultMsg = message;
207105
207172
  if (resultMsg.is_error) {
207106
207173
  this.errorEmitted = true;
207107
- const errorText = resultMsg.result || "Unknown error";
207174
+ const rawResult = resultMsg.result;
207175
+ const errorText = formatUnknownError2(rawResult) || "Unknown error";
207108
207176
  yield this.emit({
207109
207177
  type: "error",
207110
207178
  errorText
@@ -207121,9 +207189,10 @@ var AISDKStreamConverter = class {
207121
207189
  }
207122
207190
  }
207123
207191
  } catch (error) {
207192
+ const formattedError = formatUnknownError2(error);
207124
207193
  if (process.env.DEBUG === "true") {
207125
207194
  const errPayload = {
207126
- error: error instanceof Error ? error.message : String(error)
207195
+ error: formattedError
207127
207196
  };
207128
207197
  if (error instanceof Error) {
207129
207198
  if (error.stack)
@@ -207132,17 +207201,17 @@ var AISDKStreamConverter = class {
207132
207201
  errPayload.cause = error.cause instanceof Error ? {
207133
207202
  message: error.cause.message,
207134
207203
  stack: error.cause.stack
207135
- } : String(error.cause);
207204
+ } : formatUnknownError2(error.cause);
207136
207205
  }
207137
207206
  }
207138
207207
  trace(errPayload);
207139
207208
  } else {
207140
- trace({ error: String(error) });
207209
+ trace({ error: formattedError });
207141
207210
  }
207142
207211
  if (isAbortError(error)) {
207143
207212
  console.error("[AISDKStream] Operation aborted");
207144
207213
  } else {
207145
- const errorMessage = error instanceof Error ? error.message : "Unknown error";
207214
+ const errorMessage = formattedError;
207146
207215
  console.error("[AISDKStream] Error:", errorMessage);
207147
207216
  if (process.env.DEBUG === "true") {
207148
207217
  if (error instanceof Error && error.stack) {
@@ -207413,7 +207482,7 @@ Documentation: https://platform.claude.com/docs/en/agent-sdk/typescript-v2-previ
207413
207482
 
207414
207483
  `;
207415
207484
  } catch (error) {
207416
- const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
207485
+ const errorMessage = formatUnknownError2(error);
207417
207486
  console.error("[ClaudeRunner] Mock agent error:", errorMessage);
207418
207487
  yield formatDataStream({ type: "error", errorText: errorMessage });
207419
207488
  yield formatDataStream({
@@ -264474,6 +264543,26 @@ function buildSecretAwareTools(cwd, secrets) {
264474
264543
 
264475
264544
  // ../../packages/runner-pi/dist/pi-runner.js
264476
264545
  var LOG_PREFIX2 = "[bunny-agent:pi]";
264546
+ function formatUnknownError3(error) {
264547
+ if (error == null)
264548
+ return String(error);
264549
+ if (typeof error === "string")
264550
+ return error;
264551
+ if (typeof error === "number" || typeof error === "boolean") {
264552
+ return String(error);
264553
+ }
264554
+ if (error instanceof Error) {
264555
+ return error.message || error.name || "Error";
264556
+ }
264557
+ if (typeof error === "object") {
264558
+ try {
264559
+ return JSON.stringify(error);
264560
+ } catch {
264561
+ return "Unserializable object error";
264562
+ }
264563
+ }
264564
+ return String(error);
264565
+ }
264477
264566
  function parseModelSpec(model) {
264478
264567
  const trimmed = model.trim();
264479
264568
  const separator = trimmed.indexOf(":");
@@ -264713,7 +264802,7 @@ function createPiRunner(options2 = {}) {
264713
264802
  await promptPromise;
264714
264803
  } catch (error) {
264715
264804
  if (!streamConverter.finished) {
264716
- const message = error instanceof Error ? error.message : "Pi agent run failed.";
264805
+ const message = formatUnknownError3(error);
264717
264806
  for (const chunk of streamConverter.forceError(message)) {
264718
264807
  yield chunk;
264719
264808
  }
@@ -264721,7 +264810,8 @@ function createPiRunner(options2 = {}) {
264721
264810
  return;
264722
264811
  }
264723
264812
  if (!streamConverter.finished && session.agent.state.error) {
264724
- for (const chunk of streamConverter.forceError(session.agent.state.error)) {
264813
+ const errorText = formatUnknownError3(session.agent.state.error);
264814
+ for (const chunk of streamConverter.forceError(errorText)) {
264725
264815
  yield chunk;
264726
264816
  }
264727
264817
  }
@@ -264910,7 +265000,7 @@ function codingRunStream(req, env2) {
264910
265000
  controller.enqueue(encoder.encode(chunk));
264911
265001
  }
264912
265002
  } catch (err) {
264913
- const msg = err instanceof Error ? err.message : String(err);
265003
+ const msg = formatUnknownError(err);
264914
265004
  controller.enqueue(
264915
265005
  encoder.encode(
264916
265006
  `data: ${JSON.stringify({ type: "error", errorText: msg })}
@@ -264972,7 +265062,7 @@ function createNextHandler(opts) {
264972
265062
  return Response.json(result2);
264973
265063
  } catch (err) {
264974
265064
  const status = err instanceof AppError ? err.status : 500;
264975
- const msg = err instanceof Error ? err.message : String(err);
265065
+ const msg = formatUnknownError(err);
264976
265066
  return Response.json(fail(msg), { status });
264977
265067
  }
264978
265068
  }
@@ -264999,7 +265089,7 @@ function createNextHandler(opts) {
264999
265089
  });
265000
265090
  } catch (err) {
265001
265091
  const status = err instanceof AppError ? err.status : 500;
265002
- const msg = err instanceof Error ? err.message : String(err);
265092
+ const msg = formatUnknownError(err);
265003
265093
  return Response.json(fail(msg), { status });
265004
265094
  }
265005
265095
  }
@@ -1 +1 @@
1
- {"version":3,"file":"coding.d.ts","sourceRoot":"","sources":["../../src/routes/coding.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,IAAI,MAAM,WAAW,CAAC;AAGvC,MAAM,WAAW,UAAU;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAA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C,EAAE,MAAM,EAAE,CAAC;IACtB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,sDAAsD;IACtD,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,0DAA0D;IAC1D,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9B;AAKD,eAAO,MAAM,iBAAiB,oBAAoB,CAAC;AAEnD,sCAAsC;AACtC,wBAAgB,sBAAsB,IAAI,MAAM,CAE/C;AAED,8DAA8D;AAC9D,wBAAgB,sBAAsB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAEvD;AAED;;GAEG;AACH,wBAAsB,aAAa,CACjC,GAAG,EAAE,UAAU,EACf,GAAG,EAAE,IAAI,CAAC,cAAc,EACxB,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC1B,OAAO,CAAC,IAAI,CAAC,CAoDf;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,GAAG,EAAE,UAAU,EACf,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC1B,QAAQ,CA6DV"}
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AASlC,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CAAC,MAAM,CA8H9D"}
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAelC,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CAAC,MAAM,CA8H9D"}
package/dist/utils.d.ts CHANGED
@@ -5,6 +5,11 @@ export interface ApiEnvelope<T = unknown> {
5
5
  }
6
6
  export declare function ok<T>(data: T): ApiEnvelope<T>;
7
7
  export declare function fail(error: string): ApiEnvelope<null>;
8
+ /**
9
+ * Format unknown thrown values into a readable message.
10
+ * Avoids noisy "[object Object]" in logs and API error payloads.
11
+ */
12
+ export declare function formatUnknownError(err: unknown): string;
8
13
  export interface AppState {
9
14
  root: string;
10
15
  volumesRoot: string;
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,WAAW,CAAC,CAAC,GAAG,OAAO;IACtC,EAAE,EAAE,OAAO,CAAC;IACZ,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC;IACf,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB;AAED,wBAAgB,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAE7C;AAED,wBAAgB,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,CAAC,IAAI,CAAC,CAErD;AAED,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CA2B1E;AAUD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAqBlE;AAQD,qBAAa,QAAS,SAAQ,KAAK;IAExB,MAAM,EAAE,MAAM;gBAAd,MAAM,EAAE,MAAM,EACrB,OAAO,EAAE,MAAM;CAIlB;AAED,wBAAsB,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  "name": "@bunny-agent/daemon",
3
- "version": "0.9.29-beta.11",
3
+ "version": "0.9.29-beta.13",
4
4
  "description": "BunnyAgent Daemon - Unified API gateway for sandbox services (file, git, volumes)",
5
5
  "type": "module",
6
6
  "bin": {