bamboo-agents 0.1.10-dev.105.540ee26 → 0.1.10-dev.107.e739f23

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.10-dev.105.540ee26
1
+ 0.1.10-dev.107.e739f23
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.10-dev.105.540ee26";
3040
+ VERSION = "0.1.10-dev.107.e739f23";
3041
3041
  }
3042
3042
  });
3043
3043
 
@@ -14730,11 +14730,132 @@ var init_eval_test_sets = __esm({
14730
14730
  }
14731
14731
  });
14732
14732
 
14733
+ // ../../src/lib/api-contracts/investigation-waves.ts
14734
+ var InvestigationWaveMemberSchema, InvestigationWaveCoreSchema, InvestigationWaveSchema, InvestigationWaveRequestMemberSchema, InvestigationWaveRequestSchema, InvestigationWaveDetailSchema;
14735
+ var init_investigation_waves = __esm({
14736
+ "../../src/lib/api-contracts/investigation-waves.ts"() {
14737
+ init_zod();
14738
+ InvestigationWaveMemberSchema = external_exports.object({
14739
+ investigation_id: external_exports.string().uuid(),
14740
+ position: external_exports.number().int().nonnegative(),
14741
+ title: external_exports.string().nullable().optional(),
14742
+ agent_id: external_exports.string().uuid().nullable().optional(),
14743
+ lifecycle_state: external_exports.string().nullable().optional()
14744
+ });
14745
+ InvestigationWaveCoreSchema = external_exports.object({
14746
+ id: external_exports.string().uuid(),
14747
+ org_id: external_exports.string().uuid(),
14748
+ brand_id: external_exports.string().uuid(),
14749
+ name: external_exports.string(),
14750
+ status: external_exports.enum(["active", "retired"]),
14751
+ membership_revision: external_exports.number().int().nonnegative(),
14752
+ not_before: external_exports.string().nullable(),
14753
+ timezone: external_exports.string(),
14754
+ created_at: external_exports.string(),
14755
+ updated_at: external_exports.string()
14756
+ });
14757
+ InvestigationWaveSchema = InvestigationWaveCoreSchema.extend({
14758
+ members: external_exports.array(InvestigationWaveMemberSchema)
14759
+ });
14760
+ InvestigationWaveRequestMemberSchema = external_exports.object({
14761
+ investigation_id: external_exports.string().uuid(),
14762
+ position: external_exports.number().int().nonnegative(),
14763
+ case_ids: external_exports.array(external_exports.string().uuid()),
14764
+ child_key: external_exports.string(),
14765
+ status: external_exports.enum(["pending", "admitted", "blocked"]),
14766
+ run_id: external_exports.string().uuid().nullable(),
14767
+ blocker: external_exports.string().nullable()
14768
+ });
14769
+ InvestigationWaveRequestSchema = external_exports.object({
14770
+ id: external_exports.string().uuid(),
14771
+ membership_revision: external_exports.number().int().nonnegative(),
14772
+ target_agent_id: external_exports.string().uuid().nullable(),
14773
+ request_fingerprint: external_exports.string().nullable(),
14774
+ not_before: external_exports.string().nullable(),
14775
+ status: external_exports.enum(["pending", "partial", "completed", "blocked", "failed"]),
14776
+ created_at: external_exports.string(),
14777
+ members: external_exports.array(InvestigationWaveRequestMemberSchema)
14778
+ });
14779
+ InvestigationWaveDetailSchema = InvestigationWaveSchema.extend({
14780
+ requests: external_exports.array(InvestigationWaveRequestSchema)
14781
+ });
14782
+ }
14783
+ });
14784
+
14733
14785
  // ../../src/lib/api-contracts/cli/eval-management.ts
