Skip to content

Commit df8caaf

Browse files
feat: 全部类型问题解决
1 parent 1dec64c commit df8caaf

135 files changed

Lines changed: 671 additions & 503 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

bun.lock

Lines changed: 26 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,10 @@
5353
"docs:dev": "npx mintlify dev",
5454
"rcs": "bun run scripts/rcs.ts"
5555
},
56-
"dependencies": {},
56+
"dependencies": {
57+
"@types/lodash-es": "^4.17.12"
58+
},
5759
"devDependencies": {
58-
"openai": "^6.33.0",
5960
"@alcalzone/ansi-tokenize": "^0.3.0",
6061
"@ant/claude-for-chrome-mcp": "workspace:*",
6162
"@ant/computer-use-input": "workspace:*",
@@ -68,6 +69,7 @@
6869
"@anthropic-ai/sandbox-runtime": "^0.0.44",
6970
"@anthropic-ai/sdk": "^0.80.0",
7071
"@anthropic-ai/vertex-sdk": "^0.14.4",
72+
"@anthropic/ink": "workspace:*",
7173
"@aws-sdk/client-bedrock": "^3.1020.0",
7274
"@aws-sdk/client-bedrock-runtime": "^3.1020.0",
7375
"@aws-sdk/client-sts": "^3.1020.0",
@@ -101,11 +103,18 @@
101103
"@smithy/node-http-handler": "^4.5.1",
102104
"@types/bun": "^1.3.11",
103105
"@types/cacache": "^20.0.1",
106+
"@types/picomatch": "^4.0.3",
104107
"@types/plist": "^3.0.5",
108+
"@types/proper-lockfile": "^4.1.4",
109+
"@types/qrcode": "^1.5.6",
105110
"@types/react": "^19.2.14",
106111
"@types/react-reconciler": "^0.33.0",
112+
"@types/semver": "^7.7.1",
107113
"@types/sharp": "^0.32.0",
114+
"@types/shell-quote": "^1.7.5",
115+
"@types/stack-utils": "^2.0.3",
108116
"@types/turndown": "^5.0.6",
117+
"@types/ws": "^8.18.1",
109118
"ajv": "^8.18.0",
110119
"asciichart": "^1.5.25",
111120
"audio-capture-napi": "workspace:*",
@@ -132,7 +141,6 @@
132141
"highlight.js": "^11.11.1",
133142
"https-proxy-agent": "^8.0.0",
134143
"ignore": "^7.0.5",
135-
"@anthropic/ink": "workspace:*",
136144
"image-processor-napi": "workspace:*",
137145
"indent-string": "^5.0.0",
138146
"jsonc-parser": "^3.3.1",
@@ -141,6 +149,7 @@
141149
"lru-cache": "^11.2.7",
142150
"marked": "^17.0.5",
143151
"modifiers-napi": "workspace:*",
152+
"openai": "^6.33.0",
144153
"p-map": "^7.0.4",
145154
"picomatch": "^4.0.4",
146155
"plist": "^3.1.0",

packages/@ant/computer-use-mcp/src/toolCalls.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2148,7 +2148,7 @@ async function handleScreenshot(
21482148

21492149
const monitorNote = await buildMonitorNote(
21502150
adapter,
2151-
shot.displayId,
2151+
shot.displayId ?? 0,
21522152
overrides.lastScreenshot?.displayId,
21532153
overrides.onDisplayPinned !== undefined,
21542154
);
@@ -2217,7 +2217,7 @@ async function handleScreenshot(
22172217

22182218
const monitorNote = await buildMonitorNote(
22192219
adapter,
2220-
shot.displayId,
2220+
shot.displayId ?? 0,
22212221
overrides.lastScreenshot?.displayId,
22222222
overrides.onDisplayPinned !== undefined,
22232223
);

packages/@ant/ink/src/core/bidi.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,20 @@
1616
*/
1717
import bidiFactory from 'bidi-js'
1818

19+
type BidiInstance = {
20+
getEmbeddingLevels: (text: string, defaultDirection?: string) => { paragraphLevel: number; levels: Uint8Array }
21+
getReorderSegments: (text: string, embeddingLevels: { paragraphLevel: number; levels: Uint8Array }, start?: number, end?: number) => [number, number][]
22+
getVisualOrder: (reorderSegments: [number, number][]) => number[]
23+
}
24+
1925
type ClusteredChar = {
2026
value: string
2127
width: number
2228
styleId: number
2329
hyperlink: string | undefined
2430
}
2531

26-
let bidiInstance: ReturnType<typeof bidiFactory> | undefined
32+
let bidiInstance: BidiInstance | undefined
2733
let needsSoftwareBidi: boolean | undefined
2834

2935
function needsBidi(): boolean {
@@ -38,7 +44,7 @@ function needsBidi(): boolean {
3844

3945
function getBidi() {
4046
if (!bidiInstance) {
41-
bidiInstance = bidiFactory()
47+
bidiInstance = (bidiFactory as unknown as () => BidiInstance)()
4248
}
4349
return bidiInstance
4450
}

packages/@ant/ink/src/core/ink.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1883,8 +1883,8 @@ export default class Ink {
18831883
let reentered = false
18841884
const intercept = (
18851885
chunk: Uint8Array | string,
1886-
encodingOrCb?: BufferEncoding | ((err?: Error) => void),
1887-
cb?: (err?: Error) => void,
1886+
encodingOrCb?: BufferEncoding | ((err?: Error | null) => void),
1887+
cb?: (err?: Error | null) => void,
18881888
): boolean => {
18891889
const callback = typeof encodingOrCb === 'function' ? encodingOrCb : cb
18901890
// Reentrancy guard: logger.debug → writeToStderr → here. Pass

src/QueryEngine.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -563,16 +563,16 @@ export class QueryEngine {
563563
for (const msg of messagesFromUserInput) {
564564
if (
565565
msg.type === 'user' &&
566-
typeof msg.message.content === 'string' &&
567-
(msg.message.content.includes(`<${LOCAL_COMMAND_STDOUT_TAG}>`) ||
568-
msg.message.content.includes(`<${LOCAL_COMMAND_STDERR_TAG}>`) ||
566+
typeof msg.message!.content === 'string' &&
567+
(msg.message!.content.includes(`<${LOCAL_COMMAND_STDOUT_TAG}>`) ||
568+
msg.message!.content.includes(`<${LOCAL_COMMAND_STDERR_TAG}>`) ||
569569
msg.isCompactSummary)
570570
) {
571571
yield {
572572
type: 'user',
573573
message: {
574574
...msg.message,
575-
content: stripAnsi(msg.message.content),
575+
content: stripAnsi(msg.message!.content),
576576
},
577577
session_id: getSessionId(),
578578
parent_tool_use_id: null,
@@ -1089,7 +1089,7 @@ export class QueryEngine {
10891089
const edeResultType = result?.type ?? 'undefined'
10901090
const edeLastContentType =
10911091
result?.type === 'assistant'
1092-
? (last(result.message.content)?.type ?? 'none')
1092+
? (last(result.message!.content as import('@anthropic-ai/sdk/resources/beta/messages/messages.js').BetaContentBlock[])?.type ?? 'none')
10931093
: 'n/a'
10941094

10951095
// Flush buffered transcript writes before yielding result.
@@ -1147,7 +1147,7 @@ export class QueryEngine {
11471147
let isApiError = false
11481148

11491149
if (result.type === 'assistant') {
1150-
const lastContent = last(result.message.content)
1150+
const lastContent = last(result.message!.content as import('@anthropic-ai/sdk/resources/beta/messages/messages.js').BetaContentBlock[])
11511151
if (
11521152
lastContent?.type === 'text' &&
11531153
!SYNTHETIC_MESSAGES.has(lastContent.text)

src/bootstrap/state.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1429,7 +1429,7 @@ export function registerHookCallbacks(
14291429
if (!STATE.registeredHooks[eventKey]) {
14301430
STATE.registeredHooks[eventKey] = []
14311431
}
1432-
STATE.registeredHooks[eventKey]!.push(...matchers)
1432+
STATE.registeredHooks[eventKey]!.push(...(matchers ?? []))
14331433
}
14341434
}
14351435

@@ -1451,7 +1451,7 @@ export function clearRegisteredPluginHooks(): void {
14511451
const filtered: Partial<Record<HookEvent, RegisteredHookMatcher[]>> = {}
14521452
for (const [event, matchers] of Object.entries(STATE.registeredHooks)) {
14531453
// Keep only callback hooks (those without pluginRoot)
1454-
const callbackHooks = matchers.filter(m => !('pluginRoot' in m))
1454+
const callbackHooks = (matchers ?? []).filter(m => !('pluginRoot' in m))
14551455
if (callbackHooks.length > 0) {
14561456
filtered[event as HookEvent] = callbackHooks
14571457
}

src/bridge/bridgeMessaging.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,12 @@ export function extractTitleText(m: Message): string | undefined {
105105
if (m.type !== 'user' || m.isMeta || m.toolUseResult || m.isCompactSummary)
106106
return undefined
107107
if (m.origin && (m.origin as { kind?: string }).kind !== 'human') return undefined
108-
const content = m.message.content
108+
const content = m.message!.content
109109
let raw: string | undefined
110110
if (typeof content === 'string') {
111111
raw = content
112112
} else {
113-
for (const block of content) {
113+
for (const block of content ?? []) {
114114
if (block.type === 'text') {
115115
raw = block.text
116116
break

src/bridge/initReplBridge.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
waitForPolicyLimitsToLoad,
2626
} from '../services/policyLimits/index.js'
2727
import type { Message } from '../types/message.js'
28+
import type { ContentBlockParam } from '@anthropic-ai/sdk/resources/index.js'
2829
import {
2930
checkAndRefreshOAuthTokenIfNeeded,
3031
getClaudeAIOAuthTokens,
@@ -289,7 +290,7 @@ export async function initReplBridge(
289290
isSyntheticMessage(msg)
290291
)
291292
continue
292-
const rawContent = getContentText(msg.message.content)
293+
const rawContent = getContentText(msg.message!.content as string | ContentBlockParam[])
293294
if (!rawContent) continue
294295
const derived = deriveTitle(rawContent)
295296
if (!derived) continue

src/buddy/prompt.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ export function getCompanionIntroAttachment(
2222
// Skip if already announced for this companion.
2323
for (const msg of messages ?? []) {
2424
if (msg.type !== 'attachment') continue
25-
if (msg.attachment.type !== 'companion_intro') continue
26-
if (msg.attachment.name === companion.name) return []
25+
if (msg.attachment!.type !== 'companion_intro') continue
26+
if (msg.attachment!.name === companion.name) return []
2727
}
2828

2929
return [

0 commit comments

Comments
 (0)