@cchistory/lite 0.9.0 → 0.9.1

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 (175) hide show
  1. package/INSTALL.md +1 -1
  2. package/apps/lite-cli/dist/agent-contract.d.ts.map +1 -1
  3. package/apps/lite-cli/dist/agent-contract.js +41 -2
  4. package/apps/lite-cli/dist/agent-contract.js.map +1 -1
  5. package/apps/lite-cli/dist/help.js +5 -5
  6. package/apps/lite-cli/dist/index.d.ts.map +1 -1
  7. package/apps/lite-cli/dist/index.js +148 -17
  8. package/apps/lite-cli/dist/index.js.map +1 -1
  9. package/apps/lite-cli/dist/index.test.js +114 -95
  10. package/apps/lite-cli/dist/index.test.js.map +1 -1
  11. package/apps/lite-cli/dist/inventory-and-git.test.d.ts +7 -0
  12. package/apps/lite-cli/dist/inventory-and-git.test.d.ts.map +1 -0
  13. package/apps/lite-cli/dist/inventory-and-git.test.js +776 -0
  14. package/apps/lite-cli/dist/inventory-and-git.test.js.map +1 -0
  15. package/apps/lite-cli/dist/inventory-command.d.ts +30 -0
  16. package/apps/lite-cli/dist/inventory-command.d.ts.map +1 -0
  17. package/apps/lite-cli/dist/inventory-command.js +265 -0
  18. package/apps/lite-cli/dist/inventory-command.js.map +1 -0
  19. package/apps/lite-cli/dist/json-v2.d.ts +2 -2
  20. package/apps/lite-cli/dist/json-v2.d.ts.map +1 -1
  21. package/apps/lite-cli/dist/json-v2.js +9 -3
  22. package/apps/lite-cli/dist/json-v2.js.map +1 -1
  23. package/apps/lite-cli/dist/project-git-command.d.ts +28 -0
  24. package/apps/lite-cli/dist/project-git-command.d.ts.map +1 -0
  25. package/apps/lite-cli/dist/project-git-command.js +288 -0
  26. package/apps/lite-cli/dist/project-git-command.js.map +1 -0
  27. package/apps/lite-cli/dist/startup-render.d.ts +10 -0
  28. package/apps/lite-cli/dist/startup-render.d.ts.map +1 -0
  29. package/apps/lite-cli/dist/startup-render.js +335 -0
  30. package/apps/lite-cli/dist/startup-render.js.map +1 -0
  31. package/apps/lite-cli/dist/version.d.ts +1 -1
  32. package/apps/lite-cli/dist/version.js +1 -1
  33. package/apps/lite-tui/dist/render.d.ts +1 -1
  34. package/apps/lite-tui/dist/version.d.ts +1 -1
  35. package/apps/lite-tui/dist/version.js +1 -1
  36. package/docs/guide/for-agents.md +14 -0
  37. package/docs/guide/lite.md +53 -2
  38. package/node_modules/@cchistory/canonical/dist/agent-inventory.d.ts +25 -0
  39. package/node_modules/@cchistory/canonical/dist/agent-inventory.d.ts.map +1 -0
  40. package/node_modules/@cchistory/canonical/dist/agent-inventory.js +345 -0
  41. package/node_modules/@cchistory/canonical/dist/agent-inventory.js.map +1 -0
  42. package/node_modules/@cchistory/canonical/dist/agent-inventory.test.d.ts +7 -0
  43. package/node_modules/@cchistory/canonical/dist/agent-inventory.test.d.ts.map +1 -0
  44. package/node_modules/@cchistory/canonical/dist/agent-inventory.test.js +231 -0
  45. package/node_modules/@cchistory/canonical/dist/agent-inventory.test.js.map +1 -0
  46. package/node_modules/@cchistory/canonical/dist/directory-scope.d.ts.map +1 -1
  47. package/node_modules/@cchistory/canonical/dist/directory-scope.js +4 -1
  48. package/node_modules/@cchistory/canonical/dist/directory-scope.js.map +1 -1
  49. package/node_modules/@cchistory/canonical/dist/index.d.ts +2 -0
  50. package/node_modules/@cchistory/canonical/dist/index.d.ts.map +1 -1
  51. package/node_modules/@cchistory/canonical/dist/index.js +2 -0
  52. package/node_modules/@cchistory/canonical/dist/index.js.map +1 -1
  53. package/node_modules/@cchistory/canonical/dist/project-merge.d.ts +42 -0
  54. package/node_modules/@cchistory/canonical/dist/project-merge.d.ts.map +1 -0
  55. package/node_modules/@cchistory/canonical/dist/project-merge.js +396 -0
  56. package/node_modules/@cchistory/canonical/dist/project-merge.js.map +1 -0
  57. package/node_modules/@cchistory/canonical/dist/project-merge.test.d.ts +7 -0
  58. package/node_modules/@cchistory/canonical/dist/project-merge.test.d.ts.map +1 -0
  59. package/node_modules/@cchistory/canonical/dist/project-merge.test.js +319 -0
  60. package/node_modules/@cchistory/canonical/dist/project-merge.test.js.map +1 -0
  61. package/node_modules/@cchistory/canonical/dist/session-interpreter.d.ts.map +1 -1
  62. package/node_modules/@cchistory/canonical/dist/session-interpreter.js +38 -0
  63. package/node_modules/@cchistory/canonical/dist/session-interpreter.js.map +1 -1
  64. package/node_modules/@cchistory/canonical/dist/tool-call-summary.d.ts.map +1 -1
  65. package/node_modules/@cchistory/canonical/dist/tool-call-summary.js +8 -0
  66. package/node_modules/@cchistory/canonical/dist/tool-call-summary.js.map +1 -1
  67. package/node_modules/@cchistory/canonical/package.json +1 -1
  68. package/node_modules/@cchistory/domain/dist/agent-inventory.d.ts +146 -0
  69. package/node_modules/@cchistory/domain/dist/agent-inventory.d.ts.map +1 -0
  70. package/node_modules/@cchistory/domain/dist/agent-inventory.js +9 -0
  71. package/node_modules/@cchistory/domain/dist/agent-inventory.js.map +1 -0
  72. package/node_modules/@cchistory/domain/dist/agent-startup.d.ts +362 -0
  73. package/node_modules/@cchistory/domain/dist/agent-startup.d.ts.map +1 -0
  74. package/node_modules/@cchistory/domain/dist/agent-startup.js +8 -0
  75. package/node_modules/@cchistory/domain/dist/agent-startup.js.map +1 -0
  76. package/node_modules/@cchistory/domain/dist/index.d.ts +5 -0
  77. package/node_modules/@cchistory/domain/dist/index.d.ts.map +1 -1
  78. package/node_modules/@cchistory/domain/dist/index.js +3 -0
  79. package/node_modules/@cchistory/domain/dist/index.js.map +1 -1
  80. package/node_modules/@cchistory/domain/dist/index.test.js +18 -1
  81. package/node_modules/@cchistory/domain/dist/index.test.js.map +1 -1
  82. package/node_modules/@cchistory/domain/dist/project-git.d.ts +121 -0
  83. package/node_modules/@cchistory/domain/dist/project-git.d.ts.map +1 -0
  84. package/node_modules/@cchistory/domain/dist/project-git.js +93 -0
  85. package/node_modules/@cchistory/domain/dist/project-git.js.map +1 -0
  86. package/node_modules/@cchistory/domain/package.json +1 -1
  87. package/node_modules/@cchistory/live-runtime/dist/index.d.ts +2 -1
  88. package/node_modules/@cchistory/live-runtime/dist/index.d.ts.map +1 -1
  89. package/node_modules/@cchistory/live-runtime/dist/index.js +2 -1
  90. package/node_modules/@cchistory/live-runtime/dist/index.js.map +1 -1
  91. package/node_modules/@cchistory/live-runtime/dist/inventory-and-git.d.ts +35 -0
  92. package/node_modules/@cchistory/live-runtime/dist/inventory-and-git.d.ts.map +1 -0
  93. package/node_modules/@cchistory/live-runtime/dist/inventory-and-git.js +68 -0
  94. package/node_modules/@cchistory/live-runtime/dist/inventory-and-git.js.map +1 -0
  95. package/node_modules/@cchistory/live-runtime/package.json +1 -1
  96. package/node_modules/@cchistory/source-adapters/dist/core/git-project.d.ts +9 -0
  97. package/node_modules/@cchistory/source-adapters/dist/core/git-project.d.ts.map +1 -1
  98. package/node_modules/@cchistory/source-adapters/dist/core/git-project.js +130 -7
  99. package/node_modules/@cchistory/source-adapters/dist/core/git-project.js.map +1 -1
  100. package/node_modules/@cchistory/source-adapters/dist/index.d.ts +5 -0
  101. package/node_modules/@cchistory/source-adapters/dist/index.d.ts.map +1 -1
  102. package/node_modules/@cchistory/source-adapters/dist/index.js +5 -0
  103. package/node_modules/@cchistory/source-adapters/dist/index.js.map +1 -1
  104. package/node_modules/@cchistory/source-adapters/dist/index.test.d.ts +2 -0
  105. package/node_modules/@cchistory/source-adapters/dist/index.test.d.ts.map +1 -1
  106. package/node_modules/@cchistory/source-adapters/dist/index.test.js +2 -0
  107. package/node_modules/@cchistory/source-adapters/dist/index.test.js.map +1 -1
  108. package/node_modules/@cchistory/source-adapters/dist/inventory/agent-config-reader.d.ts +14 -0
  109. package/node_modules/@cchistory/source-adapters/dist/inventory/agent-config-reader.d.ts.map +1 -0
  110. package/node_modules/@cchistory/source-adapters/dist/inventory/agent-config-reader.js +397 -0
  111. package/node_modules/@cchistory/source-adapters/dist/inventory/agent-config-reader.js.map +1 -0
  112. package/node_modules/@cchistory/source-adapters/dist/inventory/agent-config-reader.test.d.ts +6 -0
  113. package/node_modules/@cchistory/source-adapters/dist/inventory/agent-config-reader.test.d.ts.map +1 -0
  114. package/node_modules/@cchistory/source-adapters/dist/inventory/agent-config-reader.test.js +106 -0
  115. package/node_modules/@cchistory/source-adapters/dist/inventory/agent-config-reader.test.js.map +1 -0
  116. package/node_modules/@cchistory/source-adapters/dist/inventory/config-io.d.ts +42 -0
  117. package/node_modules/@cchistory/source-adapters/dist/inventory/config-io.d.ts.map +1 -0
  118. package/node_modules/@cchistory/source-adapters/dist/inventory/config-io.js +368 -0
  119. package/node_modules/@cchistory/source-adapters/dist/inventory/config-io.js.map +1 -0
  120. package/node_modules/@cchistory/source-adapters/dist/inventory/redaction.d.ts +22 -0
  121. package/node_modules/@cchistory/source-adapters/dist/inventory/redaction.d.ts.map +1 -0
  122. package/node_modules/@cchistory/source-adapters/dist/inventory/redaction.js +195 -0
  123. package/node_modules/@cchistory/source-adapters/dist/inventory/redaction.js.map +1 -0
  124. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/antigravity-helpers.d.ts +23 -0
  125. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/antigravity-helpers.d.ts.map +1 -0
  126. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/antigravity-helpers.js +147 -0
  127. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/antigravity-helpers.js.map +1 -0
  128. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/antigravity.d.ts +11 -0
  129. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/antigravity.d.ts.map +1 -0
  130. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/antigravity.js +339 -0
  131. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/antigravity.js.map +1 -0
  132. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/claude-code-helpers.d.ts +70 -0
  133. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/claude-code-helpers.d.ts.map +1 -0
  134. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/claude-code-helpers.js +257 -0
  135. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/claude-code-helpers.js.map +1 -0
  136. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/claude-code.d.ts +11 -0
  137. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/claude-code.d.ts.map +1 -0
  138. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/claude-code.js +321 -0
  139. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/claude-code.js.map +1 -0
  140. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/codex.d.ts +12 -0
  141. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/codex.d.ts.map +1 -0
  142. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/codex.js +363 -0
  143. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/codex.js.map +1 -0
  144. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/deepseek-harness.d.ts +20 -0
  145. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/deepseek-harness.d.ts.map +1 -0
  146. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/deepseek-harness.js +408 -0
  147. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/deepseek-harness.js.map +1 -0
  148. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/index.d.ts +24 -0
  149. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/index.d.ts.map +1 -0
  150. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/index.js +225 -0
  151. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/index.js.map +1 -0
  152. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/opencode.d.ts +12 -0
  153. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/opencode.d.ts.map +1 -0
  154. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/opencode.js +372 -0
  155. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/opencode.js.map +1 -0
  156. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/shared.d.ts +62 -0
  157. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/shared.d.ts.map +1 -0
  158. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/shared.js +428 -0
  159. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/shared.js.map +1 -0
  160. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/startup.test.d.ts +7 -0
  161. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/startup.test.d.ts.map +1 -0
  162. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/startup.test.js +399 -0
  163. package/node_modules/@cchistory/source-adapters/dist/inventory/startup/startup.test.js.map +1 -0
  164. package/node_modules/@cchistory/source-adapters/dist/inventory/toml.d.ts +16 -0
  165. package/node_modules/@cchistory/source-adapters/dist/inventory/toml.d.ts.map +1 -0
  166. package/node_modules/@cchistory/source-adapters/dist/inventory/toml.js +478 -0
  167. package/node_modules/@cchistory/source-adapters/dist/inventory/toml.js.map +1 -0
  168. package/node_modules/@cchistory/source-adapters/package.json +1 -1
  169. package/package.json +5 -5
  170. package/schemas/cchistory-lite-agent-v1.schema.json +3 -1
  171. package/schemas/cchistory-lite-envelope-v1.schema.json +33 -0
  172. package/schemas/cchistory-lite-inventory-v1.schema.json +94 -0
  173. package/schemas/cchistory-lite-merged-projects-v1.schema.json +44 -0
  174. package/schemas/cchistory-lite-v2.schema.json +22 -1
  175. package/skills/using-cchistory-lite/SKILL.md +17 -0
