@deepstrike/sdk 0.2.52 → 0.2.61

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 (151) hide show
  1. package/README.md +28 -28
  2. package/dist/agent-ir.d.ts +103 -0
  3. package/dist/agent-ir.js +134 -0
  4. package/dist/agent.d.ts +67 -0
  5. package/dist/agent.js +36 -0
  6. package/dist/collaboration/harness.js +1 -1
  7. package/dist/collaboration/modes/creator-verifier.d.ts +2 -7
  8. package/dist/collaboration/modes/creator-verifier.js +4 -6
  9. package/dist/collaboration/pool.d.ts +8 -20
  10. package/dist/collaboration/pool.js +27 -97
  11. package/dist/compat/anthropic/mcp.d.ts +15 -0
  12. package/dist/compat/anthropic/mcp.js +10 -0
  13. package/dist/compat/openai/agent.d.ts +34 -0
  14. package/dist/compat/openai/agent.js +24 -0
  15. package/dist/governance.d.ts +1 -17
  16. package/dist/governance.js +1 -34
  17. package/dist/guardrail.d.ts +6 -0
  18. package/dist/guardrail.js +1 -0
  19. package/dist/handoff-target.d.ts +12 -0
  20. package/dist/handoff-target.js +1 -0
  21. package/dist/harness/manifest.js +0 -4
  22. package/dist/index.d.ts +19 -7
  23. package/dist/index.js +8 -5
  24. package/dist/kernel.d.ts +2 -20
  25. package/dist/knowledge/public.d.ts +29 -0
  26. package/dist/knowledge/public.js +1 -0
  27. package/dist/mcp-server.d.ts +28 -0
  28. package/dist/mcp-server.js +1 -0
  29. package/dist/memory/agent.d.ts +2 -2
  30. package/dist/memory/agent.js +2 -2
  31. package/dist/memory/durable.d.ts +16 -0
  32. package/dist/memory/durable.js +46 -0
  33. package/dist/memory/in-memory-store.d.ts +9 -7
  34. package/dist/memory/in-memory-store.js +8 -2
  35. package/dist/memory/protocols.d.ts +22 -4
  36. package/dist/memory/public.d.ts +4 -3
  37. package/dist/memory/public.js +3 -2
  38. package/dist/os/public.d.ts +1 -1
  39. package/dist/os/public.js +1 -1
  40. package/dist/providers/anthropic-adapter.d.ts +59 -0
  41. package/dist/providers/anthropic-adapter.js +530 -0
  42. package/dist/providers/anthropic-compatible.d.ts +2 -3
  43. package/dist/providers/anthropic-compatible.js +8 -5
  44. package/dist/providers/anthropic.d.ts +20 -23
  45. package/dist/providers/anthropic.js +176 -395
  46. package/dist/providers/base.d.ts +2 -2
  47. package/dist/providers/base.js +50 -8
  48. package/dist/providers/capability-router.d.ts +29 -0
  49. package/dist/providers/capability-router.js +43 -0
  50. package/dist/providers/catalog.d.ts +16 -4
  51. package/dist/providers/catalog.js +112 -36
  52. package/dist/providers/content-normalization.d.ts +57 -0
  53. package/dist/providers/content-normalization.js +238 -0
  54. package/dist/providers/content-policy.d.ts +16 -0
  55. package/dist/providers/content-policy.js +39 -0
  56. package/dist/providers/credentials.d.ts +83 -0
  57. package/dist/providers/credentials.js +190 -0
  58. package/dist/providers/endpoints.d.ts +137 -0
  59. package/dist/providers/endpoints.js +128 -0
  60. package/dist/providers/factories.js +25 -9
  61. package/dist/providers/gemini-adapter.d.ts +33 -0
  62. package/dist/providers/gemini-adapter.js +264 -0
  63. package/dist/providers/gemini.d.ts +16 -3
  64. package/dist/providers/gemini.js +97 -195
  65. package/dist/providers/model-catalog.d.ts +37 -0
  66. package/dist/providers/model-catalog.js +62 -0
  67. package/dist/providers/model-registry.d.ts +119 -0
  68. package/dist/providers/model-registry.js +379 -0
  69. package/dist/providers/ollama-adapter.d.ts +65 -0
  70. package/dist/providers/ollama-adapter.js +188 -0
  71. package/dist/providers/ollama.d.ts +9 -4
  72. package/dist/providers/ollama.js +96 -109
  73. package/dist/providers/openai-chat-dialects.d.ts +154 -0
  74. package/dist/providers/openai-chat-dialects.js +179 -0
  75. package/dist/providers/openai-chat.d.ts +46 -18
  76. package/dist/providers/openai-chat.js +416 -51
  77. package/dist/providers/openai-responses-adapter.d.ts +42 -0
  78. package/dist/providers/openai-responses-adapter.js +343 -0
  79. package/dist/providers/openai-responses.d.ts +19 -33
  80. package/dist/providers/openai-responses.js +164 -264
  81. package/dist/providers/openai.d.ts +29 -76
  82. package/dist/providers/openai.js +195 -292
  83. package/dist/providers/protocol-adapter.d.ts +39 -0
  84. package/dist/providers/protocol-adapter.js +13 -0
  85. package/dist/providers/protocol-capabilities.d.ts +34 -0
  86. package/dist/providers/protocol-capabilities.js +44 -0
  87. package/dist/providers/provider-error.d.ts +31 -0
  88. package/dist/providers/provider-error.js +153 -0
  89. package/dist/providers/public.d.ts +26 -3
  90. package/dist/providers/public.js +13 -1
  91. package/dist/providers/registry.d.ts +7 -6
  92. package/dist/providers/registry.js +47 -20
  93. package/dist/providers/request-plan.d.ts +89 -0
  94. package/dist/providers/request-plan.js +199 -0
  95. package/dist/providers/usage-normalizer.d.ts +48 -0
  96. package/dist/providers/usage-normalizer.js +139 -0
  97. package/dist/providers/vendor-profiles.d.ts +2 -15
  98. package/dist/providers/vendor-profiles.js +14 -60
  99. package/dist/runtime/canonical-kernel-step.d.ts +1 -2
  100. package/dist/runtime/canonical-kernel-step.js +47 -12
  101. package/dist/runtime/context-policy.d.ts +10 -12
  102. package/dist/runtime/context-policy.js +6 -8
  103. package/dist/runtime/durable-content.d.ts +50 -0
  104. package/dist/runtime/durable-content.js +159 -0
  105. package/dist/runtime/execution-plane.d.ts +2 -2
  106. package/dist/runtime/execution-plane.js +2 -2
  107. package/dist/runtime/kernel-event-log.js +0 -1
  108. package/dist/runtime/kernel-step.d.ts +0 -1
  109. package/dist/runtime/kernel-step.js +4 -2
  110. package/dist/runtime/mcp-proxy-plane.d.ts +25 -1
  111. package/dist/runtime/mcp-proxy-plane.js +44 -6
  112. package/dist/runtime/output-schema.d.ts +1 -2
  113. package/dist/runtime/provider-replay.d.ts +5 -1
  114. package/dist/runtime/provider-replay.js +26 -27
  115. package/dist/runtime/reactive-session.d.ts +1 -1
  116. package/dist/runtime/reactive-session.js +2 -3
  117. package/dist/runtime/run-group.d.ts +1 -1
  118. package/dist/runtime/runner.d.ts +31 -45
  119. package/dist/runtime/runner.js +178 -63
  120. package/dist/runtime/session-log.d.ts +8 -1
  121. package/dist/runtime/session-log.js +42 -2
  122. package/dist/runtime/session-repair.d.ts +1 -1
  123. package/dist/runtime/session-repair.js +1 -1
  124. package/dist/runtime/sub-agent-orchestrator.d.ts +1 -1
  125. package/dist/runtime/sub-agent-orchestrator.js +8 -11
  126. package/dist/runtime/workflow-control-flow.d.ts +0 -4
  127. package/dist/runtime/workflow-control-flow.js +0 -16
  128. package/dist/session.d.ts +11 -0
  129. package/dist/session.js +1 -0
  130. package/dist/skill.d.ts +17 -0
  131. package/dist/skill.js +16 -0
  132. package/dist/skills/loader.d.ts +3 -0
  133. package/dist/tools/errors.d.ts +1 -3
  134. package/dist/tools/errors.js +1 -3
  135. package/dist/tools/index.d.ts +3 -0
  136. package/dist/types/agent.d.ts +21 -9
  137. package/dist/types/agent.js +30 -4
  138. package/dist/types.d.ts +135 -17
  139. package/package.json +4 -4
  140. package/dist/providers/deepseek.d.ts +0 -46
  141. package/dist/providers/deepseek.js +0 -97
  142. package/dist/providers/glm.d.ts +0 -25
  143. package/dist/providers/glm.js +0 -48
  144. package/dist/providers/kimi.d.ts +0 -23
  145. package/dist/providers/kimi.js +0 -30
  146. package/dist/providers/minimax.d.ts +0 -49
  147. package/dist/providers/minimax.js +0 -98
  148. package/dist/providers/profiles.d.ts +0 -1992
  149. package/dist/providers/profiles.js +0 -796
  150. package/dist/providers/qwen.d.ts +0 -38
  151. package/dist/providers/qwen.js +0 -97
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Binds the host storage protocol to the public Memory contract for one agent and namespace.
3
+ * This is deliberately an SDK adapter: it does not lower memory mutations into the Kernel.
4
+ */
5
+ export class DurableMemory {
6
+ store;
7
+ agentId;
8
+ scope;
9
+ namespace;
10
+ constructor(store, agentId, scope) {
11
+ this.store = store;
12
+ this.agentId = agentId;
13
+ this.scope = scope;
14
+ this.namespace = scope.namespace;
15
+ }
16
+ async search(query, options = {}) {
17
+ const request = {
18
+ scope: this.scope,
19
+ query,
20
+ top_k: options.topK ?? 5,
21
+ kinds: options.kinds ?? [],
22
+ ...(options.minScore === undefined ? {} : { min_score: options.minScore }),
23
+ };
24
+ return (await this.store.search(this.agentId, request))
25
+ .map(hit => hit.record)
26
+ .filter(record => sameScope(record.scope, this.scope));
27
+ }
28
+ async get(id) {
29
+ const record = await this.store.get(this.agentId, id);
30
+ return record !== null && sameScope(record.scope, this.scope) ? record : null;
31
+ }
32
+ async put(record) {
33
+ if (!sameScope(record.scope, this.scope)) {
34
+ throw new Error("memory record scope must match the bound Memory scope");
35
+ }
36
+ await this.store.put(this.agentId, record);
37
+ }
38
+ async delete(id) {
39
+ const record = await this.get(id);
40
+ if (record !== null)
41
+ await this.store.delete(this.agentId, id);
42
+ }
43
+ }
44
+ function sameScope(left, right) {
45
+ return left.tenant_id === right.tenant_id && left.namespace === right.namespace;
46
+ }
@@ -1,7 +1,7 @@
1
1
  /**
2
- * `InMemoryDreamStore` — a lightweight `DreamStore` implementation backed by per-agent `Map`s.
2
+ * `InMemoryMemoryStore` — a lightweight `MemoryStore` implementation backed by per-agent `Map`s.
3
3
  *
4
- * Originally lived as `MockDreamStore` in the SDK's test helpers; promoted here so benchmarks,
4
+ * Originally lived as `MockMemoryStore` in the SDK's test helpers; promoted here so benchmarks,
5
5
  * examples, and downstream consumers can use it without copying the boilerplate.
6
6
  *
7
7
  * Use cases:
@@ -14,8 +14,8 @@
14
14
  * the full record set, so it (M3) bounds itself by value-ordered retention eviction and (M3/M4)
15
15
  * mirrors recall lifecycle and pin state. For semantic search, plug in a real store.
16
16
  */
