@opticell/workflow-companion 1.6.0 → 1.6.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 +36 -5
- package/index.js +207 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -31,19 +31,32 @@ many devices are on.
|
|
|
31
31
|
1. In WorkFlow on an iPhone or iPad: **Settings → Windows Companion → Answer
|
|
32
32
|
the Companion**. On a Mac: **Settings → Agent Bridge**, then the Agent
|
|
33
33
|
Bridge and **Cloud Bridge** switches.
|
|
34
|
-
2.
|
|
34
|
+
2. Install **Node.js 18 or later** (LTS) if `node -v` doesn't show it:
|
|
35
|
+
Windows `winget install OpenJS.NodeJS.LTS -e`, Mac `brew install node`,
|
|
36
|
+
Linux your package manager, or the installer from <https://nodejs.org>.
|
|
37
|
+
Then close and reopen the terminal (and restart Claude Code) so `node` and
|
|
38
|
+
`npx` are found; otherwise you'll see "node is not recognized".
|
|
39
|
+
3. In a normal terminal window:
|
|
35
40
|
|
|
36
41
|
```sh
|
|
37
|
-
npx -y @opticell/workflow-companion setup
|
|
42
|
+
npx -y @opticell/workflow-companion@latest setup
|
|
38
43
|
```
|
|
39
44
|
|
|
40
45
|
It opens <https://companion.opticell-limited.com> to sign in with the
|
|
41
46
|
Apple Account WorkFlow uses on your iPhone or Mac, then asks you to paste the token that
|
|
42
|
-
page shows.
|
|
43
|
-
|
|
47
|
+
page shows. It asks questions, so it can't run from Claude Code's `!`
|
|
48
|
+
prompt or another non-interactive shell; there, pass `--web-token <token>`
|
|
49
|
+
and `--name <name>`.
|
|
50
|
+
4. Add it to Claude:
|
|
44
51
|
|
|
45
52
|
```sh
|
|
46
|
-
claude mcp add --scope user workflow -- npx -y @opticell/workflow-companion
|
|
53
|
+
claude mcp add --scope user workflow -- npx -y @opticell/workflow-companion@latest
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
On **Windows**, `npx` is a script, so Claude Code needs `cmd /c` in front:
|
|
57
|
+
|
|
58
|
+
```sh
|
|
59
|
+
claude mcp add --scope user workflow -- cmd /c npx -y @opticell/workflow-companion@latest
|
|
47
60
|
```
|
|
48
61
|
|
|
49
62
|
`--scope user` makes it available in every project on this computer.
|
|
@@ -113,6 +126,22 @@ npx -y @opticell/workflow-companion wake-on
|
|
|
113
126
|
found. `--skip-existing` treats what's already queued as handled.
|
|
114
127
|
- The log is `~/.workflow-companion/wake.log`. `wake-off` stops it all.
|
|
115
128
|
|
|
129
|
+
## Staying up to date
|
|
130
|
+
|
|
131
|
+
- **Claude Code** runs whatever its registration names. Register it with
|
|
132
|
+
`@latest` (setup prints the exact line) and every new session uses the
|
|
133
|
+
newest release.
|
|
134
|
+
- **The scheduled jobs** (keep-alive, waking) run a saved copy that npm never
|
|
135
|
+
touches, so they update themselves. At most every 6 hours they read npm's
|
|
136
|
+
entry for the package (`registry.npmjs.org/@opticell/workflow-companion/latest`).
|
|
137
|
+
When it's newer, they download the release, check it against npm's sha512
|
|
138
|
+
checksum and that Node can parse it, then swap it in. Turn this off with
|
|
139
|
+
`auto-update off`, and update by hand with `update`.
|
|
140
|
+
- **Its version is reported.** Every ten minutes or so while it runs, each
|
|
141
|
+
companion writes its version, computer and check-in time to your iCloud.
|
|
142
|
+
WorkFlow 5.3.2 shows them in Settings → Agent Bridge → Who's Bridged, and
|
|
143
|
+
`status` lists every companion's version.
|
|
144
|
+
|
|
116
145
|
## Commands
|
|
117
146
|
|
|
118
147
|
| | |
|
|
@@ -121,6 +150,8 @@ npx -y @opticell/workflow-companion wake-on
|
|
|
121
150
|
| `workflow-companion setup` | Signs this computer in. Takes `--web-token` to skip the prompt. |
|
|
122
151
|
| `workflow-companion status` | Which device answers, how fresh the snapshot is, any receipts that arrived late. |
|
|
123
152
|
| `workflow-companion keepalive` | Renews the sign-in. The scheduled job runs this. |
|
|
153
|
+
| `workflow-companion update` | Updates the scheduled jobs' copy to the latest release now, and shows how to keep Claude Code on `@latest`. |
|
|
154
|
+
| `workflow-companion auto-update on\|off` | Whether the scheduled jobs update themselves (on by default). |
|
|
124
155
|
| `workflow-companion wake-on` | Starts a Claude Code session on its own when work for its name arrives. See above. |
|
|
125
156
|
| `workflow-companion wake-off` | Stops that. Work waits until you ask Claude here. |
|
|
126
157
|
| `workflow-companion wake` | One check of the queue. The scheduled job runs this. |
|
package/index.js
CHANGED
|
@@ -27,7 +27,7 @@ const path = require("path");
|
|
|
27
27
|
const os = require("os");
|
|
28
28
|
|
|
29
29
|
const PROTOCOL_VERSION = "2024-11-05";
|
|
30
|
-
const SERVER_INFO = { name: "workflow", version: "1.6.
|
|
30
|
+
const SERVER_INFO = { name: "workflow", version: "1.6.1" };
|
|
31
31
|
// Who the agent is in WorkFlow: the assignee its queue follows, the @name
|
|
32
32
|
// that calls it, the signature on what it writes. On the Mac it's Claude.
|
|
33
33
|
// A companion goes by the name chosen at setup (default "Companion"), so a
|
|
@@ -1018,7 +1018,10 @@ async function handle(request) {
|
|
|
1018
1018
|
try {
|
|
1019
1019
|
// In iCloud mode every tool reads the Mac's latest snapshot first
|
|
1020
1020
|
// (task lookups need it too); workflow_state reports on its own.
|
|
1021
|
-
if (CLOUD && tool.name !== "workflow_state" && tool.name !== "workflow_ping")
|
|
1021
|
+
if (CLOUD && tool.name !== "workflow_state" && tool.name !== "workflow_ping") {
|
|
1022
|
+
await cloud.load();
|
|
1023
|
+
reportPresence().catch(() => {});
|
|
1024
|
+
}
|
|
1022
1025
|
return ok({ content: [{ type: "text", text: String(await tool.handler(args)) }], isError: false });
|
|
1023
1026
|
} catch (e) {
|
|
1024
1027
|
return ok({ content: [{ type: "text", text: `${e.message || e}` }], isError: true });
|
|
@@ -1068,11 +1071,18 @@ async function cloudStateText() {
|
|
|
1068
1071
|
try { lastKeepAlive = fs.readFileSync(KEEPALIVE_LOG, "utf8").trim().split("\n").pop(); } catch (_) {}
|
|
1069
1072
|
if (lastKeepAlive) lines.push(`keep-alive last run ${lastKeepAlive}`);
|
|
1070
1073
|
lines.push(`waking ${cfg.wakeEnabled ? `on — Claude Code starts by itself when @${AGENT.name} work arrives (log ${WAKE.log})` : "off — work waits until Claude here is asked (turn on: workflow-companion wake-on)"}`);
|
|
1074
|
+
lines.push(`version ${await versionLine()}`);
|
|
1071
1075
|
lines.push(`name ${AGENT.name} — assign tasks to "${AGENT.name}", or write @${AGENT.name} in a comment or note`);
|
|
1072
1076
|
try {
|
|
1073
1077
|
await cloud.load(true);
|
|
1074
1078
|
lines.push(`answering ${cloud.macLine()}`);
|
|
1075
1079
|
lines.push(`snapshot ${cloudSnap ? `${cloudSnap.tasks.length} tasks, ${(cloudSnap.notes || []).length} notes, generated ${local(cloudSnap.generatedAt)}` : "none yet — is the companion switched on in WorkFlow's Settings (Windows Companion on iPhone and iPad, Cloud Bridge on a Mac)?"}`);
|
|
1080
|
+
try {
|
|
1081
|
+
const ago = t => { const m = Math.round((Date.now() - t) / 60000); return m < 1 ? "just now" : m < 90 ? `${m} min ago` : m < 2880 ? `${Math.round(m / 60)} h ago` : `${Math.round(m / 1440)} days ago`; };
|
|
1082
|
+
for (const c of await companionPresence()) {
|
|
1083
|
+
lines.push(`companion ${c.name}: ${c.version ? `${c.version} on ${c.host || "?"}, checked in ${ago(c.aliveAt)}${c.waking ? ", waking on" : ""}` : "hasn't reported a version (older than 1.6.1)"}`);
|
|
1084
|
+
}
|
|
1085
|
+
} catch (_) { /* presence is a nicety */ }
|
|
1076
1086
|
const clash = cloudSnap ? nameClash(AGENT.name) : null;
|
|
1077
1087
|
if (clash) lines.push(`WARNING ${clash.host} also answers to "${AGENT.name}": both would act on @${AGENT.name}. Run setup with another --name.`);
|
|
1078
1088
|
} catch (e) {
|
|
@@ -1169,7 +1179,8 @@ async function setup() {
|
|
|
1169
1179
|
} else {
|
|
1170
1180
|
console.log(`\nKeep-alive: ${installSchedule()}. It keeps the sign-in from lapsing while Claude isn't running.`);
|
|
1171
1181
|
}
|
|
1172
|
-
|
|
1182
|
+
await reportPresence(true);
|
|
1183
|
+
console.log(`\nNow add it to Claude Code (@latest, so each new session picks up the newest release):\n ${claudeCodeCommand()}`);
|
|
1173
1184
|
if (argv.includes("--wake") && !argv.includes("--no-schedule") && !process.env.WF_NO_SCHEDULE) {
|
|
1174
1185
|
console.log("");
|
|
1175
1186
|
await wakeSetup(true);
|
|
@@ -1199,7 +1210,9 @@ async function keepAlive() {
|
|
|
1199
1210
|
const at = new Date().toISOString();
|
|
1200
1211
|
try {
|
|
1201
1212
|
await cloud.call("public/users/caller");
|
|
1202
|
-
|
|
1213
|
+
await reportPresence();
|
|
1214
|
+
const update = await selfUpdate();
|
|
1215
|
+
logKeepAlive(`${at} ok${/^updated|failed/.test(update) ? `; ${update}` : ""}`);
|
|
1203
1216
|
return 0;
|
|
1204
1217
|
} catch (e) {
|
|
1205
1218
|
logKeepAlive(`${at} ${e instanceof SignInNeeded ? "SIGN-IN ENDED" : "failed"}: ${String(e.message).split("\n")[0]}`);
|
|
@@ -1396,6 +1409,7 @@ async function wake() {
|
|
|
1396
1409
|
try {
|
|
1397
1410
|
try { await cloud.load(true); }
|
|
1398
1411
|
catch (e) { logWake(`${e instanceof SignInNeeded ? "SIGN-IN ENDED" : "iCloud failed"}: ${String(e.message).split("\n")[0]}`); return 1; }
|
|
1412
|
+
await reportPresence();
|
|
1399
1413
|
if (!cloudSnap) return 0;
|
|
1400
1414
|
if (blockingClash()) { logWake(`not waking: "${AGENT.name}" is also Claude on another computer`); return 0; }
|
|
1401
1415
|
const st = readJSON(WAKE.state, null) || {};
|
|
@@ -1450,6 +1464,7 @@ async function wake() {
|
|
|
1450
1464
|
return 1;
|
|
1451
1465
|
} finally {
|
|
1452
1466
|
try { fs.unlinkSync(WAKE.lock); } catch (_) {}
|
|
1467
|
+
try { const update = await selfUpdate(); if (/^updated|failed/.test(update)) logWake(update); } catch (_) {}
|
|
1453
1468
|
}
|
|
1454
1469
|
}
|
|
1455
1470
|
|
|
@@ -1539,9 +1554,192 @@ async function wakeSetup(on) {
|
|
|
1539
1554
|
return 0;
|
|
1540
1555
|
}
|
|
1541
1556
|
|
|
1557
|
+
// ------------------------------------------------------------------ versions (1.6.1)
|
|
1558
|
+
|
|
1559
|
+
// Each companion says which version it runs, and keeps itself current.
|
|
1560
|
+
//
|
|
1561
|
+
// Presence: a "companion-<name>" record of the Mac's own status type
|
|
1562
|
+
// (BridgeStatus: aliveAt, appVersion, device, pollSeconds, all already in the
|
|
1563
|
+
// Production schema), so WorkFlow's Who's Bridged and other companions can
|
|
1564
|
+
// show "Jarvis · 1.6.1 · checked in 4 min ago".
|
|
1565
|
+
//
|
|
1566
|
+
// Latest release: npm's registry entry for the package, which is JSON and is
|
|
1567
|
+
// by definition what was last published. Checked at most every 6 hours.
|
|
1568
|
+
//
|
|
1569
|
+
// Self-update: the scheduled jobs run a saved copy that npm never touches.
|
|
1570
|
+
// When a newer release is out, that copy is replaced by the published file,
|
|
1571
|
+
// after checking it against npm's own sha512 and that Node can parse it.
|
|
1572
|
+
// Claude Code stays current by being registered with @latest.
|
|
1573
|
+
const RELEASE_URL = "https://registry.npmjs.org/@opticell/workflow-companion/latest";
|
|
1574
|
+
const RELEASE_CHECK_MS = 6 * 3600 * 1000;
|
|
1575
|
+
const PRESENCE_EVERY_MS = 10 * 60 * 1000;
|
|
1576
|
+
const SAVED_SCRIPT = path.join(COMPANION.home, "workflow-companion.js");
|
|
1577
|
+
|
|
1578
|
+
// true when version a is newer than b ("1.10.0" > "1.9.3").
|
|
1579
|
+
function newerVersion(a, b) {
|
|
1580
|
+
const pa = String(a || "").split(".").map(n => parseInt(n, 10) || 0);
|
|
1581
|
+
const pb = String(b || "").split(".").map(n => parseInt(n, 10) || 0);
|
|
1582
|
+
for (let i = 0; i < 3; i++) if ((pa[i] || 0) !== (pb[i] || 0)) return (pa[i] || 0) > (pb[i] || 0);
|
|
1583
|
+
return false;
|
|
1584
|
+
}
|
|
1585
|
+
|
|
1586
|
+
function updateConfig(change) {
|
|
1587
|
+
if (!fs.existsSync(CP.config)) return;
|
|
1588
|
+
const cfg = readJSON(CP.config, {}) || {};
|
|
1589
|
+
change(cfg);
|
|
1590
|
+
saveAtomic(CP.config, JSON.stringify(cfg, null, 2));
|
|
1591
|
+
}
|
|
1592
|
+
|
|
1593
|
+
// The newest published release, from npm (cached for 6 hours in config.json).
|
|
1594
|
+
async function latestRelease(force = false) {
|
|
1595
|
+
const cached = (readJSON(CP.config, {}) || {}).latestRelease || null;
|
|
1596
|
+
if (!force && cached && Date.now() - cached.checkedAt < RELEASE_CHECK_MS) return cached;
|
|
1597
|
+
try {
|
|
1598
|
+
const ctl = new AbortController();
|
|
1599
|
+
const timer = setTimeout(() => ctl.abort(), 8000);
|
|
1600
|
+
const res = await fetch(RELEASE_URL, { signal: ctl.signal });
|
|
1601
|
+
clearTimeout(timer);
|
|
1602
|
+
if (!res.ok) return cached;
|
|
1603
|
+
const j = await res.json();
|
|
1604
|
+
if (!j || !j.version) return cached;
|
|
1605
|
+
const info = { version: j.version, tarball: j.dist && j.dist.tarball, integrity: j.dist && j.dist.integrity, checkedAt: Date.now() };
|
|
1606
|
+
updateConfig(cfg => { cfg.latestRelease = info; });
|
|
1607
|
+
return info;
|
|
1608
|
+
} catch (_) {
|
|
1609
|
+
return cached;
|
|
1610
|
+
}
|
|
1611
|
+
}
|
|
1612
|
+
|
|
1613
|
+
// The version a saved copy of this file declares.
|
|
1614
|
+
function versionOfScript(file) {
|
|
1615
|
+
try {
|
|
1616
|
+
const m = fs.readFileSync(file, "utf8").match(/const SERVER_INFO = \{ name: "workflow", version: "([0-9.]+)" \};/);
|
|
1617
|
+
return m ? m[1] : null;
|
|
1618
|
+
} catch (_) { return null; }
|
|
1619
|
+
}
|
|
1620
|
+
|
|
1621
|
+
// package/index.js out of an npm tarball (gzip'd ustar). No dependencies.
|
|
1622
|
+
function indexFromTarball(gz) {
|
|
1623
|
+
const tar = require("zlib").gunzipSync(gz);
|
|
1624
|
+
const text = (from, len) => tar.toString("utf8", from, from + len).replace(/\0[\s\S]*$/, "");
|
|
1625
|
+
for (let off = 0; off + 512 <= tar.length;) {
|
|
1626
|
+
if (tar.subarray(off, off + 512).every(b => b === 0)) break;
|
|
1627
|
+
const name = text(off, 100), prefix = text(off + 345, 155);
|
|
1628
|
+
const size = parseInt(text(off + 124, 12).trim(), 8) || 0;
|
|
1629
|
+
const start = off + 512;
|
|
1630
|
+
if ((prefix ? `${prefix}/${name}` : name) === "package/index.js") return tar.subarray(start, start + size);
|
|
1631
|
+
off = start + Math.ceil(size / 512) * 512;
|
|
1632
|
+
}
|
|
1633
|
+
return null;
|
|
1634
|
+
}
|
|
1635
|
+
|
|
1636
|
+
// Replaces the saved copy the scheduled jobs run, if a newer release is out.
|
|
1637
|
+
// Returns "updated from X to Y", "current", "off", or a reason it didn't.
|
|
1638
|
+
async function selfUpdate({ force = false } = {}) {
|
|
1639
|
+
const cfg = readJSON(CP.config, null);
|
|
1640
|
+
if (!cfg) return "not signed in";
|
|
1641
|
+
if (cfg.autoUpdate === false && !force) return "off";
|
|
1642
|
+
if (!fs.existsSync(SAVED_SCRIPT)) return "nothing scheduled";
|
|
1643
|
+
const saved = versionOfScript(SAVED_SCRIPT);
|
|
1644
|
+
const rel = await latestRelease(force);
|
|
1645
|
+
if (!rel || !rel.version) return "couldn't reach npm";
|
|
1646
|
+
if (!newerVersion(rel.version, saved)) return "current";
|
|
1647
|
+
try {
|
|
1648
|
+
if (!rel.tarball || !/^sha512-/.test(rel.integrity || "")) throw new Error("npm gave no tarball or checksum");
|
|
1649
|
+
const res = await fetch(rel.tarball);
|
|
1650
|
+
if (!res.ok) throw new Error(`download failed (HTTP ${res.status})`);
|
|
1651
|
+
const gz = Buffer.from(await res.arrayBuffer());
|
|
1652
|
+
const sum = "sha512-" + require("crypto").createHash("sha512").update(gz).digest("base64");
|
|
1653
|
+
if (sum !== rel.integrity) throw new Error("checksum didn't match npm's");
|
|
1654
|
+
const code = indexFromTarball(gz);
|
|
1655
|
+
if (!code) throw new Error("no index.js in the package");
|
|
1656
|
+
// A .js name: Node won't --check a file with any other extension.
|
|
1657
|
+
const tmp = path.join(COMPANION.home, `workflow-companion.${process.pid}.new.js`);
|
|
1658
|
+
fs.writeFileSync(tmp, code);
|
|
1659
|
+
const check = require("child_process").spawnSync(process.execPath, ["--check", tmp], { encoding: "utf8" });
|
|
1660
|
+
if (check.status !== 0) { try { fs.unlinkSync(tmp); } catch (_) {} throw new Error("the new file didn't parse"); }
|
|
1661
|
+
fs.renameSync(tmp, SAVED_SCRIPT);
|
|
1662
|
+
return `updated from ${saved || "?"} to ${rel.version}`;
|
|
1663
|
+
} catch (e) {
|
|
1664
|
+
return `update to ${rel.version} failed: ${e.message}`;
|
|
1665
|
+
}
|
|
1666
|
+
}
|
|
1667
|
+
|
|
1668
|
+
// "I'm here, this version": at most every 10 minutes unless forced.
|
|
1669
|
+
async function reportPresence(force = false) {
|
|
1670
|
+
if (!CLOUD) return;
|
|
1671
|
+
const cfg = readJSON(CP.config, null);
|
|
1672
|
+
if (!cfg || !fs.existsSync(CP.token)) return;
|
|
1673
|
+
if (!force && cfg.presenceAt && Date.now() - cfg.presenceAt < PRESENCE_EVERY_MS) return;
|
|
1674
|
+
const slug = AGENT.authorID.slice("agent.".length);
|
|
1675
|
+
try {
|
|
1676
|
+
await cloud.call("private/records/modify", { zoneID: { zoneName: COMPANION.zone }, operations: [{ operationType: "forceReplace", record: {
|
|
1677
|
+
recordType: "BridgeStatus", recordName: `companion-${slug}`,
|
|
1678
|
+
fields: {
|
|
1679
|
+
aliveAt: { value: Date.now(), type: "TIMESTAMP" },
|
|
1680
|
+
appVersion: { value: SERVER_INFO.version, type: "STRING" },
|
|
1681
|
+
device: { value: os.hostname(), type: "STRING" },
|
|
1682
|
+
// Seconds between wake checks; 0 when waking is off.
|
|
1683
|
+
pollSeconds: { value: cfg.wakeEnabled ? WAKE.everyMinutes * 60 : 0, type: "INT64" },
|
|
1684
|
+
},
|
|
1685
|
+
} }] });
|
|
1686
|
+
updateConfig(c => { c.presenceAt = Date.now(); });
|
|
1687
|
+
} catch (_) { /* reported next time */ }
|
|
1688
|
+
}
|
|
1689
|
+
|
|
1690
|
+
// Every companion's last check-in, from their presence records.
|
|
1691
|
+
async function companionPresence() {
|
|
1692
|
+
const names = companionRoster().map(e => e.name);
|
|
1693
|
+
if (!names.includes(AGENT.name)) names.push(AGENT.name);
|
|
1694
|
+
const slugs = names.map(n => agentFor(n).authorID.slice("agent.".length));
|
|
1695
|
+
const got = await cloud.lookup(slugs.map(s => `companion-${s}`));
|
|
1696
|
+
return names.map((name, i) => {
|
|
1697
|
+
const r = got[`companion-${slugs[i]}`];
|
|
1698
|
+
return r ? { name, version: cloud.field(r, "appVersion"), host: cloud.field(r, "device"),
|
|
1699
|
+
aliveAt: cloud.field(r, "aliveAt"), waking: (cloud.field(r, "pollSeconds") || 0) > 0 } : { name };
|
|
1700
|
+
});
|
|
1701
|
+
}
|
|
1702
|
+
|
|
1703
|
+
// One line for status and workflow_state: this version, and whether it's the latest.
|
|
1704
|
+
async function versionLine() {
|
|
1705
|
+
const rel = await latestRelease();
|
|
1706
|
+
const auto = (readJSON(CP.config, {}) || {}).autoUpdate === false ? "auto-update off" : "auto-update on";
|
|
1707
|
+
if (!rel) return `${SERVER_INFO.version} (couldn't check npm for a newer one; ${auto})`;
|
|
1708
|
+
return newerVersion(rel.version, SERVER_INFO.version)
|
|
1709
|
+
? `${SERVER_INFO.version}, UPDATE AVAILABLE: ${rel.version}. Run "npx -y @opticell/workflow-companion@latest update" (${auto})`
|
|
1710
|
+
: `${SERVER_INFO.version}, the latest (${auto})`;
|
|
1711
|
+
}
|
|
1712
|
+
|
|
1713
|
+
// How Claude Code should run the companion: @latest, so every new session
|
|
1714
|
+
// picks up the newest release. Windows needs cmd /c in front of npx.
|
|
1715
|
+
function claudeCodeCommand() {
|
|
1716
|
+
return `claude mcp add --scope user workflow -- ${process.platform === "win32" ? "cmd /c " : ""}npx -y @opticell/workflow-companion@latest`;
|
|
1717
|
+
}
|
|
1718
|
+
|
|
1719
|
+
// `workflow-companion update`: refresh the saved copy now, say the version,
|
|
1720
|
+
// and how to keep Claude Code current.
|
|
1721
|
+
async function updateNow() {
|
|
1722
|
+
const result = await selfUpdate({ force: true });
|
|
1723
|
+
const rel = await latestRelease();
|
|
1724
|
+
console.log(`Latest release: ${rel ? rel.version : "unknown (couldn't reach npm)"}`);
|
|
1725
|
+
console.log(`Scheduled jobs' copy: ${result === "nothing scheduled" ? "none (waking and keep-alive aren't scheduled here)" : result}`);
|
|
1726
|
+
await reportPresence(true);
|
|
1727
|
+
console.log(`\nClaude Code runs whatever its registration says. To always get the latest:\n claude mcp remove workflow -s user\n ${claudeCodeCommand()}`);
|
|
1728
|
+
return 0;
|
|
1729
|
+
}
|
|
1730
|
+
|
|
1731
|
+
// `workflow-companion auto-update on|off`.
|
|
1732
|
+
function setAutoUpdate(on) {
|
|
1733
|
+
if (!fs.existsSync(CP.config)) { console.error(signInHelp("Not signed in yet.")); return 2; }
|
|
1734
|
+
updateConfig(cfg => { cfg.autoUpdate = on; });
|
|
1735
|
+
console.log(on ? "Auto-update is on: the scheduled jobs update themselves when a new release is out."
|
|
1736
|
+
: "Auto-update is off. Update by hand with: npx -y @opticell/workflow-companion@latest update");
|
|
1737
|
+
return 0;
|
|
1738
|
+
}
|
|
1739
|
+
|
|
1542
1740
|
function printConfig() {
|
|
1543
1741
|
if (CLOUD) {
|
|
1544
|
-
process.stdout.write(`Claude Code:\n
|
|
1742
|
+
process.stdout.write(`Claude Code:\n ${claudeCodeCommand()}\n\nClaude Desktop → Settings → Developer → Edit Config, add:\n${JSON.stringify({ mcpServers: { workflow: { command: "npx", args: ["-y", "@opticell/workflow-companion@latest"] } } }, null, 2)}\n`);
|
|
1545
1743
|
return;
|
|
1546
1744
|
}
|
|
1547
1745
|
const cfg = { mcpServers: { workflow: { command: "node", args: [__filename], env: { WF_BRIDGE: ROOT } } } };
|
|
@@ -1555,6 +1753,8 @@ const HELP = `WorkFlow companion ${SERVER_INFO.version}
|
|
|
1555
1753
|
workflow-companion setup sign this computer in to iCloud for WorkFlow (--name, --takeover, --no-browser)
|
|
1556
1754
|
workflow-companion status which device answers, how fresh is the snapshot
|
|
1557
1755
|
workflow-companion keepalive renew the sign-in (what the scheduled job runs)
|
|
1756
|
+
workflow-companion update update the scheduled jobs' copy now, and say how to keep Claude Code current
|
|
1757
|
+
workflow-companion auto-update on|off whether the scheduled jobs update themselves (on by default)
|
|
1558
1758
|
workflow-companion wake-on start a Claude Code session on its own when @name work arrives
|
|
1559
1759
|
(--allow-tools, --model, --workdir, --max-minutes, --claude, --skip-existing)
|
|
1560
1760
|
workflow-companion wake-off stop doing that; work waits until you ask
|
|
@@ -1570,6 +1770,8 @@ else if (argv.includes("--help") || verb === "help") process.stdout.write(HELP);
|
|
|
1570
1770
|
else if (verb === "setup") setup().then(c => { process.exitCode = c; }, e => { console.error(e.message || e); process.exitCode = 1; });
|
|
1571
1771
|
else if (verb === "status") cloudStateText().then(t => console.log(t), e => { console.error(e.message || e); process.exitCode = 1; });
|
|
1572
1772
|
else if (verb === "keepalive") keepAlive().then(c => { process.exitCode = c; });
|
|
1773
|
+
else if (verb === "update") updateNow().then(c => { process.exitCode = c; }, e => { console.error(e.message || e); process.exitCode = 1; });
|
|
1774
|
+
else if (verb === "auto-update") process.exitCode = setAutoUpdate(argv[argv.indexOf("auto-update") + 1] !== "off");
|
|
1573
1775
|
else if (verb === "wake") wake().then(c => { process.exitCode = c; }, e => { logWake(`failed: ${e.message || e}`); process.exitCode = 1; });
|
|
1574
1776
|
else if (verb === "wake-on" || verb === "wake-off") wakeSetup(verb === "wake-on").then(c => { process.exitCode = c; }, e => { console.error(e.message || e); process.exitCode = 1; });
|
|
1575
1777
|
else if (verb === "signout") {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opticell/workflow-companion",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.1",
|
|
4
4
|
"mcpName": "io.github.TeamDzX/workflow-companion",
|
|
5
5
|
"description": "Lets Claude on Windows or Linux work in your WorkFlow tasks, notes and projects, through WorkFlow for Mac and your own iCloud. An MCP server.",
|
|
6
6
|
"keywords": [
|