@parall/daemon 1.28.1 → 1.29.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.
@@ -4,6 +4,22 @@
4
4
  import { execFileSync, spawn } from "node:child_process";
5
5
  import * as fs from "node:fs";
6
6
  import * as path from "node:path";
7
+ function ts() {
8
+ return (/* @__PURE__ */ new Date()).toISOString();
9
+ }
10
+ var log = {
11
+ info: (msg) => console.log(`${ts()} [openclaw-agent] ${msg}`),
12
+ warn: (msg) => console.warn(`${ts()} [openclaw-agent] ${msg}`),
13
+ error: (msg) => console.error(`${ts()} [openclaw-agent] ${msg}`)
14
+ };
15
+ function env(name) {
16
+ const v = process.env[name]?.trim();
17
+ if (!v) {
18
+ log.error(`Missing required environment variable: ${name}`);
19
+ process.exit(1);
20
+ }
21
+ return v;
22
+ }
7
23
  var PRLL_API_URL = env("PRLL_API_URL");
8
24
  var PRLL_API_KEY = env("PRLL_API_KEY");
9
25
  var PRLL_ORG_ID = env("PRLL_ORG_ID");
@@ -12,14 +28,6 @@ var PRLL_WS_URL = process.env.PRLL_WS_URL?.trim() || "";
12
28
  var PRLL_SWIMLANE_NAME = process.env.PRLL_SWIMLANE_NAME?.trim() || "";
13
29
  var gatewayPort = process.env.OPENCLAW_GATEWAY_PORT?.trim() || "0";
14
30
  var pluginArchive = process.env.PRLL_OPENCLAW_PLUGIN_ARCHIVE?.trim() || "/opt/parall-plugin/parall-plugin.tgz";
15
- function env(name) {
16
- const v = process.env[name]?.trim();
17
- if (!v) {
18
- console.error(`ERROR: Missing required environment variable: ${name}`);
19
- process.exit(1);
20
- }
21
- return v;
22
- }
23
31
  var openclawStateDir = path.join(stateDir, ".openclaw");
24
32
  var configPath = path.join(openclawStateDir, "openclaw.json");
25
33
  fs.mkdirSync(path.join(openclawStateDir, "sessions"), { recursive: true });
@@ -27,7 +35,7 @@ fs.mkdirSync(path.join(openclawStateDir, "workspace"), { recursive: true });
27
35
  if (fs.existsSync(pluginArchive)) {
28
36
  const legacyExtDir = path.join(openclawStateDir, "extensions", "parall");
29
37
  fs.rmSync(legacyExtDir, { recursive: true, force: true });
30
- console.log(`Installing Parall plugin from ${pluginArchive}...`);
38
+ log.info(`Installing Parall plugin from ${pluginArchive}...`);
31
39
  try {
32
40
  execFileSync("openclaw", [
33
41
  "plugins",
@@ -41,11 +49,11 @@ if (fs.existsSync(pluginArchive)) {
41
49
  timeout: 6e4
42
50
  });
43
51
  } catch (err) {
44
- console.error(`ERROR: Failed to install Parall plugin: ${String(err)}`);
52
+ log.error(`Failed to install Parall plugin: ${String(err)}`);
45
53
  process.exit(1);
46
54
  }
47
55
  } else {
48
- console.warn(`Plugin archive not found at ${pluginArchive} \u2014 assuming plugin is already installed.`);
56
+ log.warn(`Plugin archive not found at ${pluginArchive} \u2014 assuming plugin is already installed.`);
49
57
  }
50
58
  writeOpenclawConfig();
51
59
  function writeOpenclawConfig() {
@@ -165,9 +173,9 @@ async function preseedPlatformConfig() {
165
173
  fs.writeFileSync(tmp, JSON.stringify(cfg, null, 2));
166
174
  fs.renameSync(tmp, configPath);
167
175
  const model = cfg.agents?.defaults?.model ?? "none";
168
- console.log(`Platform config pre-seeded (model: ${String(model)}).`);
176
+ log.info(`Platform config pre-seeded (model: ${String(model)}).`);
169
177
  } catch (err) {
170
- console.warn(`Platform config pre-seed skipped: ${String(err)}`);
178
+ log.warn(`Platform config pre-seed skipped: ${String(err)}`);
171
179
  }
172
180
  }
173
181
  try {
@@ -178,7 +186,7 @@ try {
178
186
  });
179
187
  } catch {
180
188
  }
