@introspection-sdk/introspection-browser 0.5.3 → 0.5.5
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/README.md +45 -33
- package/dist/api/client.d.ts +35 -12
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +81 -17
- package/dist/api/client.js.map +1 -1
- package/dist/api/http.d.ts +23 -0
- package/dist/api/http.d.ts.map +1 -1
- package/dist/api/http.js +38 -0
- package/dist/api/http.js.map +1 -1
- package/dist/api/index.d.ts +13 -12
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +12 -11
- package/dist/api/index.js.map +1 -1
- package/dist/api/runner.d.ts +45 -0
- package/dist/api/runner.d.ts.map +1 -0
- package/dist/api/runner.js +87 -0
- package/dist/api/runner.js.map +1 -0
- package/dist/api/runtimes.d.ts +12 -0
- package/dist/api/runtimes.d.ts.map +1 -0
- package/dist/api/runtimes.js +14 -0
- package/dist/api/runtimes.js.map +1 -0
- package/dist/api/tasks.d.ts +15 -48
- package/dist/api/tasks.d.ts.map +1 -1
- package/dist/api/tasks.js +7 -130
- package/dist/api/tasks.js.map +1 -1
- package/package.json +3 -3
- package/src/api/client.ts +133 -22
- package/src/api/http.ts +56 -0
- package/src/api/index.ts +46 -15
- package/src/api/runner.ts +127 -0
- package/src/api/runtimes.ts +32 -0
- package/src/api/tasks.ts +25 -160
- package/dist/api/conversations.d.ts +0 -84
- package/dist/api/conversations.d.ts.map +0 -1
- package/dist/api/conversations.js +0 -172
- package/dist/api/conversations.js.map +0 -1
- package/dist/api/files.d.ts +0 -61
- package/dist/api/files.d.ts.map +0 -1
- package/dist/api/files.js +0 -145
- package/dist/api/files.js.map +0 -1
- package/src/api/conversations.ts +0 -214
- package/src/api/files.ts +0 -196
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
|
|
2
|
-
> @introspection-sdk/introspection-browser@0.5.
|
|
2
|
+
> @introspection-sdk/introspection-browser@0.5.5 build /home/runner/work/introspection-js-sdk/introspection-js-sdk/packages/introspection-browser
|
|
3
3
|
> tsc
|
|
4
4
|
|
package/README.md
CHANGED
|
@@ -42,28 +42,26 @@ flow (see the [`sample-auth`](../../examples/apps/sample-auth) example):
|
|
|
42
42
|
via RFC 8693 token-exchange of the partner IdP token, a PKCE
|
|
43
43
|
`authorization_code`, or `client_credentials`. The IdP secret never leaves
|
|
44
44
|
the backend.
|
|
45
|
-
2. `
|
|
46
|
-
|
|
47
|
-
3.
|
|
48
|
-
|
|
45
|
+
2. `client.runtimes(name).run()` uses that token at the Control Plane to
|
|
46
|
+
resolve a runtime and mint a short-lived runner token.
|
|
47
|
+
3. The returned runner talks directly to the selected Data Plane endpoint for
|
|
48
|
+
tasks, files, conversations, and shares.
|
|
49
49
|
|
|
50
50
|
```typescript
|
|
51
51
|
import { IntrospectionApiClient } from "@introspection-sdk/introspection-browser/api";
|
|
52
52
|
|
|
53
53
|
const client = new IntrospectionApiClient({
|
|
54
|
-
|
|
55
|
-
projectId: "proj_…",
|
|
54
|
+
cpUrl: "https://api.introspection.dev",
|
|
56
55
|
// your backend returns a fresh Introspection access token
|
|
57
56
|
getToken: () => fetch("/api/introspection/token").then((r) => r.text()),
|
|
58
57
|
});
|
|
59
58
|
|
|
60
|
-
await client.
|
|
59
|
+
const runner = await client.runtimes("support-agent").run({
|
|
60
|
+
identity: { user_id: "u_42" },
|
|
61
|
+
});
|
|
61
62
|
|
|
62
|
-
const run = await
|
|
63
|
+
const run = await runner.tasks.start({
|
|
63
64
|
prompt: "Summarize my latest order",
|
|
64
|
-
agent_name: "support-agent", // or runtime_id: "rt_…"
|
|
65
|
-
identity: { user_id: "u_42" }, // folded into metadata.identity
|
|
66
|
-
visibility: "identity", // sharing scope; defaults by credential
|
|
67
65
|
idle_timeout_seconds: 120, // idle window before the sandbox is torn down
|
|
68
66
|
});
|
|
69
67
|
|
|
@@ -72,48 +70,62 @@ for await (const ev of run.stream()) {
|
|
|
72
70
|
}
|
|
73
71
|
```
|
|
74
72
|
|
|
75
|
-
`
|
|
73
|
+
`runner.tasks` exposes the full CRUD surface (`create` / `start` / `get` /
|
|
76
74
|
`list` / `update` / `delete` / `archive` / `unarchive`) plus per-run streaming
|
|
77
75
|
(`run.stream()`, `run.text()`, `run.cancel()`).
|
|
78
76
|
|
|
79
|
-
|
|
77
|
+
`create` and `start` accept **`idle_timeout_seconds`** (`number`) to override
|
|
78
|
+
the interactive idle window before the sandbox is torn down. `0` tears it down
|
|
79
|
+
as soon as it's provisioned; omit to use the deployment default. Clamped to the
|
|
80
|
+
task timeout.
|
|
81
|
+
|
|
82
|
+
The older cookie-session path is still available for apps that already know a
|
|
83
|
+
Data Plane URL:
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
const client = new IntrospectionApiClient({
|
|
87
|
+
dpUrl: "https://dp.us.introspection.dev",
|
|
88
|
+
getToken: () => fetch("/api/introspection/token").then((r) => r.text()),
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
await client.connect(); // -> intro_dp_session cookie
|
|
92
|
+
await client.tasks.start({
|
|
93
|
+
prompt: "Summarize my latest order",
|
|
94
|
+
runtime_id: "019ed295-5d76-7432-863b-f9327af50221",
|
|
95
|
+
});
|
|
96
|
+
```
|
|
80
97
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
from the session JWT, never the request body.
|
|
85
|
-
- **`idle_timeout_seconds`** (`number`) — overrides the interactive idle window
|
|
86
|
-
before the sandbox is torn down. `0` tears it down as soon as it's
|
|
87
|
-
provisioned; omit to use the deployment default. Clamped to the task timeout.
|
|
98
|
+
For new runtime-backed browser apps, prefer
|
|
99
|
+
`client.runtimes("support-agent").run()` so the browser follows the same
|
|
100
|
+
runtime resolution flow as the Node SDK and does not carry runtime ids.
|
|
88
101
|
|
|
89
102
|
## Files and conversations
|
|
90
103
|
|
|
91
|
-
The same
|
|
92
|
-
`/v1/conversations`
|
|
93
|
-
`connect()`:
|
|
104
|
+
The same runner session also reaches `/v1/files` and (read-only)
|
|
105
|
+
`/v1/conversations` using the CP-minted runner token:
|
|
94
106
|
|
|
95
107
|
```typescript
|
|
96
108
|
// Files — CRUD + upload/download, all identity-scoped
|
|
97
|
-
await
|
|
98
|
-
const page = await
|
|
99
|
-
const bytes = await
|
|
109
|
+
await runner.files.upload({ file: new Blob(["hi"]), name: "hi.txt" });
|
|
110
|
+
const page = await runner.files.list();
|
|
111
|
+
const bytes = await runner.files.download(page.records[0].id);
|
|
100
112
|
|
|
101
113
|
// Conversations — read-only projection over the telemetry store
|
|
102
|
-
for await (const summary of
|
|
114
|
+
for await (const summary of runner.conversations.list()) {
|
|
103
115
|
console.log(summary.conversation_id);
|
|
104
116
|
}
|
|
105
117
|
// Resolve the latest turn of a conversation (Responses-API shape)
|
|
106
|
-
const turn = await
|
|
118
|
+
const turn = await runner.conversations.retrieve(conversationId);
|
|
107
119
|
console.log(turn?.output_messages);
|
|
108
120
|
```
|
|
109
121
|
|
|
110
|
-
`
|
|
122
|
+
`runner.files` mirrors the Node SDK's `FilesApi` (`list` / `upload` /
|
|
111
123
|
`createText` / `get` / `update` / `delete` / `download` / `downloadStream`,
|
|
112
|
-
plus `files.versions`). `
|
|
124
|
+
plus `files.versions`). `runner.conversations` mirrors `ConversationsApi`
|
|
113
125
|
(`list`, `retrieve`, and `conversations.items.list()` / `.get()`). Both `list`
|
|
114
126
|
helpers return a `Paginator` — `await` it for the first page or `for await` it
|
|
115
127
|
to auto-page.
|
|
116
128
|
|
|
117
|
-
> **CORS:** the
|
|
118
|
-
>
|
|
119
|
-
>
|
|
129
|
+
> **CORS:** the Control Plane must allow the SPA origin for runtime resolution,
|
|
130
|
+
> and each selected Data Plane must allow the origin for runner task/file/
|
|
131
|
+
> conversation calls.
|
package/dist/api/client.d.ts
CHANGED
|
@@ -18,18 +18,29 @@
|
|
|
18
18
|
* the client transparently re-runs `getToken` + the DP exchange once
|
|
19
19
|
* before retrying.
|
|
20
20
|
*/
|
|
21
|
+
import { ConversationsClient, FilesClient, SharesClient } from "@introspection-sdk/http";
|
|
21
22
|
import { TasksClient } from "./tasks.js";
|
|
22
|
-
import {
|
|
23
|
-
import { ConversationsClient } from "./conversations.js";
|
|
23
|
+
import { type BrowserRuntimeHandleFactory, type BrowserRuntimesClient } from "./runtimes.js";
|
|
24
24
|
export interface IntrospectionApiClientOptions {
|
|
25
|
-
/**
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Control Plane REST base URL. Used by `client.runtimes(name).run()` to
|
|
27
|
+
* resolve runtimes and mint runner specs. Defaults to
|
|
28
|
+
* `https://api.introspection.dev`.
|
|
29
|
+
*/
|
|
30
|
+
cpUrl?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Data Plane REST base URL for the cookie-session APIs (`connect()` and
|
|
33
|
+
* top-level `client.tasks` / `client.files` / `client.conversations` /
|
|
34
|
+
* `client.shares`). Runner APIs use the DP endpoint returned by CP and do
|
|
35
|
+
* not require this option.
|
|
36
|
+
*/
|
|
37
|
+
dpUrl?: string;
|
|
29
38
|
/**
|
|
30
39
|
* Returns a fresh Introspection access token from the app's broker
|
|
31
40
|
* (its own backend). Called on `connect()` and again whenever the DP
|
|
32
|
-
* session cookie needs re-minting after a 401.
|
|
41
|
+
* session cookie needs re-minting after a 401. The session's project is
|
|
42
|
+
* derived from this token's claims server-side — there is no separate
|
|
43
|
+
* project option.
|
|
33
44
|
*/
|
|
34
45
|
getToken: () => string | Promise<string>;
|
|
35
46
|
/** Custom `fetch` (for tests or non-standard runtimes). */
|
|
@@ -39,14 +50,23 @@ export interface IntrospectionApiClientOptions {
|
|
|
39
50
|
}
|
|
40
51
|
export declare class IntrospectionApiClient {
|
|
41
52
|
private readonly opts;
|
|
53
|
+
/**
|
|
54
|
+
* CRUD on CP `/v1/runtimes` and the `(idOrName) => RuntimeHandle` factory.
|
|
55
|
+
* Call as `client.runtimes("customer-agent").run()`.
|
|
56
|
+
*/
|
|
57
|
+
readonly runtimes: BrowserRuntimesClient & BrowserRuntimeHandleFactory;
|
|
58
|
+
private readonly fetchImpl;
|
|
59
|
+
private readonly cpHttp;
|
|
60
|
+
private readonly cookieClients;
|
|
61
|
+
constructor(opts: IntrospectionApiClientOptions);
|
|
42
62
|
/** `/v1/tasks` operations bound to the DP session cookie. */
|
|
43
|
-
|
|
63
|
+
get tasks(): TasksClient;
|
|
44
64
|
/** `/v1/files` operations bound to the DP session cookie. */
|
|
45
|
-
|
|
65
|
+
get files(): FilesClient;
|
|
46
66
|
/** Read-only `/v1/conversations` projection bound to the session cookie. */
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
67
|
+
get conversations(): ConversationsClient;
|
|
68
|
+
/** `/v1/shares` read-sharing grants bound to the session cookie. */
|
|
69
|
+
get shares(): SharesClient;
|
|
50
70
|
/**
|
|
51
71
|
* Mint a token via `getToken` and redeem it at the DP for the
|
|
52
72
|
* `intro_dp_session` cookie. Call once before issuing task requests.
|
|
@@ -55,5 +75,8 @@ export declare class IntrospectionApiClient {
|
|
|
55
75
|
private exchange;
|
|
56
76
|
/** 401 recovery: re-exchange, reporting success so the call can retry. */
|
|
57
77
|
private reexchange;
|
|
78
|
+
private requireCookieClient;
|
|
79
|
+
private requireDpUrl;
|
|
80
|
+
private requestFreshRunnerSpec;
|
|
58
81
|
}
|
|
59
82
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/api/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAQH,OAAO,EACL,mBAAmB,EACnB,WAAW,EACX,YAAY,EACb,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
|
|
|
18
18
|
* the client transparently re-runs `getToken` + the DP exchange once
|
|
19
19
|
* before retrying.
|
|
20
20
|
*/
|
|
21
|
-
import { BrowserHttpClient, stripTrailingSlash, toApiError } from "./http.js";
|
|
21
|
+
import { BrowserBearerHttpClient, BrowserHttpClient, stripTrailingSlash, toApiError, } from "./http.js";
|
|
22
|
+
import { ConversationsClient, FilesClient, SharesClient, } from "@introspection-sdk/http";
|
|
22
23
|
import { TasksClient } from "./tasks.js";
|
|
23
|
-
import {
|
|
24
|
-
import { ConversationsClient } from "./conversations.js";
|
|
24
|
+
import { attachBrowserRuntimes, } from "./runtimes.js";
|
|
25
25
|
export class IntrospectionApiClient {
|
|
26
26
|
opts;
|
|
27
|
-
/**
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
conversations;
|
|
27
|
+
/**
|
|
28
|
+
* CRUD on CP `/v1/runtimes` and the `(idOrName) => RuntimeHandle` factory.
|
|
29
|
+
* Call as `client.runtimes("customer-agent").run()`.
|
|
30
|
+
*/
|
|
31
|
+
runtimes;
|
|
33
32
|
fetchImpl;
|
|
33
|
+
cpHttp;
|
|
34
|
+
cookieClients;
|
|
34
35
|
constructor(opts) {
|
|
35
36
|
this.opts = opts;
|
|
36
37
|
this.fetchImpl = opts.fetch ?? globalThis.fetch;
|
|
37
38
|
if (!this.fetchImpl) {
|
|
38
39
|
throw new Error("global fetch is unavailable; pass `fetch` or run in a modern browser");
|
|
39
40
|
}
|
|
40
|
-
|
|
41
|
-
apiUrl: opts.
|
|
41
|
+
this.cpHttp = new BrowserBearerHttpClient({
|
|
42
|
+
apiUrl: opts.cpUrl ?? "https://api.introspection.dev",
|
|
43
|
+
token: opts.getToken,
|
|
42
44
|
additionalHeaders: opts.additionalHeaders,
|
|
43
45
|
fetch: opts.fetch,
|
|
44
|
-
onUnauthorized: () => this.reexchange(),
|
|
45
46
|
});
|
|
46
|
-
this.
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
this.runtimes = attachBrowserRuntimes(this.cpHttp, {
|
|
48
|
+
additionalHeaders: opts.additionalHeaders,
|
|
49
|
+
fetch: opts.fetch,
|
|
50
|
+
requestFreshRunnerSpec: (source) => this.requestFreshRunnerSpec(source),
|
|
51
|
+
});
|
|
52
|
+
if (opts.dpUrl) {
|
|
53
|
+
const http = new BrowserHttpClient({
|
|
54
|
+
apiUrl: opts.dpUrl,
|
|
55
|
+
additionalHeaders: opts.additionalHeaders,
|
|
56
|
+
fetch: opts.fetch,
|
|
57
|
+
onUnauthorized: () => this.reexchange(),
|
|
58
|
+
});
|
|
59
|
+
this.cookieClients = {
|
|
60
|
+
tasks: new TasksClient(http),
|
|
61
|
+
files: new FilesClient(http),
|
|
62
|
+
conversations: new ConversationsClient(http),
|
|
63
|
+
shares: new SharesClient(http),
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
this.cookieClients = null;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/** `/v1/tasks` operations bound to the DP session cookie. */
|
|
71
|
+
get tasks() {
|
|
72
|
+
return this.requireCookieClient("tasks");
|
|
73
|
+
}
|
|
74
|
+
/** `/v1/files` operations bound to the DP session cookie. */
|
|
75
|
+
get files() {
|
|
76
|
+
return this.requireCookieClient("files");
|
|
77
|
+
}
|
|
78
|
+
/** Read-only `/v1/conversations` projection bound to the session cookie. */
|
|
79
|
+
get conversations() {
|
|
80
|
+
return this.requireCookieClient("conversations");
|
|
81
|
+
}
|
|
82
|
+
/** `/v1/shares` read-sharing grants bound to the session cookie. */
|
|
83
|
+
get shares() {
|
|
84
|
+
return this.requireCookieClient("shares");
|
|
49
85
|
}
|
|
50
86
|
/**
|
|
51
87
|
* Mint a token via `getToken` and redeem it at the DP for the
|
|
52
88
|
* `intro_dp_session` cookie. Call once before issuing task requests.
|
|
53
89
|
*/
|
|
54
90
|
async connect() {
|
|
91
|
+
this.requireDpUrl();
|
|
55
92
|
await this.exchange();
|
|
56
93
|
}
|
|
57
94
|
async exchange() {
|
|
95
|
+
const dpUrl = this.requireDpUrl();
|
|
58
96
|
const token = await this.opts.getToken();
|
|
59
|
-
const res = await this.fetchImpl(`${stripTrailingSlash(
|
|
97
|
+
const res = await this.fetchImpl(`${stripTrailingSlash(dpUrl)}/v1/oauth/exchange`, {
|
|
60
98
|
method: "POST",
|
|
61
99
|
headers: {
|
|
62
100
|
"Content-Type": "application/json",
|
|
63
101
|
...(this.opts.additionalHeaders ?? {}),
|
|
64
102
|
},
|
|
65
|
-
body: JSON.stringify({ token
|
|
103
|
+
body: JSON.stringify({ token }),
|
|
66
104
|
credentials: "include",
|
|
67
105
|
});
|
|
68
106
|
if (!res.ok)
|
|
@@ -78,5 +116,31 @@ export class IntrospectionApiClient {
|
|
|
78
116
|
return false;
|
|
79
117
|
}
|
|
80
118
|
}
|
|
119
|
+
requireCookieClient(key) {
|
|
120
|
+
if (!this.cookieClients) {
|
|
121
|
+
throw new Error(`IntrospectionApiClient.${key} requires dpUrl; use client.runtimes(...).run() for runner-bound APIs or pass dpUrl for cookie-session APIs`);
|
|
122
|
+
}
|
|
123
|
+
return this.cookieClients[key];
|
|
124
|
+
}
|
|
125
|
+
requireDpUrl() {
|
|
126
|
+
if (!this.opts.dpUrl) {
|
|
127
|
+
throw new Error("IntrospectionApiClient.connect() requires dpUrl; use client.runtimes(...).run() for runner-bound APIs or pass dpUrl for cookie-session APIs");
|
|
128
|
+
}
|
|
129
|
+
return this.opts.dpUrl;
|
|
130
|
+
}
|
|
131
|
+
async requestFreshRunnerSpec(source) {
|
|
132
|
+
if (source.kind === "runtime") {
|
|
133
|
+
return this.cpHttp.request({
|
|
134
|
+
method: "POST",
|
|
135
|
+
path: `/v1/runtimes/${encodeURIComponent(source.id)}/run`,
|
|
136
|
+
body: source.options ?? {},
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
return this.cpHttp.request({
|
|
140
|
+
method: "POST",
|
|
141
|
+
path: `/v1/experiments/${encodeURIComponent(source.id)}/run`,
|
|
142
|
+
body: source.options ?? {},
|
|
143
|
+
});
|
|
144
|
+
}
|
|
81
145
|
}
|
|
82
146
|
//# sourceMappingURL=client.js.map
|
package/dist/api/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EACL,uBAAuB,EACvB,iBAAiB,EACjB,kBAAkB,EAClB,UAAU,GACX,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,mBAAmB,EACnB,WAAW,EACX,YAAY,GACb,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EACL,qBAAqB,GAGtB,MAAM,eAAe,CAAC;AAuCvB,MAAM,OAAO,sBAAsB;IAWJ;IAV7B;;;OAGG;IACM,QAAQ,CAAsD;IAEtD,SAAS,CAAe;IACxB,MAAM,CAA0B;IAChC,aAAa,CAAuB;IAErD,YAA6B,IAAmC;QAAnC,SAAI,GAAJ,IAAI,CAA+B;QAC9D,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,KAAK,IAAI,UAAU,CAAC,KAAK,CAAC;QAChD,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CACb,sEAAsE,CACvE,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,MAAM,GAAG,IAAI,uBAAuB,CAAC;YACxC,MAAM,EAAE,IAAI,CAAC,KAAK,IAAI,+BAA+B;YACrD,KAAK,EAAE,IAAI,CAAC,QAAQ;YACpB,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;YACzC,KAAK,EAAE,IAAI,CAAC,KAAK;SACl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,IAAI,CAAC,KAAK,EAAE,CAAC;YACrB,MAAM,IAAI,KAAK,CACb,6IAA6I,CAC9I,CAAC;QACJ,CAAC;QACD,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;IACzB,CAAC;IAEO,KAAK,CAAC,sBAAsB,CAClC,MAA2B;QAE3B,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;YAC9B,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAa;gBACrC,MAAM,EAAE,MAAM;gBACd,IAAI,EAAE,gBAAgB,kBAAkB,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM;gBACzD,IAAI,EAAE,MAAM,CAAC,OAAO,IAAI,EAAE;aAC3B,CAAC,CAAC;QACL,CAAC;QACD,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAa;YACrC,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,mBAAmB,kBAAkB,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM;YAC5D,IAAI,EAAE,MAAM,CAAC,OAAO,IAAI,EAAE;SAC3B,CAAC,CAAC;IACL,CAAC;CACF"}
|
package/dist/api/http.d.ts
CHANGED
|
@@ -26,6 +26,7 @@ export interface BrowserHttpConfig {
|
|
|
26
26
|
*/
|
|
27
27
|
onUnauthorized?: () => Promise<boolean>;
|
|
28
28
|
}
|
|
29
|
+
export type BrowserApiHttpClient = Pick<BaseHttpClient, "request" | "stream">;
|
|
29
30
|
/**
|
|
30
31
|
* Cookie-authenticated HTTP wrapper bound to one DP endpoint. Has no
|
|
31
32
|
* opinion about which resource it serves — the caller picks the path.
|
|
@@ -33,4 +34,26 @@ export interface BrowserHttpConfig {
|
|
|
33
34
|
export declare class BrowserHttpClient extends BaseHttpClient {
|
|
34
35
|
constructor(cfg: BrowserHttpConfig);
|
|
35
36
|
}
|
|
37
|
+
export interface BrowserBearerHttpConfig {
|
|
38
|
+
/** REST base URL every request is prefixed with. */
|
|
39
|
+
apiUrl: string;
|
|
40
|
+
/** Bearer token, or a provider returning the latest token before each request. */
|
|
41
|
+
token: string | (() => string | Promise<string>);
|
|
42
|
+
/** Extra headers merged into every request. */
|
|
43
|
+
additionalHeaders?: Record<string, string>;
|
|
44
|
+
/** Custom `fetch` (for tests or non-standard runtimes). */
|
|
45
|
+
fetch?: typeof fetch;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Bearer-authenticated browser HTTP wrapper. Used for CP runtime calls with
|
|
49
|
+
* brokered access tokens and for DP runner calls with CP-minted runner tokens.
|
|
50
|
+
*/
|
|
51
|
+
export declare class BrowserBearerHttpClient extends BaseHttpClient {
|
|
52
|
+
private readonly tokenBox;
|
|
53
|
+
private readonly getToken?;
|
|
54
|
+
constructor(cfg: BrowserBearerHttpConfig);
|
|
55
|
+
private refreshToken;
|
|
56
|
+
request<T>(opts: Parameters<BaseHttpClient["request"]>[0]): Promise<T>;
|
|
57
|
+
stream(opts: Parameters<BaseHttpClient["stream"]>[0]): Promise<Response>;
|
|
58
|
+
}
|
|
36
59
|
//# sourceMappingURL=http.d.ts.map
|
package/dist/api/http.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/api/http.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,UAAU,EACX,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,CAAC;AAE1C,MAAM,WAAW,iBAAiB;IAChC,uDAAuD;IACvD,MAAM,EAAE,MAAM,CAAC;IACf,+CAA+C;IAC/C,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3C,2DAA2D;IAC3D,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IACrB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;CAC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,CAAC,CAAiC;gBAE/C,GAAG,EAAE,uBAAuB;YAiB1B,YAAY;IAKpB,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,UAAU,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAKtE,MAAM,CACV,IAAI,EAAE,UAAU,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,GAC5C,OAAO,CAAC,QAAQ,CAAC;CAIrB"}
|
package/dist/api/http.js
CHANGED
|
@@ -31,4 +31,42 @@ export class BrowserHttpClient extends BaseHttpClient {
|
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Bearer-authenticated browser HTTP wrapper. Used for CP runtime calls with
|
|
36
|
+
* brokered access tokens and for DP runner calls with CP-minted runner tokens.
|
|
37
|
+
*/
|
|
38
|
+
export class BrowserBearerHttpClient extends BaseHttpClient {
|
|
39
|
+
tokenBox;
|
|
40
|
+
getToken;
|
|
41
|
+
constructor(cfg) {
|
|
42
|
+
const tokenBox = { value: typeof cfg.token === "string" ? cfg.token : "" };
|
|
43
|
+
super({
|
|
44
|
+
apiUrl: cfg.apiUrl,
|
|
45
|
+
additionalHeaders: cfg.additionalHeaders,
|
|
46
|
+
fetch: cfg.fetch,
|
|
47
|
+
transport: {
|
|
48
|
+
authHeaders: () => {
|
|
49
|
+
if (!tokenBox.value)
|
|
50
|
+
return {};
|
|
51
|
+
return { Authorization: `Bearer ${tokenBox.value}` };
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
this.tokenBox = tokenBox;
|
|
56
|
+
this.getToken = typeof cfg.token === "function" ? cfg.token : undefined;
|
|
57
|
+
}
|
|
58
|
+
async refreshToken() {
|
|
59
|
+
if (!this.getToken)
|
|
60
|
+
return;
|
|
61
|
+
this.tokenBox.value = await this.getToken();
|
|
62
|
+
}
|
|
63
|
+
async request(opts) {
|
|
64
|
+
await this.refreshToken();
|
|
65
|
+
return super.request(opts);
|
|
66
|
+
}
|
|
67
|
+
async stream(opts) {
|
|
68
|
+
await this.refreshToken();
|
|
69
|
+
return super.stream(opts);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
34
72
|
//# sourceMappingURL=http.js.map
|
package/dist/api/http.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../src/api/http.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,UAAU,GACX,MAAM,yBAAyB,CAAC;AAEjC,4EAA4E;AAC5E,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../src/api/http.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,UAAU,GACX,MAAM,yBAAyB,CAAC;AAEjC,4EAA4E;AAC5E,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,CAAC;AAmB1C;;;GAGG;AACH,MAAM,OAAO,iBAAkB,SAAQ,cAAc;IACnD,YAAY,GAAsB;QAChC,KAAK,CAAC;YACJ,MAAM,EAAE,GAAG,CAAC,MAAM;YAClB,iBAAiB,EAAE,GAAG,CAAC,iBAAiB;YACxC,KAAK,EAAE,GAAG,CAAC,KAAK;YAChB,SAAS,EAAE;gBACT,WAAW,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC;gBACvB,WAAW,EAAE,SAAS;gBACtB,cAAc,EAAE,GAAG,CAAC,cAAc;aACnC;SACF,CAAC,CAAC;IACL,CAAC;CACF;AAaD;;;GAGG;AACH,MAAM,OAAO,uBAAwB,SAAQ,cAAc;IACxC,QAAQ,CAAoB;IAC5B,QAAQ,CAAkC;IAE3D,YAAY,GAA4B;QACtC,MAAM,QA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} from "@introspection-sdk/introspection-browser/api";
|
|
12
12
|
*
|
|
13
13
|
* const client = new IntrospectionApiClient({
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* //
|
|
14
|
+
* cpUrl: "https://api.introspection.dev",
|
|
15
|
+
* // your backend mints the Introspection access token (the session's
|
|
16
|
+
* // project is derived from its claims — no projectId option needed)
|
|
17
17
|
* getToken: () => fetch("/api/introspection/token").then((r) => r.text()),
|
|
18
18
|
* });
|
|
19
19
|
*
|
|
20
|
-
* await client.
|
|
21
|
-
* const run = await client.tasks.start({
|
|
22
|
-
* prompt: "Summarize my latest order",
|
|
23
|
-
* agent_name: "support-agent",
|
|
20
|
+
* const runner = await client.runtimes("support-agent").run({
|
|
24
21
|
* identity: { user_id: "u_42" },
|
|
25
22
|
* });
|
|
23
|
+
* const run = await runner.tasks.start({
|
|
24
|
+
* prompt: "Summarize my latest order",
|
|
25
|
+
* });
|
|
26
26
|
* for await (const ev of run.stream()) console.log(ev.event, ev.data);
|
|
27
27
|
* ```
|
|
28
28
|
*/
|
|
29
29
|
export { IntrospectionApiClient, type IntrospectionApiClientOptions, } from "./client.js";
|
|
30
|
+
export { BrowserRunner, Runner, type BrowserRunnerOwner, type BrowserRunnerSource, } from "./runner.js";
|
|
31
|
+
export { BrowserRuntimesClient, BrowserRuntimeHandle, attachBrowserRuntimes, isUuid, type BrowserRuntimeHandleFactory, type BrowserRuntimeRunRequestBody, } from "./runtimes.js";
|
|
30
32
|
export { TasksClient, TaskRunsClient, RunHandle, type CreateTaskParams, type StartTaskParams, } from "./tasks.js";
|
|
31
|
-
export {
|
|
32
|
-
export {
|
|
33
|
-
export { BrowserHttpClient, type BrowserHttpConfig } from "./http.js";
|
|
33
|
+
export { ConversationItemsClient, ConversationsClient, FileVersionsClient, FilesClient, SharesClient, type FileUploadBody, } from "@introspection-sdk/http";
|
|
34
|
+
export { BrowserBearerHttpClient, BrowserHttpClient, type BrowserApiHttpClient, type BrowserBearerHttpConfig, type BrowserHttpConfig, } from "./http.js";
|
|
34
35
|
export { parseSse } from "./sse.js";
|
|
35
36
|
export { Paginator, cursorPaginate, type PageSource, } from "@introspection-sdk/http";
|
|
36
|
-
export type { Task, TaskRun, TaskStatus,
|
|
37
|
-
export { IntrospectionAPIError, AuthenticationError, InsufficientScopeError, NotFoundError, NetworkError, } from "@introspection-sdk/types";
|
|
37
|
+
export type { Task, TaskRun, TaskStatus, TaskCreateResponse, TaskListParams, TaskUpdateParams, TaskRunCreateParams, TaskCancelResponse, RunIdentityInput, Paginated, SseEvent, File, FileType, FileListParams, FileUpdateParams, FileCreateTextParams, ListParams, ConversationSummary, ConversationItem, ConversationItemList, ConversationListParams, ConversationItemListParams, ConversationItemInclude, ConversationResponse, ResourceShare, ShareResourceType, ShareCreateParams, ShareListParams, Recipe, RunRequest, RunnerContext, RunnerDeployment, RunnerSpec, Runtime, RuntimeCreate, RuntimeListParams, RuntimeUpdate, } from "@introspection-sdk/types";
|
|
38
|
+
export { IntrospectionAPIError, AuthenticationError, InsufficientScopeError, NotFoundError, NetworkError, RunnerExpiredError, } from "@introspection-sdk/types";
|
|
38
39
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/api/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EACL,sBAAsB,EACtB,KAAK,6BAA6B,GACnC,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,WAAW,EACX,cAAc,EACd,SAAS,EACT,KAAK,gBAAgB,EACrB,KAAK,eAAe,GACrB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EACL,sBAAsB,EAC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a,GACd,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,sBAAsB,EACtB,aAAa,EACb,YAAY,EACZ,kBAAkB,GACnB,MAAM,0BAA0B,CAAC"}
|
package/dist/api/index.js
CHANGED
|
@@ -11,27 +11,28 @@
|
|
|
11
11
|
* import { IntrospectionApiClient } from "@introspection-sdk/introspection-browser/api";
|
|
12
12
|
*
|
|
13
13
|
* const client = new IntrospectionApiClient({
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* //
|
|
14
|
+
* cpUrl: "https://api.introspection.dev",
|
|
15
|
+
* // your backend mints the Introspection access token (the session's
|
|
16
|
+
* // project is derived from its claims — no projectId option needed)
|
|
17
17
|
* getToken: () => fetch("/api/introspection/token").then((r) => r.text()),
|
|
18
18
|
* });
|
|
19
19
|
*
|
|
20
|
-
* await client.
|
|
21
|
-
* const run = await client.tasks.start({
|
|
22
|
-
* prompt: "Summarize my latest order",
|
|
23
|
-
* agent_name: "support-agent",
|
|
20
|
+
* const runner = await client.runtimes("support-agent").run({
|
|
24
21
|
* identity: { user_id: "u_42" },
|
|
25
22
|
* });
|
|
23
|
+
* const run = await runner.tasks.start({
|
|
24
|
+
* prompt: "Summarize my latest order",
|
|
25
|
+
* });
|
|
26
26
|
* for await (const ev of run.stream()) console.log(ev.event, ev.data);
|
|
27
27
|
* ```
|
|
28
28
|
*/
|
|
29
29
|
export { IntrospectionApiClient, } from "./client.js";
|
|
30
|
+
export { BrowserRunner, Runner, } from "./runner.js";
|
|
31
|
+
export { BrowserRuntimesClient, BrowserRuntimeHandle, attachBrowserRuntimes, isUuid, } from "./runtimes.js";
|
|
30
32
|
export { TasksClient, TaskRunsClient, RunHandle, } from "./tasks.js";
|
|
31
|
-
export {
|
|
32
|
-
export {
|
|
33
|
-
export { BrowserHttpClient } from "./http.js";
|
|
33
|
+
export { ConversationItemsClient, ConversationsClient, FileVersionsClient, FilesClient, SharesClient, } from "@introspection-sdk/http";
|
|
34
|
+
export { BrowserBearerHttpClient, BrowserHttpClient, } from "./http.js";
|
|
34
35
|
export { parseSse } from "./sse.js";
|
|
35
36
|
export { Paginator, cursorPaginate, } from "@introspection-sdk/http";
|
|
36
|
-
export { IntrospectionAPIError, AuthenticationError, InsufficientScopeError, NotFoundError, NetworkError, } from "@introspection-sdk/types";
|
|
37
|
+
export { IntrospectionAPIError, AuthenticationError, InsufficientScopeError, NotFoundError, NetworkError, RunnerExpiredError, } from "@introspection-sdk/types";
|
|
37
38
|
//# sourceMappingURL=index.js.map
|
package/dist/api/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EACL,sBAAsB,GAEvB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EACL,sBAAsB,GAEvB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,aAAa,EACb,MAAM,GAGP,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,EACrB,MAAM,GAGP,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,WAAW,EACX,cAAc,EACd,SAAS,GAGV,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,uBAAuB,EACvB,mBAAmB,EACnB,kBAAkB,EAClB,WAAW,EACX,YAAY,GAEb,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,uBAAuB,EACvB,iBAAiB,GAIlB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EACL,SAAS,EACT,cAAc,GAEf,MAAM,yBAAyB,CAAC;AA0CjC,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,sBAAsB,EACtB,aAAa,EACb,YAAY,EACZ,kBAAkB,GACnB,MAAM,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type RunnerContext, type RunnerDeployment, type RunnerSpec, type RunRequest, type Uuid } from "@introspection-sdk/types";
|
|
2
|
+
import { ConversationsClient, FilesClient, SharesClient, TasksClient } from "@introspection-sdk/http";
|
|
3
|
+
export type BrowserRunnerSource = {
|
|
4
|
+
kind: "runtime";
|
|
5
|
+
id: Uuid;
|
|
6
|
+
options?: RunRequest;
|
|
7
|
+
} | {
|
|
8
|
+
kind: "experiment";
|
|
9
|
+
id: Uuid;
|
|
10
|
+
options?: RunRequest;
|
|
11
|
+
};
|
|
12
|
+
export interface BrowserRunnerOwner {
|
|
13
|
+
readonly additionalHeaders?: Record<string, string>;
|
|
14
|
+
readonly fetch?: typeof fetch;
|
|
15
|
+
requestFreshRunnerSpec(source: BrowserRunnerSource): Promise<RunnerSpec>;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Browser-side live handle to a Data Plane runner. Mirrors the Node Runner
|
|
19
|
+
* shape but uses browser-safe fetch transport and CP-minted bearer tokens.
|
|
20
|
+
*/
|
|
21
|
+
export declare class BrowserRunner {
|
|
22
|
+
private readonly owner;
|
|
23
|
+
private readonly source;
|
|
24
|
+
private spec;
|
|
25
|
+
private http;
|
|
26
|
+
private closed;
|
|
27
|
+
readonly tasks: TasksClient;
|
|
28
|
+
readonly files: FilesClient;
|
|
29
|
+
readonly conversations: ConversationsClient;
|
|
30
|
+
readonly shares: SharesClient;
|
|
31
|
+
constructor(owner: BrowserRunnerOwner, source: BrowserRunnerSource, spec: RunnerSpec);
|
|
32
|
+
get dpEndpoint(): string;
|
|
33
|
+
get deployment(): Readonly<RunnerDeployment>;
|
|
34
|
+
get expires_at(): string;
|
|
35
|
+
get session_id(): string;
|
|
36
|
+
get context(): Readonly<RunnerContext>;
|
|
37
|
+
get isClosed(): boolean;
|
|
38
|
+
refresh(): Promise<void>;
|
|
39
|
+
close(): Promise<void>;
|
|
40
|
+
private buildHttp;
|
|
41
|
+
private guardedHttp;
|
|
42
|
+
private assertOpen;
|
|
43
|
+
}
|
|
44
|
+
export { BrowserRunner as Runner };
|
|
45
|
+
//# sourceMappingURL=runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../src/api/runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,IAAI,EACV,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,mBAAmB,EACnB,WAAW,EACX,YAAY,EACZ,WAAW,EACZ,MAAM,yBAAyB,CAAC;AAGjC,MAAM,MAAM,mBAAmB,GAC3B;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,EAAE,EAAE,IAAI,CAAC;IAAC,OAAO,CAAC,EAAE,UAAU,CAAA;CAAE,GACnD;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,EAAE,EAAE,IAAI,CAAC;IAAC,OAAO,CAAC,EAAE,UAAU,CAAA;CAAE,CAAC;AAE3D,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpD,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IAC9B,sBAAsB,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CAC1E;AAED;;;GAGG;AACH,qBAAa,aAAa;IAWtB,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,MAAM;IAXzB,OAAO,CAAC,IAAI,CAAa;IACzB,OAAO,CAAC,IAAI,CAA0B;IACtC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