@eddyskywalker/dsh-chatgpt-subscription 0.40.1 → 0.41.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.
Files changed (38) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/lib/client.js +420 -15
  3. package/lib/client.js.map +1 -1
  4. package/lib/index.js +2101 -335
  5. package/lib/types/client/common/AccountPoolSection.d.ts +19 -0
  6. package/lib/types/client/common/AccountPoolSection.d.ts.map +1 -1
  7. package/lib/types/client/kimi-code/KimiCodeSection.d.ts.map +1 -1
  8. package/lib/types/client/kimi-code/KimiQuotaCard.d.ts +31 -0
  9. package/lib/types/client/kimi-code/KimiQuotaCard.d.ts.map +1 -0
  10. package/lib/types/client/kimi-code/locales.d.ts +74 -2
  11. package/lib/types/client/kimi-code/locales.d.ts.map +1 -1
  12. package/lib/types/client/kimi-code/staff-art.d.ts +19 -0
  13. package/lib/types/client/kimi-code/staff-art.d.ts.map +1 -0
  14. package/lib/types/client/kimi-code/styles.d.ts.map +1 -1
  15. package/lib/types/client/locales-ru/kimi-code.d.ts.map +1 -1
  16. package/lib/types/compat.d.ts +1 -1
  17. package/lib/types/host/antigravity/adapter.d.ts.map +1 -1
  18. package/lib/types/host/antigravity/mapper.d.ts.map +1 -1
  19. package/lib/types/host/cline-pass/adapter.d.ts +2 -0
  20. package/lib/types/host/cline-pass/adapter.d.ts.map +1 -1
  21. package/lib/types/host/common/request-images.d.ts +15 -5
  22. package/lib/types/host/common/request-images.d.ts.map +1 -1
  23. package/lib/types/host/kimi-code/adapter.d.ts +172 -0
  24. package/lib/types/host/kimi-code/adapter.d.ts.map +1 -1
  25. package/lib/types/host/kimi-code/cache-hint.d.ts +5 -5
  26. package/lib/types/host/kimi-code/client.d.ts.map +1 -1
  27. package/lib/types/host/kimi-code/mapper.d.ts +166 -1
  28. package/lib/types/host/kimi-code/mapper.d.ts.map +1 -1
  29. package/lib/types/host/kimi-code/media-files.d.ts +232 -0
  30. package/lib/types/host/kimi-code/media-files.d.ts.map +1 -0
  31. package/lib/types/host/kimi-code/routes.d.ts.map +1 -1
  32. package/lib/types/host/kimi-code/session-cache-state.d.ts +140 -0
  33. package/lib/types/host/kimi-code/session-cache-state.d.ts.map +1 -0
  34. package/lib/types/host/progress-updates/index.d.ts.map +1 -1
  35. package/lib/types/host/progress-updates/prompt.d.ts +6 -3
  36. package/lib/types/host/progress-updates/prompt.d.ts.map +1 -1
  37. package/lib/types/index.d.ts.map +1 -1
  38. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../src/host/kimi-code/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,aAAa,EASd,MAAM,YAAY,CAAA;AACnB,OAAO,EACL,mBAAmB,EAEnB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACzB,MAAM,kBAAkB,CAAA;AAGzB,OAAO,KAAK,EACV,eAAe,EACf,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,EAEd,mBAAmB,EACnB,YAAY,EACb,MAAM,qCAAqC,CAAA;AAG5C,gDAAgD;AAChD,eAAO,MAAM,WAAW,YAAY,CAAA;AACpC,eAAO,MAAM,WAAW,YAAY,CAAA;AACpC,eAAO,MAAM,OAAO,QAAQ,CAAA;AAiD5B,sFAAsF;AACtF,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAW5D;AAeD;;;;;;;GAOG;AACH,wBAAsB,eAAe,CACnC,WAAW,EAAE,MAAM,EACnB,IAAI,GAAE,YAAuB,EAC7B,KAAK,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,GACjC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAWjC;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,mBAAmB,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC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O,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAqFtC;AAkCD;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CACpC,WAAW,EAAE,mBAAmB,EAChC,OAAO,CAAC,EAAE,OAAO,EACjB,OAAO,CAAC,EAAE,OAAO,GAChB,eAAe,CAwBjB;AAED;;;;;;;;GAQG;AACH,wBAAsB,YAAY,CAChC,KAAK,EAAE,mBAAmB,EAC1B,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAmBzB;AAED;;;;;;GAMG;AACH,wBAAsB,aAAa,CACjC,KAAK,EAAE,mBAAmB,EAC1B,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAoBjC;AAED;;;;;;GAMG;AACH,wBAAsB,cAAc,CAClC,KAAK,EAAE,mBAAmB,EAC1B,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAAC;IAAE,OAAO,EAAE,eAAe,GAAG,IAAI,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,CAejE;AAED,OAAO,EAAE,aAAa,EAAE,CAAA"}
