@jigs.design/server 0.0.0-stage → 0.1.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Tom Bates
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,63 @@
1
- # Temporary Holding Version
1
+ # @jigs.design/server
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ `createPickleServer` turns a host into one fetch handler. That handler streams checked programs, runs queries and mutations, and serves the sandbox frame. You give it a `run` function per procedure, a `context` for each request, and a `model` function that calls your LLM.
4
+
5
+ Import it from server code only.
6
+
7
+ ```ts
8
+ import { createPickleServer, PickleError } from "@jigs.design/server";
9
+ import { aiSdkModel } from "@jigs.design/ai-sdk";
10
+ import { host } from "./host";
11
+
12
+ export const pickle = createPickleServer({
13
+ host,
14
+ context: async (request) => ({ userId: await userIdFrom(request) }),
15
+ run: {
16
+ orders: (input, { ctx, signal }) =>
17
+ db.listOrders(ctx.userId, input.status, { signal }),
18
+ archiveOrder: async (input, { ctx }) => {
19
+ if (!(await db.archiveOrder(ctx.userId, input.id))) {
20
+ throw new PickleError("NOT_FOUND", "That order is gone.");
21
+ }
22
+ },
23
+ },
24
+ model: aiSdkModel("anthropic/claude-sonnet-5.5"),
25
+ instructions: "You are Acme's order assistant. Today is 2026-10-18.",
26
+ });
27
+
28
+ // Mount it as GET, POST and OPTIONS on one route, e.g. /api/pickle.
29
+ export const handler = pickle.handler;
30
+ ```
31
+
32
+ The server renders the prompt from the host, calls the model, checks each streamed prefix and compiles it to a program. `instructions`, such as who the assistant is and today's date, reach every prompt: document-mode sessions, chat and repairs. When the checker finds errors, it runs repair rounds. A call carries its procedure's `kind`, and the server refuses one that does not match the host. A follow-up turn may answer with SEARCH/REPLACE edits instead of a whole document.
33
+
34
+ Specs need not come from the model. `pickle.spec(name)` returns a spec your product ships in `specs`, compiled once at startup. `pickle.compile(source)` checks and compiles one a user saved.
35
+
36
+ ## Exports
37
+
38
+ | Export | What it is |
39
+ | -------------------------- | ----------------------------------------------------------------------------------- |
40
+ | `createPickleServer` | The server: `handler`, `spec`, `compile`, `chat`, and the functions `handler` wraps |
41
+ | `defineRun` | Types `run` functions outside a server, to share them between two servers |
42
+ | `PickleError` | Throw from `context` or `run` with a code the browser can read |
43
+ | `PickleCompileError` | What a strict `pickle.compile` rejects with, carrying the `diagnostics` |
44
+ | `chatBlockText` | Writes a chat block back as a fenced block, for the model's history |
45
+ | `@jigs.design/server/node` | `nodeHandler`, for Node's `http` and Express |
46
+
47
+ It re-exports the shared types from `@jigs.design/runtime`.
48
+
49
+ ## Source
50
+
51
+ - `src/server.ts`: `createPickleServer` and the request routing.
52
+ - `src/session.ts`: one turn: prompt, model, checking, repair and edits.
53
+ - `src/compile.ts`: compiling a document against the host's catalog and recipes.
54
+ - `src/inputs.ts`, `src/literal.ts`: literal procedure inputs checked against their schemas.
55
+ - `src/chat.ts`: chat mode, where a Markdown reply carries fenced `pickle` blocks.
56
+ - `src/invalidation.ts`: which queries a mutation refreshes.
57
+ - `src/pragma.ts`: the `{@pickle 0 catalog=3}` version line.
58
+ - `src/node.ts`: the Node adapter.
59
+ - `src/errors.ts`, `src/types.ts`: errors and the public types.
60
+
61
+ ## Docs
62
+
63
+ [Server](../../apps/docs/docs/running/server.mdx), [Session](../../apps/docs/docs/running/session.mdx), [Chat](../../apps/docs/docs/running/chat.mdx), [Diagnostics](../../apps/docs/docs/running/diagnostics.mdx), [Transport](../../apps/docs/docs/running/transport.mdx).
package/dist/chat.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ import "./design.js";
2
+ import { ChatBlockSource } from "./types.js";
3
+ import "./session.js";
4
+ import "@jigs.design/compiler";
5
+ import { ChatBlock, Diagnostic, Program } from "@jigs.design/runtime";
6
+ //#region src/chat.d.ts
7
+ /**
8
+ * A block as the model wrote it, for the model's history: a fenced `pickle`
9
+ * block with its id, and its source without the pragma line.
10
+ */
11
+ export declare function chatBlockText(block: ChatBlockSource): string;
12
+ //#endregion