@vedmalex/ai-connect 0.6.0 → 0.8.0
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 +24 -1
- package/dist/browser/index.js +5 -2
- package/dist/browser/index.js.map +2 -2
- package/dist/bun/index.js +176 -11
- package/dist/bun/index.js.map +2 -2
- package/dist/bun/local.js +176 -11
- package/dist/bun/local.js.map +2 -2
- package/dist/node/index.js +176 -11
- package/dist/node/index.js.map +2 -2
- package/dist/node/local.js +176 -11
- package/dist/node/local.js.map +2 -2
- package/dist/types/acp.d.ts +14 -0
- package/dist/types/acp.d.ts.map +1 -1
- package/dist/types/cli.d.ts.map +1 -1
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/default-handlers.d.ts.map +1 -1
- package/dist/types/model-reference.d.ts.map +1 -1
- package/dist/types/types.d.ts +46 -0
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -215,6 +215,27 @@ const result = await client.generate({
|
|
|
215
215
|
});
|
|
216
216
|
```
|
|
217
217
|
|
|
218
|
+
#### ACP model selection + headless harness-noise suppression
|
|
219
|
+
|
|
220
|
+
For headless / batch prompts (e.g. per-document extraction) the ACP transport drives an interactive coding agent. Two behaviours make that robust by default:
|
|
221
|
+
|
|
222
|
+
- **Model via the protocol.** The route's model (`routeHints.model ?? account model`) is selected through a `session/set_model` call after `session/new` — you do **not** need to inject an `ANTHROPIC_MODEL` env var, and there is no env-driven "model switched" announcement leaking into the output. The call is sent only when the agent advertises a model catalog, the requested model is in its `availableModels`, and it differs from the current model; a model the agent does not advertise is surfaced as a `warning` (it is not silently replaced by the agent default).
|
|
223
|
+
- **Harness-noise suppression + guard.** Known interactive-harness marker lines (a model-switch announcement, a `Готов к работе` / `Жду …` idle greeting, `<local-command-caveat>` commentary) are filtered out of the answer text on both the `generate` and the streaming (`delta`) paths. If a turn yields **only** such harness chatter and no task output, it is surfaced as `temporary_unavailable` so the consumer can retry / fall back rather than receiving the greeting as a successful generation.
|
|
224
|
+
|
|
225
|
+
All three are on by default and can be toggled via `acp` client options:
|
|
226
|
+
|
|
227
|
+
```ts
|
|
228
|
+
const client = createLocalClient(config, {
|
|
229
|
+
acp: {
|
|
230
|
+
selectModel: true, // session/set_model from the route model (default true)
|
|
231
|
+
suppressHarnessNoise: true, // filter harness marker lines from text + deltas (default true)
|
|
232
|
+
failOnHarnessOnlyTurn: true, // harness-only turn → temporary_unavailable (default true)
|
|
233
|
+
},
|
|
234
|
+
});
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
> Limitation: the harness-noise filter / guard recognises a curated, locale-specific marker set (Claude harness, RU greetings). A reworded or other-locale greeting that still carries non-marker text is not classified as harness-only. The model-switch root cause is removed independently by `selectModel`.
|
|
238
|
+
|
|
218
239
|
Dedicated provider-specific ACP examples:
|
|
219
240
|
|
|
220
241
|
- [examples/acp-claude.ts](/Users/vedmalex/work/ai-connect/examples/acp-claude.ts)
|
|
@@ -425,7 +446,9 @@ A `cli` route exposes the same management interfaces as other providers — `dis
|
|
|
425
446
|
- **`static`** — build the catalog from the account's configured `models[]` (+ `contextWindow`). This is the default for a preset-less custom CLI that declares `models[]` (it previously reported `not_supported`); opt out with `discovery: { via: "none" }`.
|
|
426
447
|
- **`none`** — no discovery.
|
|
427
448
|
|
|
428
|
-
**Configured context window (GAP-A).** A model entry's `contextLength` is surfaced from the route's configured `contextWindow` only when discovery did not already report one (monotonic — a live discovered value always wins).
|
|
449
|
+
**Configured context window (GAP-A).** A model entry's `contextLength` is surfaced from the route's configured `contextWindow` only when discovery did not already report one (monotonic — a live discovered value always wins). Provenance is exposed on the typed field `ModelInfo.contextWindowSource`: `"discovered"` (read from a live API/cli list-command record), `"configured"` (surfaced from the route's `contextWindow`), or `undefined` (unknown). A consumer mapping `catalog.contextLength` into `resolveModelContextWindow`'s `discovered` slot should do so ONLY when `contextWindowSource === "discovered"` — treat `"configured"` as the `configured` input and `undefined` as unknown (do not promote it to the `discovered` slot) — so the precedence `discovered > reference > configured > default` stays honest. (`metadata.contextWindowSource: "configured"` is retained as a back-compat alias on the configured-fill path.)
|
|
450
|
+
|
|
451
|
+
**Discovery diagnostics.** A model-discovery route report (and its catalog) may carry a `warnings: string[]`. In particular, a cli `discovery.via: "command"` route whose list command fails/times out/returns nothing and falls back to its static `models[]` catalog records a warning there, so a degraded fallback is distinguishable from a healthy static catalog.
|
|
429
452
|
|
|
430
453
|
Current local transport scope:
|
|
431
454
|
|
package/dist/browser/index.js
CHANGED
|
@@ -1980,6 +1980,8 @@ function fillConfiguredContextLength(route, models) {
|
|
|
1980
1980
|
return {
|
|
1981
1981
|
...entry,
|
|
1982
1982
|
contextLength: configured,
|
|
1983
|
+
// FT-002: typed provenance (canonical) + metadata alias (back-compat).
|
|
1984
|
+
contextWindowSource: "configured",
|
|
1983
1985
|
metadata: { ...entry.metadata ?? {}, contextWindowSource: "configured" }
|
|
1984
1986
|
};
|
|
1985
1987
|
});
|
|
@@ -3309,7 +3311,8 @@ function createClient(configOrInput, options = {}) {
|
|
|
3309
3311
|
...catalog.canonicalModelId ? { canonicalModelId: catalog.canonicalModelId } : {},
|
|
3310
3312
|
...catalog.resolvedModelId ? { resolvedModelId: catalog.resolvedModelId } : {},
|
|
3311
3313
|
...catalog.currentModelId ? { currentModelId: catalog.currentModelId } : {},
|
|
3312
|
-
availableModels: catalog.availableModels
|
|
3314
|
+
availableModels: catalog.availableModels,
|
|
3315
|
+
...catalog.warnings?.length ? { warnings: catalog.warnings } : {}
|
|
3313
3316
|
});
|
|
3314
3317
|
wideAttempts.push({
|
|
3315
3318
|
index: wideAttempts.length + 1,
|
|
@@ -5012,7 +5015,7 @@ function parseOpenAiModelCatalog(route, payload) {
|
|
|
5012
5015
|
modelId: entry.id,
|
|
5013
5016
|
name: typeof entry.display_name === "string" ? entry.display_name : typeof entry.name === "string" ? entry.name : entry.id,
|
|
5014
5017
|
...typeof entry.description === "string" ? { description: entry.description } : {},
|
|
5015
|
-
...contextLength !== void 0 ? { contextLength } : {},
|
|
5018
|
+
...contextLength !== void 0 ? { contextLength, contextWindowSource: "discovered" } : {},
|
|
5016
5019
|
...pricing ? { pricing } : {},
|
|
5017
5020
|
...free ? { free } : {},
|
|
5018
5021
|
...metadata ? {
|