@zhin.js/adapter-github 1.1.3 → 1.1.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @zhin.js/adapter-github
2
2
 
3
+ ## 1.1.4
4
+
5
+ ### Patch Changes
6
+
7
+ - 0de4836: Expose the canonical Plugin Runtime `Message` contract from `@zhin.js/core`, `@zhin.js/core/runtime`, and the `zhin.js` root entries, and migrate Agent, permission, and GitHub integrations to the fields middleware actually receives. Document and lock the `EndpointEvent<Notice | Request>` handler boundary so side-event payload fields match editor inference.
8
+ - Updated dependencies [43eda99]
9
+ - Updated dependencies [0de4836]
10
+ - @zhin.js/core@1.1.39
11
+ - @zhin.js/adapter@1.1.15
12
+
3
13
  ## 1.1.3
4
14
 
5
15
  ### Patch Changes
@@ -16,7 +16,7 @@ function depsLogger() {
16
16
  export async function executeGithubBind(_args, client, commMessage) {
17
17
  const log = depsLogger();
18
18
  const msg = commMessage ?? getCurrentCommMessage();
19
- if (!msg?.$adapter || !msg?.$sender?.id)
19
+ if (!msg?.clientAdapter || !msg?.sender?.id)
20
20
  return '❌ 无法获取当前用户信息';
21
21
  const clientId = client.clientId;
22
22
  if (!clientId)
@@ -24,7 +24,7 @@ export async function executeGithubBind(_args, client, commMessage) {
24
24
  const model = oauthModel(client);
25
25
  if (!model)
26
26
  return '❌ 数据库未就绪';
27
- const [existing] = await model.select().where({ platform: msg.$adapter, platform_uid: msg.$sender.id });
27
+ const [existing] = await model.select().where({ platform: msg.clientAdapter, platform_uid: msg.sender.id });
28
28
  if (existing) {
29
29
  return `⚠️ 你已绑定 GitHub 账号: ${existing.github_login}\n如需重新绑定,请先执行 github_unbind`;
30
30
  }
@@ -42,7 +42,7 @@ export async function executeGithubBind(_args, client, commMessage) {
42
42
  ].join('\n');
43
43
  tokenPromise.then(async (tokenData) => {
44
44
  if (!tokenData) {
45
- log.warn(formatCompact({ op: 'device_flow', ok: false, platform: msg.$adapter, sender: msg.$sender.id }));
45
+ log.warn(formatCompact({ op: 'device_flow', ok: false, platform: msg.clientAdapter, sender: msg.sender.id }));
46
46
  return;
47
47
  }
48
48
  const userGh = new GhClient({ host, token: tokenData.access_token });
@@ -50,13 +50,13 @@ export async function executeGithubBind(_args, client, commMessage) {
50
50
  const login = authResult.ok ? authResult.user : 'unknown';
51
51
  await model.insert({
52
52
  id: Date.now(),
53
- platform: msg.$adapter,
54
- platform_uid: msg.$sender.id,
53
+ platform: msg.clientAdapter,
54
+ platform_uid: msg.sender.id,
55
55
  github_login: login,
56
56
  access_token: tokenData.access_token,
57
57
  created_at: Date.now(),
58
58
  });
59
- log.debug(formatCompact({ op: 'bind', platform: msg.$adapter, sender: msg.$sender.id, login }));
59
+ log.debug(formatCompact({ op: 'bind', platform: msg.clientAdapter, sender: msg.sender.id, login }));
60
60
  if (msg?.$reply) {
61
61
  await msg.$reply(`✅ GitHub 账号绑定成功!\n👤 ${login}`);
62
62
  }
@@ -71,12 +71,12 @@ export async function executeGithubBind(_args, client, commMessage) {
71
71
  }
72
72
  export async function executeGithubUnbind(_args, client, commMessage) {
73
73
  const msg = commMessage ?? getCurrentCommMessage();
74
- if (!msg?.$adapter || !msg?.$sender?.id)
74
+ if (!msg?.clientAdapter || !msg?.sender?.id)
75
75
  return '❌ 无法获取当前用户信息';
76
76
  const model = oauthModel(client);
77
77
  if (!model)
78
78
  return '❌ 数据库未就绪';
79
- const [existing] = await model.select().where({ platform: msg.$adapter, platform_uid: msg.$sender.id });
79
+ const [existing] = await model.select().where({ platform: msg.clientAdapter, platform_uid: msg.sender.id });
80
80
  if (!existing)
81
81
  return '📭 你尚未绑定 GitHub 账号';
82
82
  await model.delete().where({ id: existing.id });
@@ -84,12 +84,12 @@ export async function executeGithubUnbind(_args, client, commMessage) {
84
84
  }
85
85
  export async function executeGithubWhoami(_args, client, commMessage) {
86
86
  const msg = commMessage ?? getCurrentCommMessage();
87
- if (!msg?.$adapter || !msg?.$sender?.id)
87
+ if (!msg?.clientAdapter || !msg?.sender?.id)
88
88
  return '❌ 无法获取当前用户信息';
89
89
  const model = oauthModel(client);
90
90
  if (!model)
91
91
  return '❌ 数据库未就绪';
92
- const [existing] = await model.select().where({ platform: msg.$adapter, platform_uid: msg.$sender.id });
92
+ const [existing] = await model.select().where({ platform: msg.clientAdapter, platform_uid: msg.sender.id });
93
93
  if (!existing)
94
94
  return '📭 你尚未绑定 GitHub 账号\n🔗 使用 github_bind 绑定你的账号';
95
95
  const userGh = new GhClient({ host: client.host, token: existing.access_token });
@@ -26,7 +26,7 @@ function depsLogger() {
26
26
  export async function executeGithubBind(_args: Record<string, never>, client: GithubClient, commMessage?: Message) {
27
27
  const log = depsLogger();
28
28
  const msg = commMessage ?? getCurrentCommMessage();
29
- if (!msg?.$adapter || !msg?.$sender?.id) return '❌ 无法获取当前用户信息';
29
+ if (!msg?.clientAdapter || !msg?.sender?.id) return '❌ 无法获取当前用户信息';
30
30
 
31
31
  const clientId = client.clientId;
32
32
  if (!clientId) return '❌ Endpoint 未配置 GitHub App 或 App 无 client_id,无法进行账号绑定';
@@ -34,7 +34,7 @@ export async function executeGithubBind(_args: Record<string, never>, client: Gi
34
34
  const model = oauthModel(client);
35
35
  if (!model) return '❌ 数据库未就绪';
36
36
 
37
- const [existing] = await model.select().where({ platform: msg.$adapter, platform_uid: msg.$sender.id });
37
+ const [existing] = await model.select().where({ platform: msg.clientAdapter, platform_uid: msg.sender.id });
38
38
  if (existing) {
39
39
  return `⚠️ 你已绑定 GitHub 账号: ${existing.github_login}\n如需重新绑定,请先执行 github_unbind`;
40
40
  }
@@ -57,7 +57,7 @@ export async function executeGithubBind(_args: Record<string, never>, client: Gi
57
57
 
58
58
  tokenPromise.then(async (tokenData) => {
59
59
  if (!tokenData) {
60
- log.warn(formatCompact({ op: 'device_flow', ok: false, platform: msg.$adapter, sender: msg.$sender.id }));
60
+ log.warn(formatCompact({ op: 'device_flow', ok: false, platform: msg.clientAdapter, sender: msg.sender!.id }));
61
61
  return;
62
62
  }
63
63
 
@@ -67,13 +67,13 @@ export async function executeGithubBind(_args: Record<string, never>, client: Gi
67
67
 
68
68
  await model.insert({
69
69
  id: Date.now(),
70
- platform: msg.$adapter,
71
- platform_uid: msg.$sender.id,
70
+ platform: msg.clientAdapter,
71
+ platform_uid: msg.sender!.id,
72
72
  github_login: login,
73
73
  access_token: tokenData.access_token,
74
74
  created_at: Date.now(),
75
75
  });
76
- log.debug(formatCompact({ op: 'bind', platform: msg.$adapter, sender: msg.$sender.id, login }));
76
+ log.debug(formatCompact({ op: 'bind', platform: msg.clientAdapter, sender: msg.sender!.id, login }));
77
77
 
78
78
  if (msg?.$reply) {
79
79
  await msg.$reply(`✅ GitHub 账号绑定成功!\n👤 ${login}`);
@@ -90,12 +90,12 @@ export async function executeGithubBind(_args: Record<string, never>, client: Gi
90
90
 
91
91
  export async function executeGithubUnbind(_args: Record<string, never>, client: GithubClient, commMessage?: Message) {
92
92
  const msg = commMessage ?? getCurrentCommMessage();
93
- if (!msg?.$adapter || !msg?.$sender?.id) return '❌ 无法获取当前用户信息';
93
+ if (!msg?.clientAdapter || !msg?.sender?.id) return '❌ 无法获取当前用户信息';
94
94
 
95
95
  const model = oauthModel(client);
96
96
  if (!model) return '❌ 数据库未就绪';
97
97
 
98
- const [existing] = await model.select().where({ platform: msg.$adapter, platform_uid: msg.$sender.id });
98
+ const [existing] = await model.select().where({ platform: msg.clientAdapter, platform_uid: msg.sender.id });
99
99
  if (!existing) return '📭 你尚未绑定 GitHub 账号';
100
100
 
101
101
  await model.delete().where({ id: existing.id });
@@ -104,12 +104,12 @@ export async function executeGithubUnbind(_args: Record<string, never>, client:
104
104
 
105
105
  export async function executeGithubWhoami(_args: Record<string, never>, client: GithubClient, commMessage?: Message) {
106
106
  const msg = commMessage ?? getCurrentCommMessage();
107
- if (!msg?.$adapter || !msg?.$sender?.id) return '❌ 无法获取当前用户信息';
107
+ if (!msg?.clientAdapter || !msg?.sender?.id) return '❌ 无法获取当前用户信息';
108
108
 
109
109
  const model = oauthModel(client);
110
110
  if (!model) return '❌ 数据库未就绪';
111
111
 
112
- const [existing] = await model.select().where({ platform: msg.$adapter, platform_uid: msg.$sender.id });
112
+ const [existing] = await model.select().where({ platform: msg.clientAdapter, platform_uid: msg.sender.id });
113
113
  if (!existing) return '📭 你尚未绑定 GitHub 账号\n🔗 使用 github_bind 绑定你的账号';
114
114
 
115
115
  const userGh = new GhClient({ host: client.host, token: existing.access_token });
@@ -6,7 +6,7 @@ function subscriptionsModel(client) {
6
6
  }
7
7
  export async function executeGithubStar(args, client, commMessage) {
8
8
  const msg = commMessage ?? getCurrentCommMessage();
9
- const gh = await client.getUserOrDefaultApi(msg?.$adapter, msg?.$sender.id);
9
+ const gh = await client.getUserOrDefaultApi(msg?.clientAdapter, msg?.sender?.id);
10
10
  switch (args.action) {
11
11
  case 'star': {
12
12
  const r = await gh.starRepo(args.repo);
@@ -26,7 +26,7 @@ export async function executeGithubStar(args, client, commMessage) {
26
26
  }
27
27
  export async function executeGithubSubscribe(args, client, commMessage) {
28
28
  const msg = commMessage ?? getCurrentCommMessage();
29
- if (!msg?.$adapter || !msg?.$sender.id || !msg?.$channel?.id || !msg?.$endpoint) {
29
+ if (!msg?.clientAdapter || !msg?.sender?.id || !msg?.conversation.id || !msg?.endpointId) {
30
30
  return '❌ 无法获取当前聊天通道信息';
31
31
  }
32
32
  const model = subscriptionsModel(client);
@@ -40,28 +40,28 @@ export async function executeGithubSubscribe(args, client, commMessage) {
40
40
  return `❌ 无效的事件类型,可选: ${validEvents.join(', ')}`;
41
41
  const [existing] = await model.select().where({
42
42
  repo: args.repo,
43
- target_id: msg.$channel?.id,
44
- adapter: msg.$adapter,
45
- endpoint: msg.$endpoint,
43
+ target_id: msg.conversation.id,
44
+ adapter: msg.clientAdapter,
45
+ endpoint: msg.endpointId,
46
46
  });
47
47
  if (existing) {
48
- await model.update({ events, target_type: msg.$channel?.type || 'private' }).where({ id: existing.id });
48
+ await model.update({ events, target_type: msg.conversation.kind || 'private' }).where({ id: existing.id });
49
49
  return `✅ 已更新订阅 ${args.repo}\n📡 事件: ${events.join(', ')}`;
50
50
  }
51
51
  await model.insert({
52
52
  id: Date.now(),
53
53
  repo: args.repo,
54
54
  events,
55
- target_id: msg.$channel?.id,
56
- target_type: msg.$channel?.type || 'private',
57
- adapter: msg.$adapter,
58
- endpoint: msg.$endpoint,
55
+ target_id: msg.conversation.id,
56
+ target_type: msg.conversation.kind || 'private',
57
+ adapter: msg.clientAdapter,
58
+ endpoint: msg.endpointId,
59
59
  });
60
60
  return `✅ 已订阅 ${args.repo}\n📡 事件: ${events.join(', ')}\n📌 通知将推送到当前通道`;
61
61
  }
62
62
  export async function executeGithubUnsubscribe(args, client, commMessage) {
63
63
  const msg = commMessage ?? getCurrentCommMessage();
64
- if (!msg?.$adapter || !msg?.$channel?.id || !msg?.$endpoint) {
64
+ if (!msg?.clientAdapter || !msg?.conversation.id || !msg?.endpointId) {
65
65
  return '❌ 无法获取当前聊天通道信息';
66
66
  }
67
67
  const model = subscriptionsModel(client);
@@ -69,9 +69,9 @@ export async function executeGithubUnsubscribe(args, client, commMessage) {
69
69
  return '❌ 数据库未就绪';
70
70
  const [existing] = await model.select().where({
71
71
  repo: args.repo,
72
- target_id: msg.$channel?.id,
73
- adapter: msg.$adapter,
74
- endpoint: msg.$endpoint,
72
+ target_id: msg.conversation.id,
73
+ adapter: msg.clientAdapter,
74
+ endpoint: msg.endpointId,
75
75
  });
76
76
  if (!existing)
77
77
  return `📭 当前通道未订阅 ${args.repo}`;
@@ -80,16 +80,16 @@ export async function executeGithubUnsubscribe(args, client, commMessage) {
80
80
  }
81
81
  export async function executeGithubSubscriptions(_args, client, commMessage) {
82
82
  const msg = commMessage ?? getCurrentCommMessage();
83
- if (!msg?.$adapter || !msg?.$channel?.id || !msg?.$endpoint) {
83
+ if (!msg?.clientAdapter || !msg?.conversation.id || !msg?.endpointId) {
84
84
  return '❌ 无法获取当前聊天通道信息';
85
85
  }
86
86
  const model = subscriptionsModel(client);
87
87
  if (!model)
88
88
  return '❌ 数据库未就绪';
89
89
  const subs = await model.select().where({
90
- target_id: msg.$channel?.id,
91
- adapter: msg.$adapter,
92
- endpoint: msg.$endpoint,
90
+ target_id: msg.conversation.id,
91
+ adapter: msg.clientAdapter,
92
+ endpoint: msg.endpointId,
93
93
  });
94
94
  if (!subs?.length)
95
95
  return '📭 当前通道没有任何 GitHub 订阅';
@@ -17,7 +17,7 @@ function subscriptionsModel(client: GithubClient) {
17
17
 
18
18
  export async function executeGithubStar(args: { action: 'star' | 'unstar' | 'check'; repo: string }, client: GithubClient, commMessage?: Message) {
19
19
  const msg = commMessage ?? getCurrentCommMessage();
20
- const gh = await client.getUserOrDefaultApi(msg?.$adapter, msg?.$sender.id);
20
+ const gh = await client.getUserOrDefaultApi(msg?.clientAdapter, msg?.sender?.id);
21
21
  switch (args.action) {
22
22
  case 'star': {
23
23
  const r = await gh.starRepo(args.repo);
@@ -38,7 +38,7 @@ export async function executeGithubStar(args: { action: 'star' | 'unstar' | 'che
38
38
 
39
39
  export async function executeGithubSubscribe(args: { repo: string; events?: string }, client: GithubClient, commMessage?: Message) {
40
40
  const msg = commMessage ?? getCurrentCommMessage();
41
- if (!msg?.$adapter || !msg?.$sender.id || !msg?.$channel?.id || !msg?.$endpoint) {
41
+ if (!msg?.clientAdapter || !msg?.sender?.id || !msg?.conversation.id || !msg?.endpointId) {
42
42
  return '❌ 无法获取当前聊天通道信息';
43
43
  }
44
44
 
@@ -53,12 +53,12 @@ export async function executeGithubSubscribe(args: { repo: string; events?: stri
53
53
 
54
54
  const [existing] = await model.select().where({
55
55
  repo: args.repo,
56
- target_id: msg.$channel?.id,
57
- adapter: msg.$adapter,
58
- endpoint: msg.$endpoint,
56
+ target_id: msg.conversation.id,
57
+ adapter: msg.clientAdapter,
58
+ endpoint: msg.endpointId,
59
59
  });
60
60
  if (existing) {
61
- await model.update({ events, target_type: msg.$channel?.type || 'private' }).where({ id: existing.id });
61
+ await model.update({ events, target_type: msg.conversation.kind || 'private' }).where({ id: existing.id });
62
62
  return `✅ 已更新订阅 ${args.repo}\n📡 事件: ${events.join(', ')}`;
63
63
  }
64
64
 
@@ -66,17 +66,17 @@ export async function executeGithubSubscribe(args: { repo: string; events?: stri
66
66
  id: Date.now(),
67
67
  repo: args.repo,
68
68
  events,
69
- target_id: msg.$channel?.id,
70
- target_type: msg.$channel?.type || 'private',
71
- adapter: msg.$adapter,
72
- endpoint: msg.$endpoint,
69
+ target_id: msg.conversation.id,
70
+ target_type: msg.conversation.kind || 'private',
71
+ adapter: msg.clientAdapter,
72
+ endpoint: msg.endpointId,
73
73
  });
74
74
  return `✅ 已订阅 ${args.repo}\n📡 事件: ${events.join(', ')}\n📌 通知将推送到当前通道`;
75
75
  }
76
76
 
77
77
  export async function executeGithubUnsubscribe(args: { repo: string }, client: GithubClient, commMessage?: Message) {
78
78
  const msg = commMessage ?? getCurrentCommMessage();
79
- if (!msg?.$adapter || !msg?.$channel?.id || !msg?.$endpoint) {
79
+ if (!msg?.clientAdapter || !msg?.conversation.id || !msg?.endpointId) {
80
80
  return '❌ 无法获取当前聊天通道信息';
81
81
  }
82
82
 
@@ -85,9 +85,9 @@ export async function executeGithubUnsubscribe(args: { repo: string }, client: G
85
85
 
86
86
  const [existing] = await model.select().where({
87
87
  repo: args.repo,
88
- target_id: msg.$channel?.id,
89
- adapter: msg.$adapter,
90
- endpoint: msg.$endpoint,
88
+ target_id: msg.conversation.id,
89
+ adapter: msg.clientAdapter,
90
+ endpoint: msg.endpointId,
91
91
  });
92
92
  if (!existing) return `📭 当前通道未订阅 ${args.repo}`;
93
93
 
@@ -97,7 +97,7 @@ export async function executeGithubUnsubscribe(args: { repo: string }, client: G
97
97
 
98
98
  export async function executeGithubSubscriptions(_args: Record<string, never>, client: GithubClient, commMessage?: Message) {
99
99
  const msg = commMessage ?? getCurrentCommMessage();
100
- if (!msg?.$adapter || !msg?.$channel?.id || !msg?.$endpoint) {
100
+ if (!msg?.clientAdapter || !msg?.conversation.id || !msg?.endpointId) {
101
101
  return '❌ 无法获取当前聊天通道信息';
102
102
  }
103
103
 
@@ -105,9 +105,9 @@ export async function executeGithubSubscriptions(_args: Record<string, never>, c
105
105
  if (!model) return '❌ 数据库未就绪';
106
106
 
107
107
  const subs = await model.select().where({
108
- target_id: msg.$channel?.id,
109
- adapter: msg.$adapter,
110
- endpoint: msg.$endpoint,
108
+ target_id: msg.conversation.id,
109
+ adapter: msg.clientAdapter,
110
+ endpoint: msg.endpointId,
111
111
  });
112
112
  if (!subs?.length) return '📭 当前通道没有任何 GitHub 订阅';
113
113
 
@@ -1,6 +1,6 @@
1
1
  import { buildChannelId, parseChannelId } from './types.js';
2
2
  export function parseMessageChannel(message) {
3
- const channelId = message.$channel?.id;
3
+ const channelId = message.conversation.id;
4
4
  if (!channelId)
5
5
  return null;
6
6
  const parsed = parseChannelId(channelId);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhin.js/adapter-github",
3
- "version": "1.1.3",
3
+ "version": "1.1.4",
4
4
  "description": "Zhin.js GitHub adapter for Plugin Runtime (App auth + webhook)",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",
@@ -43,7 +43,7 @@
43
43
  "dependencies": {
44
44
  "@zhin.js/adapter": "1.1.15",
45
45
  "@zhin.js/agent-feature": "1.1.2",
46
- "@zhin.js/core": "1.1.38",
46
+ "@zhin.js/core": "1.1.39",
47
47
  "@zhin.js/feature-kit": "1.1.2",
48
48
  "@zhin.js/host-http": "1.1.2",
49
49
  "@zhin.js/im-contract": "1.1.2",
@@ -54,12 +54,12 @@
54
54
  "peerDependencies": {
55
55
  "zod": "^4.0.0",
56
56
  "@zhin.js/adapter": "^1.1.15",
57
- "@zhin.js/agent": "^1.1.27",
58
- "@zhin.js/command": "^1.1.2",
59
- "@zhin.js/core": "^1.1.38",
57
+ "@zhin.js/agent": "^1.1.28",
58
+ "@zhin.js/command": "^1.1.3",
59
+ "@zhin.js/core": "^1.1.39",
60
60
  "@zhin.js/host-http": "^1.1.2",
61
61
  "@zhin.js/prompt-section": "^1.1.2",
62
- "zhin.js": "^1.1.3"
62
+ "zhin.js": "^1.1.4"
63
63
  },
64
64
  "peerDependenciesMeta": {
65
65
  "@zhin.js/agent": {
@@ -83,9 +83,9 @@
83
83
  "typescript": "^6.0.3",
84
84
  "vitest": "^4.1.10",
85
85
  "zod": "^4.4.3",
86
- "@zhin.js/agent": "1.1.27",
86
+ "@zhin.js/agent": "1.1.28",
87
87
  "@zhin.js/prompt-section": "1.1.2",
88
- "zhin.js": "1.1.3"
88
+ "zhin.js": "1.1.4"
89
89
  },
90
90
  "files": [
91
91
  "adapters",
@@ -10,7 +10,7 @@ export interface GitHubChannelContext extends ParsedChannel {
10
10
  }
11
11
 
12
12
  export function parseMessageChannel(message: Message): GitHubChannelContext | null {
13
- const channelId = message.$channel?.id;
13
+ const channelId = message.conversation.id;
14
14
  if (!channelId) return null;
15
15
  const parsed = parseChannelId(channelId);
16
16
  if (!parsed) return null;