@introspection-sdk/introspection-node 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 (37) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/dist/client.d.ts +3 -4
  3. package/dist/client.d.ts.map +1 -1
  4. package/dist/client.js +3 -6
  5. package/dist/client.js.map +1 -1
  6. package/dist/index.d.ts +2 -5
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +1 -3
  9. package/dist/index.js.map +1 -1
  10. package/dist/resources/runtimes.d.ts +4 -74
  11. package/dist/resources/runtimes.d.ts.map +1 -1
  12. package/dist/resources/runtimes.js +5 -169
  13. package/dist/resources/runtimes.js.map +1 -1
  14. package/dist/runner.d.ts +2 -3
  15. package/dist/runner.d.ts.map +1 -1
  16. package/dist/runner.js +3 -3
  17. package/dist/runner.js.map +1 -1
  18. package/package.json +7 -7
  19. package/src/client.ts +3 -6
  20. package/src/index.ts +9 -6
  21. package/src/resources/runtimes.ts +14 -217
  22. package/src/runner.ts +8 -3
  23. package/dist/runner-resources/conversations.d.ts +0 -73
  24. package/dist/runner-resources/conversations.d.ts.map +0 -1
  25. package/dist/runner-resources/conversations.js +0 -161
  26. package/dist/runner-resources/conversations.js.map +0 -1
  27. package/dist/runner-resources/files.d.ts +0 -45
  28. package/dist/runner-resources/files.d.ts.map +0 -1
  29. package/dist/runner-resources/files.js +0 -129
  30. package/dist/runner-resources/files.js.map +0 -1
  31. package/dist/runner-resources/tasks.d.ts +0 -45
  32. package/dist/runner-resources/tasks.d.ts.map +0 -1
  33. package/dist/runner-resources/tasks.js +0 -127
  34. package/dist/runner-resources/tasks.js.map +0 -1
  35. package/src/runner-resources/conversations.ts +0 -202
  36. package/src/runner-resources/files.ts +0 -179
  37. package/src/runner-resources/tasks.ts +0 -158
@@ -1,234 +1,31 @@
1
- import type {
2
- Paginated,
3
- Recipe,
4
- RunRequest,
5
- Runtime,
6
- RuntimeCreate,
7
- RuntimeListParams,
8
- RuntimeUpdate,
9
- RunnerSpec,
10
- Uuid,
11
- } from "@introspection-sdk/types";
12
- import { NotFoundError } from "@introspection-sdk/types";
1
+ import {
2
+ RuntimeHandle,
3
+ RuntimesClient,
4
+ attachRuntimes as attachSharedRuntimes,
5
+ isUuid,
6
+ type RuntimeHandleFactory as SharedRuntimeHandleFactory,
7
+ } from "@introspection-sdk/http";
13
8
  import type { HttpClient } from "../http.js";
14
9
  import type { IntrospectionClient } from "../client.js";
15
- import { Paginator, cursorPaginate } from "../pagination.js";
16
- import { Runner, type RunnerSource } from "../runner.js";
10
+ import { Runner } from "../runner.js";
17
11
 
18
- const UUID_RE =
19
- /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
12
+ export { RuntimeHandle, isUuid };
20
13
 
