@womp/spark-agent 1.0.0 → 1.0.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/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": "1.0.0",
3
+ "version": "1.0.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",