@womp/spark-agent 0.3.0 → 0.3.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 +8 -0
- package/dist/agent.js +1 -1
- package/dist/context.d.ts +1 -1
- package/dist/context.js +6 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -299,6 +299,14 @@ Releases use a manual package publication; no separate release service is requir
|
|
|
299
299
|
- Custom JavaScript executors must honor cancellation and host-owned user waits. Callback-based
|
|
300
300
|
scene edits and artifact references work with both the native and QuickJS executors.
|
|
301
301
|
|
|
302
|
+
### 0.3.1 context defaults
|
|
303
|
+
|
|
304
|
+
- The default input context budget is now 128,000 estimated tokens. Hosts can still
|
|
305
|
+
set `maxInputTokens` explicitly; this budget does not change the provider's context limit.
|
|
306
|
+
- Images, including images in tool results, use a 512-token estimate instead of the
|
|
307
|
+
general 8,192-token file allowance. Encoded media bytes remain excluded from text
|
|
308
|
+
estimates. Token accounting is heuristic; no API or storage migration is required.
|
|
309
|
+
|
|
302
310
|
### Publishing
|
|
303
311
|
|
|
304
312
|
1. Choose an unused package version after checking `npm view @womp/spark-agent versions --json`.
|
package/dist/agent.js
CHANGED
package/dist/context.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export type SparkContextPolicy = {
|
|
|
6
6
|
export declare class SparkContextLimitError extends Error {
|
|
7
7
|
constructor();
|
|
8
8
|
}
|
|
9
|
-
/**
|
|
9
|
+
/** Heuristic, not provider tokenization. Encoded media bytes are not text tokens. */
|
|
10
10
|
export declare function estimateSparkContextTokens(value: unknown): number;
|
|
11
11
|
/**
|
|
12
12
|
* Project model input only. Never mutate persisted messages, remove call/result
|
package/dist/context.js
CHANGED
|
@@ -9,19 +9,21 @@ function record(value) {
|
|
|
9
9
|
? value
|
|
10
10
|
: undefined;
|
|
11
11
|
}
|
|
12
|
-
/**
|
|
12
|
+
/** Heuristic, not provider tokenization. Encoded media bytes are not text tokens. */
|
|
13
13
|
export function estimateSparkContextTokens(value) {
|
|
14
|
-
let
|
|
14
|
+
let mediaTokens = 0;
|
|
15
15
|
const json = JSON.stringify(value, (_key, item) => {
|
|
16
16
|
const part = record(item);
|
|
17
17
|
if (part &&
|
|
18
18
|
(part.type === "image" || part.type === "file" || part.type === "reasoning-file")) {
|
|
19
|
-
|
|
19
|
+
const isImage = part.type === "image" ||
|
|
20
|
+
(typeof part.mediaType === "string" && part.mediaType.startsWith("image/"));
|
|
21
|
+
mediaTokens += isImage ? 512 : 8192;
|
|
20
22
|
return { type: part.type, mediaType: part.mediaType };
|
|
21
23
|
}
|
|
22
24
|
return item;
|
|
23
25
|
}) ?? "";
|
|
24
|
-
return Math.ceil(new TextEncoder().encode(json).byteLength / 3) +
|
|
26
|
+
return Math.ceil(new TextEncoder().encode(json).byteLength / 3) + mediaTokens;
|
|
25
27
|
}
|
|
26
28
|
function executionOutput(part) {
|
|
27
29
|
if (part.toolName !== "execute_javascript" || part.output.type !== "content")
|