tryharness 0.7.83 → 0.7.86

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 (215) hide show
  1. package/README.md +21 -19
  2. package/assets/dsh-plugin.mjs +75 -4
  3. package/assets/herdr-mod/harness/main.js +367 -0
  4. package/assets/herdr-mod/harness/mod.json +6 -0
  5. package/assets/opencode-plugin.js +87 -22
  6. package/assets/pi-extension.ts +81 -2
  7. package/cli.mjs +544 -208
  8. package/lib/adapters.mjs +62 -27
  9. package/lib/agentBinaries.mjs +6 -8
  10. package/lib/agentClaims.mjs +168 -0
  11. package/lib/agentReadTools.json +415 -0
  12. package/lib/agentSignIn.mjs +17 -18
  13. package/lib/agentWiring.mjs +114 -0
  14. package/lib/archetypes.js +10 -11
  15. package/lib/attention.mjs +100 -0
  16. package/lib/audit.mjs +1 -1
  17. package/lib/backupSetup.mjs +6 -28
  18. package/lib/bankrApprovals.mjs +86 -0
  19. package/lib/boardAccess.mjs +40 -66
  20. package/lib/boardBackup.mjs +86 -85
  21. package/lib/boardCommands.mjs +28 -0
  22. package/lib/boardFileCommands.mjs +29 -36
  23. package/lib/boardFiles.mjs +83 -15
  24. package/lib/boardMirror.mjs +78 -11
  25. package/lib/boardProtocol.json +191 -123
  26. package/lib/boardThreads.mjs +19 -37
  27. package/lib/boardTools.mjs +22 -15
  28. package/lib/boardWatches.mjs +43 -15
  29. package/lib/bridge.mjs +7 -3
  30. package/lib/browserAgentTools.mjs +59 -0
  31. package/lib/browserWake.mjs +0 -6
  32. package/lib/cards.mjs +52 -0
  33. package/lib/circling.mjs +189 -0
  34. package/lib/cleanup.mjs +234 -0
  35. package/lib/cloudBoot.mjs +21 -4
  36. package/lib/cloudSave.mjs +46 -5
  37. package/lib/compaction.mjs +8 -1
  38. package/lib/completion.mjs +358 -0
  39. package/lib/computerDevices.mjs +853 -0
  40. package/lib/connectionStatus.mjs +34 -0
  41. package/lib/connectors.mjs +139 -1
  42. package/lib/coordinator.mjs +108 -14
  43. package/lib/coreModels.mjs +36 -12
  44. package/lib/daemon.mjs +2426 -338
  45. package/lib/daemonLock.mjs +103 -0
  46. package/lib/deviceDoor.mjs +308 -0
  47. package/lib/deviceIdentity.mjs +114 -0
  48. package/lib/deviceList.mjs +172 -0
  49. package/lib/deviceSeal.mjs +74 -0
  50. package/lib/dispatcher.mjs +497 -26
  51. package/lib/dispatches.mjs +3 -3
  52. package/lib/environment.mjs +2 -1
  53. package/lib/environments.mjs +67 -41
  54. package/lib/events.mjs +318 -0
  55. package/lib/facts.mjs +170 -0
  56. package/lib/fileSource.mjs +540 -0
  57. package/lib/files.mjs +47 -2
  58. package/lib/gitHost.mjs +39 -1
  59. package/lib/goalCommands.mjs +12 -80
  60. package/lib/handover.mjs +21 -16
  61. package/lib/harnessOffers.mjs +140 -15
  62. package/lib/herdr.mjs +100 -15
  63. package/lib/herdrAppCall.mjs +19 -0
  64. package/lib/herdrCore.mjs +59 -0
  65. package/lib/herdrRuns.mjs +1126 -0
  66. package/lib/hookDialects.mjs +235 -50
  67. package/lib/identityLink.mjs +81 -0
  68. package/lib/inference.mjs +31 -2
  69. package/lib/jamAccess.mjs +82 -0
  70. package/lib/{projectBoard.mjs → jamBoard.mjs} +5 -4
  71. package/lib/{projectGit.mjs → jamGit.mjs} +53 -15
  72. package/lib/jamKey.mjs +274 -0
  73. package/lib/{projectPieces.mjs → jamPieces.mjs} +35 -29
  74. package/lib/{projectSettings.mjs → jamSettings.mjs} +12 -22
  75. package/lib/jamStore.mjs +973 -0
  76. package/lib/jamUpgrade.mjs +112 -0
  77. package/lib/jams.mjs +3079 -0
  78. package/lib/kanban.mjs +13 -7
  79. package/lib/landed.mjs +5 -1
  80. package/lib/library.mjs +41 -22
  81. package/lib/limits.mjs +91 -0
  82. package/lib/lineDiff.mjs +97 -0
  83. package/lib/lineup.mjs +18 -13
  84. package/lib/link.mjs +584 -0
  85. package/lib/localStack.mjs +75 -16
  86. package/lib/localmodels.mjs +58 -78
  87. package/lib/loopBackstop.mjs +2 -1
  88. package/lib/machine.mjs +544 -0
  89. package/lib/machineLink.mjs +446 -0
  90. package/lib/machineRoutes.mjs +68 -19
  91. package/lib/machineRuns.mjs +85 -4
  92. package/lib/machineSeal.mjs +6 -31
  93. package/lib/manager.mjs +134 -12
  94. package/lib/mcp-stdio.mjs +492 -215
  95. package/lib/mcpRelay.mjs +34 -35
  96. package/lib/members.json +1 -1
  97. package/lib/modelRoute.mjs +162 -0
  98. package/lib/nativeHost.mjs +81 -90
  99. package/lib/nativeSenses.mjs +258 -0
  100. package/lib/nerves.mjs +523 -0
  101. package/lib/network.mjs +117 -278
  102. package/lib/networkPlaces.mjs +578 -0
  103. package/lib/nextStep.mjs +95 -0
  104. package/lib/notify.mjs +2 -2
  105. package/lib/nudge.mjs +116 -10
  106. package/lib/originals.mjs +216 -0
  107. package/lib/outsideEvents.mjs +383 -0
  108. package/lib/outsideRuns.mjs +230 -0
  109. package/lib/ownMachines.mjs +674 -256
  110. package/lib/pain.mjs +215 -0
  111. package/lib/pairing.mjs +91 -11
  112. package/lib/paths.mjs +42 -3
  113. package/lib/peerProcess.mjs +21 -7
  114. package/lib/peopleLink.mjs +268 -0
  115. package/lib/personNotices.mjs +3 -2
  116. package/lib/phones.mjs +252 -542
  117. package/lib/placeCards.mjs +282 -0
  118. package/lib/placeChecks.mjs +95 -0
  119. package/lib/placeCommands.mjs +8 -17
  120. package/lib/placeRequests.mjs +152 -0
  121. package/lib/placeStore.mjs +295 -0
  122. package/lib/placeTool.d.ts +12 -0
  123. package/lib/placeTool.js +40 -0
  124. package/lib/places.mjs +63 -14
  125. package/lib/plans.mjs +53 -8
  126. package/lib/presence.mjs +270 -0
  127. package/lib/privateNetwork.d.ts +2 -0
  128. package/lib/privateNetwork.js +93 -0
  129. package/lib/proposals.mjs +300 -0
  130. package/lib/publicFetch.d.ts +32 -0
  131. package/lib/publicFetch.js +248 -0
  132. package/lib/reach.mjs +128 -0
  133. package/lib/rebuildable.mjs +72 -0
  134. package/lib/recall.mjs +216 -0
  135. package/lib/record.mjs +13 -0
  136. package/lib/reflexes.mjs +392 -0
  137. package/lib/relayLimits.mjs +31 -2
  138. package/lib/releaseNotice.mjs +198 -0
  139. package/lib/removeHarness.mjs +15 -4
  140. package/lib/repoLinks.mjs +204 -35
  141. package/lib/runAuthority.mjs +102 -39
  142. package/lib/runBrief.mjs +93 -40
  143. package/lib/runRequests.mjs +52 -14
  144. package/lib/runUsage.mjs +31 -0
  145. package/lib/runWorker.mjs +74 -25
  146. package/lib/runner.mjs +289 -45
  147. package/lib/runtime-install.mjs +37 -8
  148. package/lib/schedules.mjs +171 -47
  149. package/lib/screenWatches.mjs +221 -0
  150. package/lib/sealed.mjs +12 -30
  151. package/lib/sealedThreads.mjs +198 -392
  152. package/lib/secretStore.mjs +178 -0
  153. package/lib/secrets.mjs +11 -0
  154. package/lib/seen.mjs +3 -9
  155. package/lib/selfUpdate.mjs +51 -15
  156. package/lib/senseCall.mjs +1514 -0
  157. package/lib/senseHook.mjs +114 -0
  158. package/lib/senseTools.mjs +1298 -0
  159. package/lib/sessionBriefs.mjs +87 -0
  160. package/lib/sessionControl.mjs +63 -13
  161. package/lib/sessionFiles.mjs +85 -0
  162. package/lib/setupChoices.mjs +12 -3
  163. package/lib/setupMode.mjs +70 -25
  164. package/lib/sharedKeys.mjs +166 -0
  165. package/lib/sleep.mjs +396 -0
  166. package/lib/sources.mjs +306 -0
  167. package/lib/speech.mjs +166 -411
  168. package/lib/spoken.mjs +210 -0
  169. package/lib/steerHook.mjs +3 -1
  170. package/lib/steerQueue.mjs +40 -11
  171. package/lib/store.mjs +323 -130
  172. package/lib/stuck.mjs +85 -7
  173. package/lib/swarm.mjs +157 -49
  174. package/lib/swarmDevices.mjs +25 -85
  175. package/lib/swarmMemory.mjs +93 -9
  176. package/lib/t3.mjs +73 -3
  177. package/lib/taskCommands.mjs +51 -60
  178. package/lib/taskRooms.mjs +30 -4
  179. package/lib/taskRules.json +29 -0
  180. package/lib/taskRules.mjs +21 -0
  181. package/lib/taskRuns.mjs +74 -11
  182. package/lib/team.mjs +2 -1
  183. package/lib/threadActions.mjs +37 -9
  184. package/lib/threadAuthority.mjs +4 -4
  185. package/lib/threadBriefs.mjs +173 -43
  186. package/lib/threadNotes.mjs +320 -0
  187. package/lib/threadRecord.mjs +491 -0
  188. package/lib/threadRuns.mjs +216 -108
  189. package/lib/threadView.mjs +27 -30
  190. package/lib/threadWatches.mjs +1962 -0
  191. package/lib/timeSense.mjs +839 -0
  192. package/lib/tripwires.mjs +454 -0
  193. package/lib/ui.mjs +1 -1
  194. package/lib/vault.mjs +560 -45
  195. package/lib/vaultCommands.mjs +5 -3
  196. package/lib/vaultPeers.mjs +165 -0
  197. package/lib/vaultTools.d.ts +4 -1
  198. package/lib/vaultTools.js +22 -1
  199. package/lib/verdicts.mjs +12 -26
  200. package/lib/versions.mjs +117 -0
  201. package/lib/waitTool.mjs +278 -0
  202. package/lib/wakePicture.mjs +268 -0
  203. package/lib/wakeQueue.mjs +108 -0
  204. package/lib/watchResponses.mjs +533 -0
  205. package/lib/watches.mjs +290 -145
  206. package/lib/windowAsks.mjs +80 -17
  207. package/lib/worktrees.mjs +159 -9
  208. package/npm-shrinkwrap.json +138 -631
  209. package/package.json +7 -6
  210. package/release.json +211 -129
  211. package/lib/callSessions.mjs +0 -51
  212. package/lib/directLink.mjs +0 -349
  213. package/lib/peopleBoard.mjs +0 -131
  214. package/lib/projects.mjs +0 -2917
  215. package/lib/roomChannels.mjs +0 -667
