@inferencesh/sdk 0.38.7 → 0.38.9

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,6 +1,6 @@
1
1
  import { HttpClient } from '../http/client.js';
2
2
  import type { Response } from '../http/response.js';
3
- import { LiveSession, type LiveHandlers, type WebSocketConstructor } from '../live/session.js';
3
+ import { LiveSession, type LiveHandlers, type RealtimeOptions, type WebSocketConstructor } from '../live/session.js';
4
4
  import type { JsonSchema } from '../live/schema.js';
5
5
  import { CursorListRequest, CursorListResponse, SocketAccess, SocketDTO, TaskDTO as Task } from '../types.js';
6
6
  import type { TasksAPI } from './tasks.js';
@@ -21,6 +21,8 @@ export interface OpenSocketOptions {
21
21
  inputSchema?: JsonSchema | null;
22
22
  /** The function's output schema: frames arrive at `onUpdate` as fields. */
23
23
  outputSchema?: JsonSchema | null;
24
+ /** The binary frames sent are live media (a microphone); see LiveSessionOptions.realtime. */
25
+ realtime?: boolean | RealtimeOptions;
24
26
  }
25
27
  /**
26
28
  * Sockets API: the duplex connection of a stream task.
@@ -56,6 +56,7 @@ export class SocketsAPI {
56
56
  webSocket: options.webSocket,
57
57
  inputSchema: options.inputSchema,
58
58
  outputSchema: options.outputSchema,
59
+ realtime: options.realtime,
59
60
  });
60
61
  session.connect();
61
62
  return session;
package/dist/index.d.ts CHANGED
@@ -27,8 +27,8 @@ export { SearchAPI } from './api/search.js';
27
27
  export { ProjectsAPI } from './api/projects.js';
28
28
  export { MCPServersAPI } from './api/mcp-servers.js';
29
29
  export { LiveSession, accessUrl } from './live/session.js';
30
- export type { LiveState, LiveEnd, LiveHandlers, LiveSessionOptions, LiveUpdate, WebSocketLike, WebSocketConstructor } from './live/session.js';
31
- export { STREAM_FORMAT, CLEAR_KEY, ERROR_KEY, REDIAL_CODES } from './live/protocol.js';
30
+ export type { LiveState, LiveEnd, LiveHandlers, LiveSessionOptions, RealtimeOptions, LiveUpdate, WebSocketLike, WebSocketConstructor } from './live/session.js';
31
+ export { STREAM_FORMAT, CLEAR_KEY, ERROR_KEY, REDIAL_CODES, RELAY_KEY } from './live/protocol.js';
32
32
  export { isLiveField, parseMediaType, pcmFormat, splitLiveSchema, binaryLiveField, alternativeLabel, alternativeTag, } from './live/schema.js';
33
33
  export type { JsonSchema, MediaType, PCMFormat, LiveField } from './live/schema.js';
34
34
  export { tool, appTool, agentTool, webhookTool, httpTool, callTool, mcpTool, internalTools, string, number, integer, boolean, enumOf, object, array, optional, } from './tool-builder.js';
package/dist/index.js CHANGED
@@ -29,7 +29,7 @@ export { ProjectsAPI } from './api/projects.js';
29
29
  export { MCPServersAPI } from './api/mcp-servers.js';
30
30
  // Live: the socket of a stream task and the live fields of its schemas
31
31
  export { LiveSession, accessUrl } from './live/session.js';
32
- export { STREAM_FORMAT, CLEAR_KEY, ERROR_KEY, REDIAL_CODES } from './live/protocol.js';
32
+ export { STREAM_FORMAT, CLEAR_KEY, ERROR_KEY, REDIAL_CODES, RELAY_KEY } from './live/protocol.js';
33
33
  export { isLiveField, parseMediaType, pcmFormat, splitLiveSchema, binaryLiveField, alternativeLabel, alternativeTag, } from './live/schema.js';
34
34
  // Tool Builder (fluent API)
35
35
  export { tool, appTool, agentTool, webhookTool, httpTool, callTool, mcpTool, internalTools, string, number, integer, boolean, enumOf, object, array, optional, } from './tool-builder.js';
@@ -11,6 +11,12 @@ export declare const CLEAR_KEY = "$clear";
11
11
  * else the caller should be told went wrong. The stream goes on.
12
12
  */
13
13
  export declare const ERROR_KEY = "$error";
