Skip to content

Commit c88f3dd

Browse files
committed
✨: Enhance type imports across multiple files
Added new type imports for better typing and code reliability.
1 parent 7aebe25 commit c88f3dd

12 files changed

Lines changed: 49 additions & 12 deletions

packages/core/src/agent.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ import { HTMLEscape } from "./htmlescape.js";
99
import { prettifyMarkdown } from "./markdown.js";
1010
import { TraceOptions } from "./trace.js";
1111
import { ellipse } from "./util.js";
12-
import type { ChatGenerationContext, WorkspaceFileCache } from "./types.js";
12+
import type {
13+
ChatGenerationContext,
14+
ChatTurnGenerationContext,
15+
WorkspaceFileCache,
16+
} from "./types.js";
1317

1418
import debug from "debug";
1519
const dbg = debug("agent:memory");
@@ -50,7 +54,6 @@ export async function agentQueryMemory(
5054
cache: AgentMemoryCache,
5155
ctx: ChatGenerationContext,
5256
query: string,
53-
_options: Required<TraceOptions>,
5457
) {
5558
if (!query) return undefined;
5659

packages/core/src/annotations.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import { deleteUndefinedValues } from "./cleaners.js";
1111
import { EMOJI_FAIL, EMOJI_WARNING } from "./constants.js";
1212
import { unfence } from "./unwrappers.js";
13-
import type { Diagnostic } from "./types.js";
13+
import type { Diagnostic, DiagnosticSeverity } from "./types.js";
1414

1515
// Regular expression for matching GitHub Actions annotations.
1616
// Example: ::error file=foo.js,line=10,endLine=11::Something went wrong.
@@ -39,7 +39,7 @@ const GITHUB_MARKDOWN_WARNINGS_RX =
3939
// Example: src/connection.ts(71,5): error TS1128: Declaration or statement expected.
4040
// src/connection.ts(71,5): error TS1128: Declaration or statement expected.
4141
const TYPESCRIPT_PARENTHESES_ANNOTATIONS_RX =
42-
/^(?<file>[^\(\n]+)\((?<line>\d+),(?<col>\d+)\):\s+(?<severity>error|warning)\s+(?<code>TS\d+):\s+(?<message>.+)$/gim;
42+
/^(?<file>[^(\n]+)\((?<line>\d+),(?<col>\d+)\):\s+(?<severity>error|warning)\s+(?<code>TS\d+):\s+(?<message>.+)$/gim;
4343
const ANNOTATIONS_RX = [
4444
TYPESCRIPT_PARENTHESES_ANNOTATIONS_RX,
4545
TYPESCRIPT_ANNOTATIONS_RX,
@@ -187,6 +187,7 @@ export function convertGithubMarkdownAnnotationsToItems(text: string) {
187187
* @returns A formatted string representing the Diagnostic as a list item.
188188
*/
189189
export function convertAnnotationToItem(d: Diagnostic) {
190+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
190191
const { severity, message, filename, code, range } = d;
191192
const line = range?.[0]?.[0];
192193
return `- ${SEV_EMOJI_MAP[severity?.toLowerCase()] ?? "info"} ${message}${filename ? ` (\`${filename}${line ? `#L${line}` : ""}\`)` : ""}`;

packages/core/src/anthropic.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import { LanguageModelConfiguration } from "./server/messages.js";
4040
import { deleteUndefinedValues } from "./cleaners.js";
4141
import debug from "debug";
4242
import { providerFeatures } from "./features.js";
43+
import { LanguageModelInfo } from "./types.js";
4344
const dbg = debug("genaiscript:anthropic");
4445
const dbgMessages = debug("genaiscript:anthropic:msg");
4546

packages/core/src/ast.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4+
/// <reference types="./types/prompt_template.d.ts" />
45
// Import necessary regular expressions for file type detection and host utilities
56
import { GENAI_ANYJS_REGEX, GENAI_ANYTS_REGEX } from "./constants.js";
67
import { Project } from "./server/messages.js";

packages/core/src/azureaisearch.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ import { LanguageModelConfiguration } from "./server/messages.js";
1414
import { chunk } from "./encoders.js";
1515
import { genaiscriptDebug } from "./debug.js";
1616
import { SearchClient, SearchIndexClient, AzureKeyCredential } from "@azure/search-documents";
17+
import type {
18+
ElementOrArray,
19+
TextChunk,
20+
VectorIndexOptions,
21+
VectorSearchOptions,
22+
WorkspaceFile,
23+
WorkspaceFileIndex,
24+
WorkspaceFileWithScore,
25+
} from "./types.js";
1726

1827
const dbg = genaiscriptDebug("azureaisearch");
1928

packages/core/src/azuredevops.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ export async function azureDevOpsUpdatePullRequestDescription(
110110
// query pull request
111111
const pr = await findPullRequest(info);
112112
if (!pr) return;
113+
// eslint-disable-next-line prefer-const
113114
let { pullRequestId, description } = pr;
114115

115116
text = prettifyMarkdown(text);

packages/core/src/azureopenai.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const azureManagementListModels: ListModelsFunction = async (cfg, options) => {
3434
const { base } = cfg;
3535
const subscriptionId = process.env.AZURE_OPENAI_SUBSCRIPTION_ID;
3636
let resourceGroupName = process.env.AZURE_OPENAI_RESOURCE_GROUP;
37-
const accountName = /^https:\/\/([^\.]+)\./.exec(base)[1];
37+
const accountName = /^https:\/\/([^.]+)\./.exec(base)[1];
3838

3939
if (!subscriptionId || !accountName) {
4040
dbg("subscriptionId or accountName is missing, returning an empty model list");
@@ -78,7 +78,7 @@ const azureManagementListModels: ListModelsFunction = async (cfg, options) => {
7878
`https://management.azure.com/subscriptions/${subscriptionId}/resources?api-version=2021-04-01`,
7979
);
8080
const resource = resources.value.find((r) => r.name === accountName);
81-
resourceGroupName = /\/resourceGroups\/([^\/]+)\/providers\//.exec(resource?.id)[1];
81+
resourceGroupName = /\/resourceGroups\/([^/]+)\/providers\//.exec(resource?.id)[1];
8282
if (!resourceGroupName) {
8383
dbg("unable to extract resource group name from resource id");
8484
throw new Error("Resource group not found");

packages/core/src/azuretoken.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import {
2626
ManagedIdentityCredential,
2727
WorkloadIdentityCredential,
2828
} from "@azure/identity";
29+
import type { SerializedError } from "./types.js";
2930

3031
/**
3132
* This module provides functions to handle Azure authentication tokens,

packages/core/src/chat.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,18 @@ import type {
9797
TranscriptionResult,
9898
VectorIndexOptions,
9999
WorkspaceFileIndex,
100+
ChatMessage,
101+
DataFrame,
102+
Edits,
103+
ElementOrArray,
104+
Logprob,
105+
RunPromptUsage,
106+
ShellOutput,
107+
TokenEncoder,
108+
ToolCallContent,
109+
ToolCallContext,
110+
ToolCallOutput,
111+
WorkspaceFile,
100112
} from "./types.js";
101113

102114
const dbg = genaiscriptDebug("chat");

packages/core/src/mcpclient.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { dotGenaiscriptPath } from "./workdir.js";
1919
import { YAMLStringify } from "./yaml.js";
2020
import { resolvePromptInjectionDetector } from "./contentsafety.js";
2121
import { genaiscriptDebug } from "./debug.js";
22-
import type { JSONSchemaObject, McpClient, McpServerConfig, ToolCallback } from "./types.js";
22+
import type { McpClient, McpServerConfig, ToolCallback } from "./types.js";
2323
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
2424
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
2525

0 commit comments

Comments
 (0)