14734
- var EvalManagementOperationSchema, EvalManagementBindingSchema, EvalManagementInputHelpSchema, EVAL_MANAGEMENT_INPUTS, common2, EVAL_MANAGEMENT_BINDINGS, EvalManagementCatalogResponseSchema, EvalManagementCallSchema, EvalManagementScopeSchema, InvestigationPublicationReceiptSchema, InvestigationAuthoringDataSchema, EvalManagementCatalogResultSchema, EvalManagementResultSchema;
14786
+ function parseEvalManagementOperationData(call, data, selectedOrgId) {
14787
+ const operation = call.operation;
14788
+ let parsed;
14789
+ if (operation === "investigation.create" || operation === "investigation.update")
14790
+ parsed = InvestigationAuthoringDataSchema.parse(data);
14791
+ else if ([
14792
+ "investigation.hold",
14793
+ "investigation.resume",
14794
+ "investigation.cancel"
14795
+ ].includes(operation))
14796
+ parsed = InvestigationControlReceiptSchema.parse(data);
14797
+ else if ([
14798
+ "investigation.conclude_claim",
14799
+ "investigation.close",
14800
+ "investigation.reopen",
14801
+ "investigation.retire"
14802
+ ].includes(operation))
14803
+ parsed = InvestigationDecisionReceiptSchema.parse(data);
14804
+ else if (operation === "wave.create")
14805
+ parsed = InvestigationWaveCreateReceiptSchema.parse(data);
14806
+ else if (operation === "wave.update")
14807
+ parsed = InvestigationWaveUpdateReceiptSchema.parse(data);
14808
+ else if (operation === "wave.schedule")
14809
+ parsed = InvestigationWaveScheduleReceiptSchema.parse(data);
14810
+ else return data;
14811
+ const mismatch = (label) => {
14812
+ throw new Error(`eval_management_receipt_mismatch:${label}`);
14813
+ };
14814
+ const sameId = (left, right) => left.toLowerCase() === right.toLowerCase();
14815
+ const inputId = typeof call.input.id === "string" ? call.input.id : void 0;
14816
+ const inputBrandId = typeof call.input.brand_id === "string" ? call.input.brand_id : void 0;
14817
+ const action = operation.split(".")[1];
14818
+ if (operation === "investigation.update") {
14819
+ const receipt = parsed;
14820
+ if (inputId && (!receipt.investigation_id || !sameId(receipt.investigation_id, inputId)))
14821
+ mismatch("investigation_id");
14822
+ } else if (operation === "investigation.hold" || operation === "investigation.resume" || operation === "investigation.cancel") {
14823
+ const receipt = parsed;
14824
+ if (receipt.operation !== action) mismatch("operation");
14825
+ if (inputId && !sameId(receipt.investigation_id, inputId))
14826
+ mismatch("investigation_id");
14827
+ } else if (operation === "investigation.conclude_claim" || operation === "investigation.close" || operation === "investigation.reopen" || operation === "investigation.retire") {
14828
+ const receipt = parsed;
14829
+ if (receipt.operation !== action) mismatch("operation");
14830
+ if (inputId && !sameId(receipt.investigation_id, inputId))
14831
+ mismatch("investigation_id");
14832
+ } else if (operation === "wave.create") {
14833
+ const receipt = parsed;
14834
+ if (selectedOrgId && !sameId(receipt.wave.org_id, selectedOrgId))
14835
+ mismatch("org_id");
14836
+ if (inputBrandId && !sameId(receipt.wave.brand_id, inputBrandId))
14837
+ mismatch("brand_id");
14838
+ } else if (operation === "wave.update") {
14839
+ const receipt = parsed;
14840
+ if (inputId && !sameId(receipt.wave.id, inputId)) mismatch("wave_id");
14841
+ if (receipt.wave.org_id && selectedOrgId && !sameId(receipt.wave.org_id, selectedOrgId))
14842
+ mismatch("org_id");
14843
+ if (receipt.wave.brand_id && inputBrandId && !sameId(receipt.wave.brand_id, inputBrandId))
14844
+ mismatch("brand_id");
14845
+ } else if (operation === "wave.schedule") {
14846
+ const receipt = parsed;
14847
+ if (inputId && !sameId(receipt.wave_id, inputId)) mismatch("wave_id");
14848
+ const expectedRevision = call.input.expected_membership_revision;
14849
+ if (typeof expectedRevision === "number" && receipt.membership_revision !== expectedRevision)
14850
+ mismatch("membership_revision");
14851
+ }
14852
+ return parsed;
14853
+ }
14854
+ var EvalManagementOperationSchema, EvalManagementBindingSchema, EvalManagementInputHelpSchema, EVAL_MANAGEMENT_INPUTS, common2, EVAL_MANAGEMENT_BINDINGS, EvalManagementCatalogResponseSchema, EvalManagementCallSchema, EvalManagementScopeSchema, InvestigationPublicationReceiptSchema, InvestigationAuthoringDataSchema, InvestigationControlReceiptSchema, InvestigationDecisionReceiptSchema, InvestigationWaveMemberReceiptSchema, InvestigationWaveCreateReceiptSchema, InvestigationWaveUpdateReceiptSchema, InvestigationWaveScheduleReceiptSchema, EvalManagementCatalogResultSchema, EvalManagementResultSchema;
14735
14855
  var init_eval_management = __esm({
14736
14856
  "../../src/lib/api-contracts/cli/eval-management.ts"() {
14737
14857
  init_zod();
14858
+ init_investigation_waves();
14738
14859
  EvalManagementOperationSchema = external_exports.enum([
14739
14860
  "investigation.list",
14740
14861
  "investigation.get",
@@ -14861,7 +14982,13 @@ var init_eval_management = __esm({
14861
14982
  ]
14862
14983
  },
14863
14984
  "wave.schedule": {
14864
- required: ["id", "brand_id", "agent_id", "idempotency_key"],
14985
+ required: [
14986
+ "id",
14987
+ "brand_id",
14988
+ "agent_id",
14989
+ "expected_membership_revision",
14990
+ "idempotency_key"
14991
+ ],
14865
14992
  optional: ["not_before"]
14866
14993
  }
14867
14994
  };
@@ -14922,7 +15049,9 @@ var init_eval_management = __esm({
14922
15049
  method: "POST",
14923
15050
  path: "/api/v1/eval/investigations/{id}/control",
14924
15051
  side_effect: "execution gate becomes held",
14925
- receipt: "control receipt and resulting revision"
15052
+ receipt: "control receipt and resulting revision",
15053
+ minimum_cli_version: "0.1.11",
15054
+ explicit_org_scope: true
14926
15055
  },
14927
15056
  {
14928
15057
  ...common2,
@@ -14931,7 +15060,9 @@ var init_eval_management = __esm({
14931
15060
  method: "POST",
14932
15061
  path: "/api/v1/eval/investigations/{id}/control",
14933
15062
  side_effect: "execution gate becomes active",
14934
- receipt: "control receipt and resulting revision"
15063
+ receipt: "control receipt and resulting revision",
15064
+ minimum_cli_version: "0.1.11",
15065
+ explicit_org_scope: true
14935
15066
  },
14936
15067
  {
14937
15068
  ...common2,
@@ -14940,7 +15071,9 @@ var init_eval_management = __esm({
14940
15071
  method: "POST",
14941
15072
  path: "/api/v1/eval/investigations/{id}/control",
14942
15073
  side_effect: "pending queue items are canceled",
14943
- receipt: "control receipt with affected count and served ids"
15074
+ receipt: "control receipt with affected count and served ids",
15075
+ minimum_cli_version: "0.1.11",
15076
+ explicit_org_scope: true
14944
15077
  },
14945
15078
  {
14946
15079
  ...common2,
@@ -14949,7 +15082,9 @@ var init_eval_management = __esm({
14949
15082
  method: "POST",
14950
15083
  path: "/api/v1/eval/investigations/{id}/decisions",
14951
15084
  side_effect: "append-only judgment plus repo publication",
14952
- receipt: "decision, judgment, publication, and evidence references"
15085
+ receipt: "decision, judgment, publication, and evidence references",
15086
+ minimum_cli_version: "0.1.11",
15087
+ explicit_org_scope: true
14953
15088
  },
14954
15089
  {
14955
15090
  ...common2,
@@ -14958,7 +15093,9 @@ var init_eval_management = __esm({
14958
15093
  method: "POST",
14959
15094
  path: "/api/v1/eval/investigations/{id}/decisions",
14960
15095
  side_effect: "repo lifecycle closes and pending work is canceled",
14961
- receipt: "decision, publication, cancellation count, and served ids"
15096
+ receipt: "decision, publication, cancellation count, and served ids",
15097
+ minimum_cli_version: "0.1.11",
15098
+ explicit_org_scope: true
14962
15099
  },
14963
15100
  {
14964
15101
  ...common2,
@@ -14967,7 +15104,9 @@ var init_eval_management = __esm({
14967
15104
  method: "POST",
14968
15105
  path: "/api/v1/eval/investigations/{id}/decisions",
14969
15106
  side_effect: "repo lifecycle opens and held execution resumes",
14970
- receipt: "decision and publication receipt"
15107
+ receipt: "decision and publication receipt",
15108
+ minimum_cli_version: "0.1.11",
15109
+ explicit_org_scope: true
14971
15110
  },
14972
15111
  {
14973
15112
  ...common2,
@@ -14976,7 +15115,9 @@ var init_eval_management = __esm({
14976
15115
  method: "POST",
14977
15116
  path: "/api/v1/eval/investigations/{id}/decisions",
14978
15117
  side_effect: "repo lifecycle retires and pending work is canceled",
14979
- receipt: "decision, publication, cancellation count, and served ids"
15118
+ receipt: "decision, publication, cancellation count, and served ids",
15119
+ minimum_cli_version: "0.1.11",
15120
+ explicit_org_scope: true
14980
15121
  },
14981
15122
  {
14982
15123
  ...common2,
@@ -15005,7 +15146,9 @@ var init_eval_management = __esm({
15005
15146
  method: "POST",
15006
15147
  path: "/api/v1/eval/waves",
15007
15148
  side_effect: "operational wave row",
15008
- receipt: "wave id and membership revision"
15149
+ receipt: "wave id and membership revision",
15150
+ minimum_cli_version: "0.1.11",
15151
+ explicit_org_scope: true
15009
15152
  },
15010
15153
  {
15011
15154
  ...common2,
@@ -15014,7 +15157,9 @@ var init_eval_management = __esm({
15014
15157
  method: "PATCH",
15015
15158
  path: "/api/v1/eval/waves/{id}",
15016
15159
  side_effect: "wave metadata or membership revision",
15017
- receipt: "wave and resulting membership revision"
15160
+ receipt: "wave and resulting membership revision",
15161
+ minimum_cli_version: "0.1.11",
15162
+ explicit_org_scope: true
15018
15163
  },
15019
15164
  {
15020
15165
  ...common2,
@@ -15023,7 +15168,9 @@ var init_eval_management = __esm({
15023
15168
  method: "POST",
15024
15169
  path: "/api/v1/eval/waves/{id}/schedule",
15025
15170
  side_effect: "durable run and queue admission",
15026
- receipt: "wave request and per-investigation run receipts"
15171
+ receipt: "wave request and per-investigation run receipts",
15172
+ minimum_cli_version: "0.1.11",
15173
+ explicit_org_scope: true
15027
15174
  }
15028
15175
  ];
15029
15176
  EvalManagementCatalogResponseSchema = external_exports.object({
@@ -15082,6 +15229,83 @@ var init_eval_management = __esm({
15082
15229
  source_path: external_exports.string().min(1),
15083
15230
  publication: InvestigationPublicationReceiptSchema
15084
15231
  }).passthrough();
15232
+ InvestigationControlReceiptSchema = external_exports.object({
15233
+ id: external_exports.string().uuid(),
15234
+ receipt_version: external_exports.literal(1),
15235
+ investigation_id: external_exports.string().uuid(),
15236
+ operation: external_exports.enum(["hold", "resume", "cancel"]),
15237
+ expected_revision: external_exports.number().int().nonnegative(),
15238
+ resulting_gate_state: external_exports.enum(["active", "held"]),
15239
+ resulting_revision: external_exports.number().int().nonnegative(),
15240
+ affected_pending_count: external_exports.number().int().nonnegative(),
15241
+ served_ids: external_exports.array(external_exports.string().uuid()),
15242
+ terminal_count: external_exports.number().int().nonnegative(),
15243
+ idempotent: external_exports.boolean()
15244
+ }).passthrough();
15245
+ InvestigationDecisionReceiptSchema = external_exports.object({
15246
+ id: external_exports.string().uuid(),
15247
+ judgment_id: external_exports.string().uuid(),
15248
+ investigation_id: external_exports.string().uuid(),
15249
+ operation: external_exports.enum(["conclude_claim", "close", "reopen", "retire"]),
15250
+ publication_status: external_exports.enum(["pending", "published", "failed"]),
15251
+ source_sha: external_exports.string().nullable().optional(),
15252
+ pr_url: external_exports.string().url().nullable().optional(),
15253
+ canceled_pending_count: external_exports.number().int().nonnegative(),
15254
+ served_ids: external_exports.array(external_exports.string().uuid()),
15255
+ actor_user_id: external_exports.string().uuid()
15256
+ }).passthrough();
15257
+ InvestigationWaveMemberReceiptSchema = external_exports.object({
15258
+ investigation_id: external_exports.string().uuid(),
15259
+ position: external_exports.number().int().nonnegative().optional(),
15260
+ case_ids: external_exports.array(external_exports.string().uuid()).optional(),
15261
+ child_key: external_exports.string().optional(),
15262
+ status: external_exports.enum(["pending", "admitted", "blocked"]).optional(),
15263
+ run_id: external_exports.string().uuid().nullable().optional(),
15264
+ blocker: external_exports.string().nullable().optional()
15265
+ });
15266
+ InvestigationWaveCreateReceiptSchema = external_exports.object({
15267
+ wave: InvestigationWaveCoreSchema.omit({
15268
+ created_at: true,
15269
+ updated_at: true
15270
+ }).passthrough()
15271
+ });
15272
+ InvestigationWaveUpdateReceiptSchema = external_exports.object({
15273
+ wave: InvestigationWaveCoreSchema.pick({
15274
+ id: true,
15275
+ org_id: true,
15276
+ brand_id: true,
15277
+ name: true,
15278
+ status: true,
15279
+ membership_revision: true,
15280
+ not_before: true,
15281
+ timezone: true
15282
+ }).partial({
15283
+ org_id: true,
15284
+ brand_id: true,
15285
+ name: true,
15286
+ status: true,
15287
+ not_before: true,
15288
+ timezone: true
15289
+ }).extend({ members: external_exports.array(InvestigationWaveMemberSchema) })
15290
+ });
15291
+ InvestigationWaveScheduleReceiptSchema = external_exports.object({
15292
+ request_id: external_exports.string().uuid(),
15293
+ wave_id: external_exports.string().uuid(),
15294
+ membership_revision: external_exports.number().int().nonnegative(),
15295
+ not_before: external_exports.string().nullable(),
15296
+ request_fingerprint: external_exports.string().min(1),
15297
+ status: external_exports.enum(["pending", "partial", "completed", "blocked", "failed"]),
15298
+ already_scheduled: external_exports.boolean(),
15299
+ members: external_exports.array(
15300
+ InvestigationWaveMemberReceiptSchema.extend({
15301
+ case_ids: external_exports.array(external_exports.string().uuid()),
15302
+ child_key: external_exports.string(),
15303
+ status: external_exports.enum(["pending", "admitted", "blocked"]),
15304
+ run_id: external_exports.string().uuid().nullable(),
15305
+ blocker: external_exports.string().nullable()
15306
+ })
15307
+ )
15308
+ });
15085
15309
  EvalManagementCatalogResultSchema = EvalManagementCatalogResponseSchema.extend({
15086
15310
  scope: EvalManagementScopeSchema.optional()
15087
15311
  });
@@ -15818,10 +16042,16 @@ async function callEvalManagement(bambooSession, call, orgId) {
15818
16042
  data: Object.keys(siblings).length > 0 ? { data, ...siblings } : data,
15819
16043
  scope: meta
15820
16044
  });
15821
- if (call.operation === "investigation.create" || call.operation === "investigation.update") {
15822
- result.data = InvestigationAuthoringDataSchema.parse(result.data);
15823
- }
16045
+ result.data = parseEvalManagementOperationData(call, result.data, orgId);
15824
16046
  assertExplicitOrgReceipt(result.scope, orgId);
16047
+ if (isMutation) {
16048
+ const expectedBrand = call.input.brand_id;
16049
+ const expectedAgent = call.input.agent_id;
16050
+ if (typeof expectedBrand === "string" && result.scope?.brand_id?.toLowerCase() !== expectedBrand.toLowerCase())
16051
+ throw new Error("eval_management_scope_mismatch:brand_id");
16052
+ if (typeof expectedAgent === "string" && result.scope?.agent_id?.toLowerCase() !== expectedAgent.toLowerCase())
16053
+ throw new Error("eval_management_scope_mismatch:agent_id");
16054
+ }
15825
16055
  return result;
15826
16056
  } catch (error) {
15827
16057
  if (error instanceof ApiError) throw error;
@@ -22084,6 +22314,22 @@ function managementOutcomeLine(result, readOnly) {
22084
22314
  if (publication?.status === "noop") {
22085
22315
  return `No change for ${result.operation}; the existing publication is current.`;
22086
22316
  }
22317
+ if (result.operation === "wave.schedule") {
22318
+ const status = typeof data.status === "string" ? data.status : "recorded";
22319
+ return `Scheduled the investigation wave; admission status is ${status}.`;
22320
+ }
22321
+ if (result.operation === "wave.create")
22322
+ return "Created the investigation wave without scheduling it.";
22323
+ if (result.operation === "wave.update")
22324
+ return "Updated the investigation wave without scheduling it.";
22325
+ const lifecycle = result.operation.split(".")[1];
22326
+ if (["hold", "resume", "cancel"].includes(lifecycle ?? "")) {
22327
+ return `${lifecycle === "hold" ? "Held" : lifecycle === "resume" ? "Resumed" : "Canceled pending work for"} the investigation.`;
22328
+ }
22329
+ if (["conclude_claim", "close", "reopen", "retire"].includes(lifecycle ?? "")) {
22330
+ const publicationStatus = data.publication_status;
22331
+ return publicationStatus === "pending" ? `Recorded ${result.operation}; repository publication is pending.` : `Published ${result.operation} with its decision receipt.`;
22332
+ }
22087
22333
  return `Applied ${result.operation}.`;
22088
22334
  }
22089
22335
  var init_eval_management2 = __esm({