@deepstrike/sdk 0.2.70 → 0.2.72

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 (77) hide show
  1. package/README.md +57 -41
  2. package/dist/advanced/public.d.ts +24 -0
  3. package/dist/advanced/public.js +18 -0
  4. package/dist/agent-facade.d.ts +96 -0
  5. package/dist/agent-facade.js +317 -0
  6. package/dist/agent-ir.d.ts +11 -5
  7. package/dist/agent-ir.js +42 -26
  8. package/dist/canonical-prefix-allowlist.d.ts +6 -0
  9. package/dist/canonical-prefix-allowlist.js +30 -0
  10. package/dist/evals/public.d.ts +50 -0
  11. package/dist/evals/public.js +25 -0
  12. package/dist/guardrail.d.ts +4 -1
  13. package/dist/handoff-target.d.ts +2 -0
  14. package/dist/handoff-target.js +7 -1
  15. package/dist/index.d.ts +14 -30
  16. package/dist/index.js +7 -16
  17. package/dist/kernel.d.ts +2 -2
  18. package/dist/knowledge/public.d.ts +2 -0
  19. package/dist/knowledge/public.js +1 -1
  20. package/dist/knowledge/source.d.ts +7 -0
  21. package/dist/knowledge/source.js +20 -1
  22. package/dist/memory/protocols.d.ts +2 -2
  23. package/dist/projection-pairs.d.ts +43 -0
  24. package/dist/projection-pairs.js +9 -0
  25. package/dist/providers/anthropic-adapter.d.ts +2 -2
  26. package/dist/providers/anthropic.d.ts +4 -4
  27. package/dist/providers/base.d.ts +5 -5
  28. package/dist/providers/content-normalization.d.ts +4 -4
  29. package/dist/providers/gemini-adapter.d.ts +2 -2
  30. package/dist/providers/gemini.d.ts +3 -3
  31. package/dist/providers/ollama-adapter.d.ts +2 -2
  32. package/dist/providers/ollama.d.ts +2 -2
  33. package/dist/providers/openai-chat.d.ts +4 -4
  34. package/dist/providers/openai-responses-adapter.d.ts +2 -2
  35. package/dist/providers/openai-responses.d.ts +2 -2
  36. package/dist/providers/openai.d.ts +4 -4
  37. package/dist/providers/protocol-adapter.d.ts +2 -2
  38. package/dist/providers/protocol-capabilities.d.ts +1 -0
  39. package/dist/providers/protocol-capabilities.js +3 -0
  40. package/dist/providers/public.d.ts +4 -2
  41. package/dist/providers/public.js +2 -1
  42. package/dist/providers/replay-validator.d.ts +3 -3
  43. package/dist/runtime/archive.d.ts +7 -7
  44. package/dist/runtime/canonical-kernel-step.d.ts +2 -2
  45. package/dist/runtime/context-manager.d.ts +56 -0
  46. package/dist/runtime/context-manager.js +112 -0
  47. package/dist/runtime/eval.d.ts +2 -2
  48. package/dist/runtime/kernel-step.d.ts +5 -5
  49. package/dist/runtime/provider-replay.d.ts +2 -2
  50. package/dist/runtime/public.d.ts +22 -0
  51. package/dist/runtime/public.js +11 -0
  52. package/dist/runtime/replay-fixture.d.ts +3 -3
  53. package/dist/runtime/replay-fixture.js +1 -1
  54. package/dist/runtime/replay-provider.d.ts +4 -4
  55. package/dist/runtime/replay-provider.js +1 -1
  56. package/dist/runtime/runner.d.ts +17 -5
  57. package/dist/runtime/runner.js +110 -37
  58. package/dist/runtime/session-log.d.ts +1 -1
  59. package/dist/runtime/session-repair.d.ts +2 -2
  60. package/dist/runtime/workflow-control-flow.d.ts +1 -1
  61. package/dist/runtime/workflow-control-flow.js +16 -2
  62. package/dist/runtime-classification.d.ts +161 -0
  63. package/dist/runtime-classification.js +66 -0
  64. package/dist/runtime-language.d.ts +32 -0
  65. package/dist/runtime-language.js +51 -0
  66. package/dist/skill.d.ts +31 -5
  67. package/dist/types/agent.d.ts +17 -4
  68. package/dist/types.d.ts +22 -12
  69. package/dist/workflow/definition.d.ts +19 -0
  70. package/dist/workflow/definition.js +29 -0
  71. package/dist/workflow/public.d.ts +3 -1
  72. package/dist/workflow/public.js +1 -0
  73. package/package.json +23 -2
  74. package/dist/compat/anthropic/mcp.d.ts +0 -15
  75. package/dist/compat/anthropic/mcp.js +0 -10
  76. package/dist/compat/openai/agent.d.ts +0 -34
  77. package/dist/compat/openai/agent.js +0 -24
