Commit bfebe1b
authored
docs: fix the Node.js inbound trace-context example to use a real tool-registration API (#2223)
The Node.js example in the "CLI -> SDK (inbound)" section of
docs/observability/opentelemetry.md registered a tool by calling
session.registerTool(myTool, handler). That method is not part of the public
CopilotSession API, so copying the example fails to compile with
error TS2339: Property 'registerTool' does not exist on type 'CopilotSession'
and, if the types are bypassed, throws
"TypeError: session.registerTool is not a function" at runtime. The plural
registerTools() is marked @internal and stripped from the shipped declarations,
so there is no public session method to register a tool with after the session
exists.
Move the trace-restoring handler into defineTool() and register the tool through
client.createSession({ tools: [myTool] }), which is the public registration path
and the one used by the rest of the documentation. The trace-context logic is
unchanged; only the registration mechanism is corrected. As a side effect the
handler's args and invocation parameters are now contextually typed, so the
invocation.traceparent / invocation.tracestate access in the example is actually
type-checked.
Co-authored-by: examon <examon@users.noreply.github.com>1 parent dd8d869 commit bfebe1b
1 file changed
Lines changed: 27 additions & 20 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
| 155 | + | |
155 | 156 | | |
156 | 157 | | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
177 | 181 | | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
178 | 185 | | |
179 | 186 | | |
180 | 187 | | |
| |||
0 commit comments