@zhin.js/adapter-github 4.0.1 → 4.0.2

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,23 @@
1
1
  # @zhin.js/adapter-github
2
2
 
3
+ ## 4.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - d5cd4aa: Publish Plugin Runtime entry points and convention modules as JavaScript so
8
+ installed npm plugins load on Node without TypeScript stripping. Workspace
9
+ development continues to prefer TypeScript sources for local HMR.
10
+
11
+ Remove the unconsumed legacy game hub APIs from game-kit; game navigation and
12
+ records now use ordinary convention commands owned by the game hub plugin.
13
+
14
+ - Updated dependencies [d5cd4aa]
15
+ - @zhin.js/command@1.0.4
16
+ - zhin.js@5.0.2
17
+ - @zhin.js/adapter@1.1.2
18
+ - @zhin.js/core@1.4.2
19
+ - @zhin.js/agent@1.0.7
20
+
3
21
  ## 4.0.1
4
22
 
5
23
  ### Patch Changes
@@ -0,0 +1,54 @@
1
+ // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
+ /**
3
+ * Convention entry: discover `adapters/github.ts` → defineAdapter.
4
+ * Implementation lives under `src/` (endpoint / webhook / oauth / protocol).
5
+ */
6
+ import { defineAdapter } from '@zhin.js/adapter';
7
+ import { messageGatewayToken } from '@zhin.js/core/runtime';
8
+ import { httpHostToken } from '@zhin.js/host-http';
9
+ import { databaseHostToken, } from '@zhin.js/plugin-runtime';
10
+ import { GithubEndpoint } from "../lib/endpoint.js";
11
+ import { githubRuntimeStateToken } from "../lib/github-runtime-state.js";
12
+ import { resolveGithubConfig, } from "../lib/protocol.js";
13
+ export { GithubEndpoint } from "../lib/endpoint.js";
14
+ function optionalDatabase(context) {
15
+ try {
16
+ return context.use(databaseHostToken);
17
+ }
18
+ catch {
19
+ return undefined;
20
+ }
21
+ }
22
+ export default defineAdapter({
23
+ capabilities: ['inbound', 'outbound'],
24
+ // Issue/PR 评论以 markdown 图片链接消费远程 URL;无交互面,交互段降级纯文本。
25
+ segments: {
26
+ outboundMedia: ['url'],
27
+ interactive: 'text',
28
+ },
29
+ create(context) {
30
+ const config = resolveGithubConfig(context.config);
31
+ const database = optionalDatabase(context);
32
+ // 注册到插件运行时状态(github endpoint list 的"运行中"数据源)
33
+ context.use(githubRuntimeStateToken).endpoints.set(config.name, {
34
+ name: config.name,
35
+ mode: config.webhookSecret ? 'webhook' : 'api',
36
+ });
37
+ if (config.webhookSecret) {
38
+ return new GithubEndpoint({
39
+ id: context.id,
40
+ gateway: context.use(messageGatewayToken),
41
+ http: context.use(httpHostToken),
42
+ database,
43
+ config,
44
+ });
45
+ }
46
+ // API-only: Issue/PR send + agent tools without webhook.
47
+ return new GithubEndpoint({
48
+ id: context.id,
49
+ gateway: context.use(messageGatewayToken),
50
+ database,
51
+ config,
52
+ });
53
+ },
54
+ });
@@ -0,0 +1,3 @@
1
+ // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
+ import { githubEndpointCommands } from "../../../lib/github-endpoint-commands.js";
3
+ export default githubEndpointCommands.add;
@@ -0,0 +1,3 @@
1
+ // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
+ import { githubEndpointCommands } from "../../lib/github-endpoint-commands.js";
3
+ export default githubEndpointCommands.list;
@@ -0,0 +1,3 @@
1
+ // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
+ import { githubEndpointCommands } from "../../../lib/github-endpoint-commands.js";
3
+ export default githubEndpointCommands.remove;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhin.js/adapter-github",
3
- "version": "4.0.1",
3
+ "version": "4.0.2",
4
4
  "description": "Zhin.js GitHub adapter for Plugin Runtime (App auth + webhook)",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",
