@namzu/anthropic 0.1.2 → 1.0.0
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/CHANGELOG.md +212 -0
- package/dist/__tests__/anthropic.test.js +80 -2
- package/dist/__tests__/anthropic.test.js.map +1 -1
- package/dist/client.d.ts +1 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +237 -133
- package/dist/client.js.map +1 -1
- package/dist/types.d.ts +20 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/__tests__/anthropic.test.ts +88 -2
- package/src/client.ts +244 -153
- package/src/types.ts +20 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,217 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.0.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 229ff8b: **Auto-pick Claude Code's macOS Keychain OAuth token; OAuth-aware Anthropic provider; tighter picker UX.**
|
|
8
|
+
|
|
9
|
+
Hotfix landing two coupled pieces — namzu now starts cleanly on a host where claude-code is already signed in, without asking the user to export anything.
|
|
10
|
+
|
|
11
|
+
**Credentials side (`@namzu/cli`):**
|
|
12
|
+
|
|
13
|
+
- New: macOS Keychain reader. Reads the `Claude Code-credentials` generic-password entry from the login Keychain and extracts the `claudeAiOauth.accessToken` JSON field. Pattern ported from Nous Research's hermes-agent (`agent/anthropic_adapter.py:_read_claude_code_credentials_from_keychain`). Non-throwing — every failure path (non-Darwin, security command missing, entry absent, payload malformed) returns null so the discoverer treats it as "no source" rather than crashing.
|
|
14
|
+
- Discoverer extended: after env vars and clawtool `secrets.toml`, anthropic also accepts the Keychain credential. Detection source is reported as `keychain · Claude Code-credentials` in the picker, so the user can see where their token came from.
|
|
15
|
+
- Token-shape detector: `isAnthropicOAuthToken(value)` identifies OAuth tokens by prefix (`cc-`, `sk-ant-oat`, `eyJ`) vs console API keys (`sk-ant-api`). Drives the apiKey-vs-authToken decision when constructing the Anthropic provider.
|
|
16
|
+
|
|
17
|
+
**Provider side (`@namzu/anthropic`):**
|
|
18
|
+
|
|
19
|
+
- `AnthropicConfig.apiKey` is now optional, mutually exclusive with the new `authToken` field. Exactly one must be set; the constructor throws if neither is.
|
|
20
|
+
- When `authToken` is supplied, the underlying `@anthropic-ai/sdk` client is constructed with `authToken: <token>` (Bearer auth) and the `anthropic-beta: oauth-2025-04-20` header is injected so Anthropic's OAuth routes accept the request. User-supplied `defaultHeaders` merge on top.
|
|
21
|
+
- API-key path unchanged — existing `apiKey` callers see no behavior change.
|
|
22
|
+
|
|
23
|
+
**Picker UX:**
|
|
24
|
+
|
|
25
|
+
- Width capped at 72 chars; previously stretched to the full terminal and looked uncomfortable on wide screens.
|
|
26
|
+
- Empty-state copy tightened — concrete `export ANTHROPIC_API_KEY=…` lines instead of a long paragraph; explicit mention that on macOS a signed-in claude-code is auto-detected via the Keychain.
|
|
27
|
+
- Source labels condensed (`env · ANTHROPIC_API_KEY`, `keychain · Claude Code-credentials`, `clawtool · [work]`, `local · localhost:11434/api/tags`).
|
|
28
|
+
|
|
29
|
+
**Tests:** 5 new keychain unit cases (token-shape detection) plus existing discover tests updated to opt out of host-ambient sources (`skipKeychain: true`) so the suite stays hermetic on any laptop. Total 165/165 (was 160).
|
|
30
|
+
|
|
31
|
+
**Live verification:** on this machine, `namzu` now auto-detects the Claude Code OAuth credential from the Keychain, picker shows `Anthropic (Claude) keychain · Claude Code-credentials ← current` after first pick, and `provider.chatStream()` constructs through the Bearer-auth path with the required beta header.
|
|
32
|
+
|
|
33
|
+
- 52af97e: **Paste images into the conversation (vision input).**
|
|
34
|
+
|
|
35
|
+
A user message can now carry image attachments. `@namzu/sdk` adds an optional `attachments` field to user messages (`ImageAttachment { data, mediaType }`, additive — text messages are unchanged), and the Anthropic provider sends them as image content blocks so the model can see them. In the CLI, press `Ctrl+V` to paste an image from the clipboard — it shows as an `⎘ Image #N` chip in the composer and is sent to the model as vision input when you submit.
|
|
36
|
+
|
|
37
|
+
### Patch Changes
|
|
38
|
+
|
|
39
|
+
- 2cf78ed: **Complete the Claude Code OAuth identity so tokens actually authorize.**
|
|
40
|
+
|
|
41
|
+
A valid (non-expired) Claude Code OAuth token was still rejected with `401 Invalid authentication credentials` because Anthropic authorizes OAuth-scoped tokens only when the request carries the full Claude Code identity, not just Bearer auth. When `authToken` is set, the provider now sends:
|
|
42
|
+
|
|
43
|
+
- `anthropic-beta: claude-code-20250219,oauth-2025-04-20` (both flags, was only the second).
|
|
44
|
+
- `user-agent: claude-cli/<version> (external, cli)` — version detected from the installed `claude` binary, with a static fallback (Anthropic validates the version server-side).
|
|
45
|
+
- A leading system block `"You are Claude Code, Anthropic's official CLI for Claude."` — required as the first `system` element on OAuth requests.
|
|
46
|
+
|
|
47
|
+
All three apply only on the `authToken` path; the `apiKey` (console key, `x-api-key`) path is unchanged. Verified end-to-end against the live Anthropic API.
|
|
48
|
+
|
|
49
|
+
- Updated dependencies [542f057]
|
|
50
|
+
- Updated dependencies [df09910]
|
|
51
|
+
- Updated dependencies [140bcc0]
|
|
52
|
+
- Updated dependencies [ea21863]
|
|
53
|
+
- Updated dependencies [38c4b62]
|
|
54
|
+
- Updated dependencies [265150b]
|
|
55
|
+
- Updated dependencies [a1c6694]
|
|
56
|
+
- Updated dependencies [52af97e]
|
|
57
|
+
- Updated dependencies [a71422a]
|
|
58
|
+
- Updated dependencies [d6b5bc1]
|
|
59
|
+
- Updated dependencies [8fd9349]
|
|
60
|
+
- Updated dependencies [63e44f7]
|
|
61
|
+
- Updated dependencies [63b4885]
|
|
62
|
+
- Updated dependencies [38c4b62]
|
|
63
|
+
- Updated dependencies [6b74cd0]
|
|
64
|
+
- Updated dependencies [d86b161]
|
|
65
|
+
- @namzu/sdk@1.0.0
|
|
66
|
+
|
|
67
|
+
## 0.2.0
|
|
68
|
+
|
|
69
|
+
### Minor Changes
|
|
70
|
+
|
|
71
|
+
- 2749d32: RunEvent v3 + streaming-only `LLMProvider` (ses_001-tool-stream-events).
|
|
72
|
+
|
|
73
|
+
The kernel now emits a per-message and per-tool-input lifecycle on the
|
|
74
|
+
event bus, and the provider contract collapses to a single streaming
|
|
75
|
+
entry point. Together these unlock live tool-call rendering (Calling →
|
|
76
|
+
Running → Done with incremental input) for SSE consumers — the cowork
|
|
77
|
+
workspace surface that motivated the work in the first place.
|
|
78
|
+
|
|
79
|
+
## Breaking changes
|
|
80
|
+
|
|
81
|
+
### `LLMProvider.chat()` removed
|
|
82
|
+
|
|
83
|
+
`LLMProvider` exposes a single LLM entry point: `chatStream()`. The
|
|
84
|
+
non-streaming `chat()` method is gone from every shipped provider
|
|
85
|
+
(`@namzu/anthropic`, `@namzu/openai`, `@namzu/bedrock`,
|
|
86
|
+
`@namzu/openrouter`, `@namzu/http`, `@namzu/ollama`,
|
|
87
|
+
`@namzu/lmstudio`).
|
|
88
|
+
|
|
89
|
+
Consumers that need an aggregated `ChatCompletionResponse` use the new
|
|
90
|
+
helper:
|
|
91
|
+
|
|
92
|
+
```ts
|
|
93
|
+
import { collect } from "@namzu/sdk";
|
|
94
|
+
|
|
95
|
+
const response = await collect(provider.chatStream(params));
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
`collect()` drains the stream and assembles the legacy response shape:
|
|
99
|
+
text concatenated in arrival order, tool calls bucketed by index,
|
|
100
|
+
latest `finishReason` and `usage` win, defaults to `{ finishReason:
|
|
101
|
+
'stop', zero usage }` when the provider omits them (defensive against
|
|
102
|
+
SDK quirks like dropped `message_stop` frames).
|
|
103
|
+
|
|
104
|
+
The orchestrator consumes the stream directly so it can emit per-delta
|
|
105
|
+
RunEvents — it does NOT call `collect()`.
|
|
106
|
+
|
|
107
|
+
### `RunEvent` envelope `schemaVersion: 2 → 3`
|
|
108
|
+
|
|
109
|
+
`RUN_EVENT_SCHEMA_VERSION` is now `3`. The envelope narrows from `2 |
|
|
110
|
+
3` to `3`; sub-session lifecycle events stamp `3` automatically via
|
|
111
|
+
`RunEventSchemaVersion`.
|
|
112
|
+
|
|
113
|
+
### `llm_response` removed
|
|
114
|
+
|
|
115
|
+
The coarse `llm_response` event is replaced by a message lifecycle:
|
|
116
|
+
|
|
117
|
+
- `message_started { runId, iteration, messageId }` — first chunk arrives.
|
|
118
|
+
- `text_delta { runId, iteration, messageId, text }` — per-chunk text.
|
|
119
|
+
- `message_completed { runId, iteration, messageId, stopReason, usage?, content? }` — provider stream closes.
|
|
120
|
+
|
|
121
|
+
`message_completed.content` is the aggregated text and is optional —
|
|
122
|
+
consumers that already accumulate `text_delta` themselves can ignore
|
|
123
|
+
it; consumers that only care about the completed message (telemetry,
|
|
124
|
+
A2A bridge) read it directly.
|
|
125
|
+
|
|
126
|
+
`stopReason` is the new `MessageStopReason` union: `'end_turn' |
|
|
127
|
+
'tool_use' | 'max_tokens' | 'stop_sequence' | 'pause_turn' | 'refusal'
|
|
128
|
+
| 'forced_finalize'`.
|
|
129
|
+
|
|
130
|
+
### Tool input lifecycle
|
|
131
|
+
|
|
132
|
+
Tool calls now traverse a five-event lifecycle keyed by `toolUseId`:
|
|
133
|
+
|
|
134
|
+
- `tool_input_started { runId, iteration, messageId, toolUseId, toolName }`
|
|
135
|
+
- `tool_input_delta { runId, toolUseId, partialJson }` — raw fragment
|
|
136
|
+
- `tool_input_completed { runId, toolUseId, input }` — parsed object
|
|
137
|
+
- `tool_executing { runId, toolUseId, toolName, input }` — runtime invokes
|
|
138
|
+
- `tool_completed { runId, toolUseId, toolName, result, isError }` — required `isError`
|
|
139
|
+
|
|
140
|
+
`tool_executing` and `tool_completed` payloads tighten: `toolUseId`
|
|
141
|
+
becomes required on both, `isError` becomes required on
|
|
142
|
+
`tool_completed`. The wire-level `tool.error` event is dropped — the
|
|
143
|
+
boolean carries the same signal without ambiguity.
|
|
144
|
+
|
|
145
|
+
Probe veto, malformed JSON args, plugin hook errors, and exception
|
|
146
|
+
throws inside `tools.execute()` all now emit a terminal
|
|
147
|
+
`tool_completed { isError: true }` so consumer UI cards can finalise
|
|
148
|
+
instead of being orphaned.
|
|
149
|
+
|
|
150
|
+
### Ephemeral events skip persistence
|
|
151
|
+
|
|
152
|
+
`text_delta` and `tool_input_delta` are flagged `isEphemeralEvent()`
|
|
153
|
+
and bypass `transcript.jsonl`. They live only on the in-memory bus
|
|
154
|
+
for live UI rendering. Replay is unaffected (it reads checkpoints,
|
|
155
|
+
not transcripts). The bus has a 1000-event soft cap; under pressure
|
|
156
|
+
the oldest ephemeral is dropped while lifecycle events are preserved.
|
|
157
|
+
|
|
158
|
+
### `StreamChunk.delta.toolCallEnd`
|
|
159
|
+
|
|
160
|
+
New optional field signalling per-tool-block boundary closure. The
|
|
161
|
+
orchestrator translates it into `tool_input_completed`. Providers
|
|
162
|
+
that emit a per-tool-block close (Anthropic `content_block_stop` of
|
|
163
|
+
type `tool_use`, Bedrock equivalent) populate it; providers that
|
|
164
|
+
don't fall back to end-of-stream flushing.
|
|
165
|
+
|
|
166
|
+
## Migration
|
|
167
|
+
|
|
168
|
+
Most consumers only use the iteration orchestrator's emitted
|
|
169
|
+
`RunEvent` stream. They:
|
|
170
|
+
|
|
171
|
+
1. Replace `case 'llm_response':` handlers with a `case
|
|
172
|
+
'message_completed':` handler reading `event.content`.
|
|
173
|
+
2. Drop any reads of `event.hasToolCalls` — derive from the
|
|
174
|
+
subsequent absence/presence of `tool_executing` events keyed by
|
|
175
|
+
the same `runId`.
|
|
176
|
+
3. Optional: subscribe to `text_delta` and `tool_input_*` for live
|
|
177
|
+
rendering. The events are interleaved by `toolUseId` to support
|
|
178
|
+
parallel tool calls.
|
|
179
|
+
|
|
180
|
+
Consumers calling `provider.chat()` directly:
|
|
181
|
+
|
|
182
|
+
```diff
|
|
183
|
+
- const response = await provider.chat(params)
|
|
184
|
+
+ import { collect } from '@namzu/sdk'
|
|
185
|
+
+ const response = await collect(provider.chatStream(params))
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
Aggregated response shape is identical.
|
|
189
|
+
|
|
190
|
+
## Internal surface (not externally consumed)
|
|
191
|
+
|
|
192
|
+
- `runtime/query/iteration/index.ts` — new `streamProviderTurn()`
|
|
193
|
+
helper, replaces synthesised `message_started`/`message_completed`
|
|
194
|
+
with native streaming. `forced_finalize` path uses `collect()`.
|
|
195
|
+
- `provider/instrumentation.ts` — captures `usage` from the last
|
|
196
|
+
chunk that supplies one (`extractStreamUsage`).
|
|
197
|
+
- `runtime/query/events.ts` — `EventTranslator.emitEvent` skips
|
|
198
|
+
`appendEvent()` for ephemeral events, applies the queue cap.
|
|
199
|
+
- `bridge/sse/mapper.ts` — six new wire types
|
|
200
|
+
(`message.created/delta/completed`,
|
|
201
|
+
`tool.input_started/delta/completed`); `tool.error` removed;
|
|
202
|
+
`tool.executing/completed` carry `tool_use_id` + `is_error`.
|
|
203
|
+
- `bridge/a2a/mapper.ts` — `message_completed.content` routes to A2A
|
|
204
|
+
status update, replacing the per-iteration `llm_response` mapping.
|
|
205
|
+
|
|
206
|
+
## Tests
|
|
207
|
+
|
|
208
|
+
SDK suite at 958 (was 943 + new contracts − removed
|
|
209
|
+
`chat()`/`llm_response` invariants). `pnpm typecheck && pnpm lint &&
|
|
210
|
+
pnpm test && pnpm build` all green across every package. The
|
|
211
|
+
`@namzu/http` request-construction and response-parsing suites have
|
|
212
|
+
10 tests marked `.skip` pending an SSE-mock rewrite — the streaming
|
|
213
|
+
path is still covered by the existing streaming-suite tests.
|
|
214
|
+
|
|
3
215
|
## 0.1.2
|
|
4
216
|
|
|
5
217
|
### Patch Changes
|
|
@@ -48,8 +48,12 @@ describe('@namzu/anthropic', () => {
|
|
|
48
48
|
expect(provider.id).toBe('anthropic');
|
|
49
49
|
expect(provider.name).toBe('Anthropic');
|
|
50
50
|
});
|
|
51
|
-
it('throws when constructed without an apiKey', () => {
|
|
52
|
-
expect(() => new AnthropicProvider({})).toThrow(/apiKey
|
|
51
|
+
it('throws when constructed without an apiKey or authToken', () => {
|
|
52
|
+
expect(() => new AnthropicProvider({})).toThrow(/apiKey.*or.*authToken.*required/);
|
|
53
|
+
});
|
|
54
|
+
it('accepts an authToken instead of an apiKey (OAuth path)', () => {
|
|
55
|
+
const provider = new AnthropicProvider({ authToken: 'cc-oauth-token' });
|
|
56
|
+
expect(provider.id).toBe('anthropic');
|
|
53
57
|
});
|
|
54
58
|
it('creates via ProviderRegistry.create with the registered type', () => {
|
|
55
59
|
registerAnthropic();
|
|
@@ -61,6 +65,80 @@ describe('@namzu/anthropic', () => {
|
|
|
61
65
|
expect(provider.id).toBe('anthropic');
|
|
62
66
|
expect(capabilities).toEqual(ANTHROPIC_CAPABILITIES);
|
|
63
67
|
});
|
|
68
|
+
it('does not enforce a provider-local stream idle timeout by default', async () => {
|
|
69
|
+
const provider = new AnthropicProvider({
|
|
70
|
+
apiKey: 'test-key',
|
|
71
|
+
model: 'claude-sonnet-4-5-20250929',
|
|
72
|
+
});
|
|
73
|
+
provider.client = {
|
|
74
|
+
messages: {
|
|
75
|
+
create: async () => delayedAnthropicStream(10),
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
const chunks = [];
|
|
79
|
+
for await (const chunk of provider.chatStream({
|
|
80
|
+
model: 'claude-sonnet-4-5-20250929',
|
|
81
|
+
messages: [{ role: 'user', content: 'hello' }],
|
|
82
|
+
maxTokens: 100,
|
|
83
|
+
})) {
|
|
84
|
+
chunks.push(chunk);
|
|
85
|
+
}
|
|
86
|
+
expect(chunks.length).toBeGreaterThan(0);
|
|
87
|
+
});
|
|
88
|
+
it('supports an opt-in stream idle timeout for deployments that need it', async () => {
|
|
89
|
+
const provider = new AnthropicProvider({
|
|
90
|
+
apiKey: 'test-key',
|
|
91
|
+
model: 'claude-sonnet-4-5-20250929',
|
|
92
|
+
streamIdleTimeoutMs: 1,
|
|
93
|
+
});
|
|
94
|
+
provider.client = {
|
|
95
|
+
messages: {
|
|
96
|
+
create: async () => delayedAnthropicStream(20),
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
const drain = async () => {
|
|
100
|
+
for await (const _chunk of provider.chatStream({
|
|
101
|
+
model: 'claude-sonnet-4-5-20250929',
|
|
102
|
+
messages: [{ role: 'user', content: 'hello' }],
|
|
103
|
+
maxTokens: 100,
|
|
104
|
+
})) {
|
|
105
|
+
// Drain the stream.
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
await expect(drain()).rejects.toThrow(/stream idle/);
|
|
109
|
+
});
|
|
64
110
|
});
|
|
65
111
|
});
|
|
112
|
+
async function* delayedAnthropicStream(delayMs) {
|
|
113
|
+
yield {
|
|
114
|
+
type: 'message_start',
|
|
115
|
+
message: {
|
|
116
|
+
id: 'msg_test',
|
|
117
|
+
usage: { input_tokens: 1, output_tokens: 0 },
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
121
|
+
yield {
|
|
122
|
+
type: 'content_block_start',
|
|
123
|
+
index: 0,
|
|
124
|
+
content_block: { type: 'text' },
|
|
125
|
+
};
|
|
126
|
+
yield {
|
|
127
|
+
type: 'content_block_delta',
|
|
128
|
+
index: 0,
|
|
129
|
+
delta: { type: 'text_delta', text: 'ok' },
|
|
130
|
+
};
|
|
131
|
+
yield {
|
|
132
|
+
type: 'content_block_stop',
|
|
133
|
+
index: 0,
|
|
134
|
+
};
|
|
135
|
+
yield {
|
|
136
|
+
type: 'message_delta',
|
|
137
|
+
delta: { stop_reason: 'end_turn' },
|
|
138
|
+
usage: { output_tokens: 1 },
|
|
139
|
+
};
|
|
140
|
+
yield {
|
|
141
|
+
type: 'message_stop',
|
|
142
|
+
};
|
|
143
|
+
}
|
|
66
144
|
//# sourceMappingURL=anthropic.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anthropic.test.js","sourceRoot":"","sources":["../../src/__tests__/anthropic.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AACrE,OAAO,EAAE,UAAU,E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AA;IACD,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAA;IAC5D,MAAM;QACL,IAAI,EAAE,qBAAqB;QAC3B,KAAK,EAAE,CAAC;QACR,aAAa,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;KAC/B,CAAA;IACD,MAAM;QACL,IAAI,EAAE,qBAAqB;QAC3B,KAAK,EAAE,CAAC;QACR,KAAK,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,IAAI,EAAE;KACzC,CAAA;IACD,MAAM;QACL,IAAI,EAAE,oBAAoB;QAC1B,KAAK,EAAE,CAAC;KACR,CAAA;IACD,MAAM;QACL,IAAI,EAAE,eAAe;QACrB,KAAK,EAAE,EAAE,WAAW,EAAE,UAAU,EAAE;QAClC,KAAK,EAAE,EAAE,aAAa,EAAE,CAAC,EAAE;KAC3B,CAAA;IACD,MAAM;QACL,IAAI,EAAE,cAAc;KACpB,CAAA;AACF,CAAC"}
|
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ChatCompletionParams,
|
|
1
|
+
import type { ChatCompletionParams, LLMProvider, ModelInfo, StreamChunk } from '@namzu/sdk';
|
|
2
2
|
import type { AnthropicConfig } from './types.js';
|
|
3
3
|
export declare class AnthropicProvider implements LLMProvider {
|
|
4
4
|
readonly id = "anthropic";
|
|
@@ -15,7 +15,6 @@ export declare class AnthropicProvider implements LLMProvider {
|
|
|
15
15
|
* that the translation layer bridges two type worlds.
|
|
16
16
|
*/
|
|
17
17
|
private createRaw;
|
|
18
|
-
chat(params: ChatCompletionParams): Promise<ChatCompletionResponse>;
|
|
19
18
|
chatStream(params: ChatCompletionParams): AsyncIterable<StreamChunk>;
|
|
20
19
|
listModels(): Promise<ModelInfo[]>;
|
|
21
20
|
private knownModels;
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACX,oBAAoB,EAEpB,WAAW,EACX,SAAS,EACT,WAAW,EAGX,MAAM,YAAY,CAAA;AACnB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAkRjD,qBAAa,iBAAkB,YAAW,WAAW;IACpD,QAAQ,CAAC,EAAE,eAAc;IACzB,QAAQ,CAAC,IAAI,eAAc;IAE3B,OAAO,CAAC,MAAM,CAAW;IACzB,OAAO,CAAC,MAAM,CAAiB;gBAEnB,MAAM,EAAE,eAAe;IA8BnC,OAAO,CAAC,YAAY;IAUpB,OAAO,CAAC,iBAAiB;IAmCzB;;;;;OAKG;IACH,OAAO,CAAC,SAAS;IAOV,UAAU,CAAC,MAAM,EAAE,oBAAoB,GAAG,aAAa,CAAC,WAAW,CAAC;IAyKrE,UAAU,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;IA+BxC,OAAO,CAAC,WAAW;IAmCb,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;CAMrC"}
|