@matatbread/matbot-triggers 0.2.7 → 0.3.0
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/package.json +3 -3
- package/src/tools.ts +15 -36
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"node",
|
|
5
5
|
"browser"
|
|
6
6
|
],
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.3.0",
|
|
8
8
|
"engines": {
|
|
9
9
|
"node": ">=24.0.0"
|
|
10
10
|
},
|
|
@@ -33,11 +33,11 @@
|
|
|
33
33
|
"access": "public"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"@matatbread/matbot-plugin-api": "^0.
|
|
36
|
+
"@matatbread/matbot-plugin-api": "^0.3.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"typescript": "^6.0.3",
|
|
40
|
-
"@matatbread/matbot-plugin-api": "^0.
|
|
40
|
+
"@matatbread/matbot-plugin-api": "^0.3.0"
|
|
41
41
|
},
|
|
42
42
|
"scripts": {
|
|
43
43
|
"typecheck": "tsc --noEmit"
|
package/src/tools.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import type { Tool, ToolExecutor,
|
|
1
|
+
import type { Tool, ToolExecutor, ToolContract, ToolResultOf, ToolContext, MatbotMachine } from '@matatbread/matbot-plugin-api';
|
|
2
2
|
import type { TriggerManager } from './manager.js';
|
|
3
3
|
import type { TriggerCondition, TriggerKind, Trigger } from './types.js';
|
|
4
4
|
|
|
5
5
|
declare module '@matatbread/matbot-plugin-api' {
|
|
6
|
-
interface
|
|
6
|
+
interface ToolContracts {
|
|
7
7
|
// One arm per action: a caller of `invokeTool(machine, 'trigger_action', { action: '…' })` gets the
|
|
8
|
-
// matching result narrowed by the `action` it passed (see
|
|
8
|
+
// matching result narrowed by the `action` it passed (see ToolContract / the multi-action note on ToolContracts).
|
|
9
9
|
trigger_action:
|
|
10
|
-
|
|
|
11
|
-
|
|
|
12
|
-
|
|
|
13
|
-
|
|
|
14
|
-
|
|
|
15
|
-
|
|
|
16
|
-
|
|
|
17
|
-
|
|
|
10
|
+
| ToolContract<{ triggers: Trigger[] }, { action: 'list' }>
|
|
11
|
+
| ToolContract<{ triggers: Trigger[] }, { action: 'query'; tool?: string; params?: object }>
|
|
12
|
+
| ToolContract<Trigger, { action: 'get'; id: string }>
|
|
13
|
+
| ToolContract<{ id: string }, { action: 'add'; conditions: TriggerCondition[]; tool: string; params?: object; enabled?: boolean }>
|
|
14
|
+
| ToolContract<Trigger, { action: 'update'; id: string; conditions?: TriggerCondition[]; tool?: string; params?: object; enabled?: boolean }>
|
|
15
|
+
| ToolContract<{ id: string }, { action: 'remove'; id: string }>
|
|
16
|
+
| ToolContract<{ triggers: Trigger[] }, { action: 'move'; tool?: string; params?: object; toTool: string; toParams?: object }>
|
|
17
|
+
| ToolContract<{ triggers: Trigger[] }, { action: 'copy'; tool?: string; params?: object; toTool: string; toParams?: object }>;
|
|
18
18
|
triggers_config:
|
|
19
|
-
|
|
|
20
|
-
|
|
|
21
|
-
|
|
|
19
|
+
| ToolContract<{ classifierProvider: string | null; available: string[] }, { action: 'get' }>
|
|
20
|
+
| ToolContract<{ classifierProvider: string }, { action: 'set'; provider: string }>
|
|
21
|
+
| ToolContract<{ classifierProvider: null }, { action: 'clear' }>;
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
|
|
@@ -192,20 +192,6 @@ export function createTriggerActionTool(manager: TriggerManager): Tool<ToolResul
|
|
|
192
192
|
GUIDANCE + '\n\n' +
|
|
193
193
|
'A trigger has a stable `id` — address it by that, never by its conditions. To change one, ' +
|
|
194
194
|
'"get" or "list" first to read the id, then "update" by id.\n\n' +
|
|
195
|
-
'Parameters depend on `action` (TypeScript):\n' +
|
|
196
|
-
'```ts\n' +
|
|
197
|
-
"type TriggerKind = 'ephemeral' | 'contextual' | 'retract' | 'followup'; // ephemeral=judge user msg+inject for this turn; contextual=judge user msg+fold durably onto it; retract=wrong, redo; followup=stands, add steer turn\n" +
|
|
198
|
-
'type TriggerCondition = { kind: TriggerKind; rule: string };\n' +
|
|
199
|
-
'type TriggerAction =\n' +
|
|
200
|
-
" | { action: 'list' } // -> { triggers: [...] }\n" +
|
|
201
|
-
" | { action: 'query'; tool?: string; params?: object } // triggers invoking that tool -> { triggers: [...] }\n" +
|
|
202
|
-
" | { action: 'get'; id: string } // -> the trigger\n" +
|
|
203
|
-
" | { action: 'add'; conditions: TriggerCondition[]; tool: string; params?: object; enabled?: boolean } // -> { id }\n" +
|
|
204
|
-
" | { action: 'update'; id: string; conditions?: TriggerCondition[]; tool?: string; params?: object; enabled?: boolean } // edit by id\n" +
|
|
205
|
-
" | { action: 'remove'; id: string } // -> { id }\n" +
|
|
206
|
-
" | { action: 'move'; tool?: string; params?: object; toTool: string; toParams?: object } // re-target the queried set's invoke to toTool/toParams in place -> { triggers: [...] }\n" +
|
|
207
|
-
" | { action: 'copy'; tool?: string; params?: object; toTool: string; toParams?: object }; // duplicate the queried set, the copies invoking toTool/toParams -> { triggers: [...] }\n" +
|
|
208
|
-
'```\n\n' +
|
|
209
195
|
'For `move`/`copy`, `tool`/`params` are the SAME selector as `query` (they pick which triggers ' +
|
|
210
196
|
'to act on); `toTool`/`toParams` are the new invocation. A filter is required — both refuse to ' +
|
|
211
197
|
'act on the entire trigger set.',
|
|
@@ -275,14 +261,7 @@ export function createTriggersConfigTool(services: MatbotMachine): Tool<ToolResu
|
|
|
275
261
|
'provider judges trigger conditions. It is an alias for an existing provider, not a new one. Unset, ' +
|
|
276
262
|
"the classifier uses the current turn's own provider; set it to pin a small/fast model. `get` " +
|
|
277
263
|
'reports the current pin and the available provider names; `set` pins one (it must already be ' +
|
|
278
|
-
'configured — see the provider tool); `clear` reverts to the turn provider
|
|
279
|
-
'Parameters (TypeScript):\n' +
|
|
280
|
-
'```ts\n' +
|
|
281
|
-
"type TriggersConfig =\n" +
|
|
282
|
-
" | { action: 'get' } // -> { classifierProvider: string | null, available }\n" +
|
|
283
|
-
" | { action: 'set'; provider: string } // pin a provider -> { classifierProvider }\n" +
|
|
284
|
-
" | { action: 'clear' }; // revert to the turn provider -> { classifierProvider: null }\n" +
|
|
285
|
-
'```',
|
|
264
|
+
'configured — see the provider tool); `clear` reverts to the turn provider.',
|
|
286
265
|
inputSchema: {
|
|
287
266
|
type: 'object',
|
|
288
267
|
required: ['action'],
|