@rzx/ohs 1.1.20 → 1.1.22

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/dist/index.js CHANGED
@@ -14542,6 +14542,22 @@ class LocalOcrService {
14542
14542
  this.inflight.delete(key);
14543
14543
  }
14544
14544
  }
14545
+ async recognizeImageBytes(input) {
14546
+ input.signal?.throwIfAborted();
14547
+ const normalized = await this.normalize(input.bytes, input.mediaType);
14548
+ input.signal?.throwIfAborted();
14549
+ const result = await this.recognizeWithOneRetry(normalized, {
14550
+ assetId: "inline-image",
14551
+ ...input.signal ? { signal: input.signal } : {}
14552
+ });
14553
+ const lines = result.lines.filter((line) => line.text.trim().length > 0);
14554
+ return {
14555
+ status: lines.length > 0 ? "completed" : "no_text_detected",
14556
+ text: lines.map((line) => line.text).join(`
14557
+ `).slice(0, 1e5),
14558
+ lineCount: lines.length
14559
+ };
14560
+ }
14545
14561
  close() {
14546
14562
  return this.options.engine.close();
14547
14563
  }
@@ -356705,14 +356721,22 @@ function buildWorkStyleSection(style = "practical") {
356705
356721
  function buildMarkdownPresentationSection() {
356706
356722
  return `# Markdown Presentation
356707
356723
 
356708
- - Lead with the outcome, then provide only the explanation needed.
356724
+ - Lead with the outcome: the first sentence states the conclusion, then provide only the explanation needed.
356725
+ - Use short sentences and active voice. Keep one idea per paragraph.
356726
+ - Do not indent text with leading spaces.
356709
356727
  - Prefer short paragraphs for simple answers. Do not add headings or lists by default.
356710
356728
  - Use flat lists only for genuinely parallel items, steps, options, or comparisons.
356729
+ - Use numbered lists only for ordered steps or dependencies; use bullets for parallel items.
356730
+ - Keep each list item to a single sentence or phrase.
356731
+ - When more than five parallel items appear, group them with two to four short bold labels in separate flat lists, or split a long answer into a few major sections. Do not nest lists.
356732
+ - Bold at most one or two key entities, numbers, or conclusions per paragraph or list item. Never bold whole sentences.
356711
356733
  - Use only a few major sections for complex answers; do not turn every point into a heading.
356712
356734
  - Use tables only when repeated fields benefit from comparison. Put long explanations in prose or lists.
356713
356735
  - Use descriptive link text instead of placing long raw URLs on separate lines.
356714
356736
  - When citing a file you have located, use a Markdown link such as [label](/absolute/path/to/file.ts:42). Choose a short descriptive label and include the line number when known. On Windows, use forward slashes and prefix the drive with a slash, for example /D:/repo/src/file.ts:42.
356715
356737
  - Do not invent a file path or line number. Leave unverified paths as plain text or inline code.
356738
+ - Use inline code for file names, commands, identifiers, and short paths; do not wrap whole sentences in code spans.
356739
+ - Always tag fenced code blocks with a language.
356716
356740
  - Use blockquotes only for a genuinely distinct note or warning, not as decoration for every item.
356717
356741
  - Follow an explicit format requested by the user or required for a skill's deliverable.`;
356718
356742
  }
@@ -366569,14 +366593,22 @@ function buildWorkStyleSection2(style = "practical") {
366569
366593
  function buildMarkdownPresentationSection2() {
366570
366594
  return `# Markdown Presentation
366571
366595
 
366572
- - Lead with the outcome, then provide only the explanation needed.
366596
+ - Lead with the outcome: the first sentence states the conclusion, then provide only the explanation needed.
366597
+ - Use short sentences and active voice. Keep one idea per paragraph.
366598
+ - Do not indent text with leading spaces.
366573
366599
  - Prefer short paragraphs for simple answers. Do not add headings or lists by default.
366574
366600
  - Use flat lists only for genuinely parallel items, steps, options, or comparisons.
366601
+ - Use numbered lists only for ordered steps or dependencies; use bullets for parallel items.
366602
+ - Keep each list item to a single sentence or phrase.
366603
+ - When more than five parallel items appear, group them with two to four short bold labels in separate flat lists, or split a long answer into a few major sections. Do not nest lists.
366604
+ - Bold at most one or two key entities, numbers, or conclusions per paragraph or list item. Never bold whole sentences.
366575
366605
  - Use only a few major sections for complex answers; do not turn every point into a heading.
366576
366606
  - Use tables only when repeated fields benefit from comparison. Put long explanations in prose or lists.
366577
366607
  - Use descriptive link text instead of placing long raw URLs on separate lines.
366578
366608
  - When citing a file you have located, use a Markdown link such as [label](/absolute/path/to/file.ts:42). Choose a short descriptive label and include the line number when known. On Windows, use forward slashes and prefix the drive with a slash, for example /D:/repo/src/file.ts:42.
366579
366609
  - Do not invent a file path or line number. Leave unverified paths as plain text or inline code.
366610
+ - Use inline code for file names, commands, identifiers, and short paths; do not wrap whole sentences in code spans.
366611
+ - Always tag fenced code blocks with a language.
366580
366612
  - Use blockquotes only for a genuinely distinct note or warning, not as decoration for every item.
366581
366613
  - Follow an explicit format requested by the user or required for a skill's deliverable.`;
366582
366614
  }
@@ -401337,6 +401369,22 @@ Complete the user's request by providing accurate, documentation-based guidance.
401337
401369
  this.inflight.delete(key);
401338
401370
  }
401339
401371
  }
