Skip to content

Commit cc21c3b

Browse files
committed
fix build errors and use semver library
1 parent 5274436 commit cc21c3b

File tree

8 files changed

+123
-273
lines changed

8 files changed

+123
-273
lines changed

apps/dojo/src/app/api/copilotkitnext/[integrationId]/[[...slug]]/route.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
import { handle } from "hono/vercel";
77
import type { NextRequest } from "next/server";
88
import { BasicAgent } from "@copilotkitnext/agent";
9+
import type { AbstractAgent } from "@ag-ui/client";
910

1011
type RouteParams = {
1112
params: Promise<{
@@ -22,11 +23,13 @@ function getHandler(integrationId: string) {
2223
return cached;
2324
}
2425

26+
const defaultAgent = new BasicAgent({
27+
model: "openai/gpt-4o",
28+
}) as unknown as AbstractAgent; // Cast until upstream marks run() public.
29+
2530
const runtime = new CopilotRuntime({
2631
agents: {
27-
default: new BasicAgent({
28-
model: "openai/gpt-4o",
29-
}),
32+
default: defaultAgent,
3033
},
3134
runner: new InMemoryAgentRunner(),
3235
});

integrations/a2a/typescript/src/agent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export class A2AAgent extends AbstractAgent {
5050
return new A2AAgent({ a2aClient: this.a2aClient, debug: this.debug });
5151
}
5252

53-
protected run(input: RunAgentInput): Observable<BaseEvent> {
53+
public override run(input: RunAgentInput): Observable<BaseEvent> {
5454
return new Observable<BaseEvent>((subscriber) => {
5555
const run = async () => {
5656
const runStarted: RunStartedEvent = {

integrations/mastra/typescript/examples/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ output.txt
22
node_modules
33
dist
44
.mastra
5+
.npm-cache
56
.env.development
67
.env
78
*.db

pnpm-lock.yaml

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

sdks/typescript/packages/client/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@
2525
},
2626
"dependencies": {
2727
"@ag-ui/core": "workspace:*",
28-
"@ag-ui/proto": "workspace:*",
2928
"@ag-ui/encoder": "workspace:*",
29+
"@ag-ui/proto": "workspace:*",
3030
"@types/uuid": "^10.0.0",
31+
"compare-versions": "^6.1.1",
3132
"fast-json-patch": "^3.1.1",
3233
"rxjs": "7.8.1",
3334
"untruncate-json": "^0.0.1",

sdks/typescript/packages/client/src/__tests__/parse-semver.test.ts

Lines changed: 0 additions & 44 deletions
This file was deleted.

sdks/typescript/packages/client/src/agent/agent.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import { Message, State, RunAgentInput, BaseEvent, ToolCall, AssistantMessage }
33

44
import { AgentConfig, RunAgentParameters } from "./types";
55
import { v4 as uuidv4 } from "uuid";
6-
import { structuredClone_, parseSemanticVersion } from "@/utils";
6+
import { structuredClone_ } from "@/utils";
7+
import { compareVersions } from "compare-versions";
78
import { catchError, map, tap } from "rxjs/operators";
89
import { finalize } from "rxjs/operators";
910
import { pipe, Observable, from, of, EMPTY } from "rxjs";
@@ -57,9 +58,7 @@ export abstract class AbstractAgent {
5758
this.state = structuredClone_(initialState ?? {});
5859
this.debug = debug ?? false;
5960

60-
const parsedMaxVersion = parseSemanticVersion(this.maxVersion);
61-
62-
if (parsedMaxVersion.compare(parseSemanticVersion("0.0.39")) <= 0) {
61+
if (compareVersions(this.maxVersion, "0.0.39") <= 0) {
6362
this.middlewares.unshift(new BackwardCompatibility_0_0_39());
6463
}
6564
}

sdks/typescript/packages/client/src/utils.ts

Lines changed: 3 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -20,117 +20,14 @@ export function randomUUID(): string {
2020
return uuidv4();
2121
}
2222

23-
export interface ParsedSemanticVersion {
24-
major: number;
25-
minor: number;
26-
patch: number;
27-
prerelease: string[];
28-
build: string[];
29-
source: string;
30-
compare(other: ParsedSemanticVersion): number;
31-
}
23+
// Note: semver helpers were removed in favor of using
24+
// the external `compare-versions` library directly at call sites.
3225

33-
const SEMVER_PATTERN =
34-
/^(?<major>0|[1-9]\d*)(?:\.(?<minor>0|[1-9]\d*)(?:\.(?<patch>0|[1-9]\d*))?)?(?:-(?<prerelease>(?:0|[1-9A-Za-z-][0-9A-Za-z-]*)(?:\.(?:0|[1-9A-Za-z-][0-9A-Za-z-]*))*))?(?:\+(?<build>[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?$/;
35-
const NUMERIC_IDENTIFIER_PATTERN = /^\d+$/;
3626

3727
/**
3828
* Parses a semantic version string into its numeric components.
3929
* Supports incomplete versions (e.g. "1", "1.2") by defaulting missing segments to zero.
4030
*
4131
* @throws If the version string is not a valid semantic version.
4232
*/
43-
export function parseSemanticVersion(version: string): ParsedSemanticVersion {
44-
const trimmed = version.trim();
45-
46-
if (trimmed.length === 0) {
47-
throw new Error("Semantic version cannot be empty");
48-
}
49-
50-
const match = SEMVER_PATTERN.exec(trimmed);
51-
if (!match || !match.groups?.major) {
52-
throw new Error(`Invalid semantic version: "${version}"`);
53-
}
54-
55-
const major = Number.parseInt(match.groups.major, 10);
56-
const minor = match.groups.minor ? Number.parseInt(match.groups.minor, 10) : 0;
57-
const patch = match.groups.patch ? Number.parseInt(match.groups.patch, 10) : 0;
58-
const prerelease = match.groups.prerelease ? match.groups.prerelease.split(".") : [];
59-
const build = match.groups.build ? match.groups.build.split(".") : [];
60-
61-
const parsed: ParsedSemanticVersion = {
62-
major,
63-
minor,
64-
patch,
65-
prerelease,
66-
build,
67-
source: version,
68-
compare(this: ParsedSemanticVersion, other: ParsedSemanticVersion): number {
69-
if (this.major !== other.major) {
70-
return this.major - other.major;
71-
}
72-
73-
if (this.minor !== other.minor) {
74-
return this.minor - other.minor;
75-
}
76-
77-
if (this.patch !== other.patch) {
78-
return this.patch - other.patch;
79-
}
80-
81-
if (this.prerelease.length === 0 && other.prerelease.length === 0) {
82-
return 0;
83-
}
84-
85-
if (this.prerelease.length === 0) {
86-
return 1;
87-
}
88-
89-
if (other.prerelease.length === 0) {
90-
return -1;
91-
}
92-
93-
const length = Math.max(this.prerelease.length, other.prerelease.length);
94-
for (let index = 0; index < length; index++) {
95-
const aIdentifier = this.prerelease[index];
96-
const bIdentifier = other.prerelease[index];
97-
98-
if (aIdentifier === undefined) {
99-
return -1;
100-
}
101-
102-
if (bIdentifier === undefined) {
103-
return 1;
104-
}
105-
106-
const aIsNumeric = NUMERIC_IDENTIFIER_PATTERN.test(aIdentifier);
107-
const bIsNumeric = NUMERIC_IDENTIFIER_PATTERN.test(bIdentifier);
108-
109-
if (aIsNumeric && bIsNumeric) {
110-
const diff = Number(aIdentifier) - Number(bIdentifier);
111-
if (diff !== 0) {
112-
return diff;
113-
}
114-
continue;
115-
}
116-
117-
if (aIsNumeric) {
118-
return -1;
119-
}
120-
121-
if (bIsNumeric) {
122-
return 1;
123-
}
124-
125-
const lexicalComparison = aIdentifier.localeCompare(bIdentifier);
126-
if (lexicalComparison !== 0) {
127-
return lexicalComparison;
128-
}
129-
}
130-
131-
return 0;
132-
},
133-
};
134-
135-
return parsed;
136-
}
33+
// (Intentionally left minimal.)

0 commit comments

Comments
 (0)