@introspection-sdk/introspection-browser 0.5.2 → 0.5.4

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.2 build /home/runner/work/introspection-js-sdk/introspection-js-sdk/packages/introspection-browser
2
+ > @introspection-sdk/introspection-browser@0.5.4 build /home/runner/work/introspection-js-sdk/introspection-js-sdk/packages/introspection-browser
3
3
  > tsc
4
4
 
package/README.md CHANGED
@@ -86,6 +86,34 @@ Both `create` and `start` accept two optional task controls:
86
86
  before the sandbox is torn down. `0` tears it down as soon as it's
87
87
  provisioned; omit to use the deployment default. Clamped to the task timeout.
88
88
 
89
+ ## Files and conversations
90
+
91
+ The same identity session also reaches `/v1/files` and (read-only)
92
+ `/v1/conversations` — no extra credential, just the cookie minted by
93
+ `connect()`:
94
+
95
+ ```typescript
96
+ // Files — CRUD + upload/download, all identity-scoped
97
+ await client.files.upload({ file: new Blob(["hi"]), name: "hi.txt" });
98
+ const page = await client.files.list({ visibility: "identity" });
99
+ const bytes = await client.files.download(page.records[0].id);
100
+
101
+ // Conversations — read-only projection over the telemetry store
102
+ for await (const summary of client.conversations.list()) {
103
+ console.log(summary.conversation_id);
104
+ }
105
+ // Resolve the latest turn of a conversation (Responses-API shape)
106
+ const turn = await client.conversations.retrieve(conversationId);
107
+ console.log(turn?.output_messages);
108
+ ```
109
+
110
+ `client.files` mirrors the Node SDK's `FilesApi` (`list` / `upload` /
111
+ `createText` / `get` / `update` / `delete` / `download` / `downloadStream`,
112
+ plus `files.versions`). `client.conversations` mirrors `ConversationsApi`
113
+ (`list`, `retrieve`, and `conversations.items.list()` / `.get()`). Both `list`
114
+ helpers return a `Paginator` — `await` it for the first page or `for await` it
115
+ to auto-page.
116
+
89
117
  > **CORS:** the Data Plane authorizes browser origins against its configured
90
118
  > allowlist (`CORS_ORIGINS`). A new SPA origin must be present there for the
91
- > cross-origin cookie exchange and task calls to succeed.
119
+ > cross-origin cookie exchange and task/file/conversation calls to succeed.
@@ -19,15 +19,18 @@
19
19
  * before retrying.
20
20
  */
21
21
  import { TasksClient } from "./tasks.js";
