sliccy 2.50.2 → 2.50.4
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/dist/node-server/chrome-launch.d.ts +67 -2
- package/dist/node-server/chrome-launch.js +192 -12
- package/dist/ui/assets/{adobe-DUtaWS08.js → adobe-C0PWXmIi.js} +1 -1
- package/dist/ui/assets/{adobe-DyivPKeZ.js → adobe-_sp-pnn7.js} +1 -1
- package/dist/ui/assets/{agent-bridge-CwcUwWSd.js → agent-bridge-CxttC2XA.js} +1 -1
- package/dist/ui/assets/{agent-message-to-chat-CImm2vOT.js → agent-message-to-chat-DOwxbBF0.js} +1 -1
- package/dist/ui/assets/{azure-openai-iR8v3vNp.js → azure-openai-DaxTaT48.js} +1 -1
- package/dist/ui/assets/{azure-openai-CWUoVLgB.js → azure-openai-qrl3BySR.js} +1 -1
- package/dist/ui/assets/{cdp-BqE7lRro.js → cdp-DunzU3Nj.js} +3 -3
- package/dist/ui/assets/cost-command-Co3ze3Qj.js +1 -0
- package/dist/ui/assets/{es-Dn0gWvf2.js → es-DzvKryD6.js} +1 -1
- package/dist/ui/assets/{fs-DR9Kg_gg.js → fs-DKcnn-pO.js} +2 -2
- package/dist/ui/assets/{fs-BHjUDaPI.js → fs-DSc7_3Hn.js} +1 -1
- package/dist/ui/assets/{github-C4yRzqy8.js → github-BK1AOGwq.js} +1 -1
- package/dist/ui/assets/{github-_05uBVE2.js → github-Biy6HWTq.js} +2 -2
- package/dist/ui/assets/{index-BbIDJNZM.js → index-Cn5rmczt.js} +5 -5
- package/dist/ui/assets/{kernel-worker-iLIRf2UW.js → kernel-worker-lpemPe6D.js} +9 -9
- package/dist/ui/assets/{local-llm-DQTKwWew.js → local-llm-C3MV3uOk.js} +1 -1
- package/dist/ui/assets/{local-llm-DDeUXsOw.js → local-llm-Cc7DHJSw.js} +1 -1
- package/dist/ui/assets/{magick-wasm-Bxy887fy.js → magick-wasm-BjiSSRL4.js} +1 -1
- package/dist/ui/assets/{mount-XZ9QStv8.js → mount-BdFGnrc0.js} +2 -2
- package/dist/ui/assets/{mount-BlPJ6Tdt.js → mount-ap9BLELX.js} +1 -1
- package/dist/ui/assets/{nuke-command-DRPb3203.js → nuke-command-CQr_V1Oc.js} +1 -1
- package/dist/ui/assets/{oauth-bootstrap-BcPvzxBK.js → oauth-bootstrap-CeoqKZgH.js} +1 -1
- package/dist/ui/assets/{oauth-service-CfvA2rAX.js → oauth-service-E62JrG_0.js} +1 -1
- package/dist/ui/assets/{offscreen-client-D-QLFw1K.js → offscreen-client-CsIXSBDS.js} +1 -1
- package/dist/ui/assets/{onboarding-orchestrator-C9pDcsCa.js → onboarding-orchestrator-BAPk6v9C.js} +1 -1
- package/dist/ui/assets/{provider-settings-B_lSRZ0U.js → provider-settings-CrrXS-Th.js} +1 -1
- package/dist/ui/assets/{provider-settings-DGXqU1Yt.js → provider-settings-IYxDo-k8.js} +3 -3
- package/dist/ui/assets/{providers-B3LV-JEw.js → providers-CpRzwm88.js} +1 -1
- package/dist/ui/assets/{spawn-CGCJ3d87.js → spawn-D0dgDxNw.js} +1 -1
- package/dist/ui/assets/{upgrade-detection-BWEeiTSq.js → upgrade-detection-CqgNrDUZ.js} +1 -1
- package/dist/ui/index.html +4 -4
- package/dist/ui/packages/webapp/index.html +4 -4
- package/package.json +1 -1
- package/dist/ui/assets/cost-command-DbyN_w4x.js +0 -1
|
@@ -116,6 +116,40 @@ export declare function waitForCdpPortFromStderr(child: ChildProcess, timeoutMs?
|
|
|
116
116
|
* avoid but is not worth crashing over.
|
|
117
117
|
*/
|
|
118
118
|
export declare function clearStaleDevToolsActivePort(userDataDir: string): Promise<void>;
|
|
119
|
+
export interface ProbeCdpAliveOptions {
|
|
120
|
+
/** Per-probe HTTP timeout in milliseconds. Default 500 ms. */
|
|
121
|
+
timeoutMs?: number;
|
|
122
|
+
/**
|
|
123
|
+
* When set, additionally require the returned
|
|
124
|
+
* `webSocketDebuggerUrl`'s pathname to equal this value. Used by the
|
|
125
|
+
* `DevToolsActivePort` poller to bind the probe to the *specific* CDP
|
|
126
|
+
* endpoint Chrome wrote into the file (line 2 of the file) so a port
|
|
127
|
+
* later reused by an unrelated Chrome/CDP instance can't be mistaken
|
|
128
|
+
* for ours.
|
|
129
|
+
*/
|
|
130
|
+
expectedWebSocketPath?: string | null;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Single-shot HTTP probe of Chrome's `/json/version` endpoint. Resolves
|
|
134
|
+
* `true` only when the port answers with a 2xx response whose body is
|
|
135
|
+
* valid JSON with a non-empty `webSocketDebuggerUrl` (the CDP fingerprint
|
|
136
|
+
* — won't false-positive on some other HTTP service squatting on the
|
|
137
|
+
* port). When `expectedWebSocketPath` is supplied, the probe additionally
|
|
138
|
+
* requires the URL's pathname to match, so the launcher can't attach to
|
|
139
|
+
* an unrelated live CDP server that just happens to be on the same port
|
|
140
|
+
* a stale `DevToolsActivePort` file pointed at.
|
|
141
|
+
*
|
|
142
|
+
* Contract: **every** failure mode collapses to `Promise<false>`. Out-
|
|
143
|
+
* of-range ports, synchronous `httpRequest` throws (`ERR_SOCKET_BAD_PORT`,
|
|
144
|
+
* `ERR_INVALID_ARG_TYPE`), connection refused, timeouts, oversized
|
|
145
|
+
* bodies, malformed JSON, missing `webSocketDebuggerUrl`, mismatched
|
|
146
|
+
* websocket paths, errors on the response stream — all return `false`.
|
|
147
|
+
* Callers can retry without exception plumbing.
|
|
148
|
+
*
|
|
149
|
+
* Kept small and stdlib-only (`node:http`) to avoid pulling another
|
|
150
|
+
* fetch implementation into the launcher hot path.
|
|
151
|
+
*/
|
|
152
|
+
export declare function probeCdpAlive(port: number, options?: ProbeCdpAliveOptions): Promise<boolean>;
|
|
119
153
|
/**
|
|
120
154
|
* Poll `<userDataDir>/DevToolsActivePort` for the CDP port. Chrome writes
|
|
121
155
|
* this file as soon as the DevTools listener is up — its first line is
|
|
@@ -123,14 +157,36 @@ export declare function clearStaleDevToolsActivePort(userDataDir: string): Promi
|
|
|
123
157
|
* Chromium itself recommends discovering the chosen port and is far more
|
|
124
158
|
* reliable than scraping stderr.
|
|
125
159
|
*
|
|
126
|
-
*
|
|
160
|
+
* Validation: before resolving, probe `/json/version` on the discovered
|
|
161
|
+
* port and require the response's `webSocketDebuggerUrl` pathname to
|
|
162
|
+
* match the path Chrome wrote into the file's second line. The file is
|
|
163
|
+
* written by Chrome but reused across runs in the same profile
|
|
164
|
+
* directory, and `clearStaleDevToolsActivePort` is a best-effort unlink
|
|
165
|
+
* that races our spawn. If the probe fails (port refused, wrong CDP
|
|
166
|
+
* instance, anything) we treat the file content as stale and keep
|
|
167
|
+
* polling for either an updated file (the freshly-spawned Chrome about
|
|
168
|
+
* to overwrite it) or the eventual timeout. The pathname comparison
|
|
169
|
+
* specifically guards against the port-reuse case where a stale file
|
|
170
|
+
* points at a port that's now serving an *unrelated* Chrome/CDP
|
|
171
|
+
* instance (different `browser/<uuid>` path).
|
|
172
|
+
*
|
|
173
|
+
* Resolves with the parsed port once both the file content and the
|
|
174
|
+
* live CDP probe succeed. Rejects on timeout or process exit, with
|
|
175
|
+
* the timeout message distinguishing "file never appeared" from "file
|
|
176
|
+
* appeared but its port never answered CDP".
|
|
127
177
|
*
|
|
128
178
|
* @param userDataDir absolute path Chrome was launched with via `--user-data-dir=`
|
|
129
179
|
* @param child the Chrome child process (used to bail out on early exit)
|
|
130
180
|
* @param timeoutMs total budget before giving up
|
|
131
181
|
* @param pollMs polling cadence (default 50ms)
|
|
182
|
+
* @param options test seam — inject a custom `verifyPort` to avoid
|
|
183
|
+
* real network probes in unit tests. The verifier
|
|
184
|
+
* receives both the parsed port and the websocket
|
|
185
|
+
* path Chrome wrote on line 2 (or `null` if absent).
|
|
132
186
|
*/
|
|
133
|
-
export declare function waitForCdpPortFromActivePortFile(userDataDir: string, child: ChildProcess, timeoutMs?: number, pollMs?: number
|
|
187
|
+
export declare function waitForCdpPortFromActivePortFile(userDataDir: string, child: ChildProcess, timeoutMs?: number, pollMs?: number, options?: {
|
|
188
|
+
verifyPort?: (port: number, expectedWebSocketPath: string | null) => Promise<boolean>;
|
|
189
|
+
}): Promise<number>;
|
|
134
190
|
/**
|
|
135
191
|
* Race the stderr scraper and the `DevToolsActivePort` poller. Whichever
|
|
136
192
|
* resolves first wins; the loser is silently ignored. This is the
|
|
@@ -140,5 +196,14 @@ export declare function waitForCdpPortFromActivePortFile(userDataDir: string, ch
|
|
|
140
196
|
export declare function waitForCdpPort(child: ChildProcess, options?: {
|
|
141
197
|
userDataDir?: string;
|
|
142
198
|
timeoutMs?: number;
|
|
199
|
+
/**
|
|
200
|
+
* Test seam — forwarded to `waitForCdpPortFromActivePortFile` so unit
|
|
201
|
+
* tests can simulate the "file says port X, but X isn't actually
|
|
202
|
+
* answering CDP" stale-port race without binding a real socket. The
|
|
203
|
+
* verifier receives both the parsed port and the websocket path
|
|
204
|
+
* Chrome wrote on the file's second line (or `null` when the file
|
|
205
|
+
* was read mid-write and only the port is available).
|
|
206
|
+
*/
|
|
207
|
+
verifyPort?: (port: number, expectedWebSocketPath: string | null) => Promise<boolean>;
|
|
143
208
|
}): Promise<number>;
|
|
144
209
|
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { existsSync, readdirSync } from 'fs';
|
|
2
2
|
import { mkdir, readFile, unlink, writeFile } from 'fs/promises';
|
|
3
|
+
import { request as httpRequest } from 'http';
|
|
3
4
|
import { homedir } from 'os';
|
|
4
5
|
import { dirname, join } from 'path';
|
|
5
6
|
/**
|
|
@@ -442,6 +443,120 @@ export async function clearStaleDevToolsActivePort(userDataDir) {
|
|
|
442
443
|
// Intentionally ignored — see docstring.
|
|
443
444
|
}
|
|
444
445
|
}
|
|
446
|
+
/**
|
|
447
|
+
* Single-shot HTTP probe of Chrome's `/json/version` endpoint. Resolves
|
|
448
|
+
* `true` only when the port answers with a 2xx response whose body is
|
|
449
|
+
* valid JSON with a non-empty `webSocketDebuggerUrl` (the CDP fingerprint
|
|
450
|
+
* — won't false-positive on some other HTTP service squatting on the
|
|
451
|
+
* port). When `expectedWebSocketPath` is supplied, the probe additionally
|
|
452
|
+
* requires the URL's pathname to match, so the launcher can't attach to
|
|
453
|
+
* an unrelated live CDP server that just happens to be on the same port
|
|
454
|
+
* a stale `DevToolsActivePort` file pointed at.
|
|
455
|
+
*
|
|
456
|
+
* Contract: **every** failure mode collapses to `Promise<false>`. Out-
|
|
457
|
+
* of-range ports, synchronous `httpRequest` throws (`ERR_SOCKET_BAD_PORT`,
|
|
458
|
+
* `ERR_INVALID_ARG_TYPE`), connection refused, timeouts, oversized
|
|
459
|
+
* bodies, malformed JSON, missing `webSocketDebuggerUrl`, mismatched
|
|
460
|
+
* websocket paths, errors on the response stream — all return `false`.
|
|
461
|
+
* Callers can retry without exception plumbing.
|
|
462
|
+
*
|
|
463
|
+
* Kept small and stdlib-only (`node:http`) to avoid pulling another
|
|
464
|
+
* fetch implementation into the launcher hot path.
|
|
465
|
+
*/
|
|
466
|
+
export function probeCdpAlive(port, options = {}) {
|
|
467
|
+
const timeoutMs = options.timeoutMs ?? 500;
|
|
468
|
+
const expectedWebSocketPath = options.expectedWebSocketPath ?? null;
|
|
469
|
+
return new Promise((resolve) => {
|
|
470
|
+
let resolved = false;
|
|
471
|
+
const settle = (alive) => {
|
|
472
|
+
if (resolved)
|
|
473
|
+
return;
|
|
474
|
+
resolved = true;
|
|
475
|
+
resolve(alive);
|
|
476
|
+
};
|
|
477
|
+
// Range-check before handing the port to `httpRequest`, which throws
|
|
478
|
+
// synchronously (`ERR_SOCKET_BAD_PORT`) for anything outside 0–65535.
|
|
479
|
+
// A stale or corrupt `DevToolsActivePort` can easily contain
|
|
480
|
+
// out-of-range values, and the contract above promises we never
|
|
481
|
+
// reject in that case.
|
|
482
|
+
if (!Number.isInteger(port) || port <= 0 || port > 65_535) {
|
|
483
|
+
settle(false);
|
|
484
|
+
return;
|
|
485
|
+
}
|
|
486
|
+
let req;
|
|
487
|
+
try {
|
|
488
|
+
req = httpRequest({
|
|
489
|
+
host: '127.0.0.1',
|
|
490
|
+
port,
|
|
491
|
+
path: '/json/version',
|
|
492
|
+
method: 'GET',
|
|
493
|
+
timeout: timeoutMs,
|
|
494
|
+
}, (res) => {
|
|
495
|
+
const status = res.statusCode ?? 0;
|
|
496
|
+
if (status < 200 || status >= 300) {
|
|
497
|
+
res.resume();
|
|
498
|
+
settle(false);
|
|
499
|
+
return;
|
|
500
|
+
}
|
|
501
|
+
let body = '';
|
|
502
|
+
res.setEncoding('utf-8');
|
|
503
|
+
res.on('data', (chunk) => {
|
|
504
|
+
body += chunk;
|
|
505
|
+
// Cap the body size — the real /json/version payload is well
|
|
506
|
+
// under 1 KiB, so anything larger is junk from another service.
|
|
507
|
+
if (body.length > 16_384) {
|
|
508
|
+
res.destroy();
|
|
509
|
+
settle(false);
|
|
510
|
+
}
|
|
511
|
+
});
|
|
512
|
+
res.on('end', () => {
|
|
513
|
+
try {
|
|
514
|
+
const parsed = JSON.parse(body);
|
|
515
|
+
if (typeof parsed.webSocketDebuggerUrl !== 'string' ||
|
|
516
|
+
parsed.webSocketDebuggerUrl.length === 0) {
|
|
517
|
+
settle(false);
|
|
518
|
+
return;
|
|
519
|
+
}
|
|
520
|
+
if (expectedWebSocketPath) {
|
|
521
|
+
// Parse the URL to extract its pathname so we compare
|
|
522
|
+
// apples to apples regardless of host/port differences.
|
|
523
|
+
// Any parse failure collapses to false per contract.
|
|
524
|
+
let actualPath;
|
|
525
|
+
try {
|
|
526
|
+
actualPath = new URL(parsed.webSocketDebuggerUrl).pathname;
|
|
527
|
+
}
|
|
528
|
+
catch {
|
|
529
|
+
settle(false);
|
|
530
|
+
return;
|
|
531
|
+
}
|
|
532
|
+
if (actualPath !== expectedWebSocketPath) {
|
|
533
|
+
settle(false);
|
|
534
|
+
return;
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
settle(true);
|
|
538
|
+
}
|
|
539
|
+
catch {
|
|
540
|
+
settle(false);
|
|
541
|
+
}
|
|
542
|
+
});
|
|
543
|
+
res.on('error', () => settle(false));
|
|
544
|
+
});
|
|
545
|
+
}
|
|
546
|
+
catch {
|
|
547
|
+
// `httpRequest` itself can throw synchronously for invalid option
|
|
548
|
+
// shapes (most commonly out-of-range port). Honor the contract.
|
|
549
|
+
settle(false);
|
|
550
|
+
return;
|
|
551
|
+
}
|
|
552
|
+
req.on('error', () => settle(false));
|
|
553
|
+
req.on('timeout', () => {
|
|
554
|
+
req.destroy();
|
|
555
|
+
settle(false);
|
|
556
|
+
});
|
|
557
|
+
req.end();
|
|
558
|
+
});
|
|
559
|
+
}
|
|
445
560
|
/**
|
|
446
561
|
* Poll `<userDataDir>/DevToolsActivePort` for the CDP port. Chrome writes
|
|
447
562
|
* this file as soon as the DevTools listener is up — its first line is
|
|
@@ -449,18 +564,45 @@ export async function clearStaleDevToolsActivePort(userDataDir) {
|
|
|
449
564
|
* Chromium itself recommends discovering the chosen port and is far more
|
|
450
565
|
* reliable than scraping stderr.
|
|
451
566
|
*
|
|
452
|
-
*
|
|
567
|
+
* Validation: before resolving, probe `/json/version` on the discovered
|
|
568
|
+
* port and require the response's `webSocketDebuggerUrl` pathname to
|
|
569
|
+
* match the path Chrome wrote into the file's second line. The file is
|
|
570
|
+
* written by Chrome but reused across runs in the same profile
|
|
571
|
+
* directory, and `clearStaleDevToolsActivePort` is a best-effort unlink
|
|
572
|
+
* that races our spawn. If the probe fails (port refused, wrong CDP
|
|
573
|
+
* instance, anything) we treat the file content as stale and keep
|
|
574
|
+
* polling for either an updated file (the freshly-spawned Chrome about
|
|
575
|
+
* to overwrite it) or the eventual timeout. The pathname comparison
|
|
576
|
+
* specifically guards against the port-reuse case where a stale file
|
|
577
|
+
* points at a port that's now serving an *unrelated* Chrome/CDP
|
|
578
|
+
* instance (different `browser/<uuid>` path).
|
|
579
|
+
*
|
|
580
|
+
* Resolves with the parsed port once both the file content and the
|
|
581
|
+
* live CDP probe succeed. Rejects on timeout or process exit, with
|
|
582
|
+
* the timeout message distinguishing "file never appeared" from "file
|
|
583
|
+
* appeared but its port never answered CDP".
|
|
453
584
|
*
|
|
454
585
|
* @param userDataDir absolute path Chrome was launched with via `--user-data-dir=`
|
|
455
586
|
* @param child the Chrome child process (used to bail out on early exit)
|
|
456
587
|
* @param timeoutMs total budget before giving up
|
|
457
588
|
* @param pollMs polling cadence (default 50ms)
|
|
589
|
+
* @param options test seam — inject a custom `verifyPort` to avoid
|
|
590
|
+
* real network probes in unit tests. The verifier
|
|
591
|
+
* receives both the parsed port and the websocket
|
|
592
|
+
* path Chrome wrote on line 2 (or `null` if absent).
|
|
458
593
|
*/
|
|
459
|
-
export function waitForCdpPortFromActivePortFile(userDataDir, child, timeoutMs = getDefaultCdpLaunchTimeoutMs(), pollMs = 50) {
|
|
594
|
+
export function waitForCdpPortFromActivePortFile(userDataDir, child, timeoutMs = getDefaultCdpLaunchTimeoutMs(), pollMs = 50, options = {}) {
|
|
595
|
+
const verifyPort = options.verifyPort ??
|
|
596
|
+
((port, expectedWebSocketPath) => probeCdpAlive(port, { expectedWebSocketPath }));
|
|
460
597
|
return new Promise((resolve, reject) => {
|
|
461
598
|
let settled = false;
|
|
462
599
|
const path = join(userDataDir, 'DevToolsActivePort');
|
|
463
600
|
const startedAt = Date.now();
|
|
601
|
+
// Track whether we ever observed a parseable candidate port so the
|
|
602
|
+
// timeout error can distinguish "file never showed up" from "file
|
|
603
|
+
// was there but its port never answered CDP".
|
|
604
|
+
let sawCandidate = false;
|
|
605
|
+
let lastCandidatePort = null;
|
|
464
606
|
const finish = (action) => {
|
|
465
607
|
if (settled)
|
|
466
608
|
return;
|
|
@@ -470,18 +612,27 @@ export function waitForCdpPortFromActivePortFile(userDataDir, child, timeoutMs =
|
|
|
470
612
|
const tick = async () => {
|
|
471
613
|
if (settled)
|
|
472
614
|
return;
|
|
615
|
+
let candidatePort = null;
|
|
616
|
+
let candidateWsPath = null;
|
|
473
617
|
try {
|
|
474
618
|
const contents = await readFile(path, 'utf-8');
|
|
475
|
-
// First line is the port; second is the WS path. Chrome writes
|
|
476
|
-
// atomically once the listener is up. If we read it
|
|
477
|
-
// either get an empty file
|
|
478
|
-
//
|
|
479
|
-
|
|
619
|
+
// First line is the port; second is the WS path. Chrome writes
|
|
620
|
+
// both atomically once the listener is up. If we read it
|
|
621
|
+
// mid-write we'll either get an empty file, the port-only first
|
|
622
|
+
// line, or a corrupt body — every parse failure falls through
|
|
623
|
+
// to the next tick.
|
|
624
|
+
const lines = contents.split('\n');
|
|
625
|
+
const firstLine = lines[0]?.trim();
|
|
480
626
|
if (firstLine) {
|
|
481
627
|
const port = Number.parseInt(firstLine, 10);
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
628
|
+
// Match `probeCdpAlive`'s range guard so we never hand it a
|
|
629
|
+
// value it'll reject anyway.
|
|
630
|
+
if (Number.isInteger(port) && port > 0 && port <= 65_535) {
|
|
631
|
+
candidatePort = port;
|
|
632
|
+
const secondLine = lines[1]?.trim();
|
|
633
|
+
if (secondLine && secondLine.startsWith('/')) {
|
|
634
|
+
candidateWsPath = secondLine;
|
|
635
|
+
}
|
|
485
636
|
}
|
|
486
637
|
}
|
|
487
638
|
}
|
|
@@ -491,8 +642,37 @@ export function waitForCdpPortFromActivePortFile(userDataDir, child, timeoutMs =
|
|
|
491
642
|
// racing alongside this poller than reject early.
|
|
492
643
|
void err;
|
|
493
644
|
}
|
|
645
|
+
if (candidatePort !== null) {
|
|
646
|
+
sawCandidate = true;
|
|
647
|
+
lastCandidatePort = candidatePort;
|
|
648
|
+
// Verify the file's port actually answers CDP and reports the
|
|
649
|
+
// same websocket path the file claims. A stale file (e.g. from
|
|
650
|
+
// a previous run that crashed before
|
|
651
|
+
// `clearStaleDevToolsActivePort` could land) or a port that's
|
|
652
|
+
// been reused by an unrelated Chrome will fail this probe and
|
|
653
|
+
// fall through to the next tick. Wrap in try/catch so any
|
|
654
|
+
// unexpected verifier rejection — including a rogue custom
|
|
655
|
+
// verifier in tests — is treated as "not alive" rather than
|
|
656
|
+
// aborting the poll loop and hanging discovery indefinitely.
|
|
657
|
+
let alive = false;
|
|
658
|
+
try {
|
|
659
|
+
alive = await verifyPort(candidatePort, candidateWsPath);
|
|
660
|
+
}
|
|
661
|
+
catch {
|
|
662
|
+
alive = false;
|
|
663
|
+
}
|
|
664
|
+
if (settled)
|
|
665
|
+
return; // child exited mid-probe — `child.on('exit')` already rejected.
|
|
666
|
+
if (alive) {
|
|
667
|
+
finish(() => resolve(candidatePort));
|
|
668
|
+
return;
|
|
669
|
+
}
|
|
670
|
+
}
|
|
494
671
|
if (Date.now() - startedAt >= timeoutMs) {
|
|
495
|
-
|
|
672
|
+
const message = sawCandidate
|
|
673
|
+
? `Port ${lastCandidatePort} from DevToolsActivePort at ${path} never answered CDP (${timeoutMs}ms)`
|
|
674
|
+
: `Timed out waiting for DevToolsActivePort at ${path} (${timeoutMs}ms)`;
|
|
675
|
+
finish(() => reject(new Error(message)));
|
|
496
676
|
return;
|
|
497
677
|
}
|
|
498
678
|
setTimeout(() => {
|
|
@@ -516,7 +696,7 @@ export function waitForCdpPort(child, options = {}) {
|
|
|
516
696
|
const stderrPromise = waitForCdpPortFromStderr(child, timeoutMs);
|
|
517
697
|
if (!options.userDataDir)
|
|
518
698
|
return stderrPromise;
|
|
519
|
-
const filePromise = waitForCdpPortFromActivePortFile(options.userDataDir, child, timeoutMs);
|
|
699
|
+
const filePromise = waitForCdpPortFromActivePortFile(options.userDataDir, child, timeoutMs, undefined, { verifyPort: options.verifyPort });
|
|
520
700
|
// Suppress unhandled-rejection warnings on the loser.
|
|
521
701
|
stderrPromise.catch(() => { });
|
|
522
702
|
filePromise.catch(() => { });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,f as t,t as n}from"./provider-settings-B_lSRZ0U.js";import{d as r,f as i,l as a,p as o,u as s}from"./bedrock-camp-9aDiXDk5.js";import{d as c,o as l,u}from"./transform-messages-uhk4b6os.js";import{getOAuthPageOrigin as d}from"./oauth-service-CfvA2rAX.js";const f=Object.assign({"/packages/webapp/providers/adobe-config.json":{proxyEndpoint:`https://adobe-llm-proxy.paolo-moz.workers.dev`,redirectUri:`https://www.sliccy.ai/auth/callback`,extensionRedirectUri:`https://akjjllgokmbgpbdbmafpiefnhidlmbgf.chromiumapp.org/adobe`}})[`/packages/webapp/providers/adobe-config.json`]??{clientId:``,proxyEndpoint:``,scopes:`openid,profile,email`};function p(){let t=e(`adobe`);if(t)return t.replace(/\/$/,``);if(f.proxyEndpoint)return f.proxyEndpoint.replace(/\/$/,``);throw Error(`Adobe proxy endpoint not configured — set it in Settings or adobe-config.json`)}const m=new Map,h=new Map;async function g(e){let t=m.get(e);if(t)return t;try{let t=await fetch(`${e}/v1/config`,{headers:{[j]:`2.50.2`}});if(t.ok){let n=await t.json();return m.set(e,n),n}console.warn(`[adobe] Proxy /v1/config returned ${t.status}, falling back to build-time config`)}catch(e){console.warn(`[adobe] Failed to fetch proxy config:`,e instanceof Error?e.message:String(e))}let n={};return m.set(e,n),n}function _(e){let t=e.clientId||f.clientId;if(!t)throw Error(`Could not determine IMS client ID — proxy /v1/config did not return one and adobe-config.json is empty`);return t}function v(e){return e.scopes||f.scopes}function y(e){return e.imsEnvironment||f.imsEnvironment||`prod`}const b={prod:`https://ims-na1.adobelogin.com`,stg1:`https://ims-na1-stg1.adobelogin.com`};function x(e){return b[e??f.imsEnvironment??`prod`]??b.prod}const S=typeof chrome<`u`&&!!chrome?.runtime?.id;function C(){return n().find(e=>e.providerId===`adobe`)}async function w(e,t){try{let n=await fetch(`${x(t)}/ims/userinfo/v2`,{headers:{Authorization:`Bearer ${e}`}});if(n.ok){let e=await n.json();return{name:e.displayName||e.name||e.email,avatar:e.picture||e.avatar_url}}console.warn(`[adobe] User profile fetch returned ${n.status}, account will have no display name`)}catch(e){console.warn(`[adobe] Failed to fetch user profile:`,e instanceof Error?e.message:String(e))}return{}}function T(e){let t=e.indexOf(`#`);if(t<0)return null;let n=new URLSearchParams(e.slice(t+1)),r=n.get(`access_token`);return r?{accessToken:r,expiresIn:parseInt(n.get(`expires_in`)??`86400`,10)}:null}const E={id:`adobe`,name:`Adobe`,description:`Claude via Adobe — login with your Adobe ID`,requiresApiKey:!1,requiresBaseUrl:!f.proxyEndpoint,baseUrlPlaceholder:`https://your-proxy.example.com`,baseUrlDescription:`Anthropic-compatible proxy endpoint`,isOAuth:!0,defaultModelId:`sonnet`,oauthTokenDomains:[`ims-na1.adobelogin.com`,`ims-na1-stg1.adobelogin.com`,`*.adobelogin.com`,`*.adobe.io`,`firefall.adobe.io`],getModelIds:()=>{let e=e=>{let t={id:e.id,name:e.name??e.id},n=h.get(e.id);return n?.api&&(t.api=n.api),n?.context_window!==void 0&&(t.context_window=n.context_window),n?.max_tokens!==void 0&&(t.max_tokens=n.max_tokens),n?.reasoning!==void 0&&(t.reasoning=n.reasoning),n?.input&&(t.input=n.input),/haiku/i.test(e.id)&&(t.compat={supportsEagerToolInputStreaming:!1}),t};for(let t of L.values())if(t.length){let n=t.map(t=>e({id:t.id,name:t.name??t.id}));try{localStorage.setItem(`slicc-adobe-models`,JSON.stringify(n))}catch{}return n}for(let t of m.values())if(t.models?.length)return t.models.map(e);try{let e=localStorage.getItem(`slicc-adobe-models`);if(e){let t=JSON.parse(e);if(t.length)return t}}catch{}return[{id:`claude-sonnet-4-6`,name:`Claude Sonnet 4.6`}]},onOAuthLogin:async(e,n)=>{let r=p(),i=await g(r),a=_(i),o=v(i),s=y(i),c=S?null:await d(),l=S?f.extensionRedirectUri??`https://${chrome.runtime.id}.chromiumapp.org/`:f.redirectUri??`${c.origin}/auth/callback`,u=S?void 0:btoa(JSON.stringify({port:parseInt(new URL(c.href).port||`5710`,10),path:`/auth/callback`,nonce:crypto.randomUUID()})),m=u?JSON.parse(atob(u)).nonce:null,h=new URLSearchParams({client_id:a,scope:o,response_type:`token`,redirect_uri:l});u&&h.set(`state`,u);let b=await e(`${x(s)}/ims/authorize/v2?${h}`);if(!b)return;if(m&&b)try{if(new URL(b).searchParams.get(`nonce`)!==m){console.error(`[adobe] OAuth nonce mismatch — possible CSRF`);return}}catch(e){console.warn(`[adobe] Nonce check skipped (URL parse failed):`,e instanceof Error?e.message:String(e))}let C=T(b);if(!C){console.error(`[adobe] Could not extract token from redirect URL`);return}let E=await w(C.accessToken,s);await t({providerId:`adobe`,accessToken:C.accessToken,tokenExpiresAt:Date.now()+C.expiresIn*1e3,userName:E.name,userAvatar:E.avatar,baseUrl:f.proxyEndpoint?void 0:r}),await R().catch(e=>console.warn(`[adobe] Failed to fetch models after login:`,e instanceof Error?e.message:String(e))),n()},onOAuthLogout:async()=>{let e=C();if(e?.accessToken)try{let t=m.values().next().value??{},n=t.clientId||f.clientId,r=y(t);if(n){let t=await fetch(`${x(r)}/ims/revoke`,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:new URLSearchParams({token:e.accessToken,token_type_hint:`access_token`,client_id:n})});t.ok||console.warn(`[adobe] Token revocation returned ${t.status}, token may still be valid server-side`)}}catch(e){console.warn(`[adobe] Failed to revoke token:`,e instanceof Error?e.message:String(e))}await t({providerId:`adobe`,accessToken:``})},onSilentRenew:async()=>C()?.accessToken?A():null};let D=null;async function O(){let e=C();if(!e?.accessToken)throw Error(`Not logged in to Adobe — please log in first`);if((e.tokenExpiresAt??0)-Date.now()>6e4)return e.accessToken;console.log(`[adobe] Token expired or expiring soon, attempting silent renewal...`);try{let e=await A();if(e)return e}catch(e){console.warn(`[adobe] Silent renewal failed:`,e instanceof Error?e.message:String(e))}let t=C();if((t?.tokenExpiresAt??0)-Date.now()>0&&t?.accessToken)return t.accessToken;throw Error(`Adobe session expired — please log in again`)}function k(){let e=C();return e?.tokenExpiresAt?Date.now()>e.tokenExpiresAt-6e4:!0}async function A(){return typeof window>`u`?null:D||(D=(async()=>{try{let e=p(),n=await g(e),r=_(n),i=v(n),a=y(n),o=S?f.extensionRedirectUri??`https://${chrome.runtime.id}.chromiumapp.org/`:f.redirectUri??`${window.location.origin}/auth/callback`,s=S?void 0:btoa(JSON.stringify({port:parseInt(new URL(window.location.href).port||`5710`,10),path:`/auth/callback`,nonce:crypto.randomUUID()})),c=s?JSON.parse(atob(s)).nonce:null,l=new URLSearchParams({client_id:r,scope:i,response_type:`token`,redirect_uri:o,prompt:`none`});s&&l.set(`state`,s);let u=`${x(a)}/ims/authorize/v2?${l}`,{createOAuthLauncher:d}=await import(`./oauth-service-CfvA2rAX.js`),m=await d()(u);if(!m)return null;if(c&&m)try{if(new URL(m).searchParams.get(`nonce`)!==c)return console.error(`[adobe] OAuth nonce mismatch — possible CSRF`),null}catch(e){console.warn(`[adobe] Nonce check skipped (URL parse failed):`,e instanceof Error?e.message:String(e))}let h=T(m);if(!h)return null;let b=C();return await t({providerId:`adobe`,accessToken:h.accessToken,tokenExpiresAt:Date.now()+h.expiresIn*1e3,userName:b?.userName,userAvatar:b?.userAvatar,baseUrl:f.proxyEndpoint?void 0:e}),console.log(`[adobe] Token renewed silently`),await R().catch(e=>console.warn(`[adobe] Failed to refresh models after silent renewal:`,e instanceof Error?e.message:String(e))),h.accessToken}catch(e){return console.warn(`[adobe] Silent renewal error:`,e instanceof Error?e.message:String(e)),null}finally{D=null}})(),D)}const j=`X-Slicc-Version`;function M(e){let t={};if(e.headers)for(let[n,r]of Object.entries(e.headers))n.toLowerCase()!==`x-slicc-version`&&(t[n]=r);return t[j]=`2.50.2`,{...e,headers:t}}function N(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:`adobe-anthropic`,provider:`adobe`,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`error`,errorMessage:t instanceof Error?t.message:String(t),timestamp:Date.now()}}}const P=(e,t,n={})=>{let r=l();return(async()=>{try{let i=await O();if(String(e.api).includes(`openai`)){let a=s({...e,baseUrl:`${p()}/v1`,api:`openai-completions`,compat:{...e.compat,supportsStore:!1,supportsDeveloperRole:!1}},t,M({...n,apiKey:i}));for await(let e of a)r.push(e)}else{let o=a({...e,baseUrl:p(),api:`anthropic-messages`},t,M({...n,apiKey:i}));for await(let e of o)r.push(e)}r.end()}catch(t){console.error(`[adobe] Stream error:`,t instanceof Error?t.message:String(t)),r.push(N(e,t)),r.end()}})(),r},F=(e,t,n)=>{let a=l();return(async()=>{try{let o=await O();if(String(e.api).includes(`openai`)){let r=i({...e,baseUrl:`${p()}/v1`,api:`openai-completions`,compat:{...e.compat,supportsStore:!1,supportsDeveloperRole:!1}},t,M({...n,apiKey:o}));for await(let e of r)a.push(e)}else{let i=r({...e,baseUrl:p(),api:`anthropic-messages`},t,M({...n,apiKey:o}));for await(let e of i)a.push(e)}a.end()}catch(t){console.error(`[adobe] Stream error:`,t instanceof Error?t.message:String(t)),a.push(N(e,t)),a.end()}})(),a};async function I(){try{let e=await O(),t=p(),n=await fetch(`${t}/v1/models`,{headers:{Authorization:`Bearer ${e}`,[j]:`2.50.2`}});if(n.ok){let e=await n.json();if(e.data?.length){for(let t of e.data){let e={id:t.id,name:t.name};t.api!==void 0&&(e.api=t.api),t.context_window!==void 0&&(e.context_window=t.context_window),t.max_tokens!==void 0&&(e.max_tokens=t.max_tokens),t.reasoning!==void 0&&(e.reasoning=t.reasoning),t.input!==void 0&&(e.input=t.input),h.set(t.id,e)}let n=new Map;for(let e of c())try{for(let t of u(e))n.set(t.id,t)}catch{}return e.data.map(e=>{let r=n.get(e.id),i=`adobe-${e.api===`openai`?`openai`:`anthropic`}`;return r?{...r,provider:`adobe`,api:i}:{id:e.id,name:e.name??e.id,provider:`adobe`,api:i,baseUrl:t,contextWindow:2e5,maxTokens:16384,input:[`text`,`image`],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},inputCost:0,outputCost:0,cacheReadCost:0,cacheWriteCost:0,reasoning:!0}})}}else console.warn(`[adobe] Proxy /v1/models returned ${n.status}, falling back to Anthropic models`)}catch(e){console.warn(`[adobe] Failed to fetch proxy models:`,e instanceof Error?e.message:String(e))}return u(`anthropic`).map(e=>({...e,provider:`adobe`,api:`adobe-anthropic`}))}const L=new Map;async function R(){let e=p(),t=L.get(e);if(t)return t;let n=await I();return L.set(e,n),n}function z(){o({api:`adobe-anthropic`,stream:P,streamSimple:F}),o({api:`adobe-openai`,stream:P,streamSimple:F})}export{E as config,R as getAdobeModels,O as getValidAccessToken,k as isTokenExpired,z as register};
|
|
1
|
+
import{a as e,f as t,t as n}from"./provider-settings-CrrXS-Th.js";import{d as r,f as i,l as a,p as o,u as s}from"./bedrock-camp-9aDiXDk5.js";import{d as c,o as l,u}from"./transform-messages-uhk4b6os.js";import{getOAuthPageOrigin as d}from"./oauth-service-E62JrG_0.js";const f=Object.assign({"/packages/webapp/providers/adobe-config.json":{proxyEndpoint:`https://adobe-llm-proxy.paolo-moz.workers.dev`,redirectUri:`https://www.sliccy.ai/auth/callback`,extensionRedirectUri:`https://akjjllgokmbgpbdbmafpiefnhidlmbgf.chromiumapp.org/adobe`}})[`/packages/webapp/providers/adobe-config.json`]??{clientId:``,proxyEndpoint:``,scopes:`openid,profile,email`};function p(){let t=e(`adobe`);if(t)return t.replace(/\/$/,``);if(f.proxyEndpoint)return f.proxyEndpoint.replace(/\/$/,``);throw Error(`Adobe proxy endpoint not configured — set it in Settings or adobe-config.json`)}const m=new Map,h=new Map;async function g(e){let t=m.get(e);if(t)return t;try{let t=await fetch(`${e}/v1/config`,{headers:{[j]:`2.50.4`}});if(t.ok){let n=await t.json();return m.set(e,n),n}console.warn(`[adobe] Proxy /v1/config returned ${t.status}, falling back to build-time config`)}catch(e){console.warn(`[adobe] Failed to fetch proxy config:`,e instanceof Error?e.message:String(e))}let n={};return m.set(e,n),n}function _(e){let t=e.clientId||f.clientId;if(!t)throw Error(`Could not determine IMS client ID — proxy /v1/config did not return one and adobe-config.json is empty`);return t}function v(e){return e.scopes||f.scopes}function y(e){return e.imsEnvironment||f.imsEnvironment||`prod`}const b={prod:`https://ims-na1.adobelogin.com`,stg1:`https://ims-na1-stg1.adobelogin.com`};function x(e){return b[e??f.imsEnvironment??`prod`]??b.prod}const S=typeof chrome<`u`&&!!chrome?.runtime?.id;function C(){return n().find(e=>e.providerId===`adobe`)}async function w(e,t){try{let n=await fetch(`${x(t)}/ims/userinfo/v2`,{headers:{Authorization:`Bearer ${e}`}});if(n.ok){let e=await n.json();return{name:e.displayName||e.name||e.email,avatar:e.picture||e.avatar_url}}console.warn(`[adobe] User profile fetch returned ${n.status}, account will have no display name`)}catch(e){console.warn(`[adobe] Failed to fetch user profile:`,e instanceof Error?e.message:String(e))}return{}}function T(e){let t=e.indexOf(`#`);if(t<0)return null;let n=new URLSearchParams(e.slice(t+1)),r=n.get(`access_token`);return r?{accessToken:r,expiresIn:parseInt(n.get(`expires_in`)??`86400`,10)}:null}const E={id:`adobe`,name:`Adobe`,description:`Claude via Adobe — login with your Adobe ID`,requiresApiKey:!1,requiresBaseUrl:!f.proxyEndpoint,baseUrlPlaceholder:`https://your-proxy.example.com`,baseUrlDescription:`Anthropic-compatible proxy endpoint`,isOAuth:!0,defaultModelId:`sonnet`,oauthTokenDomains:[`ims-na1.adobelogin.com`,`ims-na1-stg1.adobelogin.com`,`*.adobelogin.com`,`*.adobe.io`,`firefall.adobe.io`],getModelIds:()=>{let e=e=>{let t={id:e.id,name:e.name??e.id},n=h.get(e.id);return n?.api&&(t.api=n.api),n?.context_window!==void 0&&(t.context_window=n.context_window),n?.max_tokens!==void 0&&(t.max_tokens=n.max_tokens),n?.reasoning!==void 0&&(t.reasoning=n.reasoning),n?.input&&(t.input=n.input),/haiku/i.test(e.id)&&(t.compat={supportsEagerToolInputStreaming:!1}),t};for(let t of L.values())if(t.length){let n=t.map(t=>e({id:t.id,name:t.name??t.id}));try{localStorage.setItem(`slicc-adobe-models`,JSON.stringify(n))}catch{}return n}for(let t of m.values())if(t.models?.length)return t.models.map(e);try{let e=localStorage.getItem(`slicc-adobe-models`);if(e){let t=JSON.parse(e);if(t.length)return t}}catch{}return[{id:`claude-sonnet-4-6`,name:`Claude Sonnet 4.6`}]},onOAuthLogin:async(e,n)=>{let r=p(),i=await g(r),a=_(i),o=v(i),s=y(i),c=S?null:await d(),l=S?f.extensionRedirectUri??`https://${chrome.runtime.id}.chromiumapp.org/`:f.redirectUri??`${c.origin}/auth/callback`,u=S?void 0:btoa(JSON.stringify({port:parseInt(new URL(c.href).port||`5710`,10),path:`/auth/callback`,nonce:crypto.randomUUID()})),m=u?JSON.parse(atob(u)).nonce:null,h=new URLSearchParams({client_id:a,scope:o,response_type:`token`,redirect_uri:l});u&&h.set(`state`,u);let b=await e(`${x(s)}/ims/authorize/v2?${h}`);if(!b)return;if(m&&b)try{if(new URL(b).searchParams.get(`nonce`)!==m){console.error(`[adobe] OAuth nonce mismatch — possible CSRF`);return}}catch(e){console.warn(`[adobe] Nonce check skipped (URL parse failed):`,e instanceof Error?e.message:String(e))}let C=T(b);if(!C){console.error(`[adobe] Could not extract token from redirect URL`);return}let E=await w(C.accessToken,s);await t({providerId:`adobe`,accessToken:C.accessToken,tokenExpiresAt:Date.now()+C.expiresIn*1e3,userName:E.name,userAvatar:E.avatar,baseUrl:f.proxyEndpoint?void 0:r}),await R().catch(e=>console.warn(`[adobe] Failed to fetch models after login:`,e instanceof Error?e.message:String(e))),n()},onOAuthLogout:async()=>{let e=C();if(e?.accessToken)try{let t=m.values().next().value??{},n=t.clientId||f.clientId,r=y(t);if(n){let t=await fetch(`${x(r)}/ims/revoke`,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:new URLSearchParams({token:e.accessToken,token_type_hint:`access_token`,client_id:n})});t.ok||console.warn(`[adobe] Token revocation returned ${t.status}, token may still be valid server-side`)}}catch(e){console.warn(`[adobe] Failed to revoke token:`,e instanceof Error?e.message:String(e))}await t({providerId:`adobe`,accessToken:``})},onSilentRenew:async()=>C()?.accessToken?A():null};let D=null;async function O(){let e=C();if(!e?.accessToken)throw Error(`Not logged in to Adobe — please log in first`);if((e.tokenExpiresAt??0)-Date.now()>6e4)return e.accessToken;console.log(`[adobe] Token expired or expiring soon, attempting silent renewal...`);try{let e=await A();if(e)return e}catch(e){console.warn(`[adobe] Silent renewal failed:`,e instanceof Error?e.message:String(e))}let t=C();if((t?.tokenExpiresAt??0)-Date.now()>0&&t?.accessToken)return t.accessToken;throw Error(`Adobe session expired — please log in again`)}function k(){let e=C();return e?.tokenExpiresAt?Date.now()>e.tokenExpiresAt-6e4:!0}async function A(){return typeof window>`u`?null:D||(D=(async()=>{try{let e=p(),n=await g(e),r=_(n),i=v(n),a=y(n),o=S?f.extensionRedirectUri??`https://${chrome.runtime.id}.chromiumapp.org/`:f.redirectUri??`${window.location.origin}/auth/callback`,s=S?void 0:btoa(JSON.stringify({port:parseInt(new URL(window.location.href).port||`5710`,10),path:`/auth/callback`,nonce:crypto.randomUUID()})),c=s?JSON.parse(atob(s)).nonce:null,l=new URLSearchParams({client_id:r,scope:i,response_type:`token`,redirect_uri:o,prompt:`none`});s&&l.set(`state`,s);let u=`${x(a)}/ims/authorize/v2?${l}`,{createOAuthLauncher:d}=await import(`./oauth-service-E62JrG_0.js`),m=await d()(u);if(!m)return null;if(c&&m)try{if(new URL(m).searchParams.get(`nonce`)!==c)return console.error(`[adobe] OAuth nonce mismatch — possible CSRF`),null}catch(e){console.warn(`[adobe] Nonce check skipped (URL parse failed):`,e instanceof Error?e.message:String(e))}let h=T(m);if(!h)return null;let b=C();return await t({providerId:`adobe`,accessToken:h.accessToken,tokenExpiresAt:Date.now()+h.expiresIn*1e3,userName:b?.userName,userAvatar:b?.userAvatar,baseUrl:f.proxyEndpoint?void 0:e}),console.log(`[adobe] Token renewed silently`),await R().catch(e=>console.warn(`[adobe] Failed to refresh models after silent renewal:`,e instanceof Error?e.message:String(e))),h.accessToken}catch(e){return console.warn(`[adobe] Silent renewal error:`,e instanceof Error?e.message:String(e)),null}finally{D=null}})(),D)}const j=`X-Slicc-Version`;function M(e){let t={};if(e.headers)for(let[n,r]of Object.entries(e.headers))n.toLowerCase()!==`x-slicc-version`&&(t[n]=r);return t[j]=`2.50.4`,{...e,headers:t}}function N(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:`adobe-anthropic`,provider:`adobe`,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`error`,errorMessage:t instanceof Error?t.message:String(t),timestamp:Date.now()}}}const P=(e,t,n={})=>{let r=l();return(async()=>{try{let i=await O();if(String(e.api).includes(`openai`)){let a=s({...e,baseUrl:`${p()}/v1`,api:`openai-completions`,compat:{...e.compat,supportsStore:!1,supportsDeveloperRole:!1}},t,M({...n,apiKey:i}));for await(let e of a)r.push(e)}else{let o=a({...e,baseUrl:p(),api:`anthropic-messages`},t,M({...n,apiKey:i}));for await(let e of o)r.push(e)}r.end()}catch(t){console.error(`[adobe] Stream error:`,t instanceof Error?t.message:String(t)),r.push(N(e,t)),r.end()}})(),r},F=(e,t,n)=>{let a=l();return(async()=>{try{let o=await O();if(String(e.api).includes(`openai`)){let r=i({...e,baseUrl:`${p()}/v1`,api:`openai-completions`,compat:{...e.compat,supportsStore:!1,supportsDeveloperRole:!1}},t,M({...n,apiKey:o}));for await(let e of r)a.push(e)}else{let i=r({...e,baseUrl:p(),api:`anthropic-messages`},t,M({...n,apiKey:o}));for await(let e of i)a.push(e)}a.end()}catch(t){console.error(`[adobe] Stream error:`,t instanceof Error?t.message:String(t)),a.push(N(e,t)),a.end()}})(),a};async function I(){try{let e=await O(),t=p(),n=await fetch(`${t}/v1/models`,{headers:{Authorization:`Bearer ${e}`,[j]:`2.50.4`}});if(n.ok){let e=await n.json();if(e.data?.length){for(let t of e.data){let e={id:t.id,name:t.name};t.api!==void 0&&(e.api=t.api),t.context_window!==void 0&&(e.context_window=t.context_window),t.max_tokens!==void 0&&(e.max_tokens=t.max_tokens),t.reasoning!==void 0&&(e.reasoning=t.reasoning),t.input!==void 0&&(e.input=t.input),h.set(t.id,e)}let n=new Map;for(let e of c())try{for(let t of u(e))n.set(t.id,t)}catch{}return e.data.map(e=>{let r=n.get(e.id),i=`adobe-${e.api===`openai`?`openai`:`anthropic`}`;return r?{...r,provider:`adobe`,api:i}:{id:e.id,name:e.name??e.id,provider:`adobe`,api:i,baseUrl:t,contextWindow:2e5,maxTokens:16384,input:[`text`,`image`],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},inputCost:0,outputCost:0,cacheReadCost:0,cacheWriteCost:0,reasoning:!0}})}}else console.warn(`[adobe] Proxy /v1/models returned ${n.status}, falling back to Anthropic models`)}catch(e){console.warn(`[adobe] Failed to fetch proxy models:`,e instanceof Error?e.message:String(e))}return u(`anthropic`).map(e=>({...e,provider:`adobe`,api:`adobe-anthropic`}))}const L=new Map;async function R(){let e=p(),t=L.get(e);if(t)return t;let n=await I();return L.set(e,n),n}function z(){o({api:`adobe-anthropic`,stream:P,streamSimple:F}),o({api:`adobe-openai`,stream:P,streamSimple:F})}export{E as config,R as getAdobeModels,O as getValidAccessToken,k as isTokenExpired,z as register};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/oauth-service-B7as8KRE.js","assets/panel-rpc-f0zFUOaZ.js","assets/chunk-jRWAZmH_.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as e,s as t,v as n}from"./provider-settings-DGXqU1Yt.js";import{t as r}from"./preload-helper-ca-nBW7U.js";import{c as i,l as a,o,s,u as c}from"./bedrock-camp-CqXHYC67.js";import{d as l,o as u,u as d}from"./simple-options-imi_RHvn.js";import{getOAuthPageOrigin as f}from"./oauth-service-B7as8KRE.js";var p=Object.assign({"/packages/webapp/providers/adobe-config.json":{proxyEndpoint:`https://adobe-llm-proxy.paolo-moz.workers.dev`,redirectUri:`https://www.sliccy.ai/auth/callback`,extensionRedirectUri:`https://akjjllgokmbgpbdbmafpiefnhidlmbgf.chromiumapp.org/adobe`}})[`/packages/webapp/providers/adobe-config.json`]??{clientId:``,proxyEndpoint:``,scopes:`openid,profile,email`};function m(){let e=t(`adobe`);if(e)return e.replace(/\/$/,``);if(p.proxyEndpoint)return p.proxyEndpoint.replace(/\/$/,``);throw Error(`Adobe proxy endpoint not configured — set it in Settings or adobe-config.json`)}var h=new Map,g=new Map;async function _(e){let t=h.get(e);if(t)return t;try{let t=await fetch(`${e}/v1/config`,{headers:{[M]:`2.50.2`}});if(t.ok){let n=await t.json();return h.set(e,n),n}console.warn(`[adobe] Proxy /v1/config returned ${t.status}, falling back to build-time config`)}catch(e){console.warn(`[adobe] Failed to fetch proxy config:`,e instanceof Error?e.message:String(e))}let n={};return h.set(e,n),n}function v(e){let t=e.clientId||p.clientId;if(!t)throw Error(`Could not determine IMS client ID — proxy /v1/config did not return one and adobe-config.json is empty`);return t}function y(e){return e.scopes||p.scopes}function b(e){return e.imsEnvironment||p.imsEnvironment||`prod`}var x={prod:`https://ims-na1.adobelogin.com`,stg1:`https://ims-na1-stg1.adobelogin.com`};function S(e){return x[e??p.imsEnvironment??`prod`]??x.prod}var C=typeof chrome<`u`&&!!chrome?.runtime?.id;function w(){return e().find(e=>e.providerId===`adobe`)}async function T(e,t){try{let n=await fetch(`${S(t)}/ims/userinfo/v2`,{headers:{Authorization:`Bearer ${e}`}});if(n.ok){let e=await n.json();return{name:e.displayName||e.name||e.email,avatar:e.picture||e.avatar_url}}console.warn(`[adobe] User profile fetch returned ${n.status}, account will have no display name`)}catch(e){console.warn(`[adobe] Failed to fetch user profile:`,e instanceof Error?e.message:String(e))}return{}}function E(e){let t=e.indexOf(`#`);if(t<0)return null;let n=new URLSearchParams(e.slice(t+1)),r=n.get(`access_token`);return r?{accessToken:r,expiresIn:parseInt(n.get(`expires_in`)??`86400`,10)}:null}var D={id:`adobe`,name:`Adobe`,description:`Claude via Adobe — login with your Adobe ID`,requiresApiKey:!1,requiresBaseUrl:!p.proxyEndpoint,baseUrlPlaceholder:`https://your-proxy.example.com`,baseUrlDescription:`Anthropic-compatible proxy endpoint`,isOAuth:!0,defaultModelId:`sonnet`,oauthTokenDomains:[`ims-na1.adobelogin.com`,`ims-na1-stg1.adobelogin.com`,`*.adobelogin.com`,`*.adobe.io`,`firefall.adobe.io`],getModelIds:()=>{let e=e=>{let t={id:e.id,name:e.name??e.id},n=g.get(e.id);return n?.api&&(t.api=n.api),n?.context_window!==void 0&&(t.context_window=n.context_window),n?.max_tokens!==void 0&&(t.max_tokens=n.max_tokens),n?.reasoning!==void 0&&(t.reasoning=n.reasoning),n?.input&&(t.input=n.input),/haiku/i.test(e.id)&&(t.compat={supportsEagerToolInputStreaming:!1}),t};for(let t of R.values())if(t.length){let n=t.map(t=>e({id:t.id,name:t.name??t.id}));try{localStorage.setItem(`slicc-adobe-models`,JSON.stringify(n))}catch{}return n}for(let t of h.values())if(t.models?.length)return t.models.map(e);try{let e=localStorage.getItem(`slicc-adobe-models`);if(e){let t=JSON.parse(e);if(t.length)return t}}catch{}return[{id:`claude-sonnet-4-6`,name:`Claude Sonnet 4.6`}]},onOAuthLogin:async(e,t)=>{let r=m(),i=await _(r),a=v(i),o=y(i),s=b(i),c=C?null:await f(),l=C?p.extensionRedirectUri??`https://${chrome.runtime.id}.chromiumapp.org/`:p.redirectUri??`${c.origin}/auth/callback`,u=C?void 0:btoa(JSON.stringify({port:parseInt(new URL(c.href).port||`5710`,10),path:`/auth/callback`,nonce:crypto.randomUUID()})),d=u?JSON.parse(atob(u)).nonce:null,h=new URLSearchParams({client_id:a,scope:o,response_type:`token`,redirect_uri:l});u&&h.set(`state`,u);let g=await e(`${S(s)}/ims/authorize/v2?${h}`);if(!g)return;if(d&&g)try{if(new URL(g).searchParams.get(`nonce`)!==d){console.error(`[adobe] OAuth nonce mismatch — possible CSRF`);return}}catch(e){console.warn(`[adobe] Nonce check skipped (URL parse failed):`,e instanceof Error?e.message:String(e))}let x=E(g);if(!x){console.error(`[adobe] Could not extract token from redirect URL`);return}let w=await T(x.accessToken,s);await n({providerId:`adobe`,accessToken:x.accessToken,tokenExpiresAt:Date.now()+x.expiresIn*1e3,userName:w.name,userAvatar:w.avatar,baseUrl:p.proxyEndpoint?void 0:r}),await z().catch(e=>console.warn(`[adobe] Failed to fetch models after login:`,e instanceof Error?e.message:String(e))),t()},onOAuthLogout:async()=>{let e=w();if(e?.accessToken)try{let t=h.values().next().value??{},n=t.clientId||p.clientId,r=b(t);if(n){let t=await fetch(`${S(r)}/ims/revoke`,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:new URLSearchParams({token:e.accessToken,token_type_hint:`access_token`,client_id:n})});t.ok||console.warn(`[adobe] Token revocation returned ${t.status}, token may still be valid server-side`)}}catch(e){console.warn(`[adobe] Failed to revoke token:`,e instanceof Error?e.message:String(e))}await n({providerId:`adobe`,accessToken:``})},onSilentRenew:async()=>w()?.accessToken?j():null},O=null;async function k(){let e=w();if(!e?.accessToken)throw Error(`Not logged in to Adobe — please log in first`);if((e.tokenExpiresAt??0)-Date.now()>6e4)return e.accessToken;console.log(`[adobe] Token expired or expiring soon, attempting silent renewal...`);try{let e=await j();if(e)return e}catch(e){console.warn(`[adobe] Silent renewal failed:`,e instanceof Error?e.message:String(e))}let t=w();if((t?.tokenExpiresAt??0)-Date.now()>0&&t?.accessToken)return t.accessToken;throw Error(`Adobe session expired — please log in again`)}function A(){let e=w();return e?.tokenExpiresAt?Date.now()>e.tokenExpiresAt-6e4:!0}async function j(){return typeof window>`u`?null:O||(O=(async()=>{try{let e=m(),t=await _(e),i=v(t),a=y(t),o=b(t),s=C?p.extensionRedirectUri??`https://${chrome.runtime.id}.chromiumapp.org/`:p.redirectUri??`${window.location.origin}/auth/callback`,c=C?void 0:btoa(JSON.stringify({port:parseInt(new URL(window.location.href).port||`5710`,10),path:`/auth/callback`,nonce:crypto.randomUUID()})),l=c?JSON.parse(atob(c)).nonce:null,u=new URLSearchParams({client_id:i,scope:a,response_type:`token`,redirect_uri:s,prompt:`none`});c&&u.set(`state`,c);let d=`${S(o)}/ims/authorize/v2?${u}`,{createOAuthLauncher:f}=await r(async()=>{let{createOAuthLauncher:e}=await import(`./oauth-service-B7as8KRE.js`);return{createOAuthLauncher:e}},__vite__mapDeps([0,1,2])),h=await f()(d);if(!h)return null;if(l&&h)try{if(new URL(h).searchParams.get(`nonce`)!==l)return console.error(`[adobe] OAuth nonce mismatch — possible CSRF`),null}catch(e){console.warn(`[adobe] Nonce check skipped (URL parse failed):`,e instanceof Error?e.message:String(e))}let g=E(h);if(!g)return null;let x=w();return await n({providerId:`adobe`,accessToken:g.accessToken,tokenExpiresAt:Date.now()+g.expiresIn*1e3,userName:x?.userName,userAvatar:x?.userAvatar,baseUrl:p.proxyEndpoint?void 0:e}),console.log(`[adobe] Token renewed silently`),await z().catch(e=>console.warn(`[adobe] Failed to refresh models after silent renewal:`,e instanceof Error?e.message:String(e))),g.accessToken}catch(e){return console.warn(`[adobe] Silent renewal error:`,e instanceof Error?e.message:String(e)),null}finally{O=null}})(),O)}var M=`X-Slicc-Version`;function N(e){let t={},n=M.toLowerCase();if(e.headers)for(let[r,i]of Object.entries(e.headers))r.toLowerCase()!==n&&(t[r]=i);return t[M]=`2.50.2`,{...e,headers:t}}function P(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:`adobe-anthropic`,provider:`adobe`,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`error`,errorMessage:t instanceof Error?t.message:String(t),timestamp:Date.now()}}}var F=(e,t,n={})=>{let r=u();return(async()=>{try{let i=await k();if(String(e.api).includes(`openai`)){let a=s({...e,baseUrl:`${m()}/v1`,api:`openai-completions`,compat:{...e.compat,supportsStore:!1,supportsDeveloperRole:!1}},t,N({...n,apiKey:i}));for await(let e of a)r.push(e)}else{let a=o({...e,baseUrl:m(),api:`anthropic-messages`},t,N({...n,apiKey:i}));for await(let e of a)r.push(e)}r.end()}catch(t){console.error(`[adobe] Stream error:`,t instanceof Error?t.message:String(t)),r.push(P(e,t)),r.end()}})(),r},I=(e,t,n)=>{let r=u();return(async()=>{try{let o=await k();if(String(e.api).includes(`openai`)){let i=a({...e,baseUrl:`${m()}/v1`,api:`openai-completions`,compat:{...e.compat,supportsStore:!1,supportsDeveloperRole:!1}},t,N({...n,apiKey:o}));for await(let e of i)r.push(e)}else{let a=i({...e,baseUrl:m(),api:`anthropic-messages`},t,N({...n,apiKey:o}));for await(let e of a)r.push(e)}r.end()}catch(t){console.error(`[adobe] Stream error:`,t instanceof Error?t.message:String(t)),r.push(P(e,t)),r.end()}})(),r};async function L(){try{let e=await k(),t=m(),n=await fetch(`${t}/v1/models`,{headers:{Authorization:`Bearer ${e}`,[M]:`2.50.2`}});if(n.ok){let e=await n.json();if(e.data?.length){for(let t of e.data){let e={id:t.id,name:t.name};t.api!==void 0&&(e.api=t.api),t.context_window!==void 0&&(e.context_window=t.context_window),t.max_tokens!==void 0&&(e.max_tokens=t.max_tokens),t.reasoning!==void 0&&(e.reasoning=t.reasoning),t.input!==void 0&&(e.input=t.input),g.set(t.id,e)}let n=new Map;for(let e of l())try{for(let t of d(e))n.set(t.id,t)}catch{}return e.data.map(e=>{let r=n.get(e.id),i=`adobe-${e.api===`openai`?`openai`:`anthropic`}`;return r?{...r,provider:`adobe`,api:i}:{id:e.id,name:e.name??e.id,provider:`adobe`,api:i,baseUrl:t,contextWindow:2e5,maxTokens:16384,input:[`text`,`image`],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},inputCost:0,outputCost:0,cacheReadCost:0,cacheWriteCost:0,reasoning:!0}})}}else console.warn(`[adobe] Proxy /v1/models returned ${n.status}, falling back to Anthropic models`)}catch(e){console.warn(`[adobe] Failed to fetch proxy models:`,e instanceof Error?e.message:String(e))}return d(`anthropic`).map(e=>({...e,provider:`adobe`,api:`adobe-anthropic`}))}var R=new Map;async function z(){let e=m(),t=R.get(e);if(t)return t;let n=await L();return R.set(e,n),n}function B(){c({api:`adobe-anthropic`,stream:F,streamSimple:I}),c({api:`adobe-openai`,stream:F,streamSimple:I})}export{D as config,z as getAdobeModels,k as getValidAccessToken,A as isTokenExpired,B as register};
|
|
2
|
+
import{r as e,s as t,v as n}from"./provider-settings-IYxDo-k8.js";import{t as r}from"./preload-helper-ca-nBW7U.js";import{c as i,l as a,o,s,u as c}from"./bedrock-camp-CqXHYC67.js";import{d as l,o as u,u as d}from"./simple-options-imi_RHvn.js";import{getOAuthPageOrigin as f}from"./oauth-service-B7as8KRE.js";var p=Object.assign({"/packages/webapp/providers/adobe-config.json":{proxyEndpoint:`https://adobe-llm-proxy.paolo-moz.workers.dev`,redirectUri:`https://www.sliccy.ai/auth/callback`,extensionRedirectUri:`https://akjjllgokmbgpbdbmafpiefnhidlmbgf.chromiumapp.org/adobe`}})[`/packages/webapp/providers/adobe-config.json`]??{clientId:``,proxyEndpoint:``,scopes:`openid,profile,email`};function m(){let e=t(`adobe`);if(e)return e.replace(/\/$/,``);if(p.proxyEndpoint)return p.proxyEndpoint.replace(/\/$/,``);throw Error(`Adobe proxy endpoint not configured — set it in Settings or adobe-config.json`)}var h=new Map,g=new Map;async function _(e){let t=h.get(e);if(t)return t;try{let t=await fetch(`${e}/v1/config`,{headers:{[M]:`2.50.4`}});if(t.ok){let n=await t.json();return h.set(e,n),n}console.warn(`[adobe] Proxy /v1/config returned ${t.status}, falling back to build-time config`)}catch(e){console.warn(`[adobe] Failed to fetch proxy config:`,e instanceof Error?e.message:String(e))}let n={};return h.set(e,n),n}function v(e){let t=e.clientId||p.clientId;if(!t)throw Error(`Could not determine IMS client ID — proxy /v1/config did not return one and adobe-config.json is empty`);return t}function y(e){return e.scopes||p.scopes}function b(e){return e.imsEnvironment||p.imsEnvironment||`prod`}var x={prod:`https://ims-na1.adobelogin.com`,stg1:`https://ims-na1-stg1.adobelogin.com`};function S(e){return x[e??p.imsEnvironment??`prod`]??x.prod}var C=typeof chrome<`u`&&!!chrome?.runtime?.id;function w(){return e().find(e=>e.providerId===`adobe`)}async function T(e,t){try{let n=await fetch(`${S(t)}/ims/userinfo/v2`,{headers:{Authorization:`Bearer ${e}`}});if(n.ok){let e=await n.json();return{name:e.displayName||e.name||e.email,avatar:e.picture||e.avatar_url}}console.warn(`[adobe] User profile fetch returned ${n.status}, account will have no display name`)}catch(e){console.warn(`[adobe] Failed to fetch user profile:`,e instanceof Error?e.message:String(e))}return{}}function E(e){let t=e.indexOf(`#`);if(t<0)return null;let n=new URLSearchParams(e.slice(t+1)),r=n.get(`access_token`);return r?{accessToken:r,expiresIn:parseInt(n.get(`expires_in`)??`86400`,10)}:null}var D={id:`adobe`,name:`Adobe`,description:`Claude via Adobe — login with your Adobe ID`,requiresApiKey:!1,requiresBaseUrl:!p.proxyEndpoint,baseUrlPlaceholder:`https://your-proxy.example.com`,baseUrlDescription:`Anthropic-compatible proxy endpoint`,isOAuth:!0,defaultModelId:`sonnet`,oauthTokenDomains:[`ims-na1.adobelogin.com`,`ims-na1-stg1.adobelogin.com`,`*.adobelogin.com`,`*.adobe.io`,`firefall.adobe.io`],getModelIds:()=>{let e=e=>{let t={id:e.id,name:e.name??e.id},n=g.get(e.id);return n?.api&&(t.api=n.api),n?.context_window!==void 0&&(t.context_window=n.context_window),n?.max_tokens!==void 0&&(t.max_tokens=n.max_tokens),n?.reasoning!==void 0&&(t.reasoning=n.reasoning),n?.input&&(t.input=n.input),/haiku/i.test(e.id)&&(t.compat={supportsEagerToolInputStreaming:!1}),t};for(let t of R.values())if(t.length){let n=t.map(t=>e({id:t.id,name:t.name??t.id}));try{localStorage.setItem(`slicc-adobe-models`,JSON.stringify(n))}catch{}return n}for(let t of h.values())if(t.models?.length)return t.models.map(e);try{let e=localStorage.getItem(`slicc-adobe-models`);if(e){let t=JSON.parse(e);if(t.length)return t}}catch{}return[{id:`claude-sonnet-4-6`,name:`Claude Sonnet 4.6`}]},onOAuthLogin:async(e,t)=>{let r=m(),i=await _(r),a=v(i),o=y(i),s=b(i),c=C?null:await f(),l=C?p.extensionRedirectUri??`https://${chrome.runtime.id}.chromiumapp.org/`:p.redirectUri??`${c.origin}/auth/callback`,u=C?void 0:btoa(JSON.stringify({port:parseInt(new URL(c.href).port||`5710`,10),path:`/auth/callback`,nonce:crypto.randomUUID()})),d=u?JSON.parse(atob(u)).nonce:null,h=new URLSearchParams({client_id:a,scope:o,response_type:`token`,redirect_uri:l});u&&h.set(`state`,u);let g=await e(`${S(s)}/ims/authorize/v2?${h}`);if(!g)return;if(d&&g)try{if(new URL(g).searchParams.get(`nonce`)!==d){console.error(`[adobe] OAuth nonce mismatch — possible CSRF`);return}}catch(e){console.warn(`[adobe] Nonce check skipped (URL parse failed):`,e instanceof Error?e.message:String(e))}let x=E(g);if(!x){console.error(`[adobe] Could not extract token from redirect URL`);return}let w=await T(x.accessToken,s);await n({providerId:`adobe`,accessToken:x.accessToken,tokenExpiresAt:Date.now()+x.expiresIn*1e3,userName:w.name,userAvatar:w.avatar,baseUrl:p.proxyEndpoint?void 0:r}),await z().catch(e=>console.warn(`[adobe] Failed to fetch models after login:`,e instanceof Error?e.message:String(e))),t()},onOAuthLogout:async()=>{let e=w();if(e?.accessToken)try{let t=h.values().next().value??{},n=t.clientId||p.clientId,r=b(t);if(n){let t=await fetch(`${S(r)}/ims/revoke`,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:new URLSearchParams({token:e.accessToken,token_type_hint:`access_token`,client_id:n})});t.ok||console.warn(`[adobe] Token revocation returned ${t.status}, token may still be valid server-side`)}}catch(e){console.warn(`[adobe] Failed to revoke token:`,e instanceof Error?e.message:String(e))}await n({providerId:`adobe`,accessToken:``})},onSilentRenew:async()=>w()?.accessToken?j():null},O=null;async function k(){let e=w();if(!e?.accessToken)throw Error(`Not logged in to Adobe — please log in first`);if((e.tokenExpiresAt??0)-Date.now()>6e4)return e.accessToken;console.log(`[adobe] Token expired or expiring soon, attempting silent renewal...`);try{let e=await j();if(e)return e}catch(e){console.warn(`[adobe] Silent renewal failed:`,e instanceof Error?e.message:String(e))}let t=w();if((t?.tokenExpiresAt??0)-Date.now()>0&&t?.accessToken)return t.accessToken;throw Error(`Adobe session expired — please log in again`)}function A(){let e=w();return e?.tokenExpiresAt?Date.now()>e.tokenExpiresAt-6e4:!0}async function j(){return typeof window>`u`?null:O||(O=(async()=>{try{let e=m(),t=await _(e),i=v(t),a=y(t),o=b(t),s=C?p.extensionRedirectUri??`https://${chrome.runtime.id}.chromiumapp.org/`:p.redirectUri??`${window.location.origin}/auth/callback`,c=C?void 0:btoa(JSON.stringify({port:parseInt(new URL(window.location.href).port||`5710`,10),path:`/auth/callback`,nonce:crypto.randomUUID()})),l=c?JSON.parse(atob(c)).nonce:null,u=new URLSearchParams({client_id:i,scope:a,response_type:`token`,redirect_uri:s,prompt:`none`});c&&u.set(`state`,c);let d=`${S(o)}/ims/authorize/v2?${u}`,{createOAuthLauncher:f}=await r(async()=>{let{createOAuthLauncher:e}=await import(`./oauth-service-B7as8KRE.js`);return{createOAuthLauncher:e}},__vite__mapDeps([0,1,2])),h=await f()(d);if(!h)return null;if(l&&h)try{if(new URL(h).searchParams.get(`nonce`)!==l)return console.error(`[adobe] OAuth nonce mismatch — possible CSRF`),null}catch(e){console.warn(`[adobe] Nonce check skipped (URL parse failed):`,e instanceof Error?e.message:String(e))}let g=E(h);if(!g)return null;let x=w();return await n({providerId:`adobe`,accessToken:g.accessToken,tokenExpiresAt:Date.now()+g.expiresIn*1e3,userName:x?.userName,userAvatar:x?.userAvatar,baseUrl:p.proxyEndpoint?void 0:e}),console.log(`[adobe] Token renewed silently`),await z().catch(e=>console.warn(`[adobe] Failed to refresh models after silent renewal:`,e instanceof Error?e.message:String(e))),g.accessToken}catch(e){return console.warn(`[adobe] Silent renewal error:`,e instanceof Error?e.message:String(e)),null}finally{O=null}})(),O)}var M=`X-Slicc-Version`;function N(e){let t={},n=M.toLowerCase();if(e.headers)for(let[r,i]of Object.entries(e.headers))r.toLowerCase()!==n&&(t[r]=i);return t[M]=`2.50.4`,{...e,headers:t}}function P(e,t){return{type:`error`,reason:`error`,error:{role:`assistant`,content:[],api:`adobe-anthropic`,provider:`adobe`,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`error`,errorMessage:t instanceof Error?t.message:String(t),timestamp:Date.now()}}}var F=(e,t,n={})=>{let r=u();return(async()=>{try{let i=await k();if(String(e.api).includes(`openai`)){let a=s({...e,baseUrl:`${m()}/v1`,api:`openai-completions`,compat:{...e.compat,supportsStore:!1,supportsDeveloperRole:!1}},t,N({...n,apiKey:i}));for await(let e of a)r.push(e)}else{let a=o({...e,baseUrl:m(),api:`anthropic-messages`},t,N({...n,apiKey:i}));for await(let e of a)r.push(e)}r.end()}catch(t){console.error(`[adobe] Stream error:`,t instanceof Error?t.message:String(t)),r.push(P(e,t)),r.end()}})(),r},I=(e,t,n)=>{let r=u();return(async()=>{try{let o=await k();if(String(e.api).includes(`openai`)){let i=a({...e,baseUrl:`${m()}/v1`,api:`openai-completions`,compat:{...e.compat,supportsStore:!1,supportsDeveloperRole:!1}},t,N({...n,apiKey:o}));for await(let e of i)r.push(e)}else{let a=i({...e,baseUrl:m(),api:`anthropic-messages`},t,N({...n,apiKey:o}));for await(let e of a)r.push(e)}r.end()}catch(t){console.error(`[adobe] Stream error:`,t instanceof Error?t.message:String(t)),r.push(P(e,t)),r.end()}})(),r};async function L(){try{let e=await k(),t=m(),n=await fetch(`${t}/v1/models`,{headers:{Authorization:`Bearer ${e}`,[M]:`2.50.4`}});if(n.ok){let e=await n.json();if(e.data?.length){for(let t of e.data){let e={id:t.id,name:t.name};t.api!==void 0&&(e.api=t.api),t.context_window!==void 0&&(e.context_window=t.context_window),t.max_tokens!==void 0&&(e.max_tokens=t.max_tokens),t.reasoning!==void 0&&(e.reasoning=t.reasoning),t.input!==void 0&&(e.input=t.input),g.set(t.id,e)}let n=new Map;for(let e of l())try{for(let t of d(e))n.set(t.id,t)}catch{}return e.data.map(e=>{let r=n.get(e.id),i=`adobe-${e.api===`openai`?`openai`:`anthropic`}`;return r?{...r,provider:`adobe`,api:i}:{id:e.id,name:e.name??e.id,provider:`adobe`,api:i,baseUrl:t,contextWindow:2e5,maxTokens:16384,input:[`text`,`image`],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},inputCost:0,outputCost:0,cacheReadCost:0,cacheWriteCost:0,reasoning:!0}})}}else console.warn(`[adobe] Proxy /v1/models returned ${n.status}, falling back to Anthropic models`)}catch(e){console.warn(`[adobe] Failed to fetch proxy models:`,e instanceof Error?e.message:String(e))}return d(`anthropic`).map(e=>({...e,provider:`adobe`,api:`adobe-anthropic`}))}var R=new Map;async function z(){let e=m(),t=R.get(e);if(t)return t;let n=await L();return R.set(e,n),n}function B(){c({api:`adobe-anthropic`,stream:F,streamSimple:I}),c({api:`adobe-openai`,stream:F,streamSimple:I})}export{D as config,z as getAdobeModels,k as getValidAccessToken,A as isTokenExpired,B as register};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./logger-B-No_qN_.js";import"./provider-settings-
|
|
1
|
+
import{t as e}from"./logger-B-No_qN_.js";import"./provider-settings-IYxDo-k8.js";var t=e(`agent-bridge`),n=`__slicc_agent`,r=`agent-spawn-request`;function i(){let e={spawn(e){return new Promise((t,n)=>{let i=globalThis.chrome?.runtime;if(!i||typeof i.sendMessage!=`function`){n(Error(`agent: chrome.runtime.sendMessage not available`));return}let a=e=>{let r=i.lastError;if(r){n(Error(r.message??`chrome.runtime error`));return}if(e==null){n(Error(`agent: empty response from offscreen bridge`));return}let a=e;if(!a.ok){n(Error(a.error??`agent: offscreen bridge error`));return}if(!a.result){n(Error(`agent: offscreen bridge returned no result`));return}t(a.result)};try{i.sendMessage({source:`panel`,payload:{type:r,options:e}},a)}catch(e){n(e instanceof Error?e:Error(String(e)))}})}};return globalThis[n]=e,t.info(`agent bridge proxy published on globalThis.__slicc_agent`),e}export{i as publishAgentBridgeProxy};
|
package/dist/ui/assets/{agent-message-to-chat-CImm2vOT.js → agent-message-to-chat-DOwxbBF0.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as e}from"./kernel-worker-
|
|
1
|
+
import{i as e}from"./kernel-worker-lpemPe6D.js";const t=new Set([`webhook`,`cron`,`sprinkle`,`fswatch`,`session-reload`,`navigate`,`upgrade`,`scoop-notify`,`scoop-idle`,`scoop-wait`]);function n(e){return e!=null&&t.has(e)}function r(t,n={}){let{source:r=`cone`,idSeed:c=d,hiddenToolNames:l=e}=n,f=[],h=null,g=new Set;for(let e of t){if(i(e)){let t=s(e.content);if(t.length===0)continue;let n=p(t);for(let t of n){if(t.body.length===0&&t.sender==null)continue;let n=t.sender?m(t.sender):null,r={id:c(),role:`user`,content:t.body,timestamp:e.timestamp};n&&(r.source=`lick`,r.channel=n),f.push(r)}h=null;continue}if(a(e)){let t=s(e.content),n=u(e),i=[];for(let e of n)l.has(e.name)?g.add(e.id):i.push(e);let a={id:c(),role:`assistant`,content:t,timestamp:e.timestamp,source:r};i.length>0&&(a.toolCalls=i),f.push(a),h=a;continue}if(o(e)){if(g.has(e.toolCallId))continue;let t=h?.toolCalls?.find(t=>t.id===e.toolCallId);if(!t)continue;t.result=s(e.content),t.isError=e.isError;continue}}return f}function i(e){return e.role===`user`}function a(e){return e.role===`assistant`}function o(e){return e.role===`toolResult`}function s(e){if(typeof e==`string`)return e;if(!Array.isArray(e))return``;let t=[];for(let n of e)c(n)&&t.push(n.text);return t.join(``)}function c(e){return e.type===`text`}function l(e){return e.type===`toolCall`}function u(e){if(!Array.isArray(e.content))return[];let t=[];for(let n of e.content)l(n)&&t.push({id:n.id,name:n.name,input:n.arguments});return t}function d(){return Date.now().toString(36)+Math.random().toString(36).slice(2,8)}function f(e){if(!e.startsWith(`[`))return null;let n=e.indexOf(`] `);if(n<=0||e.lastIndexOf(`
|
|
2
2
|
`,n)!==-1)return null;let r=e.slice(n+2);if(r.startsWith(`User: `))return{sender:`User`,body:r.slice(6)};for(let e of t){let t=`${e}:`;if(!r.startsWith(t))continue;let n=r.indexOf(`
|
|
3
3
|
`),i=n===-1?r.length:n,a=r.slice(0,i),o=-1,s=a.indexOf(`[`,t.length);if(s>t.length&&(o=a.lastIndexOf(`: `,s)),o<t.length&&(o=r.indexOf(`: `,t.length)),!(o<0||o>=i))return{sender:r.slice(0,o),body:r.slice(o+2)}}let i=r.indexOf(`
|
|
4
4
|
`),a=i===-1?r.length:i,o=r.indexOf(`: `);if(o<=0||o>=a)return null;let s=r.slice(0,o);return s.includes(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e,o as t}from"./provider-settings-
|
|
1
|
+
import{c as e,o as t}from"./provider-settings-IYxDo-k8.js";import{u as n}from"./bedrock-camp-CqXHYC67.js";import{i as r,n as i,o as a,s as o}from"./simple-options-imi_RHvn.js";import{t as s}from"./openai-CRGaNv9i.js";var c=`azure-openai`,l=`2024-12-01-preview`,u={id:c,name:`Azure OpenAI`,description:`GPT models via Azure AI Foundry`,requiresApiKey:!0,apiKeyPlaceholder:`Azure API key`,apiKeyEnvVar:`AZURE_OPENAI_API_KEY`,requiresBaseUrl:!0,baseUrlPlaceholder:`https://your-resource.cognitiveservices.azure.com/`,baseUrlDescription:`Azure resource endpoint`,requiresDeployment:!0,deploymentPlaceholder:`gpt-4.1-mini, gpt-4o, o4-mini`,deploymentDescription:`Comma-separated deployment names (from Azure Portal → Deployments)`,requiresApiVersion:!0,apiVersionDefault:l,apiVersionDescription:`Azure OpenAI API version`,getModelIds:()=>{let t=e(c);if(!t)return[{id:`azure-unconfigured`,name:`Azure OpenAI (set deployments in Settings)`}];let n=t.split(`,`).map(e=>e.trim()).filter(Boolean);return n.length===0?[{id:`azure-unconfigured`,name:`Azure OpenAI (set deployments in Settings)`}]:n.map(e=>{let t=e.startsWith(`o1`)||e.startsWith(`o3`)||e.startsWith(`o4`);return{id:e,name:`${e} (Azure)`,reasoning:t,input:[`text`,`image`]}})}};function d(e){return e.replace(/[^a-zA-Z0-9_-]/g,`_`).slice(0,64)}function f(e,t){let n=r(e.messages,t,d),i=[];for(let e of n)if(e.role===`user`)if(typeof e.content==`string`)i.push({role:`user`,content:e.content});else{let t=e.content.map(e=>e.type===`text`?{type:`text`,text:e.text??``}:e.type===`image`?{type:`image_url`,image_url:{url:`data:${e.mimeType};base64,${e.data}`}}:{type:`text`,text:JSON.stringify(e)});i.push({role:`user`,content:t})}else if(e.role===`assistant`){let t=e.content,n=t.filter(e=>e.type===`text`).map(e=>e.text??``).join(``),r=t.filter(e=>e.type===`toolCall`).map(e=>({id:e.id??``,type:`function`,function:{name:e.name??``,arguments:JSON.stringify(e.arguments??{})}}));r.length?i.push({role:`assistant`,content:n||null,tool_calls:r}):i.push({role:`assistant`,content:n})}else if(e.role===`toolResult`){let t=e.content;i.push({role:`tool`,tool_call_id:e.toolCallId??``,content:t?.map(e=>e.type===`text`?e.text??``:JSON.stringify(e)).join(``)||``})}return i}function p(e){if(e?.length)return e.map(e=>({type:`function`,function:{name:e.name,description:e.description,parameters:e.parameters}}))}function m(e){let t=e.content.find(e=>e.type===`text`);if(t)return{block:t,index:e.content.indexOf(t)};let n={type:`text`,text:``};return e.content.push(n),{block:n,index:e.content.length-1}}function h(e,t){return e.content.find(e=>e.type===`toolCall`&&e.id===t)}var g=(e,n,r={})=>{let i=a();return(async()=>{let a={role:`assistant`,content:[],api:`azure-openai-anthropic`,provider:c,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`stop`,timestamp:Date.now()};try{let u=r.apiKey;if(!u)throw Error(`Azure API key is required`);let d=e.baseUrl;if(!d)throw Error(`Azure endpoint is required`);let g=e.id,_={};e.headers&&Object.assign(_,e.headers),r.headers&&Object.assign(_,r.headers);let v=t(c)||l,y=new s({endpoint:d.replace(/\/+$/,``),apiKey:u,deployment:g,apiVersion:v,dangerouslyAllowBrowser:!0,defaultHeaders:_}),b=[...n.systemPrompt?[{role:`system`,content:n.systemPrompt}]:[],...f(n,e)],x=p(n.tools),S=await y.chat.completions.create({model:g,messages:b,stream:!0,stream_options:{include_usage:!0},...r.maxTokens?{max_completion_tokens:r.maxTokens}:{},...r.temperature===void 0?{}:{temperature:r.temperature},...x?{tools:x}:{}});i.push({type:`start`,partial:a});for await(let t of S){t.usage&&(a.usage.input=t.usage.prompt_tokens??0,a.usage.output=t.usage.completion_tokens??0,a.usage.totalTokens=t.usage.total_tokens??0,o(e,a.usage));for(let e of t.choices??[]){let t=e.delta;if(t){if(t.content){let{block:e,index:n}=m(a);e.text===``&&i.push({type:`text_start`,contentIndex:n,partial:a}),e.text+=t.content,i.push({type:`text_delta`,contentIndex:n,delta:t.content,partial:a})}if(t.tool_calls)for(let e of t.tool_calls){let t=e.id?h(a,e.id):void 0;if(!t&&e.id&&(t={type:`toolCall`,id:e.id,name:e.function?.name??``,arguments:{},_partialJson:``},a.content.push(t),i.push({type:`toolcall_start`,contentIndex:a.content.length-1,partial:a})),t&&e.function?.arguments){t._partialJson+=e.function.arguments;try{t.arguments=JSON.parse(t._partialJson)}catch{}i.push({type:`toolcall_delta`,contentIndex:a.content.indexOf(t),delta:e.function.arguments,partial:a})}}e.finish_reason&&(a.stopReason=e.finish_reason===`tool_calls`?`toolUse`:e.finish_reason===`length`?`length`:`stop`)}}}for(let e of a.content){let t=a.content.indexOf(e);if(e.type===`toolCall`){let n=e;try{n.arguments=JSON.parse(n._partialJson||`{}`)}catch{}delete n._partialJson,i.push({type:`toolcall_end`,contentIndex:t,toolCall:e,partial:a})}else e.type===`text`&&i.push({type:`text_end`,contentIndex:t,content:e.text,partial:a})}i.push({type:`done`,reason:a.stopReason,message:a}),i.end()}catch(e){a.stopReason=r.signal?.aborted?`aborted`:`error`,a.errorMessage=e instanceof Error?e.message:JSON.stringify(e),i.push({type:`error`,reason:a.stopReason,error:a}),i.end()}})(),i},_=(e,t,n)=>{let r=n?.apiKey;if(!r)throw Error(`Azure API key is required`);return g(e,t,{...i(e,n,r)})};function v(){n({api:`azure-openai-anthropic`,stream:g,streamSimple:_})}export{u as config,v as register};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,o as t}from"./provider-settings-
|
|
1
|
+
import{i as e,o as t}from"./provider-settings-CrrXS-Th.js";import{p as n}from"./bedrock-camp-9aDiXDk5.js";import{o as r,r as i,s as a,t as o}from"./transform-messages-uhk4b6os.js";import{t as s}from"./openai-D6Fs9zDM.js";const c=`azure-openai`,l=`2024-12-01-preview`,u={id:c,name:`Azure OpenAI`,description:`GPT models via Azure AI Foundry`,requiresApiKey:!0,apiKeyPlaceholder:`Azure API key`,apiKeyEnvVar:`AZURE_OPENAI_API_KEY`,requiresBaseUrl:!0,baseUrlPlaceholder:`https://your-resource.cognitiveservices.azure.com/`,baseUrlDescription:`Azure resource endpoint`,requiresDeployment:!0,deploymentPlaceholder:`gpt-4.1-mini, gpt-4o, o4-mini`,deploymentDescription:`Comma-separated deployment names (from Azure Portal → Deployments)`,requiresApiVersion:!0,apiVersionDefault:l,apiVersionDescription:`Azure OpenAI API version`,getModelIds:()=>{let e=t(c);if(!e)return[{id:`azure-unconfigured`,name:`Azure OpenAI (set deployments in Settings)`}];let n=e.split(`,`).map(e=>e.trim()).filter(Boolean);return n.length===0?[{id:`azure-unconfigured`,name:`Azure OpenAI (set deployments in Settings)`}]:n.map(e=>{let t=e.startsWith(`o1`)||e.startsWith(`o3`)||e.startsWith(`o4`);return{id:e,name:`${e} (Azure)`,reasoning:t,input:[`text`,`image`]}})}};function d(e){return e.replace(/[^a-zA-Z0-9_-]/g,`_`).slice(0,64)}function f(e,t){let n=o(e.messages,t,d),r=[];for(let e of n)if(e.role===`user`)if(typeof e.content==`string`)r.push({role:`user`,content:e.content});else{let t=e.content.map(e=>e.type===`text`?{type:`text`,text:e.text??``}:e.type===`image`?{type:`image_url`,image_url:{url:`data:${e.mimeType};base64,${e.data}`}}:{type:`text`,text:JSON.stringify(e)});r.push({role:`user`,content:t})}else if(e.role===`assistant`){let t=e.content,n=t.filter(e=>e.type===`text`).map(e=>e.text??``).join(``),i=t.filter(e=>e.type===`toolCall`).map(e=>({id:e.id??``,type:`function`,function:{name:e.name??``,arguments:JSON.stringify(e.arguments??{})}}));i.length?r.push({role:`assistant`,content:n||null,tool_calls:i}):r.push({role:`assistant`,content:n})}else if(e.role===`toolResult`){let t=e.content;r.push({role:`tool`,tool_call_id:e.toolCallId??``,content:t?.map(e=>e.type===`text`?e.text??``:JSON.stringify(e)).join(``)||``})}return r}function p(e){if(e?.length)return e.map(e=>({type:`function`,function:{name:e.name,description:e.description,parameters:e.parameters}}))}function m(e){let t=e.content.find(e=>e.type===`text`);if(t)return{block:t,index:e.content.indexOf(t)};let n={type:`text`,text:``};return e.content.push(n),{block:n,index:e.content.length-1}}function h(e,t){return e.content.find(e=>e.type===`toolCall`&&e.id===t)}const g=(t,n,i={})=>{let o=r();return(async()=>{let r={role:`assistant`,content:[],api:`azure-openai-anthropic`,provider:c,model:t.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:`stop`,timestamp:Date.now()};try{let u=i.apiKey;if(!u)throw Error(`Azure API key is required`);let d=t.baseUrl;if(!d)throw Error(`Azure endpoint is required`);let g=t.id,_={};t.headers&&Object.assign(_,t.headers),i.headers&&Object.assign(_,i.headers);let v=e(c)||l,y=new s({endpoint:d.replace(/\/+$/,``),apiKey:u,deployment:g,apiVersion:v,dangerouslyAllowBrowser:!0,defaultHeaders:_}),b=[...n.systemPrompt?[{role:`system`,content:n.systemPrompt}]:[],...f(n,t)],x=p(n.tools),S=await y.chat.completions.create({model:g,messages:b,stream:!0,stream_options:{include_usage:!0},...i.maxTokens?{max_completion_tokens:i.maxTokens}:{},...i.temperature===void 0?{}:{temperature:i.temperature},...x?{tools:x}:{}});o.push({type:`start`,partial:r});for await(let e of S){e.usage&&(r.usage.input=e.usage.prompt_tokens??0,r.usage.output=e.usage.completion_tokens??0,r.usage.totalTokens=e.usage.total_tokens??0,a(t,r.usage));for(let t of e.choices??[]){let e=t.delta;if(e){if(e.content){let{block:t,index:n}=m(r);t.text===``&&o.push({type:`text_start`,contentIndex:n,partial:r}),t.text+=e.content,o.push({type:`text_delta`,contentIndex:n,delta:e.content,partial:r})}if(e.tool_calls)for(let t of e.tool_calls){let e=t.id?h(r,t.id):void 0;if(!e&&t.id&&(e={type:`toolCall`,id:t.id,name:t.function?.name??``,arguments:{},_partialJson:``},r.content.push(e),o.push({type:`toolcall_start`,contentIndex:r.content.length-1,partial:r})),e&&t.function?.arguments){e._partialJson+=t.function.arguments;try{e.arguments=JSON.parse(e._partialJson)}catch{}o.push({type:`toolcall_delta`,contentIndex:r.content.indexOf(e),delta:t.function.arguments,partial:r})}}t.finish_reason&&(r.stopReason=t.finish_reason===`tool_calls`?`toolUse`:t.finish_reason===`length`?`length`:`stop`)}}}for(let e of r.content){let t=r.content.indexOf(e);if(e.type===`toolCall`){let n=e;try{n.arguments=JSON.parse(n._partialJson||`{}`)}catch{}delete n._partialJson,o.push({type:`toolcall_end`,contentIndex:t,toolCall:e,partial:r})}else e.type===`text`&&o.push({type:`text_end`,contentIndex:t,content:e.text,partial:r})}o.push({type:`done`,reason:r.stopReason,message:r}),o.end()}catch(e){r.stopReason=i.signal?.aborted?`aborted`:`error`,r.errorMessage=e instanceof Error?e.message:JSON.stringify(e),o.push({type:`error`,reason:r.stopReason,error:r}),o.end()}})(),o},_=(e,t,n)=>{let r=n?.apiKey;if(!r)throw Error(`Azure API key is required`);return g(e,t,{...i(e,n,r)})};function v(){n({api:`azure-openai-anthropic`,stream:g,streamSimple:_})}export{u as config,v as register};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/magick-wasm-
|
|
2
|
-
import{t as e}from"./logger-B-No_qN_.js";import{t}from"./preload-helper-ca-nBW7U.js";import"./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/magick-wasm-BjiSSRL4.js","assets/index-Cn5rmczt.js","assets/chunk-jRWAZmH_.js","assets/preload-helper-ca-nBW7U.js","assets/provider-settings-IYxDo-k8.js","assets/bedrock-camp-CqXHYC67.js","assets/env-api-keys-DxKb6C4Q.js","assets/simple-options-imi_RHvn.js","assets/json-parse-C5jSA6JB.js","assets/tray-follower-status-DKq8RTLd.js","assets/logger-B-No_qN_.js","assets/tool-ui-B3Bihlxa.js","assets/telemetry-B7l3TtVP.js","assets/fs-DKcnn-pO.js","assets/backend-local-mju0Ps5U.js","assets/mount-picker-popup-DJJfRF_c.js","assets/path-utils-d3qOVZOu.js","assets/mime-types-DL940yDZ.js","assets/mount-BdFGnrc0.js","assets/index-eWuuouO-.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{t as e}from"./logger-B-No_qN_.js";import{t}from"./preload-helper-ca-nBW7U.js";import"./index-Cn5rmczt.js";var n=e(`cdp`),r=class{ws=null;nextId=1;pending=new Map;listeners=new Map;_state=`disconnected`;get state(){return this._state}async connect(e){if(this._state!==`disconnected`)throw Error(`Cannot connect: state is ${this._state}`);if(!e?.url)throw Error(`CDPClient.connect() requires a WebSocket URL`);let{url:t,timeout:r=5e3}=e;return this._state=`connecting`,new Promise((e,i)=>{let a=setTimeout(()=>{this.cleanup(),i(Error(`CDP connection timed out after ${r}ms`))},r);try{this.ws=new WebSocket(t)}catch(e){clearTimeout(a),this._state=`disconnected`,i(e);return}this.ws.onopen=()=>{clearTimeout(a),this._state=`connected`,n.info(`Connected`,{url:t}),e()},this.ws.onerror=e=>{clearTimeout(a),this._state===`connecting`&&(n.error(`Connection failed`,{url:t}),this.cleanup(),i(Error(`CDP WebSocket connection failed`)))},this.ws.onmessage=e=>{this.handleMessage(e.data)},this.ws.onclose=()=>{this.handleClose()}})}disconnect(){this.ws&&(this.ws.onclose=null,this.ws.close()),this.cleanup(),n.info(`Disconnected`)}async send(e,t,r,i=3e4){if(this._state!==`connected`||!this.ws)throw Error(`CDP client is not connected`);let a=this.nextId++,o={id:a,method:e};return t&&(o.params=t),r&&(o.sessionId=r),n.debug(`Send`,{method:e,id:a,sessionId:r}),new Promise((t,n)=>{let r=setTimeout(()=>{this.pending.delete(a),n(Error(`CDP command timed out after ${i}ms: ${e}`))},i);this.pending.set(a,{resolve:e=>{clearTimeout(r),t(e)},reject:e=>{clearTimeout(r),n(e)}}),this.ws.send(JSON.stringify(o))})}on(e,t){let n=this.listeners.get(e);n||(n=new Set,this.listeners.set(e,n)),n.add(t)}off(e,t){let n=this.listeners.get(e);n&&(n.delete(t),n.size===0&&this.listeners.delete(e))}once(e,t=3e4){return new Promise((n,r)=>{let i=setTimeout(()=>{this.off(e,a),r(Error(`Timed out waiting for event: ${e}`))},t),a=t=>{clearTimeout(i),this.off(e,a),n(t)};this.on(e,a)})}handleMessage(e){let t;try{t=JSON.parse(e)}catch{return}if(`id`in t&&typeof t.id==`number`){let e=t;n.debug(`Response`,{id:e.id,hasError:!!e.error});let r=this.pending.get(e.id);r&&(this.pending.delete(e.id),e.error?(n.error(`Command error`,{id:e.id,code:e.error.code,message:e.error.message}),r.reject(Error(`CDP error: ${e.error.message} (${e.error.code})`))):r.resolve(e.result??{}));return}if(`method`in t){let e=t;n.debug(`Event`,{method:e.method,sessionId:e.sessionId});let r=this.listeners.get(e.method);if(r){let t=e.sessionId?{...e.params,sessionId:e.sessionId}:e.params??{};for(let e of r)try{e(t)}catch{}}}}handleClose(){n.error(`Connection closed unexpectedly`,{pendingCommands:this.pending.size});for(let[,e]of this.pending)e.reject(Error(`CDP connection closed`));this.cleanup()}cleanup(){this.ws=null,this._state=`disconnected`,this.pending.clear()}};function i(e,t=``){if(e==null)return t;if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`)return String(e);try{return JSON.stringify(e)??t}catch{return String(e)}}var a=`(function() {
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
5
5
|
// ===== DOM Utilities =====
|
|
@@ -869,7 +869,7 @@ import{t as e}from"./logger-B-No_qN_.js";import{t}from"./preload-helper-ca-nBW7U
|
|
|
869
869
|
} catch(e) {
|
|
870
870
|
return { role: 'RootWebArea', name: '', description: 'Error: ' + (e.message || String(e)) };
|
|
871
871
|
}
|
|
872
|
-
})()`,o=`ws://localhost:5710/cdp`,s=e(`browser-api`);function c(e=typeof window<`u`?window.location:null){return e?.host?`${e.protocol===`https:`?`wss:`:`ws:`}//${e.host}/cdp`:o}var l=class{client;localClient;sessionId=null;attachedTargetId=null;trayTargetProvider=null;remoteTargetInfo=null;_frameContextCache=new Map;_tabLock=Promise.resolve();_onSessionChange;handleJavaScriptDialogOpening=async e=>{let t=typeof e.sessionId==`string`?e.sessionId:this.sessionId;if(t)try{await this.client.send(`Page.handleJavaScriptDialog`,{accept:!1},t,5e3),s.warn(`Auto-dismissed unexpected JavaScript dialog`,{sessionId:t,type:e.type,message:e.message,url:e.url})}catch(e){s.warn(`Failed to auto-dismiss JavaScript dialog`,{sessionId:t,error:e instanceof Error?e.message:String(e)})}};constructor(e){this.client=e??new r,this.localClient=this.client,this.addDialogListener(this.client)}getTransport(){return this.client}setSessionChangeCallback(e){this._onSessionChange=e}getSessionId(){return this.sessionId}getAttachedTargetId(){return this.attachedTargetId}async withTab(e,t){let n,r=new Promise(e=>{n=e}),i=this._tabLock;this._tabLock=r,await i;try{return await t(await this.attachToPage(e))}finally{n()}}setTrayTargetProvider(e){this.trayTargetProvider=e}async listAllTargets(){let e=await this.listPages();if(!this.trayTargetProvider)return e;let t=!this.remoteTargetInfo,n=new Set(e.map(e=>e.targetId)),r=this.trayTargetProvider.getTargets().filter(e=>!t||!(e.runtimeId===`leader`&&n.has(e.localTargetId))).map(e=>({targetId:e.targetId,title:e.title,url:e.url}));return[...e,...r]}async connect(e){await this.client.connect({url:e?.url??c(),timeout:e?.timeout})}async createPage(e){return await this.ensureConnected(),await this.ensureLocalConnected(),(await this.localClient.send(`Target.createTarget`,{url:e??`about:blank`,background:!0})).targetId}async createRemotePage(e,t){if(!this.trayTargetProvider?.openRemoteTab)throw Error(`Remote tab opening not available (no tray target provider)`);return this.trayTargetProvider.openRemoteTab(e,t??`about:blank`)}async closePage(e){if(await this.ensureConnected(),this.trayTargetProvider?.createRemoteTransport&&e.includes(`:`)){let t=e.indexOf(`:`),n=e.substring(0,t),r=e.substring(t+1);{let t=this.trayTargetProvider.createRemoteTransport(n,r);try{await t.send(`Target.closeTarget`,{targetId:r})}finally{this.trayTargetProvider.removeRemoteTransport&&this.trayTargetProvider.removeRemoteTransport(n,r)}this.attachedTargetId===e&&(this.remoteTargetInfo&&=(this.setClient(this.localClient),null),this.sessionId=null,this.attachedTargetId=null);return}}await this.localClient.send(`Target.closeTarget`,{targetId:e}),this.attachedTargetId===e&&(this.sessionId=null,this.attachedTargetId=null)}disconnect(){this.sessionId=null,this.attachedTargetId=null,this.client.disconnect()}async listPages(){return await this.ensureConnected(),await this.ensureLocalConnected(),((await this.localClient.send(`Target.getTargets`)).targetInfos??[]).filter(e=>e.type===`page`).map(e=>({targetId:e.targetId,title:e.title,url:e.url,...e.active?{active:!0}:{}}))}async attachToPage(e){if(await this.ensureConnected(),this.sessionId&&this.attachedTargetId===e)return this.sessionId;if(this._frameContextCache.clear(),this.trayTargetProvider?.createRemoteTransport&&e.includes(`:`)){let t=e.indexOf(`:`),n=e.substring(0,t),r=e.substring(t+1);{let t=this.trayTargetProvider.createRemoteTransport(n,r);this.setClient(t),this.remoteTargetInfo={runtimeId:n,localTargetId:r};let i=await this.client.send(`Target.attachToTarget`,{targetId:r,flatten:!0});return this.sessionId=i.sessionId,this.attachedTargetId=e,await this.client.send(`Page.enable`,{},this.sessionId),this._onSessionChange?.(this.sessionId,this.client),this.sessionId}}this.remoteTargetInfo&&=(this.trayTargetProvider?.removeRemoteTransport&&this.trayTargetProvider.removeRemoteTransport(this.remoteTargetInfo.runtimeId,this.remoteTargetInfo.localTargetId),this.setClient(this.localClient),null),await this.ensureLocalConnected();let t=await this.localClient.send(`Target.attachToTarget`,{targetId:e,flatten:!0});return this.sessionId=t.sessionId,this.attachedTargetId=e,await this.localClient.send(`Page.enable`,{},this.sessionId),this._onSessionChange?.(this.sessionId,this.localClient),this.sessionId}async detach(){if(this.sessionId){try{await this.client.send(`Target.detachFromTarget`,{sessionId:this.sessionId})}catch{}this.remoteTargetInfo&&this.trayTargetProvider?.removeRemoteTransport&&(this.trayTargetProvider.removeRemoteTransport(this.remoteTargetInfo.runtimeId,this.remoteTargetInfo.localTargetId),this.setClient(this.localClient),this.remoteTargetInfo=null),this.sessionId=null,this.attachedTargetId=null}}async navigate(e){await this.ensureConnected(),this.ensureAttached(),await this.client.send(`Page.enable`,{},this.sessionId);let t=this.client.once(`Page.loadEventFired`);await this.client.send(`Page.navigate`,{url:e},this.sessionId),await t}async screenshot(e){await this.ensureConnected(),this.ensureAttached();try{let n={format:e?.format??`png`,captureBeyondViewport:!0};if(e?.quality!==void 0&&(n.quality=e.quality),e?.clip||e?.fullPage){let t=0,r=0;try{await this.client.send(`Runtime.enable`,{},this.sessionId);let e=await this.client.send(`Runtime.evaluate`,{expression:`JSON.stringify({ w: window.innerWidth, h: document.documentElement.scrollHeight })`,returnByValue:!0},this.sessionId),n=JSON.parse(e.result?.value??`{}`);t=n.w??0,r=n.h??0}catch{}e?.clip?n.clip={...e.clip,scale:e.clip.scale??1}:n.clip={x:0,y:0,width:t||1280,height:r||800,scale:1}}let r;try{r=await this.client.send(`Page.captureScreenshot`,n,this.sessionId)}catch{await this.client.send(`Page.bringToFront`,{},this.sessionId),r=await this.client.send(`Page.captureScreenshot`,n,this.sessionId)}let i=r.data;if(e?.maxWidth)try{let{getMagick:n}=await t(async()=>{let{getMagick:e}=await import(`./magick-wasm-
|
|
872
|
+
})()`,o=`ws://localhost:5710/cdp`,s=e(`browser-api`);function c(e=typeof window<`u`?window.location:null){return e?.host?`${e.protocol===`https:`?`wss:`:`ws:`}//${e.host}/cdp`:o}var l=class{client;localClient;sessionId=null;attachedTargetId=null;trayTargetProvider=null;remoteTargetInfo=null;_frameContextCache=new Map;_tabLock=Promise.resolve();_onSessionChange;handleJavaScriptDialogOpening=async e=>{let t=typeof e.sessionId==`string`?e.sessionId:this.sessionId;if(t)try{await this.client.send(`Page.handleJavaScriptDialog`,{accept:!1},t,5e3),s.warn(`Auto-dismissed unexpected JavaScript dialog`,{sessionId:t,type:e.type,message:e.message,url:e.url})}catch(e){s.warn(`Failed to auto-dismiss JavaScript dialog`,{sessionId:t,error:e instanceof Error?e.message:String(e)})}};constructor(e){this.client=e??new r,this.localClient=this.client,this.addDialogListener(this.client)}getTransport(){return this.client}setSessionChangeCallback(e){this._onSessionChange=e}getSessionId(){return this.sessionId}getAttachedTargetId(){return this.attachedTargetId}async withTab(e,t){let n,r=new Promise(e=>{n=e}),i=this._tabLock;this._tabLock=r,await i;try{return await t(await this.attachToPage(e))}finally{n()}}setTrayTargetProvider(e){this.trayTargetProvider=e}async listAllTargets(){let e=await this.listPages();if(!this.trayTargetProvider)return e;let t=!this.remoteTargetInfo,n=new Set(e.map(e=>e.targetId)),r=this.trayTargetProvider.getTargets().filter(e=>!t||!(e.runtimeId===`leader`&&n.has(e.localTargetId))).map(e=>({targetId:e.targetId,title:e.title,url:e.url}));return[...e,...r]}async connect(e){await this.client.connect({url:e?.url??c(),timeout:e?.timeout})}async createPage(e){return await this.ensureConnected(),await this.ensureLocalConnected(),(await this.localClient.send(`Target.createTarget`,{url:e??`about:blank`,background:!0})).targetId}async createRemotePage(e,t){if(!this.trayTargetProvider?.openRemoteTab)throw Error(`Remote tab opening not available (no tray target provider)`);return this.trayTargetProvider.openRemoteTab(e,t??`about:blank`)}async closePage(e){if(await this.ensureConnected(),this.trayTargetProvider?.createRemoteTransport&&e.includes(`:`)){let t=e.indexOf(`:`),n=e.substring(0,t),r=e.substring(t+1);{let t=this.trayTargetProvider.createRemoteTransport(n,r);try{await t.send(`Target.closeTarget`,{targetId:r})}finally{this.trayTargetProvider.removeRemoteTransport&&this.trayTargetProvider.removeRemoteTransport(n,r)}this.attachedTargetId===e&&(this.remoteTargetInfo&&=(this.setClient(this.localClient),null),this.sessionId=null,this.attachedTargetId=null);return}}await this.localClient.send(`Target.closeTarget`,{targetId:e}),this.attachedTargetId===e&&(this.sessionId=null,this.attachedTargetId=null)}disconnect(){this.sessionId=null,this.attachedTargetId=null,this.client.disconnect()}async listPages(){return await this.ensureConnected(),await this.ensureLocalConnected(),((await this.localClient.send(`Target.getTargets`)).targetInfos??[]).filter(e=>e.type===`page`).map(e=>({targetId:e.targetId,title:e.title,url:e.url,...e.active?{active:!0}:{}}))}async attachToPage(e){if(await this.ensureConnected(),this.sessionId&&this.attachedTargetId===e)return this.sessionId;if(this._frameContextCache.clear(),this.trayTargetProvider?.createRemoteTransport&&e.includes(`:`)){let t=e.indexOf(`:`),n=e.substring(0,t),r=e.substring(t+1);{let t=this.trayTargetProvider.createRemoteTransport(n,r);this.setClient(t),this.remoteTargetInfo={runtimeId:n,localTargetId:r};let i=await this.client.send(`Target.attachToTarget`,{targetId:r,flatten:!0});return this.sessionId=i.sessionId,this.attachedTargetId=e,await this.client.send(`Page.enable`,{},this.sessionId),this._onSessionChange?.(this.sessionId,this.client),this.sessionId}}this.remoteTargetInfo&&=(this.trayTargetProvider?.removeRemoteTransport&&this.trayTargetProvider.removeRemoteTransport(this.remoteTargetInfo.runtimeId,this.remoteTargetInfo.localTargetId),this.setClient(this.localClient),null),await this.ensureLocalConnected();let t=await this.localClient.send(`Target.attachToTarget`,{targetId:e,flatten:!0});return this.sessionId=t.sessionId,this.attachedTargetId=e,await this.localClient.send(`Page.enable`,{},this.sessionId),this._onSessionChange?.(this.sessionId,this.localClient),this.sessionId}async detach(){if(this.sessionId){try{await this.client.send(`Target.detachFromTarget`,{sessionId:this.sessionId})}catch{}this.remoteTargetInfo&&this.trayTargetProvider?.removeRemoteTransport&&(this.trayTargetProvider.removeRemoteTransport(this.remoteTargetInfo.runtimeId,this.remoteTargetInfo.localTargetId),this.setClient(this.localClient),this.remoteTargetInfo=null),this.sessionId=null,this.attachedTargetId=null}}async navigate(e){await this.ensureConnected(),this.ensureAttached(),await this.client.send(`Page.enable`,{},this.sessionId);let t=this.client.once(`Page.loadEventFired`);await this.client.send(`Page.navigate`,{url:e},this.sessionId),await t}async screenshot(e){await this.ensureConnected(),this.ensureAttached();try{let n={format:e?.format??`png`,captureBeyondViewport:!0};if(e?.quality!==void 0&&(n.quality=e.quality),e?.clip||e?.fullPage){let t=0,r=0;try{await this.client.send(`Runtime.enable`,{},this.sessionId);let e=await this.client.send(`Runtime.evaluate`,{expression:`JSON.stringify({ w: window.innerWidth, h: document.documentElement.scrollHeight })`,returnByValue:!0},this.sessionId),n=JSON.parse(e.result?.value??`{}`);t=n.w??0,r=n.h??0}catch{}e?.clip?n.clip={...e.clip,scale:e.clip.scale??1}:n.clip={x:0,y:0,width:t||1280,height:r||800,scale:1}}let r;try{r=await this.client.send(`Page.captureScreenshot`,n,this.sessionId)}catch{await this.client.send(`Page.bringToFront`,{},this.sessionId),r=await this.client.send(`Page.captureScreenshot`,n,this.sessionId)}let i=r.data;if(e?.maxWidth)try{let{getMagick:n}=await t(async()=>{let{getMagick:e}=await import(`./magick-wasm-BjiSSRL4.js`);return{getMagick:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19])),r=await n(),a=atob(i),o=new Uint8Array(a.length);for(let e=0;e<a.length;e++)o[e]=a.charCodeAt(e);let s=8e3,c=!1;await r.ImageMagick.read(o,async t=>{let n=Math.min(e.maxWidth,s),r=Math.max(t.width,t.height);if(t.width>n||r>s){let e=Math.min(n/t.width,s/r);t.resize(Math.round(t.width*e),Math.round(t.height*e)),c=!0}c&&t.write(`PNG`,e=>{let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);i=btoa(t)})})}catch(e){console.warn(`[browser-api] Screenshot maxWidth resize failed, returning original`,e)}return i}finally{}}async evaluate(e,t){await this.ensureConnected(),this.ensureAttached(),await this.client.send(`Runtime.enable`,{},this.sessionId);let n=await this.client.send(`Runtime.evaluate`,{expression:e,awaitPromise:t?.awaitPromise??!0,returnByValue:t?.returnByValue??!0},this.sessionId),r=n.exceptionDetails;if(r){let e=r.exception?.description??r.text;throw Error(`Evaluation failed: ${e}`)}return n.result.value}async click(e){await this.ensureConnected(),this.ensureAttached();let t=await this.boundingBox(e);if(!t)throw Error(`Element not found: ${e}`);let n=t.x+t.width/2,r=t.y+t.height/2;await this.client.send(`Input.dispatchMouseEvent`,{type:`mousePressed`,x:n,y:r,button:`left`,clickCount:1},this.sessionId),await this.client.send(`Input.dispatchMouseEvent`,{type:`mouseReleased`,x:n,y:r,button:`left`,clickCount:1},this.sessionId)}async type(e){await this.ensureConnected(),this.ensureAttached();for(let t of e)await this.client.send(`Input.dispatchKeyEvent`,{type:`keyDown`,text:t},this.sessionId),await this.client.send(`Input.dispatchKeyEvent`,{type:`keyUp`,text:t},this.sessionId)}async waitForSelector(e,t){await this.ensureConnected(),this.ensureAttached();let n=t?.timeout??3e4,r=t?.interval??100,i=Date.now();for(;Date.now()-i<n;){if(await this.evaluate(`!!document.querySelector(${JSON.stringify(e)})`))return;await new Promise(e=>setTimeout(e,r))}throw Error(`waitForSelector timed out after ${n}ms: ${e}`)}async getAccessibilityTree(){await this.ensureConnected(),this.ensureAttached();let e=await this.evaluate(a,{awaitPromise:!1,returnByValue:!0});return!e||typeof e!=`object`?{role:`RootWebArea`,name:``}:u(e)}async clickByBackendNodeId(e){await this.ensureConnected(),this.ensureAttached(),await this.client.send(`DOM.enable`,{},this.sessionId),await this.client.send(`Runtime.enable`,{},this.sessionId);let t=(await this.client.send(`DOM.resolveNode`,{backendNodeId:e},this.sessionId)).object;if(!t?.objectId)throw Error(`Could not resolve backend node ${e} to a DOM element`);let n=(await this.client.send(`Runtime.callFunctionOn`,{objectId:t.objectId,functionDeclaration:`function() {
|
|
873
873
|
this.scrollIntoView({ block: 'center', inline: 'center' });
|
|
874
874
|
const r = this.getBoundingClientRect();
|
|
875
875
|
return { x: r.x, y: r.y, width: r.width, height: r.height };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./index-Cn5rmczt.js";function e(e){}export{e as registerSessionCostsProvider};
|