@clagentic/console 1.12.0-beta.3 → 1.13.0-beta.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/README.md +7 -1
- package/bin/cli.js +18 -15
- package/lib/agent-roster-ws.js +38 -13
- package/lib/agent-roster.js +111 -12
- package/lib/agents.js +68 -33
- package/lib/atomic-install.js +334 -0
- package/lib/build-changes.js +33 -4
- package/lib/build-sha.json +2 -2
- package/lib/build-update-offer.js +12 -0
- package/lib/chat-width.js +31 -0
- package/lib/cli/agent-usage.js +126 -0
- package/lib/cli/arg-validation.js +1 -1
- package/lib/cli/compact-output.js +69 -0
- package/lib/cli/ipc-subcommands.js +92 -67
- package/lib/cli/output.js +28 -0
- package/lib/cli/restart-verb.js +132 -0
- package/lib/cli/schedule-input-subcommands.js +45 -8
- package/lib/cli/session-subcommands.js +37 -11
- package/lib/cli/settings-subcommands.js +74 -0
- package/lib/cli-transcript-title.js +56 -3
- package/lib/client-files.js +79 -0
- package/lib/daemon.js +100 -28
- package/lib/default-avatar-color.js +4 -0
- package/lib/drain.js +58 -10
- package/lib/mcp-tool-input.js +2 -2
- package/lib/model-families.js +49 -1
- package/lib/notify/type-registry.js +4 -0
- package/lib/notify/types.js +7 -4
- package/lib/pages.js +13 -63
- package/lib/permission-summary.js +12 -16
- package/lib/plan-usage-reader.js +70 -0
- package/lib/project-connection.js +4 -2
- package/lib/project-filesystem.js +6 -7
- package/lib/project-notifications.js +55 -8
- package/lib/project-prompt-expiry-settings.js +42 -0
- package/lib/project-sessions.js +52 -0
- package/lib/project-settings-gate.js +98 -0
- package/lib/project-user-mention.js +3 -2
- package/lib/project.js +1 -1
- package/lib/prompt-expiry-settings.js +49 -0
- package/lib/prompt-expiry.js +24 -3
- package/lib/prompt-kinds/codecs.js +6 -2
- package/lib/public/app.js +36 -36
- package/lib/public/css/admin.css +156 -170
- package/lib/public/css/agent-messages.css +24 -24
- package/lib/public/css/agent-picker.css +90 -38
- package/lib/public/css/agent-roster.css +61 -27
- package/lib/public/css/at-agents.css +10 -10
- package/lib/public/css/base.css +207 -184
- package/lib/public/css/chat-layout.css +228 -0
- package/lib/public/css/command-palette.css +86 -88
- package/lib/public/css/diagnostics.css +78 -204
- package/lib/public/css/diff.css +10 -10
- package/lib/public/css/filebrowser.css +32 -60
- package/lib/public/css/home-hub.css +100 -100
- package/lib/public/css/icon-strip.css +195 -238
- package/lib/public/css/input.css +191 -212
- package/lib/public/css/login-panel.css +16 -16
- package/lib/public/css/loop.css +96 -187
- package/lib/public/css/mention.css +49 -110
- package/lib/public/css/menus.css +162 -169
- package/lib/public/css/messages.css +49 -123
- package/lib/public/css/mobile-nav.css +207 -264
- package/lib/public/css/notifications-center.css +45 -124
- package/lib/public/css/overlay.css +269 -0
- package/lib/public/css/overlays.css +134 -156
- package/lib/public/css/playbook.css +41 -41
- package/lib/public/css/profile.css +43 -112
- package/lib/public/css/rewind.css +112 -112
- package/lib/public/css/scheduler-modal.css +27 -135
- package/lib/public/css/scheduler.css +204 -210
- package/lib/public/css/server-settings.css +173 -239
- package/lib/public/css/session-search.css +20 -20
- package/lib/public/css/settings-nav.css +197 -0
- package/lib/public/css/sidebar.css +213 -304
- package/lib/public/css/skills.css +121 -135
- package/lib/public/css/sticky-notes.css +114 -200
- package/lib/public/css/stt.css +17 -26
- package/lib/public/css/team-panel.css +36 -36
- package/lib/public/css/team-view.css +9 -9
- package/lib/public/css/title-bar.css +83 -100
- package/lib/public/css/tooltip.css +10 -10
- package/lib/public/css/user-settings.css +78 -131
- package/lib/public/css/user-shell.css +125 -29
- package/lib/public/index.html +178 -177
- package/lib/public/manifest.json +0 -2
- package/lib/public/modules/admin.js +54 -92
- package/lib/public/modules/agent-avatar.js +134 -3
- package/lib/public/modules/agent-messages.js +2 -1
- package/lib/public/modules/agent-picker.js +23 -21
- package/lib/public/modules/agent-roster-groups.js +128 -0
- package/lib/public/modules/agent-roster.js +40 -11
- package/lib/public/modules/app-connection.js +13 -1
- package/lib/public/modules/app-cursors.js +9 -9
- package/lib/public/modules/app-favicon.js +8 -16
- package/lib/public/modules/app-header.js +28 -19
- package/lib/public/modules/app-history-replay.js +67 -4
- package/lib/public/modules/app-home-hub.js +15 -0
- package/lib/public/modules/app-loop-ui.js +41 -47
- package/lib/public/modules/app-loop-wizard.js +9 -10
- package/lib/public/modules/app-messages.js +32 -36
- package/lib/public/modules/app-misc.js +22 -92
- package/lib/public/modules/app-modals.js +98 -0
- package/lib/public/modules/app-notifications.js +124 -135
- package/lib/public/modules/app-panels.js +28 -32
- package/lib/public/modules/app-projects.js +30 -40
- package/lib/public/modules/app-rate-limit.js +26 -9
- package/lib/public/modules/app-rendering.js +128 -110
- package/lib/public/modules/app-skills-install.js +6 -4
- package/lib/public/modules/assistant-identity.js +55 -0
- package/lib/public/modules/at-agents.js +3 -0
- package/lib/public/modules/build-guard.js +25 -11
- package/lib/public/modules/chat-width-choice.js +75 -0
- package/lib/public/modules/chat-width-prefs.js +52 -0
- package/lib/public/modules/chat-width.js +102 -0
- package/lib/public/modules/collapsible-text.js +36 -4
- package/lib/public/modules/command-palette.js +28 -34
- package/lib/public/modules/context-sources.js +3 -5
- package/lib/public/modules/diagnostics.js +130 -129
- package/lib/public/modules/info-panel.js +31 -0
- package/lib/public/modules/injected-identity.js +8 -8
- package/lib/public/modules/input-list-menu.js +39 -0
- package/lib/public/modules/input.js +22 -21
- package/lib/public/modules/markdown.js +10 -11
- package/lib/public/modules/mcp-ui.js +4 -14
- package/lib/public/modules/mention.js +100 -229
- package/lib/public/modules/message-header.js +80 -0
- package/lib/public/modules/message-participants.js +39 -0
- package/lib/public/modules/mobile-action-sheet.js +46 -0
- package/lib/public/modules/mobile-nav-sheet.js +104 -0
- package/lib/public/modules/model-families.js +41 -4
- package/lib/public/modules/note-order.js +39 -0
- package/lib/public/modules/notifications.js +35 -52
- package/lib/public/modules/overlay-history.js +73 -19
- package/lib/public/modules/overlay-menu.js +123 -0
- package/lib/public/modules/overlay-modal.js +186 -0
- package/lib/public/modules/overlay-registry.js +392 -0
- package/lib/public/modules/overlay-stack.js +110 -0
- package/lib/public/modules/overlay.js +117 -0
- package/lib/public/modules/popover-position.js +18 -2
- package/lib/public/modules/preference-sync.js +28 -0
- package/lib/public/modules/profile.js +24 -49
- package/lib/public/modules/project-settings.js +27 -172
- package/lib/public/modules/prompt-expiry-controls.js +46 -0
- package/lib/public/modules/prompt-kinds/command-summary.js +149 -0
- package/lib/public/modules/prompt-kinds/permission.js +70 -92
- package/lib/public/modules/prompts.js +1 -2
- package/lib/public/modules/qrcode.js +6 -21
- package/lib/public/modules/queued-button.js +15 -2
- package/lib/public/modules/rewind.js +9 -3
- package/lib/public/modules/schedule-time.js +32 -7
- package/lib/public/modules/scheduled-outbox.js +51 -18
- package/lib/public/modules/scheduler-config.js +87 -127
- package/lib/public/modules/scheduler.js +29 -26
- package/lib/public/modules/serialized-save.js +79 -0
- package/lib/public/modules/server-settings.js +75 -65
- package/lib/public/modules/session-grants.js +16 -19
- package/lib/public/modules/session-list-avatars.js +98 -0
- package/lib/public/modules/session-vendor-state.js +86 -0
- package/lib/public/modules/settings-access.js +35 -0
- package/lib/public/modules/settings-hub.js +125 -0
- package/lib/public/modules/settings-nav.js +182 -0
- package/lib/public/modules/shell-line.js +24 -0
- package/lib/public/modules/sidebar-mobile.js +151 -195
- package/lib/public/modules/sidebar-projects.js +88 -129
- package/lib/public/modules/sidebar-sessions.js +66 -34
- package/lib/public/modules/sidebar.js +2 -2
- package/lib/public/modules/skills.js +11 -26
- package/lib/public/modules/sticky-notes.js +19 -16
- package/lib/public/modules/stt.js +9 -23
- package/lib/public/modules/terminal.js +86 -90
- package/lib/public/modules/theme-choice.js +126 -0
- package/lib/public/modules/theme-colors.js +19 -0
- package/lib/public/modules/theme-prefs.js +121 -0
- package/lib/public/modules/theme.js +227 -605
- package/lib/public/modules/tool-palette.js +7 -17
- package/lib/public/modules/tools.js +8 -10
- package/lib/public/modules/user-settings.js +59 -115
- package/lib/public/modules/user-shell.js +9 -2
- package/lib/public/modules/utils.js +10 -12
- package/lib/public/modules/vendor-picker.js +4 -2
- package/lib/public/modules/vendor-registry.js +1 -2
- package/lib/public/style.css +3 -1
- package/lib/public/sw.js +9 -2
- package/lib/public/theme-core.js +411 -0
- package/lib/request-body.js +70 -0
- package/lib/sdk-bridge.js +227 -88
- package/lib/sdk-message-processor.js +44 -16
- package/lib/server-admin.js +198 -200
- package/lib/server-auth.js +16 -13
- package/lib/server-dm.js +4 -3
- package/lib/server-settings.js +177 -130
- package/lib/server.js +87 -36
- package/lib/session-background-tasks.js +79 -0
- package/lib/session-directory.js +138 -13
- package/lib/session-input-ipc.js +2 -0
- package/lib/session-input.js +39 -5
- package/lib/session-list-avatars.js +16 -0
- package/lib/session-reclaim.js +37 -25
- package/lib/session-vendor.js +37 -0
- package/lib/sessions.js +99 -34
- package/lib/settings-ipc.js +60 -0
- package/lib/settings-registry.js +86 -0
- package/lib/terminal-manager.js +17 -5
- package/lib/theme-files.js +132 -0
- package/lib/theme-seed.js +136 -0
- package/lib/themes/clagentic-dark.json +13 -6
- package/lib/themes/clagentic-light.json +12 -5
- package/lib/updater.js +6 -4
- package/lib/usage-store.js +97 -10
- package/lib/users-preferences.js +118 -19
- package/lib/users.js +19 -10
- package/lib/vendor-catalog.js +130 -0
- package/lib/ws-schema.js +4 -2
- package/lib/yoke/adapters/claude.js +81 -1
- package/lib/yoke/adapters/codex-user-shell.js +87 -23
- package/lib/yoke/adapters/codex.js +89 -5
- package/lib/yoke/codex-binary.js +59 -0
- package/package.json +1 -1
- package/scripts/check-test-count.js +5 -0
- package/scripts/install-local-test.js +50 -9
- package/scripts/write-build-sha.js +18 -2
- package/lib/public/css/channel-layout.css +0 -329
- package/lib/themes/ayu-light.json +0 -9
- package/lib/themes/catppuccin-latte.json +0 -9
- package/lib/themes/catppuccin-mocha.json +0 -9
- package/lib/themes/dracula.json +0 -9
- package/lib/themes/everforest-light.json +0 -9
- package/lib/themes/everforest.json +0 -9
- package/lib/themes/github-light.json +0 -9
- package/lib/themes/gruvbox-dark.json +0 -9
- package/lib/themes/gruvbox-light.json +0 -9
- package/lib/themes/monokai.json +0 -9
- package/lib/themes/nord-light.json +0 -9
- package/lib/themes/nord.json +0 -9
- package/lib/themes/one-dark.json +0 -9
- package/lib/themes/one-light.json +0 -9
- package/lib/themes/rose-pine-dawn.json +0 -9
- package/lib/themes/rose-pine.json +0 -9
- package/lib/themes/solarized-dark.json +0 -9
- package/lib/themes/solarized-light.json +0 -9
- package/lib/themes/tokyo-night-light.json +0 -9
- package/lib/themes/tokyo-night.json +0 -9
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// atomic-install.js — install a build into the global npm prefix without the
|
|
4
|
+
// command ever going missing.
|
|
5
|
+
//
|
|
6
|
+
// `npm install -g` over an existing install retires the old package and its bin
|
|
7
|
+
// link, unpacks the new package, then relinks. For that window the command is
|
|
8
|
+
// absent, so every CLI caller (send-input, hooks, scripts) exits 127. This
|
|
9
|
+
// helper installs into a staging prefix on the same filesystem, then swaps the
|
|
10
|
+
// result in with renames only:
|
|
11
|
+
//
|
|
12
|
+
// * the bin link is repointed by creating a temporary symlink and renaming it
|
|
13
|
+
// over the live one, never unlink-then-create;
|
|
14
|
+
// * the package directory is moved into place with rename(2). rename(2)
|
|
15
|
+
// cannot replace a non-empty directory, so an existing install takes two
|
|
16
|
+
// renames (new in, old out). The bin link is pointed at a directory that
|
|
17
|
+
// exists across both, so it resolves at every instant.
|
|
18
|
+
//
|
|
19
|
+
// Lifecycle scripts are not run by the staging install (they would run against
|
|
20
|
+
// the staging path); the package's own postinstall runs at its final location.
|
|
21
|
+
// POSIX only: Windows cannot rename over files in use, so it keeps npm's own
|
|
22
|
+
// install.
|
|
23
|
+
|
|
24
|
+
const fs = require("fs");
|
|
25
|
+
const path = require("path");
|
|
26
|
+
const { spawn, execFileSync } = require("child_process");
|
|
27
|
+
|
|
28
|
+
const PACKAGE_NAME = "@clagentic/console";
|
|
29
|
+
const STAGE_PREFIX = ".clagentic-console-stage-";
|
|
30
|
+
|
|
31
|
+
function uniqueId() {
|
|
32
|
+
return process.pid + "-" + Date.now().toString(36) + "-" + Math.random().toString(36).slice(2, 8);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Runs a process to completion. Rejects with the exit status, the signal or the
|
|
36
|
+
// timeout and the tail of stderr, so a caller can show the user why.
|
|
37
|
+
function runProcess(cmd, args, opts) {
|
|
38
|
+
return new Promise(function (resolve, reject) {
|
|
39
|
+
var inherit = !!opts.inherit;
|
|
40
|
+
var child = spawn(cmd, args, {
|
|
41
|
+
cwd: opts.cwd,
|
|
42
|
+
env: opts.env || process.env,
|
|
43
|
+
stdio: inherit ? "inherit" : ["ignore", "pipe", "pipe"],
|
|
44
|
+
});
|
|
45
|
+
var tail = "";
|
|
46
|
+
var timedOut = false;
|
|
47
|
+
var timer = null;
|
|
48
|
+
if (!inherit) {
|
|
49
|
+
child.stdout.resume();
|
|
50
|
+
child.stderr.on("data", function (d) { tail = (tail + d).slice(-2000); });
|
|
51
|
+
}
|
|
52
|
+
if (opts.timeoutMs) {
|
|
53
|
+
timer = setTimeout(function () { timedOut = true; child.kill("SIGKILL"); }, opts.timeoutMs);
|
|
54
|
+
}
|
|
55
|
+
child.on("error", function (err) {
|
|
56
|
+
if (timer) clearTimeout(timer);
|
|
57
|
+
reject(err);
|
|
58
|
+
});
|
|
59
|
+
child.on("close", function (code, signal) {
|
|
60
|
+
if (timer) clearTimeout(timer);
|
|
61
|
+
if (code === 0) return resolve();
|
|
62
|
+
var why = timedOut ? "timed out after " + opts.timeoutMs + " ms"
|
|
63
|
+
: signal ? "was stopped by " + signal : "exited with status " + code;
|
|
64
|
+
var err = new Error(cmd + " " + why + (tail.trim() ? ": " + tail.trim() : ""));
|
|
65
|
+
err.exitCode = code;
|
|
66
|
+
reject(err);
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// --prefix <stageRoot> moves npm's default globalconfig to <stageRoot>/etc/npmrc,
|
|
72
|
+
// so a registry, proxy or auth setting in the real global npmrc would be
|
|
73
|
+
// ignored. npm's default for a prefix is <prefix>/etc/npmrc; hand that path to
|
|
74
|
+
// the staging install through npm_config_globalconfig, unless the caller's
|
|
75
|
+
// environment already names a globalconfig (any case, as npm reads it). The
|
|
76
|
+
// per-user ~/.npmrc is not affected by --prefix and is left alone.
|
|
77
|
+
function stagingEnv(env, prefix) {
|
|
78
|
+
const named = Object.keys(env).some(function (k) { return k.toLowerCase() === "npm_config_globalconfig" && env[k]; });
|
|
79
|
+
if (named) return env;
|
|
80
|
+
return Object.assign({}, env, { npm_config_globalconfig: path.join(prefix, "etc", "npmrc") });
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function resolveGlobalPrefix(env) {
|
|
84
|
+
return execFileSync("npm", ["prefix", "-g"], { encoding: "utf8", env: env || process.env }).trim();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Bin name -> path inside the package, from package.json's `bin` field.
|
|
88
|
+
function binMapOf(pkgJson) {
|
|
89
|
+
if (!pkgJson.bin) return {};
|
|
90
|
+
if (typeof pkgJson.bin === "string") {
|
|
91
|
+
return { [path.basename(pkgJson.name)]: pkgJson.bin };
|
|
92
|
+
}
|
|
93
|
+
return Object.assign({}, pkgJson.bin);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Creates a symlink at a temporary name beside the bin link, then renames it
|
|
97
|
+
// over the live one. The rename replaces the old link in one step.
|
|
98
|
+
function repointBin(fsx, binDir, binName, pkgDir, binRel, id) {
|
|
99
|
+
const linkPath = path.join(binDir, binName);
|
|
100
|
+
const tmpPath = path.join(binDir, "." + binName + "." + id + ".tmp");
|
|
101
|
+
const target = path.relative(binDir, path.join(pkgDir, binRel));
|
|
102
|
+
try {
|
|
103
|
+
fsx.symlinkSync(target, tmpPath);
|
|
104
|
+
fsx.renameSync(tmpPath, linkPath);
|
|
105
|
+
} catch (err) {
|
|
106
|
+
try { fsx.rmSync(tmpPath, { force: true }); } catch (_) { /* nothing left to clean */ }
|
|
107
|
+
throw err;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Moves `stagedPkgDir` into <prefix>/lib/node_modules/<name> and repoints the
|
|
113
|
+
* bin links, so the command resolves between every two filesystem operations.
|
|
114
|
+
* `stagedPkgDir` must be on the same filesystem as the prefix. Returns
|
|
115
|
+
* { retiredDir } — the previous package directory, moved aside and left for the
|
|
116
|
+
* caller to remove (null on a first install).
|
|
117
|
+
*/
|
|
118
|
+
function swapIn(opts) {
|
|
119
|
+
const fsx = opts.fs || fs;
|
|
120
|
+
const name = opts.name || PACKAGE_NAME;
|
|
121
|
+
const prefix = opts.prefix;
|
|
122
|
+
const id = opts.id || uniqueId();
|
|
123
|
+
const binMap = opts.binMap;
|
|
124
|
+
const modulesDir = path.join(prefix, "lib", "node_modules");
|
|
125
|
+
const finalDir = path.join(modulesDir, name);
|
|
126
|
+
const scopeDir = path.dirname(finalDir);
|
|
127
|
+
const leaf = path.basename(finalDir);
|
|
128
|
+
const binDir = path.join(prefix, "bin");
|
|
129
|
+
const incomingDir = path.join(scopeDir, "." + leaf + ".incoming-" + id);
|
|
130
|
+
const retiredDir = path.join(scopeDir, "." + leaf + ".retired-" + id);
|
|
131
|
+
|
|
132
|
+
fsx.mkdirSync(scopeDir, { recursive: true });
|
|
133
|
+
fsx.mkdirSync(binDir, { recursive: true });
|
|
134
|
+
|
|
135
|
+
const point = function (dir) {
|
|
136
|
+
Object.keys(binMap).forEach(function (binName) {
|
|
137
|
+
repointBin(fsx, binDir, binName, dir, binMap[binName], id);
|
|
138
|
+
});
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
let exists = true;
|
|
142
|
+
try { fsx.lstatSync(finalDir); } catch (err) {
|
|
143
|
+
if (err.code !== "ENOENT") throw err;
|
|
144
|
+
exists = false;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (!exists) {
|
|
148
|
+
fsx.renameSync(opts.stagedPkgDir, finalDir);
|
|
149
|
+
point(finalDir);
|
|
150
|
+
return { retiredDir: null };
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// The command must resolve between every pair of steps below.
|
|
154
|
+
let moved = false; // the live build sits at retiredDir
|
|
155
|
+
let incomingHere = false; // the staged build sits at incomingDir
|
|
156
|
+
let placed = false; // the staged build sits at finalDir
|
|
157
|
+
let stagedAt = opts.stagedPkgDir; // where the staged build is right now
|
|
158
|
+
try {
|
|
159
|
+
fsx.renameSync(opts.stagedPkgDir, incomingDir); // new build beside the old one
|
|
160
|
+
incomingHere = true;
|
|
161
|
+
stagedAt = incomingDir;
|
|
162
|
+
point(incomingDir); // bin -> new build
|
|
163
|
+
fsx.renameSync(finalDir, retiredDir); // old build out of the way
|
|
164
|
+
moved = true;
|
|
165
|
+
point(retiredDir); // bin -> old build, frees the incoming name
|
|
166
|
+
fsx.renameSync(incomingDir, finalDir); // new build in
|
|
167
|
+
incomingHere = false;
|
|
168
|
+
placed = true;
|
|
169
|
+
stagedAt = finalDir;
|
|
170
|
+
point(finalDir); // bin -> final path
|
|
171
|
+
} catch (err) {
|
|
172
|
+
// Put the previous build back where the command expects it and hand the
|
|
173
|
+
// staged build back to the caller. The caller's staged directory is never
|
|
174
|
+
// deleted here: in a rollback it is the only copy of the previous build.
|
|
175
|
+
try {
|
|
176
|
+
if (placed) {
|
|
177
|
+
point(retiredDir);
|
|
178
|
+
fsx.renameSync(finalDir, opts.stagedPkgDir);
|
|
179
|
+
stagedAt = opts.stagedPkgDir;
|
|
180
|
+
fsx.renameSync(retiredDir, finalDir);
|
|
181
|
+
point(finalDir);
|
|
182
|
+
} else {
|
|
183
|
+
if (moved) {
|
|
184
|
+
let finalMissing = false;
|
|
185
|
+
try { fsx.lstatSync(finalDir); } catch (_) { finalMissing = true; }
|
|
186
|
+
if (finalMissing) fsx.renameSync(retiredDir, finalDir);
|
|
187
|
+
}
|
|
188
|
+
point(finalDir);
|
|
189
|
+
if (incomingHere) {
|
|
190
|
+
fsx.renameSync(incomingDir, opts.stagedPkgDir);
|
|
191
|
+
stagedAt = opts.stagedPkgDir;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
} catch (rollbackErr) {
|
|
195
|
+
// The original failure is the one thrown; the rollback failure rides on it
|
|
196
|
+
// so the caller can report both and say where the staged build was left.
|
|
197
|
+
err.rollbackError = rollbackErr;
|
|
198
|
+
// Where the build that was live before this call sits: still at the retired
|
|
199
|
+
// name when the move-back did not happen, else at the final path.
|
|
200
|
+
let retiredHere = false;
|
|
201
|
+
if (moved) {
|
|
202
|
+
try { fsx.lstatSync(retiredDir); retiredHere = true; } catch (_) { /* not at the retired name */ }
|
|
203
|
+
}
|
|
204
|
+
err.previousAt = retiredHere ? retiredDir : finalDir;
|
|
205
|
+
}
|
|
206
|
+
err.stagedAt = stagedAt;
|
|
207
|
+
throw err;
|
|
208
|
+
}
|
|
209
|
+
return { retiredDir: retiredDir };
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function readPackageJson(fsx, dir) {
|
|
213
|
+
return JSON.parse(fsx.readFileSync(path.join(dir, "package.json"), "utf8"));
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Installs `spec` (a tarball path or name@version) into the global prefix.
|
|
218
|
+
*
|
|
219
|
+
* opts.spec what to hand to npm install
|
|
220
|
+
* opts.prefix global prefix (default: `npm prefix -g`)
|
|
221
|
+
* opts.env environment for npm and the package's postinstall
|
|
222
|
+
* opts.timeoutMs limit for the npm step
|
|
223
|
+
* opts.inherit show npm's output instead of capturing it
|
|
224
|
+
* opts.name package name (default @clagentic/console)
|
|
225
|
+
* opts.runNpm (args, runOpts) => Promise; replaces spawning npm (tests)
|
|
226
|
+
* opts.runScript (command, runOpts) => Promise; replaces the postinstall run (tests)
|
|
227
|
+
* opts.fs filesystem (tests)
|
|
228
|
+
*
|
|
229
|
+
* A failed staging install, an unwritable prefix or a failed postinstall leaves
|
|
230
|
+
* the previous build in place. Resolves to { prefix, packageDir, mode }.
|
|
231
|
+
*/
|
|
232
|
+
async function installGlobalAtomically(opts) {
|
|
233
|
+
const fsx = opts.fs || fs;
|
|
234
|
+
const name = opts.name || PACKAGE_NAME;
|
|
235
|
+
const env = opts.env || process.env;
|
|
236
|
+
const runNpm = opts.runNpm || function (args, o) { return runProcess("npm", args, o); };
|
|
237
|
+
const runScript = opts.runScript || function (command, o) { return runProcess("sh", ["-c", command], o); };
|
|
238
|
+
|
|
239
|
+
if (process.platform === "win32" && !opts.runNpm) {
|
|
240
|
+
await runNpm(["install", "-g", opts.spec], { env: env, timeoutMs: opts.timeoutMs, inherit: opts.inherit });
|
|
241
|
+
return { prefix: null, packageDir: null, mode: "npm-direct" };
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
const prefix = opts.prefix || resolveGlobalPrefix(env);
|
|
245
|
+
const stageParent = path.join(prefix, "lib");
|
|
246
|
+
const id = uniqueId();
|
|
247
|
+
let stageRoot = null;
|
|
248
|
+
try {
|
|
249
|
+
fsx.mkdirSync(stageParent, { recursive: true });
|
|
250
|
+
stageRoot = fsx.mkdtempSync(path.join(stageParent, STAGE_PREFIX));
|
|
251
|
+
} catch (err) {
|
|
252
|
+
throw new Error("cannot write to the install prefix " + prefix + " (" + err.code + "): " + err.message);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
let retiredDir = null;
|
|
256
|
+
try {
|
|
257
|
+
// --prefix on the command line wins over a prefix in the caller's npm env.
|
|
258
|
+
await runNpm(
|
|
259
|
+
["install", "-g", "--prefix", stageRoot, "--ignore-scripts", "--no-audit", "--no-fund", opts.spec],
|
|
260
|
+
{ env: stagingEnv(env, prefix), timeoutMs: opts.timeoutMs, inherit: opts.inherit }
|
|
261
|
+
);
|
|
262
|
+
|
|
263
|
+
const stagedPkgDir = path.join(stageRoot, "lib", "node_modules", name);
|
|
264
|
+
let pkgJson;
|
|
265
|
+
try {
|
|
266
|
+
pkgJson = readPackageJson(fsx, stagedPkgDir);
|
|
267
|
+
} catch (err) {
|
|
268
|
+
throw new Error("the staged install of " + opts.spec + " has no readable " + name + " package (" + err.message + ")");
|
|
269
|
+
}
|
|
270
|
+
const binMap = binMapOf(pkgJson);
|
|
271
|
+
let swapped;
|
|
272
|
+
try {
|
|
273
|
+
swapped = swapIn({ fs: fsx, prefix: prefix, name: name, stagedPkgDir: stagedPkgDir, binMap: binMap, id: id });
|
|
274
|
+
} catch (swapErr) {
|
|
275
|
+
if (!swapErr.rollbackError) throw swapErr;
|
|
276
|
+
// The previous build can sit at a dotted retired directory; name it so it
|
|
277
|
+
// is not lost, and keep the rollback failure on the error.
|
|
278
|
+
const failure = new Error("installing the new build failed (" + swapErr.message + ") and the rollback also failed (" + swapErr.rollbackError.message + "); the previous build is kept at " + (swapErr.previousAt || swapErr.stagedAt));
|
|
279
|
+
failure.cause = swapErr.rollbackError;
|
|
280
|
+
throw failure;
|
|
281
|
+
}
|
|
282
|
+
retiredDir = swapped.retiredDir;
|
|
283
|
+
const packageDir = path.join(prefix, "lib", "node_modules", name);
|
|
284
|
+
|
|
285
|
+
const postinstall = pkgJson.scripts && pkgJson.scripts.postinstall;
|
|
286
|
+
if (postinstall) {
|
|
287
|
+
const scriptEnv = Object.assign({}, env, {
|
|
288
|
+
npm_config_global: "true",
|
|
289
|
+
npm_config_prefix: prefix,
|
|
290
|
+
npm_package_name: pkgJson.name,
|
|
291
|
+
npm_package_version: pkgJson.version,
|
|
292
|
+
});
|
|
293
|
+
try {
|
|
294
|
+
await runScript(postinstall, { cwd: packageDir, env: scriptEnv, timeoutMs: opts.timeoutMs, inherit: opts.inherit });
|
|
295
|
+
} catch (err) {
|
|
296
|
+
if (retiredDir) {
|
|
297
|
+
// Restore the previous build, as npm does when a lifecycle script fails.
|
|
298
|
+
let back;
|
|
299
|
+
try {
|
|
300
|
+
back = swapIn({ fs: fsx, prefix: prefix, name: name, stagedPkgDir: retiredDir, binMap: binMap, id: id + "-undo" });
|
|
301
|
+
} catch (undoErr) {
|
|
302
|
+
// The previous build may be the only copy; leave it on disk.
|
|
303
|
+
// swapIn reports where the build it was handed ended up; a failed
|
|
304
|
+
// rollback can leave it beside the install rather than at retiredDir.
|
|
305
|
+
const kept = undoErr.stagedAt || retiredDir;
|
|
306
|
+
retiredDir = null;
|
|
307
|
+
const rollback = undoErr.rollbackError ? "; the rollback also failed (" + undoErr.rollbackError.message + ")" : "";
|
|
308
|
+
const failure = new Error("postinstall failed (" + err.message + ") and restoring the previous build failed (" + undoErr.message + ")" + rollback + "; the previous build is kept at " + kept);
|
|
309
|
+
if (undoErr.rollbackError) failure.cause = undoErr.rollbackError;
|
|
310
|
+
throw failure;
|
|
311
|
+
}
|
|
312
|
+
retiredDir = null;
|
|
313
|
+
if (back.retiredDir) fsx.rmSync(back.retiredDir, { recursive: true, force: true });
|
|
314
|
+
}
|
|
315
|
+
throw new Error("postinstall failed, the previous build was kept: " + err.message);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
return { prefix: prefix, packageDir: packageDir, mode: "atomic" };
|
|
319
|
+
} finally {
|
|
320
|
+
if (retiredDir) {
|
|
321
|
+
try { fsx.rmSync(retiredDir, { recursive: true, force: true }); } catch (_) { /* the new build is live; a leftover dotted directory is harmless */ }
|
|
322
|
+
}
|
|
323
|
+
try { fsx.rmSync(stageRoot, { recursive: true, force: true }); } catch (_) { /* same: a leftover staging directory is harmless */ }
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
module.exports = {
|
|
328
|
+
PACKAGE_NAME,
|
|
329
|
+
STAGE_PREFIX,
|
|
330
|
+
installGlobalAtomically,
|
|
331
|
+
swapIn,
|
|
332
|
+
resolveGlobalPrefix,
|
|
333
|
+
runProcess,
|
|
334
|
+
};
|
package/lib/build-changes.js
CHANGED
|
@@ -18,13 +18,42 @@ var GIT_TIMEOUT_MS = 5000;
|
|
|
18
18
|
|
|
19
19
|
// An install made from a packed tarball (npm install -g, including the
|
|
20
20
|
// install:local-test script) carries no .git directory, so the package
|
|
21
|
-
// directory cannot answer;
|
|
21
|
+
// directory cannot answer; buildSourceRepo in daemon.json can, and so can the
|
|
22
|
+
// source install:local-test records in the build.
|
|
22
23
|
var NO_REPO_REASON = 'this install carries no git history (it was installed from a package, not a checkout); ' +
|
|
23
24
|
'set buildSourceRepo in daemon.json to the checkout it was built from to list the changes';
|
|
24
25
|
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
// Set only by install:local-test, for the one `npm pack` it runs. A pack or a
|
|
27
|
+
// publish without it embeds no host path.
|
|
28
|
+
var BUILD_SOURCE_ENV = 'CLAGENTIC_CONSOLE_BUILD_SOURCE_REPO';
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The lasting checkout a local install was built from, as recorded in the
|
|
32
|
+
* package's own lib/build-sha.json, or null. It lives in the installed files,
|
|
33
|
+
* not in daemon.json, so the daemon rewriting its config cannot drop it and an
|
|
34
|
+
* operator's buildSourceRepo is never touched.
|
|
35
|
+
*/
|
|
36
|
+
function readRecordedSource(packageRoot, readFile) {
|
|
37
|
+
var read = readFile || fs.readFileSync;
|
|
38
|
+
try {
|
|
39
|
+
var parsed = JSON.parse(read(path.join(packageRoot, 'lib', 'build-sha.json'), 'utf8'));
|
|
40
|
+
var src = parsed && parsed.sourceRepo;
|
|
41
|
+
return typeof src === 'string' && path.isAbsolute(src) ? src : null;
|
|
42
|
+
} catch (_) {
|
|
43
|
+
// absent, half-written or unparsable during an install: no recorded source
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The repository to read history from, or null when there is none to try.
|
|
50
|
+
* Order: the operator's buildSourceRepo, the source recorded at local install,
|
|
51
|
+
* the package root's own .git.
|
|
52
|
+
*/
|
|
53
|
+
function resolveHistoryRepo(configured, packageRoot, readFile) {
|
|
27
54
|
if (typeof configured === 'string' && path.isAbsolute(configured)) return configured;
|
|
55
|
+
var recorded = readRecordedSource(packageRoot, readFile);
|
|
56
|
+
if (recorded) return recorded;
|
|
28
57
|
try {
|
|
29
58
|
if (fs.existsSync(path.join(packageRoot, '.git'))) return packageRoot;
|
|
30
59
|
} catch (_) {
|
|
@@ -82,4 +111,4 @@ function listBuildChanges(o) {
|
|
|
82
111
|
});
|
|
83
112
|
}
|
|
84
113
|
|
|
85
|
-
module.exports = { listBuildChanges: listBuildChanges, resolveHistoryRepo: resolveHistoryRepo, DEFAULT_LIMIT: DEFAULT_LIMIT, NO_REPO_REASON: NO_REPO_REASON };
|
|
114
|
+
module.exports = { listBuildChanges: listBuildChanges, resolveHistoryRepo: resolveHistoryRepo, readRecordedSource: readRecordedSource, BUILD_SOURCE_ENV: BUILD_SOURCE_ENV, DEFAULT_LIMIT: DEFAULT_LIMIT, NO_REPO_REASON: NO_REPO_REASON };
|
package/lib/build-sha.json
CHANGED
|
@@ -74,6 +74,17 @@ function collectInterruptions(projects) {
|
|
|
74
74
|
};
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
+
/**
|
|
78
|
+
* The sessions a restart now would end, as the restart verb reports them:
|
|
79
|
+
* project and session, plus whether each is running a turn. Reads the same
|
|
80
|
+
* collector the operator card does.
|
|
81
|
+
*/
|
|
82
|
+
function inFlightSessions(projects) {
|
|
83
|
+
return collectInterruptions(projects).sessions.map(function (s) {
|
|
84
|
+
return { project: s.slug, session: s.localId, processing: s.processing, activity: s.activity };
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
77
88
|
// The three words the card uses; a reaped session is not on the card.
|
|
78
89
|
var ACTIVITY_LABEL = {
|
|
79
90
|
running: 'running a turn',
|
|
@@ -195,6 +206,7 @@ module.exports = {
|
|
|
195
206
|
noticeCooldownFrom: noticeCooldownFrom,
|
|
196
207
|
composeNotice: composeNotice,
|
|
197
208
|
collectInterruptions: collectInterruptions,
|
|
209
|
+
inFlightSessions: inFlightSessions,
|
|
198
210
|
describeInterruptions: describeInterruptions,
|
|
199
211
|
describeSession: describeSession,
|
|
200
212
|
buildOffer: buildOffer,
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// The conversation width a person can choose in Appearance. One list for every
|
|
4
|
+
// server-side reader (the per-user preference, the profile reply, the settings
|
|
5
|
+
// verb); the browser keeps its own copy in lib/public/modules/chat-width-prefs.js
|
|
6
|
+
// and a test holds the two together. The pixel sizes live in the stylesheet
|
|
7
|
+
// (css/base.css), not here.
|
|
8
|
+
|
|
9
|
+
var CHAT_WIDTHS = ["compact", "comfortable", "wide", "full"];
|
|
10
|
+
var DEFAULT_CHAT_WIDTH = "comfortable";
|
|
11
|
+
|
|
12
|
+
// The retired bubble/channel layout choice, mapped once onto the width that
|
|
13
|
+
// looks closest: bubble was the centred column, channel the full pane.
|
|
14
|
+
var LEGACY_LAYOUT_WIDTH = { bubble: "comfortable", channel: "full" };
|
|
15
|
+
|
|
16
|
+
function isChatWidth(value) {
|
|
17
|
+
return typeof value === "string" && CHAT_WIDTHS.indexOf(value) !== -1;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** The width a retired layout value maps to, or null when it is not one. */
|
|
21
|
+
function widthFromLegacyLayout(layout) {
|
|
22
|
+
if (typeof layout !== "string") return null;
|
|
23
|
+
return Object.prototype.hasOwnProperty.call(LEGACY_LAYOUT_WIDTH, layout) ? LEGACY_LAYOUT_WIDTH[layout] : null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
module.exports = {
|
|
27
|
+
CHAT_WIDTHS: CHAT_WIDTHS,
|
|
28
|
+
DEFAULT_CHAT_WIDTH: DEFAULT_CHAT_WIDTH,
|
|
29
|
+
isChatWidth: isChatWidth,
|
|
30
|
+
widthFromLegacyLayout: widthFromLegacyLayout,
|
|
31
|
+
};
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
// lib/cli/agent-usage.js
|
|
2
|
+
//
|
|
3
|
+
// The one source of the usage text of the agent verbs: open-session, send-input,
|
|
4
|
+
// end-session, answer-prompt, list-sessions, list-outbound and the three
|
|
5
|
+
// schedule-input subcommands. The verbs' own -h/--help, their error output and
|
|
6
|
+
// the top-level `clagentic-console --help` all read it, so a flag is added in one
|
|
7
|
+
// place.
|
|
8
|
+
|
|
9
|
+
var VERB_ORDER = Object.freeze([
|
|
10
|
+
"open-session",
|
|
11
|
+
"send-input",
|
|
12
|
+
"end-session",
|
|
13
|
+
"answer-prompt",
|
|
14
|
+
"list-sessions",
|
|
15
|
+
"list-outbound",
|
|
16
|
+
"schedule-input create",
|
|
17
|
+
"schedule-input list",
|
|
18
|
+
"schedule-input delete",
|
|
19
|
+
]);
|
|
20
|
+
|
|
21
|
+
// usage: the call shape. summary: what it does, one sentence, no names.
|
|
22
|
+
var ENTRIES = {
|
|
23
|
+
"open-session": {
|
|
24
|
+
usage: "clagentic-console open-session (--project <slug> | --to <address>) --prompt <text|-> [--vendor <id>] [--agent <name>] [--name <session-name>] [--visibility shared|private] [--permission-mode <mode>] [--settings <path>] [--initiator <kind>] [--context-note <text>] [--from <name>] [--from-session <id>]",
|
|
25
|
+
summary: "Open a session and run a first prompt (prints JSON)",
|
|
26
|
+
},
|
|
27
|
+
"send-input": {
|
|
28
|
+
usage: "clagentic-console send-input (--project <slug> --session <id> | --to <address> | --reply) --prompt <text|-> [--initiator <kind>] [--context-note <text>] [--from <name>] [--from-session <id>]",
|
|
29
|
+
summary: "Send input to a session, resuming it if needed (prints JSON; exit 3 ambiguous, 4 not found by address)",
|
|
30
|
+
},
|
|
31
|
+
"end-session": {
|
|
32
|
+
usage: "clagentic-console end-session (--project <slug> --session <id> | --to <address>) [--from <name>] [--from-session <id>] [--reason <text>]",
|
|
33
|
+
summary: "Stand one live session down, even one blocked on a permission prompt; history is kept and the session resumes by id (prints JSON; exit 3 ambiguous, 4 not found by address)",
|
|
34
|
+
},
|
|
35
|
+
"answer-prompt": {
|
|
36
|
+
usage: "clagentic-console answer-prompt (--project <slug> --session <id> | --to <address>) --request <id> --decision <allow|deny|allow_always|text> [--from <name>] [--from-session <id>]",
|
|
37
|
+
summary: "Answer one pending prompt of a live session, as the browser would (prints JSON; exit 3 ambiguous, 4 not found by address)",
|
|
38
|
+
},
|
|
39
|
+
"list-sessions": {
|
|
40
|
+
usage: "clagentic-console list-sessions [--project <slug>] [--agent <name>] [--vendor <id>] [--state <live|idle|reaped|any>[,...]] [--limit <n>] [--verbose]",
|
|
41
|
+
summary: "List the console's sessions, newest first: live and idle ones, plus the newest reaped one of each agent lane with none live or idle, unless --state says otherwise (--state any lists every session); one compact row each, or the full record with --verbose (prints JSON)",
|
|
42
|
+
},
|
|
43
|
+
"list-outbound": {
|
|
44
|
+
usage: "clagentic-console list-outbound --session <vendor-session-id> [--project <slug>] [--since <dur>] [--kind sent|opens] [--verbose]",
|
|
45
|
+
summary: "List what a session (by vendor session id, see list-sessions) sent out with send-input and open-session: target, prompt, time, initiator; compact rows, or the full record with --verbose (prints JSON; read-only; kept 30 days by default)",
|
|
46
|
+
},
|
|
47
|
+
"schedule-input create": {
|
|
48
|
+
usage: "clagentic-console schedule-input create --session <id> [--project <slug>] (--in <dur> | --at <time> | --every <dur> (--until <time> | --count <n>)) (--prompt <text|-> | --prompt-file <path>)",
|
|
49
|
+
summary: "Send text into a session later, once or on a repeat with an end (prints JSON)",
|
|
50
|
+
},
|
|
51
|
+
"schedule-input list": {
|
|
52
|
+
usage: "clagentic-console schedule-input list [--session <id>] [--project <slug>] [--state armed|done|ended|any] [--verbose]",
|
|
53
|
+
summary: "List scheduled input, from the browser or the CLI; compact rows, or the full record with --verbose (prints JSON)",
|
|
54
|
+
},
|
|
55
|
+
"schedule-input delete": {
|
|
56
|
+
usage: "clagentic-console schedule-input delete --id <id> [--project <slug>]",
|
|
57
|
+
summary: "Cancel a scheduled input",
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
// Notes for the verbs that take a duration, a time or an address.
|
|
62
|
+
var NOTES = Object.freeze([
|
|
63
|
+
"<dur> is minutes or parts like 90, 10m, 1h30m; <time> is a local HH:MM (a past one means tomorrow)",
|
|
64
|
+
"<address> is <agent>@<project>, <vendor>@<project> (a plain session) or @<project>, each with an optional /<session-name>",
|
|
65
|
+
"Several matches resolve live over idle over reaped; /<session-name> names one session exactly",
|
|
66
|
+
]);
|
|
67
|
+
|
|
68
|
+
function entryFor(key) {
|
|
69
|
+
return Object.prototype.hasOwnProperty.call(ENTRIES, key) ? ENTRIES[key] : null;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// An unknown key throws: a verb added without usage text fails at once, not as a blank help.
|
|
73
|
+
function usageLine(key) {
|
|
74
|
+
var e = entryFor(key);
|
|
75
|
+
if (!e) throw new Error("no usage text for " + String(key));
|
|
76
|
+
return "Usage: " + e.usage;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// What `<verb> --help` prints: the call shape, then what it does.
|
|
80
|
+
function helpText(key) {
|
|
81
|
+
return usageLine(key) + "\n\n" + entryFor(key).summary + "\n";
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// What `schedule-input --help` prints: the three call shapes.
|
|
85
|
+
function scheduleHelpText() {
|
|
86
|
+
var lines = ["Usage: clagentic-console schedule-input (create | list | delete) ...", ""];
|
|
87
|
+
VERB_ORDER.filter(function (k) { return k.indexOf("schedule-input ") === 0; }).forEach(function (k) {
|
|
88
|
+
lines.push(" " + ENTRIES[k].usage);
|
|
89
|
+
lines.push(" " + ENTRIES[k].summary);
|
|
90
|
+
});
|
|
91
|
+
lines.push("");
|
|
92
|
+
lines.push(" " + NOTES[0]);
|
|
93
|
+
return lines.join("\n") + "\n";
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// The agent-verb lines of the top-level --help, in the same shape as its other
|
|
97
|
+
// command lines.
|
|
98
|
+
function topLevelLines() {
|
|
99
|
+
var lines = [];
|
|
100
|
+
VERB_ORDER.forEach(function (key) {
|
|
101
|
+
lines.push(" " + ENTRIES[key].usage + " " + ENTRIES[key].summary);
|
|
102
|
+
// The notes follow the last schedule-input line, as they always have.
|
|
103
|
+
if (key === "schedule-input delete") NOTES.forEach(function (n) { lines.push(" " + n); });
|
|
104
|
+
});
|
|
105
|
+
return lines;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Whether args ask for help. A value that follows a flag taking one (a prompt
|
|
109
|
+
// that reads "--help") is text, not a request. valueFlags: the flags that take a
|
|
110
|
+
// value.
|
|
111
|
+
function wantsHelp(args, valueFlags) {
|
|
112
|
+
for (var i = 0; i < args.length; i++) {
|
|
113
|
+
if (args[i] === "-h" || args[i] === "--help") return true;
|
|
114
|
+
if (valueFlags.indexOf(args[i]) !== -1) i++;
|
|
115
|
+
}
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
module.exports = {
|
|
120
|
+
VERB_ORDER: VERB_ORDER,
|
|
121
|
+
usageLine: usageLine,
|
|
122
|
+
helpText: helpText,
|
|
123
|
+
scheduleHelpText: scheduleHelpText,
|
|
124
|
+
topLevelLines: topLevelLines,
|
|
125
|
+
wantsHelp: wantsHelp,
|
|
126
|
+
};
|
|
@@ -10,7 +10,7 @@ var BOOLEAN_FLAGS = [
|
|
|
10
10
|
"--no-https", "--local-cert", "--no-update", "--skip-update", "--dev",
|
|
11
11
|
"--watch", "-w", "--debug", "-y", "--yes", "--shutdown", "--restart",
|
|
12
12
|
"--no-restart", "--list", "--activity-diagnostics", "--usage", "--process-build-status",
|
|
13
|
-
"--headless", "--multi-user", "--os-users",
|
|
13
|
+
"--headless", "--multi-user", "--os-users", "--json",
|
|
14
14
|
// Removed flag: the flag loop prints its own dedicated message and exits 1.
|
|
15
15
|
"--dangerously-skip-permissions",
|
|
16
16
|
];
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// lib/cli/compact-output.js
|
|
2
|
+
//
|
|
3
|
+
// The compact form of what the listing verbs print: list-sessions, list-outbound
|
|
4
|
+
// and schedule-input list. A caller reads a compact row by default and the full
|
|
5
|
+
// record with --verbose, so no pipe or filter is needed to cut a long history
|
|
6
|
+
// down. Pure: each function takes the daemon's result and returns a new one.
|
|
7
|
+
// Only a "listed" result is projected; a refusal or error passes through whole.
|
|
8
|
+
|
|
9
|
+
var SESSION_ROW = ["consoleSessionId", "sessionId", "project", "label", "name", "state", "lastActivity", "pendingPrompts"];
|
|
10
|
+
var OUTBOUND_ROW = ["ts", "kind", "result", "reason", "initiator", "prompt", "promptWithheld"];
|
|
11
|
+
var OUTBOUND_TARGET = ["project", "sessionId", "agent", "name", "address"];
|
|
12
|
+
var SCHEDULED_ROW = ["id", "project", "sessionId", "kind", "state", "preview", "nextAt", "every", "firedCount"];
|
|
13
|
+
|
|
14
|
+
// The listed keys of obj that it holds, in that order.
|
|
15
|
+
function pick(obj, keys) {
|
|
16
|
+
var out = {};
|
|
17
|
+
keys.forEach(function (k) {
|
|
18
|
+
if (obj && Object.prototype.hasOwnProperty.call(obj, k)) out[k] = obj[k];
|
|
19
|
+
});
|
|
20
|
+
return out;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function isListed(res) {
|
|
24
|
+
return !!res && res.ok === true && res.result === "listed";
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function compactSessions(res) {
|
|
28
|
+
if (!isListed(res) || !Array.isArray(res.sessions)) return res;
|
|
29
|
+
var out = Object.assign({}, res);
|
|
30
|
+
out.sessions = res.sessions.map(function (s) { return pick(s, SESSION_ROW); });
|
|
31
|
+
return out;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function compactOutboundMessage(m) {
|
|
35
|
+
var row = pick(m, OUTBOUND_ROW);
|
|
36
|
+
row.target = pick(m && m.target, OUTBOUND_TARGET);
|
|
37
|
+
return row;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// The calls whose sender only named itself are counted (unattributedCount) and
|
|
41
|
+
// listed with --verbose.
|
|
42
|
+
function compactOutbound(res) {
|
|
43
|
+
if (!isListed(res)) return res;
|
|
44
|
+
var out = {};
|
|
45
|
+
["ok", "result", "session", "count", "unattributedCount", "note"].forEach(function (k) {
|
|
46
|
+
if (Object.prototype.hasOwnProperty.call(res, k)) out[k] = res[k];
|
|
47
|
+
});
|
|
48
|
+
out.messages = (res.messages || []).map(compactOutboundMessage);
|
|
49
|
+
return out;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// A project whose list cannot be saved (store, storeErrors) is kept: it says
|
|
53
|
+
// nothing of that project is delivered.
|
|
54
|
+
function compactScheduled(res) {
|
|
55
|
+
if (!isListed(res) || !Array.isArray(res.inputs)) return res;
|
|
56
|
+
var out = Object.assign({}, res);
|
|
57
|
+
out.inputs = res.inputs.map(function (r) { return pick(r, SCHEDULED_ROW); });
|
|
58
|
+
return out;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
module.exports = {
|
|
62
|
+
compactSessions: compactSessions,
|
|
63
|
+
compactOutbound: compactOutbound,
|
|
64
|
+
compactScheduled: compactScheduled,
|
|
65
|
+
SESSION_ROW: SESSION_ROW,
|
|
66
|
+
OUTBOUND_ROW: OUTBOUND_ROW,
|
|
67
|
+
OUTBOUND_TARGET: OUTBOUND_TARGET,
|
|
68
|
+
SCHEDULED_ROW: SCHEDULED_ROW,
|
|
69
|
+
};
|