@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
@@ -1,3 +1,4 @@
1
+ import type { AgentDefinition } from "./agent-facade.js";
1
2
  import { Agent, type AgentOptions, type ModelRef } from "./agent.js";
2
3
  import type { Guardrail } from "./guardrail.js";
3
4
  import type { Handoff } from "./handoff-target.js";
@@ -15,7 +16,7 @@ export interface AgentToolDefinition {
15
16
  }
16
17
  /** A JSON-friendly Agent definition accepted by `normalizeAgent`. It is deliberately declarative:
17
18
  * executable tools still enter the SDK through `AgentOptions.tools`. */
18
- export interface AgentDefinition extends Omit<AgentOptions, "tools"> {
19
+ export interface AgentDescriptor extends Omit<AgentOptions, "tools"> {
19
20
  tools?: Array<RegisteredTool | AgentToolDefinition>;
20
21
  }
21
22
  export interface AgentToolIR {
@@ -85,19 +86,24 @@ export interface AgentSpec {
85
86
  guardrails?: Guardrail[];
86
87
  metadata?: Record<string, unknown>;
87
88
  /** Declared capabilities. This descriptive view grants nothing by itself. */
88
- capabilities: AgentCapabilityIR[];
89
+ readonly capabilities: AgentCapabilityIR[];
89
90
  /** Host ceiling copied from the public Agent, when supplied. Empty axes remain non-narrowing. */
90
91
  capabilityFilter?: AgentCapabilityFilter;
91
92
  /** The declarations that survive the supplied local ceiling. Host mounts may narrow further. */
92
- effectiveCapabilities: AgentCapabilityIR[];
93
+ readonly effectiveCapabilities: AgentCapabilityIR[];
93
94
  /** Namespace-isolated provider extensions. Unknown namespaces are preserved verbatim. */
94
95
  extensions: Record<string, unknown>;
95
- inputs: AgentLoweringInputs;
96
96
  }
97
97
  /** Normalizes native Agents and JSON-safe descriptor objects into the one public surface used by
98
98
  * lowering. It does not interpret provider namespaces or create executable capabilities. */
99
- export declare function normalizeAgent(agent: Agent | AgentDefinition): Agent;
99
+ export declare function normalizeAgent(agent: Agent | AgentDefinition | AgentDescriptor): Agent;
100
100
  /** Pure: no provider branching, no scheduling, authorization, persistence, or Kernel wire calls.
101
101
  * Providers consume only their own namespace from `extensions`; the host decides whether declared
102
102
  * capabilities survive its existing attenuation filter. */
103
103
  export declare function lowerAgent(agent: Agent): AgentSpec;
104
+ /** Detached projections; callers can adapt them without changing AgentSpec authority. */
105
+ export declare function projectAgentRun(spec: AgentSpec): AgentLoweringInputs["run"];
106
+ export declare function projectAgentContext(spec: AgentSpec): AgentLoweringInputs["context"];
107
+ export declare function projectAgentCapabilities(spec: AgentSpec): AgentLoweringInputs["capabilities"];
108
+ export declare function projectAgentGovernance(spec: AgentSpec): AgentLoweringInputs["governance"];
109
+ export declare function projectAgentDelegation(spec: AgentSpec): AgentLoweringInputs["delegation"];
package/dist/agent-ir.js CHANGED
@@ -37,7 +37,7 @@ export function normalizeAgent(agent) {
37
37
  return agent;
38
38
  const tools = agent.tools?.map(tool => isRegisteredTool(tool) ? tool : toolDefinitionToRegisteredTool(tool));
39
39
  const { tools: _rawTools, ...options } = agent;
40
- return new Agent({ ...options, ...(tools ? { tools } : {}) });
40
+ return new Agent({ ...options, name: options.name ?? "agent", ...(tools ? { tools } : {}) });
41
41
  }
42
42
  function lowerTool(tool) {
43
43
  let parameters;
@@ -88,17 +88,7 @@ export function lowerAgent(agent) {
88
88
  const guardrails = clone(agent.guardrails ?? []);
89
89
  const memory = lowerMemory(agent.memory);
90
90
  const extensions = clone(agent.providerOptions ?? {});
91
- const capabilities = [
92
- ...tools.map(tool => ({ kind: "tool", id: tool.name, description: tool.description })),
93
- ...mcpServers.map(server => ({
94
- kind: "mcp_server",
95
- id: server.name ?? server.transport.kind,
96
- description: server.name ?? `${server.transport.kind} MCP server`,
97
- })),
98
- ...skills.map(skill => ({ kind: "skill", id: skill.name, description: skill.description ?? "" })),
99
- ];
100
91
  const capabilityFilter = agent.capabilityFilter ? clone(agent.capabilityFilter) : undefined;
101
- const effectiveCapabilities = capabilities.filter(capability => capabilityAllowed(capability, capabilityFilter));
102
92
  return {
103
93
  name: agent.name,
104
94
  ...(agent.description ? { description: agent.description } : {}),
@@ -113,22 +103,48 @@ export function lowerAgent(agent) {
113
103
  ...(handoffs.length ? { handoffs } : {}),
114
104
  ...(guardrails.length ? { guardrails } : {}),
115
105
  ...(agent.metadata ? { metadata: clone(agent.metadata) } : {}),
116
- capabilities,
106
+ get capabilities() { return declaredCapabilities(this); },
117
107
  ...(capabilityFilter ? { capabilityFilter } : {}),
118
- effectiveCapabilities,
119
- extensions,
120
- inputs: {
121
- run: { name: agent.name, ...(agent.model ? { model: clone(agent.model) } : {}) },
122
- context: {
123
- ...(agent.description ? { description: agent.description } : {}),
124
- ...(agent.instructions ? { instructions: agent.instructions } : {}),
125
- ...(agent.outputSchema ? { outputSchema: clone(agent.outputSchema) } : {}),
126
- knowledge,
127
- },
128
- capabilities: { tools, mcpServers, skills, effective: effectiveCapabilities },
129
- ...(memory ? { memory } : {}),
130
- delegation: { handoffs },
131
- governance: { guardrails },
108
+ get effectiveCapabilities() {
109
+ return declaredCapabilities(this).filter(capability => capabilityAllowed(capability, this.capabilityFilter));
132
110
  },
111
+ extensions,
112
+ };
113
+ }
114
+ /** Detached projections; callers can adapt them without changing AgentSpec authority. */
115
+ export function projectAgentRun(spec) {
116
+ return { name: spec.name, ...(spec.model !== undefined ? { model: clone(spec.model) } : {}) };
117
+ }
118
+ export function projectAgentContext(spec) {
119
+ return {
120
+ ...(spec.description !== undefined ? { description: spec.description } : {}),
121
+ ...(spec.instructions !== undefined ? { instructions: spec.instructions } : {}),
122
+ ...(spec.outputSchema !== undefined ? { outputSchema: clone(spec.outputSchema) } : {}),
123
+ knowledge: clone(spec.knowledge ?? []),
133
124
  };
134
125
  }
126
+ export function projectAgentCapabilities(spec) {
127
+ return {
128
+ tools: clone(spec.tools),
129
+ mcpServers: clone(spec.mcpServers ?? []),
130
+ skills: clone(spec.skills ?? []),
131
+ effective: clone(spec.effectiveCapabilities),
132
+ };
133
+ }
134
+ export function projectAgentGovernance(spec) {
135
+ return { guardrails: clone(spec.guardrails ?? []) };
136
+ }
137
+ export function projectAgentDelegation(spec) {
138
+ return { handoffs: clone(spec.handoffs ?? []) };
139
+ }
140
+ function declaredCapabilities(spec) {
141
+ return [
142
+ ...spec.tools.map(tool => ({ kind: "tool", id: tool.name, description: tool.description })),
143
+ ...(spec.mcpServers ?? []).map(server => ({
144
+ kind: "mcp_server",
145
+ id: server.name ?? server.transport.kind,
146
+ description: server.name ?? `${server.transport.kind} MCP server`,
147
+ })),
148
+ ...(spec.skills ?? []).map(skill => ({ kind: "skill", id: skill.name, description: skill.description ?? "" })),
149
+ ];
150
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * SPC-028-03: names that retain the Canonical prefix for ABI/runtime reasons.
3
+ * New provider-neutral types should use a domain and representation name instead.
4
+ */
5
+ export declare const CANONICAL_PREFIX_ALLOWLIST: readonly ["CanonicalAdapterInput", "CanonicalCheckpoint", "CanonicalCommit", "CanonicalKernel", "CanonicalKernelHost", "CanonicalKernelInput", "CanonicalKernelInstance", "CanonicalKernelRebuildRequiredError", "CanonicalKernelRejectedError", "CanonicalMessage", "CanonicalMessageBlock", "CanonicalPlannedStep", "CanonicalPreparation", "CanonicalPrepared", "CanonicalRejected", "CanonicalRenderedContext", "CanonicalReplayed", "CanonicalRestoreCost", "CanonicalRunnerRuntime", "CanonicalRunnerRuntimeOptions", "CanonicalStopReason", "CanonicalToolResult", "CanonicalTransition", "CanonicalTransitionOptions"];
6
+ export type AllowedCanonicalPrefixName = typeof CANONICAL_PREFIX_ALLOWLIST[number];
@@ -0,0 +1,30 @@
1
+ /**
2
+ * SPC-028-03: names that retain the Canonical prefix for ABI/runtime reasons.
3
+ * New provider-neutral types should use a domain and representation name instead.
4
+ */
5
+ export const CANONICAL_PREFIX_ALLOWLIST = [
6
+ "CanonicalAdapterInput",
7
+ "CanonicalCheckpoint",
8
+ "CanonicalCommit",
9
+ "CanonicalKernel",
10
+ "CanonicalKernelHost",
11
+ "CanonicalKernelInput",
12
+ "CanonicalKernelInstance",
13
+ "CanonicalKernelRebuildRequiredError",
14
+ "CanonicalKernelRejectedError",
15
+ "CanonicalMessage",
16
+ "CanonicalMessageBlock",
17
+ "CanonicalPlannedStep",
18
+ "CanonicalPreparation",
19
+ "CanonicalPrepared",
20
+ "CanonicalRejected",
21
+ "CanonicalRenderedContext",
22
+ "CanonicalReplayed",
23
+ "CanonicalRestoreCost",
24
+ "CanonicalRunnerRuntime",
25
+ "CanonicalRunnerRuntimeOptions",
26
+ "CanonicalStopReason",
27
+ "CanonicalToolResult",
28
+ "CanonicalTransition",
29
+ "CanonicalTransitionOptions",
30
+ ];
@@ -0,0 +1,50 @@
1
+ /** Public evaluation language. Runtime evidence remains available through the runtime subpath. */
2
+ export { judge, buildEvalMessages, parseVerdict, verdictOutputSchema } from "../runtime/eval.js";
3
+ export type { Criterion, Verdict, VerdictDetail, JudgeArgs } from "../runtime/eval.js";
4
+ export interface DatasetCase {
5
+ id: string;
6
+ input: string;
7
+ expected?: unknown;
8
+ metadata?: Record<string, unknown>;
9
+ }
10
+ export interface Dataset {
11
+ name?: string;
12
+ cases: DatasetCase[];
13
+ }
14
+ export interface Evaluator {
15
+ name: string;
16
+ evaluate(input: {
17
+ testCase: DatasetCase;
18
+ output: string;
19
+ }): Promise<number> | number;
20
+ }
21
+ export interface EvalResult {
22
+ caseId: string;
23
+ output: string;
24
+ scores: Record<string, number>;
25
+ }
26
+ /** Optional execution evidence kept separate from the stable score/result contract. */
27
+ export interface EvalTrace {
28
+ caseId: string;
29
+ executedInput: string;
30
+ contextBinding?: Record<string, unknown>;
31
+ route?: unknown;
32
+ measurement?: unknown;
33
+ artifactSet?: unknown;
34
+ }
35
+ export interface EvalRun {
36
+ runId: string;
37
+ results: EvalResult[];
38
+ completed: boolean;
39
+ traces?: EvalTrace[];
40
+ }
41
+ export declare function evaluate(agent: {
42
+ run(input: string): Promise<{
43
+ output: string;
44
+ }>;
45
+ }, options: {
46
+ dataset: Dataset;
47
+ evaluators: Evaluator[];
48
+ runId?: string;
49
+ includeTrace?: boolean;
50
+ }): Promise<EvalRun>;
@@ -0,0 +1,25 @@
1
+ /** Public evaluation language. Runtime evidence remains available through the runtime subpath. */
2
+ export { judge, buildEvalMessages, parseVerdict, verdictOutputSchema } from "../runtime/eval.js";
3
+ export async function evaluate(agent, options) {
4
+ const results = [];
5
+ const traces = [];
6
+ for (const testCase of options.dataset.cases) {
7
+ const output = await agent.run(testCase.input);
8
+ const scores = {};
9
+ for (const evaluator of options.evaluators)
10
+ scores[evaluator.name] = await evaluator.evaluate({ testCase, output: output.output });
11
+ results.push({ caseId: testCase.id, output: output.output, scores });
12
+ if (options.includeTrace) {
13
+ const evidence = output;
14
+ traces.push({
15
+ caseId: testCase.id,
16
+ executedInput: testCase.input,
17
+ ...(testCase.metadata ? { contextBinding: testCase.metadata } : {}),
18
+ ...(evidence.route !== undefined ? { route: evidence.route } : {}),
19
+ ...(evidence.usage !== undefined ? { measurement: evidence.usage } : {}),
20
+ ...(evidence.artifacts !== undefined ? { artifactSet: evidence.artifacts } : {}),
21
+ });
22
+ }
23
+ }
24
+ return { runId: options.runId ?? crypto.randomUUID(), results, completed: true, ...(options.includeTrace ? { traces } : {}) };
25
+ }
@@ -1,6 +1,9 @@
1
- /** Public guardrail declaration. Execution/lowering belongs to a later governance card. */
1
+ import type { GovernancePolicy } from "./governance.js";
2
+ /** Public guardrail declaration. A policy-bearing guardrail lowers into host governance. */
2
3
  export interface Guardrail {
3
4
  name: string;
4
5
  description?: string;
5
6
  metadata?: Record<string, unknown>;
7
+ /** Optional executable governance policy. A descriptive guardrail without this field is inert. */
8
+ policy?: GovernancePolicy;
6
9
  }
@@ -3,6 +3,8 @@ import type { JsonSchema } from "./runtime/output-schema.js";
3
3
  export type AgentRef = string | {
4
4
  name: string;
5
5
  };
6
+ /** Canonical lowering primitive shared by handoff authorization and workflow nodes. */
7
+ export declare function agentRefName(ref: AgentRef): string;
6
8
  export interface Handoff {
7
9
  agent: AgentRef;
8
10
  description?: string;
@@ -1 +1,7 @@
1
- export {};
1
+ /** Canonical lowering primitive shared by handoff authorization and workflow nodes. */
2
+ export function agentRefName(ref) {
3
+ const name = typeof ref === "string" ? ref : ref.name;
4
+ if (!name)
5
+ throw new Error("agent reference requires a non-empty name");
6
+ return name;
7
+ }
package/dist/index.d.ts CHANGED
@@ -1,31 +1,18 @@
1
- export { runAgent, runFanout } from "./runtime/facade.js";
2
- export { runLoop, LoopDriver, foldLoopState } from "./runtime/loop-driver.js";
3
- export type { LoopSpec, LoopOutcome } from "./runtime/loop-driver.js";
4
- export type { RunAgentOptions, RunFanoutOptions } from "./runtime/facade.js";
5
- export { RuntimeRunner, collectText } from "./runtime/runner.js";
6
- export type { RuntimeOptions, KernelReliabilityOptions, OperationCancellationReason, PromptBudget, SchedulerPolicy } from "./runtime/runner.js";
7
- export { PayloadStore } from "./runtime/payload-store.js";
8
- export type { PayloadStoreConfig } from "./runtime/payload-store.js";
1
+ export { createAgent } from "./agent-facade.js";
2
+ export type { AgentDefinition, AgentRunOptions, AgentSession, AgentRuntime, DelegationRequest, DelegationResult, MemoryInput, RecallOptions, RunResult, SessionRef, } from "./agent-facade.js";
3
+ export { collectText } from "./runtime/runner.js";
9
4
  export type { InstructionProfile, NudgeRule, NudgeTrigger } from "./harness/public.js";
10
5
  export type { SignalPolicy } from "./runtime/os-profile.js";
11
6
  export { DEFAULT_CONTEXT_POLICY, PPM_SCALE, contextPolicy, normalizeContextPolicy, ratioToPpm, } from "./runtime/context-policy.js";
12
7
  export type { ContextPolicyOverrides, ContextPolicy, ContextPolicyWire, ContextPressureThresholds, } from "./runtime/context-policy.js";
13
- export { LocalExecutionPlane } from "./runtime/execution-plane.js";
14
- export type { ExecutionPlane, RunContext } from "./runtime/execution-plane.js";
15
- export { InMemorySessionLog, FileSessionLog } from "./runtime/session-log.js";
16
- export type { SessionLog, SessionEvent, SessionEventKind } from "./runtime/session-log.js";
8
+ export type { SessionEvent, SessionEventKind } from "./runtime/session-log.js";
17
9
  export { SESSION_EVENT_KINDS } from "./runtime/session-log.js";
18
10
  export { CANONICAL_CONTENT_PARTS_PREFIX, encodeCanonicalContentParts, decodeCanonicalContentParts, } from "./runtime/kernel-step.js";
19
- export { FileKernelJournal, InMemoryKernelJournal, JournalCasConflictError, JournalIntegrityError, JournalIoError, } from "./runtime/kernel-journal.js";
20
- export type { CheckpointCandidate, InstalledCheckpoint, JournalAppendReceipt, JournalEntry, JournalHead, JournalPruneReceipt, JournalRecordInput, KernelJournal, } from "./runtime/kernel-journal.js";
21
- export { diagnoseKernelJournal } from "./runtime/kernel-doctor.js";
22
- export type { KernelJournalDiagnosis } from "./runtime/kernel-doctor.js";
23
11
  export { InMemoryGroupBudgetStore, GroupBudgetScope } from "./runtime/run-group.js";
24
12
  export type { RunGroup, GroupBudgetStore, GroupLedger, GroupCharge, GroupMember, GroupBudgetRequest, GroupBudgetReservation, } from "./runtime/run-group.js";
25
13
  export { InMemoryEventStream, isVisibleTo } from "./runtime/event-stream.js";
26
14
  export type { EventStream, EventStreamOptions, BlackboardEvent, EventViewer } from "./runtime/event-stream.js";
27
15
  export type { ObserverFailure, ObserverErrorHandler } from "./runtime/reliability.js";
28
- export { ManagedTaskScope, operationAbortSignal } from "./runtime/reliability.js";
29
16
  export type { OperationContext, BackgroundTaskFailure, BackgroundTaskErrorHandler } from "./runtime/reliability.js";
30
17
  export { reactByMention, directorDriven, roundRobin, firstNonEmpty, union } from "./runtime/turn-policy.js";
31
18
  export type { TurnPolicy, PeerView } from "./runtime/turn-policy.js";
@@ -45,30 +32,27 @@ export { OpenAIResponsesProvider } from "./providers/openai-responses.js";
45
32
  export { createProvider, createProviderAsync, resolveProviderRuntime, resolveProviderRuntimeAsync } from "./providers/catalog.js";
46
33
  export { UnsupportedModalityError } from "./providers/base.js";
47
34
  export type { CreateProviderOptions, EndpointProfileId } from "./providers/catalog.js";
48
- export { createProviderRequestPlan, createProviderRequestPlanForProvider, estimateProviderPromptTokens, measurementForPlan, normalizeProviderUsage, priceProviderUsage, recordPromptMeasurement, resolveProviderRoute } from "./providers/request-plan.js";
49
- export type { CostObservation, NormalizedProviderUsage, PricingSnapshot, ProviderRequestEndpoint, ProviderRequestPlan, RecordedPromptMeasurement, ResolvedProviderRoute } from "./providers/request-plan.js";
50
- export { FULL_FOOTPRINT_USAGE_ACCOUNTING_POLICY, providerAttemptToRecord } from "./runtime/execution-evidence.js";
51
- export type { InvocationOutcome, ModelInvocation, ProviderAttempt, ProviderAttemptRecord, ProviderAttemptStatus, UsageAccountingPolicy, ModelUsageSettlement } from "./runtime/execution-evidence.js";
52
35
  export { VERIFIABLE_REPORT_SCHEMA, VERIFIABLE_FORK_SCHEMA, assertVerifiableReportSchema, createVerifiableRuntimeAdapter, createNativeVerifiableRuntimeAdapter, VerifiableOperation, } from "./runtime/verifiable-report.js";
53
36
  export type { VerifiableCommand, CheckVerdict, VerifiableForkManifest, ForkPlan, VerifiableEvidence, VerifyOptions, ReplayOptions, VerifiableRuntimeAdapter, VerifiableReport, VerifiableOperationJson, } from "./runtime/verifiable-report.js";
54
- export { createEvolutionRuntimeAdapter, createNativeEvolutionRuntimeAdapter, EvolutionRuntime } from "./runtime/evolution.js";
55
- export type { ActivationBinding, ArtifactKind, ArtifactManifest, ArtifactRef, ArtifactSet, ArtifactVersion, ContextEntryRef, ContextEntrySource, ContextExecutionInput, ContextPreparationRequest, ContextPlan, ContextPlanAction, ContextSelection, ContextState, EvaluationContextBinding, EvaluationFact, EvaluationGate, EvaluationMetric, EvaluationRun, EvolutionBundle, EvolutionProposal, EvolutionReport, EvolutionVerdict, EvolutionViolation, PromotionDecision, PromotionOutcome, EvolutionStore, } from "./runtime/evolution.js";
56
37
  export type { GovernancePolicy, GovernanceConstraint } from "./governance.js";
57
- export { AgentPool } from "./collaboration/pool.js";
58
38
  export { Agent } from "./agent.js";
59
39
  export type { AgentOptions, AgentMemory, MemoryReference, ModelRef, ModelRequirement } from "./agent.js";
60
40
  export { lowerAgent, normalizeAgent } from "./agent-ir.js";
61
- export type { AgentCapabilityIR, AgentDefinition, AgentLoweringInputs, AgentMemoryIR, AgentSpec, AgentToolDefinition, AgentToolIR } from "./agent-ir.js";
41
+ export type { AgentCapabilityIR, AgentLoweringInputs, AgentMemoryIR, AgentSpec, AgentToolDefinition, AgentToolIR } from "./agent-ir.js";
62
42
  export type { Guardrail } from "./guardrail.js";
63
43
  export type { MCPServer, McpTransport } from "./mcp-server.js";
64
44
  export type { Knowledge, KnowledgeSourceRef } from "./knowledge/public.js";
45
+ export { createTextKnowledgeSource } from "./knowledge/public.js";
46
+ export type { TextKnowledgeDocument } from "./knowledge/public.js";
47
+ export { agentRefName } from "./handoff-target.js";
65
48
  export type { AgentRef, Handoff } from "./handoff-target.js";
66
49
  export type { Session } from "./session.js";
50
+ export { createWorkflow } from "./workflow/definition.js";
51
+ export type { WorkflowDefinition, WorkflowStep, WorkflowResult } from "./workflow/definition.js";
52
+ export { evaluate } from "./evals/public.js";
53
+ export type { Dataset, DatasetCase, Evaluator, EvalResult, EvalRun, EvalTrace } from "./evals/public.js";
67
54
  export type { RuntimeSignal, SignalClaim, SignalDeliveryReceipt, SignalSource, } from "./signals/types.js";
68
- export type { ProviderMessage, ToolCall, ToolExecutionResult, 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, ProviderWireEvidence, ProviderTransportTelemetry, } from "./types.js";
55
+ export type { ModelMessage, RuntimeMessage, StoredMessage, WireMessage, ToolCall, ToolExecutionResult, 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, ProviderWireEvidence, ProviderTransportTelemetry, } from "./types.js";
69
56
  export { DurableContentError, decodeDurableContent, decodeDurableToolResult, encodeDurableContent, encodeDurableToolResult, toolOutputBlocksToDurable, durableBlocksToToolOutput, } from "./runtime/durable-content.js";
70
57
  export type { DurableContent, DurableContentBlock, DurableSource, DurableToolResult } from "./runtime/durable-content.js";
71
- export type { WorkflowSpec, WorkflowNodeSpec, SchedulingFactors, WorkflowDependencyPolicy, WorkflowNodeStatus, WorkflowNodeOutcome, WorkflowOutcome, } from "./types/agent.js";
72
- export { createContextPreparationAdapter, createNativeContextPreparationAdapter } from "./runtime/context.js";
73
- export type { ContextPrepareJson, ContextVerifyJson, ContextPrepared, ContextProviderPreparationRequest } from "./runtime/context.js";
74
- export type { PreparedProviderRequest } from "./types.js";
58
+ export type { WorkflowSpec, WorkflowNodeSpec, SchedulingFactors, WorkflowDependencyPolicy, WorkflowContextInclude, WorkflowDependencyMode, WorkflowContextPolicy, WorkflowNodeStatus, WorkflowNodeOutcome, WorkflowOutcome, } from "./types/agent.js";
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // ╔══════════════════════════════════════════════════════════════════════════╗
2
- // ║ @deepstrike/sdk — root surface (v0.2.30). ║
2
+ // ║ @deepstrike/sdk — root surface (v0.2.72). ║
3
3
  // ║ ║
4
4
  // ║ This is the intent layer: run an agent, run a workflow, author a tool, ║
5
5
  // ║ pick a provider. Advanced machinery lives behind subpaths: ║
@@ -11,25 +11,17 @@
11
11
  // ║ @deepstrike/sdk/os — profiles, diagnostics, signals, replay tests ║
12
12
  // ╚══════════════════════════════════════════════════════════════════════════╝
13
13
  // ── Start here: the canonical entry points ─────────────────────────────────
14
- export { runAgent, runFanout } from "./runtime/facade.js";
15
14
  // ③ dynamic loop agents: self-pacing rounds over the kernel pacing trap.
16
- export { runLoop, LoopDriver, foldLoopState } from "./runtime/loop-driver.js";
17
- export { RuntimeRunner, collectText } from "./runtime/runner.js";
18
- export { PayloadStore } from "./runtime/payload-store.js";
15
+ export { createAgent } from "./agent-facade.js";
16
+ export { collectText } from "./runtime/runner.js";
19
17
  export { DEFAULT_CONTEXT_POLICY, PPM_SCALE, contextPolicy, normalizeContextPolicy, ratioToPpm, } from "./runtime/context-policy.js";
20
- // ── Execution plane + session log (the defaults) ────────────────────────────
21
- export { LocalExecutionPlane } from "./runtime/execution-plane.js";
22
- export { InMemorySessionLog, FileSessionLog } from "./runtime/session-log.js";
23
18
  // Registered session-event vocabulary (F9/S3; manifest-pinned by sdk-conformance, P7-S4)
24
19
  export { SESSION_EVENT_KINDS } from "./runtime/session-log.js";
25
20
  // ── content-parts-v1 registered encoding (F14/B5; byte-pinned by sdk-conformance) ──
26
21
  export { CANONICAL_CONTENT_PARTS_PREFIX, encodeCanonicalContentParts, decodeCanonicalContentParts, } from "./runtime/kernel-step.js";
27
22
  // ── Durable transaction capability (Canonical Kernel ABI §9.1) ──────────────
28
- export { FileKernelJournal, InMemoryKernelJournal, JournalCasConflictError, JournalIntegrityError, JournalIoError, } from "./runtime/kernel-journal.js";
29
- export { diagnoseKernelJournal } from "./runtime/kernel-doctor.js";
30
23
  export { InMemoryGroupBudgetStore, GroupBudgetScope } from "./runtime/run-group.js";
31
24
  export { InMemoryEventStream, isVisibleTo } from "./runtime/event-stream.js";
32
- export { ManagedTaskScope, operationAbortSignal } from "./runtime/reliability.js";
33
25
  export { reactByMention, directorDriven, roundRobin, firstNonEmpty, union } from "./runtime/turn-policy.js";
34
26
  export { ReactiveSession, readRecentTool } from "./runtime/reactive-session.js";
35
27
  export { InMemoryReactionCheckpointStore, ReactionInProgressError } from "./runtime/reaction-checkpoint.js";
@@ -44,15 +36,14 @@ export { OpenAIProvider } from "./providers/openai.js";
44
36
  export { OpenAIResponsesProvider } from "./providers/openai-responses.js";
45
37
  export { createProvider, createProviderAsync, resolveProviderRuntime, resolveProviderRuntimeAsync } from "./providers/catalog.js";
46
38
  export { UnsupportedModalityError } from "./providers/base.js";
47
- export { createProviderRequestPlan, createProviderRequestPlanForProvider, estimateProviderPromptTokens, measurementForPlan, normalizeProviderUsage, priceProviderUsage, recordPromptMeasurement, resolveProviderRoute } from "./providers/request-plan.js";
48
- export { FULL_FOOTPRINT_USAGE_ACCOUNTING_POLICY, providerAttemptToRecord } from "./runtime/execution-evidence.js";
49
39
  export { VERIFIABLE_REPORT_SCHEMA, VERIFIABLE_FORK_SCHEMA, assertVerifiableReportSchema, createVerifiableRuntimeAdapter, createNativeVerifiableRuntimeAdapter, VerifiableOperation, } from "./runtime/verifiable-report.js";
50
- export { createEvolutionRuntimeAdapter, createNativeEvolutionRuntimeAdapter, EvolutionRuntime } from "./runtime/evolution.js";
51
40
  // ── Multi-agent primitive ───────────────────────────────────────────────────
52
41
  // Parallel fan-out / sub-agent delegation. The full orchestration layer is in `@deepstrike/sdk/workflow`.
53
- export { AgentPool } from "./collaboration/pool.js";
54
42
  // ── Ecosystem Surface Contract (spc_001) ────────────────────────────────────
55
43
  export { Agent } from "./agent.js";
56
44
  export { lowerAgent, normalizeAgent } from "./agent-ir.js";
45
+ export { createTextKnowledgeSource } from "./knowledge/public.js";
46
+ export { agentRefName } from "./handoff-target.js";
47
+ export { createWorkflow } from "./workflow/definition.js";
48
+ export { evaluate } from "./evals/public.js";
57
49
  export { DurableContentError, decodeDurableContent, decodeDurableToolResult, encodeDurableContent, encodeDurableToolResult, toolOutputBlocksToDurable, durableBlocksToToolOutput, } from "./runtime/durable-content.js";
58
- export { createContextPreparationAdapter, createNativeContextPreparationAdapter } from "./runtime/context.js";
package/dist/kernel.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { ProviderMessage } from "./types.js";
1
+ import type { ModelMessage } from "./types.js";
2
2
  /**
3
3
  * M2 资源配额 — declarative resource limits enforced at the kernel's single syscall trap.
4
4
  *
@@ -150,7 +150,7 @@ export interface CanonicalKernelInstance {
150
150
  interface KernelModule {
151
151
  CanonicalKernel: new () => CanonicalKernelInstance;
152
152
  SignalRouter: new (maxQueueSize: number) => SignalRouterInstance;
153
- buildEvalMessages(goal: string, criteria: NativeCriterion[], result: string, attempt: number, extractSkillOnPass: boolean): ProviderMessage[];
153
+ buildEvalMessages(goal: string, criteria: NativeCriterion[], result: string, attempt: number, extractSkillOnPass: boolean): ModelMessage[];
154
154
  parseVerdict(content: string): Verdict;
155
155
  verdictOutputSchema(extractSkillOnPass: boolean): string;
156
156
  verifiableOperationJson(request: string): string;
@@ -27,3 +27,5 @@ export interface Knowledge {
27
27
  metadata?: Record<string, unknown>;
28
28
  providerOptions?: Record<string, unknown>;
29
29
  }
30
+ export { createTextKnowledgeSource } from "./source.js";
31
+ export type { TextKnowledgeDocument } from "./source.js";
@@ -1 +1 @@
1
- export {};
1
+ export { createTextKnowledgeSource } from "./source.js";
@@ -3,3 +3,10 @@ export interface KnowledgeSource {
3
3
  /** One-time warmup called before the first run (load index, open connection, etc.). */
4
4
  init(): Promise<void>;
5
5
  }
6
+ export interface TextKnowledgeDocument {
7
+ id?: string;
8
+ name?: string;
9
+ content: string;
10
+ }
11
+ /** Deterministic local retrieval for inline text knowledge; external sources keep explicit bindings. */
12
+ export declare function createTextKnowledgeSource(documents: TextKnowledgeDocument[]): KnowledgeSource;
@@ -1 +1,20 @@
1
- export {};
1
+ /** Deterministic local retrieval for inline text knowledge; external sources keep explicit bindings. */
2
+ export function createTextKnowledgeSource(documents) {
3
+ const prepared = documents.filter(document => document.content.trim()).map((document, index) => ({
4
+ ...document,
5
+ key: document.id ?? document.name ?? `text-${index}`,
6
+ terms: new Set(document.content.toLowerCase().match(/[\p{L}\p{N}]+/gu) ?? []),
7
+ }));
8
+ return {
9
+ async init() { },
10
+ async retrieve(goal, topK = 5) {
11
+ const queryTerms = new Set(goal.toLowerCase().match(/[\p{L}\p{N}]+/gu) ?? []);
12
+ return prepared
13
+ .map(document => ({ document, score: [...queryTerms].reduce((score, term) => score + (document.terms.has(term) ? 1 : 0), 0) }))
14
+ .sort((left, right) => right.score - left.score || left.document.key.localeCompare(right.document.key))
15
+ .filter(item => item.score > 0 || queryTerms.size === 0)
16
+ .slice(0, Math.max(0, topK))
17
+ .map(({ document }) => document.name ? `[Knowledge: ${document.name}]\n${document.content}` : document.content);
18
+ },
19
+ };
20
+ }
@@ -1,6 +1,6 @@
1
- import type { ProviderMessage, ContentPart } from "../types.js";
1
+ import type { ModelMessage, ContentPart } from "../types.js";
2
2
  export interface SessionMessage {
3
- role: ProviderMessage["role"];
3
+ role: ModelMessage["role"];
4
4
  content: string;
5
5
  /** Structured multimodal parts. Preserved for round-trip fidelity (e.g. tool result messages). */
6
6
  contentParts?: ContentPart[];
@@ -0,0 +1,43 @@
1
+ /** SPC-028-09: registered authority/projection relationships. */
2
+ export interface ProjectionPair {
3
+ readonly authority: string;
4
+ readonly projection: string;
5
+ readonly crossingFunction: string;
6
+ }
7
+ export declare const PROJECTION_PAIRS: {
8
+ readonly Message: {
9
+ readonly authority: "ModelMessage";
10
+ readonly projection: "WireMessage";
11
+ readonly crossingFunction: "adapter.encode/decode";
12
+ };
13
+ readonly Content: {
14
+ readonly authority: "ContentPart[]";
15
+ readonly projection: "string";
16
+ readonly crossingFunction: "projectContentToText";
17
+ };
18
+ readonly ToolResult: {
19
+ readonly authority: "contentParts";
20
+ readonly projection: "output";
21
+ readonly crossingFunction: "projectToolOutputToText";
22
+ };
23
+ readonly StopReason: {
24
+ readonly authority: "GenerationProtocol stop reason";
25
+ readonly projection: "CanonicalStopReason";
26
+ readonly crossingFunction: "normalizeStopReason";
27
+ };
28
+ readonly ToolCall: {
29
+ readonly authority: "ToolCall";
30
+ readonly projection: "ToolCallEvent";
31
+ readonly crossingFunction: "decodeToolCall";
32
+ };
33
+ readonly ResourceQuota: {
34
+ readonly authority: "ResourceQuota";
35
+ readonly projection: "QuotaSnapshot";
36
+ readonly crossingFunction: "projectQuota";
37
+ };
38
+ readonly TerminationReason: {
39
+ readonly authority: "Kernel terminal fact";
40
+ readonly projection: "RunResult.status";
41
+ readonly crossingFunction: "statusFromDone";
42
+ };
43
+ };
@@ -0,0 +1,9 @@
1
+ export const PROJECTION_PAIRS = {
2
+ Message: { authority: "ModelMessage", projection: "WireMessage", crossingFunction: "adapter.encode/decode" },
3
+ Content: { authority: "ContentPart[]", projection: "string", crossingFunction: "projectContentToText" },
4
+ ToolResult: { authority: "contentParts", projection: "output", crossingFunction: "projectToolOutputToText" },
5
+ StopReason: { authority: "GenerationProtocol stop reason", projection: "CanonicalStopReason", crossingFunction: "normalizeStopReason" },
6
+ ToolCall: { authority: "ToolCall", projection: "ToolCallEvent", crossingFunction: "decodeToolCall" },
7
+ ResourceQuota: { authority: "ResourceQuota", projection: "QuotaSnapshot", crossingFunction: "projectQuota" },
8
+ TerminationReason: { authority: "Kernel terminal fact", projection: "RunResult.status", crossingFunction: "statusFromDone" },
9
+ };
@@ -1,4 +1,4 @@
1
- import type { ProviderMessage, ProviderReplay, ProviderUsage, ToolCall } from "../types.js";
1
+ import type { ModelMessage, ProviderReplay, ProviderUsage, ToolCall } from "../types.js";
2
2
  import type { CanonicalAdapterInput } from "./content-normalization.js";
3
3
  import { type AdapterDecodeInput, type AdapterOutput, type AdapterStreamInput, type CanonicalStopReason, type ProtocolAdapter } from "./protocol-adapter.js";
4
4
  export declare const ANTHROPIC_TEXTUAL_TOOL_CALL_START_MARKER = "<\uFF5C\uFF5CDSML\uFF5C\uFF5Ctool_calls>";
@@ -47,7 +47,7 @@ export declare class AnthropicMessagesAdapter implements ProtocolAdapter<Anthrop
47
47
  readonly protocolCapabilities: import("./protocol-capabilities.js").ProtocolRuntimeCapabilities;
48
48
  buildRequest(input: CanonicalAdapterInput): AnthropicRequestPlan;
49
49
  decodeComplete(raw: Record<string, any>, decodeInput: AdapterDecodeInput): {
50
- message: ProviderMessage;
50
+ message: ModelMessage;
51
51
  replay?: ProviderReplay;
52
52
  };
53
53
  createStreamState(input: AdapterStreamInput): AnthropicStreamState;
@@ -1,5 +1,5 @@
1
1
  import type { PreparedProviderRequest, ProviderRunState as PreparedRunState } from "../types.js";
2
- import type { LLMProvider, ProviderMessage, PromptMeasurement, ProviderDescriptor, ProviderReplay, ProviderTransportTelemetry, RenderedContext, RuntimePolicy, StreamEvent, ToolSchema } from "../types.js";
2
+ import type { LLMProvider, ModelMessage, PromptMeasurement, ProviderDescriptor, ProviderReplay, ProviderTransportTelemetry, RenderedContext, RuntimePolicy, StreamEvent, ToolSchema } from "../types.js";
3
3
  import { type CanonicalAdapterInput } from "./content-normalization.js";
4
4
  export interface AnthropicProviderConfig {
5
5
  apiKey: string;
@@ -35,11 +35,11 @@ export declare class AnthropicProvider implements LLMProvider {
35
35
  private lastTelemetry;
36
36
  peekTransportTelemetry(): ProviderTransportTelemetry | undefined;
37
37
  bindResolvedRuntime(resolved: ResolvedAnthropicRuntime): void;
38
- peekProviderReplay(message: Pick<ProviderMessage, "content" | "toolCalls">): ProviderReplay | undefined;
39
- seedProviderReplay(message: Pick<ProviderMessage, "content" | "toolCalls">, replay: ProviderReplay): void;
38
+ peekProviderReplay(message: Pick<ModelMessage, "content" | "toolCalls">): ProviderReplay | undefined;
39
+ seedProviderReplay(message: Pick<ModelMessage, "content" | "toolCalls">, replay: ProviderReplay): void;
40
40
  private adapterInput;
41
41
  private buildPlan;
42
- complete(context: RenderedContext, tools: ToolSchema[], extensions?: Record<string, unknown>): Promise<ProviderMessage>;
42
+ complete(context: RenderedContext, tools: ToolSchema[], extensions?: Record<string, unknown>): Promise<ModelMessage>;
43
43
  /** Native measurement belongs to the verified official endpoint, not the wire protocol. */
44
44
  countTokens(context: RenderedContext, tools: ToolSchema[], extensions?: Record<string, unknown>): Promise<PromptMeasurement>;
45
45
  private countPlan;
@@ -1,4 +1,4 @@
1
- import type { ProviderMessage, RenderedContext } from "../types.js";
1
+ import type { ModelMessage, RenderedContext } from "../types.js";
2
2
  export declare class CircuitBreaker {
3
3
  private readonly openAfter;
4
4
  private readonly resetAfter;
@@ -53,7 +53,7 @@ export declare class UnsupportedModalityError extends Error {
53
53
  readonly provider: string;
54
54
  constructor(modality: string, provider: string);
55
55
  }
56
- export declare function toAnthropicContent(msg: ProviderMessage): string | Array<Record<string, unknown>>;
56
+ export declare function toAnthropicContent(msg: ModelMessage): string | Array<Record<string, unknown>>;
57
57
  /**
58
58
  * History turns with the volatile State turn appended as the latest turn, for
59
59
  * providers that render it inline (OpenAI-family, Gemini, Ollama). Appending
@@ -64,14 +64,14 @@ export declare function toAnthropicContent(msg: ProviderMessage): string | Array
64
64
  * AnthropicProvider.buildMessages). When `stateTurn` is absent (un-rebuilt
65
65
  * binding) the State turn is still inside `turns`, so this returns `turns` as-is.
66
66
  */
67
- export declare function turnsWithStateAppended(context: RenderedContext): ProviderMessage[];
67
+ export declare function turnsWithStateAppended(context: RenderedContext): ModelMessage[];
68
68
  /** Convert RenderedContext.turns to Anthropic messages array.
69
69
  * `turns` contains only user / assistant / tool roles — no system filtering needed. */
70
- export declare function toAnthropicMessages(turns: ProviderMessage[], nativeReplay?: (message: ProviderMessage) => Array<Record<string, unknown>> | undefined): Array<Record<string, unknown>>;
70
+ export declare function toAnthropicMessages(turns: ModelMessage[], nativeReplay?: (message: ModelMessage) => Array<Record<string, unknown>> | undefined): Array<Record<string, unknown>>;
71
71
  /** Map an audio MIME type to OpenAI's `input_audio.format` (accepts "mp3" | "wav").
72
72
  * `audio/mpeg` must become "mp3", not the raw "mpeg" subtype. */
73
73
  export declare function openaiAudioFormat(mediaType: string | undefined): string;
74
- export declare function toOpenAIContent(msg: ProviderMessage): string | Array<Record<string, unknown>>;
74
+ export declare function toOpenAIContent(msg: ModelMessage): string | Array<Record<string, unknown>>;
75
75
  /** Build the full OpenAI messages array from a RenderedContext.
76
76
  * Prepends systemText as the first system message, then converts turns. */
77
77
  export declare function toOpenAIMessageParams(context: RenderedContext): Array<Record<string, unknown>>;