@coder/ai-sdk-agent 0.10.1 → 0.11.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/README.md +32 -0
- package/dist/index.d.ts +12 -2
- package/dist/index.js +11 -8
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -919,6 +919,7 @@ sequence pinpoints _where_ a turn died:
|
|
|
919
919
|
| `client` \| (`baseUrl` + `token`) | connection (one or the other; `baseUrl`/`token` default from `CODER_URL`/`CODER_SESSION_TOKEN`) |
|
|
920
920
|
| `organizationId` | org UUID that owns the chat (required) |
|
|
921
921
|
| `model` | model hint: UUID, `provider:model`, model id, or display‑name substring |
|
|
922
|
+
| `reasoningEffort` | reasoning effort for chat creation and every user-message submission (see below) |
|
|
922
923
|
| `instructions` | system prompt |
|
|
923
924
|
| `tools` | AI SDK `ToolSet` (client‑executed) |
|
|
924
925
|
| `workspaceId` | bind the chat to a Coder workspace (enables workspace‑scoped tools) |
|
|
@@ -947,6 +948,37 @@ match on the fields they carry), and an unresolvable hint falls back to the
|
|
|
947
948
|
server's default model instead of failing. Use
|
|
948
949
|
`agent.listModels()` to see what's available.
|
|
949
950
|
|
|
951
|
+
### Reasoning effort
|
|
952
|
+
|
|
953
|
+
Set `reasoningEffort` on `CoderAgentSettings` (or `CoderLanguageModelConfig`
|
|
954
|
+
when using the model directly). The global scale is `none`, `minimal`, `low`,
|
|
955
|
+
`medium`, `high`, `xhigh`, `max`. The exported `ReasoningEffort` type also accepts
|
|
956
|
+
other strings for forward compatibility. Model configs returned by
|
|
957
|
+
`agent.listModels()` / `client.listModelConfigs(organizationId)` expose the
|
|
958
|
+
optional `reasoning_efforts` list of selectable values for each model.
|
|
959
|
+
|
|
960
|
+
```ts
|
|
961
|
+
import { CoderAgent } from "@coder/ai-sdk-agent";
|
|
962
|
+
|
|
963
|
+
const agent = new CoderAgent({
|
|
964
|
+
organizationId: "your-org-uuid",
|
|
965
|
+
reasoningEffort: "low",
|
|
966
|
+
});
|
|
967
|
+
await agent.generate({ prompt: "Reply with exactly: pong" });
|
|
968
|
+
const chat = await agent.client.getChat(agent.chatId!);
|
|
969
|
+
console.log(chat.last_reasoning_effort); // string, null, or absent on the wire
|
|
970
|
+
await agent.archive();
|
|
971
|
+
```
|
|
972
|
+
|
|
973
|
+
The setting is independent of the `model` hint. It is sent as `reasoning_effort`
|
|
974
|
+
on chat creation and every user-message submission, including submissions to
|
|
975
|
+
resumed or busy chats that queue the message. When unset, the request key is
|
|
976
|
+
omitted entirely. Tool-result submissions and WebSocket reconnects do not post
|
|
977
|
+
user messages and do not send this field. There is no per-call reasoning-effort
|
|
978
|
+
override; configure it on the agent/model instance. Older Coder servers that do
|
|
979
|
+
not recognize `reasoning_effort` ignore the unknown JSON field, so setting it is
|
|
980
|
+
safe but has no effect there.
|
|
981
|
+
|
|
950
982
|
## How it works
|
|
951
983
|
|
|
952
984
|
```
|
package/dist/index.d.ts
CHANGED
|
@@ -78,6 +78,8 @@ declare const MAX_CHAT_FILE_SIZE_BYTES: number;
|
|
|
78
78
|
type ChatClientType = "ui" | "api";
|
|
79
79
|
type ChatPlanMode = "" | "plan";
|
|
80
80
|
type ChatBusyBehavior = "queue" | "interrupt";
|
|
81
|
+
/** Coder's global reasoning effort scale; accepts future server-defined values. */
|
|
82
|
+
type ReasoningEffort = "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | (string & {});
|
|
81
83
|
/**
|
|
82
84
|
* A client-executed ("dynamic") tool definition. chatd never executes these;
|
|
83
85
|
* when the model calls one, the chat enters `requires_action` and the client
|
|
@@ -97,6 +99,7 @@ interface CreateChatRequest {
|
|
|
97
99
|
system_prompt?: string;
|
|
98
100
|
workspace_id?: string;
|
|
99
101
|
model_config_id?: string;
|
|
102
|
+
reasoning_effort?: ReasoningEffort;
|
|
100
103
|
mcp_server_ids?: string[];
|
|
101
104
|
labels?: Record<string, string>;
|
|
102
105
|
unsafe_dynamic_tools?: DynamicTool[];
|
|
@@ -106,6 +109,7 @@ interface CreateChatRequest {
|
|
|
106
109
|
interface CreateChatMessageRequest {
|
|
107
110
|
content: ChatInputPart[];
|
|
108
111
|
model_config_id?: string;
|
|
112
|
+
reasoning_effort?: ReasoningEffort;
|
|
109
113
|
mcp_server_ids?: string[];
|
|
110
114
|
busy_behavior?: ChatBusyBehavior;
|
|
111
115
|
plan_mode?: ChatPlanMode;
|
|
@@ -211,6 +215,7 @@ interface Chat {
|
|
|
211
215
|
parent_chat_id?: string | null;
|
|
212
216
|
root_chat_id?: string | null;
|
|
213
217
|
last_model_config_id?: string;
|
|
218
|
+
last_reasoning_effort?: ReasoningEffort | null;
|
|
214
219
|
title: string;
|
|
215
220
|
status: ChatStatus;
|
|
216
221
|
plan_mode?: ChatPlanMode;
|
|
@@ -262,6 +267,7 @@ interface ChatModelConfig {
|
|
|
262
267
|
is_default?: boolean;
|
|
263
268
|
context_limit?: number;
|
|
264
269
|
compression_threshold?: number;
|
|
270
|
+
reasoning_efforts?: ReasoningEffort[];
|
|
265
271
|
}
|
|
266
272
|
/**
|
|
267
273
|
* An organization-scoped chat model, as returned by
|
|
@@ -282,7 +288,7 @@ interface ChatModel {
|
|
|
282
288
|
is_default?: boolean;
|
|
283
289
|
context_limit?: number;
|
|
284
290
|
compression_threshold?: number;
|
|
285
|
-
reasoning_efforts?:
|
|
291
|
+
reasoning_efforts?: ReasoningEffort[];
|
|
286
292
|
created_at?: string;
|
|
287
293
|
updated_at?: string;
|
|
288
294
|
}
|
|
@@ -999,6 +1005,8 @@ interface CoderAgentSettings<TOOLS extends ToolSet = {}> {
|
|
|
999
1005
|
organizationId: string;
|
|
1000
1006
|
/** Model hint: UUID, `provider:model`, model id, or display-name substring. */
|
|
1001
1007
|
model?: string;
|
|
1008
|
+
/** Reasoning effort sent on chat creation and each user-message submission. */
|
|
1009
|
+
reasoningEffort?: ReasoningEffort;
|
|
1002
1010
|
/** Bind the chat to a Coder workspace (enables workspace-scoped tools). */
|
|
1003
1011
|
workspaceId?: string;
|
|
1004
1012
|
/**
|
|
@@ -1286,6 +1294,8 @@ interface CoderLanguageModelConfig {
|
|
|
1286
1294
|
organizationId: string;
|
|
1287
1295
|
/** Model hint (UUID, `provider:model`, model id, or display-name substring). */
|
|
1288
1296
|
model?: string;
|
|
1297
|
+
/** Reasoning effort sent on chat creation and each user-message submission. */
|
|
1298
|
+
reasoningEffort?: ReasoningEffort;
|
|
1289
1299
|
/** Bind the chat to a Coder workspace (enables workspace tools). */
|
|
1290
1300
|
workspaceId?: string;
|
|
1291
1301
|
/** chatd-side MCP servers to enable. */
|
|
@@ -1707,4 +1717,4 @@ declare class CoderChatError extends CoderAgentError {
|
|
|
1707
1717
|
constructor(payload: ChatErrorPayload);
|
|
1708
1718
|
}
|
|
1709
1719
|
|
|
1710
|
-
export { CHAT_ATTACHMENT_MEDIA_TYPES, CODER_PROVIDER_OPTIONS, type Chat, type ChatAttachment, type ChatAttachmentMediaType, type ChatBusyBehavior, type ChatClientType, type ChatErrorPayload, type ChatFileInput, type ChatInputPart, type ChatInputPartType, type ChatMessage, type ChatMessagePart, type ChatMessagePartType, type ChatMessageRole, type ChatMessageUsage, type ChatMessagesResponse, type ChatMessagesToUIMessagesOptions, type ChatModel, type ChatModelConfig, type ChatModelProviderDescriptor, type ChatPlanMode, type ChatQueuedMessage, type ChatStatus, type ChatStreamActionRequired, type ChatStreamEvent, type ChatStreamEventType, type ChatStreamMessagePart, type ChatStreamRetry, type ChatStreamStatus, type ChatStreamToolCall, type ChatUnsupportedProvider, type ChatWatchEvent, type ChatWatchEventKind, CoderAgent, CoderAgentError, type CoderAgentSettings, CoderApiError, type CoderArchiveResult, CoderChatClient, type CoderChatClientOptions, CoderChatError, type CoderClientOperation, type CoderFileProviderOptions, type CoderInterruptResult, CoderLanguageModel, type CoderLanguageModelConfig, CoderStreamError, type CoderTransportEvent, type CreateChatMessageRequest, type CreateChatMessageResponse, type CreateChatRequest, type DynamicTool, type FileContent, type FilePartUploader, type HttpErrorTransportEvent, type HttpRequestTransportEvent, type HttpResponseTransportEvent, MAX_CHAT_FILE_SIZE_BYTES, type OrganizationChatModelsResponse, type PreviewShareLevel, type ResolvedFile, type SegmentSettleTransportEvent, type SegmentStartTransportEvent, type SharePreviewOptions, type SharedWorkspacePreview, type StreamCloseTransportEvent, type StreamDialTransportEvent, type StreamErrorTransportEvent, type StreamEventTransportEvent, type StreamOpenTransportEvent, type StreamRedialTransportEvent, type SubmitToolResultsRequest, TERMINAL_STATUSES, type ToolResult, type TransportEventHandler, type TurnAction, TurnTranslator, type TurnTranslatorOptions, type UpdateChatRequest, type UploadChatFileResponse, type UploadedChatFile, type UserContent, type WatchChatEventsOptions, type WebSocketFactory, type WebSocketLike, type WorkspaceFileStore, type WorkspacePlacement, type WorkspacePreview, type WorkspacePreviewOptions, chatMessagesToUIMessages, classifyTurnAction, dataContentToFileContent, dynamicToolNames, extractSystemPrompt, resolveFileContent, streamChatEvents, toolsToDynamicTools, userContentToInputParts, watchChatEvents };
|
|
1720
|
+
export { CHAT_ATTACHMENT_MEDIA_TYPES, CODER_PROVIDER_OPTIONS, type Chat, type ChatAttachment, type ChatAttachmentMediaType, type ChatBusyBehavior, type ChatClientType, type ChatErrorPayload, type ChatFileInput, type ChatInputPart, type ChatInputPartType, type ChatMessage, type ChatMessagePart, type ChatMessagePartType, type ChatMessageRole, type ChatMessageUsage, type ChatMessagesResponse, type ChatMessagesToUIMessagesOptions, type ChatModel, type ChatModelConfig, type ChatModelProviderDescriptor, type ChatPlanMode, type ChatQueuedMessage, type ChatStatus, type ChatStreamActionRequired, type ChatStreamEvent, type ChatStreamEventType, type ChatStreamMessagePart, type ChatStreamRetry, type ChatStreamStatus, type ChatStreamToolCall, type ChatUnsupportedProvider, type ChatWatchEvent, type ChatWatchEventKind, CoderAgent, CoderAgentError, type CoderAgentSettings, CoderApiError, type CoderArchiveResult, CoderChatClient, type CoderChatClientOptions, CoderChatError, type CoderClientOperation, type CoderFileProviderOptions, type CoderInterruptResult, CoderLanguageModel, type CoderLanguageModelConfig, CoderStreamError, type CoderTransportEvent, type CreateChatMessageRequest, type CreateChatMessageResponse, type CreateChatRequest, type DynamicTool, type FileContent, type FilePartUploader, type HttpErrorTransportEvent, type HttpRequestTransportEvent, type HttpResponseTransportEvent, MAX_CHAT_FILE_SIZE_BYTES, type OrganizationChatModelsResponse, type PreviewShareLevel, type ReasoningEffort, type ResolvedFile, type SegmentSettleTransportEvent, type SegmentStartTransportEvent, type SharePreviewOptions, type SharedWorkspacePreview, type StreamCloseTransportEvent, type StreamDialTransportEvent, type StreamErrorTransportEvent, type StreamEventTransportEvent, type StreamOpenTransportEvent, type StreamRedialTransportEvent, type SubmitToolResultsRequest, TERMINAL_STATUSES, type ToolResult, type TransportEventHandler, type TurnAction, TurnTranslator, type TurnTranslatorOptions, type UpdateChatRequest, type UploadChatFileResponse, type UploadedChatFile, type UserContent, type WatchChatEventsOptions, type WebSocketFactory, type WebSocketLike, type WorkspaceFileStore, type WorkspacePlacement, type WorkspacePreview, type WorkspacePreviewOptions, chatMessagesToUIMessages, classifyTurnAction, dataContentToFileContent, dynamicToolNames, extractSystemPrompt, resolveFileContent, streamChatEvents, toolsToDynamicTools, userContentToInputParts, watchChatEvents };
|
package/dist/index.js
CHANGED
|
@@ -1125,6 +1125,7 @@ function joinOrgModels(res) {
|
|
|
1125
1125
|
for (const m of models) {
|
|
1126
1126
|
if (typeof m !== "object" || m === null) continue;
|
|
1127
1127
|
const config = { ...m };
|
|
1128
|
+
if (m.reasoning_efforts !== void 0) config.reasoning_efforts = m.reasoning_efforts;
|
|
1128
1129
|
const providerType = typeof m.ai_provider_id === "string" ? providerTypeById.get(m.ai_provider_id) : void 0;
|
|
1129
1130
|
if (providerType !== void 0) config.provider = providerType;
|
|
1130
1131
|
configs.push(config);
|
|
@@ -2570,6 +2571,9 @@ var CoderLanguageModel = class {
|
|
|
2570
2571
|
const tools = toolsToDynamicTools(options.tools);
|
|
2571
2572
|
if (tools.length > 0) req.unsafe_dynamic_tools = tools;
|
|
2572
2573
|
if (modelConfigId) req.model_config_id = modelConfigId;
|
|
2574
|
+
if (this.#config.reasoningEffort !== void 0) {
|
|
2575
|
+
req.reasoning_effort = this.#config.reasoningEffort;
|
|
2576
|
+
}
|
|
2573
2577
|
if (this.#config.workspaceId) req.workspace_id = this.#config.workspaceId;
|
|
2574
2578
|
if (this.#config.mcpServerIds?.length) req.mcp_server_ids = this.#config.mcpServerIds;
|
|
2575
2579
|
if (this.#config.planMode) req.plan_mode = this.#config.planMode;
|
|
@@ -2580,14 +2584,12 @@ var CoderLanguageModel = class {
|
|
|
2580
2584
|
if (chat.mcp_server_ids?.length) chatHasMcpServers = true;
|
|
2581
2585
|
afterId = this.#lastSeenMessageId > 0 ? this.#lastSeenMessageId : void 0;
|
|
2582
2586
|
} else {
|
|
2583
|
-
const
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
signal
|
|
2590
|
-
);
|
|
2587
|
+
const req = { content };
|
|
2588
|
+
if (modelConfigId) req.model_config_id = modelConfigId;
|
|
2589
|
+
if (this.#config.reasoningEffort !== void 0) {
|
|
2590
|
+
req.reasoning_effort = this.#config.reasoningEffort;
|
|
2591
|
+
}
|
|
2592
|
+
const resp = await this.#config.client.createChatMessage(this.#chatId, req, signal);
|
|
2591
2593
|
if (resp.message) {
|
|
2592
2594
|
afterId = resp.message.id;
|
|
2593
2595
|
} else if (resp.queued) {
|
|
@@ -2986,6 +2988,7 @@ var CoderAgent = class {
|
|
|
2986
2988
|
client: this.#client,
|
|
2987
2989
|
organizationId: settings.organizationId,
|
|
2988
2990
|
model: settings.model,
|
|
2991
|
+
reasoningEffort: settings.reasoningEffort,
|
|
2989
2992
|
workspaceId: settings.workspaceId,
|
|
2990
2993
|
mcpServerIds: settings.mcpServerIds,
|
|
2991
2994
|
planMode: settings.planMode,
|