@harborclient/sdk 1.4.5 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/types.d.ts CHANGED
@@ -607,6 +607,55 @@ export interface RequestToolbarActionContribution {
607
607
  */
608
608
  order?: number;
609
609
  }
610
+ /**
611
+ * Context passed to a live-page chrome action command when the user clicks the button.
612
+ */
613
+ export interface LivePageChromeActionContext {
614
+ /**
615
+ * Client-side id of the browser tab whose chrome rendered the button.
616
+ */
617
+ tabId: string;
618
+ /**
619
+ * Current page URL shown in the address bar.
620
+ */
621
+ url: string;
622
+ /**
623
+ * Document title shown in the tab bar.
624
+ */
625
+ title: string;
626
+ /**
627
+ * Linked saved website database id when the tab is bound to a Website; otherwise null/undefined.
628
+ */
629
+ websiteId?: number | null;
630
+ }
631
+ /**
632
+ * Adds a RoundButton to the embedded browser chrome bar (between Downloads and Ask AI).
633
+ *
634
+ * Register the command handler with {@link PluginCommands.register} separately.
635
+ * The handler receives a single {@link LivePageChromeActionContext} argument.
636
+ * Manifest: `contributes.livePageChromeActions` plus a matching `contributes.commands` entry.
637
+ * Requires the `ui` permission.
638
+ *
639
+ * Buttons sort by plugin activation order, then registration order within the plugin — not by title.
640
+ */
641
+ export interface LivePageChromeActionContribution {
642
+ /**
643
+ * Action id — must match an entry in `contributes.livePageChromeActions`.
644
+ */
645
+ id: string;
646
+ /**
647
+ * Button label / accessible name (and tooltip).
648
+ */
649
+ title: string;
650
+ /**
651
+ * Command id to run on click — must match a registered command and manifest entry.
652
+ */
653
+ command: string;
654
+ /**
655
+ * Optional curated icon name resolved by the host (falls back to a puzzle-piece icon).
656
+ */
657
+ icon?: string;
658
+ }
610
659
  /**
611
660
  * Context passed to a script editor action command when the user clicks a row button.
612
661
  */
