From ec51384ea99122b11bb252aeb2d108e575280cb8 Mon Sep 17 00:00:00 2001 From: remy Date: Thu, 12 Nov 2026 18:30:37 +1000 Subject: [PATCH 1/2] =?UTF-8?q?feat(sdk):=20llm=20=E6=96=87=E6=9C=AC?= =?UTF-8?q?=E8=B0=83=E7=94=A8=E6=94=AF=E6=8C=81=20webSearch=20=E5=BC=80?= =?UTF-8?q?=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TextModelInput 新增 webSearch?: boolean,使用模型供应商自带的联网搜索; 构建扫描到该字段时写入 requires.operations 的 llm.webSearch。 需要桌面端在输入 schema 与模型路由中配套实现。 Co-Authored-By: Claude Opus 5.5 --- .agents/skills/floatboat-workbench/references/llm.md | 4 ++-- sdk/host-contracts.mts | 2 ++ tests/authoring.test.mjs | 4 ++-- tooling/compiler/host-operations.ts | 1 + tooling/contracts/workbenchOperations.ts | 1 + 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.agents/skills/floatboat-workbench/references/llm.md b/.agents/skills/floatboat-workbench/references/llm.md index 0a33858..d8dacf9 100644 --- a/.agents/skills/floatboat-workbench/references/llm.md +++ b/.agents/skills/floatboat-workbench/references/llm.md @@ -13,7 +13,7 @@ Calls that name no model use `DEFAULT_LLM_MODEL` (`gemini-3.8-flash`, exported b ## Conversations, tools and reasoning -Pass `messages` instead of `prompt` (one or the other) for multi-turn calls: `{ role: 'system' | 'user', content }`, `{ role: 'user', content: [{ type: 'text', text }, { type: 'image', image }] }` and `{ role: 'tool', toolCallId, content }`. Append the previous result's `assistant` unchanged; its `hostState` is encrypted reasoning material the Host needs for the next turn. Do not edit it; if it is altered or the account changes, the Host continues without it instead of failing. `reasoning: 'off' | 'low' | 'medium' | 'high'` sets reasoning effort and falls back to off on models without it. +Pass `messages` instead of `prompt` (one or the other) for multi-turn calls: `{ role: 'system' | 'user', content }`, `{ role: 'user', content: [{ type: 'text', text }, { type: 'image', image }] }` and `{ role: 'tool', toolCallId, content }`. Append the previous result's `assistant` unchanged; its `hostState` is encrypted reasoning material the Host needs for the next turn. Do not edit it; if it is altered or the account changes, the Host continues without it instead of failing. `reasoning: 'off' | 'low' | 'medium' | 'high'` sets reasoning effort and falls back to off on models without it. `webSearch: true` on `generateText` or `streamText` lets the model use its provider's built-in web search for questions about current facts; it defaults to false, falls back to false on models without it, and adds latency and cost, so expose it as a user choice rather than turning it on for every call. Tools run in your app, not in the Host. Pass `tools: [{ name, description?, parameters }]` (`parameters` is a JSON Schema with `type: 'object'`) and optionally `toolChoice: 'auto' | 'none' | 'required' | { name }` to `generateText` or `streamText`. When `finishReason` is `TOOL_CALLS`, run each entry of `toolCalls` (`{ id, name, input, inputError? }`) yourself, then call again with the history plus `result.assistant` and one tool message per call. `inputError` means the arguments failed the schema; return it as the tool result so the model can correct itself. Cap the number of rounds and check permissions before any tool writes data. @@ -63,7 +63,7 @@ const result = await app.host.llm.decide({ ## Required Host operations -`pnpm workbench:check` and Floatboat builds scan the server code and write Host operations newer than the baseline (for example `llm.rerank`, or `llm.messages` / `llm.tools` / `llm.reasoning` / `llm.images` when text calls use those fields) to `manifest.requires.operations`. Older Floatboat clients then ask the user to update instead of failing at runtime. Commit the field with your code; the build only adds entries, so remove one by hand only when the code no longer uses it. +`pnpm workbench:check` and Floatboat builds scan the server code and write Host operations newer than the baseline (for example `llm.rerank`, or `llm.messages` / `llm.tools` / `llm.reasoning` / `llm.webSearch` / `llm.images` when text calls use those fields) to `manifest.requires.operations`. Older Floatboat clients then ask the user to update instead of failing at runtime. Commit the field with your code; the build only adds entries, so remove one by hand only when the code no longer uses it. ## Errors and billing diff --git a/sdk/host-contracts.mts b/sdk/host-contracts.mts index 07d7570..937a4dd 100644 --- a/sdk/host-contracts.mts +++ b/sdk/host-contracts.mts @@ -85,6 +85,8 @@ export type ModelInput = ModelConversation & { export type TextModelInput = ModelInput & { tools?: ToolDefinition[]; toolChoice?: ToolChoice; + /** 使用模型供应商自带的联网搜索,默认 false;模型不支持时 Host 按 false 处理。 */ + webSearch?: boolean; }; export type ModelKind = 'text' | 'speech' | 'image' | 'decision' | 'embedding' | 'rerank'; diff --git a/tests/authoring.test.mjs b/tests/authoring.test.mjs index c090e3a..49076f5 100644 --- a/tests/authoring.test.mjs +++ b/tests/authoring.test.mjs @@ -206,12 +206,12 @@ test('检查扫描服务端新 Host 操作写入 requires,只用基线操作 app.route('POST', '/api/search', async ({ host }) => { const { embed } = host.llm; const vectors = await embed({ model: 'embed-test', input: ['a'] }); - const answer = await host.llm.generateText({ messages: [{ role: 'user', content: 'hi' }] }); + const answer = await host.llm.generateText({ messages: [{ role: 'user', content: 'hi' }], webSearch: true }); return { size: vectors.embeddings.length, text: answer.text }; }); await app.listen();`)); const checked = await checkApplication(root); - assert.deepEqual(checked.requires, { operations: ['llm.embed', 'llm.messages'] }); + assert.deepEqual(checked.requires, { operations: ['llm.embed', 'llm.messages', 'llm.webSearch'] }); assert.deepEqual(JSON.parse(await readFile(join(root, 'manifest.json'), 'utf8')).requires, checked.requires); }); diff --git a/tooling/compiler/host-operations.ts b/tooling/compiler/host-operations.ts index ab76709..9778c1f 100644 --- a/tooling/compiler/host-operations.ts +++ b/tooling/compiler/host-operations.ts @@ -14,6 +14,7 @@ const TEXT_FEATURE_FIELDS: Readonly> = { tools: 'llm.tools', toolChoice: 'llm.tools', reasoning: 'llm.reasoning', + webSearch: 'llm.webSearch', }; /** 旧客户端严格校验会拒收的 Agent 调用字段。 */ const AGENT_FEATURE_FIELDS: Readonly> = { instructions: 'agent.instructions' }; diff --git a/tooling/contracts/workbenchOperations.ts b/tooling/contracts/workbenchOperations.ts index 5767b0e..733e154 100644 --- a/tooling/contracts/workbenchOperations.ts +++ b/tooling/contracts/workbenchOperations.ts @@ -86,6 +86,7 @@ export const WORKBENCH_SDK_FEATURES = [ 'llm.messages', 'llm.tools', 'llm.reasoning', + 'llm.webSearch', 'agent.instructions', 'agent.tools', ] as const; From 36a16fe199fff0dc17cde05462b2b2ec27af9a9c Mon Sep 17 00:00:00 2001 From: remy Date: Fri, 13 Nov 2026 02:03:19 +1000 Subject: [PATCH 2/2] =?UTF-8?q?feat(sdk):=20ModelCatalogEntry=20=E6=A0=87?= =?UTF-8?q?=E6=B3=A8=20webSearch=20=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 桌面端 listModels 的文本条目已返回 webSearch(AOE-HQ/aoe-desktop#2742), SDK 类型与创作指引同步:说明未标注时按不支持处理,Gemini 同时传 tools 时降级。 Co-Authored-By: Claude Opus 5.5 --- .agents/skills/floatboat-workbench/references/llm.md | 4 ++-- sdk/host-contracts.mts | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.agents/skills/floatboat-workbench/references/llm.md b/.agents/skills/floatboat-workbench/references/llm.md index d8dacf9..84d5d9e 100644 --- a/.agents/skills/floatboat-workbench/references/llm.md +++ b/.agents/skills/floatboat-workbench/references/llm.md @@ -13,7 +13,7 @@ Calls that name no model use `DEFAULT_LLM_MODEL` (`gemini-3.8-flash`, exported b ## Conversations, tools and reasoning -Pass `messages` instead of `prompt` (one or the other) for multi-turn calls: `{ role: 'system' | 'user', content }`, `{ role: 'user', content: [{ type: 'text', text }, { type: 'image', image }] }` and `{ role: 'tool', toolCallId, content }`. Append the previous result's `assistant` unchanged; its `hostState` is encrypted reasoning material the Host needs for the next turn. Do not edit it; if it is altered or the account changes, the Host continues without it instead of failing. `reasoning: 'off' | 'low' | 'medium' | 'high'` sets reasoning effort and falls back to off on models without it. `webSearch: true` on `generateText` or `streamText` lets the model use its provider's built-in web search for questions about current facts; it defaults to false, falls back to false on models without it, and adds latency and cost, so expose it as a user choice rather than turning it on for every call. +Pass `messages` instead of `prompt` (one or the other) for multi-turn calls: `{ role: 'system' | 'user', content }`, `{ role: 'user', content: [{ type: 'text', text }, { type: 'image', image }] }` and `{ role: 'tool', toolCallId, content }`. Append the previous result's `assistant` unchanged; its `hostState` is encrypted reasoning material the Host needs for the next turn. Do not edit it; if it is altered or the account changes, the Host continues without it instead of failing. `reasoning: 'off' | 'low' | 'medium' | 'high'` sets reasoning effort and falls back to off on models without it. `webSearch: true` on `generateText` or `streamText` lets the model use its provider's built-in web search for questions about current facts; it defaults to false, falls back to false on models whose `listModels` entry lacks `webSearch: true` and on Gemini calls that also pass `tools`, and adds latency and cost, so expose it as a user choice rather than turning it on for every call. Tools run in your app, not in the Host. Pass `tools: [{ name, description?, parameters }]` (`parameters` is a JSON Schema with `type: 'object'`) and optionally `toolChoice: 'auto' | 'none' | 'required' | { name }` to `generateText` or `streamText`. When `finishReason` is `TOOL_CALLS`, run each entry of `toolCalls` (`{ id, name, input, inputError? }`) yourself, then call again with the history plus `result.assistant` and one tool message per call. `inputError` means the arguments failed the schema; return it as the tool result so the model can correct itself. Cap the number of rounds and check permissions before any tool writes data. @@ -30,7 +30,7 @@ for (let round = 0; round < 5; round++) { ## Model catalog -`listModels({ kind? })` returns `models` (`id`, `kinds` of `text`/`speech`/`image`/`decision`/`rerank`, `inputs` of `text`/`image`, `source`), per-kind `defaults`, and `media`. Text models follow the same release, membership and local-model rules as the Floatboat chat model picker. `defaults.text` is the text default (`gemini-3.8-flash` when allowed); local models are listed with `source: 'local'` but are never a default. Speech, image, decision and rerank models come from a list Floatboat configures remotely (the first entry of each kind is its default), so `media` is always `available`; the platform may change these lists without an app update. Choose models from this result rather than hard-coding names. +`listModels({ kind? })` returns `models` (`id`, `kinds` of `text`/`speech`/`image`/`decision`/`rerank`, `inputs` of `text`/`image`, `source`, and for text models `webSearch` telling whether `webSearch: true` takes effect), per-kind `defaults`, and `media`. Text models follow the same release, membership and local-model rules as the Floatboat chat model picker. `defaults.text` is the text default (`gemini-3.8-flash` when allowed); local models are listed with `source: 'local'` but are never a default. Speech, image, decision and rerank models come from a list Floatboat configures remotely (the first entry of each kind is its default), so `media` is always `available`; the platform may change these lists without an app update. Choose models from this result rather than hard-coding names. ## Speech and images diff --git a/sdk/host-contracts.mts b/sdk/host-contracts.mts index 937a4dd..7f278cd 100644 --- a/sdk/host-contracts.mts +++ b/sdk/host-contracts.mts @@ -96,6 +96,8 @@ export interface ModelCatalogEntry { kinds: ModelKind[]; inputs: Array<'text' | 'image'>; source: 'platform' | 'local'; + /** 文本模型是否支持 webSearch;未标注时按不支持处理。 */ + webSearch?: boolean; } export interface ModelCatalog {