@matatbread/matbot-tool-types 0.3.7 → 0.3.8

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.
Files changed (2) hide show
  1. package/package.json +5 -5
  2. package/src/index.ts +7 -9
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "matbotRuntime": [
4
4
  "node"
5
5
  ],
6
- "version": "0.3.7",
6
+ "version": "0.3.8",
7
7
  "engines": {
8
8
  "node": ">=24.0.0"
9
9
  },
@@ -36,14 +36,14 @@
36
36
  "typescript": "^6.0.3"
37
37
  },
38
38
  "peerDependencies": {
39
- "@matatbread/matbot-plugin-api": "^0.3.7",
40
- "@matatbread/matbot-core": "^0.3.7"
39
+ "@matatbread/matbot-plugin-api": "^0.3.8",
40
+ "@matatbread/matbot-core": "^0.3.8"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@types/node": "^22.0.0",
44
44
  "typescript": "^6.0.3",
45
- "@matatbread/matbot-plugin-api": "^0.3.7",
46
- "@matatbread/matbot-core": "^0.3.7"
45
+ "@matatbread/matbot-plugin-api": "^0.3.8",
46
+ "@matatbread/matbot-core": "^0.3.8"
47
47
  },
48
48
  "scripts": {
49
49
  "typecheck": "tsc --noEmit"
package/src/index.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { dirname, join } from 'node:path';
2
2
  import { existsSync } from 'node:fs';
3
3
  import { createRequire } from 'node:module';
4
- import { PLUGIN_API_VERSION } from '@matatbread/matbot-plugin-api';
4
+ import { PLUGIN_API_VERSION, RegistryChangeKind } from '@matatbread/matbot-plugin-api';
5
5
  import type { MatbotMachine, MatbotPluginSpec, ToolTypeIndex } from '@matatbread/matbot-plugin-api';
6
6
  import { getRegisteredPlugins } from '@matatbread/matbot-core';
7
7
  import { buildMatbotToolsDts } from './build-dts.js';
@@ -114,12 +114,9 @@ class ToolTypeIndexImpl implements ToolTypeIndex {
114
114
 
115
115
  constructor(machine: MatbotMachine) {
116
116
  this.machine = machine;
117
- void this.watchTools();
118
- }
119
-
120
- private async watchTools(): Promise<void> {
121
- try { for await (const _ev of this.machine.tools.watch(this.ac.signal)) this.dirty = true; }
122
- catch { /* signal aborted on teardown */ }
117
+ // Any tool CRUD invalidates the generated dts; the event itself carries nothing we need.
118
+ machine.Notifier.consume(() => { this.dirty = true; }, this.ac.signal,
119
+ n => n.kind === RegistryChangeKind && n.registry === 'tools');
123
120
  }
124
121
 
125
122
  close(): void { this.ac.abort(); }
@@ -148,8 +145,9 @@ class ToolTypeIndexImpl implements ToolTypeIndex {
148
145
  // tool.x(params)` narrows its result by the params, and a non-existent tool name is a compile error.
149
146
  // `toolInContext(override)` is the sibling factory for a context override. Both derived, never
150
147
  // hand-authored; `check()` uses this same string, so what a generator is shown is exactly what it is
151
- // graded against.
152
- return `${this.registryBlock(this.cache!)}\ndeclare const tool: import('@matatbread/matbot-plugin-api').ToolProxy;\ndeclare const toolInContext: import('@matatbread/matbot-plugin-api').ToolBox;\n`;
148
+ // graded against — which is also why `context` is declared here and not merely described in prose:
149
+ // undeclared, every body reading it would fail the very check this string backs.
150
+ return `${this.registryBlock(this.cache!)}\ndeclare const tool: import('@matatbread/matbot-plugin-api').ToolProxy;\ndeclare const toolInContext: import('@matatbread/matbot-plugin-api').ToolBox;\ndeclare const context: import('@matatbread/matbot-plugin-api').ComposedCallContext;\n`;
153
151
  }
154
152
 
155
153
  async wireContracts(): Promise<Record<string, { params: string; result: string }>> {