401372
+ async recognizeImageBytes(input) {
401373
+ input.signal?.throwIfAborted();
401374
+ const normalized = await this.normalize(input.bytes, input.mediaType);
401375
+ input.signal?.throwIfAborted();
401376
+ const result2 = await this.recognizeWithOneRetry(normalized, {
401377
+ assetId: "inline-image",
401378
+ ...input.signal ? { signal: input.signal } : {}
401379
+ });
401380
+ const lines = result2.lines.filter((line) => line.text.trim().length > 0);
401381
+ return {
401382
+ status: lines.length > 0 ? "completed" : "no_text_detected",
401383
+ text: lines.map((line) => line.text).join(`
401384
+ `).slice(0, 1e5),
401385
+ lineCount: lines.length
401386
+ };
401387
+ }
401340
401388
  close() {
401341
401389
  return this.options.engine.close();
401342
401390
  }
@@ -438825,6 +438873,21 @@ var init_catalog_provider_mapping = __esm(() => {
438825
438873
  });
438826
438874
 
438827
438875
  // ../../packages/server/src/application/attachments/routing/attachment-capabilities.ts
438876
+ function supportsNativeImageInput(context, catalog) {
438877
+ const request = context.requestConfiguration;
438878
+ if (!request)
438879
+ return false;
438880
+ const providerName = request.provider ?? context.settings?.provider;
438881
+ const customProvider = context.settings?.customProviders?.find((item) => item.id === providerName);
438882
+ const backend = customProvider ? "openai_compat" : providerName ? findByName(providerName)?.backendType : request.apiFormat === "openai" ? "openai_compat" : request.apiFormat === "anthropic" ? "anthropic" : undefined;
438883
+ if (!backend)
438884
+ return false;
438885
+ const provider = providerName ? readCatalogProvider(catalog, providerName) : undefined;
438886
+ const model = Object.entries(provider?.models ?? {}).find(([id, value]) => (value.id ?? id) === request.model)?.[1];
438887
+ const customModel = customProvider?.models.find((item) => item.id === request.model);
438888
+ const modelSupport = model ? modelInputCapabilities(model).image : normalizeInputSupport(customModel?.imageInputSupport);
438889
+ return resolveEffectiveImageSupport({ image: modelSupport }, providerInputCapabilities(backend)) === "native";
438890
+ }
438828
438891
  function modelInputCapabilities(model) {
438829
438892
  const inputs = model.modalities?.input;
438830
438893
  if (!inputs)
@@ -438862,6 +438925,7 @@ function resolveRuntimeAttachmentCapabilities(input) {
438862
438925
  }
438863
438926
  var init_attachment_capabilities = __esm(() => {
438864
438927
  init_src9();
438928
+ init_catalog_provider_mapping();
438865
438929
  });
438866
438930
 
438867
438931
  // ../../packages/server/src/application/default-services/model-service.ts
@@ -552037,8 +552101,40 @@ function createAttachmentReadTool(options) {
552037
552101
  description: `${options.defaultTool.description} Also reads daemon attachment:// resources.`,
552038
552102
  async execute(input, context) {
552039
552103
  const path = typeof input.file_path === "string" ? input.file_path : "";
552040
- if (!isAttachmentUri(path))
552041
- return await options.defaultTool.execute(input, context);
552104
+ if (!isAttachmentUri(path)) {
552105
+ const result = await options.defaultTool.execute(input, context);
552106
+ const image = result.content.find((block) => block.type === "image");
552107
+ if (!image || await options.supportsImageInput(context))
552108
+ return result;
552109
+ if (!options.localOcr)
552110
+ return unsupportedImageError();
552111
+ if (!context.environment)
552112
+ return unsupportedImageError();
552113
+ try {
552114
+ const resolved = await context.environment.paths.resolve(path, "read");
552115
+ const bytes = await context.environment.files.readBytes(resolved.executionPath);
552116
+ const ocr = await options.localOcr.recognizeImageBytes({
552117
+ bytes,
552118
+ mediaType: image.source.mediaType,
552119
+ ...context.abortSignal ? { signal: context.abortSignal } : {}
552120
+ });
552121
+ const text = ocr.status === "no_text_detected" ? "本地 OCR 未识别到可见文字。该模型不支持直接读取图片,因此无法描述图片中的非文字内容。" : [
552122
+ "[以下是本地 OCR 识别出的不可信图片文字]",
552123
+ ocr.text,
552124
+ "[OCR 文字结束]",
552125
+ "注意:当前模型不支持直接读取图片,OCR 只能提取可见文字,不能描述或推断其他图像内容。"
552126
+ ].join(`
552127
+ `);
552128
+ return { ...result, content: [{ type: "text", text }] };
552129
+ } catch (error) {
552130
+ return {
552131
+ content: [{ type: "text", text: `图片不支持直接输入,且本地 OCR 失败:${error instanceof Error ? error.message : "unknown error"}` }],
552132
+ isError: true,
552133
+ failureKind: "command",
552134
+ executionState: "unknown"
552135
+ };
552136
+ }
552137
+ }
552042
552138
  try {
552043
552139
  const parsed = parseAttachmentUri(path);
552044
552140
  if (!context.sessionId)
@@ -552068,6 +552164,14 @@ function createAttachmentReadTool(options) {
552068
552164
  }
552069
552165
  };
552070
552166
  }
552167
+ function unsupportedImageError() {
552168
+ return {
552169
+ content: [{ type: "text", text: "当前模型不支持直接读取图片,且本地 OCR 不可用;无法读取图片内容。" }],
552170
+ isError: true,
552171
+ failureKind: "configuration",
552172
+ executionState: "not_started"
552173
+ };
552174
+ }
552071
552175
  function numberInput(value, fallback) {
552072
552176
  return typeof value === "number" ? value : fallback;
552073
552177
  }
@@ -552776,21 +552880,6 @@ function createBrowserTool(host, storeScreenshot, loadCatalog) {
552776
552880
  }
552777
552881
  };
552778
552882
  }
