@netnodeag/kraftwerk 0.100.1 → 0.102.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +73 -0
- package/dist/cli/cloud.d.ts +1 -0
- package/dist/cli/cloud.js +1 -1
- package/dist/cli/join.d.ts +2 -0
- package/dist/cli/join.js +52 -0
- package/dist/cli/kraftwerk.js +3 -0
- package/dist/client/routes.d.ts +2 -0
- package/dist/client/routes.js +2 -0
- package/dist/config.d.ts +2 -2
- package/dist/config.js +3 -3
- package/dist/core/boards.d.ts +3 -0
- package/dist/core/boards.js +16 -2
- package/dist/core/cloud.d.ts +5 -0
- package/dist/core/git.d.ts +46 -2
- package/dist/core/git.js +251 -8
- package/dist/core/notifications.d.ts +3 -2
- package/dist/core/settings.d.ts +1 -1
- package/dist/core/settings.js +2 -2
- package/dist/server/api/cloud.d.ts +4 -0
- package/dist/server/api/cloud.js +14 -0
- package/dist/server/api/git.d.ts +13 -1
- package/dist/server/api/git.js +39 -1
- package/dist/server/api/index.d.ts +10 -1
- package/dist/server/cloud-events.d.ts +8 -0
- package/dist/server/cloud-events.js +199 -0
- package/dist/server/cloud.d.ts +12 -0
- package/dist/server/cloud.js +53 -0
- package/dist/server/join.d.ts +38 -0
- package/dist/server/join.js +111 -0
- package/dist/server/relay.js +5 -0
- package/dist/server/sync-setup.d.ts +31 -0
- package/dist/server/sync-setup.js +90 -0
- package/dist/server/users.d.ts +11 -0
- package/dist/server/users.js +63 -15
- package/dist/server/workspace-cloud.d.ts +3 -1
- package/dist/server/workspace-cloud.js +18 -8
- package/package.json +1 -1
- package/web/dist/assets/{dist-Dj1JIIbI.js → dist-B09k-Kwi.js} +1 -1
- package/web/dist/assets/{dist-DQsdt9qV.js → dist-BG9MPqC7.js} +1 -1
- package/web/dist/assets/{dist-DxHapyfL.js → dist-BbST9sxK.js} +1 -1
- package/web/dist/assets/{dist-OUSFQqAo.js → dist-BrXAphjl.js} +1 -1
- package/web/dist/assets/{dist-CYnkW4NZ.js → dist-C0Ulmjwh.js} +1 -1
- package/web/dist/assets/{dist-DmqwXVk5.js → dist-C8wsDqpL.js} +1 -1
- package/web/dist/assets/{dist-Dhqv4G4v.js → dist-CJk4RtqY.js} +1 -1
- package/web/dist/assets/{dist-BQht4Kxn.js → dist-CfSpo_bP.js} +1 -1
- package/web/dist/assets/dist-DMU8iY9H.js +1 -0
- package/web/dist/assets/{dist-C6Hh2gvr.js → dist-Dv55aORJ.js} +1 -1
- package/web/dist/assets/{dist-KYJrjjHE.js → dist-QQHKzUGH.js} +1 -1
- package/web/dist/assets/{editor-DjVpjnNv.js → editor-Co8xGDnf.js} +3 -3
- package/web/dist/assets/index-CepQsH8H.js +488 -0
- package/web/dist/assets/index-DJGLnVQY.css +2 -0
- package/web/dist/index.html +2 -2
- package/web/dist/assets/dist-CxDUjCCR.js +0 -1
- package/web/dist/assets/index-BV1cBJKv.js +0 -488
- package/web/dist/assets/index-ClVr51ut.css +0 -2
package/README.md
CHANGED
|
@@ -542,6 +542,68 @@ writes `users: local` and leaves the machine as it is. Only an owner
|
|
|
542
542
|
switches a workspace in cloud mode, and two switches never run at once. `GET /api/workspace/cloud` reports the mode and
|
|
543
543
|
its steps, `POST /api/workspace/cloud {mode}` switches.
|
|
544
544
|
|
|
545
|
+
### Start on the platform: `kraftwerk join`
|
|
546
|
+
|
|
547
|
+
The quickest way in starts on kraftwerk cloud: sign up, click **New
|
|
548
|
+
workspace**, and copy the one command it shows:
|
|
549
|
+
|
|
550
|
+
```bash
|
|
551
|
+
npm i -g @netnodeag/kraftwerk && kraftwerk join https://srv.kraftwerk-cloud.netnode.cloud/join/XKQ7-2MPD-HH3A
|
|
552
|
+
```
|
|
553
|
+
|
|
554
|
+
It installs kraftwerk for good (the daemon then runs from that install), starts
|
|
555
|
+
the daemon if it does not run, links this machine to your account
|
|
556
|
+
(no claim code), clones the workspace from kraftwerk sync into `./<its name>`
|
|
557
|
+
(or `kraftwerk join <link> <folder>`) and opens it in the browser — already
|
|
558
|
+
in cloud mode and signed in: the link proved the account, so the daemon hands
|
|
559
|
+
the browser a one-time sign-in (`/auth/handoff`, five minutes, single use)
|
|
560
|
+
instead of a second round through the cloud. A workspace whose repository is
|
|
561
|
+
still empty (begun locally, kraftwerk sync not set up there yet) is refused
|
|
562
|
+
with what to do, and nothing is made locally. An invite works the same way: the person accepts it in the
|
|
563
|
+
browser (signing up on the way), and the page shows the same command. A
|
|
564
|
+
workspace's page in the cloud gives you a fresh command for each further
|
|
565
|
+
machine (*Install on a machine*). Running it again on a folder that holds the
|
|
566
|
+
workspace just opens it. `POST /api/cloud/join {link, cwd, dir?}` on the
|
|
567
|
+
daemon does the work.
|
|
568
|
+
|
|
569
|
+
### kraftwerk sync: the workspace's files in the cloud
|
|
570
|
+
|
|
571
|
+
In cloud mode a workspace's history can live in its own repository in
|
|
572
|
+
kraftwerk cloud (`<cloud>/git/<id>.git`) — no GitHub needed to share a
|
|
573
|
+
workspace. The daemon brings the machine's key along when git talks to that
|
|
574
|
+
address (a URL-scoped `http.extraHeader` in git's environment, never written
|
|
575
|
+
to a config), so there is no token to paste and no credential helper.
|
|
576
|
+
|
|
577
|
+
Workspaces made on the platform start with it. For one you started locally,
|
|
578
|
+
switch it to cloud, then on the **Git** page click *set up kraftwerk sync*
|
|
579
|
+
(`POST /api/git/sync-setup`): a repository if there is none, `git:` on with
|
|
580
|
+
`autosync: sync` every 60 seconds, the remote, a first commit, a push.
|
|
581
|
+
|
|
582
|
+
`autosync: sync` is the simple sync: every interval kraftwerk commits what
|
|
583
|
+
changed under the synced paths (as the account the machine is linked to),
|
|
584
|
+
takes the others' commits in and pushes — nobody commits, pulls or merges by
|
|
585
|
+
hand. When two people changed the same file at once, the version that
|
|
586
|
+
reached the cloud first stays, and the other lands beside it as
|
|
587
|
+
`name.konflikt-<handle>.ext`, committed too, so nothing is lost. The Git page
|
|
588
|
+
lists those copies on every machine until someone deletes them:
|
|
589
|
+
|
|
590
|
+
```yaml
|
|
591
|
+
git:
|
|
592
|
+
autosync: sync # off | pull | push | sync
|
|
593
|
+
interval: 60
|
|
594
|
+
```
|
|
595
|
+
|
|
596
|
+
A remote of your own
|
|
597
|
+
(GitHub, GitLab, a server in-house) is expert mode: kraftwerk never replaces
|
|
598
|
+
it, and the Git page says which of the two a workspace uses
|
|
599
|
+
(*managed by kraftwerk* or *own git provider · expert mode*) and shows the
|
|
600
|
+
remote's address.
|
|
601
|
+
|
|
602
|
+
A workspace deleted on kraftwerk cloud (by its owner or an admin) stays on
|
|
603
|
+
your machine with all its files: the mode chip says *cloud · deleted*, and
|
|
604
|
+
switching it to local keeps you working. Switching it to cloud again gives it
|
|
605
|
+
a fresh id — the old one is never used again.
|
|
606
|
+
|
|
545
607
|
### This machine in the kraftwerk cloud
|
|
546
608
|
|
|
547
609
|
The kraftwerk cloud is the `~/.kraftwerk` registry made reachable over the
|
|
@@ -1232,6 +1294,17 @@ the model via ACP session options and the thinking budget via
|
|
|
1232
1294
|
are created and edited in the UI, or by editing the files, since the
|
|
1233
1295
|
definition is read fresh for each new session.
|
|
1234
1296
|
|
|
1297
|
+
|
|
1298
|
+
**Told at once.** A task on a cloud board handed to you by someone else
|
|
1299
|
+
lands in the bell of the workspace on your machines — and as a browser
|
|
1300
|
+
notification and on a paired phone — within a fraction of a second: the
|
|
1301
|
+
cloud pokes the machine over its event stream (`/api/machines/stream`, held
|
|
1302
|
+
by every daemon connected to the cloud, remote access or not), the daemon
|
|
1303
|
+
fetches what waits and acknowledges it; a poke missed while offline comes
|
|
1304
|
+
with the next heartbeat. A task for an agent in a work column wakes that
|
|
1305
|
+
agent on the machine that has it, as a local board does — one machine
|
|
1306
|
+
claims it, so clones never both start. The agent works it with
|
|
1307
|
+
`npx kraftwerk tasks … --board @<board>`.
|
|
1235
1308
|
### Repositories
|
|
1236
1309
|
|
|
1237
1310
|
Turn on `repos:` in `kraftwerk.yml` (or the checkbox in settings) and the
|
package/dist/cli/cloud.d.ts
CHANGED
package/dist/cli/cloud.js
CHANGED
|
@@ -26,7 +26,7 @@ const fail = (message, code = 1) => {
|
|
|
26
26
|
console.error(chalk.red(`✖ ${message}`));
|
|
27
27
|
process.exit(code);
|
|
28
28
|
};
|
|
29
|
-
function openBrowser(url) {
|
|
29
|
+
export function openBrowser(url) {
|
|
30
30
|
const [cmd, args] = process.platform === "darwin" ? ["open", [url]] : process.platform === "win32" ? ["cmd", ["/c", "start", "", url]] : ["xdg-open", [url]];
|
|
31
31
|
try {
|
|
32
32
|
spawn(cmd, args, { stdio: "ignore", detached: true }).unref();
|
package/dist/cli/join.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import { findDaemon } from "../core/daemon.js";
|
|
3
|
+
import { tildify } from "../core/instances.js";
|
|
4
|
+
import { openBrowser } from "./cloud.js";
|
|
5
|
+
import { startDaemon } from "./daemon-control.js";
|
|
6
|
+
const fail = (message, code = 1) => {
|
|
7
|
+
console.error(chalk.red(`✖ ${message}`));
|
|
8
|
+
process.exit(code);
|
|
9
|
+
};
|
|
10
|
+
export function registerJoinCommand(program) {
|
|
11
|
+
program
|
|
12
|
+
.command("join")
|
|
13
|
+
.description("Bring a workspace from kraftwerk cloud onto this machine: the link from the platform (new workspace, install, accepted invite) — clones it into ./<name> and opens it")
|
|
14
|
+
.argument("<link>", "the join link (https://…/join/XXXX-XXXX-XXXX) or its code")
|
|
15
|
+
.argument("[folder]", "where the workspace goes (default: ./<its name>)")
|
|
16
|
+
.option("--no-open", "Do not open the browser")
|
|
17
|
+
.option("--json", "Machine-readable output")
|
|
18
|
+
.action(async (link, folder, opts) => {
|
|
19
|
+
if (!(await findDaemon())) {
|
|
20
|
+
if (!opts.json)
|
|
21
|
+
console.log(chalk.dim("kraftwerk runs as a daemon on this machine — starting it"));
|
|
22
|
+
await startDaemon({});
|
|
23
|
+
}
|
|
24
|
+
const daemon = (await findDaemon()) ?? fail("the daemon did not come up — `kraftwerk daemon logs`");
|
|
25
|
+
if (!opts.json)
|
|
26
|
+
process.stdout.write(chalk.dim("joining through kraftwerk cloud …"));
|
|
27
|
+
const r = await fetch(`http://127.0.0.1:${daemon.port}/api/cloud/join`, {
|
|
28
|
+
method: "POST",
|
|
29
|
+
headers: { "content-type": "application/json" },
|
|
30
|
+
body: JSON.stringify({ link, cwd: process.cwd(), ...(folder ? { dir: folder } : {}) }),
|
|
31
|
+
signal: AbortSignal.timeout(10 * 60_000),
|
|
32
|
+
}).catch((err) => fail(`the daemon did not answer: ${err.message}`));
|
|
33
|
+
if (!opts.json)
|
|
34
|
+
process.stdout.write("\n");
|
|
35
|
+
const data = (await r.json().catch(() => ({})));
|
|
36
|
+
if (!r.ok)
|
|
37
|
+
fail(data.error ?? `${r.status} from the daemon`);
|
|
38
|
+
if (opts.json) {
|
|
39
|
+
console.log(JSON.stringify(data, null, 2));
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
console.log(`${chalk.green("✔")} ${chalk.bold(data.workspace.name)} ${chalk.dim(`(${data.workspace.id}, ${data.role})`)} is on this machine`);
|
|
43
|
+
console.log(` ${chalk.dim("folder")} ${tildify(data.root)}${data.cloned ? "" : chalk.dim(" (was already here)")}`);
|
|
44
|
+
console.log(` ${chalk.dim("account")} ${data.account} — this machine is linked to it`);
|
|
45
|
+
console.log(` ${chalk.dim("sync")} kraftwerk sync: what changes here goes to the cloud every minute, the others' changes come in`);
|
|
46
|
+
console.log(` ${chalk.dim("open")} ${chalk.cyan(data.workspace.url)}`);
|
|
47
|
+
if (opts.open)
|
|
48
|
+
openBrowser(data.signin ?? data.workspace.url);
|
|
49
|
+
else if (data.signin)
|
|
50
|
+
console.log(` ${chalk.dim("sign in")} ${data.signin} ${chalk.dim("(once, within 5 minutes)")}`);
|
|
51
|
+
});
|
|
52
|
+
}
|
package/dist/cli/kraftwerk.js
CHANGED
|
@@ -28,6 +28,7 @@ import { registerJournalCommands } from "./journal.js";
|
|
|
28
28
|
import { registerWhoamiCommand } from "./whoami.js";
|
|
29
29
|
import { registerCloudCommands } from "./cloud.js";
|
|
30
30
|
import { registerInviteCommand } from "./invite.js";
|
|
31
|
+
import { registerJoinCommand } from "./join.js";
|
|
31
32
|
import { applyDotenv } from "../dotenv.js";
|
|
32
33
|
import { resolveWorkspace } from "../config.js";
|
|
33
34
|
import { registerRoutineCommands } from "./routines.js";
|
|
@@ -60,6 +61,7 @@ import { runUi } from "./ui.js";
|
|
|
60
61
|
* kraftwerk cloud [on|off|status] this machine in the kraftwerk cloud (the daemon registers it)
|
|
61
62
|
* kraftwerk login / logout claim this machine into your cloud account (in the browser) / release it
|
|
62
63
|
* kraftwerk invite [--role owner] invite a remote member into this workspace (join code + link, via the daemon)
|
|
64
|
+
* kraftwerk join <link> [folder] bring a workspace from kraftwerk cloud onto this machine (claim, clone, open)
|
|
63
65
|
* kraftwerk doctor [--fix] preflight: harness CLIs, docker, workflows, env, routine runners
|
|
64
66
|
* kraftwerk validate [paths...] validate without executing
|
|
65
67
|
*
|
|
@@ -325,6 +327,7 @@ registerJournalCommands(program);
|
|
|
325
327
|
registerWhoamiCommand(program);
|
|
326
328
|
registerCloudCommands(program);
|
|
327
329
|
registerInviteCommand(program);
|
|
330
|
+
registerJoinCommand(program);
|
|
328
331
|
program
|
|
329
332
|
.command("ui")
|
|
330
333
|
.description("Start the inspector web UI for this project's runs and workflows")
|
package/dist/client/routes.d.ts
CHANGED
|
@@ -53,6 +53,7 @@ export declare const ROUTES: {
|
|
|
53
53
|
readonly "chats.steer": readonly ["POST", "/api/chats/:id/steer"];
|
|
54
54
|
readonly "chats.stopTask": readonly ["POST", "/api/chats/:id/task-stop"];
|
|
55
55
|
readonly "cloud.invite": readonly ["POST", "/api/cloud/invite"];
|
|
56
|
+
readonly "cloud.join": readonly ["POST", "/api/cloud/join"];
|
|
56
57
|
readonly "cloud.set": readonly ["POST", "/api/cloud"];
|
|
57
58
|
readonly "cloud.status": readonly ["GET", "/api/cloud"];
|
|
58
59
|
readonly "cloud.sync": readonly ["POST", "/api/cloud/sync"];
|
|
@@ -89,6 +90,7 @@ export declare const ROUTES: {
|
|
|
89
90
|
readonly "git.fetch": readonly ["POST", "/api/git/fetch"];
|
|
90
91
|
readonly "git.pull": readonly ["POST", "/api/git/pull"];
|
|
91
92
|
readonly "git.push": readonly ["POST", "/api/git/push"];
|
|
93
|
+
readonly "git.setupSync": readonly ["POST", "/api/git/sync-setup"];
|
|
92
94
|
readonly "git.status": readonly ["GET", "/api/git"];
|
|
93
95
|
readonly "hub.close": readonly ["POST", "/api/hub/close"];
|
|
94
96
|
readonly "hub.list": readonly ["GET", "/api/hub"];
|
package/dist/client/routes.js
CHANGED
|
@@ -54,6 +54,7 @@ export const ROUTES = {
|
|
|
54
54
|
"chats.steer": ["POST", "/api/chats/:id/steer"],
|
|
55
55
|
"chats.stopTask": ["POST", "/api/chats/:id/task-stop"],
|
|
56
56
|
"cloud.invite": ["POST", "/api/cloud/invite"],
|
|
57
|
+
"cloud.join": ["POST", "/api/cloud/join"],
|
|
57
58
|
"cloud.set": ["POST", "/api/cloud"],
|
|
58
59
|
"cloud.status": ["GET", "/api/cloud"],
|
|
59
60
|
"cloud.sync": ["POST", "/api/cloud/sync"],
|
|
@@ -90,6 +91,7 @@ export const ROUTES = {
|
|
|
90
91
|
"git.fetch": ["POST", "/api/git/fetch"],
|
|
91
92
|
"git.pull": ["POST", "/api/git/pull"],
|
|
92
93
|
"git.push": ["POST", "/api/git/push"],
|
|
94
|
+
"git.setupSync": ["POST", "/api/git/sync-setup"],
|
|
93
95
|
"git.status": ["GET", "/api/git"],
|
|
94
96
|
"hub.close": ["POST", "/api/hub/close"],
|
|
95
97
|
"hub.list": ["GET", "/api/hub"],
|
package/dist/config.d.ts
CHANGED
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
* git: # workspace git sync (absent = off, bare key = on with defaults)
|
|
28
28
|
* remote: origin
|
|
29
29
|
* interval: 300 # seconds between background fetches
|
|
30
|
-
* autosync: pull # off | pull | push (push = pull, then push what is committed)
|
|
30
|
+
* autosync: pull # off | pull | push | sync (push = pull, then push what is committed; sync = commit what changed too)
|
|
31
31
|
* repos: # git repositories the agents work on (absent = off, bare key = on)
|
|
32
32
|
* root: kraftwerk-data/repos # where clones land, relative to the file. Default: repos
|
|
33
33
|
* vibeables: # small apps built live in a chat, rendered in the inspector (absent = off, bare key = on)
|
|
@@ -69,7 +69,7 @@ export interface GitConfig {
|
|
|
69
69
|
/** Seconds between background fetches. 0 disables the timer. Default: 300. */
|
|
70
70
|
interval?: number;
|
|
71
71
|
/** off = fetch only. pull = also fast-forward when behind and clean. push = pull, and push commits that are ahead. Default: pull. */
|
|
72
|
-
autosync?: "off" | "pull" | "push";
|
|
72
|
+
autosync?: "off" | "pull" | "push" | "sync";
|
|
73
73
|
}
|
|
74
74
|
/**
|
|
75
75
|
* Repositories: git clones the agents work on, kept under one root inside
|
package/dist/config.js
CHANGED
|
@@ -33,7 +33,7 @@ import { readParsed } from "./core/file-cache.js";
|
|
|
33
33
|
* git: # workspace git sync (absent = off, bare key = on with defaults)
|
|
34
34
|
* remote: origin
|
|
35
35
|
* interval: 300 # seconds between background fetches
|
|
36
|
-
* autosync: pull # off | pull | push (push = pull, then push what is committed)
|
|
36
|
+
* autosync: pull # off | pull | push | sync (push = pull, then push what is committed; sync = commit what changed too)
|
|
37
37
|
* repos: # git repositories the agents work on (absent = off, bare key = on)
|
|
38
38
|
* root: kraftwerk-data/repos # where clones land, relative to the file. Default: repos
|
|
39
39
|
* vibeables: # small apps built live in a chat, rendered in the inspector (absent = off, bare key = on)
|
|
@@ -480,8 +480,8 @@ function validateGit(configPath, value) {
|
|
|
480
480
|
if (g.interval !== undefined && (typeof g.interval !== "number" || !Number.isInteger(g.interval) || g.interval < 0)) {
|
|
481
481
|
throw new Error(`${file}: git.interval must be a whole number of seconds (0 disables the timer)`);
|
|
482
482
|
}
|
|
483
|
-
if (g.autosync !== undefined && g.autosync !== "off" && g.autosync !== "pull" && g.autosync !== "push") {
|
|
484
|
-
throw new Error(`${file}: git.autosync must be "off", "pull" or "
|
|
483
|
+
if (g.autosync !== undefined && g.autosync !== "off" && g.autosync !== "pull" && g.autosync !== "push" && g.autosync !== "sync") {
|
|
484
|
+
throw new Error(`${file}: git.autosync must be "off", "pull", "push" or "sync"`);
|
|
485
485
|
}
|
|
486
486
|
}
|
|
487
487
|
/**
|
package/dist/core/boards.d.ts
CHANGED
|
@@ -251,6 +251,8 @@ export interface TaskEvent {
|
|
|
251
251
|
message?: string;
|
|
252
252
|
}
|
|
253
253
|
export declare const EVENTS_FILE = "boards/events.jsonl";
|
|
254
|
+
/** Append an event for the server on this machine (board-wake.ts reads the file). Local run-state: never in git. Cloud tasks come in through server/cloud-events.ts. */
|
|
255
|
+
export declare function emitTaskEvent(ev: TaskEvent): Promise<void>;
|
|
254
256
|
export declare function createTask(ref: BoardRef, input: TaskInput & {
|
|
255
257
|
actor?: string;
|
|
256
258
|
message?: string;
|
|
@@ -303,4 +305,5 @@ export interface LinkingTask {
|
|
|
303
305
|
}
|
|
304
306
|
/** Every task whose refs name the token (presentation:town-hall), across the workspace's boards. */
|
|
305
307
|
export declare function tasksReferencing(token: string): Promise<LinkingTask[]>;
|
|
308
|
+
export declare function setCloudTaskContext(fn: (reference: string) => Promise<string>): void;
|
|
306
309
|
export declare function taskContext(reference: string): Promise<string>;
|
package/dist/core/boards.js
CHANGED
|
@@ -702,8 +702,8 @@ export async function appendTaskLog(ref, idOrNumber, entry, actor) {
|
|
|
702
702
|
return (await getTask(ref, t.slug));
|
|
703
703
|
}
|
|
704
704
|
export const EVENTS_FILE = "boards/events.jsonl";
|
|
705
|
-
/** Append an event for the server on this machine (board-wake.ts reads the file). Local run-state: never in git. */
|
|
706
|
-
async function emitTaskEvent(ev) {
|
|
705
|
+
/** Append an event for the server on this machine (board-wake.ts reads the file). Local run-state: never in git. Cloud tasks come in through server/cloud-events.ts. */
|
|
706
|
+
export async function emitTaskEvent(ev) {
|
|
707
707
|
const file = path.join(getOutputDir(), EVENTS_FILE);
|
|
708
708
|
await fs.mkdir(path.dirname(file), { recursive: true });
|
|
709
709
|
await fs.appendFile(file, `${JSON.stringify(ev)}\n`);
|
|
@@ -1026,7 +1026,21 @@ export async function tasksReferencing(token) {
|
|
|
1026
1026
|
}
|
|
1027
1027
|
return out;
|
|
1028
1028
|
}
|
|
1029
|
+
/**
|
|
1030
|
+
* The context block of a cloud-board task (`@board/3`): the server provides it
|
|
1031
|
+
* (server/cloud-events.ts), core cannot reach the cloud. Unset, such a task
|
|
1032
|
+
* says where to look.
|
|
1033
|
+
*/
|
|
1034
|
+
let cloudTaskContext = null;
|
|
1035
|
+
export function setCloudTaskContext(fn) {
|
|
1036
|
+
cloudTaskContext = fn;
|
|
1037
|
+
}
|
|
1029
1038
|
export async function taskContext(reference) {
|
|
1039
|
+
if (reference.startsWith("@")) {
|
|
1040
|
+
return cloudTaskContext
|
|
1041
|
+
? cloudTaskContext(reference)
|
|
1042
|
+
: `You were opened for task ${reference} on a cloud board. Read it with \`npx kraftwerk tasks show ${reference.split("/")[1]} --board ${reference.split("/")[0]}\`.`;
|
|
1043
|
+
}
|
|
1030
1044
|
const t = await findTask(reference);
|
|
1031
1045
|
if (!t)
|
|
1032
1046
|
return `You were opened for task ${reference}, but it does not exist any more (removed, or its board is gone). Tell the user.`;
|
package/dist/core/cloud.d.ts
CHANGED
|
@@ -82,6 +82,8 @@ export interface RegisterResponse {
|
|
|
82
82
|
/** The claiming account's uuid and handle (clouds before 0.97 send neither). */
|
|
83
83
|
accountId?: string | null;
|
|
84
84
|
accountHandle?: string | null;
|
|
85
|
+
/** Reported ws_ ids deleted in the cloud (clouds before 0.102 send none). */
|
|
86
|
+
deletedWorkspaces?: string[];
|
|
85
87
|
}
|
|
86
88
|
export interface HeartbeatResponse {
|
|
87
89
|
ok: boolean;
|
|
@@ -90,6 +92,9 @@ export interface HeartbeatResponse {
|
|
|
90
92
|
accountId?: string | null;
|
|
91
93
|
accountHandle?: string | null;
|
|
92
94
|
claimCode: string | null;
|
|
95
|
+
deletedWorkspaces?: string[];
|
|
96
|
+
/** Events waiting at /api/machines/events (clouds before 0.102 send none). */
|
|
97
|
+
events?: number;
|
|
93
98
|
}
|
|
94
99
|
/** A person the cloud vouches for: the account's uuid (the same on every machine), email and handle. */
|
|
95
100
|
export interface CloudUser {
|
package/dist/core/git.d.ts
CHANGED
|
@@ -21,7 +21,13 @@
|
|
|
21
21
|
* pushes commits that already exist to a branch that already tracks its
|
|
22
22
|
* upstream. It never creates a commit, never publishes a new branch and
|
|
23
23
|
* never forces.
|
|
24
|
-
* - A diverged branch is reported, never merged or rebased from here
|
|
24
|
+
* - A diverged branch is reported, never merged or rebased from here —
|
|
25
|
+
* except with `autosync: sync` (kraftwerk sync's default): there the timer
|
|
26
|
+
* also commits what changed under the synced roots, and a diverged branch
|
|
27
|
+
* is merged with the rule "the cloud wins": where both sides changed a
|
|
28
|
+
* file, the remote's version stays and this machine's lands beside it as
|
|
29
|
+
* `name.konflikt-<handle>.ext`, committed too, so nothing is lost and
|
|
30
|
+
* nobody has to resolve anything in a terminal (see syncNow).
|
|
25
31
|
*
|
|
26
32
|
* Every git call passes an argument array, so nothing reaches a shell, and
|
|
27
33
|
* every call is async with a timeout: git runs inside the single-threaded
|
|
@@ -33,7 +39,7 @@
|
|
|
33
39
|
/** Paths whose content is never shown or synced, whichever repo they sit in. */
|
|
34
40
|
export declare const DENY: RegExp[];
|
|
35
41
|
/** off = fetch only. pull = also fast-forward. push = fast-forward, then push what is ahead. */
|
|
36
|
-
export type Autosync = "off" | "pull" | "push";
|
|
42
|
+
export type Autosync = "off" | "pull" | "push" | "sync";
|
|
37
43
|
export interface GitFile {
|
|
38
44
|
/** Path relative to the repo root, which is what git speaks. */
|
|
39
45
|
path: string;
|
|
@@ -55,6 +61,14 @@ export interface GitStatus {
|
|
|
55
61
|
/** Configured or inferred upstream, absent when the branch tracks nothing. */
|
|
56
62
|
upstream?: string;
|
|
57
63
|
remote?: string;
|
|
64
|
+
/** Where the remote lives (`git remote get-url`), any credentials in it cut out; absent without a remote. */
|
|
65
|
+
remoteUrl?: string;
|
|
66
|
+
/**
|
|
67
|
+
* Who hosts the remote: "kraftwerk" (kraftwerk sync, the workspace's repo in
|
|
68
|
+
* kraftwerk cloud), "custom" (an own git provider — expert mode) or "none"
|
|
69
|
+
* (no remote yet). Set by the API, which knows the cloud.
|
|
70
|
+
*/
|
|
71
|
+
hosting?: "kraftwerk" | "custom" | "none";
|
|
58
72
|
ahead?: number;
|
|
59
73
|
behind?: number;
|
|
60
74
|
/** True when the branches have diverged, which needs a terminal. */
|
|
@@ -71,6 +85,21 @@ export interface GitStatus {
|
|
|
71
85
|
/** The last push that worked, by hand or in the background. */
|
|
72
86
|
lastPush?: string;
|
|
73
87
|
lastError?: string;
|
|
88
|
+
/** The last commit `autosync: sync` made by itself. */
|
|
89
|
+
lastAutoCommit?: string;
|
|
90
|
+
/**
|
|
91
|
+
* Copies `autosync: sync` kept beside the remote's version (on this machine
|
|
92
|
+
* or any other), read from the files themselves: they stay listed until
|
|
93
|
+
* someone deletes the copy. Newest first.
|
|
94
|
+
*/
|
|
95
|
+
conflicts?: SyncConflict[];
|
|
96
|
+
}
|
|
97
|
+
/** One file both sides changed: the remote's version is at `path`, the other side's at `copy`, kept for `by`. */
|
|
98
|
+
export interface SyncConflict {
|
|
99
|
+
path: string;
|
|
100
|
+
copy: string;
|
|
101
|
+
by: string;
|
|
102
|
+
at: string;
|
|
74
103
|
}
|
|
75
104
|
export interface GitDiff {
|
|
76
105
|
diff: string;
|
|
@@ -90,6 +119,8 @@ export declare function git(args: string[], cwd: string, timeoutMs?: number, env
|
|
|
90
119
|
export declare function sshCommandFor(repoRoot: string): Promise<string>;
|
|
91
120
|
/** A git call that may touch the network: longer timeout, non-interactive ssh. */
|
|
92
121
|
export declare function gitNet(args: string[], repoRoot: string): Promise<GitResult>;
|
|
122
|
+
export declare function setRemoteAuth(fn: () => Record<string, string>): void;
|
|
123
|
+
export declare function remoteAuthEnv(base?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
|
|
93
124
|
/**
|
|
94
125
|
* Pathspecs are globs by default, so a file called `note[1].md` would not
|
|
95
126
|
* match itself. `:(literal)` turns the pattern off.
|
|
@@ -109,6 +140,8 @@ export declare function parseStatus(out: string): {
|
|
|
109
140
|
* of times, and the nav badge polls it from every open tab, so results are
|
|
110
141
|
* cached for a beat.
|
|
111
142
|
*/
|
|
143
|
+
/** A remote URL fit to show: `https://user:secret@host/x` → `https://host/x`. */
|
|
144
|
+
export declare function withoutCredentials(url: string): string;
|
|
112
145
|
export declare function gitStatus(fresh?: boolean): Promise<GitStatus>;
|
|
113
146
|
/**
|
|
114
147
|
* Unified diff for one changed file. Reading is as sensitive as writing
|
|
@@ -133,6 +166,10 @@ export declare function gitCommit(paths: string[], message: string): Promise<{
|
|
|
133
166
|
error?: string;
|
|
134
167
|
committed?: number;
|
|
135
168
|
}>;
|
|
169
|
+
export declare function setSyncAuthor(fn: () => {
|
|
170
|
+
name: string;
|
|
171
|
+
email: string;
|
|
172
|
+
} | null): void;
|
|
136
173
|
export declare function gitFetch(): Promise<{
|
|
137
174
|
ok: boolean;
|
|
138
175
|
error?: string;
|
|
@@ -157,3 +194,10 @@ export declare function gitPush(): Promise<{
|
|
|
157
194
|
export declare function startGitSync(): void;
|
|
158
195
|
/** Stop the current workspace's background sync (the workspace closes). A tick in flight finishes, then stops. */
|
|
159
196
|
export declare function stopGitSync(): void;
|
|
197
|
+
/** `knowledge/a.konflikt-ben-2.md` → { path: knowledge/a.md, by: ben }, or null when it is not a copy. */
|
|
198
|
+
export declare function parseConflictCopy(copy: string): {
|
|
199
|
+
path: string;
|
|
200
|
+
by: string;
|
|
201
|
+
} | null;
|
|
202
|
+
/** `notes/preise.md` → `notes/preise.konflikt-anna.md`, numbered while taken. */
|
|
203
|
+
export declare function conflictPath(file: string, handle: string, taken: (p: string) => boolean): string;
|