@deepstrike/sdk 0.2.10 → 0.2.12

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.
Files changed (41) hide show
  1. package/README.md +38 -0
  2. package/dist/harness/harness.d.ts +5 -0
  3. package/dist/harness/harness.js +12 -1
  4. package/dist/index.d.ts +7 -4
  5. package/dist/index.js +6 -4
  6. package/dist/providers/anthropic.d.ts +7 -0
  7. package/dist/providers/anthropic.js +129 -10
  8. package/dist/providers/base.d.ts +38 -0
  9. package/dist/providers/base.js +0 -0
  10. package/dist/providers/catalog.js +20 -8
  11. package/dist/providers/deepseek.d.ts +12 -0
  12. package/dist/providers/deepseek.js +23 -4
  13. package/dist/providers/gemini.js +23 -4
  14. package/dist/providers/glm.d.ts +12 -0
  15. package/dist/providers/glm.js +19 -2
  16. package/dist/providers/kimi.d.ts +12 -0
  17. package/dist/providers/kimi.js +19 -2
  18. package/dist/providers/minimax.js +4 -2
  19. package/dist/providers/ollama.js +2 -2
  20. package/dist/providers/openai-chat.js +3 -2
  21. package/dist/providers/openai-responses.js +13 -0
  22. package/dist/providers/openai.d.ts +7 -0
  23. package/dist/providers/openai.js +15 -2
  24. package/dist/providers/profiles.d.ts +52 -28
  25. package/dist/providers/profiles.js +52 -28
  26. package/dist/providers/qwen.d.ts +12 -0
  27. package/dist/providers/qwen.js +23 -4
  28. package/dist/runtime/output-schema.d.ts +14 -0
  29. package/dist/runtime/output-schema.js +113 -0
  30. package/dist/runtime/reducers.d.ts +15 -0
  31. package/dist/runtime/reducers.js +57 -0
  32. package/dist/runtime/runner.d.ts +24 -1
  33. package/dist/runtime/runner.js +185 -15
  34. package/dist/runtime/session-log.d.ts +9 -1
  35. package/dist/runtime/session-repair.d.ts +14 -0
  36. package/dist/runtime/session-repair.js +15 -0
  37. package/dist/runtime/sub-agent-orchestrator.js +14 -1
  38. package/dist/types/agent.d.ts +43 -1
  39. package/dist/types/agent.js +105 -18
  40. package/dist/types.d.ts +42 -1
  41. package/package.json +2 -2
package/dist/types.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { WorkflowNodeSpec } from "./types/agent.js";
1
2
  export interface TextPart {
2
3
  type: "text";
3
4
  text: string;
@@ -72,6 +73,18 @@ export interface ToolCallEvent extends StreamEvent {
72
73
  name: string;
73
74
  arguments: Record<string, unknown>;
74
75
  }
76
+ export interface UsageEvent extends StreamEvent {
77
+ type: "usage";
78
+ /** Full prompt size + output (the authoritative prompt size for context accounting). */
79
+ totalTokens: number;
80
+ /** Full prompt size: uncached input + cache reads + cache writes. */
81
+ inputTokens?: number;
82
+ outputTokens?: number;
83
+ /** Prompt tokens served from cache this request (billed ~0.1x). Subset of inputTokens. */
84
+ cacheReadInputTokens?: number;
85
+ /** Prompt tokens written to cache this request (billed ~1.25x). Subset of inputTokens. */
86
+ cacheCreationInputTokens?: number;
87
+ }
75
88
  export type ToolChunk = string | {
76
89
  type: "text";
77
90
  text: string;
@@ -116,6 +129,13 @@ export interface ToolResultEvent extends StreamEvent {
116
129
  isFatal?: boolean;
117
130
  errorKind?: ToolErrorKind;
118
131
  }
132
+ /** R3-1: a workflow node's agent called the `submit_workflow_nodes` tool. The runner intercepts it
133
+ * (it cannot apply to the child's own kernel — the workflow lives in the parent) and surfaces the
134
+ * requested nodes as this event; the `runWorkflow` driver sends them to the parent kernel. */
135
+ export interface WorkflowNodesSubmittedEvent extends StreamEvent {
136
+ type: "workflow_nodes_submitted";
137
+ nodes: WorkflowNodeSpec[];
138
+ }
119
139
  export interface DoneEvent extends StreamEvent {
120
140
  type: "done";
121
141
  iterations: number;
@@ -161,9 +181,14 @@ export interface ToolDeniedEvent extends StreamEvent {
161
181
  reason: string;
162
182
  }
163
183
  export interface TokenUsage {
184
+ /** Full prompt size: uncached input + cache reads + cache writes. */
164
185
  inputTokens: number;
165
186
  outputTokens: number;
166
187
  totalTokens: number;
188
+ /** Prompt tokens served from cache (billed ~0.1x). Subset of inputTokens. */
189
+ cacheReadInputTokens?: number;
190
+ /** Prompt tokens written to cache (billed ~1.25x). Subset of inputTokens. */
191
+ cacheCreationInputTokens?: number;
167
192
  }
168
193
  export interface ProviderToolSpec {
169
194
  name: string;
@@ -228,8 +253,24 @@ export interface RenderedContext {
228
253
  systemStable?: string;
229
254
  /** Knowledge (memory retrievals, skill definitions, artifacts). Anthropic system[1] with cache_control. */
230
255
  systemKnowledge?: string;
231
- /** Turns: [0] = State (task_state + signals), [1..N] = History. */
256
+ /** History turns only — the stable, cacheable message prefix. */
232
257
  turns: Message[];
258
+ /**
259
+ * Volatile State turn (task_state + signals), rebuilt every call. Providers
260
+ * render it after the cacheable history (Anthropic: after the cache breakpoint;
261
+ * OpenAI-family: prepended, preserving order). Absent when produced by an
262
+ * older binding that has not been rebuilt — then the State turn is still inside
263
+ * `turns[0]` and providers render `turns` as-is.
264
+ */
265
+ stateTurn?: Message;
266
+ /**
267
+ * P1-E: count of leading `turns` forming the frozen prefix — byte-stable until the next
268
+ * compaction. The Anthropic provider pins a deep cache breakpoint at this boundary (a long-lived
269
+ * cache that survives many turns and is immune to the 20-block lookback miss on heavy tool turns)
270
+ * and rolls the other breakpoint at the tail. Absent (older binding, or no distinct frozen region
271
+ * yet) ⇒ the provider falls back to the rolling-pair placement.
272
+ */
273
+ frozenPrefixLen?: number;
233
274
  }
234
275
  /**
235
276
  * Runtime execution policy advertised by a provider.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deepstrike/sdk",
3
- "version": "0.2.10",
3
+ "version": "0.2.12",
4
4
  "description": "DeepStrike Node.js SDK",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -20,7 +20,7 @@
20
20
  },
21
21
  "dependencies": {
22
22
  "@anthropic-ai/sdk": "^0.99.0",
23
- "@deepstrike/core": "0.2.10",
23
+ "@deepstrike/core": "0.2.12",
24
24
  "@google/generative-ai": "^0.24.1",
25
25
  "openai": "^5.23.2"
26
26
  },