bamboo-agents 0.1.12-dev.114.5cb2242 → 0.1.12-dev.115.ee669df

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.12-dev.114.5cb2242
1
+ 0.1.12-dev.115.ee669df
package/dist/index.js CHANGED
@@ -3037,7 +3037,7 @@ var VERSION;
3037
3037
  var init_version = __esm({
3038
3038
  "src/version.ts"() {
3039
3039
  "use strict";
3040
- VERSION = "0.1.12-dev.114.5cb2242";
3040
+ VERSION = "0.1.12-dev.115.ee669df";
3041
3041
  }
3042
3042
  });
3043
3043
 
@@ -7772,12 +7772,17 @@ function emitError(err, opts, exitCode) {
7772
7772
  error: {
7773
7773
  code: err.code,
7774
7774
  message: err.message,
7775
- ...err.hint ? { hint: err.hint } : {}
7775
+ ...err.hint ? { hint: err.hint } : {},
7776
+ ...err.details ? { details: err.details } : {}
7776
7777
  }
7777
7778
  };
7778
7779
  writeStdout(JSON.stringify(envelope, null, 2));
7779
7780
  } else if (!opts.quiet) {
7780
- writeStderr(`bamboo-agents: ${err.message}`);
7781
+ writeStderr(`bamboo-agents: [${err.code}] ${err.message}`);
7782
+ if (typeof err.details?.reason === "string")
7783
+ writeStderr(` Reason: ${err.details.reason}`);
7784
+ if (err.details?.read_back !== void 0)
7785
+ writeStderr(` Read-back: ${JSON.stringify(err.details.read_back)}`);
7781
7786
  if (err.hint) writeStderr(` ${err.hint}`);
7782
7787
  }
7783
7788
  if (exitCode !== void 0) process.exit(exitCode);
@@ -14903,7 +14908,7 @@ function parseEvalManagementOperationData(call, data, selectedOrgId) {
14903
14908
  }
14904
14909
  return parsed;
14905
14910
  }
14906
- var EvalManagementOperationSchema, EvalManagementBindingSchema, EvalManagementCatalogBindingSchema, EvalManagementInputHelpSchema, EVAL_MANAGEMENT_INPUTS, common2, EVAL_MANAGEMENT_BINDINGS, EvalManagementCatalogResponseSchema, EvalManagementCallSchema, EvalManagementScopeSchema, InvestigationPublicationReceiptSchema, InvestigationAuthoringDataSchema, InvestigationControlReceiptSchema, InvestigationDecisionReceiptSchema, InvestigationWaveMemberReceiptSchema, InvestigationWaveCreateReceiptSchema, InvestigationWaveUpdateReceiptSchema, InvestigationWaveScheduleReceiptSchema, EvalManagementCatalogResultSchema, EvalManagementResultSchema;
14911
+ var EvalManagementOperationSchema, EvalManagementBindingSchema, EvalManagementCatalogBindingSchema, EvalManagementInputHelpSchema, EVAL_MANAGEMENT_INPUTS, common2, EVAL_MANAGEMENT_BINDINGS, EvalManagementCatalogResponseSchema, EvalManagementCallSchema, EvalManagementScopeSchema, InvestigationPublicationReceiptSchema, InvestigationAuthoringDataSchema, InvestigationControlReceiptSchema, InvestigationDecisionReceiptSchema, InvestigationWaveMemberReceiptSchema, InvestigationWaveCreateReceiptSchema, InvestigationWaveUpdateReceiptSchema, InvestigationWaveScheduleReceiptSchema, EvalManagementCatalogResultSchema, EvalManagementResultSchema, EvalManagementWriteErrorSchema;
14907
14912
  var init_eval_management = __esm({
14908
14913
  "../../src/lib/api-contracts/cli/eval-management.ts"() {
14909
14914
  init_zod();
@@ -15326,6 +15331,7 @@ var init_eval_management = __esm({
15326
15331
  "retire"
15327
15332
  ]),
15328
15333
  publication_status: external_exports.enum(["pending", "published", "failed"]),
15334
+ publication_error: external_exports.string().nullable().optional(),
15329
15335
  source_sha: external_exports.string().nullable().optional(),
15330
15336
  pr_url: external_exports.string().url().nullable().optional(),
15331
15337
  canceled_pending_count: external_exports.number().int().nonnegative(),
@@ -15392,6 +15398,24 @@ var init_eval_management = __esm({
15392
15398
  data: external_exports.unknown(),
15393
15399
  scope: EvalManagementScopeSchema.optional()
15394
15400
  });
15401
+ EvalManagementWriteErrorSchema = external_exports.object({
15402
+ error: external_exports.object({
15403
+ code: external_exports.string().min(1),
15404
+ message: external_exports.string(),
15405
+ details: external_exports.object({
15406
+ request_id: external_exports.string().optional(),
15407
+ reason: external_exports.enum([
15408
+ "transport_failed",
15409
+ "read_back_unavailable",
15410
+ "postcondition_not_observed"
15411
+ ]).optional(),
15412
+ read_back: external_exports.unknown().optional(),
15413
+ decision_id: external_exports.string().uuid().optional(),
15414
+ judgment_id: external_exports.string().uuid().nullable().optional(),
15415
+ publication_error: external_exports.string().optional()
15416
+ }).passthrough().optional()
15417
+ }).passthrough()
15418
+ });
15395
15419
  }
15396
15420
  });
