@introspection-sdk/introspection-browser 0.5.7 → 0.5.9
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 +2 -2
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +7 -5
- package/dist/api/client.js.map +1 -1
- package/dist/api/fetch.d.ts +23 -0
- package/dist/api/fetch.d.ts.map +1 -0
- package/dist/api/fetch.js +30 -0
- package/dist/api/fetch.js.map +1 -0
- package/dist/api/http.d.ts +1 -1
- package/dist/api/http.d.ts.map +1 -1
- package/dist/api/http.js +4 -2
- package/dist/api/http.js.map +1 -1
- package/dist/api/index.d.ts +3 -3
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +2 -2
- package/dist/api/index.js.map +1 -1
- package/package.json +4 -4
- package/src/api/client.ts +7 -7
- package/src/api/fetch.ts +31 -0
- package/src/api/http.ts +5 -2
- package/src/api/index.ts +10 -3
- package/dist/api/sse.d.ts +0 -7
- package/dist/api/sse.d.ts.map +0 -1
- package/dist/api/sse.js +0 -7
- package/dist/api/sse.js.map +0 -1
- package/src/api/sse.ts +0 -6
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.9 build /home/runner/work/introspection-js-sdk/introspection-js-sdk/packages/introspection-browser
|
|
3
3
|
> tsc
|
|
4
4
|
|
package/README.md
CHANGED
|
@@ -78,13 +78,13 @@ const run = await client.tasks.start({
|
|
|
78
78
|
});
|
|
79
79
|
|
|
80
80
|
for await (const ev of run.stream()) {
|
|
81
|
-
console.log(ev.
|
|
81
|
+
console.log(ev.type);
|
|
82
82
|
}
|
|
83
83
|
```
|
|
84
84
|
|
|
85
85
|
`client.tasks` exposes the full CRUD surface (`create` / `start` / `get` /
|
|
86
86
|
`list` / `update` / `delete` / `archive` / `unarchive`) plus per-run streaming
|
|
87
|
-
(`run.stream()
|
|
87
|
+
(`run.stream()` yields AG-UI events, `run.text()`, `run.cancel()`).
|
|
88
88
|
|
|
89
89
|
`create` and `start` accept **`idle_timeout_seconds`** (`number`) to override
|
|
90
90
|
the interactive idle window before the sandbox is torn down. `0` tears it down
|
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;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAIH,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;IAuBhE,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
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
* before retrying.
|
|
25
25
|
*/
|
|
26
26
|
import { BrowserHttpClient, stripTrailingSlash, toApiError } from "./http.js";
|
|
27
|
+
import { resolveBrowserFetch } from "./fetch.js";
|
|
27
28
|
import { ConversationsClient, FilesClient, SharesClient, } from "@introspection-sdk/http";
|
|
28
29
|
import { TasksClient } from "./tasks.js";
|
|
29
30
|
export class IntrospectionApiClient {
|
|
@@ -32,17 +33,18 @@ export class IntrospectionApiClient {
|
|
|
32
33
|
cookieClients;
|
|
33
34
|
constructor(opts) {
|
|
34
35
|
this.opts = opts;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
// Native browser `fetch` throws "Illegal invocation" when called as a
|
|
37
|
+
// method of this client (`this.fetchImpl(...)`); resolveBrowserFetch
|
|
38
|
+
// returns a global-safe wrapper. The same impl backs the connect()
|
|
39
|
+
// exchange here and the cookie-session resource calls via BrowserHttpClient.
|
|
40
|
+
this.fetchImpl = resolveBrowserFetch(opts.fetch);
|
|
39
41
|
if (!opts.dpUrl) {
|
|
40
42
|
throw new Error("IntrospectionApiClient requires a dpUrl");
|
|
41
43
|
}
|
|
42
44
|
const http = new BrowserHttpClient({
|
|
43
45
|
apiUrl: opts.dpUrl,
|
|
44
46
|
additionalHeaders: opts.additionalHeaders,
|
|
45
|
-
fetch:
|
|
47
|
+
fetch: this.fetchImpl,
|
|
46
48
|
onUnauthorized: () => this.reexchange(),
|
|
47
49
|
});
|
|
48
50
|
this.cookieClients = {
|
package/dist/api/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC9E,OAAO,EACL,mBAAmB,EACnB,WAAW,EACX,YAAY,GACb,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AA8BzC,MAAM,OAAO,sBAAsB;IAIJ;IAHZ,SAAS,CAAe;IACxB,aAAa,CAAgB;IAE9C,YAA6B,IAAmC;QAAnC,SAAI,GAAJ,IAAI,CAA+B;QAC9D,
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC9E,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EACL,mBAAmB,EACnB,WAAW,EACX,YAAY,GACb,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AA8BzC,MAAM,OAAO,sBAAsB;IAIJ;IAHZ,SAAS,CAAe;IACxB,aAAa,CAAgB;IAE9C,YAA6B,IAAmC;QAAnC,SAAI,GAAJ,IAAI,CAA+B;QAC9D,sEAAsE;QACtE,qEAAqE;QACrE,mEAAmE;QACnE,6EAA6E;QAC7E,IAAI,CAAC,SAAS,GAAG,mBAAmB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACjD,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;YAChB,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;QAC7D,CAAC;QACD,MAAM,IAAI,GAAG,IAAI,iBAAiB,CAAC;YACjC,MAAM,EAAE,IAAI,CAAC,KAAK;YAClB,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;YACzC,KAAK,EAAE,IAAI,CAAC,SAAS;YACrB,cAAc,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,UAAU,EAAE;SACxC,CAAC,CAAC;QACH,IAAI,CAAC,aAAa,GAAG;YACnB,KAAK,EAAE,IAAI,WAAW,CAAC,IAAI,CAAC;YAC5B,KAAK,EAAE,IAAI,WAAW,CAAC,IAAI,CAAC;YAC5B,aAAa,EAAE,IAAI,mBAAmB,CAAC,IAAI,CAAC;YAC5C,MAAM,EAAE,IAAI,YAAY,CAAC,IAAI,CAAC;SAC/B,CAAC;IACJ,CAAC;IAED,6DAA6D;IAC7D,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC;IAClC,CAAC;IAED,6DAA6D;IAC7D,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC;IAClC,CAAC;IAED,4EAA4E;IAC5E,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC;IAC1C,CAAC;IAED,oEAAoE;IACpE,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC;IACnC,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,OAAO;QACX,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;IACxB,CAAC;IAEO,KAAK,CAAC,QAAQ;QACpB,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACzC,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,SAAS,CAC9B,GAAG,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,oBAAoB,EAC1D;YACE,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;gBAClC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,iBAAiB,IAAI,EAAE,CAAC;aACvC;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,CAAC;YAC/B,WAAW,EAAE,SAAS;SACvB,CACF,CAAC;QACF,IAAI,CAAC,GAAG,CAAC,EAAE;YAAE,MAAM,MAAM,UAAU,CAAC,GAAG,CAAC,CAAC;IAC3C,CAAC;IAED,0EAA0E;IAClE,KAAK,CAAC,UAAU;QACtB,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;YACtB,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve the `fetch` implementation for browser Data Plane calls.
|
|
3
|
+
*
|
|
4
|
+
* The native browser `fetch` brand-checks its `this`: it must be the global
|
|
5
|
+
* (`window` / `WorkerGlobalScope`). Storing `globalThis.fetch` on an instance
|
|
6
|
+
* field and later calling it as a method — `this.fetchImpl(url, init)` — rebinds
|
|
7
|
+
* `this` to the client instance, so the browser throws
|
|
8
|
+
* `Failed to execute 'fetch' on 'Window': Illegal invocation`.
|
|
9
|
+
*
|
|
10
|
+
* When no custom `fetch` is supplied we therefore return a thin wrapper that
|
|
11
|
+
* invokes `globalThis.fetch(...)` **as a method of the global** (correct `this`)
|
|
12
|
+
* and resolves it **per call**. The per-call lookup is deliberate: the only
|
|
13
|
+
* reason to go through `globalThis.fetch` rather than the lexical `fetch` is so
|
|
14
|
+
* a swapped-in implementation is honored — that is the server-side proxy
|
|
15
|
+
* (`@introspection-sdk/introspection-proxy` monkeypatches `globalThis.fetch`),
|
|
16
|
+
* never a browser concern. A caller-supplied `fetch` is returned untouched.
|
|
17
|
+
*
|
|
18
|
+
* This lives in the browser package on purpose: Node's `fetch` (undici) has no
|
|
19
|
+
* such brand check, so the shared {@link BaseHttpClient} / Node client keep
|
|
20
|
+
* resolving `globalThis.fetch` directly (so the proxy override still applies).
|
|
21
|
+
*/
|
|
22
|
+
export declare function resolveBrowserFetch(custom?: typeof fetch): typeof fetch;
|
|
23
|
+
//# sourceMappingURL=fetch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../src/api/fetch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,CAAC,EAAE,OAAO,KAAK,GAAG,OAAO,KAAK,CASvE"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve the `fetch` implementation for browser Data Plane calls.
|
|
3
|
+
*
|
|
4
|
+
* The native browser `fetch` brand-checks its `this`: it must be the global
|
|
5
|
+
* (`window` / `WorkerGlobalScope`). Storing `globalThis.fetch` on an instance
|
|
6
|
+
* field and later calling it as a method — `this.fetchImpl(url, init)` — rebinds
|
|
7
|
+
* `this` to the client instance, so the browser throws
|
|
8
|
+
* `Failed to execute 'fetch' on 'Window': Illegal invocation`.
|
|
9
|
+
*
|
|
10
|
+
* When no custom `fetch` is supplied we therefore return a thin wrapper that
|
|
11
|
+
* invokes `globalThis.fetch(...)` **as a method of the global** (correct `this`)
|
|
12
|
+
* and resolves it **per call**. The per-call lookup is deliberate: the only
|
|
13
|
+
* reason to go through `globalThis.fetch` rather than the lexical `fetch` is so
|
|
14
|
+
* a swapped-in implementation is honored — that is the server-side proxy
|
|
15
|
+
* (`@introspection-sdk/introspection-proxy` monkeypatches `globalThis.fetch`),
|
|
16
|
+
* never a browser concern. A caller-supplied `fetch` is returned untouched.
|
|
17
|
+
*
|
|
18
|
+
* This lives in the browser package on purpose: Node's `fetch` (undici) has no
|
|
19
|
+
* such brand check, so the shared {@link BaseHttpClient} / Node client keep
|
|
20
|
+
* resolving `globalThis.fetch` directly (so the proxy override still applies).
|
|
21
|
+
*/
|
|
22
|
+
export function resolveBrowserFetch(custom) {
|
|
23
|
+
if (custom)
|
|
24
|
+
return custom;
|
|
25
|
+
if (!globalThis.fetch) {
|
|
26
|
+
throw new Error("global fetch is unavailable; pass `fetch` or run in a modern browser");
|
|
27
|
+
}
|
|
28
|
+
return (input, init) => globalThis.fetch(input, init);
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=fetch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../src/api/fetch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,mBAAmB,CAAC,MAAqB;IACvD,IAAI,MAAM;QAAE,OAAO,MAAM,CAAC;IAC1B,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CACb,sEAAsE,CACvE,CAAC;IACJ,CAAC;IACD,OAAO,CAAC,KAAwB,EAAE,IAAkB,EAAE,EAAE,CACtD,UAAU,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AAClC,CAAC"}
|
package/dist/api/http.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Browser HTTP transport for the Introspection Data Plane `/v1` surface.
|
|
3
3
|
*
|
|
4
4
|
* The request/response machinery — URL joining, query building, body
|
|
5
|
-
* serialization, error mapping,
|
|
5
|
+
* serialization, error mapping, AG-UI stream parsing — lives in the shared
|
|
6
6
|
* `@introspection-sdk/http` {@link BaseHttpClient}. This module pins the
|
|
7
7
|
* browser auth strategy on top of it: the DP is reached with the HttpOnly
|
|
8
8
|
* `intro_dp_session` cookie minted by `POST /v1/oauth/exchange`, so every
|
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;
|
|
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;AAKjC,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;CAanC"}
|
package/dist/api/http.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Browser HTTP transport for the Introspection Data Plane `/v1` surface.
|
|
3
3
|
*
|
|
4
4
|
* The request/response machinery — URL joining, query building, body
|
|
5
|
-
* serialization, error mapping,
|
|
5
|
+
* serialization, error mapping, AG-UI stream parsing — lives in the shared
|
|
6
6
|
* `@introspection-sdk/http` {@link BaseHttpClient}. This module pins the
|
|
7
7
|
* browser auth strategy on top of it: the DP is reached with the HttpOnly
|
|
8
8
|
* `intro_dp_session` cookie minted by `POST /v1/oauth/exchange`, so every
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
* session cookie) triggers a single `onUnauthorized` refresh + retry.
|
|
12
12
|
*/
|
|
13
13
|
import { BaseHttpClient, stripTrailingSlash, toApiError, } from "@introspection-sdk/http";
|
|
14
|
+
import { resolveBrowserFetch } from "./fetch.js";
|
|
14
15
|
// Re-exported for `client.ts`, which redeems the DP session on `connect()`.
|
|
15
16
|
export { stripTrailingSlash, toApiError };
|
|
16
17
|
/**
|
|
@@ -21,8 +22,9 @@ export class BrowserHttpClient extends BaseHttpClient {
|
|
|
21
22
|
constructor(cfg) {
|
|
22
23
|
super({
|
|
23
24
|
apiUrl: cfg.apiUrl,
|
|
25
|
+
// Resolve a browser-safe `fetch` (native `fetch` brand-checks `this`).
|
|
26
|
+
fetch: resolveBrowserFetch(cfg.fetch),
|
|
24
27
|
additionalHeaders: cfg.additionalHeaders,
|
|
25
|
-
fetch: cfg.fetch,
|
|
26
28
|
transport: {
|
|
27
29
|
authHeaders: () => ({}),
|
|
28
30
|
credentials: "include",
|
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;AAiB1C;;;GAGG;AACH,MAAM,OAAO,iBAAkB,SAAQ,cAAc;IACnD,YAAY,GAAsB;QAChC,KAAK,CAAC;YACJ,MAAM,EAAE,GAAG,CAAC,MAAM;YAClB,
|
|
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,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEjD,4EAA4E;AAC5E,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,CAAC;AAiB1C;;;GAGG;AACH,MAAM,OAAO,iBAAkB,SAAQ,cAAc;IACnD,YAAY,GAAsB;QAChC,KAAK,CAAC;YACJ,MAAM,EAAE,GAAG,CAAC,MAAM;YAClB,uEAAuE;YACvE,KAAK,EAAE,mBAAmB,CAAC,GAAG,CAAC,KAAK,CAAC;YACrC,iBAAiB,EAAE,GAAG,CAAC,iBAAiB;YACxC,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"}
|
package/dist/api/index.d.ts
CHANGED
|
@@ -31,15 +31,15 @@
|
|
|
31
31
|
* prompt: "Summarize my latest order",
|
|
32
32
|
* runtime_id: runtimeId,
|
|
33
33
|
* });
|
|
34
|
-
* for await (const ev of run.stream()) console.log(ev.
|
|
34
|
+
* for await (const ev of run.stream()) console.log(ev.type);
|
|
35
35
|
* ```
|
|
36
36
|
*/
|
|
37
37
|
export { IntrospectionApiClient, type IntrospectionApiClientOptions, } from "./client.js";
|
|
38
38
|
export { TasksClient, TaskRunsClient, RunHandle, type CreateTaskParams, type StartTaskParams, } from "./tasks.js";
|
|
39
39
|
export { ConversationItemsClient, ConversationsClient, FileVersionsClient, FilesClient, SharesClient, type FileUploadBody, } from "@introspection-sdk/http";
|
|
40
40
|
export { BrowserHttpClient, type BrowserHttpConfig } from "./http.js";
|
|
41
|
-
export { parseSse } from "./sse.js";
|
|
42
41
|
export { Paginator, cursorPaginate, type PageSource, } from "@introspection-sdk/http";
|
|
43
|
-
export
|
|
42
|
+
export { EventType } from "@introspection-sdk/types";
|
|
43
|
+
export type { AGUIEvent, BaseEvent, Interrupt, Message, ResumeEntry, RunAgentInput, Task, TaskRun, TaskStatus, TaskRunKind, TaskCreateResponse, TaskListParams, TaskUpdateParams, TaskRunCreateParams, TaskRunResumeParams, TaskCancelResponse, RunIdentityInput, Paginated, File, FileType, FileListParams, FileUpdateParams, FileCreateTextParams, ListParams, ConversationSummary, ConversationItem, ConversationItemList, ConversationListParams, ConversationItemListParams, ConversationItemInclude, ConversationResponse, ResourceShare, ShareResourceType, ShareCreateParams, ShareListParams, } from "@introspection-sdk/types";
|
|
44
44
|
export { IntrospectionAPIError, AuthenticationError, InsufficientScopeError, NotFoundError, NetworkError, RunnerExpiredError, } from "@introspection-sdk/types";
|
|
45
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,
|
|
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,EACL,SAAS,EACT,cAAc,EACd,KAAK,UAAU,GAChB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAGrD,YAAY,EACV,SAAS,EACT,SAAS,EACT,SAAS,EACT,OAAO,EACP,WAAW,EACX,aAAa,EACb,IAAI,EACJ,OAAO,EACP,UAAU,EACV,WAAW,EACX,kBAAkB,EAClB,cAAc,EACd,gBAAgB,EAChB,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,SAAS,EACT,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
|
@@ -31,14 +31,14 @@
|
|
|
31
31
|
* prompt: "Summarize my latest order",
|
|
32
32
|
* runtime_id: runtimeId,
|
|
33
33
|
* });
|
|
34
|
-
* for await (const ev of run.stream()) console.log(ev.
|
|
34
|
+
* for await (const ev of run.stream()) console.log(ev.type);
|
|
35
35
|
* ```
|
|
36
36
|
*/
|
|
37
37
|
export { IntrospectionApiClient, } from "./client.js";
|
|
38
38
|
export { TasksClient, TaskRunsClient, RunHandle, } from "./tasks.js";
|
|
39
39
|
export { ConversationItemsClient, ConversationsClient, FileVersionsClient, FilesClient, SharesClient, } from "@introspection-sdk/http";
|
|
40
40
|
export { BrowserHttpClient } from "./http.js";
|
|
41
|
-
export { parseSse } from "./sse.js";
|
|
42
41
|
export { Paginator, cursorPaginate, } from "@introspection-sdk/http";
|
|
42
|
+
export { EventType } from "@introspection-sdk/types";
|
|
43
43
|
export { IntrospectionAPIError, AuthenticationError, InsufficientScopeError, NotFoundError, NetworkError, RunnerExpiredError, } from "@introspection-sdk/types";
|
|
44
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,
|
|
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,EACL,SAAS,EACT,cAAc,GAEf,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAwCrD,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,sBAAsB,EACtB,aAAa,EACb,YAAY,EACZ,kBAAkB,GACnB,MAAM,0BAA0B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@introspection-sdk/introspection-browser",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.9",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "Introspection observability SDK for the browser",
|
|
6
6
|
"engines": {
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@types/node": "^22.
|
|
23
|
+
"@types/node": "^22.20.0",
|
|
24
24
|
"eslint": "^9.39.4",
|
|
25
25
|
"typescript": "5.9.3",
|
|
26
26
|
"@repo/eslint-config": "0.0.0",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"@opentelemetry/api-logs": "^0.219.0",
|
|
32
32
|
"@opentelemetry/sdk-logs": "^0.219.0",
|
|
33
33
|
"@opentelemetry/exporter-logs-otlp-http": "^0.219.0",
|
|
34
|
-
"@introspection-sdk/
|
|
35
|
-
"@introspection-sdk/
|
|
34
|
+
"@introspection-sdk/http": "0.5.9",
|
|
35
|
+
"@introspection-sdk/types": "0.5.9"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
38
38
|
"lint": "eslint . --max-warnings 0",
|
package/src/api/client.ts
CHANGED
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
27
|
import { BrowserHttpClient, stripTrailingSlash, toApiError } from "./http.js";
|
|
28
|
+
import { resolveBrowserFetch } from "./fetch.js";
|
|
28
29
|
import {
|
|
29
30
|
ConversationsClient,
|
|
30
31
|
FilesClient,
|
|
@@ -65,19 +66,18 @@ export class IntrospectionApiClient {
|
|
|
65
66
|
private readonly cookieClients: CookieClients;
|
|
66
67
|
|
|
67
68
|
constructor(private readonly opts: IntrospectionApiClientOptions) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
69
|
+
// Native browser `fetch` throws "Illegal invocation" when called as a
|
|
70
|
+
// method of this client (`this.fetchImpl(...)`); resolveBrowserFetch
|
|
71
|
+
// returns a global-safe wrapper. The same impl backs the connect()
|
|
72
|
+
// exchange here and the cookie-session resource calls via BrowserHttpClient.
|
|
73
|
+
this.fetchImpl = resolveBrowserFetch(opts.fetch);
|
|
74
74
|
if (!opts.dpUrl) {
|
|
75
75
|
throw new Error("IntrospectionApiClient requires a dpUrl");
|
|
76
76
|
}
|
|
77
77
|
const http = new BrowserHttpClient({
|
|
78
78
|
apiUrl: opts.dpUrl,
|
|
79
79
|
additionalHeaders: opts.additionalHeaders,
|
|
80
|
-
fetch:
|
|
80
|
+
fetch: this.fetchImpl,
|
|
81
81
|
onUnauthorized: () => this.reexchange(),
|
|
82
82
|
});
|
|
83
83
|
this.cookieClients = {
|
package/src/api/fetch.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve the `fetch` implementation for browser Data Plane calls.
|
|
3
|
+
*
|
|
4
|
+
* The native browser `fetch` brand-checks its `this`: it must be the global
|
|
5
|
+
* (`window` / `WorkerGlobalScope`). Storing `globalThis.fetch` on an instance
|
|
6
|
+
* field and later calling it as a method — `this.fetchImpl(url, init)` — rebinds
|
|
7
|
+
* `this` to the client instance, so the browser throws
|
|
8
|
+
* `Failed to execute 'fetch' on 'Window': Illegal invocation`.
|
|
9
|
+
*
|
|
10
|
+
* When no custom `fetch` is supplied we therefore return a thin wrapper that
|
|
11
|
+
* invokes `globalThis.fetch(...)` **as a method of the global** (correct `this`)
|
|
12
|
+
* and resolves it **per call**. The per-call lookup is deliberate: the only
|
|
13
|
+
* reason to go through `globalThis.fetch` rather than the lexical `fetch` is so
|
|
14
|
+
* a swapped-in implementation is honored — that is the server-side proxy
|
|
15
|
+
* (`@introspection-sdk/introspection-proxy` monkeypatches `globalThis.fetch`),
|
|
16
|
+
* never a browser concern. A caller-supplied `fetch` is returned untouched.
|
|
17
|
+
*
|
|
18
|
+
* This lives in the browser package on purpose: Node's `fetch` (undici) has no
|
|
19
|
+
* such brand check, so the shared {@link BaseHttpClient} / Node client keep
|
|
20
|
+
* resolving `globalThis.fetch` directly (so the proxy override still applies).
|
|
21
|
+
*/
|
|
22
|
+
export function resolveBrowserFetch(custom?: typeof fetch): typeof fetch {
|
|
23
|
+
if (custom) return custom;
|
|
24
|
+
if (!globalThis.fetch) {
|
|
25
|
+
throw new Error(
|
|
26
|
+
"global fetch is unavailable; pass `fetch` or run in a modern browser",
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
return (input: RequestInfo | URL, init?: RequestInit) =>
|
|
30
|
+
globalThis.fetch(input, init);
|
|
31
|
+
}
|
package/src/api/http.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Browser HTTP transport for the Introspection Data Plane `/v1` surface.
|
|
3
3
|
*
|
|
4
4
|
* The request/response machinery — URL joining, query building, body
|
|
5
|
-
* serialization, error mapping,
|
|
5
|
+
* serialization, error mapping, AG-UI stream parsing — lives in the shared
|
|
6
6
|
* `@introspection-sdk/http` {@link BaseHttpClient}. This module pins the
|
|
7
7
|
* browser auth strategy on top of it: the DP is reached with the HttpOnly
|
|
8
8
|
* `intro_dp_session` cookie minted by `POST /v1/oauth/exchange`, so every
|
|
@@ -17,6 +17,8 @@ import {
|
|
|
17
17
|
toApiError,
|
|
18
18
|
} from "@introspection-sdk/http";
|
|
19
19
|
|
|
20
|
+
import { resolveBrowserFetch } from "./fetch.js";
|
|
21
|
+
|
|
20
22
|
// Re-exported for `client.ts`, which redeems the DP session on `connect()`.
|
|
21
23
|
export { stripTrailingSlash, toApiError };
|
|
22
24
|
|
|
@@ -43,8 +45,9 @@ export class BrowserHttpClient extends BaseHttpClient {
|
|
|
43
45
|
constructor(cfg: BrowserHttpConfig) {
|
|
44
46
|
super({
|
|
45
47
|
apiUrl: cfg.apiUrl,
|
|
48
|
+
// Resolve a browser-safe `fetch` (native `fetch` brand-checks `this`).
|
|
49
|
+
fetch: resolveBrowserFetch(cfg.fetch),
|
|
46
50
|
additionalHeaders: cfg.additionalHeaders,
|
|
47
|
-
fetch: cfg.fetch,
|
|
48
51
|
transport: {
|
|
49
52
|
authHeaders: () => ({}),
|
|
50
53
|
credentials: "include",
|
package/src/api/index.ts
CHANGED
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
* prompt: "Summarize my latest order",
|
|
32
32
|
* runtime_id: runtimeId,
|
|
33
33
|
* });
|
|
34
|
-
* for await (const ev of run.stream()) console.log(ev.
|
|
34
|
+
* for await (const ev of run.stream()) console.log(ev.type);
|
|
35
35
|
* ```
|
|
36
36
|
*/
|
|
37
37
|
|
|
@@ -55,26 +55,33 @@ export {
|
|
|
55
55
|
type FileUploadBody,
|
|
56
56
|
} from "@introspection-sdk/http";
|
|
57
57
|
export { BrowserHttpClient, type BrowserHttpConfig } from "./http.js";
|
|
58
|
-
export { parseSse } from "./sse.js";
|
|
59
58
|
export {
|
|
60
59
|
Paginator,
|
|
61
60
|
cursorPaginate,
|
|
62
61
|
type PageSource,
|
|
63
62
|
} from "@introspection-sdk/http";
|
|
63
|
+
export { EventType } from "@introspection-sdk/types";
|
|
64
64
|
|
|
65
65
|
// Re-exported wire types for convenience.
|
|
66
66
|
export type {
|
|
67
|
+
AGUIEvent,
|
|
68
|
+
BaseEvent,
|
|
69
|
+
Interrupt,
|
|
70
|
+
Message,
|
|
71
|
+
ResumeEntry,
|
|
72
|
+
RunAgentInput,
|
|
67
73
|
Task,
|
|
68
74
|
TaskRun,
|
|
69
75
|
TaskStatus,
|
|
76
|
+
TaskRunKind,
|
|
70
77
|
TaskCreateResponse,
|
|
71
78
|
TaskListParams,
|
|
72
79
|
TaskUpdateParams,
|
|
73
80
|
TaskRunCreateParams,
|
|
81
|
+
TaskRunResumeParams,
|
|
74
82
|
TaskCancelResponse,
|
|
75
83
|
RunIdentityInput,
|
|
76
84
|
Paginated,
|
|
77
|
-
SseEvent,
|
|
78
85
|
File,
|
|
79
86
|
FileType,
|
|
80
87
|
FileListParams,
|
package/dist/api/sse.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* SSE parsing now lives in the shared `@introspection-sdk/http` core so
|
|
3
|
-
* the browser and Node SDKs stay byte-for-byte identical. Re-exported
|
|
4
|
-
* here to keep the existing `./sse.js` import path stable.
|
|
5
|
-
*/
|
|
6
|
-
export { parseSse } from "@introspection-sdk/http";
|
|
7
|
-
//# sourceMappingURL=sse.d.ts.map
|
package/dist/api/sse.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sse.d.ts","sourceRoot":"","sources":["../../src/api/sse.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC"}
|
package/dist/api/sse.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* SSE parsing now lives in the shared `@introspection-sdk/http` core so
|
|
3
|
-
* the browser and Node SDKs stay byte-for-byte identical. Re-exported
|
|
4
|
-
* here to keep the existing `./sse.js` import path stable.
|
|
5
|
-
*/
|
|
6
|
-
export { parseSse } from "@introspection-sdk/http";
|
|
7
|
-
//# sourceMappingURL=sse.js.map
|
package/dist/api/sse.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sse.js","sourceRoot":"","sources":["../../src/api/sse.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC"}
|
package/src/api/sse.ts
DELETED