@bolt-foundry/gambit-core 0.6.8 → 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/README.md +228 -0
- package/cards/context.card.md +9 -0
- package/cards/end.card.md +10 -0
- package/cards/respond.card.md +10 -0
- package/esm/_dnt.polyfills.d.ts +99 -0
- package/esm/_dnt.polyfills.d.ts.map +1 -1
- package/esm/_dnt.polyfills.js +127 -1
- package/esm/deps/jsr.io/@std/path/1.1.4/constants.d.ts +1 -1
- package/esm/mod.d.ts +26 -2
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +0 -2
- package/esm/src/builtins.d.ts +3 -0
- package/esm/src/builtins.d.ts.map +1 -0
- package/esm/src/builtins.js +26 -0
- package/esm/src/loader.d.ts.map +1 -1
- package/esm/src/loader.js +6 -3
- package/esm/src/markdown.d.ts.map +1 -1
- package/esm/src/markdown.js +25 -4
- package/esm/src/openai_compat.d.ts.map +1 -1
- package/esm/src/openai_compat.js +92 -25
- package/esm/src/openresponses.d.ts +6 -0
- package/esm/src/openresponses.d.ts.map +1 -0
- package/esm/src/openresponses.js +75 -0
- package/esm/src/runtime.d.ts.map +1 -1
- package/esm/src/runtime.js +139 -35
- package/esm/src/state.d.ts +4 -3
- package/esm/src/state.d.ts.map +1 -1
- package/esm/src/types.d.ts +306 -33
- package/esm/src/types.d.ts.map +1 -1
- package/package.json +1 -2
- package/schemas/graders/contexts/conversation.ts +17 -0
- package/schemas/graders/contexts/turn.ts +10 -0
- package/schemas/graders/respond.ts +9 -0
- package/script/_dnt.polyfills.d.ts +99 -0
- package/script/_dnt.polyfills.d.ts.map +1 -1
- package/script/_dnt.polyfills.js +128 -0
- package/script/deps/jsr.io/@std/path/1.1.4/constants.d.ts +1 -1
- package/script/mod.d.ts +26 -2
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +1 -4
- package/script/src/builtins.d.ts +3 -0
- package/script/src/builtins.d.ts.map +1 -0
- package/script/src/builtins.js +63 -0
- package/script/src/loader.d.ts.map +1 -1
- package/script/src/loader.js +6 -3
- package/script/src/markdown.d.ts.map +1 -1
- package/script/src/markdown.js +25 -4
- package/script/src/openai_compat.d.ts.map +1 -1
- package/script/src/openai_compat.js +92 -25
- package/script/src/openresponses.d.ts +6 -0
- package/script/src/openresponses.d.ts.map +1 -0
- package/script/src/openresponses.js +81 -0
- package/script/src/runtime.d.ts.map +1 -1
- package/script/src/runtime.js +139 -35
- package/script/src/state.d.ts +4 -3
- package/script/src/state.d.ts.map +1 -1
- package/script/src/types.d.ts +306 -33
- package/script/src/types.d.ts.map +1 -1
- package/esm/src/providers/openrouter.d.ts +0 -8
- package/esm/src/providers/openrouter.d.ts.map +0 -1
- package/esm/src/providers/openrouter.js +0 -168
- package/script/src/providers/openrouter.d.ts +0 -8
- package/script/src/providers/openrouter.d.ts.map +0 -1
- package/script/src/providers/openrouter.js +0 -207
package/README.md
ADDED
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
# @bolt-foundry/gambit-core
|
|
2
|
+
|
|
3
|
+
Core runtime, definitions, and utilities for building Gambit decks outside of
|
|
4
|
+
the CLI. It includes the loader for Markdown/TypeScript decks, guardrail-aware
|
|
5
|
+
execution, OpenAI-compatible adapters, and helpers for persisting local run
|
|
6
|
+
state. The [`@bolt-foundry/gambit`](../gambit/README.md) package re-exports
|
|
7
|
+
these APIs plus the CLI, but `gambit-core` stays focused on the
|
|
8
|
+
authoring/runtime pieces that can live in any host.
|
|
9
|
+
|
|
10
|
+
> **Gambit vs. Gambit Core**
|
|
11
|
+
>
|
|
12
|
+
> `@bolt-foundry/gambit-core` is the lightweight runtime + authoring toolkit
|
|
13
|
+
> (deck definitions, loaders, runtime, provider helpers).
|
|
14
|
+
> [`@bolt-foundry/gambit`](../gambit/README.md) bundles those same exports
|
|
15
|
+
> **plus** the CLI, simulator server, and higher-level developer experience. If
|
|
16
|
+
> you need just the runtime inside another application or service, depend on
|
|
17
|
+
> `gambit-core`. If you also want the CLI commands (`run`, `serve`, `repl`,
|
|
18
|
+
> etc.) stick with [`@bolt-foundry/gambit`](../gambit/README.md), which already
|
|
19
|
+
> depends on this package.
|
|
20
|
+
|
|
21
|
+
## Highlights
|
|
22
|
+
|
|
23
|
+
- Typed deck/card definitions with [`defineDeck`](src/definitions.ts) and
|
|
24
|
+
[`defineCard`](src/definitions.ts) that enforce Zod
|
|
25
|
+
`inputSchema`/`outputSchema`.
|
|
26
|
+
- Loader that understands Markdown decks/cards, inline embeds, and companion
|
|
27
|
+
decks (`actionDecks`, `testDecks`, `graderDecks`).
|
|
28
|
+
- Guardrail-aware runtime (`runDeck`) that can mix LLM actions and pure compute
|
|
29
|
+
decks with structured tracing and execution context helpers.
|
|
30
|
+
- Compatibility helpers for OpenAI Chat Completions plus a ready-to-use
|
|
31
|
+
OpenRouter provider factory.
|
|
32
|
+
- State utilities (`loadState`/`saveState`) used by the Gambit simulator for
|
|
33
|
+
local-first transcripts, feedback, and notes.
|
|
34
|
+
|
|
35
|
+
## Installation
|
|
36
|
+
|
|
37
|
+
### Deno
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
deno add jsr:@bolt-foundry/gambit-core
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Import directly from JSR:
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
import { defineDeck, runDeck } from "jsr:@bolt-foundry/gambit-core";
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Node.js / bundlers
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
npm install @bolt-foundry/gambit-core
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
All exports are ESM and align with what the CLI package (`@bolt-foundry/gambit`)
|
|
56
|
+
surfaces. Use any runtime that supports modern ES modules (Node 18+, Bun, Deno,
|
|
57
|
+
etc.).
|
|
58
|
+
|
|
59
|
+
## Core concepts
|
|
60
|
+
|
|
61
|
+
- **Decks**: The primary executable unit. Decks declare a label, `inputSchema`,
|
|
62
|
+
`outputSchema`, optional `body`/`prompt`, handler hooks, and companion decks
|
|
63
|
+
(actions/tests/graders). Decks with `modelParams` render prompts, while decks
|
|
64
|
+
with `run`/`execute` are compute-only.
|
|
65
|
+
- **Cards**: Reusable prompt fragments or schema fragments that can be embedded
|
|
66
|
+
within decks or other cards. Cards can contribute
|
|
67
|
+
`inputFragment`/`outputFragment` that merge into a parent deck’s schema.
|
|
68
|
+
- **Guardrails**: Limit recursion with `maxDepth`, `maxPasses`, and `timeoutMs`.
|
|
69
|
+
Decks can override guardrails per definition; `runDeck` enforces them while
|
|
70
|
+
spawning child decks.
|
|
71
|
+
- **Handlers**: Background decks triggered on busy/idle/error intervals. Paths
|
|
72
|
+
are resolved relative to the parent deck file.
|
|
73
|
+
- **Companion decks**: `actionDecks` expose tools (function calls) to the model,
|
|
74
|
+
`testDecks` house personas or scripted tests, and `graderDecks` evaluate saved
|
|
75
|
+
transcripts.
|
|
76
|
+
|
|
77
|
+
All actual type definitions live under [`src/types.ts`](src/types.ts). Use them
|
|
78
|
+
when scripting tooling or writing custom providers.
|
|
79
|
+
|
|
80
|
+
## Define a deck in TypeScript
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
// hello.deck.ts
|
|
84
|
+
import { defineDeck } from "jsr:@bolt-foundry/gambit-core";
|
|
85
|
+
import { z } from "zod";
|
|
86
|
+
|
|
87
|
+
export default defineDeck({
|
|
88
|
+
label: "Hello World",
|
|
89
|
+
inputSchema: z.object({ user: z.string() }),
|
|
90
|
+
outputSchema: z.object({ reply: z.string() }),
|
|
91
|
+
body: `
|
|
92
|
+
You are a helpful assistant that greets the user by name.
|
|
93
|
+
`,
|
|
94
|
+
respond: true,
|
|
95
|
+
modelParams: {
|
|
96
|
+
model: "openrouter/anthropic/claude-3.5-sonnet",
|
|
97
|
+
temperature: 0.2,
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Cards look similar:
|
|
103
|
+
|
|
104
|
+
```
|
|
105
|
+
import { defineCard } from "jsr:@bolt-foundry/gambit-core";
|
|
106
|
+
import { z } from "zod";
|
|
107
|
+
|
|
108
|
+
export default defineCard({
|
|
109
|
+
label: "Shared context",
|
|
110
|
+
inputFragment: z.object({ customerId: z.string().uuid() }),
|
|
111
|
+
body: "Always double check the account number before responding.",
|
|
112
|
+
});
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Running decks programmatically
|
|
116
|
+
|
|
117
|
+
The runtime loads the deck (Markdown or TS) and steps through each pass. Provide
|
|
118
|
+
any `ModelProvider` implementation; the OpenRouter adapter lives in
|
|
119
|
+
`@bolt-foundry/gambit`.
|
|
120
|
+
|
|
121
|
+
```
|
|
122
|
+
import { runDeck } from "jsr:@bolt-foundry/gambit-core";
|
|
123
|
+
import { createOpenRouterProvider } from "jsr:@bolt-foundry/gambit";
|
|
124
|
+
|
|
125
|
+
const provider = createOpenRouterProvider({
|
|
126
|
+
apiKey: Deno.env.get("OPENROUTER_API_KEY")!,
|
|
127
|
+
referer: "https://example.com",
|
|
128
|
+
title: "My Gambit Runner",
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
const result = await runDeck({
|
|
132
|
+
path: "./hello.deck.ts",
|
|
133
|
+
input: { user: "Casey" },
|
|
134
|
+
modelProvider: provider,
|
|
135
|
+
isRoot: true,
|
|
136
|
+
trace: (event) => console.log(event),
|
|
137
|
+
stream: true,
|
|
138
|
+
onStreamText: (chunk) => Deno.stdout.write(new TextEncoder().encode(chunk)),
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
console.log(result);
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
When the deck defines `run`/`execute`, the runtime hands you an
|
|
145
|
+
[`ExecutionContext`](src/types.ts) with:
|
|
146
|
+
|
|
147
|
+
- `ctx.input`: validated input (narrowable when you type the schema).
|
|
148
|
+
- `ctx.spawnAndWait({ path, input })`: call another deck and await the result.
|
|
149
|
+
- `ctx.return(payload)`: respond early without running guards again.
|
|
150
|
+
- `ctx.fail({ message, code?, details? })`: aborts the run (throws).
|
|
151
|
+
- `ctx.log(...)`: emit structured trace entries for observability.
|
|
152
|
+
|
|
153
|
+
Pass `guardrails`, `initialUserMessage`, `modelOverride`, and
|
|
154
|
+
`allowRootStringInput` to `runDeck` when scripting custom runtimes.
|
|
155
|
+
|
|
156
|
+
## Loading Markdown decks and cards
|
|
157
|
+
|
|
158
|
+
Markdown files use front matter for metadata, with the body becoming the prompt.
|
|
159
|
+
Embedded cards or system hints can be referenced with markdown image syntax.
|
|
160
|
+
|
|
161
|
+
```
|
|
162
|
+
---
|
|
163
|
+
label: Support Triage
|
|
164
|
+
inputSchema: ./schemas/triage_input.ts
|
|
165
|
+
outputSchema: ./schemas/triage_output.ts
|
|
166
|
+
actionDecks:
|
|
167
|
+
- name: escalate
|
|
168
|
+
description: Escalate to a manager
|
|
169
|
+
path: ./actions/escalate.deck.md
|
|
170
|
+
testDecks:
|
|
171
|
+
- path: ./personas/test_bot.deck.md
|
|
172
|
+
---
|
|
173
|
+

|
|
174
|
+
|
|
175
|
+
You are the front door for support tickets. Summarize the ticket and ask
|
|
176
|
+
clarifying questions before choosing an action.
|
|
177
|
+
|
|
178
|
+

|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
`loadDeck` normalizes relative paths, merges card fragments, enforces unique
|
|
182
|
+
action names, and warns about deprecated fields (`actions`,
|
|
183
|
+
`handlers.onInterval`, `intervalMs`). The Markdown loader also injects helper
|
|
184
|
+
text for built-in tools like `gambit_init`, `gambit_respond`, and `gambit_end`
|
|
185
|
+
when you add `gambit://` markers.
|
|
186
|
+
|
|
187
|
+
## Compatibility and utilities
|
|
188
|
+
|
|
189
|
+
- **Chat Completions bridge**: [`chatCompletionsWithDeck`](src/openai_compat.ts)
|
|
190
|
+
lets you present a single deck as an OpenAI-compatible endpoint. It normalizes
|
|
191
|
+
tool calls, enforces deck schemas, and returns Chat Completions–shaped
|
|
192
|
+
responses with a `gambit` metadata extension.
|
|
193
|
+
- **Request rendering**: [`renderDeck`](src/render.ts) merges an existing Chat
|
|
194
|
+
Completions request with the deck’s system prompt and tool schema, so you can
|
|
195
|
+
debug what will actually reach the model or feed it into another orchestrator.
|
|
196
|
+
- **Model providers**: the OpenRouter adapter lives in `@bolt-foundry/gambit`
|
|
197
|
+
(see `packages/gambit/src/providers/openrouter.ts`). Implement your own
|
|
198
|
+
provider by conforming to the `responses()` signature in `ModelProvider`.
|
|
199
|
+
- **Constants**:
|
|
200
|
+
[`GAMBIT_TOOL_INIT`, `GAMBIT_TOOL_RESPOND`, `GAMBIT_TOOL_END`](src/constants.ts)
|
|
201
|
+
define the reserved tool names the runtime expects when the assistant starts,
|
|
202
|
+
responds, and explicitly ends runs.
|
|
203
|
+
|
|
204
|
+
## Persisted state and traces
|
|
205
|
+
|
|
206
|
+
[`loadState`](src/state.ts) and [`saveState`](src/state.ts) read/write JSON
|
|
207
|
+
session files that include transcript messages, message references, feedback,
|
|
208
|
+
trace events, notes, and optional conversation scores. The CLI stores them under
|
|
209
|
+
`.gambit/`, but the API works anywhere.
|
|
210
|
+
|
|
211
|
+
Use the `trace` callback offered by `runDeck` to collect
|
|
212
|
+
[`TraceEvent`](src/types.ts) entries, then persist them via `saveState` or
|
|
213
|
+
stream them to your own observability stack.
|
|
214
|
+
|
|
215
|
+
## Local development
|
|
216
|
+
|
|
217
|
+
From `packages/gambit-core/`:
|
|
218
|
+
|
|
219
|
+
```
|
|
220
|
+
deno task fmt # format sources
|
|
221
|
+
deno task lint # lint with the repo-standard rules
|
|
222
|
+
deno task test # run unit tests (allowing net/fs as required)
|
|
223
|
+
deno task build_npm # emit the npm bundle via dnt
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
Tests exercise the Markdown loader, renderer, OpenAI compatibility layer, and
|
|
227
|
+
runtime guardrails. Update snapshots/fixtures via `deno test -- --update` when
|
|
228
|
+
necessary.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
+++
|
|
2
|
+
label = "Gambit context primer"
|
|
3
|
+
+++
|
|
4
|
+
|
|
5
|
+
You will automatically receive a `gambit_init` tool result at the start of the
|
|
6
|
+
run whenever the caller supplies `--context` (formerly `--init`). This payload
|
|
7
|
+
contains run metadata or seeded inputs. Read it before you respond, treat it as
|
|
8
|
+
trusted context, and keep it on hand throughout the workflow so downstream
|
|
9
|
+
actions have the right data.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
+++
|
|
2
|
+
label = "Explicitly end the run"
|
|
3
|
+
allowEnd = true
|
|
4
|
+
+++
|
|
5
|
+
|
|
6
|
+
If the entire conversation/workflow is complete and you must stop all further
|
|
7
|
+
turns, call the `gambit_end` tool with an optional `message`, `payload`,
|
|
8
|
+
`status`, `code`, or `meta`. Only use this when you want Gambit to halt entirely
|
|
9
|
+
(no more user messages). Otherwise continue with normal responses or
|
|
10
|
+
`gambit_respond`.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
+++
|
|
2
|
+
label = "Call gambit_respond"
|
|
3
|
+
respond = true
|
|
4
|
+
+++
|
|
5
|
+
|
|
6
|
+
When you finish this workflow, do **not** emit a normal assistant reply.
|
|
7
|
+
Instead, call the `gambit_respond` tool exactly once with a JSON envelope that
|
|
8
|
+
includes your validated `payload` plus optional `status`, `message`, `code`, or
|
|
9
|
+
`meta` fields. This keeps outputs structured and lets Gambit capture the result
|
|
10
|
+
even when guardrails stop the run early.
|
package/esm/_dnt.polyfills.d.ts
CHANGED
|
@@ -1,3 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Based on [import-meta-ponyfill](https://github.com/gaubee/import-meta-ponyfill),
|
|
3
|
+
* but instead of using npm to install additional dependencies,
|
|
4
|
+
* this approach manually consolidates cjs/mjs/d.ts into a single file.
|
|
5
|
+
*
|
|
6
|
+
* Note that this code might be imported multiple times
|
|
7
|
+
* (for example, both dnt.test.polyfills.ts and dnt.polyfills.ts contain this code;
|
|
8
|
+
* or Node.js might dynamically clear the cache and then force a require).
|
|
9
|
+
* Therefore, it's important to avoid redundant writes to global objects.
|
|
10
|
+
* Additionally, consider that commonjs is used alongside esm,
|
|
11
|
+
* so the two ponyfill functions are stored independently in two separate global objects.
|
|
12
|
+
*/
|
|
13
|
+
import { createRequire } from "node:module";
|
|
14
|
+
import { type URL } from "node:url";
|
|
15
|
+
declare global {
|
|
16
|
+
interface ImportMeta {
|
|
17
|
+
/** A string representation of the fully qualified module URL. When the
|
|
18
|
+
* module is loaded locally, the value will be a file URL (e.g.
|
|
19
|
+
* `file:///path/module.ts`).
|
|
20
|
+
*
|
|
21
|
+
* You can also parse the string as a URL to determine more information about
|
|
22
|
+
* how the current module was loaded. For example to determine if a module was
|
|
23
|
+
* local or not:
|
|
24
|
+
*
|
|
25
|
+
* ```ts
|
|
26
|
+
* const url = new URL(import.meta.url);
|
|
27
|
+
* if (url.protocol === "file:") {
|
|
28
|
+
* console.log("this module was loaded locally");
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
url: string;
|
|
33
|
+
/**
|
|
34
|
+
* A function that returns resolved specifier as if it would be imported
|
|
35
|
+
* using `import(specifier)`.
|
|
36
|
+
*
|
|
37
|
+
* ```ts
|
|
38
|
+
* console.log(import.meta.resolve("./foo.js"));
|
|
39
|
+
* // file:///dev/foo.js
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* @param specifier The module specifier to resolve relative to `parent`.
|
|
43
|
+
* @param parent The absolute parent module URL to resolve from.
|
|
44
|
+
* @returns The absolute (`file:`) URL string for the resolved module.
|
|
45
|
+
*/
|
|
46
|
+
resolve(specifier: string, parent?: string | URL | undefined): string;
|
|
47
|
+
/** A flag that indicates if the current module is the main module that was
|
|
48
|
+
* called when starting the program under Deno.
|
|
49
|
+
*
|
|
50
|
+
* ```ts
|
|
51
|
+
* if (import.meta.main) {
|
|
52
|
+
* // this was loaded as the main module, maybe do some bootstrapping
|
|
53
|
+
* }
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
main: boolean;
|
|
57
|
+
/** The absolute path of the current module.
|
|
58
|
+
*
|
|
59
|
+
* This property is only provided for local modules (ie. using `file://` URLs).
|
|
60
|
+
*
|
|
61
|
+
* Example:
|
|
62
|
+
* ```
|
|
63
|
+
* // Unix
|
|
64
|
+
* console.log(import.meta.filename); // /home/alice/my_module.ts
|
|
65
|
+
*
|
|
66
|
+
* // Windows
|
|
67
|
+
* console.log(import.meta.filename); // C:\alice\my_module.ts
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
filename: string;
|
|
71
|
+
/** The absolute path of the directory containing the current module.
|
|
72
|
+
*
|
|
73
|
+
* This property is only provided for local modules (ie. using `file://` URLs).
|
|
74
|
+
*
|
|
75
|
+
* * Example:
|
|
76
|
+
* ```
|
|
77
|
+
* // Unix
|
|
78
|
+
* console.log(import.meta.dirname); // /home/alice
|
|
79
|
+
*
|
|
80
|
+
* // Windows
|
|
81
|
+
* console.log(import.meta.dirname); // C:\alice
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
dirname: string;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
type NodeRequest = ReturnType<typeof createRequire>;
|
|
88
|
+
type NodeModule = NonNullable<NodeRequest["main"]>;
|
|
89
|
+
interface ImportMetaPonyfillCommonjs {
|
|
90
|
+
(require: NodeRequest, module: NodeModule): ImportMeta;
|
|
91
|
+
}
|
|
92
|
+
interface ImportMetaPonyfillEsmodule {
|
|
93
|
+
(importMeta: ImportMeta): ImportMeta;
|
|
94
|
+
}
|
|
95
|
+
interface ImportMetaPonyfill extends ImportMetaPonyfillCommonjs, ImportMetaPonyfillEsmodule {
|
|
96
|
+
}
|
|
97
|
+
export declare let import_meta_ponyfill_commonjs: ImportMetaPonyfillCommonjs;
|
|
98
|
+
export declare let import_meta_ponyfill_esmodule: ImportMetaPonyfillEsmodule;
|
|
99
|
+
export declare let import_meta_ponyfill: ImportMetaPonyfill;
|
|
1
100
|
declare global {
|
|
2
101
|
interface Object {
|
|
3
102
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_dnt.polyfills.d.ts","sourceRoot":"","sources":["../src/_dnt.polyfills.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"_dnt.polyfills.d.ts","sourceRoot":"","sources":["../src/_dnt.polyfills.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EAAgC,KAAK,GAAG,EAAE,MAAM,UAAU,CAAC;AAGlE,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,UAAU;QAClB;;;;;;;;;;;;;;WAcG;QACH,GAAG,EAAE,MAAM,CAAC;QACZ;;;;;;;;;;;;WAYG;QACH,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,GAAG,GAAG,SAAS,GAAG,MAAM,CAAC;QACtE;;;;;;;;WAQG;QACH,IAAI,EAAE,OAAO,CAAC;QAEd;;;;;;;;;;;;WAYG;QACH,QAAQ,EAAE,MAAM,CAAC;QAEjB;;;;;;;;;;;;WAYG;QACH,OAAO,EAAE,MAAM,CAAC;KACjB;CACF;AAED,KAAK,WAAW,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC;AACpD,KAAK,UAAU,GAAG,WAAW,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC;AACnD,UAAU,0BAA0B;IAClC,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,GAAG,UAAU,CAAC;CACxD;AACD,UAAU,0BAA0B;IAClC,CAAC,UAAU,EAAE,UAAU,GAAG,UAAU,CAAC;CACtC;AACD,UAAU,kBACR,SAAQ,0BAA0B,EAAE,0BAA0B;CAC/D;AAiBD,eAAO,IAAI,6BAA6B,EA2BnC,0BAA0B,CAAC;AAMhC,eAAO,IAAI,6BAA6B,EA4DnC,0BAA0B,CAAC;AAMhC,eAAO,IAAI,oBAAoB,EAoB1B,kBAAkB,CAAC;AAgBxB,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd;;;;WAIG;QACH,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC;KAC5C;CACF;AAED,OAAO,EAAE,CAAC"}
|
package/esm/_dnt.polyfills.js
CHANGED
|
@@ -1,3 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Based on [import-meta-ponyfill](https://github.com/gaubee/import-meta-ponyfill),
|
|
3
|
+
* but instead of using npm to install additional dependencies,
|
|
4
|
+
* this approach manually consolidates cjs/mjs/d.ts into a single file.
|
|
5
|
+
*
|
|
6
|
+
* Note that this code might be imported multiple times
|
|
7
|
+
* (for example, both dnt.test.polyfills.ts and dnt.polyfills.ts contain this code;
|
|
8
|
+
* or Node.js might dynamically clear the cache and then force a require).
|
|
9
|
+
* Therefore, it's important to avoid redundant writes to global objects.
|
|
10
|
+
* Additionally, consider that commonjs is used alongside esm,
|
|
11
|
+
* so the two ponyfill functions are stored independently in two separate global objects.
|
|
12
|
+
*/
|
|
13
|
+
//@ts-ignore
|
|
14
|
+
import { createRequire } from "node:module";
|
|
15
|
+
//@ts-ignore
|
|
16
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
17
|
+
//@ts-ignore
|
|
18
|
+
import { dirname } from "node:path";
|
|
19
|
+
const defineGlobalPonyfill = (symbolFor, fn) => {
|
|
20
|
+
if (!Reflect.has(globalThis, Symbol.for(symbolFor))) {
|
|
21
|
+
Object.defineProperty(globalThis, Symbol.for(symbolFor), {
|
|
22
|
+
configurable: true,
|
|
23
|
+
get() {
|
|
24
|
+
return fn;
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
export let import_meta_ponyfill_commonjs = (Reflect.get(globalThis, Symbol.for("import-meta-ponyfill-commonjs")) ??
|
|
30
|
+
(() => {
|
|
31
|
+
const moduleImportMetaWM = new WeakMap();
|
|
32
|
+
return (require, module) => {
|
|
33
|
+
let importMetaCache = moduleImportMetaWM.get(module);
|
|
34
|
+
if (importMetaCache == null) {
|
|
35
|
+
const importMeta = Object.assign(Object.create(null), {
|
|
36
|
+
url: pathToFileURL(module.filename).href,
|
|
37
|
+
main: require.main == module,
|
|
38
|
+
resolve: (specifier, parentURL = importMeta.url) => {
|
|
39
|
+
return pathToFileURL((importMeta.url === parentURL
|
|
40
|
+
? require
|
|
41
|
+
: createRequire(parentURL))
|
|
42
|
+
.resolve(specifier)).href;
|
|
43
|
+
},
|
|
44
|
+
filename: module.filename,
|
|
45
|
+
dirname: module.path,
|
|
46
|
+
});
|
|
47
|
+
moduleImportMetaWM.set(module, importMeta);
|
|
48
|
+
importMetaCache = importMeta;
|
|
49
|
+
}
|
|
50
|
+
return importMetaCache;
|
|
51
|
+
};
|
|
52
|
+
})());
|
|
53
|
+
defineGlobalPonyfill("import-meta-ponyfill-commonjs", import_meta_ponyfill_commonjs);
|
|
54
|
+
export let import_meta_ponyfill_esmodule = (Reflect.get(globalThis, Symbol.for("import-meta-ponyfill-esmodule")) ??
|
|
55
|
+
((importMeta) => {
|
|
56
|
+
const resolveFunStr = String(importMeta.resolve);
|
|
57
|
+
const shimWs = new WeakSet();
|
|
58
|
+
//@ts-ignore
|
|
59
|
+
const mainUrl = ("file:///" + process.argv[1].replace(/\\/g, "/"))
|
|
60
|
+
.replace(/\/{3,}/, "///");
|
|
61
|
+
const commonShim = (importMeta) => {
|
|
62
|
+
if (typeof importMeta.main !== "boolean") {
|
|
63
|
+
importMeta.main = importMeta.url === mainUrl;
|
|
64
|
+
}
|
|
65
|
+
if (typeof importMeta.filename !== "string") {
|
|
66
|
+
importMeta.filename = fileURLToPath(importMeta.url);
|
|
67
|
+
importMeta.dirname = dirname(importMeta.filename);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
if (
|
|
71
|
+
// v16.2.0+, v14.18.0+: Add support for WHATWG URL object to parentURL parameter.
|
|
72
|
+
resolveFunStr === "undefined" ||
|
|
73
|
+
// v20.0.0+, v18.19.0+"" This API now returns a string synchronously instead of a Promise.
|
|
74
|
+
resolveFunStr.startsWith("async")
|
|
75
|
+
// enable by --experimental-import-meta-resolve flag
|
|
76
|
+
) {
|
|
77
|
+
import_meta_ponyfill_esmodule = (importMeta) => {
|
|
78
|
+
if (!shimWs.has(importMeta)) {
|
|
79
|
+
shimWs.add(importMeta);
|
|
80
|
+
const importMetaUrlRequire = {
|
|
81
|
+
url: importMeta.url,
|
|
82
|
+
require: createRequire(importMeta.url),
|
|
83
|
+
};
|
|
84
|
+
importMeta.resolve = function resolve(specifier, parentURL = importMeta.url) {
|
|
85
|
+
return pathToFileURL((importMetaUrlRequire.url === parentURL
|
|
86
|
+
? importMetaUrlRequire.require
|
|
87
|
+
: createRequire(parentURL)).resolve(specifier)).href;
|
|
88
|
+
};
|
|
89
|
+
commonShim(importMeta);
|
|
90
|
+
}
|
|
91
|
+
return importMeta;
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
/// native support
|
|
96
|
+
import_meta_ponyfill_esmodule = (importMeta) => {
|
|
97
|
+
if (!shimWs.has(importMeta)) {
|
|
98
|
+
shimWs.add(importMeta);
|
|
99
|
+
commonShim(importMeta);
|
|
100
|
+
}
|
|
101
|
+
return importMeta;
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
return import_meta_ponyfill_esmodule(importMeta);
|
|
105
|
+
}));
|
|
106
|
+
defineGlobalPonyfill("import-meta-ponyfill-esmodule", import_meta_ponyfill_esmodule);
|
|
107
|
+
export let import_meta_ponyfill = ((...args) => {
|
|
108
|
+
const _MODULE = (() => {
|
|
109
|
+
if (typeof require === "function" && typeof module === "object") {
|
|
110
|
+
return "commonjs";
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
// eval("typeof import.meta");
|
|
114
|
+
return "esmodule";
|
|
115
|
+
}
|
|
116
|
+
})();
|
|
117
|
+
if (_MODULE === "commonjs") {
|
|
118
|
+
//@ts-ignore
|
|
119
|
+
import_meta_ponyfill = (r, m) => import_meta_ponyfill_commonjs(r, m);
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
//@ts-ignore
|
|
123
|
+
import_meta_ponyfill = (im) => import_meta_ponyfill_esmodule(im);
|
|
124
|
+
}
|
|
125
|
+
//@ts-ignore
|
|
126
|
+
return import_meta_ponyfill(...args);
|
|
127
|
+
});
|
|
1
128
|
// https://github.com/tc39/proposal-accessible-object-hasownproperty/blob/main/polyfill.js
|
|
2
129
|
if (!Object.hasOwn) {
|
|
3
130
|
Object.defineProperty(Object, "hasOwn", {
|
|
@@ -12,4 +139,3 @@ if (!Object.hasOwn) {
|
|
|
12
139
|
writable: true,
|
|
13
140
|
});
|
|
14
141
|
}
|
|
15
|
-
export {};
|
|
@@ -7,7 +7,7 @@ export declare const DELIMITER: ";" | ":";
|
|
|
7
7
|
* The character used to separate components of a file path.
|
|
8
8
|
* On Windows, this is `\`. On all other platforms, this is `/`.
|
|
9
9
|
*/
|
|
10
|
-
export declare const SEPARATOR: "
|
|
10
|
+
export declare const SEPARATOR: "/" | "\\";
|
|
11
11
|
/**
|
|
12
12
|
* A regular expression that matches one or more path separators.
|
|
13
13
|
*/
|
package/esm/mod.d.ts
CHANGED
|
@@ -26,6 +26,32 @@ export type { Guardrails } from "./src/types.js";
|
|
|
26
26
|
export type { HandlersConfig } from "./src/types.js";
|
|
27
27
|
/** JSON-serializable value type used throughout Gambit. */
|
|
28
28
|
export type { JSONValue } from "./src/types.js";
|
|
29
|
+
/** Open Responses content part. */
|
|
30
|
+
export type { OpenResponseContentPart } from "./src/types.js";
|
|
31
|
+
/** Open Responses input (string or items). */
|
|
32
|
+
export type { OpenResponseInput } from "./src/types.js";
|
|
33
|
+
/** Open Responses item. */
|
|
34
|
+
export type { OpenResponseItem } from "./src/types.js";
|
|
35
|
+
/** Open Responses item status. */
|
|
36
|
+
export type { OpenResponseItemStatus } from "./src/types.js";
|
|
37
|
+
/** Open Responses message role. */
|
|
38
|
+
export type { OpenResponseMessageRole } from "./src/types.js";
|
|
39
|
+
/** Open Responses request type. */
|
|
40
|
+
export type { OpenResponseCreateRequest } from "./src/types.js";
|
|
41
|
+
/** Open Responses response type. */
|
|
42
|
+
export type { OpenResponseCreateResponse } from "./src/types.js";
|
|
43
|
+
/** Open Responses usage metadata. */
|
|
44
|
+
export type { OpenResponseUsage } from "./src/types.js";
|
|
45
|
+
/** Open Responses response format. */
|
|
46
|
+
export type { OpenResponseFormat } from "./src/types.js";
|
|
47
|
+
/** Open Responses tool choice. */
|
|
48
|
+
export type { OpenResponseToolChoice } from "./src/types.js";
|
|
49
|
+
/** Open Responses reasoning config. */
|
|
50
|
+
export type { OpenResponseReasoning } from "./src/types.js";
|
|
51
|
+
/** Open Responses stream options. */
|
|
52
|
+
export type { OpenResponseStreamOptions } from "./src/types.js";
|
|
53
|
+
/** Open Responses streaming event type. */
|
|
54
|
+
export type { OpenResponseEvent } from "./src/types.js";
|
|
29
55
|
/** Test deck definition shape. */
|
|
30
56
|
export type { TestDeckDefinition } from "./src/types.js";
|
|
31
57
|
/** Check if a value is an explicit end-of-run signal. */
|
|
@@ -46,8 +72,6 @@ export { renderDeck } from "./src/render.js";
|
|
|
46
72
|
export type { RenderDeckOptions } from "./src/render.js";
|
|
47
73
|
/** Result data from rendering a deck. */
|
|
48
74
|
export type { RenderDeckResult } from "./src/render.js";
|
|
49
|
-
/** Provider factory for OpenRouter-backed model calls. */
|
|
50
|
-
export { createOpenRouterProvider } from "./src/providers/openrouter.js";
|
|
51
75
|
/** Gambit CLI helpers and internal primitives. */
|
|
52
76
|
export { GAMBIT_TOOL_INIT } from "./src/constants.js";
|
|
53
77
|
/** Load a deck definition from disk. */
|
package/esm/mod.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],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AAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,kCAAkC;AAClC,YAAY,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzD,yCAAyC;AACzC,YAAY,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACxD,kDAAkD;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,wCAAwC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,0CAA0C;AAC1C,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AACtD,iCAAiC;AACjC,YAAY,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,4CAA4C;AAC5C,YAAY,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,sDAAsD;AACtD,YAAY,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,8CAA8C;AAC9C,YAAY,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,iDAAiD;AACjD,YAAY,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,6CAA6C;AAC7C,YAAY,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC"}
|
package/esm/mod.js
CHANGED
|
@@ -16,8 +16,6 @@ export { runDeck } from "./src/runtime.js";
|
|
|
16
16
|
export { chatCompletionsWithDeck } from "./src/openai_compat.js";
|
|
17
17
|
/** Render a deck to a human-readable outline or debug view. */
|
|
18
18
|
export { renderDeck } from "./src/render.js";
|
|
19
|
-
/** Provider factory for OpenRouter-backed model calls. */
|
|
20
|
-
export { createOpenRouterProvider } from "./src/providers/openrouter.js";
|
|
21
19
|
/** Gambit CLI helpers and internal primitives. */
|
|
22
20
|
export { GAMBIT_TOOL_INIT } from "./src/constants.js";
|
|
23
21
|
/** Load a deck definition from disk. */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builtins.d.ts","sourceRoot":"","sources":["../../src/src/builtins.ts"],"names":[],"mappings":"AAYA,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAOzE;AAED,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAO3E"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as path from "../deps/jsr.io/@std/path/1.1.4/mod.js";
|
|
2
|
+
const CARDS_PREFIX = "gambit://cards/";
|
|
3
|
+
const SCHEMAS_PREFIX = "gambit://schemas/";
|
|
4
|
+
const CARDS_BASE_URL = new URL("../cards/", globalThis[Symbol.for("import-meta-ponyfill-esmodule")](import.meta).url);
|
|
5
|
+
const SCHEMAS_BASE_URL = new URL("../schemas/", globalThis[Symbol.for("import-meta-ponyfill-esmodule")](import.meta).url);
|
|
6
|
+
function resolveFromBase(base, relative) {
|
|
7
|
+
return path.fromFileUrl(new URL(relative, base));
|
|
8
|
+
}
|
|
9
|
+
export function resolveBuiltinCardPath(target) {
|
|
10
|
+
if (!target.startsWith(CARDS_PREFIX))
|
|
11
|
+
return undefined;
|
|
12
|
+
const relative = target.slice(CARDS_PREFIX.length);
|
|
13
|
+
if (!relative) {
|
|
14
|
+
throw new Error(`Invalid gambit card specifier: ${target}`);
|
|
15
|
+
}
|
|
16
|
+
return resolveFromBase(CARDS_BASE_URL, relative);
|
|
17
|
+
}
|
|
18
|
+
export function resolveBuiltinSchemaPath(target) {
|
|
19
|
+
if (!target.startsWith(SCHEMAS_PREFIX))
|
|
20
|
+
return undefined;
|
|
21
|
+
const relative = target.slice(SCHEMAS_PREFIX.length);
|
|
22
|
+
if (!relative) {
|
|
23
|
+
throw new Error(`Invalid gambit schema specifier: ${target}`);
|
|
24
|
+
}
|
|
25
|
+
return resolveFromBase(SCHEMAS_BASE_URL, relative);
|
|
26
|
+
}
|
package/esm/src/loader.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/src/loader.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/src/loader.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAKV,UAAU,EACV,UAAU,EAEX,MAAM,YAAY,CAAC;AAsHpB,wBAAsB,QAAQ,CAC5B,QAAQ,EAAE,MAAM,EAChB,UAAU,CAAC,EAAE,MAAM,EACnB,KAAK,GAAE,KAAK,CAAC,MAAM,CAAM,GACxB,OAAO,CAAC,UAAU,CAAC,CAOrB;AAED,wBAAsB,QAAQ,CAC5B,QAAQ,EAAE,MAAM,EAChB,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,UAAU,CAAC,CA6HrB"}
|
package/esm/src/loader.js
CHANGED
|
@@ -3,6 +3,7 @@ import { BUILTIN_TOOL_NAME_SET, MAX_TOOL_NAME_LENGTH, RESERVED_TOOL_PREFIX, TOOL
|
|
|
3
3
|
import { isCardDefinition, isDeckDefinition } from "./definitions.js";
|
|
4
4
|
import { mergeZodObjects } from "./schema.js";
|
|
5
5
|
import { isMarkdownFile, loadMarkdownCard, loadMarkdownDeck, } from "./markdown.js";
|
|
6
|
+
import { resolveBuiltinCardPath } from "./builtins.js";
|
|
6
7
|
const logger = console;
|
|
7
8
|
function toFileUrl(p) {
|
|
8
9
|
const abs = path.resolve(p);
|
|
@@ -72,10 +73,12 @@ async function loadCardInternal(cardPath, parentPath, stack = []) {
|
|
|
72
73
|
};
|
|
73
74
|
}
|
|
74
75
|
export async function loadCard(cardPath, parentPath, stack = []) {
|
|
75
|
-
|
|
76
|
-
|
|
76
|
+
const builtinPath = resolveBuiltinCardPath(cardPath);
|
|
77
|
+
const normalizedPath = builtinPath ?? cardPath;
|
|
78
|
+
if (isMarkdownFile(normalizedPath)) {
|
|
79
|
+
return await loadMarkdownCard(normalizedPath, parentPath, stack);
|
|
77
80
|
}
|
|
78
|
-
return await loadCardInternal(
|
|
81
|
+
return await loadCardInternal(normalizedPath, parentPath, stack);
|
|
79
82
|
}
|
|
80
83
|
export async function loadDeck(deckPath, parentPath) {
|
|
81
84
|
if (isMarkdownFile(deckPath)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../src/src/markdown.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../src/src/markdown.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAIV,UAAU,EACV,UAAU,EAEX,MAAM,YAAY,CAAC;AAmKpB,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,MAAM,EAChB,UAAU,CAAC,EAAE,MAAM,EACnB,KAAK,GAAE,KAAK,CAAC,MAAM,CAAM,GACxB,OAAO,CAAC,UAAU,CAAC,CA8FrB;AAED,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,MAAM,EAChB,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,UAAU,CAAC,CAgLrB;AAED,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAExD"}
|