@inferencesh/sdk 0.22.0 → 0.23.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.
Files changed (78) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/agent/actions.d.ts +2 -2
  3. package/dist/agent/actions.js +93 -21
  4. package/dist/agent/api.d.ts +3 -3
  5. package/dist/agent/api.js +9 -7
  6. package/dist/agent/context.d.ts +1 -1
  7. package/dist/agent/hooks.d.ts +2 -2
  8. package/dist/agent/hooks.js +1 -1
  9. package/dist/agent/index.d.ts +6 -6
  10. package/dist/agent/index.js +5 -5
  11. package/dist/agent/mcp-input.d.ts +1 -1
  12. package/dist/agent/provider.d.ts +1 -1
  13. package/dist/agent/provider.js +5 -5
  14. package/dist/agent/reducer.d.ts +1 -1
  15. package/dist/agent/reducer.js +2 -2
  16. package/dist/agent/types.d.ts +5 -5
  17. package/dist/api/agents.d.ts +8 -10
  18. package/dist/api/agents.js +45 -34
  19. package/dist/api/api-keys.d.ts +3 -3
  20. package/dist/api/apps.d.ts +4 -4
  21. package/dist/api/artifacts.d.ts +3 -3
  22. package/dist/api/chats.d.ts +4 -4
  23. package/dist/api/credentials.d.ts +3 -3
  24. package/dist/api/engines.d.ts +4 -4
  25. package/dist/api/files.d.ts +3 -3
  26. package/dist/api/flow-runs.d.ts +3 -3
  27. package/dist/api/flows.d.ts +4 -4
  28. package/dist/api/index.d.ts +4 -4
  29. package/dist/api/index.js +4 -4
  30. package/dist/api/knowledge.d.ts +4 -4
  31. package/dist/api/mcp-servers.d.ts +4 -4
  32. package/dist/api/projects.d.ts +4 -4
  33. package/dist/api/search.d.ts +3 -3
  34. package/dist/api/secrets.d.ts +3 -3
  35. package/dist/api/sessions.d.ts +3 -3
  36. package/dist/api/sockets.d.ts +6 -6
  37. package/dist/api/sockets.js +2 -2
  38. package/dist/api/tasks.d.ts +3 -3
  39. package/dist/api/tasks.js +4 -4
  40. package/dist/api/teams.d.ts +4 -4
  41. package/dist/api/write-bodies.d.ts +1 -1
  42. package/dist/delta.d.ts +1 -1
  43. package/dist/delta.js +1 -1
  44. package/dist/hook-builder.d.ts +1 -1
  45. package/dist/hook-builder.js +1 -1
  46. package/dist/http/client.d.ts +2 -2
  47. package/dist/http/client.js +2 -2
  48. package/dist/http/errors.d.ts +1 -1
  49. package/dist/http/index.d.ts +4 -4
  50. package/dist/http/index.js +4 -4
  51. package/dist/http/response.d.ts +1 -1
  52. package/dist/http/stream-until-terminal.d.ts +22 -8
  53. package/dist/http/stream-until-terminal.js +17 -9
  54. package/dist/http/streamable.d.ts +63 -7
  55. package/dist/http/streamable.js +277 -119
  56. package/dist/index.d.ts +65 -65
  57. package/dist/index.js +53 -53
  58. package/dist/live/schema.js +1 -1
  59. package/dist/live/session.d.ts +3 -3
  60. package/dist/live/session.js +2 -2
  61. package/dist/proxy/express.d.ts +1 -1
  62. package/dist/proxy/express.js +1 -1
  63. package/dist/proxy/hono.d.ts +1 -1
  64. package/dist/proxy/hono.js +1 -1
  65. package/dist/proxy/index.js +0 -2
  66. package/dist/proxy/nextjs.d.ts +3 -3
  67. package/dist/proxy/nextjs.js +2 -2
  68. package/dist/proxy/remix.d.ts +1 -1
  69. package/dist/proxy/remix.js +1 -1
  70. package/dist/proxy/svelte.d.ts +1 -1
  71. package/dist/proxy/svelte.js +1 -1
  72. package/dist/tool-builder.d.ts +1 -1
  73. package/dist/tool-builder.js +1 -1
  74. package/dist/types.d.ts +164 -40
  75. package/dist/types.js +33 -9
  76. package/dist/utils.d.ts +2 -2
  77. package/dist/utils.js +2 -2
  78. package/package.json +2 -1
