@pellux/goodvibes-sdk 0.18.49 → 0.18.50
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/_internal/errors/index.d.ts +27 -2
- package/dist/_internal/errors/index.d.ts.map +1 -1
- package/dist/_internal/errors/index.js +44 -2
- package/dist/_internal/platform/auth/index.d.ts +6 -0
- package/dist/_internal/platform/auth/index.d.ts.map +1 -0
- package/dist/_internal/platform/auth/index.js +4 -0
- package/dist/_internal/platform/auth/oauth-client.d.ts +45 -0
- package/dist/_internal/platform/auth/oauth-client.d.ts.map +1 -0
- package/dist/_internal/platform/auth/oauth-client.js +45 -0
- package/dist/_internal/platform/auth/permission-resolver.d.ts +35 -0
- package/dist/_internal/platform/auth/permission-resolver.d.ts.map +1 -0
- package/dist/_internal/platform/auth/permission-resolver.js +57 -0
- package/dist/_internal/platform/auth/session-manager.d.ts +31 -0
- package/dist/_internal/platform/auth/session-manager.d.ts.map +1 -0
- package/dist/_internal/platform/auth/session-manager.js +44 -0
- package/dist/_internal/platform/auth/token-store.d.ts +23 -0
- package/dist/_internal/platform/auth/token-store.d.ts.map +1 -0
- package/dist/_internal/platform/auth/token-store.js +34 -0
- package/dist/_internal/platform/core/orchestrator.d.ts +75 -11
- package/dist/_internal/platform/core/orchestrator.d.ts.map +1 -1
- package/dist/_internal/platform/core/orchestrator.js +29 -8
- package/dist/_internal/platform/version.js +1 -1
- package/dist/_internal/transport-realtime/domain-events.d.ts +26 -0
- package/dist/_internal/transport-realtime/domain-events.d.ts.map +1 -1
- package/dist/_internal/transport-realtime/domain-events.js +63 -0
- package/dist/_internal/transport-realtime/index.d.ts +2 -2
- package/dist/_internal/transport-realtime/index.d.ts.map +1 -1
- package/dist/_internal/transport-realtime/index.js +2 -2
- package/dist/_internal/transport-realtime/runtime-events.d.ts +27 -1
- package/dist/_internal/transport-realtime/runtime-events.d.ts.map +1 -1
- package/dist/_internal/transport-realtime/runtime-events.js +27 -0
- package/dist/auth.d.ts +28 -0
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +3 -0
- package/dist/browser.d.ts +1 -0
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +1 -0
- package/dist/client.d.ts +50 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +2 -0
- package/dist/expo.d.ts +1 -0
- package/dist/expo.d.ts.map +1 -1
- package/dist/expo.js +1 -0
- package/dist/node.d.ts +1 -0
- package/dist/node.d.ts.map +1 -1
- package/dist/node.js +1 -0
- package/dist/react-native.d.ts +1 -0
- package/dist/react-native.d.ts.map +1 -1
- package/dist/react-native.js +1 -0
- package/dist/web.d.ts +1 -0
- package/dist/web.d.ts.map +1 -1
- package/dist/web.js +1 -0
- package/package.json +1 -1
|
@@ -2,6 +2,20 @@ import type { DaemonErrorCategory, DaemonErrorSource, StructuredDaemonErrorBody
|
|
|
2
2
|
export type { DaemonErrorCategory, DaemonErrorSource, StructuredDaemonErrorBody, } from './daemon-error-contract.js';
|
|
3
3
|
export type ErrorCategory = DaemonErrorCategory | 'contract';
|
|
4
4
|
export type ErrorSource = DaemonErrorSource | 'contract';
|
|
5
|
+
/**
|
|
6
|
+
* Tagged union discriminant for all SDK errors. Use this for exhaustive
|
|
7
|
+
* switch/if-else handling instead of `instanceof` chains.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* if (error instanceof GoodVibesSdkError) {
|
|
11
|
+
* if (error.kind === 'rate-limit') {
|
|
12
|
+
* await delay(error.retryAfterMs ?? 1000);
|
|
13
|
+
* } else if (error.kind === 'auth') {
|
|
14
|
+
* // refresh credentials
|
|
15
|
+
* }
|
|
16
|
+
* }
|
|
17
|
+
*/
|
|
18
|
+
export type SDKErrorKind = 'auth' | 'config' | 'contract' | 'network' | 'not-found' | 'rate-limit' | 'server' | 'validation' | 'unknown';
|
|
5
19
|
export interface GoodVibesSdkErrorOptions {
|
|
6
20
|
readonly code?: string;
|
|
7
21
|
readonly category?: ErrorCategory;
|
|
@@ -45,6 +59,7 @@ export declare const RETRYABLE_STATUS_CODES: readonly number[];
|
|
|
45
59
|
* ```
|
|
46
60
|
*/
|
|
47
61
|
export declare class GoodVibesSdkError extends Error {
|
|
62
|
+
readonly kind: SDKErrorKind;
|
|
48
63
|
readonly code?: string;
|
|
49
64
|
readonly category: ErrorCategory;
|
|
50
65
|
readonly source: ErrorSource;
|
|
@@ -68,7 +83,10 @@ export declare class GoodVibesSdkError extends Error {
|
|
|
68
83
|
* implementation available, or calling a mutation on a read-only auth resolver).
|
|
69
84
|
*
|
|
70
85
|
* Always non-recoverable (`recoverable: false`).
|
|
71
|
-
* Category: `'config'`.
|
|
86
|
+
* Category: `'config'`. Kind: `'config'`.
|
|
87
|
+
*
|
|
88
|
+
* @deprecated Use `error.kind === 'config'` instead of `instanceof ConfigurationError`.
|
|
89
|
+
* This class is preserved for backward compatibility and still throws normally.
|
|
72
90
|
*
|
|
73
91
|
* @example
|
|
74
92
|
* import { ConfigurationError } from '@pellux/goodvibes-sdk';
|
|
@@ -89,7 +107,10 @@ export declare class ConfigurationError extends GoodVibesSdkError {
|
|
|
89
107
|
* (unexpected shape, missing required fields, etc.).
|
|
90
108
|
*
|
|
91
109
|
* Always non-recoverable (`recoverable: false`).
|
|
92
|
-
* Category: `'contract'`.
|
|
110
|
+
* Category: `'contract'`. Kind: `'contract'`.
|
|
111
|
+
*
|
|
112
|
+
* @deprecated Use `error.kind === 'contract'` instead of `instanceof ContractError`.
|
|
113
|
+
* This class is preserved for backward compatibility and still throws normally.
|
|
93
114
|
*
|
|
94
115
|
* @example
|
|
95
116
|
* import { ContractError } from '@pellux/goodvibes-sdk';
|
|
@@ -117,6 +138,10 @@ export declare class ContractError extends GoodVibesSdkError {
|
|
|
117
138
|
* Use `recoverable` to decide whether to retry, and `retryAfterMs` for
|
|
118
139
|
* the backoff hint on rate-limit responses.
|
|
119
140
|
*
|
|
141
|
+
* @deprecated Use `error.kind` instead of `instanceof HttpStatusError`.
|
|
142
|
+
* For example: `error.kind === 'rate-limit'`, `error.kind === 'auth'`, `error.kind === 'server'`.
|
|
143
|
+
* This class is preserved for backward compatibility and still throws normally.
|
|
144
|
+
*
|
|
120
145
|
* @example
|
|
121
146
|
* import { HttpStatusError } from '@pellux/goodvibes-sdk';
|
|
122
147
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/_internal/errors/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,mBAAmB,EACnB,iBAAiB,EACjB,yBAAyB,EAC1B,MAAM,4BAA4B,CAAC;AAEpC,YAAY,EACV,mBAAmB,EACnB,iBAAiB,EACjB,yBAAyB,GAC1B,MAAM,4BAA4B,CAAC;AAEpC,MAAM,MAAM,aAAa,GAAG,mBAAmB,GAAG,UAAU,CAAC;AAE7D,MAAM,MAAM,WAAW,GAAG,iBAAiB,GAAG,UAAU,CAAC;AAEzD,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,CAAC,EAAE,aAAa,CAAC;IAClC,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAC9B,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;IAC/B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,SAAS,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AO,GAAE,wBAA6B;CAOpE;AAED,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,yBAAyB,CAE9F;AAED,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,OAAO,GACZ,eAAe,CAgCjB"}
|
|
@@ -1,3 +1,33 @@
|
|
|
1
|
+
function inferKind(category) {
|
|
2
|
+
switch (category) {
|
|
3
|
+
case 'authentication':
|
|
4
|
+
case 'authorization':
|
|
5
|
+
case 'billing':
|
|
6
|
+
case 'permission':
|
|
7
|
+
return 'auth';
|
|
8
|
+
case 'config':
|
|
9
|
+
return 'config';
|
|
10
|
+
case 'contract':
|
|
11
|
+
return 'contract';
|
|
12
|
+
case 'network':
|
|
13
|
+
case 'timeout':
|
|
14
|
+
return 'network';
|
|
15
|
+
case 'not_found':
|
|
16
|
+
return 'not-found';
|
|
17
|
+
case 'rate_limit':
|
|
18
|
+
return 'rate-limit';
|
|
19
|
+
case 'protocol':
|
|
20
|
+
case 'service':
|
|
21
|
+
case 'internal':
|
|
22
|
+
return 'server';
|
|
23
|
+
case 'bad_request':
|
|
24
|
+
return 'validation';
|
|
25
|
+
case 'tool':
|
|
26
|
+
case 'unknown':
|
|
27
|
+
default:
|
|
28
|
+
return 'unknown';
|
|
29
|
+
}
|
|
30
|
+
}
|
|
1
31
|
export const RETRYABLE_STATUS_CODES = [408, 429, 500, 502, 503, 504];
|
|
2
32
|
function inferCategory(status) {
|
|
3
33
|
if (status === 400)
|
|
@@ -42,6 +72,7 @@ function inferCategory(status) {
|
|
|
42
72
|
* ```
|
|
43
73
|
*/
|
|
44
74
|
export class GoodVibesSdkError extends Error {
|
|
75
|
+
kind;
|
|
45
76
|
code;
|
|
46
77
|
category;
|
|
47
78
|
source;
|
|
@@ -63,6 +94,7 @@ export class GoodVibesSdkError extends Error {
|
|
|
63
94
|
this.name = this.constructor.name;
|
|
64
95
|
this.code = options.code;
|
|
65
96
|
this.category = options.category ?? inferCategory(options.status);
|
|
97
|
+
this.kind = inferKind(this.category);
|
|
66
98
|
this.source = options.source ?? 'unknown';
|
|
67
99
|
this.recoverable = options.recoverable ?? (options.status !== undefined && RETRYABLE_STATUS_CODES.includes(options.status));
|
|
68
100
|
this.status = options.status;
|
|
@@ -84,7 +116,10 @@ export class GoodVibesSdkError extends Error {
|
|
|
84
116
|
* implementation available, or calling a mutation on a read-only auth resolver).
|
|
85
117
|
*
|
|
86
118
|
* Always non-recoverable (`recoverable: false`).
|
|
87
|
-
* Category: `'config'`.
|
|
119
|
+
* Category: `'config'`. Kind: `'config'`.
|
|
120
|
+
*
|
|
121
|
+
* @deprecated Use `error.kind === 'config'` instead of `instanceof ConfigurationError`.
|
|
122
|
+
* This class is preserved for backward compatibility and still throws normally.
|
|
88
123
|
*
|
|
89
124
|
* @example
|
|
90
125
|
* import { ConfigurationError } from '@pellux/goodvibes-sdk';
|
|
@@ -113,7 +148,10 @@ export class ConfigurationError extends GoodVibesSdkError {
|
|
|
113
148
|
* (unexpected shape, missing required fields, etc.).
|
|
114
149
|
*
|
|
115
150
|
* Always non-recoverable (`recoverable: false`).
|
|
116
|
-
* Category: `'contract'`.
|
|
151
|
+
* Category: `'contract'`. Kind: `'contract'`.
|
|
152
|
+
*
|
|
153
|
+
* @deprecated Use `error.kind === 'contract'` instead of `instanceof ContractError`.
|
|
154
|
+
* This class is preserved for backward compatibility and still throws normally.
|
|
117
155
|
*
|
|
118
156
|
* @example
|
|
119
157
|
* import { ContractError } from '@pellux/goodvibes-sdk';
|
|
@@ -149,6 +187,10 @@ export class ContractError extends GoodVibesSdkError {
|
|
|
149
187
|
* Use `recoverable` to decide whether to retry, and `retryAfterMs` for
|
|
150
188
|
* the backoff hint on rate-limit responses.
|
|
151
189
|
*
|
|
190
|
+
* @deprecated Use `error.kind` instead of `instanceof HttpStatusError`.
|
|
191
|
+
* For example: `error.kind === 'rate-limit'`, `error.kind === 'auth'`, `error.kind === 'server'`.
|
|
192
|
+
* This class is preserved for backward compatibility and still throws normally.
|
|
193
|
+
*
|
|
152
194
|
* @example
|
|
153
195
|
* import { HttpStatusError } from '@pellux/goodvibes-sdk';
|
|
154
196
|
*
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { OAuthClient } from './oauth-client.js';
|
|
2
|
+
export type { OAuthStartState, OAuthTokenPayload } from './oauth-client.js';
|
|
3
|
+
export { PermissionResolver } from './permission-resolver.js';
|
|
4
|
+
export { SessionManager } from './session-manager.js';
|
|
5
|
+
export { TokenStore } from './token-store.js';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/_internal/platform/auth/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,YAAY,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OAuthClient — Focused responsibility: OAuth 2.0 / PKCE flows.
|
|
3
|
+
*
|
|
4
|
+
* Wraps the pure functions in `oauth-core.ts` behind a class boundary so
|
|
5
|
+
* callers can inject config once and call methods, rather than threading
|
|
6
|
+
* `OAuthProviderConfig` through every call.
|
|
7
|
+
*/
|
|
8
|
+
import type { OAuthProviderConfig } from '../config/subscriptions.js';
|
|
9
|
+
import type { OAuthStartState, OAuthTokenPayload } from '../runtime/auth/oauth-core.js';
|
|
10
|
+
export type { OAuthStartState, OAuthTokenPayload };
|
|
11
|
+
export declare class OAuthClient {
|
|
12
|
+
#private;
|
|
13
|
+
constructor(config: OAuthProviderConfig);
|
|
14
|
+
/**
|
|
15
|
+
* Build the authorization URL and PKCE state needed to start an OAuth flow.
|
|
16
|
+
* Redirect the user's browser to `result.authorizationUrl`.
|
|
17
|
+
*/
|
|
18
|
+
beginAuthorization(input?: {
|
|
19
|
+
readonly state?: string;
|
|
20
|
+
readonly verifier?: string;
|
|
21
|
+
readonly redirectUri?: string;
|
|
22
|
+
}): OAuthStartState;
|
|
23
|
+
/**
|
|
24
|
+
* Exchange an authorization code (returned via the redirect) for tokens.
|
|
25
|
+
* Use the `state` and `verifier` from the matching `beginAuthorization` call.
|
|
26
|
+
*/
|
|
27
|
+
exchangeCode(input: {
|
|
28
|
+
readonly code: string;
|
|
29
|
+
readonly verifier: string;
|
|
30
|
+
readonly redirectUri: string;
|
|
31
|
+
readonly state?: string;
|
|
32
|
+
}): Promise<OAuthTokenPayload>;
|
|
33
|
+
/**
|
|
34
|
+
* Use a refresh token to obtain a new access token without user interaction.
|
|
35
|
+
*/
|
|
36
|
+
refreshToken(refreshToken: string): Promise<OAuthTokenPayload>;
|
|
37
|
+
/**
|
|
38
|
+
* Decode a JWT access token's payload without verification.
|
|
39
|
+
* Returns null when the token is malformed.
|
|
40
|
+
*/
|
|
41
|
+
decodeJwtPayload(token: string): Record<string, unknown> | null;
|
|
42
|
+
/** Expose the provider config this client was built from. */
|
|
43
|
+
get config(): OAuthProviderConfig;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=oauth-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauth-client.d.ts","sourceRoot":"","sources":["../../../../src/_internal/platform/auth/oauth-client.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAOtE,OAAO,KAAK,EACV,eAAe,EACf,iBAAiB,EAClB,MAAM,+BAA+B,CAAC;AAEvC,YAAY,EAAE,eAAe,EAAE,iBAAiB,EAAE,CAAC;AAEnD,qBAAa,WAAW;;gBAGV,MAAM,EAAE,mBAAmB;IAIvC;;;OAGG;IACH,kBAAkB,CAAC,KAAK,CAAC,EAAE;QACzB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QACxB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAC3B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;KAC/B,GAAG,eAAe;IAInB;;;OAGG;IACG,YAAY,CAAC,KAAK,EAAE;QACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;QAC1B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;QAC7B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;KACzB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAI9B;;OAEG;IACG,YAAY,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAIpE;;;OAGG;IACH,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAI/D,6DAA6D;IAC7D,IAAI,MAAM,IAAI,mBAAmB,CAEhC;CACF"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OAuthClient — Focused responsibility: OAuth 2.0 / PKCE flows.
|
|
3
|
+
*
|
|
4
|
+
* Wraps the pure functions in `oauth-core.ts` behind a class boundary so
|
|
5
|
+
* callers can inject config once and call methods, rather than threading
|
|
6
|
+
* `OAuthProviderConfig` through every call.
|
|
7
|
+
*/
|
|
8
|
+
import { buildOAuthAuthorizationStart, decodeJwtPayload, exchangeOAuthAuthorizationCode, refreshOAuthAccessToken, } from '../runtime/auth/oauth-core.js';
|
|
9
|
+
export class OAuthClient {
|
|
10
|
+
#config;
|
|
11
|
+
constructor(config) {
|
|
12
|
+
this.#config = config;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Build the authorization URL and PKCE state needed to start an OAuth flow.
|
|
16
|
+
* Redirect the user's browser to `result.authorizationUrl`.
|
|
17
|
+
*/
|
|
18
|
+
beginAuthorization(input) {
|
|
19
|
+
return buildOAuthAuthorizationStart(this.#config, input);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Exchange an authorization code (returned via the redirect) for tokens.
|
|
23
|
+
* Use the `state` and `verifier` from the matching `beginAuthorization` call.
|
|
24
|
+
*/
|
|
25
|
+
async exchangeCode(input) {
|
|
26
|
+
return exchangeOAuthAuthorizationCode(this.#config, input);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Use a refresh token to obtain a new access token without user interaction.
|
|
30
|
+
*/
|
|
31
|
+
async refreshToken(refreshToken) {
|
|
32
|
+
return refreshOAuthAccessToken(this.#config, refreshToken);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Decode a JWT access token's payload without verification.
|
|
36
|
+
* Returns null when the token is malformed.
|
|
37
|
+
*/
|
|
38
|
+
decodeJwtPayload(token) {
|
|
39
|
+
return decodeJwtPayload(token);
|
|
40
|
+
}
|
|
41
|
+
/** Expose the provider config this client was built from. */
|
|
42
|
+
get config() {
|
|
43
|
+
return this.#config;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PermissionResolver — Focused responsibility: role and scope checks.
|
|
3
|
+
*
|
|
4
|
+
* Inspects a `ControlPlaneAuthSnapshot` to answer permission questions.
|
|
5
|
+
* Callers that only need access control checks can use this directly
|
|
6
|
+
* rather than traversing the full auth snapshot themselves.
|
|
7
|
+
*/
|
|
8
|
+
import type { ControlPlaneAuthSnapshot } from '../control-plane/auth-snapshot.js';
|
|
9
|
+
export declare class PermissionResolver {
|
|
10
|
+
#private;
|
|
11
|
+
constructor(snapshot: ControlPlaneAuthSnapshot);
|
|
12
|
+
/** Whether the current principal is authenticated. */
|
|
13
|
+
get authenticated(): boolean;
|
|
14
|
+
/** Whether the current principal has admin privileges. */
|
|
15
|
+
get isAdmin(): boolean;
|
|
16
|
+
/** The principal identifier (user/bot/service id), or null when anonymous. */
|
|
17
|
+
get principalId(): string | null;
|
|
18
|
+
/** The kind of the current principal. */
|
|
19
|
+
get principalKind(): ControlPlaneAuthSnapshot['principalKind'];
|
|
20
|
+
/** Return true when the principal holds the given role. */
|
|
21
|
+
hasRole(role: string): boolean;
|
|
22
|
+
/** Return true when the principal holds ALL of the given roles. */
|
|
23
|
+
hasAllRoles(roles: readonly string[]): boolean;
|
|
24
|
+
/** Return true when the principal holds ANY of the given roles. */
|
|
25
|
+
hasAnyRole(roles: readonly string[]): boolean;
|
|
26
|
+
/** Return true when the principal holds the given scope. */
|
|
27
|
+
hasScope(scope: string): boolean;
|
|
28
|
+
/** Return true when the principal holds ALL of the given scopes. */
|
|
29
|
+
hasAllScopes(scopes: readonly string[]): boolean;
|
|
30
|
+
/** Return true when the principal holds ANY of the given scopes. */
|
|
31
|
+
hasAnyScope(scopes: readonly string[]): boolean;
|
|
32
|
+
/** Expose the raw snapshot for direct inspection. */
|
|
33
|
+
get snapshot(): ControlPlaneAuthSnapshot;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=permission-resolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permission-resolver.d.ts","sourceRoot":"","sources":["../../../../src/_internal/platform/auth/permission-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAElF,qBAAa,kBAAkB;;gBAGjB,QAAQ,EAAE,wBAAwB;IAI9C,sDAAsD;IACtD,IAAI,aAAa,IAAI,OAAO,CAE3B;IAED,0DAA0D;IAC1D,IAAI,OAAO,IAAI,OAAO,CAErB;IAED,8EAA8E;IAC9E,IAAI,WAAW,IAAI,MAAM,GAAG,IAAI,CAE/B;IAED,yCAAyC;IACzC,IAAI,aAAa,IAAI,wBAAwB,CAAC,eAAe,CAAC,CAE7D;IAED,2DAA2D;IAC3D,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI9B,mEAAmE;IACnE,WAAW,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO;IAI9C,mEAAmE;IACnE,UAAU,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO;IAI7C,4DAA4D;IAC5D,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAIhC,oEAAoE;IACpE,YAAY,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO;IAIhD,oEAAoE;IACpE,WAAW,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO;IAI/C,qDAAqD;IACrD,IAAI,QAAQ,IAAI,wBAAwB,CAEvC;CACF"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PermissionResolver — Focused responsibility: role and scope checks.
|
|
3
|
+
*
|
|
4
|
+
* Inspects a `ControlPlaneAuthSnapshot` to answer permission questions.
|
|
5
|
+
* Callers that only need access control checks can use this directly
|
|
6
|
+
* rather than traversing the full auth snapshot themselves.
|
|
7
|
+
*/
|
|
8
|
+
export class PermissionResolver {
|
|
9
|
+
#snapshot;
|
|
10
|
+
constructor(snapshot) {
|
|
11
|
+
this.#snapshot = snapshot;
|
|
12
|
+
}
|
|
13
|
+
/** Whether the current principal is authenticated. */
|
|
14
|
+
get authenticated() {
|
|
15
|
+
return this.#snapshot.authenticated;
|
|
16
|
+
}
|
|
17
|
+
/** Whether the current principal has admin privileges. */
|
|
18
|
+
get isAdmin() {
|
|
19
|
+
return this.#snapshot.admin;
|
|
20
|
+
}
|
|
21
|
+
/** The principal identifier (user/bot/service id), or null when anonymous. */
|
|
22
|
+
get principalId() {
|
|
23
|
+
return this.#snapshot.principalId;
|
|
24
|
+
}
|
|
25
|
+
/** The kind of the current principal. */
|
|
26
|
+
get principalKind() {
|
|
27
|
+
return this.#snapshot.principalKind;
|
|
28
|
+
}
|
|
29
|
+
/** Return true when the principal holds the given role. */
|
|
30
|
+
hasRole(role) {
|
|
31
|
+
return this.#snapshot.roles.includes(role);
|
|
32
|
+
}
|
|
33
|
+
/** Return true when the principal holds ALL of the given roles. */
|
|
34
|
+
hasAllRoles(roles) {
|
|
35
|
+
return roles.every((role) => this.#snapshot.roles.includes(role));
|
|
36
|
+
}
|
|
37
|
+
/** Return true when the principal holds ANY of the given roles. */
|
|
38
|
+
hasAnyRole(roles) {
|
|
39
|
+
return roles.some((role) => this.#snapshot.roles.includes(role));
|
|
40
|
+
}
|
|
41
|
+
/** Return true when the principal holds the given scope. */
|
|
42
|
+
hasScope(scope) {
|
|
43
|
+
return this.#snapshot.scopes.includes(scope);
|
|
44
|
+
}
|
|
45
|
+
/** Return true when the principal holds ALL of the given scopes. */
|
|
46
|
+
hasAllScopes(scopes) {
|
|
47
|
+
return scopes.every((scope) => this.#snapshot.scopes.includes(scope));
|
|
48
|
+
}
|
|
49
|
+
/** Return true when the principal holds ANY of the given scopes. */
|
|
50
|
+
hasAnyScope(scopes) {
|
|
51
|
+
return scopes.some((scope) => this.#snapshot.scopes.includes(scope));
|
|
52
|
+
}
|
|
53
|
+
/** Expose the raw snapshot for direct inspection. */
|
|
54
|
+
get snapshot() {
|
|
55
|
+
return this.#snapshot;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SessionManager — Focused responsibility: session lifecycle.
|
|
3
|
+
*
|
|
4
|
+
* Manages the login/logout lifecycle and ties token persistence to login
|
|
5
|
+
* results. Decoupled from transport and token storage implementations.
|
|
6
|
+
*/
|
|
7
|
+
import type { OperatorSdk } from '../../operator/index.js';
|
|
8
|
+
import type { GoodVibesAuthLoginOptions, GoodVibesCurrentAuth, GoodVibesLoginInput, GoodVibesLoginOutput } from '../../../auth.js';
|
|
9
|
+
import { TokenStore } from './token-store.js';
|
|
10
|
+
export declare class SessionManager {
|
|
11
|
+
#private;
|
|
12
|
+
constructor(operator: OperatorSdk, tokenStore: TokenStore | null);
|
|
13
|
+
/**
|
|
14
|
+
* Return the current auth state from the daemon control plane.
|
|
15
|
+
* Does not require a writable token store.
|
|
16
|
+
*/
|
|
17
|
+
current(): Promise<GoodVibesCurrentAuth>;
|
|
18
|
+
/**
|
|
19
|
+
* Perform a login and, when `persistToken` is not false, automatically
|
|
20
|
+
* persist the returned token into the configured token store.
|
|
21
|
+
*/
|
|
22
|
+
login(input: GoodVibesLoginInput, options?: GoodVibesAuthLoginOptions): Promise<GoodVibesLoginOutput>;
|
|
23
|
+
/**
|
|
24
|
+
* Whether this session manager has a writable token store.
|
|
25
|
+
* Read-only instances (using a raw `getAuthToken` resolver) return false.
|
|
26
|
+
*/
|
|
27
|
+
get writable(): boolean;
|
|
28
|
+
/** Access the underlying TokenStore (null when using a read-only resolver). */
|
|
29
|
+
get tokenStore(): TokenStore | null;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=session-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-manager.d.ts","sourceRoot":"","sources":["../../../../src/_internal/platform/auth/session-manager.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,KAAK,EACV,yBAAyB,EACzB,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,qBAAa,cAAc;;gBAIb,QAAQ,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,GAAG,IAAI;IAKhE;;;OAGG;IACG,OAAO,IAAI,OAAO,CAAC,oBAAoB,CAAC;IAI9C;;;OAGG;IACG,KAAK,CACT,KAAK,EAAE,mBAAmB,EAC1B,OAAO,GAAE,yBAA8B,GACtC,OAAO,CAAC,oBAAoB,CAAC;IAQhC;;;OAGG;IACH,IAAI,QAAQ,IAAI,OAAO,CAEtB;IAED,+EAA+E;IAC/E,IAAI,UAAU,IAAI,UAAU,GAAG,IAAI,CAElC;CACF"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SessionManager — Focused responsibility: session lifecycle.
|
|
3
|
+
*
|
|
4
|
+
* Manages the login/logout lifecycle and ties token persistence to login
|
|
5
|
+
* results. Decoupled from transport and token storage implementations.
|
|
6
|
+
*/
|
|
7
|
+
import { TokenStore } from './token-store.js';
|
|
8
|
+
export class SessionManager {
|
|
9
|
+
#operator;
|
|
10
|
+
#tokenStore;
|
|
11
|
+
constructor(operator, tokenStore) {
|
|
12
|
+
this.#operator = operator;
|
|
13
|
+
this.#tokenStore = tokenStore;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Return the current auth state from the daemon control plane.
|
|
17
|
+
* Does not require a writable token store.
|
|
18
|
+
*/
|
|
19
|
+
async current() {
|
|
20
|
+
return this.#operator.control.auth.current();
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Perform a login and, when `persistToken` is not false, automatically
|
|
24
|
+
* persist the returned token into the configured token store.
|
|
25
|
+
*/
|
|
26
|
+
async login(input, options = {}) {
|
|
27
|
+
const result = await this.#operator.control.auth.login(input);
|
|
28
|
+
if ((options.persistToken ?? true) && this.#tokenStore) {
|
|
29
|
+
await this.#tokenStore.setToken(result.token);
|
|
30
|
+
}
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Whether this session manager has a writable token store.
|
|
35
|
+
* Read-only instances (using a raw `getAuthToken` resolver) return false.
|
|
36
|
+
*/
|
|
37
|
+
get writable() {
|
|
38
|
+
return this.#tokenStore !== null;
|
|
39
|
+
}
|
|
40
|
+
/** Access the underlying TokenStore (null when using a read-only resolver). */
|
|
41
|
+
get tokenStore() {
|
|
42
|
+
return this.#tokenStore;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TokenStore — Focused responsibility: token persistence.
|
|
3
|
+
*
|
|
4
|
+
* Owns all read/write/clear operations on a `GoodVibesTokenStore`. Consumers
|
|
5
|
+
* that only need token storage can interact with this class directly rather
|
|
6
|
+
* than going through the full auth client.
|
|
7
|
+
*/
|
|
8
|
+
import type { GoodVibesTokenStore } from '../../../auth.js';
|
|
9
|
+
export declare class TokenStore {
|
|
10
|
+
#private;
|
|
11
|
+
constructor(store: GoodVibesTokenStore);
|
|
12
|
+
/** Return the current token, or null if none is stored. */
|
|
13
|
+
getToken(): Promise<string | null>;
|
|
14
|
+
/** Persist a new token, or clear storage when null. */
|
|
15
|
+
setToken(token: string | null): Promise<void>;
|
|
16
|
+
/** Clear the stored token. */
|
|
17
|
+
clearToken(): Promise<void>;
|
|
18
|
+
/** Return true when a non-empty token is currently stored. */
|
|
19
|
+
hasToken(): Promise<boolean>;
|
|
20
|
+
/** Expose the underlying store for interop with existing consumers. */
|
|
21
|
+
get store(): GoodVibesTokenStore;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=token-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token-store.d.ts","sourceRoot":"","sources":["../../../../src/_internal/platform/auth/token-store.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAE5D,qBAAa,UAAU;;gBAGT,KAAK,EAAE,mBAAmB;IAItC,2DAA2D;IACrD,QAAQ,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAIxC,uDAAuD;IACjD,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAInD,8BAA8B;IACxB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAIjC,8DAA8D;IACxD,QAAQ,IAAI,OAAO,CAAC,OAAO,CAAC;IAKlC,uEAAuE;IACvE,IAAI,KAAK,IAAI,mBAAmB,CAE/B;CACF"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TokenStore — Focused responsibility: token persistence.
|
|
3
|
+
*
|
|
4
|
+
* Owns all read/write/clear operations on a `GoodVibesTokenStore`. Consumers
|
|
5
|
+
* that only need token storage can interact with this class directly rather
|
|
6
|
+
* than going through the full auth client.
|
|
7
|
+
*/
|
|
8
|
+
export class TokenStore {
|
|
9
|
+
#store;
|
|
10
|
+
constructor(store) {
|
|
11
|
+
this.#store = store;
|
|
12
|
+
}
|
|
13
|
+
/** Return the current token, or null if none is stored. */
|
|
14
|
+
async getToken() {
|
|
15
|
+
return this.#store.getToken();
|
|
16
|
+
}
|
|
17
|
+
/** Persist a new token, or clear storage when null. */
|
|
18
|
+
async setToken(token) {
|
|
19
|
+
return this.#store.setToken(token);
|
|
20
|
+
}
|
|
21
|
+
/** Clear the stored token. */
|
|
22
|
+
async clearToken() {
|
|
23
|
+
return this.#store.clearToken();
|
|
24
|
+
}
|
|
25
|
+
/** Return true when a non-empty token is currently stored. */
|
|
26
|
+
async hasToken() {
|
|
27
|
+
const token = await this.#store.getToken();
|
|
28
|
+
return typeof token === 'string' && token.length > 0;
|
|
29
|
+
}
|
|
30
|
+
/** Expose the underlying store for interop with existing consumers. */
|
|
31
|
+
get store() {
|
|
32
|
+
return this.#store;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -17,18 +17,58 @@ interface HookDispatcherLike {
|
|
|
17
17
|
interface LowPrioritySystemMessageSink {
|
|
18
18
|
low(message: string): void;
|
|
19
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Options for constructing an {@link Orchestrator}.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* const orchestrator = new Orchestrator({
|
|
26
|
+
* conversation,
|
|
27
|
+
* getViewportHeight: () => window.innerHeight,
|
|
28
|
+
* scrollToEnd: (vHeight) => scrollContainer.scrollTo({ top: vHeight }),
|
|
29
|
+
* toolRegistry,
|
|
30
|
+
* permissionManager,
|
|
31
|
+
* getSystemPrompt: () => mySystemPrompt,
|
|
32
|
+
* hookDispatcher,
|
|
33
|
+
* flagManager,
|
|
34
|
+
* requestRender: () => renderFn(),
|
|
35
|
+
* runtimeBus,
|
|
36
|
+
* services: { agentManager, wrfcController },
|
|
37
|
+
* });
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export interface OrchestratorOptions {
|
|
41
|
+
/** Manages the conversation message history. */
|
|
42
|
+
conversation: ConversationManager;
|
|
43
|
+
/** Returns the current viewport height in rows/px for scrolling calculations. */
|
|
44
|
+
getViewportHeight: () => number;
|
|
45
|
+
/** Scrolls the UI to the given viewport height after a turn. */
|
|
46
|
+
scrollToEnd: (vHeight: number) => void;
|
|
47
|
+
/** Registry of all available tools. */
|
|
48
|
+
toolRegistry: ToolRegistry;
|
|
49
|
+
/** Manages tool-use permission grants and denials. */
|
|
50
|
+
permissionManager: PermissionManager;
|
|
51
|
+
/** Returns the current system prompt text. Defaults to `() => ''`. */
|
|
52
|
+
getSystemPrompt?: () => string;
|
|
53
|
+
/** Optional hook dispatcher for lifecycle events. */
|
|
54
|
+
hookDispatcher?: HookDispatcherLike | null;
|
|
55
|
+
/** Optional feature flag manager. */
|
|
56
|
+
flagManager?: FeatureFlagManager | null;
|
|
57
|
+
/** Optional render request callback, called after state changes requiring a redraw. */
|
|
58
|
+
requestRender?: (() => void) | null;
|
|
59
|
+
/** Optional runtime event bus for cross-system event propagation. */
|
|
60
|
+
runtimeBus?: RuntimeEventBus | null;
|
|
61
|
+
/** Required runtime service dependencies. */
|
|
62
|
+
services: {
|
|
63
|
+
readonly agentManager: Pick<AgentManager, 'list' | 'spawn'>;
|
|
64
|
+
readonly wrfcController: Pick<WrfcController, 'listChains'>;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
20
67
|
/**
|
|
21
68
|
* Orchestrator - Manages LLM turn lifecycle with full tool-use loop.
|
|
22
69
|
* Supports multi-turn agent loops: call LLM -> execute tools -> send results -> repeat.
|
|
23
70
|
*/
|
|
24
71
|
export declare class Orchestrator {
|
|
25
|
-
private conversation;
|
|
26
|
-
private getViewportHeight;
|
|
27
|
-
private scrollToEnd;
|
|
28
|
-
private toolRegistry;
|
|
29
|
-
private permissionManager;
|
|
30
|
-
private getSystemPrompt;
|
|
31
|
-
private hookDispatcher;
|
|
32
72
|
isThinking: boolean;
|
|
33
73
|
thinkingFrame: number;
|
|
34
74
|
usage: {
|
|
@@ -113,10 +153,34 @@ export declare class Orchestrator {
|
|
|
113
153
|
private readonly requestRender;
|
|
114
154
|
private systemMessageRouter;
|
|
115
155
|
private readonly followUpRuntime;
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
156
|
+
private conversation;
|
|
157
|
+
private getViewportHeight;
|
|
158
|
+
private scrollToEnd;
|
|
159
|
+
private toolRegistry;
|
|
160
|
+
private permissionManager;
|
|
161
|
+
private getSystemPrompt;
|
|
162
|
+
private hookDispatcher;
|
|
163
|
+
/**
|
|
164
|
+
* Construct an Orchestrator using a named-options object.
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
* ```ts
|
|
168
|
+
* const orchestrator = new Orchestrator({
|
|
169
|
+
* conversation,
|
|
170
|
+
* getViewportHeight: () => terminalRows,
|
|
171
|
+
* scrollToEnd: (vHeight) => ui.scrollToEnd(vHeight),
|
|
172
|
+
* toolRegistry,
|
|
173
|
+
* permissionManager,
|
|
174
|
+
* getSystemPrompt: () => systemPrompt,
|
|
175
|
+
* hookDispatcher,
|
|
176
|
+
* flagManager,
|
|
177
|
+
* requestRender: () => render(),
|
|
178
|
+
* runtimeBus,
|
|
179
|
+
* services: { agentManager, wrfcController },
|
|
180
|
+
* });
|
|
181
|
+
* ```
|
|
182
|
+
*/
|
|
183
|
+
constructor(options: OrchestratorOptions);
|
|
120
184
|
setCoreServices(services: OrchestratorCoreServices): void;
|
|
121
185
|
/**
|
|
122
186
|
* Attach an AcpManager and register the 'delegate' tool into the ToolRegistry.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orchestrator.d.ts","sourceRoot":"","sources":["../../../../src/_internal/platform/core/orchestrator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGzD,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAG7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAQpD,OAAO,EACL,KAAK,wBAAwB,EAC9B,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAK9D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAC9E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAkBlE,OAAO,EASL,KAAK,wBAAwB,EAC9B,MAAM,2BAA2B,CAAC;AAQnC,iFAAiF;AACjF,UAAU,kBAAkB;IAC1B,IAAI,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CAC7C;AAMD,UAAU,4BAA4B;IACpC,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED
|
|
1
|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