@eddyskywalker/dsh-chatgpt-subscription 0.5.0 → 0.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 +34 -1
- package/README.md +67 -1
- package/lib/client.js +1566 -222
- package/lib/client.js.map +1 -1
- package/lib/index.js +4882 -1114
- package/lib/types/client/ProviderHubSection.d.ts.map +1 -1
- package/lib/types/client/common/AccountPoolSection.d.ts +14 -0
- package/lib/types/client/common/AccountPoolSection.d.ts.map +1 -1
- package/lib/types/client/index.d.ts +1 -0
- package/lib/types/client/index.d.ts.map +1 -1
- package/lib/types/client/workbuddy/WorkBuddyComposerQuota.d.ts +26 -0
- package/lib/types/client/workbuddy/WorkBuddyComposerQuota.d.ts.map +1 -0
- package/lib/types/client/workbuddy/WorkBuddySection.d.ts +41 -0
- package/lib/types/client/workbuddy/WorkBuddySection.d.ts.map +1 -0
- package/lib/types/client/workbuddy/locales.d.ts +563 -0
- package/lib/types/client/workbuddy/locales.d.ts.map +1 -0
- package/lib/types/client/workbuddy/styles.d.ts +11 -0
- package/lib/types/client/workbuddy/styles.d.ts.map +1 -0
- package/lib/types/host/common/account-pool.d.ts +18 -0
- package/lib/types/host/common/account-pool.d.ts.map +1 -1
- package/lib/types/host/workbuddy/account-pool.d.ts +106 -0
- package/lib/types/host/workbuddy/account-pool.d.ts.map +1 -0
- package/lib/types/host/workbuddy/adapter.d.ts +97 -0
- package/lib/types/host/workbuddy/adapter.d.ts.map +1 -0
- package/lib/types/host/workbuddy/client.d.ts +90 -0
- package/lib/types/host/workbuddy/client.d.ts.map +1 -0
- package/lib/types/host/workbuddy/mapper.d.ts +114 -0
- package/lib/types/host/workbuddy/mapper.d.ts.map +1 -0
- package/lib/types/host/workbuddy/model-catalog.d.ts +108 -0
- package/lib/types/host/workbuddy/model-catalog.d.ts.map +1 -0
- package/lib/types/host/workbuddy/oauth.d.ts +38 -0
- package/lib/types/host/workbuddy/oauth.d.ts.map +1 -0
- package/lib/types/host/workbuddy/routes.d.ts +33 -0
- package/lib/types/host/workbuddy/routes.d.ts.map +1 -0
- package/lib/types/host/workbuddy/token-store.d.ts +216 -0
- package/lib/types/host/workbuddy/token-store.d.ts.map +1 -0
- package/lib/types/host/workbuddy/types.d.ts +127 -0
- package/lib/types/host/workbuddy/types.d.ts.map +1 -0
- package/lib/types/index.d.ts +5 -0
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/shared/account-pool-contracts.d.ts +8 -0
- package/lib/types/shared/account-pool-contracts.d.ts.map +1 -1
- package/lib/types/shared/workbuddy-contracts.d.ts +204 -0
- package/lib/types/shared/workbuddy-contracts.d.ts.map +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account-pool.d.ts","sourceRoot":"","sources":["../../../../src/host/common/account-pool.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAIxD,OAAO,KAAK,EACV,iBAAiB,EACjB,uBAAuB,EACvB,qBAAqB,EACtB,MAAM,wCAAwC,CAAA;AAE/C,wEAAwE;AACxE,eAAO,MAAM,sBAAsB,QAAS,CAAA;AAK5C,+EAA+E;AAC/E,eAAO,MAAM,yBAAyB,KAAK,CAAA;AAE3C;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB,CAAC,YAAY;IAC5C,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,YAAY,CAAA;IACzB,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,UAAU,CAAC,EAAE,iBAAiB,CAAA;IAC9B,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAC1B;AAED,4EAA4E;AAC5E,MAAM,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;OAQG;IACG,mBAAmB,CACvB,UAAU,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,EAChC,OAAO,GAAE,OAAO,KAAa,GAC5B,OAAO,CAAC;QAAE,OAAO,EAAE,QAAQ,CAAC;QAAC,WAAW,EAAE,YAAY,CAAA;KAAE,CAAC;CA4F7D"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WorkBuddy's account pool.
|
|
3
|
+
*
|
|
4
|
+
* This line is the one that adopts accounts it does not own: alongside the
|
|
5
|
+
* accounts a user signs in through this plugin, it reads the CodeBuddy desktop
|
|
6
|
+
* client's own `*.info` credentials so an existing IDE sign-in needs no second
|
|
7
|
+
* login. Both kinds take part in scheduling through the shared
|
|
8
|
+
* {@link AccountPoolCore}, and the difference is enforced here:
|
|
9
|
+
*
|
|
10
|
+
* - **managed** accounts were signed in through this plugin. They live in the
|
|
11
|
+
* pool's encrypted storage and may be deleted.
|
|
12
|
+
* - **desktop** accounts belong to the IDE. Their credential is re-read from the
|
|
13
|
+
* IDE's file on every pick, because the IDE rotates it on its own schedule and
|
|
14
|
+
* a cached copy would go stale; they are never deleted, only hidden.
|
|
15
|
+
*/
|
|
16
|
+
import { AccountPoolCore, type PoolAccountShape, type PoolData } from '../common/account-pool.ts';
|
|
17
|
+
import type { CredentialStore } from '../token-store.ts';
|
|
18
|
+
import { FileCredentialStore, type WorkBuddyCredentials } from './token-store.ts';
|
|
19
|
+
import type { WorkBuddyAccountSummaryDto, WorkBuddyRegion } from '../../shared/workbuddy-contracts.ts';
|
|
20
|
+
/** One pooled WorkBuddy account: the credential plus the facts the card renders. */
|
|
21
|
+
export interface WorkBuddyPoolAccount extends PoolAccountShape<WorkBuddyCredentials> {
|
|
22
|
+
region: WorkBuddyRegion;
|
|
23
|
+
nickname?: string;
|
|
24
|
+
uin?: string;
|
|
25
|
+
/** Which store owns the credential; only managed accounts may be deleted. */
|
|
26
|
+
source: 'desktop' | 'managed';
|
|
27
|
+
/** IDE file a desktop account came from; absent for managed accounts. */
|
|
28
|
+
sourceFile?: string;
|
|
29
|
+
}
|
|
30
|
+
/** Encrypted pool file this line owns. */
|
|
31
|
+
export declare function workBuddyPoolPath(): string;
|
|
32
|
+
/**
|
|
33
|
+
* Validate and normalize one whole pool document.
|
|
34
|
+
*
|
|
35
|
+
* A record whose credential is unusable is dropped rather than repaired: the
|
|
36
|
+
* account can always be adopted again from its file or by signing in again, and
|
|
37
|
+
* keeping a credential-less row would offer the user an account nothing can use.
|
|
38
|
+
*/
|
|
39
|
+
export declare function parseWorkBuddyPoolData(value: unknown): PoolData<WorkBuddyPoolAccount>;
|
|
40
|
+
export interface WorkBuddyAccountPoolOptions {
|
|
41
|
+
/** Credential store the desktop scan reads through; the pool owns scheduling. */
|
|
42
|
+
store?: FileCredentialStore;
|
|
43
|
+
/** Test seam; production builds the platform backend from the pool path. */
|
|
44
|
+
backend?: CredentialStore<PoolData<WorkBuddyPoolAccount>>;
|
|
45
|
+
maxAccounts?: number;
|
|
46
|
+
/**
|
|
47
|
+
* The settings selection: the account the user pinned and the ones hidden.
|
|
48
|
+
*
|
|
49
|
+
* Read on every pick rather than captured once, because both change from the
|
|
50
|
+
* settings card while the adapter is serving requests.
|
|
51
|
+
*/
|
|
52
|
+
selection?: () => {
|
|
53
|
+
selectedAccountId: string | null;
|
|
54
|
+
hiddenAccountIds: readonly string[];
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* WorkBuddy's account pool.
|
|
59
|
+
*
|
|
60
|
+
* Desktop accounts are adopted into the pool so they can be scheduled and
|
|
61
|
+
* cooled down like any other, but they stay owned by the IDE: the pool refreshes
|
|
62
|
+
* their credential from the IDE's own file on every pick, and deletion is
|
|
63
|
+
* refused for them.
|
|
64
|
+
*/
|
|
65
|
+
export declare class WorkBuddyAccountPool extends AccountPoolCore<WorkBuddyCredentials, WorkBuddyPoolAccount, WorkBuddyAccountSummaryDto> {
|
|
66
|
+
private readonly store;
|
|
67
|
+
private readonly options_selection;
|
|
68
|
+
constructor(options?: WorkBuddyAccountPoolOptions);
|
|
69
|
+
/**
|
|
70
|
+
* Adopt any desktop credential the pool does not know yet.
|
|
71
|
+
*
|
|
72
|
+
* The IDE's directory is the source of truth for its own accounts, so a
|
|
73
|
+
* credential that appears there joins the pool. Nothing is ever removed: a
|
|
74
|
+
* file that disappears (the IDE signed out, a profile was moved) leaves the
|
|
75
|
+
* account in place, where the user can hide or delete the managed ones.
|
|
76
|
+
*/
|
|
77
|
+
syncDesktopAccounts(): Promise<WorkBuddyAccountSummaryDto[]>;
|
|
78
|
+
/**
|
|
79
|
+
* Pick the account for the next request.
|
|
80
|
+
*
|
|
81
|
+
* A desktop account's credential is re-read from the IDE's file first: the IDE
|
|
82
|
+
* refreshes its own token, so the copy the pool adopted can be older than what
|
|
83
|
+
* is on disk.
|
|
84
|
+
*/
|
|
85
|
+
getEffectiveCredential(excludeIds?: ReadonlySet<string>, fetchFn?: typeof fetch): Promise<{
|
|
86
|
+
account: WorkBuddyPoolAccount;
|
|
87
|
+
credentials: WorkBuddyCredentials;
|
|
88
|
+
}>;
|
|
89
|
+
/**
|
|
90
|
+
* Whether an account may serve a request.
|
|
91
|
+
*
|
|
92
|
+
* A hidden account keeps its place, its alias and its history, but the user
|
|
93
|
+
* has taken it out of this plugin's rotation, so it is not eligible.
|
|
94
|
+
*/
|
|
95
|
+
protected isEligible(account: WorkBuddyPoolAccount, now: number, triedAccountIds?: ReadonlySet<string>): boolean;
|
|
96
|
+
private selection;
|
|
97
|
+
/**
|
|
98
|
+
* Delete one account.
|
|
99
|
+
*
|
|
100
|
+
* A desktop account is refused: the plugin does not own that credential file,
|
|
101
|
+
* so removing it from the pool would strand the IDE's session while telling
|
|
102
|
+
* the user their account was deleted. Hiding is the supported action there.
|
|
103
|
+
*/
|
|
104
|
+
deleteAccount(accountId: string): Promise<void>;
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=account-pool.d.ts.map
|
|
@@ -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AE,CAAA;CAC5F;AAED;;;;;;;GAOG;AACH,qBAAa,oBAAqB,SAAQ,eAAe,CACvD,oBAAoB,EACpB,oBAAoB,EACpB,0BAA0B,CAC3B;IACC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAqB;IAC3C,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAA0C;gBAEhE,OAAO,GAAE,2BAAgC;IAkErD;;;;;;;OAOG;IACG,mBAAmB,IAAI,OAAO,CAAC,0BAA0B,EAAE,CAAC;IAmBlE;;;;;;OAMG;IACG,sBAAsB,CAC1B,UAAU,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,EAChC,OAAO,GAAE,OAAO,KAAa,GAC5B,OAAO,CAAC;QAAE,OAAO,EAAE,oBAAoB,CAAC;QAAC,WAAW,EAAE,oBAAoB,CAAA;KAAE,CAAC;IAmBhF;;;;;OAKG;cACgB,UAAU,CAC3B,OAAO,EAAE,oBAAoB,EAC7B,GAAG,EAAE,MAAM,EACX,eAAe,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,GACpC,OAAO;IAMV,OAAO,CAAC,SAAS;IAIjB;;;;;;OAMG;IACY,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAO/D"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { LlmAdapter, LlmError, ReasoningEffortId, type GenerateOptions, type LlmModelInfo, type LlmProviderInfo, type LlmResolvedModelInfo, type PreparedAdapterCall, type ResolvedRetryPolicy, type StreamChunk } from '@deepseek-ai/dsh-llm';
|
|
2
|
+
import { PROVIDER_ID, PROVIDER_NAME } from './types.ts';
|
|
3
|
+
import { FileCredentialStore, FileModelSettingsStore, type WorkBuddyPreferenceStore } from './token-store.ts';
|
|
4
|
+
import { type WorkBuddyModelEntry } from './model-catalog.ts';
|
|
5
|
+
import { type AttachmentImageReader } from './mapper.ts';
|
|
6
|
+
import type { WorkBuddyCredentials } from './token-store.ts';
|
|
7
|
+
import type { WorkBuddyAccountPool } from './account-pool.ts';
|
|
8
|
+
/**
|
|
9
|
+
* Effort this route materializes when the caller names none.
|
|
10
|
+
*
|
|
11
|
+
* Preference order: the user's configured level when the model accepts it,
|
|
12
|
+
* otherwise the level the gateway's own catalog declares for that model (the
|
|
13
|
+
* same default the official CLI applies), otherwise nothing — which leaves the
|
|
14
|
+
* provider's own default in charge. A configured level the model does not
|
|
15
|
+
* accept is ignored rather than sent, since the endpoint rejects an unsupported
|
|
16
|
+
* level with `code 11150`.
|
|
17
|
+
*/
|
|
18
|
+
export declare function resolveDefaultReasoningEffort(efforts: readonly string[], configuredEffort?: string | null, modelDefaultEffort?: string | null): ReasoningEffortId | undefined;
|
|
19
|
+
/** Cooldown a 429 imposes when the service names no reset instant. */
|
|
20
|
+
export declare const POOL_COOLDOWN_MS: number;
|
|
21
|
+
export interface WorkBuddyAdapterOptions {
|
|
22
|
+
fetchFn?: typeof fetch;
|
|
23
|
+
attachments?: AttachmentImageReader;
|
|
24
|
+
/** Live catalog loader seam; defaults to the gateway `/v3/config` call. */
|
|
25
|
+
loadCatalog?: (credentials: WorkBuddyCredentials) => Promise<WorkBuddyModelEntry[]>;
|
|
26
|
+
/**
|
|
27
|
+
* Multi-account pool this adapter rotates through.
|
|
28
|
+
*
|
|
29
|
+
* Absent leaves the line on its single-credential path, which is what the
|
|
30
|
+
* headless tests and any caller that predates the pool use.
|
|
31
|
+
*/
|
|
32
|
+
accountPool?: WorkBuddyAccountPool;
|
|
33
|
+
}
|
|
34
|
+
export declare class WorkBuddyAdapter extends LlmAdapter {
|
|
35
|
+
private readonly store;
|
|
36
|
+
private readonly modelSettings;
|
|
37
|
+
private readonly preferences?;
|
|
38
|
+
private readonly options;
|
|
39
|
+
/** Null keeps the pre-pool single-credential path. */
|
|
40
|
+
private readonly accountPool;
|
|
41
|
+
constructor(store?: FileCredentialStore, modelSettings?: FileModelSettingsStore, preferences?: WorkBuddyPreferenceStore | undefined, options?: WorkBuddyAdapterOptions);
|
|
42
|
+
providerInfo(provider: string): LlmProviderInfo;
|
|
43
|
+
providerRetryPolicy(): ResolvedRetryPolicy;
|
|
44
|
+
imageRequestPricing(): undefined;
|
|
45
|
+
private settings;
|
|
46
|
+
private credentials;
|
|
47
|
+
/**
|
|
48
|
+
* Catalog for the picker: the live gateway listing when reachable, the
|
|
49
|
+
* shipped table otherwise.
|
|
50
|
+
*
|
|
51
|
+
* The gateway is the authority on capabilities, so its answer replaces the
|
|
52
|
+
* fallback rather than merging with it — a model whose context window changed
|
|
53
|
+
* upstream must not keep a stale local value.
|
|
54
|
+
*/
|
|
55
|
+
private catalog;
|
|
56
|
+
/**
|
|
57
|
+
* Models the picker may offer.
|
|
58
|
+
*
|
|
59
|
+
* The catalog is filtered by the account's own region: asking a region for a
|
|
60
|
+
* model it does not serve answers 400 `code 11102`, so offering one would
|
|
61
|
+
* hand the user a model that cannot work.
|
|
62
|
+
*/
|
|
63
|
+
listModels(provider?: string): Promise<readonly LlmModelInfo[]>;
|
|
64
|
+
resolveModel(provider: string, modelId: string, signal?: AbortSignal): Promise<LlmResolvedModelInfo>;
|
|
65
|
+
prepareCall(provider: string, model: string, signal?: AbortSignal): Promise<PreparedAdapterCall>;
|
|
66
|
+
stream(options: GenerateOptions): AsyncIterable<StreamChunk>;
|
|
67
|
+
/**
|
|
68
|
+
* Effort this request should carry, or `undefined` to send none.
|
|
69
|
+
*
|
|
70
|
+
* Order: the caller's explicit choice, then the user's configured level, then
|
|
71
|
+
* the level the gateway catalog declares for this model. The last step
|
|
72
|
+
* matters because the endpoint returns an **empty `reasoning_content`** when
|
|
73
|
+
* no `reasoning_effort` is present, even for a reasoning-only model: measured
|
|
74
|
+
* on `deepseek-v4.1-flash`, the same prompt yields 0 reasoning characters
|
|
75
|
+
* with no field and 130-215 with one. Omitting it therefore silently drops
|
|
76
|
+
* the model's thinking instead of letting the provider pick, so the catalog's
|
|
77
|
+
* own default (which is what the official CLI sends) is materialized here.
|
|
78
|
+
*
|
|
79
|
+
* A candidate the model does not accept is discarded rather than sent, since
|
|
80
|
+
* the endpoint rejects an unsupported level with `code 11150`.
|
|
81
|
+
*/
|
|
82
|
+
private effortFor;
|
|
83
|
+
private requestStream;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Map one failed HTTP response onto a DSH failure.
|
|
87
|
+
*
|
|
88
|
+
* The subscription reports its own conditions inside a JSON `code` while the
|
|
89
|
+
* status line stays generic, so the body is read for the specific cases the
|
|
90
|
+
* status alone cannot express — notably the quota signal, whose message carries
|
|
91
|
+
* the instant the allowance resets.
|
|
92
|
+
*/
|
|
93
|
+
export declare function classifyFailure(status: number, detail: string, headers?: Headers): LlmError;
|
|
94
|
+
/** Read the subscription's own numeric error code out of a response body. */
|
|
95
|
+
export declare function readErrorCode(detail: string): number | null;
|
|
96
|
+
export { PROVIDER_ID, PROVIDER_NAME };
|
|
97
|
+
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../../src/host/workbuddy/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,QAAQ,EACR,iBAAiB,EAEjB,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,KAAK,WAAW,EACjB,MAAM,sBAAsB,CAAA;AAE7B,OAAO,EAGL,WAAW,EACX,aAAa,EAGd,MAAM,YAAY,CAAA;AACnB,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EAEtB,KAAK,wBAAwB,EAC9B,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAQL,KAAK,mBAAmB,EACzB,MAAM,oBAAoB,CAAA;AAG3B,OAAO,EAQL,KAAK,qBAAqB,EAC3B,MAAM,aAAa,CAAA;AAGpB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAC5D,O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C;IA0B/D,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAsCpG,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAO/F,MAAM,CAAC,OAAO,EAAE,eAAe,GAAG,aAAa,CAAC,WAAW,CAAC;IAenE;;;;;;;;;;;;;;OAcG;YACW,SAAS;YAeR,aAAa;CAkI7B;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,OAAO,GAChB,QAAQ,CA0EV;AAED,6EAA6E;AAC7E,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAK3D;AAED,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,CAAA"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { WorkBuddyAccount, WorkBuddyAccountQuota, WorkBuddyMeter } from '../../shared/workbuddy-contracts.ts';
|
|
2
|
+
import { PROVIDER_ID, PROVIDER_NAME } from './types.ts';
|
|
3
|
+
import { FileCredentialStore, type WorkBuddyCredentials } from './token-store.ts';
|
|
4
|
+
import type { WorkBuddyModelEntry } from './model-catalog.ts';
|
|
5
|
+
export interface WorkBuddyRequestOptions {
|
|
6
|
+
fetchFn?: typeof fetch;
|
|
7
|
+
signal?: AbortSignal;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Attribution and identity headers for one backend request.
|
|
11
|
+
*
|
|
12
|
+
* The gateway gates on this header set: the international deployment answers
|
|
13
|
+
* 401 without the CLI user agent and matching `Origin`/`Referer`, and both
|
|
14
|
+
* deployments read the account identity headers rather than deriving it from
|
|
15
|
+
* the bearer token alone.
|
|
16
|
+
*/
|
|
17
|
+
export declare function workBuddyHeaders(credentials: Pick<WorkBuddyCredentials, 'accessToken' | 'domain' | 'uid' | 'enterpriseId' | 'backend'>, extra?: Record<string, string>): Record<string, string>;
|
|
18
|
+
/**
|
|
19
|
+
* Refresh an access token against the endpoint the official IDE uses.
|
|
20
|
+
*
|
|
21
|
+
* The response carries a whole new `auth` block rather than just a token, so it
|
|
22
|
+
* is merged over the current one: fields the endpoint omits (the domain, the
|
|
23
|
+
* refresh lifetime) must survive, or the next refresh would lose its target.
|
|
24
|
+
*/
|
|
25
|
+
export declare function refreshCredentials(credentials: WorkBuddyCredentials, options?: WorkBuddyRequestOptions): Promise<WorkBuddyCredentials>;
|
|
26
|
+
/** Public account facts for the settings card. */
|
|
27
|
+
export declare function accountFromCredentials(credentials: WorkBuddyCredentials): WorkBuddyAccount;
|
|
28
|
+
/**
|
|
29
|
+
* Parse one `/v3/config` payload's model list.
|
|
30
|
+
*
|
|
31
|
+
* Each entry carries the facts this route needs directly, so nothing is
|
|
32
|
+
* inferred from the model's name. Image-generation tools (`tags` naming
|
|
33
|
+
* `text-to-image`/`image-to-image`) are skipped: they are not chat models and
|
|
34
|
+
* carry no context window.
|
|
35
|
+
*/
|
|
36
|
+
export declare function parseConfigModels(payload: unknown, region: WorkBuddyCredentials['region']): WorkBuddyModelEntry[];
|
|
37
|
+
export declare function getCachedCatalog(): WorkBuddyModelEntry[];
|
|
38
|
+
export declare function clearCachedCatalog(): void;
|
|
39
|
+
/**
|
|
40
|
+
* Fetch the live catalog for one account.
|
|
41
|
+
*
|
|
42
|
+
* The gateway is the authority on capabilities, so a successful read replaces
|
|
43
|
+
* the shipped table entirely; a failure returns an empty list and the caller
|
|
44
|
+
* falls back, which keeps a first run usable before sign-in.
|
|
45
|
+
*/
|
|
46
|
+
export declare function fetchConfigCatalog(credentials: WorkBuddyCredentials, options?: WorkBuddyRequestOptions): Promise<WorkBuddyModelEntry[]>;
|
|
47
|
+
/** Cached catalog with a TTL; a failed refresh keeps the previous snapshot. */
|
|
48
|
+
export declare function loadConfigCatalog(credentials: WorkBuddyCredentials, options?: WorkBuddyRequestOptions & {
|
|
49
|
+
force?: boolean;
|
|
50
|
+
}): Promise<WorkBuddyModelEntry[]>;
|
|
51
|
+
/** Parse one `Capacity*` account record into the public quota shape. */
|
|
52
|
+
export interface ParsedBilling {
|
|
53
|
+
packageName: string | null;
|
|
54
|
+
totalCredits: number | null;
|
|
55
|
+
remainingCredits: number | null;
|
|
56
|
+
cycleUsedCredits: number | null;
|
|
57
|
+
cycleCredits: number | null;
|
|
58
|
+
cycleStartsAt: number | null;
|
|
59
|
+
cycleEndsAt: number | null;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Parse the billing payload's account list.
|
|
63
|
+
*
|
|
64
|
+
* The response nests as `data.Response.Data.Accounts[]`; each entry describes
|
|
65
|
+
* one purchased package with its own capacity counters. The first entry is the
|
|
66
|
+
* active subscription, and the totals are summed across all of them because a
|
|
67
|
+
* user can hold several packages at once.
|
|
68
|
+
*/
|
|
69
|
+
export declare function parseBilling(payload: unknown): ParsedBilling;
|
|
70
|
+
/**
|
|
71
|
+
* Parse a cycle boundary.
|
|
72
|
+
*
|
|
73
|
+
* The service sends these as local-time strings without a zone
|
|
74
|
+
* (`2026-09-01 00:00:00`), which `Date.parse` reads as local time — the same
|
|
75
|
+
* reading the IDE's own panel uses, so the card agrees with it.
|
|
76
|
+
*/
|
|
77
|
+
export declare function parseCycleTime(value: unknown): number | null;
|
|
78
|
+
/** Turn a parsed billing snapshot into the meters the card renders. */
|
|
79
|
+
export declare function billingMeters(billing: ParsedBilling): WorkBuddyMeter[];
|
|
80
|
+
export declare function getCachedQuota(): WorkBuddyAccountQuota | undefined;
|
|
81
|
+
export declare function clearCachedQuota(): void;
|
|
82
|
+
/**
|
|
83
|
+
* Read the account's credit allowance.
|
|
84
|
+
*
|
|
85
|
+
* Only one billing route exists here, so a failure is a real failure rather
|
|
86
|
+
* than a partially-answered snapshot: the caller decides whether to surface it.
|
|
87
|
+
*/
|
|
88
|
+
export declare function fetchAccountQuota(store?: FileCredentialStore, fetchFn?: typeof fetch, force?: boolean, accountId?: string | null, hiddenAccountIds?: readonly string[]): Promise<WorkBuddyAccountQuota>;
|
|
89
|
+
export { PROVIDER_ID, PROVIDER_NAME };
|
|
90
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../src/host/workbuddy/client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,gBAAgB,EAChB,qBAAqB,EACrB,cAAc,EACf,MAAM,qCAAqC,CAAA;AAC5C,OAAO,EAgBL,WAAW,EACX,aAAa,EAKd,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,mBAAmB,EAAsB,KAAK,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AACrG,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAM7D,MAAM,WAAW,uBAAuB;IACtC,OAAO,CAAC,EAAE,OAAO,KAAK,CAAA;IACtB,MAAM,CAAC,EAAE,WAAW,CAAA;CACrB;AA6BD;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,IAAI,CAAC,oBAAoB,EAAE,aAAa,GAAG,QAAQ,GAAG,KAAK,GAAG,cAAc,GAAG,SAAS,CAAC,EACtG,KAAK,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,GACjC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAmBxB;AAED;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CACtC,WAAW,EAAE,oBAAoB,EACjC,OAAO,GAAE,uBAA4B,GACpC,OAAO,CAAC,oBAAoB,CAAC,CAoD/B;AAED,kDAAkD;AAClD,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,oBAAoB,GAAG,gBAAgB,CAiB1F;AAMD;;;;;;;GAOG;AACH,wBA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AED;;;;;GAKG;AACH,wBAAsB,iBAAiB,CACrC,KAAK,sBAA4B,EACjC,OAAO,GAAE,OAAO,KAAa,EAC7B,KAAK,UAAQ,EACb,SAAS,GAAE,MAAM,GAAG,IAAW,EAC/B,gBAAgB,GAAE,SAAS,MAAM,EAAO,GACvC,OAAO,CAAC,qBAAqB,CAAC,CAmEhC;AAED,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,CAAA"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire mapping for the WorkBuddy / CodeBuddy subscription chat endpoint.
|
|
3
|
+
*
|
|
4
|
+
* The endpoint is OpenAI Chat Completions shaped, but with three measured
|
|
5
|
+
* deviations from the OpenAI default that this module exists to absorb:
|
|
6
|
+
*
|
|
7
|
+
* 1. **Stream only.** `stream: false` answers 400 `code 11101`. The request
|
|
8
|
+
* builder therefore always sends `stream: true`, and there is no
|
|
9
|
+
* non-streaming code path to keep in sync.
|
|
10
|
+
* 2. **A leading system message is mandatory on the international backend.**
|
|
11
|
+
* A request whose first message is a user turn answers 400 `code 11128`
|
|
12
|
+
* ("first message is not system prompt"). {@link buildChatRequest} injects
|
|
13
|
+
* one when the caller supplied none, so a hand-built one-shot request cannot
|
|
14
|
+
* trip this.
|
|
15
|
+
* 3. **Reasoning rides `delta.reasoning_content`,** not OpenAI's
|
|
16
|
+
* `reasoning_summary`, and is emitted as its own DSH reasoning block.
|
|
17
|
+
*/
|
|
18
|
+
import { type ContentBlock, type GenerateOptions, type StreamChunk } from '@deepseek-ai/dsh-llm';
|
|
19
|
+
import type { AttachmentStore } from '@deepseek-ai/dsh-attachment';
|
|
20
|
+
/**
|
|
21
|
+
* The system prompt every request must open with.
|
|
22
|
+
*
|
|
23
|
+
* The international backend rejects a request whose first message is not a
|
|
24
|
+
* system turn, so this stands in when the caller supplies no prompt at all. It
|
|
25
|
+
* is deliberately neutral: it must not change model behaviour beyond satisfying
|
|
26
|
+
* the shape check.
|
|
27
|
+
*/
|
|
28
|
+
declare const IMPLICIT_SYSTEM_PROMPT = "You are a helpful assistant.";
|
|
29
|
+
/** Attachment seam this route needs: verified bytes for one durable image. */
|
|
30
|
+
export type AttachmentImageReader = Pick<AttachmentStore, 'readImage'>;
|
|
31
|
+
/** One durable user image resolved for an in-flight request, or proven unreadable. */
|
|
32
|
+
export type ResolvedRequestImage = {
|
|
33
|
+
readonly kind: 'inline';
|
|
34
|
+
readonly mediaType: string;
|
|
35
|
+
readonly data: string;
|
|
36
|
+
} | {
|
|
37
|
+
readonly kind: 'unavailable';
|
|
38
|
+
};
|
|
39
|
+
/** Resolved images keyed by durable attachment id; consumed by one request build. */
|
|
40
|
+
export type ResolvedRequestImages = ReadonlyMap<string, ResolvedRequestImage>;
|
|
41
|
+
/**
|
|
42
|
+
* Base64 image payload one request may carry.
|
|
43
|
+
*
|
|
44
|
+
* The subscription proxies to several upstream vendors, so the bound has to
|
|
45
|
+
* hold for the strictest of them. 12 MB matches what this plugin's other
|
|
46
|
+
* routes allow and keeps the conversation text and tool schemas in the same
|
|
47
|
+
* body.
|
|
48
|
+
*/
|
|
49
|
+
export declare const MAX_REQUEST_IMAGE_BYTES: number;
|
|
50
|
+
/**
|
|
51
|
+
* Replace the oldest inline images with a text placeholder once one request
|
|
52
|
+
* would carry more than {@link MAX_REQUEST_IMAGE_BYTES} of base64 image data.
|
|
53
|
+
* Durable history is untouched; only the request about to be sent changes.
|
|
54
|
+
*/
|
|
55
|
+
export declare function offloadOldestRequestImages(options: GenerateOptions): GenerateOptions;
|
|
56
|
+
/**
|
|
57
|
+
* Read every durable `{ type: 'image', attachment }` block one request carries.
|
|
58
|
+
* An unreadable image resolves to `unavailable` rather than disappearing, so
|
|
59
|
+
* the model is told the picture is missing instead of answering about a blank.
|
|
60
|
+
*/
|
|
61
|
+
export declare function resolveRequestImages(options: GenerateOptions, attachments: AttachmentImageReader | undefined, signal?: AbortSignal): Promise<ResolvedRequestImages>;
|
|
62
|
+
/** Drop the JSON-Schema keywords provider gateways reject or ignore. */
|
|
63
|
+
export declare function stripMetaSchema(schema: unknown): Record<string, unknown>;
|
|
64
|
+
/**
|
|
65
|
+
* Build one `/v2/chat/completions` body.
|
|
66
|
+
*
|
|
67
|
+
* Always `stream: true`: the endpoint rejects a non-streaming request outright
|
|
68
|
+
* (400 `code 11101`), so there is no second shape to produce.
|
|
69
|
+
*/
|
|
70
|
+
export declare function buildChatRequest(options: GenerateOptions, images?: ResolvedRequestImages): Record<string, unknown>;
|
|
71
|
+
interface PendingToolCall {
|
|
72
|
+
blockIndex: number;
|
|
73
|
+
id: string;
|
|
74
|
+
name: string;
|
|
75
|
+
arguments: string;
|
|
76
|
+
started: boolean;
|
|
77
|
+
}
|
|
78
|
+
export interface WorkBuddyStreamState {
|
|
79
|
+
blocks: ContentBlock[];
|
|
80
|
+
current: {
|
|
81
|
+
index: number;
|
|
82
|
+
type: 'text' | 'reasoning';
|
|
83
|
+
text: string;
|
|
84
|
+
} | null;
|
|
85
|
+
/** wire tool index -> accumulating call. */
|
|
86
|
+
toolCalls: Map<number, PendingToolCall>;
|
|
87
|
+
hasContent: boolean;
|
|
88
|
+
hasToolCall: boolean;
|
|
89
|
+
finishReason: string | null;
|
|
90
|
+
/** The `[DONE]` sentinel arrived. */
|
|
91
|
+
done: boolean;
|
|
92
|
+
/** Terminal chunks were already emitted. */
|
|
93
|
+
finished: boolean;
|
|
94
|
+
inputTokens: number;
|
|
95
|
+
outputTokens: number;
|
|
96
|
+
cacheReadTokens: number;
|
|
97
|
+
reasoningTokens: number;
|
|
98
|
+
sawUsage: boolean;
|
|
99
|
+
}
|
|
100
|
+
export declare function createStreamState(): WorkBuddyStreamState;
|
|
101
|
+
/** Feed one SSE line from `/v2/chat/completions`. */
|
|
102
|
+
export declare function processStreamLine(line: string, state: WorkBuddyStreamState): StreamChunk[];
|
|
103
|
+
/** Flush every open block, then emit usage and the terminal finish. */
|
|
104
|
+
export declare function closeStream(state: WorkBuddyStreamState): StreamChunk[];
|
|
105
|
+
/**
|
|
106
|
+
* A stream that ends without a terminal event is truncated, not complete.
|
|
107
|
+
*
|
|
108
|
+
* The endpoint always terminates with either `finish_reason` or `[DONE]`, so
|
|
109
|
+
* their absence means the connection dropped mid-answer and the partial text
|
|
110
|
+
* must not be presented as a finished reply.
|
|
111
|
+
*/
|
|
112
|
+
export declare function assertStreamComplete(state: WorkBuddyStreamState): void;
|
|
113
|
+
export { IMPLICIT_SYSTEM_PROMPT };
|
|
114
|
+
//# sourceMappingURL=mapper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapper.d.ts","sourceRoot":"","sources":["../../../../src/host/workbuddy/mapper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAEL,KAAK,YAAY,EAEjB,KAAK,eAAe,EAEpB,KAAK,WAAW,EAEjB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,KAAK,EAAE,eAAe,EAAsB,MAAM,6BAA6B,CAAA;AAwBtF;;;;;;;GAOG;AACH,QAAA,MAAM,sBAAsB,iCAAiC,CAAA;AAM7D,8EAA8E;AAC9E,MAAM,MAAM,qBAAqB,GAAG,IAAI,CAAC,eAAe,EAAE,WAAW,CAAC,CAAA;AAEtE,sFAAsF;AACtF,MAAM,MAAM,oBAAoB,GAC5B;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC9E;IAAE,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAA;CAAE,CAAA;AAEpC,qFAAqF;AACrF,MAAM,MAAM,qBAAqB,GAAG,WAAW,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAA;AAI7E;;;;;;;GAOG;AACH,eAAO,MAAM,uBAAuB,QAAmB,CAAA;AAuDvD;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EA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Q,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,iBAAiB,IAAI,oBAAoB,CAgBxD;AAwCD,qDAAqD;AACrD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,oBAAoB,GAAG,WAAW,EAAE,CA8E1F;AAsED,uEAAuE;AACvE,wBAAgB,WAAW,CAAC,KAAK,EAAE,oBAAoB,GAAG,WAAW,EAAE,CAOtE;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,oBAAoB,GAAG,IAAI,CAItE;AAED,OAAO,EAAE,sBAAsB,EAAE,CAAA"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Model catalog for the WorkBuddy / CodeBuddy subscription.
|
|
3
|
+
*
|
|
4
|
+
* The subscription exposes no `/v1/models`-style listing on the chat host
|
|
5
|
+
* (that path answers 404), but the gateway does publish an **authoritative
|
|
6
|
+
* catalog** at `GET /v3/config`, which the official CLI reads at startup. That
|
|
7
|
+
* payload carries each model's real context window, output cap, image support,
|
|
8
|
+
* and the exact reasoning ladder it accepts — so this route prefers the live
|
|
9
|
+
* catalog and keeps the table below only as an offline fallback.
|
|
10
|
+
*
|
|
11
|
+
* The fallback is a verbatim transcription of a live `/v3/config` read, not
|
|
12
|
+
* hand-written guesses: an earlier revision of this file guessed context
|
|
13
|
+
* windows from vendor marketing and was wrong in both directions (`glm-5.3`
|
|
14
|
+
* and `kimi-k3` are 1M, not 200K/256K). Where the two regions disagree, the
|
|
15
|
+
* larger maximum is kept while the served default comes from whichever region
|
|
16
|
+
* reported one.
|
|
17
|
+
*
|
|
18
|
+
* `regions` is a routing fact, not a preference: asking a region for a model it
|
|
19
|
+
* does not serve answers 400 `code 11102`.
|
|
20
|
+
*
|
|
21
|
+
* A second `code 11102` source was measured and is deliberately NOT filtered
|
|
22
|
+
* out here: the gateway lists models the *current account* is not entitled to
|
|
23
|
+
* call (on a free plan, `glm-5.0`, `glm-4.7`, `glm-4.6`, `glm-4.6v`,
|
|
24
|
+
* `kimi-k2-thinking`, `hy4-preview-x` and `minimax-m2.5` all advertise a context
|
|
25
|
+
* window and then answer 11102). Those entries are kept because the gating is
|
|
26
|
+
* per-account, not per-model — a paid plan may serve them — and because the
|
|
27
|
+
* shipped default selection excludes them anyway. The adapter's failure message
|
|
28
|
+
* names this case so a user knows to pick another model rather than to retry.
|
|
29
|
+
*
|
|
30
|
+
* `reasoningEfforts` carries the ladder a model accepts, transcribed from the
|
|
31
|
+
* gateway's own declaration. `/v3/config` uses two shapes and they were once
|
|
32
|
+
* conflated, in opposite directions: a lone `{ effort: 'high' }` (no
|
|
33
|
+
* `supportedEfforts`) first became a one-entry ladder, which rejected a
|
|
34
|
+
* caller's explicit `low`; widening it to every level this route can name then
|
|
35
|
+
* advertised `minimal`/`xhigh` on a model that has three. Such a model accepts
|
|
36
|
+
* exactly `low`/`high`/`max` (measured on `deepseek-v4.1-flash`), the same
|
|
37
|
+
* three the gateway declares explicitly for `glm-5.3-flash` and
|
|
38
|
+
* `kimi-k2.8-preview`, and routes any other value into the nearest of them.
|
|
39
|
+
*/
|
|
40
|
+
import type { WorkBuddyRegion } from '../../shared/workbuddy-contracts.ts';
|
|
41
|
+
export interface WorkBuddyModelEntry {
|
|
42
|
+
id: string;
|
|
43
|
+
name: string;
|
|
44
|
+
/**
|
|
45
|
+
* Context length the gateway serves **by default** for this model.
|
|
46
|
+
*
|
|
47
|
+
* This route sends no explicit context-length parameter, so this is the
|
|
48
|
+
* figure DSH's compaction and overflow decisions must use. It is not always
|
|
49
|
+
* the model's maximum: the gateway reports both (for example
|
|
50
|
+
* `deepseek-v4.1-flash` serves 300000 by default and allows 1000000).
|
|
51
|
+
*/
|
|
52
|
+
contextWindow: number;
|
|
53
|
+
/** Largest context length the model accepts when one is requested. */
|
|
54
|
+
maxContextWindow: number;
|
|
55
|
+
/** Output cap requested when the caller omits one. */
|
|
56
|
+
maxTokens: number;
|
|
57
|
+
/** Regions whose backend serves this id. */
|
|
58
|
+
regions: readonly WorkBuddyRegion[];
|
|
59
|
+
/** Whether the model accepts image input. */
|
|
60
|
+
supportsImage: boolean;
|
|
61
|
+
/** Reasoning ladder the model accepts; empty for a non-reasoning model. */
|
|
62
|
+
reasoningEfforts: readonly string[];
|
|
63
|
+
/** Level this route selects when the caller names none. */
|
|
64
|
+
defaultReasoningEffort: string | null;
|
|
65
|
+
/** Whether the model can be asked to skip thinking entirely. */
|
|
66
|
+
canDisableThinking: boolean;
|
|
67
|
+
/** One-line note shown beside the model in the settings card. */
|
|
68
|
+
description: string;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Offline fallback catalog, transcribed from a live `/v3/config` read.
|
|
72
|
+
*
|
|
73
|
+
* Used when the gateway cannot be reached (first run before sign-in, or a
|
|
74
|
+
* network failure); a reachable gateway always wins.
|
|
75
|
+
*/
|
|
76
|
+
export declare const FALLBACK_MODELS: readonly WorkBuddyModelEntry[];
|
|
77
|
+
/**
|
|
78
|
+
* Models the picker offers on a fresh install.
|
|
79
|
+
*
|
|
80
|
+
* Deliberately short: the catalog holds every id the subscription serves, and
|
|
81
|
+
* the picker is far more usable with the handful of general-purpose models. The
|
|
82
|
+
* card lets a user add the rest, and a first-run default expands to everything
|
|
83
|
+
* the account's region can actually call.
|
|
84
|
+
*/
|
|
85
|
+
export declare const DEFAULT_VISIBLE_MODEL_IDS: readonly string[];
|
|
86
|
+
/** Every id the fallback knows, in declaration order. */
|
|
87
|
+
export declare const WORKBUDDY_MODEL_IDS: readonly string[];
|
|
88
|
+
/**
|
|
89
|
+
* Resolve one entry from a catalog.
|
|
90
|
+
*
|
|
91
|
+
* An unknown id resolves to a synthetic text-only entry rather than the first
|
|
92
|
+
* catalog row: reporting a real model's capabilities for an id it does not
|
|
93
|
+
* describe would mis-declare image support and route a request to a 400.
|
|
94
|
+
*/
|
|
95
|
+
export declare function resolveWorkBuddyModel(id: string, catalog?: readonly WorkBuddyModelEntry[]): WorkBuddyModelEntry;
|
|
96
|
+
/** Whether one catalog knows this exact id. */
|
|
97
|
+
export declare function isWorkBuddyModelId(id: unknown, catalog?: readonly WorkBuddyModelEntry[]): id is string;
|
|
98
|
+
/** Models an account in `region` can actually call, in catalog order. */
|
|
99
|
+
export declare function modelsForRegion(region: WorkBuddyRegion, catalog?: readonly WorkBuddyModelEntry[]): WorkBuddyModelEntry[];
|
|
100
|
+
/** Whether one model accepts image input. */
|
|
101
|
+
export declare function workBuddyModelSupportsImage(id: string, catalog?: readonly WorkBuddyModelEntry[]): boolean;
|
|
102
|
+
/** Reasoning ladder one model accepts. */
|
|
103
|
+
export declare function workBuddyReasoningEfforts(id: string, catalog?: readonly WorkBuddyModelEntry[]): readonly string[];
|
|
104
|
+
/** Output cap requested when the caller omits one. */
|
|
105
|
+
export declare function maxOutputTokensFor(id: string, catalog?: readonly WorkBuddyModelEntry[]): number;
|
|
106
|
+
/** Context window assumed when no override is saved. */
|
|
107
|
+
export declare function defaultContextWindowFor(id: string, catalog?: readonly WorkBuddyModelEntry[]): number;
|
|
108
|
+
//# sourceMappingURL=model-catalog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-catalog.d.ts","sourceRoot":"","sources":["../../../../src/host/workbuddy/model-catalog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAA;AAI1E,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ;;;;;;;OAOG;IACH,aAAa,EAAE,MAAM,CAAA;IACrB,sEAAsE;IACtE,gBAAgB,EAAE,MAAM,CAAA;IACxB,sDAAsD;IACtD,SAAS,EAAE,MAAM,CAAA;IACjB,4CAA4C;IAC5C,OAAO,EAAE,SAAS,eAAe,EAAE,CAAA;IACnC,6CAA6C;IAC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wBAAgB,uBAAuB,CACrC,EAAE,EAAE,MAAM,EACV,OAAO,GAAE,SAAS,mBAAmB,EAAoB,GACxD,MAAM,CAER"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { FileCredentialStore, type WorkBuddyCredentials } from './token-store.ts';
|
|
2
|
+
import type { WorkBuddyRegion } from '../../shared/workbuddy-contracts.ts';
|
|
3
|
+
export type WorkBuddyLoginStatus = 'idle' | 'pending' | 'complete' | 'error';
|
|
4
|
+
export interface WorkBuddyLoginFlowState {
|
|
5
|
+
status: WorkBuddyLoginStatus;
|
|
6
|
+
region?: WorkBuddyRegion;
|
|
7
|
+
authUrl?: string;
|
|
8
|
+
progress?: string;
|
|
9
|
+
accountId?: string;
|
|
10
|
+
startedAt?: number;
|
|
11
|
+
completedAt?: number;
|
|
12
|
+
error?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function getWebLoginStatus(): WorkBuddyLoginFlowState;
|
|
15
|
+
export declare function resetWebLogin(): void;
|
|
16
|
+
export interface WorkBuddyLoginAttempt {
|
|
17
|
+
state: string;
|
|
18
|
+
authUrl: string;
|
|
19
|
+
region: WorkBuddyRegion;
|
|
20
|
+
domain: string;
|
|
21
|
+
}
|
|
22
|
+
export declare function requestLoginState(region: WorkBuddyRegion, fetchFn?: typeof fetch, signal?: AbortSignal): Promise<WorkBuddyLoginAttempt>;
|
|
23
|
+
/** Parse the successful token-poll shape while accepting the two observed wrappers. */
|
|
24
|
+
export declare function parseLoginCredential(payload: unknown, attempt: WorkBuddyLoginAttempt): WorkBuddyCredentials | null;
|
|
25
|
+
export declare function pollLogin(attempt: WorkBuddyLoginAttempt, fetchFn?: typeof fetch, signal?: AbortSignal): Promise<WorkBuddyCredentials | null>;
|
|
26
|
+
/** Where a completed sign-in is written; the default is this line's own store. */
|
|
27
|
+
export interface WorkBuddyLoginOptions {
|
|
28
|
+
/**
|
|
29
|
+
* Persist the completed credential.
|
|
30
|
+
*
|
|
31
|
+
* The account pool owns routing, so it is what a completed sign-in must reach;
|
|
32
|
+
* the default writes to the credential store alone, which is what a caller
|
|
33
|
+
* running without a pool needs.
|
|
34
|
+
*/
|
|
35
|
+
onSave?: (credentials: WorkBuddyCredentials) => Promise<unknown>;
|
|
36
|
+
}
|
|
37
|
+
export declare function beginWebLogin(store: FileCredentialStore, region: WorkBuddyRegion, fetchFn?: typeof fetch, options?: WorkBuddyLoginOptions): Promise<WorkBuddyLoginFlowState>;
|
|
38
|
+
//# sourceMappingURL=oauth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauth.d.ts","sourceRoot":"","sources":["../../../../src/host/workbuddy/oauth.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,mBAAmB,EAAE,KAAK,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AACjF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAA;AAE1E,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG,SAAS,GAAG,UAAU,GAAG,OAAO,CAAA;AAE5E,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,oBAAoB,CAAA;IAC5B,MAAM,CAAC,EAAE,eAAe,CAAA;IACxB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAKD,wBAAgB,iBAAiB,IAAI,uBAAuB,CAE3D;AAED,wBAAgB,aAAa,IAAI,IAAI,CAIpC;AA0CD,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,eAAe,CAAA;IACvB,MAAM,EAAE,MAAM,CAAA;CACf;AAED,wBAAsB,iBAAiB,CACrC,MAAM,EAAE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