@@ -3,6 +3,7 @@ import path from "node:path";
33import { optionalFiniteNumberSchema } from "openclaw/plugin-sdk/channel-actions" ;
44import type { OpenClawPluginToolContext } from "openclaw/plugin-sdk/plugin-entry" ;
55import { asNonArrayRecord } from "openclaw/plugin-sdk/string-coerce-runtime" ;
6+ import { textResult } from "openclaw/plugin-sdk/tool-results" ;
67import { Type } from "typebox" ;
78import type { AnyAgentTool , OpenClawConfig } from "../api.js" ;
89import { applyMemoryWikiMutation , normalizeMemoryWikiMutationInput } from "./apply.js" ;
@@ -140,10 +141,7 @@ export function createWikiStatusTool(
140141 appConfig,
141142 callerAgentId : memoryContext . agentId ,
142143 } ) ;
143- return {
144- content : [ { type : "text" , text : renderMemoryWikiStatus ( status ) } ] ,
145- details : status ,
146- } ;
144+ return textResult ( renderMemoryWikiStatus ( status ) , status ) ;
147145 } ,
148146 } ;
149147}
@@ -190,10 +188,7 @@ export function createWikiSearchTool(
190188 `${ index + 1 } . ${ result . title } (${ result . corpus } /${ result . kind } )\nPath: ${ result . path } ${ typeof result . startLine === "number" && typeof result . endLine === "number" ? `\nLines: ${ result . startLine } -${ result . endLine } ` : "" } ${ result . provenanceLabel ? `\nProvenance: ${ result . provenanceLabel } ` : "" } ${ result . matchedClaimId ? `\nClaim: ${ result . matchedClaimId } ` : "" } ${ result . evidenceKinds && result . evidenceKinds . length > 0 ? `\nEvidence: ${ result . evidenceKinds . join ( ", " ) } ` : "" } \nSnippet: ${ result . snippet } ` ,
191189 )
192190 . join ( "\n\n" ) ;
193- return {
194- content : [ { type : "text" , text } ] ,
195- details : { results } ,
196- } ;
191+ return textResult ( text , { results } ) ;
197192 } ,
198193 } ;
199194}
@@ -228,15 +223,12 @@ export function createWikiLintTool(
228223 `Provenance gaps: ${ provenance } ` ,
229224 `Report: ${ reportPath } ` ,
230225 ] . join ( "\n" ) ;
231- return {
232- content : [ { type : "text" , text : summary } ] ,
233- details : {
234- issueCount : result . issueCount ,
235- issues : result . issues ,
236- issuesByCategory : result . issuesByCategory ,
237- reportPath,
238- } ,
239- } ;
226+ return textResult ( summary , {
227+ issueCount : result . issueCount ,
228+ issues : result . issues ,
229+ issuesByCategory : result . issuesByCategory ,
230+ reportPath,
231+ } ) ;
240232 } ,
241233 } ;
242234}
@@ -265,15 +257,10 @@ export function createWikiApplyTool(
265257 result . compile . updatedFiles . length > 0
266258 ? `Refreshed ${ result . compile . updatedFiles . length } index file${ result . compile . updatedFiles . length === 1 ? "" : "s" } .`
267259 : "Indexes unchanged." ;
268- return {
269- content : [
270- {
271- type : "text" ,
272- text : `${ action } ${ result . pagePath } via ${ result . operation } . ${ compileSummary } ` ,
273- } ,
274- ] ,
275- details : result ,
276- } ;
260+ return textResult (
261+ `${ action } ${ result . pagePath } via ${ result . operation } . ${ compileSummary } ` ,
262+ result ,
263+ ) ;
277264 } ,
278265 } ;
279266}
@@ -299,10 +286,7 @@ export function createWikiGetTool(
299286 } ;
300287 const lookup = typeof params . lookup === "string" ? params . lookup . trim ( ) : "" ;
301288 if ( ! lookup ) {
302- return {
303- content : [ { type : "text" , text : "wiki_get requires a non-empty `lookup` path or id." } ] ,
304- details : { found : false } ,
305- } ;
289+ return textResult ( "wiki_get requires a non-empty `lookup` path or id." , { found : false } ) ;
306290 }
307291 await syncImportedSourcesIfNeeded ( config , appConfig , memoryContext . signal ) ;
308292 const result = await getMemoryWikiPage ( {
@@ -319,15 +303,9 @@ export function createWikiGetTool(
319303 ...( params . corpus ? { searchCorpus : params . corpus } : { } ) ,
320304 } ) ;
321305 if ( ! result ) {
322- return {
323- content : [ { type : "text" , text : `Wiki page not found: ${ lookup } ` } ] ,
324- details : { found : false } ,
325- } ;
306+ return textResult ( `Wiki page not found: ${ lookup } ` , { found : false } ) ;
326307 }
327- return {
328- content : [ { type : "text" , text : result . content } ] ,
329- details : { found : true , ...result } ,
330- } ;
308+ return textResult ( result . content , { found : true , ...result } ) ;
331309 } ,
332310 } ;
333311}
0 commit comments