@tbox.cn/tboxcode-dsh-bundle 0.1.0-rc.15 → 0.1.0-rc.17

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/cordis.patch.yml CHANGED
@@ -1,7 +1,7 @@
1
1
  # tboxcode-bundle 结构行集(四 profile 链恒挂)。
2
2
  # 行组规格见 .agents/designs/implemented/2026-10-01-overview.md「bundle patch 行清单」(行组级)。
3
- # 禁用行组 = repo-bootstrap 落位;llm / tools / subagent 宿主行 / persona-identity /
4
- # 补挂 行组随 llm-stack C4/C5 落位(prompts / remote 行组随 C6 / serve-gateway)。
3
+ # 禁用行组 = repo-bootstrap 落位;llm / tools / subagent 宿主行 / 补挂 行组随
4
+ # llm-stack C4/C5 落位(prompts / remote 行组随 C6 / serve-gateway)。
5
5
  #
6
6
  # 行位规则(overview「行投放分类」真源):自有插件行 → bundle host 行(agent 平面行,
7
7
  # 四链恒挂;explore 面差异靠 subagent toolFilter 不靠行差分);同 id 覆盖行携带 name
@@ -9,7 +9,8 @@
9
9
  #
10
10
  # 禁用行组(同 id 覆盖,disabled 字段替换;未命中目标 warn + skip——acp / headless 链上
11
11
  # tool-web 等行缺席属预期,冗余禁用 = 两形态一致纪律,决策:web-tools-layered-disable):
12
- # plan-mode(guidance 单源 = 权限说明 section——plan-mode-mount-exclusion,两形态统一禁用)
12
+ # plan-mode(host 行统一禁用;官方 web/server standard/ptc/cordis preset 子行仍挂载
13
+ # ——P1 full 接受,见 plan-mode-mount-exclusion Revisions)
13
14
  # DeepSeek 专有行族:deepseek-llm-api-extensions / deepseek-account / session-log-deepseek /
14
15
  # session-telemetry-otel(数据外发)/ web-search-deepseek / web-deepseek-api
15
16
  # (0.2.1 新增 DeepSeek Search/Fetch API 行——专有族同纪律禁用)
@@ -18,10 +19,10 @@
18
19
  # 服务行 id;官方 adapter 占用 deepseek-official 路由锁死 id + catalog 双源 + 凭据三
19
20
  # 故事,禁后 LLM 栈单源 tboxcode-llm、id 释放,决策:llm-deepseek-rows-disable)
20
21
  # + 专有服务的消费者行:plugin-package-inventory-deepseek(官方请求附 dsh_plugin_packages
21
- # 插件包清单遥测,注入通道 deepseekLlmApiExtensions 已禁)/ account-controller(账号页
22
- # RPC,依赖 deepseekAccount 已禁;行住 web-app 层——acp/headless 链无此行 skip 属预期,
23
- # tool-web 同形态)——服务方禁用后消费者永久 pending,一并收编消启动告警(决策:
24
- # pending-consumer-rows-disable)
22
+ # 插件包清单遥测,注入通道 deepseekLlmApiExtensions 已禁)——服务方禁用后消费者永久
23
+ # pending,一并收编消启动告警(决策:pending-consumer-rows-disable)。
24
+ # 注:account-controller 消费者行上游 0.2.2-rc.3 已整体移除(账号面改 ui-settings-account /
25
+ # ui-account-notifications 客户端行,不注入 deepseekAccount),对应禁用行随之删除。
25
26
  # tool-web 整行(tboxcode 层唯一 web 工具 = 本仓 webfetch 移植版,双工具与提示词段落随行消失
26
27
  # ——宿主层面;preset 会话经官方树内 tool-web 行不受此禁影响,default 组合后果见
27
28
  # preset-mode-decoupling)
@@ -38,8 +39,7 @@
38
39
  # 注:agent-instructions 不在禁用组(原生采纳——agent-instructions-native-adoption;web/server
39
40
  # 链由 presets 树重建行接管,acp/headless 走 base 挂载行)。
40
41
  # 注:persona 无禁用行——persona 无 host 行(base / web-app 均无),只活 preset 树内;
