@inferencesh/sdk 0.6.29 → 0.6.47

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 (53) hide show
  1. package/README.md +35 -0
  2. package/dist/agent/actions.js +72 -13
  3. package/dist/agent/api.d.ts +30 -51
  4. package/dist/agent/api.js +129 -154
  5. package/dist/agent/provider.js +18 -1
  6. package/dist/agent/reducer.js +50 -11
  7. package/dist/agent/types.d.ts +34 -1
  8. package/dist/api/agents.d.ts +23 -14
  9. package/dist/api/agents.js +22 -4
  10. package/dist/api/api-keys.d.ts +4 -3
  11. package/dist/api/apps.d.ts +16 -15
  12. package/dist/api/chats.d.ts +14 -9
  13. package/dist/api/chats.js +6 -0
  14. package/dist/api/engines.d.ts +14 -13
  15. package/dist/api/files.d.ts +4 -3
  16. package/dist/api/files.js +2 -2
  17. package/dist/api/flow-runs.d.ts +8 -7
  18. package/dist/api/flows.d.ts +11 -10
  19. package/dist/api/integrations.d.ts +9 -8
  20. package/dist/api/integrations.js +8 -8
  21. package/dist/api/knowledge.d.ts +25 -24
  22. package/dist/api/mcp-servers.d.ts +10 -9
  23. package/dist/api/projects.d.ts +6 -5
  24. package/dist/api/search.d.ts +3 -2
  25. package/dist/api/secrets.d.ts +6 -5
  26. package/dist/api/sessions.d.ts +5 -4
  27. package/dist/api/sessions.js +2 -3
  28. package/dist/api/tasks.d.ts +14 -11
  29. package/dist/api/tasks.js +10 -4
  30. package/dist/api/teams.d.ts +16 -17
  31. package/dist/delta.d.ts +15 -0
  32. package/dist/delta.js +84 -0
  33. package/dist/hook-builder.d.ts +23 -0
  34. package/dist/hook-builder.js +50 -0
  35. package/dist/http/client.d.ts +9 -1
  36. package/dist/http/client.js +12 -3
  37. package/dist/http/response.d.ts +9 -0
  38. package/dist/http/response.js +1 -0
  39. package/dist/http/stream.d.ts +1 -0
  40. package/dist/http/stream.js +8 -3
  41. package/dist/http/streamable.d.ts +3 -1
  42. package/dist/http/streamable.js +10 -1
  43. package/dist/index.d.ts +11 -5
  44. package/dist/index.js +6 -1
  45. package/dist/proxy/index.d.ts +2 -0
  46. package/dist/proxy/index.js +9 -0
  47. package/dist/tool-builder.d.ts +2 -0
  48. package/dist/tool-builder.js +5 -0
  49. package/dist/types.d.ts +1204 -162
  50. package/dist/types.js +256 -30
  51. package/dist/utils.d.ts +13 -0
  52. package/dist/utils.js +43 -3
  53. package/package.json +8 -5
@@ -9,6 +9,8 @@ import { useReducer, useRef, useEffect, useMemo } from 'react';
9
9
  import { AgentChatContext } from './context';
10
10
  import { chatReducer, initialState } from './reducer';
11
11
  import { createActions, getClientToolHandlers } from './actions';
