run402 4.155.0 → 4.156.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 (69) hide show
  1. package/cli.mjs +0 -6
  2. package/lib/admin.mjs +3 -3
  3. package/lib/billing.mjs +12 -12
  4. package/lib/buzz-notifications.mjs +5 -3
  5. package/lib/buzz.mjs +8 -8
  6. package/lib/buzz.test.mjs +6 -1
  7. package/lib/command-manifest.mjs +2 -2
  8. package/lib/contacts.mjs +73 -15
  9. package/lib/harness-context.mjs +2 -3
  10. package/lib/jobs.mjs +6 -6
  11. package/lib/orgs.mjs +1 -1
  12. package/lib/remote-helper-session.mjs +18 -3
  13. package/lib/repos.mjs +3 -3
  14. package/lib/vault-daemon.mjs +10 -4
  15. package/package.json +1 -1
  16. package/sdk/dist/namespaces/admin.d.ts +62 -27
  17. package/sdk/dist/namespaces/admin.d.ts.map +1 -1
  18. package/sdk/dist/namespaces/admin.js +48 -20
  19. package/sdk/dist/namespaces/admin.js.map +1 -1
  20. package/sdk/dist/namespaces/billing.d.ts +9 -9
  21. package/sdk/dist/namespaces/billing.d.ts.map +1 -1
  22. package/sdk/dist/namespaces/billing.js +26 -26
  23. package/sdk/dist/namespaces/billing.js.map +1 -1
  24. package/sdk/dist/namespaces/buzz.d.ts +9 -7
  25. package/sdk/dist/namespaces/buzz.d.ts.map +1 -1
  26. package/sdk/dist/namespaces/buzz.js +17 -15
  27. package/sdk/dist/namespaces/buzz.js.map +1 -1
  28. package/sdk/dist/namespaces/buzz.types.d.ts +3 -3
  29. package/sdk/dist/namespaces/buzz.types.d.ts.map +1 -1
  30. package/sdk/dist/namespaces/jobs.d.ts +7 -7
  31. package/sdk/dist/namespaces/jobs.d.ts.map +1 -1
  32. package/sdk/dist/namespaces/jobs.js +15 -13
  33. package/sdk/dist/namespaces/jobs.js.map +1 -1
  34. package/sdk/dist/namespaces/org.d.ts +1 -1
  35. package/sdk/dist/namespaces/org.js +1 -1
  36. package/sdk/dist/namespaces/org.types.d.ts +1 -1
  37. package/sdk/dist/namespaces/repos.d.ts +21 -20
  38. package/sdk/dist/namespaces/repos.d.ts.map +1 -1
  39. package/sdk/dist/namespaces/repos.js +23 -22
  40. package/sdk/dist/namespaces/repos.js.map +1 -1
  41. package/sdk/dist/namespaces/vault.crypto.js +2 -2
  42. package/sdk/dist/namespaces/vault.crypto.js.map +1 -1
  43. package/sdk/dist/node/index.d.ts +1 -1
  44. package/sdk/dist/node/index.d.ts.map +1 -1
  45. package/sdk/dist/node/index.js +1 -1
  46. package/sdk/dist/node/index.js.map +1 -1
  47. package/sdk/dist/node/vault-address.d.ts +2 -2
  48. package/sdk/dist/node/vault-address.js +2 -2
  49. package/sdk/dist/node/vault-address.js.map +1 -1
  50. package/sdk/dist/node/vault-keystore.d.ts +6 -6
  51. package/sdk/dist/node/vault-keystore.d.ts.map +1 -1
  52. package/sdk/dist/node/vault-keystore.js +5 -5
  53. package/sdk/dist/node/vault-keystore.js.map +1 -1
  54. package/sdk/dist/node/vault-member-bundle.js +1 -1
  55. package/sdk/dist/node/vault-member-bundle.js.map +1 -1
  56. package/sdk/dist/node/vault-prewarm.d.ts +23 -2
  57. package/sdk/dist/node/vault-prewarm.d.ts.map +1 -1
  58. package/sdk/dist/node/vault-prewarm.js +34 -2
  59. package/sdk/dist/node/vault-prewarm.js.map +1 -1
  60. package/sdk/dist/node/vault-publication.d.ts +13 -13
  61. package/sdk/dist/node/vault-publication.d.ts.map +1 -1
  62. package/sdk/dist/node/vault-publication.js +19 -20
  63. package/sdk/dist/node/vault-publication.js.map +1 -1
  64. package/sdk/dist/secret-gate.d.ts +7 -3
  65. package/sdk/dist/secret-gate.d.ts.map +1 -1
  66. package/sdk/dist/secret-gate.js +7 -3
  67. package/sdk/dist/secret-gate.js.map +1 -1
  68. package/vault-surface.json +1 -1
  69. package/lib/webhook-secret.mjs +0 -52
package/cli.mjs CHANGED
@@ -87,7 +87,6 @@ DELIVER — reach a human when something happens
87
87
  deliveries Did a notification actually land (list, get)
88
88
  contacts Where a human is reachable — paging ladder + Telegram (list, add, connect, rm, preferences)
89
89
  subscriptions Which events go where (add, list, rm)
90
- webhook-secret Rotate your webhook signing secret
91
90
  email Send template-based emails from your project
92
91
 
93
92
  PLATFORM — everything else, and the things still finding a home
@@ -480,11 +479,6 @@ switch (cmd) {
480
479
  await run(sub, rest);
481
480
  break;
482
481
  }
