@eddyskywalker/dsh-chatgpt-subscription 0.30.0 → 0.31.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 (55) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/lib/client.js +2905 -194
  3. package/lib/client.js.map +1 -1
  4. package/lib/index.js +3829 -553
  5. package/lib/types/client/index.d.ts.map +1 -1
  6. package/lib/types/client/minimax-code/MinimaxCodeSection.d.ts.map +1 -1
  7. package/lib/types/client/minimax-code/MinimaxVideoDocumentBody.d.ts +69 -0
  8. package/lib/types/client/minimax-code/MinimaxVideoDocumentBody.d.ts.map +1 -0
  9. package/lib/types/client/minimax-code/MinimaxVideoToolView.d.ts +83 -0
  10. package/lib/types/client/minimax-code/MinimaxVideoToolView.d.ts.map +1 -0
  11. package/lib/types/client/minimax-code/VideoFormDialog.d.ts +90 -0
  12. package/lib/types/client/minimax-code/VideoFormDialog.d.ts.map +1 -0
  13. package/lib/types/client/minimax-code/VideoSettingsSections.d.ts +73 -0
  14. package/lib/types/client/minimax-code/VideoSettingsSections.d.ts.map +1 -0
  15. package/lib/types/client/minimax-code/commands-contract.d.ts +35 -0
  16. package/lib/types/client/minimax-code/commands-contract.d.ts.map +1 -0
  17. package/lib/types/client/minimax-code/document-preview.d.ts +45 -0
  18. package/lib/types/client/minimax-code/document-preview.d.ts.map +1 -0
  19. package/lib/types/client/minimax-code/locales.d.ts +206 -2
  20. package/lib/types/client/minimax-code/locales.d.ts.map +1 -1
  21. package/lib/types/client/minimax-code/styles.d.ts.map +1 -1
  22. package/lib/types/client/minimax-code/video-command-host.d.ts +61 -0
  23. package/lib/types/client/minimax-code/video-command-host.d.ts.map +1 -0
  24. package/lib/types/client/minimax-code/video-command.d.ts +126 -0
  25. package/lib/types/client/minimax-code/video-command.d.ts.map +1 -0
  26. package/lib/types/client/minimax-code/video-contract.d.ts +172 -0
  27. package/lib/types/client/minimax-code/video-contract.d.ts.map +1 -0
  28. package/lib/types/client/minimax-code/video-defaults-store.d.ts +61 -0
  29. package/lib/types/client/minimax-code/video-defaults-store.d.ts.map +1 -0
  30. package/lib/types/client/minimax-code/video-form-rules.d.ts +288 -0
  31. package/lib/types/client/minimax-code/video-form-rules.d.ts.map +1 -0
  32. package/lib/types/client/minimax-code/video-media.d.ts +61 -0
  33. package/lib/types/client/minimax-code/video-media.d.ts.map +1 -0
  34. package/lib/types/client/minimax-code/video-slots.d.ts +87 -0
  35. package/lib/types/client/minimax-code/video-slots.d.ts.map +1 -0
  36. package/lib/types/host/minimax-code/client.d.ts.map +1 -1
  37. package/lib/types/host/minimax-code/iso-bmff-duration.d.ts +84 -0
  38. package/lib/types/host/minimax-code/iso-bmff-duration.d.ts.map +1 -0
  39. package/lib/types/host/minimax-code/matrix-client.d.ts +168 -0
  40. package/lib/types/host/minimax-code/matrix-client.d.ts.map +1 -0
  41. package/lib/types/host/minimax-code/media-store.d.ts +153 -0
  42. package/lib/types/host/minimax-code/media-store.d.ts.map +1 -0
  43. package/lib/types/host/minimax-code/routes.d.ts.map +1 -1
  44. package/lib/types/host/minimax-code/video-history.d.ts +240 -0
  45. package/lib/types/host/minimax-code/video-history.d.ts.map +1 -0
  46. package/lib/types/host/minimax-code/video-submit-rules.d.ts +40 -0
  47. package/lib/types/host/minimax-code/video-submit-rules.d.ts.map +1 -0
  48. package/lib/types/host/minimax-code/video-tool.d.ts +757 -0
  49. package/lib/types/host/minimax-code/video-tool.d.ts.map +1 -0
  50. package/lib/types/host/progress-updates/index.d.ts +6 -0
  51. package/lib/types/host/progress-updates/index.d.ts.map +1 -1
  52. package/lib/types/host/progress-updates/projection.d.ts +214 -0
  53. package/lib/types/host/progress-updates/projection.d.ts.map +1 -0
  54. package/lib/types/index.d.ts.map +1 -1
  55. package/package.json +13 -4