@@ -0,0 +1,368 @@
1
+ /**
2
+ * Role: Bounded read-only filesystem helpers, JSON/JSONC/TOML config loaders, and
3
+ * MCP/extension entry extractors shared across per-client agent inventory scanners.
4
+ * Excludes per-client directory layout knowledge (owned by agent-config-reader.ts).
5
+ */
6
+ import fs from "node:fs/promises";
7
+ import path from "node:path";
8
+ import { extractSecretKeyNames, redactMcpCommand, redactMcpUrl } from "./redaction.js";
9
+ import { parseToml, TomlParseError } from "./toml.js";
10
+ export const DEFAULT_MAX_CONFIG_FILE_BYTES = 1_048_576;
11
+ const MAX_DIR_ENTRIES = 500;
12
+ const IGNORED_ENTRY_NAMES = new Set([".DS_Store", "README.md", "README", ".gitkeep", "Thumbs.db"]);
13
+ export function extractMcpServersRecord(ctx, client, scope, sourcePath, servers) {
14
+ if (!servers)
15
+ return;
16
+ for (const [serverId, rawConfig] of Object.entries(servers)) {
17
+ const rec = asRecord(rawConfig);
18
+ if (!rec)
19
+ continue;
20
+ const normalizedId = serverId.trim();
21
+ if (!normalizedId)
22
+ continue;
23
+ const dedupeKey = `${client}\0${scope}\0${normalizedId}\0${sourcePath}`;
24
+ if (ctx.mcpSeenKeys.has(dedupeKey))
25
+ continue;
26
+ ctx.mcpSeenKeys.add(dedupeKey);
27
+ const rawUrl = asNonEmptyString(rec.url) ?? asNonEmptyString(rec.serverUrl) ?? asNonEmptyString(rec.httpUrl);
28
+ const rawCommand = rec.command;
29
+ let commandStr;
30
+ let argsList = [];
31
+ if (Array.isArray(rawCommand)) {
32
+ const parts = rawCommand.filter((entry) => typeof entry === "string");
33
+ commandStr = parts[0];
34
+ argsList = parts.slice(1);
35
+ }
36
+ else if (typeof rawCommand === "string" && rawCommand.trim()) {
37
+ commandStr = rawCommand.trim();
38
+ if (Array.isArray(rec.args)) {
39
+ argsList = rec.args.filter((entry) => typeof entry === "string");
40
+ }
41
+ }
42
+ const transport = inferMcpTransport(rec, rawUrl, commandStr);
43
+ const redactedCommand = redactMcpCommand(commandStr, argsList);
44
+ const redactedUrl = redactMcpUrl(rawUrl);
45
+ const envKeys = extractSecretKeyNames(rec.env ?? rec.environment);
46
+ const headerKeys = extractSecretKeyNames(rec.headers ?? rec.http_headers ?? rec.env_http_headers);
47
+ const enabled = rec.enabled === false || rec.disabled === true ? false : true;
48
+ markConfigured(ctx, client, sourcePath);
49
+ ctx.mcpServers.push({
50
+ server_id: normalizedId,
51
+ client,
52
+ scope,
53
+ transport,
54
+ ...(redactedCommand ? { command: redactedCommand, args_count: argsList.length } : {}),
55
+ ...(redactedUrl ? { url: redactedUrl } : {}),
56
+ env_keys: envKeys,
57
+ ...(headerKeys.length > 0 ? { header_keys: headerKeys } : {}),
58
+ enabled,
59
+ source_path: sourcePath,
60
+ });
61
+ }
62
+ }
63
+ function inferMcpTransport(rec, rawUrl, commandStr) {
64
+ const declared = (asNonEmptyString(rec.transport) ?? asNonEmptyString(rec.type))?.toLowerCase();
65
+ if (declared === "stdio" || declared === "local" || declared === "command")
66
+ return "stdio";
67
+ if (declared === "sse")
68
+ return "sse";
69
+ if (declared === "http" || declared === "streamable-http" || declared === "streamable_http" || declared === "remote") {
70
+ return rawUrl && /\/sse(?:[/?#]|$)/iu.test(rawUrl) ? "sse" : "http";
71
+ }
72
+ if (rawUrl)
73
+ return /\/sse(?:[/?#]|$)/iu.test(rawUrl) ? "sse" : "http";
74
+ if (commandStr)
75
+ return "stdio";
76
+ return "unknown";
77
+ }
78
+ export function extractNamedObjectExtensions(ctx, client, kind, scope, sourcePath, record) {
79
+ if (!record)
80
+ return;
81
+ for (const [name, value] of Object.entries(record)) {
82
+ const trimmed = name.trim();
83
+ if (!trimmed)
84
+ continue;
85
+ const enabled = typeof value === "boolean"
86
+ ? value
87
+ : asRecord(value)?.enabled === false || asRecord(value)?.disabled === true
88
+ ? false
89
+ : true;
90
+ addExtension(ctx, { kind, name: trimmed, client, scope, enabled, source_path: sourcePath });
91
+ }
92
+ }
93
+ export function extractBooleanPluginMap(ctx, client, scope, sourcePath, record) {
94
+ if (!record)
95
+ return;
96
+ for (const [name, value] of Object.entries(record)) {
97
+ const trimmed = name.trim();
98
+ if (!trimmed)
99
+ continue;
100
+ addExtension(ctx, {
101
+ kind: "plugin",
102
+ name: trimmed,
103
+ client,
104
+ scope,
105
+ enabled: value !== false,
106
+ source_path: sourcePath,
107
+ });
108
+ }
109
+ }
110
+ export async function scanExtensionDirectory(ctx, client, kind, scope, dirPath) {
111
+ let entries;
112
+ try {
113
+ entries = await fs.readdir(dirPath, { withFileTypes: true });
114
+ }
115
+ catch (error) {
116
+ if (isEnoent(error))
117
+ return;
118
+ ctx.diagnostics.push({
119
+ code: "inventory_dir_unreadable",
120
+ severity: "warning",
121
+ client,
122
+ path: dirPath,
123
+ detail: formatFsError(error),
124
+ });
125
+ return;
126
+ }
127
+ markInstalled(ctx, client);
128
+ let count = 0;
129
+ for (const entry of entries) {
130
+ if (count >= MAX_DIR_ENTRIES) {
131
+ ctx.diagnostics.push({
132
+ code: "inventory_dir_truncated",
133
+ severity: "info",
134
+ client,
135
+ path: dirPath,
136
+ detail: `Stopped after ${MAX_DIR_ENTRIES} entries in ${dirPath}.`,
137
+ });
138
+ break;
139
+ }
140
+ if (entry.name.startsWith(".") || IGNORED_ENTRY_NAMES.has(entry.name))
141
+ continue;
142
+ if (!entry.isDirectory() && !entry.isFile() && !entry.isSymbolicLink())
143
+ continue;
144
+ count += 1;
145
+ const displayName = entry.isFile() ? stripKnownExtension(entry.name) : entry.name;
146
+ if (!displayName)
147
+ continue;
148
+ addExtension(ctx, {
149
+ kind,
150
+ name: displayName,
151
+ client,
152
+ scope,
153
+ source_path: path.join(dirPath, entry.name),
154
+ });
155
+ }
156
+ }
157
+ export async function recordSingleRuleFile(ctx, client, scope, filePath) {
158
+ if (!(await pathExists(filePath)))
159
+ return;
160
+ addExtension(ctx, {
161
+ kind: "rule",
162
+ name: path.basename(filePath),
163
+ client,
164
+ scope,
165
+ source_path: filePath,
166
+ });
167
+ }
168
+ export function addExtension(ctx, entry) {
169
+ const dedupeKey = `${entry.kind}\0${entry.client}\0${entry.scope}\0${entry.name.toLowerCase()}`;
170
+ if (ctx.extensionSeenKeys.has(dedupeKey))
171
+ return;
172
+ ctx.extensionSeenKeys.add(dedupeKey);
173
+ markConfigured(ctx, entry.client, entry.source_path);
174
+ ctx.extensions.push({
175
+ id: `${entry.client}:${entry.kind}:${entry.scope}:${entry.name}`,
176
+ ...entry,
177
+ });
178
+ }
179
+ export async function readTomlConfig(ctx, client, filePath) {
180
+ const content = await readBoundedTextFile(ctx, client, filePath);
181
+ if (content === undefined)
182
+ return undefined;
183
+ markConfigured(ctx, client, filePath);
184
+ try {
185
+ return parseToml(content);
186
+ }
187
+ catch (error) {
188
+ ctx.diagnostics.push({
189
+ code: "inventory_toml_parse_failed",
190
+ severity: "warning",
191
+ client,
192
+ path: filePath,
193
+ detail: error instanceof TomlParseError ? error.message : formatFsError(error),
194
+ });
195
+ return undefined;
196
+ }
197
+ }
198
+ export async function readJsonConfig(ctx, client, filePath, allowJsonc = false) {
199
+ const content = await readBoundedTextFile(ctx, client, filePath);
200
+ if (content === undefined)
201
+ return undefined;
202
+ markConfigured(ctx, client, filePath);
203
+ try {
204
+ const cleaned = allowJsonc ? stripJsoncCommentsAndTrailingCommas(content) : content;
205
+ const parsed = JSON.parse(cleaned);
206
+ const rec = asRecord(parsed);
207
+ if (!rec) {
208
+ ctx.diagnostics.push({
209
+ code: "inventory_json_not_object",
210
+ severity: "warning",
211
+ client,
212
+ path: filePath,
213
+ detail: "Expected a top-level JSON object.",
214
+ });
215
+ return undefined;
216
+ }
217
+ return rec;
218
+ }
219
+ catch (error) {
220
+ ctx.diagnostics.push({
221
+ code: "inventory_json_parse_failed",
222
+ severity: "warning",
223
+ client,
224
+ path: filePath,
225
+ detail: formatFsError(error),
226
+ });
227
+ return undefined;
228
+ }
229
+ }
230
+ export async function readBoundedTextFile(ctx, client, filePath) {
231
+ let stats;
232
+ try {
233
+ stats = await fs.stat(filePath);
234
+ }
235
+ catch (error) {
236
+ if (isEnoent(error))
237
+ return undefined;
238
+ ctx.diagnostics.push({
239
+ code: "inventory_file_unreadable",
240
+ severity: "warning",
241
+ client,
242
+ path: filePath,
243
+ detail: formatFsError(error),
244
+ });
245
+ return undefined;
246
+ }
247
+ if (!stats.isFile())
248
+ return undefined;
249
+ if (stats.size > ctx.maxFileBytes) {
250
+ ctx.diagnostics.push({
251
+ code: "inventory_file_too_large",
252
+ severity: "warning",
253
+ client,
254
+ path: filePath,
255
+ detail: `Skipped config file (${stats.size} bytes exceeds ${ctx.maxFileBytes}-byte limit).`,
256
+ });
257
+ return undefined;
258
+ }
259
+ try {
260
+ return await fs.readFile(filePath, "utf8");
261
+ }
262
+ catch (error) {
263
+ ctx.diagnostics.push({
264
+ code: "inventory_file_unreadable",
265
+ severity: "warning",
266
+ client,
267
+ path: filePath,
268
+ detail: formatFsError(error),
269
+ });
270
+ return undefined;
271
+ }
272
+ }
273
+ function stripJsoncCommentsAndTrailingCommas(input) {
274
+ let out = "";
275
+ let inString = false;
276
+ let escaped = false;
277
+ for (let i = 0; i < input.length; i += 1) {
278
+ const ch = input[i];
279
+ const next = input[i + 1];
280
+ if (inString) {
281
+ out += ch;
282
+ if (escaped)
283
+ escaped = false;
284
+ else if (ch === "\\")
285
+ escaped = true;
286
+ else if (ch === "\"")
287
+ inString = false;
288
+ continue;
289
+ }
290
+ if (ch === "\"") {
291
+ inString = true;
292
+ out += ch;
293
+ continue;
294
+ }
295
+ if (ch === "/" && next === "/") {
296
+ i += 2;
297
+ while (i < input.length && input[i] !== "\n")
298
+ i += 1;
299
+ if (i < input.length)
300
+ out += "\n";
301
+ continue;
302
+ }
303
+ if (ch === "/" && next === "*") {
304
+ i += 2;
305
+ while (i < input.length && !(input[i] === "*" && input[i + 1] === "/"))
306
+ i += 1;
307
+ i += 1;
308
+ continue;
309
+ }
310
+ out += ch;
311
+ }
312
+ return out.replace(/,(\s*[}\]])/gu, "$1");
313
+ }
314
+ export function markInstalled(ctx, client) {
315
+ const acc = ctx.clients.get(client);
316
+ if (acc)
317
+ acc.installed = true;
318
+ }
319
+ export function markConfigured(ctx, client, configPath) {
320
+ const acc = ctx.clients.get(client);
321
+ if (!acc)
322
+ return;
323
+ acc.installed = true;
324
+ acc.configured = true;
325
+ acc.config_paths.add(configPath);
326
+ }
327
+ export function asRecord(value) {
328
+ if (!value || typeof value !== "object" || Array.isArray(value))
329
+ return undefined;
330
+ return value;
331
+ }
332
+ function asNonEmptyString(value) {
333
+ return typeof value === "string" && value.trim() ? value.trim() : undefined;
334
+ }
335
+ function stripKnownExtension(fileName) {
336
+ return fileName.replace(/\.(?:md|markdown|txt|json|jsonc|toml|ya?ml|mjs|cjs|js|ts|sh)$/iu, "");
337
+ }
338
+ export function normalizeComparablePath(value) {
339
+ return path.resolve(value).replace(/\\/gu, "/").replace(/\/+$/u, "").toLowerCase();
340
+ }
341
+ export function uniquePaths(values) {
342
+ const seen = new Set();
343
+ const out = [];
344
+ for (const value of values) {
345
+ const resolved = path.resolve(value);
346
+ if (seen.has(resolved))
347
+ continue;
348
+ seen.add(resolved);
349
+ out.push(resolved);
350
+ }
351
+ return out;
352
+ }
353
+ export async function pathExists(target) {
354
+ try {
355
+ await fs.access(target);
356
+ return true;
357
+ }
358
+ catch {
359
+ return false;
360
+ }
361
+ }
362
+ function isEnoent(error) {
363
+ return Boolean(error && typeof error === "object" && "code" in error && error.code === "ENOENT");
364
+ }
365
+ function formatFsError(error) {
366
+ return error instanceof Error ? error.message : String(error);
367
+ }
368
+ //# sourceMappingURL=config-io.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-io.js","sourceRoot":"","sources":["../../src/inventory/config-io.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAU7B,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACvF,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEtD,MAAM,CAAC,MAAM,6BAA6B,GAAG,SAAS,CAAC;AACvD,MAAM,eAAe,GAAG,GAAG,CAAC;AAC5B,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC,CAAC,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC,CAAC;AAuBnG,MAAM,UAAU,uBAAuB,CACrC,GAAyB,EACzB,MAA4B,EAC5B,KAAuB,EACvB,UAAkB,EAClB,OAA4C;IAE5C,IAAI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AQ,CAAC,CAAC;IACrB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,MAAc;IAC7C,IAAI,CAAC;QACH,MAAM,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACxB,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,IAAI,KAAK,IAAK,KAA4B,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC;AAC3H,CAAC;AAED,SAAS,aAAa,CAAC,KAAc;IACnC,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Role: Strict secret-hygiene redaction for MCP server commands, arguments, URLs,
3
+ * headers, and environment key extraction. Guarantees env/header values, basic-auth
4
+ * credentials, query tokens, and bearer/API tokens never leave the parse boundary.
5
+ * Excludes filesystem discovery, TOML/JSON parsing, and activity correlation.
6
+ */
7
+ /**
8
+ * Redact an MCP URL by stripping basic-auth credentials, fragments, and all query
9
+ * parameter values (preserving query keys as `<redacted>`).
10
+ */
11
+ export declare function redactMcpUrl(raw: string | undefined): string | undefined;
12
+ /**
13
+ * Build a redacted single-line MCP command string from a command and optional args.
14
+ * Strips inline env values, secret flag values, header values, URL credentials/queries,
15
+ * and token-shaped literals.
16
+ */
17
+ export declare function redactMcpCommand(command: string | undefined, args?: readonly string[]): string | undefined;
18
+ /**
19
+ * Extract sorted key names only from an env/headers object. Values are never read or returned.
20
+ */
21
+ export declare function extractSecretKeyNames(value: unknown): string[];
22
+ //# sourceMappingURL=redaction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redaction.d.ts","sourceRoot":"","sources":["../../src/inventory/redaction.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAoCH;;;GAGG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAkCxE;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,EAAE,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,GAAG,SAAS,CA6D1G;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,EAAE,CAQ9D"}
@@ -0,0 +1,195 @@
1
+ /**
2
+ * Role: Strict secret-hygiene redaction for MCP server commands, arguments, URLs,
3
+ * headers, and environment key extraction. Guarantees env/header values, basic-auth
4
+ * credentials, query tokens, and bearer/API tokens never leave the parse boundary.
5
+ * Excludes filesystem discovery, TOML/JSON parsing, and activity correlation.
6
+ */
7
+ const SECRET_FLAG_NAMES = new Set([
8
+ "--token",
9
+ "-t",
10
+ "--api-key",
11
+ "--apikey",
12
+ "--api_key",
13
+ "--secret",
14
+ "--password",
15
+ "--passwd",
16
+ "--pass",
17
+ "--auth",
18
+ "--authorization",
19
+ "--bearer",
20
+ "--key",
21
+ "--access-token",
22
+ "--refresh-token",
23
+ "--client-secret",
24
+ "-h",
25
+ "--header",
26
+ ]);
27
+ const SENSITIVE_KEY_RE = /(?:token|secret|key|pass|auth|bearer|cookie|credential|private|sig|jwt)/iu;
28
+ const SECRET_VALUE_PATTERNS = [
29
+ /\bBearer\s+[A-Za-z0-9._~+/=-]{6,}/giu,
30
+ /\bBasic\s+[A-Za-z0-9+/=]{6,}/giu,
31
+ /\b(?:sk|pk|rk)-(?:proj-|live-|test-)?[A-Za-z0-9_-]{12,}/gu,
32
+ /\b(?:ghp|gho|ghu|ghs|ghr)_[A-Za-z0-9]{16,}/gu,
33
+ /\bgithub_pat_[A-Za-z0-9_]{20,}/gu,
34
+ /\bxox[baprs]-[A-Za-z0-9-]{12,}/gu,
35
+ /\bAIza[0-9A-Za-z_-]{20,}/gu,
36
+ /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{8,}/gu,
37
+ ];
38
+ const INLINE_URL_RE = /\b[A-Za-z][A-Za-z0-9+.-]*:\/\/[^\s"'`]+/gu;
39
+ /**
40
+ * Redact an MCP URL by stripping basic-auth credentials, fragments, and all query
41
+ * parameter values (preserving query keys as `<redacted>`).
42
+ */
43
+ export function redactMcpUrl(raw) {
44
+ const trimmed = raw?.trim();
45
+ if (!trimmed)
46
+ return undefined;
47
+ try {
48
+ const parsed = new URL(trimmed);
49
+ const hasAuth = Boolean(parsed.username || parsed.password);
50
+ parsed.username = "";
51
+ parsed.password = "";
52
+ parsed.hash = "";
53
+ const queryKeys = [...new Set([...parsed.searchParams.keys()])];
54
+ parsed.search = "";
55
+ const base = parsed.toString().replace(/\/$/u, parsed.pathname === "/" && trimmed.endsWith("/") ? "/" : "");
56
+ const querySuffix = queryKeys.length > 0
57
+ ? `?${queryKeys.map((key) => `${encodeURIComponent(key)}=<redacted>`).join("&")}`
58
+ : "";
59
+ const result = redactInlineTokens(`${base}${querySuffix}`);
60
+ return hasAuth ? result : result;
61
+ }
62
+ catch {
63
+ // Fallback for malformed URL strings with embedded auth or query params.
64
+ const withoutAuth = trimmed.replace(/^([A-Za-z][A-Za-z0-9+.-]*:\/\/)[^/@\s]+@/u, "$1");
65
+ const [withoutHash] = withoutAuth.split("#", 1);
66
+ const [beforeQuery, query] = (withoutHash ?? withoutAuth).split("?", 2);
67
+ if (!query)
68
+ return redactInlineTokens(beforeQuery ?? withoutAuth);
69
+ const redactedPairs = query
70
+ .split("&")
71
+ .filter(Boolean)
72
+ .map((pair) => {
73
+ const eqIdx = pair.indexOf("=");
74
+ const key = eqIdx >= 0 ? pair.slice(0, eqIdx) : pair;
75
+ return `${key}=<redacted>`;
76
+ });
77
+ return redactInlineTokens(`${beforeQuery}?${redactedPairs.join("&")}`);
78
+ }
79
+ }
80
+ /**
81
+ * Build a redacted single-line MCP command string from a command and optional args.
82
+ * Strips inline env values, secret flag values, header values, URL credentials/queries,
83
+ * and token-shaped literals.
84
+ */
85
+ export function redactMcpCommand(command, args) {
86
+ const parts = [];
87
+ const trimmedCommand = command?.trim();
88
+ if (trimmedCommand) {
89
+ parts.push(...tokenizeCommandForRedaction(trimmedCommand));
90
+ }
91
+ if (args && args.length > 0) {
92
+ for (const arg of args) {
93
+ parts.push(arg);
94
+ }
95
+ }
96
+ if (parts.length === 0)
97
+ return undefined;
98
+ const redacted = [];
99
+ let redactNextArg = false;
100
+ for (const part of parts) {
101
+ if (redactNextArg) {
102
+ redacted.push("<redacted>");
103
+ redactNextArg = false;
104
+ continue;
105
+ }
106
+ // Inline env assignment: `API_KEY=secret` -> `API_KEY=<redacted>`
107
+ const envMatch = /^([A-Za-z_][A-Za-z0-9_]*)=(.*)$/su.exec(part);
108
+ if (envMatch) {
109
+ redacted.push(`${envMatch[1]}=<redacted>`);
110
+ continue;
111
+ }
112
+ // `--flag=value` form where flag is sensitive or header-like.
113
+ const flagEqMatch = /^(--?[A-Za-z0-9_-]+)=(.*)$/su.exec(part);
114
+ if (flagEqMatch) {
115
+ const flagName = flagEqMatch[1];
116
+ const flagVal = flagEqMatch[2];
117
+ if (SECRET_FLAG_NAMES.has(flagName.toLowerCase()) || SENSITIVE_KEY_RE.test(flagName)) {
118
+ redacted.push(`${flagName}=<redacted>`);
119
+ }
120
+ else {
121
+ redacted.push(`${flagName}=${redactArgValue(flagVal)}`);
122
+ }
123
+ continue;
124
+ }
125
+ // Separate `--token <value>` or `-H "Authorization: Bearer ..."` form.
126
+ if (SECRET_FLAG_NAMES.has(part.toLowerCase()) || (part.startsWith("--") && SENSITIVE_KEY_RE.test(part))) {
127
+ redacted.push(part);
128
+ redactNextArg = true;
129
+ continue;
130
+ }
131
+ // Header literal such as `Authorization: Bearer ...`
132
+ const headerMatch = /^([A-Za-z][A-Za-z0-9-]*)\s*:\s*(.+)$/su.exec(part);
133
+ if (headerMatch && SENSITIVE_KEY_RE.test(headerMatch[1])) {
134
+ redacted.push(`${headerMatch[1]}: <redacted>`);
135
+ continue;
136
+ }
137
+ redacted.push(redactArgValue(part));
138
+ }
139
+ return redacted.join(" ");
140
+ }
141
+ /**
142
+ * Extract sorted key names only from an env/headers object. Values are never read or returned.
143
+ */
144
+ export function extractSecretKeyNames(value) {
145
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
146
+ return [];
147
+ }
148
+ return Object.keys(value)
149
+ .map((key) => key.trim())
150
+ .filter(Boolean)
151
+ .sort((a, b) => a.localeCompare(b));
152
+ }
153
+ function redactArgValue(value) {
154
+ let out = value.replace(INLINE_URL_RE, (match) => redactMcpUrl(match) ?? "<redacted>");
155
+ out = redactInlineTokens(out);
156
+ return out;
157
+ }
158
+ function redactInlineTokens(value) {
159
+ let out = value;
160
+ for (const pattern of SECRET_VALUE_PATTERNS) {
161
+ out = out.replace(pattern, "<redacted>");
162
+ }
163
+ return out;
164
+ }
165
+ function tokenizeCommandForRedaction(command) {
166
+ const tokens = [];
167
+ let current = "";
168
+ let quote = null;
169
+ for (let i = 0; i < command.length; i += 1) {
170
+ const ch = command[i];
171
+ if (quote) {
172
+ if (ch === quote)
173
+ quote = null;
174
+ else
175
+ current += ch;
176
+ continue;
177
+ }
178
+ if (ch === "\"" || ch === "'") {
179
+ quote = ch;
180
+ }
181
+ else if (/\s/u.test(ch)) {
182
+ if (current) {
183
+ tokens.push(current);
184
+ current = "";
185
+ }
186
+ }
187
+ else {
188
+ current += ch;
189
+ }
190
+ }
191
+ if (current)
192
+ tokens.push(current);
193
+ return tokens;
194
+ }
195
+ //# sourceMappingURL=redaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redaction.js","sourceRoot":"","sources":["../../src/inventory/redaction.ts"],"names":[],"mappings":"AA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AC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QAC3C,MAAM,EAAE,GAAG,OAAO,CAAC,CAAC,CAAE,CAAC;QACvB,IAAI,KAAK,EAAE,CAAC;YACV,IAAI,EAAE,KAAK,KAAK;gBAAE,KAAK,GAAG,IAAI,CAAC;;gBAC1B,OAAO,IAAI,EAAE,CAAC;YACnB,SAAS;QACX,CAAC;QACD,IAAI,EAAE,KAAK,IAAI,IAAI,EAAE,KAAK,GAAG,EAAE,CAAC;YAC9B,KAAK,GAAG,EAAE,CAAC;QACb,CAAC;aAAM,IAAI,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;YAC1B,IAAI,OAAO,EAAE,CAAC;gBACZ,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;gBACrB,OAAO,GAAG,EAAE,CAAC;YACf,CAAC;QACH,CAAC;aAAM,CAAC;YACN,OAAO,IAAI,EAAE,CAAC;QAChB,CAAC;IACH,CAAC;IACD,IAAI,OAAO;QAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAClC,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Role: Manifest expansion, hook extraction, rule `@[label](path)` include parsing, and
3
+ * path canonicalization helpers for the native Google Antigravity startup resolver.
4
+ * Excludes top-level Antigravity precedence orchestration and CLI formatting.
5
+ */
6
+ import type { AntigravityRuleEntry, RedactedHookEntry } from "@cchistory/domain";
7
+ import { type StartupReadTracker } from "./shared.js";
8
+ export declare const AGY_HOOK_EVENTS: readonly ["SessionStart", "PreToolUse", "PostToolUse", "PreInvocation", "PostInvocation", "Stop"];
9
+ export interface ManifestDirEntry {
10
+ dir: string;
11
+ includeOnly?: string[];
12
+ exclude?: string[];
13
+ }
14
+ export declare function readPluginManifest(tracker: StartupReadTracker, pluginDir: string): Promise<Record<string, unknown> | undefined>;
15
+ export declare function extractAntigravityHooks(hooksObj: Record<string, unknown>, sourcePath: string, out: RedactedHookEntry[]): void;
16
+ export declare function expandJsonManifest(tracker: StartupReadTracker, manifestPath: string, homeDir: string, workspaceRoot: string | null, visited?: Set<string>): Promise<ManifestDirEntry[]>;
17
+ export declare function matchesManifestFilter(name: string, filter?: {
18
+ includeOnly?: string[];
19
+ exclude?: string[];
20
+ }): boolean;
21
+ export declare function extractAntigravityIncludes(ownerPath: string, markdown: string, homeDir: string): Promise<AntigravityRuleEntry["includes"]>;
22
+ export declare function resolveSafeRealPath(target: string): Promise<string>;
23
+ //# sourceMappingURL=antigravity-helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"antigravity-helpers.d.ts","sourceRoot":"","sources":["../../../src/inventory/startup/antigravity-helpers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EACV,oBAAoB,EACpB,iBAAiB,EAClB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAKL,KAAK,kBAAkB,EACxB,MAAM,aAAa,CAAC;AAErB,eAAO,MAAM,eAAe,mGAOlB,CAAC;AAEX,MAAM,WAAW,gBAAgB;IAC/B,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,kBAAkB,EAC3B,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC,CAM9C;AAED,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjC,UAAU,EAAE,MAAM,EAClB,GAAG,EAAE,iBAAiB,EAAE,GACvB,IAAI,CA2BN;AAED,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,kBAAkB,EAC3B,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,MAAM,EACf,aAAa,EAAE,MAAM,GAAG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