@agents24/client 0.2.0 → 0.2.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.
@@ -1,4 +1,4 @@
1
- import { Agents24ClientError, normalizeBaseUrl, resolveFetch, resolveDecoderFactory, defaultClock, defaultIds, AuthenticatedHttp, encodePath, createByteMultipartEncoder, resolveEncoder, appendQuery, consumeThreadSummaryStream, responseError, responseJson, consumeRuntimeStream } from './chunk-SCZMUBXD.js';
1
+ import { Agents24ClientError, normalizeBaseUrl, resolveFetch, resolveDecoderFactory, defaultClock, defaultIds, AuthenticatedHttp, encodePath, createByteMultipartEncoder, resolveEncoder, appendQuery, consumeThreadSummaryStream, responseJson, responseError, consumeRuntimeStream } from './chunk-GXISGBVW.js';
2
2
 
3
3
  // src/client.ts
4
4
  function objectResult(value, operation) {
@@ -160,6 +160,16 @@ function createAgents24Client(options) {
160
160
  if (!response.ok) throw await responseError(response);
161
161
  return objectResult(await responseJson(response), "Bootstrap");
162
162
  },
163
+ resourcePolicies: {
164
+ async getEffective(input) {
165
+ const response = await http.request(
166
+ "GET",
167
+ deploymentPath(options.deploymentId, "/resource-policy"),
168
+ { operation: "resourcePolicies.getEffective", ...input?.signal ? { signal: input.signal } : {} }
169
+ );
170
+ return objectResult(await responseJson(response), "Effective Resource Policy");
171
+ }
172
+ },
163
173
  chat: {
164
174
  async stream(input, onEvent) {
165
175
  const initial = async (onProgress) => {
@@ -178,7 +188,7 @@ function createAgents24Client(options) {
178
188
  ...input.requestedModelId ? { requested_model_id: input.requestedModelId } : {},
179
189
  tool_inputs: input.toolInputs ?? {},
180
190
  metadata: input.metadata ?? {},
181
- client: input.client ?? { sdk_name: "@agents24/client", sdk_version: "0.2.0" }
191
+ client: input.client ?? { sdk_name: "@agents24/client", sdk_version: "0.2.1" }
182
192
  },
183
193
  ...input.signal ? { signal: input.signal } : {}
184
194
  }
@@ -211,6 +221,25 @@ function createAgents24Client(options) {
211
221
  }
212
222
  );
213
223
  return objectResult(result, "Run cancellation");
224
+ },
225
+ async setFeedback(input) {
226
+ const result = await http.json(
227
+ "PUT",
228
+ deploymentPath(
229
+ options.deploymentId,
230
+ `/runs/${encodePath(input.runId)}/feedback`
231
+ ),
232
+ {
233
+ operation: "runs.setFeedback",
234
+ body: {
235
+ rating: input.rating,
236
+ ...input.reason ? { reason: input.reason } : {},
237
+ ...input.comment ? { comment: input.comment } : {}
238
+ },
239
+ ...input.signal ? { signal: input.signal } : {}
240
+ }
241
+ );
242
+ return objectResult(result, "Response feedback");
214
243
  }
215
244
  },
