robisie 0.6.7 → 0.6.8

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 CHANGED
@@ -1,5 +1,14 @@
1
1
  # Historia zmian klienta / Client changelog
2
2
 
3
+ ## [0.6.8](https://github.com/chuppa12/robisie-app/compare/client-v0.6.7...client-v0.6.8) (2026-11-19)
4
+
5
+
6
+ ### Factory Cards
7
+
8
+ * Fabryka sama wstaje po zabitym takcie: gdy blokada factory run należy do martwego procesu albo powstała przed startem Maca, nadzorca przejmuje ją z wpisem w logu zamiast kończyć się kodem 2 i czekać na rękę ([422529d](https://github.com/chuppa12/robisie-app/commit/422529da24965e31b1be0922023cfe5e58a32793))
9
+ * praca workera task-mwmgmfgb-wfcimd (auto-commit) ([244d1a9](https://github.com/chuppa12/robisie-app/commit/244d1a9c591eab988c4f7534eac6cd6e3c75ba89))
10
+ * praca workera task-mwmiangd-zjzjou (auto-commit) ([c3b1c42](https://github.com/chuppa12/robisie-app/commit/c3b1c422bfefa8a8b41f56404a8e4d089c8e2175))
11
+
3
12
  ## [0.6.7](https://github.com/chuppa12/robisie-app/compare/client-v0.6.6...client-v0.6.7) (2026-11-18)
4
13
 
5
14
 
@@ -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.7";
3
+ export declare const PACKAGE_VERSION = "0.6.8";
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.7"; // x-release-please-version
3
+ export const PACKAGE_VERSION = "0.6.8"; // 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":"ecab7848938aefc2798695cefa13f0354f424afe","dirty":false}
1
+ {"schema":1,"sha":"1d3190a896ee54ac0698b5a670ca75645c87e3a0","dirty":false}
@@ -1725,6 +1725,6 @@
1725
1725
  "status": 0,
1726
1726
  "signal": null,
1727
1727
  "stdout": "v24.3.0\n",
1728
- "stderr": "(node:24538) 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"
1728
+ "stderr": "(node:24499) 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
  }
@@ -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.7";
37655
+ PACKAGE_VERSION = "0.6.8";
37656
37656
  SUPPORTED_CONTRACT_MAJOR = 1;
37657
37657
  DEFAULT_ORIGIN = "https://robisie.app";
37658
37658
  MCP_SERVER_NAME = "robisie";
@@ -11,6 +11,8 @@ export interface FactoryRuntime {
11
11
  kill: typeof process.kill;
12
12
  signals: Pick<NodeJS.Process, "on" | "off">;
13
13
  sleep: (ms: number, signal: AbortSignal) => Promise<void>;
14
+ now?: () => number;
15
+ uptime?: () => number;
14
16
  nodeVersion: string;
15
17
  moduleUrl: string;
16
18
  }
@@ -1,7 +1,7 @@
1
1
  import { spawn } from "node:child_process";
2
2
  import { randomUUID } from "node:crypto";
3
- import { closeSync, fstatSync, lstatSync, mkdirSync, openSync, readFileSync, realpathSync, statSync, unlinkSync, writeFileSync } from "node:fs";
4
- import { constants } from "node:os";
3
+ import { closeSync, constants as fsConstants, fstatSync, linkSync, lstatSync, mkdirSync, mkdtempSync, openSync, readFileSync, readSync, realpathSync, renameSync, rmSync, statSync, unlinkSync, utimesSync, writeFileSync, } from "node:fs";
4
+ import { constants, uptime } from "node:os";
5
5
  import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
6
6
  import { fileURLToPath } from "node:url";
7
7
  import { RobisieError } from "./context.js";
@@ -18,6 +18,181 @@ function sleep(ms, signal) {
18
18
  function errorCode(error) {
19
19
  return typeof error === "object" && error !== null && "code" in error ? error.code : undefined;
20
20
  }
21
+ function sameLock(left, right) {
22
+ return right.isFile() && left.dev === right.dev && left.ino === right.ino
23
+ && left.mtimeMs === right.mtimeMs && left.size === right.size;
24
+ }
25
+ function readSupervisorLock(path) {
26
+ try {
27
+ const stat = lstatSync(path);
28
+ // At most 16 PID digits, a space, 36 UUID characters and LF.
29
+ if (!stat.isFile() || stat.size > 54)
30
+ return null;
31
+ const fd = openSync(path, fsConstants.O_RDONLY | fsConstants.O_NOFOLLOW | fsConstants.O_NONBLOCK);
32
+ try {
33
+ if (!sameLock(stat, fstatSync(fd)))
34
+ return null;
35
+ const bytes = Buffer.alloc(stat.size + 1);
36
+ if (readSync(fd, bytes) !== stat.size || !sameLock(stat, fstatSync(fd)) || !sameLock(stat, lstatSync(path)))
37
+ return null;
38
+ return { stat, bytes: bytes.subarray(0, stat.size) };
39
+ }
40
+ finally {
41
+ closeSync(fd);
42
+ }
43
+ }
44
+ catch (error) {
45
+ if (errorCode(error) === "ENOENT" || errorCode(error) === "ELOOP")
46
+ return null;
47
+ throw error;
48
+ }
49
+ }
50
+ function predatesBoot(mtime, runtime) {
51
+ try {
52
+ // Use the earlier wall-clock sample and allow for whole-second uptime precision.
53
+ const now = runtime.now ?? Date.now;
54
+ const start = now();
55
+ const elapsed = (runtime.uptime ?? uptime)() * 1000;
56
+ const end = now();
57
+ const lowerBound = start - elapsed - 1000;
58
+ return Number.isFinite(end) && end >= start && end - start <= 1000
59
+ && elapsed > 0 && lowerBound > 0 && mtime < lowerBound;
60
+ }
61
+ catch {
62
+ return false;
63
+ }
64
+ }
65
+ function isDead(pid, runtime) {
66
+ try {
67
+ runtime.kill(pid, 0);
68
+ return false;
69
+ }
70
+ catch (error) {
71
+ return errorCode(error) === "ESRCH";
72
+ }
73
+ }
74
+ function openSupervisorLock(path) {
75
+ try {
76
+ return openSync(path, "wx", 0o600);
77
+ }
78
+ catch (error) {
79
+ if (errorCode(error) === "EEXIST")
80
+ return null;
81
+ throw error;
82
+ }
83
+ }
84
+ function staleOwner(lock, runtime) {
85
+ const token = lock.bytes.toString("utf8");
86
+ const match = /^([1-9]\d*) ([\da-f]{8}-[\da-f]{4}-[1-8][\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12})\n$/i.exec(token);
87
+ if (!match || match[0] !== token)
88
+ return null;
89
+ const pid = Number(match[1]);
90
+ if (!Number.isSafeInteger(pid) || (!predatesBoot(lock.stat.mtimeMs, runtime) && !isDead(pid, runtime)))
91
+ return null;
92
+ return { pid, uuid: match[2] };
93
+ }
94
+ function linkExclusive(from, to) {
95
+ try {
96
+ linkSync(from, to);
97
+ return true;
98
+ }
99
+ catch (error) {
100
+ if (errorCode(error) === "EEXIST")
101
+ return false;
102
+ throw error;
103
+ }
104
+ }
105
+ function claimRecovery(directory, preparedOwner, runtime) {
106
+ // Leave dead claims in place. All contenders for a dead owner must claim
107
+ // the same next slot, so a delayed contender cannot unlink a new owner's claim.
108
+ for (let attempt = 0;; attempt++) {
109
+ const path = join(directory, `owner-${attempt}`);
110
+ const owner = readSupervisorLock(path);
111
+ if (!owner)
112
+ return linkExclusive(preparedOwner, path) ? path : null;
113
+ if (!staleOwner(owner, runtime))
114
+ return null;
115
+ }
116
+ }
117
+ function archiveStaleLock(path, runtime) {
118
+ const old = readSupervisorLock(path);
119
+ if (!old)
120
+ return null;
121
+ const owner = staleOwner(old, runtime);
122
+ if (!owner)
123
+ return null;
124
+ const archive = `${path}.stale-${old.stat.mtimeMs}`;
125
+ const directory = `${archive}.recovery-${old.stat.dev}-${old.stat.ino}-${owner.uuid}`;
126
+ const snapshot = join(directory, "snapshot");
127
+ const matches = (file, candidate) => {
128
+ const current = readSupervisorLock(candidate);
129
+ return current !== null && sameLock(file.stat, current.stat) && file.bytes.equals(current.bytes);
130
+ };
131
+ try {
132
+ if (!matches(old, path))
133
+ return null;
134
+ // An archive without a matching transaction has unknown ownership.
135
+ if (!lstatSync(directory, { throwIfNoEntry: false }) && lstatSync(archive, { throwIfNoEntry: false }))
136
+ return null;
137
+ try {
138
+ mkdirSync(directory, { mode: 0o700 });
139
+ }
140
+ catch (error) {
141
+ if (errorCode(error) !== "EEXIST")
142
+ throw error;
143
+ }
144
+ if (!lstatSync(directory).isDirectory())
145
+ return null;
146
+ const stage = mkdtempSync(join(directory, "attempt-"));
147
+ try {
148
+ const preparedOwner = join(stage, "owner");
149
+ writeFileSync(preparedOwner, `${process.pid} ${randomUUID()}\n`, { flag: "wx", mode: 0o600 });
150
+ const claim = claimRecovery(directory, preparedOwner, runtime);
151
+ if (!claim)
152
+ return null;
153
+ let removed = false;
154
+ try {
155
+ if (!matches(old, path))
156
+ return null;
157
+ if (!lstatSync(snapshot, { throwIfNoEntry: false })) {
158
+ const preparedSnapshot = join(stage, "snapshot");
159
+ writeFileSync(preparedSnapshot, old.bytes, { flag: "wx", mode: 0o600 });
160
+ utimesSync(preparedSnapshot, old.stat.atimeMs / 1000, old.stat.mtimeMs / 1000);
161
+ if (!linkExclusive(preparedSnapshot, snapshot))
162
+ return null;
163
+ }
164
+ const preserved = readSupervisorLock(snapshot);
165
+ if (!preserved || (old.stat.dev === preserved.stat.dev && old.stat.ino === preserved.stat.ino)
166
+ || !old.bytes.equals(preserved.bytes))
167
+ return null;
168
+ linkExclusive(snapshot, archive);
169
+ // The archive must be this transaction's snapshot, including on retry.
170
+ if (!matches(preserved, archive) || !matches(old, path))
171
+ return null;
172
+ unlinkSync(path);
173
+ removed = true;
174
+ // Detach the directory before recursive cleanup. A contender may still
175
+ // be staging a claim and must not race the removal of these names.
176
+ const retired = `${directory}.retired-${randomUUID()}`;
177
+ renameSync(directory, retired);
178
+ rmSync(retired, { recursive: true, force: true });
179
+ }
180
+ finally {
181
+ if (!removed)
182
+ rmSync(claim, { force: true });
183
+ }
184
+ }
185
+ finally {
186
+ rmSync(stage, { recursive: true, force: true });
187
+ }
188
+ }
189
+ catch (error) {
190
+ if (errorCode(error) === "ENOENT")
191
+ return null;
192
+ throw error;
193
+ }
194
+ return { pid: owner.pid, mtime: old.stat.mtime.toISOString(), archive };
195
+ }
21
196
  /** A dangling symlink is an error, not a nonexistent ancestor we may create through. */
22
197
  function physical(path) {
23
198
  try {
@@ -175,14 +350,14 @@ export async function runFactory(ctx, options, overrides = {}) {
175
350
  checkInstallation();
176
351
  const lockPath = join(state, ".factory-run.lock");
177
352
  const lockStep = `Potwierdź, że poprzedni nadzorca i jego takt nie działają; dopiero wtedy usuń blokadę „${lockPath}” i ponów polecenie.`;
178
- let fd;
179
- try {
180
- fd = openSync(lockPath, "wx", 0o600);
181
- }
182
- catch (error) {
183
- if (errorCode(error) === "EEXIST")
353
+ let fd = openSupervisorLock(lockPath);
354
+ let reclaimed = null;
355
+ if (fd === null) {
356
+ reclaimed = archiveStaleLock(lockPath, runtime);
357
+ if (reclaimed)
358
+ fd = openSupervisorLock(lockPath);
359
+ if (fd === null)
184
360
  fail(2, "Blokada factory run już istnieje.", lockStep);
185
- throw error;
186
361
  }
187
362
  try {
188
363
  lock = { path: lockPath, stat: fstatSync(fd), token: `${process.pid} ${randomUUID()}\n` };
@@ -191,6 +366,8 @@ export async function runFactory(ctx, options, overrides = {}) {
191
366
  finally {
192
367
  closeSync(fd);
193
368
  }
369
+ if (reclaimed)
370
+ ctx.out(`Przejęto martwą blokadę factory run: pid=${reclaimed.pid} mtime=${reclaimed.mtime} archive=${reclaimed.archive}.`);
194
371
  while (!stopSignal) {
195
372
  checkInstallation();
196
373
  if (stopSignal)
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.7 \u2014 plik zarz\u0105dzany przez `npx robisie`; `npx robisie uninstall` go usunie -->";
20
+ export declare const MANAGED_LINE = "<!-- robisie:managed 0.6.8 \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.7) <!-- x-release-please-version -->
1
+ # robisie — from account to accepted card (package 0.6.8) <!-- 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
 
package/docs/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # robisie — od konta do odebranej karty (paczka 0.6.7) <!-- x-release-please-version -->
1
+ # robisie — od konta do odebranej karty (paczka 0.6.8) <!-- 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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "robisie",
3
- "version": "0.6.7",
3
+ "version": "0.6.8",
4
4
  "description": "Instalator klienta robisie: łączy agenta (Claude Code, Codex CLI, OpenCode) z tablicą robisie i instaluje role klienta.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",