@introspection-sdk/introspection-browser 0.5.5 → 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.
@@ -1,4 +1,4 @@
1
1
 
2
- > @introspection-sdk/introspection-browser@0.5.5 build /home/runner/work/introspection-js-sdk/introspection-js-sdk/packages/introspection-browser
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,30 +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
- 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.
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
- cpUrl: "https://api.introspection.dev",
55
- // your backend returns a fresh Introspection access token
56
- getToken: () => fetch("/api/introspection/token").then((r) => r.text()),
68
+ dpUrl,
69
+ getToken: () => token,
57
70
  });
58
71
 
59
- const runner = await client.runtimes("support-agent").run({
60
- identity: { user_id: "u_42" },
61
- });
72
+ await client.connect(); // -> intro_dp_session cookie
62
73
 
63
- const run = await runner.tasks.start({
74
+ const run = await client.tasks.start({
64
75
  prompt: "Summarize my latest order",
76
+ runtime_id: runtimeId,
65
77
  idle_timeout_seconds: 120, // idle window before the sandbox is torn down
66
78
  });
67
79
 
@@ -70,62 +82,43 @@ for await (const ev of run.stream()) {
70
82
  }
71
83
  ```
72
84
 
73
- `runner.tasks` exposes the full CRUD surface (`create` / `start` / `get` /
85
+ `client.tasks` exposes the full CRUD surface (`create` / `start` / `get` /
74
86
  `list` / `update` / `delete` / `archive` / `unarchive`) plus per-run streaming
75
87
  (`run.stream()`, `run.text()`, `run.cancel()`).
76
88
 
77
89
  `create` and `start` accept **`idle_timeout_seconds`** (`number`) to override
78
90
  the interactive idle window before the sandbox is torn down. `0` tears it down
79
91
  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
- ```
97
-
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.
92
+ task timeout. When no `runtime_id` is supplied, pass `agent_name` to select a
93
+ named recipe agent instead.
101
94
 
102
95
  ## Files and conversations
103
96
 
104
- The same runner session also reaches `/v1/files` and (read-only)
105
- `/v1/conversations` using the CP-minted runner token:
97
+ The same cookie session also reaches `/v1/files` and (read-only)
98
+ `/v1/conversations` on the Data Plane:
106
99
 
107
100
  ```typescript
108
101
  // Files — CRUD + upload/download, all identity-scoped
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);
102
+ await client.files.upload({ file: new Blob(["hi"]), name: "hi.txt" });
103
+ const page = await client.files.list();
104
+ const bytes = await client.files.download(page.records[0].id);
112
105
 
113
106
  // Conversations — read-only projection over the telemetry store
114
- for await (const summary of runner.conversations.list()) {
107
+ for await (const summary of client.conversations.list()) {
115
108
  console.log(summary.conversation_id);
116
109
  }
117
110
  // Resolve the latest turn of a conversation (Responses-API shape)
118
- const turn = await runner.conversations.retrieve(conversationId);
111
+ const turn = await client.conversations.retrieve(conversationId);
119
112
  console.log(turn?.output_messages);
120
113
  ```
121
114
 
122
- `runner.files` mirrors the Node SDK's `FilesApi` (`list` / `upload` /
115
+ `client.files` mirrors the Node SDK's `FilesApi` (`list` / `upload` /
123
116
  `createText` / `get` / `update` / `delete` / `download` / `downloadStream`,
124
- plus `files.versions`). `runner.conversations` mirrors `ConversationsApi`
117
+ plus `files.versions`). `client.conversations` mirrors `ConversationsApi`
125
118
  (`list`, `retrieve`, and `conversations.items.list()` / `.get()`). Both `list`
126
119
  helpers return a `Paginator` — `await` it for the first page or `for await` it
127
120
  to auto-page.
