@salesforce/sfdx-agent-harness-claude 0.7.0 → 0.8.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.
- package/README.md +8 -9
- package/dist/claude-event-adapter.d.ts +26 -2
- package/dist/claude-event-adapter.js +24 -1
- package/dist/claude-event-adapter.js.map +1 -1
- package/dist/claude-harness.d.ts +23 -0
- package/dist/claude-harness.js +125 -25
- package/dist/claude-harness.js.map +1 -1
- package/dist/claude-query-options-builder.d.ts +2 -2
- package/dist/claude-query-options-builder.js +25 -15
- package/dist/claude-query-options-builder.js.map +1 -1
- package/dist/claude-stream-broker.d.ts +46 -5
- package/dist/claude-stream-broker.js +81 -12
- package/dist/claude-stream-broker.js.map +1 -1
- package/dist/test/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -21,9 +21,9 @@ export class ClaudeQueryOptionsBuilder {
|
|
|
21
21
|
constructor(queryDefaults = {}) {
|
|
22
22
|
this.queryDefaults = queryDefaults;
|
|
23
23
|
}
|
|
24
|
-
build(projectRoot, config, streamOptions, env, sessionOptions, nativeModelId,
|
|
24
|
+
build(projectRoot, config, streamOptions, env, sessionOptions, nativeModelId, brokerPreToolUseHook, mcpServers, rulesAppend) {
|
|
25
25
|
const hasMcpServers = mcpServers !== undefined && Object.keys(mcpServers).length > 0;
|
|
26
|
-
const approvalGated = streamOptions?.requireToolApproval &&
|
|
26
|
+
const approvalGated = streamOptions?.requireToolApproval && brokerPreToolUseHook !== undefined;
|
|
27
27
|
// See ARCHITECTURE.md → "Rule Composition" for the systemPrompt shape selection.
|
|
28
28
|
const systemPrompt = buildSystemPrompt(config.instructions, rulesAppend);
|
|
29
29
|
// Auto-allow every MCP server's tool surface via the `mcp__<server>`
|
|
@@ -34,11 +34,17 @@ export class ClaudeQueryOptionsBuilder {
|
|
|
34
34
|
// model-initiated MCP tool calls. The per-server wildcard explicitly
|
|
35
35
|
// auto-allows every tool the harness surfaces (external bridges +
|
|
36
36
|
// in-process `consumer_tools` and `skill_bridge` MCP servers) without
|
|
37
|
-
// asking for user approval.
|
|
38
|
-
//
|
|
39
|
-
//
|
|
40
|
-
//
|
|
41
|
-
|
|
37
|
+
// asking for user approval.
|
|
38
|
+
//
|
|
39
|
+
// Unlike the deprecated `canUseTool` route, the `PreToolUse` hook
|
|
40
|
+
// fires regardless of `allowedTools` membership — the SDK's
|
|
41
|
+
// permission cache only short-circuits the per-tool prompt, not
|
|
42
|
+
// hook execution. Keeping `allowedTools` on under approval gating
|
|
43
|
+
// means MCP tool calls still skip the per-tool prompt (so
|
|
44
|
+
// bypassPermissions still effectively applies for the model's
|
|
45
|
+
// happy path) while the broker's hook still fires the synthetic
|
|
46
|
+
// approval request the consumer requires.
|
|
47
|
+
const allowedTools = hasMcpServers ? Object.keys(mcpServers).map((name) => `mcp__${name}`) : undefined;
|
|
42
48
|
const perAgentOptions = {
|
|
43
49
|
cwd: projectRoot,
|
|
44
50
|
...(nativeModelId ? { model: nativeModelId } : {}),
|
|
@@ -47,16 +53,20 @@ export class ClaudeQueryOptionsBuilder {
|
|
|
47
53
|
...(hasMcpServers && { mcpServers }),
|
|
48
54
|
...(allowedTools !== undefined && { allowedTools }),
|
|
49
55
|
};
|
|
50
|
-
// When the consumer asks for approval gating,
|
|
51
|
-
//
|
|
52
|
-
//
|
|
53
|
-
//
|
|
54
|
-
//
|
|
56
|
+
// When the consumer asks for approval gating, route every tool
|
|
57
|
+
// call through the broker's `PreToolUse` hook. Unlike `canUseTool`
|
|
58
|
+
// (which the SDK's per-tool / per-arg permission cache silently
|
|
59
|
+
// short-circuits for read-only built-ins like `Bash` / `Glob` /
|
|
60
|
+
// `Grep` and for repeat-arg invocations of state-mutating tools —
|
|
61
|
+
// see #484), `PreToolUse` fires unconditionally for every tool
|
|
62
|
+
// call, restoring the cross-harness contract that `requireToolApproval`
|
|
63
|
+
// gates every invocation. The factory-pinned `permissionMode` is
|
|
64
|
+
// left untouched — the hook owns the gate end-to-end.
|
|
55
65
|
const approvalOverrides = approvalGated
|
|
56
66
|
? {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
67
|
+
hooks: {
|
|
68
|
+
PreToolUse: [{ hooks: [brokerPreToolUseHook] }],
|
|
69
|
+
},
|
|
60
70
|
}
|
|
61
71
|
: {};
|
|
62
72
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claude-query-options-builder.js","sourceRoot":"","sources":["../src/claude-query-options-builder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA0BH,MAAM,wBAAwB,GAAqB;IAC/C,sBAAsB,EAAE,IAAI;IAC5B,cAAc,EAAE,EAAE;IAClB,cAAc,EAAE,IAAI;CACvB,CAAC;AAIF;;;;;;;;GAQG;AACH,MAAM,OAAO,yBAAyB;IACL;IAA7B,YAA6B,gBAAqC,EAAE;QAAvC,kBAAa,GAAb,aAAa,CAA0B;IAAG,CAAC;IAExE,KAAK,CACD,WAAmB,EACnB,MAA0B,EAC1B,aAAwC,EACxC,GAAuC,EACvC,cAA+B,EAC/B,aAAsB,EACtB,
|
|
1
|
+
{"version":3,"file":"claude-query-options-builder.js","sourceRoot":"","sources":["../src/claude-query-options-builder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA0BH,MAAM,wBAAwB,GAAqB;IAC/C,sBAAsB,EAAE,IAAI;IAC5B,cAAc,EAAE,EAAE;IAClB,cAAc,EAAE,IAAI;CACvB,CAAC;AAIF;;;;;;;;GAQG;AACH,MAAM,OAAO,yBAAyB;IACL;IAA7B,YAA6B,gBAAqC,EAAE;QAAvC,kBAAa,GAAb,aAAa,CAA0B;IAAG,CAAC;IAExE,KAAK,CACD,WAAmB,EACnB,MAA0B,EAC1B,aAAwC,EACxC,GAAuC,EACvC,cAA+B,EAC/B,aAAsB,EACtB,oBAAmC,EACnC,UAA4C,EAC5C,WAAoB;QAEpB,MAAM,aAAa,GAAG,UAAU,KAAK,SAAS,IAAI,MAAM,CAAC,IAAI,CAAC,U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gEAAgE;QAChE,kEAAkE;QAClE,+DAA+D;QAC/D,wEAAwE;QACxE,iEAAiE;QACjE,sDAAsD;QACtD,MAAM,iBAAiB,GAAqB,aAAa;YACrD,CAAC,CAAC;gBACI,KAAK,EAAE;oBACH,UAAU,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,oBAAoB,CAAC,EAAE,CAAC;iBAClD;aACJ;YACH,CAAC,CAAC,EAAE,CAAC;QAET,OAAO;YACH,GAAG,IAAI,CAAC,aAAa;YACrB,GAAG,eAAe;YAClB,GAAG,cAAc;YACjB,GAAG,wBAAwB;YAC3B,GAAG,iBAAiB;YACpB,GAAG;SACN,CAAC;IACN,CAAC;CACJ;AAED,SAAS,iBAAiB,CACtB,YAAgC,EAChC,WAA+B;IAE/B,MAAM,KAAK,GAAG,WAAW,IAAI,EAAE,CAAC;IAChC,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;IAClC,MAAM,eAAe,GAAG,YAAY,KAAK,SAAS,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC;IAC9E,IAAI,QAAQ,EAAE,CAAC;QACX,MAAM,MAAM,GAAG,eAAe,CAAC,CAAC,CAAC,GAAG,YAAY,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;QACvE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,sBAAsB,EAAE,IAAI,EAAE,CAAC;IAC3F,CAAC;IACD,OAAO,eAAe,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS,CAAC;AACtD,CAAC"}
|
|
@@ -1,20 +1,43 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { HookCallback, SDKMessage } from '@anthropic-ai/claude-agent-sdk';
|
|
2
2
|
import { type ChatEvent } from '@salesforce/sfdx-agent-sdk';
|
|
3
3
|
import { GenSink } from './gen-sink.js';
|
|
4
|
-
import type { ClaudeEventAdapter } from './claude-event-adapter.js';
|
|
4
|
+
import type { ClaudeEventAdapter, McpToolMetadataLookup } from './claude-event-adapter.js';
|
|
5
5
|
export interface ClaudeStreamBrokerOptions {
|
|
6
6
|
adapter: ClaudeEventAdapter;
|
|
7
7
|
toolApprovalTimeoutMs: number;
|
|
8
8
|
abortController: AbortController;
|
|
9
|
+
/**
|
|
10
|
+
* Optional lookup that resolves an MCP server name + annotations from a
|
|
11
|
+
* Claude-namespaced tool name (`mcp__<server>__<tool>`). When present,
|
|
12
|
+
* `tool-approval-request` events the broker pushes from
|
|
13
|
+
* `preToolUseHook` carry `serverName` + `annotations` for MCP-bridged
|
|
14
|
+
* tools — matching the enrichment the adapter applies to `tool-call` /
|
|
15
|
+
* `tool-result` events. See ARCHITECTURE.md → "Tool Approval".
|
|
16
|
+
*/
|
|
17
|
+
lookupMcpToolMetadata?: McpToolMetadataLookup;
|
|
9
18
|
}
|
|
10
19
|
/**
|
|
11
|
-
* Per-turn broker that
|
|
12
|
-
* `tool-approval-request`
|
|
20
|
+
* Per-turn broker that gates every tool call behind a synthetic
|
|
21
|
+
* `tool-approval-request` ChatEvent.
|
|
22
|
+
*
|
|
23
|
+
* Routes through the Claude Agent SDK's `PreToolUse` hook rather than
|
|
24
|
+
* `canUseTool`. The SDK's `canUseTool` callback only fires for tools the
|
|
25
|
+
* SDK's per-tool / per-arg permission cache has not already short-circuited
|
|
26
|
+
* (#484): read-only built-ins like `Bash` (non-mutating), `Glob`, `Grep`
|
|
27
|
+
* never trigger it, and state-mutating built-ins (`Read`, `Write`, `Edit`)
|
|
28
|
+
* trigger it only on the first `(toolName, args)` tuple per session. The
|
|
29
|
+
* `PreToolUse` hook fires unconditionally before the SDK's permission
|
|
30
|
+
* evaluator, so every tool call surfaces an approval request to the
|
|
31
|
+
* consumer — restoring the cross-harness contract that `requireToolApproval`
|
|
32
|
+
* gates every invocation.
|
|
33
|
+
*
|
|
34
|
+
* See ARCHITECTURE.md → "Tool Approval".
|
|
13
35
|
*/
|
|
14
36
|
export declare class ClaudeStreamBroker {
|
|
15
37
|
private readonly adapter;
|
|
16
38
|
private readonly toolApprovalTimeoutMs;
|
|
17
39
|
private readonly abortController;
|
|
40
|
+
private readonly lookupMcpToolMetadata?;
|
|
18
41
|
private readonly pendingApprovals;
|
|
19
42
|
private readonly genSinks;
|
|
20
43
|
private readonly initial;
|
|
@@ -22,7 +45,25 @@ export declare class ClaudeStreamBroker {
|
|
|
22
45
|
private lastGenSinkStale;
|
|
23
46
|
private disposed;
|
|
24
47
|
constructor(opts: ClaudeStreamBrokerOptions);
|
|
25
|
-
|
|
48
|
+
/**
|
|
49
|
+
* Claude Agent SDK `PreToolUse` hook. Fires once per tool call before
|
|
50
|
+
* the SDK's permission evaluator runs (and crucially before the SDK's
|
|
51
|
+
* per-tool / per-arg permission cache short-circuits). Pushes a
|
|
52
|
+
* `tool-approval-request` to `lastGenSink`, parks a Promise, and
|
|
53
|
+
* returns a `hookSpecificOutput` whose `permissionDecision` reflects
|
|
54
|
+
* the consumer's `approve` / `decline` decision.
|
|
55
|
+
*/
|
|
56
|
+
readonly preToolUseHook: HookCallback;
|
|
57
|
+
/**
|
|
58
|
+
* Look up the originating MCP server name and (optional) annotations for
|
|
59
|
+
* a tool name and return them in the shape consumers spread onto a
|
|
60
|
+
* `tool-approval-request` ChatEvent. Mirrors the adapter's
|
|
61
|
+
* `enrichmentFor` so the two emit surfaces stay in sync — when no lookup
|
|
62
|
+
* is wired or the tool isn't in the agent's MCP catalog (built-ins,
|
|
63
|
+
* in-process bridges, consumer-declared tools), returns an empty object
|
|
64
|
+
* so the spread is a no-op and both fields stay `undefined`.
|
|
65
|
+
*/
|
|
66
|
+
private enrichmentFor;
|
|
26
67
|
abort(): void;
|
|
27
68
|
dispose(): void;
|
|
28
69
|
private handleApprovalTimeout;
|
|
@@ -5,13 +5,27 @@
|
|
|
5
5
|
import { AgentSDKError, AgentSDKErrorType } from '@salesforce/sfdx-agent-sdk';
|
|
6
6
|
import { GenSink } from './gen-sink.js';
|
|
7
7
|
/**
|
|
8
|
-
* Per-turn broker that
|
|
9
|
-
* `tool-approval-request`
|
|
8
|
+
* Per-turn broker that gates every tool call behind a synthetic
|
|
9
|
+
* `tool-approval-request` ChatEvent.
|
|
10
|
+
*
|
|
11
|
+
* Routes through the Claude Agent SDK's `PreToolUse` hook rather than
|
|
12
|
+
* `canUseTool`. The SDK's `canUseTool` callback only fires for tools the
|
|
13
|
+
* SDK's per-tool / per-arg permission cache has not already short-circuited
|
|
14
|
+
* (#484): read-only built-ins like `Bash` (non-mutating), `Glob`, `Grep`
|
|
15
|
+
* never trigger it, and state-mutating built-ins (`Read`, `Write`, `Edit`)
|
|
16
|
+
* trigger it only on the first `(toolName, args)` tuple per session. The
|
|
17
|
+
* `PreToolUse` hook fires unconditionally before the SDK's permission
|
|
18
|
+
* evaluator, so every tool call surfaces an approval request to the
|
|
19
|
+
* consumer — restoring the cross-harness contract that `requireToolApproval`
|
|
20
|
+
* gates every invocation.
|
|
21
|
+
*
|
|
22
|
+
* See ARCHITECTURE.md → "Tool Approval".
|
|
10
23
|
*/
|
|
11
24
|
export class ClaudeStreamBroker {
|
|
12
25
|
adapter;
|
|
13
26
|
toolApprovalTimeoutMs;
|
|
14
27
|
abortController;
|
|
28
|
+
lookupMcpToolMetadata;
|
|
15
29
|
pendingApprovals = new Map();
|
|
16
30
|
genSinks = new Map();
|
|
17
31
|
initial = new GenSink();
|
|
@@ -22,18 +36,51 @@ export class ClaudeStreamBroker {
|
|
|
22
36
|
this.adapter = opts.adapter;
|
|
23
37
|
this.toolApprovalTimeoutMs = opts.toolApprovalTimeoutMs;
|
|
24
38
|
this.abortController = opts.abortController;
|
|
39
|
+
this.lookupMcpToolMetadata = opts.lookupMcpToolMetadata;
|
|
25
40
|
}
|
|
26
|
-
|
|
27
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Claude Agent SDK `PreToolUse` hook. Fires once per tool call before
|
|
43
|
+
* the SDK's permission evaluator runs (and crucially before the SDK's
|
|
44
|
+
* per-tool / per-arg permission cache short-circuits). Pushes a
|
|
45
|
+
* `tool-approval-request` to `lastGenSink`, parks a Promise, and
|
|
46
|
+
* returns a `hookSpecificOutput` whose `permissionDecision` reflects
|
|
47
|
+
* the consumer's `approve` / `decline` decision.
|
|
48
|
+
*/
|
|
49
|
+
preToolUseHook = async (input, toolUseID) => {
|
|
50
|
+
if (input.hook_event_name !== 'PreToolUse') {
|
|
51
|
+
return {};
|
|
52
|
+
}
|
|
53
|
+
const toolCallId = toolUseID ?? input.tool_use_id;
|
|
54
|
+
const toolName = input.tool_name;
|
|
55
|
+
const toolInput = (input.tool_input ?? {});
|
|
28
56
|
this.lastGenSink?.push({
|
|
29
57
|
type: 'tool-approval-request',
|
|
30
|
-
toolCall: { toolCallId, toolName, args:
|
|
58
|
+
toolCall: { toolCallId, toolName, args: toolInput },
|
|
59
|
+
...this.enrichmentFor(toolName),
|
|
31
60
|
});
|
|
32
61
|
return new Promise((resolve, reject) => {
|
|
33
62
|
const timer = setTimeout(() => this.handleApprovalTimeout(toolCallId), this.toolApprovalTimeoutMs);
|
|
34
|
-
this.pendingApprovals.set(toolCallId, { resolve, reject, input, timer });
|
|
63
|
+
this.pendingApprovals.set(toolCallId, { resolve, reject, input: toolInput, timer });
|
|
35
64
|
});
|
|
36
65
|
};
|
|
66
|
+
/**
|
|
67
|
+
* Look up the originating MCP server name and (optional) annotations for
|
|
68
|
+
* a tool name and return them in the shape consumers spread onto a
|
|
69
|
+
* `tool-approval-request` ChatEvent. Mirrors the adapter's
|
|
70
|
+
* `enrichmentFor` so the two emit surfaces stay in sync — when no lookup
|
|
71
|
+
* is wired or the tool isn't in the agent's MCP catalog (built-ins,
|
|
72
|
+
* in-process bridges, consumer-declared tools), returns an empty object
|
|
73
|
+
* so the spread is a no-op and both fields stay `undefined`.
|
|
74
|
+
*/
|
|
75
|
+
enrichmentFor(toolName) {
|
|
76
|
+
const metadata = this.lookupMcpToolMetadata?.(toolName);
|
|
77
|
+
if (!metadata)
|
|
78
|
+
return {};
|
|
79
|
+
return {
|
|
80
|
+
serverName: metadata.serverName,
|
|
81
|
+
...(metadata.annotations ? { annotations: metadata.annotations } : {}),
|
|
82
|
+
};
|
|
83
|
+
}
|
|
37
84
|
abort() {
|
|
38
85
|
const abortError = new Error('The stream was aborted.');
|
|
39
86
|
abortError.name = 'AbortError';
|
|
@@ -88,7 +135,19 @@ export class ClaudeStreamBroker {
|
|
|
88
135
|
});
|
|
89
136
|
this.endLastSink();
|
|
90
137
|
}
|
|
91
|
-
|
|
138
|
+
// `decision: 'block'` halts the agentic loop entirely; the SDK
|
|
139
|
+
// surfaces a synthetic `tool_result(is_error=true)` to the model
|
|
140
|
+
// and stops the turn. Mirrors the prior `interrupt: true` behavior
|
|
141
|
+
// on the deprecated `canUseTool` path.
|
|
142
|
+
pending.resolve({
|
|
143
|
+
decision: 'block',
|
|
144
|
+
reason: 'Tool approval timed out.',
|
|
145
|
+
hookSpecificOutput: {
|
|
146
|
+
hookEventName: 'PreToolUse',
|
|
147
|
+
permissionDecision: 'deny',
|
|
148
|
+
permissionDecisionReason: 'Tool approval timed out.',
|
|
149
|
+
},
|
|
150
|
+
});
|
|
92
151
|
}
|
|
93
152
|
initialSink() {
|
|
94
153
|
return this.initial;
|
|
@@ -98,15 +157,25 @@ export class ClaudeStreamBroker {
|
|
|
98
157
|
}
|
|
99
158
|
approve(toolCallId) {
|
|
100
159
|
return this.settlePending('approve', toolCallId, (input) => ({
|
|
101
|
-
|
|
102
|
-
|
|
160
|
+
hookSpecificOutput: {
|
|
161
|
+
hookEventName: 'PreToolUse',
|
|
162
|
+
permissionDecision: 'allow',
|
|
163
|
+
updatedInput: input,
|
|
164
|
+
},
|
|
103
165
|
}));
|
|
104
166
|
}
|
|
105
167
|
decline(toolCallId) {
|
|
106
|
-
// No `
|
|
168
|
+
// No `decision: 'block'`: the SDK synthesizes
|
|
169
|
+
// `tool_result(is_error=true)` from `permissionDecision: 'deny'`
|
|
170
|
+
// and the model acknowledges in its follow-up. Blocking would
|
|
171
|
+
// halt the agentic loop entirely, which is correct only for the
|
|
172
|
+
// timeout path.
|
|
107
173
|
return this.settlePending('decline', toolCallId, () => ({
|
|
108
|
-
|
|
109
|
-
|
|
174
|
+
hookSpecificOutput: {
|
|
175
|
+
hookEventName: 'PreToolUse',
|
|
176
|
+
permissionDecision: 'deny',
|
|
177
|
+
permissionDecisionReason: 'User declined the tool call.',
|
|
178
|
+
},
|
|
110
179
|
}));
|
|
111
180
|
}
|
|
112
181
|
settlePending(method, toolCallId, decide) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claude-stream-broker.js","sourceRoot":"","sources":["../src/claude-stream-broker.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,aAAa,EAAE,iBAAiB,
|
|
1
|
+
{"version":3,"file":"claude-stream-broker.js","sourceRoot":"","sources":["../src/claude-stream-broker.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAA2C,MAAM,4BAA4B,CAAC;AACvH,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAyBxC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAO,kBAAkB;IACV,OAAO,CAAqB;IAC5B,qBAAqB,CAAS;IAC9B,eAAe,CAAkB;IACjC,qBAAqB,CAAyB;IAE9C,gBAAgB,GAAG,IAAI,GAAG,EAA2B,CAAC;IACtD,QAAQ,GAAG,IAAI,GAAG,EAA8B,CAAC;IACjD,OAAO,GAAuB,IAAI,OAAO,EAAa,CAAC;IAChE,WAAW,GAA8B,IAAI,CAAC,OAAO,CAAC;IACtD,gBAAgB,GAAG,KAAK,CAAC;IACzB,QAAQ,GAAG,KAAK,CAAC;IAEzB,YAAY,IAA+B;QACvC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC5B,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC,qBAAqB,C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