bamboo-agents 0.1.10 → 0.1.11-dev.108.de3eba8
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 +1 -1
- package/dist/index.js +665 -106
- package/dist/index.js.map +4 -4
- package/package.json +1 -1
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.
|
|
3040
|
+
VERSION = "0.1.11-dev.108.de3eba8";
|
|
3041
3041
|
}
|
|
3042
3042
|
});
|
|
3043
3043
|
|
|
@@ -7436,7 +7436,9 @@ var init_agents = __esm({
|
|
|
7436
7436
|
/** ISO timestamp when paused, else null. */
|
|
7437
7437
|
paused_at: external_exports.string().nullable().optional(),
|
|
7438
7438
|
/** Lite derived state (active/paused/inactive) — see CliAgentLifecycleStateSchema. */
|
|
7439
|
-
state: external_exports.enum(["active", "paused", "inactive"]).optional()
|
|
7439
|
+
state: external_exports.enum(["active", "paused", "inactive"]).optional(),
|
|
7440
|
+
/** Brands this agent is assigned to; additive for older CLI servers. */
|
|
7441
|
+
brand_ids: external_exports.array(external_exports.string().uuid()).optional()
|
|
7440
7442
|
});
|
|
7441
7443
|
CliTierCapSchema = external_exports.object({
|
|
7442
7444
|
limit: external_exports.number().int(),
|
|
@@ -14728,11 +14730,132 @@ var init_eval_test_sets = __esm({
|
|
|
14728
14730
|
}
|
|
14729
14731
|
});
|
|
14730
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
|
+
|
|
14731
14785
|
// ../../src/lib/api-contracts/cli/eval-management.ts
|
|
14732
|
-
|
|
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;
|
|
14733
14855
|
var init_eval_management = __esm({
|
|
14734
14856
|
"../../src/lib/api-contracts/cli/eval-management.ts"() {
|
|
14735
14857
|
init_zod();
|
|
14858
|
+
init_investigation_waves();
|
|
14736
14859
|
EvalManagementOperationSchema = external_exports.enum([
|
|
14737
14860
|
"investigation.list",
|
|
14738
14861
|
"investigation.get",
|
|
@@ -14761,7 +14884,8 @@ var init_eval_management = __esm({
|
|
|
14761
14884
|
authority: external_exports.string(),
|
|
14762
14885
|
side_effect: external_exports.string(),
|
|
14763
14886
|
receipt: external_exports.string(),
|
|
14764
|
-
minimum_cli_version: external_exports.string()
|
|
14887
|
+
minimum_cli_version: external_exports.string(),
|
|
14888
|
+
explicit_org_scope: external_exports.boolean()
|
|
14765
14889
|
});
|
|
14766
14890
|
EvalManagementInputHelpSchema = external_exports.object({
|
|
14767
14891
|
required: external_exports.array(external_exports.string()),
|
|
@@ -14858,7 +14982,13 @@ var init_eval_management = __esm({
|
|
|
14858
14982
|
]
|
|
14859
14983
|
},
|
|
14860
14984
|
"wave.schedule": {
|
|
14861
|
-
required: [
|
|
14985
|
+
required: [
|
|
14986
|
+
"id",
|
|
14987
|
+
"brand_id",
|
|
14988
|
+
"agent_id",
|
|
14989
|
+
"expected_membership_revision",
|
|
14990
|
+
"idempotency_key"
|
|
14991
|
+
],
|
|
14862
14992
|
optional: ["not_before"]
|
|
14863
14993
|
}
|
|
14864
14994
|
};
|
|
@@ -14866,7 +14996,8 @@ var init_eval_management = __esm({
|
|
|
14866
14996
|
cli_command: "bamboo-agents eval manage",
|
|
14867
14997
|
supported_runtimes: ["cli", "api"],
|
|
14868
14998
|
authority: "Authenticated human or attributed agent with access to the target brand",
|
|
14869
|
-
minimum_cli_version: "0.1.8"
|
|
14999
|
+
minimum_cli_version: "0.1.8",
|
|
15000
|
+
explicit_org_scope: false
|
|
14870
15001
|
};
|
|
14871
15002
|
EVAL_MANAGEMENT_BINDINGS = [
|
|
14872
15003
|
{
|
|
@@ -14876,7 +15007,8 @@ var init_eval_management = __esm({
|
|
|
14876
15007
|
method: "GET",
|
|
14877
15008
|
path: "/api/v1/plays",
|
|
14878
15009
|
side_effect: "none",
|
|
14879
|
-
receipt: "investigation read model"
|
|
15010
|
+
receipt: "investigation read model",
|
|
15011
|
+
explicit_org_scope: true
|
|
14880
15012
|
},
|
|
14881
15013
|
{
|
|
14882
15014
|
...common2,
|
|
@@ -14885,7 +15017,8 @@ var init_eval_management = __esm({
|
|
|
14885
15017
|
method: "GET",
|
|
14886
15018
|
path: "/api/v1/plays/{id}",
|
|
14887
15019
|
side_effect: "none",
|
|
14888
|
-
receipt: "investigation read model"
|
|
15020
|
+
receipt: "investigation read model",
|
|
15021
|
+
explicit_org_scope: true
|
|
14889
15022
|
},
|
|
14890
15023
|
{
|
|
14891
15024
|
...common2,
|
|
@@ -14894,7 +15027,9 @@ var init_eval_management = __esm({
|
|
|
14894
15027
|
method: "POST",
|
|
14895
15028
|
path: "/api/v1/plays",
|
|
14896
15029
|
side_effect: "repo-authored investigation revision",
|
|
14897
|
-
receipt: "source path, source SHA, and investigation id"
|
|
15030
|
+
receipt: "source path, source SHA, and investigation id",
|
|
15031
|
+
minimum_cli_version: "0.1.11",
|
|
15032
|
+
explicit_org_scope: true
|
|
14898
15033
|
},
|
|
14899
15034
|
{
|
|
14900
15035
|
...common2,
|
|
@@ -14903,7 +15038,9 @@ var init_eval_management = __esm({
|
|
|
14903
15038
|
method: "PATCH",
|
|
14904
15039
|
path: "/api/v1/plays/{id}",
|
|
14905
15040
|
side_effect: "repo-authored investigation revision",
|
|
14906
|
-
receipt: "source SHA and publication result"
|
|
15041
|
+
receipt: "source SHA and publication result",
|
|
15042
|
+
minimum_cli_version: "0.1.11",
|
|
15043
|
+
explicit_org_scope: true
|
|
14907
15044
|
},
|
|
14908
15045
|
{
|
|
14909
15046
|
...common2,
|
|
@@ -14912,7 +15049,9 @@ var init_eval_management = __esm({
|
|
|
14912
15049
|
method: "POST",
|
|
14913
15050
|
path: "/api/v1/eval/investigations/{id}/control",
|
|
14914
15051
|
side_effect: "execution gate becomes held",
|
|
14915
|
-
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
|
|
14916
15055
|
},
|
|
14917
15056
|
{
|
|
14918
15057
|
...common2,
|
|
@@ -14921,7 +15060,9 @@ var init_eval_management = __esm({
|
|
|
14921
15060
|
method: "POST",
|
|
14922
15061
|
path: "/api/v1/eval/investigations/{id}/control",
|
|
14923
15062
|
side_effect: "execution gate becomes active",
|
|
14924
|
-
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
|
|
14925
15066
|
},
|
|
14926
15067
|
{
|
|
14927
15068
|
...common2,
|
|
@@ -14930,7 +15071,9 @@ var init_eval_management = __esm({
|
|
|
14930
15071
|
method: "POST",
|
|
14931
15072
|
path: "/api/v1/eval/investigations/{id}/control",
|
|
14932
15073
|
side_effect: "pending queue items are canceled",
|
|
14933
|
-
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
|
|
14934
15077
|
},
|
|
14935
15078
|
{
|
|
14936
15079
|
...common2,
|
|
@@ -14939,7 +15082,9 @@ var init_eval_management = __esm({
|
|
|
14939
15082
|
method: "POST",
|
|
14940
15083
|
path: "/api/v1/eval/investigations/{id}/decisions",
|
|
14941
15084
|
side_effect: "append-only judgment plus repo publication",
|
|
14942
|
-
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
|
|
14943
15088
|
},
|
|
14944
15089
|
{
|
|
14945
15090
|
...common2,
|
|
@@ -14948,7 +15093,9 @@ var init_eval_management = __esm({
|
|
|
14948
15093
|
method: "POST",
|
|
14949
15094
|
path: "/api/v1/eval/investigations/{id}/decisions",
|
|
14950
15095
|
side_effect: "repo lifecycle closes and pending work is canceled",
|
|
14951
|
-
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
|
|
14952
15099
|
},
|
|
14953
15100
|
{
|
|
14954
15101
|
...common2,
|
|
@@ -14957,7 +15104,9 @@ var init_eval_management = __esm({
|
|
|
14957
15104
|
method: "POST",
|
|
14958
15105
|
path: "/api/v1/eval/investigations/{id}/decisions",
|
|
14959
15106
|
side_effect: "repo lifecycle opens and held execution resumes",
|
|
14960
|
-
receipt: "decision and publication receipt"
|
|
15107
|
+
receipt: "decision and publication receipt",
|
|
15108
|
+
minimum_cli_version: "0.1.11",
|
|
15109
|
+
explicit_org_scope: true
|
|
14961
15110
|
},
|
|
14962
15111
|
{
|
|
14963
15112
|
...common2,
|
|
@@ -14966,7 +15115,9 @@ var init_eval_management = __esm({
|
|
|
14966
15115
|
method: "POST",
|
|
14967
15116
|
path: "/api/v1/eval/investigations/{id}/decisions",
|
|
14968
15117
|
side_effect: "repo lifecycle retires and pending work is canceled",
|
|
14969
|
-
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
|
|
14970
15121
|
},
|
|
14971
15122
|
{
|
|
14972
15123
|
...common2,
|
|
@@ -14975,7 +15126,8 @@ var init_eval_management = __esm({
|
|
|
14975
15126
|
method: "GET",
|
|
14976
15127
|
path: "/api/v1/eval/waves",
|
|
14977
15128
|
side_effect: "none",
|
|
14978
|
-
receipt: "wave read model"
|
|
15129
|
+
receipt: "wave read model",
|
|
15130
|
+
explicit_org_scope: true
|
|
14979
15131
|
},
|
|
14980
15132
|
{
|
|
14981
15133
|
...common2,
|
|
@@ -14984,7 +15136,8 @@ var init_eval_management = __esm({
|
|
|
14984
15136
|
method: "GET",
|
|
14985
15137
|
path: "/api/v1/eval/waves/{id}",
|
|
14986
15138
|
side_effect: "none",
|
|
14987
|
-
receipt: "wave, members, and request receipts"
|
|
15139
|
+
receipt: "wave, members, and request receipts",
|
|
15140
|
+
explicit_org_scope: true
|
|
14988
15141
|
},
|
|
14989
15142
|
{
|
|
14990
15143
|
...common2,
|
|
@@ -14993,7 +15146,9 @@ var init_eval_management = __esm({
|
|
|
14993
15146
|
method: "POST",
|
|
14994
15147
|
path: "/api/v1/eval/waves",
|
|
14995
15148
|
side_effect: "operational wave row",
|
|
14996
|
-
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
|
|
14997
15152
|
},
|
|
14998
15153
|
{
|
|
14999
15154
|
...common2,
|
|
@@ -15002,7 +15157,9 @@ var init_eval_management = __esm({
|
|
|
15002
15157
|
method: "PATCH",
|
|
15003
15158
|
path: "/api/v1/eval/waves/{id}",
|
|
15004
15159
|
side_effect: "wave metadata or membership revision",
|
|
15005
|
-
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
|
|
15006
15163
|
},
|
|
15007
15164
|
{
|
|
15008
15165
|
...common2,
|
|
@@ -15011,7 +15168,9 @@ var init_eval_management = __esm({
|
|
|
15011
15168
|
method: "POST",
|
|
15012
15169
|
path: "/api/v1/eval/waves/{id}/schedule",
|
|
15013
15170
|
side_effect: "durable run and queue admission",
|
|
15014
|
-
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
|
|
15015
15174
|
}
|
|
15016
15175
|
];
|
|
15017
15176
|
EvalManagementCatalogResponseSchema = external_exports.object({
|
|
@@ -15027,9 +15186,133 @@ var init_eval_management = __esm({
|
|
|
15027
15186
|
operation: EvalManagementOperationSchema,
|
|
15028
15187
|
input: external_exports.record(external_exports.string(), external_exports.unknown())
|
|
15029
15188
|
});
|
|
15189
|
+
EvalManagementScopeSchema = external_exports.object({
|
|
15190
|
+
scope_contract_version: external_exports.literal(1),
|
|
15191
|
+
requested_org_id: external_exports.string().nullable().optional(),
|
|
15192
|
+
effective_org_id: external_exports.string(),
|
|
15193
|
+
real_actor_user_id: external_exports.string().nullable().optional(),
|
|
15194
|
+
effective_actor_user_id: external_exports.string().nullable().optional(),
|
|
15195
|
+
credential_kind: external_exports.enum(["user_session", "api_key"]).optional(),
|
|
15196
|
+
impersonating: external_exports.boolean().optional(),
|
|
15197
|
+
acting_in_org: external_exports.boolean().optional(),
|
|
15198
|
+
brand_id: external_exports.string().nullable().optional(),
|
|
15199
|
+
agent_id: external_exports.string().nullable().optional(),
|
|
15200
|
+
request_id: external_exports.string().optional()
|
|
15201
|
+
});
|
|
15202
|
+
InvestigationPublicationReceiptSchema = external_exports.object({
|
|
15203
|
+
status: external_exports.enum(["published", "pending", "existing", "noop"]),
|
|
15204
|
+
source_path: external_exports.string().min(1),
|
|
15205
|
+
source_sha: external_exports.string().min(1).optional(),
|
|
15206
|
+
pending_commit_sha: external_exports.string().min(1).optional(),
|
|
15207
|
+
pr_number: external_exports.number().int().positive().optional(),
|
|
15208
|
+
pr_url: external_exports.string().url().optional(),
|
|
15209
|
+
projection_status: external_exports.enum(["projected", "pending"]),
|
|
15210
|
+
projection_error: external_exports.literal("projection_failed").optional()
|
|
15211
|
+
}).superRefine((receipt, ctx) => {
|
|
15212
|
+
if (receipt.status === "published" && !receipt.source_sha) {
|
|
15213
|
+
ctx.addIssue({
|
|
15214
|
+
code: external_exports.ZodIssueCode.custom,
|
|
15215
|
+
path: ["source_sha"],
|
|
15216
|
+
message: `${receipt.status} publication requires a source SHA`
|
|
15217
|
+
});
|
|
15218
|
+
}
|
|
15219
|
+
if (receipt.status === "pending" && !receipt.pending_commit_sha && !receipt.pr_number && !receipt.pr_url) {
|
|
15220
|
+
ctx.addIssue({
|
|
15221
|
+
code: external_exports.ZodIssueCode.custom,
|
|
15222
|
+
path: ["status"],
|
|
15223
|
+
message: "pending publication requires a recoverable commit or PR receipt"
|
|
15224
|
+
});
|
|
15225
|
+
}
|
|
15226
|
+
});
|
|
15227
|
+
InvestigationAuthoringDataSchema = external_exports.object({
|
|
15228
|
+
investigation_id: external_exports.string().uuid().nullable(),
|
|
15229
|
+
source_path: external_exports.string().min(1),
|
|
15230
|
+
publication: InvestigationPublicationReceiptSchema
|
|
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
|
+
});
|
|
15309
|
+
EvalManagementCatalogResultSchema = EvalManagementCatalogResponseSchema.extend({
|
|
15310
|
+
scope: EvalManagementScopeSchema.optional()
|
|
15311
|
+
});
|
|
15030
15312
|
EvalManagementResultSchema = external_exports.object({
|
|
15031
15313
|
operation: EvalManagementOperationSchema,
|
|
15032
|
-
data: external_exports.unknown()
|
|
15314
|
+
data: external_exports.unknown(),
|
|
15315
|
+
scope: EvalManagementScopeSchema.optional()
|
|
15033
15316
|
});
|
|
15034
15317
|
}
|
|
15035
15318
|
});
|
|
@@ -15045,7 +15328,11 @@ async function getInboxManagementOperations(session) {
|
|
|
15045
15328
|
try {
|
|
15046
15329
|
return InboxManagementCatalogResponseSchema.parse(json.data);
|
|
15047
15330
|
} catch {
|
|
15048
|
-
throw new ApiError(
|
|
15331
|
+
throw new ApiError(
|
|
15332
|
+
"The Inbox operation catalog response was malformed.",
|
|
15333
|
+
502,
|
|
15334
|
+
"malformed_response"
|
|
15335
|
+
);
|
|
15049
15336
|
}
|
|
15050
15337
|
}
|
|
15051
15338
|
async function listInboxOrganizations(session) {
|
|
@@ -15057,13 +15344,21 @@ async function listInboxOrganizations(session) {
|
|
|
15057
15344
|
try {
|
|
15058
15345
|
return InboxOrganizationsResponseSchema.parse(json.data);
|
|
15059
15346
|
} catch {
|
|
15060
|
-
throw new ApiError(
|
|
15347
|
+
throw new ApiError(
|
|
15348
|
+
"The organization list response was malformed.",
|
|
15349
|
+
502,
|
|
15350
|
+
"malformed_response"
|
|
15351
|
+
);
|
|
15061
15352
|
}
|
|
15062
15353
|
}
|
|
15063
15354
|
async function callInboxManagement(session, orgId, call) {
|
|
15064
15355
|
const res = await cliApiFetch(`${apiBase()}/api/v1/inbox/manage`, {
|
|
15065
15356
|
method: "POST",
|
|
15066
|
-
headers: {
|
|
15357
|
+
headers: {
|
|
15358
|
+
Authorization: `Bearer ${session}`,
|
|
15359
|
+
"bamboo-active-org": orgId,
|
|
15360
|
+
"Content-Type": "application/json"
|
|
15361
|
+
},
|
|
15067
15362
|
body: JSON.stringify(call)
|
|
15068
15363
|
});
|
|
15069
15364
|
if (!res.ok) throw await parseError(res);
|
|
@@ -15071,7 +15366,11 @@ async function callInboxManagement(session, orgId, call) {
|
|
|
15071
15366
|
try {
|
|
15072
15367
|
return InboxOperationEnvelopeSchema.parse(json.data);
|
|
15073
15368
|
} catch {
|
|
15074
|
-
throw new ApiError(
|
|
15369
|
+
throw new ApiError(
|
|
15370
|
+
"The Inbox operation response was malformed.",
|
|
15371
|
+
502,
|
|
15372
|
+
"malformed_response"
|
|
15373
|
+
);
|
|
15075
15374
|
}
|
|
15076
15375
|
}
|
|
15077
15376
|
function defaultApiBase(version) {
|
|
@@ -15182,14 +15481,17 @@ async function requestInboxRevision(bambooSession, body) {
|
|
|
15182
15481
|
return InboxReviseResponseSchema.parse(json);
|
|
15183
15482
|
}
|
|
15184
15483
|
async function requestInboxApplyRevision(bambooSession, body) {
|
|
15185
|
-
const res = await cliApiFetch(
|
|
15186
|
-
|
|
15187
|
-
|
|
15188
|
-
|
|
15189
|
-
|
|
15190
|
-
|
|
15191
|
-
|
|
15192
|
-
|
|
15484
|
+
const res = await cliApiFetch(
|
|
15485
|
+
`${apiBase()}/api/v1/cli/inbox/apply-revision`,
|
|
15486
|
+
{
|
|
15487
|
+
method: "POST",
|
|
15488
|
+
headers: {
|
|
15489
|
+
Authorization: `Bearer ${bambooSession}`,
|
|
15490
|
+
"Content-Type": "application/json"
|
|
15491
|
+
},
|
|
15492
|
+
body: JSON.stringify(body)
|
|
15493
|
+
}
|
|
15494
|
+
);
|
|
15193
15495
|
if (!res.ok) throw await parseError(res);
|
|
15194
15496
|
const json = await res.json();
|
|
15195
15497
|
return InboxApplyRevisionResponseSchema.parse(json);
|
|
@@ -15242,7 +15544,8 @@ async function getContextHealth(bambooSession, opts = {}) {
|
|
|
15242
15544
|
async function getAgentUsage(bambooSession, opts = {}) {
|
|
15243
15545
|
const url = new URL(`${apiBase()}/api/v1/cli/usage`);
|
|
15244
15546
|
if (opts.agentId) url.searchParams.set("agent_id", opts.agentId);
|
|
15245
|
-
if (opts.windowDays)
|
|
15547
|
+
if (opts.windowDays)
|
|
15548
|
+
url.searchParams.set("window_days", String(opts.windowDays));
|
|
15246
15549
|
const res = await cliApiFetch(url.toString(), {
|
|
15247
15550
|
headers: { Authorization: `Bearer ${bambooSession}` }
|
|
15248
15551
|
});
|
|
@@ -15326,17 +15629,23 @@ ${answer}
|
|
|
15326
15629
|
Saved by Boo via CLI magic-moment, ${stamp}.
|
|
15327
15630
|
`;
|
|
15328
15631
|
}
|
|
15329
|
-
async function listCliAgents(bambooSession) {
|
|
15632
|
+
async function listCliAgents(bambooSession, orgId) {
|
|
15330
15633
|
const res = await cliApiFetch(`${apiBase()}/api/v1/cli/agents`, {
|
|
15331
|
-
headers: {
|
|
15634
|
+
headers: {
|
|
15635
|
+
Authorization: `Bearer ${bambooSession}`,
|
|
15636
|
+
...orgId ? { "bamboo-active-org": orgId } : {}
|
|
15637
|
+
}
|
|
15332
15638
|
});
|
|
15333
15639
|
if (!res.ok) throw await parseError(res);
|
|
15334
15640
|
const json = await res.json();
|
|
15335
15641
|
return CliAgentsListResponseSchema.parse(json);
|
|
15336
15642
|
}
|
|
15337
|
-
async function listCliBrands(bambooSession) {
|
|
15643
|
+
async function listCliBrands(bambooSession, orgId) {
|
|
15338
15644
|
const res = await cliApiFetch(`${apiBase()}/api/v1/cli/brands`, {
|
|
15339
|
-
headers: {
|
|
15645
|
+
headers: {
|
|
15646
|
+
Authorization: `Bearer ${bambooSession}`,
|
|
15647
|
+
...orgId ? { "bamboo-active-org": orgId } : {}
|
|
15648
|
+
}
|
|
15340
15649
|
});
|
|
15341
15650
|
if (!res.ok) throw await parseError(res);
|
|
15342
15651
|
const json = await res.json();
|
|
@@ -15571,14 +15880,17 @@ async function startAbTest(bambooSession, body) {
|
|
|
15571
15880
|
return EvalAbResponseSchema.parse(json.data);
|
|
15572
15881
|
}
|
|
15573
15882
|
async function promoteBaseline(bambooSession, body) {
|
|
15574
|
-
const res = await cliApiFetch(
|
|
15575
|
-
|
|
15576
|
-
|
|
15577
|
-
|
|
15578
|
-
|
|
15579
|
-
|
|
15580
|
-
|
|
15581
|
-
|
|
15883
|
+
const res = await cliApiFetch(
|
|
15884
|
+
`${apiBase()}/api/v1/eval/baseline-promotions`,
|
|
15885
|
+
{
|
|
15886
|
+
method: "POST",
|
|
15887
|
+
headers: {
|
|
15888
|
+
Authorization: `Bearer ${bambooSession}`,
|
|
15889
|
+
"Content-Type": "application/json"
|
|
15890
|
+
},
|
|
15891
|
+
body: JSON.stringify(body)
|
|
15892
|
+
}
|
|
15893
|
+
);
|
|
15582
15894
|
if (!res.ok) throw await parseError(res);
|
|
15583
15895
|
const json = await res.json();
|
|
15584
15896
|
return EvalBaselinePromoteResponseSchema.parse(json.data);
|
|
@@ -15596,47 +15908,99 @@ async function createEvalTestSet(bambooSession, body) {
|
|
|
15596
15908
|
const json = await res.json();
|
|
15597
15909
|
return CliEvalTestSetCreateResponseSchema.parse(json.data);
|
|
15598
15910
|
}
|
|
15599
|
-
async function getEvalManagementOperations(bambooSession) {
|
|
15911
|
+
async function getEvalManagementOperations(bambooSession, orgId) {
|
|
15600
15912
|
const res = await cliApiFetch(`${apiBase()}/api/v1/eval/operations`, {
|
|
15601
|
-
headers: {
|
|
15913
|
+
headers: {
|
|
15914
|
+
Authorization: `Bearer ${bambooSession}`,
|
|
15915
|
+
...orgId ? { "bamboo-active-org": orgId } : {}
|
|
15916
|
+
}
|
|
15602
15917
|
});
|
|
15603
15918
|
if (!res.ok) throw await parseError(res);
|
|
15604
|
-
|
|
15605
|
-
|
|
15919
|
+
try {
|
|
15920
|
+
const json = await res.json();
|
|
15921
|
+
const result = EvalManagementCatalogResultSchema.parse({
|
|
15922
|
+
...json.data ?? {},
|
|
15923
|
+
scope: json.meta
|
|
15924
|
+
});
|
|
15925
|
+
assertExplicitOrgReceipt(result.scope, orgId);
|
|
15926
|
+
return result;
|
|
15927
|
+
} catch (error) {
|
|
15928
|
+
if (error instanceof ApiError) throw error;
|
|
15929
|
+
throw malformedEvalManagementResponse();
|
|
15930
|
+
}
|
|
15606
15931
|
}
|
|
15607
|
-
async function callEvalManagement(bambooSession, call) {
|
|
15608
|
-
const binding = EVAL_MANAGEMENT_BINDINGS.find(
|
|
15609
|
-
|
|
15932
|
+
async function callEvalManagement(bambooSession, call, orgId) {
|
|
15933
|
+
const binding = EVAL_MANAGEMENT_BINDINGS.find(
|
|
15934
|
+
(candidate) => candidate.operation === call.operation
|
|
15935
|
+
);
|
|
15936
|
+
if (!binding)
|
|
15937
|
+
throw new ApiError(
|
|
15938
|
+
`Unsupported operation: ${call.operation}`,
|
|
15939
|
+
400,
|
|
15940
|
+
"unsupported_operation"
|
|
15941
|
+
);
|
|
15942
|
+
if (orgId && binding.explicit_org_scope !== true) {
|
|
15943
|
+
throw new ApiError(
|
|
15944
|
+
`${call.operation} does not support explicit customer organization scope in this release.`,
|
|
15945
|
+
400,
|
|
15946
|
+
"unsupported_organization_scope"
|
|
15947
|
+
);
|
|
15948
|
+
}
|
|
15610
15949
|
const help = EVAL_MANAGEMENT_INPUTS[call.operation];
|
|
15611
15950
|
const missing = help.required.filter(
|
|
15612
15951
|
(field) => call.input[field] === void 0 || call.input[field] === null || call.input[field] === ""
|
|
15613
15952
|
);
|
|
15614
15953
|
if (missing.length) {
|
|
15615
|
-
throw new ApiError(
|
|
15954
|
+
throw new ApiError(
|
|
15955
|
+
`${call.operation} requires input fields: ${missing.join(", ")}`,
|
|
15956
|
+
400,
|
|
15957
|
+
"missing_required_input"
|
|
15958
|
+
);
|
|
15616
15959
|
}
|
|
15617
15960
|
const allowed = /* @__PURE__ */ new Set([...help.required, ...help.optional]);
|
|
15618
|
-
const unknown = Object.keys(call.input).filter(
|
|
15961
|
+
const unknown = Object.keys(call.input).filter(
|
|
15962
|
+
(field) => !allowed.has(field)
|
|
15963
|
+
);
|
|
15619
15964
|
if (unknown.length) {
|
|
15620
|
-
throw new ApiError(
|
|
15965
|
+
throw new ApiError(
|
|
15966
|
+
`${call.operation} does not accept input fields: ${unknown.join(", ")}`,
|
|
15967
|
+
400,
|
|
15968
|
+
"unknown_input"
|
|
15969
|
+
);
|
|
15621
15970
|
}
|
|
15622
15971
|
const input = { ...call.input };
|
|
15623
15972
|
let path2 = binding.path;
|
|
15624
15973
|
if (path2.includes("{id}")) {
|
|
15625
15974
|
const id = input.id;
|
|
15626
15975
|
if (typeof id !== "string" || id.length === 0) {
|
|
15627
|
-
throw new ApiError(
|
|
15976
|
+
throw new ApiError(
|
|
15977
|
+
`${call.operation} requires input.id`,
|
|
15978
|
+
400,
|
|
15979
|
+
"missing_resource_id"
|
|
15980
|
+
);
|
|
15628
15981
|
}
|
|
15629
15982
|
path2 = path2.replace("{id}", encodeURIComponent(id));
|
|
15630
15983
|
delete input.id;
|
|
15631
15984
|
}
|
|
15632
15985
|
const action = call.operation.split(".")[1] ?? "";
|
|
15633
|
-
if (call.operation.startsWith("investigation.") && [
|
|
15986
|
+
if (call.operation.startsWith("investigation.") && [
|
|
15987
|
+
"hold",
|
|
15988
|
+
"resume",
|
|
15989
|
+
"cancel",
|
|
15990
|
+
"conclude_claim",
|
|
15991
|
+
"close",
|
|
15992
|
+
"reopen",
|
|
15993
|
+
"retire"
|
|
15994
|
+
].includes(action)) {
|
|
15634
15995
|
input.operation = action;
|
|
15635
15996
|
}
|
|
15636
15997
|
let url = `${apiBase()}${path2}`;
|
|
15637
15998
|
const init = {
|
|
15638
15999
|
method: binding.method,
|
|
15639
|
-
headers: {
|
|
16000
|
+
headers: {
|
|
16001
|
+
Authorization: `Bearer ${bambooSession}`,
|
|
16002
|
+
...orgId ? { "bamboo-active-org": orgId } : {}
|
|
16003
|
+
}
|
|
15640
16004
|
};
|
|
15641
16005
|
if (binding.method === "GET") {
|
|
15642
16006
|
const query = new URLSearchParams();
|
|
@@ -15649,14 +16013,74 @@ async function callEvalManagement(bambooSession, call) {
|
|
|
15649
16013
|
init.headers["Content-Type"] = "application/json";
|
|
15650
16014
|
init.body = JSON.stringify(input);
|
|
15651
16015
|
}
|
|
15652
|
-
const
|
|
15653
|
-
|
|
15654
|
-
|
|
15655
|
-
|
|
15656
|
-
|
|
15657
|
-
|
|
15658
|
-
|
|
15659
|
-
}
|
|
16016
|
+
const isMutation = binding.method !== "GET";
|
|
16017
|
+
let res;
|
|
16018
|
+
try {
|
|
16019
|
+
res = await cliApiFetch(url, init);
|
|
16020
|
+
} catch (error) {
|
|
16021
|
+
if (!isMutation) throw error;
|
|
16022
|
+
throw unknownEvalMutationOutcome(call, orgId);
|
|
16023
|
+
}
|
|
16024
|
+
if (!res.ok) {
|
|
16025
|
+
const parsedError = await parseError(res);
|
|
16026
|
+
const knownPrewriteFailures = /* @__PURE__ */ new Set([
|
|
16027
|
+
"scope_validation_failed",
|
|
16028
|
+
"investigation_recovery_failed",
|
|
16029
|
+
"investigation_read_failed",
|
|
16030
|
+
"workspace_unavailable",
|
|
16031
|
+
"source_unavailable"
|
|
16032
|
+
]);
|
|
16033
|
+
if (isMutation && res.status >= 500 && !knownPrewriteFailures.has(parsedError.errorCode ?? ""))
|
|
16034
|
+
throw unknownEvalMutationOutcome(call, orgId);
|
|
16035
|
+
throw parsedError;
|
|
16036
|
+
}
|
|
16037
|
+
try {
|
|
16038
|
+
const json = await res.json();
|
|
16039
|
+
const { data, meta, ...siblings } = json;
|
|
16040
|
+
const result = EvalManagementResultSchema.parse({
|
|
16041
|
+
operation: call.operation,
|
|
16042
|
+
data: Object.keys(siblings).length > 0 ? { data, ...siblings } : data,
|
|
16043
|
+
scope: meta
|
|
16044
|
+
});
|
|
16045
|
+
result.data = parseEvalManagementOperationData(call, result.data, orgId);
|
|
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
|
+
}
|
|
16055
|
+
return result;
|
|
16056
|
+
} catch (error) {
|
|
16057
|
+
if (error instanceof ApiError) throw error;
|
|
16058
|
+
if (isMutation) throw unknownEvalMutationOutcome(call, orgId);
|
|
16059
|
+
throw malformedEvalManagementResponse();
|
|
16060
|
+
}
|
|
16061
|
+
}
|
|
16062
|
+
function unknownEvalMutationOutcome(call, orgId) {
|
|
16063
|
+
const operation = call.operation;
|
|
16064
|
+
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.";
|
|
16065
|
+
return new ApiError(
|
|
16066
|
+
`The ${operation} request was dispatched, but its outcome is unknown. ${recovery}`,
|
|
16067
|
+
502,
|
|
16068
|
+
"outcome_unknown"
|
|
16069
|
+
);
|
|
16070
|
+
}
|
|
16071
|
+
function malformedEvalManagementResponse() {
|
|
16072
|
+
return new ApiError(
|
|
16073
|
+
"The eval management response was malformed or incompatible with this CLI version.",
|
|
16074
|
+
502,
|
|
16075
|
+
"malformed_response"
|
|
16076
|
+
);
|
|
16077
|
+
}
|
|
16078
|
+
function assertExplicitOrgReceipt(scope, orgId) {
|
|
16079
|
+
if (!orgId) return;
|
|
16080
|
+
const expected = orgId.toLowerCase();
|
|
16081
|
+
if (!scope || scope.requested_org_id?.toLowerCase() !== expected || scope.effective_org_id.toLowerCase() !== expected) {
|
|
16082
|
+
throw malformedEvalManagementResponse();
|
|
16083
|
+
}
|
|
15660
16084
|
}
|
|
15661
16085
|
async function getEvalTestSetMemberships(bambooSession, brandId) {
|
|
15662
16086
|
const url = `${apiBase()}/api/v1/eval/test-roadmap?brand_id=${encodeURIComponent(brandId)}`;
|
|
@@ -15685,14 +16109,17 @@ function absoluteUrl(relativePath) {
|
|
|
15685
16109
|
return `${apiBase()}${relativePath}`;
|
|
15686
16110
|
}
|
|
15687
16111
|
async function postRecEpisode(bambooSession, body) {
|
|
15688
|
-
const res = await cliApiFetch(
|
|
15689
|
-
|
|
15690
|
-
|
|
15691
|
-
|
|
15692
|
-
|
|
15693
|
-
|
|
15694
|
-
|
|
15695
|
-
|
|
16112
|
+
const res = await cliApiFetch(
|
|
16113
|
+
`${apiBase()}/api/v1/cli/episodes/recommendation`,
|
|
16114
|
+
{
|
|
16115
|
+
method: "POST",
|
|
16116
|
+
headers: {
|
|
16117
|
+
Authorization: `Bearer ${bambooSession}`,
|
|
16118
|
+
"Content-Type": "application/json"
|
|
16119
|
+
},
|
|
16120
|
+
body: JSON.stringify(body)
|
|
16121
|
+
}
|
|
16122
|
+
);
|
|
15696
16123
|
if (!res.ok) throw await parseError(res);
|
|
15697
16124
|
const json = await res.json();
|
|
15698
16125
|
return CliRecEpisodeResponseSchema.parse(json);
|
|
@@ -20116,6 +20543,41 @@ var init_knowledge = __esm({
|
|
|
20116
20543
|
}
|
|
20117
20544
|
});
|
|
20118
20545
|
|
|
20546
|
+
// src/lib/organization-selection.ts
|
|
20547
|
+
async function resolveOrganizationSelection(requested, listOrganizations) {
|
|
20548
|
+
const query = requested.trim();
|
|
20549
|
+
if (!query) {
|
|
20550
|
+
throw Object.assign(new Error("Pass the customer organization with --org."), {
|
|
20551
|
+
code: "organization_scope_required"
|
|
20552
|
+
});
|
|
20553
|
+
}
|
|
20554
|
+
if (UUID.test(query)) return { id: query.toLowerCase() };
|
|
20555
|
+
const { orgs } = await listOrganizations();
|
|
20556
|
+
const normalized = query.toLowerCase();
|
|
20557
|
+
const exact = orgs.filter((org) => org.name?.toLowerCase() === normalized);
|
|
20558
|
+
const matches = exact.length ? exact : orgs.filter((org) => org.name?.toLowerCase().includes(normalized));
|
|
20559
|
+
if (matches.length === 1) return matches[0];
|
|
20560
|
+
if (matches.length === 0) {
|
|
20561
|
+
throw Object.assign(
|
|
20562
|
+
new Error(`No organization matches "${query}". Run \`bamboo-agents inbox organizations ${JSON.stringify(query)}\` to inspect available organizations.`),
|
|
20563
|
+
{ code: "organization_scope_not_found" }
|
|
20564
|
+
);
|
|
20565
|
+
}
|
|
20566
|
+
throw Object.assign(
|
|
20567
|
+
new Error(
|
|
20568
|
+
`Organization "${query}" is ambiguous: ${matches.map((org) => `${org.name} (${org.id})`).join(", ")}. Re-run with the exact name or UUID.`
|
|
20569
|
+
),
|
|
20570
|
+
{ code: "organization_scope_ambiguous" }
|
|
20571
|
+
);
|
|
20572
|
+
}
|
|
20573
|
+
var UUID;
|
|
20574
|
+
var init_organization_selection = __esm({
|
|
20575
|
+
"src/lib/organization-selection.ts"() {
|
|
20576
|
+
"use strict";
|
|
20577
|
+
UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
20578
|
+
}
|
|
20579
|
+
});
|
|
20580
|
+
|
|
20119
20581
|
// src/commands/inbox-management.ts
|
|
20120
20582
|
var inbox_management_exports = {};
|
|
20121
20583
|
__export(inbox_management_exports, {
|
|
@@ -20139,24 +20601,6 @@ async function inboxSession() {
|
|
|
20139
20601
|
);
|
|
20140
20602
|
return token;
|
|
20141
20603
|
}
|
|
20142
|
-
async function resolveOrganization(session, requested) {
|
|
20143
|
-
const query = requested.trim();
|
|
20144
|
-
if (!query) throw Object.assign(new Error("Pass the customer organization with --org."), { code: "organization_scope_required" });
|
|
20145
|
-
if (UUID.test(query)) return { id: query, name: void 0 };
|
|
20146
|
-
const { orgs } = await listInboxOrganizations(session);
|
|
20147
|
-
const normalized = query.toLowerCase();
|
|
20148
|
-
const exact = orgs.filter((org) => org.name.toLowerCase() === normalized);
|
|
20149
|
-
const matches = exact.length ? exact : orgs.filter((org) => org.name.toLowerCase().includes(normalized));
|
|
20150
|
-
if (matches.length === 1) return matches[0];
|
|
20151
|
-
if (matches.length === 0) throw Object.assign(
|
|
20152
|
-
new Error(`No organization matches "${query}". Run \`bamboo-agents inbox organizations ${JSON.stringify(query)}\` to inspect available organizations.`),
|
|
20153
|
-
{ code: "organization_scope_not_found" }
|
|
20154
|
-
);
|
|
20155
|
-
throw Object.assign(
|
|
20156
|
-
new Error(`Organization "${query}" is ambiguous: ${matches.map((org) => `${org.name} (${org.id})`).join(", ")}. Re-run with the exact name or UUID.`),
|
|
20157
|
-
{ code: "organization_scope_ambiguous" }
|
|
20158
|
-
);
|
|
20159
|
-
}
|
|
20160
20604
|
async function inputObject(value) {
|
|
20161
20605
|
const raw = value.startsWith("@") ? await readFile8(value.slice(1), "utf8") : value;
|
|
20162
20606
|
const parsed = JSON.parse(raw);
|
|
@@ -20214,7 +20658,10 @@ async function runInboxOrganizations(options) {
|
|
|
20214
20658
|
async function runInboxManage(options) {
|
|
20215
20659
|
try {
|
|
20216
20660
|
const session = await inboxSession();
|
|
20217
|
-
const organization = await
|
|
20661
|
+
const organization = await resolveOrganizationSelection(
|
|
20662
|
+
options.org,
|
|
20663
|
+
() => listInboxOrganizations(session)
|
|
20664
|
+
);
|
|
20218
20665
|
const orgId = organization.id;
|
|
20219
20666
|
if (organization.name) human(`Operating as organization: ${organization.name} (${orgId})`, options);
|
|
20220
20667
|
if (!InboxManageOperationSchema.safeParse(options.operation).success) {
|
|
@@ -20353,7 +20800,7 @@ async function runInboxManage(options) {
|
|
|
20353
20800
|
fail(error, options);
|
|
20354
20801
|
}
|
|
20355
20802
|
}
|
|
20356
|
-
var
|
|
20803
|
+
var MUTATION_EFFECTS, ANNOTATION_COMMAND_EFFECTS;
|
|
20357
20804
|
var init_inbox_management2 = __esm({
|
|
20358
20805
|
"src/commands/inbox-management.ts"() {
|
|
20359
20806
|
"use strict";
|
|
@@ -20361,8 +20808,8 @@ var init_inbox_management2 = __esm({
|
|
|
20361
20808
|
init_inbox_management();
|
|
20362
20809
|
init_api();
|
|
20363
20810
|
init_credentials();
|
|
20811
|
+
init_organization_selection();
|
|
20364
20812
|
init_output();
|
|
20365
|
-
UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
20366
20813
|
MUTATION_EFFECTS = {
|
|
20367
20814
|
"change.approve": { effect: "merge_workspace_change", reversible: false },
|
|
20368
20815
|
"change.decline": {
|
|
@@ -21691,9 +22138,47 @@ var init_episode = __esm({
|
|
|
21691
22138
|
var eval_management_exports = {};
|
|
21692
22139
|
__export(eval_management_exports, {
|
|
21693
22140
|
runEvalManage: () => runEvalManage,
|
|
21694
|
-
runEvalOperations: () => runEvalOperations
|
|
22141
|
+
runEvalOperations: () => runEvalOperations,
|
|
22142
|
+
runEvalScope: () => runEvalScope
|
|
21695
22143
|
});
|
|
21696
22144
|
import { readFile as readFile10 } from "node:fs/promises";
|
|
22145
|
+
async function runEvalScope(options) {
|
|
22146
|
+
const session = await requireSession12(options);
|
|
22147
|
+
try {
|
|
22148
|
+
const organization = await resolveOrganizationSelection(
|
|
22149
|
+
options.org,
|
|
22150
|
+
() => listInboxOrganizations(session)
|
|
22151
|
+
);
|
|
22152
|
+
const [brandResult, agentResult] = await Promise.all([
|
|
22153
|
+
listCliBrands(session, organization.id),
|
|
22154
|
+
listCliAgents(session, organization.id)
|
|
22155
|
+
]);
|
|
22156
|
+
const result = {
|
|
22157
|
+
organization,
|
|
22158
|
+
brands: brandResult.brands,
|
|
22159
|
+
agents: agentResult.agents
|
|
22160
|
+
};
|
|
22161
|
+
human(
|
|
22162
|
+
`Operating as organization: ${organization.name ?? organization.id} (${organization.id})`,
|
|
22163
|
+
options
|
|
22164
|
+
);
|
|
22165
|
+
for (const brand2 of result.brands)
|
|
22166
|
+
human(` brand: ${brand2.name} (${brand2.id})`, options);
|
|
22167
|
+
for (const agent of result.agents)
|
|
22168
|
+
human(` agent: ${agent.name} (${agent.id})`, options);
|
|
22169
|
+
emitSuccess(result, options);
|
|
22170
|
+
} catch (error) {
|
|
22171
|
+
const value = error;
|
|
22172
|
+
emitError(
|
|
22173
|
+
{
|
|
22174
|
+
code: value.code ?? value.errorCode ?? "scope_discovery_failed",
|
|
22175
|
+
message: value.message ?? "Could not discover the selected organization."
|
|
22176
|
+
},
|
|
22177
|
+
options,
|
|
22178
|
+
1
|
|
22179
|
+
);
|
|
22180
|
+
}
|
|
22181
|
+
}
|
|
21697
22182
|
async function requireSession12(opts) {
|
|
21698
22183
|
const session = await resolveSession();
|
|
21699
22184
|
if (!session) {
|
|
@@ -21721,7 +22206,11 @@ async function parseInput(value) {
|
|
|
21721
22206
|
async function runEvalOperations(options) {
|
|
21722
22207
|
const session = await requireSession12(options);
|
|
21723
22208
|
try {
|
|
21724
|
-
const
|
|
22209
|
+
const organization = options.org ? await resolveOrganizationSelection(
|
|
22210
|
+
options.org,
|
|
22211
|
+
() => listInboxOrganizations(session)
|
|
22212
|
+
) : null;
|
|
22213
|
+
const catalog = organization ? await getEvalManagementOperations(session, organization.id) : await getEvalManagementOperations(session);
|
|
21725
22214
|
human("", options);
|
|
21726
22215
|
for (const binding of catalog.bindings) {
|
|
21727
22216
|
human(
|
|
@@ -21746,7 +22235,7 @@ async function runEvalOperations(options) {
|
|
|
21746
22235
|
const value = error;
|
|
21747
22236
|
emitError(
|
|
21748
22237
|
{
|
|
21749
|
-
code: value.code ?? "operations_failed",
|
|
22238
|
+
code: value.code ?? value.errorCode ?? "operations_failed",
|
|
21750
22239
|
message: value.message ?? "Could not load operations."
|
|
21751
22240
|
},
|
|
21752
22241
|
options,
|
|
@@ -21759,18 +22248,45 @@ async function runEvalManage(options) {
|
|
|
21759
22248
|
const session = await requireSession12(output);
|
|
21760
22249
|
try {
|
|
21761
22250
|
const input = await parseInput(options.input);
|
|
22251
|
+
const organization = options.org ? await resolveOrganizationSelection(
|
|
22252
|
+
options.org,
|
|
22253
|
+
() => listInboxOrganizations(session)
|
|
22254
|
+
) : null;
|
|
21762
22255
|
const call = EvalManagementCallSchema.parse({
|
|
21763
22256
|
operation: options.operation,
|
|
21764
22257
|
input
|
|
21765
22258
|
});
|
|
21766
|
-
const
|
|
21767
|
-
|
|
22259
|
+
const binding = EVAL_MANAGEMENT_BINDINGS.find(
|
|
22260
|
+
(candidate) => candidate.operation === call.operation
|
|
22261
|
+
);
|
|
22262
|
+
if (organization && binding?.side_effect !== "none") {
|
|
22263
|
+
const advertised = await getEvalManagementOperations(
|
|
22264
|
+
session,
|
|
22265
|
+
organization.id
|
|
22266
|
+
);
|
|
22267
|
+
const serverBinding = advertised.bindings.find(
|
|
22268
|
+
(candidate) => candidate.operation === call.operation
|
|
22269
|
+
);
|
|
22270
|
+
if (!serverBinding || serverBinding.explicit_org_scope !== true) {
|
|
22271
|
+
const unsupported = new Error(
|
|
22272
|
+
`${call.operation} is not advertised for explicit customer organization scope by the selected server.`
|
|
22273
|
+
);
|
|
22274
|
+
unsupported.code = "unsupported_organization_scope";
|
|
22275
|
+
throw unsupported;
|
|
22276
|
+
}
|
|
22277
|
+
}
|
|
22278
|
+
const result = organization ? await callEvalManagement(session, call, organization.id) : await callEvalManagement(session, call);
|
|
22279
|
+
human(
|
|
22280
|
+
managementOutcomeLine(result, binding?.side_effect === "none"),
|
|
22281
|
+
output
|
|
22282
|
+
);
|
|
21768
22283
|
emitSuccess(result, output);
|
|
21769
22284
|
} catch (error) {
|
|
21770
22285
|
const value = error;
|
|
22286
|
+
const invalidInput = error instanceof SyntaxError || error instanceof ZodError || value.code === "ENOENT" || value.code === "EACCES";
|
|
21771
22287
|
emitError(
|
|
21772
22288
|
{
|
|
21773
|
-
code: value.code ?? "management_failed",
|
|
22289
|
+
code: invalidInput ? "invalid_input" : value.code ?? value.errorCode ?? "management_failed",
|
|
21774
22290
|
message: value.message ?? "Management operation failed.",
|
|
21775
22291
|
hint: "Run `bamboo-agents eval operations --json` for supported names and bindings."
|
|
21776
22292
|
},
|
|
@@ -21779,12 +22295,51 @@ async function runEvalManage(options) {
|
|
|
21779
22295
|
);
|
|
21780
22296
|
}
|
|
21781
22297
|
}
|
|
22298
|
+
function managementOutcomeLine(result, readOnly) {
|
|
22299
|
+
if (readOnly) return `Read ${result.operation}.`;
|
|
22300
|
+
const data = result.data && typeof result.data === "object" ? result.data : {};
|
|
22301
|
+
const publication = data.publication && typeof data.publication === "object" ? data.publication : null;
|
|
22302
|
+
if (publication?.status === "published" && publication.projection_status === "projected") {
|
|
22303
|
+
return `Published ${result.operation} and projected it into Tests.`;
|
|
22304
|
+
}
|
|
22305
|
+
if (publication?.status === "published") {
|
|
22306
|
+
return `Published ${result.operation}; Tests projection is pending.`;
|
|
22307
|
+
}
|
|
22308
|
+
if (publication?.status === "pending") {
|
|
22309
|
+
return `Authored ${result.operation}; publication and Tests projection are pending.`;
|
|
22310
|
+
}
|
|
22311
|
+
if (publication?.status === "existing") {
|
|
22312
|
+
return `Found the existing authored investigation; no second create was sent.`;
|
|
22313
|
+
}
|
|
22314
|
+
if (publication?.status === "noop") {
|
|
22315
|
+
return `No change for ${result.operation}; the existing publication is current.`;
|
|
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
|
+
}
|
|
22333
|
+
return `Applied ${result.operation}.`;
|
|
22334
|
+
}
|
|
21782
22335
|
var init_eval_management2 = __esm({
|
|
21783
22336
|
"src/commands/eval-management.ts"() {
|
|
21784
22337
|
"use strict";
|
|
22338
|
+
init_zod();
|
|
21785
22339
|
init_eval_management();
|
|
21786
22340
|
init_credentials();
|
|
21787
22341
|
init_api();
|
|
22342
|
+
init_organization_selection();
|
|
21788
22343
|
init_output();
|
|
21789
22344
|
}
|
|
21790
22345
|
});
|
|
@@ -22724,11 +23279,15 @@ episode.command("log-rec").description(
|
|
|
22724
23279
|
await runEpisodeLogRec2(options);
|
|
22725
23280
|
});
|
|
22726
23281
|
var evals = program2.command("eval").description("Evaluation surface \u2014 A/B a candidate skill against its baseline");
|
|
22727
|
-
evals.command("
|
|
23282
|
+
evals.command("scope").description("Resolve one organization and list its authoritative brands and agents").requiredOption("--org <uuid-or-name>", "Customer organization UUID, exact name, or unique name fragment").option("--json", "Emit a JSON envelope for agent consumption").option("--fields <list>", "Project only these dotted field paths from data (comma-separated)").option("--quiet", "Suppress human chatter (data/errors only)").action(async (options) => {
|
|
23283
|
+
const { runEvalScope: runEvalScope2 } = await Promise.resolve().then(() => (init_eval_management2(), eval_management_exports));
|
|
23284
|
+
await runEvalScope2(options);
|
|
23285
|
+
});
|
|
23286
|
+
evals.command("operations").description("List the exact supported investigation and wave management operations").option("--org <uuid-or-name>", "Operate in this organization (exact/unique names resolve authoritatively)").option("--json", "Emit a JSON envelope for agent consumption").option("--fields <list>", "Project only these dotted field paths from data (comma-separated)").option("--quiet", "Suppress human chatter (data/errors only)").action(async (options) => {
|
|
22728
23287
|
const { runEvalOperations: runEvalOperations2 } = await Promise.resolve().then(() => (init_eval_management2(), eval_management_exports));
|
|
22729
23288
|
await runEvalOperations2(options);
|
|
22730
23289
|
});
|
|
22731
|
-
evals.command("manage").description("Call one canonical investigation or wave operation").argument("<operation>", "Exact name from `eval operations`").requiredOption("--input <json-or-@file>", "JSON object, inline or loaded from @path").option("--json", "Emit a JSON envelope for agent consumption").option("--fields <list>", "Project only these dotted field paths from data (comma-separated)").option("--quiet", "Suppress human chatter (data/errors only)").option("--no-sync", "Skip the auto-sync git pull on this command").action(async (operation, options) => {
|
|
23290
|
+
evals.command("manage").description("Call one canonical investigation or wave operation").argument("<operation>", "Exact name from `eval operations`").requiredOption("--input <json-or-@file>", "JSON object, inline or loaded from @path").option("--org <uuid-or-name>", "Operate in this organization (exact/unique names resolve authoritatively)").option("--json", "Emit a JSON envelope for agent consumption").option("--fields <list>", "Project only these dotted field paths from data (comma-separated)").option("--quiet", "Suppress human chatter (data/errors only)").option("--no-sync", "Skip the auto-sync git pull on this command").action(async (operation, options) => {
|
|
22732
23291
|
const { runEvalManage: runEvalManage2 } = await Promise.resolve().then(() => (init_eval_management2(), eval_management_exports));
|
|
22733
23292
|
await runEvalManage2({ operation, ...options });
|
|
22734
23293
|
});
|