@eddyskywalker/dsh-chatgpt-subscription 0.46.0 → 0.47.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 +54 -0
- package/README.md +22 -1
- package/lib/client.js +2639 -571
- package/lib/client.js.map +1 -1
- package/lib/index.js +11993 -3559
- package/lib/plan-mode-pipeline.js +419 -0
- package/lib/types/client/hub/brand-icons.d.ts +1 -1
- package/lib/types/client/hub/brand-icons.d.ts.map +1 -1
- package/lib/types/client/hub/brand-svg.d.ts +4 -0
- package/lib/types/client/hub/brand-svg.d.ts.map +1 -1
- package/lib/types/client/hub/providers.d.ts.map +1 -1
- package/lib/types/client/index.d.ts +2 -0
- package/lib/types/client/index.d.ts.map +1 -1
- package/lib/types/client/locales-ru/index.d.ts.map +1 -1
- package/lib/types/client/locales-ru/progress-updates.d.ts.map +1 -1
- package/lib/types/client/locales-ru/workbuddy.d.ts +10 -0
- package/lib/types/client/locales-ru/workbuddy.d.ts.map +1 -0
- package/lib/types/client/progress-updates/locales.d.ts +23 -5
- package/lib/types/client/progress-updates/locales.d.ts.map +1 -1
- package/lib/types/client/progress-updates/settings-binding.d.ts +13 -1
- package/lib/types/client/progress-updates/settings-binding.d.ts.map +1 -1
- package/lib/types/client/progress-updates/settings-section.d.ts +1 -1
- package/lib/types/client/progress-updates/settings-section.d.ts.map +1 -1
- package/lib/types/client/workbuddy/WorkBuddyComposerQuota.d.ts +34 -0
- package/lib/types/client/workbuddy/WorkBuddyComposerQuota.d.ts.map +1 -0
- package/lib/types/client/workbuddy/WorkBuddySection.d.ts +91 -0
- package/lib/types/client/workbuddy/WorkBuddySection.d.ts.map +1 -0
- package/lib/types/client/workbuddy/locales.d.ts +768 -0
- package/lib/types/client/workbuddy/locales.d.ts.map +1 -0
- package/lib/types/client/workbuddy/styles.d.ts +21 -0
- package/lib/types/client/workbuddy/styles.d.ts.map +1 -0
- package/lib/types/client/workbuddy/useWorkBuddySection.d.ts +149 -0
- package/lib/types/client/workbuddy/useWorkBuddySection.d.ts.map +1 -0
- package/lib/types/compat.d.ts +1 -1
- package/lib/types/entry-plan-mode-pipeline.d.ts +191 -0
- package/lib/types/entry-plan-mode-pipeline.d.ts.map +1 -0
- package/lib/types/host/agent-preset.d.ts.map +1 -1
- package/lib/types/host/cache-warmup/contracts.d.ts +5 -1
- package/lib/types/host/cache-warmup/contracts.d.ts.map +1 -1
- package/lib/types/host/cache-warmup/install.d.ts.map +1 -1
- package/lib/types/host/cache-warmup/projection.d.ts.map +1 -1
- package/lib/types/host/cache-warmup/retrieval-intent.d.ts +18 -0
- package/lib/types/host/cache-warmup/retrieval-intent.d.ts.map +1 -0
- package/lib/types/host/cache-warmup/settings.d.ts +9 -2
- package/lib/types/host/cache-warmup/settings.d.ts.map +1 -1
- package/lib/types/host/common/capabilities.d.ts.map +1 -1
- package/lib/types/host/common/model-request-control.d.ts +1 -1
- package/lib/types/host/common/model-request-control.d.ts.map +1 -1
- package/lib/types/host/common/request-diagnostics.d.ts +1 -1
- package/lib/types/host/common/request-diagnostics.d.ts.map +1 -1
- package/lib/types/host/compaction-prompt.d.ts +129 -0
- package/lib/types/host/compaction-prompt.d.ts.map +1 -0
- package/lib/types/host/preset-sync.d.ts.map +1 -1
- package/lib/types/host/responses-client.d.ts.map +1 -1
- package/lib/types/host/workbuddy/account-pool.d.ts +389 -0
- package/lib/types/host/workbuddy/account-pool.d.ts.map +1 -0
- package/lib/types/host/workbuddy/adapter.d.ts +249 -0
- package/lib/types/host/workbuddy/adapter.d.ts.map +1 -0
- 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 +150 -0
- package/lib/types/host/workbuddy/checkin.d.ts.map +1 -0
- package/lib/types/host/workbuddy/client.d.ts +214 -0
- package/lib/types/host/workbuddy/client.d.ts.map +1 -0
- 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/identity.d.ts +71 -0
- package/lib/types/host/workbuddy/identity.d.ts.map +1 -0
- package/lib/types/host/workbuddy/mapper.d.ts +238 -0
- package/lib/types/host/workbuddy/mapper.d.ts.map +1 -0
- package/lib/types/host/workbuddy/model-catalog.d.ts +217 -0
- package/lib/types/host/workbuddy/model-catalog.d.ts.map +1 -0
- package/lib/types/host/workbuddy/oauth.d.ts +47 -0
- package/lib/types/host/workbuddy/oauth.d.ts.map +1 -0
- package/lib/types/host/workbuddy/outbound-identity.d.ts +139 -0
- package/lib/types/host/workbuddy/outbound-identity.d.ts.map +1 -0
- package/lib/types/host/workbuddy/routes.d.ts +56 -0
- package/lib/types/host/workbuddy/routes.d.ts.map +1 -0
- package/lib/types/host/workbuddy/token-store.d.ts +370 -0
- package/lib/types/host/workbuddy/token-store.d.ts.map +1 -0
- package/lib/types/host/workbuddy/types.d.ts +179 -0
- package/lib/types/host/workbuddy/types.d.ts.map +1 -0
- package/lib/types/index.d.ts +35 -0
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/shared/workbuddy-contracts.d.ts +531 -0
- package/lib/types/shared/workbuddy-contracts.d.ts.map +1 -0
- package/package.json +6 -2
- package/presets/dispatch/README.md +57 -3
- package/presets/dispatch/agent.cordis.yml +42 -13
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Replace the compaction directive DSH ships with one that reads better.
|
|
3
|
+
*
|
|
4
|
+
* DSH's `compaction-basic` delivers its summarization directive as the FINAL
|
|
5
|
+
* user message of the replayed conversation (see its `summarizer.ts`): keeping
|
|
6
|
+
* the conversation's own prefix in front of it is what makes the auxiliary call
|
|
7
|
+
* a genuine prefix of the last routed request, so the provider's KV cache is
|
|
8
|
+
* reused instead of invalidated. That directive is a private constant of the
|
|
9
|
+
* harness, not a setting, and no preset may edit it.
|
|
10
|
+
*
|
|
11
|
+
* The replacement below keeps that property: it is spliced into the SAME final
|
|
12
|
+
* message, so every earlier message — the system prompt, the tools, the whole
|
|
13
|
+
* conversation — is byte-identical and the cache prefix still matches. Only the
|
|
14
|
+
* trailing instruction differs, which is the part a compaction request was
|
|
15
|
+
* never going to cache-hit anyway.
|
|
16
|
+
*
|
|
17
|
+
* Three things the shipped directive gets wrong, each learned from the official
|
|
18
|
+
* `MoonshotAI/kimi-code` agent (`fullCompaction/compaction-instruction.md`):
|
|
19
|
+
*
|
|
20
|
+
* 1. **Language.** It demands "concise English engineering prose" even when the
|
|
21
|
+
* conversation is not English, so a Chinese session's checkpoint comes back
|
|
22
|
+
* in English and the resumed turn has to translate its own history. The
|
|
23
|
+
* official instruction says to keep the conversation's own language.
|
|
24
|
+
* 2. **Rigid sections.** It fixes nine headings. When a conversation is mostly
|
|
25
|
+
* one long debugging thread, forcing it into nine buckets spends the budget
|
|
26
|
+
* on empty sections and starves the one that matters. The official
|
|
27
|
+
* instruction lets the shape follow the task.
|
|
28
|
+
* 3. **Values, not commands.** It says to preserve "commands and error strings"
|
|
29
|
+
* but not the VALUES those commands returned. A resumed turn that knows
|
|
30
|
+
* `grep -n foo` ran, but not what it printed, re-runs it — and the file may
|
|
31
|
+
* have changed since.
|
|
32
|
+
*
|
|
33
|
+
* What is deliberately kept from DSH's version: the instruction to fold a prior
|
|
34
|
+
* `<compacted-summary>` block forward rather than copy it, because without it
|
|
35
|
+
* each compaction restates the previous checkpoint and the history grows a
|
|
36
|
+
* summary of a summary.
|
|
37
|
+
*
|
|
38
|
+
* @module dsh-chatgpt-subscription/compaction-prompt
|
|
39
|
+
*/
|
|
40
|
+
/**
|
|
41
|
+
* First line of the directive DSH ships.
|
|
42
|
+
*
|
|
43
|
+
* Matched as a prefix rather than the whole text: the harness owns that
|
|
44
|
+
* constant and may reword its later sections without warning, and a matcher
|
|
45
|
+
* pinned to the full string would silently stop replacing anything.
|
|
46
|
+
*/
|
|
47
|
+
export declare const SHIPPED_INSTRUCTION_OPENING = "You are now acting as a compaction engine for this AI coding assistant.";
|
|
48
|
+
/** Marker the harness wraps a prior checkpoint in; the replacement must keep folding it. */
|
|
49
|
+
export declare const PRIOR_CHECKPOINT_OPEN_TAG = "<compacted-summary>";
|
|
50
|
+
/** The replacement directive. */
|
|
51
|
+
export declare const COMPACTION_INSTRUCTION: string;
|
|
52
|
+
/** One text-bearing content block, as the splice reads it. */
|
|
53
|
+
export interface PromptBlock {
|
|
54
|
+
readonly type?: string | undefined;
|
|
55
|
+
readonly text?: string | undefined;
|
|
56
|
+
}
|
|
57
|
+
/** One request message, narrowed to what the splice needs. */
|
|
58
|
+
export interface PromptMessage {
|
|
59
|
+
readonly role?: string | undefined;
|
|
60
|
+
readonly content?: readonly PromptBlock[] | undefined;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Whether one message carries DSH's shipped directive.
|
|
64
|
+
* @param message - one request message.
|
|
65
|
+
* @returns whether its text opens with {@link SHIPPED_INSTRUCTION_OPENING}.
|
|
66
|
+
*/
|
|
67
|
+
export declare function carriesShippedInstruction(message: PromptMessage): boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Splice the replacement directive into the conversation's final message.
|
|
70
|
+
*
|
|
71
|
+
* Every earlier message is returned by reference, unchanged: that is the whole
|
|
72
|
+
* cache argument for doing this at the last message instead of rebuilding the
|
|
73
|
+
* request. Returns the original array when no message carries the shipped
|
|
74
|
+
* directive, so a host that reworded it (or a call that is not a compaction)
|
|
75
|
+
* costs nothing and stays on the harness's own text.
|
|
76
|
+
* @param messages - the compaction request's messages.
|
|
77
|
+
* @returns messages whose final shipped directive is replaced, or the input.
|
|
78
|
+
*/
|
|
79
|
+
export declare function replaceCompactionInstruction<M extends PromptMessage>(messages: readonly M[]): readonly M[];
|
|
80
|
+
/** The `llm/stream` options this splice reads and rewrites. */
|
|
81
|
+
export interface PromptStreamOptions {
|
|
82
|
+
/** `compaction` on an auxiliary summary call; absent on a conversation turn. */
|
|
83
|
+
readonly purpose?: string | undefined;
|
|
84
|
+
/**
|
|
85
|
+
* Ordered request messages; the last one carries the summarization directive.
|
|
86
|
+
*
|
|
87
|
+
* Deliberately NOT readonly: assigning it is how the splice hands the
|
|
88
|
+
* rewritten request downstream, because `next()` takes no arguments. The
|
|
89
|
+
* harness types the same field as a mutable array for the same reason.
|
|
90
|
+
*/
|
|
91
|
+
messages?: readonly PromptMessage[];
|
|
92
|
+
}
|
|
93
|
+
/** A chunk as it crosses the stream boundary; the splice never inspects one. */
|
|
94
|
+
export interface PromptChunk {
|
|
95
|
+
readonly type: string;
|
|
96
|
+
}
|
|
97
|
+
/** The `llm/stream` waterfall listener this module registers. */
|
|
98
|
+
export type PromptStreamListener = (options: PromptStreamOptions, next: () => AsyncIterable<PromptChunk>) => AsyncIterable<PromptChunk>;
|
|
99
|
+
/** The context surface this splice needs, declared structurally per harness generation. */
|
|
100
|
+
export interface PromptContext {
|
|
101
|
+
on?(event: 'llm/stream', listener: PromptStreamListener, options?: {
|
|
102
|
+
readonly global?: boolean;
|
|
103
|
+
}): unknown;
|
|
104
|
+
logger?: {
|
|
105
|
+
warn(message: string): void;
|
|
106
|
+
} | undefined;
|
|
107
|
+
}
|
|
108
|
+
/** Live handle: teardown for the registered listener. */
|
|
109
|
+
export interface PromptHandle {
|
|
110
|
+
dispose(): void;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Install the `llm/stream` listener that swaps the directive in place.
|
|
114
|
+
*
|
|
115
|
+
* The rewrite happens on the request object the waterfall already carries,
|
|
116
|
+
* because `next()` takes no arguments: there is no way to hand a modified
|
|
117
|
+
* request downstream, and re-entering `stream()` to pass one would put this
|
|
118
|
+
* listener back in its own path. Assigning `messages` is therefore the only
|
|
119
|
+
* seam that leaves every other field — provider, model, tools, session — exactly
|
|
120
|
+
* as the harness built them.
|
|
121
|
+
*
|
|
122
|
+
* A frozen request is skipped rather than forced: a host that freezes its
|
|
123
|
+
* options is telling callers not to rewrite them, and keeping the shipped
|
|
124
|
+
* directive is a correct outcome, not a failure.
|
|
125
|
+
* @param ctx - structural context: the event bus and a logger.
|
|
126
|
+
* @returns the live handle, or undefined on a host with no event bus.
|
|
127
|
+
*/
|
|
128
|
+
export declare function installCompactionPrompt(ctx: PromptContext): PromptHandle | undefined;
|
|
129
|
+
//# sourceMappingURL=compaction-prompt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compaction-prompt.d.ts","sourceRoot":"","sources":["../../../src/host/compaction-prompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,2BAA2B,4EACmC,CAAA;AAE3E,4FAA4F;AAC5F,eAAO,MAAM,yBAAyB,wBAAwB,CAAA;AAE9D,iCAAiC;AACjC,eAAO,MAAM,sBAAsB,QAqBvB,CAAA;AAEZ,8DAA8D;AAC9D,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAClC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CACnC;AAED,8DAA8D;AAC9D,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAClC,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,WAAW,EAAE,GAAG,SAAS,CAAA;CACtD;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAQzE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,4BAA4B,CAAC,CAAC,SAAS,aAAa,EAClE,QAAQ,EAAE,SAAS,CAAC,EAAE,GACrB,SAAS,CAAC,EAAE,CAad;AAED,+DAA+D;AAC/D,MAAM,WAAW,mBAAmB;IAClC,gFAAgF;IAChF,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACrC;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,SAAS,aAAa,EAAE,CAAA;CACpC;AAED,gFAAgF;AAChF,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CACtB;AAED,iEAAiE;AACjE,MAAM,MAAM,oBAAoB,GAAG,CACjC,OAAO,EAAE,mBAAmB,EAC5B,IAAI,EAAE,MAAM,aAAa,CAAC,WAAW,CAAC,KACnC,aAAa,CAAC,WAAW,CAAC,CAAA;AAE/B,2FAA2F;AAC3F,MAAM,WAAW,aAAa;IAC5B,EAAE,CAAC,CACD,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,oBAAoB,EAC9B,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,GACtC,OAAO,CAAA;IACV,MAAM,CAAC,EAAE;QAAE,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,GAAG,SAAS,CAAA;CACrD;AAED,yDAAyD;AACzD,MAAM,WAAW,YAAY;IAC3B,OAAO,IAAI,IAAI,CAAA;CAChB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,aAAa,GAAG,YAAY,GAAG,SAAS,CA4BpF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preset-sync.d.ts","sourceRoot":"","sources":["../../../src/host/preset-sync.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAMH,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAElE,+CAA+C;AAC/C,eAAO,MAAM,kBAAkB,EAAE,SAAS,MAAM,EAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"preset-sync.d.ts","sourceRoot":"","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AAE,CAAA;IACvC,2EAA2E;IAC3E,OAAO,EAAE,MAAM,EAAE,CAAA;CAClB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,IAAI,MAAM,CAQpC;AAED,6EAA6E;AAC7E,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C;AAED,4EAA4E;AAC5E,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAErD;AA0FD;;;;;;GAMG;AACH,wBAAgB,aAAa,CAC3B,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,QAAQ,GAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAa,GAChD,QAAQ,GAAG,SAAS,CA+CtB;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAC7B,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,MAAM,GAAE,SAAS,MAAM,EAAO,EAC9B,OAAO,CAAC,EAAE,iBAAiB,GAC1B,gBAAgB,CAiClB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,aAAa,GAAG,MAAM,IAAI,CAiB1F"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"responses-client.d.ts","sourceRoot":"","sources":["../../../src/host/responses-client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"responses-client.d.ts","sourceRoot":"","sources":["../../../src/host/responses-client.ts"],"names":[],"mappings":"AAKA,OAAO,EAKL,KAAK,eAAe,EACpB,KAAK,WAAW,EAEjB,MAAM,sBAAsB,CAAA;AAG7B,OAAO,EAA0D,KAAK,cAAc,EAAE,MAAM,2BAA2B,CAAA;AACvH,OAAO,EAAsB,KAAK,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AACnF,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAwD,KAAK,oBAAoB,EAAE,MAAM,uBAA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AChH,OAAO,GAAE,sBAA2B;IAYtC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAsB;IAE9C,MAAM,CAAC,UAAU,EAAE,eAAe,GAAG,aAAa,CAAC,WAAW,CAAC;YA+DxD,IAAI;IAmBlB;;;;;;OAMG;IACH,OAAO,CAAC,iBAAiB;IAUzB;;;;OAIG;IACH,OAAO,CAAC,cAAc;IAetB;;;;;;;OAOG;IACH,OAAO,CAAC,YAAY;IAapB;;;;;;;;;OASG;IACH,4EAA4E;YAC9D,YAAY;YAsEZ,OAAO;CA+CtB;AA4FD,wBAAuB,oBAAoB,CACzC,QAAQ,EAAE,QAAQ,EAClB,MAAM,CAAC,EAAE,WAAW,EACpB,qBAAqB,GAAE,WAAW,CAAC,MAAM,CAAa;AACtD,gFAAgF;AAChF,QAAQ,CAAC,EAAE,cAAc,GACxB,aAAa,CAAC,WAAW,CAAC,CAgR5B"}
|
|
@@ -0,0 +1,389 @@
|
|
|
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 { LlmError } from '@deepseek-ai/dsh-llm';
|
|
17
|
+
import { AccountPoolCore, type PoolAccountShape, type PoolData } from '../common/account-pool.ts';
|
|
18
|
+
import type { CredentialStore } from '../token-store.ts';
|
|
19
|
+
import { FileCredentialStore, type WorkBuddyCredentials } from './token-store.ts';
|
|
20
|
+
import type { PoolAccountQuotaDto } from '../../shared/account-pool-contracts.ts';
|
|
21
|
+
import { type WorkBuddyAccountQuota, type WorkBuddyAccountRestrictionDto, type WorkBuddyAccountSummaryDto, type WorkBuddyPoolStateDto, type WorkBuddyRegion } from '../../shared/workbuddy-contracts.ts';
|
|
22
|
+
/** One pooled WorkBuddy account: the credential plus the facts the card renders. */
|
|
23
|
+
export interface WorkBuddyPoolAccount extends PoolAccountShape<WorkBuddyCredentials> {
|
|
24
|
+
region: WorkBuddyRegion;
|
|
25
|
+
nickname?: string;
|
|
26
|
+
uin?: string;
|
|
27
|
+
/** Which store owns the credential; only managed accounts may be deleted. */
|
|
28
|
+
source: 'desktop' | 'managed';
|
|
29
|
+
/** IDE file a desktop account came from; absent for managed accounts. */
|
|
30
|
+
sourceFile?: string;
|
|
31
|
+
}
|
|
32
|
+
/** Encrypted pool file this line owns. */
|
|
33
|
+
export declare function workBuddyPoolPath(): string;
|
|
34
|
+
/**
|
|
35
|
+
* Error code the adapter routes on when the WHOLE pool is paused.
|
|
36
|
+
*
|
|
37
|
+
* Deliberately not `RATE_LIMIT`: a pause says the pool will not be served at
|
|
38
|
+
* all — the upstream barred accounts, it did not answer 429 for one request —
|
|
39
|
+
* and confusing the two would send the user to wait out a window that has
|
|
40
|
+
* nothing to do with their accounts. The pause lifts by itself and the RESTRICTED
|
|
41
|
+
* accounts do not, so the remedy is also different.
|
|
42
|
+
*/
|
|
43
|
+
export declare const WORKBUDDY_POOL_PAUSED_CODE: "WORKBUDDY_POOL_PAUSED";
|
|
44
|
+
/**
|
|
45
|
+
* Thrown instead of selecting an account while the whole pool is paused.
|
|
46
|
+
*
|
|
47
|
+
* Exported so the protocol worker's caller can tell "upstream barred two
|
|
48
|
+
* accounts" (wait for the pause, then sign the restricted ones in again) from
|
|
49
|
+
* "this request was rate limited". It is never reported as an upstream 429.
|
|
50
|
+
*/
|
|
51
|
+
export declare class WorkBuddyPoolPausedError extends LlmError {
|
|
52
|
+
/** Unix milliseconds the pause lifts on its own; absent when nothing named one. */
|
|
53
|
+
readonly pausedUntil: number | undefined;
|
|
54
|
+
constructor(message: string, pausedUntil?: number);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* How long a second barred account stops the whole pool.
|
|
58
|
+
*
|
|
59
|
+
* Thirty minutes is the confirmed Wave 2A policy: long enough that an upstream
|
|
60
|
+
* refusing every account is not hammered once per turn, short enough that a
|
|
61
|
+
* transient bar does not take the line offline for a working day. When it
|
|
62
|
+
* passes the pool resumes by itself — the restricted accounts do not, because
|
|
63
|
+
* nothing upstream said they may serve again.
|
|
64
|
+
*/
|
|
65
|
+
export declare const WORKBUDDY_POOL_PAUSE_MS: number;
|
|
66
|
+
/**
|
|
67
|
+
* Window in which a second, DIFFERENT barred account stops the whole pool.
|
|
68
|
+
*
|
|
69
|
+
* Measured from each refusal to the next. One barred account is that account's
|
|
70
|
+
* problem and the rest still serve; two different accounts barred inside this
|
|
71
|
+
* window is the pool's problem, because the same thing is about to happen to
|
|
72
|
+
* the third.
|
|
73
|
+
*/
|
|
74
|
+
export declare const WORKBUDDY_RESTRICTION_ESCALATION_WINDOW_MS: number;
|
|
75
|
+
/** One account's `11140` as this pool's own document keeps it. */
|
|
76
|
+
export interface WorkBuddyPoolRestrictionRecord {
|
|
77
|
+
/** Gateway code; {@link WORKBUDDY_RESTRICTED_ACCOUNT_CODE} is the only one recorded. */
|
|
78
|
+
code: number;
|
|
79
|
+
/** Upstream `msg` when one came with the code. Never a credential. */
|
|
80
|
+
message?: string;
|
|
81
|
+
/** Instant the gateway named, when it named one. Reported, never enforced. */
|
|
82
|
+
until?: number;
|
|
83
|
+
/** When this pool observed the refusal; drives the escalation window. */
|
|
84
|
+
observedAt: number;
|
|
85
|
+
}
|
|
86
|
+
/** A pause of the WHOLE pool, as its own document keeps it. */
|
|
87
|
+
export interface WorkBuddyPoolPauseRecord {
|
|
88
|
+
/** Composed sentence for the card; never a token. */
|
|
89
|
+
reason: string;
|
|
90
|
+
pausedSince: number;
|
|
91
|
+
/** Unix milliseconds the pause lifts by itself. */
|
|
92
|
+
pausedUntil: number;
|
|
93
|
+
/** Account ids whose `11140` caused the pause, in observation order. */
|
|
94
|
+
triggeredBy: string[];
|
|
95
|
+
}
|
|
96
|
+
/** Whole-pool state kept inside the pool document. */
|
|
97
|
+
export interface WorkBuddyPoolDocumentState {
|
|
98
|
+
/** Account id → its `11140`. A restricted account is out of rotation. */
|
|
99
|
+
restrictions: Record<string, WorkBuddyPoolRestrictionRecord>;
|
|
100
|
+
pause?: WorkBuddyPoolPauseRecord;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* This line's pool document: the shared shape plus the pool-wide state.
|
|
104
|
+
*
|
|
105
|
+
* The state lives in the SAME document rather than a second store, so one
|
|
106
|
+
* encrypted write keeps "which account may serve" and "may the pool serve at
|
|
107
|
+
* all" in step: two documents could be observed half-updated, and the pool
|
|
108
|
+
* would then select an account its own restriction record bars.
|
|
109
|
+
*/
|
|
110
|
+
export interface WorkBuddyPoolData extends PoolData<WorkBuddyPoolAccount> {
|
|
111
|
+
pool?: WorkBuddyPoolDocumentState;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Read whole-pool state out of a stored document.
|
|
115
|
+
*
|
|
116
|
+
* Absent means "no pool-wide state", which is exactly what a document written
|
|
117
|
+
* before Wave 2A holds — and what an untouched pool still writes, so an install
|
|
118
|
+
* that never met `11140` carries no extra keys at all. A malformed ENTRY is
|
|
119
|
+
* dropped rather than failing the document: losing one memory of a refusal must
|
|
120
|
+
* not make the accounts unreadable, while silently keeping an unparseable pause
|
|
121
|
+
* could take the line offline forever.
|
|
122
|
+
*/
|
|
123
|
+
export declare function parseWorkBuddyPoolState(value: unknown): WorkBuddyPoolDocumentState | undefined;
|
|
124
|
+
/**
|
|
125
|
+
* Validate and normalize one whole pool document.
|
|
126
|
+
*
|
|
127
|
+
* A record whose credential is unusable is dropped rather than repaired: the
|
|
128
|
+
* account can always be adopted again from its file or by signing in again, and
|
|
129
|
+
* keeping a credential-less row would offer the user an account nothing can use.
|
|
130
|
+
*/
|
|
131
|
+
export declare function parseWorkBuddyPoolData(value: unknown): WorkBuddyPoolData;
|
|
132
|
+
/**
|
|
133
|
+
* One cached snapshot as the shared account card renders it.
|
|
134
|
+
*
|
|
135
|
+
* Only what the DTO states is published: every meter that measured a share
|
|
136
|
+
* becomes a window, and a meter that measured none is dropped rather than drawn
|
|
137
|
+
* at 0 — which would claim an unspent allowance no reading supports.
|
|
138
|
+
*
|
|
139
|
+
* Exported for the pool's regression tests; the card only reaches it through
|
|
140
|
+
* the summary hook.
|
|
141
|
+
*/
|
|
142
|
+
export declare function workBuddyPoolQuota(snapshot: WorkBuddyAccountQuota): PoolAccountQuotaDto | undefined;
|
|
143
|
+
export interface WorkBuddyAccountPoolOptions {
|
|
144
|
+
/** Credential store the desktop scan reads through; the pool owns scheduling. */
|
|
145
|
+
store?: FileCredentialStore;
|
|
146
|
+
/** Test seam; production builds the platform backend from the pool path. */
|
|
147
|
+
backend?: CredentialStore<PoolData<WorkBuddyPoolAccount>>;
|
|
148
|
+
maxAccounts?: number;
|
|
149
|
+
/**
|
|
150
|
+
* The settings selection: the account the user pinned and the ones hidden.
|
|
151
|
+
*
|
|
152
|
+
* Read on every pick rather than captured once, because both change from the
|
|
153
|
+
* settings card while the adapter is serving requests.
|
|
154
|
+
*/
|
|
155
|
+
selection?: () => {
|
|
156
|
+
selectedAccountId: string | null;
|
|
157
|
+
hiddenAccountIds: readonly string[];
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* WorkBuddy's account pool.
|
|
162
|
+
*
|
|
163
|
+
* Desktop accounts are adopted into the pool so they can be scheduled and
|
|
164
|
+
* cooled down like any other, but they stay owned by the IDE: the pool refreshes
|
|
165
|
+
* their credential from the IDE's own file on every pick, and deletion is
|
|
166
|
+
* refused for them.
|
|
167
|
+
*/
|
|
168
|
+
export declare class WorkBuddyAccountPool extends AccountPoolCore<WorkBuddyCredentials, WorkBuddyPoolAccount, WorkBuddyAccountSummaryDto> {
|
|
169
|
+
private readonly store;
|
|
170
|
+
private readonly options_selection;
|
|
171
|
+
/**
|
|
172
|
+
* Older settings key → the id the account has now.
|
|
173
|
+
*
|
|
174
|
+
* A pin or a hide written before the identity fix names its account by the
|
|
175
|
+
* old name-derived key. Kept in step by {@link read}, which every routing
|
|
176
|
+
* decision goes through, so the mapping is never stale when it is consulted.
|
|
177
|
+
*/
|
|
178
|
+
private readonly legacyIds;
|
|
179
|
+
/**
|
|
180
|
+
* Per-model parks, in memory only: account id → model → the instant it lifts.
|
|
181
|
+
*
|
|
182
|
+
* The subscription meters an account × MODEL over a 24h window (429 `code
|
|
183
|
+
* 6004` names when it lifts), so cooling the whole ACCOUNT for one exhausted
|
|
184
|
+
* model throws away every other model that account can still serve. Process
|
|
185
|
+
* local on purpose, like the sibling gateway's model cooldowns: the window is
|
|
186
|
+
* short, and a restart re-measures it with the first request rather than
|
|
187
|
+
* trusting a stale timestamp.
|
|
188
|
+
*/
|
|
189
|
+
private readonly modelCooldowns;
|
|
190
|
+
/**
|
|
191
|
+
* Whole-pool state as of the LAST load through {@link loadPoolData}.
|
|
192
|
+
*
|
|
193
|
+
* A cache rather than a read per check: eligibility runs once per account per
|
|
194
|
+
* pick, and asking the encrypted store each time would pay a DPAPI unprotect
|
|
195
|
+
* per candidate. Every read and every mutation loads the document first, so
|
|
196
|
+
* this cannot be stale for longer than one storage round trip.
|
|
197
|
+
*/
|
|
198
|
+
private restrictions;
|
|
199
|
+
private pause;
|
|
200
|
+
constructor(options?: WorkBuddyAccountPoolOptions);
|
|
201
|
+
/**
|
|
202
|
+
* Load the pool, refreshing the legacy-key index on the way.
|
|
203
|
+
*
|
|
204
|
+
* Every routing decision and mutation goes through this method before it
|
|
205
|
+
* consults the settings selection, so building the index here is what keeps
|
|
206
|
+
* a pin written before the identity fix resolvable when
|
|
207
|
+
* {@link resolveSelectionId} is asked for it.
|
|
208
|
+
*/
|
|
209
|
+
protected loadPoolData(): Promise<PoolData<WorkBuddyPoolAccount>>;
|
|
210
|
+
/** Keep the pool-wide cache in step with the document just loaded. */
|
|
211
|
+
private observePoolState;
|
|
212
|
+
/** This account's live `11140`, matched through every key it answers to. */
|
|
213
|
+
private restrictionFor;
|
|
214
|
+
/** The pause that is still running, or undefined when it lifted or never began. */
|
|
215
|
+
private activePause;
|
|
216
|
+
/** The error every selection raises while the pool is paused. */
|
|
217
|
+
private pausedError;
|
|
218
|
+
/**
|
|
219
|
+
* Record an account-scoped refusal reported by the protocol worker.
|
|
220
|
+
*
|
|
221
|
+
* This is the ONE entry point for `11140`, and the policy it implements is
|
|
222
|
+
* the confirmed Wave 2A one:
|
|
223
|
+
*
|
|
224
|
+
* - the first barred account leaves rotation immediately and its restriction
|
|
225
|
+
* is PERSISTED (in the pool document, so a second pool instance over the
|
|
226
|
+
* same store sees it), while every other account keeps serving;
|
|
227
|
+
* - a SECOND, different account barred within
|
|
228
|
+
* {@link WORKBUDDY_RESTRICTION_ESCALATION_WINDOW_MS} pauses the whole pool
|
|
229
|
+
* for {@link WORKBUDDY_POOL_PAUSE_MS} — during which no account is selected
|
|
230
|
+
* at all — and that pause is persisted too;
|
|
231
|
+
* - the pause lifts by itself, the restricted accounts do NOT: only a
|
|
232
|
+
* completed sign-in ({@link addAccount}) puts one back in rotation.
|
|
233
|
+
*
|
|
234
|
+
* Only {@link WORKBUDDY_RESTRICTED_ACCOUNT_CODE} is accepted. `11128` is the
|
|
235
|
+
* channel/request-shape block and `11158` is one model an account has no
|
|
236
|
+
* entitlement for; neither says the ACCOUNT may not serve, so recording either
|
|
237
|
+
* would take a working account out of rotation and — with two inside the
|
|
238
|
+
* window — stop the whole pool over a request-shape mistake. The call is
|
|
239
|
+
* therefore refused loudly, which keeps that misrouting visible in a test or a
|
|
240
|
+
* log instead of silently barring a healthy account.
|
|
241
|
+
*/
|
|
242
|
+
markAccountRestriction(accountId: string, restriction: WorkBuddyAccountRestrictionDto): Promise<void>;
|
|
243
|
+
/** Clear one account's restriction; a completed sign-in is what does this. */
|
|
244
|
+
private clearRestriction;
|
|
245
|
+
/**
|
|
246
|
+
* Whole-pool state for the wire: whether the pool is paused, why, until when,
|
|
247
|
+
* which accounts are barred, and where this document lives.
|
|
248
|
+
*
|
|
249
|
+
* `pausedUntil` is the pause's remaining time in absolute form, which is what
|
|
250
|
+
* a card can count down and a route can answer without a second call. An
|
|
251
|
+
* expired pause is reported as not paused — it never needs a write to lift.
|
|
252
|
+
*/
|
|
253
|
+
poolState(): Promise<WorkBuddyPoolStateDto>;
|
|
254
|
+
/** Map a settings key from before the identity fix onto the account's real id. */
|
|
255
|
+
private resolveSelectionId;
|
|
256
|
+
/**
|
|
257
|
+
* Adopt any desktop credential the pool does not know yet.
|
|
258
|
+
*
|
|
259
|
+
* The IDE's directory is the source of truth for its own accounts, so a
|
|
260
|
+
* credential that appears there joins the pool. Nothing is ever removed: a
|
|
261
|
+
* file that disappears (the IDE signed out, a profile was moved) leaves the
|
|
262
|
+
* account in place, where the user can hide or delete the managed ones.
|
|
263
|
+
*/
|
|
264
|
+
syncDesktopAccounts(): Promise<WorkBuddyAccountSummaryDto[]>;
|
|
265
|
+
/**
|
|
266
|
+
* A stale `authStatus` is cleared once the credential in force has moved on.
|
|
267
|
+
*
|
|
268
|
+
* The marker records that ONE token was refused; it does not record that the
|
|
269
|
+
* sign-in is gone. This line can still produce it from a token-endpoint
|
|
270
|
+
* refusal, and the copy that refusal was about can be replaced afterwards by
|
|
271
|
+
* whoever owns it — the IDE rotates a desktop account's token on its own
|
|
272
|
+
* schedule, and the daily check-in renews a managed one and writes it back to
|
|
273
|
+
* this plugin's store. Nothing else in the system ever revisits an
|
|
274
|
+
* `authStatus`, so without this a row stays out of rotation for good and the
|
|
275
|
+
* card keeps saying "需要重新登录" for an account that is signed in.
|
|
276
|
+
*
|
|
277
|
+
* The verdict is re-checked against what the store holds NOW: a row whose
|
|
278
|
+
* account has a DIFFERENT, unexpired token is routable again and adopts it,
|
|
279
|
+
* while a row still holding the refused token keeps its marker — that one
|
|
280
|
+
* really does need a sign-in.
|
|
281
|
+
*/
|
|
282
|
+
private healStaleAuthFailures;
|
|
283
|
+
/** Account summaries, with a marker the credentials have outlived cleared. */
|
|
284
|
+
listAccounts(): Promise<WorkBuddyAccountSummaryDto[]>;
|
|
285
|
+
/**
|
|
286
|
+
* Pick an account, healing a stale marker first.
|
|
287
|
+
*
|
|
288
|
+
* The healing belongs on the request path, not only on the card: an account
|
|
289
|
+
* marked expired is excluded by the core's eligibility rule, so until the
|
|
290
|
+
* marker is gone the next request is answered with "全部 N 个账号都需要重新登录"
|
|
291
|
+
* for a credential the store has already replaced.
|
|
292
|
+
*/
|
|
293
|
+
getEffectiveAccount(excludeIds?: ReadonlySet<string>, fetchFn?: typeof fetch, forceRefresh?: boolean): Promise<{
|
|
294
|
+
account: WorkBuddyPoolAccount;
|
|
295
|
+
credentials: WorkBuddyCredentials;
|
|
296
|
+
}>;
|
|
297
|
+
/**
|
|
298
|
+
* Pick the account for the next request.
|
|
299
|
+
*
|
|
300
|
+
* A desktop account's credential is re-read from the IDE's file first: the IDE
|
|
301
|
+
* refreshes its own token, so the copy the pool adopted can be older than what
|
|
302
|
+
* is on disk.
|
|
303
|
+
*/
|
|
304
|
+
getEffectiveCredential(excludeIds?: ReadonlySet<string>, fetchFn?: typeof fetch, model?: string): Promise<{
|
|
305
|
+
account: WorkBuddyPoolAccount;
|
|
306
|
+
credentials: WorkBuddyCredentials;
|
|
307
|
+
}>;
|
|
308
|
+
/**
|
|
309
|
+
* Park ONE model on one account; every other model keeps serving.
|
|
310
|
+
*
|
|
311
|
+
* Returns the instant the park lifts, or undefined for a non-positive
|
|
312
|
+
* duration (which clears any existing park rather than extending it).
|
|
313
|
+
*/
|
|
314
|
+
markModelCooldown(accountId: string, model: string, durationMs: number): number | undefined;
|
|
315
|
+
/** When this account's park on this model lifts, or undefined when it may serve. */
|
|
316
|
+
modelCooldownUntil(accountId: string, model: string, now?: number): number | undefined;
|
|
317
|
+
/**
|
|
318
|
+
* The models this account is parked on right now, with the instant each park
|
|
319
|
+
* lifts.
|
|
320
|
+
*
|
|
321
|
+
* Only LIVE parks are reported: a window that has passed is dropped here, so
|
|
322
|
+
* the card never shows a model that may already serve. The lift instant is
|
|
323
|
+
* the one the upstream named, stored verbatim by
|
|
324
|
+
* {@link markModelCooldown}; it is never recomputed from a duration that has
|
|
325
|
+
* since drifted, because a re-derived instant would drift with it.
|
|
326
|
+
*/
|
|
327
|
+
private liveModelCooldowns;
|
|
328
|
+
/**
|
|
329
|
+
* Clear one account's cooldown AND the models it is parked on.
|
|
330
|
+
*
|
|
331
|
+
* The card's "reset cooldown" button promises the account is usable again. A
|
|
332
|
+
* model park is a cooldown too — the account stays eligible, but it still
|
|
333
|
+
* refuses the model the request wants — so leaving the park behind would
|
|
334
|
+
* report a reset that did not happen, and the park would outlive the only
|
|
335
|
+
* control the user has over it.
|
|
336
|
+
*
|
|
337
|
+
* The base write comes first: it is the half that can fail, and a failed
|
|
338
|
+
* write must leave the account's state as it was rather than half-cleared.
|
|
339
|
+
*/
|
|
340
|
+
clearCooldown(accountId: string): Promise<void>;
|
|
341
|
+
/** Accounts currently parked on one model, with lifted entries pruned on the way. */
|
|
342
|
+
private parkedAccountIds;
|
|
343
|
+
/**
|
|
344
|
+
* Whether another account besides `triedAccountIds` can serve THIS model.
|
|
345
|
+
*
|
|
346
|
+
* The plain {@link hasAnotherAvailableAccount} answers for any model, so a
|
|
347
|
+
* rotation loop that consulted it would keep trying while every remaining
|
|
348
|
+
* account is parked on the model it is asking for — turning one exhausted
|
|
349
|
+
* window into a burst of refused requests.
|
|
350
|
+
*/
|
|
351
|
+
hasAnotherAvailableAccountFor(triedAccountIds: ReadonlySet<string>, model: string): Promise<boolean>;
|
|
352
|
+
/**
|
|
353
|
+
* Whether another account may serve right now.
|
|
354
|
+
*
|
|
355
|
+
* Answered from ONE read that also carries the pool-wide state, and false
|
|
356
|
+
* while the pool is paused: the rotation loop consults this before retrying,
|
|
357
|
+
* so a pause has to end the loop there rather than after another selection it
|
|
358
|
+
* would only refuse.
|
|
359
|
+
*/
|
|
360
|
+
hasAnotherAvailableAccount(triedAccountIds: ReadonlySet<string>): Promise<boolean>;
|
|
361
|
+
/**
|
|
362
|
+
* Whether an account may serve a request.
|
|
363
|
+
*
|
|
364
|
+
* A hidden account keeps its place, its alias and its history, but the user
|
|
365
|
+
* has taken it out of this plugin's rotation, so it is not eligible.
|
|
366
|
+
*/
|
|
367
|
+
protected isEligible(account: WorkBuddyPoolAccount, now: number, triedAccountIds?: ReadonlySet<string>): boolean;
|
|
368
|
+
private selection;
|
|
369
|
+
/**
|
|
370
|
+
* Add or re-authorize one account, settling its identity first.
|
|
371
|
+
*
|
|
372
|
+
* A completed browser sign-in states the display name but not always the uid,
|
|
373
|
+
* while the IDE's own file for the same account states the uid. Passing the
|
|
374
|
+
* raw response through would key the login under the name and the file under
|
|
375
|
+
* the uid, so the pool would hold the same account twice — the duplicate this
|
|
376
|
+
* fix exists to remove. Resolving from the credential's own token before the
|
|
377
|
+
* dedupe key is computed is what makes the two paths agree.
|
|
378
|
+
*/
|
|
379
|
+
addAccount(credentials: WorkBuddyCredentials, alias?: string): Promise<WorkBuddyPoolAccount>;
|
|
380
|
+
/**
|
|
381
|
+
* Remove one account inside a transaction.
|
|
382
|
+
*
|
|
383
|
+
* A desktop account is refused: the plugin does not own that credential file,
|
|
384
|
+
* so removing it from the pool would strand the IDE's session while telling
|
|
385
|
+
* the user their account was deleted. Hiding is the supported action there.
|
|
386
|
+
*/
|
|
387
|
+
protected deleteAccountFromPool(data: PoolData<WorkBuddyPoolAccount>, accountId: string): void;
|
|
388
|
+
}
|
|
389
|
+
//# sourceMappingURL=account-pool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account-p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