@prbe.ai/electron-sdk 0.1.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 (54) hide show
  1. package/dist/agent.d.ts +105 -0
  2. package/dist/agent.d.ts.map +1 -0
  3. package/dist/agent.js +861 -0
  4. package/dist/agent.js.map +1 -0
  5. package/dist/assets/index.d.ts +6 -0
  6. package/dist/assets/index.d.ts.map +1 -0
  7. package/dist/assets/index.js +13 -0
  8. package/dist/assets/index.js.map +1 -0
  9. package/dist/index.d.ts +16 -0
  10. package/dist/index.d.ts.map +1 -0
  11. package/dist/index.js +62 -0
  12. package/dist/index.js.map +1 -0
  13. package/dist/interactions.d.ts +56 -0
  14. package/dist/interactions.d.ts.map +1 -0
  15. package/dist/interactions.js +27 -0
  16. package/dist/interactions.js.map +1 -0
  17. package/dist/models.d.ts +212 -0
  18. package/dist/models.d.ts.map +1 -0
  19. package/dist/models.js +120 -0
  20. package/dist/models.js.map +1 -0
  21. package/dist/serialization.d.ts +49 -0
  22. package/dist/serialization.d.ts.map +1 -0
  23. package/dist/serialization.js +69 -0
  24. package/dist/serialization.js.map +1 -0
  25. package/dist/state.d.ts +67 -0
  26. package/dist/state.d.ts.map +1 -0
  27. package/dist/state.js +270 -0
  28. package/dist/state.js.map +1 -0
  29. package/dist/tools/bash.d.ts +30 -0
  30. package/dist/tools/bash.d.ts.map +1 -0
  31. package/dist/tools/bash.js +247 -0
  32. package/dist/tools/bash.js.map +1 -0
  33. package/dist/tools/filesystem.d.ts +63 -0
  34. package/dist/tools/filesystem.d.ts.map +1 -0
  35. package/dist/tools/filesystem.js +573 -0
  36. package/dist/tools/filesystem.js.map +1 -0
  37. package/dist/tools/index.d.ts +46 -0
  38. package/dist/tools/index.d.ts.map +1 -0
  39. package/dist/tools/index.js +171 -0
  40. package/dist/tools/index.js.map +1 -0
  41. package/dist/tools/interactive.d.ts +15 -0
  42. package/dist/tools/interactive.d.ts.map +1 -0
  43. package/dist/tools/interactive.js +57 -0
  44. package/dist/tools/interactive.js.map +1 -0
  45. package/dist/tools/logs.d.ts +72 -0
  46. package/dist/tools/logs.d.ts.map +1 -0
  47. package/dist/tools/logs.js +366 -0
  48. package/dist/tools/logs.js.map +1 -0
  49. package/dist/types.d.ts +14 -0
  50. package/dist/types.d.ts.map +1 -0
  51. package/dist/types.js +32 -0
  52. package/dist/types.js.map +1 -0
  53. package/package.json +35 -0
  54. package/src/assets/probe-mark.svg +5 -0