@@ -47,6 +47,60 @@ import type { KimiCodeReasoningEffort, KimiCodeWire } from '../../shared/kimi-co
47
47
  export declare const KNOWN_REASONING_KEYS: readonly ["reasoning_content", "reasoning_details", "reasoning"];
48
48
  /** Default outbound reasoning key, used until a response proves otherwise. */
49
49
  export declare const DEFAULT_REASONING_KEY: string;
50
+ /**
51
+ * How one `reasoning_details` fragment arrived on the wire.
52
+ *
53
+ * - `string` — the older bare-string spelling of the whole field;
54
+ * - `summary` — a visible summary element: official `type: 'summary'`, no
55
+ * `type` at all, or the `reasoning.summary` gateway spelling;
56
+ * - `encrypted` — official opaque provider state, which carries no visible text;
57
+ * - `text` — the `reasoning.text` compatibility spelling.
58
+ *
59
+ * The form is recorded because the same text has to be written back in the shape
60
+ * it arrived in: a bare string must not become an array, and an official
61
+ * encrypted element must stay one.
62
+ */
63
+ export type ReasoningForm = 'string' | 'text' | 'summary' | 'encrypted';
64
+ /**
65
+ * One reasoning fragment, together with how it arrived.
66
+ *
67
+ * The key is carried per fragment rather than per message because one delta can
68
+ * legitimately carry several at once: Kimi answers under `reasoning_content`,
69
+ * gateways add `reasoning_details`, and newer vLLM builds reply under
70
+ * `reasoning`. Stopping at the first field loses text the service already
71
+ * charged for, and flattening every field onto one outbound key is what makes a
72
+ * replay read as a field the peer never sent.
73
+ *
74
+ * An encrypted fragment is the one shape with no visible text: its `text` is ''
75
+ * and its payload stays in `encrypted`, which is opaque provider state and is
76
+ * never decoded, rendered, or logged.
77
+ */
78
+ export interface ReasoningFragment {
79
+ /** Wire field the fragment arrived under. */
80
+ readonly key: string;
81
+ /** Wire form, only meaningful when `key` is `reasoning_details`. */
82
+ readonly form?: ReasoningForm;
83
+ /** Element `type` exactly as received; absent when the element carried none. */
84
+ readonly wireType?: string;
85
+ /** Element index: the wire's own number, else the element's position. */
86
+ readonly index?: number;
87
+ /** Opaque encrypted provider state (`form: 'encrypted'`); never text. */
88
+ readonly encrypted?: string;
89
+ /** Visible text; always '' for an encrypted fragment. */
90
+ readonly text: string;
91
+ }
92
+ /**
93
+ * Every reasoning fragment one inbound object (a stream delta or a message)
94
+ * carries, in a fixed, documented order.
95
+ *
96
+ * `reasoning_content` comes first and `reasoning` last because that is the
97
+ * order of {@link KNOWN_REASONING_KEYS}: the Kimi field is the one this route is
98
+ * documented against and `reasoning` is the newer vLLM rename, so a delta
99
+ * carrying both keeps its text in the order a single-key endpoint would have
100
+ * produced it in. A `reasoning_details` array keeps its arrival order; `index` is
101
+ * carried as metadata and never reorders it (see reasoningDetailFragments).
102
+ */
103
+ export declare function reasoningFragmentsOf(source: unknown): ReasoningFragment[];
50
104
  /**
51
105
  * Per-endpoint reasoning-field dialect: observes what the endpoint actually
52
106
  * sends, and echoes thinking back under the same key.
@@ -59,7 +113,23 @@ export declare const DEFAULT_REASONING_KEY: string;
59
113
  */