package/lib/archetypes.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // One catalog for PiP, the Relay's agents and hosted MCP clients. These are built-in
2
2
  // procedures, not provider entitlements: a pack never supplies execution authority.
3
- // A skill with hosts reads live public data. Those requests are a Resident capability
4
- // (owner, October 24), so the readers below are told whether this surface may make them.
3
+ // A skill with hosts reads live public data. Signed-out guests, confidential turns and held runs (work another person's agent asked for) do not make those requests, so
4
+ // the readers below are told whether this surface may make them.
5
5
  export const ARCHETYPE_IDS = [
6
6
  "general",
7
7
  "software",
@@ -21,7 +21,7 @@ export const ARCHETYPES = {
21
21
  "Web search",
22
22
  "Page and screen context",
23
23
  "Browser errands",
24
- "Watches and automations",
24
+ "Watches",
25
25
  "Connected agents",
26
26
  ],
27
27
  skills: {
@@ -60,21 +60,20 @@ Use this for a task with several steps on websites: book a table, renew a librar
60
60
  Plan the steps before the first click, then do them one at a time with browser_task: one instruction per step, each with its order and slots. Open pages on other sites in a new tab so the person's current page stays where it is. To find a good option, search first, choose two or three, and open each pick's own page; compare from the live pages, not search snippets.
61
61
  After each step, read what the session returns and check the page state against what the step was meant to achieve before moving on. When it stops for something only the person knows or must decide, ask exactly that one thing.
62
62
  Steps that send, buy, book, pay, post, delete or share need the person to have asked for that action. Before the submitting step, show the final values you inferred (recipient, date, total, account) when any came from somewhere other than their own words. A field asking for card details, a password or a one-time code waits for the person. Never invent a confirmation number or report a submission you have not seen confirmed on the page.
63
- When you are working without their browser, as a background task, an automation or another agent, use hand_to_window for the part that needs their signed-in pages, with what you found and what remains. Finish with what was done, the confirmation the page showed, and anything left for them.`,
63
+ Finish with what was done, the confirmation the page showed, and anything left for them.`,
64
64
  },
65
65
  "watch-or-schedule": {
66
- name: "Watch, schedule or background",
66
+ name: "Watch or background",
67
67
  description:
68
- "Choose between a screen watch, an automation, a background task or a handoff.",
69
- instructions: `# Watch, schedule or background
68
+ "Choose between a screen watch, a background task or a handoff.",
69
+ instructions: `# Watch or background
70
70
  Match the tool to what must happen and when. Promise only what a tool call has actually set up.
71
71
  - A look now: read the current screen or page and answer. No watch.
72
72
  - Something on the shared screen over the next minutes or hours: start_temporal_watch, 1 to 120 minutes. For "tell me when", pass one to four concrete conditions checkable from pixels (the build badge turns green, the orders counter leaves 0), never "something important". For one stable value, read get_screen_regions and add install_watcher so the change is caught at once. A watch sees only what is shared; if the page will be closed or hidden, say so.
73
- - A check that repeats on websites with no window open: schedule_automation, every 5 minutes or slower or a cron in the person's time zone, with the sites it may use and a daily run cap. It runs on the person's credits and exists only after they approve its card, so choose the slowest cadence that serves the goal and match each source's own update rate (exchange rates daily, forecasts hourly).
74
73
  - One long job now that should not block the chat: run_in_background. It cannot see the screen or this chat, so write a self-contained brief with what you saw on screen as text.
75
74
  - A number from a command on the person's computer, like a heartbeat age or an error count: in the Relay, suggest_watch with a read-only command.
76
75
  - Work another agent should pick up later: a board task (read general/task-handoff).
77
- Tell the person which one you set up, how long it lasts, what triggers an alert and where the result arrives. Change or stop one only when they ask, with list_watchers and kill_watcher or list_automations and change_automation. A watch or automation keeps the authority it was approved with. When an alert calls for work, stage it for the person to start; an alert never approves a purchase, trade or send by itself.`,
76
+ Tell the person which one you set up, how long it lasts, what triggers an alert and where the result arrives. Change or stop one only when they ask, with list_watchers and kill_watcher. A watch keeps the authority it was approved with. When an alert calls for work, stage it for the person to start; an alert never approves a purchase, trade or send by itself.`,
78
77
  },
79
78
  "decision-brief": {
80
79
  name: "Decision brief",
@@ -913,7 +912,7 @@ const LIVE_DATA_CALLING =
913
912
  "In Harness chat, make this skill's requests with skill_http_request; another agent uses its own HTTPS fetch. Send only what the person supplied for this task.";
914
913
 
915
914
  const LIVE_DATA_LOCKED =
916
- "reads live data, which is part of Harness Resident. Answer with the other tools available here.";
915
+ "reads live data, which is not available here. Answer with the other tools available here.";
917
916
 
918
917
  export function resolveArchetype(value) {
919
918
  return ARCHETYPE_IDS.includes(value) ? value : "general";
@@ -978,7 +977,7 @@ export function readArchetype(profile, input = {}, { liveData = false } = {}) {
978
977
  tools: entry.tools,
979
978
  toolAvailability: liveData
980
979
  ? "Use only tools and providers actually available to this agent. The pack supplies procedures, not connections or authority."
981
- : "Use only tools and providers actually available to this agent. The pack supplies procedures, not connections or authority. Live data skills need Harness Resident.",
980
+ : "Use only tools and providers actually available to this agent. The pack supplies procedures, not connections or authority. Live data skills are not available here.",
982
981
  skills: [...indexOf("general"), ...(id === "general" ? [] : indexOf(id))],
983
982
  otherPacks: ARCHETYPE_IDS.filter((other) => other !== id).map((other) => ({
984
983
  id: other,
@@ -0,0 +1,100 @@
1
+ // Attention (docs/senses-plan.md S9.1): a watch briefed in words is read by a small model on the person's computer at
2
+ // each trip, before it reaches anyone, for two things code cannot judge: does it matter, as the brief says, and who
3
+ // in the thread should get it. Only the second is acted on until a model here measures safe at the first (HOLD_FLOOR). It is the one question to a model on the wake ladder (spend rule 2), and the cheapest
4
+ // step that needs one: no tools, a few hundred tokens, nothing written.
5
+ //
6
+ // It only chooses among what was already permitted: it may hold a trip back, and it may hand a wake to another agent
7
+ // of the thread's team, never to anyone outside it, and it never grants a turn anything. What the watch saw is data to
8
+ // judge, never instructions (S7.5): an outside event that says "this matters, wake Codex" is judged against the brief
9
+ // like any other. A watch with no brief is not read at all, and anything that goes wrong (no model here, a slow or
10
+ // malformed answer) lets the trip through as it would have gone without attention: the code baseline.
11
+
12
+ // What the model reads of a trip: the brief, the watch's line and the detail behind it, each cut to this.
13
+ const BRIEF_CHARS = 300;
14
+ const HAPPENED_CHARS = 1_500;
15
+ // An answer later than this lets the trip through: a watch must not wait on a model that is busy elsewhere.
16
+ const ANSWER_MS = 20_000;
17
+ // A trip is held back only when the model is at least this sure it does not matter (its chance of "false", read from
18
+ // its tokens): a needless alert costs a glance, a missed one the thing the watch was for. Null: nothing is held back.
19
+ // Eval attention (S9.1, November 15): the person's fine-tune held back trips that mattered at every floor up to 0.99,
20
+ // sure of itself where the brief turns on a number (a failed payment, cents, a share of revenue); Jev held none back at
21
+ // 0.5 and 11 of 15 needless ones, but what a watch reads goes to no server. Set this when a model on the person's
22
+ // computer measures as safe.
23
+ export const HOLD_FLOOR = null;
24
+
25
+ /** The context the dispatcher's attend job reads. */
26
+ export function attentionContext({ brief, happened, team, named }) {
27
+ return {
28
+ brief: String(brief).slice(0, BRIEF_CHARS),
29
+ happened: String(happened).slice(0, HAPPENED_CHARS),
30
+ team: team.map((member) => ({
31
+ id: member.id,
32
+ ...(member.good_at?.length ? { good_at: member.good_at } : {}),
33
+ // Its record on this board (S9.3): what it finished, the person's verdicts and what a run used.
34
+ ...(member.record ? { record: member.record } : {}),
35
+ })),
36
+ named: named ?? null,
37
+ };
38
+ }
39
+
40
+ /**
41
+ * The model's answer held to what was permitted: `matters` false only when the model said so and was sure enough
42
+ * (`leaveAlone`, its chance of false, at least `floor`), and `who` one of the team, else whoever the watch names. Null
43
+ * when the answer is not one.
44
+ */
45
+ export function attentionAnswer(output, { team, named }, floor = HOLD_FLOOR) {
46
+ if (typeof output?.matters !== "boolean") return null;
47
+ const sure =
48
+ floor !== null &&
49
+ typeof output.leaveAlone === "number" &&
50
+ output.leaveAlone >= floor;
51
+ const ids = team.map((member) => member.id);
52
+ // A watch that tells the person reaches them alone; one that wakes may be handed to another of the team.
53
+ const who =
54
+ ids.includes(named) && ids.includes(output.who)
55
+ ? output.who
56
+ : (named ?? null);
57
+ return { matters: output.matters || !sure, who };
58
+ }
59
+
60
+ /**
61
+ * `ask(context)` is the dispatcher's attend job (dispatcher.mjs). `judge({ brief, happened, team, named })` resolves to
62
+ * `{ matters, who, by, ms }`: `by` "model" for the model's answer, "code" when it let the trip through without one,
63
+ * with `why`.
64
+ */
65
+ export function createAttention({
66
+ ask,
67
+ log = () => {},
68
+ now = () => Date.now(),
69
+ }) {
70
+ const judge = async ({ brief, happened, team, named }) => {
71
+ const started = now();
72
+ const through = (why) => {
73
+ log(`attention: let it through (${why})`);
74
+ return {
75
+ matters: true,
76
+ who: named ?? null,
77
+ by: "code",
78
+ why,
79
+ ms: now() - started,
80
+ };
81
+ };
82
+ try {
83
+ const output = await Promise.race([
84
+ ask(attentionContext({ brief, happened, team, named })),
85
+ new Promise((_, reject) =>
86
+ setTimeout(
87
+ () => reject(new Error("no answer in time")),
88
+ ANSWER_MS
89
+ ).unref?.()
90
+ ),
91
+ ]);
92
+ const answer = attentionAnswer(output, { team, named });
93
+ if (!answer) return through("the model answered in the wrong shape");
94
+ return { ...answer, by: "model", ms: now() - started };
95
+ } catch (error) {
96
+ return through(error.message);
97
+ }
98
+ };
99
+ return { judge };
100
+ }
package/lib/audit.mjs CHANGED
@@ -223,7 +223,7 @@ function auditCommitted(store, task) {
223
223
  ];
224
224
  }
225
225
 
226
- // A piece of a shared project this run handed on stays its own until the receiver reports (projectPieces.mjs keeps
226
+ // A piece of a jam this run handed on stays its own until the receiver reports (jamPieces.mjs keeps
227
227
  // the run's open handoffs, and audits it again when one is reported).
228
228
  const openHandoffs = (store, task) => {
229
229
  try {
@@ -11,24 +11,8 @@ const when = (iso) => {
11
11
  : at.toLocaleString(undefined, { dateStyle: "medium", timeStyle: "short" });
12
12
  };
13
13
 
14
- async function askPassphrase(ui, { twice }) {
15
- const first = await ui.password({
16
- message: twice
17
- ? "Choose a backup passphrase (at least 8 characters). Only you will have it: without it the backup cannot be opened, by anyone."
18
- : "Your backup passphrase",
19
- });
20
- if (!first) return null;
21
- if (!twice) return first;
22
- const again = await ui.password({ message: "Type it again" });
23
- if (again !== first) {
24
- ui.warn("The two did not match, so backups stay off.");
25
- return null;
26
- }
27
- return first;
28
- }
29
-
30
14
  /** npx tryharness backup [on | now | restore | off] */
31
- export async function backupCommand({ argv, ui, daemonRequest }) {
15
+ export async function backupCommand({ argv, daemonRequest }) {
32
16
  const sub = argv[0];
33
17
  const must = (reply) => {
34
18
  if (!reply?.ok)
@@ -36,13 +20,9 @@ export async function backupCommand({ argv, ui, daemonRequest }) {
36
20
  return reply;
37
21
  };
38
22
  if (sub === "on") {
39
- const passphrase = await askPassphrase(ui, { twice: true });
40
- if (!passphrase) return;
41
- const on = must(
42
- await daemonRequest({ command: "backup.on", passphrase }, 120_000)
43
- );
23
+ const on = must(await daemonRequest({ command: "backup.on" }, 120_000));
44
24
  console.log(
45
- `Backed up your board, sealed with your passphrase (${on.rows} items). It backs up again by itself when the board changes.`
25
+ `Backed up your board, sealed with your keys (${on.rows} items). It backs up again by itself when the board changes.`
46
26
  );
47
27
  return;
48
28
  }
@@ -52,13 +32,11 @@ export async function backupCommand({ argv, ui, daemonRequest }) {
52
32
  return;
53
33
  }
54
34
  if (sub === "restore") {
55
- const passphrase = await askPassphrase(ui, { twice: false });
56
- if (!passphrase) return;
57
35
  const restored = must(
58
- await daemonRequest({ command: "backup.restore", passphrase }, 120_000)
36
+ await daemonRequest({ command: "backup.restore" }, 120_000)
59
37
  );
60
38
  console.log(
61
- `Brought back your board from ${restored.from || "another computer"} (${restored.rows} items). Nothing that was already here was removed.`
39
+ `Brought back your board from ${restored.from || "another computer"} (${restored.rows} items)${restored.vault ? ", and your vault's secrets" : ""}. Nothing that was already here was removed.`
62
40
  );
63
41
  return;
64
42
  }
@@ -74,7 +52,7 @@ export async function backupCommand({ argv, ui, daemonRequest }) {
74
52
  const status = must(await daemonRequest({ command: "backup.status" }));
75
53
  if (status.entitled === false) {
76
54
  console.log(
77
- "Your board stays on this computer. An encrypted backup of it is a Resident feature."
55
+ "Your board stays on this computer. Encrypted backup comes with a pass, or with holding $HARNESS."
78
56
  );
79
57
  return;
80
58
  }
@@ -0,0 +1,86 @@
1
+ // A Bankr proposal from work in one of the person's threads that waits for them (past their limits, or a send to an
2
+ // address another agent supplied), told by Harness's server (src/server/swarm/bankrApprovals.ts). It is shown wherever
3
+ // they are as their agents' permissions are (runRequests.mjs: a needs-you card in PiP, on the phone and in the buddy,
4
+ // read and answered only here or sealed), and their answer goes back to approve or decline that one proposal. Only a
5
+ // proposal for a Bankr task this computer posted in that thread is shown: the server's word alone puts nothing in a
6
+ // thread. A proposal decided anywhere else takes its card down.
7
+
8
+ const dollars = (usd) =>
9
+ Number.isFinite(usd) ? `$${usd.toFixed(2)}` : "an amount Bankr names";
10
+
11
+ export function createBankrApprovals({
12
+ store,
13
+ runRequests,
14
+ cloudAsked,
15
+ send,
16
+ log = () => {},
17
+ }) {
18
+ // What ends each card still up, by proposal.
19
+ const open = new Map();
20
+
21
+ const asked = (message) => {
22
+ const proposalId = String(message.proposalId ?? "");
23
+ const taskId = String(message.taskId ?? "");
24
+ const threadId = String(message.threadId ?? "");
25
+ const posted = cloudAsked(taskId);
26
+ if (!proposalId || !posted || posted.parent !== threadId) return;
27
+ if (store.getTask(threadId)?.kind !== "goal" || open.has(proposalId))
28
+ return;
29
+ const ended = new AbortController();
30
+ open.set(proposalId, ended);
31
+ const held = Array.isArray(message.held) ? message.held.map(String) : [];
32
+ void runRequests()
33
+ .request({
34
+ runId: taskId,
35
+ agent: "bankr",
36
+ threadId,
37
+ approval: {
38
+ approvalId: proposalId,
39
+ currentRequirementId: proposalId,
40
+ toolName: "bankr",
41
+ rawArgs: [
42
+ String(message.summary ?? ""),
43
+ `At most ${dollars(Number(message.maximumUsd))}.`,
44
+ ...held.map(
45
+ (reason) => `It waits for you because it includes ${reason}.`
46
+ ),
47
+ ].join("\n\n"),
48
+ summary: `Bankr asks: ${String(message.summary ?? "").slice(0, 300)} (at most ${dollars(Number(message.maximumUsd))}). Go ahead?`,
49
+ availableChoices: [
50
+ {
51
+ choiceId: "once",
52
+ label: "Go ahead",
53
+ decision: "approved",
54
+ scope: "once",
55
+ },
56
+ {
57
+ choiceId: "reject",
58
+ label: "Not now",
59
+ decision: "denied",
60
+ scope: "once",
61
+ },
62
+ ],
63
+ },
64
+ signal: ended.signal,
65
+ })
66
+ .then(
67
+ ({ choiceId }) =>
68
+ send({
69
+ type: "bankr_approval_answer",
70
+ proposalId,
71
+ approve: choiceId === "once",
72
+ }),
73
+ () => {}
74
+ )
75
+ .finally(() => open.delete(proposalId));
76
+ log(
77
+ `Bankr proposal ${proposalId} waits for the person in thread ${threadId}`
78
+ );
79
+ };
80
+
81
+ const settled = (message) => {
82
+ open.get(String(message.proposalId ?? ""))?.abort();
83
+ };
84
+
85
+ return { asked, settled };
86
+ }
@@ -1,7 +1,7 @@
1
1
  import { boardCommandsFor, boardMetadata } from "./boardProtocol.mjs";
2
- import { randomUUID } from "node:crypto";
3
2
  import { documentText, isDocument } from "./files.mjs";
4
3
  import { secretReason } from "./secrets.mjs";
4
+ import { checkedAsText } from "./boardFiles.mjs";
5
5
  import { imageKind } from "./ocr.mjs";
6
6
  import { member } from "./members.mjs";
7
7
 
@@ -9,8 +9,6 @@ export function createBoardAccess({
9
9
  store,
10
10
  inRoom,
11
11
  boardCommand,
12
- sendThreadMessage,
13
- notifyBoard,
14
12
  namedPath,
15
13
  textLike,
16
14
  coveredImage,
@@ -21,17 +19,18 @@ export function createBoardAccess({
21
19
  // Harness's own reads and writes come sealed from a paired device. This holds whether or not a browser is paired
22
20
  // (security audit S2, October 25): an unpaired relay once gave the server the whole board as the person, a Start
23
21
  // included. What still works in the clear, for what runs on Harness's servers: a run's status, the timeline's
24
- // counts, a trace's timings, a bounty's check that a guest posted, the person's Stop on standing permission; a
22
+ // counts, a trace's timings, the person's Stop on standing permission, Harness's own use of a secret it was allowed; a
25
23
  // hosted caller (Muse, Grok Bot, any connector) works the tasks it is part of in full, which it has to read.
26
24
  const SEALED_ONLY = {
27
25
  ok: false,
28
26
  code: "sealed_only",
29
27
  error:
30
- "this computer answers Harness only end to end encrypted; connect this browser to it: npx tryharness link",
28
+ "this computer answers Harness only end to end encrypted; open Harness in a browser on your devices, and it reaches this computer by itself",
31
29
  };
32
30
  // Narrowing only: the timeline's Stop turns standing permission off.
33
31
  const PLAIN_PERSON_COMMANDS = boardCommandsFor("plainPerson");
34
32
  const PLAIN_HARNESS_READS = boardCommandsFor("plainHarnessReads");
33
+ const PLAIN_HARNESS_SECRETS = boardCommandsFor("plainHarnessSecrets");
35
34
  const TASK_METADATA = boardMetadata.task;
36
35
  const GOAL_METADATA = boardMetadata.goal;
37
36
  const pick = (value, keys) =>
@@ -78,48 +77,6 @@ export function createBoardAccess({
78
77
  : {}),
79
78
  }
80
79
  : result;
81
- // Harness's own notice in a goal's room (a bounty): kept as a note that mentions and wakes no one, shared with guests when asked.
82
- const plainNotice = (input) => {
83
- const goal = store.getTask(String(input.id || ""));
84
- if (!goal || goal.kind !== "goal")
85
- return { ok: false, error: "goal not found" };
86
- if (goal.status !== "open")
87
- return { ok: false, error: `the goal is ${goal.status}` };
88
- const text = String(input.text || "")
89
- .trim()
90
- .slice(0, 2_000);
91
- if (!text || secretReason(text))
92
- return { ok: false, error: "a notice needs plain text" };
93
- const post = store.roomPost({
94
- goalId: goal.id,
95
- author: "harness",
96
- kind: "note",
97
- text,
98
- });
99
- if (input.shareWithGuests === true)
100
- for (const guest of goal.goal.guests) {
101
- if (
102
- !store.getThread(guest.thread) ||
103
- store.getThread(guest.thread).closed_at
104
- )
105
- continue;
106
- const sent = store.postMessage({
107
- id: randomUUID(),
108
- taskId: guest.thread,
109
- sender: "harness",
110
- text,
111
- refs: [],
112
- flagReason: null,
113
- });
114
- if (sent.ok && sent.message.state === "sent")
115
- sendThreadMessage(sent.message);
116
- }
117
- notifyBoard(store.getTask(goal.id));
118
- return {
119
- ok: true,
120
- post: pick(post, ["id", "seq", "author", "kind", "created_at"]),
121
- };
122
- };
123
80
  const roomOf = (task) => {
124
81
  const parent = task?.parent_id ? store.getTask(task.parent_id) : null;
125
82
  return parent?.kind === "goal" ? parent : null;
@@ -163,8 +120,8 @@ export function createBoardAccess({
163
120
  };
164
121
  const plainBoard = (input) => {
165
122
  const agent = String(input.agent || "");
166
- // A file's bytes are checked as a whole: a text file that holds a secret stays here; an image goes with what must not
167
- // leave covered (coveredImage); other binary files are not text to check.
123
+ // A file's bytes are checked as a whole: a text file (by its bytes, whatever type it was given) that holds a secret
124
+ // stays here; an image goes with what must not leave covered (coveredImage); other binary files are not text.
168
125
  if (input.command === "board.file.get") {
169
126
  const answer = answerPlain(input);
170
127
  if (!answer?.ok) return answer;
@@ -174,9 +131,10 @@ export function createBoardAccess({
174
131
  file && isDocument(file.mime)
175
132
  ? documentText(namedPath(file), file.mime)
176
133
  : null;
134
+ const bytes = Buffer.from(answer.data, "base64");
177
135
  const flag =
178
- (textLike(answer.file.mime) &&
179
- secretReason(Buffer.from(answer.data, "base64").toString("utf8"))) ||
136
+ (checkedAsText(answer.file.mime, bytes) &&
137
+ secretReason(bytes.toString("utf8"))) ||
180
138
  (words && secretReason(words));
181
139
  if (flag)
182
140
  return {
@@ -224,18 +182,16 @@ export function createBoardAccess({
224
182
  error:
225
183
  "the desk's book and the audits stay on the person's computers: only the person and agents there read them",
226
184
  };
227
- // A thread Harness posts on accept: on the asking side, only one this machine asked for (it supplies the words itself).
185
+ // A friendship Harness posts on accept. It carries no words: this computer keeps only the other person's name from
186
+ // it, between two persons, and pins their key from Harness, shown as a fingerprint to compare with them
187
+ // (sealedThreads.mjs openPost). Nothing else Harness sends in the person's name is taken.
228
188
  if (
229
189
  command === "board.post" &&
230
190
  input.thread &&
231
191
  typeof input.thread === "object" &&
232
192
  agent === "user"
233
- ) {
234
- return input.thread.role === "asker" &&
235
- store.meta(`relay_pending:${String(input.id || "")}`)
236
- ? boardCommand(input)
237
- : SEALED_ONLY;
238
- }
193
+ )
194
+ return boardCommand(input);
239
195
  if (agent === "harness" && PLAIN_HARNESS_READS.has(command)) {
240
196
  const result = boardCommand(
241
197
  command === "board.list" ? { ...input, all: true } : input
@@ -275,8 +231,32 @@ export function createBoardAccess({
275
231
  ok: false,
276
232
  error: "watches are only for the person and agents on this computer",
277
233
  };
278
- if (agent === "harness" && command === "board.room.post")
279
- return plainNotice(input);
234
+ // A thread Harness starts from its server, as any of the person's agents may: through the server it is the server's
235
+ // word, so the thread is an agent's (provenance.mjs viaServer) and its asks are read by this computer's guard before
236
+ // anything runs on a standing permission (runAuthority.mjs). The server gets back only the thread's id.
237
+ if (agent === "harness" && command === "board.swarm.start") {
238
+ const started = boardCommand(input);
239
+ const idOnly = (result) =>
240
+ result?.ok
241
+ ? {
242
+ ok: true,
243
+ redacted: true,
244
+ thread: { id: result.thread?.id ?? null },
245
+ note: result.note,
246
+ }
247
+ : result;
248
+ return started?.pending
249
+ ? { pending: Promise.resolve(started.pending).then(idOnly) }
250
+ : idOnly(started);
251
+ }
252
+ // A task Harness works on its server, with no window: the vault holds it to what Harness may use from there, as it
253
+ // does every hosted caller, and only a website's cleaned answer comes back, never a value (vault.mjs).
254
+ if (agent === "harness" && PLAIN_HARNESS_SECRETS.has(command))
255
+ return boardCommand(input);
256
+ // Harness's own turn reads and writes at the person's outside places through its server, as outside agents do;
257
+ // what only the person decides there stays theirs (networkPlaces.mjs).
258
+ if (agent === "harness" && command === "board.place.op")
259
+ return boardCommand(input);
280
260
  if (agent === "user" || agent === "harness")
281
261
  return PLAIN_PERSON_COMMANDS.has(command)
282
262
  ? boardCommand(input)
@@ -311,12 +291,6 @@ export function createBoardAccess({
311
291
  ? { ok: false, error: "task not found" }
312
292
  : boardCommand(input);
313
293
  }
314
- if (
315
- ["board.thread.read", "board.thread.post"].includes(command) &&
316
- task &&
317
- task.claimed_by !== agent
318
- )
319
- return { ok: false, error: "task not found" };
320
294
  if (command === "board.children" && task && visibleTo(task, agent)) {
321
295
  const listed = boardCommand(input);
322
296
  return listed?.ok