File tree Expand file tree Collapse file tree
cli-plugins/copilot/src/commands/app Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import chalk from 'chalk' ;
22import ora from 'ora' ;
33
4- import type { CopilotSession , JsonValue } from '@github/copilot-sdk' ;
4+ import type { CopilotSession } from '@github/copilot-sdk' ;
55
66import { tryFormatMessage } from './try-format-message.js' ;
77
88/**
99 * Extracts the first string-valued property found among `keys` on a tool-call's
10- * JSON arguments, narrowing the untyped `JsonValue` union to its object branch first .
11- * @param value - The tool-call arguments to inspect, as reported by the Copilot SDK
10+ * arguments record, as reported by the Copilot SDK .
11+ * @param value - The tool-call arguments to inspect
1212 * @param keys - Property names to check, in priority order
1313 * @returns The first matching string value, or `undefined` if none match
1414 */
15- function firstStringProp ( value : JsonValue | undefined , keys : string [ ] ) : string | undefined {
16- // Primitives and arrays have no named properties to read
17- if ( typeof value !== 'object' || value === null || Array . isArray ( value ) ) {
15+ function firstStringProp (
16+ value : Record < string , unknown > | undefined ,
17+ keys : string [ ] ,
18+ ) : string | undefined {
19+ if ( value === undefined ) {
1820 return undefined ;
1921 }
2022 // Return the first key present with a string value, in caller-specified priority order
Original file line number Diff line number Diff line change @@ -21,5 +21,6 @@ import { assert } from './assert.js';
2121 */
2222export function assertObject ( value : object , message ?: string | Error ) : asserts value {
2323 // typeof null is 'object', so this does not exclude null values
24- assert ( typeof value === 'object' , message ) ;
24+ // normalize to `Error | undefined` to match the `node:assert` overload
25+ assert ( typeof value === 'object' , typeof message === 'string' ? new Error ( message ) : message ) ;
2526}
You can’t perform that action at this time.
0 commit comments