@@ -1864,7 +1913,7 @@ export interface UpdateLiveServerInput {
1864
1913
  *
1865
1914
  * Provide `savedId` to start from a persisted config (config optional override),
1866
1915
  * or provide `config` alone for an ad-hoc run. Does not open a browser tab;
1867
- * use {@link PluginContext.webpage} when the `browser` permission is granted.
1916
+ * use {@link PluginContext.livePage} when the `browser` permission is granted.
1868
1917
  */
1869
1918
  export interface StartLiveServerInput {
1870
1919
  /**
@@ -2168,6 +2217,343 @@ export interface PluginLiveServers {
2168
2217
  */
2169
2218
  onRequestLog(listener: (entry: LiveServerRequestLogEntry) => void): Disposable;
2170
2219
  }
2220
+ /**
2221
+ * Page-load points at which a saved website injection script may run.
2222
+ *
2223
+ * Mirrors `@harborclient/core` website script run-at values.
2224
+ */
2225
+ export type WebsiteScriptRunAt = 'document-start' | 'dom-ready' | 'did-finish-load';
2226
+ /**
2227
+ * One plain JavaScript injection script persisted with a website.
2228
+ *
2229
+ * Mirrors `@harborclient/core` website injection script rows.
2230
+ */
2231
+ export interface WebsiteInjectionScript {
2232
+ /**
2233
+ * Stable id within the website's script list.
2234
+ */
2235
+ id: string;
2236
+ /**
2237
+ * Display name shown in browser settings.
2238
+ */
2239
+ name: string;
2240
+ /**
2241
+ * When false, the script is skipped at injection time.
2242
+ */
2243
+ enabled: boolean;
2244
+ /**
2245
+ * Guest lifecycle hook that triggers this script.
2246
+ */
2247
+ runAt: WebsiteScriptRunAt;
2248
+ /**
2249
+ * JavaScript source executed in the page main world.
2250
+ */
2251
+ source: string;
2252
+ }
2253
+ /**
2254
+ * One pre/post request script on a saved website (no path match).
2255
+ *
2256
+ * Mirrors `@harborclient/core` ScriptRef used by live pages.
2257
+ */
2258
+ export interface WebsiteScriptRef {
2259
+ /**
2260
+ * Stable list key used for reordering and React keys.
2261
+ */
2262
+ id: string;
2263
+ /**
2264
+ * When false, the script is skipped.
2265
+ */
2266
+ enabled: boolean;
2267
+ /**
2268
+ * Inline JavaScript source or a live reference to a saved snippet.
2269
+ */
2270
+ kind: 'inline' | 'snippet';
2271
+ /**
2272
+ * Optional display label for inline scripts.
2273
+ */
2274
+ name?: string;
2275
+ /**
2276
+ * JavaScript source when {@link kind} is `inline`.
2277
+ */
2278
+ code?: string;
2279
+ /**
2280
+ * Snippet uuid when {@link kind} is `snippet`.
2281
+ */
2282
+ snippetUuid?: string;
2283
+ /**
2284
+ * When true, the script editor body is expanded in the list UI.
2285
+ */
2286
+ expanded?: boolean;
2287
+ /**
2288
+ * Stage within a request stage list. Live pages coerce this to `main`.
2289
+ */
2290
+ stage?: ScriptStage;
2291
+ }
2292
+ /**
2293
+ * Authorization stored on a saved website (includes OAuth 2.0 fields for parity with core).
2294
+ *
2295
+ * Mirrors `@harborclient/core` AuthConfig used by {@link Website}.
2296
+ */
2297
+ export interface WebsiteAuthConfig {
2298
+ /**
2299
+ * Selected auth mode; none means no chrome-driven auth header.
2300
+ */
2301
+ type: 'none' | 'basic' | 'bearer' | 'oauth2';
2302
+ /**
2303
+ * Username and password for Basic Auth.
2304
+ */
2305
+ basic: {
2306
+ username: string;
2307
+ password: string;
2308
+ };
2309
+ /**
2310
+ * Token value for Bearer Token auth.
2311
+ */
2312
+ bearer: {
2313
+ token: string;
2314
+ };
2315
+ /**
2316
+ * OAuth 2.0 Client Credentials settings (not applied to guest navigations today).
2317
+ */
2318
+ oauth2: {
2319
+ tokenUrl: string;
2320
+ clientId: string;
2321
+ clientSecret: string;
2322
+ scope: string;
2323
+ audience: string;
2324
+ clientAuth: 'body' | 'header';
2325
+ };
2326
+ }
2327
+ /**
2328
+ * A saved embedded-browser website (live page) in the local registry.
2329
+ *
2330
+ * Mirrors `@harborclient/core` Website entity shape.
2331
+ */
2332
+ export interface Website {
2333
+ /**
2334
+ * Database primary key.
2335
+ */
2336
+ id: number;
2337
+ /**
2338
+ * Stable portable identifier for export/import.
2339
+ */
2340
+ uuid: string;
2341
+ /**
2342
+ * Display name shown in the sidebar (last page title).
2343
+ */
2344
+ name: string;
2345
+ /**
2346
+ * Last committed URL when the website was saved.
2347
+ */
2348
+ url: string;
2349
+ /**
2350
+ * Home URL for the browser Home button.
2351
+ */
2352
+ homeUrl: string;
2353
+ /**
2354
+ * Favicon as a data URL when available.
2355
+ */
2356
+ faviconDataUrl: string | null;
2357
+ /**
2358
+ * Applied injection scripts.
2359
+ */
2360
+ scripts: WebsiteInjectionScript[];
2361
+ /**
2362
+ * Applied pre-request hc.* scripts.
2363
+ */
2364
+ preRequestScripts: WebsiteScriptRef[];
2365
+ /**
2366
+ * Applied post-request hc.* scripts.
2367
+ */
2368
+ postRequestScripts: WebsiteScriptRef[];
2369
+ /**
2370
+ * Website-scoped variables for address-bar and script substitution.
2371
+ */
2372
+ variables: Variable[];
2373
+ /**
2374
+ * Headers sent with chrome-driven guest navigations.
2375
+ */
2376
+ headers: KeyValue[];
2377
+ /**
2378
+ * User-Agent override for chrome-driven navigations; empty uses Chromium default.
2379
+ */
2380
+ userAgent: string;
2381
+ /**
2382
+ * Authorization applied to chrome-driven guest navigations (Basic/Bearer).
2383
+ */
2384
+ auth: WebsiteAuthConfig;
2385
+ /**
2386
+ * Id of the storage connection that stores this live page.
2387
+ *
2388
+ * Omitted for provider-local records before RoutingStorage merges registry metadata.
2389
+ */
2390
+ connectionId?: string;
2391
+ /**
2392
+ * Creation timestamp in milliseconds since epoch.
2393
+ */
2394
+ createdAt: number;
2395
+ /**
2396
+ * Last update timestamp in milliseconds since epoch.
2397
+ */
2398
+ updatedAt: number;
2399
+ }
2400
+ /**
2401
+ * Input for creating a website in the local registry.
2402
+ *
2403
+ * Mirrors `@harborclient/core` CreateWebsiteInput.
2404
+ */
2405
+ export interface CreateWebsiteInput {
2406
+ /**
2407
+ * Display name for the website.
2408
+ */
2409
+ name: string;
2410
+ /**
2411
+ * Optional portable uuid; generated when omitted.
2412
+ */
2413
+ uuid?: string;
2414
+ /**
2415
+ * Optional storage connection id; defaults to the active data provider when omitted.
2416
+ */
2417
+ connectionId?: string;
2418
+ /**
2419
+ * Last committed URL.
2420
+ */
2421
+ url: string;
2422
+ /**
2423
+ * Home URL for the browser Home button.
2424
+ */
2425
+ homeUrl: string;
2426
+ /**
2427
+ * Optional favicon data URL.
2428
+ */
2429
+ faviconDataUrl?: string | null;
2430
+ /**
2431
+ * Injection scripts to persist.
2432
+ */
2433
+ scripts?: WebsiteInjectionScript[];
2434
+ /**
2435
+ * Pre-request hc.* scripts to persist.
2436
+ */
2437
+ preRequestScripts?: WebsiteScriptRef[];
2438
+ /**
2439
+ * Post-request hc.* scripts to persist.
2440
+ */
2441
+ postRequestScripts?: WebsiteScriptRef[];
2442
+ /**
2443
+ * Website-scoped variables to persist.
2444
+ */
2445
+ variables?: Variable[];
2446
+ /**
2447
+ * Headers to persist for chrome-driven navigations.
2448
+ */
2449
+ headers?: KeyValue[];
2450
+ /**
2451
+ * User-Agent override to persist; empty uses Chromium default.
2452
+ */
2453
+ userAgent?: string;
2454
+ /**
2455
+ * Authorization settings to persist.
2456
+ */
2457
+ auth?: WebsiteAuthConfig;
2458
+ }
2459
+ /**
2460
+ * Input for updating a website in the local registry.
2461
+ *
2462
+ * Mirrors `@harborclient/core` UpdateWebsiteInput.
2463
+ */
2464
+ export interface UpdateWebsiteInput {
2465
+ /**
2466
+ * Database primary key of the website to update.
2467
+ */
2468
+ id: number;
2469
+ /**
2470
+ * Display name for the website.
2471
+ */
2472
+ name: string;
2473
+ /**
2474
+ * Last committed URL.
2475
+ */
2476
+ url: string;
2477
+ /**
2478
+ * Home URL for the browser Home button.
2479
+ */
2480
+ homeUrl: string;
2481
+ /**
2482
+ * Optional favicon data URL.
2483
+ */
2484
+ faviconDataUrl?: string | null;
2485
+ /**
2486
+ * Injection scripts to persist.
2487
+ */
2488
+ scripts: WebsiteInjectionScript[];
2489
+ /**
2490
+ * Pre-request hc.* scripts to persist.
2491
+ */
2492
+ preRequestScripts: WebsiteScriptRef[];
2493
+ /**
2494
+ * Post-request hc.* scripts to persist.
2495
+ */
2496
+ postRequestScripts: WebsiteScriptRef[];
2497
+ /**
2498
+ * Website-scoped variables to persist.
2499
+ */
2500
+ variables: Variable[];
2501
+ /**
2502
+ * Headers to persist for chrome-driven navigations.
2503
+ */
2504
+ headers: KeyValue[];
2505
+ /**
2506
+ * User-Agent override to persist; empty uses Chromium default.
2507
+ */
2508
+ userAgent: string;
2509
+ /**
2510
+ * Authorization settings to persist.
2511
+ */
2512
+ auth: WebsiteAuthConfig;
2513
+ }
2514
+ /**
2515
+ * Saved live page (website) APIs available on {@link PluginContext.livePages}.
2516
+ *
2517
+ * Requires the `live-pages` permission. Mutations update the registry only; they do
2518
+ * not open or bind a browser tab.
2519
+ */
2520
+ export interface PluginLivePages {
2521
+ /**
2522
+ * Lists all saved live pages from the local registry.
2523
+ *
2524
+ * @returns Saved website rows.
2525
+ */
2526
+ list(): Promise<Website[]>;
2527
+ /**
2528
+ * Returns one saved live page by database id or uuid.
2529
+ *
2530
+ * @param idOrUuid - Numeric id or uuid string.
2531
+ * @returns The saved website, or null when not found.
2532
+ */
2533
+ get(idOrUuid: number | string): Promise<Website | null>;
2534
+ /**
2535
+ * Creates a saved live page and returns the new row.
2536
+ *
2537
+ * @param input - Name, URLs, and optional scripts/headers/auth/variables.
2538
+ * @returns The created saved website.
2539
+ */
2540
+ create(input: CreateWebsiteInput): Promise<Website>;
2541
+ /**
2542
+ * Updates a saved live page and returns the refreshed row.
2543
+ *
2544
+ * Does not open or bind a browser tab.
2545
+ *
2546
+ * @param input - Full update payload including id.
2547
+ * @returns The updated saved website.
2548
+ */
2549
+ update(input: UpdateWebsiteInput): Promise<Website>;
2550
+ /**
2551
+ * Deletes a saved live page (moves it to trash).
2552
+ *
2553
+ * @param id - Database primary key.
2554
+ */
2555
+ delete(id: number): Promise<void>;
2556
+ }
2171
2557
  /**
2172
2558
  * Config for {@link PluginAi.registerChatPointer}.
2173
2559
  */
@@ -2218,11 +2604,11 @@ export interface PluginCopyToChatInput {
2218
2604
  };
2219
2605
  }
