@zhin.js/plugin-lottery 1.0.3 → 1.0.4

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.
@@ -19,6 +19,8 @@ interface AuthoringToolLike {
19
19
  readonly inputSchema?: unknown;
20
20
  readonly keywords?: readonly string[];
21
21
  readonly tags?: readonly string[];
22
+ readonly platforms?: readonly string[];
23
+ readonly scopes?: readonly ('private' | 'group' | 'channel')[];
22
24
  readonly permissions?: readonly string[];
23
25
  readonly hidden?: boolean;
24
26
  execute(input: never, ctx?: unknown): unknown | Promise<unknown>;
@@ -43,6 +45,8 @@ export function registerLotteryAgentTools(host: AgentToolsHost): () => void {
43
45
  source: 'lottery',
44
46
  ...(tool.keywords ? { keywords: tool.keywords } : {}),
45
47
  ...(tool.tags ? { tags: tool.tags } : {}),
48
+ ...(tool.platforms ? { platforms: tool.platforms } : {}),
49
+ ...(tool.scopes ? { scopes: tool.scopes } : {}),
46
50
  ...(tool.permissions ? { permissions: tool.permissions } : {}),
47
51
  ...(tool.hidden !== undefined ? { hidden: tool.hidden } : {}),
48
52
  execute: (input) => tool.execute(input as never, { pluginName: 'lottery', runtimeName: name }),
@@ -2,6 +2,7 @@
2
2
  * Shared runtime deps for lottery agent/ authoring tools.
3
3
  * Set once from plugin index during init — never call getPlugin() from tool execute.
4
4
  */
5
+ import { type Dispose } from '@zhin.js/plugin-runtime';
5
6
  import type { GameId } from './types.js';
6
7
  import type { LotteryDb } from './db.js';
7
8
  import type { Kl8Config } from './games/kl8-groups.js';
@@ -18,7 +19,11 @@ export interface LotteryAgentDeps {
18
19
  pipelinePush: boolean;
19
20
  }
20
21
  export declare function setLotteryAgentDeps(deps: LotteryAgentDeps): void;
21
- /** Generation-owned Agent dependency binding used by Plugin Runtime setup(). */
22
- export declare function registerLotteryAgentDeps(deps: LotteryAgentDeps): () => void;
22
+ /**
23
+ * Generation-owned Agent dependency binding used by Plugin Runtime setup().
24
+ * The fresh lifecycle is detached: callers own the returned dispose (setup()
25
+ * hooks it into context.lifecycle); provide() does not retain the context.
26
+ */
27
+ export declare function registerLotteryAgentDeps(deps: LotteryAgentDeps): Dispose;
23
28
  export declare function getLotteryAgentDeps(): LotteryAgentDeps;
24
29
  //# sourceMappingURL=lottery-agent-deps.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"lottery-agent-deps.d.ts","sourceRoot":"","sources":["../src/lottery-agent-deps.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAEvD,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,SAAS,GAAG,IAAI,CAAC;IAC9B,SAAS,EAAE,MAAM;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,SAAS,CAAA;KAAE,CAAC;IAC7E,YAAY,EAAE,MAAM,MAAM,EAAE,CAAC;IAC7B,YAAY,EAAE,MAAM,MAAM,CAAC;IAC3B,eAAe,EAAE,MAAM,OAAO,CAAC;IAC/B,YAAY,EAAE,OAAO,CAAC;CACvB;AAKD,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,gBAAgB,GAAG,IAAI,CAEhE;AAED,gFAAgF;AAChF,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,gBAAgB,GAAG,MAAM,IAAI,CAO3E;AAED,wBAAgB,mBAAmB,IAAI,gBAAgB,CAItD"}
1
+ {"version":3,"file":"lottery-agent-deps.d.ts","sourceRoot":"","sources":["../src/lottery-agent-deps.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAuC,KAAK,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAC5F,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAEvD,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,SAAS,GAAG,IAAI,CAAC;IAC9B,SAAS,EAAE,MAAM;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,SAAS,CAAA;KAAE,CAAC;IAC7E,YAAY,EAAE,MAAM,MAAM,EAAE,CAAC;IAC7B,YAAY,EAAE,MAAM,MAAM,CAAC;IAC3B,eAAe,EAAE,MAAM,OAAO,CAAC;IAC/B,YAAY,EAAE,OAAO,CAAC;CACvB;AAMD,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,gBAAgB,GAAG,IAAI,CAEhE;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAExE;AAED,wBAAgB,mBAAmB,IAAI,gBAAgB,CAItD"}
@@ -1,20 +1,23 @@
1
+ /**
2
+ * Shared runtime deps for lottery agent/ authoring tools.
3
+ * Set once from plugin index during init — never call getPlugin() from tool execute.
4
+ */
5
+ import { createGenerationStore, DisposeStack } from '@zhin.js/plugin-runtime';
6
+ const agentDepsStore = createGenerationStore('lottery/agent-deps');
1
7
  let _deps = null;
2
- const registrations = [];
3
8
  export function setLotteryAgentDeps(deps) {
4
9
  _deps = deps;
5
10
  }
6
- /** Generation-owned Agent dependency binding used by Plugin Runtime setup(). */
11
+ /**
12
+ * Generation-owned Agent dependency binding used by Plugin Runtime setup().
13
+ * The fresh lifecycle is detached: callers own the returned dispose (setup()
14
+ * hooks it into context.lifecycle); provide() does not retain the context.
15
+ */
7
16
  export function registerLotteryAgentDeps(deps) {
8
- const registration = Object.freeze({ value: deps });
9
- registrations.push(registration);
10
- return () => {
11
- const index = registrations.lastIndexOf(registration);
12
- if (index >= 0)
13
- registrations.splice(index, 1);
14
- };
17
+ return agentDepsStore.provide({ lifecycle: new DisposeStack() }, deps);
15
18
  }
16
19
  export function getLotteryAgentDeps() {
17
- const deps = registrations[registrations.length - 1]?.value ?? _deps;
20
+ const deps = agentDepsStore.tryUse() ?? _deps;
18
21
  if (!deps)
19
22
  throw new Error('lottery agent deps not initialized');
20
23
  return deps;
@@ -1 +1 @@
1
- {"version":3,"file":"lottery-agent-deps.js","sourceRoot":"","sources":["../src/lottery-agent-deps.ts"],"names":[],"mappings":"AAiBA,IAAI,KAAK,GAA4B,IAAI,CAAC;AAC1C,MAAM,aAAa,GAAgD,EAAE,CAAC;AAEtE,MAAM,UAAU,mBAAmB,CAAC,IAAsB;IACxD,KAAK,GAAG,IAAI,CAAC;AACf,CAAC;AAED,gFAAgF;AAChF,MAAM,UAAU,wBAAwB,CAAC,IAAsB;IAC7D,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACpD,aAAa,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACjC,OAAO,GAAG,EAAE;QACV,MAAM,KAAK,GAAG,aAAa,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;QACtD,IAAI,KAAK,IAAI,CAAC;YAAE,aAAa,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IACjD,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,mBAAmB;IACjC,MAAM,IAAI,GAAG,aAAa,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,KAAK,IAAI,KAAK,CAAC;IACrE,IAAI,CAAC,IAAI;QAAE,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;IACjE,OAAO,IAAI,CAAC;AACd,CAAC"}
1
+ {"version":3,"file":"lottery-agent-deps.js","sourceRoot":"","sources":["../src/lottery-agent-deps.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAgB,MAAM,yBAAyB,CAAC;AAc5F,MAAM,cAAc,GAAG,qBAAqB,CAAmB,oBAAoB,CAAC,CAAC;AAErF,IAAI,KAAK,GAA4B,IAAI,CAAC;AAE1C,MAAM,UAAU,mBAAmB,CAAC,IAAsB;IACxD,KAAK,GAAG,IAAI,CAAC;AACf,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,wBAAwB,CAAC,IAAsB;IAC7D,OAAO,cAAc,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE,IAAI,YAAY,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC;AACzE,CAAC;AAED,MAAM,UAAU,mBAAmB;IACjC,MAAM,IAAI,GAAG,cAAc,CAAC,MAAM,EAAE,IAAI,KAAK,CAAC;IAC9C,IAAI,CAAC,IAAI;QAAE,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;IACjE,OAAO,IAAI,CAAC;AACd,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhin.js/plugin-lottery",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "Multi-game lottery analysis for Zhin.js (Plugin Runtime)",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",
@@ -41,18 +41,18 @@
41
41
  },
42
42
  "license": "MIT",
43
43
  "dependencies": {
44
- "@zhin.js/command": "1.0.2",
45
- "@zhin.js/plugin-runtime": "1.1.0"
44
+ "@zhin.js/command": "1.0.3",
45
+ "@zhin.js/plugin-runtime": "1.1.1"
46
46
  },
47
47
  "devDependencies": {
48
48
  "typescript": "^6.0.3",
49
49
  "vitest": "^4.1.10",
50
50
  "zod": "^4.4.3",
51
- "@zhin.js/agent": "1.0.5"
51
+ "@zhin.js/agent": "1.0.6"
52
52
  },
53
53
  "peerDependencies": {
54
54
  "zod": "^4.0.0",
55
- "@zhin.js/agent": "1.0.5"
55
+ "@zhin.js/agent": "1.0.6"
56
56
  },
57
57
  "peerDependenciesMeta": {
58
58
  "@zhin.js/agent": {
@@ -2,6 +2,7 @@
2
2
  * Shared runtime deps for lottery agent/ authoring tools.
3
3
  * Set once from plugin index during init — never call getPlugin() from tool execute.
4
4
  */
5
+ import { createGenerationStore, DisposeStack, type Dispose } from '@zhin.js/plugin-runtime';
5
6
  import type { GameId } from './types.js';
6
7
  import type { LotteryDb } from './db.js';
7
8
  import type { Kl8Config } from './games/kl8-groups.js';
@@ -15,25 +16,25 @@ export interface LotteryAgentDeps {
15
16
  pipelinePush: boolean;
16
17
  }
17
18
 
19
+ const agentDepsStore = createGenerationStore<LotteryAgentDeps>('lottery/agent-deps');
20
+
18
21
  let _deps: LotteryAgentDeps | null = null;
19
- const registrations: Array<{ readonly value: LotteryAgentDeps }> = [];
20
22
 
21
23
  export function setLotteryAgentDeps(deps: LotteryAgentDeps): void {
22
24
  _deps = deps;
23
25
  }
24
26
 
25
- /** Generation-owned Agent dependency binding used by Plugin Runtime setup(). */
26
- export function registerLotteryAgentDeps(deps: LotteryAgentDeps): () => void {
27
- const registration = Object.freeze({ value: deps });
28
- registrations.push(registration);
29
- return () => {
30
- const index = registrations.lastIndexOf(registration);
31
- if (index >= 0) registrations.splice(index, 1);
32
- };
27
+ /**
28
+ * Generation-owned Agent dependency binding used by Plugin Runtime setup().
29
+ * The fresh lifecycle is detached: callers own the returned dispose (setup()
30
+ * hooks it into context.lifecycle); provide() does not retain the context.
31
+ */
32
+ export function registerLotteryAgentDeps(deps: LotteryAgentDeps): Dispose {
33
+ return agentDepsStore.provide({ lifecycle: new DisposeStack() }, deps);
33
34
  }
34
35
 
35
36
  export function getLotteryAgentDeps(): LotteryAgentDeps {
36
- const deps = registrations[registrations.length - 1]?.value ?? _deps;
37
+ const deps = agentDepsStore.tryUse() ?? _deps;
37
38
  if (!deps) throw new Error('lottery agent deps not initialized');
38
39
  return deps;
39
40
  }