@caupulican/pi-adaptative 0.81.12 → 0.81.13
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 +6 -1
- package/dist/bundled-resources/skills/tool-call-repair/SKILL.md +22 -18
- package/dist/cli/list-models.d.ts.map +1 -1
- package/dist/cli/list-models.js +5 -0
- package/dist/cli/list-models.js.map +1 -1
- package/dist/core/agent-session.d.ts +28 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +215 -19
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/model-registry.d.ts +1 -0
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +6 -0
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/models/adaptation-store.d.ts +18 -1
- package/dist/core/models/adaptation-store.d.ts.map +1 -1
- package/dist/core/models/adaptation-store.js +31 -3
- package/dist/core/models/adaptation-store.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +5 -0
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/tool-repair-health.d.ts.map +1 -1
- package/dist/core/tool-repair-health.js +21 -1
- package/dist/core/tool-repair-health.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +24 -0
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +8 -0
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +23 -1
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/docs/models.md +5 -1
- package/docs/rpc.md +39 -0
- package/docs/settings.md +4 -2
- package/docs/tool-repair.md +13 -5
- package/docs/usage.md +1 -0
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +12 -12
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
## [
|
|
1
|
+
## [0.81.13] - 2026-07-07
|
|
2
|
+
|
|
3
|
+
### Fixed
|
|
4
|
+
- Fixed custom model registration to preserve `textToolCallProtocol` and show it in `--list-models`.
|
|
5
|
+
- Fixed text tool protocol calibration failures to persist, fail fast until explicit reset, and invalidate stale calibrated protocols after repeated live parse failures.
|
|
6
|
+
- Added `/toolprobe` and RPC `tool_probe` to live-probe native/text-protocol tool-call support and persist host-local verdicts.
|
|
2
7
|
|
|
3
8
|
## [0.81.12] - 2026-07-07
|
|
4
9
|
|
|
@@ -92,34 +92,38 @@ as code (not prose):
|
|
|
92
92
|
grep, find).
|
|
93
93
|
- **Failure grammar** (`references/failure-grammar.md`) — how a malformed
|
|
94
94
|
call is recognized and repaired: the `errorSignature → transform → guard →
|
|
95
|
-
note` table (
|
|
96
|
-
bash (`command` as argv-array or object-wrapper,
|
|
97
|
-
edit, read/ls/grep/find. This is what `analyzer.ts`
|
|
95
|
+
note` table (tool-agnostic modes, including the required-null bounce) plus
|
|
96
|
+
the tool-specific rows for bash (`command` as argv-array or object-wrapper,
|
|
97
|
+
`timeout` as string/{}), edit, read/ls/grep/find. This is what `analyzer.ts`
|
|
98
|
+
classifies against.
|
|
98
99
|
|
|
99
100
|
## The catalogue (summary; full table in references/failure-grammar.md)
|
|
100
101
|
|
|
101
102
|
| # | Name | Model emits | Repair (guard-gated) |
|
|
102
103
|
|---|---|---|---|
|
|
103
|
-
| 1 | nullOptionalDrop | `null` for an optional field | delete key
|
|
104
|
-
| 2 |
|
|
105
|
-
| 3 |
|
|
106
|
-
| 4 |
|
|
107
|
-
| 5 |
|
|
108
|
-
| 6 |
|
|
109
|
-
| 7 |
|
|
110
|
-
| 8 |
|
|
111
|
-
| 9 |
|
|
112
|
-
| 10 |
|
|
104
|
+
| 1 | nullOptionalDrop | `null` for an optional field | delete key |
|
|
105
|
+
| 2 | nullRequiredBounce | `null` for a required field | no repair; bounce with required-value feedback |
|
|
106
|
+
| 3 | jsonStringParse | `"[...]"`/`"{...}"` string where container expected | JSON.parse; keep if it matches + checks |
|
|
107
|
+
| 4 | singleObjectWrap | single object where array-of-objects expected | wrap `[obj]` if it passes `items` |
|
|
108
|
+
| 5 | bareScalarWrap | bare scalar where array expected | wrap `[v]` if it passes `items` |
|
|
109
|
+
| 6 | emptyObjectPlaceholder | `{}` placeholder where scalar expected | delete if optional (default applies); else bounce |
|
|
110
|
+
| 7 | numberFromString | `"42"` where number expected | `Number(s)` if finite |
|
|
111
|
+
| 8 | boolFromString | `"true"`/`"false"` where bool expected | exact map (never truthiness) |
|
|
112
|
+
| 9 | enumCaseNormalize | case/space enum variant | match to the one member, else bounce |
|
|
113
|
+
| 10 | singleElementUnwrap | `[v]` where scalar expected | unwrap if 1 elem and checks |
|
|
114
|
+
| 11 | stringifiedNumberInArray | `["1","2"]` where number[] expected | map Number if all finite |
|
|
115
|
+
| 12 | bashCommandArgvJoin | bash `command` sent as an argv list | join string values with spaces |
|
|
116
|
+
| 13 | bashCommandUnwrap | bash `command` sent as a single-key object wrapper | unwrap the string-valued wrapper |
|
|
113
117
|
|
|
114
|
-
|
|
115
|
-
`bashCommandUnwrap` (`{cmd}` → string). Every entry is a NAMED registry entry
|
|
118
|
+
Every entry is a NAMED registry entry
|
|
116
119
|
`{name, errorSignature, transform, guard, noteTemplate}` — one table powers
|
|
117
120
|
the repair, the teach note, the telemetry tag, and the docs row: the
|
|
118
121
|
deterministic set of what pi can and will repair. Repairs NEVER invent values
|
|
119
122
|
and are ALWAYS guard-gated (kept only if the transform Checks), so a repair
|
|
120
|
-
can only ever turn an invalid call valid, never alter a valid one.
|
|
121
|
-
and
|
|
122
|
-
path nothing because they run only on already-failed calls (see decision
|
|
123
|
+
can only ever turn an invalid call valid, never alter a valid one. The scalar,
|
|
124
|
+
array-number, and bash rows are the increment past the original four; they cost
|
|
125
|
+
the hot path nothing because they run only on already-failed calls (see decision
|
|
126
|
+
2a).
|
|
123
127
|
|
|
124
128
|
## Method for an improvement pass
|
|
125
129
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-models.d.ts","sourceRoot":"","sources":["../../src/cli/list-models.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAiB/D;;GAEG;AACH,wBAAsB,UAAU,CAAC,aAAa,EAAE,aAAa,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"list-models.d.ts","sourceRoot":"","sources":["../../src/cli/list-models.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAiB/D;;GAEG;AACH,wBAAsB,UAAU,CAAC,aAAa,EAAE,aAAa,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAuFpG","sourcesContent":["/**\n * List available models with optional fuzzy search\n */\n\nimport type { Api, Model } from \"@caupulican/pi-ai\";\nimport { fuzzyFilter } from \"@caupulican/pi-tui\";\nimport chalk from \"chalk\";\nimport { formatNoModelsAvailableMessage } from \"../core/auth-guidance.ts\";\nimport type { ModelRegistry } from \"../core/model-registry.ts\";\n\n/**\n * Format a number as human-readable (e.g., 200000 -> \"200K\", 1000000 -> \"1M\")\n */\nfunction formatTokenCount(count: number): string {\n\tif (count >= 1_000_000) {\n\t\tconst millions = count / 1_000_000;\n\t\treturn millions % 1 === 0 ? `${millions}M` : `${millions.toFixed(1)}M`;\n\t}\n\tif (count >= 1_000) {\n\t\tconst thousands = count / 1_000;\n\t\treturn thousands % 1 === 0 ? `${thousands}K` : `${thousands.toFixed(1)}K`;\n\t}\n\treturn count.toString();\n}\n\n/**\n * List available models, optionally filtered by search pattern\n */\nexport async function listModels(modelRegistry: ModelRegistry, searchPattern?: string): Promise<void> {\n\tconst loadError = modelRegistry.getError();\n\tif (loadError) {\n\t\tconsole.error(chalk.yellow(`Warning: errors loading models.json:\\n${loadError}`));\n\t}\n\n\tconst models = modelRegistry.getAvailable();\n\n\tif (models.length === 0) {\n\t\tconsole.log(formatNoModelsAvailableMessage());\n\t\treturn;\n\t}\n\n\t// Apply fuzzy filter if search pattern provided\n\tlet filteredModels: Model<Api>[] = models;\n\tif (searchPattern) {\n\t\tfilteredModels = fuzzyFilter(models, searchPattern, (m) => `${m.provider} ${m.id}`);\n\t}\n\n\tif (filteredModels.length === 0) {\n\t\tconsole.log(`No models matching \"${searchPattern}\"`);\n\t\treturn;\n\t}\n\n\t// Sort by provider, then by model id\n\tfilteredModels.sort((a, b) => {\n\t\tconst providerCmp = a.provider.localeCompare(b.provider);\n\t\tif (providerCmp !== 0) return providerCmp;\n\t\treturn a.id.localeCompare(b.id);\n\t});\n\n\t// Calculate column widths\n\tconst rows = filteredModels.map((m) => ({\n\t\tprovider: m.provider,\n\t\tmodel: m.id,\n\t\tcontext: formatTokenCount(m.contextWindow),\n\t\tmaxOut: formatTokenCount(m.maxTokens),\n\t\tthinking: m.reasoning ? \"yes\" : \"no\",\n\t\timages: m.input.includes(\"image\") ? \"yes\" : \"no\",\n\t\ttextTools: m.textToolCallProtocol ? \"yes\" : \"no\",\n\t}));\n\n\tconst headers = {\n\t\tprovider: \"provider\",\n\t\tmodel: \"model\",\n\t\tcontext: \"context\",\n\t\tmaxOut: \"max-out\",\n\t\tthinking: \"thinking\",\n\t\timages: \"images\",\n\t\ttextTools: \"text-tools\",\n\t};\n\n\tconst widths = {\n\t\tprovider: Math.max(headers.provider.length, ...rows.map((r) => r.provider.length)),\n\t\tmodel: Math.max(headers.model.length, ...rows.map((r) => r.model.length)),\n\t\tcontext: Math.max(headers.context.length, ...rows.map((r) => r.context.length)),\n\t\tmaxOut: Math.max(headers.maxOut.length, ...rows.map((r) => r.maxOut.length)),\n\t\tthinking: Math.max(headers.thinking.length, ...rows.map((r) => r.thinking.length)),\n\t\timages: Math.max(headers.images.length, ...rows.map((r) => r.images.length)),\n\t\ttextTools: Math.max(headers.textTools.length, ...rows.map((r) => r.textTools.length)),\n\t};\n\n\t// Print header\n\tconst headerLine = [\n\t\theaders.provider.padEnd(widths.provider),\n\t\theaders.model.padEnd(widths.model),\n\t\theaders.context.padEnd(widths.context),\n\t\theaders.maxOut.padEnd(widths.maxOut),\n\t\theaders.thinking.padEnd(widths.thinking),\n\t\theaders.images.padEnd(widths.images),\n\t\theaders.textTools.padEnd(widths.textTools),\n\t].join(\" \");\n\tconsole.log(headerLine);\n\n\t// Print rows\n\tfor (const row of rows) {\n\t\tconst line = [\n\t\t\trow.provider.padEnd(widths.provider),\n\t\t\trow.model.padEnd(widths.model),\n\t\t\trow.context.padEnd(widths.context),\n\t\t\trow.maxOut.padEnd(widths.maxOut),\n\t\t\trow.thinking.padEnd(widths.thinking),\n\t\t\trow.images.padEnd(widths.images),\n\t\t\trow.textTools.padEnd(widths.textTools),\n\t\t].join(\" \");\n\t\tconsole.log(line);\n\t}\n}\n"]}
|
package/dist/cli/list-models.js
CHANGED
|
@@ -55,6 +55,7 @@ export async function listModels(modelRegistry, searchPattern) {
|
|
|
55
55
|
maxOut: formatTokenCount(m.maxTokens),
|
|
56
56
|
thinking: m.reasoning ? "yes" : "no",
|
|
57
57
|
images: m.input.includes("image") ? "yes" : "no",
|
|
58
|
+
textTools: m.textToolCallProtocol ? "yes" : "no",
|
|
58
59
|
}));
|
|
59
60
|
const headers = {
|
|
60
61
|
provider: "provider",
|
|
@@ -63,6 +64,7 @@ export async function listModels(modelRegistry, searchPattern) {
|
|
|
63
64
|
maxOut: "max-out",
|
|
64
65
|
thinking: "thinking",
|
|
65
66
|
images: "images",
|
|
67
|
+
textTools: "text-tools",
|
|
66
68
|
};
|
|
67
69
|
const widths = {
|
|
68
70
|
provider: Math.max(headers.provider.length, ...rows.map((r) => r.provider.length)),
|
|
@@ -71,6 +73,7 @@ export async function listModels(modelRegistry, searchPattern) {
|
|
|
71
73
|
maxOut: Math.max(headers.maxOut.length, ...rows.map((r) => r.maxOut.length)),
|
|
72
74
|
thinking: Math.max(headers.thinking.length, ...rows.map((r) => r.thinking.length)),
|
|
73
75
|
images: Math.max(headers.images.length, ...rows.map((r) => r.images.length)),
|
|
76
|
+
textTools: Math.max(headers.textTools.length, ...rows.map((r) => r.textTools.length)),
|
|
74
77
|
};
|
|
75
78
|
// Print header
|
|
76
79
|
const headerLine = [
|
|
@@ -80,6 +83,7 @@ export async function listModels(modelRegistry, searchPattern) {
|
|
|
80
83
|
headers.maxOut.padEnd(widths.maxOut),
|
|
81
84
|
headers.thinking.padEnd(widths.thinking),
|
|
82
85
|
headers.images.padEnd(widths.images),
|
|
86
|
+
headers.textTools.padEnd(widths.textTools),
|
|
83
87
|
].join(" ");
|
|
84
88
|
console.log(headerLine);
|
|
85
89
|
// Print rows
|
|
@@ -91,6 +95,7 @@ export async function listModels(modelRegistry, searchPattern) {
|
|
|
91
95
|
row.maxOut.padEnd(widths.maxOut),
|
|
92
96
|
row.thinking.padEnd(widths.thinking),
|
|
93
97
|
row.images.padEnd(widths.images),
|
|
98
|
+
row.textTools.padEnd(widths.textTools),
|
|
94
99
|
].join(" ");
|
|
95
100
|
console.log(line);
|
|
96
101
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-models.js","sourceRoot":"","sources":["../../src/cli/list-models.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,MAAM,OAAO,CA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AM,CAAC,MAAM,CAAC,QAAQ,CAAC;YACpC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;YAC9B,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC;YAClC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC;YAChC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC;YACpC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC;YAChC,GAAG,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC;SACtC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACb,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACnB,CAAC;AAAA,CACD","sourcesContent":["/**\n * List available models with optional fuzzy search\n */\n\nimport type { Api, Model } from \"@caupulican/pi-ai\";\nimport { fuzzyFilter } from \"@caupulican/pi-tui\";\nimport chalk from \"chalk\";\nimport { formatNoModelsAvailableMessage } from \"../core/auth-guidance.ts\";\nimport type { ModelRegistry } from \"../core/model-registry.ts\";\n\n/**\n * Format a number as human-readable (e.g., 200000 -> \"200K\", 1000000 -> \"1M\")\n */\nfunction formatTokenCount(count: number): string {\n\tif (count >= 1_000_000) {\n\t\tconst millions = count / 1_000_000;\n\t\treturn millions % 1 === 0 ? `${millions}M` : `${millions.toFixed(1)}M`;\n\t}\n\tif (count >= 1_000) {\n\t\tconst thousands = count / 1_000;\n\t\treturn thousands % 1 === 0 ? `${thousands}K` : `${thousands.toFixed(1)}K`;\n\t}\n\treturn count.toString();\n}\n\n/**\n * List available models, optionally filtered by search pattern\n */\nexport async function listModels(modelRegistry: ModelRegistry, searchPattern?: string): Promise<void> {\n\tconst loadError = modelRegistry.getError();\n\tif (loadError) {\n\t\tconsole.error(chalk.yellow(`Warning: errors loading models.json:\\n${loadError}`));\n\t}\n\n\tconst models = modelRegistry.getAvailable();\n\n\tif (models.length === 0) {\n\t\tconsole.log(formatNoModelsAvailableMessage());\n\t\treturn;\n\t}\n\n\t// Apply fuzzy filter if search pattern provided\n\tlet filteredModels: Model<Api>[] = models;\n\tif (searchPattern) {\n\t\tfilteredModels = fuzzyFilter(models, searchPattern, (m) => `${m.provider} ${m.id}`);\n\t}\n\n\tif (filteredModels.length === 0) {\n\t\tconsole.log(`No models matching \"${searchPattern}\"`);\n\t\treturn;\n\t}\n\n\t// Sort by provider, then by model id\n\tfilteredModels.sort((a, b) => {\n\t\tconst providerCmp = a.provider.localeCompare(b.provider);\n\t\tif (providerCmp !== 0) return providerCmp;\n\t\treturn a.id.localeCompare(b.id);\n\t});\n\n\t// Calculate column widths\n\tconst rows = filteredModels.map((m) => ({\n\t\tprovider: m.provider,\n\t\tmodel: m.id,\n\t\tcontext: formatTokenCount(m.contextWindow),\n\t\tmaxOut: formatTokenCount(m.maxTokens),\n\t\tthinking: m.reasoning ? \"yes\" : \"no\",\n\t\timages: m.input.includes(\"image\") ? \"yes\" : \"no\",\n\t\ttextTools: m.textToolCallProtocol ? \"yes\" : \"no\",\n\t}));\n\n\tconst headers = {\n\t\tprovider: \"provider\",\n\t\tmodel: \"model\",\n\t\tcontext: \"context\",\n\t\tmaxOut: \"max-out\",\n\t\tthinking: \"thinking\",\n\t\timages: \"images\",\n\t\ttextTools: \"text-tools\",\n\t};\n\n\tconst widths = {\n\t\tprovider: Math.max(headers.provider.length, ...rows.map((r) => r.provider.length)),\n\t\tmodel: Math.max(headers.model.length, ...rows.map((r) => r.model.length)),\n\t\tcontext: Math.max(headers.context.length, ...rows.map((r) => r.context.length)),\n\t\tmaxOut: Math.max(headers.maxOut.length, ...rows.map((r) => r.maxOut.length)),\n\t\tthinking: Math.max(headers.thinking.length, ...rows.map((r) => r.thinking.length)),\n\t\timages: Math.max(headers.images.length, ...rows.map((r) => r.images.length)),\n\t\ttextTools: Math.max(headers.textTools.length, ...rows.map((r) => r.textTools.length)),\n\t};\n\n\t// Print header\n\tconst headerLine = [\n\t\theaders.provider.padEnd(widths.provider),\n\t\theaders.model.padEnd(widths.model),\n\t\theaders.context.padEnd(widths.context),\n\t\theaders.maxOut.padEnd(widths.maxOut),\n\t\theaders.thinking.padEnd(widths.thinking),\n\t\theaders.images.padEnd(widths.images),\n\t\theaders.textTools.padEnd(widths.textTools),\n\t].join(\" \");\n\tconsole.log(headerLine);\n\n\t// Print rows\n\tfor (const row of rows) {\n\t\tconst line = [\n\t\t\trow.provider.padEnd(widths.provider),\n\t\t\trow.model.padEnd(widths.model),\n\t\t\trow.context.padEnd(widths.context),\n\t\t\trow.maxOut.padEnd(widths.maxOut),\n\t\t\trow.thinking.padEnd(widths.thinking),\n\t\t\trow.images.padEnd(widths.images),\n\t\t\trow.textTools.padEnd(widths.textTools),\n\t\t].join(\" \");\n\t\tconsole.log(line);\n\t}\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Agent, AgentEvent, AgentMessage, AgentState, AgentTool, StreamIdleOptions, ThinkingLevel } from "@caupulican/pi-agent-core";
|
|
2
2
|
import { type CustomMessage } from "@caupulican/pi-agent-core";
|
|
3
3
|
import { type BranchSummaryEntry, type CompactionResult, type SessionManager } from "@caupulican/pi-agent-core/node";
|
|
4
|
-
import type { CacheRetention, ImageContent, Message, Model, StopReason, TextContent, Usage } from "@caupulican/pi-ai";
|
|
4
|
+
import type { CacheRetention, ImageContent, Message, Model, StopReason, TextContent, TextToolProtocolVariant, Usage } from "@caupulican/pi-ai";
|
|
5
5
|
import type { CapabilityEnvelope, EvidenceBundle, LearningDecision, WorkerRequest, WorkerResult } from "./autonomy/contracts.ts";
|
|
6
6
|
import type { LaneRecord } from "./autonomy/lane-tracker.ts";
|
|
7
7
|
import type { AutonomyDiagnosticSnapshot, AutonomyStatusSnapshot, GateOutcomeHistoryEntry } from "./autonomy/status.ts";
|
|
@@ -198,6 +198,17 @@ export interface PromptOptions {
|
|
|
198
198
|
/** Whether an idle active goal should auto-inject bounded continuation prompts after this prompt settles. Default: true. */
|
|
199
199
|
autoContinueGoal?: boolean;
|
|
200
200
|
}
|
|
201
|
+
export type ToolProbeVerdict = "native" | "text-protocol" | "none";
|
|
202
|
+
export interface ToolProbeResult {
|
|
203
|
+
model: string;
|
|
204
|
+
verdict: ToolProbeVerdict;
|
|
205
|
+
variant?: TextToolProtocolVariant;
|
|
206
|
+
diagnostic?: string;
|
|
207
|
+
}
|
|
208
|
+
export interface ToolProbeReport {
|
|
209
|
+
results: ToolProbeResult[];
|
|
210
|
+
table: string;
|
|
211
|
+
}
|
|
201
212
|
/** Result from cycleModel() */
|
|
202
213
|
export interface ModelCycleResult {
|
|
203
214
|
model: Model<any>;
|
|
@@ -361,6 +372,8 @@ export declare class AgentSession {
|
|
|
361
372
|
private readonly _localRuntimeController;
|
|
362
373
|
private readonly _modelAdaptationStore;
|
|
363
374
|
private readonly _repairModeSessionCounts;
|
|
375
|
+
private readonly _textProtocolParseFailures;
|
|
376
|
+
private _textProtocolParseObservedThisTurn;
|
|
364
377
|
/** Assembles the session's base system prompt from live session state (see
|
|
365
378
|
* system-prompt-builder.ts); owns the paired _baseSystemPromptOptions. */
|
|
366
379
|
private readonly _systemPromptBuilder;
|
|
@@ -492,9 +505,22 @@ export declare class AgentSession {
|
|
|
492
505
|
private _applyToolRepairLayerSettings;
|
|
493
506
|
private _getModelAdaptationRulesForPrompt;
|
|
494
507
|
private _textProtocolFlag;
|
|
508
|
+
private _streamForToolProbe;
|
|
495
509
|
private _textProtocolCalibrationContext;
|
|
510
|
+
private _messageHasEchoProbe;
|
|
511
|
+
private _runNativeToolProbeTrial;
|
|
496
512
|
private _runTextProtocolTrial;
|
|
513
|
+
private _calibrateTextToolProtocolForModel;
|
|
497
514
|
private _ensureTextToolProtocolForActiveModel;
|
|
515
|
+
private _modelRef;
|
|
516
|
+
private _formatToolProbeReport;
|
|
517
|
+
private _storeToolProbe;
|
|
518
|
+
private _probeToolCallingForModel;
|
|
519
|
+
private _resolveToolProbeModels;
|
|
520
|
+
probeToolCalling(target?: string): Promise<ToolProbeReport>;
|
|
521
|
+
private _handleTextToolProtocolParse;
|
|
522
|
+
private _recordTextToolProtocolParseOutcomeFromLastAssistant;
|
|
523
|
+
private _looksLikeTextToolProtocolAttempt;
|
|
498
524
|
private _recordToolValidationBounce;
|
|
499
525
|
private _tagModelAdaptationRuleTeaching;
|
|
500
526
|
private _repairSessionCount;
|
|
@@ -552,6 +578,7 @@ export declare class AgentSession {
|
|
|
552
578
|
formatContextCompositionDashboard(): string;
|
|
553
579
|
formatToolRepairHealthReport(): string;
|
|
554
580
|
removeToolRepairRule(model: string, mode: string): boolean;
|
|
581
|
+
resetToolProtocolCalibration(model: string): boolean;
|
|
555
582
|
/** Curation status for diagnostics/dashboard: settings, live telemetry, last refusal reason. */
|
|
556
583
|
/** Curation status for diagnostics/dashboard (delegates to {@link ContextPipeline.getContextCurationStatus}). */
|
|
557
584
|
getContextCurationStatus(): {
|