@introspection-sdk/introspection-browser 0.5.3 → 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 (43) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/README.md +45 -33
  3. package/dist/api/client.d.ts +35 -12
  4. package/dist/api/client.d.ts.map +1 -1
  5. package/dist/api/client.js +81 -17
  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 +13 -12
  12. package/dist/api/index.d.ts.map +1 -1
  13. package/dist/api/index.js +12 -11
  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 +15 -48
  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 +133 -22
  29. package/src/api/http.ts +56 -0
  30. package/src/api/index.ts +46 -15
  31. package/src/api/runner.ts +127 -0
  32. package/src/api/runtimes.ts +32 -0
  33. package/src/api/tasks.ts +25 -160
  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 -145
  41. package/dist/api/files.js.map +0 -1
  42. package/src/api/conversations.ts +0 -214
  43. package/src/api/files.ts +0 -196
package/src/api/http.ts CHANGED
@@ -35,6 +35,8 @@ export interface BrowserHttpConfig {
35
35
  onUnauthorized?: () => Promise<boolean>;
36
36
  }
37
37
 
38
+ export type BrowserApiHttpClient = Pick<BaseHttpClient, "request" | "stream">;
39
+
38
40
  /**
39
41
  * Cookie-authenticated HTTP wrapper bound to one DP endpoint. Has no
40
42
  * opinion about which resource it serves — the caller picks the path.
@@ -53,3 +55,57 @@ export class BrowserHttpClient extends BaseHttpClient {
53
55
  });
54
56
  }
55
57
  }
58
+
59
+ export interface BrowserBearerHttpConfig {
60
+ /** REST base URL every request is prefixed with. */
61
+ apiUrl: string;
62
+ /** Bearer token, or a provider returning the latest token before each request. */
63
+ token: string | (() => string | Promise<string>);
64
+ /** Extra headers merged into every request. */
65
+ additionalHeaders?: Record<string, string>;
66
+ /** Custom `fetch` (for tests or non-standard runtimes). */
67
+ fetch?: typeof fetch;
68
+ }
69
+
70
+ /**
71
+ * Bearer-authenticated browser HTTP wrapper. Used for CP runtime calls with
72
+ * brokered access tokens and for DP runner calls with CP-minted runner tokens.
73
+ */
74
+ export class BrowserBearerHttpClient extends BaseHttpClient {
75
+ private readonly tokenBox: { value: string };
76
+ private readonly getToken?: () => string | Promise<string>;
77
+
78
+ constructor(cfg: BrowserBearerHttpConfig) {
79
+ const tokenBox = { value: typeof cfg.token === "string" ? cfg.token : "" };
80
+ super({
81
+ apiUrl: cfg.apiUrl,
82
+ additionalHeaders: cfg.additionalHeaders,
83
+ fetch: cfg.fetch,
84
+ transport: {
85
+ authHeaders: (): Record<string, string> => {
86
+ if (!tokenBox.value) return {};
87
+ return { Authorization: `Bearer ${tokenBox.value}` };
88
+ },
89
+ },
90
+ });
91
+ this.tokenBox = tokenBox;
92
+ this.getToken = typeof cfg.token === "function" ? cfg.token : undefined;
93
+ }
94
+
95
+ private async refreshToken(): Promise<void> {
96
+ if (!this.getToken) return;
97
+ this.tokenBox.value = await this.getToken();
98
+ }
99
+
100
+ async request<T>(opts: Parameters<BaseHttpClient["request"]>[0]): Promise<T> {
101
+ await this.refreshToken();
102
+ return super.request<T>(opts);
103
+ }
104
+
105
+ async stream(
106
+ opts: Parameters<BaseHttpClient["stream"]>[0],
107
+ ): Promise<Response> {
108
+ await this.refreshToken();
109
+ return super.stream(opts);
110
+ }
111
+ }
package/src/api/index.ts CHANGED
@@ -11,18 +11,18 @@
11
11
  * import { IntrospectionApiClient } from "@introspection-sdk/introspection-browser/api";
12
12
  *