@@ -41,21 +41,21 @@
41
41
  "directory": "plugins/adapters/github"
42
42
  },
43
43
  "dependencies": {
44
- "@zhin.js/adapter": "1.1.1",
45
- "@zhin.js/command": "1.0.3",
46
- "@zhin.js/core": "1.4.1",
44
+ "@zhin.js/adapter": "1.1.2",
45
+ "@zhin.js/command": "1.0.4",
46
+ "@zhin.js/core": "1.4.2",
47
47
  "@zhin.js/host-http": "1.0.3",
48
48
  "@zhin.js/logger": "1.0.75",
49
49
  "@zhin.js/plugin-runtime": "1.1.1"
50
50
  },
51
51
  "peerDependencies": {
52
52
  "zod": "^4.0.0",
53
- "@zhin.js/adapter": "1.1.1",
54
- "@zhin.js/agent": "1.0.6",
55
- "@zhin.js/core": "1.4.1",
53
+ "@zhin.js/adapter": "1.1.2",
54
+ "@zhin.js/agent": "1.0.7",
55
+ "@zhin.js/core": "1.4.2",
56
56
  "@zhin.js/host-http": "1.0.3",
57
57
  "@zhin.js/plugin-runtime": "1.1.1",
58
- "zhin.js": "5.0.1"
58
+ "zhin.js": "5.0.2"
59
59
  },
