MCPcopy Create free account
hub / github.com/anomalyco/opencode / appendText

Function appendText

packages/llm/test/lib/tool-runtime.ts:112–128  ·  view source on GitHub ↗
(
  content: ContentPart[],
  type: "text" | "reasoning",
  text: string,
  providerMetadata?: ProviderMetadata,
)

Source from the content-addressed store, hash-verified

110}
111
112const appendText = (
113 content: ContentPart[],
114 type: "text" | "reasoning",
115 text: string,
116 providerMetadata?: ProviderMetadata,
117) => {
118 const last = content.at(-1)
119 if (last?.type === type) {
120 content[content.length - 1] = {
121 ...last,
122 text: `${last.text}${text}`,
123 providerMetadata: providerMetadata ?? last.providerMetadata,
124 }
125 return
126 }
127 content.push({ type, text, providerMetadata })
128}
129
130const addUsage = (left: Usage | undefined, right: Usage | undefined): Usage | undefined => {
131 if (!left) return right

Callers 1

stepStateFunction · 0.70

Calls 2

atMethod · 0.80
pushMethod · 0.80

Tested by

no test coverage detected