@carrieros/cli-staging 0.4.0 → 0.4.1
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/dist/commands/chat.js +3 -3
- package/dist/commands/logout.js +1 -0
- package/dist/commands/permissions.js +1 -0
- package/dist/commands/settings.js +61 -1
- package/dist/commands/update.js +102 -46
- package/dist/commands/usage.js +5 -3
- package/dist/ide/ide-session.js +10 -6
- package/dist/main.js +6 -0
- package/dist/services/api.js +5 -3
- package/dist/services/auto-update.js +221 -0
- package/dist/services/config.js +2 -1
- package/dist/services/context.js +53 -8
- package/dist/services/device-auth.js +3 -1
- package/dist/services/login-flow.js +3 -3
- package/dist/services/meta.js +27 -0
- package/dist/services/session-resolver.js +2 -0
- package/dist/services/update.js +420 -1
- package/dist/shell/shell-chat.js +3 -0
- package/dist/shell/shell-commands.js +1 -1
- package/dist/shell/shell.js +44 -19
- package/dist/ui/command-registry.js +2 -2
- package/package.json +1 -1
package/dist/commands/chat.js
CHANGED
|
@@ -18,7 +18,7 @@ export function registerChat(program, ctx) {
|
|
|
18
18
|
.argument("[message...]", "an optional first message to send immediately (uses attached files)")
|
|
19
19
|
.option("-m, --mode <mode>", "Carrier mode (general, code, research, …)")
|
|
20
20
|
.option("--model <model>", "provider model override (e.g. gpt-5.5); 'auto' to clear")
|
|
21
|
-
.option("--standard", "start in Standard chat
|
|
21
|
+
.option("--standard", "start in Standard chat (the default)")
|
|
22
22
|
.action(async (messageParts, opts) => {
|
|
23
23
|
// Mode follows the chat type (Carrier → General, Standard → saved or
|
|
24
24
|
// Auto); an explicit -m flag overrides it for this run.
|
|
@@ -26,8 +26,8 @@ export function registerChat(program, ctx) {
|
|
|
26
26
|
ctx.config.set("mode", opts.mode);
|
|
27
27
|
if (opts.model !== undefined)
|
|
28
28
|
ctx.config.set("model", opts.model === "auto" ? "" : opts.model);
|
|
29
|
-
//
|
|
30
|
-
//
|
|
29
|
+
// Standard is the default; --standard explicitly clears the active
|
|
30
|
+
// session so its next message starts a fresh Standard conversation.
|
|
31
31
|
if (opts.standard)
|
|
32
32
|
ctx.setChatType("standard");
|
|
33
33
|
// e.g. `cos chat "Summarize this file"` — send it right away (with any
|
package/dist/commands/logout.js
CHANGED
|
@@ -19,6 +19,7 @@ export function registerLogout(program, ctx) {
|
|
|
19
19
|
// Best-effort server revoke so the refresh token can't be reused.
|
|
20
20
|
await withSpinner("Signing out…", () => logoutCliSession(apiUrl, refreshToken));
|
|
21
21
|
}
|
|
22
|
+
ctx.noteSessionSelectionChanged();
|
|
22
23
|
ctx.config.clearAuth();
|
|
23
24
|
success("Logged out. This device's session has been removed.");
|
|
24
25
|
});
|
|
@@ -48,6 +48,7 @@ export async function runPermissions(ctx, arg) {
|
|
|
48
48
|
const COMPACT_REASONS = {
|
|
49
49
|
NOTHING_TO_COMPACT: "Nothing new to compact since the last summary.",
|
|
50
50
|
RESTRUCTURING_DISABLED: "Chat restructuring is turned off in your preferences, so a summary would not be used. Turn it on in Settings → Performance to compact.",
|
|
51
|
+
SNAPSHOTS_DISABLED: "Memory snapshots are turned off in your preferences, so a summary would not be used. Turn them on in Settings → Performance to compact.",
|
|
51
52
|
BUSY: "An automatic context restructure is running for this conversation. Try /compact again in a moment.",
|
|
52
53
|
SESSION_NOT_FOUND: "This conversation is no longer available. Run /sessions to pick another."
|
|
53
54
|
};
|
|
@@ -4,6 +4,8 @@ import { errorLine, line } from "../services/output.js";
|
|
|
4
4
|
import { c } from "../ui/colors.js";
|
|
5
5
|
import { sectionHeader } from "../ui/ui.js";
|
|
6
6
|
import { executionAdapter, executionPlatform } from "../services/execution-platform.js";
|
|
7
|
+
import { updateSettings } from "../services/auto-update.js";
|
|
8
|
+
import { isUpdateChannel, packageName, UPDATE_CHANNELS } from "../services/update.js";
|
|
7
9
|
/**
|
|
8
10
|
* `cos settings` — the CLI's persisted behaviour settings, in one place.
|
|
9
11
|
*
|
|
@@ -32,8 +34,14 @@ export function runSettings(ctx, argStr) {
|
|
|
32
34
|
const [name = "", value = ""] = argStr.trim().toLowerCase().split(/\s+/);
|
|
33
35
|
if (!name)
|
|
34
36
|
return showSettings(ctx);
|
|
37
|
+
if (name === "updates" || name === "auto-updates")
|
|
38
|
+
return setAutoUpdates(ctx, value);
|
|
39
|
+
if (name === "channel" || name === "update-channel")
|
|
40
|
+
return setChannel(ctx, value);
|
|
41
|
+
if (name === "update-interval")
|
|
42
|
+
return setUpdateInterval(ctx, value);
|
|
35
43
|
if (name !== "commands" && name !== "local-commands") {
|
|
36
|
-
errorLine(`Unknown setting "${name}". Try: /settings commands on|off`);
|
|
44
|
+
errorLine(`Unknown setting "${name}". Try: /settings commands on|off, /settings updates on|off, /settings channel latest|beta|next|staging`);
|
|
37
45
|
return;
|
|
38
46
|
}
|
|
39
47
|
if (!ON.has(value) && !OFF.has(value)) {
|
|
@@ -74,6 +82,54 @@ export const LOCAL_COMMANDS_NOTICE = [
|
|
|
74
82
|
"read, and may open other applications through Windows file associations.",
|
|
75
83
|
"Turn it off again with /settings commands off."
|
|
76
84
|
];
|
|
85
|
+
/** Automatic background updates. /update keeps working either way. */
|
|
86
|
+
function setAutoUpdates(ctx, value) {
|
|
87
|
+
if (!ON.has(value) && !OFF.has(value)) {
|
|
88
|
+
errorLine("Use /settings updates on or /settings updates off.");
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const enable = ON.has(value);
|
|
92
|
+
ctx.config.set("autoUpdates", enable);
|
|
93
|
+
line();
|
|
94
|
+
line(" " + c.ok("✓") + " " + c.value(enable ? "Automatic updates enabled." : "Automatic updates disabled.") +
|
|
95
|
+
" " + c.dim(enable ? "New releases install in the background when you exit." : "Run /update to check and install manually."));
|
|
96
|
+
line();
|
|
97
|
+
}
|
|
98
|
+
/** Which npm dist-tag to follow. Only ever changed here, by the user. */
|
|
99
|
+
function setChannel(ctx, value) {
|
|
100
|
+
if (!isUpdateChannel(value)) {
|
|
101
|
+
errorLine(`Use /settings channel ${UPDATE_CHANNELS.join("|")}.`);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
if (packageName() === "@carrieros/cli-staging" && value !== "staging") {
|
|
105
|
+
errorLine("The staging CLI always follows its isolated staging update channel.");
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
if (value === "staging" && packageName() !== "@carrieros/cli-staging") {
|
|
109
|
+
errorLine("The staging update channel is available only in the staging CLI package.");
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
ctx.config.set("updateChannel", value);
|
|
113
|
+
// The cached result belongs to the previous channel.
|
|
114
|
+
ctx.config.set("latestCliVersion", undefined);
|
|
115
|
+
ctx.config.set("updateCheckAt", undefined);
|
|
116
|
+
ctx.config.set("updateNoticeShown", undefined);
|
|
117
|
+
line();
|
|
118
|
+
line(" " + c.ok("✓") + " " + c.value(`Update channel set to ${value}.`) + " " +
|
|
119
|
+
c.dim(value === "latest" ? "Stable releases only." : "Pre-releases on this channel will be offered. /update checks now."));
|
|
120
|
+
line();
|
|
121
|
+
}
|
|
122
|
+
function setUpdateInterval(ctx, value) {
|
|
123
|
+
const hours = Number(value);
|
|
124
|
+
if (!Number.isInteger(hours) || hours < 1 || hours > 168) {
|
|
125
|
+
errorLine("Use /settings update-interval <hours>, between 1 and 168.");
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
ctx.config.set("updateCheckIntervalHours", hours);
|
|
129
|
+
line();
|
|
130
|
+
line(" " + c.ok("✓") + " " + c.value(`Checking for updates every ${hours} hour${hours === 1 ? "" : "s"}.`) + " " + c.dim("Applies from the next start."));
|
|
131
|
+
line();
|
|
132
|
+
}
|
|
77
133
|
function showSettings(ctx) {
|
|
78
134
|
const state = localCommandsState(ctx, undefined, getPermissionMode(ctx.config) === "auto");
|
|
79
135
|
const row = (label, value, note = "") => line(" " + c.label(label.padEnd(16)) + value + (note ? " " + c.dim(note) : ""));
|
|
@@ -96,5 +152,9 @@ function showSettings(ctx) {
|
|
|
96
152
|
row("Clarification", c.value(ctx.siaMode), "/sia");
|
|
97
153
|
const web = ctx.webSearch;
|
|
98
154
|
row("Web search", web === undefined ? c.dim("workspace default") : web ? c.ok("on") : c.dim("off"), "/websearch");
|
|
155
|
+
const updates = updateSettings(ctx.config);
|
|
156
|
+
row("Auto updates", updates.autoUpdates ? c.ok("on") : c.dim("off"), "/settings updates on|off");
|
|
157
|
+
row("Update channel", c.value(updates.channel), "/settings channel latest|beta|next|staging");
|
|
158
|
+
row("Update checks", c.value(`every ${updates.intervalHours}h`), "/settings update-interval <hours>");
|
|
99
159
|
line();
|
|
100
160
|
}
|
package/dist/commands/update.js
CHANGED
|
@@ -2,7 +2,8 @@ import { line } from "../services/output.js";
|
|
|
2
2
|
import { withSpinner } from "../services/spinner.js";
|
|
3
3
|
import { isPackaged, isSignedRelease, PACKAGED_DOWNLOAD_URL } from "../services/packaged.js";
|
|
4
4
|
import { checkInstallerSignature, checkPackagedUpdate, downloadVerified, launchInstaller, updatesDir, UpdateError } from "../services/packaged-update.js";
|
|
5
|
-
import {
|
|
5
|
+
import { acquireUpdateLock, checkChannel, defaultUpdateChannel, detectInstallation, installExactVersion, manualUpdateCommand, PACKAGE_NAME, packageName, releaseUpdateLock, updateInProgress } from "../services/update.js";
|
|
6
|
+
import { updateSettings } from "../services/auto-update.js";
|
|
6
7
|
import { c } from "../ui/colors.js";
|
|
7
8
|
import { pickFromList } from "../ui/select.js";
|
|
8
9
|
/**
|
|
@@ -28,7 +29,7 @@ function versions(current, latest) {
|
|
|
28
29
|
line(" " + c.dim("Latest version: ") + c.value(latest));
|
|
29
30
|
line();
|
|
30
31
|
}
|
|
31
|
-
function renderTerminalState(state) {
|
|
32
|
+
function renderTerminalState(state, manual = MANUAL) {
|
|
32
33
|
if (state.kind === "current") {
|
|
33
34
|
line();
|
|
34
35
|
line(" " + c.ok("✓") + " " + c.value("Carrier OS CLI is already up to date (v" + state.current + ")"));
|
|
@@ -49,7 +50,7 @@ function renderTerminalState(state) {
|
|
|
49
50
|
line();
|
|
50
51
|
line(" " + c.dim("npm was not found on this system."));
|
|
51
52
|
line(" " + c.dim("Update manually with:"));
|
|
52
|
-
line(" " + c.cmd(
|
|
53
|
+
line(" " + c.cmd(manual));
|
|
53
54
|
line();
|
|
54
55
|
return;
|
|
55
56
|
}
|
|
@@ -62,50 +63,95 @@ function renderTerminalState(state) {
|
|
|
62
63
|
line();
|
|
63
64
|
}
|
|
64
65
|
/**
|
|
65
|
-
* `/update` and `cos update` — the
|
|
66
|
+
* `/update` and `cos update` — check the configured channel and, if a newer
|
|
67
|
+
* release exists, offer to install it.
|
|
66
68
|
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
* Nothing is installed without an explicit Yes, and the process is never
|
|
73
|
-
* restarted: npm swaps files under a running Node, and re-execing through the
|
|
74
|
-
* shim while the old process still holds handles is how partial installs occur.
|
|
69
|
+
* Nothing is installed without an explicit Yes (or --yes), never during a
|
|
70
|
+
* running agent turn, and never over a local, development, npx or unwritable
|
|
71
|
+
* install — those get the right manual command instead. The process is never
|
|
72
|
+
* restarted: the user is told to restart once the new version is verified on
|
|
73
|
+
* disk. Settings (channel) come from the CLI's own config.
|
|
75
74
|
*/
|
|
76
75
|
export async function runUpdate(opts = {}) {
|
|
77
|
-
// The packaged executable has no npm to update through.
|
|
78
|
-
// rather than running an npm command that cannot exist in that environment.
|
|
76
|
+
// The packaged executable has no npm to update through.
|
|
79
77
|
if (isPackaged()) {
|
|
80
78
|
await runPackagedUpdate(opts.assumeYes === true);
|
|
81
79
|
return;
|
|
82
80
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
81
|
+
// Never alongside a running agent task: it may be using files npm would replace.
|
|
82
|
+
if (opts.busy) {
|
|
83
|
+
line();
|
|
84
|
+
line(" " + c.warn("⚠") + " " + c.value("An agent task is running. Run /update again when it has finished."));
|
|
85
|
+
line();
|
|
88
86
|
return;
|
|
89
87
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
line(" " + c.
|
|
88
|
+
const channel = opts.config ? updateSettings(opts.config).channel : defaultUpdateChannel();
|
|
89
|
+
const manual = manualUpdateCommand(channel);
|
|
90
|
+
const state = await withSpinner(c.dim("Checking for updates…"), () => checkChannel(channel));
|
|
91
|
+
if (state.kind === "current") {
|
|
92
|
+
line();
|
|
93
|
+
line(" " + c.ok("✓") + " " + c.value("You are using the latest version of CarrierOS CLI.") + c.dim(" (v" + state.current + (channel === "latest" ? "" : ", " + channel + " channel") + ")"));
|
|
96
94
|
line();
|
|
97
|
-
|
|
98
|
-
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
if (state.kind === "no-channel") {
|
|
98
|
+
heading();
|
|
99
|
+
line(" " + c.dim("Current version: ") + c.value(state.current));
|
|
100
|
+
line(" " + c.warn("⚠") + " " + c.value(state.detail));
|
|
101
|
+
line(" " + c.dim("Switch back with: ") + c.cmd("/settings channel latest"));
|
|
99
102
|
line();
|
|
100
103
|
return;
|
|
101
104
|
}
|
|
105
|
+
if (state.kind !== "available") {
|
|
106
|
+
renderTerminalState(state, manual);
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
102
109
|
heading();
|
|
103
110
|
versions(state.current, state.latest);
|
|
104
|
-
|
|
111
|
+
const install = opts.installation ?? (await detectInstallation());
|
|
112
|
+
if (install.kind === "development") {
|
|
113
|
+
line(" " + c.warn("⚠") + " " + c.value("Running from a development checkout (or npm link)."));
|
|
114
|
+
line(" " + c.dim("Automatic update is disabled here — it would replace the link to your checkout."));
|
|
115
|
+
line(" " + c.dim("Install the published CLI with: ") + c.cmd(manual));
|
|
116
|
+
line();
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
if (install.kind === "local") {
|
|
120
|
+
line(" " + c.value("This copy is installed as a project dependency."));
|
|
121
|
+
line(" " + c.dim("Update it with your package manager, e.g. ") + c.cmd("npm install " + packageName() + "@" + state.latest));
|
|
122
|
+
line();
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
if (install.kind === "npx") {
|
|
126
|
+
line(" " + c.dim("Running through npx. Use the new version with: ") + c.cmd("npx " + packageName() + "@" + channel));
|
|
127
|
+
line();
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
if (install.kind !== "global") {
|
|
131
|
+
line(" " + c.dim("This installation cannot be updated automatically. Update with:"));
|
|
132
|
+
line(" " + c.cmd(manual));
|
|
133
|
+
line();
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
if (!install.writable) {
|
|
137
|
+
line(" " + c.warn("⚠") + " " + c.value("Your global npm folder is not writable by this user."));
|
|
138
|
+
line(" " + c.dim("Carrier OS will not request administrator rights. Update with:"));
|
|
139
|
+
line(" " + c.cmd(manual));
|
|
140
|
+
line();
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
const dir = opts.config && "dir" in opts.config ? opts.config.dir : null;
|
|
144
|
+
if (dir && updateInProgress(dir)) {
|
|
145
|
+
line(" " + c.value("An update is already being installed in the background."));
|
|
146
|
+
line(" " + c.dim("Restart Carrier OS CLI in a moment to use it."));
|
|
147
|
+
line();
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
line(" " + c.value("CarrierOS CLI " + state.latest + " is available."));
|
|
105
151
|
line();
|
|
106
152
|
const answer = opts.assumeYes ? "yes" : await pickFromList({
|
|
107
153
|
title: "Update now?",
|
|
108
|
-
description: "Runs " +
|
|
154
|
+
description: "Runs npm install -g " + packageName() + "@" + state.latest,
|
|
109
155
|
choices: [
|
|
110
156
|
{ value: "yes", label: "Yes", description: "Install v" + state.latest + " now" },
|
|
111
157
|
{ value: "no", label: "No", description: "Stay on v" + state.current }
|
|
@@ -119,16 +165,25 @@ export async function runUpdate(opts = {}) {
|
|
|
119
165
|
line();
|
|
120
166
|
return;
|
|
121
167
|
}
|
|
122
|
-
|
|
123
|
-
|
|
168
|
+
if (dir && !acquireUpdateLock(dir)) {
|
|
169
|
+
line(" " + c.value("An update is already being installed. Try again in a moment."));
|
|
124
170
|
line();
|
|
125
|
-
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
let result;
|
|
174
|
+
try {
|
|
175
|
+
result = await withSpinner(c.dim("Installing CarrierOS CLI " + state.latest + "…"), () => installExactVersion(state.latest, install.globalRoot ?? null));
|
|
176
|
+
}
|
|
177
|
+
finally {
|
|
178
|
+
if (dir)
|
|
179
|
+
releaseUpdateLock(dir);
|
|
180
|
+
}
|
|
181
|
+
if (!result.ok) {
|
|
126
182
|
line();
|
|
127
|
-
line(" " + c.
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
line(" " + c.dim("
|
|
131
|
-
}
|
|
183
|
+
line(" " + c.err("✗") + " " + c.value("CarrierOS CLI could not be updated."));
|
|
184
|
+
line(" " + c.dim("You are still on v") + c.value(state.current) + c.dim(". Update manually with: ") + c.cmd(manual));
|
|
185
|
+
if (result.permission)
|
|
186
|
+
line(" " + c.dim("npm reported a permissions problem with the global npm folder."));
|
|
132
187
|
if (result.detail) {
|
|
133
188
|
line();
|
|
134
189
|
for (const l of result.detail.split("\n").slice(0, 6))
|
|
@@ -137,14 +192,15 @@ export async function runUpdate(opts = {}) {
|
|
|
137
192
|
line();
|
|
138
193
|
return;
|
|
139
194
|
}
|
|
140
|
-
//
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
line(" " + c.dim(state.current) + c.dim(" → ") + c.value(installed));
|
|
195
|
+
// Verified on disk (installExactVersion reads the installed package.json).
|
|
196
|
+
if (opts.config) {
|
|
197
|
+
opts.config.set("pendingUpdate", undefined);
|
|
198
|
+
opts.config.set("updateFailedVersion", undefined);
|
|
199
|
+
}
|
|
146
200
|
line();
|
|
147
|
-
line(" " + c.
|
|
201
|
+
line(" " + c.ok("✓") + " " + c.value("CarrierOS CLI " + result.installed + " has been installed successfully."));
|
|
202
|
+
line(" " + c.dim(state.current) + c.dim(" → ") + c.value(String(result.installed)));
|
|
203
|
+
line(" " + c.dim("Restart the CLI to use the new version."));
|
|
148
204
|
line();
|
|
149
205
|
}
|
|
150
206
|
/**
|
|
@@ -218,12 +274,12 @@ async function runPackagedUpdate(assumeYes) {
|
|
|
218
274
|
line();
|
|
219
275
|
}
|
|
220
276
|
}
|
|
221
|
-
export function registerUpdate(program,
|
|
277
|
+
export function registerUpdate(program, ctx) {
|
|
222
278
|
program
|
|
223
279
|
.command("update")
|
|
224
280
|
.description("Check for and install the latest Carrier OS CLI version")
|
|
225
281
|
.option("-y, --yes", "install an available update without asking (for scripts)")
|
|
226
282
|
.action(async (opts) => {
|
|
227
|
-
await runUpdate({ assumeYes: opts.yes === true });
|
|
283
|
+
await runUpdate({ assumeYes: opts.yes === true, config: ctx.config });
|
|
228
284
|
});
|
|
229
285
|
}
|
package/dist/commands/usage.js
CHANGED
|
@@ -125,16 +125,18 @@ export function renderCredits(credits) {
|
|
|
125
125
|
const pools = credits.models ?? [];
|
|
126
126
|
if (pools.length === 0 || unlimited)
|
|
127
127
|
return;
|
|
128
|
+
// The name the web model picker shows; the id only when the server sends none.
|
|
129
|
+
const label = (p) => p.display_name || p.model;
|
|
128
130
|
const spent = (p) => p.status === "exceeded" || p.remaining <= 0;
|
|
129
131
|
const available = pools.filter((p) => !spent(p)).sort((a, b) => b.remaining - a.remaining);
|
|
130
|
-
const exhausted = pools.filter(spent).sort((a, b) => a.
|
|
132
|
+
const exhausted = pools.filter(spent).sort((a, b) => label(a).localeCompare(label(b)));
|
|
131
133
|
line();
|
|
132
134
|
line(sectionHeader(`Model credits (${available.length} of ${pools.length} available)`));
|
|
133
135
|
line();
|
|
134
136
|
// What you CAN use, with its balance, in as many columns as the terminal
|
|
135
137
|
// fits — this is the actionable half, so it keeps its numbers.
|
|
136
138
|
if (available.length > 0) {
|
|
137
|
-
for (const l of grid(available.map((p) => [p
|
|
139
|
+
for (const l of grid(available.map((p) => [label(p), dec(p.remaining)]))) {
|
|
138
140
|
line(l);
|
|
139
141
|
}
|
|
140
142
|
}
|
|
@@ -146,7 +148,7 @@ export function renderCredits(credits) {
|
|
|
146
148
|
if (exhausted.length > 0) {
|
|
147
149
|
line();
|
|
148
150
|
line(" " + c.err("✕") + c.dim(` ${exhausted.length} exhausted`));
|
|
149
|
-
for (const l of wrap(exhausted.map(
|
|
151
|
+
for (const l of wrap(exhausted.map(label).join(", "), Math.max(20, panelWidth() - 6))) {
|
|
150
152
|
line(" " + c.dim(l));
|
|
151
153
|
}
|
|
152
154
|
}
|
package/dist/ide/ide-session.js
CHANGED
|
@@ -196,7 +196,10 @@ export async function runIdeTurn(ctx, client, message, ports, externalSignal) {
|
|
|
196
196
|
// whether it is still the same repository and the same bytes. Context only.
|
|
197
197
|
const taskFiles = workflow ? new TaskFileLedger() : undefined;
|
|
198
198
|
const ownerScope = workflow ? client.mutationRecoveryScope() : undefined;
|
|
199
|
-
const
|
|
199
|
+
const hasSessionOverride = Object.prototype.hasOwnProperty.call(ports, "sessionId");
|
|
200
|
+
const sessionId = hasSessionOverride ? ports.sessionId : ctx.config.get("sessionId");
|
|
201
|
+
const chatType = ports.chatType ?? ctx.chatType;
|
|
202
|
+
let resultSessionId = sessionId;
|
|
200
203
|
const compose = ports.composeMessage ?? ((m) => m);
|
|
201
204
|
// What the model has said so far. It narrates as it works; commit each span at
|
|
202
205
|
// a tool boundary so a progress line lands above the activity it describes.
|
|
@@ -232,7 +235,7 @@ export async function runIdeTurn(ctx, client, message, ports, externalSignal) {
|
|
|
232
235
|
model: ctx.config.get("model") || undefined,
|
|
233
236
|
message: compose(message),
|
|
234
237
|
session_id: sessionId,
|
|
235
|
-
chat_type:
|
|
238
|
+
chat_type: chatType,
|
|
236
239
|
file_ids: ports.fileIds?.length ? ports.fileIds : undefined,
|
|
237
240
|
...(ports.webSearch === true ? { web_search: true } : {}),
|
|
238
241
|
// Fast Mode and High Power, shared with the CLI's /fast and /hipwr.
|
|
@@ -287,11 +290,12 @@ export async function runIdeTurn(ctx, client, message, ports, externalSignal) {
|
|
|
287
290
|
workflow.interrupt();
|
|
288
291
|
emitOutcome(workflow, outcome, mutations, emit);
|
|
289
292
|
}
|
|
290
|
-
|
|
293
|
+
resultSessionId = result.session_id ?? sessionId;
|
|
294
|
+
if (!hasSessionOverride && result.session_id && result.session_id !== sessionId) {
|
|
291
295
|
ctx.config.set("sessionId", result.session_id);
|
|
292
296
|
rememberPermissionMode(ctx.config);
|
|
293
297
|
}
|
|
294
|
-
return { response: result.response, sessionId:
|
|
298
|
+
return { response: result.response, sessionId: resultSessionId, applied: mutations?.applied ?? [] };
|
|
295
299
|
}
|
|
296
300
|
catch (err) {
|
|
297
301
|
if (workflow) {
|
|
@@ -301,7 +305,7 @@ export async function runIdeTurn(ctx, client, message, ports, externalSignal) {
|
|
|
301
305
|
const e = err;
|
|
302
306
|
return {
|
|
303
307
|
response: streamed,
|
|
304
|
-
sessionId,
|
|
308
|
+
sessionId: resultSessionId,
|
|
305
309
|
applied: mutations?.applied ?? [],
|
|
306
310
|
error: { code: e.code ?? "TURN_FAILED", message: e.message ?? "The turn failed.", ...(e.reason ? { reason: e.reason } : {}) }
|
|
307
311
|
};
|
|
@@ -312,7 +316,7 @@ export async function runIdeTurn(ctx, client, message, ports, externalSignal) {
|
|
|
312
316
|
// Hash what this turn read or changed, as it is on disk now, for the next
|
|
313
317
|
// turn's freshness report — also after a failed or cancelled turn.
|
|
314
318
|
taskFiles?.touchApplied(mutations?.applied ?? []);
|
|
315
|
-
taskFiles?.commit(ownerScope,
|
|
319
|
+
taskFiles?.commit(ownerScope, resultSessionId);
|
|
316
320
|
// However the turn ended, nothing it left open — a change review or a
|
|
317
321
|
// command dialog — may still be approved and apply or run afterwards.
|
|
318
322
|
controller.abort();
|
package/dist/main.js
CHANGED
|
@@ -31,6 +31,9 @@ import { registerVersion } from "./commands/version.js";
|
|
|
31
31
|
import { registerWhoami } from "./commands/whoami.js";
|
|
32
32
|
import { ApiError } from "./services/api.js";
|
|
33
33
|
import { ConfigStore } from "./services/config.js";
|
|
34
|
+
import { setClientIdentity, setClientReleaseChannel } from "./services/meta.js";
|
|
35
|
+
import { isPackaged } from "./services/packaged.js";
|
|
36
|
+
import { updateSettings } from "./services/auto-update.js";
|
|
34
37
|
import { AuthRequiredError, CommandContext } from "./services/context.js";
|
|
35
38
|
import { cliVersion } from "./services/meta.js";
|
|
36
39
|
import { errorLine } from "./services/output.js";
|
|
@@ -45,6 +48,9 @@ async function main() {
|
|
|
45
48
|
attachConfig(ctx.config);
|
|
46
49
|
// Restore the saved accent color before anything renders.
|
|
47
50
|
loadAccent(ctx.config.get("theme")?.accent);
|
|
51
|
+
// Identify this client on every API request (version + release channel).
|
|
52
|
+
setClientIdentity(isPackaged() ? "cli-exe" : "cli");
|
|
53
|
+
setClientReleaseChannel(updateSettings(ctx.config).channel);
|
|
48
54
|
const program = new Command();
|
|
49
55
|
program
|
|
50
56
|
.name("cos")
|
package/dist/services/api.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
|
+
import { clientHeaders } from "./meta.js";
|
|
2
3
|
import path from "node:path";
|
|
3
4
|
import axios, { isAxiosError } from "axios";
|
|
4
5
|
import FormData from "form-data";
|
|
@@ -82,6 +83,7 @@ export class ApiClient {
|
|
|
82
83
|
const withAuth = {
|
|
83
84
|
...config,
|
|
84
85
|
headers: {
|
|
86
|
+
...clientHeaders(),
|
|
85
87
|
...(config.headers ?? {}),
|
|
86
88
|
...(token ? { Authorization: `Bearer ${token}` } : {})
|
|
87
89
|
}
|
|
@@ -182,7 +184,7 @@ export class ApiClient {
|
|
|
182
184
|
// No client-side timeout: a turn legitimately idles while a local tool
|
|
183
185
|
// runs, and the server's keep-alive pings hold the socket open.
|
|
184
186
|
timeout: 0,
|
|
185
|
-
headers: { Authorization: `Bearer ${token}`, Accept: "text/event-stream" },
|
|
187
|
+
headers: { ...clientHeaders(), Authorization: `Bearer ${token}`, Accept: "text/event-stream" },
|
|
186
188
|
validateStatus: () => true
|
|
187
189
|
});
|
|
188
190
|
}
|
|
@@ -363,8 +365,8 @@ export class ApiClient {
|
|
|
363
365
|
sessionMessages(id) {
|
|
364
366
|
return this.request({ method: "GET", url: `/sessions/${id}/messages` });
|
|
365
367
|
}
|
|
366
|
-
createSession(title) {
|
|
367
|
-
return this.request({ method: "POST", url: "/sessions", data: { title } });
|
|
368
|
+
createSession(title, chatType) {
|
|
369
|
+
return this.request({ method: "POST", url: "/sessions", data: { title, ...(chatType ? { chat_type: chatType } : {}) } });
|
|
368
370
|
}
|
|
369
371
|
/**
|
|
370
372
|
* /compact: replace the conversation's earlier messages in the model's
|