@introspection-sdk/introspection-browser 0.5.4 → 0.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/README.md +45 -33
  3. package/dist/api/client.d.ts +31 -11
  4. package/dist/api/client.d.ts.map +1 -1
  5. package/dist/api/client.js +80 -20
  6. package/dist/api/client.js.map +1 -1
  7. package/dist/api/http.d.ts +23 -0
  8. package/dist/api/http.d.ts.map +1 -1
  9. package/dist/api/http.js +38 -0
  10. package/dist/api/http.js.map +1 -1
  11. package/dist/api/index.d.ts +11 -11
  12. package/dist/api/index.d.ts.map +1 -1
  13. package/dist/api/index.js +10 -10
  14. package/dist/api/index.js.map +1 -1
  15. package/dist/api/runner.d.ts +45 -0
  16. package/dist/api/runner.d.ts.map +1 -0
  17. package/dist/api/runner.js +87 -0
  18. package/dist/api/runner.js.map +1 -0
  19. package/dist/api/runtimes.d.ts +12 -0
  20. package/dist/api/runtimes.d.ts.map +1 -0
  21. package/dist/api/runtimes.js +14 -0
  22. package/dist/api/runtimes.js.map +1 -0
  23. package/dist/api/tasks.d.ts +8 -47
  24. package/dist/api/tasks.d.ts.map +1 -1
  25. package/dist/api/tasks.js +7 -130
  26. package/dist/api/tasks.js.map +1 -1
  27. package/package.json +3 -3
  28. package/src/api/client.ts +129 -22
  29. package/src/api/http.ts +56 -0
  30. package/src/api/index.ts +40 -12
  31. package/src/api/runner.ts +127 -0
  32. package/src/api/runtimes.ts +32 -0
  33. package/src/api/tasks.ts +18 -158
  34. package/dist/api/conversations.d.ts +0 -84
  35. package/dist/api/conversations.d.ts.map +0 -1
  36. package/dist/api/conversations.js +0 -172
  37. package/dist/api/conversations.js.map +0 -1
  38. package/dist/api/files.d.ts +0 -61
  39. package/dist/api/files.d.ts.map +0 -1
  40. package/dist/api/files.js +0 -141
  41. package/dist/api/files.js.map +0 -1
  42. package/dist/api/shares.d.ts +0 -29
  43. package/dist/api/shares.d.ts.map +0 -1
  44. package/dist/api/shares.js +0 -52
  45. package/dist/api/shares.js.map +0 -1
  46. package/src/api/conversations.ts +0 -214
  47. package/src/api/files.ts +0 -179
  48. package/src/api/shares.ts +0 -65
