@harborclient/sdk 1.5.3 → 1.6.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/CHANGELOG.md +11 -0
- package/dist/components/Breadcrumb/CrumbSegment.d.ts.map +1 -1
- package/dist/components/Breadcrumb/CrumbSegment.js +4 -2
- package/dist/components/Breadcrumb/types.d.ts +10 -1
- package/dist/components/Breadcrumb/types.d.ts.map +1 -1
- package/dist/components/MethodSelect/MethodSelectMenu.d.ts +34 -0
- package/dist/components/MethodSelect/MethodSelectMenu.d.ts.map +1 -0
- package/dist/components/MethodSelect/MethodSelectMenu.js +150 -0
- package/dist/components/MethodSelect/MethodSelectOption.d.ts +36 -0
- package/dist/components/MethodSelect/MethodSelectOption.d.ts.map +1 -0
- package/dist/components/MethodSelect/MethodSelectOption.js +15 -0
- package/dist/components/MethodSelect/MethodSelectSeparator.d.ts +10 -0
- package/dist/components/MethodSelect/MethodSelectSeparator.d.ts.map +1 -0
- package/dist/components/MethodSelect/MethodSelectSeparator.js +11 -0
- package/dist/components/MethodSelect/index.d.ts +21 -7
- package/dist/components/MethodSelect/index.d.ts.map +1 -1
- package/dist/components/MethodSelect/index.js +47 -6
- package/dist/components/SidebarItem/sidebarItemClasses.d.ts.map +1 -1
- package/dist/components/SidebarItem/sidebarItemClasses.js +2 -1
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.d.ts.map +1 -1
- package/dist/runtime/createBridgedPluginContext.js +295 -7
- package/dist/runtime/viewHost.js +6 -0
- package/dist/snippets.d.ts +30 -19
- package/dist/types.d.ts +337 -16
- package/dist/types.d.ts.map +1 -1
- package/dist/ui/tokens.d.ts +1 -0
- package/dist/ui/tokens.d.ts.map +1 -1
- package/dist/ui/tokens.js +4 -2
- package/package.json +1 -1
package/dist/types.d.ts
CHANGED
|
@@ -3,6 +3,12 @@ import type * as React from 'react';
|
|
|
3
3
|
* HTTP method supported in the request editor.
|
|
4
4
|
*/
|
|
5
5
|
export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS';
|
|
6
|
+
/**
|
|
7
|
+
* Transport protocol for a saved request or editor draft.
|
|
8
|
+
*
|
|
9
|
+
* HTTP uses the buffered send path. SSE opens a long-lived event stream.
|
|
10
|
+
*/
|
|
11
|
+
export type RequestProtocol = 'http' | 'sse';
|
|
6
12
|
/**
|
|
7
13
|
* A collection-scoped variable for use in request URLs via {{key}} syntax.
|
|
8
14
|
*/
|
|
@@ -306,6 +312,12 @@ export interface RequestDraft {
|
|
|
306
312
|
* HTTP method (for example `GET`, `POST`).
|
|
307
313
|
*/
|
|
308
314
|
method: string;
|
|
315
|
+
/**
|
|
316
|
+
* Transport protocol for the active request (`http` or `sse`).
|
|
317
|
+
*
|
|
318
|
+
* When `sse`, the editor uses the SSE session path instead of a buffered send.
|
|
319
|
+
*/
|
|
320
|
+
protocol?: RequestProtocol;
|
|
309
321
|
/**
|
|
310
322
|
* Request URL including scheme, host, path, and query string.
|
|
311
323
|
*/
|
|
@@ -956,12 +968,12 @@ export interface StatusBarItemContribution {
|
|
|
956
968
|
* - `resize-handle` — resizable panel grip (and high-contrast chrome accents)
|
|
957
969
|
* - `variable-token` — `{{variable}}` syntax highlight in editors
|
|
958
970
|
* - `danger`, `danger-light`, `warning`, `success`, `info` — status colors
|
|
959
|
-
* - `method-get`, `method-post`, `method-put`, `method-patch`, `method-delete`, `method-head`, `method-options` — HTTP method badge colors
|
|
971
|
+
* - `method-get`, `method-post`, `method-put`, `method-patch`, `method-delete`, `method-head`, `method-options`, `method-sse` — HTTP method / SSE badge colors
|
|
960
972
|
* - `scrollbar-track`, `scrollbar-thumb`, `scrollbar-thumb-hover`, `scrollbar-thumb-active` — scrollbar track and thumb colors
|
|
961
973
|
* - `script-stage-before-all`, `script-stage-before-each`, `script-stage-main`, `script-stage-after-each`, `script-stage-after-all` — script row stage accent colors
|
|
962
974
|
* - `terminal` — footer terminal background
|
|
963
975
|
*/
|
|
964
|
-
export type ThemeColorToken = 'surface' | 'header' | 'page-header' | 'page-header-text' | 'page-header-muted' | 'sidebar' | 'sidebar-toolbar' | 'sidebar-rail' | 'sidebar-rail-active' | 'sidebar-rail-text' | 'sidebar-rail-separator' | 'sidebar-section' | 'sidebar-section-text' | 'footer' | 'footer-text' | 'footer-muted' | 'footer-icon-active' | 'toolbar-action-active' | 'breadcrumb-background' | 'breadcrumb-segment' | 'breadcrumb-current' | 'git-staged' | 'git-uncommitted' | 'git-unstaged' | 'git-untracked' | 'control' | 'field' | 'separator' | 'text' | 'text-secondary' | 'muted' | 'accent' | 'selection' | 'doc-markdown' | 'tab-unsaved' | 'tab-underline' | 'resize-separator' | 'resize-handle' | 'variable-token' | 'danger' | 'danger-light' | 'warning' | 'success' | 'info' | 'method-get' | 'method-post' | 'method-put' | 'method-patch' | 'method-delete' | 'method-head' | 'method-options' | 'scrollbar-track' | 'scrollbar-thumb' | 'scrollbar-thumb-hover' | 'scrollbar-thumb-active' | 'script-stage-before-all' | 'script-stage-before-each' | 'script-stage-main' | 'script-stage-after-each' | 'script-stage-after-all' | 'terminal';
|
|
976
|
+
export type ThemeColorToken = 'surface' | 'header' | 'page-header' | 'page-header-text' | 'page-header-muted' | 'sidebar' | 'sidebar-toolbar' | 'sidebar-rail' | 'sidebar-rail-active' | 'sidebar-rail-text' | 'sidebar-rail-separator' | 'sidebar-section' | 'sidebar-section-text' | 'footer' | 'footer-text' | 'footer-muted' | 'footer-icon-active' | 'toolbar-action-active' | 'breadcrumb-background' | 'breadcrumb-segment' | 'breadcrumb-current' | 'git-staged' | 'git-uncommitted' | 'git-unstaged' | 'git-untracked' | 'control' | 'field' | 'separator' | 'text' | 'text-secondary' | 'muted' | 'accent' | 'selection' | 'doc-markdown' | 'tab-unsaved' | 'tab-underline' | 'resize-separator' | 'resize-handle' | 'variable-token' | 'danger' | 'danger-light' | 'warning' | 'success' | 'info' | 'method-get' | 'method-post' | 'method-put' | 'method-patch' | 'method-delete' | 'method-head' | 'method-options' | 'method-sse' | 'scrollbar-track' | 'scrollbar-thumb' | 'scrollbar-thumb-hover' | 'scrollbar-thumb-active' | 'script-stage-before-all' | 'script-stage-before-each' | 'script-stage-main' | 'script-stage-after-each' | 'script-stage-after-all' | 'terminal';
|
|
965
977
|
/**
|
|
966
978
|
* HarborClient UI metric token ids (typography and geometry).
|
|
967
979
|
*
|
|
@@ -2674,20 +2686,61 @@ export interface PluginLivePages {
|
|
|
2674
2686
|
*/
|
|
2675
2687
|
delete(id: number): Promise<void>;
|
|
2676
2688
|
}
|
|
2689
|
+
/**
|
|
2690
|
+
* Structured fields returned by a plugin {@link PluginChatPointerConfig.parse}.
|
|
2691
|
+
*
|
|
2692
|
+
* The host fills `kind`, `pluginId`, `pointerId`, and token offsets/text.
|
|
2693
|
+
*/
|
|
2694
|
+
export interface PluginChatPointerParseResult {
|
|
2695
|
+
/**
|
|
2696
|
+
* Opaque key identifying the referenced object for this pointer kind.
|
|
2697
|
+
*/
|
|
2698
|
+
key: string;
|
|
2699
|
+
/**
|
|
2700
|
+
* Optional character-range selection within the captured context.
|
|
2701
|
+
*/
|
|
2702
|
+
selection?: {
|
|
2703
|
+
/**
|
|
2704
|
+
* Inclusive start offset.
|
|
2705
|
+
*/
|
|
2706
|
+
start: number;
|
|
2707
|
+
/**
|
|
2708
|
+
* Exclusive end offset.
|
|
2709
|
+
*/
|
|
2710
|
+
end: number;
|
|
2711
|
+
};
|
|
2712
|
+
}
|
|
2677
2713
|
/**
|
|
2678
2714
|
* Config for {@link PluginAi.registerChatPointer}.
|
|
2679
2715
|
*/
|
|
2680
2716
|
export interface PluginChatPointerConfig {
|
|
2681
2717
|
/**
|
|
2682
|
-
* Pointer id segment
|
|
2718
|
+
* Pointer id segment. Must match `[a-z][a-z0-9-]*`.
|
|
2683
2719
|
*
|
|
2684
|
-
*
|
|
2720
|
+
* With the default grammar this becomes `@plugin.<pluginId>.<id>.<key>`.
|
|
2721
|
+
* With a custom {@link match}, it only identifies the registration.
|
|
2685
2722
|
*/
|
|
2686
2723
|
id: string;
|
|
2687
2724
|
/**
|
|
2688
2725
|
* Static rules merged into the agent system prompt while the plugin is loaded.
|
|
2689
2726
|
*/
|
|
2690
2727
|
agentGuidance?: string;
|
|
2728
|
+
/**
|
|
2729
|
+
* Regex for the token body after `@` (no leading `@`).
|
|
2730
|
+
*
|
|
2731
|
+
* Required together with {@link parse}. Omit both for the default
|
|
2732
|
+
* `@plugin.<pluginId>.<id>.<key>` grammar. Must not collide with reserved
|
|
2733
|
+
* builtin prefixes (`request`, `res`, `term`, `plugin`, …).
|
|
2734
|
+
*/
|
|
2735
|
+
match?: RegExp | string;
|
|
2736
|
+
/**
|
|
2737
|
+
* Maps a successful {@link match} into key/selection (or null to reject).
|
|
2738
|
+
*
|
|
2739
|
+
* Required when {@link match} is set. Runs in the plugin webview; the host
|
|
2740
|
+
* uses a sync fallback for composer highlighting and re-invokes this at
|
|
2741
|
+
* send/validate over IPC.
|
|
2742
|
+
*/
|
|
2743
|
+
parse?: (match: RegExpMatchArray, fullToken: string, atIndex: number) => PluginChatPointerParseResult | null;
|
|
2691
2744
|
}
|
|
2692
2745
|
/**
|
|
2693
2746
|
* Input for {@link PluginAi.copyToChat}.
|
|
@@ -2698,9 +2751,15 @@ export interface PluginCopyToChatInput {
|
|
|
2698
2751
|
*/
|
|
2699
2752
|
pointerId: string;
|
|
2700
2753
|
/**
|
|
2701
|
-
* Opaque key
|
|
2754
|
+
* Opaque key for the default `@plugin…` grammar. Required when the pointer
|
|
2755
|
+
* did not register a custom {@link PluginChatPointerConfig.match}.
|
|
2702
2756
|
*/
|
|
2703
|
-
key
|
|
2757
|
+
key?: string;
|
|
2758
|
+
/**
|
|
2759
|
+
* Full composer token including leading `@`. Required when the pointer
|
|
2760
|
+
* registered a custom {@link PluginChatPointerConfig.match}.
|
|
2761
|
+
*/
|
|
2762
|
+
token?: string;
|
|
2704
2763
|
/**
|
|
2705
2764
|
* Badge label shown in the AI composer and message bubbles.
|
|
2706
2765
|
*/
|
|
@@ -2710,7 +2769,8 @@ export interface PluginCopyToChatInput {
|
|
|
2710
2769
|
*/
|
|
2711
2770
|
context: string;
|
|
2712
2771
|
/**
|
|
2713
|
-
* Optional character-range selection
|
|
2772
|
+
* Optional character-range selection (default grammar appends `#start.end`;
|
|
2773
|
+
* custom tokens may already include a selection suffix).
|
|
2714
2774
|
*/
|
|
2715
2775
|
selection?: {
|
|
2716
2776
|
/**
|
|
@@ -2846,7 +2906,166 @@ export interface PluginLivePageHandle {
|
|
|
2846
2906
|
}>;
|
|
2847
2907
|
}
|
|
2848
2908
|
/**
|
|
2849
|
-
*
|
|
2909
|
+
* Append-only static instruction bag on {@link PluginAi.instructions}.
|
|
2910
|
+
*
|
|
2911
|
+
* Fragments are merged into the agent system prompt while registered. Plugins
|
|
2912
|
+
* cannot rewrite Harbor's base system prompt.
|
|
2913
|
+
*/
|
|
2914
|
+
export interface PluginAiInstructions {
|
|
2915
|
+
/**
|
|
2916
|
+
* Appends a fragment merged into the agent system prompt while registered.
|
|
2917
|
+
*
|
|
2918
|
+
* @param text - Instruction text (whitespace-only strings are ignored).
|
|
2919
|
+
* @returns A {@link Disposable} that removes the fragment when disposed.
|
|
2920
|
+
*/
|
|
2921
|
+
add(text: string): Disposable;
|
|
2922
|
+
/**
|
|
2923
|
+
* This plugin's currently registered instruction fragments (read-only).
|
|
2924
|
+
*/
|
|
2925
|
+
readonly list: readonly string[];
|
|
2926
|
+
}
|
|
2927
|
+
/**
|
|
2928
|
+
* One conversation message visible to {@link PluginAiBeforeTurnContext} handlers.
|
|
2929
|
+
*/
|
|
2930
|
+
export interface PluginAiTurnMessage {
|
|
2931
|
+
/**
|
|
2932
|
+
* OpenAI-compatible message role.
|
|
2933
|
+
*/
|
|
2934
|
+
role: 'system' | 'user' | 'assistant' | 'tool';
|
|
2935
|
+
/**
|
|
2936
|
+
* Message text content.
|
|
2937
|
+
*/
|
|
2938
|
+
content?: string | null;
|
|
2939
|
+
}
|
|
2940
|
+
/**
|
|
2941
|
+
* Turn-scoped ephemeral instruction bag on {@link PluginAiBeforeTurnContext}.
|
|
2942
|
+
*/
|
|
2943
|
+
export interface PluginAiTurnInstructions {
|
|
2944
|
+
/**
|
|
2945
|
+
* Appends a fragment for this turn only (ephemeral system message).
|
|
2946
|
+
*
|
|
2947
|
+
* @param text - Instruction text.
|
|
2948
|
+
*/
|
|
2949
|
+
push(text: string): void;
|
|
2950
|
+
/**
|
|
2951
|
+
* Fragments pushed for this turn so far.
|
|
2952
|
+
*/
|
|
2953
|
+
readonly list: readonly string[];
|
|
2954
|
+
}
|
|
2955
|
+
/**
|
|
2956
|
+
* Mutable context passed to {@link PluginAi.onBeforeTurn} once per user chat turn.
|
|
2957
|
+
*
|
|
2958
|
+
* Fires before the first LLM completion step. Mutating {@link userMessage.content}
|
|
2959
|
+
* changes model-facing text for this turn only (not the persisted DB row).
|
|
2960
|
+
*/
|
|
2961
|
+
export interface PluginAiBeforeTurnContext {
|
|
2962
|
+
/**
|
|
2963
|
+
* Chat row id.
|
|
2964
|
+
*/
|
|
2965
|
+
chatId: number;
|
|
2966
|
+
/**
|
|
2967
|
+
* Model id selected in the composer.
|
|
2968
|
+
*/
|
|
2969
|
+
model: string;
|
|
2970
|
+
/**
|
|
2971
|
+
* Team Hub id when the selected model is hub-proxied.
|
|
2972
|
+
*/
|
|
2973
|
+
hubId?: string;
|
|
2974
|
+
/**
|
|
2975
|
+
* The user message driving this turn.
|
|
2976
|
+
*/
|
|
2977
|
+
userMessage: {
|
|
2978
|
+
/**
|
|
2979
|
+
* Model-facing user text (mutable).
|
|
2980
|
+
*/
|
|
2981
|
+
content: string;
|
|
2982
|
+
/**
|
|
2983
|
+
* Read-only `@` reference snapshots already collected for this send.
|
|
2984
|
+
*/
|
|
2985
|
+
readonly referenceSnapshots?: Record<string, unknown>;
|
|
2986
|
+
};
|
|
2987
|
+
/**
|
|
2988
|
+
* Turn-only instruction fragments (appended after static plugin instructions).
|
|
2989
|
+
*/
|
|
2990
|
+
instructions: PluginAiTurnInstructions;
|
|
2991
|
+
/**
|
|
2992
|
+
* Conversation history that will be sent (excluding Harbor's base system prompt).
|
|
2993
|
+
*/
|
|
2994
|
+
messages: PluginAiTurnMessage[];
|
|
2995
|
+
/**
|
|
2996
|
+
* Aborts the turn before any LLM call.
|
|
2997
|
+
*
|
|
2998
|
+
* @param reason - Optional user-facing cancel reason.
|
|
2999
|
+
*/
|
|
3000
|
+
cancel(reason?: string): void;
|
|
3001
|
+
}
|
|
3002
|
+
/**
|
|
3003
|
+
* Read-only result passed to {@link PluginAi.onAfterTurn} when a user turn ends.
|
|
3004
|
+
*/
|
|
3005
|
+
export interface PluginAiAfterTurnContext {
|
|
3006
|
+
/**
|
|
3007
|
+
* Chat row id.
|
|
3008
|
+
*/
|
|
3009
|
+
chatId: number;
|
|
3010
|
+
/**
|
|
3011
|
+
* Model id used for the turn.
|
|
3012
|
+
*/
|
|
3013
|
+
model: string;
|
|
3014
|
+
/**
|
|
3015
|
+
* Team Hub id when hub-proxied.
|
|
3016
|
+
*/
|
|
3017
|
+
hubId?: string;
|
|
3018
|
+
/**
|
|
3019
|
+
* User text that drove this turn (after before-turn rewrites).
|
|
3020
|
+
*/
|
|
3021
|
+
userMessage: {
|
|
3022
|
+
/**
|
|
3023
|
+
* User message content.
|
|
3024
|
+
*/
|
|
3025
|
+
content: string;
|
|
3026
|
+
};
|
|
3027
|
+
/**
|
|
3028
|
+
* Final assistant text persisted for the turn, if any.
|
|
3029
|
+
*/
|
|
3030
|
+
assistantMessage: {
|
|
3031
|
+
/**
|
|
3032
|
+
* Assistant message content.
|
|
3033
|
+
*/
|
|
3034
|
+
content: string;
|
|
3035
|
+
} | null;
|
|
3036
|
+
/**
|
|
3037
|
+
* How the turn ended.
|
|
3038
|
+
*/
|
|
3039
|
+
status: 'completed' | 'cancelled' | 'error';
|
|
3040
|
+
/**
|
|
3041
|
+
* Error details when {@link status} is `error`.
|
|
3042
|
+
*/
|
|
3043
|
+
error?: {
|
|
3044
|
+
/**
|
|
3045
|
+
* User-facing error message.
|
|
3046
|
+
*/
|
|
3047
|
+
message: string;
|
|
3048
|
+
};
|
|
3049
|
+
/**
|
|
3050
|
+
* Cheap telemetry from the tool loop.
|
|
3051
|
+
*/
|
|
3052
|
+
stats: {
|
|
3053
|
+
/**
|
|
3054
|
+
* Number of `completeChatStep` calls in this turn.
|
|
3055
|
+
*/
|
|
3056
|
+
stepCount: number;
|
|
3057
|
+
/**
|
|
3058
|
+
* Number of tool calls executed in this turn.
|
|
3059
|
+
*/
|
|
3060
|
+
toolCallCount: number;
|
|
3061
|
+
/**
|
|
3062
|
+
* Wall-clock duration of the turn in milliseconds.
|
|
3063
|
+
*/
|
|
3064
|
+
durationMs: number;
|
|
3065
|
+
};
|
|
3066
|
+
}
|
|
3067
|
+
/**
|
|
3068
|
+
* AI chat pointer, instruction, and turn-hook APIs available on {@link PluginContext.ai}.
|
|
2850
3069
|
*
|
|
2851
3070
|
* Requires the `ai` permission. Registrations are activation-scoped.
|
|
2852
3071
|
*/
|
|
@@ -2864,6 +3083,24 @@ export interface PluginAi {
|
|
|
2864
3083
|
* @param input - Pointer id, key, label, and context text captured by the plugin.
|
|
2865
3084
|
*/
|
|
2866
3085
|
copyToChat(input: PluginCopyToChatInput): Promise<void>;
|
|
3086
|
+
/**
|
|
3087
|
+
* Append-only static instruction fragments merged into the agent system prompt.
|
|
3088
|
+
*/
|
|
3089
|
+
instructions: PluginAiInstructions;
|
|
3090
|
+
/**
|
|
3091
|
+
* Registers a callback that runs once per user chat turn before the first LLM step.
|
|
3092
|
+
*
|
|
3093
|
+
* @param handler - Called with a mutable turn context.
|
|
3094
|
+
* @returns A {@link Disposable} that unregisters the handler when disposed.
|
|
3095
|
+
*/
|
|
3096
|
+
onBeforeTurn(handler: (ctx: PluginAiBeforeTurnContext) => void | Promise<void>): Disposable;
|
|
3097
|
+
/**
|
|
3098
|
+
* Registers a callback that runs once when a user chat turn finishes.
|
|
3099
|
+
*
|
|
3100
|
+
* @param handler - Called with a read-only turn result.
|
|
3101
|
+
* @returns A {@link Disposable} that unregisters the handler when disposed.
|
|
3102
|
+
*/
|
|
3103
|
+
onAfterTurn(handler: (ctx: PluginAiAfterTurnContext) => void | Promise<void>): Disposable;
|
|
2867
3104
|
}
|
|
2868
3105
|
/**
|
|
2869
3106
|
* **File → Import** handler registration available on {@link PluginContext.imports}.
|
|
@@ -3338,6 +3575,10 @@ export interface CreateCollectionRequest {
|
|
|
3338
3575
|
* HTTP method (for example `GET`, `POST`). Defaults to `GET` when omitted or invalid.
|
|
3339
3576
|
*/
|
|
3340
3577
|
method?: string;
|
|
3578
|
+
/**
|
|
3579
|
+
* Transport protocol (`http` or `sse`). Defaults to `http` when omitted.
|
|
3580
|
+
*/
|
|
3581
|
+
protocol?: 'http' | 'sse';
|
|
3341
3582
|
/**
|
|
3342
3583
|
* Request URL including scheme, host, path, and query string.
|
|
3343
3584
|
*/
|
|
@@ -3527,6 +3768,10 @@ export interface SavedRequestSummary {
|
|
|
3527
3768
|
name: string;
|
|
3528
3769
|
/** HTTP method. */
|
|
3529
3770
|
method: HttpMethod;
|
|
3771
|
+
/**
|
|
3772
|
+
* Transport protocol (`http` or `sse`). Defaults to `http` when omitted by older hosts.
|
|
3773
|
+
*/
|
|
3774
|
+
protocol?: RequestProtocol;
|
|
3530
3775
|
/** Sibling sort order. */
|
|
3531
3776
|
sort_order: number;
|
|
3532
3777
|
/** Optional sidebar marker color. */
|
|
@@ -3788,6 +4033,10 @@ export interface CreateRequestInput {
|
|
|
3788
4033
|
name?: string;
|
|
3789
4034
|
/** HTTP method; defaults to `GET`. */
|
|
3790
4035
|
method?: HttpMethod;
|
|
4036
|
+
/**
|
|
4037
|
+
* Transport protocol; defaults to `http`. Use `sse` for Server-Sent Events.
|
|
4038
|
+
*/
|
|
4039
|
+
protocol?: RequestProtocol;
|
|
3791
4040
|
/** Request URL; defaults to empty. */
|
|
3792
4041
|
url?: string;
|
|
3793
4042
|
}
|
|
@@ -3989,7 +4238,10 @@ export interface HostSavedRequest extends SavedRequestSummary {
|
|
|
3989
4238
|
updated_at: string;
|
|
3990
4239
|
}
|
|
3991
4240
|
/**
|
|
3992
|
-
* Input for
|
|
4241
|
+
* Input for plugin outbound HTTP before conversion to the native fetch API.
|
|
4242
|
+
* Prefer {@link PluginHost.fetch} with `(input, init?)` in new code.
|
|
4243
|
+
*
|
|
4244
|
+
* @deprecated Use fetch(url, init?) instead.
|
|
3993
4245
|
*/
|
|
3994
4246
|
export interface PluginSendRequestInput {
|
|
3995
4247
|
/** HTTP method to use. */
|
|
@@ -4012,7 +4264,72 @@ export interface PluginSendRequestInput {
|
|
|
4012
4264
|
sourceRequestName?: string;
|
|
4013
4265
|
}
|
|
4014
4266
|
/**
|
|
4015
|
-
*
|
|
4267
|
+
* Headers-like facade returned by {@link PluginHost.fetch}.
|
|
4268
|
+
*/
|
|
4269
|
+
export interface PluginFetchHeaders {
|
|
4270
|
+
/**
|
|
4271
|
+
* Returns the first header value for the given name (case-insensitive), or null.
|
|
4272
|
+
*
|
|
4273
|
+
* @param name - Header name.
|
|
4274
|
+
*/
|
|
4275
|
+
get(name: string): string | null;
|
|
4276
|
+
/**
|
|
4277
|
+
* Returns true when a header with the given name is present.
|
|
4278
|
+
*
|
|
4279
|
+
* @param name - Header name.
|
|
4280
|
+
*/
|
|
4281
|
+
has(name: string): boolean;
|
|
4282
|
+
/**
|
|
4283
|
+
* Iterates header entries as [name, value] pairs.
|
|
4284
|
+
*/
|
|
4285
|
+
entries(): IterableIterator<[string, string]>;
|
|
4286
|
+
/**
|
|
4287
|
+
* Iterates header names.
|
|
4288
|
+
*/
|
|
4289
|
+
keys(): IterableIterator<string>;
|
|
4290
|
+
/**
|
|
4291
|
+
* Iterates header values.
|
|
4292
|
+
*/
|
|
4293
|
+
values(): IterableIterator<string>;
|
|
4294
|
+
/**
|
|
4295
|
+
* Invokes callback for each header entry.
|
|
4296
|
+
*
|
|
4297
|
+
* @param callback - Called with (value, key).
|
|
4298
|
+
*/
|
|
4299
|
+
forEach(callback: (value: string, key: string) => void): void;
|
|
4300
|
+
}
|
|
4301
|
+
/**
|
|
4302
|
+
* Response-compatible result of {@link PluginHost.fetch}.
|
|
4303
|
+
*/
|
|
4304
|
+
export interface PluginFetchResponse {
|
|
4305
|
+
/** True when status is in the 200–299 range. */
|
|
4306
|
+
readonly ok: boolean;
|
|
4307
|
+
/** HTTP status code. */
|
|
4308
|
+
readonly status: number;
|
|
4309
|
+
/** HTTP status text. */
|
|
4310
|
+
readonly statusText: string;
|
|
4311
|
+
/** Response headers. */
|
|
4312
|
+
readonly headers: PluginFetchHeaders;
|
|
4313
|
+
/** Returns the response body as text. */
|
|
4314
|
+
text(): Promise<string>;
|
|
4315
|
+
/** Parses the response body as JSON. */
|
|
4316
|
+
json(): Promise<unknown>;
|
|
4317
|
+
/** Returns the response body as an ArrayBuffer (UTF-8 bytes of the text body). */
|
|
4318
|
+
arrayBuffer(): Promise<ArrayBuffer>;
|
|
4319
|
+
}
|
|
4320
|
+
/**
|
|
4321
|
+
* RequestInit-compatible options for {@link PluginHost.fetch}.
|
|
4322
|
+
*/
|
|
4323
|
+
export interface PluginFetchInit {
|
|
4324
|
+
/** HTTP method (default GET). */
|
|
4325
|
+
method?: string;
|
|
4326
|
+
/** Request headers as a record, header list, or Headers-like object. */
|
|
4327
|
+
headers?: Record<string, string> | Array<[string, string]> | PluginFetchHeaders;
|
|
4328
|
+
/** Request body. Only strings and URLSearchParams are supported. */
|
|
4329
|
+
body?: string | URLSearchParams | null;
|
|
4330
|
+
}
|
|
4331
|
+
/**
|
|
4332
|
+
* Result of a plugin-initiated HTTP send used by console logging and history.
|
|
4016
4333
|
*/
|
|
4017
4334
|
export interface PluginSendResult {
|
|
4018
4335
|
/** HTTP status code, or 0 when the request failed before a response. */
|
|
@@ -4038,7 +4355,7 @@ export interface PluginSendResult {
|
|
|
4038
4355
|
/**
|
|
4039
4356
|
* Typed wrappers for built-in HarborClient request editor commands.
|
|
4040
4357
|
*
|
|
4041
|
-
* Requires the `ui` permission (except {@link PluginHost.
|
|
4358
|
+
* Requires the `ui` permission (except {@link PluginHost.fetch}, which
|
|
4042
4359
|
* requires `network`). Prefer these over stringly-typed
|
|
4043
4360
|
* {@link PluginCommands.execute} for opening request tabs.
|
|
4044
4361
|
*/
|
|
@@ -4151,7 +4468,7 @@ export interface PluginHost {
|
|
|
4151
4468
|
*
|
|
4152
4469
|
* No-op when a send is already in flight for the active tab.
|
|
4153
4470
|
*/
|
|
4154
|
-
|
|
4471
|
+
send(): Promise<void>;
|
|
4155
4472
|
/**
|
|
4156
4473
|
* Creates a new environment, populates it with variables, and selects it as active.
|
|
4157
4474
|
*
|
|
@@ -4486,14 +4803,18 @@ export interface PluginHost {
|
|
|
4486
4803
|
result: PluginSendResult;
|
|
4487
4804
|
}): Promise<void>;
|
|
4488
4805
|
/**
|
|
4489
|
-
* Sends one HTTP request through the main-process pipeline
|
|
4490
|
-
*
|
|
4806
|
+
* Sends one HTTP request through the main-process pipeline using the native
|
|
4807
|
+
* fetch(input, init?) signature. Failures resolve to a Response-like object
|
|
4808
|
+
* with status 0 rather than throwing.
|
|
4491
4809
|
*
|
|
4492
4810
|
* Requires the `network` permission.
|
|
4493
4811
|
*
|
|
4494
|
-
* @param input - Request
|
|
4812
|
+
* @param input - URL string, URL, or Request-like `{ url }` object.
|
|
4813
|
+
* @param init - Optional RequestInit-compatible options.
|
|
4495
4814
|
*/
|
|
4496
|
-
|
|
4815
|
+
fetch(input: string | URL | {
|
|
4816
|
+
url: string;
|
|
4817
|
+
}, init?: PluginFetchInit): Promise<PluginFetchResponse>;
|
|
4497
4818
|
/**
|
|
4498
4819
|
* Clears the active request tab's last HTTP response so plugin-only response
|
|
4499
4820
|
* views can take over the panel.
|