@inferencesh/sdk 0.24.0 → 0.25.0

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/CHANGELOG.md CHANGED
@@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.25.0] - 2026-10-12
11
+
12
+ ### Added
13
+
14
+ - Generated types follow the API: device authorization records the starting device and proximity (`DeviceAuthCodeInfo.device` with `client`, `client_version`, `proximity`, `scopes`), `DeviceAuthStatusSlowDown` and the poll `interval`, the `code_confirmation_required` and `invalid_scope` error codes, and `cached_tokens` / `cache_write_tokens` on LLM usage and text meta items.
15
+
16
+ ## [0.24.0] - 2026-10-11
17
+
10
18
  ### Added
11
19
 
12
20
  - Client tools can return files. A `ClientToolHandlerFn` may return `{ result: string; attachments?: FileRef[] }` (new `ClientToolResult` type) besides a string; the files are uploaded first with POST /files (`client.files.upload`, the chat's `uploadFile`) and sent as `attachments` with the result. Images reach the model as image input when it supports images. `submitToolResult` (agent api, `Agent`, `AgentsAPI`, the React chat actions) takes optional `attachments`, sent only when non-empty. `ToolResultRequest.attachments` is added by hand to the generated types until the next `make types` picks it up from the API. String returns work as before.
package/dist/types.d.ts CHANGED
@@ -645,6 +645,12 @@ export interface DeviceAuthPollResponse {
645
645
  * credential comes with it.
646
646
  */
647
647
  admin_until?: string;
648
+ /**
649
+ * Interval is the polling interval in seconds the device is now held
650
+ * to, set with status slow_down (RFC 8628 3.5: each one raises it by
651
+ * five seconds).
652
+ */
653
+ interval?: number;
648
654
  }
649
655
  /**
650
656
  * AdminElevateRequest is the body of POST /device/auth/elevate: a platform
@@ -2801,7 +2807,7 @@ export interface DecideEntitlementRequestRequest {
2801
2807
  * and APIError.Code on the legacy envelope. Clients branch on these, so a
2802
2808
  * code is a named const here, where it generates into models and the SDKs.
2803
2809
  */
2804
- export type ErrorCode = "invalid_request" | "validation_error" | "unauthorized" | "forbidden" | "not_found" | "conflict" | "name_conflict" | "already_exists" | "not_configured" | "method_not_allowed" | "rate_limited" | "internal_error" | "team_role_required" | "blocked_by_usage_policy" | "last_owner" | "account_deactivated" | "account_banned" | "person_required" | "otp_required" | "requires_sign_in" | "insufficient_scope" | "impersonation_reason_required" | "mcp_auth_expired" | "admin_session_required" | "admin_scopes_not_approved" | "cli_session_required" | "admin_required" | "same_admin_required" | "browser_session_required" | "invalid_ttl" | "admin_authenticator_required" | "limit_exceeded" | "feature_not_available" | "entitlement_unavailable" | "payment_required" | "payment_method_required" | "form_closed" | "already_submitted" | "already_claimed" | "already_entitled" | "request_open" | "invalid_code" | "already_processed" | "expired" | "app_retired" | "app_maintenance" | "invalid_transition" | "SESSION_NOT_FOUND" | "SESSION_EXPIRED" | "SESSION_ENDED" | "WORKER_LEASED" | "APP_MISMATCH" | "VERSION_MISMATCH" | "agents_disabled" | "remote_offline" | "remote_timeout" | "harness_not_drivable" | "harness_too_old";
2810
+ export type ErrorCode = "invalid_request" | "validation_error" | "unauthorized" | "forbidden" | "not_found" | "conflict" | "name_conflict" | "already_exists" | "not_configured" | "method_not_allowed" | "rate_limited" | "internal_error" | "team_role_required" | "blocked_by_usage_policy" | "last_owner" | "account_deactivated" | "account_banned" | "person_required" | "otp_required" | "requires_sign_in" | "insufficient_scope" | "invalid_scope" | "impersonation_reason_required" | "mcp_auth_expired" | "admin_session_required" | "admin_scopes_not_approved" | "cli_session_required" | "admin_required" | "same_admin_required" | "browser_session_required" | "invalid_ttl" | "admin_authenticator_required" | "limit_exceeded" | "feature_not_available" | "entitlement_unavailable" | "payment_required" | "payment_method_required" | "form_closed" | "already_submitted" | "already_claimed" | "already_entitled" | "request_open" | "invalid_code" | "already_processed" | "expired" | "code_confirmation_required" | "app_retired" | "app_maintenance" | "invalid_transition" | "SESSION_NOT_FOUND" | "SESSION_EXPIRED" | "SESSION_ENDED" | "WORKER_LEASED" | "APP_MISMATCH" | "VERSION_MISMATCH" | "agents_disabled" | "remote_offline" | "remote_timeout" | "harness_not_drivable" | "harness_too_old";
2805
2811
  export declare const ErrorCodeInvalidRequest: ErrorCode;
2806
2812
  export declare const ErrorCodeValidationError: ErrorCode;
2807
2813
  export declare const ErrorCodeUnauthorized: ErrorCode;
@@ -2860,6 +2866,12 @@ export declare const ErrorCodeRequiresSignIn: ErrorCode;
2860
2866
  * narrowed login granted less). The detail names the scope.
