@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
@@ -1,109 +1,49 @@
1
- import { collectText } from "../runtime/runner.js";
2
1
  import { spawnStandalone } from "../runtime/sub-agent-orchestrator.js";
3
2
  import { formatContractForSystemPrompt } from "./contract.js";
4
3
  import { agentIdentitySub } from "../types/agent.js";
5
- export const KERNEL_ROLE_MAP = {
6
- orchestrator: "plan",
7
- executor: "implement",
8
- verifier: "verify",
9
- };
10
4
  export class AgentPool {
11
- runners = new Map();
12
5
  coordinator;
13
- add(role, runner) {
14
- this.runners.set(role, runner);
15
- return this;
16
- }
17
6
  /** Enable kernel spawn path with lineage recorded under `sessionId`. */
18
7
  configureCoordinator(opts, sessionId) {
19
8
  this.coordinator = { opts, sessionId };
20
9
  return this;
21
10
  }
22
- /**
23
- * Infer coordinator from a registered runner (executor → orchestrator → verifier).
24
- * Idempotent when coordinator is already configured.
25
- */
26
- ensureCoordinator(sessionId) {
27
- if (this.coordinator)
28
- return this;
29
- const source = this.has("executor")
30
- ? "executor"
31
- : this.has("orchestrator")
32
- ? "orchestrator"
33
- : "verifier";
34
- return this.configureCoordinator(this.get(source).hostOptions, sessionId ?? crypto.randomUUID());
11
+ /** Assert that this pool has one canonical kernel coordinator. */
12
+ ensureCoordinator() {
13
+ if (!this.coordinator) {
14
+ throw new Error("AgentPool.configureCoordinator() must be called before execution");
15
+ }
16
+ return this;
35
17
  }
36
18
  usesSpawnPath() {
37
19
  return this.coordinator !== undefined;
38
20
  }
39
- has(role) {
40
- return this.runners.has(role);
41
- }
42
- get(role) {
43
- const runner = this.runners.get(role);
44
- if (!runner)
45
- throw new Error(`AgentPool: no runner registered for role "${role}"`);
46
- return runner;
47
- }
48
- /**
49
- * Spawn a kernel-isolated sub-agent. Requires `configureCoordinator()`.
50
- * Maps legacy pool roles to kernel roles (executor → implement, etc.).
51
- */
21
+ /** Spawn a kernel-isolated sub-agent. Requires `configureCoordinator()`. */
52
22
  async spawn(role, goal, extra) {
53
23
  if (!this.coordinator) {
54
24
  throw new Error("AgentPool.configureCoordinator() required for kernel spawn path");
55
25
  }
56
- const kernelRole = role in KERNEL_ROLE_MAP ? KERNEL_ROLE_MAP[role] : role;
57
26
  const spec = {
58
- identity: agentIdentitySub(`${kernelRole}-${crypto.randomUUID()}`, crypto.randomUUID(), this.coordinator.sessionId),
59
- role: kernelRole,
27
+ identity: agentIdentitySub(`${role}-${crypto.randomUUID()}`, crypto.randomUUID(), this.coordinator.sessionId),
28
+ role,
60
29
  goal,
61
30
  ...extra,
62
31
  };
63
32
  return spawnStandalone(this.coordinator.opts, this.coordinator.sessionId, spec);
64
33
  }
65
- /** Execute a role in a caller-owned session so AttemptLoop can retain transcript across attempts. */
34
+ /** Execute a role in a caller-owned session while preserving kernel lineage. */
66
35
  async execute(role, input) {
67
- if (this.coordinator) {
68
- const kernelRole = KERNEL_ROLE_MAP[role];
69
- const spec = {
70
- identity: agentIdentitySub(`${kernelRole}-${input.sessionId}`, input.sessionId, this.coordinator.sessionId),
71
- role: kernelRole,
72
- goal: input.goal,
73
- ...(input.verificationContractId
74
- ? { verificationContractId: input.verificationContractId }
75
- : {}),
76
- };
77
- return spawnStandalone(this.coordinator.opts, this.coordinator.sessionId, spec, undefined, input.contextInput);
78
- }
79
- const runner = this.get(role);
80
- if (input.contextInput)
81
- runner.injectNote(input.contextInput);
82
- let finalText = "";
83
- let turnsUsed = 0;
84
- let totalTokensUsed = 0;
85
- let termination = "error";
86
- for await (const event of runner.run({ sessionId: input.sessionId, goal: input.goal })) {
87
- if (event.type === "text_delta")
88
- finalText += event.delta;
89
- if (event.type === "done") {
90
- const done = event;
91
- turnsUsed = done.iterations;
92
- totalTokensUsed = done.totalTokens;
93
- termination = done.status;
94
- }
95
- }
96
- return {
97
- agentId: `${KERNEL_ROLE_MAP[role]}-${input.sessionId}`,
98
- result: {
99
- termination,
100
- turnsUsed,
101
- totalTokensUsed,
102
- ...(finalText
103
- ? { finalMessage: { role: "assistant", content: finalText, toolCalls: [] } }
104
- : {}),
105
- },
36
+ this.ensureCoordinator();
37
+ const coordinator = this.coordinator;
38
+ const spec = {
39
+ identity: agentIdentitySub(`${role}-${input.sessionId}`, input.sessionId, coordinator.sessionId),
40
+ role,
41
+ goal: input.goal,
42
+ ...(input.verificationContractId
43
+ ? { verificationContractId: input.verificationContractId }
44
+ : {}),
106
45
  };
46
+ return spawnStandalone(coordinator.opts, coordinator.sessionId, spec, undefined, input.contextInput);
107
47
  }
108
48
  async verify(ctx) {
109
49
  const contractBlock = formatContractForSystemPrompt(ctx.contract);
@@ -128,15 +68,11 @@ export class AgentPool {
128
68
  }, null, 2),
129
69
  "Every contract criterion id must appear exactly once in details. Do not emit prose or markdown.",
130
70
  ].join("\n");
131
- if (this.coordinator) {
132
- const result = await this.spawn("verify", auditGoal, {
133
- verificationContractId: ctx.contract.id,
134
- isolation: "read_only",
135
- });
136
- return result.result.finalMessage?.content ?? "";
137
- }
138
- const runner = this.get("verifier");
139
- return collectText(runner.run({ sessionId: crypto.randomUUID(), goal: auditGoal }));
71
+ const result = await this.spawn("verify", auditGoal, {
72
+ verificationContractId: ctx.contract.id,
73
+ isolation: "read_only",
74
+ });
75
+ return result.result.finalMessage?.content ?? "";
140
76
  }
141
77
  async orchestrate(goal) {
142
78
  const orchestratorGoal = [
@@ -155,13 +91,7 @@ export class AgentPool {
155
91
  ``,
156
92
  `Output ONLY the JSON object, no prose.`,
157
93
  ].join("\n");
158
- if (this.coordinator) {
159
- const result = await this.spawn("plan", orchestratorGoal);
160
- return result.result.finalMessage?.content ?? "";
161
- }
162
- return collectText(this.get("orchestrator").run({
163
- sessionId: crypto.randomUUID(),
164
- goal: orchestratorGoal,
165
- }));
94
+ const result = await this.spawn("plan", orchestratorGoal);
95
+ return result.result.finalMessage?.content ?? "";
166
96
  }
167
97
  }
@@ -0,0 +1,15 @@
1
+ import type { MCPServer } from "../../mcp-server.js";
2
+ /** spc_007 §3: minimal Anthropic/Claude-style MCP server config shape (the per-server object in
3
+ * a Claude Desktop-style `mcpServers` map — `{ command, args, env }`), not a live SDK type
4
+ * import — this adapter reads a serialized config (e.g.
5
+ * `__fixtures__/anthropic-mcp-config.json`). */
6
+ export interface AnthropicMcpConfigJson {
7
+ name?: string;
8
+ command: string;
9
+ args?: string[];
10
+ env?: Record<string, string>;
11
+ }
12
+ /** Anthropic MCP config → DeepStrike `MCPServer` (spc_001-07). Anthropic's config format is
13
+ * always a subprocess launch (stdio transport) — there is no http/sse/custom variant to map
14
+ * from. Pure Surface→Surface mapping, produces only `MCPServer`. */
15
+ export declare function fromAnthropicMcpConfig(json: AnthropicMcpConfigJson): MCPServer;
@@ -0,0 +1,10 @@
1
+ /** Anthropic MCP config → DeepStrike `MCPServer` (spc_001-07). Anthropic's config format is
2
+ * always a subprocess launch (stdio transport) — there is no http/sse/custom variant to map
3
+ * from. Pure Surface→Surface mapping, produces only `MCPServer`. */
4
+ export function fromAnthropicMcpConfig(json) {
5
+ return {
6
+ name: json.name,
7
+ transport: { kind: "stdio", command: json.command, args: json.args },
8
+ ...(json.env ? { metadata: { env: json.env } } : {}),
9
+ };
10
+ }
@@ -0,0 +1,34 @@
1
+ import { Agent } from "../../agent.js";
2
+ /** spc_007 §2: minimal OpenAI Agents SDK agent-definition shape this adapter accepts. Field
3
+ * names/shape mirror the doc's §2 table left column, not any live OpenAI SDK type import — this
4
+ * adapter reads a serialized agent definition (e.g. `__fixtures__/openai-agent.json`), not a
5
+ * running SDK object. */
6
+ export interface OpenAiAgentJson {
7
+ name: string;
8
+ instructions?: string;
9
+ model?: string;
10
+ tools?: Array<{
11
+ type?: string;
12
+ name: string;
13
+ description?: string;
14
+ parameters?: Record<string, unknown>;
15
+ }>;
16
+ handoffs?: Array<{
17
+ agent: string;
18
+ description?: string;
19
+ }>;
20
+ /** OpenAI-specific: no common `Agent` field for this (spc_007 §2's "Guardrails" row lowers to
21
+ * governance policy, not a Canonical IR field) — preserved under `providerOptions.openai`
22
+ * rather than silently dropped (spc_001 §3: "Unknown fields → never silently discarded"). */
23
+ guardrails?: unknown[];
24
+ }
25
+ /** spc_007 §2: OpenAI Agent → DeepStrike `Agent` (spc_001's Canonical Agent IR entry object).
26
+ * Pure Surface→Surface mapping — produces only `Agent`, never a Kernel-internal type
27
+ * (`Tcb`/`Capability`/etc.), matching this doc's own boundary ("Adapter 代码不得进入 Kernel
28
+ * crate").
29
+ *
30
+ * A JSON tool definition carries no executable body, so each mapped tool's `execute` is a
31
+ * placeholder that throws — this adapter only reconstructs declarative shape (name/description/
32
+ * schema/count), never behavior; wiring a real implementation back onto an OpenAI-sourced tool
33
+ * definition is a separate, later concern outside this card. */
34
+ export declare function fromOpenAiAgent(json: OpenAiAgentJson): Agent;
@@ -0,0 +1,24 @@
1
+ import { Agent } from "../../agent.js";
2
+ import { tool } from "../../tools/index.js";
3
+ /** spc_007 §2: OpenAI Agent → DeepStrike `Agent` (spc_001's Canonical Agent IR entry object).
4
+ * Pure Surface→Surface mapping — produces only `Agent`, never a Kernel-internal type
5
+ * (`Tcb`/`Capability`/etc.), matching this doc's own boundary ("Adapter 代码不得进入 Kernel
6
+ * crate").
7
+ *
8
+ * A JSON tool definition carries no executable body, so each mapped tool's `execute` is a
9
+ * placeholder that throws — this adapter only reconstructs declarative shape (name/description/
10
+ * schema/count), never behavior; wiring a real implementation back onto an OpenAI-sourced tool
11
+ * definition is a separate, later concern outside this card. */
12
+ export function fromOpenAiAgent(json) {
13
+ const tools = (json.tools ?? []).map(t => tool(t.name, t.description ?? "", t.parameters ?? { type: "object", properties: {} }, async () => {
14
+ throw new Error(`tool "${t.name}" has no execution binding — fromOpenAiAgent only carries declarative shape`);
15
+ }));
16
+ return new Agent({
17
+ name: json.name,
18
+ instructions: json.instructions,
19
+ model: json.model,
20
+ tools,
21
+ handoffs: json.handoffs,
22
+ ...(json.guardrails ? { providerOptions: { openai: { guardrails: json.guardrails } } } : {}),
23
+ });
24
+ }
@@ -1,20 +1,3 @@
1
- import type { GovernanceVerdict } from "./kernel.js";
2
- type GovernanceDefaultAction = "allow" | "deny" | "ask_user";
3
- type GovernanceRuleAction = "allow" | "deny" | "ask_user";
4
- export declare class Governance {
5
- private readonly inner;
6
- constructor(defaultAction?: GovernanceDefaultAction);
7
- setIdentity(agentId: string, sessionId: string): void;
8
- addPermissionRule(pattern: string, action: GovernanceRuleAction): void;
9
- blockTool(name: string): void;
10
- setRateLimit(toolName: string, maxCalls: number, windowMs: number): void;
11
- requireParam(toolName: string, paramPath: string): void;
12
- allowParamValues(toolName: string, paramPath: string, allowedValues: string[]): void;
13
- limitParamRange(toolName: string, paramPath: string, min?: number, max?: number): void;
14
- setTime(nowMs: number | bigint): void;
15
- evaluate(toolName: string, argsJson: string): GovernanceVerdict;
16
- }
17
- export type { GovernanceVerdict };
18
1
  type GovernancePolicyAction = "allow" | "deny" | "ask_user";
19
2
  export interface GovernancePolicy {
20
3
  defaultAction?: GovernancePolicyAction;
@@ -71,3 +54,4 @@ export type GovernanceConstraint = {
71
54
  * kernel event payload (snake_case wire fields). Pure — no side effects.
72
55
  */
73
56
  export declare function governancePolicyToKernelEvent(policy: GovernancePolicy): Record<string, unknown>;
57
+ export {};
@@ -1,37 +1,4 @@
1
- import { getKernel } from "./kernel.js";
2
- export class Governance {
3
- inner;
4
- constructor(defaultAction = "allow") {
5
- this.inner = new (getKernel().Governance)(defaultAction);
6
- }
7
- setIdentity(agentId, sessionId) {
8
- this.inner.setIdentity(agentId, sessionId);
9
- }
10
- addPermissionRule(pattern, action) {
11
- this.inner.addPermissionRule(pattern, action);
12
- }
13
- blockTool(name) {
14
- this.inner.blockTool(name);
15
- }
16
- setRateLimit(toolName, maxCalls, windowMs) {
17
- this.inner.setRateLimit(toolName, maxCalls, BigInt(windowMs));
18
- }
19
- requireParam(toolName, paramPath) {
20
- this.inner.requireParam(toolName, paramPath);
21
- }
22
- allowParamValues(toolName, paramPath, allowedValues) {
23
- this.inner.allowParamValues(toolName, paramPath, allowedValues);
24
- }
25
- limitParamRange(toolName, paramPath, min, max) {
26
- this.inner.limitParamRange(toolName, paramPath, min, max);
27
- }
28
- setTime(nowMs) {
29
- this.inner.setTime(typeof nowMs === "bigint" ? nowMs : BigInt(nowMs));
30
- }
31
- evaluate(toolName, argsJson) {
32
- return this.inner.evaluate(toolName, argsJson);
33
- }
34
- }
1
+ // ─── Declarative policy (in-kernel gate) ──────────────────────────────────────
35
2
  /** I5: walk the tool list and bucket each tool into `allowed` / `denied` based on a declarative
36
3
  * policy. A tool is denied when:
37
4
  * - the tool name appears in `vetoes`
@@ -0,0 +1,6 @@
1
+ /** Public guardrail declaration. Execution/lowering belongs to a later governance card. */
2
+ export interface Guardrail {
3
+ name: string;
4
+ description?: string;
5
+ metadata?: Record<string, unknown>;
6
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,12 @@
1
+ import type { JsonSchema } from "./runtime/output-schema.js";
2
+ /** A control-transfer target, deliberately distinct from `HandoffArtifact` sprint evidence. */
3
+ export type AgentRef = string | {
4
+ name: string;
5
+ };
6
+ export interface Handoff {
7
+ agent: AgentRef;
8
+ description?: string;
9
+ inputSchema?: JsonSchema;
10
+ metadata?: Record<string, unknown>;
11
+ providerOptions?: Record<string, unknown>;
12
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -17,10 +17,6 @@
17
17
  * therefore structurally inexpressible, and the whole security audit stays O(1): read the whitelist,
18
18
  * check the one invariant. (`enablePlanTool` is exempt — it toggles a kernel-owned meta-tool,
19
19
  * attention-shaping not capability-granting, so it folds by plain assignment.)
20
- *
21
- * `toolDispatchGate` is deliberately ABSENT from the whitelist and must stay so: it selects whether
22
- * the kernel enforces the exposure surface at dispatch. A proposer that could set it to `"registered"`
23
- * would disable the enforcement half of the ceiling it is otherwise structurally unable to widen.
24
20
  */
25
21
  import { createHash } from "node:crypto";
26
22
  import { validateNudgeRules } from "./nudge.js";
package/dist/index.d.ts CHANGED
@@ -8,8 +8,8 @@ export { PayloadStore } from "./runtime/payload-store.js";
8
8
  export type { PayloadStoreConfig } from "./runtime/payload-store.js";
9
9
  export type { InstructionProfile, NudgeRule, NudgeTrigger } from "./harness/public.js";
10
10
  export type { SignalPolicy } from "./runtime/os-profile.js";
11
- export { CONTEXT_POLICY_VERSION, DEFAULT_CONTEXT_POLICY_V1, PPM_SCALE, contextPolicyV1, normalizeContextPolicyV1, ratioToPpm, } from "./runtime/context-policy.js";
12
- export type { ContextPolicyOverridesV1, ContextPolicyV1, ContextPolicyWireV1, ContextPressureThresholdsV1, } from "./runtime/context-policy.js";
11
+ export { DEFAULT_CONTEXT_POLICY, PPM_SCALE, contextPolicy, normalizeContextPolicy, ratioToPpm, } from "./runtime/context-policy.js";
12
+ export type { ContextPolicyOverrides, ContextPolicy, ContextPolicyWire, ContextPressureThresholds, } from "./runtime/context-policy.js";
13
13
  export { LocalExecutionPlane } from "./runtime/execution-plane.js";
14
14
  export type { ExecutionPlane, RunContext } from "./runtime/execution-plane.js";
15
15
  export { InMemorySessionLog, FileSessionLog } from "./runtime/session-log.js";
@@ -38,12 +38,24 @@ export type { AnthropicProviderConfig } from "./providers/anthropic.js";
38
38
  export { OpenAIProvider } from "./providers/openai.js";
39
39
  export type { OpenAIProviderOptions } from "./providers/openai.js";
40
40
  export { OpenAIResponsesProvider } from "./providers/openai-responses.js";
41
- export { createProvider } from "./providers/catalog.js";
41
+ export { createProvider, createProviderAsync, resolveProviderRuntime, resolveProviderRuntimeAsync } from "./providers/catalog.js";
42
42
  export { UnsupportedModalityError } from "./providers/base.js";
43
43
  export type { CreateProviderOptions, EndpointProfileId } from "./providers/catalog.js";
44
- export { Governance } from "./governance.js";
45
- export type { GovernanceVerdict, GovernancePolicy, GovernanceConstraint } from "./governance.js";
44
+ export { createProviderRequestPlan, createProviderRequestPlanForProvider, estimateProviderPromptTokens, measurementForPlan, normalizeProviderUsage, priceProviderUsage, recordPromptMeasurement } from "./providers/request-plan.js";
45
+ export type { CostObservation, NormalizedProviderUsage, PricingSnapshot, ProviderRequestEndpoint, ProviderRequestPlan, RecordedPromptMeasurement } from "./providers/request-plan.js";
46
+ export type { GovernancePolicy, GovernanceConstraint } from "./governance.js";
46
47
  export { AgentPool } from "./collaboration/pool.js";
48
+ export { Agent } from "./agent.js";
49
+ export type { AgentOptions, AgentMemory, MemoryReference, ModelRef, ModelRequirement } from "./agent.js";
50
+ export { lowerAgent, normalizeAgent } from "./agent-ir.js";
51
+ export type { AgentCapabilityIR, AgentDefinition, AgentLoweringInputs, AgentMemoryIR, AgentSpec, AgentToolDefinition, AgentToolIR } from "./agent-ir.js";
52
+ export type { Guardrail } from "./guardrail.js";
53
+ export type { MCPServer, McpTransport } from "./mcp-server.js";
54
+ export type { Knowledge, KnowledgeSourceRef } from "./knowledge/public.js";
55
+ export type { AgentRef, Handoff } from "./handoff-target.js";
56
+ export type { Session } from "./session.js";
47
57
  export type { RuntimeSignal, SignalClaim, SignalDeliveryReceipt, SignalSource, } from "./signals/types.js";
48
- export type { Message, ToolCall, ToolResult, ToolSchema, ContentPart, TextPart, ImagePart, AudioPart, StreamEvent, TextDelta, ThinkingDelta, ToolCallEvent, ToolChunk, ToolDeltaEvent, ToolSuspendEvent, ToolResultEvent, ToolAuditFailedEvent, DoneEvent, ErrorEvent, PermissionRequestEvent, PermissionResolvedEvent, PermissionResponse, EntropySample, EntropySampleEvent, EntropyAlertEvent, EntropyWatchOptions, LLMProvider, RetryConfig, TokenUsage, } from "./types.js";
49
- export type { WorkflowSpec, WorkflowNodeSpec, WorkflowDependencyPolicy, WorkflowNodeStatus, WorkflowNodeOutcome, WorkflowOutcome, } from "./types/agent.js";
58
+ export type { Message, ToolCall, ToolResult, ToolSchema, ContentPart, TextPart, ImagePart, AudioPart, MediaSource, ContentBlockText, ContentBlockImage, ContentBlockAudio, ContentBlockVideo, ContentBlockFile, StreamEvent, TextDelta, ThinkingDelta, ToolCallEvent, ToolChunk, ToolDeltaEvent, ToolSuspendEvent, ToolResultEvent, ToolAuditFailedEvent, DoneEvent, ErrorEvent, PermissionRequestEvent, PermissionResolvedEvent, PermissionResponse, EntropySample, EntropySampleEvent, EntropyAlertEvent, EntropyWatchOptions, LLMProvider, RetryConfig, TokenUsage, } from "./types.js";
59
+ export { DurableContentError, decodeDurableContent, decodeDurableToolResult, encodeDurableContent, encodeDurableToolResult, toolOutputBlocksToDurable, durableBlocksToToolOutput, } from "./runtime/durable-content.js";
60
+ export type { DurableContent, DurableContentBlock, DurableSource, DurableToolResult } from "./runtime/durable-content.js";
61
+ export type { WorkflowSpec, WorkflowNodeSpec, SchedulingFactors, WorkflowDependencyPolicy, WorkflowNodeStatus, WorkflowNodeOutcome, WorkflowOutcome, } from "./types/agent.js";
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@
6
6
  // ║ @deepstrike/sdk/providers — backend provider classes + profiles ║
7
7
  // ║ @deepstrike/sdk/workflow — orchestration, reducers, contracts, specs ║
8
8
  // ║ @deepstrike/sdk/planes — worktree / sandbox / mcp / vpc planes ║
9
- // ║ @deepstrike/sdk/memory — dream + working memory, knowledge sources
9
+ // ║ @deepstrike/sdk/memory — durable + working memory, knowledge sources
10
10
  // ║ @deepstrike/sdk/harness — eval harnesses + judge ║
11
11
  // ║ @deepstrike/sdk/os — profiles, diagnostics, signals, replay tests ║
12
12
  // ╚══════════════════════════════════════════════════════════════════════════╝
@@ -16,7 +16,7 @@ export { runAgent, runFanout } from "./runtime/facade.js";
16
16
  export { runLoop, LoopDriver, foldLoopState } from "./runtime/loop-driver.js";
17
17
  export { RuntimeRunner, collectText } from "./runtime/runner.js";
18
18
  export { PayloadStore } from "./runtime/payload-store.js";
19
- export { CONTEXT_POLICY_VERSION, DEFAULT_CONTEXT_POLICY_V1, PPM_SCALE, contextPolicyV1, normalizeContextPolicyV1, ratioToPpm, } from "./runtime/context-policy.js";
19
+ export { DEFAULT_CONTEXT_POLICY, PPM_SCALE, contextPolicy, normalizeContextPolicy, ratioToPpm, } from "./runtime/context-policy.js";
20
20
  // ── Execution plane + session log (the defaults) ────────────────────────────
21
21
  export { LocalExecutionPlane } from "./runtime/execution-plane.js";
22
22
  export { InMemorySessionLog, FileSessionLog } from "./runtime/session-log.js";
@@ -37,10 +37,13 @@ export { safeTool, ok, fail, ToolError, formatToolError } from "./tools/errors.j
37
37
  export { AnthropicProvider } from "./providers/anthropic.js";
38
38
  export { OpenAIProvider } from "./providers/openai.js";
39
39
  export { OpenAIResponsesProvider } from "./providers/openai-responses.js";
40
- export { createProvider } from "./providers/catalog.js";
40
+ export { createProvider, createProviderAsync, resolveProviderRuntime, resolveProviderRuntimeAsync } from "./providers/catalog.js";
41
41
  export { UnsupportedModalityError } from "./providers/base.js";
42
- // ── Governance ──────────────────────────────────────────────────────────────
43
- export { Governance } from "./governance.js";
42
+ export { createProviderRequestPlan, createProviderRequestPlanForProvider, estimateProviderPromptTokens, measurementForPlan, normalizeProviderUsage, priceProviderUsage, recordPromptMeasurement } from "./providers/request-plan.js";
44
43
  // ── Multi-agent primitive ───────────────────────────────────────────────────
45
44
  // Parallel fan-out / sub-agent delegation. The full orchestration layer is in `@deepstrike/sdk/workflow`.
46
45
  export { AgentPool } from "./collaboration/pool.js";
46
+ // ── Ecosystem Surface Contract (spc_001) ────────────────────────────────────
47
+ export { Agent } from "./agent.js";
48
+ export { lowerAgent, normalizeAgent } from "./agent-ir.js";
49
+ export { DurableContentError, decodeDurableContent, decodeDurableToolResult, encodeDurableContent, encodeDurableToolResult, toolOutputBlocksToDurable, durableBlocksToToolOutput, } from "./runtime/durable-content.js";
package/dist/kernel.d.ts CHANGED
@@ -1,13 +1,8 @@
1
1
  import type { Message } from "./types.js";
2
- export interface GovernanceVerdict {
3
- kind: "allow" | "deny" | "rate_limited" | "ask_user";
4
- reason?: string;
5
- retryAfterMs?: number;
6
- }
7
2
  /**
8
3
  * M2 资源配额 — declarative resource limits enforced at the kernel's single syscall trap.
9
4
  *
10
- * Installed through the versioned JSON event ABI (`set_resource_quota`), not a side-channel
5
+ * Installed through the canonical JSON event contract (`set_resource_quota`), not a side-channel
11
6
  * setter, so quota config is replayable and session-loggable like governance/scheduler config.
12
7
  * Every field is optional; an omitted field imposes no limit, and omitting the quota entirely
13
8
  * preserves the pre-M2 behavior of admitting all spawn / memory-write syscalls.
@@ -35,7 +30,7 @@ export interface ResourceQuota {
35
30
  *
36
31
  * Included in canonical operation configuration, so memory policy is replayable and
37
32
  * kernel-enforced. Omitted fields retain the canonical defaults. Host storage belongs to the
38
- * configured `DreamStore`, never to this contract.
33
+ * configured `MemoryStore`, never to this contract.
39
34
  */
40
35
  export interface MemoryPolicy {
41
36
  /** Age after which a recalled memory is flagged stale (days). */
@@ -52,17 +47,6 @@ export interface MemoryPolicy {
52
47
  * `promotion_suggested` for a recalled record. Omitted = suggestions disabled. */
53
48
  promotionRecallThreshold?: number;
54
49
  }
55
- export interface GovernanceInstance {
56
- setIdentity(agentId: string, sessionId: string): void;
57
- addPermissionRule(pattern: string, action: "allow" | "deny" | "ask_user"): void;
58
- blockTool(name: string): void;
59
- setRateLimit(toolName: string, maxCalls: number, windowMs: bigint): void;
60
- requireParam(toolName: string, paramPath: string): void;
61
- allowParamValues(toolName: string, paramPath: string, allowedValues: string[]): void;
62
- limitParamRange(toolName: string, paramPath: string, min?: number, max?: number): void;
63
- setTime(nowMs: bigint): void;
64
- evaluate(toolName: string, argsJson: string): GovernanceVerdict;
65
- }
66
50
  export interface RuntimeSignal {
67
51
  id: string;
68
52
  source: "cron" | "gateway" | "heartbeat" | "custom";
@@ -160,9 +144,7 @@ export interface CanonicalKernelInstance {
160
144
  terminalJson(): string | undefined;
161
145
  }
162
146
  interface KernelModule {
163
- Governance: new (defaultAction?: "allow" | "deny" | "ask_user") => GovernanceInstance;
164
147
  CanonicalKernel: new () => CanonicalKernelInstance;
165
- kernelAbiVersion(): number;
166
148
  SignalRouter: new (maxQueueSize: number) => SignalRouterInstance;
167
149
  buildEvalMessages(goal: string, criteria: NativeCriterion[], result: string, attempt: number, extractSkillOnPass: boolean): Message[];
168
150
  parseVerdict(content: string): Verdict;
@@ -0,0 +1,29 @@
1
+ import type { KnowledgeSource } from "./source.js";
2
+ /** Public knowledge descriptor, distinct from the executable `KnowledgeSource` retriever. */
3
+ export type KnowledgeSourceRef = {
4
+ kind: "file";
5
+ path: string;
6
+ } | {
7
+ kind: "directory";
8
+ path: string;
9
+ } | {
10
+ kind: "text";
11
+ content: string;
12
+ } | {
13
+ kind: "url";
14
+ url: string;
15
+ } | {
16
+ kind: "vector";
17
+ retriever: KnowledgeSource;
18
+ } | {
19
+ kind: "custom";
20
+ [key: string]: unknown;
21
+ };
22
+ export interface Knowledge {
23
+ id?: string;
24
+ name?: string;
25
+ source: KnowledgeSourceRef;
26
+ description?: string;
27
+ metadata?: Record<string, unknown>;
28
+ providerOptions?: Record<string, unknown>;
29
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,28 @@
1
+ /** spc_001 §2.3: public MCP server contract. A parallel new type — not a replacement for
2
+ * `McpServerConfig` (`runtime/mcp-proxy-plane.ts`), which is the stdio-only execution-layer
3
+ * config `McpProxyPlane` actually spawns. `MCPServer` is the public IR shape; lowering it down
4
+ * to `McpServerConfig` (or an equivalent per transport kind) is separate, later work. */
5
+ export type McpTransport = {
6
+ kind: "stdio";
7
+ command: string;
8
+ args?: string[];
9
+ } | {
10
+ kind: "http";
11
+ url: string;
12
+ } | {
13
+ kind: "sse";
14
+ url: string;
15
+ } | {
16
+ kind: "custom";
17
+ [key: string]: unknown;
18
+ };
19
+ export interface MCPServer {
20
+ name?: string;
21
+ transport: McpTransport;
22
+ tools?: string[];
23
+ resources?: boolean;
24
+ prompts?: boolean;
25
+ auth?: Record<string, unknown>;
26
+ metadata?: Record<string, unknown>;
27
+ providerOptions?: Record<string, unknown>;
28
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -6,7 +6,7 @@
6
6
  * Design principles:
7
7
  * - Kernel defines memory types and validation rules
8
8
  * - SDK performs I/O and selection
9
- * - Semantic reranking remains an optional DreamStore capability
9
+ * - Semantic reranking remains an optional MemoryStore capability
10
10
  */
11
11
  import type { MemoryQuery, MemoryRecall, MemoryRecord } from "./protocols.js";
12
12
  export type { MemoryKind, MemoryQuery, MemoryRecall, MemoryRecord, } from "./protocols.js";
@@ -14,7 +14,7 @@ export type { MemoryKind, MemoryQuery, MemoryRecall, MemoryRecord, } from "./pro
14
14
  * Select relevant memories for the current context.
15
15
  *
16
16
  * The reference selector is deterministic and provider-independent: lexical overlap first,
17
- * recency second. Semantic/embedding reranking belongs in a DreamStore plugin.
17
+ * recency second. Semantic/embedding reranking belongs in a MemoryStore plugin.
18
18
  *
19
19
  * @param query - Memory query from kernel
20
20
  * @param memoryIndex - Memory index entries
@@ -6,14 +6,14 @@
6
6
  * Design principles:
7
7
  * - Kernel defines memory types and validation rules
8
8
  * - SDK performs I/O and selection
9
- * - Semantic reranking remains an optional DreamStore capability
9
+ * - Semantic reranking remains an optional MemoryStore capability
10
10
  */
11
11
  import { rankMemories } from "./ranking.js";
12
12
  /**
13
13
  * Select relevant memories for the current context.
14
14
  *
15
15
  * The reference selector is deterministic and provider-independent: lexical overlap first,
16
- * recency second. Semantic/embedding reranking belongs in a DreamStore plugin.
16
+ * recency second. Semantic/embedding reranking belongs in a MemoryStore plugin.
17
17
  *
18
18
  * @param query - Memory query from kernel
19
19
  * @param memoryIndex - Memory index entries
@@ -0,0 +1,16 @@
1
+ import type { Memory, MemoryRecord, MemoryScope, MemorySearchOptions, MemoryStore } from "./protocols.js";
2
+ /**
3
+ * Binds the host storage protocol to the public Memory contract for one agent and namespace.
4
+ * This is deliberately an SDK adapter: it does not lower memory mutations into the Kernel.
5
+ */
6
+ export declare class DurableMemory implements Memory {
7
+ private readonly store;
8
+ private readonly agentId;
9
+ private readonly scope;
10
+ readonly namespace: string;
11
+ constructor(store: MemoryStore, agentId: string, scope: MemoryScope);
12
+ search(query: string, options?: MemorySearchOptions): Promise<MemoryRecord[]>;
13
+ get(id: string): Promise<MemoryRecord | null>;
14
+ put(record: MemoryRecord): Promise<void>;
15
+ delete(id: string): Promise<void>;
16
+ }