216
245
  threads: {
@@ -230,8 +259,7 @@ function createAgents24Client(options) {
230
259
  deploymentPath(options.deploymentId, `/threads/${encodePath(input.threadId)}`),
231
260
  {
232
261
  limit: input.limit,
233
- before_turn_index: input.beforeTurnIndex,
234
- include_run_events: input.includeRunEvents
262
+ before_turn_index: input.beforeTurnIndex
235
263
  }
236
264
  );
237
265
  const result = await http.json("GET", path, {
@@ -282,11 +310,11 @@ function createAgents24Client(options) {
282
310
  }
283
311
  },
284
312
  attachments: {
285
- async upload(input) {
313
+ async uploadBatch(input) {
286
314
  const multipart = options.multipart ?? createByteMultipartEncoder(resolveEncoder(options.encoder));
287
315
  const encoded = await multipart.encode([
288
316
  ...input.threadId ? [{ field: "thread_id", value: input.threadId }] : [],
289
- { field: "files", value: input.upload }
317
+ ...input.uploads.map((upload) => ({ field: "files", value: upload }))
290
318
  ]);
291
319
  const result = await http.json(
292
320
  "POST",
@@ -300,8 +328,23 @@ function createAgents24Client(options) {
300
328
  }
301
329
  );
302
330
  const body = objectResult(result, "Attachment upload");
303
- const item = Array.isArray(body.items) ? body.items[0] : body;
304
- return objectResult(item, "Attachment upload");
331
+ if (!Array.isArray(body.items)) throw new Error("Attachment upload returned an invalid batch");
332
+ return body.items.map((item) => objectResult(item, "Attachment upload"));
333
+ },
334
+ async createContentAccess(input) {
335
+ const result = await http.json(
336
+ "POST",
337
+ deploymentPath(
338
+ options.deploymentId,
339
+ `/attachments/${encodePath(input.attachmentId)}/content-access`
340
+ ),
341
+ {
342
+ operation: "attachments.create_content_access",
343
+ body: { disposition: input.disposition },
344
+ ...input.signal ? { signal: input.signal } : {}
345
+ }
346
+ );
347
+ return objectResult(result, "Attachment content access");
305
348
  }
306
349
  },
307
350
  hitl: {
@@ -319,7 +362,8 @@ function createAgents24Client(options) {
319
362
  schema_version: "agents24.hitl.resume.v2",
320
363
  interrupt_id: input.interruptId,
321
364
  action: input.action,
322
- ...input.comment ? { comment: input.comment } : {}
365
+ ...input.comment ? { comment: input.comment } : {},
366
+ ...input.answers ? { answers: input.answers } : {}
323
367
  },
324
368
  ...input.signal ? { signal: input.signal } : {}
325
369
  }
@@ -382,5 +426,5 @@ function createAgents24Client(options) {
382
426
  }
383
427
 
384
428
  export { createAgents24Client };
385
- //# sourceMappingURL=chunk-QAIOKNUK.js.map
386
- //# sourceMappingURL=chunk-QAIOKNUK.js.map
429
+ //# sourceMappingURL=chunk-SPWEZFHZ.js.map
430
+ //# sourceMappingURL=chunk-SPWEZFHZ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/client.ts"],"names":[],"mappings":";;;AAwBA,SAAS,YAAA,CAA+B,OAAgB,SAAA,EAAsB;AAC5E,EAAA,IAAI,CAAC,SAAS,OAAO,KAAA,KAAU,YAAY,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA,EAAG;AAC/D,IAAA,MAAM,IAAI,mBAAA,CAAoB,CAAA,EAAG,SAAS,CAAA,8BAAA,CAAA,EAAkC;AAAA,MAC1E,IAAA,EAAM,UAAA;AAAA,MACN,IAAA,EAAM;AAAA,KACP,CAAA;AAAA,EACH;AACA,EAAA,OAAO,KAAA;AACT;AAEA,SAAS,cAAA,CAAe,cAAsB,MAAA,EAAwB;AACpE,EAAA,OAAO,CAAA,mCAAA,EAAsC,UAAA,CAAW,YAAY,CAAC,GAAG,MAAM,CAAA,CAAA;AAChF;AAEA,SAAS,gBAAgB,KAAA,EAAyB;AACh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U;AAAA,MACR,MAAM,OAAO,KAAA,EAAO;AAClB,QAAA,IAAI,CAAC,OAAA,CAAQ,eAAA,CAAgB,MAAA,EAAQ;AACnC,UAAA,MAAM,IAAI,oBAAoB,yDAAA,EAA2D;AAAA,YACvF,IAAA,EAAM,oBAAA;AAAA,YACN,IAAA,EAAM;AAAA,WACP,CAAA;AAAA,QACH;AACA,QAAA,MAAM,OAAA,CAAQ,gBAAgB,MAAA,CAAO;AAAA,UACnC,cAAA,EAAgB,KAAA,EAAO,cAAA,IAAkB,GAAA,CAAI,QAAA,EAAS;AAAA,UACtD,GAAI,OAAO,MAAA,GAAS,EAAE,QAAQ,KAAA,CAAM,MAAA,KAAW;AAAC,SACjD,CAAA;AAAA,MACH;AAAA;AACF,GACF;AACF","file":"chunk-SPWEZFHZ.js","sourcesContent":["import { defaultClock, defaultIds, resolveDecoderFactory, resolveEncoder, resolveFetch } from \"./capabilities.js\";\nimport { Agents24ClientError } from \"./errors.js\";\nimport { AuthenticatedHttp, responseError, responseJson } from \"./http.js\";\nimport { createByteMultipartEncoder } from \"./multipart.js\";\nimport { consumeRuntimeStream, consumeThreadSummaryStream, type RuntimeStreamState } from \"./stream.js\";\nimport { appendQuery, encodePath, normalizeBaseUrl } from \"./url.js\";\nimport type {\n AgentClient,\n Agents24ClientOptions,\n AttachmentResult,\n ClientBootstrap,\n EffectiveResourcePolicy,\n HitlResumeResult,\n McpAuthorizationResult,\n McpCallbackResult,\n ResponseFeedbackResult,\n RuntimeEventHandler,\n StreamResult,\n ThreadDetail,\n ThreadListResult,\n ThreadSummaryEventHandler,\n} from \"./types.js\";\nimport type { AttachmentContentAccess } from \"./runtime-types.js\";\n\nfunction objectResult<T extends object>(value: unknown, operation: string): T {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) {\n throw new Agents24ClientError(`${operation} returned an invalid response.`, {\n kind: \"protocol\",\n code: \"INVALID_JSON_RESPONSE\",\n });\n }\n return value as T;\n}\n\nfunction deploymentPath(deploymentId: string, suffix: string): string {\n return `/public/client-runtime/deployments/${encodePath(deploymentId)}${suffix}`;\n}\n\nfunction shouldReconnect(error: unknown): boolean {\n return error instanceof Agents24ClientError && error.kind === \"network\" && error.retryable;\n}\n\nexport function createAgents24Client(options: Agents24ClientOptions): AgentClient {\n if (!options.deploymentId || /[\\r\\n\\0/]/.test(options.deploymentId)) {\n throw new Agents24ClientError(\"deploymentId is invalid.\", {\n kind: \"configuration\",\n code: \"INVALID_DEPLOYMENT_ID\",\n });\n }\n if (options.transport !== undefined && options.transport !== \"auto\" && options.transport !== \"fetch\") {\n throw new Agents24ClientError(\"The requested transport is unavailable.\", {\n kind: \"missing_capability\",\n code: \"MISSING_TRANSPORT\",\n });\n }\n const baseUrl = normalizeBaseUrl(options.baseUrl);\n const fetch = resolveFetch(options.fetch);\n const decoder = resolveDecoderFactory(options.decoder);\n const clock = options.clock ?? defaultClock();\n const ids = options.ids ?? defaultIds();\n const maxReconnectAttempts = Math.max(0, Math.min(options.maxReconnectAttempts ?? 3, 10));\n const http = new AuthenticatedHttp({\n baseUrl,\n sessionProvider: options.sessionProvider,\n fetch,\n clock,\n ...(options.telemetry ? { telemetry: options.telemetry } : {}),\n });\n const emit = async (event: Parameters<NonNullable<typeof options.telemetry>[\"emit\"]>[0]): Promise<void> => {\n try {\n await options.telemetry?.emit(event);\n } catch {\n // Telemetry is isolated from runtime behavior and credentials.\n }\n };\n\n const attach = async (\n runId: string,\n cursor: number | undefined,\n headers: Readonly<Record<string, string>> | undefined,\n signal: Parameters<AgentClient[\"runs\"][\"attach\"]>[0][\"signal\"],\n onEvent: RuntimeEventHandler,\n onProgress?: (state: RuntimeStreamState) => void,\n ): Promise<RuntimeStreamState> => {\n const response = await http.request(\n \"POST\",\n deploymentPath(options.deploymentId, `/runs/${encodePath(runId)}/attach`),\n {\n operation: \"runs.attach\",\n accept: \"text/event-stream\",\n body: cursor === undefined ? {} : { cursor },\n ...(headers ? { headers } : {}),\n ...(signal ? { signal } : {}),\n },\n );\n return consumeRuntimeStream({\n response,\n decoder: decoder(),\n onEvent,\n ...(signal ? { signal } : {}),\n ...(cursor === undefined ? {} : { afterCursor: cursor }),\n ...(onProgress ? { onProgress } : {}),\n });\n };\n\n const reconnect = async (\n initial: (onProgress: (next: RuntimeStreamState) => void) => Promise<RuntimeStreamState>,\n signal: Parameters<AgentClient[\"runs\"][\"attach\"]>[0][\"signal\"],\n onEvent: RuntimeEventHandler,\n operation: \"chat.stream\" | \"runs.attach\",\n headers?: Readonly<Record<string, string>>,\n ): Promise<StreamResult> => {\n let state: RuntimeStreamState | undefined;\n let attempt = 0;\n const onProgress = (next: RuntimeStreamState) => {\n if (!state) {\n void emit({\n type: \"stream.connected\",\n operation,\n ...(next.runId ? { runId: next.runId } : {}),\n ...(next.cursor === null ? {} : { cursor: next.cursor }),\n attempt,\n });\n }\n state = next;\n };\n while (true) {\n try {\n state = state?.runId\n ? await attach(state.runId, state.cursor ?? undefined, headers, signal, onEvent, onProgress)\n : await initial(onProgress);\n } catch (error) {\n if (signal?.aborted || !shouldReconnect(error) || attempt >= maxReconnectAttempts) throw error;\n attempt += 1;\n await emit({\n type: \"stream.reconnecting\",\n operation,\n ...(state?.runId ? { runId: state.runId } : {}),\n ...(state?.cursor == null ? {} : { cursor: state.cursor }),\n attempt,\n reason: \"network\",\n });\n continue;\n }\n if (!state.detached || signal?.aborted) {\n await emit({\n type: \"stream.completed\",\n operation,\n ...(state.runId ? { runId: state.runId } : {}),\n ...(state.cursor === null ? {} : { cursor: state.cursor }),\n attempt,\n });\n return state;\n }\n await emit({\n type: \"stream.detached\",\n operation,\n ...(state.runId ? { runId: state.runId } : {}),\n ...(state.cursor === null ? {} : { cursor: state.cursor }),\n attempt,\n reason: state.detachReason ?? \"server_detach\",\n });\n if (attempt >= maxReconnectAttempts || state.detachReason === \"revoked\" || state.detachReason === \"policy_changed\") {\n return state;\n }\n if (state.detachReason === \"token_expired\" && options.sessionProvider.refresh) {\n await options.sessionProvider.refresh({ reason: \"stream_detached\", ...(signal ? { signal } : {}) });\n }\n attempt += 1;\n }\n };\n\n return {\n async bootstrap(input) {\n let response: Awaited<ReturnType<typeof fetch>>;\n try {\n response = await fetch(\n `${baseUrl}${deploymentPath(options.deploymentId, \"/bootstrap\")}`,\n {\n method: \"GET\",\n headers: { Accept: \"application/json\", \"Cache-Control\": \"no-store\", Pragma: \"no-cache\" },\n redirect: \"error\",\n cache: \"no-store\",\n credentials: \"omit\",\n ...(input?.signal ? { signal: input.signal } : {}),\n },\n );\n } catch (cause) {\n throw new Agents24ClientError(\"The Agents24 deployment bootstrap could not be reached.\", {\n kind: input?.signal?.aborted ? \"aborted\" : \"network\",\n code: input?.signal?.aborted ? \"ABORTED\" : \"NETWORK_ERROR\",\n retryable: !input?.signal?.aborted,\n cause,\n });\n }\n if (response.redirected || (response.status >= 300 && response.status < 400)) {\n throw new Agents24ClientError(\"Client-runtime redirects are not allowed.\", {\n kind: \"network\",\n code: \"REDIRECT_REJECTED\",\n status: response.status,\n });\n }\n if (!response.ok) throw await responseError(response);\n return objectResult<ClientBootstrap>(await responseJson(response), \"Bootstrap\");\n },\n resourcePolicies: {\n async getEffective(input) {\n const response = await http.request(\n \"GET\",\n deploymentPath(options.deploymentId, \"/resource-policy\"),\n { operation: \"resourcePolicies.getEffective\", ...(input?.signal ? { signal: input.signal } : {}) },\n );\n return objectResult<EffectiveResourcePolicy>(await responseJson(response), \"Effective Resource Policy\");\n },\n },\n chat: {\n async stream(input, onEvent) {\n const initial = async (onProgress: (state: RuntimeStreamState) => void) => {\n const response = await http.request(\n \"POST\",\n deploymentPath(options.deploymentId, \"/chat/stream\"),\n {\n operation: \"chat.stream\",\n accept: \"text/event-stream\",\n idempotencyKey: input.idempotencyKey,\n ...(input.headers ? { headers: input.headers } : {}),\n body: {\n input: input.input,\n attachment_ids: [...(input.attachmentIds ?? [])],\n ...(input.threadId ? { thread_id: input.threadId } : {}),\n ...(input.requestedModelId ? { requested_model_id: input.requestedModelId } : {}),\n tool_inputs: input.toolInputs ?? {},\n metadata: input.metadata ?? {},\n client: input.client ?? { sdk_name: \"@agents24/client\", sdk_version: \"0.2.1\" },\n },\n ...(input.signal ? { signal: input.signal } : {}),\n },\n );\n return consumeRuntimeStream({\n response,\n decoder: decoder(),\n onEvent,\n ...(input.signal ? { signal: input.signal } : {}),\n onProgress,\n });\n };\n return reconnect(initial, input.signal, onEvent, \"chat.stream\", input.headers);\n },\n },\n runs: {\n async attach(input, onEvent) {\n const initial = (onProgress: (state: RuntimeStreamState) => void) =>\n attach(input.runId, input.cursor, input.headers, input.signal, onEvent, onProgress);\n return reconnect(initial, input.signal, onEvent, \"runs.attach\", input.headers);\n },\n async cancel(input) {\n const result = await http.json<unknown>(\n \"POST\",\n deploymentPath(options.deploymentId, `/runs/${encodePath(input.runId)}/cancel`),\n {\n operation: \"runs.cancel\",\n body: {},\n idempotencyKey: input.idempotencyKey,\n ...(input.signal ? { signal: input.signal } : {}),\n },\n );\n return objectResult<Record<string, unknown>>(result, \"Run cancellation\");\n },\n async setFeedback(input) {\n const result = await http.json<unknown>(\n \"PUT\",\n deploymentPath(\n options.deploymentId,\n `/runs/${encodePath(input.runId)}/feedback`,\n ),\n {\n operation: \"runs.setFeedback\",\n body: {\n rating: input.rating,\n ...(input.reason ? { reason: input.reason } : {}),\n ...(input.comment ? { comment: input.comment } : {}),\n },\n ...(input.signal ? { signal: input.signal } : {}),\n },\n );\n return objectResult<ResponseFeedbackResult>(result, \"Response feedback\");\n },\n },\n threads: {\n async list(input) {\n const path = appendQuery(deploymentPath(options.deploymentId, \"/threads\"), {\n skip: input?.skip,\n limit: input?.limit,\n });\n const result = await http.json<unknown>(\"GET\", path, {\n operation: \"threads.list\",\n ...(input?.signal ? { signal: input.signal } : {}),\n });\n return objectResult<ThreadListResult>(result, \"Thread listing\");\n },\n async get(input) {\n const path = appendQuery(\n deploymentPath(options.deploymentId, `/threads/${encodePath(input.threadId)}`),\n {\n limit: input.limit,\n before_turn_index: input.beforeTurnIndex,\n },\n );\n const result = await http.json<unknown>(\"GET\", path, {\n operation: \"threads.get\",\n ...(input.signal ? { signal: input.signal } : {}),\n });\n return objectResult<ThreadDetail>(result, \"Thread detail\");\n },\n async events(input, onEvent: ThreadSummaryEventHandler) {\n let cursor = input.cursor;\n let attempts = 0;\n while (!input.signal?.aborted) {\n try {\n const path = appendQuery(deploymentPath(options.deploymentId, \"/threads/events\"), { cursor });\n const response = await http.request(\"GET\", path, {\n operation: \"threads.events\",\n accept: \"text/event-stream\",\n ...(input.signal ? { signal: input.signal } : {}),\n });\n cursor = (await consumeThreadSummaryStream({\n response,\n decoder: decoder(),\n onEvent,\n ...(input.signal ? { signal: input.signal } : {}),\n ...(cursor === undefined ? {} : { afterCursor: cursor }),\n onCursor(next) {\n cursor = next;\n },\n })) ?? undefined;\n return;\n } catch (error) {\n if (input.signal?.aborted || !shouldReconnect(error) || attempts >= maxReconnectAttempts) throw error;\n attempts += 1;\n }\n }\n },\n async delete(input) {\n const result = await http.json<unknown>(\n \"DELETE\",\n deploymentPath(options.deploymentId, `/threads/${encodePath(input.threadId)}`),\n {\n operation: \"threads.delete\",\n idempotencyKey: input.idempotencyKey,\n ...(input.signal ? { signal: input.signal } : {}),\n },\n );\n return objectResult<Record<string, unknown>>(result, \"Thread deletion\");\n },\n },\n attachments: {\n async uploadBatch(input) {\n const multipart = options.multipart ?? createByteMultipartEncoder(resolveEncoder(options.encoder));\n const encoded = await multipart.encode([\n ...(input.threadId ? [{ field: \"thread_id\", value: input.threadId }] : []),\n ...input.uploads.map((upload) => ({ field: \"files\", value: upload })),\n ]);\n const result = await http.json<unknown>(\n \"POST\",\n deploymentPath(options.deploymentId, \"/attachments/upload\"),\n {\n operation: \"attachments.upload\",\n rawBody: encoded.body,\n contentType: encoded.contentType,\n idempotencyKey: input.idempotencyKey,\n ...(input.signal ? { signal: input.signal } : {}),\n },\n );\n const body = objectResult<Record<string, unknown>>(result, \"Attachment upload\");\n if (!Array.isArray(body.items)) throw new Error(\"Attachment upload returned an invalid batch\");\n return body.items.map((item) => objectResult<AttachmentResult>(item, \"Attachment upload\"));\n },\n async createContentAccess(input) {\n const result = await http.json<unknown>(\n \"POST\",\n deploymentPath(\n options.deploymentId,\n `/attachments/${encodePath(input.attachmentId)}/content-access`,\n ),\n {\n operation: \"attachments.create_content_access\",\n body: { disposition: input.disposition },\n ...(input.signal ? { signal: input.signal } : {}),\n },\n );\n return objectResult<AttachmentContentAccess>(result, \"Attachment content access\");\n },\n },\n hitl: {\n async resume(input) {\n const result = await http.json<unknown>(\n \"POST\",\n deploymentPath(\n options.deploymentId,\n `/runs/${encodePath(input.runId)}/hitl/${encodePath(input.interruptId)}/resume`,\n ),\n {\n operation: \"hitl.resume\",\n idempotencyKey: input.idempotencyKey,\n body: {\n schema_version: \"agents24.hitl.resume.v2\",\n interrupt_id: input.interruptId,\n action: input.action,\n ...(input.comment ? { comment: input.comment } : {}),\n ...(input.answers ? { answers: input.answers } : {}),\n },\n ...(input.signal ? { signal: input.signal } : {}),\n },\n );\n return objectResult<HitlResumeResult>(result, \"HITL resume\");\n },\n },\n mcp: {\n async startAuthorization(input) {\n const result = await http.json<unknown>(\n \"POST\",\n deploymentPath(\n options.deploymentId,\n `/runs/${encodePath(input.runId)}/mcp/servers/${encodePath(input.serverId)}/auth/start`,\n ),\n {\n operation: \"mcp.startAuthorization\",\n idempotencyKey: input.idempotencyKey,\n body: {\n interrupt_id: input.interruptId,\n redirect_uri: input.redirectUri,\n popup_nonce: input.popupNonce,\n code_challenge: input.codeChallenge,\n code_challenge_method: \"S256\",\n },\n ...(input.signal ? { signal: input.signal } : {}),\n },\n );\n return objectResult<McpAuthorizationResult>(result, \"MCP authorization start\");\n },\n async redeemCallback(input) {\n const result = await http.json<unknown>(\n \"POST\",\n deploymentPath(options.deploymentId, \"/mcp/callback/redeem\"),\n {\n operation: \"mcp.redeemCallback\",\n idempotencyKey: input.idempotencyKey,\n body: { code: input.code, code_verifier: input.codeVerifier },\n ...(input.signal ? { signal: input.signal } : {}),\n },\n );\n return objectResult<McpCallbackResult>(result, \"MCP callback redemption\");\n },\n },\n sessions: {\n async revoke(input) {\n if (!options.sessionProvider.revoke) {\n throw new Agents24ClientError(\"The configured session provider cannot revoke sessions.\", {\n kind: \"missing_capability\",\n code: \"SESSION_REVOKE_UNAVAILABLE\",\n });\n }\n await options.sessionProvider.revoke({\n idempotencyKey: input?.idempotencyKey ?? ids.createId(),\n ...(input?.signal ? { signal: input.signal } : {}),\n });\n },\n },\n };\n}\n"]}
@@ -1,16 +1,27 @@
1
- export type ContextWindowSource = "exact" | "estimated" | "provider_count_api" | "provider_usage" | "provider_cached_estimate" | "runtime_tokenizer" | "hf_tokenizer" | "multimodal_estimate" | "text_estimate" | "tokenizer_estimate" | "heuristic_estimate" | "unknown";
1
+ export type ContextWindowSource = "exact" | "estimated" | "provider_count_api" | "provider_usage" | "provider_cached_estimate" | "runtime_tokenizer" | "hf_tokenizer" | "lab_tokenizer" | "tiktoken" | "multimodal_estimate" | "text_estimate" | "tokenizer_estimate" | "heuristic_estimate" | "unknown";
2
2
  export type ContextWindowStage = "preflight" | "sent_prompt" | "final_usage";
3
3
  export type ContextWindowConfidence = "exact" | "high" | "medium" | "low" | "unknown";
4
4
  export type ContextCompression = {
5
5
  active: boolean;
6
+ status?: "started" | "completed" | "failed" | null;
7
+ strategy?: "artifact_references" | "semantic_checkpoint" | null;
6
8
  reason?: string | null;
7
9
  input_tokens?: number | null;
8
10
  max_tokens?: number | null;
9
11
  usage_ratio?: number | null;
12
+ admission_input_tokens?: number | null;
13
+ admission_input_tokens_before?: number | null;
14
+ admission_input_tokens_after?: number | null;
15
+ admission_ratio?: number | null;
16
+ admission_confidence?: ContextWindowConfidence | null;
17
+ applied_margin?: number | null;
10
18
  full_frame_count?: number | null;
11
19
  compact_frame_count?: number | null;
12
20
  dropped_frame_count?: number | null;
13
21
  artifact_ref_count?: number | null;
22
+ checkpoint_frame_count?: number | null;
23
+ input_tokens_before?: number | null;
24
+ input_tokens_after?: number | null;
14
25
  compression_trigger_budget?: number | null;
15
26
  compression_target_budget?: number | null;
16
27
  compression_target_ratio?: number | null;
@@ -28,6 +39,10 @@ export type ContextWindow = {
28
39
  input_tokens?: number | null;
29
40
  remaining_tokens?: number | null;
30
41
  usage_ratio?: number | null;
42
+ admission_input_tokens?: number | null;
43
+ admission_ratio?: number | null;
44
+ admission_confidence?: ContextWindowConfidence | null;
45
+ applied_margin?: number | null;
31
46
  assembly?: Record<string, unknown> | null;
32
47
  context_compression?: ContextCompression | null;
33
48
  };
package/dist/errors.d.ts CHANGED
@@ -1,25 +1,50 @@
1
1
  export type Agents24ErrorKind = "configuration" | "missing_capability" | "authentication" | "authorization" | "not_found" | "conflict" | "quota" | "rate_limit" | "validation" | "protocol" | "network" | "aborted" | "server";
2
- export interface PublicErrorBody {
2
+ export interface FailureView {
3
+ schema_version: "agents24.failure.v1";
4
+ failure_id: string;
3
5
  code: string;
6
+ category: string;
4
7
  message: string;
5
- request_id: string;
6
8
  retryable: boolean;
9
+ request_id: string | null;
10
+ retry_after_ms: number | null;
11
+ details: Readonly<Record<string, unknown>>;
12
+ }
13
+ export interface ResourcePolicyViolation {
14
+ policy_subject_type: "agent" | "client_deployment" | "user";
15
+ rule_type: "allow" | "quota";
16
+ resource_type: "agent" | "model" | "tool" | "toolset" | "knowledge_store";
17
+ resource_name: string;
18
+ aggregation_scope?: "subject" | "consumer";
19
+ quota_unit?: "tokens";
20
+ quota_window?: "monthly";
21
+ limit?: number;
22
+ remaining?: number;
23
+ resets_at?: string;
7
24
  }
8
25
  export declare class Agents24ClientError extends Error {
9
26
  readonly kind: Agents24ErrorKind;
10
27
  readonly code: string;
11
28
  readonly status: number | undefined;
29
+ readonly failure: FailureView | undefined;
12
30
  readonly requestId: string | undefined;
13
31
  readonly retryable: boolean;
32
+ readonly violations: readonly ResourcePolicyViolation[];
14
33
  readonly cause?: unknown;
15
34
  constructor(message: string, options: {
16
35
  kind: Agents24ErrorKind;
17
36
  code?: string;
18
37
  status?: number;
38
+ failure?: FailureView;
19
39
  requestId?: string;
20
40
  retryable?: boolean;
41
+ violations?: readonly ResourcePolicyViolation[];
21
42
  cause?: unknown;
22
43
  });
44
+ get failureId(): string | undefined;
45
+ get category(): string | undefined;
46
+ get retryAfterMs(): number | undefined;
47
+ get details(): Readonly<Record<string, unknown>>;
23
48
  }
24
49
  export declare function missingCapability(name: string): Agents24ClientError;
25
50
  export declare function abortedError(cause?: unknown): Agents24ClientError;
@@ -1,5 +1,5 @@
1
1
  // @generated by @agents24/sdk-contract; DO NOT EDIT.
2
- // contract-sha256: 90a64d2df2facc3c4510edc7a0762cb86a336578667d3bc6cfeb7ae035133e00
2
+ // contract-sha256: 13f59fd11fc838b1f7a51afe15afcdb6f1429fed94e37a1341c97061882e57d2
3
3
  export type ProtocolErrorCategory =
4
4
  | "invalid_json"
5
5
  | "invalid_envelope"
@@ -13,32 +13,55 @@ export type JsonScalar = string | number | boolean | null;
13
13
  export type JsonValue = JsonScalar | JsonValue[] | { [key: string]: JsonValue };
14
14
  export type PublicResponseBlock = {
15
15
  id: string;
16
- kind: "assistant_text" | "reasoning_note" | "tool_call" | "ui_blocks" | "hitl_request" | "error" | "source" | "citation" | "attachment" | "mcp_authorization" | "user_message";
16
+ kind: "assistant_text" | "reasoning_note" | "context_compression" | "node_activity" | "tool_call" | "ui_blocks" | "hitl_request" | "error" | "source" | "citation" | "attachment" | "mcp_authorization" | "user_message";
17
17
  seq: number;
18
18
  status: string;
19
19
  [key: string]: unknown;
20
20
  };
21
- export type RuntimeEventName = "run.accepted" | "run.snapshot" | "run.completed" | "run.cancelled" | "run.paused" | "run.failed" | "run.detached" | "assistant.delta" | "reasoning.update" | "tool.started" | "tool.completed" | "tool.failed" | "tool.cancelled" | "tool.child_run_started" | "tool.child_run_finished" | "tool.child_tool_started" | "tool.child_tool_completed" | "tool.child_tool_failed" | "tool.child_tool_cancelled" | "context_window.updated" | "context.compression.updated" | "run_usage.updated" | "hitl.requested" | "hitl.resolved" | "mcp.authorization.required" | "mcp.authorization.completed" | "mcp.authorization.failed" | "attachment.created" | "attachment.updated" | "attachment.ready" | "attachment.failed" | "source.added" | "citation.added" | "ui_blocks.updated" | "runtime.error";
22
- export type RuntimeStage = "run" | "assistant" | "reasoning" | "tool" | "context" | "usage" | "attachment" | "source" | "system";
23
- export type RuntimeEvent = {
24
- version: "run-stream.v2";
21
+ export type RuntimeEventPayload = Record<string, unknown> & {
22
+ response_block?: PublicResponseBlock;
23
+ };
24
+ export type ModelTurnKind = "agent" | "model";
25
+ export type ModelTurnStatus = "running" | "completed" | "failed";
26
+ export type ModelTurnOutcome = "text" | "tool_calls" | "completed";
27
+ export type ModelTurnEventName = "model.turn.started" | "model.turn.completed" | "model.turn.failed";
28
+ export type ModelTurnPayload = Record<string, unknown> & {
29
+ model_turn_id: string;
30
+ kind: ModelTurnKind;
31
+ status: ModelTurnStatus;
32
+ iteration?: number;
33
+ outcome?: ModelTurnOutcome;
34
+ };
35
+ export type RuntimeEventName = "run.accepted" | "run.snapshot" | "run.completed" | "run.cancelled" | "run.paused" | "run.failed" | "run.detached" | "assistant.delta" | "model.turn.started" | "model.turn.completed" | "model.turn.failed" | "reasoning.update" | "node.status.updated" | "tool.started" | "tool.completed" | "tool.failed" | "tool.cancelled" | "tool.child_run_started" | "tool.child_run_finished" | "tool.child_tool_started" | "tool.child_tool_completed" | "tool.child_tool_failed" | "tool.child_tool_cancelled" | "context_window.updated" | "context.compression.updated" | "run_usage.updated" | "hitl.requested" | "hitl.resolved" | "mcp.authorization.required" | "mcp.authorization.completed" | "mcp.authorization.failed" | "attachment.created" | "attachment.updated" | "attachment.ready" | "attachment.failed" | "source.added" | "citation.added" | "ui_blocks.updated";
36
+ export type RuntimeStage = "run" | "assistant" | "model" | "reasoning" | "node" | "tool" | "context" | "usage" | "attachment" | "source" | "system";
37
+ type RuntimeEventEnvelope = {
38
+ version: "run-stream.v3";
25
39
  seq: number;
26
40
  ts: string;
27
- event: RuntimeEventName;
28
41
  run_id: string;
29
42
  stage: RuntimeStage;
30
- payload: Record<string, unknown>;
31
43
  [key: string]: unknown;
32
44
  };
45
+ export type ModelTurnRuntimeEvent = RuntimeEventEnvelope & {
46
+ event: ModelTurnEventName;
47
+ stage: "model";
48
+ payload: ModelTurnPayload;
49
+ };
50
+ export type RuntimeEvent =
51
+ | ModelTurnRuntimeEvent
52
+ | (RuntimeEventEnvelope & {
53
+ event: Exclude<RuntimeEventName, ModelTurnEventName>;
54
+ payload: RuntimeEventPayload;
55
+ });
33
56
  export type ExtendedRuntimeEvent = {
34
- version: "run-stream.v2";
57
+ version: "run-stream.v3";
35
58
  seq: number;
36
59
  ts: string;
37
60
  event: string;
38
61
  run_id: string;
39
62
  stage: string;
40
63
  diagnostics?: Array<Record<string, unknown>>;
41
- payload: Record<string, unknown>;
64
+ payload: RuntimeEventPayload;
42
65
  [key: string]: unknown;
43
66
  };
44
67
  export type RuntimeEventValidationOptions = {
@@ -60,7 +83,7 @@ export interface SseParser {
60
83
  finish(): Promise<void>;
61
84
  }
62
85
  export declare const CONTRACT_HASH: string;
63
- export declare const RUNTIME_PROTOCOL_VERSION: "run-stream.v2";
86
+ export declare const RUNTIME_PROTOCOL_VERSION: "run-stream.v3";
64
87
  export declare const THREAD_SUMMARY_PROTOCOL_VERSION: "agents24.thread_summary_event.v1";
65
88
  export declare class Agents24ProtocolError extends Error {
66
89
  readonly category: ProtocolErrorCategory;
package/dist/index.d.ts CHANGED
@@ -5,6 +5,7 @@ export { createPkcePair, createWebCryptoDpopKeyProvider, } from "./dpop.js";
5
5
  export type { DpopKeyHandle, DpopKeyHandleStorage, WebCryptoDpopOptions, WebCryptoLike, } from "./dpop.js";
6
6
  export { createAnonymousSessionProvider, createFencedRefreshCoordinator, createHostedOidcSessionProvider, createInMemoryRefreshCoordinator, createManagedSessionProvider, createStaticSessionProvider, } from "./sessions.js";
7
7
  export type { AnonymousSessionProviderOptions, FencedRefreshCoordinatorOptions, HostedOidcSessionProvider, HostedOidcSessionProviderOptions, ManagedSessionProviderOptions, } from "./sessions.js";
8
- export type { Agents24ErrorKind, PublicErrorBody, } from "./errors.js";
9
- export type { AgentClient, Agents24ClientOptions, AbortSignalLike, AttachmentResult, BinaryUploadData, BlobLike, ChatStreamInput, ClientBootstrap, ClientHints, ClientSessionAccess, ClientSessionProvider, ClientSessionStorage, ClientSessionStorageRecord, Clock, DpopKeyProvider, DpopProofInput, EncodedMultipart, FetchLike, FetchRequestLike, FetchResponseLike, HeadersLike, HitlAction, HitlResumeResult, IdProvider, McpAuthorizationResult, McpCallbackResult, MultipartEncoder, MultipartPart, PortableUpload, PublicJwk, ReadableBodyLike, ReadableBodyReaderLike, RunAttachInput, RuntimeEventHandler, SessionRefreshCoordinator, SessionRefreshFenceRecord, SessionRefreshFenceStorage, SessionRefreshLease, SessionRequestContext, StreamResult, TelemetryEvent, TelemetrySink, TextDecoderLike, TextEncoderLike, ThreadDetail, ThreadListInput, ThreadListResult, ThreadSummary, ThreadSummaryEventHandler, TransportSelection, WaitCapability, } from "./types.js";
10
- export type { JsonScalar, JsonValue, ProtocolErrorCategory, PublicResponseBlock, ExtendedRuntimeEvent, RuntimeEvent, RuntimeEventValidationOptions, ThreadSummaryEvent, } from "./generated/protocol.js";
8
+ export type { Agents24ErrorKind, FailureView, ResourcePolicyViolation, } from "./errors.js";
9
+ export type { AgentClient, ActiveThreadRun, Agents24ClientOptions, AbortSignalLike, AttachmentResult, BinaryUploadData, BlobLike, ChatStreamInput, ClientBootstrap, ClientInputFeature, ClientInputModalityFeature, ClientAttachmentInputModalityFeature, ClientModelSelectionFeature, ClientHints, ClientSessionAccess, EffectiveResourcePolicy, ClientSessionProvider, ClientSessionStorage, ClientSessionStorageRecord, Clock, DpopKeyProvider, DpopProofInput, EncodedMultipart, FetchLike, FetchRequestLike, FetchResponseLike, HeadersLike, HitlAction, HitlAnswer, HitlResponse, HitlResumeResult, IdProvider, McpAuthorizationResult, McpCallbackResult, MultipartEncoder, MultipartPart, PortableUpload, PublicJwk, FeedbackRating, FeedbackReason, ResponseFeedback, ResponseFeedbackResult, ReadableBodyLike, ReadableBodyReaderLike, RunAttachInput, SetFeedbackInput, RuntimeEventHandler, SessionRefreshCoordinator, SessionRefreshFenceRecord, SessionRefreshFenceStorage, SessionRefreshLease, SessionRequestContext, StreamResult, TelemetryEvent, TelemetrySink, TextDecoderLike, TextEncoderLike, ThreadDetail, ThreadListInput, ThreadListResult, ThreadSummary, ThreadSummaryEventHandler, TransportSelection, WaitCapability, } from "./types.js";
10
+ export type { AttachmentContentAccess } from "./runtime-types.js";
11
+ export type { JsonScalar, JsonValue, ModelTurnEventName, ModelTurnKind, ModelTurnOutcome, ModelTurnPayload, ModelTurnRuntimeEvent, ModelTurnStatus, ProtocolErrorCategory, PublicResponseBlock, ExtendedRuntimeEvent, RuntimeEvent, RuntimeEventValidationOptions, ThreadSummaryEvent, } from "./generated/protocol.js";