@namzu/cli 11.0.0 → 12.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/README.md +390 -46
  2. package/dist/cli.d.ts +15 -0
  3. package/dist/cli.d.ts.map +1 -1
  4. package/dist/cli.js +132 -4
  5. package/dist/cli.js.map +1 -1
  6. package/dist/commands/acp.d.ts +29 -0
  7. package/dist/commands/acp.d.ts.map +1 -0
  8. package/dist/commands/acp.js +156 -0
  9. package/dist/commands/acp.js.map +1 -0
  10. package/dist/commands/doctor.d.ts +12 -1
  11. package/dist/commands/doctor.d.ts.map +1 -1
  12. package/dist/commands/doctor.js +18 -2
  13. package/dist/commands/doctor.js.map +1 -1
  14. package/dist/commands/drain.d.ts +2 -2
  15. package/dist/commands/drain.d.ts.map +1 -1
  16. package/dist/commands/drain.js +31 -8
  17. package/dist/commands/drain.js.map +1 -1
  18. package/dist/commands/run-flags.d.ts.map +1 -1
  19. package/dist/commands/run-flags.js +33 -0
  20. package/dist/commands/run-flags.js.map +1 -1
  21. package/dist/commands/run-stream.d.ts +3 -3
  22. package/dist/commands/run-stream.d.ts.map +1 -1
  23. package/dist/commands/run-stream.js +27 -10
  24. package/dist/commands/run-stream.js.map +1 -1
  25. package/dist/commands/run.d.ts.map +1 -1
  26. package/dist/commands/run.js +50 -4
  27. package/dist/commands/run.js.map +1 -1
  28. package/dist/commands/types.d.ts +10 -0
  29. package/dist/commands/types.d.ts.map +1 -1
  30. package/dist/config/load.d.ts +64 -0
  31. package/dist/config/load.d.ts.map +1 -1
  32. package/dist/config/load.js +137 -20
  33. package/dist/config/load.js.map +1 -1
  34. package/dist/config/schema.d.ts +51 -0
  35. package/dist/config/schema.d.ts.map +1 -1
  36. package/dist/config/schema.js.map +1 -1
  37. package/dist/context/capabilities.d.ts +88 -0
  38. package/dist/context/capabilities.d.ts.map +1 -0
  39. package/dist/context/capabilities.js +160 -0
  40. package/dist/context/capabilities.js.map +1 -0
  41. package/dist/context/sandbox.d.ts +13 -0
  42. package/dist/context/sandbox.d.ts.map +1 -1
  43. package/dist/context/sandbox.js +15 -0
  44. package/dist/context/sandbox.js.map +1 -1
  45. package/dist/doctor/checks/index.d.ts +6 -1
  46. package/dist/doctor/checks/index.d.ts.map +1 -1
  47. package/dist/doctor/checks/index.js +45 -2
  48. package/dist/doctor/checks/index.js.map +1 -1
  49. package/dist/doctor/checks/invariants.d.ts +23 -0
  50. package/dist/doctor/checks/invariants.d.ts.map +1 -0
  51. package/dist/doctor/checks/invariants.js +79 -0
  52. package/dist/doctor/checks/invariants.js.map +1 -0
  53. package/dist/doctor/checks/logging.d.ts +10 -0
  54. package/dist/doctor/checks/logging.d.ts.map +1 -0
  55. package/dist/doctor/checks/logging.js +69 -0
  56. package/dist/doctor/checks/logging.js.map +1 -0
  57. package/dist/doctor/checks/session-export.d.ts +21 -0
  58. package/dist/doctor/checks/session-export.d.ts.map +1 -0
  59. package/dist/doctor/checks/session-export.js +62 -0
  60. package/dist/doctor/checks/session-export.js.map +1 -0
  61. package/dist/doctor/checks/telemetry.d.ts +15 -28
  62. package/dist/doctor/checks/telemetry.d.ts.map +1 -1
  63. package/dist/doctor/checks/telemetry.js +34 -54
  64. package/dist/doctor/checks/telemetry.js.map +1 -1
  65. package/dist/doctor/checks/vault.d.ts +4 -20
  66. package/dist/doctor/checks/vault.d.ts.map +1 -1
  67. package/dist/doctor/checks/vault.js +58 -19
  68. package/dist/doctor/checks/vault.js.map +1 -1
  69. package/dist/doctor/registry.d.ts.map +1 -1
  70. package/dist/doctor/registry.js +13 -6
  71. package/dist/doctor/registry.js.map +1 -1
  72. package/dist/index.d.ts +3 -2
  73. package/dist/index.d.ts.map +1 -1
  74. package/dist/index.js +3 -2
  75. package/dist/index.js.map +1 -1
  76. package/dist/integrations/files/attachment-store.d.ts +44 -0
  77. package/dist/integrations/files/attachment-store.d.ts.map +1 -0
  78. package/dist/integrations/files/attachment-store.js +86 -0
  79. package/dist/integrations/files/attachment-store.js.map +1 -0
  80. package/dist/integrations/providers/credential-provider.d.ts +39 -0
  81. package/dist/integrations/providers/credential-provider.d.ts.map +1 -0
  82. package/dist/integrations/providers/credential-provider.js +74 -0
  83. package/dist/integrations/providers/credential-provider.js.map +1 -0
  84. package/dist/integrations/providers/discover.d.ts.map +1 -1
  85. package/dist/integrations/providers/discover.js +15 -3
  86. package/dist/integrations/providers/discover.js.map +1 -1
  87. package/dist/integrations/providers/oauth.d.ts.map +1 -1
  88. package/dist/integrations/providers/oauth.js +24 -1
  89. package/dist/integrations/providers/oauth.js.map +1 -1
  90. package/dist/integrations/sessions/store.d.ts +2 -2
  91. package/dist/integrations/sessions/store.d.ts.map +1 -1
  92. package/dist/integrations/sessions/store.js +21 -9
  93. package/dist/integrations/sessions/store.js.map +1 -1
  94. package/dist/integrations/subagents/runtime.d.ts +3 -3
  95. package/dist/integrations/subagents/runtime.d.ts.map +1 -1
  96. package/dist/integrations/subagents/runtime.js +11 -11
  97. package/dist/integrations/subagents/runtime.js.map +1 -1
  98. package/dist/integrations/telemetry/session-export.d.ts +99 -0
  99. package/dist/integrations/telemetry/session-export.d.ts.map +1 -0
  100. package/dist/integrations/telemetry/session-export.js +119 -0
  101. package/dist/integrations/telemetry/session-export.js.map +1 -0
  102. package/dist/logging.d.ts +79 -0
  103. package/dist/logging.d.ts.map +1 -0
  104. package/dist/logging.js +67 -0
  105. package/dist/logging.js.map +1 -0
  106. package/dist/permissions/rules.d.ts +3 -3
  107. package/dist/permissions/rules.d.ts.map +1 -1
  108. package/dist/permissions/rules.js +1 -1
  109. package/dist/permissions/rules.js.map +1 -1
  110. package/dist/skills/store.d.ts +1 -1
  111. package/dist/skills/store.js +1 -1
  112. package/dist/tui/App.d.ts.map +1 -1
  113. package/dist/tui/App.js +92 -6
  114. package/dist/tui/App.js.map +1 -1
  115. package/dist/tui/StatusBar.d.ts +1 -1
  116. package/dist/tui/StatusBar.d.ts.map +1 -1
  117. package/dist/tui/agent.d.ts +54 -24
  118. package/dist/tui/agent.d.ts.map +1 -1
  119. package/dist/tui/agent.js +327 -124
  120. package/dist/tui/agent.js.map +1 -1
  121. package/dist/tui/index.d.ts.map +1 -1
  122. package/dist/tui/index.js +17 -6
  123. package/dist/tui/index.js.map +1 -1
  124. package/dist/tui/log-pane.d.ts +48 -0
  125. package/dist/tui/log-pane.d.ts.map +1 -0
  126. package/dist/tui/log-pane.js +106 -0
  127. package/dist/tui/log-pane.js.map +1 -0
  128. package/dist/tui/slashCommands.d.ts +134 -11
  129. package/dist/tui/slashCommands.d.ts.map +1 -1
  130. package/dist/tui/slashCommands.js +169 -15
  131. package/dist/tui/slashCommands.js.map +1 -1
  132. package/dist/tui/types.d.ts +11 -2
  133. package/dist/tui/types.d.ts.map +1 -1
  134. package/package.json +8 -6