60
114
  export declare class ReasoningKeyDialect {
61
115
  private detected;
62
- /** Reasoning text on an inbound message or delta, remembering its key. */
116
+ /**
117
+ * Every reasoning fragment one inbound delta carries, remembering the dialect.
118
+ *
119
+ * The FIRST string-shaped fragment names the key this endpoint speaks, which is
120
+ * exactly the field the earlier single-match read picked: an endpoint answering
121
+ * under `reasoning_content` keeps that outbound key even when the same delta
122
+ * also carries a sibling field, so learning does not change just because a peer
123
+ * became chattier.
124
+ *
125
+ * An element of a `reasoning_details` ARRAY never teaches the dialect: the
126
+ * outbound key must be a field that takes a plain string, and array elements
127
+ * could only teach `reasoning_details`, which on that wire is an array. A bare
128
+ * string `reasoning_details` still teaches it, because that spelling really is
129
+ * a string.
130
+ */
131
+ observeAll(source: unknown): ReasoningFragment[];
132
+ /** First reasoning fragment on an inbound message or delta, remembering its key. */
63
133
  observe(source: unknown): string | undefined;
64
134
  /** The key to serialize thinking into on an outbound assistant message. */
65
135
  outboundKey(): string;
@@ -166,6 +236,67 @@ export interface RequestMediaOptions {
166
236
  * (`messages[].tools`), Kimi's `dynamically_loaded_tools` capability.
167
237
  */
168
238
  messageTools?: boolean;
239
+ /**
240
+ * Hosted references this request already uploaded, keyed by ATTACHMENT ID.
241
+ *
242
+ * The value is the `ms://<id>` reference the upload returned, and citing it
243
+ * instead of the bytes is the whole point: the service reads the stored file,
244
+ * so the body carries a ~20-byte URL where it used to carry a megabyte of
245
+ * base64. Only the OpenAI-compatible surface documents this; the Anthropic
246
+ * one keeps its inline block (see anthropicUserContent).
247
+ *
248
+ * A miss is not an error: an occurrence with no entry here is sent exactly as
249
+ * it always was (inline when readable, the unavailable placeholder when not),
250
+ * which is what makes a per-media upload failure degrade instead of fail.
251
+ */
252
+ imageReferences?: ReadonlyMap<string, string>;
253
+ /** Hosted video references, keyed by attachment id; see imageReferences. */
254
+ videoReferences?: ReadonlyMap<string, string>;
255
+ }
256
+ /**
257
+ * One `reasoning_details` element, rebuilt from the provenance the stream
258
+ * recorded.
259
+ *
260
+ * Each variant is written back in the shape it arrived in: `text` and `summary`
261
+ * keep the wire `type` they were sent with (a summary may legitimately have
262
+ * none), `encrypted` keeps the opaque payload verbatim, and no variant invents
263
+ * an `index` the wire did not carry.
264
+ */
265
+ export type ReplayedReasoningDetail = {
266
+ readonly form: 'text';
267
+ readonly text: string;
268
+ readonly index?: number;
269
+ } | {
270
+ readonly form: 'summary';
271
+ readonly summary: string;
272
+ readonly wireType?: string;
273
+ readonly index?: number;
274
+ } | {
275
+ readonly form: 'encrypted';
276
+ readonly encrypted: string;
277
+ readonly wireType?: string;
278
+ readonly index?: number;
279
+ };
280
+ /**
281
+ * Reasoning of one assistant message, split by the wire shape it arrived in.
282
+ *
283
+ * `fields` holds text that belongs under a plain string field, `detailsString`
284
+ * is the older bare-string `reasoning_details` value (which must stay a
285
+ * string), and `details` holds array elements; `joined` is everything
286
+ * concatenated, which is what a message with no provenance still sends.
287
+ */
288
+ export interface ReplayedReasoning {
289
+ /** Text per plain string field, in first-seen order. */
290
+ readonly fields: ReadonlyArray<{
291
+ readonly key: string;
292
+ readonly text: string;
293
+ }>;
294
+ /** The legacy bare-string `reasoning_details` value, when one was recorded. */
295
+ readonly detailsString?: string;
296
+ /** `reasoning_details` elements rebuilt from their provenance, in wire order. */
297
+ readonly details: ReadonlyArray<ReplayedReasoningDetail>;
298
+ /** Every reasoning block concatenated, used when no provenance survives. */
299
+ readonly joined: string;
169
300
  }
170
301
  /**
171
302
  * One complete tool definition, in the shape the function-calling wire wants.
@@ -337,6 +468,28 @@ export interface KimiCodeInBandStreamError {
337
468
  /** The provider's own diagnostic, without this mapper's prefix. */
338
469
  message: string;
339
470
  }
