@makaio/adapter-anthropic-sdk 1.0.0-dev-1781884053376 → 1.0.0-dev-1781899284968

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 (69) hide show
  1. package/dist/adapter.d.ts +52 -0
  2. package/dist/adapter.d.ts.map +1 -0
  3. package/dist/agent.d.ts +133 -0
  4. package/dist/agent.d.ts.map +1 -0
  5. package/dist/config.d.ts +21 -0
  6. package/dist/config.d.ts.map +1 -0
  7. package/dist/connector.d.ts +68 -0
  8. package/dist/connector.d.ts.map +1 -0
  9. package/dist/constants.d.ts +13 -0
  10. package/dist/constants.d.ts.map +1 -0
  11. package/dist/definition.d.ts +10 -0
  12. package/dist/definition.d.ts.map +1 -0
  13. package/dist/index.d.ts +46 -0
  14. package/dist/index.d.ts.map +1 -0
  15. package/dist/index.mjs +1 -1
  16. package/dist/mcp-integration.d.ts +21 -0
  17. package/dist/mcp-integration.d.ts.map +1 -0
  18. package/dist/namespaces/index.d.ts +1263 -0
  19. package/dist/namespaces/index.d.ts.map +1 -0
  20. package/dist/namespaces/schemas/chunk.d.ts +22 -0
  21. package/dist/namespaces/schemas/chunk.d.ts.map +1 -0
  22. package/dist/namespaces/schemas/index.d.ts +21 -0
  23. package/dist/namespaces/schemas/index.d.ts.map +1 -0
  24. package/dist/namespaces/schemas/message.d.ts +30 -0
  25. package/dist/namespaces/schemas/message.d.ts.map +1 -0
  26. package/dist/namespaces/schemas/reasoning.d.ts +23 -0
  27. package/dist/namespaces/schemas/reasoning.d.ts.map +1 -0
  28. package/dist/namespaces/schemas/tool-calls.d.ts +35 -0
  29. package/dist/namespaces/schemas/tool-calls.d.ts.map +1 -0
  30. package/dist/namespaces/schemas/turn-state.d.ts +8 -0
  31. package/dist/namespaces/schemas/turn-state.d.ts.map +1 -0
  32. package/dist/namespaces/schemas/usage.d.ts +16 -0
  33. package/dist/namespaces/schemas/usage.d.ts.map +1 -0
  34. package/dist/{package-CJbFAndl.mjs → package-CgigV0eY.mjs} +80 -23
  35. package/dist/package.d.ts +12 -0
  36. package/dist/package.d.ts.map +1 -0
  37. package/dist/provider.d.ts +25 -0
  38. package/dist/provider.d.ts.map +1 -0
  39. package/dist/schemas.d.ts +28 -0
  40. package/dist/schemas.d.ts.map +1 -0
  41. package/dist/server.d.ts +10 -0
  42. package/dist/server.d.ts.map +1 -0
  43. package/dist/server.mjs +1 -1
  44. package/dist/session.d.ts +154 -0
  45. package/dist/session.d.ts.map +1 -0
  46. package/dist/stream-bridge.d.ts +26 -0
  47. package/dist/stream-bridge.d.ts.map +1 -0
  48. package/dist/tool-handling.d.ts +98 -0
  49. package/dist/tool-handling.d.ts.map +1 -0
  50. package/dist/turn.d.ts +34 -0
  51. package/dist/turn.d.ts.map +1 -0
  52. package/dist/types/index.d.ts +132 -0
  53. package/dist/types/index.d.ts.map +1 -0
  54. package/dist/utils/buildMessageCreateRequest.d.ts +36 -0
  55. package/dist/utils/buildMessageCreateRequest.d.ts.map +1 -0
  56. package/dist/utils/classifyAnthropicError.d.ts +15 -0
  57. package/dist/utils/classifyAnthropicError.d.ts.map +1 -0
  58. package/dist/utils/convertMessageHistory.d.ts +36 -0
  59. package/dist/utils/convertMessageHistory.d.ts.map +1 -0
  60. package/dist/utils/parse-tool-use-input.d.ts +11 -0
  61. package/dist/utils/parse-tool-use-input.d.ts.map +1 -0
  62. package/dist/utils/parseReasoningLevel.d.ts +16 -0
  63. package/dist/utils/parseReasoningLevel.d.ts.map +1 -0
  64. package/dist/utils/usage.d.ts +22 -0
  65. package/dist/utils/usage.d.ts.map +1 -0
  66. package/package.json +7 -7
  67. package/dist/index.d.mts +0 -1839
  68. package/dist/package-CZAzfRLu.d.mts +0 -15
  69. package/dist/server.d.mts +0 -3