41
- # identity 单点化 = 双树删行 + system-prompt 覆盖行(上方),dsh 内建 preset 树的
42
- # persona 行属 dsh 内建面不动(reminders-plugin-dissolution 实施校准)。
42
+ # 默认身份 = DSH app bundle 部署 persona;本 bundle 不覆盖 system-prompt。
43
43
  - id: plan-mode
44
44
  disabled: true
45
45
  - id: deepseek-llm-api-extensions
@@ -52,8 +52,6 @@
52
52
  disabled: true
53
53
  - id: plugin-package-inventory-deepseek
54
54
  disabled: true
55
- - id: account-controller
56
- disabled: true
57
55
  - id: session-log-deepseek
58
56
  disabled: true
59
57
  - id: session-telemetry-otel
@@ -73,7 +71,7 @@
73
71
  disabled: false
74
72
 
75
73
  # ── 新增行组(insert 语义——裸行 = 覆盖语义会 not found,新增行必须包 insert 块;
76
- # persona-identity 与 skill-filesystem 是覆盖行保持裸行)──
74
+ # skill-filesystem 是覆盖行保持裸行)──
77
75
  - insert:
78
76
  # ── llm 行组(host 服务行;零 config——插件零 Config 导出纪律,C2)──
79
77
  - id: tboxcode-llm
@@ -99,11 +97,16 @@
99
97
  - id: tboxcode-auto-commit
100
98
  name: '@tbox.cn/tboxcode-dsh-tools/auto-commit'
101
99
 
102
- # ── prompts 行组(C6:七 section + 三 context + 重排器 + complete 整接管;
103
- # systemPrompt / rules 翻译域经行 config 注入)──
100
+ # ── prompts 行组(native-prompt-reset:只保留 permission + scratch 两条
101
+ # 产品 context;七 section / complete / 重排器已退役)──
104
102
  - id: tboxcode-prompts
105
103
  name: '@tbox.cn/tboxcode-dsh-bundle/prompts'
106
104
 
105
+ # ── identity 行组(自读 config.jsonc 的 identity 域;agent-scoped 覆盖
106
+ # preset/deployment persona;默认不配置即 no-op)──
107
+ - id: tboxcode-identity
108
+ name: '@tbox.cn/tboxcode-dsh-bundle/identity'
109
+
107
110
  # ── 收敛环(C8:config 结构级热载——watcher 触发翻译比对、session/event
108
111
  # open-turn 门、profileContext.overlays 原位更新 + reconcile;零 config——
109
112
  # configDir 走 env 探测点)──
@@ -111,16 +114,9 @@
111
114
  name: '@tbox.cn/tboxcode-dsh-bundle/convergence'
112
115
  - id: tboxcode-remote
113
116
  name: '@tbox.cn/tboxcode-dsh-bundle/remote'
114
-
115
- # ── persona-identity 单点化(同 id 覆盖 dsh-base system-prompt 服务行;
116
- # decisions:reminders-plugin-dissolution——品牌串纯静态零插值,{{model}} 退出 prompt
117
- # 改由 tboxcode:model context 承载〔C6〕;includeHarnessIdentity 关闭 harness 身份段;
118
- # personaSuffix 键不出现 → schema 默认空串生效)──
119
- - id: system-prompt
120
- name: '@deepseek-ai/dsh-system-prompt'
121
- config:
122
- personaPrefix: You are a coding agent, running inside tboxcode.
123
- includeHarnessIdentity: false
117
+ # ── 图片 URL 来源(抓取 → 归一化 → 出处记录;自读 image_url 域,零 config)──
118
+ - id: tboxcode-image-source
119
+ name: '@tbox.cn/tboxcode-dsh-bundle/image-source'
124
120
 
125
121
  # ── 补挂行组:host skill-filesystem 启用行(server 形态生态融合义务——web 基座
126
122
  # host 层禁用〔provider 注册进 preset 层〕,本行重开 global 层挂载;skill-filesystem
