@skillrecordings/cli 0.5.0 → 0.6.0
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/index.js +444 -44
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -91670,6 +91670,77 @@ function registerFaqCommands(program3) {
|
|
|
91670
91670
|
// src/commands/front/index.ts
|
|
91671
91671
|
init_esm_shims();
|
|
91672
91672
|
|
|
91673
|
+
// src/commands/front/api.ts
|
|
91674
|
+
init_esm_shims();
|
|
91675
|
+
function getFrontClient() {
|
|
91676
|
+
const apiToken = process.env.FRONT_API_TOKEN;
|
|
91677
|
+
if (!apiToken) {
|
|
91678
|
+
throw new Error("FRONT_API_TOKEN environment variable is required");
|
|
91679
|
+
}
|
|
91680
|
+
return createInstrumentedFrontClient({ apiToken });
|
|
91681
|
+
}
|
|
91682
|
+
async function apiPassthrough(method, endpoint, options) {
|
|
91683
|
+
const front = getFrontClient();
|
|
91684
|
+
const httpMethod = method.toUpperCase();
|
|
91685
|
+
let body = void 0;
|
|
91686
|
+
if (options.data) {
|
|
91687
|
+
try {
|
|
91688
|
+
body = JSON.parse(options.data);
|
|
91689
|
+
} catch {
|
|
91690
|
+
throw new Error("Invalid JSON in --data");
|
|
91691
|
+
}
|
|
91692
|
+
}
|
|
91693
|
+
const normalizedEndpoint = endpoint.startsWith("/") ? endpoint : `/${endpoint}`;
|
|
91694
|
+
let result;
|
|
91695
|
+
switch (httpMethod) {
|
|
91696
|
+
case "GET":
|
|
91697
|
+
result = await front.raw.get(normalizedEndpoint);
|
|
91698
|
+
break;
|
|
91699
|
+
case "POST":
|
|
91700
|
+
result = await front.raw.post(normalizedEndpoint, body);
|
|
91701
|
+
break;
|
|
91702
|
+
case "PATCH":
|
|
91703
|
+
result = await front.raw.patch(normalizedEndpoint, body);
|
|
91704
|
+
break;
|
|
91705
|
+
case "PUT":
|
|
91706
|
+
result = await front.raw.put(normalizedEndpoint, body);
|
|
91707
|
+
break;
|
|
91708
|
+
case "DELETE":
|
|
91709
|
+
result = await front.raw.delete(normalizedEndpoint);
|
|
91710
|
+
break;
|
|
91711
|
+
default:
|
|
91712
|
+
throw new Error(
|
|
91713
|
+
`Unsupported method: ${method}. Use GET, POST, PATCH, PUT, or DELETE.`
|
|
91714
|
+
);
|
|
91715
|
+
}
|
|
91716
|
+
console.log(JSON.stringify(result, null, 2));
|
|
91717
|
+
}
|
|
91718
|
+
function registerApiCommand(frontCommand) {
|
|
91719
|
+
frontCommand.command("api").description("Raw Front API request (escape hatch)").argument("<method>", "HTTP method (GET, POST, PATCH, PUT, DELETE)").argument(
|
|
91720
|
+
"<endpoint>",
|
|
91721
|
+
"API endpoint path (e.g., /me, /conversations/cnv_xxx)"
|
|
91722
|
+
).option("--data <json>", "Request body as JSON string").action(
|
|
91723
|
+
async (method, endpoint, options) => {
|
|
91724
|
+
try {
|
|
91725
|
+
await apiPassthrough(method, endpoint, options);
|
|
91726
|
+
} catch (error) {
|
|
91727
|
+
console.error(
|
|
91728
|
+
JSON.stringify(
|
|
91729
|
+
{
|
|
91730
|
+
error: error instanceof Error ? error.message : "Unknown error",
|
|
91731
|
+
method: method.toUpperCase(),
|
|
91732
|
+
endpoint
|
|
91733
|
+
},
|
|
91734
|
+
null,
|
|
91735
|
+
2
|
|
91736
|
+
)
|
|
91737
|
+
);
|
|
91738
|
+
process.exit(1);
|
|
91739
|
+
}
|
|
91740
|
+
}
|
|
91741
|
+
);
|
|
91742
|
+
}
|
|
91743
|
+
|
|
91673
91744
|
// src/commands/front/archive.ts
|
|
91674
91745
|
init_esm_shims();
|
|
91675
91746
|
|
|
@@ -91721,6 +91792,31 @@ function conversationActions(convId) {
|
|
|
91721
91792
|
description: "Archive this conversation",
|
|
91722
91793
|
destructive: true
|
|
91723
91794
|
},
|
|
91795
|
+
{
|
|
91796
|
+
action: "assign",
|
|
91797
|
+
command: `skill front assign ${convId} <teammate-id> --json`,
|
|
91798
|
+
description: "Assign to a teammate"
|
|
91799
|
+
},
|
|
91800
|
+
{
|
|
91801
|
+
action: "unassign",
|
|
91802
|
+
command: `skill front assign ${convId} --unassign --json`,
|
|
91803
|
+
description: "Remove assignee"
|
|
91804
|
+
},
|
|
91805
|
+
{
|
|
91806
|
+
action: "tag",
|
|
91807
|
+
command: `skill front tag ${convId} <tag-name-or-id> --json`,
|
|
91808
|
+
description: "Add a tag"
|
|
91809
|
+
},
|
|
91810
|
+
{
|
|
91811
|
+
action: "untag",
|
|
91812
|
+
command: `skill front untag ${convId} <tag-name-or-id> --json`,
|
|
91813
|
+
description: "Remove a tag"
|
|
91814
|
+
},
|
|
91815
|
+
{
|
|
91816
|
+
action: "reply",
|
|
91817
|
+
command: `skill front reply ${convId} --body "<text>" --json`,
|
|
91818
|
+
description: "Create a draft reply"
|
|
91819
|
+
},
|
|
91724
91820
|
{
|
|
91725
91821
|
action: "tags",
|
|
91726
91822
|
command: `skill front tags list --json`,
|
|
@@ -91757,6 +91853,11 @@ function conversationListActions(inboxId) {
|
|
|
91757
91853
|
action: "triage",
|
|
91758
91854
|
command: `skill front triage --inbox ${inboxId} --json`,
|
|
91759
91855
|
description: "Triage conversations"
|
|
91856
|
+
},
|
|
91857
|
+
{
|
|
91858
|
+
action: "report",
|
|
91859
|
+
command: `skill front report --inbox ${inboxId} --json`,
|
|
91860
|
+
description: "Generate inbox report"
|
|
91760
91861
|
}
|
|
91761
91862
|
);
|
|
91762
91863
|
}
|
|
@@ -91861,7 +91962,7 @@ function teammateListLinks(teammates) {
|
|
|
91861
91962
|
}
|
|
91862
91963
|
|
|
91863
91964
|
// src/commands/front/archive.ts
|
|
91864
|
-
function
|
|
91965
|
+
function getFrontClient2() {
|
|
91865
91966
|
const apiToken = process.env.FRONT_API_TOKEN;
|
|
91866
91967
|
if (!apiToken) {
|
|
91867
91968
|
throw new Error("FRONT_API_TOKEN environment variable is required");
|
|
@@ -91885,7 +91986,7 @@ async function archiveConversation(front, convId) {
|
|
|
91885
91986
|
}
|
|
91886
91987
|
async function archiveConversations(convId, additionalIds, options) {
|
|
91887
91988
|
try {
|
|
91888
|
-
const front =
|
|
91989
|
+
const front = getFrontClient2();
|
|
91889
91990
|
const allIds = [convId, ...additionalIds];
|
|
91890
91991
|
if (options.json) {
|
|
91891
91992
|
const results2 = await Promise.all(
|
|
@@ -91960,6 +92061,75 @@ function registerArchiveCommand(frontCommand) {
|
|
|
91960
92061
|
frontCommand.command("archive").description("Archive one or more conversations by ID").argument("<id>", "Conversation ID (e.g., cnv_xxx)").argument("[ids...]", "Additional conversation IDs to archive").option("--json", "Output as JSON").action(archiveConversations);
|
|
91961
92062
|
}
|
|
91962
92063
|
|
|
92064
|
+
// src/commands/front/assign.ts
|
|
92065
|
+
init_esm_shims();
|
|
92066
|
+
function getFrontClient3() {
|
|
92067
|
+
const apiToken = process.env.FRONT_API_TOKEN;
|
|
92068
|
+
if (!apiToken) {
|
|
92069
|
+
throw new Error("FRONT_API_TOKEN environment variable is required");
|
|
92070
|
+
}
|
|
92071
|
+
return createInstrumentedFrontClient({ apiToken });
|
|
92072
|
+
}
|
|
92073
|
+
function normalizeId2(idOrUrl) {
|
|
92074
|
+
return idOrUrl.startsWith("http") ? idOrUrl.split("/").pop() : idOrUrl;
|
|
92075
|
+
}
|
|
92076
|
+
async function assignConversation(conversationId, teammateId, options) {
|
|
92077
|
+
try {
|
|
92078
|
+
const front = getFrontClient3();
|
|
92079
|
+
const convId = normalizeId2(conversationId);
|
|
92080
|
+
if (!teammateId && !options.unassign) {
|
|
92081
|
+
throw new Error(
|
|
92082
|
+
"Provide a teammate ID or use --unassign to remove assignment"
|
|
92083
|
+
);
|
|
92084
|
+
}
|
|
92085
|
+
if (teammateId && options.unassign) {
|
|
92086
|
+
throw new Error("Cannot provide both teammate ID and --unassign");
|
|
92087
|
+
}
|
|
92088
|
+
const assigneeId = options.unassign ? "" : normalizeId2(teammateId);
|
|
92089
|
+
await front.conversations.updateAssignee(convId, assigneeId);
|
|
92090
|
+
if (options.json) {
|
|
92091
|
+
console.log(
|
|
92092
|
+
JSON.stringify(
|
|
92093
|
+
hateoasWrap({
|
|
92094
|
+
type: "assign-result",
|
|
92095
|
+
command: options.unassign ? `skill front assign ${convId} --unassign --json` : `skill front assign ${convId} ${assigneeId} --json`,
|
|
92096
|
+
data: {
|
|
92097
|
+
id: convId,
|
|
92098
|
+
assignee: options.unassign ? null : assigneeId,
|
|
92099
|
+
success: true
|
|
92100
|
+
}
|
|
92101
|
+
}),
|
|
92102
|
+
null,
|
|
92103
|
+
2
|
|
92104
|
+
)
|
|
92105
|
+
);
|
|
92106
|
+
} else {
|
|
92107
|
+
if (options.unassign) {
|
|
92108
|
+
console.log(`\u2705 Unassigned ${convId}`);
|
|
92109
|
+
} else {
|
|
92110
|
+
console.log(`\u2705 Assigned ${convId} to ${assigneeId}`);
|
|
92111
|
+
}
|
|
92112
|
+
}
|
|
92113
|
+
} catch (error) {
|
|
92114
|
+
if (options.json) {
|
|
92115
|
+
console.error(
|
|
92116
|
+
JSON.stringify({
|
|
92117
|
+
error: error instanceof Error ? error.message : "Unknown error"
|
|
92118
|
+
})
|
|
92119
|
+
);
|
|
92120
|
+
} else {
|
|
92121
|
+
console.error(
|
|
92122
|
+
"Error:",
|
|
92123
|
+
error instanceof Error ? error.message : "Unknown error"
|
|
92124
|
+
);
|
|
92125
|
+
}
|
|
92126
|
+
process.exit(1);
|
|
92127
|
+
}
|
|
92128
|
+
}
|
|
92129
|
+
function registerAssignCommand(frontCommand) {
|
|
92130
|
+
frontCommand.command("assign").description("Assign a conversation to a teammate").argument("<conversation-id>", "Conversation ID (cnv_xxx)").argument("[teammate-id]", "Teammate ID (tea_xxx) - omit with --unassign").option("--unassign", "Remove assignee").option("--json", "Output as JSON").action(assignConversation);
|
|
92131
|
+
}
|
|
92132
|
+
|
|
91963
92133
|
// src/commands/front/bulk-archive.ts
|
|
91964
92134
|
init_esm_shims();
|
|
91965
92135
|
function parseDuration(duration) {
|
|
@@ -92247,9 +92417,133 @@ function registerBulkArchiveCommand(parent2) {
|
|
|
92247
92417
|
).option("--dry-run", "Preview without archiving").option("--json", "JSON output").action(bulkArchiveConversations);
|
|
92248
92418
|
}
|
|
92249
92419
|
|
|
92420
|
+
// src/commands/front/conversation-tag.ts
|
|
92421
|
+
init_esm_shims();
|
|
92422
|
+
function getFrontClient4() {
|
|
92423
|
+
const apiToken = process.env.FRONT_API_TOKEN;
|
|
92424
|
+
if (!apiToken) {
|
|
92425
|
+
throw new Error("FRONT_API_TOKEN environment variable is required");
|
|
92426
|
+
}
|
|
92427
|
+
return createInstrumentedFrontClient({ apiToken });
|
|
92428
|
+
}
|
|
92429
|
+
function normalizeId3(idOrUrl) {
|
|
92430
|
+
return idOrUrl.startsWith("http") ? idOrUrl.split("/").pop() : idOrUrl;
|
|
92431
|
+
}
|
|
92432
|
+
async function resolveTag(front, tagNameOrId) {
|
|
92433
|
+
const normalized = normalizeId3(tagNameOrId);
|
|
92434
|
+
const data2 = await front.raw.get("/tags");
|
|
92435
|
+
const tags = data2._results ?? [];
|
|
92436
|
+
if (normalized.startsWith("tag_")) {
|
|
92437
|
+
const match2 = tags.find((t2) => t2.id === normalized);
|
|
92438
|
+
return { id: normalized, name: match2?.name ?? normalized };
|
|
92439
|
+
}
|
|
92440
|
+
const needle = tagNameOrId.trim().toLowerCase();
|
|
92441
|
+
const match = tags.find((t2) => t2.name.toLowerCase() === needle);
|
|
92442
|
+
if (!match) {
|
|
92443
|
+
throw new Error(
|
|
92444
|
+
`Tag not found: "${tagNameOrId}". Use \`skill front tags list\` to see available tags.`
|
|
92445
|
+
);
|
|
92446
|
+
}
|
|
92447
|
+
return { id: match.id, name: match.name };
|
|
92448
|
+
}
|
|
92449
|
+
async function tagConversation(convId, tagNameOrId, options) {
|
|
92450
|
+
try {
|
|
92451
|
+
const front = getFrontClient4();
|
|
92452
|
+
const normalizedConvId = normalizeId3(convId);
|
|
92453
|
+
const tag = await resolveTag(front, tagNameOrId);
|
|
92454
|
+
await front.conversations.addTag(normalizedConvId, tag.id);
|
|
92455
|
+
if (options.json) {
|
|
92456
|
+
console.log(
|
|
92457
|
+
JSON.stringify(
|
|
92458
|
+
hateoasWrap({
|
|
92459
|
+
type: "tag-result",
|
|
92460
|
+
command: `skill front tag ${normalizedConvId} ${tagNameOrId} --json`,
|
|
92461
|
+
data: {
|
|
92462
|
+
conversationId: normalizedConvId,
|
|
92463
|
+
tagId: tag.id,
|
|
92464
|
+
tagName: tag.name,
|
|
92465
|
+
action: "added"
|
|
92466
|
+
}
|
|
92467
|
+
}),
|
|
92468
|
+
null,
|
|
92469
|
+
2
|
|
92470
|
+
)
|
|
92471
|
+
);
|
|
92472
|
+
return;
|
|
92473
|
+
}
|
|
92474
|
+
console.log(
|
|
92475
|
+
`
|
|
92476
|
+
\u2705 Tagged ${normalizedConvId} with "${tag.name}" (${tag.id})
|
|
92477
|
+
`
|
|
92478
|
+
);
|
|
92479
|
+
} catch (error) {
|
|
92480
|
+
if (options.json) {
|
|
92481
|
+
console.error(
|
|
92482
|
+
JSON.stringify({
|
|
92483
|
+
error: error instanceof Error ? error.message : "Unknown error"
|
|
92484
|
+
})
|
|
92485
|
+
);
|
|
92486
|
+
} else {
|
|
92487
|
+
console.error(
|
|
92488
|
+
"Error:",
|
|
92489
|
+
error instanceof Error ? error.message : "Unknown error"
|
|
92490
|
+
);
|
|
92491
|
+
}
|
|
92492
|
+
process.exit(1);
|
|
92493
|
+
}
|
|
92494
|
+
}
|
|
92495
|
+
async function untagConversation(convId, tagNameOrId, options) {
|
|
92496
|
+
try {
|
|
92497
|
+
const front = getFrontClient4();
|
|
92498
|
+
const normalizedConvId = normalizeId3(convId);
|
|
92499
|
+
const tag = await resolveTag(front, tagNameOrId);
|
|
92500
|
+
await front.conversations.removeTag(normalizedConvId, tag.id);
|
|
92501
|
+
if (options.json) {
|
|
92502
|
+
console.log(
|
|
92503
|
+
JSON.stringify(
|
|
92504
|
+
hateoasWrap({
|
|
92505
|
+
type: "untag-result",
|
|
92506
|
+
command: `skill front untag ${normalizedConvId} ${tagNameOrId} --json`,
|
|
92507
|
+
data: {
|
|
92508
|
+
conversationId: normalizedConvId,
|
|
92509
|
+
tagId: tag.id,
|
|
92510
|
+
tagName: tag.name,
|
|
92511
|
+
action: "removed"
|
|
92512
|
+
}
|
|
92513
|
+
}),
|
|
92514
|
+
null,
|
|
92515
|
+
2
|
|
92516
|
+
)
|
|
92517
|
+
);
|
|
92518
|
+
return;
|
|
92519
|
+
}
|
|
92520
|
+
console.log(`
|
|
92521
|
+
\u2705 Removed tag "${tag.name}" from ${normalizedConvId}
|
|
92522
|
+
`);
|
|
92523
|
+
} catch (error) {
|
|
92524
|
+
if (options.json) {
|
|
92525
|
+
console.error(
|
|
92526
|
+
JSON.stringify({
|
|
92527
|
+
error: error instanceof Error ? error.message : "Unknown error"
|
|
92528
|
+
})
|
|
92529
|
+
);
|
|
92530
|
+
} else {
|
|
92531
|
+
console.error(
|
|
92532
|
+
"Error:",
|
|
92533
|
+
error instanceof Error ? error.message : "Unknown error"
|
|
92534
|
+
);
|
|
92535
|
+
}
|
|
92536
|
+
process.exit(1);
|
|
92537
|
+
}
|
|
92538
|
+
}
|
|
92539
|
+
function registerConversationTagCommands(frontCommand) {
|
|
92540
|
+
frontCommand.command("tag").description("Add a tag to a conversation").argument("<conversation-id>", "Conversation ID (cnv_xxx)").argument("<tag-name-or-id>", "Tag name or ID (tag_xxx)").option("--json", "Output as JSON").action(tagConversation);
|
|
92541
|
+
frontCommand.command("untag").description("Remove a tag from a conversation").argument("<conversation-id>", "Conversation ID (cnv_xxx)").argument("<tag-name-or-id>", "Tag name or ID (tag_xxx)").option("--json", "Output as JSON").action(untagConversation);
|
|
92542
|
+
}
|
|
92543
|
+
|
|
92250
92544
|
// src/commands/front/inbox.ts
|
|
92251
92545
|
init_esm_shims();
|
|
92252
|
-
function
|
|
92546
|
+
function getFrontClient5() {
|
|
92253
92547
|
const apiToken = process.env.FRONT_API_TOKEN;
|
|
92254
92548
|
if (!apiToken) {
|
|
92255
92549
|
throw new Error("FRONT_API_TOKEN environment variable is required");
|
|
@@ -92264,12 +92558,12 @@ function formatTimestamp(ts) {
|
|
|
92264
92558
|
minute: "2-digit"
|
|
92265
92559
|
});
|
|
92266
92560
|
}
|
|
92267
|
-
function
|
|
92561
|
+
function normalizeId4(idOrUrl) {
|
|
92268
92562
|
return idOrUrl.startsWith("http") ? idOrUrl.split("/").pop() : idOrUrl;
|
|
92269
92563
|
}
|
|
92270
92564
|
async function findInbox(nameOrId) {
|
|
92271
|
-
const front =
|
|
92272
|
-
const normalizedId =
|
|
92565
|
+
const front = getFrontClient5();
|
|
92566
|
+
const normalizedId = normalizeId4(nameOrId);
|
|
92273
92567
|
if (normalizedId.startsWith("inb_")) {
|
|
92274
92568
|
try {
|
|
92275
92569
|
const inbox = await front.inboxes.get(normalizedId);
|
|
@@ -92286,7 +92580,7 @@ async function findInbox(nameOrId) {
|
|
|
92286
92580
|
}
|
|
92287
92581
|
async function listInboxes(options) {
|
|
92288
92582
|
try {
|
|
92289
|
-
const front =
|
|
92583
|
+
const front = getFrontClient5();
|
|
92290
92584
|
const inboxList = await front.inboxes.list();
|
|
92291
92585
|
const inboxes = inboxList._results ?? [];
|
|
92292
92586
|
if (options.json) {
|
|
@@ -92337,35 +92631,59 @@ async function listInboxes(options) {
|
|
|
92337
92631
|
}
|
|
92338
92632
|
async function listConversations(inboxNameOrId, options) {
|
|
92339
92633
|
try {
|
|
92340
|
-
const front =
|
|
92634
|
+
const front = getFrontClient5();
|
|
92341
92635
|
const inbox = await findInbox(inboxNameOrId);
|
|
92342
92636
|
if (!inbox) {
|
|
92343
92637
|
throw new Error(`Inbox not found: ${inboxNameOrId}`);
|
|
92344
92638
|
}
|
|
92639
|
+
const totalLimit = parseInt(String(options.limit ?? "50"), 10);
|
|
92640
|
+
const resolvedLimit = Number.isFinite(totalLimit) && totalLimit > 0 ? totalLimit : void 0;
|
|
92345
92641
|
const filters2 = [];
|
|
92346
92642
|
if (options.status) {
|
|
92347
|
-
filters2.push(`status
|
|
92643
|
+
filters2.push(`status: ${options.status}`);
|
|
92348
92644
|
}
|
|
92349
92645
|
if (options.tag) {
|
|
92350
|
-
filters2.push(`tag:"${options.tag}"`);
|
|
92646
|
+
filters2.push(`tag: "${options.tag}"`);
|
|
92351
92647
|
}
|
|
92352
|
-
const queryParts = [];
|
|
92353
|
-
if (
|
|
92354
|
-
queryParts.push(`q=${encodeURIComponent(
|
|
92648
|
+
const queryParts = ["limit=50"];
|
|
92649
|
+
if (options.status) {
|
|
92650
|
+
queryParts.push(`q[statuses][]=${encodeURIComponent(options.status)}`);
|
|
92355
92651
|
}
|
|
92356
|
-
if (options.
|
|
92357
|
-
queryParts.push(`
|
|
92652
|
+
if (options.tag) {
|
|
92653
|
+
queryParts.push(`q=${encodeURIComponent(`tag:"${options.tag}"`)}`);
|
|
92654
|
+
}
|
|
92655
|
+
const queryString = `?${queryParts.join("&")}`;
|
|
92656
|
+
const conversations = [];
|
|
92657
|
+
let nextUrl = `/inboxes/${inbox.id}/conversations${queryString}`;
|
|
92658
|
+
while (nextUrl) {
|
|
92659
|
+
const response = await front.raw.get(nextUrl);
|
|
92660
|
+
conversations.push(...response._results ?? []);
|
|
92661
|
+
if (!options.json) {
|
|
92662
|
+
process.stdout.write(
|
|
92663
|
+
`\r Fetched ${conversations.length} conversations...`
|
|
92664
|
+
);
|
|
92665
|
+
}
|
|
92666
|
+
nextUrl = response._pagination?.next || null;
|
|
92667
|
+
if (resolvedLimit && conversations.length >= resolvedLimit) {
|
|
92668
|
+
conversations.splice(resolvedLimit);
|
|
92669
|
+
break;
|
|
92670
|
+
}
|
|
92671
|
+
}
|
|
92672
|
+
if (!options.json) {
|
|
92673
|
+
console.log(`
|
|
92674
|
+
Total: ${conversations.length} conversations
|
|
92675
|
+
`);
|
|
92358
92676
|
}
|
|
92359
|
-
const queryString = queryParts.length > 0 ? `?${queryParts.join("&")}` : "";
|
|
92360
|
-
const response = await front.raw.get(`/inboxes/${inbox.id}/conversations${queryString}`);
|
|
92361
|
-
const conversations = response._results ?? [];
|
|
92362
92677
|
if (options.json) {
|
|
92363
92678
|
console.log(
|
|
92364
92679
|
JSON.stringify(
|
|
92365
92680
|
hateoasWrap({
|
|
92366
92681
|
type: "conversation-list",
|
|
92367
92682
|
command: `skill front inbox ${inbox.id} --json`,
|
|
92368
|
-
data:
|
|
92683
|
+
data: {
|
|
92684
|
+
total: conversations.length,
|
|
92685
|
+
conversations
|
|
92686
|
+
},
|
|
92369
92687
|
links: conversationListLinks(
|
|
92370
92688
|
conversations.map((c) => ({ id: c.id, subject: c.subject })),
|
|
92371
92689
|
inbox.id
|
|
@@ -92405,12 +92723,6 @@ async function listConversations(inboxNameOrId, options) {
|
|
|
92405
92723
|
console.log(` Created: ${time}`);
|
|
92406
92724
|
}
|
|
92407
92725
|
console.log("");
|
|
92408
|
-
if (response._pagination?.next) {
|
|
92409
|
-
console.log(
|
|
92410
|
-
` \u{1F4A1} More conversations available. Use --limit to adjust results.`
|
|
92411
|
-
);
|
|
92412
|
-
console.log("");
|
|
92413
|
-
}
|
|
92414
92726
|
} catch (error) {
|
|
92415
92727
|
if (options.json) {
|
|
92416
92728
|
console.error(
|
|
@@ -92593,6 +92905,74 @@ function registerPullCommand(parent2) {
|
|
|
92593
92905
|
parent2.command("pull").description("Export conversations to JSON for eval datasets").option("-i, --inbox <id>", "Inbox ID to pull from").option("-l, --limit <n>", "Max conversations to pull", parseInt).option("-o, --output <file>", "Output file path").option("-f, --filter <term>", "Filter by subject/tag containing term").option("--json", "JSON output").action(pullConversations);
|
|
92594
92906
|
}
|
|
92595
92907
|
|
|
92908
|
+
// src/commands/front/reply.ts
|
|
92909
|
+
init_esm_shims();
|
|
92910
|
+
function getFrontClient6() {
|
|
92911
|
+
const apiToken = process.env.FRONT_API_TOKEN;
|
|
92912
|
+
if (!apiToken) {
|
|
92913
|
+
throw new Error("FRONT_API_TOKEN environment variable is required");
|
|
92914
|
+
}
|
|
92915
|
+
return createInstrumentedFrontClient({ apiToken });
|
|
92916
|
+
}
|
|
92917
|
+
function normalizeId5(idOrUrl) {
|
|
92918
|
+
return idOrUrl.startsWith("http") ? idOrUrl.split("/").pop() : idOrUrl;
|
|
92919
|
+
}
|
|
92920
|
+
async function replyToConversation(conversationId, options) {
|
|
92921
|
+
try {
|
|
92922
|
+
const front = getFrontClient6();
|
|
92923
|
+
const normalizedId = normalizeId5(conversationId);
|
|
92924
|
+
const draft = await front.raw.post(
|
|
92925
|
+
`/conversations/${normalizedId}/drafts`,
|
|
92926
|
+
{
|
|
92927
|
+
body: options.body,
|
|
92928
|
+
...options.author ? { author_id: options.author } : {}
|
|
92929
|
+
}
|
|
92930
|
+
);
|
|
92931
|
+
if (options.json) {
|
|
92932
|
+
console.log(
|
|
92933
|
+
JSON.stringify(
|
|
92934
|
+
hateoasWrap({
|
|
92935
|
+
type: "draft-reply",
|
|
92936
|
+
command: `skill front reply ${normalizedId} --body ${JSON.stringify(options.body)}${options.author ? ` --author ${options.author}` : ""} --json`,
|
|
92937
|
+
data: draft
|
|
92938
|
+
}),
|
|
92939
|
+
null,
|
|
92940
|
+
2
|
|
92941
|
+
)
|
|
92942
|
+
);
|
|
92943
|
+
return;
|
|
92944
|
+
}
|
|
92945
|
+
const draftId = draft.id;
|
|
92946
|
+
const bodyPreview = options.body.length > 100 ? options.body.slice(0, 100) + "..." : options.body;
|
|
92947
|
+
console.log("");
|
|
92948
|
+
console.log(`\u{1F4DD} Draft reply created on ${normalizedId}`);
|
|
92949
|
+
if (draftId) {
|
|
92950
|
+
console.log(` Draft ID: ${draftId}`);
|
|
92951
|
+
}
|
|
92952
|
+
console.log(` Body preview: ${bodyPreview}`);
|
|
92953
|
+
console.log("");
|
|
92954
|
+
console.log(` \u{1F4A1} Review and send from Front.`);
|
|
92955
|
+
console.log("");
|
|
92956
|
+
} catch (error) {
|
|
92957
|
+
if (options.json) {
|
|
92958
|
+
console.error(
|
|
92959
|
+
JSON.stringify({
|
|
92960
|
+
error: error instanceof Error ? error.message : "Unknown error"
|
|
92961
|
+
})
|
|
92962
|
+
);
|
|
92963
|
+
} else {
|
|
92964
|
+
console.error(
|
|
92965
|
+
"Error:",
|
|
92966
|
+
error instanceof Error ? error.message : "Unknown error"
|
|
92967
|
+
);
|
|
92968
|
+
}
|
|
92969
|
+
process.exit(1);
|
|
92970
|
+
}
|
|
92971
|
+
}
|
|
92972
|
+
function registerReplyCommand(frontCommand) {
|
|
92973
|
+
frontCommand.command("reply").description("Create a draft reply on a conversation").argument("<conversation-id>", "Conversation ID (cnv_xxx)").requiredOption("--body <text>", "Reply body text").option("--author <teammate-id>", "Author teammate ID").option("--json", "Output as JSON").action(replyToConversation);
|
|
92974
|
+
}
|
|
92975
|
+
|
|
92596
92976
|
// src/commands/front/report.ts
|
|
92597
92977
|
init_esm_shims();
|
|
92598
92978
|
function formatDate2(timestamp) {
|
|
@@ -93355,7 +93735,7 @@ function registerTagCommands(frontCommand) {
|
|
|
93355
93735
|
|
|
93356
93736
|
// src/commands/front/triage.ts
|
|
93357
93737
|
init_esm_shims();
|
|
93358
|
-
function
|
|
93738
|
+
function getFrontClient7() {
|
|
93359
93739
|
const apiToken = process.env.FRONT_API_TOKEN;
|
|
93360
93740
|
if (!apiToken) {
|
|
93361
93741
|
throw new Error("FRONT_API_TOKEN environment variable is required");
|
|
@@ -93410,7 +93790,7 @@ async function triageConversations(options) {
|
|
|
93410
93790
|
json = false
|
|
93411
93791
|
} = options;
|
|
93412
93792
|
try {
|
|
93413
|
-
const front =
|
|
93793
|
+
const front = getFrontClient7();
|
|
93414
93794
|
if (!json) {
|
|
93415
93795
|
console.log(`
|
|
93416
93796
|
Fetching ${status} conversations from inbox ${inbox}...`);
|
|
@@ -93577,7 +93957,7 @@ function registerTriageCommand(front) {
|
|
|
93577
93957
|
}
|
|
93578
93958
|
|
|
93579
93959
|
// src/commands/front/index.ts
|
|
93580
|
-
function
|
|
93960
|
+
function getFrontClient8() {
|
|
93581
93961
|
const apiToken = process.env.FRONT_API_TOKEN;
|
|
93582
93962
|
if (!apiToken) {
|
|
93583
93963
|
throw new Error("FRONT_API_TOKEN environment variable is required");
|
|
@@ -93603,19 +93983,19 @@ function truncate3(str2, len) {
|
|
|
93603
93983
|
if (str2.length <= len) return str2;
|
|
93604
93984
|
return str2.slice(0, len - 3) + "...";
|
|
93605
93985
|
}
|
|
93606
|
-
function
|
|
93986
|
+
function normalizeId6(idOrUrl) {
|
|
93607
93987
|
return idOrUrl.startsWith("http") ? idOrUrl.split("/").pop() : idOrUrl;
|
|
93608
93988
|
}
|
|
93609
93989
|
async function getMessage(id, options) {
|
|
93610
93990
|
try {
|
|
93611
|
-
const front =
|
|
93612
|
-
const message = await front.messages.get(
|
|
93991
|
+
const front = getFrontClient8();
|
|
93992
|
+
const message = await front.messages.get(normalizeId6(id));
|
|
93613
93993
|
if (options.json) {
|
|
93614
93994
|
console.log(
|
|
93615
93995
|
JSON.stringify(
|
|
93616
93996
|
hateoasWrap({
|
|
93617
93997
|
type: "message",
|
|
93618
|
-
command: `skill front message ${
|
|
93998
|
+
command: `skill front message ${normalizeId6(id)} --json`,
|
|
93619
93999
|
data: message,
|
|
93620
94000
|
links: messageLinks(message.id)
|
|
93621
94001
|
}),
|
|
@@ -93669,17 +94049,17 @@ async function getMessage(id, options) {
|
|
|
93669
94049
|
}
|
|
93670
94050
|
async function getConversation2(id, options) {
|
|
93671
94051
|
try {
|
|
93672
|
-
const front =
|
|
93673
|
-
const conversation = await front.conversations.get(
|
|
94052
|
+
const front = getFrontClient8();
|
|
94053
|
+
const conversation = await front.conversations.get(normalizeId6(id));
|
|
93674
94054
|
let messages;
|
|
93675
94055
|
if (options.messages) {
|
|
93676
94056
|
const messageList = await front.conversations.listMessages(
|
|
93677
|
-
|
|
94057
|
+
normalizeId6(id)
|
|
93678
94058
|
);
|
|
93679
94059
|
messages = messageList._results ?? [];
|
|
93680
94060
|
}
|
|
93681
94061
|
if (options.json) {
|
|
93682
|
-
const convId =
|
|
94062
|
+
const convId = normalizeId6(id);
|
|
93683
94063
|
console.log(
|
|
93684
94064
|
JSON.stringify(
|
|
93685
94065
|
hateoasWrap({
|
|
@@ -93782,10 +94162,18 @@ async function listTeammates(options) {
|
|
|
93782
94162
|
console.log("");
|
|
93783
94163
|
}
|
|
93784
94164
|
} catch (error) {
|
|
93785
|
-
|
|
93786
|
-
|
|
93787
|
-
|
|
93788
|
-
|
|
94165
|
+
if (options.json) {
|
|
94166
|
+
console.error(
|
|
94167
|
+
JSON.stringify({
|
|
94168
|
+
error: error instanceof Error ? error.message : "Unknown error"
|
|
94169
|
+
})
|
|
94170
|
+
);
|
|
94171
|
+
} else {
|
|
94172
|
+
console.error(
|
|
94173
|
+
"Error:",
|
|
94174
|
+
error instanceof Error ? error.message : "Unknown error"
|
|
94175
|
+
);
|
|
94176
|
+
}
|
|
93789
94177
|
process.exit(1);
|
|
93790
94178
|
}
|
|
93791
94179
|
}
|
|
@@ -93822,10 +94210,18 @@ async function getTeammate(id, options) {
|
|
|
93822
94210
|
console.log(` Available: ${teammate.is_available ? "Yes" : "No"}`);
|
|
93823
94211
|
console.log("");
|
|
93824
94212
|
} catch (error) {
|
|
93825
|
-
|
|
93826
|
-
|
|
93827
|
-
|
|
93828
|
-
|
|
94213
|
+
if (options.json) {
|
|
94214
|
+
console.error(
|
|
94215
|
+
JSON.stringify({
|
|
94216
|
+
error: error instanceof Error ? error.message : "Unknown error"
|
|
94217
|
+
})
|
|
94218
|
+
);
|
|
94219
|
+
} else {
|
|
94220
|
+
console.error(
|
|
94221
|
+
"Error:",
|
|
94222
|
+
error instanceof Error ? error.message : "Unknown error"
|
|
94223
|
+
);
|
|
94224
|
+
}
|
|
93829
94225
|
process.exit(1);
|
|
93830
94226
|
}
|
|
93831
94227
|
}
|
|
@@ -93842,6 +94238,10 @@ function registerFrontCommands(program3) {
|
|
|
93842
94238
|
registerTriageCommand(front);
|
|
93843
94239
|
registerPullCommand(front);
|
|
93844
94240
|
registerTagCommands(front);
|
|
94241
|
+
registerAssignCommand(front);
|
|
94242
|
+
registerConversationTagCommands(front);
|
|
94243
|
+
registerReplyCommand(front);
|
|
94244
|
+
registerApiCommand(front);
|
|
93845
94245
|
}
|
|
93846
94246
|
|
|
93847
94247
|
// src/commands/health.ts
|