@teamclaw/feishu-agent 1.0.2 → 1.0.4

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 +85 -14
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -2131,7 +2131,7 @@ var {
2131
2131
  // src/cli/commands/setup.ts
2132
2132
  import { createServer } from "node:http";
2133
2133
  import { exec } from "node:child_process";
2134
- import { writeFile, mkdir as mkdir2 } from "node:fs/promises";
2134
+ import { writeFile } from "node:fs/promises";
2135
2135
 
2136
2136
  // src/core/config.ts
2137
2137
  import { homedir } from "node:os";
@@ -2231,11 +2231,11 @@ class AuthManager {
2231
2231
  userToken = null;
2232
2232
  constructor(config) {
2233
2233
  this.config = config;
2234
- if (config.userAccessToken) {
2234
+ if (config.userAccessToken && config.refreshToken) {
2235
2235
  this.userToken = {
2236
2236
  accessToken: config.userAccessToken,
2237
- refreshToken: config.refreshToken || "",
2238
- expireTime: Date.now() + 2 * 60 * 60 * 1000
2237
+ refreshToken: config.refreshToken,
2238
+ expireTime: 0
2239
2239
  };
2240
2240
  }
2241
2241
  }
@@ -2317,7 +2317,7 @@ class AuthManager {
2317
2317
  clearTimeout(timeoutId);
2318
2318
  }
2319
2319
  }
2320
- async refreshToken() {
2320
+ async refreshUserToken() {
2321
2321
  if (!this.userToken?.refreshToken) {
2322
2322
  throw new FeishuError("Refresh token not available", 401);
2323
2323
  }
@@ -2636,15 +2636,11 @@ async function setupCommand() {
2636
2636
  console.log(` User ID: ${user_id}`);
2637
2637
  console.log(` Name: ${name}`);
2638
2638
  console.log("");
2639
- await mkdir2(".feishu_agent", { recursive: true });
2640
- await writeFile(".feishu_agent/config.json", JSON.stringify({
2641
- appId,
2642
- appSecret,
2639
+ await saveGlobalConfig({
2643
2640
  userAccessToken: access_token,
2644
- refreshToken: refresh_token,
2645
- userId: user_id
2646
- }, null, 2));
2647
- console.log(`Configuration saved to .feishu_agent/config.json
2641
+ refreshToken: refresh_token
2642
+ });
2643
+ console.log(`Configuration saved to ~/.feishu-agent/config.json
2648
2644
  `);
2649
2645
  console.log("Step 3: Feishu Bitable (\u591A\u7EF4\u8868\u683C)");
2650
2646
  console.log("-".repeat(40));
@@ -3166,6 +3162,9 @@ class CalendarManager {
3166
3162
  return res;
3167
3163
  }
3168
3164
  async createEvent(calendarId, event) {
3165
+ if (event.checkConflict !== false) {
3166
+ await this.checkTimeConflict(event.startTime, event.endTime);
3167
+ }
3169
3168
  const body = {
3170
3169
  summary: event.summary,
3171
3170
  description: event.description,
@@ -3198,6 +3197,31 @@ class CalendarManager {
3198
3197
  const res = await this.client.post("/open-apis/calendar/v4/freebusy/list", body, { user_id_type: userIdType }, true);
3199
3198
  return res;
3200
3199
  }
3200
+ async checkTimeConflict(startTime, endTime) {
3201
+ const currentUser = await this.client.getCurrentUser();
3202
+ if (!currentUser?.user_id) {
3203
+ return;
3204
+ }
3205
+ const timeMin = this.toRFC3339(startTime);
3206
+ const timeMax = this.toRFC3339(endTime);
3207
+ const freeBusy = await this.getUserFreeBusy(currentUser.user_id, timeMin, timeMax);
3208
+ if (freeBusy.freebusy_list && freeBusy.freebusy_list.length > 0) {
3209
+ const conflicts = freeBusy.freebusy_list.map((slot) => `${new Date(slot.start_time).toLocaleString()} - ${new Date(slot.end_time).toLocaleString()}`);
3210
+ throw new Error(`Time conflict detected. The following time slots are already busy:
3211
+ ` + ` ${conflicts.join(`
3212
+ `)}`);
3213
+ }
3214
+ }
3215
+ toRFC3339(time) {
3216
+ if (time.timestamp) {
3217
+ const date = new Date(parseInt(time.timestamp) * 1000);
3218
+ return date.toISOString();
3219
+ }
3220
+ if (time.date) {
3221
+ return time.date;
3222
+ }
3223
+ return new Date().toISOString();
3224
+ }
3201
3225
  async updateEvent(calendarId, eventId, updates) {
3202
3226
  const body = {};
3203
3227
  if (updates.summary !== undefined)
@@ -3724,11 +3748,58 @@ async function handleSearch(config, query) {
3724
3748
  console.log("No matching users found.");
3725
3749
  }
3726
3750
  }
3751
+ // package.json
3752
+ var package_default = {
3753
+ name: "@teamclaw/feishu-agent",
3754
+ version: "1.0.4",
3755
+ description: "Feishu Agent CLI for AI assistants",
3756
+ type: "module",
3757
+ private: false,
3758
+ bin: {
3759
+ "feishu-agent": "./dist/cli.js"
3760
+ },
3761
+ scripts: {
3762
+ test: "bun test",
3763
+ start: "bun run src/cli/index.ts",
3764
+ build: "bun build ./src/cli/index.ts --target=bun --outfile=dist/cli.js",
3765
+ prepublishOnly: "bun run build"
3766
+ },
3767
+ devDependencies: {
3768
+ "@types/bun": "latest"
3769
+ },
3770
+ dependencies: {
3771
+ "@modelcontextprotocol/sdk": "^1.27.1",
3772
+ commander: "^14.0.3",
3773
+ zod: "^4.3.6"
3774
+ },
3775
+ engines: {
3776
+ bun: ">=1.0.0"
3777
+ },
3778
+ files: [
3779
+ "dist",
3780
+ "README.md"
3781
+ ],
3782
+ keywords: [
3783
+ "feishu",
3784
+ "lark",
3785
+ "mcp",
3786
+ "ai",
3787
+ "assistant",
3788
+ "calendar",
3789
+ "todo",
3790
+ "cli"
3791
+ ],
3792
+ repository: {
3793
+ type: "git",
3794
+ url: "git+https://github.com/teamclaw/feishu-agent.git"
3795
+ },
3796
+ license: "MIT"
3797
+ };
3727
3798
 
3728
3799
  // src/cli/index.ts
3729
3800
  async function main() {
3730
3801
  const program2 = new Command;
3731
- program2.name("feishu-agent").description("Feishu Agent CLI for AI assistants").version("1.0.0");
3802
+ program2.name("feishu-agent").description("Feishu Agent CLI for AI assistants").version(package_default.version);
3732
3803
  program2.command("setup").description("Initialize configuration").action(setupCommand);
3733
3804
  program2.command("auth").description("Authenticate with Feishu OAuth").action(authCommand);
3734
3805
  program2.command("whoami").description("Show current user info").action(whoamiCommand);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teamclaw/feishu-agent",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Feishu Agent CLI for AI assistants",
5
5
  "type": "module",
6
6
  "private": false,