@inferencesh/sdk 0.14.2 → 0.16.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,34 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.16.0] - 2026-10-02
11
+
12
+ ### Added
13
+
14
+ - `useAgentActions().getAlwaysAllowOptions(toolInvocationId)`: what "always allow" can save for a call awaiting approval, narrowest first, computed by the api (`GET /chats/{id}/tools/{toolId}/always-allow/options`). Each option has a `key`, a `scope` (`exact`, `prefix`, `folder`, `remote`, `tool`), a `label` such as "npm run commands on laptop", and the chat `rules` it saves; `default` is the narrowest that answers the call again, and `unavailable` says why there are none.
15
+ - `useAgentActions().explainTool(toolInvocationId)`: a plain-words explanation of a call awaiting approval, `{ risk_level: 'low' | 'medium' | 'high', explanation, reasoning, risk }` (`POST /chats/{id}/tools/{toolId}/explain`). A model writes it the first time it is asked for and the api keeps it for the call; call it only when the person asks.
16
+ - Types: `ToolExplanationDTO`, `ToolRiskLevel`, `AlwaysAllowOptionsDTO`, `AlwaysAllowOptionDTO`, `AlwaysAllowScope`, `AlwaysAllowRequest`, `AlwaysAllowResultDTO`, `PolicyRuleDTO` (with `label`), `AlwaysAllowChoice`.
17
+
18
+ ### Changed
19
+
20
+ - `useAgentActions().alwaysAllowTool(toolInvocationId, { option })` saves the chosen option and resolves to the saved rules. The second argument used to be the tool name; a string is still accepted and means the api's default. A 409 (stale option) or 400 rejects without putting the chat in the error state.
21
+
22
+ ### Security
23
+
24
+ - `proxy-addr` 2.0.8 in the lockfile (CVE-2026-90711).
25
+
26
+ ## [0.15.0] - 2026-10-02
27
+
28
+ ### Added
29
+
30
+ - `useAgentActions().updateChatSettings(settings)`: change a chat's name, visibility, `allow_all_tools` (run every tool without asking; switching it on approves the calls already waiting), `disable_hooks` and `forget_memory` (`POST /chats/{id}/settings`).
31
+ - `useAgentActions().switchAgent(agentRef)`: hand the chat to another agent our loop runs; the next message goes to it. A harness agent is refused.
32
+ - Types: `ChatSettingsRequest`; `ChatData.allow_all_tools` and `disable_hooks`; per-server MCP headers; API key scope and an optional `last_used_at`; engine-picker provider options.
33
+
34
+ ### Changed
35
+
36
+ - The `inference-src` export condition is listed before `types`, so a bundler that sets it resolves the TypeScript source.
37
+
10
38
  ## [0.14.2] - 2026-10-01
11
39
 
12
40
  ### Added
@@ -368,16 +368,37 @@ export function createActions(ctx) {
368
368
  throw error;
369
369
  }
370
370
  },