2861
2867
  */
2862
2868
  export declare const ErrorCodeInsufficientScope: ErrorCode;
2869
+ /**
2870
+ * ErrorCodeInvalidScope (400): a grant request (an OAuth authorization,
2871
+ * a device sign-in's approval) named only scopes this server does not
2872
+ * know. The detail names them.
2873
+ */
2874
+ export declare const ErrorCodeInvalidScope: ErrorCode;
2863
2875
  /**
2864
2876
  * ErrorCodeImpersonationReasonRequired (403): a platform admin named a
2865
2877
  * team they are not a member of without a live impersonation grant.
@@ -2938,6 +2950,11 @@ export declare const ErrorCodeRequestOpen: ErrorCode;
2938
2950
  export declare const ErrorCodeInvalidCode: ErrorCode;
2939
2951
  export declare const ErrorCodeAlreadyProcessed: ErrorCode;
2940
2952
  export declare const ErrorCodeExpired: ErrorCode;
2953
+ /**
2954
+ * A device sign-in started away from the approver is approved only
2955
+ * with the code typed from the device (400).
2956
+ */
2957
+ export declare const ErrorCodeCodeConfirmationRequired: ErrorCode;
2941
2958
  /**
2942
2959
  * Run-time refusals. AppRetired (410): the app no longer runs.
2943
2960
  * AppMaintenance (503, Retry-After): the owner paused it; the message is
@@ -5022,6 +5039,12 @@ export interface ToolInvocationDTO extends BaseModelDTO, PermissionModelDTO {
5022
5039
  export interface MetaItem {
5023
5040
  type: MetaItemType;
5024
5041
  tokens?: number;
5042
+ /**
5043
+ * CachedTokens and CacheWriteTokens are the parts of Tokens (on an input
5044
+ * text item) read from and written to the provider's prompt cache.
5045
+ */
5046
+ cached_tokens?: number;
5047
+ cache_write_tokens?: number;
5025
5048
  width?: number;
5026
5049
  height?: number;
5027
5050
  resolution_mp?: number;
@@ -6288,11 +6311,16 @@ export declare const OpIsNull: FilterOperator;
6288
6311
  export declare const OpIsNotNull: FilterOperator;
6289
6312
  export declare const OpIsEmpty: FilterOperator;
6290
6313
  export declare const OpIsNotEmpty: FilterOperator;
6291
- export type DeviceAuthStatus = "pending" | "approved" | "expired" | "denied" | "valid" | "invalid" | "loading";
6314
+ export type DeviceAuthStatus = "pending" | "approved" | "expired" | "denied" | "slow_down" | "valid" | "invalid" | "loading";
6292
6315
  export declare const DeviceAuthStatusPending: DeviceAuthStatus;
6293
6316
  export declare const DeviceAuthStatusApproved: DeviceAuthStatus;
