@butlerbot/sdk 0.0.22 → 0.0.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/dist/link/protocol.d.ts +1 -0
- package/dist/link/tool.d.ts +13 -0
- package/dist/link/tool.js +1 -0
- package/package.json +1 -1
- package/readme.md +21 -0
package/dist/link/protocol.d.ts
CHANGED
package/dist/link/tool.d.ts
CHANGED
|
@@ -64,6 +64,19 @@ export type ToolConfig<S extends ToolSchema | undefined> = {
|
|
|
64
64
|
};
|
|
65
65
|
/** Whether the tool is on before the user has touched it. */
|
|
66
66
|
defaultEnabled?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Where in Alfred the tool is reachable, as platform ids. Defaults to the user's chat.
|
|
69
|
+
*
|
|
70
|
+
* Say this when your client mirrors a whole platform. A Discord bot offering seventy tools does
|
|
71
|
+
* not want seventy entries in front of somebody having a conversation about their groceries — it
|
|
72
|
+
* wants them behind Alfred's Discord agent, which is one entry and already knows how to decide
|
|
73
|
+
* when Discord is relevant.
|
|
74
|
+
*
|
|
75
|
+
* Known values are Alfred's platform ids, e.g. `"platform.chat.user"` (the default) and
|
|
76
|
+
* `"platform.agent.discord"`. An unknown one is rejected at registration rather than ignored,
|
|
77
|
+
* because a tool reachable from nowhere is indistinguishable from a tool that is broken.
|
|
78
|
+
*/
|
|
79
|
+
platforms?: string[];
|
|
67
80
|
/** How long the server waits for a result before giving up. */
|
|
68
81
|
timeoutMs?: number;
|
|
69
82
|
/** Runs the tool. Return anything JSON-serialisable, or throw to fail the call. */
|
package/dist/link/tool.js
CHANGED
|
@@ -27,6 +27,7 @@ class Tool {
|
|
|
27
27
|
inputSchema,
|
|
28
28
|
...(this.config.display ? { display: this.config.display } : {}),
|
|
29
29
|
...(this.config.defaultEnabled !== undefined ? { defaultEnabled: this.config.defaultEnabled } : {}),
|
|
30
|
+
...(this.config.platforms ? { platforms: this.config.platforms } : {}),
|
|
30
31
|
...(this.config.timeoutMs !== undefined ? { timeoutMs: this.config.timeoutMs } : {}),
|
|
31
32
|
};
|
|
32
33
|
}
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -156,6 +156,27 @@ Subscriptions are never persisted by the SDK. They arrive on connect, follow del
|
|
|
156
156
|
connected, and are dropped on disconnect — so there is nothing to reconcile, and a restart is
|
|
157
157
|
correct by construction.
|
|
158
158
|
|
|
159
|
+
### Tools can belong to an agent instead of a chat
|
|
160
|
+
|
|
161
|
+
By default a tool shows up where a user is talking to Alfred. If your client mirrors a whole
|
|
162
|
+
platform, say so instead:
|
|
163
|
+
|
|
164
|
+
```ts
|
|
165
|
+
new Tool({
|
|
166
|
+
id: "discord_member_kick",
|
|
167
|
+
description: "Kick a member from a server.",
|
|
168
|
+
platforms: ["platform.agent.discord"],
|
|
169
|
+
run: async ({ args, meta }) => kick(meta.identities?.discord, args),
|
|
170
|
+
});
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
Seventy tools in front of somebody asking about their groceries is not a feature. Behind Alfred's
|
|
174
|
+
Discord agent they are one entry that already knows when Discord is relevant — and the agent keeps
|
|
175
|
+
whatever tier and permission gating it carries, which tools bolted onto the chat would quietly skip.
|
|
176
|
+
|
|
177
|
+
An unknown platform is rejected when you register, not ignored: a tool reachable from nowhere looks
|
|
178
|
+
exactly like a tool that is broken.
|
|
179
|
+
|
|
159
180
|
### Tools belong to the user, not to a conversation
|
|
160
181
|
|
|
161
182
|
Once a tool is registered, Alfred can call it anywhere that user talks to it — the web
|