60
60
  "peerDependenciesMeta": {
61
61
  "zhin.js": {
@@ -73,13 +73,13 @@
73
73
  "typescript": "^6.0.3",
74
74
  "vitest": "^4.1.10",
75
75
  "zod": "^4.4.3",
76
- "@zhin.js/agent": "1.0.6",
77
- "zhin.js": "5.0.1"
76
+ "@zhin.js/agent": "1.0.7",
77
+ "zhin.js": "5.0.2"
78
78
  },
79
79
  "files": [
80
80
  "adapters",
81
81
  "commands",
82
- "plugin.ts",
82
+ "plugin.js",
83
83
  "schema.json",
84
84
  "src",
85
85
  "lib",
@@ -97,7 +97,7 @@
97
97
  "zhin": {
98
98
  "protocol": 1,
99
99
  "type": "plugin",
100
- "entry": "./plugin.ts",
100
+ "entry": "./plugin.js",
101
101
  "engine": "^1.0.0",
102
102
  "runtime": "trusted",
103
103
  "features": [
package/plugin.js ADDED
@@ -0,0 +1,55 @@
1
+ // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
+ import { createEndpointRuntimeState } from '@zhin.js/adapter';
3
+ import { definePlugin, databaseHostToken } from '@zhin.js/plugin-runtime';
4
+ import { githubRuntimeStateToken } from "./lib/github-runtime-state.js";
5
+ import { defineGithubOauthUsersTable } from "./lib/oauth-users.js";
6
+ /**
7
+ * github_subscriptions — repo event subscriptions per chat channel
8
+ * (used by github_subscriptions agent tool; schema matches legacy defineModel).
9
+ */
10
+ const GITHUB_SUBSCRIPTIONS_SCHEMA = {
11
+ id: { type: 'integer', primary: true },
12
+ repo: { type: 'text', nullable: false },
13
+ events: { type: 'json', default: [] },
14
+ target_id: { type: 'text', nullable: false },
15
+ target_type: { type: 'text', nullable: false },
16
+ adapter: { type: 'text', nullable: false },
17
+ endpoint: { type: 'text', nullable: false },
18
+ };
19
+ /**
20
+ * Plugin Runtime GitHub adapter.
21
+ * - Endpoint: `adapters/github.ts`
22
+ * - OAuth user tokens: define `github_oauth_users` when DatabaseHost is present
23
+ */
24
+ export default definePlugin({
25
+ name: 'github',
26
+ metadata: {
27
+ displayName: 'GitHub Adapter',
28
+ },
29
+ setup(context) {
30
+ // 运行中 endpoint 注册表(github endpoint list 的"运行中"数据源)
31
+ context.resources.provide(githubRuntimeStateToken, createEndpointRuntimeState());
32
+ if (context.resources.has(databaseHostToken)) {
33
+ const host = context.resources.use(databaseHostToken);
34
+ defineGithubOauthUsersTable(host);
35
+ host.define('github_subscriptions', { ...GITHUB_SUBSCRIPTIONS_SCHEMA });
36
+ }
37
+ // Agent prompt contributor (orchestrator/deferred-worker GitHub guidance).
38
+ // `zhin.js/agent` is an optional peer — skip silently on IM-only installs.
39
+ let cancelled = false;
40
+ let unregister;
41
+ void Promise.all([
42
+ import('zhin.js/agent'),
43
+ import("./lib/agent-prompt.js"),
44
+ ]).then(([agent, prompt]) => {
45
+ if (cancelled)
46
+ return;
47
+ agent.registerAgentPromptContributor(prompt.createGithubAgentPromptContributor());
48
+ unregister = () => agent.unregisterAgentPromptContributor('github');
49
+ }).catch(() => { });
50
+ return () => {
51
+ cancelled = true;
52
+ unregister?.();
53
+ };
54
+ },
55
+ });
package/plugin.ts DELETED
@@ -1,56 +0,0 @@
1
- import { createEndpointRuntimeState } from '@zhin.js/adapter';
2
- import { definePlugin, databaseHostToken } from '@zhin.js/plugin-runtime';
3
- import { githubRuntimeStateToken } from './src/github-runtime-state.js';
4
- import { defineGithubOauthUsersTable } from './src/oauth-users.js';
5
-
6
- /**
7
- * github_subscriptions — repo event subscriptions per chat channel
8
- * (used by github_subscriptions agent tool; schema matches legacy defineModel).
9
- */
10
- const GITHUB_SUBSCRIPTIONS_SCHEMA = {
11
- id: { type: 'integer', primary: true },
12
- repo: { type: 'text', nullable: false },
13
- events: { type: 'json', default: [] },
14
- target_id: { type: 'text', nullable: false },
15
- target_type: { type: 'text', nullable: false },
16
- adapter: { type: 'text', nullable: false },
17
- endpoint: { type: 'text', nullable: false },
18
- } as const;
19
-
20
- /**
21
- * Plugin Runtime GitHub adapter.
22
- * - Endpoint: `adapters/github.ts`
23
- * - OAuth user tokens: define `github_oauth_users` when DatabaseHost is present
24
- */
25
- export default definePlugin({
26
- name: 'github',
27
- metadata: {
28
- displayName: 'GitHub Adapter',
29
- },
30
- setup(context) {
31
- // 运行中 endpoint 注册表(github endpoint list 的"运行中"数据源)
32
- context.resources.provide(githubRuntimeStateToken, createEndpointRuntimeState());
33
- if (context.resources.has(databaseHostToken)) {
34
- const host = context.resources.use(databaseHostToken);
35
- defineGithubOauthUsersTable(host);
36
- host.define('github_subscriptions', { ...GITHUB_SUBSCRIPTIONS_SCHEMA });
37
- }
38
-
39
- // Agent prompt contributor (orchestrator/deferred-worker GitHub guidance).
40
- // `zhin.js/agent` is an optional peer — skip silently on IM-only installs.
41
- let cancelled = false;
42
- let unregister: (() => void) | undefined;
43
- void Promise.all([
44
- import('zhin.js/agent'),
45
- import('./src/agent-prompt.js'),
46
- ]).then(([agent, prompt]) => {
47
- if (cancelled) return;
48
- agent.registerAgentPromptContributor(prompt.createGithubAgentPromptContributor());
49
- unregister = () => agent.unregisterAgentPromptContributor('github');
50
- }).catch(() => { /* optional peer not installed */ });
51
- return () => {
52
- cancelled = true;
53
- unregister?.();
54
- };
55
- },
56
- });