robisie 0.6.4 → 0.6.6

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,28 @@
1
1
  # Historia zmian klienta / Client changelog
2
2
 
3
+ ## [0.6.6](https://github.com/chuppa12/robisie-app/compare/client-v0.6.5...client-v0.6.6) (2026-11-18)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **client:** engine.lock nie blokuje promocji kart o rozłącznych plikach kodu (sznurek) ([196f912](https://github.com/chuppa12/robisie-app/commit/196f9127e3646080287db5782dac8cea6596af5f))
9
+ * **client:** engine.lock nie blokuje promocji kart o rozłącznych plikach kodu (sznurek) ([7df9e8a](https://github.com/chuppa12/robisie-app/commit/7df9e8ae683d5bc4650aef81e0233b43b1b5a147))
10
+ * **client:** engine.lock nie blokuje promocji kart o rozłącznych plikach kodu (sznurek) ([#1091](https://github.com/chuppa12/robisie-app/issues/1091)) ([196f912](https://github.com/chuppa12/robisie-app/commit/196f9127e3646080287db5782dac8cea6596af5f))
11
+ * **client:** host zapisuje tożsamość Workera (backend, model, dostawca) w każdym zapisie maszynisty ([ec53bc1](https://github.com/chuppa12/robisie-app/commit/ec53bc1de1e2173b4d6f5bb8d42be5e43700a990))
12
+ * **client:** host zapisuje tożsamość Workera (backend, model, dostawca) w każdym zapisie maszynisty ([#1082](https://github.com/chuppa12/robisie-app/issues/1082)) ([ec53bc1](https://github.com/chuppa12/robisie-app/commit/ec53bc1de1e2173b4d6f5bb8d42be5e43700a990))
13
+
14
+
15
+ ### Factory Cards
16
+
17
+ * Doctor klienta nie mówi „gotowe”, gdy projekt ma tryb odbioru legacy, w którym karta nigdy nie dojdzie do „zrobione” ([9588af2](https://github.com/chuppa12/robisie-app/commit/9588af298b76816f0dec659f736d722bb236f107))
18
+
19
+ ## [0.6.5](https://github.com/chuppa12/robisie-app/compare/client-v0.6.4...client-v0.6.5) (2026-11-18)
20
+
21
+
22
+ ### Factory Cards
23
+
24
+ * Komenda update odracza zamiast odmawiać przy żywym claimie Testera lub odbiorcy, nie liczy cudzych procesów za pracę fabryki, a alarm odroczenia nazywa powód ([84a2acb](https://github.com/chuppa12/robisie-app/commit/84a2acb959f1bb64ea11477bacfc5e225d0e2411))
25
+
3
26
  ## [0.6.4](https://github.com/chuppa12/robisie-app/compare/client-v0.6.3...client-v0.6.4) (2026-11-18)
4
27
 
5
28
 
package/dist/commands.js CHANGED
@@ -458,6 +458,8 @@ export async function doctor(ctx) {
458
458
  policyLine = policy === "enforced" ? "✓ Polityka enforced: TAK"
459
459
  : policy === "legacy" ? "! Polityka enforced: NIE (projekt ma politykę legacy) — odbiór B (accept_review) będzie odmawiany; poproś operatora Robisie o ustawienie enforced dla tego projektu"
460
460
  : "! Polityka enforced: NIE SPRAWDZONO — serwer nie zwraca polityki.";
461
+ if (policy === "legacy")
462
+ problems.push(recoveryStep(ctx, "Poproś obsługę robisie o włączenie trybu enforced dla tego projektu; dopiero wtedy będzie można zamknąć kartę przez odbiór B (accept_review)."));
461
463
  }
462
464
  finally {
463
465
  await client.close().catch(() => undefined);
@@ -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.4";
3
+ export declare const PACKAGE_VERSION = "0.6.6";
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.4"; // x-release-please-version
3
+ export const PACKAGE_VERSION = "0.6.6"; // 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.
@@ -7,7 +7,8 @@ export declare const SCOPE_DETAILS_KEYS: readonly ["scope"];
7
7
  /** Ścieżka przed opisem i numerem linii; porównujemy całe segmenty katalogu. */
8
8
  export declare function scopePaths(card: CardLike): string[];
9
9
  export declare function scopesOverlap(a: readonly string[], b: readonly string[]): boolean;
10
- /** Only promotion/dispatch collisions ignore tests; write permissions and land diffs stay complete. */
10
+ /** Promotion/dispatch collisions concern code, ignoring tests and the generated engine.lock.
11
+ * Write permissions and land diffs stay complete. */
11
12
  export declare function collisionScope(scope: readonly string[]): string[];
12
13
  /** Dispatch only, normalized paths. ownerChanges: omitted = candidate, array = owner delta, null = unknown IO. */
13
14
  export declare function dispatchScope(paths: readonly string[], confirmedTestDirectories: readonly string[], ownerChanges?: readonly string[] | null): string[];
@@ -11,9 +11,10 @@ export function scopePaths(card) {
11
11
  export function scopesOverlap(a, b) {
12
12
  return a.some(x => b.some(y => x === "." || y === "." || x === y || x.startsWith(`${y}/`) || y.startsWith(`${x}/`)));
13
13
  }
14
- /** Only promotion/dispatch collisions ignore tests; write permissions and land diffs stay complete. */
14
+ /** Promotion/dispatch collisions concern code, ignoring tests and the generated engine.lock.
15
+ * Write permissions and land diffs stay complete. */
15
16
  export function collisionScope(scope) {
16
- return scope.filter(file => !/(^|\/)(?:__tests__|tests)(?:\/|$)|\.(?:test|spec)\.[^/]+$/.test(file));
17
+ return scope.filter(file => posix.normalize(file).replace(/\/$/, "") !== "packages/client/engine.lock" && !/(^|\/)(?:__tests__|tests)(?:\/|$)|\.(?:test|spec)\.[^/]+$/.test(file));
17
18
  }
18
19
  /** Dispatch only, normalized paths. ownerChanges: omitted = candidate, array = owner delta, null = unknown IO. */
19
20
  export function dispatchScope(paths, confirmedTestDirectories, ownerChanges) {
@@ -1 +1 @@
1
- {"schema":1,"sha":"6c3b20e80a8be698452a2c6ccf9ad59d74ff87f8","dirty":false}
1
+ {"schema":1,"sha":"d7a8316d16701e715d7f725bfbfed210e0581dc4","dirty":false}
@@ -1692,14 +1692,14 @@
1692
1692
  "staticOperations": {
1693
1693
  "beforePreflight": {
1694
1694
  "module": "maszynista/tick.ts",
1695
- "startLine": 10258,
1696
- "endLine": 10371,
1695
+ "startLine": 10272,
1696
+ "endLine": 10385,
1697
1697
  "text": "export async function main(): Promise<number> {\n const start = standaloneStartCheck({ filename: __filename, env: process.env });\n if (start.standalone && !start.ok) {\n console.error(start.message);\n process.exitCode = 78;\n return 78;\n }\n let installation: EngineContext;\n try { installation = createEngineContext(currentEngine(), {\n loadEnvironment: loadEnvFiles, preflight, baseRef: engineBaseRef, refreshBase: fetchMain,\n disk: defaultDiskPressureDependencies, workerContext: loadNorthStar,\n controlEnv: hostEnv, workerEnv: executionEnv, prepareWorktree: prepareHostWorktree, workerArtifacts: createWorkerTmpdir,\n notify: async (card, reason) => { decisionForReksio(card, reason, \"Rozstrzygnij na karcie\", \"\", \"\"); return { outcome: \"recorded\", ref: DECISIONS_REKSIO }; },\n hostOperations: hostOperationsPhase,\n activation: { confirmLoaded, finishHostActivation, readActivationState, recoverTickTimeout, runEnabledAuto },\n }, git, log); }\n catch (error) {\n if (!engineClient()) throw error;\n console.error(`HOLD kontekst klienta: ${clientTickFailure(error)}`);\n process.exitCode = 78;\n return 78;\n }\n const previousInstallation = tickInstallation;\n const hostErrorText = errorText;\n const client = engineClient();\n const result: { outcome: \"ok\" | \"retry\" | \"stop\"; reason: string; cleanup: boolean } = { outcome: \"ok\", reason: \"\", cleanup: false };\n const stopClient = (reason = clientTickFailure()): void => {\n if (client && result.outcome !== \"stop\") { result.outcome = \"stop\"; result.reason = reason; }\n };\n let code = 2;\n try { code = await q.withPlannerQueries(installation.planner, async () => {\n tickInstallation = installation;\n const seedGateSettings = installationSeedGateSettings();\n const errorText = client ? clientTickFailure : hostErrorText;\n const loadEnvFiles = installation.loadEnvironment;\n const preflight = () => {\n const actor = installation.preflight();\n return { uid: actor.kind === \"db\" ? actor.uid : API_ACTOR };\n };\n const { confirmLoaded, finishHostActivation, readActivationState, recoverTickTimeout, runEnabledAuto } = installation.activation;\n const smokeOnly = DRY && process.env.MASZYNISTA_SMOKE === \"1\";\n if (!DRY) {\n const acquire = (): boolean => tryCreateTickLock(LOCK);\n if (!acquire()) {\n const raw = readFileSync(LOCK, \"utf8\"), pid = Number(raw);\n if (!Number.isSafeInteger(pid) || pid <= 0) { console.log(\"tick lock bez poprawnego PID — HOLD\"); return 0; }\n try { process.kill(pid, 0); console.log(`tick już trwa (pid ${pid})`); return 0; }\n catch (error) { if ((error as NodeJS.ErrnoException).code !== \"ESRCH\") throw error; }\n if (readFileSync(LOCK, \"utf8\") === raw) unlinkSync(LOCK);\n if (!acquire()) { console.log(\"tick już trwa\"); return 0; }\n }\n }\n skippedCardEvents.clear();\n let s = parseState(null).state;\n // Internal smoke handoff: the child cannot outlive the parent's reserved budget.\n const smokeLimit = DRY ? Number(process.env.MASZYNISTA_SMOKE_TIMEOUT_MS) : NaN;\n let stateLoaded = false;\n let tickStarted: string | undefined;\n let outcome: \"ok\" | \"failed\" = \"ok\";\n let runtimeFailed = false;\n let observedLoaded = \"UNKNOWN\";\n let tickPhase = \"startup\";\n const deadlineAlarm = armTickDeadline(() => s, Number.isSafeInteger(smokeLimit) && smokeLimit > 0\n ? Math.min(TICK_LIMIT_MS, smokeLimit) : TICK_LIMIT_MS, () => ({ phase: tickPhase, observedLoaded }));\n let hostReady = false;\n let hostBoard: { uid: string; projectId: string } | undefined;\n let activationCards: CardLike[] = [];\n let activationCardsKnown = false;\n let blockedBefore = 0;\n const clientStopped = (): boolean => {\n if (client && (outcome === \"failed\" || (!DRY && s.blocked > blockedBefore))) stopClient();\n if (client && result.outcome === \"stop\") outcome = \"failed\";\n return client && result.outcome === \"stop\";\n };\n let hostPhaseStarted = false;\n const hostPhase = async (): Promise<boolean> => {\n if (smokeOnly || !hostReady || hostPhaseStarted) return false;\n hostPhaseStarted = true;\n tickPhase = \"host\";\n if (hostBoard) {\n const { uid: boardUid, projectId: boardProject } = hostBoard;\n try {\n await runEnabledAuto({ state: s, loadedSha: observedLoaded, repo: REPO, logPath: LOG, tick: s.tick, stateDir: hostStateDir(),\n now: new Date().toISOString(), activation: readActivationState(hostStateDir()), dryRun: DRY }, {\n listCards: async () => scanTasks(boardUid, boardProject, { full: true, statuses: [\"delivered\"],\n detailsKeys: ENABLED_SCAN_DETAILS_KEYS }),\n getTask: id => q.getTask(boardUid, id),\n appendDetail: async (id, patch) => { await appendBoundedDetail(boardUid, id, patch); },\n saveState: writeState,\n alarm: hostActivationAlarm,\n log,\n });\n } catch (error) { runtimeFailed = true; outcome = \"failed\"; log(`FAIL ENABLED auto: ${errorText(error)}`); }\n } else log(\"ENABLED auto: UNKNOWN — brak odczytu projektu; dowód karty czeka na dostęp do tablicy\");\n try {\n const result = await engineRunHostActivation({ repo: REPO, stateDir: hostStateDir(), cards: activationCards, cardsKnown: activationCardsKnown, tick: s.tick, dryRun: DRY }, {\n git, remainingTickMs, alarm: hostActivationAlarm, infrastructureChecks, infrastructurePullRequest, log: line => log(`host-activation: ${line}`),\n });\n log(`host-activation: code=${result.code} target=${result.target ?? \"UNKNOWN\"}${result.detail ? ` reason=${result.detail}` : \"\"}`);\n if (result.code === \"activate\" && result.target) {\n lastTick(s, \"activation\", `aktywacja ${result.target}; ogon odroczony`, outcome === \"ok\");\n return true;\n }\n } catch (error) { runtimeFailed = true; outcome = \"failed\"; log(`FAIL aktywacja: ${errorText(error)}`); }\n return false;\n };\n try {\n observedLoaded = loadedSha = readLoadedSha(REPO);\n s = readState((await engineFjConfig()).enabled);\n stateLoaded = true; blockedBefore = s.blocked;\n s.tick++; tickStarted = new Date().toISOString(); s.lastTickAt = tickStarted;\n log(`tick_started tick=${s.tick} at=${tickStarted} duration=UNKNOWN loaded=${loadedSha}`);\n loadEnvFiles();\n const { uid } = preflight();"
1698
1698
  },
1699
1699
  "finalization": {
1700
1700
  "module": "maszynista/tick.ts",
1701
- "startLine": 10662,
1702
- "endLine": 10714,
1701
+ "startLine": 10676,
1702
+ "endLine": 10728,
1703
1703
  "text": " } finally {\n // A persisted terminal FAIL is a card result; every unexpected exception above\n // remains a runtime failure, including DB errors inside card handling.\n if (!DRY && s.blocked > blockedBefore) {\n outcome = \"failed\";\n try { log(`FAIL: licznik blocked wzrósł ${blockedBefore} → ${s.blocked}; outcome=failed`); }\n catch (error) { console.error(`zapis licznika blocked: ${errorText(error)}`); }\n }\n clientStopped();\n // Early board failure still reaches the same host phase, at most once per tick.\n await hostPhase();\n tickPhase = \"finalizing\";\n try { if (!DRY) await finishHostActivation({ stateDir: hostStateDir(), outcome, tick: s.tick, runtimeFailed, observedLoaded }, { alarm: hostActivationAlarm, log }); }\n catch (error) { runtimeFailed = true; outcome = \"failed\"; log(`FAIL breaker aktywacji: ${errorText(error)}`); }\n clientStopped();\n try { if (stateLoaded) writeState(s); }\n catch (error) { runtimeFailed = true; outcome = \"failed\"; if (!client) throw error; stopClient(); result.cleanup = true; }\n finally {\n if (!DRY) {\n try { if (readFileSync(LOCK, \"utf8\") === String(process.pid)) unlinkSync(LOCK); }\n catch (error) { if ((error as NodeJS.ErrnoException).code !== \"ENOENT\") { if (!client) throw error; stopClient(); result.cleanup = true; } }\n }\n const at = new Date().toISOString();\n const duration = tickStarted ? `${(Date.parse(at) - Date.parse(tickStarted)) / 1000}s` : \"UNKNOWN\";\n try {\n const { total, ops } = drainEgressCounters();\n const sorted = Object.entries(ops).sort(([, a], [, b]) => b.bytes - a.bytes);\n const summary = sorted.filter(([op]) => !op.includes(\":\")).slice(0, 12)\n .map(([op, counter]) => `${op}:${counter.calls}:${counter.bytes}`).join(\",\");\n const variants = sorted.filter(([op]) => op.includes(\":\")).slice(0, 6)\n .map(([op, counter]) => `${op}:${counter.calls}:${counter.bytes}`).join(\",\");\n log(`egress tick=${s.tick} total=${total} ops=${summary} variants=${variants}`);\n } catch { /* Optional metrics must never interrupt tick cleanup. */ }\n try { refreshTickReport(observedLoaded); log(`tick_finished tick=${s.tick} at=${at} outcome=${client && result.outcome === \"retry\" ? \"retry\" : outcome} duration=${duration} loaded=${loadedSha}`); }\n finally { clearTimeout(deadlineAlarm); tickDeadline = Number.POSITIVE_INFINITY; }\n }\n }\n }); } catch (error) {\n if (!client) throw error;\n stopClient(); result.cleanup = true;\n } finally {\n tickInstallation = previousInstallation;\n try { await installation.close(); }\n catch (error) {\n if (client) { stopClient(); result.cleanup = true; }\n else safeLog(`Zamknięcie instalacji nieudane: ${String(error)}`);\n }\n }\n if (client && result.outcome !== \"ok\") console.error(`Fabryka ${result.outcome === \"stop\" ? \"zatrzymana\" : \"retry\"}: ${result.reason}${result.cleanup ? \"; finalizacja niepotwierdzona — sprawdź stan i blokadę\" : \"\"}`);\n return client && result.outcome === \"stop\" ? 2 : code;\n}\n\nif (require.main === module && !([\"--opencode-runner\", \"--grok-runner\"].includes(process.argv[2] ?? \"\"))) {"
1704
1704
  },
1705
1705
  "refreshTickReport": {
@@ -1725,6 +1725,6 @@
1725
1725
  "status": 0,
1726
1726
  "signal": null,
1727
1727
  "stdout": "v24.3.0\n",
1728
- "stderr": "(node:24341) 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:24508) 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.4";
37655
+ PACKAGE_VERSION = "0.6.6";
37656
37656
  SUPPORTED_CONTRACT_MAJOR = 1;
37657
37657
  DEFAULT_ORIGIN = "https://robisie.app";
37658
37658
  MCP_SERVER_NAME = "robisie";
@@ -48143,7 +48143,7 @@ function scopesOverlap(a, b) {
48143
48143
  return a.some((x) => b.some((y) => x === "." || y === "." || x === y || x.startsWith(`${y}/`) || y.startsWith(`${x}/`)));
48144
48144
  }
48145
48145
  function collisionScope(scope) {
48146
- return scope.filter((file3) => !/(^|\/)(?:__tests__|tests)(?:\/|$)|\.(?:test|spec)\.[^/]+$/.test(file3));
48146
+ return scope.filter((file3) => import_node_path5.posix.normalize(file3).replace(/\/$/, "") !== "packages/client/engine.lock" && !/(^|\/)(?:__tests__|tests)(?:\/|$)|\.(?:test|spec)\.[^/]+$/.test(file3));
48147
48147
  }
48148
48148
  function dispatchScope(paths, confirmedTestDirectories2, ownerChanges) {
48149
48149
  if (ownerChanges !== void 0 && !paths.length) return ["."];
@@ -49603,6 +49603,8 @@ function reconcileActive(input) {
49603
49603
  if ("engine" in meta4) stamp2.engine = meta4.engine;
49604
49604
  if (fromState.backend) stamp2.backend = fromState.backend;
49605
49605
  if (fromState.model) stamp2.model = fromState.model;
49606
+ const provider = fromState.provider ?? meta4.provider;
49607
+ if (nonempty(provider)) stamp2.provider = provider;
49606
49608
  if (fromState.opencode) stamp2.opencode = fromState.opencode;
49607
49609
  actives.push(active);
49608
49610
  adopted.push({ active, stamp: stamp2 });
@@ -323047,6 +323049,12 @@ async function reconcileBoardActives(s, uid, boardCards2, installation = tickIns
323047
323049
  }
323048
323050
  return handled;
323049
323051
  }
323052
+ function workerIdentity(meta4, client = engineClient()) {
323053
+ return {
323054
+ ...Object.fromEntries(["backend", "model", "engine", "grok", "opencode"].filter((key) => meta4[key] !== void 0).map((key) => [key, meta4[key]])),
323055
+ ...typeof meta4.provider === "string" && meta4.provider.trim() ? { provider: meta4.provider } : !client && meta4.backend === "codex" ? { provider: "openai" } : {}
323056
+ };
323057
+ }
323050
323058
  async function consumeActive(s, uid, a = s.actives[0], landing = { available: true }, bootAt, installation = tickInstallation) {
323051
323059
  if (!a) return false;
323052
323060
  const diagnostic = (phase, reason) => {
@@ -323180,6 +323188,7 @@ async function consumeActive(s, uid, a = s.actives[0], landing = { available: tr
323180
323188
  engine: metadata.engine,
323181
323189
  startedAt: metadata.startedAt
323182
323190
  } : {},
323191
+ ...engineClient() ? {} : workerIdentity(metadata),
323183
323192
  branchLease: metadata.branchLease ?? null,
323184
323193
  at: (/* @__PURE__ */ new Date()).toISOString(),
323185
323194
  jobId: a.jobId,
@@ -323540,6 +323549,7 @@ async function consumeActive(s, uid, a = s.actives[0], landing = { available: tr
323540
323549
  ...atCapacity && !openCodeJob ? { codex_model: capacityModel } : {},
323541
323550
  maszynista: {
323542
323551
  ...clientPair ? { clientPair, ...metadata.clientReceiver !== void 0 ? { clientReceiver: metadata.clientReceiver } : {}, backend: metadata.backend, model: metadata.model, engine: metadata.engine, startedAt: metadata.startedAt } : {},
323552
+ ...clientPair ? {} : workerIdentity(metadata),
323543
323553
  branchLease: metadata.branchLease ?? null,
323544
323554
  artifacts: metadata.artifacts ?? null,
323545
323555
  input_sha256: metadata.input_sha256 ?? null,
@@ -323576,6 +323586,8 @@ async function consumeActive(s, uid, a = s.actives[0], landing = { available: tr
323576
323586
  } : {}
323577
323587
  }
323578
323588
  };
323589
+ if (!engineClient() && (typeof evidence2.maszynista.provider !== "string" || !evidence2.maszynista.provider.trim()))
323590
+ log2(`ALARM stempel ${card.id}: brak dostawcy Workera`);
323579
323591
  const event = await prepareCardEvent(uid, card, "terminal", JSON.stringify([a.jobId, a.attempts]), { key: "maszynista", value: { jobId: a.jobId, attempts: a.attempts, outcome: workerOutcome }, statuses: [move.status === "retry" ? "ready" : move.status, "delivered", "done"] }, evidence2.maszynista);
323580
323592
  if (!DRY2) await appendBoundedDetail(uid, a.taskId, evidence2);
323581
323593
  card.details = { ...card.details, ...evidence2 };
@@ -325911,6 +325923,7 @@ TMPDIR tej pr\xF3by: ${localArtifacts.tmpdir}. Kopie tw\xF3rz przez mktemp -d "$
325911
325923
  engine: { model: job.model, effort: clientConfig || job.backend === "codex" ? engine.effort : "n/a", note: job.backend === "codex" ? engine.note : null },
325912
325924
  backend: job.backend,
325913
325925
  model: job.model,
325926
+ ...!clientConfig && job.backend === "codex" ? { provider: "openai" } : {},
325914
325927
  ...job.grok ? { grok: job.grok, provider: "xai" } : {},
325915
325928
  ...asRecord3(c.details?.maszynista).grokStartFallback ? { grokStartFallback: {
325916
325929
  reason: asRecord3(asRecord3(c.details?.maszynista).grokStartFallback).reason,
@@ -327713,6 +327726,7 @@ async function dispatchNext(s, uid, projectId2, diskDependencies, cards = /* @__
327713
327726
  worktree: worker.worktree,
327714
327727
  branch: worker.branch
327715
327728
  } : {},
327729
+ ...engineClient() ? {} : workerIdentity(worker),
327716
327730
  at: (/* @__PURE__ */ new Date()).toISOString(),
327717
327731
  verdict: "human",
327718
327732
  reason: verdict.reason,
@@ -1,7 +1,7 @@
1
1
  import { spawnSync } from 'node:child_process';
2
2
  import { createHash } from 'node:crypto';
3
3
  import * as fs from 'node:fs';
4
- import { dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
4
+ import { basename, dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
5
5
  import { createInterface } from 'node:readline/promises';
6
6
  import { fileURLToPath } from 'node:url';
7
7
  import { isDeepStrictEqual } from 'node:util';
@@ -410,7 +410,7 @@ export async function runInstallationUpdate(ctx, options, overrides = {}) {
410
410
  notifyFailure = host ? () => alarm('Aktualizacja nieudana; sprawdź prywatny audyt i potwierdzenie powrotu.') : undefined;
411
411
  const legacyState = env.HU_STATE || join(hostHome, 'auto-update.state');
412
412
  let legacyAttempt;
413
- const defer = () => {
413
+ const defer = (reason) => {
414
414
  if (legacyAttempt) {
415
415
  if (!regular(legacyState).equals(legacyAttempt.saved))
416
416
  refuse('Rejestr starego agenta zmienił się przed odroczeniem.');
@@ -441,11 +441,12 @@ export async function runInstallationUpdate(ctx, options, overrides = {}) {
441
441
  const alarmed = previous?.alarmed === true || runtime.now() - since >= 7_200_000;
442
442
  io.writeFileSync(path, JSON.stringify({ since, alarmed }), { mode: 0o600, flush: true });
443
443
  if (alarmed && previous?.alarmed !== true) {
444
- audit('deferred-alarm', { since });
445
- ctx.err('Alarm: aktualizacja odroczona od co najmniej 7200 sekund.');
446
- alarm('Aktualizacja odroczona od co najmniej 7200 sekund: Worker w toku.');
444
+ audit('deferred-alarm', { since, reason });
445
+ const message = `Aktualizacja odroczona od co najmniej 7200 sekund: ${reason}.`;
446
+ ctx.err(`Alarm: ${message}`);
447
+ alarm(message);
447
448
  }
448
- ctx.out('Aktualizacja odroczona: trwa praca fabryki.');
449
+ ctx.out(`Aktualizacja odroczona: ${reason}.`);
449
450
  return 0;
450
451
  };
451
452
  serialRelease = acquire(join(update, '.update.lock')) ?? undefined;
@@ -453,37 +454,152 @@ export async function runInstallationUpdate(ctx, options, overrides = {}) {
453
454
  ctx.out('Aktualizacja odroczona: inny aktualizator już działa.');
454
455
  return 0;
455
456
  }
457
+ const hostPlist = host ? env.HU_PLIST || join(ctx.home, 'Library/LaunchAgents/com.robisie.maszynista.plist') : null;
458
+ let hostService;
459
+ const readHostService = () => {
460
+ if (!hostPlist || hostService)
461
+ return;
462
+ const original = regular(hostPlist);
463
+ const service = json(Buffer.from(command('plutil', ['-convert', 'json', '-o', '-', hostPlist])));
464
+ const args = service.ProgramArguments;
465
+ if (service.Label !== 'com.robisie.maszynista' || !Array.isArray(args) || args.length !== 7
466
+ || !args.every(arg => typeof arg === 'string') || !isAbsolute(args[0]) || !isAbsolute(args[1])
467
+ || !isDeepStrictEqual(args.slice(2, 6), ['factory', 'run', '--once', '--engine-config'])
468
+ || io.realpathSync(args[6]) !== configPath || !args[1].endsWith('/dist/cli.js')
469
+ || object(service.EnvironmentVariables) && service.EnvironmentVariables.ROBISIE_ENGINE_CONFIG !== undefined
470
+ && io.realpathSync(String(service.EnvironmentVariables.ROBISIE_ENGINE_CONFIG)) !== configPath)
471
+ refuse('Niepoprawna tożsamość hostowego plista, paczki lub konfiguracji.');
472
+ hostService = { original, current: original, prepared: Buffer.alloc(0), cli: args[1], originalCli: args[1] };
473
+ };
474
+ const processEntry = (path) => {
475
+ if (!isAbsolute(path))
476
+ return null;
477
+ try {
478
+ return io.realpathSync(path);
479
+ }
480
+ catch (error) {
481
+ if (code(error) === 'ENOENT' || code(error) === 'ENOTDIR')
482
+ return null;
483
+ refuse('Nieustalony stan procesów fabryki.');
484
+ }
485
+ };
486
+ const alive = (pid, name) => {
487
+ try {
488
+ runtime.kill(pid, 0);
489
+ return true;
490
+ }
491
+ catch (error) {
492
+ if (code(error) === 'ESRCH')
493
+ return false;
494
+ refuse(`Nieustalony stan procesu: ${name}; zachowaj stan.`);
495
+ }
496
+ };
456
497
  const processBusy = () => {
457
- const output = command('ps', ['-axo', 'pid=,command=']);
458
- for (const line of output.split('\n').filter(line => line.trim())) {
459
- const match = line.match(/^\s*([1-9]\d*)\s+(.+)$/);
460
- if (!match)
498
+ const result = runtime.exec('ps', ['-axo', 'pid=,command='], ctx.cwd, env);
499
+ if (result.status !== 0 || result.signal !== null)
500
+ refuse('Nieustalony stan procesów fabryki.');
501
+ let busy = null;
502
+ for (const line of result.stdout.split('\n').filter(line => line.trim())) {
503
+ const match = line.match(/^\s*([1-9]\d*)\s+(\S.*)$/);
504
+ if (!match || !Number.isSafeInteger(Number(match[1])))
461
505
  refuse('Nieustalony stan procesów fabryki.');
462
506
  if (Number(match[1]) === runtime.pid)
463
507
  continue;
464
- if (/\bfactory\s+run\b|(?:^|[\/\s])tick\.(?:cjs|ts|js)(?:\s|$)|\bcodex\b[^\n]*\bexec\b/.test(match[2]))
465
- return true;
508
+ const tokens = match[2].trim().split(/\s+/).slice(0, 8), name = basename(tokens[0]);
509
+ const entry = tokens[1] === '--import' && tokens[2] === 'tsx' ? 3 : 1;
510
+ const script = basename(tokens[entry] ?? '');
511
+ const job = /\.(?:cjs|mjs|js)$/.test(script) && tokens[entry + 1] === '--job'
512
+ && ['tester', 'receiver'].includes(tokens[entry + 2] ?? '') && Boolean(tokens[entry + 3]);
513
+ let factory = false;
514
+ if (name === 'node' && (/^(?:tick|tester-job|receiver-job)\.(?:cjs|ts|js)$/.test(script) || script === 'cli.js' || job)) {
515
+ readHostService();
516
+ const path = processEntry(tokens[entry]);
517
+ if (path) {
518
+ const dirs = [dirname(fileURLToPath(runtime.moduleUrl))];
519
+ if (hostService)
520
+ dirs.push(dirname(hostService.cli));
521
+ const current = join(update, 'current');
522
+ if (stat(current))
523
+ dirs.push(join(io.realpathSync(current), 'dist'));
524
+ const cli = dirs.some(dir => processEntry(join(dir, 'cli.js')) === path);
525
+ // build-engine.mjs emits tick.cjs; aliases must resolve to that entrypoint.
526
+ const bundle = dirs.some(dir => processEntry(join(dir, 'engine/tick.cjs')) === path);
527
+ const source = /^(?:tick|tester-job|receiver-job)\.(?:cjs|ts|js)$/.test(basename(path))
528
+ && dirname(path) === join(repo, 'maszynista');
529
+ factory = cli && tokens[entry + 1] === 'factory' && tokens[entry + 2] === 'run'
530
+ || bundle || source;
531
+ }
532
+ }
533
+ const active = name === 'node' && (factory
534
+ || script === 'codex-companion.mjs' && tokens[entry + 1] === 'task-worker')
535
+ || name === 'codex' && tokens.slice(1, 4).includes('exec')
536
+ || name === 'claude' && tokens.slice(1, 6).some(token => token === '-p' || token === '--print');
537
+ if (active)
538
+ busy ??= `proces ${/^[A-Za-z0-9._-]+$/.test(name) ? name : 'fabryki'} PID ${match[1]}`;
466
539
  }
467
- return false;
540
+ return busy;
468
541
  };
469
542
  const preflight = async () => {
470
543
  check();
471
- const busy = processBusy();
544
+ let busy = null;
472
545
  for (const claim of ['.tester-job.lock', '.tester-job.input.json', '.tester-job.result.json',
473
546
  ...['claim.json', 'started', 'wynik.json', 'stop.json', 'ack.json'].map(name => `receiver-jobs/local/${name}`)]) {
474
- for (const suffix of ['', '.pending'])
475
- if (stat(join(state, claim + suffix)))
476
- refuse('Nierozliczony claim testera lub odbiorcy; zachowaj stan.');
547
+ for (const suffix of ['', '.pending']) {
548
+ const name = claim + suffix, path = join(state, name);
549
+ let exists = false;
550
+ try {
551
+ const file = stat(path);
552
+ if (!file)
553
+ continue;
554
+ exists = true;
555
+ if (!['.tester-job.lock', 'receiver-jobs/local/claim.json'].includes(claim) || !file.isFile())
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))
560
+ throw new Error('unsafe claim');
561
+ if (!alive(pid, name))
562
+ throw new Error('dead claim');
563
+ busy ??= `claim ${name}`;
564
+ }
565
+ catch {
566
+ refuse(`${exists ? 'Nierozliczony' : 'Nieczytelny'} claim ${name}; zachowaj stan.`);
567
+ }
568
+ }
477
569
  }
570
+ for (const name of ['.tick.lock', '.factory-run.lock']) {
571
+ const path = join(state, name);
572
+ try {
573
+ const file = stat(path);
574
+ if (!file)
575
+ continue;
576
+ const bytes = regular(path), token = bytes.toString('utf8').trim();
577
+ const match = token.match(name === '.tick.lock' ? /^([1-9]\d*)$/ : /^([1-9]\d*) [0-9a-fA-F-]{36}$/);
578
+ if (!match || !Number.isSafeInteger(Number(match[1])))
579
+ throw new Error('invalid lock');
580
+ const live = Number(match[1]) !== runtime.pid && alive(Number(match[1]), name), fresh = stat(path);
581
+ if (!fresh || fresh.ino !== file.ino || fresh.dev !== file.dev || !regular(path).equals(bytes))
582
+ throw new Error('changed lock');
583
+ if (live)
584
+ busy ??= `blokada ${name}`;
585
+ }
586
+ catch {
587
+ refuse(`Nieustalony stan blokady ${name}; zachowaj stan.`);
588
+ }
589
+ }
590
+ const processReason = processBusy();
591
+ busy ??= processReason;
478
592
  if (host) {
479
593
  const report = stat(lastTick);
480
- let workerBusy = false;
481
594
  if (report && runtime.now() - report.mtimeMs <= 600_000) {
482
595
  const lines = regular(lastTick).toString('utf8').match(/^- detail: wykonania .+$/gm);
483
596
  const counter = lines?.length === 1 ? lines[0].match(/^- detail: wykonania (0|[1-9]\d*)\/([1-9]\d*)(?:[ ,;].*)?$/) : null;
484
- workerBusy = !counter || !Number.isSafeInteger(Number(counter[1])) || !Number.isSafeInteger(Number(counter[2])) || Number(counter[1]) !== 0;
597
+ if (!counter || !Number.isSafeInteger(Number(counter[1])) || !Number.isSafeInteger(Number(counter[2])))
598
+ busy ??= 'LAST-TICK: nieustalony licznik wykonań';
599
+ else if (Number(counter[1]) !== 0)
600
+ busy ??= `LAST-TICK: wykonania ${counter[1]}/${counter[2]}`;
485
601
  }
486
- return { busy: busy || workerBusy, own: [] };
602
+ return { busy, own: [] };
487
603
  }
488
604
  const rows = await board.listTasks({ projectId: config.project, statuses: ['in_progress'], detailsKeys: [] });
489
605
  if (!Array.isArray(rows))
@@ -503,23 +619,10 @@ export async function runInstallationUpdate(ctx, options, overrides = {}) {
503
619
  }
504
620
  return { busy, own };
505
621
  };
506
- if ((await preflight()).busy)
507
- return defer();
508
- const hostPlist = host ? env.HU_PLIST || join(ctx.home, 'Library/LaunchAgents/com.robisie.maszynista.plist') : null;
509
- let hostService;
510
- if (hostPlist) {
511
- const original = regular(hostPlist);
512
- const service = json(Buffer.from(command('plutil', ['-convert', 'json', '-o', '-', hostPlist])));
513
- const args = service.ProgramArguments;
514
- if (service.Label !== 'com.robisie.maszynista' || !Array.isArray(args) || args.length !== 7
515
- || !args.every(arg => typeof arg === 'string') || !isAbsolute(args[0]) || !isAbsolute(args[1])
516
- || !isDeepStrictEqual(args.slice(2, 6), ['factory', 'run', '--once', '--engine-config'])
517
- || io.realpathSync(args[6]) !== configPath || !args[1].endsWith('/dist/cli.js')
518
- || object(service.EnvironmentVariables) && service.EnvironmentVariables.ROBISIE_ENGINE_CONFIG !== undefined
519
- && io.realpathSync(String(service.EnvironmentVariables.ROBISIE_ENGINE_CONFIG)) !== configPath)
520
- refuse('Niepoprawna tożsamość hostowego plista, paczki lub konfiguracji.');
521
- hostService = { original, current: original, prepared: Buffer.alloc(0), cli: args[1], originalCli: args[1] };
522
- }
622
+ const initial = await preflight();
623
+ if (initial.busy)
624
+ return defer(initial.busy);
625
+ readHostService();
523
626
  const pointer = join(update, 'current');
524
627
  if (stat(pointer) && !stat(pointer)?.isSymbolicLink())
525
628
  refuse('Żywy wskaźnik musi być dowiązaniem aktualizatora.');
@@ -564,14 +667,15 @@ export async function runInstallationUpdate(ctx, options, overrides = {}) {
564
667
  // A second precheck under the same lock as tick precedes card writes and the release attempt.
565
668
  tickRelease = acquire(join(state, '.tick.lock')) ?? undefined;
566
669
  if (!tickRelease)
567
- return defer();
670
+ return defer('blokada .tick.lock');
568
671
  const second = await preflight();
569
672
  if (second.busy)
570
- return defer();
673
+ return defer(second.busy);
571
674
  for (const card of second.own) {
572
675
  check();
573
- if (processBusy())
574
- return defer();
676
+ const activity = await preflight();
677
+ if (activity.busy)
678
+ return defer(activity.busy);
575
679
  const echo = await board.updateTask({ id: card.id, status: 'blocked', expected: { status: 'in_progress', details: card.details } });
576
680
  if (echo.id !== card.id || echo.status !== 'blocked')
577
681
  refuse('Niepotwierdzony CAS blocked; nie ponowiono zapisu.');
@@ -618,9 +722,9 @@ export async function runInstallationUpdate(ctx, options, overrides = {}) {
618
722
  regular(join(next, 'dist/engine/tick.cjs'));
619
723
  const prepared = await preflight();
620
724
  if (prepared.busy)
621
- return defer();
725
+ return defer(prepared.busy);
622
726
  if (prepared.own.length)
623
- return defer();
727
+ return defer('karta maszynisty in_progress');
624
728
  const launcher = join(update, 'launch.mjs');
625
729
  const launcherText = `// robisie:update-managed
626
730
  import {realpathSync} from 'node:fs';
@@ -964,7 +1068,7 @@ try {
964
1068
  const activating = await preflight();
965
1069
  if (activating.busy || activating.own.length) {
966
1070
  rollback = undefined;
967
- return defer();
1071
+ return defer(activating.busy ?? 'karta maszynisty in_progress');
968
1072
  }
969
1073
  rememberTick();
970
1074
  const switchedAt = runtime.now();
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.4 \u2014 plik zarz\u0105dzany przez `npx robisie`; `npx robisie uninstall` go usunie -->";
20
+ export declare const MANAGED_LINE = "<!-- robisie:managed 0.6.6 \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.4) <!-- x-release-please-version -->
1
+ # robisie — from account to accepted card (package 0.6.6) <!-- 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.4) <!-- x-release-please-version -->
1
+ # robisie — od konta do odebranej karty (paczka 0.6.6) <!-- 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.4",
3
+ "version": "0.6.6",
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",