@mastra/code-sdk 1.5.0-alpha.11 → 1.5.0-alpha.3
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/CHANGELOG.md +0 -106
- package/dist/agents/instructions.d.ts +1 -12
- package/dist/agents/instructions.d.ts.map +1 -1
- package/dist/agents/instructions.js +5 -23
- package/dist/agents/instructions.js.map +1 -1
- package/dist/agents/memory.d.ts.map +1 -1
- package/dist/agents/memory.js +32 -35
- package/dist/agents/memory.js.map +1 -1
- package/dist/agents/model.d.ts +4 -11
- package/dist/agents/model.d.ts.map +1 -1
- package/dist/agents/model.js +1 -2
- package/dist/agents/model.js.map +1 -1
- package/dist/agents/prompts/agent-instructions.d.ts +0 -9
- package/dist/agents/prompts/agent-instructions.d.ts.map +1 -1
- package/dist/agents/prompts/agent-instructions.js +4 -14
- package/dist/agents/prompts/agent-instructions.js.map +1 -1
- package/dist/agents/prompts/index.d.ts +0 -28
- package/dist/agents/prompts/index.d.ts.map +1 -1
- package/dist/agents/prompts/index.js +9 -48
- package/dist/agents/prompts/index.js.map +1 -1
- package/dist/agents/tools.d.ts +1 -2
- package/dist/agents/tools.d.ts.map +1 -1
- package/dist/agents/tools.js +5 -4
- package/dist/agents/tools.js.map +1 -1
- package/dist/onboarding/settings.d.ts +6 -12
- package/dist/onboarding/settings.d.ts.map +1 -1
- package/dist/onboarding/settings.js +23 -18
- package/dist/onboarding/settings.js.map +1 -1
- package/dist/providers/openai-codex.d.ts +4 -3
- package/dist/providers/openai-codex.d.ts.map +1 -1
- package/dist/providers/openai-codex.js +9 -1
- package/dist/providers/openai-codex.js.map +1 -1
- package/dist/schema.d.ts +3 -4
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +8 -2
- package/dist/schema.js.map +1 -1
- package/dist/tools/index.d.ts +1 -1
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +2 -2
- package/dist/tools/web-search.d.ts +2 -81
- package/dist/tools/web-search.d.ts.map +1 -1
- package/dist/tools/web-search.js +4 -98
- package/dist/tools/web-search.js.map +1 -1
- package/dist/workflows/register-primitives.d.ts +4 -4
- package/dist/workflows/register-primitives.d.ts.map +1 -1
- package/dist/workflows/register-primitives.js +4 -5
- package/dist/workflows/register-primitives.js.map +1 -1
- package/package.json +11 -12
- package/dist/agents/context-audit.d.ts +0 -84
- package/dist/agents/context-audit.d.ts.map +0 -1
- package/dist/agents/context-audit.js +0 -118
- package/dist/agents/context-audit.js.map +0 -1
- package/dist/thinking.d.ts +0 -33
- package/dist/thinking.d.ts.map +0 -1
- package/dist/thinking.js +0 -58
- package/dist/thinking.js.map +0 -1
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import { tokenEstimate } from "../utils/token-estimator.js";
|
|
2
|
-
//#region src/agents/context-audit.ts
|
|
3
|
-
/**
|
|
4
|
-
* Context audit — accounts for what occupies the model's context window.
|
|
5
|
-
*
|
|
6
|
-
* Deliberately pure: callers collect the real strings (prompt sections, the
|
|
7
|
-
* injected skills catalog, tool definitions) and this module only measures and
|
|
8
|
-
* groups them. That keeps the audit honest — it reports on the same text the
|
|
9
|
-
* model receives rather than a description of it — and keeps it testable
|
|
10
|
-
* without a live session.
|
|
11
|
-
*
|
|
12
|
-
* Nothing here reads file contents or secrets: entries carry labels, origins
|
|
13
|
-
* and sizes only, never the underlying text, so an audit can be shown or
|
|
14
|
-
* pasted without leaking whatever the context happens to contain.
|
|
15
|
-
*/
|
|
16
|
-
function measure(id, label, content, detail) {
|
|
17
|
-
return {
|
|
18
|
-
id,
|
|
19
|
-
label,
|
|
20
|
-
detail,
|
|
21
|
-
tokens: tokenEstimate(content),
|
|
22
|
-
characters: content.length,
|
|
23
|
-
percent: 0
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
function sectionEntries(sections, prefix) {
|
|
27
|
-
return sections.filter((section) => section.content.length > 0).map((section) => measure(`${prefix}:${section.id}`, section.label, section.content, section.detail));
|
|
28
|
-
}
|
|
29
|
-
function group(id, label, entries, note) {
|
|
30
|
-
if (entries.length === 0) return void 0;
|
|
31
|
-
return {
|
|
32
|
-
id,
|
|
33
|
-
label,
|
|
34
|
-
tokens: entries.reduce((sum, entry) => sum + entry.tokens, 0),
|
|
35
|
-
percent: 0,
|
|
36
|
-
entries,
|
|
37
|
-
note
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Group tool definitions by their provider so a chatty MCP server is visible as
|
|
42
|
-
* one line rather than fifty. Per-tool entries stay available underneath.
|
|
43
|
-
*/
|
|
44
|
-
function toolEntries(tools) {
|
|
45
|
-
return tools.map((tool) => {
|
|
46
|
-
const serialized = [
|
|
47
|
-
tool.name,
|
|
48
|
-
tool.description ?? "",
|
|
49
|
-
tool.parameters ? JSON.stringify(tool.parameters) : ""
|
|
50
|
-
].join("\n");
|
|
51
|
-
return measure(`tool:${tool.server ?? "built-in"}:${tool.name}`, tool.name, serialized, tool.server);
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
function withPercent(items, total) {
|
|
55
|
-
for (const item of items) item.percent = total > 0 ? item.tokens / total * 100 : 0;
|
|
56
|
-
return items;
|
|
57
|
-
}
|
|
58
|
-
function sumTokens(groups) {
|
|
59
|
-
return groups.reduce((sum, entry) => sum + entry.tokens, 0);
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Build a context audit from already-collected context.
|
|
63
|
-
*
|
|
64
|
-
* Percentages are shares of the audited total, not of the model's context
|
|
65
|
-
* window: window size is not exposed by the model registry, and inventing one
|
|
66
|
-
* would make every number wrong for models that disagree with the guess.
|
|
67
|
-
*/
|
|
68
|
-
function buildContextAudit(input) {
|
|
69
|
-
const startupGroups = [
|
|
70
|
-
group("system-prompt", "System prompt", sectionEntries(input.promptSections ?? [], "prompt")),
|
|
71
|
-
group("dynamic-instructions", "Dynamic instructions", sectionEntries(input.instructionSections ?? [], "dynamic")),
|
|
72
|
-
group("skills", "Skills catalog", input.skillsCatalog ? [measure("skills:catalog", "Available skills", input.skillsCatalog)] : [], "Skill instructions are loaded on demand and are not counted here."),
|
|
73
|
-
group("tools", "Tool definitions", toolEntries(input.tools ?? []))
|
|
74
|
-
].filter((entry) => entry !== void 0);
|
|
75
|
-
const observationEntries = [];
|
|
76
|
-
if (typeof input.injectedObservations === "string") observationEntries.push(measure("observations:injected", "Injected into context", input.injectedObservations));
|
|
77
|
-
else if (input.injectedObservations && input.injectedObservations.tokens > 0) observationEntries.push({
|
|
78
|
-
id: "observations:injected",
|
|
79
|
-
label: "Injected into context",
|
|
80
|
-
tokens: input.injectedObservations.tokens,
|
|
81
|
-
characters: 0,
|
|
82
|
-
percent: 0
|
|
83
|
-
});
|
|
84
|
-
const startupTokens = sumTokens(startupGroups);
|
|
85
|
-
const injectedObservationTokens = observationEntries.reduce((sum, entry) => sum + entry.tokens, 0);
|
|
86
|
-
const promptTokens = input.conversation?.promptTokens ?? 0;
|
|
87
|
-
const conversationTokens = Math.max(0, promptTokens - startupTokens - injectedObservationTokens);
|
|
88
|
-
const accumulatedGroups = [group("conversation", "Conversation", promptTokens > 0 ? [{
|
|
89
|
-
id: "conversation:messages",
|
|
90
|
-
label: "Messages, tool calls and results",
|
|
91
|
-
tokens: conversationTokens,
|
|
92
|
-
characters: 0,
|
|
93
|
-
percent: 0
|
|
94
|
-
}] : [], `Derived from the provider's last request (~${promptTokens} prompt tokens) minus the startup context measured above.`), group("observations", "Observation memory", observationEntries, "Observations kept only in storage are not counted: they cost nothing until recalled.")].filter((entry) => entry !== void 0);
|
|
95
|
-
const accumulatedTokens = sumTokens(accumulatedGroups);
|
|
96
|
-
const totalTokens = startupTokens + accumulatedTokens;
|
|
97
|
-
for (const entry of [...startupGroups, ...accumulatedGroups]) withPercent(entry.entries, totalTokens);
|
|
98
|
-
withPercent(startupGroups, totalTokens);
|
|
99
|
-
withPercent(accumulatedGroups, totalTokens);
|
|
100
|
-
return {
|
|
101
|
-
startup: {
|
|
102
|
-
tokens: startupTokens,
|
|
103
|
-
percent: totalTokens > 0 ? startupTokens / totalTokens * 100 : 0,
|
|
104
|
-
groups: startupGroups
|
|
105
|
-
},
|
|
106
|
-
accumulated: {
|
|
107
|
-
tokens: accumulatedTokens,
|
|
108
|
-
percent: totalTokens > 0 ? accumulatedTokens / totalTokens * 100 : 0,
|
|
109
|
-
groups: accumulatedGroups
|
|
110
|
-
},
|
|
111
|
-
totalTokens,
|
|
112
|
-
estimated: true
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
//#endregion
|
|
116
|
-
export { buildContextAudit };
|
|
117
|
-
|
|
118
|
-
//# sourceMappingURL=context-audit.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context-audit.js","names":[],"sources":["../../src/agents/context-audit.ts"],"sourcesContent":["/**\n * Context audit — accounts for what occupies the model's context window.\n *\n * Deliberately pure: callers collect the real strings (prompt sections, the\n * injected skills catalog, tool definitions) and this module only measures and\n * groups them. That keeps the audit honest — it reports on the same text the\n * model receives rather than a description of it — and keeps it testable\n * without a live session.\n *\n * Nothing here reads file contents or secrets: entries carry labels, origins\n * and sizes only, never the underlying text, so an audit can be shown or\n * pasted without leaking whatever the context happens to contain.\n */\nimport { tokenEstimate } from '../utils/token-estimator.js';\nimport type { PromptSection } from './prompts/index.js';\n\n/** A single measured contributor to the context window. */\nexport interface ContextAuditEntry {\n id: string;\n label: string;\n /** Provenance: file path, server name, model id — whatever identifies the source. */\n detail?: string;\n tokens: number;\n characters: number;\n /** Share of the audit total, 0-100. */\n percent: number;\n}\n\n/** A category of contributors (e.g. all agent instruction files). */\nexport interface ContextAuditGroup {\n id: string;\n label: string;\n tokens: number;\n /** Share of the audit total, 0-100. */\n percent: number;\n entries: ContextAuditEntry[];\n /** Shown alongside the group when its numbers need qualifying. */\n note?: string;\n}\n\nexport interface ContextAudit {\n /** Context present before the first message: system prompt, skills, tools. */\n startup: { tokens: number; percent: number; groups: ContextAuditGroup[] };\n /** Context accumulated by the session: conversation and observation memory. */\n accumulated: { tokens: number; percent: number; groups: ContextAuditGroup[] };\n /** Startup + accumulated. Percentages elsewhere are shares of this. */\n totalTokens: number;\n /** Estimated rather than measured: token counts come from a heuristic estimator. */\n estimated: true;\n}\n\n/** A tool definition as advertised to the model. */\nexport interface ContextAuditTool {\n name: string;\n description?: string;\n /** JSON schema (or any serializable shape) sent with the definition. */\n parameters?: unknown;\n /** MCP server that provides the tool, when it is not built in. */\n server?: string;\n}\n\nexport interface ContextAuditInput {\n /** Labeled sections of the assembled system prompt. */\n promptSections?: PromptSection[];\n /** Labeled sections of the per-request dynamic instructions. */\n instructionSections?: PromptSection[];\n /** The skills catalog exactly as injected into the system message. */\n skillsCatalog?: string;\n /** Tool definitions advertised to the model. */\n tools?: ContextAuditTool[];\n /**\n * Observation memory currently occupying the context window, either as the\n * injected text or as a token count reported by the memory subsystem.\n *\n * Only observations that are actually in the context belong here.\n * Observations that merely sit in storage cost nothing until recalled, and\n * conflating the two is exactly the confusion this audit exists to resolve.\n */\n injectedObservations?: string | { tokens: number };\n /** Prompt tokens the provider reported for the most recent request. */\n conversation?: { promptTokens?: number };\n}\n\nfunction measure(id: string, label: string, content: string, detail?: string): ContextAuditEntry {\n return { id, label, detail, tokens: tokenEstimate(content), characters: content.length, percent: 0 };\n}\n\nfunction sectionEntries(sections: PromptSection[], prefix: string): ContextAuditEntry[] {\n return sections\n .filter(section => section.content.length > 0)\n .map(section => measure(`${prefix}:${section.id}`, section.label, section.content, section.detail));\n}\n\nfunction group(id: string, label: string, entries: ContextAuditEntry[], note?: string): ContextAuditGroup | undefined {\n if (entries.length === 0) return undefined;\n return { id, label, tokens: entries.reduce((sum, entry) => sum + entry.tokens, 0), percent: 0, entries, note };\n}\n\n/**\n * Group tool definitions by their provider so a chatty MCP server is visible as\n * one line rather than fifty. Per-tool entries stay available underneath.\n */\nfunction toolEntries(tools: ContextAuditTool[]): ContextAuditEntry[] {\n return tools.map(tool => {\n // Approximates the serialized definition: name, description and schema are\n // what a provider sends, and the exact wire framing is provider-specific.\n const serialized = [tool.name, tool.description ?? '', tool.parameters ? JSON.stringify(tool.parameters) : ''].join(\n '\\n',\n );\n return measure(`tool:${tool.server ?? 'built-in'}:${tool.name}`, tool.name, serialized, tool.server);\n });\n}\n\nfunction withPercent<T extends { tokens: number; percent: number }>(items: T[], total: number): T[] {\n for (const item of items) {\n item.percent = total > 0 ? (item.tokens / total) * 100 : 0;\n }\n return items;\n}\n\nfunction sumTokens(groups: ContextAuditGroup[]): number {\n return groups.reduce((sum, entry) => sum + entry.tokens, 0);\n}\n\n/**\n * Build a context audit from already-collected context.\n *\n * Percentages are shares of the audited total, not of the model's context\n * window: window size is not exposed by the model registry, and inventing one\n * would make every number wrong for models that disagree with the guess.\n */\nexport function buildContextAudit(input: ContextAuditInput): ContextAudit {\n const startupGroups = [\n group('system-prompt', 'System prompt', sectionEntries(input.promptSections ?? [], 'prompt')),\n group('dynamic-instructions', 'Dynamic instructions', sectionEntries(input.instructionSections ?? [], 'dynamic')),\n group(\n 'skills',\n 'Skills catalog',\n input.skillsCatalog ? [measure('skills:catalog', 'Available skills', input.skillsCatalog)] : [],\n 'Skill instructions are loaded on demand and are not counted here.',\n ),\n group('tools', 'Tool definitions', toolEntries(input.tools ?? [])),\n ].filter((entry): entry is ContextAuditGroup => entry !== undefined);\n\n const observationEntries: ContextAuditEntry[] = [];\n if (typeof input.injectedObservations === 'string') {\n observationEntries.push(measure('observations:injected', 'Injected into context', input.injectedObservations));\n } else if (input.injectedObservations && input.injectedObservations.tokens > 0) {\n observationEntries.push({\n id: 'observations:injected',\n label: 'Injected into context',\n tokens: input.injectedObservations.tokens,\n characters: 0,\n percent: 0,\n });\n }\n\n const startupTokens = sumTokens(startupGroups);\n const injectedObservationTokens = observationEntries.reduce((sum, entry) => sum + entry.tokens, 0);\n\n // The provider's prompt token count covers the whole request — startup\n // context and injected observations included — so the conversation's own\n // contribution is what is left after subtracting everything already\n // accounted for. Using the raw prompt count would double-count all of it.\n const promptTokens = input.conversation?.promptTokens ?? 0;\n const conversationTokens = Math.max(0, promptTokens - startupTokens - injectedObservationTokens);\n const conversationEntries: ContextAuditEntry[] =\n promptTokens > 0\n ? [\n {\n id: 'conversation:messages',\n label: 'Messages, tool calls and results',\n tokens: conversationTokens,\n characters: 0,\n percent: 0,\n },\n ]\n : [];\n\n const accumulatedGroups = [\n group(\n 'conversation',\n 'Conversation',\n conversationEntries,\n `Derived from the provider's last request (~${promptTokens} prompt tokens) minus the startup context measured above.`,\n ),\n group(\n 'observations',\n 'Observation memory',\n observationEntries,\n 'Observations kept only in storage are not counted: they cost nothing until recalled.',\n ),\n ].filter((entry): entry is ContextAuditGroup => entry !== undefined);\n\n const accumulatedTokens = sumTokens(accumulatedGroups);\n const totalTokens = startupTokens + accumulatedTokens;\n\n for (const entry of [...startupGroups, ...accumulatedGroups]) {\n withPercent(entry.entries, totalTokens);\n }\n withPercent(startupGroups, totalTokens);\n withPercent(accumulatedGroups, totalTokens);\n\n return {\n startup: {\n tokens: startupTokens,\n percent: totalTokens > 0 ? (startupTokens / totalTokens) * 100 : 0,\n groups: startupGroups,\n },\n accumulated: {\n tokens: accumulatedTokens,\n percent: totalTokens > 0 ? (accumulatedTokens / totalTokens) * 100 : 0,\n groups: accumulatedGroups,\n },\n totalTokens,\n estimated: true,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;AAmFA,SAAS,QAAQ,IAAY,OAAe,SAAiB,QAAoC;CAC/F,OAAO;EAAE;EAAI;EAAO;EAAQ,QAAQ,cAAc,OAAO;EAAG,YAAY,QAAQ;EAAQ,SAAS;CAAE;AACrG;AAEA,SAAS,eAAe,UAA2B,QAAqC;CACtF,OAAO,SACJ,QAAO,YAAW,QAAQ,QAAQ,SAAS,CAAC,CAAC,CAC7C,KAAI,YAAW,QAAQ,GAAG,OAAO,GAAG,QAAQ,MAAM,QAAQ,OAAO,QAAQ,SAAS,QAAQ,MAAM,CAAC;AACtG;AAEA,SAAS,MAAM,IAAY,OAAe,SA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AAyB,MAAM,oBAAoB,CAAC;MACxG,IAAI,MAAM,wBAAwB,MAAM,qBAAqB,SAAS,GAC3E,mBAAmB,KAAK;EACtB,IAAI;EACJ,OAAO;EACP,QAAQ,MAAM,qBAAqB;EACnC,YAAY;EACZ,SAAS;CACX,CAAC;CAGH,MAAM,gBAAgB,UAAU,aAAa;CAC7C,MAAM,4BAA4B,mBAAmB,QAAQ,KAAK,UAAU,MAAM,MAAM,QAAQ,CAAC;CAMjG,MAAM,eAAe,MAAM,cAAc,gBAAgB;CACzD,MAAM,qBAAqB,KAAK,IAAI,GAAG,eAAe,gBAAgB,yBAAyB;CAc/F,MAAM,oBAAoB,CACxB,MACE,gBACA,gBAfF,eAAe,IACX,CACE;EACE,IAAI;EACJ,OAAO;EACP,QAAQ;EACR,YAAY;EACZ,SAAS;CACX,CACF,IACA,CAAC,GAOH,8CAA8C,aAAa,0DAC7D,GACA,MACE,gBACA,sBACA,oBACA,sFACF,CACF,CAAC,CAAC,QAAQ,UAAsC,UAAU,KAAA,CAAS;CAEnE,MAAM,oBAAoB,UAAU,iBAAiB;CACrD,MAAM,cAAc,gBAAgB;CAEpC,KAAK,MAAM,SAAS,CAAC,GAAG,eAAe,GAAG,iBAAiB,GACzD,YAAY,MAAM,SAAS,WAAW;CAExC,YAAY,eAAe,WAAW;CACtC,YAAY,mBAAmB,WAAW;CAE1C,OAAO;EACL,SAAS;GACP,QAAQ;GACR,SAAS,cAAc,IAAK,gBAAgB,cAAe,MAAM;GACjE,QAAQ;EACV;EACA,aAAa;GACX,QAAQ;GACR,SAAS,cAAc,IAAK,oBAAoB,cAAe,MAAM;GACrE,QAAQ;EACV;EACA;EACA,WAAW;CACb;AACF"}
|
package/dist/thinking.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
export type ThinkingLevelSetting = 'off' | 'low' | 'medium' | 'high' | 'xhigh' | 'max';
|
|
2
|
-
export type ThinkingLevelSource = 'mode-default' | 'global';
|
|
3
|
-
export interface ThinkingDefaults {
|
|
4
|
-
globalDefault: ThinkingLevelSetting;
|
|
5
|
-
modeDefaults: Readonly<Record<string, ThinkingLevelSetting>>;
|
|
6
|
-
}
|
|
7
|
-
export declare const THINKING_LEVEL_VALUES: ThinkingLevelSetting[];
|
|
8
|
-
export declare const THINK_COMMAND_DESCRIPTOR: {
|
|
9
|
-
name: string;
|
|
10
|
-
args: string;
|
|
11
|
-
description: string;
|
|
12
|
-
};
|
|
13
|
-
export type ThinkCommandAction = {
|
|
14
|
-
kind: 'status';
|
|
15
|
-
} | {
|
|
16
|
-
kind: 'clear';
|
|
17
|
-
} | {
|
|
18
|
-
kind: 'set';
|
|
19
|
-
level: ThinkingLevelSetting;
|
|
20
|
-
} | {
|
|
21
|
-
kind: 'invalid';
|
|
22
|
-
value: string;
|
|
23
|
-
levels: readonly ThinkingLevelSetting[];
|
|
24
|
-
};
|
|
25
|
-
export declare function isThinkingLevelSetting(value: unknown): value is ThinkingLevelSetting;
|
|
26
|
-
export declare function supportsMaxReasoningEffort(modelId: string): boolean;
|
|
27
|
-
export declare function getAvailableThinkingLevelsForModel(modelId: string): ThinkingLevelSetting[];
|
|
28
|
-
export declare function parseThinkCommand(input: string, levels?: readonly ThinkingLevelSetting[]): ThinkCommandAction;
|
|
29
|
-
export declare function resolveDefaultThinkingLevel(defaults: ThinkingDefaults, mode?: string | null): {
|
|
30
|
-
level: ThinkingLevelSetting;
|
|
31
|
-
source: ThinkingLevelSource;
|
|
32
|
-
};
|
|
33
|
-
//# sourceMappingURL=thinking.d.ts.map
|
package/dist/thinking.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"thinking.d.ts","sourceRoot":"","sources":["../src/thinking.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,oBAAoB,GAAG,KAAK,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,CAAC;AAEvF,MAAM,MAAM,mBAAmB,GAAG,cAAc,GAAG,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
"medium",
|
|
6
|
-
"high",
|
|
7
|
-
"xhigh",
|
|
8
|
-
"max"
|
|
9
|
-
];
|
|
10
|
-
const THINK_COMMAND_DESCRIPTOR = {
|
|
11
|
-
name: "think",
|
|
12
|
-
args: "[status|default|off|low|medium|high|xhigh|max]",
|
|
13
|
-
description: "Show or set session thinking level"
|
|
14
|
-
};
|
|
15
|
-
const GPT_VERSION_RE = /^gpt-(\d+)(?:\.(\d+))?/;
|
|
16
|
-
function isThinkingLevelSetting(value) {
|
|
17
|
-
return typeof value === "string" && THINKING_LEVEL_VALUES.some((level) => level === value);
|
|
18
|
-
}
|
|
19
|
-
function supportsMaxReasoningEffort(modelId) {
|
|
20
|
-
const bareModelId = modelId.startsWith("openai/") ? modelId.slice(7) : modelId;
|
|
21
|
-
const match = GPT_VERSION_RE.exec(bareModelId);
|
|
22
|
-
if (!match) return false;
|
|
23
|
-
const major = Number(match[1]);
|
|
24
|
-
const minor = Number(match[2] ?? 0);
|
|
25
|
-
return major > 5 || major === 5 && minor >= 6;
|
|
26
|
-
}
|
|
27
|
-
function getAvailableThinkingLevelsForModel(modelId) {
|
|
28
|
-
if (!modelId.startsWith("openai/") || supportsMaxReasoningEffort(modelId)) return [...THINKING_LEVEL_VALUES];
|
|
29
|
-
return THINKING_LEVEL_VALUES.filter((level) => level !== "max");
|
|
30
|
-
}
|
|
31
|
-
function parseThinkCommand(input, levels = THINKING_LEVEL_VALUES) {
|
|
32
|
-
const value = input.trim().toLowerCase();
|
|
33
|
-
if (!value || value === "status") return { kind: "status" };
|
|
34
|
-
if (value === "default" || value === "clear") return { kind: "clear" };
|
|
35
|
-
const level = levels.find((candidate) => candidate === value);
|
|
36
|
-
return level ? {
|
|
37
|
-
kind: "set",
|
|
38
|
-
level
|
|
39
|
-
} : {
|
|
40
|
-
kind: "invalid",
|
|
41
|
-
value,
|
|
42
|
-
levels
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
function resolveDefaultThinkingLevel(defaults, mode) {
|
|
46
|
-
const modeLevel = mode ? defaults.modeDefaults[mode] : void 0;
|
|
47
|
-
return modeLevel ? {
|
|
48
|
-
level: modeLevel,
|
|
49
|
-
source: "mode-default"
|
|
50
|
-
} : {
|
|
51
|
-
level: defaults.globalDefault,
|
|
52
|
-
source: "global"
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
//#endregion
|
|
56
|
-
export { THINKING_LEVEL_VALUES, THINK_COMMAND_DESCRIPTOR, getAvailableThinkingLevelsForModel, isThinkingLevelSetting, parseThinkCommand, resolveDefaultThinkingLevel, supportsMaxReasoningEffort };
|
|
57
|
-
|
|
58
|
-
//# sourceMappingURL=thinking.js.map
|
package/dist/thinking.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"thinking.js","names":[],"sources":["../src/thinking.ts"],"sourcesContent":["export type ThinkingLevelSetting = 'off' | 'low' | 'medium' | 'high' | 'xhigh' | 'max';\n\nexport type ThinkingLevelSource = 'mode-default' | 'global';\n\nexport interface ThinkingDefaults {\n globalDefault: ThinkingLevelSetting;\n modeDefaults: Readonly<Record<string, ThinkingLevelSetting>>;\n}\n\nexport const THINKING_LEVEL_VALUES: ThinkingLevelSetting[] = ['off', 'low', 'medium', 'high', 'xhigh', 'max'];\n\nexport const THINK_COMMAND_DESCRIPTOR = {\n name: 'think',\n args: '[status|default|off|low|medium|high|xhigh|max]',\n description: 'Show or set session thinking level',\n};\n\nexport type ThinkCommandAction =\n | { kind: 'status' }\n | { kind: 'clear' }\n | { kind: 'set'; level: ThinkingLevelSetting }\n | { kind: 'invalid'; value: string; levels: readonly ThinkingLevelSetting[] };\n\nconst GPT_VERSION_RE = /^gpt-(\\d+)(?:\\.(\\d+))?/;\n\nexport function isThinkingLevelSetting(value: unknown): value is ThinkingLevelSetting {\n return typeof value === 'string' && THINKING_LEVEL_VALUES.some(level => level === value);\n}\n\nexport function supportsMaxReasoningEffort(modelId: string): boolean {\n const bareModelId = modelId.startsWith('openai/') ? modelId.slice('openai/'.length) : modelId;\n const match = GPT_VERSION_RE.exec(bareModelId);\n if (!match) return false;\n const major = Number(match[1]);\n const minor = Number(match[2] ?? 0);\n return major > 5 || (major === 5 && minor >= 6);\n}\n\nexport function getAvailableThinkingLevelsForModel(modelId: string): ThinkingLevelSetting[] {\n if (!modelId.startsWith('openai/') || supportsMaxReasoningEffort(modelId)) {\n return [...THINKING_LEVEL_VALUES];\n }\n return THINKING_LEVEL_VALUES.filter(level => level !== 'max');\n}\n\nexport function parseThinkCommand(\n input: string,\n levels: readonly ThinkingLevelSetting[] = THINKING_LEVEL_VALUES,\n): ThinkCommandAction {\n const value = input.trim().toLowerCase();\n if (!value || value === 'status') return { kind: 'status' };\n if (value === 'default' || value === 'clear') return { kind: 'clear' };\n const level = levels.find(candidate => candidate === value);\n return level ? { kind: 'set', level } : { kind: 'invalid', value, levels };\n}\n\nexport function resolveDefaultThinkingLevel(\n defaults: ThinkingDefaults,\n mode?: string | null,\n): { level: ThinkingLevelSetting; source: ThinkingLevelSource } {\n const modeLevel = mode ? defaults.modeDefaults[mode] : undefined;\n return modeLevel ? { level: modeLevel, source: 'mode-default' } : { level: defaults.globalDefault, source: 'global' };\n}\n"],"mappings":";AASA,MAAa,wBAAgD;CAAC;CAAO;CAAO;CAAU;CAAQ;CAAS;AAAK;AAE5G,MAAa,2BAA2B;CACtC,MAAM;CACN,MAAM;CACN,aAAa;AACf;AAQA,MAAM,iBAAiB;AAEvB,SAAgB,uBAAuB,OAA+C;CACpF,OAAO,OAAO,UAAU,YAAY,sBAAsB,MAAK,UAAS,UAAU,KAAK;AACzF;AAEA,SAAgB,2BAA2B,SAA0B;CACnE,MAAM,cAAc,QAAQ,WAAW,SAAS,IAAI,QAAQ,MAAM,CAAgB,IAAI;CACtF,MAAM,QAAQ,eAAe,KAAK,WAAW;CAC7C,IAAI,CAAC,OAAO,OAAO;CACnB,MAAM,QAAQ,OAAO,MAAM,EAAE;CAC7B,MAAM,QAAQ,OAAO,MAAM,MAA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