@inferencesh/sdk 0.8.3 → 0.10.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/README.md CHANGED
@@ -523,6 +523,14 @@ const output = await agent.run('Analyze: Great product!');
523
523
  | `disconnect()` | Stop active stream/poll connections |
524
524
  | `reset()` | Disconnect and clear chat state so the next message starts a new chat |
525
525
 
526
+ Messages that arrive through a channel integration (Slack, Telegram, a wearable) can carry `channel_context` so the reply is routed back the same way. The API records it on the chat the first time it sees it, so later turns inherit it:
527
+
528
+ ```typescript
529
+ await agent.sendMessage(text, {
530
+ channel_context: { channel_type: 'slack', channel_metadata: { channel: 'C123', thread_ts: '1700000000.000100' } },
531
+ });
532
+ ```
533
+
526
534
  ## API Reference
527
535
 
528
536
  ### `inference(config)`
@@ -1,7 +1,7 @@
1
1
  import { HttpClient } from '../http/client';
2
2
  import type { Response } from '../http/response';
3
3
  import { FilesAPI } from './files';
4
- import { ChatDTO, ChatMessageDTO, LLMDelta, LLMOutput, AgentConfigInput as AgentConfig, AgentDTO, AgentVersionDTO, CreateAgentRequest, FileDTO as File, InterruptDTO, CursorListRequest, CursorListResponse } from '../types';
4
+ import { ChatDTO, ChatMessageDTO, ChannelContext, LLMDelta, LLMOutput, AgentConfigInput as AgentConfig, AgentDTO, AgentVersionDTO, CreateAgentRequest, FileDTO as File, InterruptDTO, CursorListRequest, CursorListResponse } from '../types';
5
5
  /** Internal tool definition returned by getInternalTools */
