@inferencesh/sdk 0.9.0 → 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 +8 -0
- package/dist/api/agents.d.ts +9 -1
- package/dist/api/agents.js +3 -0
- package/package.json +1 -1
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)`
|
package/dist/api/agents.d.ts
CHANGED
|
@@ -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) */
|
package/dist/api/agents.js
CHANGED
|
@@ -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);
|