@teamclaw/feishu-agent 1.0.9 → 1.0.10

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.
Files changed (2) hide show
  1. package/dist/cli.js +33 -28
  2. 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 content = await readFile(localConfigPath, "utf-8");
2359
- const config = JSON.parse(content);
2360
- config.userAccessToken = token.accessToken;
2361
- config.refreshToken = token.refreshToken;
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(config, null, 2));
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
- try {
2368
- const content = await readFile(globalConfigPath, "utf-8");
2369
- const config = JSON.parse(content);
2370
- config.userAccessToken = token.accessToken;
2371
- config.refreshToken = token.refreshToken;
2372
- await writeFile(globalConfigPath, JSON.stringify(config, null, 2));
2373
- } catch {}
2374
- } catch {}
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
- return res.event;
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);
@@ -3471,7 +3476,7 @@ async function handleCreateEvent(config, options) {
3471
3476
  console.error("Error: --summary, --start, and --end are required.");
3472
3477
  process.exit(1);
3473
3478
  }
3474
- let attendeeOpenIds = [];
3479
+ let attendeeUserIds = [];
3475
3480
  if (attendeeName && attendeeName.length > 0) {
3476
3481
  console.log(`
3477
3482
  \uD83D\uDD0D Resolving attendee names...`);
@@ -3488,12 +3493,12 @@ async function handleCreateEvent(config, options) {
3488
3493
  });
3489
3494
  console.log(" Using the first match.");
3490
3495
  }
3491
- attendeeOpenIds.push(results[0].open_id || results[0].union_id);
3492
- console.log(` \u2713 "${name}" -> ${results[0].name} (${results[0].open_id || results[0].union_id})`);
3496
+ attendeeUserIds.push(results[0].union_id);
3497
+ console.log(` \u2713 "${name}" -> ${results[0].name} (${results[0].union_id})`);
3493
3498
  }
3494
3499
  }
3495
3500
  if (attendee && attendee.length > 0) {
3496
- attendeeOpenIds = [...attendeeOpenIds, ...attendee];
3501
+ attendeeUserIds = [...attendeeUserIds, ...attendee];
3497
3502
  }
3498
3503
  let targetCalendarId = calendarId;
3499
3504
  if (!targetCalendarId) {
@@ -3512,15 +3517,15 @@ async function handleCreateEvent(config, options) {
3512
3517
  summary,
3513
3518
  startTime: { timestamp: startTimestamp },
3514
3519
  endTime: { timestamp: endTimestamp },
3515
- attendeeOpenIds: attendeeOpenIds.length > 0 ? attendeeOpenIds : undefined
3520
+ attendeeUserIds: attendeeUserIds.length > 0 ? attendeeUserIds : undefined
3516
3521
  });
3517
3522
  console.log(`
3518
3523
  \u2705 Event created!`);
3519
3524
  console.log(` Title: ${summary}`);
3520
3525
  console.log(` Time: ${new Date(parseInt(startTimestamp) * 1000).toLocaleString()} - ${new Date(parseInt(endTimestamp) * 1000).toLocaleString()}`);
3521
3526
  console.log(` Calendar ID: ${targetCalendarId}`);
3522
- if (attendeeOpenIds.length > 0) {
3523
- console.log(` Attendees: ${attendeeOpenIds.join(", ")}`);
3527
+ if (attendeeUserIds.length > 0) {
3528
+ console.log(` Attendees: ${attendeeUserIds.join(", ")}`);
3524
3529
  }
3525
3530
  }
3526
3531
  async function handleDeleteEvent(config, options) {
@@ -3765,7 +3770,7 @@ async function handleSearch(config, query) {
3765
3770
  // package.json
3766
3771
  var package_default = {
3767
3772
  name: "@teamclaw/feishu-agent",
3768
- version: "1.0.9",
3773
+ version: "1.0.10",
3769
3774
  description: "Feishu Agent CLI for AI assistants",
3770
3775
  type: "module",
3771
3776
  private: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teamclaw/feishu-agent",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
4
4
  "description": "Feishu Agent CLI for AI assistants",
5
5
  "type": "module",
6
6
  "private": false,