@lazehq/cli 0.1.127 → 0.1.129

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 (2) hide show
  1. package/dist/laze.mjs +893 -370
  2. package/package.json +1 -1
package/dist/laze.mjs CHANGED
@@ -19486,7 +19486,7 @@ var require_snapshot_utils = __commonJS({
19486
19486
  var require_snapshot_recorder = __commonJS({
19487
19487
  "../../node_modules/.pnpm/undici@8.10.0/node_modules/undici/lib/mock/snapshot-recorder.js"(exports, module) {
19488
19488
  "use strict";
19489
- var { writeFile: writeFile12, readFile: readFile39, mkdir: mkdir14 } = __require("node:fs/promises");
19489
+ var { writeFile: writeFile12, readFile: readFile40, mkdir: mkdir14 } = __require("node:fs/promises");
19490
19490
  var { dirname: dirname29, resolve: resolve27 } = __require("node:path");
19491
19491
  var { setTimeout: setTimeout2, clearTimeout: clearTimeout2 } = __require("node:timers");
19492
19492
  var { InvalidArgumentError, UndiciError } = require_errors();
@@ -19703,7 +19703,7 @@ var require_snapshot_recorder = __commonJS({
19703
19703
  throw new InvalidArgumentError("Snapshot path is required");
19704
19704
  }
19705
19705
  try {
19706
- const data = await readFile39(resolve27(path), "utf8");
19706
+ const data = await readFile40(resolve27(path), "utf8");
19707
19707
  const parsed = JSON.parse(data);
19708
19708
  if (Array.isArray(parsed)) {
19709
19709
  this.#snapshots.clear();
@@ -36960,7 +36960,7 @@ function shadowedLinkLineOf({ shadow }) {
36960
36960
  }
36961
36961
 
36962
36962
  // src/rules/cli-version.rules.ts
36963
- var STAMPED = "0.1.127";
36963
+ var STAMPED = "0.1.129";
36964
36964
  function cliVersionOf({ stamped = STAMPED } = {}) {
36965
36965
  return stamped.startsWith("__") ? "dev" : stamped;
36966
36966
  }
@@ -37586,7 +37586,7 @@ function linkedProfileNameOf({
37586
37586
  }
37587
37587
  }
37588
37588
  function revokedKeyLineOf({ profile }) {
37589
- return `${profile}: this agent's key was revoked: run \`laze agent link\` again or remove it with \`laze logout --profile ${profile}\``;
37589
+ return `${profile}: Laze refuses this agent's key. Ask its person for a new link (in Laze: Reconnect beside the agent, then Regenerate Connection Key) and run \`laze agent link --token <token>\` with it in the agent's session, or remove it with \`laze logout --profile ${profile}\``;
37590
37590
  }
37591
37591
 
37592
37592
  // src/rules/refusal-format.rules.ts
@@ -60135,6 +60135,101 @@ var dropVaultAgentAccessInputSchemaDefinition = external_exports.object({
60135
60135
  });
60136
60136
  var VaultAgentRulesDialogSlot = uiTokens("vault").component("agentRulesDialog");
60137
60137
 
60138
+ // ../../modules/vault/contract/src/vault-levels.ts
60139
+ var LEVEL_LABELS = {
60140
+ auto: "Allow",
60141
+ checked: "Auto",
60142
+ ask: "Always ask",
60143
+ human_only: "Human only"
60144
+ };
60145
+ function vaultLevelLabel(level2) {
60146
+ return LEVEL_LABELS[level2];
60147
+ }
60148
+ var CLI_LEVELS = {
60149
+ auto: "allow",
60150
+ checked: "auto",
60151
+ ask: "always-ask",
60152
+ human_only: "human-only"
60153
+ };
60154
+ var VAULT_CLI_LEVEL_NAMES = [
60155
+ "allow",
60156
+ "auto",
60157
+ "always-ask",
60158
+ "human-only"
60159
+ ];
60160
+ function vaultCliLevelOf(level2) {
60161
+ return CLI_LEVELS[level2];
60162
+ }
60163
+ function vaultLevelOfCliName(name3) {
60164
+ const wanted = name3.toLowerCase();
60165
+ const found = Object.keys(CLI_LEVELS).find(
60166
+ (level2) => CLI_LEVELS[level2] === wanted
60167
+ );
60168
+ return found ?? "unknown";
60169
+ }
60170
+
60171
+ // ../../modules/vault/contract/src/vault.errors.ts
60172
+ var VaultSealMismatchError = class extends HandledError {
60173
+ constructor() {
60174
+ super("vault_seal_mismatch", "This sealed value does not belong to the secret it names", {
60175
+ httpStatus: 422
60176
+ });
60177
+ this.name = "VaultSealMismatchError";
60178
+ }
60179
+ };
60180
+
60181
+ // ../../modules/vault/contract/src/vault-boundary.ts
60182
+ var VAULT_BOUNDARY_HOST = /^(?=.{1,259}$)[a-z0-9](?:[a-z0-9-]*[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)*:\d{1,5}$/;
60183
+ var vaultBoundaryResolveInputSchemaDefinition = external_exports.object({
60184
+ agentId: external_exports.string().min(1),
60185
+ connectionId: external_exports.string().min(1),
60186
+ field: external_exports.string().min(1).max(200),
60187
+ host: external_exports.string().regex(VAULT_BOUNDARY_HOST),
60188
+ method: external_exports.string().max(20).default("GET"),
60189
+ path: external_exports.string().max(2e3).default("/"),
60190
+ /** The proxy read the body as a read, such as a GraphQL document of queries only. */
60191
+ readOnly: external_exports.boolean().optional(),
60192
+ /** The read the proxy found, such as "GraphQL query Issues". */
60193
+ operation: external_exports.string().max(120).optional()
60194
+ });
60195
+ var vaultBoundaryResolutionSchemaDefinition = external_exports.discriminatedUnion("decision", [
60196
+ external_exports.object({ decision: external_exports.literal("allow"), value: external_exports.string() }),
60197
+ external_exports.object({ decision: external_exports.literal("pending"), requestId: external_exports.string(), message: external_exports.string() }),
60198
+ external_exports.object({ decision: external_exports.literal("deny"), code: external_exports.string(), message: external_exports.string() })
60199
+ ]);
60200
+ var vaultBoundaryStatusInputSchemaDefinition = external_exports.object({
60201
+ agentId: external_exports.string().min(1),
60202
+ requestId: external_exports.string().min(1),
60203
+ field: external_exports.string().min(1).max(200),
60204
+ host: external_exports.string().regex(VAULT_BOUNDARY_HOST)
60205
+ });
60206
+ var vaultValueShapeSchemaDefinition = external_exports.object({
60207
+ kept: external_exports.string().max(8),
60208
+ classes: external_exports.string().regex(/^[luds]*$/),
60209
+ symbols: external_exports.string()
60210
+ });
60211
+ var vaultValueShapeSchema = vaultValueShapeSchemaDefinition;
60212
+ var vaultBoundaryKeySchemaDefinition = external_exports.object({
60213
+ connectionId: external_exports.string().min(1),
60214
+ name: external_exports.string().min(1),
60215
+ field: external_exports.string().min(1),
60216
+ shape: vaultValueShapeSchema
60217
+ });
60218
+ var vaultEgressHostSchemaDefinition = external_exports.object({
60219
+ host: external_exports.string(),
60220
+ addedBy: external_exports.enum(["judge", "person"]),
60221
+ addedByUserId: external_exports.string().nullable(),
60222
+ reason: external_exports.string().nullable(),
60223
+ createdAt: external_exports.iso.datetime()
60224
+ });
60225
+ var vaultEgressHostSchema = vaultEgressHostSchemaDefinition;
60226
+ var vaultEgressHostInputSchemaDefinition = external_exports.object({
60227
+ workspaceId: external_exports.string().min(1),
60228
+ connectionId: external_exports.string().min(1),
60229
+ host: external_exports.string().min(1).max(260)
60230
+ });
60231
+ var vaultEgressHostInputSchema = vaultEgressHostInputSchemaDefinition;
60232
+
60138
60233
  // ../../modules/vault/contract/src/vault-devices.ts
60139
60234
  var base64Url = external_exports.string().regex(/^[A-Za-z0-9_-]+$/).max(16384);
60140
60235
  var name = external_exports.string().regex(/^[a-z0-9][a-z0-9-]{0,62}$/);
@@ -60642,6 +60737,8 @@ var vaultConnectionSchemaDefinition = external_exports.object({
60642
60737
  maxLeaseSeconds: external_exports.number().int().positive().nullable(),
60643
60738
  /** Every use asks a person: no lease is offered and none covers it. */
60644
60739
  everyUseAsks: external_exports.boolean().default(false),
60740
+ /** Used in-process on the agent's computer: a hosted agent gets the value, not a placeholder. */
60741
+ localUse: external_exports.boolean().default(false),
60645
60742
  /** Every Allow and lease needs a passkey, Touch ID or Face ID proof, never a plain tap. */
60646
60743
  deviceApproval: external_exports.boolean().optional(),
60647
60744
  fieldNames: external_exports.array(vaultFieldNameSchema),
@@ -60674,6 +60771,7 @@ var createVaultConnectionInputSchemaDefinition = external_exports.object({
60674
60771
  approverUserIds: external_exports.array(external_exports.string().min(1)).default([]),
60675
60772
  maxLeaseSeconds: external_exports.number().int().positive().max(VAULT_LONGEST_LEASE_SECONDS).nullable().default(null),
60676
60773
  everyUseAsks: external_exports.boolean().default(false),
60774
+ localUse: external_exports.boolean().default(false),
60677
60775
  secret: vaultSecretBundleSchema,
60678
60776
  egress: vaultEgressTargetSchema.nullable().default(null)
60679
60777
  });
@@ -60687,6 +60785,7 @@ var updateVaultConnectionInputSchemaDefinition = external_exports.object({
60687
60785
  approverUserIds: external_exports.array(external_exports.string().min(1)).optional(),
60688
60786
  maxLeaseSeconds: external_exports.number().int().positive().max(VAULT_LONGEST_LEASE_SECONDS).nullable().optional(),
60689
60787
  everyUseAsks: external_exports.boolean().optional(),
60788
+ localUse: external_exports.boolean().optional(),
60690
60789
  /** On from anywhere; off only from the page, with a fresh device proof. */
60691
60790
  deviceApproval: external_exports.boolean().optional(),
60692
60791
  secret: vaultSecretBundleSchema.optional(),
@@ -60918,7 +61017,11 @@ var vaultEgressResolveInputSchemaDefinition = external_exports.object({
60918
61017
  /** A floor the proxy sets for a guarded request, such as a git push asking before it goes. */
60919
61018
  atLeast: vaultSensitivitySchema.optional(),
60920
61019
  /** What the proxy knows the request is, such as "git push to github.com/acme/widgets". */
60921
- reason: external_exports.string().max(300).optional()
61020
+ reason: external_exports.string().max(300).optional(),
61021
+ /** The proxy read the body as a read, such as a GraphQL document of queries only. */
61022
+ readOnly: external_exports.boolean().optional(),
61023
+ /** The read the proxy found, such as "GraphQL query PullRequestByNumber". */
61024
+ operation: external_exports.string().max(120).optional()
60922
61025
  });
60923
61026
  var vaultEgressResolutionSchemaDefinition = external_exports.discriminatedUnion("decision", [
60924
61027
  external_exports.object({ decision: external_exports.literal("allow"), value: external_exports.string() }),
@@ -61294,11 +61397,13 @@ var vaultCoreTrpc = defineTrpcContract("vault").mutation("createConnection").wit
61294
61397
  ).withOutput(vaultSealedMaterialSchema).query("getSealedApproval").withInput(external_exports.object({ ...workspaceInput.shape, requestId: external_exports.string().min(1) })).withOutput(vaultSealedApprovalSchema).mutation("answerSealedApproval").withInput(answerSealedApprovalInputSchema).withOutput(vaultApprovalRequestSchema).mutation("compareSecret").withInput(compareVaultSecretInputSchema).withOutput(vaultSecretComparisonSchema).mutation("replaceSecretValue").withInput(replaceVaultSecretValueInputSchema).withOutput(vaultConnectionSchema).mutation("savePastedSecret").withInput(external_exports.object({ ...workspaceInput.shape, ...saveVaultPastedSecretBodySchema.shape })).withOutput(vaultPastedSecretSavedSchema).build();
61295
61398
  var vaultAgentRuleTrpc = defineTrpcContract("vault").query("listAgentRules").withInput(listVaultAgentRulesInputSchema).withOutput(external_exports.array(vaultAgentRuleEntrySchema)).mutation("setAgentRule").withInput(setVaultAgentRuleInputSchema).withOutput(external_exports.array(vaultAgentRuleEntrySchema)).build();
61296
61399
  var vaultTierTrpc = defineTrpcContract("vault").query("tierPolicy").withInput(workspaceInput).withOutput(vaultTierPolicySchema).mutation("setTierSetting").withInput(setVaultTierSettingInputSchema).withOutput(vaultTierPolicySchema).mutation("setSubjectTier").withInput(setVaultSubjectTierInputSchema).withOutput(vaultTierPolicySchema).build();
61400
+ var vaultEgressHostTrpc = defineTrpcContract("vault").query("listEgressHosts").withInput(vaultEgressHostInputSchema.omit({ host: true })).withOutput(external_exports.array(vaultEgressHostSchema)).mutation("addEgressHost").withInput(vaultEgressHostInputSchema).withOutput(external_exports.array(vaultEgressHostSchema)).mutation("removeEgressHost").withInput(vaultEgressHostInputSchema).withOutput(external_exports.array(vaultEgressHostSchema)).build();
61297
61401
  var vaultTrpc = joinTrpcContracts(
61298
61402
  "vault",
61299
61403
  vaultCoreTrpc,
61300
61404
  vaultAgentRuleTrpc,
61301
- vaultTierTrpc
61405
+ vaultTierTrpc,
61406
+ vaultEgressHostTrpc
61302
61407
  );
61303
61408
 
61304
61409
  // ../../modules/vault/contract/src/vault.config.ts
@@ -61312,6 +61417,11 @@ var vaultConfig = Config.define((c) => ({
61312
61417
  turnTtlMinutes: c.env("VAULT_TURN_TTL_MINUTES", positiveInt.default(1440)),
61313
61418
  /** The judge runs only when this is on and its key is set; off, Checked asks a person. */
61314
61419
  judgeEnabled: c.env("VAULT_JUDGE_ENABLED", environmentBooleanSchema.default(false)),
61420
+ /**
61421
+ * The judge decides new egress hosts when this is on (it passed its eval on the EU endpoint);
61422
+ * off, every new host asks a person. ADR 20261112-egress-boundary.
61423
+ */
61424
+ hostJudgeEnabled: c.env("VAULT_HOST_JUDGE_ENABLED", environmentBooleanSchema.default(true)),
61315
61425
  judgeTimeoutMs: c.env("VAULT_JUDGE_TIMEOUT_MS", positiveInt.default(2e4)),
61316
61426
  /** Where the judge posts /v1/decisions: OpenAI's EU host, or the LangWatch AI gateway. */
61317
61427
  judgeBaseUrl: c.env("VAULT_JUDGE_BASE_URL", external_exports.url().default("https://eu.api.openai.com")),
@@ -61351,49 +61461,6 @@ var vaultConfig = Config.define((c) => ({
61351
61461
  alertWorkspaceId: c.env("VAULT_ALERT_WORKSPACE_ID", external_exports.string().min(1).optional())
61352
61462
  }));
61353
61463
 
61354
- // ../../modules/vault/contract/src/vault-levels.ts
61355
- var LEVEL_LABELS = {
61356
- auto: "Allow",
61357
- checked: "Auto",
61358
- ask: "Always ask",
61359
- human_only: "Human only"
61360
- };
61361
- function vaultLevelLabel(level2) {
61362
- return LEVEL_LABELS[level2];
61363
- }
61364
- var CLI_LEVELS = {
61365
- auto: "allow",
61366
- checked: "auto",
61367
- ask: "always-ask",
61368
- human_only: "human-only"
61369
- };
61370
- var VAULT_CLI_LEVEL_NAMES = [
61371
- "allow",
61372
- "auto",
61373
- "always-ask",
61374
- "human-only"
61375
- ];
61376
- function vaultCliLevelOf(level2) {
61377
- return CLI_LEVELS[level2];
61378
- }
61379
- function vaultLevelOfCliName(name3) {
61380
- const wanted = name3.toLowerCase();
61381
- const found = Object.keys(CLI_LEVELS).find(
61382
- (level2) => CLI_LEVELS[level2] === wanted
61383
- );
61384
- return found ?? "unknown";
61385
- }
61386
-
61387
- // ../../modules/vault/contract/src/vault.errors.ts
61388
- var VaultSealMismatchError = class extends HandledError {
61389
- constructor() {
61390
- super("vault_seal_mismatch", "This sealed value does not belong to the secret it names", {
61391
- httpStatus: 422
61392
- });
61393
- this.name = "VaultSealMismatchError";
61394
- }
61395
- };
61396
-
61397
61464
  // ../../modules/vault/contract/src/vault.events.ts
61398
61465
  var vaultApprovalRequestedPayloadSchemaDefinition = external_exports.object({
61399
61466
  workspaceId: external_exports.string().min(1),
@@ -61799,6 +61866,16 @@ var vaultAlertRaisedPayloadSchemaDefinition = external_exports.object({
61799
61866
  recipientUserIds: external_exports.array(external_exports.string().min(1)),
61800
61867
  at: external_exports.iso.datetime()
61801
61868
  });
61869
+ var vaultOpsAlertSchemaDefinition = external_exports.object({
61870
+ /** When vaultd (or the vault) raised it, not when Laze recorded it. */
61871
+ at: external_exports.iso.datetime(),
61872
+ seq: external_exports.number().int().nonnegative().nullable(),
61873
+ kind: external_exports.string().min(1),
61874
+ /** The workspace the alert is about; null for a total or a process alert. */
61875
+ subjectWorkspaceId: external_exports.string().min(1).nullable(),
61876
+ /** Counts, windows, uses and caller labels as vaultd sent them: never a value or an AAD. */
61877
+ detail: vaultAlertDetailSchema
61878
+ });
61802
61879
 
61803
61880
  // ../../modules/vault/contract/src/vault-pending.ts
61804
61881
  var connectionName2 = external_exports.string().regex(/^[a-z0-9][a-z0-9-]{0,62}$/);
@@ -62366,6 +62443,11 @@ var vaultBatchReleaseInputSchemaDefinition = external_exports.object({
62366
62443
  ...batchFieldsDefinition
62367
62444
  });
62368
62445
  var vaultBatchReleaseInputSchema = vaultBatchReleaseInputSchemaDefinition;
62446
+ var vaultEgressBatchReleaseInputSchemaDefinition = external_exports.object({
62447
+ ...vaultBatchReleaseInputSchemaDefinition.shape,
62448
+ /** The computer holds placeholders: a key swapped at the boundary comes back as `boundary`. */
62449
+ placeholders: external_exports.boolean().default(false)
62450
+ });
62369
62451
  var vaultBatchConnectionSchemaDefinition = external_exports.object({
62370
62452
  name: vaultConnectionNameSchema,
62371
62453
  label: external_exports.string(),
@@ -62377,7 +62459,9 @@ var vaultBatchConnectionSchema = vaultBatchConnectionSchemaDefinition;
62377
62459
  var vaultBatchEntrySchemaDefinition = external_exports.object({
62378
62460
  ref: external_exports.string(),
62379
62461
  connection: vaultBatchConnectionSchema.nullable(),
62380
- release: vaultRunReleaseSchema.nullable()
62462
+ release: vaultRunReleaseSchema.nullable(),
62463
+ /** The key is swapped at the egress boundary: the computer's own placeholder stands in for it. */
62464
+ boundary: external_exports.object({ connectionId: external_exports.string() }).optional()
62381
62465
  });
62382
62466
  var vaultBatchEntrySchema = vaultBatchEntrySchemaDefinition;
62383
62467
  var vaultBatchReleaseSchemaDefinition = external_exports.object({
@@ -64413,6 +64497,30 @@ var forgetMirroredInputSchemaDefinition = external_exports.object({
64413
64497
  before: external_exports.iso.datetime(),
64414
64498
  limit: external_exports.number().int().positive().max(1e3).default(500)
64415
64499
  });
64500
+ var listMirroredMessagesInputSchemaDefinition = external_exports.object({
64501
+ workspaceId: workspaceIdSchema,
64502
+ channelId: idSchema4,
64503
+ since: external_exports.iso.datetime(),
64504
+ /** Messages numbered above this one; 0 starts at the first. */
64505
+ afterSeq: external_exports.number().int().nonnegative().default(0),
64506
+ limit: external_exports.number().int().min(1).max(500).default(200)
64507
+ });
64508
+ var mirroredMessagesPageSchemaDefinition = external_exports.object({
64509
+ messages: external_exports.array(
64510
+ external_exports.object({
64511
+ seq: external_exports.number().int(),
64512
+ originKey: external_exports.string(),
64513
+ createdAt: external_exports.iso.datetime(),
64514
+ /** The Laze person who wrote it through the mirror, such as the owner; null for others. */
64515
+ personId: external_exports.string().nullable(),
64516
+ /** The name the source gave its author; empty when it gave none. */
64517
+ authorName: external_exports.string(),
64518
+ body: external_exports.string()
64519
+ })
64520
+ ),
64521
+ /** The `afterSeq` that reads on; null on the last page. */
64522
+ nextSeq: external_exports.number().int().nullable()
64523
+ });
64416
64524
  var mirrorUnreadsInputSchemaDefinition = external_exports.object({
64417
64525
  workspaceId: workspaceIdSchema,
64418
64526
  userId: idSchema4,
@@ -65202,7 +65310,7 @@ var apnsPayloadSchemaDefinition = external_exports.object({
65202
65310
  badge: external_exports.number().int().nonnegative().optional(),
65203
65311
  /** Who a message alert is from, for a communication notification with their picture. */
65204
65312
  sender: apnsSenderSchemaDefinition.optional(),
65205
- /** The channel a message alert is in ("#ops"): the app shows it as a group conversation. */
65313
+ /** Where a message alert was said ("#ops", a conversation, a group DM), to group it under. */
65206
65314
  conversationName: external_exports.string().min(2).max(120).optional()
65207
65315
  }).strict();
65208
65316
 
@@ -67405,6 +67513,17 @@ var egressConnectionSchemaDefinition = external_exports.object({
67405
67513
  message: "A connection holds a secret or is the vault's, never both"
67406
67514
  });
67407
67515
  var egressConnectionSchema = egressConnectionSchemaDefinition;
67516
+ var boundaryKeySchemaDefinition = external_exports.object({
67517
+ connectionId: external_exports.string().min(1),
67518
+ name: external_exports.string().min(1),
67519
+ field: external_exports.string().min(1),
67520
+ shape: external_exports.object({
67521
+ kept: external_exports.string().max(8),
67522
+ classes: external_exports.string().regex(/^[luds]*$/),
67523
+ symbols: external_exports.string()
67524
+ })
67525
+ });
67526
+ var BOUNDARY_KEYS_MAX = 1e3;
67408
67527
  var claudeGatewayModelsSchemaDefinition = external_exports.object({
67409
67528
  opus: external_exports.string().min(1),
67410
67529
  sonnet: external_exports.string().min(1),
@@ -67440,6 +67559,8 @@ var agentSandboxSpecSchemaDefinition = external_exports.object({
67440
67559
  /** The harness model's context window, when Laze knows it: compaction is set against it. */
67441
67560
  contextWindow: external_exports.number().int().positive().optional(),
67442
67561
  connections: external_exports.array(egressConnectionSchema).default([]),
67562
+ /** Vault keys swapped at the egress boundary; only for an agent in a Laze computer. */
67563
+ boundaryKeys: external_exports.array(boundaryKeySchemaDefinition).max(BOUNDARY_KEYS_MAX).optional(),
67443
67564
  /** Harness credentials that must live inside the sandbox (a user's own subscription token). */
67444
67565
  harnessEnvironment: external_exports.record(external_exports.string(), external_exports.string()).default({}),
67445
67566
  /** Files the supervisor writes under the home folder at every start, by relative path. */
@@ -67991,7 +68112,7 @@ var agentRuntimeConfig = Config.define((c) => ({
67991
68112
  * run on their owners' machines. */
67992
68113
  vmdSocketPath: c.env("AGENT_RUNTIME_VMD_SOCKET", external_exports.string().min(1).optional()),
67993
68114
  /** The agent image vmd's base image is built from; a new one makes every computer anew. */
67994
- image: c.env("AGENT_RUNTIME_IMAGE", external_exports.string().default("laze-agent:m5-rush-7")),
68115
+ image: c.env("AGENT_RUNTIME_IMAGE", external_exports.string().default("laze-agent:m5-rush-8")),
67995
68116
  supervisorBundlePath: c.env(
67996
68117
  "AGENT_RUNTIME_SUPERVISOR_BUNDLE",
67997
68118
  external_exports.string().default("/opt/laze/agent-supervisor/supervisor.mjs")
@@ -68456,7 +68577,12 @@ var agentReconnectSchemaDefinition = external_exports.discriminatedUnion("connec
68456
68577
  /** The session's folder, for its owner alone; null when unknown. */
68457
68578
  folder: external_exports.string().nullable(),
68458
68579
  /** The session's machine, for its owner alone; null when unknown. */
68459
- machine: external_exports.string().nullable()
68580
+ machine: external_exports.string().nullable(),
68581
+ /**
68582
+ * For its owner alone: whether Laze still takes the agent's key, so Reconnect asks the
68583
+ * session to check itself first and makes a new link only for a key that no longer works.
68584
+ */
68585
+ keyWorks: external_exports.boolean().optional()
68460
68586
  })
68461
68587
  ]);
68462
68588
  var agentReconnectSchema = agentReconnectSchemaDefinition;
@@ -71149,6 +71275,10 @@ var remoteHttpRequestSchemaDefinition = external_exports.object({
71149
71275
  host: external_exports.string().optional(),
71150
71276
  /** This api process on loopback, where the MCP tools call the REST operations. */
71151
71277
  loopbackOrigin: external_exports.string(),
71278
+ /** The `DPoP` header: a person's CLI key proves its machine on the request itself. */
71279
+ proof: external_exports.string().optional(),
71280
+ /** The caller's address behind the deployment's own hops. */
71281
+ clientAddress: external_exports.string().optional(),
71152
71282
  /** The MCP-Protocol-Version, Mcp-Method and Mcp-Name headers, which 2026-07-28 checks. */
71153
71283
  mcpProtocolVersion: external_exports.string().optional(),
71154
71284
  mcpMethod: external_exports.string().optional(),
@@ -73517,7 +73647,7 @@ async function reportMachine({
73517
73647
  function markMigratedOn({ context, profile }) {
73518
73648
  return async ({ notice, link: link2 }) => context.store.markMigrated({ name: profile, migrated: { at: context.nowMs(), link: link2, notice } });
73519
73649
  }
73520
- var REFUSED_RECHECK_MS = 6 * 60 * 60 * 1e3;
73650
+ var REFUSED_RECHECK_MS = 10 * 60 * 1e3;
73521
73651
  function markRefusedOn({
73522
73652
  context,
73523
73653
  profile,
@@ -78075,17 +78205,23 @@ async function rearmRushGuards({ context }) {
78075
78205
  // src/services/rush-watchdog.service.ts
78076
78206
  var UNDELIVERED_AFTER_MS = 6e4;
78077
78207
  var CHECK_TIMEOUT_MS = 5e3;
78078
- function clientOf({ context, profile }) {
78208
+ function clientOf({
78209
+ context,
78210
+ profile,
78211
+ fresh = false
78212
+ }) {
78079
78213
  return context.store.read().then((config2) => {
78080
78214
  const entry2 = config2.profiles[profile];
78081
78215
  if (!entry2 || entry2.migrated) return void 0;
78082
- if (refusedRecently({ profile: entry2, nowMs: context.nowMs() })) return void 0;
78216
+ if (!fresh && refusedRecently({ profile: entry2, nowMs: context.nowMs() })) return void 0;
78217
+ const clear = () => context.store.markRefused({ name: profile, token: entry2.token, refused: void 0 });
78083
78218
  return LazeClient.create({
78084
78219
  baseUrl: entry2.url,
78085
78220
  token: entry2.token,
78086
78221
  fetcher: (input2, init) => context.fetcher(input2, { ...init, signal: AbortSignal.timeout(CHECK_TIMEOUT_MS) }),
78087
78222
  onMigrated: markMigratedOn({ context, profile }),
78088
- onRefused: markRefusedOn({ context, profile, token: entry2.token })
78223
+ onRefused: markRefusedOn({ context, profile, token: entry2.token }),
78224
+ ...fresh && entry2.refused ? { onAnswered: clear } : {}
78089
78225
  });
78090
78226
  });
78091
78227
  }
@@ -78093,9 +78229,9 @@ async function waitingOf({
78093
78229
  context,
78094
78230
  profile
78095
78231
  }) {
78096
- const client = await clientOf({ context, profile });
78232
+ const client = await clientOf({ context, profile, fresh: true });
78097
78233
  return client?.get("/api/agents/me/inbox/waiting").catch(
78098
- (error63) => error63 instanceof LazeApiError && error63.status === 401 ? "refused" : void 0
78234
+ (error63) => error63 instanceof LazeApiError && refusesTheKey(error63) ? "refused" : void 0
78099
78235
  );
78100
78236
  }
78101
78237
  function waitedMsOf({ waiting, nowMs: nowMs2 }) {
@@ -78127,7 +78263,9 @@ async function checkSession({ context, row }) {
78127
78263
  if (row.standing === "stopped" || !row.noted) return void 0;
78128
78264
  const client = await clientOf({ context, profile: row.profile });
78129
78265
  if (!client) return void 0;
78130
- const waiting = await client.get("/api/agents/me/inbox/waiting");
78266
+ const waiting = await forSession({ client, session: row.noted.session }).get(
78267
+ "/api/agents/me/inbox/waiting"
78268
+ );
78131
78269
  const waited = waitedMsOf({ waiting, nowMs: context.nowMs() });
78132
78270
  if (waited <= UNDELIVERED_AFTER_MS) return void 0;
78133
78271
  const taken = await claimFor({ context, client, row: { ...row, noted: row.noted } });
@@ -78618,7 +78756,7 @@ async function status2({ context }) {
78618
78756
  }
78619
78757
  for (const line of await mcpRelayLinesOf({ context })) context.out(`${line}
78620
78758
  `);
78621
- for (const line of await rushLinesOf({ context })) context.out(`${line}
78759
+ for (const line of await sessionLinesOf({ context, serviceRuns: live })) context.out(`${line}
78622
78760
  `);
78623
78761
  const config2 = await context.store.read();
78624
78762
  const linked = Object.entries(config2.profiles).filter(([, profile]) => profile.delivery);
@@ -78639,40 +78777,132 @@ async function mcpRelayLinesOf({ context }) {
78639
78777
  return `${connectionId} ${relay2.label} ${targetLineOf({ target: relay2.target })} ${state}`;
78640
78778
  });
78641
78779
  }
78642
- async function rushLinesOf({ context }) {
78780
+ async function sessionLinesOf({
78781
+ context,
78782
+ serviceRuns
78783
+ }) {
78643
78784
  const lines2 = [...(await sessionNotesOf({ context, tell: false })).dropped];
78644
- const refused = /* @__PURE__ */ new Set();
78645
- for (const row of await rushListenersOf({ context })) {
78646
- if (refused.has(row.profile)) continue;
78647
- const waiting = row.refused ? "refused" : await waitingOf({ context, profile: row.profile });
78648
- if (waiting === "refused") {
78649
- refused.add(row.profile);
78650
- lines2.push(revokedKeyLineOf({ profile: row.profile }));
78651
- } else
78652
- lines2.push(`${rushLineOf({ row })}${inLazeOf({ row, waiting, nowMs: context.nowMs() })}`);
78785
+ const asked = /* @__PURE__ */ new Map();
78786
+ const rush = await rushListenersOf({ context });
78787
+ const plain3 = await plainSessionsOf({ context, skip: new Set(rush.map((row) => row.key)) });
78788
+ const rows = [
78789
+ ...rush.map((row) => ({
78790
+ profile: row.profile,
78791
+ key: row.key,
78792
+ line: rushLineOf({ row, serviceRuns }),
78793
+ delivers: rushDelivers({ row, serviceRuns }),
78794
+ where: `rush session ${row.rushId}`
78795
+ })),
78796
+ ...plain3.map((row) => ({
78797
+ profile: row.profile,
78798
+ key: row.key,
78799
+ line: plainLineOf({ row }),
78800
+ delivers: row.waiterPid !== void 0,
78801
+ where: row.claudePid ? "that Claude Code session" : `the session, once \`claude --resume ${row.sessionId}\` runs it again`
78802
+ }))
78803
+ ];
78804
+ for (const row of rows) {
78805
+ if (!asked.has(row.profile)) {
78806
+ asked.set(row.profile, await waitingOf({ context, profile: row.profile }));
78807
+ }
78808
+ for (const line of rowLinesOf({
78809
+ row,
78810
+ waiting: asked.get(row.profile),
78811
+ nowMs: context.nowMs()
78812
+ })) {
78813
+ if (!lines2.includes(line)) lines2.push(line);
78814
+ }
78653
78815
  }
78654
78816
  return lines2;
78655
78817
  }
78656
- function rushLineOf({ row }) {
78818
+ function rowLinesOf({
78819
+ row,
78820
+ waiting,
78821
+ nowMs: nowMs2
78822
+ }) {
78823
+ if (waiting === "refused") return [revokedKeyLineOf({ profile: row.profile })];
78824
+ const next = nextStepOf({ ...row, waiting });
78825
+ return [`${row.line}${inLazeOf({ row, waiting, nowMs: nowMs2 })}`, ...next ? [` next: ${next}`] : []];
78826
+ }
78827
+ function rushDelivers({ row, serviceRuns }) {
78828
+ if (row.standing === "stopped") return false;
78829
+ if (row.waiterPid || row.listenerPid) return true;
78830
+ return serviceRuns && row.noted !== void 0;
78831
+ }
78832
+ function nextStepOf({
78833
+ profile,
78834
+ key,
78835
+ waiting,
78836
+ delivers,
78837
+ where
78838
+ }) {
78839
+ const bind = `\`laze agent bind --profile ${profile}\``;
78840
+ if (!waiting)
78841
+ return delivers ? void 0 : "Laze did not answer: run `laze connect status` again";
78842
+ if (boundAwayOf({ waiting, key })) {
78843
+ return `messages go to the session Laze binds it to; only its person moves it here, with ${bind} inside ${where}`;
78844
+ }
78845
+ if (delivers) return void 0;
78846
+ return `run ${bind} inside ${where}: its key works, and this keeps the agent in this session and starts its listener again`;
78847
+ }
78848
+ function rushLineOf({ row, serviceRuns }) {
78657
78849
  const head = `${row.profile} Claude Code in rush ${row.rushId} ${row.standing}`;
78658
78850
  if (row.standing === "awake" && row.waiterPid) {
78659
78851
  return `${head}, its Claude Code delivers (waiter pid ${row.waiterPid})`;
78660
78852
  }
78661
- if (row.standing === "awake") {
78853
+ if (row.standing === "awake" && serviceRuns && row.noted) {
78662
78854
  return `${head}, no hook waiter right now: the connect service hands over what waits over ${UNDELIVERED_AFTER_MS / 1e3}s`;
78663
78855
  }
78856
+ if (row.standing === "awake") {
78857
+ const why = serviceRuns ? "no hook has noted this session" : "the connect service does not run";
78858
+ return `${head}, NO LISTENER: no hook waiter, and ${why}, so messages wait in Laze`;
78859
+ }
78664
78860
  if (row.standing === "stopped") return `${head}, gets messages when rush starts it again`;
78665
78861
  if (row.listenerPid) return `${head}, guard pid ${row.listenerPid}`;
78666
78862
  return `${head}, NO LISTENER: messages wait in Laze; \`laze connect install\` brings a guard back`;
78667
78863
  }
78864
+ async function plainSessionsOf({
78865
+ context,
78866
+ skip
78867
+ }) {
78868
+ const config2 = await context.store.read();
78869
+ const { notes } = await sessionNotesOf({ context, tell: false });
78870
+ const rows = [];
78871
+ for (const [key, profile] of Object.entries(config2.sessions ?? {})) {
78872
+ const entry2 = config2.profiles[profile];
78873
+ if (!key.startsWith("claude-code:") || skip.has(key) || !entry2 || entry2.migrated) continue;
78874
+ const sessionId = key.slice("claude-code:".length);
78875
+ const running = notes.find(
78876
+ (each) => each.note.sessionId === sessionId && each.standing === "live"
78877
+ );
78878
+ const waiter = await readJson({
78879
+ path: statePathOf({ context, kind: "waiters", profile })
78880
+ });
78881
+ const waiterPid = waiter?.sessionId === sessionId && context.processes.alive(waiter.pid) ? waiter.pid : void 0;
78882
+ rows.push({
78883
+ profile,
78884
+ key,
78885
+ sessionId,
78886
+ ...running ? { claudePid: running.pid } : {},
78887
+ ...waiterPid ? { waiterPid } : {}
78888
+ });
78889
+ }
78890
+ return rows;
78891
+ }
78892
+ function plainLineOf({ row }) {
78893
+ const head = `${row.profile} Claude Code session ${row.sessionId}`;
78894
+ if (row.waiterPid) return `${head} its Claude Code delivers (waiter pid ${row.waiterPid})`;
78895
+ if (row.claudePid) return `${head} Claude Code pid ${row.claudePid} runs it, NO LISTENER`;
78896
+ return `${head} not running: messages wait in Laze until it runs again`;
78897
+ }
78668
78898
  function inLazeOf({
78669
78899
  row,
78670
78900
  waiting,
78671
78901
  nowMs: nowMs2
78672
78902
  }) {
78673
- if (!waiting) return "; Laze could not say what waits";
78903
+ if (!waiting) return "; Laze did not answer, so its key and binding are unknown";
78674
78904
  const away = boundAwayOf({ waiting, key: row.key });
78675
- const bound = away ? `; Laze binds the agent to ${away}, not this session` : "";
78905
+ const bound = away ? `; key works; Laze binds the agent to ${away}, not this session` : `; key works, bound ${waiting.session ? "here" : "to no session"} in Laze`;
78676
78906
  const waited = waitedMsOf({ waiting, nowMs: nowMs2 });
78677
78907
  if (waiting.count === 0) return bound;
78678
78908
  const age = `the oldest for ${Math.round(waited / 1e3)}s`;
@@ -78871,8 +79101,8 @@ async function waitForMessages({ context, args }) {
78871
79101
  const claudePid = await claudePidOf({ context });
78872
79102
  const named = await pluginHookArgs({ context, args, session, claudePid, source: input2.source });
78873
79103
  if (!named) return 0;
78874
- const { client, name: name3 } = await signedIn({ context, args: named });
78875
79104
  await rememberSession({ context, claudePid, session });
79105
+ const { client, name: name3 } = await signedIn({ context, args: named });
78876
79106
  const rush = claudePid ? await rushAboveOf({ context, from: claudePid }) : void 0;
78877
79107
  if (rush) await startRushGuard({ context, profile: name3, claudePid, rush });
78878
79108
  if (rush) await healRushDelivery({ context });
@@ -78940,7 +79170,7 @@ async function refusedOnce({
78940
79170
  }
78941
79171
  await writeStateText({ path, text: String(context.nowMs()) });
78942
79172
  context.err(
78943
- `Laze: Laze refused this agent's key (${String(error63)}), so messages no longer reach this session. Link it again: laze agent link.
79173
+ `Laze: Laze refused this agent's key (${String(error63)}), so messages no longer reach this session. ${revokedKeyLineOf({ profile })}
78944
79174
  `
78945
79175
  );
78946
79176
  return 2;
@@ -81913,23 +82143,27 @@ async function bindAgentSession({
81913
82143
  if (!target) throw new CliUsageError(NO_AGENT);
81914
82144
  const named = { ...args, flags: { ...args.flags, profile: target } };
81915
82145
  const { client, name: name3, profile } = await signedIn({ context, args: named });
82146
+ const before = await client.get("/api/agents/me/inbox/waiting").catch(() => void 0);
82147
+ const already = before?.session ? `${before.session.harness}:${before.session.sessionId}` === key : false;
81916
82148
  await forSession({ client, session }).post("/api/agents/me/bind", {});
81917
82149
  await context.store.bindSession({ session: key, profile: name3 });
81918
82150
  const where = `profile ${name3}, config ${context.environment.configPath}`;
81919
82151
  const from = own2 && own2 !== name3 ? ` It moved from "${config2.profiles[own2]?.name}".` : "";
81920
82152
  const listener = await listenerOfBound({ context, args, name: name3, harness: session.harness });
81921
82153
  if (listener !== "none") {
81922
- context.out(`"${profile.name}" now listens in this session (${where}).${from}
81923
- `);
82154
+ context.out(
82155
+ already ? `"${profile.name}" already listens in this session (${where}); its listener runs again.
82156
+ ` : `"${profile.name}" now listens in this session (${where}).${from}
82157
+ `
82158
+ );
81924
82159
  return;
81925
82160
  }
81926
82161
  const { command: laze } = await rerunCommandOf({ context });
81927
82162
  const lines2 = noListenerLinesOf({ laze, profile: name3 });
81928
- context.out(
81929
- `"${profile.name}" is bound to this session (${where}).${from}
82163
+ const head = already ? `"${profile.name}" already listens in this session (${where}).` : `"${profile.name}" is bound to this session (${where}).${from}`;
82164
+ context.out(`${head}
81930
82165
  ${lines2.join("\n")}
81931
- `
81932
- );
82166
+ `);
81933
82167
  }
81934
82168
  async function listenerOfBound({
81935
82169
  context,
@@ -84976,6 +85210,40 @@ function loginValuesOf({
84976
85210
  return username ? { username, password } : { password };
84977
85211
  }
84978
85212
 
85213
+ // src/services/patient-poll.service.ts
85214
+ var BACKOFF_MS = [1e3, 2e3, 4e3, 8e3, 15e3, 3e4];
85215
+ var PROXY_STATUSES = /* @__PURE__ */ new Set([502, 503, 504]);
85216
+ function transientFailure(error63) {
85217
+ if (error63 instanceof LazeApiError) {
85218
+ return PROXY_STATUSES.has(error63.status) ? `status ${error63.status} ${error63.code}` : void 0;
85219
+ }
85220
+ if (error63 instanceof TypeError) return error63.message;
85221
+ const code4 = error63?.code;
85222
+ return typeof code4 === "string" && /^(E[A-Z]+|UND_ERR_[A-Z_]+)$/.test(code4) ? code4 : void 0;
85223
+ }
85224
+ async function patiently({
85225
+ context,
85226
+ call,
85227
+ giveUpAt = Infinity
85228
+ }) {
85229
+ for (let attempt = 0; ; attempt += 1) {
85230
+ try {
85231
+ return await call();
85232
+ } catch (error63) {
85233
+ const why = transientFailure(error63);
85234
+ if (why === void 0 || context.nowMs() >= giveUpAt) throw error63;
85235
+ if (attempt === 0) {
85236
+ context.err(
85237
+ `laze: Laze is not answering (${why}), probably restarting; still waiting...
85238
+ `
85239
+ );
85240
+ }
85241
+ const wait = BACKOFF_MS[Math.min(attempt, BACKOFF_MS.length - 1)] ?? 0;
85242
+ await context.sleep(Math.max(0, Math.min(wait, giveUpAt - context.nowMs())));
85243
+ }
85244
+ }
85245
+ }
85246
+
84979
85247
  // src/services/vault-commands.service.ts
84980
85248
  import { createHash as createHash8 } from "node:crypto";
84981
85249
  import { readFile as readFile15, rm as rm11 } from "node:fs/promises";
@@ -85015,7 +85283,7 @@ as the calling Claude Code, Codex, Kanban or terminal session.
85015
85283
  --channel <id> the conversation whose turn it runs in, when the agent answers in several
85016
85284
  --as <name> the session's name on the card when signed in as yourself (or LAZE_SESSION_NAME)`;
85017
85285
  var POLL_MS = 3e3;
85018
- var RESTART_WAIT_MS = 12e4;
85286
+ var RESTART_WAIT_MS = 6e5;
85019
85287
  var RESTART_BACKOFF_MS = [1e3, 2e3, 4e3, 8e3, 1e4];
85020
85288
  var P2562 = { name: "ECDH", namedCurve: "P-256" };
85021
85289
  var ServerGoneError = class extends Error {
@@ -85090,7 +85358,9 @@ async function sendOnce({
85090
85358
  if (init.method === "POST" && !wasRefused) throw error63;
85091
85359
  return { restarting: wasRefused ? "connection refused" : String(error63) };
85092
85360
  }
85093
- if (response.status !== 502 && response.status !== 503) return { response };
85361
+ if (response.status !== 502 && response.status !== 503 && response.status !== 504) {
85362
+ return { response };
85363
+ }
85094
85364
  const code4 = codeOf(await response.clone().text());
85095
85365
  const neverReached = response.status === 503 && code4 === "vault_not_answering";
85096
85366
  if (init.method === "POST" && !neverReached) return { response };
@@ -85109,7 +85379,7 @@ async function reach(input2) {
85109
85379
  }
85110
85380
  if (attempt === 0) {
85111
85381
  context.err(
85112
- `laze vault: the Laze server is not answering (${sent.restarting}), probably restarting; waiting up to 2 min...
85382
+ `laze vault: the Laze server is not answering (${sent.restarting}), probably restarting; waiting up to 10 min...
85113
85383
  `
85114
85384
  );
85115
85385
  }
@@ -85294,7 +85564,11 @@ async function keyRelease({
85294
85564
  extra: { channelId: flagText({ args, name: "channel" }) || null }
85295
85565
  };
85296
85566
  const first = await client.post(door.ask, { ...body, ...door.extra }).catch(refusedRelease);
85297
- const next = (requestId) => client.post(door.status, { requestId, ...door.extra }).catch(refusedRelease);
85567
+ const next = (requestId) => patiently({
85568
+ context,
85569
+ giveUpAt: deadline,
85570
+ call: () => client.post(door.status, { requestId, ...door.extra })
85571
+ }).catch(refusedRelease);
85298
85572
  const release2 = await untilAnswered({ context, first, next, deadline });
85299
85573
  return settled2({ context, release: release2, run: run4, keyPath });
85300
85574
  }
@@ -85522,7 +85796,11 @@ async function waitForDone({
85522
85796
  const deadline = context.nowMs() + seconds * 1e3;
85523
85797
  while (context.nowMs() < deadline) {
85524
85798
  await context.sleep(Math.min(ASK_POLL_MS, Math.max(0, deadline - context.nowMs())));
85525
- const now = await client.post(BROWSER_TAB_PATHS.get, { tab: tab.id, ...channel });
85799
+ const now = await patiently({
85800
+ context,
85801
+ giveUpAt: deadline,
85802
+ call: () => client.post(BROWSER_TAB_PATHS.get, { tab: tab.id, ...channel })
85803
+ });
85526
85804
  if (!now.ask) return print9(now, `${who} pressed Done. ${now.title} shows ${now.url}
85527
85805
  `);
85528
85806
  }
@@ -86307,6 +86585,21 @@ async function serveAppFolder({
86307
86585
  })
86308
86586
  };
86309
86587
  }
86588
+ function followingKey({
86589
+ client,
86590
+ reopen
86591
+ }) {
86592
+ let current3 = client;
86593
+ return async (call) => {
86594
+ try {
86595
+ return await call(current3);
86596
+ } catch (error63) {
86597
+ if (!(error63 instanceof LazeApiError) || error63.status !== 401) throw error63;
86598
+ current3 = await reopen();
86599
+ return call(current3);
86600
+ }
86601
+ };
86602
+ }
86310
86603
 
86311
86604
  // src/services/app-trigger-commands.service.ts
86312
86605
  var USAGE6 = `Usage:
@@ -86785,12 +87078,13 @@ var appServe = async ({ context, args }) => {
86785
87078
  throw new CliUsageError("--port must be a port number");
86786
87079
  }
86787
87080
  const origin = live.url.replace(/\/+$/, "");
87081
+ const withKey = followingKey({ client, reopen: () => appClient({ context, args }) });
86788
87082
  const served = await serveAppFolder({
86789
87083
  folder,
86790
87084
  port,
86791
87085
  backend: {
86792
- collections: () => client.post("/api/apps/collections", { appId }),
86793
- records: (input2) => client.post("/api/apps/records", { appId, ...input2 }),
87086
+ collections: () => withKey((now) => now.post("/api/apps/collections", { appId })),
87087
+ records: (input2) => withKey((now) => now.post("/api/apps/records", { appId, ...input2 })),
86794
87088
  platformFile: async (path) => {
86795
87089
  const answer6 = await context.fetcher(`${origin}${path}`);
86796
87090
  return {
@@ -90127,6 +90421,8 @@ var browserTabDefinition = external_exports.object({
90127
90421
  createdAt: external_exports.iso.datetime(),
90128
90422
  /** Only on an open: an open tab of that title was reused instead of making a second one. */
90129
90423
  reused: external_exports.boolean().optional(),
90424
+ /** Only on a read: the site the owner's dedicated IP last failed to reach, lately. */
90425
+ routeFailure: external_exports.object({ host: external_exports.string().min(1), at: external_exports.iso.datetime() }).nullable().optional(),
90130
90426
  /** What the reader may do: see the screen, type into it, change the tab; asked: the open
90131
90427
  * request names them. */
90132
90428
  you: external_exports.object({
@@ -90165,6 +90461,12 @@ var gotoDefinition = external_exports.object({
90165
90461
  url: external_exports.string().trim().min(1).max(4096)
90166
90462
  });
90167
90463
  var browserTabGotoInputSchema = gotoDefinition;
90464
+ var browserTabStepSchema = external_exports.enum(["back", "forward", "reload"]);
90465
+ var stepDefinition = external_exports.object({
90466
+ ...browserTabRefDefinition.shape,
90467
+ step: browserTabStepSchema
90468
+ });
90469
+ var browserTabStepInputSchema = stepDefinition;
90168
90470
  var askDefinition = external_exports.object({
90169
90471
  ...browserTabRefDefinition.shape,
90170
90472
  text: external_exports.string().trim().min(1).max(500)
@@ -92062,6 +92364,39 @@ var agentHostGrantDefinition = external_exports.object({
92062
92364
  expiresAt: external_exports.iso.datetime()
92063
92365
  });
92064
92366
 
92367
+ // ../../modules/compute/contract/src/whatsapp-history.ts
92368
+ var WHATSAPP_HISTORY_PATH = "/api/compute/whatsapp/history";
92369
+ var historyInputDefinition = external_exports.object({
92370
+ workspaceId: external_exports.string().min(1).max(64),
92371
+ /** The Laze conversation that mirrors the chat. */
92372
+ channelId: external_exports.string().min(1).max(64),
92373
+ /** The page holds messages written before this time. */
92374
+ before: external_exports.iso.datetime({ offset: true })
92375
+ });
92376
+ var whatsappHistoryInputSchema = historyInputDefinition;
92377
+ var historyByKeyInputDefinition = historyInputDefinition.omit({ workspaceId: true });
92378
+ var historyMessageDefinition = external_exports.object({
92379
+ /** The same key a cached copy of the message carries. */
92380
+ key: external_exports.string().min(1),
92381
+ createdAt: external_exports.iso.datetime(),
92382
+ authorName: external_exports.string(),
92383
+ authorAvatarUrl: external_exports.null(),
92384
+ /** The owner, for their own messages; else null. */
92385
+ authorUserId: external_exports.string().nullable(),
92386
+ /** The chat's outside author id, as the cached copies carry it; null for the owner. */
92387
+ authorExternalId: external_exports.string().nullable(),
92388
+ /** Laze markdown; a file is named, and opens on the phone. */
92389
+ body: external_exports.string(),
92390
+ replyCount: external_exports.literal(0),
92391
+ files: external_exports.array(external_exports.never())
92392
+ });
92393
+ var historyPageDefinition = external_exports.object({
92394
+ /** Oldest first. */
92395
+ messages: external_exports.array(historyMessageDefinition),
92396
+ hasOlder: external_exports.boolean()
92397
+ });
92398
+ var whatsappHistoryPageSchema = historyPageDefinition;
92399
+
92065
92400
  // ../../modules/compute/contract/src/compute.ts
92066
92401
  var idSchema26 = external_exports.string().min(1).max(64);
92067
92402
  var workspaceIdSchema23 = external_exports.string().min(1).max(64);
@@ -92257,10 +92592,12 @@ var ownMachineSshConnectDefinition = external_exports.object({
92257
92592
  var ownMachineSshConnectSchema = ownMachineSshConnectDefinition;
92258
92593
  var reconcileDefinition = external_exports.object({ workspaceId: workspaceIdSchema23, machineId: idSchema26 });
92259
92594
  var ComputeApi = moduleApi()("compute");
92260
- var computeCoreTrpc = defineTrpcContract("compute").query("status").withInput(computeWorkspaceInputSchema).withOutput(computeStatusSchema).query("browserTabs").withInput(browserTabListInputSchema).withOutput(browserTabListSchema).query("browserTab").withInput(browserTabInputSchema).withOutput(browserTabSchema).mutation("openBrowserTab").withInput(openBrowserTabInputSchema).withOutput(browserTabSchema).mutation("browserTabScreen").withInput(browserTabInputSchema).withOutput(browserTabScreenSchema).mutation("sizeBrowserTabScreen").withInput(browserTabScreenSizeInputSchema).withOutput(browserTabScreenSizeSchema).mutation("gotoBrowserTab").withInput(browserTabGotoInputSchema).withOutput(browserTabPageSchema).mutation("doneOnBrowserTab").withInput(browserTabInputSchema).withOutput(browserTabSchema).mutation("shareBrowserTab").withInput(browserTabShareInputSchema).withOutput(browserTabSchema).mutation("closeBrowserTab").withInput(browserTabInputSchema).withOutput(external_exports.object({ closed: external_exports.literal(true) })).query("computer").withInput(computeWorkspaceInputSchema).withOutput(computerStatusSchema).mutation("setComputerSize").withInput(setComputerSizeInputSchema).withOutput(computerSizeAnswerSchema).mutation("requestComputerSize").withInput(setComputerSizeInputSchema).withOutput(computerRequestSchema).mutation("cancelComputerRequest").withInput(computerRequestRefSchema).withOutput(computerRequestSchema).mutation("restartComputer").withInput(restartComputerInputSchema).withOutput(computerRestartAnswerSchema).query("computers").withInput(computeWorkspaceInputSchema).withOutput(computerListSchema).query("dedicatedIp").withInput(computeWorkspaceInputSchema).withOutput(dedicatedIpStatusSchema).mutation("setDedicatedIp").withInput(setDedicatedIpInputSchema).withOutput(dedicatedIpAnswerSchema).mutation("turnOffDedicatedIp").withInput(computeWorkspaceInputSchema).withOutput(dedicatedIpAnswerSchema).mutation("setDedicatedIpDomains").withInput(setDedicatedIpDomainsInputSchema).withOutput(dedicatedIpAnswerSchema).query("dedicatedIps").withInput(computeWorkspaceInputSchema).withOutput(dedicatedIpListSchema).query("dedicatedIpCountries").withInput(computeWorkspaceInputSchema).withOutput(dedicatedIpCountriesSchema).query("dedicatedIpOffer").withInput(dedicatedIpOfferInputSchema).withOutput(dedicatedIpOfferSchema).query("list").withInput(computeWorkspaceInputSchema).withOutput(external_exports.array(machineSchema)).query("get").withInput(machineRefSchema).withOutput(machineSchema).mutation("setupBrowser").withInput(setupBrowserInputSchema).withOutput(machineSchema).mutation("sleep").withInput(machineRefSchema).withOutput(machineSchema).mutation("wake").withInput(machineRefSchema).withOutput(machineSchema).mutation("delete").withInput(machineRefSchema).withOutput(machineSchema).mutation("rename").withInput(renameMachineInputSchema).withOutput(machineSchema).mutation("grant").withInput(machineGrantInputSchema).withOutput(machineSchema).mutation("revokeGrant").withInput(machineGrantInputSchema).withOutput(machineSchema).mutation("setBudget").withInput(setMachineBudgetInputSchema).withOutput(machineSchema).mutation("openScreen").withInput(openScreenInputSchema).withOutput(screenSessionSchema).mutation("openLoginTerminal").withInput(openLoginTerminalInputSchema).withOutput(loginTerminalSchema).mutation("finishScreen").withInput(screenRefSchema).withOutput(machineSchema).mutation("connectOwn").withInput(connectOwnMachineInputSchema).withOutput(ownMachineConnectSchema).mutation("newConnectCommand").withInput(machineRefSchema).withOutput(ownMachineConnectSchema).mutation("connectSsh").withInput(connectSshMachineInputSchema).withOutput(ownMachineSshConnectSchema).mutation("trustHostKey").withInput(trustHostKeyInputSchema).withOutput(machineSchema).mutation("checkHealth").withInput(machineRefSchema).withOutput(machineSchema).mutation("hostAgent").withInput(hostAgentInputSchema).withOutput(machineSchema).mutation("unhostAgent").withInput(unhostAgentInputSchema).withOutput(external_exports.object({ agentId: external_exports.string() })).mutation("pairWhatsapp").withInput(whatsappPairInputSchema).withOutput(whatsappPairingSchema).query("whatsappMirror").withInput(machineRefSchema).withOutput(whatsappMirrorSettingsSchema).mutation("setWhatsappMirror").withInput(setWhatsappMirrorInputSchema).withOutput(whatsappMirrorSettingsSchema).query("whatsappPairing").withInput(whatsappPairingRefSchema).withOutput(whatsappPairingSchema).mutation("cancelWhatsappPairing").withInput(whatsappPairingRefSchema).withOutput(whatsappPairingSchema).mutation("unpairWhatsapp").withInput(machineRefSchema).withOutput(machineSchema).build();
92261
- var computeFleetTrpc = defineTrpcContract("compute").query("whatsappComputer").withInput(whatsappComputerInputSchema).withOutput(whatsappComputerSchema).mutation("prepareWhatsappComputer").withInput(whatsappComputerInputSchema).withOutput(whatsappComputerSchema).mutation("warmComputer").withInput(computeWorkspaceInputSchema).withOutput(warmComputerSchema).query("myComputers").withInput(computeWorkspaceInputSchema).withOutput(myComputersSchema).query("personComputer").withInput(personComputerInputSchema).withOutput(computerUseSchema2).mutation("createComputer").withInput(createComputerInputSchema).withOutput(computerStatusSchema).mutation("deleteComputer").withInput(deleteComputerInputSchema).withOutput(deleteComputerAnswerSchema).mutation("setComputerCreators").withInput(setComputerCreatorsInputSchema).withOutput(computerStatusSchema).mutation("setAgentComputer").withInput(setAgentComputerInputSchema).withOutput(agentComputerAnswerSchema).query("whatsappAgents").withInput(machineRefSchema).withOutput(whatsappAgentsSchema).mutation("setWhatsappAgent").withInput(setWhatsappAgentInputSchema).withOutput(whatsappAgentsSchema).mutation("setWhatsappAgentLease").withInput(setWhatsappAgentLeaseInputSchema).withOutput(whatsappAgentsSchema).mutation("setWhatsappEveryAgent").withInput(setWhatsappEveryAgentInputSchema).withOutput(whatsappAgentsSchema).mutation("setWhatsappAgentAccess").withInput(setWhatsappAgentAccessInputSchema).withOutput(whatsappAgentsSchema).mutation("checkWhatsappNow").withInput(machineRefSchema).withOutput(whatsappMirrorSettingsSchema).query("whatsappChatPeople").withInput(whatsappChatPeopleInputSchema).withOutput(whatsappChatPeopleSchema).mutation("watchWhatsappChat").withInput(whatsappWatchInputSchema).withOutput(whatsappWatchSchema).mutation("checkWhatsappReply").withInput(whatsappReplyCheckInputSchema).withOutput(whatsappReplyCheckSchema).build();
92595
+ var computeBrowserTabTrpc = defineTrpcContract("compute").query("browserTabs").withInput(browserTabListInputSchema).withOutput(browserTabListSchema).query("browserTab").withInput(browserTabInputSchema).withOutput(browserTabSchema).mutation("openBrowserTab").withInput(openBrowserTabInputSchema).withOutput(browserTabSchema).mutation("browserTabScreen").withInput(browserTabInputSchema).withOutput(browserTabScreenSchema).mutation("sizeBrowserTabScreen").withInput(browserTabScreenSizeInputSchema).withOutput(browserTabScreenSizeSchema).mutation("gotoBrowserTab").withInput(browserTabGotoInputSchema).withOutput(browserTabPageSchema).mutation("stepBrowserTab").withInput(browserTabStepInputSchema).withOutput(browserTabPageSchema).mutation("doneOnBrowserTab").withInput(browserTabInputSchema).withOutput(browserTabSchema).mutation("shareBrowserTab").withInput(browserTabShareInputSchema).withOutput(browserTabSchema).mutation("closeBrowserTab").withInput(browserTabInputSchema).withOutput(external_exports.object({ closed: external_exports.literal(true) })).build();
92596
+ var computeCoreTrpc = defineTrpcContract("compute").query("status").withInput(computeWorkspaceInputSchema).withOutput(computeStatusSchema).query("computer").withInput(computeWorkspaceInputSchema).withOutput(computerStatusSchema).mutation("setComputerSize").withInput(setComputerSizeInputSchema).withOutput(computerSizeAnswerSchema).mutation("requestComputerSize").withInput(setComputerSizeInputSchema).withOutput(computerRequestSchema).mutation("cancelComputerRequest").withInput(computerRequestRefSchema).withOutput(computerRequestSchema).mutation("restartComputer").withInput(restartComputerInputSchema).withOutput(computerRestartAnswerSchema).query("computers").withInput(computeWorkspaceInputSchema).withOutput(computerListSchema).query("dedicatedIp").withInput(computeWorkspaceInputSchema).withOutput(dedicatedIpStatusSchema).mutation("setDedicatedIp").withInput(setDedicatedIpInputSchema).withOutput(dedicatedIpAnswerSchema).mutation("turnOffDedicatedIp").withInput(computeWorkspaceInputSchema).withOutput(dedicatedIpAnswerSchema).mutation("setDedicatedIpDomains").withInput(setDedicatedIpDomainsInputSchema).withOutput(dedicatedIpAnswerSchema).query("dedicatedIps").withInput(computeWorkspaceInputSchema).withOutput(dedicatedIpListSchema).query("dedicatedIpCountries").withInput(computeWorkspaceInputSchema).withOutput(dedicatedIpCountriesSchema).query("dedicatedIpOffer").withInput(dedicatedIpOfferInputSchema).withOutput(dedicatedIpOfferSchema).query("list").withInput(computeWorkspaceInputSchema).withOutput(external_exports.array(machineSchema)).query("get").withInput(machineRefSchema).withOutput(machineSchema).mutation("setupBrowser").withInput(setupBrowserInputSchema).withOutput(machineSchema).mutation("sleep").withInput(machineRefSchema).withOutput(machineSchema).mutation("wake").withInput(machineRefSchema).withOutput(machineSchema).mutation("delete").withInput(machineRefSchema).withOutput(machineSchema).mutation("rename").withInput(renameMachineInputSchema).withOutput(machineSchema).mutation("grant").withInput(machineGrantInputSchema).withOutput(machineSchema).mutation("revokeGrant").withInput(machineGrantInputSchema).withOutput(machineSchema).mutation("setBudget").withInput(setMachineBudgetInputSchema).withOutput(machineSchema).mutation("openScreen").withInput(openScreenInputSchema).withOutput(screenSessionSchema).mutation("openLoginTerminal").withInput(openLoginTerminalInputSchema).withOutput(loginTerminalSchema).mutation("finishScreen").withInput(screenRefSchema).withOutput(machineSchema).mutation("connectOwn").withInput(connectOwnMachineInputSchema).withOutput(ownMachineConnectSchema).mutation("newConnectCommand").withInput(machineRefSchema).withOutput(ownMachineConnectSchema).mutation("connectSsh").withInput(connectSshMachineInputSchema).withOutput(ownMachineSshConnectSchema).mutation("trustHostKey").withInput(trustHostKeyInputSchema).withOutput(machineSchema).mutation("checkHealth").withInput(machineRefSchema).withOutput(machineSchema).mutation("hostAgent").withInput(hostAgentInputSchema).withOutput(machineSchema).mutation("unhostAgent").withInput(unhostAgentInputSchema).withOutput(external_exports.object({ agentId: external_exports.string() })).mutation("pairWhatsapp").withInput(whatsappPairInputSchema).withOutput(whatsappPairingSchema).query("whatsappMirror").withInput(machineRefSchema).withOutput(whatsappMirrorSettingsSchema).mutation("setWhatsappMirror").withInput(setWhatsappMirrorInputSchema).withOutput(whatsappMirrorSettingsSchema).query("whatsappPairing").withInput(whatsappPairingRefSchema).withOutput(whatsappPairingSchema).mutation("cancelWhatsappPairing").withInput(whatsappPairingRefSchema).withOutput(whatsappPairingSchema).mutation("unpairWhatsapp").withInput(machineRefSchema).withOutput(machineSchema).build();
92597
+ var computeFleetTrpc = defineTrpcContract("compute").query("whatsappComputer").withInput(whatsappComputerInputSchema).withOutput(whatsappComputerSchema).mutation("prepareWhatsappComputer").withInput(whatsappComputerInputSchema).withOutput(whatsappComputerSchema).mutation("warmComputer").withInput(computeWorkspaceInputSchema).withOutput(warmComputerSchema).query("myComputers").withInput(computeWorkspaceInputSchema).withOutput(myComputersSchema).query("personComputer").withInput(personComputerInputSchema).withOutput(computerUseSchema2).mutation("createComputer").withInput(createComputerInputSchema).withOutput(computerStatusSchema).mutation("deleteComputer").withInput(deleteComputerInputSchema).withOutput(deleteComputerAnswerSchema).mutation("setComputerCreators").withInput(setComputerCreatorsInputSchema).withOutput(computerStatusSchema).mutation("setAgentComputer").withInput(setAgentComputerInputSchema).withOutput(agentComputerAnswerSchema).query("whatsappAgents").withInput(machineRefSchema).withOutput(whatsappAgentsSchema).mutation("setWhatsappAgent").withInput(setWhatsappAgentInputSchema).withOutput(whatsappAgentsSchema).mutation("setWhatsappAgentLease").withInput(setWhatsappAgentLeaseInputSchema).withOutput(whatsappAgentsSchema).mutation("setWhatsappEveryAgent").withInput(setWhatsappEveryAgentInputSchema).withOutput(whatsappAgentsSchema).mutation("setWhatsappAgentAccess").withInput(setWhatsappAgentAccessInputSchema).withOutput(whatsappAgentsSchema).mutation("checkWhatsappNow").withInput(machineRefSchema).withOutput(whatsappMirrorSettingsSchema).query("whatsappChatPeople").withInput(whatsappChatPeopleInputSchema).withOutput(whatsappChatPeopleSchema).query("whatsappHistory").withInput(whatsappHistoryInputSchema).withOutput(whatsappHistoryPageSchema).mutation("watchWhatsappChat").withInput(whatsappWatchInputSchema).withOutput(whatsappWatchSchema).mutation("checkWhatsappReply").withInput(whatsappReplyCheckInputSchema).withOutput(whatsappReplyCheckSchema).build();
92262
92598
  var computeTrpc = joinTrpcContracts(
92263
92599
  "compute",
92600
+ computeBrowserTabTrpc,
92264
92601
  computeCoreTrpc,
92265
92602
  computeFleetTrpc,
92266
92603
  computeWaitlistTrpc
@@ -92768,7 +93105,23 @@ var whatsappMirrorHealthDefinition = external_exports.object({
92768
93105
  failureCode: external_exports.string().nullable()
92769
93106
  }).nullable(),
92770
93107
  /** Intake holds (ADR-216 §11) by kind and code, with when the oldest was made. */
92771
- holds: external_exports.array(external_exports.object({ kind: external_exports.string(), code: external_exports.string(), count: count11, oldestAt: at4 }))
93108
+ holds: external_exports.array(external_exports.object({ kind: external_exports.string(), code: external_exports.string(), count: count11, oldestAt: at4 })),
93109
+ /**
93110
+ * The computer store's fill (ADR-223): chats done, how many mirrored items from the last 6
93111
+ * months Laze held, those the store held and those sent; the mirrored items Laze holds now
93112
+ * and how many a trim to 7 days after last read would delete. Null before a fill started.
93113
+ */
93114
+ storeFill: external_exports.object({
93115
+ chats: count11,
93116
+ lazeHeld: count11,
93117
+ alreadyHeld: count11,
93118
+ sent: count11,
93119
+ problem: external_exports.string().nullable(),
93120
+ filledAt: at4.nullable(),
93121
+ updatedAt: at4,
93122
+ mirrored: count11,
93123
+ trimmable: count11
93124
+ }).nullable().optional()
92772
93125
  })
92773
93126
  )
92774
93127
  });
@@ -92933,7 +93286,18 @@ var computerBrowserFactsDefinition = external_exports.object({
92933
93286
  openTabs: external_exports.number().int().nonnegative(),
92934
93287
  streamsNow: external_exports.number().int().nonnegative(),
92935
93288
  /** Since this api process started, newest last, at most 60. */
92936
- events: external_exports.array(relayEventDefinition).max(60)
93289
+ events: external_exports.array(relayEventDefinition).max(60),
93290
+ /**
93291
+ * Where the browser's traffic leaves: the person's dedicated IP and whether the computer's
93292
+ * browser joins it (only a route for all traffic does), else the shared address.
93293
+ */
93294
+ egress: external_exports.object({
93295
+ dedicatedIp: external_exports.enum(["none", "off", "pending", "on"]),
93296
+ scope: dedicatedIpScopeSchema.nullable(),
93297
+ countryCode: external_exports.string().max(8).nullable(),
93298
+ onSince: at5.nullable(),
93299
+ browserLeaves: external_exports.enum(["dedicated_ip", "shared_address"])
93300
+ })
92937
93301
  });
92938
93302
  var computerBrowserFactsSchema = computerBrowserFactsDefinition;
92939
93303
 
@@ -93769,11 +94133,11 @@ async function suggestServer({
93769
94133
  }
93770
94134
 
93771
94135
  // src/services/connector-commands.service.ts
93772
- import { readFile as readFile23 } from "node:fs/promises";
94136
+ import { readFile as readFile24 } from "node:fs/promises";
93773
94137
  import { resolve as resolve14 } from "node:path";
93774
94138
 
93775
94139
  // src/services/vault-keychain-commands.service.ts
93776
- import { readFile as readFile22 } from "node:fs/promises";
94140
+ import { readFile as readFile23 } from "node:fs/promises";
93777
94141
 
93778
94142
  // src/rules/vault-input.rules.ts
93779
94143
  function secondsOf(text3) {
@@ -94066,6 +94430,273 @@ var listDevices = async ({ context, args }) => {
94066
94430
  }
94067
94431
  };
94068
94432
 
94433
+ // src/services/vault-batch.service.ts
94434
+ import { readFile as readFile22, rm as rm16 } from "node:fs/promises";
94435
+ async function placeholdersOf({
94436
+ env
94437
+ }) {
94438
+ const path = env.LAZE_VAULT_PLACEHOLDERS;
94439
+ if (!path || !proxyOf({ env })) return {};
94440
+ try {
94441
+ const parsed = JSON.parse(await readFile22(path, "utf8"));
94442
+ return parsed && typeof parsed === "object" ? parsed : {};
94443
+ } catch {
94444
+ return {};
94445
+ }
94446
+ }
94447
+ async function batchOf({ response }) {
94448
+ const text3 = await response.text();
94449
+ if (!response.ok) {
94450
+ const code4 = /"code"\s*:\s*"([^"]+)"/.exec(text3)?.[1] ?? `status ${response.status}`;
94451
+ throw new CliUsageError(`laze vault: the batch was refused (${code4})`);
94452
+ }
94453
+ return JSON.parse(text3);
94454
+ }
94455
+ async function doorOf({
94456
+ context,
94457
+ args,
94458
+ keyName
94459
+ }) {
94460
+ const env = context.environment.inherited;
94461
+ const proxy = proxyOf({ env });
94462
+ if (proxy) {
94463
+ const turnFile = turnFileOf({ env });
94464
+ const headers = {
94465
+ "proxy-authorization": proxy.authorization,
94466
+ "x-laze-turn": await turnTokenOf2({ env, turnFile, command: "laze vault env" })
94467
+ };
94468
+ return {
94469
+ keyPath: runKeyPathOf({ turnFile, connection: keyName }),
94470
+ ask: async (body) => batchOf({
94471
+ response: await reach({
94472
+ context,
94473
+ url: `${proxy.origin}/vault/release-batch`,
94474
+ init: {
94475
+ method: "POST",
94476
+ headers: { ...headers, "content-type": "application/json" },
94477
+ body: JSON.stringify(body)
94478
+ }
94479
+ })
94480
+ }),
94481
+ status: async (requestId) => releaseOf({
94482
+ response: await reach({
94483
+ context,
94484
+ url: `${proxy.origin}/vault/release/${encodeURIComponent(requestId)}`,
94485
+ init: { method: "GET", headers }
94486
+ })
94487
+ })
94488
+ };
94489
+ }
94490
+ const signed2 = await signedIn({ context, args }).catch(() => null);
94491
+ if (signed2?.profile.kind !== "agent" && signed2?.profile.kind !== "person") {
94492
+ throw new CliUsageError(`laze vault env ${WHERE}`);
94493
+ }
94494
+ const { name: name3 } = signed2;
94495
+ const harnessSession = await currentSessionOf({ context, args });
94496
+ const client = forSession({ client: signed2.client, session: harnessSession });
94497
+ const door = signed2.profile.kind === "person" ? {
94498
+ ask: "/api/vault/session/release-batch",
94499
+ status: "/api/vault/session/release-status",
94500
+ extra: { session: await vaultSessionFor({ context, args, harnessSession }) }
94501
+ } : {
94502
+ ask: "/api/agents/me/vault/release-batch",
94503
+ status: "/api/agents/me/vault/release-status",
94504
+ extra: { channelId: flagText({ args, name: "channel" }) || null }
94505
+ };
94506
+ return {
94507
+ keyPath: runKeyPathOf({ turnFile: void 0, connection: keyName, profile: name3 }),
94508
+ ask: async (body) => {
94509
+ try {
94510
+ return await client.post(door.ask, { ...body, ...door.extra });
94511
+ } catch (error63) {
94512
+ if (!(error63 instanceof LazeApiError)) throw error63;
94513
+ throw new CliUsageError(`laze vault: the batch was refused: ${refusalText(error63)}`);
94514
+ }
94515
+ },
94516
+ status: (requestId) => patiently({
94517
+ context,
94518
+ call: () => client.post(door.status, { requestId, ...door.extra })
94519
+ }).catch(refusedRelease)
94520
+ };
94521
+ }
94522
+ async function resolveBatch({
94523
+ context,
94524
+ args,
94525
+ refs
94526
+ }) {
94527
+ const door = await doorOf({ context, args, keyName: "env-names" });
94528
+ const answer6 = await door.ask({ refs, reason: "", command: [], resolveOnly: true });
94529
+ return answer6.entries;
94530
+ }
94531
+ var keyOf = (entry2) => entry2.connection?.name ?? entry2.ref;
94532
+ async function untilAllAnswered({
94533
+ context,
94534
+ door,
94535
+ waiting,
94536
+ deadline
94537
+ }) {
94538
+ const answered = /* @__PURE__ */ new Map();
94539
+ if (waiting.size === 0) return answered;
94540
+ const [first] = waiting.values();
94541
+ context.err(
94542
+ `laze vault: ${[...waiting.keys()].join(", ")} wait for an answer (${first?.message ?? "a card"}); cards expire after 24 hours...
94543
+ `
94544
+ );
94545
+ while (waiting.size > 0) {
94546
+ if (context.nowMs() + POLL_MS > deadline) {
94547
+ context.err(
94548
+ `laze vault: ${[...waiting.keys()].join(", ")} not approved yet; ask again later.
94549
+ `
94550
+ );
94551
+ return "capped";
94552
+ }
94553
+ await context.sleep(POLL_MS);
94554
+ for (const [key, pending2] of waiting) {
94555
+ const next = await door.status(pending2.requestId);
94556
+ if (next.outcome === "ask") waiting.set(key, next);
94557
+ else {
94558
+ waiting.delete(key);
94559
+ answered.set(key, next);
94560
+ }
94561
+ }
94562
+ }
94563
+ return answered;
94564
+ }
94565
+ async function releaseBatch({
94566
+ context,
94567
+ args,
94568
+ refs,
94569
+ reason: reason2,
94570
+ command
94571
+ }) {
94572
+ const deadline = deadlineOf({ args, nowMs: context.nowMs() });
94573
+ const door = await doorOf({ context, args, keyName: `env:${[...refs].toSorted().join(",")}` });
94574
+ const run4 = await runKeyAt({ path: door.keyPath });
94575
+ const placeholders = await placeholdersOf({ env: context.environment.inherited });
94576
+ let answer6;
94577
+ let settled3;
94578
+ try {
94579
+ answer6 = await door.ask({
94580
+ refs,
94581
+ reason: reason2,
94582
+ command,
94583
+ recipient: run4.publicKey,
94584
+ ...Object.keys(placeholders).length > 0 && { placeholders: true }
94585
+ });
94586
+ const missing = answer6.entries.filter((entry2) => !entry2.connection);
94587
+ if (missing.length > 0) {
94588
+ context.err(
94589
+ `laze vault: no key named ${missing.map((entry2) => entry2.ref).join(", ")} in your vault or reachable by this agent
94590
+ `
94591
+ );
94592
+ return { exitCode: 1 };
94593
+ }
94594
+ const sorted = sortedReleasesOf({ entries: answer6.entries });
94595
+ settled3 = sorted.settled;
94596
+ const { waiting } = sorted;
94597
+ const later = await untilAllAnswered({ context, door, waiting, deadline });
94598
+ if (later === "capped") return { exitCode: 75 };
94599
+ for (const [key, release2] of later) settled3.set(key, release2);
94600
+ } catch (error63) {
94601
+ if (!(error63 instanceof ServerGoneError)) throw error63;
94602
+ context.err(`${error63.message}. Run the command again to keep waiting.
94603
+ `);
94604
+ return { exitCode: 75 };
94605
+ }
94606
+ const swapped = swappedOf({ context, entries: answer6.entries, placeholders });
94607
+ if (!swapped) return { exitCode: 1 };
94608
+ const outcome = await valuesOf({
94609
+ context,
94610
+ entries: answer6.entries,
94611
+ settled: settled3,
94612
+ run: run4,
94613
+ keyPath: door.keyPath
94614
+ });
94615
+ if ("exitCode" in outcome) return outcome;
94616
+ for (const [ref2, fields] of swapped) outcome.released.set(ref2, { fields });
94617
+ return outcome;
94618
+ }
94619
+ function swappedOf({
94620
+ context,
94621
+ entries,
94622
+ placeholders
94623
+ }) {
94624
+ const swapped = /* @__PURE__ */ new Map();
94625
+ for (const entry2 of entries) {
94626
+ if (!entry2.boundary || !entry2.connection) continue;
94627
+ const held = placeholders[entry2.boundary.connectionId] ?? {};
94628
+ const fields = Object.fromEntries(
94629
+ entry2.connection.fieldNames.flatMap((field) => {
94630
+ const placeholder = held[field];
94631
+ return placeholder ? [[field, placeholder]] : [];
94632
+ })
94633
+ );
94634
+ if (Object.keys(fields).length === 0) {
94635
+ context.err(
94636
+ `laze vault: ${entry2.connection.name} is swapped by Laze's proxy, but this computer holds no placeholder for it yet; it gets one on its next start
94637
+ `
94638
+ );
94639
+ return null;
94640
+ }
94641
+ swapped.set(entry2.ref, fields);
94642
+ }
94643
+ return swapped;
94644
+ }
94645
+ function sortedReleasesOf({ entries }) {
94646
+ const settled3 = /* @__PURE__ */ new Map();
94647
+ const waiting = /* @__PURE__ */ new Map();
94648
+ for (const entry2 of entries) {
94649
+ const release2 = entry2.release;
94650
+ if (!release2) continue;
94651
+ if (release2.outcome === "ask") waiting.set(keyOf(entry2), release2);
94652
+ else settled3.set(keyOf(entry2), release2);
94653
+ }
94654
+ return { settled: settled3, waiting };
94655
+ }
94656
+ function refusalOf({
94657
+ context,
94658
+ settled: settled3
94659
+ }) {
94660
+ const codes = [];
94661
+ for (const release2 of settled3.values()) {
94662
+ if (release2.outcome !== "deny") continue;
94663
+ context.err(`${release2.message}
94664
+ `);
94665
+ codes.push(release2.exitCode || 1);
94666
+ }
94667
+ if (codes.length === 0) return 0;
94668
+ return codes.includes(77) ? 77 : codes[0] ?? 1;
94669
+ }
94670
+ async function valuesOf({
94671
+ context,
94672
+ entries,
94673
+ settled: settled3,
94674
+ run: run4,
94675
+ keyPath
94676
+ }) {
94677
+ const refused = refusalOf({ context, settled: settled3 });
94678
+ if (refused !== 0) {
94679
+ await rm16(keyPath, { force: true });
94680
+ return { exitCode: refused };
94681
+ }
94682
+ const opened = /* @__PURE__ */ new Map();
94683
+ let keep2 = false;
94684
+ for (const [key, release2] of settled3) {
94685
+ if (release2.outcome !== "allow") continue;
94686
+ opened.set(key, await envOf({ release: release2, run: run4 }));
94687
+ if (leaseHolds({ release: release2, nowMs: context.nowMs() })) keep2 = true;
94688
+ if (release2.message) context.err(`${release2.message}
94689
+ `);
94690
+ }
94691
+ if (!keep2) await rm16(keyPath, { force: true });
94692
+ const released = /* @__PURE__ */ new Map();
94693
+ for (const entry2 of entries) {
94694
+ const fields = opened.get(keyOf(entry2));
94695
+ if (fields) released.set(entry2.ref, { fields });
94696
+ }
94697
+ return { released, entries };
94698
+ }
94699
+
94069
94700
  // src/services/vault-share-commands.service.ts
94070
94701
  var SHARE_USAGE2 = "Usage: laze vault share <connection> --with <email|userId> [--for 1h]";
94071
94702
  var WAITING_LINE = "It waits for the owner's approval with a passkey or Face ID, in Settings > Vault.";
@@ -94129,14 +94760,14 @@ var VAULT_USAGE = `Usage (your own key; an agent's key lists and runs its owner'
94129
94760
  from an agent, its owner's keys it may use
94130
94761
  laze vault add <name> --label <text> [--keychain personal|workspace|agent:<id>]
94131
94762
  [--level allow|auto|always-ask|human-only] [--rules <text>] [--approver <userId>]...
94132
- [--lease 15m|1h|8h|1d|2d] [--every-use-asks] [--field <FIELD>] [--from-file <path>]
94763
+ [--lease 15m|1h|8h|1d|2d] [--every-use-asks] [--local-use] [--field <FIELD>] [--from-file <path>]
94133
94764
  levels as the page names them: allow (agents use it), auto (the automatic check reads
94134
94765
  each use against --rules), always-ask (a person approves), human-only (agents never do)
94135
94766
  --lease (or --max-lease) is how long an approval lasts for the agent, 2 days by default
94136
94767
  the value comes from stdin or --from-file, never a flag: KEY=value lines, one value
94137
94768
  with --field, or a JSON secret bundle ({"kind":"api_key_set","fields":{...}})
94138
94769
  laze vault update <connection> [--label] [--level] [--rules] [--approver]... [--lease 1h|none]
94139
- [--every-use-asks yes|no] [--device-approval]
94770
+ [--every-use-asks yes|no] [--local-use yes|no] [--device-approval]
94140
94771
  --device-approval: every Allow and lease needs Touch ID, a passkey or Face ID from then on;
94141
94772
  it is turned off only in Settings > Vault, on a device
94142
94773
  laze vault replace <connection> [--field <FIELD>] [--from-file <path>] a new value, from stdin
@@ -94194,9 +94825,16 @@ async function secretText({ context, args }) {
94194
94825
  );
94195
94826
  }
94196
94827
  const file4 = flagText({ args, name: "from-file" });
94197
- const text3 = file4 ? await readFile22(file4, "utf8") : await context.readStdin();
94828
+ const text3 = file4 ? await readFile23(file4, "utf8") : await context.readStdin();
94198
94829
  const trimmed = text3.replace(/\r?\n$/, "");
94199
94830
  if (!trimmed.trim()) throw new CliUsageError("No value: pipe it on stdin or use --from-file.");
94831
+ const held = await placeholdersOf({ env: context.environment.inherited });
94832
+ const field = Object.values(held).flatMap((fields) => Object.entries(fields)).find(([, placeholder]) => trimmed.includes(placeholder))?.[0];
94833
+ if (field) {
94834
+ throw new CliUsageError(
94835
+ `This value holds the stand-in for ${field} that Laze's proxy swaps on this computer, not the key itself, so it would not work anywhere else. To copy the real key, run the copy with laze vault run <name> -- <command>.`
94836
+ );
94837
+ }
94200
94838
  return trimmed;
94201
94839
  }
94202
94840
  async function keychainOf2({ client, args }) {
@@ -94212,6 +94850,7 @@ function settingsOf2(args) {
94212
94850
  const lease = flagText({ args, name: "lease" }) || flagText({ args, name: "max-lease" });
94213
94851
  const approvers = args.lists.approver;
94214
94852
  const everyUseAsks = yesNoOf({ args, name: "every-use-asks" });
94853
+ const localUse = yesNoOf({ args, name: "local-use" });
94215
94854
  const label3 = flagText({ args, name: "label" });
94216
94855
  const rules = args.flags.rules;
94217
94856
  return {
@@ -94220,7 +94859,8 @@ function settingsOf2(args) {
94220
94859
  ...typeof rules === "string" && { rules },
94221
94860
  ...approvers && { approverUserIds: [...approvers] },
94222
94861
  ...lease && { maxLeaseSeconds: lease === "none" ? null : secondsOf(lease) },
94223
- ...everyUseAsks !== void 0 && { everyUseAsks }
94862
+ ...everyUseAsks !== void 0 && { everyUseAsks },
94863
+ ...localUse !== void 0 && { localUse }
94224
94864
  };
94225
94865
  }
94226
94866
  var list4 = async ({ context, args }) => {
@@ -94430,7 +95070,7 @@ async function keyText({ context, args }) {
94430
95070
  throw new CliUsageError("A key never goes in a flag: pipe it on stdin or use --from-file.");
94431
95071
  }
94432
95072
  const file4 = flagText({ args, name: "from-file" });
94433
- const text3 = file4 ? await readFile23(resolve14(context.cwd, file4), "utf8") : await context.readStdin();
95073
+ const text3 = file4 ? await readFile24(resolve14(context.cwd, file4), "utf8") : await context.readStdin();
94434
95074
  const trimmed = text3.trim();
94435
95075
  if (!trimmed) throw new CliUsageError("No key: pipe it on stdin or use --from-file.");
94436
95076
  return trimmed;
@@ -94819,7 +95459,7 @@ async function conversationDelete({ context, args }) {
94819
95459
  }
94820
95460
 
94821
95461
  // src/services/discord-commands.service.ts
94822
- import { readFile as readFile24 } from "node:fs/promises";
95462
+ import { readFile as readFile25 } from "node:fs/promises";
94823
95463
  import { resolve as resolve15 } from "node:path";
94824
95464
 
94825
95465
  // ../../modules/discord/contract/src/discord.ts
@@ -94941,13 +95581,13 @@ var oauthCallbackDefinition = external_exports.object({
94941
95581
  error: external_exports.string().max(200).optional()
94942
95582
  });
94943
95583
  var linkParamsDefinition = external_exports.object({ workspaceId: workspaceIdSchema25, guildId: discordIdSchema });
94944
- var historyInputDefinition = external_exports.object({
95584
+ var historyInputDefinition2 = external_exports.object({
94945
95585
  workspaceId: workspaceIdSchema25,
94946
95586
  /** The Laze conversation that mirrors the Discord channel. */
94947
95587
  channelId: external_exports.string().min(1).max(200),
94948
95588
  before: external_exports.iso.datetime()
94949
95589
  });
94950
- var discordHistoryInputSchema = historyInputDefinition;
95590
+ var discordHistoryInputSchema = historyInputDefinition2;
94951
95591
  var channelPeopleInputDefinition = external_exports.object({
94952
95592
  workspaceId: workspaceIdSchema25,
94953
95593
  channelId: external_exports.string().min(1).max(200)
@@ -94963,7 +95603,7 @@ var discordFileDefinition = external_exports.object({
94963
95603
  mimetype: external_exports.string(),
94964
95604
  size: external_exports.number().int().nonnegative()
94965
95605
  });
94966
- var historyMessageDefinition = external_exports.object({
95606
+ var historyMessageDefinition2 = external_exports.object({
94967
95607
  key: external_exports.string().min(1),
94968
95608
  createdAt: external_exports.iso.datetime(),
94969
95609
  authorName: external_exports.string(),
@@ -94973,12 +95613,12 @@ var historyMessageDefinition = external_exports.object({
94973
95613
  replyCount: external_exports.number().int().nonnegative(),
94974
95614
  files: external_exports.array(discordFileDefinition)
94975
95615
  });
94976
- var historyPageDefinition = external_exports.object({
95616
+ var historyPageDefinition2 = external_exports.object({
94977
95617
  /** Oldest first. */
94978
- messages: external_exports.array(historyMessageDefinition),
95618
+ messages: external_exports.array(historyMessageDefinition2),
94979
95619
  hasOlder: external_exports.boolean()
94980
95620
  });
94981
- var discordHistoryPageSchema = historyPageDefinition;
95621
+ var discordHistoryPageSchema = historyPageDefinition2;
94982
95622
  var fileParamsDefinition = external_exports.object({
94983
95623
  workspaceId: workspaceIdSchema25,
94984
95624
  channelId: external_exports.string().min(1).max(200),
@@ -94994,7 +95634,7 @@ var saveAppByKeyDefinition = external_exports.object({
94994
95634
  });
94995
95635
  var pickByKeyDefinition = pickDefinition.omit({ workspaceId: true });
94996
95636
  var updateByKeyDefinition = updateConnectionDefinition.omit({ workspaceId: true });
94997
- var historyByKeyDefinition = historyInputDefinition.omit({ workspaceId: true });
95637
+ var historyByKeyDefinition = historyInputDefinition2.omit({ workspaceId: true });
94998
95638
  var emptyDefinition3 = external_exports.object({});
94999
95639
  var DISCORD_KEY_PATHS = {
95000
95640
  overview: "/api/discord/overview",
@@ -95167,7 +95807,7 @@ async function secretsOf({ context, args }) {
95167
95807
  const fromConnection = flagText({ args, name: "from-vault" });
95168
95808
  if (fromConnection) return { fromConnection };
95169
95809
  const file4 = flagText({ args, name: "from-file" });
95170
- const text3 = file4 ? await readFile24(resolve15(context.cwd, file4), "utf8") : await context.readStdin();
95810
+ const text3 = file4 ? await readFile25(resolve15(context.cwd, file4), "utf8") : await context.readStdin();
95171
95811
  const lines2 = text3.split("\n").map((line) => line.trim()).filter(Boolean);
95172
95812
  if (lines2.length !== 2) {
95173
95813
  throw new CliUsageError(
@@ -95470,7 +96110,7 @@ async function domains({ context, args }) {
95470
96110
  }
95471
96111
 
95472
96112
  // src/services/emoji-commands.service.ts
95473
- import { readFile as readFile25 } from "node:fs/promises";
96113
+ import { readFile as readFile26 } from "node:fs/promises";
95474
96114
  import { resolve as resolve16 } from "node:path";
95475
96115
  var EMOJI_USAGE = `Usage:
95476
96116
  laze emoji list [--json] the workspace's custom emoji, aliases and who added each
@@ -95511,7 +96151,7 @@ async function addEmoji({ context, args, client }) {
95511
96151
  const file4 = wordAt4(args, 3);
95512
96152
  let bytes;
95513
96153
  try {
95514
- bytes = new Uint8Array(await readFile25(resolve16(context.cwd, file4)));
96154
+ bytes = new Uint8Array(await readFile26(resolve16(context.cwd, file4)));
95515
96155
  } catch {
95516
96156
  throw new CliUsageError(`Cannot read ${file4}.`);
95517
96157
  }
@@ -95850,7 +96490,7 @@ var ExternalChannelBannerSlot = externalUi.component("channel-banner");
95850
96490
  var ExternalSharingHooksToken = externalUi.hooks("sharing");
95851
96491
 
95852
96492
  // src/services/workspace-commands.service.ts
95853
- import { readFile as readFile26 } from "node:fs/promises";
96493
+ import { readFile as readFile27 } from "node:fs/promises";
95854
96494
  import { resolve as resolve17 } from "node:path";
95855
96495
  var ROLE_NAMES2 = {
95856
96496
  OWNER: "Owner",
@@ -96033,7 +96673,7 @@ var LOGO_USAGE = "Usage: laze workspace logo set <file.png|jpg|webp> | laze work
96033
96673
  async function readLogo({ context, file: file4 }) {
96034
96674
  let bytes;
96035
96675
  try {
96036
- bytes = new Uint8Array(await readFile26(resolve17(context.cwd, file4)));
96676
+ bytes = new Uint8Array(await readFile27(resolve17(context.cwd, file4)));
96037
96677
  } catch {
96038
96678
  throw new CliUsageError(`No file to read at ${file4}.`);
96039
96679
  }
@@ -96668,7 +97308,7 @@ async function agentFeedAccess({
96668
97308
  }
96669
97309
 
96670
97310
  // src/services/feed-commands.service.ts
96671
- import { readFile as readFile27 } from "node:fs/promises";
97311
+ import { readFile as readFile28 } from "node:fs/promises";
96672
97312
  import { resolve as resolve18 } from "node:path";
96673
97313
 
96674
97314
  // ../../modules/feed/contract/src/feed.delegate.ts
@@ -97822,7 +98462,7 @@ async function feedTurnOf({
97822
98462
  const read4 = async () => {
97823
98463
  const pinned = env.LAZE_TURN_TOKEN?.trim();
97824
98464
  if (pinned) return pinned;
97825
- if (env.LAZE_TURN_FILE) return (await readFile27(env.LAZE_TURN_FILE, "utf8")).trim();
98465
+ if (env.LAZE_TURN_FILE) return (await readFile28(env.LAZE_TURN_FILE, "utf8")).trim();
97826
98466
  return agent3 ? connectedTurnTokenOf({ client, channelId: channel }) : "";
97827
98467
  };
97828
98468
  const turn = await read4().catch(() => "");
@@ -97896,7 +98536,7 @@ async function bodyOf2({
97896
98536
  flags: flags2
97897
98537
  }) {
97898
98538
  const body = { ...flags2.fields };
97899
- const read4 = (source) => "file" in source ? readFile27(resolve18(context.cwd, source.file), "utf8") : source.text;
98539
+ const read4 = (source) => "file" in source ? readFile28(resolve18(context.cwd, source.file), "utf8") : source.text;
97900
98540
  for (const [field, source] of Object.entries(flags2.texts)) body[field] = await read4(source);
97901
98541
  if (flags2.rich) {
97902
98542
  const text3 = await read4(flags2.rich.source);
@@ -98173,7 +98813,7 @@ async function textFlag({
98173
98813
  }) {
98174
98814
  const value = flagText({ args, name: name3 });
98175
98815
  if (!value.startsWith("@")) return value;
98176
- return readFile27(resolve18(context.cwd, value.slice(1)), "utf8");
98816
+ return readFile28(resolve18(context.cwd, value.slice(1)), "utf8");
98177
98817
  }
98178
98818
  async function feedList({ context, args }) {
98179
98819
  const { client, profile } = await signedIn({ context, args });
@@ -98263,7 +98903,7 @@ async function ranksOf({
98263
98903
  }) {
98264
98904
  const file4 = flagText({ args, name: "file" });
98265
98905
  if (file4) {
98266
- const parsed = JSON.parse(await readFile27(resolve18(context.cwd, file4), "utf8"));
98906
+ const parsed = JSON.parse(await readFile28(resolve18(context.cwd, file4), "utf8"));
98267
98907
  if (Array.isArray(parsed)) return parsed;
98268
98908
  throw new CliUsageError("--file holds a list of {itemId, priority}");
98269
98909
  }
@@ -98378,7 +99018,7 @@ async function feed({ context, args }) {
98378
99018
  }
98379
99019
 
98380
99020
  // src/services/github-commands.service.ts
98381
- import { readFile as readFile28 } from "node:fs/promises";
99021
+ import { readFile as readFile29 } from "node:fs/promises";
98382
99022
 
98383
99023
  // src/rules/github-signature.rules.ts
98384
99024
  var TURN_SEPARATOR = "~";
@@ -98448,7 +99088,7 @@ var REAL_GH = "/usr/bin/gh";
98448
99088
  var NOT_SET = "laze: agent_github_not_set: this agent has no GitHub connection. Run `laze github request --repo <owner/name>` to post a card that gets it in one click, or its owner runs `laze agent set-github <agent> <connection>`.";
98449
99089
  async function turnFileToken({ env }) {
98450
99090
  if (!env.LAZE_TURN_FILE) return "";
98451
- return readFile28(env.LAZE_TURN_FILE, "utf8").then(
99091
+ return readFile29(env.LAZE_TURN_FILE, "utf8").then(
98452
99092
  (text3) => text3.trim(),
98453
99093
  () => ""
98454
99094
  );
@@ -98482,7 +99122,7 @@ async function githubGh({
98482
99122
  args: args.rest,
98483
99123
  agentName: profile.name ?? "An agent",
98484
99124
  threadUrl: threadUrlOf({ env, workspaceId: profile.workspaceId }),
98485
- readBodyFile: (path) => path === "-" ? context.readStdin() : readFile28(path, "utf8")
99125
+ readBodyFile: (path) => path === "-" ? context.readStdin() : readFile29(path, "utf8")
98486
99126
  });
98487
99127
  return context.runCommand({
98488
99128
  command: [REAL_GH, ...ghArgs],
@@ -98698,6 +99338,14 @@ async function groups({ context, args }) {
98698
99338
  }
98699
99339
 
98700
99340
  // src/rules/history-format.rules.ts
99341
+ var SOURCE_LABELS = {
99342
+ slack: "Slack",
99343
+ discord: "Discord",
99344
+ whatsapp: "WhatsApp"
99345
+ };
99346
+ function sourceOfKey(key) {
99347
+ return key ? SOURCE_LABELS[key.split(":")[0] ?? ""] ?? null : null;
99348
+ }
98701
99349
  function timeOf2(iso3) {
98702
99350
  return `${iso3.slice(0, 10)} ${iso3.slice(11, 16)} UTC`;
98703
99351
  }
@@ -98705,8 +99353,9 @@ function linesOf3(output2) {
98705
99353
  const live = (output2.live?.messages ?? []).map((message2) => ({
98706
99354
  at: message2.createdAt,
98707
99355
  author: message2.authorName,
98708
- fromSlack: true,
98709
- cursor: message2.key,
99356
+ source: sourceOfKey(message2.key) ?? SOURCE_LABELS[output2.laze.mirror?.source ?? ""] ?? null,
99357
+ // A Slack key reads back as its time; other sources' keys do not, so their time is the cursor.
99358
+ cursor: message2.key.startsWith("slack:") ? message2.key : message2.createdAt,
98710
99359
  threadRootId: null,
98711
99360
  replyCount: message2.replyCount,
98712
99361
  body: message2.body
@@ -98714,7 +99363,7 @@ function linesOf3(output2) {
98714
99363
  const cached2 = output2.laze.messages.map((message2) => ({
98715
99364
  at: message2.postedAt,
98716
99365
  author: message2.author.name,
98717
- fromSlack: message2.originKey?.startsWith("slack:") ?? false,
99366
+ source: sourceOfKey(message2.originKey),
98718
99367
  cursor: message2.messageId,
98719
99368
  threadRootId: message2.threadRootId,
98720
99369
  replyCount: message2.replyCount,
@@ -98724,7 +99373,7 @@ function linesOf3(output2) {
98724
99373
  return [...live, ...cached2];
98725
99374
  }
98726
99375
  function blockOf2(line) {
98727
- const badge = line.fromSlack ? " [Slack]" : "";
99376
+ const badge = line.source ? ` [${line.source}]` : "";
98728
99377
  const thread2 = line.threadRootId ? ` in thread ${line.threadRootId}` : "";
98729
99378
  const link2 = line.link ? ` ${line.link}` : "";
98730
99379
  const head = `${timeOf2(line.at)} ${line.author}${badge} ${line.cursor}${thread2}${link2}`;
@@ -98760,10 +99409,16 @@ ${blocks}${older}
98760
99409
  // src/services/history-commands.service.ts
98761
99410
  var HISTORY_USAGE = `Usage: laze history <channel> [--before <message-id>] [--limit <1-${CALLER_HISTORY_LIMIT_MAX}>] [--json]
98762
99411
 
98763
- A conversation's messages before a message, oldest first: the cached ones, then, in a channel
98764
- that mirrors Slack, older ones read live from Slack. --before also takes a Slack message key or
98765
- an ISO time, as the "Older:" line prints it. An agent reads while it answers a message: outside
98766
- a turn the call is refused.`;
99412
+ A conversation's messages before a message, oldest first: the cached ones, then, in a
99413
+ conversation that mirrors Slack, Discord or WhatsApp, older ones pulled back from the source
99414
+ (WhatsApp's from the owner's Laze computer, which wakes for it). --before also takes a Slack
99415
+ message key or an ISO time, as the "Older:" line prints it. An agent reads while it answers a
99416
+ message: outside a turn the call is refused.`;
99417
+ var LIVE_PATHS = {
99418
+ slack: SLACK_HISTORY_PATH,
99419
+ discord: DISCORD_KEY_PATHS.history,
99420
+ whatsapp: WHATSAPP_HISTORY_PATH
99421
+ };
98767
99422
  var SLACK_KEY = /^slack:[^:]+:[^:]+:(\d+(?:\.\d+)?)$/;
98768
99423
  function isoOf(epochMilliseconds) {
98769
99424
  return Temporal3.Instant.fromEpochMilliseconds(epochMilliseconds).toString({
@@ -98805,9 +99460,10 @@ async function history2({
98805
99460
  });
98806
99461
  let live = null;
98807
99462
  let refused = null;
99463
+ const livePath = LIVE_PATHS[laze.mirror?.source ?? "slack"] ?? SLACK_HISTORY_PATH;
98808
99464
  if (laze.messages.length < limit && laze.liveBefore) {
98809
99465
  try {
98810
- const page = await client.post(SLACK_HISTORY_PATH, {
99466
+ const page = await client.post(livePath, {
98811
99467
  channelId: laze.channelId,
98812
99468
  before: laze.liveBefore
98813
99469
  });
@@ -99130,7 +99786,7 @@ async function ip({ context, args }) {
99130
99786
  }
99131
99787
 
99132
99788
  // src/services/join-commands.service.ts
99133
- import { rm as rm16 } from "node:fs/promises";
99789
+ import { rm as rm17 } from "node:fs/promises";
99134
99790
  import { hostname as hostname9 } from "node:os";
99135
99791
  import { dirname as dirname22, join as join31 } from "node:path";
99136
99792
  var DEFAULT_WAIT_SECONDS2 = 100;
@@ -99152,7 +99808,7 @@ async function keepPending({ context, pending: pending2 }) {
99152
99808
  await writeStateJson({ path: pendingPathOf({ context }), value: pending2 });
99153
99809
  }
99154
99810
  async function dropPending({ context }) {
99155
- await rm16(pendingPathOf({ context }), { force: true });
99811
+ await rm17(pendingPathOf({ context }), { force: true });
99156
99812
  }
99157
99813
  function waitSecondsOf3({ args }) {
99158
99814
  const raw = flagText({ args, name: "timeout" });
@@ -100411,18 +101067,18 @@ async function serveMcp({
100411
101067
  }
100412
101068
 
100413
101069
  // src/services/memory-commands.service.ts
100414
- import { readdir as readdir7, readFile as readFile30 } from "node:fs/promises";
101070
+ import { readdir as readdir7, readFile as readFile31 } from "node:fs/promises";
100415
101071
  import { join as join32, resolve as resolve20 } from "node:path";
100416
101072
 
100417
101073
  // src/services/mount-files.service.ts
100418
- import { mkdir as mkdir11, readFile as readFile29, rm as rm17, writeFile as writeFile8 } from "node:fs/promises";
101074
+ import { mkdir as mkdir11, readFile as readFile30, rm as rm18, writeFile as writeFile8 } from "node:fs/promises";
100419
101075
  import { dirname as dirname23, relative as relative5, resolve as resolve19 } from "node:path";
100420
101076
  async function textArgument({
100421
101077
  context,
100422
101078
  value
100423
101079
  }) {
100424
101080
  if (value === "-") return context.readStdin();
100425
- if (value.startsWith("@")) return readFile29(resolve19(context.cwd, value.slice(1)), "utf8");
101081
+ if (value.startsWith("@")) return readFile30(resolve19(context.cwd, value.slice(1)), "utf8");
100426
101082
  return value;
100427
101083
  }
100428
101084
  function turnChannel({ context, args }) {
@@ -100435,7 +101091,7 @@ async function writeMount({
100435
101091
  files: files2
100436
101092
  }) {
100437
101093
  const root = resolve19(context.cwd, flagText({ args, name: "dir", fallback: ".laze" }), folder);
100438
- await rm17(root, { recursive: true, force: true });
101094
+ await rm18(root, { recursive: true, force: true });
100439
101095
  await mkdir11(root, { recursive: true });
100440
101096
  for (const file4 of files2) {
100441
101097
  const target = resolve19(root, file4.path);
@@ -100569,7 +101225,7 @@ async function turnTokenOf5({ context }) {
100569
101225
  const pinned = env.LAZE_TURN_TOKEN?.trim();
100570
101226
  if (pinned) return pinned;
100571
101227
  if (!env.LAZE_TURN_FILE) return "";
100572
- return readFile30(env.LAZE_TURN_FILE, "utf8").then(
101228
+ return readFile31(env.LAZE_TURN_FILE, "utf8").then(
100573
101229
  (text3) => text3.trim(),
100574
101230
  () => ""
100575
101231
  );
@@ -100699,7 +101355,7 @@ async function siestaImport({
100699
101355
  dir
100700
101356
  }) {
100701
101357
  const root = resolve20(context.cwd, dir);
100702
- const log = await readFile30(join32(root, "LOG.md"));
101358
+ const log = await readFile31(join32(root, "LOG.md"));
100703
101359
  const names = (await readdir7(join32(root, "tree")).catch(() => [])).filter(
100704
101360
  (name3) => /^\d{1,6}-\d{1,6}\.md$/.test(name3)
100705
101361
  );
@@ -100707,7 +101363,7 @@ async function siestaImport({
100707
101363
  await Promise.all(
100708
101364
  names.map(async (name3) => [
100709
101365
  name3.slice(0, -3),
100710
- (await readFile30(join32(root, "tree", name3))).toString("base64")
101366
+ (await readFile31(join32(root, "tree", name3))).toString("base64")
100711
101367
  ])
100712
101368
  )
100713
101369
  );
@@ -100727,7 +101383,7 @@ async function memoryImport({ context, args }) {
100727
101383
  const dir = flagText({ args, name: "optmem" });
100728
101384
  if (!dir) throw new CliUsageError(USAGE14);
100729
101385
  const root = resolve20(context.cwd, dir);
100730
- const log = await readFile30(join32(root, "LOG.txt"));
101386
+ const log = await readFile31(join32(root, "LOG.txt"));
100731
101387
  const sizes2 = (await readdir7(join32(root, "TREE")).catch(() => [])).filter(
100732
101388
  (name3) => /^\d{1,4}$/.test(name3)
100733
101389
  );
@@ -100735,7 +101391,7 @@ async function memoryImport({ context, args }) {
100735
101391
  await Promise.all(
100736
101392
  sizes2.map(async (size) => [
100737
101393
  size,
100738
- (await readFile30(join32(root, "TREE", size))).toString("base64")
101394
+ (await readFile31(join32(root, "TREE", size))).toString("base64")
100739
101395
  ])
100740
101396
  )
100741
101397
  );
@@ -101332,7 +101988,7 @@ async function openclaw({
101332
101988
 
101333
101989
  // src/services/operator-key-commands.service.ts
101334
101990
  import { createHash as createHash10, randomBytes as randomBytes5 } from "node:crypto";
101335
- import { mkdir as mkdir12, readFile as readFile31, rm as rm18, writeFile as writeFile9 } from "node:fs/promises";
101991
+ import { mkdir as mkdir12, readFile as readFile32, rm as rm19, writeFile as writeFile9 } from "node:fs/promises";
101336
101992
  import { dirname as dirname24, join as join33 } from "node:path";
101337
101993
 
101338
101994
  // ../../modules/audit-log/contract/src/audit-log.api.ts
@@ -102491,7 +103147,15 @@ var snapshotOutputDefinition = external_exports.object({
102491
103147
  var eventsInputDefinition = external_exports.object({ from: external_exports.iso.datetime(), to: external_exports.iso.datetime() }).strict();
102492
103148
  var eventCountsDefinition = external_exports.object({
102493
103149
  total: count12,
102494
- byType: external_exports.array(external_exports.object({ eventType: external_exports.string(), count: count12 }))
103150
+ /** Per type: how many, and the stored bytes of their payloads and sealed copies. */
103151
+ byType: external_exports.array(
103152
+ external_exports.object({
103153
+ eventType: external_exports.string(),
103154
+ count: count12,
103155
+ payloadBytes: external_exports.number().nonnegative(),
103156
+ encryptedCopyBytes: external_exports.number().nonnegative()
103157
+ })
103158
+ )
102495
103159
  });
102496
103160
  var tenantEventsInputDefinition = external_exports.object({
102497
103161
  from: external_exports.iso.datetime(),
@@ -102547,11 +103211,35 @@ var databaseHealthDefinition = external_exports.object({
102547
103211
  longestActiveSeconds: external_exports.number().nonnegative(),
102548
103212
  longestIdleInTransactionSeconds: external_exports.number().nonnegative()
102549
103213
  }),
103214
+ /** Every database this role may open, by size: they share the volume. */
103215
+ databases: external_exports.array(external_exports.object({ name: external_exports.string(), sizeBytes: external_exports.number().nonnegative() })),
103216
+ /** pg_wal's size (null when the role may not list it) and what each replication slot holds. */
103217
+ wal: external_exports.object({
103218
+ bytes: external_exports.number().nonnegative().nullable(),
103219
+ slots: external_exports.array(
103220
+ external_exports.object({ type: external_exports.string(), active: external_exports.boolean(), retainedBytes: external_exports.number().nonnegative() })
103221
+ )
103222
+ }),
103223
+ /** When the statistics counters started from zero; scans below count from then. */
103224
+ statsSince: external_exports.iso.datetime().nullable(),
103225
+ /** The largest indexes with their scans since statsSince; unique ones enforce a rule unread. */
103226
+ indexes: external_exports.array(
103227
+ external_exports.object({
103228
+ table: external_exports.string(),
103229
+ index: external_exports.string(),
103230
+ sizeBytes: external_exports.number().nonnegative(),
103231
+ scans: external_exports.number().nonnegative(),
103232
+ unique: external_exports.boolean()
103233
+ })
103234
+ ),
102550
103235
  /** The tables, largest first: sizes, row estimates and scans; never a row. */
102551
103236
  tables: pageOf(
102552
103237
  external_exports.object({
102553
103238
  table: external_exports.string(),
102554
103239
  totalBytes: external_exports.number().nonnegative(),
103240
+ heapBytes: external_exports.number().nonnegative(),
103241
+ toastBytes: external_exports.number().nonnegative(),
103242
+ indexBytes: external_exports.number().nonnegative(),
102555
103243
  liveRows: external_exports.number().nonnegative(),
102556
103244
  deadRows: external_exports.number().nonnegative(),
102557
103245
  seqScans: external_exports.number().nonnegative(),
@@ -102773,6 +103461,32 @@ var contentBreakerOutputDefinition = external_exports.object({
102773
103461
  upkeepCeilings: vaultContentBreakerSchema.shape.upkeepCeilings,
102774
103462
  rows: pageOf(vaultContentBreakerSchema.shape.rows.element)
102775
103463
  });
103464
+ var vaultAlertsInputDefinition = external_exports.object({
103465
+ from: external_exports.iso.datetime(),
103466
+ to: external_exports.iso.datetime(),
103467
+ kind: external_exports.string().trim().min(1).max(64).optional(),
103468
+ limit: external_exports.number().int().min(1).max(500).default(100),
103469
+ cursor: cursorDefinition.optional()
103470
+ }).strict();
103471
+ var vaultAlertRowDefinition = external_exports.object({
103472
+ at: external_exports.iso.datetime(),
103473
+ seq: external_exports.number().int().nullable(),
103474
+ kind: external_exports.string(),
103475
+ subjectWorkspaceId: external_exports.string().nullable(),
103476
+ scope: external_exports.string().nullable(),
103477
+ window: external_exports.string().nullable(),
103478
+ count: external_exports.number().nullable(),
103479
+ ceiling: external_exports.number().nullable(),
103480
+ wouldLock: external_exports.boolean(),
103481
+ topUse: external_exports.string().nullable(),
103482
+ /** Opens per vault use (`release`, `token_refresh`...) in the window that tripped. */
103483
+ uses: external_exports.record(external_exports.string(), external_exports.number()),
103484
+ /** The busiest code-path labels and their opens; never an id. */
103485
+ callers: external_exports.record(external_exports.string(), external_exports.number()),
103486
+ /** A gate or process alert's operation, such as `unwrap`. */
103487
+ op: external_exports.string().nullable()
103488
+ });
103489
+ var vaultAlertsOutputDefinition = external_exports.object({ alerts: pageOf(vaultAlertRowDefinition) });
102776
103490
  var judgeMeasureInputDefinition = external_exports.object({
102777
103491
  from: external_exports.iso.datetime(),
102778
103492
  to: external_exports.iso.datetime(),
@@ -103028,6 +103742,13 @@ var OPS_FUNCTIONS = {
103028
103742
  input: contentBreakerInputDefinition,
103029
103743
  output: contentBreakerOutputDefinition
103030
103744
  }),
103745
+ "vault.alerts": entry({
103746
+ title: "Vault alerts over a range: kind, when vaultd raised it, the workspace id, the breaker numbers, uses and busiest callers",
103747
+ scope: "platform",
103748
+ view: "table",
103749
+ input: vaultAlertsInputDefinition,
103750
+ output: vaultAlertsOutputDefinition
103751
+ }),
103031
103752
  "vault.judge_measure": entry({
103032
103753
  title: "The vault judge's verdicts against people's answers, with false allows and blocks",
103033
103754
  scope: "platform",
@@ -103158,7 +103879,11 @@ async function waitForAnswer({
103158
103879
  let current3 = key;
103159
103880
  while (current3.status === "pending" && context.nowMs() < giveUpAt) {
103160
103881
  await context.sleep(POLL_MS3);
103161
- current3 = await client.post(OPERATOR_KEY_REST_PATHS.status, { keyId: key.id });
103882
+ current3 = await patiently({
103883
+ context,
103884
+ giveUpAt,
103885
+ call: () => client.post(OPERATOR_KEY_REST_PATHS.status, { keyId: key.id })
103886
+ });
103162
103887
  }
103163
103888
  return current3;
103164
103889
  }
@@ -103202,7 +103927,7 @@ async function forgetIfOver({
103202
103927
  const key = await client.post(OPERATOR_KEY_REST_PATHS.status, { keyId });
103203
103928
  const windowOver = key.endsAt !== null && Temporal3.Instant.from(key.endsAt).epochMilliseconds <= context.nowMs();
103204
103929
  if (key.status !== "pending" && (key.status !== "approved" || windowOver || key.spentAt)) {
103205
- await rm18(keyFile({ context, keyId }), { force: true });
103930
+ await rm19(keyFile({ context, keyId }), { force: true });
103206
103931
  }
103207
103932
  return key;
103208
103933
  }
@@ -103215,7 +103940,7 @@ async function useKey({
103215
103940
  if (!keyId) throw new CliUsageError(OPERATOR_KEY_USAGE);
103216
103941
  const { client } = await signedIn({ context, args });
103217
103942
  const path = keyFile({ context, keyId });
103218
- const secret = await readFile31(path, "utf8").catch(() => null);
103943
+ const secret = await readFile32(path, "utf8").catch(() => null);
103219
103944
  if (secret === null) {
103220
103945
  throw new CliUsageError(`No operator key ${keyId} is kept on this machine.`);
103221
103946
  }
@@ -103414,7 +104139,7 @@ function watchingRelease({
103414
104139
  }
103415
104140
 
103416
104141
  // src/services/rush-guard.service.ts
103417
- import { rm as rm19 } from "node:fs/promises";
104142
+ import { rm as rm20 } from "node:fs/promises";
103418
104143
  var WATCH_MS3 = 2e3;
103419
104144
  async function guardRound(guard) {
103420
104145
  const { context, client, name: name3, lock, claudePid, session, rush, launch } = guard;
@@ -103501,10 +104226,10 @@ async function rushWakeHook({ context, args }) {
103501
104226
  return await guardRounds(guard);
103502
104227
  } finally {
103503
104228
  if ((await holderOf({ path: lock }))?.pid === context.processes.pid)
103504
- await rm19(lock, { force: true });
104229
+ await rm20(lock, { force: true });
103505
104230
  }
103506
104231
  } finally {
103507
- await rm19(path, { force: true });
104232
+ await rm20(path, { force: true });
103508
104233
  }
103509
104234
  }
103510
104235
 
@@ -103673,7 +104398,7 @@ async function schedule({ context, args }) {
103673
104398
  }
103674
104399
 
103675
104400
  // src/services/skill-commands.service.ts
103676
- import { readdir as readdir8, readFile as readFile32 } from "node:fs/promises";
104401
+ import { readdir as readdir8, readFile as readFile33 } from "node:fs/promises";
103677
104402
  import { join as join35, relative as relative6, resolve as resolve22 } from "node:path";
103678
104403
  var USAGE18 = `Usage:
103679
104404
  laze skill list [--agent <agentId>]
@@ -103696,7 +104421,7 @@ async function folderFiles({ root }) {
103696
104421
  for (const entry2 of entries) {
103697
104422
  if (!entry2.isFile()) continue;
103698
104423
  const full = join35(entry2.parentPath, entry2.name);
103699
- files2.push({ path: relative6(root, full), content: await readFile32(full, "utf8") });
104424
+ files2.push({ path: relative6(root, full), content: await readFile33(full, "utf8") });
103700
104425
  }
103701
104426
  return files2.toSorted((a, b) => a.path.localeCompare(b.path));
103702
104427
  }
@@ -103794,7 +104519,7 @@ async function skillUpdate({ context, args }) {
103794
104519
  if (!name3 || !newName && description === void 0 && !skillMdFile) {
103795
104520
  throw new CliUsageError(USAGE18);
103796
104521
  }
103797
- const skillMd = skillMdFile ? await readFile32(resolve22(context.cwd, skillMdFile), "utf8") : void 0;
104522
+ const skillMd = skillMdFile ? await readFile33(resolve22(context.cwd, skillMdFile), "utf8") : void 0;
103798
104523
  const { client } = await signedIn({ context, args });
103799
104524
  const updated = await client.post("/api/skills/update", {
103800
104525
  name: name3,
@@ -103840,7 +104565,7 @@ async function skill({ context, args }) {
103840
104565
  }
103841
104566
 
103842
104567
  // src/services/slack-commands.service.ts
103843
- import { readFile as readFile33 } from "node:fs/promises";
104568
+ import { readFile as readFile34 } from "node:fs/promises";
103844
104569
  import { resolve as resolve23 } from "node:path";
103845
104570
  var SLACK_USAGE = `Usage (a person's key; Slack stays the source, the bot joins no channel by itself):
103846
104571
  laze slack overview connected Slack workspaces, mirrors, your link
@@ -103891,7 +104616,7 @@ async function secretLines({ context, args }) {
103891
104616
  throw new CliUsageError("A secret never goes in a flag: pipe it on stdin or use --from-file.");
103892
104617
  }
103893
104618
  const file4 = flagText({ args, name: "from-file" });
103894
- const text3 = file4 ? await readFile33(resolve23(context.cwd, file4), "utf8") : await context.readStdin();
104619
+ const text3 = file4 ? await readFile34(resolve23(context.cwd, file4), "utf8") : await context.readStdin();
103895
104620
  return text3.split("\n").map((line) => line.trim()).filter(Boolean);
103896
104621
  }
103897
104622
  async function secretsOf2({
@@ -104209,7 +104934,7 @@ async function slack({
104209
104934
  }
104210
104935
 
104211
104936
  // src/services/sso-commands.service.ts
104212
- import { readFile as readFile34 } from "node:fs/promises";
104937
+ import { readFile as readFile35 } from "node:fs/promises";
104213
104938
  var SSO_USAGE = `Usage:
104214
104939
  laze sso domains claimed domains and how each signs in (admins)
104215
104940
  laze sso claim <domain> the TXT record that proves the domain
@@ -104296,7 +105021,7 @@ function refuseSecretFlags({ args }) {
104296
105021
  }
104297
105022
  async function clientSecretOf({ context, args }) {
104298
105023
  const file4 = flagText({ args, name: "from-file" });
104299
- const text3 = file4 ? await readFile34(file4, "utf8") : await context.readStdin();
105024
+ const text3 = file4 ? await readFile35(file4, "utf8") : await context.readStdin();
104300
105025
  const secret = text3.trim();
104301
105026
  if (!secret) throw new CliUsageError("No client secret: pipe it on stdin or use --from-file.");
104302
105027
  return secret;
@@ -104640,7 +105365,7 @@ async function checkInstalled({
104640
105365
  }
104641
105366
 
104642
105367
  // src/services/vault-env-commands.service.ts
104643
- import { readFile as readFile35, stat as stat12 } from "node:fs/promises";
105368
+ import { readFile as readFile36, stat as stat12 } from "node:fs/promises";
104644
105369
  import { dirname as dirname26, join as join36, resolve as resolve24 } from "node:path";
104645
105370
 
104646
105371
  // src/rules/vault-manifest.rules.ts
@@ -104728,208 +105453,6 @@ function credentialProcessJson(fields) {
104728
105453
  });
104729
105454
  }
104730
105455
 
104731
- // src/services/vault-batch.service.ts
104732
- import { rm as rm20 } from "node:fs/promises";
104733
- async function batchOf({ response }) {
104734
- const text3 = await response.text();
104735
- if (!response.ok) {
104736
- const code4 = /"code"\s*:\s*"([^"]+)"/.exec(text3)?.[1] ?? `status ${response.status}`;
104737
- throw new CliUsageError(`laze vault: the batch was refused (${code4})`);
104738
- }
104739
- return JSON.parse(text3);
104740
- }
104741
- async function doorOf({
104742
- context,
104743
- args,
104744
- keyName
104745
- }) {
104746
- const env = context.environment.inherited;
104747
- const proxy = proxyOf({ env });
104748
- if (proxy) {
104749
- const turnFile = turnFileOf({ env });
104750
- const headers = {
104751
- "proxy-authorization": proxy.authorization,
104752
- "x-laze-turn": await turnTokenOf2({ env, turnFile, command: "laze vault env" })
104753
- };
104754
- return {
104755
- keyPath: runKeyPathOf({ turnFile, connection: keyName }),
104756
- ask: async (body) => batchOf({
104757
- response: await reach({
104758
- context,
104759
- url: `${proxy.origin}/vault/release-batch`,
104760
- init: {
104761
- method: "POST",
104762
- headers: { ...headers, "content-type": "application/json" },
104763
- body: JSON.stringify(body)
104764
- }
104765
- })
104766
- }),
104767
- status: async (requestId) => releaseOf({
104768
- response: await reach({
104769
- context,
104770
- url: `${proxy.origin}/vault/release/${encodeURIComponent(requestId)}`,
104771
- init: { method: "GET", headers }
104772
- })
104773
- })
104774
- };
104775
- }
104776
- const signed2 = await signedIn({ context, args }).catch(() => null);
104777
- if (signed2?.profile.kind !== "agent" && signed2?.profile.kind !== "person") {
104778
- throw new CliUsageError(`laze vault env ${WHERE}`);
104779
- }
104780
- const { name: name3 } = signed2;
104781
- const harnessSession = await currentSessionOf({ context, args });
104782
- const client = forSession({ client: signed2.client, session: harnessSession });
104783
- const door = signed2.profile.kind === "person" ? {
104784
- ask: "/api/vault/session/release-batch",
104785
- status: "/api/vault/session/release-status",
104786
- extra: { session: await vaultSessionFor({ context, args, harnessSession }) }
104787
- } : {
104788
- ask: "/api/agents/me/vault/release-batch",
104789
- status: "/api/agents/me/vault/release-status",
104790
- extra: { channelId: flagText({ args, name: "channel" }) || null }
104791
- };
104792
- return {
104793
- keyPath: runKeyPathOf({ turnFile: void 0, connection: keyName, profile: name3 }),
104794
- ask: async (body) => {
104795
- try {
104796
- return await client.post(door.ask, { ...body, ...door.extra });
104797
- } catch (error63) {
104798
- if (!(error63 instanceof LazeApiError)) throw error63;
104799
- throw new CliUsageError(`laze vault: the batch was refused: ${refusalText(error63)}`);
104800
- }
104801
- },
104802
- status: (requestId) => client.post(door.status, { requestId, ...door.extra }).catch(refusedRelease)
104803
- };
104804
- }
104805
- async function resolveBatch({
104806
- context,
104807
- args,
104808
- refs
104809
- }) {
104810
- const door = await doorOf({ context, args, keyName: "env-names" });
104811
- const answer6 = await door.ask({ refs, reason: "", command: [], resolveOnly: true });
104812
- return answer6.entries;
104813
- }
104814
- var keyOf = (entry2) => entry2.connection?.name ?? entry2.ref;
104815
- async function untilAllAnswered({
104816
- context,
104817
- door,
104818
- waiting,
104819
- deadline
104820
- }) {
104821
- const answered = /* @__PURE__ */ new Map();
104822
- if (waiting.size === 0) return answered;
104823
- const [first] = waiting.values();
104824
- context.err(
104825
- `laze vault: ${[...waiting.keys()].join(", ")} wait for an answer (${first?.message ?? "a card"}); cards expire after 24 hours...
104826
- `
104827
- );
104828
- while (waiting.size > 0) {
104829
- if (context.nowMs() + POLL_MS > deadline) {
104830
- context.err(
104831
- `laze vault: ${[...waiting.keys()].join(", ")} not approved yet; ask again later.
104832
- `
104833
- );
104834
- return "capped";
104835
- }
104836
- await context.sleep(POLL_MS);
104837
- for (const [key, pending2] of waiting) {
104838
- const next = await door.status(pending2.requestId);
104839
- if (next.outcome === "ask") waiting.set(key, next);
104840
- else {
104841
- waiting.delete(key);
104842
- answered.set(key, next);
104843
- }
104844
- }
104845
- }
104846
- return answered;
104847
- }
104848
- async function releaseBatch({
104849
- context,
104850
- args,
104851
- refs,
104852
- reason: reason2,
104853
- command
104854
- }) {
104855
- const deadline = deadlineOf({ args, nowMs: context.nowMs() });
104856
- const door = await doorOf({ context, args, keyName: `env:${[...refs].toSorted().join(",")}` });
104857
- const run4 = await runKeyAt({ path: door.keyPath });
104858
- let answer6;
104859
- let settled3;
104860
- try {
104861
- answer6 = await door.ask({ refs, reason: reason2, command, recipient: run4.publicKey });
104862
- const missing = answer6.entries.filter((entry2) => !entry2.connection);
104863
- if (missing.length > 0) {
104864
- context.err(
104865
- `laze vault: no key named ${missing.map((entry2) => entry2.ref).join(", ")} in your vault or reachable by this agent
104866
- `
104867
- );
104868
- return { exitCode: 1 };
104869
- }
104870
- settled3 = /* @__PURE__ */ new Map();
104871
- const waiting = /* @__PURE__ */ new Map();
104872
- for (const entry2 of answer6.entries) {
104873
- const release2 = entry2.release;
104874
- if (!release2) continue;
104875
- if (release2.outcome === "ask") waiting.set(keyOf(entry2), release2);
104876
- else settled3.set(keyOf(entry2), release2);
104877
- }
104878
- const later = await untilAllAnswered({ context, door, waiting, deadline });
104879
- if (later === "capped") return { exitCode: 75 };
104880
- for (const [key, release2] of later) settled3.set(key, release2);
104881
- } catch (error63) {
104882
- if (!(error63 instanceof ServerGoneError)) throw error63;
104883
- context.err(`${error63.message}. Run the command again to keep waiting.
104884
- `);
104885
- return { exitCode: 75 };
104886
- }
104887
- return valuesOf({ context, entries: answer6.entries, settled: settled3, run: run4, keyPath: door.keyPath });
104888
- }
104889
- function refusalOf({
104890
- context,
104891
- settled: settled3
104892
- }) {
104893
- const codes = [];
104894
- for (const release2 of settled3.values()) {
104895
- if (release2.outcome !== "deny") continue;
104896
- context.err(`${release2.message}
104897
- `);
104898
- codes.push(release2.exitCode || 1);
104899
- }
104900
- if (codes.length === 0) return 0;
104901
- return codes.includes(77) ? 77 : codes[0] ?? 1;
104902
- }
104903
- async function valuesOf({
104904
- context,
104905
- entries,
104906
- settled: settled3,
104907
- run: run4,
104908
- keyPath
104909
- }) {
104910
- const refused = refusalOf({ context, settled: settled3 });
104911
- if (refused !== 0) {
104912
- await rm20(keyPath, { force: true });
104913
- return { exitCode: refused };
104914
- }
104915
- const opened = /* @__PURE__ */ new Map();
104916
- let keep2 = false;
104917
- for (const [key, release2] of settled3) {
104918
- if (release2.outcome !== "allow") continue;
104919
- opened.set(key, await envOf({ release: release2, run: run4 }));
104920
- if (leaseHolds({ release: release2, nowMs: context.nowMs() })) keep2 = true;
104921
- if (release2.message) context.err(`${release2.message}
104922
- `);
104923
- }
104924
- if (!keep2) await rm20(keyPath, { force: true });
104925
- const released = /* @__PURE__ */ new Map();
104926
- for (const entry2 of entries) {
104927
- const fields = opened.get(keyOf(entry2));
104928
- if (fields) released.set(entry2.ref, { fields });
104929
- }
104930
- return { released, entries };
104931
- }
104932
-
104933
105456
  // src/services/vault-env-commands.service.ts
104934
105457
  var ENV_USAGE = `Usage: laze vault env [<file>] [--env <name>] --reason "<one plain sentence>" [--wait <s>] -- <command> [args...]
104935
105458
  laze vault env [<file>] [--env <name>] --names
@@ -104999,7 +105522,7 @@ async function manifestOf({
104999
105522
  args
105000
105523
  }) {
105001
105524
  const file4 = await manifestPathOf({ context, args });
105002
- const text3 = await readFile35(file4, "utf8").catch(() => {
105525
+ const text3 = await readFile36(file4, "utf8").catch(() => {
105003
105526
  throw new CliUsageError(`laze vault: cannot read ${file4}`);
105004
105527
  });
105005
105528
  return { file: file4, lines: parseManifest({ text: text3, file: file4 }) };
@@ -105361,7 +105884,7 @@ async function vaultScrub({ context, args }) {
105361
105884
  }
105362
105885
 
105363
105886
  // src/services/whatsapp-business-commands.service.ts
105364
- import { readFile as readFile36 } from "node:fs/promises";
105887
+ import { readFile as readFile37 } from "node:fs/promises";
105365
105888
  import { resolve as resolve25 } from "node:path";
105366
105889
 
105367
105890
  // ../../modules/whatsapp-business/contract/src/whatsapp-business.prices.ts
@@ -105858,7 +106381,7 @@ async function secretsOf3({ context, args }) {
105858
106381
  const fromConnection = flagText({ args, name: "from-vault" });
105859
106382
  if (fromConnection) return { fromConnection };
105860
106383
  const file4 = flagText({ args, name: "from-file" });
105861
- const text3 = file4 ? await readFile36(resolve25(context.cwd, file4), "utf8") : await context.readStdin();
106384
+ const text3 = file4 ? await readFile37(resolve25(context.cwd, file4), "utf8") : await context.readStdin();
105862
106385
  const lines2 = text3.split("\n").map((line) => line.trim()).filter(Boolean);
105863
106386
  if (lines2.length !== 2) {
105864
106387
  throw new CliUsageError(
@@ -107063,7 +107586,7 @@ import {
107063
107586
  randomBytes as randomBytes6,
107064
107587
  sign
107065
107588
  } from "node:crypto";
107066
- import { chmod, link, mkdir as mkdir13, readFile as readFile37, rm as rm21, writeFile as writeFile11 } from "node:fs/promises";
107589
+ import { chmod, link, mkdir as mkdir13, readFile as readFile38, rm as rm21, writeFile as writeFile11 } from "node:fs/promises";
107067
107590
  import { dirname as dirname27, join as join37 } from "node:path";
107068
107591
  var KEYCHAIN_SERVICE = "laze-cli-machine-key";
107069
107592
  var runProgram = ({ program, args, stdin: stdin2, timeoutMs }) => new Promise((resolve27, reject) => {
@@ -107136,7 +107659,7 @@ var MachineKeyStore = class _MachineKeyStore {
107136
107659
  async read() {
107137
107660
  let meta3;
107138
107661
  try {
107139
- meta3 = machineKeyRegistrationSchema.parse(JSON.parse(await readFile37(this.metaPath, "utf8")));
107662
+ meta3 = machineKeyRegistrationSchema.parse(JSON.parse(await readFile38(this.metaPath, "utf8")));
107140
107663
  } catch {
107141
107664
  return null;
107142
107665
  }
@@ -107151,7 +107674,7 @@ var MachineKeyStore = class _MachineKeyStore {
107151
107674
  "-w"
107152
107675
  ],
107153
107676
  timeoutMs: 1e4
107154
- }) : await readFile37(this.pemPathOf(meta3.jwk), "utf8");
107677
+ }) : await readFile38(this.pemPathOf(meta3.jwk), "utf8");
107155
107678
  return keyOf2({ meta: meta3, privateKey: createPrivateKey(pemOf(pem)) });
107156
107679
  }
107157
107680
  async make() {
@@ -107293,7 +107816,7 @@ function machineProofFetch({
107293
107816
  // src/services/processes.service.ts
107294
107817
  import { execFile as execFile3, spawn as spawn4, spawnSync } from "node:child_process";
107295
107818
  import { closeSync, mkdirSync, openSync, renameSync, statSync } from "node:fs";
107296
- import { readFile as readFile38, readlink } from "node:fs/promises";
107819
+ import { readFile as readFile39, readlink } from "node:fs/promises";
107297
107820
  import { dirname as dirname28 } from "node:path";
107298
107821
  import { promisify as promisify2 } from "node:util";
107299
107822
  var run3 = promisify2(execFile3);
@@ -107307,14 +107830,14 @@ function alive(pid) {
107307
107830
  }
107308
107831
  }
107309
107832
  async function argsOf2(pid) {
107310
- const raw = await readFile38(`/proc/${pid}/cmdline`, "utf8").catch(() => void 0);
107833
+ const raw = await readFile39(`/proc/${pid}/cmdline`, "utf8").catch(() => void 0);
107311
107834
  if (raw) return raw.split("\0").filter(Boolean);
107312
107835
  const listed = await run3("ps", ["-o", "args=", "-p", String(pid)]).catch(() => void 0);
107313
107836
  const line = listed?.stdout.trim();
107314
107837
  return line ? line.split(/\s+/) : void 0;
107315
107838
  }
107316
107839
  async function parentOf(pid) {
107317
- const stat13 = await readFile38(`/proc/${pid}/stat`, "utf8").catch(() => void 0);
107840
+ const stat13 = await readFile39(`/proc/${pid}/stat`, "utf8").catch(() => void 0);
107318
107841
  const fromStat = stat13 ? Number(stat13.slice(stat13.lastIndexOf(")") + 2).split(" ")[1]) : NaN;
107319
107842
  if (fromStat > 0) return fromStat;
107320
107843
  const listed = await run3("ps", ["-o", "ppid=", "-p", String(pid)]).catch(() => void 0);
@@ -107322,7 +107845,7 @@ async function parentOf(pid) {
107322
107845
  return parent > 0 ? parent : void 0;
107323
107846
  }
107324
107847
  async function startOf(pid) {
107325
- const stat13 = await readFile38(`/proc/${pid}/stat`, "utf8").catch(() => void 0);
107848
+ const stat13 = await readFile39(`/proc/${pid}/stat`, "utf8").catch(() => void 0);
107326
107849
  const ticks = stat13 ? stat13.slice(stat13.lastIndexOf(")") + 2).split(" ")[19] : void 0;
107327
107850
  if (ticks) return ticks;
107328
107851
  const listed = await run3("ps", ["-o", "lstart=", "-p", String(pid)]).catch(() => void 0);