@indigoai-us/hq-cli 5.345.236 → 5.345.237
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 +38 -0
- package/dist/command-catalog.generated.d.ts +1 -1
- package/dist/command-catalog.generated.js +1 -1
- package/dist/commands/bot.js +9 -0
- package/dist/commands/daemon.d.ts +1 -0
- package/dist/commands/daemon.js +70 -6
- package/dist/commands/deploy-app-db.js +4 -19
- package/dist/commands/deploy-app-upload.js +66 -40
- package/dist/commands/deploy-mutations.js +24 -16
- package/dist/commands/deploy-runtime-bindings.js +7 -26
- package/dist/commands/deploy-ssr.js +5 -24
- package/dist/commands/mesh.js +6 -2
- package/dist/commands/signals-run.d.ts +43 -2
- package/dist/commands/signals-run.js +85 -7
- package/dist/commands/sync-core.d.ts +7 -0
- package/dist/commands/sync-core.js +52 -3
- package/dist/lib/bot/continuity.d.ts +21 -2
- package/dist/lib/bot/continuity.js +48 -19
- package/dist/lib/bot/fleet-cron.js +6 -0
- package/dist/lib/bot/fleet-local.d.ts +11 -1
- package/dist/lib/bot/fleet-local.js +21 -1
- package/dist/lib/bot/fleet-state.d.ts +129 -0
- package/dist/lib/bot/fleet-state.js +669 -0
- package/dist/lib/bot/promote.d.ts +9 -3
- package/dist/lib/bot/promote.js +115 -16
- package/dist/lib/daemon/catalog.d.ts +13 -0
- package/dist/lib/daemon/catalog.js +32 -6
- package/dist/lib/daemon/lanes-reconcile-status.d.ts +0 -4
- package/dist/lib/daemon/lanes-reconcile-status.js +2 -12
- package/dist/lib/daemon/lanes-reconcile-watcher.d.ts +1 -1
- package/dist/lib/daemon/lanes-reconcile-watcher.js +2 -1
- package/dist/lib/daemon/legacy-handover.d.ts +38 -0
- package/dist/lib/daemon/legacy-handover.js +117 -0
- package/dist/lib/daemon/mesh-owner.js +2 -1
- package/dist/lib/daemon/run.d.ts +18 -1
- package/dist/lib/daemon/run.js +85 -12
- package/dist/lib/daemon/selfcheck.d.ts +28 -0
- package/dist/lib/daemon/selfcheck.js +86 -15
- package/dist/lib/deploy-api.d.ts +1 -1
- package/dist/lib/deploy-api.js +2 -1
- package/dist/lib/deploy-identity.d.ts +18 -0
- package/dist/lib/deploy-identity.js +179 -0
- package/dist/lib/hot-channels/alert.js +13 -6
- package/dist/lib/hot-channels/fleet-complete.d.ts +89 -0
- package/dist/lib/hot-channels/fleet-complete.js +157 -0
- package/dist/lib/hot-channels/run.js +2 -1
- package/dist/lib/hot-channels/signals-claude-login.d.ts +3 -2
- package/dist/lib/hot-channels/signals-claude-login.js +6 -1
- package/dist/lib/hot-channels/signals-pass-failure.d.ts +29 -0
- package/dist/lib/hot-channels/signals-pass-failure.js +36 -0
- package/dist/lib/hot-channels/signals-pass.d.ts +49 -2
- package/dist/lib/hot-channels/signals-pass.js +188 -12
- package/dist/lib/hot-channels/signals-runtime.d.ts +6 -3
- package/dist/lib/hot-channels/signals-runtime.js +11 -2
- package/dist/lib/lanes/reconcile-result.d.ts +5 -0
- package/dist/lib/lanes/reconcile-result.js +20 -2
- package/dist/lib/lanes/reconcile.js +12 -3
- package/dist/lib/mesh/live/emit.js +25 -6
- package/dist/lib/mesh/live/flush.js +119 -15
- package/dist/lib/mesh/live/reporting-privacy.d.ts +41 -0
- package/dist/lib/mesh/live/reporting-privacy.js +147 -1
- package/dist/lib/mesh/live/spool.d.ts +16 -0
- package/dist/lib/mesh/live/spool.js +45 -0
- package/dist/lib/signals/engine.d.ts +17 -3
- package/dist/lib/signals/engine.js +28 -9
- package/dist/lib/signals/failure-alert.d.ts +33 -1
- package/dist/lib/signals/failure-alert.js +72 -5
- package/dist/lib/signals/owner-notice.d.ts +94 -0
- package/dist/lib/signals/owner-notice.js +233 -0
- package/dist/lib/signals/reply.d.ts +7 -0
- package/dist/lib/signals/reply.js +23 -3
- package/dist/lib/signals/steps/adapters.d.ts +51 -2
- package/dist/lib/signals/steps/adapters.js +213 -7
- package/dist/lib/signals/steps/extract.js +18 -4
- package/dist/lib/signals/steps/types.d.ts +63 -1
- package/dist/lib/signals/steps/types.js +32 -0
- package/dist/lib/sync-core/engine-auth.d.ts +35 -0
- package/dist/lib/sync-core/engine-auth.js +96 -0
- package/dist/lib/sync-core/engine-home.d.ts +6 -0
- package/dist/lib/sync-core/engine-home.js +12 -0
- package/dist/lib/sync-core/rollout-state.d.ts +1 -0
- package/dist/lib/sync-core/rollout-state.js +3 -0
- package/dist/lib/vault-sync-switches.d.ts +7 -0
- package/dist/lib/vault-sync-switches.js +56 -0
- package/dist/lib/work-context/errors.d.ts +12 -0
- package/dist/lib/work-context/errors.js +15 -0
- package/dist/lib/work-context/organize.js +6 -1
- package/dist/lib/work-context/reconcile.js +20 -1
- package/dist/utils/resident-package-preload.js +34 -4
- package/docs/anywhere-runtime.md +6 -0
- package/package.json +7 -7
|
@@ -0,0 +1,669 @@
|
|
|
1
|
+
/** What a promoted HQ Fleet Runtime bot takes out of its local profile: the
|
|
2
|
+
* skills it learned, its portable scheduled jobs and its settings. The shared
|
|
3
|
+
* memory store cannot be split per bot, so none of it moves. Read-only; nothing
|
|
4
|
+
* here stops or changes a bot.
|
|
5
|
+
*/
|
|
6
|
+
import { createHash } from "node:crypto";
|
|
7
|
+
import * as fs from "node:fs";
|
|
8
|
+
import * as path from "node:path";
|
|
9
|
+
import * as yaml from "js-yaml";
|
|
10
|
+
import { HQ_FLEET_RUNTIME_ENGINE_ID } from "./config.js";
|
|
11
|
+
import { FLEET_STATE_DIR, MAX_TRANSFER_BYTES, MAX_TRANSFER_FILES, PRIVATE_NAME, readStableFile } from "./continuity.js";
|
|
12
|
+
import { fleetHome, fleetLocalProfileDir } from "./fleet-local.js";
|
|
13
|
+
import { ALLOW_MARKERS, pathIgnored, scanFragment, scanPath } from "../secret-scan/detect.js";
|
|
14
|
+
const MEMORY_DELIMITER = /\r?\n§\r?\n/;
|
|
15
|
+
const MAX_SKILL_DEPTH = 4;
|
|
16
|
+
/** Strong signals only, so a skill about tokens or password resets still moves. */
|
|
17
|
+
const SECRET_FILE_NAME = /^(?:credentials?(?:[._-].*)?|secrets?\..+|\.env(?:\..*)?|private[_-]?key(?:\..*)?)$/i;
|
|
18
|
+
const SECRET_FILE_EXTENSION = /\.(pem|key|p12|pfx)$/i;
|
|
19
|
+
const SSH_KEY_FILE = /^id_(rsa|dsa|ecdsa|ed25519)(\.|$)/i;
|
|
20
|
+
/** The box installer refuses a single file larger than this. */
|
|
21
|
+
export const MAX_SKILL_FILE_BYTES = 4 * 1024 * 1024;
|
|
22
|
+
/** The box installer accepts at most this many carried jobs. */
|
|
23
|
+
export const MAX_CARRIED_JOBS = 200;
|
|
24
|
+
/** Zone names the box installer accepts. */
|
|
25
|
+
const INSTALLER_ZONE = /^[A-Za-z0-9_+\-/]{1,64}$/;
|
|
26
|
+
/** Job ids the box installer accepts. */
|
|
27
|
+
const INSTALLER_JOB_ID = /^[A-Za-z0-9_-]{1,64}$/;
|
|
28
|
+
/** One year; a longer interval is treated as unreadable. */
|
|
29
|
+
export const MAX_INTERVAL_MINUTES = 525_600;
|
|
30
|
+
/** A line longer than this is not scanned: the text is treated as possibly holding a secret. */
|
|
31
|
+
export const MAX_SCANNED_LINE = 64 * 1024;
|
|
32
|
+
const SCAN_WINDOW = 16 * 1024;
|
|
33
|
+
/** Consecutive scan windows share this much text, so a match up to this long is never cut. */
|
|
34
|
+
const SCAN_OVERLAP = 8 * 1024;
|
|
35
|
+
/** `run_at` forms every Python `datetime.fromisoformat` since 3.7 accepts (after the box turns `Z` into `+00:00`). */
|
|
36
|
+
const RUN_AT = /^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.(?:\d{3}|\d{6}))?)?(Z|[+-]\d{2}:\d{2})?)?$/;
|
|
37
|
+
export const SKILL_FILE_TOO_LARGE = "has a file over 4 MiB";
|
|
38
|
+
export const SKILL_MAY_HOLD_SECRET = "may contain a secret";
|
|
39
|
+
export const BUNDLED_MANIFEST_MISSING = "bundled-manifest-missing";
|
|
40
|
+
/** The box installer installs at most this many carried skills. */
|
|
41
|
+
export const MAX_CARRIED_SKILLS = 500;
|
|
42
|
+
export const SKILL_PAST_LIMIT = `is past the ${MAX_CARRIED_SKILLS}-skill limit for one move`;
|
|
43
|
+
/** Written in place of a skill folder name that looks like a credential. */
|
|
44
|
+
export const WITHHELD_SKILL_NAME = "(name withheld)";
|
|
45
|
+
function refuse(message) { throw new Error(`Bot continuity: ${message}`); }
|
|
46
|
+
/** Learned skills hold more than one transfer allows; `skills` names them, largest first. */
|
|
47
|
+
export class FleetStateLimitError extends Error {
|
|
48
|
+
skills;
|
|
49
|
+
constructor(message, skills) { super(`Bot continuity: ${message}`); this.skills = skills; }
|
|
50
|
+
}
|
|
51
|
+
/** False when absent. A link is never followed. */
|
|
52
|
+
function plainDirectoryExists(absolute, label) {
|
|
53
|
+
const st = fs.lstatSync(absolute, { throwIfNoEntry: false });
|
|
54
|
+
if (!st)
|
|
55
|
+
return false;
|
|
56
|
+
if (st.isSymbolicLink() || !st.isDirectory())
|
|
57
|
+
refuse(`${label} must be a real folder, not a link: ${absolute}`);
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
function readOptionalFile(absolute, label) {
|
|
61
|
+
const st = fs.lstatSync(absolute, { throwIfNoEntry: false });
|
|
62
|
+
return st ? readStableFile(absolute, label, st).bytes : null;
|
|
63
|
+
}
|
|
64
|
+
function zoneDate(instant, timeZone) {
|
|
65
|
+
try {
|
|
66
|
+
return new Intl.DateTimeFormat("en-CA", { timeZone, year: "numeric", month: "2-digit", day: "2-digit" }).format(instant);
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/** Entries in one shared-store file, counted by delimiter only. Null when the
|
|
73
|
+
* folder or file is a link or cannot be read.
|
|
74
|
+
*/
|
|
75
|
+
export function countSharedMemoryEntries(memoriesDir, file) {
|
|
76
|
+
try {
|
|
77
|
+
const dir = fs.lstatSync(memoriesDir, { throwIfNoEntry: false });
|
|
78
|
+
if (!dir)
|
|
79
|
+
return 0;
|
|
80
|
+
if (dir.isSymbolicLink() || !dir.isDirectory())
|
|
81
|
+
return null;
|
|
82
|
+
const bytes = readOptionalFile(path.join(memoriesDir, file), `memories/${file}`);
|
|
83
|
+
return bytes ? bytes.toString("utf8").split(MEMORY_DELIMITER).filter((part) => part.trim()).length : 0;
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/** A port of the runtime's `_read_skill_name` (tools/skills_sync.py), which
|
|
90
|
+
* names skills for `.bundled_manifest`; not the shared frontmatter splitter,
|
|
91
|
+
* whose stricter fences would name some bundled skills differently.
|
|
92
|
+
*/
|
|
93
|
+
function skillFrontmatterName(skillMd, fallback) {
|
|
94
|
+
let inFrontmatter = false;
|
|
95
|
+
for (const line of skillMd.slice(0, 4000).split("\n")) {
|
|
96
|
+
const stripped = line.trim();
|
|
97
|
+
if (stripped === "---") {
|
|
98
|
+
if (inFrontmatter)
|
|
99
|
+
break;
|
|
100
|
+
inFrontmatter = true;
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
if (inFrontmatter && stripped.startsWith("name:")) {
|
|
104
|
+
const value = stripped.slice(5).trim().replace(/^["']+|["']+$/g, "");
|
|
105
|
+
if (value)
|
|
106
|
+
return value;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return fallback;
|
|
110
|
+
}
|
|
111
|
+
function bundledSkillNames(skillsDir) {
|
|
112
|
+
const bytes = readOptionalFile(path.join(skillsDir, ".bundled_manifest"), "skills/.bundled_manifest");
|
|
113
|
+
const names = new Set();
|
|
114
|
+
for (const line of bytes?.toString("utf8").split("\n") ?? []) {
|
|
115
|
+
const name = line.split(":")[0].trim();
|
|
116
|
+
if (name)
|
|
117
|
+
names.add(name);
|
|
118
|
+
}
|
|
119
|
+
return names;
|
|
120
|
+
}
|
|
121
|
+
function hubSkills(skillsDir) {
|
|
122
|
+
const found = { names: new Set(), paths: new Set() };
|
|
123
|
+
if (!plainDirectoryExists(path.join(skillsDir, ".hub"), "The installed-skills folder"))
|
|
124
|
+
return found;
|
|
125
|
+
const bytes = readOptionalFile(path.join(skillsDir, ".hub", "lock.json"), "skills/.hub/lock.json");
|
|
126
|
+
if (!bytes)
|
|
127
|
+
return found;
|
|
128
|
+
let installed;
|
|
129
|
+
try {
|
|
130
|
+
installed = JSON.parse(bytes.toString("utf8")).installed;
|
|
131
|
+
}
|
|
132
|
+
catch {
|
|
133
|
+
return found;
|
|
134
|
+
}
|
|
135
|
+
if (!installed || typeof installed !== "object")
|
|
136
|
+
return found;
|
|
137
|
+
for (const [name, entry] of Object.entries(installed)) {
|
|
138
|
+
found.names.add(name);
|
|
139
|
+
const installPath = entry && typeof entry === "object" ? entry.install_path : undefined;
|
|
140
|
+
if (typeof installPath === "string")
|
|
141
|
+
found.paths.add(installPath.replace(/\/+$/, ""));
|
|
142
|
+
}
|
|
143
|
+
return found;
|
|
144
|
+
}
|
|
145
|
+
/** Relative directories under `skills/` that hold a skill the bot made itself:
|
|
146
|
+
* not shipped with the runtime and not installed from the hub. Without the
|
|
147
|
+
* runtime's bundled list no skill can be told apart, so none is returned.
|
|
148
|
+
*/
|
|
149
|
+
export function learnedSkillDirs(skillsDir) {
|
|
150
|
+
if (!plainDirectoryExists(skillsDir, "The bot's skills folder"))
|
|
151
|
+
return { dirs: [], bundledManifestMissing: false };
|
|
152
|
+
const bundled = bundledSkillNames(skillsDir);
|
|
153
|
+
const hub = hubSkills(skillsDir);
|
|
154
|
+
const learned = [];
|
|
155
|
+
let anySkill = false;
|
|
156
|
+
const walk = (rel, depth) => {
|
|
157
|
+
for (const entry of fs.readdirSync(path.join(skillsDir, rel)).sort()) {
|
|
158
|
+
if (entry.startsWith("."))
|
|
159
|
+
continue;
|
|
160
|
+
const child = rel ? `${rel}/${entry}` : entry;
|
|
161
|
+
const absolute = path.join(skillsDir, child);
|
|
162
|
+
const st = fs.lstatSync(absolute);
|
|
163
|
+
if (st.isSymbolicLink() || !st.isDirectory())
|
|
164
|
+
continue;
|
|
165
|
+
const skillMd = fs.lstatSync(path.join(absolute, "SKILL.md"), { throwIfNoEntry: false });
|
|
166
|
+
if (!skillMd) {
|
|
167
|
+
if (depth < MAX_SKILL_DEPTH)
|
|
168
|
+
walk(child, depth + 1);
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
anySkill = true;
|
|
172
|
+
if (!bundled.size)
|
|
173
|
+
continue;
|
|
174
|
+
if (bundled.has(entry) || hub.names.has(entry) || hub.paths.has(child))
|
|
175
|
+
continue;
|
|
176
|
+
const name = skillFrontmatterName(readStableFile(path.join(absolute, "SKILL.md"), `skills/${child}/SKILL.md`, skillMd).bytes.toString("utf8"), entry);
|
|
177
|
+
if (bundled.has(name) || hub.names.has(name))
|
|
178
|
+
continue;
|
|
179
|
+
learned.push(child);
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
walk("", 1);
|
|
183
|
+
return bundled.size ? { dirs: learned, bundledManifestMissing: false } : { dirs: [], bundledManifestMissing: anySkill };
|
|
184
|
+
}
|
|
185
|
+
/** Null when a path in the skill is one the cloud importer refuses as private,
|
|
186
|
+
* or a hidden env file: the skill stays rather than failing the promotion.
|
|
187
|
+
*/
|
|
188
|
+
/** The manifest and the jobs file take two of a transfer's files. */
|
|
189
|
+
const SKILL_FILE_BUDGET = MAX_TRANSFER_FILES - 2;
|
|
190
|
+
/** Stats only, nothing is read. Counts the skill's files against one
|
|
191
|
+
* transfer's budget and stops walking once the file count is past it.
|
|
192
|
+
*/
|
|
193
|
+
function listSkillFiles(skillsDir, skill, budget) {
|
|
194
|
+
if (skill.split("/").some((part) => PRIVATE_NAME.test(part)))
|
|
195
|
+
return { skipped: SKILL_MAY_HOLD_SECRET };
|
|
196
|
+
const entries = [];
|
|
197
|
+
let unsafe = false;
|
|
198
|
+
let tooLarge = false;
|
|
199
|
+
let bytes = 0;
|
|
200
|
+
const walk = (rel) => {
|
|
201
|
+
for (const entry of fs.readdirSync(path.join(skillsDir, rel)).sort()) {
|
|
202
|
+
if (unsafe || budget.files + entries.length > SKILL_FILE_BUDGET)
|
|
203
|
+
return;
|
|
204
|
+
if (entry.startsWith(".")) {
|
|
205
|
+
if (SECRET_FILE_NAME.test(entry))
|
|
206
|
+
unsafe = true;
|
|
207
|
+
continue;
|
|
208
|
+
}
|
|
209
|
+
if (PRIVATE_NAME.test(entry)) {
|
|
210
|
+
unsafe = true;
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
const child = `${rel}/${entry}`;
|
|
214
|
+
const absolute = path.join(skillsDir, child);
|
|
215
|
+
const st = fs.lstatSync(absolute);
|
|
216
|
+
if (st.isSymbolicLink())
|
|
217
|
+
refuse(`the learned skill ${skill} contains a link (skills/${child}), which cannot be moved; replace it with a real file or remove the skill, then retry`);
|
|
218
|
+
if (st.isDirectory()) {
|
|
219
|
+
walk(child);
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
if (st.isFile() && st.size > MAX_SKILL_FILE_BYTES) {
|
|
223
|
+
tooLarge = true;
|
|
224
|
+
continue;
|
|
225
|
+
}
|
|
226
|
+
entries.push({ child, absolute, st });
|
|
227
|
+
bytes += st.size;
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
walk(skill);
|
|
231
|
+
if (unsafe)
|
|
232
|
+
return { skipped: SKILL_MAY_HOLD_SECRET };
|
|
233
|
+
if (tooLarge)
|
|
234
|
+
return { skipped: SKILL_FILE_TOO_LARGE };
|
|
235
|
+
budget.files += entries.length;
|
|
236
|
+
budget.bytes += bytes;
|
|
237
|
+
budget.weight.set(skill, { files: entries.length, bytes });
|
|
238
|
+
return entries;
|
|
239
|
+
}
|
|
240
|
+
function overBudget(budget) {
|
|
241
|
+
const byBytes = budget.files <= SKILL_FILE_BUDGET;
|
|
242
|
+
const limit = byBytes ? `${MAX_TRANSFER_BYTES / (1024 * 1024)} MiB` : `${MAX_TRANSFER_FILES}-file`;
|
|
243
|
+
const skills = [...budget.weight]
|
|
244
|
+
.sort((a, b) => (byBytes ? b[1].bytes - a[1].bytes : b[1].files - a[1].files) || a[0].localeCompare(b[0]))
|
|
245
|
+
.map(([skill]) => (skillNameMayHoldSecret(skill) ? WITHHELD_SKILL_NAME : skill));
|
|
246
|
+
throw new FleetStateLimitError(`the bot's learned skills and scheduled jobs exceed the ${limit} transfer limit; nothing was truncated`, skills);
|
|
247
|
+
}
|
|
248
|
+
/** True when some line is longer than `limit` characters. */
|
|
249
|
+
function hasLongLine(text, limit) {
|
|
250
|
+
for (let start = 0;;) {
|
|
251
|
+
const end = text.indexOf("\n", start);
|
|
252
|
+
if ((end < 0 ? text.length : end) - start > limit)
|
|
253
|
+
return true;
|
|
254
|
+
if (end < 0)
|
|
255
|
+
return false;
|
|
256
|
+
start = end + 1;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
/** True when the HQ secret scanner finds a credential in the text, or when a
|
|
260
|
+
* line is too long to scan in reasonable time. Allow markers do not count:
|
|
261
|
+
* carried state is not code under review. The scanner skips some file types
|
|
262
|
+
* by name, so those are scanned as plain text. Long text is scanned in
|
|
263
|
+
* overlapping windows of whole lines, so each rule only runs where its
|
|
264
|
+
* keyword appears.
|
|
265
|
+
*/
|
|
266
|
+
export function textMayHoldSecret(text, file = "notes.txt") {
|
|
267
|
+
if (hasLongLine(text, MAX_SCANNED_LINE))
|
|
268
|
+
return true;
|
|
269
|
+
const name = pathIgnored(file) ? `${file}.txt` : file;
|
|
270
|
+
const plain = ALLOW_MARKERS.reduce((current, marker) => current.split(marker).join(" ".repeat(marker.length)), text);
|
|
271
|
+
for (let start = 0; start < plain.length;) {
|
|
272
|
+
let end = plain.length;
|
|
273
|
+
if (start + SCAN_WINDOW < plain.length) {
|
|
274
|
+
end = plain.lastIndexOf("\n", start + SCAN_WINDOW);
|
|
275
|
+
if (end <= start)
|
|
276
|
+
end = plain.indexOf("\n", start + SCAN_WINDOW);
|
|
277
|
+
if (end < 0)
|
|
278
|
+
end = plain.length;
|
|
279
|
+
}
|
|
280
|
+
if (scanFragment({ file: name, text: plain.slice(start, end), startLine: 1 }).length)
|
|
281
|
+
return true;
|
|
282
|
+
if (end >= plain.length)
|
|
283
|
+
return false;
|
|
284
|
+
const next = plain.lastIndexOf("\n", end - SCAN_OVERLAP) + 1;
|
|
285
|
+
start = next > start ? next : end + 1;
|
|
286
|
+
}
|
|
287
|
+
return false;
|
|
288
|
+
}
|
|
289
|
+
function skillNameMayHoldSecret(skill) {
|
|
290
|
+
return textMayHoldSecret(skill) || scanPath(`${FLEET_STATE_DIR}/skills/${skill}`).length > 0;
|
|
291
|
+
}
|
|
292
|
+
/** True when a file's name, relative path or text looks like a credential. */
|
|
293
|
+
export function mayHoldSecret(file) {
|
|
294
|
+
const name = path.posix.basename(file.path);
|
|
295
|
+
if (SECRET_FILE_NAME.test(name) || SECRET_FILE_EXTENSION.test(name) || SSH_KEY_FILE.test(name) || scanPath(file.path).length)
|
|
296
|
+
return true;
|
|
297
|
+
if (textMayHoldSecret(file.path))
|
|
298
|
+
return true;
|
|
299
|
+
return textMayHoldSecret(file.bytes.toString("utf8"), file.path);
|
|
300
|
+
}
|
|
301
|
+
function insideRoot(root, candidate) {
|
|
302
|
+
const relative = path.relative(path.resolve(root), path.resolve(candidate));
|
|
303
|
+
return relative === "" || (!relative.startsWith("..") && !path.isAbsolute(relative));
|
|
304
|
+
}
|
|
305
|
+
const text = (value) => typeof value === "string" && value.trim() !== "";
|
|
306
|
+
/** Split a profile's job list into jobs that can run on the cloud computer and
|
|
307
|
+
* jobs tied to this one. Carried jobs keep only their portable fields.
|
|
308
|
+
*/
|
|
309
|
+
export function selectPortableJobs(records, input) {
|
|
310
|
+
const jobs = [];
|
|
311
|
+
const skipped = [];
|
|
312
|
+
const cache = input.scanCache ?? new Map();
|
|
313
|
+
const scan = (value) => {
|
|
314
|
+
const key = `text\0${createHash("sha256").update(value).digest("hex")}`;
|
|
315
|
+
let flagged = cache.get(key);
|
|
316
|
+
if (flagged === undefined) {
|
|
317
|
+
flagged = textMayHoldSecret(value);
|
|
318
|
+
cache.set(key, flagged);
|
|
319
|
+
}
|
|
320
|
+
return flagged;
|
|
321
|
+
};
|
|
322
|
+
for (const record of records) {
|
|
323
|
+
const job = (record && typeof record === "object" && !Array.isArray(record) ? record : {});
|
|
324
|
+
const rawId = text(job.id) && INSTALLER_JOB_ID.test(job.id) ? job.id : "";
|
|
325
|
+
// A skipped job's id and name still reach the manifest, so each is written only when it scans clean.
|
|
326
|
+
const id = rawId && !scan(rawId) ? rawId : "";
|
|
327
|
+
const name = text(job.name) && !scan(job.name) ? job.name : "";
|
|
328
|
+
const skip = (reason) => { skipped.push({ id, name, reason }); };
|
|
329
|
+
const schedule = (job.schedule && typeof job.schedule === "object" ? job.schedule : {});
|
|
330
|
+
const origin = (job.origin && typeof job.origin === "object" ? job.origin : {});
|
|
331
|
+
const kind = schedule.kind;
|
|
332
|
+
const portableSchedule = { kind };
|
|
333
|
+
const zone = schedule.timezone != null && schedule.timezone !== "" ? validTimeZone(schedule.timezone) : input.timeZone ?? null;
|
|
334
|
+
const runAt = kind === "once" && text(schedule.run_at) ? runAtInstant(schedule.run_at, zone) : null;
|
|
335
|
+
if (kind === "cron" && text(schedule.expr) && !/[\r\n]/.test(schedule.expr))
|
|
336
|
+
portableSchedule.expr = schedule.expr;
|
|
337
|
+
else if (kind === "interval" && typeof schedule.minutes === "number" && Number.isInteger(schedule.minutes) && schedule.minutes >= 1 && schedule.minutes <= MAX_INTERVAL_MINUTES)
|
|
338
|
+
portableSchedule.minutes = schedule.minutes;
|
|
339
|
+
else if (kind === "once" && runAt !== null)
|
|
340
|
+
portableSchedule.run_at = schedule.run_at;
|
|
341
|
+
else {
|
|
342
|
+
skip("its schedule could not be read");
|
|
343
|
+
continue;
|
|
344
|
+
}
|
|
345
|
+
if (!rawId) {
|
|
346
|
+
skip("its record could not be read");
|
|
347
|
+
continue;
|
|
348
|
+
}
|
|
349
|
+
if (schedule.timezone != null && schedule.timezone !== "" && !validTimeZone(schedule.timezone)) {
|
|
350
|
+
skip("its time zone could not be read");
|
|
351
|
+
continue;
|
|
352
|
+
}
|
|
353
|
+
const repeat = (job.repeat && typeof job.repeat === "object" ? job.repeat : {});
|
|
354
|
+
if (repeat.times != null && !Number.isInteger(repeat.times)) {
|
|
355
|
+
skip("its repeat count could not be read");
|
|
356
|
+
continue;
|
|
357
|
+
}
|
|
358
|
+
const times = typeof repeat.times === "number" ? repeat.times : null;
|
|
359
|
+
const completed = Number.isInteger(repeat.completed) ? repeat.completed : 0;
|
|
360
|
+
if (times !== null && completed >= times) {
|
|
361
|
+
skip("has already run as many times as it was set to");
|
|
362
|
+
continue;
|
|
363
|
+
}
|
|
364
|
+
if (text(job.script) || text(job.monitor_script) || job.no_agent === true) {
|
|
365
|
+
skip("runs a script on the original computer");
|
|
366
|
+
continue;
|
|
367
|
+
}
|
|
368
|
+
if (text(job.monitor_url)) {
|
|
369
|
+
skip("watches a web address, which is not moved");
|
|
370
|
+
continue;
|
|
371
|
+
}
|
|
372
|
+
if (text(job.workdir) && !insideRoot(input.hqRoot, job.workdir)) {
|
|
373
|
+
skip("works in a folder outside HQ on the original computer");
|
|
374
|
+
continue;
|
|
375
|
+
}
|
|
376
|
+
if (kind === "once" && !(runAt > input.now.getTime())) {
|
|
377
|
+
skip("was a one-time job whose time has passed");
|
|
378
|
+
continue;
|
|
379
|
+
}
|
|
380
|
+
if ((job.deliver ?? "origin") !== "origin" || origin.platform !== "hqdm" || !text(origin.chat_id)) {
|
|
381
|
+
skip("does not report to an HQ direct message");
|
|
382
|
+
continue;
|
|
383
|
+
}
|
|
384
|
+
if (origin.chat_id !== input.ownerUid || (origin.user_id != null && origin.user_id !== input.ownerUid)) {
|
|
385
|
+
skip("reports to someone other than the bot's owner");
|
|
386
|
+
continue;
|
|
387
|
+
}
|
|
388
|
+
if (Array.isArray(job.enabled_toolsets) && job.enabled_toolsets.length) {
|
|
389
|
+
skip("is limited to certain tools, which the cloud copy cannot keep yet");
|
|
390
|
+
continue;
|
|
391
|
+
}
|
|
392
|
+
if (typeof job.prompt === "string" && scan(job.prompt)) {
|
|
393
|
+
skip("its instructions may contain a secret");
|
|
394
|
+
continue;
|
|
395
|
+
}
|
|
396
|
+
if (text(schedule.display))
|
|
397
|
+
portableSchedule.display = schedule.display;
|
|
398
|
+
if (text(schedule.timezone))
|
|
399
|
+
portableSchedule.timezone = validTimeZone(schedule.timezone);
|
|
400
|
+
const carried = {
|
|
401
|
+
id: rawId,
|
|
402
|
+
name: text(job.name) ? job.name : "",
|
|
403
|
+
prompt: typeof job.prompt === "string" ? job.prompt : "",
|
|
404
|
+
schedule: portableSchedule,
|
|
405
|
+
repeat: { times, completed },
|
|
406
|
+
enabled: job.enabled !== false,
|
|
407
|
+
state: job.state === "paused" ? "paused" : "scheduled",
|
|
408
|
+
deliver: "origin",
|
|
409
|
+
origin: { platform: "hqdm", chat_id: input.ownerUid, ...(origin.user_id != null ? { user_id: input.ownerUid } : {}) },
|
|
410
|
+
skills: Array.isArray(job.skills) ? job.skills.filter(text) : [],
|
|
411
|
+
};
|
|
412
|
+
if (stringsOf({ ...carried, prompt: "" }).some(scan)) {
|
|
413
|
+
skip("its details may contain a secret");
|
|
414
|
+
continue;
|
|
415
|
+
}
|
|
416
|
+
if (jobs.length >= MAX_CARRIED_JOBS) {
|
|
417
|
+
skip(`is past the ${MAX_CARRIED_JOBS}-job limit for one move`);
|
|
418
|
+
continue;
|
|
419
|
+
}
|
|
420
|
+
jobs.push(carried);
|
|
421
|
+
}
|
|
422
|
+
return { jobs, skipped };
|
|
423
|
+
}
|
|
424
|
+
function stringsOf(value) {
|
|
425
|
+
if (typeof value === "string")
|
|
426
|
+
return [value];
|
|
427
|
+
if (Array.isArray(value))
|
|
428
|
+
return value.flatMap(stringsOf);
|
|
429
|
+
return value && typeof value === "object" ? Object.values(value).flatMap(stringsOf) : [];
|
|
430
|
+
}
|
|
431
|
+
/** The instant the box will run a one-time job at, or null when the box could
|
|
432
|
+
* not read the time. A time without an offset is wall time in `zone` (UTC when
|
|
433
|
+
* there is none).
|
|
434
|
+
*/
|
|
435
|
+
function runAtInstant(value, zone) {
|
|
436
|
+
const match = RUN_AT.exec(value.trim());
|
|
437
|
+
if (!match)
|
|
438
|
+
return null;
|
|
439
|
+
const [year, month, day, hour = 0, minute = 0, second = 0] = match.slice(1, 7).map((part) => Number(part ?? 0));
|
|
440
|
+
const offset = match[7];
|
|
441
|
+
const wall = Date.UTC(year, month - 1, day, hour, minute, second);
|
|
442
|
+
const check = new Date(wall);
|
|
443
|
+
if (year < 1 || check.getUTCMonth() !== month - 1 || check.getUTCDate() !== day || hour > 23 || minute > 59 || second > 59)
|
|
444
|
+
return null;
|
|
445
|
+
if (offset === "Z")
|
|
446
|
+
return wall;
|
|
447
|
+
if (offset) {
|
|
448
|
+
const [h, m] = offset.slice(1).split(":").map(Number);
|
|
449
|
+
if (h > 23 || m > 59)
|
|
450
|
+
return null;
|
|
451
|
+
return wall - (offset[0] === "-" ? -1 : 1) * (h * 60 + m) * 60_000;
|
|
452
|
+
}
|
|
453
|
+
if (!zone)
|
|
454
|
+
return wall;
|
|
455
|
+
const guess = wall - zoneOffsetMs(wall, zone);
|
|
456
|
+
return wall - zoneOffsetMs(guess, zone);
|
|
457
|
+
}
|
|
458
|
+
function zoneOffsetMs(instant, timeZone) {
|
|
459
|
+
const parts = new Intl.DateTimeFormat("en-US", {
|
|
460
|
+
timeZone, hourCycle: "h23", year: "numeric", month: "2-digit", day: "2-digit", hour: "2-digit", minute: "2-digit", second: "2-digit",
|
|
461
|
+
}).formatToParts(new Date(instant));
|
|
462
|
+
const part = (type) => Number(parts.find((entry) => entry.type === type).value);
|
|
463
|
+
return Date.UTC(part("year"), part("month") - 1, part("day"), part("hour"), part("minute"), part("second")) - Math.floor(instant / 1000) * 1000;
|
|
464
|
+
}
|
|
465
|
+
/** A zone both `Intl` and the box installer accept, or null. */
|
|
466
|
+
function validTimeZone(value) {
|
|
467
|
+
if (!text(value))
|
|
468
|
+
return null;
|
|
469
|
+
const zone = value.trim();
|
|
470
|
+
return INSTALLER_ZONE.test(zone) && zoneDate(new Date(0), zone) ? zone : null;
|
|
471
|
+
}
|
|
472
|
+
function profileSettings(config, profileDir, machineTimeZone, brain) {
|
|
473
|
+
let provider = null;
|
|
474
|
+
let model = text(config.model) ? config.model : null;
|
|
475
|
+
let timezone = null;
|
|
476
|
+
if (profileDir) {
|
|
477
|
+
try {
|
|
478
|
+
const raw = readOptionalFile(path.join(profileDir, "profile.json"), "profile.json");
|
|
479
|
+
const record = raw ? JSON.parse(raw.toString("utf8")).provider : undefined;
|
|
480
|
+
if (text(record?.id))
|
|
481
|
+
provider = record.id;
|
|
482
|
+
if (text(record?.model))
|
|
483
|
+
model = record.model;
|
|
484
|
+
}
|
|
485
|
+
catch { /* settings stay unknown */ }
|
|
486
|
+
try {
|
|
487
|
+
const raw = readOptionalFile(path.join(profileDir, "config.yaml"), "config.yaml");
|
|
488
|
+
const parsed = raw ? yaml.load(raw.toString("utf8")) : null;
|
|
489
|
+
if (parsed && typeof parsed === "object")
|
|
490
|
+
timezone = validTimeZone(parsed.timezone);
|
|
491
|
+
}
|
|
492
|
+
catch { /* fall back to the computer's zone */ }
|
|
493
|
+
}
|
|
494
|
+
timezone ??= validTimeZone(machineTimeZone ?? Intl.DateTimeFormat().resolvedOptions().timeZone);
|
|
495
|
+
if (brain)
|
|
496
|
+
model = text(brain.model) ? brain.model : null;
|
|
497
|
+
// Settings reach the manifest as written, so a value that looks like a credential is dropped.
|
|
498
|
+
const clean = (value) => (value !== null && !textMayHoldSecret(value) ? value : null);
|
|
499
|
+
const effort = brain ? brain.effort : config.effort;
|
|
500
|
+
return { runtime: brain ? brain.runtime : config.runtime ?? null, provider: clean(provider), model: clean(model), effort: text(effort) ? effort : null, timezone };
|
|
501
|
+
}
|
|
502
|
+
/** Null for a bot that does not run on the HQ Fleet Runtime: it has no profile. */
|
|
503
|
+
export function collectFleetState(config, stateDir, deps = {}) {
|
|
504
|
+
if (config.engine?.id !== HQ_FLEET_RUNTIME_ENGINE_ID)
|
|
505
|
+
return null;
|
|
506
|
+
const root = deps.fleetHome ?? fleetHome();
|
|
507
|
+
const now = (deps.now ?? (() => new Date()))();
|
|
508
|
+
const candidate = fleetLocalProfileDir(config.agentUid, { fleetHome: root });
|
|
509
|
+
const profileDir = plainDirectoryExists(candidate, "The bot's HQ Fleet profile") ? candidate : null;
|
|
510
|
+
const settings = profileSettings(config, profileDir, deps.machineTimeZone, deps.brain);
|
|
511
|
+
const files = [];
|
|
512
|
+
const botName = path.basename(fs.realpathSync(stateDir));
|
|
513
|
+
const memoriesDir = path.join(root, "memories");
|
|
514
|
+
const staying = (file) => ({
|
|
515
|
+
entries: 0, anyStayed: countSharedMemoryEntries(memoriesDir, file) !== 0, skippedOtherBots: 0, skippedUntagged: 0, skippedOlderThanBot: 0,
|
|
516
|
+
});
|
|
517
|
+
const memory = staying("MEMORY.md");
|
|
518
|
+
const user = staying("USER.md");
|
|
519
|
+
const skillsDir = profileDir ? path.join(profileDir, "skills") : null;
|
|
520
|
+
const learned = skillsDir ? learnedSkillDirs(skillsDir) : { dirs: [], bundledManifestMissing: false };
|
|
521
|
+
const skills = [];
|
|
522
|
+
const skippedSkills = [];
|
|
523
|
+
const budget = { files: 0, bytes: 0, weight: new Map() };
|
|
524
|
+
const listed = learned.dirs.map((skill) => ({ skill, entries: listSkillFiles(skillsDir, skill, budget) }));
|
|
525
|
+
if (budget.files > SKILL_FILE_BUDGET || budget.bytes > MAX_TRANSFER_BYTES)
|
|
526
|
+
overBudget(budget);
|
|
527
|
+
const scanCache = deps.scanCache ?? new Map();
|
|
528
|
+
for (const { skill, entries } of listed) {
|
|
529
|
+
// A skill's folder name reaches the manifest either way, so a name that looks like a credential is never written.
|
|
530
|
+
if (skillNameMayHoldSecret(skill)) {
|
|
531
|
+
skippedSkills.push({ skill: WITHHELD_SKILL_NAME, reason: SKILL_MAY_HOLD_SECRET });
|
|
532
|
+
continue;
|
|
533
|
+
}
|
|
534
|
+
if (!Array.isArray(entries)) {
|
|
535
|
+
skippedSkills.push({ skill, reason: entries.skipped });
|
|
536
|
+
continue;
|
|
537
|
+
}
|
|
538
|
+
if (skills.length >= MAX_CARRIED_SKILLS) {
|
|
539
|
+
skippedSkills.push({ skill, reason: SKILL_PAST_LIMIT });
|
|
540
|
+
continue;
|
|
541
|
+
}
|
|
542
|
+
const own = [];
|
|
543
|
+
let secret = false;
|
|
544
|
+
for (const { child, absolute, st } of entries) {
|
|
545
|
+
const read = readStableFile(absolute, `skills/${child}`, st);
|
|
546
|
+
const file = { path: `${FLEET_STATE_DIR}/skills/${child}`, bytes: read.bytes, executable: read.executable };
|
|
547
|
+
const key = `${absolute}\0${st.size}\0${st.mtimeMs}`;
|
|
548
|
+
let flagged = scanCache.get(key);
|
|
549
|
+
if (flagged === undefined) {
|
|
550
|
+
flagged = mayHoldSecret(file);
|
|
551
|
+
scanCache.set(key, flagged);
|
|
552
|
+
}
|
|
553
|
+
if (flagged) {
|
|
554
|
+
secret = true;
|
|
555
|
+
break;
|
|
556
|
+
}
|
|
557
|
+
own.push(file);
|
|
558
|
+
}
|
|
559
|
+
if (secret) {
|
|
560
|
+
skippedSkills.push({ skill, reason: SKILL_MAY_HOLD_SECRET });
|
|
561
|
+
continue;
|
|
562
|
+
}
|
|
563
|
+
skills.push(skill);
|
|
564
|
+
files.push(...own);
|
|
565
|
+
}
|
|
566
|
+
let records = [];
|
|
567
|
+
if (profileDir && plainDirectoryExists(path.join(profileDir, "cron"), "The bot's jobs folder")) {
|
|
568
|
+
const readJobs = () => readOptionalFile(path.join(profileDir, "cron", "jobs.json"), "cron/jobs.json");
|
|
569
|
+
let bytes;
|
|
570
|
+
// The running bot may rewrite its jobs file mid-read; one retry covers that.
|
|
571
|
+
try {
|
|
572
|
+
bytes = readJobs();
|
|
573
|
+
}
|
|
574
|
+
catch (error) {
|
|
575
|
+
if (!(error instanceof Error && error.message.includes("file changed while reading")))
|
|
576
|
+
throw error;
|
|
577
|
+
bytes = readJobs();
|
|
578
|
+
}
|
|
579
|
+
if (bytes) {
|
|
580
|
+
let parsed;
|
|
581
|
+
try {
|
|
582
|
+
parsed = JSON.parse(bytes.toString("utf8"));
|
|
583
|
+
}
|
|
584
|
+
catch {
|
|
585
|
+
refuse("the bot's scheduled jobs file could not be read; nothing was moved");
|
|
586
|
+
}
|
|
587
|
+
const list = Array.isArray(parsed) ? parsed : parsed?.jobs;
|
|
588
|
+
if (Array.isArray(list))
|
|
589
|
+
records = list;
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
const selected = selectPortableJobs(records, { hqRoot: config.hqRoot, ownerUid: config.ownerUid, now, timeZone: settings.timezone, scanCache });
|
|
593
|
+
if (selected.jobs.length) {
|
|
594
|
+
files.push({
|
|
595
|
+
path: `${FLEET_STATE_DIR}/cron/jobs.json`,
|
|
596
|
+
bytes: Buffer.from(`${JSON.stringify({ schemaVersion: 1, timezone: settings.timezone, jobs: selected.jobs }, null, 2)}\n`),
|
|
597
|
+
executable: false,
|
|
598
|
+
});
|
|
599
|
+
}
|
|
600
|
+
const manifest = {
|
|
601
|
+
schemaVersion: 1,
|
|
602
|
+
agentUid: config.agentUid,
|
|
603
|
+
botName,
|
|
604
|
+
exportedAt: now.toISOString(),
|
|
605
|
+
memory,
|
|
606
|
+
user,
|
|
607
|
+
skills,
|
|
608
|
+
skippedSkills,
|
|
609
|
+
...(learned.bundledManifestMissing ? { skillsNotCarried: { reason: BUNDLED_MANIFEST_MISSING } } : {}),
|
|
610
|
+
jobs: { ...(selected.jobs.length ? { file: "cron/jobs.json" } : {}), count: selected.jobs.length, skipped: selected.skipped },
|
|
611
|
+
settings,
|
|
612
|
+
};
|
|
613
|
+
files.unshift({ path: `${FLEET_STATE_DIR}/manifest.json`, bytes: Buffer.from(`${JSON.stringify(manifest, null, 2)}\n`), executable: false });
|
|
614
|
+
return { manifest, files };
|
|
615
|
+
}
|
|
616
|
+
/** The manifest a frozen snapshot carries; null for one frozen by an older CLI. */
|
|
617
|
+
export function fleetStateManifestOf(bundle) {
|
|
618
|
+
const file = bundle.files.find((entry) => entry.area === "memory" && entry.path === `${FLEET_STATE_DIR}/manifest.json`);
|
|
619
|
+
if (!file)
|
|
620
|
+
return null;
|
|
621
|
+
try {
|
|
622
|
+
const manifest = JSON.parse(Buffer.from(file.base64, "base64").toString("utf8"));
|
|
623
|
+
return manifest?.schemaVersion === 1 && manifest.agentUid === bundle.agentUid && manifest.memory && manifest.user && Array.isArray(manifest.skills) && manifest.jobs ? manifest : null;
|
|
624
|
+
}
|
|
625
|
+
catch {
|
|
626
|
+
return null;
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
const count = (n, one, many) => `${n} ${n === 1 ? one : many}`;
|
|
630
|
+
/** Plain lines for `hq bot promote`: what moves, what stays, and the model note. */
|
|
631
|
+
export function describeFleetState(manifest) {
|
|
632
|
+
const moving = [];
|
|
633
|
+
if (manifest.skills.length)
|
|
634
|
+
moving.push(`${count(manifest.skills.length, "learned skill", "learned skills")} (${manifest.skills.join(", ")})`);
|
|
635
|
+
if (manifest.jobs.count)
|
|
636
|
+
moving.push(count(manifest.jobs.count, "scheduled job", "scheduled jobs"));
|
|
637
|
+
const lines = [moving.length
|
|
638
|
+
? `Moving with the bot: ${moving.join(", ")}.`
|
|
639
|
+
: "Moving with the bot: its identity and saved files. It has no learned skills or scheduled jobs of its own to move."];
|
|
640
|
+
if (manifest.memory.anyStayed !== false || manifest.user.anyStayed !== false)
|
|
641
|
+
lines.push("Memory notes in this computer's shared memory store stay on this computer.");
|
|
642
|
+
const staying = [];
|
|
643
|
+
if (manifest.skillsNotCarried)
|
|
644
|
+
staying.push("its learned skills, because the runtime's list of bundled skills is missing and they cannot be told apart");
|
|
645
|
+
const secret = (manifest.skippedSkills ?? []).filter((skill) => skill.reason === SKILL_MAY_HOLD_SECRET).map((skill) => skill.skill);
|
|
646
|
+
if (secret.length)
|
|
647
|
+
staying.push(`${count(secret.length, "learned skill that", "learned skills that")} may contain a secret (${secret.join(", ")})`);
|
|
648
|
+
const large = (manifest.skippedSkills ?? []).filter((skill) => skill.reason === SKILL_FILE_TOO_LARGE).map((skill) => skill.skill);
|
|
649
|
+
if (large.length)
|
|
650
|
+
staying.push(`${count(large.length, "learned skill that has", "learned skills that each have")} a file over 4 MiB, more than the cloud computer accepts (${large.join(", ")})`);
|
|
651
|
+
const pastLimit = (manifest.skippedSkills ?? []).filter((skill) => skill.reason === SKILL_PAST_LIMIT).length;
|
|
652
|
+
if (pastLimit)
|
|
653
|
+
staying.push(`${count(pastLimit, "learned skill that is", "learned skills that are")} past the ${MAX_CARRIED_SKILLS}-skill limit for one move`);
|
|
654
|
+
const reasons = new Map();
|
|
655
|
+
for (const job of manifest.jobs.skipped)
|
|
656
|
+
reasons.set(job.reason, (reasons.get(job.reason) ?? 0) + 1);
|
|
657
|
+
for (const [reason, n] of reasons) {
|
|
658
|
+
staying.push(reason.startsWith("its ")
|
|
659
|
+
? `${count(n, "scheduled job whose", "scheduled jobs whose")} ${reason.slice(4)}`
|
|
660
|
+
: `${count(n, "scheduled job that", "scheduled jobs that each")} ${reason}`);
|
|
661
|
+
}
|
|
662
|
+
if (staying.length)
|
|
663
|
+
lines.push(`Staying on this computer: ${staying.join(", ")}.`);
|
|
664
|
+
if (manifest.settings.runtime && manifest.settings.runtime !== "codex") {
|
|
665
|
+
lines.push(`The cloud bot signs in with ChatGPT and uses the cloud default model${manifest.settings.model ? `, not ${manifest.settings.model}` : ""}.`);
|
|
666
|
+
}
|
|
667
|
+
return lines;
|
|
668
|
+
}
|
|
669
|
+
//# sourceMappingURL=fleet-state.js.map
|