@rcrsr/claude-code-runner 0.10.0 → 0.11.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 (81) hide show
  1. package/README.md +13 -10
  2. package/dist/cli/args.d.ts.map +1 -1
  3. package/dist/cli/args.js +25 -4
  4. package/dist/cli/args.js.map +1 -1
  5. package/dist/cli/docs.d.ts +9 -0
  6. package/dist/cli/docs.d.ts.map +1 -0
  7. package/dist/cli/docs.js +55 -0
  8. package/dist/cli/docs.js.map +1 -0
  9. package/dist/cli/index.d.ts +1 -0
  10. package/dist/cli/index.d.ts.map +1 -1
  11. package/dist/cli/index.js +1 -0
  12. package/dist/cli/index.js.map +1 -1
  13. package/dist/index.js +7 -1
  14. package/dist/index.js.map +1 -1
  15. package/dist/output/colors.d.ts +29 -1
  16. package/dist/output/colors.d.ts.map +1 -1
  17. package/dist/output/colors.js +95 -1
  18. package/dist/output/colors.js.map +1 -1
  19. package/dist/output/formatter.d.ts +6 -0
  20. package/dist/output/formatter.d.ts.map +1 -1
  21. package/dist/output/formatter.js +50 -9
  22. package/dist/output/formatter.js.map +1 -1
  23. package/dist/rill/context.d.ts +2 -0
  24. package/dist/rill/context.d.ts.map +1 -1
  25. package/dist/rill/context.js +84 -13
  26. package/dist/rill/context.js.map +1 -1
  27. package/dist/rill/runner.d.ts.map +1 -1
  28. package/dist/rill/runner.js +56 -1
  29. package/dist/rill/runner.js.map +1 -1
  30. package/dist/types/runner.d.ts +10 -1
  31. package/dist/types/runner.d.ts.map +1 -1
  32. package/dist/types/runner.js.map +1 -1
  33. package/dist/utils/constants.d.ts +4 -0
  34. package/dist/utils/constants.d.ts.map +1 -1
  35. package/dist/utils/constants.js +5 -0
  36. package/dist/utils/constants.js.map +1 -1
  37. package/package.json +2 -4
  38. package/dist/core/index.d.ts +0 -2
  39. package/dist/core/index.d.ts.map +0 -1
  40. package/dist/core/index.js +0 -2
  41. package/dist/core/index.js.map +0 -1
  42. package/dist/core/runner.d.ts +0 -22
  43. package/dist/core/runner.d.ts.map +0 -1
  44. package/dist/core/runner.js +0 -100
  45. package/dist/core/runner.js.map +0 -1
  46. package/dist/output/ui-components.d.ts +0 -34
  47. package/dist/output/ui-components.d.ts.map +0 -1
  48. package/dist/output/ui-components.js +0 -158
  49. package/dist/output/ui-components.js.map +0 -1
  50. package/dist/output/ui-renderer.d.ts +0 -18
  51. package/dist/output/ui-renderer.d.ts.map +0 -1
  52. package/dist/output/ui-renderer.js +0 -75
  53. package/dist/output/ui-renderer.js.map +0 -1
  54. package/dist/output/ui-state.d.ts +0 -71
  55. package/dist/output/ui-state.d.ts.map +0 -1
  56. package/dist/output/ui-state.js +0 -131
  57. package/dist/output/ui-state.js.map +0 -1
  58. package/dist/parsers/signals.d.ts +0 -10
  59. package/dist/parsers/signals.d.ts.map +0 -1
  60. package/dist/parsers/signals.js +0 -21
  61. package/dist/parsers/signals.js.map +0 -1
  62. package/dist/script/index.d.ts +0 -8
  63. package/dist/script/index.d.ts.map +0 -1
  64. package/dist/script/index.js +0 -10
  65. package/dist/script/index.js.map +0 -1
  66. package/dist/script/loader.d.ts +0 -13
  67. package/dist/script/loader.d.ts.map +0 -1
  68. package/dist/script/loader.js +0 -66
  69. package/dist/script/loader.js.map +0 -1
  70. package/dist/script/parser.d.ts +0 -63
  71. package/dist/script/parser.d.ts.map +0 -1
  72. package/dist/script/parser.js +0 -349
  73. package/dist/script/parser.js.map +0 -1
  74. package/dist/script/types.d.ts +0 -49
  75. package/dist/script/types.d.ts.map +0 -1
  76. package/dist/script/types.js +0 -5
  77. package/dist/script/types.js.map +0 -1
  78. package/dist/script/variables.d.ts +0 -27
  79. package/dist/script/variables.d.ts.map +0 -1
  80. package/dist/script/variables.js +0 -74
  81. package/dist/script/variables.js.map +0 -1