14
+ /**
15
+ * `{"$relay": "waiting" | "paired"}`: written by the relay, not the app, to a
16
+ * client that dialed with `?signals=paired`. "waiting" on attach says this
17
+ * relay reports pairing; "paired" says the worker is there.
18
+ */
19
+ export declare const RELAY_KEY = "$relay";
14
20
  /**
15
21
  * Relay close codes that mean "dial again". 1012: the relay is restarting and
16
22
  * closed an end that still waited for its peer. 1013: the peer did not come in
@@ -13,6 +13,12 @@ export const CLEAR_KEY = '$clear';
13
13
  * else the caller should be told went wrong. The stream goes on.
14
14
  */
15
15
  export const ERROR_KEY = '$error';
16
+ /**
17
+ * `{"$relay": "waiting" | "paired"}`: written by the relay, not the app, to a
18
+ * client that dialed with `?signals=paired`. "waiting" on attach says this
19
+ * relay reports pairing; "paired" says the worker is there.
20
+ */
21
+ export const RELAY_KEY = '$relay';
16
22
  /**
17
23
  * Relay close codes that mean "dial again". 1012: the relay is restarting and
18
24
  * closed an end that still waited for its peer. 1013: the peer did not come in
@@ -80,6 +80,8 @@ export interface WebSocketLike {
80
80
  }) => void) | null;
81
81
  send(data: string | ArrayBuffer | ArrayBufferView): void;
82
82
  close(code?: number, reason?: string): void;
83
+ /** Bytes queued and not yet sent; browsers and `ws` have it. */
84
+ readonly bufferedAmount?: number;
83
85
  }
84
86
  export type WebSocketConstructor = new (url: string) => WebSocketLike;
