robisie 0.6.10 → 0.6.12
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 +21 -0
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +1 -1
- package/dist/engine/build-id.json +1 -1
- package/dist/engine/bundle-report.json +1 -1
- package/dist/engine/tick.cjs +1 -1
- package/dist/installation-update.d.ts +1 -0
- package/dist/installation-update.js +184 -55
- package/dist/roles.d.ts +1 -1
- package/docs/README.en.md +2 -1
- package/docs/README.md +2 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# Historia zmian klienta / Client changelog
|
|
2
2
|
|
|
3
|
+
## [0.6.12](https://github.com/chuppa12/robisie-app/compare/client-v0.6.11...client-v0.6.12) (2026-11-19)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Factory Cards
|
|
7
|
+
|
|
8
|
+
* Komenda update odracza bez alarmu, gdy claim Testera lub odbiorcy jest młodszy niż 10 minut i czeka na rozliczenie przez takt; odmowa z alarmem zostaje dla claima osieroconego ([6e57f12](https://github.com/chuppa12/robisie-app/commit/6e57f12ef352c766074e24a8073ff23622283713))
|
|
9
|
+
* praca workera task-mwntr8cx-dcqk3k (auto-commit) ([e8c074a](https://github.com/chuppa12/robisie-app/commit/e8c074a41b5401ab19fa6d180595d6d98257b8b7))
|
|
10
|
+
|
|
11
|
+
## [0.6.11](https://github.com/chuppa12/robisie-app/compare/client-v0.6.10...client-v0.6.11) (2026-11-19)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Factory Cards
|
|
15
|
+
|
|
16
|
+
* Klient na Linuksie bez systemctl aktualizuje instalację jednorazowo przez `robisie update` i dalej uruchamia fabrykę ręcznie ([84fa44c](https://github.com/chuppa12/robisie-app/commit/84fa44c74b7f4198813b9524ecb76d80e06c629f))
|
|
17
|
+
* praca workera task-mwnkmpbe-vgff3z (auto-commit) ([64acb51](https://github.com/chuppa12/robisie-app/commit/64acb51168ef5e34d1e2266e457a97f4ecaefef4))
|
|
18
|
+
* praca workera task-mwnl0nrj-6c33av (auto-commit) ([fc8d2df](https://github.com/chuppa12/robisie-app/commit/fc8d2df7de817e670e66e395791eb6e6213b8cc7))
|
|
19
|
+
* praca workera task-mwnlkxo7-bo6dvn (auto-commit) ([672d3f2](https://github.com/chuppa12/robisie-app/commit/672d3f27e2ead975a7b425d86f8314444abe9492))
|
|
20
|
+
* praca workera task-mwnn6snb-12goms (auto-commit) ([aa552be](https://github.com/chuppa12/robisie-app/commit/aa552beb813d614a7365f89c3955ad6574fa2d22))
|
|
21
|
+
* praca workera task-mwnnu82u-7166xh (auto-commit) ([a94afca](https://github.com/chuppa12/robisie-app/commit/a94afcad469c3348d1632ad47bcfefa7878a649f))
|
|
22
|
+
* przygotowanie konfliktu z main ([3f8cac0](https://github.com/chuppa12/robisie-app/commit/3f8cac0c8a32c3984f02985fdcc5697713afb056))
|
|
23
|
+
|
|
3
24
|
## [0.6.10](https://github.com/chuppa12/robisie-app/compare/client-v0.6.9...client-v0.6.10) (2026-11-19)
|
|
4
25
|
|
|
5
26
|
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** Package identity and the server contract it speaks. */
|
|
2
2
|
export declare const PACKAGE_NAME = "robisie";
|
|
3
|
-
export declare const PACKAGE_VERSION = "0.6.
|
|
3
|
+
export declare const PACKAGE_VERSION = "0.6.12";
|
|
4
4
|
/**
|
|
5
5
|
* MAJOR of the agent-API contract this package understands.
|
|
6
6
|
* PARITY: src/lib/mcp/contract-version.ts (AGENT_API_CONTRACT_VERSION) on the server.
|
package/dist/constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** Package identity and the server contract it speaks. */
|
|
2
2
|
export const PACKAGE_NAME = "robisie";
|
|
3
|
-
export const PACKAGE_VERSION = "0.6.
|
|
3
|
+
export const PACKAGE_VERSION = "0.6.12"; // x-release-please-version
|
|
4
4
|
/**
|
|
5
5
|
* MAJOR of the agent-API contract this package understands.
|
|
6
6
|
* PARITY: src/lib/mcp/contract-version.ts (AGENT_API_CONTRACT_VERSION) on the server.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"schema":1,"sha":"
|
|
1
|
+
{"schema":1,"sha":"c80e15613130c94c95c51181943e93c870a0602f","dirty":false}
|
|
@@ -1725,6 +1725,6 @@
|
|
|
1725
1725
|
"status": 0,
|
|
1726
1726
|
"signal": null,
|
|
1727
1727
|
"stdout": "v24.3.0\n",
|
|
1728
|
-
"stderr": "(node:
|
|
1728
|
+
"stderr": "(node:24533) ExperimentalWarning: SQLite is an experimental feature and might change at any time\n(Use `node --trace-warnings ...` to show where the warning was created)\n"
|
|
1729
1729
|
}
|
|
1730
1730
|
}
|
package/dist/engine/tick.cjs
CHANGED
|
@@ -37652,7 +37652,7 @@ var init_constants = __esm({
|
|
|
37652
37652
|
"packages/client/src/constants.ts"() {
|
|
37653
37653
|
"use strict";
|
|
37654
37654
|
PACKAGE_NAME = "robisie";
|
|
37655
|
-
PACKAGE_VERSION = "0.6.
|
|
37655
|
+
PACKAGE_VERSION = "0.6.12";
|
|
37656
37656
|
SUPPORTED_CONTRACT_MAJOR = 1;
|
|
37657
37657
|
DEFAULT_ORIGIN = "https://robisie.app";
|
|
37658
37658
|
MCP_SERVER_NAME = "robisie";
|
|
@@ -6,7 +6,7 @@ import { createInterface } from 'node:readline/promises';
|
|
|
6
6
|
import { fileURLToPath } from 'node:url';
|
|
7
7
|
import { isDeepStrictEqual } from 'node:util';
|
|
8
8
|
import { agentPaths } from './agents.js';
|
|
9
|
-
import { RobisieError } from './context.js';
|
|
9
|
+
import { RobisieError, shellQuote } from './context.js';
|
|
10
10
|
import { CONFIG_FILE, parseEngineConfig } from './engine-config.js';
|
|
11
11
|
import { readKey } from './manifest.js';
|
|
12
12
|
import { PlanerClient } from './planer-client.js';
|
|
@@ -54,7 +54,9 @@ export async function runInstallationUpdate(ctx, options, overrides = {}) {
|
|
|
54
54
|
const runtime = {
|
|
55
55
|
fs, exec: (command, args, cwd, env) => {
|
|
56
56
|
const result = spawnSync(command, args, { cwd, env, encoding: 'utf8', shell: false, timeout: 120_000, maxBuffer: 4 * 1024 * 1024 });
|
|
57
|
-
|
|
57
|
+
const errorCode = code(result.error);
|
|
58
|
+
return { status: result.status, signal: result.signal, stdout: result.stdout, stderr: result.stderr,
|
|
59
|
+
errorCode: typeof errorCode === 'string' ? errorCode : undefined };
|
|
58
60
|
}, kill: process.kill, now: Date.now, sleep: ms => new Promise(done => setTimeout(done, ms)),
|
|
59
61
|
interactive: Boolean(process.stdin.isTTY && process.stdout.isTTY),
|
|
60
62
|
ask: async (question) => {
|
|
@@ -75,9 +77,10 @@ export async function runInstallationUpdate(ctx, options, overrides = {}) {
|
|
|
75
77
|
const digest = (bytes) => createHash('sha256').update(bytes).digest('hex');
|
|
76
78
|
let result = 2;
|
|
77
79
|
let completed = false;
|
|
80
|
+
let oneShot = false;
|
|
81
|
+
let manualStart;
|
|
78
82
|
const env = { ...ctx.env };
|
|
79
|
-
const command = (name, args, cwd = ctx.cwd) => {
|
|
80
|
-
const outcome = runtime.exec(name, args, cwd, env);
|
|
83
|
+
const command = (name, args, cwd = ctx.cwd, outcome = runtime.exec(name, args, cwd, env)) => {
|
|
81
84
|
if (outcome.status !== 0 || outcome.signal !== null) {
|
|
82
85
|
const tail = (outcome.stderr ?? '').split(/\r\n|\n|\r/).filter(line => !/TOKEN|KEY|SECRET|PASSWORD/i.test(line))
|
|
83
86
|
.join(' ').replace(/\s+/g, ' ').trim().slice(-300);
|
|
@@ -256,10 +259,21 @@ export async function runInstallationUpdate(ctx, options, overrides = {}) {
|
|
|
256
259
|
}
|
|
257
260
|
const manager = ctx.platform === 'linux' ? 'systemctl' : 'launchctl';
|
|
258
261
|
const domain = `gui/${typeof process.getuid === 'function' ? process.getuid() : 0}`;
|
|
262
|
+
const probeArgs = ctx.platform === 'linux' ? ['--user', 'show-environment'] : ['print', domain];
|
|
263
|
+
const linuxClient = !host && ctx.platform === 'linux';
|
|
264
|
+
const probeClient = () => {
|
|
265
|
+
const outcome = runtime.exec(manager, probeArgs, ctx.cwd, env);
|
|
266
|
+
oneShot = outcome.errorCode === 'ENOENT' && outcome.status === null && outcome.signal === null;
|
|
267
|
+
return outcome;
|
|
268
|
+
};
|
|
269
|
+
const clientProbe = linuxClient && !config.update?.enabled ? probeClient() : undefined;
|
|
259
270
|
let managerProbed = false;
|
|
260
271
|
const probeManager = () => {
|
|
272
|
+
const outcome = clientProbe ?? (linuxClient ? probeClient() : undefined);
|
|
273
|
+
if (oneShot)
|
|
274
|
+
return;
|
|
261
275
|
try {
|
|
262
|
-
command(manager, ctx.
|
|
276
|
+
command(manager, probeArgs, ctx.cwd, outcome);
|
|
263
277
|
}
|
|
264
278
|
catch (error) {
|
|
265
279
|
if (ctx.platform === 'linux' && error instanceof RobisieError)
|
|
@@ -268,7 +282,7 @@ export async function runInstallationUpdate(ctx, options, overrides = {}) {
|
|
|
268
282
|
}
|
|
269
283
|
managerProbed = true;
|
|
270
284
|
};
|
|
271
|
-
if (!config.update?.enabled) {
|
|
285
|
+
if (!oneShot && !config.update?.enabled) {
|
|
272
286
|
if (!runtime.interactive || config.update?.enabled === false) {
|
|
273
287
|
ctx.out('Aktualizacja pominięta: brak włączonej zgody w konfiguracji.');
|
|
274
288
|
return 0;
|
|
@@ -332,7 +346,7 @@ export async function runInstallationUpdate(ctx, options, overrides = {}) {
|
|
|
332
346
|
refuse('Żywy wskaźnik zmienił się podczas aktualizacji.');
|
|
333
347
|
};
|
|
334
348
|
// Probe manager before any pointer, service, or card mutation.
|
|
335
|
-
if (!managerProbed)
|
|
349
|
+
if (!oneShot && !managerProbed)
|
|
336
350
|
probeManager();
|
|
337
351
|
if (!host)
|
|
338
352
|
board = await runtime.board(ctx, config);
|
|
@@ -446,6 +460,8 @@ export async function runInstallationUpdate(ctx, options, overrides = {}) {
|
|
|
446
460
|
ctx.err(`Alarm: ${message}`);
|
|
447
461
|
alarm(message);
|
|
448
462
|
}
|
|
463
|
+
if (reason.startsWith('claim '))
|
|
464
|
+
audit('deferred', { reason });
|
|
449
465
|
ctx.out(`Aktualizacja odroczona: ${reason}.`);
|
|
450
466
|
return 0;
|
|
451
467
|
};
|
|
@@ -552,15 +568,20 @@ export async function runInstallationUpdate(ctx, options, overrides = {}) {
|
|
|
552
568
|
if (!file)
|
|
553
569
|
continue;
|
|
554
570
|
exists = true;
|
|
555
|
-
if (!
|
|
556
|
-
throw new Error('unsupported claim');
|
|
557
|
-
const value = json(regular(path)), pid = value.pid;
|
|
558
|
-
if (typeof pid !== 'number' || !Number.isSafeInteger(pid) || pid <= 0
|
|
559
|
-
|| !(runtime.now() - file.mtimeMs <= 600_000))
|
|
571
|
+
if (!file.isFile() || !(runtime.now() - file.mtimeMs <= 600_000))
|
|
560
572
|
throw new Error('unsafe claim');
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
573
|
+
let live = false;
|
|
574
|
+
if (claim === '.tester-job.lock' || claim === 'receiver-jobs/local/claim.json') {
|
|
575
|
+
const bytes = regular(path);
|
|
576
|
+
let pid;
|
|
577
|
+
try {
|
|
578
|
+
pid = json(bytes).pid;
|
|
579
|
+
}
|
|
580
|
+
catch { /* Successfully read bytes may not yet contain a usable PID. */ }
|
|
581
|
+
// process.kill accepts only signed 32-bit PIDs.
|
|
582
|
+
live = typeof pid === 'number' && Number.isInteger(pid) && pid > 0 && pid <= 2_147_483_647 && alive(pid, name);
|
|
583
|
+
}
|
|
584
|
+
busy ??= live ? `claim ${name}` : `claim ${name} czeka na rozliczenie przez takt`;
|
|
564
585
|
}
|
|
565
586
|
catch {
|
|
566
587
|
refuse(`${exists ? 'Nierozliczony' : 'Nieczytelny'} claim ${name}; zachowaj stan.`);
|
|
@@ -643,7 +664,32 @@ export async function runInstallationUpdate(ctx, options, overrides = {}) {
|
|
|
643
664
|
|| typeof metadata.gitHead !== 'string' || !/^[a-f0-9]{40}$/.test(metadata.gitHead))
|
|
644
665
|
refuse('Niepoprawne metadane npm: wymagane gitHead i integralność.');
|
|
645
666
|
const latest = metadata.version;
|
|
646
|
-
|
|
667
|
+
const hasNewerRelease = newer(latest, oldPackage.version);
|
|
668
|
+
const unitDir = ctx.platform === 'linux' ? join(dirname(agentPaths(ctx).clientDir), 'systemd/user') : join(ctx.home, 'Library/LaunchAgents');
|
|
669
|
+
const systemdUnits = ['robisie-factory', 'robisie-update'];
|
|
670
|
+
const quotedWorkingDirectory = /^WorkingDirectory="[^\r\n]*"(?=\r?$)/m;
|
|
671
|
+
let repairUnits = false;
|
|
672
|
+
if (!oneShot && ctx.platform === 'linux' && latest === oldPackage.version && pointerSnapshot.target && oldSha === metadata.gitHead) {
|
|
673
|
+
// After rollback, current can already point to the package replaced by a manual npm install.
|
|
674
|
+
repairUnits = systemdUnits.some(name => {
|
|
675
|
+
const path = join(unitDir, `${name}.service`);
|
|
676
|
+
if (!stat(path)?.isFile())
|
|
677
|
+
return false;
|
|
678
|
+
const contents = regular(path).toString('utf8');
|
|
679
|
+
return contents.includes('robisie:update-managed') && quotedWorkingDirectory.test(contents);
|
|
680
|
+
});
|
|
681
|
+
if (!repairUnits && stat(auditPath)) {
|
|
682
|
+
// A failed reload can leave corrected files on disk before systemd accepts them.
|
|
683
|
+
const lastRepair = regular(auditPath).toString('utf8').split('\n').reverse().find(line => {
|
|
684
|
+
if (!line.includes('"event":"unit-repair"'))
|
|
685
|
+
return false;
|
|
686
|
+
const entry = json(Buffer.from(line));
|
|
687
|
+
return entry.sha === oldSha && entry.version === latest;
|
|
688
|
+
});
|
|
689
|
+
repairUnits = lastRepair !== undefined && json(Buffer.from(lastRepair)).confirmed === false;
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
if (!hasNewerRelease && !repairUnits && (latest !== oldPackage.version || pointerSnapshot.target)) {
|
|
647
693
|
ctx.out('Zainstalowana wersja robisie jest aktualna; brak downgrade.');
|
|
648
694
|
return 0;
|
|
649
695
|
}
|
|
@@ -655,7 +701,7 @@ export async function runInstallationUpdate(ctx, options, overrides = {}) {
|
|
|
655
701
|
refuse('Ta wersja była już próbowana przez starego agenta; wyjaśnij wpis auto-update.state.');
|
|
656
702
|
}
|
|
657
703
|
const attempts = join(update, 'attempts.jsonl');
|
|
658
|
-
const attemptBytes = stat(attempts) ? regular(attempts) : null;
|
|
704
|
+
const attemptBytes = !repairUnits && stat(attempts) ? regular(attempts) : null;
|
|
659
705
|
if (attemptBytes)
|
|
660
706
|
for (const line of attemptBytes.toString('utf8').split('\n').filter(Boolean)) {
|
|
661
707
|
const entry = JSON.parse(line);
|
|
@@ -671,6 +717,8 @@ export async function runInstallationUpdate(ctx, options, overrides = {}) {
|
|
|
671
717
|
const second = await preflight();
|
|
672
718
|
if (second.busy)
|
|
673
719
|
return defer(second.busy);
|
|
720
|
+
if (repairUnits && second.own.length)
|
|
721
|
+
return defer('karta maszynisty in_progress');
|
|
674
722
|
for (const card of second.own) {
|
|
675
723
|
check();
|
|
676
724
|
const activity = await preflight();
|
|
@@ -696,28 +744,31 @@ export async function runInstallationUpdate(ctx, options, overrides = {}) {
|
|
|
696
744
|
audit('card-blocked', { id: card.id, before: card, after, echo, echoDetail });
|
|
697
745
|
}
|
|
698
746
|
check();
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
747
|
+
let next = previous, sha = oldSha;
|
|
748
|
+
if (!repairUnits) {
|
|
749
|
+
if (attemptBytes ? !regular(attempts).equals(attemptBytes) : stat(attempts) !== null)
|
|
750
|
+
refuse('Rejestr prób zmienił się podczas aktualizacji.');
|
|
751
|
+
if (host) {
|
|
752
|
+
const before = stat(legacyState) ? regular(legacyState) : null;
|
|
753
|
+
io.appendFileSync(legacyState, `${latest} ATTEMPT ${new Date(runtime.now()).toISOString()}\n`, { mode: 0o600, flush: true });
|
|
754
|
+
legacyAttempt = { before, saved: regular(legacyState) };
|
|
755
|
+
}
|
|
756
|
+
append(attempts, { version: latest, at: new Date(runtime.now()).toISOString() });
|
|
757
|
+
attempt = { path: attempts, before: attemptBytes, saved: regular(attempts) };
|
|
758
|
+
audit('attempt', { version: latest, previous: oldSha });
|
|
759
|
+
const releases = join(update, 'releases');
|
|
760
|
+
privateDir(releases);
|
|
761
|
+
const release = io.mkdtempSync(join(releases, `robisie-${latest}-`));
|
|
762
|
+
io.writeFileSync(join(release, 'package.json'), JSON.stringify({ private: true }) + '\n', { flag: 'wx', mode: 0o600, flush: true });
|
|
763
|
+
command(npm, ['install', `robisie@${latest}`, '--ignore-scripts', '--no-audit', '--no-fund', '--save-exact'], release);
|
|
764
|
+
next = join(release, 'node_modules/robisie');
|
|
765
|
+
sha = validBuild(json(regular(join(next, 'dist/engine/build-id.json'))));
|
|
766
|
+
const lock = json(regular(join(release, 'package-lock.json')));
|
|
767
|
+
const installed = object(lock.packages) ? lock.packages['node_modules/robisie'] : null;
|
|
768
|
+
if (sha !== metadata.gitHead || !object(installed) || installed.integrity !== metadata.dist.integrity
|
|
769
|
+
|| json(regular(join(next, 'package.json'))).version !== latest)
|
|
770
|
+
refuse('Weryfikacja wydania npm nie powiodła się.');
|
|
705
771
|
}
|
|
706
|
-
append(attempts, { version: latest, at: new Date(runtime.now()).toISOString() });
|
|
707
|
-
attempt = { path: attempts, before: attemptBytes, saved: regular(attempts) };
|
|
708
|
-
audit('attempt', { version: latest, previous: oldSha });
|
|
709
|
-
const releases = join(update, 'releases');
|
|
710
|
-
privateDir(releases);
|
|
711
|
-
const release = io.mkdtempSync(join(releases, `robisie-${latest}-`));
|
|
712
|
-
io.writeFileSync(join(release, 'package.json'), JSON.stringify({ private: true }) + '\n', { flag: 'wx', mode: 0o600, flush: true });
|
|
713
|
-
command(npm, ['install', `robisie@${latest}`, '--ignore-scripts', '--no-audit', '--no-fund', '--save-exact'], release);
|
|
714
|
-
const next = join(release, 'node_modules/robisie');
|
|
715
|
-
const build = json(regular(join(next, 'dist/engine/build-id.json'))), sha = validBuild(build);
|
|
716
|
-
const lock = json(regular(join(release, 'package-lock.json')));
|
|
717
|
-
const installed = object(lock.packages) ? lock.packages['node_modules/robisie'] : null;
|
|
718
|
-
if (sha !== metadata.gitHead || !object(installed) || installed.integrity !== metadata.dist.integrity
|
|
719
|
-
|| json(regular(join(next, 'package.json'))).version !== latest)
|
|
720
|
-
refuse('Weryfikacja wydania npm nie powiodła się.');
|
|
721
772
|
regular(join(next, 'dist/cli.js'));
|
|
722
773
|
regular(join(next, 'dist/engine/tick.cjs'));
|
|
723
774
|
const prepared = await preflight();
|
|
@@ -740,23 +791,38 @@ try {
|
|
|
740
791
|
env.ROBISIE_KEY=readKey(dir);
|
|
741
792
|
env.ROBISIE_REVIEW_KEY=readKey(dir,'review-key');
|
|
742
793
|
if(!env.ROBISIE_KEY||!env.ROBISIE_REVIEW_KEY) throw new Error('Brak plików kluczy instalacji');
|
|
743
|
-
}
|
|
794
|
+
}${oneShot ? `
|
|
795
|
+
if(process.argv[2]==='factory' && process.argv[3]==='run') {
|
|
796
|
+
// Keep the launcher PID so TERM reaches the supervisor directly.
|
|
797
|
+
process.chdir(${JSON.stringify(ctx.cwd)});
|
|
798
|
+
process.execve(${JSON.stringify(runtime.node)},[${JSON.stringify(runtime.node)},join(root,'dist/cli.js'),...process.argv.slice(2)],env);
|
|
799
|
+
throw new Error('Polecenie robisie nie powiodło się');
|
|
800
|
+
}` : ''}
|
|
744
801
|
const r=spawnSync(${JSON.stringify(runtime.node)},[join(root,'dist/cli.js'),...process.argv.slice(2)],{cwd:${JSON.stringify(ctx.cwd)},env,stdio:'inherit',shell:false});
|
|
745
802
|
if(r.status!==0||r.signal!==null) throw new Error('Polecenie robisie nie powiodło się');
|
|
746
803
|
process.exitCode=0;
|
|
747
804
|
} catch { process.stderr.write('Błąd uruchomienia robisie; sprawdź prywatny audyt aktualizacji.\\n'); process.exitCode=2; }
|
|
748
805
|
`;
|
|
749
|
-
const
|
|
750
|
-
|
|
806
|
+
const readManaged = (path) => {
|
|
807
|
+
const contents = stat(path) ? regular(path) : null;
|
|
808
|
+
if (contents !== null && !contents.includes('robisie:update-managed'))
|
|
751
809
|
refuse('Obcy plik jednostki lub launchera; odmowa nadpisania.');
|
|
810
|
+
return contents;
|
|
811
|
+
};
|
|
812
|
+
const writeManaged = (path, content) => {
|
|
813
|
+
readManaged(path);
|
|
752
814
|
io.writeFileSync(path, content, { mode: 0o600, flush: true });
|
|
753
815
|
};
|
|
754
|
-
|
|
755
|
-
|
|
816
|
+
if (!oneShot && ctx.platform === 'linux' && (!isAbsolute(ctx.cwd) || /[\n\r]/.test(ctx.cwd)))
|
|
817
|
+
refuse('WorkingDirectory wymaga absolutnej ścieżki bez LF i CR.');
|
|
818
|
+
if (!oneShot)
|
|
819
|
+
io.mkdirSync(unitDir, { recursive: true, mode: 0o700 });
|
|
756
820
|
const factoryArgs = ['factory', 'run', '--once', '--engine-config', configPath];
|
|
757
821
|
const updateArgs = ['update', '--engine-config', configPath];
|
|
758
822
|
const factoryName = ctx.platform === 'linux' ? 'robisie-factory' : host ? 'com.robisie.maszynista' : 'com.robisie.factory';
|
|
759
823
|
const ensureOwned = () => {
|
|
824
|
+
if (oneShot)
|
|
825
|
+
return;
|
|
760
826
|
if (hostService && hostPlist) {
|
|
761
827
|
if (!regular(hostPlist).equals(hostService.current))
|
|
762
828
|
refuse('Hostowy plist zmienił się podczas aktualizacji.');
|
|
@@ -785,7 +851,16 @@ try {
|
|
|
785
851
|
}
|
|
786
852
|
};
|
|
787
853
|
ensureOwned();
|
|
788
|
-
|
|
854
|
+
if (repairUnits) {
|
|
855
|
+
readManaged(launcher);
|
|
856
|
+
for (const name of systemdUnits) {
|
|
857
|
+
readManaged(join(unitDir, `${name}.service`));
|
|
858
|
+
readManaged(join(unitDir, `${name}.timer`));
|
|
859
|
+
}
|
|
860
|
+
audit('unit-repair', { sha, version: latest, confirmed: false });
|
|
861
|
+
}
|
|
862
|
+
else
|
|
863
|
+
writeManaged(launcher, launcherText);
|
|
789
864
|
if (hostService && hostPlist) {
|
|
790
865
|
const service = json(Buffer.from(command('plutil', ['-convert', 'json', '-o', '-', hostPlist])));
|
|
791
866
|
const args = service.ProgramArguments;
|
|
@@ -805,14 +880,38 @@ try {
|
|
|
805
880
|
const unitEnv = Object.entries({ ...(host ? Object.fromEntries(Object.entries(env).filter(([key]) => /^HU_(?:HOME|MODE|LASTTICK|SK|REPO|APP|PLIST|CHECKOUT|LOG|STATE|NPM|ALARM)$/.test(key))) : {}), HOME: ctx.home, PATH: ctx.env.PATH, CODEX_HOME: ctx.env.CODEX_HOME, XDG_CONFIG_HOME: ctx.env.XDG_CONFIG_HOME })
|
|
806
881
|
.filter((entry) => entry[1] !== undefined);
|
|
807
882
|
let hostUpdateUnit;
|
|
808
|
-
if (ctx.platform === 'linux' && (!isAbsolute(ctx.cwd) || /[\n\r]/.test(ctx.cwd)))
|
|
809
|
-
refuse('WorkingDirectory wymaga absolutnej ścieżki bez LF i CR.');
|
|
810
883
|
for (const [name, args] of [['factory', factoryArgs], ['update', updateArgs]]) {
|
|
884
|
+
if (oneShot)
|
|
885
|
+
break;
|
|
811
886
|
if (host && name === 'factory')
|
|
812
887
|
continue;
|
|
813
888
|
if (ctx.platform === 'linux') {
|
|
889
|
+
const service = join(unitDir, `robisie-${name}.service`);
|
|
890
|
+
const workingDirectory = `WorkingDirectory=${ctx.cwd.replace(/%/g, '%%')}`;
|
|
891
|
+
if (repairUnits) {
|
|
892
|
+
const before = readManaged(service);
|
|
893
|
+
if (!before)
|
|
894
|
+
continue;
|
|
895
|
+
// A one-byte encoding keeps every byte outside the replaced line intact.
|
|
896
|
+
const contents = before.toString('latin1');
|
|
897
|
+
const repaired = contents.replace(quotedWorkingDirectory, () => Buffer.from(workingDirectory).toString('latin1'));
|
|
898
|
+
if (repaired === contents)
|
|
899
|
+
continue;
|
|
900
|
+
const staging = io.mkdtempSync(join(unitDir, '.robisie-repair-'));
|
|
901
|
+
try {
|
|
902
|
+
const temporary = join(staging, `${name}.service`);
|
|
903
|
+
io.writeFileSync(temporary, Buffer.from(repaired, 'latin1'), { flag: 'wx', mode: 0o600, flush: true });
|
|
904
|
+
if (!readManaged(service)?.equals(before))
|
|
905
|
+
refuse('Usługa systemd zmieniła się podczas naprawy.');
|
|
906
|
+
io.renameSync(temporary, service);
|
|
907
|
+
}
|
|
908
|
+
finally {
|
|
909
|
+
io.rmSync(staging, { recursive: true, force: true });
|
|
910
|
+
}
|
|
911
|
+
continue;
|
|
912
|
+
}
|
|
814
913
|
// Tick and update own their deadlines, including the separate rollback health window.
|
|
815
|
-
writeManaged(
|
|
914
|
+
writeManaged(service, `# robisie:update-managed\n[Unit]\nDescription=robisie ${name}\n[Service]\nType=oneshot\nTimeoutStartSec=infinity\n${unitEnv.map(([key, value]) => `Environment=${systemArg(`${key}=${value}`)}\n`).join('')}${workingDirectory}\nExecStart=${[runtime.node, launcher, ...args].map(arg => systemArg(arg, true)).join(' ')}\n`);
|
|
816
915
|
writeManaged(join(unitDir, `robisie-${name}.timer`), `# robisie:update-managed\n[Unit]\nDescription=robisie ${name}\n[Timer]\nOnBootSec=120s\nOnUnitInactiveSec=120s\nUnit=robisie-${name}.service\n[Install]\nWantedBy=timers.target\n`);
|
|
817
916
|
}
|
|
818
917
|
else {
|
|
@@ -983,7 +1082,7 @@ try {
|
|
|
983
1082
|
}
|
|
984
1083
|
return false;
|
|
985
1084
|
};
|
|
986
|
-
if (modeBytes) {
|
|
1085
|
+
if (modeBytes && !repairUnits) {
|
|
987
1086
|
mode = { path: modePath, bytes: modeBytes, expected: modeBytes, sha: digest(modeBytes) };
|
|
988
1087
|
const backup = join(update, 'HOST-ACTIVATION.mode.backup');
|
|
989
1088
|
if (stat(backup) && !stat(backup)?.isFile())
|
|
@@ -1049,12 +1148,20 @@ try {
|
|
|
1049
1148
|
const locked = await preflight();
|
|
1050
1149
|
if (locked.busy || locked.own.length)
|
|
1051
1150
|
refuse('Alarm: nowa praca pod blokadą uniemożliwia powrót.');
|
|
1052
|
-
|
|
1053
|
-
|
|
1151
|
+
if (oneShot)
|
|
1152
|
+
check();
|
|
1153
|
+
else {
|
|
1154
|
+
ensureOwned();
|
|
1155
|
+
rememberTick();
|
|
1156
|
+
}
|
|
1054
1157
|
replaceHostService(true);
|
|
1055
1158
|
const restoredAt = runtime.now();
|
|
1056
1159
|
switchPointer(previous);
|
|
1057
1160
|
rollbackAudit('restored', { sha: oldSha, failed: sha });
|
|
1161
|
+
if (oneShot) {
|
|
1162
|
+
refresh(previous);
|
|
1163
|
+
return;
|
|
1164
|
+
}
|
|
1058
1165
|
const restarted = activate(previous, oldSha, 'rollback-start-failed');
|
|
1059
1166
|
const confirmed = restarted && await health(oldSha, restoredAt, 'old-tick', 'rollback-start-failed');
|
|
1060
1167
|
rollbackAudit(confirmed ? 'rollback-confirmed' : 'rollback-unconfirmed', { sha: oldSha, failed: sha });
|
|
@@ -1072,21 +1179,39 @@ try {
|
|
|
1072
1179
|
rollback = undefined;
|
|
1073
1180
|
return defer(activating.busy ?? 'karta maszynisty in_progress');
|
|
1074
1181
|
}
|
|
1075
|
-
|
|
1182
|
+
if (oneShot)
|
|
1183
|
+
check();
|
|
1184
|
+
else
|
|
1185
|
+
rememberTick();
|
|
1076
1186
|
const switchedAt = runtime.now();
|
|
1187
|
+
if (repairUnits) {
|
|
1188
|
+
const started = activate(next, sha, 'unit-repair-start-failed');
|
|
1189
|
+
if (!started || !await health(sha, switchedAt, 'unit-repair-tick', 'unit-repair-start-failed'))
|
|
1190
|
+
refuse('Nie potwierdzono naprawy jednostek systemd dwoma świeżymi taktami OK.');
|
|
1191
|
+
audit('unit-repair', { sha, version: latest, confirmed: true });
|
|
1192
|
+
if (stat(join(update, 'deferred.json')))
|
|
1193
|
+
io.unlinkSync(join(update, 'deferred.json'));
|
|
1194
|
+
completed = true;
|
|
1195
|
+
return 0;
|
|
1196
|
+
}
|
|
1077
1197
|
rollback = restorePrevious;
|
|
1078
1198
|
if (hostUpdateUnit)
|
|
1079
1199
|
writeManaged(hostUpdateUnit.path, hostUpdateUnit.content);
|
|
1080
1200
|
replaceHostService(false);
|
|
1081
1201
|
switchPointer(next);
|
|
1082
1202
|
audit('switched', { sha, previous: oldSha });
|
|
1083
|
-
|
|
1084
|
-
|
|
1203
|
+
if (oneShot) {
|
|
1204
|
+
refresh(next);
|
|
1205
|
+
check();
|
|
1206
|
+
}
|
|
1207
|
+
if (oneShot || (activate(next, sha, 'start-failed') && await health(sha, switchedAt, 'new-tick', 'start-failed'))) {
|
|
1085
1208
|
audit('updated', { sha });
|
|
1086
1209
|
if (stat(join(update, 'deferred.json')))
|
|
1087
1210
|
io.unlinkSync(join(update, 'deferred.json'));
|
|
1088
1211
|
completed = true;
|
|
1089
1212
|
result = 0;
|
|
1213
|
+
if (oneShot)
|
|
1214
|
+
manualStart = `${shellQuote(runtime.node)} ${shellQuote(launcher)} factory run --engine-config ${shellQuote(configPath)}`;
|
|
1090
1215
|
if (host)
|
|
1091
1216
|
afterCleanup = async () => {
|
|
1092
1217
|
const checkout = env.HU_CHECKOUT || repo, deadline = runtime.now() + 480_000;
|
|
@@ -1163,7 +1288,11 @@ try {
|
|
|
1163
1288
|
catch {
|
|
1164
1289
|
ctx.err('Alarm: błąd dostawy lub audytu alarmu hosta.');
|
|
1165
1290
|
}
|
|
1166
|
-
if (completed && result === 0)
|
|
1167
|
-
|
|
1291
|
+
if (completed && result === 0) {
|
|
1292
|
+
if (manualStart)
|
|
1293
|
+
ctx.out(`Aktualizacja zakończona. Teraz uruchom fabrykę ręcznie jak dotąd.\n${manualStart}`);
|
|
1294
|
+
else
|
|
1295
|
+
ctx.out('Aktualizacja potwierdzona dwoma świeżymi taktami OK.');
|
|
1296
|
+
}
|
|
1168
1297
|
return result;
|
|
1169
1298
|
}
|
package/dist/roles.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export interface Role {
|
|
|
17
17
|
export declare function rolesDir(): string;
|
|
18
18
|
export declare function parseRole(file: Role["file"], text: string): Role;
|
|
19
19
|
export declare function loadRoles(dir?: string): Role[];
|
|
20
|
-
export declare const MANAGED_LINE = "<!-- robisie:managed 0.6.
|
|
20
|
+
export declare const MANAGED_LINE = "<!-- robisie:managed 0.6.12 \u2014 plik zarz\u0105dzany przez `npx robisie`; `npx robisie uninstall` go usunie -->";
|
|
21
21
|
export type AgentFlavor = "claude" | "codex" | "opencode";
|
|
22
22
|
/** How the operator starts the Builder for one card in its own session (the card id is not a secret). */
|
|
23
23
|
export declare function builderStartCommand(flavor: AgentFlavor, codexRolePath?: string): string;
|
package/docs/README.en.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# robisie — from account to accepted card (package 0.6.
|
|
1
|
+
# robisie — from account to accepted card (package 0.6.12) <!-- x-release-please-version -->
|
|
2
2
|
|
|
3
3
|
In the project directory with its engine configuration, run `npx robisie init`, then `npx robisie doctor`: init prepares the project goal and tester protection list, and doctor checks both inputs.
|
|
4
4
|
|
|
@@ -607,6 +607,7 @@ For the first upgrade from robisie ≤0.5.48, or on Linux with systemd also from
|
|
|
607
607
|
The update needs Node.js 24 or newer on the PATH of the shell that runs the command and of the service; check `node -v` and `command -v node`, because an older Node on the PATH ends the command with a version message.
|
|
608
608
|
|
|
609
609
|
On Linux the update command needs a working `systemd --user` session; check `systemctl --user show-environment`, and if there is none, the human enables linger with `loginctl enable-linger $USER` and sets `XDG_RUNTIME_DIR=/run/user/$(id -u)`.
|
|
610
|
+
In a Linux container without `systemctl`, a one-time `npx robisie update` requires no consent for automatic updates, and afterward you start the factory manually from the new release with the command printed by the updater (`node "<stateDir>/update/launch.mjs" factory run --engine-config "<absolute config path>"`).
|
|
610
611
|
|
|
611
612
|
The human gives consent to updates. An agent without a terminal does not write it on its own; only after the human's explicit instruction does it add exactly `"update":{"consentedAt":"<ISO time with offset>","enabled":true}` to `robisie.config.json`; without that entry the background command exits with code 0 and changes nothing.
|
|
612
613
|
|
package/docs/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# robisie — od konta do odebranej karty (paczka 0.6.
|
|
1
|
+
# robisie — od konta do odebranej karty (paczka 0.6.12) <!-- x-release-please-version -->
|
|
2
2
|
|
|
3
3
|
W katalogu projektu z konfiguracją silnika uruchom `npx robisie init`, potem `npx robisie doctor`: init przygotuje cel projektu i listę ochrony testera, a doctor sprawdzi oba wejścia.
|
|
4
4
|
|
|
@@ -655,6 +655,7 @@ Pierwsze przejście z robisie ≤0.5.48, a na Linuxie z systemd także z robisie
|
|
|
655
655
|
Aktualizacja wymaga Node.js 24 lub nowszego na PATH powłoki, w której uruchamiasz komendę, i usługi; sprawdź `node -v` i `command -v node`, bo starszy Node na PATH kończy komendę komunikatem o wersji.
|
|
656
656
|
|
|
657
657
|
Na Linuxie komenda update wymaga działającej sesji `systemd --user`; sprawdź `systemctl --user show-environment`, a gdy sesji nie ma, człowiek włącza linger poleceniem `loginctl enable-linger $USER` i ustawia `XDG_RUNTIME_DIR=/run/user/$(id -u)`.
|
|
658
|
+
W kontenerze linuksowym bez `systemctl` jednorazowe `npx robisie update` nie wymaga zgody na automatyczne aktualizacje, a po aktualizacji uruchom fabrykę ręcznie z nowego wydania poleceniem wypisanym przez aktualizator (`node "<stateDir>/update/launch.mjs" factory run --engine-config "<absolutna ścieżka konfiguracji>"`).
|
|
658
659
|
|
|
659
660
|
Zgodę na aktualizacje wyraża człowiek. Agent bez terminala nie wpisuje jej sam; dopiero po wyraźnym poleceniu człowieka dopisuje do `robisie.config.json` dosłownie `"update":{"consentedAt":"<czas ISO z przesunięciem strefy>","enabled":true}`; bez takiego wpisu komenda w tle kończy się kodem 0 bez zmian.
|
|
660
661
|
|
package/package.json
CHANGED