@@ -0,0 +1,161 @@
1
+ /** SPC-028-02: cross-layer object classification registry. */
2
+ export type RuntimeDomain = "public" | "host" | "kernel" | "provider";
3
+ export type RuntimeAuthority = "public-agent" | "host-runtime" | "kernel" | "none";
4
+ export type RuntimeRepresentation = "semantic" | "projection" | "measurement" | "evidence" | "wire" | "state-truth" | "snapshot";
5
+ export type RuntimeDurability = "durable" | "ephemeral" | "rebuildable" | "append-only";
6
+ export interface RuntimeObjectClassification {
7
+ domain: RuntimeDomain;
8
+ authority: RuntimeAuthority;
9
+ representation: RuntimeRepresentation;
10
+ durability: RuntimeDurability;
11
+ identity: string;
12
+ causation: string;
13
+ replay: string;
14
+ }
15
+ export declare const RUNTIME_OBJECT_CLASSIFICATIONS: {
16
+ readonly AgentDefinition: {
17
+ readonly domain: "public";
18
+ readonly authority: "public-agent";
19
+ readonly representation: "semantic";
20
+ readonly durability: "rebuildable";
21
+ readonly identity: "agent name or host-assigned agent identity";
22
+ readonly causation: "agent declaration";
23
+ readonly replay: "input to AgentSpec projection";
24
+ };
25
+ readonly AgentSpec: {
26
+ readonly domain: "host";
27
+ readonly authority: "host-runtime";
28
+ readonly representation: "semantic";
29
+ readonly durability: "rebuildable";
30
+ readonly identity: "agent identity";
31
+ readonly causation: "AgentDefinition plus host bindings";
32
+ readonly replay: "re-derived from public definition and runtime bindings";
33
+ };
34
+ readonly StoredMessageState: {
35
+ readonly domain: "host";
36
+ readonly authority: "host-runtime";
37
+ readonly representation: "state-truth";
38
+ readonly durability: "durable";
39
+ readonly identity: "message identity";
40
+ readonly causation: "accepted session or run input";
41
+ readonly replay: "replayed from durable message history";
42
+ };
43
+ readonly ModelMessage: {
44
+ readonly domain: "host";
45
+ readonly authority: "host-runtime";
46
+ readonly representation: "semantic";
47
+ readonly durability: "rebuildable";
48
+ readonly identity: "message identity";
49
+ readonly causation: "stored or runtime message projection";
50
+ readonly replay: "re-rendered from message state";
51
+ };
52
+ readonly ProviderRequestPlan: {
53
+ readonly domain: "host";
54
+ readonly authority: "none";
55
+ readonly representation: "projection";
56
+ readonly durability: "rebuildable";
57
+ readonly identity: "request fingerprint";
58
+ readonly causation: "ContextCandidate plus ResolvedProviderRoute";
59
+ readonly replay: "re-rendered and re-encoded from inputs";
60
+ };
61
+ readonly PromptMeasurement: {
62
+ readonly domain: "host";
63
+ readonly authority: "host-runtime";
64
+ readonly representation: "measurement";
65
+ readonly durability: "durable";
66
+ readonly identity: "request fingerprint";
67
+ readonly causation: "prepared provider request";
68
+ readonly replay: "reused only on exact fingerprint match";
69
+ };
70
+ readonly ProviderUsage: {
71
+ readonly domain: "provider";
72
+ readonly authority: "host-runtime";
73
+ readonly representation: "measurement";
74
+ readonly durability: "durable";
75
+ readonly identity: "provider attempt identity";
76
+ readonly causation: "decoded provider response";
77
+ readonly replay: "retained as response evidence";
78
+ };
79
+ readonly ResolvedProviderRoute: {
80
+ readonly domain: "provider";
81
+ readonly authority: "host-runtime";
82
+ readonly representation: "projection";
83
+ readonly durability: "durable";
84
+ readonly identity: "route identity";
85
+ readonly causation: "model resolution";
86
+ readonly replay: "frozen on ProviderAttempt";
87
+ };
88
+ readonly ProviderAttempt: {
89
+ readonly domain: "host";
90
+ readonly authority: "host-runtime";
91
+ readonly representation: "evidence";
92
+ readonly durability: "append-only";
93
+ readonly identity: "effect identity plus attempt sequence";
94
+ readonly causation: "CallProvider effect";
95
+ readonly replay: "evidence for one physical execution";
96
+ };
97
+ readonly KernelInput: {
98
+ readonly domain: "kernel";
99
+ readonly authority: "kernel";
100
+ readonly representation: "wire";
101
+ readonly durability: "append-only";
102
+ readonly identity: "input identity";
103
+ readonly causation: "host submission";
104
+ readonly replay: "durable input sequence";
105
+ };
106
+ readonly KernelEffect: {
107
+ readonly domain: "kernel";
108
+ readonly authority: "kernel";
109
+ readonly representation: "wire";
110
+ readonly durability: "append-only";
111
+ readonly identity: "effect identity";
112
+ readonly causation: "kernel decision";
113
+ readonly replay: "journal decision chain";
114
+ };
115
+ readonly BudgetLedger: {
116
+ readonly domain: "kernel";
117
+ readonly authority: "kernel";
118
+ readonly representation: "state-truth";
119
+ readonly durability: "durable";
120
+ readonly identity: "operation or group budget identity";
121
+ readonly causation: "accepted kernel facts";
122
+ readonly replay: "folded from journal facts";
123
+ };
124
+ readonly Journal: {
125
+ readonly domain: "kernel";
126
+ readonly authority: "kernel";
127
+ readonly representation: "state-truth";
128
+ readonly durability: "append-only";
129
+ readonly identity: "journal sequence and digest";
130
+ readonly causation: "kernel inputs and facts";
131
+ readonly replay: "source of durable state truth";
132
+ };
133
+ readonly Checkpoint: {
134
+ readonly domain: "kernel";
135
+ readonly authority: "kernel";
136
+ readonly representation: "snapshot";
137
+ readonly durability: "durable";
138
+ readonly identity: "checkpoint identity and journal head";
139
+ readonly causation: "checkpoint boundary";
140
+ readonly replay: "restore seed verified against journal";
141
+ };
142
+ readonly SessionLog: {
143
+ readonly domain: "host";
144
+ readonly authority: "none";
145
+ readonly representation: "evidence";
146
+ readonly durability: "append-only";
147
+ readonly identity: "session identity and event sequence";
148
+ readonly causation: "host observations";
149
+ readonly replay: "evidence only; never recovery authority";
150
+ };
151
+ readonly EvaluationRun: {
152
+ readonly domain: "host";
153
+ readonly authority: "host-runtime";
154
+ readonly representation: "semantic";
155
+ readonly durability: "durable";
156
+ readonly identity: "evaluation run identity";
157
+ readonly causation: "public Eval request";
158
+ readonly replay: "replayed from dataset and captured evidence";
159
+ };
160
+ };
161
+ export type RuntimeObjectName = keyof typeof RUNTIME_OBJECT_CLASSIFICATIONS;
@@ -0,0 +1,66 @@
1
+ export const RUNTIME_OBJECT_CLASSIFICATIONS = {
2
+ AgentDefinition: {
3
+ domain: "public", authority: "public-agent", representation: "semantic", durability: "rebuildable",
4
+ identity: "agent name or host-assigned agent identity", causation: "agent declaration", replay: "input to AgentSpec projection",
5
+ },
6
+ AgentSpec: {
7
+ domain: "host", authority: "host-runtime", representation: "semantic", durability: "rebuildable",
8
+ identity: "agent identity", causation: "AgentDefinition plus host bindings", replay: "re-derived from public definition and runtime bindings",
9
+ },
10
+ StoredMessageState: {
11
+ domain: "host", authority: "host-runtime", representation: "state-truth", durability: "durable",
12
+ identity: "message identity", causation: "accepted session or run input", replay: "replayed from durable message history",
13
+ },
14
+ ModelMessage: {
15
+ domain: "host", authority: "host-runtime", representation: "semantic", durability: "rebuildable",
16
+ identity: "message identity", causation: "stored or runtime message projection", replay: "re-rendered from message state",
17
+ },
18
+ ProviderRequestPlan: {
19
+ domain: "host", authority: "none", representation: "projection", durability: "rebuildable",
20
+ identity: "request fingerprint", causation: "ContextCandidate plus ResolvedProviderRoute", replay: "re-rendered and re-encoded from inputs",
21
+ },
22
+ PromptMeasurement: {
23
+ domain: "host", authority: "host-runtime", representation: "measurement", durability: "durable",
24
+ identity: "request fingerprint", causation: "prepared provider request", replay: "reused only on exact fingerprint match",
25
+ },
26
+ ProviderUsage: {
27
+ domain: "provider", authority: "host-runtime", representation: "measurement", durability: "durable",
28
+ identity: "provider attempt identity", causation: "decoded provider response", replay: "retained as response evidence",
29
+ },
30
+ ResolvedProviderRoute: {
31
+ domain: "provider", authority: "host-runtime", representation: "projection", durability: "durable",
32
+ identity: "route identity", causation: "model resolution", replay: "frozen on ProviderAttempt",
33
+ },
34
+ ProviderAttempt: {
35
+ domain: "host", authority: "host-runtime", representation: "evidence", durability: "append-only",
36
+ identity: "effect identity plus attempt sequence", causation: "CallProvider effect", replay: "evidence for one physical execution",
37
+ },
38
+ KernelInput: {
39
+ domain: "kernel", authority: "kernel", representation: "wire", durability: "append-only",
40
+ identity: "input identity", causation: "host submission", replay: "durable input sequence",
41
+ },
42
+ KernelEffect: {
43
+ domain: "kernel", authority: "kernel", representation: "wire", durability: "append-only",
44
+ identity: "effect identity", causation: "kernel decision", replay: "journal decision chain",
45
+ },
46
+ BudgetLedger: {
47
+ domain: "kernel", authority: "kernel", representation: "state-truth", durability: "durable",
48
+ identity: "operation or group budget identity", causation: "accepted kernel facts", replay: "folded from journal facts",
49
+ },
50
+ Journal: {
51
+ domain: "kernel", authority: "kernel", representation: "state-truth", durability: "append-only",
52
+ identity: "journal sequence and digest", causation: "kernel inputs and facts", replay: "source of durable state truth",
53
+ },
54
+ Checkpoint: {
55
+ domain: "kernel", authority: "kernel", representation: "snapshot", durability: "durable",
56
+ identity: "checkpoint identity and journal head", causation: "checkpoint boundary", replay: "restore seed verified against journal",
57
+ },
58
+ SessionLog: {
59
+ domain: "host", authority: "none", representation: "evidence", durability: "append-only",
60
+ identity: "session identity and event sequence", causation: "host observations", replay: "evidence only; never recovery authority",
61
+ },
62
+ EvaluationRun: {
63
+ domain: "host", authority: "host-runtime", representation: "semantic", durability: "durable",
64
+ identity: "evaluation run identity", causation: "public Eval request", replay: "replayed from dataset and captured evidence",
65
+ },
66
+ };
@@ -0,0 +1,32 @@
1
+ /**
2
+ * SPC-028-01: the normative vocabulary for the four runtime language layers.
3
+ *
4
+ * Terms are names, not a second semantic authority. The registry is consumed by
5
+ * conformance tests and documentation tooling so each term has one primary layer.
6
+ */
7
+ export declare const RUNTIME_VOCABULARY: {
8
+ readonly version: "0.2.72";
9
+ readonly public: readonly ["Agent", "Model", "Run", "Session", "Tool", "Skill", "Memory", "Knowledge", "MCPServer", "Handoff", "Workflow", "Guardrail", "Eval", "Dataset", "Evaluator", "Output", "Usage"];
10
+ readonly host: readonly ["AgentSpec", "Context", "ContextPlan", "Capability", "ModelRoute", "Invocation", "ProviderAttempt", "Measurement", "Evidence", "Artifact", "Evaluation", "Promotion", "ExecutionPlane"];
11
+ readonly kernel: readonly ["Operation", "Intent", "Decision", "Effect", "Fact", "Settlement", "Task", "Capability", "Budget", "Journal", "Checkpoint", "StateTransition"];
12
+ readonly provider: readonly ["Model", "Provider", "Endpoint", "Protocol", "Route", "Adapter", "Request", "Response", "Usage", "ReplayEvidence"];
13
+ readonly primaryDomain: {
14
+ readonly Model: "public";
15
+ readonly Usage: "public";
16
+ readonly Capability: "host";
17
+ readonly Route: "host";
18
+ };
19
+ readonly verbs: {
20
+ readonly resolve: "select or answer a runtime object at a boundary";
21
+ readonly render: "project semantic state into model-facing input";
22
+ readonly encode: "map semantic input into a wire request";
23
+ readonly execute: "perform one physical provider or external call";
24
+ readonly decode: "extract semantic output and retained wire evidence";
25
+ readonly normalize: "map vendor data into the controlled runtime vocabulary";
26
+ readonly settle: "apply accounting policy to an observed measurement";
27
+ };
28
+ };
29
+ export type RuntimeLanguage = typeof RUNTIME_VOCABULARY;
30
+ export type RuntimeLanguageDomain = "public" | "host" | "kernel" | "provider";
31
+ /** Returns all layer terms while preserving the registry's primary-domain order. */
32
+ export declare function runtimeVocabularyTerms(): readonly string[];
@@ -0,0 +1,51 @@
1
+ /**
2
+ * SPC-028-01: the normative vocabulary for the four runtime language layers.
3
+ *
4
+ * Terms are names, not a second semantic authority. The registry is consumed by
5
+ * conformance tests and documentation tooling so each term has one primary layer.
6
+ */
7
+ export const RUNTIME_VOCABULARY = {
8
+ version: "0.2.72",
9
+ public: [
10
+ "Agent", "Model", "Run", "Session", "Tool", "Skill", "Memory", "Knowledge",
11
+ "MCPServer", "Handoff", "Workflow", "Guardrail", "Eval", "Dataset", "Evaluator",
12
+ "Output", "Usage",
13
+ ],
14
+ host: [
15
+ "AgentSpec", "Context", "ContextPlan", "Capability", "ModelRoute", "Invocation",
16
+ "ProviderAttempt", "Measurement", "Evidence", "Artifact", "Evaluation", "Promotion",
17
+ "ExecutionPlane",
18
+ ],
19
+ kernel: [
20
+ "Operation", "Intent", "Decision", "Effect", "Fact", "Settlement", "Task", "Capability",
21
+ "Budget", "Journal", "Checkpoint", "StateTransition",
22
+ ],
23
+ provider: [
24
+ "Model", "Provider", "Endpoint", "Protocol", "Route", "Adapter", "Request", "Response",
25
+ "Usage", "ReplayEvidence",
26
+ ],
27
+ primaryDomain: {
28
+ Model: "public",
29
+ Usage: "public",
30
+ Capability: "host",
31
+ Route: "host",
32
+ },
33
+ verbs: {
34
+ resolve: "select or answer a runtime object at a boundary",
35
+ render: "project semantic state into model-facing input",
36
+ encode: "map semantic input into a wire request",
37
+ execute: "perform one physical provider or external call",
38
+ decode: "extract semantic output and retained wire evidence",
39
+ normalize: "map vendor data into the controlled runtime vocabulary",
40
+ settle: "apply accounting policy to an observed measurement",
41
+ },
42
+ };
43
+ /** Returns all layer terms while preserving the registry's primary-domain order. */
44
+ export function runtimeVocabularyTerms() {
45
+ return [
46
+ ...RUNTIME_VOCABULARY.public,
47
+ ...RUNTIME_VOCABULARY.host,
48
+ ...RUNTIME_VOCABULARY.kernel,
49
+ ...RUNTIME_VOCABULARY.provider,
50
+ ];
51
+ }
package/dist/skill.d.ts CHANGED
@@ -1,13 +1,39 @@
1
+ export interface SkillResource {
2
+ name: string;
3
+ uri?: string;
4
+ content?: string;
5
+ metadata?: Record<string, unknown>;
6
+ }
7
+ export interface SkillScript {
8
+ name: string;
9
+ command: string;
10
+ description?: string;
11
+ metadata?: Record<string, unknown>;
12
+ }
13
+ export type SkillTool = string | {
14
+ name: string;
15
+ description?: string;
16
+ inputSchema?: Record<string, unknown>;
17
+ };
18
+ export type SkillMCPServer = string | {
19
+ name: string;
20
+ transport: Record<string, unknown>;
21
+ };
22
+ export type SkillKnowledge = string | {
23
+ name: string;
24
+ content?: string;
25
+ source?: unknown;
26
+ };
1
27
  /** spc_001 §2.4: public Skill contract, built directly on `SKILL.md`-style frontmatter files. */
