@godwit/sdk 1.5.0 → 1.7.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.
Files changed (2) hide show
  1. package/godwit.d.ts +49 -0
  2. package/package.json +4 -2
package/godwit.d.ts CHANGED
@@ -218,6 +218,53 @@ export interface Translator {
218
218
  translate(req: TranslateRequest): MaybePromise<TranslateResult>
219
219
  }
220
220
 
221
+ /**
222
+ * A model the plugin offers. An "http" model is run by Godwit with the SDK of
223
+ * its protocol (the first three generate, the last two judge), at baseURL; a
224
+ * "plugin" model is a judge the plugin answers itself.
225
+ */
226
+ /** description: one line about the model on this computer, shown in settings. */
227
+ export type Model = { description?: Text } & (
228
+ | {
229
+ id: string
230
+ name: string
231
+ transport: "http"
232
+ protocol: "openai-completions" | "openai-responses" | "anthropic-message" | "typesafe-systemone" | "openai-decisions"
233
+ baseURL: string
234
+ }
235
+ | { id: string; name: string; transport: "plugin"; operation: "judge" }
236
+ )
237
+
238
+ /** A request Godwit's SDK encoded for one of the plugin's http models; body is its JSON text. */
239
+ export interface ModelRequest {
240
+ modelId: string
241
+ method: string
242
+ url: string
243
+ headers: Record<string, string>
244
+ body: string
245
+ }
246
+
247
+ /** A plugin judge call: questions about input, which is untrusted data. */
248
+ export interface JudgeRequest {
249
+ modelId: string
250
+ input: string
251
+ questions: Question[]
252
+ }
253
+
254
+ /**
255
+ * Models the user can pick as their default, small or judge model. The plugin
256
+ * must declare "capabilities": ["models"] in plugin.json and register in its
257
+ * default function. prepareRequest, if given, adjusts each request to an http
258
+ * model (credentials, headers, body) and returns it; Godwit sends it to a host
259
+ * in permissions.net and hands the response back to the SDK. judge answers the
260
+ * plugin's own "plugin" models.
261
+ */
262
+ export interface ModelProvider {
263
+ listModels(): MaybePromise<{ models: Model[] }>
264
+ prepareRequest?(req: ModelRequest): MaybePromise<{ url: string; headers: Record<string, string>; body: string }>
265
+ judge?(req: JudgeRequest): MaybePromise<{ answers: Answer[] }>
266
+ }
267
+
221
268
  export interface Ctx {
222
269
  on(event: "message.received", handler: (message: ReceivedMessage, info: DeliveryInfo) => MaybePromise<void>): void
223
270
  on(event: "message.beforeSend", handler: (draft: OutgoingDraft) => MaybePromise<SendCheck | void>): void
@@ -227,6 +274,8 @@ export interface Ctx {
227
274
  tools: { register(tool: Tool): void }
228
275
  /** needs "capabilities": ["translate"]; at most one */
229
276
  translators: { register(translator: Translator): void }
277
+ /** needs "capabilities": ["models"]; at most one */
278
+ models: { register(provider: ModelProvider): void }
230
279
 
231
280
  /** the user's configuration, secrets included; read-only */
232
281
  readonly config: Readonly<Record<string, string | number | boolean | undefined>>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@godwit/sdk",
3
- "version": "1.5.0",
3
+ "version": "1.7.0",
4
4
  "description": "Types for Godwit plugins",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -10,7 +10,9 @@
10
10
  },
11
11
  "homepage": "https://github.com/godwit-email/godwit/tree/main/sdk",
12
12
  "types": "godwit.d.ts",
13
- "files": ["godwit.d.ts"],
13
+ "files": [
14
+ "godwit.d.ts"
15
+ ],
14
16
  "publishConfig": {
15
17
  "access": "public"
16
18
  }