bamboo-agents 0.1.12-dev.112.7287623 → 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.112.7287623
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.112.7287623";
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);
@@ -12785,7 +12790,7 @@ function inboxSourceVersionsMatch(current, reviewed) {
12785
12790
  const canonicalUtc = (value) => value.replace(/\+00:00$/i, "Z");
12786
12791
  return canonicalUtc(current) === canonicalUtc(reviewed);
12787
12792
  }
12788
- var InboxUtcTimestampSchema, InboxOperationSchema, InboxManageOperationSchema, InboxOperationBindingSchema, common, INBOX_MANAGEMENT_BINDINGS, INBOX_EXISTING_COMMAND_BINDINGS, changeCommon, CHANGE_MANAGEMENT_BINDINGS, opportunityCommon, OPPORTUNITY_MANAGEMENT_BINDINGS, annotationCommon, ANNOTATION_MANAGEMENT_BINDINGS, lifecycleMutationInputs, FDE_ACTION_MANAGEMENT_BINDINGS, GRAPH_RECOVERY_MANAGEMENT_BINDINGS, InboxManagementCatalogResponseSchema, InboxOrganizationsResponseSchema, OpportunityDecisionInputBaseSchema, InboxManagementCallSchema, InboxWorkItemSchema, InboxListReceiptSchema, InboxGetReceiptSchema, InboxEnvelopeBaseSchema, UnknownMutationReceiptSchema, ChangeReadBackSchema, OpportunitySnapshotSchema, OpportunityUnknownReceiptSchema, OpportunityCommandSchema, FdeActionSnapshotSchema, GraphRecoverySnapshotSchema, LifecycleUnknownReceiptSchema, AnnotationSnapshotSchema, AnnotationUnknownReceiptSchema, InboxOperationEnvelopeSchema;
12793
+ var InboxUtcTimestampSchema, InboxOperationSchema, InboxManageOperationSchema, InboxOperationBindingSchema, common, INBOX_MANAGEMENT_BINDINGS, INBOX_EXISTING_COMMAND_BINDINGS, changeCommon, CHANGE_MANAGEMENT_BINDINGS, opportunityCommon, graphDecisionErrorCodes, OPPORTUNITY_MANAGEMENT_BINDINGS, annotationCommon, ANNOTATION_MANAGEMENT_BINDINGS, lifecycleMutationInputs, FDE_ACTION_MANAGEMENT_BINDINGS, GRAPH_RECOVERY_MANAGEMENT_BINDINGS, InboxManagementCatalogResponseSchema, InboxOrganizationsResponseSchema, OpportunityDecisionInputBaseSchema, InboxManagementCallSchema, InboxWorkItemSchema, InboxListReceiptSchema, InboxGetReceiptSchema, InboxEnvelopeBaseSchema, UnknownMutationReceiptSchema, ChangeReadBackSchema, OpportunitySnapshotSchema, OpportunityUnknownReceiptSchema, OpportunityCommandSchema, FdeActionSnapshotSchema, GraphRecoverySnapshotSchema, LifecycleUnknownReceiptSchema, AnnotationSnapshotSchema, AnnotationUnknownReceiptSchema, InboxOperationEnvelopeSchema;
12789
12794
  var init_inbox_management = __esm({
12790
12795
  "../../src/lib/api-contracts/cli/inbox-management.ts"() {
12791
12796
  init_zod();
@@ -12943,10 +12948,20 @@ var init_inbox_management = __esm({
12943
12948
  "brain_opportunity_stale",
12944
12949
  "brain_opportunity_assignment_target_invalid",
12945
12950
  "missing_assignment",
12951
+ "missing_proposed_assignee",
12946
12952
  "wording_mismatch",
12947
12953
  "recipient_mismatch",
12948
12954
  "proposal_failed",
12949
12955
  "graph_decision_conflict",
12956
+ "opportunity_not_decidable",
12957
+ "opportunity_applied_receipt_unavailable",
12958
+ "opportunity_preflight_failed",
12959
+ "graph_decision_reason_required",
12960
+ "graph_decision_assignee_required",
12961
+ "graph_decision_assignee_invalid",
12962
+ "graph_decision_invalid",
12963
+ "graph_decision_command_id_required",
12964
+ "graph_decision_command_id_too_long",
12950
12965
  "stale_action",
12951
12966
  "invalid_transition",
12952
12967
  "stale_transition",
@@ -13279,6 +13294,18 @@ var init_inbox_management = __esm({
13279
13294
  "malformed_response"
13280
13295
  ]
13281
13296
  };
13297
+ graphDecisionErrorCodes = [
13298
+ "opportunity_not_decidable",
13299
+ "opportunity_applied_receipt_unavailable",
13300
+ "opportunity_preflight_failed",
13301
+ "missing_proposed_assignee",
13302
+ "graph_decision_reason_required",
13303
+ "graph_decision_assignee_required",
13304
+ "graph_decision_assignee_invalid",
13305
+ "graph_decision_invalid",
13306
+ "graph_decision_command_id_required",
13307
+ "graph_decision_command_id_too_long"
13308
+ ];
13282
13309
  OPPORTUNITY_MANAGEMENT_BINDINGS = [
13283
13310
  {
13284
13311
  ...opportunityCommon,
@@ -13343,7 +13370,8 @@ var init_inbox_management = __esm({
13343
13370
  "missing_assignment",
13344
13371
  "wording_mismatch",
13345
13372
  "recipient_mismatch",
13346
- "graph_decision_conflict"
13373
+ "graph_decision_conflict",
13374
+ ...graphDecisionErrorCodes
13347
13375
  ]
13348
13376
  },
13349
13377
  ...["reject", "defer", "annotate", "block"].map((decision) => ({
@@ -13370,7 +13398,8 @@ var init_inbox_management = __esm({
13370
13398
  error_codes: [
13371
13399
  ...opportunityCommon.error_codes,
13372
13400
  "brain_opportunity_stale",
13373
- "graph_decision_conflict"
13401
+ "graph_decision_conflict",
13402
+ ...graphDecisionErrorCodes
13374
13403
  ]
13375
13404
  })),
13376
13405
  {
@@ -14018,7 +14047,9 @@ var init_inbox_management = __esm({
14018
14047
  OpportunityUnknownReceiptSchema = external_exports.object({
14019
14048
  state: external_exports.literal("unknown"),
14020
14049
  command_id: external_exports.string(),
14021
- instruction: external_exports.literal("inspect_source_before_retry")
14050
+ instruction: external_exports.literal("inspect_source_before_retry"),
14051
+ reason: external_exports.enum(["read_back_unavailable", "postcondition_not_observed", "command_receipt_unavailable"]),
14052
+ read_back: OpportunitySnapshotSchema.optional()
14022
14053
  });
14023
14054
  OpportunityCommandSchema = external_exports.union([
14024
14055
  external_exports.object({
@@ -14877,7 +14908,7 @@ function parseEvalManagementOperationData(call, data, selectedOrgId) {
14877
14908
  }
14878
14909
  return parsed;
14879
14910
  }
14880
- 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;
14881
14912
  var init_eval_management = __esm({
14882
14913
  "../../src/lib/api-contracts/cli/eval-management.ts"() {
14883
14914
  init_zod();
@@ -15129,7 +15160,10 @@ var init_eval_management = __esm({
15129
15160
  path: "/api/v1/eval/investigations/{id}/decisions",
15130
15161
  side_effect: "append-only FDE judgment plus repo and Tests lifecycle update",
15131
15162
  receipt: "decision, judgment, publication, and projection receipt",
15132
- minimum_cli_version: "0.1.11",
15163
+ // 0.1.12 is the first stable whose catalog parser tolerates this
15164
+ // additive operation; every earlier stable rejects the whole catalog
15165
+ // once it appears (BAM-5292), so it must not claim 0.1.11.
15166
+ minimum_cli_version: "0.1.12",
15133
15167
  explicit_org_scope: true
15134
15168
  },
15135
15169
  {
@@ -15297,6 +15331,7 @@ var init_eval_management = __esm({
15297
15331
  "retire"
15298
15332
  ]),
15299
15333
  publication_status: external_exports.enum(["pending", "published", "failed"]),
15334
+ publication_error: external_exports.string().nullable().optional(),
15300
15335
  source_sha: external_exports.string().nullable().optional(),
15301
15336
  pr_url: external_exports.string().url().nullable().optional(),
15302
15337
  canceled_pending_count: external_exports.number().int().nonnegative(),
@@ -15363,6 +15398,24 @@ var init_eval_management = __esm({
15363
15398
  data: external_exports.unknown(),
15364
15399
  scope: EvalManagementScopeSchema.optional()
15365
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
+ });
15366
15419
  }
15367
15420
  });
15368
15421
 
@@ -15428,7 +15481,7 @@ function defaultApiBase(version) {
15428
15481
  function apiBase() {
15429
15482
  return process.env.BAMBOO_BASE_URL ?? defaultApiBase(VERSION);
15430
15483
  }
15431
- async function parseError(res) {
15484
+ async function parseError(res, options = {}) {
15432
15485
  let body = {};
15433
15486
  try {
15434
15487
  body = await res.json();
@@ -15438,10 +15491,10 @@ async function parseError(res) {
15438
15491
  const flatError = typeof body.error === "string" ? body.error : void 0;
15439
15492
  let message = nested?.message ?? body.message ?? flatError ?? `HTTP ${res.status} from ${res.url}`;
15440
15493
  const code = nested?.code ?? flatError;
15441
- if (res.status === 401) {
15494
+ if (res.status === 401 && !options.preserveMessage) {
15442
15495
  message += " \u2014 run `bamboo-agents login` to re-authenticate.";
15443
15496
  }
15444
- return new ApiError(message, res.status, code);
15497
+ return new ApiError(message, res.status, code, nested?.details);
15445
15498
  }
15446
15499
  function userAgent() {
15447
15500
  const nodeVersion = process.versions.node;
@@ -16072,17 +16125,7 @@ async function callEvalManagement(bambooSession, call, orgId) {
16072
16125
  throw unknownEvalMutationOutcome(call, orgId);
16073
16126
  }
16074
16127
  if (!res.ok) {
16075
- const parsedError = await parseError(res);
16076
- const knownPrewriteFailures = /* @__PURE__ */ new Set([
16077
- "scope_validation_failed",
16078
- "investigation_recovery_failed",
16079
- "investigation_read_failed",
16080
- "workspace_unavailable",
16081
- "source_unavailable"
16082
- ]);
16083
- if (isMutation && res.status >= 500 && !knownPrewriteFailures.has(parsedError.errorCode ?? ""))
16084
- throw unknownEvalMutationOutcome(call, orgId);
16085
- throw parsedError;
16128
+ throw await parseError(res, { preserveMessage: true });
16086
16129
  }
16087
16130
  try {
16088
16131
  const json = await res.json();
@@ -16105,7 +16148,6 @@ async function callEvalManagement(bambooSession, call, orgId) {
16105
16148
  return result;
16106
16149
  } catch (error) {
16107
16150
  if (error instanceof ApiError) throw error;
16108
- if (isMutation) throw unknownEvalMutationOutcome(call, orgId);
16109
16151
  throw malformedEvalManagementResponse();
16110
16152
  }
16111
16153
  }
@@ -16113,9 +16155,10 @@ function unknownEvalMutationOutcome(call, orgId) {
16113
16155
  const operation = call.operation;
16114
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.";
16115
16157
  return new ApiError(
16116
- `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}`,
16117
16159
  502,
16118
- "outcome_unknown"
16160
+ "outcome_unknown",
16161
+ { reason: "transport_failed" }
16119
16162
  );
16120
16163
  }
16121
16164
  function malformedEvalManagementResponse() {
@@ -16209,10 +16252,11 @@ var init_api = __esm({
16209
16252
  DEV_DEFAULT_BASE = "https://dev.withbamboo.com";
16210
16253
  REQUEST_TIMEOUT_MS = 3e4;
16211
16254
  ApiError = class extends Error {
16212
- constructor(message, status, errorCode) {
16255
+ constructor(message, status, errorCode, details) {
16213
16256
  super(message);
16214
16257
  this.status = status;
16215
16258
  this.errorCode = errorCode;
16259
+ this.details = details;
16216
16260
  this.name = "ApiError";
16217
16261
  }
16218
16262
  };
@@ -22234,8 +22278,8 @@ async function requireSession12(opts) {
22234
22278
  if (!session) {
22235
22279
  emitError(
22236
22280
  {
22237
- code: "not_signed_in",
22238
- message: "not signed in.",
22281
+ code: "authentication_required",
22282
+ message: "Run `bamboo-agents login` first.",
22239
22283
  hint: "Run `bamboo-agents login` first."
22240
22284
  },
22241
22285
  opts,
@@ -22338,7 +22382,8 @@ async function runEvalManage(options) {
22338
22382
  {
22339
22383
  code: invalidInput ? "invalid_input" : value.code ?? value.errorCode ?? "management_failed",
22340
22384
  message: value.message ?? "Management operation failed.",
22341
- 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."
22342
22387
  },
22343
22388
  output,
22344
22389
  1
@@ -22349,6 +22394,10 @@ function managementOutcomeLine(result, readOnly) {
22349
22394
  if (readOnly) return `Read ${result.operation}.`;
22350
22395
  const data = result.data && typeof result.data === "object" ? result.data : {};
22351
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
+ }
22352
22401
  if (publication?.status === "published" && publication.projection_status === "projected") {
22353
22402
  return `Published ${result.operation} and projected it into Tests.`;
22354
22403
  }
@@ -22380,6 +22429,8 @@ function managementOutcomeLine(result, readOnly) {
22380
22429
  lifecycle ?? ""
22381
22430
  )) {
22382
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}` : "."}`;
22383
22434
  return publicationStatus === "pending" ? `Recorded ${result.operation}; repository publication is pending.` : `Published ${result.operation} with its decision receipt.`;
22384
22435
  }
22385
22436
  return `Applied ${result.operation}.`;