@inferencesh/sdk 0.29.1 → 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/CHANGELOG.md +5 -0
- package/README.md +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/tool-builder.d.ts +6 -16
- package/dist/tool-builder.js +7 -16
- package/dist/types.d.ts +17 -8
- package/dist/types.js +7 -0
- package/dist/utils.d.ts +11 -0
- package/dist/utils.js +14 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.30.0] - 2026-10-18
|
|
11
|
+
|
|
12
|
+
### Removed
|
|
13
|
+
- `credentialId` on `httpTool().auth()` and `mcpTool()`, and the positional `mcpTool(name, credentialId, toolName)`: a tool no longer pins a connection. Credential-auth HTTP tools and MCP tools always sign in with the caller's own login to the provider at run time; `mcpTool(name, { server, toolName })` requires `server` (INF-1012). Generated types: `ToolAuthConfig`, `MCPToolConfig` and `MCPToolConfigDTO` lose `credential_id`.
|
|
14
|
+
|
|
10
15
|
## [0.29.0] - 2026-10-17
|
|
11
16
|
|
|
12
17
|
### Removed
|
package/README.md
CHANGED
|
@@ -377,7 +377,7 @@ Use the fluent builders to define `AgentTool` schemas. Client tools (`tool`) run
|
|
|
377
377
|
| `agentTool(name, agentRef)` | Server | Delegate to a sub-agent |
|
|
378
378
|
| `httpTool(name, url)` / `callTool(name, url)` | Server | HTTP request with credential injection (preferred over `webhookTool`) |
|
|
379
379
|
| `webhookTool(name, url)` | Server | Unsigned webhook (legacy; use `httpTool` for new tools) |
|
|
380
|
-
| `mcpTool(name, { server, toolName
|
|
380
|
+
| `mcpTool(name, { server, toolName })` | Server | Call a tool on an MCP server (by slug), signed in with the runner's own connection to the server's provider |
|
|
381
381
|
| `internalTools()` | Server | Built-in tools: plan, memory, widget, finish, skills, meta, remote, knowledge, artifact, agent |
|
|
382
382
|
|
|
383
383
|
```typescript
|
|
@@ -401,7 +401,7 @@ const clientTool = tool('get_weather')
|
|
|
401
401
|
const gmailSend = httpTool('gmail_send', 'https://gmail.googleapis.com/gmail/v1/users/me/messages/send')
|
|
402
402
|
.describe('Send an email via Gmail')
|
|
403
403
|
.method('POST')
|
|
404
|
-
.auth({ credential: CredentialProviderGoogle
|
|
404
|
+
.auth({ credential: CredentialProviderGoogle })
|
|
405
405
|
.build();
|
|
406
406
|
|
|
407
407
|
// API key or bearer auth
|
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/tool-builder.d.ts
CHANGED
|
@@ -100,13 +100,12 @@ declare class HTTPToolBuilder extends ToolBuilder {
|
|
|
100
100
|
constructor(name: string, url: string);
|
|
101
101
|
method(m: string): this;
|
|
102
102
|
/**
|
|
103
|
-
* How the tool authenticates: `credential` sends
|
|
104
|
-
*
|
|
105
|
-
*
|
|
103
|
+
* How the tool authenticates: `credential` sends the access token of the
|
|
104
|
+
* runner's own connection to that provider, `apiKey` / `bearer` send a
|
|
105
|
+
* vault secret.
|
|
106
106
|
*/
|
|
107
107
|
auth(config: {
|
|
108
108
|
credential?: string;
|
|
109
|
-
credentialId?: string;
|
|
110
109
|
apiKey?: string;
|
|
111
110
|
bearer?: string;
|
|
112
111
|
header?: string;
|
|
@@ -131,24 +130,15 @@ export interface MCPToolTarget {
|
|
|
131
130
|
/** The MCP server's slug (a workspace registration or a directory entry). */
|
|
132
131
|
server: string;
|
|
133
132
|
toolName: string;
|
|
134
|
-
/** Pins one connection to the server's provider; by default the runner's own is used. */
|
|
135
|
-
credentialId?: string;
|
|
136
133
|
}
|
|
137
134
|
/**
|
|
138
135
|
* Create an MCP tool: `toolName` on the MCP server `target.server` (its slug).
|
|
139
|
-
* The call signs in with the runner's connection to the server's provider
|
|
140
|
-
* `credentialId` pins one connection instead.
|
|
141
|
-
*
|
|
142
|
-
* The older form `mcpTool(name, credentialId, toolName)` (a string second
|
|
143
|
-
* argument) still works: a tool naming only a connection is saved with the
|
|
144
|
-
* server that connection's provider is declared by.
|
|
136
|
+
* The call signs in with the runner's own connection to the server's provider.
|
|
145
137
|
*/
|
|
146
|
-
export declare function mcpTool(name: string, target: MCPToolTarget
|
|
138
|
+
export declare function mcpTool(name: string, target: MCPToolTarget): MCPToolBuilder;
|
|
147
139
|
declare class MCPToolBuilder extends ToolBuilder {
|
|
148
140
|
private target;
|
|
149
|
-
constructor(name: string, target:
|
|
150
|
-
toolName: string;
|
|
151
|
-
});
|
|
141
|
+
constructor(name: string, target: MCPToolTarget);
|
|
152
142
|
build(): AgentTool;
|
|
153
143
|
}
|
|
154
144
|
declare class InternalToolsBuilder {
|
package/dist/tool-builder.js
CHANGED
|
@@ -184,13 +184,13 @@ class HTTPToolBuilder extends ToolBuilder {
|
|
|
184
184
|
return this;
|
|
185
185
|
}
|
|
186
186
|
/**
|
|
187
|
-
* How the tool authenticates: `credential` sends
|
|
188
|
-
*
|
|
189
|
-
*
|
|
187
|
+
* How the tool authenticates: `credential` sends the access token of the
|
|
188
|
+
* runner's own connection to that provider, `apiKey` / `bearer` send a
|
|
189
|
+
* vault secret.
|
|
190
190
|
*/
|
|
191
191
|
auth(config) {
|
|
192
192
|
if (config.credential) {
|
|
193
|
-
this.authConfig = { type: ToolAuthTypeCredential, provider: config.credential
|
|
193
|
+
this.authConfig = { type: ToolAuthTypeCredential, provider: config.credential };
|
|
194
194
|
}
|
|
195
195
|
else if (config.apiKey) {
|
|
196
196
|
this.authConfig = { type: ToolAuthTypeAPIKey, secret: config.apiKey, header: config.header || 'X-API-Key' };
|
|
@@ -238,17 +238,9 @@ export const httpTool = (name, url) => new HTTPToolBuilder(name, url);
|
|
|
238
238
|
export const callTool = (name, url) => new HTTPToolBuilder(name, url);
|
|
239
239
|
/**
|
|
240
240
|
* Create an MCP tool: `toolName` on the MCP server `target.server` (its slug).
|
|
241
|
-
* The call signs in with the runner's connection to the server's provider
|
|
242
|
-
* `credentialId` pins one connection instead.
|
|
243
|
-
*
|
|
244
|
-
* The older form `mcpTool(name, credentialId, toolName)` (a string second
|
|
245
|
-
* argument) still works: a tool naming only a connection is saved with the
|
|
246
|
-
* server that connection's provider is declared by.
|
|
241
|
+
* The call signs in with the runner's own connection to the server's provider.
|
|
247
242
|
*/
|
|
248
|
-
export function mcpTool(name, target
|
|
249
|
-
if (typeof target === 'string') {
|
|
250
|
-
return new MCPToolBuilder(name, { toolName: toolName ?? '', credentialId: target });
|
|
251
|
-
}
|
|
243
|
+
export function mcpTool(name, target) {
|
|
252
244
|
return new MCPToolBuilder(name, target);
|
|
253
245
|
}
|
|
254
246
|
class MCPToolBuilder extends ToolBuilder {
|
|
@@ -264,9 +256,8 @@ class MCPToolBuilder extends ToolBuilder {
|
|
|
264
256
|
type: ToolTypeMCP,
|
|
265
257
|
require_approval: this.approval || undefined,
|
|
266
258
|
mcp: {
|
|
259
|
+
server: this.target.server,
|
|
267
260
|
tool_name: this.target.toolName,
|
|
268
|
-
...(this.target.server ? { server: this.target.server } : {}),
|
|
269
|
-
...(this.target.credentialId ? { credential_id: this.target.credentialId } : {}),
|
|
270
261
|
},
|
|
271
262
|
};
|
|
272
263
|
}
|
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;
|
|
@@ -172,7 +179,6 @@ export declare const ToolAuthTypeBearer: ToolAuthType;
|
|
|
172
179
|
export interface ToolAuthConfig {
|
|
173
180
|
type: ToolAuthType;
|
|
174
181
|
provider?: string;
|
|
175
|
-
credential_id?: string;
|
|
176
182
|
secret?: string;
|
|
177
183
|
header?: string;
|
|
178
184
|
}
|
|
@@ -203,15 +209,12 @@ export interface HTTPToolConfig {
|
|
|
203
209
|
/**
|
|
204
210
|
* MCPToolConfig is a tool of an MCP server: the server by its slug (the
|
|
205
211
|
* agent's team's registration, its org's or the directory's) and the tool
|
|
206
|
-
* to call.
|
|
207
|
-
*
|
|
208
|
-
* written with only a connection is saved with the server that
|
|
209
|
-
* connection's provider is declared by.
|
|
212
|
+
* to call. Each call signs in with the runner's connection to the
|
|
213
|
+
* server's provider (Credential.ToolConnection).
|
|
210
214
|
*/
|
|
211
215
|
export interface MCPToolConfig {
|
|
212
216
|
server?: string;
|
|
213
217
|
tool_name: string;
|
|
214
|
-
credential_id?: string;
|
|
215
218
|
}
|
|
216
219
|
export interface AppToolConfigDTO {
|
|
217
220
|
ref: string;
|
|
@@ -264,7 +267,6 @@ export interface HTTPToolConfigDTO {
|
|
|
264
267
|
export interface MCPToolConfigDTO {
|
|
265
268
|
server: string;
|
|
266
269
|
tool_name: string;
|
|
267
|
-
credential_id?: string;
|
|
268
270
|
}
|
|
269
271
|
/**
|
|
270
272
|
* CoreAppConfigDTO references an app used as the agent's core
|
|
@@ -6716,6 +6718,13 @@ export declare const GraphEdgeTypeOutput: GraphEdgeType;
|
|
|
6716
6718
|
* allow starts the turn, a deny ends the run.
|
|
6717
6719
|
*/
|
|
6718
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;
|
|
6719
6728
|
/**
|
|
6720
6729
|
* MergeStrategy defines how a delta field should be merged by consumers.
|
|
6721
6730
|
*/
|
|
@@ -7846,7 +7855,7 @@ export declare const AgentRunStateRejected: AgentRunState;
|
|
|
7846
7855
|
* InterruptReason describes why an agent run is in an interrupted state.
|
|
7847
7856
|
* Aligns with AG-UI interrupt outcome reasons.
|
|
7848
7857
|
*/
|
|
7849
|
-
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";
|
|
7850
7859
|
export declare const InterruptReasonToolApproval: InterruptReason;
|
|
7851
7860
|
export declare const InterruptReasonClientTool: InterruptReason;
|
|
7852
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
|
|
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
|
+
}
|