2
28
  export interface Skill {
3
29
  name: string;
4
30
  description?: string;
5
31
  instructions?: string;
6
- resources?: unknown[];
7
- scripts?: unknown[];
8
- tools?: unknown[];
9
- mcpServers?: unknown[];
10
- knowledge?: unknown[];
32
+ resources?: SkillResource[];
33
+ scripts?: SkillScript[];
34
+ tools?: SkillTool[];
35
+ mcpServers?: SkillMCPServer[];
36
+ knowledge?: SkillKnowledge[];
11
37
  metadata?: Record<string, unknown>;
12
38
  providerOptions?: Record<string, unknown>;
13
39
  }
@@ -1,4 +1,4 @@
1
- import type { ProviderMessage, ToolSchema } from "../types.js";
1
+ import type { ModelMessage, ToolSchema } from "../types.js";
2
2
  export type KernelAgentRole = "explore" | "plan" | "implement" | "verify" | "custom";
3
3
  export type AgentIsolation = "shared" | "read_only" | "worktree" | "remote";
4
4
  export type ContextInheritance = "none" | "system_only" | "full";
@@ -86,7 +86,7 @@ export interface AgentProcessChangedObservation {
86
86
  }
87
87
  export interface LoopResult {
88
88
  termination: TerminationReason | string;
89
- finalMessage?: ProviderMessage;
89
+ finalMessage?: ModelMessage;
90
90
  turnsUsed: number;
91
91
  totalTokensUsed: number;
92
92
  /** loop-control loop stop signal: a loop iteration sets `false` to end the loop before `max_iters`.
@@ -163,6 +163,13 @@ export type WorkflowTaskSpec = {
163
163
  /** W3 trust level for a workflow node. */
164
164
  export type NodeTrust = "trusted" | "quarantined";
165
165
  export type WorkflowDependencyPolicy = "all_success" | "accept_partial" | "all_terminal" | "optional";
166
+ export type WorkflowContextInclude = "dependency_outputs" | "memory" | "knowledge";
167
+ export type WorkflowDependencyMode = "full" | "summary" | "reference";
168
+ export interface WorkflowContextPolicy {
169
+ include?: WorkflowContextInclude[];
170
+ dependencyMode?: WorkflowDependencyMode;
171
+ maxTokens?: number;
172
+ }
166
173
  export type WorkflowNodeStatus = "completed" | "completed_partial" | "failed" | "skipped_upstream_failed";
167
174
  /** Host-observed, deterministic scheduling inputs for one workflow node. They never originate
168
175
  * from model-authored workflow tools. */
@@ -175,8 +182,14 @@ export interface SchedulingFactors {
175
182
  export declare function workflowNodeStatusFromTermination(termination: TerminationReason | string): WorkflowNodeStatus;
176
183
  /** One node in a declarative workflow DAG (camelCase host shape). */
177
184
  export interface WorkflowNodeSpec {
185
+ /** Stable public workflow step key; host-only metadata for lowering and diagnostics. */
186
+ nodeId?: string;
178
187
  task: WorkflowTaskSpec;
179
188
  role: KernelAgentRole;
189
+ /** Public workflow binding retained by the host while lowering the node to a kernel agent run. */
190
+ agent?: string;
191
+ /** Host context contract; dependency data is narrowed before entering the child goal. */
192
+ context?: WorkflowContextPolicy;
180
193
  isolation?: AgentIsolation;
181
194
  contextInheritance?: ContextInheritance;
182
195
  modelHint?: string;
@@ -228,7 +241,7 @@ export interface KernelWorkflowNodeOutcome {
228
241
  status: WorkflowNodeStatus;
229
242
  termination?: TerminationReason;
230
243
  output?: {
231
- role: ProviderMessage["role"];
244
+ role: ModelMessage["role"];
232
245
  content: string;
233
246
  tool_calls?: Array<{
234
247
  id: string;
@@ -241,7 +254,7 @@ export interface WorkflowNodeOutcome {
241
254
  nodeId: string;
242
255
  status: WorkflowNodeStatus;
243
256
  termination?: TerminationReason;
244
- output?: ProviderMessage;
257
+ output?: ModelMessage;
245
258
  }
246
259
  /** A control-plane request rejected before any workflow effect started. */
247
260
  export interface ControlRequestRejection {
package/dist/types.d.ts CHANGED
@@ -84,7 +84,8 @@ export interface ContentBlockFile {
84
84
  /** Legal content returned by a tool. Deliberately excludes ToolExecutionResult, so nesting is
85
85
  * unrepresentable in the canonical type. */
86
86
  export type ToolOutputBlock = ContentBlockText | ContentBlockImage | ContentBlockAudio | ContentBlockVideo | ContentBlockFile;
87
- export interface ProviderMessage {
87
+ /** Semantic message consumed by the model invocation layer. Provider wire messages are adapter-local. */
88
+ export interface ModelMessage {
88
89
  role: "system" | "user" | "assistant" | "tool";
89
90
  /** Plain-text content. When `contentParts` is present, this holds only the text segments. */
90
91
  content: string;
@@ -92,6 +93,17 @@ export interface ProviderMessage {
92
93
  contentParts?: ContentPart[];
93
94
  toolCalls?: ToolCall[];
94
95
  }
96
+ /** Stored durable representation. It references the semantic message without becoming a second content authority. */
97
+ export interface StoredMessage extends ModelMessage {
98
+ readonly messageId?: string;
99
+ readonly createdAt?: number;
100
+ }
101
+ /** Host execution representation; contentParts remains the structured content authority. */
102
+ export interface RuntimeMessage extends ModelMessage {
103
+ readonly messageId?: string;
104
+ }
105
+ /** Provider wire representation is adapter-owned and intentionally opaque at the SDK boundary. */
106
+ export type WireMessage = Readonly<Record<string, unknown>>;
95
107
  export interface ToolCall {
96
108
  id: string;
97
109
  name: string;
@@ -478,7 +490,7 @@ export interface RenderedContext {
478
490
  /** Knowledge (memory retrievals, skill definitions, artifacts). Anthropic system[1] with cache_control. */
479
491
  systemKnowledge?: string;
480
492
  /** History turns only — the stable, cacheable message prefix. */
481
- turns: ProviderMessage[];
493
+ turns: ModelMessage[];
482
494
  /**
483
495
  * Volatile State turn (task_state + signals), rebuilt every call. Providers
484
496
  * render it after the cacheable history (Anthropic: after the cache breakpoint;
@@ -486,7 +498,7 @@ export interface RenderedContext {
486
498
  * older binding that has not been rebuilt — then the State turn is still inside
487
499
  * `turns[0]` and providers render `turns` as-is.
488
500
  */
489
- stateTurn?: ProviderMessage;
501
+ stateTurn?: ModelMessage;
490
502
  /**
491
503
  * P1-E: count of leading `turns` forming the frozen prefix — byte-stable until the next
492
504
  * compaction. The Anthropic provider pins a deep cache breakpoint at this boundary (a long-lived
@@ -531,7 +543,7 @@ export interface LLMProvider {
531
543
  */
532
544
  runtimePolicy?(): RuntimePolicy;
533
545
  /** Read provider-native replay fields captured after the most recent assistant turn. */
534
- peekProviderReplay?(message: Pick<ProviderMessage, "content" | "toolCalls">): ProviderReplay | undefined;
546
+ peekProviderReplay?(message: Pick<ModelMessage, "content" | "toolCalls">): ProviderReplay | undefined;
535
547
  /**
536
548
  * P4-S1: read the transport facts captured during the most recent execution (HTTP rung count,
537
549
  * wire response id). Optional — a provider without it simply omits the telemetry and the
@@ -540,7 +552,7 @@ export interface LLMProvider {
540
552
  */
541
553
  peekTransportTelemetry?(): ProviderTransportTelemetry | undefined;
542
554
  /** Restore provider-native replay fields when rebuilding history from SessionLog. */
543
- seedProviderReplay?(message: Pick<ProviderMessage, "content" | "toolCalls">, replay: ProviderReplay): void;
555
+ seedProviderReplay?(message: Pick<ModelMessage, "content" | "toolCalls">, replay: ProviderReplay): void;
544
556
  /**
545
557
  * Pre-flight query: would this history validate against this provider with the
546
558
  * given extensions, without sending the request? Returns the tool-call ids
@@ -554,13 +566,11 @@ export interface LLMProvider {
554
566
  * (Anthropic `messages.countTokens` and Gemini `countTokens`),
555
567
  * where the vendor offers one. Optional — providers without a native endpoint simply omit it,
556
568
  * and callers fall back to `FallbackEstimator` (Rust `context::token_engine`, spc_011-C-01) or
557
- * a local tokenizer. Not currently invoked by any dispatch loop (nothing in the Rust kernel
558
- * emits `EffectKind::MeasurePrompt` yet see its doc comment); this method exists so the
559
- * capability remains directly callable, but no dispatch trigger is enabled until request
560
- * fingerprinting and durable measurement semantics are defined.
569
+ * a local tokenizer. The host runner invokes this capability during provider request
570
+ * preparation and binds the resulting measurement to the prepared request fingerprint.
561
571
  */
562
572
  countTokens?(context: RenderedContext, tools: ToolSchema[], extensions?: Record<string, unknown>, state?: ProviderRunState): Promise<PromptMeasurement>;
563
- complete(context: RenderedContext, tools: ToolSchema[], extensions?: Record<string, unknown>): Promise<ProviderMessage>;
573
+ complete(context: RenderedContext, tools: ToolSchema[], extensions?: Record<string, unknown>): Promise<ModelMessage>;
564
574
  stream(context: RenderedContext, tools: ToolSchema[], extensions?: Record<string, unknown>, state?: ProviderRunState,
565
575
  /** #2-B-ii: when provided, a preempting `InterruptNow` (or `interrupt()`) aborts the in-flight
566
576
  * request. SDK-client providers should forward it to the client (`{ signal }`); the runner also
@@ -573,14 +583,14 @@ export interface LLMProvider {
573
583
  * Produces a richer LLM-generated summary that replaces the rule-based one on next wake.
574
584
  */
575
585
  export interface AsyncSummarizer {
576
- summarize(archived: ProviderMessage[], action: string): Promise<string>;
586
+ summarize(archived: ModelMessage[], action: string): Promise<string>;
577
587
  }
578
588
  /**
579
589
  * Durable-memory summarizer for semantic `page_out` events (Layer 5 contract).
580
590
  * The kernel emits `page_out { tier_hint: "semantic" }`; the SDK persists an LLM summary to MemoryStore.
581
591
  */
582
592
  export interface MemorySummarizer {
583
- summarize(archived: ProviderMessage[], context: {
593
+ summarize(archived: ModelMessage[], context: {
584
594
  action?: string;
585
595
  }): Promise<string>;
586
596
  }
@@ -0,0 +1,19 @@
1
+ import type { Agent } from "../agent.js";
2
+ import type { AgentRef } from "../handoff-target.js";
3
+ import type { WorkflowContextPolicy, WorkflowDependencyPolicy, WorkflowOutcome, WorkflowSpec } from "../types/agent.js";
4
+ export interface WorkflowStep {
5
+ agent: Agent | AgentRef;
6
+ input: string;
7
+ dependsOn?: string[];
8
+ dependencyPolicy?: WorkflowDependencyPolicy;
9
+ context?: WorkflowContextPolicy;
10
+ metadata?: Record<string, unknown>;
11
+ }
12
+ export interface WorkflowDefinition {
13
+ name?: string;
14
+ steps: Record<string, WorkflowStep>;
15
+ metadata?: Record<string, unknown>;
16
+ }
17
+ export declare function lowerWorkflowDefinition(definition: WorkflowDefinition): WorkflowSpec;
18
+ export type WorkflowResult = WorkflowOutcome;
19
+ export declare function createWorkflow(definition: WorkflowDefinition): WorkflowDefinition;
@@ -0,0 +1,29 @@
1
+ import { agentRefName } from "../handoff-target.js";
2
+ export function lowerWorkflowDefinition(definition) {
3
+ const entries = Object.entries(definition.steps);
4
+ const indexById = new Map(entries.map(([nodeId], index) => [nodeId, index]));
5
+ return {
6
+ nodes: entries.map(([nodeId, step]) => ({
7
+ ...(() => {
8
+ const dependsOn = step.dependsOn?.map(dependencyId => {
9
+ const index = indexById.get(dependencyId);
10
+ if (index === undefined)
11
+ throw new Error(`workflow step "${nodeId}" depends on unknown step "${dependencyId}"`);
12
+ return index;
13
+ });
14
+ return dependsOn ? { dependsOn } : {};
15
+ })(),
16
+ nodeId,
17
+ task: { goal: step.input },
18
+ role: "implement",
19
+ isolation: "read_only",
20
+ contextInheritance: "system_only",
21
+ dependencyPolicy: step.dependencyPolicy,
22
+ context: step.context,
23
+ agent: agentRefName(step.agent),
24
+ })),
25
+ };
26
+ }
27
+ export function createWorkflow(definition) {
28
+ return Object.freeze({ ...definition, steps: Object.freeze({ ...definition.steps }) });
29
+ }
@@ -3,8 +3,10 @@ export type { SubAgentRunContext } from "../runtime/sub-agent-orchestrator.js";
3
3
  export { builtinReducers, resolveReducer } from "../runtime/reducers.js";
4
4
  export type { Reducer, ReducerRegistry, ReducerInput } from "../runtime/reducers.js";
5
5
  export { FileWorkflowStore } from "../runtime/workflow-store.js";
6
+ export { createWorkflow, lowerWorkflowDefinition } from "./definition.js";
7
+ export type { WorkflowDefinition, WorkflowStep, WorkflowResult } from "./definition.js";
6
8
  export { submitWorkflowNodesTool, startWorkflowTool, generateAndFilter, verifyRules, genEval, milestoneCheckPass, milestoneCheckFail, MILESTONE_UNVERIFIED_REASON, } from "../types/agent.js";
7
- export type { AgentCapabilityFilter, AgentIdentity, AgentIsolation, AgentRunSpec, AgentProcessChangedObservation, ContextInheritance, KernelAgentRole, LoopResult, MilestoneCheckResult, MilestoneContract, MilestonePhase, MilestonePolicy, SubAgentResult, TerminationReason, WorkflowSpawnInfo, WorkflowTaskSpec, WorkflowDependencyPolicy, WorkflowNodeStatus, WorkflowNodeOutcome, WorkflowOutcome, } from "../types/agent.js";
9
+ export type { AgentCapabilityFilter, AgentIdentity, AgentIsolation, AgentRunSpec, AgentProcessChangedObservation, ContextInheritance, KernelAgentRole, LoopResult, MilestoneCheckResult, MilestoneContract, MilestonePhase, MilestonePolicy, SubAgentResult, TerminationReason, WorkflowSpawnInfo, WorkflowTaskSpec, WorkflowDependencyPolicy, WorkflowContextInclude, WorkflowDependencyMode, WorkflowContextPolicy, WorkflowNodeStatus, WorkflowNodeOutcome, WorkflowOutcome, } from "../types/agent.js";
8
10
  export type { AcceptanceCriterion, VerificationContract, ContractCheckResult } from "../collaboration/contract.js";
9
11
  export { ContractBuilder, formatContractForSystemPrompt, contractToCriteriaStrings } from "../collaboration/contract.js";
10
12
  export type { AgentRole, IsolatedVerifierContext, CoordinatorConfig } from "../collaboration/pool.js";
@@ -5,6 +5,7 @@
5
5
  export { SubAgentOrchestrator, defaultSubAgentOrchestrator, spawnStandalone } from "../runtime/sub-agent-orchestrator.js";
6
6
  export { builtinReducers, resolveReducer } from "../runtime/reducers.js";
7
7
  export { FileWorkflowStore } from "../runtime/workflow-store.js";
8
+ export { createWorkflow, lowerWorkflowDefinition } from "./definition.js";
8
9
  export { submitWorkflowNodesTool, startWorkflowTool, generateAndFilter, verifyRules, genEval, milestoneCheckPass, milestoneCheckFail, MILESTONE_UNVERIFIED_REASON, } from "../types/agent.js";
9
10
  export { ContractBuilder, formatContractForSystemPrompt, contractToCriteriaStrings } from "../collaboration/contract.js";
10
11
  export { HandoffBus } from "../collaboration/handoff.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deepstrike/sdk",
3
- "version": "0.2.70",
3
+ "version": "0.2.72",
4
4
  "description": "DeepStrike Node.js SDK",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "type": "module",
@@ -34,6 +34,18 @@
34
34
  "./os": {
35
35
  "types": "./dist/os/public.d.ts",
36
36
  "import": "./dist/os/public.js"
37
+ },
38
+ "./advanced": {
39
+ "types": "./dist/advanced/public.d.ts",
40
+ "import": "./dist/advanced/public.js"
41
+ },
42
+ "./runtime": {
43
+ "types": "./dist/runtime/public.d.ts",
44
+ "import": "./dist/runtime/public.js"
45
+ },
46
+ "./evals": {
47
+ "types": "./dist/evals/public.d.ts",
48
+ "import": "./dist/evals/public.js"
37
49
  }
38
50
  },
39
51
  "typesVersions": {
@@ -55,6 +67,15 @@
55
67
  ],
56
68
  "os": [
57
69
  "./dist/os/public.d.ts"
70
+ ],
71
+ "advanced": [
72
+ "./dist/advanced/public.d.ts"
73
+ ],
74
+ "runtime": [
75
+ "./dist/runtime/public.d.ts"
76
+ ],
77
+ "evals": [
78
+ "./dist/evals/public.d.ts"
58
79
  ]
59
80
  }
60
81
  },
@@ -73,7 +94,7 @@
73
94
  },
74
95
  "dependencies": {
75
96
  "@anthropic-ai/sdk": "^0.99.0",
76
- "@deepstrike/core": "0.2.70",
97
+ "@deepstrike/core": "0.2.72",
77
98
  "@google/generative-ai": "^0.24.1",
78
99
  "openai": "^7.5.0"
79
100
  },