clavarium 0.2.396-next.1 → 0.2.398-next.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/config/tools.json +44 -0
- package/npm-shrinkwrap.json +6 -6
- package/package.json +2 -2
- package/server/api.mjs +15 -0
- package/server/apikeys.mjs +4 -0
- package/server/conversations.mjs +55 -0
- package/server/settingswords.mjs +3 -0
- package/server/tools.mjs +12 -1
- package/web/app.js +19 -0
- package/web/index.html +7 -0
package/config/tools.json
CHANGED
|
@@ -12,6 +12,16 @@
|
|
|
12
12
|
"--continue"
|
|
13
13
|
],
|
|
14
14
|
"memoryMb": 2048,
|
|
15
|
+
"state": {
|
|
16
|
+
"keep": [
|
|
17
|
+
".claude",
|
|
18
|
+
".claude.json"
|
|
19
|
+
],
|
|
20
|
+
"skip": [
|
|
21
|
+
".claude/shell-snapshots",
|
|
22
|
+
".claude/statsig"
|
|
23
|
+
]
|
|
24
|
+
},
|
|
15
25
|
"rights": {
|
|
16
26
|
"full": [
|
|
17
27
|
"--dangerously-skip-permissions",
|
|
@@ -76,6 +86,15 @@
|
|
|
76
86
|
"--continue"
|
|
77
87
|
],
|
|
78
88
|
"memoryMb": 2048,
|
|
89
|
+
"state": {
|
|
90
|
+
"keep": [
|
|
91
|
+
".config/opencode",
|
|
92
|
+
".local/share/opencode"
|
|
93
|
+
],
|
|
94
|
+
"skip": [
|
|
95
|
+
".local/share/opencode/log"
|
|
96
|
+
]
|
|
97
|
+
},
|
|
79
98
|
"rights": {
|
|
80
99
|
"full": [
|
|
81
100
|
"--auto"
|
|
@@ -156,6 +175,14 @@
|
|
|
156
175
|
"--last"
|
|
157
176
|
],
|
|
158
177
|
"memoryMb": 2048,
|
|
178
|
+
"state": {
|
|
179
|
+
"keep": [
|
|
180
|
+
".codex"
|
|
181
|
+
],
|
|
182
|
+
"skip": [
|
|
183
|
+
".codex/log"
|
|
184
|
+
]
|
|
185
|
+
},
|
|
159
186
|
"rights": {
|
|
160
187
|
"full": [
|
|
161
188
|
"--dangerously-bypass-approvals-and-sandbox"
|
|
@@ -190,6 +217,11 @@
|
|
|
190
217
|
"--continue"
|
|
191
218
|
],
|
|
192
219
|
"memoryMb": 2048,
|
|
220
|
+
"state": {
|
|
221
|
+
"keep": [
|
|
222
|
+
".vibe"
|
|
223
|
+
]
|
|
224
|
+
},
|
|
193
225
|
"rights": {
|
|
194
226
|
"full": [
|
|
195
227
|
"--auto-approve"
|
|
@@ -246,6 +278,11 @@
|
|
|
246
278
|
"latest"
|
|
247
279
|
],
|
|
248
280
|
"memoryMb": 2048,
|
|
281
|
+
"state": {
|
|
282
|
+
"keep": [
|
|
283
|
+
".gemini"
|
|
284
|
+
]
|
|
285
|
+
},
|
|
249
286
|
"rights": {
|
|
250
287
|
"full": [
|
|
251
288
|
"--yolo",
|
|
@@ -275,6 +312,13 @@
|
|
|
275
312
|
"-l"
|
|
276
313
|
],
|
|
277
314
|
"memoryMb": 768,
|
|
315
|
+
"state": {
|
|
316
|
+
"keep": [
|
|
317
|
+
".bash_history",
|
|
318
|
+
".bashrc",
|
|
319
|
+
".profile"
|
|
320
|
+
]
|
|
321
|
+
},
|
|
278
322
|
"install": []
|
|
279
323
|
}
|
|
280
324
|
]
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.398-next.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "clavarium",
|
|
9
|
-
"version": "0.2.
|
|
9
|
+
"version": "0.2.398-next.1",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"clavarium-binder": "0.1.62-next.1",
|
|
15
15
|
"clavarium-docket": "0.1.2-next.2",
|
|
16
16
|
"clavarium-parley": "0.17.91-next.1",
|
|
17
|
-
"clavarium-tether": "0.1.0-next.
|
|
17
|
+
"clavarium-tether": "0.1.0-next.66",
|
|
18
18
|
"mammoth": "1.13.0",
|
|
19
19
|
"mermaid": "11.17.2",
|
|
20
20
|
"node-pty": "^1.1.0",
|
|
@@ -800,9 +800,9 @@
|
|
|
800
800
|
}
|
|
801
801
|
},
|
|
802
802
|
"node_modules/clavarium-tether": {
|
|
803
|
-
"version": "0.1.0-next.
|
|
804
|
-
"resolved": "https://registry.npmjs.org/clavarium-tether/-/clavarium-tether-0.1.0-next.
|
|
805
|
-
"integrity": "sha512-
|
|
803
|
+
"version": "0.1.0-next.66",
|
|
804
|
+
"resolved": "https://registry.npmjs.org/clavarium-tether/-/clavarium-tether-0.1.0-next.66.tgz",
|
|
805
|
+
"integrity": "sha512-Q1XPq+wVlZEOPuFNsHm9cATbAsVbr1QObIPa9u6e9V1KhMb1tGPpFsuU15jIflRa6tD/XaZo4VCrUtd1o8iz/w==",
|
|
806
806
|
"license": "MIT",
|
|
807
807
|
"bin": {
|
|
808
808
|
"tether": "bin/cli.mjs",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.398-next.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "A conversation is a VM with a terminal in it. Everything else is a folder.",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"clavarium-binder": "0.1.62-next.1",
|
|
49
49
|
"clavarium-docket": "0.1.2-next.2",
|
|
50
50
|
"clavarium-parley": "0.17.91-next.1",
|
|
51
|
-
"clavarium-tether": "0.1.0-next.
|
|
51
|
+
"clavarium-tether": "0.1.0-next.66",
|
|
52
52
|
"mammoth": "1.13.0",
|
|
53
53
|
"mermaid": "11.17.2",
|
|
54
54
|
"node-pty": "^1.1.0",
|
package/server/api.mjs
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* POST /api/conversations {name, tool, memoryMb?}
|
|
7
7
|
* POST /api/conversations/<name>/sleep
|
|
8
8
|
* POST /api/conversations/<name>/restart a clean stop (by force if it hangs), then a start
|
|
9
|
+
* GET /api/conversations/<name>/export its tool's state, one archive (#351) POST .../import put back (same tool)
|
|
9
10
|
* POST /api/conversations/<name>/machine {memoryMb?, diskGb?, cpus?}: stopped, set, started again (202);
|
|
10
11
|
* asleep: checked and kept for its wake, as `sizeAtWake` (200)
|
|
11
12
|
* POST /api/conversations/<name>/machine {action: start|stop|restart|sleep|force|force-now}: done on its machine,
|
|
@@ -292,6 +293,20 @@ export async function handleApi(request, response, conversations, headers, resou
|
|
|
292
293
|
}
|
|
293
294
|
return send(201, await importFile(attached('write'), query.get('p') ?? '', query.get('name') ?? '', request, { exists: query.get('exists') ?? 'keep', dir: query.get('dir') ?? '', batch: query.get('batch') ?? undefined })), true;
|
|
294
295
|
}
|
|
296
|
+
/* A CONVERSATION CARRIED ELSEWHERE (#351): its tool's state as one archive, streamed from its machine;
|
|
297
|
+
put back into a conversation of the same tool. Downloaded and sent by the person, from the page. */
|
|
298
|
+
const carry = /^\/api\/conversations\/([^/]+)\/(export|import)$/.exec(pathname);
|
|
299
|
+
if (carry && request.method === 'GET' && carry[2] === 'export') {
|
|
300
|
+
const out = await conversations.exportState(decodeURIComponent(carry[1]));
|
|
301
|
+
response.writeHead(200, { ...headers, 'content-type': 'application/gzip', 'content-disposition': `attachment; filename*=UTF-8''${encodeURIComponent(out.name)}` });
|
|
302
|
+
out.stream.pipe(response);
|
|
303
|
+
response.on('close', () => { try { out.child?.kill(); } catch { /* ended */ } });
|
|
304
|
+
return true;
|
|
305
|
+
}
|
|
306
|
+
if (carry && request.method === 'POST' && carry[2] === 'import') {
|
|
307
|
+
if (!originOk(request.headers) || request.headers['content-type'] !== 'application/octet-stream') return send(403, { error: 'This request does not come from this site.' }), true;
|
|
308
|
+
return send(200, await conversations.importState(decodeURIComponent(carry[1]), request)), true;
|
|
309
|
+
}
|
|
295
310
|
if (pathname.startsWith('/api/files/')) {
|
|
296
311
|
if (request.method === 'POST' && !originOk(request.headers)) return send(403, { error: 'This request does not come from this site.' }), true;
|
|
297
312
|
const answer = await changeRoute(request.method, pathname.slice('/api'.length), query, request, attached);
|
package/server/apikeys.mjs
CHANGED
|
@@ -1097,6 +1097,9 @@ export async function handleExternal(request, response, { keys, status, chats =
|
|
|
1097
1097
|
try { id = keys.check(request.headers.authorization); } catch (error) { return refused(error, '/mcp'); }
|
|
1098
1098
|
let text = '';
|
|
1099
1099
|
for await (const piece of request) { text += piece; if (text.length > MCP_BODY_MAX) { note(id, 413, '/mcp'); return send(413, { error: 'Too long.' }); } }
|
|
1100
|
+
/* A protocol version said in the header, and none spoken here: refused, as the spec asks (none said: the oldest assumed). */
|
|
1101
|
+
const said = request.headers['mcp-protocol-version'];
|
|
1102
|
+
if (typeof said === 'string' && said && !MCP_VERSIONS.includes(said)) { note(id, 400, '/mcp'); return send(400, { jsonrpc: '2.0', id: null, error: { code: -32600, message: `Unsupported MCP-Protocol-Version: ${said.slice(0, 20)} (spoken: ${MCP_VERSIONS.join(', ')})` } }); }
|
|
1100
1103
|
let msg;
|
|
1101
1104
|
try { msg = JSON.parse(text); } catch { note(id, 400, '/mcp'); return send(400, { jsonrpc: '2.0', id: null, error: { code: -32700, message: 'Parse error' } }); }
|
|
1102
1105
|
if (!msg || typeof msg !== 'object' || Array.isArray(msg) || msg.jsonrpc !== '2.0' || typeof msg.method !== 'string') {
|
|
@@ -1174,6 +1177,7 @@ export async function handleExternal(request, response, { keys, status, chats =
|
|
|
1174
1177
|
if (!(error instanceof Refusal)) throw error;
|
|
1175
1178
|
/* Not given: refused as the API refuses it (too many, too). Anything else is the tool's own failure, said to the caller. */
|
|
1176
1179
|
if (error.status === 429) { note(id, 429, what); return send(429, { jsonrpc: '2.0', id: msg.id, error: { code: -32002, message: error.message } }, { 'retry-after': String(error.retry ?? 60) }); }
|
|
1180
|
+
/* (An HTTP 403 for a scope not given is what the MCP authorization spec says: kept, MCP review 11-11.) */
|
|
1177
1181
|
if (error.status === 403) { note(id, 403, what); return send(403, { jsonrpc: '2.0', id: msg.id, error: { code: -32001, message: error.message } }); }
|
|
1178
1182
|
note(id, error.status, what);
|
|
1179
1183
|
return send(200, { jsonrpc: '2.0', id: msg.id, result: { content: [{ type: 'text', text: error.message }], isError: true } });
|
package/server/conversations.mjs
CHANGED
|
@@ -13,6 +13,7 @@ import { WORK, VM_USER, SHARING_STEP, stepLine } from './vm.mjs';
|
|
|
13
13
|
import { resumeOrFresh } from './tools.mjs';
|
|
14
14
|
import { TOOLS_PATH, LAUNCH } from './toolbox.mjs';
|
|
15
15
|
import { availableParallelism } from 'node:os';
|
|
16
|
+
import { spawn } from 'node:child_process';
|
|
16
17
|
|
|
17
18
|
export const SESSION = 'main';
|
|
18
19
|
export const STOP_DELAY_MS = 60_000;
|
|
@@ -825,6 +826,60 @@ export class Conversations {
|
|
|
825
826
|
return true;
|
|
826
827
|
}
|
|
827
828
|
|
|
829
|
+
/* CARRIED ELSEWHERE (11-11, #351): what the conversation is beyond /work -- its tool's state, where its
|
|
830
|
+
entry in config/tools.json says it is (`state.keep`, without `state.skip`) -- as one .tar.gz streamed
|
|
831
|
+
from its machine, a manifest first (clavarium-conversation.json: its tool, its name, its size). Nothing
|
|
832
|
+
of the tool is known here: any tool that says where its state is can be exported, imported, moved.
|
|
833
|
+
The machine must run (its home is in it). -> { name: the file's name, stream } */
|
|
834
|
+
async exportState(name) {
|
|
835
|
+
const c = this.#store.get(name);
|
|
836
|
+
if (!c) throw new Refusal(404, 'No such conversation.');
|
|
837
|
+
const tool = this.#tools.find((t) => t.id === c.tool);
|
|
838
|
+
if (!tool?.state) throw new Refusal(409, `${tool?.label ?? c.tool} does not say where it keeps its state: it cannot be exported.`);
|
|
839
|
+
if ((await this.#vms.state(name).catch(() => undefined)) !== 'Running') throw new Refusal(409, 'Its machine is not running: open the conversation first.', { retry: false });
|
|
840
|
+
const manifest = JSON.stringify({ kind: 'clavarium-conversation', version: 1, tool: c.tool, name: c.name, ...(c.title ? { title: c.title } : {}), memoryMb: c.memoryMb, cpus: c.cpus ?? 1, diskGb: c.diskGb ?? DISK_GB, at: new Date().toISOString() });
|
|
841
|
+
/* In its machine: the manifest written aside, then one archive -- the manifest first, then what is kept
|
|
842
|
+
(a path it has not made yet left out), the cache left out. */
|
|
843
|
+
/* (Its paths are plain -- letters, digits, . _ / - -- checked by tools.mjs: given as words.) */
|
|
844
|
+
const script = 'set -e; m=$(mktemp -d); printf "%s" "$1" > "$m/clavarium-conversation.json"; '
|
|
845
|
+
+ 'ex=""; for a in $2; do ex="$ex --exclude=./$a"; done; ks=""; for a in $3; do if [ -e "$HOME/$a" ]; then ks="$ks ./$a"; fi; done; '
|
|
846
|
+
+ 'tar -czf - -C "$m" clavarium-conversation.json -C "$HOME" $ex $ks; rm -rf "$m"';
|
|
847
|
+
const argv = this.#vms.execArgv(name, ['sh', '-c', script, 'export', manifest, tool.state.skip.join(' '), tool.state.keep.join(' ')]);
|
|
848
|
+
const child = spawn(argv[0], argv.slice(1), { stdio: ['ignore', 'pipe', 'ignore'] });
|
|
849
|
+
return { name: `${name}-${new Date().toISOString().slice(0, 10)}.clavarium.tar.gz`, stream: child.stdout, child };
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
/* PUT BACK an exported state in this conversation (same tool): its tool stopped, the archive unpacked in
|
|
853
|
+
its home, its tool started again, taking up its last session. -> { tool, from } */
|
|
854
|
+
async importState(name, input) {
|
|
855
|
+
const c = this.#busyCheck(name);
|
|
856
|
+
const tool = this.#tools.find((t) => t.id === c.tool);
|
|
857
|
+
if (!tool?.state) throw new Refusal(409, `${tool?.label ?? c.tool} does not say where it keeps its state: nothing can be imported in it.`);
|
|
858
|
+
if ((await this.#vms.state(name).catch(() => undefined)) !== 'Running') throw new Refusal(409, 'Its machine is not running: open the conversation first.', { retry: false });
|
|
859
|
+
this.drop(name);
|
|
860
|
+
await this.#vms.exec(name, ['tmux', '-L', SOCKET, 'kill-server'], { timeoutMs: 10_000 }).catch(() => {});
|
|
861
|
+
/* Unpacked aside first: its manifest read, its tool checked; then moved into the home. */
|
|
862
|
+
/* Aside in the home itself (never /tmp, which may be memory): then each part moved in place of the old. */
|
|
863
|
+
const script = 'set -e; m=$(mktemp -d "$HOME/.clavarium-import.XXXXXX"); trap \'rm -rf "$m"\' EXIT; tar -xzf - -C "$m"; '
|
|
864
|
+
+ 'grep -q "\\"kind\\":\\"clavarium-conversation\\"" "$m/clavarium-conversation.json" || { echo "not an exported conversation" >&2; exit 3; }; '
|
|
865
|
+
+ 'grep -q "\\"tool\\":\\"$1\\"" "$m/clavarium-conversation.json" || { echo "another tool" >&2; exit 4; }; '
|
|
866
|
+
+ 'cat "$m/clavarium-conversation.json"; rm -f "$m/clavarium-conversation.json"; '
|
|
867
|
+
+ 'for e in "$m"/.[!.]* "$m"/*; do if [ ! -e "$e" ]; then continue; fi; b=$(basename "$e"); rm -rf "$HOME/$b"; mv "$e" "$HOME/$b"; done';
|
|
868
|
+
const argv = this.#vms.execArgv(name, ['sh', '-c', script, 'import', c.tool]);
|
|
869
|
+
const child = spawn(argv[0], argv.slice(1), { stdio: ['pipe', 'pipe', 'pipe'] });
|
|
870
|
+
const out = []; const err = [];
|
|
871
|
+
child.stdout.on('data', (d) => out.push(d)); child.stderr.on('data', (d) => err.push(d));
|
|
872
|
+
input.pipe(child.stdin);
|
|
873
|
+
child.stdin.on('error', () => { /* it stopped reading: said below */ });
|
|
874
|
+
const code = await new Promise((ok) => child.on('close', ok));
|
|
875
|
+
this.ready(name);
|
|
876
|
+
if (code === 3) throw new Refusal(400, 'This is not an exported conversation.');
|
|
877
|
+
if (code === 4) throw new Refusal(400, `This export is of another tool: import it into a conversation with that tool.`);
|
|
878
|
+
if (code !== 0) throw new Refusal(502, `Not imported: ${firstLine(Buffer.concat(err).toString()) || `exit ${code}`}`);
|
|
879
|
+
let from = null; try { from = JSON.parse(Buffer.concat(out).toString()); } catch { /* said nothing */ }
|
|
880
|
+
return { tool: c.tool, from: from ? { name: from.name, at: from.at } : null };
|
|
881
|
+
}
|
|
882
|
+
|
|
828
883
|
async #fixup(name, tool) {
|
|
829
884
|
for (const step of tool.fixups) {
|
|
830
885
|
const r = await this.#vms.exec(name, step.argv, { timeoutMs: 120_000 }).catch(() => ({ code: 1 }));
|
package/server/settingswords.mjs
CHANGED
|
@@ -159,6 +159,9 @@ export const SETTINGS_WORDS_FR = {
|
|
|
159
159
|
'set-na-k-mcp': 'Serveur MCP', 'set-cx-mcp': 'serveur MCP',
|
|
160
160
|
'set-mcp-head': 'Ajouter un serveur MCP', 'set-mcp-hint': 'Ses outils pour vos IA ; la clé reste ici.',
|
|
161
161
|
'set-mcp-name': 'Nom', 'set-mcp-url': 'Adresse', 'set-mcp-key': 'Clé', 'set-mcp-add': 'Ajouter',
|
|
162
|
+
'set-carry': 'La mémoire de son outil', 'set-carry-hint': 'Mémoire, sessions, réglages : à emporter.',
|
|
163
|
+
'set-carry-export': 'Exporter', 'set-carry-import': 'Importer…', 'set-carry-go': 'Importer',
|
|
164
|
+
'set-carry-ask': '« {file} » dans « {name} » ? Mémoire remplacée.', 'set-carry-done': 'Importé depuis « {from} ».',
|
|
162
165
|
'set-mcp-drop': 'Collez ici la configuration du service', 'set-mcp-drop-hint': 'le bloc { "mcpServers": … } de sa page d\'aide',
|
|
163
166
|
'set-mcp-hand': 'Remplir à la main', 'set-mcp-add-n': 'Ajouter les {n}', 'set-mcp-nokey': 'aucune',
|
|
164
167
|
'set-mcp-notjson': 'Pas du JSON : collez tout le bloc.',
|
package/server/tools.mjs
CHANGED
|
@@ -100,13 +100,24 @@ export function readTools(text) {
|
|
|
100
100
|
if (t.instructions !== undefined && !INSTRUCTIONS.test(t.instructions)) throw new Error(`${t.id}: instructions is a relative path in the home, without ".."`);
|
|
101
101
|
/* Where the tool keeps its own log, read when it ends (why it stopped): folders relative to the home. */
|
|
102
102
|
if (t.logs !== undefined && (!Array.isArray(t.logs) || t.logs.some((d) => typeof d !== 'string' || !/^[A-Za-z0-9._/-]+$/.test(d) || d.startsWith('/') || d.split('/').includes('..')))) throw new Error(`${t.id}: logs is a list of folders relative to the home, without ".."`);
|
|
103
|
+
/* Optional: WHERE IT KEEPS ITS STATE (11-11, #351), relative to the home -- its memory, its sessions, its
|
|
104
|
+
settings, what a conversation is beyond /work: `keep`, the paths to carry when the conversation is
|
|
105
|
+
exported, imported or moved; `skip`, paths inside them that are only cache. Clavarium carries them for
|
|
106
|
+
any tool, with no case of its own. */
|
|
107
|
+
let state;
|
|
108
|
+
if (t.state !== undefined) {
|
|
109
|
+
const rel = (list) => Array.isArray(list) && list.every((d) => typeof d === 'string' && /^[A-Za-z0-9._/-]+$/.test(d) && !d.startsWith('/') && !d.split('/').includes('..') && d !== '.');
|
|
110
|
+
if (!t.state || typeof t.state !== 'object' || !rel(t.state.keep) || t.state.keep.length === 0 || (t.state.skip !== undefined && !rel(t.state.skip))) throw new Error(`${t.id}: state needs "keep", paths relative to the home without "..", and may have "skip"`);
|
|
111
|
+
if ((t.state.skip ?? []).some((d) => !t.state.keep.some((k) => d === k || d.startsWith(`${k}/`)))) throw new Error(`${t.id}: state "skip" names paths inside "keep"`);
|
|
112
|
+
state = Object.freeze({ keep: Object.freeze([...t.state.keep]), skip: Object.freeze([...(t.state.skip ?? [])]) });
|
|
113
|
+
}
|
|
103
114
|
/* Optional: ITS LAUNCHER, a script of config/launch shown at /tools/launch: run at each start,
|
|
104
115
|
given the rights chosen (full, ask) then the command; it sets what the tool needs,
|
|
105
116
|
then runs it. Clavarium knows nothing more of the tool. */
|
|
106
117
|
if (t.launch !== undefined && !/^[a-z][a-z0-9-]{0,40}\.sh$/.test(t.launch)) throw new Error(`${t.id}: launch is the name of a script of config/launch, such as "${t.id}.sh"`);
|
|
107
118
|
/* Repairs an existing machine is given once (see FIXES in conversations.mjs). */
|
|
108
119
|
const fixups = t.install.includes('npm-writable') ? NPM_WRITABLE : [];
|
|
109
|
-
return Object.freeze({ id: t.id, label: t.label, ...(t.instructions ? { instructions: t.instructions } : {}), ...(t.logs ? { logs: Object.freeze([...t.logs]) } : {}), command: Object.freeze([...t.command]), ...(t.launch ? { launch: t.launch } : {}), ...(t.resume ? { resume: Object.freeze([...t.resume]) } : {}), memoryMb: t.memoryMb, ...(rights ? { rights } : {}), steps: Object.freeze(steps), fixups: Object.freeze(fixups), signin });
|
|
120
|
+
return Object.freeze({ id: t.id, label: t.label, ...(t.instructions ? { instructions: t.instructions } : {}), ...(t.logs ? { logs: Object.freeze([...t.logs]) } : {}), ...(state ? { state } : {}), command: Object.freeze([...t.command]), ...(t.launch ? { launch: t.launch } : {}), ...(t.resume ? { resume: Object.freeze([...t.resume]) } : {}), memoryMb: t.memoryMb, ...(rights ? { rights } : {}), steps: Object.freeze(steps), fixups: Object.freeze(fixups), signin });
|
|
110
121
|
});
|
|
111
122
|
}
|
|
112
123
|
|
package/web/app.js
CHANGED
|
@@ -2574,6 +2574,25 @@
|
|
|
2574
2574
|
catch (error) { show(error.message, 'Back to the terminal', enter); }
|
|
2575
2575
|
}, () => { notice.hidden = true; focusTerminal(); });
|
|
2576
2576
|
};
|
|
2577
|
+
/* Its tool's memory, exported as one file, or put back from one (#351): the person's own act, from here. */
|
|
2578
|
+
$('carry-box').hidden = DEVICE || !here;
|
|
2579
|
+
$('carry-export').href = `${API}/conversations/${encodeURIComponent(current)}/export`;
|
|
2580
|
+
$('carry-import').onclick = () => $('carry-file').click();
|
|
2581
|
+
$('carry-file').onchange = () => {
|
|
2582
|
+
const file = $('carry-file').files?.[0]; $('carry-file').value = '';
|
|
2583
|
+
if (!file) return;
|
|
2584
|
+
const name = current;
|
|
2585
|
+
leavePanel();
|
|
2586
|
+
show(uiSaid('set-carry-ask', '« {file} » into « {name} »? Its memory is replaced.', { file: file.name, name }),
|
|
2587
|
+
uiSaid('set-carry-go', 'Import'), async () => {
|
|
2588
|
+
try {
|
|
2589
|
+
const r = await fetch(`${API}/conversations/${encodeURIComponent(name)}/import`, { method: 'POST', headers: { 'content-type': 'application/octet-stream' }, body: file });
|
|
2590
|
+
const said = await r.json().catch(() => ({}));
|
|
2591
|
+
if (!r.ok) throw new Error(said.error ?? `HTTP ${r.status}`);
|
|
2592
|
+
show(uiSaid('set-carry-done', 'Imported from « {from} ».', { from: said.from?.name ?? file.name }), 'OK', () => { notice.hidden = true; focusTerminal(); });
|
|
2593
|
+
} catch (error) { show(error.message, 'Back to the terminal', enter); }
|
|
2594
|
+
}, () => { notice.hidden = true; focusTerminal(); });
|
|
2595
|
+
};
|
|
2577
2596
|
void paintAnswerer(); paintWakeups(); void paintTalkBox(); void paintShareHere();
|
|
2578
2597
|
paintMachine(here);
|
|
2579
2598
|
void paintGuide(here);
|
package/web/index.html
CHANGED
|
@@ -231,6 +231,13 @@
|
|
|
231
231
|
<p id="work-moved" class="hint" hidden></p>
|
|
232
232
|
<button type="button" id="work-move"></button>
|
|
233
233
|
</div>
|
|
234
|
+
<!-- CARRIED ELSEWHERE (#351): its tool's state (memory, sessions, settings) as one file; put back here. -->
|
|
235
|
+
<div id="carry-box">
|
|
236
|
+
<div class="panel-top"><b data-said="set-carry">Its tool's memory</b></div>
|
|
237
|
+
<p class="hint" data-said="set-carry-hint">Memory, sessions, settings: to take elsewhere.</p>
|
|
238
|
+
<div class="row"><a id="carry-export" class="button" download data-said="set-carry-export">Export</a><button type="button" id="carry-import" data-said="set-carry-import">Import...</button><input type="file" id="carry-file" accept=".gz,application/gzip" hidden></div>
|
|
239
|
+
<p id="carry-said" class="hint" role="status" hidden></p>
|
|
240
|
+
</div>
|
|
234
241
|
<!-- WHEN ITS MACHINE IS SHORT (server/healthreact.mjs): you are told either way. -->
|
|
235
242
|
<form id="react-box" autocomplete="off">
|
|
236
243
|
<div class="panel-top"><b>When its machine is short of room or memory</b></div>
|