@@ -29,7 +29,9 @@
29
29
  * was written back to the Keychain would be a no-op off macOS, leaving the
30
30
  * real store holding a token that is refreshed again on every launch.
31
31
  */
32
- import { readStoredSubscriptionCredential, writeStoredSubscriptionCredential, } from './credential-store.js';
32
+ import { buildProbeContext, probe } from '@namzu/sdk';
33
+ import { SUBSCRIPTION_CREDENTIAL_REF } from './credential-provider.js';
34
+ import { credentialsPath, readStoredSubscriptionCredential, writeStoredSubscriptionCredential, } from './credential-store.js';
33
35
  import { OAUTH_CLIENT_ID, OAUTH_TOKEN_URL } from './identity.js';
34
36
  import { readAgentKeychainCredential, writeAgentKeychainCredential, } from './keychain.js';
35
37
  /** Refresh a few seconds early so an about-to-expire token isn't used. */
@@ -79,6 +81,23 @@ export async function ensureFreshAnthropicToken(accessToken, oauth) {
79
81
  * the token is already in hand and usable for this session, so a store that
80
82
  * will not take it costs a re-refresh next launch, not the session.
81
83
  */
84
+ /**
85
+ * Say that a credential turned over, without saying what it turned into.
86
+ *
87
+ * Through the probe registry that already carries `vault_lookup`, because a
88
+ * second bus means a subscriber that sees lookups and not rotations, or the
89
+ * reverse, depending on which one it happened to find.
90
+ */
91
+ function announceRotation(replaced) {
92
+ probe.dispatch({
93
+ type: 'vault_credential_changed',
94
+ kind: replaced ? 'rotated' : 'set',
95
+ source: credentialsPath(),
96
+ // The NAME. This event exists to be logged and retained, which is
97
+ // exactly what the value must not be.
98
+ ref: SUBSCRIPTION_CREDENTIAL_REF,
99
+ }, buildProbeContext());
100
+ }
82
101
  function persistRefreshed(cred, origin) {
83
102
  if (origin === 'keychain') {
84
103
  writeAgentKeychainCredential(cred);
@@ -86,6 +105,10 @@ function persistRefreshed(cred, origin) {
86
105
  }
87
106
  try {
88
107
  writeStoredSubscriptionCredential(cred);
108
+ // Announced only after the store proved the file private. A rotation
109
+ // event for a write that refused would have a reader chasing a
110
+ // credential turn-over that never happened.
111
+ announceRotation(cred.accessToken !== undefined);
89
112
  }
90
113
  catch {
91
114
  // The store refused to prove the file private and therefore wrote
@@ -1 +1 @@
1
- {"version":3,"file":"oauth.js","sourceRoot":"","sources":["../../../src/integrations/providers/oauth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,EACN,gCAAgC,EAChC,iCAAiC,GACjC,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAChE,OAAO,EAEN,2BAA2B,EAC3B,4BAA4B,GAC5B,MAAM,eAAe,CAAA;AAEtB,0EAA0E;AAC1E,MAAM,cAAc,GAAG,MAAM,CAAA;AAE7B;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,0BAA0B,CAAC,MAAwB;IAClE,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,gCAAgC,EAAE,CAAC,CAAC,CAAC,2BAA2B,EAAE,CAAA;AAChG,CAAC;AAYD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAC9C,WAAmB,EACnB,KAAoB;IAEpB,MAAM,KAAK,GAAG,KAAK,CAAC,SAAS,KAAK,SAAS,IAAI,KAAK,CAAC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EAAsE;QACtE,kEAAkE;IACnE,CAAC;AACF,CAAC;AAED,+EAA+E;AAC/E,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC3C,YAAoB;IAEpB,IAAI,CAAC;QACJ,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,eAAe,EAAE;YACxC,MAAM,EAAE,MAAM;YACd,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;YAC/C,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;gBACpB,UAAU,EAAE,eAAe;gBAC3B,aAAa,EAAE,YAAY;gBAC3B,SAAS,EAAE,eAAe;aAC1B,CAAC;SACF,CAAC,CAAA;QACF,IAAI,CAAC,GAAG,CAAC,EAAE;YAAE,OAAO,IAAI,CAAA;QACxB,MAAM,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAI7B,CAAA;QACD,IAAI,OAAO,IAAI,CAAC,YAAY,KAAK,QAAQ,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,IAAI,CAAA;QACxF,OAAO;YACN,WAAW,EAAE,IAAI,CAAC,YAAY;YAC9B,YAAY,EAAE,OAAO,IAAI,CAAC,aAAa,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,YAAY;YACxF,SAAS,EACR,OAAO,IAAI,CAAC,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC,CAAC,CAAC,SAAS;SACvF,CAAA;IACF,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,IAAI,CAAA;IACZ,CAAC;AACF,CAAC"}
@@ -10,11 +10,11 @@
10
10
  * `<cwd>/.namzu`, the same root `query()` writes its runs under, so a
11
11
  * session's `session.json` and its `runs/` live in one place.
12
12
  */
13
- import { DiskSessionStore, type Message, type ProjectId, type SessionId, type TenantId, type ThreadId } from '@namzu/sdk';
13
+ import { DiskSessionStore, type Message, type ProjectId, type SessionId, type TenantId, type TopicId } from '@namzu/sdk';
14
14
  export interface CliSessions {
15
15
  readonly store: DiskSessionStore;
16
16
  readonly projectId: ProjectId;
17
- readonly threadId: ThreadId;
17
+ readonly topicId: TopicId;
18
18
  readonly tenantId: TenantId;
19
19
  /** Absolute path of the cwd's `.namzu` root (where pointers live). */
20
20
  readonly root: string;
@@ -1 +1 @@
1
- {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../src/integrations/sessions/store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,EACN,gBAAgB,EAChB,KAAK,OAAO,EACZ,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,QAAQ,EACb,KAAK,QAAQ,EAGb,MAAM,YAAY,CAAA;AAKnB,MAAM,WAAW,WAAW;IAC3B,QAAQ,CAAC,KAAK,EAAE,gBAAgB,CAAA;IAChC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAA;IAC7B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAA;IAC3B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAA;IAC3B,sEAAsE;IACtE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CACrB;AAED,MAAM,WAAW,kBAAkB;IAClC,QAAQ,CAAC,EAAE,EAAE,SAAS,CAAA;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CACtB;AAED;;;;GAIG;AACH,wBAAsB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAsBpE;AAgBD;;;;;GAKG;AACH,wBAAsB,mBAAmB,CAAC,CAAC,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAWzF;AAED;;;;;;;;;;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AACH,wBAAsB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CA4BpE;AAgBD;;;;;GAKG;AACH,wBAAsB,mBAAmB,CAAC,CAAC,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAezF;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,iBAAiB,CAAC,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,SAAS,CAAC,CAO1E;AAED,oDAAoD;AACpD,wBAAsB,cAAc,CACnC,CAAC,EAAE,WAAW,EACd,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,SAAS,OAAO,EAAE,GAC1B,OAAO,CAAC,IAAI,CAAC,CAIf;AAED,kDAAkD;AAClD,wBAAsB,gBAAgB,CAAC,CAAC,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAE/F;AAED,6EAA6E;AAC7E,wBAAsB,UAAU,CAAC,CAAC,EAAE,WAAW,EAAE,KAAK,SAAK,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAc1F"}
@@ -12,9 +12,11 @@
12
12
  */
13
13
  import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
14
14
  import { join } from 'node:path';
15
- import { DiskSessionStore, UNKNOWN_TENANT_ID, requireOpenProject, } from '@namzu/sdk';
15
+ import { DiskSessionStore, UNKNOWN_TENANT_ID, asProjectId, asSessionId, asTopicId, requireOpenProject, } from '@namzu/sdk';
16
+ // `UNKNOWN_TENANT_ID` is already a `TenantId`; the assertion this replaced
17
+ // re-stated a type the constant carries.
16
18
  const TENANT = UNKNOWN_TENANT_ID;
17
- const THREAD = 'thd_namzu-cli';
19
+ const THREAD = asTopicId('top_namzu-cli');
18
20
  /**
19
21
  * Open (or initialize) the cwd's CLI project. Returns the handle used by
20
22
  * the other helpers. Throws only on unexpected store errors; callers treat
@@ -27,8 +29,13 @@ export async function openSessions(cwd) {
27
29
  let projectId;
28
30
  try {
29
31
  const ptr = JSON.parse(readFileSync(pointerPath, 'utf8'));
30
- if (typeof ptr.projectId === 'string')
31
- projectId = ptr.projectId;
32
+ // Prefix-checked, and a bad pointer is treated exactly like a stale one:
33
+ // the next lines already drop a projectId whose directory is gone, so a
34
+ // hand-edited `cli.json` takes the same path instead of carrying a
35
+ // non-id into a store lookup.
36
+ if (typeof ptr.projectId === 'string' && ptr.projectId.startsWith('prj_')) {
37
+ projectId = asProjectId(ptr.projectId);
38
+ }
32
39
  }
33
40
  catch {
34
41
  // no pointer yet
@@ -42,7 +49,7 @@ export async function openSessions(cwd) {
42
49
  mkdirSync(root, { recursive: true });
43
50
  writeFileSync(pointerPath, `${JSON.stringify({ projectId }, null, 2)}\n`, { mode: 0o600 });
44
51
  }
45
- return { store, projectId, threadId: THREAD, tenantId: TENANT, root };
52
+ return { store, projectId, topicId: THREAD, tenantId: TENANT, root };
46
53
  }
47
54
  // Maps an embedder's own session key (e.g. a desktop host's uuid) to a
48
55
  // namzu conversation id, so reopening that session resumes the same
@@ -66,8 +73,13 @@ function readDesktopMap(root) {
66
73
  export async function resolveConversation(s, key) {
67
74
  const map = readDesktopMap(s.root);
68
75
  const existing = map[key];
69
- if (existing && (await s.store.getSession(existing, s.tenantId))) {
70
- return existing;
76
+ // Same treatment as the project pointer above: a mapped id that is not an
77
+ // id is indistinguishable from one whose session was wiped, and this
78
+ // function already knows what to do about that — mint a fresh one.
79
+ if (existing?.startsWith('ses_')) {
80
+ const mapped = asSessionId(existing);
81
+ if (await s.store.getSession(mapped, s.tenantId))
82
+ return mapped;
71
83
  }
72
84
  const id = await startConversation(s);
73
85
  map[key] = id;
@@ -92,7 +104,7 @@ export async function resolveConversation(s, key) {
92
104
  */
93
105
  export async function startConversation(s) {
94
106
  await requireOpenProject(s.store, s.projectId, s.tenantId, 'cli-session');
95
- const session = await s.store.createSession({ threadId: s.threadId, projectId: s.projectId, currentActor: null }, s.tenantId);
107
+ const session = await s.store.createSession({ topicId: s.topicId, projectId: s.projectId, currentActor: null }, s.tenantId);
96
108
  return session.id;
97
109
  }
98
110
  /** Append messages (in order) to a conversation. */
@@ -107,7 +119,7 @@ export async function loadConversation(s, sessionId) {
107
119
  }
108
120
  /** Recent non-empty conversations, newest first — for the `/resume` list. */
109
121
  export async function listRecent(s, limit = 20) {
110
- const sessions = await s.store.listSessions(s.threadId, s.tenantId);
122
+ const sessions = await s.store.listSessionsByTopic(s.topicId, s.tenantId);
111
123
  const out = [];
112
124
  for (const sess of sessions) {
113
125
  const messages = await s.store.loadMessages(sess.id, s.tenantId);
@@ -1 +1 @@
1
- {"version":3,"file":"store.js","sourceRoot":"","sources":["../../../src/integrations/sessions/store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAChE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EACN,gBAAgB,EAMhB,iBAAiB,EACjB,kBAAkB,GAClB,MAAM,YAAY,CAAA;AAEnB,MAAM,MAAM,GAAG,iBAA6B,CAAA;AAC5C,MAAM,MAAM,GAAG,eAA2B,CAAA;AAkB1C;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,GAAW;IAC7C,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAA;IAChC,MAAM,KAAK,GAAG,IAAI,gBAAgB,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAA;IACrD,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,CAAA;IAE1C,IAAI,SAAgC,CAAA;IACpC,IAAI,CAAC;QACJ,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,WAAW,EAAE,MAAM,CAAC,CAA2B,CAAA;QACnF,IAAI,OAAO,GAAG,CAAC,S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;AAED,SAAS,iBAAiB,CAAC,QAA4B;IACtD,MAAM,SAAS,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,CAAA;IACzD,MAAM,GAAG,GAAG,OAAO,SAAS,EAAE,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,cAAc,CAAA;IACvF,MAAM,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAA;IAC5C,OAAO,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,IAAI,cAAc,CAAA;AAC3E,CAAC;AAED,SAAS,KAAK,CAAC,KAAc;IAC5B,IAAI,KAAK,YAAY,IAAI;QAAE,OAAO,KAAK,CAAC,WAAW,EAAE,CAAA;IACrD,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAA;AACrE,CAAC"}
@@ -11,7 +11,7 @@
11
11
  * store backs the AgentManager, so sub-agent bookkeeping never touches the
12
12
  * CLI's on-disk `/resume` conversation store.
13
13
  */
14
- import { type LLMProvider, type RunEvent, type TaskGateway, type ToolDefinition, type ToolRegistryContract, type VerificationGateConfig } from '@namzu/sdk';
14
+ import { type AuthorizationGateConfig, type LLMProvider, type RunEvent, type TaskScheduler, type ToolDefinition, type ToolRegistryContract } from '@namzu/sdk';
15
15
  export declare const GENERAL_PURPOSE_SUBAGENT = "general-purpose";
16
16
  export interface SubagentRuntimeOptions {
17
17
  readonly cwd: string;
@@ -20,7 +20,7 @@ export interface SubagentRuntimeOptions {
20
20
  readonly buildProvider: () => LLMProvider;
21
21
  /** Build the sub-agent's tool registry (its own working set). */
22
22
  readonly buildTools: () => ToolRegistryContract;
23
- readonly verificationGate?: VerificationGateConfig;
23
+ readonly verificationGate?: AuthorizationGateConfig;
24
24
  /**
25
25
  * The project's own instruction block, already composed, or absent when the
26
26
  * working directory declares none.
@@ -46,7 +46,7 @@ export interface SubagentRuntimeOptions {
46
46
  readonly onEvent?: (event: RunEvent) => void;
47
47
  }
48
48
  export interface SubagentRuntime {
49
- readonly gateway: TaskGateway;
49
+ readonly gateway: TaskScheduler;
50
50
  readonly agentTool: ToolDefinition;
51
51
  readonly allowedAgentIds: readonly string[];
52
52
  }
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../src/integrations/subagents/runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAYN,KAAK,WAAW,EAIhB,KAAK,QAAQ,EAIb,KAAK,WAAW,EAGhB,KAAK,cAAc,EACnB,KAAK,oBAAoB,EAEzB,KAAK,sBAAsB,EAI3B,MAAM,YAAY,CAAA;AAEnB,eAAO,MAAM,wBAAwB,oBAAoB,CAAA;AAczD,MAAM,WAAW,sBAAsB;IACtC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,yEAAyE;IACzE,QAAQ,CAAC,aAAa,EAAE,MAAM,WAAW,CAAA;IACzC,iEAAiE;IACjE,QAAQ,CAAC,UAAU,EAAE,MAAM,oBAAoB,CAAA;IAC/C,QAAQ,CAAC,gBAAgB,CAAC,EAAE,sBAAsB,CAAA;IAClD;;;;;;;;;OASG;IACH,QAAQ,CAAC,mBAAmB,CAAC,EAAE,MAAM,CAAA;IACrC;;;;;;;;OAQG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAA;IAChD,4EAA4E;IAC5E,QAAQ,CAAC,OAAO,CAAC,EAAE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Q,CAAC,OAAO,EAAE,aAAa,CAAA;IAC/B,QAAQ,CAAC,SAAS,EAAE,cAAc,CAAA;IAClC,QAAQ,CAAC,eAAe,EAAE,SAAS,MAAM,EAAE,CAAA;CAC3C;AAED;;;GAGG;AACH,wBAAsB,qBAAqB,CAC1C,IAAI,EAAE,sBAAsB,GAC1B,OAAO,CAAC,eAAe,CAAC,CA4J1B"}
@@ -11,7 +11,7 @@
11
11
  * store backs the AgentManager, so sub-agent bookkeeping never touches the
12
12
  * CLI's on-disk `/resume` conversation store.
13
13
  */
14
- import { AgentManager, AgentRegistry, DefaultCapacityValidator, InMemorySessionStore, InMemoryThreadStore, LocalTaskGateway, ReactiveAgent, SessionSummaryMaterializer, ThreadManager, WorkspaceBackendRegistry, defineTool, mcpJsonSchemaToZod, } from '@namzu/sdk';
14
+ import { AgentManager, AgentRegistry, DefaultCapacityValidator, InMemorySessionStore, InMemoryTopicStore, LocalTaskScheduler, ReactiveAgent, SessionSummaryMaterializer, TopicManager, WorkspaceBackendRegistry, asRunId, asSummaryId, asTenantId, asUserId, defineTool, mcpJsonSchemaToZod, } from '@namzu/sdk';
15
15
  export const GENERAL_PURPOSE_SUBAGENT = 'general-purpose';
16
16
  const SUBAGENT_PROMPT = [
17
17
  'You are a focused sub-agent dispatched by namzu to complete one self-contained task and report back.',
@@ -29,12 +29,12 @@ const SUBAGENT_PROMPT = [
29
29
  * register on the parent and the gateway to pass to `query({ taskGateway })`.
30
30
  */
31
31
  export async function createSubagentRuntime(opts) {
32
- const tenantId = 'tnt_namzu-cli';
32
+ const tenantId = asTenantId('tnt_namzu-cli');
33
33
  const store = new InMemorySessionStore();
34
- const threadStore = new InMemoryThreadStore();
35
- const userActor = { kind: 'user', userId: 'usr_namzu', tenantId };
34
+ const topicStore = new InMemoryTopicStore();
35
+ const userActor = { kind: 'user', userId: asUserId('usr_namzu'), tenantId };
36
36
  const project = await store.createProject({ tenantId, name: 'namzu-cli' }, tenantId);
37
- const thread = await threadStore.createThread({ projectId: project.id, title: 'namzu-cli' }, tenantId);
37
+ const thread = await topicStore.createTopic({ projectId: project.id, title: 'namzu-cli' }, tenantId);
38
38
  // No workspace gate here, and that is a finding rather than an omission.
39
39
  //
40
40
  // A direct `createSession` bypasses `requireOpenProject`, which is why the
@@ -48,16 +48,16 @@ export async function createSubagentRuntime(opts) {
48
48
  //
49
49
  // The trigger to add one is the day this store is replaced by a persistent
50
50
  // one, or the project id starts arriving from a caller.
51
- const parentSession = await store.createSession({ threadId: thread.id, projectId: project.id, currentActor: userActor }, tenantId);
51
+ const parentSession = await store.createSession({ topicId: thread.id, projectId: project.id, currentActor: userActor }, tenantId);
52
52
  await store.updateSession({ ...parentSession, status: 'active' }, tenantId);
53
53
  let summaryCounter = 0;
54
54
  const materializer = new SessionSummaryMaterializer({
55
55
  store,
56
- generateSummaryId: () => `sum_namzu_${++summaryCounter}`,
56
+ generateSummaryId: () => asSummaryId(`sum_namzu_${++summaryCounter}`),
57
57
  });
58
58
  const registry = new AgentRegistry();
59
59
  registry.register(buildDefinition(GENERAL_PURPOSE_SUBAGENT, 'A general-purpose sub-agent.', SUBAGENT_PROMPT, opts));
60
- const threadManager = new ThreadManager({ threadStore, sessionStore: store });
60
+ const threadManager = new TopicManager({ topicStore, sessionStore: store });
61
61
  const manager = new AgentManager(registry, undefined, {
62
62
  sessionStore: store,
63
63
  summaryMaterializer: materializer,
@@ -66,18 +66,18 @@ export async function createSubagentRuntime(opts) {
66
66
  threadManager,
67
67
  });
68
68
  const taskContext = {
69
- parentRunId: 'run_namzu-cli',
69
+ parentRunId: asRunId('run_namzu-cli'),
70
70
  parentAgentId: 'namzu',
71
71
  parentAbortController: new AbortController(),
72
72
  depth: 0,
73
73
  budgetTracker: { total: 1_000_000, remaining: 1_000_000 },
74
74
  tenantId,
75
- threadId: thread.id,
75
+ topicId: thread.id,
76
76
  sessionId: parentSession.id,
77
77
  projectId: project.id,
78
78
  parentActor: userActor,
79
79
  };
80
- const gateway = new LocalTaskGateway(manager, taskContext, opts.onEvent);
80
+ const gateway = new LocalTaskScheduler(manager, taskContext, opts.onEvent);
81
81
  // Dynamic `Agent` tool: the model passes an optional `role` (the persona /
82
82
  // system prompt) and we register + spawn a fresh specialist for it at call
83
83
  // time — no pre-defined agent file needed. Omit `role` → general-purpose.
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../../src/integrations/subagents/runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAGN,YAAY,EACZ,aAAa,EAKb,wBAAwB,EACxB,oBAAoB,EACpB,mBAAmB,EAEnB,gBAAgB,EAChB,aAAa,EAIb,0BAA0B,EAI1B,aAAa,EAKb,wBAAwB,EACxB,UAAU,EACV,kBAAkB,GAClB,MAAM,YAAY,CAAA;AAEnB,MAAM,CAAC,MAAM,wBAAwB,GAAG,iBAAiB,CAAA;AAEzD,MAAM,eAAe,GAAG;IACvB,sGAAsG;IACtG,oFAAoF;IACpF,2HAA2H;IAC3H,8FAA8F;IAC9F,EAAE;IACF,4EAA4E;IAC5E,+HAA+H;IAC/H,sKAAsK;IACtK,mGAAmG;CACnG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAyCZ;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAC1C,IAA4B;IAE5B,MAAM,QAAQ,GAAG,eAA2B,CAAA;IAC5C,MAAM,KAAK,GAAG,IAAI,oBAAoB,EAAE,CAAA;IACxC,MAAM,WAAW,GAAG,IAAI,mBAAmB,EAAE,CAAA;IAE7C,MAAM,SAAS,GAAa,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,WAAqB,EAAE,QAAQ,EAAE,CAAA;IACrF,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,aAAa,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,QAAQ,CAAC,CAAA;IACpF,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,YAAY,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CAAA;QACF,CAAC;KACD,CAAA;AACF,CAAC"}
@@ -0,0 +1,99 @@
1
+ import type { RunEventListener } from '@namzu/sdk';
2
+ import type { SessionExportConfig } from '../../config/schema.js';
3
+ /**
4
+ * Turning `telemetry.sessionExport` in a config file into a live listener.
5
+ *
6
+ * Two things this file is careful about, and both are the reason it exists
7
+ * rather than the wiring being inline at the call site.
8
+ *
9
+ * **`@namzu/telemetry` is optional, and its absence is a REFUSAL here.**
10
+ * Everywhere else in this CLI an absent optional package degrades a feature:
11
+ * no sandbox package, no sandbox, say so and continue. Not here. An operator
12
+ * who wrote `sessionExport` into a config asked for a session to be
13
+ * recorded, and continuing without it means the run happens and the record
14
+ * they were counting on does not exist — the failure is invisible until the
15
+ * moment they go looking for the session that was supposed to be there.
16
+ *
17
+ * **The redaction chain is never silently empty.** Omitting `redactors`
18
+ * installs the shipped secret redactor. Turning redaction off takes an
19
+ * explicit `redactors: []`, because reaching "no redaction" by forgetting a
20
+ * key is the shape this whole seam exists to prevent.
21
+ */
22
+ /** What the CLI needs back: a listener to attach, and a way to drain it. */
23
+ export interface AttachedSessionExport {
24
+ readonly listener: RunEventListener;
25
+ /** Flush before the process exits. */
26
+ shutdown(): Promise<void>;
27
+ /** The sentence to show a user — `describeSessionExport`'s output. */
28
+ readonly disclosure: string;
29
+ }
30
+ /** Why a configured export could not be started. */
31
+ export declare class SessionExportUnavailableError extends Error {
32
+ readonly reason: 'absent' | 'broken';
33
+ constructor(reason: 'absent' | 'broken', cause?: string);
34
+ }
35
+ /** The slice of `@namzu/telemetry` this uses. Structural, so a test needs no install. */
36
+ interface TelemetryModule {
37
+ createSessionExportListener(config: {
38
+ sink: {
39
+ emit(record: unknown): void;
40
+ shutdown(): Promise<void>;
41
+ };
42
+ destination: string;
43
+ eventTypes?: readonly string[];
44
+ redactors?: readonly ((record: unknown) => unknown)[];
45
+ }): RunEventListener;
46
+ describeSessionExport(config?: unknown): string;
47
+ secretRedactor(): (record: unknown) => unknown;
48
+ }
49
+ export type TelemetryLoader = () => Promise<TelemetryModule>;
50
+ /**
51
+ * Load the optional package, separating "not installed" from "installed and
52
+ * unusable" the same way `context/capabilities.ts` does — and for the same
53
+ * reason: the two send a reader to different places.
54
+ *
55
+ * Takes the specifier so a test can drive the REAL resolution path with a
56
+ * name that cannot resolve. Everything else in this file is tested through
57
+ * an injected loader, which proves what `attachSessionExport` does with a
58
+ * refusal and proves nothing about where the refusal comes from — a
59
+ * mutation replacing this `throw` with a stub module survived until this was
60
+ * separated out.
61
+ */
62
+ export declare function loadTelemetryFrom(specifier: string): Promise<TelemetryModule>;
63
+ /**
64
+ * A JSONL file, one record per line.
65
+ *
66
+ * `appendFileSync` rather than a stream, and that is a deliberate trade: a
67
+ * stream would not block, but a stream's buffered tail is lost when the
68
+ * process exits on a signal, and the whole value of an exported session is
69
+ * that it survives the run that produced it. The listener already never
70
+ * waits on `emit` — the synchronous write happens inside a call the run does
71
+ * not await, so the cost lands on the exporting call and not on the model
72
+ * loop.
73
+ */
74
+ export declare function fileSink(destinationPath: string): {
75
+ emit(record: unknown): void;
76
+ shutdown(): Promise<void>;
77
+ };
78
+ export interface AttachSessionExportOptions {
79
+ readonly config: SessionExportConfig;
80
+ /** Injectable for tests; production resolves `@namzu/telemetry` itself. */
81
+ readonly loader?: TelemetryLoader;
82
+ /** Injectable for tests; production appends to the configured file. */
83
+ readonly sink?: {
84
+ emit(record: unknown): void;
85
+ shutdown(): Promise<void>;
86
+ };
87
+ }
88
+ export declare function attachSessionExport(options: AttachSessionExportOptions): Promise<AttachedSessionExport>;
89
+ /**
90
+ * The disclosure when export is NOT configured.
91
+ *
92
+ * Goes through the same function as the configured case so the two cannot
93
+ * drift into reading alike — which is the property
94
+ * `describeSessionExport`'s own test pins, and which is worth nothing if
95
+ * this branch hand-writes its own sentence instead.
96
+ */
97
+ export declare function describeSessionExportOff(loader?: TelemetryLoader): Promise<string | null>;
98
+ export {};
99
+ //# sourceMappingURL=session-export.d.ts.map
@@ -0,0 +1 @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;;;;;;;GAWG;AACH,wBAAsB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAcnF;AAOD;;;;;;;;;;GAUG;AACH,wBAAgB,QAAQ,CAAC,eAAe,EAAE,MAAM,GAAG;IAClD,IAAI,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAAA;IAC3B,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CACzB,CAeA;AAED,MAAM,WAAW,0BAA0B;IAC1C,QAAQ,CAAC,MAAM,EAAE,mBAAmB,CAAA;IACpC,2EAA2E;IAC3E,QAAQ,CAAC,MAAM,CAAC,EAAE,eAAe,CAAA;IACjC,uEAAuE;IACvE,QAAQ,CAAC,IAAI,CAAC,EAAE;QAAE,IAAI,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;QAAC,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;KAAE,CAAA;CAC1E;AAED,wBAAsB,mBAAmB,CACxC,OAAO,EAAE,0BAA0B,GACjC,OAAO,CAAC,qBAAqB,CAAC,CAyBhC;AAED;;;;;;;GAOG;AACH,wBAAsB,wBAAwB,CAAC,MAAM,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAU/F"}
@@ -0,0 +1,119 @@
1
+ import { appendFileSync, mkdirSync } from 'node:fs';
2
+ import { dirname, resolve } from 'node:path';
3
+ import { probeOptionalPackage } from '../../context/capabilities.js';
4
+ /** Why a configured export could not be started. */
5
+ export class SessionExportUnavailableError extends Error {
6
+ reason;
7
+ constructor(reason, cause) {
8
+ super(reason === 'absent'
9
+ ? 'telemetry.sessionExport is configured but "@namzu/telemetry" is not installed, so nothing would be recorded. Install it (npm i @namzu/telemetry), or remove telemetry.sessionExport from your config. Refusing rather than running a session whose export silently does not exist.'
10
+ : `telemetry.sessionExport is configured but "@namzu/telemetry" failed to load (${cause ?? 'no detail'}). Reinstall it, or remove telemetry.sessionExport from your config.`);
11
+ this.reason = reason;
12
+ this.name = 'SessionExportUnavailableError';
13
+ }
14
+ }
15
+ const TELEMETRY_SPECIFIER = '@namzu/telemetry';
16
+ /**
17
+ * Load the optional package, separating "not installed" from "installed and
18
+ * unusable" the same way `context/capabilities.ts` does — and for the same
19
+ * reason: the two send a reader to different places.
20
+ *
21
+ * Takes the specifier so a test can drive the REAL resolution path with a
22
+ * name that cannot resolve. Everything else in this file is tested through
23
+ * an injected loader, which proves what `attachSessionExport` does with a
24
+ * refusal and proves nothing about where the refusal comes from — a
25
+ * mutation replacing this `throw` with a stub module survived until this was
26
+ * separated out.
27
+ */
28
+ export async function loadTelemetryFrom(specifier) {
29
+ // Through the SAME probe the doctor and the boot narrative use, rather
30
+ // than a second resolution here. Two answers to "is @namzu/telemetry
31
+ // installed" is two chances to disagree, and the one that drifted would be
32
+ // the one deciding whether a session gets recorded.
33
+ //
34
+ // It also inherits the fix: `require.resolve` reports an installed
35
+ // ESM-only package as absent, which would have produced this refusal
36
+ // against a machine that was configured correctly.
37
+ const probe = await probeOptionalPackage(specifier);
38
+ if (probe.state === 'absent')
39
+ throw new SessionExportUnavailableError('absent');
40
+ if (probe.state === 'broken')
41
+ throw new SessionExportUnavailableError('broken', probe.error.message);
42
+ return (await import(specifier));
43
+ }
44
+ async function loadTelemetry(loader) {
45
+ if (loader)
46
+ return await loader();
47
+ return await loadTelemetryFrom(TELEMETRY_SPECIFIER);
48
+ }
49
+ /**
50
+ * A JSONL file, one record per line.
51
+ *
52
+ * `appendFileSync` rather than a stream, and that is a deliberate trade: a
53
+ * stream would not block, but a stream's buffered tail is lost when the
54
+ * process exits on a signal, and the whole value of an exported session is
55
+ * that it survives the run that produced it. The listener already never
56
+ * waits on `emit` — the synchronous write happens inside a call the run does
57
+ * not await, so the cost lands on the exporting call and not on the model
58
+ * loop.
59
+ */
60
+ export function fileSink(destinationPath) {
61
+ const path = resolve(destinationPath);
62
+ let ensured = false;
63
+ return {
64
+ emit(record) {
65
+ if (!ensured) {
66
+ mkdirSync(dirname(path), { recursive: true });
67
+ ensured = true;
68
+ }
69
+ appendFileSync(path, `${JSON.stringify(record)}\n`, 'utf-8');
70
+ },
71
+ // Nothing is buffered, so there is nothing to drain — and saying so is
72
+ // better than an empty function that reads as an unfinished one.
73
+ shutdown: async () => { },
74
+ };
75
+ }
76
+ export async function attachSessionExport(options) {
77
+ const telemetry = await loadTelemetry(options.loader);
78
+ const sink = options.sink ?? fileSink(options.config.destination);
79
+ // Omitted means the shipped redactor; `[]` means none. A config reaches
80
+ // "no redaction" only by saying so.
81
+ const redactors = (options.config.redactors ?? ['secrets']).map((name) => {
82
+ switch (name) {
83
+ case 'secrets':
84
+ return telemetry.secretRedactor();
85
+ }
86
+ });
87
+ const exportConfig = {
88
+ sink,
89
+ destination: options.config.destination,
90
+ ...(options.config.eventTypes !== undefined ? { eventTypes: options.config.eventTypes } : {}),
91
+ redactors,
92
+ };
93
+ return {
94
+ listener: telemetry.createSessionExportListener(exportConfig),
95
+ shutdown: () => sink.shutdown(),
96
+ disclosure: telemetry.describeSessionExport(exportConfig),
97
+ };
98
+ }
99
+ /**
100
+ * The disclosure when export is NOT configured.
101
+ *
102
+ * Goes through the same function as the configured case so the two cannot
103
+ * drift into reading alike — which is the property
104
+ * `describeSessionExport`'s own test pins, and which is worth nothing if
105
+ * this branch hand-writes its own sentence instead.
106
+ */
107
+ export async function describeSessionExportOff(loader) {
108
+ try {
109
+ const telemetry = await loadTelemetry(loader);
110
+ return telemetry.describeSessionExport();
111
+ }
112
+ catch {
113
+ // `@namzu/telemetry` absent AND export unconfigured is the ordinary
114
+ // case, not a problem: there is nothing to disclose because there is
115
+ // nothing installed that could export.
116
+ return null;
117
+ }
118
+ }
119
+ //# sourceMappingURL=session-export.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-export.js","sourceRoot":"","sources":["../../../src/integrations/telemetry/session-export.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,SAAS,EAA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EAAE,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC7F,SAAS;KACT,CAAA;IAED,OAAO;QACN,QAAQ,EAAE,SAAS,CAAC,2BAA2B,CAAC,YAAY,CAAC;QAC7D,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE;QAC/B,UAAU,EAAE,SAAS,CAAC,qBAAqB,CAAC,YAAY,CAAC;KACzD,CAAA;AACF,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAAC,MAAwB;IACtE,IAAI,CAAC;QACJ,MAAM,SAAS,GAAG,MAAM,aAAa,CAAC,MAAM,CAAC,CAAA;QAC7C,OAAO,SAAS,CAAC,qBAAqB,EAAE,CAAA;IACzC,CAAC;IAAC,MAAM,CAAC;QACR,oEAAoE;QACpE,qEAAqE;QACrE,uCAAuC;QACvC,OAAO,IAAI,CAAA;IACZ,CAAC;AACF,CAAC"}
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Log level + format resolution for the CLI's five entry points that used
3
+ * to force the SDK logger's level to `silent` via `configureLogger` and
4
+ * never turn it back on: `tui/index.tsx`, `commands/run.ts`,
5
+ * `commands/drain.ts` and `commands/run-stream.ts` (twice — `run-stream`
6
+ * itself and `providers-json`). LOG-05.
7
+ *
8
+ * Kept out of `config/load.ts`'s cascade on purpose. That system merges
9
+ * four sources for `format`/`quiet`/`permissions`/`sandbox`, all of them
10
+ * either boolean or a closed enum with a config-file counterpart.
11
+ * `NAMZU_LOG_LEVEL` has no config-file counterpart in this increment and is
12
+ * not boolean-shaped — it names a level directly, string-valued, the same
13
+ * way `--verbose`/`--quiet` do. Precedence here is exactly what the design
14
+ * specifies and nothing more: an explicit flag beats the environment beats
15
+ * the default that used to be silence.
16
+ */
17
+ import type { LevelFilter, LogSink } from '@namzu/sdk';
18
+ export type LogFormat = 'pretty' | 'json';
19
+ /** What every entry point installs as its process sink, resolved once per
20
+ * invocation in `cli.ts#getContext()` and threaded through
21
+ * `CommandContext`/`TuiContext`. */
22
+ export interface ResolvedLogging {
23
+ readonly level: LevelFilter;
24
+ readonly format: LogFormat;
25
+ }
26
+ export interface LogLevelFlags {
27
+ /** `-v, --verbose` as Commander parsed it — `undefined` unless given. */
28
+ readonly verbose?: boolean;
29
+ /**
30
+ * `-q, --quiet` as Commander parsed it — `undefined` unless given.
31
+ * Reuses the CLI's existing global flag rather than minting a second
32
+ * "quiet" that means something different depending which one you typed.
33
+ */
34
+ readonly quiet?: boolean;
35
+ }
36
+ /**
37
+ * `--verbose` -> `debug`, `--quiet` -> `warn`, otherwise `NAMZU_LOG_LEVEL`
38
+ * if it names a real level, otherwise `info` — the floor that used to be
39
+ * silence.
40
+ *
41
+ * `cli.ts` declares `--verbose` and `--quiet` as a `.conflicts()`-paired
42
+ * pair of Commander options, so through the CLI itself at most one of
43
+ * `flags.verbose` / `flags.quiet` is ever true at once. The `verbose`-first
44
+ * check below is what a caller that builds `LogLevelFlags` by hand — every
45
+ * test in `logging.test.ts` — gets instead of relying on that invariant.
46
+ */
47
+ export declare function resolveLogLevel(flags: LogLevelFlags, env?: NodeJS.ProcessEnv): LevelFilter;
48
+ export interface LogFormatFlags {
49
+ /**
50
+ * `--log-format <pretty|json>`. Commander's `.choices(['pretty','json'])`
51
+ * already rejects anything else at parse time, so `undefined` is the
52
+ * only other value `cli.ts` can hand this. Re-checked below anyway
53
+ * because a caller building this by hand (every test in
54
+ * `logging.test.ts`) is not bound by what Commander would have refused.
55
+ */
56
+ readonly logFormat?: string;
57
+ }
58
+ export declare function resolveLogFormat(flags: LogFormatFlags, env?: NodeJS.ProcessEnv): LogFormat;
59
+ /**
60
+ * The sink `run`/`drain` install, chosen by `--log-format`/
61
+ * `NAMZU_LOG_FORMAT`. `run-stream` does NOT use this — its stderr is a
62
+ * machine-read NDJSON channel regardless of the format flag, the same way
63
+ * its stdout protocol is unaffected by anything the operator passes. See
64
+ * `commands/run-stream.ts`.
65
+ */
66
+ export declare function createStderrSink(format: LogFormat): LogSink;
67
+ /**
68
+ * Falls back to the same resolution `cli.ts#getContext()` would have
69
+ * produced with no flags and the live environment, for a `ctx`/`TuiContext`
70
+ * a test built by hand without a `logging` field — a fixture omitting a
71
+ * field it does not care about must not crash the handler it exercises.
72
+ * Every production `ctx` carries `logging`; only a test double hits the
73
+ * fallback, and `test-setup.ts` defaults `NAMZU_LOG_LEVEL` to `silent` so
74
+ * that fallback stays quiet unless a test deliberately overrides it.
75
+ */
76
+ export declare function contextLogging(ctx: {
77
+ readonly logging?: ResolvedLogging;
78
+ }): ResolvedLogging;
79
+ //# sourceMappingURL=logging.d.ts.map