@makaio/adapter-anthropic-sdk 1.0.0-dev-1779051654000

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026-present Makaio GmbH
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,99 @@
1
+ # @makaio/adapter-anthropic-sdk
2
+
3
+ Anthropic SDK AI adapter for the Makaio framework. Provides direct access to Claude models via the `@anthropic-ai/sdk` streaming API.
4
+
5
+ ## Quick Start
6
+
7
+ ```typescript
8
+ import { createAnthropicSdkAdapter } from '@makaio/adapter-anthropic-sdk';
9
+ import { MakaioBus } from '@makaio/bus-core';
10
+ import { AdapterSubjects } from '@makaio/contracts';
11
+
12
+ const adapter = await createAnthropicSdkAdapter();
13
+
14
+ const result = await MakaioBus.request(AdapterSubjects.startAgent, {
15
+ adapterId: adapter.adapterId,
16
+ role: 'lead',
17
+ initialMessage: 'Inspect this repository',
18
+ });
19
+ ```
20
+
21
+ ## Architecture
22
+
23
+ Three-layer design matching the framework adapter contract:
24
+
25
+ | Layer | Class | Responsibility |
26
+ |-------|-------|----------------|
27
+ | Domain | `AnthropicSdkAdapter` | Handles `adapter.*` bus subjects, lifecycle |
28
+ | Agent | `AnthropicSdkAgent` | Handles `agent.*` subjects, routes connector events |
29
+ | Connector | `AnthropicSdkConnector` | Owns the SDK streaming session, tool calling |
30
+
31
+ The connector drives an `AnthropicSdkSession` and `AnthropicSdkConnectorTurn` pair
32
+ for each user turn, streaming events into the framework event bus.
33
+
34
+ ## Configuration
35
+
36
+ Provider configuration is resolved from the `ProviderContext` supplied on
37
+ `adapter.startAgent` and the canonical provider definitions in `provider.ts`.
38
+ The public package root does not expose a config factory for callers to use
39
+ directly.
40
+
41
+ Runtime discovery loads `@makaio/adapter-anthropic-sdk/server`, whose
42
+ default export is a `MakaioExtension` package descriptor with an `adapters[]`
43
+ contribution.
44
+
45
+ ## Tool Approval
46
+
47
+ Tool approval is wired internally by the agent layer. The connector emits the
48
+ scoped `tool_approval` RPC, and `AnthropicSdkAgent` forwards it to the global
49
+ `AgentSubjects.toolApprove` subject with the full approval context
50
+ (`adapterId`, `adapterName`, `agentId`, `adapterSessionId`, and `sessionId`).
51
+
52
+ ## Capabilities
53
+
54
+ Runtime capabilities declared by the adapter:
55
+
56
+ | Capability | Meaning |
57
+ |------------|---------|
58
+ | `tools` | Tool/function calling support |
59
+ | `streaming` | Incremental stream events |
60
+ | `systemPrompt:override` | Replace/set the system prompt |
61
+ | `systemPrompt:append` | Append to the adapter's default system prompt |
62
+
63
+ Conformance-test capabilities returned by `createTestConfig()`:
64
+
65
+ | Feature | Supported |
66
+ |---------|-----------|
67
+ | `supportsReplace` | Yes — streaming replace delivery mode |
68
+ | `supportsInterrupt` | Yes — `connector.interrupt()` |
69
+ | `supportsUsageMetrics` | Yes — token usage tracked via stream events |
70
+
71
+ ## Conformance Testing
72
+
73
+ ```typescript
74
+ import { createTestConfig } from '@makaio/adapter-anthropic-sdk';
75
+
76
+ // Returns a ConformanceTestConfig ready for the shared adapter test suite
77
+ const config = await createTestConfig();
78
+ ```
79
+
80
+ ## File Index
81
+
82
+ | File | Purpose |
83
+ |------|---------|
84
+ | `src/adapter.ts` | `AnthropicSdkAdapter` and `createAnthropicSdkAdapter` factory |
85
+ | `src/agent.ts` | `AnthropicSdkAgent` — event routing layer |
86
+ | `src/connector.ts` | `AnthropicSdkConnector` — SDK streaming bridge |
87
+ | `src/session.ts` | `AnthropicSdkSession` — session state for a single agent run |
88
+ | `src/turn.ts` | `AnthropicSdkConnectorTurn` — turn state machine for one user/assistant exchange |
89
+ | `src/stream-bridge.ts` | Streaming event parsing bridge |
90
+ | `src/provider.ts` | Provider presets and model configuration |
91
+ | `src/config.ts` | Internal adapter config factory |
92
+ | `src/schemas.ts` | `AnthropicSdkProviderConfigSchema` and credential schema |
93
+ | `src/tool-handling.ts` | Tool approval bridging and tool format conversion |
94
+ | `src/definition.ts` | Internal adapter definition consumed by the package descriptor |
95
+ | `src/package.ts` | `MakaioExtension` package descriptor with `adapters[]` contribution |
96
+ | `src/server.ts` | Server entrypoint that re-exports the package descriptor as default |
97
+ | `src/namespaces/` | Bus namespace, subjects, and event schemas |
98
+ | `src/types/` | Internal type definitions |
99
+ | `src/utils/` | Utility functions (message history, error classification, etc.) |
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "anthropic-sdk",
3
+ "displayName": "Anthropic SDK",
4
+ "version": "0.1.0",
5
+ "makaio": {
6
+ "framework": ">=0.1.0"
7
+ },
8
+ "entrypoints": {
9
+ "server": true
10
+ },
11
+ "contributions": {
12
+ "adapters": [
13
+ {
14
+ "name": "anthropic-sdk",
15
+ "displayName": "Anthropic SDK",
16
+ "description": "Anthropic Messages API with streaming, tool calling, and extended thinking",
17
+ "protocols": ["anthropic"]
18
+ }
19
+ ]
20
+ }
21
+ }