12
+ import { fetchAgentInfo } from './api';
13
+ import { isTemplateConfig } from './types';
12
14
  function mergeHandlers(base, extra) {
13
15
  if (!extra || extra.size === 0)
14
16
  return base;
@@ -62,7 +64,9 @@ export function AgentChatProvider({ client, agentConfig, chatId, clientToolHandl
62
64
  streamRef.current = stream;
63
65
  pollIntervalMsRef.current = pollIntervalMs;
64
66
  }, [stream, pollIntervalMs]);
65
- // Keep chatIdRef synced with state
67
+ // Keep refs synced with state
68
+ const stateRef = useRef(state);
69
+ stateRef.current = state;
66
70
  useEffect(() => {
67
71
  chatIdRef.current = state.chatId;
68
72
  }, [state.chatId]);
@@ -70,6 +74,7 @@ export function AgentChatProvider({ client, agentConfig, chatId, clientToolHandl
70
74
  const actionsContext = useMemo(() => ({
71
75
  client,
72
76
  dispatch,
77
+ getState: () => stateRef.current,
73
78
  getConfig: () => configRef.current,
74
79
  getChatId: () => chatIdRef.current,
75
80
  getClientToolHandlers: () => clientToolHandlersRef.current,
@@ -88,6 +93,18 @@ export function AgentChatProvider({ client, agentConfig, chatId, clientToolHandl
88
93
  actionsResultRef.current = createActions(actionsContext);
89
94
  }
90
95
  const { publicActions, internalActions } = actionsResultRef.current;
96
+ // Fetch agent info for template configs (example_prompts, description)
97
+ const agentRef = isTemplateConfig(agentConfig) ? agentConfig.agent : null;
98
+ useEffect(() => {
99
+ if (!agentRef)
100
+ return;
101
+ let stale = false;
102
+ fetchAgentInfo(client, agentRef).then((info) => {
103
+ if (info && !stale)
104
+ dispatch({ type: 'SET_AGENT_INFO', payload: info });
105
+ });
106
+ return () => { stale = true; };
107
+ }, [client, agentRef]);
91
108
  // Handle initial chatId or chatId changes
92
109
  useEffect(() => {
93
110
  if (chatId && chatId !== state.chatId) {
@@ -3,6 +3,16 @@
3
3
  *
4
4
  * Pure reducer for managing agent chat state.
5
5
  */
6
+ import { ChatStatusBusy, ChatStatusAwaitingInput, ChatStatusIdle, AgentRunStateWorking, AgentRunStateSubmitted } from '../types';
7
+ function deriveChatStatus(run) {
8
+ if (!run)
9
+ return ChatStatusIdle;
10
+ if (run.state === AgentRunStateWorking || run.state === AgentRunStateSubmitted)
11
+ return ChatStatusBusy;
12
+ if (run.state === 'input_required' || run.state === 'auth_required')
13
+ return ChatStatusAwaitingInput;
14
+ return ChatStatusIdle;
15
+ }
6
16
  // =============================================================================
7
17
  // Initial State
8
18
  // =============================================================================
@@ -12,6 +22,8 @@ export const initialState = {
12
22
  connectionStatus: 'idle',
13
23
  error: undefined,
14
24
  chat: null,
25
+ messageCursor: undefined,
26
+ hasOlderMessages: undefined,
15
27
  };
16
28
  // =============================================================================
17
29
  // Reducer
@@ -23,10 +35,12 @@ export function chatReducer(state, action) {
23
35
  case 'SET_CHAT': {
24
36
  const chat = action.payload;
25
37
  if (!chat) {
26
- return { ...state, chat: null, messages: [], connectionStatus: 'idle' };
38
+ return { ...state, chat: null, messages: [], connectionStatus: 'idle', messageCursor: undefined, hasOlderMessages: undefined };
27
39
  }
28
40
  const messages = [...(chat.chat_messages || [])].sort((a, b) => a.order - b.order);
29
- return { ...state, chat, messages };
41
+ const cursor = chat?._messageCursor;
42
+ const hasOlder = chat?._hasOlderMessages;
43
+ return { ...state, chat, messages, messageCursor: cursor, hasOlderMessages: hasOlder };
30
44
  }
31
45
  case 'UPDATE_CHAT': {
32
46
  // Update chat metadata without replacing messages
@@ -38,34 +52,59 @@ export function chatReducer(state, action) {
38
52
  case 'UPDATE_ACTIVE_RUN': {
39
53
  if (!state.chat)
40
54
  return state;
41
- return { ...state, chat: { ...state.chat, active_run: action.payload } };
55
+ return { ...state, chat: { ...state.chat, active_run: action.payload, status: deriveChatStatus(action.payload) } };
42
56
  }
43
57
  case 'SET_MESSAGES':
44
58
  return { ...state, messages: action.payload };
59
+ case 'PREPEND_MESSAGES': {
60
+ const { messages: older, cursor, hasMore } = action.payload;
61
+ const existingIds = new Set(state.messages.map(m => m.id));
62
+ const deduped = older.filter(m => !existingIds.has(m.id));
63
+ const merged = [...deduped, ...state.messages].sort((a, b) => a.order - b.order);
64
+ return { ...state, messages: merged, messageCursor: cursor, hasOlderMessages: hasMore };
65
+ }
45
66
  case 'UPDATE_MESSAGE': {
46
67
  const message = action.payload;
47
68
  const existingIndex = state.messages.findIndex((m) => m.id === message.id);
48
- let newMessages;
49
69
  if (existingIndex !== -1) {
50
- newMessages = [...state.messages];
51
- newMessages[existingIndex] = message;
70
+ const existing = state.messages[existingIndex];
71
+ const updated = action.partial ? { ...existing, ...message } : message;
72
+ if (existing === updated)
73
+ return state;
74
+ const newMessages = [...state.messages];
75
+ newMessages[existingIndex] = updated;
76
+ return { ...state, messages: newMessages };
52
77
  }
53
- else {
54
- newMessages = [...state.messages, message].sort((a, b) => a.order - b.order);
55
- }
56
- return { ...state, messages: newMessages };
78
+ if (action.partial)
79
+ return state;
80
+ return { ...state, messages: [...state.messages, message].sort((a, b) => a.order - b.order) };
57
81
  }
58
82
  case 'ADD_MESSAGE':
59
83
  return {
60
84
  ...state,
61
85
  messages: [...state.messages, action.payload].sort((a, b) => a.order - b.order),
62
86
  };
87
+ case 'DELTA_TOKEN': {
88
+ const output = action.payload;
89
+ const msgs = state.messages;
90
+ const lastAssistant = [...msgs].reverse().find(m => m.role === 'assistant');
91
+ if (!lastAssistant)
92
+ return state;
93
+ const textBlock = lastAssistant.content?.find(c => c.type === 'text');
94
+ const newContent = textBlock
95
+ ? lastAssistant.content.map(c => c.type === 'text' ? { ...c, text: output.response } : c)
96
+ : [{ type: 'text', text: output.response }, ...lastAssistant.content];
97
+ const newMessages = msgs.map(m => m.id === lastAssistant.id ? { ...lastAssistant, content: newContent } : m);
98
+ return { ...state, messages: newMessages };
99
+ }
63
100
  case 'SET_CONNECTION_STATUS':
64
101
  return { ...state, connectionStatus: action.payload };
65
102
  case 'SET_ERROR':
66
103
  return { ...state, error: action.payload };
104
+ case 'SET_AGENT_INFO':
105
+ return { ...state, agentInfo: action.payload };
67
106
  case 'RESET':
68
- return initialState;
107
+ return { ...initialState, agentInfo: state.agentInfo };
69
108
  default:
70
109
  return state;
71
110
  }
@@ -4,7 +4,7 @@
4
4
  * Public types for the Agent chat module.
5
5
  */
6
6
  import type { Dispatch } from 'react';
7
- import type { AgentRunDTO, ChatDTO, ChatMessageDTO, AgentTool, AgentConfigInput as GeneratedAgentConfig, CoreAppConfigInput as CoreAppConfig, FileRef } from '../types';
7
+ import type { AgentRunDTO, AgentVersionDTO, ChatDTO, ChatMessageDTO, AgentTool, AgentConfigInput as GeneratedAgentConfig, CoreAppConfigInput as CoreAppConfig, FileRef } from '../types';
8
8
  import type { HttpClient } from '../http/client';
9
9
  import type { StreamableManager } from '../http/streamable';
10
10
  import type { PollManager } from '../http/poll';
@@ -81,6 +81,10 @@ export declare function isAdHocConfig(config: AgentOptions): config is AdHocAgen
81
81
  * Type guard to check if config is template-based
82
82
  */
83
83
  export declare function isTemplateConfig(config: AgentOptions): config is TemplateAgentConfig;
84
+ /**
85
+ * Agent metadata fetched from the backend for template configs
86
+ */
87
+ export type AgentInfo = Partial<Pick<AgentVersionDTO, 'description' | 'example_prompts'>>;
84
88
  /**
85
89
  * Status of the chat
86
90
  */
@@ -99,6 +103,12 @@ export interface AgentChatState {
99
103
  error?: string;
100
104
  /** The full chat object (if loaded) */
101
105
  chat: ChatDTO | null;
106
+ /** Cursor for loading older messages */
107
+ messageCursor?: string;
108
+ /** Whether older messages exist beyond the current page */
109
+ hasOlderMessages?: boolean;
110
+ /** Agent info fetched from the backend (description, example_prompts) */
111
+ agentInfo?: AgentInfo;
102
112
  }
103
113
  /**
104
114
  * Actions available for interacting with the chat
@@ -122,6 +132,14 @@ export interface AgentChatActions {
122
132
  rejectTool: (toolInvocationId: string, reason?: string) => Promise<void>;
123
133
  /** Always allow a tool for this chat (approves + auto-approves future invocations) */
124
134
  alwaysAllowTool: (toolInvocationId: string, toolName: string) => Promise<void>;
135
+ /** Cancel a queued message before the agent processes it */
136
+ cancelMessage: (messageId: string) => Promise<void>;
137
+ /** Resolve an interrupt gate (allow or deny) */
138
+ resolveInterrupt: (interruptId: string, decision: 'allow' | 'deny') => Promise<void>;
139
+ /** Load older messages (scroll-up pagination). Returns true if more exist. */
140
+ loadOlderMessages: () => Promise<boolean>;
141
+ /** Whether there are older messages to load */
142
+ hasOlderMessages: boolean;
125
143
  }
126
144
  /**
127
145
  * Props for the AgentChatProvider
@@ -196,15 +214,29 @@ export type ChatAction = {
196
214
  } | {
197
215
  type: 'UPDATE_MESSAGE';
198
216
  payload: ChatMessageDTO;
217
+ partial?: boolean;
199
218
  } | {
200
219
  type: 'ADD_MESSAGE';
201
220
  payload: ChatMessageDTO;
221
+ } | {
222
+ type: 'DELTA_TOKEN';
223
+ payload: Record<string, any>;
202
224
  } | {
203
225
  type: 'SET_CONNECTION_STATUS';
204
226
  payload: ChatStatus;
205
227
  } | {
206
228
  type: 'SET_ERROR';
207
229
  payload: string | undefined;
230
+ } | {
231
+ type: 'PREPEND_MESSAGES';
232
+ payload: {
233
+ messages: ChatMessageDTO[];
234
+ cursor?: string;
235
+ hasMore: boolean;
236
+ };
237
+ } | {
238
+ type: 'SET_AGENT_INFO';
239
+ payload: AgentInfo;
208
240
  } | {
209
241
  type: 'RESET';
210
242
  };
@@ -216,6 +248,7 @@ export type UpdateManager = StreamableManager<unknown> | PollManager<unknown>;
216
248
  export interface ActionsContext {
217
249
  client: AgentClient;
218
250
  dispatch: Dispatch<ChatAction>;
251
+ getState: () => AgentChatState;
219
252
  getConfig: () => AgentOptions | null;
220
253
  getChatId: () => string | null;
221
254
  getClientToolHandlers: () => Map<string, ClientToolHandlerFn>;
@@ -1,6 +1,7 @@
1
1
  import { HttpClient } from '../http/client';
2
+ import type { Response } from '../http/response';
2
3
  import { FilesAPI } from './files';
3
- import { ChatDTO, ChatMessageDTO, AgentConfigInput as AgentConfig, AgentDTO, AgentVersionDTO, CreateAgentRequest, FileDTO as File, CursorListRequest, CursorListResponse } from '../types';
4
+ import { ChatDTO, ChatMessageDTO, AgentConfigInput as AgentConfig, AgentDTO, AgentVersionDTO, CreateAgentRequest, FileDTO as File, InterruptDTO, CursorListRequest, CursorListResponse } from '../types';
4
5
  /** Internal tool definition returned by getInternalTools */
5
6
  export interface InternalToolDefinition {
6
7
  id: string;
@@ -107,57 +108,57 @@ export declare class AgentsAPI {
107
108
  /**
108
109
  * List agent templates with cursor-based pagination
109
110
  */
110
- list(params?: Partial<CursorListRequest>): Promise<CursorListResponse<AgentDTO>>;
111
+ list(params?: Partial<CursorListRequest>): Promise<Response<CursorListResponse<AgentDTO>>>;
111
112
  /**
112
113
  * Get an agent template by ID
113
114
  */
114
- get(agentId: string): Promise<AgentDTO>;
115
+ get(agentId: string): Promise<Response<AgentDTO>>;
115
116
  /**
116
117
  * Create a new agent template or create a new version of an existing agent
117
118
  */
118
- createAgent(data: CreateAgentRequest): Promise<AgentDTO>;
119
+ createAgent(data: CreateAgentRequest): Promise<Response<AgentDTO>>;
119
120
  /**
120
121
  * Update an agent template
121
122
  */
122
- update(agentId: string, data: Partial<AgentDTO>): Promise<AgentDTO>;
123
+ update(agentId: string, data: Partial<AgentDTO>): Promise<Response<AgentDTO>>;
123
124
  /**
124
125
  * Delete an agent template
125
126
  */
126
- delete(agentId: string): Promise<void>;
127
+ delete(agentId: string): Promise<Response<void>>;
127
128
  /**
128
129
  * Duplicate an agent template
129
130
  */
130
- duplicate(agentId: string): Promise<AgentDTO>;
131
+ duplicate(agentId: string): Promise<Response<AgentDTO>>;
131
132
  /**
132
133
  * List agent template versions
133
134
  */
134
- listVersions(agentId: string, params?: Partial<CursorListRequest>): Promise<CursorListResponse<AgentVersionDTO>>;
135
+ listVersions(agentId: string, params?: Partial<CursorListRequest>): Promise<Response<CursorListResponse<AgentVersionDTO>>>;
135
136
  /**
136
137
  * Transfer agent ownership to another team
137
138
  */
138
- transferOwnership(agentId: string, newTeamId: string): Promise<AgentDTO>;
139
+ transferOwnership(agentId: string, newTeamId: string): Promise<Response<AgentDTO>>;
139
140
  /**
140
141
  * Update agent visibility
141
142
  */
142
- updateVisibility(agentId: string, visibility: string): Promise<AgentDTO>;
143
+ updateVisibility(agentId: string, visibility: string): Promise<Response<AgentDTO>>;
143
144
  /**
144
145
  * Get a specific agent version
145
146
  */
146
- getVersion(agentId: string, versionId: string): Promise<AgentVersionDTO>;
147
+ getVersion(agentId: string, versionId: string): Promise<Response<AgentVersionDTO>>;
147
148
  /**
148
149
  * Get an agent by namespace/name (e.g., "inference/my-agent")
149
150
  */
150
- getByName(namespace: string, name: string): Promise<AgentDTO>;
151
+ getByName(namespace: string, name: string): Promise<Response<AgentDTO>>;
151
152
  /**
152
153
  * Get internal tools for the agent
153
154
  */
154
- getInternalTools(): Promise<InternalToolDefinition[]>;
155
+ getInternalTools(): Promise<Response<InternalToolDefinition[]>>;
155
156
  /**
156
157
  * Get A2A protocol agent card for an agent.
157
158
  * Returns raw JSON (not wrapped in {data:...}) for direct upload to GCP Producer Portal.
158
159
  * Spec: https://a2a-protocol.org/latest/specification/
159
160
  */
160
- getA2ACard(agentId: string): Promise<Record<string, unknown>>;
161
+ getA2ACard(agentId: string): Promise<Response<Record<string, unknown>>>;
161
162
  /**
162
163
  * Create an agent instance for chat interactions
163
164
  */
@@ -172,5 +173,13 @@ export declare class AgentsAPI {
172
173
  };
173
174
  form_data?: Record<string, unknown>;
174
175
  }): Promise<void>;
176
+ /**
177
+ * Resolve an interrupt gate on an agent run
178
+ */
179
+ resolveInterrupt(interruptId: string, decision: 'allow' | 'deny'): Promise<Response<InterruptDTO>>;
180
+ /**
181
+ * List pending interrupts for an agent run
182
+ */
183
+ listRunInterrupts(runId: string): Promise<Response<InterruptDTO[]>>;
175
184
  }
176
185
  export declare function createAgentsAPI(http: HttpClient, files: FilesAPI): AgentsAPI;
@@ -77,7 +77,8 @@ export class Agent {
77
77
  waitPromise = waitFn(options);
78
78
  }
79
79
  // Make the POST request
80
- const response = await this.http.request('post', '/agents/run', { data: body });
80
+ const resp = await this.http.request('post', '/agents/run', { data: body });
81
+ const response = resp.data;
81
82
  // For new chats: Set chatId and start waiting immediately after POST
82
83
  const isNewChat = !this.chatId && response.assistant_message.chat_id;
83
84
  if (isNewChat) {
@@ -97,7 +98,8 @@ export class Agent {
97
98
  const id = chatId || this.chatId;
98
99
  if (!id)
99
100
  return null;
100
- return this.http.request('get', `/chats/${id}`);
101
+ const resp = await this.http.request('get', `/chats/${id}`);
102
+ return resp.data;
101
103
  }
102
104
  /** Stop the current chat generation */
103
105
  async stopChat() {
@@ -202,13 +204,15 @@ export class Agent {
202
204
  this.poller = new PollManager({
203
205
  pollFunction: async () => {
204
206
  // Lightweight status check first
205
- const status = await this.http.request('get', `/chats/${this.chatId}/status`);
207
+ const statusResp = await this.http.request('get', `/chats/${this.chatId}/status`);
208
+ const status = statusResp.data;
206
209
  if (status.status === prevStatus) {
207
210
  // No change — return a stub to skip processing
208
211
  return { status: status.status };
209
212
  }
210
213
  // Status changed — fetch full chat
211
- return this.http.request('get', `/chats/${this.chatId}`);
214
+ const chatResp = await this.http.request('get', `/chats/${this.chatId}`);
215
+ return chatResp.data;
212
216
  },
213
217
  intervalMs,
214
218
  onData: (chat) => {
@@ -365,6 +369,20 @@ export class AgentsAPI {
365
369
  const result = typeof resultOrAction === 'string' ? resultOrAction : JSON.stringify(resultOrAction);
366
370
  await this.http.request('post', `/tools/${toolInvocationId}`, { data: { result } });
367
371
  }
372
+ /**
373
+ * Resolve an interrupt gate on an agent run
374
+ */
375
+ async resolveInterrupt(interruptId, decision) {
376
+ return this.http.request('post', `/interrupts/${interruptId}/resolve`, {
377
+ data: { decision }
378
+ });
379
+ }
380
+ /**
381
+ * List pending interrupts for an agent run
382
+ */
383
+ async listRunInterrupts(runId) {
384
+ return this.http.request('get', `/agent-runs/${runId}/interrupts`);
385
+ }
368
386
  }
369
387
  export function createAgentsAPI(http, files) {
370
388
  return new AgentsAPI(http, files);
@@ -1,4 +1,5 @@
1
1
  import { HttpClient } from '../http/client';
2
+ import type { Response } from '../http/response';
2
3
  import { ApiKeyDTO, CursorListRequest, CursorListResponse } from '../types';
3
4
  /**
4
5
  * API Keys API
@@ -9,16 +10,16 @@ export declare class ApiKeysAPI {
9
10
  /**
10
11
  * List API keys with cursor-based pagination
11
12
  */
12
- list(params?: Partial<CursorListRequest>): Promise<CursorListResponse<ApiKeyDTO>>;
13
+ list(params?: Partial<CursorListRequest>): Promise<Response<CursorListResponse<ApiKeyDTO>>>;
13
14
  /**
14
15
  * Create an API key
15
16
  */
16
17
  create(data: {
17
18
  name: string;
18
19
  scopes?: string[];
19
- }): Promise<ApiKeyDTO>;
20
+ }): Promise<Response<ApiKeyDTO>>;
20
21
  /**
21
22
  * Delete an API key
22
23
  */
23
- delete(id: string): Promise<void>;
24
+ delete(id: string): Promise<Response<void>>;
24
25
  }
@@ -1,4 +1,5 @@
1
1
  import { HttpClient } from '../http/client';
2
+ import type { Response } from '../http/response';
2
3
  import { AppDTO as App, AppVersionDTO, CursorListRequest, CursorListResponse, LicenseRecordDTO } from '../types';
3
4
  /**
4
5
  * Apps API
@@ -9,62 +10,62 @@ export declare class AppsAPI {
9
10
  /**
10
11
  * List apps with cursor-based pagination
11
12
  */
12
- list(params?: Partial<CursorListRequest>): Promise<CursorListResponse<App>>;
13
+ list(params?: Partial<CursorListRequest>): Promise<Response<CursorListResponse<App>>>;
13
14
  /**
14
15
  * Get an app by ID
15
16
  */
16
- get(appId: string): Promise<App>;
17
+ get(appId: string): Promise<Response<App>>;
17
18
  /**
18
19
  * Get an app by version ID
19
20
  */
20
- getByVersionId(appId: string, versionId: string): Promise<App>;
21
+ getByVersionId(appId: string, versionId: string): Promise<Response<App>>;
21
22
  /**
22
23
  * Create a new app
23
24
  */
24
- create(data: Partial<App>): Promise<App>;
25
+ create(data: Partial<App>): Promise<Response<App>>;
25
26
  /**
26
27
  * Update an app
27
28
  */
28
- update(appId: string, data: Partial<App>): Promise<App>;
29
+ update(appId: string, data: Partial<App>): Promise<Response<App>>;
29
30
  /**
30
31
  * Delete an app
31
32
  */
32
- delete(appId: string): Promise<void>;
33
+ delete(appId: string): Promise<Response<void>>;
33
34
  /**
34
35
  * Duplicate an app
35
36
  */
36
- duplicate(appId: string): Promise<App>;
37
+ duplicate(appId: string): Promise<Response<App>>;
37
38
  /**
38
39
  * List app versions
39
40
  */
40
- listVersions(appId: string, params?: Partial<CursorListRequest>): Promise<CursorListResponse<AppVersionDTO>>;
41
+ listVersions(appId: string, params?: Partial<CursorListRequest>): Promise<Response<CursorListResponse<AppVersionDTO>>>;
41
42
  /**
42
43
  * Transfer app ownership to another team
43
44
  */
44
- transferOwnership(appId: string, newTeamId: string): Promise<App>;
45
+ transferOwnership(appId: string, newTeamId: string): Promise<Response<App>>;
45
46
  /**
46
47
  * Update app visibility
47
48
  */
48
- updateVisibility(appId: string, visibility: string): Promise<App>;
49
+ updateVisibility(appId: string, visibility: string): Promise<Response<App>>;
49
50
  /**
50
51
  * Update app lifecycle status
51
52
  */
52
- updateStatus(appId: string, status: string, message?: string): Promise<App>;
53
+ updateStatus(appId: string, status: string, message?: string): Promise<Response<App>>;
53
54
  /**
54
55
  * Get an app by namespace and name (e.g., "inference/claude-haiku")
55
56
  */
56
- getByName(name: string): Promise<App>;
57
+ getByName(name: string): Promise<Response<App>>;
57
58
  /**
58
59
  * Get app license record
59
60
  */
60
- getLicense(appId: string): Promise<LicenseRecordDTO>;
61
+ getLicense(appId: string): Promise<Response<LicenseRecordDTO>>;
61
62
  /**
62
63
  * Save app license
63
64
  */
64
- saveLicense(appId: string, license: string): Promise<LicenseRecordDTO>;
65
+ saveLicense(appId: string, license: string): Promise<Response<LicenseRecordDTO>>;
65
66
  /**
66
67
  * Set the current (active) version of an app
67
68
  */
68
- setCurrentVersion(appId: string, versionId: string): Promise<App>;
69
+ setCurrentVersion(appId: string, versionId: string): Promise<Response<App>>;
69
70
  }
70
71
  export declare function createAppsAPI(http: HttpClient): AppsAPI;
@@ -1,5 +1,6 @@
1
1
  import { HttpClient } from '../http/client';
2
- import { ChatDTO as Chat, ChatTraceDTO, CursorListRequest, CursorListResponse } from '../types';
2
+ import type { Response } from '../http/response';
3
+ import { ChatDTO as Chat, ChatMessageDTO, ChatTraceDTO, CursorListRequest, CursorListResponse } from '../types';
3
4
  /**
4
5
  * Chats API
5
6
  */
@@ -9,33 +10,37 @@ export declare class ChatsAPI {
9
10
  /**
10
11
  * List chats with cursor-based pagination
11
12
  */
12
- list(params?: Partial<CursorListRequest>): Promise<CursorListResponse<Chat>>;
13
+ list(params?: Partial<CursorListRequest>): Promise<Response<CursorListResponse<Chat>>>;
13
14
  /**
14
15
  * Get a chat by ID
15
16
  */
16
- get(chatId: string): Promise<Chat>;
17
+ get(chatId: string): Promise<Response<Chat>>;
17
18
  /**
18
19
  * Update a chat
19
20
  */
20
- update(chatId: string, data: Partial<Chat>): Promise<Chat>;
21
+ update(chatId: string, data: Partial<Chat>): Promise<Response<Chat>>;
21
22
  /**
22
23
  * Delete a chat
23
24
  */
24
- delete(chatId: string): Promise<void>;
25
+ delete(chatId: string): Promise<Response<void>>;
25
26
  /**
26
27
  * Get chat trace (for debugging/observability)
27
28
  */
28
- getTrace(chatId: string): Promise<ChatTraceDTO>;
29
+ getTrace(chatId: string): Promise<Response<ChatTraceDTO>>;
29
30
  /**
30
31
  * Get chat status
31
32
  */
32
- getStatus(chatId: string): Promise<{
33
+ getStatus(chatId: string): Promise<Response<{
33
34
  status: string;
34
- }>;
35
+ }>>;
35
36
  /**
36
37
  * Stop chat generation
37
38
  */
38
- stop(chatId: string): Promise<void>;
39
+ stop(chatId: string): Promise<Response<void>>;
40
+ /**
41
+ * Cancel a queued message
42
+ */
43
+ cancelMessage(messageId: string): Promise<Response<ChatMessageDTO>>;
39
44
  /**
40
45
  * Stream chat updates
41
46
  */
package/dist/api/chats.js CHANGED
@@ -47,6 +47,12 @@ export class ChatsAPI {
47
47
  async stop(chatId) {
48
48
  return this.http.request('post', `/chats/${chatId}/stop`);
49
49
  }
50
+ /**
51
+ * Cancel a queued message
52
+ */
53
+ async cancelMessage(messageId) {
54
+ return this.http.request('post', `/chats/messages/${messageId}/cancel`);
55
+ }
50
56
  /**
51
57
  * Stream chat updates
52
58
  */
@@ -1,4 +1,5 @@
1
1
  import { HttpClient } from '../http/client';
2
+ import type { Response } from '../http/response';
2
3
  import { EngineDTO as Engine, CursorListRequest, CursorListResponse } from '../types';
3
4
  /**
4
5
  * Engines API
@@ -9,30 +10,30 @@ export declare class EnginesAPI {
9
10
  /**
10
11
  * List engines with cursor-based pagination
11
12
  */
12
- list(params?: Partial<CursorListRequest>): Promise<CursorListResponse<Engine>>;
13
+ list(params?: Partial<CursorListRequest>): Promise<Response<CursorListResponse<Engine>>>;
13
14
  /**
14
15
  * Get an engine by ID
15
16
  */
16
- get(engineId: string): Promise<Engine>;
17
+ get(engineId: string): Promise<Response<Engine>>;
17
18
  /**
18
19
  * Get engines for specific resources (apps/agents)
19
20
  */
20
21
  getForResources(request: {
21
22
  app_ids?: string[];
22
23
  agent_ids?: string[];
23
- }): Promise<Engine[]>;
24
+ }): Promise<Response<Engine[]>>;
24
25
  /**
25
26
  * Create a new engine
26
27
  */
27
- create(data: Partial<Engine>): Promise<Engine>;
28
+ create(data: Partial<Engine>): Promise<Response<Engine>>;
28
29
  /**
29
30
  * Update an engine
30
31
  */
31
- update(engineId: string, data: Partial<Engine>): Promise<Engine>;
32
+ update(engineId: string, data: Partial<Engine>): Promise<Response<Engine>>;
32
33
  /**
33
34
  * Delete an engine
34
35
  */
35
- delete(engineId: string): Promise<void>;
36
+ delete(engineId: string): Promise<Response<void>>;
36
37
  /**
37
38
  * Stream engine updates
38
39
  */
@@ -40,30 +41,30 @@ export declare class EnginesAPI {
40
41
  /**
41
42
  * Stop an engine
42
43
  */
43
- stop(engineId: string): Promise<void>;
44
+ stop(engineId: string): Promise<Response<void>>;
44
45
  /**
45
46
  * Restart an engine
46
47
  */
47
- restart(engineId: string): Promise<void>;
48
+ restart(engineId: string): Promise<Response<void>>;
48
49
  /**
49
50
  * Update engine visibility
50
51
  */
51
- updateVisibility(engineId: string, visibility: string): Promise<Engine>;
52
+ updateVisibility(engineId: string, visibility: string): Promise<Response<Engine>>;
52
53
  /**
53
54
  * Transfer engine ownership
54
55
  */
55
- transferOwnership(engineId: string, newTeamId: string): Promise<Engine>;
56
+ transferOwnership(engineId: string, newTeamId: string): Promise<Response<Engine>>;
56
57
  /**
57
58
  * Extend engine duration
58
59
  */
59
- extend(engineId: string): Promise<void>;
60
+ extend(engineId: string): Promise<Response<void>>;
60
61
  /**
61
62
  * Drain an engine
62
63
  */
63
- drain(engineId: string): Promise<void>;
64
+ drain(engineId: string): Promise<Response<void>>;
64
65
  /**
65
66
  * Update an engine binary (drain + restart with new version)
66
67
  */
67
- updateBinary(engineId: string): Promise<void>;
68
+ updateBinary(engineId: string): Promise<Response<void>>;
68
69
  }
69
70
  export declare function createEnginesAPI(http: HttpClient): EnginesAPI;