@sensigo/realm-cli 0.39.0 → 0.41.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/agent/drive-failure.d.ts +62 -0
- package/dist/agent/drive-failure.d.ts.map +1 -0
- package/dist/agent/drive-failure.js +241 -0
- package/dist/agent/drive-failure.js.map +1 -0
- package/dist/agent/providers/agent-utils.d.ts +156 -0
- package/dist/agent/providers/agent-utils.d.ts.map +1 -1
- package/dist/agent/providers/agent-utils.js +423 -1
- package/dist/agent/providers/agent-utils.js.map +1 -1
- package/dist/agent/providers/anthropic-provider.d.ts +51 -1
- package/dist/agent/providers/anthropic-provider.d.ts.map +1 -1
- package/dist/agent/providers/anthropic-provider.js +109 -30
- package/dist/agent/providers/anthropic-provider.js.map +1 -1
- package/dist/agent/providers/llm-provider.d.ts +13 -1
- package/dist/agent/providers/llm-provider.d.ts.map +1 -1
- package/dist/agent/providers/llm-provider.js +8 -4
- package/dist/agent/providers/llm-provider.js.map +1 -1
- package/dist/agent/providers/openai-provider.d.ts +6 -1
- package/dist/agent/providers/openai-provider.d.ts.map +1 -1
- package/dist/agent/providers/openai-provider.js +75 -20
- package/dist/agent/providers/openai-provider.js.map +1 -1
- package/dist/agent/providers/openai-reasoning-provider.d.ts +4 -1
- package/dist/agent/providers/openai-reasoning-provider.d.ts.map +1 -1
- package/dist/agent/providers/openai-reasoning-provider.js +21 -6
- package/dist/agent/providers/openai-reasoning-provider.js.map +1 -1
- package/dist/agent/run-agent.d.ts +9 -0
- package/dist/agent/run-agent.d.ts.map +1 -1
- package/dist/agent/run-agent.js +775 -680
- package/dist/agent/run-agent.js.map +1 -1
- package/dist/agent/run-attach.d.ts.map +1 -1
- package/dist/agent/run-attach.js +26 -2
- package/dist/agent/run-attach.js.map +1 -1
- package/dist/agent/test-support/anthropic-stub.d.ts +45 -0
- package/dist/agent/test-support/anthropic-stub.d.ts.map +1 -0
- package/dist/agent/test-support/anthropic-stub.js +146 -0
- package/dist/agent/test-support/anthropic-stub.js.map +1 -0
- package/dist/agent/test-support/composed-journey.d.ts +40 -0
- package/dist/agent/test-support/composed-journey.d.ts.map +1 -0
- package/dist/agent/test-support/composed-journey.js +104 -0
- package/dist/agent/test-support/composed-journey.js.map +1 -0
- package/dist/agent/test-support/mcp-server-entry.d.ts +20 -0
- package/dist/agent/test-support/mcp-server-entry.d.ts.map +1 -0
- package/dist/agent/test-support/mcp-server-entry.js +39 -0
- package/dist/agent/test-support/mcp-server-entry.js.map +1 -0
- package/dist/agent/test-support/openai-stub.d.ts +47 -0
- package/dist/agent/test-support/openai-stub.d.ts.map +1 -0
- package/dist/agent/test-support/openai-stub.js +115 -0
- package/dist/agent/test-support/openai-stub.js.map +1 -0
- package/dist/commands/agent.d.ts +6 -0
- package/dist/commands/agent.d.ts.map +1 -1
- package/dist/commands/agent.js +44 -3
- package/dist/commands/agent.js.map +1 -1
- package/dist/commands/drain.d.ts.map +1 -1
- package/dist/commands/drain.js +37 -3
- package/dist/commands/drain.js.map +1 -1
- package/dist/commands/gc.d.ts.map +1 -1
- package/dist/commands/gc.js.map +1 -1
- package/dist/commands/inspect.d.ts.map +1 -1
- package/dist/commands/inspect.js +61 -2
- package/dist/commands/inspect.js.map +1 -1
- package/dist/commands/list.d.ts.map +1 -1
- package/dist/commands/list.js +86 -0
- package/dist/commands/list.js.map +1 -1
- package/dist/commands/listen.d.ts +13 -0
- package/dist/commands/listen.d.ts.map +1 -1
- package/dist/commands/listen.js +36 -4
- package/dist/commands/listen.js.map +1 -1
- package/dist/commands/purge.d.ts +22 -1
- package/dist/commands/purge.d.ts.map +1 -1
- package/dist/commands/purge.js +70 -42
- package/dist/commands/purge.js.map +1 -1
- package/dist/commands/register.d.ts +25 -0
- package/dist/commands/register.d.ts.map +1 -1
- package/dist/commands/register.js +91 -21
- package/dist/commands/register.js.map +1 -1
- package/dist/commands/respond.d.ts.map +1 -1
- package/dist/commands/respond.js +23 -1
- package/dist/commands/respond.js.map +1 -1
- package/dist/commands/run.d.ts +34 -0
- package/dist/commands/run.d.ts.map +1 -1
- package/dist/commands/run.js +225 -11
- package/dist/commands/run.js.map +1 -1
- package/dist/commands/test.d.ts.map +1 -1
- package/dist/commands/test.js +48 -8
- package/dist/commands/test.js.map +1 -1
- package/dist/commands/validate.d.ts +19 -0
- package/dist/commands/validate.d.ts.map +1 -1
- package/dist/commands/validate.js +358 -84
- package/dist/commands/validate.js.map +1 -1
- package/dist/commands/watch.d.ts +30 -0
- package/dist/commands/watch.d.ts.map +1 -1
- package/dist/commands/watch.js +159 -23
- package/dist/commands/watch.js.map +1 -1
- package/dist/commands/workflow-list.d.ts +16 -0
- package/dist/commands/workflow-list.d.ts.map +1 -0
- package/dist/commands/workflow-list.js +96 -0
- package/dist/commands/workflow-list.js.map +1 -0
- package/dist/commands-registry.d.ts.map +1 -1
- package/dist/commands-registry.js +2 -0
- package/dist/commands-registry.js.map +1 -1
- package/dist/extensions/load-project-extensions.d.ts.map +1 -1
- package/dist/extensions/load-project-extensions.js +9 -3
- package/dist/extensions/load-project-extensions.js.map +1 -1
- package/dist/index.js +22 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/loader-warnings.d.ts +45 -3
- package/dist/lib/loader-warnings.d.ts.map +1 -1
- package/dist/lib/loader-warnings.js +106 -5
- package/dist/lib/loader-warnings.js.map +1 -1
- package/package.json +5 -4
|
@@ -34,12 +34,86 @@ let additionalRedactionValues = [];
|
|
|
34
34
|
export function setAdditionalRedactionValues(values) {
|
|
35
35
|
additionalRedactionValues = values;
|
|
36
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* The THREE launcher keys whose values are public by name, not by prefix (issue #407).
|
|
39
|
+
*
|
|
40
|
+
* Exact keys, deliberately — the prefix form they replace was a secret channel. Yarn classic
|
|
41
|
+
* flattens the ENTIRE package.json into `npm_package_*`, so `npm_package_deploy_apiKey` was
|
|
42
|
+
* excluded from redaction under that launcher. With a closed set of three, everything a launcher
|
|
43
|
+
* invents is swept by default: `npm_package_config_*`, `npm_config_*`, every yarn1-flattened
|
|
44
|
+
* field, and `npm_lifecycle_script` — whose value is author-written script text that can carry an
|
|
45
|
+
* inline token, and whose whole line is echoed by a spawn failure.
|
|
46
|
+
*
|
|
47
|
+
* `npm_package_json` is NOT here: it is path-valued on every launcher that sets it, so it belongs
|
|
48
|
+
* to the under-HOME value rule below — a checkout under home keeps its tail, one outside home is
|
|
49
|
+
* redacted whole, which is the same privacy trade every other path value gets.
|
|
50
|
+
*
|
|
51
|
+
* Case-sensitive on purpose: a hostile `NPM_PACKAGE_NAME` is not one of these and stays swept.
|
|
52
|
+
*/
|
|
53
|
+
const EXCLUDED_LAUNCHER_METADATA = new Set([
|
|
54
|
+
'npm_package_name',
|
|
55
|
+
'npm_package_version',
|
|
56
|
+
'npm_lifecycle_event',
|
|
57
|
+
]);
|
|
58
|
+
/**
|
|
59
|
+
* Values that are public by SHAPE: booleans, and 2-or-3-segment dotted version numbers.
|
|
60
|
+
*
|
|
61
|
+
* Launchers inject these constantly — pnpm's `pnpm_config_verify_deps_before_run=false`, yarn1's
|
|
62
|
+
* `YARN_WRAP_OUTPUT=false`, npm's `npm_config_npm_version=11.8.0` — so the word "false" and any
|
|
63
|
+
* matching version string were being cut out of every message and every recorded tool result.
|
|
64
|
+
*
|
|
65
|
+
* The bound is narrow on purpose. A looser `\d+(\.\d+)*` would admit bare integers (numeric
|
|
66
|
+
* PINs, account ids) and IPv4 addresses — values the sweep exists for. Two or three segments,
|
|
67
|
+
* each dotted, and nothing else: `1.0.0-beta` and four-segment strings stay swept.
|
|
68
|
+
*
|
|
69
|
+
* Case-sensitive: `FALSE` stays swept. The `true` alternative is dead today — four characters,
|
|
70
|
+
* already below the length filter — and is kept as defense should that filter ever change.
|
|
71
|
+
*/
|
|
72
|
+
const PUBLIC_VALUE_SHAPE = /^(true|false|\d+\.\d+(\.\d+)?)$/;
|
|
37
73
|
/**
|
|
38
74
|
* Converts an error value to a string and strips sensitive patterns: Bearer tokens,
|
|
39
75
|
* query-string tokens, process.env values longer than 4 characters, and the additional
|
|
40
76
|
* (manifest-secret) values. All literal values are redacted in ONE combined pass,
|
|
41
77
|
* deduped and applied LONGEST-FIRST — a short value contained in a longer one can no
|
|
42
78
|
* longer leave fragments of the longer value behind.
|
|
79
|
+
*
|
|
80
|
+
* THE BOUNDARY (issue #407). The default is fail-closed — every env value over four characters
|
|
81
|
+
* is redacted — with three bounded exceptions, and everything else swept. Where the field bounds
|
|
82
|
+
* redaction by key semantics or by registered values, realm keeps the closed default and names
|
|
83
|
+
* its exceptions.
|
|
84
|
+
*
|
|
85
|
+
* Why it exists at all: under npm, `npm_package_name` is `"realm"`, so realm redacted its own
|
|
86
|
+
* name out of its own error messages. Console-only that was cosmetic; issue #401 persists those
|
|
87
|
+
* messages in the run record, which made the mangling durable evidence.
|
|
88
|
+
*
|
|
89
|
+
* The first fix excluded `npm_package_*` BY PREFIX — and that was itself a secret channel. Yarn
|
|
90
|
+
* classic flattens the whole package.json into that namespace, so `npm_package_deploy_apiKey`
|
|
91
|
+
* and `npm_package_scripts_ship` (a script line with an inline token) were excluded from
|
|
92
|
+
* redaction. The premise "npm_package_* is public metadata" is true of npm, pnpm, bun and berry,
|
|
93
|
+
* and FALSE of yarn 1.x. Exact keys cannot be flattened into.
|
|
94
|
+
*
|
|
95
|
+
* The three rules, applied to the ENV SWEEP ONLY:
|
|
96
|
+
*
|
|
97
|
+
* 1. EXACT KEYS — {@link EXCLUDED_LAUNCHER_METADATA}, three of them, none path-valued.
|
|
98
|
+
* 2. PUBLIC SHAPE — {@link PUBLIC_VALUE_SHAPE}: booleans and dotted versions, which launchers
|
|
99
|
+
* inject everywhere and which mangled ordinary prose ("received false") and version numbers.
|
|
100
|
+
* 3. UNDER HOME — a value starting with `HOME + '/'` leaves the sweep, so a require stack
|
|
101
|
+
* renders `[REDACTED]/code/realm/…`: the tail is the informative half, the username is not.
|
|
102
|
+
* HOME ITSELF stays swept, which is what strips the prefix.
|
|
103
|
+
*
|
|
104
|
+
* Rule 3 is CONDITIONAL PRIVACY, and the condition is the point: a path outside home — the WSL
|
|
105
|
+
* `/mnt/c/Users/<Name>` shape — cannot have its username stripped by a home-prefix rule, so it
|
|
106
|
+
* stays redacted whole. Accepted bound: a path INTO home (`SECRET_PATH=/home/x/secrets/key.pem`)
|
|
107
|
+
* reveals its tail. A path to a secret is not the secret — file content never transits env — but
|
|
108
|
+
* the tail can disclose directory structure. The remedy for a sensitive path is to declare it a
|
|
109
|
+
* manifest secret: the exemption below redacts declared values even under home.
|
|
110
|
+
*
|
|
111
|
+
* THE EXEMPTION, load-bearing: rules 2 and 3 filter the ENV sweep only. `additionalRedactionValues`
|
|
112
|
+
* — values an author DECLARED secret — are never filtered, however public-shaped they look or
|
|
113
|
+
* wherever they live.
|
|
114
|
+
*
|
|
115
|
+
* BLAST RADIUS: {@link serializeToolResult} runs this same pass, so persisted tool results heal
|
|
116
|
+
* with it — going forward. Records written by earlier releases keep the mangled form.
|
|
43
117
|
*/
|
|
44
118
|
export function sanitizeError(err) {
|
|
45
119
|
let text;
|
|
@@ -54,7 +128,30 @@ export function sanitizeError(err) {
|
|
|
54
128
|
}
|
|
55
129
|
text = text.replace(/Bearer [A-Za-z0-9._-]+/g, 'Bearer [REDACTED]');
|
|
56
130
|
text = text.replace(/token=[A-Za-z0-9._-]+/g, 'token=[REDACTED]');
|
|
57
|
-
|
|
131
|
+
// Read PER CALL, never captured at module scope: a module-scope read is the issue-#285 class
|
|
132
|
+
// and would make every `vi.stubEnv('HOME', …)` cell test the process's real home instead.
|
|
133
|
+
//
|
|
134
|
+
// Keyed on `process.env.HOME`, deliberately NOT `os.homedir()`, and the listen.ts #332
|
|
135
|
+
// precedent that brands bare HOME reads house-inconsistent does not apply here: the filter key
|
|
136
|
+
// MUST be the same string the sweep can still redact. With homedir() and HOME unset or
|
|
137
|
+
// different, under-home values would leave the sweep while nothing redacted their prefix, and
|
|
138
|
+
// the full path would ship bare. The coupling is the mechanism.
|
|
139
|
+
//
|
|
140
|
+
// The length guard is not cosmetic: a HOME of four characters or fewer is itself outside the
|
|
141
|
+
// sweep, so nothing would redact the prefix it strips. No normalization either — a trailing
|
|
142
|
+
// slash makes `HOME + '/'` never match, the rule no-ops, and the value stays redacted.
|
|
143
|
+
//
|
|
144
|
+
// win32 is a stated non-goal rather than an oversight (realm has live win32 branches
|
|
145
|
+
// elsewhere): HOME is typically undefined there, so the rule no-ops into today's fail-closed
|
|
146
|
+
// full redaction, and `USERPROFILE` is deliberately unhandled — its value stays swept.
|
|
147
|
+
const home = process.env['HOME'];
|
|
148
|
+
const homePrefix = home !== undefined && home.length > 4 ? `${home}/` : undefined;
|
|
149
|
+
const envValues = Object.entries(process.env)
|
|
150
|
+
.filter(([key]) => !EXCLUDED_LAUNCHER_METADATA.has(key))
|
|
151
|
+
.map(([, val]) => val)
|
|
152
|
+
.filter((val) => val !== undefined && val.length > 4)
|
|
153
|
+
.filter((val) => !PUBLIC_VALUE_SHAPE.test(val))
|
|
154
|
+
.filter((val) => homePrefix === undefined || !val.startsWith(homePrefix));
|
|
58
155
|
const combined = [...new Set([...envValues, ...additionalRedactionValues])].sort((a, b) => b.length - a.length);
|
|
59
156
|
for (const val of combined) {
|
|
60
157
|
text = text.split(val).join('[REDACTED]');
|
|
@@ -69,6 +166,60 @@ export function serializeToolResult(result) {
|
|
|
69
166
|
const raw = typeof result === 'string' ? result : JSON.stringify(result);
|
|
70
167
|
return sanitizeError(raw);
|
|
71
168
|
}
|
|
169
|
+
/** The `error` text for a Class-B result whose content carries no readable text at all. */
|
|
170
|
+
export const CLASS_B_NO_TEXT_MARKER = 'tool returned isError with no text content';
|
|
171
|
+
/**
|
|
172
|
+
* Extracts the failure text from a POLITELY FAILED tool call — issue #345.
|
|
173
|
+
*
|
|
174
|
+
* MCP defines two ways a tool call fails. The transport can reject (Class A: an exception, which
|
|
175
|
+
* the providers' catch branch already records honestly), or the call can RETURN normally with
|
|
176
|
+
* `isError: true` inside the result (Class B: the polite failure the spec defines for a tool
|
|
177
|
+
* reporting its own error to the model). Class B used to be minted as a success — no `error`
|
|
178
|
+
* field, the failure text buried inside `result` — which made the record type's own doc contract
|
|
179
|
+
* false and made every tool-reliability count read failures as successes.
|
|
180
|
+
*
|
|
181
|
+
* Returns the sanitized failure text for a Class-B result, or `undefined` for anything else — so
|
|
182
|
+
* a caller writes `const err = classBError(raw)` and branches on presence.
|
|
183
|
+
*
|
|
184
|
+
* WHY `=== true` AND NOT TRUTHINESS. The SDK zod-validates every `callTool` response against
|
|
185
|
+
* `CallToolResultSchema`, where `isError` is `z.boolean().optional()`. A non-boolean `isError`
|
|
186
|
+
* fails that parse, the promise REJECTS, and the call lands in the catch branch as Class A —
|
|
187
|
+
* recorded WITH an `error` either way. So the spec-illegal world cannot reach this mint through
|
|
188
|
+
* the real transport, and a strict check cannot silently swallow a failure. (The fixture in the
|
|
189
|
+
* strict-boolean cell models a wire state that cannot occur; it exists to pin the choice, not a
|
|
190
|
+
* reachable case.) This premise breaks only if realm switches to
|
|
191
|
+
* `CompatibilityCallToolResultSchema` or talks to a raw transport that skips validation — if that
|
|
192
|
+
* ever happens, revisit this line first.
|
|
193
|
+
*/
|
|
194
|
+
export function classBError(rawResult) {
|
|
195
|
+
if (typeof rawResult !== 'object' || rawResult === null)
|
|
196
|
+
return undefined;
|
|
197
|
+
const result = rawResult;
|
|
198
|
+
if (result.isError !== true)
|
|
199
|
+
return undefined;
|
|
200
|
+
const blocks = Array.isArray(result.content) ? result.content : [];
|
|
201
|
+
const text = blocks
|
|
202
|
+
.filter((b) => typeof b === 'object' &&
|
|
203
|
+
b !== null &&
|
|
204
|
+
b.type === 'text' &&
|
|
205
|
+
typeof b.text === 'string')
|
|
206
|
+
.map((b) => b.text)
|
|
207
|
+
// '\n' is specified rather than incidental: two providers mint this and a different join
|
|
208
|
+
// would make the same failure read differently depending on which one ran.
|
|
209
|
+
.join('\n');
|
|
210
|
+
// Empty JOINED text, not merely absent blocks — `text: ''` is transport-legal, and an empty
|
|
211
|
+
// `error` would be invisible to inspect's truthiness check, so a politely-failed call would
|
|
212
|
+
// render as unfailed. The marker is what stops that.
|
|
213
|
+
//
|
|
214
|
+
// Tested on the TRIMMED text, and that is not fussiness: TWO empty blocks join to `'\n'`, which
|
|
215
|
+
// is length 1 and would have sailed past a `length === 0` check — producing an `error` that is
|
|
216
|
+
// technically truthy and visually nothing, which is the same invisible failure wearing a
|
|
217
|
+
// different hat. (Found by the all-empty cell below, which is why it exists.) The returned text
|
|
218
|
+
// is never trimmed — only the emptiness question is.
|
|
219
|
+
if (text.trim().length === 0)
|
|
220
|
+
return CLASS_B_NO_TEXT_MARKER;
|
|
221
|
+
return sanitizeError(text);
|
|
222
|
+
}
|
|
72
223
|
/** Splits "server_id:tool_name" into its components. Throws if the format is invalid. */
|
|
73
224
|
export function parseNamespacedId(id) {
|
|
74
225
|
const colonIdx = id.indexOf(':');
|
|
@@ -291,4 +442,275 @@ export function extractApiErrorFields(err) {
|
|
|
291
442
|
out.api_code = typeof e.code === 'string' ? e.code : null;
|
|
292
443
|
return out;
|
|
293
444
|
}
|
|
445
|
+
// =================================================================================================
|
|
446
|
+
// issue #401 — the per-create budget: the counting fetch, the ceiling, and the attribution
|
|
447
|
+
//
|
|
448
|
+
// THE INVARIANT: no single model request can hold a drive hostage. The SDK's own `timeout` bounds
|
|
449
|
+
// one ATTEMPT; nothing bounded the whole create, so a server directing a two-hour Retry-After, or
|
|
450
|
+
// a connection that hung after headers, could park a drive indefinitely with nothing recorded.
|
|
451
|
+
//
|
|
452
|
+
// Scope, stated because the claim must not overreach: this bounds realm's IN-REPO providers, which
|
|
453
|
+
// consume the clock. A `--provider-module` provider still gets the RECORD when it fails — it just
|
|
454
|
+
// does not get the bound.
|
|
455
|
+
// =================================================================================================
|
|
456
|
+
/** Realm's own retry count, passed EXPLICITLY to every SDK client. */
|
|
457
|
+
export const MAX_RETRIES = 2;
|
|
458
|
+
/** The download allowance the derived ceiling adds on top of the retry budget. */
|
|
459
|
+
const DOWNLOAD_ALLOWANCE_MS = 60_000;
|
|
460
|
+
/**
|
|
461
|
+
* The largest delay a timer can hold. Past it `setTimeout` overflows and fires ~immediately,
|
|
462
|
+
* which would inVERT a huge budget into an instant abort (gate-expiry-timer.ts:24 clamps for the
|
|
463
|
+
* same reason). Both timers matter here: realm's own ceiling, and the `timeout` realm hands the
|
|
464
|
+
* SDK — an unclamped per-attempt value overflows one layer down and returns as a
|
|
465
|
+
* `connection_timeout` that has nothing to do with the connection.
|
|
466
|
+
*/
|
|
467
|
+
const MAX_TIMEOUT_MS = 2 ** 31 - 1;
|
|
468
|
+
/**
|
|
469
|
+
* Derives the whole-create ceiling from a per-attempt value.
|
|
470
|
+
*
|
|
471
|
+
* `perAttempt × (MAX_RETRIES + 1)` covers every attempt the SDK will make, plus the backoff it
|
|
472
|
+
* sleeps between them, plus a download allowance so a large-but-progressing response is never
|
|
473
|
+
* killed for being large. The backoff term is the SDK's OWN schedule summed as an UPPER bound —
|
|
474
|
+
* its jitter only ever reduces the wait, so budgeting the un-jittered sum cannot cut short a
|
|
475
|
+
* retry the SDK scheduled for itself.
|
|
476
|
+
*
|
|
477
|
+
* A SERVER-DIRECTED wait is a different thing and is deliberately NOT budgeted. A `Retry-After`
|
|
478
|
+
* can ask for hours; the ceiling outranks it on purpose, which is the point of the bound rather
|
|
479
|
+
* than a gap in it.
|
|
480
|
+
*/
|
|
481
|
+
export function deriveLlmClock(perAttemptMs) {
|
|
482
|
+
let backoffMarginMs = 0;
|
|
483
|
+
for (let n = 0; n < MAX_RETRIES; n++)
|
|
484
|
+
backoffMarginMs += Math.min(0.5 * 2 ** n, 8) * 1000;
|
|
485
|
+
// Clamped BEFORE the arithmetic and again after it, because both numbers arm a real timer. The
|
|
486
|
+
// clamped per-attempt value is what gets recorded too — the record states what actually bounds
|
|
487
|
+
// the attempt, not what someone asked for. There is deliberately no validator upper bound: a
|
|
488
|
+
// huge value is not an authoring error, it is a request for "effectively no limit", and that is
|
|
489
|
+
// what it gets.
|
|
490
|
+
const perAttempt = Math.min(perAttemptMs, MAX_TIMEOUT_MS);
|
|
491
|
+
return {
|
|
492
|
+
ceilingMs: Math.min(perAttempt * (MAX_RETRIES + 1) + backoffMarginMs + DOWNLOAD_ALLOWANCE_MS, MAX_TIMEOUT_MS),
|
|
493
|
+
declaredPerAttemptMs: perAttempt,
|
|
494
|
+
};
|
|
495
|
+
}
|
|
496
|
+
/**
|
|
497
|
+
* Parses all three Retry-After forms into milliseconds: `retry-after-ms`, a numeric
|
|
498
|
+
* `Retry-After` in seconds, and an HTTP-date `Retry-After`. OBSERVED, never honored by realm.
|
|
499
|
+
*
|
|
500
|
+
* The date form is legal, the SDKs honor it, and a parser that only understood numbers dropped a
|
|
501
|
+
* whole header form on the floor — recording nothing for a rate limit that was clearly signalled.
|
|
502
|
+
* A date already in the past observes as 0 (the wait is over; a negative number would be a
|
|
503
|
+
* nonsense measurement), while a header nobody can parse observes as nothing at all — realm has
|
|
504
|
+
* no idea what was asked for and says so by omission rather than by inventing a zero.
|
|
505
|
+
*/
|
|
506
|
+
function parseRetryAfterMs(headers) {
|
|
507
|
+
const ms = headers.get('retry-after-ms');
|
|
508
|
+
if (ms !== null && ms.trim() !== '' && Number.isFinite(Number(ms)))
|
|
509
|
+
return Number(ms);
|
|
510
|
+
const after = headers.get('retry-after');
|
|
511
|
+
if (after === null || after.trim() === '')
|
|
512
|
+
return undefined;
|
|
513
|
+
if (Number.isFinite(Number(after)))
|
|
514
|
+
return Number(after) * 1000;
|
|
515
|
+
// `Number`, deliberately, not `parseFloat`. RFC 9110 says a Retry-After is EITHER digits-only
|
|
516
|
+
// seconds or an HTTP-date; `parseFloat('7200abc')` would happily read 7200 out of a header that
|
|
517
|
+
// is neither, and record a measurement the server never sent. The strict parse falls through to
|
|
518
|
+
// the date arm and then to nothing, which is the truthful answer for a malformed header.
|
|
519
|
+
const at = Date.parse(after);
|
|
520
|
+
if (!Number.isFinite(at))
|
|
521
|
+
return undefined;
|
|
522
|
+
return Math.max(0, at - Date.now());
|
|
523
|
+
}
|
|
524
|
+
/**
|
|
525
|
+
* Wraps `fetch` so realm can SEE what the SDK's retry ladder did — how many attempts it made, the
|
|
526
|
+
* last status, and any Retry-After the server asked for, in all three of its legal forms
|
|
527
|
+
* (`retry-after-ms`, a numeric `Retry-After`, an HTTP-date `Retry-After`).
|
|
528
|
+
*
|
|
529
|
+
* Observation only. Realm never honors a Retry-After: acting on it would be a scheduling decision
|
|
530
|
+
* this layer does not make, and recording it is what lets an operator tell a rate limit apart from
|
|
531
|
+
* a hang. The inner fetch is injectable so the wrapper is unit-testable without a socket.
|
|
532
|
+
*/
|
|
533
|
+
export function makeCountingFetch(counters, innerFetch = globalThis.fetch) {
|
|
534
|
+
return async (input, init) => {
|
|
535
|
+
try {
|
|
536
|
+
const res = await innerFetch(input, init);
|
|
537
|
+
counters.attempts++;
|
|
538
|
+
counters.lastStatus = res.status;
|
|
539
|
+
const retryAfter = parseRetryAfterMs(res.headers);
|
|
540
|
+
if (retryAfter !== undefined)
|
|
541
|
+
counters.lastRetryAfterMs = retryAfter;
|
|
542
|
+
return res;
|
|
543
|
+
}
|
|
544
|
+
catch (err) {
|
|
545
|
+
// A rejection is still an attempt — it just carries no status to observe.
|
|
546
|
+
counters.attempts++;
|
|
547
|
+
throw err;
|
|
548
|
+
}
|
|
549
|
+
};
|
|
550
|
+
}
|
|
551
|
+
/**
|
|
552
|
+
* Attaches a payload to an error, WITHOUT overwriting one that is already there.
|
|
553
|
+
*
|
|
554
|
+
* TOTAL. Both the probe and the assignment can throw on a value realm did not create — `in` runs
|
|
555
|
+
* a proxy's `has` trap, and assigning to a frozen object throws in strict mode. Either one would
|
|
556
|
+
* hand the caller the attacher's own TypeError in place of the failure it was trying to describe,
|
|
557
|
+
* which is the whole attribution chain defeated by the last link in it. An error that cannot be
|
|
558
|
+
* enriched still propagates, intact and unenriched; shape classification never needed the payload.
|
|
559
|
+
*/
|
|
560
|
+
export function attachDriveCall(err, payload) {
|
|
561
|
+
if (typeof err !== 'object' || err === null)
|
|
562
|
+
return;
|
|
563
|
+
try {
|
|
564
|
+
if ('driveCall' in err)
|
|
565
|
+
return; // e.g. getClient's sdk_missing attach — never re-attributed
|
|
566
|
+
err.driveCall = payload;
|
|
567
|
+
}
|
|
568
|
+
catch {
|
|
569
|
+
/* enrichment never out-throws the error being attributed */
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
/**
|
|
573
|
+
* Converts any thrown value to display text, TOTALLY.
|
|
574
|
+
*
|
|
575
|
+
* The chokepoints interpolate the thrown value into their console line BEFORE recording it, so a
|
|
576
|
+
* poisoned `toString` used to out-throw at the print — replacing the operator's error with a
|
|
577
|
+
* secondary one before the (already hardened) mint could run.
|
|
578
|
+
*/
|
|
579
|
+
export function safeErrorText(err) {
|
|
580
|
+
try {
|
|
581
|
+
return err instanceof Error ? err.message : String(err);
|
|
582
|
+
}
|
|
583
|
+
catch {
|
|
584
|
+
return 'unrenderable thrown value';
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
/**
|
|
588
|
+
* Classifies an SDK-raised error by shape, for the payload's `error_class`.
|
|
589
|
+
*
|
|
590
|
+
* BOTH `name` and `constructor.name` are checked, and the second is the one that works. Neither
|
|
591
|
+
* installed SDK sets `.name` on its error classes — a real `APIConnectionError` from either one
|
|
592
|
+
* reports `name === 'Error'` and carries its identity on the constructor — so a check on `.name`
|
|
593
|
+
* alone recorded every genuine connection failure and every genuine request timeout as `other`.
|
|
594
|
+
* `.name` is kept because a wrapper that re-throws with a copied name is a real shape too.
|
|
595
|
+
*
|
|
596
|
+
* The timeout arm sits first as a belt: under exact string equality a real timeout cannot match
|
|
597
|
+
* the connection arm anyway (its constructor name is the leaf), but a wrapper copying a parent
|
|
598
|
+
* `.name` onto a timeout instance could.
|
|
599
|
+
*
|
|
600
|
+
* TOTAL. This runs inside driveCreate's catch, where a throw would replace the operator's failure
|
|
601
|
+
* with realm's own — and reading `constructor` and `name` off a value realm did not create can
|
|
602
|
+
* throw. (That hole predates the constructor check: a poisoned `.name` getter out-threw here.)
|
|
603
|
+
*/
|
|
604
|
+
function shapeClass(err) {
|
|
605
|
+
try {
|
|
606
|
+
const name = err?.name;
|
|
607
|
+
const ctor = err?.constructor?.name;
|
|
608
|
+
if (name === 'APIConnectionTimeoutError' || ctor === 'APIConnectionTimeoutError') {
|
|
609
|
+
return 'connection_timeout';
|
|
610
|
+
}
|
|
611
|
+
if (name === 'APIConnectionError' || ctor === 'APIConnectionError')
|
|
612
|
+
return 'connection_error';
|
|
613
|
+
if (extractHttpStatus(err) !== undefined)
|
|
614
|
+
return 'api_status';
|
|
615
|
+
return 'other';
|
|
616
|
+
}
|
|
617
|
+
catch {
|
|
618
|
+
return 'other';
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
/**
|
|
622
|
+
* Runs ONE model create under realm's ceiling.
|
|
623
|
+
*
|
|
624
|
+
* Two mechanisms, because one is not enough. The timer is what bounds the wall clock; the abort is
|
|
625
|
+
* what actually stops work — but only as far as the SDK will let it. The SDK's sleep primitive is
|
|
626
|
+
* signal-aware, yet its retry site passes no signal, so a raced-out backoff sleep runs to
|
|
627
|
+
* completion in the worker. That is the ceiling's known reach, not a bug in it: an SDK bump that
|
|
628
|
+
* threads the signal there would make the race leg partially redundant, and it would still be
|
|
629
|
+
* earning its keep on the post-header body hang.
|
|
630
|
+
*
|
|
631
|
+
* Wraps the CREATE only. Client construction stays outside — that is where a missing SDK attaches
|
|
632
|
+
* its own payload, and this must never re-attribute it.
|
|
633
|
+
*/
|
|
634
|
+
export async function driveCreate(rawCreate, body, clock, counters) {
|
|
635
|
+
const before = { ...counters };
|
|
636
|
+
// The observations are cleared, the attempt total is not. `attempts` is a running count, so a
|
|
637
|
+
// delta is the right question for it; a status is an OBSERVATION, and asking "did it change?"
|
|
638
|
+
// means a second identical 429 reads as nothing observed at all — the discriminator vanishing
|
|
639
|
+
// exactly during the rate-limit storm it exists to describe. Cleared here, they are present in
|
|
640
|
+
// the payload if and only if THIS create saw them.
|
|
641
|
+
delete counters.lastStatus;
|
|
642
|
+
delete counters.lastRetryAfterMs;
|
|
643
|
+
const started = Date.now();
|
|
644
|
+
const controller = new AbortController();
|
|
645
|
+
let timer;
|
|
646
|
+
let fired = false;
|
|
647
|
+
const ceiling = new Promise((_, reject) => {
|
|
648
|
+
timer = setTimeout(() => {
|
|
649
|
+
fired = true;
|
|
650
|
+
reject(new Error('__realm_ceiling__'));
|
|
651
|
+
}, clock.ceilingMs);
|
|
652
|
+
});
|
|
653
|
+
// A race has a LOSER, and an unobserved rejected promise takes the process down on Node >= 15.
|
|
654
|
+
// DEFENSE IN DEPTH, stated precisely: `Promise.race` subscribes to every promise it is given,
|
|
655
|
+
// and that subscription counts as handling — so as long as the race below actually runs, neither
|
|
656
|
+
// loser can go unhandled, and probing this line away does NOT trip an unhandledRejection trap.
|
|
657
|
+
// What made the class real was the path where the race NEVER RAN: a create that threw
|
|
658
|
+
// synchronously escaped before `Promise.race`, leaving this timer to fire into nothing and kill
|
|
659
|
+
// the process. That path is closed structurally below; this line is the belt for a future
|
|
660
|
+
// refactor that stops racing, which is why it survives a probe showing it does nothing today.
|
|
661
|
+
void ceiling.catch(() => undefined);
|
|
662
|
+
// Declared out here so the fired path can observe the loser; ASSIGNED inside the try, because a
|
|
663
|
+
// provider whose create throws SYNCHRONOUSLY (a bad argument, a mocked double) would otherwise
|
|
664
|
+
// escape past both the classification and the `finally` — leaving the error unattributed and
|
|
665
|
+
// the timer running to fire into nothing.
|
|
666
|
+
let sdkCall;
|
|
667
|
+
try {
|
|
668
|
+
sdkCall = (async () => rawCreate(body, { signal: controller.signal }))();
|
|
669
|
+
return await Promise.race([sdkCall, ceiling]);
|
|
670
|
+
}
|
|
671
|
+
catch (err) {
|
|
672
|
+
// Present iff THIS create observed them — the fields were cleared at the top, so a stale
|
|
673
|
+
// status from a previous create cannot attach to this failure and tell a confident lie about
|
|
674
|
+
// what just happened.
|
|
675
|
+
const sawStatus = counters.lastStatus !== undefined;
|
|
676
|
+
const sawRetryAfter = counters.lastRetryAfterMs !== undefined;
|
|
677
|
+
const delta = {
|
|
678
|
+
attempts_sdk: counters.attempts - before.attempts,
|
|
679
|
+
elapsed_ms: Date.now() - started,
|
|
680
|
+
...(sawStatus ? { last_observed_status: counters.lastStatus } : {}),
|
|
681
|
+
...(sawRetryAfter ? { retry_after_observed_ms: counters.lastRetryAfterMs } : {}),
|
|
682
|
+
...(clock.declaredPerAttemptMs !== undefined
|
|
683
|
+
? { declared_per_attempt_ms: clock.declaredPerAttemptMs }
|
|
684
|
+
: {}),
|
|
685
|
+
derived_ceiling_ms: clock.ceilingMs,
|
|
686
|
+
};
|
|
687
|
+
if (fired) {
|
|
688
|
+
controller.abort();
|
|
689
|
+
// The loser's rejection still arrives — an APIUserAbortError, moments later. Same defense
|
|
690
|
+
// in depth as the timer's catch above, and the same honest caveat: the race is already
|
|
691
|
+
// subscribed, so this is insurance rather than the thing currently preventing a crash.
|
|
692
|
+
void sdkCall?.catch(() => undefined);
|
|
693
|
+
// The lever named is the one that is actually LIVE. Telling an operator to raise a flag
|
|
694
|
+
// that a step key is already overriding sends them to change something with no effect —
|
|
695
|
+
// so provenance decides which arm renders. With no provenance at all (a hand-built clock)
|
|
696
|
+
// both arms render, because either could be the live one.
|
|
697
|
+
const source = clock.perAttemptSource;
|
|
698
|
+
const stepArm = source === undefined || source === 'step';
|
|
699
|
+
const flagArm = source === undefined || source === 'flag' || source === 'default';
|
|
700
|
+
const levers = [
|
|
701
|
+
...(stepArm ? ['raise llm_timeout_seconds on the step'] : []),
|
|
702
|
+
...(flagArm ? ['pass a larger --llm-timeout'] : []),
|
|
703
|
+
].join(' or ');
|
|
704
|
+
const aborted = new Error(`LLM create exceeded the per-create ceiling (${String(clock.ceilingMs)}ms) — ${levers}`);
|
|
705
|
+
attachDriveCall(aborted, { error_class: 'aborted_by_budget', ...delta });
|
|
706
|
+
throw aborted;
|
|
707
|
+
}
|
|
708
|
+
attachDriveCall(err, { error_class: shapeClass(err), ...delta });
|
|
709
|
+
throw err;
|
|
710
|
+
}
|
|
711
|
+
finally {
|
|
712
|
+
if (timer !== undefined)
|
|
713
|
+
clearTimeout(timer);
|
|
714
|
+
}
|
|
715
|
+
}
|
|
294
716
|
//# sourceMappingURL=agent-utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-utils.js","sourceRoot":"","sources":["../../../src/agent/providers/agent-utils.ts"],"names":[],"mappings":"AAGA,MAAM,kBAAkB,GACtB,kEAAkE;IAClE,8FAA8F,CAAC;AAEjG,mGAAmG;AACnG,mGAAmG;AACnG,2GAA2G;AAC3G,MAAM,4BAA4B,GAChC,kEAAkE;IAClE,8FAA8F;IAC9F,wDAAwD,CAAC;AAE3D;;;;;;;GAOG;AACH,MAAM,UAAU,iBAAiB,CAC/B,WAAqC,EACrC,wBAAiC,EACjC,qBAA+B;IAE/B,MAAM,UAAU,GACd,qBAAqB,KAAK,IAAI,CAAC,CAAC,CAAC,4BAA4B,CAAC,CAAC,CAAC,kBAAkB,CAAC;IACrF,MAAM,IAAI,GACR,wBAAwB,KAAK,SAAS;QACpC,CAAC,CAAC,GAAG,wBAAwB,OAAO,UAAU,EAAE;QAChD,CAAC,CAAC,UAAU,CAAC;IACjB,IAAI,WAAW,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IAC3C,OAAO,GAAG,IAAI,2CAA2C,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,EAAE,CAAC;AACzF,CAAC;AAED;;;;;GAKG;AACH,IAAI,yBAAyB,GAAsB,EAAE,CAAC;AAEtD,6EAA6E;AAC7E,MAAM,UAAU,4BAA4B,CAAC,MAAyB;IACpE,yBAAyB,GAAG,MAAM,CAAC;AACrC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,GAAY;IACxC,IAAI,IAAY,CAAC;IACjB,IAAI,GAAG,YAAY,KAAK,EAAE,CAAC;QACzB,IAAI,GAAG,GAAG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QACT,IAAI,KAAK,KAAK,SAAS;YAAE,YAAY,CAAC,KAAK,CAAC,CAAC;IAC/C,CAAC;AACH,CAAC"}
|
|
@@ -1,6 +1,52 @@
|
|
|
1
1
|
import { type StructuredOutputMeta } from '@sensigo/realm';
|
|
2
2
|
import { ToolCapableLlmProvider, type ProviderCapabilities } from './llm-provider.js';
|
|
3
3
|
import type { ToolDefinition, ToolExecutor, StepWithToolsResult } from '../mcp/mcp-extensions.js';
|
|
4
|
+
import { type LlmClock } from './agent-utils.js';
|
|
5
|
+
/**
|
|
6
|
+
* Returns the maximum output tokens for the given Anthropic model.
|
|
7
|
+
* The Anthropic Messages API requires max_tokens — this must always produce a valid value.
|
|
8
|
+
* Source: https://docs.anthropic.com/en/docs/about-claude/models/all-models
|
|
9
|
+
*
|
|
10
|
+
* Issue #309 fix (ratified per design-d4-final.md's ADDENDUM, the audit's 3.5-cap correction):
|
|
11
|
+
* the PRE-#309 regex (`claude-(3[-.]5|[a-z]+-4)`) was stale in a dangerous direction — it gave
|
|
12
|
+
* the claude-3.5 family's OWN hard output cap (8192; 16384 would 400 every call) to EVERY 4.x
|
|
13
|
+
* model too (claude-sonnet-4-5, claude-opus-4-1, …), silently under-budgeting them. Three
|
|
14
|
+
* buckets now, ordered most-specific-first:
|
|
15
|
+
* 1. claude-3.5 family (`claude-3-5-*` / `claude-3.5-*`) ⇒ 8192 — its OWN hard cap.
|
|
16
|
+
* 2. Bare legacy claude-3 generation (claude-3-opus/-sonnet/-haiku, NOT 3.5) ⇒ 4096 — original,
|
|
17
|
+
* unchanged fallback.
|
|
18
|
+
* 3. Everything else — 3.7, every 4.x/5.x model, and any UNKNOWN future model id — ⇒ 16384.
|
|
19
|
+
* Fail-forward (the stale-classifier lesson, #312 is the durable fix: an unrecognized model
|
|
20
|
+
* id is treated as AT LEAST as capable as today's models, never less; 16384 is
|
|
21
|
+
* non-streaming-safe and current models think by default, so 4096 would starve
|
|
22
|
+
* thinking+output on anything not explicitly bucketed above).
|
|
23
|
+
*/
|
|
24
|
+
export declare function resolveMaxTokens(model: string): number;
|
|
25
|
+
/**
|
|
26
|
+
* The Anthropic SDK's own non-streaming coherence threshold. A single non-streaming request asking
|
|
27
|
+
* for more output tokens than this can legitimately outrun a ten-minute budget, and the SDK would
|
|
28
|
+
* rather you stream than have the request die on a timeout it cannot distinguish from a hang.
|
|
29
|
+
*/
|
|
30
|
+
export declare const MAX_NONSTREAMING_TOKENS = 21333;
|
|
31
|
+
/**
|
|
32
|
+
* issue #401 — realm re-imposes the SDK's rule, because realm's own `timeout` DISABLES it.
|
|
33
|
+
* The SDK runs that check only when `!stream && timeout == null` (messages.js:29-33): the moment
|
|
34
|
+
* realm passes an explicit per-attempt timeout, the guard silently stops running. Re-imposing it
|
|
35
|
+
* here keeps behaviour identical to the pre-#401 client instead of trading a loud refusal for a
|
|
36
|
+
* confusing abort — so it fires ONLY when a clock was threaded (no clock ⇒ no realm timeout ⇒ the
|
|
37
|
+
* SDK's own guard is still live and will raise this itself).
|
|
38
|
+
*
|
|
39
|
+
* STREAMING FORK: realm's Anthropic path never sets `stream: true` on any request, so in practice
|
|
40
|
+
* this is unconditional. If a streaming path is ever added it must NOT call this — the rule is
|
|
41
|
+
* about non-streaming requests only, and inheriting it would refuse a request that is perfectly
|
|
42
|
+
* legal when streamed.
|
|
43
|
+
*
|
|
44
|
+
* Realm re-imposes the RATIO rule ONLY. The SDK additionally carries per-model
|
|
45
|
+
* MODEL_NONSTREAMING_TOKENS caps; those are deliberately not duplicated — a per-model table
|
|
46
|
+
* copied into a client goes stale on the next model release and starts refusing requests the
|
|
47
|
+
* server would have served.
|
|
48
|
+
*/
|
|
49
|
+
export declare function assertMaxTokensCoherent(maxTokens: number, clock: LlmClock | undefined): void;
|
|
4
50
|
/**
|
|
5
51
|
* Thrown when the ladder's OWN drop-strict retry ALSO fails — design §4 [R2-7]: (a) carries the
|
|
6
52
|
* `structuredOutput` meta so a catch site can still disclose the downgrade even though no result
|
|
@@ -42,11 +88,14 @@ export declare class AnthropicProvider extends ToolCapableLlmProvider {
|
|
|
42
88
|
* THIS invocation — a step that never opted in gets no `structuredOutput` meta at all.
|
|
43
89
|
*/
|
|
44
90
|
private callStepInternal;
|
|
45
|
-
callStep(prompt: string, inputSchema?: Record<string, unknown>, agentProfileInstructions?: string
|
|
91
|
+
callStep(prompt: string, inputSchema?: Record<string, unknown>, agentProfileInstructions?: string, opts?: {
|
|
92
|
+
llmClock?: LlmClock;
|
|
93
|
+
}): Promise<Record<string, unknown>>;
|
|
46
94
|
/** issue #236 override — the only provider in this codebase that actually honors
|
|
47
95
|
* `opts.structuredOutputStrict`; the base class's default just wraps `callStep`. */
|
|
48
96
|
callStepWithMeta(prompt: string, inputSchema?: Record<string, unknown>, agentProfileInstructions?: string, opts?: {
|
|
49
97
|
structuredOutputStrict?: boolean;
|
|
98
|
+
llmClock?: LlmClock;
|
|
50
99
|
}): Promise<{
|
|
51
100
|
output: Record<string, unknown>;
|
|
52
101
|
meta?: StructuredOutputMeta;
|
|
@@ -64,6 +113,7 @@ export declare class AnthropicProvider extends ToolCapableLlmProvider {
|
|
|
64
113
|
maxFanOut?: number;
|
|
65
114
|
toolTimeoutMs?: number;
|
|
66
115
|
agentProfileInstructions?: string;
|
|
116
|
+
llmClock?: LlmClock;
|
|
67
117
|
}): Promise<StepWithToolsResult>;
|
|
68
118
|
}
|
|
69
119
|
//# sourceMappingURL=anthropic-provider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anthropic-provider.d.ts","sourceRoot":"","sources":["../../../src/agent/providers/anthropic-provider.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,oBAAoB,EAC1B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,sBAAsB,EAAE,KAAK,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACtF,OAAO,KAAK,EAEV,cAAc,EACd,YAAY,EACZ,mBAAmB,EACpB,MAAM,0BAA0B,CAAC;
|
|
1
|
+
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