@@ -1,172 +0,0 @@
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 { 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
@@ -1 +0,0 @@
1
- {"version":3,"file":"conversations.js","sourceRoot":"","sources":["../../src/api/conversations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAcH,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC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AK,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"}
@@ -1,61 +0,0 @@
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
@@ -1 +0,0 @@
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"}
package/dist/api/files.js DELETED
@@ -1,141 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"files.js","sourceRoot":"","sources":["../../src/api/files.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAWH,OAAO,EAAa,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAYpE,sDAAsD;AACtD,MAAM,OAAO,kBAAkB;IACA;IAA7B,YAA6B,IAAuB;QAAvB,SAAI,GAAJ,IAAI,CAAmB;IAAG,CAAC;IAExD;;;;OAIG;IACH,IAAI,CAAC,MAAc,EAAE,MAAmB;QACtC,OAAO,cAA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ares client for the browser (`/v1/shares`).
3
- *
4
- * Read-sharing grants for files and conversations: `create` / `list` / `get` /
5
- * `delete` (revoke). A grant carries a `url` (with the `?share_id` capability) —
6
- * read the shared resource via `client.files.get(id, { shareId })` or
7
- * `client.conversations.items(id, { shareId })`. To fork a new task from a
8
- * shared conversation, pass `fork_share_id` to `client.tasks.create(...)`.
9
- */
10
- import type { ResourceShare, ShareCreateParams, ShareListParams } from "@introspection-sdk/types";
11
- import { Paginator } from "@introspection-sdk/http";
12
- import { BrowserHttpClient } from "./http.js";
13
- /** Cookie-authenticated `/v1/shares` client. */
14
- export declare class SharesClient {
15
- private readonly http;
16
- constructor(http: BrowserHttpClient);
17
- /**
18
- * List grants the caller created or that target them. `await` for the first
19
- * page, or `for await` to stream every grant across pages.
20
- */
21
- list(params?: ShareListParams): Paginator<ResourceShare>;
22
- /** Create a read-sharing grant. The caller must own the target resource. */
23
- create(body: ShareCreateParams): Promise<ResourceShare>;
24
- /** Read a single grant (carries the `url` to the shared resource). */
25
- get(shareId: string): Promise<ResourceShare>;
26
- /** Revoke a grant. Only the grantor (or an admin/owner) may revoke. */
27
- delete(shareId: string): Promise<void>;
28
- }
29
- //# sourceMappingURL=shares.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"shares.d.ts","sourceRoot":"","sources":["../../src/api/shares.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAEV,aAAa,EACb,iBAAiB,EACjB,eAAe,EAChB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,SAAS,EAAkB,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE9C,gDAAgD;AAChD,qBAAa,YAAY;IACX,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,iBAAiB;IAEpD;;;OAGG;IACH,IAAI,CAAC,MAAM,CAAC,EAAE,eAAe,GAAG,SAAS,CAAC,aAAa,CAAC;IAYxD,4EAA4E;IAC5E,MAAM,CAAC,IAAI,EAAE,iBAAiB,GAAG,OAAO,CAAC,aAAa,CAAC;IAQvD,sEAAsE;IACtE,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAO5C,uEAAuE;IACvE,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAOvC"}
@@ -1,52 +0,0 @@
1
- /**
2
- * Cookie-authenticated Resource Shares client for the browser (`/v1/shares`).
3
- *
4
- * Read-sharing grants for files and conversations: `create` / `list` / `get` /
5
- * `delete` (revoke). A grant carries a `url` (with the `?share_id` capability) —
6
- * read the shared resource via `client.files.get(id, { shareId })` or
7
- * `client.conversations.items(id, { shareId })`. To fork a new task from a
8
- * shared conversation, pass `fork_share_id` to `client.tasks.create(...)`.
9
- */
10
- import { cursorPaginate } from "@introspection-sdk/http";
11
- /** Cookie-authenticated `/v1/shares` client. */
12
- export class SharesClient {
13
- http;
14
- constructor(http) {
15
- this.http = http;
16
- }
17
- /**
18
- * List grants the caller created or that target them. `await` for the first
19
- * page, or `for await` to stream every grant across pages.
20
- */
21
- list(params) {
22
- return cursorPaginate((next) => this.http.request({
23
- method: "GET",
24
- path: "/v1/shares",
25
- query: { ...params, next },
26
- }), params?.next);
27
- }
28
- /** Create a read-sharing grant. The caller must own the target resource. */
29
- create(body) {
30
- return this.http.request({
31
- method: "POST",
32
- path: "/v1/shares",
33
- body,
34
- });
35
- }
36
- /** Read a single grant (carries the `url` to the shared resource). */
37
- get(shareId) {
38
- return this.http.request({
39
- method: "GET",
40
- path: `/v1/shares/${encodeURIComponent(shareId)}`,
41
- });
42
- }
43
- /** Revoke a grant. Only the grantor (or an admin/owner) may revoke. */
44
- delete(shareId) {
45
- return this.http.request({
46
- method: "DELETE",
47
- path: `/v1/shares/${encodeURIComponent(shareId)}`,
48
- expect: "empty",
49
- });
50
- }
51
- }
52
- //# sourceMappingURL=shares.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"shares.js","sourceRoot":"","sources":["../../src/api/shares.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAQH,OAAO,EAAa,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAGpE,gDAAgD;AAChD,MAAM,OAAO,YAAY;IACM;IAA7B,YAA6B,IAAuB;QAAvB,SAAI,GAAJ,IAAI,CAAmB;IAAG,CAAC;IAExD;;;OAGG;IACH,IAAI,CAAC,MAAwB;QAC3B,OAAO,cAAc,CACnB,CAAC,IAAI,EAAE,EAAE,CACP,IAAI,CAAC,IAAI,CAAC,OAAO,CAA2B;YAC1C,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,YAAY;YAClB,KAAK,EAAE,EAAE,GAAG,MAAM,EAAE,IAAI,EAA6B;SACtD,CAAC,EACJ,MAAM,EAAE,IAAI,CACb,CAAC;IACJ,CAAC;IAED,4EAA4E;IAC5E,MAAM,CAAC,IAAuB;QAC5B,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAgB;YACtC,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,YAAY;YAClB,IAAI;SACL,CAAC,CAAC;IACL,CAAC;IAED,sEAAsE;IACtE,GAAG,CAAC,OAAe;QACjB,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAgB;YACtC,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,cAAc,kBAAkB,CAAC,OAAO,CAAC,EAAE;SAClD,CAAC,CAAC;IACL,CAAC;IAED,uEAAuE;IACvE,MAAM,CAAC,OAAe;QACpB,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAO;YAC7B,MAAM,EAAE,QAAQ;YAChB,IAAI,EAAE,cAAc,kBAAkB,CAAC,OAAO,CAAC,EAAE;YACjD,MAAM,EAAE,OAAO;SAChB,CAAC,CAAC;IACL,CAAC;CACF"}