2220
2606
  /**
2221
- * Live DOM helpers on a webpage handle from {@link PluginContext.webpage}.
2607
+ * Live DOM helpers on a live-page handle from {@link PluginContext.livePage}.
2222
2608
  *
2223
2609
  * Requires the `browser` permission.
2224
2610
  */
2225
- export interface PluginWebpageDom {
2611
+ export interface PluginLivePageDom {
2226
2612
  /**
2227
2613
  * Queries the live page DOM with a CSS selector.
2228
2614
  *
@@ -2261,17 +2647,29 @@ export interface PluginWebpageDom {
2261
2647
  injectStylesheet(css: string): Promise<string>;
2262
2648
  }
2263
2649
  /**
2264
- * Handle returned by {@link PluginContext.webpage} for an embedded browser tab.
2650
+ * Handle returned by {@link PluginContext.livePage} for an embedded browser tab.
2265
2651
  *
2266
- * Requires the `browser` permission. Same semantics as request-script `hc.webpage`.
2652
+ * Requires the `browser` permission. Same semantics as request-script `hc.livePage`.
2267
2653
  */
2268
- export interface PluginWebpageHandle {
2654
+ export interface PluginLivePageHandle {
2269
2655
  readonly tabId: string;
2270
- readonly url: string;
2271
- readonly title: string;
2272
- readonly canGoBack: boolean;
2273
- readonly canGoForward: boolean;
2274
- readonly dom: PluginWebpageDom;
2656
+ /**
2657
+ * Current page URL. Updated after navigate / goBack / goForward / reload.
2658
+ */
2659
+ url: string;
2660
+ /**
2661
+ * Document title. Updated after navigate / goBack / goForward / reload.
2662
+ */
2663
+ title: string;
2664
+ /**
2665
+ * Whether history can go back. Updated after navigation helpers.
2666
+ */
2667
+ canGoBack: boolean;
2668
+ /**
2669
+ * Whether history can go forward. Updated after navigation helpers.
2670
+ */
2671
+ canGoForward: boolean;
2672
+ readonly dom: PluginLivePageDom;
2275
2673
  /**
2276
2674
  * Focuses this browser tab in the tab bar.
2277
2675
  */
@@ -2280,6 +2678,36 @@ export interface PluginWebpageHandle {
2280
2678
  * Closes this browser tab. Returns false when the user cancels a leave prompt.
2281
2679
  */
2282
2680
  close(): Promise<boolean>;
2681
+ /**
2682
+ * Navigates history back one entry and waits for load.
2683
+ *
2684
+ * Updates {@link PluginLivePageHandle.url}, {@link PluginLivePageHandle.title},
2685
+ * {@link PluginLivePageHandle.canGoBack}, and {@link PluginLivePageHandle.canGoForward}.
2686
+ */
2687
+ goBack(): Promise<void>;
2688
+ /**
2689
+ * Navigates history forward one entry and waits for load.
2690
+ *
2691
+ * Updates {@link PluginLivePageHandle.url}, {@link PluginLivePageHandle.title},
2692
+ * {@link PluginLivePageHandle.canGoBack}, and {@link PluginLivePageHandle.canGoForward}.
2693
+ */
2694
+ goForward(): Promise<void>;
2695
+ /**
2696
+ * Reloads the current page and waits for load.
2697
+ *
2698
+ * Updates {@link PluginLivePageHandle.url}, {@link PluginLivePageHandle.title},
2699
+ * {@link PluginLivePageHandle.canGoBack}, and {@link PluginLivePageHandle.canGoForward}.
2700
+ */
2701
+ reload(): Promise<void>;
2702
+ /**
2703
+ * Loads a URL in this tab and waits for load.
2704
+ *
2705
+ * Updates {@link PluginLivePageHandle.url}, {@link PluginLivePageHandle.title},
2706
+ * {@link PluginLivePageHandle.canGoBack}, and {@link PluginLivePageHandle.canGoForward}.
2707
+ *
2708
+ * @param url - Absolute http(s) or about:blank URL.
2709
+ */
2710
+ navigate(url: string): Promise<void>;
2283
2711
  /**
2284
2712
  * Captures the visible viewport as PNG and writes it under an allowlisted path.
2285
2713
  *
@@ -2582,6 +3010,16 @@ export interface PluginUi {
2582
3010
  * @returns A {@link Disposable} that unregisters the action when disposed.
2583
3011
  */
2584
3012
  registerRequestToolbarAction(action: RequestToolbarActionContribution): Disposable;
3013
+ /**
3014
+ * Adds a RoundButton to the embedded browser chrome bar.
3015
+ *
3016
+ * Manifest: `contributes.livePageChromeActions` plus a matching `contributes.commands` entry.
3017
+ * The command handler receives a {@link LivePageChromeActionContext} argument.
3018
+ *
3019
+ * @param action - Live-page chrome action contribution.
3020
+ * @returns A {@link Disposable} that unregisters the action when disposed.
3021
+ */
3022
+ registerLivePageChromeAction(action: LivePageChromeActionContribution): Disposable;
2585
3023
  /**
2586
3024
  * Adds an icon button to each script row in the pre/post request script editor.
2587
3025
  *
@@ -4027,6 +4465,10 @@ export interface PluginContext {
4027
4465
  * permission.
4028
4466
  */
4029
4467
  liveServers: PluginLiveServers;
4468
+ /**
4469
+ * Saved live page (website) CRUD. Requires the `live-pages` permission.
4470
+ */
4471
+ livePages: PluginLivePages;
4030
4472
  /**
4031
4473
  * AI chat pointer registration and copy-to-chat. Requires the `ai` permission.
4032
4474
  */
@@ -4035,16 +4477,16 @@ export interface PluginContext {
4035
4477
  * Opens or reuses an embedded browser tab and returns a control handle.
4036
4478
  *
4037
4479
  * Requires the `browser` permission (granted at install/enable). Same call shape
4038
- * as request-script `hc.webpage`: omit `url` to bind the active browser tab;
4480
+ * as request-script `hc.livePage`: omit `url` to bind the active browser tab;
4039
4481
  * `{ reuse }` defaults to true; new tabs wait for load.
4040
4482
  *
4041
4483
  * @param url - Optional URL to open or reuse.
4042
4484
  * @param options - Optional `{ reuse }` (default true).
4043
4485
  * @returns Handle with `focus` / `close` and `dom` helpers.
4044
4486
  */
4045
- webpage(url?: string, options?: {
4487
+ livePage(url?: string, options?: {
4046
4488
  reuse?: boolean;
4047
- }): Promise<PluginWebpageHandle>;
4489
+ }): Promise<PluginLivePageHandle>;
4048
4490
  /**
4049
4491
  * Host-managed disposable list used for registration cleanup on deactivation.
4050
4492
  *