@openruntime/cli 0.1.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/assets/auth-connector/icon-128.png +0 -0
- package/assets/auth-connector/icon-16.png +0 -0
- package/assets/auth-connector/icon-32.png +0 -0
- package/assets/auth-connector/icon-48.png +0 -0
- package/dist/args.d.ts +9 -0
- package/dist/args.d.ts.map +1 -0
- package/dist/args.js +52 -0
- package/dist/args.js.map +1 -0
- package/dist/auth-connector.d.ts +66 -0
- package/dist/auth-connector.d.ts.map +1 -0
- package/dist/auth-connector.js +1031 -0
- package/dist/auth-connector.js.map +1 -0
- package/dist/bridge-process.d.ts +64 -0
- package/dist/bridge-process.d.ts.map +1 -0
- package/dist/bridge-process.js +228 -0
- package/dist/bridge-process.js.map +1 -0
- package/dist/browser.d.ts +25 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js +180 -0
- package/dist/browser.js.map +1 -0
- package/dist/client.d.ts +21 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +132 -0
- package/dist/client.js.map +1 -0
- package/dist/command-definition.d.ts +19 -0
- package/dist/command-definition.d.ts.map +1 -0
- package/dist/command-definition.js +42 -0
- package/dist/command-definition.js.map +1 -0
- package/dist/command-skill.d.ts +5 -0
- package/dist/command-skill.d.ts.map +1 -0
- package/dist/command-skill.js +25 -0
- package/dist/command-skill.js.map +1 -0
- package/dist/entry.d.ts +2 -0
- package/dist/entry.d.ts.map +1 -0
- package/dist/entry.js +16 -0
- package/dist/entry.js.map +1 -0
- package/dist/extension-api.d.ts +85 -0
- package/dist/extension-api.d.ts.map +1 -0
- package/dist/extension-api.js +313 -0
- package/dist/extension-api.js.map +1 -0
- package/dist/extensions/types.d.ts +3 -0
- package/dist/extensions/types.d.ts.map +1 -0
- package/dist/extensions/types.js +2 -0
- package/dist/extensions/types.js.map +1 -0
- package/dist/external-extensions.d.ts +19 -0
- package/dist/external-extensions.d.ts.map +1 -0
- package/dist/external-extensions.js +168 -0
- package/dist/external-extensions.js.map +1 -0
- package/dist/help.d.ts +17 -0
- package/dist/help.d.ts.map +1 -0
- package/dist/help.js +214 -0
- package/dist/help.js.map +1 -0
- package/dist/index.d.ts +100 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1579 -0
- package/dist/index.js.map +1 -0
- package/dist/next-browser-profile-preload.d.ts +2 -0
- package/dist/next-browser-profile-preload.d.ts.map +1 -0
- package/dist/next-browser-profile-preload.js +391 -0
- package/dist/next-browser-profile-preload.js.map +1 -0
- package/dist/operation-log.d.ts +23 -0
- package/dist/operation-log.d.ts.map +1 -0
- package/dist/operation-log.js +76 -0
- package/dist/operation-log.js.map +1 -0
- package/dist/output.d.ts +42 -0
- package/dist/output.d.ts.map +1 -0
- package/dist/output.js +111 -0
- package/dist/output.js.map +1 -0
- package/dist/profile.d.ts +56 -0
- package/dist/profile.d.ts.map +1 -0
- package/dist/profile.js +414 -0
- package/dist/profile.js.map +1 -0
- package/dist/record.d.ts +17 -0
- package/dist/record.d.ts.map +1 -0
- package/dist/record.js +1494 -0
- package/dist/record.js.map +1 -0
- package/package.json +46 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
3
|
+
import { homedir } from "node:os";
|
|
4
|
+
import { join, resolve } from "node:path";
|
|
5
|
+
import { OPEN_RUNTIME_SESSION_QUERY_PARAM } from "@openruntime/core";
|
|
6
|
+
export function createFileOperationLogStore(cwd = process.cwd(), stateDirectory = createDefaultOperationLogDirectory()) {
|
|
7
|
+
const normalizedCwd = resolve(cwd);
|
|
8
|
+
const key = createOperationLogKey(normalizedCwd);
|
|
9
|
+
const stateFile = join(stateDirectory, `${key}.json`);
|
|
10
|
+
return {
|
|
11
|
+
read: async () => {
|
|
12
|
+
try {
|
|
13
|
+
const parsed = JSON.parse(await readFile(stateFile, "utf8"));
|
|
14
|
+
if (!isCliOperationLogEntry(parsed))
|
|
15
|
+
return undefined;
|
|
16
|
+
return parsed;
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
write: async (entry) => {
|
|
23
|
+
await mkdir(stateDirectory, { recursive: true });
|
|
24
|
+
await writeFile(stateFile, `${JSON.stringify({
|
|
25
|
+
schemaVersion: 1,
|
|
26
|
+
key,
|
|
27
|
+
cwd: normalizedCwd,
|
|
28
|
+
...entry
|
|
29
|
+
}, null, 2)}\n`, "utf8");
|
|
30
|
+
},
|
|
31
|
+
remove: async () => {
|
|
32
|
+
await rm(stateFile, { force: true });
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export function createDefaultOperationLogDirectory() {
|
|
37
|
+
return join(homedir(), ".openruntime", "operations");
|
|
38
|
+
}
|
|
39
|
+
export function createOperationLogKey(cwd) {
|
|
40
|
+
return `open-${createHash("sha256").update(resolve(cwd)).digest("hex").slice(0, 16)}`;
|
|
41
|
+
}
|
|
42
|
+
export function createOperationSessionId(cwd = process.cwd()) {
|
|
43
|
+
return createOperationLogKey(cwd);
|
|
44
|
+
}
|
|
45
|
+
export function normalizeOpenRuntimeUrlForMatch(input) {
|
|
46
|
+
try {
|
|
47
|
+
const url = new URL(input);
|
|
48
|
+
url.searchParams.delete(OPEN_RUNTIME_SESSION_QUERY_PARAM);
|
|
49
|
+
if (isLoopbackHostname(url.hostname)) {
|
|
50
|
+
url.hostname = "localhost";
|
|
51
|
+
}
|
|
52
|
+
return url.toString();
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
return input.endsWith("/") ? input.slice(0, -1) : input;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function isCliOperationLogEntry(value) {
|
|
59
|
+
if (value === null || typeof value !== "object")
|
|
60
|
+
return false;
|
|
61
|
+
const entry = value;
|
|
62
|
+
return entry.schemaVersion === 1 &&
|
|
63
|
+
entry.command === "open" &&
|
|
64
|
+
typeof entry.key === "string" &&
|
|
65
|
+
typeof entry.cwd === "string" &&
|
|
66
|
+
typeof entry.url === "string" &&
|
|
67
|
+
typeof entry.normalizedUrl === "string" &&
|
|
68
|
+
(typeof entry.bridgeUrl === "string" || entry.bridgeUrl === null) &&
|
|
69
|
+
(typeof entry.sessionId === "string" || entry.sessionId === null) &&
|
|
70
|
+
typeof entry.openedAt === "number" &&
|
|
71
|
+
typeof entry.exitCode === "number";
|
|
72
|
+
}
|
|
73
|
+
function isLoopbackHostname(hostname) {
|
|
74
|
+
return hostname === "localhost" || hostname === "127.0.0.1" || hostname === "[::1]";
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=operation-log.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operation-log.js","sourceRoot":"","sources":["../src/operation-log.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,gCAAgC,EAAE,MAAM,mBAAmB,CAAC;AAqBrE,MAAM,UAAU,2BAA2B,CACzC,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,EACnB,cAAc,GAAG,kCAAkC,EAAE;IAErD,MAAM,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IACnC,MAAM,GAAG,GAAG,qBAAqB,CAAC,aAAa,CAAC,CAAC;IACjD,MAAM,SAAS,GAAG,IAAI,CAAC,cAAc,EAAE,GAAG,GAAG,OAAO,CAAC,CAAC;IAEtD,OAAO;QACL,IAAI,EAAE,KAAK,IAAI,EAAE;YACf,IAAI,CAAC;gBACH,MAAM,MAAM,GAA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AC;AAED,SAAS,kBAAkB,CAAC,QAAgB;IAC1C,OAAO,QAAQ,KAAK,WAAW,IAAI,QAAQ,KAAK,WAAW,IAAI,QAAQ,KAAK,OAAO,CAAC;AACtF,CAAC"}
|
package/dist/output.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export type CommandOutputStatus = "ok" | "needs_input" | "error";
|
|
2
|
+
export type CommandErrorKind = "validation" | "needs_input" | "auth" | "browser" | "runtime" | "not_found" | "internal";
|
|
3
|
+
export interface CommandOutputMeta {
|
|
4
|
+
version: 1;
|
|
5
|
+
command: string;
|
|
6
|
+
}
|
|
7
|
+
export interface CommandOutputWriter {
|
|
8
|
+
write(chunk: string): void;
|
|
9
|
+
}
|
|
10
|
+
export interface CommandErrorOptions {
|
|
11
|
+
code: string;
|
|
12
|
+
kind: CommandErrorKind;
|
|
13
|
+
message: string;
|
|
14
|
+
outputCommand?: string;
|
|
15
|
+
retryable?: boolean;
|
|
16
|
+
hint?: string;
|
|
17
|
+
details?: Record<string, unknown>;
|
|
18
|
+
data?: unknown;
|
|
19
|
+
}
|
|
20
|
+
export interface CommandOutput {
|
|
21
|
+
ok<T>(data: T, message?: string): void;
|
|
22
|
+
needsInput(message: string, options: readonly unknown[], data?: unknown): void;
|
|
23
|
+
error(error: unknown): void;
|
|
24
|
+
}
|
|
25
|
+
export declare class CommandError extends Error {
|
|
26
|
+
readonly code: string;
|
|
27
|
+
readonly kind: CommandErrorKind;
|
|
28
|
+
readonly outputCommand?: string;
|
|
29
|
+
readonly retryable: boolean;
|
|
30
|
+
readonly hint?: string;
|
|
31
|
+
readonly details?: Record<string, unknown>;
|
|
32
|
+
readonly data?: unknown;
|
|
33
|
+
constructor(options: CommandErrorOptions);
|
|
34
|
+
}
|
|
35
|
+
export declare function createError(options: CommandErrorOptions): CommandError;
|
|
36
|
+
export declare function isCommandError(error: unknown): error is CommandError;
|
|
37
|
+
export declare function createCommandOutput(stdout: CommandOutputWriter, command: string): CommandOutput;
|
|
38
|
+
export declare function runWithOutputErrorBoundary(output: CommandOutput, run: () => Promise<number>): Promise<number>;
|
|
39
|
+
export declare function writeOkOutput<T>(stdout: CommandOutputWriter, command: string, data: T, message?: string): void;
|
|
40
|
+
export declare function writeNeedsInputOutput(stdout: CommandOutputWriter, command: string, message: string, options: readonly unknown[], data?: unknown): void;
|
|
41
|
+
export declare function writeErrorOutput(stdout: CommandOutputWriter, command: string, error: unknown): void;
|
|
42
|
+
//# sourceMappingURL=output.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../src/output.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,mBAAmB,GAAG,IAAI,GAAG,aAAa,GAAG,OAAO,CAAC;AAEjE,MAAM,MAAM,gBAAgB,GACxB,YAAY,GACZ,aAAa,GACb,MAAM,GACN,SAAS,GACT,SAAS,GACT,WAAW,GACX,UAAU,CAAC;AAEf,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,CAAC,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,mBAAmB;IAClC,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,gBAAgB,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,aAAa;IAC5B,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvC,UAAU,CA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,OAAO,EAAE,EAC3B,IAAI,CAAC,EAAE,OAAO,GACb,IAAI,CAQN;AAED,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,mBAAmB,EAC3B,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,OAAO,GACb,IAAI,CAgBN"}
|
package/dist/output.js
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
export class CommandError extends Error {
|
|
2
|
+
code;
|
|
3
|
+
kind;
|
|
4
|
+
outputCommand;
|
|
5
|
+
retryable;
|
|
6
|
+
hint;
|
|
7
|
+
details;
|
|
8
|
+
data;
|
|
9
|
+
constructor(options) {
|
|
10
|
+
super(options.message);
|
|
11
|
+
this.name = "CommandError";
|
|
12
|
+
this.code = options.code;
|
|
13
|
+
this.kind = options.kind;
|
|
14
|
+
if (options.outputCommand !== undefined) {
|
|
15
|
+
this.outputCommand = options.outputCommand;
|
|
16
|
+
}
|
|
17
|
+
this.retryable = options.retryable ?? false;
|
|
18
|
+
if (options.hint !== undefined) {
|
|
19
|
+
this.hint = options.hint;
|
|
20
|
+
}
|
|
21
|
+
if (options.details !== undefined) {
|
|
22
|
+
this.details = options.details;
|
|
23
|
+
}
|
|
24
|
+
if (options.data !== undefined) {
|
|
25
|
+
this.data = options.data;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export function createError(options) {
|
|
30
|
+
return new CommandError(options);
|
|
31
|
+
}
|
|
32
|
+
export function isCommandError(error) {
|
|
33
|
+
return error instanceof CommandError;
|
|
34
|
+
}
|
|
35
|
+
export function createCommandOutput(stdout, command) {
|
|
36
|
+
return {
|
|
37
|
+
ok: (data, message) => {
|
|
38
|
+
writeOkOutput(stdout, command, data, message);
|
|
39
|
+
},
|
|
40
|
+
needsInput: (message, options, data) => {
|
|
41
|
+
writeNeedsInputOutput(stdout, command, message, options, data);
|
|
42
|
+
},
|
|
43
|
+
error: (error) => {
|
|
44
|
+
writeErrorOutput(stdout, command, error);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
export async function runWithOutputErrorBoundary(output, run) {
|
|
49
|
+
try {
|
|
50
|
+
return await run();
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
output.error(error);
|
|
54
|
+
return 1;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
export function writeOkOutput(stdout, command, data, message) {
|
|
58
|
+
writeOutput(stdout, {
|
|
59
|
+
status: "ok",
|
|
60
|
+
...(message === undefined ? {} : { message }),
|
|
61
|
+
data,
|
|
62
|
+
meta: createMeta(command)
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
export function writeNeedsInputOutput(stdout, command, message, options, data) {
|
|
66
|
+
writeOutput(stdout, {
|
|
67
|
+
status: "needs_input",
|
|
68
|
+
message,
|
|
69
|
+
options,
|
|
70
|
+
...(data === undefined ? {} : { data }),
|
|
71
|
+
meta: createMeta(command)
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
export function writeErrorOutput(stdout, command, error) {
|
|
75
|
+
const normalized = normalizeCommandError(error);
|
|
76
|
+
const outputCommand = normalized.outputCommand ?? command;
|
|
77
|
+
writeOutput(stdout, {
|
|
78
|
+
status: "error",
|
|
79
|
+
message: normalized.message,
|
|
80
|
+
error: {
|
|
81
|
+
code: normalized.code,
|
|
82
|
+
kind: normalized.kind,
|
|
83
|
+
retryable: normalized.retryable,
|
|
84
|
+
...(normalized.hint === undefined ? {} : { hint: normalized.hint }),
|
|
85
|
+
...(normalized.details === undefined ? {} : { details: normalized.details })
|
|
86
|
+
},
|
|
87
|
+
...(normalized.data === undefined ? {} : { data: normalized.data }),
|
|
88
|
+
meta: createMeta(outputCommand)
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
function normalizeCommandError(error) {
|
|
92
|
+
if (isCommandError(error)) {
|
|
93
|
+
return error;
|
|
94
|
+
}
|
|
95
|
+
return createError({
|
|
96
|
+
code: "INTERNAL_ERROR",
|
|
97
|
+
kind: "internal",
|
|
98
|
+
message: error instanceof Error ? error.message : String(error),
|
|
99
|
+
retryable: false
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
function createMeta(command) {
|
|
103
|
+
return {
|
|
104
|
+
version: 1,
|
|
105
|
+
command
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
function writeOutput(stdout, value) {
|
|
109
|
+
stdout.write(`${JSON.stringify(value, null, 2)}\n`);
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=output.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output.js","sourceRoot":"","sources":["../src/output.ts"],"names":[],"mappings":"AAqCA,MAAM,OAAO,YAAa,SAAQ,KAAK;IAC5B,IAAI,CAAS;IACb,IAAI,CAAmB;IACvB,aAAa,CAAU;IACvB,SAAS,CAAU;IACnB,IAAI,CAAU;IACd,OAAO,CAA2B;IAClC,IAAI,CAAW;IAExB,YAAY,OAA4B;QACtC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;QAC3B,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACzB,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACzB,IAAI,OAAO,CAAC,aAAa,KAAK,SAAS,EAAE,CAAC;YACxC,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;QAC7C,CAAC;QACD,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,KAAK,CAAC;QAC5C,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;YAC/B,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QAC3B,CAAC;QACD,IAAI,OAAO,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;YAClC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QACjC,CAAC;QACD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C,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,CAAC;QACnE,IAAI,EAAE,UAAU,CAAC,aAAa,CAAC;KAChC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,qBAAqB,CAAC,KAAc;IAC3C,IAAI,cAAc,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,WAAW,CAAC;QACjB,IAAI,EAAE,gBAAgB;QACtB,IAAI,EAAE,UAAU;QAChB,OAAO,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;QAC/D,SAAS,EAAE,KAAK;KACjB,CAAC,CAAC;AACL,CAAC;AAED,SAAS,UAAU,CAAC,OAAe;IACjC,OAAO;QACL,OAAO,EAAE,CAAC;QACV,OAAO;KACR,CAAC;AACJ,CAAC;AAED,SAAS,WAAW,CAAC,MAA2B,EAAE,KAAc;IAC9D,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;AACtD,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { type BrowserContext } from "playwright";
|
|
2
|
+
export declare const PROFILE_TOKEN_PREFIX = "openruntime-profile:v1";
|
|
3
|
+
export declare const AUTH_STATE_FILE_NAME = ".openruntime-auth-state.json";
|
|
4
|
+
export interface ProfileExportResult {
|
|
5
|
+
kind: "auth";
|
|
6
|
+
path?: string;
|
|
7
|
+
content?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface ProfileImportResult {
|
|
10
|
+
kind: "auth";
|
|
11
|
+
profileDirectory: string;
|
|
12
|
+
}
|
|
13
|
+
export interface ProfileListResult {
|
|
14
|
+
kind: "auth";
|
|
15
|
+
profileDirectory: string;
|
|
16
|
+
authStatePath: string;
|
|
17
|
+
imported: boolean;
|
|
18
|
+
sites: Array<{
|
|
19
|
+
site: string;
|
|
20
|
+
cookies: number;
|
|
21
|
+
origins: string[];
|
|
22
|
+
}>;
|
|
23
|
+
}
|
|
24
|
+
export interface ProfileClearResult {
|
|
25
|
+
kind: "auth";
|
|
26
|
+
profileDirectory: string;
|
|
27
|
+
removed: boolean;
|
|
28
|
+
url?: string;
|
|
29
|
+
removedCookies?: number;
|
|
30
|
+
removedOrigins?: string[];
|
|
31
|
+
}
|
|
32
|
+
export type AuthStateApplier = (profileDirectory: string, storageState: unknown) => Promise<void>;
|
|
33
|
+
export declare function getProfileDirectory(env?: NodeJS.ProcessEnv): string;
|
|
34
|
+
export declare function getAuthStatePath(profileDirectory: string): string;
|
|
35
|
+
export declare function exportAuthStateProfile(options: {
|
|
36
|
+
storageState: unknown;
|
|
37
|
+
outputPath?: string;
|
|
38
|
+
}): Promise<ProfileExportResult>;
|
|
39
|
+
export declare function importProfile(options: {
|
|
40
|
+
input: string;
|
|
41
|
+
profileDirectory: string;
|
|
42
|
+
applyAuthState?: AuthStateApplier;
|
|
43
|
+
}): Promise<ProfileImportResult>;
|
|
44
|
+
export declare function listProfile(options: {
|
|
45
|
+
profileDirectory: string;
|
|
46
|
+
}): Promise<ProfileListResult>;
|
|
47
|
+
export declare function clearProfile(options: {
|
|
48
|
+
profileDirectory: string;
|
|
49
|
+
url?: string;
|
|
50
|
+
}): Promise<ProfileClearResult>;
|
|
51
|
+
export declare function readProfileInput(input: string | undefined): Promise<string>;
|
|
52
|
+
export declare function readProfileInputFile(path: string): Promise<string>;
|
|
53
|
+
export declare function saveAuthState(profileDirectory: string, storageState: unknown): Promise<void>;
|
|
54
|
+
export declare function applyStoredAuthState(context: BrowserContext, profileDirectory: string): Promise<void>;
|
|
55
|
+
export declare function persistAuthStateOnClose(context: BrowserContext, profileDirectory: string): BrowserContext;
|
|
56
|
+
//# sourceMappingURL=profile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|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