package/dist/index.js CHANGED
@@ -1,69 +1,69 @@
1
1
  // HTTP utilities
2
- export { HttpClient, createHttpClient } from './http/client';
3
- export { StreamManager } from './http/stream';
4
- export { StreamableManager, streamable, streamableRaw } from './http/streamable';
5
- export { PollManager } from './http/poll';
6
- export { isLoopbackHost, isHttpsOrLoopback } from './http/loopback';
2
+ export { HttpClient, createHttpClient } from './http/client.js';
3
+ export { StreamManager } from './http/stream.js';
4
+ export { StreamableManager, streamable, streamableRaw } from './http/streamable.js';
5
+ export { PollManager } from './http/poll.js';
6
+ export { isLoopbackHost, isHttpsOrLoopback } from './http/loopback.js';
7
7
  export { InferenceError, RequirementsNotMetException, SessionError, SessionNotFoundError, SessionExpiredError, SessionEndedError, WorkerLostError,
8
8
  // Type guards (use these instead of instanceof for reliability)
9
- isRequirementsNotMetException, isInferenceError, isSessionError, } from './http/errors';
9
+ isRequirementsNotMetException, isInferenceError, isSessionError, } from './http/errors.js';
10
10
  // API modules
11
- export { TasksAPI } from './api/tasks';
12
- export { SocketsAPI } from './api/sockets';
13
- export { FilesAPI } from './api/files';
14
- export { AgentsAPI, Agent } from './api/agents';
15
- export { SessionsAPI } from './api/sessions';
16
- export { AppsAPI } from './api/apps';
17
- export { ChatsAPI } from './api/chats';
18
- export { FlowsAPI } from './api/flows';
19
- export { FlowRunsAPI } from './api/flow-runs';
20
- export { EnginesAPI } from './api/engines';
21
- export { KnowledgeAPI, SkillsAPI } from './api/knowledge';
22
- export { ArtifactsAPI } from './api/artifacts';
23
- export { TeamsAPI } from './api/teams';
24
- export { SecretsAPI } from './api/secrets';
25
- export { ApiKeysAPI } from './api/api-keys';
26
- export { CredentialsAPI } from './api/credentials';
27
- export { SearchAPI } from './api/search';
28
- export { ProjectsAPI } from './api/projects';
29
- export { MCPServersAPI } from './api/mcp-servers';
11
+ export { TasksAPI } from './api/tasks.js';
12
+ export { SocketsAPI } from './api/sockets.js';
13
+ export { FilesAPI } from './api/files.js';
14
+ export { AgentsAPI, Agent } from './api/agents.js';
15
+ export { SessionsAPI } from './api/sessions.js';
16
+ export { AppsAPI } from './api/apps.js';
17
+ export { ChatsAPI } from './api/chats.js';
18
+ export { FlowsAPI } from './api/flows.js';
19
+ export { FlowRunsAPI } from './api/flow-runs.js';
20
+ export { EnginesAPI } from './api/engines.js';
21
+ export { KnowledgeAPI, SkillsAPI } from './api/knowledge.js';
22
+ export { ArtifactsAPI } from './api/artifacts.js';
23
+ export { TeamsAPI } from './api/teams.js';
24
+ export { SecretsAPI } from './api/secrets.js';
25
+ export { ApiKeysAPI } from './api/api-keys.js';
26
+ export { CredentialsAPI } from './api/credentials.js';
27
+ export { SearchAPI } from './api/search.js';
28
+ export { ProjectsAPI } from './api/projects.js';
29
+ export { MCPServersAPI } from './api/mcp-servers.js';
30
30
  // Live: the socket of a stream task and the live fields of its schemas
