@databricks/sdk-agentkit 0.0.0-stage → 0.0.1

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.
@@ -0,0 +1,710 @@
1
+ import { resolveClientConfig } from "./transport.js";
2
+ import { buildHttpRequest, executeCall, executeHttpCall, marshalRequest, parseResponse } from "./utils.js";
3
+ import { name, version } from "../package.js";
4
+ import { marshalAppendSessionItemsRequestSchema, marshalClearSessionItemsRequestSchema, marshalExtractMemoriesRequestSchema, marshalForkSessionRequestSchema, marshalManagedMemoryEntrySchema, marshalManagedMemoryStoreSchema, marshalPopSessionItemRequestSchema, marshalSearchManagedMemoryEntriesRequestSchema, marshalSessionSchema, marshalSessionStoreSchema, unmarshalAppendSessionItemsResponseSchema, unmarshalClearSessionItemsResponseSchema, unmarshalExtractMemoriesResponseSchema, unmarshalForkSessionResponseSchema, unmarshalListManagedMemoryEntriesResponseSchema, unmarshalListManagedMemoryStoresResponseSchema, unmarshalListSessionItemsResponseSchema, unmarshalListSessionStoresResponseSchema, unmarshalListSessionsResponseSchema, unmarshalManagedMemoryEntrySchema, unmarshalManagedMemoryStoreSchema, unmarshalPopSessionItemResponseSchema, unmarshalSearchManagedMemoryEntriesResponseSchema, unmarshalSessionSchema, unmarshalSessionStoreSchema } from "./model.js";
5
+ import { VERSION } from "@databricks/sdk-auth";
6
+ import { createDefault } from "@databricks/sdk-core/clientinfo";
7
+ import { NoOpLogger } from "@databricks/sdk-core/logger";
8
+
9
+ //#region src/v1/client.ts
10
+ const PACKAGE_SEGMENT = {
11
+ key: "sdk-js-" + name.replace(/^@[^/]+\/sdk-/, ""),
12
+ value: version
13
+ };
14
+ var AgentKitClient = class {
15
+ options;
16
+ logger;
17
+ userAgent;
18
+ config;
19
+ constructor(options) {
20
+ this.options = options;
21
+ this.logger = options.logger ?? new NoOpLogger();
22
+ this.userAgent = createDefault().with(PACKAGE_SEGMENT).with({
23
+ key: "sdk-js-auth",
24
+ value: VERSION
25
+ }).with({
26
+ key: "auth",
27
+ value: options.credentials?.name() ?? "default"
28
+ }).toString();
29
+ }
30
+ resolveConfig() {
31
+ this.config ??= resolveClientConfig(this.options);
32
+ return this.config;
33
+ }
34
+ /** Appends items to a session. */
35
+ async appendSessionItems(req, options) {
36
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
37
+ const url = `${host}/api/2.0/agents/${req.parent ?? ""}/items:append`;
38
+ const body = marshalRequest(req, marshalAppendSessionItemsRequestSchema);
39
+ let resp;
40
+ const call = async (callSignal) => {
41
+ const headers = new Headers({ "Content-Type": "application/json" });
42
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
43
+ headers.set("User-Agent", this.userAgent);
44
+ resp = parseResponse(await executeHttpCall({
45
+ request: buildHttpRequest("POST", url, headers, callSignal, body),
46
+ httpClient,
47
+ logger: this.logger
48
+ }), unmarshalAppendSessionItemsResponseSchema);
49
+ };
50
+ await executeCall(call, options);
51
+ if (resp === void 0) throw new Error("operation completed without a result.");
52
+ return resp;
53
+ }
54
+ /** Clears all items from a session. */
55
+ async clearSessionItems(req, options) {
56
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
57
+ const url = `${host}/api/2.0/agents/${req.parent ?? ""}/items:clear`;
58
+ const body = marshalRequest(req, marshalClearSessionItemsRequestSchema);
59
+ let resp;
60
+ const call = async (callSignal) => {
61
+ const headers = new Headers({ "Content-Type": "application/json" });
62
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
63
+ headers.set("User-Agent", this.userAgent);
64
+ resp = parseResponse(await executeHttpCall({
65
+ request: buildHttpRequest("POST", url, headers, callSignal, body),
66
+ httpClient,
67
+ logger: this.logger
68
+ }), unmarshalClearSessionItemsResponseSchema);
69
+ };
70
+ await executeCall(call, options);
71
+ if (resp === void 0) throw new Error("operation completed without a result.");
72
+ return resp;
73
+ }
74
+ /**
75
+ * Creates a managed memory entry using exclusive-create semantics. Callers may choose the entry
76
+ * ID; the service generates one when it is omitted. Returns `ALREADY_EXISTS` when an entry with
77
+ * the same actor, session, and path already exists. Omitted `session_id` is its own uniqueness
78
+ * key: two omitted-session entries with the same actor and path conflict, but an omitted-session
79
+ * entry does not conflict with a session-scoped entry at the same actor and path.
80
+ */
81
+ async createMemory(req, options) {
82
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
83
+ const url = `${host}/api/2.0/agents/${req.parent ?? ""}/entries`;
84
+ const params = new URLSearchParams();
85
+ if (req.managedMemoryEntryId !== void 0) params.append("managed_memory_entry_id", req.managedMemoryEntryId);
86
+ const query = params.toString();
87
+ const fullUrl = query !== "" ? `${url}?${query}` : url;
88
+ const body = marshalRequest(req.managedMemoryEntry, marshalManagedMemoryEntrySchema);
89
+ let resp;
90
+ const call = async (callSignal) => {
91
+ const headers = new Headers({ "Content-Type": "application/json" });
92
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
93
+ headers.set("User-Agent", this.userAgent);
94
+ resp = parseResponse(await executeHttpCall({
95
+ request: buildHttpRequest("POST", fullUrl, headers, callSignal, body),
96
+ httpClient,
97
+ logger: this.logger
98
+ }), unmarshalManagedMemoryEntrySchema);
99
+ };
100
+ await executeCall(call, options);
101
+ if (resp === void 0) throw new Error("operation completed without a result.");
102
+ return resp;
103
+ }
104
+ /** Creates a managed memory store in the caller's workspace. */
105
+ async createMemoryStore(req, options) {
106
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
107
+ const url = `${host}/api/2.0/agents/memory-stores`;
108
+ const params = new URLSearchParams();
109
+ if (req.managedMemoryStoreId !== void 0) params.append("managed_memory_store_id", req.managedMemoryStoreId);
110
+ const query = params.toString();
111
+ const fullUrl = query !== "" ? `${url}?${query}` : url;
112
+ const body = marshalRequest(req.managedMemoryStore, marshalManagedMemoryStoreSchema);
113
+ let resp;
114
+ const call = async (callSignal) => {
115
+ const headers = new Headers({ "Content-Type": "application/json" });
116
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
117
+ headers.set("User-Agent", this.userAgent);
118
+ resp = parseResponse(await executeHttpCall({
119
+ request: buildHttpRequest("POST", fullUrl, headers, callSignal, body),
120
+ httpClient,
121
+ logger: this.logger
122
+ }), unmarshalManagedMemoryStoreSchema);
123
+ };
124
+ await executeCall(call, options);
125
+ if (resp === void 0) throw new Error("operation completed without a result.");
126
+ return resp;
127
+ }
128
+ /** Creates a session within a session store. */
129
+ async createSession(req, options) {
130
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
131
+ const url = `${host}/api/2.0/agents/${req.parent ?? ""}/sessions`;
132
+ const params = new URLSearchParams();
133
+ if (req.sessionId !== void 0) params.append("session_id", req.sessionId);
134
+ const query = params.toString();
135
+ const fullUrl = query !== "" ? `${url}?${query}` : url;
136
+ const body = marshalRequest(req.session, marshalSessionSchema);
137
+ let resp;
138
+ const call = async (callSignal) => {
139
+ const headers = new Headers({ "Content-Type": "application/json" });
140
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
141
+ headers.set("User-Agent", this.userAgent);
142
+ resp = parseResponse(await executeHttpCall({
143
+ request: buildHttpRequest("POST", fullUrl, headers, callSignal, body),
144
+ httpClient,
145
+ logger: this.logger
146
+ }), unmarshalSessionSchema);
147
+ };
148
+ await executeCall(call, options);
149
+ if (resp === void 0) throw new Error("operation completed without a result.");
150
+ return resp;
151
+ }
152
+ /** Creates a session store. */
153
+ async createSessionStore(req, options) {
154
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
155
+ const url = `${host}/api/2.0/agents/session-stores`;
156
+ const params = new URLSearchParams();
157
+ if (req.sessionStoreId !== void 0) params.append("session_store_id", req.sessionStoreId);
158
+ const query = params.toString();
159
+ const fullUrl = query !== "" ? `${url}?${query}` : url;
160
+ const body = marshalRequest(req.sessionStore, marshalSessionStoreSchema);
161
+ let resp;
162
+ const call = async (callSignal) => {
163
+ const headers = new Headers({ "Content-Type": "application/json" });
164
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
165
+ headers.set("User-Agent", this.userAgent);
166
+ resp = parseResponse(await executeHttpCall({
167
+ request: buildHttpRequest("POST", fullUrl, headers, callSignal, body),
168
+ httpClient,
169
+ logger: this.logger
170
+ }), unmarshalSessionStoreSchema);
171
+ };
172
+ await executeCall(call, options);
173
+ if (resp === void 0) throw new Error("operation completed without a result.");
174
+ return resp;
175
+ }
176
+ /**
177
+ * Deletes a managed memory entry by resource name. Returns `NOT_FOUND` when the entry does not
178
+ * exist in the caller's workspace.
179
+ */
180
+ async deleteMemory(req, options) {
181
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
182
+ const url = `${host}/api/2.0/agents/${req.name ?? ""}`;
183
+ const call = async (callSignal) => {
184
+ const headers = new Headers();
185
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
186
+ headers.set("User-Agent", this.userAgent);
187
+ await executeHttpCall({
188
+ request: buildHttpRequest("DELETE", url, headers, callSignal),
189
+ httpClient,
190
+ logger: this.logger
191
+ });
192
+ };
193
+ await executeCall(call, options);
194
+ }
195
+ /**
196
+ * Deletes a managed memory store by resource name. Returns `NOT_FOUND` when the store does not
197
+ * exist in the caller's workspace.
198
+ */
199
+ async deleteMemoryStore(req, options) {
200
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
201
+ const url = `${host}/api/2.0/agents/${req.name ?? ""}`;
202
+ const call = async (callSignal) => {
203
+ const headers = new Headers();
204
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
205
+ headers.set("User-Agent", this.userAgent);
206
+ await executeHttpCall({
207
+ request: buildHttpRequest("DELETE", url, headers, callSignal),
208
+ httpClient,
209
+ logger: this.logger
210
+ });
211
+ };
212
+ await executeCall(call, options);
213
+ }
214
+ /**
215
+ * Deletes a session, its items, and any descendant sessions recursively. Independently retained
216
+ * memory is not deleted.
217
+ */
218
+ async deleteSession(req, options) {
219
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
220
+ const url = `${host}/api/2.0/agents/${req.name ?? ""}`;
221
+ const call = async (callSignal) => {
222
+ const headers = new Headers();
223
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
224
+ headers.set("User-Agent", this.userAgent);
225
+ await executeHttpCall({
226
+ request: buildHttpRequest("DELETE", url, headers, callSignal),
227
+ httpClient,
228
+ logger: this.logger
229
+ });
230
+ };
231
+ await executeCall(call, options);
232
+ }
233
+ /**
234
+ * Deletes a session store, its sessions and items, and its service-managed storage. Memory entries
235
+ * retained by a separate Memory Store are not deleted.
236
+ */
237
+ async deleteSessionStore(req, options) {
238
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
239
+ const url = `${host}/api/2.0/agents/${req.name ?? ""}`;
240
+ const call = async (callSignal) => {
241
+ const headers = new Headers();
242
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
243
+ headers.set("User-Agent", this.userAgent);
244
+ await executeHttpCall({
245
+ request: buildHttpRequest("DELETE", url, headers, callSignal),
246
+ httpClient,
247
+ logger: this.logger
248
+ });
249
+ };
250
+ await executeCall(call, options);
251
+ }
252
+ /**
253
+ * Synchronously extracts memories from a single session into the given memory store, returning
254
+ * the entries that were written.
255
+ */
256
+ async extractMemories(req, options) {
257
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
258
+ const url = `${host}/api/2.0/agents/${req.sessionStore ?? ""}/sessions/${req.sessionId ?? ""}/extractions`;
259
+ const body = marshalRequest(req, marshalExtractMemoriesRequestSchema);
260
+ let resp;
261
+ const call = async (callSignal) => {
262
+ const headers = new Headers({ "Content-Type": "application/json" });
263
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
264
+ headers.set("User-Agent", this.userAgent);
265
+ resp = parseResponse(await executeHttpCall({
266
+ request: buildHttpRequest("POST", url, headers, callSignal, body),
267
+ httpClient,
268
+ logger: this.logger
269
+ }), unmarshalExtractMemoriesResponseSchema);
270
+ };
271
+ await executeCall(call, options);
272
+ if (resp === void 0) throw new Error("operation completed without a result.");
273
+ return resp;
274
+ }
275
+ /** Forks a session into an independent top-level copy. */
276
+ async forkSession(req, options) {
277
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
278
+ const url = `${host}/api/2.0/agents/${req.parent ?? ""}/sessions:fork`;
279
+ const body = marshalRequest(req, marshalForkSessionRequestSchema);
280
+ let resp;
281
+ const call = async (callSignal) => {
282
+ const headers = new Headers({ "Content-Type": "application/json" });
283
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
284
+ headers.set("User-Agent", this.userAgent);
285
+ resp = parseResponse(await executeHttpCall({
286
+ request: buildHttpRequest("POST", url, headers, callSignal, body),
287
+ httpClient,
288
+ logger: this.logger
289
+ }), unmarshalForkSessionResponseSchema);
290
+ };
291
+ await executeCall(call, options);
292
+ if (resp === void 0) throw new Error("operation completed without a result.");
293
+ return resp;
294
+ }
295
+ /**
296
+ * Retrieves a managed memory entry by resource name. `view` controls whether the response
297
+ * includes memory content. Returns `NOT_FOUND` when the entry does not exist in the caller's
298
+ * workspace.
299
+ */
300
+ async getMemory(req, options) {
301
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
302
+ const url = `${host}/api/2.0/agents/${req.name ?? ""}`;
303
+ const params = new URLSearchParams();
304
+ if (req.view !== void 0) params.append("view", req.view);
305
+ const query = params.toString();
306
+ const fullUrl = query !== "" ? `${url}?${query}` : url;
307
+ let resp;
308
+ const call = async (callSignal) => {
309
+ const headers = new Headers();
310
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
311
+ headers.set("User-Agent", this.userAgent);
312
+ resp = parseResponse(await executeHttpCall({
313
+ request: buildHttpRequest("GET", fullUrl, headers, callSignal),
314
+ httpClient,
315
+ logger: this.logger
316
+ }), unmarshalManagedMemoryEntrySchema);
317
+ };
318
+ await executeCall(call, options);
319
+ if (resp === void 0) throw new Error("operation completed without a result.");
320
+ return resp;
321
+ }
322
+ /**
323
+ * Retrieves a managed memory store by resource name. Returns `NOT_FOUND` when the store does not
324
+ * exist in the caller's workspace.
325
+ */
326
+ async getMemoryStore(req, options) {
327
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
328
+ const url = `${host}/api/2.0/agents/${req.name ?? ""}`;
329
+ let resp;
330
+ const call = async (callSignal) => {
331
+ const headers = new Headers();
332
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
333
+ headers.set("User-Agent", this.userAgent);
334
+ resp = parseResponse(await executeHttpCall({
335
+ request: buildHttpRequest("GET", url, headers, callSignal),
336
+ httpClient,
337
+ logger: this.logger
338
+ }), unmarshalManagedMemoryStoreSchema);
339
+ };
340
+ await executeCall(call, options);
341
+ if (resp === void 0) throw new Error("operation completed without a result.");
342
+ return resp;
343
+ }
344
+ /** Gets a session by resource name. */
345
+ async getSession(req, options) {
346
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
347
+ const url = `${host}/api/2.0/agents/${req.name ?? ""}`;
348
+ let resp;
349
+ const call = async (callSignal) => {
350
+ const headers = new Headers();
351
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
352
+ headers.set("User-Agent", this.userAgent);
353
+ resp = parseResponse(await executeHttpCall({
354
+ request: buildHttpRequest("GET", url, headers, callSignal),
355
+ httpClient,
356
+ logger: this.logger
357
+ }), unmarshalSessionSchema);
358
+ };
359
+ await executeCall(call, options);
360
+ if (resp === void 0) throw new Error("operation completed without a result.");
361
+ return resp;
362
+ }
363
+ /** Gets a session store by resource name. */
364
+ async getSessionStore(req, options) {
365
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
366
+ const url = `${host}/api/2.0/agents/${req.name ?? ""}`;
367
+ let resp;
368
+ const call = async (callSignal) => {
369
+ const headers = new Headers();
370
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
371
+ headers.set("User-Agent", this.userAgent);
372
+ resp = parseResponse(await executeHttpCall({
373
+ request: buildHttpRequest("GET", url, headers, callSignal),
374
+ httpClient,
375
+ logger: this.logger
376
+ }), unmarshalSessionStoreSchema);
377
+ };
378
+ await executeCall(call, options);
379
+ if (resp === void 0) throw new Error("operation completed without a result.");
380
+ return resp;
381
+ }
382
+ /**
383
+ * Lists managed memory entries for one actor. An exact `path` filters entries across sessions,
384
+ * ignoring session metadata. Otherwise, `session_id` and `path_prefix` restrict the actor
385
+ * partition. `view` controls whether each returned entry includes memory content.
386
+ */
387
+ async listMemories(req, options) {
388
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
389
+ const url = `${host}/api/2.0/agents/${req.parent ?? ""}/entries`;
390
+ const params = new URLSearchParams();
391
+ if (req.pageSize !== void 0) params.append("page_size", String(req.pageSize));
392
+ if (req.pageToken !== void 0) params.append("page_token", req.pageToken);
393
+ if (req.actorId !== void 0) params.append("actor_id", req.actorId);
394
+ if (req.pathPrefix !== void 0) params.append("path_prefix", req.pathPrefix);
395
+ if (req.sessionId !== void 0) params.append("session_id", req.sessionId);
396
+ if (req.view !== void 0) params.append("view", req.view);
397
+ const query = params.toString();
398
+ const fullUrl = query !== "" ? `${url}?${query}` : url;
399
+ let resp;
400
+ const call = async (callSignal) => {
401
+ const headers = new Headers();
402
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
403
+ headers.set("User-Agent", this.userAgent);
404
+ resp = parseResponse(await executeHttpCall({
405
+ request: buildHttpRequest("GET", fullUrl, headers, callSignal),
406
+ httpClient,
407
+ logger: this.logger
408
+ }), unmarshalListManagedMemoryEntriesResponseSchema);
409
+ };
410
+ await executeCall(call, options);
411
+ if (resp === void 0) throw new Error("operation completed without a result.");
412
+ return resp;
413
+ }
414
+ async *listMemoriesIter(req, options) {
415
+ const pageReq = { ...req };
416
+ for (;;) {
417
+ const resp = await this.listMemories(pageReq, options);
418
+ for (const item of resp.managedMemoryEntries ?? []) yield item;
419
+ if (resp.nextPageToken === void 0 || resp.nextPageToken === "") return;
420
+ pageReq.pageToken = resp.nextPageToken;
421
+ }
422
+ }
423
+ /** Lists managed memory stores in the caller's workspace. */
424
+ async listMemoryStores(req, options) {
425
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
426
+ const url = `${host}/api/2.0/agents/memory-stores`;
427
+ const params = new URLSearchParams();
428
+ if (req.pageSize !== void 0) params.append("page_size", String(req.pageSize));
429
+ if (req.pageToken !== void 0) params.append("page_token", req.pageToken);
430
+ const query = params.toString();
431
+ const fullUrl = query !== "" ? `${url}?${query}` : url;
432
+ let resp;
433
+ const call = async (callSignal) => {
434
+ const headers = new Headers();
435
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
436
+ headers.set("User-Agent", this.userAgent);
437
+ resp = parseResponse(await executeHttpCall({
438
+ request: buildHttpRequest("GET", fullUrl, headers, callSignal),
439
+ httpClient,
440
+ logger: this.logger
441
+ }), unmarshalListManagedMemoryStoresResponseSchema);
442
+ };
443
+ await executeCall(call, options);
444
+ if (resp === void 0) throw new Error("operation completed without a result.");
445
+ return resp;
446
+ }
447
+ async *listMemoryStoresIter(req, options) {
448
+ const pageReq = { ...req };
449
+ for (;;) {
450
+ const resp = await this.listMemoryStores(pageReq, options);
451
+ for (const item of resp.managedMemoryStores ?? []) yield item;
452
+ if (resp.nextPageToken === void 0 || resp.nextPageToken === "") return;
453
+ pageReq.pageToken = resp.nextPageToken;
454
+ }
455
+ }
456
+ /** Lists items in a session. */
457
+ async listSessionItems(req, options) {
458
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
459
+ const url = `${host}/api/2.0/agents/${req.parent ?? ""}/items`;
460
+ const params = new URLSearchParams();
461
+ if (req.pageSize !== void 0) params.append("page_size", String(req.pageSize));
462
+ if (req.pageToken !== void 0) params.append("page_token", req.pageToken);
463
+ if (req.orderBy !== void 0) params.append("order_by", req.orderBy);
464
+ const query = params.toString();
465
+ const fullUrl = query !== "" ? `${url}?${query}` : url;
466
+ let resp;
467
+ const call = async (callSignal) => {
468
+ const headers = new Headers();
469
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
470
+ headers.set("User-Agent", this.userAgent);
471
+ resp = parseResponse(await executeHttpCall({
472
+ request: buildHttpRequest("GET", fullUrl, headers, callSignal),
473
+ httpClient,
474
+ logger: this.logger
475
+ }), unmarshalListSessionItemsResponseSchema);
476
+ };
477
+ await executeCall(call, options);
478
+ if (resp === void 0) throw new Error("operation completed without a result.");
479
+ return resp;
480
+ }
481
+ async *listSessionItemsIter(req, options) {
482
+ const pageReq = { ...req };
483
+ for (;;) {
484
+ const resp = await this.listSessionItems(pageReq, options);
485
+ for (const item of resp.sessionItems ?? []) yield item;
486
+ if (resp.nextPageToken === void 0 || resp.nextPageToken === "") return;
487
+ pageReq.pageToken = resp.nextPageToken;
488
+ }
489
+ }
490
+ /** Lists session stores. */
491
+ async listSessionStores(req, options) {
492
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
493
+ const url = `${host}/api/2.0/agents/session-stores`;
494
+ const params = new URLSearchParams();
495
+ if (req.pageSize !== void 0) params.append("page_size", String(req.pageSize));
496
+ if (req.pageToken !== void 0) params.append("page_token", req.pageToken);
497
+ const query = params.toString();
498
+ const fullUrl = query !== "" ? `${url}?${query}` : url;
499
+ let resp;
500
+ const call = async (callSignal) => {
501
+ const headers = new Headers();
502
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
503
+ headers.set("User-Agent", this.userAgent);
504
+ resp = parseResponse(await executeHttpCall({
505
+ request: buildHttpRequest("GET", fullUrl, headers, callSignal),
506
+ httpClient,
507
+ logger: this.logger
508
+ }), unmarshalListSessionStoresResponseSchema);
509
+ };
510
+ await executeCall(call, options);
511
+ if (resp === void 0) throw new Error("operation completed without a result.");
512
+ return resp;
513
+ }
514
+ async *listSessionStoresIter(req, options) {
515
+ const pageReq = { ...req };
516
+ for (;;) {
517
+ const resp = await this.listSessionStores(pageReq, options);
518
+ for (const item of resp.sessionStores ?? []) yield item;
519
+ if (resp.nextPageToken === void 0 || resp.nextPageToken === "") return;
520
+ pageReq.pageToken = resp.nextPageToken;
521
+ }
522
+ }
523
+ /** Lists sessions within a session store. */
524
+ async listSessions(req, options) {
525
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
526
+ const url = `${host}/api/2.0/agents/${req.parent ?? ""}/sessions`;
527
+ const params = new URLSearchParams();
528
+ if (req.pageSize !== void 0) params.append("page_size", String(req.pageSize));
529
+ if (req.pageToken !== void 0) params.append("page_token", req.pageToken);
530
+ if (req.filter !== void 0) params.append("filter", req.filter);
531
+ if (req.orderBy !== void 0) params.append("order_by", req.orderBy);
532
+ const query = params.toString();
533
+ const fullUrl = query !== "" ? `${url}?${query}` : url;
534
+ let resp;
535
+ const call = async (callSignal) => {
536
+ const headers = new Headers();
537
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
538
+ headers.set("User-Agent", this.userAgent);
539
+ resp = parseResponse(await executeHttpCall({
540
+ request: buildHttpRequest("GET", fullUrl, headers, callSignal),
541
+ httpClient,
542
+ logger: this.logger
543
+ }), unmarshalListSessionsResponseSchema);
544
+ };
545
+ await executeCall(call, options);
546
+ if (resp === void 0) throw new Error("operation completed without a result.");
547
+ return resp;
548
+ }
549
+ async *listSessionsIter(req, options) {
550
+ const pageReq = { ...req };
551
+ for (;;) {
552
+ const resp = await this.listSessions(pageReq, options);
553
+ for (const item of resp.sessions ?? []) yield item;
554
+ if (resp.nextPageToken === void 0 || resp.nextPageToken === "") return;
555
+ pageReq.pageToken = resp.nextPageToken;
556
+ }
557
+ }
558
+ /** Pops the newest item from a session. */
559
+ async popSessionItem(req, options) {
560
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
561
+ const url = `${host}/api/2.0/agents/${req.parent ?? ""}/items:pop`;
562
+ const body = marshalRequest(req, marshalPopSessionItemRequestSchema);
563
+ let resp;
564
+ const call = async (callSignal) => {
565
+ const headers = new Headers({ "Content-Type": "application/json" });
566
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
567
+ headers.set("User-Agent", this.userAgent);
568
+ resp = parseResponse(await executeHttpCall({
569
+ request: buildHttpRequest("POST", url, headers, callSignal, body),
570
+ httpClient,
571
+ logger: this.logger
572
+ }), unmarshalPopSessionItemResponseSchema);
573
+ };
574
+ await executeCall(call, options);
575
+ if (resp === void 0) throw new Error("operation completed without a result.");
576
+ return resp;
577
+ }
578
+ /**
579
+ * Searches managed memory entries by text query for one actor. Returns matching entries and
580
+ * scores ranked by relevance; `view` controls whether each returned entry includes content.
581
+ */
582
+ async searchMemories(req, options) {
583
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
584
+ const url = `${host}/api/2.0/agents/${req.parent ?? ""}/entries:search`;
585
+ const body = marshalRequest(req, marshalSearchManagedMemoryEntriesRequestSchema);
586
+ let resp;
587
+ const call = async (callSignal) => {
588
+ const headers = new Headers({ "Content-Type": "application/json" });
589
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
590
+ headers.set("User-Agent", this.userAgent);
591
+ resp = parseResponse(await executeHttpCall({
592
+ request: buildHttpRequest("POST", url, headers, callSignal, body),
593
+ httpClient,
594
+ logger: this.logger
595
+ }), unmarshalSearchManagedMemoryEntriesResponseSchema);
596
+ };
597
+ await executeCall(call, options);
598
+ if (resp === void 0) throw new Error("operation completed without a result.");
599
+ return resp;
600
+ }
601
+ async *searchMemoriesIter(req, options) {
602
+ const pageReq = { ...req };
603
+ for (;;) {
604
+ const resp = await this.searchMemories(pageReq, options);
605
+ for (const item of resp.results ?? []) yield item;
606
+ if (resp.nextPageToken === void 0 || resp.nextPageToken === "") return;
607
+ pageReq.pageToken = resp.nextPageToken;
608
+ }
609
+ }
610
+ /** Updates selected mutable fields on a managed memory entry. Identity fields are immutable. */
611
+ async updateMemory(req, options) {
612
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
613
+ const url = `${host}/api/2.0/agents/${req.managedMemoryEntry?.name ?? ""}`;
614
+ const params = new URLSearchParams();
615
+ if (req.updateMask !== void 0) params.append("update_mask", req.updateMask.toString());
616
+ const query = params.toString();
617
+ const fullUrl = query !== "" ? `${url}?${query}` : url;
618
+ const body = marshalRequest(req.managedMemoryEntry, marshalManagedMemoryEntrySchema);
619
+ let resp;
620
+ const call = async (callSignal) => {
621
+ const headers = new Headers({ "Content-Type": "application/json" });
622
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
623
+ headers.set("User-Agent", this.userAgent);
624
+ resp = parseResponse(await executeHttpCall({
625
+ request: buildHttpRequest("PATCH", fullUrl, headers, callSignal, body),
626
+ httpClient,
627
+ logger: this.logger
628
+ }), unmarshalManagedMemoryEntrySchema);
629
+ };
630
+ await executeCall(call, options);
631
+ if (resp === void 0) throw new Error("operation completed without a result.");
632
+ return resp;
633
+ }
634
+ /** Updates a managed memory store's description and metadata. */
635
+ async updateMemoryStore(req, options) {
636
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
637
+ const url = `${host}/api/2.0/agents/${req.managedMemoryStore?.name ?? ""}`;
638
+ const params = new URLSearchParams();
639
+ if (req.updateMask !== void 0) params.append("update_mask", req.updateMask.toString());
640
+ const query = params.toString();
641
+ const fullUrl = query !== "" ? `${url}?${query}` : url;
642
+ const body = marshalRequest(req.managedMemoryStore, marshalManagedMemoryStoreSchema);
643
+ let resp;
644
+ const call = async (callSignal) => {
645
+ const headers = new Headers({ "Content-Type": "application/json" });
646
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
647
+ headers.set("User-Agent", this.userAgent);
648
+ resp = parseResponse(await executeHttpCall({
649
+ request: buildHttpRequest("PATCH", fullUrl, headers, callSignal, body),
650
+ httpClient,
651
+ logger: this.logger
652
+ }), unmarshalManagedMemoryStoreSchema);
653
+ };
654
+ await executeCall(call, options);
655
+ if (resp === void 0) throw new Error("operation completed without a result.");
656
+ return resp;
657
+ }
658
+ /** Updates a session's mutable fields. */
659
+ async updateSession(req, options) {
660
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
661
+ const url = `${host}/api/2.0/agents/${req.session?.name ?? ""}`;
662
+ const params = new URLSearchParams();
663
+ if (req.updateMask !== void 0) params.append("update_mask", req.updateMask.toString());
664
+ const query = params.toString();
665
+ const fullUrl = query !== "" ? `${url}?${query}` : url;
666
+ const body = marshalRequest(req.session, marshalSessionSchema);
667
+ let resp;
668
+ const call = async (callSignal) => {
669
+ const headers = new Headers({ "Content-Type": "application/json" });
670
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
671
+ headers.set("User-Agent", this.userAgent);
672
+ resp = parseResponse(await executeHttpCall({
673
+ request: buildHttpRequest("PATCH", fullUrl, headers, callSignal, body),
674
+ httpClient,
675
+ logger: this.logger
676
+ }), unmarshalSessionSchema);
677
+ };
678
+ await executeCall(call, options);
679
+ if (resp === void 0) throw new Error("operation completed without a result.");
680
+ return resp;
681
+ }
682
+ /** Updates a session store's description and metadata. */
683
+ async updateSessionStore(req, options) {
684
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
685
+ const url = `${host}/api/2.0/agents/${req.sessionStore?.name ?? ""}`;
686
+ const params = new URLSearchParams();
687
+ if (req.updateMask !== void 0) params.append("update_mask", req.updateMask.toString());
688
+ const query = params.toString();
689
+ const fullUrl = query !== "" ? `${url}?${query}` : url;
690
+ const body = marshalRequest(req.sessionStore, marshalSessionStoreSchema);
691
+ let resp;
692
+ const call = async (callSignal) => {
693
+ const headers = new Headers({ "Content-Type": "application/json" });
694
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
695
+ headers.set("User-Agent", this.userAgent);
696
+ resp = parseResponse(await executeHttpCall({
697
+ request: buildHttpRequest("PATCH", fullUrl, headers, callSignal, body),
698
+ httpClient,
699
+ logger: this.logger
700
+ }), unmarshalSessionStoreSchema);
701
+ };
702
+ await executeCall(call, options);
703
+ if (resp === void 0) throw new Error("operation completed without a result.");
704
+ return resp;
705
+ }
706
+ };
707
+
708
+ //#endregion
709
+ export { AgentKitClient };
710
+ //# sourceMappingURL=client.js.map