13
13
  * const client = new IntrospectionApiClient({
14
- * dpUrl: "https://dp.us.introspection.dev",
15
- * projectId: "proj_…",
16
- * // your backend mints the Introspection access token
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
17
  * getToken: () => fetch("/api/introspection/token").then((r) => r.text()),
18
18
  * });
19
19
  *
20
- * await client.connect(); // → intro_dp_session cookie
21
- * const run = await client.tasks.start({
22
- * prompt: "Summarize my latest order",
23
- * agent_name: "support-agent",
20
+ * const runner = await client.runtimes("support-agent").run({
24
21
  * identity: { user_id: "u_42" },
25
22
  * });
23
+ * const run = await runner.tasks.start({
24
+ * prompt: "Summarize my latest order",
25
+ * });
26
26
  * for await (const ev of run.stream()) console.log(ev.event, ev.data);
27
27
  * ```
28
28
  */
@@ -31,6 +31,20 @@ export {
31
31
  IntrospectionApiClient,
32
32
  type IntrospectionApiClientOptions,
33
33
  } from "./client.js";
34
+ export {
35
+ BrowserRunner,
36
+ Runner,
37
+ type BrowserRunnerOwner,
38
+ type BrowserRunnerSource,
39
+ } from "./runner.js";
40
+ export {
41
+ BrowserRuntimesClient,
42
+ BrowserRuntimeHandle,
43
+ attachBrowserRuntimes,
44
+ isUuid,
45
+ type BrowserRuntimeHandleFactory,
46
+ type BrowserRuntimeRunRequestBody,
47
+ } from "./runtimes.js";
34
48
  export {
35
49
  TasksClient,
36
50
  TaskRunsClient,
@@ -39,15 +53,20 @@ export {
39
53
  type StartTaskParams,
40
54
  } from "./tasks.js";
41
55
  export {
42
- FilesClient,
56
+ ConversationItemsClient,
57
+ ConversationsClient,
43
58
  FileVersionsClient,
59
+ FilesClient,
60
+ SharesClient,
44
61
  type FileUploadBody,
45
- } from "./files.js";
62
+ } from "@introspection-sdk/http";
46
63
  export {
47
- ConversationsClient,
48
- ConversationItemsClient,
49
- } from "./conversations.js";
50
- export { BrowserHttpClient, type BrowserHttpConfig } from "./http.js";
64
+ BrowserBearerHttpClient,
65
+ BrowserHttpClient,
66
+ type BrowserApiHttpClient,
67
+ type BrowserBearerHttpConfig,
68
+ type BrowserHttpConfig,
69
+ } from "./http.js";
51
70
  export { parseSse } from "./sse.js";
52
71
  export {
53
72
  Paginator,
@@ -60,7 +79,6 @@ export type {
60
79
  Task,
61
80
  TaskRun,
62
81
  TaskStatus,
63
- TaskVisibility,
64
82
  TaskCreateResponse,
65
83
  TaskListParams,
66
84
  TaskUpdateParams,
@@ -74,7 +92,6 @@ export type {
74
92
  FileListParams,
75
93
  FileUpdateParams,
76
94
  FileCreateTextParams,
77
- FileCreateOptions,
78
95
  ListParams,
79
96
  ConversationSummary,
80
97
  ConversationItem,
@@ -83,6 +100,19 @@ export type {
83
100
  ConversationItemListParams,
84
101
  ConversationItemInclude,
85
102
  ConversationResponse,
103
+ ResourceShare,
104
+ ShareResourceType,
105
+ ShareCreateParams,
106
+ ShareListParams,
107
+ Recipe,
108
+ RunRequest,
109
+ RunnerContext,
110
+ RunnerDeployment,
111
+ RunnerSpec,
112
+ Runtime,
113
+ RuntimeCreate,
114
+ RuntimeListParams,
115
+ RuntimeUpdate,
86
116
  } from "@introspection-sdk/types";
87
117
  export {
88
118
  IntrospectionAPIError,
@@ -90,4 +120,5 @@ export {
90
120
  InsufficientScopeError,
91
121
  NotFoundError,
92
122
  NetworkError,
123
+ RunnerExpiredError,
93
124
  } from "@introspection-sdk/types";
@@ -0,0 +1,127 @@
1
+ import {
2
+ RunnerExpiredError,
3
+ type RunnerContext,
4
+ type RunnerDeployment,
5
+ type RunnerSpec,
6
+ type RunRequest,
7
+ type Uuid,
8
+ } from "@introspection-sdk/types";
9
+ import {
10
+ ConversationsClient,
11
+ FilesClient,
12
+ SharesClient,
13
+ TasksClient,
14
+ } from "@introspection-sdk/http";
15
+ import { BrowserBearerHttpClient } from "./http.js";
16
+
17
+ export type BrowserRunnerSource =
18
+ | { kind: "runtime"; id: Uuid; options?: RunRequest }
19
+ | { kind: "experiment"; id: Uuid; options?: RunRequest };
20
+
21
+ export interface BrowserRunnerOwner {
22
+ readonly additionalHeaders?: Record<string, string>;
23
+ readonly fetch?: typeof fetch;
24
+ requestFreshRunnerSpec(source: BrowserRunnerSource): Promise<RunnerSpec>;
25
+ }
26
+
27
+ /**
28
+ * Browser-side live handle to a Data Plane runner. Mirrors the Node Runner
29
+ * shape but uses browser-safe fetch transport and CP-minted bearer tokens.
30
+ */
31
+ export class BrowserRunner {
32
+ private spec: RunnerSpec;
33
+ private http: BrowserBearerHttpClient;
34
+ private closed = false;
35
+
36
+ readonly tasks: TasksClient;
37
+ readonly files: FilesClient;
38
+ readonly conversations: ConversationsClient;
39
+ readonly shares: SharesClient;
40
+
41
+ constructor(
42
+ private readonly owner: BrowserRunnerOwner,
43
+ private readonly source: BrowserRunnerSource,
44
+ spec: RunnerSpec,
45
+ ) {
46
+ this.spec = spec;
47
+ this.http = this.buildHttp(spec);
48
+ const guarded = this.guardedHttp();
49
+ this.tasks = new TasksClient(guarded);
50
+ this.files = new FilesClient(guarded);
51
+ this.conversations = new ConversationsClient(guarded);
52
+ this.shares = new SharesClient(guarded);
53
+ }
54
+
55
+ get dpEndpoint(): string {
56
+ return this.spec.deployment.endpoint;
57
+ }
58
+
59
+ get deployment(): Readonly<RunnerDeployment> {
60
+ return Object.freeze({ ...this.spec.deployment });
61
+ }
62
+
63
+ get expires_at(): string {
64
+ return this.spec.expires_at;
65
+ }
66
+
67
+ get session_id(): string {
68
+ return this.spec.session_id;
69
+ }
70
+
71
+ get context(): Readonly<RunnerContext> {
72
+ return Object.freeze({ ...this.spec.runtime_context });
73
+ }
74
+
75
+ get isClosed(): boolean {
76
+ return this.closed;
77
+ }
78
+
79
+ async refresh(): Promise<void> {
80
+ this.assertOpen();
81
+ const fresh = await this.owner.requestFreshRunnerSpec(this.source);
82
+ this.spec = fresh;
83
+ this.http = this.buildHttp(fresh);
84
+ }
85
+
86
+ async close(): Promise<void> {
87
+ this.closed = true;
88
+ }
89
+
90
+ private buildHttp(spec: RunnerSpec): BrowserBearerHttpClient {
91
+ return new BrowserBearerHttpClient({
92
+ apiUrl: spec.deployment.endpoint,
93
+ token: spec.session_token,
94
+ additionalHeaders: this.owner.additionalHeaders,
95
+ fetch: this.owner.fetch,
96
+ });
97
+ }
98
+
99
+ private guardedHttp(): BrowserBearerHttpClient {
100
+ const proxy: BrowserBearerHttpClient = Object.create(this.http);
101
+ proxy.request = async <T>(
102
+ opts: Parameters<BrowserBearerHttpClient["request"]>[0],
103
+ ): Promise<T> => {
104
+ this.assertOpen();
105
+ return this.http.request<T>(opts);
106
+ };
107
+ proxy.stream = async (
108
+ opts: Parameters<BrowserBearerHttpClient["stream"]>[0],
109
+ ): Promise<Response> => {
110
+ this.assertOpen();
111
+ return this.http.stream(opts);
112
+ };
113
+ return proxy;
114
+ }
115
+
116
+ private assertOpen(): void {
117
+ if (this.closed) {
118
+ throw new RunnerExpiredError({
119
+ message: "Runner has been closed",
120
+ status: 401,
121
+ code: "runner_expired",
122
+ });
123
+ }
124
+ }
125
+ }
126
+
127
+ export { BrowserRunner as Runner };
@@ -0,0 +1,32 @@
1
+ import {
2
+ RuntimeHandle,
3
+ RuntimesClient,
4
+ attachRuntimes,
5
+ isUuid,
6
+ type RuntimeHandleFactory,
7
+ type RuntimeRunRequestBody,
8
+ } from "@introspection-sdk/http";
9
+ import type { BrowserApiHttpClient } from "./http.js";
10
+ import { BrowserRunner, type BrowserRunnerOwner } from "./runner.js";
11
+
12
+ export { isUuid };
13
+ export type { RuntimeRunRequestBody as BrowserRuntimeRunRequestBody };
14
+
15
+ export class BrowserRuntimesClient extends RuntimesClient<BrowserRunner> {
16
+ constructor(http: BrowserApiHttpClient, owner: BrowserRunnerOwner) {
17
+ super(http, (source, spec) => new BrowserRunner(owner, source, spec));
18
+ }
19
+ }
20
+
21
+ export { RuntimeHandle as BrowserRuntimeHandle };
22
+
23
+ export type BrowserRuntimeHandleFactory = RuntimeHandleFactory<BrowserRunner>;
24
+
25
+ export function attachBrowserRuntimes(
26
+ http: BrowserApiHttpClient,
27
+ owner: BrowserRunnerOwner,
28
+ ): BrowserRuntimesClient & BrowserRuntimeHandleFactory {
29
+ const api = new BrowserRuntimesClient(http, owner);
30
+ return attachRuntimes(api) as BrowserRuntimesClient &
31
+ BrowserRuntimeHandleFactory;
32
+ }
package/src/api/tasks.ts CHANGED
@@ -1,20 +1,10 @@
1
- import type {
2
- Paginated,
3
- RunIdentityInput,
4
- SseEvent,
5
- Task,
6
- TaskCancelResponse,
7
- TaskCreateResponse,
8
- TaskListParams,
9
- TaskRun,
10
- TaskRunCreateParams,
11
- TaskRunResponse,
12
- TaskUpdateParams,
13
- TaskVisibility,
14
- } from "@introspection-sdk/types";
15
- import { Paginator, cursorPaginate } from "@introspection-sdk/http";
16
- import { BrowserHttpClient } from "./http.js";
17
- import { parseSse } from "./sse.js";
1
+ import type { RunIdentityInput } from "@introspection-sdk/types";
2
+ import {
3
+ RunHandle,
4
+ TaskRunsClient,
5
+ TasksClient as SharedTasksClient,
6
+ type ResourceHttpClient,
7
+ } from "@introspection-sdk/http";
18
8
 
19
9
  /**
20
10
  * Body for creating a task directly against the DP from the browser.
@@ -34,7 +24,6 @@ export interface CreateTaskParams {
34
24
  agent_name?: string;
35
25
  title?: string;
36
26
  metadata?: Record<string, unknown>;
37
- visibility?: TaskVisibility;
38
27
  /**
39
28
  * Override the interactive idle window (seconds) before the sandbox is
40
29
  * torn down. `0` tears down as soon as it's provisioned; omit to use the
@@ -43,6 +32,13 @@ export interface CreateTaskParams {
43
32
  idle_timeout_seconds?: number;
44
33
  /** Caller identity for attribution; merged into `metadata.identity`. */
45
34
  identity?: RunIdentityInput;
35
+ /**
36
+ * Fork from a shared conversation: the `/v1/shares` grant id for the source
37
+ * conversation. Its presence makes this create a fork — the server seeds the
38
+ * new task with that conversation's history, read via the share (the
39
+ * permissions boundary).
40
+ */
41
+ fork_share_id?: string;
46
42
  }
47
43
 
48
44
  export interface StartTaskParams extends CreateTaskParams {
@@ -60,149 +56,18 @@ function toTaskBody(params: CreateTaskParams): Record<string, unknown> {
60
56
  return body;
61
57
  }
62
58
 
63
- /** Live handle on a task's run: stream its events, collect text, cancel. */
64
- export class RunHandle {
65
- constructor(
66
- public readonly task: Task | null,
67
- public readonly run: TaskRun,
68
- private readonly runs: TaskRunsClient,
69
- ) {}
70
-
71
- stream(): AsyncIterable<SseEvent> {
72
- return this.runs.stream(this.run.task_id, this.run.id);
73
- }
74
-
75
- cancel(): Promise<TaskCancelResponse> {
76
- return this.runs.cancel(this.run.task_id, this.run.id);
77
- }
78
-
79
- /** Convenience: concatenate `data` from `text`/`message` SSE frames. */
80
- async text(): Promise<string> {
81
- let out = "";
82
- for await (const ev of this.stream()) {
83
- if (ev.event === "text" || ev.event === "message") out += ev.data;
84
- }
85
- return out;
86
- }
87
- }
88
-
89
- export class TaskRunsClient {
90
- constructor(private readonly http: BrowserHttpClient) {}
91
-
92
- async create(taskId: string, body: TaskRunCreateParams): Promise<RunHandle> {
93
- const res = await this.http.request<TaskRunResponse>({
94
- method: "POST",
95
- path: `/v1/tasks/${encodeURIComponent(taskId)}/runs`,
96
- body,
97
- });
98
- return new RunHandle(null, res.run, this);
99
- }
100
-
101
- get(taskId: string, runId: string): Promise<TaskRun> {
102
- return this.http.request<TaskRun>({
103
- method: "GET",
104
- path: `/v1/tasks/${encodeURIComponent(taskId)}/runs/${encodeURIComponent(runId)}`,
105
- });
106
- }
107
-
108
- cancel(taskId: string, runId: string): Promise<TaskCancelResponse> {
109
- return this.http.request<TaskCancelResponse>({
110
- method: "POST",
111
- path: `/v1/tasks/${encodeURIComponent(taskId)}/runs/${encodeURIComponent(runId)}/cancel`,
112
- });
113
- }
114
-
115
- async *stream(taskId: string, runId: string): AsyncIterable<SseEvent> {
116
- const res = await this.http.stream({
117
- path: `/v1/tasks/${encodeURIComponent(taskId)}/runs/${encodeURIComponent(runId)}/stream`,
118
- });
119
- yield* parseSse(res);
120
- }
121
- }
122
-
123
59
  /**
124
- * Cookie-authenticated `/v1/tasks` client. Mirrors the Node SDK's
125
- * `TasksApi` shape but is bound to a DP session cookie rather than a
126
- * bearer token, and lets the caller select the agent on create.
60
+ * Cookie-authenticated `/v1/tasks` client. The implementation is shared with
61
+ * Node's runner-bound task client; this browser subclass only adds the
62
+ * `identity -> metadata.identity` body mapping used by cookie-session calls.
127
63
  */
128
- export class TasksClient {
129
- readonly runs: TaskRunsClient;
130
-
131
- constructor(private readonly http: BrowserHttpClient) {
132
- this.runs = new TaskRunsClient(http);
133
- }
134
-
135
- /**
136
- * Tasks matching `params`. `await` it for the first page (preserving
137
- * the wire envelope's counts + `next` cursor), or `for await` it to
138
- * stream every task across pages (fetched lazily — `limit` sets the
139
- * page size, `next` the starting cursor; stop early to stop fetching).
140
- *
141
- * Mirrors the Node SDK's `TasksApi.list`, which is the source of truth
142
- * for the `/v1/tasks` shape.
143
- */
144
- list(params?: TaskListParams): Paginator<Task> {
145
- return cursorPaginate(
146
- (next) =>
147
- this.http.request<Paginated<Task>>({
148
- method: "GET",
149
- path: "/v1/tasks",
150
- query: { ...params, next } as Record<string, unknown>,
151
- }),
152
- params?.next,
153
- );
154
- }
155
-
156
- create(body: CreateTaskParams): Promise<TaskCreateResponse> {
157
- return this.http.request<TaskCreateResponse>({
158
- method: "POST",
159
- path: "/v1/tasks",
160
- body: toTaskBody(body),
161
- });
162
- }
163
-
164
- get(taskId: string): Promise<Task> {
165
- return this.http.request<Task>({
166
- method: "GET",
167
- path: `/v1/tasks/${encodeURIComponent(taskId)}`,
168
- });
169
- }
170
-
171
- update(taskId: string, body: TaskUpdateParams): Promise<Task> {
172
- return this.http.request<Task>({
173
- method: "PATCH",
174
- path: `/v1/tasks/${encodeURIComponent(taskId)}`,
175
- body,
176
- });
177
- }
178
-
179
- delete(taskId: string): Promise<void> {
180
- return this.http.request<void>({
181
- method: "DELETE",
182
- path: `/v1/tasks/${encodeURIComponent(taskId)}`,
183
- expect: "empty",
184
- });
185
- }
186
-
187
- archive(taskId: string): Promise<void> {
188
- return this.http.request<void>({
189
- method: "POST",
190
- path: `/v1/tasks/${encodeURIComponent(taskId)}/archive`,
191
- expect: "empty",
192
- });
193
- }
194
-
195
- unarchive(taskId: string): Promise<void> {
196
- return this.http.request<void>({
197
- method: "POST",
198
- path: `/v1/tasks/${encodeURIComponent(taskId)}/unarchive`,
199
- expect: "empty",
200
- });
201
- }
202
-
203
- /** Sugar: create a task + return a handle on its initial run. */
204
- async start(params: StartTaskParams): Promise<RunHandle> {
205
- const res = await this.create(params);
206
- return new RunHandle(res.task, res.run, this.runs);
64
+ export class TasksClient extends SharedTasksClient<
65
+ CreateTaskParams,
66
+ StartTaskParams
67
+ > {
68
+ constructor(http: ResourceHttpClient) {
69
+ super(http, toTaskBody);
207
70
  }
208
71
  }
72
+
73
+ export { RunHandle, TaskRunsClient };
@@ -1,84 +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 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
@@ -1 +0,0 @@
1
- {"version":3,"file":"conversations.d.ts","sourceRoot":"","sources":["../../src/api/conversations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EACV,gBAAgB,EAChB,uBAAuB,EACvB,oBAAoB,EACpB,0BAA0B,EAC1B,sBAAsB,EACtB,oBAAoB,EACpB,mBAAmB,EAIpB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,SAAS,EAAkB,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAS9C;;;;;;GAMG;AACH,qBAAa,uBAAuB;IACtB,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,iBAAiB;IAEpD;;;;;;;;;;OAUG;IACH,IAAI,CACF,cAAc,EAAE,MAAM,EACtB,MAAM,CAAC,EAAE,0BAA0B,GAClC,SAAS,CAAC,gBAAgB,EAAE,oBAAoB,CAAC;IAiBpD;;;OAGG;IACH,GAAG,CACD,cAAc,EAAE,MAAM,EACtB,MAAM,EAAE,MAAM,EACd,MAAM,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,uBAAuB,EAAE,CAAA;KAAE,GAC/C,OAAO,CAAC,gBAAgB,CAAC;CAO7B;AAED;;;;;;;;GAQG;AACH,qBAAa,mBAAmB;IAIlB,OAAO,CAAC,QAAQ,CAAC,IAAI;IAHjC,qEAAqE;IACrE,QAAQ,CAAC,KAAK,EAAE,uBAAuB,CAAC;gBAEX,IAAI,EAAE,iBAAiB;IAIpD;;;;;OAKG;IACH,IAAI,CAAC,MAAM,CAAC,EAAE,sBAAsB,GAAG,SAAS,CAAC,mBAAmB,CAAC;IAYrE;;;;;;;;;;;;;OAaG;IACG,QAAQ,CACZ,cAAc,EAAE,MAAM,EACtB,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;IA6BvC,mEAAmE;YACrD,gBAAgB;CAc/B"}