22
+ import { FilesClient } from "./files.js";
23
+ import { ConversationsClient } from "./conversations.js";
24
+ import { SharesClient } from "./shares.js";
22
25
  export interface IntrospectionApiClientOptions {
23
26
  /** Data Plane REST base URL (e.g. `https://dp.us.introspection.dev`). */
24
27
  dpUrl: string;
25
- /** Project the session is scoped to. */
26
- projectId: string;
27
28
  /**
28
29
  * Returns a fresh Introspection access token from the app's broker
29
30
  * (its own backend). Called on `connect()` and again whenever the DP
30
- * session cookie needs re-minting after a 401.
31
+ * session cookie needs re-minting after a 401. The session's project is
32
+ * derived from this token's claims server-side — there is no separate
33
+ * project option.
31
34
  */
32
35
  getToken: () => string | Promise<string>;
33
36
  /** Custom `fetch` (for tests or non-standard runtimes). */
@@ -39,6 +42,12 @@ export declare class IntrospectionApiClient {
39
42
  private readonly opts;
40
43
  /** `/v1/tasks` operations bound to the DP session cookie. */
41
44
  readonly tasks: TasksClient;
45
+ /** `/v1/files` operations bound to the DP session cookie. */
46
+ readonly files: FilesClient;
47
+ /** Read-only `/v1/conversations` projection bound to the session cookie. */
48
+ readonly conversations: ConversationsClient;
49
+ /** `/v1/shares` read-sharing grants bound to the session cookie. */
50
+ readonly shares: SharesClient;
42
51
  private readonly fetchImpl;
43
52
  constructor(opts: IntrospectionApiClientOptions);
44
53
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,MAAM,WAAW,6BAA6B;IAC5C,yEAAyE;IACzE,KAAK,EAAE,MAAM,CAAC;IACd,wCAAwC;IACxC,SAAS,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,QAAQ,EAA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,6DAA6D;IAC7D,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;IAC5B,4EAA4E;IAC5E,QAAQ,CAAC,aAAa,EAAE,mBAAmB,CAAC;IAC5C,oEAAoE;IACpE,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAE9B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAe;gBAEZ,IAAI,EAAE,6BAA6B;IAmBhE;;;OAGG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;YAIhB,QAAQ;IAiBtB,0EAA0E;YAC5D,UAAU;CAQzB"}
@@ -20,10 +20,19 @@
20
20
  */
21
21
  import { BrowserHttpClient, stripTrailingSlash, toApiError } from "./http.js";
22
22
  import { TasksClient } from "./tasks.js";
23
+ import { FilesClient } from "./files.js";
24
+ import { ConversationsClient } from "./conversations.js";
25
+ import { SharesClient } from "./shares.js";
23
26
  export class IntrospectionApiClient {
24
27
  opts;
25
28
  /** `/v1/tasks` operations bound to the DP session cookie. */
26
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;
27
36
  fetchImpl;
28
37
  constructor(opts) {
29
38
  this.opts = opts;
@@ -38,6 +47,9 @@ export class IntrospectionApiClient {
38
47
  onUnauthorized: () => this.reexchange(),
39
48
  });
40
49
  this.tasks = new TasksClient(http);
50
+ this.files = new FilesClient(http);
51
+ this.conversations = new ConversationsClient(http);
52
+ this.shares = new SharesClient(http);
41
53
  }
42
54
  /**
43
55
  * Mint a token via `getToken` and redeem it at the DP for the
@@ -54,7 +66,7 @@ export class IntrospectionApiClient {
54
66
  "Content-Type": "application/json",
55
67
  ...(this.opts.additionalHeaders ?? {}),
56
68
  },
57
- body: JSON.stringify({ token, project_id: this.opts.projectId }),
69
+ body: JSON.stringify({ token }),
58
70
  credentials: "include",
59
71
  });
60
72
  if (!res.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I,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,84 @@
1
+ /**
2
+ * Cookie-authenticated, read-only Conversations client for the browser
3
+ * (`/v1/conversations`).
4
+ *
5
+ * Mirrors the Node SDK's runner-bound `ConversationsApi`, but rides the
6
+ * DP `intro_dp_session` cookie via {@link BrowserHttpClient} instead of a
7
+ * bearer token — so a single-page app reads conversation history with the
8
+ * same identity session it uses for tasks and files. Conversations are a
9
+ * projection over the immutable telemetry store: list summaries, walk a
10
+ * conversation's items, or `retrieve()` the resolved state of one turn.
11
+ */
12
+ import type { ConversationItem, ConversationItemInclude, ConversationItemList, ConversationItemListParams, ConversationListParams, ConversationResponse, ConversationSummary } from "@introspection-sdk/types";
13
+ import { Paginator } from "@introspection-sdk/http";
14
+ import { BrowserHttpClient } from "./http.js";
15
+ /**
16
+ * Items of a conversation (`/v1/conversations/{id}/items`). Read-only.
17
+ *
18
+ * Paging is OpenAI-style underneath: the envelope has NO `next` token —
19
+ * `list()` drives `after` = the previous page's `last_id` while
20
+ * `has_more` is true.
21
+ */
22
+ export declare class ConversationItemsClient {
23
+ private readonly http;
24
+ constructor(http: BrowserHttpClient);
25
+ /**
26
+ * List items of a conversation. `await` the result for the first page
27
+ * (an OpenAI-style {@link ConversationItemList} envelope), or
28
+ * `for await` it to stream every item across pages (fetched lazily —
29
+ * `limit` sets the page size, `after` the starting cursor; stop early to
30
+ * stop fetching). Pass `order: "asc"` to walk the transcript from the
31
+ * start.
32
+ *
33
+ * Items carry the turn-local delta in `input_messages` — only the
34
+ * messages new to that turn. Use `get()` for the full input history.
35
+ */
36
+ list(conversationId: string, params?: ConversationItemListParams): Paginator<ConversationItem, ConversationItemList>;
37
+ /**
38
+ * Fetch a single conversation item. Unlike the list route, the
39
+ * detail's `input_messages` is the FULL input history for that span.
40
+ */
41
+ get(conversationId: string, itemId: string, params?: {
42
+ include?: ConversationItemInclude[];
43
+ }): Promise<ConversationItem>;
44
+ }
45
+ /**
46
+ * Read-only Conversations client (`/v1/conversations`).
47
+ *
48
+ * Both `list()` and `items.list()` are auto-paging, but they drive
49
+ * different wire protocols underneath: `list()` walks the standard
50
+ * Introspection cursor envelope's opaque `next` token, while
51
+ * `items.list()` walks an OpenAI-style envelope via `after` = the
52
+ * previous page's `last_id` while `has_more` is true.
53
+ */
54
+ export declare class ConversationsClient {
55
+ private readonly http;
56
+ /** Items of a conversation — `conversations.items.list(...)` etc. */
57
+ readonly items: ConversationItemsClient;
58
+ constructor(http: BrowserHttpClient);
59
+ /**
60
+ * List conversation summaries matching `params`. `await` the result for
61
+ * the first page, or `for await` it to stream every summary across
62
+ * pages (fetched lazily — `limit` sets the page size, `next` the
63
+ * starting cursor; stop early to stop fetching).
64
+ */
65
+ list(params?: ConversationListParams): Paginator<ConversationSummary>;
66
+ /**
67
+ * Responses-API-style retrieve: load the state of a conversation as of
68
+ * one item — the full input history, output, system instructions, and
69
+ * tool definitions of that turn.
70
+ *
71
+ * When `itemId` is omitted, the latest LLM turn is used: the first
72
+ * item (in descending order) whose `node_type` is `"assistant"` or
73
+ * whose `operation_name` is `"chat"`, falling back to the first item
74
+ * with a non-null `output_message`. Returns `null` when the
75
+ * conversation has no items.
76
+ *
77
+ * For the full per-turn transcript instead, iterate
78
+ * `items.list(conversationId, { order: "asc" })`.
79
+ */
80
+ retrieve(conversationId: string, itemId?: string): Promise<ConversationResponse | null>;
81
+ /** Scan items in descending order for the most recent LLM turn. */
82
+ private findLatestTurnId;
83
+ }
84
+ //# sourceMappingURL=conversations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"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* Cookie-authenticated, read-only Conversations client for the browser
3
+ * (`/v1/conversations`).
4
+ *
5
+ * Mirrors the Node SDK's runner-bound `ConversationsApi`, but rides the
6
+ * DP `intro_dp_session` cookie via {@link BrowserHttpClient} instead of a
7
+ * bearer token — so a single-page app reads conversation history with the
8
+ * same identity session it uses for tasks and files. Conversations are a
9
+ * projection over the immutable telemetry store: list summaries, walk a
10
+ * conversation's items, or `retrieve()` the resolved state of one turn.
11
+ */
12
+ import { Paginator, cursorPaginate } from "@introspection-sdk/http";
13
+ /** Includes requested when building a {@link ConversationResponse}. */
14
+ const RESPONSE_INCLUDES = [
15
+ "gen_ai.input.messages",
16
+ "gen_ai.system_instructions",
17
+ "gen_ai.tool.definitions",
18
+ ];
19
+ /**
20
+ * Items of a conversation (`/v1/conversations/{id}/items`). Read-only.
21
+ *
22
+ * Paging is OpenAI-style underneath: the envelope has NO `next` token —
23
+ * `list()` drives `after` = the previous page's `last_id` while
24
+ * `has_more` is true.
25
+ */
26
+ export class ConversationItemsClient {
27
+ http;
28
+ constructor(http) {
29
+ this.http = http;
30
+ }
31
+ /**
32
+ * List items of a conversation. `await` the result for the first page
33
+ * (an OpenAI-style {@link ConversationItemList} envelope), or
34
+ * `for await` it to stream every item across pages (fetched lazily —
35
+ * `limit` sets the page size, `after` the starting cursor; stop early to
36
+ * stop fetching). Pass `order: "asc"` to walk the transcript from the
37
+ * start.
38
+ *
39
+ * Items carry the turn-local delta in `input_messages` — only the
40
+ * messages new to that turn. Use `get()` for the full input history.
41
+ */
42
+ list(conversationId, params) {
43
+ return new Paginator({
44
+ fetch: (after) => this.http.request({
45
+ method: "GET",
46
+ path: `/v1/conversations/${encodeURIComponent(conversationId)}/items`,
47
+ query: { ...params, after },
48
+ }),
49
+ items: (page) => page.data,
50
+ next: (page) => page.has_more && page.last_id !== null ? page.last_id : undefined,
51
+ }, params?.after);
52
+ }
53
+ /**
54
+ * Fetch a single conversation item. Unlike the list route, the
55
+ * detail's `input_messages` is the FULL input history for that span.
56
+ */
57
+ get(conversationId, itemId, params) {
58
+ return this.http.request({
59
+ method: "GET",
60
+ path: `/v1/conversations/${encodeURIComponent(conversationId)}/items/${encodeURIComponent(itemId)}`,
61
+ query: params,
62
+ });
63
+ }
64
+ }
65
+ /**
66
+ * Read-only Conversations client (`/v1/conversations`).
67
+ *
68
+ * Both `list()` and `items.list()` are auto-paging, but they drive
69
+ * different wire protocols underneath: `list()` walks the standard
70
+ * Introspection cursor envelope's opaque `next` token, while
71
+ * `items.list()` walks an OpenAI-style envelope via `after` = the
72
+ * previous page's `last_id` while `has_more` is true.
73
+ */
74
+ export class ConversationsClient {
75
+ http;
76
+ /** Items of a conversation — `conversations.items.list(...)` etc. */
77
+ items;
78
+ constructor(http) {
79
+ this.http = http;
80
+ this.items = new ConversationItemsClient(http);
81
+ }
82
+ /**
83
+ * List conversation summaries matching `params`. `await` the result for
84
+ * the first page, or `for await` it to stream every summary across
85
+ * pages (fetched lazily — `limit` sets the page size, `next` the
86
+ * starting cursor; stop early to stop fetching).
87
+ */
88
+ list(params) {
89
+ return cursorPaginate((next) => this.http.request({
90
+ method: "GET",
91
+ path: "/v1/conversations",
92
+ query: { ...params, next },
93
+ }), params?.next);
94
+ }
95
+ /**
96
+ * Responses-API-style retrieve: load the state of a conversation as of
97
+ * one item — the full input history, output, system instructions, and
98
+ * tool definitions of that turn.
99
+ *
100
+ * When `itemId` is omitted, the latest LLM turn is used: the first
101
+ * item (in descending order) whose `node_type` is `"assistant"` or
102
+ * whose `operation_name` is `"chat"`, falling back to the first item
103
+ * with a non-null `output_message`. Returns `null` when the
104
+ * conversation has no items.
105
+ *
106
+ * For the full per-turn transcript instead, iterate
107
+ * `items.list(conversationId, { order: "asc" })`.
108
+ */
109
+ async retrieve(conversationId, itemId) {
110
+ const targetId = itemId ?? (await this.findLatestTurnId(conversationId));
111
+ if (targetId === null)
112
+ return null;
113
+ const detail = await this.items.get(conversationId, targetId, {
114
+ include: RESPONSE_INCLUDES,
115
+ });
116
+ const outputMessages = detail.gen_ai_output_messages ??
117
+ (detail.output_message ? [detail.output_message] : []);
118
+ return {
119
+ conversation_id: conversationId,
120
+ response_id: detail.response_id ?? null,
121
+ item_id: detail.id,
122
+ created_at: detail.created_at,
123
+ model: detail.model_name ??
124
+ detail.response_model ??
125
+ detail.request_model ??
126
+ null,
127
+ provider_name: detail.provider_name ?? null,
128
+ // The single-item route returns the FULL input history here.
129
+ input_messages: normalizeMessages(detail.input_messages),
130
+ output_messages: normalizeMessages(outputMessages),
131
+ system_instructions: detail.system_instructions ?? null,
132
+ tool_definitions: detail.tool_definitions ?? null,
133
+ };
134
+ }
135
+ /** Scan items in descending order for the most recent LLM turn. */
136
+ async findLatestTurnId(conversationId) {
137
+ let fallback = null;
138
+ for await (const item of this.items.list(conversationId, {
139
+ order: "desc",
140
+ })) {
141
+ if (item.node_type === "assistant" || item.operation_name === "chat") {
142
+ return item.id;
143
+ }
144
+ if (fallback === null && item.output_message != null)
145
+ fallback = item;
146
+ }
147
+ return fallback?.id ?? null;
148
+ }
149
+ }
150
+ /**
151
+ * Defensive normalization for {@link ConversationsClient.retrieve} only:
152
+ * older DP deployments emitted `tool_call_response` parts with a legacy
153
+ * `result` key instead of the semconv `response` key. Map it across so
154
+ * replayed history is always semconv-shaped.
155
+ */
156
+ function normalizeMessages(messages) {
157
+ return messages.map((message) => ({
158
+ ...message,
159
+ parts: message.parts.map(normalizePart),
160
+ }));
161
+ }
162
+ function normalizePart(part) {
163
+ if (part.type !== "tool_call_response")
164
+ return part;
165
+ const legacy = part;
166
+ if (legacy.response !== undefined || legacy.result === undefined) {
167
+ return part;
168
+ }
169
+ const { result, ...rest } = legacy;
170
+ return { ...rest, response: result };
171
+ }
172
+ //# sourceMappingURL=conversations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conversations.js","sourceRoot":"","sources":["../../src/api/conversations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAcH,OAAO,EAAE,SAAS,EAAE,cAAc,EA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I,MAAM,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QACjE,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;IACnC,OAAO,EAAE,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;AACvC,CAAC"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Cookie-authenticated Files client for the browser (`/v1/files`).
3
+ *
4
+ * Mirrors the Node SDK's runner-bound `FilesApi`, but rides the DP
5
+ * `intro_dp_session` cookie via {@link BrowserHttpClient} instead of a
6
+ * bearer token — so a single-page app reads and writes files with the
7
+ * same identity session it uses for tasks and conversations. The DP
8
+ * derives the owning `identity_key` from the session JWT; per-identity
9
+ * file ownership and access are enforced server-side.
10
+ */
11
+ import type { File as FileResource, FileCreateTextParams, FileListParams, FileType, FileUpdateParams, ListParams } from "@introspection-sdk/types";
12
+ import { Paginator } from "@introspection-sdk/http";
13
+ import { BrowserHttpClient } from "./http.js";
14
+ export type FileUploadBody = {
15
+ file: Blob;
16
+ name?: string;
17
+ file_type?: FileType;
18
+ } | {
19
+ file: Uint8Array;
20
+ name: string;
21
+ file_type?: FileType;
22
+ contentType?: string;
23
+ };
24
+ /** Versions of a file (`/v1/files/{id}/versions`). */
25
+ export declare class FileVersionsClient {
26
+ private readonly http;
27
+ constructor(http: BrowserHttpClient);
28
+ /**
29
+ * List versions of a file. `await` the result for the first page, or
30
+ * `for await` it to stream every version across pages (fetched lazily;
31
+ * stop early to stop fetching).
32
+ */
33
+ list(fileId: string, params?: ListParams): Paginator<FileResource>;
34
+ get(fileId: string, versionId: string): Promise<FileResource>;
35
+ create(fileId: string, body: FileUploadBody): Promise<FileResource>;
36
+ }
37
+ /**
38
+ * Cookie-authenticated `/v1/files` client. Mirrors the Node SDK's
39
+ * `FilesApi` shape but is bound to a DP session cookie rather than a
40
+ * bearer token.
41
+ */
42
+ export declare class FilesClient {
43
+ private readonly http;
44
+ readonly versions: FileVersionsClient;
45
+ constructor(http: BrowserHttpClient);
46
+ /**
47
+ * List files matching `params`. `await` the result for the first page,
48
+ * or `for await` it to stream every file across pages (fetched lazily —
49
+ * `limit` sets the page size, `next` the starting cursor; stop early to
50
+ * stop fetching).
51
+ */
52
+ list(params?: FileListParams): Paginator<FileResource>;
53
+ upload(body: FileUploadBody): Promise<FileResource>;
54
+ createText(body: FileCreateTextParams): Promise<FileResource>;
55
+ get(fileId: string): Promise<FileResource>;
56
+ update(fileId: string, body: FileUpdateParams): Promise<FileResource>;
57
+ delete(fileId: string): Promise<void>;
58
+ download(fileId: string): Promise<Uint8Array>;
59
+ downloadStream(fileId: string): Promise<ReadableStream<Uint8Array>>;
60
+ }
61
+ //# sourceMappingURL=files.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../src/api/files.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EACV,IAAI,IAAI,YAAY,EACpB,oBAAoB,EACpB,cAAc,EACd,QAAQ,EACR,gBAAgB,EAChB,UAAU,EAEX,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,SAAS,EAAkB,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE9C,MAAM,MAAM,cAAc,GACtB;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,QAAQ,CAAA;CAAE,GACnD;IACE,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,QAAQ,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEN,sDAAsD;AACtD,qBAAa,kBAAkB;IACjB,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,iBAAiB;IAEpD;;;;OAIG;IACH,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC,YAAY,CAAC;IAYlE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAO7D,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC;CAQpE;AAED;;;;GAIG;AACH,qBAAa,WAAW;IAGV,OAAO,CAAC,QAAQ,CAAC,IAAI;IAFjC,QAAQ,CAAC,QAAQ,EAAE,kBAAkB,CAAC;gBAET,IAAI,EAAE,iBAAiB;IAIpD;;;;;OAKG;IACH,IAAI,CAAC,MAAM,CAAC,EAAE,cAAc,GAAG,SAAS,CAAC,YAAY,CAAC;IAYtD,MAAM,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC;IASnD,UAAU,CAAC,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,YAAY,CAAC;IAQ7D,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAO1C,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,YAAY,CAAC;IAQrE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQrC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAQ7C,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;CAOpE"}
@@ -0,0 +1,141 @@
1
+ /**
2
+ * Cookie-authenticated Files client for the browser (`/v1/files`).
3
+ *
4
+ * Mirrors the Node SDK's runner-bound `FilesApi`, but rides the DP
5
+ * `intro_dp_session` cookie via {@link BrowserHttpClient} instead of a
6
+ * bearer token — so a single-page app reads and writes files with the
7
+ * same identity session it uses for tasks and conversations. The DP
8
+ * derives the owning `identity_key` from the session JWT; per-identity
9
+ * file ownership and access are enforced server-side.
10
+ */
11
+ import { cursorPaginate } from "@introspection-sdk/http";
12
+ /** Versions of a file (`/v1/files/{id}/versions`). */
13
+ export class FileVersionsClient {
14
+ http;
15
+ constructor(http) {
16
+ this.http = http;
17
+ }
18
+ /**
19
+ * List versions of a file. `await` the result for the first page, or
20
+ * `for await` it to stream every version across pages (fetched lazily;
21
+ * stop early to stop fetching).
22
+ */
23
+ list(fileId, params) {
24
+ return cursorPaginate((next) => this.http.request({
25
+ method: "GET",
26
+ path: `/v1/files/${encodeURIComponent(fileId)}/versions`,
27
+ query: { ...params, next },
28
+ }), params?.next);
29
+ }
30
+ get(fileId, versionId) {
31
+ return this.http.request({
32
+ method: "GET",
33
+ path: `/v1/files/${encodeURIComponent(fileId)}/versions/${encodeURIComponent(versionId)}`,
34
+ });
35
+ }
36
+ create(fileId, body) {
37
+ const form = toFormData(body);
38
+ return this.http.request({
39
+ method: "POST",
40
+ path: `/v1/files/${encodeURIComponent(fileId)}/versions`,
41
+ body: form,
42
+ });
43
+ }
44
+ }
45
+ /**
46
+ * Cookie-authenticated `/v1/files` client. Mirrors the Node SDK's
47
+ * `FilesApi` shape but is bound to a DP session cookie rather than a
48
+ * bearer token.
49
+ */
50
+ export class FilesClient {
51
+ http;
52
+ versions;
53
+ constructor(http) {
54
+ this.http = http;
55
+ this.versions = new FileVersionsClient(http);
56
+ }
57
+ /**
58
+ * List files matching `params`. `await` the result for the first page,
59
+ * or `for await` it to stream every file across pages (fetched lazily —
60
+ * `limit` sets the page size, `next` the starting cursor; stop early to
61
+ * stop fetching).
62
+ */
63
+ list(params) {
64
+ return cursorPaginate((next) => this.http.request({
65
+ method: "GET",
66
+ path: "/v1/files",
67
+ query: { ...params, next },
68
+ }), params?.next);
69
+ }
70
+ upload(body) {
71
+ const form = toFormData(body);
72
+ return this.http.request({
73
+ method: "POST",
74
+ path: "/v1/files",
75
+ body: form,
76
+ });
77
+ }
78
+ createText(body) {
79
+ return this.http.request({
80
+ method: "POST",
81
+ path: "/v1/files",
82
+ body,
83
+ });
84
+ }
85
+ get(fileId) {
86
+ return this.http.request({
87
+ method: "GET",
88
+ path: `/v1/files/${encodeURIComponent(fileId)}`,
89
+ });
90
+ }
91
+ update(fileId, body) {
92
+ return this.http.request({
93
+ method: "PATCH",
94
+ path: `/v1/files/${encodeURIComponent(fileId)}`,
95
+ body,
96
+ });
97
+ }
98
+ delete(fileId) {
99
+ return this.http.request({
100
+ method: "DELETE",
101
+ path: `/v1/files/${encodeURIComponent(fileId)}`,
102
+ expect: "empty",
103
+ });
104
+ }
105
+ download(fileId) {
106
+ return this.http.request({
107
+ method: "GET",
108
+ path: `/v1/files/${encodeURIComponent(fileId)}/content`,
109
+ expect: "bytes",
110
+ });
111
+ }
112
+ downloadStream(fileId) {
113
+ return this.http.request({
114
+ method: "GET",
115
+ path: `/v1/files/${encodeURIComponent(fileId)}/content`,
116
+ expect: "stream",
117
+ });
118
+ }
119
+ }
120
+ function toFormData(body) {
121
+ const fd = new FormData();
122
+ if ("file" in body && body.file instanceof Blob) {
123
+ fd.append("file", body.file, body.name);
124
+ }
125
+ else {
126
+ // Uint8Array branch — copy into a fresh ArrayBuffer so the Blob
127
+ // constructor sees a concrete ArrayBuffer (not ArrayBufferLike,
128
+ // which TS rejects under nodenext lib).
129
+ const u8 = body.file;
130
+ const ct = body.contentType ??
131
+ "application/octet-stream";
132
+ const ab = u8.buffer.slice(u8.byteOffset, u8.byteOffset + u8.byteLength);
133
+ fd.append("file", new Blob([ab], { type: ct }), body.name);
134
+ }
135
+ if (body.name)
136
+ fd.append("name", body.name);
137
+ if (body.file_type)
138
+ fd.append("file_type", body.file_type);
139
+ return fd;
140
+ }
141
+ //# sourceMappingURL=files.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files.js","sourceRoot":"","sources":["../../src/api/files.ts"],"names":[],"mappings":"AA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AAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5C,IAAI,IAAI,CAAC,SAAS;QAAE,EAAE,CAAC,MAAM,CAAC,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IAC3D,OAAO,EAAE,CAAC;AACZ,CAAC"}
@@ -12,8 +12,8 @@
12
12
  *
13
13
  * const client = new IntrospectionApiClient({
14
14
  * dpUrl: "https://dp.us.introspection.dev",
15
- * projectId: "proj_…",
16
- * // your backend mints the Introspection access token
15
+ * // your backend mints the Introspection access token (the session's
16
+ * // project is derived from its claims — no projectId option needed)
17
17
  * getToken: () => fetch("/api/introspection/token").then((r) => r.text()),
18
18
  * });
19
19
  *
@@ -28,9 +28,12 @@
28
28
  */
29
29
  export { IntrospectionApiClient, type IntrospectionApiClientOptions, } from "./client.js";
30
30
  export { TasksClient, TaskRunsClient, RunHandle, type CreateTaskParams, type StartTaskParams, } from "./tasks.js";
31
+ export { FilesClient, FileVersionsClient, type FileUploadBody, } from "./files.js";
32
+ export { ConversationsClient, ConversationItemsClient, } from "./conversations.js";
33
+ export { SharesClient } from "./shares.js";
31
34
  export { BrowserHttpClient, type BrowserHttpConfig } from "./http.js";
32
35
  export { parseSse } from "./sse.js";
33
36
  export { Paginator, cursorPaginate, type PageSource, } from "@introspection-sdk/http";
34
- export type { Task, TaskRun, TaskStatus, TaskVisibility, TaskCreateResponse, TaskListParams, TaskUpdateParams, TaskRunCreateParams, TaskCancelResponse, RunIdentityInput, Paginated, SseEvent, } from "@introspection-sdk/types";
37
+ export type { Task, TaskRun, TaskStatus, TaskCreateResponse, TaskListParams, TaskUpdateParams, TaskRunCreateParams, TaskCancelResponse, RunIdentityInput, Paginated, SseEvent, File, FileType, FileListParams, FileUpdateParams, FileCreateTextParams, ListParams, ConversationSummary, ConversationItem, ConversationItemList, ConversationListParams, ConversationItemListParams, ConversationItemInclude, ConversationResponse, ResourceShare, ShareResourceType, ShareCreateParams, ShareListParams, } from "@introspection-sdk/types";
35
38
  export { IntrospectionAPIError, AuthenticationError, InsufficientScopeError, NotFoundError, NetworkError, } from "@introspection-sdk/types";
36
39
  //# 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,WAAW,EACX,cAAc,EACd,SAAS,EACT,KAAK,gBAAgB,EACrB,KAAK,eAAe,GACrB,MAAM,YAAY,CAAC;AACpB,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,cAAc,EACd,kBAAkB,EAClB,cAAc,EACd,gBAAgB,EAChB,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,SAAS,EACT,QAAQ,GACT,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,sBAAsB,EACtB,aAAa,EACb,YAAY,GACb,MAAM,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EACL,sBAAsB,EACtB,KAAK,6BAA6B,GACnC,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,WAAW,EACX,cAAc,EACd,SAAS,EACT,KAAK,gBAAgB,EACrB,KAAK,eAAe,GACrB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,KAAK,cAAc,GACpB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,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,GACb,MAAM,0BAA0B,CAAC"}