17
- import type { DreamStore, MemoryQuery, MemoryRecall, MemoryRecallLifecycle, MemoryRecord, SessionData } from "./protocols.js";
18
- export interface InMemoryDreamStoreOptions {
17
+ import type { MemoryStore, MemoryQuery, MemoryRecall, MemoryRecallLifecycle, MemoryRecord, SessionData } from "./protocols.js";
18
+ export interface InMemoryMemoryStoreOptions {
19
19
  /** Cap the per-agent record set; a write past it evicts the lowest-value unpinned records (M3). */
20
20
  maxRecords?: number;
21
21
  /** Age (days) past which a record's recall relevance is discounted. Default 2. */
@@ -23,7 +23,7 @@ export interface InMemoryDreamStoreOptions {
23
23
  /** Wall-clock source for staleness scoring + recall stamps. Injectable for deterministic tests. */
24
24
  now?: () => number;
25
25
  }
26
- export declare class InMemoryDreamStore implements DreamStore {
26
+ export declare class InMemoryMemoryStore implements MemoryStore {
27
27
  private readonly initialMemories;
28
28
  private memories;
29
29
  /** Sessions persisted via `saveSession`; exposed for test assertions. */
@@ -35,9 +35,11 @@ export declare class InMemoryDreamStore implements DreamStore {
35
35
  * @param initialMemories Optional seed memories applied to every agent that asks for memories
36
36
  * for the first time. Useful for benchmark scenarios that preload a fact.
37
37
  */
38
- constructor(initialMemories?: MemoryRecord[], options?: InMemoryDreamStoreOptions);
38
+ constructor(initialMemories?: MemoryRecord[], options?: InMemoryMemoryStoreOptions);
39
39
  private recordsFor;
40
- upsert(agentId: string, incoming: MemoryRecord): Promise<void>;
40
+ put(agentId: string, incoming: MemoryRecord): Promise<void>;
41
+ get(agentId: string, recordId: string): Promise<MemoryRecord | null>;
42
+ delete(agentId: string, recordId: string): Promise<void>;
41
43
  /** M3: value-ordered retention eviction. Sheds the lowest-value unpinned records — the shared
42
44
  * deterministic formula, never a blind tail-cut — until the set fits `maxRecords`. */
43
45
  private evictToCapacity;
@@ -1,6 +1,6 @@
1
1
  import { rankMemories } from "./ranking.js";
2
2
  import { memoryRetentionScore } from "./retention.js";
3
- export class InMemoryDreamStore {
3
+ export class InMemoryMemoryStore {
4
4
  initialMemories;
5
5
  memories = new Map();
6
6
  /** Sessions persisted via `saveSession`; exposed for test assertions. */
@@ -27,7 +27,7 @@ export class InMemoryDreamStore {
27
27
  }
28
28
  return [];
29
29
  }
30
- async upsert(agentId, incoming) {
30
+ async put(agentId, incoming) {
31
31
  const kept = [...this.recordsFor(agentId)];
32
32
  const index = kept.findIndex(record => record.scope.tenant_id === incoming.scope.tenant_id
33
33
  && record.scope.namespace === incoming.scope.namespace
@@ -39,6 +39,12 @@ export class InMemoryDreamStore {
39
39
  kept.push(incoming);
40
40
  this.memories.set(agentId, this.evictToCapacity(kept));
41
41
  }
42
+ async get(agentId, recordId) {
43
+ return this.recordsFor(agentId).find(record => record.record_id === recordId) ?? null;
44
+ }
45
+ async delete(agentId, recordId) {
46
+ this.memories.set(agentId, this.recordsFor(agentId).filter(record => record.record_id !== recordId));
47
+ }
42
48
  /** M3: value-ordered retention eviction. Sheds the lowest-value unpinned records — the shared
43
49
  * deterministic formula, never a blind tail-cut — until the set fits `maxRecords`. */
44
50
  evictToCapacity(records) {
@@ -60,10 +60,28 @@ export interface MemoryRecallLifecycle {
60
60
  recall_count: number;
61
61
  last_recalled_at: number;
62
62
  }
63
- export interface DreamStore {
64
- /** The only durable memory mutation. Callers must reach this through the kernel WriteMemory gate. */
65
- upsert(agentId: string, record: MemoryRecord): Promise<void>;
66
- /** Semantic search over the agent's long-term memories. Called on demand during a run. */
63
+ /** Search options for the public, agent-bound durable `Memory` descriptor. */
64
+ export interface MemorySearchOptions {
65
+ topK?: number;
66
+ kinds?: MemoryKind[];
67
+ minScore?: number;
68
+ }
69
+ /**
70
+ * Public durable memory descriptor bound to one agent and scope. It intentionally returns records,
71
+ * not ranking internals, and is distinct from `WorkingMemory`, the SDK-only scratch pad.
72
+ */
73
+ export interface Memory {
74
+ readonly namespace?: string;
75
+ search(query: string, options?: MemorySearchOptions): Promise<MemoryRecord[]>;
76
+ get(id: string): Promise<MemoryRecord | null>;
77
+ put(record: MemoryRecord): Promise<void>;
78
+ delete(id: string): Promise<void>;
79
+ }
80
+ /** Host-owned durable storage behind an agent-bound public `Memory` descriptor. */
81
+ export interface MemoryStore {
82
+ put(agentId: string, record: MemoryRecord): Promise<void>;
83
+ get(agentId: string, recordId: string): Promise<MemoryRecord | null>;
84
+ delete(agentId: string, recordId: string): Promise<void>;
67
85
  search(agentId: string, query: MemoryQuery): Promise<MemoryRecall[]>;
68
86
  /** Persist the completed session before the runner performs its one extraction pass. */
69
87
  saveSession(data: SessionData): Promise<void>;
@@ -1,9 +1,10 @@
1
1
  export { WorkingMemory } from "./working.js";
2
- export { InMemoryDreamStore } from "./in-memory-store.js";
3
- export type { InMemoryDreamStoreOptions } from "./in-memory-store.js";
2
+ export { DurableMemory } from "./durable.js";
3
+ export { InMemoryMemoryStore } from "./in-memory-store.js";
4
+ export type { InMemoryMemoryStoreOptions } from "./in-memory-store.js";
4
5
  export { memoryRetentionScore } from "./retention.js";
5
6
  export { rankMemories } from "./ranking.js";
6
7
  export type { RankableMemory, RankedMemory, RankOptions } from "./ranking.js";
7
8
  export { extractSessionMemories, parseExtractedMemories } from "./extraction.js";
8
- export type { DreamStore, SessionData, SessionMessage, MemoryRecord, MemoryRecall, MemoryQuery, MemoryScope, MemoryProvenance, MemoryRecallLifecycle, MemoryKind, MemoryAuthor, MemoryTrustLevel, } from "./protocols.js";
9
+ export type { MemoryStore, Memory, MemorySearchOptions, SessionData, SessionMessage, MemoryRecord, MemoryRecall, MemoryQuery, MemoryScope, MemoryProvenance, MemoryRecallLifecycle, MemoryKind, MemoryAuthor, MemoryTrustLevel, } from "./protocols.js";
9
10
  export type { KnowledgeSource } from "../knowledge/source.js";
@@ -1,6 +1,7 @@
1
- // `@deepstrike/sdk/memory` — long-term (dream) and working memory, plus the knowledge-source interface.
1
+ // `@deepstrike/sdk/memory` — durable and working memory, plus the knowledge-source interface.
2
2
  export { WorkingMemory } from "./working.js";
3
- export { InMemoryDreamStore } from "./in-memory-store.js";
3
+ export { DurableMemory } from "./durable.js";
4
+ export { InMemoryMemoryStore } from "./in-memory-store.js";
4
5
  export { memoryRetentionScore } from "./retention.js";
5
6
  export { rankMemories } from "./ranking.js";
6
7
  export { extractSessionMemories, parseExtractedMemories } from "./extraction.js";
@@ -15,5 +15,5 @@ export { ReplayProvider } from "../runtime/replay-provider.js";
15
15
  export type { ReplayProviderOpts } from "../runtime/replay-provider.js";
16
16
  export { extractRecordedMessages } from "../runtime/replay-fixture.js";
17
17
  export { ProviderReplayValidationError, DEGRADED_REASONING_PLACEHOLDER } from "../providers/replay-validator.js";
18
- export { assessProviderReplayability, peekProviderReplay, seedProviderReplayFromEvents, isReplayCompatibleWithProvider, } from "../runtime/provider-replay.js";
18
+ export { ProviderReplayProtocolMismatchError, assessProviderReplayability, peekProviderReplay, seedProviderReplayFromEvents, isReplayCompatibleWithProvider, } from "../runtime/provider-replay.js";
19
19
  export type { ReplayabilityAssessment } from "../types.js";
package/dist/os/public.js CHANGED
@@ -12,4 +12,4 @@ export { PermissionManager, PermissionMode } from "../safety/permissions.js";
12
12
  export { ReplayProvider } from "../runtime/replay-provider.js";
13
13
  export { extractRecordedMessages } from "../runtime/replay-fixture.js";
14
14
  export { ProviderReplayValidationError, DEGRADED_REASONING_PLACEHOLDER } from "../providers/replay-validator.js";
15
- export { assessProviderReplayability, peekProviderReplay, seedProviderReplayFromEvents, isReplayCompatibleWithProvider, } from "../runtime/provider-replay.js";
15
+ export { ProviderReplayProtocolMismatchError, assessProviderReplayability, peekProviderReplay, seedProviderReplayFromEvents, isReplayCompatibleWithProvider, } from "../runtime/provider-replay.js";
@@ -0,0 +1,59 @@
1
+ import type { Message, ProviderReplay, ProviderUsage, ToolCall } from "../types.js";
2
+ import type { CanonicalAdapterInput } from "./content-normalization.js";
3
+ import { type AdapterDecodeInput, type AdapterOutput, type AdapterStreamInput, type CanonicalStopReason, type ProtocolAdapter } from "./protocol-adapter.js";
4
+ export declare const ANTHROPIC_TEXTUAL_TOOL_CALL_START_MARKER = "<\uFF5C\uFF5CDSML\uFF5C\uFF5Ctool_calls>";
5
+ type TextualToolCallPolicy = "off" | "reject";
6
+ interface TextualToolCallGuardState {
7
+ policy: TextualToolCallPolicy;
8
+ mode: "passthrough" | "candidate";
9
+ tail: string;
10
+ capturedLength: number;
11
+ sawNativeToolCall: boolean;
12
+ }
13
+ export interface AnthropicRequestPlan {
14
+ transport: "stable" | "beta";
15
+ params: Record<string, unknown>;
16
+ cacheSlots: {
17
+ system: boolean;
18
+ tools: boolean;
19
+ messages: boolean;
20
+ };
21
+ }
22
+ export type AnthropicStreamChunk = Record<string, any>;
23
+ export interface AnthropicStreamState {
24
+ readonly input: CanonicalAdapterInput;
25
+ readonly cacheSlots: {
26
+ system: boolean;
27
+ tools: boolean;
28
+ messages: boolean;
29
+ };
30
+ readonly toolBlocks: Record<number, {
31
+ id: string;
32
+ name: string;
33
+ argsBuffer: string;
34
+ }>;
35
+ readonly nativeBlocks: Record<number, Record<string, unknown>>;
36
+ readonly finalToolCalls: ToolCall[];
37
+ readonly textualToolCallGuard: TextualToolCallGuardState;
38
+ finalText: string;
39
+ uncachedInput: number;
40
+ cacheReadTokens: number;
41
+ cacheCreationTokens: number;
42
+ cacheTelemetryMeasured: boolean;
43
+ outputTokens: number;
44
+ }
45
+ export declare class AnthropicMessagesAdapter implements ProtocolAdapter<AnthropicRequestPlan, Record<string, any>, AnthropicStreamChunk, AnthropicStreamState, undefined> {
46
+ readonly protocol: "anthropic-messages";
47
+ readonly protocolCapabilities: import("./protocol-capabilities.js").ProtocolRuntimeCapabilities;
48
+ buildRequest(input: CanonicalAdapterInput): AnthropicRequestPlan;
49
+ decodeComplete(raw: Record<string, any>, decodeInput: AdapterDecodeInput): {
50
+ message: Message;
51
+ replay?: ProviderReplay;
52
+ };
53
+ createStreamState(input: AdapterStreamInput): AnthropicStreamState;
54
+ pushStreamChunk(chunk: AnthropicStreamChunk, state: AnthropicStreamState): AdapterOutput;
55
+ finishStream(state: AnthropicStreamState): AdapterOutput;
56
+ normalizeUsage(raw: unknown): ProviderUsage | undefined;
57
+ normalizeStopReason(raw: string | undefined): CanonicalStopReason | undefined;
58
+ }
59
+ export {};