31
- export { LiveSession, accessUrl } from './live/session';
32
- export { STREAM_FORMAT, CLEAR_KEY, ERROR_KEY, REDIAL_CODES } from './live/protocol';
33
- export { isLiveField, parseMediaType, pcmFormat, splitLiveSchema, binaryLiveField, alternativeLabel, alternativeTag, } from './live/schema';
31
+ export { LiveSession, accessUrl } from './live/session.js';
32
+ export { STREAM_FORMAT, CLEAR_KEY, ERROR_KEY, REDIAL_CODES } from './live/protocol.js';
33
+ export { isLiveField, parseMediaType, pcmFormat, splitLiveSchema, binaryLiveField, alternativeLabel, alternativeTag, } from './live/schema.js';
34
34
  // Tool Builder (fluent API)
35
- export { tool, appTool, agentTool, webhookTool, httpTool, callTool, mcpTool, internalTools, string, number, integer, boolean, enumOf, object, array, optional, } from './tool-builder';
35
+ export { tool, appTool, agentTool, webhookTool, httpTool, callTool, mcpTool, internalTools, string, number, integer, boolean, enumOf, object, array, optional, } from './tool-builder.js';
36
36
  // Hook Builder (fluent API)
37
- export { lifecycleHook, learningHooks } from './hook-builder';
37
+ export { lifecycleHook, learningHooks } from './hook-builder.js';
38
38
  // Delta accumulator for streaming responses
39
- export { DeltaAccumulator, createLLMDeltaAccumulator } from './delta';
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, } from './utils';
41
+ export { parseStatus, isTerminalStatus, isChatBusy, isAwaitingHuman, isRunTerminal, isRunInterrupted, isRunSettled, isRunWorking, isMessageTerminal, pendingApprovals, } from './utils.js';
42
42
  // Types - includes TaskStatus constants and all DTOs
43
- export * from './types';
43
+ export * from './types.js';
44
44
  // =============================================================================
45
45
  // Main Client
46
46
  // =============================================================================
47
- import { HttpClient } from './http/client';
48
- import { TasksAPI } from './api/tasks';
49
- import { SocketsAPI } from './api/sockets';
50
- import { FilesAPI } from './api/files';
51
- import { AgentsAPI } from './api/agents';
52
- import { SessionsAPI } from './api/sessions';
53
- import { AppsAPI } from './api/apps';
54
- import { ChatsAPI } from './api/chats';
55
- import { FlowsAPI } from './api/flows';
56
- import { FlowRunsAPI } from './api/flow-runs';
57
- import { EnginesAPI } from './api/engines';
58
- import { KnowledgeAPI, SkillsAPI } from './api/knowledge';
59
- import { ArtifactsAPI } from './api/artifacts';
60
- import { TeamsAPI } from './api/teams';
61
- import { SecretsAPI } from './api/secrets';
62
- import { ApiKeysAPI } from './api/api-keys';
63
- import { CredentialsAPI } from './api/credentials';
64
- import { SearchAPI } from './api/search';
65
- import { ProjectsAPI } from './api/projects';
66
- import { MCPServersAPI } from './api/mcp-servers';
47
+ import { HttpClient } from './http/client.js';
48
+ import { TasksAPI } from './api/tasks.js';
49
+ import { SocketsAPI } from './api/sockets.js';
50
+ import { FilesAPI } from './api/files.js';
51
+ import { AgentsAPI } from './api/agents.js';
52
+ import { SessionsAPI } from './api/sessions.js';
53
+ import { AppsAPI } from './api/apps.js';
54
+ import { ChatsAPI } from './api/chats.js';
55
+ import { FlowsAPI } from './api/flows.js';
56
+ import { FlowRunsAPI } from './api/flow-runs.js';
57
+ import { EnginesAPI } from './api/engines.js';
58
+ import { KnowledgeAPI, SkillsAPI } from './api/knowledge.js';
59
+ import { ArtifactsAPI } from './api/artifacts.js';
60
+ import { TeamsAPI } from './api/teams.js';
61
+ import { SecretsAPI } from './api/secrets.js';
62
+ import { ApiKeysAPI } from './api/api-keys.js';
63
+ import { CredentialsAPI } from './api/credentials.js';
64
+ import { SearchAPI } from './api/search.js';
65
+ import { ProjectsAPI } from './api/projects.js';
66
+ import { MCPServersAPI } from './api/mcp-servers.js';
67
67
  /**
68
68
  * Inference.sh SDK Client
69
69
  *
@@ -16,7 +16,7 @@
16
16
  * The helpers are generic over the schema type so a caller with a richer
17
17
  * JSON Schema type keeps it.
18
18
  */
