@netnodeag/kraftwerk 0.76.0 → 0.78.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 +33 -27
- package/dist/cli/cloud.d.ts +2 -0
- package/dist/cli/cloud.js +262 -0
- package/dist/cli/daemon.js +9 -0
- package/dist/cli/doctor.js +16 -8
- package/dist/cli/init.js +2 -2
- package/dist/cli/invite.d.ts +2 -0
- package/dist/cli/invite.js +48 -0
- package/dist/cli/kraftwerk.js +7 -0
- package/dist/client/relay.d.ts +40 -0
- package/dist/client/relay.js +35 -0
- package/dist/client/routes.d.ts +5 -0
- package/dist/client/routes.js +5 -0
- package/dist/config.d.ts +15 -28
- package/dist/config.js +5 -19
- package/dist/core/chat/channel-turns.d.ts +2 -2
- package/dist/core/chat/channel-turns.js +2 -2
- package/dist/core/chat/sessions.d.ts +20 -3
- package/dist/core/chat/sessions.js +22 -7
- package/dist/core/chat/types.d.ts +21 -0
- package/dist/core/cloud.d.ts +152 -0
- package/dist/core/cloud.js +98 -0
- package/dist/core/routines.d.ts +22 -2
- package/dist/core/routines.js +26 -0
- package/dist/server/api/chats.js +45 -8
- package/dist/server/api/cloud.d.ts +86 -0
- package/dist/server/api/cloud.js +51 -0
- package/dist/server/api/devices.d.ts +15 -9
- package/dist/server/api/devices.js +3 -2
- package/dist/server/api/index.d.ts +108 -11
- package/dist/server/api/index.js +2 -0
- package/dist/server/api/router.d.ts +3 -2
- package/dist/server/api/router.js +12 -0
- package/dist/server/api/workspace.d.ts +16 -1
- package/dist/server/api/workspace.js +2 -1
- package/dist/server/cloud.d.ts +104 -33
- package/dist/server/cloud.js +279 -185
- package/dist/server/hub-context.d.ts +1 -1
- package/dist/server/hub-context.js +3 -3
- package/dist/server/members.d.ts +87 -0
- package/dist/server/members.js +117 -0
- package/dist/server/relay.d.ts +21 -1
- package/dist/server/relay.js +74 -3
- package/dist/server/server.d.ts +3 -2
- package/dist/server/server.js +13 -6
- package/dist/server/trust.d.ts +16 -0
- package/dist/server/trust.js +12 -1
- package/package.json +1 -1
- package/schema/kraftwerk.schema.json +4 -4
- package/web/dist/assets/{dist-T1sNLC62.js → dist-B-yVL5lk.js} +1 -1
- package/web/dist/assets/{dist-DFXmaDc5.js → dist-B9EMB1Ie.js} +1 -1
- package/web/dist/assets/{dist-BQpWYkxm.js → dist-BTc878j7.js} +1 -1
- package/web/dist/assets/{dist-fgB7OEJy.js → dist-C90kUzps.js} +1 -1
- package/web/dist/assets/{dist-l7foWlFx.js → dist-CpLdAqFQ.js} +1 -1
- package/web/dist/assets/{dist-flnLXEzU.js → dist-Crnb8VVO.js} +1 -1
- package/web/dist/assets/{dist-vuciRCSz.js → dist-D0rjnN8S.js} +1 -1
- package/web/dist/assets/{dist-BTVP-6On.js → dist-D4SDXoGw.js} +1 -1
- package/web/dist/assets/{dist-BwIca_Uj.js → dist-DHRhdODt.js} +1 -1
- package/web/dist/assets/{dist-BYkcY-Vl.js → dist-DQbifCX0.js} +1 -1
- package/web/dist/assets/dist-lSJ-O7kT.js +1 -0
- package/web/dist/assets/{editor-C6Ok8NPo.js → editor-DHAdW1g_.js} +3 -3
- package/web/dist/assets/{index-z4tpCCzk.js → index-D7JVAjll.js} +5 -5
- package/web/dist/index.html +1 -1
- package/web/dist-remote/sw.js +1 -1
- package/web/dist/assets/dist-BURf1l-A.js +0 -1
package/dist/server/cloud.d.ts
CHANGED
|
@@ -1,53 +1,124 @@
|
|
|
1
|
+
import { type Credentials, type CloudUrlSource, type InviteResponse } from "../core/cloud.js";
|
|
1
2
|
/**
|
|
2
|
-
* The
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
3
|
+
* The machine client: the daemon registers THIS MACHINE with the kraftwerk
|
|
4
|
+
* cloud once and heartbeats while it runs; the workspaces it serves ride
|
|
5
|
+
* along as children of that record (see core/cloud.ts for the contract and
|
|
6
|
+
* the settings). One per process, and only the daemon starts it
|
|
7
|
+
* (startMachineCloud from `kraftwerk daemon`): a standalone `kraftwerk ui`
|
|
8
|
+
* and test fixtures never talk to the cloud.
|
|
7
9
|
*
|
|
8
|
-
*
|
|
9
|
-
* ~/.kraftwerk/cloud
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
10
|
+
* start ensure the machine key (relay.json, relay stays off), drop the
|
|
11
|
+
* retired per-workspace identities (~/.kraftwerk/cloud/), and,
|
|
12
|
+
* unless cloud.json or KRAFTWERK_CLOUD_URL=off says no, register
|
|
13
|
+
* — anonymous: the answer carries a claim code until someone
|
|
14
|
+
* claims the machine (`kraftwerk login`, or the code in the UI)
|
|
15
|
+
* heartbeat every `interval` the cloud asked for; the workspace list rides
|
|
16
|
+
* along whenever it changed (opened, closed, vetoed, claimed).
|
|
17
|
+
* A claim made in the cloud arrives in the answer
|
|
18
|
+
* privacy while unclaimed, entries carry name/slug/ws-id only — no
|
|
19
|
+
* roots; once claimed, roots too, and the routines that ran
|
|
20
|
+
* here (`routines`, sent when it changed; private ones never)
|
|
21
|
+
* members the machine's credentials and the served workspaces are
|
|
22
|
+
* what member sessions over the relay are verified with
|
|
23
|
+
* (server/members.ts), and what `kraftwerk invite` asks the
|
|
24
|
+
* cloud with (createWorkspaceInvite)
|
|
25
|
+
* recovery a cloud that no longer knows the machine (data reset) gets a
|
|
26
|
+
* fresh registration; a cloud that is down is retried at the
|
|
27
|
+
* same cadence and never affects the UI
|
|
28
|
+
* goodbye on shutdown (bounded), and when `kraftwerk cloud off` reaches
|
|
29
|
+
* the running daemon
|
|
16
30
|
*/
|
|
17
31
|
export type CloudState = "off" | "connecting" | "connected" | "error";
|
|
18
32
|
export interface CloudStatus {
|
|
19
33
|
url: string;
|
|
20
34
|
state: CloudState;
|
|
21
|
-
/**
|
|
35
|
+
/** Why it is off, when it is. */
|
|
36
|
+
reason?: string;
|
|
37
|
+
/** Where the URL came from (env, cloud.json, a deprecated kraftwerk.yml cloud.url, the default). */
|
|
38
|
+
source?: CloudUrlSource;
|
|
39
|
+
/** Last error message while registering or heartbeating. */
|
|
22
40
|
error?: string;
|
|
23
|
-
/**
|
|
41
|
+
/** The machine's id in the cloud (its relay id). */
|
|
24
42
|
id?: string;
|
|
25
|
-
/**
|
|
43
|
+
/** This machine's handle@machine. */
|
|
44
|
+
machine?: string;
|
|
45
|
+
/** Email of the account that claimed the machine; null while unclaimed. */
|
|
26
46
|
account?: string | null;
|
|
27
|
-
/** Effective seconds between heartbeats (the cloud
|
|
47
|
+
/** Effective seconds between heartbeats (what the cloud asked for). */
|
|
28
48
|
interval?: number;
|
|
49
|
+
/** Last successful register or heartbeat. */
|
|
29
50
|
lastSeen?: string;
|
|
30
|
-
/** XXXX-XXXX
|
|
51
|
+
/** XXXX-XXXX that claims this machine in the cloud; null once claimed. */
|
|
31
52
|
claimCode?: string | null;
|
|
32
|
-
/** The cloud page that claims this
|
|
53
|
+
/** The cloud page that claims this machine after sign-in. */
|
|
33
54
|
claimUrl?: string | null;
|
|
55
|
+
/** Workspaces reported (vetoed ones left out). */
|
|
56
|
+
workspaces?: number;
|
|
34
57
|
}
|
|
58
|
+
/** What the daemon serves right now; `ws` runs code inside that workspace (the routine report reads its state). */
|
|
59
|
+
export type WorkspaceSource = () => Array<{
|
|
60
|
+
root: string;
|
|
61
|
+
slug: string;
|
|
62
|
+
name: string;
|
|
63
|
+
ws?: {
|
|
64
|
+
run<T>(fn: () => T): T;
|
|
65
|
+
};
|
|
66
|
+
}>;
|
|
35
67
|
export declare const cloudStatus: () => CloudStatus;
|
|
36
68
|
/**
|
|
37
|
-
* Start the client
|
|
38
|
-
*
|
|
39
|
-
* own afterwards.
|
|
69
|
+
* Start the machine client (the daemon, once its workspaces are open).
|
|
70
|
+
* Resolves after the first registration attempt; the heartbeat runs on its
|
|
71
|
+
* own afterwards. A second start in the same process is ignored.
|
|
72
|
+
*/
|
|
73
|
+
export declare function startMachineCloud(opts: {
|
|
74
|
+
version: string;
|
|
75
|
+
workspaces: WorkspaceSource;
|
|
76
|
+
owner?: unknown;
|
|
77
|
+
}): Promise<CloudStatus>;
|
|
78
|
+
/**
|
|
79
|
+
* Settings changed (`kraftwerk cloud on|off`, a URL): turn the client on or
|
|
80
|
+
* off to match; off says goodbye first. Without a started client (a
|
|
81
|
+
* standalone server) nothing happens.
|
|
82
|
+
*/
|
|
83
|
+
export declare function applyMachineCloud(): Promise<CloudStatus>;
|
|
84
|
+
/** A round now (the CLI's `login` waits for a claim): registers when needed, else heartbeats. */
|
|
85
|
+
export declare function syncMachineCloud(): Promise<CloudStatus>;
|
|
86
|
+
/** Release the claim (`kraftwerk logout`): the cloud hands out a fresh claim code. */
|
|
87
|
+
export declare function unlinkMachineCloud(): Promise<CloudStatus>;
|
|
88
|
+
/**
|
|
89
|
+
* Stop the client and tell the cloud the machine is going away (bounded:
|
|
90
|
+
* an exit handler waits for this). `owner`: only the client that owner
|
|
91
|
+
* started (a hub stopping in a test leaves another's alone).
|
|
92
|
+
*/
|
|
93
|
+
export declare function stopMachineCloud(owner?: unknown): Promise<void>;
|
|
94
|
+
/**
|
|
95
|
+
* What member verification needs (server/members.ts): the cloud's origin,
|
|
96
|
+
* this machine's credentials. Null when no machine client runs (a
|
|
97
|
+
* standalone server, the cloud turned off).
|
|
40
98
|
*/
|
|
41
|
-
export declare function
|
|
42
|
-
|
|
43
|
-
|
|
99
|
+
export declare function machineLink(): {
|
|
100
|
+
url: string;
|
|
101
|
+
creds: Credentials;
|
|
102
|
+
version: string;
|
|
103
|
+
} | null;
|
|
104
|
+
/** The served workspace whose kraftwerk.yml `id` is `id` (vetoed ones not), or null. */
|
|
105
|
+
export declare function servedWorkspace(id: string): Promise<{
|
|
106
|
+
slug: string;
|
|
107
|
+
name: string;
|
|
108
|
+
root: string;
|
|
109
|
+
} | null>;
|
|
44
110
|
/**
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
111
|
+
* An invite to a served workspace (`kraftwerk invite`): the cloud's machine
|
|
112
|
+
* path, so only a claimed machine that reports the workspace gets one.
|
|
113
|
+
* `which` is the workspace's slug or root.
|
|
48
114
|
*/
|
|
49
|
-
export declare function
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
115
|
+
export declare function createWorkspaceInvite(which: {
|
|
116
|
+
slug?: string;
|
|
117
|
+
root?: string;
|
|
118
|
+
}, role?: "owner" | "member"): Promise<InviteResponse & {
|
|
119
|
+
workspace: {
|
|
120
|
+
id: string;
|
|
121
|
+
slug: string;
|
|
122
|
+
name: string;
|
|
123
|
+
};
|
|
124
|
+
}>;
|