371
- alwaysAllowTool: async (toolInvocationId, toolName) => {
371
+ getAlwaysAllowOptions: async (toolInvocationId) => {
372
+ const chatId = getChatId();
373
+ if (!chatId)
374
+ return null;
375
+ return api.getAlwaysAllowOptions(client, chatId, toolInvocationId);
376
+ },
377
+ explainTool: async (toolInvocationId) => {
378
+ const chatId = getChatId();
379
+ if (!chatId)
380
+ throw new Error('Cannot explain a tool call without a chat');
381
+ return api.explainTool(client, chatId, toolInvocationId);
382
+ },
383
+ alwaysAllowTool: async (toolInvocationId, choice) => {
372
384
  const chatId = getChatId();
373
385
  if (!chatId) {
374
386
  console.error('[AgentSDK] Cannot always-allow tool without a chatId');
375
- return;
387
+ return undefined;
376
388
  }
389
+ // A string is the tool name older callers passed; the api reads the
390
+ // tool from the call, so it only means "the default option".
391
+ const option = typeof choice === 'string' ? undefined : choice?.option;
377
392
  try {
378
- await api.alwaysAllowTool(client, chatId, toolInvocationId, toolName);
393
+ return await api.alwaysAllowTool(client, chatId, toolInvocationId, option);
379
394
  }
380
395
  catch (error) {
396
+ // 409: the option is stale (the rules changed since it was read);
397
+ // 400: nothing can be always-allowed here. The call is still
398
+ // waiting and the connection is fine: the caller reads the options
399
+ // again or shows why.
400
+ if (isInferenceError(error) && (error.statusCode === 409 || error.statusCode === 400))
401
+ throw error;
381
402
  console.error('[AgentSDK] Failed to always-allow tool:', error);
382
403
  const err = error instanceof Error ? error : new Error('Failed to always-allow tool');
383
404
  dispatch({ type: 'SET_CONNECTION_STATUS', payload: 'error' });
@@ -386,6 +407,42 @@ export function createActions(ctx) {
386
407
  throw error;
387
408
  }
388
409
  },
410
+ updateChatSettings: async (settings) => {
411
+ const chatId = getChatId();
412
+ if (!chatId) {
413
+ console.error('[AgentSDK] Cannot change chat settings without a chatId');
414
+ return;
415
+ }
416
+ try {
417
+ // The response carries the chat without its messages: update the
418
+ // chat and keep the conversation on screen.
419
+ dispatch({ type: 'UPDATE_CHAT', payload: await api.updateChatSettings(client, chatId, settings) });
420
+ }
421
+ catch (error) {
422
+ console.error('[AgentSDK] Failed to change chat settings:', error);
423
+ const err = error instanceof Error ? error : new Error('Failed to change chat settings');
424
+ dispatch({ type: 'SET_ERROR', payload: err.message });
425
+ callbacks.onError?.(err);
426
+ throw error;
427
+ }
428
+ },
429
+ switchAgent: async (agentRef) => {
430
+ const chatId = getChatId();
431
+ if (!chatId) {
432
+ console.error('[AgentSDK] Cannot switch the agent without a chatId');
433
+ return;
434
+ }
435
+ try {
436
+ dispatch({ type: 'UPDATE_CHAT', payload: await api.setAgent(client, chatId, agentRef) });
437
+ }
438
+ catch (error) {
439
+ console.error('[AgentSDK] Failed to switch the agent:', error);
440
+ const err = error instanceof Error ? error : new Error('Failed to switch the agent');
441
+ dispatch({ type: 'SET_ERROR', payload: err.message });
442
+ callbacks.onError?.(err);
443
+ throw error;
444
+ }
445
+ },
389
446
  cancelMessage: async (messageId) => {
390
447
  try {
391
448
  await api.cancelMessage(client, messageId);
@@ -7,7 +7,7 @@
7
7
  *
8
8
  * /agents/run stays for A2A/programmatic use.
9
9
  */
10
- import type { ChatDTO, ChatMessageDTO, InterruptDTO } from '../types';
10
+ import type { AlwaysAllowOptionsDTO, AlwaysAllowResultDTO, ChatDTO, ChatMessageDTO, ChatSettingsRequest, InterruptDTO, ToolExplanationDTO } from '../types';
11
11
  import type { AgentOptions, AgentClient, AgentInfo, FileRef } from './types';
12
12
  export interface SendResult {
13
13
  chatId: string;
@@ -46,7 +46,24 @@ export declare function submitToolResult(client: AgentClient, toolInvocationId:
46
46
  }): Promise<void>;
47
47
  export declare function approveTool(client: AgentClient, toolInvocationId: string): Promise<void>;
48
48
  export declare function rejectTool(client: AgentClient, toolInvocationId: string, reason?: string): Promise<void>;
49
- export declare function alwaysAllowTool(client: AgentClient, chatId: string, toolInvocationId: string, toolName: string): Promise<void>;
49
+ /**
50
+ * What "always allow" can save for a call awaiting approval, narrowest first.
51
+ * The api computes the options from the call; each one, saved, answers it again.
52
+ */
53
+ export declare function getAlwaysAllowOptions(client: AgentClient, chatId: string, toolInvocationId: string): Promise<AlwaysAllowOptionsDTO>;
54
+ /**
55
+ * Save an "always allow" option (a key from getAlwaysAllowOptions) as chat
56
+ * rules and approve the call once. Without an option the api saves its old
57
+ * default: the command exactly for remote_exec, the whole tool otherwise.
58
+ */
59
+ export declare function alwaysAllowTool(client: AgentClient, chatId: string, toolInvocationId: string, option?: string): Promise<AlwaysAllowResultDTO>;
60
+ /**
61
+ * Explain a call awaiting approval in plain words: what it does, why the agent
62
+ * appears to make it, and its risk. Generated by a model the first time and kept
63
+ * for the call, so asking again is free.
64
+ */
65
+ export declare function explainTool(client: AgentClient, chatId: string, toolInvocationId: string): Promise<ToolExplanationDTO>;
66
+ export declare function updateChatSettings(client: AgentClient, chatId: string, settings: ChatSettingsRequest): Promise<ChatDTO>;
50
67
  export declare function resolveInterrupt(client: AgentClient, interruptId: string, decision: 'allow' | 'deny'): Promise<InterruptDTO>;
51
68
  export declare function listRunInterrupts(client: AgentClient, runId: string): Promise<InterruptDTO[]>;
52
69
  export declare function uploadFile(client: AgentClient, file: globalThis.File): Promise<FileRef>;
package/dist/agent/api.js CHANGED
@@ -151,10 +151,36 @@ export async function approveTool(client, toolInvocationId) {
151
151
  export async function rejectTool(client, toolInvocationId, reason) {
152
152
  await client.http.request('post', `/tools/${toolInvocationId}/reject`, { data: { reason } });
153
153
  }
154
- export async function alwaysAllowTool(client, chatId, toolInvocationId, toolName) {
155
- await client.http.request('post', `/chats/${chatId}/tools/${toolInvocationId}/always-allow`, {
156
- data: { tool_name: toolName }
157
- });
154
+ /**
155
+ * What "always allow" can save for a call awaiting approval, narrowest first.
156
+ * The api computes the options from the call; each one, saved, answers it again.
157
+ */
158
+ export async function getAlwaysAllowOptions(client, chatId, toolInvocationId) {
159
+ const resp = await client.http.request('get', `/chats/${chatId}/tools/${toolInvocationId}/always-allow/options`);
160
+ return resp.data;
161
+ }
162
+ /**
163
+ * Save an "always allow" option (a key from getAlwaysAllowOptions) as chat
164
+ * rules and approve the call once. Without an option the api saves its old
165
+ * default: the command exactly for remote_exec, the whole tool otherwise.
166
+ */
167
+ export async function alwaysAllowTool(client, chatId, toolInvocationId, option) {
168
+ const data = option ? { option } : {};
169
+ const resp = await client.http.request('post', `/chats/${chatId}/tools/${toolInvocationId}/always-allow`, { data });
170
+ return resp.data;
171
+ }
172
+ /**
173
+ * Explain a call awaiting approval in plain words: what it does, why the agent
174
+ * appears to make it, and its risk. Generated by a model the first time and kept
175
+ * for the call, so asking again is free.
176
+ */
177
+ export async function explainTool(client, chatId, toolInvocationId) {
178
+ const resp = await client.http.request('post', `/chats/${chatId}/tools/${toolInvocationId}/explain`);
179
+ return resp.data;
180
+ }
181
+ export async function updateChatSettings(client, chatId, settings) {
182
+ const resp = await client.http.request('post', `/chats/${chatId}/settings`, { data: settings });
183
+ return resp.data;
158
184
  }
159
185
  // =========================================================================
160
186
  // Interrupt operations
@@ -46,6 +46,6 @@
46
46
  export { AgentChatProvider } from './provider';
47
47
  export { useAgentChat, useAgentActions, useAgentClient, useAgentChatContext, useMessage, } from './hooks';
48
48
  export { AgentChatContext, type AgentChatContextValue } from './context';
49
- export type { AgentClient, FileRef, AdHocAgentConfig, TemplateAgentConfig, AgentOptions, AgentChatState, AgentChatActions, ChatStatus, AgentChatProviderProps, ClientTool, ClientToolHandlerFn, } from './types';
49
+ export type { AgentClient, FileRef, AdHocAgentConfig, TemplateAgentConfig, AgentOptions, AgentChatState, AgentChatActions, AlwaysAllowChoice, ChatStatus, AgentChatProviderProps, ClientTool, ClientToolHandlerFn, } from './types';
50
50
  export { isAdHocConfig, isTemplateConfig, isClientTool, extractToolSchemas, extractClientToolHandlers, } from './types';
51
51
  export { MCPMethodElicitationCreate, parseMCPInputState, elicitParams, isURLElicitation, buildMCPInputResult, type MCPInputState, type ElicitRequestParams, type ElicitRequestedSchema, type ElicitPropertySchema, } from './mcp-input';
@@ -4,11 +4,15 @@
4
4
  * Public types for the Agent chat module.
5
5
  */
6
6
  import type { Dispatch } from 'react';
7
- import type { AgentRunDTO, AgentVersionDTO, ChatDTO, ChatMessageDTO, AgentTool, AgentConfigInput as GeneratedAgentConfig, CoreAppConfigInput as CoreAppConfig, FileRef, ElicitResult } from '../types';
7
+ import type { AgentRunDTO, AgentVersionDTO, AlwaysAllowOptionsDTO, AlwaysAllowResultDTO, ToolExplanationDTO, ChatDTO, ChatMessageDTO, ChatSettingsRequest, AgentTool, AgentConfigInput as GeneratedAgentConfig, CoreAppConfigInput as CoreAppConfig, FileRef, ElicitResult } from '../types';
8
8
  import type { HttpClient } from '../http/client';
9
9
  import type { StreamableManager } from '../http/streamable';
10
10
  import type { PollManager } from '../http/poll';
11
11
  export type { FileRef } from '../types';
12
+ /** The "always allow" option to save: a key from getAlwaysAllowOptions. */
13
+ export interface AlwaysAllowChoice {
14
+ option?: string;
15
+ }
12
16
  /**
13
17
  * Minimal client interface required by the agent module.
14
18
  * This allows extended clients (like the app client) to be used.
@@ -132,8 +136,30 @@ export interface AgentChatActions {
132
136
  approveTool: (toolInvocationId: string) => Promise<void>;
133
137
  /** Reject a tool (for HIL approval - AwaitingApproval status) */
134
138
  rejectTool: (toolInvocationId: string, reason?: string) => Promise<void>;
135
- /** Always allow a tool for this chat (approves + auto-approves future invocations) */
136
- alwaysAllowTool: (toolInvocationId: string, toolName: string) => Promise<void>;
139
+ /**
140
+ * What "always allow" can save for a call awaiting approval, narrowest
141
+ * first, as computed by the api (null without a chat). Show the options'
142
+ * labels in order; `default` is the narrowest that answers the call again.
143
+ */
144
+ getAlwaysAllowOptions: (toolInvocationId: string) => Promise<AlwaysAllowOptionsDTO | null>;
145
+ /**
146
+ * Explain a call awaiting approval (risk level, what it does, why, what could
147
+ * go wrong). A model generates it the first time it is asked for; later calls
148
+ * return the kept answer. Call it only when the person asks.
149
+ */
150
+ explainTool: (toolInvocationId: string) => Promise<ToolExplanationDTO>;
151
+ /**
152
+ * Always allow a call: save the chosen option's chat rules (`{ option: key }`
153
+ * from getAlwaysAllowOptions) and approve the call once. Without an option the
154
+ * api saves its default. A string is accepted from older callers (it was the
155
+ * tool name) and means the default. Rejects with a 409 when the option is
156
+ * stale: read the options again.
157
+ */
158
+ alwaysAllowTool: (toolInvocationId: string, choice?: AlwaysAllowChoice | string) => Promise<AlwaysAllowResultDTO | undefined>;
159
+ /** Change this chat's settings, e.g. allow_all_tools (switching it on approves the calls waiting) */
160
+ updateChatSettings: (settings: ChatSettingsRequest) => Promise<void>;
161
+ /** Hand this chat to another agent (namespace/name); the next message goes to it. Agents our loop runs only. */
162
+ switchAgent: (agentRef: string) => Promise<void>;
137
163
  /** Cancel a queued message before the agent processes it */
138
164
  cancelMessage: (messageId: string) => Promise<void>;
139
165
  /** Resolve an interrupt gate (allow or deny) */
package/dist/types.d.ts CHANGED
@@ -552,6 +552,18 @@ export interface MeResponse {
552
552
  */
553
553
  team_view?: TeamViewDTO;
554
554
  diagnostics?: DiagnosticsConfig;
555
+ /**
556
+ * PersonalTeamID is the caller's personal workspace, empty for a managed
557
+ * account, which has none.
558
+ */
559
+ personal_team_id?: string;
560
+ /**
561
+ * NeedsUsername: the caller has not chosen a username yet (their
562
+ * personal workspace's setup is incomplete). Every new account picks one
563
+ * before landing, whichever team it lands in (an invite's included), via
564
+ * POST /teams/{personal_team_id}/complete-setup.
565
+ */
566
+ needs_username: boolean;
555
567
  }
556
568
  export interface TeamCreateRequest {
557
569
  name: string;
@@ -666,6 +678,11 @@ export interface CreateApiKeyRequest {
666
678
  name: string;
667
679
  expires_at?: string;
668
680
  scopes?: string[];
681
+ /**
682
+ * Scope is who the key acts as. Empty means user (a personal key);
683
+ * workspace requires manage_keys.
684
+ */
685
+ scope?: ApiKeyScope;
669
686
  }
670
687
  /**
671
688
  * EstimateCostRequest is the request for POST /store/apps/{appId}/estimate.
@@ -1042,10 +1059,24 @@ export interface ScopePreset {
1042
1059
  export interface ApiKeyDTO extends BaseModelDTO, PermissionModelDTO {
1043
1060
  name: string;
1044
1061
  key: string;
1045
- last_used_at: string;
1062
+ /**
1063
+ * LastUsedAt is absent for a key that has never been used.
1064
+ */
1065
+ last_used_at?: string;
1046
1066
  expires_at?: string;
1047
1067
  scopes: Scope[];
1048
1068
  source?: string;
1069
+ /**
1070
+ * Scope is who the key acts as: its creator (user) or the workspace.
1071
+ */
1072
+ scope: ApiKeyScope;
1073
+ /**
1074
+ * CreatedBy is the person who created the key; Creator is that person,
1075
+ * set on lists. On a workspace key user_id is the workspace's service
1076
+ * account, so these are what show who made it.
1077
+ */
1078
+ created_by: string;
1079
+ creator?: TeamMemberUserDTO;
1049
1080
  }
1050
1081
  /**
1051
1082
  * AppPricing configures all pricing using CEL expressions.
@@ -1716,6 +1747,36 @@ export interface SubmitBountyResponse {
1716
1747
  submission: BountySubmissionDTO;
1717
1748
  granted_amount?: number;
1718
1749
  }
1750
+ /**
1751
+ * ChatSettingsRequest changes a chat's settings. A field left out is left as
1752
+ * it is.
1753
+ */
1754
+ export interface ChatSettingsRequest {
1755
+ /**
1756
+ * Name renames the chat. It cannot be empty.
1757
+ */
1758
+ name?: string;
1759
+ /**
1760
+ * Visibility is who can open the chat: private (only you), team (your
1761
+ * workspace) or public (anyone with the link).
1762
+ */
1763
+ visibility?: Visibility;
1764
+ /**
1765
+ * AllowAllTools runs every tool call without asking. Switching it on also
1766
+ * approves the calls already waiting.
1767
+ */
1768
+ allow_all_tools?: boolean;
1769
+ /**
1770
+ * DisableHooks stops the agent's lifecycle hooks (suggest, learn,
1771
+ * webhooks, gates) firing in this chat.
1772
+ */
1773
+ disable_hooks?: boolean;
1774
+ /**
1775
+ * ForgetMemory removes these keys from the chat's memory, the notes the
1776
+ * agent keeps for this conversation. A key that is not there is ignored.
1777
+ */
1778
+ forget_memory?: string[];
1779
+ }
1719
1780
  /**
1720
1781
  * ChatDTO for API responses
1721
1782
  */
@@ -1773,6 +1834,189 @@ export interface ChatMessageDTO extends BaseModelDTO, PermissionModelDTO {
1773
1834
  tool_call_id?: string;
1774
1835
  tool_invocations?: ToolInvocationDTO[];
1775
1836
  }
1837
+ /**
1838
+ * PolicyEffect is a rule's outcome: allow, ask or deny.
1839
+ */
1840
+ export type PolicyEffect = "allow" | "ask" | "deny";
1841
+ export declare const PolicyEffectAllow: PolicyEffect;
1842
+ export declare const PolicyEffectAsk: PolicyEffect;
1843
+ export declare const PolicyEffectDeny: PolicyEffect;
1844
+ /**
1845
+ * PolicyRuleDTO is one rule, typed form Kind[selector](specifier).
1846
+ */
1847
+ export interface PolicyRuleDTO {
1848
+ id: string;
1849
+ effect: PolicyEffect;
1850
+ /**
1851
+ * Kind: RemoteExec, Workspace, Harness, Tool (and, from phase 3, App,
1852
+ * Agent, Knowledge, Mcp, Flow, WebFetch).
1853
+ */
1854
+ kind: string;
1855
+ /**
1856
+ * Selector narrows the rule to one remote (its id) or a tag (tag:<name>);
1857
+ * empty applies everywhere.
1858
+ */
1859
+ selector: string;
1860
+ /**
1861
+ * Specifier is the kind's pattern: a command (`npm test`, `git push:*`),
1862
+ * a folder (`~/proj/**`), a harness tool with its pattern
1863
+ * (`Bash(git status:*)`, `Edit`), or a loop tool's name. Empty is the
1864
+ * whole kind.
1865
+ */
1866
+ specifier: string;
1867
+ /**
1868
+ * Label is the rule in words, e.g. "git commit commands on Laptop", the
1869
+ * same words an approval prompt's "always allow" options use.
1870
+ */
1871
+ label: string;
1872
+ /**
1873
+ * CreatedAt is null for a rule that is not a stored row yet: an entry of
1874
+ * the chat's always-allow list from before rules existed, or the chat's
1875
+ * "allow every tool" setting.
1876
+ */
1877
+ created_at?: string;
1878
+ /**
1879
+ * CreatedBy is the user who wrote the rule; empty for those above.
1880
+ */
1881
+ created_by: string;
1882
+ }
1883
+ /**
1884
+ * AlwaysAllowScope is how far an "always allow" option reaches, narrowest
1885
+ * first.
1886
+ */
1887
+ export type AlwaysAllowScope = "exact" | "prefix" | "folder" | "remote" | "tool";
1888
+ /**
1889
+ * AlwaysAllowScopeExact: this call exactly (each piece of the command,
1890
+ * the file, the domain).
1891
+ */
1892
+ export declare const AlwaysAllowScopeExact: AlwaysAllowScope;
1893
+ /**
1894
+ * AlwaysAllowScopePrefix: commands that start the same way, per piece
1895
+ * (git commit:*, npm run:*).
1896
+ */
1897
+ export declare const AlwaysAllowScopePrefix: AlwaysAllowScope;
1898
+ /**
1899
+ * AlwaysAllowScopeFolder: files in the same folder.
1900
+ */
1901
+ export declare const AlwaysAllowScopeFolder: AlwaysAllowScope;
1902
+ /**
1903
+ * AlwaysAllowScopeRemote: every command on the machine.
1904
+ */
1905
+ export declare const AlwaysAllowScopeRemote: AlwaysAllowScope;
1906
+ /**
1907
+ * AlwaysAllowScopeTool: every call of the tool.
1908
+ */
1909
+ export declare const AlwaysAllowScopeTool: AlwaysAllowScope;
1910
+ /**
1911
+ * AlwaysAllowOptionDTO is one "always allow" choice on an approval prompt:
1912
+ * the chat rules it saves.
1913
+ */
1914
+ export interface AlwaysAllowOptionDTO {
1915
+ /**
1916
+ * Key names the option in POST .../always-allow. It changes when the
1917
+ * rules it stands for change.
1918
+ */
1919
+ key: string;
1920
+ scope: AlwaysAllowScope;
1921
+ /**
1922
+ * Label is the option in words, e.g. "git clone commands on Laptop".
1923
+ */
1924
+ label: string;
1925
+ /**
1926
+ * Description adds why a broad option is the narrowest offered, e.g.
1927
+ * the command uses shell syntax no narrower rule can match.
1928
+ */
1929
+ description?: string;
1930
+ /**
1931
+ * Rules are the chat rules the option saves (not stored yet: no id).
1932
+ */
1933
+ rules: PolicyRuleDTO[];
1934
+ }
1935
+ /**
1936
+ * AlwaysAllowOptionsDTO is GET /chats/{id}/tools/{toolId}/always-allow/options:
1937
+ * the options for a call awaiting approval, narrowest first. Each one,
1938
+ * saved, answers this call again. Computed by the api from the call; the
1939
+ * client never builds rules.
1940
+ */
1941
+ export interface AlwaysAllowOptionsDTO {
1942
+ options: AlwaysAllowOptionDTO[];
1943
+ /**
1944
+ * Default is the key of the narrowest option, "" when there is none.
1945
+ */
1946
+ default?: string;
1947
+ /**
1948
+ * Unavailable says why there are no options: a policy allows only its
1949
+ * own rules, or no chat rule could allow this call.
1950
+ */
1951
+ unavailable?: string;
1952
+ }
1953
+ /**
1954
+ * AlwaysAllowRequest is POST /chats/{id}/tools/{toolId}/always-allow. The
1955
+ * api saves the option's rules to the chat and approves the call once.
1956
+ */
1957
+ export interface AlwaysAllowRequest {
1958
+ /**
1959
+ * Option is an option key from the options endpoint. A key that no
1960
+ * longer names a current option is refused (409). Without one, the
1961
+ * call saves what "always allow" saved before options existed: the
1962
+ * command's pieces exactly for remote_exec, the whole tool otherwise.
1963
+ */
1964
+ option?: string;
1965
+ /**
1966
+ * ToolName is accepted from older clients and ignored: the call names
1967
+ * its own tool.
1968
+ */
1969
+ tool_name?: string;
1970
+ }
1971
+ /**
1972
+ * AlwaysAllowResultDTO is what an always-allow saved.
1973
+ */
1974
+ export interface AlwaysAllowResultDTO {
1975
+ /**
1976
+ * Option is the option chosen; null for a call without one.
1977
+ */
1978
+ option?: AlwaysAllowOptionDTO;
1979
+ /**
1980
+ * Rules are the chat rules now in place for it.
1981
+ */
1982
+ rules: PolicyRuleDTO[];
1983
+ }
1984
+ /**
1985
+ * ToolRiskLevel is how risky an explained call is.
1986
+ */
1987
+ export type ToolRiskLevel = "low" | "medium" | "high";
1988
+ /**
1989
+ * ToolRiskLow: safe development workflows (reads, builds, tests).
1990
+ */
1991
+ export declare const ToolRiskLow: ToolRiskLevel;
1992
+ /**
1993
+ * ToolRiskMedium: changes that can be undone.
1994
+ */
1995
+ export declare const ToolRiskMedium: ToolRiskLevel;
1996
+ /**
1997
+ * ToolRiskHigh: dangerous or irreversible changes.
1998
+ */
1999
+ export declare const ToolRiskHigh: ToolRiskLevel;
2000
+ /**
2001
+ * ToolExplanationDTO is POST /chats/{id}/tools/{toolId}/explain: a model's
2002
+ * plain-words reading of a call awaiting approval (Claude Code's permission
2003
+ * explainer). Generated once, when the person asks, and kept for the call.
2004
+ */
2005
+ export interface ToolExplanationDTO {
2006
+ risk_level: ToolRiskLevel;
2007
+ /**
2008
+ * Explanation is what the call does, in one or two sentences.
2009
+ */
2010
+ explanation: string;
2011
+ /**
2012
+ * Reasoning is why the agent appears to be making it.
2013
+ */
2014
+ reasoning: string;
2015
+ /**
2016
+ * Risk is what could go wrong, in a few words.
2017
+ */
2018
+ risk: string;
2019
+ }
1776
2020
  /**
1777
2021
  * CredentialDTO is the API response for a credential (never exposes secrets).
1778
2022
  */
@@ -2069,7 +2313,7 @@ export interface EntitlementErrorMeta {
2069
2313
  * and APIError.Code on the legacy envelope. Clients branch on these, so a
2070
2314
  * code is a named const here, where it generates into models and the SDKs.
2071
2315
  */
2072
- 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" | "otp_required" | "mcp_auth_expired" | "limit_exceeded" | "feature_not_available" | "entitlement_unavailable" | "payment_required" | "payment_method_required" | "agents_disabled" | "remote_offline" | "remote_timeout" | "harness_not_drivable" | "harness_too_old";
2316
+ 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" | "mcp_auth_expired" | "limit_exceeded" | "feature_not_available" | "entitlement_unavailable" | "payment_required" | "payment_method_required" | "agents_disabled" | "remote_offline" | "remote_timeout" | "harness_not_drivable" | "harness_too_old";
2073
2317
  export declare const ErrorCodeInvalidRequest: ErrorCode;
2074
2318
  export declare const ErrorCodeValidationError: ErrorCode;
2075
2319
  export declare const ErrorCodeUnauthorized: ErrorCode;
@@ -2093,6 +2337,25 @@ export declare const ErrorCodeTeamRoleRequired: ErrorCode;
2093
2337
  * usage policy. The message names who to ask.
2094
2338
  */
2095
2339
  export declare const ErrorCodeBlockedByUsagePolicy: ErrorCode;
2340
+ /**
2341
+ * ErrorCodeLastOwner (400): the change would leave a team (or an org's
2342
+ * workspace) without an owner.
2343
+ */
2344
+ export declare const ErrorCodeLastOwner: ErrorCode;
2345
+ /**
2346
+ * ErrorCodeAccountDeactivated (403): an org deactivated this managed
2347
+ * account; sign-in and every request are refused until an org admin
2348
+ * reactivates it. ErrorCodeAccountBanned (403): the platform suspended
2349
+ * the account.
2350
+ */
2351
+ export declare const ErrorCodeAccountDeactivated: ErrorCode;
2352
+ export declare const ErrorCodeAccountBanned: ErrorCode;
2353
+ /**
2354
+ * ErrorCodePersonRequired (403): only a person may do this, and the
2355
+ * caller is a workspace's service account (a workspace API key), or the
2356
+ * account is one and cannot sign in.
2357
+ */
2358
+ export declare const ErrorCodePersonRequired: ErrorCode;
2096
2359
  export declare const ErrorCodeOTPRequired: ErrorCode;
2097
2360
  export declare const ErrorCodeMCPAuthExpired: ErrorCode;
2098
2361
  /**
@@ -2529,6 +2792,11 @@ export interface InstanceTypeDTO extends BaseModelDTO, PermissionModelDTO {
2529
2792
  * for this rental type. Empty on the raw catalog.
2530
2793
  */
2531
2794
  rental_type?: InstanceRentalType;
2795
+ /**
2796
+ * Options lists every in-stock provider for an engine-picker offer,
2797
+ * cheapest first; the offer itself is the first one. Empty on the raw catalog.
2798
+ */
2799
+ options?: InstanceTypeOptionDTO[];
2532
2800
  configuration?: InstanceTypeConfiguration;
2533
2801
  availability: InstanceTypeAvailability[];
2534
2802
  boot_time?: InstanceTypeBootTime;
@@ -2554,6 +2822,28 @@ export interface InstanceTypeAvailability {
2554
2822
  */
2555
2823
  hourly_price?: number;
2556
2824
  }
2825
+ /**
2826
+ * InstanceTypeOptionDTO is one launchable provider behind an engine-picker
2827
+ * offer. Launch with its cloud and shade_instance_type, one of its regions and
2828
+ * the offer's rental_type.
2829
+ */
2830
+ export interface InstanceTypeOptionDTO {
2831
+ cloud: InstanceCloudProvider;
2832
+ cloud_logo_url?: string;
2833
+ shade_instance_type: string;
2834
+ cloud_instance_type: string;
2835
+ hourly_price: number;
2836
+ configuration?: InstanceTypeConfiguration;
2837
+ regions: InstanceTypeOptionRegion[];
2838
+ }
2839
+ /**
2840
+ * InstanceTypeOptionRegion is an in-stock region and its hourly price in
2841
+ * cents. Spot prices can differ by region.
2842
+ */
2843
+ export interface InstanceTypeOptionRegion {
2844
+ region: string;
2845
+ hourly_price: number;
2846
+ }
2557
2847
  export interface InstanceTypeBootTime {
2558
2848
  average_seconds: number;
2559
2849
  updated_at: string;
@@ -2914,6 +3204,17 @@ export interface MCPServerDTO {
2914
3204
  auth_type: MCPServerAuthType;
2915
3205
  oauth_client_id?: string;
2916
3206
  default_scopes: StringSlice;
3207
+ /**
3208
+ * Headers are static HTTP headers sent on every request to the server,
3209
+ * set by the team's admins (e.g. X-MCP-Toolsets, X-MCP-Readonly).
3210
+ */
3211
+ headers?: {
3212
+ [key: string]: string;
3213
+ };
3214
+ /**
3215
+ * Setup is what the server's directory entry knows about setting it up.
3216
+ */
3217
+ setup?: MCPServerSetup;
2917
3218
  documentation_url: string;
2918
3219
  connection_status?: string;
2919
3220
  /**
@@ -2922,6 +3223,27 @@ export interface MCPServerDTO {
2922
3223
  */
2923
3224
  connection_scope?: CredentialScope;
2924
3225
  }
3226
+ /**
3227
+ * MCPServerSetup is what a server's directory entry knows about setting the
3228
+ * server up, as data: shown to whoever connects a server on the same host,
3229
+ * so no server's specifics live in code.
3230
+ */
3231
+ export interface MCPServerSetup {
3232
+ /**
3233
+ * ResourceAppID is the id the server's API has at its authorization
3234
+ * server, which an organization must know before it can approve access
3235
+ * (for a Microsoft Entra resource: the application id a tenant needs a
3236
+ * service principal for).
3237
+ */
3238
+ resource_app_id?: string;
3239
+ /**
3240
+ * RecommendedHeaders are the least-privilege static headers the server
3241
+ * documents (e.g. X-MCP-Toolsets), offered by the headers editor.
3242
+ */
3243
+ recommended_headers?: {
3244
+ [key: string]: string;
3245
+ };
3246
+ }
2925
3247
  /**
2926
3248
  * NotificationDTO is the data transfer object
2927
3249
  */
@@ -3793,6 +4115,12 @@ export interface TeamDTO extends BaseModelDTO {
3793
4115
  * OrgID of the org this team belongs to ('' = standalone team).
3794
4116
  */
3795
4117
  org_id?: string;
4118
+ /**
4119
+ * OrgName is that org's display name (its workspace's name), set on the
4120
+ * caller's team list (/teams) so a member of one of its teams sees whose
4121
+ * org it is without belonging to the org workspace.
4122
+ */
4123
+ org_name?: string;
3796
4124
  /**
3797
4125
  * UsagePolicyID of the team's own usage policy ('' = inherit the org's,
3798
4126
  * or ungoverned when standalone, INF-808).
@@ -3987,6 +4315,11 @@ export interface UserDTO extends BaseModelDTO {
3987
4315
  * cannot create teams/orgs).
3988
4316
  */
3989
4317
  managed_by_org_id?: string;
4318
+ /**
4319
+ * ServiceTeamID: set on a workspace's service account, the principal its
4320
+ * workspace API keys act as.
4321
+ */
4322
+ service_team_id?: string;
3990
4323
  email: string;
3991
4324
  name: string;
3992
4325
  full_name: string;
@@ -4197,6 +4530,23 @@ export interface A2UISurface {
4197
4530
  components: A2UIComponent[];
4198
4531
  dataModel?: any;
4199
4532
  }
4533
+ /**
4534
+ * ApiKeyScope is who an API key acts as, chosen when it is created, the way a
4535
+ * credential's scope says who owns it.
4536
+ */
4537
+ export type ApiKeyScope = "user" | "workspace";
4538
+ /**
4539
+ * ApiKeyScopeUser is a personal key: it acts as the person who created it,
4540
+ * in the workspace it was created in, and ends when they can no longer
4541
+ * act there. Device-auth, `belt auth token`, OAuth and engine keys are
4542
+ * always personal.
4543
+ */
4544
+ export declare const ApiKeyScopeUser: ApiKeyScope;
4545
+ /**
4546
+ * ApiKeyScopeWorkspace is a workspace key: it acts as the workspace's
4547
+ * service account, not a person, and outlives the admin who created it.
4548
+ */
4549
+ export declare const ApiKeyScopeWorkspace: ApiKeyScope;
4200
4550
  export type AppCategory = "image" | "video" | "audio" | "text" | "chat" | "3d" | "other" | "flow";
4201
4551
  export declare const AppCategoryImage: AppCategory;
4202
4552
  export declare const AppCategoryVideo: AppCategory;
@@ -4330,6 +4680,17 @@ export interface ChatData {
4330
4680
  plan_steps: PlanStep[];
4331
4681
  memory: StringEncodedMap;
4332
4682
  always_allowed_tools: string[];
4683
+ /**
4684
+ * AllowAllTools runs every tool call in this chat without asking. The
4685
+ * person switches it in the chat's settings, and off again at any time.
4686
+ */
4687
+ allow_all_tools: boolean;
4688
+ /**
4689
+ * DisableHooks stops the agent's lifecycle hooks firing in this chat. A
4690
+ * review branch is opened with it set, so a review cannot fire the hook
4691
+ * that reviews it.
4692
+ */
4693
+ disable_hooks?: boolean;
4333
4694
  }
4334
4695
  /**
4335
4696
  * PlanStep represents a step in an agent's execution plan
@@ -5326,11 +5687,24 @@ export declare const TeamKindOrg: TeamKind;
5326
5687
  * TeamCapability is one thing a caller may do to a team's settings. The set is
5327
5688
  * closed; team.Subject.Can is the only place that grants them.
5328
5689
  */
5329
- export type TeamCapability = "edit_profile" | "manage_members" | "view_members" | "manage_keys" | "manage_vault" | "view_billing" | "manage_billing" | "view_policy" | "manage_policy" | "manage_org" | "manage_sso" | "archive" | "create_team" | "create_org" | "connect_org_credential" | "connect_platform_credential";
5690
+ export type TeamCapability = "edit_profile" | "manage_members" | "manage_admins" | "view_members" | "manage_keys" | "create_keys" | "manage_vault" | "view_billing" | "manage_billing" | "view_policy" | "manage_policy" | "manage_org" | "manage_sso" | "archive" | "create_team" | "create_org" | "connect_org_credential" | "connect_platform_credential";
5330
5691
  export declare const TeamCapabilityEditProfile: TeamCapability;
5331
5692
  export declare const TeamCapabilityManageMembers: TeamCapability;
5693
+ /**
5694
+ * ManageAdmins: granting, changing and removing the admin and owner
5695
+ * roles. Owners only; admins manage plain members.
5696
+ */
5697
+ export declare const TeamCapabilityManageAdmins: TeamCapability;
5332
5698
  export declare const TeamCapabilityViewMembers: TeamCapability;
5699
+ /**
5700
+ * ManageKeys: the workspace's keys. Creating workspace keys, and listing
5701
+ * and revoking every key of the workspace, whoever created it.
5702
+ */
5333
5703
  export declare const TeamCapabilityManageKeys: TeamCapability;
5704
+ /**
5705
+ * CreateKeys: creating, listing and revoking your own personal keys.
5706
+ */
5707
+ export declare const TeamCapabilityCreateKeys: TeamCapability;
5334
5708
  export declare const TeamCapabilityManageVault: TeamCapability;
5335
5709
  export declare const TeamCapabilityViewBilling: TeamCapability;
5336
5710
  export declare const TeamCapabilityManageBilling: TeamCapability;
package/dist/types.js CHANGED
@@ -302,6 +302,43 @@ export const ScopeGroupKnowledge = "knowledge";
302
302
  export const ScopeGroupArtifacts = "artifacts";
303
303
  export const ScopeGroupUser = "user";
304
304
  export const ScopeGroupSettings = "settings";
305
+ export const PolicyEffectAllow = "allow";
306
+ export const PolicyEffectAsk = "ask";
307
+ export const PolicyEffectDeny = "deny";
308
+ /**
309
+ * AlwaysAllowScopeExact: this call exactly (each piece of the command,
310
+ * the file, the domain).
311
+ */
312
+ export const AlwaysAllowScopeExact = "exact";
313
+ /**
314
+ * AlwaysAllowScopePrefix: commands that start the same way, per piece
315
+ * (git commit:*, npm run:*).
316
+ */
317
+ export const AlwaysAllowScopePrefix = "prefix";
318
+ /**
319
+ * AlwaysAllowScopeFolder: files in the same folder.
320
+ */
321
+ export const AlwaysAllowScopeFolder = "folder";
322
+ /**
323
+ * AlwaysAllowScopeRemote: every command on the machine.
324
+ */
325
+ export const AlwaysAllowScopeRemote = "remote";
326
+ /**
327
+ * AlwaysAllowScopeTool: every call of the tool.
328
+ */
329
+ export const AlwaysAllowScopeTool = "tool";
330
+ /**
331
+ * ToolRiskLow: safe development workflows (reads, builds, tests).
332
+ */
333
+ export const ToolRiskLow = "low";
334
+ /**
335
+ * ToolRiskMedium: changes that can be undone.
336
+ */
337
+ export const ToolRiskMedium = "medium";
338
+ /**
339
+ * ToolRiskHigh: dangerous or irreversible changes.
340
+ */
341
+ export const ToolRiskHigh = "high";
305
342
  export const ErrorCodeInvalidRequest = "invalid_request";
306
343
  export const ErrorCodeValidationError = "validation_error";
307
344
  export const ErrorCodeUnauthorized = "unauthorized";
@@ -325,6 +362,25 @@ export const ErrorCodeTeamRoleRequired = "team_role_required";
325
362
  * usage policy. The message names who to ask.
326
363
  */
327
364
  export const ErrorCodeBlockedByUsagePolicy = "blocked_by_usage_policy";
365
+ /**
366
+ * ErrorCodeLastOwner (400): the change would leave a team (or an org's
367
+ * workspace) without an owner.
368
+ */
369
+ export const ErrorCodeLastOwner = "last_owner";
370
+ /**
371
+ * ErrorCodeAccountDeactivated (403): an org deactivated this managed
372
+ * account; sign-in and every request are refused until an org admin
373
+ * reactivates it. ErrorCodeAccountBanned (403): the platform suspended
374
+ * the account.
375
+ */
376
+ export const ErrorCodeAccountDeactivated = "account_deactivated";
377
+ export const ErrorCodeAccountBanned = "account_banned";
378
+ /**
379
+ * ErrorCodePersonRequired (403): only a person may do this, and the
380
+ * caller is a workspace's service account (a workspace API key), or the
381
+ * account is one and cannot sign in.
382
+ */
383
+ export const ErrorCodePersonRequired = "person_required";
328
384
  export const ErrorCodeOTPRequired = "otp_required";
329
385
  export const ErrorCodeMCPAuthExpired = "mcp_auth_expired";
330
386
  /**
@@ -500,6 +556,18 @@ export const A2UIForm = "Form";
500
556
  * the viewer. Rendered from the artifact's /render endpoint.
501
557
  */
502
558
  export const A2UIArtifact = "Artifact";
559
+ /**
560
+ * ApiKeyScopeUser is a personal key: it acts as the person who created it,
561
+ * in the workspace it was created in, and ends when they can no longer
562
+ * act there. Device-auth, `belt auth token`, OAuth and engine keys are
563
+ * always personal.
564
+ */
565
+ export const ApiKeyScopeUser = "user";
566
+ /**
567
+ * ApiKeyScopeWorkspace is a workspace key: it acts as the workspace's
568
+ * service account, not a person, and outlives the admin who created it.
569
+ */
570
+ export const ApiKeyScopeWorkspace = "workspace";
503
571
  export const AppCategoryImage = "image";
504
572
  export const AppCategoryVideo = "video";
505
573
  export const AppCategoryAudio = "audio";
@@ -1094,8 +1162,21 @@ export const TeamKindOrgMember = "org_member";
1094
1162
  export const TeamKindOrg = "org";
1095
1163
  export const TeamCapabilityEditProfile = "edit_profile";
1096
1164
  export const TeamCapabilityManageMembers = "manage_members";
1165
+ /**
1166
+ * ManageAdmins: granting, changing and removing the admin and owner
1167
+ * roles. Owners only; admins manage plain members.
1168
+ */
1169
+ export const TeamCapabilityManageAdmins = "manage_admins";
1097
1170
  export const TeamCapabilityViewMembers = "view_members";
1171
+ /**
1172
+ * ManageKeys: the workspace's keys. Creating workspace keys, and listing
1173
+ * and revoking every key of the workspace, whoever created it.
1174
+ */
1098
1175
  export const TeamCapabilityManageKeys = "manage_keys";
1176
+ /**
1177
+ * CreateKeys: creating, listing and revoking your own personal keys.
1178
+ */
1179
+ export const TeamCapabilityCreateKeys = "create_keys";
1099
1180
  export const TeamCapabilityManageVault = "manage_vault";
1100
1181
  export const TeamCapabilityViewBilling = "view_billing";
1101
1182
  export const TeamCapabilityManageBilling = "manage_billing";
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@inferencesh/sdk",
3
- "version": "0.14.2",
3
+ "version": "0.16.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",
7
7
  "types": "dist/index.d.ts",
8
8
  "exports": {
9
9
  ".": {
10
- "types": "./dist/index.d.ts",
11
10
  "inference-src": "./src/index.ts",
11
+ "types": "./dist/index.d.ts",
12
12
  "default": "./dist/index.js"
13
13
  },
14
14
  "./proxy": {
@@ -28,8 +28,8 @@
28
28
  "default": "./dist/proxy/hono.js"
29
29
  },
30
30
  "./proxy/remix": {
31
- "types": "./dist/proxy/remix.d.ts",
32
31
  "inference-src": "./src/proxy/remix.ts",
32
+ "types": "./dist/proxy/remix.d.ts",
33
33
  "default": "./dist/proxy/remix.js"
34
34
  },
35
35
  "./proxy/svelte": {
@@ -37,13 +37,13 @@
37
37
  "default": "./dist/proxy/svelte.js"
38
38
  },
39
39
  "./agent": {
40
- "types": "./dist/agent/index.d.ts",
41
40
  "inference-src": "./src/agent/index.ts",
41
+ "types": "./dist/agent/index.d.ts",
42
42
  "default": "./dist/agent/index.js"
43
43
  },
44
44
  "./internal/upload": {
45
- "types": "./dist/api/files.d.ts",
46
45
  "inference-src": "./src/api/files.ts",
46
+ "types": "./dist/api/files.d.ts",
47
47
  "default": "./dist/api/files.js"
48
48
  }
49
49
  },