@zhin.js/adapter-line 1.1.19 → 1.1.21

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,41 @@
1
1
  # @zhin.js/adapter-line
2
2
 
3
+ ## 1.1.21
4
+
5
+ ### Patch Changes
6
+
7
+ - 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.
8
+
9
+ 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.
10
+
11
+ 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.
12
+
13
+ - Updated dependencies [b88e988]
14
+ - Updated dependencies [f78eb84]
15
+ - Updated dependencies [c15cef9]
16
+ - Updated dependencies [b0c02a2]
17
+ - Updated dependencies [af8f803]
18
+ - Updated dependencies [26fda97]
19
+ - Updated dependencies [976886c]
20
+ - Updated dependencies [032dc96]
21
+ - @zhin.js/adapter@1.1.27
22
+ - @zhin.js/client@1.1.23
23
+ - @zhin.js/im-contract@1.1.10
24
+ - @zhin.js/core@1.1.55
25
+ - @zhin.js/tool@1.1.14
26
+ - @zhin.js/page@1.1.13
27
+ - @zhin.js/host-http@1.1.13
28
+ - @zhin.js/agent-feature@1.1.12
29
+ - @zhin.js/feature-kit@1.1.11
30
+ - @zhin.js/skill@1.1.12
31
+
32
+ ## 1.1.20
33
+
34
+ ### Patch Changes
35
+
36
+ - Updated dependencies [5e878ba]
37
+ - @zhin.js/page@1.1.12
38
+
3
39
  ## 1.1.19
4
40
 
5
41
  ### Patch Changes
package/lib/endpoint.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { createEndpointSpecification, endpointSpec } from 'zhin.js/adapter';
2
2
  import { LineClient } from './client.js';
3
+ import { createLineSelfProfile } from './self-profile.js';
3
4
  /** Actual protocol Client; framework lifecycle and admission stay in their symbol namespace. */