15397
15421
 
@@ -15457,7 +15481,7 @@ function defaultApiBase(version) {
15457
15481
  function apiBase() {
15458
15482
  return process.env.BAMBOO_BASE_URL ?? defaultApiBase(VERSION);
15459
15483
  }
15460
- async function parseError(res) {
15484
+ async function parseError(res, options = {}) {
15461
15485
  let body = {};
15462
15486
  try {
15463
15487
  body = await res.json();
@@ -15467,10 +15491,10 @@ async function parseError(res) {
15467
15491
  const flatError = typeof body.error === "string" ? body.error : void 0;
15468
15492
  let message = nested?.message ?? body.message ?? flatError ?? `HTTP ${res.status} from ${res.url}`;
15469
15493
  const code = nested?.code ?? flatError;
15470
- if (res.status === 401) {
15494
+ if (res.status === 401 && !options.preserveMessage) {
15471
15495
  message += " \u2014 run `bamboo-agents login` to re-authenticate.";
15472
15496
  }
15473
- return new ApiError(message, res.status, code);
15497
+ return new ApiError(message, res.status, code, nested?.details);
15474
15498
  }
15475
15499
  function userAgent() {
15476
15500
  const nodeVersion = process.versions.node;
@@ -16101,17 +16125,7 @@ async function callEvalManagement(bambooSession, call, orgId) {
16101
16125
  throw unknownEvalMutationOutcome(call, orgId);
16102
16126
  }
16103
16127
  if (!res.ok) {
16104
- const parsedError = await parseError(res);
16105
- const knownPrewriteFailures = /* @__PURE__ */ new Set([
16106
- "scope_validation_failed",
16107
- "investigation_recovery_failed",
16108
- "investigation_read_failed",
16109
- "workspace_unavailable",
16110
- "source_unavailable"
16111
- ]);
16112
- if (isMutation && res.status >= 500 && !knownPrewriteFailures.has(parsedError.errorCode ?? ""))
16113
- throw unknownEvalMutationOutcome(call, orgId);
16114
- throw parsedError;
16128
+ throw await parseError(res, { preserveMessage: true });
16115
16129
  }
16116
16130
  try {
16117
16131
  const json = await res.json();
@@ -16134,7 +16148,6 @@ async function callEvalManagement(bambooSession, call, orgId) {
16134
16148
  return result;
16135
16149
  } catch (error) {
16136
16150
  if (error instanceof ApiError) throw error;
16137
- if (isMutation) throw unknownEvalMutationOutcome(call, orgId);
16138
16151
  throw malformedEvalManagementResponse();
16139
16152
  }
16140
16153
  }
@@ -16142,9 +16155,10 @@ function unknownEvalMutationOutcome(call, orgId) {
16142
16155
  const operation = call.operation;
16143
16156
  const recovery = operation === "investigation.create" ? `Do not blindly retry. Reconcile the selected scope first with: bamboo-agents eval manage investigation.list${orgId ? ` --org ${orgId}` : ""} --input '${JSON.stringify({ brand_id: call.input.brand_id, agent_id: call.input.agent_id, search: call.input.title })}'` : "Read the scoped investigation and repository receipt before retrying.";
16144
16157
  return new ApiError(
16145
- `The ${operation} request was dispatched, but its outcome is unknown. ${recovery}`,
16158
+ `The ${operation} request received no HTTP response, so its outcome is unknown. ${recovery}`,
16146
16159
  502,
16147
- "outcome_unknown"
16160
+ "outcome_unknown",
16161
+ { reason: "transport_failed" }
16148
16162
  );
16149
16163
  }
16150
16164
  function malformedEvalManagementResponse() {
@@ -16238,10 +16252,11 @@ var init_api = __esm({
16238
16252
  DEV_DEFAULT_BASE = "https://dev.withbamboo.com";
16239
16253
  REQUEST_TIMEOUT_MS = 3e4;
16240
16254
  ApiError = class extends Error {
16241
- constructor(message, status, errorCode) {
16255
+ constructor(message, status, errorCode, details) {
16242
16256
  super(message);
16243
16257
  this.status = status;
16244
16258
  this.errorCode = errorCode;
16259
+ this.details = details;
16245
16260
  this.name = "ApiError";
16246
16261
  }
16247
16262
  };
@@ -22263,8 +22278,8 @@ async function requireSession12(opts) {
22263
22278
  if (!session) {
22264
22279
  emitError(
22265
22280
  {
22266
- code: "not_signed_in",
22267
- message: "not signed in.",
22281
+ code: "authentication_required",
22282
+ message: "Run `bamboo-agents login` first.",
22268
22283
  hint: "Run `bamboo-agents login` first."
22269
22284
  },
22270
22285
  opts,
@@ -22367,7 +22382,8 @@ async function runEvalManage(options) {
22367
22382
  {
22368
22383
  code: invalidInput ? "invalid_input" : value.code ?? value.errorCode ?? "management_failed",
22369
22384
  message: value.message ?? "Management operation failed.",
22370
- hint: "Run `bamboo-agents eval operations --json` for supported names and bindings."
22385
+ ...value.details ? { details: value.details } : {},
22386
+ hint: value.status === 401 ? "Run `bamboo-agents login` to re-authenticate." : "Run `bamboo-agents eval operations --json` for supported names and bindings."
22371
22387
  },
22372
22388
  output,
22373
22389
  1
@@ -22378,6 +22394,10 @@ function managementOutcomeLine(result, readOnly) {
22378
22394
  if (readOnly) return `Read ${result.operation}.`;
22379
22395
  const data = result.data && typeof result.data === "object" ? result.data : {};
22380
22396
  const publication = data.publication && typeof data.publication === "object" ? data.publication : null;
22397
+ if (publication?.status === "failed") {
22398
+ const reason = publication.publication_error ?? publication.error;
22399
+ return `Failed to publish ${result.operation}${typeof reason === "string" ? `: ${reason}` : "."}`;
22400
+ }
22381
22401
  if (publication?.status === "published" && publication.projection_status === "projected") {
22382
22402
  return `Published ${result.operation} and projected it into Tests.`;
22383
22403
  }
@@ -22409,6 +22429,8 @@ function managementOutcomeLine(result, readOnly) {
22409
22429
  lifecycle ?? ""
22410
22430
  )) {
22411
22431
  const publicationStatus = data.publication_status;
22432
+ if (publicationStatus === "failed")
22433
+ return `Failed to publish ${result.operation}${typeof data.publication_error === "string" ? `: ${data.publication_error}` : "."}`;
22412
22434
  return publicationStatus === "pending" ? `Recorded ${result.operation}; repository publication is pending.` : `Published ${result.operation} with its decision receipt.`;
22413
22435
  }
22414
22436
  return `Applied ${result.operation}.`;