6294
6317
  export declare const DeviceAuthStatusExpired: DeviceAuthStatus;
6295
6318
  export declare const DeviceAuthStatusDenied: DeviceAuthStatus;
6319
+ /**
6320
+ * DeviceAuthStatusSlowDown: still pending, and the device polled sooner
6321
+ * than its interval, which is now five seconds longer (RFC 8628 3.5).
6322
+ */
6323
+ export declare const DeviceAuthStatusSlowDown: DeviceAuthStatus;
6296
6324
  export declare const DeviceAuthStatusValid: DeviceAuthStatus;
6297
6325
  export declare const DeviceAuthStatusInvalid: DeviceAuthStatus;
6298
6326
  export declare const DeviceAuthStatusLoading: DeviceAuthStatus;
@@ -7310,7 +7338,17 @@ export interface LLMUsage {
7310
7338
  stop_reason: string;
7311
7339
  time_to_first_token: number;
7312
7340
  tokens_per_second: number;
7341
+ /**
7342
+ * PromptTokens counts every input token, cached ones included
7343
+ * (OpenAI, xAI and OpenRouter count them this way).
7344
+ */
7313
7345
  prompt_tokens: number;
7346
+ /**
7347
+ * CachedTokens is how many of PromptTokens were read from the provider's
7348
+ * prompt cache; CacheWriteTokens how many were written to it.
7349
+ */
7350
+ cached_tokens: number;
7351
+ cache_write_tokens: number;
7314
7352
  completion_tokens: number;
7315
7353
  total_tokens: number;
7316
7354
  reasoning_tokens: number;
package/dist/types.js CHANGED
@@ -434,6 +434,12 @@ export const ErrorCodeRequiresSignIn = "requires_sign_in";
434
434
  * narrowed login granted less). The detail names the scope.
435
435
  */
436
436
  export const ErrorCodeInsufficientScope = "insufficient_scope";
437
+ /**
438
+ * ErrorCodeInvalidScope (400): a grant request (an OAuth authorization,
439
+ * a device sign-in's approval) named only scopes this server does not
440
+ * know. The detail names them.
441
+ */
442
+ export const ErrorCodeInvalidScope = "invalid_scope";
437
443
  /**
438
444
  * ErrorCodeImpersonationReasonRequired (403): a platform admin named a
439
445
  * team they are not a member of without a live impersonation grant.
@@ -512,6 +518,11 @@ export const ErrorCodeRequestOpen = "request_open";
512
518
  export const ErrorCodeInvalidCode = "invalid_code";
513
519
  export const ErrorCodeAlreadyProcessed = "already_processed";
514
520
  export const ErrorCodeExpired = "expired";
521
+ /**
522
+ * A device sign-in started away from the approver is approved only
523
+ * with the code typed from the device (400).
524
+ */
525
+ export const ErrorCodeCodeConfirmationRequired = "code_confirmation_required";
515
526
  /**
516
527
  * Run-time refusals. AppRetired (410): the app no longer runs.
517
528
  * AppMaintenance (503, Retry-After): the owner paused it; the message is
@@ -1054,6 +1065,11 @@ export const DeviceAuthStatusPending = "pending";
1054
1065
  export const DeviceAuthStatusApproved = "approved";
1055
1066
  export const DeviceAuthStatusExpired = "expired";
1056
1067
  export const DeviceAuthStatusDenied = "denied";
1068
+ /**
1069
+ * DeviceAuthStatusSlowDown: still pending, and the device polled sooner
1070
+ * than its interval, which is now five seconds longer (RFC 8628 3.5).
1071
+ */
1072
+ export const DeviceAuthStatusSlowDown = "slow_down";
1057
1073
  export const DeviceAuthStatusValid = "valid";
1058
1074
  export const DeviceAuthStatusInvalid = "invalid";
1059
1075
  export const DeviceAuthStatusLoading = "loading";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inferencesh/sdk",
3
- "version": "0.24.0",
3
+ "version": "0.25.0",
4
4
  "description": "Official JavaScript/TypeScript SDK for inference.sh - Run AI models with a simple API",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",