@inferencesh/sdk 0.30.0 → 0.31.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/index.d.ts CHANGED
@@ -36,8 +36,8 @@ export type { ClientTool, ClientToolHandler, ClientToolResult } from './tool-bui
36
36
  export { lifecycleHook, learningHooks } from './hook-builder.js';
37
37
  export type { LifecycleHookBuilder } from './hook-builder.js';
38
38
  export { DeltaAccumulator, createLLMDeltaAccumulator, type DeltaEvent, type FieldTags, type FieldTagsRegistry } from './delta.js';
39
- export { parseStatus, isTerminalStatus, isChatBusy, isAwaitingHuman, isRunTerminal, isRunInterrupted, isRunSettled, isRunWorking, isMessageTerminal, pendingApprovals, heldTurn, } from './utils.js';
40
- export type { PendingApproval, HeldTurn } from './utils.js';
39
+ export { parseStatus, isTerminalStatus, isChatBusy, isAwaitingHuman, isRunTerminal, isRunInterrupted, isRunSettled, isRunWorking, isMessageTerminal, pendingApprovals, heldTurn, pendingWait, } from './utils.js';
40
+ export type { PendingApproval, HeldTurn, PendingWait } from './utils.js';
41
41
  export * from './types.js';
42
42
  export type { TaskDTO as Task } from './types.js';
43
43
  import { HttpClient, type HttpClientConfig } from './http/client.js';
package/dist/index.js CHANGED
@@ -38,7 +38,7 @@ export { lifecycleHook, learningHooks } from './hook-builder.js';
38
38
  // Delta accumulator for streaming responses
39
39
  export { DeltaAccumulator, createLLMDeltaAccumulator } from './delta.js';
40
40
  // Status utilities (handle both int and string status values)
41
- export { parseStatus, isTerminalStatus, isChatBusy, isAwaitingHuman, isRunTerminal, isRunInterrupted, isRunSettled, isRunWorking, isMessageTerminal, pendingApprovals, heldTurn, } from './utils.js';
41
+ export { parseStatus, isTerminalStatus, isChatBusy, isAwaitingHuman, isRunTerminal, isRunInterrupted, isRunSettled, isRunWorking, isMessageTerminal, pendingApprovals, heldTurn, pendingWait, } from './utils.js';
42
42
  // Types - includes TaskStatus constants and all DTOs
43
43
  export * from './types.js';
44
44
  // =============================================================================
package/dist/types.d.ts CHANGED
@@ -17,6 +17,7 @@ export interface InternalToolsConfig {
17
17
  agent?: boolean;
18
18
  remote?: boolean;
19
19
  knowledge?: boolean;
20
+ wait?: boolean;
20
21
  }
21
22
  /**
22
23
  * AgentPermissions is what an agent's new chats in its own workspace may do
@@ -43,6 +44,11 @@ export interface AgentTool {
43
44
  description: string;
44
45
  type: ToolType;
45
46
  require_approval?: boolean;
47
+ /**
48
+ * ApprovalTimeout is how many seconds a call of this tool waits for its
49
+ * approval before it is refused. 0 waits until someone answers.
50
+ */
51
+ approval_timeout?: number;
46
52
  app?: AppToolConfig;
47
53
  agent?: AgentToolConfig;
48
54
  hook?: HookToolConfig;
