@mnemom/mnemom 0.17.32-next.3 → 0.17.32-next.4

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.
@@ -607,11 +607,34 @@ export async function agentCommand(scenarioArg, options = {}) {
607
607
  // index.ts's top-level handler, which prints the message and exits
608
608
  // non-zero before anything is spawned. There is no fallback path back to
609
609
  // `mnemomKey`'s original (owner) value.
610
+ //
611
+ // The mint names the served agent's org, not the account org: with an org API key the account
612
+ // org is the key owner's personal org, where the agent does not exist, so the API answers 404
613
+ // and the launch would fail closed (door1-path run 40400479127). Same read as Record's.
610
614
  let sessionKeyId;
615
+ // One read of the served agent's org serves the mint and Record; each says why in its own
616
+ // words when the read fails and the account org is used instead.
617
+ let servedOrg;
618
+ const readServedOrg = (accountOrgId) =>
619
+ // Every caller passes account.orgId, so the first call's fallback holds for the rest.
620
+ (servedOrg ??= (async () => {
621
+ let fallback;
622
+ const orgId = await recordOrgFor(servedAgentId, accountOrgId, {
623
+ onFallback: (reason) => (fallback = reason),
624
+ });
625
+ return { orgId, fallback };
626
+ })());
611
627
  if (mnemomKey) {
628
+ let mintOrgId = account.orgId;
629
+ if (account.orgId) {
630
+ const o = await readServedOrg(account.orgId);
631
+ if (o.fallback)
632
+ say(fmt.warn(`mnemom agent: could not read ${servedAgentId}'s org (${o.fallback}); minting the session key under ${account.orgId}.`));
633
+ mintOrgId = o.orgId;
634
+ }
612
635
  const minted = await mintSessionGatewayKey(defaultSessionKeyDeps(say), {
613
636
  agentId: servedAgentId,
614
- orgId: account.orgId,
637
+ orgId: mintOrgId,
615
638
  sessionId: cc.id ?? undefined,
616
639
  });
617
640
  mnemomKey = minted.key;
@@ -741,8 +764,10 @@ export async function agentCommand(scenarioArg, options = {}) {
741
764
  commitReport: cli.name === "claude" && commitReportEnabled(process.env[COMMIT_REPORT_ENV], CLI_VERSION),
742
765
  fedStatusline: cli.name === "claude" && fedStatuslineWanted(CLI_VERSION, Boolean(goalMode), process.env),
743
766
  }) && account.orgId
744
- ? await recordOrgFor(servedAgentId, account.orgId, {
745
- onFallback: (reason) => say(fmt.warn(`mnemom agent: record: could not read ${servedAgentId}'s org (${reason}); using ${account.orgId}, which may hold none of this session's record.`)),
767
+ ? await readServedOrg(account.orgId).then((o) => {
768
+ if (o.fallback)
769
+ say(fmt.warn(`mnemom agent: record: could not read ${servedAgentId}'s org (${o.fallback}); using ${account.orgId}, which may hold none of this session's record.`));
770
+ return o.orgId;
746
771
  })
747
772
  : account.orgId;
748
773
  launchTerminal({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mnemom/mnemom",
3
- "version": "0.17.32-next.3",
3
+ "version": "0.17.32-next.4",
4
4
  "description": "Transparent AI agent tracing",
5
5
  "type": "module",
6
6
  "bin": {