pi-web-ui 0.116.0 → 0.117.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. package/CHANGELOG.md +38 -4
  2. package/bin/device-hub-cli.mjs +26 -3
  3. package/bin/pi-web-ui.mjs +138 -70
  4. package/dist/server/agent-service-daemon.js +52 -6
  5. package/dist/server/agent-service.js +495 -141
  6. package/dist/server/canvas/canvas-workspace.js +18 -86
  7. package/dist/server/client-state.js +35 -6
  8. package/dist/server/compaction-markers.js +43 -24
  9. package/dist/server/dangling-tools.js +172 -16
  10. package/dist/server/device-center/bot-execution.js +48 -1
  11. package/dist/server/device-center/collab-service.js +26 -8
  12. package/dist/server/device-center/collab-tool.js +394 -18
  13. package/dist/server/device-center/connector.js +107 -37
  14. package/dist/server/device-center/delivery-authority.js +98 -0
  15. package/dist/server/device-center/delivery-subject.js +30 -0
  16. package/dist/server/device-center/device-integration.js +453 -183
  17. package/dist/server/device-center/execution-guides.js +15 -5
  18. package/dist/server/device-center/executor.js +47 -5
  19. package/dist/server/device-center/hub-conversations.js +14 -4
  20. package/dist/server/device-center/hub-deliveries.js +120 -15
  21. package/dist/server/device-center/hub-integration.js +655 -334
  22. package/dist/server/device-center/hub-page.js +5 -4
  23. package/dist/server/device-center/hub-setup.js +23 -1
  24. package/dist/server/device-center/hub-transaction-log.js +197 -0
  25. package/dist/server/device-center/hub.js +772 -354
  26. package/dist/server/device-center/integration-verification.js +113 -0
  27. package/dist/server/device-center/local-hub.js +6 -2
  28. package/dist/server/device-center/local-publication.js +423 -0
  29. package/dist/server/device-center/local-verification-job.js +97 -0
  30. package/dist/server/device-center/local-verification.js +274 -0
  31. package/dist/server/device-center/local.js +107 -12
  32. package/dist/server/device-center/main.js +4 -1
  33. package/dist/server/device-center/partition-log.js +62 -25
  34. package/dist/server/device-center/publication-journal.js +312 -0
  35. package/dist/server/device-center/publish-intent.js +379 -0
  36. package/dist/server/device-center/relay.js +134 -24
  37. package/dist/server/device-center/runtime.js +426 -42
  38. package/dist/server/device-center/store.js +225 -47
  39. package/dist/server/device-center/task-outcome.js +81 -0
  40. package/dist/server/device-center/task-recovery.js +603 -178
  41. package/dist/server/device-center/task-settlement.js +353 -0
  42. package/dist/server/device-center/task-workspace.js +443 -0
  43. package/dist/server/device-center/verification-limits.js +10 -0
  44. package/dist/server/device-center/work-contract.js +995 -0
  45. package/dist/server/dispatch-domain-handlers.js +15 -0
  46. package/dist/server/dsh/dsh-agent-service.js +9 -2
  47. package/dist/server/index.js +26 -1
  48. package/dist/server/patch-node-pty.js +3 -2
  49. package/dist/server/patch-remote-catalog.js +3 -2
  50. package/dist/server/preset-fields.js +17 -1
  51. package/dist/server/preset-share.js +1 -0
  52. package/dist/server/protocol-version.js +1 -1
  53. package/dist/server/quick-ask-settings.js +28 -0
  54. package/dist/server/quick-ask.js +164 -0
  55. package/dist/server/resolve-global-sdk.js +61 -11
  56. package/dist/server/scheduler-tasks.js +35 -8
  57. package/dist/server/session-list-scan.js +223 -0
  58. package/dist/server/session-open.js +93 -0
  59. package/dist/server/session-parser.js +4 -0
  60. package/dist/server/session-scan.js +90 -38
  61. package/dist/server/settings-service.js +9 -1
  62. package/dist/server/soft-cap.js +5 -0
  63. package/dist/server/transcript-prepare.js +73 -0
  64. package/dist/server/universal/drivers/claude-code.js +98 -34
  65. package/dist/server/universal/universal-session.js +4 -0
  66. package/dist/server/workspace-handle.js +428 -0
  67. package/docs/architecture-plugins.md +18 -5
  68. package/docs/device-center.md +30 -22
  69. package/package.json +3 -4
  70. package/plugin-sdk/README.md +16 -8
  71. package/plugin-sdk/client.d.ts +27 -0
  72. package/plugin-sdk/client.mjs +82 -0
  73. package/plugin-sdk/index.d.ts +10 -0
  74. package/plugin-sdk/index.mjs +4 -683
  75. package/plugin-sdk/package.json +15 -4
  76. package/plugin-sdk/testing.d.ts +10 -0
  77. package/plugin-sdk/testing.mjs +566 -0
  78. package/themes/flow-cristallo.css +168 -0
  79. package/themes/flow-ink.css +169 -0
  80. package/themes/flow-obsidian.css +169 -0
  81. package/themes/flow-zurich.css +169 -0
  82. package/web/dist/.build-assets.json +1 -1
  83. package/web/dist/assets/{BgTasksModal-BDoOpj-F.js → BgTasksModal-BjNRIUIc.js} +1 -1
  84. package/web/dist/assets/{BgTasksModal-C0i3O1FT.js → BgTasksModal-C0zuU8FE.js} +1 -1
  85. package/web/dist/assets/{CanvasStudio-B8thymBN.js → CanvasStudio-BWvdmJ0M.js} +3 -3
  86. package/web/dist/assets/{CanvasStudio-zSxyIx1R.js → CanvasStudio-VQFjmTGq.js} +3 -3
  87. package/web/dist/assets/DeviceCenter-DI9_0aBB.js +3 -0
  88. package/web/dist/assets/DeviceCenter-DsNtXqzY.js +3 -0
  89. package/web/dist/assets/{DeviceExecutionSettings-q5Ik8oXg.js → DeviceExecutionSettings-BLP1Su5G.js} +1 -1
  90. package/web/dist/assets/DeviceGroups-2Pvk0Cds.js +1 -0
  91. package/web/dist/assets/DeviceGroups-CP7CcyPD.js +1 -0
  92. package/web/dist/assets/{Dropdown-C4LIhshN.js → Dropdown-CQtstPGv.js} +1 -1
  93. package/web/dist/assets/FilePreview-BMB2tNyT.js +2 -0
  94. package/web/dist/assets/FilePreview-RGFQUbJo.js +2 -0
  95. package/web/dist/assets/{GlobalSearchModal-BWgU8yPd.js → GlobalSearchModal-BM5wxiqU.js} +1 -1
  96. package/web/dist/assets/{GlobalSearchModal-F7fNimKk.js → GlobalSearchModal-DGv_WINq.js} +1 -1
  97. package/web/dist/assets/GroupConversation-B7SnuXj1.js +61 -0
  98. package/web/dist/assets/GroupConversation-Dda69q-2.js +61 -0
  99. package/web/dist/assets/{HintTip-c6d0TJoh.js → HintTip-ChTW8o1m.js} +1 -1
  100. package/web/dist/assets/ModelConfigModal-C-0Z4hUZ.js +2 -0
  101. package/web/dist/assets/ModelConfigModal-yqeadyab.js +2 -0
  102. package/web/dist/assets/{PiSetupModal-BmMrrgB9.js → PiSetupModal-BX5rUuoI.js} +1 -1
  103. package/web/dist/assets/{ProviderOAuthControls-BGSBIKD7.js → ProviderOAuthControls-DY4SCfXg.js} +1 -1
  104. package/web/dist/assets/SCMPanel-C4KbQvvK.js +2 -0
  105. package/web/dist/assets/SCMPanel-DPAyY2sW.js +2 -0
  106. package/web/dist/assets/SettingsModal-DxZp6D_g.js +32 -0
  107. package/web/dist/assets/SettingsModal-WhQzaOPt.js +32 -0
  108. package/web/dist/assets/{TerminalPanel-DDavKvFr.js → TerminalPanel-D4By_RVc.js} +2 -2
  109. package/web/dist/assets/{TerminalPanel-0CYvD72B.js → TerminalPanel-lZw8-i3j.js} +2 -2
  110. package/web/dist/assets/{TuiOverlayModal-BsA-QTvN.js → TuiOverlayModal-C3pAVuC8.js} +1 -1
  111. package/web/dist/assets/{TuiOverlayModal-DzoVQBuG.js → TuiOverlayModal-D7_rEXcJ.js} +1 -1
  112. package/web/dist/assets/app-globals-KqOVtmp1.js +123 -0
  113. package/web/dist/assets/{canvas-client-CUnXlQYX.js → canvas-client-BY6ojmle.js} +1 -1
  114. package/web/dist/assets/{desktop-aAKpvKJV.js → desktop-CV6KKp9R.js} +1 -1
  115. package/web/dist/assets/index-BawF7ZP5.js +397 -0
  116. package/web/dist/assets/index-BoGCoq5X.js +397 -0
  117. package/web/dist/assets/index-CVW9FoY2.css +1 -0
  118. package/web/dist/assets/{plugin-host-BRWib9DF.js → plugin-host-Dn8Dd6SC.js} +1 -1
  119. package/web/dist/assets/{remote-ssh-client-CfYSMEZg.js → remote-ssh-client-Dzi-eEyE.js} +1 -1
  120. package/web/dist/assets/{theme-D2l_mLNo.js → theme-D_bihpdN.js} +1 -1
  121. package/web/dist/index.html +11 -11
  122. package/web/dist/sw.js +1 -1
  123. package/dist/gh-comment-781.md +0 -5
  124. package/dist/server/device-center/local-page.js +0 -17
  125. package/dist/server/device-center/smoke-preview.js +0 -3
  126. package/dist/server/durable/durable-capabilities.js +0 -11
  127. package/dist/server/markers/builtins/services.js +0 -123
  128. package/dist/server/markers/builtins/todo.js +0 -189
  129. package/dist/server/markers-list-tool.js +0 -34
  130. package/dist/server/orchestrator.js +0 -109
  131. package/dist/server/patch-turn-end-boundary.js +0 -77
  132. package/dist/server/system-prompt-soul.js +0 -41
  133. package/dist/server/univer-service.js +0 -448
  134. package/dist/server/universal/drivers/dsh-driver.js +0 -379
  135. package/dist/test-artifact.md +0 -9
  136. package/dist/test-preview-modal.md +0 -11
  137. package/dist/test-report.html +0 -20
  138. package/web/dist/assets/DeviceCenter-DfAHKcid.js +0 -3
  139. package/web/dist/assets/DeviceCenter-ydvOTlzE.js +0 -3
  140. package/web/dist/assets/DeviceGroups-CI14_SRb.js +0 -1
  141. package/web/dist/assets/DeviceGroups-DvsB5IEU.js +0 -1
  142. package/web/dist/assets/FilePreview-BgGongmv.js +0 -2
  143. package/web/dist/assets/FilePreview-D4NrhF-U.js +0 -2
  144. package/web/dist/assets/GroupConversation-Dh71Pdb-.js +0 -17
  145. package/web/dist/assets/GroupConversation-ZK3nRmNm.js +0 -17
  146. package/web/dist/assets/ModelConfigModal-YVEgyy34.js +0 -2
  147. package/web/dist/assets/ModelConfigModal-vWtg3srp.js +0 -2
  148. package/web/dist/assets/SCMPanel-B8_EDxNr.js +0 -2
  149. package/web/dist/assets/SCMPanel-BU58qk3T.js +0 -2
  150. package/web/dist/assets/SettingsModal-CMUybq3J.js +0 -32
  151. package/web/dist/assets/SettingsModal-OBmGTh-5.js +0 -32
  152. package/web/dist/assets/app-globals-CZxzGvIo.js +0 -123
  153. package/web/dist/assets/index-C6DwztqE.css +0 -1
  154. package/web/dist/assets/index-CuN802Sj.js +0 -93
  155. package/web/dist/assets/index-EH5Fw9fa.js +0 -93
