@teamclaw/feishu-agent 1.0.6 → 1.0.8
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 +24 -13
- 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
|
}
|
|
@@ -2770,9 +2772,9 @@ FEISHU_APP_SECRET=${appSecret}
|
|
|
2770
2772
|
// src/cli/commands/auth.ts
|
|
2771
2773
|
import { parseArgs } from "node:util";
|
|
2772
2774
|
import { createServer as createServer2 } from "node:http";
|
|
2773
|
-
async function authCommand(
|
|
2775
|
+
async function authCommand() {
|
|
2774
2776
|
const { values } = parseArgs({
|
|
2775
|
-
args,
|
|
2777
|
+
args: process.argv.slice(3),
|
|
2776
2778
|
strict: false,
|
|
2777
2779
|
options: {
|
|
2778
2780
|
port: { type: "string", default: "3000" }
|
|
@@ -3180,7 +3182,12 @@ class CalendarManager {
|
|
|
3180
3182
|
const res = await this.client.post(`/open-apis/calendar/v4/calendars/${calendarId}/events`, body, { user_id_type: "union_id" }, true);
|
|
3181
3183
|
const createdEvent = res.event;
|
|
3182
3184
|
if (event.attendeeUserIds && event.attendeeUserIds.length > 0) {
|
|
3183
|
-
await this.client.post(`/open-apis/calendar/v4/calendars/${calendarId}/events/${createdEvent.event_id}/attendees`, {
|
|
3185
|
+
await this.client.post(`/open-apis/calendar/v4/calendars/${calendarId}/events/${createdEvent.event_id}/attendees`, {
|
|
3186
|
+
attendees: event.attendeeUserIds.map((id) => ({
|
|
3187
|
+
type: "user",
|
|
3188
|
+
user_id: id
|
|
3189
|
+
}))
|
|
3190
|
+
}, {});
|
|
3184
3191
|
}
|
|
3185
3192
|
return createdEvent;
|
|
3186
3193
|
}
|
|
@@ -3205,12 +3212,12 @@ class CalendarManager {
|
|
|
3205
3212
|
}
|
|
3206
3213
|
async checkTimeConflict(startTime, endTime) {
|
|
3207
3214
|
const currentUser = await this.client.getCurrentUser();
|
|
3208
|
-
if (!currentUser?.
|
|
3215
|
+
if (!currentUser?.union_id) {
|
|
3209
3216
|
return;
|
|
3210
3217
|
}
|
|
3211
3218
|
const timeMin = this.toRFC3339(startTime);
|
|
3212
3219
|
const timeMax = this.toRFC3339(endTime);
|
|
3213
|
-
const freeBusy = await this.getUserFreeBusy(currentUser.
|
|
3220
|
+
const freeBusy = await this.getUserFreeBusy(currentUser.union_id, timeMin, timeMax);
|
|
3214
3221
|
if (freeBusy.freebusy_list && freeBusy.freebusy_list.length > 0) {
|
|
3215
3222
|
const conflicts = freeBusy.freebusy_list.map((slot) => `${new Date(slot.start_time).toLocaleString()} - ${new Date(slot.end_time).toLocaleString()}`);
|
|
3216
3223
|
throw new Error(`Time conflict detected. The following time slots are already busy:
|
|
@@ -3266,6 +3273,7 @@ class ContactManager {
|
|
|
3266
3273
|
return cachedResults.map((c) => ({
|
|
3267
3274
|
user_id: c.user_id,
|
|
3268
3275
|
union_id: c.union_id,
|
|
3276
|
+
open_id: c.open_id,
|
|
3269
3277
|
name: c.name,
|
|
3270
3278
|
email: c.email
|
|
3271
3279
|
}));
|
|
@@ -3431,7 +3439,7 @@ async function handleListEvents(config, calendarId) {
|
|
|
3431
3439
|
const attendeeDisplay = attendees.map((a) => {
|
|
3432
3440
|
if (a.type === "user" && a.user_id) {
|
|
3433
3441
|
for (const [unionId, entry] of Object.entries(contactCache)) {
|
|
3434
|
-
if (entry.
|
|
3442
|
+
if (entry.user_id === a.user_id || unionId === a.user_id) {
|
|
3435
3443
|
return `${entry.name}${a.is_optional ? " (optional)" : ""}`;
|
|
3436
3444
|
}
|
|
3437
3445
|
}
|
|
@@ -3466,7 +3474,7 @@ async function handleCreateEvent(config, options) {
|
|
|
3466
3474
|
console.error("Error: --summary, --start, and --end are required.");
|
|
3467
3475
|
process.exit(1);
|
|
3468
3476
|
}
|
|
3469
|
-
let
|
|
3477
|
+
let attendeeUnionIds = [];
|
|
3470
3478
|
if (attendeeName && attendeeName.length > 0) {
|
|
3471
3479
|
console.log(`
|
|
3472
3480
|
\uD83D\uDD0D Resolving attendee names...`);
|
|
@@ -3483,10 +3491,13 @@ async function handleCreateEvent(config, options) {
|
|
|
3483
3491
|
});
|
|
3484
3492
|
console.log(" Using the first match.");
|
|
3485
3493
|
}
|
|
3486
|
-
|
|
3494
|
+
attendeeUnionIds.push(results[0].union_id);
|
|
3487
3495
|
console.log(` \u2713 "${name}" -> ${results[0].name} (${results[0].union_id})`);
|
|
3488
3496
|
}
|
|
3489
3497
|
}
|
|
3498
|
+
if (attendee && attendee.length > 0) {
|
|
3499
|
+
attendeeUnionIds = [...attendeeUnionIds, ...attendee];
|
|
3500
|
+
}
|
|
3490
3501
|
let targetCalendarId = calendarId;
|
|
3491
3502
|
if (!targetCalendarId) {
|
|
3492
3503
|
const calendars = await calendarManager.listCalendars();
|
|
@@ -3504,15 +3515,15 @@ async function handleCreateEvent(config, options) {
|
|
|
3504
3515
|
summary,
|
|
3505
3516
|
startTime: { timestamp: startTimestamp },
|
|
3506
3517
|
endTime: { timestamp: endTimestamp },
|
|
3507
|
-
attendeeUserIds:
|
|
3518
|
+
attendeeUserIds: attendeeUnionIds.length > 0 ? attendeeUnionIds : undefined
|
|
3508
3519
|
});
|
|
3509
3520
|
console.log(`
|
|
3510
3521
|
\u2705 Event created!`);
|
|
3511
3522
|
console.log(` Title: ${summary}`);
|
|
3512
3523
|
console.log(` Time: ${new Date(parseInt(startTimestamp) * 1000).toLocaleString()} - ${new Date(parseInt(endTimestamp) * 1000).toLocaleString()}`);
|
|
3513
3524
|
console.log(` Calendar ID: ${targetCalendarId}`);
|
|
3514
|
-
if (
|
|
3515
|
-
console.log(` Attendees: ${
|
|
3525
|
+
if (attendeeUnionIds.length > 0) {
|
|
3526
|
+
console.log(` Attendees: ${attendeeUnionIds.join(", ")}`);
|
|
3516
3527
|
}
|
|
3517
3528
|
}
|
|
3518
3529
|
async function handleDeleteEvent(config, options) {
|
|
@@ -3757,7 +3768,7 @@ async function handleSearch(config, query) {
|
|
|
3757
3768
|
// package.json
|
|
3758
3769
|
var package_default = {
|
|
3759
3770
|
name: "@teamclaw/feishu-agent",
|
|
3760
|
-
version: "1.0.
|
|
3771
|
+
version: "1.0.8",
|
|
3761
3772
|
description: "Feishu Agent CLI for AI assistants",
|
|
3762
3773
|
type: "module",
|
|
3763
3774
|
private: false,
|