Skip to content

Commit ff03fe7

Browse files
fix: 修复类型问题
1 parent e70319e commit ff03fe7

18 files changed

Lines changed: 70 additions & 56 deletions

File tree

packages/@ant/ink/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// ============================================================
1313
export { default as wrappedRender, renderSync, createRoot } from './core/root.js'
1414
export type { RenderOptions, Instance, Root } from './core/root.js'
15-
15+
export * from './theme/theme-types.js'
1616
// InkCore class
1717
export { default as Ink } from './core/ink.js'
1818

src/cli/print.ts

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2256,7 +2256,7 @@ function runHeadlessStreaming(
22562256
{ turnStartTime } as import('src/utils/filePersistence/types.js').TurnStartTime,
22572257
abortController.signal,
22582258
result => {
2259-
const filesResult = result as { persistedFiles: { filename: string; file_id: string }[]; failedFiles: { filename: string; error: string }[] }
2259+
const filesResult = result as unknown as { persistedFiles: { filename: string; file_id: string }[]; failedFiles: { filename: string; error: string }[] }
22602260
output.enqueue({
22612261
type: 'system' as const,
22622262
subtype: 'files_persisted' as const,
@@ -3315,7 +3315,7 @@ function runHeadlessStreaming(
33153315
output,
33163316
)
33173317
} else if (req.subtype === 'mcp_authenticate') {
3318-
const { serverName } = req
3318+
const serverName = req.serverName as string
33193319
const currentAppState = getAppState()
33203320
const config =
33213321
getMcpConfigByName(serverName) ??
@@ -3333,9 +3333,9 @@ function runHeadlessStreaming(
33333333
} else {
33343334
try {
33353335
// Abort any previous in-flight OAuth flow for this server
3336-
activeOAuthFlows.get(serverName)?.abort()
3336+
activeOAuthFlows.get(serverName as string)?.abort()
33373337
const controller = new AbortController()
3338-
activeOAuthFlows.set(serverName, controller)
3338+
activeOAuthFlows.set(serverName as string, controller)
33393339

33403340
// Capture the auth URL from the callback
33413341
let resolveAuthUrl: (url: string) => void
@@ -3345,14 +3345,14 @@ function runHeadlessStreaming(
33453345

33463346
// Start the OAuth flow in the background
33473347
const oauthPromise = performMCPOAuthFlow(
3348-
serverName,
3348+
serverName as string,
33493349
config,
33503350
url => resolveAuthUrl!(url),
33513351
controller.signal,
33523352
{
33533353
skipBrowserOpen: true,
33543354
onWaitingForCallback: submit => {
3355-
oauthCallbackSubmitters.set(serverName, submit)
3355+
oauthCallbackSubmitters.set(serverName as string, submit)
33563356
},
33573357
},
33583358
)
@@ -3386,27 +3386,27 @@ function runHeadlessStreaming(
33863386
const fullFlowPromise = oauthPromise
33873387
.then(async () => {
33883388
// Don't reconnect if the server was disabled during the OAuth flow
3389-
if (isMcpServerDisabled(serverName)) {
3389+
if (isMcpServerDisabled(serverName as string)) {
33903390
return
33913391
}
33923392
// Skip reconnect if the manual callback path was used —
33933393
// handleAuthDone will do it via mcp_reconnect (which
33943394
// updates dynamicMcpState for tool registration).
3395-
if (oauthManualCallbackUsed.has(serverName)) {
3395+
if (oauthManualCallbackUsed.has(serverName as string)) {
33963396
return
33973397
}
33983398
// Reconnect the server after successful auth
33993399
const result = await reconnectMcpServerImpl(
3400-
serverName,
3400+
serverName as string,
34013401
config,
34023402
)
3403-
const prefix = getMcpPrefix(serverName)
3403+
const prefix = getMcpPrefix(serverName as string)
34043404
setAppState(prev => ({
34053405
...prev,
34063406
mcp: {
34073407
...prev.mcp,
34083408
clients: prev.mcp.clients.map(c =>
3409-
c.name === serverName ? result.client : c,
3409+
c.name === serverName as string ? result.client : c,
34103410
),
34113411
tools: [
34123412
...reject(prev.mcp.tools, t =>
@@ -3416,17 +3416,17 @@ function runHeadlessStreaming(
34163416
],
34173417
commands: [
34183418
...reject(prev.mcp.commands, c =>
3419-
commandBelongsToServer(c, serverName),
3419+
commandBelongsToServer(c, serverName as string),
34203420
),
34213421
...result.commands,
34223422
],
34233423
resources:
34243424
result.resources && result.resources.length > 0
34253425
? {
34263426
...prev.mcp.resources,
3427-
[serverName]: result.resources,
3427+
[serverName as string]: result.resources,
34283428
}
3429-
: omit(prev.mcp.resources, serverName),
3429+
: omit(prev.mcp.resources, serverName as string),
34303430
},
34313431
}))
34323432
// Also update dynamicMcpState so run() picks up the new tools
@@ -3449,17 +3449,17 @@ function runHeadlessStreaming(
34493449
})
34503450
.catch(error => {
34513451
logForDebugging(
3452-
`MCP OAuth failed for ${serverName}: ${error}`,
3452+
`MCP OAuth failed for ${serverName as string}: ${error}`,
34533453
{ level: 'error' },
34543454
)
34553455
})
34563456
.finally(() => {
34573457
// Clean up only if this is still the active flow
3458-
if (activeOAuthFlows.get(serverName) === controller) {
3459-
activeOAuthFlows.delete(serverName)
3460-
oauthCallbackSubmitters.delete(serverName)
3461-
oauthManualCallbackUsed.delete(serverName)
3462-
oauthAuthPromises.delete(serverName)
3458+
if (activeOAuthFlows.get(serverName as string) === controller) {
3459+
activeOAuthFlows.delete(serverName as string)
3460+
oauthCallbackSubmitters.delete(serverName as string)
3461+
oauthManualCallbackUsed.delete(serverName as string)
3462+
oauthAuthPromises.delete(serverName as string)
34633463
}
34643464
})
34653465
void fullFlowPromise
@@ -3468,7 +3468,8 @@ function runHeadlessStreaming(
34683468
}
34693469
}
34703470
} else if (req.subtype === 'mcp_oauth_callback_url') {
3471-
const { serverName, callbackUrl } = req
3471+
const serverName = req.serverName as string
3472+
const callbackUrl = req.callbackUrl as string
34723473
const submit = oauthCallbackSubmitters.get(serverName)
34733474
if (submit) {
34743475
// Validate the callback URL before submitting. The submit
@@ -3477,7 +3478,7 @@ function runHeadlessStreaming(
34773478
// block the control message loop until timeout.
34783479
let hasCodeOrError = false
34793480
try {
3480-
const parsed = new URL(callbackUrl)
3481+
const parsed = new URL(callbackUrl as string | URL)
34813482
hasCodeOrError =
34823483
parsed.searchParams.has('code') ||
34833484
parsed.searchParams.has('error')
@@ -3491,7 +3492,7 @@ function runHeadlessStreaming(
34913492
)
34923493
} else {
34933494
oauthManualCallbackUsed.add(serverName)
3494-
submit(callbackUrl)
3495+
submit(callbackUrl as string)
34953496
// Wait for auth (token exchange) to complete before responding.
34963497
// Reconnect is handled by the extension via handleAuthDone →
34973498
// mcp_reconnect (which updates dynamicMcpState for tools).
@@ -3524,7 +3525,7 @@ function runHeadlessStreaming(
35243525
// both URLs and wait. Automatic URL → localhost listener catches
35253526
// the redirect if the browser is on this host; manual URL → the
35263527
// success page shows "code#state" for claude_oauth_callback.
3527-
const { loginWithClaudeAi } = req
3528+
const loginWithClaudeAi = req.loginWithClaudeAi as boolean | undefined
35283529

35293530
// Clean up any prior flow. cleanup() closes the localhost listener
35303531
// and nulls the manual resolver. The prior `flow` promise is left
@@ -3534,7 +3535,7 @@ function runHeadlessStreaming(
35343535
claudeOAuth?.service.cleanup()
35353536

35363537
logEvent('tengu_oauth_flow_start', {
3537-
loginWithClaudeAi: loginWithClaudeAi ?? true,
3538+
loginWithClaudeAi: (loginWithClaudeAi ?? true) as boolean | number,
35383539
})
35393540

35403541
const service = new OAuthService()
@@ -3557,7 +3558,7 @@ function runHeadlessStreaming(
35573558
urlResolver({ manualUrl, automaticUrl: automaticUrl! })
35583559
},
35593560
{
3560-
loginWithClaudeAi: loginWithClaudeAi ?? true,
3561+
loginWithClaudeAi: (loginWithClaudeAi ?? true) as boolean,
35613562
skipBrowserOpen: true,
35623563
},
35633564
)
@@ -3569,7 +3570,7 @@ function runHeadlessStreaming(
35693570
// next API call re-reads keychain/file and works. No respawn.
35703571
await installOAuthTokens(tokens)
35713572
logEvent('tengu_oauth_success', {
3572-
loginWithClaudeAi: loginWithClaudeAi ?? true,
3573+
loginWithClaudeAi: (loginWithClaudeAi ?? true) as boolean | number,
35733574
})
35743575
})
35753576
.finally(() => {
@@ -3656,7 +3657,7 @@ function runHeadlessStreaming(
36563657
)
36573658
}
36583659
} else if (req.subtype === 'mcp_clear_auth') {
3659-
const { serverName } = req
3660+
const serverName = req.serverName as string
36603661
const currentAppState = getAppState()
36613662
const config =
36623663
getMcpConfigByName(serverName) ??
@@ -3680,7 +3681,7 @@ function runHeadlessStreaming(
36803681
mcp: {
36813682
...prev.mcp,
36823683
clients: prev.mcp.clients.map(c =>
3683-
c.name === serverName ? result.client : c,
3684+
c.name === serverName as string ? result.client : c,
36843685
),
36853686
tools: [
36863687
...reject(prev.mcp.tools, t => t.name?.startsWith(prefix)),
@@ -3791,7 +3792,8 @@ function runHeadlessStreaming(
37913792
// Fire-and-forget so the Haiku call does not block the stdin loop
37923793
// (which would delay processing of subsequent user messages /
37933794
// interrupts for the duration of the API roundtrip).
3794-
const { description, persist } = req
3795+
const description = req.description as string
3796+
const persist = req.persist as boolean
37953797
// Reuse the live controller only if it has not already been aborted
37963798
// (e.g. by interrupt()); an aborted signal would cause queryHaiku to
37973799
// immediately throw APIUserAbortError → {title: null}.
@@ -3835,7 +3837,7 @@ function runHeadlessStreaming(
38353837
// matches in the common case. May still miss the cache for
38363838
// coordinator mode or memory-mechanics extras — acceptable, the
38373839
// alternative is the side question failing entirely.
3838-
const { question } = req
3840+
const question = req.question as string
38393841
void (async () => {
38403842
try {
38413843
const saved = getLastCacheSafeParams()

src/cli/structuredIO.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ export class StructuredIO {
679679
{
680680
subtype: 'hook_callback',
681681
callback_id: callbackId,
682-
input: input as Parameters<HookCallback['callback']>[0],
682+
input: input as any,
683683
tool_use_id: toolUseID || undefined,
684684
},
685685
hookJSONOutputSchema(),

src/components/BuiltinStatusLine.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ function BuiltinStatusLineInner({
8181
const tokenDisplay = `${formatTokens(usedTokens)}/${formatTokens(contextWindowSize)}`;
8282

8383
return (
84-
<Box wrap="truncate">
84+
<Box>
8585
{/* Model name */}
8686
<Text>{shortModel}</Text>
8787

src/components/PromptInput/PromptInputFooterSuggestions.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ const SuggestionItemRow = memo(function SuggestionItemRow({
163163
{paddedDisplayText}
164164
</Text>
165165
{tagText ? (
166-
<Text color={item.tag === 'local' ? ('yellow' as const) : undefined} dimColor={item.tag !== 'local'}>
166+
<Text color={item.tag === 'local' ? 'ansi:yellow' : undefined} dimColor={item.tag !== 'local'}>
167167
{tagText}
168168
</Text>
169169
) : null}

src/components/skills/SkillsMenu.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
type PromptCommand,
1010
} from '../../commands.js'
1111
import { Box, Text } from '@anthropic/ink'
12+
import type { Theme } from '@anthropic/ink'
1213
import {
1314
estimateSkillFrontmatterTokens,
1415
getSkillsPath,
@@ -140,7 +141,7 @@ export function SkillsMenu({ onExit, commands }: Props): React.ReactNode {
140141
}
141142

142143
const getScopeTag = (
143-
source: SkillSource,
144+
source: string,
144145
): { label: string; color: string } | undefined => {
145146
switch (source) {
146147
case 'projectSettings':
@@ -169,6 +170,7 @@ export function SkillsMenu({ onExit, commands }: Props): React.ReactNode {
169170
<Text>{getCommandName(skill)}</Text>
170171
{scopeTag && (
171172
<Text color={scopeTag.color as keyof Theme}> [{scopeTag.label}]</Text>
173+
172174
)}
173175
<Text dimColor>
174176
{pluginName ? ` · ${pluginName}` : ''} · {tokenDisplay} description

src/components/tasks/RemoteSessionDetailDialog.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import {
2929
formatReviewStageCounts,
3030
RemoteSessionProgress,
3131
} from './RemoteSessionProgress.js'
32+
import { AssistantMessage } from 'src/types/message.js'
3233

3334
type Props = {
3435
session: DeepImmutable<RemoteAgentTaskState>
@@ -122,7 +123,7 @@ function UltraplanSessionDetail({
122123
let lastBlock: { name: string; input: unknown } | null = null
123124
for (const msg of session.log) {
124125
if (msg.type !== 'assistant') continue
125-
const content = msg.message?.content ?? []
126+
const content = (msg.message as { content?: unknown[] })?.content ?? []
126127
for (const block of content as Array<{type: string; name: string; input: unknown}>) {
127128
if (block.type !== 'tool_use') continue
128129
calls++
@@ -612,7 +613,7 @@ export function RemoteSessionDetailDialog({
612613
{lastMessages.map((msg, i) => (
613614
<Message
614615
key={i}
615-
message={msg}
616+
message={msg as AssistantMessage}
616617
lookups={EMPTY_LOOKUPS}
617618
addMargin={i > 0}
618619
tools={toolUseContext.options.tools}

src/hooks/useReplBridge.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import {
4444
transitionPermissionMode,
4545
} from '../utils/permissions/permissionSetup.js'
4646
import { getLeaderToolUseConfirmQueue } from '../utils/swarm/leaderPermissionBridge.js'
47+
import { ContentBlockParam } from '@anthropic-ai/sdk/resources'
4748

4849
/** How long after a failure before replBridgeEnabled is auto-cleared (stops retries). */
4950
export const BRIDGE_FAILURE_DISMISS_MS = 10_000
@@ -226,7 +227,7 @@ export function useReplBridge(
226227
'../bridge/inboundAttachments.js'
227228
)
228229
const rawContent = fields.content
229-
let sanitized: string | Array<{ type: string; [key: string]: unknown }> = typeof rawContent === 'string' ? rawContent : rawContent as Array<{ type: string; [key: string]: unknown }>
230+
let sanitized: string | Array<{ type: string; [key: string]: unknown }> = typeof rawContent === 'string' ? rawContent : rawContent as unknown as Array<{ type: string; [key: string]: unknown }>
230231
if (feature('KAIROS_GITHUB_WEBHOOKS')) {
231232
/* eslint-disable @typescript-eslint/no-require-imports */
232233
const { sanitizeInboundWebhookContent } =
@@ -236,7 +237,7 @@ export function useReplBridge(
236237
sanitized = sanitizeInboundWebhookContent(sanitized)
237238
}
238239
}
239-
const content = await resolveAndPrepend(msg, sanitized)
240+
const content = await resolveAndPrepend(msg, sanitized as string | ContentBlockParam[])
240241

241242
const preview =
242243
typeof content === 'string'

src/hooks/useSSHSession.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export function useSSHSession({
9898
createToolStub(request.tool_name)
9999

100100
const syntheticMessage = createSyntheticAssistantMessage(
101-
request,
101+
request as unknown as Parameters<typeof createSyntheticAssistantMessage>[0],
102102
requestId,
103103
)
104104

src/services/api/gemini/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
normalizeContentFromAPI,
1515
normalizeMessagesForAPI,
1616
} from '../../../utils/messages.js'
17+
import type { SDKAssistantMessageError } from '../../../entrypoints/agentSdkTypes.js'
1718
import type { SystemPrompt } from '../../../utils/systemPromptType.js'
1819
import type { ThinkingConfig } from '../../../utils/thinking.js'
1920
import type { Options } from '../claude.js'
@@ -186,7 +187,7 @@ export async function* queryModelGemini(
186187
yield createAssistantAPIErrorMessage({
187188
content: `API Error: ${errorMessage}`,
188189
apiError: 'api_error',
189-
error: (error instanceof Error ? error : new Error(String(error))) as Error,
190+
error: (error instanceof Error ? error : new Error(String(error))) as unknown as SDKAssistantMessageError,
190191
})
191192
}
192193
}

0 commit comments

Comments
 (0)