@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 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
@@ -127,7 +127,7 @@ export function runSparkAgent(options) {
127
127
  return {
128
128
  system,
129
129
  messages: prepareSparkContext(prepared, system, {
130
- maxInputTokens: options.maxInputTokens ?? 64_000,
130
+ maxInputTokens: options.maxInputTokens ?? 128_000,
131
131
  }),
132
132
  };
133
133
  },
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
- /** Approximation for text/code, with a separate allowance for each image/file. */
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
- /** Approximation for text/code, with a separate allowance for each image/file. */
12
+ /** Heuristic, not provider tokenization. Encoded media bytes are not text tokens. */
13
13
  export function estimateSparkContextTokens(value) {
14
- let media = 0;
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
- media++;
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) + media * 8192;
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")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@womp/spark-agent",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Portable skills-based AI agent with local and durable chat transports for Womp",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",