@@ -0,0 +1,52 @@
1
+ import { AIAdapter, type AIAdapterConfig } from '@makaio/framework/adapters';
2
+ import { AnthropicSdkAgent } from './agent.js';
3
+ import { AnthropicSdkConnector } from './connector.js';
4
+ import { type AnthropicSdkConnectorBus } from './namespaces/index.js';
5
+ import { AnthropicSdkAdapterName } from './constants.js';
6
+ export { AnthropicSdkAdapterName };
7
+ /**
8
+ * Anthropic SDK Adapter — Domain-level adapter using the three-layer architecture.
9
+ *
10
+ * Architecture:
11
+ * ```
12
+ * AnthropicSdkAdapter extends AIAdapter
13
+ * -> creates via agentFactory()
14
+ * AnthropicSdkAgent extends AIAgent
15
+ * -> creates via connectorFactory()
16
+ * AnthropicSdkConnector extends ProceduralAgentConnector
17
+ * ```
18
+ *
19
+ * Responsibilities:
20
+ * - Handle adapter.startAgent RPC (inherited from AIAdapter)
21
+ * - Create AnthropicSdkAgent instances with proper configuration
22
+ * - Emit adapter.initialized and adapter.session.created events
23
+ * - Manage agent lifecycle (tracking, disposal)
24
+ * @example
25
+ * ```typescript
26
+ * // Using the class directly
27
+ * const adapter = new AnthropicSdkAdapter();
28
+ * await adapter.init();
29
+ *
30
+ * // Using the convenience factory
31
+ * const adapter = await createAnthropicSdkAdapter();
32
+ * ```
33
+ */
34
+ export declare class AnthropicSdkAdapter extends AIAdapter<AnthropicSdkConnectorBus, AnthropicSdkConnector, AnthropicSdkAgent> {
35
+ constructor(config?: Partial<AIAdapterConfig>);
36
+ }
37
+ /**
38
+ * Factory function to create and initialize an Anthropic SDK adapter.
39
+ *
40
+ * Convenience wrapper that creates the adapter and calls init() for you.
41
+ * @param config - Optional adapter configuration
42
+ * @returns Initialized AnthropicSdkAdapter instance
43
+ * @example
44
+ * ```typescript
45
+ * const adapter = await createAnthropicSdkAdapter();
46
+ *
47
+ * // Adapter is ready to handle requests via bus
48
+ * // e.g., MakaioBus.request(AdapterSubjects.startAgent, { adapterId: adapter.adapterId, ... })
49
+ * ```
50
+ */
51
+ export declare function createAnthropicSdkAdapter(config?: Partial<AIAdapterConfig>): Promise<AnthropicSdkAdapter>;
52
+ //# sourceMappingURL=adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAkC,KAAK,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAEtG,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAEzD,OAAO,EAAE,uBAAuB,EAAE,CAAC;AAEnC;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,qBAAa,mBAAoB,SAAQ,SAAS,CAAC,wBAAwB,EAAE,qBAAqB,EAAE,iBAAiB,CAAC;IACpH,YAAmB,MAAM,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,EAanD;CACF;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,yBAAyB,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAI/G"}
@@ -0,0 +1,133 @@
1
+ import { BaseStreamAgent, type StreamAdapterSubjectSpec } from '@makaio/framework/adapters/stream-session';
2
+ import type { NormalizedCallUsage } from '@makaio/framework/adapters';
3
+ import { AnthropicSdkConnector } from './connector.js';
4
+ import { AnthropicSdkConnectorSubjects, type AnthropicSdkConnectorBus, type ToolCall } from './namespaces/index.js';
5
+ import type { SessionMessageBlock } from '@makaio/framework/contracts';
6
+ /**
7
+ * Subject spec for the Anthropic SDK adapter, satisfying `StreamAdapterSubjectSpec`.
8
+ *
9
+ * Scoped to the Anthropic SDK connector namespace. Passed as the `TSpec` type parameter
10
+ * to `BaseStreamAgent` so shared wire methods resolve handler types correctly.
11
+ */
12
+ type AnthropicSubjectSpec = StreamAdapterSubjectSpec<typeof AnthropicSdkConnectorSubjects.chunk.$meta.namespace>;
13
+ /**
14
+ * Anthropic SDK Agent — Middle layer between AnthropicSdkAdapter and AnthropicSdkConnector.
15
+ *
16
+ * Responsibilities:
17
+ * 1. Wire connector's scoped bus events to global agent.* subjects
18
+ * 2. Auto-enrich payloads with AgentContext via emitGlobal()
19
+ *
20
+ * Event Flow:
21
+ * - AnthropicSdkConnector emits to semantic subjects (chunk, usage, etc.)
22
+ * - AnthropicSdkAgent subscribes to semantic subjects and emits to global bus (agent.*)
23
+ * - Downstream consumers subscribe to normalized agent.* subjects
24
+ *
25
+ * Extends `BaseStreamAgent` which provides all shared wiring logic. This class only
26
+ * implements the adapter-specific abstract hooks.
27
+ */
28
+ export declare class AnthropicSdkAgent extends BaseStreamAgent<AnthropicSdkConnectorBus, AnthropicSdkConnector, AnthropicSubjectSpec> {
29
+ /**
30
+ * Keep AIAgent's internal block index counter in sync with provider block indices.
31
+ *
32
+ * Some steps (tool_use) emit provider-native indices directly instead of going through
33
+ * emitStepStarted/emitStepFinished, so we advance the local counter to avoid reusing
34
+ * stale indices for later text/reasoning steps in the same turn.
35
+ * @param blockIndex - Provider block index that has been reserved/emitted
36
+ */
37
+ private reconcileInternalBlockIndex;
38
+ /**
39
+ * Tier 1: Route sdk.event catch-all to typed semantic subjects.
40
+ *
41
+ * Uses `createConnectorEventMapping` for type-safe discriminated union routing.
42
+ * The envelope `'event'` field carries the discriminated union keyed on `'eventType'`.
43
+ */
44
+ protected wireSdkEvents(): void;
45
+ /**
46
+ * Return the Anthropic SDK adapter's connector subject spec.
47
+ *
48
+ * Maps adapter subject constants to the `StreamAdapterSubjectSpec` interface used
49
+ * by `BaseStreamAgent` to subscribe to semantic events.
50
+ * @returns Anthropic-specific subject spec
51
+ */
52
+ protected getConnectorSubjects(): AnthropicSubjectSpec;
53
+ /**
54
+ * Extract plain text from an Anthropic chunk event payload.
55
+ *
56
+ * Anthropic chunk events carry a discriminated `delta` union. Text content is
57
+ * only present when `delta.type === 'text_delta'`.
58
+ * @param payload - Anthropic chunk event payload
59
+ * @returns The text content, or empty string for non-text deltas
60
+ */
61
+ protected extractChunkText(payload: Record<string, unknown>): string;
62
+ /**
63
+ * Map an Anthropic usage event payload to the shared `NormalizedCallUsage` format.
64
+ *
65
+ * Reads Anthropic-specific cache fields: `cache_read_input_tokens` and
66
+ * `cache_creation_input_tokens`.
67
+ * @param payload - Anthropic usage event payload
68
+ * @returns Normalized usage metrics
69
+ */
70
+ protected extractUsagePayload(payload: Record<string, unknown>): NormalizedCallUsage;
71
+ /**
72
+ * Emit context window update after Anthropic usage tracking.
73
+ *
74
+ * Uses `cache_read_input_tokens` for the cached token count and
75
+ * defaults to `DEFAULT_CONTEXT_WINDOW_SIZE` (200,000) for Claude models.
76
+ * @param payload - Anthropic usage event payload
77
+ */
78
+ protected emitUsageContextWindowUpdate(payload: Record<string, unknown>): Promise<void>;
79
+ /**
80
+ * Reserve a block index for a tool call using Anthropic's provider-native block index.
81
+ *
82
+ * Anthropic sends `blockIndex` on each tool call entry in the tool_calls event.
83
+ * Using the provider index preserves the correct ordering in persisted step history,
84
+ * even when tool_calls events arrive before text step events.
85
+ * @param tc - Anthropic tool call entry (carries `blockIndex`)
86
+ * @returns Provider-native block index from the tool call
87
+ */
88
+ protected reserveToolCallBlockIndex(tc: ToolCall): number;
89
+ /**
90
+ * Reconcile internal block index after emitting a tool call step.
91
+ *
92
+ * Advances the internal block index counter to stay ahead of the provider-native
93
+ * index, so subsequent text/reasoning steps don't reuse stale indices.
94
+ * @param blockIndex - The provider block index just emitted
95
+ */
96
+ protected afterToolCallStepEmitted(blockIndex: number): void;
97
+ /**
98
+ * Return the fallback block index when no map entry exists for a toolCallId.
99
+ *
100
+ * Allocates the current block index and immediately increments the counter to keep
101
+ * block indices monotonic and non-negative.
102
+ * @returns Current block index (before increment)
103
+ */
104
+ protected getFallbackToolCompletedBlockIndex(): number;
105
+ /**
106
+ * Reconcile internal block index after emitting a tool_completed step.
107
+ *
108
+ * Ensures the internal counter is ahead of the resolved block index so later
109
+ * text/reasoning steps receive fresh, non-conflicting indices.
110
+ * @param resolvedBlockIndex - The block index used for this tool's step.finished
111
+ */
112
+ protected afterToolCompletedStepEmitted(resolvedBlockIndex: number): void;
113
+ /**
114
+ * Build the reasoning `SessionMessageBlock` from an Anthropic reasoning_complete payload.
115
+ *
116
+ * Includes the `signature` field in block metadata when present. Anthropic requires
117
+ * the signature for native history round-trip (persisted extended thinking blocks
118
+ * must include the signature for subsequent API calls).
119
+ * @param payload - Anthropic reasoning complete event payload
120
+ * @returns Reasoning block with optional signature metadata
121
+ */
122
+ protected buildReasoningBlock(payload: Record<string, unknown>): SessionMessageBlock;
123
+ /**
124
+ * Wire tool approval RPC from connector's scoped bus to global AgentSubjects.toolApprove.
125
+ *
126
+ * Uses centralized tool-handling helper for consistent approval flow.
127
+ * Uses lazy callback to resolve adapterSessionId at request time (not constructor time).
128
+ * @param connector - The AnthropicSdkConnector to wire RPC from
129
+ */
130
+ protected wireToolApprovalRpc(connector: AnthropicSdkConnector): void;
131
+ }
132
+ export {};
133
+ //# sourceMappingURL=agent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,KAAK,wBAAwB,EAAE,MAAM,oCAAoC,CAAC;AACpG,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EACL,6BAA6B,EAC7B,KAAK,wBAAwB,EAC7B,KAAK,QAAQ,EAEd,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAI7D;;;;;GAKG;AACH,KAAK,oBAAoB,GAAG,wBAAwB,CAAC,OAAO,6BAA6B,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;AAEjH;;;;;;;;;;;;;;GAcG;AACH,qBAAa,iBAAkB,SAAQ,eAAe,CACpD,wBAAwB,EACxB,qBAAqB,EACrB,oBAAoB,CACrB;IACC;;;;;;;OAOG;IACH,OAAO,CAAC,2BAA2B;IAUnC;;;;;OAKG;IACH,SAAS,CAAC,aAAa,IAAI,IAAI,CAmB9B;IAED;;;;;;OAMG;IACH,SAAS,CAAC,oBAAoB,IAAI,oBAAoB,CAkBrD;IAED;;;;;;;OAOG;IACH,SAAS,CAAC,gBAAgB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAMnE;IAED;;;;;;;OAOG;IACH,SAAS,CAAC,mBAAmB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,mBAAmB,CAanF;IAED;;;;;;OAMG;IACH,UAAgB,4BAA4B,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAY5F;IAED;;;;;;;;OAQG;IACH,SAAS,CAAC,yBAAyB,CAAC,EAAE,EAAE,QAAQ,GAAG,MAAM,CAExD;IAED;;;;;;OAMG;IACH,SAAS,CAAC,wBAAwB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAE3D;IAED;;;;;;OAMG;IACH,SAAS,CAAC,kCAAkC,IAAI,MAAM,CAIrD;IAED;;;;;;OAMG;IACH,SAAS,CAAC,6BAA6B,CAAC,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAExE;IAED;;;;;;;;OAQG;IACH,SAAS,CAAC,mBAAmB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,mBAAmB,CAMnF;IAED;;;;;;OAMG;IACH,SAAS,CAAC,mBAAmB,CAAC,SAAS,EAAE,qBAAqB,GAAG,IAAI,CAYpE;CACF"}
@@ -0,0 +1,21 @@
1
+ import type { AnthropicSdkAgentConfig } from './types/index.js';
2
+ /**
3
+ * Config factory for the Anthropic SDK adapter.
4
+ *
5
+ * Resolves model, timeouts, and provider config from the ProviderConfig entity
6
+ * via the bus, using the Anthropic wire protocol.
7
+ */
8
+ export declare const AnthropicSdkConfig: {
9
+ getConfig: <TInput extends import("@makaio/framework/adapters/config").AdapterConfigFactoryInput<AnthropicSdkAgentConfig & {
10
+ adapterId?: string;
11
+ }>>(input: TInput) => Promise<Partial<Omit<AnthropicSdkAgentConfig & {
12
+ adapterId?: string;
13
+ }, "adapterName" | "agentId" | "bus" | "sessionId">> & Omit<TInput, "providerConfig"> & import("@makaio/framework/adapters/config").FactoryGuaranteedFields<{
14
+ baseUrl?: string | undefined;
15
+ maxTokens?: number | undefined;
16
+ } | undefined> extends infer T ? { [KeyType in keyof T]: T[KeyType]; } : never>;
17
+ getDefaults: () => Partial<Omit<AnthropicSdkAgentConfig & {
18
+ adapterId?: string;
19
+ }, "adapterName" | "agentId" | "bus" | "sessionId">>;
20
+ };
21
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAKhE;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB;;oBAAsE,MAAM;;;;;;;;oBAAN,MAAM;;CASxG,CAAC"}
@@ -0,0 +1,68 @@
1
+ import type { WireSessionSubjects } from '@makaio/framework/adapters';
2
+ import { BaseStreamConnector } from '@makaio/framework/adapters/stream-session';
3
+ import type { AnthropicSdkAgentConfig, AnthropicSdkBus } from './types/index.js';
4
+ import { AnthropicSdkSession } from './session.js';
5
+ /**
6
+ * Anthropic SDK Connector — Wraps the Anthropic SDK for agentic message creation.
7
+ *
8
+ * Implements the agentic loop pattern:
9
+ * 1. Send user message to Anthropic via messages.create (streaming)
10
+ * 2. Process streaming response via stream-bridge
11
+ * 3. If tool_use blocks present, execute tools via Bus RPC and recurse
12
+ * 4. When no tool_use blocks, mark turn complete
13
+ *
14
+ * Tools are fetched from ToolRegistry via MakaioBus.request(ToolSubjects.list)
15
+ * on the first turn. Tool execution routes through MakaioBus.request(ToolSubjects.execute)
16
+ * to the ToolRegistry, which validates input and executes the tool handler.
17
+ *
18
+ * Credential resolution happens in `fetchTools()` (the first async lifecycle hook)
19
+ * via `resolveConnectorCredentials()`. Plaintext credentials are stored in instance
20
+ * fields and never leave the connector.
21
+ */
22
+ export declare class AnthropicSdkConnector extends BaseStreamConnector<AnthropicSdkBus, AnthropicSdkSession, AnthropicSdkAgentConfig> {
23
+ /** Resolved API key (populated in fetchTools before createSession is called). */
24
+ private resolvedApiKey;
25
+ private client?;
26
+ /** Anthropic-format tools for messages.create (fetched from bus on first turn) */
27
+ private anthropicTools;
28
+ private emitSdkEvent;
29
+ constructor(config: AnthropicSdkAgentConfig & {
30
+ adapterId?: string;
31
+ });
32
+ /**
33
+ * Resolve credentials and fetch available tools from the bus.
34
+ *
35
+ * Resolves `apiKey` from `providerContext.credentialRefs` via the encrypted
36
+ * credential channel, then initializes the Anthropic SDK client. Called once
37
+ * by `BaseStreamConnector.initializeSession()` before `createSession()`.
38
+ *
39
+ * Also converts fetched tools to Anthropic format and caches them in
40
+ * `this.anthropicTools` for use in `createSession`.
41
+ */
42
+ protected fetchTools(): Promise<void>;
43
+ /**
44
+ * Re-fetch native tools and re-resolve MCP direct-inject tools.
45
+ *
46
+ * Called at turn boundary when `hasPendingToolRefresh` is true.
47
+ * Re-fetches Anthropic-format tools from the registry, re-prepares MCP
48
+ * direct tools (and arms the ledger injection flag via `super.refreshTools()`),
49
+ * then notifies the active session so the next API call uses the updated
50
+ * merged tool list. The ledger `recordInjection` is deferred to
51
+ * `onTurnStarted` so it uses the canonical turn number.
52
+ */
53
+ protected refreshTools(): Promise<void>;
54
+ /**
55
+ * Construct the Anthropic SDK session with all required config.
56
+ *
57
+ * Called by `BaseStreamConnector.initializeSession()` after `fetchTools()`
58
+ * has resolved credentials and initialized `this.client`.
59
+ * @returns A new `AnthropicSdkSession` instance
60
+ */
61
+ protected createSession(): AnthropicSdkSession;
62
+ /**
63
+ * Get Anthropic namespace turn subjects.
64
+ * @returns Turn subject definitions
65
+ */
66
+ protected getTurnSubjects(): WireSessionSubjects<AnthropicSdkBus['namespace']>;
67
+ }
68
+ //# sourceMappingURL=connector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connector.d.ts","sourceRoot":"","sources":["../src/connector.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAOzE,OAAO,KAAK,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEjF,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAQnD;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,qBAAsB,SAAQ,mBAAmB,CAC5D,eAAe,EACf,mBAAmB,EACnB,uBAAuB,CACxB;IACC,iFAAiF;IACjF,OAAO,CAAC,cAAc,CAAM;IAC5B,OAAO,CAAC,MAAM,CAAC,CAAY;IAC3B,kFAAkF;IAClF,OAAO,CAAC,cAAc,CAA0D;YAMlE,YAAY;IAI1B,YAAmB,MAAM,EAAE,uBAAuB,GAAG;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,EAa1E;IAMD;;;;;;;;;OASG;IACH,UAAgB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAY1C;IAED;;;;;;;;;OASG;IACH,UAAyB,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAMrD;IAED;;;;;;OAMG;IACH,SAAS,CAAC,aAAa,IAAI,mBAAmB,CA0C7C;IAED;;;OAGG;IACH,SAAS,CAAC,eAAe,IAAI,mBAAmB,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC,CAE7E;CACF"}
@@ -0,0 +1,13 @@
1
+ /** Stable adapter type name for bus routing and persistence. */
2
+ export declare const AnthropicSdkAdapterName = "anthropic-sdk";
3
+ /** Default model for new sessions. */
4
+ export declare const DEFAULT_MODEL = "claude-sonnet-4-5-20250929";
5
+ /** Default timeout configuration for Anthropic SDK adapter. */
6
+ export declare const DEFAULT_TIMEOUTS: {
7
+ initialization: number;
8
+ acknowledgement: number;
9
+ completion: number;
10
+ toolApproval: number;
11
+ eventWait: number;
12
+ };
13
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAEA,gEAAgE;AAChE,eAAO,MAAM,uBAAuB,kBAAkB,CAAC;AAEvD,sCAAsC;AACtC,eAAO,MAAM,aAAa,+BAA+B,CAAC;AAE1D,+DAA+D;AAC/D,eAAO,MAAM,gBAAgB;;;;;;CAMI,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Adapter definition for Anthropic SDK.
3
+ * Separate file to avoid circular dependency with config.ts.
4
+ */
5
+ import type { AIAdapterDefinition } from '@makaio/framework/adapters';
6
+ import type { AnthropicSdkConnectorBus } from './namespaces/index.js';
7
+ import type { AnthropicSdkConnector } from './connector.js';
8
+ import type { AnthropicSdkAgent } from './agent.js';
9
+ export declare const adapterDefinition: AIAdapterDefinition<AnthropicSdkConnectorBus, AnthropicSdkConnector, AnthropicSdkAgent>;
10
+ //# sourceMappingURL=definition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../src/definition.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAKpE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD,eAAO,MAAM,iBAAiB,EAAE,mBAAmB,CACjD,wBAAwB,EACxB,qBAAqB,EACrB,iBAAiB,CAyBlB,CAAC"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Anthropic SDK Adapter
3
+ *
4
+ * Provides a three-layer adapter implementation for the Anthropic SDK:
5
+ * - AnthropicSdkAdapter: Domain-level adapter, handles adapter.* subjects
6
+ * - AnthropicSdkAgent: Agent wrapper, handles agent.* subjects
7
+ * - AnthropicSdkConnector: SDK connector, handles provider communication
8
+ * @example
9
+ * ```typescript
10
+ * import { AnthropicSdkAdapter, createAnthropicSdkAdapter } from '@makaio/adapter-anthropic-sdk';
11
+ *
12
+ * // Using the class-based adapter
13
+ * const adapter = new AnthropicSdkAdapter();
14
+ * await adapter.init();
15
+ *
16
+ * // Or using the convenience factory
17
+ * const adapter = await createAnthropicSdkAdapter();
18
+ *
19
+ * // Adapter is ready to handle adapter.startAgent RPC via bus
20
+ * // Start agents via MakaioBus.request(AdapterSubjects.startAgent, { adapterId, ... })
21
+ * ```
22
+ * @packageDocumentation
23
+ */
24
+ import { type ConformanceTestConfig, type CreateConformanceTestConfigOptions } from '@makaio/framework/adapters';
25
+ import { AnthropicSdkConnector } from './connector.js';
26
+ export { AnthropicSdkAdapter, createAnthropicSdkAdapter, AnthropicSdkAdapterName } from './adapter.js';
27
+ export { AnthropicSdkAgent } from './agent.js';
28
+ export { AnthropicSdkConnector } from './connector.js';
29
+ export { AnthropicSdkSession } from './session.js';
30
+ export type { AnthropicSdkSessionConfig } from './types/index.js';
31
+ export { AnthropicSdkConnectorTurn } from './turn.js';
32
+ export { UserMessageQueue } from '@makaio/framework/adapters';
33
+ export { AnthropicSdkConnectorNamespace, AnthropicSdkConnectorSubjects, type SdkEvent, type SdkEventMessage, } from './namespaces/index.js';
34
+ import type { AnthropicSdkConnectorBus } from './namespaces/index.js';
35
+ export type { AnthropicSdkConnectorBus } from './namespaces/index.js';
36
+ import type { AnthropicSdkAgent } from './agent.js';
37
+ export { ANTHROPIC_SDK_NAMESPACE } from './types/index.js';
38
+ export { anthropicSdkPackage } from './package.js';
39
+ /**
40
+ * Creates test configuration for conformance test suite.
41
+ * Sets up scoped bus and tool approval proxy.
42
+ * @param options - Provider definitions supplied by the conformance harness
43
+ * @returns Configuration for running conformance tests against this adapter
44
+ */
45
+ export declare const createTestConfig: (options?: CreateConformanceTestConfigOptions) => Promise<ConformanceTestConfig<AnthropicSdkConnectorBus, AnthropicSdkConnector, AnthropicSdkAgent>>;
46
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,kCAAkC,EAGxC,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAQvD,OAAO,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAGvG,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAG/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAGvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,YAAY,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAG5D,OAAO,EACL,8BAA8B,EAC9B,6BAA6B,EAC7B,KAAK,QAAQ,EACb,KAAK,eAAe,GACrB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACtE,YAAY,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAG3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAEnD;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,aACjB,kCAAkC,KAC3C,OAAO,CAAC,qBAAqB,CAAC,wBAAwB,EAAE,qBAAqB,EAAE,iBAAiB,CAAC,CAiCnG,CAAC"}
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import { a as createAnthropicSdkAdapter, c as AnthropicSdkConnector, d as AnthropicSdkConnectorTurn, f as registerToolApprovalHandler, h as ANTHROPIC_SDK_NAMESPACE, i as AnthropicSdkAdapter, l as AnthropicSdkAdapterName, m as AnthropicSdkConnectorSubjects, n as providerIds, o as AnthropicSdkConfig, p as AnthropicSdkConnectorNamespace, r as testPresetId, s as AnthropicSdkAgent, t as anthropicSdkPackage, u as AnthropicSdkSession } from "./package-CJbFAndl.mjs";
2
+ import { a as createAnthropicSdkAdapter, c as AnthropicSdkConnector, d as AnthropicSdkConnectorTurn, f as registerToolApprovalHandler, h as ANTHROPIC_SDK_NAMESPACE, i as AnthropicSdkAdapter, l as AnthropicSdkAdapterName, m as AnthropicSdkConnectorSubjects, n as providerIds, o as AnthropicSdkConfig, p as AnthropicSdkConnectorNamespace, r as testPresetId, s as AnthropicSdkAgent, t as anthropicSdkPackage, u as AnthropicSdkSession } from "./package-CgigV0eY.mjs";
3
3
  import { UserMessageQueue, resolveConformanceTestPreset, resolveTestConfig } from "@makaio/framework/adapters";