@@ -1,2 +1,2 @@
1
- import { a as createConvergenceCore, i as ConvergenceState, n as ConvergenceIO, o as rowsEqual, r as ConvergenceRow, t as ConvergenceCore } from "./convergence-core-C1ZtU17g.js";
1
+ import { a as createConvergenceCore, i as ConvergenceState, n as ConvergenceIO, o as rowsEqual, r as ConvergenceRow, t as ConvergenceCore } from "./convergence-core-B81Z55Bq.js";
2
2
  export { ConvergenceCore, ConvergenceIO, ConvergenceRow, ConvergenceState, createConvergenceCore, rowsEqual };
@@ -1,2 +1,2 @@
1
- import { n as inject, r as name, t as apply } from "./convergence-CvqBcQv2.js";
1
+ import { n as inject, r as name, t as apply } from "./convergence-Bb__S8RE.js";
2
2
  export { apply, inject, name };
@@ -0,0 +1,9 @@
1
+ import { Context } from "@deepseek-ai/cordis";
2
+
3
+ //#region src/identity.d.ts
4
+
5
+ declare const name = "tboxcode-identity";
6
+ declare const inject: never[];
7
+ declare function apply(ctx: Context): void;
8
+ //#endregion
9
+ export { apply, inject, name };
@@ -0,0 +1,113 @@
1
+ import { loadConfig, resolveConfigDir } from "@tbox.cn/tboxcode-dsh-runtime";
2
+
3
+ //#region src/identity.ts
4
+ const name = "tboxcode-identity";
5
+ const inject = [];
6
+ const PERSONA_SECTION = "deployment:persona-prefix";
7
+ const HARNESS_SECTION = "harness:identity";
8
+ const MAX_PERSONA_CHARS = 16384;
9
+ function loggerOf(ctx) {
10
+ const logger = ctx.logger;
11
+ if (logger !== void 0) return logger;
12
+ return { warn: (message, ...args) => console.warn(message, ...args) };
13
+ }
14
+ function parseIdentity(raw, warn) {
15
+ if (typeof raw !== "object" || raw === null || Array.isArray(raw)) {
16
+ warn("[tboxcode-identity] config.identity 必须是对象;已忽略");
17
+ return;
18
+ }
19
+ const obj = raw;
20
+ const unknownKeys = Object.keys(obj).filter((k) => k !== "persona" && k !== "suppress_harness" && k !== "interpolate");
21
+ if (unknownKeys.length > 0) warn(`[tboxcode-identity] config.identity 未知键被忽略:${unknownKeys.join(", ")}`);
22
+ const rawPersona = obj["persona"];
23
+ if (rawPersona !== void 0 && typeof rawPersona !== "string") {
24
+ warn("[tboxcode-identity] config.identity.persona 必须是字符串;已忽略");
25
+ return;
26
+ }
27
+ if (typeof rawPersona === "string" && rawPersona.length > MAX_PERSONA_CHARS) {
28
+ warn(`[tboxcode-identity] config.identity.persona 超过 ${MAX_PERSONA_CHARS} 字符;已忽略`);
29
+ return;
30
+ }
31
+ const rawSuppress = obj["suppress_harness"];
32
+ if (rawSuppress !== void 0 && typeof rawSuppress !== "boolean") {
33
+ warn("[tboxcode-identity] config.identity.suppress_harness 必须是布尔值;已忽略");
34
+ return;
35
+ }
36
+ const rawInterpolate = obj["interpolate"];
37
+ if (rawInterpolate !== void 0 && typeof rawInterpolate !== "boolean") {
38
+ warn("[tboxcode-identity] config.identity.interpolate 必须是布尔值;已忽略");
39
+ return;
40
+ }
41
+ return {
42
+ persona: typeof rawPersona === "string" ? rawPersona : void 0,
43
+ suppressHarness: rawSuppress === true,
44
+ interpolate: rawInterpolate === true
45
+ };
46
+ }
47
+ function readIdentity(warn) {
48
+ let config;
49
+ try {
50
+ config = loadConfig(resolveConfigDir()).config;
51
+ } catch (error) {
52
+ warn(`[tboxcode-identity] config.jsonc 读取失败;身份覆盖已忽略:${error instanceof Error ? error.message : String(error)}`);
53
+ return;
54
+ }
55
+ const raw = config["identity"];
56
+ if (raw === void 0) return void 0;
57
+ return parseIdentity(raw, warn);
58
+ }
59
+ function isSubagent(agent) {
60
+ const header = agent.session?.header;
61
+ return header?.origin === "subagent" || header?.parentSession !== void 0;
62
+ }
63
+ function apply(ctx) {
64
+ const logger = loggerOf(ctx);
65
+ let warned = false;
66
+ const warnOnce = (message) => {
67
+ if (warned) return;
68
+ warned = true;
69
+ logger.warn(message);
70
+ };
71
+ const onAgentCreated = ({ agent }) => {
72
+ if (isSubagent(agent)) return;
73
+ const identity = readIdentity(warnOnce);
74
+ if (identity === void 0) return;
75
+ const hasPersona = identity.persona !== void 0 && identity.persona.length > 0;
76
+ if (!hasPersona && !identity.suppressHarness) return;
77
+ const agentCtx = agent.ctx;
78
+ const sp = agentCtx?.get?.("systemPrompt");
79
+ if (sp === void 0 || agentCtx?.effect === void 0) return;
80
+ try {
81
+ agentCtx.effect(() => {
82
+ const disposers = [];
83
+ const cleanup = () => {
84
+ for (const dispose of disposers.reverse()) dispose();
85
+ };
86
+ try {
87
+ if (hasPersona) disposers.push(sp.section({
88
+ name: PERSONA_SECTION,
89
+ order: sp.getSectionOrder("DEPLOYMENT_PERSONA_PREFIX"),
90
+ text: identity.persona,
91
+ ...identity.interpolate ? {} : { interpolate: false }
92
+ }));
93
+ if (identity.suppressHarness) disposers.push(sp.section({
94
+ name: HARNESS_SECTION,
95
+ order: sp.getSectionOrder("HARNESS_IDENTITY"),
96
+ text: "",
97
+ interpolate: false
98
+ }));
99
+ return cleanup;
100
+ } catch (error) {
101
+ cleanup();
102
+ throw error;
103
+ }
104
+ }, "tboxcode-identity.sections");
105
+ } catch (error) {
106
+ warnOnce(`[tboxcode-identity] 身份注册失败:${error instanceof Error ? error.message : String(error)}`);
107
+ }
108
+ };
109
+ ctx.on?.call(ctx, "agent/created", onAgentCreated);
110
+ }
111
+
112
+ //#endregion
113
+ export { apply, inject, name };
@@ -0,0 +1,156 @@
1
+ //#region src/image-fetch.ts
2
+ const DEFAULT_IMAGE_FETCH_POLICY = {
3
+ maxBytes: 50 * 1024 * 1024,
4
+ timeoutMs: 3e4,
5
+ deadlineMs: 5e4,
6
+ maxRedirects: 3,
7
+ maxUrlLength: 8192
8
+ };
9
+ /** 声明类型的预筛白名单:这些"非 image/*"不算强否证(CDN 常态)。 */
10
+ const GENERIC_DECLARED = new Set([
11
+ "application/octet-stream",
12
+ "binary/octet-stream",
13
+ "text/plain",
14
+ ""
15
+ ]);
16
+ /**
17
+ * 按文件头判定图片类型。
18
+ * @param bytes - 响应字节(至少前 12 字节)。
19
+ * @returns 命中四种受支持格式时给出媒体类型,否则 undefined。
20
+ */
21
+ function sniffImageMediaType(bytes) {
22
+ const head = bytes.subarray(0, 12);
23
+ if (head.length >= 8 && head[0] === 137 && head[1] === 80 && head[2] === 78 && head[3] === 71 && head[4] === 13 && head[5] === 10 && head[6] === 26 && head[7] === 10) return "image/png";
24
+ if (head.length >= 3 && head[0] === 255 && head[1] === 216 && head[2] === 255) return "image/jpeg";
25
+ if (head.length >= 6 && head[0] === 71 && head[1] === 73 && head[2] === 70 && head[3] === 56) return "image/gif";
26
+ if (head.length >= 12 && head[0] === 82 && head[1] === 73 && head[2] === 70 && head[3] === 70 && head[8] === 87 && head[9] === 69 && head[10] === 66 && head[11] === 80) return "image/webp";
27
+ }
28
+ function isTimeout(error) {
29
+ return error instanceof Error && (error.name === "TimeoutError" || error.name === "AbortError");
30
+ }
31
+ /** URL 的最小合法性检查(绝对 http(s)、无凭据、长度受限)。 */
32
+ function isValidImageUrl(value, maxUrlLength) {
33
+ if (value.length === 0 || value.length > maxUrlLength) return false;
34
+ let parsed;
35
+ try {
36
+ parsed = new URL(value);
37
+ } catch {
38
+ return false;
39
+ }
40
+ if (parsed.protocol !== "http:" && parsed.protocol !== "https:") return false;
41
+ return parsed.username === "" && parsed.password === "";
42
+ }
43
+ /**
44
+ * 抓取一张图片。
45
+ * @param url - 绝对 http(s) URL。
46
+ * @param policy - 抓取策略。
47
+ * @param deps - 注入的 fetch(测试可给桩)与外部取消信号。
48
+ * @returns 成功给出字节与媒体类型;失败给出稳定 reason(调用方映射错误文案)。
49
+ */
50
+ async function fetchImage(url, policy, deps) {
51
+ if (!isValidImageUrl(url, policy.maxUrlLength)) return {
52
+ ok: false,
53
+ reason: "url-invalid"
54
+ };
55
+ const deadline = AbortSignal.timeout(policy.deadlineMs);
56
+ const outer = deps.signal === void 0 ? deadline : AbortSignal.any([deps.signal, deadline]);
57
+ let current = url;
58
+ for (let redirects = 0; redirects <= policy.maxRedirects; redirects += 1) {
59
+ let response;
60
+ try {
61
+ response = await deps.fetch(current, {
62
+ redirect: "manual",
63
+ signal: AbortSignal.any([outer, AbortSignal.timeout(policy.timeoutMs)]),
64
+ headers: { accept: "image/*,*/*;q=0.5" }
65
+ });
66
+ } catch (error) {
67
+ return {
68
+ ok: false,
69
+ reason: isTimeout(error) ? "timeout" : "unreachable"
70
+ };
71
+ }
72
+ if (response.status >= 300 && response.status < 400) {
73
+ const location = response.headers.get("location");
74
+ if (location === null) return {
75
+ ok: false,
76
+ reason: "url-invalid"
77
+ };
78
+ let next;
79
+ try {
80
+ next = new URL(location, current);
81
+ } catch {
82
+ return {
83
+ ok: false,
84
+ reason: "url-invalid"
85
+ };
86
+ }
87
+ if (!isValidImageUrl(next.toString(), policy.maxUrlLength)) return {
88
+ ok: false,
89
+ reason: "url-invalid"
90
+ };
91
+ current = next.toString();
92
+ continue;
93
+ }
94
+ if (!response.ok) return {
95
+ ok: false,
96
+ reason: "unreachable"
97
+ };
98
+ const declared = (response.headers.get("content-type") ?? "").split(";")[0].trim().toLowerCase();
99
+ if (!declared.startsWith("image/") && !GENERIC_DECLARED.has(declared)) return {
100
+ ok: false,
101
+ reason: "not-an-image"
102
+ };
103
+ if (response.body === null) return {
104
+ ok: false,
105
+ reason: "not-an-image"
106
+ };
107
+ const reader = response.body.getReader();
108
+ const chunks = [];
109
+ let total = 0;
110
+ try {
111
+ while (true) {
112
+ const { done, value } = await reader.read();
113
+ if (done) break;
114
+ total += value.byteLength;
115
+ if (total > policy.maxBytes) {
116
+ await reader.cancel().catch(() => void 0);
117
+ return {
118
+ ok: false,
119
+ reason: "too-large"
120
+ };
121
+ }
122
+ chunks.push(value);
123
+ }
124
+ } catch (error) {
125
+ return {
126
+ ok: false,
127
+ reason: isTimeout(error) ? "timeout" : "unreachable"
128
+ };
129
+ }
130
+ const bytes = new Uint8Array(total);
131
+ let offset = 0;
132
+ for (const chunk of chunks) {
133
+ bytes.set(chunk, offset);
134
+ offset += chunk.byteLength;
135
+ }
136
+ const mediaType = sniffImageMediaType(bytes);
137
+ if (mediaType === void 0) return {
138
+ ok: false,
139
+ reason: "not-an-image"
140
+ };
141
+ return {
142
+ ok: true,
143
+ image: {
144
+ mediaType,
145
+ data: Buffer.from(bytes).toString("base64")
146
+ }
147
+ };
148
+ }
149
+ return {
150
+ ok: false,
151
+ reason: "url-invalid"
152
+ };
153
+ }
154
+
155
+ //#endregion
156
+ export { sniffImageMediaType as i, fetchImage as n, isValidImageUrl as r, DEFAULT_IMAGE_FETCH_POLICY as t };
@@ -0,0 +1,54 @@
1
+ //#region src/image-fetch.d.ts
2
+ /**
3
+ * image-fetch —— 图片 URL 抓取策略(纯策略 + 注入 fetch,单测可离线驱动)。
4
+ *
5
+ * 安全姿态是**最小防护 + 沙箱边界**:只允许 http(s)、拒绝 userinfo、逐跳重校验
6
+ * 重定向、单请求超时与整批截止、流式字节上限;不做 DNS/IP 黑名单(dsh 与 box
7
+ * 同容器,网络边界由部署承担——决策见 note 的 Risks)。
8
+ *
9
+ * 媒体类型以 **magic 为唯一权威**:真实 CDN 常返回 application/octet-stream 或
10
+ * 错误声明,声明只用于预筛(明显不是图片的强类型早拒,省流量)与诊断。
11
+ */
12
+ /** 抓取策略(全部可被插件自读域覆盖,字节上限只允许调低)。 */
13
+ interface ImageFetchPolicy {
14
+ readonly maxBytes: number;
15
+ readonly timeoutMs: number;
16
+ readonly deadlineMs: number;
17
+ readonly maxRedirects: number;
18
+ readonly maxUrlLength: number;
19
+ }
20
+ declare const DEFAULT_IMAGE_FETCH_POLICY: ImageFetchPolicy;
21
+ type ImageFetchFailureReason = 'url-invalid' | 'unreachable' | 'timeout' | 'too-large' | 'not-an-image';
22
+ interface FetchedImage {
23
+ readonly mediaType: string;
24
+ /** 规范 base64(标准字母表、带填充)。 */
25
+ readonly data: string;
26
+ }
27
+ type ImageFetchResult = {
28
+ readonly ok: true;
29
+ readonly image: FetchedImage;
30
+ } | {
31
+ readonly ok: false;
32
+ readonly reason: ImageFetchFailureReason;
33
+ };
34
+ /**
35
+ * 按文件头判定图片类型。
36
+ * @param bytes - 响应字节(至少前 12 字节)。
37
+ * @returns 命中四种受支持格式时给出媒体类型,否则 undefined。
38
+ */
39
+ declare function sniffImageMediaType(bytes: Uint8Array): string | undefined;
40
+ /** URL 的最小合法性检查(绝对 http(s)、无凭据、长度受限)。 */
41
+ declare function isValidImageUrl(value: string, maxUrlLength: number): boolean;
42
+ /**
43
+ * 抓取一张图片。
44
+ * @param url - 绝对 http(s) URL。
45
+ * @param policy - 抓取策略。
46
+ * @param deps - 注入的 fetch(测试可给桩)与外部取消信号。
47
+ * @returns 成功给出字节与媒体类型;失败给出稳定 reason(调用方映射错误文案)。
48
+ */
49
+ declare function fetchImage(url: string, policy: ImageFetchPolicy, deps: {
50
+ readonly fetch: typeof fetch;
51
+ readonly signal?: AbortSignal;
52
+ }): Promise<ImageFetchResult>;
53
+ //#endregion
54
+ export { DEFAULT_IMAGE_FETCH_POLICY, FetchedImage, ImageFetchFailureReason, ImageFetchPolicy, ImageFetchResult, fetchImage, isValidImageUrl, sniffImageMediaType };
@@ -0,0 +1,3 @@
1
+ import { i as sniffImageMediaType, n as fetchImage, r as isValidImageUrl, t as DEFAULT_IMAGE_FETCH_POLICY } from "./image-fetch-D_8nywZV.js";
2
+
3
+ export { DEFAULT_IMAGE_FETCH_POLICY, fetchImage, isValidImageUrl, sniffImageMediaType };
@@ -0,0 +1,62 @@
1
+ import { Context, Service } from "@deepseek-ai/cordis";
2
+ import { Session } from "@deepseek-ai/dsh-session";
3
+
4
+ //#region src/image-source.d.ts
5
+ declare const name = "@tbox.cn/tboxcode-dsh-bundle/image-source";
6
+ declare const inject: string[];
7
+ /** 一张已准入的 URL 图片来源(端口面:两载体同形)。 */
8
+ interface ImageSourceAdmission {
9
+ readonly attachment: unknown;
10
+ readonly attachmentId: string;
11
+ readonly name?: string;
12
+ }
13
+ /** 附件服务最小读面(不硬依赖 dsh-attachment 类型——服务缺席即降级)。 */
14
+ interface AttachmentFace {
15
+ readonly imageLimits?: {
16
+ readonly maxImageBytes?: number;
17
+ readonly maxMessageImageBytes?: number;
18
+ };
19
+ admitPromptContent(parts: readonly unknown[]): Promise<readonly unknown[]>;
20
+ readImage?(ref: never, signal?: AbortSignal): Promise<{
21
+ readonly ref: {
22
+ readonly mediaType: string;
23
+ };
24
+ readonly data: Uint8Array;
25
+ }>;
26
+ }
27
+ /**
28
+ * 展示名裁决:客户端原始文件名优先(前端传 `fileName`),缺失/空白/超长时
29
+ * 回退 URL 末段。名称只作展示,永不参与路径解释。
30
+ */
31
+ declare function displayNameFor(url: string, provided: string | undefined): string | undefined;
32
+ declare class TboxcodeImageSource extends Service {
33
+ constructor(ctx: Context);
34
+ /** 自读域重新装载(构造 + watcher 回调;非法值告警后回落默认)。 */
35
+ syncConfig(): void;
36
+ /** 记录真实 Session 实例(注册到 session/created 与 agent/created 两路)。 */
37
+ remember(session: Session): void;
38
+ /** 附件服务读面(可选服务——缺席即降级)。 */
39
+ attachmentsFace(): AttachmentFace | undefined;
40
+ /** 字节上限恒等于附件准入上限(只可调低——"上传能过则 URL 也能过")。 */
41
+ maxImageBytes(): number;
42
+ /**
43
+ * 准入一组图片 URL(等长同序返回;内部按 URL 去重抓取与落盘)。
44
+ * @param request - 会话 id、URL 列表与取消信号。
45
+ */
46
+ admitUrls(request: {
47
+ sessionId: string;
48
+ urls: readonly string[];
49
+ /** 与 `urls` 等长同序的客户端文件名(前端原始 fileName)。 */
50
+ names?: readonly (string | undefined)[];
51
+ signal?: AbortSignal;
52
+ }): Promise<ImageSourceAdmission[]>;
53
+ /** 读一张已落盘图片(历史回显);失败返回 undefined(调用方降级占位)。 */
54
+ readImage(attachment: unknown, signal?: AbortSignal): Promise<{
55
+ mediaType: string;
56
+ data: string;
57
+ } | undefined>;
58
+ }
59
+ /** 插件入口:服务缺席才注册(重复挂载零副作用)。 */
60
+ declare function apply(ctx: Context): void;
61
+ //#endregion
62
+ export { ImageSourceAdmission, TboxcodeImageSource, apply, displayNameFor, inject, name };