@inferencesh/sdk 0.10.1 → 0.11.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/dist/types.js CHANGED
@@ -79,6 +79,12 @@ export const ScopeTeams = "teams";
79
79
  * Empty scopes = full access (for backwards compatibility with existing keys).
80
80
  */
81
81
  export const ScopeBilling = "billing";
82
+ /**
83
+ * API Key Scopes - hierarchical permission system.
84
+ * Resource-level scopes (e.g., "agents") imply all action-level scopes (e.g., "agents:read").
85
+ * Empty scopes = full access (for backwards compatibility with existing keys).
86
+ */
87
+ export const ScopeArtifacts = "artifacts";
82
88
  /**
83
89
  * Action-level scopes for Agents
84
90
  */
@@ -218,6 +224,16 @@ export const ScopeEnginesRead = "engines:read";
218
224
  * Empty scopes = full access (for backwards compatibility with existing keys).
219
225
  */
220
226
  export const ScopeEnginesWrite = "engines:write";
227
+ /**
228
+ * Action-level scopes for Remotes
229
+ */
230
+ export const ScopeRemotesRead = "remotes:read";
231
+ /**
232
+ * API Key Scopes - hierarchical permission system.
233
+ * Resource-level scopes (e.g., "agents") imply all action-level scopes (e.g., "agents:read").
234
+ * Empty scopes = full access (for backwards compatibility with existing keys).
235
+ */
236
+ export const ScopeRemotesWrite = "remotes:write";
221
237
  /**
222
238
  * Action-level scopes for API Keys
223
239
  */
@@ -241,12 +257,6 @@ export const ScopeKnowledgeWrite = "knowledge:write";
241
257
  /**
242
258
  * Action-level scopes for Artifacts (published HTML/Markdown pages)
243
259
  */
244
- export const ScopeArtifacts = "artifacts";
245
- /**
246
- * API Key Scopes - hierarchical permission system.
247
- * Resource-level scopes (e.g., "agents") imply all action-level scopes (e.g., "agents:read").
248
- * Empty scopes = full access (for backwards compatibility with existing keys).
249
- */
250
260
  export const ScopeArtifactsRead = "artifacts:read";