19
- import { STREAM_FORMAT } from './protocol';
19
+ import { STREAM_FORMAT } from './protocol.js';
20
20
  export function isLiveField(schema) {
21
21
  return !!schema && schema.format === STREAM_FORMAT;
22
22
  }
@@ -10,9 +10,9 @@
10
10
  * item of the binary live field, a text frame is a JSON object keyed by field
11
11
  * name.
12
12
  */
13
- import type { SocketAccess } from '../types';
14
- import type { TaskWatch as TasksWatch } from '../api/tasks';
15
- import { type JsonSchema } from './schema';
13
+ import type { SocketAccess } from '../types.js';
14
+ import type { TaskWatch as TasksWatch } from '../api/tasks.js';
15
+ import { type JsonSchema } from './schema.js';
16
16
  export type LiveState = 'connecting' | 'waiting' | 'live' | 'ended';
17
17
  export interface LiveEnd {
18
18
  /** The WebSocket close code, or 1006 when the session ended without one. */
@@ -1,5 +1,5 @@
1
- import { CLEAR_KEY, ERROR_KEY, REDIAL_CODES } from './protocol';
2
- import { binaryLiveField, splitLiveSchema } from './schema';
1
+ import { CLEAR_KEY, ERROR_KEY, REDIAL_CODES } from './protocol.js';
2
+ import { binaryLiveField, splitLiveSchema } from './schema.js';
3
3
  const WS_OPEN = 1;
4
4
  const MAX_REDIALS = 5;
5
5
  function globalWebSocket() {
@@ -12,7 +12,7 @@
12
12
  * ```
13
13
  */
14
14
  import type { Request, RequestHandler } from "express";
15
- import { type ProxyOptions } from "./index";
15
+ import { type ProxyOptions } from "./index.js";
16
16
  /** Default proxy route path */
17
17
  export declare const PROXY_ROUTE = "/api/inference/proxy";
18
18
  /** @deprecated Use PROXY_ROUTE */
@@ -11,7 +11,7 @@
11
11
  * app.all(PROXY_ROUTE, createHandler({ allowedEndpoints: ["my-team/*"] }));
12
12
  * ```
13
13
  */
14
- import { PROXY_PATH, processProxyRequest, } from "./index";
14
+ import { PROXY_PATH, processProxyRequest, } from "./index.js";
15
15
  /** Default proxy route path */
16
16
  export const PROXY_ROUTE = PROXY_PATH;
17
17
  /** @deprecated Use PROXY_ROUTE */
@@ -13,7 +13,7 @@
13
13
  * ```
14
14
  */
15
15
  import type { Context } from "hono";
16
- import { type ProxyOptions } from "./index";
16
+ import { type ProxyOptions } from "./index.js";
17
17
  /** Proxy options; `isAuthenticated` receives the Context. */
18
18
  export interface HonoProxyOptions extends ProxyOptions<Context> {
19
19
  /** Custom function to resolve the API key */
@@ -12,7 +12,7 @@
12
12
  * app.all("/api/inference/proxy", createHandler({ allowedEndpoints: ["my-team/*"] }));
13
13
  * ```
14
14
  */
15
- import { processProxyRequest, getEnvApiKey, passthrough, headersToRecord, } from "./index";
15
+ import { processProxyRequest, getEnvApiKey, passthrough, headersToRecord, } from "./index.js";
16
16
  /**
17
17
  * Creates a Hono route handler for the Inference.sh proxy.
18
18
  */
@@ -18,8 +18,6 @@
18
18
  * });
19
19
  * ```
20
20
  */
21
- // With the .js extension: dist/proxy/index.js is the one proxy entry that
22
- // loads in plain Node ESM (no bundler), and Node does not add extensions.
23
21
  import { isHttpsOrLoopback } from "../http/loopback.js";
24
22
  // The calls the proxy forwards, generated by go/api from its route table
25
23
  // (`make proxy-endpoints`, copied here by `make types`). Do not edit it here.
@@ -15,9 +15,9 @@
15
15
  * export default createPageHandler({ allowedEndpoints: ["my-team/*"] });
16
16
  * ```