4
5
  export class LineEndpoint extends LineClient {
5
6
  [endpointSpec] = this.#createSpecification();
@@ -11,6 +12,7 @@ export class LineEndpoint extends LineClient {
11
12
  send: (request) => this.sendPayload(request),
12
13
  name: this.configName(),
13
14
  management: this.endpointManagement,
15
+ profile: createLineSelfProfile({ client: this, reportAccount: id => this[endpointSpec].reportSelfUserId(id) }),
14
16
  };
15
17
  Object.defineProperty(hooks, 'transportState', { get: () => this.transportState });
16
18
  return createEndpointSpecification(this, hooks);
package/lib/protocol.d.ts CHANGED
@@ -1,11 +1,8 @@
1
- /**
2
- * LINE Messaging API protocol 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
  /** One endpoint config after AdapterIndex expands `plugins.<instanceKey>.endpoints`. */
8
- export interface LineEndpointConfig {
5
+ export interface LineEndpointConfig extends EndpointProfileConfiguration {
9
6
  readonly id: string;
10
7
  readonly channelSecret: string;
11
8
  readonly channelAccessToken: string;
@@ -0,0 +1,9 @@
1
+ import type { EndpointProfile } from 'zhin.js/adapter';
2
+ import type { LineApiClient } from './api-client.js';
3
+ interface LineSelfProfileOptions {
4
+ readonly client: Pick<LineApiClient, 'request'>;
5
+ readonly reportAccount: (id: string) => void;
6
+ }
7
+ /** Messaging API exposes bot info, but profile edits remain in LINE account administration. */
8
+ export declare function createLineSelfProfile({ client, reportAccount }: LineSelfProfileOptions): EndpointProfile;
9
+ export {};
@@ -0,0 +1,13 @@
1
+ /** Messaging API exposes bot info, but profile edits remain in LINE account administration. */
2
+ export function createLineSelfProfile({ client, reportAccount }) {
3
+ return Object.freeze({
4
+ writableFields: Object.freeze([]),
5
+ async read({ signal }) {
6
+ const self = await client.request('/v2/bot/info', { signal });
7
+ if (!self.userId || typeof self.displayName !== 'string')
8
+ throw new Error('LINE returned an incomplete bot profile');
9
+ reportAccount(self.userId);
10
+ return { nickname: self.displayName, ...(typeof self.pictureUrl === 'string' ? { avatar: self.pictureUrl } : {}) };
11
+ },
12
+ });
13
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhin.js/adapter-line",
3
- "version": "1.1.19",
3
+ "version": "1.1.21",
4
4
  "description": "Zhin.js LINE Messaging API adapter for Plugin Runtime (HTTP webhook)",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",
@@ -31,26 +31,26 @@
31
31
  "directory": "plugins/adapters/line"
32
32
  },
33
33
  "dependencies": {
34
- "@zhin.js/adapter": "1.1.26",
35
- "@zhin.js/agent-feature": "1.1.11",
36
- "@zhin.js/client": "1.1.22",
34
+ "@zhin.js/adapter": "1.1.27",
35
+ "@zhin.js/agent-feature": "1.1.12",
36
+ "@zhin.js/client": "1.1.23",
37
37
  "@zhin.js/console-contract": "1.1.3",
38
- "@zhin.js/core": "1.1.54",
39
- "@zhin.js/feature-kit": "1.1.10",
40
- "@zhin.js/host-http": "1.1.12",
41
- "@zhin.js/im-contract": "1.1.9",
38
+ "@zhin.js/core": "1.1.55",
39
+ "@zhin.js/feature-kit": "1.1.11",
40
+ "@zhin.js/host-http": "1.1.13",
41
+ "@zhin.js/im-contract": "1.1.10",
42
42
  "@zhin.js/logger": "1.1.2",
43
- "@zhin.js/page": "1.1.11",
44
- "@zhin.js/skill": "1.1.11",
45
- "@zhin.js/tool": "1.1.13"
43
+ "@zhin.js/page": "1.1.13",
44
+ "@zhin.js/skill": "1.1.12",
45
+ "@zhin.js/tool": "1.1.14"
46
46
  },
47
47
  "peerDependencies": {
48
48
  "zod": "^4.0.0",
49
- "@zhin.js/adapter": "^1.1.26",
50
- "@zhin.js/command": "^1.1.12",
51
- "@zhin.js/core": "^1.1.54",
52
- "@zhin.js/host-http": "^1.1.12",
53
- "zhin.js": "^1.1.19"
49
+ "@zhin.js/adapter": "^1.1.27",
50
+ "@zhin.js/command": "^1.1.13",
51
+ "@zhin.js/core": "^1.1.55",
52
+ "@zhin.js/host-http": "^1.1.13",
53
+ "zhin.js": "^1.1.20"
54
54
  },
55
55
  "peerDependenciesMeta": {
56
56
  "@zhin.js/command": {
@@ -68,7 +68,7 @@
68
68
  "typescript": "^6.0.3",
69
69
  "vitest": "^4.1.10",
70
70
  "zod": "^4.4.3",
71
- "zhin.js": "1.1.19"
71
+ "zhin.js": "1.1.20"
72
72
  },
73
73
  "files": [
74
74
  "adapters",
@@ -100,7 +100,7 @@
100
100
  "features": [
101
101
  {
102
102
  "package": "@zhin.js/adapter",
103
- "api": "^2.0.0"
103
+ "api": "^2.1.0"
104
104
  },
105
105
  {
106
106
  "package": "@zhin.js/command",
@@ -108,7 +108,7 @@
108
108
  },
109
109
  {
110
110
  "package": "@zhin.js/tool",
111
- "api": "^1.0.0"
111
+ "api": "^1.1.0"
112
112
  },
113
113
  {
114
114
  "package": "@zhin.js/skill",
package/schema.json CHANGED
@@ -95,6 +95,27 @@
95
95
  "id": {
96
96
  "type": "string",
97
97
  "description": "LINE bot name"
98
+ },
99
+ "nickname": {
100
+ "type": [
101
+ "string",
102
+ "null"
103
+ ],
104
+ "description": "账号昵称兜底",
105
+ "x-i18n": {
106
+ "en": {
107
+ "description": "Fallback account nickname"
108
+ }
109
+ }
110
+ },
111
+ "profile": {
112
+ "$ref": "#/$defs/selfProfileFallback",
113
+ "description": "账号资料兜底",
114
+ "x-i18n": {
115
+ "en": {
116
+ "description": "Fallback account profile"
117
+ }
118
+ }
98
119
  }
99
120
  },
100
121
  "required": [
@@ -118,9 +139,93 @@
118
139
  "description": "Command prefix. The default empty string allows unprefixed commands; '/' requires a leading slash. Each endpoints[i] can override it."
119
140
  }
120
141
  }
142
+ },
143
+ "nickname": {
144
+ "type": [
145
+ "string",
146
+ "null"
147
+ ],
148
+ "description": "账号昵称兜底",
149
+ "x-i18n": {
150
+ "en": {
151
+ "description": "Fallback account nickname"
152
+ }
153
+ }
154
+ },
155
+ "profile": {
156
+ "$ref": "#/$defs/selfProfileFallback",
157
+ "description": "账号资料兜底",
158
+ "x-i18n": {
159
+ "en": {
160
+ "description": "Fallback account profile"
161
+ }
162
+ }
121
163
  }
122
164
  },
123
165
  "required": [
124
166
  "endpoints"
125
- ]
167
+ ],
168
+ "$defs": {
169
+ "selfProfileFallback": {
170
+ "type": "object",
171
+ "additionalProperties": false,
172
+ "properties": {
173
+ "gender": {
174
+ "type": [
175
+ "string",
176
+ "null"
177
+ ],
178
+ "enum": [
179
+ "male",
180
+ "female",
181
+ "other",
182
+ "unknown",
183
+ null
184
+ ]
185
+ },
186
+ "age": {
187
+ "type": [
188
+ "integer",
189
+ "null"
190
+ ],
191
+ "minimum": 0
192
+ },
193
+ "birthday": {
194
+ "type": [
195
+ "string",
196
+ "null"
197
+ ],
198
+ "pattern": "^\\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\\d|3[01])$"
199
+ },
200
+ "signature": {
201
+ "type": [
202
+ "string",
203
+ "null"
204
+ ]
205
+ },
206
+ "avatar": {
207
+ "type": [
208
+ "string",
209
+ "null"
210
+ ],
211
+ "pattern": "^(https?://[^\\s/?#]+(?:[/?#].*)?|)$"
212
+ },
213
+ "interests": {
214
+ "type": [
215
+ "array",
216
+ "null"
217
+ ],
218
+ "items": {
219
+ "type": "string"
220
+ }
221
+ },
222
+ "bio": {
223
+ "type": [
224
+ "string",
225
+ "null"
226
+ ]
227
+ }
228
+ }
229
+ }
230
+ }
126
231
  }
package/src/endpoint.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { createEndpointSpecification, endpointSpec, type Endpoint } from 'zhin.js/adapter';
2
2
  import { LineClient, type LineEndpointOptions } from './client.js';
3
+ import { createLineSelfProfile } from './self-profile.js';
3
4
  export type { LineEndpointOptions } from './client.js';
4
5
  export type { LineFetch } from './client.js';
5
6
 
@@ -14,6 +15,7 @@ export class LineEndpoint extends LineClient implements Endpoint {
14
15
  send: (request: import('zhin.js/adapter').EndpointSendRequest) => this.sendPayload(request),
15
16
  name: this.configName(),
16
17
  management: this.endpointManagement,
18
+ profile: createLineSelfProfile({ client: this, reportAccount: id => this[endpointSpec].reportSelfUserId(id) }),
17
19
  };
18
20
  Object.defineProperty(hooks, 'transportState', { get: () => this.transportState });
19
21
  return createEndpointSpecification(this, hooks);
package/src/protocol.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { EndpointProfileConfiguration } from 'zhin.js/adapter';
1
2
  /**
2
3
  * LINE Messaging API protocol helpers — no legacy Adapter/Endpoint / segment-mapper.
3
4
  * Canonicalization is owned by gateway/core before endpoint.send.
@@ -11,7 +12,7 @@ import { formatCompact, getLogger } from '@zhin.js/logger';
11
12
  const logger = getLogger('line');
12
13
 
13
14
  /** One endpoint config after AdapterIndex expands `plugins.<instanceKey>.endpoints`. */
14
- export interface LineEndpointConfig {
15
+ export interface LineEndpointConfig extends EndpointProfileConfiguration {
15
16
  readonly id: string;
16
17
  readonly channelSecret: string;
17
18
  readonly channelAccessToken: string;
@@ -0,0 +1,20 @@
1
+ import type { EndpointProfile } from 'zhin.js/adapter';
2
+ import type { LineApiClient } from './api-client.js';
3
+
4
+ interface LineSelfProfileOptions {
5
+ readonly client: Pick<LineApiClient, 'request'>;
6
+ readonly reportAccount: (id: string) => void;
7
+ }
8
+
9
+ /** Messaging API exposes bot info, but profile edits remain in LINE account administration. */
10
+ export function createLineSelfProfile({ client, reportAccount }: LineSelfProfileOptions): EndpointProfile {
11
+ return Object.freeze<EndpointProfile>({
12
+ writableFields: Object.freeze([]),
13
+ async read({ signal }) {
14
+ const self = await client.request<{ userId: string; displayName: string; pictureUrl?: string }>('/v2/bot/info', { signal });
15
+ if (!self.userId || typeof self.displayName !== 'string') throw new Error('LINE returned an incomplete bot profile');
16
+ reportAccount(self.userId);
17
+ return { nickname: self.displayName, ...(typeof self.pictureUrl === 'string' ? { avatar: self.pictureUrl } : {}) };
18
+ },
19
+ });
20
+ }