@runlot/next 0.1.0-rc.21 → 0.1.0-rc.211
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 +10 -10
- package/dist/ai.d.ts +576 -0
- package/dist/ai.d.ts.map +1 -0
- package/dist/ai.js +2 -0
- package/dist/ai.js.map +1 -0
- package/dist/build.d.ts +22 -17
- package/dist/build.d.ts.map +1 -1
- package/dist/build.js +48 -32
- package/dist/build.js.map +1 -1
- package/dist/entry.d.ts +4 -3
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +11 -9
- package/dist/entry.js.map +1 -1
- package/dist/index.d.ts +15 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +43 -25
- package/dist/index.js.map +1 -1
- package/dist/judge.d.ts +36 -0
- package/dist/judge.d.ts.map +1 -0
- package/dist/judge.js +27 -0
- package/dist/judge.js.map +1 -0
- package/dist/opennext/context.d.ts +6 -3
- package/dist/opennext/context.d.ts.map +1 -1
- package/dist/opennext/context.js +17 -12
- package/dist/opennext/context.js.map +1 -1
- package/dist/opennext/incremental-cache.d.ts +2 -1
- package/dist/opennext/incremental-cache.d.ts.map +1 -1
- package/dist/opennext/incremental-cache.js +18 -12
- package/dist/opennext/incremental-cache.js.map +1 -1
- package/dist/opennext/tag-cache.d.ts +3 -3
- package/dist/opennext/tag-cache.d.ts.map +1 -1
- package/dist/opennext/tag-cache.js +15 -11
- package/dist/opennext/tag-cache.js.map +1 -1
- package/dist/store.d.ts +14 -9
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +22 -20
- package/dist/store.js.map +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# @runlot/next
|
|
2
2
|
|
|
3
|
-
Next.js
|
|
3
|
+
Next.js 어댑터입니다. 이 문서는 패키지 사용법을 설명합니다.
|
|
4
4
|
|
|
5
|
-
> **npm 이름은
|
|
5
|
+
> **npm 패키지 이름은 `@runlot/next` 입니다.** 예제와 템플릿의 import 지정자도 같습니다.
|
|
6
6
|
> 랜딩의 코드 예시와 템플릿이 쓰는 지정자는 `runlot/next` 다 (`import { env }
|
|
7
7
|
> from "runlot/next"`). 게시할 때 이름을 바꾸는 자리가 여기 하나뿐이도록,
|
|
8
8
|
> 이 패키지 안에서는 자기 이름을 문자열로 쓰지 않는다 — 예외는 빌드가 만드는
|
|
@@ -11,9 +11,9 @@ Next.js 어댑터. 설계는 `docs/nextjs.md` 에 있고, 이 문서는 표면
|
|
|
11
11
|
## 표면
|
|
12
12
|
|
|
13
13
|
```ts
|
|
14
|
-
import { env, request, waitUntil } from "runlot/next";
|
|
14
|
+
import { env, request, waitUntil } from "@runlot/next";
|
|
15
15
|
|
|
16
|
-
const user = await env.auth.user(); // 요청은 어댑터가
|
|
16
|
+
const user = await env.auth.user(); // 요청은 어댑터가 알아서 넘깁니다
|
|
17
17
|
const rows = await env.db.exec("select 1");
|
|
18
18
|
const url = await env.storage.presign("covers/a.png");
|
|
19
19
|
const token = env.MY_SECRET; // 나머지는 문자열이다
|
|
@@ -21,15 +21,15 @@ const token = env.MY_SECRET; // 나머지는 문자열이다
|
|
|
21
21
|
|
|
22
22
|
| 이름 | 무엇 |
|
|
23
23
|
|---|---|
|
|
24
|
-
| `env` | 이 요청의 바인딩. **요청 밖에서 읽으면
|
|
24
|
+
| `env` | 이 요청의 바인딩. **요청 밖에서 읽으면 오류를 냅니다** |
|
|
25
25
|
| `env.auth.user(request?)` | 인자가 없으면 이 요청. `signOut` 도 같다 |
|
|
26
26
|
| `request()` | 이 요청의 `Request` |
|
|
27
27
|
| `waitUntil(p)` | 응답 뒤에도 끝까지 도는 일 |
|
|
28
28
|
| `inRequest()` | 지금 요청 안인가. 라이브러리가 갈래를 나눌 때만 |
|
|
29
|
-
| `wrap(worker)` (
|
|
30
|
-
| `buildNext(opts)` (
|
|
29
|
+
| `wrap(worker)` (`@runlot/next/entry`) | 빌드가 세우는 진입 wrapper |
|
|
30
|
+
| `buildNext(opts)` (`@runlot/next/build`) | `runlot deploy` 가 부릅니다 |
|
|
31
31
|
|
|
32
|
-
`env` 가 요청 밖에서
|
|
32
|
+
`env` 가 요청 밖에서 오류를 내는 것은 의도된 설계입니다. 모듈 최상단과 빌드 시점 정적 렌더가
|
|
33
33
|
그 자리이고, 거기서 조용히 빈 값을 주면 **모든 페이지가 로그아웃 상태로**
|
|
34
34
|
보인다 (`docs/auth.md §4` 의 같은 문장).
|
|
35
35
|
|
|
@@ -55,7 +55,7 @@ const token = env.MY_SECRET; // 나머지는 문자열이다
|
|
|
55
55
|
| queue | OpenNext 의 `memory-queue` (`WORKER_SELF_REFERENCE` 를 쓴다) | — |
|
|
56
56
|
| enableCacheInterception | `true` | — |
|
|
57
57
|
|
|
58
|
-
## wrangler 는 의존이
|
|
58
|
+
## wrangler 는 의존이 아닙니다
|
|
59
59
|
|
|
60
60
|
`@opennextjs/cloudflare` 의 `peerDependencies` 에 `wrangler` 가 있지만, 런타임에
|
|
61
61
|
그것을 import 하는 것은 `dist/cli/commands/*` 뿐이다. 우리가 부르는
|
|
@@ -63,7 +63,7 @@ const token = env.MY_SECRET; // 나머지는 문자열이다
|
|
|
63
63
|
`dependencies` 에 두지 않는다 — pnpm 이 peer 를 자동 설치하는 워크스페이스에서는
|
|
64
64
|
스토어에 내려와 있을 수 있지만, 우리 코드 경로는 그것을 부르지 않는다.
|
|
65
65
|
|
|
66
|
-
##
|
|
66
|
+
## 요청 상태는 globalThis 의 심볼에 둡니다
|
|
67
67
|
|
|
68
68
|
`Symbol.for("runlot.next.store")`. 모듈 인스턴스가 하나라는 보장이 없어서다:
|
|
69
69
|
OpenNext 의 `worker.js` 는 이미 묶인 번들이라 그 안에 이 패키지의 사본이 있고,
|
package/dist/ai.d.ts
ADDED
|
@@ -0,0 +1,576 @@
|
|
|
1
|
+
/** A JSON Schema object accepted by `responseFormat` and `inputJsonSchema`. */
|
|
2
|
+
export type AIJsonSchema = Record<string, unknown>;
|
|
3
|
+
/** A text part. An array of text parts is the string its texts make, joined by "\n". */
|
|
4
|
+
export interface AITextPart {
|
|
5
|
+
type: "text";
|
|
6
|
+
text: string;
|
|
7
|
+
}
|
|
8
|
+
/** A tool call the model made, sent back on the assistant message that made it. */
|
|
9
|
+
export interface AIToolCallPart {
|
|
10
|
+
type: "tool_call";
|
|
11
|
+
id: string;
|
|
12
|
+
name: string;
|
|
13
|
+
args: Record<string, unknown>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Your answer to a tool call, on the user message right after the assistant
|
|
17
|
+
* message that made it; every call of that message needs one.
|
|
18
|
+
*/
|
|
19
|
+
export interface AIToolResultPart {
|
|
20
|
+
type: "tool_result";
|
|
21
|
+
/** The `id` of the `tool_call` this answers. */
|
|
22
|
+
callId: string;
|
|
23
|
+
text?: string;
|
|
24
|
+
data?: unknown;
|
|
25
|
+
isError?: boolean;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* A reasoning block, sent back exactly as a return-mode answer's `content`
|
|
29
|
+
* carried it: the provider checks the signature. `redacted` is base64.
|
|
30
|
+
*/
|
|
31
|
+
export interface AIReasoningPart {
|
|
32
|
+
type: "reasoning";
|
|
33
|
+
text?: string;
|
|
34
|
+
signature?: string;
|
|
35
|
+
redacted?: string;
|
|
36
|
+
}
|
|
37
|
+
/** What a user message's `content` array may hold. */
|
|
38
|
+
export type AIUserPart = AITextPart | AIToolResultPart;
|
|
39
|
+
/** What an assistant message's `content` array may hold, and what a return-mode answer's `content` is. */
|
|
40
|
+
export type AIAssistantPart = AITextPart | AIToolCallPart | AIReasoningPart;
|
|
41
|
+
export type AIContentPart = AIUserPart | AIAssistantPart;
|
|
42
|
+
interface AIMessageBase {
|
|
43
|
+
/**
|
|
44
|
+
* End a cached prefix after this message (user messages only). Only on a
|
|
45
|
+
* model whose `env.ai.models()` row lists `cacheTTLs`.
|
|
46
|
+
*/
|
|
47
|
+
cacheBreakpoint?: boolean;
|
|
48
|
+
}
|
|
49
|
+
export interface AIUserMessage extends AIMessageBase {
|
|
50
|
+
role: "user";
|
|
51
|
+
content: string | readonly AIUserPart[];
|
|
52
|
+
}
|
|
53
|
+
export interface AIAssistantMessage extends AIMessageBase {
|
|
54
|
+
role: "assistant";
|
|
55
|
+
content: string | readonly AIAssistantPart[];
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* One conversational message. System instructions belong in
|
|
59
|
+
* `AIRunOptions.system`.
|
|
60
|
+
*
|
|
61
|
+
* `content` is a string or an array of parts. A runtime whose
|
|
62
|
+
* `env.ai.features` lacks `"contentParts"` (or that has no `features`) turns
|
|
63
|
+
* an array into text; check before sending one. The runtime refuses a
|
|
64
|
+
* transcript whose parts do not fit together (code `bad_messages`): a result
|
|
65
|
+
* that answers no call of the turn before it, a call left without a result,
|
|
66
|
+
* or a `tool_call` naming a tool the call does not pass.
|
|
67
|
+
*/
|
|
68
|
+
export type AIMessage = AIUserMessage | AIAssistantMessage;
|
|
69
|
+
/** Token usage returned by a chat run and accumulated across tool rounds. */
|
|
70
|
+
export interface AIUsage {
|
|
71
|
+
inputTokens: number;
|
|
72
|
+
outputTokens: number;
|
|
73
|
+
/** The part of `inputTokens` read from the provider's prompt cache. */
|
|
74
|
+
cachedInputTokens: number;
|
|
75
|
+
/**
|
|
76
|
+
* The part of `inputTokens` written to the provider's prompt cache. Optional
|
|
77
|
+
* in the type so that usage objects written before it existed still check;
|
|
78
|
+
* the deployed runtime always sends it.
|
|
79
|
+
*/
|
|
80
|
+
cacheWriteInputTokens?: number;
|
|
81
|
+
/**
|
|
82
|
+
* The cache counts the provider did not report. Each one named here is `0`
|
|
83
|
+
* above for lack of information, not because nothing was read or written,
|
|
84
|
+
* and is charged as that `0`. Absent when every count was reported; skip
|
|
85
|
+
* the calls that name `cachedInputTokens` when computing a hit rate.
|
|
86
|
+
*/
|
|
87
|
+
unreported?: Array<"cachedInputTokens" | "cacheWriteInputTokens">;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* The explicit prompt cache. Only on a model whose `env.ai.models()` row lists
|
|
91
|
+
* `cacheTTLs`; asking any other model is a 400.
|
|
92
|
+
*/
|
|
93
|
+
export interface AICacheOptions {
|
|
94
|
+
/**
|
|
95
|
+
* `implicit` (the default) lets the provider add its own breakpoint at the
|
|
96
|
+
* latest message beside yours; `explicit` uses only your breakpoints, and a
|
|
97
|
+
* call with none caches nothing and pays no write.
|
|
98
|
+
*/
|
|
99
|
+
mode?: "implicit" | "explicit";
|
|
100
|
+
/** One of the model's `cacheTTLs`. Omitted means the provider's default. */
|
|
101
|
+
ttl?: string;
|
|
102
|
+
/** Calls that share a key are routed together, which makes a read likely. At most 64 bytes. */
|
|
103
|
+
key?: string;
|
|
104
|
+
/** End a cached prefix after the system prompt. */
|
|
105
|
+
system?: boolean;
|
|
106
|
+
}
|
|
107
|
+
/** Every reasoning-effort value currently advertised by the model catalog. */
|
|
108
|
+
export type AIReasoningEffort = "none" | "low" | "medium" | "high" | "xhigh" | "max";
|
|
109
|
+
export interface AIReasoning {
|
|
110
|
+
effort: AIReasoningEffort;
|
|
111
|
+
}
|
|
112
|
+
/** Ask a supported model for JSON conforming to `schema`. */
|
|
113
|
+
export interface AIResponseFormat {
|
|
114
|
+
type: "json_schema";
|
|
115
|
+
/** Optional provider-facing schema name. The runtime defaults it to `response`. */
|
|
116
|
+
name?: string;
|
|
117
|
+
schema: AIJsonSchema;
|
|
118
|
+
}
|
|
119
|
+
export interface AIToolContext {
|
|
120
|
+
/** Aborted when the caller aborts the run or the remote tool session ends. */
|
|
121
|
+
signal: AbortSignal;
|
|
122
|
+
/** The id that correlates this callback with the model's tool call. */
|
|
123
|
+
callId: string;
|
|
124
|
+
model: string;
|
|
125
|
+
}
|
|
126
|
+
/** A normal tool result. A thrown error is converted to `{ text, isError: true }`. */
|
|
127
|
+
export interface AIToolResult<Data = unknown> {
|
|
128
|
+
text?: string;
|
|
129
|
+
data?: Data;
|
|
130
|
+
isError?: boolean;
|
|
131
|
+
stop?: false;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* A terminal tool result. The facade acknowledges remote cancellation instead
|
|
135
|
+
* of submitting it to the model, then returns without another model round.
|
|
136
|
+
*/
|
|
137
|
+
export interface AITerminalToolResult<Data = unknown> {
|
|
138
|
+
stop: true;
|
|
139
|
+
text?: string;
|
|
140
|
+
data?: Data;
|
|
141
|
+
}
|
|
142
|
+
/** A non-object return is wrapped as the tool result's `data` field. */
|
|
143
|
+
export type AIToolRawResult = string | number | boolean | null | undefined | readonly unknown[];
|
|
144
|
+
export type AIToolExecuteResult<Data = unknown> = AIToolResult<Data> | AITerminalToolResult<Data> | AIToolRawResult;
|
|
145
|
+
/** A callback tool whose closure remains in the originating app worker. */
|
|
146
|
+
export interface AITool<Args extends Record<string, unknown> = Record<string, unknown>, Data = unknown> {
|
|
147
|
+
name: string;
|
|
148
|
+
description: string;
|
|
149
|
+
inputJsonSchema: AIJsonSchema;
|
|
150
|
+
execute(args: Args, context: AIToolContext): AIToolExecuteResult<Data> | Promise<AIToolExecuteResult<Data>>;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* A tool as `toolMode: "return"` takes it: the definition the model may call,
|
|
154
|
+
* and no `execute` — the runtime runs nothing in that mode.
|
|
155
|
+
*/
|
|
156
|
+
export interface AIToolDefinition {
|
|
157
|
+
name: string;
|
|
158
|
+
description: string;
|
|
159
|
+
inputJsonSchema: AIJsonSchema;
|
|
160
|
+
execute?: never;
|
|
161
|
+
}
|
|
162
|
+
/** One tool call of a return-mode answer. */
|
|
163
|
+
export interface AIToolCall<Args extends Record<string, unknown> = Record<string, unknown>> {
|
|
164
|
+
id: string;
|
|
165
|
+
name: string;
|
|
166
|
+
args: Args;
|
|
167
|
+
}
|
|
168
|
+
export interface AIFinalTool<Args extends Record<string, unknown> = Record<string, unknown>, Data = unknown> {
|
|
169
|
+
id: string;
|
|
170
|
+
name: string;
|
|
171
|
+
args: Args;
|
|
172
|
+
result: AITerminalToolResult<Data>;
|
|
173
|
+
}
|
|
174
|
+
/** Provider stop reasons are open-ended; `tool_stop` is added by Runlot. */
|
|
175
|
+
export type AIStopReason = "tool_stop" | (string & {});
|
|
176
|
+
export interface AIRunResult {
|
|
177
|
+
text: string;
|
|
178
|
+
model: string;
|
|
179
|
+
stopReason: AIStopReason;
|
|
180
|
+
usage: AIUsage;
|
|
181
|
+
/** False means `usage` is the amount observed before termination, not an exact final total. */
|
|
182
|
+
usageComplete: boolean;
|
|
183
|
+
/** Present when a callback returned `{ stop: true }`. */
|
|
184
|
+
finalTool?: AIFinalTool;
|
|
185
|
+
}
|
|
186
|
+
export interface AIToolStopResult extends AIRunResult {
|
|
187
|
+
stopReason: "tool_stop";
|
|
188
|
+
finalTool: AIFinalTool;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* A `toolMode: "return"` answer: one model call, whose tool calls are
|
|
192
|
+
* returned instead of run. `stopReason` is the provider's (`"tool_use"` when
|
|
193
|
+
* the model asked for tools).
|
|
194
|
+
*/
|
|
195
|
+
export interface AIReturnRunResult extends Omit<AIRunResult, "finalTool"> {
|
|
196
|
+
/** Every tool call of the round, in the model's order; `[]` when there were none. */
|
|
197
|
+
toolCalls: AIToolCall[];
|
|
198
|
+
/**
|
|
199
|
+
* The assistant turn as parts, in the model's order. Send it back as the
|
|
200
|
+
* next call's assistant message, followed by a user message of
|
|
201
|
+
* `tool_result` parts.
|
|
202
|
+
*/
|
|
203
|
+
content: AIAssistantPart[];
|
|
204
|
+
}
|
|
205
|
+
type AIRunInput = {
|
|
206
|
+
prompt: string;
|
|
207
|
+
messages?: string | readonly AIMessage[];
|
|
208
|
+
} | {
|
|
209
|
+
messages: string | readonly AIMessage[];
|
|
210
|
+
prompt?: string;
|
|
211
|
+
};
|
|
212
|
+
/**
|
|
213
|
+
* What the app attaches to one call for its own observability
|
|
214
|
+
* (docs/ai-observability.md §2.2). It is never sent to the model or to a
|
|
215
|
+
* lender; it exists only on the project's record of the call. Strings are cut
|
|
216
|
+
* at 200 bytes and tags after ten, never refused.
|
|
217
|
+
*/
|
|
218
|
+
export interface AICallMetadata {
|
|
219
|
+
/** Groups calls into a session on the dashboard. */
|
|
220
|
+
sessionId?: string;
|
|
221
|
+
/** The app's own end-user id; only readers with the pii grant see it. */
|
|
222
|
+
userId?: string;
|
|
223
|
+
tags?: readonly string[];
|
|
224
|
+
}
|
|
225
|
+
interface AIRunSettings {
|
|
226
|
+
system?: string;
|
|
227
|
+
maxTokens?: number;
|
|
228
|
+
temperature?: number;
|
|
229
|
+
reasoning?: AIReasoning;
|
|
230
|
+
responseFormat?: AIResponseFormat;
|
|
231
|
+
cache?: AICacheOptions;
|
|
232
|
+
tools?: readonly AITool[];
|
|
233
|
+
/** Defaults to 8 and is bounded by the runtime. */
|
|
234
|
+
maxToolRounds?: number;
|
|
235
|
+
/** `"execute"`, the default: the runtime runs each tool's `execute` and loops. */
|
|
236
|
+
toolMode?: "execute";
|
|
237
|
+
/** Used by the app-worker tool loop. */
|
|
238
|
+
signal?: AbortSignal;
|
|
239
|
+
metadata?: AICallMetadata;
|
|
240
|
+
}
|
|
241
|
+
/** Options shared by streaming and non-streaming model runs. */
|
|
242
|
+
export type AIRunOptions = AIRunInput & AIRunSettings & {
|
|
243
|
+
stream?: boolean;
|
|
244
|
+
};
|
|
245
|
+
/**
|
|
246
|
+
* `toolMode: "return"`: the runtime makes one model call and answers the
|
|
247
|
+
* tool calls the model asked for (`AIReturnRunResult`) instead of running
|
|
248
|
+
* them, so your code runs the loop — send `content` back as the assistant
|
|
249
|
+
* message and your results as `tool_result` parts. `tools` are bare
|
|
250
|
+
* definitions and required; `maxToolRounds` has no meaning here. The runtime
|
|
251
|
+
* throws a TypeError for a tool with `execute`, no tools, or `maxToolRounds`.
|
|
252
|
+
* Check `env.ai.features` for `"toolModeReturn"` first: an older runtime
|
|
253
|
+
* would ignore the mode.
|
|
254
|
+
*/
|
|
255
|
+
export type AIReturnRunOptions = AIRunInput & Omit<AIRunSettings, "tools" | "maxToolRounds" | "toolMode"> & {
|
|
256
|
+
toolMode: "return";
|
|
257
|
+
tools: readonly AIToolDefinition[];
|
|
258
|
+
maxToolRounds?: never;
|
|
259
|
+
stream?: boolean;
|
|
260
|
+
};
|
|
261
|
+
export type AIStream = ReadableStream<Uint8Array>;
|
|
262
|
+
/** A text frame in the public SSE stream. */
|
|
263
|
+
export interface AIStreamDelta {
|
|
264
|
+
delta: string;
|
|
265
|
+
}
|
|
266
|
+
/** A usage frame emitted by a tool-bearing stream after a completed round. */
|
|
267
|
+
export interface AIStreamUsage extends AIUsage {
|
|
268
|
+
/** True for a provider's cumulative total, absent for per-round usage. */
|
|
269
|
+
cumulative?: boolean;
|
|
270
|
+
round?: number;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* The `done` payload. Plain model streams guarantee `model`; tool-bearing
|
|
274
|
+
* streams also include the accumulated result fields.
|
|
275
|
+
*/
|
|
276
|
+
export interface AIStreamDone {
|
|
277
|
+
model: string;
|
|
278
|
+
text?: string;
|
|
279
|
+
stopReason?: AIStopReason;
|
|
280
|
+
usage?: AIUsage;
|
|
281
|
+
/** False means `usage` is only what was observable before the stream stopped. */
|
|
282
|
+
usageComplete?: boolean;
|
|
283
|
+
finalTool?: AIFinalTool;
|
|
284
|
+
/** A `toolMode: "return"` stream's: the round's tool calls, `[]` when none. */
|
|
285
|
+
toolCalls?: AIToolCall[];
|
|
286
|
+
/** A `toolMode: "return"` stream's: the assistant turn as parts. */
|
|
287
|
+
content?: AIAssistantPart[];
|
|
288
|
+
}
|
|
289
|
+
/** A mid-stream failure payload. Rich context is present on tool-bearing runs. */
|
|
290
|
+
export interface AIStreamError {
|
|
291
|
+
message: string;
|
|
292
|
+
code?: string;
|
|
293
|
+
text?: string;
|
|
294
|
+
model?: string;
|
|
295
|
+
usage?: AIUsage;
|
|
296
|
+
/** Tool errors report partial observed usage; plain streams may omit this. */
|
|
297
|
+
usageComplete?: false;
|
|
298
|
+
/** Present when the terminal callback completed but remote cancellation failed. */
|
|
299
|
+
finalTool?: AIFinalTool;
|
|
300
|
+
}
|
|
301
|
+
/** Fields attached to errors returned before an HTTP stream starts. */
|
|
302
|
+
export interface AIHTTPError extends Error {
|
|
303
|
+
status: number;
|
|
304
|
+
code: string;
|
|
305
|
+
text?: string;
|
|
306
|
+
usage?: AIUsage;
|
|
307
|
+
model?: string;
|
|
308
|
+
/** Pre-stream failures have no final usage; when present this is false. */
|
|
309
|
+
usageComplete?: false;
|
|
310
|
+
}
|
|
311
|
+
/** Fields attached when a tool loop fails after producing partial work. */
|
|
312
|
+
export interface AIToolRunError extends Error {
|
|
313
|
+
code?: string;
|
|
314
|
+
text: string;
|
|
315
|
+
usage: AIUsage;
|
|
316
|
+
/** Errors report partial observed usage, so this is false. */
|
|
317
|
+
usageComplete: boolean;
|
|
318
|
+
model: string;
|
|
319
|
+
/** Present when the terminal callback completed but remote cancellation failed. */
|
|
320
|
+
finalTool?: AIFinalTool;
|
|
321
|
+
status?: number;
|
|
322
|
+
}
|
|
323
|
+
/** The union useful when narrowing an unknown `env.ai` failure. */
|
|
324
|
+
export type AIError = AIHTTPError | AIToolRunError;
|
|
325
|
+
/** Every task type currently accepted by the task-aware embedding model. */
|
|
326
|
+
export type AIEmbeddingTaskType = "RETRIEVAL_QUERY" | "RETRIEVAL_DOCUMENT" | "SEMANTIC_SIMILARITY" | "CLASSIFICATION" | "CLUSTERING" | "QUESTION_ANSWERING" | "FACT_VERIFICATION" | "CODE_RETRIEVAL_QUERY";
|
|
327
|
+
export interface AIEmbedOptions {
|
|
328
|
+
dimensions?: number;
|
|
329
|
+
/** Omit this to retain the model's own default embedding space. */
|
|
330
|
+
taskType?: AIEmbeddingTaskType;
|
|
331
|
+
metadata?: AICallMetadata;
|
|
332
|
+
}
|
|
333
|
+
export interface AIEmbedUsage {
|
|
334
|
+
inputTokens: number;
|
|
335
|
+
}
|
|
336
|
+
export interface AIEmbedResult {
|
|
337
|
+
/** `vectors[i]` belongs to `input[i]`. */
|
|
338
|
+
vectors: number[][];
|
|
339
|
+
dimensions: number;
|
|
340
|
+
model: string;
|
|
341
|
+
usage: AIEmbedUsage;
|
|
342
|
+
/** Echoed only when the request supplied a task type. */
|
|
343
|
+
taskType?: AIEmbeddingTaskType;
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* One question to a decision model (`env.ai.judge`), on the System One
|
|
347
|
+
* contract: `noul` is the probability of yes, `choice` one option of a set,
|
|
348
|
+
* `score` a position on an ordered rubric (levels lowest first), and `box`
|
|
349
|
+
* where something is in an image (Jev 1.14; only on a model whose
|
|
350
|
+
* `questionTypes` lists it). Any other field is the vendor's and is sent as
|
|
351
|
+
* written. The helpers `noul`, `choice`, `score` and `box` build these.
|
|
352
|
+
*/
|
|
353
|
+
export type AIJudgeQuestion = AIJudgeNoulQuestion | AIJudgeChoiceQuestion | AIJudgeScoreQuestion | AIJudgeBoxQuestion;
|
|
354
|
+
export interface AIJudgeNoulQuestion {
|
|
355
|
+
readonly type: "noul";
|
|
356
|
+
readonly instructions?: unknown;
|
|
357
|
+
readonly criteria?: {
|
|
358
|
+
readonly true?: unknown;
|
|
359
|
+
readonly false?: unknown;
|
|
360
|
+
};
|
|
361
|
+
readonly [vendorField: string]: unknown;
|
|
362
|
+
}
|
|
363
|
+
export interface AIJudgeChoiceQuestion<O extends string = string> {
|
|
364
|
+
readonly type: "choice";
|
|
365
|
+
readonly instructions?: unknown;
|
|
366
|
+
/** Option name → description; 2 to the model's `maxChoices`. */
|
|
367
|
+
readonly criteria: {
|
|
368
|
+
readonly [option in O]: unknown;
|
|
369
|
+
};
|
|
370
|
+
readonly [vendorField: string]: unknown;
|
|
371
|
+
}
|
|
372
|
+
export interface AIJudgeScoreQuestion<L = unknown> {
|
|
373
|
+
readonly type: "score";
|
|
374
|
+
readonly instructions?: unknown;
|
|
375
|
+
/** Levels, lowest first; 2 to the model's `maxScoreLevels`. */
|
|
376
|
+
readonly criteria: readonly L[];
|
|
377
|
+
readonly [vendorField: string]: unknown;
|
|
378
|
+
}
|
|
379
|
+
export interface AIJudgeBoxQuestion {
|
|
380
|
+
readonly type: "box";
|
|
381
|
+
/** What to find, e.g. "the coffee mug in `photo`". A box takes no criteria. */
|
|
382
|
+
readonly instructions?: unknown;
|
|
383
|
+
readonly criteria?: never;
|
|
384
|
+
readonly [vendorField: string]: unknown;
|
|
385
|
+
}
|
|
386
|
+
/** The questions of one call, keyed by name. */
|
|
387
|
+
export type AIJudgeQuestions = {
|
|
388
|
+
readonly [name: string]: AIJudgeQuestion;
|
|
389
|
+
};
|
|
390
|
+
export interface AIJudgeNoulAnswer {
|
|
391
|
+
type: "noul";
|
|
392
|
+
/** The probability the answer is yes, 0–1. */
|
|
393
|
+
noul: number;
|
|
394
|
+
}
|
|
395
|
+
export interface AIJudgeChoiceAnswer<O extends string = string> {
|
|
396
|
+
type: "choice";
|
|
397
|
+
choice: O;
|
|
398
|
+
confidence: number;
|
|
399
|
+
probabilities: Record<O, number>;
|
|
400
|
+
}
|
|
401
|
+
export interface AIJudgeScoreAnswer<L = unknown> {
|
|
402
|
+
type: "score";
|
|
403
|
+
/** Probability-weighted level index; can land between levels. */
|
|
404
|
+
score: number;
|
|
405
|
+
confidence: number;
|
|
406
|
+
/** Level index (as a string) → the level as you wrote it. */
|
|
407
|
+
legend?: Record<string, L>;
|
|
408
|
+
probabilities: Record<string, number>;
|
|
409
|
+
}
|
|
410
|
+
export interface AIJudgeBoxAnswer {
|
|
411
|
+
type: "box";
|
|
412
|
+
/** Fractions 0–1: left and right of the width, top and bottom of the height. */
|
|
413
|
+
box: {
|
|
414
|
+
top: number;
|
|
415
|
+
bottom: number;
|
|
416
|
+
left: number;
|
|
417
|
+
right: number;
|
|
418
|
+
};
|
|
419
|
+
confidence: number;
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* A model that declines one question answers it `{ type: "refusal" }` with no
|
|
423
|
+
* evaluation fields (OpenAI Decisions does). It is an answer, not an error:
|
|
424
|
+
* the other questions of the call are answered, and the call is billed.
|
|
425
|
+
*/
|
|
426
|
+
export interface AIJudgeRefusal {
|
|
427
|
+
type: "refusal";
|
|
428
|
+
}
|
|
429
|
+
/** One answer, keyed by the question's name. */
|
|
430
|
+
export type AIJudgeAnswer = AIJudgeNoulAnswer | AIJudgeChoiceAnswer | AIJudgeScoreAnswer | AIJudgeBoxAnswer | AIJudgeRefusal;
|
|
431
|
+
/** The answer a question of this shape gets back — or a refusal. */
|
|
432
|
+
export type AIJudgeAnswerFor<Q> = (Q extends {
|
|
433
|
+
type: "noul";
|
|
434
|
+
} ? AIJudgeNoulAnswer : Q extends {
|
|
435
|
+
type: "choice";
|
|
436
|
+
criteria: infer C;
|
|
437
|
+
} ? AIJudgeChoiceAnswer<Extract<keyof C, string>> : Q extends {
|
|
438
|
+
type: "score";
|
|
439
|
+
criteria: readonly (infer L)[];
|
|
440
|
+
} ? AIJudgeScoreAnswer<L> : Q extends {
|
|
441
|
+
type: "box";
|
|
442
|
+
} ? AIJudgeBoxAnswer : AIJudgeAnswer) | AIJudgeRefusal;
|
|
443
|
+
/**
|
|
444
|
+
* `env.ai.judge`'s answer. Given the questions' type (what `judge` infers),
|
|
445
|
+
* each answer is typed by its question: a choice's `choice` is the union of
|
|
446
|
+
* its option names. Given a string union of names, every answer is the
|
|
447
|
+
* untyped `AIJudgeAnswer`, as before.
|
|
448
|
+
*/
|
|
449
|
+
export interface AIJudgeResult<Q extends string | AIJudgeQuestions = string> {
|
|
450
|
+
answers: Q extends string ? Record<Q, AIJudgeAnswer> : {
|
|
451
|
+
[K in keyof Q]: AIJudgeAnswerFor<Q[K]>;
|
|
452
|
+
};
|
|
453
|
+
model: string;
|
|
454
|
+
usage: {
|
|
455
|
+
inputTokens: number;
|
|
456
|
+
};
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* One media input. `data` is the file: an ArrayBuffer, a typed array, base64,
|
|
460
|
+
* or a base64 `data:` URL (whose type stands in for `mediaType`). Which media
|
|
461
|
+
* types and how many a model takes is its row's (`env.ai.models()`: `media`).
|
|
462
|
+
*/
|
|
463
|
+
export interface AIJudgeAsset {
|
|
464
|
+
data: ArrayBuffer | ArrayBufferView | string;
|
|
465
|
+
mediaType?: string;
|
|
466
|
+
}
|
|
467
|
+
export interface AIJudgeOptions {
|
|
468
|
+
/**
|
|
469
|
+
* System One's assets map, name → file. On a model whose `mediaMode` is
|
|
470
|
+
* `named` (Jev), the name is a reference string you write into the state
|
|
471
|
+
* or a question where the model should see the file, and an asset nothing
|
|
472
|
+
* refers to is refused. On a `positional` model (Clef), the model sees the
|
|
473
|
+
* files in the order written, before the state, and never their names — so
|
|
474
|
+
* do not use names that look like integers, which JavaScript orders first.
|
|
475
|
+
*/
|
|
476
|
+
assets?: {
|
|
477
|
+
readonly [name: string]: AIJudgeAsset;
|
|
478
|
+
};
|
|
479
|
+
metadata?: AICallMetadata;
|
|
480
|
+
}
|
|
481
|
+
/** A decision model's limits for one media family. */
|
|
482
|
+
export interface AIDecisionMediaLimit {
|
|
483
|
+
kind: "image" | "audio" | "video";
|
|
484
|
+
/** Every accepted media type, e.g. `image/png`. */
|
|
485
|
+
types: string[];
|
|
486
|
+
maxCount: number;
|
|
487
|
+
/** One item, decoded. */
|
|
488
|
+
maxBytes: number;
|
|
489
|
+
/** The most input tokens one item can bill. */
|
|
490
|
+
maxTokens: number;
|
|
491
|
+
}
|
|
492
|
+
export type AIModelLane = "frontier" | "value";
|
|
493
|
+
interface AIModelBase {
|
|
494
|
+
id: string;
|
|
495
|
+
lane: AIModelLane;
|
|
496
|
+
display: string;
|
|
497
|
+
vendor: string;
|
|
498
|
+
contextTokens: number;
|
|
499
|
+
maxInputTokens: number;
|
|
500
|
+
maxOutputTokens: number;
|
|
501
|
+
frontier: boolean;
|
|
502
|
+
}
|
|
503
|
+
export interface AIChatModel extends AIModelBase {
|
|
504
|
+
kind: "chat";
|
|
505
|
+
effortLevels?: AIReasoningEffort[];
|
|
506
|
+
/** Present as `true` only when this model accepts `responseFormat`. */
|
|
507
|
+
structuredOutput?: true;
|
|
508
|
+
/** Every `cache.ttl` this model accepts; present only when it takes `cache` at all. */
|
|
509
|
+
cacheTTLs?: string[];
|
|
510
|
+
dimensions?: never;
|
|
511
|
+
dimensionOptions?: never;
|
|
512
|
+
}
|
|
513
|
+
export interface AIEmbeddingModel extends AIModelBase {
|
|
514
|
+
kind: "embedding";
|
|
515
|
+
dimensions: number;
|
|
516
|
+
dimensionOptions?: number[];
|
|
517
|
+
effortLevels?: never;
|
|
518
|
+
structuredOutput?: never;
|
|
519
|
+
}
|
|
520
|
+
export interface AIDecisionModel extends AIModelBase {
|
|
521
|
+
kind: "decision";
|
|
522
|
+
maxQuestions: number;
|
|
523
|
+
maxChoices: number;
|
|
524
|
+
maxScoreLevels: number;
|
|
525
|
+
/** Every question type this model takes; any other is `400 unsupported_question_type`. */
|
|
526
|
+
questionTypes?: Array<AIJudgeQuestion["type"]>;
|
|
527
|
+
/** The state's own ceiling, where it is below the context. */
|
|
528
|
+
maxStateTokens?: number;
|
|
529
|
+
/** Absent: text only, and `options.assets` is `400 media_unsupported`. */
|
|
530
|
+
mediaMode?: "named" | "positional";
|
|
531
|
+
media?: AIDecisionMediaLimit[];
|
|
532
|
+
/** Every media item of one call together, decoded. */
|
|
533
|
+
maxMediaBytes?: number;
|
|
534
|
+
effortLevels?: never;
|
|
535
|
+
structuredOutput?: never;
|
|
536
|
+
dimensions?: never;
|
|
537
|
+
dimensionOptions?: never;
|
|
538
|
+
}
|
|
539
|
+
export type AIModel = AIChatModel | AIEmbeddingModel | AIDecisionModel;
|
|
540
|
+
/** A capability `env.ai.features` names. Open-ended: a newer runtime may list more. */
|
|
541
|
+
export type AIFeature = "contentParts" | "toolModeReturn" | (string & {});
|
|
542
|
+
/** The public `env.ai` binding. */
|
|
543
|
+
export interface RunlotAI {
|
|
544
|
+
/**
|
|
545
|
+
* What this runtime takes beyond string messages and the `execute` loop:
|
|
546
|
+
* `"contentParts"` (message content as parts) and `"toolModeReturn"`
|
|
547
|
+
* (`toolMode: "return"`). Absent on a runtime older than both — one that
|
|
548
|
+
* would turn a parts array into text — so a library tests it before
|
|
549
|
+
* sending either.
|
|
550
|
+
*/
|
|
551
|
+
readonly features?: readonly AIFeature[];
|
|
552
|
+
run(model: string, options: AIReturnRunOptions & {
|
|
553
|
+
stream: true;
|
|
554
|
+
}): Promise<AIStream>;
|
|
555
|
+
run(model: string, options: AIReturnRunOptions & {
|
|
556
|
+
stream?: false;
|
|
557
|
+
}): Promise<AIReturnRunResult>;
|
|
558
|
+
run(model: string, options: AIReturnRunOptions): Promise<AIReturnRunResult | AIStream>;
|
|
559
|
+
run(model: string, options: AIRunOptions & {
|
|
560
|
+
stream: true;
|
|
561
|
+
}): Promise<AIStream>;
|
|
562
|
+
run(model: string, options: AIRunOptions & {
|
|
563
|
+
stream?: false;
|
|
564
|
+
}): Promise<AIRunResult>;
|
|
565
|
+
run(model: string, options: AIRunOptions): Promise<AIRunResult | AIStream>;
|
|
566
|
+
embed(model: string, input: string | readonly string[], options?: AIEmbedOptions): Promise<AIEmbedResult>;
|
|
567
|
+
/**
|
|
568
|
+
* A decision model's answers, one per question, typed by the question:
|
|
569
|
+
* `const r = await env.ai.judge(m, ticket, { route: choice("…", { billing: "…", bug: "…" }) })`
|
|
570
|
+
* gives `r.answers.route` whose `choice` is `"billing" | "bug"` (or a refusal).
|
|
571
|
+
*/
|
|
572
|
+
judge<const Q extends AIJudgeQuestions>(model: string, state: string | object, questions: Q, options?: AIJudgeOptions): Promise<AIJudgeResult<Q>>;
|
|
573
|
+
models(): Promise<AIModel[]>;
|
|
574
|
+
}
|
|
575
|
+
export {};
|
|
576
|
+
//# sourceMappingURL=ai.d.ts.map
|
package/dist/ai.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai.d.ts","sourceRoot":"","sources":["../src/ai.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,MAAM,MAAM,YAAY,G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