@owlmeans/llm-common 0.2.0-alpha.0 → 0.2.0-alpha.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/README.md +9 -3
- package/agent-meta/manifest.json +2 -2
- package/agent-meta/skills/llm-common/SKILL.md +6 -3
- package/build/index.d.ts +1 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +1 -0
- package/build/index.js.map +1 -1
- package/build/media/consts.d.ts +30 -0
- package/build/media/consts.d.ts.map +1 -0
- package/build/media/consts.js +34 -0
- package/build/media/consts.js.map +1 -0
- package/build/media/index.d.ts +3 -0
- package/build/media/index.d.ts.map +1 -0
- package/build/media/index.js +2 -0
- package/build/media/index.js.map +1 -0
- package/build/media/types.d.ts +58 -0
- package/build/media/types.d.ts.map +1 -0
- package/build/media/types.js +2 -0
- package/build/media/types.js.map +1 -0
- package/build/types.d.ts +4 -0
- package/build/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +1 -0
- package/src/media/consts.ts +37 -0
- package/src/media/index.ts +2 -0
- package/src/media/types.ts +63 -0
- package/src/types.ts +4 -0
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ extends these; `@owlmeans/llm` implements against them.
|
|
|
20
20
|
## Installation
|
|
21
21
|
|
|
22
22
|
```bash
|
|
23
|
-
bun add @owlmeans/llm-common@^0.2.0-alpha.
|
|
23
|
+
bun add @owlmeans/llm-common@^0.2.0-alpha.1
|
|
24
24
|
```
|
|
25
25
|
|
|
26
26
|
## Usage
|
|
@@ -69,13 +69,19 @@ export interface MyExecutionState extends ExecutionState {
|
|
|
69
69
|
| `StructuredMode` | `Native` (provider JSON-schema mode) vs `Tool` (forced tool call). |
|
|
70
70
|
| `SpectatorContentType` | `Text` · `Json` · `ToolCall`. |
|
|
71
71
|
| `SPECTATOR_GENERAL` | Default entry kind for consumers that do not classify calls. |
|
|
72
|
+
| `MediaKind` | `Image` · `Document` · `Audio` · `Video` · `File` — what a binary content part is. |
|
|
73
|
+
| `MEDIA_IMAGE_TYPES`, `MEDIA_DOCUMENT_TYPES` | The image types (png, jpeg, gif, webp) and document type (PDF) every built-in provider accepts. |
|
|
74
|
+
| `MEDIA_LIMITS` | Per-part limits in raw bytes and pixels: image 7 500 000 bytes and 8000 px, PDF 50 000 000 bytes. |
|
|
72
75
|
|
|
73
76
|
### Types
|
|
74
77
|
|
|
75
78
|
| Export | Description |
|
|
76
79
|
|--------|-------------|
|
|
77
80
|
| `ModelRole` | Open `string`. Declare your own enum; its values stay assignable. |
|
|
78
|
-
| `ModelConfigPatch` | JSON-safe subset of a runtime model config — never credentials. |
|
|
81
|
+
| `ModelConfigPatch` | JSON-safe subset of a runtime model config — never credentials; includes the `vision` / `documents` capability flags. |
|
|
82
|
+
| `ModelCapabilities`, `RungCapabilities`, `MediaNeeds` | What a resolved model accepts, rung by rung, and what a call's content needs. |
|
|
83
|
+
| `MediaPlaceholder` | `{ type, mime, bytes, sha256 }` — what a trace stores in place of a binary part. |
|
|
84
|
+
| `MediaLimits`, `MediaRequestLimits` | Per-part and per-request media limit shapes. |
|
|
79
85
|
| `ModelConfigOverride` | `string` (a config alias) or a `ModelConfigPatch`. |
|
|
80
86
|
| `ModelPolicy` | `{ effort, roleOverrides?, modelOverrides? }` — inherited by every refinement. |
|
|
81
87
|
| `ExecutionState` | `{ level, purpose, policy }` — the persistable core. |
|
|
@@ -96,7 +102,7 @@ This package ships embedded agent skills under `agent-meta/`. After installing y
|
|
|
96
102
|
your project's skill store (`.agents/skills/`):
|
|
97
103
|
|
|
98
104
|
```sh
|
|
99
|
-
npx @owlmeans/agent-skills@^0.2.0-alpha.
|
|
105
|
+
npx @owlmeans/agent-skills@^0.2.0-alpha.2
|
|
100
106
|
```
|
|
101
107
|
|
|
102
108
|
The embedded files are version-matched to this package release. Do not edit them
|
package/agent-meta/manifest.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 3,
|
|
3
3
|
"package": "@owlmeans/llm-common",
|
|
4
|
-
"version": "0.2.0-alpha.
|
|
5
|
-
"generatedAt": "2026-11-
|
|
4
|
+
"version": "0.2.0-alpha.1",
|
|
5
|
+
"generatedAt": "2026-11-12T14:18:05.463Z",
|
|
6
6
|
"canonicalRepo": "https://github.com/owlmeans/common",
|
|
7
7
|
"entries": [
|
|
8
8
|
{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: llm-common
|
|
3
|
-
description: How to use @owlmeans/llm-common — runtime-free serializable contracts for LLM inference and execution (ModelProvider, ExecutionEffort/Level, ModelPolicy, PromptPolicy, SkillDefinition, ExecutionState and its cumulative-results view, PromptBlock/PromptRegion, PromptFocus, PackagePurpose, CacheTtlPolicy, spectator records, NullCapture, LlmFileProvider). Auto-invoked when importing those contracts or extending them for a domain.
|
|
3
|
+
description: How to use @owlmeans/llm-common — runtime-free serializable contracts for LLM inference and execution (ModelProvider, ExecutionEffort/Level, ModelPolicy, PromptPolicy, SkillDefinition, ExecutionState and its cumulative-results view, PromptBlock/PromptRegion, PromptFocus, PackagePurpose, CacheTtlPolicy, spectator records, NullCapture, LlmFileProvider, model capabilities and media limits). Auto-invoked when importing those contracts or extending them for a domain.
|
|
4
4
|
user-invocable: false
|
|
5
5
|
---
|
|
6
6
|
<!-- AUTO-GENERATED — do not edit. Regenerate via sync-agent-meta. -->
|
|
@@ -8,7 +8,7 @@ user-invocable: false
|
|
|
8
8
|
# @owlmeans/llm-common
|
|
9
9
|
|
|
10
10
|
**Layer:** Core
|
|
11
|
-
**Install:** `"@owlmeans/llm-common": "^0.2.0-alpha.
|
|
11
|
+
**Install:** `"@owlmeans/llm-common": "^0.2.0-alpha.1"` in `dependencies`
|
|
12
12
|
|
|
13
13
|
The contracts half of the LLM stack. **No `@langchain/*` runtime dependency** — importable
|
|
14
14
|
from a browser bundle, a queue worker, or any package that must not pull an inference SDK.
|
|
@@ -26,7 +26,10 @@ The dependency direction is one-way: a domain contracts package extends these;
|
|
|
26
26
|
| `StructuredMode` | `Native` (provider JSON-schema mode) vs `Tool` (forced tool call). |
|
|
27
27
|
| `SpectatorContentType`, `SPECTATOR_GENERAL` | Observability record enums/defaults. |
|
|
28
28
|
| `ModelRole` | Open `string` — declare your own enum, its values stay assignable. |
|
|
29
|
-
| `ModelConfigPatch` / `ModelConfigOverride` | The JSON-safe config subset; never credentials. Carries the model-capability fields (`contextWindow`, `maxOutput`, `combinedWindow`) alongside the budget ones — see the `llm` skill for what each means. |
|
|
29
|
+
| `ModelConfigPatch` / `ModelConfigOverride` | The JSON-safe config subset; never credentials. Carries the model-capability fields (`contextWindow`, `maxOutput`, `combinedWindow`, `vision`, `documents`) alongside the budget ones — see the `llm` skill for what each means. |
|
|
30
|
+
| `ModelCapabilities`, `RungCapabilities`, `MediaNeeds` | What the model a role resolved to accepts, rung by rung (`vision` = some rung takes images — a media call runs only on those), and what a call's content needs. Answered by `@owlmeans/llm` (`media` part). |
|
|
31
|
+
| `MediaKind`, `MediaPlaceholder` | What a binary part is, and the `{ type, mime, bytes, sha256 }` a trace stores instead of its payload. |
|
|
32
|
+
| `MEDIA_IMAGE_TYPES`, `MEDIA_DOCUMENT_TYPES`, `MEDIA_LIMITS`, `MediaLimits`, `MediaRequestLimits` | png/jpeg/gif/webp and PDF; per-part limits in raw bytes and pixels — the strictest the built-in providers document (image 7 500 000 bytes and 8000 px, PDF 50 000 000 bytes), so an upload screen checks `file.size` against the same numbers; per-request limit shape. |
|
|
30
33
|
| `ModelPolicy` | `{ effort, roleOverrides?, modelOverrides?, utilityRole? }` — inherited by every refinement. |
|
|
31
34
|
| `UTILITY_ROLE` | `'utility'` — the conventional cheap tier for side calls (a relevance pick, a classification). `ModelPolicy.utilityRole` points it at another alias; `ExecutionService.utility` resolves it. |
|
|
32
35
|
| `ExecutionState` / `TaskExecutionState` | The persistable core (`level`/`purpose`/`policy`, optional `prompt`/`inquiry`/`results`, plus `phase`/`completed`/`cursor`/`data`). |
|
package/build/index.d.ts
CHANGED
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAA;AAC3B,mBAAmB,YAAY,CAAA;AAC/B,mBAAmB,sBAAsB,CAAA;AACzC,mBAAmB,kBAAkB,CAAA;AACrC,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA;AACnC,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAA;AAC3B,mBAAmB,YAAY,CAAA;AAC/B,mBAAmB,sBAAsB,CAAA;AACzC,mBAAmB,kBAAkB,CAAA;AACrC,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA;AACnC,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,cAAc,kBAAkB,CAAA"}
|
package/build/index.js
CHANGED
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAA;AAI3B,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA;AACnC,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAA;AAI3B,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA;AACnC,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,cAAc,kBAAkB,CAAA"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { MediaLimits } from './types.js';
|
|
2
|
+
/** What a binary content part carries — the `type` of a trace placeholder. */
|
|
3
|
+
export declare enum MediaKind {
|
|
4
|
+
Image = "image",
|
|
5
|
+
/** A PDF (or another document a provider reads as pages). */
|
|
6
|
+
Document = "document",
|
|
7
|
+
Audio = "audio",
|
|
8
|
+
Video = "video",
|
|
9
|
+
/** Any other binary file. */
|
|
10
|
+
File = "file"
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The image types every built-in provider plugin accepts (Anthropic and OpenAI document the same
|
|
14
|
+
* four; an animated GIF is read by its first frame). Anything else is refused before a request.
|
|
15
|
+
*/
|
|
16
|
+
export declare const MEDIA_IMAGE_TYPES: readonly string[];
|
|
17
|
+
/** The document types a model reads as pages. */
|
|
18
|
+
export declare const MEDIA_DOCUMENT_TYPES: readonly string[];
|
|
19
|
+
/**
|
|
20
|
+
* Per-part limits — the strictest documented by the built-in providers, so a part that passes is
|
|
21
|
+
* accepted by every one of them:
|
|
22
|
+
*
|
|
23
|
+
* - an image of at most 10 MB base64-encoded (Anthropic API; OpenAI states no per-image size), which
|
|
24
|
+
* is 7 500 000 raw bytes, and at most 8000 px on either side (Anthropic);
|
|
25
|
+
* - a PDF under 50 MB (OpenAI, per file and per request; Anthropic allows a 128 MB request).
|
|
26
|
+
*
|
|
27
|
+
* Checked on the raw bytes, so an upload screen can test `file.size` against the same numbers.
|
|
28
|
+
*/
|
|
29
|
+
export declare const MEDIA_LIMITS: Readonly<MediaLimits>;
|
|
30
|
+
//# sourceMappingURL=consts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../../src/media/consts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAE7C,8EAA8E;AAC9E,oBAAY,SAAS;IACnB,KAAK,UAAU;IACf,6DAA6D;IAC7D,QAAQ,aAAa;IACrB,KAAK,UAAU;IACf,KAAK,UAAU;IACf,6BAA6B;IAC7B,IAAI,SAAS;CACd;AAED;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,SAAS,MAAM,EAA0E,CAAA;AAEzH,iDAAiD;AACjD,eAAO,MAAM,oBAAoB,EAAE,SAAS,MAAM,EAAuC,CAAA;AAEzF;;;;;;;;;GASG;AACH,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,WAAW,CAI7C,CAAA"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/** What a binary content part carries — the `type` of a trace placeholder. */
|
|
2
|
+
export var MediaKind;
|
|
3
|
+
(function (MediaKind) {
|
|
4
|
+
MediaKind["Image"] = "image";
|
|
5
|
+
/** A PDF (or another document a provider reads as pages). */
|
|
6
|
+
MediaKind["Document"] = "document";
|
|
7
|
+
MediaKind["Audio"] = "audio";
|
|
8
|
+
MediaKind["Video"] = "video";
|
|
9
|
+
/** Any other binary file. */
|
|
10
|
+
MediaKind["File"] = "file";
|
|
11
|
+
})(MediaKind || (MediaKind = {}));
|
|
12
|
+
/**
|
|
13
|
+
* The image types every built-in provider plugin accepts (Anthropic and OpenAI document the same
|
|
14
|
+
* four; an animated GIF is read by its first frame). Anything else is refused before a request.
|
|
15
|
+
*/
|
|
16
|
+
export const MEDIA_IMAGE_TYPES = Object.freeze(['image/png', 'image/jpeg', 'image/gif', 'image/webp']);
|
|
17
|
+
/** The document types a model reads as pages. */
|
|
18
|
+
export const MEDIA_DOCUMENT_TYPES = Object.freeze(['application/pdf']);
|
|
19
|
+
/**
|
|
20
|
+
* Per-part limits — the strictest documented by the built-in providers, so a part that passes is
|
|
21
|
+
* accepted by every one of them:
|
|
22
|
+
*
|
|
23
|
+
* - an image of at most 10 MB base64-encoded (Anthropic API; OpenAI states no per-image size), which
|
|
24
|
+
* is 7 500 000 raw bytes, and at most 8000 px on either side (Anthropic);
|
|
25
|
+
* - a PDF under 50 MB (OpenAI, per file and per request; Anthropic allows a 128 MB request).
|
|
26
|
+
*
|
|
27
|
+
* Checked on the raw bytes, so an upload screen can test `file.size` against the same numbers.
|
|
28
|
+
*/
|
|
29
|
+
export const MEDIA_LIMITS = Object.freeze({
|
|
30
|
+
imageBytes: 7_500_000,
|
|
31
|
+
imageSide: 8000,
|
|
32
|
+
documentBytes: 50_000_000,
|
|
33
|
+
});
|
|
34
|
+
//# sourceMappingURL=consts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consts.js","sourceRoot":"","sources":["../../src/media/consts.ts"],"names":[],"mappings":"AAEA,8EAA8E;AAC9E,MAAM,CAAN,IAAY,SAQX;AARD,WAAY,SAAS;IACnB,4BAAe,CAAA;IACf,6DAA6D;IAC7D,kCAAqB,CAAA;IACrB,4BAAe,CAAA;IACf,4BAAe,CAAA;IACf,6BAA6B;IAC7B,0BAAa,CAAA;AACf,CAAC,EARW,SAAS,KAAT,SAAS,QAQpB;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAsB,MAAM,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,CAAC,CAAC,CAAA;AAEzH,iDAAiD;AACjD,MAAM,CAAC,MAAM,oBAAoB,GAAsB,MAAM,CAAC,MAAM,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAA;AAEzF;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,YAAY,GAA0B,MAAM,CAAC,MAAM,CAAC;IAC/D,UAAU,EAAE,SAAS;IACrB,SAAS,EAAE,IAAI;IACf,aAAa,EAAE,UAAU;CAC1B,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/media/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,mBAAmB,YAAY,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/media/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { MediaKind } from './consts.js';
|
|
2
|
+
/** Per-part media limits, in raw bytes and pixels — see `MEDIA_LIMITS`. */
|
|
3
|
+
export interface MediaLimits {
|
|
4
|
+
/** Largest image, raw bytes. */
|
|
5
|
+
imageBytes: number;
|
|
6
|
+
/** Longest side of an image, px. */
|
|
7
|
+
imageSide: number;
|
|
8
|
+
/** Largest document, raw bytes. */
|
|
9
|
+
documentBytes: number;
|
|
10
|
+
}
|
|
11
|
+
/** Per-request media limits one provider documents. An omitted field is not limited. */
|
|
12
|
+
export interface MediaRequestLimits {
|
|
13
|
+
/** Image parts in one request, earlier turns included. */
|
|
14
|
+
images?: number;
|
|
15
|
+
/** Raw bytes of every binary part of one request together. */
|
|
16
|
+
mediaBytes?: number;
|
|
17
|
+
/** Raw bytes of every document of one request together. */
|
|
18
|
+
documentBytes?: number;
|
|
19
|
+
}
|
|
20
|
+
/** What a call's content needs from the model that answers it. */
|
|
21
|
+
export interface MediaNeeds {
|
|
22
|
+
/** The content carries an image. */
|
|
23
|
+
vision: boolean;
|
|
24
|
+
/** The content carries a document. */
|
|
25
|
+
documents: boolean;
|
|
26
|
+
}
|
|
27
|
+
/** What one rung of a role's escalation ladder accepts. */
|
|
28
|
+
export interface RungCapabilities {
|
|
29
|
+
/** The rung's model id, when its config names one. */
|
|
30
|
+
model?: string;
|
|
31
|
+
provider?: string;
|
|
32
|
+
vision: boolean;
|
|
33
|
+
documents: boolean;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* What the model a role resolved to accepts. A call carrying images (documents) is sent only to the
|
|
37
|
+
* rungs that accept them — a fallback without the capability never receives media — so `vision` is
|
|
38
|
+
* true when at least one rung can answer such a call; `rungs[0]` is the primary.
|
|
39
|
+
*/
|
|
40
|
+
export interface ModelCapabilities {
|
|
41
|
+
vision: boolean;
|
|
42
|
+
documents: boolean;
|
|
43
|
+
/** Primary first, then every fallback. */
|
|
44
|
+
rungs: RungCapabilities[];
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* What a trace stores in place of a binary content part: never the payload, only enough to tell
|
|
48
|
+
* which file it was.
|
|
49
|
+
*/
|
|
50
|
+
export interface MediaPlaceholder {
|
|
51
|
+
type: MediaKind;
|
|
52
|
+
mime: string;
|
|
53
|
+
/** Size of the decoded payload. */
|
|
54
|
+
bytes: number;
|
|
55
|
+
/** Hex SHA-256 of the decoded payload. */
|
|
56
|
+
sha256: string;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/media/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAE5C,2EAA2E;AAC3E,MAAM,WAAW,WAAW;IAC1B,gCAAgC;IAChC,UAAU,EAAE,MAAM,CAAA;IAClB,oCAAoC;IACpC,SAAS,EAAE,MAAM,CAAA;IACjB,mCAAmC;IACnC,aAAa,EAAE,MAAM,CAAA;CACtB;AAED,wFAAwF;AACxF,MAAM,WAAW,kBAAkB;IACjC,0DAA0D;IAC1D,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,8DAA8D;IAC9D,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,2DAA2D;IAC3D,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB;AAED,kEAAkE;AAClE,MAAM,WAAW,UAAU;IACzB,oCAAoC;IACpC,MAAM,EAAE,OAAO,CAAA;IACf,sCAAsC;IACtC,SAAS,EAAE,OAAO,CAAA;CACnB;AAED,2DAA2D;AAC3D,MAAM,WAAW,gBAAgB;IAC/B,sDAAsD;IACtD,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,OAAO,CAAA;IACf,SAAS,EAAE,OAAO,CAAA;CACnB;AAED;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,OAAO,CAAA;IACf,SAAS,EAAE,OAAO,CAAA;IAClB,0CAA0C;IAC1C,KAAK,EAAE,gBAAgB,EAAE,CAAA;CAC1B;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,SAAS,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,mCAAmC;IACnC,KAAK,EAAE,MAAM,CAAA;IACb,0CAA0C;IAC1C,MAAM,EAAE,MAAM,CAAA;CACf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/media/types.ts"],"names":[],"mappings":""}
|
package/build/types.d.ts
CHANGED
|
@@ -39,6 +39,10 @@ export interface ModelConfigPatch {
|
|
|
39
39
|
maxOutput?: number;
|
|
40
40
|
/** The window is shared between input and output rather than input-only. */
|
|
41
41
|
combinedWindow?: boolean;
|
|
42
|
+
/** The model accepts image input. Unset means it does not — a call carrying images skips it. */
|
|
43
|
+
vision?: boolean;
|
|
44
|
+
/** The model accepts PDF documents. Unset means it does not — a call carrying one skips it. */
|
|
45
|
+
documents?: boolean;
|
|
42
46
|
}
|
|
43
47
|
/** A JSON-safe model override: a config alias, or a partial config patch. */
|
|
44
48
|
export type ModelConfigOverride = string | ModelConfigPatch;
|
package/build/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,WAAW,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAC5G,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAE3D;;;;GAIG;AACH,MAAM,WAAW,UAAU;IACzB,yEAAyE;IACzE,IAA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AAE,MAAM,CAAA;QACpB,IAAI,CAAC,EAAE,MAAM,CAAA;KACd,CAAA;IACD,OAAO,EAAE;QACP,QAAQ,EAAE,OAAO,EAAE,CAAA;QACnB,MAAM,CAAC,EAAE;YAAE,QAAQ,EAAE,MAAM,CAAC;YAAC,WAAW,EAAE,OAAO,CAAA;SAAE,CAAA;QACnD,0EAA0E;QAC1E,QAAQ,EAAE,OAAO,CAAA;QACjB,gGAAgG;QAChG,MAAM,CAAC,EAAE,MAAM,CAAA;KAChB,CAAA;IACD,QAAQ,EAAE;QACR,OAAO,EAAE,OAAO,CAAA;QAChB,iBAAiB,CAAC,EAAE,OAAO,CAAA;QAC3B,iBAAiB,CAAC,EAAE,OAAO,CAAA;QAC3B,cAAc,CAAC,EAAE,OAAO,CAAA;QACxB,UAAU,CAAC,EAAE,OAAO,CAAA;KACrB,GAAG,IAAI,CAAA;IACR,WAAW,EAAE;QACX,+FAA+F;QAC/F,YAAY,CAAC,EAAE,MAAM,CAAA;QACrB,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,YAAY,CAAC,EAAE,MAAM,CAAA;QACrB,eAAe,CAAC,EAAE,MAAM,CAAA;QACxB,YAAY,EAAE,OAAO,CAAA;QACrB;;;;WAIG;QACH,YAAY,CAAC,EAAE,OAAO,CAAA;QACtB,WAAW,EAAE,OAAO,CAAA;KACrB,CAAA;CACF"}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { MediaLimits } from './types.js'
|
|
2
|
+
|
|
3
|
+
/** What a binary content part carries — the `type` of a trace placeholder. */
|
|
4
|
+
export enum MediaKind {
|
|
5
|
+
Image = 'image',
|
|
6
|
+
/** A PDF (or another document a provider reads as pages). */
|
|
7
|
+
Document = 'document',
|
|
8
|
+
Audio = 'audio',
|
|
9
|
+
Video = 'video',
|
|
10
|
+
/** Any other binary file. */
|
|
11
|
+
File = 'file',
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The image types every built-in provider plugin accepts (Anthropic and OpenAI document the same
|
|
16
|
+
* four; an animated GIF is read by its first frame). Anything else is refused before a request.
|
|
17
|
+
*/
|
|
18
|
+
export const MEDIA_IMAGE_TYPES: readonly string[] = Object.freeze(['image/png', 'image/jpeg', 'image/gif', 'image/webp'])
|
|
19
|
+
|
|
20
|
+
/** The document types a model reads as pages. */
|
|
21
|
+
export const MEDIA_DOCUMENT_TYPES: readonly string[] = Object.freeze(['application/pdf'])
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Per-part limits — the strictest documented by the built-in providers, so a part that passes is
|
|
25
|
+
* accepted by every one of them:
|
|
26
|
+
*
|
|
27
|
+
* - an image of at most 10 MB base64-encoded (Anthropic API; OpenAI states no per-image size), which
|
|
28
|
+
* is 7 500 000 raw bytes, and at most 8000 px on either side (Anthropic);
|
|
29
|
+
* - a PDF under 50 MB (OpenAI, per file and per request; Anthropic allows a 128 MB request).
|
|
30
|
+
*
|
|
31
|
+
* Checked on the raw bytes, so an upload screen can test `file.size` against the same numbers.
|
|
32
|
+
*/
|
|
33
|
+
export const MEDIA_LIMITS: Readonly<MediaLimits> = Object.freeze({
|
|
34
|
+
imageBytes: 7_500_000,
|
|
35
|
+
imageSide: 8000,
|
|
36
|
+
documentBytes: 50_000_000,
|
|
37
|
+
})
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { MediaKind } from './consts.js'
|
|
2
|
+
|
|
3
|
+
/** Per-part media limits, in raw bytes and pixels — see `MEDIA_LIMITS`. */
|
|
4
|
+
export interface MediaLimits {
|
|
5
|
+
/** Largest image, raw bytes. */
|
|
6
|
+
imageBytes: number
|
|
7
|
+
/** Longest side of an image, px. */
|
|
8
|
+
imageSide: number
|
|
9
|
+
/** Largest document, raw bytes. */
|
|
10
|
+
documentBytes: number
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** Per-request media limits one provider documents. An omitted field is not limited. */
|
|
14
|
+
export interface MediaRequestLimits {
|
|
15
|
+
/** Image parts in one request, earlier turns included. */
|
|
16
|
+
images?: number
|
|
17
|
+
/** Raw bytes of every binary part of one request together. */
|
|
18
|
+
mediaBytes?: number
|
|
19
|
+
/** Raw bytes of every document of one request together. */
|
|
20
|
+
documentBytes?: number
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** What a call's content needs from the model that answers it. */
|
|
24
|
+
export interface MediaNeeds {
|
|
25
|
+
/** The content carries an image. */
|
|
26
|
+
vision: boolean
|
|
27
|
+
/** The content carries a document. */
|
|
28
|
+
documents: boolean
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** What one rung of a role's escalation ladder accepts. */
|
|
32
|
+
export interface RungCapabilities {
|
|
33
|
+
/** The rung's model id, when its config names one. */
|
|
34
|
+
model?: string
|
|
35
|
+
provider?: string
|
|
36
|
+
vision: boolean
|
|
37
|
+
documents: boolean
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* What the model a role resolved to accepts. A call carrying images (documents) is sent only to the
|
|
42
|
+
* rungs that accept them — a fallback without the capability never receives media — so `vision` is
|
|
43
|
+
* true when at least one rung can answer such a call; `rungs[0]` is the primary.
|
|
44
|
+
*/
|
|
45
|
+
export interface ModelCapabilities {
|
|
46
|
+
vision: boolean
|
|
47
|
+
documents: boolean
|
|
48
|
+
/** Primary first, then every fallback. */
|
|
49
|
+
rungs: RungCapabilities[]
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* What a trace stores in place of a binary content part: never the payload, only enough to tell
|
|
54
|
+
* which file it was.
|
|
55
|
+
*/
|
|
56
|
+
export interface MediaPlaceholder {
|
|
57
|
+
type: MediaKind
|
|
58
|
+
mime: string
|
|
59
|
+
/** Size of the decoded payload. */
|
|
60
|
+
bytes: number
|
|
61
|
+
/** Hex SHA-256 of the decoded payload. */
|
|
62
|
+
sha256: string
|
|
63
|
+
}
|
package/src/types.ts
CHANGED
|
@@ -42,6 +42,10 @@ export interface ModelConfigPatch {
|
|
|
42
42
|
maxOutput?: number
|
|
43
43
|
/** The window is shared between input and output rather than input-only. */
|
|
44
44
|
combinedWindow?: boolean
|
|
45
|
+
/** The model accepts image input. Unset means it does not — a call carrying images skips it. */
|
|
46
|
+
vision?: boolean
|
|
47
|
+
/** The model accepts PDF documents. Unset means it does not — a call carrying one skips it. */
|
|
48
|
+
documents?: boolean
|
|
45
49
|
}
|
|
46
50
|
|
|
47
51
|
/** A JSON-safe model override: a config alias, or a partial config patch. */
|