251
261
  /**
252
262
  * API Key Scopes - hierarchical permission system.
@@ -286,11 +296,60 @@ export const ScopeGroupBilling = "billing";
286
296
  export const ScopeGroupSecrets = "secrets";
287
297
  export const ScopeGroupCredentials = "credentials";
288
298
  export const ScopeGroupEngines = "engines";
299
+ export const ScopeGroupRemotes = "remotes";
289
300
  export const ScopeGroupApiKeys = "apikeys";
290
301
  export const ScopeGroupKnowledge = "knowledge";
291
302
  export const ScopeGroupArtifacts = "artifacts";
292
303
  export const ScopeGroupUser = "user";
293
304
  export const ScopeGroupSettings = "settings";
305
+ export const ErrorCodeInvalidRequest = "invalid_request";
306
+ export const ErrorCodeValidationError = "validation_error";
307
+ export const ErrorCodeUnauthorized = "unauthorized";
308
+ export const ErrorCodeForbidden = "forbidden";
309
+ export const ErrorCodeNotFound = "not_found";
310
+ export const ErrorCodeConflict = "conflict";
311
+ export const ErrorCodeNameConflict = "name_conflict";
312
+ export const ErrorCodeAlreadyExists = "already_exists";
313
+ export const ErrorCodeNotConfigured = "not_configured";
314
+ export const ErrorCodeMethodNotAllowed = "method_not_allowed";
315
+ export const ErrorCodeRateLimited = "rate_limited";
316
+ export const ErrorCodeInternalError = "internal_error";
317
+ /**
318
+ * ErrorCodeTeamRoleRequired: the caller's team role or org-admin status
319
+ * does not allow the action. Meta is TeamRoleRequiredMeta when a
320
+ * capability gate refused it.
321
+ */
322
+ export const ErrorCodeTeamRoleRequired = "team_role_required";
323
+ /**
324
+ * ErrorCodeBlockedByUsagePolicy: the resource is outside the team or org
325
+ * usage policy. The message names who to ask.
326
+ */
327
+ export const ErrorCodeBlockedByUsagePolicy = "blocked_by_usage_policy";
328
+ export const ErrorCodeOTPRequired = "otp_required";
329
+ export const ErrorCodeMCPAuthExpired = "mcp_auth_expired";
330
+ /**
331
+ * Entitlements. LimitExceeded (402) and FeatureNotAvailable (403) carry
332
+ * EntitlementErrorMeta. EntitlementUnavailable (500) means the plan could
333
+ * not be checked and the request is retriable.
334
+ */
335
+ export const ErrorCodeLimitExceeded = "limit_exceeded";
336
+ export const ErrorCodeFeatureNotAvailable = "feature_not_available";
337
+ export const ErrorCodeEntitlementUnavailable = "entitlement_unavailable";
338
+ export const ErrorCodePaymentRequired = "payment_required";
339
+ /**
340
+ * ErrorCodePaymentMethodRequired (402): a bounty program requires a saved
341
+ * payment method and the caller's team has none. Meta is
342
+ * PaymentMethodRequiredMeta; clients send the user to BillingPage.
343
+ */
344
+ export const ErrorCodePaymentMethodRequired = "payment_method_required";
345
+ /**
346
+ * Remote harness refusals.
347
+ */
348
+ export const ErrorCodeAgentsDisabled = "agents_disabled";
349
+ export const ErrorCodeRemoteOffline = "remote_offline";
350
+ export const ErrorCodeRemoteTimeout = "remote_timeout";
351
+ export const ErrorCodeHarnessNotDrivable = "harness_not_drivable";
352
+ export const ErrorCodeHarnessTooOld = "harness_too_old";
294
353
  /**
295
354
  * Flow graph action type constants.
296
355
  */
@@ -510,7 +569,8 @@ export const ChatMessageRoleAssistant = "assistant";
510
569
  export const ChatMessageRoleTool = "tool";
511
570
  /**
512
571
  * Internal bookkeeping roles — never sent to the LLM provider.
513
- * BuildContext converts these to system messages or skips them.
572
+ * BuildContext folds injections into the user turn and replaces
573
+ * compaction markers with their summary.
514
574
  */
515
575
  export const ChatMessageRoleInjection = "injection";
516
576
  export const ChatMessageRoleCompaction = "compaction";
@@ -1004,6 +1064,26 @@ export const TeamStatusTerminated = "terminated";
1004
1064
  export const TeamRoleOwner = "owner";
1005
1065
  export const TeamRoleAdmin = "admin";
1006
1066
  export const TeamRoleMember = "member";
1067
+ export const TeamCapabilityEditProfile = "edit_profile";
1068
+ export const TeamCapabilityManageMembers = "manage_members";
1069
+ export const TeamCapabilityViewMembers = "view_members";
1070
+ export const TeamCapabilityManageKeys = "manage_keys";
1071
+ export const TeamCapabilityManageVault = "manage_vault";
1072
+ export const TeamCapabilityViewBilling = "view_billing";
1073
+ export const TeamCapabilityManageBilling = "manage_billing";
1074
+ export const TeamCapabilityViewPolicy = "view_policy";
1075
+ export const TeamCapabilityManagePolicy = "manage_policy";
1076
+ export const TeamCapabilityManageOrg = "manage_org";
1077
+ export const TeamCapabilityManageSSO = "manage_sso";
1078
+ export const TeamCapabilityArchive = "archive";
1079
+ export const TeamCapabilityCreateTeam = "create_team";
1080
+ export const TeamCapabilityCreateOrg = "create_org";
1081
+ /**
1082
+ * Connecting a credential the whole org, or the whole platform, resolves.
1083
+ * The workspace level is manage_vault.
1084
+ */
1085
+ export const TeamCapabilityConnectOrgCredential = "connect_org_credential";
1086
+ export const TeamCapabilityConnectPlatformCredential = "connect_platform_credential";
1007
1087
  export const RoleGuest = "guest";
