@inferencesh/sdk 0.14.0 → 0.14.2

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,30 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.14.2] - 2026-10-01
11
+
12
+ ### Added
13
+
14
+ - Instance types: `InstanceRentalType` (`on_demand`, `spot`), `rental_type` on availability and engine-picker offers, `hourly_price` on spot entries.
15
+ - `lifecycleHook(event).builtin(name)` for hooks the platform runs itself.
16
+ - `learningHooks({ suggest, learn })`: `suggest` adds the team's matching skills, knowledge and apps to context before each turn (`belt:suggest`); `learn` saves reusable knowledge from the conversation to the team's registry every 10th user turn and before compaction (`belt:extract`). Both are off unless set.
17
+ - `BuiltinHookBeltExtract`.
18
+
19
+ ## [0.14.1] - 2026-10-01
20
+
21
+ ### Added
22
+
23
+ - `internalTools()` builder methods for every category: `knowledge()` (search, read, save and delete skills and knowledge entries), `agent()` (run a copy of the agent on a side task), `skills()`, `artifact()` and `remote()`.
24
+ - `InternalToolsConfig.knowledge` and `InternalToolsConfig.agent`.
25
+
26
+ ### Changed
27
+
28
+ - `InternalToolsConfig.spawn` is now `agent`. The API still reads a stored or sent `spawn` as `agent`.
29
+
30
+ ### Deprecated
31
+
32
+ - `InternalToolsConfig.host_context`: the API ignores it and no longer offers `get_host_context` or `send_to_host`.
33
+
10
34
  ## [0.14.0] - 2026-09-27
11
35
 
12
36
  ### Fixed
package/README.md CHANGED
@@ -378,7 +378,7 @@ Use the fluent builders to define `AgentTool` schemas. Client tools (`tool`) run
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
380
  | `mcpTool(name, credentialId, toolName)` | Server | Call a tool through a connected MCP credential |
381
- | `internalTools()` | Server | Built-in plan, memory, and widget tools |
381
+ | `internalTools()` | Server | Built-in tools: plan, memory, widget, finish, skills, meta, remote, knowledge, artifact, agent |
382
382
 