6
6
  export interface InternalToolDefinition {
7
7
  id: string;
@@ -65,6 +65,14 @@ export interface SendMessageOptions {
65
65
  * cannot resolve those is the typical caller.
66
66
  */
67
67
  signal?: AbortSignal;
68
+ /**
69
+ * The channel this message came through (slack, telegram, a wearable...):
70
+ * `channel_type` plus whatever `channel_metadata` the integration needs to
71
+ * route the reply (thread ids, chat ids). Sent as `channel_context` on the
72
+ * message; the API records it on the chat the first time it sees it, so
73
+ * later turns in that chat inherit the routing.
74
+ */
75
+ channel_context?: ChannelContext;
68
76
  }
69
77
  export interface AgentRunOptions extends Omit<SendMessageOptions, 'stream'> {
70
78
  /** Polling interval in ms (default: 2000) */
@@ -100,6 +100,9 @@ export class Agent {
100
100
  context: this.context,
101
101
  input: { text, images: imageUris, files: fileUris, role: 'user', context: [], system_prompt: '', context_size: 0 },
102
102
  };
103
+ if (options.channel_context !== undefined) {
104
+ body.channel_context = options.channel_context;
105
+ }
103
106
  const useStream = options.stream ?? this.http.getStreamDefault();
104
107
  const shouldWait = useStream === false || hasCallbacks;
105
108
  const gate = new TurnGate(!!this.chatId);
@@ -95,12 +95,14 @@ export class LiveSession {
95
95
  const { onClear, onError } = this.handlers;
96
96
  if (onClear && typeof record[CLEAR_KEY] === 'string') {
97
97
  onClear(record[CLEAR_KEY]);
98
+ // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
98
99
  delete record[CLEAR_KEY];
99
100
  }
100
101
  if (onError) {
101
102
  const key = ERROR_KEY in record ? ERROR_KEY : this.legacyError(record) ? 'error' : undefined;
102
103
  if (key) {
103
104
  const err = record[key];
105
+ // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
104
106
  delete record[key];
105
107
  const { field = null, message } = (err && typeof err === 'object' ? err : { message: String(err) });
106
108
  onError(field, typeof message === 'string' ? message : JSON.stringify(err));
package/dist/types.d.ts CHANGED
@@ -585,12 +585,21 @@ export interface CredentialConnectRequest {
585
585
  */
586
586
  connection_scope?: CredentialScope;
587
587
  }
588
+ /**
589
+ * CredentialCompleteOAuthRequest is what the provider's redirect delivered:
590
+ * the code and state, the PKCE verifier the client kept, and every other
591
+ * query param the callback carried (QuickBooks' realmId, Shopify's shop),
592
+ * which a scheme reads as {{callback.*}}.
593
+ */
588
594
  export interface CredentialCompleteOAuthRequest {
589
595
  provider: string;
590
596
  type: string;
591
597
  code: string;
592
598
  state: string;
593
599
  code_verifier?: string;
600
+ params?: {
601
+ [key: string]: string;
602
+ };
594
603
  }
595
604
  export interface CredentialConnectResponse {
596
605
  credential?: CredentialDTO;
@@ -1579,7 +1588,6 @@ export interface PermissionModelDTO {
1579
1588
  user?: UserRelationDTO;
1580
1589
  team_id: string;
1581
1590
  team?: TeamRelationDTO;
1582
- org_id?: string;
1583
1591
  visibility: Visibility;
1584
1592
  }
1585
1593
  /**
@@ -1727,7 +1735,8 @@ export interface ChatMessageDTO extends BaseModelDTO, PermissionModelDTO {
1727
1735
  export interface CredentialDTO extends BaseModelDTO, PermissionModelDTO {
1728
1736
  provider: string;
1729
1737
  type: CredentialType;
1730
- grant?: CredentialGrant;
1738
+ grant: CredentialGrant;
1739
+ app_credential_id?: string;
1731
1740
  scope: CredentialScope;
1732
1741
  status: CredentialStatus;
1733
1742
  display_name: string;
@@ -1760,7 +1769,19 @@ export interface CredentialConfigDTO {
1760
1769
  allows_byok: boolean;
1761
1770
  available: boolean;
1762
1771
  has_managed: boolean;
1763
- grant?: CredentialGrant;
1772
+ /**
1773
+ * ConnectionScope is who a new connection belongs to by default: the
1774
+ * team, or each user (their own account).
1775
+ */
1776
+ connection_scope: CredentialScope;
1777
+ /**
1778
+ * App is the OAuth app a login to this provider goes through (a
1779
+ * grant=credentials row): the workspace's own, its org's or the
1780
+ * platform's. Nil when the provider signs in through an app and none is
1781
+ * set up yet, or when it doesn't sign in through one. Credential is the
1782
+ * login itself.
1783
+ */
1784
+ app?: CredentialDTO;
1764
1785
  /**
1765
1786
  * AuthSchemeID is set when the provider is one the team defined
1766
1787
  * itself (models.AuthScheme), so the UI can offer edit and remove.
@@ -2741,7 +2762,6 @@ export interface MCPServerDTO {
2741
2762
  user?: UserRelationDTO;
2742
2763
  team_id: string;
2743
2764
  team?: TeamRelationDTO;
2744
- org_id?: string;
2745
2765
  visibility: Visibility;
2746
2766
  slug: string;
2747
2767
  name: string;
@@ -3599,6 +3619,14 @@ export interface TeamMemberDTO {
3599
3619
  team_id: string;
3600
3620
  role: TeamRole;
3601
3621
  user?: TeamMemberUserDTO;
3622
+ /**
3623
+ * AssignableRoles are the roles the caller may set this member to, the
3624
+ * current one included; Removable, whether the caller may remove them.
3625
+ * Set on GET /teams/{id}/members by the rules the member writes enforce;
3626
+ * absent means none.
3627
+ */
3628
+ assignable_roles?: TeamRole[];
3629
+ removable?: boolean;
3602
3630
  }
3603
3631
  /**
3604
3632
  * TeamMemberUserDTO is a lightweight user view within team membership.
@@ -4755,10 +4783,20 @@ export declare const CredentialScopeTeam: CredentialScope;
4755
4783
  export declare const CredentialScopeUser: CredentialScope;
4756
4784
  export declare const CredentialScopeAgent: CredentialScope;
4757
4785
  /**
4758
- * CredentialGrant describes what a credential provides.
4786
+ * CredentialGrant is which layer a credential row is. OAuth has two: the
4787
+ * app (client id and secret, owned by the platform, an org or a team) and
4788
+ * the logins made through it (owned by a team or a user). Every other
4789
+ * credential type is a token row.
4759
4790
  */
4760
4791
  export type CredentialGrant = string;
4792
+ /**
4793
+ * CredentialGrantCredentials: an OAuth app. Never a connection.
4794
+ */
4761
4795
  export declare const CredentialGrantCredentials: CredentialGrant;
4796
+ /**
4797
+ * CredentialGrantToken: a connection: an OAuth login, an API key, a
4798
+ * service account, an MCP authorization.
4799
+ */
4762
4800
  export declare const CredentialGrantToken: CredentialGrant;
4763
4801
  /**
4764
4802
  * NotificationChannel represents a delivery channel
package/dist/types.js CHANGED
@@ -856,7 +856,14 @@ export const CredentialScopeOrg = "org";
856
856
  export const CredentialScopeTeam = "team";
857
857
  export const CredentialScopeUser = "user";
858
858
  export const CredentialScopeAgent = "agent";
859
+ /**
860
+ * CredentialGrantCredentials: an OAuth app. Never a connection.
861
+ */
859
862
  export const CredentialGrantCredentials = "credentials";
863
+ /**
864
+ * CredentialGrantToken: a connection: an OAuth login, an API key, a
865
+ * service account, an MCP authorization.
866
+ */
860
867
  export const CredentialGrantToken = "token";
861
868
  export const NotificationChannelEmail = "email";
862
869
  export const NotificationChannelSMS = "sms";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inferencesh/sdk",
3
- "version": "0.8.3",
3
+ "version": "0.10.0",
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",
@@ -73,10 +73,10 @@
73
73
  "url": "https://github.com/inference-sh/sdk-js/issues"
74
74
  },
75
75
  "engines": {
76
- "node": ">=18.0.0"
76
+ "node": ">=22.12.0"
77
77
  },
78
78
  "dependencies": {
79
- "eventsource": "^4.0.0"
79
+ "eventsource": "^5.1.1"
80
80
  },
81
81
  "devDependencies": {
82
82
  "@sveltejs/kit": "^2.60.1",
@@ -84,12 +84,12 @@
84
84
  "@types/jest": "^30.0.0",
85
85
  "@types/node": "^26.1.1",
86
86
  "@types/react": "^19.1.12",
87
- "@eslint/js": "^9.39.5",
87
+ "@eslint/js": "^10.0.1",
88
88
  "@typescript-eslint/eslint-plugin": "^8.65.0",
89
89
  "@typescript-eslint/parser": "^8.65.0",
90
- "eslint": "^9.32.0",
90
+ "eslint": "^10.10.0",
91
91
  "eslint-config-prettier": "^10.1.8",
92
- "globals": "^16.5.0",
92
+ "globals": "^17.12.0",
93
93
  "hono": "^4.13.1",
94
94
  "jest": "^30.4.2",
95
95
  "next": "^16.2.6",