@letta-ai/letta-agent-sdk 0.8.22 → 0.8.24
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.
- package/README.md +4 -5
- package/dist/app-server-session.d.ts +2 -0
- package/dist/app-server-session.d.ts.map +1 -1
- package/dist/client-base.d.ts +4 -4
- package/dist/client-base.d.ts.map +1 -1
- package/dist/client-entry.js +29 -21
- package/dist/client-entry.js.map +8 -8
- package/dist/client.d.ts +2 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/cloud-session.d.ts +1 -1
- package/dist/cloud-session.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +83 -36
- package/dist/index.js.map +12 -12
- package/dist/local-app-server-session.d.ts.map +1 -1
- package/dist/query-types.d.ts +13 -11
- package/dist/query-types.d.ts.map +1 -1
- package/dist/query.d.ts +4 -4
- package/dist/query.d.ts.map +1 -1
- package/dist/remote-session-protocol.d.ts +1 -1
- package/dist/remote-session-protocol.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/app-server-session.ts +23 -3
- package/src/client-base.ts +18 -18
- package/src/client.ts +4 -12
- package/src/cloud-session.ts +4 -4
- package/src/index.ts +2 -1
- package/src/local-app-server-session.ts +4 -0
- package/src/query-types.ts +14 -11
- package/src/query.ts +4 -6
- package/src/remote-session-protocol.ts +1 -1
package/README.md
CHANGED
|
@@ -51,7 +51,7 @@ measures the tracked turn and excludes session initialization; measure `ready()`
|
|
|
51
51
|
separately when startup latency matters.
|
|
52
52
|
|
|
53
53
|
For a simple question that should not create or use an agent, call `query()`.
|
|
54
|
-
It creates an
|
|
54
|
+
It creates an ordinary conversation from the supplied model and
|
|
55
55
|
system prompt, streams the turn, and closes the runtime when iteration ends:
|
|
56
56
|
|
|
57
57
|
```typescript
|
|
@@ -66,9 +66,8 @@ for await (const message of client.query({
|
|
|
66
66
|
}
|
|
67
67
|
```
|
|
68
68
|
|
|
69
|
-
`query()`
|
|
70
|
-
|
|
71
|
-
store agent-free conversations.
|
|
69
|
+
`query()` supports API-backed App Servers and local App Servers that advertise
|
|
70
|
+
local conversation support. Older local App Servers return an upgrade error.
|
|
72
71
|
|
|
73
72
|
Pass the returned `query.conversationId` as `options.conversationId` on a later
|
|
74
73
|
`query()` to continue that conversation with its history. On resume, `model`,
|
|
@@ -76,7 +75,7 @@ Pass the returned `query.conversationId` as `options.conversationId` on a later
|
|
|
76
75
|
stored configuration.
|
|
77
76
|
|
|
78
77
|
Cloud queries require an explicit connected computer. Local and remote clients
|
|
79
|
-
run the
|
|
78
|
+
run the conversation through their App Server.
|
|
80
79
|
|
|
81
80
|
Set `LETTA_API_KEY` for the cloud backend. See the [quickstart](https://docs.letta.com/agent-sdk/quickstart) for the local and self-hosted paths.
|
|
82
81
|
|
|
@@ -17,6 +17,8 @@ export type AppServerSessionOptions = Partial<LettaCodeRemoteClientOptions> & {
|
|
|
17
17
|
url: string;
|
|
18
18
|
close(): void;
|
|
19
19
|
}>;
|
|
20
|
+
/** Require the app-server capability needed by local query conversations. */
|
|
21
|
+
requireLocalConversationCapability?: boolean;
|
|
20
22
|
};
|
|
21
23
|
export type AppServerSessionMode = RuntimeSessionMode;
|
|
22
24
|
export declare function externalToolGroups(tools: AnyAgentTool[] | undefined): Array<Record<string, unknown>> | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-server-session.d.ts","sourceRoot":"","sources":["../src/app-server-session.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,gCAAgC,EAEtC,MAAM,wCAAwC,CAAC;AAsBhD,OAAO,EACL,uBAAuB,EAKvB,KAAK,eAAe,EACpB,KAAK,6BAA6B,EAClC,KAAK,sBAAsB,EAC3B,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACxB,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EACV,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EAClB,4BAA4B,EAC5B,6BAA6B,EAC7B,gBAAgB,EAChB,mBAAmB,EACnB,kBAAkB,EAElB,8BAA8B,EAC9B,6BAA6B,EAC7B,WAAW,EACX,iBAAiB,EAClB,MAAM,YAAY,CAAC;AAWpB,KAAK,kBAAkB,GAAG;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;
|
|
1
|
+
{"version":3,"file":"app-server-session.d.ts","sourceRoot":"","sources":["../src/app-server-session.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,gCAAgC,EAEtC,MAAM,wCAAwC,CAAC;AAsBhD,OAAO,EACL,uBAAuB,EAKvB,KAAK,eAAe,EACpB,KAAK,6BAA6B,EAClC,KAAK,sBAAsB,EAC3B,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACxB,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EACV,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EAClB,4BAA4B,EAC5B,6BAA6B,EAC7B,gBAAgB,EAChB,mBAAmB,EACnB,kBAAkB,EAElB,8BAA8B,EAC9B,6BAA6B,EAC7B,WAAW,EACX,iBAAiB,EAClB,MAAM,YAAY,CAAC;AAWpB,KAAK,kBAAkB,GAAG;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAOF,wBAAgB,cAAc,CAC5B,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAC/B,MAAM,EAAE,GAAG,SAAS,CAStB;AAED,MAAM,MAAM,uBAAuB,GAAG,OAAO,CAAC,4BAA4B,CAAC,GAAG;IAC5E,0BAA0B;IAC1B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;O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B,GAC1B,OAAO,CAAC,iBAAiB,CAAC;IAYvB,uBAAuB,CAC3B,OAAO,EAAE,YAAY,EACrB,OAAO,GAAE,8BAAmC,GAC3C,OAAO,CAAC,6BAA6B,CAAC;IAqBnC,YAAY,CAChB,cAAc,EAAE,MAAM,EACtB,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,kBAAkB,CAAC;IAwC9B,KAAK,IAAI,IAAI;CAGd;AAED,qBAAa,gBAAiB,SAAQ,uBAAuB;IASzD,OAAO,CAAC,QAAQ,CAAC,aAAa;IARhC,OAAO,CAAC,eAAe,CAAkC;IACzD,OAAO,CAAC,aAAa,CAAmC;IACxD,OAAO,CAAC,SAAS,CAA8B;IAC/C,OAAO,CAAC,UAAU,CAAoC;IACtD,OAAO,CAAC,yBAAyB,CAA6B;IAC9D,OAAO,CAAC,2BAA2B,CAA6B;gBAG7C,aAAa,EAAE,uBAAuB,EACvD,IAAI,EAAE,oBAAoB;cAYT,iBAAiB,CAAC,OAAO,EAAE,6BAA6B,GAAG,kBAAkB,GAAG,OAAO;cAKjF,2BAA2B,IAAI,OAAO,CAAC,kBAAkB,CAAC;cA4GhE,WAAW,IAAI,IAAI;cAUb,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IAIxD,OAAO,CAAC,cAAc;YAOR,mBAAmB;YAenB,YAAY;YAOZ,wBAAwB;YA+GxB,0BAA0B;CAqBzC"}
|
package/dist/client-base.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { type SkillNodeSupport } from "./skill-loading.js";
|
|
|
3
3
|
import { type ComputerSelector, type ComputersClient } from "./computers.js";
|
|
4
4
|
import { type ManagementTransport } from "./management.js";
|
|
5
5
|
import type { AgentsClient, ConversationsClient, ModelsClient } from "./management-types.js";
|
|
6
|
-
import type {
|
|
6
|
+
import type { Query, QueryOptions, QueryParams } from "./query-types.js";
|
|
7
7
|
import type { CreateAgentOptions, LettaCodeBackend, LettaCodeClientOptions, LettaCodeClientSessionOptions, LettaCodeEnvironment, LettaCodeSession, SDKResultMessage, SendMessage } from "./types.js";
|
|
8
8
|
/**
|
|
9
9
|
* Top-level Letta Agent SDK client.
|
|
@@ -60,9 +60,9 @@ export declare class LettaAgentClientBase implements AsyncDisposable {
|
|
|
60
60
|
* Applications should use a session when they need interactive turn state.
|
|
61
61
|
*/
|
|
62
62
|
prompt(message: SendMessage, agentId: string, options?: LettaCodeClientSessionOptions): Promise<SDKResultMessage>;
|
|
63
|
-
/** Run one prompt in a new or resumed
|
|
63
|
+
/** Run one prompt in a new or resumed ordinary conversation. */
|
|
64
64
|
query(params: QueryParams): Query;
|
|
65
|
-
private
|
|
65
|
+
private createQuerySession;
|
|
66
66
|
private assertSessionBackend;
|
|
67
67
|
protected createLocalAgent(_options: CreateAgentOptions): Promise<string>;
|
|
68
68
|
/**
|
|
@@ -72,7 +72,7 @@ export declare class LettaAgentClientBase implements AsyncDisposable {
|
|
|
72
72
|
*/
|
|
73
73
|
protected skillNodeSupport(): SkillNodeSupport | undefined;
|
|
74
74
|
protected createLocalSession(_agentId: string, _options: LettaCodeClientSessionOptions): LettaCodeSession;
|
|
75
|
-
protected
|
|
75
|
+
protected createLocalQuerySession(_queryOptions: QueryOptions, _sessionOptions: LettaCodeClientSessionOptions): LettaCodeSession;
|
|
76
76
|
protected resumeLocalSession(_id: string, _options: LettaCodeClientSessionOptions): LettaCodeSession;
|
|
77
77
|
protected localBackendUnavailableError(): Error;
|
|
78
78
|
protected createLocalManagementTransport(): ManagementTransport;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-base.d.ts","sourceRoot":"","sources":["../src/client-base.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAqB,KAAK,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAS9E,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACrB,MAAM,gBAAgB,CAAC;AAOxB,OAAO,EAIL,KA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AAG,EAAE,MAAM,EACX,QAAQ,EAAE,6BAA6B,GACtC,gBAAgB;IAInB,SAAS,CAAC,4BAA4B,IAAI,KAAK;IAM/C,SAAS,CAAC,8BAA8B,IAAI,mBAAmB;IAI/D,OAAO,CAAC,aAAa;IAOrB,OAAO,CAAC,uBAAuB;IAI/B,OAAO,CAAC,kBAAkB;IAW1B,OAAO,CAAC,qBAAqB;IAY7B,OAAO,CAAC,0BAA0B;IAYlC,OAAO,CAAC,2BAA2B;IAQnC,OAAO,CAAC,cAAc;IAQtB,OAAO,CAAC,sBAAsB;IAiB9B;;;;OAIG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAUtB,wCAAwC;IAClC,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5C,OAAO,CAAC,UAAU;IAIlB,OAAO,CAAC,YAAY;CAMrB"}
|
package/dist/client-entry.js
CHANGED
|
@@ -9432,7 +9432,7 @@ function isAppServerInfoResponseMessage(message) {
|
|
|
9432
9432
|
return false;
|
|
9433
9433
|
}
|
|
9434
9434
|
const capabilityRecord = capabilities;
|
|
9435
|
-
return candidate.type === "app_server_info_response" && typeof candidate.request_id === "string" && candidate.request_id.length > 0 && candidate.success === true && (candidate.backend === "local" || candidate.backend === "api") && typeof candidate.letta_code_version === "string" && typeof candidate.protocol_version === "number" && Number.isInteger(candidate.protocol_version) && typeof capabilityRecord.agent_management === "boolean" && typeof capabilityRecord.conversation_management === "boolean" && typeof capabilityRecord.memory_management === "boolean" && typeof capabilityRecord.runtime_start === "boolean" && (capabilityRecord.launch_subagent === undefined || typeof capabilityRecord.launch_subagent === "boolean") && (capabilityRecord.runtime_workspace_sandbox === undefined || typeof capabilityRecord.runtime_workspace_sandbox === "boolean") && (capabilityRecord.runtime_external_tools_update === undefined || typeof capabilityRecord.runtime_external_tools_update === "boolean") && (capabilityRecord.structured_outputs === undefined || typeof capabilityRecord.structured_outputs === "boolean") && typeof capabilityRecord.split_channels === "boolean";
|
|
9435
|
+
return candidate.type === "app_server_info_response" && typeof candidate.request_id === "string" && candidate.request_id.length > 0 && candidate.success === true && (candidate.backend === "local" || candidate.backend === "api") && typeof candidate.letta_code_version === "string" && typeof candidate.protocol_version === "number" && Number.isInteger(candidate.protocol_version) && typeof capabilityRecord.agent_management === "boolean" && typeof capabilityRecord.conversation_management === "boolean" && typeof capabilityRecord.memory_management === "boolean" && typeof capabilityRecord.runtime_start === "boolean" && (capabilityRecord.agent_free_conversations === undefined || typeof capabilityRecord.agent_free_conversations === "boolean") && (capabilityRecord.launch_subagent === undefined || typeof capabilityRecord.launch_subagent === "boolean") && (capabilityRecord.runtime_workspace_sandbox === undefined || typeof capabilityRecord.runtime_workspace_sandbox === "boolean") && (capabilityRecord.runtime_external_tools_update === undefined || typeof capabilityRecord.runtime_external_tools_update === "boolean") && (capabilityRecord.structured_outputs === undefined || typeof capabilityRecord.structured_outputs === "boolean") && typeof capabilityRecord.split_channels === "boolean";
|
|
9436
9436
|
}
|
|
9437
9437
|
var DEFAULT_REQUEST_TIMEOUT_MS = 30000;
|
|
9438
9438
|
var WEBSOCKET_OPEN_STATE = 1;
|
|
@@ -14538,6 +14538,7 @@ class RemoteClientSessionCore {
|
|
|
14538
14538
|
}
|
|
14539
14539
|
|
|
14540
14540
|
// src/app-server-session.ts
|
|
14541
|
+
var LOCAL_CONVERSATION_CAPABILITY = "agent_free_conversations";
|
|
14541
14542
|
function agentToolNames(agent) {
|
|
14542
14543
|
const tools = agent && "tools" in agent ? agent.tools : undefined;
|
|
14543
14544
|
if (!Array.isArray(tools))
|
|
@@ -14939,6 +14940,13 @@ class AppServerSession extends RemoteClientSessionCore {
|
|
|
14939
14940
|
}
|
|
14940
14941
|
try {
|
|
14941
14942
|
await client.connect();
|
|
14943
|
+
if (this.mode.kind === "conversation" && this.remoteOptions.requireLocalConversationCapability === true) {
|
|
14944
|
+
const info = await client.info();
|
|
14945
|
+
const capabilities = info.capabilities;
|
|
14946
|
+
if (info.backend === "local" && capabilities[LOCAL_CONVERSATION_CAPABILITY] !== true) {
|
|
14947
|
+
throw new Error(`Local query() requires a Letta Code app-server with local conversation support (connected version: ${info.letta_code_version}). Upgrade @letta-ai/letta-code.`);
|
|
14948
|
+
}
|
|
14949
|
+
}
|
|
14942
14950
|
const response = await this.startRuntime(client);
|
|
14943
14951
|
if (!response.success || !response.runtime) {
|
|
14944
14952
|
throw new Error(response.error ?? "Failed to start app-server runtime");
|
|
@@ -15016,7 +15024,7 @@ class AppServerSession extends RemoteClientSessionCore {
|
|
|
15016
15024
|
const mode = mapPermissionMode(options.permissionMode);
|
|
15017
15025
|
if (mode)
|
|
15018
15026
|
command.mode = mode;
|
|
15019
|
-
if (this.mode.kind === "
|
|
15027
|
+
if (this.mode.kind === "conversation" && this.mode.disableMemoryGuard === true) {
|
|
15020
15028
|
command.execution_settings = {
|
|
15021
15029
|
allowed_tools: [],
|
|
15022
15030
|
disallowed_tools: [],
|
|
@@ -15042,7 +15050,7 @@ class AppServerSession extends RemoteClientSessionCore {
|
|
|
15042
15050
|
};
|
|
15043
15051
|
return command;
|
|
15044
15052
|
}
|
|
15045
|
-
if (this.mode.kind === "
|
|
15053
|
+
if (this.mode.kind === "conversation") {
|
|
15046
15054
|
if (this.mode.createConversation) {
|
|
15047
15055
|
const create = this.mode.createConversation;
|
|
15048
15056
|
command.create_conversation = {
|
|
@@ -15059,7 +15067,7 @@ class AppServerSession extends RemoteClientSessionCore {
|
|
|
15059
15067
|
} else if (this.mode.conversationId) {
|
|
15060
15068
|
command.conversation_id = this.mode.conversationId;
|
|
15061
15069
|
} else {
|
|
15062
|
-
throw new Error("
|
|
15070
|
+
throw new Error("Query sessions require a conversation to create or resume.");
|
|
15063
15071
|
}
|
|
15064
15072
|
return command;
|
|
15065
15073
|
}
|
|
@@ -16127,9 +16135,9 @@ class CloudEnvironmentSession extends RemoteClientSessionCore {
|
|
|
16127
16135
|
return bridge?.close() ?? Promise.resolve();
|
|
16128
16136
|
}
|
|
16129
16137
|
async resolveRuntime() {
|
|
16130
|
-
if (this.cloudMode.kind === "
|
|
16138
|
+
if (this.cloudMode.kind === "conversation") {
|
|
16131
16139
|
if (!this.cloudMode.conversationId) {
|
|
16132
|
-
throw new Error("Cloud
|
|
16140
|
+
throw new Error("Cloud query sessions require a conversation id.");
|
|
16133
16141
|
}
|
|
16134
16142
|
return {
|
|
16135
16143
|
runtime: {
|
|
@@ -16284,7 +16292,7 @@ class CloudEnvironmentSession extends RemoteClientSessionCore {
|
|
|
16284
16292
|
}
|
|
16285
16293
|
async createManagedSandboxConnection(runtime) {
|
|
16286
16294
|
if (!runtime.agent_id) {
|
|
16287
|
-
throw new Error("
|
|
16295
|
+
throw new Error("Queries without an agent require an explicit Cloud computer; managed sandboxes are agent-scoped.");
|
|
16288
16296
|
}
|
|
16289
16297
|
const conversationId = runtime.conversation_id && runtime.conversation_id !== "default" ? runtime.conversation_id : undefined;
|
|
16290
16298
|
const sandbox = await this.createManagedSandbox(runtime.agent_id, conversationId);
|
|
@@ -16871,7 +16879,7 @@ function hasCreateAgentEnvironment(options) {
|
|
|
16871
16879
|
function looksLikeConversationId(id) {
|
|
16872
16880
|
return id.startsWith("conv-") || id.startsWith("local-conv-");
|
|
16873
16881
|
}
|
|
16874
|
-
function
|
|
16882
|
+
function querySessionOptions(options) {
|
|
16875
16883
|
const {
|
|
16876
16884
|
system: _system,
|
|
16877
16885
|
parentAgentId: _parentAgentId,
|
|
@@ -16885,7 +16893,7 @@ function agentFreeSessionOptions(options) {
|
|
|
16885
16893
|
} = options;
|
|
16886
16894
|
return sessionOptions;
|
|
16887
16895
|
}
|
|
16888
|
-
function
|
|
16896
|
+
function validateQueryOptions(options) {
|
|
16889
16897
|
if (options.conversationId !== undefined && (typeof options.conversationId !== "string" || !options.conversationId.trim())) {
|
|
16890
16898
|
throw new Error("query() conversationId must be a non-empty string.");
|
|
16891
16899
|
}
|
|
@@ -16895,7 +16903,7 @@ function validateAgentFreeQueryOptions(options) {
|
|
|
16895
16903
|
if (typeof options.system !== "string") {
|
|
16896
16904
|
throw new Error("query() requires a system prompt.");
|
|
16897
16905
|
}
|
|
16898
|
-
validateCreateSessionOptions(
|
|
16906
|
+
validateCreateSessionOptions(querySessionOptions(options));
|
|
16899
16907
|
}
|
|
16900
16908
|
|
|
16901
16909
|
class LettaAgentClientBase {
|
|
@@ -17072,20 +17080,20 @@ class LettaAgentClientBase {
|
|
|
17072
17080
|
}
|
|
17073
17081
|
query(params) {
|
|
17074
17082
|
this.assertOpen();
|
|
17075
|
-
|
|
17076
|
-
return createQuery((options) => this.
|
|
17083
|
+
validateQueryOptions(params.options);
|
|
17084
|
+
return createQuery((options) => this.createQuerySession(options), params);
|
|
17077
17085
|
}
|
|
17078
|
-
async
|
|
17086
|
+
async createQuerySession(options) {
|
|
17079
17087
|
this.assertOpen();
|
|
17080
|
-
|
|
17081
|
-
const sessionOptions =
|
|
17088
|
+
validateQueryOptions(options);
|
|
17089
|
+
const sessionOptions = querySessionOptions(options);
|
|
17082
17090
|
this.assertSessionBackend("query", sessionOptions);
|
|
17083
17091
|
if (options.disableMemoryGuard === true && this.backend === "cloud") {
|
|
17084
17092
|
throw new Error('query() disableMemoryGuard is only supported with backend: "local" or "remote".');
|
|
17085
17093
|
}
|
|
17086
17094
|
if (this.backend === "remote") {
|
|
17087
17095
|
return new AppServerSession(this.appServerSessionOptions(), {
|
|
17088
|
-
kind: "
|
|
17096
|
+
kind: "conversation",
|
|
17089
17097
|
...options.conversationId ? { conversationId: options.conversationId } : {
|
|
17090
17098
|
createConversation: {
|
|
17091
17099
|
model: options.model,
|
|
@@ -17118,15 +17126,15 @@ class LettaAgentClientBase {
|
|
|
17118
17126
|
}
|
|
17119
17127
|
});
|
|
17120
17128
|
if (!conversation || typeof conversation !== "object" || typeof conversation.id !== "string") {
|
|
17121
|
-
throw new Error("Cloud
|
|
17129
|
+
throw new Error("Cloud query conversation response did not include a conversation id.");
|
|
17122
17130
|
}
|
|
17123
17131
|
return new CloudEnvironmentSession(this.cloudOptions(), {
|
|
17124
|
-
kind: "
|
|
17132
|
+
kind: "conversation",
|
|
17125
17133
|
conversationId: conversation.id,
|
|
17126
17134
|
options: sessionOptions
|
|
17127
17135
|
}, this.getCloudClient());
|
|
17128
17136
|
}
|
|
17129
|
-
return this.
|
|
17137
|
+
return this.createLocalQuerySession(options, sessionOptions);
|
|
17130
17138
|
}
|
|
17131
17139
|
assertSessionBackend(action, options) {
|
|
17132
17140
|
if (options.computer !== undefined && options.environment !== undefined) {
|
|
@@ -17198,7 +17206,7 @@ class LettaAgentClientBase {
|
|
|
17198
17206
|
createLocalSession(_agentId, _options) {
|
|
17199
17207
|
throw this.localBackendUnavailableError();
|
|
17200
17208
|
}
|
|
17201
|
-
|
|
17209
|
+
createLocalQuerySession(_queryOptions, _sessionOptions) {
|
|
17202
17210
|
throw this.localBackendUnavailableError();
|
|
17203
17211
|
}
|
|
17204
17212
|
resumeLocalSession(_id, _options) {
|
|
@@ -17815,4 +17823,4 @@ export {
|
|
|
17815
17823
|
CloudManagedSandboxExpiredError
|
|
17816
17824
|
};
|
|
17817
17825
|
|
|
17818
|
-
//# debugId=
|
|
17826
|
+
//# debugId=066C5652FCCEF11364756E2164756E21
|