1008
1088
  export const RoleUser = "user";
1009
1089
  export const RoleAdmin = "admin";
@@ -1094,6 +1174,8 @@ export const HookDecisionSuspend = "suspend";
1094
1174
  export const HookHandlerWebhook = "webhook";
1095
1175
  export const HookHandlerTask = "task";
1096
1176
  export const HookHandlerGate = "gate";
1177
+ export const HookHandlerBuiltin = "builtin";
1178
+ export const BuiltinHookBeltSuggest = "belt:suggest";
1097
1179
  export const ToolInvocationStatusPending = "pending";
1098
1180
  export const ToolInvocationStatusInProgress = "in_progress";
1099
1181
  export const ToolInvocationStatusAwaitingInput = "awaiting_input";
@@ -1109,6 +1191,7 @@ export const ToolTypeCall = "call";
1109
1191
  export const ToolTypeMCP = "mcp";
1110
1192
  export const ToolTypeClient = "client";
1111
1193
  export const ToolTypeInternal = "internal";
1194
+ export const ToolTypeHarness = "harness";
1112
1195
  /**
1113
1196
  * Tool call types
1114
1197
  */
package/dist/utils.d.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  * Provides future compatibility when API migrates from int to string status.
4
4
  */
5
5
  import { TaskStatus } from './types';
6
- import type { ChatDTO } from './types';
6
+ import type { AgentRunState, ChatDTO, ChatMessageStatus } from './types';
7
7
  /**
8
8
  * Parse task status from int or string to TaskStatus number.
9
9
  * Handles both current int-based API and future string-based API.
@@ -14,7 +14,18 @@ export declare function parseStatus(status: number | string | undefined | null):
14
14
  * Handles both int and string status values.
15
15
  */
16
16
  export declare function isTerminalStatus(status: number | string | undefined | null): boolean;
17
+ export declare function isRunTerminal(state: AgentRunState | null | undefined): boolean;
18
+ /** Parked on a human: a tool approval or input (input_required) or an authorization (auth_required). */
19
+ export declare function isRunInterrupted(state: AgentRunState | null | undefined): boolean;
20
+ /** The run produces no further events this turn: terminal or interrupted. */
21
+ export declare function isRunSettled(state: AgentRunState | null | undefined): boolean;
22
+ /** The run is executing: submitted or working. */
23
+ export declare function isRunWorking(state: AgentRunState | null | undefined): boolean;
24
+ export declare function isMessageTerminal(status: ChatMessageStatus | null | undefined): boolean;
25
+ /** The turn is still open: the run is working or parked on a human (approval, input, authorization). */
17
26
  export declare function isChatBusy(chat: ChatDTO | null | undefined): boolean;
27
+ /** The chat is blocked on a human: nothing more arrives until someone approves, answers or authorizes. */
28
+ export declare function isAwaitingHuman(chat: ChatDTO | null | undefined): boolean;
18
29
  /** A tool invocation gated on human approval, projected from the chat's pending interrupts. */
