@aexhq/sdk 0.32.0 → 0.33.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.
package/dist/cli.mjs CHANGED
@@ -11700,14 +11700,14 @@ var init_client = __esm({
11700
11700
  return { req, url, timeout: options.timeout };
11701
11701
  }
11702
11702
  async buildHeaders({ options, method, bodyHeaders, retryCount }) {
11703
- let idempotencyHeaders = {};
11703
+ let idempotencyHeaders2 = {};
11704
11704
  if (this.idempotencyHeader && method !== "get") {
11705
11705
  if (!options.idempotencyKey)
11706
11706
  options.idempotencyKey = this.defaultIdempotencyKey();
11707
- idempotencyHeaders[this.idempotencyHeader] = options.idempotencyKey;
11707
+ idempotencyHeaders2[this.idempotencyHeader] = options.idempotencyKey;
11708
11708
  }
11709
11709
  const headers = buildHeaders([
11710
- idempotencyHeaders,
11710
+ idempotencyHeaders2,
11711
11711
  {
11712
11712
  Accept: "application/json",
11713
11713
  "User-Agent": this.getUserAgent(),
@@ -12013,96 +12013,6 @@ var TERMINAL_RUN_STATUSES = [
12013
12013
  ];
12014
12014
  var terminalRunStatuses = new Set(TERMINAL_RUN_STATUSES);
12015
12015
 
12016
- // ../contracts/dist/runtime-sizes.js
12017
- var RUNTIME_SIZE_PRESETS = {
12018
- "shared-0.06x-256mb": { cpus: 0.0625, memoryMb: 256 },
12019
- "shared-0.25x-1gb": { cpus: 0.25, memoryMb: 1024 },
12020
- "shared-0.5x-4gb": { cpus: 0.5, memoryMb: 4096 },
12021
- "shared-1x-6gb": { cpus: 1, memoryMb: 6144 },
12022
- "shared-2x-8gb": { cpus: 2, memoryMb: 8192 },
12023
- "shared-4x-12gb": { cpus: 4, memoryMb: 12288 }
12024
- };
12025
- var RUNTIME_SIZES = Object.keys(RUNTIME_SIZE_PRESETS);
12026
- var DEFAULT_RUNTIME_SIZE = "shared-0.25x-1gb";
12027
- var DEFAULT_RUN_TIMEOUT_MS = 60 * 60 * 1e3;
12028
- var MAX_RUN_TIMEOUT_MS = 6 * 60 * 60 * 1e3;
12029
- var MIN_RUN_TIMEOUT_MS = 60 * 1e3;
12030
- var DURATION_PATTERN = /^(\d+(?:\.\d+)?)(ms|s|m|h)?$/;
12031
- function parseDurationToMs(input) {
12032
- const match = DURATION_PATTERN.exec(input.trim());
12033
- if (!match) {
12034
- throw new Error(`invalid duration ${JSON.stringify(input)} (expected e.g. "1h", "90m", "30s", "500ms", or a bare ms integer)`);
12035
- }
12036
- const value = Number(match[1]);
12037
- if (!Number.isFinite(value) || value < 0) {
12038
- throw new Error(`invalid duration ${JSON.stringify(input)} (must be a non-negative number)`);
12039
- }
12040
- const unit = match[2] ?? "ms";
12041
- const factor = unit === "h" ? 36e5 : unit === "m" ? 6e4 : unit === "s" ? 1e3 : 1;
12042
- return Math.round(value * factor);
12043
- }
12044
- var RUN_PROCESS_KILL_GRACE_MS = 60 * 1e3;
12045
- var RUN_TERMINAL_GRACE_MS = 90 * 1e3;
12046
-
12047
- // ../contracts/dist/post-hook.js
12048
- var DEFAULT_POST_HOOK_TIMEOUT_MS = 5 * 60 * 1e3;
12049
- var DEFAULT_POST_HOOK_MAX_TURNS = 10;
12050
- function parsePostHook(input, path5 = "postHook") {
12051
- if (input === void 0 || input === null) {
12052
- return void 0;
12053
- }
12054
- const value = requirePostHookRecord(input, path5);
12055
- const allowed = /* @__PURE__ */ new Set(["command", "timeout", "maxTurns", "maxChars"]);
12056
- for (const key of Object.keys(value)) {
12057
- if (!allowed.has(key)) {
12058
- throw new Error(`${path5}.${key} is not an allowed field; permitted: command, timeout, maxTurns, maxChars`);
12059
- }
12060
- }
12061
- if (typeof value.command !== "string") {
12062
- throw new Error(`${path5}.command must be a string`);
12063
- }
12064
- if (value.command.trim().length === 0) {
12065
- return void 0;
12066
- }
12067
- const timeoutMs = parsePostHookTimeout(value.timeout, `${path5}.timeout`);
12068
- const maxTurns = parseNonNegativeInteger(value.maxTurns, `${path5}.maxTurns`, DEFAULT_POST_HOOK_MAX_TURNS);
12069
- const maxChars = value.maxChars === null ? null : parseNonNegativeInteger(value.maxChars, `${path5}.maxChars`, null);
12070
- return {
12071
- command: value.command,
12072
- timeoutMs,
12073
- maxTurns,
12074
- maxChars
12075
- };
12076
- }
12077
- function parsePostHookTimeout(input, path5) {
12078
- if (input === void 0) {
12079
- return DEFAULT_POST_HOOK_TIMEOUT_MS;
12080
- }
12081
- if (typeof input !== "string") {
12082
- throw new Error(`${path5} must be a duration string (e.g. "5m", "30s"); got ${JSON.stringify(input)}`);
12083
- }
12084
- const ms = parseDurationToMs(input);
12085
- if (ms <= 0) {
12086
- throw new Error(`${path5} must be greater than 0ms; got ${ms}ms`);
12087
- }
12088
- return ms;
12089
- }
12090
- function parseNonNegativeInteger(input, path5, defaultValue) {
12091
- if (input === void 0) {
12092
- return defaultValue;
12093
- }
12094
- if (typeof input !== "number" || !Number.isSafeInteger(input) || input < 0) {
12095
- throw new Error(`${path5} must be a non-negative integer`);
12096
- }
12097
- return input;
12098
- }
12099
- function requirePostHookRecord(input, path5) {
12100
- if (input === null || typeof input !== "object" || Array.isArray(input)) {
12101
- throw new Error(`${path5} must be an object`);
12102
- }
12103
- return input;
12104
- }
12105
-
12106
12016
  // ../contracts/dist/run-config.js
12107
12017
  var SKILL_BUNDLE_LIMITS = {
12108
12018
  /** Compressed (.zip) ceiling. */
@@ -12414,7 +12324,6 @@ function parseRunRequestConfig(input) {
12414
12324
  "environment",
12415
12325
  "runtimeSize",
12416
12326
  "timeout",
12417
- "postHook",
12418
12327
  "proxyEndpoints",
12419
12328
  "metadata"
12420
12329
  ]);
@@ -12431,7 +12340,6 @@ function parseRunRequestConfig(input) {
12431
12340
  const prompt = parseRunRequestConfigPrompt(record.prompt);
12432
12341
  const skills = parseRunRequestConfigSkills(record.skills);
12433
12342
  const mcpServers = parseRunRequestConfigMcpServers(record.mcpServers);
12434
- const postHook = parsePostHook(record.postHook, "run request config postHook");
12435
12343
  return {
12436
12344
  model,
12437
12345
  ...system !== void 0 ? { system } : {},
@@ -12445,7 +12353,6 @@ function parseRunRequestConfig(input) {
12445
12353
  ...record.environment !== void 0 ? { environment: record.environment } : {},
12446
12354
  ...record.runtimeSize !== void 0 ? { runtimeSize: record.runtimeSize } : {},
12447
12355
  ...record.timeout !== void 0 ? { timeout: record.timeout } : {},
12448
- ...postHook !== void 0 ? { postHook: record.postHook } : {},
12449
12356
  ...record.proxyEndpoints !== void 0 ? { proxyEndpoints: record.proxyEndpoints } : {},
12450
12357
  ...record.metadata !== void 0 ? { metadata: record.metadata } : {}
12451
12358
  };
@@ -12500,6 +12407,23 @@ function parseRunRequestConfigMcpServers(value) {
12500
12407
  });
12501
12408
  }
12502
12409
 
12410
+ // ../contracts/dist/runtime-sizes.js
12411
+ var RUNTIME_SIZE_PRESETS = {
12412
+ "shared-0.06x-256mb": { cpus: 0.0625, memoryMb: 256 },
12413
+ "shared-0.25x-1gb": { cpus: 0.25, memoryMb: 1024 },
12414
+ "shared-0.5x-4gb": { cpus: 0.5, memoryMb: 4096 },
12415
+ "shared-1x-6gb": { cpus: 1, memoryMb: 6144 },
12416
+ "shared-2x-8gb": { cpus: 2, memoryMb: 8192 },
12417
+ "shared-4x-12gb": { cpus: 4, memoryMb: 12288 }
12418
+ };
12419
+ var RUNTIME_SIZES = Object.keys(RUNTIME_SIZE_PRESETS);
12420
+ var DEFAULT_RUNTIME_SIZE = "shared-0.25x-1gb";
12421
+ var DEFAULT_RUN_TIMEOUT_MS = 60 * 60 * 1e3;
12422
+ var MAX_RUN_TIMEOUT_MS = 6 * 60 * 60 * 1e3;
12423
+ var MIN_RUN_TIMEOUT_MS = 60 * 1e3;
12424
+ var RUN_PROCESS_KILL_GRACE_MS = 60 * 1e3;
12425
+ var RUN_TERMINAL_GRACE_MS = 90 * 1e3;
12426
+
12503
12427
  // ../contracts/dist/runtime-security-profile.js
12504
12428
  var RUNTIME_SECURITY_PROFILE_CONFIG = Object.freeze({
12505
12429
  strict: Object.freeze({
@@ -13383,14 +13307,17 @@ __export(operations_exports, {
13383
13307
  READ_OUTPUT_TEXT_DEFAULT_BYTES: () => READ_OUTPUT_TEXT_DEFAULT_BYTES,
13384
13308
  READ_OUTPUT_TEXT_MAX_BYTES: () => READ_OUTPUT_TEXT_MAX_BYTES,
13385
13309
  cancelRun: () => cancelRun,
13310
+ cancelSession: () => cancelSession,
13386
13311
  classifyOutput: () => classifyOutput,
13387
13312
  createOutputLink: () => createOutputLink,
13388
13313
  createSecret: () => createSecret,
13314
+ createSession: () => createSession,
13389
13315
  createSkillBundleDirect: () => createSkillBundleDirect,
13390
13316
  deleteAgentsMd: () => deleteAgentsMd,
13391
13317
  deleteFile: () => deleteFile,
13392
13318
  deleteRun: () => deleteRun,
13393
13319
  deleteSecret: () => deleteSecret,
13320
+ deleteSession: () => deleteSession,
13394
13321
  deleteSkill: () => deleteSkill,
13395
13322
  deleteWorkspaceAsset: () => deleteWorkspaceAsset,
13396
13323
  download: () => download,
@@ -13412,6 +13339,8 @@ __export(operations_exports, {
13412
13339
  getRunWebhookDeliveries: () => getRunWebhookDeliveries,
13413
13340
  getSecret: () => getSecret,
13414
13341
  getSecretValue: () => getSecretValue,
13342
+ getSession: () => getSession,
13343
+ getSessionCoordinatorTicket: () => getSessionCoordinatorTicket,
13415
13344
  getSkill: () => getSkill,
13416
13345
  listAgentsMd: () => listAgentsMd,
13417
13346
  listFiles: () => listFiles,
@@ -13419,14 +13348,20 @@ __export(operations_exports, {
13419
13348
  listRunEvents: () => listRunEvents,
13420
13349
  listRuns: () => listRuns,
13421
13350
  listSecrets: () => listSecrets,
13351
+ listSessionEvents: () => listSessionEvents,
13352
+ listSessionOutputs: () => listSessionOutputs,
13353
+ listSessions: () => listSessions,
13422
13354
  listSkills: () => listSkills,
13423
13355
  normalizeOutputLinkExpiresIn: () => normalizeOutputLinkExpiresIn,
13424
13356
  outputLink: () => outputLink,
13425
13357
  readOutputText: () => readOutputText,
13426
13358
  redeliverRunWebhook: () => redeliverRunWebhook,
13427
13359
  resolveOutputFileSelector: () => resolveOutputFileSelector,
13360
+ resumeSession: () => resumeSession,
13428
13361
  rotateSecret: () => rotateSecret,
13362
+ sendSessionMessage: () => sendSessionMessage,
13429
13363
  submitRun: () => submitRun,
13364
+ suspendSession: () => suspendSession,
13430
13365
  uploadWorkspaceAsset: () => uploadWorkspaceAsset,
13431
13366
  whoami: () => whoami
13432
13367
  });
@@ -14167,6 +14102,79 @@ async function listRuns(http, query) {
14167
14102
  params.cursor = query.cursor;
14168
14103
  return http.request("/api/runs", {}, params);
14169
14104
  }
14105
+ function idempotencyHeaders(options) {
14106
+ return options?.idempotencyKey ? { "Idempotency-Key": options.idempotencyKey } : void 0;
14107
+ }
14108
+ async function createSession(http, request, options) {
14109
+ const headers = idempotencyHeaders(options);
14110
+ const result = await http.request("/api/sessions", {
14111
+ method: "POST",
14112
+ ...headers ? { headers } : {},
14113
+ body: JSON.stringify(request)
14114
+ });
14115
+ return unwrapSession(result);
14116
+ }
14117
+ async function getSession(http, sessionId) {
14118
+ const result = await http.request(`/api/sessions/${encodeURIComponent(sessionId)}`);
14119
+ return unwrapSession(result);
14120
+ }
14121
+ async function listSessions(http, query) {
14122
+ const params = {};
14123
+ if (query?.status !== void 0)
14124
+ params.status = query.status;
14125
+ if (query?.since !== void 0)
14126
+ params.since = query.since;
14127
+ if (query?.limit !== void 0)
14128
+ params.limit = String(query.limit);
14129
+ if (query?.cursor !== void 0)
14130
+ params.cursor = query.cursor;
14131
+ return http.request("/api/sessions", {}, params);
14132
+ }
14133
+ async function sendSessionMessage(http, sessionId, request, options) {
14134
+ const headers = idempotencyHeaders(options);
14135
+ return http.request(`/api/sessions/${encodeURIComponent(sessionId)}/messages`, {
14136
+ method: "POST",
14137
+ ...headers ? { headers } : {},
14138
+ body: JSON.stringify(request)
14139
+ });
14140
+ }
14141
+ async function suspendSession(http, sessionId, options) {
14142
+ const headers = idempotencyHeaders(options);
14143
+ return http.request(`/api/sessions/${encodeURIComponent(sessionId)}/suspend`, { method: "POST", ...headers ? { headers } : {} });
14144
+ }
14145
+ async function cancelSession(http, sessionId, options) {
14146
+ const headers = idempotencyHeaders(options);
14147
+ return http.request(`/api/sessions/${encodeURIComponent(sessionId)}/cancel`, { method: "POST", ...headers ? { headers } : {} });
14148
+ }
14149
+ async function resumeSession(http, sessionId, options) {
14150
+ const headers = idempotencyHeaders(options);
14151
+ return http.request(`/api/sessions/${encodeURIComponent(sessionId)}/resume`, { method: "POST", ...headers ? { headers } : {} });
14152
+ }
14153
+ async function deleteSession(http, sessionId, options) {
14154
+ const headers = idempotencyHeaders(options);
14155
+ return http.request(`/api/sessions/${encodeURIComponent(sessionId)}`, { method: "DELETE", ...headers ? { headers } : {} });
14156
+ }
14157
+ async function listSessionEvents(http, sessionId) {
14158
+ const path5 = `/api/sessions/${encodeURIComponent(sessionId)}/events`;
14159
+ const all = [];
14160
+ let cursor;
14161
+ for (let page = 0; page < LIST_EVENTS_PAGE_BUDGET; page++) {
14162
+ const query = cursor !== void 0 ? { cursor: String(cursor) } : {};
14163
+ const result = await http.request(path5, {}, query);
14164
+ all.push(...result.events);
14165
+ if (typeof result.nextCursor !== "number")
14166
+ break;
14167
+ cursor = result.nextCursor;
14168
+ }
14169
+ return all;
14170
+ }
14171
+ async function listSessionOutputs(http, sessionId, query) {
14172
+ const result = await http.request(`/api/sessions/${encodeURIComponent(sessionId)}/outputs`);
14173
+ return query === void 0 ? result.outputs : filterOutputs(result.outputs, query);
14174
+ }
14175
+ async function getSessionCoordinatorTicket(http, sessionId) {
14176
+ return http.request(`/api/sessions/${encodeURIComponent(sessionId)}/events/ticket`, { method: "POST" });
14177
+ }
14170
14178
  var LIST_EVENTS_PAGE_BUDGET = 1e3;
14171
14179
  async function listRunEvents(http, runId) {
14172
14180
  const path5 = `/api/runs/${encodeURIComponent(runId)}/events`;
@@ -14780,6 +14788,12 @@ function unwrapSkill(result) {
14780
14788
  function hasRun(value) {
14781
14789
  return Boolean(value && typeof value === "object" && "run" in value);
14782
14790
  }
14791
+ function unwrapSession(result) {
14792
+ if (result && typeof result === "object" && "session" in result) {
14793
+ return result.session;
14794
+ }
14795
+ return result;
14796
+ }
14783
14797
  async function uploadWorkspaceAsset(http, input) {
14784
14798
  return http.request("/assets", {
14785
14799
  method: "POST",
@@ -15772,7 +15786,6 @@ async function runRunCmd(io2, argv) {
15772
15786
  secrets,
15773
15787
  ...runtimeSizeFlag.value ? { runtimeSize: runtimeSizeFlag.value } : runConfig.runtimeSize ? { runtimeSize: runConfig.runtimeSize } : {},
15774
15788
  ...runTimeoutFlag.value ? { timeout: runTimeoutFlag.value } : runConfig.timeout ? { timeout: runConfig.timeout } : {},
15775
- ...runConfig.postHook ? { postHook: runConfig.postHook } : {},
15776
15789
  ...webhookFlag.value ? { webhook: { url: webhookFlag.value } } : {},
15777
15790
  ...proxyEndpoints.length > 0 ? { proxyEndpoints } : {}
15778
15791
  };
@@ -1 +1 @@
1
- 91bc1e9fe17896658e7fea3117b8a16b601da0a747b121ee3628e6a95a00ddc1 cli.mjs
1
+ ad37c1366dc0104bf96adc80f5b48d9a2b8b7cf73bc6cba0d014a3d458441855 cli.mjs
package/dist/client.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { HttpClient, SecretString, type AexEvent, type AgentsMdRecord, type DebugSink, type FetchLike, type FileRecord, type Output, type OutputFileType, type OutputLink, type OutputLinkOptions, type OutputQuery, type OutputText, type OutputMode, type ReadOutputTextOptions, type RunListPage, type RunListQuery, type OutputSearchQuery, type OutputSearchPage, type PlatformEnvironmentInput, type PlatformSubmission, type PlatformInlineSecrets, type PlatformProxyEndpoint, type PlatformProxyEndpointAuth, type PlatformPostHookInput, type Run, type RunModel, type RunEvent, type RunTrace, type UsageSummary, type RunLimits, type RunWebhookDelivery, type RunProvider, type SecretRecord, type SecretReveal, type RunUnit, type BuiltinToolName, type RuntimeSize, type Skill as SkillRecord, type WhoAmI } from "./_contracts/index.js";
1
+ import { HttpClient, SecretString, type AexEvent, type AgentsMdRecord, type DebugSink, type FetchLike, type FileRecord, type Output, type OutputFileType, type OutputLink, type OutputLinkOptions, type OutputQuery, type OutputText, type OutputMode, type ReadOutputTextOptions, type RunListPage, type RunListQuery, type OutputSearchQuery, type OutputSearchPage, type Session, type SessionCreateRequest, type SessionEvent, type SessionListPage, type SessionListQuery, type SessionStateChangeAccepted, type SessionTurn, type PlatformEnvironmentInput, type PlatformSubmission, type PlatformInlineSecrets, type PlatformProxyEndpoint, type PlatformProxyEndpointAuth, type Run, type RunModel, type RunEvent, type RunTrace, type UsageSummary, type RunLimits, type RunWebhookDelivery, type RunProvider, type SecretRecord, type SecretReveal, type RunUnit, type BuiltinToolName, type RuntimeSize, type Skill as SkillRecord, type WebSocketFactory, type WhoAmI } from "./_contracts/index.js";
2
2
  import { AgentsMd } from "./agents-md.js";
3
3
  import { type UploadedAsset } from "./asset-upload.js";
4
4
  import { File } from "./file.js";
@@ -110,12 +110,6 @@ export interface SubmitOptions {
110
110
  * [1m, 6h]; omit for the 1h default. Applies to both runtimes.
111
111
  */
112
112
  readonly timeout?: string;
113
- /**
114
- * Command to run after the agent process exits successfully. A non-zero exit
115
- * or timeout is sent back to the model as a repair prompt until `maxTurns`
116
- * is exhausted. Empty commands are treated as omitted.
117
- */
118
- readonly postHook?: PlatformPostHookInput;
119
113
  readonly proxyEndpoints?: readonly ProxyEndpoint[];
120
114
  /**
121
115
  * Output capture policy for the run's output files.
@@ -186,24 +180,29 @@ export interface SubmitOptions {
186
180
  * shape + positivity are validated client-side.
187
181
  */
188
182
  readonly limits?: RunLimits;
189
- readonly signal?: AbortSignal;
190
183
  }
191
184
  /**
192
185
  * The settle-consistent result of {@link AgentExecutor.run} / `runAndCollect`:
193
- * the terminal run record plus its settle-bracketed events, decoded trace,
194
- * assistant text, and captured outputs — everything a "do it and give me the
195
- * result" caller needs without hand-rolling a poll loop.
186
+ * the one-shot session record plus its events, decoded trace, assistant text,
187
+ * and captured outputs — everything a "do it and give me the result" caller
188
+ * needs without hand-rolling a session/message/stream loop.
196
189
  */
197
190
  export interface RunResult {
198
191
  readonly runId: string;
199
- /** The full terminal run record (status, costTelemetry, timings). */
192
+ /** The session id used as the run-compatible handle. */
193
+ readonly sessionId?: string;
194
+ /** Run-compatible view of the underlying session record. */
200
195
  readonly run: Run;
196
+ /** The underlying resumable session record. */
197
+ readonly session?: Session;
198
+ /** The turn accepted for this one-shot run. */
199
+ readonly turn?: SessionTurn;
201
200
  readonly status: string;
202
- /** `true` when `status === "succeeded"`. */
201
+ /** `true` when the one-shot turn parked the session cleanly (`idle` or `suspended`). */
203
202
  readonly ok: boolean;
204
- /** The assistant's final text (decoded over the settled events). */
203
+ /** The assistant's final text. */
205
204
  readonly text: string;
206
- /** The settle-bracketed event stream (RUN_STARTED … terminal). */
205
+ /** The session turn event stream. */
207
206
  readonly events: readonly RunEvent[];
208
207
  /** Decoded view of the events: tool calls + usage + assistant text. */
209
208
  readonly trace: RunTrace;
@@ -218,12 +217,96 @@ export interface RunResult {
218
217
  }
219
218
  /** Options for {@link AgentExecutor.run} / `runAndCollect`. */
220
219
  export interface RunCollectOptions {
221
- /** Overall wait budget (ms) for the run to reach a terminal record. */
220
+ /** Overall wait budget (ms) for the one-shot session turn to park. */
222
221
  readonly timeoutMs?: number;
223
- readonly signal?: AbortSignal;
222
+ readonly webSocketFactory?: WebSocketFactory;
223
+ readonly idleTimeoutMs?: number;
224
+ readonly pingIntervalMs?: number;
224
225
  /** Throw a {@link RunStateError} when the run does not succeed. Default false. */
225
226
  readonly throwOnFailure?: boolean;
226
227
  }
228
+ export type SessionInput = string | readonly string[];
229
+ export type ChatInput = SessionInput;
230
+ export interface SessionEnvironmentOptions extends Omit<PlatformEnvironmentInput, "envVars"> {
231
+ readonly variables?: Readonly<Record<string, string>>;
232
+ readonly secrets?: Readonly<Record<string, Secret>>;
233
+ }
234
+ export interface SessionOverrides {
235
+ readonly idleTtl?: string;
236
+ readonly timeout?: string;
237
+ readonly maxSpendUsd?: number;
238
+ }
239
+ export interface SessionCreateOptions extends Omit<SubmitOptions, "prompt" | "webhook" | "environment" | "secretEnv" | "secrets" | "runtimeSize" | "parentRunId" | "limits" | "timeout"> {
240
+ readonly apiKeys?: Partial<Record<RunProvider, string>>;
241
+ readonly environment?: SessionEnvironmentOptions;
242
+ readonly runtime?: RuntimeSize;
243
+ readonly overrides?: SessionOverrides;
244
+ }
245
+ export type ChatCreateOptions = SessionCreateOptions;
246
+ export interface SessionSendOptions {
247
+ readonly idempotencyKey?: string;
248
+ readonly from?: number;
249
+ readonly webSocketFactory?: WebSocketFactory;
250
+ readonly idleTimeoutMs?: number;
251
+ readonly pingIntervalMs?: number;
252
+ }
253
+ export type ChatSendOptions = SessionSendOptions;
254
+ export interface SessionRunOptions extends SessionCreateOptions {
255
+ readonly message: SessionInput;
256
+ readonly deleteAfter?: boolean;
257
+ readonly messageIdempotencyKey?: string;
258
+ readonly stream?: Omit<SessionSendOptions, "idempotencyKey">;
259
+ }
260
+ export type ChatRunOptions = SessionRunOptions;
261
+ export interface SessionTurnResult {
262
+ readonly sessionId: string;
263
+ readonly session: Session;
264
+ readonly turn: SessionTurn;
265
+ readonly status: string;
266
+ readonly text: string;
267
+ readonly events: readonly SessionEvent[];
268
+ readonly outputs: readonly Output[];
269
+ }
270
+ export interface ChatTurnResult extends SessionTurnResult {
271
+ }
272
+ export interface SessionRunResult extends SessionTurnResult {
273
+ }
274
+ export interface ChatRunResult extends SessionRunResult {
275
+ }
276
+ export declare class SessionTurnStream implements AsyncIterable<SessionEvent> {
277
+ #private;
278
+ constructor(run: () => AsyncGenerator<SessionEvent, SessionTurnResult, void>);
279
+ [Symbol.asyncIterator](): AsyncIterator<SessionEvent>;
280
+ done(): Promise<SessionTurnResult>;
281
+ }
282
+ export declare const ChatTurnStream: typeof SessionTurnStream;
283
+ export type ChatTurnStream = SessionTurnStream;
284
+ export declare class SessionHandle {
285
+ #private;
286
+ constructor(http: HttpClient, session: Session);
287
+ get id(): string;
288
+ get record(): Session;
289
+ send(input: SessionInput, options?: SessionSendOptions): SessionTurnStream;
290
+ suspend(options?: Pick<SessionSendOptions, "idempotencyKey">): Promise<SessionStateChangeAccepted>;
291
+ cancel(options?: Pick<SessionSendOptions, "idempotencyKey">): Promise<SessionStateChangeAccepted>;
292
+ resume(options?: Pick<SessionSendOptions, "idempotencyKey">): Promise<SessionStateChangeAccepted>;
293
+ delete(options?: Pick<SessionSendOptions, "idempotencyKey">): Promise<void>;
294
+ listEvents(): Promise<readonly SessionEvent[]>;
295
+ listOutputs(query?: OutputQuery): Promise<readonly Output[]>;
296
+ }
297
+ export declare const ChatSession: typeof SessionHandle;
298
+ export type ChatSession = SessionHandle;
299
+ export declare class SessionClient {
300
+ #private;
301
+ constructor(http: HttpClient, buildCreateRequest: (options: SessionCreateOptions) => Promise<SessionCreateRequest>);
302
+ create(options: SessionCreateOptions): Promise<SessionHandle>;
303
+ open(sessionId: string): Promise<SessionHandle>;
304
+ get(sessionId: string): Promise<Session>;
305
+ list(query?: SessionListQuery): Promise<SessionListPage>;
306
+ run(options: SessionRunOptions): Promise<SessionRunResult>;
307
+ }
308
+ export declare const ChatClient: typeof SessionClient;
309
+ export type ChatClient = SessionClient;
227
310
  export interface StreamEventsOptions {
228
311
  /** Poll interval in ms for the `RunEvent` snapshot loop. Default 1000. */
229
312
  readonly intervalMs?: number;
@@ -397,6 +480,8 @@ export declare class AgentExecutor {
397
480
  readonly agentsMd: AgentsMdClient;
398
481
  readonly files: FilesClient;
399
482
  readonly secrets: SecretsClient;
483
+ readonly sessions: SessionClient;
484
+ readonly chat: ChatClient;
400
485
  constructor(options: AgentExecutorOptions);
401
486
  /**
402
487
  * Internal: satisfies the `SecretUploader` surface so a
@@ -422,26 +507,20 @@ export declare class AgentExecutor {
422
507
  readonly contentType?: string;
423
508
  }): Promise<UploadedAsset>;
424
509
  /**
425
- * Submit a run, wait until its RECORD is terminal, and collect the full
426
- * {@link RunResult} the settle-consistent "do it and give me the result"
427
- * primitive. Folds the poll loop every consumer hand-rolled into one call:
428
- * submit {@link waitForRun} (polls `getRun`, NOT the earlier RUN_FINISHED
429
- * event) poll `listEvents` until the snapshot is settle-bracketed
430
- * (RUN_STARTED + a terminal event present) → `listOutputs` → decode the trace
431
- * and assistant text. On resolve, `getRun`/`listOutputs` are guaranteed
432
- * consistent.
433
- *
434
- * Uses polling (portable across backends), NOT the coordinator WebSocket. By
435
- * default a failed run resolves with `ok: false` and a populated `error`; pass
436
- * `{ throwOnFailure: true }` to throw instead. For live events prefer `submit`
437
- * + `streamEnvelopes(runId, { settleConsistent: true })`.
510
+ * Convenience one-shot on top of the canonical session API:
511
+ * open a session, send `message` as the first turn, stream until the session
512
+ * parks (`idle` / `suspended` / `error`), then return the collected text,
513
+ * events, outputs, and session record. The returned `runId` is the session id,
514
+ * so callers can resume later with `openSession(runId)`.
438
515
  */
439
- run(options: SubmitOptions, opts?: RunCollectOptions): Promise<RunResult>;
516
+ run(options: SessionRunOptions, opts?: RunCollectOptions): Promise<RunResult>;
440
517
  /**
441
- * Explicit, discoverable alias for {@link run}: submit, wait, and collect the
442
- * full {@link RunResult} in one call.
518
+ * Explicit, discoverable alias for {@link run}: open a one-shot session turn
519
+ * and collect the full {@link RunResult} in one call.
443
520
  */
444
- runAndCollect(options: SubmitOptions, opts?: RunCollectOptions): Promise<RunResult>;
521
+ runAndCollect(options: SessionRunOptions, opts?: RunCollectOptions): Promise<RunResult>;
522
+ openSession(options: SessionCreateOptions): Promise<SessionHandle>;
523
+ openSession(sessionId: string): Promise<SessionHandle>;
445
524
  /**
446
525
  * Submit a run and return its run id immediately. Use that id with
447
526
  * `wait`, `stream`, `outputs`, `download`, `cancel`, or `delete`.
@@ -592,4 +671,7 @@ export declare class AgentExecutor {
592
671
  /** Download only the run record (the `metadata` namespace) as a zip. */
593
672
  downloadMetadata(runId: string, options?: OutputDownloadOptions): Promise<Uint8Array>;
594
673
  }
674
+ /** Canonical SDK client name. `AgentExecutor` remains as a compatibility alias. */
675
+ export declare class Aex extends AgentExecutor {
676
+ }
595
677
  export type { OutputFileType, OutputLink, OutputLinkOptions, OutputQuery, PlatformProxyEndpoint, PlatformProxyEndpointAuth };