471
+ /**
472
+ * One run of reasoning and how it arrived.
473
+ *
474
+ * Length, not text: the run describes where a slice of the block came from
475
+ * without storing the thinking twice, which keeps the persisted replay state
476
+ * small and keeps it a plain JSON value. An encrypted run has `length: 0` — it
477
+ * carries no visible text, only the opaque payload that must be handed back.
478
+ */
479
+ export interface ReasoningRun {
480
+ /** Wire field the slice arrived under. */
481
+ readonly key: string;
482
+ /** Wire form, only meaningful when `key` is `reasoning_details`. */
483
+ readonly form?: ReasoningForm;
484
+ /** Element `type` exactly as received; absent when the element carried none. */
485
+ readonly wireType?: string;
486
+ /** Element index: the wire's own number, else the element's position. */
487
+ readonly index?: number;
488
+ /** Opaque encrypted provider state (`form: 'encrypted'`); never text. */
489
+ readonly encrypted?: string;
490
+ /** Length of the slice in the assembled block's text; 0 when there is none. */
491
+ readonly length: number;
492
+ }
340
493
  export interface KimiCodeStreamState {
341
494
  wire: KimiCodeWire;
342
495
  blocks: OutboundContentBlock[];
@@ -345,6 +498,18 @@ export interface KimiCodeStreamState {
345
498
  type: 'text' | 'reasoning';
346
499
  text: string;
347
500
  } | null;
501
+ /**
502
+ * Which wire field the reasoning text of each block arrived under.
503
+ *
504
+ * One block can mix fields: a delta may carry `reasoning_content` and
505
+ * `reasoning` together, and consecutive deltas may alternate spellings without
506
+ * the block boundary moving. Each run records the key and the LENGTH of its
507
+ * slice rather than the slice itself, so the provenance never duplicates the
508
+ * thinking it describes and a replay can put every slice back under the field
509
+ * it came from. Keyed by block index and serialized by
510
+ * {@link reasoningReplayState}.
511
+ */
512
+ reasoningRuns: Map<number, ReasoningRun[]>;
348
513
  /** wire tool index -> accumulating call (OpenAI route). */
349
514
  toolCalls: Map<number, PendingToolCall>;
350
515
  /** anthropic content-block index -> our block index. */
@@ -1 +1 @@
1
- {"version":3,"file":"mapper.d.ts","sourceRoot":"","sources":["../../../../src/host/kimi-code/mapper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAGH,OAAO,EAGL,KAAK,oBAAoB,EAEzB,KAAK,eAAe,EACpB,KAAK,OAAO,EACZ,KAAK,WAAW,EAEjB,MAAM,yBAAyB,CAAA;AAKhC,OAAO,EAAE,uBAAuB,EAAmB,MAAM,0BAA0B,CAAA;AACnF,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAA;AAEnE,O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UG;AACH,wBAAgB,aAAa,CAC3B,SAAS,CAAC,EAAE,MAAM,EAClB,SAAS,CAAC,EAAE,MAAM,GACjB,kBAAkB,GAAG;IAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAmBlD;AASD,oFAAoF;AACpF,wBAAgB,eAAe,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAYxD;AA6DD,uEAAuE;AACvE,wBAAgB,WAAW,CAAC,KAAK,EAAE,mBAAmB,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,WAAW,EAAE,CAgBzF;AAED,kEAAkE;AAClE,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,mBAAmB,GAAG,IAAI,CAUrE"}
@@ -0,0 +1,232 @@
1
+ /**
2
+ * Kimi Code hosted-file (media upload) client.
3
+ *
4
+ * WHY THIS FILE EXISTS. Everything this plugin has ever sent to the Kimi Code
5
+ * gateway carries media INLINE, as a `data:<type>;base64,...` URL
6
+ * (mapper.ts builds both the image and the video block that way). The gateway
7
+ * also accepts a hosted reference instead: upload the bytes once, cite
8
+ * `ms://<id>` afterwards. That is the only way to send a clip whose base64 would
9
+ * overrun the request body ceiling, and it is what this module implements.
10
+ *
11
+ * EVERY WIRE FACT BELOW WAS MEASURED live against the subscription gateway by
12
+ * `scripts/probe-kimi-files.probe.ts` on this line's own account and region,
13
+ * not copied from the official client:
14
+ *
15
+ * - the upload is `POST {coding base}/v1/files`, `multipart/form-data` with a
16
+ * `file` part and a `purpose` part whose value is `image` or `video`
17
+ * (note: NOT the `*_understanding` vocabulary the MiniMax line uses);
18
+ * - it authenticates with the bearer token plus the same `X-Msh-*` identity
19
+ * headers every other request on this line sends;
20
+ * - the body answers with the id at the top level or nested under
21
+ * `data`/`file`/`result`, and the reference a later chat body cites is
22
+ * `ms://<id>`;
23
+ * - `content-type` is never set by hand: the runtime writes
24
+ * `multipart/form-data; boundary=...` itself, and a hand-written JSON header
25
+ * on a form body is a malformed request.
26
+ *
27
+ * DELIBERATELY NARROW. No adapter, mapper or route is touched here: this module
28
+ * only uploads, caches and returns a reference. Integration is a later change.
29
+ *
30
+ * @module dsh-chatgpt-subscription/kimi-media-files
31
+ */
32
+ /** Upload route, relative to a base URL that may already carry `/v1`. */
33
+ export declare const FILES_UPLOAD_PATH = "/v1/files";
34
+ /** Scheme a stored id is cited by on the wire. */
35
+ export declare const FILE_REF_SCHEME = "ms://";
36
+ /**
37
+ * Ceiling on cached references.
38
+ *
39
+ * Bounded because a long conversation can attach many distinct clips and a
40
+ * process that lives for days must not grow one map per upload forever. 256 is
41
+ * far more than one conversation cites and small enough to be invisible.
42
+ */
43
+ export declare const DEFAULT_MEDIA_FILE_CACHE_ENTRIES = 256;
44
+ /** Time budget for one upload request. */
45
+ export declare const MEDIA_UPLOAD_TIMEOUT_MS = 120000;
46
+ /** The two purposes this surface measuredly accepts. */
47
+ export type KimiMediaKind = 'image' | 'video';
48
+ /** Why one upload could not produce a usable reference. */
49
+ export type KimiMediaUploadFailure =
50
+ /** The request was unusable before anything was sent (media type, empty body, ...). */
51
+ 'invalid-request'
52
+ /** The media type is not image/* or video/*, so there is no purpose to send. */
53
+ | 'unsupported-media'
54
+ /** HTTP 401/403: the credential was not accepted. */
55
+ | 'unauthorized'
56
+ /** HTTP 404/405: this base URL does not expose the upload route. */
57
+ | 'not-found'
58
+ /** HTTP 413: the service refused the body as too large. */
59
+ | 'too-large'
60
+ /** HTTP 5xx: the service failed; the same request may succeed later. */
61
+ | 'server'
62
+ /** Any other non-2xx answer. */
63
+ | 'rejected'
64
+ /** 2xx whose body was not JSON. */
65
+ | 'not-json'
66
+ /** 2xx whose body carried no usable id. */
67
+ | 'no-id'
68
+ /** The local time budget elapsed before the response arrived. */
69
+ | 'timeout'
70
+ /** The request never completed (socket, DNS, TLS, ...). */
71
+ | 'network';
72
+ /**
73
+ * One failed upload.
74
+ *
75
+ * Carries the HTTP status and a REDACTED digest of the response body so a
76
+ * caller can decide (401 -> sign in again, 5xx -> retry) without the raw body
77
+ * reaching a log. The access token is never placed in `message` or `detail`;
78
+ * see {@link redact}.
79
+ */
80
+ export declare class KimiMediaUploadError extends Error {
81
+ readonly failure: KimiMediaUploadFailure;
82
+ readonly status: number | null;
83
+ /** Redacted one-line digest of the response body, or '' when there was none. */
84
+ readonly detail: string;
85
+ constructor(failure: KimiMediaUploadFailure, message: string, options?: {
86
+ status?: number | null;
87
+ detail?: string;
88
+ });
89
+ }
90
+ /** What one upload needs. */
91
+ export interface KimiMediaUploadRequest {
92
+ /** Bearer token the caller obtained; never logged and never part of a key. */
93
+ readonly accessToken: string;
94
+ /** Coding API base, with or without a trailing slash and with or without `/v1`. */
95
+ readonly baseUrl: string;
96
+ /**
97
+ * Opaque, stable identifier of the ACCOUNT the bytes are uploaded under.
98
+ *
99
+ * It scopes the cache: an id minted for one account is never handed to
100
+ * another, because nothing here proves the gateway shares ids across accounts.
101
+ * It must identify the account (a user id, an account slot index) and must
102
+ * NEVER be the access token — {@link KimiMediaFilesUploader.upload} refuses
103
+ * that, so a token cannot end up inside a cache key by accident.
104
+ */
105
+ readonly accountScope: string;
106
+ /** Complete file bytes. */
107
+ readonly data: Uint8Array;
108
+ /** Media type, such as `image/png` or `video/mp4`. */
109
+ readonly mediaType: string;
110
+ /** Optional display name; only its leaf is used, and never as a path. */
111
+ readonly filename?: string;
112
+ /** Cancels this caller's wait, and the upload once nobody is waiting. */
113
+ readonly signal?: AbortSignal;
114
+ }
115
+ /** Everything a caller of this module may swap out, plus test seams. */
116
+ export interface KimiMediaUploadOptions {
117
+ /** Transport; defaults to the global `fetch`. */
118
+ readonly fetchFn?: typeof fetch;
119
+ /** Cache ceiling; defaults to {@link DEFAULT_MEDIA_FILE_CACHE_ENTRIES}. */
120
+ readonly maxCacheEntries?: number;
121
+ /** Per-request time budget; 0 (or a negative value) disables it. */
122
+ readonly timeoutMs?: number;
123
+ }
124
+ /**
125
+ * The upload URL for one coding base.
126
+ *
127
+ * The base this line resolves normally carries neither a version nor a trailing
128
+ * slash (`https://api.kimi.com/coding`), so the measured route is built by
129
+ * appending `/v1/files` and the answer is `.../coding/v1/files`. A caller that
130
+ * passes a base which ALREADY ends in `/v1` — the official client's own
131
+ * KIMI_CODE_BASE_URL shape — gets the prefix removed once rather than doubled:
132
+ * `.../coding/v1/v1/files` is a 404 that reads like a missing route.
133
+ */
134
+ export declare function filesUploadUrl(baseUrl: string): string;
135
+ /** The upload purpose one media type maps to, or undefined when unsupported. */
136
+ export declare function mediaKindFor(mediaType: string): KimiMediaKind | undefined;
137
+ /** The wire reference for a stored id. */
138
+ export declare function fileReference(id: string): string;
139
+ /**
140
+ * The cache key for one upload.
141
+ *
142
+ * Five things, and each of them is load-bearing:
143
+ *
144
+ * - ACCOUNT SCOPE, because an id minted for one account is never assumed to be
145
+ * readable by another (see {@link KimiMediaUploadRequest.accountScope});
146
+ * - BASE URL (normalized through {@link filesUploadUrl}, so a trailing slash
147
+ * cannot split one endpoint into two slots), because two regions or two
148
+ * deployments are two distinct file stores;
149
+ * - MEDIA KIND and MEDIA TYPE, because the same bytes uploaded as an image and
150
+ * as a video are two different resources as far as the purpose is concerned;
151
+ * - CONTENT SHA-256, so identical bytes reuse one upload and any change at all
152
+ * misses the cache.
153
+ *
154
+ * The access token is NOT part of it: a key is written to memory only, but a
155
+ * token in a key is a token in the next dump, and the account is already
156
+ * identified by its scope. `|` cannot appear in a scope because the scope is
157
+ * sanitized here.
158
+ */
159
+ export declare function mediaFileCacheKey(input: {
160
+ accountScope: string;
161
+ baseUrl: string;
162
+ mediaType: string;
163
+ data: Uint8Array;
164
+ }): string;
165
+ /**
166
+ * Uploads one media file per distinct key, caching and single-flighting them.
167
+ *
168
+ * Two behaviours are deliberate and easy to get wrong:
169
+ *
170
+ * 1. SINGLE FLIGHT. Concurrent callers with the same key share one request.
171
+ * A caller that aborts stops waiting immediately and gets an AbortError, but
172
+ * the shared request is only cancelled once NO caller is still waiting — so
173
+ * one cancelled turn does not fail another turn that wants the same clip.
174
+ * 2. NO TTL. A successful reference is cached until it is evicted by the LRU
175
+ * ceiling. Inventing an expiry would either expire a live id (a failed turn)
176
+ * or outlive it silently; nothing here measured a lifetime, so nothing here
177
+ * pretends to know one. A reference the service later rejects is dropped with
178
+ * {@link forget} by whoever sees that rejection.
179
+ */
180
+ export declare class KimiMediaFilesUploader {
181
+ private readonly fetchFn;
182
+ private readonly maxCacheEntries;
183
+ private readonly timeoutMs;
184
+ /** key -> `ms://<id>`, in least-recently-used order. */
185
+ private readonly cache;
186
+ private readonly flights;
187
+ constructor(options?: KimiMediaUploadOptions);
188
+ /** Cached references currently held, for a settings surface or a test. */
189
+ get size(): number;
190
+ /** Uploads one file and returns the `ms://<id>` reference a request cites. */
191
+ upload(request: KimiMediaUploadRequest): Promise<string>;
192
+ /**
193
+ * Drop the reference one upload would use.
194
+ *
195
+ * The caller that sees a stored id REJECTED on the wire calls this so the next
196
+ * attempt uploads again instead of replaying the same dead reference.
197
+ */
198
+ forget(request: Omit<KimiMediaUploadRequest, 'accessToken'>): boolean;
199
+ /** Forget everything; a sign-out or a test starting over. */
200
+ clear(): void;
201
+ /** Validate and normalize one request, or throw before anything is sent. */
202
+ private resolve;
203
+ private readCache;
204
+ private writeCache;
205
+ /** Open one flight and run it; the map entry is dropped as it settles. */
206
+ private startFlight;
207
+ /**
208
+ * Wait for one flight, respecting THIS caller's abort.
209
+ *
210
+ * The flight is not bound to the caller's signal: a caller that aborts
211
+ * detaches, and the transport is cancelled only when the last waiter has gone.
212
+ */
213
+ private join;
214
+ /** The one request a flight performs. */
215
+ private performUpload;
216
+ /** Turn a transport rejection into the error the caller must see. */
217
+ private transportFailure;
218
+ /** Read one response into a reference, or into a typed failure. */
219
+ private settle;
220
+ }
221
+ /** One uploader with the default transport and cache size. */
222
+ export declare function createMediaFilesUploader(options?: KimiMediaUploadOptions): KimiMediaFilesUploader;
223
+ /**
224
+ * The process-wide uploader the adapter will use.
225
+ *
226
+ * Shared on purpose: the cache is the whole point, and a per-call instance would
227
+ * upload the same clip once per turn.
228
+ */
229
+ export declare const kimiMediaFiles: KimiMediaFilesUploader;
230
+ /** Upload one file through the shared uploader. */
231
+ export declare function uploadMediaFile(request: KimiMediaUploadRequest): Promise<string>;
232
+ //# sourceMappingURL=media-files.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"media-files.d.ts","sourceRoot":"","sources":["../../../../src/host/kimi-code/media-files.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAKH,yEAAyE;AACzE,eAAO,MAAM,iBAAiB,cAAc,CAAA;AAE5C,kDAAkD;AAClD,eAAO,MAAM,eAAe,UAAU,CAAA;AAEtC;;;;;;GAMG;AACH,eAAO,MAAM,gCAAgC,MAAM,CAAA;AAEnD,0CAA0C;AAC1C,eAAO,MAAM,uBAAuB,SAAU,CAAA;AAE9C,wDAAwD;AACxD,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,OAAO,CAAA;AAE7C,2DAA2D;AAC3D,MAAM,MAAM,sBAAsB;AAChC,uFAAuF;AACrF,iBAAiB;AACnB,gFAAgF;GAC9E,mBAAmB;AACrB,qDAAqD;GACnD,cAAc;AAChB,oEAAoE;GAClE,WAAW;AACb,2DAA2D;GACzD,WAAW;AACb,wEAAwE;GACtE,QAAQ;AACV,gCAAgC;GAC9B,UAAU;AACZ,mCAAmC;GACjC,UAAU;AACZ,2CAA2C;GACzC,OAAO;AACT,iEAAiE;GAC/D,SAAS;AACX,2DAA2D;GACzD,SAAS,CAAA;AAEb;;;;;;;GAOG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,QAAQ,CAAC,OAAO,EAAE,sBAAsB,CAAA;IACxC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B,gFAAgF;IAChF,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;gBAGrB,OAAO,EAAE,sBAAsB,EAC/B,OAAO,EAAE,MAAM,EACf,OAAO,GAAE;QAAE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,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAA;CACpC;AAMD,mFAAmF;AACnF,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,mBAAmB,EAC1B,aAAa,EAAE,sBAAsB,EACrC,WAAW,CAAC,EAAE,uBAAuB,EACrC,OAAO,GAAE,qBAA0B,EACnC,WAAW,GAAE,mBAAmB,GAAG,SAA+B,GACjE,OAAO,CAAC,iBAAiB,CAAC,CA4E5B;AAoHD,qEAAqE;AACrE,wBAAgB,sBAAsB,CACpC,GAAG,EAAE,OAAO,EACZ,KAAK,EAAE,mBAAmB,EAC1B,aAAa,EAAE,sBAAsB,EACrC,WAAW,CAAC,EAAE,uBAAuB,EACrC,OAAO,GAAE,qBAA0B,EACnC,WAAW,GAAE,mBAAmB,GAAG,SAA+B,GACjE,MAAM,IAAI,CA0UZ;AAED,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,CAAA"}
@@ -0,0 +1,140 @@
1
+ /**
2
+ * Durable per-session cache state for the Kimi route.
3
+ *
4
+ * Kimi's prefix cache lives on the service, but everything a status card needs
5
+ * to describe it - when this conversation last ran, how large its prompt is, and
6
+ * why the last request's prefix broke - used to live in process memory only. A
7
+ * restart therefore erased the one fact the expiry hint depends on, exactly when
8
+ * the user resumes a task and pays for the whole prompt again: the card showed
9
+ * an empty state instead of "this conversation sat idle past the cache lifetime".
10
+ *
11
+ * This module keeps that state on disk, in the same storages directory the
12
+ * preferences store uses, so the hint and the attribution survive a restart.
13
+ * It is a diagnostic: nothing here changes a request.
14
+ * @module dsh-chatgpt-subscription/kimi-code-session-cache-state
15
+ */
16
+ /**
17
+ * Conversations kept in the document.
18
+ *
19
+ * The hint only ever describes a conversation that ran recently, so an install
20
+ * that opens hundreds of sessions does not need all of them on disk. Old entries
21
+ * are dropped by {@link SessionCacheStateStore.write} in updatedAt order, which
22
+ * is the same order the "most recent conversation" fallback reads.
23
+ */
24
+ export declare const MAX_SESSION_RECORDS = 64;
25
+ /** One conversation's cache state, as it survives the process. */
26
+ export interface KimiCodeSessionCacheRecord {
27
+ /** When this conversation last sent a request, epoch ms. */
28
+ lastActiveAt: number;
29
+ /**
30
+ * Prompt tokens of the most recent request (cache read + fresh input).
31
+ *
32
+ * The LAST request, not the rolling total: the expiry hint is about how much
33
+ * the next turn will have to reprocess, and summing every turn of a long
34
+ * conversation would overstate that by an order of magnitude.
35
+ */
36
+ totalTokens: number;
37
+ /** Rolling totals for the card, mirroring the mapper's per-session stats. */
38
+ requests: number;
39
+ cachedTokens: number;
40
+ freshTokens: number;
41
+ outputTokens: number;
42
+ cacheWriteTokens: number;
43
+ cacheWrite5mTokens: number;
44
+ cacheWrite1hTokens: number;
45
+ /** Cause attributed to the most recent request's prefix break, when there was one. */
46
+ lastDrift?: string;
47
+ /** When any field above last changed, epoch ms. Used for pruning and ordering. */
48
+ updatedAt: number;
49
+ }
50
+ /** Where the document lives; beside the other plugin-owned JSON. */
51
+ export declare function sessionCacheStatePath(): string;
52
+ /**
53
+ * Per-session cache state held in one JSON document.
54
+ *
55
+ * Reads are synchronous because every caller is answering a status request or
56
+ * closing a turn, both of which are allowed to block on a file this size. Writes
57
+ * are debounced: a turn reports once, and several turns in flight must not
58
+ * rewrite the document several times.
59
+ */
60
+ export declare class SessionCacheStateStore {
61
+ private document;
62
+ private pending;
63
+ /**
64
+ * @param filePath - Document location; defaults to {@link sessionCacheStatePath}.
65
+ * @param maxEntries - Conversations kept; the oldest are dropped first.
66
+ */
67
+ private readonly filePath;
68
+ private readonly maxEntries;
69
+ /**
70
+ * Whether this store may write at all.
71
+ *
72
+ * A store built on an explicit path is someone's own file - a test's temporary
73
+ * document - and always writes. The default-path store belongs to the user's
74
+ * harness home, and a test that never named a path must not overwrite it.
75
+ */
76
+ private readonly allowWrite;
77
+ constructor(filePath?: string, maxEntries?: number);
78
+ /**
79
+ * The record for one conversation, or the most recently active one.
80
+ *
81
+ * The fallback is what makes the status card useful without a session named:
82
+ * the card describes the line, and the only conversation it can honestly
83
+ * describe in that case is the one that ran last.
84
+ * @param sessionId - Conversation to read; omit for the most recent one.
85
+ * @returns the record, or undefined when nothing has ever been recorded.
86
+ */
87
+ read(sessionId?: string): KimiCodeSessionCacheRecord | undefined;
88
+ /**
89
+ * File one conversation's state and schedule the document write.
90
+ * @param sessionId - Conversation the record belongs to; ignored when blank.
91
+ * @param record - Complete record for that conversation.
92
+ */
93
+ write(sessionId: string, record: KimiCodeSessionCacheRecord): void;
94
+ /**
95
+ * Write the document now, synchronously.
96
+ *
97
+ * Exposed for tests and for a caller that is about to lose the process; the
98
+ * debounced path is what normal turns use.
99
+ */
100
+ flush(): void;
101
+ /** Drop everything older than the newest maxEntries conversations. */
102
+ private prune;
103
+ /** Read the document once; a missing or corrupt file reads as empty. */
104
+ private load;
105
+ /** Coalesce the writes one turn's several fields would otherwise cause. */
106
+ private schedule;
107
+ private cancelPending;
108
+ /** Write through a temporary file so a crash cannot leave half a document. */
109
+ private persist;
110
+ }
111
+ /** What the running process knows about one conversation, before any disk read. */
112
+ export interface SessionCacheViewInput {
113
+ /** Last activity the process remembers, if the conversation ran in it. */
114
+ memoryLastActiveAt?: number;
115
+ /** Prompt tokens the process has seen for this conversation; 0 when none. */
116
+ memoryTotalTokens: number;
117
+ }
118
+ /**
119
+ * Combine process memory with the durable record into the hint's two inputs.
120
+ *
121
+ * The process supplies the idle baseline whenever it has served the conversation,
122
+ * because only it knows about the turn that just ended. The prompt size comes
123
+ * from the file when it has one: the record is rewritten at every turn close, so
124
+ * it holds the LAST request's size, while the process only offers a sum across
125
+ * every turn of the conversation - which can overstate the next turn's cost by
126
+ * an order of magnitude. With no conversation named the file is the only source,
127
+ * because a process aggregate spans several conversations and would make "this
128
+ * conversation's prompt" a number no single conversation has.
129
+ * @param sessionId - Conversation being described; omit for "the most recent".
130
+ * @param memory - What this process knows about it.
131
+ * @param durable - What the last run on this machine left behind.
132
+ * @returns the idle baseline and prompt size the expiry rule needs.
133
+ */
134
+ export declare function resolveSessionCacheView(sessionId: string | undefined, memory: SessionCacheViewInput, durable: KimiCodeSessionCacheRecord | undefined): {
135
+ lastActiveAt?: number;
136
+ totalTokens: number;
137
+ };
138
+ /** The process-wide store the adapter writes and the routes read. */
139
+ export declare const sessionCacheState: SessionCacheStateStore;
140
+ //# sourceMappingURL=session-cache-state.d.ts.map