@@ -0,0 +1,171 @@
1
+ "use strict";
2
+ /**
3
+ * tools/index.ts — Tool interface, registry, and closure tool
4
+ *
5
+ * Mirrors PRBEAgentTools.swift tool protocol + registry pattern.
6
+ */
7
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
+ if (k2 === undefined) k2 = k;
9
+ var desc = Object.getOwnPropertyDescriptor(m, k);
10
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
+ desc = { enumerable: true, get: function() { return m[k]; } };
12
+ }
13
+ Object.defineProperty(o, k2, desc);
14
+ }) : (function(o, m, k, k2) {
15
+ if (k2 === undefined) k2 = k;
16
+ o[k2] = m[k];
17
+ }));
18
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
19
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
20
+ }) : function(o, v) {
21
+ o["default"] = v;
22
+ });
23
+ var __importStar = (this && this.__importStar) || (function () {
24
+ var ownKeys = function(o) {
25
+ ownKeys = Object.getOwnPropertyNames || function (o) {
26
+ var ar = [];
27
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
28
+ return ar;
29
+ };
30
+ return ownKeys(o);
31
+ };
32
+ return function (mod) {
33
+ if (mod && mod.__esModule) return mod;
34
+ var result = {};
35
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
36
+ __setModuleDefault(result, mod);
37
+ return result;
38
+ };
39
+ })();
40
+ Object.defineProperty(exports, "__esModule", { value: true });
41
+ exports.PRBEClosureTool = exports.PRBEToolRegistry = void 0;
42
+ exports.resolveAndValidate = resolveAndValidate;
43
+ exports.resolveWithAccessRequest = resolveWithAccessRequest;
44
+ exports.humanReadableSize = humanReadableSize;
45
+ // ---------------------------------------------------------------------------
46
+ // Tool Registry
47
+ // ---------------------------------------------------------------------------
48
+ class PRBEToolRegistry {
49
+ tools = new Map();
50
+ register(tool) {
51
+ this.tools.set(tool.declaration.name, tool);
52
+ }
53
+ allDeclarations() {
54
+ return Array.from(this.tools.values()).map((t) => t.declaration);
55
+ }
56
+ async execute(name, args) {
57
+ const tool = this.tools.get(name);
58
+ if (!tool) {
59
+ return `Error: unknown tool '${name}'`;
60
+ }
61
+ return tool.execute(args);
62
+ }
63
+ }
64
+ exports.PRBEToolRegistry = PRBEToolRegistry;
65
+ // ---------------------------------------------------------------------------
66
+ // Closure Tool (for user-registered custom tools)
67
+ // ---------------------------------------------------------------------------
68
+ class PRBEClosureTool {
69
+ declaration;
70
+ handler;
71
+ constructor(name, description, parameters, handler) {
72
+ this.declaration = { name, description, parameters };
73
+ this.handler = handler;
74
+ }
75
+ async execute(args) {
76
+ return this.handler(args);
77
+ }
78
+ }
79
+ exports.PRBEClosureTool = PRBEClosureTool;
80
+ // ---------------------------------------------------------------------------
81
+ // Path Validation (shared by filesystem + flag tools)
82
+ // ---------------------------------------------------------------------------
83
+ const path = __importStar(require("path"));
84
+ /**
85
+ * Resolve a path string and validate it against allowed roots.
86
+ * Returns the resolved absolute path or null if outside allowed roots.
87
+ */
88
+ function resolveAndValidate(pathStr, allowedRoots) {
89
+ let resolved;
90
+ if (path.isAbsolute(pathStr)) {
91
+ resolved = path.resolve(pathStr);
92
+ }
93
+ else if (allowedRoots.length > 0) {
94
+ resolved = path.resolve(allowedRoots[0], pathStr);
95
+ }
96
+ else {
97
+ return null;
98
+ }
99
+ // Normalize to remove trailing slashes for comparison
100
+ const normalizedResolved = path.resolve(resolved);
101
+ for (const root of allowedRoots) {
102
+ const normalizedRoot = path.resolve(root);
103
+ if (normalizedResolved === normalizedRoot || normalizedResolved.startsWith(normalizedRoot + path.sep)) {
104
+ return normalizedResolved;
105
+ }
106
+ }
107
+ return null;
108
+ }
109
+ /**
110
+ * Resolve a path, requesting user access if outside allowed roots.
111
+ * When a requester is available and the path fails validation, prompts
112
+ * the user for permission and caches the grant in `grantedPaths`.
113
+ *
114
+ * Returns { path } on success, { error } with a message for the agent, or null.
115
+ */
116
+ async function resolveWithAccessRequest(pathStr, allowedRoots, grantedPaths, requester) {
117
+ // First try against allowed roots + already-granted paths
118
+ const allRoots = [...allowedRoots, ...grantedPaths];
119
+ const resolved = resolveAndValidate(pathStr, allRoots);
120
+ if (resolved)
121
+ return { path: resolved };
122
+ // No requester — can't ask for access
123
+ if (!requester)
124
+ return null;
125
+ // Resolve the absolute path even though it's outside roots
126
+ let absolute;
127
+ if (path.isAbsolute(pathStr)) {
128
+ absolute = path.resolve(pathStr);
129
+ }
130
+ else if (allowedRoots.length > 0) {
131
+ absolute = path.resolve(allowedRoots[0], pathStr);
132
+ }
133
+ else {
134
+ return null;
135
+ }
136
+ // Reject overly broad paths — tell the agent to be more specific
137
+ const depth = absolute.split(path.sep).filter(Boolean).length;
138
+ if (depth < 3) {
139
+ return { error: `Path '${pathStr}' is too broad. Use a more specific path (e.g. a subdirectory at least 3 levels deep).` };
140
+ }
141
+ // Request path access from the user
142
+ const { randomUUID } = await Promise.resolve().then(() => __importStar(require("crypto")));
143
+ const response = await requester.requestUserInteraction({
144
+ type: (await Promise.resolve().then(() => __importStar(require("../interactions")))).InteractionType.REQUEST_PATH_ACCESS,
145
+ interactionId: randomUUID(),
146
+ path: absolute,
147
+ reason: `The agent needs access to '${pathStr}' which is outside the allowed directories.`,
148
+ });
149
+ const pathResponse = response;
150
+ if (!pathResponse.granted)
151
+ return { error: "Path access denied by user." };
152
+ // Grant the exact resolved path (not parent — avoid overly broad grants)
153
+ grantedPaths.add(absolute);
154
+ return { path: absolute };
155
+ }
156
+ /**
157
+ * Format byte sizes for human-readable output.
158
+ */
159
+ function humanReadableSize(bytes) {
160
+ if (bytes < 1024)
161
+ return `${bytes} B`;
162
+ const kb = bytes / 1024;
163
+ if (kb < 1024)
164
+ return `${kb.toFixed(1)} KB`;
165
+ const mb = kb / 1024;
166
+ if (mb < 1024)
167
+ return `${mb.toFixed(1)} MB`;
168
+ const gb = mb / 1024;
169
+ return `${gb.toFixed(1)} GB`;
170
+ }
171
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuEH,gDAqBC;AAYD,4DA8CC;AAKD,8CAQC;AAtJD,8EAA8E;AAC9E,gBAAgB;AAChB,8EAA8E;AAE9E,MAAa,gBAAgB;IACnB,KAAK,GAA0B,IAAI,GAAG,EAAE,CAAC;IAEjD,QAAQ,CAAC,IAAc;QACrB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC9C,CAAC;IAED,eAAe;QACb,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;IACnE,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,IAAY,EAAE,IAA6B;QACvD,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAClC,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,OAAO,wBAAwB,IAAI,GAAG,CAAC;QACzC,CAAC;QACD,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;I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AAC,sBAAsB,CAAC;QACtD,IAAI,EAAE,CAAC,wDAAa,iBAAiB,GAAC,CAAC,CAAC,eAAe,CAAC,mBAAmB;QAC3E,aAAa,EAAE,UAAU,EAAE;QAC3B,IAAI,EAAE,QAAQ;QACd,MAAM,EAAE,8BAA8B,OAAO,6CAA6C;KAC3F,CAAC,CAAC;IAEH,MAAM,YAAY,GAAG,QAA+D,CAAC;IACrF,IAAI,CAAC,YAAY,CAAC,OAAO;QAAE,OAAO,EAAE,KAAK,EAAE,6BAA6B,EAAE,CAAC;IAE3E,yEAAyE;IACzE,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAE3B,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;AAC5B,CAAC;AAED;;GAEG;AACH,SAAgB,iBAAiB,CAAC,KAAa;IAC7C,IAAI,KAAK,GAAG,IAAI;QAAE,OAAO,GAAG,KAAK,IAAI,CAAC;IACtC,MAAM,EAAE,GAAG,KAAK,GAAG,IAAI,CAAC;IACxB,IAAI,EAAE,GAAG,IAAI;QAAE,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;IAC5C,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IACrB,IAAI,EAAE,GAAG,IAAI;QAAE,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;IAC5C,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IACrB,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;AAC/B,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * tools/interactive.ts — AskUserTool
3
+ *
4
+ * Allows the agent to ask the user a question during an investigation.
5
+ */
6
+ import type { PRBEToolDeclaration } from "../models";
7
+ import type { PRBEInteractionRequester } from "../interactions";
8
+ import type { PRBETool } from "./index";
9
+ export declare class AskUserTool implements PRBETool {
10
+ private readonly requester;
11
+ constructor(requester: PRBEInteractionRequester);
12
+ get declaration(): PRBEToolDeclaration;
13
+ execute(args: Record<string, unknown>): Promise<string>;
14
+ }
15
+ //# sourceMappingURL=interactive.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interactive.d.ts","sourceRoot":"","sources":["../../src/tools/interactive.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAGrD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAEhE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAExC,qBAAa,WAAY,YAAW,QAAQ;IAC1C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA2B;gBAEzC,SAAS,EAAE,wBAAwB;IAI/C,IAAI,WAAW,IAAI,mBAAmB,CAoBrC;IAEK,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;CAqB9D"}
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ /**
3
+ * tools/interactive.ts — AskUserTool
4
+ *
5
+ * Allows the agent to ask the user a question during an investigation.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.AskUserTool = void 0;
9
+ const crypto_1 = require("crypto");
10
+ const models_1 = require("../models");
11
+ const interactions_1 = require("../interactions");
12
+ class AskUserTool {
13
+ requester;
14
+ constructor(requester) {
15
+ this.requester = requester;
16
+ }
17
+ get declaration() {
18
+ return {
19
+ name: models_1.ToolName.CLIENT_ASK_USER,
20
+ description: "Ask the user a question and wait for their response. Use this when you need clarification or additional information from the user to continue the investigation.",
21
+ parameters: [
22
+ {
23
+ name: "question",
24
+ type: models_1.ToolParamType.STRING,
25
+ description: "The question to ask the user",
26
+ required: true,
27
+ },
28
+ {
29
+ name: "context",
30
+ type: models_1.ToolParamType.STRING,
31
+ description: "Optional context explaining why you need this information",
32
+ required: false,
33
+ },
34
+ ],
35
+ };
36
+ }
37
+ async execute(args) {
38
+ const question = args["question"];
39
+ if (!question)
40
+ return "Error: 'question' parameter is required";
41
+ // CRs are autonomous — don't prompt the user, tell the agent to proceed
42
+ if (this.requester.investigationSource !== interactions_1.InvestigationSource.USER) {
43
+ return "This is a context request investigation — you cannot ask the user questions. Use the available tools to answer the query autonomously.";
44
+ }
45
+ const context = args["context"];
46
+ const response = await this.requester.requestUserInteraction({
47
+ type: interactions_1.InteractionType.ASK_QUESTION,
48
+ interactionId: (0, crypto_1.randomUUID)(),
49
+ question,
50
+ context,
51
+ });
52
+ const askResponse = response;
53
+ return askResponse.answer;
54
+ }
55
+ }
56
+ exports.AskUserTool = AskUserTool;
57
+ //# sourceMappingURL=interactive.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interactive.js","sourceRoot":"","sources":["../../src/tools/interactive.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,mCAAoC;AAEpC,sCAAoD;AACpD,kDAAuE;AAKvE,MAAa,WAAW;IACL,SAAS,CAA2B;IAErD,YAAY,SAAmC;QAC7C,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAED,IAAI,WAAW;QACb,OAAO;YACL,IAAI,EAAE,iBAAQ,CAAC,eAAe;YAC9B,WAAW,EACT,kKAAkK;YACpK,UAAU,EAAE;gBACV;oBACE,IAAI,EAAE,UAAU;oBAChB,IAAI,EAAE,sBAAa,CAAC,MAAM;oBAC1B,WAAW,EAAE,8BAA8B;oBAC3C,QAAQ,EAAE,IAAI;iBACf;gBACD;oBACE,IAAI,EAAE,SAAS;oBACf,IAAI,EAAE,sBAAa,CAAC,MAAM;oBAC1B,WAAW,EAAE,2DAA2D;oBACxE,QAAQ,EAAE,KAAK;iBAChB;aACF;SACF,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,IAA6B;QACzC,MAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAuB,CAAC;QACxD,IAAI,CAAC,QAAQ;YAAE,OAAO,yCAAyC,CAAC;QAEhE,wEAAwE;QACxE,IAAI,IAAI,CAAC,SAAS,CAAC,mBAAmB,KAAK,kCAAmB,CAAC,IAAI,EAAE,CAAC;YACpE,OAAO,wIAAwI,CAAC;QAClJ,CAAC;QAED,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAuB,CAAC;QAEtD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,sBAAsB,CAAC;YAC3D,IAAI,EAAE,8BAAe,CAAC,YAAY;YAClC,aAAa,EAAE,IAAA,mBAAU,GAAE;YAC3B,QAAQ;YACR,OAAO;SACR,CAAC,CAAC;QAEH,MAAM,WAAW,GAAG,QAA+B,CAAC;QACpD,OAAO,WAAW,CAAC,MAAM,CAAC;IAC5B,CAAC;CACF;AAlDD,kCAkDC"}
@@ -0,0 +1,72 @@
1
+ /**
2
+ * tools/logs.ts — Log capture + built-in log tools
3
+ *
4
+ * Implements: client_read_app_logs, client_search_app_logs,
5
+ * client_clear_app_logs, client_flag_app_logs
6
+ *
7
+ * Mirrors PRBELogCapture.swift + log tool implementations from PRBEAgentTools.swift.
8
+ * Log capture works by monkey-patching console.log/warn/error in the Electron main process.
9
+ */
10
+ import type { PRBEToolDeclaration, FlaggedFileIn } from "../models";
11
+ import type { PRBETool } from "./index";
12
+ export interface LogEntry {
13
+ timestamp: Date;
14
+ level: string;
15
+ category: string;
16
+ message: string;
17
+ }
18
+ export declare class PRBELogCapture {
19
+ private entries;
20
+ private readonly maxEntries;
21
+ private isCapturing;
22
+ private originalLog?;
23
+ private originalWarn?;
24
+ private originalError?;
25
+ private originalDebug?;
26
+ private originalInfo?;
27
+ constructor(maxEntries?: number);
28
+ log(message: string, level?: string, category?: string): void;
29
+ get count(): number;
30
+ getEntries(options?: {
31
+ offset?: number;
32
+ limit?: number;
33
+ level?: string;
34
+ from?: Date;
35
+ to?: Date;
36
+ }): LogEntry[];
37
+ search(pattern: string, contextLines?: number, maxResults?: number): Array<{
38
+ index: number;
39
+ entry: LogEntry;
40
+ }>;
41
+ clearLogs(): number;
42
+ startCapturing(): void;
43
+ stopCapturing(): void;
44
+ getAllEntries(): LogEntry[];
45
+ private append;
46
+ }
47
+ export declare class ReadAppLogsTool implements PRBETool {
48
+ private readonly logCapture;
49
+ constructor(logCapture: PRBELogCapture);
50
+ get declaration(): PRBEToolDeclaration;
51
+ execute(args: Record<string, unknown>): Promise<string>;
52
+ }
53
+ export declare class SearchAppLogsTool implements PRBETool {
54
+ private readonly logCapture;
55
+ constructor(logCapture: PRBELogCapture);
56
+ get declaration(): PRBEToolDeclaration;
57
+ execute(args: Record<string, unknown>): Promise<string>;
58
+ }
59
+ export declare class ClearAppLogsTool implements PRBETool {
60
+ private readonly logCapture;
61
+ constructor(logCapture: PRBELogCapture);
62
+ get declaration(): PRBEToolDeclaration;
63
+ execute(_args: Record<string, unknown>): Promise<string>;
64
+ }
65
+ export declare class FlagAppLogsTool implements PRBETool {
66
+ private readonly logCapture;
67
+ private readonly onFlag;
68
+ constructor(logCapture: PRBELogCapture, onFlag: (file: FlaggedFileIn) => void);
69
+ get declaration(): PRBEToolDeclaration;
70
+ execute(args: Record<string, unknown>): Promise<string>;
71
+ }
72
+ //# sourceMappingURL=logs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logs.d.ts","sourceRoot":"","sources":["../../src/tools/logs.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAEpE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAMxC,MAAM,WAAW,QAAQ;IACvB,SAAS,EAAE,IAAI,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB;AAMD,qBAAa,cAAc;IACzB,OA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