181
- console.log("Starting OpenClaw gateway...");
189
+ log.info("Starting OpenClaw gateway...");
182
190
  var workspaceDir = process.env.PRLL_OPENCLAW_WORKSPACE_DIR?.trim() || "";
183
191
  var gatewayEnv = {
184
192
  ...process.env,
package/dist/config.d.ts CHANGED
@@ -22,6 +22,8 @@ export type ClaudeDaemonConfig = {
22
22
  rootClaudeHome: string;
23
23
  /** Optional WS URL override for the machine control-plane WebSocket. */
24
24
  wsUrl?: string;
25
+ /** Optional swimlane routing name, e.g. pr-1191. */
26
+ swimlaneName?: string;
25
27
  /** @deprecated Superseded by WS event-driven model; kept for backward compat. */
26
28
  pollIntervalMs: number;
27
29
  /** @deprecated Superseded by WS event-driven model; kept for backward compat. */
@@ -61,5 +63,5 @@ export declare function sharedClaudeCredentialsFileFor(rootClaudeHome: string):
61
63
  export declare function agentClaudeCredentialsFileFor(agentClaudeHome: string): string;
62
64
  /** Per-agent workspace dir where the agent runs git commands. */
63
65
  export declare function agentWorkspaceDirFor(rootStateDir: string, agentId: string): string;
64
- export declare function resolveWsUrl(apiUrl: string, explicitWsUrl?: string): string;
66
+ export declare function resolveWsUrl(apiUrl: string, explicitWsUrl?: string, swimlaneName?: string): string;
65
67
  //# sourceMappingURL=config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,qCAAqC;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,2GAA2G;IAC3G,QAAQ,EAAE,MAAM,CAAC;IACjB,yFAAyF;IACzF,YAAY,EAAE,MAAM,CAAC;IACrB,kGAAkG;IAClG,cAAc,EAAE,MAAM,CAAC;IACvB,wEAAwE;IACxE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iFAAiF;IACjF,cAAc,EAAE,MAAM,CAAC;IACvB,iFAAiF;IACjF,mBAAmB,EAAE,MAAM,CAAC;IAC5B,oDAAoD;IACpD,gBAAgB,EAAE,MAAM,CAAC;IACzB,oFAAoF;IACpF,mBAAmB,EAAE,MAAM,CAAC;IAC5B;;;;;OAKG;IACH,kBAAkB,EAAE,MAAM,CAAC;IAC3B,qBAAqB,EAAE,MAAM,CAAC;IAC9B;;;;OAIG;IACH,0BAA0B,EAAE,MAAM,CAAC;IACnC,6BAA6B,EAAE,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js CHANGED
@@ -82,6 +82,7 @@ export function resolveClaudeDaemonConfig(env = process.env) {
82
82
  rootStateDir,
83
83
  rootClaudeHome,
84
84
  wsUrl: env.PRLL_WS_URL?.trim() || undefined,
85
+ swimlaneName: env.PRLL_SWIMLANE_NAME?.trim() || undefined,
85
86
  pollIntervalMs: parseMs(env.PRLL_DAEMON_POLL_INTERVAL_MS, 30_000),
86
87
  heartbeatIntervalMs: parseMs(env.PRLL_DAEMON_HEARTBEAT_INTERVAL_MS, 30_000),
87
88
  restartBackoffMs: parseMs(env.PRLL_DAEMON_RESTART_BACKOFF_MS, 5_000),
@@ -120,6 +121,11 @@ export function agentClaudeCredentialsFileFor(agentClaudeHome) {
120
121
  export function agentWorkspaceDirFor(rootStateDir, agentId) {
121
122
  return path.join(rootStateDir, "agents", assertSafeAgentId(agentId), "workspace");
122
123
  }
123
- export function resolveWsUrl(apiUrl, explicitWsUrl) {
124
- return explicitWsUrl || `${apiUrl.replace(/\/$/, "").replace(/^http/, "ws")}/ws`;
124
+ export function resolveWsUrl(apiUrl, explicitWsUrl, swimlaneName) {
125
+ const base = explicitWsUrl || `${apiUrl.replace(/\/$/, "").replace(/^http/, "ws")}/ws`;
126
+ if (!swimlaneName)
127
+ return base;
128
+ const url = new URL(base);
129
+ url.searchParams.set("swimlane", swimlaneName);
130
+ return url.toString();
125
131
  }
package/dist/index.js CHANGED
@@ -1,15 +1,10 @@
1
1
  #!/usr/bin/env node
2
+ import { createLogger } from "@parall/agent-core";
2
3
  import { ParallClient } from "@parall/sdk";
3
4
  import { resolveClaudeDaemonConfig, resolveWsUrl } from "./config.js";
4
5
  import { DaemonSupervisor, sleepCancellable } from "./supervisor.js";
5
6
  import { runCLI } from "./cli.js";
6
- function createLogger(prefix) {
7
- return {
8
- info: (msg) => console.log(`[${prefix}] ${msg}`),
9
- warn: (msg) => console.warn(`[${prefix}] ${msg}`),
10
- error: (msg) => console.error(`[${prefix}] ${msg}`),
11
- };
12
- }
7
+ const log = createLogger("daemon");
13
8
  function formatError(reason) {
14
9
  if (reason instanceof Error) {
15
10
  return reason.stack ?? reason.message;
@@ -73,7 +68,6 @@ async function runForever(config, client, log, signal) {
73
68
  }
74
69
  async function main() {
75
70
  const config = resolveClaudeDaemonConfig(process.env);
76
- const log = createLogger("daemon");
77
71
  log.info(`boot: api=${config.apiUrl} pollMs=${config.pollIntervalMs} heartbeatMs=${config.heartbeatIntervalMs} agentBin=${config.agentBin}`);
78
72
  log.info(`keepalive: bootstrapBackoffMs=${config.bootstrapBackoffMs} supervisorRestartBackoffMs=${config.supervisorRestartBackoffMs}`);
79
73
  // The daemon talks to the API as a Machine — the bearer is mck_*.
@@ -82,6 +76,7 @@ async function main() {
82
76
  const client = new ParallClient({
83
77
  baseUrl: config.apiUrl,
84
78
  token: config.apiKey,
79
+ swimlaneName: config.swimlaneName,
85
80
  });
86
81
  const abortController = new AbortController();
87
82
  const onSignal = (sig) => {
@@ -101,7 +96,7 @@ async function main() {
101
96
  process.exitCode = 1;
102
97
  process.exit(1);
103
98
  });
104
- config.wsUrl = resolveWsUrl(config.apiUrl, config.wsUrl);
99
+ config.wsUrl = resolveWsUrl(config.apiUrl, config.wsUrl, config.swimlaneName);
105
100
  await runForever(config, client, log, abortController.signal);
106
101
  }
107
102
  const cliArgs = process.argv.slice(2);
@@ -110,11 +105,11 @@ runCLI(cliArgs)
110
105
  if (result === "handled")
111
106
  return;
112
107
  main().catch((err) => {
113
- console.error(`[daemon] fatal: ${formatError(err)}`);
108
+ log.error(`fatal: ${formatError(err)}`);
114
109
  process.exitCode = 1;
115
110
  });
116
111
  })
117
112
  .catch((err) => {
118
- console.error(`[daemon] fatal: ${formatError(err)}`);
113
+ log.error(`fatal: ${formatError(err)}`);
119
114
  process.exitCode = 1;
120
115
  });
@@ -1,12 +1,20 @@
1
+ export interface ProviderConfig {
2
+ llm_source?: string;
3
+ openai_api_key?: string;
4
+ openai_base_url?: string;
5
+ anthropic_auth_token?: string;
6
+ anthropic_base_url?: string;
7
+ }
1
8
  export interface RuntimeAdapter {
2
9
  bin: string;
3
- buildEnv(baseEnv: NodeJS.ProcessEnv, agentId: string, orgId: string, apiKey: string, dirs: AgentDirs): NodeJS.ProcessEnv;
10
+ buildEnv(baseEnv: NodeJS.ProcessEnv, agentId: string, orgId: string, apiKey: string, dirs: AgentDirs, pc?: ProviderConfig): NodeJS.ProcessEnv;
4
11
  }
5
12
  export interface AgentDirs {
6
13
  stateDir: string;
7
14
  workspaceDir: string;
8
15
  claudeHome: string;
9
16
  }
17
+ export declare function clearAllProviderCreds(env: NodeJS.ProcessEnv): void;
10
18
  export declare function getRuntimeAdapter(runtimeType: string): RuntimeAdapter;
11
19
  export declare function assertAgentKey(apiKey: string): void;
12
20
  //# sourceMappingURL=runtimes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtimes.d.ts","sourceRoot":"","sources":["../src/runtimes.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,GAAG,MAAM,CAAC,UAAU,CAAC;CAC1H;AAED,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CACpB;AAyED,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,cAAc,CAErE;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAInD"}
1
+ {"version":3,"file":"runtimes.d.ts","sourceRoot":"","sources":["../src/runtimes.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,cAAc;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,CAAC,EAAE,cAAc,GAAG,MAAM,CAAC,UAAU,CAAC;CAC/I;AAED,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CACpB;AAeD,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,GAAG,IAAI,CAOlE;AAgGD,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,cAAc,CAErE;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAInD"}
package/dist/runtimes.js CHANGED
@@ -1,7 +1,28 @@
1
+ import * as path from "node:path";
2
+ function llmSource(pc) {
3
+ if (pc?.llm_source)
4
+ return pc.llm_source;
5
+ if (pc?.openai_api_key ||
6
+ pc?.openai_base_url ||
7
+ pc?.anthropic_auth_token ||
8
+ pc?.anthropic_base_url) {
9
+ return "custom";
10
+ }
11
+ return "parall";
12
+ }
13
+ export function clearAllProviderCreds(env) {
14
+ delete env.ANTHROPIC_AUTH_TOKEN;
15
+ delete env.ANTHROPIC_BASE_URL;
16
+ delete env.ANTHROPIC_API_KEY;
17
+ delete env.OPENAI_API_KEY;
18
+ delete env.OPENAI_BASE_URL;
19
+ delete env.PRLL_CLAUDE_ALLOW_API_KEY;
20
+ }
1
21
  const claudeCodeAdapter = {
2
22
  bin: "parall-claude-agent",
3
- buildEnv(baseEnv, agentId, orgId, apiKey, dirs) {
23
+ buildEnv(baseEnv, agentId, orgId, apiKey, dirs, pc) {
4
24
  const env = { ...baseEnv };
25
+ clearAllProviderCreds(env);
5
26
  env.PRLL_API_KEY = apiKey;
6
27
  env.PRLL_ORG_ID = orgId;
7
28
  env.AGENT_ID = agentId;
@@ -9,8 +30,19 @@ const claudeCodeAdapter = {
9
30
  env.PRLL_CLAUDE_HOME = dirs.claudeHome;
10
31
  env.PRLL_CLAUDE_STATE_DIR = dirs.stateDir;
11
32
  env.PRLL_CLAUDE_WORKSPACE_DIR = dirs.workspaceDir;
12
- if ("ANTHROPIC_AUTH_TOKEN" in env) {
33
+ const source = llmSource(pc);
34
+ if (source === "parall") {
13
35
  env.ANTHROPIC_AUTH_TOKEN = apiKey;
36
+ env.ANTHROPIC_BASE_URL = `${baseEnv.PRLL_API_URL}/api/llm`;
37
+ env.PRLL_CLAUDE_ALLOW_API_KEY = "1";
38
+ }
39
+ else if (source === "custom") {
40
+ if (pc?.anthropic_auth_token) {
41
+ env.ANTHROPIC_AUTH_TOKEN = pc.anthropic_auth_token;
42
+ env.PRLL_CLAUDE_ALLOW_API_KEY = "1";
43
+ }
44
+ if (pc?.anthropic_base_url)
45
+ env.ANTHROPIC_BASE_URL = pc.anthropic_base_url;
14
46
  }
15
47
  delete env.PRLL_DAEMON_MODE;
16
48
  return env;
@@ -18,14 +50,27 @@ const claudeCodeAdapter = {
18
50
  };
19
51
  const codexAdapter = {
20
52
  bin: "parall-codex-agent",
21
- buildEnv(baseEnv, agentId, orgId, apiKey, dirs) {
53
+ buildEnv(baseEnv, agentId, orgId, apiKey, dirs, pc) {
22
54
  const env = { ...baseEnv };
55
+ clearAllProviderCreds(env);
23
56
  env.PRLL_API_KEY = apiKey;
24
57
  env.PRLL_ORG_ID = orgId;
25
58
  env.AGENT_ID = agentId;
26
59
  env.PRLL_AGENT_ID = agentId;
27
60
  env.PRLL_CODEX_STATE_DIR = dirs.stateDir;
28
61
  env.PRLL_CODEX_WORKSPACE_DIR = dirs.workspaceDir;
62
+ env.PRLL_CODEX_HOME = path.join(dirs.stateDir, ".codex");
63
+ const source = llmSource(pc);
64
+ if (source === "parall") {
65
+ env.OPENAI_API_KEY = apiKey;
66
+ env.OPENAI_BASE_URL = `${baseEnv.PRLL_API_URL}/api/llm/v1`;
67
+ }
68
+ else if (source === "custom") {
69
+ if (pc?.openai_api_key)
70
+ env.OPENAI_API_KEY = pc.openai_api_key;
71
+ if (pc?.openai_base_url)
72
+ env.OPENAI_BASE_URL = pc.openai_base_url;
73
+ }
29
74
  delete env.PRLL_DAEMON_MODE;
30
75
  return env;
31
76
  },
@@ -48,6 +93,7 @@ const openclawAdapter = {
48
93
  bin: "parall-openclaw-agent",
49
94
  buildEnv(baseEnv, agentId, orgId, apiKey, dirs) {
50
95
  const env = { ...baseEnv };
96
+ clearAllProviderCreds(env);
51
97
  env.PRLL_API_KEY = apiKey;
52
98
  env.PRLL_ORG_ID = orgId;
53
99
  env.AGENT_ID = agentId;
@@ -1,10 +1,6 @@
1
+ import type { GatewayLogger } from "@parall/agent-core";
1
2
  import { ParallClient } from "@parall/sdk";
2
3
  import { type ClaudeDaemonConfig } from "./config.js";
3
- export interface DaemonLogger {
4
- info(msg: string): void;
5
- warn(msg: string): void;
6
- error(msg: string): void;
7
- }
8
4
  /**
9
5
  * Sleep that wakes early on abort. Returns true if the full delay elapsed,
10
6
  * false if aborted. Used by bootstrap retry and the outer keepalive in
@@ -28,11 +24,16 @@ export declare class DaemonSupervisor {
28
24
  private readonly client;
29
25
  private readonly log;
30
26
  private readonly children;
27
+ private readonly spawningAgents;
28
+ private readonly pendingWorkspaceSetup;
29
+ private readonly workspaceSetupRetryTimers;
30
+ private readonly cancelledSpawns;
31
31
  private ws;
32
32
  private running;
33
33
  private machineOrgId;
34
+ private machineLlmSource;
34
35
  private stopResolve;
35
- constructor(config: ClaudeDaemonConfig, client: ParallClient, log: DaemonLogger);
36
+ constructor(config: ClaudeDaemonConfig, client: ParallClient, log: GatewayLogger);
36
37
  /** Start the supervisor. Returns a promise that resolves on `stop()`. */
37
38
  run(signal: AbortSignal): Promise<void>;
38
39
  /** Disconnect WS, cancel timers, SIGTERM all children, await exit. */
@@ -45,10 +46,17 @@ export declare class DaemonSupervisor {
45
46
  * by parsing session state files which embed the agent ID in the runtimeKey.
46
47
  */
47
48
  private migrateFlatLayout;
49
+ private fetchAttachedAgent;
48
50
  private handleAgentAttached;
49
51
  private handleAgentDetached;
52
+ private handleWorkspaceSetupRequested;
53
+ private scheduleWorkspaceSetupRetry;
54
+ private clearWorkspaceSetupRetry;
55
+ private refreshMachineConfig;
56
+ private respawnAllChildren;
50
57
  private restartChildNow;
51
58
  private spawnAgent;
59
+ private spawnAgentOnce;
52
60
  private startChild;
53
61
  private terminateChild;
54
62
  private ensureSharedCredentialLink;
@@ -1 +1 @@
1
- {"version":3,"file":"supervisor.d.ts","sourceRoot":"","sources":["../src/supervisor.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAmJ,MAAM,aAAa,CAAC;AAC5L,OAAO,EACL,KAAK,kBAAkB,EAMxB,MAAM,aAAa,CAAC;AASrB,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED;;;;GAIG;AACH,iBAAS,gBAAgB,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,CAa3E;AAED,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAuB5B;;;;;;;;;;GAUG;AACH,qBAAa,gBAAgB;IAQzB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,GAAG;IATtB,OAAO,CAAC,Q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