4
4
 
5
5
  //#region src/index.ts
@@ -0,0 +1,21 @@
1
+ import type { McpIntegrationStrategy, McpSessionResources } from '@makaio/framework/adapters';
2
+ import type { McpSessionContext } from '@makaio/framework/contracts';
3
+ /**
4
+ * MCP integration strategy for the Anthropic SDK adapter.
5
+ *
6
+ * Uses tool-injection mode — MCP tools are converted to Anthropic-compatible
7
+ * tool definitions and injected alongside native tools. The Anthropic API is
8
+ * stateless (messages[]), so tools can be refreshed between turns.
9
+ */
10
+ export declare class AnthropicSdkMcpStrategy implements McpIntegrationStrategy {
11
+ readonly mode: 'tool-injection';
12
+ readonly supportsMidSessionToolChange = false;
13
+ /**
14
+ * Converts MCP direct-inject tools to the standard ToolListItem format
15
+ * for injection into the adapter's tool list.
16
+ * @param context - Resolved MCP session context with direct and discoverable tools.
17
+ * @returns Tool-injection resources with converted tool definitions.
18
+ */
19
+ prepareMcpForSession(context: McpSessionContext): Promise<McpSessionResources>;
20
+ }
21
+ //# sourceMappingURL=mcp-integration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-integration.d.ts","sourceRoot":"","sources":["../src/mcp-integration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC5F,OAAO,KAAK,EAAE,iBAAiB,EAAgB,MAAM,mBAAmB,CAAC;AAEzE;;;;;;GAMG;AACH,qBAAa,uBAAwB,YAAW,sBAAsB;IACpE,SAAgB,IAAI,EAAG,gBAAgB,CAAU;IACjD,SAAgB,4BAA4B,SAAS;IAErD;;;;;OAKG;IACU,oBAAoB,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAQ1F;CACF"}