@zhin.js/adapter-github 1.1.20 → 1.1.22

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,67 @@
1
1
  # @zhin.js/adapter-github
2
2
 
3
+ ## 1.1.22
4
+
5
+ ### Patch Changes
6
+
7
+ - 41ff1a5: ADR 0044 C5: every official adapter now declares a capability `profile` (its `segments` moved into `profile.default.messaging.segments`). icqq declares the complete profile (per conversation kind: scene, all 14 actions with real limits, events, feedback, delivery) and implements the seven new management ports (`pokeUser`, `unmuteGroupMember`, `muteAllGroupMembers`, `setGroupCard`, `setGroupTitle`, `setGroupEssence`, `inviteGroupMember`) with fresh bot-role reads. qq official declares its passive reply windows; undeclared capabilities stay unsupported.
8
+ - cbd3f14: ADR 0044 integration and C6 guard. `delivery.spool` now reproduces the pre-0044 media rule (icqq `false`, every other official adapter `true`). icqq narrows `actions.recall.others` unless the Bot is admin or owner, and declares recall for groups. Endpoint kind capabilities merge the Endpoint's `operations` (Discord reactions keep working; Discord declares reaction feedback). Adapters in the `@zhin.js/` scope are trusted: their custom prompt text is not labelled `external_content`. Core no longer keeps a telegram/discord interactive-policy table (adapters declare `segments.interactive`). New `pnpm check:no-platform-branches` blocks platform-name branches in runtime code.
9
+ - 4fe49b5: 支持配置按需生效:分离保存与有效版本,独立变更先应用,账号资料更新保留连接,模型按回合使用确定版本;Console 返回结构化应用结果。监听改为仅显式 --watch 启用,开发模板显式选择源码和配置监听。
10
+
11
+ 自变更消费配置应用回执,避免已处理配置被二次重载;持久化本次写入修订和应用结果,未知结果或修订冲突时停止自动续作并保留现场,恢复不会覆盖未经本次变更确认的配置。
12
+
13
+ - Updated dependencies [b249e5e]
14
+ - Updated dependencies [57661f6]
15
+ - Updated dependencies [cbd3f14]
16
+ - Updated dependencies [299863a]
17
+ - Updated dependencies [aaa93d7]
18
+ - Updated dependencies [bd524d1]
19
+ - Updated dependencies [126ae99]
20
+ - Updated dependencies [4fe49b5]
21
+ - Updated dependencies [cce07db]
22
+ - Updated dependencies [b652db3]
23
+ - Updated dependencies [0315ba0]
24
+ - Updated dependencies [00be764]
25
+ - @zhin.js/core@1.1.56
26
+ - @zhin.js/adapter@1.1.28
27
+ - @zhin.js/im-contract@1.1.11
28
+ - @zhin.js/tool@1.1.15
29
+ - @zhin.js/skill@1.1.13
30
+ - @zhin.js/host-http@1.1.14
31
+ - @zhin.js/feature-kit@1.1.12
32
+ - @zhin.js/client@1.1.24
33
+ - @zhin.js/page@1.1.14
34
+ - @zhin.js/agent-feature@1.1.13
35
+
36
+ ## 1.1.21
37
+
38
+ ### Patch Changes
39
+
40
+ - af8f803: Use the current Endpoint's platform profile for Agent account identity, with per-field configured fallbacks and scoped, identity-approved profile tools. Keep SOUL first-person and independent of account names. Profile ports preserve the source Client, cancellation, truthful update outcomes and private image authority.
41
+
42
+ Adapter Feature API 2.1 and Tool Feature API 1.1 describe the additive profile requirements; new Core, official adapters and generated plugins declare the corresponding floors. Existing compatible API-2.0/API-1.0 plugins remain accepted by the newer providers. npm releases remain patch.
43
+
44
+ Private IM assets now bind to the full canonical conversation and principal. Existing IM asset records that contain only the earlier lossy hash remain on disk until their original expiry, but cannot be safely rebound; recapture them. No automatic file deletion, platform profile mutation or workspace SOUL rewrite occurs during upgrade.
45
+
46
+ - Updated dependencies [b88e988]
47
+ - Updated dependencies [f78eb84]
48
+ - Updated dependencies [c15cef9]
49
+ - Updated dependencies [b0c02a2]
50
+ - Updated dependencies [af8f803]
51
+ - Updated dependencies [26fda97]
52
+ - Updated dependencies [976886c]
53
+ - Updated dependencies [032dc96]
54
+ - @zhin.js/adapter@1.1.27
55
+ - @zhin.js/client@1.1.23
56
+ - @zhin.js/im-contract@1.1.10
57
+ - @zhin.js/core@1.1.55
58
+ - @zhin.js/tool@1.1.14
59
+ - @zhin.js/page@1.1.13
60
+ - @zhin.js/host-http@1.1.13
61
+ - @zhin.js/agent-feature@1.1.12
62
+ - @zhin.js/feature-kit@1.1.11
63
+ - @zhin.js/skill@1.1.12
64
+
3
65
  ## 1.1.20
