@zhin.js/plugin-calendar 0.1.13 → 0.1.15

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,49 @@
1
1
  # @zhin.js/plugin-calendar
2
2
 
3
+ ## 0.1.15
4
+
5
+ ### Patch Changes
6
+
7
+ - 8adce16: fix: post-refactor audit fixes across runtime, console blueprints, AI setup, and plugin stores
8
+
9
+ - **Agent & Runtime**: adapt `DatabaseHost` models for `DatabaseEngagementJournal` after `DatabaseHost.start()` (`this[#db].select is not a function`), suppress deferred database warning in `seedInitialAiPlanIfEmpty`, lazy-load `@zhin.js/agent/runtime` in `agent-console.ts`, wrap `#receiveSideEvent` with `withEndpointEventPayload` and `captureInteraction`, select only `('id', 'timestamp')` in `SystemLogDatabaseTransport.prune()`, and surface clear install errors when optional AI/protocol packages are absent.
10
+ - **Console Blueprints & RPC**: bundle `.ts` blueprint page entries via `esbuild` in `TypeScriptClientBuilder` so `spec`, `fields`, `dictionary`, `pollMs`, and `reviewSpec` are preserved in browser bundles; wire `CommentReviewSession` in `DeclarativePageView`; authorize `zhin.game` / `zhin.feature.game` in `plugin-console-rpc.ts`; forward `locale` in `entry-routes.ts`; pass `pluginId: entry.owner ?? entry.id` in `loadConsoleEntries.ts`.
11
+ - **Plugin Store & Capabilities**: make `deriveStoreDisposer` idempotent in `@zhin.js/plugin-runtime`, guard nullish `carrier.resources`, handle `{ dispose }` return shapes in isolate `bootstrap.ts`, remove duplicate manual disposals in `answers`/`earthquake`, guard optional `projectLocaleToken` in `calendar`/`reminder`/`rss`/`lottery`, migrate `process-monitor` to `definePluginStore`, and align `capabilityGraph` declarations across plugins.
12
+ - **Architectural Enhancements**:
13
+ 1. **Model Capability Baseline Catalog + Override Layer** (`@zhin.js/ai`, `@zhin.js/scaffold-wizard`, `@zhin.js/cli`): add `MODEL_CAPABILITY_CATALOG`, `inferModelCapabilities`, and `applyModelCapabilityDefaults` so built-in models carry accurate `input`/`streaming`/`toolCalling`/`thinking` baselines while preserving explicit `provider.capabilities` overrides.
14
+ 2. **Zero-Bundler Declarative Blueprint Protocol** (`@zhin.js/console-contract`, `@zhin.js/client`, `@zhin.js/pagemanager`): add JSON-serializable `DeclarativeValueExpr` operators (`$path`, `$count`, `$sum`, `$format`, `$map`, `$join`, `$coalesce`) evaluated identically across Web, IM Card, and CLI Panel projections, plus in-process `ts.transpileModule` synthesis (`synthesizePureBlueprintModule`) in `TypeScriptClientBuilder`.
15
+ 3. **Auto CapabilityGraph Convention Merge & Codegen** (`@zhin.js/plugin-runtime`, `@zhin.js/runtime`, `@zhin.js/cli`): add `mergePluginCapabilityGraph`, `scanConventionCapabilityFeatures` (auto-merged during `PluginScopeAssembler.setupTree`), and `zhin runtime codegen [dir] --write --json`.
16
+ 4. **Durable Turn Step Checkpointing** (`@zhin.js/agent`): add `TurnCheckpointStore` and `DatabaseTurnCheckpointStorage` (`agent_turn_checkpoints`) so multi-step tool turns interrupted mid-flight record completed `(assistant[toolCall] -> toolResult[])` rounds and resume from the last committed `toolResult` boundary on retry or `"继续"`/`"continue"`.
17
+ - **UI Component System & Developer Preview Workbench** (`@zhin.js/client`, `@zhin.js/components`, `@zhin.js/cli`, `create-zhin-app`):
18
+ - Expand `@zhin.js/client/ui` and `@zhin.js/components` with unified design tokens (`UI_DESIGN_TOKENS`), option icons (`RadioGroup`/`CheckboxGroup`), custom chart images/logos (`BarChart`/`Sparkline`/`DonutChart`/`GaugeBar`), batch table selection & sticky columns (`DataTable`), responsive viewport presets (`CardCanvas`), and shared layout/display primitives.
19
+ - Add `zhin preview [dir]` command in `@zhin.js/cli` (and `"preview": "zhin preview"` in `create-zhin-app`) for zero-build live SSE component & page blueprint previewing, interactive `previewProps` JSON editing, canvas width/background presets, and box-model outline debugging.
20
+ - **IM Chat Controlled Restart & Post-Restart Channel Receipt** (`@zhin.js/cli`):
21
+ - Add `installRestartHost` (`restart` / `重启` / `reboot` command for Bot owners) and `deliverPendingRestartReceipt` so owners can trigger a supervised process restart from any IM conversation and automatically receive the restart completion summary in the originating channel once the endpoint reconnects.
22
+ - Ignore `SIGHUP` in `NativeTypeScriptSupervisor` when running in `--daemon` mode.
23
+
24
+ - Updated dependencies [8adce16]
25
+ - @zhin.js/console-contract@1.1.5
26
+ - @zhin.js/host-http@1.1.17
27
+ - @zhin.js/page@1.1.17
28
+ - @zhin.js/skill@1.1.16
29
+ - @zhin.js/tool@1.1.18
30
+
31
+ ## 0.1.14
32
+
33
+ ### Patch Changes
34
+
35
+ - cbf1fb1: Unify Console page blueprints (`definePageBlueprint`, `defineAdapterPage`, `defineCommentReviewPage`, `projectBlueprintToImCard`, `projectBlueprintToCliPanel`) into `@zhin.js/console-contract` and `@zhin.js/page`, add zero-esbuild pure Blueprint synthesis + static client bundle mounting to `@zhin.js/pagemanager`, remove `@zhin.js/client` (React 19) and `.tsx` from all 30 server-side plugins and adapters (including `bilibili` and `juejin`), and remove legacy Era-1 Koa `PageManager` code.
36
+ - 5419b88: Add generation-scoped `definePluginStore` (`PluginStore`), `Scope.get()`, declarative `PluginSetupCapabilities` return in `definePlugin()`, and `JsonSerializable<T>` typing on `PluginStateStore` to eliminate `as never` casts on TypeScript interfaces.
37
+ - Updated dependencies [cbf1fb1]
38
+ - Updated dependencies [008ccad]
39
+ - Updated dependencies [a1f1028]
40
+ - @zhin.js/console-contract@1.1.4
41
+ - @zhin.js/page@1.1.16
42
+ - @zhin.js/im-contract@1.1.13
43
+ - @zhin.js/host-http@1.1.16
44
+ - @zhin.js/tool@1.1.17
45
+ - @zhin.js/skill@1.1.15
46
+
3
47
  ## 0.1.13
