flavor-code 1.3.10 → 1.3.12

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.
@@ -13,11 +13,14 @@ export interface OpenAIModelAdapterOptions {
13
13
  client?: OpenAIClient;
14
14
  /** Mirror the per-request cache breakdown to stderr. Defaults to FLAVOR_DEBUG_USAGE=1. File logging to usage.jsonl is always on. */
15
15
  debugUsage?: boolean;
16
+ /** Reasoning effort requested from the Responses API; omitted when undefined. */
17
+ thinkingEffort?: "low" | "medium" | "high";
16
18
  }
17
19
  export declare class OpenAIModelAdapter implements ModelAdapter {
18
20
  #private;
19
21
  private readonly client;
20
22
  private readonly debugUsage;
23
+ private readonly thinkingEffort;
21
24
  constructor(options: OpenAIModelAdapterOptions);
22
25
  stream(request: ModelRequest): AsyncIterable<ModelEvent>;
23
26
  }
@@ -11,6 +11,10 @@ export interface StructuredOutputOptions<T> {
11
11
  name: string;
12
12
  description: string;
13
13
  schema: z.ZodType<T>;
14
+ /** Provider-facing schema when runtime validation was derived from another source (for example MCP). */
15
+ modelInputSchema?: Record<string, unknown>;
16
+ /** Preserve the original tool's provider strictness during argument repair. */
17
+ modelStrict?: boolean;
14
18
  retry?: StructuredOutputRetryPolicy;
15
19
  beforeAttempt?(attempt: StructuredOutputAttempt): void | Promise<void>;
16
20
  afterAttempt?(attempt: StructuredOutputAttemptResult): void | Promise<void>;
@@ -72,6 +76,10 @@ export declare class StructuredOutputError extends Error {
72
76
  }
73
77
  export declare function withStructuredOutput<T>(options: StructuredOutputOptions<T>): StructuredModel<T>;
74
78
  export declare function strictJsonSchema(schema: z.ZodType<unknown>): Record<string, unknown>;
79
+ /** Runtime-facing JSON Schema before provider strictness rewrites optional fields. */
80
+ export declare function jsonSchemaFromZod(schema: z.ZodType<unknown>): Record<string, unknown>;
81
+ /** Recursively adapts an existing JSON Schema for providers that require strict function tools. */
82
+ export declare function strictJsonSchemaObject(schema: Record<string, unknown>): Record<string, unknown>;
75
83
  /**
76
84
  * Extract the first JSON object or array from free-form model text (plain JSON,
77
85
  * fenced ```json blocks, or JSON embedded in prose). Returns undefined when no
@@ -80,10 +88,11 @@ export declare function strictJsonSchema(schema: z.ZodType<unknown>): Record<str
80
88
  export declare function extractJsonObject(text: string): unknown;
81
89
  /**
82
90
  * Best-effort type coercion guided by a JSON schema. Some providers serialize
83
- * typed fields as strings (`"10"` for an integer). This rewrites string→number /
84
- * string→boolean where the schema demands those types, recursing into object
85
- * properties and anyOf branches. Values already matching the schema are
86
- * returned unchanged, so a valid payload is a no-op.
91
+ * typed fields as strings (`"10"` for an integer) or collapse a single-item
92
+ * array to its item (`"main"` instead of `["main"]`). This rewrites those
93
+ * provider representations where the schema demands another type, recursing
94
+ * into object properties and anyOf branches. Values already matching the
95
+ * schema are returned unchanged, so a valid payload is a no-op.
87
96
  */
88
97
  export declare function coerceByJsonSchema(value: unknown, schema: unknown): unknown;
89
98
  export declare function modelToolFromZod(name: string, description: string, schema: z.ZodType<unknown>): ModelTool;
@@ -22,12 +22,18 @@ interface ModelMessageMetadata {
22
22
  /** Provider-neutral marker for the end of a byte-stable reusable prompt prefix. */
23
23
  cacheBreakpoint?: boolean;
24
24
  }
25
+ export interface ModelThinkingBlock {
26
+ text: string;
27
+ /** Provider-signed integrity token; Anthropic requires it echoed back verbatim. */
28
+ signature?: string;
29
+ }
25
30
  export type ModelMessage = (ModelMessageMetadata & {
26
31
  role: "user";
27
32
  content: ModelContent;
28
33
  }) | (ModelMessageMetadata & {
29
34
  role: "system" | "assistant" | "tool";
30
35
  content: string;
36
+ thinkingBlocks?: ModelThinkingBlock[];
31
37
  });
32
38
  export declare function modelContentText(content: ModelContent): string;
33
39
  export declare function modelContentTranscriptText(content: ModelContent): string;
@@ -57,6 +63,19 @@ export interface ProviderError {
57
63
  export type ModelEvent = {
58
64
  type: "text";
59
65
  text: string;
66
+ } | {
67
+ type: "thinking";
68
+ text: string;
69
+ }
70
+ /**
71
+ * Sealed thinking block emitted once per provider thinking block. Carries the
72
+ * provider signature that must be echoed back verbatim on the next request
73
+ * when extended thinking is combined with tool use.
74
+ */
75
+ | {
76
+ type: "thinking-block";
77
+ text: string;
78
+ signature?: string;
60
79
  } | {
61
80
  type: "tool-call";
62
81
  id: string;
@@ -23,6 +23,8 @@ export interface ProductionRuntimeOptions {
23
23
  environment?: NodeJS.ProcessEnv;
24
24
  output(event: SessionOutput): void;
25
25
  onApprovalChange?(): void;
26
+ /** Called whenever the active registerTool-managed command set changes. */
27
+ onToolsChange?(): void;
26
28
  /** Non-interactive callers must deny requests instead of waiting for input. */
27
29
  approvalPolicy?: "prompt" | "deny";
28
30
  /** Allow a protocol host to resolve tool approvals without enabling other interactive UI bridges. */
package/dist/sdk/index.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  FlavorRpcServer,
5
5
  TraceRecordSchema,
6
6
  TraceRecorder
7
- } from "../chunk-T2ARW6CZ.js";
7
+ } from "../chunk-EZNIDHFZ.js";
8
8
  import {
9
9
  AgentMessageQueue,
10
10
  DockerExecutionEnvironment,
@@ -13,8 +13,8 @@ import {
13
13
  WorkspaceCheckpointStore,
14
14
  buildDockerInvocation,
15
15
  createProductionRuntime
16
- } from "../chunk-Y3DPUAEJ.js";
17
- import "../chunk-IG4Z23CL.js";
16
+ } from "../chunk-QC5OYQTB.js";
17
+ import "../chunk-JFKRX2KG.js";
18
18
  import "../chunk-RQTYHUMK.js";
19
19
  import "../chunk-S32JRDZK.js";
20
20
 
@@ -61,5 +61,10 @@ export declare class ToolRuntime {
61
61
  label(call: ToolCall): string | undefined;
62
62
  hint(call: ToolCall): string | undefined;
63
63
  execute(call: ToolCall, context: ToolContext): Promise<ToolResult>;
64
+ /**
65
+ * Validates a call and applies the same conservative provider-argument
66
+ * normalization used by the agent loop before falling back to repair.
67
+ */
68
+ normalize(call: ToolCall): ToolInputValidation;
64
69
  callPresentation(call: ToolCall): import("./types.js").ToolPresentation | undefined;
65
70
  }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Return the display width of a Unicode code point in a fixed-width terminal.
3
+ *
4
+ * - 2 for CJK ideographs, fullwidth forms, Hangul, Kana, and most emoji.
5
+ * - 0 for combining marks, zero-width joiners, and other invisible characters.
6
+ * - 1 for everything else (ASCII, Latin, Cyrillic, etc.).
7
+ *
8
+ * This is a heuristic based on Unicode East Asian Width conventions. It covers
9
+ * the most common ranges and is intentionally zero-dependency so it stays fast
10
+ * and reviewable.
11
+ */
12
+ export declare function charWidth(codePoint: number): number;
@@ -1,4 +1,4 @@
1
- export declare const MVP_COMMANDS: readonly ["model", "init", "config", "login", "logout", "permissions", "skills", "plugins", "hooks", "tasks", "finish", "compact", "clear", "help", "exit", "audit", "usage", "loop", "goal", "evolve", "mcp", "commit", "review", "ide", "memory", "remember", "forget", "forget-cold", "checkpoint", "tree", "rewind", "unrevert", "fork", "pals", "chat", "co-work"];
1
+ export declare const MVP_COMMANDS: readonly ["model", "init", "config", "login", "logout", "permissions", "skills", "plugins", "hooks", "tasks", "finish", "compact", "clear", "help", "exit", "audit", "usage", "loop", "goal", "evolve", "mcp", "commit", "review", "ide", "memory", "remember", "forget", "forget-cold", "checkpoint", "tree", "rewind", "unrevert", "fork", "pals", "chat", "co-work", "tool"];
2
2
  export declare const COMMAND_DESCRIPTIONS: Record<(typeof MVP_COMMANDS)[number], string>;
3
3
  export type PermissionCommandMode = PermissionMode;
4
4
  export type ModelRole = "main" | "subagent";
@@ -57,6 +57,10 @@ export type SlashCommand = {
57
57
  name: "skill";
58
58
  skill: string;
59
59
  prompt: string;
60
+ } | {
61
+ name: "managed-tool";
62
+ tool: string;
63
+ input: string;
60
64
  } | {
61
65
  name: "loop";
62
66
  goal: string;
@@ -87,7 +91,7 @@ export type SlashCommand = {
87
91
  target: string;
88
92
  goal: string;
89
93
  } | CoWorkSlashCommand | {
90
- name: Exclude<(typeof MVP_COMMANDS)[number], "model" | "permissions" | "audit" | "loop" | "goal" | "evolve" | "commit" | "review" | "mcp" | "remember" | "forget" | "checkpoint" | "rewind" | "fork" | "pals" | "chat" | "co-work">;
94
+ name: Exclude<(typeof MVP_COMMANDS)[number], "model" | "permissions" | "audit" | "loop" | "goal" | "evolve" | "commit" | "review" | "mcp" | "remember" | "forget" | "checkpoint" | "rewind" | "fork" | "pals" | "chat" | "co-work" | "tool">;
91
95
  } | {
92
96
  name: "audit";
93
97
  toolFilter?: string | undefined;
@@ -103,6 +107,6 @@ export type SlashCommand = {
103
107
  command: string;
104
108
  message: string;
105
109
  };
106
- export declare function parseSlashCommand(input: string, dynamicCommands?: readonly string[], skillCommands?: readonly string[]): SlashCommand | null;
110
+ export declare function parseSlashCommand(input: string, dynamicCommands?: readonly string[], skillCommands?: readonly string[], managedTools?: readonly string[]): SlashCommand | null;
107
111
  import { type PermissionMode } from "../config/schema.js";
108
112
  import { type MemoryType } from "../memory/types.js";
@@ -153,6 +153,11 @@ export interface SessionServices {
153
153
  description?: string;
154
154
  }[];
155
155
  runPluginCommand(name: string, args: readonly string[], signal: AbortSignal): Promise<unknown>;
156
+ managedToolCommands(): readonly {
157
+ name: string;
158
+ description?: string;
159
+ }[];
160
+ runManagedTool(name: string, input: string, signal: AbortSignal): Promise<unknown>;
156
161
  output(event: SessionOutput): void;
157
162
  questions: QuestionBridge;
158
163
  login(): Promise<string>;
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Display model for the streamed thinking line.
3
+ *
4
+ * The line occupies a fixed cell width. Text is revealed like a typewriter:
5
+ * while it fits, the whole text is shown. Once it overflows, the viewport
6
+ * chases the newest tail — content visibly pushes left. The chase eases so a
7
+ * burst of tokens does not jerk the line, and it always converges on the tail
8
+ * so the freshest reasoning stays readable.
9
+ */
10
+ export declare const THINKING_SCROLL_CELLS_PER_SEC = 16;
11
+ /** Exponential catch-up factor applied to the remaining lag each update. */
12
+ export declare const THINKING_EASE = 0.18;
13
+ /** Caps one update's elapsed time so a paused clock cannot jump the scroll. */
14
+ export declare const THINKING_MAX_STEP_MS = 250;
15
+ /** Cap for stored thinking text per model activity (characters). */
16
+ export declare const THINKING_MAX_STORED_CHARS = 4000;
17
+ export interface ThinkingWindowOptions {
18
+ /** Visible width in terminal cells. */
19
+ width: number;
20
+ /** Milliseconds since the previous update. */
21
+ dtMs: number;
22
+ cellsPerSecond?: number;
23
+ ease?: number;
24
+ }
25
+ export interface ThinkingWindowState {
26
+ /** The slice to render in the fixed-width slot. */
27
+ text: string;
28
+ /** Scroll offset in cells; feed back as `previousStart` next update. */
29
+ start: number;
30
+ }
31
+ export declare function normalizeThinkingText(text: string): string;
32
+ export declare function thinkingDisplayWidth(text: string): number;
33
+ /** Slice a display-width window out of text; wide chars straddling an edge are kept whole. */
34
+ export declare function sliceThinkingByWidth(text: string, startCell: number, cellCount: number): string;
35
+ /**
36
+ * Advance the fixed-width viewport toward the newest tail by one update.
37
+ * `previousStart` carries the scroll position from the last frame so the
38
+ * movement is rate-limited rather than an instant jump.
39
+ */
40
+ export declare function thinkingWindow(text: string, previousStart: number, options: ThinkingWindowOptions): ThinkingWindowState;
41
+ /** Append a thinking delta, keeping only the tail of the accumulated text. */
42
+ export declare function appendThinkingText(previous: string | undefined, delta: string): string;
@@ -55,6 +55,8 @@ export type TranscriptBlock = {
55
55
  role: "main" | "subagent";
56
56
  };
57
57
  activity?: "model";
58
+ /** Accumulated streamed thinking text while a model activity is running. */
59
+ thinkingText?: string;
58
60
  presentation?: ToolPresentation;
59
61
  tool?: TranscriptToolDetails;
60
62
  details?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flavor-code",
3
- "version": "1.3.10",
3
+ "version": "1.3.12",
4
4
  "author": "YachuanWzh",
5
5
  "type": "module",
6
6
  "publishConfig": {