128
121
 
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.
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.
@@ -2,17 +2,22 @@
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 auth boundary:
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 an Introspection access
8
- * token — via RFC 8693 token-exchange of the partner IdP token, a
9
- * PKCE `authorization_code`, or `client_credentials`. The IdP
10
- * secret never leaves the backend. The SPA fetches that token
11
- * through the `getToken` callback.
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(...)`, `.get(...)`, run streaming, etc.
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
@@ -20,21 +25,13 @@
20
25
  */
21
26
  import { ConversationsClient, FilesClient, SharesClient } from "@introspection-sdk/http";
22
27
  import { TasksClient } from "./tasks.js";
23
- import { type BrowserRuntimeHandleFactory, type BrowserRuntimesClient } from "./runtimes.js";
24
28
  export interface IntrospectionApiClientOptions {
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
29
  /**
32
30
  * 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.
31
+ * `client.tasks` / `client.files` / `client.conversations` /
32
+ * `client.shares`). Required — the browser only talks to the DP.
36
33
  */
37
- dpUrl?: string;
34
+ dpUrl: string;
38
35
  /**
39
36
  * Returns a fresh Introspection access token from the app's broker
40
37
  * (its own backend). Called on `connect()` and again whenever the DP
@@ -50,13 +47,7 @@ export interface IntrospectionApiClientOptions {
50
47
  }
51
48
  export declare class IntrospectionApiClient {
52
49
  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
50
  private readonly fetchImpl;
59
- private readonly cpHttp;
60
51
  private readonly cookieClients;
61
52
  constructor(opts: IntrospectionApiClientOptions);
62
53
  /** `/v1/tasks` operations bound to the DP session cookie. */
@@ -75,8 +66,5 @@ export declare class IntrospectionApiClient {
75
66
  private exchange;
76
67
  /** 401 recovery: re-exchange, reporting success so the call can retry. */
77
68
  private reexchange;
78
- private requireCookieClient;
79
- private requireDpUrl;
80
- private requestFreshRunnerSpec;
81
69
  }
82
70
  //# sourceMappingURL=client.d.ts.map
@@ -1 +1 @@
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,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAEL,KAAK,2BAA2B,EAChC,KAAK,qBAAqB,EAC3B,MAAM,eAA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;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"}
@@ -2,35 +2,33 @@
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 auth boundary:
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 an Introspection access
8
- * token — via RFC 8693 token-exchange of the partner IdP token, a
9
- * PKCE `authorization_code`, or `client_credentials`. The IdP
10
- * secret never leaves the backend. The SPA fetches that token
11
- * through the `getToken` callback.
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(...)`, `.get(...)`, run streaming, etc.
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
- import { BrowserBearerHttpClient, BrowserHttpClient, stripTrailingSlash, toApiError, } from "./http.js";
26
+ import { BrowserHttpClient, stripTrailingSlash, toApiError } from "./http.js";
22
27
  import { ConversationsClient, FilesClient, SharesClient, } from "@introspection-sdk/http";
23
28
  import { TasksClient } from "./tasks.js";
