@introspection-sdk/introspection-node 0.5.4 → 0.5.6
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/.turbo/turbo-build.log +1 -1
- package/dist/auth.d.ts +127 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +112 -0
- package/dist/auth.js.map +1 -0
- package/dist/client.d.ts +30 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +35 -0
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +4 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -4
- package/dist/index.js.map +1 -1
- package/dist/resources/runtimes.d.ts +4 -74
- package/dist/resources/runtimes.d.ts.map +1 -1
- package/dist/resources/runtimes.js +5 -171
- package/dist/resources/runtimes.js.map +1 -1
- package/dist/runner.d.ts +1 -4
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +1 -4
- package/dist/runner.js.map +1 -1
- package/package.json +7 -7
- package/src/auth.ts +236 -0
- package/src/client.ts +38 -0
- package/src/index.ts +23 -7
- package/src/resources/runtimes.ts +14 -216
- package/src/runner.ts +6 -4
- package/dist/runner-resources/conversations.d.ts +0 -73
- package/dist/runner-resources/conversations.d.ts.map +0 -1
- package/dist/runner-resources/conversations.js +0 -161
- package/dist/runner-resources/conversations.js.map +0 -1
- package/dist/runner-resources/files.d.ts +0 -45
- package/dist/runner-resources/files.d.ts.map +0 -1
- package/dist/runner-resources/files.js +0 -125
- package/dist/runner-resources/files.js.map +0 -1
- package/dist/runner-resources/shares.d.ts +0 -27
- package/dist/runner-resources/shares.d.ts.map +0 -1
- package/dist/runner-resources/shares.js +0 -50
- package/dist/runner-resources/shares.js.map +0 -1
- package/dist/runner-resources/tasks.d.ts +0 -45
- package/dist/runner-resources/tasks.d.ts.map +0 -1
- package/dist/runner-resources/tasks.js +0 -127
- package/dist/runner-resources/tasks.js.map +0 -1
- package/src/runner-resources/conversations.ts +0 -202
- package/src/runner-resources/files.ts +0 -162
- package/src/runner-resources/shares.ts +0 -62
- package/src/runner-resources/tasks.ts +0 -158
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
|
|
2
|
-
> @introspection-sdk/introspection-node@0.5.
|
|
2
|
+
> @introspection-sdk/introspection-node@0.5.6 build /home/runner/work/introspection-js-sdk/introspection-js-sdk/packages/introspection-node
|
|
3
3
|
> tsc
|
|
4
4
|
|
package/dist/auth.d.ts
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CP `POST /v1/oauth/token` response. No refresh token is issued for the
|
|
3
|
+
* machine grants — re-mint when it expires.
|
|
4
|
+
*/
|
|
5
|
+
export interface OAuthToken {
|
|
6
|
+
/** Project-scoped RS256 access token (`Authorization: Bearer …`). */
|
|
7
|
+
access_token: string;
|
|
8
|
+
/** Always `"Bearer"`. */
|
|
9
|
+
token_type: string;
|
|
10
|
+
/** Token lifetime in seconds. */
|
|
11
|
+
expires_in: number;
|
|
12
|
+
/** The granted (scope-capped) scope, when the CP returns one. */
|
|
13
|
+
scope: string | null;
|
|
14
|
+
/**
|
|
15
|
+
* Data Plane API base URL for the token's project, resolved by the CP the
|
|
16
|
+
* same way it is for the CLI login. `null` when the deployment can't be
|
|
17
|
+
* resolved; the caller then needs an explicit DP URL. Hand this to the
|
|
18
|
+
* browser SDK as `dpUrl` so the SPA connects without separate DP config.
|
|
19
|
+
*/
|
|
20
|
+
dp_url: string | null;
|
|
21
|
+
}
|
|
22
|
+
export interface ServiceAccountTokenParams {
|
|
23
|
+
/** Confidential Application client id (`intro_app_…`). */
|
|
24
|
+
clientId: string;
|
|
25
|
+
/** Confidential Application client secret (`intro_sk_…`). */
|
|
26
|
+
clientSecret: string;
|
|
27
|
+
/**
|
|
28
|
+
* Project the token is scoped to. Required by the CP `client_credentials`
|
|
29
|
+
* grant — the minted token is project-scoped and the project must belong to
|
|
30
|
+
* the Application's organization.
|
|
31
|
+
*/
|
|
32
|
+
projectId: string;
|
|
33
|
+
/**
|
|
34
|
+
* Optional space-separated scope. Capped server-side to the Application's
|
|
35
|
+
* `allowed_scopes`; omit to receive the Application's default scope.
|
|
36
|
+
*/
|
|
37
|
+
scope?: string;
|
|
38
|
+
/**
|
|
39
|
+
* CP API base URL. Defaults to `INTROSPECTION_BASE_API_URL` or
|
|
40
|
+
* `https://api.introspection.dev`.
|
|
41
|
+
*/
|
|
42
|
+
baseApiUrl?: string;
|
|
43
|
+
/** Custom `fetch` (for tests or non-standard runtimes). */
|
|
44
|
+
fetch?: typeof fetch;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Back-compat alias: the `client_credentials` response is the same shape as
|
|
48
|
+
* every other `/v1/oauth/token` response.
|
|
49
|
+
*/
|
|
50
|
+
export type ServiceAccountToken = OAuthToken;
|
|
51
|
+
/**
|
|
52
|
+
* Mint a project-scoped CP access token from confidential service-account
|
|
53
|
+
* credentials. See {@link ServiceAccountTokenParams}.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* const { access_token, dp_url } = await serviceAccountToken({
|
|
58
|
+
* clientId: process.env.INTROSPECTION_SERVICE_ACCOUNT_CLIENT_ID!,
|
|
59
|
+
* clientSecret: process.env.INTROSPECTION_SERVICE_ACCOUNT_CLIENT_SECRET!,
|
|
60
|
+
* projectId: process.env.INTRO_PROJECT_ID!,
|
|
61
|
+
* });
|
|
62
|
+
* const client = new IntrospectionClient({ token: access_token });
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
export declare function serviceAccountToken(params: ServiceAccountTokenParams): Promise<OAuthToken>;
|
|
66
|
+
export interface AuthorizationCodeParams {
|
|
67
|
+
/** The authorization code returned to the redirect URI. */
|
|
68
|
+
code: string;
|
|
69
|
+
/** Public SPA Application `client_id` (PKCE — no secret). */
|
|
70
|
+
clientId: string;
|
|
71
|
+
/** The redirect URI the code was issued for (must match the authorize call). */
|
|
72
|
+
redirectUri: string;
|
|
73
|
+
/** The PKCE `code_verifier` paired with the authorize-step challenge. */
|
|
74
|
+
codeVerifier: string;
|
|
75
|
+
/**
|
|
76
|
+
* CP API base URL. Defaults to `INTROSPECTION_BASE_API_URL` or
|
|
77
|
+
* `https://api.introspection.dev`.
|
|
78
|
+
*/
|
|
79
|
+
baseApiUrl?: string;
|
|
80
|
+
/** Custom `fetch` (for tests or non-standard runtimes). */
|
|
81
|
+
fetch?: typeof fetch;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* RFC 6749 / PKCE `authorization_code` exchange against CP
|
|
85
|
+
* `POST /v1/oauth/token`. Run it in your backend so the browser hosted-login
|
|
86
|
+
* flow does not hand-roll the token POST.
|
|
87
|
+
*/
|
|
88
|
+
export declare function authorizationCodeToken(params: AuthorizationCodeParams): Promise<OAuthToken>;
|
|
89
|
+
export interface TokenExchangeParams {
|
|
90
|
+
/** The end user's subject token (e.g. a partner-IdP `id_token`). */
|
|
91
|
+
subjectToken: string;
|
|
92
|
+
/** The federated Application's `client_id` (public client — no secret). */
|
|
93
|
+
clientId: string;
|
|
94
|
+
/** Project the minted DP token is scoped to. */
|
|
95
|
+
projectId: string;
|
|
96
|
+
/**
|
|
97
|
+
* The subject token's type URI. Defaults to
|
|
98
|
+
* `urn:ietf:params:oauth:token-type:id_token`.
|
|
99
|
+
*/
|
|
100
|
+
subjectTokenType?: string;
|
|
101
|
+
/** Optional space-separated scope, capped server-side. */
|
|
102
|
+
scope?: string;
|
|
103
|
+
/**
|
|
104
|
+
* CP API base URL. Defaults to `INTROSPECTION_BASE_API_URL` or
|
|
105
|
+
* `https://api.introspection.dev`.
|
|
106
|
+
*/
|
|
107
|
+
baseApiUrl?: string;
|
|
108
|
+
/** Custom `fetch` (for tests or non-standard runtimes). */
|
|
109
|
+
fetch?: typeof fetch;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* RFC 8693 token-exchange against CP `POST /v1/oauth/token`: trade an end
|
|
113
|
+
* user's partner-IdP token for a project-scoped DP access token for a
|
|
114
|
+
* `member_type=customer` member. Intended to run server-side in a broker (the
|
|
115
|
+
* subject token shouldn't be re-handled in the browser longer than needed).
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* ```typescript
|
|
119
|
+
* const { access_token, dp_url } = await tokenExchange({
|
|
120
|
+
* subjectToken: idTokenFromPartnerIdp,
|
|
121
|
+
* clientId: process.env.FEDERATED_CLIENT_ID!,
|
|
122
|
+
* projectId: process.env.INTRO_PROJECT_ID!,
|
|
123
|
+
* });
|
|
124
|
+
* ```
|
|
125
|
+
*/
|
|
126
|
+
export declare function tokenExchange(params: TokenExchangeParams): Promise<OAuthToken>;
|
|
127
|
+
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAyDA;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,qEAAqE;IACrE,YAAY,EAAE,MAAM,CAAC;IACrB,yBAAyB;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,iCAAiC;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,iEAAiE;IACjE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB;;;;;OAKG;IACH,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAED,MAAM,WAAW,yBAAyB;IACxC,0DAA0D;IAC1D,QAAQ,EAAE,MAAM,CAAC;IACjB,6DAA6D;IAC7D,YAAY,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2DAA2D;IAC3D,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;CACtB;AAED;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG,UAAU,CAAC;AAE7C;;;;;;;;;;;;;GAaG;AACH,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,yBAAyB,GAChC,OAAO,CAAC,UAAU,CAAC,CAarB;AAED,MAAM,WAAW,uBAAuB;IACtC,2DAA2D;IAC3D,IAAI,EAAE,MAAM,CAAC;IACb,6DAA6D;IAC7D,QAAQ,EAAE,MAAM,CAAC;IACjB,gFAAgF;IAChF,WAAW,EAAE,MAAM,CAAC;IACpB,yEAAyE;IACzE,YAAY,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2DAA2D;IAC3D,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;CACtB;AAED;;;;GAIG;AACH,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,uBAAuB,GAC9B,OAAO,CAAC,UAAU,CAAC,CAarB;AAED,MAAM,WAAW,mBAAmB;IAClC,oEAAoE;IACpE,YAAY,EAAE,MAAM,CAAC;IACrB,2EAA2E;IAC3E,QAAQ,EAAE,MAAM,CAAC;IACjB,gDAAgD;IAChD,SAAS,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,0DAA0D;IAC1D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2DAA2D;IAC3D,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;CACtB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,aAAa,CACjC,MAAM,EAAE,mBAAmB,GAC1B,OAAO,CAAC,UAAU,CAAC,CAcrB"}
|
package/dist/auth.js
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Service-account (machine) authentication for the Control Plane.
|
|
3
|
+
*
|
|
4
|
+
* Mints a short-lived, project-scoped Introspection access token via the
|
|
5
|
+
* OAuth 2.0 `client_credentials` grant against CP `POST /v1/oauth/token`.
|
|
6
|
+
* This is the headless / CI counterpart to a long-lived API key: the
|
|
7
|
+
* confidential Application's `client_id` + `client_secret` stay server-side,
|
|
8
|
+
* and you re-mint when the token expires (no refresh token is issued).
|
|
9
|
+
*
|
|
10
|
+
* The minted `access_token` is an ordinary CP bearer token, so it drops
|
|
11
|
+
* straight into the existing client surface — pass it to
|
|
12
|
+
* {@link IntrospectionClient}, or use
|
|
13
|
+
* {@link IntrospectionClient.fromServiceAccount} to mint and construct in one
|
|
14
|
+
* call, and the usual `client.runtimes("name").run()` flow works unchanged.
|
|
15
|
+
*/
|
|
16
|
+
import { stripTrailingSlash, toApiError } from "@introspection-sdk/http";
|
|
17
|
+
const DEFAULT_BASE_API_URL = "https://api.introspection.dev";
|
|
18
|
+
const GRANT_TYPE_CLIENT_CREDENTIALS = "client_credentials";
|
|
19
|
+
const GRANT_TYPE_TOKEN_EXCHANGE = "urn:ietf:params:oauth:grant-type:token-exchange";
|
|
20
|
+
const GRANT_TYPE_AUTHORIZATION_CODE = "authorization_code";
|
|
21
|
+
const SUBJECT_TOKEN_TYPE_ID_TOKEN = "urn:ietf:params:oauth:token-type:id_token";
|
|
22
|
+
function resolveBaseApiUrl(baseApiUrl) {
|
|
23
|
+
return stripTrailingSlash(baseApiUrl ??
|
|
24
|
+
process.env.INTROSPECTION_BASE_API_URL ??
|
|
25
|
+
DEFAULT_BASE_API_URL);
|
|
26
|
+
}
|
|
27
|
+
function resolveFetch(custom) {
|
|
28
|
+
const fetchImpl = custom ?? globalThis.fetch;
|
|
29
|
+
if (!fetchImpl) {
|
|
30
|
+
throw new Error("global fetch is unavailable; pass `fetch` or run on Node 18+");
|
|
31
|
+
}
|
|
32
|
+
return fetchImpl;
|
|
33
|
+
}
|
|
34
|
+
async function postTokenForm(baseApiUrl, form, fetchImpl) {
|
|
35
|
+
const res = await fetchImpl(`${baseApiUrl}/v1/oauth/token`, {
|
|
36
|
+
method: "POST",
|
|
37
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
38
|
+
body: form.toString(),
|
|
39
|
+
cache: "no-store",
|
|
40
|
+
});
|
|
41
|
+
if (!res.ok)
|
|
42
|
+
throw await toApiError(res);
|
|
43
|
+
return (await res.json());
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Mint a project-scoped CP access token from confidential service-account
|
|
47
|
+
* credentials. See {@link ServiceAccountTokenParams}.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```typescript
|
|
51
|
+
* const { access_token, dp_url } = await serviceAccountToken({
|
|
52
|
+
* clientId: process.env.INTROSPECTION_SERVICE_ACCOUNT_CLIENT_ID!,
|
|
53
|
+
* clientSecret: process.env.INTROSPECTION_SERVICE_ACCOUNT_CLIENT_SECRET!,
|
|
54
|
+
* projectId: process.env.INTRO_PROJECT_ID!,
|
|
55
|
+
* });
|
|
56
|
+
* const client = new IntrospectionClient({ token: access_token });
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export async function serviceAccountToken(params) {
|
|
60
|
+
const form = new URLSearchParams({
|
|
61
|
+
grant_type: GRANT_TYPE_CLIENT_CREDENTIALS,
|
|
62
|
+
client_id: params.clientId,
|
|
63
|
+
client_secret: params.clientSecret,
|
|
64
|
+
project_id: params.projectId,
|
|
65
|
+
});
|
|
66
|
+
if (params.scope)
|
|
67
|
+
form.set("scope", params.scope);
|
|
68
|
+
return postTokenForm(resolveBaseApiUrl(params.baseApiUrl), form, resolveFetch(params.fetch));
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* RFC 6749 / PKCE `authorization_code` exchange against CP
|
|
72
|
+
* `POST /v1/oauth/token`. Run it in your backend so the browser hosted-login
|
|
73
|
+
* flow does not hand-roll the token POST.
|
|
74
|
+
*/
|
|
75
|
+
export async function authorizationCodeToken(params) {
|
|
76
|
+
const form = new URLSearchParams({
|
|
77
|
+
grant_type: GRANT_TYPE_AUTHORIZATION_CODE,
|
|
78
|
+
code: params.code,
|
|
79
|
+
client_id: params.clientId,
|
|
80
|
+
redirect_uri: params.redirectUri,
|
|
81
|
+
code_verifier: params.codeVerifier,
|
|
82
|
+
});
|
|
83
|
+
return postTokenForm(resolveBaseApiUrl(params.baseApiUrl), form, resolveFetch(params.fetch));
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* RFC 8693 token-exchange against CP `POST /v1/oauth/token`: trade an end
|
|
87
|
+
* user's partner-IdP token for a project-scoped DP access token for a
|
|
88
|
+
* `member_type=customer` member. Intended to run server-side in a broker (the
|
|
89
|
+
* subject token shouldn't be re-handled in the browser longer than needed).
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```typescript
|
|
93
|
+
* const { access_token, dp_url } = await tokenExchange({
|
|
94
|
+
* subjectToken: idTokenFromPartnerIdp,
|
|
95
|
+
* clientId: process.env.FEDERATED_CLIENT_ID!,
|
|
96
|
+
* projectId: process.env.INTRO_PROJECT_ID!,
|
|
97
|
+
* });
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
export async function tokenExchange(params) {
|
|
101
|
+
const form = new URLSearchParams({
|
|
102
|
+
grant_type: GRANT_TYPE_TOKEN_EXCHANGE,
|
|
103
|
+
subject_token: params.subjectToken,
|
|
104
|
+
subject_token_type: params.subjectTokenType ?? SUBJECT_TOKEN_TYPE_ID_TOKEN,
|
|
105
|
+
client_id: params.clientId,
|
|
106
|
+
project_id: params.projectId,
|
|
107
|
+
});
|
|
108
|
+
if (params.scope)
|
|
109
|
+
form.set("scope", params.scope);
|
|
110
|
+
return postTokenForm(resolveBaseApiUrl(params.baseApiUrl), form, resolveFetch(params.fetch));
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=auth.js.map
|
package/dist/auth.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EA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KAAK,CAAC,CAAC;IAClD,OAAO,aAAa,CAClB,iBAAiB,CAAC,MAAM,CAAC,UAAU,CAAC,EACpC,IAAI,EACJ,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC,CAC3B,CAAC;AACJ,CAAC"}
|
package/dist/client.d.ts
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
*/
|
|
14
14
|
import type { AdvancedOptions } from "@introspection-sdk/types";
|
|
15
15
|
import type { IntrospectionClientOptions } from "./types.js";
|
|
16
|
+
import { type ServiceAccountTokenParams } from "./auth.js";
|
|
16
17
|
import { HttpClient } from "./http.js";
|
|
17
18
|
import { type RuntimeHandleFactory, type RuntimesApi } from "./resources/runtimes.js";
|
|
18
19
|
import { type ExperimentHandleFactory, type ExperimentsApi } from "./resources/experiments.js";
|
|
@@ -60,6 +61,35 @@ export declare class IntrospectionClient {
|
|
|
60
61
|
*/
|
|
61
62
|
readonly recipes: RecipesApi;
|
|
62
63
|
constructor(options?: IntrospectionClientOptions);
|
|
64
|
+
/**
|
|
65
|
+
* Authenticate as a confidential service account and return a ready
|
|
66
|
+
* client.
|
|
67
|
+
*
|
|
68
|
+
* Mints a short-lived, project-scoped CP access token via the
|
|
69
|
+
* `client_credentials` grant (see {@link serviceAccountToken}) and wires
|
|
70
|
+
* it in as the bearer token, so the runtime flow works exactly as it does
|
|
71
|
+
* with an API key:
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```typescript
|
|
75
|
+
* const client = await IntrospectionClient.fromServiceAccount({
|
|
76
|
+
* clientId: process.env.INTROSPECTION_SERVICE_ACCOUNT_CLIENT_ID!,
|
|
77
|
+
* clientSecret: process.env.INTROSPECTION_SERVICE_ACCOUNT_CLIENT_SECRET!,
|
|
78
|
+
* projectId: process.env.INTRO_PROJECT_ID!,
|
|
79
|
+
* });
|
|
80
|
+
*
|
|
81
|
+
* // Resolved fresh from the runtime name on every call.
|
|
82
|
+
* const runner = await client.runtimes("customer-agent").run({
|
|
83
|
+
* identity: { user_id: "u_demo" },
|
|
84
|
+
* });
|
|
85
|
+
* ```
|
|
86
|
+
*
|
|
87
|
+
* The token is not auto-refreshed: it lives for `expires_in` seconds, so
|
|
88
|
+
* re-mint (call this again) for long-lived processes once it lapses.
|
|
89
|
+
*/
|
|
90
|
+
static fromServiceAccount(params: ServiceAccountTokenParams & {
|
|
91
|
+
serviceName?: string;
|
|
92
|
+
}): Promise<IntrospectionClient>;
|
|
63
93
|
/** Close the underlying HTTP client. */
|
|
64
94
|
shutdown(): Promise<void>;
|
|
65
95
|
}
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAEhE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAEL,KAAK,oBAAoB,EACzB,KAAK,WAAW,EACjB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAEL,KAAK,uBAAuB,EAC5B,KAAK,cAAc,EACpB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAiB,KAAK,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAExE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,mBAAmB;IAC9B,2EAA2E;IAC3E,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B,mFAAmF;IACnF,QAAQ,CAAC,eAAe,EAAE,eAAe,CAAC;IAE1C;;;;;OAKG;IACH,QAAQ,CAAC,QAAQ,EAAE,WAAW,GAAG,oBAAoB,CAAC;IAEtD;;OAEG;IACH,QAAQ,CAAC,WAAW,EAAE,cAAc,GAAG,uBAAuB,CAAC;IAE/D;;;;OAIG;IACH,QAAQ,CAAC,OAAO,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wCAAwC;IAClC,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAKhC"}
|
package/dist/client.js
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
* `@introspection-sdk/introspection-node/otel`.
|
|
13
13
|
*/
|
|
14
14
|
import { logger as sdkLogger } from "./utils.js";
|
|
15
|
+
import { serviceAccountToken } from "./auth.js";
|
|
15
16
|
import { HttpClient } from "./http.js";
|
|
16
17
|
import { attachRuntimes, } from "./resources/runtimes.js";
|
|
17
18
|
import { attachExperiments, } from "./resources/experiments.js";
|
|
@@ -82,6 +83,40 @@ export class IntrospectionClient {
|
|
|
82
83
|
this.recipes = attachRecipes(this.cpHttp);
|
|
83
84
|
sdkLogger.info(`IntrospectionClient initialized: api=${baseApiUrl}`);
|
|
84
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* Authenticate as a confidential service account and return a ready
|
|
88
|
+
* client.
|
|
89
|
+
*
|
|
90
|
+
* Mints a short-lived, project-scoped CP access token via the
|
|
91
|
+
* `client_credentials` grant (see {@link serviceAccountToken}) and wires
|
|
92
|
+
* it in as the bearer token, so the runtime flow works exactly as it does
|
|
93
|
+
* with an API key:
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ```typescript
|
|
97
|
+
* const client = await IntrospectionClient.fromServiceAccount({
|
|
98
|
+
* clientId: process.env.INTROSPECTION_SERVICE_ACCOUNT_CLIENT_ID!,
|
|
99
|
+
* clientSecret: process.env.INTROSPECTION_SERVICE_ACCOUNT_CLIENT_SECRET!,
|
|
100
|
+
* projectId: process.env.INTRO_PROJECT_ID!,
|
|
101
|
+
* });
|
|
102
|
+
*
|
|
103
|
+
* // Resolved fresh from the runtime name on every call.
|
|
104
|
+
* const runner = await client.runtimes("customer-agent").run({
|
|
105
|
+
* identity: { user_id: "u_demo" },
|
|
106
|
+
* });
|
|
107
|
+
* ```
|
|
108
|
+
*
|
|
109
|
+
* The token is not auto-refreshed: it lives for `expires_in` seconds, so
|
|
110
|
+
* re-mint (call this again) for long-lived processes once it lapses.
|
|
111
|
+
*/
|
|
112
|
+
static async fromServiceAccount(params) {
|
|
113
|
+
const { access_token } = await serviceAccountToken(params);
|
|
114
|
+
return new IntrospectionClient({
|
|
115
|
+
token: access_token,
|
|
116
|
+
serviceName: params.serviceName,
|
|
117
|
+
advanced: { baseApiUrl: params.baseApiUrl, fetch: params.fetch },
|
|
118
|
+
});
|
|
119
|
+
}
|
|
85
120
|
/** Close the underlying HTTP client. */
|
|
86
121
|
async shutdown() {
|
|
87
122
|
// HttpClient has no persistent connections to close, but reserved
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAE,MAAM,IAAI,SAAS,EAAE,MAAM,YAAY,CAAC;AAEjD,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EACL,cAAc,GAGf,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,iBAAiB,GAGlB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,aAAa,EAAmB,MAAM,wBAAwB,CAAC;AAExE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,OAAO,mBAAmB;IAC9B,2EAA2E;IAClE,MAAM,CAAa;IAC5B,mFAAmF;IAC1E,eAAe,CAAkB;IAE1C;;;;;OAKG;IACM,QAAQ,CAAqC;IAEtD;;OAEG;IACM,WAAW,CAA2C;IAE/D;;;;OAIG;IACM,OAAO,CAAa;IAE7B,YAAY,UAAsC,EAAE;QAClD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,GAAG,CAAC,mBAAmB,IAAI,EAAE,CAAC;QACrE,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,EAAE,CAAC;QACxC,IAAI,CAAC,eAAe,GAAG,QAAQ,CAAC;QAChC,M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EAAE,CAAC,CAAC;IACvE,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,MAAM,CAAC,KAAK,CAAC,kBAAkB,CAC7B,MAA4D;QAE5D,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,mBAAmB,CAAC,MAAM,CAAC,CAAC;QAC3D,OAAO,IAAI,mBAAmB,CAAC;YAC7B,KAAK,EAAE,YAAY;YACnB,WAAW,EAAE,MAAM,CAAC,WAAW;YAC/B,QAAQ,EAAE,EAAE,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE;SACjE,CAAC,CAAC;IACL,CAAC;IAED,wCAAwC;IACxC,KAAK,CAAC,QAAQ;QACZ,kEAAkE;QAClE,gDAAgD;QAChD,SAAS,CAAC,KAAK,CAAC,uCAAuC,CAAC,CAAC;IAC3D,CAAC;CACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -9,13 +9,11 @@
|
|
|
9
9
|
* from `@introspection-sdk/introspection-node/otel`.
|
|
10
10
|
*/
|
|
11
11
|
export { IntrospectionClient } from "./client.js";
|
|
12
|
+
export { serviceAccountToken, tokenExchange, authorizationCodeToken, } from "./auth.js";
|
|
13
|
+
export type { ServiceAccountTokenParams, ServiceAccountToken, TokenExchangeParams, AuthorizationCodeParams, OAuthToken, } from "./auth.js";
|
|
12
14
|
export type { AdvancedOptions, IntrospectionClientOptions, FeedbackOptions, UserTraits, } from "./types.js";
|
|
13
|
-
export {
|
|
14
|
-
export type { StartParams } from "
|
|
15
|
-
export { FilesApi, FileVersionsApi } from "./runner-resources/files.js";
|
|
16
|
-
export type { FileUploadBody } from "./runner-resources/files.js";
|
|
17
|
-
export { ConversationsApi, ConversationItemsApi, } from "./runner-resources/conversations.js";
|
|
18
|
-
export { SharesApi } from "./runner-resources/shares.js";
|
|
15
|
+
export { ConversationItemsApi, ConversationsApi, FileVersionsApi, FilesApi, RunHandle, SharesApi, TaskRunsApi, TasksApi, } from "@introspection-sdk/http";
|
|
16
|
+
export type { FileUploadBody, StartParams } from "@introspection-sdk/http";
|
|
19
17
|
export { HttpClient } from "./http.js";
|
|
20
18
|
export type { ResolvedApiConfig } from "./http.js";
|
|
21
19
|
export { parseSse } from "./streaming.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAGlD,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAGlD,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,sBAAsB,GACvB,MAAM,WAAW,CAAC;AACnB,YAAY,EACV,yBAAyB,EACzB,mBAAmB,EACnB,mBAAmB,EACnB,uBAAuB,EACvB,UAAU,GACX,MAAM,WAAW,CAAC;AAGnB,YAAY,EACV,eAAe,EACf,0BAA0B,EAC1B,eAAe,EACf,UAAU,GACX,MAAM,YAAY,CAAC;AAIpB,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EAChB,eAAe,EACf,QAAQ,EACR,SAAS,EACT,SAAS,EACT,WAAW,EACX,QAAQ,GACT,MAAM,yBAAyB,CAAC;AACjC,YAAY,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,YAAY,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAG1C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAC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Aa,EACb,aAAa,EACb,eAAe,EACf,cAAc,EACd,uBAAuB,EACvB,WAAW,EACX,YAAY,EACZ,oBAAoB,GACrB,MAAM,0BAA0B,CAAC;AAGlC,YAAY,EACV,eAAe,EACf,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,cAAc,EACd,QAAQ,EACR,mBAAmB,EACnB,oBAAoB,EACpB,cAAc,EACd,YAAY,EACZ,cAAc,EACd,WAAW,GACZ,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAGxD,OAAO,EACL,+BAA+B,EAC/B,gCAAgC,EAChC,8BAA8B,EAC9B,qCAAqC,GACtC,MAAM,wBAAwB,CAAC;AAChC,YAAY,EACV,iBAAiB,EACjB,kBAAkB,EAClB,YAAY,EACZ,aAAa,EACb,QAAQ,IAAI,cAAc,GAC3B,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EACL,oCAAoC,EACpC,uCAAuC,EACvC,uCAAuC,EACvC,mCAAmC,GACpC,MAAM,wBAAwB,CAAC;AAChC,YAAY,EACV,eAAe,EACf,aAAa,EACb,yBAAyB,EACzB,UAAU,EACV,UAAU,GACX,MAAM,wBAAwB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -10,12 +10,11 @@
|
|
|
10
10
|
*/
|
|
11
11
|
// REST client.
|
|
12
12
|
export { IntrospectionClient } from "./client.js";
|
|
13
|
+
// Machine / federated / hosted-login OAuth token helpers.
|
|
14
|
+
export { serviceAccountToken, tokenExchange, authorizationCodeToken, } from "./auth.js";
|
|
13
15
|
// Runner-bound REST namespaces (runner.tasks, runner.files,
|
|
14
16
|
// runner.conversations) + HTTP/SSE.
|
|
15
|
-
export {
|
|
16
|
-
export { FilesApi, FileVersionsApi } from "./runner-resources/files.js";
|
|
17
|
-
export { ConversationsApi, ConversationItemsApi, } from "./runner-resources/conversations.js";
|
|
18
|
-
export { SharesApi } from "./runner-resources/shares.js";
|
|
17
|
+
export { ConversationItemsApi, ConversationsApi, FileVersionsApi, FilesApi, RunHandle, SharesApi, TaskRunsApi, TasksApi, } from "@introspection-sdk/http";
|
|
19
18
|
export { HttpClient } from "./http.js";
|
|
20
19
|
export { parseSse } from "./streaming.js";
|
|
21
20
|
// Runner + CP resources.
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,eAAe;AACf,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,eAAe;AACf,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAElD,0DAA0D;AAC1D,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,sBAAsB,GACvB,MAAM,WAAW,CAAC;AAiBnB,4DAA4D;AAC5D,oCAAoC;AACpC,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EAChB,eAAe,EACf,QAAQ,EACR,SAAS,EACT,SAAS,EACT,WAAW,EACX,QAAQ,GACT,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,yBAAyB;AACzB,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EACL,WAAW,EACX,aAAa,EACb,cAAc,EACd,MAAM,GACP,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAgEnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,sBAAsB,EACtB,kBAAkB,EAClB,aAAa,EACb,aAAa,EACb,eAAe,EACf,cAAc,EACd,uBAAuB,EACvB,WAAW,EACX,YAAY,EACZ,oBAAoB,GACrB,MAAM,0BAA0B,CAAC;AAiBlC,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAExD,kEAAkE;AAClE,OAAO,EACL,+BAA+B,EAC/B,gCAAgC,EAChC,8BAA8B,EAC9B,qCAAqC,GACtC,MAAM,wBAAwB,CAAC;AAShC,2DAA2D;AAC3D,OAAO,EACL,oCAAoC,EACpC,uCAAuC,EACvC,uCAAuC,EACvC,mCAAmC,GACpC,MAAM,wBAAwB,CAAC"}
|
|
@@ -1,82 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { RuntimeHandle, RuntimesClient, isUuid, type RuntimeHandleFactory as SharedRuntimeHandleFactory } from "@introspection-sdk/http";
|
|
2
2
|
import type { HttpClient } from "../http.js";
|
|
3
3
|
import type { IntrospectionClient } from "../client.js";
|
|
4
|
-
import { Paginator } from "../pagination.js";
|
|
5
4
|
import { Runner } from "../runner.js";
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
identity?: {
|
|
9
|
-
user_id?: string;
|
|
10
|
-
anonymous_id?: string;
|
|
11
|
-
conversation_id?: string;
|
|
12
|
-
};
|
|
13
|
-
ttl_seconds?: number;
|
|
14
|
-
recipe_id?: Uuid;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Programmatic CRUD for `/v1/runtimes` on the CP. Mounted on the
|
|
18
|
-
* IntrospectionClient as a callable hybrid (see `RuntimeHandleFactory`).
|
|
19
|
-
*/
|
|
20
|
-
export declare class RuntimesApi {
|
|
21
|
-
private readonly http;
|
|
5
|
+
export { RuntimeHandle, isUuid };
|
|
6
|
+
export declare class RuntimesApi extends RuntimesClient<Runner> {
|
|
22
7
|
private readonly client;
|
|
23
8
|
constructor(http: HttpClient, client: IntrospectionClient);
|
|
24
|
-
/**
|
|
25
|
-
* List runtimes matching `params`. `await` the result for the first
|
|
26
|
-
* page, or `for await` it to stream every runtime across pages (fetched
|
|
27
|
-
* lazily — `limit` sets the page size, `next` the starting cursor; stop
|
|
28
|
-
* early to stop fetching).
|
|
29
|
-
*/
|
|
30
|
-
list(params: RuntimeListParams): Paginator<Runtime>;
|
|
31
|
-
get(id: Uuid, params: {
|
|
32
|
-
project_id?: Uuid;
|
|
33
|
-
}): Promise<Runtime>;
|
|
34
|
-
create(input: RuntimeCreate): Promise<Runtime>;
|
|
35
|
-
update(id: Uuid, input: RuntimeUpdate): Promise<Runtime>;
|
|
36
|
-
delete(id: Uuid): Promise<void>;
|
|
37
|
-
/** Resolve a name to a runtime by querying `/v1/runtimes?name=…`. */
|
|
38
|
-
resolveByName(name: string, projectId?: Uuid): Promise<Runtime>;
|
|
39
|
-
/** POST `/v1/runtimes/{id}/run` and wrap the result in a `Runner`. */
|
|
40
|
-
runById(id: Uuid, opts?: RunRequest): Promise<Runner>;
|
|
41
|
-
activateById(id: Uuid, params?: {
|
|
42
|
-
project_id?: Uuid;
|
|
43
|
-
}): Promise<Runtime>;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Handle returned by `client.runtimes(idOrName)`. Resolves the underlying
|
|
47
|
-
* runtime id lazily — if you pass a UUID, no extra lookup happens; if you
|
|
48
|
-
* pass a name, the first call that needs the id will hit
|
|
49
|
-
* `/v1/runtimes?name=…`.
|
|
50
|
-
*/
|
|
51
|
-
export declare class RuntimeHandle {
|
|
52
|
-
private readonly api;
|
|
53
|
-
private readonly client;
|
|
54
|
-
private readonly idOrName;
|
|
55
|
-
private resolvedId;
|
|
56
|
-
private readonly pinnedRecipeId;
|
|
57
|
-
constructor(api: RuntimesApi, client: IntrospectionClient, idOrName: string, pinnedRecipeId?: Uuid | null);
|
|
58
|
-
private resolveId;
|
|
59
|
-
/**
|
|
60
|
-
* Pin to a specific recipe — canary a previous version. Subsequent
|
|
61
|
-
* `.run()` calls on the returned handle open a runner against the
|
|
62
|
-
* runtime row in this name whose `recipe_id` matches `recipe.id`
|
|
63
|
-
* (resolved server-side by CP).
|
|
64
|
-
*
|
|
65
|
-
* Returns a new child {@link RuntimeHandle}; the original handle is
|
|
66
|
-
* unaffected. Accepts a {@link Recipe} object (uses `.id`) or a
|
|
67
|
-
* recipe id string.
|
|
68
|
-
*/
|
|
69
|
-
pin(recipe: Recipe | string): RuntimeHandle;
|
|
70
|
-
run(opts?: RunRequest): Promise<Runner>;
|
|
71
|
-
activate(params?: {
|
|
72
|
-
projectId?: Uuid;
|
|
73
|
-
}): Promise<Runtime>;
|
|
74
9
|
}
|
|
75
|
-
|
|
76
|
-
* Callable hybrid: `client.runtimes` exposes the CRUD methods of
|
|
77
|
-
* `RuntimesApi` AND can be invoked as a function returning a
|
|
78
|
-
* `RuntimeHandle`. Realised by `attachRuntimes` below.
|
|
79
|
-
*/
|
|
80
|
-
export type RuntimeHandleFactory = (idOrName: string) => RuntimeHandle;
|
|
10
|
+
export type RuntimeHandleFactory = SharedRuntimeHandleFactory<Runner>;
|
|
81
11
|
export declare function attachRuntimes(client: IntrospectionClient, http: HttpClient): RuntimesApi & RuntimeHandleFactory;
|
|
82
12
|
//# sourceMappingURL=runtimes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtimes.d.ts","sourceRoot":"","sources":["../../src/resources/runtimes.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"runtimes.d.ts","sourceRoot":"","sources":["../../src/resources/runtimes.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,cAAc,EAEd,MAAM,EACN,KAAK,oBAAoB,IAAI,0BAA0B,EACxD,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,CAAC;AAEjC,qBAAa,WAAY,SAAQ,cAAc,CAAC,MAAM,CAAC;IAGnD,OAAO,CAAC,QAAQ,CAAC,MAAM;gBADvB,IAAI,EAAE,UAAU,EACC,MAAM,EAAE,mBAAmB;CAI/C;AAED,MAAM,MAAM,oBAAoB,GAAG,0BAA0B,CAAC,MAAM,CAAC,CAAC;AAEtE,wBAAgB,cAAc,CAC5B,MAAM,EAAE,mBAAmB,EAC3B,IAAI,EAAE,UAAU,GACf,WAAW,GAAG,oBAAoB,CAGpC"}
|