@tianshu-ai/tianshu 0.3.53 → 0.3.54
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/package.json +1 -1
- package/packages/server/dist/chat/compact-decision.d.ts +46 -0
- package/packages/server/dist/chat/compact-decision.d.ts.map +1 -0
- package/packages/server/dist/chat/compact-decision.js +72 -0
- package/packages/server/dist/chat/compact-decision.js.map +1 -0
- package/packages/server/dist/chat/handler.d.ts +3 -176
- package/packages/server/dist/chat/handler.d.ts.map +1 -1
- package/packages/server/dist/chat/handler.js +10 -498
- package/packages/server/dist/chat/handler.js.map +1 -1
- package/packages/server/dist/chat/system-prompt.d.ts +134 -0
- package/packages/server/dist/chat/system-prompt.d.ts.map +1 -0
- package/packages/server/dist/chat/system-prompt.js +458 -0
- package/packages/server/dist/chat/system-prompt.js.map +1 -0
package/package.json
CHANGED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { AgentHarness, Session as PiSession, type CompactionSettings, type SessionTreeEntry } from "@earendil-works/pi-agent-core";
|
|
2
|
+
export interface ShouldCompactBranchInput {
|
|
3
|
+
branch: SessionTreeEntry[];
|
|
4
|
+
contextWindow: number | undefined;
|
|
5
|
+
settings?: CompactionSettings;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Pure decision function: given a branch (the entries pi's
|
|
9
|
+
* harness sees as the active turn history) and the model's
|
|
10
|
+
* context window, return whether the next turn should run
|
|
11
|
+
* compaction first.
|
|
12
|
+
*
|
|
13
|
+
* Exported for tests; runtime callers go through
|
|
14
|
+
* `maybeAutoCompact` which folds storage + harness in.
|
|
15
|
+
*/
|
|
16
|
+
export declare function shouldCompactBranch(input: ShouldCompactBranchInput): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Pure-side-effect helper that drives one auto-compact decision
|
|
19
|
+
* + (if needed) action against any AgentHarness, with no
|
|
20
|
+
* dependency on the chat WebSocket or session-row plumbing.
|
|
21
|
+
*
|
|
22
|
+
* Reused by:
|
|
23
|
+
* - the main chat handler after every successful turn
|
|
24
|
+
* - the worker agent loop (agent-loop.ts) on a configurable
|
|
25
|
+
* cadence so a long-running worker can recover from runaway
|
|
26
|
+
* context growth instead of stalling with `no_completion`.
|
|
27
|
+
*
|
|
28
|
+
* Returns one of:
|
|
29
|
+
* - { compacted: false } — below threshold,
|
|
30
|
+
* no work done
|
|
31
|
+
* - { compacted: true, tokensBefore: N } — ran compact()
|
|
32
|
+
* successfully
|
|
33
|
+
* - { compacted: false, error: "..." } — attempted but
|
|
34
|
+
* compact() threw; caller decides whether to surface this
|
|
35
|
+
*/
|
|
36
|
+
export interface AutoCompactDecision {
|
|
37
|
+
compacted: boolean;
|
|
38
|
+
tokensBefore?: number;
|
|
39
|
+
error?: string;
|
|
40
|
+
}
|
|
41
|
+
export declare function tryAutoCompact(args: {
|
|
42
|
+
piSession: PiSession;
|
|
43
|
+
harness: AgentHarness;
|
|
44
|
+
contextWindow: number | undefined;
|
|
45
|
+
}): Promise<AutoCompactDecision>;
|
|
46
|
+
//# sourceMappingURL=compact-decision.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compact-decision.d.ts","sourceRoot":"","sources":["../../src/chat/compact-decision.ts"],"names":[],"mappings":"AAsBA,OAAO,EACL,YAAY,EAEZ,OAAO,IAAI,SAAS,EAIpB,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACtB,MAAM,+BAA+B,CAAC;AAuBvC,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,gBAAgB,EAAE,CAAC;IAC3B,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,QAAQ,CAAC,EAAE,kBAAkB,CAAC;CAC/B;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,wBAAwB,GAC9B,OAAO,CAWT;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,WAAW,mBAAmB;IAClC,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wBAAsB,cAAc,CAAC,IAAI,EAAE;IACzC,SAAS,EAAE,SAAS,CAAC;IACrB,OAAO,EAAE,YAAY,CAAC;IACtB,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;CACnC,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAuB/B"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// Compaction-decision helpers.
|
|
2
|
+
//
|
|
3
|
+
// Pure functions that decide whether to run `harness.compact()` —
|
|
4
|
+
// kept separate from the WS/session-row plumbing in handler.ts so
|
|
5
|
+
// the worker agent-loop and unit tests can consume the same logic
|
|
6
|
+
// without dragging in chat-shell state. The actual compaction work
|
|
7
|
+
// (LLM summarisation + new session forking) lives in compact.ts;
|
|
8
|
+
// these helpers only answer "should we?" and run an optional
|
|
9
|
+
// harness.compact() if the answer is yes.
|
|
10
|
+
//
|
|
11
|
+
// Two paths converge here:
|
|
12
|
+
// - main chat handler after every successful turn
|
|
13
|
+
// - worker agent-loop on a configurable cadence so a long-running
|
|
14
|
+
// worker can recover from runaway context growth instead of
|
|
15
|
+
// stalling with `no_completion`
|
|
16
|
+
//
|
|
17
|
+
// Skipped on:
|
|
18
|
+
// - the model has no `contextWindow` declared (we'd compact every
|
|
19
|
+
// turn against an undefined window)
|
|
20
|
+
// - DEFAULT_COMPACTION_SETTINGS.enabled is false (future-proofs a
|
|
21
|
+
// per-tenant override even though today the constant is true)
|
|
22
|
+
import { DEFAULT_COMPACTION_SETTINGS, estimateContextTokens, shouldCompact, } from "@earendil-works/pi-agent-core";
|
|
23
|
+
/**
|
|
24
|
+
* Pure decision function: given a branch (the entries pi's
|
|
25
|
+
* harness sees as the active turn history) and the model's
|
|
26
|
+
* context window, return whether the next turn should run
|
|
27
|
+
* compaction first.
|
|
28
|
+
*
|
|
29
|
+
* Exported for tests; runtime callers go through
|
|
30
|
+
* `maybeAutoCompact` which folds storage + harness in.
|
|
31
|
+
*/
|
|
32
|
+
export function shouldCompactBranch(input) {
|
|
33
|
+
const settings = input.settings ?? DEFAULT_COMPACTION_SETTINGS;
|
|
34
|
+
if (!settings.enabled)
|
|
35
|
+
return false;
|
|
36
|
+
if (!input.contextWindow || input.contextWindow <= 0)
|
|
37
|
+
return false;
|
|
38
|
+
const messages = [];
|
|
39
|
+
for (const entry of input.branch) {
|
|
40
|
+
if (entry.type === "message")
|
|
41
|
+
messages.push(entry.message);
|
|
42
|
+
}
|
|
43
|
+
if (messages.length === 0)
|
|
44
|
+
return false;
|
|
45
|
+
const usage = estimateContextTokens(messages);
|
|
46
|
+
return shouldCompact(usage.tokens, input.contextWindow, settings);
|
|
47
|
+
}
|
|
48
|
+
export async function tryAutoCompact(args) {
|
|
49
|
+
const { piSession, harness, contextWindow } = args;
|
|
50
|
+
let branch;
|
|
51
|
+
try {
|
|
52
|
+
branch = await piSession.getBranch();
|
|
53
|
+
}
|
|
54
|
+
catch (err) {
|
|
55
|
+
console.warn(`[chat] auto-compact decision failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
56
|
+
return { compacted: false };
|
|
57
|
+
}
|
|
58
|
+
if (!shouldCompactBranch({ branch, contextWindow })) {
|
|
59
|
+
return { compacted: false };
|
|
60
|
+
}
|
|
61
|
+
try {
|
|
62
|
+
const result = await harness.compact();
|
|
63
|
+
return { compacted: true, tokensBefore: result.tokensBefore };
|
|
64
|
+
}
|
|
65
|
+
catch (err) {
|
|
66
|
+
return {
|
|
67
|
+
compacted: false,
|
|
68
|
+
error: err instanceof Error ? err.message : String(err),
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=compact-decision.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compact-decision.js","sourceRoot":"","sources":["../../src/chat/compact-decision.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,EAAE;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AI,CAAC;QACH,MAAM,GAAG,MAAM,SAAS,CAAC,SAAS,EAAE,CAAC;IACvC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,IAAI,CACV,wCAAwC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAC3F,CAAC;QACF,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;IAC9B,CAAC;IACD,IAAI,CAAC,mBAAmB,CAAC,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC,EAAE,CAAC;QACpD,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;IAC9B,CAAC;IACD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,OAAO,EAAE,CAAC;QACvC,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,CAAC,YAAY,EAAE,CAAC;IAChE,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO;YACL,SAAS,EAAE,KAAK;YAChB,KAAK,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;SACxD,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { shouldCompactBranch, tryAutoCompact, type AutoCompactDecision, type ShouldCompactBranchInput } from "./compact-decision.js";
|
|
2
|
+
export { shouldCompactBranch, tryAutoCompact, type AutoCompactDecision, type ShouldCompactBranchInput, };
|
|
3
|
+
export { defaultSystemPrompt, formatAvailableSkillsBlock, formatExecutionBiasBlock, formatMainAgentContextBlock, formatPluginPromptFragments, formatRuntimeContextBlock, formatWorkerAgentContextBlock, formatWorkspaceContextBlock, substituteUserIdPlaceholders, type PluginPromptFragment, } from "./system-prompt.js";
|
|
2
4
|
import type { WebSocket } from "ws";
|
|
3
5
|
import { type TenantContext } from "../core/index.js";
|
|
4
6
|
import { type LoadedSkill } from "../core/plugins/skills.js";
|
|
@@ -41,181 +43,6 @@ interface RunPromptArgs {
|
|
|
41
43
|
session?: import("./messages.js").ChatSession;
|
|
42
44
|
}
|
|
43
45
|
export declare function runPrompt(args: RunPromptArgs): Promise<void>;
|
|
44
|
-
export interface ShouldCompactBranchInput {
|
|
45
|
-
branch: SessionTreeEntry[];
|
|
46
|
-
contextWindow: number | undefined;
|
|
47
|
-
settings?: CompactionSettings;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Pure decision function: given a branch (the entries pi's
|
|
51
|
-
* harness sees as the active turn history) and the model's
|
|
52
|
-
* context window, return whether the next turn should run
|
|
53
|
-
* compaction first.
|
|
54
|
-
*
|
|
55
|
-
* Exported for tests; runtime callers go through
|
|
56
|
-
* `maybeAutoCompact` which folds storage + harness in.
|
|
57
|
-
*/
|
|
58
|
-
export declare function shouldCompactBranch(input: ShouldCompactBranchInput): boolean;
|
|
59
|
-
/**
|
|
60
|
-
* Pure-side-effect helper that drives one auto-compact decision
|
|
61
|
-
* + (if needed) action against any AgentHarness, with no
|
|
62
|
-
* dependency on the chat WebSocket or session-row plumbing.
|
|
63
|
-
*
|
|
64
|
-
* Reused by:
|
|
65
|
-
* - the main chat handler after every successful turn
|
|
66
|
-
* - the worker agent loop (agent-loop.ts) on a configurable
|
|
67
|
-
* cadence so a long-running worker can recover from runaway
|
|
68
|
-
* context growth instead of stalling with `no_completion`.
|
|
69
|
-
*
|
|
70
|
-
* Returns one of:
|
|
71
|
-
* - { compacted: false } — below threshold,
|
|
72
|
-
* no work done
|
|
73
|
-
* - { compacted: true, tokensBefore: N } — ran compact()
|
|
74
|
-
* successfully
|
|
75
|
-
* - { compacted: false, error: "..." } — attempted but
|
|
76
|
-
* compact() threw; caller decides whether to surface this
|
|
77
|
-
*/
|
|
78
|
-
export interface AutoCompactDecision {
|
|
79
|
-
compacted: boolean;
|
|
80
|
-
tokensBefore?: number;
|
|
81
|
-
error?: string;
|
|
82
|
-
}
|
|
83
|
-
export declare function tryAutoCompact(args: {
|
|
84
|
-
piSession: PiSession;
|
|
85
|
-
harness: AgentHarness;
|
|
86
|
-
contextWindow: number | undefined;
|
|
87
|
-
}): Promise<AutoCompactDecision>;
|
|
88
|
-
/**
|
|
89
|
-
* Build the system prompt the orchestrator runs with.
|
|
90
|
-
*
|
|
91
|
-
* The prompt encodes the workspace scaffold defined in ADR-0001 so the
|
|
92
|
-
* agent has a stable mental model of where things live:
|
|
93
|
-
*
|
|
94
|
-
* - Default cwd is the user's per-tenant home (`users/<userId>/`).
|
|
95
|
-
* - Projects, uploads, scratch and trash all live under that home.
|
|
96
|
-
* - The shared `_tenant/` area is read-only by convention (team
|
|
97
|
-
* persona / memory / config).
|
|
98
|
-
*
|
|
99
|
-
* Tools currently expose a path model rooted at the user's home, so
|
|
100
|
-
* paths in this prompt are written relative to `./` (= cwd) for
|
|
101
|
-
* exactly that reason. When sandbox mounts land (PR #22+) the absolute
|
|
102
|
-
* `/workspace/...` view will become real and we'll surface it here.
|
|
103
|
-
*
|
|
104
|
-
* Worker / task vocabulary is intentionally absent: workers don't ship
|
|
105
|
-
* until PR #23+, and dangling references just let the model fabricate.
|
|
106
|
-
*/
|
|
107
|
-
/** Plugin-contributed system-prompt fragment (see
|
|
108
|
-
* `manifest.contributes.systemPromptFragments`). The handler
|
|
109
|
-
* pulls these from the plugin registry on every turn and injects
|
|
110
|
-
* them between the workspace section and the available-skills
|
|
111
|
-
* block, grouped by plugin so the agent can attribute the
|
|
112
|
-
* guidance. */
|
|
113
|
-
export interface PluginPromptFragment {
|
|
114
|
-
pluginId: string;
|
|
115
|
-
pluginDisplayName: string;
|
|
116
|
-
fragmentId: string;
|
|
117
|
-
text: string;
|
|
118
|
-
}
|
|
119
|
-
export declare function defaultSystemPrompt(ctx: TenantContext, userId: string, skills?: readonly LoadedSkill[], pluginFragments?: readonly PluginPromptFragment[]): string;
|
|
120
|
-
/**
|
|
121
|
-
* Host-level Execution Bias block. Exported so the worker
|
|
122
|
-
* agent-loop path (which builds its own systemPrompt by
|
|
123
|
-
* concatenating SOUL + fragments + skills, bypassing
|
|
124
|
-
* defaultSystemPrompt) can include the same rules without copying
|
|
125
|
-
* the strings.
|
|
126
|
-
*/
|
|
127
|
-
/**
|
|
128
|
-
* Runtime context the LLM almost always wants but doesn't get
|
|
129
|
-
* for free from the conversation history: wall-clock time,
|
|
130
|
-
* timezone, host OS. Injected for BOTH main and worker prompts
|
|
131
|
-
* so an agent that needs "what day is today?" / "am I on macOS
|
|
132
|
-
* or Linux?" / "what timezone is the user in?" doesn't have to
|
|
133
|
-
* ask or guess.
|
|
134
|
-
*
|
|
135
|
-
* We re-render on every prompt build so the time stamps stay
|
|
136
|
-
* fresh across turns of a long session. Cheap (a handful of
|
|
137
|
-
* Date / Intl calls per build).
|
|
138
|
-
*
|
|
139
|
-
* Format is markdown so it stitches into the prompt the same
|
|
140
|
-
* way the other helpers in this file do; the section title
|
|
141
|
-
* matches our convention (`## <Title>`).
|
|
142
|
-
*
|
|
143
|
-
* Time format: ISO-8601 with timezone offset (e.g.
|
|
144
|
-
* `2026-06-23T23:45:12+08:00`). Provider models all parse this
|
|
145
|
-
* cleanly; no provider has a known regression with it.
|
|
146
|
-
*/
|
|
147
|
-
export declare function formatRuntimeContextBlock(opts: {
|
|
148
|
-
tenantId: string;
|
|
149
|
-
userId: string;
|
|
150
|
-
brand?: string;
|
|
151
|
-
}): string;
|
|
152
|
-
export declare function formatExecutionBiasBlock(): string;
|
|
153
|
-
/**
|
|
154
|
-
* Main-agent context: tenant-shared working files plus the
|
|
155
|
-
* caller's per-user USER.md. SOUL / MEMORY / AGENTS live at the
|
|
156
|
-
* tenant root because they're team-wide; USER.md is the only
|
|
157
|
-
* per-user file because it captures preferences that don't
|
|
158
|
-
* generalise.
|
|
159
|
-
*/
|
|
160
|
-
export declare function formatMainAgentContextBlock(workspaceDir: string, userHome: string): string;
|
|
161
|
-
/**
|
|
162
|
-
* Worker-agent context: the worker's own bundle (AGENTS.md /
|
|
163
|
-
* MEMORY.md — SOUL.md is already injected upstream via
|
|
164
|
-
* req.systemPrompt) plus the caller's USER.md. Workers don't
|
|
165
|
-
* read the tenant-shared SOUL/AGENTS/MEMORY because each worker
|
|
166
|
-
* has its own personality + own long-term notes scoped to its
|
|
167
|
-
* specialisation.
|
|
168
|
-
*/
|
|
169
|
-
export declare function formatWorkerAgentContextBlock(workspaceDir: string, userHome: string, workerSlug: string): string;
|
|
170
|
-
/**
|
|
171
|
-
* Backwards-compatible thin wrapper. The previous shape pointed
|
|
172
|
-
* to user home only; kept as an alias for tests / external
|
|
173
|
-
* callers but new code should use formatMainAgentContextBlock.
|
|
174
|
-
*/
|
|
175
|
-
export declare function formatWorkspaceContextBlock(userHome: string): string;
|
|
176
|
-
/**
|
|
177
|
-
* Replace `<self>` and `<userId>` placeholders with the caller's
|
|
178
|
-
* concrete userId throughout an assembled system prompt.
|
|
179
|
-
*
|
|
180
|
-
* Plugin manifests + tool descriptions write paths like
|
|
181
|
-
* `/workspace/users/<self>/...` because the plugin author can't
|
|
182
|
-
* know the runtime userId. Without substitution the LLM sees a
|
|
183
|
-
* literal `<self>` and either invents a userId (we caught
|
|
184
|
-
* `user1` / `user3` / `user_x` in production) or just guesses
|
|
185
|
-
* wrong. Substituting at the very end of prompt assembly — after
|
|
186
|
-
* SOUL, plugin fragments, context block, skills are all stitched
|
|
187
|
-
* together — means every appearance of these placeholders
|
|
188
|
-
* resolves to the right value, regardless of which layer wrote
|
|
189
|
-
* it.
|
|
190
|
-
*
|
|
191
|
-
* Idempotent and safe to call on prompts that don't contain
|
|
192
|
-
* either placeholder.
|
|
193
|
-
*/
|
|
194
|
-
export declare function substituteUserIdPlaceholders(prompt: string, userId: string): string;
|
|
195
|
-
/** Render plugin-contributed system-prompt fragments. Grouped by
|
|
196
|
-
* plugin so the agent sees one section per plugin (workboard
|
|
197
|
-
* rules in one block, microsandbox rules in another, etc), and
|
|
198
|
-
* so debugging prompts is straightforward ("this guidance came
|
|
199
|
-
* from plugin X"). Returns an empty string when no fragments
|
|
200
|
-
* are contributed. */
|
|
201
|
-
export declare function formatPluginPromptFragments(fragments: readonly PluginPromptFragment[]): string;
|
|
202
|
-
/**
|
|
203
|
-
* Render the `<available_skills>` block that's appended to every
|
|
204
|
-
* system prompt — the host default prompt for the main chat agent,
|
|
205
|
-
* AND any custom worker prompt coming from `worker_agents.system_prompt`.
|
|
206
|
-
*
|
|
207
|
-
* Worker LLMs need this just as badly as the main agent: without
|
|
208
|
-
* it they only see plugin-shipped skills via `tenant_config_list`,
|
|
209
|
-
* not their per-tenant ones. Workers ship a kind-specific
|
|
210
|
-
* `system_prompt` in the worker_agents table, and the agent-loop
|
|
211
|
-
* bypasses `defaultSystemPrompt` when that's set; so we expose the
|
|
212
|
-
* skill block as a reusable helper and the loop appends it after
|
|
213
|
-
* the kind-specific prompt.
|
|
214
|
-
*
|
|
215
|
-
* Returns "" when the skills list is empty so callers can drop the
|
|
216
|
-
* block entirely (no leading blank lines, no half-empty XML).
|
|
217
|
-
*/
|
|
218
|
-
export declare function formatAvailableSkillsBlock(skills: readonly LoadedSkill[]): string;
|
|
219
46
|
export declare function loadHostSkills(): LoadedSkill[];
|
|
220
47
|
export type { ChatMessage };
|
|
221
48
|
//# sourceMappingURL=handler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/chat/handler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/chat/handler.ts"],"names":[],"mappings":"AAgDA,OAAO,EACL,mBAAmB,EACnB,cAAc,EACd,KAAK,mBAAmB,EACxB,KAAK,wBAAwB,EAC9B,MAAM,uBAAuB,CAAC;AAI/B,OAAO,EACL,mBAAmB,EACnB,cAAc,EACd,KAAK,mBAAmB,EACxB,K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