anyclaude-sdk 0.4.5 → 0.4.6

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/compact.d.ts CHANGED
@@ -19,4 +19,19 @@ export declare function summarizeHistory(history: ChatMsg[], llm: SummarizerLLM,
19
19
  signal?: AbortSignal;
20
20
  focus?: string;
21
21
  }): Promise<ChatMsg[] | null>;
22
+ /**
23
+ * Window-aware compaction: keep the most recent `keepRecent` messages VERBATIM
24
+ * and summarize only the older prefix into one summary message. Far less lossy
25
+ * than `summarizeHistory` (which collapses the entire transcript) — recent turns
26
+ * stay intact while old context is condensed. Returns a new history, or the
27
+ * original array unchanged if there isn't enough to compact.
28
+ *
29
+ * if (estimateTokens(history) > limit) history = await compactWithWindow(history, llm, { keepRecent: 8 })
30
+ */
31
+ export declare function compactWithWindow(history: ChatMsg[], llm: SummarizerLLM, opts?: {
32
+ keepRecent?: number;
33
+ model?: string;
34
+ signal?: AbortSignal;
35
+ focus?: string;
36
+ }): Promise<ChatMsg[]>;
22
37
  export {};
package/dist/compact.js CHANGED
@@ -65,3 +65,28 @@ export async function summarizeHistory(history, llm, opts = {}) {
65
65
  return null;
66
66
  return [history[0], { role: 'user', content: `Summary of the conversation so far:\n${summary}` }];
67
67
  }
68
+ /**
69
+ * Window-aware compaction: keep the most recent `keepRecent` messages VERBATIM
70
+ * and summarize only the older prefix into one summary message. Far less lossy
71
+ * than `summarizeHistory` (which collapses the entire transcript) — recent turns
72
+ * stay intact while old context is condensed. Returns a new history, or the
73
+ * original array unchanged if there isn't enough to compact.
74
+ *
75
+ * if (estimateTokens(history) > limit) history = await compactWithWindow(history, llm, { keepRecent: 8 })
76
+ */
77
+ export async function compactWithWindow(history, llm, opts = {}) {
78
+ const keepRecent = Math.max(2, opts.keepRecent ?? 8);
79
+ if (history.length <= keepRecent + 2)
80
+ return history;
81
+ // Cut boundary for the verbatim window; don't start it on an orphan tool
82
+ // result (pull its preceding assistant turn into the window).
83
+ let cut = history.length - keepRecent;
84
+ while (cut > 1 && history[cut]?.role === 'tool')
85
+ cut--;
86
+ const older = history.slice(0, cut); // includes the system message at [0]
87
+ const recent = history.slice(cut);
88
+ const summarized = await summarizeHistory(older, llm, opts);
89
+ if (!summarized)
90
+ return history;
91
+ return [summarized[0], summarized[1], ...recent];
92
+ }
package/dist/index.d.ts CHANGED
@@ -24,4 +24,4 @@ export { enterPlanMode, exitPlanMode, PLAN_MODE_TOOLS } from './tools/plan_mode.
24
24
  export { uuid } from './util/ids.js';
25
25
  export * as paths from './util/paths.js';
26
26
  export { priceFor, computeCostUSD, contextWindowFor, type Pricing } from './util/pricing.js';
27
- export { estimateTokens, summarizeHistory } from './compact.js';
27
+ export { estimateTokens, summarizeHistory, compactWithWindow } from './compact.js';
package/dist/index.js CHANGED
@@ -26,5 +26,5 @@ export { enterPlanMode, exitPlanMode, PLAN_MODE_TOOLS } from './tools/plan_mode.
26
26
  export { uuid } from './util/ids.js';
27
27
  export * as paths from './util/paths.js';
28
28
  export { priceFor, computeCostUSD, contextWindowFor } from './util/pricing.js';
29
- export { estimateTokens, summarizeHistory } from './compact.js';
29
+ export { estimateTokens, summarizeHistory, compactWithWindow } from './compact.js';
30
30
  // (createResponsesClient is exported via ./llm/index.js)
@@ -1,3 +1,4 @@
1
1
  export * from './openai.js';
2
2
  export * from './anthropic.js';
3
3
  export * from './responses.js';
4
+ export { hasInlineToolCalls, parseInlineToolCalls } from './inlineTools.js';
package/dist/llm/index.js CHANGED
@@ -1,3 +1,6 @@
1
1
  export * from './openai.js';
2
2
  export * from './anthropic.js';
3
3
  export * from './responses.js';
4
+ // Inline tool-call parsing — recover tool calls a model emitted as TEXT
5
+ // (e.g. weak models that narrate tool calls instead of using native function calls).
6
+ export { hasInlineToolCalls, parseInlineToolCalls } from './inlineTools.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "anyclaude-sdk",
3
- "version": "0.4.5",
3
+ "version": "0.4.6",
4
4
  "description": "Standalone, browser-compatible SDK providing Claude Code agent capabilities (tools, tool loop, multi-turn, MCP, sub-agents, sessions) against any OpenAI/Anthropic-compatible LLM endpoint. Runs in the browser (WebContainer), Node, and Bun — no backend required.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -47,6 +47,22 @@
47
47
  "./compact": {
48
48
  "types": "./dist/compact.d.ts",
49
49
  "import": "./dist/compact.js"
50
+ },
51
+ "./permissions": {
52
+ "types": "./dist/permissions/index.d.ts",
53
+ "import": "./dist/permissions/index.js"
54
+ },
55
+ "./skills": {
56
+ "types": "./dist/skills/index.d.ts",
57
+ "import": "./dist/skills/index.js"
58
+ },
59
+ "./queue": {
60
+ "types": "./dist/queue.d.ts",
61
+ "import": "./dist/queue.js"
62
+ },
63
+ "./prompt": {
64
+ "types": "./dist/prompt.d.ts",
65
+ "import": "./dist/prompt.js"
50
66
  }
51
67
  },
52
68
  "sideEffects": false,