@teamclaw/feishu-agent 1.0.7 → 1.0.9

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 +24 -16
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -2205,7 +2205,7 @@ async function searchContactCache(query) {
2205
2205
  const results = [];
2206
2206
  for (const [unionId, entry] of Object.entries(cache)) {
2207
2207
  if (entry.name.toLowerCase().includes(lowerQuery) || entry.email && entry.email.toLowerCase() === lowerQuery) {
2208
- results.push({ union_id: unionId, user_id: entry.user_id, name: entry.name, email: entry.email });
2208
+ results.push({ union_id: unionId, user_id: entry.user_id, open_id: entry.open_id, name: entry.name, email: entry.email });
2209
2209
  }
2210
2210
  }
2211
2211
  return results;
@@ -2271,6 +2271,8 @@ class AuthManager {
2271
2271
  if (data.code === 0 && data.data) {
2272
2272
  return {
2273
2273
  user_id: data.data.user_id,
2274
+ union_id: data.data.union_id,
2275
+ open_id: data.data.open_id,
2274
2276
  name: data.data.name
2275
2277
  };
2276
2278
  }
@@ -3177,12 +3179,14 @@ class CalendarManager {
3177
3179
  start_time: event.startTime,
3178
3180
  end_time: event.endTime
3179
3181
  };
3180
- const res = await this.client.post(`/open-apis/calendar/v4/calendars/${calendarId}/events`, body, { user_id_type: "union_id" }, true);
3181
- const createdEvent = res.event;
3182
- if (event.attendeeUserIds && event.attendeeUserIds.length > 0) {
3183
- await this.client.post(`/open-apis/calendar/v4/calendars/${calendarId}/events/${createdEvent.event_id}/attendees`, { attendees: event.attendeeUserIds.map((id) => ({ type: "user", user_id: id })) }, { user_id_type: "union_id" }, true);
3182
+ if (event.attendeeOpenIds && event.attendeeOpenIds.length > 0) {
3183
+ body.attendees = event.attendeeOpenIds.map((id) => ({
3184
+ type: "user",
3185
+ user_id: id
3186
+ }));
3184
3187
  }
3185
- return createdEvent;
3188
+ const res = await this.client.post(`/open-apis/calendar/v4/calendars/${calendarId}/events`, body, { user_id_type: "union_id" }, true);
3189
+ return res.event;
3186
3190
  }
3187
3191
  async deleteEvent(calendarId, eventId) {
3188
3192
  await this.client.request(`/open-apis/calendar/v4/calendars/${calendarId}/events/${eventId}`, { method: "DELETE" }, true);
@@ -3205,12 +3209,12 @@ class CalendarManager {
3205
3209
  }
3206
3210
  async checkTimeConflict(startTime, endTime) {
3207
3211
  const currentUser = await this.client.getCurrentUser();
3208
- if (!currentUser?.user_id) {
3212
+ if (!currentUser?.union_id) {
3209
3213
  return;
3210
3214
  }
3211
3215
  const timeMin = this.toRFC3339(startTime);
3212
3216
  const timeMax = this.toRFC3339(endTime);
3213
- const freeBusy = await this.getUserFreeBusy(currentUser.user_id, timeMin, timeMax);
3217
+ const freeBusy = await this.getUserFreeBusy(currentUser.union_id, timeMin, timeMax);
3214
3218
  if (freeBusy.freebusy_list && freeBusy.freebusy_list.length > 0) {
3215
3219
  const conflicts = freeBusy.freebusy_list.map((slot) => `${new Date(slot.start_time).toLocaleString()} - ${new Date(slot.end_time).toLocaleString()}`);
3216
3220
  throw new Error(`Time conflict detected. The following time slots are already busy:
@@ -3266,6 +3270,7 @@ class ContactManager {
3266
3270
  return cachedResults.map((c) => ({
3267
3271
  user_id: c.user_id,
3268
3272
  union_id: c.union_id,
3273
+ open_id: c.open_id,
3269
3274
  name: c.name,
3270
3275
  email: c.email
3271
3276
  }));
@@ -3431,7 +3436,7 @@ async function handleListEvents(config, calendarId) {
3431
3436
  const attendeeDisplay = attendees.map((a) => {
3432
3437
  if (a.type === "user" && a.user_id) {
3433
3438
  for (const [unionId, entry] of Object.entries(contactCache)) {
3434
- if (entry.open_id === a.user_id || unionId === a.user_id) {
3439
+ if (entry.user_id === a.user_id || unionId === a.user_id) {
3435
3440
  return `${entry.name}${a.is_optional ? " (optional)" : ""}`;
3436
3441
  }
3437
3442
  }
@@ -3466,7 +3471,7 @@ async function handleCreateEvent(config, options) {
3466
3471
  console.error("Error: --summary, --start, and --end are required.");
3467
3472
  process.exit(1);
3468
3473
  }
3469
- let attendeeUserIds = attendee || [];
3474
+ let attendeeOpenIds = [];
3470
3475
  if (attendeeName && attendeeName.length > 0) {
3471
3476
  console.log(`
3472
3477
  \uD83D\uDD0D Resolving attendee names...`);
@@ -3483,10 +3488,13 @@ async function handleCreateEvent(config, options) {
3483
3488
  });
3484
3489
  console.log(" Using the first match.");
3485
3490
  }
3486
- attendeeUserIds.push(results[0].union_id);
3487
- console.log(` \u2713 "${name}" -> ${results[0].name} (${results[0].union_id})`);
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})`);
3488
3493
  }
3489
3494
  }
3495
+ if (attendee && attendee.length > 0) {
3496
+ attendeeOpenIds = [...attendeeOpenIds, ...attendee];
3497
+ }
3490
3498
  let targetCalendarId = calendarId;
3491
3499
  if (!targetCalendarId) {
3492
3500
  const calendars = await calendarManager.listCalendars();
@@ -3504,15 +3512,15 @@ async function handleCreateEvent(config, options) {
3504
3512
  summary,
3505
3513
  startTime: { timestamp: startTimestamp },
3506
3514
  endTime: { timestamp: endTimestamp },
3507
- attendeeUserIds: attendeeUserIds.length > 0 ? attendeeUserIds : undefined
3515
+ attendeeOpenIds: attendeeOpenIds.length > 0 ? attendeeOpenIds : undefined
3508
3516
  });
3509
3517
  console.log(`
3510
3518
  \u2705 Event created!`);
3511
3519
  console.log(` Title: ${summary}`);
3512
3520
  console.log(` Time: ${new Date(parseInt(startTimestamp) * 1000).toLocaleString()} - ${new Date(parseInt(endTimestamp) * 1000).toLocaleString()}`);
3513
3521
  console.log(` Calendar ID: ${targetCalendarId}`);
3514
- if (attendeeUserIds.length > 0) {
3515
- console.log(` Attendees: ${attendeeUserIds.join(", ")}`);
3522
+ if (attendeeOpenIds.length > 0) {
3523
+ console.log(` Attendees: ${attendeeOpenIds.join(", ")}`);
3516
3524
  }
3517
3525
  }
3518
3526
  async function handleDeleteEvent(config, options) {
@@ -3757,7 +3765,7 @@ async function handleSearch(config, query) {
3757
3765
  // package.json
3758
3766
  var package_default = {
3759
3767
  name: "@teamclaw/feishu-agent",
3760
- version: "1.0.7",
3768
+ version: "1.0.9",
3761
3769
  description: "Feishu Agent CLI for AI assistants",
3762
3770
  type: "module",
3763
3771
  private: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teamclaw/feishu-agent",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "description": "Feishu Agent CLI for AI assistants",
5
5
  "type": "module",
6
6
  "private": false,