21
- export function isUuid(value: string): boolean {
22
- return UUID_RE.test(value);
23
- }
24
-
25
- export interface RuntimeRunRequestBody {
26
- identity?: {
27
- user_id?: string;
28
- anonymous_id?: string;
29
- conversation_id?: string;
30
- };
31
- ttl_seconds?: number;
32
- recipe_id?: Uuid;
33
- }
34
-
35
- function toRunBody(opts?: RunRequest): RuntimeRunRequestBody | undefined {
36
- if (!opts) return undefined;
37
- const out: RuntimeRunRequestBody = {};
38
- if (opts.identity) out.identity = opts.identity;
39
- if (opts.ttl_seconds !== undefined) out.ttl_seconds = opts.ttl_seconds;
40
- if (opts.recipe_id !== undefined) out.recipe_id = opts.recipe_id;
41
- return out;
42
- }
43
-
44
- /**
45
- * Programmatic CRUD for `/v1/runtimes` on the CP. Mounted on the
46
- * IntrospectionClient as a callable hybrid (see `RuntimeHandleFactory`).
47
- */
48
- export class RuntimesApi {
14
+ export class RuntimesApi extends RuntimesClient<Runner> {
49
15
  constructor(
50
- private readonly http: HttpClient,
16
+ http: HttpClient,
51
17
  private readonly client: IntrospectionClient,
52
- ) {}
53
-
54
- /**
55
- * List runtimes matching `params`. `await` the result for the first
56
- * page, or `for await` it to stream every runtime across pages (fetched
57
- * lazily — `limit` sets the page size, `next` the starting cursor; stop
58
- * early to stop fetching).
59
- */
60
- list(params: RuntimeListParams): Paginator<Runtime> {
61
- return cursorPaginate(
62
- (next) =>
63
- this.http.request<Paginated<Runtime>>({
64
- method: "GET",
65
- path: "/v1/runtimes",
66
- query: { ...params, next } as unknown as Record<string, unknown>,
67
- }),
68
- params.next,
69
- );
70
- }
71
-
72
- get(id: Uuid, params: { project_id?: Uuid }): Promise<Runtime> {
73
- return this.http.request<Runtime>({
74
- method: "GET",
75
- path: `/v1/runtimes/${encodeURIComponent(id)}`,
76
- query: params as Record<string, unknown>,
77
- });
78
- }
79
-
80
- create(input: RuntimeCreate): Promise<Runtime> {
81
- return this.http.request<Runtime>({
82
- method: "POST",
83
- path: "/v1/runtimes",
84
- body: input,
85
- });
86
- }
87
-
88
- update(id: Uuid, input: RuntimeUpdate): Promise<Runtime> {
89
- return this.http.request<Runtime>({
90
- method: "PATCH",
91
- path: `/v1/runtimes/${encodeURIComponent(id)}`,
92
- body: input,
93
- });
94
- }
95
-
96
- delete(id: Uuid): Promise<void> {
97
- return this.http.request<void>({
98
- method: "DELETE",
99
- path: `/v1/runtimes/${encodeURIComponent(id)}`,
100
- expect: "empty",
101
- });
102
- }
103
-
104
- /** Resolve a name to a runtime by querying `/v1/runtimes?name=…`. */
105
- async resolveByName(name: string, projectId?: Uuid): Promise<Runtime> {
106
- for await (const r of this.list({
107
- project_id: projectId,
108
- name,
109
- limit: 2,
110
- })) {
111
- if (r.name === name) return r;
112
- }
113
- throw new NotFoundError({
114
- message: `Runtime '${name}' not found${projectId ? ` in project ${projectId}` : ""}`,
115
- status: 404,
116
- code: "not_found",
117
- });
118
- }
119
-
120
- /** POST `/v1/runtimes/{id}/run` and wrap the result in a `Runner`. */
121
- async runById(id: Uuid, opts?: RunRequest): Promise<Runner> {
122
- const spec = await this.http.request<RunnerSpec>({
123
- method: "POST",
124
- path: `/v1/runtimes/${encodeURIComponent(id)}/run`,
125
- body: toRunBody(opts) ?? {},
126
- });
127
- const source: RunnerSource = {
128
- kind: "runtime",
129
- id,
130
- options: opts,
131
- };
132
- return new Runner(this.client, source, spec);
133
- }
134
-
135
- async activateById(
136
- id: Uuid,
137
- params?: { project_id?: Uuid },
138
- ): Promise<Runtime> {
139
- return this.http.request<Runtime>({
140
- method: "POST",
141
- path: `/v1/runtimes/${encodeURIComponent(id)}/activate`,
142
- query: params as Record<string, unknown> | undefined,
143
- body: {},
144
- });
145
- }
146
- }
147
-
148
- /**
149
- * Handle returned by `client.runtimes(idOrName)`. Resolves the underlying
150
- * runtime id lazily — if you pass a UUID, no extra lookup happens; if you
151
- * pass a name, the first call that needs the id will hit
152
- * `/v1/runtimes?name=…`.
153
- */
154
- export class RuntimeHandle {
155
- private resolvedId: Uuid | null;
156
- private readonly pinnedRecipeId: Uuid | null;
157
-
158
- constructor(
159
- private readonly api: RuntimesApi,
160
- private readonly client: IntrospectionClient,
161
- private readonly idOrName: string,
162
- pinnedRecipeId: Uuid | null = null,
163
18
  ) {
164
- this.resolvedId = isUuid(idOrName) ? idOrName : null;
165
- this.pinnedRecipeId = pinnedRecipeId;
166
- }
167
-
168
- private async resolveId(): Promise<Uuid> {
169
- if (this.resolvedId) return this.resolvedId;
170
- const runtime = await this.api.resolveByName(
171
- this.idOrName,
172
- this.client.projectId,
173
- );
174
- this.resolvedId = runtime.id;
175
- return runtime.id;
176
- }
177
-
178
- /**
179
- * Pin to a specific recipe — canary a previous version. Subsequent
180
- * `.run()` calls on the returned handle open a runner against the
181
- * runtime row in this name whose `recipe_id` matches `recipe.id`
182
- * (resolved server-side by CP).
183
- *
184
- * Returns a new child {@link RuntimeHandle}; the original handle is
185
- * unaffected. Accepts a {@link Recipe} object (uses `.id`) or a
186
- * recipe id string.
187
- */
188
- pin(recipe: Recipe | string): RuntimeHandle {
189
- const recipeId = typeof recipe === "string" ? recipe : recipe.id;
190
- return new RuntimeHandle(this.api, this.client, this.idOrName, recipeId);
191
- }
192
-
193
- async run(opts?: RunRequest): Promise<Runner> {
194
- const id = await this.resolveId();
195
- const merged: RunRequest | undefined =
196
- this.pinnedRecipeId !== null
197
- ? { ...(opts ?? {}), recipe_id: this.pinnedRecipeId }
198
- : opts;
199
- return this.api.runById(id, merged);
200
- }
201
-
202
- async activate(params?: { projectId?: Uuid }): Promise<Runtime> {
203
- const id = await this.resolveId();
204
- return this.api.activateById(id, { project_id: params?.projectId });
19
+ super(http, (source, spec) => new Runner(this.client, source, spec));
205
20
  }
206
21
  }
207
22
 
208
- /**
209
- * Callable hybrid: `client.runtimes` exposes the CRUD methods of
210
- * `RuntimesApi` AND can be invoked as a function returning a
211
- * `RuntimeHandle`. Realised by `attachRuntimes` below.
212
- */
213
- export type RuntimeHandleFactory = (idOrName: string) => RuntimeHandle;
23
+ export type RuntimeHandleFactory = SharedRuntimeHandleFactory<Runner>;
214
24
 
215
25
  export function attachRuntimes(
216
26
  client: IntrospectionClient,
217
27
  http: HttpClient,
218
28
  ): RuntimesApi & RuntimeHandleFactory {
219
29
  const api = new RuntimesApi(http, client);
220
- const factory: RuntimeHandleFactory = (idOrName: string) =>
221
- new RuntimeHandle(api, client, idOrName);
222
- // Mount the API methods on the factory function. Using bound copies so
223
- // the methods can be invoked off the proxy without losing `this`.
224
- const hybrid = factory as RuntimesApi & RuntimeHandleFactory;
225
- hybrid.list = api.list.bind(api);
226
- hybrid.get = api.get.bind(api);
227
- hybrid.create = api.create.bind(api);
228
- hybrid.update = api.update.bind(api);
229
- hybrid.delete = api.delete.bind(api);
230
- hybrid.resolveByName = api.resolveByName.bind(api);
231
- hybrid.runById = api.runById.bind(api);
232
- hybrid.activateById = api.activateById.bind(api);
233
- return hybrid;
30
+ return attachSharedRuntimes(api) as RuntimesApi & RuntimeHandleFactory;
234
31
  }
package/src/runner.ts CHANGED
@@ -6,10 +6,13 @@ import {
6
6
  type RunRequest,
7
7
  type Uuid,
8
8
  } from "@introspection-sdk/types";
9
+ import {
10
+ ConversationsApi,
11
+ FilesApi,
12
+ SharesApi,
13
+ TasksApi,
14
+ } from "@introspection-sdk/http";
9
15
  import { HttpClient } from "./http.js";
10
- import { TasksApi } from "./runner-resources/tasks.js";
11
- import { FilesApi } from "./runner-resources/files.js";
12
- import { ConversationsApi } from "./runner-resources/conversations.js";
13
16
  import type { IntrospectionClient } from "./client.js";
14
17
 
15
18
  /**
@@ -41,6 +44,7 @@ export class Runner {
41
44
  readonly tasks: TasksApi;
42
45
  readonly files: FilesApi;
43
46
  readonly conversations: ConversationsApi;
47
+ readonly shares: SharesApi;
44
48
 
45
49
  constructor(
46
50
  private readonly client: IntrospectionClient,
@@ -52,6 +56,7 @@ export class Runner {
52
56
  this.tasks = new TasksApi(this.guardedHttp(this.http));
53
57
  this.files = new FilesApi(this.guardedHttp(this.http));
54
58
  this.conversations = new ConversationsApi(this.guardedHttp(this.http));
59
+ this.shares = new SharesApi(this.guardedHttp(this.http));
55
60
  }
56
61
 
57
62
  // --- public accessors ---
@@ -1,73 +0,0 @@
1
- import type { ConversationItem, ConversationItemInclude, ConversationItemList, ConversationItemListParams, ConversationListParams, ConversationResponse, ConversationSummary } from "@introspection-sdk/types";
2
- import { HttpClient } from "../http.js";
3
- import { Paginator } from "../pagination.js";
4
- /**
5
- * Items of a conversation (`/v1/conversations/{id}/items`). Read-only.
6
- *
7
- * Paging is OpenAI-style underneath: the envelope has NO `next` token —
8
- * `list()` drives `after` = the previous page's `last_id` while
9
- * `has_more` is true.
10
- */
11
- export declare class ConversationItemsApi {
12
- private readonly http;
13
- constructor(http: HttpClient);
14
- /**
15
- * List items of a conversation. `await` the result for the first page
16
- * (an OpenAI-style {@link ConversationItemList} envelope), or
17
- * `for await` it to stream every item across pages (fetched lazily —
18
- * `limit` sets the page size, `after` the starting cursor; stop early to
19
- * stop fetching). Pass `order: "asc"` to walk the transcript from the
20
- * start.
21
- *
22
- * Items carry the turn-local delta in `input_messages` — only the
23
- * messages new to that turn. Use `get()` for the full input history.
24
- */
25
- list(conversationId: string, params?: ConversationItemListParams): Paginator<ConversationItem, ConversationItemList>;
26
- /**
27
- * Fetch a single conversation item. Unlike the list route, the
28
- * detail's `input_messages` is the FULL input history for that span.
29
- */
30
- get(conversationId: string, itemId: string, params?: {
31
- include?: ConversationItemInclude[];
32
- }): Promise<ConversationItem>;
33
- }
34
- /**
35
- * Read-only Conversations API (`/v1/conversations`).
36
- *
37
- * Both `list()` and `items.list()` are auto-paging async generators,
38
- * but they drive different wire protocols underneath: `list()` walks
39
- * the standard Introspection cursor envelope's opaque `next` token,
40
- * while `items.list()` walks an OpenAI-style envelope via `after` =
41
- * the previous page's `last_id` while `has_more` is true.
42
- */
43
- export declare class ConversationsApi {
44
- private readonly http;
45
- /** Items of a conversation — `conversations.items.list(...)` etc. */
46
- readonly items: ConversationItemsApi;
47
- constructor(http: HttpClient);
48
- /**
49
- * List conversation summaries matching `params`. `await` the result for
50
- * the first page, or `for await` it to stream every summary across
51
- * pages (fetched lazily — `limit` sets the page size, `next` the
52
- * starting cursor; stop early to stop fetching).
53
- */
54
- list(params?: ConversationListParams): Paginator<ConversationSummary>;
55
- /**
56
- * Responses-API-style retrieve: load the state of a conversation as of
57
- * one item — the full input history, output, system instructions, and
58
- * tool definitions of that turn.
59
- *
60
- * When `itemId` is omitted, the latest LLM turn is used: the first
61
- * item (in descending order) whose `node_type` is `"assistant"` or
62
- * whose `operation_name` is `"chat"`, falling back to the first item
63
- * with a non-null `output_message`. Returns `null` when the
64
- * conversation has no items.
65
- *
66
- * For the full per-turn transcript instead, iterate
67
- * `items.list(conversationId, { order: "asc" })`.
68
- */
69
- retrieve(conversationId: string, itemId?: string): Promise<ConversationResponse | null>;
70
- /** Scan items in descending order for the most recent LLM turn. */
71
- private findLatestTurnId;
72
- }
73
- //# sourceMappingURL=conversations.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"conversations.d.ts","sourceRoot":"","sources":["../../src/runner-resources/conversations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,uBAAuB,EACvB,oBAAoB,EACpB,0BAA0B,EAC1B,sBAAsB,EACtB,oBAAoB,EACpB,mBAAmB,EAIpB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,SAAS,EAAkB,MAAM,kBAAkB,CAAC;AAS7D;;;;;;GAMG;AACH,qBAAa,oBAAoB;IACnB,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C;;;;;;;;;;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,gBAAgB;IAIf,OAAO,CAAC,QAAQ,CAAC,IAAI;IAHjC,qEAAqE;IACrE,QAAQ,CAAC,KAAK,EAAE,oBAAoB,CAAC;gBAER,IAAI,EAAE,UAAU;IAI7C;;;;;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"}
@@ -1,161 +0,0 @@
1
- import { Paginator, cursorPaginate } from "../pagination.js";
2
- /** Includes requested when building a {@link ConversationResponse}. */
3
- const RESPONSE_INCLUDES = [
4
- "gen_ai.input.messages",
5
- "gen_ai.system_instructions",
6
- "gen_ai.tool.definitions",
7
- ];
8
- /**
9
- * Items of a conversation (`/v1/conversations/{id}/items`). Read-only.
10
- *
11
- * Paging is OpenAI-style underneath: the envelope has NO `next` token —
12
- * `list()` drives `after` = the previous page's `last_id` while
13
- * `has_more` is true.
14
- */
15
- export class ConversationItemsApi {
16
- http;
17
- constructor(http) {
18
- this.http = http;
19
- }
20
- /**
21
- * List items of a conversation. `await` the result for the first page
22
- * (an OpenAI-style {@link ConversationItemList} envelope), or
23
- * `for await` it to stream every item across pages (fetched lazily —
24
- * `limit` sets the page size, `after` the starting cursor; stop early to
25
- * stop fetching). Pass `order: "asc"` to walk the transcript from the
26
- * start.
27
- *
28
- * Items carry the turn-local delta in `input_messages` — only the
29
- * messages new to that turn. Use `get()` for the full input history.
30
- */
31
- list(conversationId, params) {
32
- return new Paginator({
33
- fetch: (after) => this.http.request({
34
- method: "GET",
35
- path: `/v1/conversations/${encodeURIComponent(conversationId)}/items`,
36
- query: { ...params, after },
37
- }),
38
- items: (page) => page.data,
39
- next: (page) => page.has_more && page.last_id !== null ? page.last_id : undefined,
40
- }, params?.after);
41
- }
42
- /**
43
- * Fetch a single conversation item. Unlike the list route, the
44
- * detail's `input_messages` is the FULL input history for that span.
45
- */
46
- get(conversationId, itemId, params) {
47
- return this.http.request({
48
- method: "GET",
49
- path: `/v1/conversations/${encodeURIComponent(conversationId)}/items/${encodeURIComponent(itemId)}`,
50
- query: params,
51
- });
52
- }
53
- }
54
- /**
55
- * Read-only Conversations API (`/v1/conversations`).
56
- *
57
- * Both `list()` and `items.list()` are auto-paging async generators,
58
- * but they drive different wire protocols underneath: `list()` walks
59
- * the standard Introspection cursor envelope's opaque `next` token,
60
- * while `items.list()` walks an OpenAI-style envelope via `after` =
61
- * the previous page's `last_id` while `has_more` is true.
62
- */
63
- export class ConversationsApi {
64
- http;
65
- /** Items of a conversation — `conversations.items.list(...)` etc. */
66
- items;
67
- constructor(http) {
68
- this.http = http;
69
- this.items = new ConversationItemsApi(http);
70
- }
71
- /**
72
- * List conversation summaries matching `params`. `await` the result for
73
- * the first page, or `for await` it to stream every summary across
74
- * pages (fetched lazily — `limit` sets the page size, `next` the
75
- * starting cursor; stop early to stop fetching).
76
- */
77
- list(params) {
78
- return cursorPaginate((next) => this.http.request({
79
- method: "GET",
80
- path: "/v1/conversations",
81
- query: { ...params, next },
82
- }), params?.next);
83
- }
84
- /**
85
- * Responses-API-style retrieve: load the state of a conversation as of
86
- * one item — the full input history, output, system instructions, and
87
- * tool definitions of that turn.
88
- *
89
- * When `itemId` is omitted, the latest LLM turn is used: the first
90
- * item (in descending order) whose `node_type` is `"assistant"` or
91
- * whose `operation_name` is `"chat"`, falling back to the first item
92
- * with a non-null `output_message`. Returns `null` when the
93
- * conversation has no items.
94
- *
95
- * For the full per-turn transcript instead, iterate
96
- * `items.list(conversationId, { order: "asc" })`.
97
- */
98
- async retrieve(conversationId, itemId) {
99
- const targetId = itemId ?? (await this.findLatestTurnId(conversationId));
100
- if (targetId === null)
101
- return null;
102
- const detail = await this.items.get(conversationId, targetId, {
103
- include: RESPONSE_INCLUDES,
104
- });
105
- const outputMessages = detail.gen_ai_output_messages ??
106
- (detail.output_message ? [detail.output_message] : []);
107
- return {
108
- conversation_id: conversationId,
109
- response_id: detail.response_id ?? null,
110
- item_id: detail.id,
111
- created_at: detail.created_at,
112
- model: detail.model_name ??
113
- detail.response_model ??
114
- detail.request_model ??
115
- null,
116
- provider_name: detail.provider_name ?? null,
117
- // The single-item route returns the FULL input history here.
118
- input_messages: normalizeMessages(detail.input_messages),
119
- output_messages: normalizeMessages(outputMessages),
120
- system_instructions: detail.system_instructions ?? null,
121
- tool_definitions: detail.tool_definitions ?? null,
122
- };
123
- }
124
- /** Scan items in descending order for the most recent LLM turn. */
125
- async findLatestTurnId(conversationId) {
126
- let fallback = null;
127
- for await (const item of this.items.list(conversationId, {
128
- order: "desc",
129
- })) {
130
- if (item.node_type === "assistant" || item.operation_name === "chat") {
131
- return item.id;
132
- }
133
- if (fallback === null && item.output_message != null)
134
- fallback = item;
135
- }
136
- return fallback?.id ?? null;
137
- }
138
- }
139
- /**
140
- * Defensive normalization for {@link ConversationsApi.retrieve} only:
141
- * older DP deployments emitted `tool_call_response` parts with a legacy
142
- * `result` key instead of the semconv `response` key. Map it across so
143
- * replayed history is always semconv-shaped.
144
- */
145
- function normalizeMessages(messages) {
146
- return messages.map((message) => ({
147
- ...message,
148
- parts: message.parts.map(normalizePart),
149
- }));
150
- }
151
- function normalizePart(part) {
152
- if (part.type !== "tool_call_response")
153
- return part;
154
- const legacy = part;
155
- if (legacy.response !== undefined || legacy.result === undefined) {
156
- return part;
157
- }
158
- const { result, ...rest } = legacy;
159
- return { ...rest, response: result };
160
- }
161
- //# sourceMappingURL=conversations.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"conversations.js","sourceRoot":"","sources":["../../src/runner-resources/conversations.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAE7D,uEAAuE;AACvE,MAAM,iBAAiB,GAA8B;IACnD,uBAAuB;IACvB,4BAA4B;IAC5B,yBAAyB;CAC1B,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,OAAO,oBAAoB;IACF;IAA7B,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD;;;;;;;;;;OAUG;IACH,IAAI,CACF,cAAsB,EACtB,MAAmC;QAEnC,OAAO,IAAI,SAAS,CAClB;YACE,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CACf,IAAI,CAAC,IAAI,CAAC,OAAO,CAAuB;gBACtC,MAAM,EAAE,KAAK;gBACb,IAAI,EAAE,qBAAqB,kBAAkB,CAAC,cAAc,CAAC,QAAQ;gBACrE,KAAK,EAAE,EAAE,GAAG,MAAM,EAAE,KAAK,EAA6B;aACvD,CAAC;YACJ,KAAK,EAAE,CAAC,IAAI,EAAE,E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,CAAC,EAAE,CAAC;YACjB,CAAC;YACD,IAAI,QAAQ,KAAK,IAAI,IAAI,IAAI,CAAC,cAAc,IAAI,IAAI;gBAAE,QAAQ,GAAG,IAAI,CAAC;QACxE,CAAC;QACD,OAAO,QAAQ,EAAE,EAAE,IAAI,IAAI,CAAC;IAC9B,CAAC;CACF;AAED;;;;;GAKG;AACH,SAAS,iBAAiB,CACxB,QAAa;IAEb,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QAChC,GAAG,OAAO;QACV,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,aAAa,CAAC;KACxC,CAAC,CAAC,CAAC;AACN,CAAC;AAED,SAAS,aAAa,CAAC,IAAiB;IACtC,IAAI,IAAI,CAAC,IAAI,KAAK,oBAAoB;QAAE,OAAO,IAAI,CAAC;IACpD,MAAM,MAAM,GAAG,IAAmD,CAAC;IACnE,IAAI,MAAM,CAAC,QAAQ,KAAK,SAAS,IAAI,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"}
@@ -1,45 +0,0 @@
1
- import type { File as FileResource, FileCreateOptions, FileCreateTextParams, FileListParams, FileType, FileUpdateParams, ListParams } from "@introspection-sdk/types";
2
- import { HttpClient } from "../http.js";
3
- import { Paginator } from "../pagination.js";
4
- export type FileUploadBody = {
5
- file: Blob;
6
- name?: string;
7
- file_type?: FileType;
8
- } | {
9
- file: Uint8Array;
10
- name: string;
11
- file_type?: FileType;
12
- contentType?: string;
13
- };
14
- export declare class FileVersionsApi {
15
- private readonly http;
16
- constructor(http: HttpClient);
17
- /**
18
- * List versions of a file. `await` the result for the first page, or
19
- * `for await` it to stream every version across pages (fetched lazily;
20
- * stop early to stop fetching).
21
- */
22
- list(fileId: string, params?: ListParams): Paginator<FileResource>;
23
- get(fileId: string, versionId: string): Promise<FileResource>;
24
- create(fileId: string, body: FileUploadBody, options?: FileCreateOptions): Promise<FileResource>;
25
- }
26
- export declare class FilesApi {
27
- private readonly http;
28
- readonly versions: FileVersionsApi;
29
- constructor(http: HttpClient);
30
- /**
31
- * List files matching `params`. `await` the result for the first page,
32
- * or `for await` it to stream every file across pages (fetched lazily —
33
- * `limit` sets the page size, `next` the starting cursor; stop early to
34
- * stop fetching).
35
- */
36
- list(params?: FileListParams): Paginator<FileResource>;
37
- upload(body: FileUploadBody, options?: FileCreateOptions): Promise<FileResource>;
38
- createText(body: FileCreateTextParams, options?: FileCreateOptions): Promise<FileResource>;
39
- get(fileId: string): Promise<FileResource>;
40
- update(fileId: string, body: FileUpdateParams): Promise<FileResource>;
41
- delete(fileId: string): Promise<void>;
42
- download(fileId: string): Promise<Uint8Array>;
43
- downloadStream(fileId: string): Promise<ReadableStream<Uint8Array>>;
44
- }
45
- //# sourceMappingURL=files.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../src/runner-resources/files.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,IAAI,IAAI,YAAY,EACpB,iBAAiB,EACjB,oBAAoB,EACpB,cAAc,EACd,QAAQ,EACR,gBAAgB,EAChB,UAAU,EAEX,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,SAAS,EAAkB,MAAM,kBAAkB,CAAC;AAE7D,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,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