\ No newline at end of file
diff --git a/2021/03/31/2020-年终总结/index.html b/2021/03/31/2020-年终总结/index.html
index e0bbd53100..20b763c016 100644
--- a/2021/03/31/2020-年终总结/index.html
+++ b/2021/03/31/2020-年终总结/index.html
@@ -1 +1 @@
-2020 年终总结 | Nicksxs's Blog
\ No newline at end of file
diff --git a/2021/07/18/2021-年中总结/index.html b/2021/07/18/2021-年中总结/index.html
index 76a85cc7d8..bab054648f 100644
--- a/2021/07/18/2021-年中总结/index.html
+++ b/2021/07/18/2021-年中总结/index.html
@@ -1 +1 @@
-2021 年中总结 | Nicksxs's Blog
constDESCRIPTION_INTRO = `Run JavaScript code to orchestrate/compose tool calls - Evaluates the provided JavaScript code in a fresh QuickJS sandbox as the body of an async function: top-level \`await\` and \`return\` work. - All nested tools are available on the global \`tools\` object, for example \`await tools.read(...)\`. Tool names are exposed as normalized JavaScript identifiers, for example \`await tools.mcp__ologs__get_profile(...)\`. - Nested tool methods take an object as their input argument. - Nested tools return either an object or a string, based on the description. - A nested tool call that fails, is blocked, or gets invalid arguments rejects with an Error carrying the tool's error text. - Runs raw JavaScript -- no Node, no file system, no network access, no timers. - Accepts raw JavaScript source text, not JSON, quoted strings, or markdown code fences. - You may optionally start the tool input with a first line like \`// @options: {"max_output_tokens": 1000, "timeout_ms": 60000}\`. - \`max_output_tokens\` sets the token budget for the script's output. Defaults to 10000 tokens. - \`timeout_ms\` sets a hard deadline for the whole script. By default there is none. - When the JS code is fully evaluated, calls that are still running are cancelled and unawaited promises are silently discarded. - Tool calls are real and have side effects. If the script fails partway, earlier calls are not undone. - Scripts have a 256 MB memory limit; exceeding it throws \`InternalError: out of memory\`. Filter or aggregate large data instead of accumulating it. - Global helpers: - \`exit()\`: Immediately ends the current script successfully (like an early return from the top level). - \`text(value: string | number | boolean | undefined | null)\`: Appends a text item. Non-string values are stringified with \`JSON.stringify(...)\` when possible. - \`image(imageUrlOrItem: string | { image_url: string } | ImageContent)\`: Appends an image item. \`image_url\` should be a base64-encoded \`data:\` URL. To forward an MCP tool image, pass an individual \`ImageContent\` block from \`result.content\`, for example \`image(result.content[0])\`. - \`store(key: string, value: any)\`: stores a serializable value under a string key for later \`codemode\` calls in the same session. Storing \`undefined\` deletes the key. Writes are kept only if the script succeeds. - \`load(key: string)\`: returns the stored value for a string key, or \`undefined\` if it is missing. - \`ALL_TOOLS\`: metadata for the enabled nested tools as \`{ name, description }\` entries. - \`searchTools(query: string, options?: { limit?: number; namespace?: string })\`: resolves to the nested tools that best match the query (BM25, default limit 8), as \`{ name, description }\` entries like \`ALL_TOOLS\`. - \`describeTool(name: string)\`: resolves to the description and declaration of a nested tool, or \`undefined\`. - \`describeNamespace(name: string)\`: resolves to \`{ name, description?, instructions?, tools }\` for a namespace of nested tools, such as an MCP server: its usage instructions and the names of its tools, or \`undefined\`. - \`console.log(...)\` and the other \`console\` methods append a text item like \`text()\`. - \`return value\` at the top level appends the value like \`text()\`.`;
constDEFERRED_TOOLS_GUIDANCE = `Some nested tools may be omitted from this description, such as deferred tools and MCP tools. They are still available on the global \`tools\` object and listed in \`ALL_TOOLS\`. To find one, call \`await searchTools(query)\` (pass \`{ namespace }\` to search one namespace), or filter \`ALL_TOOLS\` by \`name\` and \`description\`. \`await describeNamespace(name)\` returns a namespace's usage instructions and the names of its tools.`;
constDESCRIPTION_INTRO = `Run JavaScript that calls other tools. The input is raw JavaScript (not JSON, no code fence), run as an async function body in a QuickJS sandbox: top-level \`await\` and \`return\` work. No Node, file system, network, or timers. - \`await tools.<name>({ ...args })\` resolves to a string, or an object if the tool's declaration says so, and rejects with an Error on failure. Calls still running when the script ends are cancelled. - Optional first line: \`// @options: {"max_output_tokens": 10000, "timeout_ms": 60000}\``;
/** One line per global. The details live in {@link CODEMODE_DOCS_PATH}. */ functiondescribeGlobals(models: boolean): string { const lines = [ "Globals:", "- `text(value)`, `image(dataUrlOrImageBlock)`, `console.log(...)`, and top-level `return` add output; `exit()` ends the script.", "- `store(key, value)` and `load(key)` keep JSON values across codemode calls.", "- `ALL_TOOLS`, `searchTools(query, { limit?, namespace? })`, `describeTool(name)`, `describeNamespace(name)`: find unlisted tools, such as MCP tools.", ]; if (models) { lines.push(`- \`models\`: classifiers and image generation. Read ${CODEMODE_DOCS_PATH} first.`); } return lines.join("\n"); }
constMODEL_TYPES = `type ModelType = "chat" | "image" | "classifier"; /** A model catalog entry. \`provider\` and \`id\` identify it; the other fields depend on the type. */ interface ModelInfo { type?: ModelType; provider: string; id: string; name: string; api: string; input: ("text" | "image")[]; contextWindow?: number; [key: string]: unknown; } type ClassifierQuestion = | { type: "choice"; instructions: string; criteria: Record<string, string> } | { type: "score"; instructions: string; criteria: string[] } | { type: "bool"; instructions: string; criteria: { true: string; false: string } }; type ClassifierAnswer = | { type: "choice"; choice: string; probabilities: Record<string, number>; confidence: number } | { type: "score"; score: number; confidence: number } | { type: "bool"; probability: number }; interface ClassifierContext { state: Record<string, unknown>; questions: Record<string, ClassifierQuestion>; } /** Token counts reported by the service. Cost is in USD. */ type ModelUsage = { input: number; output: number; totalTokens: number; cost: { total: number } }; interface ClassifierResult { api: string; provider: string; model: string; answers: Record<string, ClassifierAnswer>; usage?: ModelUsage; stopReason: "stop" | "error" | "aborted"; errorMessage?: string; timestamp: number; } type ModelTextBlock = { type: "text"; text: string }; /** \`data\` is base64. Show it with \`image(block)\`; never print \`data\` with \`text()\`, \`console\`, or \`return\`. */ type ModelImageBlock = { type: "image"; data: string; mimeType: string }; interface ImagesContext { /** The prompt as text blocks, plus image blocks to edit or use as references. */ input: (ModelTextBlock | ModelImageBlock)[]; } interface ImagesResult { api: string; provider: string; model: string; /** Generated images, and text blocks for models that also return text. */ output: (ModelTextBlock | ModelImageBlock)[]; usage?: ModelUsage; stopReason: "stop" | "error" | "aborted"; errorMessage?: string; timestamp: number; }`;
/** Declarations of the `models` globals; codemode-execute.ts implements them. */ exportconstMODEL_GLOBAL_DECLARATIONS: readonlyOmit<CodemodeTool, "execute">[] = [ { name: "models.getModelsOfType", description: "Every known model of a type, optionally for one provider.", signature: "(type: ModelType, provider?: string): Promise<ModelInfo[]>", }, { name: "models.getAvailableOfType", description: "Models of a type whose provider has working credentials.", signature: "(type: ModelType, provider?: string): Promise<ModelInfo[]>", }, { name: "models.getModelOfType", description: "One catalog entry, or undefined.", signature: "(type: ModelType, provider: string, id: string): Promise<ModelInfo | undefined>", }, { name: "models.classify", description: "Run a classifier model on one state. Only `provider` and `id` of `model` are used. Provider errors do not throw: check `stopReason` and `errorMessage`.", signature: "(model: ModelInfo, context: ClassifierContext): Promise<ClassifierResult>", }, { name: "models.generateImages", description: 'Generate images with an image model. Only `provider` and `id` of `model` are used. Provider errors do not throw: check `stopReason` and `errorMessage`. Generation can take minutes, so do not set a short `timeout_ms`. Show results with `for (const block of result.output) if (block.type === "image") image(block);`.', signature: "(model: ModelInfo, context: ImagesContext): Promise<ImagesResult>", }, ];
declareconsttools: { bash(args: { // Shell command to execute command: string; // Timeout in seconds (optional, no default timeout) timeout?: number; }): Promise<{ exit_code: number; // Temp file with the full output, when truncated full_output_path?: string; // Combined stdout and stderr, up to 1 MiB. Longer output keeps its first and last 512 KiB around an omission marker. output: string; // Whether `output` omits part of the command output truncated: boolean; wall_time_seconds: number; }>; };
/** * A declared tool's description followed by how scripts call it and what the call resolves to. The * arguments are the tool's declared parameters, so they are not repeated. */ functiondescribeScriptCall(tool: AgentTool<any>): string { return`${tool.description.trim()}\n\nCodemode: \`tools.${toCodemodeIdentifier(tool.name)}(args)\` resolves to ${describeOutput(toCodemodeDeclaration(tool).outputSchema)}.`; }
constSERVERS_SECTION_INTRO = "MCP servers whose tools are not declared to you. Call the tools of `codemode` servers from codemode scripts: find them with `searchTools(query, { namespace })` and read a server's instructions and tool names with `describeNamespace(name)`. Load the tools of `tool_search` servers with `tool_search`.";
改后根据当前服务器实际采用的路径拼接:
1 2 3 4 5 6
functionserversSectionIntro(reaches: ReadonlySet<string>): string { let intro = "MCP servers whose tools are not declared to you."; if (reaches.has("codemode")) intro += " Call the tools of `codemode` servers from codemode scripts."; if (reaches.has("tool_search")) intro += " Load the tools of `tool_search` servers with `tool_search`."; return intro; }
exportconst codemodeToolSystemPromptContribution = { snippet: "Run JavaScript that calls other tools (chains, loops, Promise.all, filtering large results)", guidelines: [ "Use codemode to batch or chain several tool calls, or to filter large tool output down to what you need, instead of issuing many individual tool calls. Batch independent calls in one codemode call using await Promise.allSettled([...]).", ], } asconst;
改后:
1 2 3 4 5 6
exportconst codemodeToolSystemPromptContribution = { snippet: "Run JavaScript that calls other tools", guidelines: [ "Use codemode to batch independent tool calls (Promise.allSettled), chain them, or filter large output, instead of many separate calls.", ], } asconst;
constDESCRIPTION_INTRO = `Run JavaScript code to orchestrate/compose tool calls - Evaluates the provided JavaScript code in a fresh QuickJS sandbox as the body of an async function: top-level \`await\` and \`return\` work. - All nested tools are available on the global \`tools\` object, for example \`await tools.read(...)\`. Tool names are exposed as normalized JavaScript identifiers, for example \`await tools.mcp__ologs__get_profile(...)\`. - Nested tool methods take an object as their input argument. - Nested tools return either an object or a string, based on the description. - A nested tool call that fails, is blocked, or gets invalid arguments rejects with an Error carrying the tool's error text. - Runs raw JavaScript -- no Node, no file system, no network access, no timers. - Accepts raw JavaScript source text, not JSON, quoted strings, or markdown code fences. - You may optionally start the tool input with a first line like \`// @options: {"max_output_tokens": 1000, "timeout_ms": 60000}\`. - \`max_output_tokens\` sets the token budget for the script's output. Defaults to 10000 tokens. - \`timeout_ms\` sets a hard deadline for the whole script. By default there is none. - When the JS code is fully evaluated, calls that are still running are cancelled and unawaited promises are silently discarded. - Tool calls are real and have side effects. If the script fails partway, earlier calls are not undone. - Scripts have a 256 MB memory limit; exceeding it throws \`InternalError: out of memory\`. Filter or aggregate large data instead of accumulating it. - Global helpers: - \`exit()\`: Immediately ends the current script successfully (like an early return from the top level). - \`text(value: string | number | boolean | undefined | null)\`: Appends a text item. Non-string values are stringified with \`JSON.stringify(...)\` when possible. - \`image(imageUrlOrItem: string | { image_url: string } | ImageContent)\`: Appends an image item. \`image_url\` should be a base64-encoded \`data:\` URL. To forward an MCP tool image, pass an individual \`ImageContent\` block from \`result.content\`, for example \`image(result.content[0])\`. - \`store(key: string, value: any)\`: stores a serializable value under a string key for later \`codemode\` calls in the same session. Storing \`undefined\` deletes the key. Writes are kept only if the script succeeds. - \`load(key: string)\`: returns the stored value for a string key, or \`undefined\` if it is missing. - \`ALL_TOOLS\`: metadata for the enabled nested tools as \`{ name, description }\` entries. - \`searchTools(query: string, options?: { limit?: number; namespace?: string })\`: resolves to the nested tools that best match the query (BM25, default limit 8), as \`{ name, description }\` entries like \`ALL_TOOLS\`. - \`describeTool(name: string)\`: resolves to the description and declaration of a nested tool, or \`undefined\`. - \`describeNamespace(name: string)\`: resolves to \`{ name, description?, instructions?, tools }\` for a namespace of nested tools, such as an MCP server: its usage instructions and the names of its tools, or \`undefined\`. - \`console.log(...)\` and the other \`console\` methods append a text item like \`text()\`. - \`return value\` at the top level appends the value like \`text()\`.`;
constDEFERRED_TOOLS_GUIDANCE = `Some nested tools may be omitted from this description, such as deferred tools and MCP tools. They are still available on the global \`tools\` object and listed in \`ALL_TOOLS\`. To find one, call \`await searchTools(query)\` (pass \`{ namespace }\` to search one namespace), or filter \`ALL_TOOLS\` by \`name\` and \`description\`. \`await describeNamespace(name)\` returns a namespace's usage instructions and the names of its tools.`;
constDESCRIPTION_INTRO = `Run JavaScript that calls other tools. The input is raw JavaScript (not JSON, no code fence), run as an async function body in a QuickJS sandbox: top-level \`await\` and \`return\` work. No Node, file system, network, or timers. - \`await tools.<name>({ ...args })\` resolves to a string, or an object if the tool's declaration says so, and rejects with an Error on failure. Calls still running when the script ends are cancelled. - Optional first line: \`// @options: {"max_output_tokens": 10000, "timeout_ms": 60000}\``;
/** One line per global. The details live in {@link CODEMODE_DOCS_PATH}. */ functiondescribeGlobals(models: boolean): string { const lines = [ "Globals:", "- `text(value)`, `image(dataUrlOrImageBlock)`, `console.log(...)`, and top-level `return` add output; `exit()` ends the script.", "- `store(key, value)` and `load(key)` keep JSON values across codemode calls.", "- `ALL_TOOLS`, `searchTools(query, { limit?, namespace? })`, `describeTool(name)`, `describeNamespace(name)`: find unlisted tools, such as MCP tools.", ]; if (models) { lines.push(`- \`models\`: classifiers and image generation. Read ${CODEMODE_DOCS_PATH} first.`); } return lines.join("\n"); }
constMODEL_TYPES = `type ModelType = "chat" | "image" | "classifier"; /** A model catalog entry. \`provider\` and \`id\` identify it; the other fields depend on the type. */ interface ModelInfo { type?: ModelType; provider: string; id: string; name: string; api: string; input: ("text" | "image")[]; contextWindow?: number; [key: string]: unknown; } type ClassifierQuestion = | { type: "choice"; instructions: string; criteria: Record<string, string> } | { type: "score"; instructions: string; criteria: string[] } | { type: "bool"; instructions: string; criteria: { true: string; false: string } }; type ClassifierAnswer = | { type: "choice"; choice: string; probabilities: Record<string, number>; confidence: number } | { type: "score"; score: number; confidence: number } | { type: "bool"; probability: number }; interface ClassifierContext { state: Record<string, unknown>; questions: Record<string, ClassifierQuestion>; } /** Token counts reported by the service. Cost is in USD. */ type ModelUsage = { input: number; output: number; totalTokens: number; cost: { total: number } }; interface ClassifierResult { api: string; provider: string; model: string; answers: Record<string, ClassifierAnswer>; usage?: ModelUsage; stopReason: "stop" | "error" | "aborted"; errorMessage?: string; timestamp: number; } type ModelTextBlock = { type: "text"; text: string }; /** \`data\` is base64. Show it with \`image(block)\`; never print \`data\` with \`text()\`, \`console\`, or \`return\`. */ type ModelImageBlock = { type: "image"; data: string; mimeType: string }; interface ImagesContext { /** The prompt as text blocks, plus image blocks to edit or use as references. */ input: (ModelTextBlock | ModelImageBlock)[]; } interface ImagesResult { api: string; provider: string; model: string; /** Generated images, and text blocks for models that also return text. */ output: (ModelTextBlock | ModelImageBlock)[]; usage?: ModelUsage; stopReason: "stop" | "error" | "aborted"; errorMessage?: string; timestamp: number; }`;
/** Declarations of the `models` globals; codemode-execute.ts implements them. */ exportconstMODEL_GLOBAL_DECLARATIONS: readonlyOmit<CodemodeTool, "execute">[] = [ { name: "models.getModelsOfType", description: "Every known model of a type, optionally for one provider.", signature: "(type: ModelType, provider?: string): Promise<ModelInfo[]>", }, { name: "models.getAvailableOfType", description: "Models of a type whose provider has working credentials.", signature: "(type: ModelType, provider?: string): Promise<ModelInfo[]>", }, { name: "models.getModelOfType", description: "One catalog entry, or undefined.", signature: "(type: ModelType, provider: string, id: string): Promise<ModelInfo | undefined>", }, { name: "models.classify", description: "Run a classifier model on one state. Only `provider` and `id` of `model` are used. Provider errors do not throw: check `stopReason` and `errorMessage`.", signature: "(model: ModelInfo, context: ClassifierContext): Promise<ClassifierResult>", }, { name: "models.generateImages", description: 'Generate images with an image model. Only `provider` and `id` of `model` are used. Provider errors do not throw: check `stopReason` and `errorMessage`. Generation can take minutes, so do not set a short `timeout_ms`. Show results with `for (const block of result.output) if (block.type === "image") image(block);`.', signature: "(model: ModelInfo, context: ImagesContext): Promise<ImagesResult>", }, ];
declareconsttools: { bash(args: { // Shell command to execute command: string; // Timeout in seconds (optional, no default timeout) timeout?: number; }): Promise<{ exit_code: number; // Temp file with the full output, when truncated full_output_path?: string; // Combined stdout and stderr, up to 1 MiB. Longer output keeps its first and last 512 KiB around an omission marker. output: string; // Whether `output` omits part of the command output truncated: boolean; wall_time_seconds: number; }>; };
/** * A declared tool's description followed by how scripts call it and what the call resolves to. The * arguments are the tool's declared parameters, so they are not repeated. */ functiondescribeScriptCall(tool: AgentTool<any>): string { return`${tool.description.trim()}\n\nCodemode: \`tools.${toCodemodeIdentifier(tool.name)}(args)\` resolves to ${describeOutput(toCodemodeDeclaration(tool).outputSchema)}.`; }
constSERVERS_SECTION_INTRO = "MCP servers whose tools are not declared to you. Call the tools of `codemode` servers from codemode scripts: find them with `searchTools(query, { namespace })` and read a server's instructions and tool names with `describeNamespace(name)`. Load the tools of `tool_search` servers with `tool_search`.";
改后根据当前服务器实际采用的路径拼接:
1 2 3 4 5 6
functionserversSectionIntro(reaches: ReadonlySet<string>): string { let intro = "MCP servers whose tools are not declared to you."; if (reaches.has("codemode")) intro += " Call the tools of `codemode` servers from codemode scripts."; if (reaches.has("tool_search")) intro += " Load the tools of `tool_search` servers with `tool_search`."; return intro; }
exportconst codemodeToolSystemPromptContribution = { snippet: "Run JavaScript that calls other tools (chains, loops, Promise.all, filtering large results)", guidelines: [ "Use codemode to batch or chain several tool calls, or to filter large tool output down to what you need, instead of issuing many individual tool calls. Batch independent calls in one codemode call using await Promise.allSettled([...]).", ], } asconst;
改后:
1 2 3 4 5 6
exportconst codemodeToolSystemPromptContribution = { snippet: "Run JavaScript that calls other tools", guidelines: [ "Use codemode to batch independent tool calls (Promise.allSettled), chain them, or filter large output, instead of many separate calls.", ], } asconst;
6.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" class=octo-body fill=currentColor>
\ No newline at end of file
diff --git a/tags/mysql/index.html b/tags/mysql/index.html
index a45119023a..3036aed087 100644
--- a/tags/mysql/index.html
+++ b/tags/mysql/index.html
@@ -1 +1 @@
-标签: Mysql | Nicksxs's Blog
\ No newline at end of file
diff --git a/tags/php/index.html b/tags/php/index.html
index e6d5da7702..ecfe490cae 100644
--- a/tags/php/index.html
+++ b/tags/php/index.html
@@ -1 +1 @@
-标签: PHP | Nicksxs's Blog