@moxt-ai/mobius 0.0.35 → 0.0.36

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.
@@ -6,7 +6,6 @@ export { CodexAgentSpecification } from "./agents/codex-agent.ts";
6
6
  export { CopilotCliAgentSpecification } from "./agents/copilot-cli-agent.ts";
7
7
  export { CursorCliAgentSpecification } from "./agents/cursor-cli-agent.ts";
8
8
  export { DeepSeekHarnessAgentSpecification } from "./agents/deepseek-harness-agent.ts";
9
- export { GeminiCliAgentSpecification } from "./agents/gemini-cli-agent.ts";
10
9
  export { GrokBuildAgentSpecification } from "./agents/grok-build-agent.ts";
11
10
  export { HermesAgentSpecification } from "./agents/hermes-agent.ts";
12
11
  export { OpenCodeAgentSpecification } from "./agents/opencode-agent.ts";
@@ -1 +1 @@
1
- {"version":3,"file":"discover-local-agents.d.ts","sourceRoot":"","sources":["../../src/agent-catalog/discover-local-agents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC/E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAIxE,OAAO,EACH,cAAc,EACd,mBAAmB,GACtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,4BAA4B,EAAE,MAAM,+BAA+B,CAAC;AAC7E,OAAO,EAAE,2BAA2B,EAAE,MAAM,8BAA8B,CAAC;AAC3E,OAAO,EAAE,iCAAiC,EAAE,MAAM,oCAAoC,CAAC;AACvF,OAAO,EAAE,2BAA2B,EAAE,MAAM,8BAA8B,CAAC;AAC3E,OAAO,EAAE,2BAA2B,EAAE,MAAM,8BAA8B,CAAC;AAC3E,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,E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E,iCAAiC,EAAE,MAAM,4CAA4C,CAAC;AAC/F,OAAO,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAC;AAC1E,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAEnE,MAAM,WAAW,kCAAmC,SAAQ,0BAA0B;IAClF,QAAQ,CAAC,cAAc,CAAC,EAAE,SAAS,uBAAuB,EAAE,CAAC;CAChE;AAED,wBAAsB,2BAA2B,CAC7C,OAAO,EAAE,kCAAkC,GAC5C,OAAO,CAAC,mBAAmB,CAAC,CAM9B"}
@@ -6,7 +6,6 @@ export { CodexAgentSpecification } from "./agents/codex-agent.js";
6
6
  export { CopilotCliAgentSpecification } from "./agents/copilot-cli-agent.js";
7
7
  export { CursorCliAgentSpecification } from "./agents/cursor-cli-agent.js";
8
8
  export { DeepSeekHarnessAgentSpecification } from "./agents/deepseek-harness-agent.js";
9
- export { GeminiCliAgentSpecification } from "./agents/gemini-cli-agent.js";
10
9
  export { GrokBuildAgentSpecification } from "./agents/grok-build-agent.js";
11
10
  export { HermesAgentSpecification } from "./agents/hermes-agent.js";
12
11
  export { OpenCodeAgentSpecification } from "./agents/opencode-agent.js";
@@ -1 +1 @@
1
- {"version":3,"file":"discover-local-agents.js","sourceRoot":"","sources":["../../src/agent-catalog/discover-local-agents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAG3D,OAAO,EAAE,iCAAiC,EAAE,MAAM,4CAA4C,CAAC;AAC/F,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EACH,cAAc,EACd,mBAAmB,GACtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,4BAA4B,EAAE,MAAM,+BAA+B,CAAC;AAC7E,OAAO,EAAE,2BAA2B,EAAE,MAAM,8BAA8B,CAAC;AAC3E,OAAO,EAAE,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A+B,CAAC;AAC7E,OAAO,EAAE,2BAA2B,EAAE,MAAM,8BAA8B,CAAC;AAC3E,OAAO,EAAE,iCAAiC,EAAE,MAAM,oCAAoC,CAAC;AACvF,OAAO,EAAE,2BAA2B,EAAE,MAAM,8BAA8B,CAAC;AAC3E,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,iCAAiC,EAAE,MAAM,4CAA4C,CAAC;AAC/F,OAAO,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAC;AAC1E,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAMnE,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAC7C,OAA2C;IAE3C,MAAM,cAAc,GAAG,OAAO,CAAC,cAAc,IAAI,iCAAiC,EAAE,CAAC;IACrF,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC,GAAG,CACjC,cAAc,CAAC,GAAG,CAAC,KAAK,EAAE,aAAa,EAAE,EAAE,CAAC,MAAM,aAAa,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC,CAC3F,CAAC;IACF,OAAO,IAAI,mBAAmB,CAAC,WAAW,CAAC,CAAC;AAChD,CAAC"}
package/dist/cli.js CHANGED
@@ -11,7 +11,7 @@ import { mkdir as mkdir5 } from "node:fs/promises";
11
11
  // package.json
12
12
  var package_default = {
13
13
  name: "@moxt-ai/mobius",
14
- version: "0.0.35",
14
+ version: "0.0.36",
15
15
  description: "Mobius CLI for pairing and running local AI agent services.",
16
16
  type: "module",
17
17
  bin: {
@@ -22951,6 +22951,12 @@ var sessionIdentityFields = {
22951
22951
  };
22952
22952
  var sessionPrepareCommandSchema = external_exports.strictObject({
22953
22953
  ...sessionIdentityFields,
22954
+ configuration: external_exports.strictObject({
22955
+ booleanValue: external_exports.boolean(),
22956
+ configId: external_exports.string().min(1).max(128),
22957
+ value: external_exports.string().max(500),
22958
+ valueType: external_exports.enum(["boolean", "select"])
22959
+ }).readonly().optional(),
22954
22960
  kind: external_exports.literal(SESSION_PREPARE_KIND),
22955
22961
  requestId: IDENTIFIER,
22956
22962
  transient: external_exports.boolean().optional()
@@ -22968,6 +22974,12 @@ var sessionReadyEventSchema = external_exports.strictObject({
22968
22974
  kind: external_exports.literal(SESSION_READY_KIND),
22969
22975
  requestId: IDENTIFIER,
22970
22976
  restored: external_exports.boolean(),
22977
+ runtimeTimings: external_exports.array(
22978
+ external_exports.strictObject({
22979
+ durationMilliseconds: external_exports.number().finite().nonnegative().max(12e4),
22980
+ name: external_exports.string().regex(/^[a-z][a-z0-9-]{0,63}$/)
22981
+ }).readonly()
22982
+ ).max(16).readonly().optional(),
22971
22983
  sessionId: IDENTIFIER
22972
22984
  }).readonly();
22973
22985
  var sessionConfigureCommandSchema = external_exports.strictObject({
@@ -25752,6 +25764,38 @@ async function readAuthorizedRaster(uri, roots, signal) {
25752
25764
  return new LocalRasterImage(basename3(target) || "Image", mimeType, bytes);
25753
25765
  }
25754
25766
 
25767
+ // src/infra/operation-metrics.ts
25768
+ var AccumulatingOperationMetrics = class {
25769
+ #durations = /* @__PURE__ */ new Map();
25770
+ measure = async (name, operation) => {
25771
+ const startedAt = performance.now();
25772
+ try {
25773
+ return await operation();
25774
+ } finally {
25775
+ this.record(name, performance.now() - startedAt);
25776
+ }
25777
+ };
25778
+ measureSync = (name, operation) => {
25779
+ const startedAt = performance.now();
25780
+ try {
25781
+ return operation();
25782
+ } finally {
25783
+ this.record(name, performance.now() - startedAt);
25784
+ }
25785
+ };
25786
+ snapshot = () => Object.freeze(
25787
+ [...this.#durations].map(([name, durationMilliseconds]) => Object.freeze({ durationMilliseconds, name }))
25788
+ );
25789
+ record = (name, durationMilliseconds) => {
25790
+ this.#durations.set(name, (this.#durations.get(name) ?? 0) + Math.max(0, durationMilliseconds));
25791
+ };
25792
+ };
25793
+ var unmeasuredOperationMetrics = Object.freeze({
25794
+ measure: async (_name, operation) => await operation(),
25795
+ measureSync: (_name, operation) => operation(),
25796
+ snapshot: () => Object.freeze([])
25797
+ });
25798
+
25755
25799
  // src/native-sessions/history-images.ts
25756
25800
  var IMAGE_MARKER = /\[@image\]\(([^)\r\n]*)(?:\)|$)/g;
25757
25801
  async function embedLocalHistoryImages(history, roots, signal) {
@@ -27492,6 +27536,7 @@ var AcpProcessSession = class _AcpProcessSession {
27492
27536
  #pendingPermissions = /* @__PURE__ */ new Map();
27493
27537
  #preSessionUpdates = [];
27494
27538
  #processExit;
27539
+ #metrics;
27495
27540
  #sessionConfigProtocol;
27496
27541
  #store;
27497
27542
  #verifiedAgentVersion;
@@ -27525,13 +27570,14 @@ var AcpProcessSession = class _AcpProcessSession {
27525
27570
  #sessionUpdatedAt = "";
27526
27571
  #turn = new IdleAcpTurn();
27527
27572
  #updateTail = Promise.resolve();
27528
- constructor(agent, cwd, additionalDirectories, mobiusSessionId, getObserver, store) {
27573
+ constructor(agent, cwd, additionalDirectories, mobiusSessionId, getObserver, store, metrics) {
27529
27574
  this.#additionalDirectories = [...additionalDirectories];
27530
27575
  this.#agentId = agent.id;
27531
27576
  this.#cwd = cwd;
27532
27577
  this.#environment = agent.environment;
27533
27578
  this.#getObserver = getObserver;
27534
27579
  this.#mobiusSessionId = mobiusSessionId;
27580
+ this.#metrics = metrics;
27535
27581
  this.#sessionConfigProtocol = sessionConfigProtocolForAgent(agent.id);
27536
27582
  this.#store = store;
27537
27583
  this.#verifiedAgentVersion = agent.agentVersion;
@@ -27560,13 +27606,16 @@ var AcpProcessSession = class _AcpProcessSession {
27560
27606
  const stream = ndJsonStream2(createWritableAcpStream(stdin), readableWebStream(stdout));
27561
27607
  this.#connection = createAcpClient(this).connect(stream);
27562
27608
  }
27563
- static async #start(options, getObserver, store, initialize) {
27609
+ static async #start(options, getObserver, store, initialize, metrics) {
27564
27610
  for (let attempt = 1; attempt <= 2; attempt += 1) {
27565
27611
  options.signal.throwIfAborted();
27566
- const [adapterUnchanged, agentUnchanged] = await Promise.all([
27567
- revalidateExecutable(options.agent.adapterIdentity),
27568
- revalidateExecutable(options.agent.agentIdentity)
27569
- ]);
27612
+ const [adapterUnchanged, agentUnchanged] = await metrics.measure(
27613
+ "executable-validation",
27614
+ async () => await Promise.all([
27615
+ revalidateExecutable(options.agent.adapterIdentity),
27616
+ revalidateExecutable(options.agent.agentIdentity)
27617
+ ])
27618
+ );
27570
27619
  options.signal.throwIfAborted();
27571
27620
  if (!adapterUnchanged || !agentUnchanged) {
27572
27621
  throw new AcpExecutionError(
@@ -27575,13 +27624,17 @@ var AcpProcessSession = class _AcpProcessSession {
27575
27624
  "agent_runtime_changed"
27576
27625
  );
27577
27626
  }
27578
- const runtime = new _AcpProcessSession(
27579
- options.agent,
27580
- options.cwd,
27581
- options.additionalDirectories,
27582
- options.sessionId,
27583
- getObserver,
27584
- store
27627
+ const runtime = metrics.measureSync(
27628
+ "process-spawn",
27629
+ () => new _AcpProcessSession(
27630
+ options.agent,
27631
+ options.cwd,
27632
+ options.additionalDirectories,
27633
+ options.sessionId,
27634
+ getObserver,
27635
+ store,
27636
+ metrics
27637
+ )
27585
27638
  );
27586
27639
  try {
27587
27640
  await initialize(runtime);
@@ -27603,17 +27656,19 @@ var AcpProcessSession = class _AcpProcessSession {
27603
27656
  }
27604
27657
  throw new AcpExecutionError("ACP agent initialization failed");
27605
27658
  }
27606
- static start = async (options, getObserver, store) => await _AcpProcessSession.#start(
27659
+ static start = async (options, getObserver, store, metrics = unmeasuredOperationMetrics) => await _AcpProcessSession.#start(
27607
27660
  options,
27608
27661
  getObserver,
27609
27662
  store,
27610
- async (runtime) => await runtime.initialize(options.signal, options.origin)
27663
+ async (runtime) => await runtime.initialize(options.signal, options.origin),
27664
+ metrics
27611
27665
  );
27612
27666
  static startNativeSessionBrowser = async (options, getObserver, store) => await _AcpProcessSession.#start(
27613
27667
  options,
27614
27668
  getObserver,
27615
27669
  store,
27616
- async (runtime) => await runtime.#initializeAgent(options.signal)
27670
+ async (runtime) => await runtime.#initializeAgent(options.signal),
27671
+ unmeasuredOperationMetrics
27617
27672
  );
27618
27673
  static startSessionForkAtTurn = async (options, sourceNativeSessionId, forkPoint, getObserver, store) => await _AcpProcessSession.#start(
27619
27674
  options,
@@ -27623,7 +27678,8 @@ var AcpProcessSession = class _AcpProcessSession {
27623
27678
  options.signal,
27624
27679
  { kind: "fork", nativeSessionId: sourceNativeSessionId },
27625
27680
  forkPoint
27626
- )
27681
+ ),
27682
+ unmeasuredOperationMetrics
27627
27683
  );
27628
27684
  belongsTo = (agentId, cwd, additionalDirectories) => this.#agentId === agentId && this.#cwd === cwd && arraysEqual(this.#additionalDirectories, additionalDirectories);
27629
27685
  usesEnvironment = (environment) => recordsEqual(this.#environment, environment);
@@ -27742,6 +27798,9 @@ var AcpProcessSession = class _AcpProcessSession {
27742
27798
  );
27743
27799
  };
27744
27800
  async #initializeAgent(signal) {
27801
+ await this.#metrics.measure("agent-initialize", async () => await this.#initializeAgentOperation(signal));
27802
+ }
27803
+ async #initializeAgentOperation(signal) {
27745
27804
  const initialized = await this.race(
27746
27805
  this.#connection.agent.request(
27747
27806
  methods6.agent.initialize,
@@ -27912,18 +27971,21 @@ var AcpProcessSession = class _AcpProcessSession {
27912
27971
  }
27913
27972
  this.#store.remove(this.#mobiusSessionId);
27914
27973
  }
27915
- const created = await this.race(
27916
- this.#connection.agent.request(
27917
- methods6.agent.session.new,
27918
- {
27919
- additionalDirectories: [...this.#additionalDirectories],
27920
- cwd: this.#cwd,
27921
- mcpServers: []
27922
- },
27923
- { cancellationSignal: signal }
27924
- ),
27925
- "ACP agent exited while starting a session",
27926
- signal
27974
+ const created = await this.#metrics.measure(
27975
+ "session-new",
27976
+ async () => await this.race(
27977
+ this.#connection.agent.request(
27978
+ methods6.agent.session.new,
27979
+ {
27980
+ additionalDirectories: [...this.#additionalDirectories],
27981
+ cwd: this.#cwd,
27982
+ mcpServers: []
27983
+ },
27984
+ { cancellationSignal: signal }
27985
+ ),
27986
+ "ACP agent exited while starting a session",
27987
+ signal
27988
+ )
27927
27989
  );
27928
27990
  this.selectNativeSession(created.sessionId);
27929
27991
  lifecycleResponse = created;
@@ -28726,10 +28788,10 @@ var AcpSessionManager = class {
28726
28788
  this.#nativeBrowserPreparing.set(options.sessionId, operation);
28727
28789
  return await operation;
28728
28790
  }
28729
- async #startPreparation(options) {
28791
+ async #startPreparation(options, metrics = unmeasuredOperationMetrics) {
28730
28792
  const operation = (async () => {
28731
28793
  try {
28732
- const runtime = await AcpProcessSession.start(options, () => this.#observer, this.#store);
28794
+ const runtime = await AcpProcessSession.start(options, () => this.#observer, this.#store, metrics);
28733
28795
  this.#sessions.set(options.sessionId, runtime);
28734
28796
  return runtime;
28735
28797
  } finally {
@@ -28758,13 +28820,13 @@ var AcpSessionManager = class {
28758
28820
  this.#preparing.set(options.sessionId, operation);
28759
28821
  return await operation;
28760
28822
  }
28761
- async #replacePreparation(existing, options) {
28823
+ async #replacePreparation(existing, options, metrics) {
28762
28824
  const operation = (async () => {
28763
28825
  try {
28764
28826
  this.#sessions.delete(options.sessionId);
28765
28827
  await existing.close();
28766
28828
  this.#store.remove(options.sessionId);
28767
- const runtime = await AcpProcessSession.start(options, () => this.#observer, this.#store);
28829
+ const runtime = await AcpProcessSession.start(options, () => this.#observer, this.#store, metrics);
28768
28830
  this.#sessions.set(options.sessionId, runtime);
28769
28831
  return runtime;
28770
28832
  } finally {
@@ -28826,7 +28888,7 @@ var AcpSessionManager = class {
28826
28888
  this.#preparing.set(options.sessionId, operation);
28827
28889
  return await operation;
28828
28890
  }
28829
- prepareSession = async (options) => {
28891
+ prepareSession = async (options, metrics = unmeasuredOperationMetrics) => {
28830
28892
  const stored = this.#store.read(options.sessionId);
28831
28893
  if (stored instanceof DeletedAcpStoredSession) {
28832
28894
  throw new AcpExecutionError(
@@ -28844,7 +28906,7 @@ var AcpSessionManager = class {
28844
28906
  if (runtime2.belongsTo(options.agent.id, options.cwd, options.additionalDirectories)) {
28845
28907
  return runtime2.prepared();
28846
28908
  }
28847
- return await this.prepareSession(options);
28909
+ return await this.prepareSession(options, metrics);
28848
28910
  }
28849
28911
  const existing = this.#sessions.get(options.sessionId);
28850
28912
  if (existing !== void 0) {
@@ -28858,10 +28920,10 @@ var AcpSessionManager = class {
28858
28920
  "session_identity_mismatch"
28859
28921
  );
28860
28922
  }
28861
- const runtime2 = await this.#replacePreparation(existing, options);
28923
+ const runtime2 = await this.#replacePreparation(existing, options, metrics);
28862
28924
  return runtime2.prepared();
28863
28925
  }
28864
- const runtime = await this.#startPreparation(options);
28926
+ const runtime = await this.#startPreparation(options, metrics);
28865
28927
  return runtime.prepared();
28866
28928
  };
28867
28929
  /**
@@ -32802,6 +32864,7 @@ async function executeSessionPrepare(publisher, socket, command, config2, direct
32802
32864
  signal
32803
32865
  );
32804
32866
  const agent = config2.catalog.find(command.agentId);
32867
+ const metrics = new AccumulatingOperationMetrics();
32805
32868
  const preparation = {
32806
32869
  additionalDirectories: resolved.additionalDirectories,
32807
32870
  agent,
@@ -32809,29 +32872,65 @@ async function executeSessionPrepare(publisher, socket, command, config2, direct
32809
32872
  sessionId: command.sessionId,
32810
32873
  signal
32811
32874
  };
32812
- const prepared = command.transient === true ? await sessions.inspectSession(preparation) : await sessions.prepareSession(preparation);
32875
+ const prepared = command.transient === true ? await sessions.inspectSession(preparation) : await sessions.prepareSession(preparation, metrics);
32876
+ const configuration = command.configuration;
32877
+ const configOptions = configuration === void 0 ? prepared.configOptions : await metrics.measure(
32878
+ "configuration",
32879
+ async () => await sessions.configureSession({
32880
+ ...preparation,
32881
+ booleanValue: configuration.booleanValue,
32882
+ configId: configuration.configId,
32883
+ requestId: command.requestId,
32884
+ value: configuration.value,
32885
+ valueType: configuration.valueType
32886
+ })
32887
+ );
32813
32888
  const listing = await directories.list(config2.bindingId, command.directoryId, signal);
32814
32889
  audit.record({
32815
32890
  commandId: command.requestId,
32816
32891
  event: "session_prepared",
32817
32892
  sessionId: command.sessionId
32818
32893
  });
32819
- publisher.recordRuntime(
32820
- command.sessionId,
32821
- encodeSessionReadyEvent({
32822
- additionalDirectories: resolved.additionalDirectoryEntries,
32823
- agentId: command.agentId,
32824
- agentName: prepared.agentName,
32825
- agentVersion: prepared.agentVersion,
32826
- capabilities: prepared.capabilities,
32827
- commands: prepared.commands,
32828
- configOptions: prepared.configOptions,
32829
- directoryId: command.directoryId,
32830
- directoryLabel: listing.directoryLabel,
32831
- kind: "session.ready",
32832
- requestId: command.requestId,
32833
- restored: prepared.restored,
32894
+ if (command.configuration !== void 0) {
32895
+ audit.record({
32896
+ commandId: command.requestId,
32897
+ event: "session_configured",
32834
32898
  sessionId: command.sessionId
32899
+ });
32900
+ publisher.recordRuntime(
32901
+ command.sessionId,
32902
+ encodeSessionConfigUpdatedEvent({
32903
+ configOptions,
32904
+ kind: "session.config.updated",
32905
+ requestId: command.requestId,
32906
+ sessionId: command.sessionId
32907
+ })
32908
+ );
32909
+ }
32910
+ const readyEvent = {
32911
+ additionalDirectories: resolved.additionalDirectoryEntries,
32912
+ agentId: command.agentId,
32913
+ agentName: prepared.agentName,
32914
+ agentVersion: prepared.agentVersion,
32915
+ capabilities: prepared.capabilities,
32916
+ commands: prepared.commands,
32917
+ configOptions,
32918
+ directoryId: command.directoryId,
32919
+ directoryLabel: listing.directoryLabel,
32920
+ kind: "session.ready",
32921
+ requestId: command.requestId,
32922
+ restored: prepared.restored,
32923
+ sessionId: command.sessionId,
32924
+ runtimeTimings: metrics.snapshot()
32925
+ };
32926
+ metrics.measureSync("readiness-commit", () => {
32927
+ publisher.recordRuntime(command.sessionId, encodeSessionReadyEvent(readyEvent));
32928
+ });
32929
+ send(
32930
+ socket,
32931
+ encodeSessionReadyEvent({
32932
+ ...readyEvent,
32933
+ runtimeTimings: metrics.snapshot()
32835
32934
  })
32836
32935
  );
32837
32936
  } catch (error62) {