Skip to content

Commit bcfacb1

Browse files
tylergibbs1claude
andauthored
Add Azure feature parity: allowedTools, canUseTool, interrupt, audio, predicted output (#4)
* Add Azure feature parity: predicted output, audio, allowedTools, canUseTool, interrupt, session tool management New ModelSettings fields: - prediction: predicted output for faster completions (Chat Completions) - modalities/audio: audio output for gpt-4o-audio models (Chat Completions) - dataSources: Azure On Your Data RAG sources (Chat Completions) - contextManagement: server-side context compaction (Responses API) New RunOptions: - allowedTools: glob-style wildcard filtering (e.g. "mcp__github__*") - canUseTool: centralized HITL permission callback (allow/deny/modify) New StreamedRunResult: - interrupt(): graceful stop returning partial result instead of throwing New Session methods: - addTools/removeTools/setTools: hot-swap tools between turns - allowedTools/canUseTool passthrough from SessionConfig Bug fix: canUseTool deny now short-circuits needsApproval to prevent unnecessary interrupts when the permission callback would deny anyway. 614 unit tests + 9 integration tests + 21 battle tests, all passing. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Bump @usestratus/sdk to v1.2.0 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Fix canUseTool double-invocation for dynamic needsApproval tools Evaluate needsApproval before canUseTool in collectPendingApprovals. Previously, tools with a needsApproval function that returned false would still trigger canUseTool in the approval check, then again during execution — causing double side effects (audit logs, rate limit decrements, latency). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 0fe6a2f commit bcfacb1

14 files changed

Lines changed: 1997 additions & 25 deletions

File tree

packages/stratus-sdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@usestratus/sdk",
3-
"version": "1.1.0",
3+
"version": "1.2.0",
44
"type": "module",
55
"main": "./dist/index.js",
66
"types": "./dist/index.d.ts",

packages/stratus-sdk/src/azure/chat-completions-model.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,10 @@ export class AzureChatCompletionsModel implements Model {
214214
if (s.user !== undefined) body.user = s.user;
215215
if (s.logprobs !== undefined) body.logprobs = s.logprobs;
216216
if (s.topLogprobs !== undefined) body.top_logprobs = s.topLogprobs;
217+
if (s.prediction !== undefined) body.prediction = s.prediction;
218+
if (s.modalities !== undefined) body.modalities = s.modalities;
219+
if (s.audio !== undefined) body.audio = s.audio;
220+
if (s.dataSources !== undefined) body.data_sources = s.dataSources;
217221
}
218222

219223
return body;

packages/stratus-sdk/src/azure/responses-model.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ export class AzureResponsesModel implements Model {
386386
if (s.metadata !== undefined) body.metadata = s.metadata;
387387
if (s.user !== undefined) body.user = s.user;
388388
// logprobs/topLogprobs are Chat Completions-only; not supported by the Responses API.
389+
if (s.contextManagement !== undefined) body.context_management = s.contextManagement;
389390
}
390391

391392
return body;

packages/stratus-sdk/src/core/codemode/executor.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,7 @@ export class FunctionExecutor implements Executor {
7575
...args: string[]
7676
) => (...args: unknown[]) => Promise<unknown>;
7777

78-
const fn = new AsyncFunction(
79-
"codemode",
80-
"console",
81-
`return await (${code})()`,
82-
);
78+
const fn = new AsyncFunction("codemode", "console", `return await (${code})()`);
8379

8480
const timeoutMs = this.#timeout;
8581
const result = await Promise.race([

packages/stratus-sdk/src/core/codemode/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
import { z } from "zod";
1010
import { isFunctionTool } from "../hosted-tool";
11+
import type { AgentTool } from "../hosted-tool";
1112
import { tool } from "../tool";
1213
import type { FunctionTool } from "../tool";
13-
import type { AgentTool } from "../hosted-tool";
1414
import type { Executor } from "./executor";
1515
import { generateTypes, normalizeCode, sanitizeToolName } from "./types";
1616

packages/stratus-sdk/src/core/codemode/types.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,9 +297,7 @@ function jsonSchemaToTypeString(
297297
const desc = propSchema.description;
298298
const format = propSchema.format;
299299
if (desc || format) {
300-
const descText = desc
301-
? escapeJsDoc(desc.replace(/\r?\n/g, " "))
302-
: undefined;
300+
const descText = desc ? escapeJsDoc(desc.replace(/\r?\n/g, " ")) : undefined;
303301
const formatTag = format ? `@format ${escapeJsDoc(format)}` : undefined;
304302
if (descText && formatTag) {
305303
lines.push(`${indent} /**`);

packages/stratus-sdk/src/core/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ export type {
1313
ToolErrorFormatter,
1414
CallModelInputFilter,
1515
MaxTurnsErrorHandler,
16+
CanUseTool,
17+
ToolPermissionAllow,
18+
ToolPermissionDeny,
19+
ToolPermissionResult,
1620
} from "./run";
1721

1822
export { createSession, forkSession, loadSession, prompt, resumeSession, Session } from "./session";
@@ -123,6 +127,14 @@ export type {
123127
ContentPart,
124128
TextContentPart,
125129
ImageContentPart,
130+
AudioFormat,
131+
AudioVoice,
132+
AudioConfig,
133+
Modality,
134+
PredictedOutput,
135+
DataSource,
136+
ContextManagement,
137+
ContextManagementRule,
126138
} from "./types";
127139

128140
export {

0 commit comments

Comments
 (0)