17
17
  */
18
- import { type NextRequest } from "next/server";
19
- import type { NextApiHandler, NextApiRequest } from "next/types";
20
- import { type ProxyOptions } from "./index";
18
+ import { type NextRequest } from "next/server.js";
19
+ import type { NextApiHandler, NextApiRequest } from "next/types.js";
20
+ import { type ProxyOptions } from "./index.js";
21
21
  /** Default proxy route path */
22
22
  export declare const PROXY_ROUTE = "/api/inference/proxy";
23
23
  /**
@@ -15,8 +15,8 @@
15
15
  * export default createPageHandler({ allowedEndpoints: ["my-team/*"] });
16
16
  * ```
17
17
  */
18
- import { NextResponse } from "next/server";
19
- import { PROXY_PATH, processProxyRequest, headersToRecord, } from "./index";
18
+ import { NextResponse } from "next/server.js";
19
+ import { PROXY_PATH, processProxyRequest, headersToRecord, } from "./index.js";
20
20
  // ============================================================================
21
21
  // Exports
22
22
  // ============================================================================
@@ -14,7 +14,7 @@
14
14
  * export const action = handler;
15
15
  * ```
16
16
  */
17
- import { type ProxyOptions } from "./index";
17
+ import { type ProxyOptions } from "./index.js";
18
18
  /** Proxy options; `isAuthenticated` receives the Request. */
19
19
  export interface RemixProxyOptions extends ProxyOptions<Request> {
20
20
  /** Custom function to resolve the API key */
@@ -14,7 +14,7 @@
14
14
  * export const action = handler;
15
15
  * ```
16
16
  */
17
- import { processProxyRequest, getEnvApiKey, passthrough, headersToRecord, } from "./index";
17
+ import { processProxyRequest, getEnvApiKey, passthrough, headersToRecord, } from "./index.js";
18
18
  /**
19
19
  * Creates a Remix request handler for the Inference.sh proxy.
20
20
  * Use this as both a loader and action in your Remix route.
@@ -15,7 +15,7 @@
15
15
  * ```
16
16
  */
17
17
  import type { RequestEvent } from "@sveltejs/kit";
18
- import { type ProxyOptions } from "./index";
18
+ import { type ProxyOptions } from "./index.js";
19
19
  /** Proxy options; `isAuthenticated` receives the RequestEvent. */
20
20
  export interface SvelteProxyOptions extends ProxyOptions<RequestEvent> {
21
21
  /** Custom function to resolve the API key */
@@ -14,7 +14,7 @@
14
14
  * export const POST = handler;
15
15
  * ```
16
16
  */
17
- import { processProxyRequest, getEnvApiKey, passthrough, headersToRecord, } from "./index";
17
+ import { processProxyRequest, getEnvApiKey, passthrough, headersToRecord, } from "./index.js";
18
18
  /**
19
19
  * Creates a SvelteKit request handler for the Inference.sh proxy.
20
20
  *
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Tool Builder - Fluent API for defining agent tools
3
3
  */
4
- import { AgentTool, InternalToolsConfig } from './types';
4
+ import { AgentTool, InternalToolsConfig } from './types.js';
5
5
  /** Handler function for client tools (executed in browser/Node) */
6
6
  export type ClientToolHandler = (args: Record<string, unknown>) => Promise<string> | string;
7
7
  /** Client tool with schema and handler bundled together */
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Tool Builder - Fluent API for defining agent tools
3
3
  */
4
- import { ToolAuthTypeAPIKey, ToolAuthTypeBearer, ToolAuthTypeCredential, ToolTypeClient, ToolTypeApp, ToolTypeAgent, ToolTypeHook, ToolTypeHTTP, ToolTypeMCP } from './types';
4
+ import { ToolAuthTypeAPIKey, ToolAuthTypeBearer, ToolAuthTypeCredential, ToolTypeClient, ToolTypeApp, ToolTypeAgent, ToolTypeHook, ToolTypeHTTP, ToolTypeMCP } from './types.js';
5
5
  // =============================================================================
6
6
  // Schema Builders
7
7
  // =============================================================================