383
383
  ```typescript
384
384
  import {
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Hook Builder - Fluent API for defining lifecycle hooks
3
3
  */
4
- import { LifecycleHookConfig, HookEvent } from './types';
4
+ import { LifecycleHookConfig, HookEvent, BuiltinHook } from './types';
5
5
  export declare class LifecycleHookBuilder {
6
6
  private event;
7
7
  private handlerType;
@@ -13,6 +13,8 @@ export declare class LifecycleHookBuilder {
13
13
  webhook(url: string): this;
14
14
  /** Set handler to a task (agent ref) */
15
15
  task(agentRef: string): this;
16
+ /** Set handler to a builtin the platform runs itself (e.g. belt:suggest) */
17
+ builtin(name: BuiltinHook): this;
16
18
  /** Set async execution */
17
19
  async(enabled: boolean): this;
18
20
  /** Set handler timeout in seconds */
@@ -21,3 +23,14 @@ export declare class LifecycleHookBuilder {
21
23
  }
22
24
  /** Create a lifecycle hook for an agent event */
23
25
  export declare const lifecycleHook: (event: HookEvent) => LifecycleHookBuilder;
26
+ /**
27
+ * The built-in learning hooks, attached to the events each one runs on.
28
+ * - `suggest`: before each turn, add the team's matching skills, knowledge and apps to context.
29
+ * - `learn`: every 10th user turn and before compaction, save reusable knowledge from the
30
+ * conversation to the team's registry, deduplicated. Runs on the agent's own model, and only
31
+ * for chats by the agent's owning team.
32
+ */
33
+ export declare function learningHooks(opts: {
34
+ suggest?: boolean;
35
+ learn?: boolean;
36
+ }): LifecycleHookConfig[];
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Hook Builder - Fluent API for defining lifecycle hooks
3
3
  */
4
- import { HookHandlerWebhook, HookHandlerTask } from './types';
4
+ import { HookHandlerWebhook, HookHandlerTask, HookHandlerBuiltin, BuiltinHookBeltSuggest, BuiltinHookBeltExtract, HookEventTurnStart, HookEventAgentComplete, HookEventPreCompact, } from './types';
5
5
  // =============================================================================
6
6
  // Hook Builder
7
7
  // =============================================================================
@@ -23,6 +23,12 @@ export class LifecycleHookBuilder {
23
23
  this.handlerRef = agentRef;
24
24
  return this;
25
25
  }
26
+ /** Set handler to a builtin the platform runs itself (e.g. belt:suggest) */
27
+ builtin(name) {
28
+ this.handlerType = HookHandlerBuiltin;
29
+ this.handlerRef = name;
30
+ return this;
31
+ }
26
32
  /** Set async execution */
27
33
  async(enabled) {
28
34
  this.isAsync = enabled;
@@ -48,3 +54,22 @@ export class LifecycleHookBuilder {
48
54
  // =============================================================================
49
55
  /** Create a lifecycle hook for an agent event */
50
56
  export const lifecycleHook = (event) => new LifecycleHookBuilder(event);
57
+ /**
58
+ * The built-in learning hooks, attached to the events each one runs on.
59
+ * - `suggest`: before each turn, add the team's matching skills, knowledge and apps to context.
60
+ * - `learn`: every 10th user turn and before compaction, save reusable knowledge from the
61
+ * conversation to the team's registry, deduplicated. Runs on the agent's own model, and only
62
+ * for chats by the agent's owning team.
63
+ */
64
+ export function learningHooks(opts) {
65
+ const hooks = [];
66
+ if (opts.suggest) {
67
+ hooks.push(lifecycleHook(HookEventTurnStart).builtin(BuiltinHookBeltSuggest).build());
68
+ }
69
+ if (opts.learn) {
70
+ for (const event of [HookEventAgentComplete, HookEventPreCompact]) {
71
+ hooks.push(lifecycleHook(event).builtin(BuiltinHookBeltExtract).build());
72
+ }
73
+ }
74
+ return hooks;
75
+ }
package/dist/index.d.ts CHANGED
@@ -31,7 +31,7 @@ export { isLiveField, parseMediaType, pcmFormat, splitLiveSchema, binaryLiveFiel
31
31
  export type { JsonSchema, MediaType, PCMFormat, LiveField } from './live/schema';
32
32
  export { tool, appTool, agentTool, webhookTool, httpTool, callTool, mcpTool, internalTools, string, number, integer, boolean, enumOf, object, array, optional, } from './tool-builder';
33
33
  export type { ClientTool, ClientToolHandler } from './tool-builder';
34
- export { lifecycleHook } from './hook-builder';
34
+ export { lifecycleHook, learningHooks } from './hook-builder';
35
35
  export type { LifecycleHookBuilder } from './hook-builder';
36
36
  export { DeltaAccumulator, createLLMDeltaAccumulator, type DeltaEvent, type FieldTags, type FieldTagsRegistry } from './delta';
37
37
  export { parseStatus, isTerminalStatus, isChatBusy, isAwaitingHuman, isRunTerminal, isRunInterrupted, isRunSettled, isRunWorking, isMessageTerminal, pendingApprovals, } from './utils';
package/dist/index.js CHANGED
@@ -33,7 +33,7 @@ export { isLiveField, parseMediaType, pcmFormat, splitLiveSchema, binaryLiveFiel
33
33
  // Tool Builder (fluent API)
34
34
  export { tool, appTool, agentTool, webhookTool, httpTool, callTool, mcpTool, internalTools, string, number, integer, boolean, enumOf, object, array, optional, } from './tool-builder';
35
35
  // Hook Builder (fluent API)
36
- export { lifecycleHook } from './hook-builder';
36
+ export { lifecycleHook, learningHooks } from './hook-builder';
37
37
  // Delta accumulator for streaming responses
38
38
  export { DeltaAccumulator, createLLMDeltaAccumulator } from './delta';
39
39
  // Status utilities (handle both int and string status values)
@@ -136,6 +136,14 @@ declare class InternalToolsBuilder {
136
136
  meta(enabled?: boolean): this;
137
137
  /** Enable remote tools (run commands on the user's connected remotes) */
138
138
  remote(enabled?: boolean): this;
139
+ /** Enable knowledge tools (search, read and save the user's skills and knowledge entries) */
140
+ knowledge(enabled?: boolean): this;
141
+ /** Enable skill_get for the skills configured on the agent (on by default) */
142
+ skills(enabled?: boolean): this;
143
+ /** Enable artifact tools (publish shareable HTML/Markdown pages) */
144
+ artifact(enabled?: boolean): this;
145
+ /** Enable the agent tool (run a copy of this agent on a side task) */
146
+ agent(enabled?: boolean): this;
139
147
  /** Enable all internal tools */
140
148
  all(): this;
141
149
  /** Disable all internal tools */
@@ -293,6 +293,26 @@ class InternalToolsBuilder {
293
293
  this.config.remote = enabled;
294
294
  return this;
295
295
  }
296
+ /** Enable knowledge tools (search, read and save the user's skills and knowledge entries) */
297
+ knowledge(enabled = true) {
298
+ this.config.knowledge = enabled;
299
+ return this;
300
+ }
301
+ /** Enable skill_get for the skills configured on the agent (on by default) */
302
+ skills(enabled = true) {
303
+ this.config.skills = enabled;
304
+ return this;
305
+ }
306
+ /** Enable artifact tools (publish shareable HTML/Markdown pages) */
307
+ artifact(enabled = true) {
308
+ this.config.artifact = enabled;
309
+ return this;
310
+ }
311
+ /** Enable the agent tool (run a copy of this agent on a side task) */
312
+ agent(enabled = true) {
313
+ this.config.agent = enabled;
314
+ return this;
315
+ }
296
316
  /** Enable all internal tools */
297
317
  all() {
298
318
  this.config.plan = true;
package/dist/types.d.ts CHANGED
@@ -7,11 +7,16 @@ export interface InternalToolsConfig {
7
7
  widget?: boolean;
8
8
  finish?: boolean;
9
9
  skills?: boolean;
10
+ /**
11
+ * Deprecated: ignored. Host context is disabled until embed context has a
12
+ * replacement; agents are never offered get_host_context or send_to_host.
13
+ */
10
14
  host_context?: boolean;
11
15
  meta?: boolean;
12
16
  artifact?: boolean;
13
- spawn?: boolean;
17
+ agent?: boolean;
14
18
  remote?: boolean;
19
+ knowledge?: boolean;
15
20
  }
16
21
  /**
17
22
  * AgentTool represents a unified tool that can be used by an agent
@@ -84,6 +89,13 @@ export interface AppToolConfig {
84
89
  session_enabled?: boolean;
85
90
  setup?: any;
86
91
  input?: any;
92
+ /**
93
+ * FixedInput pins arguments: they are merged over whatever the model sent,
94
+ * and removed from the tool schema the model is shown, so it neither sees
95
+ * nor controls them. Input only supplies defaults the model may override;
96
+ * this is for values an operator decides, not the model.
97
+ */
98
+ fixed_input?: any;
87
99
  }
88
100
  export interface AgentToolConfig {
89
101
  ref: string;
@@ -153,6 +165,7 @@ export interface AppToolConfigDTO {
153
165
  session_enabled?: boolean;
154
166
  setup?: any;
155
167
  input?: any;
168
+ fixed_input?: any;
156
169
  }
157
170
  export interface AgentToolConfigDTO {
158
171
  ref: string;
@@ -2489,6 +2502,7 @@ export interface InstanceDTO extends BaseModelDTO, PermissionModelDTO {
2489
2502
  status: InstanceStatus;
2490
2503
  cost_estimate: string;
2491
2504
  hourly_price: number;
2505
+ rental_type?: InstanceRentalType;
2492
2506
  template_id?: string;
2493
2507
  volume_ids?: string[];
2494
2508
  tags?: string[];
@@ -2510,6 +2524,11 @@ export interface InstanceTypeDTO extends BaseModelDTO, PermissionModelDTO {
2510
2524
  cloud_instance_type: string;
2511
2525
  deployment_type: InstanceTypeDeploymentType;
2512
2526
  hourly_price: number;
2527
+ /**
2528
+ * RentalType is set on engine-picker offers: Region and HourlyPrice are
2529
+ * for this rental type. Empty on the raw catalog.
2530
+ */
2531
+ rental_type?: InstanceRentalType;
2513
2532
  configuration?: InstanceTypeConfiguration;
2514
2533
  availability: InstanceTypeAvailability[];
2515
2534
  boot_time?: InstanceTypeBootTime;
@@ -2529,6 +2548,11 @@ export interface InstanceTypeConfiguration {
2529
2548
  export interface InstanceTypeAvailability {
2530
2549
  available: boolean;
2531
2550
  region: string;
2551
+ rental_type?: InstanceRentalType;
2552
+ /**
2553
+ * HourlyPrice is the spot price in cents, set on spot entries only.
2554
+ */
2555
+ hourly_price?: number;
2532
2556
  }
2533
2557
  export interface InstanceTypeBootTime {
2534
2558
  average_seconds: number;
@@ -2960,10 +2984,6 @@ export interface OrgDTO extends BaseModelDTO {
2960
2984
  name: string;
2961
2985
  avatar_url?: string;
2962
2986
  default_team_id?: string;
2963
- /**
2964
- * UsagePolicyID of the org's usage policy ('' = ungoverned, INF-808).
2965
- */
2966
- usage_policy_id?: string;
2967
2987
  /**
2968
2988
  * IsAdmin: whether the CALLER is on this org's admin grant list. Set on
2969
2989
  * caller-scoped responses.
@@ -4268,7 +4288,7 @@ export declare const PlanStepStatusPending: PlanStepStatus;
4268
4288
  export declare const PlanStepStatusInProgress: PlanStepStatus;
4269
4289
  export declare const PlanStepStatusCompleted: PlanStepStatus;
4270
4290
  export declare const PlanStepStatusCancelled: PlanStepStatus;
4271
- export type ChatMessageRole = "system" | "user" | "assistant" | "tool" | "injection" | "compaction";
4291
+ export type ChatMessageRole = "system" | "user" | "assistant" | "tool" | "injection" | "compaction" | "event";
4272
4292
  /**
4273
4293
  * LLM wire-protocol roles
4274
4294
  */
@@ -4279,22 +4299,25 @@ export declare const ChatMessageRoleTool: ChatMessageRole;
4279
4299
  /**
4280
4300
  * Internal bookkeeping roles — never sent to the LLM provider.
4281
4301
  * BuildContext folds injections into the user turn and replaces
4282
- * compaction markers with their summary.
4302
+ * compaction markers with their summary. Event messages are display-only
4303
+ * system info (a hook ran, ...) and BuildContext skips them.
4283
4304
  */
4284
4305
  export declare const ChatMessageRoleInjection: ChatMessageRole;
4285
4306
  export declare const ChatMessageRoleCompaction: ChatMessageRole;
4307
+ export declare const ChatMessageRoleEvent: ChatMessageRole;
4286
4308
  export type ChatMessageStatus = "pending" | "queued" | "ready" | "failed" | "cancelled";
4287
4309
  export declare const ChatMessageStatusPending: ChatMessageStatus;
4288
4310
  export declare const ChatMessageStatusQueued: ChatMessageStatus;
4289
4311
  export declare const ChatMessageStatusReady: ChatMessageStatus;
4290
4312
  export declare const ChatMessageStatusFailed: ChatMessageStatus;
4291
4313
  export declare const ChatMessageStatusCancelled: ChatMessageStatus;
4292
- export type ChatMessageContentType = "text" | "reasoning" | "image" | "file" | "tool";
4314
+ export type ChatMessageContentType = "text" | "reasoning" | "image" | "file" | "tool" | "event";
4293
4315
  export declare const ChatMessageContentTypeText: ChatMessageContentType;
4294
4316
  export declare const ChatMessageContentTypeReasoning: ChatMessageContentType;
4295
4317
  export declare const ChatMessageContentTypeImage: ChatMessageContentType;
4296
4318
  export declare const ChatMessageContentTypeFile: ChatMessageContentType;
4297
4319
  export declare const ChatMessageContentTypeTool: ChatMessageContentType;
4320
+ export declare const ChatMessageContentTypeEvent: ChatMessageContentType;
4298
4321
  export type ChannelType = "slack" | "discord" | "teams" | "telegram";
4299
4322
  export declare const ChannelTypeSlack: ChannelType;
4300
4323
  export declare const ChannelTypeDiscord: ChannelType;
@@ -4328,6 +4351,34 @@ export interface ChatMessageContent {
4328
4351
  image?: string;
4329
4352
  file?: string;
4330
4353
  tool_calls?: ToolCall[];
4354
+ event?: ChatEvent;
4355
+ }
4356
+ export type ChatEventType = "hook";
4357
+ export declare const ChatEventTypeHook: ChatEventType;
4358
+ /**
4359
+ * ChatEvent is the payload of an event-role message: system info shown in the
4360
+ * chat but never sent to the model.
4361
+ */
4362
+ export interface ChatEvent {
4363
+ type: ChatEventType;
4364
+ hook?: ChatHookEvent;
4365
+ }
4366
+ /**
4367
+ * ChatHookEvent records one lifecycle hook handler run.
4368
+ */
4369
+ export interface ChatHookEvent {
4370
+ event: HookEvent;
4371
+ handler_type: HookHandlerType;
4372
+ /**
4373
+ * Handler names what ran: the builtin or agent ref, or a webhook's host
4374
+ * (never its full URL, which can carry credentials).
4375
+ */
4376
+ handler: string;
4377
+ decision?: HookDecision;
4378
+ reason?: string;
4379
+ injected?: boolean;
4380
+ error?: string;
4381
+ duration_ms: number;
4331
4382
  }
4332
4383
  /**
4333
4384
  * ChannelContext records which channel a chat or message came through
@@ -4749,6 +4800,13 @@ export type InstanceTypeDeploymentType = "vm" | "container" | "baremetal";
4749
4800
  export declare const InstanceTypeDeploymentTypeVM: InstanceTypeDeploymentType;
4750
4801
  export declare const InstanceTypeDeploymentTypeContainer: InstanceTypeDeploymentType;
4751
4802
  export declare const InstanceTypeDeploymentTypeBaremetal: InstanceTypeDeploymentType;
4803
+ /**
4804
+ * InstanceRentalType is how a Shadeform instance is rented. Spot is discounted
4805
+ * but can be reclaimed at any time.
4806
+ */
4807
+ export type InstanceRentalType = "on_demand" | "spot";
4808
+ export declare const InstanceRentalTypeOnDemand: InstanceRentalType;
4809
+ export declare const InstanceRentalTypeSpot: InstanceRentalType;
4752
4810
  export type AppSessionStatus = "active" | "ended" | "expired";
4753
4811
  export declare const AppSessionStatusActive: AppSessionStatus;
4754
4812
  export declare const AppSessionStatusEnded: AppSessionStatus;
@@ -5543,8 +5601,21 @@ export declare const HookHandlerBuiltin: HookHandlerType;
5543
5601
  * agent config is validated against it, and clients enumerate it to show what
5544
5602
  * an agent can switch on without hosting anything.
5545
5603
  */
5546
- export type BuiltinHook = "belt:suggest";
5604
+ export type BuiltinHook = "belt:suggest" | "belt:extract";
5605
+ /**
5606
+ * BuiltinHookBeltSuggest searches the team's skills, knowledge and apps
5607
+ * for what the turn is about and injects the matches, so an agent picks up
5608
+ * procedural knowledge it was never prompted with.
5609
+ */
5547
5610
  export declare const BuiltinHookBeltSuggest: BuiltinHook;
5611
+ /**
5612
+ * BuiltinHookBeltExtract reviews the conversation for reusable knowledge
5613
+ * and saves it to the team's registry, deduplicated against what is
5614
+ * there, so belt:suggest can hand it back later. It runs in the
5615
+ * background: on agent.complete every tenth user turn, and before
5616
+ * compaction drops the turns it would have learned from.
5617
+ */
5618
+ export declare const BuiltinHookBeltExtract: BuiltinHook;
5548
5619
  /**
5549
5620
  * BuiltinHookDefinition describes a builtin hook and where it may be used.
5550
5621
  */
package/dist/types.js CHANGED
@@ -575,10 +575,12 @@ export const ChatMessageRoleTool = "tool";
575
575
  /**
576
576
  * Internal bookkeeping roles — never sent to the LLM provider.
577
577
  * BuildContext folds injections into the user turn and replaces
578
- * compaction markers with their summary.
578
+ * compaction markers with their summary. Event messages are display-only
579
+ * system info (a hook ran, ...) and BuildContext skips them.
579
580
  */
580
581
  export const ChatMessageRoleInjection = "injection";
581
582
  export const ChatMessageRoleCompaction = "compaction";
583
+ export const ChatMessageRoleEvent = "event";
582
584
  export const ChatMessageStatusPending = "pending";
583
585
  export const ChatMessageStatusQueued = "queued";
584
586
  export const ChatMessageStatusReady = "ready";
@@ -589,10 +591,12 @@ export const ChatMessageContentTypeReasoning = "reasoning";
589
591
  export const ChatMessageContentTypeImage = "image";
590
592
  export const ChatMessageContentTypeFile = "file";
591
593
  export const ChatMessageContentTypeTool = "tool";
594
+ export const ChatMessageContentTypeEvent = "event";
592
595
  export const ChannelTypeSlack = "slack";
593
596
  export const ChannelTypeDiscord = "discord";
594
597
  export const ChannelTypeTeams = "teams";
595
598
  export const ChannelTypeTelegram = "telegram";
599
+ export const ChatEventTypeHook = "hook";
596
600
  export const EngineStatusRunning = "running";
597
601
  export const EngineStatusPending = "pending";
598
602
  export const EngineStatusDraining = "draining";
@@ -730,6 +734,8 @@ export const InstanceStatusDeleted = "deleted";
730
734
  export const InstanceTypeDeploymentTypeVM = "vm";
731
735
  export const InstanceTypeDeploymentTypeContainer = "container";
732
736
  export const InstanceTypeDeploymentTypeBaremetal = "baremetal";
737
+ export const InstanceRentalTypeOnDemand = "on_demand";
738
+ export const InstanceRentalTypeSpot = "spot";
733
739
  export const AppSessionStatusActive = "active";
734
740
  export const AppSessionStatusEnded = "ended";
735
741
  export const AppSessionStatusExpired = "expired";
@@ -1197,7 +1203,20 @@ export const HookHandlerWebhook = "webhook";
1197
1203
  export const HookHandlerTask = "task";
1198
1204
  export const HookHandlerGate = "gate";
1199
1205
  export const HookHandlerBuiltin = "builtin";
1206
+ /**
1207
+ * BuiltinHookBeltSuggest searches the team's skills, knowledge and apps
1208
+ * for what the turn is about and injects the matches, so an agent picks up
1209
+ * procedural knowledge it was never prompted with.
1210
+ */
1200
1211
  export const BuiltinHookBeltSuggest = "belt:suggest";
1212
+ /**
1213
+ * BuiltinHookBeltExtract reviews the conversation for reusable knowledge
1214
+ * and saves it to the team's registry, deduplicated against what is
1215
+ * there, so belt:suggest can hand it back later. It runs in the
1216
+ * background: on agent.complete every tenth user turn, and before
1217
+ * compaction drops the turns it would have learned from.
1218
+ */
1219
+ export const BuiltinHookBeltExtract = "belt:extract";
1201
1220
  export const ToolInvocationStatusPending = "pending";
1202
1221
  export const ToolInvocationStatusInProgress = "in_progress";
1203
1222
  export const ToolInvocationStatusAwaitingInput = "awaiting_input";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inferencesh/sdk",
3
- "version": "0.14.0",
3
+ "version": "0.14.2",
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",