@bolt-foundry/gambit 0.7.0 → 0.8.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/CHANGELOG.md CHANGED
@@ -1,8 +1,16 @@
1
1
  +++
2
2
  [release]
3
- since = "225456917f75e92cc095af525201373c4be37944"
3
+ since = "692534996df73790229b8303516d48be66136fce"
4
4
  +++
5
5
 
6
6
  # Changelog
7
7
 
8
+ ## Unreleased (v0.8.1)
9
+
10
+ - TBD
11
+
12
+ ## v0.8.0
13
+
14
+ - chore(gambit): prepare 0.8.0 changelog
15
+
8
16
  ## 0.7.0 — Show HN launch
package/README.md CHANGED
@@ -1,23 +1,35 @@
1
- # Gambit
1
+ # <img src="./gambit_1color_bg.png" alt="Gambit logo" height="50" />
2
2
 
3
3
  Gambit helps you build reliable LLM workflows by composing small, typed “decks”\
4
4
  with clear inputs/outputs and guardrails. Run decks locally, stream traces, and\
5
5
  debug with a built-in UI.
6
6
 
7
+ [Watch the demo video](https://youtu.be/J_hQ2L_yy60).
8
+
7
9
  ## Quickstart
8
10
 
9
- Requirements: Node.js 18+ and `OPENROUTER_API_KEY` (set `OPENROUTER_BASE_URL`
10
- if\
11
+ Requirements: Node.js 18+ and `OPENROUTER_API_KEY` (set `OPENROUTER_BASE_URL` if
11
12
  you proxy OpenRouter-style APIs).
12
13
 
13
14
  Run the CLI directly with npx (no install):
14
15
 
15
16
  ```
16
17
  export OPENROUTER_API_KEY=...
17
- npx @bolt-foundry/gambit init
18
+ npx @bolt-foundry/gambit demo
19
+ ```
20
+
21
+ Downloads example files (hello decks plus the `examples/` gallery) and sets
22
+ environment variables.
23
+
24
+ To scaffold a starter project that you can customize, run:
25
+
26
+ ```
27
+ npx @bolt-foundry/gambit init my-project
18
28
  ```
19
29
 
20
- Downloads example files and sets environment variables.
30
+ This creates a structured skeleton (`decks/`, `actions/`, `graders/`, `tests/`,
31
+ `schemas/`, `.gambit/`) with README guides so you can start authoring your own
32
+ workflows immediately.
21
33
 
22
34
  Run an example in the terminal (`repl`):
23
35
 
@@ -75,9 +87,12 @@ npx @bolt-foundry/gambit <command>
75
87
  Run a deck once:
76
88
 
77
89
  ```
78
- npx @bolt-foundry/gambit run <deck> --init <json|string> --message <json|string>
90
+ npx @bolt-foundry/gambit run <deck> --context <json|string> --message <json|string>
79
91
  ```
80
92
 
93
+ > `--context` replaces the old `--init` flag. The CLI still accepts `--init` as
94
+ > a deprecated alias for now so existing scripts keep working.
95
+
81
96
  Drop into a REPL (streams by default):
82
97
 
83
98
  ```
@@ -177,7 +192,7 @@ You are a concise assistant. Greet the user and echo the input.
177
192
  Run it:
178
193
 
179
194
  ```
180
- npx @bolt-foundry/gambit run ./hello_world.deck.md --init '"Gambit"' --stream
195
+ npx @bolt-foundry/gambit run ./hello_world.deck.md --context '"Gambit"' --stream
181
196
  ```
182
197
 
183
198
  ### Compute deck in TypeScript (no model call): `echo.deck.ts`
@@ -200,7 +215,7 @@ export default defineDeck({
200
215
  Run it:
201
216
 
202
217
  ```
203
- npx @bolt-foundry/gambit run ./echo.deck.ts --init '{"text":"ping"}'
218
+ npx @bolt-foundry/gambit run ./echo.deck.ts --context '{"text":"ping"}'
204
219
  ```
205
220
 
206
221
  ### Deck with a child action (calls a TypeScript tool): `agent_with_time.deck.md`
@@ -238,7 +253,7 @@ export default defineDeck({
238
253
  Run it:
239
254
 
240
255
  ```
241
- npx @bolt-foundry/gambit run ./agent_with_time.deck.md --init '"hello"' --stream
256
+ npx @bolt-foundry/gambit run ./agent_with_time.deck.md --context '"hello"' --stream
242
257
  ```
243
258
 
244
259
  ## Deno
@@ -249,13 +264,19 @@ Quickstart:
249
264
 
250
265
  ```
251
266
  export OPENROUTER_API_KEY=...
252
- deno run -A jsr:@bolt-foundry/gambit/cli init
267
+ deno run -A jsr:@bolt-foundry/gambit/cli demo
268
+ ```
269
+
270
+ Starter project:
271
+
272
+ ```
273
+ deno run -A jsr:@bolt-foundry/gambit/cli init my-project
253
274
  ```
254
275
 
255
276
  Run a deck:
256
277
 
257
278
  ```
258
- deno run -A jsr:@bolt-foundry/gambit/cli run <deck> --init <json|string> --message <json|string>
279
+ deno run -A jsr:@bolt-foundry/gambit/cli run <deck> --context <json|string> --message <json|string>
259
280
  ```
260
281
 
261
282
  Start the Debug UI:
package/esm/mod.d.ts CHANGED
@@ -35,11 +35,11 @@ export { runDeck } from "@bolt-foundry/gambit-core";
35
35
  /** Signal for explicitly ending a Gambit run. */
36
36
  export type { GambitEndSignal } from "@bolt-foundry/gambit-core";
37
37
  /** OpenAI Chat Completions compatibility helper for a deck. */
38
- export { chatCompletionsWithDeck } from "@bolt-foundry/gambit-core";
38
+ export { chatCompletionsWithDeck } from "./src/compat/openai.js";
39
39
  /** OpenAI-compatible request payload. */
40
- export type { ChatCompletionsRequest } from "@bolt-foundry/gambit-core";
40
+ export type { ChatCompletionsRequest } from "./src/compat/openai.js";
41
41
  /** OpenAI-compatible response payload. */
42
- export type { ChatCompletionsResponse } from "@bolt-foundry/gambit-core";
42
+ export type { ChatCompletionsResponse } from "./src/compat/openai.js";
43
43
  /** Render a deck to a human-readable outline or debug view. */
44
44
  export { renderDeck } from "@bolt-foundry/gambit-core";
45
45
  /** Options for deck rendering. */
@@ -47,7 +47,7 @@ export type { RenderDeckOptions } from "@bolt-foundry/gambit-core";
47
47
  /** Result data from rendering a deck. */
48
48
  export type { RenderDeckResult } from "@bolt-foundry/gambit-core";
49
49
  /** Provider factory for OpenRouter-backed model calls. */
50
- export { createOpenRouterProvider } from "@bolt-foundry/gambit-core";
50
+ export { createOpenRouterProvider } from "./src/providers/openrouter.js";
51
51
  /** Start the WebSocket simulator server for the Gambit UI. */
52
52
  export { startWebSocketSimulator } from "./src/server.js";
53
53
  //# sourceMappingURL=mod.d.ts.map
package/esm/mod.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,yEAA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AC;AACpE,yDAAyD;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,kDAAkD;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACpD,iDAAiD;AACjD,YAAY,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACjE,+DAA+D;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,yCAAyC;AACzC,YAAY,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AACrE,0CAA0C;AAC1C,YAAY,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACtE,+DAA+D;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,kCAAkC;AAClC,YAAY,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACnE,yCAAyC;AACzC,YAAY,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,0DAA0D;AAC1D,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,8DAA8D;AAC9D,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC"}
package/esm/mod.js CHANGED
@@ -13,10 +13,10 @@ export { isGambitEndSignal } from "@bolt-foundry/gambit-core";
13
13
  /** Run a deck and return its execution result. */
14
14
  export { runDeck } from "@bolt-foundry/gambit-core";
15
15
  /** OpenAI Chat Completions compatibility helper for a deck. */
16
- export { chatCompletionsWithDeck } from "@bolt-foundry/gambit-core";
16
+ export { chatCompletionsWithDeck } from "./src/compat/openai.js";
17
17
  /** Render a deck to a human-readable outline or debug view. */
18
18
  export { renderDeck } from "@bolt-foundry/gambit-core";
19
19
  /** Provider factory for OpenRouter-backed model calls. */
20
- export { createOpenRouterProvider } from "@bolt-foundry/gambit-core";
20
+ export { createOpenRouterProvider } from "./src/providers/openrouter.js";
21
21
  /** Start the WebSocket simulator server for the Gambit UI. */
22
22
  export { startWebSocketSimulator } from "./src/server.js";
@@ -1,14 +1,13 @@
1
- import type { ModelMessage } from "@bolt-foundry/gambit-core";
2
- import type { SavedState } from "@bolt-foundry/gambit-core";
1
+ import type { OpenResponseItem, SavedState } from "@bolt-foundry/gambit-core";
3
2
  export declare function parsePortValue(value: unknown, label?: string): number | undefined;
4
3
  export declare function normalizeFlagList(value: string | Array<string> | undefined): Array<string>;
5
4
  export declare function slugifyDeckPath(deckPath: string): string;
6
5
  export declare function defaultSessionRoot(deckPath: string): string;
7
6
  export declare function defaultTestBotStatePath(deckPath: string): string;
8
7
  export declare function enrichStateMeta(state: SavedState, deckPath: string): SavedState;
9
- export declare function parseInit(raw?: string): unknown;
8
+ export declare function parseContext(raw?: string): unknown;
10
9
  export declare function parseMessage(raw?: string): unknown;
11
10
  export declare function parseBotInput(raw?: string): unknown;
12
- export declare function findLastAssistantMessage(messages: Array<ModelMessage>): string | undefined;
13
- export declare function extractInitInput(state?: SavedState): unknown;
11
+ export declare function findLastAssistantMessage(messages: Array<OpenResponseItem>): string | undefined;
12
+ export declare function extractContextInput(state?: SavedState): unknown;
14
13
  //# sourceMappingURL=cli_utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cli_utils.d.ts","sourceRoot":"","sources":["../../src/src/cli_utils.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAE5D,wBAAgB,cAAc,CAC5B,KAAK,EAAE,OAAO,EACd,KAAK,SAAS,GACb,MAAM,GAAG,SAAS,CAOpB;AAED,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,SAAS,GACxC,KAAK,CAAC,MAAM,CAAC,CAGf;AAED,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAQxD;AAuBD,wBAAgB,kBAAk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AED,wBAAgB,YAAY,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAOlD;AAED,wBAAgB,YAAY,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAOlD;AAED,wBAAgB,aAAa,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAOnD;AAmBD,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,KAAK,CAAC,gBAAgB,CAAC,GAChC,MAAM,GAAG,SAAS,CAYpB;AAED,wBAAgB,mBAAmB,CAAC,KAAK,CAAC,EAAE,UAAU,GAAG,OAAO,CAkB/D"}
@@ -64,7 +64,7 @@ export function enrichStateMeta(state, deckPath) {
64
64
  }
65
65
  return { ...state, meta };
66
66
  }
67
- export function parseInit(raw) {
67
+ export function parseContext(raw) {
68
68
  if (raw === undefined)
69
69
  return undefined;
70
70
  try {
@@ -94,23 +94,43 @@ export function parseBotInput(raw) {
94
94
  return raw;
95
95
  }
96
96
  }
97
+ function contentText(parts) {
98
+ return parts.map((part) => {
99
+ switch (part.type) {
100
+ case "input_text":
101
+ case "output_text":
102
+ case "text":
103
+ case "summary_text":
104
+ case "reasoning_text":
105
+ return part.text;
106
+ case "refusal":
107
+ return part.refusal;
108
+ default:
109
+ return "";
110
+ }
111
+ }).join("");
112
+ }
97
113
  export function findLastAssistantMessage(messages) {
98
114
  for (let i = messages.length - 1; i >= 0; i--) {
99
115
  const msg = messages[i];
100
- if (msg?.role === "assistant") {
101
- return typeof msg.content === "string"
102
- ? msg.content
103
- : JSON.stringify(msg.content ?? "");
116
+ if (msg?.type === "message" && msg.role === "assistant") {
117
+ if (typeof msg.content === "string")
118
+ return msg.content;
119
+ if (Array.isArray(msg.content)) {
120
+ return contentText(msg.content);
121
+ }
122
+ return JSON.stringify(msg.content ?? "");
104
123
  }
105
124
  }
106
125
  return undefined;
107
126
  }
108
- export function extractInitInput(state) {
127
+ export function extractContextInput(state) {
109
128
  if (!state?.messages)
110
129
  return undefined;
111
130
  for (let i = state.messages.length - 1; i >= 0; i--) {
112
131
  const msg = state.messages[i];
113
- if (msg.role === "tool" && msg.name === GAMBIT_TOOL_INIT) {
132
+ if (msg.type === "message" && msg.role === "tool" &&
133
+ msg.name === GAMBIT_TOOL_INIT) {
114
134
  const content = msg.content;
115
135
  if (typeof content !== "string")
116
136
  return undefined;
@@ -0,0 +1,2 @@
1
+ export { type ChatCompletionsRequest, type ChatCompletionsResponse, chatCompletionsWithDeck, } from "@bolt-foundry/gambit-core";
2
+ //# sourceMappingURL=openai.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../../src/src/compat/openai.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,uBAAuB,GACxB,MAAM,2BAA2B,CAAC"}
@@ -0,0 +1 @@
1
+ export { chatCompletionsWithDeck, } from "@bolt-foundry/gambit-core";
@@ -0,0 +1,9 @@
1
+ import type { ModelProvider } from "@bolt-foundry/gambit-core";
2
+ export declare function createOpenRouterProvider(opts: {
3
+ apiKey: string;
4
+ baseURL?: string;
5
+ referer?: string;
6
+ title?: string;
7
+ useResponses?: boolean;
8
+ }): ModelProvider;
9
+ //# sourceMappingURL=openrouter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openrouter.d.ts","sourceRoot":"","sources":["../../../src/src/providers/openrouter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAEV,aAAa,EAOd,MAAM,2BAA2B,CAAC;AAmNnC,wBAAgB,wBAAwB,CAAC,IAAI,EAAE;IAC7C,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,GAAG,aAAa,CAsdhB"}