24
- import { attachBrowserRuntimes, } from "./runtimes.js";
25
29
  export class IntrospectionApiClient {
26
30
  opts;
27
- /**
28
- * CRUD on CP `/v1/runtimes` and the `(idOrName) => RuntimeHandle` factory.
29
- * Call as `client.runtimes("customer-agent").run()`.
30
- */
31
- runtimes;
32
31
  fetchImpl;
33
- cpHttp;
34
32
  cookieClients;
35
33
  constructor(opts) {
36
34
  this.opts = opts;
@@ -38,63 +36,48 @@ export class IntrospectionApiClient {
38
36
  if (!this.fetchImpl) {
39
37
  throw new Error("global fetch is unavailable; pass `fetch` or run in a modern browser");
40
38
  }
41
- this.cpHttp = new BrowserBearerHttpClient({
42
- apiUrl: opts.cpUrl ?? "https://api.introspection.dev",
43
- token: opts.getToken,
44
- additionalHeaders: opts.additionalHeaders,
45
- fetch: opts.fetch,
46
- });
47
- this.runtimes = attachBrowserRuntimes(this.cpHttp, {
39
+ if (!opts.dpUrl) {
40
+ throw new Error("IntrospectionApiClient requires a dpUrl");
41
+ }
42
+ const http = new BrowserHttpClient({
43
+ apiUrl: opts.dpUrl,
48
44
  additionalHeaders: opts.additionalHeaders,
49
45
  fetch: opts.fetch,
50
- requestFreshRunnerSpec: (source) => this.requestFreshRunnerSpec(source),
46
+ onUnauthorized: () => this.reexchange(),
51
47
  });
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
- }
48
+ this.cookieClients = {
49
+ tasks: new TasksClient(http),
50
+ files: new FilesClient(http),
51
+ conversations: new ConversationsClient(http),
52
+ shares: new SharesClient(http),
53
+ };
69
54
  }
70
55
  /** `/v1/tasks` operations bound to the DP session cookie. */
71
56
  get tasks() {
72
- return this.requireCookieClient("tasks");
57
+ return this.cookieClients.tasks;
73
58
  }
74
59
  /** `/v1/files` operations bound to the DP session cookie. */
75
60
  get files() {
76
- return this.requireCookieClient("files");
61
+ return this.cookieClients.files;
77
62
  }
78
63
  /** Read-only `/v1/conversations` projection bound to the session cookie. */
79
64
  get conversations() {
80
- return this.requireCookieClient("conversations");
65
+ return this.cookieClients.conversations;
81
66
  }
82
67
  /** `/v1/shares` read-sharing grants bound to the session cookie. */
83
68
  get shares() {
84
- return this.requireCookieClient("shares");
69
+ return this.cookieClients.shares;
85
70
  }
86
71
  /**
87
72
  * Mint a token via `getToken` and redeem it at the DP for the
88
73
  * `intro_dp_session` cookie. Call once before issuing task requests.
89
74
  */
90
75
  async connect() {
91
- this.requireDpUrl();
92
76
  await this.exchange();
93
77
  }
94
78
  async exchange() {
95
- const dpUrl = this.requireDpUrl();
96
79
  const token = await this.opts.getToken();
97
- const res = await this.fetchImpl(`${stripTrailingSlash(dpUrl)}/v1/oauth/exchange`, {
80
+ const res = await this.fetchImpl(`${stripTrailingSlash(this.opts.dpUrl)}/v1/oauth/exchange`, {
98
81
  method: "POST",
99
82
  headers: {
100
83
  "Content-Type": "application/json",
@@ -116,31 +99,5 @@ export class IntrospectionApiClient {
116
99
  return false;
117
100
  }
118
101
  }
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
- }
145
102
  }
146
103
  //# sourceMappingURL=client.js.map
@@ -1 +1 @@
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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AAO,IAAI,CAAC;QACd,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;CACF"}
@@ -26,7 +26,6 @@ export interface BrowserHttpConfig {
26
26
  */
27
27
  onUnauthorized?: () => Promise<boolean>;
28
28
  }
29
- export type BrowserApiHttpClient = Pick<BaseHttpClient, "request" | "stream">;
30
29
  /**
31
30
  * Cookie-authenticated HTTP wrapper bound to one DP endpoint. Has no
32
31
  * opinion about which resource it serves — the caller picks the path.
@@ -34,26 +33,4 @@ export type BrowserApiHttpClient = Pick<BaseHttpClient, "request" | "stream">;
34
33
  export declare class BrowserHttpClient extends BaseHttpClient {
35
34
  constructor(cfg: BrowserHttpConfig);
36
35
  }
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
- }
59
36
  //# sourceMappingURL=http.d.ts.map
@@ -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,kBAA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C5C,OAAO,CAAC,QAAQ,CAAC;CAIrB"}
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;CACzC;AAED;;;GAGG;AACH,qBAAa,iBAAkB,SAAQ,cAAc;gBACvC,GAAG,EAAE,iBAAiB;CAYnC"}
package/dist/api/http.js CHANGED
@@ -31,42 +31,4 @@ 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
- }
72
34
  //# sourceMappingURL=http.js.map
@@ -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;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,QAAQ,GAAG,EAAE,KAAK,EAAE,OAAO,GAAG,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;QAC3E,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,GAA2B,EAAE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B;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"}
@@ -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
- * 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
- * getToken: () => fetch("/api/introspection/token").then((r) => r.text()),
25
+ * dpUrl,
26
+ * getToken: () => token,
18
27
  * });
19
28
  *
20
- * const runner = await client.runtimes("support-agent").run({
21
- * identity: { user_id: "u_42" },
22
- * });
23
- * const run = await runner.tasks.start({
29
+ * await client.connect(); // -> intro_dp_session cookie
30
+ * const run = await client.tasks.start({
24
31
  * prompt: "Summarize my latest order",
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
- export { BrowserRunner, Runner, type BrowserRunnerOwner, type BrowserRunnerSource, } from "./runner.js";
31
- export { BrowserRuntimesClient, BrowserRuntimeHandle, attachBrowserRuntimes, isUuid, type BrowserRuntimeHandleFactory, type BrowserRuntimeRunRequestBody, } from "./runtimes.js";
32
38
  export { TasksClient, TaskRunsClient, RunHandle, type CreateTaskParams, type StartTaskParams, } from "./tasks.js";
33
39
  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";
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
- 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";
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
44
  export { IntrospectionAPIError, AuthenticationError, InsufficientScopeError, NotFoundError, NetworkError, RunnerExpiredError, } from "@introspection-sdk/types";
39
45
  //# sourceMappingURL=index.d.ts.map
@@ -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,aAAa,EACb,MAAM,EACN,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,GACzB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,EACrB,MAAM,EACN,KAAK,2BAA2B,EAChC,KAAK,4BAA4B,GAClC,MAAM,eAAe,CAAC;AACvB,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,EACL,uBAAuB,EACvB,iBAAiB,EACjB,KAAK,oBAAoB,EACzB,KAAK,uBAAuB,EAC5B,KAAK,iBAAiB,GACvB,MAAM,WAAW,CAAC;AACnB,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,EACf,MAAM,EACN,UAAU,EACV,aAAa,EACb,gBAAgB,EAChB,UAAU,EACV,OAAO,EACP,aAAa,EACb,iBAAiB,EACjB,aAAa,GACd,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,sBAAsB,EACtB,aAAa,EACb,YAAY,EACZ,kBAAkB,GACnB,MAAM,0BAA0B,CAAC"}
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,32 +6,38 @@
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
- * 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
- * getToken: () => fetch("/api/introspection/token").then((r) => r.text()),
25
+ * dpUrl,
26
+ * getToken: () => token,
18
27
  * });
19
28
  *
20
- * const runner = await client.runtimes("support-agent").run({
21
- * identity: { user_id: "u_42" },
22
- * });
23
- * const run = await runner.tasks.start({
29
+ * await client.connect(); // -> intro_dp_session cookie
30
+ * const run = await client.tasks.start({
24
31
  * prompt: "Summarize my latest order",
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
- export { BrowserRunner, Runner, } from "./runner.js";
31
- export { BrowserRuntimesClient, BrowserRuntimeHandle, attachBrowserRuntimes, isUuid, } from "./runtimes.js";
32
38
  export { TasksClient, TaskRunsClient, RunHandle, } from "./tasks.js";
33
39
  export { ConversationItemsClient, ConversationsClient, FileVersionsClient, FilesClient, SharesClient, } from "@introspection-sdk/http";
34
- export { BrowserBearerHttpClient, BrowserHttpClient, } from "./http.js";
40
+ export { BrowserHttpClient } from "./http.js";
35
41
  export { parseSse } from "./sse.js";
36
42
  export { Paginator, cursorPaginate, } from "@introspection-sdk/http";
37
43
  export { IntrospectionAPIError, AuthenticationError, InsufficientScopeError, NotFoundError, NetworkError, RunnerExpiredError, } from "@introspection-sdk/types";
@@ -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,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"}
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"}