@zhin.js/plugin-content-moderation 1.1.22 → 1.1.23

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/lib/runtime.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  import type { ModerationEngine } from './engine.js';
2
- export declare const moderationEngineToken: import("zhin.js").Token<ModerationEngine>;
2
+ export declare const moderationEngineStore: import("zhin.js").PluginStore<ModerationEngine, unknown>;
3
+ export declare const moderationEngineToken: import("zhin.js").PluginStore<ModerationEngine, unknown>;
3
4
  //# sourceMappingURL=runtime.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD,eAAO,MAAM,qBAAqB,2CAGjC,CAAC"}
1
+ {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD,eAAO,MAAM,qBAAqB,0DAGjC,CAAC;AACF,eAAO,MAAM,qBAAqB,0DAAwB,CAAC"}
package/lib/runtime.js CHANGED
@@ -1,3 +1,4 @@
1
- import { createToken } from 'zhin.js';
2
- export const moderationEngineToken = createToken('zhin.content-moderation.engine', 'Owner-scoped content moderation engine');
1
+ import { definePluginStore } from 'zhin.js';
2
+ export const moderationEngineStore = definePluginStore('zhin.content-moderation.engine', 'Owner-scoped content moderation engine');
3
+ export const moderationEngineToken = moderationEngineStore;
3
4
  //# sourceMappingURL=runtime.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAGtC,MAAM,CAAC,MAAM,qBAAqB,GAAG,WAAW,CAC9C,gCAAgC,EAChC,wCAAwC,CACzC,CAAC"}
1
+ {"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAG5C,MAAM,CAAC,MAAM,qBAAqB,GAAG,iBAAiB,CACpD,gCAAgC,EAChC,wCAAwC,CACzC,CAAC;AACF,MAAM,CAAC,MAAM,qBAAqB,GAAG,qBAAqB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhin.js/plugin-content-moderation",
3
- "version": "1.1.22",
3
+ "version": "1.1.23",
4
4
  "description": "Content moderation plugin for Zhin.js — inbound/outbound multi-source scanning (Plugin Runtime)",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",
@@ -39,19 +39,18 @@
39
39
  },
40
40
  "license": "MIT",
41
41
  "dependencies": {
42
- "@zhin.js/client": "1.1.25",
43
- "@zhin.js/console-contract": "1.1.3",
44
- "@zhin.js/core": "1.1.57",
42
+ "@zhin.js/console-contract": "1.1.4",
43
+ "@zhin.js/core": "1.1.58",
45
44
  "@zhin.js/logger": "1.1.2",
46
- "@zhin.js/page": "1.1.15",
47
- "@zhin.js/skill": "1.1.14",
48
- "@zhin.js/tool": "1.1.16"
45
+ "@zhin.js/page": "1.1.16",
46
+ "@zhin.js/skill": "1.1.15",
47
+ "@zhin.js/tool": "1.1.17"
49
48
  },
50
49
  "devDependencies": {
51
50
  "typescript": "^6.0.3",
52
51
  "vitest": "^4.1.10",
53
52
  "zod": "^4.4.3",
54
- "zhin.js": "1.1.22"
53
+ "zhin.js": "1.1.23"
55
54
  },
56
55
  "repository": {
57
56
  "type": "git",
@@ -93,11 +92,11 @@
93
92
  },
94
93
  "peerDependencies": {
95
94
  "zod": "^4.0.0",
96
- "@zhin.js/middleware": "^1.1.14",
97
- "@zhin.js/page": "^1.1.15",
98
- "@zhin.js/skill": "^1.1.14",
99
- "@zhin.js/tool": "^1.1.16",
100
- "zhin.js": "^1.1.22"
95
+ "@zhin.js/middleware": "^1.1.15",
96
+ "@zhin.js/page": "^1.1.16",
97
+ "@zhin.js/skill": "^1.1.15",
98
+ "@zhin.js/tool": "^1.1.17",
99
+ "zhin.js": "^1.1.23"
101
100
  },
102
101
  "peerDependenciesMeta": {
103
102
  "@zhin.js/middleware": {
@@ -1,6 +1,5 @@
1
1
  // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
- import { definePage } from '@zhin.js/console-contract';
3
- import { createDeclarativePage } from '@zhin.js/client';
2
+ import { definePage, createDeclarativePage } from '@zhin.js/console-contract';
4
3
  export const meta = definePage({
5
4
  title: '内容审核',
6
5
  titleI18n: { en: 'Content Moderation' },
@@ -1,5 +1,4 @@
1
- import { definePage } from '@zhin.js/console-contract';
2
- import { createDeclarativePage } from '@zhin.js/client';
1
+ import { definePage, createDeclarativePage } from '@zhin.js/console-contract';
3
2
  import type {
4
3
  ModerationConsoleStatus,
5
4
  ModerationProviderStatusRow,
package/plugin.js CHANGED
@@ -1,21 +1,29 @@
1
1
  // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
- import { definePlugin, pluginConsoleRpcToken } from 'zhin.js';
2
+ import { definePlugin, definePluginCapabilityGraph, pluginConsoleRpcToken, } from 'zhin.js';
3
3
  import { createModerationConsoleRpc } from "./lib/console.js";
4
4
  import { ModerationEngine } from "./lib/engine.js";
5
- import { moderationEngineToken } from "./lib/runtime.js";
5
+ import { moderationEngineStore } from "./lib/runtime.js";
6
6
  export default definePlugin({
7
7
  name: 'content-moderation',
8
8
  metadata: {
9
9
  displayName: 'Content Moderation',
10
10
  },
11
+ capabilityGraph: definePluginCapabilityGraph({
12
+ provides: [moderationEngineStore, pluginConsoleRpcToken],
13
+ features: {
14
+ middlewares: ['inbound', 'outbound'],
15
+ skills: ['content-moderation'],
16
+ tools: ['moderation_check', 'moderation_status'],
17
+ pages: ['index'],
18
+ },
19
+ }),
11
20
  setup(context) {
12
21
  // 每个 generation 配置一次:providers 构建与词库 readFileSync 都在
13
22
  // configure 内,绝不能放在每条消息的中间件热路径上。
14
23
  // provide 自动挂 lifecycle 反注册,代际结束即摘除。
15
24
  const engine = new ModerationEngine();
16
25
  engine.configure(context.config.get());
17
- context.resources.provide(moderationEngineToken, engine);
18
- context.resources.provide(pluginConsoleRpcToken, createModerationConsoleRpc(engine));
26
+ moderationEngineStore.provide(context, engine);
19
27
  context.events.on('hmr.resume', ({ details }) => {
20
28
  if (details.outcome !== 'committed')
21
29
  return;
@@ -23,6 +31,9 @@ export default definePlugin({
23
31
  if (details.receiver.state === 'replaced')
24
32
  engine.groupReviewQueue.stop();
25
33
  });
26
- return () => engine.groupReviewQueue.stop();
34
+ return {
35
+ consoleRpc: createModerationConsoleRpc(engine),
36
+ dispose: () => engine.groupReviewQueue.stop(),
37
+ };
27
38
  },
28
39
  });
package/src/runtime.ts CHANGED
@@ -1,7 +1,8 @@
1
- import { createToken } from 'zhin.js';
1
+ import { definePluginStore } from 'zhin.js';
2
2
  import type { ModerationEngine } from './engine.js';
3
3
 
4
- export const moderationEngineToken = createToken<ModerationEngine>(
4
+ export const moderationEngineStore = definePluginStore<ModerationEngine>(
5
5
  'zhin.content-moderation.engine',
6
6
  'Owner-scoped content moderation engine',
7
7
  );
8
+ export const moderationEngineToken = moderationEngineStore;