@jigs.design/ai-sdk 0.1.2 → 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/README.md +2 -5
- package/dist/chat.d.ts +2 -2
- package/dist/chat.js +1 -1
- package/dist/model.d.ts +1 -1
- package/dist/model.js +1 -1
- package/dist/schemas.d.ts +6 -3
- package/dist/schemas.js +12 -9
- package/dist/stored.d.ts +2 -2
- package/dist/stored.js +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -2,17 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
Optional. Connects Jigs to the [AI SDK](https://ai-sdk.dev) in two ways:
|
|
4
4
|
|
|
5
|
-
- `aiSdkModel(model, settings?)` is a `model` for `
|
|
5
|
+
- `aiSdkModel(model, settings?)` is a `model` for `withModel`. It passes the host's prompt as `instructions`, streams the text through `streamText`, and reports token usage to `onTurn`. It takes a gateway id such as `"anthropic/claude-sonnet-5.5"` or any provider's `LanguageModel`.
|
|
6
6
|
- `jigsChat(jigs, { request, messages })` runs chat mode on a `useChat` conversation. The assistant answers in Markdown, and each fenced `jigs` block becomes a `data-jigs` part you draw with `JigsView`.
|
|
7
7
|
|
|
8
8
|
```ts
|
|
9
9
|
import { aiSdkModel } from "@jigs.design/ai-sdk";
|
|
10
10
|
import { createJigsServer } from "@jigs.design/server";
|
|
11
11
|
|
|
12
|
-
export const jigs = createJigsServer({
|
|
13
|
-
host,
|
|
14
|
-
context,
|
|
15
|
-
run,
|
|
12
|
+
export const jigs = createJigsServer({ host, context, run }).withModel({
|
|
16
13
|
model: aiSdkModel("anthropic/claude-sonnet-5.5", { temperature: 0.2 }),
|
|
17
14
|
});
|
|
18
15
|
```
|
package/dist/chat.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { JigsBlockData, JigsUIMessage, WithJigsBlocks } from "./stored.js";
|
|
2
|
-
import { ChatTurn, JigsServer } from "@jigs.design/server";
|
|
2
|
+
import { ChatTurn, JigsModelServer, JigsServer } from "@jigs.design/server";
|
|
3
3
|
import { InferUIMessageChunk, UIMessage, UIMessageChunk } from "ai";
|
|
4
4
|
//#region src/chat.d.ts
|
|
5
5
|
export interface JigsChat {
|
|
@@ -41,7 +41,7 @@ export interface JigsChat {
|
|
|
41
41
|
* conversation's earlier jigs from `messages`, so edits and versions
|
|
42
42
|
* continue from them.
|
|
43
43
|
*/
|
|
44
|
-
export declare function jigsChat<TContext,
|
|
44
|
+
export declare function jigsChat<TContext, TPageName extends string>(jigs: JigsModelServer<TContext, TPageName>, input: {
|
|
45
45
|
messages: ReadonlyArray<UIMessage>;
|
|
46
46
|
/** App options for the server's `options` schema, passed to repairs. */
|
|
47
47
|
options?: unknown;
|
package/dist/chat.js
CHANGED
|
@@ -3,7 +3,7 @@ import { chatBlockText } from "@jigs.design/server";
|
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
//#region src/chat.ts
|
|
5
5
|
const blockSource = z.object({
|
|
6
|
-
|
|
6
|
+
name: z.string(),
|
|
7
7
|
source: z.string()
|
|
8
8
|
});
|
|
9
9
|
/** The conversation's blocks, oldest first, read from its `data-jigs` parts. */
|
package/dist/model.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export type ModelSettings = Omit<Parameters<typeof streamText>[0], "abortSignal"
|
|
|
12
12
|
*/
|
|
13
13
|
export declare function cachedInstructions(system: string, prefix: string): Instructions;
|
|
14
14
|
/**
|
|
15
|
-
* A `model` for `
|
|
15
|
+
* A `model` for `withModel` from an AI SDK model: document-mode
|
|
16
16
|
* sessions and chat repairs stream through `streamText`, and token usage
|
|
17
17
|
* reaches `onTurn`. The prompt's stable start is marked for the provider's
|
|
18
18
|
* cache (`cachedInstructions`).
|
package/dist/model.js
CHANGED
|
@@ -19,7 +19,7 @@ function cachedInstructions(system, prefix) {
|
|
|
19
19
|
}];
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
|
-
* A `model` for `
|
|
22
|
+
* A `model` for `withModel` from an AI SDK model: document-mode
|
|
23
23
|
* sessions and chat repairs stream through `streamText`, and token usage
|
|
24
24
|
* reaches `onTurn`. The prompt's stable start is marked for the provider's
|
|
25
25
|
* cache (`cachedInstructions`).
|
package/dist/schemas.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { z } from "zod";
|
|
|
4
4
|
* Schemas for `validateUIMessages<StoredJigsUIMessage>({ messages,
|
|
5
5
|
* dataSchemas })`, to check a conversation the browser sent or one read
|
|
6
6
|
* from storage. A jig's program is dropped, never checked: the server
|
|
7
|
-
* reads only `
|
|
7
|
+
* reads only `name` and `source`, and a source is only ever compiled.
|
|
8
8
|
*/
|
|
9
9
|
export declare const jigsDataSchemas: {
|
|
10
10
|
jigs: z.ZodObject<{
|
|
@@ -25,7 +25,6 @@ export declare const jigsDataSchemas: {
|
|
|
25
25
|
message: z.ZodString;
|
|
26
26
|
severity: z.ZodEnum<{
|
|
27
27
|
error: "error";
|
|
28
|
-
hint: "hint";
|
|
29
28
|
info: "info";
|
|
30
29
|
warning: "warning";
|
|
31
30
|
}>;
|
|
@@ -52,8 +51,12 @@ export declare const jigsDataSchemas: {
|
|
|
52
51
|
}>;
|
|
53
52
|
message: z.ZodString;
|
|
54
53
|
}, z.core.$strip>>;
|
|
55
|
-
id: z.ZodString;
|
|
56
54
|
key: z.ZodString;
|
|
55
|
+
name: z.ZodString;
|
|
56
|
+
ref: z.ZodExactOptional<z.ZodObject<{
|
|
57
|
+
name: z.ZodString;
|
|
58
|
+
props: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodBoolean, z.ZodNumber, z.ZodString]>>;
|
|
59
|
+
}, z.core.$strip>>;
|
|
57
60
|
source: z.ZodString;
|
|
58
61
|
status: z.ZodEnum<{
|
|
59
62
|
done: "done";
|
package/dist/schemas.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { jigsErrorCodes } from "@jigs.design/
|
|
2
|
+
import { jigsErrorCodes, severities } from "@jigs.design/protocol";
|
|
3
3
|
//#region src/schemas.ts
|
|
4
4
|
const span = z.object({
|
|
5
5
|
column: z.number().exactOptional(),
|
|
@@ -18,20 +18,23 @@ const storedBlock = z.object({
|
|
|
18
18
|
title: z.string()
|
|
19
19
|
}).exactOptional(),
|
|
20
20
|
message: z.string(),
|
|
21
|
-
severity: z.enum(
|
|
22
|
-
"error",
|
|
23
|
-
"hint",
|
|
24
|
-
"info",
|
|
25
|
-
"warning"
|
|
26
|
-
]),
|
|
21
|
+
severity: z.enum(severities),
|
|
27
22
|
span
|
|
28
23
|
})),
|
|
29
24
|
error: z.object({
|
|
30
25
|
code: z.enum(jigsErrorCodes),
|
|
31
26
|
message: z.string()
|
|
32
27
|
}).exactOptional(),
|
|
33
|
-
id: z.string(),
|
|
34
28
|
key: z.string(),
|
|
29
|
+
name: z.string(),
|
|
30
|
+
ref: z.object({
|
|
31
|
+
name: z.string(),
|
|
32
|
+
props: z.record(z.string(), z.union([
|
|
33
|
+
z.boolean(),
|
|
34
|
+
z.number(),
|
|
35
|
+
z.string()
|
|
36
|
+
]))
|
|
37
|
+
}).exactOptional(),
|
|
35
38
|
source: z.string(),
|
|
36
39
|
status: z.enum([
|
|
37
40
|
"streaming",
|
|
@@ -44,7 +47,7 @@ const storedBlock = z.object({
|
|
|
44
47
|
* Schemas for `validateUIMessages<StoredJigsUIMessage>({ messages,
|
|
45
48
|
* dataSchemas })`, to check a conversation the browser sent or one read
|
|
46
49
|
* from storage. A jig's program is dropped, never checked: the server
|
|
47
|
-
* reads only `
|
|
50
|
+
* reads only `name` and `source`, and a source is only ever compiled.
|
|
48
51
|
*/
|
|
49
52
|
const jigsDataSchemas = { jigs: storedBlock };
|
|
50
53
|
//#endregion
|
package/dist/stored.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChatBlock } from "@jigs.design/
|
|
1
|
+
import { ChatBlock } from "@jigs.design/protocol";
|
|
2
2
|
import { UIMessage } from "ai";
|
|
3
3
|
//#region src/stored.d.ts
|
|
4
4
|
/** A jig's `data-jigs` part: one fenced block of a reply, compiled. */
|
|
@@ -42,7 +42,7 @@ export type WithJigsBlocks<TMessage extends UIMessage, TBlock> = Omit<TMessage,
|
|
|
42
42
|
/**
|
|
43
43
|
* The messages without their jigs' programs: for the body `useChat`
|
|
44
44
|
* posts (`prepareSendMessagesRequest`), and for storing a conversation. The
|
|
45
|
-
* server reads only each block's `
|
|
45
|
+
* server reads only each block's `name` and `source`. Every other part, and
|
|
46
46
|
* every other field of a block, is kept as it is.
|
|
47
47
|
*/
|
|
48
48
|
export declare function withoutPrograms<TMessage extends UIMessage>(messages: ReadonlyArray<TMessage>): Array<WithJigsBlocks<TMessage, StoredJigsBlock>>;
|
package/dist/stored.js
CHANGED
|
@@ -6,7 +6,7 @@ function hasProgram(part) {
|
|
|
6
6
|
/**
|
|
7
7
|
* The messages without their jigs' programs: for the body `useChat`
|
|
8
8
|
* posts (`prepareSendMessagesRequest`), and for storing a conversation. The
|
|
9
|
-
* server reads only each block's `
|
|
9
|
+
* server reads only each block's `name` and `source`. Every other part, and
|
|
10
10
|
* every other field of a block, is kept as it is.
|
|
11
11
|
*/
|
|
12
12
|
function withoutPrograms(messages) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jigs.design/ai-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Jigs on the AI SDK: a model function for createJigsServer, and chat mode for useChat.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"access": "public"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@jigs.design/
|
|
33
|
-
"@jigs.design/server": "0.
|
|
32
|
+
"@jigs.design/protocol": "0.3.0",
|
|
33
|
+
"@jigs.design/server": "0.3.0"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"ai": "^7.0.0",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@ai-sdk/provider": "4.0.27",
|
|
41
41
|
"ai": "7.0.140",
|
|
42
42
|
"zod": "4.6.7",
|
|
43
|
-
"@jigs.design/catalog": "0.
|
|
44
|
-
"@jigs.design/host": "0.
|
|
43
|
+
"@jigs.design/catalog": "0.3.0",
|
|
44
|
+
"@jigs.design/host": "0.3.0"
|
|
45
45
|
}
|
|
46
46
|
}
|