@zenalexa/unicli 0.224.1 → 0.225.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/AGENTS.md +3 -3
- package/README.md +91 -91
- package/README.zh-CN.md +68 -68
- package/dist/adapters/xueqiu/extra.js +2 -2
- package/dist/adapters/xueqiu/extra.js.map +1 -1
- package/dist/browser/cdp-client.d.ts +10 -0
- package/dist/browser/cdp-client.d.ts.map +1 -1
- package/dist/browser/cdp-client.js +21 -0
- package/dist/browser/cdp-client.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +4 -3
- package/dist/cli.js.map +1 -1
- package/dist/commands/architecture.d.ts +3 -1
- package/dist/commands/architecture.d.ts.map +1 -1
- package/dist/commands/architecture.js +13 -5
- package/dist/commands/architecture.js.map +1 -1
- package/dist/commands/delivery.d.ts.map +1 -1
- package/dist/commands/delivery.js.map +1 -1
- package/dist/commands/describe.d.ts.map +1 -1
- package/dist/commands/describe.js +104 -9
- package/dist/commands/describe.js.map +1 -1
- package/dist/commands/dispatch.d.ts.map +1 -1
- package/dist/commands/dispatch.js +3 -13
- package/dist/commands/dispatch.js.map +1 -1
- package/dist/commands/do.d.ts +2 -1
- package/dist/commands/do.d.ts.map +1 -1
- package/dist/commands/do.js +43 -4
- package/dist/commands/do.js.map +1 -1
- package/dist/commands/social.d.ts.map +1 -1
- package/dist/commands/social.js +3 -13
- package/dist/commands/social.js.map +1 -1
- package/dist/core/architecture-tree.d.ts +26 -6
- package/dist/core/architecture-tree.d.ts.map +1 -1
- package/dist/core/architecture-tree.js +184 -40
- package/dist/core/architecture-tree.js.map +1 -1
- package/dist/core/capability-matrix.d.ts +63 -0
- package/dist/core/capability-matrix.d.ts.map +1 -0
- package/dist/core/capability-matrix.js +316 -0
- package/dist/core/capability-matrix.js.map +1 -0
- package/dist/core/command-contract-lint.d.ts.map +1 -1
- package/dist/core/command-contract-lint.js +3 -1
- package/dist/core/command-contract-lint.js.map +1 -1
- package/dist/core/command-contract.d.ts +10 -3
- package/dist/core/command-contract.d.ts.map +1 -1
- package/dist/core/command-contract.js +87 -5
- package/dist/core/command-contract.js.map +1 -1
- package/dist/discovery/core-catalog.d.ts +1 -0
- package/dist/discovery/core-catalog.d.ts.map +1 -1
- package/dist/discovery/core-catalog.js +22 -5
- package/dist/discovery/core-catalog.js.map +1 -1
- package/dist/engine/cascade.d.ts.map +1 -1
- package/dist/engine/cascade.js +21 -25
- package/dist/engine/cascade.js.map +1 -1
- package/dist/engine/chromium-cookies.d.ts +27 -0
- package/dist/engine/chromium-cookies.d.ts.map +1 -1
- package/dist/engine/chromium-cookies.js +53 -14
- package/dist/engine/chromium-cookies.js.map +1 -1
- package/dist/engine/cookie-capture.d.ts +30 -0
- package/dist/engine/cookie-capture.d.ts.map +1 -0
- package/dist/engine/cookie-capture.js +104 -0
- package/dist/engine/cookie-capture.js.map +1 -0
- package/dist/engine/cookie-extractor.d.ts.map +1 -1
- package/dist/engine/cookie-extractor.js +4 -12
- package/dist/engine/cookie-extractor.js.map +1 -1
- package/dist/engine/cookie-refresh.d.ts +59 -8
- package/dist/engine/cookie-refresh.d.ts.map +1 -1
- package/dist/engine/cookie-refresh.js +80 -58
- package/dist/engine/cookie-refresh.js.map +1 -1
- package/dist/engine/cookie-source.d.ts +110 -0
- package/dist/engine/cookie-source.d.ts.map +1 -0
- package/dist/engine/cookie-source.js +207 -0
- package/dist/engine/cookie-source.js.map +1 -0
- package/dist/engine/cookies.d.ts +37 -25
- package/dist/engine/cookies.d.ts.map +1 -1
- package/dist/engine/cookies.js +58 -157
- package/dist/engine/cookies.js.map +1 -1
- package/dist/engine/delivery/index.d.ts +2 -1
- package/dist/engine/delivery/index.d.ts.map +1 -1
- package/dist/engine/delivery/index.js +2 -1
- package/dist/engine/delivery/index.js.map +1 -1
- package/dist/engine/delivery/spec.d.ts +44 -0
- package/dist/engine/delivery/spec.d.ts.map +1 -0
- package/dist/engine/delivery/spec.js +82 -0
- package/dist/engine/delivery/spec.js.map +1 -0
- package/dist/engine/executor.d.ts +17 -6
- package/dist/engine/executor.d.ts.map +1 -1
- package/dist/engine/executor.js +131 -68
- package/dist/engine/executor.js.map +1 -1
- package/dist/engine/runtime.d.ts.map +1 -1
- package/dist/engine/runtime.js +9 -4
- package/dist/engine/runtime.js.map +1 -1
- package/dist/engine/step-observer.d.ts +62 -0
- package/dist/engine/step-observer.d.ts.map +1 -0
- package/dist/engine/step-observer.js +38 -0
- package/dist/engine/step-observer.js.map +1 -0
- package/dist/engine/steps/browser-helpers.d.ts.map +1 -1
- package/dist/engine/steps/browser-helpers.js +2 -8
- package/dist/engine/steps/browser-helpers.js.map +1 -1
- package/dist/engine/steps/fetch-text.d.ts.map +1 -1
- package/dist/engine/steps/fetch-text.js +106 -33
- package/dist/engine/steps/fetch-text.js.map +1 -1
- package/dist/engine/steps/fetch.d.ts +20 -0
- package/dist/engine/steps/fetch.d.ts.map +1 -1
- package/dist/engine/steps/fetch.js.map +1 -1
- package/dist/engine/steps/index.d.ts +2 -0
- package/dist/engine/steps/index.d.ts.map +1 -1
- package/dist/engine/steps/index.js +2 -0
- package/dist/engine/steps/index.js.map +1 -1
- package/dist/engine/steps/split-text.d.ts +26 -0
- package/dist/engine/steps/split-text.d.ts.map +1 -0
- package/dist/engine/steps/split-text.js +89 -0
- package/dist/engine/steps/split-text.js.map +1 -0
- package/dist/engine/steps/to-entries.d.ts +9 -0
- package/dist/engine/steps/to-entries.d.ts.map +1 -0
- package/dist/engine/steps/to-entries.js +27 -0
- package/dist/engine/steps/to-entries.js.map +1 -0
- package/dist/fast-path/handlers/discovery.d.ts.map +1 -1
- package/dist/fast-path/handlers/discovery.js +7 -7
- package/dist/fast-path/handlers/discovery.js.map +1 -1
- package/dist/manifest-compact.txt +1 -1
- package/dist/manifest.json +142 -1
- package/dist/mcp/tools.js +1 -1
- package/dist/mcp/tools.js.map +1 -1
- package/dist/output/auth-guidance.d.ts +17 -3
- package/dist/output/auth-guidance.d.ts.map +1 -1
- package/dist/output/auth-guidance.js +27 -3
- package/dist/output/auth-guidance.js.map +1 -1
- package/dist/output/error-map.d.ts.map +1 -1
- package/dist/output/error-map.js +4 -0
- package/dist/output/error-map.js.map +1 -1
- package/package.json +2 -2
- package/server.json +2 -2
- package/skills/unicli/SKILL.md +1 -1
- package/skills/unicli-claude-code/SKILL.md +1 -1
- package/skills/unicli-hermes/SKILL.md +1 -1
- package/src/adapters/12306/price.yaml +91 -0
- package/src/adapters/12306/stations.yaml +52 -0
- package/src/adapters/12306/trains.yaml +129 -0
- package/src/adapters/xueqiu/extra.ts +5 -2
package/dist/engine/cookies.js
CHANGED
|
@@ -1,39 +1,29 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
2
|
+
* @owner src::engine::cookies
|
|
3
|
+
* @does Cookie front door for adapters — thin projections over the
|
|
4
|
+
* structured acquisition core in cookie-source.ts (disk read,
|
|
5
|
+
* header formatting, multi-source load, refresh).
|
|
6
|
+
* @needs ./cookie-source, ./cookie-extractor (saveCookies)
|
|
7
|
+
* @feeds adapters (loadCookiesWithCDP/formatCookieHeader), executor,
|
|
8
|
+
* dispatch/social (refreshCookiesFromBrowser), commands/auth
|
|
9
|
+
* @breaks loadCookies/loadCookiesWithCDP return null on miss (back-compat);
|
|
10
|
+
* acquireCookies returns a typed CookieLoadOutcome that names the
|
|
11
|
+
* real cause — callers that need the cause use acquireCookies
|
|
12
|
+
* @invariants loadCookiesWithCDP cookies === acquireCookies(...).cookies on load
|
|
13
|
+
* @side-effects acquireCookies persists browser/CDP cookies to disk (best-effort)
|
|
14
|
+
* @test tests/unit/engine/cookie-source.test.ts, cookie-refresh-format.test.ts
|
|
15
|
+
* @stability stable
|
|
16
|
+
* @since 2026-05-30
|
|
6
17
|
*/
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { extractCookiesViaCDP, saveCookies as saveCookiesToDisk, } from "./cookie-extractor.js";
|
|
10
|
-
function cookieDir() {
|
|
11
|
-
return (process.env.UNICLI_COOKIE_DIR ??
|
|
12
|
-
join(process.env.HOME ?? "~", ".unicli", "cookies"));
|
|
13
|
-
}
|
|
18
|
+
import { cookieDir, describeCookieFailure, loadCookiesWithDiagnostics, readDiskCookies, resolveCookieDomain, } from "./cookie-source.js";
|
|
19
|
+
import { saveCookies as saveCookiesToDisk } from "./cookie-extractor.js";
|
|
14
20
|
/**
|
|
15
|
-
* Load cookies for a site from disk.
|
|
16
|
-
*
|
|
21
|
+
* Load cookies for a site from disk. Returns null when the file is absent OR
|
|
22
|
+
* unreadable; callers needing to tell those apart use `acquireCookies`.
|
|
17
23
|
*/
|
|
18
24
|
export function loadCookies(site) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const path = join(cookieDir(), `${site}.json`);
|
|
22
|
-
if (!existsSync(path))
|
|
23
|
-
return null;
|
|
24
|
-
try {
|
|
25
|
-
const raw = readFileSync(path, "utf-8");
|
|
26
|
-
const parsed = JSON.parse(raw);
|
|
27
|
-
if (typeof parsed !== "object" ||
|
|
28
|
-
parsed === null ||
|
|
29
|
-
Array.isArray(parsed)) {
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
return parsed;
|
|
33
|
-
}
|
|
34
|
-
catch {
|
|
35
|
-
return null;
|
|
36
|
-
}
|
|
25
|
+
const read = readDiskCookies(site);
|
|
26
|
+
return read.kind === "ok" ? read.cookies : null;
|
|
37
27
|
}
|
|
38
28
|
/**
|
|
39
29
|
* Format cookies as an HTTP Cookie header value.
|
|
@@ -44,9 +34,7 @@ export function formatCookieHeader(cookies) {
|
|
|
44
34
|
.map(([k, v]) => `${k}=${v}`)
|
|
45
35
|
.join("; ");
|
|
46
36
|
}
|
|
47
|
-
/**
|
|
48
|
-
* Validate that a cookie file has all required keys.
|
|
49
|
-
*/
|
|
37
|
+
/** Validate that a cookie file has all required keys. */
|
|
50
38
|
export function validateCookies(site, requiredKeys) {
|
|
51
39
|
const cookies = loadCookies(site);
|
|
52
40
|
if (!cookies)
|
|
@@ -54,77 +42,44 @@ export function validateCookies(site, requiredKeys) {
|
|
|
54
42
|
const missing = requiredKeys.filter((k) => !(k in cookies));
|
|
55
43
|
return { valid: missing.length === 0, missing };
|
|
56
44
|
}
|
|
57
|
-
/**
|
|
58
|
-
* Get the cookie directory path (for display in auth commands).
|
|
59
|
-
*/
|
|
45
|
+
/** Get the cookie directory path (for display in auth commands). */
|
|
60
46
|
export function getCookieDir() {
|
|
61
47
|
return cookieDir();
|
|
62
48
|
}
|
|
63
49
|
/**
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
* 3. CDP — connects to Chrome debug port (legacy)
|
|
70
|
-
*
|
|
71
|
-
* The browser disk source is the new default for `strategy: cookie` adapters:
|
|
72
|
-
* it works whether the browser is open or closed, never opens a new tab, and
|
|
73
|
-
* needs neither extension nor daemon. Successful reads are persisted to
|
|
74
|
-
* ~/.unicli/cookies for offline reuse.
|
|
75
|
-
*
|
|
76
|
-
* Set `UNICLI_COOKIE_NO_BROWSER=1` to skip the browser-disk step (e.g., in CI
|
|
77
|
-
* where the macOS Keychain prompt would block).
|
|
50
|
+
* Acquire cookies across disk → browser → CDP, returning the structured outcome
|
|
51
|
+
* (loaded / absent / error+reasons). On a non-disk load, persists to
|
|
52
|
+
* ~/.unicli/cookies for offline reuse. This is the front door for callers that
|
|
53
|
+
* need to surface WHY acquisition failed (Keychain denial, v20 encryption,
|
|
54
|
+
* corrupt file) instead of a bare null.
|
|
78
55
|
*/
|
|
79
|
-
export async function
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
// Resolve the cookie domain once for both browser and CDP paths.
|
|
85
|
-
let cookieDomain = domain ?? site.replace(/_/g, ".");
|
|
86
|
-
if (!cookieDomain.includes(".")) {
|
|
87
|
-
cookieDomain = `${cookieDomain}.com`;
|
|
88
|
-
}
|
|
89
|
-
// 2. Direct browser disk read (no launch, no CDP, no extension).
|
|
90
|
-
if (process.env.UNICLI_COOKIE_NO_BROWSER !== "1") {
|
|
91
|
-
const browserCookies = await loadFromInstalledBrowser(cookieDomain);
|
|
92
|
-
if (browserCookies && Object.keys(browserCookies).length > 0) {
|
|
93
|
-
try {
|
|
94
|
-
saveCookiesToDisk(site, browserCookies);
|
|
95
|
-
}
|
|
96
|
-
catch {
|
|
97
|
-
// Non-fatal — caller still gets the cookies.
|
|
98
|
-
}
|
|
99
|
-
return browserCookies;
|
|
56
|
+
export async function acquireCookies(site, domain, opts = {}) {
|
|
57
|
+
const outcome = await loadCookiesWithDiagnostics(site, domain, undefined, opts);
|
|
58
|
+
if (outcome.status === "loaded" && outcome.source !== "disk") {
|
|
59
|
+
try {
|
|
60
|
+
saveCookiesToDisk(site, outcome.cookies);
|
|
100
61
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
const cdpCookies = await extractCookiesViaCDP(cookieDomain);
|
|
105
|
-
if (Object.keys(cdpCookies).length > 0) {
|
|
106
|
-
try {
|
|
107
|
-
saveCookiesToDisk(site, cdpCookies);
|
|
108
|
-
}
|
|
109
|
-
catch {
|
|
110
|
-
// Non-fatal: disk write failed but we still have the cookies
|
|
111
|
-
}
|
|
112
|
-
return cdpCookies;
|
|
62
|
+
catch {
|
|
63
|
+
// REASON: persistence is best-effort; the cookies are already usable for
|
|
64
|
+
// this run, and the next run re-acquires from the same live source.
|
|
113
65
|
}
|
|
114
66
|
}
|
|
115
|
-
|
|
116
|
-
// CDP not available — fall through
|
|
117
|
-
}
|
|
118
|
-
return null;
|
|
67
|
+
return outcome;
|
|
119
68
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
69
|
+
/**
|
|
70
|
+
* Load cookies with multi-source fallback (disk → browser DB → CDP). Returns
|
|
71
|
+
* null on any miss. Behavior-compatible with every existing adapter consumer;
|
|
72
|
+
* the structured cause is available via `acquireCookies`.
|
|
73
|
+
*/
|
|
74
|
+
export async function loadCookiesWithCDP(site, domain) {
|
|
75
|
+
const outcome = await acquireCookies(site, domain);
|
|
76
|
+
return outcome.status === "loaded" ? outcome.cookies : null;
|
|
127
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* Re-acquire cookies from the live browser / CDP after an auth failure. Skips
|
|
80
|
+
* the on-disk file (those are the stale cookies that just failed) and reports
|
|
81
|
+
* the real cause on failure rather than a generic message.
|
|
82
|
+
*/
|
|
128
83
|
export async function refreshCookiesFromBrowser(site, domain) {
|
|
129
84
|
if (!/^[a-zA-Z0-9._-]+$/.test(site)) {
|
|
130
85
|
return {
|
|
@@ -134,77 +89,23 @@ export async function refreshCookiesFromBrowser(site, domain) {
|
|
|
134
89
|
suggestion: "Site names must contain only letters, digits, dot, dash, or underscore.",
|
|
135
90
|
};
|
|
136
91
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
}
|
|
141
|
-
if (process.env.UNICLI_COOKIE_NO_BROWSER !== "1") {
|
|
142
|
-
const browserCookies = await loadFromInstalledBrowser(cookieDomain);
|
|
143
|
-
if (browserCookies && Object.keys(browserCookies).length > 0) {
|
|
144
|
-
persistCookies(site, browserCookies);
|
|
145
|
-
return {
|
|
146
|
-
ok: true,
|
|
147
|
-
site,
|
|
148
|
-
domain: cookieDomain,
|
|
149
|
-
source: "browser",
|
|
150
|
-
cookieCount: Object.keys(browserCookies).length,
|
|
151
|
-
cookies: Object.keys(browserCookies),
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
try {
|
|
156
|
-
const cdpCookies = await extractCookiesViaCDP(cookieDomain);
|
|
157
|
-
if (Object.keys(cdpCookies).length > 0) {
|
|
158
|
-
persistCookies(site, cdpCookies);
|
|
159
|
-
return {
|
|
160
|
-
ok: true,
|
|
161
|
-
site,
|
|
162
|
-
domain: cookieDomain,
|
|
163
|
-
source: "cdp",
|
|
164
|
-
cookieCount: Object.keys(cdpCookies).length,
|
|
165
|
-
cookies: Object.keys(cdpCookies),
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
catch {
|
|
92
|
+
const cookieDomain = resolveCookieDomain(site, domain);
|
|
93
|
+
const outcome = await acquireCookies(site, domain, { skipDisk: true });
|
|
94
|
+
if (outcome.status === "loaded") {
|
|
170
95
|
return {
|
|
171
|
-
ok:
|
|
96
|
+
ok: true,
|
|
172
97
|
site,
|
|
173
98
|
domain: cookieDomain,
|
|
174
|
-
|
|
99
|
+
source: outcome.source === "cdp" ? "cdp" : "browser",
|
|
100
|
+
cookieCount: Object.keys(outcome.cookies).length,
|
|
101
|
+
cookies: Object.keys(outcome.cookies),
|
|
175
102
|
};
|
|
176
103
|
}
|
|
177
104
|
return {
|
|
178
105
|
ok: false,
|
|
179
106
|
site,
|
|
180
107
|
domain: cookieDomain,
|
|
181
|
-
suggestion:
|
|
108
|
+
suggestion: describeCookieFailure(outcome, site, domain).suggestion,
|
|
182
109
|
};
|
|
183
110
|
}
|
|
184
|
-
/**
|
|
185
|
-
* Try each installed Chromium browser in priority order until one yields
|
|
186
|
-
* cookies for the domain. Failures (browser not installed, Keychain denied,
|
|
187
|
-
* unsupported encryption) fall through silently — the next source handles it.
|
|
188
|
-
*/
|
|
189
|
-
async function loadFromInstalledBrowser(domain) {
|
|
190
|
-
let mod;
|
|
191
|
-
try {
|
|
192
|
-
mod = await import("./chromium-cookies.js");
|
|
193
|
-
}
|
|
194
|
-
catch {
|
|
195
|
-
return null;
|
|
196
|
-
}
|
|
197
|
-
const installed = mod.detectInstalledBrowsers();
|
|
198
|
-
for (const browser of installed) {
|
|
199
|
-
try {
|
|
200
|
-
const record = mod.readCookiesAsRecord({ browser, domain });
|
|
201
|
-
if (Object.keys(record).length > 0)
|
|
202
|
-
return record;
|
|
203
|
-
}
|
|
204
|
-
catch {
|
|
205
|
-
// Move on to the next browser.
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
return null;
|
|
209
|
-
}
|
|
210
111
|
//# sourceMappingURL=cookies.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cookies.js","sourceRoot":"","sources":["../../src/engine/cookies.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"cookies.js","sourceRoot":"","sources":["../../src/engine/cookies.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EACL,SAAS,EACT,qBAAqB,EACrB,0BAA0B,EAC1B,eAAe,EACf,mBAAmB,GAEpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,WAAW,IAAI,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAEzE;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,MAAM,IAAI,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;IACnC,OAAO,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;AAClD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAA+B;IAChE,OAAO,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC;SAC3B,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;SAC5B,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC;AAED,yDAAyD;AACzD,MAAM,UAAU,eAAe,CAC7B,IAAY,EACZ,YAAsB;IAEtB,MAAM,OAAO,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;IAClC,IAAI,CAAC,OAAO;QAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC;IAC7D,MAAM,OAAO,GAAG,YAAY,CAAC,MA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IAAI,IAAI;YACtB,UAAU,EACR,yEAAyE;SAC5E,CAAC;IACJ,CAAC;IAED,MAAM,YAAY,GAAG,mBAAmB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACvD,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;IAEvE,IAAI,OAAO,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;QAChC,OAAO;YACL,EAAE,EAAE,IAAI;YACR,IAAI;YACJ,MAAM,EAAE,YAAY;YACpB,MAAM,EAAE,OAAO,CAAC,MAAM,KAAK,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS;YACpD,WAAW,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM;YAChD,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;SACtC,CAAC;IACJ,CAAC;IAED,OAAO;QACL,EAAE,EAAE,KAAK;QACT,IAAI;QACJ,MAAM,EAAE,YAAY;QACpB,UAAU,EAAE,qBAAqB,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,UAAU;KACpE,CAAC;AACJ,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @owner src/engine/delivery/index.ts
|
|
3
3
|
* @does Exposes the internal objective-level delivery kernel.
|
|
4
|
-
* @needs src/engine/delivery/planner.ts, src/engine/delivery/repair.ts, src/engine/delivery/session.ts, src/engine/delivery/trajectory.ts, src/engine/delivery/types.ts
|
|
4
|
+
* @needs src/engine/delivery/planner.ts, src/engine/delivery/repair.ts, src/engine/delivery/session.ts, src/engine/delivery/spec.ts, src/engine/delivery/trajectory.ts, src/engine/delivery/types.ts
|
|
5
5
|
* @feeds tests and future command surfaces that orchestrate objective delivery.
|
|
6
6
|
* @breaks Missing exports hide the delivery state machine from integration layers.
|
|
7
7
|
* @invariants exports are side-effect free and preserve the delivery module boundary.
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
export * from "./planner.js";
|
|
16
16
|
export * from "./repair.js";
|
|
17
17
|
export * from "./session.js";
|
|
18
|
+
export * from "./spec.js";
|
|
18
19
|
export * from "./trajectory.js";
|
|
19
20
|
export * from "./types.js";
|
|
20
21
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/engine/delivery/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/engine/delivery/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @owner src/engine/delivery/index.ts
|
|
3
3
|
* @does Exposes the internal objective-level delivery kernel.
|
|
4
|
-
* @needs src/engine/delivery/planner.ts, src/engine/delivery/repair.ts, src/engine/delivery/session.ts, src/engine/delivery/trajectory.ts, src/engine/delivery/types.ts
|
|
4
|
+
* @needs src/engine/delivery/planner.ts, src/engine/delivery/repair.ts, src/engine/delivery/session.ts, src/engine/delivery/spec.ts, src/engine/delivery/trajectory.ts, src/engine/delivery/types.ts
|
|
5
5
|
* @feeds tests and future command surfaces that orchestrate objective delivery.
|
|
6
6
|
* @breaks Missing exports hide the delivery state machine from integration layers.
|
|
7
7
|
* @invariants exports are side-effect free and preserve the delivery module boundary.
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
export * from "./planner.js";
|
|
16
16
|
export * from "./repair.js";
|
|
17
17
|
export * from "./session.js";
|
|
18
|
+
export * from "./spec.js";
|
|
18
19
|
export * from "./trajectory.js";
|
|
19
20
|
export * from "./types.js";
|
|
20
21
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/engine/delivery/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/engine/delivery/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @owner src/engine/delivery/spec.ts
|
|
3
|
+
* @does Builds explicit delivery operator spec templates from executable command matches.
|
|
4
|
+
* @needs src/engine/delivery/types.ts, src/types.ts
|
|
5
|
+
* @feeds src/commands/do.ts, src/commands/delivery.ts, tests/unit/delivery-cli.test.ts
|
|
6
|
+
* @breaks Bad template IDs or strategy kinds make do-to-delivery handoff ambiguous or non-executable.
|
|
7
|
+
* @invariants generated specs contain no attempts or runs; execution remains owned by delivery.run.
|
|
8
|
+
* @side-effects none
|
|
9
|
+
* @perf O(command metadata size).
|
|
10
|
+
* @concurrency pure and reentrant.
|
|
11
|
+
* @test tests/unit/commands/do.test.ts, tests/unit/delivery-cli.test.ts
|
|
12
|
+
* @stability experimental
|
|
13
|
+
* @since 2026-05-31
|
|
14
|
+
*/
|
|
15
|
+
import type { AdapterType, TargetSurface } from "../../types.js";
|
|
16
|
+
import type { DeliveryAttempt, DeliveryObjective, DeliveryStrategy } from "./types.js";
|
|
17
|
+
import type { RunId } from "../session/types.js";
|
|
18
|
+
export interface DeliveryRunRef {
|
|
19
|
+
run_id: RunId;
|
|
20
|
+
strategy_id: string;
|
|
21
|
+
id?: string;
|
|
22
|
+
ordinal?: number;
|
|
23
|
+
}
|
|
24
|
+
export interface DeliveryOperatorSpec {
|
|
25
|
+
objective: DeliveryObjective;
|
|
26
|
+
strategies: DeliveryStrategy[];
|
|
27
|
+
attempts: DeliveryAttempt[];
|
|
28
|
+
runs: DeliveryRunRef[];
|
|
29
|
+
recorded_at?: string;
|
|
30
|
+
}
|
|
31
|
+
export interface DeliverySpecCommandMatch {
|
|
32
|
+
intent: string;
|
|
33
|
+
site: string;
|
|
34
|
+
command: string;
|
|
35
|
+
description?: string;
|
|
36
|
+
args?: Record<string, unknown>;
|
|
37
|
+
adapter_path?: string;
|
|
38
|
+
verify_command?: string;
|
|
39
|
+
adapter_type?: AdapterType | string;
|
|
40
|
+
target_surface?: TargetSurface | string;
|
|
41
|
+
uses_browser?: boolean;
|
|
42
|
+
}
|
|
43
|
+
export declare function buildDeliveryOperatorSpecTemplate(match: DeliverySpecCommandMatch): DeliveryOperatorSpec;
|
|
44
|
+
//# sourceMappingURL=spec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spec.d.ts","sourceRoot":"","sources":["../../../src/engine/delivery/spec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,KAAK,EACV,eAAe,EAEf,iBAAiB,EACjB,gBAAgB,EAEjB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAOjD,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,KAAK,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,iBAAiB,CAAC;IAC7B,UAAU,EAAE,gBAAgB,EAAE,CAAC;IAC/B,QAAQ,EAAE,eAAe,EAAE,CAAC;IAC5B,IAAI,EAAE,cAAc,EAAE,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,WAAW,GAAG,MAAM,CAAC;IACpC,cAAc,CAAC,EAAE,aAAa,GAAG,MAAM,CAAC;IACxC,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,wBAAgB,iCAAiC,CAC/C,KAAK,EAAE,wBAAwB,GAC9B,oBAAoB,CA6BtB"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @owner src/engine/delivery/spec.ts
|
|
3
|
+
* @does Builds explicit delivery operator spec templates from executable command matches.
|
|
4
|
+
* @needs src/engine/delivery/types.ts, src/types.ts
|
|
5
|
+
* @feeds src/commands/do.ts, src/commands/delivery.ts, tests/unit/delivery-cli.test.ts
|
|
6
|
+
* @breaks Bad template IDs or strategy kinds make do-to-delivery handoff ambiguous or non-executable.
|
|
7
|
+
* @invariants generated specs contain no attempts or runs; execution remains owned by delivery.run.
|
|
8
|
+
* @side-effects none
|
|
9
|
+
* @perf O(command metadata size).
|
|
10
|
+
* @concurrency pure and reentrant.
|
|
11
|
+
* @test tests/unit/commands/do.test.ts, tests/unit/delivery-cli.test.ts
|
|
12
|
+
* @stability experimental
|
|
13
|
+
* @since 2026-05-31
|
|
14
|
+
*/
|
|
15
|
+
const DEFAULT_TEMPLATE_GATES = [
|
|
16
|
+
{ kind: "run_completed" },
|
|
17
|
+
{ kind: "required_evidence_type", evidence_type: "result-envelope" },
|
|
18
|
+
];
|
|
19
|
+
export function buildDeliveryOperatorSpecTemplate(match) {
|
|
20
|
+
const site = match.site.trim();
|
|
21
|
+
const command = match.command.trim();
|
|
22
|
+
const objectiveId = `deliver-${slugPart(site)}-${slugPart(command)}`;
|
|
23
|
+
const strategyKind = strategyKindForMatch(match);
|
|
24
|
+
const strategyId = `${strategyKind}-${slugPart(site)}-${slugPart(command)}`;
|
|
25
|
+
const strategy = {
|
|
26
|
+
id: strategyId,
|
|
27
|
+
kind: strategyKind,
|
|
28
|
+
label: strategyLabel(match, site, command),
|
|
29
|
+
priority: 10,
|
|
30
|
+
command: `${site}.${command}`,
|
|
31
|
+
...(hasEntries(match.args) ? { args: match.args } : {}),
|
|
32
|
+
...(nonEmpty(match.adapter_path)
|
|
33
|
+
? { adapter_path: match.adapter_path }
|
|
34
|
+
: {}),
|
|
35
|
+
verify_command: match.verify_command ?? `unicli test ${site} ${command}`,
|
|
36
|
+
};
|
|
37
|
+
return {
|
|
38
|
+
objective: {
|
|
39
|
+
id: objectiveId,
|
|
40
|
+
goal: nonEmpty(match.intent) ?? `Run ${site}.${command}`,
|
|
41
|
+
evidence_gates: DEFAULT_TEMPLATE_GATES,
|
|
42
|
+
},
|
|
43
|
+
strategies: [strategy],
|
|
44
|
+
attempts: [],
|
|
45
|
+
runs: [],
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function strategyKindForMatch(match) {
|
|
49
|
+
if (match.uses_browser === true || match.adapter_type === "browser") {
|
|
50
|
+
return "browser";
|
|
51
|
+
}
|
|
52
|
+
if (match.target_surface === "desktop" || match.adapter_type === "desktop") {
|
|
53
|
+
return "desktop";
|
|
54
|
+
}
|
|
55
|
+
if (match.target_surface === "system" ||
|
|
56
|
+
match.adapter_type === "bridge" ||
|
|
57
|
+
match.adapter_type === "service") {
|
|
58
|
+
return "local";
|
|
59
|
+
}
|
|
60
|
+
return "adapter";
|
|
61
|
+
}
|
|
62
|
+
function strategyLabel(match, site, command) {
|
|
63
|
+
const description = nonEmpty(match.description);
|
|
64
|
+
return description
|
|
65
|
+
? `Run ${site}.${command}: ${description}`
|
|
66
|
+
: `Run ${site}.${command}`;
|
|
67
|
+
}
|
|
68
|
+
function hasEntries(value) {
|
|
69
|
+
return value !== undefined && Object.keys(value).length > 0;
|
|
70
|
+
}
|
|
71
|
+
function nonEmpty(value) {
|
|
72
|
+
const trimmed = value?.trim();
|
|
73
|
+
return trimmed ? trimmed : undefined;
|
|
74
|
+
}
|
|
75
|
+
function slugPart(value) {
|
|
76
|
+
return (value
|
|
77
|
+
.trim()
|
|
78
|
+
.toLowerCase()
|
|
79
|
+
.replace(/[^a-z0-9]+/g, "-")
|
|
80
|
+
.replace(/^-+|-+$/g, "") || "command");
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spec.js","sourceRoot":"","sources":["../../../src/engine/delivery/spec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAYH,MAAM,sBAAsB,GAA2B;IACrD,EAAE,IAAI,EAAE,eAAe,EAAE;IACzB,EAAE,IAAI,EAAE,wBAAwB,EAAE,aAAa,EAAE,iBAAiB,EAAE;CACrE,CAAC;AA8BF,MAAM,UAAU,iCAAiC,CAC/C,KAA+B;IAE/B,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,CAA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,CACxC,CAAC;AACJ,CAAC"}
|
|
@@ -4,17 +4,21 @@
|
|
|
4
4
|
* Dispatches pipeline steps through `step-registry`. Per-step bodies live
|
|
5
5
|
* in `steps/*.ts` and self-register on import. This file owns:
|
|
6
6
|
* - PipelineError shape
|
|
7
|
-
* - `executeStep` dispatch (registry → visual/ax bus → plugin registry)
|
|
7
|
+
* - `executeStep` dispatch (registry → visual/ax bus → plugin registry);
|
|
8
|
+
* an unrecognized action raises a typed `unknown_action` PipelineError
|
|
9
|
+
* - `buildPipelineError` — single shaping point for step-failure envelopes
|
|
8
10
|
* - `runPipeline` orchestration (cookies, retry, fallback, auto-fix,
|
|
9
|
-
* diagnostic, cookie refresh, temp-dir cleanup)
|
|
11
|
+
* diagnostic, cookie refresh, temp-dir cleanup, per-step observation)
|
|
10
12
|
*
|
|
11
|
-
* Per-step recovery helpers live in `runtime.ts`.
|
|
13
|
+
* Per-step recovery helpers live in `runtime.ts`. The per-step observation
|
|
14
|
+
* record + sink contract live in `step-observer.ts`.
|
|
12
15
|
*/
|
|
13
16
|
import type { PipelineStep } from "../types.js";
|
|
14
17
|
import type { BrowserSessionPreference } from "../types.js";
|
|
15
18
|
import type { BrowserPage } from "../browser/page.js";
|
|
16
19
|
import { getBus, buildTransportCtx, _resetTransportBusForTests } from "../transport/bus.js";
|
|
17
20
|
import type { ArgSource, ResolvedArgs } from "./args.js";
|
|
21
|
+
import { type StepObserver } from "./step-observer.js";
|
|
18
22
|
import "./steps/index.js";
|
|
19
23
|
export { assertSafeRequestUrl } from "./ssrf.js";
|
|
20
24
|
export { getBus, buildTransportCtx, _resetTransportBusForTests };
|
|
@@ -44,6 +48,13 @@ export interface PipelineOptions {
|
|
|
44
48
|
trace_id?: string;
|
|
45
49
|
/** Browser transport preference declared by a browser command. */
|
|
46
50
|
browserSession?: BrowserSessionPreference;
|
|
51
|
+
/**
|
|
52
|
+
* Optional sink for per-step observations. When provided, runPipeline emits
|
|
53
|
+
* one observation per executed step (timing + output shape on success,
|
|
54
|
+
* errorType + message on failure). Additive side channel — never alters the
|
|
55
|
+
* result/error envelope. Undefined = zero overhead (the default).
|
|
56
|
+
*/
|
|
57
|
+
observer?: StepObserver;
|
|
47
58
|
}
|
|
48
59
|
export type PipelineContext = {
|
|
49
60
|
data: unknown;
|
|
@@ -74,7 +85,7 @@ export declare class PipelineError extends Error {
|
|
|
74
85
|
step: number;
|
|
75
86
|
action: string;
|
|
76
87
|
config: unknown;
|
|
77
|
-
errorType: "http_error" | "selector_miss" | "empty_result" | "parse_error" | "network_error" | "timeout" | "expression_error" | "assertion_failed" | "permission_denied" | "stale_ref" | "ambiguous" | "ref_not_found";
|
|
88
|
+
errorType: "http_error" | "selector_miss" | "empty_result" | "parse_error" | "network_error" | "timeout" | "expression_error" | "assertion_failed" | "permission_denied" | "stale_ref" | "ambiguous" | "ref_not_found" | "unknown_action";
|
|
78
89
|
url?: string;
|
|
79
90
|
statusCode?: number;
|
|
80
91
|
responsePreview?: string;
|
|
@@ -86,7 +97,7 @@ export declare class PipelineError extends Error {
|
|
|
86
97
|
step: number;
|
|
87
98
|
action: string;
|
|
88
99
|
config: unknown;
|
|
89
|
-
errorType: "http_error" | "selector_miss" | "empty_result" | "parse_error" | "network_error" | "timeout" | "expression_error" | "assertion_failed" | "permission_denied" | "stale_ref" | "ambiguous" | "ref_not_found";
|
|
100
|
+
errorType: "http_error" | "selector_miss" | "empty_result" | "parse_error" | "network_error" | "timeout" | "expression_error" | "assertion_failed" | "permission_denied" | "stale_ref" | "ambiguous" | "ref_not_found" | "unknown_action";
|
|
90
101
|
url?: string;
|
|
91
102
|
statusCode?: number;
|
|
92
103
|
responsePreview?: string;
|
|
@@ -100,7 +111,7 @@ export declare class PipelineError extends Error {
|
|
|
100
111
|
step: number;
|
|
101
112
|
action: string;
|
|
102
113
|
config: unknown;
|
|
103
|
-
errorType: "http_error" | "selector_miss" | "empty_result" | "parse_error" | "network_error" | "timeout" | "expression_error" | "assertion_failed" | "permission_denied" | "stale_ref" | "ambiguous" | "ref_not_found";
|
|
114
|
+
errorType: "http_error" | "selector_miss" | "empty_result" | "parse_error" | "network_error" | "timeout" | "expression_error" | "assertion_failed" | "permission_denied" | "stale_ref" | "ambiguous" | "ref_not_found" | "unknown_action";
|
|
104
115
|
url?: string;
|
|
105
116
|
statusCode?: number;
|
|
106
117
|
responsePreview?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../src/engine/executor.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../src/engine/executor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AActD,OAAO,EACL,MAAM,EACN,iBAAiB,EACjB,0BAA0B,EAC3B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EACL,KAAK,YAAY,EAGlB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,kBAAkB,CAAC;AAE1B,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,0BAA0B,EAAE,CAAC;AAEjE,MAAM,WAAW,eAAe;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,OAAO,CAAC,EAAE,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,OAAO,GAAG,KAAK,C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