bamboo-agents 0.1.9 → 0.1.10-dev.102.32ca898
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 +92 -28
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
package/dist/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.1.
|
|
1
|
+
0.1.10-dev.102.32ca898
|
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.10-dev.102.32ca898";
|
|
3041
3041
|
}
|
|
3042
3042
|
});
|
|
3043
3043
|
|
|
@@ -12756,10 +12756,19 @@ var init_inbox_apply_revision = __esm({
|
|
|
12756
12756
|
});
|
|
12757
12757
|
|
|
12758
12758
|
// ../../src/lib/api-contracts/cli/inbox-management.ts
|
|
12759
|
-
|
|
12759
|
+
function inboxSourceVersionsMatch(current, reviewed) {
|
|
12760
|
+
if (typeof current !== "string" || typeof reviewed !== "string") return current === reviewed;
|
|
12761
|
+
const canonicalUtc = (value) => value.replace(/\+00:00$/i, "Z");
|
|
12762
|
+
return canonicalUtc(current) === canonicalUtc(reviewed);
|
|
12763
|
+
}
|
|
12764
|
+
var InboxUtcTimestampSchema, InboxOperationSchema, InboxManageOperationSchema, InboxOperationBindingSchema, common, INBOX_MANAGEMENT_BINDINGS, INBOX_EXISTING_COMMAND_BINDINGS, changeCommon, CHANGE_MANAGEMENT_BINDINGS, opportunityCommon, OPPORTUNITY_MANAGEMENT_BINDINGS, annotationCommon, ANNOTATION_MANAGEMENT_BINDINGS, lifecycleMutationInputs, FDE_ACTION_MANAGEMENT_BINDINGS, GRAPH_RECOVERY_MANAGEMENT_BINDINGS, InboxManagementCatalogResponseSchema, InboxOrganizationsResponseSchema, OpportunityDecisionInputBaseSchema, InboxManagementCallSchema, InboxWorkItemSchema, InboxListReceiptSchema, InboxGetReceiptSchema, InboxEnvelopeBaseSchema, UnknownMutationReceiptSchema, ChangeReadBackSchema, OpportunitySnapshotSchema, OpportunityUnknownReceiptSchema, OpportunityCommandSchema, FdeActionSnapshotSchema, GraphRecoverySnapshotSchema, LifecycleUnknownReceiptSchema, AnnotationSnapshotSchema, AnnotationUnknownReceiptSchema, InboxOperationEnvelopeSchema;
|
|
12760
12765
|
var init_inbox_management = __esm({
|
|
12761
12766
|
"../../src/lib/api-contracts/cli/inbox-management.ts"() {
|
|
12762
12767
|
init_zod();
|
|
12768
|
+
InboxUtcTimestampSchema = external_exports.string().datetime({ offset: true }).refine(
|
|
12769
|
+
(value) => /(?:Z|\+00:00)$/i.test(value),
|
|
12770
|
+
"source version must use UTC (Z or +00:00)"
|
|
12771
|
+
);
|
|
12763
12772
|
InboxOperationSchema = external_exports.enum([
|
|
12764
12773
|
"inbox.list",
|
|
12765
12774
|
"inbox.get",
|
|
@@ -13536,10 +13545,17 @@ var init_inbox_management = __esm({
|
|
|
13536
13545
|
bindings: external_exports.array(InboxOperationBindingSchema),
|
|
13537
13546
|
related_cli_commands: external_exports.array(external_exports.string())
|
|
13538
13547
|
});
|
|
13548
|
+
InboxOrganizationsResponseSchema = external_exports.object({
|
|
13549
|
+
orgs: external_exports.array(external_exports.object({
|
|
13550
|
+
id: external_exports.string().uuid(),
|
|
13551
|
+
name: external_exports.string().min(1),
|
|
13552
|
+
status: external_exports.string()
|
|
13553
|
+
}))
|
|
13554
|
+
});
|
|
13539
13555
|
OpportunityDecisionInputBaseSchema = external_exports.object({
|
|
13540
13556
|
opportunity_id: external_exports.string().uuid(),
|
|
13541
13557
|
brand_id: external_exports.string().uuid().optional(),
|
|
13542
|
-
source_version:
|
|
13558
|
+
source_version: InboxUtcTimestampSchema,
|
|
13543
13559
|
command_id: external_exports.string().min(1).max(128),
|
|
13544
13560
|
reason: external_exports.string().trim().min(1),
|
|
13545
13561
|
approved: external_exports.literal(true),
|
|
@@ -13700,7 +13716,7 @@ var init_inbox_management = __esm({
|
|
|
13700
13716
|
input: external_exports.object({
|
|
13701
13717
|
opportunity_id: external_exports.string().uuid(),
|
|
13702
13718
|
brand_id: external_exports.string().uuid().optional(),
|
|
13703
|
-
source_version:
|
|
13719
|
+
source_version: InboxUtcTimestampSchema,
|
|
13704
13720
|
command_id: external_exports.string().min(1).max(128),
|
|
13705
13721
|
recipient_user_id: external_exports.string().uuid(),
|
|
13706
13722
|
recipient_name: external_exports.string().trim().min(1),
|
|
@@ -13742,7 +13758,7 @@ var init_inbox_management = __esm({
|
|
|
13742
13758
|
input: external_exports.object({
|
|
13743
13759
|
opportunity_id: external_exports.string().uuid(),
|
|
13744
13760
|
brand_id: external_exports.string().uuid().optional(),
|
|
13745
|
-
source_version:
|
|
13761
|
+
source_version: InboxUtcTimestampSchema,
|
|
13746
13762
|
command_id: external_exports.string().min(1).max(128),
|
|
13747
13763
|
answer: external_exports.string().trim().min(1).max(2e4),
|
|
13748
13764
|
subquestion_key: external_exports.string().trim().min(1).max(240).optional(),
|
|
@@ -13767,7 +13783,7 @@ var init_inbox_management = __esm({
|
|
|
13767
13783
|
input: external_exports.object({
|
|
13768
13784
|
id: external_exports.string().uuid(),
|
|
13769
13785
|
brand_id: external_exports.string().uuid().optional(),
|
|
13770
|
-
source_version:
|
|
13786
|
+
source_version: InboxUtcTimestampSchema,
|
|
13771
13787
|
command_id: external_exports.string().min(1).max(128),
|
|
13772
13788
|
command: external_exports.enum([
|
|
13773
13789
|
"assign",
|
|
@@ -15032,6 +15048,18 @@ async function getInboxManagementOperations(session) {
|
|
|
15032
15048
|
throw new ApiError("The Inbox operation catalog response was malformed.", 502, "malformed_response");
|
|
15033
15049
|
}
|
|
15034
15050
|
}
|
|
15051
|
+
async function listInboxOrganizations(session) {
|
|
15052
|
+
const res = await cliApiFetch(`${apiBase()}/api/v1/admin/orgs`, {
|
|
15053
|
+
headers: { Authorization: `Bearer ${session}` }
|
|
15054
|
+
});
|
|
15055
|
+
if (!res.ok) throw await parseError(res);
|
|
15056
|
+
const json = await res.json();
|
|
15057
|
+
try {
|
|
15058
|
+
return InboxOrganizationsResponseSchema.parse(json.data);
|
|
15059
|
+
} catch {
|
|
15060
|
+
throw new ApiError("The organization list response was malformed.", 502, "malformed_response");
|
|
15061
|
+
}
|
|
15062
|
+
}
|
|
15035
15063
|
async function callInboxManagement(session, orgId, call) {
|
|
15036
15064
|
const res = await cliApiFetch(`${apiBase()}/api/v1/inbox/manage`, {
|
|
15037
15065
|
method: "POST",
|
|
@@ -20092,10 +20120,11 @@ var init_knowledge = __esm({
|
|
|
20092
20120
|
var inbox_management_exports = {};
|
|
20093
20121
|
__export(inbox_management_exports, {
|
|
20094
20122
|
runInboxManage: () => runInboxManage,
|
|
20095
|
-
runInboxOperations: () => runInboxOperations
|
|
20123
|
+
runInboxOperations: () => runInboxOperations,
|
|
20124
|
+
runInboxOrganizations: () => runInboxOrganizations
|
|
20096
20125
|
});
|
|
20097
20126
|
import { readFile as readFile8 } from "node:fs/promises";
|
|
20098
|
-
async function
|
|
20127
|
+
async function inboxSession() {
|
|
20099
20128
|
const token = await resolveSession();
|
|
20100
20129
|
if (!token)
|
|
20101
20130
|
throw Object.assign(new Error("Run `bamboo-agents login` first."), {
|
|
@@ -20108,13 +20137,26 @@ async function sessionForOrg(org) {
|
|
|
20108
20137
|
),
|
|
20109
20138
|
{ code: "organization_scope_required" }
|
|
20110
20139
|
);
|
|
20111
|
-
if (!org)
|
|
20112
|
-
throw Object.assign(
|
|
20113
|
-
new Error("Pass the customer organization with --org."),
|
|
20114
|
-
{ code: "organization_scope_required" }
|
|
20115
|
-
);
|
|
20116
20140
|
return token;
|
|
20117
20141
|
}
|
|
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
|
+
}
|
|
20118
20160
|
async function inputObject(value) {
|
|
20119
20161
|
const raw = value.startsWith("@") ? await readFile8(value.slice(1), "utf8") : value;
|
|
20120
20162
|
const parsed = JSON.parse(raw);
|
|
@@ -20156,9 +20198,25 @@ async function runInboxOperations(options) {
|
|
|
20156
20198
|
fail(error, options);
|
|
20157
20199
|
}
|
|
20158
20200
|
}
|
|
20201
|
+
async function runInboxOrganizations(options) {
|
|
20202
|
+
try {
|
|
20203
|
+
const session = await inboxSession();
|
|
20204
|
+
const { orgs } = await listInboxOrganizations(session);
|
|
20205
|
+
const query = options.query?.trim() ?? "";
|
|
20206
|
+
const normalized = query.toLowerCase();
|
|
20207
|
+
const organizations = query ? orgs.filter((org) => org.name.toLowerCase().includes(normalized) || org.id.toLowerCase().includes(normalized)) : orgs;
|
|
20208
|
+
for (const org of organizations) human(` ${org.name} (${org.id}) [${org.status}]`, options);
|
|
20209
|
+
emitSuccess({ organizations, count: organizations.length, query: query || null }, options);
|
|
20210
|
+
} catch (error) {
|
|
20211
|
+
fail(error, options);
|
|
20212
|
+
}
|
|
20213
|
+
}
|
|
20159
20214
|
async function runInboxManage(options) {
|
|
20160
20215
|
try {
|
|
20161
|
-
const session = await
|
|
20216
|
+
const session = await inboxSession();
|
|
20217
|
+
const organization = await resolveOrganization(session, options.org);
|
|
20218
|
+
const orgId = organization.id;
|
|
20219
|
+
if (organization.name) human(`Operating as organization: ${organization.name} (${orgId})`, options);
|
|
20162
20220
|
if (!InboxManageOperationSchema.safeParse(options.operation).success) {
|
|
20163
20221
|
throw Object.assign(
|
|
20164
20222
|
new Error(`Unsupported Inbox operation: ${options.operation}`),
|
|
@@ -20214,18 +20272,18 @@ async function runInboxManage(options) {
|
|
|
20214
20272
|
});
|
|
20215
20273
|
const preview = await callInboxManagement(
|
|
20216
20274
|
session,
|
|
20217
|
-
|
|
20275
|
+
orgId,
|
|
20218
20276
|
previewCall
|
|
20219
20277
|
);
|
|
20220
|
-
if (preview.scope.org_id !==
|
|
20278
|
+
if (preview.scope.org_id !== orgId)
|
|
20221
20279
|
throw Object.assign(
|
|
20222
20280
|
new Error(
|
|
20223
|
-
`Requested organization ${
|
|
20281
|
+
`Requested organization ${orgId} but server resolved ${preview.scope.org_id}.`
|
|
20224
20282
|
),
|
|
20225
20283
|
{ code: "organization_scope_mismatch" }
|
|
20226
20284
|
);
|
|
20227
20285
|
const suppliedVersion = input.source_version ?? input.subject_revision;
|
|
20228
|
-
if (!isProposal && preview.source_version
|
|
20286
|
+
if (!isProposal && !inboxSourceVersionsMatch(preview.source_version, suppliedVersion))
|
|
20229
20287
|
throw Object.assign(
|
|
20230
20288
|
new Error(
|
|
20231
20289
|
`The reviewed source revision ${String(suppliedVersion)} is stale; current revision is ${preview.source_version}.`
|
|
@@ -20252,14 +20310,15 @@ async function runInboxManage(options) {
|
|
|
20252
20310
|
) : String(
|
|
20253
20311
|
input.opportunity_id ?? input.pr_number ?? input.id ?? input.task_id ?? "unknown"
|
|
20254
20312
|
);
|
|
20255
|
-
|
|
20256
|
-
|
|
20257
|
-
|
|
20258
|
-
);
|
|
20313
|
+
const command = input.command ? `; command: ${String(input.command)}` : "";
|
|
20314
|
+
const reason = input.reason ? `; reason: ${String(input.reason)}` : "";
|
|
20315
|
+
const commandId = input.command_id ? `; command ID: ${String(input.command_id)}` : "";
|
|
20316
|
+
const previewSummary = `Approval preview \u2014 organization: ${preview.scope.org_name} (${preview.scope.org_id}); brand: ${preview.scope.brand_name ?? "all brands"}; operation: ${options.operation}; source item: ${sourceItem}; source version: ${preview.source_version ?? "new proposal"}; effect: ${mutation?.effect ?? "unspecified"}; reversible: ${String(mutation?.reversible ?? "unspecified")}${command}${reason}${commandId}${recipient}${wording}`;
|
|
20317
|
+
human(previewSummary, options);
|
|
20259
20318
|
if (!options.approve) {
|
|
20260
20319
|
throw Object.assign(
|
|
20261
20320
|
new Error(
|
|
20262
|
-
"This operation changes customer state. Review the preview, obtain approval for its exact scope, source version, effect, and reversibility, then re-run with --approve
|
|
20321
|
+
`${options.quiet ? `${previewSummary}. ` : ""}This operation changes customer state. Review the preview, obtain approval for its exact scope, source version, effect, and reversibility, then re-run with --approve.`
|
|
20263
20322
|
),
|
|
20264
20323
|
{ code: "approval_required" }
|
|
20265
20324
|
);
|
|
@@ -20277,11 +20336,11 @@ async function runInboxManage(options) {
|
|
|
20277
20336
|
operation: options.operation,
|
|
20278
20337
|
input
|
|
20279
20338
|
});
|
|
20280
|
-
const result = await callInboxManagement(session,
|
|
20281
|
-
if (result.scope.org_id !==
|
|
20339
|
+
const result = await callInboxManagement(session, orgId, call);
|
|
20340
|
+
if (result.scope.org_id !== orgId)
|
|
20282
20341
|
throw Object.assign(
|
|
20283
20342
|
new Error(
|
|
20284
|
-
`Requested organization ${
|
|
20343
|
+
`Requested organization ${orgId} but server resolved ${result.scope.org_id}.`
|
|
20285
20344
|
),
|
|
20286
20345
|
{ code: "organization_scope_mismatch" }
|
|
20287
20346
|
);
|
|
@@ -20294,7 +20353,7 @@ async function runInboxManage(options) {
|
|
|
20294
20353
|
fail(error, options);
|
|
20295
20354
|
}
|
|
20296
20355
|
}
|
|
20297
|
-
var MUTATION_EFFECTS, ANNOTATION_COMMAND_EFFECTS;
|
|
20356
|
+
var UUID, MUTATION_EFFECTS, ANNOTATION_COMMAND_EFFECTS;
|
|
20298
20357
|
var init_inbox_management2 = __esm({
|
|
20299
20358
|
"src/commands/inbox-management.ts"() {
|
|
20300
20359
|
"use strict";
|
|
@@ -20303,6 +20362,7 @@ var init_inbox_management2 = __esm({
|
|
|
20303
20362
|
init_api();
|
|
20304
20363
|
init_credentials();
|
|
20305
20364
|
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;
|
|
20306
20366
|
MUTATION_EFFECTS = {
|
|
20307
20367
|
"change.approve": { effect: "merge_workspace_change", reversible: false },
|
|
20308
20368
|
"change.decline": {
|
|
@@ -22537,7 +22597,11 @@ inbox.command("operations").description("List the supported customer Inbox opera
|
|
|
22537
22597
|
const { runInboxOperations: runInboxOperations2 } = await Promise.resolve().then(() => (init_inbox_management2(), inbox_management_exports));
|
|
22538
22598
|
await runInboxOperations2(options);
|
|
22539
22599
|
});
|
|
22540
|
-
inbox.command("
|
|
22600
|
+
inbox.command("organizations [query]").description("List or search customer organizations available for --org").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 (query, options) => {
|
|
22601
|
+
const { runInboxOrganizations: runInboxOrganizations2 } = await Promise.resolve().then(() => (init_inbox_management2(), inbox_management_exports));
|
|
22602
|
+
await runInboxOrganizations2({ query, ...options });
|
|
22603
|
+
});
|
|
22604
|
+
inbox.command("manage").description("Call one catalog-advertised customer Inbox operation").argument("<operation>", "Exact operation name").requiredOption("--input <json-or-@file>", "JSON object, inline or loaded from @path").requiredOption("--org <uuid-or-name>", "Explicit customer organization UUID or unique name").option("--approve", "Confirm the exact displayed mutation after user approval").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 (operation, options) => {
|
|
22541
22605
|
const { runInboxManage: runInboxManage2 } = await Promise.resolve().then(() => (init_inbox_management2(), inbox_management_exports));
|
|
22542
22606
|
await runInboxManage2({ operation, ...options });
|
|
22543
22607
|
});
|