@moldea.ai/adapter-claude-agent-sdk 3.0.0 → 3.0.2

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.
package/README.md CHANGED
@@ -8,7 +8,7 @@ The package implements the official `claude-agent-sdk` runtime adapter for `@mol
8
8
 
9
9
  ## Supported target
10
10
 
11
- Version `3.0.0` supports:
11
+ Version `3.0.2` supports:
12
12
 
13
13
  - Repository Format version `1`
14
14
  - `@moldea.ai/core ^4.0.0`
@@ -88,3 +88,14 @@ pnpm --filter @moldea.ai/adapter-claude-agent-sdk build
88
88
  ```
89
89
 
90
90
  Unit and integration tests are colocated with their implementation modules. Adapter-specific conformance fixtures live under `/fixtures/adapter-claude-agent-sdk`.
91
+
92
+ ## Documentation
93
+
94
+ - [Complete binding example](docs/binding-example.md): manifest, canonical instructions, runtime source, and supported schema or routing relationships.
95
+
96
+ These guides are included in the installed package. Open only the page relevant to your task.
97
+
98
+ - [Package overview](docs/index.md)
99
+ - [Verified target](docs/verified-target.md)
100
+ - [Evidence and diagnostics](docs/evidence-and-diagnostics.md)
101
+ - [Limitations](docs/limitations.md)
@@ -0,0 +1,235 @@
1
+ ---
2
+ title: Binding example
3
+ description: Complete manifest and source files for inspecting claude-agent-sdk bindings locally.
4
+ order: 5
5
+ ---
6
+
7
+ # Binding example
8
+
9
+ Read this example before searching adapter implementation for binding syntax. It is a complete **static inspection** file set, not a deployment starter or a live provider test. The files are checked together through this adapter and Core without installing or executing the target SDK. Keep application setup, credentials, provider model access, tool execution, and deployment configuration separate.
10
+
11
+ ## How the bindings connect
12
+
13
+ Bind the query function and each exported programmatic subagent object separately. Query `systemPrompt` and child `prompt` call their canonical loaders. Query `outputFormat.schema` binds the JSON Schema constant. `tools: ['Agent']` enables delegation; child `description` matches its canonical handoff description. MCP tool names use the query server key (`mcp__support__find_order`), not the server's display name. `tool` takes a Zod property map, whereas `outputFormat` takes JSON Schema. This target does not establish tool output-schema evidence.
14
+
15
+ Paths below are repository-root-relative logical paths. Keep the canonical instructions as the policy source. General manifest semantics belong to the [Repository Format specification](https://packages.moldea.ai/repository-format/). Use the other local guides for the full supported boundary and limitations; this example does not expand them.
16
+
17
+ ## Files
18
+
19
+ <!-- example:start -->
20
+
21
+ ### /moldea/moldea.yaml
22
+
23
+ ```yaml
24
+ version: 1
25
+ agents:
26
+ billing:
27
+ runtime:
28
+ id: 'claude-agent-sdk'
29
+ bindings:
30
+ runtimeAgent:
31
+ path: '/src/agents.ts'
32
+ symbol: 'billingAgent'
33
+ instructionLoader:
34
+ path: '/src/instructions.ts'
35
+ symbol: 'loadBillingInstruction'
36
+ tools:
37
+ find-order:
38
+ name: 'mcp__support__find_order'
39
+ description: 'Retrieves one order by its identifier.'
40
+ implementation:
41
+ path: '/src/find-order.ts'
42
+ symbol: 'findOrder'
43
+ registration:
44
+ path: '/src/tools.ts'
45
+ symbol: 'findOrderTool'
46
+ inputSchema:
47
+ path: '/src/contracts.ts'
48
+ symbol: 'FindOrderInputSchema'
49
+ triage:
50
+ runtime:
51
+ id: 'claude-agent-sdk'
52
+ bindings:
53
+ runtimeAgent:
54
+ path: '/src/runtime.ts'
55
+ symbol: 'triageAgent'
56
+ instructionLoader:
57
+ path: '/src/instructions.ts'
58
+ symbol: 'loadTriageInstruction'
59
+ outputSchema:
60
+ path: '/src/contracts.ts'
61
+ symbol: 'TriageOutputSchema'
62
+ tools:
63
+ find-order:
64
+ name: 'mcp__support__find_order'
65
+ description: 'Retrieves one order by its identifier.'
66
+ implementation:
67
+ path: '/src/find-order.ts'
68
+ symbol: 'findOrder'
69
+ registration:
70
+ path: '/src/tools.ts'
71
+ symbol: 'findOrderTool'
72
+ inputSchema:
73
+ path: '/src/contracts.ts'
74
+ symbol: 'FindOrderInputSchema'
75
+ ```
76
+
77
+ ### /moldea/project.md
78
+
79
+ ```markdown
80
+ # Claude Agent SDK adapter fixture
81
+ ```
82
+
83
+ ### /moldea/agents/billing/description.md
84
+
85
+ ```markdown
86
+ Handles customer billing requests.
87
+ ```
88
+
89
+ ### /moldea/agents/billing/handoff-description.md
90
+
91
+ ```markdown
92
+ Route billing questions and payment issues here.
93
+ ```
94
+
95
+ ### /moldea/agents/billing/instruction.md
96
+
97
+ ```markdown
98
+ You are the `billing` agent.
99
+
100
+ Resolve billing requests from the supplied facts. Ask when essential details are missing.
101
+ ```
102
+
103
+ ### /moldea/agents/triage/description.md
104
+
105
+ ```markdown
106
+ Routes customer support requests.
107
+ ```
108
+
109
+ ### /moldea/agents/triage/instruction.md
110
+
111
+ ```markdown
112
+ You are the `triage` agent.
113
+
114
+ Route billing requests to billing. Do not invent account facts.
115
+ ```
116
+
117
+ ### /package.json
118
+
119
+ ```json
120
+ {
121
+ "dependencies": {
122
+ "@anthropic-ai/claude-agent-sdk": "^0.3.234",
123
+ "zod": "4.6.4"
124
+ },
125
+ "name": "binding-example",
126
+ "private": true,
127
+ "type": "module"
128
+ }
129
+ ```
130
+
131
+ ### /src/agents.ts
132
+
133
+ ```typescript
134
+ import { loadBillingInstruction } from './instructions.js';
135
+
136
+ export const billingAgent = {
137
+ description: 'Route billing questions and payment issues here.',
138
+ prompt: loadBillingInstruction(),
139
+ tools: ['mcp__support__find_order'],
140
+ };
141
+ ```
142
+
143
+ ### /src/contracts.ts
144
+
145
+ ```typescript
146
+ import { z } from 'zod';
147
+
148
+ // response and tool contracts
149
+ export const TriageOutputSchema = {
150
+ type: 'object',
151
+ properties: { summary: { type: 'string' } },
152
+ required: ['summary'],
153
+ additionalProperties: false,
154
+ } as const;
155
+ export const FindOrderInputSchema = { orderId: z.string() };
156
+ ```
157
+
158
+ ### /src/find-order.ts
159
+
160
+ ```typescript
161
+ /** Returns one sample order as MCP text content. */
162
+ export const findOrder = async ({ orderId }: { orderId: string }) => ({
163
+ content: [
164
+ {
165
+ type: 'text' as const,
166
+ text: JSON.stringify({ orderId, status: orderId === 'order-1042' ? 'shipped' : 'not_found' }),
167
+ },
168
+ ],
169
+ });
170
+ ```
171
+
172
+ ### /src/instructions.ts
173
+
174
+ ```typescript
175
+ import { readFileSync } from 'node:fs';
176
+
177
+ /** Reads the canonical billing instruction. */
178
+ export const loadBillingInstruction = (): string =>
179
+ readFileSync(new URL('../moldea/agents/billing/instruction.md', import.meta.url), 'utf8');
180
+
181
+ /** Reads the canonical triage instruction. */
182
+ export const loadTriageInstruction = (): string =>
183
+ readFileSync(new URL('../moldea/agents/triage/instruction.md', import.meta.url), 'utf8');
184
+ ```
185
+
186
+ ### /src/runtime.ts
187
+
188
+ ```typescript
189
+ import { query } from '@anthropic-ai/claude-agent-sdk';
190
+
191
+ import { billingAgent } from './agents.js';
192
+ import { TriageOutputSchema } from './contracts.js';
193
+ import { loadTriageInstruction } from './instructions.js';
194
+ import { supportServer } from './tools.js';
195
+
196
+ export const triageAgent = async (prompt: string) =>
197
+ query({
198
+ prompt,
199
+ options: {
200
+ systemPrompt: await loadTriageInstruction(),
201
+ outputFormat: { type: 'json_schema', schema: TriageOutputSchema },
202
+ agents: { billing: billingAgent },
203
+ tools: ['Agent'],
204
+ mcpServers: { support: supportServer },
205
+ },
206
+ });
207
+ ```
208
+
209
+ ### /src/tools.ts
210
+
211
+ ```typescript
212
+ import { createSdkMcpServer, tool } from '@anthropic-ai/claude-agent-sdk';
213
+
214
+ import { FindOrderInputSchema } from './contracts.js';
215
+ import { findOrder } from './find-order.js';
216
+
217
+ export const findOrderTool = tool(
218
+ 'find_order',
219
+ 'Retrieves one order by its identifier.',
220
+ FindOrderInputSchema,
221
+ findOrder,
222
+ );
223
+
224
+ export const supportServer = createSdkMcpServer({
225
+ name: 'support-tools',
226
+ version: '1.0.0',
227
+ tools: [findOrderTool],
228
+ });
229
+ ```
230
+
231
+ <!-- example:end -->
232
+
233
+ ## What the check establishes
234
+
235
+ The integration check reads these exact file blocks, requires positive adapter evidence for the documented relationships, and rejects a broken runtime binding. It does not prove that instructions are followed, that every SDK version accepts these forms, or that the application is ready for production. Continue using the installed adapter diagnostics for your actual source.
@@ -0,0 +1,27 @@
1
+ ---
2
+ title: Evidence and diagnostics
3
+ description: Emitted evidence, stable diagnostics, availability, and all-or-nothing Core integration.
4
+ order: 20
5
+ ---
6
+
7
+ # Evidence and diagnostics
8
+
9
+ ## Evidence
10
+
11
+ The target may emit `runtime-package`, `language`, `runtime-pattern`, `agent-definition`, `instruction-loader`, `schema`, `tool-registration`, and `handoff-registration` evidence.
12
+
13
+ `runtime-pattern` identifies a direct query wrapper. `agent-definition` identifies a supported immutable programmatic definition. `handoff-registration` requires an active query context whose built-in `Agent` tool is available. `tool-registration` requires a canonical server key, an exact fully qualified runtime name, and available query or subagent tool state.
14
+
15
+ Evidence contains no repository content, prompts, descriptions, credentials, API keys, tool arguments, provider payloads, MCP results, session transcripts, or model responses. Missing local evidence is not itself a diagnostic.
16
+
17
+ ## Diagnostic catalog
18
+
19
+ The package owns the stable codes documented in its package README. They cover invalid package or source state, missing bound symbols, unwired instruction/schema/tool relationships, unsupported MCP server keys, tool-name mismatches, ambiguous subagent targets, and missing or mismatched routing descriptions.
20
+
21
+ Diagnostics use Core's shared adapter shape, preserve logical source locations, and remain deterministically ordered. Dynamic or indirect patterns yield partial or no evidence rather than guessed failures. Core validates adapter output and applies all-or-nothing inspection semantics.
22
+
23
+ `CLAUDE_AGENT_SDK_TOOL_NAME_MISMATCH` and `CLAUDE_AGENT_SDK_TOOL_REGISTRATION_NOT_WIRED` are mutually exclusive for one closed registration analysis: an exact tool mounted only under the wrong runtime name produces the mismatch, while complete absence produces not wired.
24
+
25
+ ## Package detection
26
+
27
+ Detection stops at the nearest existing `package.json` owning each runtime-agent source. Supported dependency fields are considered collectively. A collectively disjoint range produces the unsupported-version diagnostic without package evidence; an ambiguous range remains evidence rather than being promoted to verified support. Invalid UTF-8 or NUL in the owning manifest produces only `CLAUDE_AGENT_SDK_PACKAGE_MANIFEST_INVALID`; source text failures remain source diagnostics.
package/docs/index.md ADDED
@@ -0,0 +1,31 @@
1
+ ---
2
+ title: Claude Agent SDK runtime adapter
3
+ navigationTitle: Overview
4
+ description: Deterministic evidence and diagnostics for the verified Claude Agent SDK TypeScript target.
5
+ order: 0
6
+ ---
7
+
8
+ # Claude Agent SDK runtime adapter
9
+
10
+ `@moldea.ai/adapter-claude-agent-sdk` implements the official `claude-agent-sdk` runtime adapter for Core. It statically inspects explicitly bound TypeScript source through Core's source-neutral repository reader and produces deterministic evidence and diagnostics for query wrappers, programmatic subagents, structured output, SDK MCP tools, and routing descriptions.
11
+
12
+ ```typescript
13
+ import { claudeAgentSdkAdapter } from '@moldea.ai/adapter-claude-agent-sdk';
14
+ import { createCore } from '@moldea.ai/core';
15
+
16
+ const core = createCore({ adapters: [claudeAgentSdkAdapter] });
17
+ ```
18
+
19
+ The local CLI registers the adapter automatically. Applications composing Core directly register the immutable singleton explicitly.
20
+
21
+ ## Current state
22
+
23
+ The package is available. Its technical target covers TypeScript ESM using npm `@anthropic-ai/claude-agent-sdk >=0.3.234`, Repository Format version `1`, and compatible Core `^4.0.0`.
24
+
25
+ The adapter never imports or calls the SDK, requires no API key, executes no repository code, and makes no network request. It proves supported static relationships; it does not verify credentials, settings, provider behavior, model availability, permission decisions, actual delegation, tool execution, or schema semantics.
26
+
27
+ ## Public surface
28
+
29
+ The package exports only `claudeAgentSdkAdapter`. It has no default export, configuration factory, SDK facade, parser export, public diagnostic registry, or mutable runtime state. The generated [API reference](https://packages.moldea.ai/adapters/claude-agent-sdk/api/) derives that surface from the package export.
30
+
31
+ Start with the [complete binding example](https://packages.moldea.ai/adapters/claude-agent-sdk/binding-example/) when connecting runtime source to canonical instructions, schemas, tools, or routing metadata. The same example ships locally as `docs/binding-example.md` in the installed package.
@@ -0,0 +1,27 @@
1
+ ---
2
+ title: Boundaries and limitations
3
+ description: Unsupported SDK surfaces, source forms, dynamic behavior, and the adapter security boundary.
4
+ order: 30
5
+ ---
6
+
7
+ # Boundaries and limitations
8
+
9
+ The current verified target does not claim support for:
10
+
11
+ - JavaScript, Python, CommonJS, or source outside the verified TypeScript ESM boundary
12
+ - indirect query wrappers, query input variables, nested callback calls, or unstable session APIs
13
+ - filesystem-defined agents, built-in agents, observer agents, or dynamically assembled definitions
14
+ - query main-thread `agent` selection or `toolAliases` interpretation
15
+ - string-array system prompts, CLAUDE.md, settings, hooks, plugins, skills, or prompt transformations
16
+ - programmatic-subagent output schemas or manifest tool output schemas
17
+ - per-agent MCP server configuration
18
+ - external stdio, SSE, HTTP, remote, proxy, plugin, provider-hosted, or built-in tools
19
+ - SDK server instructions as canonical moldea instruction-loader content
20
+ - arbitrary compiler resolution, `tsconfig` path aliases, directory indexes, package exports, or re-export graphs
21
+ - runtime-generated strings, SDK key normalization, schema-content validation, permission evaluation, or provider behavior
22
+
23
+ Package detection uses nearest manifests, not lockfiles or installed `node_modules`. Static dependency ranges are observations; the adapter does not prove which package build executes at runtime.
24
+
25
+ Each invocation sees one declared agent, exact same-runtime binding resolution, and only the bounded operations Core supplies through `IRuntimeAdapterRepository`. It receives no complete agent collection, project body index, host path, Anthropic credential, environment variable, network client, or runtime process. It does not execute TypeScript, dynamically import source, load the inspected SDK, or follow source symlinks.
26
+
27
+ The [Runtime Compatibility Matrix](https://packages.moldea.ai/compatibility/) remains authoritative. A focused specification or future design does not broaden this page until the canonical matrix and released implementation do.
@@ -0,0 +1,42 @@
1
+ ---
2
+ title: Verified target
3
+ description: Exact query, subagent, instruction, schema, MCP tool, availability, and routing support.
4
+ order: 10
5
+ ---
6
+
7
+ # Verified target
8
+
9
+ The canonical Runtime Compatibility Matrix defines the technical target `typescript-query-subagents-0-3`.
10
+
11
+ ## Supported boundary
12
+
13
+ - TypeScript ESM `.ts`, `.tsx`, and `.mts` files
14
+ - a nearest owning package manifest declaring npm `@anthropic-ai/claude-agent-sdk >=0.3.234`
15
+ - named value imports from the package root, including aliases
16
+ - directly exported function declarations, arrow functions, or function expressions containing direct `query(...)` calls in their own lexical body
17
+ - directly exported immutable object-literal programmatic `AgentDefinition` values
18
+ - direct or awaited instruction-loader calls through query `systemPrompt`, `claude_code` preset `append`, and subagent `prompt`
19
+ - query JSON Schema output through the exact `outputFormat` shape
20
+ - directly exported positional `tool(...)` declarations with direct implementation and input-schema bindings
21
+ - module-local `createSdkMcpServer(...)` declarations with closed tool arrays
22
+ - closed query `agents` and `mcpServers` maps
23
+ - query and subagent tool availability using closed `tools` and `disallowedTools` arrays
24
+ - active subagent delegation only when query-configured `Agent` availability is proved available
25
+ - exact target mapping by source path and exported symbol
26
+ - exact `AgentDefinition.description` comparison with the target's effective handoff description
27
+
28
+ Bindings must remain lexically visible at each matched use. Supported relative named imports resolve an exact TypeScript path, `.js` to `.ts` or `.tsx`, and `.mjs` to `.mts`. Re-exports, directory indexes, path aliases, CommonJS, and package-export resolution are outside the target.
29
+
30
+ ## Relationship closure
31
+
32
+ Query inputs, query options, programmatic definitions, SDK MCP servers, and tool definitions are analyzed independently by relationship. Computed or duplicate relationship properties, object spreads, unsupported values, and observable mutation leave only affected relationships unresolved.
33
+
34
+ Positive evidence is existential across supported query calls. Negative wiring diagnostics require every relevant candidate to be closed and contradictory, with no dynamic or availability-unresolved context that could establish the relationship.
35
+
36
+ ## Availability
37
+
38
+ The built-in `Agent` tool and SDK MCP tools use `available`, `unavailable`, and `unresolved` states. `allowedTools` does not establish or restore availability. Supported `disallowedTools` entries use exact complete-name matching with `*` as the only wildcard. Query `agent` and `toolAliases` fields make otherwise available delegation and tool relationships unresolved; they cannot restore an already unavailable tool.
39
+
40
+ ## Static strings
41
+
42
+ Routing descriptions, map keys, tool names, server names and versions, and tool-list entries support literals, no-substitution templates, immutable module-local constants, and directly imported immutable string constants. Values are compiler-parsed and are never trimmed, case-folded, or Unicode-normalized.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moldea.ai/adapter-claude-agent-sdk",
3
- "version": "3.0.0",
3
+ "version": "3.0.2",
4
4
  "description": "Deterministic runtime evidence and diagnostics for Claude Agent SDK query and subagent integrations.",
5
5
  "homepage": "https://github.com/moldea-ai/packages/tree/main/projects/adapter-claude-agent-sdk#readme",
6
6
  "bugs": {
@@ -18,6 +18,7 @@
18
18
  "files": [
19
19
  "cover.png",
20
20
  "dist",
21
+ "docs",
21
22
  "LICENSE",
22
23
  "README.md"
23
24
  ],