looply-cli 0.5.39 → 0.5.43

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 (98) hide show
  1. package/dist/account-standing.d.ts +23 -0
  2. package/dist/account-standing.d.ts.map +1 -0
  3. package/dist/account-standing.js +41 -0
  4. package/dist/account-standing.js.map +1 -0
  5. package/dist/bin.d.ts.map +1 -1
  6. package/dist/bin.js +1 -0
  7. package/dist/bin.js.map +1 -1
  8. package/dist/branch-delivery-wiring.d.ts +19 -0
  9. package/dist/branch-delivery-wiring.d.ts.map +1 -1
  10. package/dist/branch-delivery-wiring.js +49 -26
  11. package/dist/branch-delivery-wiring.js.map +1 -1
  12. package/dist/checkout-deps.d.ts +6 -0
  13. package/dist/checkout-deps.d.ts.map +1 -1
  14. package/dist/checkout-deps.js +11 -0
  15. package/dist/checkout-deps.js.map +1 -1
  16. package/dist/checkout-leftovers.d.ts.map +1 -1
  17. package/dist/checkout-leftovers.js +28 -21
  18. package/dist/checkout-leftovers.js.map +1 -1
  19. package/dist/daemon-cmd.d.ts.map +1 -1
  20. package/dist/daemon-cmd.js +51 -1
  21. package/dist/daemon-cmd.js.map +1 -1
  22. package/dist/feature-report.d.ts.map +1 -1
  23. package/dist/feature-report.js +27 -4
  24. package/dist/feature-report.js.map +1 -1
  25. package/dist/gate-health.d.ts +7 -0
  26. package/dist/gate-health.d.ts.map +1 -1
  27. package/dist/gate-health.js +11 -1
  28. package/dist/gate-health.js.map +1 -1
  29. package/dist/goal-compile.d.ts.map +1 -1
  30. package/dist/goal-compile.js +3 -0
  31. package/dist/goal-compile.js.map +1 -1
  32. package/dist/goal-gap.d.ts +22 -1
  33. package/dist/goal-gap.d.ts.map +1 -1
  34. package/dist/goal-gap.js +65 -6
  35. package/dist/goal-gap.js.map +1 -1
  36. package/dist/grant-waiting-wiring.d.ts +16 -1
  37. package/dist/grant-waiting-wiring.d.ts.map +1 -1
  38. package/dist/grant-waiting-wiring.js +27 -1
  39. package/dist/grant-waiting-wiring.js.map +1 -1
  40. package/dist/heroku-cli.d.ts +13 -1
  41. package/dist/heroku-cli.d.ts.map +1 -1
  42. package/dist/heroku-cli.js +15 -0
  43. package/dist/heroku-cli.js.map +1 -1
  44. package/dist/machine-settings.d.ts +7 -0
  45. package/dist/machine-settings.d.ts.map +1 -1
  46. package/dist/machine-settings.js +27 -0
  47. package/dist/machine-settings.js.map +1 -1
  48. package/dist/provider-accounts.d.ts +5 -1
  49. package/dist/provider-accounts.d.ts.map +1 -1
  50. package/dist/provider-accounts.js +1 -0
  51. package/dist/provider-accounts.js.map +1 -1
  52. package/dist/qa-feedback.d.ts +110 -0
  53. package/dist/qa-feedback.d.ts.map +1 -0
  54. package/dist/qa-feedback.js +353 -0
  55. package/dist/qa-feedback.js.map +1 -0
  56. package/dist/run-cmd.d.ts.map +1 -1
  57. package/dist/run-cmd.js +43 -6
  58. package/dist/run-cmd.js.map +1 -1
  59. package/dist/self-update.d.ts +440 -0
  60. package/dist/self-update.d.ts.map +1 -0
  61. package/dist/self-update.js +1006 -0
  62. package/dist/self-update.js.map +1 -0
  63. package/dist/serve-cmd.d.ts +32 -1
  64. package/dist/serve-cmd.d.ts.map +1 -1
  65. package/dist/serve-cmd.js +162 -7
  66. package/dist/serve-cmd.js.map +1 -1
  67. package/dist/serve.d.ts.map +1 -1
  68. package/dist/serve.js +3 -0
  69. package/dist/serve.js.map +1 -1
  70. package/dist/server-client.d.ts +6 -0
  71. package/dist/server-client.d.ts.map +1 -1
  72. package/dist/server-client.js +4 -0
  73. package/dist/server-client.js.map +1 -1
  74. package/dist/setup-check-wiring.d.ts +31 -0
  75. package/dist/setup-check-wiring.d.ts.map +1 -0
  76. package/dist/setup-check-wiring.js +195 -0
  77. package/dist/setup-check-wiring.js.map +1 -0
  78. package/dist/setup-check.d.ts +222 -0
  79. package/dist/setup-check.d.ts.map +1 -0
  80. package/dist/setup-check.js +620 -0
  81. package/dist/setup-check.js.map +1 -0
  82. package/dist/signals.d.ts +13 -0
  83. package/dist/signals.d.ts.map +1 -1
  84. package/dist/signals.js +26 -1
  85. package/dist/signals.js.map +1 -1
  86. package/dist/ticket-attachments.d.ts +31 -1
  87. package/dist/ticket-attachments.d.ts.map +1 -1
  88. package/dist/ticket-attachments.js +232 -9
  89. package/dist/ticket-attachments.js.map +1 -1
  90. package/dist/watchdog-wiring.d.ts +40 -0
  91. package/dist/watchdog-wiring.d.ts.map +1 -0
  92. package/dist/watchdog-wiring.js +108 -0
  93. package/dist/watchdog-wiring.js.map +1 -0
  94. package/dist/watchdog.d.ts +107 -0
  95. package/dist/watchdog.d.ts.map +1 -0
  96. package/dist/watchdog.js +424 -0
  97. package/dist/watchdog.js.map +1 -0
  98. package/package.json +4 -4
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.requesterOfGoal = requesterOfGoal;
4
+ exports.goalAccounts = goalAccounts;
5
+ exports.accountFreeForGoal = accountFreeForGoal;
6
+ exports.makeDaemonWatchdog = makeDaemonWatchdog;
7
+ const node_fs_1 = require("node:fs");
8
+ const node_path_1 = require("node:path");
9
+ const account_standing_1 = require("./account-standing");
10
+ const branch_delivery_1 = require("./branch-delivery");
11
+ const checkout_leftovers_1 = require("./checkout-leftovers");
12
+ const environment_hold_1 = require("./environment-hold");
13
+ const gate_health_1 = require("./gate-health");
14
+ const git_driver_1 = require("./git-driver");
15
+ const grant_waiting_wiring_1 = require("./grant-waiting-wiring");
16
+ const watchdog_1 = require("./watchdog");
17
+ const workspace_1 = require("./workspace");
18
+ /** Who asked for a goal (`requestedBy.ref` in the goal mirror), or null. */
19
+ function requesterOfGoal(stateDir, goalId) {
20
+ try {
21
+ const raw = JSON.parse((0, node_fs_1.readFileSync)((0, node_path_1.join)(stateDir, 'goals.json'), 'utf8'));
22
+ const g = (raw.goals ?? []).find((x) => x['id'] === goalId);
23
+ const ref = g?.['requestedBy']?.ref;
24
+ return typeof ref === 'string' && ref !== '' ? ref : null;
25
+ }
26
+ catch {
27
+ return null;
28
+ }
29
+ }
30
+ /** The accounts a goal may use now, with its requester from the goal mirror. */
31
+ function goalAccounts(stateDir, projectId, goalId, now = Date.now(), opts = {}) {
32
+ const input = { projectId, requesterRef: requesterOfGoal(stateDir, goalId), now, ...(opts.role ? { role: opts.role } : {}), ...(opts.provider ? { provider: opts.provider } : {}) };
33
+ return opts.home === undefined ? (0, account_standing_1.accountStanding)(input) : (0, account_standing_1.accountStanding)(input, opts.home);
34
+ }
35
+ /**
36
+ * An account that may take this goal's calls in EVERY role its runs use, and is not resting — or
37
+ * null. A run calls an implementer, a verifier and a prover (and the brain, when the project has it on); an
38
+ * account free for one of them only would meet the limit again on the next call.
39
+ */
40
+ function accountFreeForGoal(stateDir, projectId, goalId, roles, provider, now = Date.now(), home) {
41
+ let common = null;
42
+ for (const role of roles) {
43
+ const usable = goalAccounts(stateDir, projectId, goalId, now, { role, provider, ...(home === undefined ? {} : { home }) }).usable;
44
+ common = common === null ? [...usable] : common.filter((n) => usable.includes(n));
45
+ if (common.length === 0)
46
+ return null;
47
+ }
48
+ return common?.[0] ?? null;
49
+ }
50
+ /** The daemon's watchdog, from the pieces it already has. */
51
+ function makeDaemonWatchdog(opts) {
52
+ const stateDir = (0, git_driver_1.projectStateDir)(opts.cwd);
53
+ const now = opts.now ?? Date.now;
54
+ const version = (0, grant_waiting_wiring_1.packageVersion)();
55
+ const provider = opts.provider ?? 'claude';
56
+ // Every model role a run calls: the prover too (it runs a model), and the brain when the project has it on.
57
+ const roles = opts.brain === true ? ['implementer', 'verifier', 'prover', 'brain'] : ['implementer', 'verifier', 'prover'];
58
+ const deps = {
59
+ stateDir,
60
+ now,
61
+ log: opts.log,
62
+ grants: () => opts.grants.all(),
63
+ waits: opts.waits,
64
+ holdRecords: {
65
+ read: (controllerId) => (0, environment_hold_1.readEnvironmentHold)(stateDir, controllerId),
66
+ stands: (record) => (0, environment_hold_1.decideEnvironmentHold)(record, { at: now(), looplyVersion: version, configDigest: (0, environment_hold_1.configDigest)(opts.cwd) }).held,
67
+ release: (controllerId) => (0, environment_hold_1.releaseEnvironmentHold)(stateDir, controllerId, now()),
68
+ },
69
+ accounts: (goalId) => goalAccounts(stateDir, opts.projectId, goalId, now(), { provider }),
70
+ accountFree: (goalId) => accountFreeForGoal(stateDir, opts.projectId, goalId, roles, provider, now()),
71
+ ...(opts.providerReady === null ? {} : { providerReady: opts.providerReady }),
72
+ diskProblem: () => {
73
+ try {
74
+ return (0, workspace_1.roomForCheckout)((0, workspace_1.workspacesRoot)(opts.cwd));
75
+ }
76
+ catch {
77
+ return undefined;
78
+ }
79
+ },
80
+ redBase: () => (0, gate_health_1.redBaseFacts)((0, gate_health_1.readBaseHealth)(stateDir)),
81
+ checkouts: {
82
+ idle: () => (0, workspace_1.abandonedWorkspaces)(opts.cwd, new workspace_1.RunRegistry(stateDir)).abandoned,
83
+ madeByLooply: (path) => (0, checkout_leftovers_1.machineMadeCheckout)(path, opts.cwd, (0, workspace_1.workspacesRoots)(opts.cwd)),
84
+ busy: (path) => (0, workspace_1.checkoutBusy)((0, node_path_1.join)(path, git_driver_1.STATE_DIR, 'state')),
85
+ changes: async (path) => {
86
+ try {
87
+ // Looply's own folder (the carried config.yaml) is not leftover work (`setAsideLeftovers`).
88
+ return (await new git_driver_1.GitDriver((0, git_driver_1.nodeGitExec)(path)).changedEntries())
89
+ .filter((e) => e.path !== git_driver_1.STATE_DIR && !e.path.startsWith(`${git_driver_1.STATE_DIR}/`))
90
+ .map((e) => `${e.status} ${e.path}`);
91
+ }
92
+ catch {
93
+ return null;
94
+ }
95
+ },
96
+ setAside: (path) => (0, checkout_leftovers_1.setAsideLeftovers)({ checkout: path, projectRoot: opts.cwd, exec: (0, git_driver_1.nodeGitExec)(path) }),
97
+ },
98
+ deliveries: {
99
+ all: () => (0, branch_delivery_1.fileDeliveryStore)(stateDir).all(),
100
+ retry: (goalId) => opts.deliverer.retry(goalId),
101
+ },
102
+ herokuLogins: () => opts.deliverer.herokuLogins(),
103
+ tellHold: (goalId, hold) => opts.grantWaiting().say(goalId, hold),
104
+ untellHold: (goalId, code) => opts.grantWaiting().unsay(goalId, code),
105
+ };
106
+ return (0, watchdog_1.makeWatchdog)(deps);
107
+ }
108
+ //# sourceMappingURL=watchdog-wiring.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"watchdog-wiring.js","sourceRoot":"","sources":["../src/watchdog-wiring.ts"],"names":[],"mappings":";;AAgBA,0CASC;AAGD,oCASC;AAOD,gDAgBC;AAGD,gDAoEC;AAnID,qCAAuC;AACvC,yCAAiC;AAEjC,yDAAqD;AAErD,uDAAsD;AAEtD,6DAA8E;AAC9E,yDAAsH;AACtH,+CAA6D;AAC7D,6CAAkF;AAClF,iEAA2E;AAC3E,yCAA6D;AAC7D,2CAA+H;AAE/H,4EAA4E;AAC5E,SAAgB,eAAe,CAAC,QAAgB,EAAE,MAAc;IAC9D,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAA,sBAAY,EAAC,IAAA,gBAAI,EAAC,QAAQ,EAAE,YAAY,CAAC,EAAE,MAAM,CAAC,CAA+C,CAAC;QACzH,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,MAAM,CAAC,CAAC;QAC5D,MAAM,GAAG,GAAI,CAAC,EAAE,CAAC,aAAa,CAAmC,EAAE,GAAG,CAAC;QACvE,OAAO,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;IAC5D,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,gFAAgF;AAChF,SAAgB,YAAY,CAC1B,QAAgB,EAChB,SAAiB,EACjB,MAAc,EACd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,CAAC;QACjE,UAAU,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC;KACtE,CAAC;IACF,OAAO,IAAA,uBAAY,EAAC,IAAI,CAAC,CAAC;AAC5B,CAAC"}
@@ -0,0 +1,107 @@
1
+ import { type AccountsFacts, type BranchDeliveryReport, type GoalHold, type RedBaseFacts, type WatchdogReport } from '@looply/core';
2
+ import type { AutonomyProgress } from './autonomy-store';
3
+ import { type DeliveryEntry } from './branch-delivery';
4
+ import type { HerokuLoginFact } from './branch-delivery-wiring';
5
+ import type { SetAside } from './checkout-leftovers';
6
+ import type { EnvironmentHoldRecord } from './environment-hold';
7
+ /**
8
+ * LOOPLY NOTICES AND REPAIRS ITS OWN STUCK STATES.
9
+ *
10
+ * ─────────────────────────────────────────────────────────────────────────────
11
+ * 🔴 WHAT THIS EXISTS FOR (2026-10-22). Every stall that day was found by a Claude session reading
12
+ * `~/.looply/serve.log` and `<repo>/.looply/state`, then repaired by hand or by a release:
13
+ *
14
+ * - a goal held on a verdict a newer Looply, or simply a later look, would judge differently;
15
+ * - a checkout Looply reuses, left with an earlier run's changes in it;
16
+ * - every account a ticket may use resting on a usage limit while other connected accounts sat
17
+ * idle, refused by their owners' settings — the ticket said only "usage limit";
18
+ * - a delivery in a state no pass moves (a push that failed, a branch pushed with no pull request);
19
+ * - the PC's Heroku CLI signed in as another account, so every deploy failed.
20
+ *
21
+ * Every 15 minutes the daemon looks (`makeWatchdog`) and, for each goal and delivery:
22
+ *
23
+ * 1. lists what has waited past the threshold (`WATCHDOG_STALLED_AFTER_MS`), with its code;
24
+ * 2. runs the SAFE remedy for what it knows — asks the hold's question again and releases the
25
+ * hold when the answer changed (an account free for every role, the AI tool ready, room on the
26
+ * disk, its own checkout cleaned — never a red base, see `causeGone`); sets aside what an earlier run left in a
27
+ * checkout LOOPLY MADE once it has stood unchanged and idle; delivers again a change whose push
28
+ * or pull request failed; reads the Heroku sign-in against what each environment needs;
29
+ * 3. says what it cannot fix ONCE, on the ticket, through the path every stall already takes
30
+ * (`stall.ts`: the hold's or the delivery's diagnosis, which AutoRyn puts on the ticket when it
31
+ * is due) — and only a wait nobody told the ticket about is told here;
32
+ * 4. records what it did in `.looply/state/watchdog.json`, which the feature report carries to
33
+ * AutoRyn (core `watchdog.ts`).
34
+ *
35
+ * ⚠️ NEVER DESTRUCTIVE TO A PERSON'S WORK. Nothing here touches the project's own folder or a
36
+ * checkout a person made (`machineMadeCheckout`); a Looply checkout's changes are SAVED (a patch and
37
+ * the new files, `checkout-leftovers.ts`) before it is reset, and only when no run holds it. A hold
38
+ * released early costs nothing: a fault still there holds the goal again and counts from when it
39
+ * first began. Nothing here changes who may use which account, or spends a try.
40
+ * ─────────────────────────────────────────────────────────────────────────────
41
+ */
42
+ export declare const WATCHDOG_FILE = "watchdog.json";
43
+ /** A Looply checkout's changes must stand unchanged, with no run in it, this long before they are set aside. */
44
+ export declare const CHECKOUT_SETTLE_MS: number;
45
+ /** How long an undelivered change waits between deliveries again, and how many it gets per commit. */
46
+ export declare const DELIVERY_RETRY_MS: number;
47
+ export declare const DELIVERY_RETRIES_MAX = 8;
48
+ /** A set-aside that failed is tried again after this, doubling each time it fails again (up to a day). */
49
+ export declare const SET_ASIDE_BACKOFF_MS: number;
50
+ export interface WatchdogDeps {
51
+ readonly stateDir: string;
52
+ now(): number;
53
+ log(line: string): void;
54
+ /** Every grant this machine holds; only authorized ones are looked at. */
55
+ grants(): readonly AutonomyProgress[];
56
+ /** What each goal waits on, as the tick said it, and since when (epoch ms) it has waited. */
57
+ waits(): ReadonlyMap<string, {
58
+ readonly because: string;
59
+ readonly since: number;
60
+ }>;
61
+ readonly holdRecords: {
62
+ read(controllerId: string): EnvironmentHoldRecord | null;
63
+ /** Does it hold now (`decideEnvironmentHold` with this Looply and this config)? */
64
+ stands(record: EnvironmentHoldRecord): boolean;
65
+ release(controllerId: string): boolean;
66
+ };
67
+ /** The accounts a goal may use now, for its implementer (`account-standing.ts`); null when unknown. */
68
+ accounts?(goalId: string): AccountsFacts | null;
69
+ /**
70
+ * An account, of the project's provider, that may take this goal's calls in EVERY role its runs
71
+ * use, and is not resting; null when there is none (or it cannot tell).
72
+ */
73
+ accountFree?(goalId: string): string | null;
74
+ /** The AI tool can run here now; null when this daemon cannot tell (a configured provider). */
75
+ providerReady?(): boolean | null;
76
+ /** Why no new checkout fits now, or null when one does; undefined when it could not be read. */
77
+ diskProblem?(): string | null | undefined;
78
+ /** The red base's own facts, for a diagnosis. */
79
+ redBase?(): RedBaseFacts | null;
80
+ readonly checkouts?: {
81
+ /** Checkouts under this project's workspaces folders that no run holds (`abandonedWorkspaces`). */
82
+ idle(): readonly string[];
83
+ /** Made by Looply: inside its workspaces folders, never the project's own folder. */
84
+ madeByLooply(path: string): boolean;
85
+ /** A run took it since `idle` was asked. */
86
+ busy(path: string): boolean;
87
+ /** What is changed there, Looply's own folder left out; null when it could not be read. */
88
+ changes(path: string): Promise<readonly string[] | null>;
89
+ setAside(path: string): Promise<SetAside | null>;
90
+ };
91
+ readonly deliveries?: {
92
+ all(): readonly DeliveryEntry[];
93
+ retry(goalId: string): Promise<BranchDeliveryReport | null>;
94
+ };
95
+ herokuLogins?(): Promise<readonly HerokuLoginFact[]>;
96
+ /** Tell the server a wait, as a hold (`grant-waiting-wiring.ts`'s `say`). */
97
+ tellHold?(goalId: string, hold: GoalHold): void;
98
+ /** Clear the hold the server shows for a goal, ONLY when it is still one of this code (`unsay`). */
99
+ untellHold?(goalId: string, code: GoalHold['code']): void;
100
+ }
101
+ /** The last look, as AutoRyn is shown it; null before the first. */
102
+ export declare function readWatchdogReport(stateDir: string): WatchdogReport | null;
103
+ /** One look. Never throws for what it finds; a remedy that fails is said and left for the next look. */
104
+ export declare function watchdogPass(deps: WatchdogDeps): Promise<WatchdogReport>;
105
+ /** The daemon's handle: called on its five-minute cadence, it looks at most every 15 minutes. Never throws. */
106
+ export declare function makeWatchdog(deps: WatchdogDeps, every?: number): () => Promise<WatchdogReport | null>;
107
+ //# sourceMappingURL=watchdog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"watchdog.d.ts","sourceRoot":"","sources":["../src/watchdog.ts"],"names":[],"mappings":"AAGA,OAAO,EAUL,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,KAAK,QAAQ,EACb,KAAK,YAAY,EAEjB,KAAK,cAAc,EAEpB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAiB,KAAK,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAEhE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,eAAO,MAAM,aAAa,kBAAkB,CAAC;AAC7C,gHAAgH;AAChH,eAAO,MAAM,kBAAkB,QAAoB,CAAC;AACpD,sGAAsG;AACtG,eAAO,MAAM,iBAAiB,QAAoB,CAAC;AACnD,eAAO,MAAM,oBAAoB,IAAI,CAAC;AACtC,0GAA0G;AAC1G,eAAO,MAAM,oBAAoB,QAAoB,CAAC;AAgBtD,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,GAAG,IAAI,MAAM,CAAC;IACd,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,0EAA0E;IAC1E,MAAM,IAAI,SAAS,gBAAgB,EAAE,CAAC;IACtC,6FAA6F;IAC7F,KAAK,IAAI,WAAW,CAAC,MAAM,EAAE;QAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,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