4
48
 
5
49
  ### Patch Changes
@@ -1,4 +1,5 @@
1
1
  import type { Locale } from 'zhin.js/i18n';
2
+ import type { JsonSerializable, JsonValue } from 'zhin.js';
2
3
  /**
3
4
  * Persists OAuth refresh tokens in the plugin's database state (never in .env).
4
5
  */
@@ -6,17 +7,17 @@ import type { OAuthProviderKind, RefreshTokenStore } from "./token-manager.js";
6
7
  /** The subset of zhin's PluginStateStore used by the calendar plugin. */
7
8
  export interface CalendarStateStore {
8
9
  get<T>(key: string): Promise<T | undefined>;
9
- set(key: string, value: never): Promise<void>;
10
+ set<T>(key: string, value: T & JsonSerializable<T>): Promise<void>;
10
11
  delete(key: string): Promise<void>;
11
12
  }
12
13
  /** Who completed the chat authorization and where to notify them later. */
13
- export interface CredentialOwner<Target = unknown> {
14
+ export interface CredentialOwner<Target = JsonValue> {
14
15
  readonly sender_id: string;
15
16
  /** Fixed when authorization starts; token rotation preserves it. */
16
17
  readonly locale?: Locale;
17
18
  readonly target: Target;
18
19
  }
19
- export interface StoredCredential<Target = unknown> {
20
+ export interface StoredCredential<Target = JsonValue> {
20
21
  readonly refresh_token: string;
21
22
  readonly authorized_at: string;
22
23
  readonly authorized_by: CredentialOwner<Target> | null;
@@ -1 +1 @@
1
- {"version":3,"file":"credential-store.d.ts","sourceRoot":"","sources":["../src/credential-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C;;GAEG;AACH,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE/E,yEAAyE;AACzE,MAAM,WAAW,kBAAkB;IACjC,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;IAC5C,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9C,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACpC;AAED,2EAA2E;AAC3E,MAAM,WAAW,eAAe,CAAC,MAAM,GAAG,OAAO;IAC/C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,oEAAoE;IACpE,QAAQ,CAAC,MAAM,C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C5C,OAAO,UAAU,EAAE,aAAa,CAAC;YACnC,CAAC;YACD,IAAI,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE;gBAC3B,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;gBAC1C,MAAM,YAAY,GAAG,QAAQ,EAAE,aAAa,IAAI,IAAI,CAAC;gBACrD,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC;YACxD,CAAC;SACF,CAAC;IACJ,CAAC;CACF"}
package/lib/runtime.d.ts CHANGED
@@ -7,5 +7,6 @@ export interface CalendarRuntime {
7
7
  /** Chat authorization flow used by the `calendar` commands. */
8
8
  readonly auth: CalendarAuthService<unknown>;
9
9
  }
10
- export declare const calendarRuntimeToken: import("zhin.js").Token<CalendarRuntime>;
10
+ export declare const calendarRuntimeStore: import("zhin.js").PluginStore<CalendarRuntime, unknown>;
11
+ export declare const calendarRuntimeToken: import("zhin.js").PluginStore<CalendarRuntime, unknown>;
11
12
  //# 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,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAE1D,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,GAAG,SAAS,CAAC;IAChD,+DAA+D;IAC/D,QAAQ,CAAC,IAAI,EAAE,mBAAmB,CAAC,OAAO,CAAC,CAAC;CAC7C;AAED,eAAO,MAAM,oBAAoB,0CAGhC,CAAC"}
1
+ {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAE1D,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,GAAG,SAAS,CAAC;IAChD,+DAA+D;IAC/D,QAAQ,CAAC,IAAI,EAAE,mBAAmB,CAAC,OAAO,CAAC,CAAC;CAC7C;AAED,eAAO,MAAM,oBAAoB,yDAGhC,CAAC;AACF,eAAO,MAAM,oBAAoB,yDAAuB,CAAC"}
package/lib/runtime.js CHANGED
@@ -1,3 +1,4 @@
1
- import { createToken } from "zhin.js";
2
- export const calendarRuntimeToken = createToken("zhin.calendar.runtime", "Owner-scoped calendar provider and config");
1
+ import { definePluginStore } from "zhin.js";
2
+ export const calendarRuntimeStore = definePluginStore("zhin.calendar.runtime", "Owner-scoped calendar provider and config");
3
+ export const calendarRuntimeToken = calendarRuntimeStore;
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;AAYtC,MAAM,CAAC,MAAM,oBAAoB,GAAG,WAAW,CAC7C,uBAAuB,EACvB,2CAA2C,CAC5C,CAAC"}
1
+ {"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAY5C,MAAM,CAAC,MAAM,oBAAoB,GAAG,iBAAiB,CACnD,uBAAuB,EACvB,2CAA2C,CAC5C,CAAC;AACF,MAAM,CAAC,MAAM,oBAAoB,GAAG,oBAAoB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhin.js/plugin-calendar",
3
- "version": "0.1.13",
3
+ "version": "0.1.15",
4
4
  "description": "CalDAV / Google / Microsoft calendar tools for Zhin Agent",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",
@@ -40,28 +40,27 @@
40
40
  "url": "https://github.com/lc-cn"
41
41
  },
42
42
  "dependencies": {
43
- "@zhin.js/client": "1.1.25",
44
- "@zhin.js/console-contract": "1.1.3",
45
- "@zhin.js/host-http": "1.1.15",
46
- "@zhin.js/im-contract": "1.1.12",
47
- "@zhin.js/page": "1.1.15",
48
- "@zhin.js/skill": "1.1.14",
49
- "@zhin.js/tool": "1.1.16"
43
+ "@zhin.js/console-contract": "1.1.5",
44
+ "@zhin.js/host-http": "1.1.17",
45
+ "@zhin.js/im-contract": "1.1.13",
46
+ "@zhin.js/page": "1.1.17",
47
+ "@zhin.js/skill": "1.1.16",
48
+ "@zhin.js/tool": "1.1.18"
50
49
  },
51
50
  "devDependencies": {
52
51
  "typescript": "^6.0.3",
53
52
  "vitest": "^4.1.10",
54
53
  "zod": "^4.4.3",
55
- "@zhin.js/command": "1.1.15",
56
- "zhin.js": "1.1.22"
54
+ "@zhin.js/command": "1.1.17",
55
+ "zhin.js": "1.1.24"
57
56
  },
58
57
  "peerDependencies": {
59
58
  "zod": "^4.0.0",
60
- "@zhin.js/command": "^1.1.15",
61
- "@zhin.js/page": "^1.1.15",
62
- "@zhin.js/skill": "^1.1.14",
63
- "@zhin.js/tool": "^1.1.16",
64
- "zhin.js": "^1.1.22"
59
+ "@zhin.js/command": "^1.1.17",
60
+ "@zhin.js/page": "^1.1.17",
61
+ "@zhin.js/skill": "^1.1.16",
62
+ "@zhin.js/tool": "^1.1.18",
63
+ "zhin.js": "^1.1.24"
65
64
  },
66
65
  "peerDependenciesMeta": {
67
66
  "@zhin.js/command": {
@@ -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: 'Calendar' },
@@ -21,8 +20,26 @@ export default createDeclarativePage({
21
20
  badges: [
22
21
  {
23
22
  key: 'ready',
24
- label: (data, ctx) => (data.ready ? ctx.t('已就绪') : ctx.t('未就绪')),
25
- tone: (data) => (data.ready ? 'success' : 'warning'),
23
+ label: {
24
+ $map: {
25
+ path: 'ready',
26
+ cases: {
27
+ true: { zh: '已就绪', en: 'Ready' },
28
+ false: { zh: '未就绪', en: 'Not ready' },
29
+ },
30
+ default: { zh: '未就绪', en: 'Not ready' },
31
+ },
32
+ },
33
+ tone: {
34
+ $map: {
35
+ path: 'ready',
36
+ cases: {
37
+ true: 'success',
38
+ false: 'warning',
39
+ },
40
+ default: 'warning',
41
+ },
42
+ },
26
43
  },
27
44
  ],
28
45
  stats: [
@@ -46,13 +63,13 @@ export default createDeclarativePage({
46
63
  {
47
64
  id: 'overview',
48
65
  title: { zh: '配置概览', en: 'Configuration Overview' },
49
- entries: (data) => ({
50
- provider: data.provider,
51
- timezone: data.timezone,
52
- ready: data.ready ? 'true' : 'false',
53
- oauthCallbackPath: data.oauthCallbackPath,
54
- workingHours: data.workingHours,
55
- }),
66
+ entries: [
67
+ { label: 'provider', dataKey: 'provider' },
68
+ { label: 'timezone', dataKey: 'timezone' },
69
+ { label: 'ready', dataKey: 'ready' },
70
+ { label: 'oauthCallbackPath', dataKey: 'oauthCallbackPath' },
71
+ { label: 'workingHours', dataKey: 'workingHours' },
72
+ ],
56
73
  },
57
74
  ],
58
75
  });
@@ -1,8 +1,7 @@
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
 
4
3
  export interface CalendarConsoleStatus {
5
- readonly provider: 'none' | 'google' | 'microsoft' | 'caldav' | 'ics';
4
+ readonly provider: 'none' | 'google' | 'microsoft' | 'caldav';
6
5
  readonly timezone: string;
7
6
  readonly ready: boolean;
8
7
  readonly oauthCallbackPath: string;
@@ -30,8 +29,26 @@ export default createDeclarativePage<CalendarConsoleStatus>({
30
29
  badges: [
31
30
  {
32
31
  key: 'ready',
33
- label: (data, ctx) => (data.ready ? ctx.t('已就绪') : ctx.t('未就绪')),
34
- tone: (data) => (data.ready ? 'success' : 'warning'),
32
+ label: {
33
+ $map: {
34
+ path: 'ready',
35
+ cases: {
36
+ true: { zh: '已就绪', en: 'Ready' },
37
+ false: { zh: '未就绪', en: 'Not ready' },
38
+ },
39
+ default: { zh: '未就绪', en: 'Not ready' },
40
+ },
41
+ },
42
+ tone: {
43
+ $map: {
44
+ path: 'ready',
45
+ cases: {
46
+ true: 'success',
47
+ false: 'warning',
48
+ },
49
+ default: 'warning',
50
+ },
51
+ },
35
52
  },
36
53
  ],
37
54
  stats: [
@@ -55,13 +72,13 @@ export default createDeclarativePage<CalendarConsoleStatus>({
55
72
  {
56
73
  id: 'overview',
57
74
  title: { zh: '配置概览', en: 'Configuration Overview' },
58
- entries: (data) => ({
59
- provider: data.provider,
60
- timezone: data.timezone,
61
- ready: data.ready ? 'true' : 'false',
62
- oauthCallbackPath: data.oauthCallbackPath,
63
- workingHours: data.workingHours,
64
- }),
75
+ entries: [
76
+ { label: 'provider', dataKey: 'provider' },
77
+ { label: 'timezone', dataKey: 'timezone' },
78
+ { label: 'ready', dataKey: 'ready' },
79
+ { label: 'oauthCallbackPath', dataKey: 'oauthCallbackPath' },
80
+ { label: 'workingHours', dataKey: 'workingHours' },
81
+ ],
65
82
  },
66
83
  ],
67
84
  });
package/plugin.js CHANGED
@@ -1,15 +1,29 @@
1
1
  // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
2
  import { projectLocaleToken } from 'zhin.js/i18n';
3
- import { databaseHostToken, definePlugin, outboundHostToken, pluginConsoleRpcToken, } from "zhin.js";
3
+ import { databaseHostToken, definePlugin, definePluginCapabilityGraph, outboundHostToken, pluginConsoleRpcToken, } from "zhin.js";
4
4
  import { httpHostToken } from "@zhin.js/host-http";
5
5
  import { assertCalendarTimezone, createCalendarConsoleRpc, createCalendarProvider, createOAuthTokenManagers, } from "./lib/index.js";
6
6
  import { buildRedirectUri, CalendarAuthService, DEFAULT_OAUTH_CALLBACK_PATH, localOriginFromAddress, } from "./lib/chat-auth.js";
7
7
  import { CalendarCredentialStore, } from "./lib/credential-store.js";
8
8
  import { registerOAuthCallbackRoute } from "./lib/http-callback.js";
9
- import { calendarRuntimeToken } from "./lib/runtime.js";
9
+ import { calendarRuntimeStore } from "./lib/runtime.js";
10
10
  export default definePlugin({
11
11
  name: "calendar",
12
12
  metadata: { displayName: "日历" },
13
+ capabilityGraph: definePluginCapabilityGraph({
14
+ provides: [calendarRuntimeStore, pluginConsoleRpcToken],
15
+ injects: [databaseHostToken, outboundHostToken, httpHostToken, projectLocaleToken],
16
+ features: {
17
+ commands: ["calendar/auth", "calendar/logout", "calendar/status"],
18
+ skills: ["calendar-scheduling"],
19
+ tools: [
20
+ "skill/calendar-scheduling/create_event",
21
+ "skill/calendar-scheduling/find_free_time",
22
+ "skill/calendar-scheduling/list_events",
23
+ ],
24
+ pages: ["index"],
25
+ },
26
+ }),
13
27
  setup(context) {
14
28
  const config = context.config.get();
15
29
  assertCalendarTimezone(config.timezone);
@@ -45,9 +59,16 @@ export default definePlugin({
45
59
  credentials,
46
60
  onAuthorizationLost: (provider, message) => auth.notifyAuthorizationLost(provider, message),
47
61
  });
62
+ let projectLocale;
63
+ try {
64
+ projectLocale = context.resources.use(projectLocaleToken);
65
+ }
66
+ catch {
67
+ projectLocale = undefined;
68
+ }
48
69
  const auth = new CalendarAuthService({
49
70
  config,
50
- locale: resources.use(projectLocaleToken),
71
+ locale: projectLocale,
51
72
  managers,
52
73
  credentials,
53
74
  notify,
@@ -59,16 +80,18 @@ export default definePlugin({
59
80
  provider,
60
81
  auth: auth,
61
82
  };
62
- context.resources.provide(calendarRuntimeToken, runtime);
63
- context.resources.provide(pluginConsoleRpcToken, createCalendarConsoleRpc(runtime));
83
+ calendarRuntimeStore.provide(context, runtime);
64
84
  if (config.provider !== "none" && !provider) {
65
85
  console.warn("[calendar] provider 已配置但凭据为空,日历工具将不可用;Google/Microsoft 请先配置 client_id,再在聊天中发送 calendar auth <provider>");
66
86
  }
67
87
  const releaseRoute = http
68
88
  ? registerOAuthCallbackRoute(http, callbackPath, (searchParams) => auth.handleCallback(searchParams))
69
89
  : undefined;
70
- return () => {
71
- releaseRoute?.();
90
+ return {
91
+ consoleRpc: createCalendarConsoleRpc(runtime),
92
+ dispose: () => {
93
+ releaseRoute?.();
94
+ },
72
95
  };
73
96
  },
74
97
  });
@@ -1,4 +1,5 @@
1
1
  import type { Locale } from 'zhin.js/i18n';
2
+ import type { JsonSerializable, JsonValue } from 'zhin.js';
2
3
  /**
3
4
  * Persists OAuth refresh tokens in the plugin's database state (never in .env).
4
5
  */
@@ -7,19 +8,19 @@ import type { OAuthProviderKind, RefreshTokenStore } from "./token-manager.js";
7
8
  /** The subset of zhin's PluginStateStore used by the calendar plugin. */
8
9
  export interface CalendarStateStore {
9
10
  get<T>(key: string): Promise<T | undefined>;
10
- set(key: string, value: never): Promise<void>;
11
+ set<T>(key: string, value: T & JsonSerializable<T>): Promise<void>;
11
12
  delete(key: string): Promise<void>;
12
13
  }
13
14
 
14
15
  /** Who completed the chat authorization and where to notify them later. */
15
- export interface CredentialOwner<Target = unknown> {
16
+ export interface CredentialOwner<Target = JsonValue> {
16
17
  readonly sender_id: string;
17
18
  /** Fixed when authorization starts; token rotation preserves it. */
18
19
  readonly locale?: Locale;
19
20
  readonly target: Target;
20
21
  }
21
22
 
22
- export interface StoredCredential<Target = unknown> {
23
+ export interface StoredCredential<Target = JsonValue> {
23
24
  readonly refresh_token: string;
24
25
  readonly authorized_at: string;
25
26
  readonly authorized_by: CredentialOwner<Target> | null;
@@ -58,7 +59,7 @@ export class CalendarCredentialStore {
58
59
  authorized_at: new Date().toISOString(),
59
60
  authorized_by: authorizedBy,
60
61
  };
61
- await this.#state.set(credentialKey(provider), credential as never);
62
+ await this.#state.set(credentialKey(provider), credential);
62
63
  }
63
64
 
64
65
  async delete(provider: OAuthProviderKind): Promise<void> {
package/src/runtime.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { createToken } from "zhin.js";
1
+ import { definePluginStore } from "zhin.js";
2
2
  import type { CalendarConfig } from "./config.js";
3
3
  import type { CalendarProvider } from "./types.js";
4
4
  import type { CalendarAuthService } from "./chat-auth.js";
@@ -10,7 +10,8 @@ export interface CalendarRuntime {
10
10
  readonly auth: CalendarAuthService<unknown>;
11
11
  }
12
12
 
13
- export const calendarRuntimeToken = createToken<CalendarRuntime>(
13
+ export const calendarRuntimeStore = definePluginStore<CalendarRuntime>(
14
14
  "zhin.calendar.runtime",
15
15
  "Owner-scoped calendar provider and config"
16
16
  );
17
+ export const calendarRuntimeToken = calendarRuntimeStore;