85
87
  export interface LiveSessionOptions {
@@ -99,6 +101,27 @@ export interface LiveSessionOptions {
99
101
  inputSchema?: JsonSchema | null;
100
102
  /** The function's output schema: frames arrive at onUpdate as fields. */
101
103
  outputSchema?: JsonSchema | null;
104
+ /**
105
+ * The binary frames sent are live media, a microphone: perishable, so late
106
+ * is worse than lost. The session then holds them until the app can read
107
+ * them (the relay says the socket paired, or the app's first frame
108
+ * arrives), keeping only the newest few, and drops a frame rather than
109
+ * queue it behind a full send buffer. Leave it off for binary data that
110
+ * must all arrive (a file sent in chunks).
111
+ */
112
+ realtime?: boolean | RealtimeOptions;
113
+ }
114
+ export interface RealtimeOptions {
115
+ /** Binary frames kept while the app cannot read yet, the newest (default 5: 100 ms of 20 ms frames). */
116
+ holdFrames?: number;
117
+ /** Bytes the WebSocket may have queued before a binary frame is dropped (default 8192: about 250 ms of 16 kHz audio). */
118
+ maxBufferedAmount?: number;
119
+ /**
120
+ * How long to wait, once open, for the relay to say it will report pairing.
121
+ * A relay that does not (an older one) is treated as today: frames go out
122
+ * once the socket is open. Default 1500 ms.
123
+ */
124
+ signalTimeoutMs?: number;
102
125
  }
103
126
  /**
104
127
  * Where to dial. A browser cannot set headers on a WebSocket, so the
@@ -121,13 +144,29 @@ export declare class LiveSession {
121
144
  private readonly inputKnown;
122
145
  private readonly inputBinary;
123
146
  private resolveEnded;
147
+ private readonly realtime;
148
+ /** Realtime: binary frames may go out now. Set per connection. */
149
+ private released;
150
+ private held;
151
+ private signalTimer;
152
+ private dropped;
124
153
  /** Settles when the session has ended, however it ended. */
125
154
  readonly ended: Promise<LiveEnd>;
126
155
  constructor(options: LiveSessionOptions);
127
156
  get state(): LiveState;
128
157
  get isOpen(): boolean;
158
+ /** Realtime: binary frames dropped, as stale (held past holdFrames) or behind a full send buffer. */
159
+ get droppedFrames(): number;
129
160
  /** Dials the relay. The session reports its progress through onState. */
130
161
  connect(): void;
162
+ /**
163
+ * `{"$relay": "waiting" | "paired"}`, written by the relay itself to a
164
+ * client that dialed with ?signals=paired. True when the frame was one.
165
+ */
166
+ private relaySignal;
167
+ /** Realtime: the app can read now. Sends the newest held frames and stops holding. */
168
+ private release;
169
+ private clearSignalTimer;
131
170
  private deliverText;
132
171
  /** `{"error": {"message": ...}}` from an app on an older SDK, unless the output has an `error` field. */
133
172
  private legacyError;
@@ -1,6 +1,7 @@
1
- import { CLEAR_KEY, ERROR_KEY, REDIAL_CODES } from './protocol.js';
1
+ import { CLEAR_KEY, ERROR_KEY, REDIAL_CODES, RELAY_KEY } from './protocol.js';
2
2
  import { binaryLiveField, splitLiveSchema } from './schema.js';
3
3
  const WS_OPEN = 1;
4
+ const REALTIME_DEFAULTS = { holdFrames: 5, maxBufferedAmount: 8192, signalTimeoutMs: 1500 };
4
5
  const MAX_REDIALS = 5;
5
6
  function globalWebSocket() {
6
7
  const ctor = globalThis.WebSocket;
@@ -23,6 +24,11 @@ export class LiveSession {
23
24
  this.current = 'connecting';
24
25
  this.closedByCaller = false;
25
26
  this.redials = 0;
27
+ /** Realtime: binary frames may go out now. Set per connection. */
28
+ this.released = false;
29
+ this.held = [];
30
+ this.signalTimer = null;
31
+ this.dropped = 0;
26
32
  this.watched = false;
27
33
  this.access = options.access;
28
34
  this.handlers = options.handlers ?? {};
@@ -34,6 +40,7 @@ export class LiveSession {
34
40
  this.outputFields = new Set(Object.keys(options.outputSchema?.properties ?? {}));
35
41
  this.inputKnown = !!options.inputSchema;
36
42
  this.inputBinary = binaryLiveField(splitLiveSchema(options.inputSchema).live)?.key;
43
+ this.realtime = options.realtime ? { ...REALTIME_DEFAULTS, ...(options.realtime === true ? {} : options.realtime) } : null;
37
44
  this.ended = new Promise((resolve) => {
38
45
  this.resolveEnded = resolve;
39
46
  });
@@ -44,15 +51,36 @@ export class LiveSession {
44
51
  get isOpen() {
45
52
  return this.ws?.readyState === WS_OPEN;
46
53
  }
54
+ /** Realtime: binary frames dropped, as stale (held past holdFrames) or behind a full send buffer. */
55
+ get droppedFrames() {
56
+ return this.dropped;
57
+ }
47
58
  /** Dials the relay. The session reports its progress through onState. */
48
59
  connect() {
49
60
  this.setState('connecting');
50
61
  this.watchTask();
51
- const ws = new this.WebSocket(accessUrl(this.access));
62
+ // Realtime: ask the relay to say when the app is there (see release).
63
+ const ws = new this.WebSocket(accessUrl(this.access) + (this.realtime ? '&signals=paired' : ''));
52
64
  ws.binaryType = 'arraybuffer';
53
65
  this.ws = ws;
54
- ws.onopen = () => this.setState('waiting');
66
+ this.released = false;
67
+ this.clearSignalTimer();
68
+ ws.onopen = () => {
69
+ this.setState('waiting');
70
+ const realtime = this.realtime;
71
+ if (realtime) {
72
+ // A relay that reports pairing says so first thing. One that says
73
+ // nothing is an older relay: send as soon as open, as before.
74
+ this.signalTimer = setTimeout(() => {
75
+ this.signalTimer = null;
76
+ this.release();
77
+ }, realtime.signalTimeoutMs);
78
+ }
79
+ };
55
80
  ws.onmessage = (event) => {
81
+ if (typeof event.data === 'string' && this.relaySignal(event.data))
82
+ return;
83
+ this.release(); // the app is there: it reads what we send
56
84
  if (this.current !== 'live') {
57
85
  this.setState('live');
58
86
  this.task?.stop(); // the app is there; the task's fate now shows on the socket
@@ -66,6 +94,8 @@ export class LiveSession {
66
94
  if (this.ws !== ws)
67
95
  return;
68
96
  this.ws = null;
97
+ this.released = false;
98
+ this.clearSignalTimer();
69
99
  const waiting = this.current !== 'live';
70
100
  if (!this.closedByCaller && waiting && REDIAL_CODES.has(event.code) && this.redials < MAX_REDIALS) {
71
101
  this.redials += 1;
@@ -75,6 +105,42 @@ export class LiveSession {
75
105
  this.end({ code: event.code, reason: event.reason, byCaller: this.closedByCaller, taskEnded: false });
76
106
  };
77
107
  }
108
+ /**
109
+ * `{"$relay": "waiting" | "paired"}`, written by the relay itself to a
110
+ * client that dialed with ?signals=paired. True when the frame was one.
111
+ */
112
+ relaySignal(text) {
113
+ if (!text.startsWith(`{"${RELAY_KEY}"`))
114
+ return false;
115
+ let signal;
116
+ try {
117
+ signal = JSON.parse(text)[RELAY_KEY];
118
+ }
119
+ catch {
120
+ return false;
121
+ }
122
+ if (signal === 'waiting')
123
+ this.clearSignalTimer(); // it will say when it pairs: hold until then
124
+ else if (signal === 'paired')
125
+ this.release();
126
+ return true;
127
+ }
128
+ /** Realtime: the app can read now. Sends the newest held frames and stops holding. */
129
+ release() {
130
+ if (this.released)
131
+ return;
132
+ this.released = true;
133
+ this.clearSignalTimer();
134
+ const held = this.held;
135
+ this.held = [];
136
+ for (const frame of held)
137
+ this.sendBinary(frame);
138
+ }
139
+ clearSignalTimer() {
140
+ if (this.signalTimer)
141
+ clearTimeout(this.signalTimer);
142
+ this.signalTimer = null;
143
+ }
78
144
  deliverText(text) {
79
145
  let patch;
80
146
  try {
@@ -165,8 +231,29 @@ export class LiveSession {
165
231
  }
166
232
  /** One item of the input's binary live field. */
167
233
  sendBinary(data) {
168
- if (this.isOpen)
169
- this.ws.send(data);
234
+ const realtime = this.realtime;
235
+ if (!realtime) {
236
+ if (this.isOpen)
237
+ this.ws.send(data);
238
+ return;
239
+ }
240
+ if (!this.released) {
241
+ // The app cannot read yet: keep the newest few, so what it hears
242
+ // first is what was just said, not what was said during its cold start.
243
+ this.held.push(data);
244
+ if (this.held.length > realtime.holdFrames) {
245
+ this.held.shift();
246
+ this.dropped += 1;
247
+ }
248
+ return;
249
+ }
250
+ if (!this.isOpen)
251
+ return;
252
+ if ((this.ws.bufferedAmount ?? 0) > realtime.maxBufferedAmount) {
253
+ this.dropped += 1; // the network is behind: this frame would arrive late
254
+ return;
255
+ }
256
+ this.ws.send(data);
170
257
  }
171
258
  /**
172
259
  * One item of an input live field, or a new value of an ordinary one: a
package/dist/types.d.ts CHANGED
@@ -746,11 +746,15 @@ export interface MeResponse {
746
746
  team_view?: TeamViewDTO;
747
747
  diagnostics?: DiagnosticsConfig;
748
748
  /**
749
- * Notice is an operator's notice about the caller's access, set only
750
- * when the request comes from an address restricted to sign-in and the
751
- * CLI. Empty otherwise.
749
+ * Notice is a notice about the caller's access, set only when the
750
+ * redlist restricts this request (a restricted address, or a
751
+ * restricted account): the text an access_restricted refusal carries
752
+ * as its detail. Empty otherwise. NoticeReference and NoticeContact
753
+ * are that refusal's meta.reference and meta.contact.
752
754
  */
753
755
  notice?: string;
756
+ notice_reference?: string;
757
+ notice_contact?: string;
754
758
  /**
755
759
  * PersonalTeamID is the caller's personal workspace, empty for a managed
756
760
  * account, which has none.
@@ -2938,6 +2942,100 @@ export interface CursorListResponse<T extends any> {
2938
2942
  export interface CountResponse {
2939
2943
  count: number;
2940
2944
  }
2945
+ /**
2946
+ * EgressGrantScope is what a grant lets use a login: a task or a sandbox.
2947
+ */
2948
+ export type EgressGrantScope = "task" | "sandbox";
2949
+ export declare const EgressGrantScopeTask: EgressGrantScope;
2950
+ export declare const EgressGrantScopeSandbox: EgressGrantScope;
2951
+ /**
2952
+ * EgressGrantState is where a grant stands.
2953
+ */
2954
+ export type EgressGrantState = "open" | "asked" | "allowed" | "declined" | "ended";
2955
+ /**
2956
+ * EgressGrantOpen: the scope may be asked for the login; nobody has
2957
+ * been yet.
2958
+ */
2959
+ export declare const EgressGrantOpen: EgressGrantState;
2960
+ /**
2961
+ * EgressGrantAsked: a card is open (EgressGrantDTO.InterruptID).
2962
+ */
2963
+ export declare const EgressGrantAsked: EgressGrantState;
2964
+ /**
2965
+ * EgressGrantAllowed: the scope gets the login.
2966
+ */
2967
+ export declare const EgressGrantAllowed: EgressGrantState;
2968
+ /**
2969
+ * EgressGrantDeclined: a person said no, for the scope's life.
2970
+ */
2971
+ export declare const EgressGrantDeclined: EgressGrantState;
2972
+ /**
2973
+ * EgressGrantEnded: the grant no longer holds (Reason says why); the
2974
+ * scope keeps running, and its next use decides again.
2975
+ */
2976
+ export declare const EgressGrantEnded: EgressGrantState;
2977
+ /**
2978
+ * EgressGrantSource is where a grant came from.
2979
+ */
2980
+ export type EgressGrantSource = "app_declared" | "agent_config" | "sandbox_create" | "owner_approval" | "connected_offer" | "reconnect";
2981
+ export declare const EgressGrantSourceAppDeclared: EgressGrantSource;
2982
+ export declare const EgressGrantSourceAgentConfig: EgressGrantSource;
2983
+ export declare const EgressGrantSourceSandboxCreate: EgressGrantSource;
2984
+ export declare const EgressGrantSourceOwnerApproval: EgressGrantSource;
2985
+ export declare const EgressGrantSourceConnectedOffer: EgressGrantSource;
2986
+ export declare const EgressGrantSourceReconnect: EgressGrantSource;
2987
+ /**
2988
+ * EgressGrantReason is why a grant was declined or ended.
2989
+ */
2990
+ export type EgressGrantReason = "declined" | "login_deleted" | "login_disconnected" | "not_owner" | "expired_lifetime" | "scopes_missing" | "scope_ended" | "revoked_by_owner";
2991
+ export declare const EgressGrantReasonDeclined: EgressGrantReason;
2992
+ export declare const EgressGrantReasonLoginDeleted: EgressGrantReason;
2993
+ export declare const EgressGrantReasonLoginDisconnected: EgressGrantReason;
2994
+ export declare const EgressGrantReasonNotOwner: EgressGrantReason;
2995
+ export declare const EgressGrantReasonExpiredLifetime: EgressGrantReason;
2996
+ export declare const EgressGrantReasonScopesMissing: EgressGrantReason;
2997
+ export declare const EgressGrantReasonScopeEnded: EgressGrantReason;
2998
+ export declare const EgressGrantReasonRevokedByOwner: EgressGrantReason;
2999
+ /**
3000
+ * EgressGrantDTO is one decision that a task or a sandbox may use a
3001
+ * provider's login through the engine's egress gateway: what was allowed,
3002
+ * who allowed it and why, and which login answers (INF-1173). It never
3003
+ * holds a value. GET /sandboxes/{id}/grants, GET /tasks/{id}/grants.
3004
+ */
3005
+ export interface EgressGrantDTO {
3006
+ id: string;
3007
+ scope: EgressGrantScope;
3008
+ scope_id: string;
3009
+ /**
3010
+ * Provider is the provider's slug.
3011
+ */
3012
+ provider: string;
3013
+ mode: SandboxCredentialMode;
3014
+ state: EgressGrantState;
3015
+ source: EgressGrantSource;
3016
+ /**
3017
+ * GrantedBy is the user who allowed it: the task's user for an app's
3018
+ * declaration, the agent config's owner for its own, the answering
3019
+ * owner for an approval.
3020
+ */
3021
+ granted_by?: string;
3022
+ /**
3023
+ * CredentialID is the login that answers; empty until first use picks
3024
+ * one.
3025
+ */
3026
+ credential_id?: string;
3027
+ /**
3028
+ * Host is the first host it was wanted for.
3029
+ */
3030
+ host?: string;
3031
+ /**
3032
+ * Reason is why it was declined or ended.
3033
+ */
3034
+ reason?: EgressGrantReason;
3035
+ created_at: string;
3036
+ updated_at: string;
3037
+ ended_at?: string;
3038
+ }
2941
3039
  /**
2942
3040
  * EngineConfig holds engine configuration (no gorm tags).
2943
3041
  */
@@ -3110,7 +3208,7 @@ export interface WorkerRAM {
3110
3208
  * a task lists the ones it needs (Task.Requires); the scheduler only sends
3111
3209
  * a task to an engine that has every one it needs.
3112
3210
  */
3113
- export type EngineCapability = "egress_gateway" | "sandboxes" | "capacity" | "egress_pending";
3211
+ export type EngineCapability = "egress_gateway" | "sandboxes" | "capacity" | "egress_pending" | "egress_grants";
3114
3212
  /**
3115
3213
  * EngineCapabilityEgressGateway: the engine runs its sandboxes behind
3116
3214
  * the egress gateway, so it can take bound secrets (the v2 secrets
@@ -3135,6 +3233,15 @@ export declare const EngineCapabilityCapacity: EngineCapability;
3135
3233
  * reach (POST /engines/{id}/egress/hosts) (INF-1173).
3136
3234
  */
3137
3235
  export declare const EngineCapabilityEgressPending: EngineCapability;
3236
+ /**
3237
+ * EngineCapabilityEgressGrants: the engine's gateway holds a fetched
3238
+ * value only BoundSecret.KeepFor (at most until it expires), answers a
3239
+ * refused binding with EgressResolveResponse.Reason, wipes a binding's
3240
+ * held value when it is declined, and takes egress_revoke
3241
+ * (WsEgressRevokePayload). Tasks are sent pending bindings only on such
3242
+ * an engine (INF-1173).
3243
+ */
3244
+ export declare const EngineCapabilityEgressGrants: EngineCapability;
3138
3245
  /**
3139
3246
  * EngineCapabilities is a set of capabilities, kept as a list. Nil and
3140
3247
  * empty are the same: nothing beyond the base contract.
@@ -3272,7 +3379,7 @@ export interface DecideEntitlementRequestRequest {
3272
3379
  * and APIError.Code on the legacy envelope. Clients branch on these, so a
3273
3380
  * code is a named const here, where it generates into models and the SDKs.
3274
3381
  */
3275
- 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" | "web_access_restricted" | "requirements_not_met" | "team_role_required" | "in_other_workspace" | "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" | "last_authenticator" | "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";
3382
+ 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" | "access_restricted" | "web_access_restricted" | "requirements_not_met" | "team_role_required" | "in_other_workspace" | "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" | "last_authenticator" | "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";
3276
3383
  export declare const ErrorCodeInvalidRequest: ErrorCode;
3277
3384
  export declare const ErrorCodeValidationError: ErrorCode;
3278
3385
  export declare const ErrorCodeUnauthorized: ErrorCode;
@@ -3286,9 +3393,16 @@ export declare const ErrorCodeMethodNotAllowed: ErrorCode;
3286
3393
  export declare const ErrorCodeRateLimited: ErrorCode;
3287
3394
  export declare const ErrorCodeInternalError: ErrorCode;
3288
3395
  /**
3289
- * ErrorCodeWebAccessRestricted (403): the request comes from an address
3290
- * restricted to sign-in and the CLI; detail is the operator's notice
3291
- * and meta is WebAccessRestrictedMeta.
3396
+ * ErrorCodeAccessRestricted (403): the redlist refuses the request (a
3397
+ * restricted address, or a restricted account outside sign-in, /me,
3398
+ * telemetry and balance). detail is the notice to show the person, as
3399
+ * is; meta is AccessRestrictedMeta: a reference to quote and who to
3400
+ * contact.
3401
+ */
3402
+ export declare const ErrorCodeAccessRestricted: ErrorCode;
3403
+ /**
3404
+ * ErrorCodeWebAccessRestricted is no longer sent: refusals are
3405
+ * access_restricted. Kept so clients that name it still build.
3292
3406
  */
3293
3407
  export declare const ErrorCodeWebAccessRestricted: ErrorCode;
3294
3408
  /**
package/dist/types.js CHANGED
@@ -438,6 +438,44 @@ export const ToolRiskMedium = "medium";
438
438
  * ToolRiskHigh: dangerous or irreversible changes.
439
439
  */
440
440
  export const ToolRiskHigh = "high";
441
+ export const EgressGrantScopeTask = "task";
442
+ export const EgressGrantScopeSandbox = "sandbox";
443
+ /**
444
+ * EgressGrantOpen: the scope may be asked for the login; nobody has
445
+ * been yet.
446
+ */
447
+ export const EgressGrantOpen = "open";
448
+ /**
449
+ * EgressGrantAsked: a card is open (EgressGrantDTO.InterruptID).
450
+ */
451
+ export const EgressGrantAsked = "asked";
452
+ /**
453
+ * EgressGrantAllowed: the scope gets the login.
454
+ */
455
+ export const EgressGrantAllowed = "allowed";
456
+ /**
457
+ * EgressGrantDeclined: a person said no, for the scope's life.
458
+ */
459
+ export const EgressGrantDeclined = "declined";
460
+ /**
461
+ * EgressGrantEnded: the grant no longer holds (Reason says why); the
462
+ * scope keeps running, and its next use decides again.
463
+ */
464
+ export const EgressGrantEnded = "ended";
465
+ export const EgressGrantSourceAppDeclared = "app_declared";
466
+ export const EgressGrantSourceAgentConfig = "agent_config";
467
+ export const EgressGrantSourceSandboxCreate = "sandbox_create";
468
+ export const EgressGrantSourceOwnerApproval = "owner_approval";
469
+ export const EgressGrantSourceConnectedOffer = "connected_offer";
470
+ export const EgressGrantSourceReconnect = "reconnect";
471
+ export const EgressGrantReasonDeclined = "declined";
472
+ export const EgressGrantReasonLoginDeleted = "login_deleted";
473
+ export const EgressGrantReasonLoginDisconnected = "login_disconnected";
474
+ export const EgressGrantReasonNotOwner = "not_owner";
475
+ export const EgressGrantReasonExpiredLifetime = "expired_lifetime";
476
+ export const EgressGrantReasonScopesMissing = "scopes_missing";
477
+ export const EgressGrantReasonScopeEnded = "scope_ended";
478
+ export const EgressGrantReasonRevokedByOwner = "revoked_by_owner";
441
479
  /**
442
480
  * EngineCapabilityEgressGateway: the engine runs its sandboxes behind
443
481
  * the egress gateway, so it can take bound secrets (the v2 secrets
@@ -462,6 +500,15 @@ export const EngineCapabilityCapacity = "capacity";
462
500
  * reach (POST /engines/{id}/egress/hosts) (INF-1173).
463
501
  */
464
502
  export const EngineCapabilityEgressPending = "egress_pending";
503
+ /**
504
+ * EngineCapabilityEgressGrants: the engine's gateway holds a fetched
505
+ * value only BoundSecret.KeepFor (at most until it expires), answers a
506
+ * refused binding with EgressResolveResponse.Reason, wipes a binding's
507
+ * held value when it is declined, and takes egress_revoke
508
+ * (WsEgressRevokePayload). Tasks are sent pending bindings only on such
509
+ * an engine (INF-1173).
510
+ */
511
+ export const EngineCapabilityEgressGrants = "egress_grants";
465
512
  export const ErrorCodeInvalidRequest = "invalid_request";
466
513
  export const ErrorCodeValidationError = "validation_error";
467
514
  export const ErrorCodeUnauthorized = "unauthorized";
@@ -475,9 +522,16 @@ export const ErrorCodeMethodNotAllowed = "method_not_allowed";
475
522
  export const ErrorCodeRateLimited = "rate_limited";
476
523
  export const ErrorCodeInternalError = "internal_error";
477
524
  /**
478
- * ErrorCodeWebAccessRestricted (403): the request comes from an address
479
- * restricted to sign-in and the CLI; detail is the operator's notice
480
- * and meta is WebAccessRestrictedMeta.
525
+ * ErrorCodeAccessRestricted (403): the redlist refuses the request (a
526
+ * restricted address, or a restricted account outside sign-in, /me,
527
+ * telemetry and balance). detail is the notice to show the person, as
528
+ * is; meta is AccessRestrictedMeta: a reference to quote and who to
529
+ * contact.
530
+ */
531
+ export const ErrorCodeAccessRestricted = "access_restricted";
532
+ /**
533
+ * ErrorCodeWebAccessRestricted is no longer sent: refusals are
534
+ * access_restricted. Kept so clients that name it still build.
481
535
  */
482
536
  export const ErrorCodeWebAccessRestricted = "web_access_restricted";
483
537
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inferencesh/sdk",
3
- "version": "0.38.7",
3
+ "version": "0.38.9",
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",