@steipete/oracle 0.4.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/LICENSE +21 -0
- package/README.md +129 -0
- package/assets-oracle-icon.png +0 -0
- package/dist/bin/oracle-cli.js +954 -0
- package/dist/bin/oracle-mcp.js +6 -0
- package/dist/bin/oracle.js +683 -0
- package/dist/markdansi/types/index.js +4 -0
- package/dist/oracle/bin/oracle-cli.js +472 -0
- package/dist/oracle/src/browser/actions/assistantResponse.js +471 -0
- package/dist/oracle/src/browser/actions/attachments.js +82 -0
- package/dist/oracle/src/browser/actions/modelSelection.js +190 -0
- package/dist/oracle/src/browser/actions/navigation.js +75 -0
- package/dist/oracle/src/browser/actions/promptComposer.js +167 -0
- package/dist/oracle/src/browser/chromeLifecycle.js +104 -0
- package/dist/oracle/src/browser/config.js +33 -0
- package/dist/oracle/src/browser/constants.js +40 -0
- package/dist/oracle/src/browser/cookies.js +210 -0
- package/dist/oracle/src/browser/domDebug.js +36 -0
- package/dist/oracle/src/browser/index.js +331 -0
- package/dist/oracle/src/browser/pageActions.js +5 -0
- package/dist/oracle/src/browser/prompt.js +88 -0
- package/dist/oracle/src/browser/promptSummary.js +20 -0
- package/dist/oracle/src/browser/sessionRunner.js +80 -0
- package/dist/oracle/src/browser/types.js +1 -0
- package/dist/oracle/src/browser/utils.js +62 -0
- package/dist/oracle/src/browserMode.js +1 -0
- package/dist/oracle/src/cli/browserConfig.js +44 -0
- package/dist/oracle/src/cli/dryRun.js +59 -0
- package/dist/oracle/src/cli/engine.js +17 -0
- package/dist/oracle/src/cli/errorUtils.js +9 -0
- package/dist/oracle/src/cli/help.js +70 -0
- package/dist/oracle/src/cli/markdownRenderer.js +15 -0
- package/dist/oracle/src/cli/options.js +103 -0
- package/dist/oracle/src/cli/promptRequirement.js +14 -0
- package/dist/oracle/src/cli/rootAlias.js +30 -0
- package/dist/oracle/src/cli/sessionCommand.js +77 -0
- package/dist/oracle/src/cli/sessionDisplay.js +270 -0
- package/dist/oracle/src/cli/sessionRunner.js +94 -0
- package/dist/oracle/src/heartbeat.js +43 -0
- package/dist/oracle/src/oracle/client.js +48 -0
- package/dist/oracle/src/oracle/config.js +29 -0
- package/dist/oracle/src/oracle/errors.js +101 -0
- package/dist/oracle/src/oracle/files.js +220 -0
- package/dist/oracle/src/oracle/format.js +33 -0
- package/dist/oracle/src/oracle/fsAdapter.js +7 -0
- package/dist/oracle/src/oracle/oscProgress.js +60 -0
- package/dist/oracle/src/oracle/request.js +48 -0
- package/dist/oracle/src/oracle/run.js +444 -0
- package/dist/oracle/src/oracle/tokenStats.js +39 -0
- package/dist/oracle/src/oracle/types.js +1 -0
- package/dist/oracle/src/oracle.js +9 -0
- package/dist/oracle/src/sessionManager.js +205 -0
- package/dist/oracle/src/version.js +39 -0
- package/dist/scripts/browser-tools.js +536 -0
- package/dist/scripts/check.js +21 -0
- package/dist/scripts/chrome/browser-tools.js +295 -0
- package/dist/scripts/run-cli.js +14 -0
- package/dist/src/browser/actions/assistantResponse.js +555 -0
- package/dist/src/browser/actions/attachments.js +82 -0
- package/dist/src/browser/actions/modelSelection.js +300 -0
- package/dist/src/browser/actions/navigation.js +175 -0
- package/dist/src/browser/actions/promptComposer.js +167 -0
- package/dist/src/browser/actions/remoteFileTransfer.js +154 -0
- package/dist/src/browser/chromeCookies.js +274 -0
- package/dist/src/browser/chromeLifecycle.js +107 -0
- package/dist/src/browser/config.js +49 -0
- package/dist/src/browser/constants.js +42 -0
- package/dist/src/browser/cookies.js +130 -0
- package/dist/src/browser/domDebug.js +36 -0
- package/dist/src/browser/index.js +541 -0
- package/dist/src/browser/keytarShim.js +56 -0
- package/dist/src/browser/pageActions.js +5 -0
- package/dist/src/browser/policies.js +43 -0
- package/dist/src/browser/prompt.js +82 -0
- package/dist/src/browser/promptSummary.js +20 -0
- package/dist/src/browser/sessionRunner.js +96 -0
- package/dist/src/browser/types.js +1 -0
- package/dist/src/browser/utils.js +112 -0
- package/dist/src/browser/windowsCookies.js +218 -0
- package/dist/src/browserMode.js +1 -0
- package/dist/src/cli/browserConfig.js +193 -0
- package/dist/src/cli/bundleWarnings.js +9 -0
- package/dist/src/cli/clipboard.js +10 -0
- package/dist/src/cli/detach.js +11 -0
- package/dist/src/cli/dryRun.js +103 -0
- package/dist/src/cli/duplicatePromptGuard.js +14 -0
- package/dist/src/cli/engine.js +25 -0
- package/dist/src/cli/errorUtils.js +9 -0
- package/dist/src/cli/format.js +13 -0
- package/dist/src/cli/help.js +77 -0
- package/dist/src/cli/hiddenAliases.js +22 -0
- package/dist/src/cli/markdownBundle.js +17 -0
- package/dist/src/cli/markdownRenderer.js +97 -0
- package/dist/src/cli/notifier.js +300 -0
- package/dist/src/cli/options.js +193 -0
- package/dist/src/cli/oscUtils.js +20 -0
- package/dist/src/cli/promptRequirement.js +17 -0
- package/dist/src/cli/renderFlags.js +9 -0
- package/dist/src/cli/renderOutput.js +26 -0
- package/dist/src/cli/rootAlias.js +30 -0
- package/dist/src/cli/runOptions.js +62 -0
- package/dist/src/cli/sessionCommand.js +111 -0
- package/dist/src/cli/sessionDisplay.js +540 -0
- package/dist/src/cli/sessionRunner.js +419 -0
- package/dist/src/cli/tagline.js +258 -0
- package/dist/src/cli/tui/index.js +520 -0
- package/dist/src/cli/writeOutputPath.js +21 -0
- package/dist/src/config.js +27 -0
- package/dist/src/heartbeat.js +43 -0
- package/dist/src/mcp/server.js +36 -0
- package/dist/src/mcp/tools/consult.js +221 -0
- package/dist/src/mcp/tools/sessionResources.js +75 -0
- package/dist/src/mcp/tools/sessions.js +96 -0
- package/dist/src/mcp/types.js +18 -0
- package/dist/src/mcp/utils.js +27 -0
- package/dist/src/oracle/background.js +134 -0
- package/dist/src/oracle/claude.js +95 -0
- package/dist/src/oracle/client.js +87 -0
- package/dist/src/oracle/config.js +92 -0
- package/dist/src/oracle/errors.js +104 -0
- package/dist/src/oracle/files.js +371 -0
- package/dist/src/oracle/format.js +30 -0
- package/dist/src/oracle/fsAdapter.js +10 -0
- package/dist/src/oracle/gemini.js +185 -0
- package/dist/src/oracle/logging.js +36 -0
- package/dist/src/oracle/markdown.js +46 -0
- package/dist/src/oracle/multiModelRunner.js +164 -0
- package/dist/src/oracle/oscProgress.js +66 -0
- package/dist/src/oracle/promptAssembly.js +13 -0
- package/dist/src/oracle/request.js +49 -0
- package/dist/src/oracle/run.js +492 -0
- package/dist/src/oracle/runUtils.js +27 -0
- package/dist/src/oracle/tokenEstimate.js +37 -0
- package/dist/src/oracle/tokenStats.js +39 -0
- package/dist/src/oracle/tokenStringifier.js +24 -0
- package/dist/src/oracle/types.js +1 -0
- package/dist/src/oracle.js +12 -0
- package/dist/src/remote/client.js +128 -0
- package/dist/src/remote/server.js +294 -0
- package/dist/src/remote/types.js +1 -0
- package/dist/src/sessionManager.js +462 -0
- package/dist/src/sessionStore.js +56 -0
- package/dist/src/version.js +39 -0
- package/dist/vendor/oracle-notifier/OracleNotifier.app/Contents/CodeResources +0 -0
- package/dist/vendor/oracle-notifier/OracleNotifier.app/Contents/Info.plist +20 -0
- package/dist/vendor/oracle-notifier/OracleNotifier.app/Contents/MacOS/OracleNotifier +0 -0
- package/dist/vendor/oracle-notifier/OracleNotifier.app/Contents/Resources/OracleIcon.icns +0 -0
- package/dist/vendor/oracle-notifier/OracleNotifier.app/Contents/_CodeSignature/CodeResources +128 -0
- package/dist/vendor/oracle-notifier/OracleNotifier.swift +45 -0
- package/dist/vendor/oracle-notifier/README.md +24 -0
- package/dist/vendor/oracle-notifier/build-notifier.sh +93 -0
- package/dist/vendor/oracle-notifier/oracle-notifier/OracleNotifier.app/Contents/CodeResources +0 -0
- package/dist/vendor/oracle-notifier/oracle-notifier/OracleNotifier.app/Contents/Info.plist +20 -0
- package/dist/vendor/oracle-notifier/oracle-notifier/OracleNotifier.app/Contents/MacOS/OracleNotifier +0 -0
- package/dist/vendor/oracle-notifier/oracle-notifier/OracleNotifier.app/Contents/Resources/OracleIcon.icns +0 -0
- package/dist/vendor/oracle-notifier/oracle-notifier/OracleNotifier.app/Contents/_CodeSignature/CodeResources +128 -0
- package/dist/vendor/oracle-notifier/oracle-notifier/OracleNotifier.swift +45 -0
- package/dist/vendor/oracle-notifier/oracle-notifier/README.md +24 -0
- package/dist/vendor/oracle-notifier/oracle-notifier/build-notifier.sh +93 -0
- package/package.json +102 -0
- package/vendor/oracle-notifier/OracleNotifier.app/Contents/CodeResources +0 -0
- package/vendor/oracle-notifier/OracleNotifier.app/Contents/Info.plist +20 -0
- package/vendor/oracle-notifier/OracleNotifier.app/Contents/MacOS/OracleNotifier +0 -0
- package/vendor/oracle-notifier/OracleNotifier.app/Contents/Resources/OracleIcon.icns +0 -0
- package/vendor/oracle-notifier/OracleNotifier.app/Contents/_CodeSignature/CodeResources +128 -0
- package/vendor/oracle-notifier/OracleNotifier.swift +45 -0
- package/vendor/oracle-notifier/README.md +24 -0
- package/vendor/oracle-notifier/build-notifier.sh +93 -0
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { COOKIE_URLS } from './constants.js';
|
|
2
|
+
import { loadChromeCookies } from './chromeCookies.js';
|
|
3
|
+
export class ChromeCookieSyncError extends Error {
|
|
4
|
+
}
|
|
5
|
+
export async function syncCookies(Network, url, profile, logger, options = {}) {
|
|
6
|
+
const { allowErrors = false, filterNames, inlineCookies, cookiePath } = options;
|
|
7
|
+
try {
|
|
8
|
+
const cookies = inlineCookies?.length
|
|
9
|
+
? normalizeInlineCookies(inlineCookies, new URL(url).hostname)
|
|
10
|
+
: await readChromeCookies(url, profile, filterNames ?? undefined, cookiePath ?? undefined);
|
|
11
|
+
if (!cookies.length) {
|
|
12
|
+
return 0;
|
|
13
|
+
}
|
|
14
|
+
let applied = 0;
|
|
15
|
+
for (const cookie of cookies) {
|
|
16
|
+
const cookieWithUrl = attachUrl(cookie, url);
|
|
17
|
+
try {
|
|
18
|
+
const result = await Network.setCookie(cookieWithUrl);
|
|
19
|
+
if (result?.success) {
|
|
20
|
+
applied += 1;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
25
|
+
logger(`Failed to set cookie ${cookie.name}: ${message}`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return applied;
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
32
|
+
if (allowErrors) {
|
|
33
|
+
logger(`Cookie sync failed (continuing with override): ${message}`);
|
|
34
|
+
return 0;
|
|
35
|
+
}
|
|
36
|
+
throw error instanceof ChromeCookieSyncError ? error : new ChromeCookieSyncError(message);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
async function readChromeCookies(url, profile, filterNames, cookiePath) {
|
|
40
|
+
const urlsToCheck = Array.from(new Set([stripQuery(url), ...COOKIE_URLS]));
|
|
41
|
+
const merged = new Map();
|
|
42
|
+
const allowlist = normalizeCookieNames(filterNames);
|
|
43
|
+
for (const candidateUrl of urlsToCheck) {
|
|
44
|
+
const cookies = await loadChromeCookies({
|
|
45
|
+
targetUrl: candidateUrl,
|
|
46
|
+
profile: profile ?? undefined,
|
|
47
|
+
explicitCookiePath: cookiePath ?? undefined,
|
|
48
|
+
filterNames: allowlist ?? undefined,
|
|
49
|
+
});
|
|
50
|
+
const fallbackHostname = new URL(candidateUrl).hostname;
|
|
51
|
+
for (const cookie of cookies) {
|
|
52
|
+
const key = `${cookie.domain ?? fallbackHostname}:${cookie.name}`;
|
|
53
|
+
if (!merged.has(key)) {
|
|
54
|
+
merged.set(key, cookie);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return Array.from(merged.values());
|
|
59
|
+
}
|
|
60
|
+
function normalizeInlineCookies(rawCookies, fallbackHost) {
|
|
61
|
+
const merged = new Map();
|
|
62
|
+
for (const cookie of rawCookies) {
|
|
63
|
+
if (!cookie?.name)
|
|
64
|
+
continue;
|
|
65
|
+
const normalized = {
|
|
66
|
+
...cookie,
|
|
67
|
+
name: cookie.name,
|
|
68
|
+
value: cookie.value ?? '',
|
|
69
|
+
domain: cookie.domain ?? fallbackHost,
|
|
70
|
+
path: cookie.path ?? '/',
|
|
71
|
+
expires: normalizeExpiration(cookie.expires),
|
|
72
|
+
secure: cookie.secure ?? true,
|
|
73
|
+
httpOnly: cookie.httpOnly ?? false,
|
|
74
|
+
};
|
|
75
|
+
const key = `${normalized.domain ?? fallbackHost}:${normalized.name}`;
|
|
76
|
+
if (!merged.has(key)) {
|
|
77
|
+
merged.set(key, normalized);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return Array.from(merged.values());
|
|
81
|
+
}
|
|
82
|
+
function normalizeCookieNames(names) {
|
|
83
|
+
if (!names || names.length === 0) {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
return new Set(names.map((name) => name.trim()).filter(Boolean));
|
|
87
|
+
}
|
|
88
|
+
function attachUrl(cookie, fallbackUrl) {
|
|
89
|
+
const cookieWithUrl = { ...cookie };
|
|
90
|
+
if (!cookieWithUrl.url) {
|
|
91
|
+
if (!cookieWithUrl.domain || cookieWithUrl.domain === 'localhost') {
|
|
92
|
+
cookieWithUrl.url = fallbackUrl;
|
|
93
|
+
}
|
|
94
|
+
else if (!cookieWithUrl.domain.startsWith('.')) {
|
|
95
|
+
cookieWithUrl.url = `https://${cookieWithUrl.domain}`;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
// When url is present, let Chrome derive the host from it; keeping domain can trigger CDP sanitization errors.
|
|
99
|
+
if (cookieWithUrl.url) {
|
|
100
|
+
delete cookieWithUrl.domain;
|
|
101
|
+
}
|
|
102
|
+
return cookieWithUrl;
|
|
103
|
+
}
|
|
104
|
+
function stripQuery(url) {
|
|
105
|
+
try {
|
|
106
|
+
const parsed = new URL(url);
|
|
107
|
+
parsed.hash = '';
|
|
108
|
+
parsed.search = '';
|
|
109
|
+
return parsed.toString();
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
return url;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
function normalizeExpiration(expires) {
|
|
116
|
+
if (!expires || Number.isNaN(expires)) {
|
|
117
|
+
return undefined;
|
|
118
|
+
}
|
|
119
|
+
const value = Number(expires);
|
|
120
|
+
if (value <= 0) {
|
|
121
|
+
return undefined;
|
|
122
|
+
}
|
|
123
|
+
if (value > 1_000_000_000_000) {
|
|
124
|
+
return Math.round(value / 1_000_000 - 11644473600);
|
|
125
|
+
}
|
|
126
|
+
if (value > 1_000_000_000) {
|
|
127
|
+
return Math.round(value / 1000);
|
|
128
|
+
}
|
|
129
|
+
return Math.round(value);
|
|
130
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { CONVERSATION_TURN_SELECTOR } from './constants.js';
|
|
2
|
+
export function buildConversationDebugExpression() {
|
|
3
|
+
return `(() => {
|
|
4
|
+
const CONVERSATION_SELECTOR = ${JSON.stringify(CONVERSATION_TURN_SELECTOR)};
|
|
5
|
+
const turns = Array.from(document.querySelectorAll(CONVERSATION_SELECTOR));
|
|
6
|
+
return turns.map((node) => ({
|
|
7
|
+
role: node.getAttribute('data-message-author-role'),
|
|
8
|
+
text: node.innerText?.slice(0, 200),
|
|
9
|
+
testid: node.getAttribute('data-testid'),
|
|
10
|
+
}));
|
|
11
|
+
})()`;
|
|
12
|
+
}
|
|
13
|
+
export async function logConversationSnapshot(Runtime, logger) {
|
|
14
|
+
const expression = buildConversationDebugExpression();
|
|
15
|
+
const { result } = await Runtime.evaluate({ expression, returnByValue: true });
|
|
16
|
+
if (Array.isArray(result.value)) {
|
|
17
|
+
const recent = result.value.slice(-3);
|
|
18
|
+
logger(`Conversation snapshot: ${JSON.stringify(recent)}`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export async function logDomFailure(Runtime, logger, context) {
|
|
22
|
+
if (!logger?.verbose) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
try {
|
|
26
|
+
const entry = `Browser automation failure (${context}); capturing DOM snapshot for debugging...`;
|
|
27
|
+
logger(entry);
|
|
28
|
+
if (logger.sessionLog && logger.sessionLog !== logger) {
|
|
29
|
+
logger.sessionLog(entry);
|
|
30
|
+
}
|
|
31
|
+
await logConversationSnapshot(Runtime, logger);
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
// ignore snapshot failures
|
|
35
|
+
}
|
|
36
|
+
}
|