19
30
  export type PendingApproval = {
20
31
  interruptId: string;
package/dist/utils.js CHANGED
@@ -3,7 +3,7 @@
3
3
  * Provides future compatibility when API migrates from int to string status.
4
4
  */
5
5
  import { InterruptReasonToolApproval, InterruptStatusPending } from './types';
6
- import { TaskStatusUnknown, TaskStatusReceived, TaskStatusQueued, TaskStatusDispatched, TaskStatusPreparing, TaskStatusServing, TaskStatusSettingUp, TaskStatusRunning, TaskStatusCancelling, TaskStatusUploading, TaskStatusCompleted, TaskStatusFailed, TaskStatusCancelled, AgentRunStateWorking, AgentRunStateSubmitted, AgentRunStateInputRequired, ChatStatusBusy, ChatStatusAwaitingInput, } from './types';
6
+ import { TaskStatusUnknown, TaskStatusReceived, TaskStatusQueued, TaskStatusDispatched, TaskStatusPreparing, TaskStatusServing, TaskStatusSettingUp, TaskStatusRunning, TaskStatusCancelling, TaskStatusUploading, TaskStatusCompleted, TaskStatusFailed, TaskStatusCancelled, AgentRunStateWorking, AgentRunStateSubmitted, AgentRunStateInputRequired, AgentRunStateAuthRequired, AgentRunStateCompleted, AgentRunStateFailed, AgentRunStateCanceled, AgentRunStateRejected, ChatMessageStatusReady, ChatMessageStatusFailed, ChatMessageStatusCancelled, ChatStatusBusy, ChatStatusAwaitingInput, } from './types';
7
7
  /** Map string status names to TaskStatus values (for future string-based API) */
8
8
  const STATUS_STRING_MAP = {
9
9
  unknown: TaskStatusUnknown,
@@ -44,13 +44,41 @@ export function isTerminalStatus(status) {
44
44
  const parsed = parseStatus(status);
45
45
  return parsed === TaskStatusCompleted || parsed === TaskStatusFailed || parsed === TaskStatusCancelled;
46
46
  }
47
+ // Run and message state predicates. Ports of the Go methods AgentRunState.IsTerminal/
48
+ // IsInterrupted/IsSettled and ChatMessageStatus.IsTerminal; every consumer uses these.
49
+ export function isRunTerminal(state) {
50
+ return state === AgentRunStateCompleted || state === AgentRunStateFailed || state === AgentRunStateCanceled || state === AgentRunStateRejected;
51
+ }
52
+ /** Parked on a human: a tool approval or input (input_required) or an authorization (auth_required). */
53
+ export function isRunInterrupted(state) {
54
+ return state === AgentRunStateInputRequired || state === AgentRunStateAuthRequired;
55
+ }
56
+ /** The run produces no further events this turn: terminal or interrupted. */
57
+ export function isRunSettled(state) {
58
+ return isRunTerminal(state) || isRunInterrupted(state);
59
+ }
60
+ /** The run is executing: submitted or working. */
61
+ export function isRunWorking(state) {
62
+ return state === AgentRunStateWorking || state === AgentRunStateSubmitted;
63
+ }
64
+ export function isMessageTerminal(status) {
65
+ return status === ChatMessageStatusReady || status === ChatMessageStatusFailed || status === ChatMessageStatusCancelled;
66
+ }
67
+ /** The turn is still open: the run is working or parked on a human (approval, input, authorization). */
47
68
  export function isChatBusy(chat) {
48
69
  const run = chat?.active_run;
49
70
  if (run) {
50
- return run.state === AgentRunStateWorking || run.state === AgentRunStateSubmitted || run.state === AgentRunStateInputRequired;
71
+ return isRunWorking(run.state) || isRunInterrupted(run.state);
51
72
  }
52
73
  return chat?.status === ChatStatusBusy || chat?.status === ChatStatusAwaitingInput;
53
74
  }
75
+ /** The chat is blocked on a human: nothing more arrives until someone approves, answers or authorizes. */
76
+ export function isAwaitingHuman(chat) {
77
+ const run = chat?.active_run;
78
+ if (run)
79
+ return isRunInterrupted(run.state);
80
+ return chat?.status === ChatStatusAwaitingInput;
81
+ }
54
82
  function parseApprovalMeta(interrupt) {
55
83
  const meta = interrupt.meta;
56
84
  if (!meta)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inferencesh/sdk",
3
- "version": "0.10.1",
3
+ "version": "0.11.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",