build: enable modern TypeScript module syntax · openclaw/openclaw@bbc1772
steipete
·
2026-05-25
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -2,7 +2,8 @@ import fs from "node:fs/promises";
|
2 | 2 | import { stringEnum } from "openclaw/plugin-sdk/channel-actions"; |
3 | 3 | import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime"; |
4 | 4 | import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime"; |
5 | | -import { Static, Type } from "typebox"; |
| 5 | +import { Type } from "typebox"; |
| 6 | +import type { Static } from "typebox"; |
6 | 7 | import type { AnyAgentTool, OpenClawPluginApi, OpenClawPluginToolContext } from "../api.js"; |
7 | 8 | import { PlaywrightDiffScreenshotter, type DiffScreenshotter } from "./browser.js"; |
8 | 9 | import { resolveDiffImageRenderOptions } from "./config.js"; |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | import type { DiscordGatewayHandle } from "./monitor/gateway-handle.js"; |
2 | | -import { |
| 2 | +import { DiscordGatewayLifecycleError } from "./monitor/gateway-supervisor.js"; |
| 3 | +import type { |
3 | 4 | DiscordGatewayEvent, |
4 | | -DiscordGatewayLifecycleError, |
5 | 5 | DiscordGatewaySupervisor, |
6 | 6 | } from "./monitor/gateway-supervisor.js"; |
7 | 7 | |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -26,10 +26,7 @@ const { undiciFetchMock, agentSpy, envHttpProxyAgentSpy, proxyAgentSpy, createMo
|
26 | 26 | ("httpsProxy" in options || "httpProxy" in options) |
27 | 27 | ) { |
28 | 28 | const proxyOptions = options as { httpsProxy?: unknown; httpProxy?: unknown }; |
29 | | -if ( |
30 | | -proxyOptions.httpsProxy === "bad-proxy" || |
31 | | -proxyOptions.httpProxy === "bad-proxy" |
32 | | -) { |
| 29 | +if (proxyOptions.httpsProxy === "bad-proxy" || proxyOptions.httpProxy === "bad-proxy") { |
33 | 30 | throw new Error("bad env proxy"); |
34 | 31 | } |
35 | 32 | } |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | import { |
2 | 2 | definePluginEntry, |
3 | | -OpenClawConfig, |
4 | 3 | type OpenClawPluginApi, |
5 | 4 | type ProviderAuthContext, |
6 | 5 | type ProviderAuthMethodNonInteractiveContext, |
7 | 6 | type ProviderAuthResult, |
8 | 7 | type ProviderRuntimeModel, |
9 | 8 | } from "openclaw/plugin-sdk/plugin-entry"; |
| 9 | +import type { OpenClawConfig } from "openclaw/plugin-sdk/plugin-entry"; |
10 | 10 | import { CUSTOM_LOCAL_AUTH_MARKER } from "openclaw/plugin-sdk/provider-auth"; |
11 | 11 | import { lmstudioMemoryEmbeddingProviderAdapter } from "./memory-embedding-adapter.js"; |
12 | 12 | import { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -14,6 +14,8 @@ export type MatrixLegacyCryptoInspectionResult = {
|
14 | 14 | decryptionKeyBase64: string | null; |
15 | 15 | }; |
16 | 16 | |
| 17 | +const MATRIX_CRYPTO_STORE_SQLITE = 0; |
| 18 | + |
17 | 19 | function resolveLegacyMachineStorePath(params: { |
18 | 20 | cryptoRootDir: string; |
19 | 21 | deviceId: string; |
@@ -56,15 +58,15 @@ export async function inspectLegacyMatrixCryptoStore(params: {
|
56 | 58 | log: params.log, |
57 | 59 | }); |
58 | 60 | |
59 | | -const { DeviceId, OlmMachine, StoreType, UserId } = requireFn( |
| 61 | +const { DeviceId, OlmMachine, UserId } = requireFn( |
60 | 62 | "@matrix-org/matrix-sdk-crypto-nodejs", |
61 | 63 | ) as typeof import("@matrix-org/matrix-sdk-crypto-nodejs"); |
62 | 64 | const machine = await OlmMachine.initialize( |
63 | 65 | new UserId(params.userId), |
64 | 66 | new DeviceId(params.deviceId), |
65 | 67 | machineStorePath, |
66 | 68 | "", |
67 | | -StoreType.Sqlite, |
| 69 | +MATRIX_CRYPTO_STORE_SQLITE, |
68 | 70 | ); |
69 | 71 | |
70 | 72 | try { |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | | -import { |
2 | | -ParseErrorCode, |
3 | | -type ParseError, |
4 | | -parseTree, |
5 | | -printParseErrorCode, |
6 | | -} from "jsonc-parser/lib/esm/main.js"; |
| 1 | +import { type ParseError, parseTree, printParseErrorCode } from "jsonc-parser/lib/esm/main.js"; |
7 | 2 | import type { Diagnostic } from "../ast.js"; |
8 | 3 | import type { JsoncAst, JsoncEntry, JsoncValue } from "./ast.js"; |
9 | 4 | |
@@ -24,6 +19,8 @@ export const MAX_PARSE_DEPTH = 256;
|
24 | 19 | * supported configuration. |
25 | 20 | */ |
26 | 21 | export const MAX_JSONC_INPUT_BYTES = 16 * 1024 * 1024; |
| 22 | +const JSONC_PARSE_INVALID_SYMBOL = 1; |
| 23 | +const JSONC_PARSE_END_OF_FILE_EXPECTED = 9; |
27 | 24 | |
28 | 25 | export interface JsoncParseResult { |
29 | 26 | readonly ast: JsoncAst; |
@@ -104,9 +101,10 @@ function toDiagnostic(
|
104 | 101 | tree: JsoncParserNode | undefined, |
105 | 102 | ): Diagnostic { |
106 | 103 | const treeEnd = tree ? tree.offset + tree.length : 0; |
| 104 | +const errorCode: number = error.error; |
107 | 105 | const isTrailingInput = |
108 | | -error.error === ParseErrorCode.EndOfFileExpected || |
109 | | -(tree !== undefined && error.error === ParseErrorCode.InvalidSymbol && error.offset >= treeEnd); |
| 106 | +errorCode === JSONC_PARSE_END_OF_FILE_EXPECTED || |
| 107 | +(tree !== undefined && errorCode === JSONC_PARSE_INVALID_SYMBOL && error.offset >= treeEnd); |
110 | 108 | return { |
111 | 109 | line: lineMap.lineForOffset(error.offset), |
112 | 110 | message: printParseErrorCode(error.error), |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | import type { ChannelRuntimeSurface } from "openclaw/plugin-sdk/channel-contract"; |
2 | | -import { Mock, vi } from "vitest"; |
| 2 | +import { vi } from "vitest"; |
| 3 | +import type { Mock } from "vitest"; |
3 | 4 | import { clearSlackInboundDeliveryStateForTest } from "./monitor/inbound-delivery-state.js"; |
4 | 5 | |
5 | 6 | type SlackHandler = (args: unknown) => Promise<void>; |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -69,10 +69,8 @@ import type {
|
69 | 69 | TelegramMessageContextOptions, |
70 | 70 | TelegramPromptContextEntry, |
71 | 71 | } from "./bot-message-context.types.js"; |
72 | | -import { |
73 | | -parseTelegramNativeCommandCallbackData, |
74 | | -RegisterTelegramHandlerParams, |
75 | | -} from "./bot-native-commands.js"; |
| 72 | +import { parseTelegramNativeCommandCallbackData } from "./bot-native-commands.js"; |
| 73 | +import type { RegisterTelegramHandlerParams } from "./bot-native-commands.js"; |
76 | 74 | import { |
77 | 75 | MEDIA_GROUP_TIMEOUT_MS, |
78 | 76 | type MediaGroupEntry, |
@@ -1315,8 +1313,11 @@ export const registerTelegramHandlers = ({
|
1315 | 1313 | }; |
1316 | 1314 | |
1317 | 1315 | class TelegramRetryableCallbackError extends Error { |
1318 | | -constructor(public override readonly cause: unknown) { |
| 1316 | +public override readonly cause: unknown; |
| 1317 | + |
| 1318 | +constructor(cause: unknown) { |
1319 | 1319 | super(String(cause)); |
| 1320 | +this.cause = cause; |
1320 | 1321 | this.name = "TelegramRetryableCallbackError"; |
1321 | 1322 | } |
1322 | 1323 | } |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -64,7 +64,7 @@ import {
|
64 | 64 | syncTelegramMenuCommands as syncTelegramMenuCommandsRuntime, |
65 | 65 | type TelegramMenuCommand, |
66 | 66 | } from "./bot-native-command-menu.js"; |
67 | | -import { TelegramUpdateKeyContext } from "./bot-updates.js"; |
| 67 | +import type { TelegramUpdateKeyContext } from "./bot-updates.js"; |
68 | 68 | import type { TelegramBotOptions } from "./bot.types.js"; |
69 | 69 | import { |
70 | 70 | buildTelegramRoutingTarget, |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -6,7 +6,6 @@ import { WhatsAppRetryableInboundError } from "./inbound/dedupe.js";
|
6 | 6 | import { WHATSAPP_GROUP_METADATA_CACHE_MAX_ENTRIES } from "./inbound/monitor.js"; |
7 | 7 | import { |
8 | 8 | type InboxMonitorOptions, |
9 | | -InboxOnMessage, |
10 | 9 | buildNotifyMessageUpsert, |
11 | 10 | failNextWhatsAppPluginStateRegisterIfAbsent, |
12 | 11 | getAuthDir, |
@@ -17,6 +16,7 @@ import {
|
17 | 16 | startInboxMonitor, |
18 | 17 | waitForMessageCalls, |
19 | 18 | } from "./monitor-inbox.test-harness.js"; |
| 19 | +import type { InboxOnMessage } from "./monitor-inbox.test-harness.js"; |
20 | 20 | |
21 | 21 | const { sleepWithAbortMock } = vi.hoisted(() => ({ |
22 | 22 | sleepWithAbortMock: vi.fn(async (_ms: number, _signal?: AbortSignal) => undefined), |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。