@inferencesh/sdk 0.7.0 → 0.7.1

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
@@ -28,7 +28,7 @@ export { ProjectsAPI } from './api/projects';
28
28
  export { MCPServersAPI } from './api/mcp-servers';
29
29
  export { LiveSession, accessUrl } from './live/session';
30
30
  export type { LiveState, LiveEnd, LiveHandlers, LiveSessionOptions, WebSocketLike, WebSocketConstructor } from './live/session';
31
- export { STREAM_FORMAT, isLiveField, parseMediaType, pcmFormat, splitLiveSchema, binaryLiveField, alternativeLabel, } from './live/schema';
31
+ export { STREAM_FORMAT, CLEAR_KEY, isLiveField, parseMediaType, pcmFormat, splitLiveSchema, binaryLiveField, alternativeLabel, } from './live/schema';
32
32
  export type { JsonSchema, MediaType, PCMFormat, LiveField } from './live/schema';
33
33
  export { tool, appTool, agentTool, webhookTool, httpTool, callTool, mcpTool, internalTools, string, number, integer, boolean, enumOf, object, array, optional, } from './tool-builder';
34
34
  export type { ClientTool, ClientToolHandler } from './tool-builder';
package/dist/index.js CHANGED
@@ -30,7 +30,7 @@ export { ProjectsAPI } from './api/projects';
30
30
  export { MCPServersAPI } from './api/mcp-servers';
31
31
  // Live: the socket of a stream task and the live fields of its schemas
32
32
  export { LiveSession, accessUrl } from './live/session';
33
- export { STREAM_FORMAT, isLiveField, parseMediaType, pcmFormat, splitLiveSchema, binaryLiveField, alternativeLabel, } from './live/schema';
33
+ export { STREAM_FORMAT, CLEAR_KEY, isLiveField, parseMediaType, pcmFormat, splitLiveSchema, binaryLiveField, alternativeLabel, } from './live/schema';
34
34
  // Tool Builder (fluent API)
35
35
  export { tool, appTool, agentTool, webhookTool, httpTool, callTool, mcpTool, internalTools, string, number, integer, boolean, enumOf, object, array, optional, } from './tool-builder';
36
36
  // Hook Builder (fluent API)
@@ -17,6 +17,11 @@
17
17
  * JSON Schema type keeps it.
18
18
  */
19
19
  export declare const STREAM_FORMAT = "stream";
20
+ /**
21
+ * A control frame, `{"$clear": "audio"}`: drop what has been buffered of a
22
+ * live output field. Reserved keys start with `$`, which no field name can.
23
+ */
24
+ export declare const CLEAR_KEY = "$clear";
20
25
  /** The part of JSON Schema these helpers read. */
21
26
  export interface JsonSchema {
22
27
  $ref?: string;
@@ -17,6 +17,11 @@
17
17
  * JSON Schema type keeps it.
18
18
  */
19
19
  export const STREAM_FORMAT = 'stream';
20
+ /**
21
+ * A control frame, `{"$clear": "audio"}`: drop what has been buffered of a
22
+ * live output field. Reserved keys start with `$`, which no field name can.
23
+ */
24
+ export const CLEAR_KEY = '$clear';
20
25
  export function isLiveField(schema) {
21
26
  return !!schema && schema.format === STREAM_FORMAT;
22
27
  }
@@ -27,6 +27,12 @@ export interface LiveHandlers {
27
27
  onBinary?: (data: ArrayBuffer) => void;
28
28
  /** A partial output object keyed by field name. */
29
29
  onPatch?: (patch: Record<string, unknown>) => void;
30
+ /**
31
+ * Drop what you have buffered of this live output field: the app sends it
32
+ * when an answer is cut short, e.g. the user talked over it. Without this
33
+ * handler the control frame reaches onPatch as `{"$clear": field}`.
34
+ */
35
+ onClear?: (field: string) => void;
30
36
  }
31
37
  /**
32
38
  * Follows the task the socket belongs to. `done` settles when the task ends
@@ -1,3 +1,4 @@
1
+ import { CLEAR_KEY } from './schema';
1
2
  const WS_OPEN = 1;
2
3
  // 1012: the relay is restarting and closed an end that still waited for its
3
4
  // peer. 1013: the peer did not come in time. Both mean "dial again" while the
@@ -63,7 +64,15 @@ export class LiveSession {
63
64
  patch = { text: event.data };
64
65
  }
65
66
  if (patch && typeof patch === 'object' && !Array.isArray(patch)) {
66
- this.handlers.onPatch?.(patch);
67
+ const record = patch;
68
+ const clear = record[CLEAR_KEY];
69
+ if (this.handlers.onClear && typeof clear === 'string') {
70
+ this.handlers.onClear(clear);
71
+ delete record[CLEAR_KEY];
72
+ if (Object.keys(record).length === 0)
73
+ return;
74
+ }
75
+ this.handlers.onPatch?.(record);
67
76
  }
68
77
  }
69
78
  else {
package/dist/types.d.ts CHANGED
@@ -1093,13 +1093,28 @@ export interface SecretRequirement {
1093
1093
  optional?: boolean;
1094
1094
  }
1095
1095
  /**
1096
- * CredentialRequirement defines a credential that an app requires.
1097
- * Key is the provider slug (e.g. "bytedance", "google").
1098
- * Secrets lists the specific env var names to inject from this credential.
1099
- * Scopes lists OAuth scopes needed (for OAuth credentials).
1096
+ * CredentialRequirement is an entry under credentials: in inf.yml: keys an
1097
+ * app needs that belong to a provider. Provider names whose credential
1098
+ * supplies them; Secrets lists the keys to inject from it (an API key
1099
+ * credential), Scopes what to ask for (an OAuth one).
1100
+ * credentials:
1101
+ * - provider: acme
1102
+ * name: Acme CRM
1103
+ * website: acme.com
1104
+ * secrets: [ACME_API_KEY]
1105
+ * Key is a capability of a provider the platform defines ("x.tweet.read",
1106
+ * "google.sheets"): an OAuth grant with the scopes it implies. An entry sets
1107
+ * Provider, Key, or both; with both, Key decides how it is resolved.
1100
1108
  */
1101
1109
  export interface CredentialRequirement {
1102
- key: string;
1110
+ provider?: string;
1111
+ /**
1112
+ * Name and Website describe a provider the platform does not list: the
1113
+ * name its credential is shown under and the site its logo comes from.
1114
+ */
1115
+ name?: string;
1116
+ website?: string;
1117
+ key?: string;
1103
1118
  description?: string;
1104
1119
  optional?: boolean;
1105
1120
  secrets?: string[];
@@ -3193,6 +3208,16 @@ export interface SetupAction {
3193
3208
  scope_descriptions?: {
3194
3209
  [key: string]: string;
3195
3210
  };
3211
+ /**
3212
+ * Secrets are the keys to supply for an add_secret action on a
3213
+ * provider: saved against Provider, they become its credential.
3214
+ */
3215
+ secrets?: string[];
3216
+ /**
3217
+ * ProviderWebsite is where the logo of a provider the platform does not
3218
+ * list comes from; sent back when the keys are saved.
3219
+ */
3220
+ provider_website?: string;
3196
3221
  }
3197
3222
  /**
3198
3223
  * CheckRequirementsRequest is the request body for checking requirements
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inferencesh/sdk",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
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",