@inferencesh/sdk 0.6.14 → 0.6.15

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/README.md CHANGED
@@ -677,7 +677,7 @@ import type {
677
677
 
678
678
  - [documentation](https://inference.sh/docs) — getting started guides and api reference
679
679
  - [blog](https://inference.sh/blog) — tutorials on ai agents, image generation, and more
680
- - [app store](https://app.inference.sh) — browse 250+ ai models
680
+ - [app store](https://app.inference.sh) — browse ai models
681
681
  - [discord](https://discord.gg/inference) — community support
682
682
  - [github](https://github.com/inference-sh) — open source projects
683
683
 
@@ -18,6 +18,14 @@ const dispatchedToolInvocations = new Set();
18
18
  // =============================================================================
19
19
  export function createActions(ctx) {
20
20
  const { client, dispatch, getConfig, getChatId, getClientToolHandlers, getStreamManager, setStreamManager, getStreamEnabled, getPollIntervalMs, callbacks } = ctx;
21
+ let prevChatWasBusy = false;
22
+ const checkTurnEnd = (chat) => {
23
+ const isBusy = chat.status === ChatStatusBusy;
24
+ if (prevChatWasBusy && !isBusy) {
25
+ callbacks.onTurnEnd?.(chat);
26
+ }
27
+ prevChatWasBusy = isBusy;
28
+ };
21
29
  // =========================================================================
22
30
  // Internal helpers
23
31
  // =========================================================================
@@ -26,6 +34,7 @@ export function createActions(ctx) {
26
34
  if (chat) {
27
35
  const status = chat.status === ChatStatusBusy ? 'streaming' : 'idle';
28
36
  callbacks.onStatusChange?.(status);
37
+ checkTurnEnd(chat);
29
38
  }
30
39
  };
31
40
  const updateMessage = (message) => {
@@ -129,6 +138,7 @@ export function createActions(ctx) {
129
138
  if (chatData) {
130
139
  const status = chatData.status === ChatStatusBusy ? 'streaming' : 'idle';
131
140
  callbacks.onStatusChange?.(status);
141
+ checkTurnEnd(chatData);
132
142
  }
133
143
  });
134
144
  // Listen for ChatMessage updates
@@ -27,7 +27,7 @@ import type { AgentChatProviderProps } from './types';
27
27
  * }
28
28
  * ```
29
29
  */
30
- export declare function AgentChatProvider({ client, agentConfig, chatId, clientToolHandlers: extraHandlers, onChatCreated, onStatusChange, onError, stream, pollIntervalMs, children, }: AgentChatProviderProps): import("react/jsx-runtime").JSX.Element;
30
+ export declare function AgentChatProvider({ client, agentConfig, chatId, clientToolHandlers: extraHandlers, onChatCreated, onStatusChange, onError, onTurnEnd, stream, pollIntervalMs, children, }: AgentChatProviderProps): import("react/jsx-runtime").JSX.Element;
31
31
  export declare namespace AgentChatProvider {
32
32
  var displayName: string;
33
33
  }
@@ -39,7 +39,7 @@ function mergeHandlers(base, extra) {
39
39
  * }
40
40
  * ```
41
41
  */
42
- export function AgentChatProvider({ client, agentConfig, chatId, clientToolHandlers: extraHandlers, onChatCreated, onStatusChange, onError, stream, pollIntervalMs, children, }) {
42
+ export function AgentChatProvider({ client, agentConfig, chatId, clientToolHandlers: extraHandlers, onChatCreated, onStatusChange, onError, onTurnEnd, stream, pollIntervalMs, children, }) {
43
43
  // Core state via useReducer
44
44
  const [state, dispatch] = useReducer(chatReducer, initialState);
45
45
  // Refs for mutable values that actions need access to
@@ -49,15 +49,15 @@ export function AgentChatProvider({ client, agentConfig, chatId, clientToolHandl
49
49
  const streamRef = useRef(stream);
50
50
  const pollIntervalMsRef = useRef(pollIntervalMs);
51
51
  const clientToolHandlersRef = useRef(mergeHandlers(getClientToolHandlers(agentConfig), extraHandlers));
52
- const callbacksRef = useRef({ onChatCreated, onStatusChange, onError });
52
+ const callbacksRef = useRef({ onChatCreated, onStatusChange, onError, onTurnEnd });
53
53
  // Keep refs in sync with props
54
54
  useEffect(() => {
55
55
  configRef.current = agentConfig;
56
56
  clientToolHandlersRef.current = mergeHandlers(getClientToolHandlers(agentConfig), extraHandlers);
57
57
  }, [agentConfig, extraHandlers]);
58
58
  useEffect(() => {
59
- callbacksRef.current = { onChatCreated, onStatusChange, onError };
60
- }, [onChatCreated, onStatusChange, onError]);
59
+ callbacksRef.current = { onChatCreated, onStatusChange, onError, onTurnEnd };
60
+ }, [onChatCreated, onStatusChange, onError, onTurnEnd]);
61
61
  useEffect(() => {
62
62
  streamRef.current = stream;
63
63
  pollIntervalMsRef.current = pollIntervalMs;
@@ -82,7 +82,7 @@ export function AgentChatProvider({ client, agentConfig, chatId, clientToolHandl
82
82
  // Re-bind callbacks when they change
83
83
  useEffect(() => {
84
84
  actionsContext.callbacks = callbacksRef.current;
85
- }, [actionsContext, onChatCreated, onStatusChange, onError]);
85
+ }, [actionsContext, onChatCreated, onStatusChange, onError, onTurnEnd]);
86
86
  const actionsResultRef = useRef(null);
87
87
  if (!actionsResultRef.current) {
88
88
  actionsResultRef.current = createActions(actionsContext);
@@ -135,6 +135,8 @@ export interface AgentChatProviderProps {
135
135
  onStatusChange?: (status: ChatStatus) => void;
136
136
  /** Callback when an error occurs */
137
137
  onError?: (error: Error) => void;
138
+ /** Callback when the agent's turn ends (chat transitions from busy to idle/completed) */
139
+ onTurnEnd?: (chat: ChatDTO) => void;
138
140
  /** Use SSE streaming (true, default) or polling (false) for real-time updates */
139
141
  stream?: boolean;
140
142
  /** Polling interval in ms when stream is false (default: 2000) */
@@ -216,6 +218,7 @@ export interface ActionsContext {
216
218
  onChatCreated?: (chatId: string) => void;
217
219
  onStatusChange?: (status: ChatStatus) => void;
218
220
  onError?: (error: Error) => void;
221
+ onTurnEnd?: (chat: ChatDTO) => void;
219
222
  };
220
223
  }
221
224
  /**
package/dist/types.d.ts CHANGED
@@ -506,6 +506,42 @@ export interface CreateApiKeyRequest {
506
506
  expires_at?: string;
507
507
  scopes?: string[];
508
508
  }
509
+ /**
510
+ * EstimateCostRequest is the request for POST /store/apps/{appId}/estimate.
511
+ */
512
+ export interface EstimateCostRequest {
513
+ input: {
514
+ [key: string]: any;
515
+ };
516
+ function?: string;
517
+ }
518
+ /**
519
+ * EstimateCostResponse is the response from the cost estimation endpoint.
520
+ */
521
+ export interface EstimateCostResponse {
522
+ /**
523
+ * Confidence: "exact" (all fees input-based), "range" (estimate expression),
524
+ * or "unknown" (output-dependent, no estimate expression).
525
+ */
526
+ confidence: string;
527
+ /**
528
+ * Microcents is set when confidence is "exact".
529
+ */
530
+ microcents?: number;
531
+ /**
532
+ * Min/Max are set when confidence is "range".
533
+ */
534
+ min?: number;
535
+ max?: number;
536
+ /**
537
+ * DependsOn lists post-execution variables the pricing needs (when not exact).
538
+ */
539
+ depends_on?: string[];
540
+ /**
541
+ * PricingDescription is the rendered human-readable pricing string.
542
+ */
543
+ pricing_description?: string;
544
+ }
509
545
  /**
510
546
  * Scope represents an API key permission scope string.
511
547
  */
@@ -683,7 +719,7 @@ export declare const ScopeBillingRead: Scope;
683
719
  */
684
720
  export declare const ScopeBillingWrite: Scope;
685
721
  /**
686
- * Action-level scopes for Secrets (sensitive - not in read/run presets)
722
+ * Action-level scopes for Secrets (sensitive - excluded from read-only preset)
687
723
  */
688
724
  export declare const ScopeSecretsRead: Scope;
689
725
  /**
@@ -794,6 +830,8 @@ export interface ScopePreset {
794
830
  label: string;
795
831
  description: string;
796
832
  scopes: Scope[];
833
+ summary?: string[];
834
+ hidden?: boolean;
797
835
  }
798
836
  /**
799
837
  * ApiKeyDTO for API responses
@@ -820,6 +858,19 @@ export interface AppPricing {
820
858
  royalty_expression: string;
821
859
  partner_expression: string;
822
860
  total_expression: string;
861
+ /**
862
+ * Estimate is a single CEL expression for pre-execution cost estimation.
863
+ * Returns either an int (exact total in microcents) or a {"min": int, "max": int} map.
864
+ * Only has access to pre-execution variables: task_inputs, prices, fees, task_function.
865
+ * Used by the /estimate endpoint when the real expressions depend on post-execution data.
866
+ * Not needed when all fee expressions are already input-based (the system evaluates those directly).
867
+ */
868
+ estimate?: string;
869
+ /**
870
+ * Estimable is computed at save time. True when all fee expressions can be
871
+ * evaluated from pre-execution data alone (task_inputs, prices, fees, task_function).
872
+ */
873
+ estimable?: boolean;
823
874
  description: string;
824
875
  description_rendered?: string;
825
876
  }
@@ -971,6 +1022,7 @@ export interface AppStoreListingDTO {
971
1022
  max_concurrency: number;
972
1023
  max_concurrency_per_team: number;
973
1024
  min_concurrency: number;
1025
+ required_feature?: string;
974
1026
  tags?: string[];
975
1027
  }
976
1028
  /**
@@ -1170,6 +1222,7 @@ export interface EngineDTO extends BaseModelDTO, PermissionModelDTO {
1170
1222
  name: string;
1171
1223
  api_url: string;
1172
1224
  status: EngineStatus;
1225
+ engine_version: string;
1173
1226
  system_info?: SystemInfo;
1174
1227
  workers: (WorkerDTO | undefined)[];
1175
1228
  }
@@ -1264,6 +1317,20 @@ export interface EntitlementDTO extends BaseModelDTO {
1264
1317
  source: EntitlementSource;
1265
1318
  enforcement: EnforcementMode;
1266
1319
  expires_at?: string;
1320
+ team_plan_id?: string;
1321
+ }
1322
+ /**
1323
+ * EntitlementErrorMeta is the structured metadata returned in entitlement error responses.
1324
+ */
1325
+ export interface EntitlementErrorMeta {
1326
+ resource: EntitlementResource;
1327
+ resource_label?: string;
1328
+ limit?: number;
1329
+ current?: number;
1330
+ upgrade_available: boolean;
1331
+ addon_plan_id?: string;
1332
+ addon_plan_name?: string;
1333
+ addon_plan_price?: number;
1267
1334
  }
1268
1335
  /**
1269
1336
  * FileMetadata holds probed media metadata cached on File records.
@@ -1590,6 +1657,7 @@ export interface KnowledgeVersionDTO extends BaseModelDTO {
1590
1657
  content_hash: string;
1591
1658
  description: string;
1592
1659
  tags: string[];
1660
+ scope?: string[];
1593
1661
  metadata?: {
1594
1662
  [key: string]: string;
1595
1663
  };
@@ -1819,11 +1887,14 @@ export interface PlanDTO extends BaseModelDTO {
1819
1887
  display_order: number;
1820
1888
  active: boolean;
1821
1889
  self_serve?: boolean;
1890
+ plan_type: PlanType;
1822
1891
  price_monthly?: number;
1823
1892
  price_yearly?: number;
1824
1893
  credits_monthly: number;
1825
1894
  provider_price_id_monthly?: string;
1826
1895
  provider_price_id_yearly?: string;
1896
+ required_plan_ids?: string[];
1897
+ required_plan_names?: string[];
1827
1898
  limits: PlanLimits;
1828
1899
  }
1829
1900
  /**
@@ -1854,6 +1925,7 @@ export interface RefRouteDTO extends BaseModelDTO {
1854
1925
  alias_ref: string;
1855
1926
  target_ref: string;
1856
1927
  primary: boolean;
1928
+ mode: RefRouteMode;
1857
1929
  description: string;
1858
1930
  enabled: boolean;
1859
1931
  }
@@ -1879,6 +1951,7 @@ export interface KnowledgeVersionInput {
1879
1951
  content?: KnowledgeFile;
1880
1952
  files?: KnowledgeFile[];
1881
1953
  tags?: string[];
1954
+ scope?: string[];
1882
1955
  metadata?: {
1883
1956
  [key: string]: string;
1884
1957
  };
@@ -1987,6 +2060,7 @@ export interface SuggestRequest {
1987
2060
  limit?: number;
1988
2061
  category?: string;
1989
2062
  agent?: boolean;
2063
+ scope?: string[];
1990
2064
  }
1991
2065
  /**
1992
2066
  * SuggestResponse is the output of the suggest endpoint.
@@ -2000,6 +2074,7 @@ export interface SuggestResponse {
2000
2074
  */
2001
2075
  export interface SuggestResult {
2002
2076
  type: string;
2077
+ tag?: string;
2003
2078
  name: string;
2004
2079
  description: string;
2005
2080
  command: string;
@@ -2085,7 +2160,6 @@ export interface SecretDTO extends BaseModelDTO, PermissionModelDTO {
2085
2160
  */
2086
2161
  export interface SubscriptionDTO extends BaseModelDTO {
2087
2162
  team_id: string;
2088
- stripe_subscription_id?: string;
2089
2163
  plan_id: string;
2090
2164
  plan?: PlanDTO;
2091
2165
  interval: SubscriptionInterval;
@@ -2621,6 +2695,21 @@ export declare const SubscriptionStatusPaused: SubscriptionStatus;
2621
2695
  export type SubscriptionInterval = string;
2622
2696
  export declare const SubscriptionIntervalMonthly: SubscriptionInterval;
2623
2697
  export declare const SubscriptionIntervalYearly: SubscriptionInterval;
2698
+ export type PlanType = string;
2699
+ export declare const PlanTypeBase: PlanType;
2700
+ export declare const PlanTypeAddon: PlanType;
2701
+ export type EntitlementSource = string;
2702
+ export declare const EntitlementSourceTier: EntitlementSource;
2703
+ export declare const EntitlementSourceOverride: EntitlementSource;
2704
+ export declare const EntitlementSourceWhitelist: EntitlementSource;
2705
+ export declare const EntitlementSourceTrial: EntitlementSource;
2706
+ export declare const EntitlementSourceAddon: EntitlementSource;
2707
+ export type EntitlementType = string;
2708
+ export declare const EntitlementTypeBoolean: EntitlementType;
2709
+ export declare const EntitlementTypeLimit: EntitlementType;
2710
+ export type EnforcementMode = string;
2711
+ export declare const EnforcementBlock: EnforcementMode;
2712
+ export declare const EnforcementWarn: EnforcementMode;
2624
2713
  export type ChatStatus = string;
2625
2714
  export declare const ChatStatusBusy: ChatStatus;
2626
2715
  export declare const ChatStatusIdle: ChatStatus;
@@ -2872,6 +2961,9 @@ export declare const GraphEdgeTypeParent: GraphEdgeType;
2872
2961
  export declare const GraphEdgeTypeAncestor: GraphEdgeType;
2873
2962
  export declare const GraphEdgeTypeDuplicate: GraphEdgeType;
2874
2963
  export declare const GraphEdgeTypeReferences: GraphEdgeType;
2964
+ export declare const GraphEdgeTypeSupersedes: GraphEdgeType;
2965
+ export declare const GraphEdgeTypeInput: GraphEdgeType;
2966
+ export declare const GraphEdgeTypeOutput: GraphEdgeType;
2875
2967
  /**
2876
2968
  * SecretScope defines the visibility/purpose of a secret
2877
2969
  */
@@ -2888,20 +2980,6 @@ export declare const SecretScopeInternal: SecretScope;
2888
2980
  * SecretScopeSystem is a global system setting, owned by system team, admin-only
2889
2981
  */
2890
2982
  export declare const SecretScopeSystem: SecretScope;
2891
- export type EntitlementSource = string;
2892
- export declare const EntitlementSourceTier: EntitlementSource;
2893
- export declare const EntitlementSourceOverride: EntitlementSource;
2894
- export declare const EntitlementSourceWhitelist: EntitlementSource;
2895
- export declare const EntitlementSourceTrial: EntitlementSource;
2896
- export type EntitlementType = string;
2897
- export declare const EntitlementTypeBoolean: EntitlementType;
2898
- export declare const EntitlementTypeLimit: EntitlementType;
2899
- /**
2900
- * EnforcementMode controls how limit violations are handled.
2901
- */
2902
- export type EnforcementMode = string;
2903
- export declare const EnforcementBlock: EnforcementMode;
2904
- export declare const EnforcementWarn: EnforcementMode;
2905
2983
  export type PageStatus = number;
2906
2984
  export declare const PageStatusUnknown: PageStatus;
2907
2985
  export declare const PageStatusDraft: PageStatus;
@@ -3030,6 +3108,9 @@ export type RefRouteType = string;
3030
3108
  export declare const RefRouteTypeApp: RefRouteType;
3031
3109
  export declare const RefRouteTypeAgent: RefRouteType;
3032
3110
  export declare const RefRouteTypeSkill: RefRouteType;
3111
+ export type RefRouteMode = string;
3112
+ export declare const RefRouteModeRewrite: RefRouteMode;
3113
+ export declare const RefRouteModeRedirect: RefRouteMode;
3033
3114
  export type KnowledgeType = string;
3034
3115
  export declare const KnowledgeTypeConcept: KnowledgeType;
3035
3116
  export declare const KnowledgeTypeSkill: KnowledgeType;
@@ -3103,6 +3184,7 @@ export declare const ResourceTaskExecutions: EntitlementResource;
3103
3184
  * Feature gates — only what has real cost/complexity
3104
3185
  */
3105
3186
  export declare const ResourceFeatureBYOK: EntitlementResource;
3187
+ export declare const ResourceFeatureSeedance: EntitlementResource;
3106
3188
  /**
3107
3189
  * Legacy feature gates — kept for DB compatibility, no longer gated
3108
3190
  */
@@ -3243,6 +3325,10 @@ export declare const NotificationTypeSecurityAlert: NotificationType;
3243
3325
  */
3244
3326
  export declare const NotificationTypeTaskComplete: NotificationType;
3245
3327
  export declare const NotificationTypeTaskFailed: NotificationType;
3328
+ /**
3329
+ * Data export
3330
+ */
3331
+ export declare const NotificationTypeDataExport: NotificationType;
3246
3332
  /**
3247
3333
  * System notifications
3248
3334
  */
package/dist/types.js CHANGED
@@ -172,7 +172,7 @@ export const ScopeBillingRead = "billing:read";
172
172
  */
173
173
  export const ScopeBillingWrite = "billing:write";
174
174
  /**
175
- * Action-level scopes for Secrets (sensitive - not in read/run presets)
175
+ * Action-level scopes for Secrets (sensitive - excluded from read-only preset)
176
176
  */
177
177
  export const ScopeSecretsRead = "secrets:read";
178
178
  /**
@@ -285,6 +285,17 @@ export const SubscriptionStatusCanceled = "canceled";
285
285
  export const SubscriptionStatusPaused = "paused";
286
286
  export const SubscriptionIntervalMonthly = "monthly";
287
287
  export const SubscriptionIntervalYearly = "yearly";
288
+ export const PlanTypeBase = "base";
289
+ export const PlanTypeAddon = "addon";
290
+ export const EntitlementSourceTier = "tier";
291
+ export const EntitlementSourceOverride = "override";
292
+ export const EntitlementSourceWhitelist = "whitelist";
293
+ export const EntitlementSourceTrial = "trial";
294
+ export const EntitlementSourceAddon = "addon";
295
+ export const EntitlementTypeBoolean = "boolean";
296
+ export const EntitlementTypeLimit = "limit";
297
+ export const EnforcementBlock = "block";
298
+ export const EnforcementWarn = "warn";
288
299
  export const ChatStatusBusy = "busy";
289
300
  export const ChatStatusIdle = "idle";
290
301
  export const ChatStatusAwaitingInput = "awaiting_input";
@@ -355,6 +366,9 @@ export const GraphEdgeTypeParent = "parent";
355
366
  export const GraphEdgeTypeAncestor = "ancestor";
356
367
  export const GraphEdgeTypeDuplicate = "duplicate";
357
368
  export const GraphEdgeTypeReferences = "references";
369
+ export const GraphEdgeTypeSupersedes = "supersedes";
370
+ export const GraphEdgeTypeInput = "input";
371
+ export const GraphEdgeTypeOutput = "output";
358
372
  /**
359
373
  * SecretScopeTeam is a normal user secret, visible in team secret lists
360
374
  */
@@ -367,14 +381,6 @@ export const SecretScopeInternal = "internal";
367
381
  * SecretScopeSystem is a global system setting, owned by system team, admin-only
368
382
  */
369
383
  export const SecretScopeSystem = "system";
370
- export const EntitlementSourceTier = "tier";
371
- export const EntitlementSourceOverride = "override";
372
- export const EntitlementSourceWhitelist = "whitelist";
373
- export const EntitlementSourceTrial = "trial";
374
- export const EntitlementTypeBoolean = "boolean";
375
- export const EntitlementTypeLimit = "limit";
376
- export const EnforcementBlock = "block";
377
- export const EnforcementWarn = "warn";
378
384
  export const PageStatusUnknown = 0;
379
385
  export const PageStatusDraft = 1;
380
386
  export const PageStatusPublished = 2;
@@ -464,6 +470,8 @@ export const TeamInviteStatusRevoked = "revoked";
464
470
  export const RefRouteTypeApp = "app";
465
471
  export const RefRouteTypeAgent = "agent";
466
472
  export const RefRouteTypeSkill = "skill";
473
+ export const RefRouteModeRewrite = "rewrite";
474
+ export const RefRouteModeRedirect = "redirect";
467
475
  export const KnowledgeTypeConcept = "concept";
468
476
  export const KnowledgeTypeSkill = "skill";
469
477
  export const KnowledgeTypeObservation = "observation";
@@ -528,6 +536,7 @@ export const ResourceTaskExecutions = "task_executions";
528
536
  * Feature gates — only what has real cost/complexity
529
537
  */
530
538
  export const ResourceFeatureBYOK = "feature:byok";
539
+ export const ResourceFeatureSeedance = "feature:seedance";
531
540
  /**
532
541
  * Legacy feature gates — kept for DB compatibility, no longer gated
533
542
  */
@@ -638,6 +647,10 @@ export const NotificationTypeSecurityAlert = "security_alert";
638
647
  */
639
648
  export const NotificationTypeTaskComplete = "task_complete";
640
649
  export const NotificationTypeTaskFailed = "task_failed";
650
+ /**
651
+ * Data export
652
+ */
653
+ export const NotificationTypeDataExport = "data_export";
641
654
  /**
642
655
  * System notifications
643
656
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inferencesh/sdk",
3
- "version": "0.6.14",
3
+ "version": "0.6.15",
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",