4
66
 
5
67
  ### Patch Changes
@@ -10,9 +10,16 @@ export { GithubEndpoint } from "../../lib/endpoint.js";
10
10
  export default defineAdapter({
11
11
  capabilities: ['inbound', 'outbound'],
12
12
  // Issue/PR 评论以 markdown 图片链接消费远程 URL;无交互面,交互段降级纯文本。
13
- segments: {
14
- outboundMedia: ['url'],
15
- interactive: 'text',
13
+ profile: {
14
+ default: {
15
+ messaging: {
16
+ segments: {
17
+ outboundMedia: ['url'],
18
+ interactive: 'text',
19
+ },
20
+ },
21
+ delivery: { send: true, spool: true },
22
+ },
16
23
  },
17
24
  createAdapter: context => new GithubAdapter(context),
18
25
  });
@@ -15,9 +15,16 @@ export type { GithubEndpointOptions } from '../../src/endpoint.js';
15
15
  export default defineAdapter<GithubEndpointConfig>({
16
16
  capabilities: ['inbound', 'outbound'],
17
17
  // Issue/PR 评论以 markdown 图片链接消费远程 URL;无交互面,交互段降级纯文本。
18
- segments: {
19
- outboundMedia: ['url'],
20
- interactive: 'text',
18
+ profile: {
19
+ default: {
20
+ messaging: {
21
+ segments: {
22
+ outboundMedia: ['url'],
23
+ interactive: 'text',
24
+ },
25
+ },
26
+ delivery: { send: true, spool: true },
27
+ },
21
28
  },
22
29
  createAdapter: context => new GithubAdapter(context),
23
30
  });
package/lib/endpoint.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { createEndpointSpecification, endpointSpec } from 'zhin.js/adapter';
2
2
  import { formatCompact, getAdapterLogger } from '@zhin.js/logger';
3
3
  import { GhClient } from './gh-client.js';
4
+ import { createGithubSelfProfile } from './self-profile.js';
4
5
  import { enrichInboundContent, formatInboundContent, formatOutboundBody, githubInboundConversation, parseChannelId, } from './protocol.js';
5
6
  import { registerGithubWebhookRoutes } from './webhook.js';
6
7
  import { WorkspaceManager } from './workspace-manager.js';
@@ -13,6 +14,7 @@ export class GithubEndpoint extends GhClient {
13
14
  [endpointSpec] = createEndpointSpecification(this, {
14
15
  start: signal => this.#startFramework(signal), open: () => this.#openFramework(), close: () => this.#closeFramework(),
15
16
  stop: () => this.#stopFramework(), send: request => this.#sendFramework(request),
17
+ profile: createGithubSelfProfile({ client: this, reportAccount: id => this[endpointSpec].reportSelfUserId(id) }),
16
18
  });
17
19
  #workspaceManager;
18
20
  get database() { return this.#options.database; }
package/lib/protocol.d.ts CHANGED
@@ -1,14 +1,11 @@
1
- /**
2
- * GitHub webhook / comment helpers — no legacy Adapter/Endpoint / segment-mapper.
3
- * Canonicalization is owned by gateway/core before endpoint.send.
4
- */
1
+ import type { EndpointProfileConfiguration } from 'zhin.js/adapter';
5
2
  import type { IncomingMessage } from 'node:http';
6
3
  import { type ConversationRef } from '@zhin.js/im-contract';
7
4
  import { type GenericWebhookPayload, type IssueCommentPayload, type PRReviewCommentPayload, type PRReviewPayload } from './types.js';
8
5
  export type { EventType, GenericWebhookPayload, GitHubComment, GitHubIssue, GitHubOAuthUser, GitHubPR, GitHubRepo, GitHubUser, IssueCommentPayload, ParsedChannel, PRReviewCommentPayload, PRReviewPayload, Subscription, } from './types.js';
9
6
  export { buildChannelId, parseChannelId } from './types.js';
10
7
  /** One expanded GitHub endpoint configuration produced by AdapterIndex. */
11
- export interface GithubEndpointConfig {
8
+ export interface GithubEndpointConfig extends EndpointProfileConfiguration {
12
9
  readonly id: string;
13
10
  readonly host?: string;
14
11
  readonly app_id: string | number;
@@ -0,0 +1,9 @@
1
+ import { type EndpointProfile } from 'zhin.js/adapter';
2
+ import type { GhClient } from './gh-client.js';
3
+ interface GithubSelfProfileOptions {
4
+ readonly client: Pick<GhClient, 'getBotIdentity' | 'request' | 'isAppAuth'>;
5
+ readonly reportAccount: (id: string) => void;
6
+ }
7
+ /** PAT accounts read /user; GitHub Apps read the verified app bot's public user profile. */
8
+ export declare function createGithubSelfProfile({ client, reportAccount }: GithubSelfProfileOptions): EndpointProfile;
9
+ export {};
@@ -0,0 +1,27 @@
1
+ import { createEndpointOperation } from 'zhin.js/adapter';
2
+ /** PAT accounts read /user; GitHub Apps read the verified app bot's public user profile. */
3
+ export function createGithubSelfProfile({ client, reportAccount }) {
4
+ return Object.freeze({
5
+ writableFields: Object.freeze([]),
6
+ async read({ signal }) {
7
+ const operation = createEndpointOperation({ signal });
8
+ const bot = await operation.prepare(() => client.getBotIdentity());
9
+ if (client.isAppAuth && !bot)
10
+ throw new Error('GitHub App bot identity is unavailable');
11
+ const response = await client.request({
12
+ method: 'GET', path: bot ? `/users/${encodeURIComponent(bot.login)}` : '/user', signal,
13
+ });
14
+ if (!response.ok)
15
+ throw new Error(`GitHub self profile lookup failed (${response.status}): ${response.data?.message ?? 'API request failed'}`);
16
+ if (!response.data?.id || typeof response.data.login !== 'string')
17
+ throw new Error('GitHub returned no account profile');
18
+ if (bot && response.data.id !== bot.userId)
19
+ throw new Error('GitHub returned another account profile');
20
+ const user = response.data;
21
+ reportAccount(String(user.id));
22
+ return { nickname: user.name || user.login,
23
+ ...(user.bio === null || typeof user.bio === 'string' ? { bio: user.bio } : {}),
24
+ ...(typeof user.avatar_url === 'string' ? { avatar: user.avatar_url } : {}) };
25
+ },
26
+ });
27
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhin.js/adapter-github",
3
- "version": "1.1.20",
3
+ "version": "1.1.22",
4
4
  "description": "Zhin.js GitHub adapter for Plugin Runtime (App auth + webhook)",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",
@@ -39,28 +39,28 @@
39
39
  "directory": "plugins/adapters/github"
40
40
  },
41
41
  "dependencies": {
42
- "@zhin.js/adapter": "1.1.26",
43
- "@zhin.js/agent-feature": "1.1.11",
44
- "@zhin.js/client": "1.1.22",
42
+ "@zhin.js/agent-feature": "1.1.13",
43
+ "@zhin.js/client": "1.1.24",
45
44
  "@zhin.js/console-contract": "1.1.3",
46
- "@zhin.js/core": "1.1.54",
47
- "@zhin.js/feature-kit": "1.1.10",
48
- "@zhin.js/host-http": "1.1.12",
49
- "@zhin.js/im-contract": "1.1.9",
45
+ "@zhin.js/core": "1.1.56",
46
+ "@zhin.js/feature-kit": "1.1.12",
47
+ "@zhin.js/host-http": "1.1.14",
48
+ "@zhin.js/im-contract": "1.1.11",
50
49
  "@zhin.js/logger": "1.1.2",
51
- "@zhin.js/page": "1.1.12",
52
- "@zhin.js/skill": "1.1.11",
53
- "@zhin.js/tool": "1.1.13"
50
+ "@zhin.js/page": "1.1.14",
51
+ "@zhin.js/skill": "1.1.13",
52
+ "@zhin.js/tool": "1.1.15",
53
+ "@zhin.js/adapter": "1.1.28"
54
54
  },
55
55
  "peerDependencies": {
56
56
  "zod": "^4.0.0",
57
- "@zhin.js/adapter": "^1.1.26",
58
- "@zhin.js/agent": "^1.1.45",
59
- "@zhin.js/command": "^1.1.12",
60
- "@zhin.js/core": "^1.1.54",
61
- "@zhin.js/host-http": "^1.1.12",
62
- "@zhin.js/prompt-section": "^1.1.10",
63
- "zhin.js": "^1.1.19"
57
+ "@zhin.js/adapter": "^1.1.28",
58
+ "@zhin.js/agent": "^1.1.47",
59
+ "@zhin.js/command": "^1.1.14",
60
+ "@zhin.js/core": "^1.1.56",
61
+ "@zhin.js/host-http": "^1.1.14",
62
+ "@zhin.js/prompt-section": "^1.1.12",
63
+ "zhin.js": "^1.1.21"
64
64
  },
65
65
  "peerDependenciesMeta": {
66
66
  "@zhin.js/agent": {
@@ -84,9 +84,9 @@
84
84
  "typescript": "^6.0.3",
85
85
  "vitest": "^4.1.10",
86
86
  "zod": "^4.4.3",
87
- "@zhin.js/agent": "1.1.45",
88
- "@zhin.js/prompt-section": "1.1.10",
89
- "zhin.js": "1.1.19"
87
+ "@zhin.js/agent": "1.1.47",
88
+ "@zhin.js/prompt-section": "1.1.12",
89
+ "zhin.js": "1.1.21"
90
90
  },
91
91
  "files": [
92
92
  "adapters",
@@ -117,7 +117,7 @@
117
117
  "features": [
118
118
  {
119
119
  "package": "@zhin.js/adapter",
120
- "api": "^2.0.0"
120
+ "api": "^2.1.0"
121
121
  },
122
122
  {
123
123
  "package": "@zhin.js/command",
@@ -125,7 +125,7 @@
125
125
  },
126
126
  {
127
127
  "package": "@zhin.js/tool",
128
- "api": "^1.0.0"
128
+ "api": "^1.1.0"
129
129
  },
130
130
  {
131
131
  "package": "@zhin.js/skill",
package/plugin.js CHANGED
@@ -22,6 +22,7 @@ const GITHUB_SUBSCRIPTIONS_SCHEMA = {
22
22
  */
23
23
  export default definePlugin({
24
24
  name: 'github',
25
+ configUpdate: { featurePaths: [['nickname'], ['profile'], ['endpoints']] },
25
26
  metadata: {
26
27
  displayName: 'GitHub Adapter',
27
28
  },
package/schema.json CHANGED
@@ -141,6 +141,27 @@
141
141
  "description": "Command prefix for this endpoint."
142
142
  }
143
143
  }
144
+ },
145
+ "nickname": {
146
+ "type": [
147
+ "string",
148
+ "null"
149
+ ],
150
+ "description": "账号昵称兜底",
151
+ "x-i18n": {
152
+ "en": {
153
+ "description": "Fallback account nickname"
154
+ }
155
+ }
156
+ },
157
+ "profile": {
158
+ "$ref": "#/$defs/selfProfileFallback",
159
+ "description": "账号资料兜底",
160
+ "x-i18n": {
161
+ "en": {
162
+ "description": "Fallback account profile"
163
+ }
164
+ }
144
165
  }
145
166
  },
146
167
  "required": [
@@ -164,9 +185,93 @@
164
185
  "description": "Command prefix. The default empty string allows unprefixed commands; '/' requires a leading slash. Each endpoints[i] can override it."
165
186
  }
166
187
  }
188
+ },
189
+ "nickname": {
190
+ "type": [
191
+ "string",
192
+ "null"
193
+ ],
194
+ "description": "账号昵称兜底",
195
+ "x-i18n": {
196
+ "en": {
197
+ "description": "Fallback account nickname"
198
+ }
199
+ }
200
+ },
201
+ "profile": {
202
+ "$ref": "#/$defs/selfProfileFallback",
203
+ "description": "账号资料兜底",
204
+ "x-i18n": {
205
+ "en": {
206
+ "description": "Fallback account profile"
207
+ }
208
+ }
167
209
  }
168
210
  },
169
211
  "required": [
170
212
  "endpoints"
171
- ]
213
+ ],
214
+ "$defs": {
215
+ "selfProfileFallback": {
216
+ "type": "object",
217
+ "additionalProperties": false,
218
+ "properties": {
219
+ "gender": {
220
+ "type": [
221
+ "string",
222
+ "null"
223
+ ],
224
+ "enum": [
225
+ "male",
226
+ "female",
227
+ "other",
228
+ "unknown",
229
+ null
230
+ ]
231
+ },
232
+ "age": {
233
+ "type": [
234
+ "integer",
235
+ "null"
236
+ ],
237
+ "minimum": 0
238
+ },
239
+ "birthday": {
240
+ "type": [
241
+ "string",
242
+ "null"
243
+ ],
244
+ "pattern": "^\\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\\d|3[01])$"
245
+ },
246
+ "signature": {
247
+ "type": [
248
+ "string",
249
+ "null"
250
+ ]
251
+ },
252
+ "avatar": {
253
+ "type": [
254
+ "string",
255
+ "null"
256
+ ],
257
+ "pattern": "^(https?://[^\\s/?#]+(?:[/?#].*)?|)$"
258
+ },
259
+ "interests": {
260
+ "type": [
261
+ "array",
262
+ "null"
263
+ ],
264
+ "items": {
265
+ "type": "string"
266
+ }
267
+ },
268
+ "bio": {
269
+ "type": [
270
+ "string",
271
+ "null"
272
+ ]
273
+ }
274
+ }
275
+ }
276
+ }
172
277
  }
package/src/endpoint.ts CHANGED
@@ -6,6 +6,7 @@ import type { HttpHost, HttpRouteRegistration } from '@zhin.js/host-http';
6
6
  import { formatCompact, getAdapterLogger } from '@zhin.js/logger';
7
7
  import type { CapabilityId, PluginDatabaseHost } from 'zhin.js';
8
8
  import { GhClient } from './gh-client.js';
9
+ import { createGithubSelfProfile } from './self-profile.js';
9
10
  import {
10
11
  enrichInboundContent,
11
12
  formatInboundContent,
@@ -34,6 +35,7 @@ export class GithubEndpoint extends GhClient implements Endpoint {
34
35
  readonly [endpointSpec] = createEndpointSpecification(this, {
35
36
  start: signal => this.#startFramework(signal), open: () => this.#openFramework(), close: () => this.#closeFramework(),
36
37
  stop: () => this.#stopFramework(), send: request => this.#sendFramework(request),
38
+ profile: createGithubSelfProfile({ client: this, reportAccount: id => this[endpointSpec].reportSelfUserId(id) }),
37
39
  });
38
40
  #workspaceManager?: WorkspaceManager;
39
41
  get database() { return this.#options.database; }
package/src/protocol.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { EndpointProfileConfiguration } from 'zhin.js/adapter';
1
2
  /**
2
3
  * GitHub webhook / comment helpers — no legacy Adapter/Endpoint / segment-mapper.
3
4
  * Canonicalization is owned by gateway/core before endpoint.send.
@@ -36,7 +37,7 @@ export type {
36
37
  export { buildChannelId, parseChannelId } from './types.js';
37
38
 
38
39
  /** One expanded GitHub endpoint configuration produced by AdapterIndex. */
39
- export interface GithubEndpointConfig {
40
+ export interface GithubEndpointConfig extends EndpointProfileConfiguration {
40
41
  readonly id: string;
41
42
  readonly host?: string;
42
43
  readonly app_id: string | number;
@@ -0,0 +1,30 @@
1
+ import { createEndpointOperation, type EndpointProfile } from 'zhin.js/adapter';
2
+ import type { GhClient } from './gh-client.js';
3
+
4
+ interface GithubSelfProfileOptions {
5
+ readonly client: Pick<GhClient, 'getBotIdentity' | 'request' | 'isAppAuth'>;
6
+ readonly reportAccount: (id: string) => void;
7
+ }
8
+
9
+ /** PAT accounts read /user; GitHub Apps read the verified app bot's public user profile. */
10
+ export function createGithubSelfProfile({ client, reportAccount }: GithubSelfProfileOptions): EndpointProfile {
11
+ return Object.freeze<EndpointProfile>({
12
+ writableFields: Object.freeze([]),
13
+ async read({ signal }) {
14
+ const operation = createEndpointOperation({ signal });
15
+ const bot = await operation.prepare(() => client.getBotIdentity());
16
+ if (client.isAppAuth && !bot) throw new Error('GitHub App bot identity is unavailable');
17
+ const response = await client.request<{ id?: number; login?: string; name?: string | null; bio?: string | null; avatar_url?: string; message?: string }>({
18
+ method: 'GET', path: bot ? `/users/${encodeURIComponent(bot.login)}` : '/user', signal,
19
+ });
20
+ if (!response.ok) throw new Error(`GitHub self profile lookup failed (${response.status}): ${response.data?.message ?? 'API request failed'}`);
21
+ if (!response.data?.id || typeof response.data.login !== 'string') throw new Error('GitHub returned no account profile');
22
+ if (bot && response.data.id !== bot.userId) throw new Error('GitHub returned another account profile');
23
+ const user = response.data;
24
+ reportAccount(String(user.id));
25
+ return { nickname: user.name || user.login,
26
+ ...(user.bio === null || typeof user.bio === 'string' ? { bio: user.bio } : {}),
27
+ ...(typeof user.avatar_url === 'string' ? { avatar: user.avatar_url } : {}) };
28
+ },
29
+ });
30
+ }