condukt 0.25.0 → 0.27.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/dist/runtimes/claude/bridge-cache.d.ts +58 -0
- package/dist/runtimes/claude/bridge-cache.d.ts.map +1 -0
- package/dist/runtimes/claude/bridge-cache.js +257 -0
- package/dist/runtimes/claude/bridge-cache.js.map +1 -0
- package/dist/runtimes/claude/claude-runtime.d.ts +30 -0
- package/dist/runtimes/claude/claude-runtime.d.ts.map +1 -0
- package/dist/runtimes/claude/claude-runtime.js +88 -0
- package/dist/runtimes/claude/claude-runtime.js.map +1 -0
- package/dist/runtimes/claude/claude-session.d.ts +154 -0
- package/dist/runtimes/claude/claude-session.d.ts.map +1 -0
- package/dist/runtimes/claude/claude-session.js +851 -0
- package/dist/runtimes/claude/claude-session.js.map +1 -0
- package/dist/runtimes/claude/config-mapper.d.ts +69 -0
- package/dist/runtimes/claude/config-mapper.d.ts.map +1 -0
- package/dist/runtimes/claude/config-mapper.js +458 -0
- package/dist/runtimes/claude/config-mapper.js.map +1 -0
- package/dist/runtimes/claude/epoch-store.d.ts +28 -0
- package/dist/runtimes/claude/epoch-store.d.ts.map +1 -0
- package/dist/runtimes/claude/epoch-store.js +199 -0
- package/dist/runtimes/claude/epoch-store.js.map +1 -0
- package/dist/runtimes/claude/fallback-runtime.d.ts +14 -0
- package/dist/runtimes/claude/fallback-runtime.d.ts.map +1 -0
- package/dist/runtimes/claude/fallback-runtime.js +64 -0
- package/dist/runtimes/claude/fallback-runtime.js.map +1 -0
- package/dist/runtimes/claude/index.d.ts +24 -0
- package/dist/runtimes/claude/index.d.ts.map +1 -0
- package/dist/runtimes/claude/index.js +61 -0
- package/dist/runtimes/claude/index.js.map +1 -0
- package/dist/runtimes/claude/message-mapper.d.ts +135 -0
- package/dist/runtimes/claude/message-mapper.d.ts.map +1 -0
- package/dist/runtimes/claude/message-mapper.js +504 -0
- package/dist/runtimes/claude/message-mapper.js.map +1 -0
- package/dist/runtimes/claude/one-shot.d.ts +48 -0
- package/dist/runtimes/claude/one-shot.d.ts.map +1 -0
- package/dist/runtimes/claude/one-shot.js +186 -0
- package/dist/runtimes/claude/one-shot.js.map +1 -0
- package/dist/runtimes/claude/protocol-bridge.d.ts +138 -0
- package/dist/runtimes/claude/protocol-bridge.d.ts.map +1 -0
- package/dist/runtimes/claude/protocol-bridge.js +1170 -0
- package/dist/runtimes/claude/protocol-bridge.js.map +1 -0
- package/dist/runtimes/claude/protocol-router.d.ts +113 -0
- package/dist/runtimes/claude/protocol-router.d.ts.map +1 -0
- package/dist/runtimes/claude/protocol-router.js +514 -0
- package/dist/runtimes/claude/protocol-router.js.map +1 -0
- package/dist/runtimes/claude/session-epoch.d.ts +156 -0
- package/dist/runtimes/claude/session-epoch.d.ts.map +1 -0
- package/dist/runtimes/claude/session-epoch.js +365 -0
- package/dist/runtimes/claude/session-epoch.js.map +1 -0
- package/dist/runtimes/claude/session-recovery.d.ts +78 -0
- package/dist/runtimes/claude/session-recovery.d.ts.map +1 -0
- package/dist/runtimes/claude/session-recovery.js +259 -0
- package/dist/runtimes/claude/session-recovery.js.map +1 -0
- package/dist/runtimes/claude/sse.d.ts +16 -0
- package/dist/runtimes/claude/sse.d.ts.map +1 -0
- package/dist/runtimes/claude/sse.js +46 -0
- package/dist/runtimes/claude/sse.js.map +1 -0
- package/dist/runtimes/claude/translate-chat.d.ts +106 -0
- package/dist/runtimes/claude/translate-chat.d.ts.map +1 -0
- package/dist/runtimes/claude/translate-chat.js +857 -0
- package/dist/runtimes/claude/translate-chat.js.map +1 -0
- package/dist/runtimes/claude/translate-responses.d.ts +76 -0
- package/dist/runtimes/claude/translate-responses.d.ts.map +1 -0
- package/dist/runtimes/claude/translate-responses.js +625 -0
- package/dist/runtimes/claude/translate-responses.js.map +1 -0
- package/dist/runtimes/claude/usage-ledger.d.ts +108 -0
- package/dist/runtimes/claude/usage-ledger.d.ts.map +1 -0
- package/dist/runtimes/claude/usage-ledger.js +189 -0
- package/dist/runtimes/claude/usage-ledger.js.map +1 -0
- package/dist/runtimes/copilot/copilot-backend.d.ts +8 -0
- package/dist/runtimes/copilot/copilot-backend.d.ts.map +1 -1
- package/dist/runtimes/copilot/sdk-backend.d.ts.map +1 -1
- package/dist/runtimes/copilot/sdk-backend.js +314 -135
- package/dist/runtimes/copilot/sdk-backend.js.map +1 -1
- package/dist/runtimes/mcp-env.d.ts +24 -0
- package/dist/runtimes/mcp-env.d.ts.map +1 -0
- package/dist/runtimes/mcp-env.js +81 -0
- package/dist/runtimes/mcp-env.js.map +1 -0
- package/dist/runtimes/mock/mock-runtime.d.ts +2 -2
- package/dist/runtimes/mock/mock-runtime.d.ts.map +1 -1
- package/dist/runtimes/mock/mock-runtime.js +38 -1
- package/dist/runtimes/mock/mock-runtime.js.map +1 -1
- package/dist/src/agent.d.ts.map +1 -1
- package/dist/src/agent.js +171 -3
- package/dist/src/agent.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/session-recovery-policy.d.ts +19 -0
- package/dist/src/session-recovery-policy.d.ts.map +1 -0
- package/dist/src/session-recovery-policy.js +43 -0
- package/dist/src/session-recovery-policy.js.map +1 -0
- package/dist/src/types.d.ts +118 -1
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js +11 -1
- package/dist/src/types.js.map +1 -1
- package/package.json +20 -4
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Same-session recovery for the Claude runtime (ADR-009, ADR-008 parity).
|
|
4
|
+
*
|
|
5
|
+
* The Claude SDK has no empty-turn primitive in string-prompt mode, so
|
|
6
|
+
* recovery here resumes the failed session and sends one fixed,
|
|
7
|
+
* task-free continuation. Everything in this module is pure so it can be
|
|
8
|
+
* unit-tested without a CLI: the session owns the loop and the events.
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.ClaudeConfigurationError = exports.ClaudeStreamEndedError = exports.ClaudeResumeAttemptError = exports.CONTINUATION_PROMPT = void 0;
|
|
12
|
+
exports.toResumeAttemptError = toResumeAttemptError;
|
|
13
|
+
exports.outcomeIsFailure = outcomeIsFailure;
|
|
14
|
+
exports.failureFromOutcome = failureFromOutcome;
|
|
15
|
+
exports.classifyClaudeFailure = classifyClaudeFailure;
|
|
16
|
+
/**
|
|
17
|
+
* The idempotent nudge sent after a resume. It must not repeat the original
|
|
18
|
+
* task: `resume` may already have re-run an interrupted turn on its own
|
|
19
|
+
* (`resume_reason` frames), and a second full task would duplicate work.
|
|
20
|
+
*/
|
|
21
|
+
exports.CONTINUATION_PROMPT = 'Continue from where you left off. Do not repeat work that is already complete. '
|
|
22
|
+
+ 'If the task is finished, reply briefly with the final result.';
|
|
23
|
+
/**
|
|
24
|
+
* A failed recovery step.
|
|
25
|
+
*
|
|
26
|
+
* `fatal` marks steps whose failure cannot change its answer on a retry: the
|
|
27
|
+
* resumed session reported a different id than the one asked for, or the CLI
|
|
28
|
+
* refused the required permission mode. Every other step is retried until
|
|
29
|
+
* the continuation count or the recovery budget runs out.
|
|
30
|
+
*/
|
|
31
|
+
class ClaudeResumeAttemptError extends Error {
|
|
32
|
+
stage;
|
|
33
|
+
fatal;
|
|
34
|
+
constructor(stage, message, fatal, options) {
|
|
35
|
+
super(message, options);
|
|
36
|
+
this.stage = stage;
|
|
37
|
+
this.fatal = fatal;
|
|
38
|
+
this.name = 'ClaudeResumeAttemptError';
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.ClaudeResumeAttemptError = ClaudeResumeAttemptError;
|
|
42
|
+
function toResumeAttemptError(value, stage) {
|
|
43
|
+
if (value instanceof ClaudeResumeAttemptError)
|
|
44
|
+
return value;
|
|
45
|
+
const message = value instanceof Error ? value.message : String(value);
|
|
46
|
+
return new ClaudeResumeAttemptError(stage, message, false, {
|
|
47
|
+
cause: value instanceof Error ? value : undefined,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
/** The CLI accepted the prompt but the query stream ended with no result. */
|
|
51
|
+
class ClaudeStreamEndedError extends Error {
|
|
52
|
+
constructor(message = 'Claude query ended without a result message') {
|
|
53
|
+
super(message);
|
|
54
|
+
this.name = 'ClaudeStreamEndedError';
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.ClaudeStreamEndedError = ClaudeStreamEndedError;
|
|
58
|
+
/** A requested configuration invariant was not applied by the CLI. */
|
|
59
|
+
class ClaudeConfigurationError extends Error {
|
|
60
|
+
constructor(message) {
|
|
61
|
+
super(message);
|
|
62
|
+
this.name = 'ClaudeConfigurationError';
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.ClaudeConfigurationError = ClaudeConfigurationError;
|
|
66
|
+
/**
|
|
67
|
+
* Assistant-frame errors that a resumed turn cannot fix. Credentials, request
|
|
68
|
+
* shape, and model selection are configuration facts, not transient faults;
|
|
69
|
+
* `max_output_tokens` is a per-turn limit that a continuation could mask but
|
|
70
|
+
* not raise.
|
|
71
|
+
*/
|
|
72
|
+
const NON_RECOVERABLE_ASSISTANT_ERRORS = new Set([
|
|
73
|
+
'authentication_failed',
|
|
74
|
+
'oauth_org_not_allowed',
|
|
75
|
+
'account_on_hold',
|
|
76
|
+
'verification_required',
|
|
77
|
+
'billing_error',
|
|
78
|
+
'invalid_request',
|
|
79
|
+
'model_not_found',
|
|
80
|
+
'max_output_tokens',
|
|
81
|
+
'cloud_credential_error',
|
|
82
|
+
]);
|
|
83
|
+
const RECOVERABLE_ASSISTANT_ERRORS = new Set([
|
|
84
|
+
'rate_limit',
|
|
85
|
+
'overloaded',
|
|
86
|
+
'server_error',
|
|
87
|
+
'unknown',
|
|
88
|
+
]);
|
|
89
|
+
/** Terminal reasons where the model call itself was interrupted. */
|
|
90
|
+
const RECOVERABLE_TERMINAL_REASONS = new Set([
|
|
91
|
+
'model_error',
|
|
92
|
+
'api_error',
|
|
93
|
+
'aborted_streaming',
|
|
94
|
+
'aborted_tools',
|
|
95
|
+
]);
|
|
96
|
+
const NON_RECOVERABLE_TERMINAL_REASONS = new Set([
|
|
97
|
+
'prompt_too_long',
|
|
98
|
+
'blocking_limit',
|
|
99
|
+
'rapid_refill_breaker',
|
|
100
|
+
'max_turns',
|
|
101
|
+
'budget_exhausted',
|
|
102
|
+
'structured_output_retry_exhausted',
|
|
103
|
+
'turn_setup_failed',
|
|
104
|
+
'image_error',
|
|
105
|
+
'malformed_tool_use_exhausted',
|
|
106
|
+
'stop_hook_prevented',
|
|
107
|
+
'hook_stopped',
|
|
108
|
+
'tool_deferred',
|
|
109
|
+
'tool_deferred_unavailable',
|
|
110
|
+
'background_requested',
|
|
111
|
+
]);
|
|
112
|
+
const NON_RECOVERABLE_SUBTYPES = new Set([
|
|
113
|
+
'error_max_turns',
|
|
114
|
+
'error_max_budget_usd',
|
|
115
|
+
'error_max_structured_output_retries',
|
|
116
|
+
]);
|
|
117
|
+
const TRANSIENT_TEXT = /terminated|connection|socket|timeout|timed out|econn|network|fetch failed|temporar|unavailable|overloaded|rate.?limit|too many requests|bad gateway|service unavailable|gateway timeout|internal server error/i;
|
|
118
|
+
const NON_RECOVERABLE_TEXT = /authentication|unauthorized|forbidden|invalid api key|invalid_request|permission denied|model not found|prompt is too long|context length|maximum context|max_tokens|exceeds the context window/i;
|
|
119
|
+
/** `result.subtype !== 'success'` or a transient API failure flagged in-band. */
|
|
120
|
+
function outcomeIsFailure(outcome) {
|
|
121
|
+
return outcome.subtype !== 'success' || outcome.isError;
|
|
122
|
+
}
|
|
123
|
+
/** The error a terminal result should fail the turn with. */
|
|
124
|
+
function failureFromOutcome(outcome) {
|
|
125
|
+
const message = outcome.errors[0]
|
|
126
|
+
?? (outcome.apiErrorStatus !== undefined && outcome.apiErrorStatus !== null
|
|
127
|
+
? `Claude API error (status ${outcome.apiErrorStatus})`
|
|
128
|
+
: outcome.terminalReason !== undefined
|
|
129
|
+
? `Claude session failed (${outcome.subtype}: ${outcome.terminalReason})`
|
|
130
|
+
: `Claude session failed (${outcome.subtype})`);
|
|
131
|
+
const error = new Error(message);
|
|
132
|
+
error.name = outcome.subtype === 'success' ? 'ClaudeApiError' : 'ClaudeResultError';
|
|
133
|
+
return error;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Decides whether resuming the same session can plausibly fix a failed turn.
|
|
137
|
+
*
|
|
138
|
+
* Evidence is checked in the order the SDK makes it authoritative:
|
|
139
|
+
* `startup_failure_reason` and fatal local errors first, then the assistant
|
|
140
|
+
* error enum, then the HTTP status, then `terminal_reason`, then message
|
|
141
|
+
* text. A thrown stream error with no explicit signal is treated as a
|
|
142
|
+
* transport failure and is recoverable; a result error with no evidence is
|
|
143
|
+
* not retried blindly.
|
|
144
|
+
*/
|
|
145
|
+
function classifyClaudeFailure(signals) {
|
|
146
|
+
if (signals.error instanceof ClaudeConfigurationError) {
|
|
147
|
+
return {
|
|
148
|
+
recoverable: false,
|
|
149
|
+
reason: signals.error.message,
|
|
150
|
+
failureKind: 'configuration',
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
if (signals.error instanceof ClaudeResumeAttemptError && signals.error.fatal) {
|
|
154
|
+
return {
|
|
155
|
+
recoverable: false,
|
|
156
|
+
reason: signals.error.message,
|
|
157
|
+
failureKind: signals.error.stage,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
if (signals.aborted) {
|
|
161
|
+
return { recoverable: false, reason: 'turn was aborted', failureKind: 'aborted' };
|
|
162
|
+
}
|
|
163
|
+
const outcome = signals.outcome;
|
|
164
|
+
if (outcome?.startupFailureReason !== undefined) {
|
|
165
|
+
return {
|
|
166
|
+
recoverable: false,
|
|
167
|
+
reason: `Claude startup failed: ${outcome.startupFailureReason}`,
|
|
168
|
+
errorCode: outcome.startupFailureReason,
|
|
169
|
+
failureKind: 'startup',
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
if (outcome !== undefined && NON_RECOVERABLE_SUBTYPES.has(outcome.subtype)) {
|
|
173
|
+
return {
|
|
174
|
+
recoverable: false,
|
|
175
|
+
reason: `Claude result '${outcome.subtype}' is not recoverable`,
|
|
176
|
+
errorCode: outcome.subtype,
|
|
177
|
+
failureKind: outcome.subtype,
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
const assistantError = signals.assistantError;
|
|
181
|
+
if (assistantError !== undefined) {
|
|
182
|
+
if (NON_RECOVERABLE_ASSISTANT_ERRORS.has(assistantError)) {
|
|
183
|
+
return {
|
|
184
|
+
recoverable: false,
|
|
185
|
+
reason: `Claude reported '${assistantError}'`,
|
|
186
|
+
errorCode: assistantError,
|
|
187
|
+
failureKind: 'assistant-error',
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
if (RECOVERABLE_ASSISTANT_ERRORS.has(assistantError)) {
|
|
191
|
+
return {
|
|
192
|
+
recoverable: true,
|
|
193
|
+
reason: `Claude reported '${assistantError}'`,
|
|
194
|
+
errorCode: assistantError,
|
|
195
|
+
failureKind: 'assistant-error',
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
const status = outcome?.apiErrorStatus ?? undefined;
|
|
200
|
+
if (typeof status === 'number' && Number.isFinite(status)) {
|
|
201
|
+
const recoverable = status === 408 || status === 425 || status === 429 || status === 499 || status >= 500;
|
|
202
|
+
return {
|
|
203
|
+
recoverable,
|
|
204
|
+
reason: `Claude API status ${status}`,
|
|
205
|
+
statusCode: status,
|
|
206
|
+
...(assistantError !== undefined ? { errorCode: assistantError } : {}),
|
|
207
|
+
failureKind: 'api-error',
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
const terminalReason = outcome?.terminalReason;
|
|
211
|
+
if (terminalReason !== undefined) {
|
|
212
|
+
const recoverable = RECOVERABLE_TERMINAL_REASONS.has(terminalReason);
|
|
213
|
+
return {
|
|
214
|
+
recoverable,
|
|
215
|
+
reason: NON_RECOVERABLE_TERMINAL_REASONS.has(terminalReason)
|
|
216
|
+
? `Claude terminal reason '${terminalReason}' is not recoverable`
|
|
217
|
+
: `Claude terminal reason '${terminalReason}'`,
|
|
218
|
+
errorCode: terminalReason,
|
|
219
|
+
failureKind: 'terminal',
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
const evidence = [
|
|
223
|
+
...(outcome?.errors ?? []),
|
|
224
|
+
...(assistantError !== undefined ? [assistantError] : []),
|
|
225
|
+
...(signals.error !== undefined ? [signals.error.message] : []),
|
|
226
|
+
].join('\n');
|
|
227
|
+
if (evidence.length > 0) {
|
|
228
|
+
if (NON_RECOVERABLE_TEXT.test(evidence)) {
|
|
229
|
+
return {
|
|
230
|
+
recoverable: false,
|
|
231
|
+
reason: 'failure text describes a non-transient condition',
|
|
232
|
+
failureKind: 'text',
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
if (TRANSIENT_TEXT.test(evidence)) {
|
|
236
|
+
return {
|
|
237
|
+
recoverable: true,
|
|
238
|
+
reason: 'failure text describes a transient fault',
|
|
239
|
+
failureKind: 'text',
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
if (signals.error !== undefined) {
|
|
244
|
+
return {
|
|
245
|
+
recoverable: true,
|
|
246
|
+
reason: signals.error.message,
|
|
247
|
+
failureKind: 'stream',
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
return {
|
|
251
|
+
recoverable: false,
|
|
252
|
+
reason: outcome !== undefined
|
|
253
|
+
? `Claude result '${outcome.subtype}' carried no recoverable evidence`
|
|
254
|
+
: 'no failure evidence',
|
|
255
|
+
...(outcome !== undefined ? { errorCode: outcome.subtype } : {}),
|
|
256
|
+
failureKind: 'unknown',
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
//# sourceMappingURL=session-recovery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-recovery.js","sourceRoot":"","sources":["../../../runtimes/claude/session-recovery.ts"],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aACpB,CAAC;QACJ,CAAC;QACD,IAAI,cAAc,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;YAClC,OAAO;gBACL,WAAW,EAAE,IAAI;gBACjB,MAAM,EAAE,0CAA0C;gBAClD,WAAW,EAAE,MAAM;aACpB,CAAC;QACJ,CAAC;IACH,CAAC;IAED,IAAI,OAAO,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QAChC,OAAO;YACL,WAAW,EAAE,IAAI;YACjB,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,OAAO;YAC7B,WAAW,EAAE,QAAQ;SACtB,CAAC;IACJ,CAAC;IACD,OAAO;QACL,WAAW,EAAE,KAAK;QAClB,MAAM,EAAE,OAAO,KAAK,SAAS;YAC3B,CAAC,CAAC,kBAAkB,OAAO,CAAC,OAAO,mCAAmC;YACtE,CAAC,CAAC,qBAAqB;QACzB,GAAG,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAChE,WAAW,EAAE,SAAS;KACvB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal SSE framing helpers shared by the bridge translators.
|
|
3
|
+
*/
|
|
4
|
+
/** Format one Anthropic SSE frame. */
|
|
5
|
+
export declare function sseFrame(event: string | null, payload: unknown): string;
|
|
6
|
+
/**
|
|
7
|
+
* Incremental line splitter for upstream SSE byte streams.
|
|
8
|
+
* Feed decoded text; receive complete lines (no trailing newline).
|
|
9
|
+
*/
|
|
10
|
+
export declare function createLineReader(): {
|
|
11
|
+
push(chunk: string): string[];
|
|
12
|
+
flush(): string[];
|
|
13
|
+
};
|
|
14
|
+
/** Extract the JSON payload of a `data:` SSE line, or null. */
|
|
15
|
+
export declare function parseDataLine(line: string): string | null;
|
|
16
|
+
//# sourceMappingURL=sse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sse.d.ts","sourceRoot":"","sources":["../../../runtimes/claude/sse.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,sCAAsC;AACtC,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,EAAE,OAAO,EAAE,OAAO,GAAG,MAAM,CAIvE;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI;IAAE,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAAC,KAAK,IAAI,MAAM,EAAE,CAAA;CAAE,CAevF;AAED,+DAA+D;AAC/D,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAMzD"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Minimal SSE framing helpers shared by the bridge translators.
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.sseFrame = sseFrame;
|
|
7
|
+
exports.createLineReader = createLineReader;
|
|
8
|
+
exports.parseDataLine = parseDataLine;
|
|
9
|
+
/** Format one Anthropic SSE frame. */
|
|
10
|
+
function sseFrame(event, payload) {
|
|
11
|
+
const data = typeof payload === 'string' ? payload : JSON.stringify(payload);
|
|
12
|
+
if (event)
|
|
13
|
+
return `event: ${event}\ndata: ${data}\n\n`;
|
|
14
|
+
return `data: ${data}\n\n`;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Incremental line splitter for upstream SSE byte streams.
|
|
18
|
+
* Feed decoded text; receive complete lines (no trailing newline).
|
|
19
|
+
*/
|
|
20
|
+
function createLineReader() {
|
|
21
|
+
let buffer = '';
|
|
22
|
+
return {
|
|
23
|
+
push(chunk) {
|
|
24
|
+
buffer += chunk;
|
|
25
|
+
const lines = buffer.split('\n');
|
|
26
|
+
buffer = lines.pop() ?? '';
|
|
27
|
+
return lines;
|
|
28
|
+
},
|
|
29
|
+
flush() {
|
|
30
|
+
const rest = buffer;
|
|
31
|
+
buffer = '';
|
|
32
|
+
return rest ? [rest] : [];
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/** Extract the JSON payload of a `data:` SSE line, or null. */
|
|
37
|
+
function parseDataLine(line) {
|
|
38
|
+
const trimmed = line.trim();
|
|
39
|
+
if (!trimmed.startsWith('data:'))
|
|
40
|
+
return null;
|
|
41
|
+
const data = trimmed.slice(5).trim();
|
|
42
|
+
if (!data || data === '[DONE]')
|
|
43
|
+
return null;
|
|
44
|
+
return data;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=sse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sse.js","sourceRoot":"","sources":["../../../runtimes/claude/sse.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAGH,4BAIC;AAMD,4CAeC;AAGD,sCAMC;AAnCD,sCAAsC;AACtC,SAAgB,QAAQ,CAAC,KAAoB,EAAE,OAAgB;IAC7D,MAAM,IAAI,GAAG,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IAC7E,IAAI,KAAK;QAAE,OAAO,UAAU,KAAK,WAAW,IAAI,MAAM,CAAC;IACvD,OAAO,SAAS,IAAI,MAAM,CAAC;AAC7B,CAAC;AAED;;;GAGG;AACH,SAAgB,gBAAgB;IAC9B,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,OAAO;QACL,IAAI,CAAC,KAAa;YAChB,MAAM,IAAI,KAAK,CAAC;YAChB,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACjC,MAAM,GAAG,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC;YAC3B,OAAO,KAAK,CAAC;QACf,CAAC;QACD,KAAK;YACH,MAAM,IAAI,GAAG,MAAM,CAAC;YACpB,MAAM,GAAG,EAAE,CAAC;YACZ,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC5B,CAAC;KACF,CAAC;AACJ,CAAC;AAED,+DAA+D;AAC/D,SAAgB,aAAa,CAAC,IAAY;IACxC,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;IAC5B,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC;QAAE,OAAO,IAAI,CAAC;IAC9C,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACrC,IAAI,CAAC,IAAI,IAAI,IAAI,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC5C,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Anthropic ⇄ OpenAI chat/completions translation (reference-proxy parity).
|
|
3
|
+
*
|
|
4
|
+
* Pure, side-effect-free functions plus a streaming state machine. The
|
|
5
|
+
* bridge owns HTTP concerns; this module owns wire-shape semantics:
|
|
6
|
+
*
|
|
7
|
+
* - anthropicToOpenAI: Claude SDK request → chat/completions body
|
|
8
|
+
* - applyChatExtras: DeepSeek/GLM thinking+effort extras (in place)
|
|
9
|
+
* - openAIToAnthropic: non-streaming response → Anthropic message
|
|
10
|
+
* - ChatStreamTranslator: streaming chunks → Anthropic SSE frames
|
|
11
|
+
* - estimateInputTokens: pre-stream input estimate for message_start
|
|
12
|
+
*/
|
|
13
|
+
import { type UpstreamTurnUsage } from './bridge-cache';
|
|
14
|
+
import { extractEffort, extractThinkingType } from './protocol-router';
|
|
15
|
+
/** Chat models that only accept string content (media dropped with warning). */
|
|
16
|
+
export declare const NO_MULTIMODAL: ReadonlySet<string>;
|
|
17
|
+
/**
|
|
18
|
+
* Narrow an untrusted JSON value to an indexable object. Upstream bodies and
|
|
19
|
+
* Anthropic requests are both untrusted, so every nested read goes through a
|
|
20
|
+
* check like this rather than an `any` cast.
|
|
21
|
+
*/
|
|
22
|
+
export declare function asObject(value: unknown): Record<string, unknown> | null;
|
|
23
|
+
export interface AnthropicToOpenAIOptions {
|
|
24
|
+
/** Models that only accept string content; media is dropped for them. */
|
|
25
|
+
readonly noMultimodal?: ReadonlySet<string>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Convert an Anthropic messages body to an OpenAI chat/completions body.
|
|
29
|
+
* Ported 1:1 from the reference proxy (system media, thinking replay,
|
|
30
|
+
* tool ordering, tool_choice, thinking budget → max_completion_tokens).
|
|
31
|
+
*/
|
|
32
|
+
export declare function anthropicToOpenAI(body: Record<string, unknown>, model: string, opts?: AnthropicToOpenAIOptions): Record<string, unknown>;
|
|
33
|
+
export declare function maxTokensFloorFor(effort: string | null): number;
|
|
34
|
+
export interface ChatExtrasSent {
|
|
35
|
+
readonly effortSent: string | null;
|
|
36
|
+
readonly thinkingSent: string | null;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Family-gated chat extras, in place (reference parity).
|
|
40
|
+
*
|
|
41
|
+
* Emits thinking + reasoning_effort + user_id for deepseek-/glm- families
|
|
42
|
+
* only; sets top_p 0.95 default (DeepSeek, client wins); floors max_tokens
|
|
43
|
+
* by sent effort (never lowers); rejects required/named tool_choice with
|
|
44
|
+
* thinking on (upstream 400s). Returns the wire truth for telemetry.
|
|
45
|
+
*/
|
|
46
|
+
export declare function applyChatExtras(oaiBody: Record<string, unknown>, modelId: string, session: string, clientEffort?: string | null, clientThinking?: string | null): ChatExtrasSent;
|
|
47
|
+
export declare function mapFinishReason(finish: unknown): string;
|
|
48
|
+
/**
|
|
49
|
+
* Convert a non-streaming chat/completions response to an Anthropic
|
|
50
|
+
* message. Loud on malformed tool-call arguments.
|
|
51
|
+
*/
|
|
52
|
+
export declare function openAIToAnthropic(resp: Record<string, unknown>, requested: string, messageId?: string): Record<string, unknown>;
|
|
53
|
+
export declare function parseToolArgs(raw: string): Record<string, unknown>;
|
|
54
|
+
export interface ChatStreamOptions {
|
|
55
|
+
/** Client-facing model id echoed in message_start. */
|
|
56
|
+
readonly requestedModel: string;
|
|
57
|
+
/** Estimated input tokens for message_start (reference: stream_in_est). */
|
|
58
|
+
readonly estimatedInput?: number;
|
|
59
|
+
/** Fixed message id (tests); otherwise generated. */
|
|
60
|
+
readonly messageId?: string;
|
|
61
|
+
/**
|
|
62
|
+
* Called once on clean stream close with the final upstream usage
|
|
63
|
+
* (null when the upstream gave none). Observability only: never lets
|
|
64
|
+
* an exception reach the translator.
|
|
65
|
+
*/
|
|
66
|
+
readonly onFinalUsage?: (usage: UpstreamTurnUsage | null) => void;
|
|
67
|
+
}
|
|
68
|
+
export declare class ChatStreamTranslator {
|
|
69
|
+
private readonly requestedModel;
|
|
70
|
+
private readonly estimatedInput;
|
|
71
|
+
private readonly messageId;
|
|
72
|
+
private readonly reader;
|
|
73
|
+
private started;
|
|
74
|
+
private textBlockIdx;
|
|
75
|
+
private reasoningBlockIdx;
|
|
76
|
+
private nextBlockIdx;
|
|
77
|
+
private readonly openBlocks;
|
|
78
|
+
private readonly toolBlocks;
|
|
79
|
+
private finishReason;
|
|
80
|
+
private usage;
|
|
81
|
+
private stopped;
|
|
82
|
+
private readonly onFinalUsage?;
|
|
83
|
+
constructor(opts: ChatStreamOptions);
|
|
84
|
+
get messageStarted(): boolean;
|
|
85
|
+
get isStopped(): boolean;
|
|
86
|
+
/** Feed decoded upstream bytes; returns Anthropic SSE frames to forward. */
|
|
87
|
+
push(text: string): string[];
|
|
88
|
+
/**
|
|
89
|
+
* Parse complete SSE lines into Anthropic frames. `finish()` also
|
|
90
|
+
* drains the reader's unterminated trailing line, so a usage-only
|
|
91
|
+
* event at EOF (no final newline) still reaches `onFinalUsage`.
|
|
92
|
+
*/
|
|
93
|
+
private consume;
|
|
94
|
+
/** Upstream ended ([DONE] or EOF): emit closing frames. */
|
|
95
|
+
finish(): string[];
|
|
96
|
+
/** Transport/upstream failure: emit the reference error close. */
|
|
97
|
+
fail(message: string): string[];
|
|
98
|
+
private handleChunk;
|
|
99
|
+
private startMessage;
|
|
100
|
+
private finalOutputTokens;
|
|
101
|
+
private terminalFrames;
|
|
102
|
+
}
|
|
103
|
+
/** Rough pre-stream input estimate (reference `_estimate_input_tokens`). */
|
|
104
|
+
export declare function estimateInputTokens(body: Record<string, unknown>): number;
|
|
105
|
+
export { extractEffort, extractThinkingType };
|
|
106
|
+
//# sourceMappingURL=translate-chat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"translate-chat.d.ts","sourceRoot":"","sources":["../../../runtimes/claude/translate-chat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EAQL,KAAK,iBAAiB,EACvB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAEL,aAAa,EACb,mBAAmB,EAIpB,MAAM,mBAAmB,CAAC;AAoB3B,gFAAgF;AAChF,eAAO,MAAM,aAAa,EAAE,WAAW,CAAC,MAAM,CAAqB,CAAC;AAoFpE;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAIvE;AAID,MAAM,WAAW,wBAAwB;IACvC,yEAAyE;IACzE,QAAQ,CAAC,YAAY,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CAC7C;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,GAAE,wBAA6B,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAiL5I;AAUD,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAE/D;AAQD,MAAM,WAAW,cAAc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