pi-harness-runtime 1.1.512 → 1.1.513
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/CHANGELOG.md +91 -0
- package/footer-status.ts +112 -43
- package/harness/cookie-import-refresh.ts +60 -0
- package/harness/quota-credential-choice.ts +67 -0
- package/harness/quota-refresh-coordinator.ts +129 -0
- package/index.ts +182 -97
- package/package.json +1 -1
- package/packages/agent-policy/package.json +1 -1
- package/packages/auth/package.json +1 -1
- package/packages/autonomous-runtime/package.json +1 -1
- package/packages/checkpoint/package.json +1 -1
- package/packages/clipboard/package.json +1 -1
- package/packages/codex-watcher/package.json +1 -1
- package/packages/config-capture/package.json +1 -1
- package/packages/contracts/package.json +1 -1
- package/packages/cookie-sanitizer/dist/detect-format.d.ts +26 -12
- package/packages/cookie-sanitizer/dist/detect-format.d.ts.map +1 -1
- package/packages/cookie-sanitizer/dist/detect-format.js +54 -39
- package/packages/cookie-sanitizer/dist/detect-format.js.map +1 -1
- package/packages/cookie-sanitizer/dist/index.d.ts +9 -3
- package/packages/cookie-sanitizer/dist/index.d.ts.map +1 -1
- package/packages/cookie-sanitizer/dist/index.js +5 -3
- package/packages/cookie-sanitizer/dist/index.js.map +1 -1
- package/packages/cookie-sanitizer/dist/parse-netscape-space.d.ts +73 -0
- package/packages/cookie-sanitizer/dist/parse-netscape-space.d.ts.map +1 -0
- package/packages/cookie-sanitizer/dist/parse-netscape-space.js +154 -0
- package/packages/cookie-sanitizer/dist/parse-netscape-space.js.map +1 -0
- package/packages/cookie-sanitizer/dist/parse-netscape.d.ts +28 -1
- package/packages/cookie-sanitizer/dist/parse-netscape.d.ts.map +1 -1
- package/packages/cookie-sanitizer/dist/parse-netscape.js +50 -13
- package/packages/cookie-sanitizer/dist/parse-netscape.js.map +1 -1
- package/packages/cookie-sanitizer/dist/source-state.d.ts +56 -0
- package/packages/cookie-sanitizer/dist/source-state.d.ts.map +1 -0
- package/packages/cookie-sanitizer/dist/source-state.js +61 -0
- package/packages/cookie-sanitizer/dist/source-state.js.map +1 -0
- package/packages/cookie-sanitizer/dist/sync.d.ts +9 -0
- package/packages/cookie-sanitizer/dist/sync.d.ts.map +1 -1
- package/packages/cookie-sanitizer/dist/sync.js +47 -16
- package/packages/cookie-sanitizer/dist/sync.js.map +1 -1
- package/packages/cookie-sanitizer/dist/types.d.ts +1 -1
- package/packages/cookie-sanitizer/dist/types.d.ts.map +1 -1
- package/packages/cookie-sanitizer/package.json +1 -1
- package/packages/cookie-sanitizer/src/detect-format.ts +78 -41
- package/packages/cookie-sanitizer/src/index.ts +34 -1
- package/packages/cookie-sanitizer/src/parse-netscape-space.ts +188 -0
- package/packages/cookie-sanitizer/src/parse-netscape.ts +81 -13
- package/packages/cookie-sanitizer/src/source-state.ts +95 -0
- package/packages/cookie-sanitizer/src/sync.ts +59 -16
- package/packages/cookie-sanitizer/src/types.ts +4 -1
- package/packages/evaluation-engine/package.json +1 -1
- package/packages/event-bus/package.json +1 -1
- package/packages/event-store/package.json +1 -1
- package/packages/experience-replay/package.json +1 -1
- package/packages/file-copy-helper/package.json +1 -1
- package/packages/intent-analyzer/package.json +1 -1
- package/packages/jev-judge/package.json +1 -1
- package/packages/knowledge-retrieval/package.json +1 -1
- package/packages/learning-engine/package.json +1 -1
- package/packages/logging/package.json +1 -1
- package/packages/memory-engine/package.json +1 -1
- package/packages/notification/package.json +1 -1
- package/packages/paperclip-integration/package.json +1 -1
- package/packages/performance-optimizer/package.json +1 -1
- package/packages/privilege-broker/package.json +1 -1
- package/packages/prompt-compiler/package.json +1 -1
- package/packages/providers/package.json +1 -1
- package/packages/qdrant-skills/package.json +1 -1
- package/packages/quota-manager/package.json +1 -1
- package/packages/relay/package.json +1 -1
- package/packages/skill-mcp-client/package.json +1 -1
- package/packages/skills/package.json +1 -1
- package/packages/todo-bd-sync/package.json +1 -1
- package/packages/token-estimation/package.json +1 -1
- package/packages/tooling-preference/package.json +1 -1
- package/packages/trajectory/package.json +1 -1
- package/packages/tui/package.json +1 -1
- package/packages/two-phase-review/package.json +1 -1
- package/packages/types/package.json +1 -1
- package/packages/webmcp-tester/package.json +1 -1
- package/packages/wiki/package.json +1 -1
- package/packages/write-review/package.json +1 -1
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The state of the cookie source.
|
|
3
|
+
*
|
|
4
|
+
* Three facts are different and were conflated:
|
|
5
|
+
*
|
|
6
|
+
* - discovery: a file exists in the drop folder.
|
|
7
|
+
* - import: the canonical cache exists, which only happens after a
|
|
8
|
+
* successful validation and normalization of a drop file.
|
|
9
|
+
* - authentication: the provider accepted the credential.
|
|
10
|
+
*
|
|
11
|
+
* The first two are facts about this machine and are cheap to read. The
|
|
12
|
+
* third is a fact about the provider and only a fetch can establish it.
|
|
13
|
+
* This module reports the first two; the runtime reports the third.
|
|
14
|
+
*
|
|
15
|
+
* Nothing here reads a cookie value: the state is a stage and a count.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* How far the cookie source got.
|
|
19
|
+
*
|
|
20
|
+
* - `none`: nothing was found.
|
|
21
|
+
* - `discovered`: a file was found in the drop folder; it was not imported.
|
|
22
|
+
* - `imported`: the canonical cache exists, so an import succeeded.
|
|
23
|
+
*/
|
|
24
|
+
export type CookieSourceStage = "none" | "discovered" | "imported";
|
|
25
|
+
/** The state of the cookie source. */
|
|
26
|
+
export interface CookieSourceState {
|
|
27
|
+
/** The stage the source reached. */
|
|
28
|
+
stage: CookieSourceStage;
|
|
29
|
+
/** The files that the drop folder holds. */
|
|
30
|
+
dropFileCount: number;
|
|
31
|
+
/** Whether the canonical cache exists. */
|
|
32
|
+
cacheExists: boolean;
|
|
33
|
+
/** The canonical cache path, when it is known. */
|
|
34
|
+
cachePath: string | null;
|
|
35
|
+
}
|
|
36
|
+
/** The options of the inspection. */
|
|
37
|
+
export interface InspectCookieSourceOptions {
|
|
38
|
+
/** The drop folder. */
|
|
39
|
+
dropDir: string;
|
|
40
|
+
/** The canonical cache path. */
|
|
41
|
+
cachePath?: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Report the state of the cookie source.
|
|
45
|
+
*
|
|
46
|
+
* Never throws: an unreadable folder is a folder with no files.
|
|
47
|
+
*/
|
|
48
|
+
export declare function inspectCookieSource(options: InspectCookieSourceOptions): CookieSourceState;
|
|
49
|
+
/**
|
|
50
|
+
* Whether a source exists at all.
|
|
51
|
+
*
|
|
52
|
+
* The name says "exists", so it answers the discovery question and never
|
|
53
|
+
* the authentication question.
|
|
54
|
+
*/
|
|
55
|
+
export declare function hasCookieSourceState(state: CookieSourceState): boolean;
|
|
56
|
+
//# sourceMappingURL=source-state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source-state.d.ts","sourceRoot":"","sources":["../src/source-state.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAKH;;;;;;GAMG;AACH,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,YAAY,GAAG,UAAU,CAAC;AAEnE,sCAAsC;AACtC,MAAM,WAAW,iBAAiB;IACjC,oCAAoC;IACpC,KAAK,EAAE,iBAAiB,CAAC;IACzB,4CAA4C;IAC5C,aAAa,EAAE,MAAM,CAAC;IACtB,0CAA0C;IAC1C,WAAW,EAAE,OAAO,CAAC;IACrB,kDAAkD;IAClD,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAED,qCAAqC;AACrC,MAAM,WAAW,0BAA0B;IAC1C,uBAAuB;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,gCAAgC;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAClC,OAAO,EAAE,0BAA0B,GACjC,iBAAiB,CA4BnB;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAEtE"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The state of the cookie source.
|
|
3
|
+
*
|
|
4
|
+
* Three facts are different and were conflated:
|
|
5
|
+
*
|
|
6
|
+
* - discovery: a file exists in the drop folder.
|
|
7
|
+
* - import: the canonical cache exists, which only happens after a
|
|
8
|
+
* successful validation and normalization of a drop file.
|
|
9
|
+
* - authentication: the provider accepted the credential.
|
|
10
|
+
*
|
|
11
|
+
* The first two are facts about this machine and are cheap to read. The
|
|
12
|
+
* third is a fact about the provider and only a fetch can establish it.
|
|
13
|
+
* This module reports the first two; the runtime reports the third.
|
|
14
|
+
*
|
|
15
|
+
* Nothing here reads a cookie value: the state is a stage and a count.
|
|
16
|
+
*/
|
|
17
|
+
import { existsSync } from "node:fs";
|
|
18
|
+
import { enumerateDropFiles } from "./sync.js";
|
|
19
|
+
/**
|
|
20
|
+
* Report the state of the cookie source.
|
|
21
|
+
*
|
|
22
|
+
* Never throws: an unreadable folder is a folder with no files.
|
|
23
|
+
*/
|
|
24
|
+
export function inspectCookieSource(options) {
|
|
25
|
+
const dropDir = options.dropDir;
|
|
26
|
+
const cachePath = options.cachePath ?? null;
|
|
27
|
+
let dropFileCount = 0;
|
|
28
|
+
try {
|
|
29
|
+
dropFileCount = enumerateDropFiles(dropDir).length;
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
dropFileCount = 0;
|
|
33
|
+
}
|
|
34
|
+
let cacheExists = false;
|
|
35
|
+
if (cachePath) {
|
|
36
|
+
try {
|
|
37
|
+
cacheExists = existsSync(cachePath);
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
cacheExists = false;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
let stage = "none";
|
|
44
|
+
if (cacheExists) {
|
|
45
|
+
stage = "imported";
|
|
46
|
+
}
|
|
47
|
+
else if (dropFileCount > 0) {
|
|
48
|
+
stage = "discovered";
|
|
49
|
+
}
|
|
50
|
+
return { stage, dropFileCount, cacheExists, cachePath };
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Whether a source exists at all.
|
|
54
|
+
*
|
|
55
|
+
* The name says "exists", so it answers the discovery question and never
|
|
56
|
+
* the authentication question.
|
|
57
|
+
*/
|
|
58
|
+
export function hasCookieSourceState(state) {
|
|
59
|
+
return state.stage !== "none";
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=source-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source-state.js","sourceRoot":"","sources":["../src/source-state.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AA+B/C;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAClC,OAAmC;IAEnC,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAChC,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,IAAI,CAAC;IAE5C,IAAI,aAAa,GAAG,CAAC,CAAC;IACtB,IAAI,CAAC;QACJ,aAAa,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC;IACpD,CAAC;IAAC,MAAM,CAAC;QACR,aAAa,GAAG,CAAC,CAAC;IACnB,CAAC;IAED,IAAI,WAAW,GAAG,KAAK,CAAC;IACxB,IAAI,SAAS,EAAE,CAAC;QACf,IAAI,CAAC;YACJ,WAAW,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC;QACrC,CAAC;QAAC,MAAM,CAAC;YACR,WAAW,GAAG,KAAK,CAAC;QACrB,CAAC;IACF,CAAC;IAED,IAAI,KAAK,GAAsB,MAAM,CAAC;IACtC,IAAI,WAAW,EAAE,CAAC;QACjB,KAAK,GAAG,UAAU,CAAC;IACpB,CAAC;SAAM,IAAI,aAAa,GAAG,CAAC,EAAE,CAAC;QAC9B,KAAK,GAAG,YAAY,CAAC;IACtB,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,SAAS,EAAE,CAAC;AACzD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAwB;IAC5D,OAAO,KAAK,CAAC,KAAK,KAAK,MAAM,CAAC;AAC/B,CAAC"}
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
* use file basenames and 64-char previews with values redacted.
|
|
16
16
|
*/
|
|
17
17
|
import type { SyncOptions, SyncResult } from "./types.js";
|
|
18
|
+
import { type FormatRejection } from "./detect-format.js";
|
|
18
19
|
/** Default drop-folder location. */
|
|
19
20
|
export declare const DEFAULT_DROP_DIR: string;
|
|
20
21
|
/**
|
|
@@ -33,6 +34,14 @@ export declare function readInputFile(filePath: string): {
|
|
|
33
34
|
text: string;
|
|
34
35
|
reason?: string;
|
|
35
36
|
};
|
|
37
|
+
/**
|
|
38
|
+
* The reason a file was not imported, in words a user can act on.
|
|
39
|
+
*
|
|
40
|
+
* The sentence names the file by its basename and says what to do. It
|
|
41
|
+
* never repeats a line, a header, a cookie name, or a cookie value: the
|
|
42
|
+
* content of a credential file never reaches a log line.
|
|
43
|
+
*/
|
|
44
|
+
export declare function formatRejectionReason(basename: string, reason: FormatRejection | undefined): string;
|
|
36
45
|
/**
|
|
37
46
|
* Run the full sync pipeline.
|
|
38
47
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../src/sync.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAUH,OAAO,KAAK,EAAmB,WAAW,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../src/sync.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAUH,OAAO,KAAK,EAAmB,WAAW,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC3E,OAAO,EAGN,KAAK,eAAe,EACpB,MAAM,oBAAoB,CAAC;AAgB5B,oCAAoC;AACpC,eAAO,MAAM,gBAAgB,QAI5B,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CACjC,GAAG,EAAE,MAAM,EACX,WAAW,CAAC,EAAE,MAAM,GAClB,MAAM,EAAE,CA6CV;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG;IAChD,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB,CAmBA;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACpC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,eAAe,GAAG,SAAS,GACjC,MAAM,CAWR;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,IAAI,CAAC,IAAI,GAAE,WAAgB,GAAG,UAAU,CA8HvD;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CACjC,OAAO,GAAE,MAAyB,GAChC,OAAO,CAET;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAC7B,OAAO,GAAE,MAAyB,GAChC,MAAM,GAAG,IAAI,CAqBf;AAED,OAAO,EACN,aAAa,EACb,yBAAyB,EACzB,wBAAwB,GACxB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,YAAY,EACX,WAAW,EACX,UAAU,EACV,eAAe,EACf,UAAU,EACV,YAAY,EACZ,gBAAgB,EAChB,YAAY,GACZ,MAAM,YAAY,CAAC"}
|
|
@@ -16,8 +16,9 @@
|
|
|
16
16
|
*/
|
|
17
17
|
import { existsSync, mkdirSync, readdirSync, readFileSync, statSync, } from "node:fs";
|
|
18
18
|
import { join } from "node:path";
|
|
19
|
-
import { buildDetectedFile,
|
|
20
|
-
import { parseNetscape, serializeNetscape } from "./parse-netscape.js";
|
|
19
|
+
import { buildDetectedFile, diagnoseFormat, } from "./detect-format.js";
|
|
20
|
+
import { parseNetscape, parseNetscapeDetailed, serializeNetscape, } from "./parse-netscape.js";
|
|
21
|
+
import { parseNetscapeSpace } from "./parse-netscape-space.js";
|
|
21
22
|
import { parseEditThisCookieJson } from "./parse-json.js";
|
|
22
23
|
import { normalize } from "./normalize.js";
|
|
23
24
|
import { inferProvider } from "./infer-provider.js";
|
|
@@ -112,6 +113,25 @@ export function readInputFile(filePath) {
|
|
|
112
113
|
};
|
|
113
114
|
}
|
|
114
115
|
}
|
|
116
|
+
/**
|
|
117
|
+
* The reason a file was not imported, in words a user can act on.
|
|
118
|
+
*
|
|
119
|
+
* The sentence names the file by its basename and says what to do. It
|
|
120
|
+
* never repeats a line, a header, a cookie name, or a cookie value: the
|
|
121
|
+
* content of a credential file never reaches a log line.
|
|
122
|
+
*/
|
|
123
|
+
export function formatRejectionReason(basename, reason) {
|
|
124
|
+
switch (reason) {
|
|
125
|
+
case "space-rows-not-valid":
|
|
126
|
+
return `${basename} found, but its Netscape rows use spaces and did not validate; export Netscape TSV or EditThisCookie JSON`;
|
|
127
|
+
case "no-rows":
|
|
128
|
+
return `${basename} found, but it holds no cookie rows; export Netscape TSV or EditThisCookie JSON`;
|
|
129
|
+
case "tab-rows-not-valid":
|
|
130
|
+
return `${basename} found, but its rows did not validate; export Netscape TSV or EditThisCookie JSON`;
|
|
131
|
+
default:
|
|
132
|
+
return `${basename} found, but its format was not recognized; export Netscape TSV or EditThisCookie JSON`;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
115
135
|
/**
|
|
116
136
|
* Run the full sync pipeline.
|
|
117
137
|
*
|
|
@@ -156,29 +176,40 @@ export function sync(opts = {}) {
|
|
|
156
176
|
}
|
|
157
177
|
const det = buildDetectedFile(filePath, text);
|
|
158
178
|
if (det.format == null) {
|
|
159
|
-
const
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
});
|
|
164
|
-
tmpResult.errors.push({
|
|
165
|
-
basename: det.basename,
|
|
166
|
-
message: "unrecognised format",
|
|
167
|
-
});
|
|
179
|
+
const diagnosis = diagnoseFormat(text);
|
|
180
|
+
const reason = formatRejectionReason(det.basename, diagnosis.reason);
|
|
181
|
+
tmpResult.skippedFiles.push({ basename: det.basename, reason });
|
|
182
|
+
tmpResult.errors.push({ basename: det.basename, message: reason });
|
|
168
183
|
continue;
|
|
169
184
|
}
|
|
170
185
|
let cookies = [];
|
|
186
|
+
let accepted = 0;
|
|
187
|
+
let rejected = 0;
|
|
171
188
|
if (det.format === "netscape") {
|
|
172
|
-
|
|
189
|
+
// A file may hold both kinds of rows. The fallback reads the
|
|
190
|
+
// rows that the tab split rejects with the compatible parser.
|
|
191
|
+
const parsed = parseNetscapeDetailed(text, { compatibleFallback: true });
|
|
192
|
+
cookies = parsed.cookies;
|
|
193
|
+
accepted = parsed.accepted;
|
|
194
|
+
rejected = parsed.rejected;
|
|
195
|
+
}
|
|
196
|
+
else if (det.format === "netscape-space") {
|
|
197
|
+
const parsed = parseNetscapeSpace(text);
|
|
198
|
+
cookies = parsed.cookies;
|
|
199
|
+
accepted = parsed.accepted;
|
|
200
|
+
rejected = parsed.rejected;
|
|
173
201
|
}
|
|
174
202
|
else if (det.format === "edit-this-cookie-json") {
|
|
175
203
|
cookies = parseEditThisCookieJson(text);
|
|
204
|
+
accepted = cookies.length;
|
|
176
205
|
}
|
|
177
206
|
if (cookies.length === 0) {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
})
|
|
207
|
+
const counts = det.format === "edit-this-cookie-json"
|
|
208
|
+
? "0 cookies"
|
|
209
|
+
: `${accepted} rows read, ${rejected} rows rejected`;
|
|
210
|
+
const reason = `${det.basename} parsed as ${det.format} but yielded 0 cookies (${counts})`;
|
|
211
|
+
tmpResult.skippedFiles.push({ basename: det.basename, reason });
|
|
212
|
+
tmpResult.errors.push({ basename: det.basename, message: reason });
|
|
182
213
|
continue;
|
|
183
214
|
}
|
|
184
215
|
allCookies.push(...cookies);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync.js","sourceRoot":"","sources":["../src/sync.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EACN,UAAU,EACV,SAAS,EACT,WAAW,EACX,YAAY,EACZ,QAAQ,GACR,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,
|
|
1
|
+
{"version":3,"file":"sync.js","sourceRoot":"","sources":["../src/sync.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EACN,UAAU,EACV,SAAS,EACT,WAAW,EACX,YAAY,EACZ,QAAQ,GACR,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EACN,iBAAiB,EACjB,cAAc,GAEd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACN,aAAa,EACb,qBAAqB,EACrB,iBAAiB,GACjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAE7E,sEAAsE;AACtE,MAAM,SAAS,GAAG,CAAC,CAAC;AACpB,0DAA0D;AAC1D,MAAM,eAAe,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AACxC,oCAAoC;AACpC,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,CACnC,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,MAAM,EAC1B,qBAAqB,EACrB,SAAS,CACT,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CACjC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AAO,IAAI,CAAC;IAC3B,OAAO,mBAAmB,CAAC,QAAQ,CAAC,CAAC;AACtC,CAAC;AAED,OAAO,EACN,aAAa,EACb,yBAAyB,EACzB,wBAAwB,GACxB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
/** Provider identifier — inferred from filename or dominant cookie domain. */
|
|
13
13
|
export type ProviderId = "minimax" | "anthropic" | "openai" | "glm" | "openrouter" | string;
|
|
14
14
|
/** Input file format. */
|
|
15
|
-
export type CookieFileFormat = "netscape" | "edit-this-cookie-json";
|
|
15
|
+
export type CookieFileFormat = "netscape" | "netscape-space" | "edit-this-cookie-json";
|
|
16
16
|
/** A single cookie in canonical (post-normalize) form. */
|
|
17
17
|
export interface CanonicalCookie {
|
|
18
18
|
/** Provider this cookie belongs to. Set during infer-provider pass. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,8EAA8E;AAC9E,MAAM,MAAM,UAAU,GACnB,SAAS,GACT,WAAW,GACX,QAAQ,GACR,KAAK,GACL,YAAY,GACZ,MAAM,CAAC;AAEV,yBAAyB;AACzB,MAAM,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,8EAA8E;AAC9E,MAAM,MAAM,UAAU,GACnB,SAAS,GACT,WAAW,GACX,QAAQ,GACR,KAAK,GACL,YAAY,GACZ,MAAM,CAAC;AAEV,yBAAyB;AACzB,MAAM,MAAM,gBAAgB,GACzB,UAAU,GACV,gBAAgB,GAChB,uBAAuB,CAAC;AAE3B,0DAA0D;AAC1D,MAAM,WAAW,eAAe;IAC/B,uEAAuE;IACvE,QAAQ,CAAC,EAAE,U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WAAW;IAC3B,iDAAiD;IACjD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,qDAAqD;IACrD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,uDAAuD;IACvD,YAAY,CAAC,EAAE,UAAU,CAAC;IAC1B,0EAA0E;IAC1E,MAAM,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,kDAAkD;AAClD,MAAM,MAAM,YAAY,GACrB;IACA,IAAI,EAAE,SAAS,CAAC;IAChB,QAAQ,EAAE,UAAU,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACf,GACD;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACrC;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GACvC;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC"}
|
|
@@ -1,22 +1,47 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Format detection — does the input look like Netscape
|
|
2
|
+
* Format detection — does the input look like Netscape, a space-separated
|
|
3
|
+
* Netscape export, or EditThisCookie JSON?
|
|
3
4
|
*
|
|
4
5
|
* Detection rule:
|
|
5
|
-
* -
|
|
6
|
-
* -
|
|
7
|
-
*
|
|
8
|
-
* - Otherwise
|
|
6
|
+
* - First non-blank byte is `[` or `{` → JSON
|
|
7
|
+
* - ≥ 1 tab-separated 7-column row → Netscape
|
|
8
|
+
* - ≥ 1 row that the compatible parser accepts → Netscape (space)
|
|
9
|
+
* - Otherwise → unknown
|
|
9
10
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
11
|
+
* The header wording is not part of the rule: an export whose header
|
|
12
|
+
* differs from the canonical wording is still a supported format when its
|
|
13
|
+
* rows are readable.
|
|
14
|
+
*
|
|
15
|
+
* SEC-001: cookie values are never copied into a return value that gets
|
|
16
|
+
* logged. A diagnostic carries counts and reason codes only — never a
|
|
17
|
+
* line, a header, a cookie name, or a cookie value.
|
|
12
18
|
*/
|
|
13
19
|
|
|
14
20
|
import { basename } from "node:path";
|
|
21
|
+
import {
|
|
22
|
+
hasCompatibleRow,
|
|
23
|
+
looksSpaceSeparated,
|
|
24
|
+
} from "./parse-netscape-space.js";
|
|
15
25
|
import type { CookieFileFormat, DetectedFile } from "./types.js";
|
|
16
26
|
|
|
17
27
|
const HEADER_RE = /^# Netscape HTTP Cookie File/im;
|
|
18
28
|
const MIN_TAB_COLS = 7;
|
|
19
29
|
|
|
30
|
+
/** Why a file was not recognized. A reason code, never its content. */
|
|
31
|
+
export type FormatRejection =
|
|
32
|
+
| "empty"
|
|
33
|
+
| "no-rows"
|
|
34
|
+
| "space-rows-not-valid"
|
|
35
|
+
| "tab-rows-not-valid";
|
|
36
|
+
|
|
37
|
+
/** The outcome of a detection. */
|
|
38
|
+
export interface FormatDiagnosis {
|
|
39
|
+
/** The detected format, or null when the file is not supported. */
|
|
40
|
+
format: CookieFileFormat | null;
|
|
41
|
+
/** The reason the file was not recognized. */
|
|
42
|
+
reason?: FormatRejection;
|
|
43
|
+
}
|
|
44
|
+
|
|
20
45
|
/**
|
|
21
46
|
* Returns the basename only, never a path that could leak directory
|
|
22
47
|
* structure. Safe to log.
|
|
@@ -26,47 +51,28 @@ export function safeBasename(filePath: string): string {
|
|
|
26
51
|
}
|
|
27
52
|
|
|
28
53
|
/**
|
|
29
|
-
*
|
|
30
|
-
* Strips cookie values to avoid leaking secrets.
|
|
54
|
+
* Detect the format of cookie file text and say why it failed.
|
|
31
55
|
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
56
|
+
* The reason is a code. A caller that wants to tell the user what to do
|
|
57
|
+
* maps the code to a sentence; the code itself never carries content.
|
|
34
58
|
*/
|
|
35
|
-
export function
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
.map((l) => l.trim())
|
|
40
|
-
.find((l) => l.length > 0) ?? "";
|
|
41
|
-
const redacted = firstLine
|
|
42
|
-
.split("\t")
|
|
43
|
-
.map((col, i) => (i >= 5 ? "<redacted>" : col))
|
|
44
|
-
.join("\t");
|
|
45
|
-
return redacted.length > maxChars
|
|
46
|
-
? `${redacted.slice(0, maxChars)}…`
|
|
47
|
-
: redacted;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Detect the format of cookie file text.
|
|
52
|
-
*/
|
|
53
|
-
export function detectFormat(text: string): CookieFileFormat | null {
|
|
54
|
-
if (typeof text !== "string" || text.length === 0) return null;
|
|
59
|
+
export function diagnoseFormat(text: string): FormatDiagnosis {
|
|
60
|
+
if (typeof text !== "string" || text.length === 0) {
|
|
61
|
+
return { format: null, reason: "empty" };
|
|
62
|
+
}
|
|
55
63
|
|
|
56
64
|
const trimmed = text.trimStart();
|
|
57
65
|
const firstByte = trimmed[0];
|
|
58
66
|
|
|
59
67
|
// JSON heuristic — array or object at the top.
|
|
60
68
|
if (firstByte === "[" || firstByte === "{") {
|
|
61
|
-
return "edit-this-cookie-json";
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// Netscape heuristic — header OR a tab-separated 7-column row.
|
|
65
|
-
if (HEADER_RE.test(text)) {
|
|
66
|
-
return "netscape";
|
|
69
|
+
return { format: "edit-this-cookie-json" };
|
|
67
70
|
}
|
|
68
71
|
|
|
69
72
|
const lines = text.split(/\r?\n/);
|
|
73
|
+
|
|
74
|
+
// A tab-separated row is the strict Netscape format.
|
|
75
|
+
let hasTabRow = false;
|
|
70
76
|
for (const line of lines) {
|
|
71
77
|
if (!line || (line.startsWith("#") && !line.startsWith("#HttpOnly_"))) {
|
|
72
78
|
continue;
|
|
@@ -74,13 +80,44 @@ export function detectFormat(text: string): CookieFileFormat | null {
|
|
|
74
80
|
const trimmedLine = line.startsWith("#HttpOnly_")
|
|
75
81
|
? line.slice("#HttpOnly_".length)
|
|
76
82
|
: line;
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
83
|
+
if (trimmedLine.split("\t").length >= MIN_TAB_COLS) {
|
|
84
|
+
hasTabRow = true;
|
|
85
|
+
break;
|
|
80
86
|
}
|
|
81
87
|
}
|
|
88
|
+
if (hasTabRow) {
|
|
89
|
+
return { format: "netscape" };
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// The header alone is not enough: the rows decide the format.
|
|
93
|
+
if (hasCompatibleRow(text)) {
|
|
94
|
+
return { format: "netscape-space" };
|
|
95
|
+
}
|
|
96
|
+
if (HEADER_RE.test(text)) {
|
|
97
|
+
// The wording of the header matches, but no row could be read.
|
|
98
|
+
// The file claims the format; the parse reports that it holds no
|
|
99
|
+
// cookie.
|
|
100
|
+
return { format: "netscape" };
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (looksSpaceSeparated(text)) {
|
|
104
|
+
return { format: null, reason: "space-rows-not-valid" };
|
|
105
|
+
}
|
|
82
106
|
|
|
83
|
-
|
|
107
|
+
const hasDataLine = lines.some(
|
|
108
|
+
(line) => line.trim().length > 0 && !line.startsWith("#"),
|
|
109
|
+
);
|
|
110
|
+
return {
|
|
111
|
+
format: null,
|
|
112
|
+
reason: hasDataLine ? "tab-rows-not-valid" : "no-rows",
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Detect the format of cookie file text.
|
|
118
|
+
*/
|
|
119
|
+
export function detectFormat(text: string): CookieFileFormat | null {
|
|
120
|
+
return diagnoseFormat(text).format;
|
|
84
121
|
}
|
|
85
122
|
|
|
86
123
|
/**
|
|
@@ -29,20 +29,34 @@
|
|
|
29
29
|
* ```
|
|
30
30
|
*/
|
|
31
31
|
|
|
32
|
+
export {
|
|
33
|
+
inspectCookieSource,
|
|
34
|
+
hasCookieSourceState,
|
|
35
|
+
} from "./source-state.js";
|
|
36
|
+
|
|
32
37
|
export {
|
|
33
38
|
sync,
|
|
34
39
|
hasAnyCookieSource,
|
|
35
40
|
inferCachePath,
|
|
36
41
|
enumerateDropFiles,
|
|
37
42
|
readInputFile,
|
|
43
|
+
formatRejectionReason,
|
|
38
44
|
DEFAULT_DROP_DIR,
|
|
39
45
|
} from "./sync.js";
|
|
40
46
|
|
|
41
47
|
export {
|
|
42
48
|
parseNetscape,
|
|
49
|
+
parseNetscapeDetailed,
|
|
43
50
|
serializeNetscape,
|
|
44
51
|
} from "./parse-netscape.js";
|
|
45
52
|
|
|
53
|
+
export {
|
|
54
|
+
parseNetscapeSpace,
|
|
55
|
+
parseCompatibleRow,
|
|
56
|
+
hasCompatibleRow,
|
|
57
|
+
looksSpaceSeparated,
|
|
58
|
+
} from "./parse-netscape-space.js";
|
|
59
|
+
|
|
46
60
|
export { parseEditThisCookieJson } from "./parse-json.js";
|
|
47
61
|
|
|
48
62
|
export {
|
|
@@ -60,9 +74,9 @@ export {
|
|
|
60
74
|
|
|
61
75
|
export {
|
|
62
76
|
detectFormat,
|
|
77
|
+
diagnoseFormat,
|
|
63
78
|
buildDetectedFile,
|
|
64
79
|
safeBasename,
|
|
65
|
-
safePreview,
|
|
66
80
|
} from "./detect-format.js";
|
|
67
81
|
|
|
68
82
|
export {
|
|
@@ -86,4 +100,23 @@ export type {
|
|
|
86
100
|
WatcherEvent,
|
|
87
101
|
} from "./types.js";
|
|
88
102
|
|
|
103
|
+
export type { FormatDiagnosis, FormatRejection } from "./detect-format.js";
|
|
104
|
+
|
|
105
|
+
export type {
|
|
106
|
+
CookieSourceStage,
|
|
107
|
+
CookieSourceState,
|
|
108
|
+
InspectCookieSourceOptions,
|
|
109
|
+
} from "./source-state.js";
|
|
110
|
+
|
|
111
|
+
export type {
|
|
112
|
+
CompatibleParseResult,
|
|
113
|
+
CompatibleRowOutcome,
|
|
114
|
+
CompatibleRowRejection,
|
|
115
|
+
} from "./parse-netscape-space.js";
|
|
116
|
+
|
|
117
|
+
export type {
|
|
118
|
+
ParseNetscapeOptions,
|
|
119
|
+
ParseNetscapeResult,
|
|
120
|
+
} from "./parse-netscape.js";
|
|
121
|
+
|
|
89
122
|
export type { CookieWatcherConfig } from "./watcher.js";
|