@introspection-sdk/introspection-browser 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/README.md +34 -29
- package/dist/api/client.d.ts +25 -17
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +39 -22
- package/dist/api/client.js.map +1 -1
- package/dist/api/index.d.ts +17 -11
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +17 -11
- package/dist/api/index.js.map +1 -1
- package/dist/api/tasks.d.ts +8 -47
- 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 +59 -24
- package/src/api/index.ts +21 -14
- package/src/api/tasks.ts +18 -158
- 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 -141
- package/dist/api/files.js.map +0 -1
- package/dist/api/shares.d.ts +0 -29
- package/dist/api/shares.d.ts.map +0 -1
- package/dist/api/shares.js +0 -52
- package/dist/api/shares.js.map +0 -1
- package/src/api/conversations.ts +0 -214
- package/src/api/files.ts +0 -179
- package/src/api/shares.ts +0 -65
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.6 build /home/runner/work/introspection-js-sdk/introspection-js-sdk/packages/introspection-browser
|
|
3
3
|
> tsc
|
|
4
4
|
|
package/README.md
CHANGED
|
@@ -38,32 +38,42 @@ single-page app **create and stream Introspection tasks directly from the
|
|
|
38
38
|
browser, with no API key in JavaScript**. Authentication is the standard B2B2C
|
|
39
39
|
flow (see the [`sample-auth`](../../examples/apps/sample-auth) example):
|
|
40
40
|
|
|
41
|
+
**The browser talks only to the Data Plane.** Runtime resolution is a Control
|
|
42
|
+
Plane call and stays on your backend, so the CP never has to serve CORS to
|
|
43
|
+
customer web origins.
|
|
44
|
+
|
|
41
45
|
1. The app's **own backend ("broker")** mints an Introspection access token —
|
|
42
46
|
via RFC 8693 token-exchange of the partner IdP token, a PKCE
|
|
43
47
|
`authorization_code`, or `client_credentials`. The IdP secret never leaves
|
|
44
|
-
the backend.
|
|
45
|
-
|
|
46
|
-
(`
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
the backend. The backend returns **`{ token, runtimeId, dpUrl }`**: it
|
|
49
|
+
resolves the runtime id server-side (e.g. with the Node SDK's
|
|
50
|
+
`client.runtimes.resolveByName("support-agent")`) and supplies the Data
|
|
51
|
+
Plane URL, so the SPA needs no Introspection config of its own.
|
|
52
|
+
2. `client.connect()` redeems the token at the **Data Plane**
|
|
53
|
+
`POST /v1/oauth/exchange` for the HttpOnly `intro_dp_session` cookie.
|
|
54
|
+
3. `client.tasks.start({ runtime_id })` and friends ride that cookie against
|
|
55
|
+
the Data Plane for tasks, files, conversations, and shares.
|
|
49
56
|
|
|
50
57
|
```typescript
|
|
51
58
|
import { IntrospectionApiClient } from "@introspection-sdk/introspection-browser/api";
|
|
52
59
|
|
|
60
|
+
// Your backend returns { token, runtimeId, dpUrl }: it mints the access token,
|
|
61
|
+
// resolves the runtime id, and supplies the DP URL — so the browser never
|
|
62
|
+
// calls the CP and carries no Introspection config of its own.
|
|
63
|
+
const { token, runtimeId, dpUrl } = await fetch(
|
|
64
|
+
"/api/introspection/session",
|
|
65
|
+
).then((r) => r.json());
|
|
66
|
+
|
|
53
67
|
const client = new IntrospectionApiClient({
|
|
54
|
-
dpUrl
|
|
55
|
-
|
|
56
|
-
// your backend returns a fresh Introspection access token
|
|
57
|
-
getToken: () => fetch("/api/introspection/token").then((r) => r.text()),
|
|
68
|
+
dpUrl,
|
|
69
|
+
getToken: () => token,
|
|
58
70
|
});
|
|
59
71
|
|
|
60
|
-
await client.connect(); //
|
|
72
|
+
await client.connect(); // -> intro_dp_session cookie
|
|
61
73
|
|
|
62
74
|
const run = await client.tasks.start({
|
|
63
75
|
prompt: "Summarize my latest order",
|
|
64
|
-
|
|
65
|
-
identity: { user_id: "u_42" }, // folded into metadata.identity
|
|
66
|
-
visibility: "identity", // sharing scope; defaults by credential
|
|
76
|
+
runtime_id: runtimeId,
|
|
67
77
|
idle_timeout_seconds: 120, // idle window before the sandbox is torn down
|
|
68
78
|
});
|
|
69
79
|
|
|
@@ -76,26 +86,21 @@ for await (const ev of run.stream()) {
|
|
|
76
86
|
`list` / `update` / `delete` / `archive` / `unarchive`) plus per-run streaming
|
|
77
87
|
(`run.stream()`, `run.text()`, `run.cancel()`).
|
|
78
88
|
|
|
79
|
-
|
|
80
|
-
|
|
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.
|
|
89
|
+
`create` and `start` accept **`idle_timeout_seconds`** (`number`) to override
|
|
90
|
+
the interactive idle window before the sandbox is torn down. `0` tears it down
|
|
91
|
+
as soon as it's provisioned; omit to use the deployment default. Clamped to the
|
|
92
|
+
task timeout. When no `runtime_id` is supplied, pass `agent_name` to select a
|
|
93
|
+
named recipe agent instead.
|
|
88
94
|
|
|
89
95
|
## Files and conversations
|
|
90
96
|
|
|
91
|
-
The same
|
|
92
|
-
`/v1/conversations`
|
|
93
|
-
`connect()`:
|
|
97
|
+
The same cookie session also reaches `/v1/files` and (read-only)
|
|
98
|
+
`/v1/conversations` on the Data Plane:
|
|
94
99
|
|
|
95
100
|
```typescript
|
|
96
101
|
// Files — CRUD + upload/download, all identity-scoped
|
|
97
102
|
await client.files.upload({ file: new Blob(["hi"]), name: "hi.txt" });
|
|
98
|
-
const page = await client.files.list(
|
|
103
|
+
const page = await client.files.list();
|
|
99
104
|
const bytes = await client.files.download(page.records[0].id);
|
|
100
105
|
|
|
101
106
|
// Conversations — read-only projection over the telemetry store
|
|
@@ -114,6 +119,6 @@ plus `files.versions`). `client.conversations` mirrors `ConversationsApi`
|
|
|
114
119
|
helpers return a `Paginator` — `await` it for the first page or `for await` it
|
|
115
120
|
to auto-page.
|
|
116
121
|
|
|
117
|
-
> **CORS:** the Data Plane
|
|
118
|
-
>
|
|
119
|
-
>
|
|
122
|
+
> **CORS:** the browser only calls the Data Plane, so just the selected Data
|
|
123
|
+
> Plane needs to allow the SPA origin. The Control Plane never receives browser
|
|
124
|
+
> requests — runtime resolution happens on your backend.
|
package/dist/api/client.d.ts
CHANGED
|
@@ -2,28 +2,35 @@
|
|
|
2
2
|
* Browser-side Introspection API client.
|
|
3
3
|
*
|
|
4
4
|
* Lets a single-page app create and stream Introspection tasks directly
|
|
5
|
-
* from the browser, with no API key in JavaScript. The
|
|
5
|
+
* from the browser, with no API key in JavaScript. The browser talks only
|
|
6
|
+
* to the Data Plane — runtime resolution and any other Control Plane work
|
|
7
|
+
* stays on the app's backend, so the CP never needs to serve CORS to
|
|
8
|
+
* customer web origins. The auth boundary:
|
|
6
9
|
*
|
|
7
|
-
* 1. The SPA's own backend ("broker") mints
|
|
8
|
-
* token — via RFC 8693 token-exchange of the partner IdP
|
|
9
|
-
* PKCE `authorization_code`, or `client_credentials
|
|
10
|
-
* secret never leaves the backend
|
|
11
|
-
*
|
|
10
|
+
* 1. The SPA's own backend ("broker") mints a short-lived Introspection
|
|
11
|
+
* access token — via RFC 8693 token-exchange of the partner IdP
|
|
12
|
+
* token, a PKCE `authorization_code`, or `client_credentials` (the
|
|
13
|
+
* IdP secret never leaves the backend) — and, when a specific runtime
|
|
14
|
+
* is needed, resolves its `runtime_id` server-side. The SPA fetches
|
|
15
|
+
* the token through the `getToken` callback.
|
|
12
16
|
* 2. `connect()` redeems the token at the DP `POST /v1/oauth/exchange`
|
|
13
17
|
* for the HttpOnly `intro_dp_session` cookie.
|
|
14
18
|
* 3. Every subsequent call rides that cookie (`credentials: "include"`)
|
|
15
|
-
* — `client.tasks.start(
|
|
19
|
+
* — `client.tasks.start({ runtime_id })`, `.get(...)`, run streaming,
|
|
20
|
+
* etc.
|
|
16
21
|
*
|
|
17
22
|
* When the session cookie expires, an in-flight request gets a 401, and
|
|
18
23
|
* the client transparently re-runs `getToken` + the DP exchange once
|
|
19
24
|
* before retrying.
|
|
20
25
|
*/
|
|
26
|
+
import { ConversationsClient, FilesClient, SharesClient } from "@introspection-sdk/http";
|
|
21
27
|
import { TasksClient } from "./tasks.js";
|
|
22
|
-
import { FilesClient } from "./files.js";
|
|
23
|
-
import { ConversationsClient } from "./conversations.js";
|
|
24
|
-
import { SharesClient } from "./shares.js";
|
|
25
28
|
export interface IntrospectionApiClientOptions {
|
|
26
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* Data Plane REST base URL for the cookie-session APIs (`connect()` and
|
|
31
|
+
* `client.tasks` / `client.files` / `client.conversations` /
|
|
32
|
+
* `client.shares`). Required — the browser only talks to the DP.
|
|
33
|
+
*/
|
|
27
34
|
dpUrl: string;
|
|
28
35
|
/**
|
|
29
36
|
* Returns a fresh Introspection access token from the app's broker
|
|
@@ -40,16 +47,17 @@ export interface IntrospectionApiClientOptions {
|
|
|
40
47
|
}
|
|
41
48
|
export declare class IntrospectionApiClient {
|
|
42
49
|
private readonly opts;
|
|
50
|
+
private readonly fetchImpl;
|
|
51
|
+
private readonly cookieClients;
|
|
52
|
+
constructor(opts: IntrospectionApiClientOptions);
|
|
43
53
|
/** `/v1/tasks` operations bound to the DP session cookie. */
|
|
44
|
-
|
|
54
|
+
get tasks(): TasksClient;
|
|
45
55
|
/** `/v1/files` operations bound to the DP session cookie. */
|
|
46
|
-
|
|
56
|
+
get files(): FilesClient;
|
|
47
57
|
/** Read-only `/v1/conversations` projection bound to the session cookie. */
|
|
48
|
-
|
|
58
|
+
get conversations(): ConversationsClient;
|
|
49
59
|
/** `/v1/shares` read-sharing grants bound to the session cookie. */
|
|
50
|
-
|
|
51
|
-
private readonly fetchImpl;
|
|
52
|
-
constructor(opts: IntrospectionApiClientOptions);
|
|
60
|
+
get shares(): SharesClient;
|
|
53
61
|
/**
|
|
54
62
|
* Mint a token via `getToken` and redeem it at the DP for the
|
|
55
63
|
* `intro_dp_session` cookie. Call once before issuing task requests.
|
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
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAGH,OAAO,EACL,mBAAmB,EACnB,WAAW,EACX,YAAY,EACb,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AASzC,MAAM,WAAW,6BAA6B;IAC5C;;;;OAIG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;;;;OAMG;IACH,QAAQ,EAAE,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACzC,2DAA2D;IAC3D,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IACrB,kDAAkD;IAClD,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC5C;AAED,qBAAa,sBAAsB;IAIrB,OAAO,CAAC,QAAQ,CAAC,IAAI;IAHjC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAe;IACzC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAgB;gBAEjB,IAAI,EAAE,6BAA6B;IAwBhE,6DAA6D;IAC7D,IAAI,KAAK,IAAI,WAAW,CAEvB;IAED,6DAA6D;IAC7D,IAAI,KAAK,IAAI,WAAW,CAEvB;IAED,4EAA4E;IAC5E,IAAI,aAAa,IAAI,mBAAmB,CAEvC;IAED,oEAAoE;IACpE,IAAI,MAAM,IAAI,YAAY,CAEzB;IAED;;;OAGG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;YAIhB,QAAQ;IAiBtB,0EAA0E;YAC5D,UAAU;CAQzB"}
|
package/dist/api/client.js
CHANGED
|
@@ -2,54 +2,71 @@
|
|
|
2
2
|
* Browser-side Introspection API client.
|
|
3
3
|
*
|
|
4
4
|
* Lets a single-page app create and stream Introspection tasks directly
|
|
5
|
-
* from the browser, with no API key in JavaScript. The
|
|
5
|
+
* from the browser, with no API key in JavaScript. The browser talks only
|
|
6
|
+
* to the Data Plane — runtime resolution and any other Control Plane work
|
|
7
|
+
* stays on the app's backend, so the CP never needs to serve CORS to
|
|
8
|
+
* customer web origins. The auth boundary:
|
|
6
9
|
*
|
|
7
|
-
* 1. The SPA's own backend ("broker") mints
|
|
8
|
-
* token — via RFC 8693 token-exchange of the partner IdP
|
|
9
|
-
* PKCE `authorization_code`, or `client_credentials
|
|
10
|
-
* secret never leaves the backend
|
|
11
|
-
*
|
|
10
|
+
* 1. The SPA's own backend ("broker") mints a short-lived Introspection
|
|
11
|
+
* access token — via RFC 8693 token-exchange of the partner IdP
|
|
12
|
+
* token, a PKCE `authorization_code`, or `client_credentials` (the
|
|
13
|
+
* IdP secret never leaves the backend) — and, when a specific runtime
|
|
14
|
+
* is needed, resolves its `runtime_id` server-side. The SPA fetches
|
|
15
|
+
* the token through the `getToken` callback.
|
|
12
16
|
* 2. `connect()` redeems the token at the DP `POST /v1/oauth/exchange`
|
|
13
17
|
* for the HttpOnly `intro_dp_session` cookie.
|
|
14
18
|
* 3. Every subsequent call rides that cookie (`credentials: "include"`)
|
|
15
|
-
* — `client.tasks.start(
|
|
19
|
+
* — `client.tasks.start({ runtime_id })`, `.get(...)`, run streaming,
|
|
20
|
+
* etc.
|
|
16
21
|
*
|
|
17
22
|
* When the session cookie expires, an in-flight request gets a 401, and
|
|
18
23
|
* the client transparently re-runs `getToken` + the DP exchange once
|
|
19
24
|
* before retrying.
|
|
20
25
|
*/
|
|
21
26
|
import { BrowserHttpClient, stripTrailingSlash, toApiError } from "./http.js";
|
|
27
|
+
import { ConversationsClient, FilesClient, SharesClient, } from "@introspection-sdk/http";
|
|
22
28
|
import { TasksClient } from "./tasks.js";
|
|
23
|
-
import { FilesClient } from "./files.js";
|
|
24
|
-
import { ConversationsClient } from "./conversations.js";
|
|
25
|
-
import { SharesClient } from "./shares.js";
|
|
26
29
|
export class IntrospectionApiClient {
|
|
27
30
|
opts;
|
|
28
|
-
/** `/v1/tasks` operations bound to the DP session cookie. */
|
|
29
|
-
tasks;
|
|
30
|
-
/** `/v1/files` operations bound to the DP session cookie. */
|
|
31
|
-
files;
|
|
32
|
-
/** Read-only `/v1/conversations` projection bound to the session cookie. */
|
|
33
|
-
conversations;
|
|
34
|
-
/** `/v1/shares` read-sharing grants bound to the session cookie. */
|
|
35
|
-
shares;
|
|
36
31
|
fetchImpl;
|
|
32
|
+
cookieClients;
|
|
37
33
|
constructor(opts) {
|
|
38
34
|
this.opts = opts;
|
|
39
35
|
this.fetchImpl = opts.fetch ?? globalThis.fetch;
|
|
40
36
|
if (!this.fetchImpl) {
|
|
41
37
|
throw new Error("global fetch is unavailable; pass `fetch` or run in a modern browser");
|
|
42
38
|
}
|
|
39
|
+
if (!opts.dpUrl) {
|
|
40
|
+
throw new Error("IntrospectionApiClient requires a dpUrl");
|
|
41
|
+
}
|
|
43
42
|
const http = new BrowserHttpClient({
|
|
44
43
|
apiUrl: opts.dpUrl,
|
|
45
44
|
additionalHeaders: opts.additionalHeaders,
|
|
46
45
|
fetch: opts.fetch,
|
|
47
46
|
onUnauthorized: () => this.reexchange(),
|
|
48
47
|
});
|
|
49
|
-
this.
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
48
|
+
this.cookieClients = {
|
|
49
|
+
tasks: new TasksClient(http),
|
|
50
|
+
files: new FilesClient(http),
|
|
51
|
+
conversations: new ConversationsClient(http),
|
|
52
|
+
shares: new SharesClient(http),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/** `/v1/tasks` operations bound to the DP session cookie. */
|
|
56
|
+
get tasks() {
|
|
57
|
+
return this.cookieClients.tasks;
|
|
58
|
+
}
|
|
59
|
+
/** `/v1/files` operations bound to the DP session cookie. */
|
|
60
|
+
get files() {
|
|
61
|
+
return this.cookieClients.files;
|
|
62
|
+
}
|
|
63
|
+
/** Read-only `/v1/conversations` projection bound to the session cookie. */
|
|
64
|
+
get conversations() {
|
|
65
|
+
return this.cookieClients.conversations;
|
|
66
|
+
}
|
|
67
|
+
/** `/v1/shares` read-sharing grants bound to the session cookie. */
|
|
68
|
+
get shares() {
|
|
69
|
+
return this.cookieClients.shares;
|
|
53
70
|
}
|
|
54
71
|
/**
|
|
55
72
|
* Mint a token via `getToken` and redeem it at the DP for the
|
package/dist/api/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"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"}
|
package/dist/api/index.d.ts
CHANGED
|
@@ -6,34 +6,40 @@
|
|
|
6
6
|
* Separate from the package's default telemetry export so apps only pull
|
|
7
7
|
* in what they use.
|
|
8
8
|
*
|
|
9
|
+
* The browser talks only to the Data Plane. Resolving a runtime by name
|
|
10
|
+
* (a Control Plane call) stays on your backend, which hands the browser a
|
|
11
|
+
* short-lived access token plus the resolved `runtime_id`.
|
|
12
|
+
*
|
|
9
13
|
* @example
|
|
10
14
|
* ```typescript
|
|
11
15
|
* import { IntrospectionApiClient } from "@introspection-sdk/introspection-browser/api";
|
|
12
16
|
*
|
|
17
|
+
* // Your backend returns { token, runtimeId, dpUrl } — it mints the access
|
|
18
|
+
* // token, resolves the runtime id, and surfaces the DP URL (e.g. from the
|
|
19
|
+
* // Node SDK's serviceAccountToken response), so the browser never calls the CP.
|
|
20
|
+
* const { token, runtimeId, dpUrl } = await fetch(
|
|
21
|
+
* "/api/introspection/session",
|
|
22
|
+
* ).then((r) => r.json());
|
|
23
|
+
*
|
|
13
24
|
* const client = new IntrospectionApiClient({
|
|
14
|
-
* dpUrl
|
|
15
|
-
*
|
|
16
|
-
* // project is derived from its claims — no projectId option needed)
|
|
17
|
-
* getToken: () => fetch("/api/introspection/token").then((r) => r.text()),
|
|
25
|
+
* dpUrl,
|
|
26
|
+
* getToken: () => token,
|
|
18
27
|
* });
|
|
19
28
|
*
|
|
20
|
-
* await client.connect(); //
|
|
29
|
+
* await client.connect(); // -> intro_dp_session cookie
|
|
21
30
|
* const run = await client.tasks.start({
|
|
22
31
|
* prompt: "Summarize my latest order",
|
|
23
|
-
*
|
|
24
|
-
* identity: { user_id: "u_42" },
|
|
32
|
+
* runtime_id: runtimeId,
|
|
25
33
|
* });
|
|
26
34
|
* for await (const ev of run.stream()) console.log(ev.event, ev.data);
|
|
27
35
|
* ```
|
|
28
36
|
*/
|
|
29
37
|
export { IntrospectionApiClient, type IntrospectionApiClientOptions, } from "./client.js";
|
|
30
38
|
export { TasksClient, TaskRunsClient, RunHandle, type CreateTaskParams, type StartTaskParams, } from "./tasks.js";
|
|
31
|
-
export {
|
|
32
|
-
export { ConversationsClient, ConversationItemsClient, } from "./conversations.js";
|
|
33
|
-
export { SharesClient } from "./shares.js";
|
|
39
|
+
export { ConversationItemsClient, ConversationsClient, FileVersionsClient, FilesClient, SharesClient, type FileUploadBody, } from "@introspection-sdk/http";
|
|
34
40
|
export { BrowserHttpClient, type BrowserHttpConfig } from "./http.js";
|
|
35
41
|
export { parseSse } from "./sse.js";
|
|
36
42
|
export { Paginator, cursorPaginate, type PageSource, } from "@introspection-sdk/http";
|
|
37
43
|
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, } from "@introspection-sdk/types";
|
|
38
|
-
export { IntrospectionAPIError, AuthenticationError, InsufficientScopeError, NotFoundError, NetworkError, } from "@introspection-sdk/types";
|
|
44
|
+
export { IntrospectionAPIError, AuthenticationError, InsufficientScopeError, NotFoundError, NetworkError, RunnerExpiredError, } from "@introspection-sdk/types";
|
|
39
45
|
//# 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
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;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,uBAAuB,EACvB,mBAAmB,EACnB,kBAAkB,EAClB,WAAW,EACX,YAAY,EACZ,KAAK,cAAc,GACpB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,iBAAiB,EAAE,KAAK,iBAAiB,EAAE,MAAM,WAAW,CAAC;AACtE,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EACL,SAAS,EACT,cAAc,EACd,KAAK,UAAU,GAChB,MAAM,yBAAyB,CAAC;AAGjC,YAAY,EACV,IAAI,EACJ,OAAO,EACP,UAAU,EACV,kBAAkB,EAClB,cAAc,EACd,gBAAgB,EAChB,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,SAAS,EACT,QAAQ,EACR,IAAI,EACJ,QAAQ,EACR,cAAc,EACd,gBAAgB,EAChB,oBAAoB,EACpB,UAAU,EACV,mBAAmB,EACnB,gBAAgB,EAChB,oBAAoB,EACpB,sBAAsB,EACtB,0BAA0B,EAC1B,uBAAuB,EACvB,oBAAoB,EACpB,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,GAChB,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
|
@@ -6,33 +6,39 @@
|
|
|
6
6
|
* Separate from the package's default telemetry export so apps only pull
|
|
7
7
|
* in what they use.
|
|
8
8
|
*
|
|
9
|
+
* The browser talks only to the Data Plane. Resolving a runtime by name
|
|
10
|
+
* (a Control Plane call) stays on your backend, which hands the browser a
|
|
11
|
+
* short-lived access token plus the resolved `runtime_id`.
|
|
12
|
+
*
|
|
9
13
|
* @example
|
|
10
14
|
* ```typescript
|
|
11
15
|
* import { IntrospectionApiClient } from "@introspection-sdk/introspection-browser/api";
|
|
12
16
|
*
|
|
17
|
+
* // Your backend returns { token, runtimeId, dpUrl } — it mints the access
|
|
18
|
+
* // token, resolves the runtime id, and surfaces the DP URL (e.g. from the
|
|
19
|
+
* // Node SDK's serviceAccountToken response), so the browser never calls the CP.
|
|
20
|
+
* const { token, runtimeId, dpUrl } = await fetch(
|
|
21
|
+
* "/api/introspection/session",
|
|
22
|
+
* ).then((r) => r.json());
|
|
23
|
+
*
|
|
13
24
|
* const client = new IntrospectionApiClient({
|
|
14
|
-
* dpUrl
|
|
15
|
-
*
|
|
16
|
-
* // project is derived from its claims — no projectId option needed)
|
|
17
|
-
* getToken: () => fetch("/api/introspection/token").then((r) => r.text()),
|
|
25
|
+
* dpUrl,
|
|
26
|
+
* getToken: () => token,
|
|
18
27
|
* });
|
|
19
28
|
*
|
|
20
|
-
* await client.connect(); //
|
|
29
|
+
* await client.connect(); // -> intro_dp_session cookie
|
|
21
30
|
* const run = await client.tasks.start({
|
|
22
31
|
* prompt: "Summarize my latest order",
|
|
23
|
-
*
|
|
24
|
-
* identity: { user_id: "u_42" },
|
|
32
|
+
* runtime_id: runtimeId,
|
|
25
33
|
* });
|
|
26
34
|
* for await (const ev of run.stream()) console.log(ev.event, ev.data);
|
|
27
35
|
* ```
|
|
28
36
|
*/
|
|
29
37
|
export { IntrospectionApiClient, } from "./client.js";
|
|
30
38
|
export { TasksClient, TaskRunsClient, RunHandle, } from "./tasks.js";
|
|
31
|
-
export {
|
|
32
|
-
export { ConversationsClient, ConversationItemsClient, } from "./conversations.js";
|
|
33
|
-
export { SharesClient } from "./shares.js";
|
|
39
|
+
export { ConversationItemsClient, ConversationsClient, FileVersionsClient, FilesClient, SharesClient, } from "@introspection-sdk/http";
|
|
34
40
|
export { BrowserHttpClient } from "./http.js";
|
|
35
41
|
export { parseSse } from "./sse.js";
|
|
36
42
|
export { Paginator, cursorPaginate, } from "@introspection-sdk/http";
|
|
37
|
-
export { IntrospectionAPIError, AuthenticationError, InsufficientScopeError, NotFoundError, NetworkError, } from "@introspection-sdk/types";
|
|
43
|
+
export { IntrospectionAPIError, AuthenticationError, InsufficientScopeError, NotFoundError, NetworkError, RunnerExpiredError, } from "@introspection-sdk/types";
|
|
38
44
|
//# 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
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,EACL,sBAAsB,GAEvB,MAAM,aAAa,CAAC;AACrB,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,EAAE,iBAAiB,EAA0B,MAAM,WAAW,CAAC;AACtE,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EACL,SAAS,EACT,cAAc,GAEf,MAAM,yBAAyB,CAAC;AAiCjC,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,sBAAsB,EACtB,aAAa,EACb,YAAY,EACZ,kBAAkB,GACnB,MAAM,0BAA0B,CAAC"}
|
package/dist/api/tasks.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type { RunIdentityInput
|
|
2
|
-
import {
|
|
3
|
-
import { BrowserHttpClient } from "./http.js";
|
|
1
|
+
import type { RunIdentityInput } from "@introspection-sdk/types";
|
|
2
|
+
import { RunHandle, TaskRunsClient, TasksClient as SharedTasksClient, type ResourceHttpClient } from "@introspection-sdk/http";
|
|
4
3
|
/**
|
|
5
4
|
* Body for creating a task directly against the DP from the browser.
|
|
6
5
|
*
|
|
@@ -39,51 +38,13 @@ export interface StartTaskParams extends CreateTaskParams {
|
|
|
39
38
|
/** Required for the `start()` sugar that returns a run handle. */
|
|
40
39
|
prompt: string;
|
|
41
40
|
}
|
|
42
|
-
/** Live handle on a task's run: stream its events, collect text, cancel. */
|
|
43
|
-
export declare class RunHandle {
|
|
44
|
-
readonly task: Task | null;
|
|
45
|
-
readonly run: TaskRun;
|
|
46
|
-
private readonly runs;
|
|
47
|
-
constructor(task: Task | null, run: TaskRun, runs: TaskRunsClient);
|
|
48
|
-
stream(): AsyncIterable<SseEvent>;
|
|
49
|
-
cancel(): Promise<TaskCancelResponse>;
|
|
50
|
-
/** Convenience: concatenate `data` from `text`/`message` SSE frames. */
|
|
51
|
-
text(): Promise<string>;
|
|
52
|
-
}
|
|
53
|
-
export declare class TaskRunsClient {
|
|
54
|
-
private readonly http;
|
|
55
|
-
constructor(http: BrowserHttpClient);
|
|
56
|
-
create(taskId: string, body: TaskRunCreateParams): Promise<RunHandle>;
|
|
57
|
-
get(taskId: string, runId: string): Promise<TaskRun>;
|
|
58
|
-
cancel(taskId: string, runId: string): Promise<TaskCancelResponse>;
|
|
59
|
-
stream(taskId: string, runId: string): AsyncIterable<SseEvent>;
|
|
60
|
-
}
|
|
61
41
|
/**
|
|
62
|
-
* Cookie-authenticated `/v1/tasks` client.
|
|
63
|
-
*
|
|
64
|
-
*
|
|
42
|
+
* Cookie-authenticated `/v1/tasks` client. The implementation is shared with
|
|
43
|
+
* Node's runner-bound task client; this browser subclass only adds the
|
|
44
|
+
* `identity -> metadata.identity` body mapping used by cookie-session calls.
|
|
65
45
|
*/
|
|
66
|
-
export declare class TasksClient {
|
|
67
|
-
|
|
68
|
-
readonly runs: TaskRunsClient;
|
|
69
|
-
constructor(http: BrowserHttpClient);
|
|
70
|
-
/**
|
|
71
|
-
* Tasks matching `params`. `await` it for the first page (preserving
|
|
72
|
-
* the wire envelope's counts + `next` cursor), or `for await` it to
|
|
73
|
-
* stream every task across pages (fetched lazily — `limit` sets the
|
|
74
|
-
* page size, `next` the starting cursor; stop early to stop fetching).
|
|
75
|
-
*
|
|
76
|
-
* Mirrors the Node SDK's `TasksApi.list`, which is the source of truth
|
|
77
|
-
* for the `/v1/tasks` shape.
|
|
78
|
-
*/
|
|
79
|
-
list(params?: TaskListParams): Paginator<Task>;
|
|
80
|
-
create(body: CreateTaskParams): Promise<TaskCreateResponse>;
|
|
81
|
-
get(taskId: string): Promise<Task>;
|
|
82
|
-
update(taskId: string, body: TaskUpdateParams): Promise<Task>;
|
|
83
|
-
delete(taskId: string): Promise<void>;
|
|
84
|
-
archive(taskId: string): Promise<void>;
|
|
85
|
-
unarchive(taskId: string): Promise<void>;
|
|
86
|
-
/** Sugar: create a task + return a handle on its initial run. */
|
|
87
|
-
start(params: StartTaskParams): Promise<RunHandle>;
|
|
46
|
+
export declare class TasksClient extends SharedTasksClient<CreateTaskParams, StartTaskParams> {
|
|
47
|
+
constructor(http: ResourceHttpClient);
|
|
88
48
|
}
|
|
49
|
+
export { RunHandle, TaskRunsClient };
|
|
89
50
|
//# sourceMappingURL=tasks.d.ts.map
|
package/dist/api/tasks.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tasks.d.ts","sourceRoot":"","sources":["../../src/api/tasks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"tasks.d.ts","sourceRoot":"","sources":["../../src/api/tasks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EACL,SAAS,EACT,cAAc,EACd,WAAW,IAAI,iBAAiB,EAChC,KAAK,kBAAkB,EACxB,MAAM,yBAAyB,CAAC;AAEjC;;;;;;;;;GASG;AACH,MAAM,WAAW,gBAAgB;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iDAAiD;IACjD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,0DAA0D;IAC1D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC;;;;OAIG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,wEAAwE;IACxE,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAC5B;;;;;OAKG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,eAAgB,SAAQ,gBAAgB;IACvD,kEAAkE;IAClE,MAAM,EAAE,MAAM,CAAC;CAChB;AAYD;;;;GAIG;AACH,qBAAa,WAAY,SAAQ,iBAAiB,CAChD,gBAAgB,EAChB,eAAe,CAChB;gBACa,IAAI,EAAE,kBAAkB;CAGrC;AAED,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC"}
|