instar 1.3.256 → 1.3.258

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.
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/commands/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AA4SH,UAAU,YAAY;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;2DACuD;IACvD,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAgxDD,wBAAsB,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CA02QtE;AAED,wBAAsB,UAAU,CAAC,OAAO,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAsDzE;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAuD5E"}
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/commands/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AA4SH,UAAU,YAAY;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;2DACuD;IACvD,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAkxDD,wBAAsB,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAm8QtE;AAED,wBAAsB,UAAU,CAAC,OAAO,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAsDzE;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAuD5E"}
@@ -328,6 +328,8 @@ let _meshSelfId = null;
328
328
  let _resolveRouterUrl = null;
329
329
  /** Multi-Machine Session Pool §L4: per-topic placement pin store ("move this to <nickname>"). */
330
330
  let _topicPinStore = null;
331
+ /** Cross-machine secret-sync (spec Phase 4): route-facing handle (push lever + read-only status). */
332
+ let _secretSyncHandle = null;
331
333
  /** Recognize + apply a "move/run this on <nickname>" relocation on inbound; returns handled=true when the message WAS a relocation command (so it must not also be dispatched). */
332
334
  let _tryNicknameRelocation = null;
333
335
  /** Per-topic framework override (claude-code | codex-cli). Populated from
@@ -9168,6 +9170,33 @@ export async function startServer(options) {
9168
9170
  .catch((err) => console.warn(` [session-pool] owner-side resume failed for topic ${topicId}: ${err instanceof Error ? err.message : String(err)}`));
9169
9171
  },
9170
9172
  });
9173
+ // ── Secret-sync inbound handler (cross-machine secret distribution, spec Phase 4) ──
9174
+ // Dark by default; live on the dev agent via the developmentAgent gate. An inbound
9175
+ // `secret-share` command is decrypted to THIS machine's X25519 key and stored in the
9176
+ // local encrypted vault. The sender's authenticity + registered-peer gate are enforced
9177
+ // by the mesh acceptance layer before this runs; confidentiality is enforced by the
9178
+ // decryption (a payload not sealed to our key fails). The OUTBOUND provisioner is wired
9179
+ // after the MeshRpcClient is constructed (below).
9180
+ const _secretSyncEnabled = config.multiMachine?.secretSync?.enabled
9181
+ ?? !!config.developmentAgent;
9182
+ let _secretShareHandler;
9183
+ if (_secretSyncEnabled) {
9184
+ try {
9185
+ const secretSyncMod = await import('../core/SecretSync.js');
9186
+ const secretStoreMod = await import('../core/SecretStore.js');
9187
+ const cryptoMod = await import('node:crypto');
9188
+ const secretStore = new secretStoreMod.SecretStore({ stateDir: config.stateDir });
9189
+ _secretShareHandler = new secretSyncMod.SecretShareHandler({
9190
+ ownEncryptionPrivateKey: () => cryptoMod.createPrivateKey(meshIdMgr.loadEncryptionKey()),
9191
+ store: { set: (k, v) => secretStore.set(k, v) },
9192
+ log: (m) => console.log(pc.dim(` ${m}`)),
9193
+ });
9194
+ console.log(pc.dim(' [secret-sync] enabled — inbound handler wired'));
9195
+ }
9196
+ catch (err) {
9197
+ console.log(pc.dim(` [secret-sync] inbound handler not wired: ${err instanceof Error ? err.message : String(err)}`));
9198
+ }
9199
+ }
9171
9200
  meshRpcDispatcher = new meshMod.MeshRpcDispatcher({
9172
9201
  verify: {
9173
9202
  selfMachineId: meshSelfId,
@@ -9209,6 +9238,9 @@ export async function startServer(options) {
9209
9238
  transfer: ownAction,
9210
9239
  release: ownAction,
9211
9240
  deliverMessage: deliverMessageHandler,
9241
+ 'secret-share': (cmd, sender) => _secretShareHandler
9242
+ ? _secretShareHandler.handle(cmd, sender)
9243
+ : { ok: false, reason: 'secret-sync disabled' },
9212
9244
  },
9213
9245
  logger: (m) => console.log(pc.dim(` ${m}`)),
9214
9246
  });
@@ -9284,6 +9316,70 @@ export async function startServer(options) {
9284
9316
  const selfNickTimer = setInterval(() => { void convergeSelfNickname(); }, 60_000);
9285
9317
  if (typeof selfNickTimer.unref === 'function')
9286
9318
  selfNickTimer.unref();
9319
+ // ── Secret-sync OUTBOUND provisioner (push-on-provision, spec Phase 4) ──
9320
+ // Constructed here (after meshClient + peerUrl exist). Encrypts the secret set
9321
+ // PER online peer to that peer's X25519 key and pushes a signed `secret-share`.
9322
+ // Dark by default; live on the dev agent via the same gate as the inbound handler.
9323
+ // Exposed to routes via _secretSyncHandle (push lever + read-only status). A boot
9324
+ // best-effort push covers a peer that came online after a secret was provisioned
9325
+ // elsewhere; the deterministic POST /secrets/sync-now is the explicit lever.
9326
+ if (_secretSyncEnabled) {
9327
+ try {
9328
+ const secretSyncMod = await import('../core/SecretSync.js');
9329
+ const secretStoreMod = await import('../core/SecretStore.js');
9330
+ const cryptoModOut = await import('node:crypto');
9331
+ const provStore = new secretStoreMod.SecretStore({ stateDir: config.stateDir });
9332
+ const readSecrets = () => {
9333
+ // @silent-fallback-ok — no vault on disk (or unreadable) ⇒ nothing to sync; an
9334
+ // empty set makes provisionAll a clean no-op rather than crashing the boot path.
9335
+ try {
9336
+ return provStore.read();
9337
+ }
9338
+ catch {
9339
+ return {};
9340
+ }
9341
+ };
9342
+ const onlinePeers = () => meshIdMgr.getActiveMachines()
9343
+ .filter((m) => m.machineId !== meshSelfId)
9344
+ .filter((m) => machinePoolRegistry?.getCapacity(m.machineId)?.online ?? false)
9345
+ .map((m) => ({ machineId: m.machineId, nickname: machinePoolRegistry?.getCapacity(m.machineId)?.nickname ?? null }));
9346
+ const provisioner = new secretSyncMod.SecretProvisioner({
9347
+ secretsToSync: readSecrets,
9348
+ listPeers: () => onlinePeers()
9349
+ .map((p) => {
9350
+ const pem = meshIdMgr.getEncryptionPublicKeyPem(p.machineId);
9351
+ if (!pem)
9352
+ return null;
9353
+ const b64 = cryptoModOut.createPublicKey(pem).export({ type: 'spki', format: 'der' }).toString('base64');
9354
+ return { machineId: p.machineId, encryptionPublicKey: b64 };
9355
+ })
9356
+ .filter((x) => x !== null),
9357
+ send: async (machineId, command) => {
9358
+ const url = peerUrl(machineId);
9359
+ if (!url)
9360
+ return { ok: false, reason: 'no peer url' };
9361
+ const r = await meshClient.send({ machineId, url }, command, 0);
9362
+ return { ok: r.ok, reason: r.reason };
9363
+ },
9364
+ log: (m) => console.log(pc.dim(` ${m}`)),
9365
+ });
9366
+ _secretSyncHandle = {
9367
+ enabled: true,
9368
+ provisionAll: () => provisioner.provisionAll(),
9369
+ localKeyPaths: () => secretSyncMod.secretKeyPaths(readSecrets()),
9370
+ syncTargets: onlinePeers,
9371
+ };
9372
+ // Boot best-effort: push current secrets to any peer already online.
9373
+ // @silent-fallback-ok — fire-and-forget; per-peer failures are already captured
9374
+ // in provisionAll's result array, and a fresh push fires on the next provision /
9375
+ // the deterministic POST /secrets/sync-now. Boot must never block on a peer.
9376
+ void provisioner.provisionAll().catch(() => { });
9377
+ console.log(pc.dim(' [secret-sync] enabled — outbound provisioner wired'));
9378
+ }
9379
+ catch (err) {
9380
+ console.log(pc.dim(` [secret-sync] outbound provisioner not wired: ${err instanceof Error ? err.message : String(err)}`));
9381
+ }
9382
+ }
9287
9383
  // This machine participates in the session pool, so a read-only standby may
9288
9384
  // persist the PER-SESSION state of sessions it's handed (the pool's owner-side
9289
9385
  // resume only fires for CAS-confirmed owned sessions, and only past 'dark').
@@ -9573,7 +9669,7 @@ export async function startServer(options) {
9573
9669
  catch (err) {
9574
9670
  console.log(pc.dim(` [session-pool] rollout gate not wired: ${err instanceof Error ? err.message : String(err)}`));
9575
9671
  }
9576
- const server = new AgentServer({ config, sessionManager, state, scheduler, telegram, relationships, feedback, feedbackAnomalyDetector, dispatches, updateChecker, autoUpdater, autoDispatcher, quotaTracker, quotaManager, publisher, viewer, tunnel, evolution, watchdog, topicMemory, triageNurse, projectMapper, coherenceGate: scopeVerifier, contextHierarchy, canonicalState, operationGate, sentinel, adaptiveTrust, memoryMonitor, orphanReaper, coherenceMonitor, commitmentTracker, semanticMemory, activitySentinel, rateLimitSentinel, releaseReadinessSentinel: releaseReadinessSentinel ?? undefined, messageRouter, summarySentinel, spawnManager, systemReviewer, capabilityMapper, selfKnowledgeTree, coverageAuditor, topicResumeMap: _topicResumeMap ?? undefined, sessionRefresh: _sessionRefresh ?? undefined, autonomyManager, trustElevationTracker, autonomousEvolution, coordinator: coordinator.enabled ? coordinator : undefined, localSigningKeyPem, leaseTransport, onLeasePullRequest: () => leaseCoordinatorRef?.currentLease() ?? null, liveTailReceiver, handoffWireTransport, onHandoffBegin, onHandoffInitiate: handoffInitiate, handoffInProgress: handoffSentinelInProgress, messageLedger, currentInboundByTopic, replyMarkerTransport, onReplyMarker: messageLedger ? (marker) => { const m = marker; messageLedger.applyRemoteReplyMarker(m.dedupeKey, { platform: m.platform, replyIdempotencyKey: m.replyIdempotencyKey, epoch: m.epoch, topic: m.topic ?? null }); } : undefined, whatsapp: whatsappAdapter, slack: slackAdapter, imessage: imessageAdapter, whatsappBusinessBackend, messageBridge, hookEventReceiver, worktreeMonitor, subagentTracker, instructionsVerifier, handshakeManager: threadlineHandshake, threadlineRouter, conversationStore, warrantsReplyGate, collaborationSurfacer, threadResumeMap, topicLinkageHandler: topicLinkageHandler ?? undefined, threadlineRelayClient, threadlineReplyWaiters, listenerManager: listenerManager ?? undefined, responseReviewGate, messagingToneGate, outboundDedupGate, telemetryHeartbeat, pasteManager, featureRegistry, discoveryEvaluator, completionEvaluator, unifiedTrust, liveConfig, sharedStateLedger, ledgerSessionRegistry, worktreeManager, oidcEnrolledRepos: parallelDevConfig?.oidcEnrolledRepos, initiativeTracker, projectRoundRunner, projectDriftChecker, machineHeartbeat, machinePoolRegistry, meshRpcDispatcher, sessionOwnershipRegistry, topicPinStore: _topicPinStore ?? undefined, meshSelfId: _meshSelfId ?? undefined, resolveRouterUrl: _resolveRouterUrl ?? undefined, sessionPoolE2EResultStore, proxyCoordinator, topicIntentStore, topicIntentArcCheck, usherSignalStore, intelligence: sharedIntelligence ?? undefined, telegramBridgeConfig, telegramBridge: telegramBridge ?? undefined, threadlineObservability, briefDeps, workingMemory, taskFlowRegistry, threadlineFlowBridge, sessionReaper, agentWorktreeReaper, mcpProcessReaper, geminiLoopRunner, sleepController, agentActivityState, reapLog, sleepWakeDetector, unjustifiedStopGate, stopGateDb, stopNotifier });
9672
+ const server = new AgentServer({ config, sessionManager, state, scheduler, telegram, relationships, feedback, feedbackAnomalyDetector, dispatches, updateChecker, autoUpdater, autoDispatcher, quotaTracker, quotaManager, publisher, viewer, tunnel, evolution, watchdog, topicMemory, triageNurse, projectMapper, coherenceGate: scopeVerifier, contextHierarchy, canonicalState, operationGate, sentinel, adaptiveTrust, memoryMonitor, orphanReaper, coherenceMonitor, commitmentTracker, semanticMemory, activitySentinel, rateLimitSentinel, releaseReadinessSentinel: releaseReadinessSentinel ?? undefined, messageRouter, summarySentinel, spawnManager, systemReviewer, capabilityMapper, selfKnowledgeTree, coverageAuditor, topicResumeMap: _topicResumeMap ?? undefined, sessionRefresh: _sessionRefresh ?? undefined, autonomyManager, trustElevationTracker, autonomousEvolution, coordinator: coordinator.enabled ? coordinator : undefined, localSigningKeyPem, leaseTransport, onLeasePullRequest: () => leaseCoordinatorRef?.currentLease() ?? null, liveTailReceiver, handoffWireTransport, onHandoffBegin, onHandoffInitiate: handoffInitiate, handoffInProgress: handoffSentinelInProgress, messageLedger, currentInboundByTopic, replyMarkerTransport, onReplyMarker: messageLedger ? (marker) => { const m = marker; messageLedger.applyRemoteReplyMarker(m.dedupeKey, { platform: m.platform, replyIdempotencyKey: m.replyIdempotencyKey, epoch: m.epoch, topic: m.topic ?? null }); } : undefined, whatsapp: whatsappAdapter, slack: slackAdapter, imessage: imessageAdapter, whatsappBusinessBackend, messageBridge, hookEventReceiver, worktreeMonitor, subagentTracker, instructionsVerifier, handshakeManager: threadlineHandshake, threadlineRouter, conversationStore, warrantsReplyGate, collaborationSurfacer, threadResumeMap, topicLinkageHandler: topicLinkageHandler ?? undefined, threadlineRelayClient, threadlineReplyWaiters, listenerManager: listenerManager ?? undefined, responseReviewGate, messagingToneGate, outboundDedupGate, telemetryHeartbeat, pasteManager, featureRegistry, discoveryEvaluator, completionEvaluator, unifiedTrust, liveConfig, sharedStateLedger, ledgerSessionRegistry, worktreeManager, oidcEnrolledRepos: parallelDevConfig?.oidcEnrolledRepos, initiativeTracker, projectRoundRunner, projectDriftChecker, machineHeartbeat, machinePoolRegistry, meshRpcDispatcher, sessionOwnershipRegistry, topicPinStore: _topicPinStore ?? undefined, secretSync: _secretSyncHandle ?? undefined, meshSelfId: _meshSelfId ?? undefined, resolveRouterUrl: _resolveRouterUrl ?? undefined, sessionPoolE2EResultStore, proxyCoordinator, topicIntentStore, topicIntentArcCheck, usherSignalStore, intelligence: sharedIntelligence ?? undefined, telegramBridgeConfig, telegramBridge: telegramBridge ?? undefined, threadlineObservability, briefDeps, workingMemory, taskFlowRegistry, threadlineFlowBridge, sessionReaper, agentWorktreeReaper, mcpProcessReaper, geminiLoopRunner, sleepController, agentActivityState, reapLog, sleepWakeDetector, unjustifiedStopGate, stopGateDb, stopNotifier });
9577
9673
  // Boot-recovery (tunnel-failure-resilience spec Part 6): if the agent
9578
9674
  // died mid-relay-episode, the persisted tunnel.json carries
9579
9675
  // rotationPending=true. Rotate the dashboard PIN + authToken BEFORE