dsh-github-copilot 0.4.0-alpha.18
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/AGENTS.md +233 -0
- package/CONTRIBUTING.md +46 -0
- package/LICENSE +21 -0
- package/README.md +365 -0
- package/README.zh.md +376 -0
- package/SECURITY.md +29 -0
- package/cordis.patch.yml +16 -0
- package/deployment-baseline.json +752 -0
- package/docs/agent-readiness.md +95 -0
- package/docs/images/copilot-auth-card-signed-in.png +0 -0
- package/docs/images/copilot-device-code-copy.png +0 -0
- package/docs/images/copilot-model-freshness.png +0 -0
- package/docs/images/copilot-model-refreshing.png +0 -0
- package/docs/images/copilot-provider-authorization.png +0 -0
- package/docs/images/copilot-provider-entry.png +0 -0
- package/docs/images/github-copilot-auth-flow.gif +0 -0
- package/docs/model-compatibility-acceptance.md +46 -0
- package/docs/npm-distribution.md +134 -0
- package/docs/session-search-routing.md +53 -0
- package/docs/single-route-migration.md +115 -0
- package/lib/client.js +7153 -0
- package/lib/client.js.map +1 -0
- package/lib/index.js +5384 -0
- package/lib/remote.js +162 -0
- package/lib/routed-web.js +80 -0
- package/lib/search-routing-pFLux0W7.js +763 -0
- package/lib/types/account-model-auth.d.ts +15 -0
- package/lib/types/account-model-catalog.d.ts +67 -0
- package/lib/types/account-model-source.d.ts +85 -0
- package/lib/types/authorization-controller.d.ts +100 -0
- package/lib/types/client.d.ts +106 -0
- package/lib/types/compact-account.d.ts +42 -0
- package/lib/types/compatibility.d.ts +17 -0
- package/lib/types/config.d.ts +42 -0
- package/lib/types/content-file.d.ts +10 -0
- package/lib/types/copilot-auth.d.ts +23 -0
- package/lib/types/copilot-grant.d.ts +11 -0
- package/lib/types/copilot-identity.d.ts +6 -0
- package/lib/types/copilot-request.d.ts +11 -0
- package/lib/types/current-provider.d.ts +59 -0
- package/lib/types/deepseek-search-fallback.d.ts +11 -0
- package/lib/types/failure.d.ts +38 -0
- package/lib/types/http.d.ts +48 -0
- package/lib/types/index.d.ts +39 -0
- package/lib/types/migration-status.d.ts +50 -0
- package/lib/types/model-protocol.d.ts +31 -0
- package/lib/types/pi-provider-bridge.d.ts +22 -0
- package/lib/types/plan.d.ts +148 -0
- package/lib/types/preview-provider.d.ts +35 -0
- package/lib/types/preview-route.d.ts +63 -0
- package/lib/types/probe.d.ts +39 -0
- package/lib/types/reasoning-presentation.d.ts +55 -0
- package/lib/types/remote.d.ts +151 -0
- package/lib/types/responses-reasoning-text.d.ts +24 -0
- package/lib/types/responses-reasoning.d.ts +7 -0
- package/lib/types/route-ownership.d.ts +70 -0
- package/lib/types/routed-web.d.ts +38 -0
- package/lib/types/search-backend.d.ts +16 -0
- package/lib/types/search-routing.d.ts +43 -0
- package/lib/types/serialize.d.ts +109 -0
- package/lib/types/sse.d.ts +28 -0
- package/lib/types/temporary-models.d.ts +25 -0
- package/lib/types/tool-schema-compat.d.ts +17 -0
- package/lib/types/traditional-search.d.ts +17 -0
- package/lib/types/types.d.ts +69 -0
- package/lib/types/usage.d.ts +26 -0
- package/lib/types/watchdog.d.ts +22 -0
- package/lib/types/web-delegate.d.ts +12 -0
- package/lib/types/web-search-routing-card.d.ts +10 -0
- package/lib/types/web-search-routing-config.d.ts +16 -0
- package/lib/types/wire-anthropic.d.ts +37 -0
- package/lib/types/wire.d.ts +56 -0
- package/lib/web-delegate.js +9 -0
- package/package.json +200 -0
- package/scripts/check-search-composition.mjs +191 -0
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client-safe Remote contribution for the plugin-owned authorization bridge.
|
|
3
|
+
*/
|
|
4
|
+
import type { RemoteResult, TypertRemoteContribution } from '@deepseek-ai/dsh-typert-protocol';
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import type { GitHubCopilotAuthorizationView } from './authorization-controller.ts';
|
|
7
|
+
import type { GitHubCopilotMigrationStatus } from './migration-status.ts';
|
|
8
|
+
declare module '@deepseek-ai/dsh-typert-protocol' {
|
|
9
|
+
interface TypertRemoteNamespaceMap {
|
|
10
|
+
githubCopilot: {
|
|
11
|
+
migrationStatus(): Promise<RemoteResult<GitHubCopilotMigrationStatus>>;
|
|
12
|
+
status(): Promise<RemoteResult<GitHubCopilotAuthorizationView>>;
|
|
13
|
+
reconcile(): Promise<RemoteResult<GitHubCopilotAuthorizationView>>;
|
|
14
|
+
discoverModels(): Promise<RemoteResult<GitHubCopilotAuthorizationView>>;
|
|
15
|
+
ensureModels(): Promise<RemoteResult<GitHubCopilotAuthorizationView>>;
|
|
16
|
+
start(): Promise<RemoteResult<GitHubCopilotAuthorizationView>>;
|
|
17
|
+
cancel(): Promise<RemoteResult<GitHubCopilotAuthorizationView>>;
|
|
18
|
+
signOut(): Promise<RemoteResult<GitHubCopilotAuthorizationView>>;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export declare const GITHUB_COPILOT_AUTHORIZATION_VIEW_TYPE_SYMBOL = "dsh-github-copilot#GitHubCopilotAuthorizationView";
|
|
23
|
+
export declare const GitHubCopilotAuthorizationViewSchema: z.ZodObject<{
|
|
24
|
+
phase: z.ZodEnum<{
|
|
25
|
+
error: "error";
|
|
26
|
+
"signed-out": "signed-out";
|
|
27
|
+
authorizing: "authorizing";
|
|
28
|
+
"signed-in": "signed-in";
|
|
29
|
+
}>;
|
|
30
|
+
configured: z.ZodBoolean;
|
|
31
|
+
writable: z.ZodBoolean;
|
|
32
|
+
inFlight: z.ZodBoolean;
|
|
33
|
+
notices: z.ZodArray<z.ZodObject<{
|
|
34
|
+
message: z.ZodString;
|
|
35
|
+
url: z.ZodOptional<z.ZodString>;
|
|
36
|
+
code: z.ZodOptional<z.ZodString>;
|
|
37
|
+
}, z.core.$strict>>;
|
|
38
|
+
catalog: z.ZodOptional<z.ZodObject<{
|
|
39
|
+
state: z.ZodEnum<{
|
|
40
|
+
current: "current";
|
|
41
|
+
"partially-outdated": "partially-outdated";
|
|
42
|
+
outdated: "outdated";
|
|
43
|
+
}>;
|
|
44
|
+
accountModelCount: z.ZodNumber;
|
|
45
|
+
supportedModelCount: z.ZodNumber;
|
|
46
|
+
unknownModelIds: z.ZodArray<z.ZodString>;
|
|
47
|
+
temporarilyUnavailableModelIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
48
|
+
previewModelIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
49
|
+
}, z.core.$strict>>;
|
|
50
|
+
accountModels: z.ZodOptional<z.ZodObject<{
|
|
51
|
+
state: z.ZodEnum<{
|
|
52
|
+
error: "error";
|
|
53
|
+
idle: "idle";
|
|
54
|
+
loading: "loading";
|
|
55
|
+
ready: "ready";
|
|
56
|
+
stale: "stale";
|
|
57
|
+
disposed: "disposed";
|
|
58
|
+
unconfigured: "unconfigured";
|
|
59
|
+
unavailable: "unavailable";
|
|
60
|
+
}>;
|
|
61
|
+
models: z.ZodArray<z.ZodObject<{
|
|
62
|
+
id: z.ZodString;
|
|
63
|
+
name: z.ZodString;
|
|
64
|
+
api: z.ZodString;
|
|
65
|
+
}, z.core.$strict>>;
|
|
66
|
+
rejected: z.ZodArray<z.ZodObject<{
|
|
67
|
+
id: z.ZodOptional<z.ZodString>;
|
|
68
|
+
code: z.ZodString;
|
|
69
|
+
}, z.core.$strict>>;
|
|
70
|
+
warnings: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
71
|
+
id: z.ZodString;
|
|
72
|
+
code: z.ZodString;
|
|
73
|
+
}, z.core.$strict>>>;
|
|
74
|
+
discoveredAt: z.ZodOptional<z.ZodNumber>;
|
|
75
|
+
error: z.ZodOptional<z.ZodString>;
|
|
76
|
+
}, z.core.$strict>>;
|
|
77
|
+
route: z.ZodOptional<z.ZodObject<{
|
|
78
|
+
state: z.ZodEnum<{
|
|
79
|
+
error: "error";
|
|
80
|
+
ready: "ready";
|
|
81
|
+
"needs-repair": "needs-repair";
|
|
82
|
+
"not-configured": "not-configured";
|
|
83
|
+
conflict: "conflict";
|
|
84
|
+
}>;
|
|
85
|
+
diagnosticCode: z.ZodOptional<z.ZodEnum<{
|
|
86
|
+
ROUTE_READ_FAILED: "ROUTE_READ_FAILED";
|
|
87
|
+
RECONCILIATION_FAILED: "RECONCILIATION_FAILED";
|
|
88
|
+
ROUTE_CONFLICT: "ROUTE_CONFLICT";
|
|
89
|
+
}>>;
|
|
90
|
+
}, z.core.$strict>>;
|
|
91
|
+
error: z.ZodOptional<z.ZodString>;
|
|
92
|
+
}, z.core.$strict>;
|
|
93
|
+
export declare const GITHUB_COPILOT_MIGRATION_STATUS_TYPE_SYMBOL = "dsh-github-copilot#GitHubCopilotMigrationStatus";
|
|
94
|
+
/** Independent Ops result: strict at every object level; no account or private Session data. */
|
|
95
|
+
export declare const GitHubCopilotMigrationStatusSchema: z.ZodObject<{
|
|
96
|
+
plugin: z.ZodObject<{
|
|
97
|
+
name: z.ZodLiteral<"dsh-github-copilot">;
|
|
98
|
+
version: z.ZodString;
|
|
99
|
+
}, z.core.$strict>;
|
|
100
|
+
protocolVersion: z.ZodLiteral<1>;
|
|
101
|
+
historyScope: z.ZodLiteral<"live-agents-only">;
|
|
102
|
+
observedAt: z.ZodNumber;
|
|
103
|
+
capabilities: z.ZodObject<{
|
|
104
|
+
agentsList: z.ZodBoolean;
|
|
105
|
+
sessionProjections: z.ZodBoolean;
|
|
106
|
+
settingsCas: z.ZodBoolean;
|
|
107
|
+
providerRegistry: z.ZodBoolean;
|
|
108
|
+
defaultSelection: z.ZodBoolean;
|
|
109
|
+
}, z.core.$strict>;
|
|
110
|
+
complete: z.ZodObject<{
|
|
111
|
+
sessions: z.ZodBoolean;
|
|
112
|
+
defaultSelection: z.ZodBoolean;
|
|
113
|
+
routes: z.ZodBoolean;
|
|
114
|
+
}, z.core.$strict>;
|
|
115
|
+
defaultSelection: z.ZodNullable<z.ZodObject<{
|
|
116
|
+
provider: z.ZodString;
|
|
117
|
+
model: z.ZodString;
|
|
118
|
+
reasoningEffort: z.ZodOptional<z.ZodString>;
|
|
119
|
+
}, z.core.$strict>>;
|
|
120
|
+
sessions: z.ZodArray<z.ZodObject<{
|
|
121
|
+
id: z.ZodString;
|
|
122
|
+
status: z.ZodEnum<{
|
|
123
|
+
idle: "idle";
|
|
124
|
+
running: "running";
|
|
125
|
+
}>;
|
|
126
|
+
effectiveSelection: z.ZodNullable<z.ZodObject<{
|
|
127
|
+
provider: z.ZodString;
|
|
128
|
+
model: z.ZodString;
|
|
129
|
+
reasoningEffort: z.ZodOptional<z.ZodString>;
|
|
130
|
+
}, z.core.$strict>>;
|
|
131
|
+
selectionSource: z.ZodEnum<{
|
|
132
|
+
default: "default";
|
|
133
|
+
pending: "pending";
|
|
134
|
+
"request-header": "request-header";
|
|
135
|
+
unknown: "unknown";
|
|
136
|
+
}>;
|
|
137
|
+
activeRequestSelection: z.ZodNullable<z.ZodObject<{
|
|
138
|
+
provider: z.ZodString;
|
|
139
|
+
model: z.ZodString;
|
|
140
|
+
reasoningEffort: z.ZodOptional<z.ZodString>;
|
|
141
|
+
}, z.core.$strict>>;
|
|
142
|
+
}, z.core.$strict>>;
|
|
143
|
+
routes: z.ZodObject<{
|
|
144
|
+
nativeConfigured: z.ZodNullable<z.ZodBoolean>;
|
|
145
|
+
nativeRegistered: z.ZodNullable<z.ZodBoolean>;
|
|
146
|
+
managedRegistered: z.ZodNullable<z.ZodBoolean>;
|
|
147
|
+
}, z.core.$strict>;
|
|
148
|
+
}, z.core.$strict>;
|
|
149
|
+
declare const contribution: TypertRemoteContribution;
|
|
150
|
+
export default contribution;
|
|
151
|
+
//# sourceMappingURL=remote.d.ts.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** Public Responses reasoning text only; encrypted replay payloads are never read. */
|
|
2
|
+
type Family = 'summary' | 'raw';
|
|
3
|
+
export declare function responseIndex(value: unknown): number | undefined;
|
|
4
|
+
/**
|
|
5
|
+
* Append-only public text for one output item. Snapshots complete streamed
|
|
6
|
+
* prefixes rather than repeating them. If both public representations occur,
|
|
7
|
+
* stream the first and retain the other until item end so an identical mirror
|
|
8
|
+
* can be omitted without dropping a distinct public summary.
|
|
9
|
+
*/
|
|
10
|
+
export declare class ResponsesReasoningText {
|
|
11
|
+
private family;
|
|
12
|
+
private readonly parts;
|
|
13
|
+
private emitted;
|
|
14
|
+
private finished;
|
|
15
|
+
get text(): string;
|
|
16
|
+
private render;
|
|
17
|
+
update(family: Family, index: unknown, value: unknown, done: boolean): string;
|
|
18
|
+
/** Only recognized public text fields are examined; no copying of the item. */
|
|
19
|
+
snapshot(item: unknown): string;
|
|
20
|
+
/** Flush a distinct secondary representation, including on failure/abort. */
|
|
21
|
+
finish(): string;
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=responses-reasoning-text.d.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
2
|
+
import type { GenerateOptions } from '@deepseek-ai/dsh-llm';
|
|
3
|
+
import type { SearchPlanCandidate } from './plan.ts';
|
|
4
|
+
import type { ResponsesReasoningOptions } from './serialize.ts';
|
|
5
|
+
/** Resolve only the selected model's declared/native efforts, with the same precedence as Core. */
|
|
6
|
+
export declare function resolveCopilotResponsesReasoning(ctx: Context, request: GenerateOptions, candidate: Pick<SearchPlanCandidate, 'protocol' | 'model'>): ResponsesReasoningOptions | undefined;
|
|
7
|
+
//# sourceMappingURL=responses-reasoning.d.ts.map
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/** Journal provenance only; process identity is not namespace lifetime evidence. */
|
|
2
|
+
export declare const ROUTE_OWNERSHIP_EPOCH: `${string}-${string}-${string}-${string}-${string}`;
|
|
3
|
+
export type RouteMutation = {
|
|
4
|
+
readonly op: 'set';
|
|
5
|
+
readonly path: string[];
|
|
6
|
+
readonly value: unknown;
|
|
7
|
+
} | {
|
|
8
|
+
readonly op: 'unset';
|
|
9
|
+
readonly path: string[];
|
|
10
|
+
};
|
|
11
|
+
export interface RouteSettings {
|
|
12
|
+
get(namespace: string): unknown;
|
|
13
|
+
describe(options?: {
|
|
14
|
+
redactSecrets?: boolean;
|
|
15
|
+
}): Array<{
|
|
16
|
+
ns: string;
|
|
17
|
+
revision: number;
|
|
18
|
+
user?: unknown;
|
|
19
|
+
base?: unknown;
|
|
20
|
+
secrets?: readonly {
|
|
21
|
+
path: readonly string[];
|
|
22
|
+
set: boolean;
|
|
23
|
+
}[];
|
|
24
|
+
}>;
|
|
25
|
+
mutate(namespace: string, operations: readonly RouteMutation[], expectedRevision?: number): Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
export declare class TemporaryRouteConflictError extends Error {
|
|
28
|
+
readonly code: 'TEMPORARY_ROUTE_OWNERSHIP_CONFLICT' | 'TEMPORARY_ROUTE_LEGACY_CONFLICT' | 'TEMPORARY_ROUTE_INVALID_BACKUP';
|
|
29
|
+
constructor(code?: 'TEMPORARY_ROUTE_OWNERSHIP_CONFLICT' | 'TEMPORARY_ROUTE_LEGACY_CONFLICT' | 'TEMPORARY_ROUTE_INVALID_BACKUP');
|
|
30
|
+
}
|
|
31
|
+
export declare function object(value: unknown): Record<string, unknown> | undefined;
|
|
32
|
+
export declare function profileAt(value: unknown): Record<string, unknown> | undefined;
|
|
33
|
+
/** Bounded comparison; never stringify or copy unknown model extras or headers. */
|
|
34
|
+
export declare function equalJson(a: unknown, b: unknown, depth?: number): boolean;
|
|
35
|
+
interface Leaves {
|
|
36
|
+
readonly api?: string;
|
|
37
|
+
readonly models?: readonly Record<string, unknown>[];
|
|
38
|
+
}
|
|
39
|
+
export interface RouteBackup {
|
|
40
|
+
readonly version: 2;
|
|
41
|
+
readonly providerExisted: boolean;
|
|
42
|
+
readonly preimage: Leaves;
|
|
43
|
+
readonly postimage: Leaves;
|
|
44
|
+
readonly ownedHeaders: Readonly<Record<string, string>>;
|
|
45
|
+
readonly phase: 'overlay' | 'restoring';
|
|
46
|
+
readonly sourceRevision: number;
|
|
47
|
+
readonly sourceEpoch: string;
|
|
48
|
+
readonly target?: Leaves;
|
|
49
|
+
readonly removeProfile?: boolean;
|
|
50
|
+
}
|
|
51
|
+
export declare function leavesOf(profile: Record<string, unknown> | undefined): Leaves;
|
|
52
|
+
export declare function encodeBackup(backup: RouteBackup): string;
|
|
53
|
+
export declare function readBackup(value: unknown): RouteBackup | undefined;
|
|
54
|
+
export declare function settingsSnapshot(settings: RouteSettings): {
|
|
55
|
+
current: Record<string, unknown> | undefined;
|
|
56
|
+
raw: Record<string, unknown> | undefined;
|
|
57
|
+
base: Record<string, unknown> | undefined;
|
|
58
|
+
hasSecrets: boolean;
|
|
59
|
+
hasOwnedSecrets: boolean;
|
|
60
|
+
routeRevision: number;
|
|
61
|
+
markerRevision: number;
|
|
62
|
+
backup: RouteBackup | undefined;
|
|
63
|
+
};
|
|
64
|
+
export declare function assertOwned(current: Record<string, unknown> | undefined, backup: RouteBackup): 'preimage' | 'postimage' | 'target';
|
|
65
|
+
export declare function leafOperations(current: Record<string, unknown> | undefined, target: Leaves): RouteMutation[];
|
|
66
|
+
export declare function ownedHeaderRemoval(current: Record<string, unknown> | undefined, backup: RouteBackup): RouteMutation[];
|
|
67
|
+
/** Raw shape, not schema-resolved defaults, proves whole-profile ownership. */
|
|
68
|
+
export declare function wholeProfileOwned(snapshot: ReturnType<typeof settingsSnapshot>, backup: RouteBackup): boolean;
|
|
69
|
+
export {};
|
|
70
|
+
//# sourceMappingURL=route-ownership.d.ts.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
2
|
+
import { WebRuntime } from '@deepseek-ai/dsh-web';
|
|
3
|
+
import type { WebRuntimeConfig, WebSearchRequest, WebSearchResult, WebSearchProvider, WebFetchProvider, WebFetchRequest, WebFetchResult } from '@deepseek-ai/dsh-web';
|
|
4
|
+
/** Parent dispatch captured from the exact WebRuntime instance serving this call. */
|
|
5
|
+
export type NativeSearch = (request: WebSearchRequest, signal?: AbortSignal) => Promise<WebSearchResult>;
|
|
6
|
+
/** Exact-id dispatch over providers registered through the routed facade. */
|
|
7
|
+
export type ProviderSearch = (providerId: string, request: WebSearchRequest, signal?: AbortSignal) => Promise<WebSearchResult>;
|
|
8
|
+
/** Host-owned router; credentials and provider implementation objects stay inside the facade. */
|
|
9
|
+
export interface GitHubCopilotSearchRouter {
|
|
10
|
+
search(request: WebSearchRequest, signal: AbortSignal | undefined, delegate: NativeSearch, selectProvider?: ProviderSearch): Promise<WebSearchResult>;
|
|
11
|
+
}
|
|
12
|
+
declare module '@deepseek-ai/cordis' {
|
|
13
|
+
interface Context {
|
|
14
|
+
githubCopilotSearchRouter: GitHubCopilotSearchRouter;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Plugin-owned WebRuntime facade. The bundle isolates, but does not reconfigure,
|
|
19
|
+
* the original official service. Normal search, fetch and registrations delegate
|
|
20
|
+
* through its public APIs. A second private official WebRuntime supplies the same
|
|
21
|
+
* validation/source cap for the Copilot branch. No Core prototypes or private
|
|
22
|
+
* registries are read or changed.
|
|
23
|
+
*/
|
|
24
|
+
export default class CopilotRoutedWeb extends WebRuntime {
|
|
25
|
+
static inject: string[];
|
|
26
|
+
private readonly bounded;
|
|
27
|
+
private readonly lifetime;
|
|
28
|
+
private readonly pending;
|
|
29
|
+
private readonly mirroredSearchProviders;
|
|
30
|
+
constructor(ctx: Context, config?: WebRuntimeConfig);
|
|
31
|
+
private disposedError;
|
|
32
|
+
private searchWithProvider;
|
|
33
|
+
registerSearchProvider(provider: WebSearchProvider): () => void;
|
|
34
|
+
registerFetchProvider(provider: WebFetchProvider): () => void;
|
|
35
|
+
fetch(request: WebFetchRequest, signal?: AbortSignal): Promise<WebFetchResult>;
|
|
36
|
+
search(request: WebSearchRequest, signal?: AbortSignal): Promise<WebSearchResult>;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=routed-web.d.ts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { WebError } from '@deepseek-ai/dsh-web';
|
|
2
|
+
/** Safe request-option leaves; never includes auth, URL path/query or opaque provider state. */
|
|
3
|
+
export interface SearchBackend {
|
|
4
|
+
readonly provider: 'deepseek-official';
|
|
5
|
+
readonly origin: string;
|
|
6
|
+
readonly model: string;
|
|
7
|
+
readonly customEndpoint: boolean;
|
|
8
|
+
}
|
|
9
|
+
/** Bounded metadata included in the same query's successful or failed fallback notice. */
|
|
10
|
+
export declare function describeSearchBackend(backend: SearchBackend): string;
|
|
11
|
+
/** Known sanitized failure, distinct from arbitrary native provider exception messages. */
|
|
12
|
+
export declare class DescribedSearchFallbackError extends WebError {
|
|
13
|
+
readonly backend: SearchBackend | undefined;
|
|
14
|
+
constructor(backend: SearchBackend | undefined, code?: WebError['code']);
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=search-backend.d.ts.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { WebSearchProvider, WebSearchRequest, WebSearchResult } from '@deepseek-ai/dsh-web';
|
|
2
|
+
/** Explicit cross-provider spending policy; disabled unless the operator selects DeepSeek. */
|
|
3
|
+
export type SearchFallback = 'none' | 'deepseek';
|
|
4
|
+
/** Selection captured from the initiating request, never from a global default. */
|
|
5
|
+
export interface SearchSelection {
|
|
6
|
+
readonly provider: string;
|
|
7
|
+
readonly model: string;
|
|
8
|
+
}
|
|
9
|
+
/** Public, non-secret provenance retained outside the canonical WebSearchResult. */
|
|
10
|
+
export interface SearchRouting {
|
|
11
|
+
readonly requestedProvider: 'github-copilot-hosted';
|
|
12
|
+
readonly actualProvider: 'github-copilot-hosted' | 'deepseek-official';
|
|
13
|
+
readonly model: string;
|
|
14
|
+
readonly fallback: boolean;
|
|
15
|
+
readonly reason?: string;
|
|
16
|
+
}
|
|
17
|
+
/** Delegated results have no plugin provenance and retain their original object identity. */
|
|
18
|
+
export interface RoutedSearchResult {
|
|
19
|
+
readonly result: WebSearchResult;
|
|
20
|
+
readonly routing?: SearchRouting;
|
|
21
|
+
}
|
|
22
|
+
/** Operation-local dependencies; providers must be owned instances, not private-registry lookups. */
|
|
23
|
+
export interface SessionSearchDependencies {
|
|
24
|
+
readonly selection: SearchSelection | undefined;
|
|
25
|
+
readonly managedOwned: boolean;
|
|
26
|
+
readonly fallback: SearchFallback;
|
|
27
|
+
readonly copilot: WebSearchProvider;
|
|
28
|
+
readonly delegate: (request: WebSearchRequest, signal?: AbortSignal) => Promise<WebSearchResult>;
|
|
29
|
+
readonly resolveDeepSeek: () => Promise<WebSearchProvider>;
|
|
30
|
+
/** Recheck captured owner/account generation after every asynchronous boundary. */
|
|
31
|
+
readonly canContinue: () => boolean;
|
|
32
|
+
}
|
|
33
|
+
/** Match only the canonical route or a verified plugin-owned managed route. */
|
|
34
|
+
export declare function isCopilotSearchSelection(selection: SearchSelection | undefined, managedOwned: boolean): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Route one already-validated search using captured request identity.
|
|
37
|
+
* Non-Copilot calls delegate untouched. Copilot failures reach a known DeepSeek
|
|
38
|
+
* provider only under the explicit spending policy; cancellation and invalidated
|
|
39
|
+
* ownership never trigger fallback. Consumer validation, batching and deadlines
|
|
40
|
+
* remain the caller's responsibility, not this provider-selection function.
|
|
41
|
+
*/
|
|
42
|
+
export declare function routeSessionSearch(request: WebSearchRequest, signal: AbortSignal | undefined, deps: SessionSearchDependencies): Promise<RoutedSearchResult>;
|
|
43
|
+
//# sourceMappingURL=search-routing.d.ts.map
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Text/tool serialization for the inline wire path, plus server-side web
|
|
3
|
+
* search injection. Reasoning and opaque replay histories remain Core-owned;
|
|
4
|
+
* this limited serializer refuses them instead of inventing Responses items.
|
|
5
|
+
* @module dsh-github-copilot/serialize
|
|
6
|
+
*/
|
|
7
|
+
import type { ContentBlock, GenerateOptions, Message, ToolSchema } from '@deepseek-ai/dsh-llm';
|
|
8
|
+
import type { ResponsesWebSearchToolType } from './plan.ts';
|
|
9
|
+
import type { InlineConfig } from './config.ts';
|
|
10
|
+
/** Mapped only after the selected model's native capability checks succeed. */
|
|
11
|
+
export interface ResponsesReasoningOptions {
|
|
12
|
+
readonly effort: string;
|
|
13
|
+
readonly summary: 'auto';
|
|
14
|
+
}
|
|
15
|
+
/** Keep Core-owned reasoning provenance and opaque replay state out of this serializer. */
|
|
16
|
+
export declare function hasResponsesReplayContext(messages: readonly Message[]): boolean;
|
|
17
|
+
/** Thrown for content whose projection must remain with Core. */
|
|
18
|
+
export declare class UnsupportedContentError extends Error {
|
|
19
|
+
constructor(detail: string);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Stable short hash (FNV-1a variant) for synthesizing item ids.
|
|
23
|
+
* @param input - any string.
|
|
24
|
+
* @returns an 8-character base36 string.
|
|
25
|
+
*/
|
|
26
|
+
export declare function shortHash(input: string): string;
|
|
27
|
+
/**
|
|
28
|
+
* Split a harness call id into the Responses `call_id`/`id` pair. Harness
|
|
29
|
+
* ids produced by the pi-ai adapter carry the `call_id|item_id` shape; ids
|
|
30
|
+
* from other origins get a synthesized item id.
|
|
31
|
+
* @param id - the harness tool-call id.
|
|
32
|
+
* @returns the call id and item id.
|
|
33
|
+
*/
|
|
34
|
+
export declare function splitCallId(id: string): {
|
|
35
|
+
callId: string;
|
|
36
|
+
itemId: string;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Concatenate the text blocks of a content array.
|
|
40
|
+
* @param content - the message content blocks.
|
|
41
|
+
* @returns the joined text.
|
|
42
|
+
*/
|
|
43
|
+
export declare function flattenText(content: readonly ContentBlock[]): string;
|
|
44
|
+
/**
|
|
45
|
+
* Serialize one dsh message into Responses input items.
|
|
46
|
+
* @param message - the harness message.
|
|
47
|
+
* @returns the wire input items; may be empty for content-free messages.
|
|
48
|
+
* @throws UnsupportedContentError for image or Core-owned reasoning/replay content.
|
|
49
|
+
*/
|
|
50
|
+
export declare function serializeMessage(message: Message, pairedCallIds?: ReadonlySet<string>): unknown[];
|
|
51
|
+
/**
|
|
52
|
+
* Return call ids that have both an assistant function call and a user tool
|
|
53
|
+
* result. Responses rejects either half when replayed alone, which can happen
|
|
54
|
+
* when a prior provider/tool failure ended the step before persistence wrote
|
|
55
|
+
* the matching result.
|
|
56
|
+
*/
|
|
57
|
+
export declare function pairedToolCallIds(messages: readonly Message[]): ReadonlySet<string>;
|
|
58
|
+
/**
|
|
59
|
+
* Build the wire tools array: function tools (optionally stripped of the
|
|
60
|
+
* variants shadowed by server-side web tools) plus the server-side web
|
|
61
|
+
* search tool in the candidate's verified spelling.
|
|
62
|
+
* @param tools - the harness tool schemas.
|
|
63
|
+
* @param stripServerTools - whether to drop the shadowed function variants.
|
|
64
|
+
* @param webSearchToolType - the Responses spelling the probe verified.
|
|
65
|
+
* @returns the wire tools array.
|
|
66
|
+
*/
|
|
67
|
+
export declare function wireTools(tools: readonly ToolSchema[] | undefined, stripServerTools: boolean, webSearchToolType: ResponsesWebSearchToolType): unknown[];
|
|
68
|
+
/**
|
|
69
|
+
* Build the complete Responses request body for one inline call.
|
|
70
|
+
* @param request - the harness request.
|
|
71
|
+
* @param cfg - the wire controls.
|
|
72
|
+
* @param model - the model the plan resolved (config override or the loop's
|
|
73
|
+
* route model); the same model the capability probe verified.
|
|
74
|
+
* @param webSearchToolType - the Responses spelling the probe verified; the
|
|
75
|
+
* wire must send exactly the spelling that passed.
|
|
76
|
+
* @returns the JSON body to POST.
|
|
77
|
+
*/
|
|
78
|
+
export declare function buildWireBody(request: GenerateOptions, cfg: Pick<InlineConfig, 'includeSources' | 'stripServerTools'>, model: string, webSearchToolType: ResponsesWebSearchToolType, reasoning?: ResponsesReasoningOptions): unknown;
|
|
79
|
+
/**
|
|
80
|
+
* Build the Anthropic Messages wire tools array: function tools (optionally
|
|
81
|
+
* stripped of the `web_search` variant, which shadows the server-side tool)
|
|
82
|
+
* plus the server-side web search tool. Function tools carry no `type`.
|
|
83
|
+
* @param tools - the harness tool schemas.
|
|
84
|
+
* @param stripServerTools - whether to drop the shadowed function variants.
|
|
85
|
+
* @returns the wire tools array.
|
|
86
|
+
*/
|
|
87
|
+
export declare function anthropicWireTools(tools: readonly ToolSchema[] | undefined, stripServerTools: boolean): unknown[];
|
|
88
|
+
/**
|
|
89
|
+
* Serialize one dsh message into Anthropic Messages content items.
|
|
90
|
+
* Assistant messages aggregate their blocks into one content array
|
|
91
|
+
* (reasoning without a usable signature becomes plain text).
|
|
92
|
+
* @param message - the harness message.
|
|
93
|
+
* @returns the Anthropic content items for this message.
|
|
94
|
+
* @throws UnsupportedContentError for image content.
|
|
95
|
+
*/
|
|
96
|
+
export declare function serializeAnthropicMessage(message: Message): unknown[];
|
|
97
|
+
/**
|
|
98
|
+
* Build the complete Anthropic Messages request body for one inline call.
|
|
99
|
+
* The system prompt goes to the top-level `system` field (unlike the
|
|
100
|
+
* Responses wire, the Anthropic gateway keeps server-side web_search native
|
|
101
|
+
* with a top-level system).
|
|
102
|
+
* @param request - the harness request.
|
|
103
|
+
* @param cfg - the wire controls.
|
|
104
|
+
* @param model - the model the plan resolved (config override or the loop's
|
|
105
|
+
* route model); the same model the capability probe verified.
|
|
106
|
+
* @returns the JSON body to POST.
|
|
107
|
+
*/
|
|
108
|
+
export declare function buildAnthropicWireBody(request: GenerateOptions, cfg: Pick<InlineConfig, 'stripServerTools'>, model: string): unknown;
|
|
109
|
+
//# sourceMappingURL=serialize.d.ts.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bounded SSE line parser for the inline wire path. Handles `event:` and
|
|
3
|
+
* `data:` fields, multi-line data, CRLF, comments, and trailing events
|
|
4
|
+
* without a final blank line; unknown fields are ignored and oversized
|
|
5
|
+
* individual events are rejected.
|
|
6
|
+
* @module dsh-github-copilot/sse
|
|
7
|
+
*/
|
|
8
|
+
/** Upper bound on one incomplete SSE event, in bytes. */
|
|
9
|
+
export declare const MAX_SSE_EVENT_BYTES: number;
|
|
10
|
+
/** Stable error raised when one incomplete SSE event exceeds its byte bound. */
|
|
11
|
+
export declare class SseEventSizeError extends Error {
|
|
12
|
+
readonly limit: number;
|
|
13
|
+
constructor();
|
|
14
|
+
}
|
|
15
|
+
/** One parsed SSE event; `type` falls back to `message`. */
|
|
16
|
+
export interface SseEvent {
|
|
17
|
+
readonly type: string;
|
|
18
|
+
readonly data: unknown;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Parse an SSE byte stream into typed events.
|
|
22
|
+
* @param body - the response body stream.
|
|
23
|
+
* @returns an async generator of parsed events.
|
|
24
|
+
* @throws on invalid JSON or when one event exceeds
|
|
25
|
+
* {@link MAX_SSE_EVENT_BYTES}.
|
|
26
|
+
*/
|
|
27
|
+
export declare function parseSse(body: ReadableStream<Uint8Array>): AsyncGenerator<SseEvent>;
|
|
28
|
+
//# sourceMappingURL=sse.d.ts.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Api } from '@earendil-works/pi-ai';
|
|
2
|
+
import type { CopilotModelFacts } from './model-protocol.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Narrow compatibility metadata for account models that GitHub releases before
|
|
5
|
+
* the published pi-ai Copilot catalog catches up. Correct native protocol and
|
|
6
|
+
* capability metadata retire the correction; a matching ID alone does not.
|
|
7
|
+
*/
|
|
8
|
+
export interface TemporaryGitHubCopilotModel {
|
|
9
|
+
readonly id: string;
|
|
10
|
+
readonly name: string;
|
|
11
|
+
readonly api: Api;
|
|
12
|
+
readonly baseUrl: string;
|
|
13
|
+
readonly contextWindow: number;
|
|
14
|
+
readonly maxTokens: number;
|
|
15
|
+
readonly input: readonly ('text' | 'image')[];
|
|
16
|
+
readonly reasoningEfforts: Readonly<Record<string, string | null>>;
|
|
17
|
+
readonly headers: Readonly<Record<string, string>>;
|
|
18
|
+
}
|
|
19
|
+
/** Return a narrow correction until the native entry supplies the verified capabilities. */
|
|
20
|
+
export declare function temporaryGitHubCopilotModel(modelId: string, installedModels: ReadonlyMap<string, CopilotModelFacts>, nativeAuthoritative?: boolean): TemporaryGitHubCopilotModel | undefined;
|
|
21
|
+
/** Minimal llm-pi-ai settings entry for one temporary model. */
|
|
22
|
+
export declare function temporaryGitHubCopilotModelProfile(model: TemporaryGitHubCopilotModel): Record<string, unknown>;
|
|
23
|
+
/** Recognize metadata written by this overlay without matching user-owned extras. */
|
|
24
|
+
export declare function temporaryGitHubCopilotModelFromProfile(value: Readonly<Record<string, unknown>>): TemporaryGitHubCopilotModel | undefined;
|
|
25
|
+
//# sourceMappingURL=temporary-models.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
2
|
+
import type { ToolSchema } from '@deepseek-ai/dsh-llm';
|
|
3
|
+
interface PromptAssemblyView {
|
|
4
|
+
readonly variables: Readonly<Record<string, string | undefined>>;
|
|
5
|
+
readonly tools: readonly ToolSchema[];
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Copilot models repeatedly emit optional arguments even when runtime state
|
|
9
|
+
* makes them invalid. Remove unusable sandbox escalation fields and expose the
|
|
10
|
+
* multi-action Goal update as a discriminated union, so each action advertises
|
|
11
|
+
* only its legal fields. Other model providers retain the original schemas.
|
|
12
|
+
*/
|
|
13
|
+
export declare function filterCopilotToolAssembly<T extends PromptAssemblyView>(assembly: T, ownedPreview?: boolean): T;
|
|
14
|
+
/** Install the provider-scoped filter after Agent model selection has run. */
|
|
15
|
+
export declare function installCopilotToolSchemaCompatibility(ctx: Context): void;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=tool-schema-compat.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Traditional `ctx.web` search provider backed by a verified OpenAI Responses
|
|
3
|
+
* candidate. This is intentionally search-only: URL fetching remains owned by
|
|
4
|
+
* dedicated anonymous fetch providers.
|
|
5
|
+
* @module dsh-github-copilot/traditional-search
|
|
6
|
+
*/
|
|
7
|
+
import type { WebSearchProvider } from '@deepseek-ai/dsh-web';
|
|
8
|
+
import type { InlineConfig } from './config.ts';
|
|
9
|
+
import type { SearchPlan } from './plan.ts';
|
|
10
|
+
import type { InlineHooks } from './wire.ts';
|
|
11
|
+
/** Stable provider id selected through `web.searchProvider`. */
|
|
12
|
+
export declare const GITHUB_COPILOT_HOSTED_SEARCH_PROVIDER_ID = "github-copilot-hosted";
|
|
13
|
+
/** @deprecated Use {@link GITHUB_COPILOT_HOSTED_SEARCH_PROVIDER_ID}. */
|
|
14
|
+
export declare const COPILOT_HOSTED_SEARCH_PROVIDER_ID = "github-copilot-hosted";
|
|
15
|
+
/** Build the search-only provider registered with `ctx.web`. */
|
|
16
|
+
export declare function createTraditionalSearchProvider(available: () => boolean, plan: (signal?: AbortSignal) => SearchPlan | Promise<SearchPlan>, hooks: InlineHooks, config: () => InlineConfig, unavailableMessage?: string): WebSearchProvider;
|
|
17
|
+
//# sourceMappingURL=traditional-search.d.ts.map
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider-private wire types for the two search-capable protocols this
|
|
3
|
+
* package speaks, restricted to the shapes the capability probe consumes:
|
|
4
|
+
* the OpenAI Responses API `web_search_call` evidence item and the
|
|
5
|
+
* Anthropic-compatible Messages API `web_search_tool_result` block. The
|
|
6
|
+
* probe's verdict is structural — a reply containing the evidence item means
|
|
7
|
+
* the endpoint executed native search inside the request.
|
|
8
|
+
* @module dsh-github-copilot/types
|
|
9
|
+
*/
|
|
10
|
+
/** A `web_search_call` output item: evidence that the server ran the tool. */
|
|
11
|
+
export interface WebSearchCallItem {
|
|
12
|
+
readonly type: 'web_search_call';
|
|
13
|
+
readonly id?: string;
|
|
14
|
+
readonly status?: string;
|
|
15
|
+
readonly action?: {
|
|
16
|
+
readonly sources?: readonly ResponsesWebSearchSource[];
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/** One Responses citation or search source. */
|
|
20
|
+
export interface ResponsesWebSearchSource {
|
|
21
|
+
readonly url?: string;
|
|
22
|
+
readonly title?: string;
|
|
23
|
+
readonly snippet?: string;
|
|
24
|
+
readonly published_at?: string;
|
|
25
|
+
}
|
|
26
|
+
/** One annotation on generated output text. */
|
|
27
|
+
export interface ResponsesAnnotation extends ResponsesWebSearchSource {
|
|
28
|
+
readonly type?: string;
|
|
29
|
+
}
|
|
30
|
+
/** Generated output text carrying optional URL citations. */
|
|
31
|
+
export interface ResponsesOutputText {
|
|
32
|
+
readonly type: 'output_text';
|
|
33
|
+
readonly text?: string;
|
|
34
|
+
readonly annotations?: readonly ResponsesAnnotation[];
|
|
35
|
+
}
|
|
36
|
+
/** A generated message in a non-streamed Responses envelope. */
|
|
37
|
+
export interface ResponsesMessageItem {
|
|
38
|
+
readonly type: 'message';
|
|
39
|
+
readonly content?: readonly ResponsesOutputText[];
|
|
40
|
+
}
|
|
41
|
+
/** Any output item consumed by the probe or traditional-search bridge. */
|
|
42
|
+
export type ResponseOutputItem = WebSearchCallItem | ResponsesMessageItem | {
|
|
43
|
+
readonly type: string;
|
|
44
|
+
};
|
|
45
|
+
/** The non-streamed Responses envelope the probe parses. */
|
|
46
|
+
export interface ResponsesResponse {
|
|
47
|
+
readonly id?: string;
|
|
48
|
+
readonly status?: string;
|
|
49
|
+
readonly output?: readonly ResponseOutputItem[];
|
|
50
|
+
}
|
|
51
|
+
/** A `web_search_result` item inside a `web_search_tool_result` block. */
|
|
52
|
+
export interface WebSearchResultItem {
|
|
53
|
+
readonly type: string;
|
|
54
|
+
readonly url: string;
|
|
55
|
+
}
|
|
56
|
+
/** A `web_search_tool_result` content block: the citeable result shape. */
|
|
57
|
+
export interface WebSearchToolResultBlock {
|
|
58
|
+
readonly type: 'web_search_tool_result';
|
|
59
|
+
readonly content?: readonly WebSearchResultItem[];
|
|
60
|
+
}
|
|
61
|
+
/** Any content block; only `web_search_tool_result` is consumed by the probe. */
|
|
62
|
+
export type ContentBlock = WebSearchToolResultBlock | {
|
|
63
|
+
readonly type: string;
|
|
64
|
+
};
|
|
65
|
+
/** The Messages response envelope the probe parses. */
|
|
66
|
+
export interface AnthropicResponse {
|
|
67
|
+
readonly content?: readonly ContentBlock[];
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Usage mapping for the inline wire path: Responses-API usage objects
|
|
3
|
+
* project onto the harness TokenUsage shape exactly like the pi-ai adapter
|
|
4
|
+
* (input minus cached, cache and reasoning split out as separate fields).
|
|
5
|
+
* @module dsh-github-copilot/usage
|
|
6
|
+
*/
|
|
7
|
+
import type { TokenUsage } from '@deepseek-ai/dsh-llm';
|
|
8
|
+
/** The usage object carried by `response.completed` / `response.incomplete` (snake_case wire fields). */
|
|
9
|
+
export interface WireUsage {
|
|
10
|
+
readonly input_tokens: number;
|
|
11
|
+
readonly output_tokens: number;
|
|
12
|
+
readonly total_tokens: number;
|
|
13
|
+
readonly input_tokens_details?: {
|
|
14
|
+
readonly cached_tokens?: number;
|
|
15
|
+
};
|
|
16
|
+
readonly output_tokens_details?: {
|
|
17
|
+
readonly reasoning_tokens?: number;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Map a wire usage object to the harness TokenUsage shape.
|
|
22
|
+
* @param usage - the provider usage object (snake_case wire fields).
|
|
23
|
+
* @returns the harness usage; cache and reasoning fields are omitted when absent.
|
|
24
|
+
*/
|
|
25
|
+
export declare function mapUsage(usage: WireUsage): TokenUsage;
|
|
26
|
+
//# sourceMappingURL=usage.d.ts.map
|