bamboo-agents 0.1.10-dev.104.ffdbe11 → 0.1.10-dev.105.540ee26
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 +231 -54
- package/dist/index.js.map +2 -2
- package/package.json +1 -1
package/dist/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.1.10-dev.
|
|
1
|
+
0.1.10-dev.105.540ee26
|
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.
|
|
3040
|
+
VERSION = "0.1.10-dev.105.540ee26";
|
|
3041
3041
|
}
|
|
3042
3042
|
});
|
|
3043
3043
|
|
|
@@ -14731,7 +14731,7 @@ var init_eval_test_sets = __esm({
|
|
|
14731
14731
|
});
|
|
14732
14732
|
|
|
14733
14733
|
// ../../src/lib/api-contracts/cli/eval-management.ts
|
|
14734
|
-
var EvalManagementOperationSchema, EvalManagementBindingSchema, EvalManagementInputHelpSchema, EVAL_MANAGEMENT_INPUTS, common2, EVAL_MANAGEMENT_BINDINGS, EvalManagementCatalogResponseSchema, EvalManagementCallSchema, EvalManagementScopeSchema, EvalManagementCatalogResultSchema, EvalManagementResultSchema;
|
|
14734
|
+
var EvalManagementOperationSchema, EvalManagementBindingSchema, EvalManagementInputHelpSchema, EVAL_MANAGEMENT_INPUTS, common2, EVAL_MANAGEMENT_BINDINGS, EvalManagementCatalogResponseSchema, EvalManagementCallSchema, EvalManagementScopeSchema, InvestigationPublicationReceiptSchema, InvestigationAuthoringDataSchema, EvalManagementCatalogResultSchema, EvalManagementResultSchema;
|
|
14735
14735
|
var init_eval_management = __esm({
|
|
14736
14736
|
"../../src/lib/api-contracts/cli/eval-management.ts"() {
|
|
14737
14737
|
init_zod();
|
|
@@ -14900,7 +14900,9 @@ var init_eval_management = __esm({
|
|
|
14900
14900
|
method: "POST",
|
|
14901
14901
|
path: "/api/v1/plays",
|
|
14902
14902
|
side_effect: "repo-authored investigation revision",
|
|
14903
|
-
receipt: "source path, source SHA, and investigation id"
|
|
14903
|
+
receipt: "source path, source SHA, and investigation id",
|
|
14904
|
+
minimum_cli_version: "0.1.11",
|
|
14905
|
+
explicit_org_scope: true
|
|
14904
14906
|
},
|
|
14905
14907
|
{
|
|
14906
14908
|
...common2,
|
|
@@ -14909,7 +14911,9 @@ var init_eval_management = __esm({
|
|
|
14909
14911
|
method: "PATCH",
|
|
14910
14912
|
path: "/api/v1/plays/{id}",
|
|
14911
14913
|
side_effect: "repo-authored investigation revision",
|
|
14912
|
-
receipt: "source SHA and publication result"
|
|
14914
|
+
receipt: "source SHA and publication result",
|
|
14915
|
+
minimum_cli_version: "0.1.11",
|
|
14916
|
+
explicit_org_scope: true
|
|
14913
14917
|
},
|
|
14914
14918
|
{
|
|
14915
14919
|
...common2,
|
|
@@ -15043,10 +15047,41 @@ var init_eval_management = __esm({
|
|
|
15043
15047
|
effective_actor_user_id: external_exports.string().nullable().optional(),
|
|
15044
15048
|
credential_kind: external_exports.enum(["user_session", "api_key"]).optional(),
|
|
15045
15049
|
impersonating: external_exports.boolean().optional(),
|
|
15050
|
+
acting_in_org: external_exports.boolean().optional(),
|
|
15046
15051
|
brand_id: external_exports.string().nullable().optional(),
|
|
15047
15052
|
agent_id: external_exports.string().nullable().optional(),
|
|
15048
15053
|
request_id: external_exports.string().optional()
|
|
15049
15054
|
});
|
|
15055
|
+
InvestigationPublicationReceiptSchema = external_exports.object({
|
|
15056
|
+
status: external_exports.enum(["published", "pending", "existing", "noop"]),
|
|
15057
|
+
source_path: external_exports.string().min(1),
|
|
15058
|
+
source_sha: external_exports.string().min(1).optional(),
|
|
15059
|
+
pending_commit_sha: external_exports.string().min(1).optional(),
|
|
15060
|
+
pr_number: external_exports.number().int().positive().optional(),
|
|
15061
|
+
pr_url: external_exports.string().url().optional(),
|
|
15062
|
+
projection_status: external_exports.enum(["projected", "pending"]),
|
|
15063
|
+
projection_error: external_exports.literal("projection_failed").optional()
|
|
15064
|
+
}).superRefine((receipt, ctx) => {
|
|
15065
|
+
if (receipt.status === "published" && !receipt.source_sha) {
|
|
15066
|
+
ctx.addIssue({
|
|
15067
|
+
code: external_exports.ZodIssueCode.custom,
|
|
15068
|
+
path: ["source_sha"],
|
|
15069
|
+
message: `${receipt.status} publication requires a source SHA`
|
|
15070
|
+
});
|
|
15071
|
+
}
|
|
15072
|
+
if (receipt.status === "pending" && !receipt.pending_commit_sha && !receipt.pr_number && !receipt.pr_url) {
|
|
15073
|
+
ctx.addIssue({
|
|
15074
|
+
code: external_exports.ZodIssueCode.custom,
|
|
15075
|
+
path: ["status"],
|
|
15076
|
+
message: "pending publication requires a recoverable commit or PR receipt"
|
|
15077
|
+
});
|
|
15078
|
+
}
|
|
15079
|
+
});
|
|
15080
|
+
InvestigationAuthoringDataSchema = external_exports.object({
|
|
15081
|
+
investigation_id: external_exports.string().uuid().nullable(),
|
|
15082
|
+
source_path: external_exports.string().min(1),
|
|
15083
|
+
publication: InvestigationPublicationReceiptSchema
|
|
15084
|
+
}).passthrough();
|
|
15050
15085
|
EvalManagementCatalogResultSchema = EvalManagementCatalogResponseSchema.extend({
|
|
15051
15086
|
scope: EvalManagementScopeSchema.optional()
|
|
15052
15087
|
});
|
|
@@ -15069,7 +15104,11 @@ async function getInboxManagementOperations(session) {
|
|
|
15069
15104
|
try {
|
|
15070
15105
|
return InboxManagementCatalogResponseSchema.parse(json.data);
|
|
15071
15106
|
} catch {
|
|
15072
|
-
throw new ApiError(
|
|
15107
|
+
throw new ApiError(
|
|
15108
|
+
"The Inbox operation catalog response was malformed.",
|
|
15109
|
+
502,
|
|
15110
|
+
"malformed_response"
|
|
15111
|
+
);
|
|
15073
15112
|
}
|
|
15074
15113
|
}
|
|
15075
15114
|
async function listInboxOrganizations(session) {
|
|
@@ -15081,13 +15120,21 @@ async function listInboxOrganizations(session) {
|
|
|
15081
15120
|
try {
|
|
15082
15121
|
return InboxOrganizationsResponseSchema.parse(json.data);
|
|
15083
15122
|
} catch {
|
|
15084
|
-
throw new ApiError(
|
|
15123
|
+
throw new ApiError(
|
|
15124
|
+
"The organization list response was malformed.",
|
|
15125
|
+
502,
|
|
15126
|
+
"malformed_response"
|
|
15127
|
+
);
|
|
15085
15128
|
}
|
|
15086
15129
|
}
|
|
15087
15130
|
async function callInboxManagement(session, orgId, call) {
|
|
15088
15131
|
const res = await cliApiFetch(`${apiBase()}/api/v1/inbox/manage`, {
|
|
15089
15132
|
method: "POST",
|
|
15090
|
-
headers: {
|
|
15133
|
+
headers: {
|
|
15134
|
+
Authorization: `Bearer ${session}`,
|
|
15135
|
+
"bamboo-active-org": orgId,
|
|
15136
|
+
"Content-Type": "application/json"
|
|
15137
|
+
},
|
|
15091
15138
|
body: JSON.stringify(call)
|
|
15092
15139
|
});
|
|
15093
15140
|
if (!res.ok) throw await parseError(res);
|
|
@@ -15095,7 +15142,11 @@ async function callInboxManagement(session, orgId, call) {
|
|
|
15095
15142
|
try {
|
|
15096
15143
|
return InboxOperationEnvelopeSchema.parse(json.data);
|
|
15097
15144
|
} catch {
|
|
15098
|
-
throw new ApiError(
|
|
15145
|
+
throw new ApiError(
|
|
15146
|
+
"The Inbox operation response was malformed.",
|
|
15147
|
+
502,
|
|
15148
|
+
"malformed_response"
|
|
15149
|
+
);
|
|
15099
15150
|
}
|
|
15100
15151
|
}
|
|
15101
15152
|
function defaultApiBase(version) {
|
|
@@ -15206,14 +15257,17 @@ async function requestInboxRevision(bambooSession, body) {
|
|
|
15206
15257
|
return InboxReviseResponseSchema.parse(json);
|
|
15207
15258
|
}
|
|
15208
15259
|
async function requestInboxApplyRevision(bambooSession, body) {
|
|
15209
|
-
const res = await cliApiFetch(
|
|
15210
|
-
|
|
15211
|
-
|
|
15212
|
-
|
|
15213
|
-
|
|
15214
|
-
|
|
15215
|
-
|
|
15216
|
-
|
|
15260
|
+
const res = await cliApiFetch(
|
|
15261
|
+
`${apiBase()}/api/v1/cli/inbox/apply-revision`,
|
|
15262
|
+
{
|
|
15263
|
+
method: "POST",
|
|
15264
|
+
headers: {
|
|
15265
|
+
Authorization: `Bearer ${bambooSession}`,
|
|
15266
|
+
"Content-Type": "application/json"
|
|
15267
|
+
},
|
|
15268
|
+
body: JSON.stringify(body)
|
|
15269
|
+
}
|
|
15270
|
+
);
|
|
15217
15271
|
if (!res.ok) throw await parseError(res);
|
|
15218
15272
|
const json = await res.json();
|
|
15219
15273
|
return InboxApplyRevisionResponseSchema.parse(json);
|
|
@@ -15266,7 +15320,8 @@ async function getContextHealth(bambooSession, opts = {}) {
|
|
|
15266
15320
|
async function getAgentUsage(bambooSession, opts = {}) {
|
|
15267
15321
|
const url = new URL(`${apiBase()}/api/v1/cli/usage`);
|
|
15268
15322
|
if (opts.agentId) url.searchParams.set("agent_id", opts.agentId);
|
|
15269
|
-
if (opts.windowDays)
|
|
15323
|
+
if (opts.windowDays)
|
|
15324
|
+
url.searchParams.set("window_days", String(opts.windowDays));
|
|
15270
15325
|
const res = await cliApiFetch(url.toString(), {
|
|
15271
15326
|
headers: { Authorization: `Bearer ${bambooSession}` }
|
|
15272
15327
|
});
|
|
@@ -15601,14 +15656,17 @@ async function startAbTest(bambooSession, body) {
|
|
|
15601
15656
|
return EvalAbResponseSchema.parse(json.data);
|
|
15602
15657
|
}
|
|
15603
15658
|
async function promoteBaseline(bambooSession, body) {
|
|
15604
|
-
const res = await cliApiFetch(
|
|
15605
|
-
|
|
15606
|
-
|
|
15607
|
-
|
|
15608
|
-
|
|
15609
|
-
|
|
15610
|
-
|
|
15611
|
-
|
|
15659
|
+
const res = await cliApiFetch(
|
|
15660
|
+
`${apiBase()}/api/v1/eval/baseline-promotions`,
|
|
15661
|
+
{
|
|
15662
|
+
method: "POST",
|
|
15663
|
+
headers: {
|
|
15664
|
+
Authorization: `Bearer ${bambooSession}`,
|
|
15665
|
+
"Content-Type": "application/json"
|
|
15666
|
+
},
|
|
15667
|
+
body: JSON.stringify(body)
|
|
15668
|
+
}
|
|
15669
|
+
);
|
|
15612
15670
|
if (!res.ok) throw await parseError(res);
|
|
15613
15671
|
const json = await res.json();
|
|
15614
15672
|
return EvalBaselinePromoteResponseSchema.parse(json.data);
|
|
@@ -15648,8 +15706,15 @@ async function getEvalManagementOperations(bambooSession, orgId) {
|
|
|
15648
15706
|
}
|
|
15649
15707
|
}
|
|
15650
15708
|
async function callEvalManagement(bambooSession, call, orgId) {
|
|
15651
|
-
const binding = EVAL_MANAGEMENT_BINDINGS.find(
|
|
15652
|
-
|
|
15709
|
+
const binding = EVAL_MANAGEMENT_BINDINGS.find(
|
|
15710
|
+
(candidate) => candidate.operation === call.operation
|
|
15711
|
+
);
|
|
15712
|
+
if (!binding)
|
|
15713
|
+
throw new ApiError(
|
|
15714
|
+
`Unsupported operation: ${call.operation}`,
|
|
15715
|
+
400,
|
|
15716
|
+
"unsupported_operation"
|
|
15717
|
+
);
|
|
15653
15718
|
if (orgId && binding.explicit_org_scope !== true) {
|
|
15654
15719
|
throw new ApiError(
|
|
15655
15720
|
`${call.operation} does not support explicit customer organization scope in this release.`,
|
|
@@ -15662,25 +15727,47 @@ async function callEvalManagement(bambooSession, call, orgId) {
|
|
|
15662
15727
|
(field) => call.input[field] === void 0 || call.input[field] === null || call.input[field] === ""
|
|
15663
15728
|
);
|
|
15664
15729
|
if (missing.length) {
|
|
15665
|
-
throw new ApiError(
|
|
15730
|
+
throw new ApiError(
|
|
15731
|
+
`${call.operation} requires input fields: ${missing.join(", ")}`,
|
|
15732
|
+
400,
|
|
15733
|
+
"missing_required_input"
|
|
15734
|
+
);
|
|
15666
15735
|
}
|
|
15667
15736
|
const allowed = /* @__PURE__ */ new Set([...help.required, ...help.optional]);
|
|
15668
|
-
const unknown = Object.keys(call.input).filter(
|
|
15737
|
+
const unknown = Object.keys(call.input).filter(
|
|
15738
|
+
(field) => !allowed.has(field)
|
|
15739
|
+
);
|
|
15669
15740
|
if (unknown.length) {
|
|
15670
|
-
throw new ApiError(
|
|
15741
|
+
throw new ApiError(
|
|
15742
|
+
`${call.operation} does not accept input fields: ${unknown.join(", ")}`,
|
|
15743
|
+
400,
|
|
15744
|
+
"unknown_input"
|
|
15745
|
+
);
|
|
15671
15746
|
}
|
|
15672
15747
|
const input = { ...call.input };
|
|
15673
15748
|
let path2 = binding.path;
|
|
15674
15749
|
if (path2.includes("{id}")) {
|
|
15675
15750
|
const id = input.id;
|
|
15676
15751
|
if (typeof id !== "string" || id.length === 0) {
|
|
15677
|
-
throw new ApiError(
|
|
15752
|
+
throw new ApiError(
|
|
15753
|
+
`${call.operation} requires input.id`,
|
|
15754
|
+
400,
|
|
15755
|
+
"missing_resource_id"
|
|
15756
|
+
);
|
|
15678
15757
|
}
|
|
15679
15758
|
path2 = path2.replace("{id}", encodeURIComponent(id));
|
|
15680
15759
|
delete input.id;
|
|
15681
15760
|
}
|
|
15682
15761
|
const action = call.operation.split(".")[1] ?? "";
|
|
15683
|
-
if (call.operation.startsWith("investigation.") && [
|
|
15762
|
+
if (call.operation.startsWith("investigation.") && [
|
|
15763
|
+
"hold",
|
|
15764
|
+
"resume",
|
|
15765
|
+
"cancel",
|
|
15766
|
+
"conclude_claim",
|
|
15767
|
+
"close",
|
|
15768
|
+
"reopen",
|
|
15769
|
+
"retire"
|
|
15770
|
+
].includes(action)) {
|
|
15684
15771
|
input.operation = action;
|
|
15685
15772
|
}
|
|
15686
15773
|
let url = `${apiBase()}${path2}`;
|
|
@@ -15702,8 +15789,27 @@ async function callEvalManagement(bambooSession, call, orgId) {
|
|
|
15702
15789
|
init.headers["Content-Type"] = "application/json";
|
|
15703
15790
|
init.body = JSON.stringify(input);
|
|
15704
15791
|
}
|
|
15705
|
-
const
|
|
15706
|
-
|
|
15792
|
+
const isMutation = binding.method !== "GET";
|
|
15793
|
+
let res;
|
|
15794
|
+
try {
|
|
15795
|
+
res = await cliApiFetch(url, init);
|
|
15796
|
+
} catch (error) {
|
|
15797
|
+
if (!isMutation) throw error;
|
|
15798
|
+
throw unknownEvalMutationOutcome(call, orgId);
|
|
15799
|
+
}
|
|
15800
|
+
if (!res.ok) {
|
|
15801
|
+
const parsedError = await parseError(res);
|
|
15802
|
+
const knownPrewriteFailures = /* @__PURE__ */ new Set([
|
|
15803
|
+
"scope_validation_failed",
|
|
15804
|
+
"investigation_recovery_failed",
|
|
15805
|
+
"investigation_read_failed",
|
|
15806
|
+
"workspace_unavailable",
|
|
15807
|
+
"source_unavailable"
|
|
15808
|
+
]);
|
|
15809
|
+
if (isMutation && res.status >= 500 && !knownPrewriteFailures.has(parsedError.errorCode ?? ""))
|
|
15810
|
+
throw unknownEvalMutationOutcome(call, orgId);
|
|
15811
|
+
throw parsedError;
|
|
15812
|
+
}
|
|
15707
15813
|
try {
|
|
15708
15814
|
const json = await res.json();
|
|
15709
15815
|
const { data, meta, ...siblings } = json;
|
|
@@ -15712,13 +15818,26 @@ async function callEvalManagement(bambooSession, call, orgId) {
|
|
|
15712
15818
|
data: Object.keys(siblings).length > 0 ? { data, ...siblings } : data,
|
|
15713
15819
|
scope: meta
|
|
15714
15820
|
});
|
|
15821
|
+
if (call.operation === "investigation.create" || call.operation === "investigation.update") {
|
|
15822
|
+
result.data = InvestigationAuthoringDataSchema.parse(result.data);
|
|
15823
|
+
}
|
|
15715
15824
|
assertExplicitOrgReceipt(result.scope, orgId);
|
|
15716
15825
|
return result;
|
|
15717
15826
|
} catch (error) {
|
|
15718
15827
|
if (error instanceof ApiError) throw error;
|
|
15828
|
+
if (isMutation) throw unknownEvalMutationOutcome(call, orgId);
|
|
15719
15829
|
throw malformedEvalManagementResponse();
|
|
15720
15830
|
}
|
|
15721
15831
|
}
|
|
15832
|
+
function unknownEvalMutationOutcome(call, orgId) {
|
|
15833
|
+
const operation = call.operation;
|
|
15834
|
+
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.";
|
|
15835
|
+
return new ApiError(
|
|
15836
|
+
`The ${operation} request was dispatched, but its outcome is unknown. ${recovery}`,
|
|
15837
|
+
502,
|
|
15838
|
+
"outcome_unknown"
|
|
15839
|
+
);
|
|
15840
|
+
}
|
|
15722
15841
|
function malformedEvalManagementResponse() {
|
|
15723
15842
|
return new ApiError(
|
|
15724
15843
|
"The eval management response was malformed or incompatible with this CLI version.",
|
|
@@ -15760,14 +15879,17 @@ function absoluteUrl(relativePath) {
|
|
|
15760
15879
|
return `${apiBase()}${relativePath}`;
|
|
15761
15880
|
}
|
|
15762
15881
|
async function postRecEpisode(bambooSession, body) {
|
|
15763
|
-
const res = await cliApiFetch(
|
|
15764
|
-
|
|
15765
|
-
|
|
15766
|
-
|
|
15767
|
-
|
|
15768
|
-
|
|
15769
|
-
|
|
15770
|
-
|
|
15882
|
+
const res = await cliApiFetch(
|
|
15883
|
+
`${apiBase()}/api/v1/cli/episodes/recommendation`,
|
|
15884
|
+
{
|
|
15885
|
+
method: "POST",
|
|
15886
|
+
headers: {
|
|
15887
|
+
Authorization: `Bearer ${bambooSession}`,
|
|
15888
|
+
"Content-Type": "application/json"
|
|
15889
|
+
},
|
|
15890
|
+
body: JSON.stringify(body)
|
|
15891
|
+
}
|
|
15892
|
+
);
|
|
15771
15893
|
if (!res.ok) throw await parseError(res);
|
|
15772
15894
|
const json = await res.json();
|
|
15773
15895
|
return CliRecEpisodeResponseSchema.parse(json);
|
|
@@ -21806,16 +21928,25 @@ async function runEvalScope(options) {
|
|
|
21806
21928
|
brands: brandResult.brands,
|
|
21807
21929
|
agents: agentResult.agents
|
|
21808
21930
|
};
|
|
21809
|
-
human(
|
|
21810
|
-
|
|
21811
|
-
|
|
21931
|
+
human(
|
|
21932
|
+
`Operating as organization: ${organization.name ?? organization.id} (${organization.id})`,
|
|
21933
|
+
options
|
|
21934
|
+
);
|
|
21935
|
+
for (const brand2 of result.brands)
|
|
21936
|
+
human(` brand: ${brand2.name} (${brand2.id})`, options);
|
|
21937
|
+
for (const agent of result.agents)
|
|
21938
|
+
human(` agent: ${agent.name} (${agent.id})`, options);
|
|
21812
21939
|
emitSuccess(result, options);
|
|
21813
21940
|
} catch (error) {
|
|
21814
21941
|
const value = error;
|
|
21815
|
-
emitError(
|
|
21816
|
-
|
|
21817
|
-
|
|
21818
|
-
|
|
21942
|
+
emitError(
|
|
21943
|
+
{
|
|
21944
|
+
code: value.code ?? value.errorCode ?? "scope_discovery_failed",
|
|
21945
|
+
message: value.message ?? "Could not discover the selected organization."
|
|
21946
|
+
},
|
|
21947
|
+
options,
|
|
21948
|
+
1
|
|
21949
|
+
);
|
|
21819
21950
|
}
|
|
21820
21951
|
}
|
|
21821
21952
|
async function requireSession12(opts) {
|
|
@@ -21845,7 +21976,10 @@ async function parseInput(value) {
|
|
|
21845
21976
|
async function runEvalOperations(options) {
|
|
21846
21977
|
const session = await requireSession12(options);
|
|
21847
21978
|
try {
|
|
21848
|
-
const organization = options.org ? await resolveOrganizationSelection(
|
|
21979
|
+
const organization = options.org ? await resolveOrganizationSelection(
|
|
21980
|
+
options.org,
|
|
21981
|
+
() => listInboxOrganizations(session)
|
|
21982
|
+
) : null;
|
|
21849
21983
|
const catalog = organization ? await getEvalManagementOperations(session, organization.id) : await getEvalManagementOperations(session);
|
|
21850
21984
|
human("", options);
|
|
21851
21985
|
for (const binding of catalog.bindings) {
|
|
@@ -21871,7 +22005,7 @@ async function runEvalOperations(options) {
|
|
|
21871
22005
|
const value = error;
|
|
21872
22006
|
emitError(
|
|
21873
22007
|
{
|
|
21874
|
-
code: value.code ?? "operations_failed",
|
|
22008
|
+
code: value.code ?? value.errorCode ?? "operations_failed",
|
|
21875
22009
|
message: value.message ?? "Could not load operations."
|
|
21876
22010
|
},
|
|
21877
22011
|
options,
|
|
@@ -21884,7 +22018,10 @@ async function runEvalManage(options) {
|
|
|
21884
22018
|
const session = await requireSession12(output);
|
|
21885
22019
|
try {
|
|
21886
22020
|
const input = await parseInput(options.input);
|
|
21887
|
-
const organization = options.org ? await resolveOrganizationSelection(
|
|
22021
|
+
const organization = options.org ? await resolveOrganizationSelection(
|
|
22022
|
+
options.org,
|
|
22023
|
+
() => listInboxOrganizations(session)
|
|
22024
|
+
) : null;
|
|
21888
22025
|
const call = EvalManagementCallSchema.parse({
|
|
21889
22026
|
operation: options.operation,
|
|
21890
22027
|
input
|
|
@@ -21892,15 +22029,34 @@ async function runEvalManage(options) {
|
|
|
21892
22029
|
const binding = EVAL_MANAGEMENT_BINDINGS.find(
|
|
21893
22030
|
(candidate) => candidate.operation === call.operation
|
|
21894
22031
|
);
|
|
22032
|
+
if (organization && binding?.side_effect !== "none") {
|
|
22033
|
+
const advertised = await getEvalManagementOperations(
|
|
22034
|
+
session,
|
|
22035
|
+
organization.id
|
|
22036
|
+
);
|
|
22037
|
+
const serverBinding = advertised.bindings.find(
|
|
22038
|
+
(candidate) => candidate.operation === call.operation
|
|
22039
|
+
);
|
|
22040
|
+
if (!serverBinding || serverBinding.explicit_org_scope !== true) {
|
|
22041
|
+
const unsupported = new Error(
|
|
22042
|
+
`${call.operation} is not advertised for explicit customer organization scope by the selected server.`
|
|
22043
|
+
);
|
|
22044
|
+
unsupported.code = "unsupported_organization_scope";
|
|
22045
|
+
throw unsupported;
|
|
22046
|
+
}
|
|
22047
|
+
}
|
|
21895
22048
|
const result = organization ? await callEvalManagement(session, call, organization.id) : await callEvalManagement(session, call);
|
|
21896
|
-
human(
|
|
22049
|
+
human(
|
|
22050
|
+
managementOutcomeLine(result, binding?.side_effect === "none"),
|
|
22051
|
+
output
|
|
22052
|
+
);
|
|
21897
22053
|
emitSuccess(result, output);
|
|
21898
22054
|
} catch (error) {
|
|
21899
22055
|
const value = error;
|
|
21900
22056
|
const invalidInput = error instanceof SyntaxError || error instanceof ZodError || value.code === "ENOENT" || value.code === "EACCES";
|
|
21901
22057
|
emitError(
|
|
21902
22058
|
{
|
|
21903
|
-
code: invalidInput ? "invalid_input" : value.code ?? "management_failed",
|
|
22059
|
+
code: invalidInput ? "invalid_input" : value.code ?? value.errorCode ?? "management_failed",
|
|
21904
22060
|
message: value.message ?? "Management operation failed.",
|
|
21905
22061
|
hint: "Run `bamboo-agents eval operations --json` for supported names and bindings."
|
|
21906
22062
|
},
|
|
@@ -21909,6 +22065,27 @@ async function runEvalManage(options) {
|
|
|
21909
22065
|
);
|
|
21910
22066
|
}
|
|
21911
22067
|
}
|
|
22068
|
+
function managementOutcomeLine(result, readOnly) {
|
|
22069
|
+
if (readOnly) return `Read ${result.operation}.`;
|
|
22070
|
+
const data = result.data && typeof result.data === "object" ? result.data : {};
|
|
22071
|
+
const publication = data.publication && typeof data.publication === "object" ? data.publication : null;
|
|
22072
|
+
if (publication?.status === "published" && publication.projection_status === "projected") {
|
|
22073
|
+
return `Published ${result.operation} and projected it into Tests.`;
|
|
22074
|
+
}
|
|
22075
|
+
if (publication?.status === "published") {
|
|
22076
|
+
return `Published ${result.operation}; Tests projection is pending.`;
|
|
22077
|
+
}
|
|
22078
|
+
if (publication?.status === "pending") {
|
|
22079
|
+
return `Authored ${result.operation}; publication and Tests projection are pending.`;
|
|
22080
|
+
}
|
|
22081
|
+
if (publication?.status === "existing") {
|
|
22082
|
+
return `Found the existing authored investigation; no second create was sent.`;
|
|
22083
|
+
}
|
|
22084
|
+
if (publication?.status === "noop") {
|
|
22085
|
+
return `No change for ${result.operation}; the existing publication is current.`;
|
|
22086
|
+
}
|
|
22087
|
+
return `Applied ${result.operation}.`;
|
|
22088
|
+
}
|
|
21912
22089
|
var init_eval_management2 = __esm({
|
|
21913
22090
|
"src/commands/eval-management.ts"() {
|
|
21914
22091
|
"use strict";
|