@@ -0,0 +1,87 @@
1
+ /**
2
+ * 本线路用到的槽位声明与浏览器侧服务面。
3
+ *
4
+ * `tool.call.toolview` 不在这里重复声明:它由本插件已安装的 ui-tool 合并进
5
+ * `SlotMap`,同一格写两次形状不同就是编译错误。
6
+ *
7
+ * `sidebar.right.tab.document` 由 `@deepseek-ai/dsh-client-ui-sidebar-documentpreview`
8
+ * 提供,而那个包**不是本插件的依赖**(`package.json` 的 `dsh.client.inject` 只声明
9
+ * 运行期顺序,不是编译期依赖)。为了两行注册去依赖整个文档预览包,等于把一个可选
10
+ * 能力变成硬依赖,所以这里按平台同形把它**声明**出来——运行语义完全由平台的槽位
11
+ * 注册表决定,这里只是让 `register` / `inject` 的实参过类型检查。
12
+ * 这与 `../progress-updates/contracts.ts` 对 `sidebar.right.pane.tab` 的处理一致。
13
+ *
14
+ * 刻意**不**合并 cordis 的 `Context`:只要 `src/client/**` 里出现一条那样的
15
+ * augmentation,cordis 自己的 `interface Context extends Pick<Fiber, 'effect'>`
16
+ * 就会整片失效(`../progress-updates/contracts.ts` 末尾记了这个坑)。
17
+ * 所以 `documentPreviews` / `remote` 一律经 `ctx.get(name)` 取回再窄化。
18
+ *
19
+ * @module @eddyskywalker/dsh-chatgpt-subscription/client/minimax-code/video-slots
20
+ */
21
+ /** 一份 `DocumentPreviewDefinition` 在运行期的形状(宿主 `document/registry.ts` 同形)。 */
22
+ export interface DocumentPreviewRegistration {
23
+ /** 唯一实现名,同时是文档槽的键。 */
24
+ readonly id: string;
25
+ /** 认领的文件后缀(不带点)。 */
26
+ readonly extensions: readonly string[];
27
+ /** 其中字节不可当文本读的后缀,必须是 `extensions` 的子集。 */
28
+ readonly binaryExtensions?: readonly string[];
29
+ /** 外部实现优先于内置实现。 */
30
+ readonly priority?: 'builtin' | 'extension';
31
+ /** 页签上的实现名,渲染时求值。 @returns 可见名称。 */
32
+ readonly title: () => string;
33
+ /** 内容下发方式。 */
34
+ readonly loading: 'text-pages' | 'bytes-complete' | 'renderer';
35
+ /** 是否消费文档的换行偏好。 */
36
+ readonly wrap?: boolean;
37
+ }
38
+ /** `ctx.documentPreviews` 的注册面。 */
39
+ export interface DocumentPreviewRegistryService {
40
+ /**
41
+ * 注册一个实现。
42
+ * @param definition - 静态声明;`binaryExtensions` 越界或 id 重复都会抛。
43
+ * @returns 幂等卸载函数。
44
+ */
45
+ register(definition: DocumentPreviewRegistration): () => void;
46
+ }
47
+ /**
48
+ * 本插件用到的 `remote.workspaceFiles` 面。
49
+ *
50
+ * 与宿主 `ui-sidebar-documentpreview/src/client/rpc.ts` 的
51
+ * `WorkspaceFilesReadRemote` 同形:不传 `range` 就是整文件读取(上限由宿主
52
+ * `maxFileBytes` 决定),`baseFile` 用于把相对路径解析到基准文件目录。
53
+ */
54
+ export interface WorkspaceFilesRemote {
55
+ readonly workspaceFiles: {
56
+ /**
57
+ * 读整段文件字节。
58
+ * @param sessionId - 决定工作区根的会话 id。
59
+ * @param path - 绝对路径,或相对该会话工作区根的路径。
60
+ * @param options - 可选的字节窗口与基准文件;本实现不传。
61
+ * @param signal - 取消信号。
62
+ * @returns 裸字节结果(`data` 是 `Uint8Array`)。
63
+ */
64
+ readBytes(sessionId: string, path: string, options: {
65
+ readonly baseFile?: string;
66
+ readonly range?: {
67
+ readonly offset?: number;
68
+ readonly length?: number;
69
+ };
70
+ }, signal?: AbortSignal): Promise<{
71
+ readonly data: Uint8Array;
72
+ }>;
73
+ };
74
+ }
75
+ declare module '@deepseek-ai/dsh-client-ui-slots' {
76
+ interface SlotMap {
77
+ /**
78
+ * 文档正文,按注册的实现 id 分发。本渲染器只消费地址与注入的取字节通道,
79
+ * 所以只声明驱动 `register` / `inject` 过类型检查的这两轴。
80
+ */
81
+ 'sidebar.right.tab.document': {
82
+ kind: 'keyed';
83
+ scope: 'session';
84
+ };
85
+ }
86
+ }
87
+ //# sourceMappingURL=video-slots.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"video-slots.d.ts","sourceRoot":"","sources":["../../../../src/client/minimax-code/video-slots.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,4EAA4E;AAC5E,MAAM,WAAW,2BAA2B;I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C,gBAAgB,GAAG,IAAI,CAAC,CA2GlC;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,IAAI,MAAM,EAAE,CAEvC;AAED,+EAA+E;AAC/E,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,sBAAsB,GAAG,IAAI,GAAG,kBAAkB,GAAG,IAAI,CAEzG;AAED,OAAO,EAAE,4BAA4B,EAAE,YAAY,EAAE,aAAa,EAAE,+BAA+B,EAAE,sBAAsB,EAAE,WAAW,EAAE,CAAA;AAC1I,YAAY,EAAE,iBAAiB,EAAE,CAAA"}
@@ -0,0 +1,84 @@
1
+ /**
2
+ * The smallest ISO BMFF duration reader this route needs, with no decoder.
3
+ *
4
+ * WHY IT EXISTS. A reference video must be sent to the generation service with
5
+ * its length in seconds beside it (docs/minimax-video-extended-spec.md section
6
+ * 4), and upstream reads that number out of the container itself rather than
7
+ * asking the caller for it - `readIsoBmffDurationSeconds` is the name of the
8
+ * upstream file too. A LOCAL reference video therefore owes the caller no
9
+ * `referenceVideoDurationSeconds` argument: this module supplies it.
10
+ *
11
+ * WHY IT IS NOT AFFMPEG. The number lives in exactly one box, `moov/mvhd`, at a
12
+ * fixed byte offset inside it. Reaching it is an eight-byte header walk, not a
13
+ * demux; pulling in a media toolchain (or a native binding) to read two integers
14
+ * would dwarf the rest of this plugin.
15
+ *
16
+ * THE TWO LAYOUTS, which is the whole reason the walk is written the way it is:
17
+ *
18
+ * | layout | box order | what a whole-file read would cost |
19
+ * | ------------- | -------------------- | --------------------------------- |
20
+ * | faststart | `ftyp moov mdat` | the moov is near the front |
21
+ * | ordinary mp4 | `ftyp mdat moov` | the moov is AFTER tens of megabytes |
22
+ *
23
+ * So the reader NEVER loads the file. It opens a handle, `stat`s the size, and
24
+ * seeks: it reads the eight-byte header of each TOP-LEVEL box only, jumps over a
25
+ * `mdat` by its declared size, and - once it lands on `moov` - reads that box's
26
+ * own child headers the same way until it finds `mvhd`, of which it keeps the
27
+ * last 32 bytes. A 500 MB clip costs a few dozen bytes of I/O.
28
+ *
29
+ * WHAT IT REFUSES, deliberately, instead of guessing:
30
+ * - a file that is not ISO BMFF at all (a WebM's EBML magic is not a box
31
+ * header) -> `MINIMAX_VIDEO_NOT_ISO_BMFF`;
32
+ * - a box header that runs past the end of its container, or a box smaller
33
+ * than its own header -> `MINIMAX_VIDEO_NOT_ISO_BMFF`;
34
+ * - an ISO BMFF file with no `moov`, no `mvhd`, or a `mvhd` too short to hold
35
+ * its own fields -> `MINIMAX_VIDEO_DURATION_UNREADABLE`;
36
+ * - a `timescale` of zero (the division has no answer) -> the same code;
37
+ * - `mvhd`'s documented "unknown duration" sentinels (all bits set) -> the
38
+ * same code, because reporting a made-up length is worse than refusing.
39
+ *
40
+ * Every refusal is an ERROR, never `undefined`: a caller that silently got no
41
+ * duration would send a reference video with no length, or `null`, and neither
42
+ * is a thing the service asked for.
43
+ *
44
+ * @module dsh-chatgpt-subscription/minimax-code/iso-bmff-duration
45
+ */
46
+ import { HarnessError } from '@deepseek-ai/dsh-llm';
47
+ /**
48
+ * Raised when a file's length cannot be read out of its ISO BMFF container.
49
+ *
50
+ * A `HarnessError` subclass rather than a bare `Error`, so the tool layer can
51
+ * hand its `code` straight to the caller without re-wrapping the message.
52
+ */
53
+ export declare class IsoBmffDurationError extends HarnessError {
54
+ constructor(message: string, code: string);
55
+ }
56
+ /**
57
+ * Read one mp4/mov file's length in seconds, without decoding a frame.
58
+ *
59
+ * The walk, in full:
60
+ *
61
+ * 1. `stat` the file - the size is the only bound needed, and nothing is read
62
+ * before it is known.
63
+ * 2. From offset 0, read each TOP-LEVEL box header and jump to the next one, so
64
+ * an `mdat` is skipped by arithmetic rather than by reading it. The first box
65
+ * must be one of {@link ISO_BMFF_LEADING_BOX_TYPES}, which is where a
66
+ * non-mp4 file is caught.
67
+ * 3. On `moov`, walk ITS direct children the same way until `mvhd` appears. A
68
+ * `trak` is skipped by size, exactly like `mdat`.
69
+ * 4. Read the first {@link MVHD_MAX_READ_BYTES} bytes of `mvhd` and divide
70
+ * `duration` by `timescale`.
71
+ *
72
+ * Both measured layouts work for the same reason: the walk is driven by the
73
+ * sizes the boxes declare, so it does not care whether `moov` came before or
74
+ * after the media data. Faststart files find it on the first or second hop; a
75
+ * camera/encoder file finds it after one seek over the entire `mdat`.
76
+ *
77
+ * @param filePath - absolute path to the file to read.
78
+ * @returns the clip length in seconds, as an exact ratio.
79
+ * @throws IsoBmffDurationError (a `HarnessError`) whenever the length cannot be
80
+ * established - a missing file, a non-ISO-BMFF file, a truncated box, a
81
+ * missing `moov`/`mvhd`, an unreadable `mvhd`, or a zero timescale.
82
+ */
83
+ export declare function readIsoBmffDurationSeconds(filePath: string): Promise<number>;
84
+ //# sourceMappingURL=iso-bmff-duration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"iso-bmff-duration.d.ts","sourceRoot":"","sources":["../../../../src/host/minimax-code/iso-bmff-duration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAEnD;;;;;GAKG;AACH,qBAAa,oBAAqB,SAAQ,YAAY;gBACxC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;CAI1C;AAyOD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAsB,0BAA0B,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAkFlF"}
@@ -0,0 +1,168 @@
1
+ /**
2
+ * The Matrix media gateway client for the MiniMax Code subscription.
3
+ *
4
+ * The Messages route (`{agentBase}/mavis/api/v1/llm/v1/messages`) carries the
5
+ * chat surface only. Everything else the subscription can do — video generation,
6
+ * video understanding, image and audio tools — lives behind a SECOND prefix on
7
+ * the SAME origin: `{agentBase}/mavis/api/v1/mcp/<tool>`. Nothing in
8
+ * ./client.ts reaches it, and this module is that missing half.
9
+ *
10
+ * Why the endpoint set is what it is (docs/minimax-video-design-spec.md section
11
+ * 3, and the live probe in scripts/probe-minimax-matrix-gateway.probe.ts):
12
+ *
13
+ * - the host is the AGENT host, not the API host. cn is `https://agent.minimax.cn`
14
+ * and global is `https://agent.minimax.io`, both already named by
15
+ * ./types.ts's REGION_HOSTS. `agent.minimaxi.com` is the CHECK-IN surface's
16
+ * host — the upstream tree spells it LEGACY (matrix-env.ts:28) — and pointing
17
+ * a media call at it would miss.
18
+ * - authentication is the subscription bearer and nothing else. The measured
19
+ * request carried exactly accept / authorization / content-type / user-agent
20
+ * and was answered HTTP 200 `base_resp.status_code: 0`. The `yy` /
21
+ * `x-timestamp` / `x-signature` triple belongs to the check-in surface, and
22
+ * `user_id` / `biz_id` / `request_sk` are gated on a non-prod build env and
23
+ * resolve to {} in prod, so none of them is sent here either.
24
+ *
25
+ * TWO FAILURE KINDS, and they are not the same verdict:
26
+ *
27
+ * - a BUSINESS failure is HTTP 200 with `base_resp.status_code !== 0` OR with a
28
+ * non-zero TOP-LEVEL `code`. Both are the service accepting the request,
29
+ * understanding it, and refusing it: retrying the same body asks the same
30
+ * question again and gets the same answer, so it is terminal. Upstream proves
31
+ * the same pair (packages/agent-tools/src/cloud/matrix-tools/client.ts:140-158)
32
+ * and a client that only reads the first one reports a refusal as a success.
33
+ * - a REQUEST failure is a non-2xx status. Which one it is (a refused
34
+ * credential, back-pressure, an overloaded gateway, a malformed body) is
35
+ * decided by {@link classifyMinimaxFailure}, which this line already uses for
36
+ * every other refusal it reports.
37
+ *
38
+ * The classification SHAPE is reused rather than reinvented: `code`,
39
+ * `message`, `retryable`, `accountScoped`. A caller that reads a verdict from
40
+ * the Messages route and a caller that reads one from here must not have to
41
+ * know which surface produced it.
42
+ *
43
+ * @module dsh-chatgpt-subscription/minimax-code/matrix-client
44
+ */
45
+ import { HarnessError } from '@deepseek-ai/dsh-llm';
46
+ import type { MinimaxCodeRegion } from '../../shared/minimax-code-contracts.ts';
47
+ import { type MinimaxFailureClassification } from './adapter.ts';
48
+ /** Prefix every Matrix media tool hangs off. */
49
+ export declare const MATRIX_API_PREFIX = "/mavis/api/v1/mcp";
50
+ /**
51
+ * User agent the gateway was measured to accept.
52
+ *
53
+ * NOT the package's own product token (./types.ts USER_AGENT). A media call is
54
+ * a first-party-client surface rather than an LLM endpoint, and the measured
55
+ * shape sent this literal; the note in ./types.ts about not impersonating the
56
+ * official app is about the TELEMETRY headers (`yy` and friends), which are
57
+ * still never sent.
58
+ */
59
+ export declare const MATRIX_USER_AGENT = "MiniMaxAgent";
60
+ /** Default per-call time budget, matching the upstream media-tool timeout table. */
61
+ export declare const MATRIX_DEFAULT_TIMEOUT_MS = 120000;
62
+ /** Path segment of the video-understanding tool. */
63
+ export declare const MATRIX_TOOL_VIDEOS_UNDERSTAND = "videos_understand";
64
+ /** Path segment of the async video-generation submit tool. */
65
+ export declare const MATRIX_TOOL_SUBMIT_VIDEO = "submit_video_generation";
66
+ /** Path segment of the async video-generation query tool. */
67
+ export declare const MATRIX_TOOL_QUERY_VIDEO = "query_video_generation";
68
+ /** Path segment of the presigned-upload broker. */
69
+ export declare const MATRIX_TOOL_GET_UPLOAD_URL = "get_upload_url";
70
+ type FetchLike = typeof fetch;
71
+ /**
72
+ * The Matrix media route for one region and tool.
73
+ *
74
+ * @param region - subscription region (`cn` or `global`).
75
+ * @param tool - tool path segment, e.g. `videos_understand`.
76
+ * @returns the absolute endpoint URL.
77
+ */
78
+ export declare function matrixToolUrl(region: MinimaxCodeRegion, tool: string): string;
79
+ /**
80
+ * The complete header set of one Matrix request: exactly four entries.
81
+ *
82
+ * Kept as a function of the token alone so a test can assert the absence of the
83
+ * check-in surface's signature headers and the routing headers by name, rather
84
+ * than trusting that nobody added one later.
85
+ *
86
+ * @param accessToken - subscription access token.
87
+ * @returns the four headers, in the measured spelling.
88
+ */
89
+ export declare function matrixRequestHeaders(accessToken: string): Record<string, string>;
90
+ /**
91
+ * One settled Matrix call.
92
+ *
93
+ * `body` is the parsed JSON envelope with `base_resp` still on it, so a caller
94
+ * can read `status_msg` when it needs the service's own wording. Payload fields
95
+ * sit at the TOP level of that envelope on every tool this line has read.
96
+ *
97
+ * The one top-level key that is NOT a payload field is `code`: it is the
98
+ * envelope's second status code, already proven zero by the time a response is
99
+ * returned (see {@link businessStatusOf}).
100
+ */
101
+ export interface MatrixToolResponse {
102
+ /** The tool the call named. */
103
+ readonly tool: string;
104
+ /** HTTP status of the answer. */
105
+ readonly status: number;
106
+ /** Parsed JSON object body. */
107
+ readonly body: Record<string, unknown>;
108
+ }
109
+ /** One Matrix failure, carrying the verdict the rest of the line speaks. */
110
+ export declare class MatrixToolError extends HarnessError {
111
+ /** The reused classification: `code`/`message`/`retryable`/`accountScoped`. */
112
+ readonly classification: MinimaxFailureClassification;
113
+ /** HTTP status when there was one; undefined for a transport failure. */
114
+ readonly status: number | undefined;
115
+ /** The tool the failing call named. */
116
+ readonly tool: string;
117
+ constructor(message: string, code: string, classification: MinimaxFailureClassification, tool: string, status?: number);
118
+ }
119
+ /** Error code for a business refusal (HTTP 200, `base_resp.status_code !== 0`). */
120
+ export declare const MATRIX_BUSINESS_ERROR_CODE = "MINIMAX_MATRIX_BUSINESS_ERROR";
121
+ /** Error code for a non-2xx answer. */
122
+ export declare const MATRIX_HTTP_ERROR_CODE = "MINIMAX_MATRIX_HTTP_ERROR";
123
+ /** Error code for a request that never produced a response. */
124
+ export declare const MATRIX_TRANSPORT_ERROR_CODE = "MINIMAX_MATRIX_TRANSPORT_ERROR";
125
+ /** Error code for a call that outlived its budget. */
126
+ export declare const MATRIX_TIMEOUT_ERROR_CODE = "MINIMAX_MATRIX_TIMEOUT";
127
+ /** Options for {@link callMatrixTool}. */
128
+ export interface CallMatrixToolOptions {
129
+ /** Subscription region; decides which agent host is used. */
130
+ readonly region: MinimaxCodeRegion;
131
+ /** Subscription access token (bearer). */
132
+ readonly accessToken: string;
133
+ /** Tool path segment, e.g. `videos_understand`. */
134
+ readonly tool: string;
135
+ /** JSON request body. */
136
+ readonly body: Record<string, unknown>;
137
+ /** Injected fetch, so tests never touch the network. */
138
+ readonly fetchFn?: FetchLike;
139
+ /** Caller cancellation. */
140
+ readonly signal?: AbortSignal;
141
+ /** Per-call budget; defaults to {@link MATRIX_DEFAULT_TIMEOUT_MS}. */
142
+ readonly timeoutMs?: number;
143
+ }
144
+ /**
145
+ * Call one Matrix media tool and return its parsed envelope.
146
+ *
147
+ * @param options - region, credential, tool, body and the injectable transport.
148
+ * @returns the parsed envelope, with the business status already proven zero.
149
+ * @throws MatrixToolError for a business refusal, a non-2xx answer, a transport
150
+ * failure, or a timeout. Every one carries a reused classification.
151
+ */
152
+ export declare function callMatrixTool(options: CallMatrixToolOptions): Promise<MatrixToolResponse>;
153
+ /**
154
+ * Read one payload field out of an envelope, trying the shapes this gateway
155
+ * has been observed to use.
156
+ *
157
+ * Top level first — that is where every measured tool puts its payload — then
158
+ * `data` and `result` for a tool that nests it. Undefined when none of them
159
+ * carries the key, so the caller refuses rather than reading a missing field as
160
+ * an empty string.
161
+ *
162
+ * @param body - the parsed envelope.
163
+ * @param key - the field name the tool documents.
164
+ * @returns the value, whatever it is, or undefined.
165
+ */
166
+ export declare function matrixPayloadField(body: Record<string, unknown>, key: string): unknown;
167
+ export {};
168
+ //# sourceMappingURL=matrix-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matrix-client.d.ts","sourceRoot":"","sources":["../../../../src/host/minimax-code/matrix-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAA;AAC/E,OAAO,EAA0B,KAAK,4BAA4B,EAAE,MAAM,cAAc,CAAA;AAIxF,gDAAgD;AAChD,eAAO,MAAM,iBAA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AAM,CAAC,EAAE,MAAM;CAQlB;AAED,mFAAmF;AACnF,eAAO,MAAM,0BAA0B,kCAAkC,CAAA;AACzE,uCAAuC;AACvC,eAAO,MAAM,sBAAsB,8BAA8B,CAAA;AACjE,+DAA+D;AAC/D,eAAO,MAAM,2BAA2B,mCAAmC,CAAA;AAC3E,sDAAsD;AACtD,eAAO,MAAM,yBAAyB,2BAA2B,CAAA;AAEjE,0CAA0C;AAC1C,MAAM,WAAW,qBAAqB;IACpC,6DAA6D;IAC7D,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAA;IAClC,0CAA0C;IAC1C,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,mDAAmD;IACnD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,yBAAyB;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACtC,wDAAwD;IACxD,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,CAAA;IAC5B,2BAA2B;IAC3B,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAA;IAC7B,sEAAsE;IACtE,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAC5B;AA8DD;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CA8GhG;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAOtF"}
@@ -0,0 +1,153 @@
1
+ /**
2
+ * Where a generated video is written, and how the path it gets is derived.
3
+ *
4
+ * WHY THE SESSION WORKSPACE AND NOT A PRIVATE DIRECTORY. The sidebar's video
5
+ * preview is a DOCUMENT preview: it renders a file the workspace can address,
6
+ * because that is what the preview registry is keyed on. A clip parked in
7
+ * `$DSH_HOME/storages/...` — which is where the Kimi line's attachment store
8
+ * lives — is invisible to that surface: the tool would report success and the
9
+ * user would have no player to open it in. So the bytes land in the session's
10
+ * own working directory, and this module's whole job is to do that without
11
+ * letting a caller name a path.
12
+ *
13
+ * HOW THE ROOT IS RESOLVED (the answer to "what can a tool actually see here"):
14
+ *
15
+ * 1. `ctx.get('workingDirectory')` then `ensure(agent, signal)` — the same call
16
+ * the harness itself makes. `packages/core/tools/src/index.ts:949-956` uses
17
+ * it to capture `run_code`'s cwd, and `packages/deliverables/tool-present/
18
+ * src/index.ts:82` uses it to resolve the directory `present` addresses.
19
+ * It is the CURRENT directory, which is what a user means by "the
20
+ * workspace" after they change it mid-session.
21
+ * 2. `agent.session.header.cwd` — `packages/core/session/src/types.ts:106`
22
+ * documents it as "Absolute working directory the session was created in".
23
+ * This is the fallback when the working-directory service is not composed
24
+ * (a headless host), and it is a plain field, so reading it cannot fail.
25
+ * 3. Neither: the call FAILS. There is deliberately no third fallback to a
26
+ * plugin-owned directory, because the product contract is that the file is
27
+ * reachable from the workspace; silently writing somewhere else would report
28
+ * a success the user cannot open. The error names both remedies.
29
+ *
30
+ * The host's own workspace-file scope agrees with the same decision:
31
+ * `packages/api/workspace-files/src/index.ts:218` resolves a session's root as
32
+ * `header.cwd ?? scope.sandboxPolicy.workspaceRoot`, i.e. the header first.
33
+ *
34
+ * @module dsh-chatgpt-subscription/minimax-code/media-store
35
+ */
36
+ import { HarnessError } from '@deepseek-ai/dsh-llm';
37
+ /**
38
+ * Largest single generated video this route will write.
39
+ *
40
+ * A 15-second 2K H3 clip is a few tens of megabytes, so 200 MB is not a
41
+ * prediction of the output size — it is the ceiling that stops a runaway
42
+ * download (a wrong URL that streams an ISO, a redirect to something huge) from
43
+ * filling the user's disk. Nothing legitimate comes near it.
44
+ */
45
+ export declare const MAX_GENERATED_VIDEO_BYTES: number;
46
+ /** Directory, under the workspace root, that generated videos land in. */
47
+ export declare const GENERATED_VIDEO_DIR = "minimax-videos";
48
+ /** Raised when a write cannot produce a usable workspace path. */
49
+ export declare class MediaStoreError extends HarnessError {
50
+ constructor(message: string, code: string);
51
+ }
52
+ /** The one place a generated video may be written, and how to name it. */
53
+ export interface MediaStoreTarget {
54
+ /** Absolute workspace root. */
55
+ readonly root: string;
56
+ /** Absolute directory the file is written into. */
57
+ readonly directory: string;
58
+ /**
59
+ * Whether the root came from the working-directory service (true) or from
60
+ * the session header (false). Reported so a caller can tell a live directory
61
+ * from the creation-time one.
62
+ */
63
+ readonly fromWorkingDirectory: boolean;
64
+ }
65
+ /**
66
+ * The least a tool execution must expose for {@link resolveMediaStoreTarget}.
67
+ *
68
+ * Structural rather than the registry's own `ToolRunContext` so a test can
69
+ * hand in a plain object; every field is optional because a tool is also
70
+ * executed by tooling that composes no agent at all.
71
+ */
72
+ export interface MediaStoreExec {
73
+ readonly signal?: AbortSignal;
74
+ readonly agent?: {
75
+ readonly session?: {
76
+ readonly header?: {
77
+ readonly cwd?: string;
78
+ };
79
+ };
80
+ };
81
+ }
82
+ /** The part of the harness `workingDirectory` service this module reads. */
83
+ export interface WorkingDirectoryLookup {
84
+ ensure(agent: unknown, signal?: AbortSignal): Promise<string>;
85
+ }
86
+ /**
87
+ * The session's current working directory, or undefined when nothing can name
88
+ * one.
89
+ *
90
+ * @param ctx - anything with a `get` that returns the harness services.
91
+ * @param exec - the tool execution naming the agent and its cancellation.
92
+ * @returns an absolute directory, or undefined.
93
+ */
94
+ export declare function resolveSessionRoot(ctx: {
95
+ get(name: string): unknown;
96
+ }, exec: MediaStoreExec): Promise<{
97
+ root: string;
98
+ fromWorkingDirectory: boolean;
99
+ } | undefined>;
100
+ /**
101
+ * Resolve where a generated video will be written for one execution.
102
+ *
103
+ * @param ctx - host context, for the working-directory service.
104
+ * @param exec - the tool execution.
105
+ * @returns the resolved target.
106
+ * @throws MediaStoreError when no workspace directory can be named at all.
107
+ */
108
+ export declare function resolveMediaStoreTarget(ctx: {
109
+ get(name: string): unknown;
110
+ }, exec: MediaStoreExec): Promise<MediaStoreTarget>;
111
+ /**
112
+ * A filesystem-safe file name derived from values this module controls.
113
+ *
114
+ * Every part is generated here — a timestamp, the task id the service issued and
115
+ * a fixed extension — and everything outside `[A-Za-z0-9._-]` is replaced, so a
116
+ * task id carrying a separator cannot climb out of the directory. The caller
117
+ * never supplies a path, which is what makes path traversal impossible rather
118
+ * than merely filtered.
119
+ *
120
+ * @param taskId - upstream task id (or an equivalent generated identity).
121
+ * @param extension - leading-dot extension, e.g. `.mp4`.
122
+ * @param now - clock, injected so a test can pin the name.
123
+ * @returns a leaf file name with no directory component.
124
+ */
125
+ export declare function generatedVideoFileName(taskId: string, extension: string, now?: number): string;
126
+ /** A file extension for one media type, defaulting to .mp4. */
127
+ export declare function extensionForMediaType(mediaType: string): string;
128
+ /** Result of one committed write. */
129
+ export interface StoredVideo {
130
+ /** Path relative to the workspace root, always POSIX-separated. */
131
+ readonly relativePath: string;
132
+ /** Absolute path on this machine. */
133
+ readonly absolutePath: string;
134
+ /** Exact byte length written. */
135
+ readonly bytes: number;
136
+ }
137
+ /**
138
+ * Write one generated video into the workspace.
139
+ *
140
+ * @param target - the resolved target from {@link resolveMediaStoreTarget}.
141
+ * @param data - the complete video bytes.
142
+ * @param taskId - upstream task id, used to derive the file name.
143
+ * @param mediaType - media type the response declared, for the extension.
144
+ * @param now - clock, injected for a pinned test name.
145
+ * @returns the workspace-relative path and its absolute counterpart.
146
+ * @throws MediaStoreError for an empty or oversized payload.
147
+ */
148
+ export declare function writeGeneratedVideo(target: MediaStoreTarget, data: Uint8Array, options: {
149
+ taskId: string;
150
+ mediaType: string;
151
+ now?: number;
152
+ }): Promise<StoredVideo>;
153
+ //# sourceMappingURL=media-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"media-store.d.ts","sourceRoot":"","sources":["../../../../src/host/minimax-code/media-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAIH,OAAO,EAAE,YAA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