483
- case "webhook-secret": {
484
- const { run } = await import("./lib/webhook-secret.mjs");
485
- await run(sub, rest);
486
- break;
487
- }
488
482
  case "logs": {
489
483
  const { run } = await import("./lib/logs.mjs");
490
484
  await run(sub, rest);
package/lib/admin.mjs CHANGED
@@ -116,10 +116,10 @@ function validateFlags(sub, args) {
116
116
  }
117
117
 
118
118
  async function leasePerpetual(args) {
119
- const organizationId = args.find((a) => typeof a === "string" && !a.startsWith("--"));
119
+ const orgId = args.find((a) => typeof a === "string" && !a.startsWith("--"));
120
120
  const enable = args.includes("--enable");
121
121
  const disable = args.includes("--disable");
122
- if (!organizationId) {
122
+ if (!orgId) {
123
123
  fail({
124
124
  code: "BAD_USAGE",
125
125
  message: "Missing <org_id>.",
@@ -134,7 +134,7 @@ async function leasePerpetual(args) {
134
134
  });
135
135
  }
136
136
  try {
137
- const adminOrg = getSdk().admin.org(organizationId);
137
+ const adminOrg = getSdk().admin.org(orgId);
138
138
  const data = enable ? await adminOrg.pinLease() : await adminOrg.unpinLease();
139
139
  console.log(JSON.stringify(data, null, 2));
140
140
  } catch (err) {
package/lib/billing.mjs CHANGED
@@ -363,7 +363,7 @@ async function linkWallet(args) {
363
363
  const parsedArgs = normalizeArgv(args);
364
364
  assertKnownFlags(parsedArgs, ["--org", "--address", "--help", "-h"], ["--org", "--address"]);
365
365
  const walletFlag = flagValue(parsedArgs, "--address");
366
- const { orgId: organizationId, rest } = await takeOrgPositional(parsedArgs, ["--org", "--address"], { cmd: "billing" });
366
+ const { orgId, rest } = await takeOrgPositional(parsedArgs, ["--org", "--address"], { cmd: "billing" });
367
367
  const count = walletFlag ? 0 : 1;
368
368
  requireRest(rest, {
369
369
  min: count, max: count,
@@ -372,10 +372,10 @@ async function linkWallet(args) {
372
372
  });
373
373
  const wallet = walletFlag ?? rest[0];
374
374
  try {
375
- const data = await getSdk().billing.linkWallet(organizationId, wallet);
375
+ const data = await getSdk().billing.linkWallet(orgId, wallet);
376
376
  const output = {
377
377
  status: data?.status ?? "ok",
378
- org_id: data?.org_id ?? organizationId,
378
+ org_id: data?.org_id ?? orgId,
379
379
  wallet: data?.wallet ?? wallet.toLowerCase(),
380
380
  ...(data?.pool_implications ? { pool_implications: data.pool_implications } : {}),
381
381
  };
@@ -396,7 +396,7 @@ async function autoRecharge(args) {
396
396
  const threshold = parsedArgs.includes("--threshold")
397
397
  ? parseIntegerFlag("--threshold", thresholdStr, { min: 0 })
398
398
  : undefined;
399
- const { orgId: organizationId, rest } = await takeOrgPositional(parsedArgs, valueFlags, { cmd: "billing" });
399
+ const { orgId, rest } = await takeOrgPositional(parsedArgs, valueFlags, { cmd: "billing" });
400
400
  const count = stateFlag ? 0 : 1;
401
401
  requireRest(rest, {
402
402
  min: count, max: count,
@@ -413,11 +413,11 @@ async function autoRecharge(args) {
413
413
  }
414
414
  try {
415
415
  await getSdk().billing.setAutoRecharge({
416
- organizationId: organizationId,
416
+ orgId,
417
417
  enabled: state === "on",
418
418
  threshold,
419
419
  });
420
- console.log(JSON.stringify({ org_id: organizationId, enabled: state === "on", updated: true }));
420
+ console.log(JSON.stringify({ org_id: orgId, enabled: state === "on", updated: true }));
421
421
  } catch (err) {
422
422
  reportSdkError(err);
423
423
  }
@@ -457,7 +457,7 @@ async function metering(args) {
457
457
  const rechargeUsdMicros = parsedArgs.includes("--recharge") ? parseUsdFlag("--recharge", flagValue(parsedArgs, "--recharge")) : undefined;
458
458
  const standingRaw = flagValue(parsedArgs, "--standing-order");
459
459
  if (standingRaw !== null) assertAllowedValue(standingRaw, ["on", "off"], "--standing-order");
460
- const { orgId: organizationId, rest } = await takeOrgPositional(parsedArgs, valueFlags, { cmd: "billing" });
460
+ const { orgId, rest } = await takeOrgPositional(parsedArgs, valueFlags, { cmd: "billing" });
461
461
  requireRest(rest, {
462
462
  min: 0, max: 0,
463
463
  command: "run402 billing metering [<org_id>] [--enable --cap <usd> | --disable] [--standing-order <on|off>] [--threshold <usd>] [--recharge <usd>]",
@@ -470,9 +470,9 @@ async function metering(args) {
470
470
  // without on|off) keeps the current state for the part it does not name,
471
471
  // so `--standing-order on` alone never turns metering off.
472
472
  const needsCurrent = !writes || !(enable || disable) || (touchesStandingOrder && standingRaw === null);
473
- const current = needsCurrent ? await sdk.billing.getMetering(organizationId) : null;
473
+ const current = needsCurrent ? await sdk.billing.getMetering(orgId) : null;
474
474
  if (!writes) {
475
- console.log(JSON.stringify({ org_id: organizationId, metering: current }, null, 2));
475
+ console.log(JSON.stringify({ org_id: orgId, metering: current }, null, 2));
476
476
  return;
477
477
  }
478
478
  const enabled = enable ? true : disable ? false : (current?.enabled ?? false);
@@ -483,7 +483,7 @@ async function metering(args) {
483
483
  rechargeUsdMicros,
484
484
  }
485
485
  : undefined;
486
- const data = await sdk.billing.setMetering({ organizationId, enabled, capUsdMicros, standingOrder });
486
+ const data = await sdk.billing.setMetering({ orgId, enabled, capUsdMicros, standingOrder });
487
487
  console.log(JSON.stringify(data, null, 2));
488
488
  if (data?.metering?.suspended_reason) {
489
489
  console.error(`Metering is suspended (${data.metering.suspended_reason}): fund the allowance, raise the cap, or save a card; it resumes on the next daily pass.`);
@@ -503,10 +503,10 @@ async function card(args) {
503
503
  const valueFlags = ["--org", "--return-url"];
504
504
  assertKnownFlags(parsedArgs, [...valueFlags, "--help", "-h"], valueFlags);
505
505
  const returnUrl = flagValue(parsedArgs, "--return-url");
506
- const { orgId: organizationId, rest } = await takeOrgPositional(parsedArgs, valueFlags, { cmd: "billing" });
506
+ const { orgId, rest } = await takeOrgPositional(parsedArgs, valueFlags, { cmd: "billing" });
507
507
  requireRest(rest, { min: 0, max: 0, command: "run402 billing card setup [<org_id>] [--return-url <url>]" });
508
508
  try {
509
- const data = await getSdk().billing.createCardSetup(organizationId, { returnUrl: returnUrl ?? undefined });
509
+ const data = await getSdk().billing.createCardSetup(orgId, { returnUrl: returnUrl ?? undefined });
510
510
  console.log(JSON.stringify(data, null, 2));
511
511
  console.error(`Open setup_url in a browser to save a card for this organization (the link expires ${data.expires_at}); then run402 billing metering --standing-order on.`);
512
512
  } catch (err) {
@@ -61,9 +61,11 @@ THE WORKFLOW — configure -> authorize -> test -> live:
61
61
  only — nothing that predates the route is ever delivered.
62
62
 
63
63
  What can be routed:
64
- event types deploy_activated, error_fingerprints_observed,
65
- platform_incident — the three reviewed projectors. Nothing
66
- else has one, so nothing else can be routed.
64
+ event types agent_claim_created, agent_claim_released,
65
+ agent_message_sent, deploy_activated,
66
+ error_fingerprints_observed, platform_incident,
67
+ platform_payment_received — the seven reviewed projectors.
68
+ Nothing else has one, so nothing else can be routed.
67
69
  event classes security, billing_critical, destructive_lifecycle,
68
70
  verification, and recovery may NEVER be routed to Buzz.
69
71
  Omitting --event-type/--event-class routes every registered type / every
package/lib/buzz.mjs CHANGED
@@ -46,7 +46,7 @@ Explicit consent/decision commands:
46
46
  run402 buzz revoke <buzzae_id>
47
47
 
48
48
  Project-event routing into a Buzz channel (configure → authorize → test → live):
49
- run402 buzz notifications configure --org <uuid> --installation <buzzci_id> --name <route_name> --channel <uuid> --project <project_id> [--event-type <t> ...] [--event-class <c> ...] [--include-org-events]
49
+ run402 buzz notifications configure --org <uuid> --installation <buzzci_id> --name <route_name> --channel <uuid> (--project <project_id> [--project <project_id> ...] | --all-projects) [--event-type <t> ...] [--event-class <c> ...] [--include-org-events]
50
50
  run402 buzz notifications status [--org <uuid> | <buzzper_id>]
51
51
  run402 buzz notifications test <buzzper_id> [--wait]
52
52
  run402 buzz notifications deliveries <buzzper_id> [--limit <n>] [--cursor <c>] [--delivery <buzzped_id>]
@@ -150,9 +150,9 @@ async function adopt(args) {
150
150
  const values = ["--org", "--identity-link", "--idempotency-key"];
151
151
  assertKnownFlags(a, values, values);
152
152
  requirePositionalCount(a, values, { min: 0, max: 0, command: "run402 buzz adopt direct [--org <org_id>] --identity-link <idlnk_id>" });
153
- const organizationId = await resolveOrgId(a, { cmd: "buzz" });
153
+ const orgId = await resolveOrgId(a, { cmd: "buzz" });
154
154
  return invoke(() => getSdk({ authMode: "wallet" }).buzz.adopt({
155
- organizationId,
155
+ orgId,
156
156
  identityLinkId: requiredFlag(a, "--identity-link"),
157
157
  idempotencyKey: flagValue(a, "--idempotency-key") ?? undefined,
158
158
  }));
@@ -178,7 +178,7 @@ async function adoptionOffer(args) {
178
178
  assertKnownFlags(a, values, values);
179
179
  requirePositionalCount(a, values, { min: 0, max: 0, command: "run402 buzz adopt offer [--org <org_id>] --identity-link <idlnk_id>" });
180
180
  const deploymentPath = flagValue(a, "--deployment-context-file");
181
- const organizationId = await resolveOrgId(a, { cmd: "buzz" });
181
+ const orgId = await resolveOrgId(a, { cmd: "buzz" });
182
182
  return invoke(async () => {
183
183
  const client = getSdk({ authMode: "wallet" });
184
184
  const status = await client.buzz.status();
@@ -191,7 +191,7 @@ async function adoptionOffer(args) {
191
191
  });
192
192
  }
193
193
  return client.buzz.offerAdoption({
194
- organizationId,
194
+ orgId,
195
195
  identityLinkId: requiredFlag(a, "--identity-link"),
196
196
  deploymentContext: deploymentPath ? readJsonFile(deploymentPath, "--deployment-context-file") : undefined,
197
197
  idempotencyKey: flagValue(a, "--idempotency-key") ?? undefined,
@@ -261,9 +261,9 @@ async function install(args) {
261
261
  assertKnownFlags(a, values, values);
262
262
  requirePositionalCount(a, values, { min: 0, max: 0, command: "run402 buzz install [--org <org_id>] --community <subject> [--authority <hex>]" });
263
263
  const policyFile = flagValue(a, "--policy-file");
264
- const organizationId = await resolveOrgId(a, { cmd: "buzz" });
264
+ const orgId = await resolveOrgId(a, { cmd: "buzz" });
265
265
  return invoke(() => getSdk().buzz.install({
266
- organizationId,
266
+ orgId,
267
267
  buzzCommunitySubject: requiredFlag(a, "--community"),
268
268
  buzzCommunityAuthoritySubject: flagValue(a, "--authority") ?? undefined,
269
269
  enrollmentPolicy: policyFile ? readJsonFile(policyFile, "--policy-file") : undefined,
@@ -278,7 +278,7 @@ async function enroll(args) {
278
278
  const values = ["--org", "--status"];
279
279
  assertKnownFlags(a, values, values);
280
280
  requirePositionalCount(a, values, { min: 0, max: 0, command: "run402 buzz enroll list [--org <org_id>] [--status <state>]" });
281
- return invoke(() => getSdk().buzz.enrollments.list({ organizationId: flagValue(a, "--org") ?? undefined, status: flagValue(a, "--status") ?? undefined }));
281
+ return invoke(() => getSdk().buzz.enrollments.list({ orgId: flagValue(a, "--org") ?? undefined, status: flagValue(a, "--status") ?? undefined }));
282
282
  }
283
283
  if (operation === "show") {
284
284
  const a = normalizeArgv(rest);
package/lib/buzz.test.mjs CHANGED
@@ -54,6 +54,7 @@ describe("run402 buzz CLI", () => {
54
54
  assert.match(stdout.join("\n"), /community installation/);
55
55
  assert.match(stdout.join("\n"), /human adoption/);
56
56
  assert.match(stdout.join("\n"), /agent enrollment/);
57
+ assert.match(stdout.join("\n"), /notifications configure [^\n]*--all-projects/);
57
58
  });
58
59
 
59
60
  it("reports an older gateway as unsupported without attempting a mutation", async () => {
@@ -282,7 +283,11 @@ describe("run402 buzz notifications CLI", () => {
282
283
  const help = stdout.join("\n");
283
284
  assert.match(help, /Usage:/);
284
285
  assert.match(help, /configure -> authorize -> test -> live/);
285
- assert.match(help, /deploy_activated, error_fingerprints_observed/);
286
+ // The seven routable types the gateway's BUZZ_ROUTE_FILTER_INVALID lists.
287
+ for (const t of ["agent_claim_created", "agent_claim_released", "agent_message_sent", "deploy_activated", "error_fingerprints_observed", "platform_incident", "platform_payment_received"]) {
288
+ assert.match(help, new RegExp(t));
289
+ }
290
+ assert.doesNotMatch(help, /three reviewed/);
286
291
  assert.match(help, /may NEVER be routed/);
287
292
  assert.match(help, /Buzz Desktop -> Settings -> Profile -> Identity/);
288
293
  assert.match(help, /never a deadman channel/);
@@ -277,6 +277,7 @@ export const COMMAND_MANIFEST = [
277
277
  { path: ["contacts", "rm"], positionals: [p("contact_id")], projectScoped: false, legacyPositionalProject: false, minimalArgs: ["c_1"], runStyle: "sub" },
278
278
  { path: ["contacts", "test"], positionals: [], projectScoped: false, legacyPositionalProject: false, minimalArgs: [], runStyle: "sub" },
279
279
  { path: ["contacts", "preferences"], positionals: [], projectScoped: false, legacyPositionalProject: false, minimalArgs: [], runStyle: "sub" },
280
+ { path: ["contacts", "webhook"], positionals: [], projectScoped: false, legacyPositionalProject: false, minimalArgs: [], runStyle: "sub" },
280
281
  { path: ["subscriptions", "add"], positionals: [], projectScoped: false, legacyPositionalProject: false, minimalArgs: [], runStyle: "sub" },
281
282
  { path: ["subscriptions", "list"], positionals: [], projectScoped: false, legacyPositionalProject: false, minimalArgs: [], runStyle: "sub" },
282
283
  { path: ["subscriptions", "rm"], positionals: [p("subscription_id")], projectScoped: false, legacyPositionalProject: false, minimalArgs: ["r_1"], runStyle: "sub" },
@@ -504,7 +505,7 @@ export const COMMAND_MANIFEST = [
504
505
  { path: ["contracts", "drain"], positionals: [p("signer_id")], projectScoped: true, legacyPositionalProject: true, minimalArgs: ["cwlt_gate1", "--to", "0x4444444444444444444444444444444444444444", "--confirm"] },
505
506
  { path: ["contracts", "delete"], positionals: [p("signer_id")], projectScoped: true, legacyPositionalProject: true, minimalArgs: ["cwlt_gate1", "--confirm"] },
506
507
 
507
- // ── service / cache / doctor / notifications / webhook-secret / logs ─────
508
+ // ── service / cache / doctor / notifications / logs ─────
508
509
  { path: ["service", "status"], positionals: [], projectScoped: false, legacyPositionalProject: false, minimalArgs: [] },
509
510
  { path: ["service", "health"], positionals: [], projectScoped: false, legacyPositionalProject: false, minimalArgs: [] },
510
511
  { path: ["cache", "inspect"], positionals: [p("url")], projectScoped: false, legacyPositionalProject: false, minimalArgs: ["https://example.com/"] },
@@ -514,7 +515,6 @@ export const COMMAND_MANIFEST = [
514
515
  // wallet/machine-wide, but the gate's contract is "accepts --project
515
516
  // without rejecting it," which this satisfies.
516
517
  { path: ["doctor"], positionals: [], projectScoped: true, legacyPositionalProject: false, minimalArgs: ["--no-scan"], runStyle: "merged" },
517
- { path: ["webhook-secret", "rotate"], positionals: [], projectScoped: false, legacyPositionalProject: false, minimalArgs: [] },
518
518
  // `run402 logs [<function>] --request-id <request_id>`: the optional positional is
519
519
  // the function name (`run402 errors list` samples print it that way); it is
520
520
  // never a project id.
package/lib/contacts.mjs CHANGED
@@ -45,8 +45,12 @@ Usage:
45
45
  run402 contacts add <email> [--level <1-10>] [--name <display>]
46
46
  run402 contacts connect telegram [--label <name>]
47
47
  run402 contacts rm <contact_id>
48
- run402 contacts preferences
49
- run402 contacts preferences set <key>=<value> [<key>=<value> ...]
48
+ run402 contacts preferences [--email <address>]
49
+ run402 contacts preferences set <key>=<value> [<key>=<value> ...] [--email <address>]
50
+ run402 contacts webhook
51
+ run402 contacts webhook set <https_url>
52
+ run402 contacts webhook rm
53
+ run402 contacts webhook rotate-secret
50
54
  run402 contacts test [--source app|platform] [--type <event_type>] [--severity <level>]
51
55
 
52
56
  Two kinds, one question:
@@ -58,6 +62,17 @@ Two kinds, one question:
58
62
 
59
63
  Every row carries \`kind\`. \`rm\` takes either kind's id and works out which.
60
64
 
65
+ Preferences belong to the verified email a notice goes to, not to a wallet:
66
+ a wallet acts on its verified contact email, a person signed in with
67
+ \`run402 login\` on their own verified email (--email picks among several).
68
+ Keys: lifecycle_events (off|critical_only|all), threshold_alerts
69
+ (off|digest_only|immediate), digest_cadence (off|daily|weekly|monthly),
70
+ digest_day_of_week (1-7), digest_hour_utc (0-23), locale, timezone.
71
+
72
+ The webhook is the wallet's own channel. \`webhook set\` needs passkey
73
+ assurance ('run402 login'); the first URL prints its signing secret EXACTLY
74
+ once. \`webhook rotate-secret\` prints a new one; the previous stays valid 24h.
75
+
61
76
  Notes:
62
77
  - Adding an address with no verified contact email is ACCEPTED with a
63
78
  reachability warning — you must be able to configure the chain before the
@@ -67,14 +82,14 @@ Notes:
67
82
 
68
83
  async function preferences(args) {
69
84
  const parsedArgs = normalizeArgv(args);
70
- assertKnownFlags(parsedArgs, ["--help", "-h"]);
85
+ assertKnownFlags(parsedArgs, ["--help", "-h", "--email"]);
71
86
  const positionals = positionalArgs(parsedArgs);
72
- walletAuthHeaders("/agent/v1/notifications/preferences");
87
+ const email = flagValue(parsedArgs, "--email");
88
+ const opts = email ? { email } : {};
73
89
 
74
90
  if (positionals.length === 0) {
75
- // GET preferences
76
91
  try {
77
- const data = await getSdk().admin.getNotificationPreferences();
92
+ const data = await getSdk().admin.getNotificationPreferences(opts);
78
93
  console.log(JSON.stringify(data, null, 2));
79
94
  } catch (err) {
80
95
  reportSdkError(err);
@@ -83,7 +98,7 @@ async function preferences(args) {
83
98
  }
84
99
 
85
100
  if (positionals[0] !== "set") {
86
- fail({ code: "BAD_USAGE", message: "Usage: run402 contacts preferences [set <key>=<value> ...]" });
101
+ fail({ code: "BAD_USAGE", message: "Usage: run402 contacts preferences [set <key>=<value> ...] [--email <address>]" });
87
102
  }
88
103
 
89
104
  // SET — parse remaining positional args as key=value
@@ -95,22 +110,62 @@ async function preferences(args) {
95
110
  }
96
111
  const key = kv.slice(0, eq);
97
112
  const rawValue = kv.slice(eq + 1);
98
- if (key === "digest_day_of_week" || key === "digest_hour_utc") {
99
- patch[key] = Number(rawValue);
100
- } else if (key === "webhook_url" && (rawValue === "null" || rawValue === "")) {
101
- patch[key] = null;
102
- } else {
103
- patch[key] = rawValue;
104
- }
113
+ patch[key] = key === "digest_day_of_week" || key === "digest_hour_utc" ? Number(rawValue) : rawValue;
105
114
  }
106
115
  try {
107
- const data = await getSdk().admin.setNotificationPreferences(patch, await sessionProofs("/agent/v1/notifications/preferences"));
116
+ const data = await getSdk().admin.setNotificationPreferences(patch, opts);
108
117
  console.log(JSON.stringify(data, null, 2));
109
118
  } catch (err) {
110
119
  reportSdkError(err);
111
120
  }
112
121
  }
113
122
 
123
+ async function webhook(args) {
124
+ const parsedArgs = normalizeArgv(args);
125
+ assertKnownFlags(parsedArgs, ["--help", "-h"]);
126
+ const positionals = positionalArgs(parsedArgs);
127
+ const verb = positionals[0];
128
+ const channels = getSdk().admin.channels;
129
+ try {
130
+ if (verb === undefined) {
131
+ console.log(JSON.stringify(await channels.getWebhook(), null, 2));
132
+ return;
133
+ }
134
+ if (verb === "set") {
135
+ if (positionals.length !== 2) {
136
+ fail({ code: "BAD_USAGE", message: "Usage: run402 contacts webhook set <https_url>" });
137
+ }
138
+ walletAuthHeaders("/agent/v1/notifications/channels/webhook");
139
+ const data = await channels.setWebhook(positionals[1], await sessionProofs("/agent/v1/notifications/channels/webhook"));
140
+ console.log(JSON.stringify(data, null, 2));
141
+ if (data.webhook_signing_secret) {
142
+ console.error("");
143
+ console.error("⚠ Store this signing secret NOW — it will not be shown again.");
144
+ }
145
+ return;
146
+ }
147
+ if (verb === "rm") {
148
+ walletAuthHeaders("/agent/v1/notifications/channels/webhook");
149
+ const data = await channels.removeWebhook(await sessionProofs("/agent/v1/notifications/channels/webhook"));
150
+ console.log(JSON.stringify(data, null, 2));
151
+ return;
152
+ }
153
+ if (verb === "rotate-secret") {
154
+ walletAuthHeaders("/agent/v1/notifications/channels/webhook/rotate-secret");
155
+ const data = await channels.rotateWebhookSecret(await sessionProofs("/agent/v1/notifications/channels/webhook/rotate-secret"));
156
+ console.log(JSON.stringify(data, null, 2));
157
+ console.error("");
158
+ console.error("⚠ Store this secret NOW — it will not be shown again.");
159
+ console.error("⚠ Your previous secret remains valid for the next 24 hours.");
160
+ return;
161
+ }
162
+ } catch (err) {
163
+ reportSdkError(err);
164
+ return;
165
+ }
166
+ failUnknownSubcommand("contacts webhook", verb, { extraSubcommands: ["set", "rm", "rotate-secret"] });
167
+ }
168
+
114
169
  // ---------------------------------------------------------------------------
115
170
  // Telegram channel bindings — notification-channel-routing-telegram.
116
171
  // ---------------------------------------------------------------------------
@@ -422,6 +477,9 @@ export async function run(sub, args) {
422
477
  case "preferences":
423
478
  await preferences(rest);
424
479
  return;
480
+ case "webhook":
481
+ await webhook(rest);
482
+ return;
425
483
  case "test":
426
484
  // "Am I actually reachable?" — sends a synthetic event through the
427
485
  // configured channels and subscriptions. It belongs to the noun that
@@ -2,8 +2,7 @@
2
2
  * Best-effort session + task identity sourced from the AI harness running
3
3
  * this CLI invocation (Claude Code, Codex, or Grok) — no network call, every source
4
4
  * optional, the chain always terminates. Backs coordination-room presence
5
- * resumption in rooms-context.mjs (run402-private's
6
- * presence-naming-ergonomics, tasks 2.2 / 3.1-3.2).
5
+ * resumption in rooms-context.mjs (decisions D-agent-presence-1 and -2).
7
6
  *
8
7
  * Session identity is what makes a presence RESUMABLE across a lost local
9
8
  * cache (a fresh checkout, a wiped .run402/, a restarted machine): the
@@ -222,7 +221,7 @@ async function readCodexThreadTitle({ env, existsSyncImpl, homedirImpl }) {
222
221
  /**
223
222
  * Best-effort "what is this session working on", sourced from the harness's
224
223
  * own thread title when the caller did not pass an explicit `task`. Design
225
- * D1a (presence-naming-ergonomics): the thread title is the best
224
+ * D-agent-presence-2 (run402-private): the thread title is the best
226
225
  * "what am I working on" string in the system — automatic, human-meaningful,
227
226
  * already maintained by the user — and the schema already has the right
228
227
  * slot for it (`task` is display-only and already refreshed on every
package/lib/jobs.mjs CHANGED
@@ -24,10 +24,10 @@ Usage:
24
24
 
25
25
  Subcommands:
26
26
  submit --file <path>|--stdin Submit a managed job request
27
- get <job_id> Get a job run
27
+ get <job_id> Get a job
28
28
  logs <job_id> Read job logs
29
29
  cancel <job_id> Cancel a queued or running job
30
- purge Purge all job runs for the project
30
+ purge Purge all jobs for the project
31
31
  artifacts get <job_id> --file <name> Download a completed job's artifact (legacy: <job_id> <file>)
32
32
 
33
33
  Examples:
@@ -69,7 +69,7 @@ Example request:
69
69
  dedupe on the Run402-Webhook-Id header and re-fetch with 'jobs get'
70
70
  before acting.
71
71
  `,
72
- get: `run402 jobs get — Get a managed job run
72
+ get: `run402 jobs get — Get a managed job
73
73
 
74
74
  Usage:
75
75
  run402 jobs get <job_id> [--project <project_id>]
@@ -87,7 +87,7 @@ Options:
87
87
  --tail <n> Maximum entries to return (gateway max: 1000)
88
88
  --since <iso> Only include logs at or after this ISO-8601 timestamp
89
89
  `,
90
- cancel: `run402 jobs cancel — Cancel a managed job run
90
+ cancel: `run402 jobs cancel — Cancel a managed job
91
91
 
92
92
  Usage:
93
93
  run402 jobs cancel <job_id> [--project <project_id>]
@@ -95,7 +95,7 @@ Usage:
95
95
  Options:
96
96
  --project <project_id> Project ID (defaults to the active project)
97
97
  `,
98
- purge: `run402 jobs purge — Purge all managed job runs for a project
98
+ purge: `run402 jobs purge — Purge all managed jobs for a project
99
99
 
100
100
  Usage:
101
101
  run402 jobs purge [--project <project_id>]
@@ -103,7 +103,7 @@ Usage:
103
103
  Options:
104
104
  --project <project_id> Project ID (defaults to the active project)
105
105
 
106
- Deletes all project-scoped managed-job run records. Queued/running jobs are
106
+ Deletes all of the project's managed-job records. Queued/running jobs are
107
107
  included in the purge; known active runner instances are terminated first.
108
108
  Prints { deleted_jobs, cancelled_active_jobs, terminated_instances }.
109
109
  `,
package/lib/orgs.mjs CHANGED
@@ -717,7 +717,7 @@ async function runMember(args) {
717
717
  }
718
718
 
719
719
  if (memberAction === "revoke-key") {
720
- // vault-agent-envelopes D3: owner + step-up revokes a member's current
720
+ // D-vault-human-envelopes-9: owner + step-up revokes a member's current
721
721
  // vault encryption key — the ONLY rotation path for a member that shares
722
722
  // an org with another custodian (a lost/rebuilt keystore fails
723
723
  // VAULT_KEY_ROTATION_REQUIRED and points here). Adapter only.
@@ -145,7 +145,7 @@ const configModP = import("./config.mjs");
145
145
  const { getSdk } = await sdkModP;
146
146
  const { resolveWalletCore, enforceWalletExistsCore, WalletSelectionError } = await walletModP;
147
147
  const { vaultRemoteAddressForm, vaultSlugReleasedInfo, parseVaultRemoteUrl, vaultDegradedReadNote } = await isoModP;
148
- const { VAULT_R402_REF_NAMESPACE, hardenedGit, resolveGitInvocationRepo, readPinnedVaultRepo, pinVaultRepo, readVaultRestoreMarker, readVaultAutoGcThreshold, predialVaultObjectStore } = await nodeModP;
148
+ const { VAULT_R402_REF_NAMESPACE, hardenedGit, resolveGitInvocationRepo, readPinnedVaultRepo, pinVaultRepo, readVaultRestoreMarker, readVaultAutoGcThreshold, predialVaultObjectStore, predialVaultObjectStoreForProject } = await nodeModP;
149
149
  const { walletFile, projectCredentialsFile, profileStateFile } = await configModP;
150
150
 
151
151
  /**
@@ -321,6 +321,17 @@ function resolveRemoteAddress(argv) {
321
321
  return null;
322
322
  }
323
323
 
324
+ /**
325
+ * The id-form address git's argv names, or `null` (no address, or a slug
326
+ * that names no project id). The resident daemon's session-accept predial
327
+ * (vault-object-host-predial task 2.3) uses it to find a fresh clone
328
+ * target's repo in the keystore before the session module takes over.
329
+ */
330
+ export function idFormRemoteAddress(argv) {
331
+ const address = resolveRemoteAddress(Array.isArray(argv) ? argv : []);
332
+ return address && vaultRemoteAddressForm(address) === "id" ? address : null;
333
+ }
334
+
324
335
  /** `[+]<src>:<dst>` — an empty `<src>` is a deletion. */
325
336
  function parsePushSpec(spec) {
326
337
  const forced = spec.startsWith("+");
@@ -480,16 +491,20 @@ async function main(argv, { onBackgroundWork } = {}) {
480
491
  // fallback path — this module IS that fallback; a daemon-forwarded
481
492
  // session reaches the same code and gets the same predial for free).
482
493
  // The repository is now known OFFLINE (no network read, matching
483
- // design D6) — fire-and-forget dial the addressed repo's persisted
494
+ // D-vault-client-surface-11) — fire-and-forget dial the addressed repo's persisted
484
495
  // object-store origin(s), if the local keystore has learned any, so
485
496
  // it overlaps the rest of this session's local work exactly like the
486
497
  // API-origin prewarm that already raced module load above. A repo
487
498
  // with no local pin (never opened here before) or nothing persisted
488
499
  // yet predials nothing — never a source of a new failure mode.
500
+ // Task 2.3: a fresh clone target carries no pin yet (a handoff
501
+ // `resume` clone always), so an id-form address resolves the repo
502
+ // from the keystore's own project→repo match instead — still offline.
489
503
  void (async () => {
490
504
  try {
491
505
  const pinned = await readPinnedVaultRepo(resolvedRepo.repo_dir);
492
506
  if (pinned) predialVaultObjectStore(pinned.repo_id);
507
+ else if (addressForm === "id") predialVaultObjectStoreForProject(address.project_id, address.org_id);
493
508
  } catch {
494
509
  /* best-effort: must never surface from repository resolution */
495
510
  }
@@ -648,7 +663,7 @@ async function main(argv, { onBackgroundWork } = {}) {
648
663
  fetchMarker = null;
649
664
  }
650
665
  }
651
- // vault-restore-recipe design D2/D6: a marker-absent fetch target is,
666
+ // D-vault-19, D-vault-client-surface-21: a marker-absent fetch target is,
652
667
  // by construction, the WHOLESALE restore shape (a fresh `git clone`, or
653
668
  // a target that never completed a restore) — declare restore intent
654
669
  // here so a capable gateway's plan rides THIS state read, reused by
package/lib/repos.mjs CHANGED
@@ -2033,7 +2033,7 @@ async function invite(args) {
2033
2033
  // The inviter's own message must not wake the inviter's next `messages wait`:
2034
2034
  // advance this checkout's stored cursor past it (best-effort).
2035
2035
  if (result.room?.room_key && result.room_message?.posted && typeof result.room_message.cursor === "string") {
2036
- try { updateRoomState(result.room.organization_id, result.room.room_key, { cursor: result.room_message.cursor }); } catch { /* never fails a mint */ }
2036
+ try { updateRoomState(result.room.org_id, result.room.room_key, { cursor: result.room_message.cursor }); } catch { /* never fails a mint */ }
2037
2037
  }
2038
2038
  if (asJson) {
2039
2039
  printJson(sdk, result);
@@ -2099,7 +2099,7 @@ async function joinInvite(args) {
2099
2099
  try {
2100
2100
  const dir = result.restored?.dir;
2101
2101
  if (dir && existsSync(dir)) {
2102
- updateRoomState(result.room.organization_id, result.room.room_key, {
2102
+ updateRoomState(result.room.org_id, result.room.room_key, {
2103
2103
  ...(result.presence ? { presence_id: result.presence.presence_id, name: result.presence.name } : {}),
2104
2104
  ...(typeof result.cursor === "string" ? { cursor: result.cursor } : {}),
2105
2105
  }, { cwd: dir });
@@ -2894,7 +2894,7 @@ async function accessRevokeKey(args) {
2894
2894
  */
2895
2895
  /**
2896
2896
  * `repos access repin --principal <principal_id> --fingerprint <ek_…>` — a KEY-HOLDER
2897
- * explicitly accepts a recipient's CHANGED key (vault-agent-envelopes D3).
2897
+ * explicitly accepts a recipient's CHANGED key (D-vault-client-surface-24).
2898
2898
  * The session-start reconcile refuses `pinned_key_mismatch` and never
2899
2899
  * bypasses it, not even after an owner's revoke — acceptance names the new
2900
2900
  * fingerprint (the out-of-band verification point) and moves the local pin.
@@ -53,14 +53,14 @@ export async function runDaemon() {
53
53
  // Load the heavy module ONCE — this is the entire point of residency.
54
54
  // Its top-level await pulls the SDK graph; the prewarm dials the API
55
55
  // origin so the first forwarded session rides a warm h2 connection.
56
- const { prewarmVaultConnection, kickVaultConnection, predialVaultObjectStore } = await import("../sdk/dist/node/vault-prewarm.js");
56
+ const { prewarmVaultConnection, kickVaultConnection, predialVaultObjectStore, predialVaultObjectStoreForProject } = await import("../sdk/dist/node/vault-prewarm.js");
57
57
  prewarmVaultConnection();
58
- const { runHelperSession } = await import("./remote-helper-session.mjs");
58
+ const { runHelperSession, idFormRemoteAddress } = await import("./remote-helper-session.mjs");
59
59
  // vault-object-host-predial task 2.2 — narrow, session-scoped imports
60
60
  // (not the whole `#sdk/node` barrel) for the OFFLINE repo resolution the
61
61
  // session-accept predial needs: a local git subprocess (`rev-parse
62
62
  // --absolute-git-dir`) plus a local git-config read, never a network
63
- // call (design D6).
63
+ // call (D-vault-client-surface-11).
64
64
  const { resolveGitInvocationRepo } = await import("../sdk/dist/node/vault-snapshot.js");
65
65
  const { readPinnedVaultRepo } = await import("../sdk/dist/node/vault-address.js");
66
66
 
@@ -202,13 +202,19 @@ export async function runDaemon() {
202
202
  // --absolute-git-dir`) then `readPinnedVaultRepo` (a local
203
203
  // `git config --local` read). Any resolution failure (no
204
204
  // `GIT_DIR`, not a repository, no pin yet) predials nothing —
205
- // never a network read to learn where to predial (design D6),
205
+ // never a network read to learn where to predial (D-vault-client-surface-11),
206
206
  // and never allowed to delay or fail this session's accept.
207
207
  void (async () => {
208
208
  try {
209
209
  const { repo_dir } = await resolveGitInvocationRepo(msg.env ?? {}, msg.cwd);
210
210
  const pinned = await readPinnedVaultRepo(repo_dir);
211
211
  if (pinned) predialVaultObjectStore(pinned.repo_id);
212
+ else {
213
+ // Task 2.3: a fresh clone target has no pin yet — find the
214
+ // addressed repo in the keystore by its project, offline.
215
+ const address = idFormRemoteAddress(msg.argv);
216
+ if (address) predialVaultObjectStoreForProject(address.project_id, address.org_id);
217
+ }
212
218
  } catch {
213
219
  /* best-effort: must never surface from session accept */
214
220
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "run402",
3
- "version": "4.155.0",
3
+ "version": "4.156.0",
4
4
  "description": "CLI for Run402 — full-stack backend infrastructure for AI agents: Postgres, auth, storage, serverless functions and atomic deploys. Paid with x402/MPP. Includes $0.03 image generation.",
5
5
  "type": "module",
6
6
  "bin": {