@@ -0,0 +1,113 @@
1
+ import { createHash } from "node:crypto";
2
+ import { canonicalizeJson } from "./work-contract.js";
3
+ function fail(message) {
4
+ throw Object.assign(new Error(message), { status: 502 });
5
+ }
6
+ const digest = (value) => createHash("sha256").update(canonicalizeJson(value)).digest("hex");
7
+ export const computeVerificationPlanDigest = (commands) => digest({ commands });
8
+ export function freezeVerificationPlan(commands, accountId) {
9
+ if (!Array.isArray(commands) ||
10
+ commands.length < 1 ||
11
+ commands.length > 8 ||
12
+ commands.some((c) => typeof c !== "string" || !c.trim() || c.length > 4096 || /[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/.test(c)))
13
+ throw Object.assign(new Error("Expected 1..8 bounded verification commands"), { status: 400 });
14
+ return {
15
+ commands: [...commands],
16
+ digest: computeVerificationPlanDigest(commands),
17
+ authorizedByAccountId: accountId,
18
+ authorizedAt: Date.now(),
19
+ };
20
+ }
21
+ function hex(value, length, name) {
22
+ if (typeof value !== "string" || !new RegExp(`^[a-f0-9]{${length}}$`).test(value))
23
+ fail(`Invalid ${name}`);
24
+ return value;
25
+ }
26
+ /** Only device facts enter the receipt; device-provided identity/digest/status alone has no authority. */
27
+ export function validateVerificationFacts(raw, integration) {
28
+ if (!raw || typeof raw !== "object" || Array.isArray(raw))
29
+ fail("Invalid verification facts");
30
+ const obj = raw;
31
+ const plan = integration.verificationPlan;
32
+ if (!plan ||
33
+ plan.authorizedByAccountId !== integration.accountId ||
34
+ plan.digest !== computeVerificationPlanDigest(plan.commands))
35
+ fail("Missing authorized verification plan");
36
+ if (obj.status !== "verified" && obj.status !== "failed")
37
+ fail("Invalid verification status");
38
+ if (obj.planDigest !== plan.digest ||
39
+ obj.artifactDigest !== integration.artifactRef?.artifactDigest ||
40
+ obj.materializedCommit !== integration.materializedCommit)
41
+ fail("Verification subject mismatch");
42
+ // Artifact baselines remain SHA-1; legacy repositories may explicitly report SHA-256.
43
+ const objectLength = integration.objectFormat === "sha256" && !integration.artifactRef ? 64 : 40;
44
+ const treeBefore = hex(obj.treeBefore, objectLength, "treeBefore");
45
+ const treeAfter = hex(obj.treeAfter, objectLength, "treeAfter");
46
+ if (treeBefore !== integration.preparedTree || treeAfter !== integration.preparedTree)
47
+ fail("Verification changed prepared tree");
48
+ if (!Array.isArray(obj.results) || obj.results.length !== plan.commands.length || obj.results.length === 0)
49
+ fail("Missing complete command evidence");
50
+ const results = obj.results.map((rawItem, index) => {
51
+ if (!rawItem || typeof rawItem !== "object" || Array.isArray(rawItem))
52
+ fail("Invalid command evidence");
53
+ const item = rawItem;
54
+ if (item.command !== plan.commands[index] ||
55
+ !Number.isSafeInteger(item.exitCode) ||
56
+ Math.abs(item.exitCode) > 2147483647 ||
57
+ (item.status !== "passed" && item.status !== "failed") ||
58
+ (item.status === "passed") !== (item.exitCode === 0))
59
+ fail("Command evidence disagrees with plan or exit code");
60
+ if (typeof item.outputPreview !== "string" || item.outputPreview.length > 16384)
61
+ fail("Invalid output preview");
62
+ return {
63
+ command: item.command,
64
+ status: item.status,
65
+ exitCode: item.exitCode,
66
+ outputDigest: hex(item.outputDigest, 64, "outputDigest"),
67
+ outputPreview: item.outputPreview,
68
+ };
69
+ });
70
+ if ((obj.status === "verified") !== results.every((r) => r.status === "passed"))
71
+ fail("Verification status disagrees with command evidence");
72
+ return {
73
+ status: obj.status,
74
+ facts: {
75
+ planDigest: plan.digest,
76
+ ...(integration.artifactRef ? { artifactDigest: integration.artifactRef.artifactDigest } : {}),
77
+ materializedCommit: integration.materializedCommit,
78
+ treeBefore,
79
+ treeAfter,
80
+ results,
81
+ },
82
+ };
83
+ }
84
+ export function computeVerificationDigest(integration, facts) {
85
+ return digest({
86
+ integrationId: integration.id,
87
+ accountId: integration.accountId,
88
+ roomId: integration.roomId,
89
+ conversationId: integration.conversationId,
90
+ deliveryId: integration.deliveryId,
91
+ commit: integration.commit ?? null,
92
+ artifactRef: integration.artifactRef ?? null,
93
+ targetBotId: integration.targetBotId,
94
+ targetBotRevision: integration.targetBotRevision,
95
+ targetDeviceId: integration.targetDeviceId ?? null,
96
+ targetBranch: integration.targetBranch,
97
+ expectedTargetSha: integration.expectedTargetSha,
98
+ preparedTree: integration.preparedTree,
99
+ verificationPlan: integration.verificationPlan,
100
+ facts,
101
+ });
102
+ }
103
+ export function hasVerifiedIntegration(integration) {
104
+ try {
105
+ if (!integration.verification)
106
+ return false;
107
+ const { facts, status } = validateVerificationFacts({ status: "verified", ...integration.verification }, integration);
108
+ return status === "verified" && integration.verification.digest === computeVerificationDigest(integration, facts);
109
+ }
110
+ catch {
111
+ return false;
112
+ }
113
+ }
@@ -63,8 +63,9 @@ export async function createLocalDeviceHub(dataDir, getSettings) {
63
63
  onTaskToolLifecycle: (id, frame) => hub.acceptTaskToolLifecycle(id, frame),
64
64
  onTaskPlanReady: (id, frame) => hub.acceptTaskPlanReady(id, frame),
65
65
  onTaskInteractions: (id, event) => hub.acceptInteractions(id, event),
66
- onTaskEvent: async (id, event) => {
67
- await hub.acceptTaskEvent(id, event);
66
+ onTaskEvent: (id, event) => hub.acceptTaskEvent(id, event),
67
+ onDeviceConnect: async (id) => {
68
+ await Promise.all([hub.resumeQueuedTasks(id), hub.reconcilePendingPublications(id)]);
68
69
  },
69
70
  onTaskClaim: (id, claim) => hub.claimTask(id, claim),
70
71
  onTaskLeaseRenew: (id, renew) => hub.renewTaskLease(id, renew),
@@ -72,6 +73,8 @@ export async function createLocalDeviceHub(dataDir, getSettings) {
72
73
  });
73
74
  hub.setRelay({
74
75
  onTask: relay.sendTask,
76
+ cancelTask: relay.cancelTask,
77
+ steerTask: relay.steerTask,
75
78
  answerInteraction: relay.answerInteraction,
76
79
  onRevoke: relay.revoke,
77
80
  handleRequest: relay.handleRequest,
@@ -87,6 +90,7 @@ export async function createLocalDeviceHub(dataDir, getSettings) {
87
90
  hubUrl,
88
91
  name: hostname(),
89
92
  deviceId,
93
+ accountId,
90
94
  credential,
91
95
  uiCredential,
92
96
  allowExecution: true,
@@ -0,0 +1,423 @@
1
+ import { spawn, execFile } from "node:child_process";
2
+ import { realpath } from "node:fs/promises";
3
+ import { resolve } from "node:path";
4
+ import { buildPublishCommit, validatePublishIntent } from "./publish-intent.js";
5
+ import { appendPublicationJournal, createPublicationJournal, readPublicationJournal, serializePublication, PUBLICATION_WRITER_EPOCH, } from "./publication-journal.js";
6
+ export class PublicationStopUnconfirmedError extends Error {
7
+ stopUnconfirmed = true;
8
+ constructor() {
9
+ super("Publication Git process stop unconfirmed");
10
+ }
11
+ }
12
+ const activeChildren = new Map();
13
+ const controllers = new Map();
14
+ const fences = new Set();
15
+ const operationKey = (dataDir, intent) => JSON.stringify([resolve(dataDir), intent.accountId, intent.targetDeviceId, intent.integrationId]);
16
+ const gitEnvironment = () => {
17
+ const env = { ...process.env };
18
+ for (const key of Object.keys(env))
19
+ if (/^GIT_/i.test(key))
20
+ delete env[key];
21
+ return {
22
+ ...env,
23
+ GIT_CONFIG_NOSYSTEM: "1",
24
+ GIT_CONFIG_SYSTEM: process.platform === "win32" ? "NUL" : "/dev/null",
25
+ GIT_CONFIG_GLOBAL: process.platform === "win32" ? "NUL" : "/dev/null",
26
+ GIT_TERMINAL_PROMPT: "0",
27
+ GIT_NO_REPLACE_OBJECTS: "1",
28
+ GIT_GRAFT_FILE: process.platform === "win32" ? "NUL" : "/dev/null",
29
+ GIT_NO_LAZY_FETCH: "1",
30
+ GIT_OPTIONAL_LOCKS: "0",
31
+ GIT_ATTR_NOSYSTEM: "1",
32
+ GIT_LFS_SKIP_SMUDGE: "1",
33
+ };
34
+ };
35
+ /** Dedicated runner: actual zero exit is preserved even when cancellation wins the JS race. */
36
+ export function runPublicationGit(cwd, args, options = {}) {
37
+ options.signal?.throwIfAborted();
38
+ return new Promise((resolveExit, reject) => {
39
+ const child = spawn("git", [
40
+ "--no-optional-locks",
41
+ "-c",
42
+ "core.hooksPath=/dev/null",
43
+ "-c",
44
+ "maintenance.auto=false",
45
+ "-c",
46
+ "gc.auto=0",
47
+ "-c",
48
+ "core.fsmonitor=false",
49
+ "-c",
50
+ "credential.helper=",
51
+ "-c",
52
+ "protocol.allow=never",
53
+ ...args,
54
+ ], {
55
+ cwd,
56
+ env: gitEnvironment(),
57
+ windowsHide: true,
58
+ detached: process.platform !== "win32",
59
+ stdio: ["pipe", "pipe", "pipe"],
60
+ });
61
+ const children = activeChildren.get(options.key ?? "") ?? new Set();
62
+ if (options.key && child.pid) {
63
+ children.add(child.pid);
64
+ activeChildren.set(options.key, children);
65
+ }
66
+ let stdout = "", stderr = "", error, settled = false;
67
+ let stopTimer;
68
+ const settle = (result) => {
69
+ if (settled)
70
+ return;
71
+ settled = true;
72
+ clearTimeout(timer);
73
+ clearTimeout(stopTimer);
74
+ options.signal?.removeEventListener("abort", stop);
75
+ if (result)
76
+ resolveExit(result);
77
+ else
78
+ reject(new PublicationStopUnconfirmedError());
79
+ };
80
+ const stop = () => {
81
+ if (child.pid) {
82
+ if (process.platform === "win32")
83
+ execFile("taskkill", ["/pid", String(child.pid), "/T", "/F"], { timeout: 1500, windowsHide: true }, () => { });
84
+ else
85
+ try {
86
+ process.kill(-child.pid, "SIGKILL");
87
+ }
88
+ catch {
89
+ /* close/error remains the only stop proof */
90
+ }
91
+ }
92
+ stopTimer ??= setTimeout(() => settle(), options.stopTimeoutMs ?? 2000);
93
+ };
94
+ const timer = setTimeout(stop, options.timeoutMs ?? 30_000);
95
+ options.signal?.addEventListener("abort", stop, { once: true });
96
+ for (const [stream, target] of [
97
+ [child.stdout, "stdout"],
98
+ [child.stderr, "stderr"],
99
+ ])
100
+ stream.on("data", (chunk) => {
101
+ const remaining = Math.max(0, 256 * 1024 - Buffer.byteLength(stdout) - Buffer.byteLength(stderr));
102
+ if (target === "stdout")
103
+ stdout += chunk.subarray(0, remaining).toString();
104
+ else
105
+ stderr += chunk.subarray(0, remaining).toString();
106
+ if (chunk.length > remaining) {
107
+ error = new Error("Publication Git output exceeded bound");
108
+ stop();
109
+ }
110
+ });
111
+ child.on("error", (value) => {
112
+ error = value;
113
+ });
114
+ child.on("close", (code, signal) => {
115
+ if (child.pid)
116
+ children.delete(child.pid);
117
+ if (options.key && !children.size)
118
+ activeChildren.delete(options.key);
119
+ settle({ code, signal, stdout, stderr, ...(error ? { error } : {}) });
120
+ });
121
+ child.stdin.on("error", () => { });
122
+ child.stdin.end(options.input);
123
+ if (options.signal?.aborted)
124
+ stop();
125
+ });
126
+ }
127
+ async function checkedGit(repo, args, signal, input, key) {
128
+ const result = await runPublicationGit(repo.repoRoot, args, { signal, input, key });
129
+ if (result.code !== 0 || result.signal || result.error)
130
+ throw new Error(`Publication Git failed: ${result.stderr.slice(0, 300)}`, { cause: result.error });
131
+ return result.stdout.trim();
132
+ }
133
+ function receipt(intent, proof, targetSha) {
134
+ return {
135
+ intentId: intent.id,
136
+ intentDigest: intent.digest,
137
+ candidateSha: intent.candidateSha,
138
+ outcome: "applied",
139
+ proof,
140
+ observedAt: Date.now(),
141
+ ...(targetSha ? { targetSha } : {}),
142
+ };
143
+ }
144
+ function observation(intent, phase, values = {}) {
145
+ return {
146
+ intentId: intent.id,
147
+ intentDigest: intent.digest,
148
+ candidateSha: intent.candidateSha,
149
+ observedAt: Date.now(),
150
+ target: "unknown",
151
+ phase,
152
+ retryable: false,
153
+ ...values,
154
+ };
155
+ }
156
+ async function verifyOriginalRepository(journal) {
157
+ const repo = journal.repository;
158
+ if (!repo)
159
+ throw new Error("Original publication repository is unavailable");
160
+ const root = await realpath(repo.repoRoot), common = await realpath(repo.commonDir);
161
+ const equal = (a, b) => process.platform === "win32" ? a.toLowerCase() === b.toLowerCase() : a === b;
162
+ if (!equal(root, repo.repoRoot) || !equal(common, repo.commonDir))
163
+ throw new Error("Original publication repository path changed");
164
+ const top = await checkedGit(repo, ["rev-parse", "--show-toplevel"]);
165
+ const gitCommon = await checkedGit(repo, ["rev-parse", "--path-format=absolute", "--git-common-dir"]);
166
+ const format = await checkedGit(repo, ["rev-parse", "--show-object-format"]);
167
+ if (!equal(await realpath(top), root) ||
168
+ !equal(await realpath(gitCommon), common) ||
169
+ format !== repo.objectFormat ||
170
+ repo.repositoryId !== journal.intent.repositoryId)
171
+ throw new Error("Original publication repository identity changed");
172
+ await checkedGit(repo, ["cat-file", "-e", `${journal.intent.expectedOld}^{commit}`]);
173
+ return repo;
174
+ }
175
+ /** Historical observation is read-only: no session, current Bot, config helpers, index, refs or journal writes. */
176
+ export function localPublicationStatus(params) {
177
+ return serializePublication(params.dataDir, () => publicationStatusWithinGate(params));
178
+ }
179
+ async function publicationStatusWithinGate(params) {
180
+ const intent = validatePublishIntent(params.publishIntent);
181
+ let journal;
182
+ try {
183
+ journal = await readPublicationJournal(params.dataDir, intent);
184
+ }
185
+ catch {
186
+ return {
187
+ status: "pending",
188
+ publishObservation: observation(intent, "unknown", { error: "Publication journal is unreadable or corrupt" }),
189
+ };
190
+ }
191
+ if (!journal)
192
+ return { status: "pending", publishObservation: observation(intent, "absent") };
193
+ let current = observation(intent, journal.phase);
194
+ let inferred;
195
+ try {
196
+ const repo = await verifyOriginalRepository(journal);
197
+ const target = await runPublicationGit(repo.repoRoot, ["rev-parse", "--verify", journal.intent.targetRef]);
198
+ if (target.code !== 0) {
199
+ current = observation(intent, journal.phase, {
200
+ target: target.code === 128 && !target.error && !target.signal ? "missing" : "unknown",
201
+ });
202
+ }
203
+ else {
204
+ const sha = target.stdout.trim();
205
+ const exists = await runPublicationGit(repo.repoRoot, ["cat-file", "-e", `${intent.candidateSha}^{commit}`]);
206
+ if (exists.code !== 0 || exists.signal || exists.error) {
207
+ if (journal.phase !== "prepared" || sha !== intent.expectedOld)
208
+ throw new Error("Candidate object is unavailable");
209
+ await checkedGit(repo, ["cat-file", "-e", intent.preparedTree + "^{tree}"]);
210
+ await checkedGit(repo, ["cat-file", "-e", intent.materializedCommit + "^{commit}"]);
211
+ }
212
+ if (sha === intent.candidateSha) {
213
+ current = observation(intent, journal.phase, { target: "candidate", targetSha: sha });
214
+ inferred = receipt(intent, "target_exact", sha);
215
+ }
216
+ else if (sha === intent.expectedOld)
217
+ current = observation(intent, journal.phase, { target: "expected_old", targetSha: sha });
218
+ else {
219
+ const shallow = await checkedGit(repo, ["rev-parse", "--is-shallow-repository"]);
220
+ if (shallow !== "false")
221
+ throw new Error("Shallow ancestry is inconclusive");
222
+ const ancestry = await runPublicationGit(repo.repoRoot, [
223
+ "merge-base",
224
+ "--is-ancestor",
225
+ intent.candidateSha,
226
+ sha,
227
+ ]);
228
+ if (ancestry.code === 0 && !ancestry.signal && !ancestry.error) {
229
+ current = observation(intent, journal.phase, { target: "descendant", targetSha: sha });
230
+ inferred = receipt(intent, "target_descendant", sha);
231
+ }
232
+ else if (ancestry.code === 1 && !ancestry.signal && !ancestry.error)
233
+ current = observation(intent, journal.phase, { target: "other", targetSha: sha });
234
+ else
235
+ throw new Error("Publication ancestry is inconclusive");
236
+ }
237
+ }
238
+ current.retryable =
239
+ !journal.stop &&
240
+ !journal.receipt &&
241
+ !inferred &&
242
+ ["prepared", "cas_rejected"].includes(journal.phase) &&
243
+ current.target === "expected_old";
244
+ }
245
+ catch {
246
+ current = observation(intent, journal.phase, {
247
+ error: "Original publication repository observation is unavailable",
248
+ });
249
+ }
250
+ if (journal.stop?.pastEffect === "not_applied")
251
+ inferred = undefined;
252
+ if (!journal.receipt && inferred)
253
+ journal = await appendPublicationJournal(params.dataDir, journal, "applied", { receipt: inferred });
254
+ const positive = journal.receipt;
255
+ if (positive && journal.casStarted && !journal.processStopped && !journal.stop) {
256
+ const stop = {
257
+ intentId: intent.id,
258
+ intentDigest: intent.digest,
259
+ candidateSha: intent.candidateSha,
260
+ closed: true,
261
+ stopConfirmed: false,
262
+ pastEffect: "applied",
263
+ fencedAt: Date.now(),
264
+ };
265
+ journal = await appendPublicationJournal(params.dataDir, journal, "closed", { stop });
266
+ }
267
+ return {
268
+ status: positive
269
+ ? "applied"
270
+ : journal.stop?.stopConfirmed && journal.stop.pastEffect === "not_applied"
271
+ ? "cancelled"
272
+ : "pending",
273
+ ...(positive ? { publishReceipt: positive } : {}),
274
+ publishObservation: current,
275
+ ...(journal.stop ? { publishStop: journal.stop } : {}),
276
+ };
277
+ }
278
+ /** All callers use one local gate; cancellation fences are installed synchronously before waiting. */
279
+ export function publishLocalIntent(params, options = {}) {
280
+ const intent = validatePublishIntent(params.publishIntent);
281
+ const key = operationKey(params.dataDir, intent);
282
+ return serializePublication(params.dataDir, async () => {
283
+ if (activeChildren.get(key)?.size)
284
+ throw new PublicationStopUnconfirmedError();
285
+ if (fences.has(key))
286
+ return publicationStatusWithinGate(params);
287
+ const existing = await readPublicationJournal(params.dataDir, intent);
288
+ if (existing?.receipt || existing?.stop)
289
+ return publicationStatusWithinGate(params);
290
+ if (existing && (params.mode !== "resume" || !["prepared", "cas_rejected"].includes(existing.phase)))
291
+ return publicationStatusWithinGate(params);
292
+ if (!existing && params.mode === "resume")
293
+ return publicationStatusWithinGate(params);
294
+ const controller = new AbortController();
295
+ controllers.set(key, controller);
296
+ const signal = AbortSignal.any([controller.signal, ...(options.signal ? [options.signal] : [])]);
297
+ try {
298
+ signal.throwIfAborted();
299
+ let journal = existing ?? (await createPublicationJournal(params.dataDir, intent, params.repository));
300
+ await options.hooks?.afterPrepared?.();
301
+ await verifyOriginalRepository(journal);
302
+ await params.verify(signal);
303
+ signal.throwIfAborted();
304
+ const { raw, candidateSha } = buildPublishCommit(intent);
305
+ const repo = journal.repository;
306
+ const written = await checkedGit(repo, ["hash-object", "-t", "commit", "-w", "--stdin"], signal, raw, key);
307
+ if (written !== candidateSha)
308
+ throw new Error("Publication candidate hash mismatch");
309
+ const pin = `refs/pi/publications/${intent.digest}`;
310
+ const existingPin = await runPublicationGit(repo.repoRoot, ["show-ref", "--verify", "--hash", pin], {
311
+ signal,
312
+ key,
313
+ });
314
+ if (existingPin.code === 0) {
315
+ if (existingPin.stdout.trim() !== candidateSha)
316
+ throw new Error("Publication retention ref identity mismatch");
317
+ const symbolicPin = await runPublicationGit(repo.repoRoot, ["symbolic-ref", "-q", pin], { signal, key });
318
+ if (symbolicPin.code !== 1)
319
+ throw new Error("Publication retention ref is symbolic or unreadable");
320
+ }
321
+ else {
322
+ if (existingPin.signal || existingPin.error || ![1, 128].includes(existingPin.code ?? -1))
323
+ throw new Error("Publication retention ref is unreadable");
324
+ await checkedGit(repo, ["update-ref", "--no-deref", pin, candidateSha, "0".repeat(candidateSha.length)], signal, undefined, key);
325
+ }
326
+ await options.hooks?.afterCandidatePinned?.();
327
+ await params.verify(signal);
328
+ signal.throwIfAborted();
329
+ if (fences.has(key))
330
+ return publicationStatusWithinGate(params);
331
+ const symbolicTarget = await runPublicationGit(repo.repoRoot, ["symbolic-ref", "-q", intent.targetRef], {
332
+ signal,
333
+ key,
334
+ });
335
+ if (symbolicTarget.code !== 1)
336
+ throw new Error("Publication target is symbolic or unreadable");
337
+ journal = await appendPublicationJournal(params.dataDir, journal, "cas_started", {
338
+ processEpoch: PUBLICATION_WRITER_EPOCH,
339
+ });
340
+ await options.hooks?.afterCasStarted?.();
341
+ signal.throwIfAborted();
342
+ const exit = await runPublicationGit(repo.repoRoot, ["update-ref", "--no-deref", intent.targetRef, candidateSha, intent.expectedOld], { signal, key });
343
+ await options.hooks?.afterCasExit?.(exit);
344
+ // No outer cancellation check after spawn: record the actual process exit.
345
+ if (exit.code === 0 && !exit.signal && !exit.error) {
346
+ const applied = receipt(intent, "cas_exit", candidateSha);
347
+ journal = await appendPublicationJournal(params.dataDir, journal, "applied", {
348
+ receipt: applied,
349
+ processStopped: true,
350
+ });
351
+ await options.hooks?.afterReceipt?.();
352
+ return { status: "applied", publishReceipt: applied };
353
+ }
354
+ // Only Git's explicit old-value mismatch proves that update-ref did not apply.
355
+ if (!exit.signal &&
356
+ !exit.error &&
357
+ [1, 128].includes(exit.code ?? -1) &&
358
+ /cannot lock ref .*is at [a-f0-9]+ but expected [a-f0-9]+/.test(exit.stderr))
359
+ await appendPublicationJournal(params.dataDir, journal, "cas_rejected", { processStopped: true });
360
+ else
361
+ await appendPublicationJournal(params.dataDir, journal, "cas_started", { processStopped: true });
362
+ return publicationStatusWithinGate(params);
363
+ }
364
+ finally {
365
+ if (controllers.get(key) === controller)
366
+ controllers.delete(key);
367
+ }
368
+ });
369
+ }
370
+ export function cancelLocalPublication(params) {
371
+ const intent = validatePublishIntent(params.publishIntent);
372
+ const key = operationKey(params.dataDir, intent);
373
+ fences.add(key);
374
+ controllers.get(key)?.abort(new Error("Publication cancelled"));
375
+ return serializePublication(params.dataDir, async () => {
376
+ const live = !!activeChildren.get(key)?.size;
377
+ let journal = await readPublicationJournal(params.dataDir, intent);
378
+ if (journal?.stop?.stopConfirmed)
379
+ return publicationStatusWithinGate(params);
380
+ const observed = await publicationStatusWithinGate(params);
381
+ journal = await readPublicationJournal(params.dataDir, intent);
382
+ const stopConfirmed = !live &&
383
+ (!journal?.casStarted || journal.processStopped === true || journal.processEpoch === PUBLICATION_WRITER_EPOCH);
384
+ if (journal?.stop && !stopConfirmed) {
385
+ if (live)
386
+ throw new PublicationStopUnconfirmedError();
387
+ return { ...observed, cleanupPending: true };
388
+ }
389
+ const stop = {
390
+ intentId: intent.id,
391
+ intentDigest: intent.digest,
392
+ candidateSha: intent.candidateSha,
393
+ closed: true,
394
+ stopConfirmed,
395
+ pastEffect: observed.publishReceipt
396
+ ? "applied"
397
+ : !journal || !journal.casStarted || journal.phase === "cas_rejected"
398
+ ? "not_applied"
399
+ : "unknown",
400
+ fencedAt: journal?.stop?.fencedAt ?? Date.now(),
401
+ ...(stopConfirmed ? { stoppedAt: Date.now() } : {}),
402
+ };
403
+ if (journal)
404
+ await appendPublicationJournal(params.dataDir, journal, "closed", {
405
+ stop,
406
+ ...(stopConfirmed ? { processStopped: true } : {}),
407
+ });
408
+ else
409
+ await createPublicationJournal(params.dataDir, intent, undefined, stop);
410
+ if (live)
411
+ throw new PublicationStopUnconfirmedError();
412
+ return {
413
+ ...observed,
414
+ status: observed.publishReceipt
415
+ ? "applied"
416
+ : stopConfirmed && stop.pastEffect === "not_applied"
417
+ ? "cancelled"
418
+ : "pending",
419
+ publishStop: stop,
420
+ ...(!stopConfirmed ? { cleanupPending: true } : {}),
421
+ };
422
+ });
423
+ }
@@ -0,0 +1,97 @@
1
+ // Windows foreground verification supervisor. Commands enter a non-breakaway Job before
2
+ // their first instruction; only this supervisor can emit the per-operation stop receipt.
3
+ export const WINDOWS_VERIFICATION_SUPERVISOR = String.raw `
4
+ $ErrorActionPreference = 'Stop'
5
+ $ProgressPreference = 'SilentlyContinue'
6
+ Add-Type -TypeDefinition @'
7
+ using System;
8
+ using System.Runtime.InteropServices;
9
+ using System.Text;
10
+ using System.IO;
11
+ using System.IO.Pipes;
12
+ using System.Threading;
13
+ using System.Threading.Tasks;
14
+ public static class PiVerificationJob {
15
+ [StructLayout(LayoutKind.Sequential)] struct SECURITY_ATTRIBUTES { public int nLength; public IntPtr lpSecurityDescriptor; public int bInheritHandle; }
16
+ [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)] struct STARTUPINFO { public int cb; public string lpReserved, lpDesktop, lpTitle; public int dwX,dwY,dwXSize,dwYSize,dwXCountChars,dwYCountChars,dwFillAttribute,dwFlags; public short wShowWindow,cbReserved2; public IntPtr lpReserved2,hStdInput,hStdOutput,hStdError; }
17
+ [StructLayout(LayoutKind.Sequential)] struct PROCESS_INFORMATION { public IntPtr hProcess,hThread; public uint dwProcessId,dwThreadId; }
18
+ [StructLayout(LayoutKind.Sequential)] struct IO_COUNTERS { public ulong ReadOperationCount,WriteOperationCount,OtherOperationCount,ReadTransferCount,WriteTransferCount,OtherTransferCount; }
19
+ [StructLayout(LayoutKind.Sequential)] struct BASIC_LIMIT { public long PerProcessUserTimeLimit,PerJobUserTimeLimit; public uint LimitFlags; public UIntPtr MinimumWorkingSetSize,MaximumWorkingSetSize; public uint ActiveProcessLimit; public UIntPtr Affinity; public uint PriorityClass,SchedulingClass; }
20
+ [StructLayout(LayoutKind.Sequential)] struct EXTENDED_LIMIT { public BASIC_LIMIT BasicLimitInformation; public IO_COUNTERS IoInfo; public UIntPtr ProcessMemoryLimit,JobMemoryLimit,PeakProcessMemoryUsed,PeakJobMemoryUsed; }
21
+ [StructLayout(LayoutKind.Sequential)] struct ACCOUNTING { public long TotalUserTime,TotalKernelTime,ThisPeriodTotalUserTime,ThisPeriodTotalKernelTime; public uint TotalPageFaultCount,TotalProcesses,ActiveProcesses,TotalTerminatedProcesses; }
22
+ [DllImport("kernel32.dll", SetLastError=true)] static extern IntPtr CreateJobObject(IntPtr a,string name);
23
+ [DllImport("kernel32.dll", SetLastError=true)] static extern bool SetInformationJobObject(IntPtr job,int info,ref EXTENDED_LIMIT value,uint length);
24
+ [DllImport("kernel32.dll", SetLastError=true)] static extern bool QueryInformationJobObject(IntPtr job,int info,out ACCOUNTING value,uint length,IntPtr returned);
25
+ [DllImport("kernel32.dll", SetLastError=true)] static extern bool AssignProcessToJobObject(IntPtr job,IntPtr process);
26
+ [DllImport("kernel32.dll", SetLastError=true)] static extern bool TerminateJobObject(IntPtr job,uint code);
27
+ [DllImport("kernel32.dll", SetLastError=true)] static extern bool TerminateProcess(IntPtr process,uint code);
28
+ [DllImport("kernel32.dll", SetLastError=true, CharSet=CharSet.Unicode)] static extern bool CreateProcess(string app,StringBuilder command,IntPtr pa,IntPtr ta,bool inherit,uint flags,IntPtr env,string cwd,ref STARTUPINFO startup,out PROCESS_INFORMATION process);
29
+ [DllImport("kernel32.dll")] static extern IntPtr GetStdHandle(int value);
30
+ [DllImport("kernel32.dll", SetLastError=true)] static extern bool SetHandleInformation(IntPtr handle,uint mask,uint flags);
31
+ [DllImport("kernel32.dll", SetLastError=true, CharSet=CharSet.Unicode)] static extern IntPtr CreateFile(string name,uint access,uint share,ref SECURITY_ATTRIBUTES security,uint creation,uint flags,IntPtr template);
32
+ [DllImport("kernel32.dll", SetLastError=true)] static extern uint ResumeThread(IntPtr thread);
33
+ [DllImport("kernel32.dll", SetLastError=true)] static extern uint WaitForSingleObject(IntPtr handle,uint milliseconds);
34
+ [DllImport("kernel32.dll", SetLastError=true)] static extern bool GetExitCodeProcess(IntPtr process,out uint code);
35
+ [DllImport("kernel32.dll")] static extern bool CloseHandle(IntPtr handle);
36
+ static void Check(bool ok) { if (!ok) throw new System.ComponentModel.Win32Exception(Marshal.GetLastWin32Error()); }
37
+ static uint Active(IntPtr job) { ACCOUNTING value; Check(QueryInformationJobObject(job,1,out value,(uint)Marshal.SizeOf(typeof(ACCOUNTING)),IntPtr.Zero)); return value.ActiveProcesses; }
38
+ static void Empty(IntPtr job) { var until=DateTime.UtcNow.AddSeconds(5); while(Active(job)!=0) { if(DateTime.UtcNow>until) throw new Exception("Job stop unconfirmed"); Thread.Sleep(10); } }
39
+ public static void Run() {
40
+ string receiptSecret=Console.In.ReadLine();
41
+ if(receiptSecret==null || receiptSecret.Length!=64) Environment.Exit(126);
42
+ string command=Environment.GetEnvironmentVariable("PI_LOCAL_VERIFICATION_COMMAND");
43
+ string pipeName=Environment.GetEnvironmentVariable("PI_LOCAL_VERIFICATION_PIPE");
44
+ Environment.SetEnvironmentVariable("PI_LOCAL_VERIFICATION_COMMAND",null);
45
+ Environment.SetEnvironmentVariable("PI_LOCAL_VERIFICATION_PIPE",null);
46
+ IntPtr job=IntPtr.Zero,nul=IntPtr.Zero; PROCESS_INFORMATION process=new PROCESS_INFORMATION(); bool assigned=false,confirmed=false; int result=125;
47
+ try {
48
+ job=CreateJobObject(IntPtr.Zero,null); Check(job!=IntPtr.Zero);
49
+ var limits=new EXTENDED_LIMIT(); limits.BasicLimitInformation.LimitFlags=0x2000; // KILL_ON_JOB_CLOSE; no breakaway
50
+ Check(SetInformationJobObject(job,9,ref limits,(uint)Marshal.SizeOf(typeof(EXTENDED_LIMIT))));
51
+ var security=new SECURITY_ATTRIBUTES(); security.nLength=Marshal.SizeOf(typeof(SECURITY_ATTRIBUTES)); security.bInheritHandle=1;
52
+ nul=CreateFile("NUL",0x80000000,3,ref security,3,0,IntPtr.Zero); Check(nul!=new IntPtr(-1));
53
+ var startup=new STARTUPINFO(); startup.cb=Marshal.SizeOf(typeof(STARTUPINFO)); startup.dwFlags=0x100; startup.hStdInput=nul; startup.hStdOutput=GetStdHandle(-11); startup.hStdError=GetStdHandle(-12);
54
+ Check(SetHandleInformation(startup.hStdOutput,1,1)); Check(SetHandleInformation(startup.hStdError,1,1));
55
+ Check(SetHandleInformation(GetStdHandle(-10),1,0)); // Private control input never enters the command's handle table.
56
+ string shell=Environment.GetEnvironmentVariable("COMSPEC") ?? (Environment.GetEnvironmentVariable("SystemRoot")+"\\System32\\cmd.exe");
57
+ Check(CreateProcess(shell,new StringBuilder("\""+shell+"\" /d /s /c \""+command+"\""),IntPtr.Zero,IntPtr.Zero,true,0x08000004,IntPtr.Zero,Environment.CurrentDirectory,ref startup,out process));
58
+ Check(AssignProcessToJobObject(job,process.hProcess)); assigned=true;
59
+ Check(ResumeThread(process.hThread)!=0xffffffff);
60
+ Task<string> stop=Task.Run(() => Console.In.ReadLine());
61
+ bool cancelled=false;
62
+ while(WaitForSingleObject(process.hProcess,10)!=0) {
63
+ if(stop.IsCompleted) { Check(TerminateJobObject(job,130)); cancelled=true; break; }
64
+ }
65
+ uint code; Check(GetExitCodeProcess(process.hProcess,out code));
66
+ result=cancelled ? 130 : unchecked((int)code);
67
+ // A successful shell with surviving descendants is a failed command. Reap the whole job.
68
+ if(!cancelled && Active(job)!=0) Thread.Sleep(20);
69
+ if(Active(job)!=0) { if(!cancelled) result=1; Check(TerminateJobObject(job,(uint)result)); }
70
+ Empty(job); confirmed=true;
71
+ } catch {
72
+ try {
73
+ if(process.hProcess!=IntPtr.Zero && !assigned) { TerminateProcess(process.hProcess,125); Check(WaitForSingleObject(process.hProcess,5000)==0); }
74
+ if(job!=IntPtr.Zero) { Check(TerminateJobObject(job,125)); Empty(job); }
75
+ confirmed=true;
76
+ } catch { confirmed=false; }
77
+ result=125;
78
+ } finally {
79
+ if(process.hThread!=IntPtr.Zero) CloseHandle(process.hThread);
80
+ if(process.hProcess!=IntPtr.Zero) CloseHandle(process.hProcess);
81
+ if(nul!=IntPtr.Zero && nul!=new IntPtr(-1)) CloseHandle(nul);
82
+ if(job!=IntPtr.Zero) CloseHandle(job);
83
+ }
84
+ if(confirmed) {
85
+ try {
86
+ using(var pipe=new NamedPipeClientStream(".",pipeName,PipeDirection.Out)) {
87
+ pipe.Connect(2000);
88
+ using(var writer=new StreamWriter(pipe,new UTF8Encoding(false))) { writer.WriteLine(receiptSecret+":"+result.ToString(System.Globalization.CultureInfo.InvariantCulture)); writer.Flush(); }
89
+ }
90
+ } catch { Environment.Exit(126); }
91
+ }
92
+ Environment.Exit(confirmed ? result : 126);
93
+ }
94
+ }
95
+ '@
96
+ [PiVerificationJob]::Run()
97
+ `;