@@ -97,6 +103,7 @@ export interface AgentToolDTO {
97
103
  description: string;
98
104
  type: ToolType;
99
105
  require_approval?: boolean;
106
+ approval_timeout?: number;
100
107
  app?: AppToolConfigDTO;
101
108
  agent?: AgentToolConfigDTO;
102
109
  hook?: HookToolConfigDTO;
@@ -6711,6 +6718,13 @@ export declare const GraphEdgeTypeOutput: GraphEdgeType;
6711
6718
  * allow starts the turn, a deny ends the run.
6712
6719
  */
6713
6720
  export declare const InterruptResourceTurn: InterruptResourceType;
6721
+ /**
6722
+ * InterruptReasonWait is a tool call the agent made to wait: the run is
6723
+ * paused until the interrupt's deadline, when its own expiry trigger settles
6724
+ * it (allow), or until a person ends the wait sooner. Its resource is the
6725
+ * wait call (InterruptResourceToolInvocation).
6726
+ */
6727
+ export declare const InterruptReasonWait: InterruptReason;
6714
6728
  /**
6715
6729
  * MergeStrategy defines how a delta field should be merged by consumers.
6716
6730
  */
@@ -7841,7 +7855,7 @@ export declare const AgentRunStateRejected: AgentRunState;
7841
7855
  * InterruptReason describes why an agent run is in an interrupted state.
7842
7856
  * Aligns with AG-UI interrupt outcome reasons.
7843
7857
  */
7844
- export type InterruptReason = "tool_approval" | "client_tool" | "widget" | "auth" | "confirmation" | "hook_gate";
7858
+ export type InterruptReason = "wait" | "tool_approval" | "client_tool" | "widget" | "auth" | "confirmation" | "hook_gate";
7845
7859
  export declare const InterruptReasonToolApproval: InterruptReason;
7846
7860
  export declare const InterruptReasonClientTool: InterruptReason;
7847
7861
  export declare const InterruptReasonWidget: InterruptReason;
package/dist/types.js CHANGED
@@ -992,6 +992,13 @@ export const GraphEdgeTypeOutput = "output";
992
992
  * allow starts the turn, a deny ends the run.
993
993
  */
994
994
  export const InterruptResourceTurn = "turn";
995
+ /**
996
+ * InterruptReasonWait is a tool call the agent made to wait: the run is
997
+ * paused until the interrupt's deadline, when its own expiry trigger settles
998
+ * it (allow), or until a person ends the wait sooner. Its resource is the
999
+ * wait call (InterruptResourceToolInvocation).
1000
+ */
1001
+ export const InterruptReasonWait = "wait";
995
1002
  export const MergeStrategyConcat = "concat";
996
1003
  export const MergeStrategyReplace = "replace";
997
1004
  export const MergeStrategyIndexed = "indexed";
package/dist/utils.d.ts CHANGED
@@ -49,3 +49,14 @@ export type HeldTurn = {
49
49
  };
50
50
  /** The held turn among a run's pending interrupts, if one is held. */
51
51
  export declare function heldTurn(interrupts: InterruptDTO[] | null | undefined): HeldTurn | null;
52
+ /** A run paused by its agent's wait tool (InterruptReasonWait): it continues at `until`, or sooner when the person ends the wait ("continue now", allow) or cancels it (deny). */
53
+ export type PendingWait = {
54
+ interruptId: string;
55
+ runId: string;
56
+ /** When the wait ends, RFC3339; null when the api gives no deadline. */
57
+ until: string | null;
58
+ /** What the agent said it will do when the wait ends. */
59
+ note: string;
60
+ };
61
+ /** The wait among a run's pending interrupts, if the run is waiting. */
62
+ export declare function pendingWait(interrupts: InterruptDTO[] | null | undefined): PendingWait | null;
package/dist/utils.js CHANGED
@@ -2,7 +2,7 @@
2
2
  * Status utilities for handling both int and string-based status values.
3
3
  * Provides future compatibility when API migrates from int to string status.
4
4
  */
5
- import { InterruptReasonToolApproval, InterruptResourceTurn, InterruptStatusPending } from './types.js';
5
+ import { InterruptReasonToolApproval, InterruptReasonWait, InterruptResourceTurn, InterruptStatusPending } from './types.js';
6
6
  import { TaskStatusUnknown, TaskStatusReceived, TaskStatusQueued, TaskStatusDispatched, TaskStatusPreparing, TaskStatusServing, TaskStatusSettingUp, TaskStatusRunning, TaskStatusCancelling, TaskStatusUploading, TaskStatusCompleted, TaskStatusFailed, TaskStatusCancelled, TaskStatusRejected, AgentRunStateWorking, AgentRunStateSubmitted, AgentRunStateInputRequired, AgentRunStateAuthRequired, AgentRunStateCompleted, AgentRunStateFailed, AgentRunStateCanceled, AgentRunStateRejected, ChatMessageStatusReady, ChatMessageStatusFailed, ChatMessageStatusCancelled, ChatStatusBusy, ChatStatusAwaitingInput, } from './types.js';
7
7
  /** Map string status names to TaskStatus values (for future string-based API) */
8
8
  const STATUS_STRING_MAP = {
@@ -117,11 +117,23 @@ export function pendingApprovals(chat) {
117
117
  }
118
118
  return out;
119
119
  }
120
+ /** The first pending interrupt among a run's that matches. */
121
+ function pendingInterrupt(interrupts, match) {
122
+ return interrupts?.find(i => i.status === InterruptStatusPending && match(i));
123
+ }
120
124
  /** The held turn among a run's pending interrupts, if one is held. */
121
125
  export function heldTurn(interrupts) {
122
- const interrupt = interrupts?.find(i => i.resource_type === InterruptResourceTurn && i.status === InterruptStatusPending);
126
+ const interrupt = pendingInterrupt(interrupts, i => i.resource_type === InterruptResourceTurn);
123
127
  if (!interrupt)
124
128
  return null;
125
129
  const { steps } = parseMeta(interrupt);
126
130
  return { interruptId: interrupt.id, runId: interrupt.run_id, steps: typeof steps === 'number' ? steps : null };
127
131
  }
132
+ /** The wait among a run's pending interrupts, if the run is waiting. */
133
+ export function pendingWait(interrupts) {
134
+ const interrupt = pendingInterrupt(interrupts, i => i.reason === InterruptReasonWait);
135
+ if (!interrupt)
136
+ return null;
137
+ const { note } = parseMeta(interrupt);
138
+ return { interruptId: interrupt.id, runId: interrupt.run_id, until: interrupt.expires_at ?? null, note: typeof note === 'string' ? note : '' };
139
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inferencesh/sdk",
3
- "version": "0.30.0",
3
+ "version": "0.31.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",