@@ -1,131 +0,0 @@
1
- /**
2
- * UI state management for parallel agent display
3
- */
4
- import { UI_MAX_AGENTS, UI_MAX_DESCRIPTION_LENGTH, UI_MAX_VISIBLE_TOOLS, } from '../utils/constants.js';
5
- /**
6
- * Create initial UI state with empty agents and log
7
- */
8
- export function createUIState() {
9
- return {
10
- agents: new Map(),
11
- mainLog: [],
12
- renderStartTime: Date.now(),
13
- spinnerFrame: 0,
14
- };
15
- }
16
- /**
17
- * Register a new agent in the UI state
18
- * @throws {Error} if agent count exceeds UI_MAX_AGENTS
19
- * @throws {Error} if agent ID already registered
20
- */
21
- export function registerAgent(state, task, description) {
22
- // EC-1: Check agent count limit
23
- if (state.agents.size >= UI_MAX_AGENTS) {
24
- throw new Error('Maximum 10 concurrent agents exceeded');
25
- }
26
- // EC-2: Check for duplicate agent ID
27
- if (state.agents.has(task.id)) {
28
- throw new Error(`Agent ${task.id} already registered`);
29
- }
30
- // Truncate description to 40 characters
31
- const truncatedDescription = description.length > UI_MAX_DESCRIPTION_LENGTH
32
- ? description.slice(0, UI_MAX_DESCRIPTION_LENGTH)
33
- : description;
34
- // Create agent state
35
- const agentState = {
36
- id: task.id,
37
- name: task.name,
38
- description: truncatedDescription,
39
- label: task.label,
40
- toolCalls: [],
41
- messageCount: 0,
42
- startTime: Date.now(),
43
- status: 'running',
44
- };
45
- // Check if this is the first agent (trigger callback before adding)
46
- const isFirstAgent = state.agents.size === 0;
47
- // Add to agents map
48
- state.agents.set(task.id, agentState);
49
- // Trigger callback for first agent
50
- if (isFirstAgent && state.onFirstAgent) {
51
- state.onFirstAgent();
52
- }
53
- // Add invocation entry to main log
54
- const logEntry = {
55
- timestamp: new Date(),
56
- agentLabel: task.label,
57
- agentName: task.name,
58
- type: 'invocation',
59
- content: truncatedDescription,
60
- };
61
- state.mainLog.push(logEntry);
62
- }
63
- /**
64
- * Record a tool call for an agent
65
- * @throws {Error} if agent ID not found
66
- * @throws {Error} if tool name empty
67
- */
68
- export function recordToolCall(state, agentId, toolName, args) {
69
- // EC-3: Check agent ID exists
70
- const agent = state.agents.get(agentId);
71
- if (!agent) {
72
- throw new Error(`Unknown agent: ${agentId}`);
73
- }
74
- // EC-4: Check tool name not empty
75
- if (!toolName || toolName.trim().length === 0) {
76
- throw new Error('Tool name required');
77
- }
78
- // Create tool call entry
79
- const toolCall = {
80
- toolName,
81
- args,
82
- timestamp: new Date(),
83
- };
84
- // Add to agent's tool calls (FIFO management for max 5 visible)
85
- agent.toolCalls.push(toolCall);
86
- // AC-8: Remove oldest if exceeds max visible tools
87
- if (agent.toolCalls.length > UI_MAX_VISIBLE_TOOLS) {
88
- agent.toolCalls.shift();
89
- }
90
- // Add tool call entry to main log
91
- const logEntry = {
92
- timestamp: new Date(),
93
- agentLabel: agent.label,
94
- agentName: agent.name,
95
- type: 'tool',
96
- content: `${toolName}(${args})`,
97
- };
98
- state.mainLog.push(logEntry);
99
- }
100
- /**
101
- * Mark agent complete and add completion entry to main log
102
- * @throws {Error} if agent ID not found
103
- * @throws {Error} if agent already complete
104
- */
105
- export function completeAgent(state, agentId) {
106
- // EC-5: Check agent ID exists
107
- const agent = state.agents.get(agentId);
108
- if (!agent) {
109
- throw new Error(`Unknown agent: ${agentId}`);
110
- }
111
- // EC-6: Check agent not already complete
112
- if (agent.status === 'complete') {
113
- throw new Error(`Agent ${agentId} already completed`);
114
- }
115
- // Calculate duration from agent start time to current time
116
- const duration = Date.now() - agent.startTime;
117
- // Set agent status to 'complete' for renderer to remove box
118
- agent.status = 'complete';
119
- // Add completion entry to main log with duration and message count
120
- const logEntry = {
121
- timestamp: new Date(),
122
- agentLabel: agent.label,
123
- agentName: agent.name,
124
- type: 'completion',
125
- content: 'Complete',
126
- duration,
127
- messageCount: agent.messageCount,
128
- };
129
- state.mainLog.push(logEntry);
130
- }
131
- //# sourceMappingURL=ui-state.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ui-state.js","sourceRoot":"","sources":["../../src/output/ui-state.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EACL,aAAa,EACb,yBAAyB,EACzB,oBAAoB,GACrB,MAAM,uBAAuB,CAAC;AAkD/B;;GAEG;AACH,MAAM,UAAU,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Signal } from '../types/runner.js';
5
- /**
6
- * Detect loop control signals in Claude's text output
7
- * Returns null if no signal found
8
- */
9
- export declare function detectRunnerSignal(text: string): RunnerSignal | null;
10
- //# sourceMappingURL=signals.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"signals.d.ts","sourceRoot":"","sources":["../../src/parsers/signals.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAkB,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvE;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI,CAWpE"}
@@ -1,21 +0,0 @@
1
- /**
2
- * Runner signal detection in Claude output
3
- */
4
- import { RUNNER_SIGNALS } from '../types/runner.js';
5
- /**
6
- * Detect loop control signals in Claude's text output
7
- * Returns null if no signal found
8
- */
9
- export function detectRunnerSignal(text) {
10
- if (text.includes(RUNNER_SIGNALS.REPEAT_STEP)) {
11
- return 'repeat_step';
12
- }
13
- if (text.includes(RUNNER_SIGNALS.BLOCKED)) {
14
- return 'blocked';
15
- }
16
- if (text.includes(RUNNER_SIGNALS.ERROR)) {
17
- return 'error';
18
- }
19
- return null;
20
- }
21
- //# sourceMappingURL=signals.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"signals.js","sourceRoot":"","sources":["../../src/parsers/signals.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAqB,MAAM,oBAAoB,CAAC;AAEvE;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAAY;IAC7C,IAAI,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,CAAC;QAC9C,OAAO,aAAa,CAAC;IACvB,CAAC;IACD,IAAI,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,CAAC;QAC1C,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,IAAI,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,CAAC;QACxC,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -1,8 +0,0 @@
1
- /**
2
- * Script module - parsing, loading, and variable management
3
- */
4
- export type { CommandLine, ParsedScript, PromptLine, ScriptFrontmatter, ScriptLine, VariableStore, } from './types.js';
5
- export { loadScript } from './loader.js';
6
- export { extractScriptLines, parseCommandLine, parsePromptLine, parseScriptLine, } from './parser.js';
7
- export { captureOutput, createVariableStore, getCaptureLogMessage, getSubstitutionList, substituteVariables, } from './variables.js';
8
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/script/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,YAAY,EACV,WAAW,EACX,YAAY,EACZ,UAAU,EACV,iBAAiB,EACjB,UAAU,EACV,aAAa,GACd,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,eAAe,GAChB,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,gBAAgB,CAAC"}
@@ -1,10 +0,0 @@
1
- /**
2
- * Script module - parsing, loading, and variable management
3
- */
4
- // Loader
5
- export { loadScript } from './loader.js';
6
- // Parser (for direct use if needed)
7
- export { extractScriptLines, parseCommandLine, parsePromptLine, parseScriptLine, } from './parser.js';
8
- // Variables
9
- export { captureOutput, createVariableStore, getCaptureLogMessage, getSubstitutionList, substituteVariables, } from './variables.js';
10
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/script/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAYH,SAAS;AACT,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,oCAAoC;AACpC,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,eAAe,GAChB,MAAM,aAAa,CAAC;AAErB,YAAY;AACZ,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,gBAAgB,CAAC"}
@@ -1,13 +0,0 @@
1
- /**
2
- * Script file loading with frontmatter and argument validation
3
- */
4
- import type { ParsedScript } from './types.js';
5
- /**
6
- * Load and parse a script file
7
- *
8
- * @param scriptFile - Path to the script file
9
- * @param scriptArgs - Arguments passed to the script (for validation only)
10
- * @returns Parsed script with lines and frontmatter
11
- */
12
- export declare function loadScript(scriptFile: string, scriptArgs?: string[]): ParsedScript;
13
- //# sourceMappingURL=loader.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/script/loader.ts"],"names":[],"mappings":"AAAA;;GAEG;AAOH,OAAO,KAAK,EAAE,YAAY,EAAiC,MAAM,YAAY,CAAC;AA+B9E;;;;;;GAMG;AACH,wBAAgB,UAAU,CACxB,UAAU,EAAE,MAAM,EAClB,UAAU,GAAE,MAAM,EAAO,GACxB,YAAY,CAmCd"}
@@ -1,66 +0,0 @@
1
- /**
2
- * Script file loading with frontmatter and argument validation
3
- */
4
- import * as fs from 'fs';
5
- import { parseFrontmatter } from '../templates/command.js';
6
- import { parseArgumentHint } from '../utils/arguments.js';
7
- import { extractScriptLines, parseScriptLine } from './parser.js';
8
- /**
9
- * Validate script arguments against argument-hint
10
- */
11
- function validateArguments(frontmatter, args) {
12
- const { requiredCount, optionalPositions } = parseArgumentHint(frontmatter.argumentHint);
13
- if (args.length < requiredCount) {
14
- const missing = [];
15
- for (let i = args.length + 1; i <= requiredCount; i++) {
16
- if (!optionalPositions.has(i)) {
17
- missing.push(`$${i}`);
18
- }
19
- }
20
- if (missing.length > 0) {
21
- const hint = frontmatter.argumentHint
22
- ? ` (usage: ${frontmatter.argumentHint})`
23
- : '';
24
- throw new Error(`Missing required arguments: ${missing.join(', ')}${hint}`);
25
- }
26
- }
27
- }
28
- /**
29
- * Load and parse a script file
30
- *
31
- * @param scriptFile - Path to the script file
32
- * @param scriptArgs - Arguments passed to the script (for validation only)
33
- * @returns Parsed script with lines and frontmatter
34
- */
35
- export function loadScript(scriptFile, scriptArgs = []) {
36
- if (!fs.existsSync(scriptFile)) {
37
- throw new Error(`Script not found: ${scriptFile}`);
38
- }
39
- const content = fs.readFileSync(scriptFile, 'utf-8');
40
- // Parse frontmatter (reuse from templates/command.ts)
41
- const { frontmatter: rawFrontmatter, body } = parseFrontmatter(content);
42
- // Convert to ScriptFrontmatter (handle exactOptionalPropertyTypes)
43
- const frontmatter = {};
44
- if (rawFrontmatter.model)
45
- frontmatter.model = rawFrontmatter.model;
46
- if (rawFrontmatter.description)
47
- frontmatter.description = rawFrontmatter.description;
48
- if (rawFrontmatter.argumentHint)
49
- frontmatter.argumentHint = rawFrontmatter.argumentHint;
50
- // Validate arguments
51
- validateArguments(frontmatter, scriptArgs);
52
- // Extract raw lines (handling heredocs)
53
- const rawLines = extractScriptLines(body);
54
- // Parse each line
55
- const lines = rawLines.map((line, index) => {
56
- try {
57
- return parseScriptLine(line);
58
- }
59
- catch (error) {
60
- const msg = error instanceof Error ? error.message : String(error);
61
- throw new Error(`Script parse error on line ${index + 1}: ${msg}`);
62
- }
63
- });
64
- return { lines, frontmatter };
65
- }
66
- //# sourceMappingURL=loader.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"loader.js","sourceRoot":"","sources":["../../src/script/loader.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AAEzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,E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EAAE,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAExE,mEAAmE;IACnE,MAAM,WAAW,GAAsB,EAAE,CAAC;IAC1C,IAAI,cAAc,CAAC,KAAK;QAAE,WAAW,CAAC,KAAK,GAAG,cAAc,CAAC,KAAK,CAAC;IACnE,IAAI,cAAc,CAAC,WAAW;QAC5B,WAAW,CAAC,WAAW,GAAG,cAAc,CAAC,WAAW,CAAC;IACvD,IAAI,cAAc,CAAC,YAAY;QAC7B,WAAW,CAAC,YAAY,GAAG,cAAc,CAAC,YAAY,CAAC;IAEzD,qBAAqB;IACrB,iBAAiB,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;IAE3C,wCAAwC;IACxC,MAAM,QAAQ,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAC;IAE1C,kBAAkB;IAClB,MAAM,KAAK,GAAiB,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;QACvD,IAAI,CAAC;YACH,OAAO,eAAe,CAAC,IAAI,CAAC,CAAC;QAC/B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,GAAG,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACnE,MAAM,IAAI,KAAK,CAAC,8BAA8B,KAAK,GAAG,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC;QACrE,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC;AAChC,CAAC"}
@@ -1,63 +0,0 @@
1
- /**
2
- * Script line parser
3
- *
4
- * Parses the new script syntax:
5
- * - prompt("text") -> $var
6
- * - prompt(<<EOF ... EOF) -> $var
7
- * - command("name", ["arg1", "arg2"]) -> $var
8
- */
9
- import type { CommandLine, PromptLine, ScriptLine } from './types.js';
10
- /**
11
- * Parse a quoted string, handling escape sequences
12
- * Returns the parsed string and the position after the closing quote
13
- */
14
- export declare function parseQuotedString(input: string, startPos: number): {
15
- value: string;
16
- endPos: number;
17
- };
18
- /**
19
- * Parse a heredoc block
20
- * Input should start at << position
21
- * Returns the content and position after the closing delimiter
22
- */
23
- export declare function parseHeredoc(input: string, startPos: number): {
24
- value: string;
25
- endPos: number;
26
- };
27
- /**
28
- * Parse an array of strings: ["arg1", "arg2"]
29
- */
30
- export declare function parseStringArray(input: string, startPos: number): {
31
- values: string[];
32
- endPos: number;
33
- };
34
- /**
35
- * Parse capture syntax: -> $varname
36
- * Returns variable name (without $) or undefined
37
- */
38
- export declare function parseCapture(input: string, startPos: number): {
39
- capture?: string;
40
- endPos: number;
41
- };
42
- /**
43
- * Parse a prompt line: prompt("text") or prompt(<<EOF...EOF)
44
- */
45
- export declare function parsePromptLine(input: string): PromptLine;
46
- /**
47
- * Parse a command line: command("name") or command("name", ["args"])
48
- */
49
- export declare function parseCommandLine(input: string): CommandLine;
50
- /**
51
- * Parse a single script line
52
- */
53
- export declare function parseScriptLine(line: string): ScriptLine;
54
- /**
55
- * Check if a line is a comment or empty
56
- */
57
- export declare function isCommentOrEmpty(line: string): boolean;
58
- /**
59
- * Parse script content into lines, handling multi-line heredocs
60
- * Returns raw line strings (not parsed) for further processing
61
- */
62
- export declare function extractScriptLines(content: string): string[];
63
- //# sourceMappingURL=parser.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/script/parser.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAOtE;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,GACf;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAyCnC;AAED;;;;GAIG;AACH,wBAAgB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