@namzu/cli 14.1.0 → 14.2.1
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/README.md +20 -9
- package/dist/commands/login.d.ts +21 -3
- package/dist/commands/login.d.ts.map +1 -1
- package/dist/commands/login.js +33 -21
- package/dist/commands/login.js.map +1 -1
- package/dist/integrations/providers/discover.d.ts +4 -0
- package/dist/integrations/providers/discover.d.ts.map +1 -1
- package/dist/integrations/providers/discover.js +55 -37
- package/dist/integrations/providers/discover.js.map +1 -1
- package/dist/integrations/providers/harness-credentials.d.ts +44 -9
- package/dist/integrations/providers/harness-credentials.d.ts.map +1 -1
- package/dist/integrations/providers/harness-credentials.js +140 -11
- package/dist/integrations/providers/harness-credentials.js.map +1 -1
- package/dist/integrations/providers/identity.d.ts +20 -24
- package/dist/integrations/providers/identity.d.ts.map +1 -1
- package/dist/integrations/providers/identity.js +20 -24
- package/dist/integrations/providers/identity.js.map +1 -1
- package/dist/integrations/providers/index.d.ts +1 -1
- package/dist/integrations/providers/index.d.ts.map +1 -1
- package/dist/integrations/providers/index.js +1 -1
- package/dist/integrations/providers/index.js.map +1 -1
- package/dist/integrations/providers/oauth.d.ts +8 -3
- package/dist/integrations/providers/oauth.d.ts.map +1 -1
- package/dist/integrations/providers/oauth.js +37 -11
- package/dist/integrations/providers/oauth.js.map +1 -1
- package/dist/integrations/providers/subscription-login.d.ts +7 -41
- package/dist/integrations/providers/subscription-login.d.ts.map +1 -1
- package/dist/integrations/providers/subscription-login.js +26 -149
- package/dist/integrations/providers/subscription-login.js.map +1 -1
- package/dist/tui/App.d.ts.map +1 -1
- package/dist/tui/App.js +316 -83
- package/dist/tui/App.js.map +1 -1
- package/dist/tui/ChoicePicker.d.ts +14 -0
- package/dist/tui/ChoicePicker.d.ts.map +1 -0
- package/dist/tui/ChoicePicker.js +15 -0
- package/dist/tui/ChoicePicker.js.map +1 -0
- package/dist/tui/Picker.d.ts +4 -2
- package/dist/tui/Picker.d.ts.map +1 -1
- package/dist/tui/Picker.js +99 -10
- package/dist/tui/Picker.js.map +1 -1
- package/dist/tui/StatusBar.d.ts +24 -40
- package/dist/tui/StatusBar.d.ts.map +1 -1
- package/dist/tui/StatusBar.js +71 -106
- package/dist/tui/StatusBar.js.map +1 -1
- package/dist/tui/agent.d.ts.map +1 -1
- package/dist/tui/agent.js +10 -8
- package/dist/tui/agent.js.map +1 -1
- package/dist/tui/login-prompt.d.ts +0 -1
- package/dist/tui/login-prompt.d.ts.map +1 -1
- package/dist/tui/login-prompt.js +1 -6
- package/dist/tui/login-prompt.js.map +1 -1
- package/dist/tui/slashCommands.d.ts +8 -0
- package/dist/tui/slashCommands.d.ts.map +1 -1
- package/dist/tui/slashCommands.js +20 -15
- package/dist/tui/slashCommands.js.map +1 -1
- package/package.json +4 -4
|
@@ -1,19 +1,66 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* record, validates only the fields its provider wire needs, and never writes
|
|
6
|
-
* either file. In particular, refresh tokens remain owned by the harness that
|
|
7
|
-
* obtained them; consuming a single-use refresh grant here would race that
|
|
8
|
-
* owner and could log it out.
|
|
9
|
-
*/
|
|
10
|
-
import { readFileSync, statSync } from 'node:fs';
|
|
1
|
+
/** Adapters for credentials owned by co-installed agent harnesses. */
|
|
2
|
+
import { execFileSync } from 'node:child_process';
|
|
3
|
+
import { randomBytes } from 'node:crypto';
|
|
4
|
+
import { closeSync, fsyncSync, openSync, readFileSync, renameSync, statSync, unlinkSync, writeFileSync, } from 'node:fs';
|
|
11
5
|
import { homedir } from 'node:os';
|
|
12
|
-
import { isAbsolute, join, resolve } from 'node:path';
|
|
6
|
+
import { basename, dirname, isAbsolute, join, resolve } from 'node:path';
|
|
13
7
|
const MAX_CREDENTIAL_FILE_BYTES = 1024 * 1024;
|
|
14
8
|
export function claudeCredentialsPath(home = homedir()) {
|
|
15
9
|
return join(home, '.claude', '.credentials.json');
|
|
16
10
|
}
|
|
11
|
+
/** Convert an absolute Windows path into the drive mount WSL exposes. */
|
|
12
|
+
export function windowsPathToWsl(path) {
|
|
13
|
+
const normalized = path.trim().replaceAll('\\', '/');
|
|
14
|
+
const match = /^([A-Za-z]):\/(.+)$/u.exec(normalized);
|
|
15
|
+
if (!match?.[1] || !match[2] || match[2].split('/').includes('..'))
|
|
16
|
+
return null;
|
|
17
|
+
return `/mnt/${match[1].toLowerCase()}/${match[2]}`;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Resolve the Windows account paired with this WSL process.
|
|
21
|
+
*
|
|
22
|
+
* The Windows executable is pinned instead of searched through PATH: this
|
|
23
|
+
* lookup decides where a credential may be read, so a project-local `cmd.exe`
|
|
24
|
+
* must not be able to redirect it. Failure is an ordinary "no second home"
|
|
25
|
+
* result; native Linux never starts a process.
|
|
26
|
+
*/
|
|
27
|
+
export function wslWindowsHome(env = process.env, run = execFileSync, command = '/mnt/c/Windows/System32/cmd.exe') {
|
|
28
|
+
if (!env.WSL_DISTRO_NAME && !env.WSL_INTEROP)
|
|
29
|
+
return null;
|
|
30
|
+
try {
|
|
31
|
+
if (!statSync(command).isFile())
|
|
32
|
+
return null;
|
|
33
|
+
const output = run(command, ['/d', '/s', '/c', 'echo', '%USERPROFILE%'], {
|
|
34
|
+
encoding: 'utf8',
|
|
35
|
+
timeout: 1_000,
|
|
36
|
+
windowsHide: true,
|
|
37
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
38
|
+
});
|
|
39
|
+
return windowsPathToWsl(String(output));
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Usable Claude sessions visible from this process, freshest first.
|
|
47
|
+
*
|
|
48
|
+
* WSL is one device with two home directories in practice. Claude may be
|
|
49
|
+
* installed and signed in on Windows while Namzu runs inside WSL; treating the
|
|
50
|
+
* Linux home as the whole device turns that valid subscription into a missing
|
|
51
|
+
* credential. An explicit `home` remains hermetic for embeds and tests.
|
|
52
|
+
*/
|
|
53
|
+
export function readClaudeFileCredentialCandidates(home, env = process.env, windowsHome = home === undefined ? wslWindowsHome(env) : null) {
|
|
54
|
+
const paths = [
|
|
55
|
+
claudeCredentialsPath(home),
|
|
56
|
+
...(windowsHome ? [claudeCredentialsPath(windowsHome)] : []),
|
|
57
|
+
];
|
|
58
|
+
const unique = [...new Set(paths)];
|
|
59
|
+
return unique.flatMap((path) => {
|
|
60
|
+
const credential = readClaudeCredentialFile(path);
|
|
61
|
+
return credential ? [{ path, credential }] : [];
|
|
62
|
+
});
|
|
63
|
+
}
|
|
17
64
|
export function codexCredentialsPath(home = homedir(), env = process.env) {
|
|
18
65
|
const configured = env.CODEX_HOME?.trim();
|
|
19
66
|
const root = configured
|
|
@@ -65,6 +112,73 @@ export function readClaudeCredentialFile(path) {
|
|
|
65
112
|
scopes: optionalStringArray(oauth?.scopes),
|
|
66
113
|
};
|
|
67
114
|
}
|
|
115
|
+
function sameClaudeCredential(left, right) {
|
|
116
|
+
return (left.accessToken === right.accessToken &&
|
|
117
|
+
left.refreshToken === right.refreshToken &&
|
|
118
|
+
left.expiresAt === right.expiresAt &&
|
|
119
|
+
JSON.stringify(left.scopes ?? []) === JSON.stringify(right.scopes ?? []));
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Publish a refreshed Claude session back to the exact owner file discovered.
|
|
123
|
+
*
|
|
124
|
+
* Claude refresh grants may rotate. Keeping the successor only in Namzu would
|
|
125
|
+
* consume the owner's grant and leave its file unusable, so this preserves the
|
|
126
|
+
* full envelope and atomically replaces only its OAuth fields. The final
|
|
127
|
+
* re-read lets an owner rotation that completed during the network request win.
|
|
128
|
+
* Claude does not participate in Namzu's lock, so this is intentionally not
|
|
129
|
+
* described as a cross-process CAS; it is the strongest owner-compatible
|
|
130
|
+
* publication available for this shared file format.
|
|
131
|
+
*/
|
|
132
|
+
export function replaceClaudeCredentialFile(path, expected, replacement) {
|
|
133
|
+
const root = record(readCredentialJson(path));
|
|
134
|
+
const oauth = record(root?.claudeAiOauth);
|
|
135
|
+
const current = readClaudeCredentialFile(path);
|
|
136
|
+
if (!root || !oauth || !current)
|
|
137
|
+
return { replaced: false, current };
|
|
138
|
+
if (!sameClaudeCredential(current, expected))
|
|
139
|
+
return { replaced: false, current };
|
|
140
|
+
const updated = {
|
|
141
|
+
...root,
|
|
142
|
+
claudeAiOauth: {
|
|
143
|
+
...oauth,
|
|
144
|
+
accessToken: replacement.accessToken,
|
|
145
|
+
...(replacement.refreshToken === undefined ? {} : { refreshToken: replacement.refreshToken }),
|
|
146
|
+
...(replacement.expiresAt === undefined ? {} : { expiresAt: replacement.expiresAt }),
|
|
147
|
+
...(replacement.scopes === undefined ? {} : { scopes: replacement.scopes }),
|
|
148
|
+
},
|
|
149
|
+
};
|
|
150
|
+
const tempPath = join(dirname(path), `.${basename(path)}.namzu-${process.pid}-${randomBytes(8).toString('hex')}.tmp`);
|
|
151
|
+
let descriptor;
|
|
152
|
+
try {
|
|
153
|
+
descriptor = openSync(tempPath, 'wx', 0o600);
|
|
154
|
+
writeFileSync(descriptor, `${JSON.stringify(updated, null, 2)}\n`, 'utf8');
|
|
155
|
+
fsyncSync(descriptor);
|
|
156
|
+
closeSync(descriptor);
|
|
157
|
+
descriptor = undefined;
|
|
158
|
+
const beforeCommit = readClaudeCredentialFile(path);
|
|
159
|
+
if (!beforeCommit || !sameClaudeCredential(beforeCommit, expected)) {
|
|
160
|
+
return { replaced: false, current: beforeCommit };
|
|
161
|
+
}
|
|
162
|
+
renameSync(tempPath, path);
|
|
163
|
+
return { replaced: true, current: replacement };
|
|
164
|
+
}
|
|
165
|
+
finally {
|
|
166
|
+
if (descriptor !== undefined) {
|
|
167
|
+
try {
|
|
168
|
+
closeSync(descriptor);
|
|
169
|
+
}
|
|
170
|
+
catch {
|
|
171
|
+
// The primary publication error remains authoritative.
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
try {
|
|
175
|
+
unlinkSync(tempPath);
|
|
176
|
+
}
|
|
177
|
+
catch {
|
|
178
|
+
// A successful rename has already consumed the temporary name.
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
68
182
|
export function codexCredentialFromTokens(tokens) {
|
|
69
183
|
if (tokens.accessToken.length === 0)
|
|
70
184
|
return null;
|
|
@@ -108,6 +222,21 @@ function jwtClaims(token) {
|
|
|
108
222
|
export function readCodexFileCredential(home = homedir(), env = process.env) {
|
|
109
223
|
return readCodexCredentialFile(codexCredentialsPath(home, env));
|
|
110
224
|
}
|
|
225
|
+
/** Usable Codex sessions visible from this process, including a paired WSL host. */
|
|
226
|
+
export function readCodexFileCredentialCandidates(home, env = process.env, windowsHome = home === undefined ? wslWindowsHome(env) : null) {
|
|
227
|
+
// CODEX_HOME is an explicit authority choice. Do not silently add another
|
|
228
|
+
// store beside it, because two owners could then refresh independently.
|
|
229
|
+
const paths = env.CODEX_HOME?.trim()
|
|
230
|
+
? [codexCredentialsPath(home, env)]
|
|
231
|
+
: [
|
|
232
|
+
codexCredentialsPath(home, env),
|
|
233
|
+
...(windowsHome ? [codexCredentialsPath(windowsHome, {})] : []),
|
|
234
|
+
];
|
|
235
|
+
return [...new Set(paths)].flatMap((path) => {
|
|
236
|
+
const credential = readCodexCredentialFile(path);
|
|
237
|
+
return credential ? [{ path, credential }] : [];
|
|
238
|
+
});
|
|
239
|
+
}
|
|
111
240
|
/** Read a Codex-owned credential from the exact path discovery admitted. */
|
|
112
241
|
export function readCodexCredentialFile(path) {
|
|
113
242
|
const root = record(readCredentialJson(path));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"harness-credentials.js","sourceRoot":"","sources":["../../../src/integrations/providers/harness-credentials.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"harness-credentials.js","sourceRoot":"","sources":["../../../src/integrations/providers/harness-credentials.ts"],"names":[],"mappings":"AAAA,sEAAsE;AAEtE,OAAO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AK,CAAA;IACvB,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAA;IACvB,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,IAAI,MAAM,CAAC,iBAAiB,CAAA;IAC7D,MAAM,WAAW,GAAG,KAAK,CAAC,SAAS,IAAI,MAAM,CAAC,iBAAiB,CAAA;IAC/D,MAAM,SAAS,GAAG,UAAU,GAAG,GAAG,GAAG,MAAM,CAAA;IAC3C,MAAM,UAAU,GAAG,WAAW,GAAG,GAAG,GAAG,MAAM,CAAA;IAC7C,IAAI,SAAS,KAAK,UAAU;QAAE,OAAO,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAA;IAC7D,OAAO,UAAU,IAAI,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAA;AAChD,CAAC"}
|
|
@@ -36,33 +36,29 @@
|
|
|
36
36
|
*
|
|
37
37
|
* ## The addresses
|
|
38
38
|
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
* The redirect port is fixed and NOT free to change: it is part of what the
|
|
47
|
-
* client identity above is registered with, so a different port is simply not
|
|
48
|
-
* an accepted redirect. That is why a busy port degrades to the paste flow
|
|
49
|
-
* rather than picking another one.
|
|
39
|
+
* Re-verified by capturing the exact URL emitted by the installed owner client
|
|
40
|
+
* (`claude auth login --claudeai`, 2.1.241) on 2026-08-23. Its live production
|
|
41
|
+
* contract uses the CAI authorize endpoint, the platform token endpoint and
|
|
42
|
+
* the platform callback below. That client does not offer a loopback redirect
|
|
43
|
+
* on this flow. A localhost callback may be valid OAuth in general, but it is
|
|
44
|
+
* not registered for this client identity; sending one makes the consent page
|
|
45
|
+
* refuse the request before sign-in.
|
|
50
46
|
*/
|
|
51
47
|
export declare const OAUTH_CLIENT_ID = "9d1c250a-e61b-44d9-88ed-5944d1962f5e";
|
|
52
|
-
export declare const OAUTH_TOKEN_URL = "https://
|
|
53
|
-
export declare const AUTHORIZE_URL = "https://claude.
|
|
54
|
-
/** Registered
|
|
55
|
-
export declare const
|
|
56
|
-
export declare const REDIRECT_URI = "http://localhost:53692/callback";
|
|
48
|
+
export declare const OAUTH_TOKEN_URL = "https://platform.claude.com/v1/oauth/token";
|
|
49
|
+
export declare const AUTHORIZE_URL = "https://claude.com/cai/oauth/authorize";
|
|
50
|
+
/** Registered browser-to-terminal callback; not ours to replace with localhost. */
|
|
51
|
+
export declare const MANUAL_REDIRECT_URI = "https://platform.claude.com/oauth/code/callback";
|
|
57
52
|
/**
|
|
58
|
-
* The
|
|
53
|
+
* The direct Claude Pro/Max scope set used by the current Claude harness.
|
|
59
54
|
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
55
|
+
* This looks broader than the inference capability Namzu consumes, but it is
|
|
56
|
+
* the exact set the current owner client sends for `--claudeai`, not its
|
|
57
|
+
* separately selected `--console` flow. The CAI endpoint validates the whole
|
|
58
|
+
* registered request shape; deleting `org:create_api_key` because its name
|
|
59
|
+
* sounds unrelated produces "Invalid request format" before the account can
|
|
60
|
+
* authorize anything. Keep this as one captured protocol value rather than a
|
|
61
|
+
* hand-curated list of what Namzu later uses.
|
|
66
62
|
*/
|
|
67
|
-
export declare const OAUTH_SCOPES = "org:create_api_key user:profile user:inference";
|
|
63
|
+
export declare const OAUTH_SCOPES = "org:create_api_key user:profile user:inference user:sessions:claude_code user:mcp_servers user:file_upload";
|
|
68
64
|
//# sourceMappingURL=identity.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../../src/integrations/providers/identity.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../../src/integrations/providers/identity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAEH,eAAO,MAAM,eAAe,yCAAyC,CAAA;AACrE,eAAO,MAAM,eAAe,+CAA+C,CAAA;AAC3E,eAAO,MAAM,aAAa,2CAA2C,CAAA;AAErE,mFAAmF;AACnF,eAAO,MAAM,mBAAmB,oDAAoD,CAAA;AAEpF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,YAAY,+GACoF,CAAA"}
|
|
@@ -36,33 +36,29 @@
|
|
|
36
36
|
*
|
|
37
37
|
* ## The addresses
|
|
38
38
|
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
* The redirect port is fixed and NOT free to change: it is part of what the
|
|
47
|
-
* client identity above is registered with, so a different port is simply not
|
|
48
|
-
* an accepted redirect. That is why a busy port degrades to the paste flow
|
|
49
|
-
* rather than picking another one.
|
|
39
|
+
* Re-verified by capturing the exact URL emitted by the installed owner client
|
|
40
|
+
* (`claude auth login --claudeai`, 2.1.241) on 2026-08-23. Its live production
|
|
41
|
+
* contract uses the CAI authorize endpoint, the platform token endpoint and
|
|
42
|
+
* the platform callback below. That client does not offer a loopback redirect
|
|
43
|
+
* on this flow. A localhost callback may be valid OAuth in general, but it is
|
|
44
|
+
* not registered for this client identity; sending one makes the consent page
|
|
45
|
+
* refuse the request before sign-in.
|
|
50
46
|
*/
|
|
51
47
|
export const OAUTH_CLIENT_ID = '9d1c250a-e61b-44d9-88ed-5944d1962f5e';
|
|
52
|
-
export const OAUTH_TOKEN_URL = 'https://
|
|
53
|
-
export const AUTHORIZE_URL = 'https://claude.
|
|
54
|
-
/** Registered
|
|
55
|
-
export const
|
|
56
|
-
export const REDIRECT_URI = `http://localhost:${SUBSCRIPTION_REDIRECT_PORT}/callback`;
|
|
48
|
+
export const OAUTH_TOKEN_URL = 'https://platform.claude.com/v1/oauth/token';
|
|
49
|
+
export const AUTHORIZE_URL = 'https://claude.com/cai/oauth/authorize';
|
|
50
|
+
/** Registered browser-to-terminal callback; not ours to replace with localhost. */
|
|
51
|
+
export const MANUAL_REDIRECT_URI = 'https://platform.claude.com/oauth/code/callback';
|
|
57
52
|
/**
|
|
58
|
-
* The
|
|
53
|
+
* The direct Claude Pro/Max scope set used by the current Claude harness.
|
|
59
54
|
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
55
|
+
* This looks broader than the inference capability Namzu consumes, but it is
|
|
56
|
+
* the exact set the current owner client sends for `--claudeai`, not its
|
|
57
|
+
* separately selected `--console` flow. The CAI endpoint validates the whole
|
|
58
|
+
* registered request shape; deleting `org:create_api_key` because its name
|
|
59
|
+
* sounds unrelated produces "Invalid request format" before the account can
|
|
60
|
+
* authorize anything. Keep this as one captured protocol value rather than a
|
|
61
|
+
* hand-curated list of what Namzu later uses.
|
|
66
62
|
*/
|
|
67
|
-
export const OAUTH_SCOPES = 'org:create_api_key user:profile user:inference';
|
|
63
|
+
export const OAUTH_SCOPES = 'org:create_api_key user:profile user:inference user:sessions:claude_code user:mcp_servers user:file_upload';
|
|
68
64
|
//# sourceMappingURL=identity.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../../../src/integrations/providers/identity.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../../../src/integrations/providers/identity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAEH,MAAM,CAAC,MAAM,eAAe,GAAG,sCAAsC,CAAA;AACrE,MAAM,CAAC,MAAM,eAAe,GAAG,4CAA4C,CAAA;AAC3E,MAAM,CAAC,MAAM,aAAa,GAAG,wCAAwC,CAAA;AAErE,mFAAmF;AACnF,MAAM,CAAC,MAAM,mBAAmB,GAAG,iDAAiD,CAAA;AAEpF;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,YAAY,GACxB,4GAA4G,CAAA"}
|
|
@@ -4,7 +4,7 @@ export { type AgentOAuthCredential, isAnthropicOAuthToken, readAgentKeychainCred
|
|
|
4
4
|
export { beginCodexDeviceLogin, CODEX_AUTH_ORIGIN, CODEX_OAUTH_CLIENT_ID, type CodexDeviceLogin, type CodexDeviceLoginOptions, type CodexDeviceLoginOutcome, } from './codex-device-login.js';
|
|
5
5
|
export { clearAllStoredCredentials, clearStoredSubscriptionCredential, clearStoredCodexCredential, CREDENTIALS_FILE_VERSION, CredentialStoreError, credentialsPath, readStoredSubscriptionCredential, readStoredCodexCredential, replaceStoredCodexCredential, type StoredCodexCredential, writeStoredSubscriptionCredential, writeStoredCodexCredential, } from './credential-store.js';
|
|
6
6
|
export { ensureFreshStoredCodexCredential, type StoredCodexRefreshOptions, } from './codex-oauth.js';
|
|
7
|
-
export {
|
|
7
|
+
export { MANUAL_REDIRECT_URI, OAUTH_SCOPES } from './identity.js';
|
|
8
8
|
export { CredentialPublicationError, CredentialRefreshRejectedError, CredentialWithdrawnError, type CredentialOrigin, ensureFreshAnthropicToken, type OAuthMetadata, readSubscriptionCredential, refreshAgentOAuthToken, sameOAuthCredential, } from './oauth.js';
|
|
9
9
|
export { beginSubscriptionLogin, type LoginOutcome, parsePastedInput, type SubscriptionLogin, type SubscriptionLoginOptions, subscriptionDetectedProvider, } from './subscription-login.js';
|
|
10
10
|
export { type CapabilityDisagreement, chainCapabilityDisagreements, describeAcceptedMismatch, describeCapabilityRefusal, type MemberCapabilities, unresolvedMembers, } from './chain-capabilities.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/integrations/providers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,iBAAiB,EACjB,YAAY,EACZ,6BAA6B,GAC7B,MAAM,eAAe,CAAA;AACtB,OAAO,EACN,KAAK,oBAAoB,EACzB,qBAAqB,EACrB,oBAAoB,EACpB,wBAAwB,EACxB,wBAAwB,EACxB,uBAAuB,EACvB,uBAAuB,GACvB,MAAM,0BAA0B,CAAA;AACjC,OAAO,EACN,KAAK,oBAAoB,EACzB,qBAAqB,EACrB,2BAA2B,GAC3B,MAAM,eAAe,CAAA;AACtB,OAAO,EACN,qBAAqB,EACrB,iBAAiB,EACjB,qBAAqB,EACrB,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,GAC5B,MAAM,yBAAyB,CAAA;AAChC,OAAO,EACN,yBAAyB,EACzB,iCAAiC,EACjC,0BAA0B,EAC1B,wBAAwB,EACxB,oBAAoB,EACpB,eAAe,EACf,gCAAgC,EAChC,yBAAyB,EACzB,4BAA4B,EAC5B,KAAK,qBAAqB,EAC1B,iCAAiC,EACjC,0BAA0B,GAC1B,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EACN,gCAAgC,EAChC,KAAK,yBAAyB,GAC9B,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/integrations/providers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,iBAAiB,EACjB,YAAY,EACZ,6BAA6B,GAC7B,MAAM,eAAe,CAAA;AACtB,OAAO,EACN,KAAK,oBAAoB,EACzB,qBAAqB,EACrB,oBAAoB,EACpB,wBAAwB,EACxB,wBAAwB,EACxB,uBAAuB,EACvB,uBAAuB,GACvB,MAAM,0BAA0B,CAAA;AACjC,OAAO,EACN,KAAK,oBAAoB,EACzB,qBAAqB,EACrB,2BAA2B,GAC3B,MAAM,eAAe,CAAA;AACtB,OAAO,EACN,qBAAqB,EACrB,iB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AAe,EACpB,0BAA0B,GAC1B,MAAM,eAAe,CAAA;AACtB,OAAO,EACN,gBAAgB,EAChB,YAAY,EACZ,wBAAwB,GACxB,MAAM,eAAe,CAAA"}
|
|
@@ -4,7 +4,7 @@ export { isAnthropicOAuthToken, readAgentKeychainCredential, } from './keychain.
|
|
|
4
4
|
export { beginCodexDeviceLogin, CODEX_AUTH_ORIGIN, CODEX_OAUTH_CLIENT_ID, } from './codex-device-login.js';
|
|
5
5
|
export { clearAllStoredCredentials, clearStoredSubscriptionCredential, clearStoredCodexCredential, CREDENTIALS_FILE_VERSION, CredentialStoreError, credentialsPath, readStoredSubscriptionCredential, readStoredCodexCredential, replaceStoredCodexCredential, writeStoredSubscriptionCredential, writeStoredCodexCredential, } from './credential-store.js';
|
|
6
6
|
export { ensureFreshStoredCodexCredential, } from './codex-oauth.js';
|
|
7
|
-
export {
|
|
7
|
+
export { MANUAL_REDIRECT_URI, OAUTH_SCOPES } from './identity.js';
|
|
8
8
|
export { CredentialPublicationError, CredentialRefreshRejectedError, CredentialWithdrawnError, ensureFreshAnthropicToken, readSubscriptionCredential, refreshAgentOAuthToken, sameOAuthCredential, } from './oauth.js';
|
|
9
9
|
export { beginSubscriptionLogin, parsePastedInput, subscriptionDetectedProvider, } from './subscription-login.js';
|
|
10
10
|
export { chainCapabilityDisagreements, describeAcceptedMismatch, describeCapabilityRefusal, unresolvedMembers, } from './chain-capabilities.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/integrations/providers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAIN,iBAAiB,EACjB,YAAY,EACZ,6BAA6B,GAC7B,MAAM,eAAe,CAAA;AACtB,OAAO,EAEN,qBAAqB,EACrB,oBAAoB,EACpB,wBAAwB,EACxB,wBAAwB,EACxB,uBAAuB,EACvB,uBAAuB,GACvB,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAEN,qBAAqB,EACrB,2BAA2B,GAC3B,MAAM,eAAe,CAAA;AACtB,OAAO,EACN,qBAAqB,EACrB,iBAAiB,EACjB,qBAAqB,GAIrB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EACN,yBAAyB,EACzB,iCAAiC,EACjC,0BAA0B,EAC1B,wBAAwB,EACxB,oBAAoB,EACpB,eAAe,EACf,gCAAgC,EAChC,yBAAyB,EACzB,4BAA4B,EAE5B,iCAAiC,EACjC,0BAA0B,GAC1B,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EACN,gCAAgC,GAEhC,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/integrations/providers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAIN,iBAAiB,EACjB,YAAY,EACZ,6BAA6B,GAC7B,MAAM,eAAe,CAAA;AACtB,OAAO,EAEN,qBAAqB,EACrB,oBAAoB,EACpB,wBAAwB,EACxB,wBAAwB,EACxB,uBAAuB,EACvB,uBAAuB,GACvB,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAEN,qBAAqB,EACrB,2BAA2B,GAC3B,MAAM,eAAe,CAAA;AACtB,OAAO,EACN,qBAAqB,EACrB,iBAAiB,EACjB,qBAAqB,GAIrB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EACN,yBAAyB,EACzB,iCAAiC,EACjC,0BAA0B,EAC1B,wBAAwB,EACxB,oBAAoB,EACpB,eAAe,EACf,gCAAgC,EAChC,yBAAyB,EACzB,4BAA4B,EAE5B,iCAAiC,EACjC,0BAA0B,GAC1B,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EACN,gCAAgC,GAEhC,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AACjE,OAAO,EACN,0BAA0B,EAC1B,8BAA8B,EAC9B,wBAAwB,EAExB,yBAAyB,EAEzB,0BAA0B,EAC1B,sBAAsB,EACtB,mBAAmB,GACnB,MAAM,YAAY,CAAA;AACnB,OAAO,EACN,sBAAsB,EAEtB,gBAAgB,EAGhB,4BAA4B,GAC5B,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAEN,4BAA4B,EAC5B,wBAAwB,EACxB,yBAAyB,EAEzB,iBAAiB,GACjB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EACN,iBAAiB,EAEjB,wBAAwB,EACxB,gBAAgB,EAChB,eAAe,EACf,eAAe,EAGf,eAAe,EACf,gBAAgB,GAChB,MAAM,kBAAkB,CAAA;AACzB,OAAO,EACN,gBAAgB,EAChB,wBAAwB,EACxB,iBAAiB,EAKjB,0BAA0B,GAC1B,MAAM,eAAe,CAAA;AACtB,OAAO,EACN,gBAAgB,EAChB,YAAY,EACZ,wBAAwB,GACxB,MAAM,eAAe,CAAA"}
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
*
|
|
17
17
|
* ## Where a refreshed token is written back
|
|
18
18
|
*
|
|
19
|
-
* There are
|
|
19
|
+
* There are three places a subscription credential can live and they are not
|
|
20
20
|
* interchangeable, so `origin` says which one this credential came from and
|
|
21
21
|
* therefore which publication rule applies:
|
|
22
22
|
*
|
|
@@ -24,6 +24,9 @@
|
|
|
24
24
|
* every platform. A refresh replaces only the exact credential it used.
|
|
25
25
|
* - `'keychain'` — a co-installed tool's macOS entry, which namzu reads but
|
|
26
26
|
* does not own. A refresh is session-local and never writes that entry.
|
|
27
|
+
* - `'claude-file'` — Claude's device-session file. A rotating refresh grant
|
|
28
|
+
* must publish its successor back to the exact admitted file or it would
|
|
29
|
+
* log the owner out, so publication preserves Claude's full envelope.
|
|
27
30
|
*
|
|
28
31
|
* `origin` is optional and defaults to `'keychain'` because that is the only
|
|
29
32
|
* source that existed when this file was written. Every namzu-owned caller
|
|
@@ -50,7 +53,7 @@ import { type AgentOAuthCredential } from './keychain.js';
|
|
|
50
53
|
* One credential, one store, for its whole life. `discover.ts` decides which
|
|
51
54
|
* at detection; everything after that is told, not asked.
|
|
52
55
|
*/
|
|
53
|
-
export declare function readSubscriptionCredential(origin: CredentialOrigin): AgentOAuthCredential | null;
|
|
56
|
+
export declare function readSubscriptionCredential(origin: CredentialOrigin, sourcePath?: string): AgentOAuthCredential | null;
|
|
54
57
|
/** Which store a subscription credential came from and therefore who owns publication. */
|
|
55
58
|
export type CredentialOrigin = 'stored' | 'keychain' | 'claude-file';
|
|
56
59
|
export interface OAuthMetadata {
|
|
@@ -59,6 +62,8 @@ export interface OAuthMetadata {
|
|
|
59
62
|
readonly scopes?: readonly string[];
|
|
60
63
|
/** Defaults to `'keychain'` — see the note at the top of this file. */
|
|
61
64
|
readonly origin?: CredentialOrigin;
|
|
65
|
+
/** Exact owner file admitted by discovery; required for `'claude-file'`. */
|
|
66
|
+
readonly sourcePath?: string;
|
|
62
67
|
}
|
|
63
68
|
/** The credential that authorized a refresh was removed before publication. */
|
|
64
69
|
export declare class CredentialWithdrawnError extends Error {
|
|
@@ -93,5 +98,5 @@ export declare function sameOAuthCredential(left: AgentOAuthCredential, right: A
|
|
|
93
98
|
* `400 invalid_grant` throws {@link CredentialRefreshRejectedError}; retrying
|
|
94
99
|
* the same grant is not recovery.
|
|
95
100
|
*/
|
|
96
|
-
export declare function refreshAgentOAuthToken(refreshToken: string, signal?: AbortSignal): Promise<AgentOAuthCredential | null>;
|
|
101
|
+
export declare function refreshAgentOAuthToken(refreshToken: string, signal?: AbortSignal, scopes?: readonly string[]): Promise<AgentOAuthCredential | null>;
|
|
97
102
|
//# sourceMappingURL=oauth.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth.d.ts","sourceRoot":"","sources":["../../../src/integrations/providers/oauth.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"oauth.d.ts","sourceRoot":"","sources":["../../../src/integrations/providers/oauth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAYH,OAAO,EAAE,KAAK,o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AAsB,sBAAsB,CAC3C,YAAY,EAAE,MAAM,EACpB,MAAM,CAAC,EAAE,WAAW,EACpB,MAAM,GAAE,SAAS,MAAM,EAA4B,GACjD,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAgEtC"}
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
*
|
|
17
17
|
* ## Where a refreshed token is written back
|
|
18
18
|
*
|
|
19
|
-
* There are
|
|
19
|
+
* There are three places a subscription credential can live and they are not
|
|
20
20
|
* interchangeable, so `origin` says which one this credential came from and
|
|
21
21
|
* therefore which publication rule applies:
|
|
22
22
|
*
|
|
@@ -24,6 +24,9 @@
|
|
|
24
24
|
* every platform. A refresh replaces only the exact credential it used.
|
|
25
25
|
* - `'keychain'` — a co-installed tool's macOS entry, which namzu reads but
|
|
26
26
|
* does not own. A refresh is session-local and never writes that entry.
|
|
27
|
+
* - `'claude-file'` — Claude's device-session file. A rotating refresh grant
|
|
28
|
+
* must publish its successor back to the exact admitted file or it would
|
|
29
|
+
* log the owner out, so publication preserves Claude's full envelope.
|
|
27
30
|
*
|
|
28
31
|
* `origin` is optional and defaults to `'keychain'` because that is the only
|
|
29
32
|
* source that existed when this file was written. Every namzu-owned caller
|
|
@@ -34,8 +37,8 @@
|
|
|
34
37
|
import { buildProbeContext, probe } from '@namzu/sdk';
|
|
35
38
|
import { SUBSCRIPTION_CREDENTIAL_REF } from './credential-provider.js';
|
|
36
39
|
import { credentialsPath, readStoredSubscriptionCredential, replaceStoredSubscriptionCredential, } from './credential-store.js';
|
|
37
|
-
import {
|
|
38
|
-
import { OAUTH_CLIENT_ID, OAUTH_TOKEN_URL } from './identity.js';
|
|
40
|
+
import { readClaudeCredentialFile, replaceClaudeCredentialFile } from './harness-credentials.js';
|
|
41
|
+
import { OAUTH_CLIENT_ID, OAUTH_SCOPES, OAUTH_TOKEN_URL } from './identity.js';
|
|
39
42
|
import { readAgentKeychainCredential } from './keychain.js';
|
|
40
43
|
/** Refresh a few seconds early so an about-to-expire token isn't used. */
|
|
41
44
|
const EXPIRY_SKEW_MS = 60_000;
|
|
@@ -89,10 +92,13 @@ async function awaitWithSignal(operation, signal) {
|
|
|
89
92
|
* One credential, one store, for its whole life. `discover.ts` decides which
|
|
90
93
|
* at detection; everything after that is told, not asked.
|
|
91
94
|
*/
|
|
92
|
-
export function readSubscriptionCredential(origin) {
|
|
95
|
+
export function readSubscriptionCredential(origin, sourcePath) {
|
|
93
96
|
if (origin === 'stored')
|
|
94
97
|
return readStoredSubscriptionCredential();
|
|
95
|
-
|
|
98
|
+
if (origin === 'claude-file') {
|
|
99
|
+
return sourcePath ? readClaudeCredentialFile(sourcePath) : null;
|
|
100
|
+
}
|
|
101
|
+
return readAgentKeychainCredential();
|
|
96
102
|
}
|
|
97
103
|
/** The credential that authorized a refresh was removed before publication. */
|
|
98
104
|
export class CredentialWithdrawnError extends Error {
|
|
@@ -130,7 +136,7 @@ export async function ensureFreshAnthropicToken(accessToken, oauth, signal) {
|
|
|
130
136
|
return accessToken;
|
|
131
137
|
if (!oauth.refreshToken)
|
|
132
138
|
return accessToken;
|
|
133
|
-
const refreshed = await refreshAgentOAuthToken(oauth.refreshToken, signal);
|
|
139
|
+
const refreshed = await refreshAgentOAuthToken(oauth.refreshToken, signal, oauth.scopes);
|
|
134
140
|
if (!refreshed)
|
|
135
141
|
return accessToken;
|
|
136
142
|
// The response body was the final foreign await. Re-check immediately at
|
|
@@ -142,7 +148,8 @@ export async function ensureFreshAnthropicToken(accessToken, oauth, signal) {
|
|
|
142
148
|
expiresAt: oauth.expiresAt,
|
|
143
149
|
scopes: oauth.scopes,
|
|
144
150
|
};
|
|
145
|
-
return publishRefreshed(expected, refreshed, oauth.origin ?? 'keychain')
|
|
151
|
+
return publishRefreshed(expected, refreshed, oauth.origin ?? 'keychain', oauth.sourcePath)
|
|
152
|
+
.accessToken;
|
|
146
153
|
}
|
|
147
154
|
/**
|
|
148
155
|
* Say that a credential turned over, without saying what it turned into.
|
|
@@ -161,17 +168,34 @@ function announceRotation(replaced) {
|
|
|
161
168
|
ref: SUBSCRIPTION_CREDENTIAL_REF,
|
|
162
169
|
}, buildProbeContext());
|
|
163
170
|
}
|
|
164
|
-
function publishRefreshed(expected, refreshed, origin) {
|
|
165
|
-
if (origin
|
|
171
|
+
function publishRefreshed(expected, refreshed, origin, sourcePath) {
|
|
172
|
+
if (origin === 'keychain') {
|
|
166
173
|
// This entry belongs to another product, whose writer cannot participate
|
|
167
174
|
// in a Namzu lock or conditional update. Never overwrite it. A rotation
|
|
168
175
|
// that landed while the request was pending wins for this session; when it
|
|
169
176
|
// is unchanged, the refreshed token remains session-local.
|
|
170
|
-
const current =
|
|
177
|
+
const current = readAgentKeychainCredential();
|
|
171
178
|
if (!current)
|
|
172
179
|
throw new CredentialWithdrawnError();
|
|
173
180
|
return !sameOAuthCredential(current, expected) ? current : refreshed;
|
|
174
181
|
}
|
|
182
|
+
if (origin === 'claude-file') {
|
|
183
|
+
if (!sourcePath)
|
|
184
|
+
throw new CredentialPublicationError();
|
|
185
|
+
let result;
|
|
186
|
+
try {
|
|
187
|
+
result = replaceClaudeCredentialFile(sourcePath, expected, refreshed);
|
|
188
|
+
}
|
|
189
|
+
catch (error) {
|
|
190
|
+
throw new CredentialPublicationError({ cause: error });
|
|
191
|
+
}
|
|
192
|
+
if (!result.replaced) {
|
|
193
|
+
if (!result.current)
|
|
194
|
+
throw new CredentialWithdrawnError();
|
|
195
|
+
return result.current;
|
|
196
|
+
}
|
|
197
|
+
return refreshed;
|
|
198
|
+
}
|
|
175
199
|
let result;
|
|
176
200
|
try {
|
|
177
201
|
result = replaceStoredSubscriptionCredential(expected, refreshed);
|
|
@@ -217,7 +241,7 @@ export function sameOAuthCredential(left, right) {
|
|
|
217
241
|
* `400 invalid_grant` throws {@link CredentialRefreshRejectedError}; retrying
|
|
218
242
|
* the same grant is not recovery.
|
|
219
243
|
*/
|
|
220
|
-
export async function refreshAgentOAuthToken(refreshToken, signal) {
|
|
244
|
+
export async function refreshAgentOAuthToken(refreshToken, signal, scopes = OAUTH_SCOPES.split(' ')) {
|
|
221
245
|
signal?.throwIfAborted();
|
|
222
246
|
const requestController = new AbortController();
|
|
223
247
|
const timeoutCause = new RefreshDeadlineError();
|
|
@@ -234,6 +258,7 @@ export async function refreshAgentOAuthToken(refreshToken, signal) {
|
|
|
234
258
|
grant_type: 'refresh_token',
|
|
235
259
|
refresh_token: refreshToken,
|
|
236
260
|
client_id: OAUTH_CLIENT_ID,
|
|
261
|
+
scope: scopes.join(' '),
|
|
237
262
|
}),
|
|
238
263
|
signal: requestController.signal,
|
|
239
264
|
}), requestController.signal);
|
|
@@ -254,6 +279,7 @@ export async function refreshAgentOAuthToken(refreshToken, signal) {
|
|
|
254
279
|
accessToken: data.access_token,
|
|
255
280
|
refreshToken: typeof data.refresh_token === 'string' ? data.refresh_token : refreshToken,
|
|
256
281
|
expiresAt: typeof data.expires_in === 'number' ? Date.now() + data.expires_in * 1_000 : undefined,
|
|
282
|
+
scopes: typeof data.scope === 'string' ? data.scope.split(' ').filter(Boolean) : [...scopes],
|
|
257
283
|
};
|
|
258
284
|
}
|
|
259
285
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth.js","sourceRoot":"","sources":["../../../src/integrations/providers/oauth.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"oauth.js","sourceRoot":"","sources":["../../../src/integrations/providers/oauth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,EAAE,iBAAiB,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAErD,OAAO,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAA;AACtE,OAAO,EACN,eAAe,EACf,gCAAgC,EAChC,mCAAmC,GACnC,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,wBAAwB,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAA;AAChG,OAA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