@teamclaw/feishu-agent 1.0.9 → 1.0.11
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/cli.js +40 -32
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -2355,23 +2355,24 @@ class AuthManager {
|
|
|
2355
2355
|
const { homedir: homedir2 } = await import("node:os");
|
|
2356
2356
|
const localConfigPath = ".feishu_agent/config.json";
|
|
2357
2357
|
try {
|
|
2358
|
-
const
|
|
2359
|
-
const
|
|
2360
|
-
|
|
2361
|
-
|
|
2358
|
+
const content2 = await readFile(localConfigPath, "utf-8");
|
|
2359
|
+
const config2 = JSON.parse(content2);
|
|
2360
|
+
config2.userAccessToken = token.accessToken;
|
|
2361
|
+
config2.refreshToken = token.refreshToken;
|
|
2362
2362
|
await mkdir2(".feishu_agent", { recursive: true });
|
|
2363
|
-
await writeFile(localConfigPath, JSON.stringify(
|
|
2363
|
+
await writeFile(localConfigPath, JSON.stringify(config2, null, 2));
|
|
2364
2364
|
return;
|
|
2365
2365
|
} catch {}
|
|
2366
2366
|
const globalConfigPath = join2(homedir2(), ".feishu-agent", "config.json");
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2367
|
+
const content = await readFile(globalConfigPath, "utf-8");
|
|
2368
|
+
const config = JSON.parse(content);
|
|
2369
|
+
config.userAccessToken = token.accessToken;
|
|
2370
|
+
config.refreshToken = token.refreshToken;
|
|
2371
|
+
await writeFile(globalConfigPath, JSON.stringify(config, null, 2));
|
|
2372
|
+
} catch (error) {
|
|
2373
|
+
console.error("Warning: Failed to save updated tokens to config file.");
|
|
2374
|
+
console.error("Tokens will need to be refreshed again on next run.");
|
|
2375
|
+
}
|
|
2375
2376
|
}
|
|
2376
2377
|
}
|
|
2377
2378
|
|
|
@@ -3179,14 +3180,18 @@ class CalendarManager {
|
|
|
3179
3180
|
start_time: event.startTime,
|
|
3180
3181
|
end_time: event.endTime
|
|
3181
3182
|
};
|
|
3182
|
-
if (event.attendeeOpenIds && event.attendeeOpenIds.length > 0) {
|
|
3183
|
-
body.attendees = event.attendeeOpenIds.map((id) => ({
|
|
3184
|
-
type: "user",
|
|
3185
|
-
user_id: id
|
|
3186
|
-
}));
|
|
3187
|
-
}
|
|
3188
3183
|
const res = await this.client.post(`/open-apis/calendar/v4/calendars/${calendarId}/events`, body, { user_id_type: "union_id" }, true);
|
|
3189
|
-
|
|
3184
|
+
const createdEvent = res.event;
|
|
3185
|
+
if (event.attendeeUserIds && event.attendeeUserIds.length > 0) {
|
|
3186
|
+
await this.client.post(`/open-apis/calendar/v4/calendars/${calendarId}/events/${createdEvent.event_id}/attendees`, {
|
|
3187
|
+
attendees: event.attendeeUserIds.map((id) => ({
|
|
3188
|
+
type: "user",
|
|
3189
|
+
user_id: id
|
|
3190
|
+
})),
|
|
3191
|
+
need_notification: true
|
|
3192
|
+
}, { user_id_type: "union_id" });
|
|
3193
|
+
}
|
|
3194
|
+
return createdEvent;
|
|
3190
3195
|
}
|
|
3191
3196
|
async deleteEvent(calendarId, eventId) {
|
|
3192
3197
|
await this.client.request(`/open-apis/calendar/v4/calendars/${calendarId}/events/${eventId}`, { method: "DELETE" }, true);
|
|
@@ -3317,8 +3322,8 @@ function createCalendarCommands(program2, config) {
|
|
|
3317
3322
|
program2.command("list").description("List all calendars").action(async () => {
|
|
3318
3323
|
await handleListCalendars(config);
|
|
3319
3324
|
});
|
|
3320
|
-
program2.command("events").description("List events in a calendar").option("--calendar-id <string>", "Specify calendar ID").action(async (options) => {
|
|
3321
|
-
await handleListEvents(config, options.calendarId);
|
|
3325
|
+
program2.command("events").description("List events in a calendar").option("--calendar-id <string>", "Specify calendar ID").option("--start <string>", "Filter events starting after this time").option("--end <string>", "Filter events ending before this time").action(async (options) => {
|
|
3326
|
+
await handleListEvents(config, options.calendarId, options.start, options.end);
|
|
3322
3327
|
});
|
|
3323
3328
|
program2.command("create").description("Create a new event").requiredOption("--summary <string>", "Event title").requiredOption("--start <string>", "Event start time").requiredOption("--end <string>", "Event end time").option("--attendee <ids...>", "User IDs (union_id) to invite").option("--attendee-name <names...>", "Contact names to invite").option("--calendar-id <string>", "Specify calendar ID").action(async (options) => {
|
|
3324
3329
|
await handleCreateEvent(config, options);
|
|
@@ -3385,7 +3390,7 @@ async function handleListCalendars(config) {
|
|
|
3385
3390
|
console.log(`Tip: Use --calendar-id "${primary[0].calendar_id}" to list events.`);
|
|
3386
3391
|
}
|
|
3387
3392
|
}
|
|
3388
|
-
async function handleListEvents(config, calendarId) {
|
|
3393
|
+
async function handleListEvents(config, calendarId, timeMin, timeMax) {
|
|
3389
3394
|
if (!config.appId || !config.appSecret || !config.userAccessToken) {
|
|
3390
3395
|
console.error("Error: Authorization required. Run 'feishu-agent auth'.");
|
|
3391
3396
|
process.exit(1);
|
|
@@ -3409,7 +3414,10 @@ async function handleListEvents(config, calendarId) {
|
|
|
3409
3414
|
\uD83D\uDCC5 Events
|
|
3410
3415
|
`);
|
|
3411
3416
|
console.log("=".repeat(60));
|
|
3412
|
-
const events = await calendarManager.listEvents(calendarId
|
|
3417
|
+
const events = await calendarManager.listEvents(calendarId, {
|
|
3418
|
+
startTime: timeMin,
|
|
3419
|
+
endTime: timeMax
|
|
3420
|
+
});
|
|
3413
3421
|
if (!events.items || events.items.length === 0) {
|
|
3414
3422
|
console.log("No events found.");
|
|
3415
3423
|
return;
|
|
@@ -3471,7 +3479,7 @@ async function handleCreateEvent(config, options) {
|
|
|
3471
3479
|
console.error("Error: --summary, --start, and --end are required.");
|
|
3472
3480
|
process.exit(1);
|
|
3473
3481
|
}
|
|
3474
|
-
let
|
|
3482
|
+
let attendeeUserIds = [];
|
|
3475
3483
|
if (attendeeName && attendeeName.length > 0) {
|
|
3476
3484
|
console.log(`
|
|
3477
3485
|
\uD83D\uDD0D Resolving attendee names...`);
|
|
@@ -3488,12 +3496,12 @@ async function handleCreateEvent(config, options) {
|
|
|
3488
3496
|
});
|
|
3489
3497
|
console.log(" Using the first match.");
|
|
3490
3498
|
}
|
|
3491
|
-
|
|
3492
|
-
console.log(` \u2713 "${name}" -> ${results[0].name} (${results[0].
|
|
3499
|
+
attendeeUserIds.push(results[0].union_id);
|
|
3500
|
+
console.log(` \u2713 "${name}" -> ${results[0].name} (${results[0].union_id})`);
|
|
3493
3501
|
}
|
|
3494
3502
|
}
|
|
3495
3503
|
if (attendee && attendee.length > 0) {
|
|
3496
|
-
|
|
3504
|
+
attendeeUserIds = [...attendeeUserIds, ...attendee];
|
|
3497
3505
|
}
|
|
3498
3506
|
let targetCalendarId = calendarId;
|
|
3499
3507
|
if (!targetCalendarId) {
|
|
@@ -3512,15 +3520,15 @@ async function handleCreateEvent(config, options) {
|
|
|
3512
3520
|
summary,
|
|
3513
3521
|
startTime: { timestamp: startTimestamp },
|
|
3514
3522
|
endTime: { timestamp: endTimestamp },
|
|
3515
|
-
|
|
3523
|
+
attendeeUserIds: attendeeUserIds.length > 0 ? attendeeUserIds : undefined
|
|
3516
3524
|
});
|
|
3517
3525
|
console.log(`
|
|
3518
3526
|
\u2705 Event created!`);
|
|
3519
3527
|
console.log(` Title: ${summary}`);
|
|
3520
3528
|
console.log(` Time: ${new Date(parseInt(startTimestamp) * 1000).toLocaleString()} - ${new Date(parseInt(endTimestamp) * 1000).toLocaleString()}`);
|
|
3521
3529
|
console.log(` Calendar ID: ${targetCalendarId}`);
|
|
3522
|
-
if (
|
|
3523
|
-
console.log(` Attendees: ${
|
|
3530
|
+
if (attendeeUserIds.length > 0) {
|
|
3531
|
+
console.log(` Attendees: ${attendeeUserIds.join(", ")}`);
|
|
3524
3532
|
}
|
|
3525
3533
|
}
|
|
3526
3534
|
async function handleDeleteEvent(config, options) {
|
|
@@ -3765,7 +3773,7 @@ async function handleSearch(config, query) {
|
|
|
3765
3773
|
// package.json
|
|
3766
3774
|
var package_default = {
|
|
3767
3775
|
name: "@teamclaw/feishu-agent",
|
|
3768
|
-
version: "1.0.
|
|
3776
|
+
version: "1.0.11",
|
|
3769
3777
|
description: "Feishu Agent CLI for AI assistants",
|
|
3770
3778
|
type: "module",
|
|
3771
3779
|
private: false,
|