@wirecat/cli-core 0.627.0 → 0.628.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/CHANGELOG.md +16 -0
- package/dist/cli/ai-model-command.js +39 -17
- package/dist/documents.d.ts +1 -1
- package/dist/documents.js +1 -1
- package/dist/errors/reasons.js +5 -1
- package/dist/models/ai.d.ts +18 -2
- package/dist/models/ai.js +18 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,22 @@ Notable changes to `@wirecat/cli-core` (`@wirecat/cli-messaging` up to 0.261.0,
|
|
|
5
5
|
minor version may break callers, and says how under "Changed — may break callers". `pnpm docs:check` checks the
|
|
6
6
|
shape of this file.
|
|
7
7
|
|
|
8
|
+
## 0.628.0 — 10.11.2026
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **`aiTextReader` in `@wirecat/cli-core/documents`** sends text to the model chosen with `models ai set`, with the
|
|
13
|
+
key kept for that address. It says `ai.not-set` or `ai.key-missing` when it cannot, and whether the text leaves this
|
|
14
|
+
computer. memo's `ai-model` source reader uses it, so one key and one model serve images and text.
|
|
15
|
+
|
|
16
|
+
### Changed — may break callers
|
|
17
|
+
|
|
18
|
+
- **`models ai` uses the shared command words.** `off` is now `unset` and `forget` is now `remove`. The key is
|
|
19
|
+
read with `--secret-stdin` (was `--key-stdin`). Image consent is `--allow-remote` (was `--images`), given for that
|
|
20
|
+
call's address and model: a `set` without it takes it back, and so does the new `models ai revoke`. `--no-images`
|
|
21
|
+
is gone. memo's command lint refused the old words. 0.626.0 shipped them for one day, and only WireCat Desktop
|
|
22
|
+
calls them.
|
|
23
|
+
|
|
8
24
|
## 0.627.0 — 10.11.2026
|
|
9
25
|
|
|
10
26
|
### Added
|
|
@@ -55,6 +55,7 @@ export const aiModelCommand = (app, options) => {
|
|
|
55
55
|
output: { entity: "ai_model" },
|
|
56
56
|
examples: [`${app.command} models ai show`],
|
|
57
57
|
})
|
|
58
|
+
.summary("the chosen model, its key, and whether images may go to it")
|
|
58
59
|
.description("the chosen model, whether a key is stored for its address, and whether images may go to it")
|
|
59
60
|
.action(function () {
|
|
60
61
|
options.output(itemOf(view(app, options, readAiSetting(aiSettingPath(options.env())))), this);
|
|
@@ -64,18 +65,19 @@ export const aiModelCommand = (app, options) => {
|
|
|
64
65
|
mcp: false,
|
|
65
66
|
output: { entity: "ai_model", view: "chosen" },
|
|
66
67
|
examples: [
|
|
67
|
-
`${app.command} models ai set anthropic --model claude-haiku-4-5 --
|
|
68
|
-
`${app.command} models ai set openai --model openai/gpt-4o-mini --base-url https://openrouter.ai/api/v1 --
|
|
68
|
+
`${app.command} models ai set anthropic --model claude-haiku-4-5 --secret-stdin --allow-remote`,
|
|
69
|
+
`${app.command} models ai set openai --model openai/gpt-4o-mini --base-url https://openrouter.ai/api/v1 --secret-stdin`,
|
|
69
70
|
`${app.command} models ai set ollama --model llama3.2-vision`,
|
|
70
71
|
],
|
|
71
72
|
}))
|
|
73
|
+
.summary("choose the AI model: anthropic, openai or compatible, or ollama (beta)")
|
|
72
74
|
.description("choose the model: anthropic, openai (or any service that works like it, with --base-url) or ollama (beta)")
|
|
73
75
|
.argument("<provider>", AI_PROVIDERS.join(", "))
|
|
74
76
|
.requiredOption("--model <model>", "the model's name as the provider writes it")
|
|
75
77
|
.option("--base-url <url>", "the service's address; https, or http only on this computer")
|
|
76
|
-
.option("--
|
|
77
|
-
.option("--
|
|
78
|
-
|
|
78
|
+
.option("--secret-stdin", "read the API key from stdin, or ask for it; kept for this address only")
|
|
79
|
+
.option("--allow-remote", "let images you add to memory go to this model to be read; they leave this computer. Without it, a set " +
|
|
80
|
+
"takes back an earlier yes")
|
|
79
81
|
.option("--from-app", "you did this in WireCat Desktop")
|
|
80
82
|
.action(async function (provider, given) {
|
|
81
83
|
const env = options.env();
|
|
@@ -86,10 +88,9 @@ export const aiModelCommand = (app, options) => {
|
|
|
86
88
|
provider,
|
|
87
89
|
model: given.model,
|
|
88
90
|
baseUrl: given.baseUrl,
|
|
89
|
-
|
|
90
|
-
before,
|
|
91
|
+
allowImages: given.allowRemote,
|
|
91
92
|
});
|
|
92
|
-
if (given.
|
|
93
|
+
if (given.secretStdin) {
|
|
93
94
|
if (!aiNeedsKey(setting))
|
|
94
95
|
throw new CliError("validation_error", "Ollama on this computer takes no key");
|
|
95
96
|
const input = options.stdin?.();
|
|
@@ -101,38 +102,38 @@ export const aiModelCommand = (app, options) => {
|
|
|
101
102
|
writeAiSetting(path, setting);
|
|
102
103
|
if (setting.images)
|
|
103
104
|
options.diagnostic(imagesNote(setting));
|
|
104
|
-
const changed = JSON.stringify(before === undefined ? null : { ...before, images: before
|
|
105
|
-
JSON.stringify({ ...setting, images: setting
|
|
105
|
+
const changed = JSON.stringify(before === undefined ? null : { ...before, images: aiImagesAllowed(before) }) !==
|
|
106
|
+
JSON.stringify({ ...setting, images: aiImagesAllowed(setting) });
|
|
106
107
|
options.output(itemOf({ ...view(app, options, setting), changed }), this);
|
|
107
108
|
});
|
|
108
|
-
grantsAuthority(annotate(ai.command("
|
|
109
|
+
grantsAuthority(annotate(ai.command("unset"), {
|
|
109
110
|
effects: LOCAL_WRITE,
|
|
110
111
|
mcp: false,
|
|
111
112
|
output: { entity: "ai_model", view: "off" },
|
|
112
|
-
examples: [`${app.command} models ai
|
|
113
|
+
examples: [`${app.command} models ai unset`],
|
|
113
114
|
}))
|
|
114
|
-
.description("stop using a model; its key stays until models ai
|
|
115
|
+
.description("stop using a model; its key stays until models ai remove")
|
|
115
116
|
.option("--from-app", "you did this in WireCat Desktop")
|
|
116
117
|
.action(function () {
|
|
117
118
|
const env = options.env();
|
|
118
|
-
ownerOnly(this, env, "
|
|
119
|
+
ownerOnly(this, env, "unset");
|
|
119
120
|
const path = aiSettingPath(env);
|
|
120
121
|
const before = previous(path);
|
|
121
122
|
writeAiSetting(path, undefined);
|
|
122
123
|
options.output(itemOf({ changed: before !== undefined, key_kept: true }), this);
|
|
123
124
|
});
|
|
124
|
-
grantsAuthority(annotate(ai.command("
|
|
125
|
+
grantsAuthority(annotate(ai.command("remove"), {
|
|
125
126
|
effects: LOCAL_WRITE,
|
|
126
127
|
mcp: false,
|
|
127
128
|
output: { entity: "ai_model", view: "key-removed" },
|
|
128
|
-
examples: [`${app.command} models ai
|
|
129
|
+
examples: [`${app.command} models ai remove https://api.anthropic.com`],
|
|
129
130
|
}))
|
|
130
131
|
.description("remove the key stored for an address")
|
|
131
132
|
.argument("[origin]", "the address, for example https://openrouter.ai; the chosen model's when absent")
|
|
132
133
|
.option("--from-app", "you did this in WireCat Desktop")
|
|
133
134
|
.action(function (given) {
|
|
134
135
|
const env = options.env();
|
|
135
|
-
ownerOnly(this, env, "
|
|
136
|
+
ownerOnly(this, env, "remove");
|
|
136
137
|
const setting = given ? undefined : previous(aiSettingPath(env));
|
|
137
138
|
let origin = setting ? aiOrigin(setting) : "";
|
|
138
139
|
if (given) {
|
|
@@ -151,12 +152,33 @@ export const aiModelCommand = (app, options) => {
|
|
|
151
152
|
options.diagnostic(`a key for ${origin} is still found in ${still}; remove it there too`);
|
|
152
153
|
options.output(itemOf({ origin, removed: removed.length > 0, still_found: still }), this);
|
|
153
154
|
});
|
|
155
|
+
grantsAuthority(annotate(ai.command("revoke"), {
|
|
156
|
+
effects: LOCAL_WRITE,
|
|
157
|
+
mcp: false,
|
|
158
|
+
output: { entity: "ai_model", view: "chosen" },
|
|
159
|
+
examples: [`${app.command} models ai revoke`],
|
|
160
|
+
}))
|
|
161
|
+
.description("stop sending images to the AI model; the model itself stays chosen")
|
|
162
|
+
.option("--from-app", "you did this in WireCat Desktop")
|
|
163
|
+
.action(function () {
|
|
164
|
+
const env = options.env();
|
|
165
|
+
ownerOnly(this, env, "revoke");
|
|
166
|
+
const path = aiSettingPath(env);
|
|
167
|
+
const setting = readAiSetting(path);
|
|
168
|
+
if (!setting)
|
|
169
|
+
throw new CliError("configuration_error", "no AI model is chosen", { reason: "ai.not-set" });
|
|
170
|
+
const { images, ...kept } = setting;
|
|
171
|
+
if (images !== undefined)
|
|
172
|
+
writeAiSetting(path, kept);
|
|
173
|
+
options.output(itemOf({ ...view(app, options, kept), changed: images !== undefined }), this);
|
|
174
|
+
});
|
|
154
175
|
annotate(ai.command("check"), {
|
|
155
176
|
effects: FETCH,
|
|
156
177
|
mcp: false,
|
|
157
178
|
output: { entity: "ai_model_check" },
|
|
158
179
|
examples: [`${app.command} models ai check`],
|
|
159
180
|
})
|
|
181
|
+
.summary("send one short paid request and say what is wrong")
|
|
160
182
|
.description("send one short request (billed by the provider, usually under a cent) and say what is wrong")
|
|
161
183
|
.option("--from-app", "you did this in WireCat Desktop")
|
|
162
184
|
.action(async function () {
|
package/dist/documents.d.ts
CHANGED
|
@@ -8,6 +8,6 @@ export { columnName, sheetText } from "./attachments/sheets.js";
|
|
|
8
8
|
export * from "./documents/index.js";
|
|
9
9
|
export { isPublicAddress } from "./fetch/addresses.js";
|
|
10
10
|
export { type FetchedPage, type FetchPageOptions, fetchPage, nodeTransport, PAGE_LIMITS, PAGE_USER_AGENT, type PageLimits, type PageLookup, type PageRequest, type PageResponse, type PageTransport, type ResolvedAddress, } from "./fetch/page.js";
|
|
11
|
-
export { AI_PROVIDERS, type AiImageRefusal, type AiProvider, type AiSetting, aiImageReader, aiSettingPath, readAiSetting, } from "./models/ai.js";
|
|
11
|
+
export { AI_PROVIDERS, type AiImageRefusal, type AiProvider, type AiSetting, type AiTextReader, type AiTextRefusal, aiImageReader, aiLeavesComputer, aiSettingPath, aiTextReader, readAiSetting, } from "./models/ai.js";
|
|
12
12
|
export { registerReader } from "./readers/registry.js";
|
|
13
13
|
export type { ReadContext, Reader, Section } from "./readers/types.js";
|
package/dist/documents.js
CHANGED
|
@@ -6,5 +6,5 @@ export { columnName, sheetText } from "./attachments/sheets.js";
|
|
|
6
6
|
export * from "./documents/index.js";
|
|
7
7
|
export { isPublicAddress } from "./fetch/addresses.js";
|
|
8
8
|
export { fetchPage, nodeTransport, PAGE_LIMITS, PAGE_USER_AGENT, } from "./fetch/page.js";
|
|
9
|
-
export { AI_PROVIDERS, aiImageReader, aiSettingPath, readAiSetting, } from "./models/ai.js";
|
|
9
|
+
export { AI_PROVIDERS, aiImageReader, aiLeavesComputer, aiSettingPath, aiTextReader, readAiSetting, } from "./models/ai.js";
|
|
10
10
|
export { registerReader } from "./readers/registry.js";
|
package/dist/errors/reasons.js
CHANGED
|
@@ -63,7 +63,11 @@ const OTHERS = [
|
|
|
63
63
|
["model.offline", "permission_error", "downloading a model needs the network; --offline was requested"],
|
|
64
64
|
["model.key-rejected", "invalid_response", "the model provider refused the API key (401 or 403)"],
|
|
65
65
|
["model.unreachable", "invalid_response", "the model provider could not be reached over the network"],
|
|
66
|
-
[
|
|
66
|
+
[
|
|
67
|
+
"ai.owner-only",
|
|
68
|
+
"permission_error",
|
|
69
|
+
"only the owner chooses, unsets, checks or removes the AI model and its key, or revokes its consent",
|
|
70
|
+
],
|
|
67
71
|
["ai.setting-invalid", "configuration_error", "the ai section or the model given is not one WireCat can use"],
|
|
68
72
|
validation("ai.address-refused", "the model address must be https, or http only on this computer"),
|
|
69
73
|
["ai.not-set", "configuration_error", "no AI model is chosen; models ai set chooses one"],
|
package/dist/models/ai.d.ts
CHANGED
|
@@ -25,8 +25,7 @@ export declare const aiSettingOf: (given: {
|
|
|
25
25
|
provider: string;
|
|
26
26
|
model: string;
|
|
27
27
|
baseUrl?: string | undefined;
|
|
28
|
-
|
|
29
|
-
before?: AiSetting | undefined;
|
|
28
|
+
allowImages?: boolean | undefined;
|
|
30
29
|
}) => AiSetting;
|
|
31
30
|
export declare const aiBaseUrl: (setting: Pick<AiSetting, "provider" | "base_url">) => string;
|
|
32
31
|
export declare const aiOrigin: (setting: Pick<AiSetting, "provider" | "base_url">) => string;
|
|
@@ -65,6 +64,23 @@ export declare const aiImageReader: (deps: AiCallDeps) => {
|
|
|
65
64
|
} | {
|
|
66
65
|
refused: AiImageRefusal;
|
|
67
66
|
};
|
|
67
|
+
/** False only for a model on this computer: Ollama, or any address on loopback. */
|
|
68
|
+
export declare const aiLeavesComputer: (setting: AiSetting) => boolean;
|
|
69
|
+
export type AiTextRefusal = "ai.not-set" | "ai.key-missing";
|
|
70
|
+
export interface AiTextReader {
|
|
71
|
+
by: string;
|
|
72
|
+
leavesComputer: boolean;
|
|
73
|
+
complete(request: {
|
|
74
|
+
purpose: string;
|
|
75
|
+
system: string;
|
|
76
|
+
prompt: string;
|
|
77
|
+
maxTokens: number;
|
|
78
|
+
}): Promise<string>;
|
|
79
|
+
}
|
|
80
|
+
/** The chosen model for text a tool sends on purpose; picking this reader by name is the owner's consent, as for images. */
|
|
81
|
+
export declare const aiTextReader: (deps: AiCallDeps) => AiTextReader | {
|
|
82
|
+
refused: AiTextRefusal;
|
|
83
|
+
};
|
|
68
84
|
export type AiCheckReason = "ai.ok" | "ai.not-set" | "ai.key-missing" | "ai.key-rejected" | "ai.no-credit" | "ai.model-unknown" | "ai.rate-limited" | "ai.unreachable" | "ai.provider-error" | "ai.failed";
|
|
69
85
|
/** One tiny paid request that proves the key, the model and the credit together; the provider's own text is never kept. */
|
|
70
86
|
export declare const checkAi: (deps: AiCallDeps) => Promise<{
|
package/dist/models/ai.js
CHANGED
|
@@ -65,10 +65,7 @@ export const aiSettingOf = (given) => {
|
|
|
65
65
|
}
|
|
66
66
|
if (checked.output.provider === "ollama" && !loopback(new URL(aiBaseUrl(checked.output)).hostname))
|
|
67
67
|
throw new CliError("validation_error", "Ollama is read only on this computer", { reason: "ai.address-refused" });
|
|
68
|
-
|
|
69
|
-
if (kept && kept.origin === aiOrigin(checked.output) && kept.model === checked.output.model)
|
|
70
|
-
return { ...checked.output, images: kept };
|
|
71
|
-
return given.images
|
|
68
|
+
return given.allowImages
|
|
72
69
|
? {
|
|
73
70
|
...checked.output,
|
|
74
71
|
images: { origin: aiOrigin(checked.output), model: checked.output.model, at: new Date().toISOString() },
|
|
@@ -153,6 +150,23 @@ export const aiImageReader = (deps) => {
|
|
|
153
150
|
},
|
|
154
151
|
};
|
|
155
152
|
};
|
|
153
|
+
/** False only for a model on this computer: Ollama, or any address on loopback. */
|
|
154
|
+
export const aiLeavesComputer = (setting) => !loopback(new URL(aiBaseUrl(setting)).hostname);
|
|
155
|
+
/** The chosen model for text a tool sends on purpose; picking this reader by name is the owner's consent, as for images. */
|
|
156
|
+
export const aiTextReader = (deps) => {
|
|
157
|
+
const setting = readAiSetting(aiSettingPath(deps.env));
|
|
158
|
+
if (!setting)
|
|
159
|
+
return { refused: "ai.not-set" };
|
|
160
|
+
const key = keyFor(setting, deps);
|
|
161
|
+
if (aiNeedsKey(setting) && !key)
|
|
162
|
+
return { refused: "ai.key-missing" };
|
|
163
|
+
const gateway = gatewayFor(setting, deps, key);
|
|
164
|
+
return {
|
|
165
|
+
by: `${setting.provider}/${setting.model}`,
|
|
166
|
+
leavesComputer: aiLeavesComputer(setting),
|
|
167
|
+
complete: async (request) => (await gateway.complete(request)).text,
|
|
168
|
+
};
|
|
169
|
+
};
|
|
156
170
|
const reasonOf = (error) => {
|
|
157
171
|
if (!(error instanceof CliError))
|
|
158
172
|
return "ai.failed";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wirecat/cli-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.628.0",
|
|
4
4
|
"description": "The messenger-neutral half of a messaging CLI: domain model, message locators, rendering, name resolution, the SQLite seam, the command skeleton and shared read commands, the send guard, run records and the message store",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Viacheslav Ptsarev",
|