@cubicecho/agent-core 2.10.0 → 2.11.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 +15 -0
- package/dist/index.d.ts +1 -1
- package/dist/side-task.d.ts +17 -4
- package/dist/side-task.js +2 -2
- package/llms.txt +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -202,6 +202,21 @@ mean every property required and `additionalProperties: false`; a looser schema
|
|
|
202
202
|
`preselect` is its first user, answering `{ tools: [...] }`, and `preselection` still takes the
|
|
203
203
|
bare array an older prompt produced.
|
|
204
204
|
|
|
205
|
+
### Showing a side task an image
|
|
206
|
+
|
|
207
|
+
`ask` and `askJson` take the user turn as a string or as content parts, because an image reaches an
|
|
208
|
+
OpenAI-compatible server only as an `image_url` part beside the text. The parts are sent as given
|
|
209
|
+
and nothing here checks that the model can see: whether a text-only model rejects the image or
|
|
210
|
+
answers without it is up to the server, so pick a vision model.
|
|
211
|
+
|
|
212
|
+
```ts
|
|
213
|
+
const page: SideTaskInput = [
|
|
214
|
+
{ type: "text", text: "Transcribe this page." },
|
|
215
|
+
{ type: "image_url", image_url: { url: `data:image/png;base64,${png}` } },
|
|
216
|
+
];
|
|
217
|
+
const text = await ask(config, visionModel, "You are an OCR engine.", page);
|
|
218
|
+
```
|
|
219
|
+
|
|
205
220
|
## Sizing a request before sending it
|
|
206
221
|
|
|
207
222
|
`runTurn` will refuse a request that cannot fit rather than spending a round trip finding out:
|
package/dist/index.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ export { resetAll } from "./reset.ts";
|
|
|
22
22
|
export { backoffMs, ContextOverflow, compact, EndpointSilent, isModelLoading, isOverflow, isTransient, LOADING_POLL_MS, LOADING_TIMEOUT_MS, messageTokens, requestTokens, SMALLEST_LIKELY_WINDOW, sleep, } from "./retry.ts";
|
|
23
23
|
export { type RunTurnOptions, runTurn } from "./run-turn.ts";
|
|
24
24
|
export { isGrammarError, relaxTools, sanitizeTools } from "./schema-compat.ts";
|
|
25
|
-
export { type AskJsonOptions, ask, askJson, clean, listLines, parseJson, resetHints, type SideTaskOptions, tryAsk, } from "./side-task.ts";
|
|
25
|
+
export { type AskJsonOptions, ask, askJson, clean, listLines, parseJson, resetHints, type SideTaskInput, type SideTaskOptions, tryAsk, } from "./side-task.ts";
|
|
26
26
|
export { CAPABILITY_SNAPSHOT_VERSION, type CapabilitySnapshot, type EndpointSnapshot, exportCapabilities, importCapabilities, type ModelSnapshot, } from "./snapshot.ts";
|
|
27
27
|
export { type Produced, type StreamTurnOptions, streamTurn, type Turn, type TurnUsage, } from "./stream.ts";
|
|
28
28
|
export { ALL_FENCES, DEFAULT_FENCES, type Fence, FenceSplitter, type FenceSplitterOptions, type Split, stripThinking, THINK_FENCE, } from "./thinking.ts";
|
package/dist/side-task.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import OpenAI from "openai";
|
|
1
2
|
import type { Endpoint } from "./config.ts";
|
|
2
3
|
/** An (endpoint, model) pair as `noHints` holds it: `[endpointId, model]`, stringified. */
|
|
3
4
|
export declare const hintKey: (endpoint: string, model: string) => string;
|
|
@@ -5,6 +6,18 @@ export declare const hintKey: (endpoint: string, model: string) => string;
|
|
|
5
6
|
export declare const refusedHints: () => Set<string>;
|
|
6
7
|
/** Test seam, alongside `resetClients` and `resetAll`: forget which models refused the hints. */
|
|
7
8
|
export declare const resetHints: () => void;
|
|
9
|
+
/**
|
|
10
|
+
* The input a side task applies its instruction to: text, or the content parts a vision model
|
|
11
|
+
* reads.
|
|
12
|
+
*
|
|
13
|
+
* A string is the ordinary case and stays the cheapest thing to write. The array is what an
|
|
14
|
+
* image needs, because a page, a screenshot or a photo reaches an OpenAI-compatible server only
|
|
15
|
+
* as an `image_url` part alongside the text — there is no other spelling for it, and a caller
|
|
16
|
+
* with one otherwise has to leave this module and build the request itself. Nothing here reads
|
|
17
|
+
* the parts: they are handed to the SDK as given, and whether a model that cannot see rejects
|
|
18
|
+
* the image or answers without it is the server's decision, not this module's.
|
|
19
|
+
*/
|
|
20
|
+
export type SideTaskInput = string | OpenAI.ChatCompletionContentPart[];
|
|
8
21
|
/** What a side task may be given. All optional — one given none of them still runs. */
|
|
9
22
|
export interface SideTaskOptions {
|
|
10
23
|
/** Ceiling on the reply, default 512. These answers are meant to be short. */
|
|
@@ -33,10 +46,10 @@ export interface SideTaskOptions {
|
|
|
33
46
|
* @param config Where to send it and how long to wait.
|
|
34
47
|
* @param model The model to ask, usually smaller than the one running the work.
|
|
35
48
|
* @param system The instruction.
|
|
36
|
-
* @param user The input it applies to.
|
|
49
|
+
* @param user The input it applies to. Content parts where the model is being shown an image.
|
|
37
50
|
* @param options Reply ceiling, temperature, cancellation, notices.
|
|
38
51
|
*/
|
|
39
|
-
export declare function ask(config: Endpoint, model: string, system: string, user:
|
|
52
|
+
export declare function ask(config: Endpoint, model: string, system: string, user: SideTaskInput, options?: SideTaskOptions): Promise<string>;
|
|
40
53
|
/** What `askJson` takes besides a side task's options. */
|
|
41
54
|
export interface AskJsonOptions extends SideTaskOptions {
|
|
42
55
|
/** What the schema is called in the request, `answer` by default. Letters, digits, `_` and `-`. */
|
|
@@ -62,11 +75,11 @@ export interface AskJsonOptions extends SideTaskOptions {
|
|
|
62
75
|
* @param config Where to send it and how long to wait.
|
|
63
76
|
* @param model The model to ask.
|
|
64
77
|
* @param system The instruction. The schema is appended to it.
|
|
65
|
-
* @param user The input it applies to.
|
|
78
|
+
* @param user The input it applies to. Content parts where the model is being shown an image.
|
|
66
79
|
* @param schema The JSON Schema of the answer. Its root is held to an object, as a tool's is.
|
|
67
80
|
* @param options A side task's options, plus the schema's `name` and whether it is `strict`.
|
|
68
81
|
*/
|
|
69
|
-
export declare function askJson<T>(config: Endpoint, model: string, system: string, user:
|
|
82
|
+
export declare function askJson<T>(config: Endpoint, model: string, system: string, user: SideTaskInput, schema: Record<string, unknown>, { name, strict, ...options }?: AskJsonOptions): Promise<T | undefined>;
|
|
70
83
|
/**
|
|
71
84
|
* A side task is never worth failing the work it supports. Callers that can carry on without
|
|
72
85
|
* an answer use this and get `undefined` instead of an exception.
|
package/dist/side-task.js
CHANGED
|
@@ -71,7 +71,7 @@ function rejectedTheRequest(error) {
|
|
|
71
71
|
* @param config Where to send it and how long to wait.
|
|
72
72
|
* @param model The model to ask, usually smaller than the one running the work.
|
|
73
73
|
* @param system The instruction.
|
|
74
|
-
* @param user The input it applies to.
|
|
74
|
+
* @param user The input it applies to. Content parts where the model is being shown an image.
|
|
75
75
|
* @param options Reply ceiling, temperature, cancellation, notices.
|
|
76
76
|
*/
|
|
77
77
|
export function ask(config, model, system, user, options = {}) {
|
|
@@ -168,7 +168,7 @@ async function complete(config, model, system, user, { maxTokens = 512, temperat
|
|
|
168
168
|
* @param config Where to send it and how long to wait.
|
|
169
169
|
* @param model The model to ask.
|
|
170
170
|
* @param system The instruction. The schema is appended to it.
|
|
171
|
-
* @param user The input it applies to.
|
|
171
|
+
* @param user The input it applies to. Content parts where the model is being shown an image.
|
|
172
172
|
* @param schema The JSON Schema of the answer. Its root is held to an object, as a tool's is.
|
|
173
173
|
* @param options A side task's options, plus the schema's `name` and whether it is `strict`.
|
|
174
174
|
*/
|
package/llms.txt
CHANGED
|
@@ -182,6 +182,7 @@ One-shot calls that support a run without being one: picking tools, naming a ses
|
|
|
182
182
|
- `listLines` — A list-shaped reply, one item per line, cleaned of the bullets and quotes models decorate them with.
|
|
183
183
|
- `parseJson` — Models are asked for JSON and often answer with prose around it, or a fenced block.
|
|
184
184
|
- `resetHints` — Test seam, alongside `resetClients` and `resetAll`: forget which models refused the hints.
|
|
185
|
+
- `SideTaskInput` (type) — The input a side task applies its instruction to: text, or the content parts a vision model reads.
|
|
185
186
|
- `SideTaskOptions` (type) — What a side task may be given.
|
|
186
187
|
- `tryAsk` — A side task is never worth failing the work it supports.
|
|
187
188
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cubicecho/agent-core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.11.0",
|
|
4
4
|
"description": "The endpoint-agnostic half of an OpenAI-compatible agent loop: tool-schema compatibility, on-demand tool loading, one-shot side tasks, run events, and a pooled client.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"openai",
|