@dirgha/code 1.16.2 → 1.17.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.
- package/dist/cli/config.d.ts +3 -3
- package/dist/cli/config.js +34 -14
- package/dist/cli/config.js.map +1 -1
- package/dist/cli/first-run.d.ts +10 -0
- package/dist/cli/first-run.js +86 -0
- package/dist/cli/first-run.js.map +1 -0
- package/dist/cli/interactive.js +129 -116
- package/dist/cli/interactive.js.map +1 -1
- package/dist/cli/main.js +24 -4
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/slash/cost.d.ts +6 -0
- package/dist/cli/slash/cost.js +12 -0
- package/dist/cli/slash/cost.js.map +1 -0
- package/dist/cli/slash/export.d.ts +2 -0
- package/dist/cli/slash/export.js +151 -0
- package/dist/cli/slash/export.js.map +1 -0
- package/dist/cli/slash/fs.d.ts +2 -0
- package/dist/cli/slash/fs.js +145 -0
- package/dist/cli/slash/fs.js.map +1 -0
- package/dist/cli/slash/index.d.ts +29 -25
- package/dist/cli/slash/index.js +32 -24
- package/dist/cli/slash/index.js.map +1 -1
- package/dist/cli/slash/mcp.d.ts +2 -0
- package/dist/cli/slash/mcp.js +93 -0
- package/dist/cli/slash/mcp.js.map +1 -0
- package/dist/cli/slash/models.d.ts +1 -1
- package/dist/cli/slash/models.js +21 -20
- package/dist/cli/slash/models.js.map +1 -1
- package/dist/cli/slash.d.ts +5 -5
- package/dist/cli/slash.js +53 -22
- package/dist/cli/slash.js.map +1 -1
- package/dist/cli/subcommands/models.js +6 -2
- package/dist/cli/subcommands/models.js.map +1 -1
- package/dist/cli/update-check.d.ts +1 -0
- package/dist/cli/update-check.js +77 -0
- package/dist/cli/update-check.js.map +1 -0
- package/dist/context/default-soul.md +1 -1
- package/dist/context/ledger.d.ts +12 -2
- package/dist/context/ledger.js +92 -32
- package/dist/context/ledger.js.map +1 -1
- package/dist/context/memory.d.ts +7 -2
- package/dist/context/memory.js +71 -50
- package/dist/context/memory.js.map +1 -1
- package/dist/context/primer.d.ts +4 -2
- package/dist/context/primer.js +18 -10
- package/dist/context/primer.js.map +1 -1
- package/dist/context/session.d.ts +8 -7
- package/dist/context/session.js +40 -23
- package/dist/context/session.js.map +1 -1
- package/dist/daemon/server.d.ts +4 -4
- package/dist/daemon/server.js +66 -36
- package/dist/daemon/server.js.map +1 -1
- package/dist/fleet/templates.d.ts +18 -0
- package/dist/fleet/templates.js +103 -0
- package/dist/fleet/templates.js.map +1 -0
- package/dist/intelligence/error-classifier.d.ts +2 -2
- package/dist/intelligence/error-classifier.js +76 -33
- package/dist/intelligence/error-classifier.js.map +1 -1
- package/dist/intelligence/prices.js +819 -193
- package/dist/intelligence/prices.js.map +1 -1
- package/dist/intelligence/smart-router.d.ts +3 -1
- package/dist/intelligence/smart-router.js +34 -12
- package/dist/intelligence/smart-router.js.map +1 -1
- package/dist/kernel/agent-loop.d.ts +11 -0
- package/dist/kernel/agent-loop.js +43 -2
- package/dist/kernel/agent-loop.js.map +1 -1
- package/dist/kernel/types.d.ts +30 -27
- package/dist/lsp/client.d.ts +76 -0
- package/dist/lsp/client.js +332 -0
- package/dist/lsp/client.js.map +1 -0
- package/dist/lsp/detector.d.ts +13 -0
- package/dist/lsp/detector.js +152 -0
- package/dist/lsp/detector.js.map +1 -0
- package/dist/lsp/index.d.ts +25 -0
- package/dist/lsp/index.js +127 -0
- package/dist/lsp/index.js.map +1 -0
- package/dist/providers/dispatch.d.ts +1 -1
- package/dist/providers/dispatch.js +70 -31
- package/dist/providers/dispatch.js.map +1 -1
- package/dist/providers/family-fallback.d.ts +12 -0
- package/dist/providers/family-fallback.js +73 -0
- package/dist/providers/family-fallback.js.map +1 -0
- package/dist/providers/health.d.ts +13 -0
- package/dist/providers/health.js +71 -0
- package/dist/providers/health.js.map +1 -0
- package/dist/providers/index.d.ts +15 -12
- package/dist/providers/index.js +63 -40
- package/dist/providers/index.js.map +1 -1
- package/dist/subagents/delegator.d.ts +2 -2
- package/dist/subagents/delegator.js +29 -14
- package/dist/subagents/delegator.js.map +1 -1
- package/dist/subagents/loop-detector.d.ts +30 -0
- package/dist/subagents/loop-detector.js +62 -0
- package/dist/subagents/loop-detector.js.map +1 -0
- package/dist/tools/exec.d.ts +8 -4
- package/dist/tools/exec.js +10 -1
- package/dist/tools/exec.js.map +1 -1
- package/dist/tools/fs-edit.d.ts +1 -1
- package/dist/tools/fs-edit.js +30 -17
- package/dist/tools/fs-edit.js.map +1 -1
- package/dist/tools/index.d.ts +26 -18
- package/dist/tools/index.js +31 -18
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/lsp-definition.d.ts +2 -0
- package/dist/tools/lsp-definition.js +48 -0
- package/dist/tools/lsp-definition.js.map +1 -0
- package/dist/tools/lsp-hover.d.ts +2 -0
- package/dist/tools/lsp-hover.js +68 -0
- package/dist/tools/lsp-hover.js.map +1 -0
- package/dist/tools/lsp-references.d.ts +2 -0
- package/dist/tools/lsp-references.js +48 -0
- package/dist/tools/lsp-references.js.map +1 -0
- package/dist/tools/lsp-symbols.d.ts +2 -0
- package/dist/tools/lsp-symbols.js +62 -0
- package/dist/tools/lsp-symbols.js.map +1 -0
- package/dist/tools/registry.d.ts +3 -2
- package/dist/tools/registry.js.map +1 -1
- package/dist/tools/shell.d.ts +1 -1
- package/dist/tools/shell.js +55 -36
- package/dist/tools/shell.js.map +1 -1
- package/dist/tui/ink/App.d.ts +2 -0
- package/dist/tui/ink/App.js +29 -9
- package/dist/tui/ink/App.js.map +1 -1
- package/dist/tui/ink/components/ToolBox.d.ts +5 -0
- package/dist/tui/ink/components/ToolBox.js +45 -4
- package/dist/tui/ink/components/ToolBox.js.map +1 -1
- package/dist/tui/ink/components/ToolGroup.d.ts +1 -0
- package/dist/tui/ink/components/ToolGroup.js +20 -2
- package/dist/tui/ink/components/ToolGroup.js.map +1 -1
- package/dist/tui/ink/components/vim-bindings.d.ts +1 -1
- package/dist/tui/ink/components/vim-bindings.js +107 -40
- package/dist/tui/ink/components/vim-bindings.js.map +1 -1
- package/dist/tui/ink/index.d.ts +19 -18
- package/dist/tui/ink/index.js +26 -19
- package/dist/tui/ink/index.js.map +1 -1
- package/dist/tui/ink/use-event-projection.d.ts +2 -0
- package/dist/tui/ink/use-event-projection.js +28 -1
- package/dist/tui/ink/use-event-projection.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
export const TEAM_TEMPLATES = [
|
|
2
|
+
{
|
|
3
|
+
name: "bugfix",
|
|
4
|
+
description: "Investigate, fix, and verify a bug",
|
|
5
|
+
coordination: "sequential",
|
|
6
|
+
agents: [
|
|
7
|
+
{
|
|
8
|
+
type: "research",
|
|
9
|
+
count: 1,
|
|
10
|
+
tools: ["fs_read", "search_grep", "search_glob", "git", "web_fetch"],
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
type: "code",
|
|
14
|
+
count: 1,
|
|
15
|
+
tools: ["fs_read", "fs_write", "fs_edit", "shell"],
|
|
16
|
+
},
|
|
17
|
+
{ type: "verify", count: 1, tools: ["fs_read", "shell", "search_grep"] },
|
|
18
|
+
],
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: "refactor",
|
|
22
|
+
description: "Research codebase and refactor in parallel",
|
|
23
|
+
coordination: "parallel",
|
|
24
|
+
agents: [
|
|
25
|
+
{
|
|
26
|
+
type: "research",
|
|
27
|
+
count: 1,
|
|
28
|
+
tools: ["fs_read", "search_grep", "search_glob", "git"],
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
type: "code",
|
|
32
|
+
count: 2,
|
|
33
|
+
tools: ["fs_read", "fs_write", "fs_edit", "shell"],
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: "research",
|
|
39
|
+
description: "Deep research using multiple agents in parallel",
|
|
40
|
+
coordination: "parallel",
|
|
41
|
+
agents: [
|
|
42
|
+
{
|
|
43
|
+
type: "research",
|
|
44
|
+
count: 2,
|
|
45
|
+
tools: ["fs_read", "search_grep", "search_glob", "web_fetch", "git"],
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: "review",
|
|
51
|
+
description: "Review code and verify correctness",
|
|
52
|
+
coordination: "sequential",
|
|
53
|
+
agents: [
|
|
54
|
+
{
|
|
55
|
+
type: "code",
|
|
56
|
+
count: 1,
|
|
57
|
+
tools: ["fs_read", "search_grep", "search_glob"],
|
|
58
|
+
},
|
|
59
|
+
{ type: "verify", count: 1, tools: ["fs_read", "shell", "search_grep"] },
|
|
60
|
+
],
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: "implement",
|
|
64
|
+
description: "Implement a feature with parallel coding agents",
|
|
65
|
+
coordination: "parallel",
|
|
66
|
+
agents: [
|
|
67
|
+
{
|
|
68
|
+
type: "code",
|
|
69
|
+
count: 2,
|
|
70
|
+
tools: ["fs_read", "fs_write", "fs_edit", "shell"],
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
name: "triple-shot",
|
|
76
|
+
description: "Plan → implement → refine in three passes",
|
|
77
|
+
coordination: "sequential",
|
|
78
|
+
agents: [
|
|
79
|
+
{
|
|
80
|
+
type: "plan",
|
|
81
|
+
count: 1,
|
|
82
|
+
tools: ["fs_read", "search_grep", "search_glob"],
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
type: "code",
|
|
86
|
+
count: 1,
|
|
87
|
+
tools: ["fs_read", "fs_write", "fs_edit", "shell"],
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
type: "verify",
|
|
91
|
+
count: 1,
|
|
92
|
+
tools: ["fs_read", "shell", "search_grep", "fs_edit"],
|
|
93
|
+
},
|
|
94
|
+
],
|
|
95
|
+
},
|
|
96
|
+
];
|
|
97
|
+
export function getTemplate(name) {
|
|
98
|
+
return TEAM_TEMPLATES.find((t) => t.name === name);
|
|
99
|
+
}
|
|
100
|
+
export function listTemplateNames() {
|
|
101
|
+
return TEAM_TEMPLATES.map((t) => t.name);
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=templates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../src/fleet/templates.ts"],"names":[],"mappings":"AAiBA,MAAM,CAAC,MAAM,cAAc,GAAmB;IAC5C;QACE,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,oCAAoC;QACjD,YAAY,EAAE,YAAY;QAC1B,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,UAAU;gBAChB,KAAK,EAAE,CAAC;gBACR,KAAK,EAAE,CAAC,SAAS,EAAE,aAAa,EAAE,aAAa,EAAE,KAAK,EAAE,WAAW,CAAC;aACrE;YACD;gBACE,IAAI,EAAE,MAAM;gBACZ,KAAK,EAAE,CAAC;gBACR,KAAK,EAAE,CAAC,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,CAAC;aACnD;YACD,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,SAAS,EAAE,OAAO,EAAE,aAAa,CAAC,EAAE;SACzE;KACF;IACD;QACE,IAAI,EAAE,UAAU;QAChB,WAAW,EAAE,4CAA4C;QACzD,YAAY,EAAE,UAAU;QACxB,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,UAAU;gBAChB,KAAK,EAAE,CAAC;gBACR,KAAK,EAAE,CAAC,SAAS,EAAE,aAAa,EAAE,aAAa,EAAE,KAAK,CAAC;aACxD;YACD;gBACE,IAAI,EAAE,MAAM;gBACZ,KAAK,EAAE,CAAC;gBACR,KAAK,EAAE,CAAC,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,CAAC;aACnD;SACF;KACF;IACD;QACE,IAAI,EAAE,UAAU;QAChB,WAAW,EAAE,iDAAiD;QAC9D,YAAY,EAAE,UAAU;QACxB,MAAM,EAAE;YACN;gBACE,IA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AAEF,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,OAAO,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;AACrD,CAAC;AAED,MAAM,UAAU,iBAAiB;IAC/B,OAAO,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AAC3C,CAAC"}
|
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
* ClassifiedError with actionable recovery hints. The agent loop and
|
|
4
4
|
* retry policy consult this — no string matching anywhere else.
|
|
5
5
|
*/
|
|
6
|
-
import type { ErrorClassifier } from
|
|
7
|
-
export type ErrorReason =
|
|
6
|
+
import type { ErrorClassifier } from "../kernel/types.js";
|
|
7
|
+
export type ErrorReason = "auth" | "billing" | "rate_limit" | "overloaded" | "timeout" | "network" | "context_overflow" | "model_not_found" | "format_error" | "tool_schema" | "content_filter" | "unknown";
|
|
8
8
|
export declare function createErrorClassifier(): ErrorClassifier;
|
|
@@ -3,69 +3,112 @@
|
|
|
3
3
|
* ClassifiedError with actionable recovery hints. The agent loop and
|
|
4
4
|
* retry policy consult this — no string matching anywhere else.
|
|
5
5
|
*/
|
|
6
|
-
import { ProviderError } from
|
|
6
|
+
import { ProviderError } from "../providers/iface.js";
|
|
7
7
|
export function createErrorClassifier() {
|
|
8
8
|
return {
|
|
9
9
|
classify(err, provider, model) {
|
|
10
10
|
const { reason, backoffMs } = diagnose(err);
|
|
11
|
-
|
|
12
|
-
void model;
|
|
11
|
+
const userMessage = composeUserMessage(reason, err, provider, model);
|
|
13
12
|
return {
|
|
14
13
|
reason,
|
|
15
14
|
retryable: isRetryable(reason),
|
|
16
15
|
backoffMs,
|
|
17
16
|
shouldFallback: shouldFallback(reason),
|
|
17
|
+
userMessage,
|
|
18
18
|
};
|
|
19
19
|
},
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
|
+
const PROVIDER_ENV = {
|
|
23
|
+
anthropic: "ANTHROPIC_API_KEY",
|
|
24
|
+
openai: "OPENAI_API_KEY",
|
|
25
|
+
openrouter: "OPENROUTER_API_KEY",
|
|
26
|
+
nvidia: "NVIDIA_API_KEY",
|
|
27
|
+
gemini: "GEMINI_API_KEY",
|
|
28
|
+
deepseek: "DEEPSEEK_API_KEY",
|
|
29
|
+
};
|
|
30
|
+
function composeUserMessage(reason, err, provider, model) {
|
|
31
|
+
const label = PROVIDER_ENV[provider];
|
|
32
|
+
switch (reason) {
|
|
33
|
+
case "auth":
|
|
34
|
+
if (label) {
|
|
35
|
+
return `No API key configured for ${provider}. Run: /keys set ${label} <your-key>
|
|
36
|
+
Or try a free model: /model tencent/hy3-preview:free`;
|
|
37
|
+
}
|
|
38
|
+
return `Authentication failed for ${provider}. Check your API key or run: dirgha setup`;
|
|
39
|
+
case "rate_limit":
|
|
40
|
+
return `Rate limited by ${provider}. Waiting and retrying automatically.
|
|
41
|
+
Tip: Add more providers for fallback.`;
|
|
42
|
+
case "overloaded":
|
|
43
|
+
return `${provider} is overloaded. Trying fallback...`;
|
|
44
|
+
case "model_not_found":
|
|
45
|
+
return `Model not found: ${model}. Check available: /models`;
|
|
46
|
+
case "billing":
|
|
47
|
+
return `Billing issue with ${provider}. Check your account balance.
|
|
48
|
+
Tip: Switch to a free model: /model tencent/hy3-preview:free`;
|
|
49
|
+
default: {
|
|
50
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
51
|
+
if (/5\d\d/.test(msg)) {
|
|
52
|
+
return `Server error from ${provider}. Retrying...`;
|
|
53
|
+
}
|
|
54
|
+
if (/timeout|timed out/i.test(msg)) {
|
|
55
|
+
return `Request to ${provider} timed out. Retrying...`;
|
|
56
|
+
}
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
22
61
|
function diagnose(err) {
|
|
23
62
|
if (err instanceof ProviderError) {
|
|
24
63
|
const status = err.status ?? 0;
|
|
25
64
|
if (status === 401 || status === 403)
|
|
26
|
-
return { reason:
|
|
65
|
+
return { reason: "auth" };
|
|
27
66
|
if (status === 402)
|
|
28
|
-
return { reason:
|
|
67
|
+
return { reason: "billing" };
|
|
29
68
|
if (status === 404)
|
|
30
|
-
return { reason:
|
|
69
|
+
return { reason: "model_not_found" };
|
|
31
70
|
if (status === 408)
|
|
32
|
-
return { reason:
|
|
71
|
+
return { reason: "timeout", backoffMs: 1000 };
|
|
33
72
|
if (status === 413)
|
|
34
|
-
return { reason:
|
|
73
|
+
return { reason: "context_overflow" };
|
|
35
74
|
if (status === 415 || status === 422)
|
|
36
|
-
return { reason:
|
|
75
|
+
return { reason: "format_error" };
|
|
37
76
|
if (status === 429)
|
|
38
|
-
return { reason:
|
|
77
|
+
return { reason: "rate_limit", backoffMs: 4000 };
|
|
39
78
|
if (status === 503 || status === 529)
|
|
40
|
-
return { reason:
|
|
79
|
+
return { reason: "overloaded", backoffMs: 3000 };
|
|
41
80
|
if (status >= 500)
|
|
42
|
-
return { reason:
|
|
81
|
+
return { reason: "overloaded", backoffMs: 2000 };
|
|
43
82
|
const msg = err.message.toLowerCase();
|
|
44
|
-
if (msg.includes(
|
|
45
|
-
return { reason:
|
|
46
|
-
if (msg.includes(
|
|
47
|
-
return { reason:
|
|
48
|
-
if (msg.includes(
|
|
49
|
-
return { reason:
|
|
50
|
-
return { reason:
|
|
83
|
+
if (msg.includes("content filter") || msg.includes("content policy"))
|
|
84
|
+
return { reason: "content_filter" };
|
|
85
|
+
if (msg.includes("tool") && msg.includes("schema"))
|
|
86
|
+
return { reason: "tool_schema" };
|
|
87
|
+
if (msg.includes("context length"))
|
|
88
|
+
return { reason: "context_overflow" };
|
|
89
|
+
return { reason: "unknown" };
|
|
51
90
|
}
|
|
52
|
-
const message = err instanceof Error
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
if (message.includes(
|
|
56
|
-
return { reason:
|
|
57
|
-
|
|
91
|
+
const message = err instanceof Error
|
|
92
|
+
? err.message.toLowerCase()
|
|
93
|
+
: String(err).toLowerCase();
|
|
94
|
+
if (message.includes("timed out") || message.includes("abort"))
|
|
95
|
+
return { reason: "timeout", backoffMs: 1000 };
|
|
96
|
+
if (message.includes("econnrefused") ||
|
|
97
|
+
message.includes("enotfound") ||
|
|
98
|
+
message.includes("network"))
|
|
99
|
+
return { reason: "network", backoffMs: 1000 };
|
|
100
|
+
return { reason: "unknown" };
|
|
58
101
|
}
|
|
59
102
|
function isRetryable(reason) {
|
|
60
|
-
return reason ===
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
103
|
+
return (reason === "rate_limit" ||
|
|
104
|
+
reason === "overloaded" ||
|
|
105
|
+
reason === "timeout" ||
|
|
106
|
+
reason === "network");
|
|
64
107
|
}
|
|
65
108
|
function shouldFallback(reason) {
|
|
66
|
-
return reason ===
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
109
|
+
return (reason === "rate_limit" ||
|
|
110
|
+
reason === "overloaded" ||
|
|
111
|
+
reason === "model_not_found" ||
|
|
112
|
+
reason === "billing");
|
|
70
113
|
}
|
|
71
114
|
//# sourceMappingURL=error-classifier.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-classifier.js","sourceRoot":"","sources":["../../src/intelligence/error-classifier.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAgBtD,MAAM,UAAU,qBAAqB;IACnC,OAAO;QACL,QAAQ,CAAC,GAAY,EAAE,QAAgB,EAAE,KAAa;YACpD,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;YAC5C,
|
|
1
|
+
{"version":3,"file":"error-classifier.js","sourceRoot":"","sources":["../../src/intelligence/error-classifier.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAgBtD,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