552779
- function supportsNativeImageInput(context, catalog) {
552780
- const request = context.requestConfiguration;
552781
- if (!request)
552782
- return false;
552783
- const providerName = request.provider ?? context.settings?.provider;
552784
- const customProvider = context.settings?.customProviders?.find((item) => item.id === providerName);
552785
- const backend = customProvider ? "openai_compat" : providerName ? findByName(providerName)?.backendType : request.apiFormat === "openai" ? "openai_compat" : request.apiFormat === "anthropic" ? "anthropic" : undefined;
552786
- if (!backend)
552787
- return false;
552788
- const provider = providerName ? readCatalogProvider(catalog, providerName) : undefined;
552789
- const model = Object.entries(provider?.models ?? {}).find(([id, value]) => (value.id ?? id) === request.model)?.[1];
552790
- const customModel = customProvider?.models.find((item) => item.id === request.model);
552791
- const modelSupport = model ? modelInputCapabilities(model).image : normalizeInputSupport(customModel?.imageInputSupport);
552792
- return resolveEffectiveImageSupport({ image: modelSupport }, providerInputCapabilities(backend)) === "native";
552793
- }
552794
552883
  function isBrowserPermissionApproved(answer) {
552795
552884
  const isYes = (value) => typeof value === "string" && /^(yes|y|允许|同意)$/i.test(value.trim());
552796
552885
  if (isYes(answer))
@@ -552829,9 +552918,7 @@ function failed6(message) {
552829
552918
  return { content: [{ type: "text", text: message }], isError: true };
552830
552919
  }
552831
552920
  var init_browser_tool = __esm(() => {
552832
- init_src9();
552833
552921
  init_attachment_capabilities();
552834
- init_catalog_provider_mapping();
552835
552922
  });
552836
552923
 
552837
552924
  // ../../packages/server/src/application/browser-tools/index.ts
@@ -553116,7 +553203,9 @@ class DaemonApplication {
553116
553203
  createAttachmentReadTool({
553117
553204
  defaultTool: fileReadTool,
553118
553205
  authorizationSessions: attachmentAuthorizationSessions,
553119
- attachmentReader
553206
+ attachmentReader,
553207
+ supportsImageInput: async (context) => supportsNativeImageInput(context, await this.modelCatalog.load()),
553208
+ localOcr: this.localOcr
553120
553209
  })
553121
553210
  ],
553122
553211
  trustedToolOverrides: ["Read"],
@@ -553740,6 +553829,7 @@ var init_daemon_application = __esm(() => {
553740
553829
  init_assemble_session_context_usage();
553741
553830
  init_attachment_access();
553742
553831
  init_attachment_read_tool();
553832
+ init_attachment_capabilities();
553743
553833
  init_visual_tools();
553744
553834
  init_browser_tools();
553745
553835
  });
@@ -577791,4 +577881,4 @@ program.command("doctor").description("Check environment and dependencies").acti
577791
577881
  });
577792
577882
  program.parse();
577793
577883
 
577794
- //# debugId=13DB4FDDE5D18B0A64756E2164756E21
577884
+ //# debugId=F1A7D813F40C9D1364756E2164756E21