@eddyskywalker/dsh-chatgpt-subscription 0.26.1 → 0.27.1
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 +28 -0
- package/README.md +57 -0
- package/lib/client.js +2176 -116
- package/lib/client.js.map +1 -1
- package/lib/index.js +2112 -93
- package/lib/types/client/index.d.ts +2 -0
- package/lib/types/client/index.d.ts.map +1 -1
- package/lib/types/client/progress-updates/contracts.d.ts +125 -0
- package/lib/types/client/progress-updates/contracts.d.ts.map +1 -0
- package/lib/types/client/progress-updates/guide-artwork.d.ts +28 -0
- package/lib/types/client/progress-updates/guide-artwork.d.ts.map +1 -0
- package/lib/types/client/progress-updates/host-source.d.ts +128 -0
- package/lib/types/client/progress-updates/host-source.d.ts.map +1 -0
- package/lib/types/client/progress-updates/index.d.ts +91 -0
- package/lib/types/client/progress-updates/index.d.ts.map +1 -0
- package/lib/types/client/progress-updates/locales.d.ts +127 -0
- package/lib/types/client/progress-updates/locales.d.ts.map +1 -0
- package/lib/types/client/progress-updates/markdown-lite.d.ts +60 -0
- package/lib/types/client/progress-updates/markdown-lite.d.ts.map +1 -0
- package/lib/types/client/progress-updates/progress-row.d.ts +87 -0
- package/lib/types/client/progress-updates/progress-row.d.ts.map +1 -0
- package/lib/types/client/progress-updates/settings-binding.d.ts +71 -0
- package/lib/types/client/progress-updates/settings-binding.d.ts.map +1 -0
- package/lib/types/client/progress-updates/settings-section.d.ts +57 -0
- package/lib/types/client/progress-updates/settings-section.d.ts.map +1 -0
- package/lib/types/client/progress-updates/styles.d.ts +34 -0
- package/lib/types/client/progress-updates/styles.d.ts.map +1 -0
- package/lib/types/client/progress-updates/tool-name.d.ts +14 -0
- package/lib/types/client/progress-updates/tool-name.d.ts.map +1 -0
- package/lib/types/client/progress-updates/updates-panel.d.ts +113 -0
- package/lib/types/client/progress-updates/updates-panel.d.ts.map +1 -0
- package/lib/types/client/step-code/locales.d.ts +2 -2
- package/lib/types/client/workbuddy/WorkBuddySection.d.ts.map +1 -1
- package/lib/types/client/workbuddy/locales.d.ts +108 -0
- package/lib/types/client/workbuddy/locales.d.ts.map +1 -1
- package/lib/types/client/workbuddy/styles.d.ts.map +1 -1
- package/lib/types/client/workbuddy/useWorkBuddySection.d.ts +9 -1
- package/lib/types/client/workbuddy/useWorkBuddySection.d.ts.map +1 -1
- package/lib/types/host/progress-updates/index.d.ts +90 -0
- package/lib/types/host/progress-updates/index.d.ts.map +1 -0
- package/lib/types/host/progress-updates/nudge.d.ts +91 -0
- package/lib/types/host/progress-updates/nudge.d.ts.map +1 -0
- package/lib/types/host/progress-updates/prompt.d.ts +34 -0
- package/lib/types/host/progress-updates/prompt.d.ts.map +1 -0
- package/lib/types/host/progress-updates/routes.d.ts +39 -0
- package/lib/types/host/progress-updates/routes.d.ts.map +1 -0
- package/lib/types/host/progress-updates/store.d.ts +74 -0
- package/lib/types/host/progress-updates/store.d.ts.map +1 -0
- package/lib/types/host/progress-updates/tool.d.ts +42 -0
- package/lib/types/host/progress-updates/tool.d.ts.map +1 -0
- package/lib/types/host/reasoning-collapse-guard/index.d.ts +5 -0
- package/lib/types/host/reasoning-collapse-guard/index.d.ts.map +1 -1
- package/lib/types/host/web-provider-reconciler.d.ts +34 -0
- package/lib/types/host/web-provider-reconciler.d.ts.map +1 -0
- package/lib/types/host/workbuddy/account-pool.d.ts +32 -1
- package/lib/types/host/workbuddy/account-pool.d.ts.map +1 -1
- package/lib/types/host/workbuddy/adapter.d.ts +32 -0
- package/lib/types/host/workbuddy/adapter.d.ts.map +1 -1
- package/lib/types/host/workbuddy/atrest.d.ts +98 -0
- package/lib/types/host/workbuddy/atrest.d.ts.map +1 -0
- package/lib/types/host/workbuddy/checkin.d.ts +16 -0
- package/lib/types/host/workbuddy/checkin.d.ts.map +1 -1
- package/lib/types/host/workbuddy/client.d.ts +9 -0
- package/lib/types/host/workbuddy/client.d.ts.map +1 -1
- package/lib/types/host/workbuddy/dsml.d.ts +55 -0
- package/lib/types/host/workbuddy/dsml.d.ts.map +1 -0
- package/lib/types/host/workbuddy/guardrails.d.ts +111 -0
- package/lib/types/host/workbuddy/guardrails.d.ts.map +1 -0
- package/lib/types/host/workbuddy/mapper.d.ts +11 -0
- package/lib/types/host/workbuddy/mapper.d.ts.map +1 -1
- package/lib/types/host/workbuddy/model-catalog.d.ts +8 -1
- package/lib/types/host/workbuddy/model-catalog.d.ts.map +1 -1
- package/lib/types/host/workbuddy/outbound-identity.d.ts +66 -0
- package/lib/types/host/workbuddy/outbound-identity.d.ts.map +1 -0
- package/lib/types/host/workbuddy/routes.d.ts +8 -1
- package/lib/types/host/workbuddy/routes.d.ts.map +1 -1
- package/lib/types/host/workbuddy/token-store.d.ts +93 -0
- package/lib/types/host/workbuddy/token-store.d.ts.map +1 -1
- package/lib/types/index.d.ts +63 -5
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/shared/workbuddy-contracts.d.ts +54 -2
- package/lib/types/shared/workbuddy-contracts.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -5,6 +5,7 @@ import { type WorkBuddyModelEntry } from './model-catalog.ts';
|
|
|
5
5
|
import { type AttachmentImageReader } from './mapper.ts';
|
|
6
6
|
import type { WorkBuddyCredentials } from './token-store.ts';
|
|
7
7
|
import type { WorkBuddyAccountPool } from './account-pool.ts';
|
|
8
|
+
import { type WorkBuddyUsageLedger } from './guardrails.ts';
|
|
8
9
|
/**
|
|
9
10
|
* Effort this route materializes when the caller names none.
|
|
10
11
|
*
|
|
@@ -19,6 +20,13 @@ export declare function resolveDefaultReasoningEffort(efforts: readonly string[]
|
|
|
19
20
|
/** Cooldown a 429 imposes when the service names no reset instant. */
|
|
20
21
|
export declare const POOL_COOLDOWN_MS: number;
|
|
21
22
|
export interface WorkBuddyAdapterOptions {
|
|
23
|
+
/**
|
|
24
|
+
* Per-account daily token counters behind the local guardrails.
|
|
25
|
+
*
|
|
26
|
+
* Absent means the guardrails cannot be evaluated, so a deployment without it
|
|
27
|
+
* never refuses a request for a reason nothing is counting.
|
|
28
|
+
*/
|
|
29
|
+
usageLedger?: WorkBuddyUsageLedger;
|
|
22
30
|
fetchFn?: typeof fetch;
|
|
23
31
|
attachments?: AttachmentImageReader;
|
|
24
32
|
/** Live catalog loader seam; defaults to the gateway `/v3/config` call. */
|
|
@@ -79,6 +87,14 @@ export declare class WorkBuddyAdapter extends LlmAdapter {
|
|
|
79
87
|
* A candidate the model does not accept is discarded rather than sent, since
|
|
80
88
|
* the endpoint rejects an unsupported level with `code 11150`.
|
|
81
89
|
*/
|
|
90
|
+
/**
|
|
91
|
+
* Accounts the LOCAL guardrails refuse for this model right now.
|
|
92
|
+
*
|
|
93
|
+
* Reads only numbers this plugin already owns — the billing snapshot's
|
|
94
|
+
* remaining credits and this line's own token counters — so it never becomes a
|
|
95
|
+
* second, disagreeing source of truth about the upstream allowance.
|
|
96
|
+
*/
|
|
97
|
+
private guardrailBlockedAccounts;
|
|
82
98
|
private effortFor;
|
|
83
99
|
private requestStream;
|
|
84
100
|
}
|
|
@@ -91,6 +107,22 @@ export declare class WorkBuddyAdapter extends LlmAdapter {
|
|
|
91
107
|
* the instant the allowance resets.
|
|
92
108
|
*/
|
|
93
109
|
export declare function classifyFailure(status: number, detail: string, headers?: Headers): LlmError;
|
|
110
|
+
/**
|
|
111
|
+
* The reset instant a quota refusal names, as a delay from now.
|
|
112
|
+
*
|
|
113
|
+
* A 24h allowance that is exhausted answers 429 / `code 6004` with the wall
|
|
114
|
+
* clock it lifts — but only in the MESSAGE, never in a header, and in two
|
|
115
|
+
* realm-specific wordings (measured: intl "… resets at 2026-09-20 10:50:48
|
|
116
|
+
* UTC+8", cn "… 将在 2026-10-09 14:44:59 UTC+8 重置"). Reading the status alone
|
|
117
|
+
* therefore loses the only fact that says how long the account is out, and the
|
|
118
|
+
* pool parks a 24-hour limit for five minutes before trying it again.
|
|
119
|
+
*
|
|
120
|
+
* Deliberately tolerant, in the same direction as their gateway: an unparseable
|
|
121
|
+
* body yields `undefined` (callers keep their default cooldown) rather than an
|
|
122
|
+
* error, because this runs on a failure path. An absent `UTC±h` marker means
|
|
123
|
+
* UTC, which is how the sibling implementation reads it too.
|
|
124
|
+
*/
|
|
125
|
+
export declare function readRateLimitReset(detail: string, now?: number): number | undefined;
|
|
94
126
|
/** Read the subscription's own numeric error code out of a response body. */
|
|
95
127
|
export declare function readErrorCode(detail: string): number | null;
|
|
96
128
|
export { PROVIDER_ID, PROVIDER_NAME };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../../src/host/workbuddy/adapter.ts"],"names":[],"mappings":"AAGA,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;AAIpB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAC5D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../../src/host/workbuddy/adapter.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,UAAU,EACV,QAAQ,EACR,iBAAiB,EAEjB,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,m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,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAK3D;AAED,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,CAAA"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `$wbEncrypted` at-rest credential envelope.
|
|
3
|
+
*
|
|
4
|
+
* The CodeBuddy/WorkBuddy desktop client stopped writing plaintext tokens on
|
|
5
|
+
* 2026-09-24: `auth.accessToken` / `auth.refreshToken` became
|
|
6
|
+
* `{"$wbEncrypted": 1, "envelope": base64}` (the domestic build also seals
|
|
7
|
+
* `nickname` / `phoneNumber`). Reading such a file the way this plugin used to
|
|
8
|
+
* yields the envelope TEXT as the bearer token, so every request answers 401 —
|
|
9
|
+
* the adoption path has to decrypt before it can use the credential.
|
|
10
|
+
*
|
|
11
|
+
* The scheme below is transcribed from the client's `packages/at-rest-crypto`
|
|
12
|
+
* as reimplemented by workbuddy2api-hub (`wb_atrest.py`, MIT); the framing
|
|
13
|
+
* constants are the part that must match byte for byte:
|
|
14
|
+
*
|
|
15
|
+
* key = sha256(atRestSecretKey as an ASCII string) # the protector key
|
|
16
|
+
* keyId = sha256(key).hex[0..16] # `protectorKeyId`
|
|
17
|
+
* AAD = "WB-AAD\0" | 0x01 | LP(fileMagic) | LP("sym-v1")
|
|
18
|
+
* | u32(suite) | LP(keyId) | framingCode | 0x00 | 0x00
|
|
19
|
+
* envelope = base64(JSON{suite, keyId, nonce, authTag, ciphertext}) # AES-256-GCM
|
|
20
|
+
* framing : the keyblob's wrapped master key is `WBEF1`/1, a sealed `.info`
|
|
21
|
+
* field is `WBEV1`/2 — the SAME protector key opens both.
|
|
22
|
+
*
|
|
23
|
+
* Key material never leaves the process and is never logged: the user pastes it
|
|
24
|
+
* once, it is stored through the platform credential store (DPAPI / Keychain /
|
|
25
|
+
* Secret Service), and every read re-validates it against the client's own
|
|
26
|
+
* keyblob when that file exists.
|
|
27
|
+
*/
|
|
28
|
+
/** Field name the client uses to mark a sealed value. */
|
|
29
|
+
export declare const ENVELOPE_KEY = "$wbEncrypted";
|
|
30
|
+
/** Framing kinds and the code each carries in the AAD. */
|
|
31
|
+
declare const FRAMING: {
|
|
32
|
+
readonly file: {
|
|
33
|
+
readonly magic: "WBEF1";
|
|
34
|
+
readonly code: 1;
|
|
35
|
+
};
|
|
36
|
+
readonly field: {
|
|
37
|
+
readonly magic: "WBEV1";
|
|
38
|
+
readonly code: 2;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
type Framing = keyof typeof FRAMING;
|
|
42
|
+
/** Every failure the at-rest path can report to a user. */
|
|
43
|
+
export declare class AtRestError extends Error {
|
|
44
|
+
constructor(message: string);
|
|
45
|
+
}
|
|
46
|
+
/** The GCM associated data, byte-identical to the client's. */
|
|
47
|
+
export declare function associatedData(keyId: string, suite: number, framing: Framing): Buffer;
|
|
48
|
+
/** `protectorKeyId` / `envelope.keyId`: the first 16 hex characters of sha256(key). */
|
|
49
|
+
export declare function deriveKeyId(key: Buffer): string;
|
|
50
|
+
/**
|
|
51
|
+
* Whether a value is a sealed envelope rather than plaintext.
|
|
52
|
+
*
|
|
53
|
+
* Older clients sometimes stored the whole envelope as a JSON STRING in the
|
|
54
|
+
* field, so that shape is recognised too.
|
|
55
|
+
*/
|
|
56
|
+
export declare function isSealedValue(value: unknown): boolean;
|
|
57
|
+
interface SealedEnvelope {
|
|
58
|
+
suite: number;
|
|
59
|
+
keyId: string;
|
|
60
|
+
nonce: Buffer;
|
|
61
|
+
authTag: Buffer;
|
|
62
|
+
ciphertext: Buffer;
|
|
63
|
+
}
|
|
64
|
+
/** Split one envelope into its GCM parts. */
|
|
65
|
+
export declare function parseEnvelope(value: unknown): SealedEnvelope;
|
|
66
|
+
/** Open one envelope with the protector key, returning the plaintext bytes. */
|
|
67
|
+
export declare function openEnvelope(key: Buffer, value: unknown, framing: Framing): Buffer;
|
|
68
|
+
/** Decrypt a field that may be sealed, leaving plaintext values untouched. */
|
|
69
|
+
export declare function openSealedField(key: Buffer, value: unknown): string;
|
|
70
|
+
/**
|
|
71
|
+
* Normalise a pasted secret into the 32-byte protector key.
|
|
72
|
+
*
|
|
73
|
+
* Two spellings are accepted, neither requiring the user to compute anything:
|
|
74
|
+
* a 64-character hex protector key (used as-is), or the 44-character base64
|
|
75
|
+
* `atRestSecretKey` the client carries in its payload — that one is hashed as
|
|
76
|
+
* the STRING, which is what produces the protector key.
|
|
77
|
+
*/
|
|
78
|
+
export declare function parseKeyText(text: string): Buffer;
|
|
79
|
+
/** Path of the client's keyblob, or null when the client is not installed here. */
|
|
80
|
+
export declare function keyBlobPath(): string | null;
|
|
81
|
+
/**
|
|
82
|
+
* Validate a protector key against the client's own keyblob.
|
|
83
|
+
*
|
|
84
|
+
* This is the check that turns a typo into an error instead of a mystery: the
|
|
85
|
+
* key must match the `static-v1` slot's `protectorKeyId` and must unwrap a
|
|
86
|
+
* 32-byte master whose derived id matches the blob's own `keyId`. Returns
|
|
87
|
+
* `false` when there is no keyblob to check against (the desktop client is not
|
|
88
|
+
* installed on this machine) — absence of evidence, not evidence of a bad key.
|
|
89
|
+
*/
|
|
90
|
+
export declare function verifyKeyAgainstKeyBlob(key: Buffer): Promise<boolean>;
|
|
91
|
+
/** Install the protector key for this process (already persisted by the caller). */
|
|
92
|
+
export declare function setActiveAtRestKey(key: Buffer | null): void;
|
|
93
|
+
/** The protector key this process holds, if any. */
|
|
94
|
+
export declare function activeAtRestKey(): Buffer | null;
|
|
95
|
+
/** Whether sealed credentials can be opened right now. */
|
|
96
|
+
export declare function hasAtRestKey(): boolean;
|
|
97
|
+
export {};
|
|
98
|
+
//# sourceMappingURL=atrest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"atrest.d.ts","sourceRoot":"","sources":["../../../../src/host/workbuddy/atrest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAQH,yDAAyD;AACzD,eAAO,MAAM,YAAY,iBAAi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ACpF,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAE3D;AAED,oDAAoD;AACpD,wBAAgB,eAAe,IAAI,MAAM,GAAG,IAAI,CAE/C;AAED,0DAA0D;AAC1D,wBAAgB,YAAY,IAAI,OAAO,CAEtC"}
|
|
@@ -48,6 +48,16 @@ export declare const CHECKIN_TIMEOUT_MS = 20000;
|
|
|
48
48
|
* costing at most one status request per hour per account.
|
|
49
49
|
*/
|
|
50
50
|
export declare const CHECKIN_INACTIVE_RECHECK_MS: number;
|
|
51
|
+
/**
|
|
52
|
+
* Random pause between two accounts in one pass.
|
|
53
|
+
*
|
|
54
|
+
* Sequential accounts already serialise their requests, but they still arrive as
|
|
55
|
+
* one tight cluster from one outbound IP; a dozen-account pool doing that at the
|
|
56
|
+
* same minute is the burst pattern the sibling gateway added jitter for after
|
|
57
|
+
* seeing upstream rate-limit whole pools.
|
|
58
|
+
*/
|
|
59
|
+
export declare const CHECKIN_JITTER_MIN_MS = 2000;
|
|
60
|
+
export declare const CHECKIN_JITTER_MAX_MS = 5000;
|
|
51
61
|
/** State document the scheduler keeps beside the other plugin stores. */
|
|
52
62
|
export declare function checkinStatePath(): string;
|
|
53
63
|
/** Local calendar day an instant belongs to; state entries are keyed by it. */
|
|
@@ -68,6 +78,10 @@ export interface WorkBuddyCheckinServiceOptions {
|
|
|
68
78
|
ready?: () => Promise<void>;
|
|
69
79
|
/** Clock injection for tests. */
|
|
70
80
|
now?: () => number;
|
|
81
|
+
/** Wait between two accounts in one pass; injected so tests run without delays. */
|
|
82
|
+
pause?: (ms: number) => Promise<void>;
|
|
83
|
+
/** Jitter source; injected so a test can pin the delay it caused. */
|
|
84
|
+
random?: () => number;
|
|
71
85
|
logger?: {
|
|
72
86
|
info(message: string): void;
|
|
73
87
|
warn(message: string): void;
|
|
@@ -83,6 +97,8 @@ export declare class WorkBuddyCheckinService {
|
|
|
83
97
|
private readonly fetchFn;
|
|
84
98
|
private readonly statePath;
|
|
85
99
|
private readonly now;
|
|
100
|
+
private readonly pause;
|
|
101
|
+
private readonly random;
|
|
86
102
|
private readonly logger;
|
|
87
103
|
private state;
|
|
88
104
|
private loaded;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkin.d.ts","sourceRoot":"","sources":["../../../../src/host/workbuddy/checkin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAOH,OAAO,EAEL,KAAK,mBAAmB,EAEzB,MAAM,kBAAkB,CAAA;AACzB,OAAO,KAAK,EACV,wBAAwB,EACxB,uBAAuB,EACxB,MAAM,qCAAqC,CAAA;AAE5C,2EAA2E;AAC3E,eAAO,MAAM,mBAAmB,2CAA2C,CAAA;AAC3E,wEAAwE;AACxE,eAAO,MAAM,YAAY,iCAAiC,CAAA;AAC1D;;;;GAIG;AACH,eAAO,MAAM,eAAe,QAAiB,CAAA;AAC7C,kEAAkE;AAClE,eAAO,MAAM,mBAAmB,IAAI,CAAA;AACpC,eAAO,MAAM,kBAAkB,QAAS,CAAA;AACxC;;;;;;;GAOG;AACH,eAAO,MAAM,2BAA2B,QAAiB,CAAA;AAEzD,yEAAyE;AACzE,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED,+EAA+E;AAC/E,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAKrD;AA2GD,MAAM,WAAW,8BAA8B;IAC7C,OAAO,CAAC,EAAE,OAAO,KAAK,CAAA;IACtB,wFAAwF;IACxF,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,6EAA6E;IAC7E,QAAQ,EAAE,MAAM,wBAAwB,CAAA;IACxC;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IAC3B,iCAAiC;IACjC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAA;IAClB,MAAM,CAAC,EAAE;QACP,IAAI,CAAC,OAAO,EAAE,MAA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;IAC9E,OAAO,CAAC,YAAY;IAWpB;;;;;;OAMG;YACW,YAAY;IAgB1B;;;OAGG;IACG,OAAO,IAAI,OAAO,CAAC,uBAAuB,CAAC;YA+BnC,IAAI;YAuBJ,IAAI;YAaJ,IAAI;CAwBnB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { WorkBuddyAccount, WorkBuddyAccountQuota, WorkBuddyMeter } from '../../shared/workbuddy-contracts.ts';
|
|
2
|
+
import { type WorkBuddyOutboundProduct } from './outbound-identity.ts';
|
|
2
3
|
import { PROVIDER_ID, PROVIDER_NAME } from './types.ts';
|
|
3
4
|
import { FileCredentialStore, type WorkBuddyCredentials } from './token-store.ts';
|
|
4
5
|
import type { WorkBuddyTokenIdentity } from './identity.ts';
|
|
@@ -17,6 +18,14 @@ export interface WorkBuddyRequestOptions {
|
|
|
17
18
|
* they already worked with.
|
|
18
19
|
*/
|
|
19
20
|
export interface WorkBuddyChannelOptions {
|
|
21
|
+
/**
|
|
22
|
+
* Which client identity this request presents.
|
|
23
|
+
*
|
|
24
|
+
* Omitted means the line's shipped identity (`cli`). Only the chat call ever
|
|
25
|
+
* sets it: the config, billing and refresh surfaces are the ones measured to
|
|
26
|
+
* accept the CLI identity, and the choice exists for the chat fingerprint.
|
|
27
|
+
*/
|
|
28
|
+
product?: WorkBuddyOutboundProduct;
|
|
20
29
|
/**
|
|
21
30
|
* Harness session the chat call belongs to.
|
|
22
31
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../src/host/workbuddy/client.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,gBAAgB,EAChB,qBAAqB,EACrB,cAAc,EACf,MAAM,qCAAqC,CAAA;AAC5C,OAAO,EAsBL,WAAW,EACX,aAAa,EAKd,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,mBAAmB,EAAsB,KAAK,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AACrG,OA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AAE,CAAA"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Recovery of tool calls the model PRINTED instead of emitting structurally.
|
|
3
|
+
*
|
|
4
|
+
* Measured upstream behaviour (and the reason workbuddy2api-hub has the same
|
|
5
|
+
* recovery, `wb_proxy.py` "Printed tool calls on the Chat Completions path"):
|
|
6
|
+
* a tools request sometimes answers with the call spelled out inside `content`
|
|
7
|
+
* — either the full-width DSML form
|
|
8
|
+
*
|
|
9
|
+
* <||DSML|| calls><||DSML|| invoke name="run_code">
|
|
10
|
+
* <||DSML|| parameter name="code">print(1)</||DSML|| parameter>
|
|
11
|
+
* </||DSML|| invoke></||DSML|| calls>
|
|
12
|
+
*
|
|
13
|
+
* or a hybrid the model mixes on its own: a plain opening tag closed by DSML
|
|
14
|
+
* tags, with the first parameter's close tag swallowed. Forwarded verbatim the
|
|
15
|
+
* client sees prose, finds no call, and the turn simply ends — reported by
|
|
16
|
+
* users as "it keeps stopping by itself".
|
|
17
|
+
*
|
|
18
|
+
* A structured `tool_calls` delta always wins; this only runs for text, which
|
|
19
|
+
* is why the recovery is a pure function over the accumulated content.
|
|
20
|
+
*/
|
|
21
|
+
/** One recovered call, in the shape the mapper emits. */
|
|
22
|
+
export interface PrintedToolCall {
|
|
23
|
+
id: string;
|
|
24
|
+
name: string;
|
|
25
|
+
arguments: string;
|
|
26
|
+
}
|
|
27
|
+
/** A successful recovery: the calls plus the prose left behind. */
|
|
28
|
+
export interface PrintedRecovery {
|
|
29
|
+
calls: PrintedToolCall[];
|
|
30
|
+
clean: string;
|
|
31
|
+
}
|
|
32
|
+
/** Recover the full-width `<||DSML|| …>` spelling. */
|
|
33
|
+
export declare function parseDsmlToolCalls(text: string): PrintedRecovery | null;
|
|
34
|
+
/**
|
|
35
|
+
* Recover the hybrid spelling, driven by the `<parameter>` elements.
|
|
36
|
+
*
|
|
37
|
+
* Parameter elements are spelled the same way in both shapes and a parameter
|
|
38
|
+
* name is the one thing a call cannot do without, so they are the anchor; the
|
|
39
|
+
* nearest preceding opening tag that is neither a wrapper nor a parameter names
|
|
40
|
+
* the tool.
|
|
41
|
+
*/
|
|
42
|
+
export declare function parseLeakedToolCalls(text: string): PrintedRecovery | null;
|
|
43
|
+
/** Recover a printed call under either spelling. */
|
|
44
|
+
export declare function recoverPrintedToolCalls(text: string): PrintedRecovery | null;
|
|
45
|
+
/**
|
|
46
|
+
* Index from which a streaming text buffer must be held back.
|
|
47
|
+
*
|
|
48
|
+
* The earliest `<` that either opens a recognisable tag or could still grow
|
|
49
|
+
* into one (a delta may split `<parameter` across frames), or -1 when the
|
|
50
|
+
* whole buffer is safe to emit as prose.
|
|
51
|
+
*/
|
|
52
|
+
export declare function printedCallHoldIndex(text: string): number;
|
|
53
|
+
/** Whether a held buffer has already reached a closing tag. */
|
|
54
|
+
export declare function printedCallLooksComplete(text: string): boolean;
|
|
55
|
+
//# sourceMappingURL=dsml.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dsml.d.ts","sourceRoot":"","sources":["../../../../src/host/workbuddy/dsml.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAIH,yDAAyD;AACzD,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,mEAAmE;AACnE,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,eAAe,EAAE,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;CACf;AA2CD,sDAAsD;AACtD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,GAAG,IAAI,CAiBvE;AAiBD;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,GAAG,IAAI,CAyFzE;AAED,oDAAoD;AACpD,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,GAAG,IAAI,CAE5E;AAgBD;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CASzD;AAED,+DAA+D;AAC/D,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE9D"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Local quota guardrails for the WorkBuddy line.
|
|
3
|
+
*
|
|
4
|
+
* The subscription meters an account × model over a 24h window (429 `code
|
|
5
|
+
* 6004`), but it only says so AFTER the window is gone — and on the shared
|
|
6
|
+
* account that window is minutes of a large model or a day of a small one. These
|
|
7
|
+
* guardrails stop serving BEFORE that happens, so an exhausted window never has
|
|
8
|
+
* to be discovered by a user staring at a 429.
|
|
9
|
+
*
|
|
10
|
+
* Three of the four guardrails workbuddy2api-hub ships are reproduced here, and
|
|
11
|
+
* all three are EXACT — they read numbers this plugin already has:
|
|
12
|
+
*
|
|
13
|
+
* reserveCredits stop the account when its remaining credits fall below N
|
|
14
|
+
* (the billing snapshot already reports the remainder)
|
|
15
|
+
* dailyTokens stop the account for the rest of the local day at N tokens
|
|
16
|
+
* modelDailyTokens stop ONE model for the rest of the local day at N tokens
|
|
17
|
+
*
|
|
18
|
+
* The fourth one there — a daily CREDITS budget — is deliberately NOT
|
|
19
|
+
* reproduced: a request's credit cost is not on the wire this route reads, and
|
|
20
|
+
* deriving it from the catalog multiplier × tokens would invent a number that
|
|
21
|
+
* silently diverges from the bill. A guardrail that lies is worse than none.
|
|
22
|
+
*
|
|
23
|
+
* `0` means OFF for every field, and the default is all-off: an install that
|
|
24
|
+
* never opens this setting behaves exactly as before.
|
|
25
|
+
*/
|
|
26
|
+
import type { WorkBuddyGuardrailsDto } from '../../shared/workbuddy-contracts.ts';
|
|
27
|
+
/**
|
|
28
|
+
* The three exact guardrails.
|
|
29
|
+
*
|
|
30
|
+
* The shape has ONE definition — the shared wire contract — so the card and the
|
|
31
|
+
* enforcement can never disagree about a field name.
|
|
32
|
+
*/
|
|
33
|
+
export type WorkBuddyGuardrails = WorkBuddyGuardrailsDto;
|
|
34
|
+
/** Shipped default: every guardrail off. */
|
|
35
|
+
export declare const DEFAULT_GUARDRAILS: WorkBuddyGuardrails;
|
|
36
|
+
/** Narrow a stored or patched value into guardrails; anything unusable means off. */
|
|
37
|
+
export declare function normalizeGuardrails(value: unknown): WorkBuddyGuardrails;
|
|
38
|
+
/** Whether any guardrail is armed; a no-op check must stay cheap. */
|
|
39
|
+
export declare function guardrailsArmed(guardrails: WorkBuddyGuardrails): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* The local calendar day a counter belongs to.
|
|
42
|
+
*
|
|
43
|
+
* Local, not UTC, because the reset the user reasons about is their own
|
|
44
|
+
* midnight — the same choice this line makes for the CN check-in day.
|
|
45
|
+
*/
|
|
46
|
+
export declare function localDayKey(now?: number): string;
|
|
47
|
+
/** Per-account counters for one day. */
|
|
48
|
+
export interface UsageLedgerEntry {
|
|
49
|
+
tokens: number;
|
|
50
|
+
perModel: Record<string, number>;
|
|
51
|
+
}
|
|
52
|
+
/** Where the local usage counters live. */
|
|
53
|
+
export declare function usageLedgerPath(): string;
|
|
54
|
+
/**
|
|
55
|
+
* Token counters per account per local day.
|
|
56
|
+
*
|
|
57
|
+
* Deliberately a small persisted document rather than an accounting system: it
|
|
58
|
+
* exists to answer one question ("has this account / model used its day?") and a
|
|
59
|
+
* restart must not forget it, or a guardrail would reset by restarting DSH.
|
|
60
|
+
*/
|
|
61
|
+
export declare class WorkBuddyUsageLedger {
|
|
62
|
+
private readonly filePath;
|
|
63
|
+
private readonly now;
|
|
64
|
+
private document;
|
|
65
|
+
private loaded;
|
|
66
|
+
private writing;
|
|
67
|
+
constructor(filePath?: string, now?: () => number);
|
|
68
|
+
/** Read the counters once; a missing or unreadable file starts a fresh day. */
|
|
69
|
+
load(): Promise<void>;
|
|
70
|
+
/** Drop yesterday's counters the moment a read notices the day changed. */
|
|
71
|
+
private rollIfNewDay;
|
|
72
|
+
/** Tokens one account has used today, across models. */
|
|
73
|
+
tokensToday(accountId: string): number;
|
|
74
|
+
/** Tokens one account has used today on one model. */
|
|
75
|
+
modelTokensToday(accountId: string, model: string): number;
|
|
76
|
+
/** Today's counters, for the settings card and for tests. */
|
|
77
|
+
snapshot(): Readonly<Record<string, UsageLedgerEntry>>;
|
|
78
|
+
/**
|
|
79
|
+
* Add one request's tokens.
|
|
80
|
+
*
|
|
81
|
+
* Serialized through a promise chain: two concurrent requests on different
|
|
82
|
+
* accounts would otherwise read the same document, add their own counts and
|
|
83
|
+
* write, losing one of them.
|
|
84
|
+
*/
|
|
85
|
+
record(accountId: string, model: string, tokens: number): Promise<void>;
|
|
86
|
+
private persist;
|
|
87
|
+
}
|
|
88
|
+
/** Why an account may not serve a request. */
|
|
89
|
+
export type GuardrailReason = 'reserve-credits' | 'daily-tokens' | 'model-daily-tokens';
|
|
90
|
+
/** The verdict for one account on one model. */
|
|
91
|
+
export type GuardrailVerdict = {
|
|
92
|
+
allowed: true;
|
|
93
|
+
} | {
|
|
94
|
+
allowed: false;
|
|
95
|
+
reason: GuardrailReason;
|
|
96
|
+
detail: string;
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* Decide whether one account may serve one model right now.
|
|
100
|
+
*
|
|
101
|
+
* Pure on purpose: every number it reads is passed in, so the decision can be
|
|
102
|
+
* tested without a pool, a clock or a network.
|
|
103
|
+
*/
|
|
104
|
+
export declare function evaluateGuardrails(input: {
|
|
105
|
+
guardrails: WorkBuddyGuardrails;
|
|
106
|
+
tokensToday: number;
|
|
107
|
+
modelTokensToday: number;
|
|
108
|
+
/** Remaining credits from the billing snapshot; null when never read. */
|
|
109
|
+
remainingCredits: number | null | undefined;
|
|
110
|
+
}): GuardrailVerdict;
|
|
111
|
+
//# sourceMappingURL=guardrails.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guardrails.d.ts","sourceRoot":"","sources":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D,QAAQ,IAAI,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAKtD;;;;;;OAMG;IACG,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;YAY/D,OAAO;CAMtB;AAED,8CAA8C;AAC9C,MAAM,MAAM,eAAe,GAAG,iBAAiB,GAAG,cAAc,GAAG,oBAAoB,CAAA;AAEvF,gDAAgD;AAChD,MAAM,MAAM,gBAAgB,GACxB;IAAE,OAAO,EAAE,IAAI,CAAA;CAAE,GACjB;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,eAAe,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAA;AAE/D;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE;IACxC,UAAU,EAAE,mBAAmB,CAAA;IAC/B,WAAW,EAAE,MAAM,CAAA;IACnB,gBAAgB,EAAE,MAAM,CAAA;IACxB,yEAAyE;IACzE,gBAAgB,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;CAC5C,GAAG,gBAAgB,CA4BnB"}
|
|
@@ -101,6 +101,17 @@ export interface WorkBuddyStreamState {
|
|
|
101
101
|
cacheWriteTokens: number;
|
|
102
102
|
reasoningTokens: number;
|
|
103
103
|
sawUsage: boolean;
|
|
104
|
+
/**
|
|
105
|
+
* Text held back while it may still turn into a printed tool call.
|
|
106
|
+
*
|
|
107
|
+
* `holding` is set once a `<` that could open a call region was seen; the
|
|
108
|
+
* buffer then grows until the region closes (or the cap is hit), and is
|
|
109
|
+
* resolved into prose or calls exactly once.
|
|
110
|
+
*/
|
|
111
|
+
printed: {
|
|
112
|
+
pending: string;
|
|
113
|
+
holding: boolean;
|
|
114
|
+
};
|
|
104
115
|
}
|
|
105
116
|
export declare function createStreamState(): WorkBuddyStreamState;
|
|
106
117
|
/** Feed one SSE line from `/v2/chat/completions`. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapper.d.ts","sourceRoot":"","sources":["../../../../src/host/workbuddy/mapper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,EAGL,KAAK,oBAAoB,EAEzB,KAAK,eAAe,EAEpB,KAAK,WAAW,EAEjB,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAAK,EAAE,eAAe,EAAsB,MAAM,6BAA6B,CAAA;
|
|
1
|
+
{"version":3,"file":"mapper.d.ts","sourceRoot":"","sources":["../../../../src/host/workbuddy/mapper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,EAGL,KAAK,oBAAoB,EAEzB,KAAK,eAAe,EAEpB,KAAK,WAAW,EAEjB,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAAK,EAAE,eAAe,EAAsB,MAAM,6BAA6B,CAAA;AA8BtF;;;;;;;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;AAgEvD;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,eAAe,GAAG,e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AM,CAAA;IACvB,QAAQ,EAAE,OAAO,CAAA;IACjB;;;;;;OAMG;IACH,OAAO,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE,CAAA;CAC/C;AAED,wBAAgB,iBAAiB,IAAI,oBAAoB,CAkBxD;AAwID,qDAAqD;AACrD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,oBAAoB,GAAG,WAAW,EAAE,CAiF1F;AAuED,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"}
|
|
@@ -193,7 +193,14 @@ export declare function groupWorkBuddyModelsByVendor<T extends {
|
|
|
193
193
|
export declare function modelsForRegion(region: WorkBuddyRegion, catalog?: readonly WorkBuddyModelEntry[]): WorkBuddyModelEntry[];
|
|
194
194
|
/** Whether one model accepts image input. */
|
|
195
195
|
export declare function workBuddyModelSupportsImage(id: string, catalog?: readonly WorkBuddyModelEntry[]): boolean;
|
|
196
|
-
/**
|
|
196
|
+
/**
|
|
197
|
+
* Reasoning ladder one model accepts, plus `none` when its trace can be turned off.
|
|
198
|
+
*
|
|
199
|
+
* The ladder in the catalog is what the model ACCEPTS, so `none` never appears
|
|
200
|
+
* in it; `canDisableThinking` is the separate statement that switching thinking
|
|
201
|
+
* off is allowed, and this is the single place that turns it into the one level
|
|
202
|
+
* the picker can offer. Callers that need the ladder alone read the entry.
|
|
203
|
+
*/
|
|
197
204
|
export declare function workBuddyReasoningEfforts(id: string, catalog?: readonly WorkBuddyModelEntry[]): readonly string[];
|
|
198
205
|
/**
|
|
199
206
|
* Consumption multiplier per region one model publishes.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-catalog.d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;;;;GAMG;AACH,wBAAgB,4BAA4B,CAAC,CAAC,SAAS;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,GAAG,CAAC,EAAE,CAWhG;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,eAAe,EACvB,OAAO,GAAE,SAAS,mBAAmB,EAAoB,GACxD,mBAAmB,EAAE,CAEvB;AAED,6CAA6C;AAC7C,wBAAgB,2BAA2B,CACzC,EAAE,EAAE,MAAM,EACV,OAAO,GAAE,SAAS,mBAAmB,EAAoB,GACxD,OAAO,CAET;AAED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CACvC,EAAE,EAAE,MAAM,EACV,OAAO,GAAE,SAAS,mBAAmB,EAAoB,GACxD,SAAS,MAAM,EAAE,CAInB;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,EAAE,EAAE,MAAM,EACV,OAAO,GAAE,SAAS,mBAAmB,EAAoB,GACxD,qBAAqB,CAEvB;AAED,sDAAsD;AACtD,wBAAgB,kBAAkB,CAChC,EAAE,EAAE,MAAM,EACV,OAAO,GAAE,SAAS,mBAAmB,EAAoB,GACxD,MAAM,CAER;AAED,wDAAwD;AACxD,wBAAgB,uBAAuB,CACrC,EAAE,EAAE,MAAM,EACV,OAAO,GAAE,SAAS,mBAAmB,EAAoB,GACxD,MAAM,CAER"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Outbound client identities this route can present.
|
|
3
|
+
*
|
|
4
|
+
* The subscription gateway gates on client identity, and it gates DIFFERENTLY
|
|
5
|
+
* per surface: measured on this route, `CodeBuddyIDE` is rejected by
|
|
6
|
+
* `/v3/config` with 400 `code 12403` ("check ua") and 401'd outright by the
|
|
7
|
+
* international chat endpoint, which is why the CLI identity is what the line
|
|
8
|
+
* ships and has always used.
|
|
9
|
+
*
|
|
10
|
+
* Two more identities exist on the same backend, and workbuddy2api-hub has
|
|
11
|
+
* captured what the real clients send (their `wb_identity.py`, measured
|
|
12
|
+
* 2026-10-16 with mitmproxy against the international desktop build 5.8.4):
|
|
13
|
+
*
|
|
14
|
+
* desktop `WorkBuddy/5.8.4 workbuddy-ai/5.8.4 CLI/2.161.0`
|
|
15
|
+
* + `X-IDE-Type/Name: WorkBuddy`, `X-IDE-Version`, `X-Agent-Intent: craft`
|
|
16
|
+
* + `X-Agent-Purpose: conversation`, `X-Agent-Type: main`, trace headers
|
|
17
|
+
* vscode `VSCode/1.119.0 WorkBuddy/4.9.29177644`
|
|
18
|
+
* + `X-IDE-Type/Name: VSCode`, `X-IDE-Version`, `X-Product-Version`, `X-Env-ID`
|
|
19
|
+
* cli `CLI/<v> CodeBuddy/<v>` + `X-IDE-Type/Name: CLI`
|
|
20
|
+
*
|
|
21
|
+
* `cli` is deliberately kept byte-identical to what this line sends today
|
|
22
|
+
* (including the `CodeBuddyIDE` IDE name, which is what was actually measured
|
|
23
|
+
* to work here) so the default cannot regress; the other two are opt-in
|
|
24
|
+
* attempts.
|
|
25
|
+
*
|
|
26
|
+
* Quota is NOT per identity: the subscription meters an account × model over a
|
|
27
|
+
* 24h window (429 `code 6004`), so switching identity cannot create allowance.
|
|
28
|
+
* What it can do is give each account a stable, plausible client — the same
|
|
29
|
+
* reason the gateway projects one device per account.
|
|
30
|
+
*/
|
|
31
|
+
import type { WorkBuddyOutboundProduct, WorkBuddyOutboundSetting } from '../../shared/workbuddy-contracts.ts';
|
|
32
|
+
export type { WorkBuddyOutboundProduct, WorkBuddyOutboundSetting };
|
|
33
|
+
/** Everything the settings card may offer, in display order. */
|
|
34
|
+
export declare const OUTBOUND_PRODUCTS: readonly WorkBuddyOutboundProduct[];
|
|
35
|
+
/** Shipped default: the identity this line already ships and measured working. */
|
|
36
|
+
export declare const DEFAULT_OUTBOUND_SETTING: WorkBuddyOutboundSetting;
|
|
37
|
+
/** Narrow a stored or patched value into a supported preference. */
|
|
38
|
+
export declare function normalizeOutboundSetting(value: unknown): WorkBuddyOutboundSetting;
|
|
39
|
+
/**
|
|
40
|
+
* Which identity one account uses.
|
|
41
|
+
*
|
|
42
|
+
* `auto` assigns by hashing the account key, so an account keeps the same
|
|
43
|
+
* client for its whole life — the one property that matters for a device
|
|
44
|
+
* fingerprint — while a pool as a whole spreads over the available clients.
|
|
45
|
+
*/
|
|
46
|
+
export declare function resolveOutboundProduct(setting: WorkBuddyOutboundSetting, accountKey: string): WorkBuddyOutboundProduct;
|
|
47
|
+
/**
|
|
48
|
+
* A stable pseudo-device id for one account.
|
|
49
|
+
*
|
|
50
|
+
* Same derivation as the measured clients (`derive_id`: md5 of `salt:uid`
|
|
51
|
+
* reshaped into a UUID), so the value is a well-formed v4-shaped machine id
|
|
52
|
+
* that never changes for an account and never collides between accounts. A
|
|
53
|
+
* per-PROCESS id would be worse than none here: it would present every account
|
|
54
|
+
* in the pool as the same machine.
|
|
55
|
+
*/
|
|
56
|
+
export declare function deriveMachineId(uid: string): string;
|
|
57
|
+
/** Identity-specific headers and user agent for one request. */
|
|
58
|
+
export interface OutboundIdentity {
|
|
59
|
+
product: WorkBuddyOutboundProduct;
|
|
60
|
+
userAgent: string;
|
|
61
|
+
/** Extra or overriding headers; `conversation` supplies the ids already minted. */
|
|
62
|
+
headers(conversation: Readonly<Record<string, string>>): Record<string, string>;
|
|
63
|
+
}
|
|
64
|
+
/** Resolve the identity block for one product on one region. */
|
|
65
|
+
export declare function outboundIdentity(product: WorkBuddyOutboundProduct, region: 'cn' | 'intl', uid: string): OutboundIdentity;
|
|
66
|
+
//# sourceMappingURL=outbound-identity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"outbound-identity.d.ts","sourceRoot":"","sources":["../../../../src/host/workbuddy/outbound-identity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAGH,OAAO,KAAK,EACV,wBAAwB,EACxB,wBAAwB,EACzB,MAAM,qCAAqC,CAAA;AAE5C,YAAY,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,CAAA;AAElE,gEAAgE;AAChE,eAAO,MAAM,iBAAiB,EAAE,SAAS,wBAAwB,EAAmC,CAAA;AAEpG,kFAAkF;AAClF,eAAO,MAAM,wBAAwB,EAAE,wBAAgC,CAAA;AAEvE,oEAAoE;AACpE,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,wBAAwB,CAKjF;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,wBAAwB,EACjC,UAAU,EAAE,MAAM,GACjB,wBAAwB,CAK1B;AAqBD;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAInD;AAoBD,gEAAgE;AAChE,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,wBAAwB,CAAA;IACjC,SAAS,EAAE,MAAM,CAAA;IACjB,mFAAmF;IACnF,OAAO,CAAC,YAAY,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAChF;AAED,gEAAgE;AAChE,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,wBAAwB,EACjC,MAAM,EAAE,IAAI,GAAG,MAAM,EACrB,GAAG,EAAE,MAAM,GACV,gBAAgB,CA4ClB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Context } from '@deepseek-ai/cordis';
|
|
2
2
|
import { DEFAULT_CONTEXT_WINDOW, PROVIDER_ID, PROVIDER_NAME } from './types.ts';
|
|
3
|
-
import { FileCredentialStore, FileModelSettingsStore, type WorkBuddyPreferenceStore } from './token-store.ts';
|
|
3
|
+
import { FileCredentialStore, FileModelSettingsStore, type WorkBuddyAtRestKeyStore, type WorkBuddyPreferenceStore } from './token-store.ts';
|
|
4
4
|
import { getCachedQuota } from './client.ts';
|
|
5
5
|
import { type WorkBuddyModelEntry } from './model-catalog.ts';
|
|
6
6
|
import type { WorkBuddyModelOption, WorkBuddyWebStatus } from '../../shared/workbuddy-contracts.ts';
|
|
@@ -40,6 +40,13 @@ export interface WorkBuddyStatusOptions {
|
|
|
40
40
|
accountPool?: WorkBuddyAccountPool;
|
|
41
41
|
/** Daily check-in scheduler; absent leaves the card's check-in row empty. */
|
|
42
42
|
checkin?: Pick<WorkBuddyCheckinService, 'tick' | 'summary'>;
|
|
43
|
+
/**
|
|
44
|
+
* Storage for the `$wbEncrypted` at-rest key.
|
|
45
|
+
*
|
|
46
|
+
* Absent hides the whole control: without it a pasted key could not be
|
|
47
|
+
* remembered, and offering the field anyway would lose it on restart.
|
|
48
|
+
*/
|
|
49
|
+
atRestKey?: Pick<WorkBuddyAtRestKeyStore, 'adopt' | 'clear' | 'load' | 'path'>;
|
|
43
50
|
}
|
|
44
51
|
/** Everything the settings card renders: account, quota, and the model catalog. */
|
|
45
52
|
export declare function getWorkBuddyWebStatus(store: FileCredentialStore, modelSettings: FileModelSettingsStore, preferences?: WorkBuddyPreferenceStore, options?: WorkBuddyStatusOptions): Promise<WorkBuddyWebStatus>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../../../src/host/workbuddy/routes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAIlD,OAAO,EAGL,sBAAsB,EACtB,WAAW,EACX,aAAa,EAEd,MAAM,YAAY,CAAA;AACnB,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EAGtB,KAAK,wBAAwB,EAC9B,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../../../src/host/workbuddy/routes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAIlD,OAAO,EAGL,sBAAsB,EACtB,WA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