@agentuity/core 3.0.0-alpha.7 → 3.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/services/coder/client.d.ts +13 -1
- package/dist/services/coder/client.d.ts.map +1 -1
- package/dist/services/coder/client.js +22 -1
- package/dist/services/coder/client.js.map +1 -1
- package/dist/services/coder/protocol.d.ts +121 -5
- package/dist/services/coder/protocol.d.ts.map +1 -1
- package/dist/services/coder/protocol.js +117 -0
- package/dist/services/coder/protocol.js.map +1 -1
- package/dist/services/coder/types.d.ts +73 -0
- package/dist/services/coder/types.d.ts.map +1 -1
- package/dist/services/coder/types.js +83 -1
- package/dist/services/coder/types.js.map +1 -1
- package/dist/services/coder/workspaces.d.ts +11 -1
- package/dist/services/coder/workspaces.d.ts.map +1 -1
- package/dist/services/coder/workspaces.js +34 -1
- package/dist/services/coder/workspaces.js.map +1 -1
- package/dist/services/keyvalue/service.d.ts +9 -3
- package/dist/services/keyvalue/service.d.ts.map +1 -1
- package/dist/services/keyvalue/service.js +6 -3
- package/dist/services/keyvalue/service.js.map +1 -1
- package/dist/services/oauth/token-storage.d.ts +4 -1
- package/dist/services/oauth/token-storage.d.ts.map +1 -1
- package/dist/services/oauth/token-storage.js +4 -1
- package/dist/services/oauth/token-storage.js.map +1 -1
- package/dist/services/queue/service.d.ts +31 -33
- package/dist/services/queue/service.d.ts.map +1 -1
- package/dist/services/queue/service.js +13 -13
- package/dist/services/queue/service.js.map +1 -1
- package/dist/services/sandbox/api-reference.js +8 -8
- package/dist/services/sandbox/api-reference.js.map +1 -1
- package/dist/services/sandbox/client.d.ts +3 -2
- package/dist/services/sandbox/client.d.ts.map +1 -1
- package/dist/services/sandbox/client.js.map +1 -1
- package/dist/services/sandbox/create.d.ts +5 -0
- package/dist/services/sandbox/create.d.ts.map +1 -1
- package/dist/services/sandbox/create.js +8 -0
- package/dist/services/sandbox/create.js.map +1 -1
- package/dist/services/sandbox/get.d.ts +8 -4
- package/dist/services/sandbox/get.d.ts.map +1 -1
- package/dist/services/sandbox/get.js +28 -3
- package/dist/services/sandbox/get.js.map +1 -1
- package/dist/services/sandbox/getStatus.d.ts +3 -0
- package/dist/services/sandbox/getStatus.d.ts.map +1 -1
- package/dist/services/sandbox/getStatus.js +19 -2
- package/dist/services/sandbox/getStatus.js.map +1 -1
- package/dist/services/sandbox/index.d.ts +1 -1
- package/dist/services/sandbox/index.d.ts.map +1 -1
- package/dist/services/sandbox/list.d.ts +3 -0
- package/dist/services/sandbox/list.d.ts.map +1 -1
- package/dist/services/sandbox/list.js +5 -0
- package/dist/services/sandbox/list.js.map +1 -1
- package/dist/services/sandbox/pause.d.ts +17 -1
- package/dist/services/sandbox/pause.d.ts.map +1 -1
- package/dist/services/sandbox/pause.js +21 -3
- package/dist/services/sandbox/pause.js.map +1 -1
- package/dist/services/sandbox/run.d.ts +3 -2
- package/dist/services/sandbox/run.d.ts.map +1 -1
- package/dist/services/sandbox/run.js +229 -82
- package/dist/services/sandbox/run.js.map +1 -1
- package/dist/services/sandbox/types.d.ts +11 -4
- package/dist/services/sandbox/types.d.ts.map +1 -1
- package/dist/services/sandbox/types.js +12 -0
- package/dist/services/sandbox/types.js.map +1 -1
- package/dist/services/session/get.d.ts +0 -2
- package/dist/services/session/get.d.ts.map +1 -1
- package/dist/services/session/get.js.map +1 -1
- package/dist/services/stream/namespaces.d.ts +2 -2
- package/dist/services/stream/namespaces.js +2 -2
- package/dist/services/stream/namespaces.js.map +1 -1
- package/dist/services/vector/service.d.ts +11 -11
- package/dist/services/vector/service.d.ts.map +1 -1
- package/dist/services/vector/service.js.map +1 -1
- package/package.json +3 -4
- package/src/env.d.ts +1 -31
- package/src/index.ts +0 -1
- package/src/services/coder/client.ts +34 -0
- package/src/services/coder/protocol.ts +121 -0
- package/src/services/coder/types.ts +94 -1
- package/src/services/coder/workspaces.ts +74 -0
- package/src/services/keyvalue/service.ts +16 -7
- package/src/services/oauth/token-storage.ts +4 -1
- package/src/services/queue/service.ts +31 -33
- package/src/services/sandbox/api-reference.ts +8 -8
- package/src/services/sandbox/client.ts +4 -4
- package/src/services/sandbox/create.ts +10 -0
- package/src/services/sandbox/get.ts +32 -3
- package/src/services/sandbox/getStatus.ts +23 -2
- package/src/services/sandbox/index.ts +1 -1
- package/src/services/sandbox/list.ts +5 -0
- package/src/services/sandbox/pause.ts +38 -4
- package/src/services/sandbox/run.ts +339 -103
- package/src/services/sandbox/types.ts +17 -2
- package/src/services/session/get.ts +0 -2
- package/src/services/stream/namespaces.ts +2 -2
- package/src/services/vector/service.ts +11 -21
- package/dist/deprecation.d.ts +0 -20
- package/dist/deprecation.d.ts.map +0 -1
- package/dist/deprecation.js +0 -102
- package/dist/deprecation.js.map +0 -1
- package/src/deprecation.ts +0 -120
|
@@ -162,7 +162,7 @@ export const VectorSearchParamsSchema = <T extends z.ZodTypeAny>(metadataSchema:
|
|
|
162
162
|
),
|
|
163
163
|
});
|
|
164
164
|
|
|
165
|
-
export type VectorSearchParams<T
|
|
165
|
+
export type VectorSearchParams<T = Record<string, unknown>> = {
|
|
166
166
|
query: string;
|
|
167
167
|
limit?: number;
|
|
168
168
|
similarity?: number;
|
|
@@ -210,7 +210,7 @@ export const VectorSearchResultSchema = <T extends z.ZodTypeAny>(metadataSchema:
|
|
|
210
210
|
.describe('the expiration time of the vector as an ISO 8601 timestamp.'),
|
|
211
211
|
});
|
|
212
212
|
|
|
213
|
-
export type VectorSearchResult<T
|
|
213
|
+
export type VectorSearchResult<T = Record<string, unknown>> = {
|
|
214
214
|
id: string;
|
|
215
215
|
key: string;
|
|
216
216
|
metadata?: T;
|
|
@@ -237,9 +237,7 @@ export const VectorSearchResultWithDocumentSchema = <T extends z.ZodTypeAny>(met
|
|
|
237
237
|
embeddings: z.array(z.number()).optional().describe('the embeddings of the vector object'),
|
|
238
238
|
});
|
|
239
239
|
|
|
240
|
-
export type VectorSearchResultWithDocument<
|
|
241
|
-
T extends Record<string, unknown> = Record<string, unknown>,
|
|
242
|
-
> = VectorSearchResult<T> & {
|
|
240
|
+
export type VectorSearchResultWithDocument<T = Record<string, unknown>> = VectorSearchResult<T> & {
|
|
243
241
|
document?: string;
|
|
244
242
|
embeddings?: Array<number>;
|
|
245
243
|
};
|
|
@@ -277,7 +275,7 @@ export const VectorResultFoundSchema = <T extends z.ZodTypeAny>(metadataSchema:
|
|
|
277
275
|
exists: z.literal(true).describe('the vector was found'),
|
|
278
276
|
});
|
|
279
277
|
|
|
280
|
-
export type VectorResultFound<T
|
|
278
|
+
export type VectorResultFound<T = Record<string, unknown>> = {
|
|
281
279
|
data: VectorSearchResultWithDocument<T>;
|
|
282
280
|
exists: true;
|
|
283
281
|
};
|
|
@@ -302,9 +300,7 @@ export type VectorResultNotFound = z.infer<typeof VectorResultNotFoundSchema>;
|
|
|
302
300
|
/**
|
|
303
301
|
* Result of a get operation
|
|
304
302
|
*/
|
|
305
|
-
export type VectorResult<T
|
|
306
|
-
| VectorResultFound<T>
|
|
307
|
-
| VectorResultNotFound;
|
|
303
|
+
export type VectorResult<T = Record<string, unknown>> = VectorResultFound<T> | VectorResultNotFound;
|
|
308
304
|
|
|
309
305
|
export const VectorResultSchema = <T extends z.ZodTypeAny>(metadataSchema: T) =>
|
|
310
306
|
z.discriminatedUnion('exists', [
|
|
@@ -525,10 +521,7 @@ export interface VectorStorage {
|
|
|
525
521
|
* }
|
|
526
522
|
* ```
|
|
527
523
|
*/
|
|
528
|
-
get<T
|
|
529
|
-
name: string,
|
|
530
|
-
key: string
|
|
531
|
-
): Promise<VectorResult<T>>;
|
|
524
|
+
get<T = Record<string, unknown>>(name: string, key: string): Promise<VectorResult<T>>;
|
|
532
525
|
|
|
533
526
|
/**
|
|
534
527
|
* Get multiple vectors by their keys in a single request
|
|
@@ -545,7 +538,7 @@ export interface VectorStorage {
|
|
|
545
538
|
* }
|
|
546
539
|
* ```
|
|
547
540
|
*/
|
|
548
|
-
getMany<T
|
|
541
|
+
getMany<T = Record<string, unknown>>(
|
|
549
542
|
name: string,
|
|
550
543
|
...keys: string[]
|
|
551
544
|
): Promise<Map<string, VectorSearchResultWithDocument<T>>>;
|
|
@@ -579,7 +572,7 @@ export interface VectorStorage {
|
|
|
579
572
|
* }
|
|
580
573
|
* ```
|
|
581
574
|
*/
|
|
582
|
-
search<T
|
|
575
|
+
search<T = Record<string, unknown>>(
|
|
583
576
|
name: string,
|
|
584
577
|
params: VectorSearchParams<T>
|
|
585
578
|
): Promise<VectorSearchResult<T>[]>;
|
|
@@ -897,10 +890,7 @@ export class VectorStorageService implements VectorStorage {
|
|
|
897
890
|
throw await toServiceException('PUT', url, res.response);
|
|
898
891
|
}
|
|
899
892
|
|
|
900
|
-
async get<T
|
|
901
|
-
name: string,
|
|
902
|
-
key: string
|
|
903
|
-
): Promise<VectorResult<T>> {
|
|
893
|
+
async get<T = Record<string, unknown>>(name: string, key: string): Promise<VectorResult<T>> {
|
|
904
894
|
if (!name || typeof name !== 'string' || name.trim().length === 0) {
|
|
905
895
|
throw new VectorStorageNameRequiredError();
|
|
906
896
|
}
|
|
@@ -947,7 +937,7 @@ export class VectorStorageService implements VectorStorage {
|
|
|
947
937
|
throw await toServiceException('GET', url, res.response);
|
|
948
938
|
}
|
|
949
939
|
|
|
950
|
-
async getMany<T
|
|
940
|
+
async getMany<T = Record<string, unknown>>(
|
|
951
941
|
name: string,
|
|
952
942
|
...keys: string[]
|
|
953
943
|
): Promise<Map<string, VectorSearchResultWithDocument<T>>> {
|
|
@@ -978,7 +968,7 @@ export class VectorStorageService implements VectorStorage {
|
|
|
978
968
|
return resultMap;
|
|
979
969
|
}
|
|
980
970
|
|
|
981
|
-
async search<T
|
|
971
|
+
async search<T = Record<string, unknown>>(
|
|
982
972
|
name: string,
|
|
983
973
|
params: VectorSearchParams<T>
|
|
984
974
|
): Promise<VectorSearchResult<T>[]> {
|
package/dist/deprecation.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Deprecation warning for v1 SDK packages.
|
|
3
|
-
*
|
|
4
|
-
* This module logs a deprecation warning when v1 packages are used,
|
|
5
|
-
* recommending migration to v2.
|
|
6
|
-
*
|
|
7
|
-
* The warning is only shown once per process to avoid noise.
|
|
8
|
-
*/
|
|
9
|
-
import type { Logger } from './logger.ts';
|
|
10
|
-
/**
|
|
11
|
-
* Show deprecation warning for v1 packages.
|
|
12
|
-
*
|
|
13
|
-
* @param logger - Optional logger instance (falls back to console)
|
|
14
|
-
*/
|
|
15
|
-
export declare function showDeprecationWarning(logger?: Logger): void;
|
|
16
|
-
/**
|
|
17
|
-
* Check if the current package is v1.
|
|
18
|
-
*/
|
|
19
|
-
export declare function isV1Package(): boolean;
|
|
20
|
-
//# sourceMappingURL=deprecation.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"deprecation.d.ts","sourceRoot":"","sources":["../src/deprecation.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AA8C1C;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAmD5D;AAED;;GAEG;AACH,wBAAgB,WAAW,IAAI,OAAO,CAGrC"}
|
package/dist/deprecation.js
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Deprecation warning for v1 SDK packages.
|
|
3
|
-
*
|
|
4
|
-
* This module logs a deprecation warning when v1 packages are used,
|
|
5
|
-
* recommending migration to v2.
|
|
6
|
-
*
|
|
7
|
-
* The warning is only shown once per process to avoid noise.
|
|
8
|
-
*/
|
|
9
|
-
let deprecationWarningShown = false;
|
|
10
|
-
/**
|
|
11
|
-
* Get version from package.json using various strategies.
|
|
12
|
-
*/
|
|
13
|
-
function getPackageVersion() {
|
|
14
|
-
try {
|
|
15
|
-
// Try to read from the bundled package.json
|
|
16
|
-
// When bundled by Bun/Vite, import.meta.resolve can find the package.json
|
|
17
|
-
const pkgUrl = import.meta.resolve('@agentuity/core/package.json');
|
|
18
|
-
const pkg = require(pkgUrl);
|
|
19
|
-
if (pkg?.version) {
|
|
20
|
-
const match = pkg.version.match(/^(\d+)\.\d+\.\d+/);
|
|
21
|
-
return {
|
|
22
|
-
version: pkg.version,
|
|
23
|
-
major: match ? parseInt(match[1], 10) : 0,
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
catch {
|
|
28
|
-
// Try require fallback
|
|
29
|
-
try {
|
|
30
|
-
const pkg = require('@agentuity/core/package.json');
|
|
31
|
-
if (pkg?.version) {
|
|
32
|
-
const match = pkg.version.match(/^(\d+)\.\d+\.\d+/);
|
|
33
|
-
return {
|
|
34
|
-
version: pkg.version,
|
|
35
|
-
major: match ? parseInt(match[1], 10) : 0,
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
catch {
|
|
40
|
-
// Ignore
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return null;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Show deprecation warning for v1 packages.
|
|
47
|
-
*
|
|
48
|
-
* @param logger - Optional logger instance (falls back to console)
|
|
49
|
-
*/
|
|
50
|
-
export function showDeprecationWarning(logger) {
|
|
51
|
-
// Only show once per process
|
|
52
|
-
if (deprecationWarningShown) {
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
// Skip if explicitly disabled
|
|
56
|
-
if (process.env.AGENTUITY_NO_DEPRECATION_WARNING === 'true') {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
// Skip in test environments
|
|
60
|
-
if (process.env.NODE_ENV === 'test' || process.env.VITEST === 'true') {
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
const pkgVersion = getPackageVersion();
|
|
64
|
-
// Only warn if this is a v1 package
|
|
65
|
-
if (!pkgVersion || pkgVersion.major !== 1) {
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
deprecationWarningShown = true;
|
|
69
|
-
const message = '\n' +
|
|
70
|
-
'┌──────────────────────────────────────────────────────────────────────┐\n' +
|
|
71
|
-
'│ │\n' +
|
|
72
|
-
'│ ⚠️ Agentuity SDK v1 is deprecated │\n' +
|
|
73
|
-
'│ │\n' +
|
|
74
|
-
'│ You are using @agentuity/core@' +
|
|
75
|
-
pkgVersion.version.padEnd(22) +
|
|
76
|
-
' │\n' +
|
|
77
|
-
'│ │\n' +
|
|
78
|
-
'│ v2 introduces major improvements: │\n' +
|
|
79
|
-
'│ • Hono RPC for end-to-end type safety │\n' +
|
|
80
|
-
'│ • Vite-native dev server with HMR │\n' +
|
|
81
|
-
'│ • Simplified configuration in createApp() │\n' +
|
|
82
|
-
'│ │\n' +
|
|
83
|
-
'│ → Run `npx @agentuity/migrate` to upgrade your project │\n' +
|
|
84
|
-
'│ │\n' +
|
|
85
|
-
'│ Docs: https://docs.agentuity.com/migration/v1-to-v2 │\n' +
|
|
86
|
-
'│ │\n' +
|
|
87
|
-
'└──────────────────────────────────────────────────────────────────────┘\n';
|
|
88
|
-
if (logger) {
|
|
89
|
-
logger.warn(message);
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
console.warn(message);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Check if the current package is v1.
|
|
97
|
-
*/
|
|
98
|
-
export function isV1Package() {
|
|
99
|
-
const pkgVersion = getPackageVersion();
|
|
100
|
-
return pkgVersion?.major === 1;
|
|
101
|
-
}
|
|
102
|
-
//# sourceMappingURL=deprecation.js.map
|
package/dist/deprecation.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"deprecation.js","sourceRoot":"","sources":["../src/deprecation.ts"],"names":[],"mappings":"AAAA;;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
*
|
|
4
|
-
* This module logs a deprecation warning when v1 packages are used,
|
|
5
|
-
* recommending migration to v2.
|
|
6
|
-
*
|
|
7
|
-
* The warning is only shown once per process to avoid noise.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import type { Logger } from './logger.ts';
|
|
11
|
-
|
|
12
|
-
let deprecationWarningShown = false;
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Package version info
|
|
16
|
-
*/
|
|
17
|
-
interface PackageVersion {
|
|
18
|
-
version: string;
|
|
19
|
-
major: number;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Get version from package.json using various strategies.
|
|
24
|
-
*/
|
|
25
|
-
function getPackageVersion(): PackageVersion | null {
|
|
26
|
-
try {
|
|
27
|
-
// Try to read from the bundled package.json
|
|
28
|
-
// When bundled by Bun/Vite, import.meta.resolve can find the package.json
|
|
29
|
-
const pkgUrl = import.meta.resolve('@agentuity/core/package.json');
|
|
30
|
-
const pkg = require(pkgUrl);
|
|
31
|
-
if (pkg?.version) {
|
|
32
|
-
const match = pkg.version.match(/^(\d+)\.\d+\.\d+/);
|
|
33
|
-
return {
|
|
34
|
-
version: pkg.version,
|
|
35
|
-
major: match ? parseInt(match[1], 10) : 0,
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
} catch {
|
|
39
|
-
// Try require fallback
|
|
40
|
-
try {
|
|
41
|
-
const pkg = require('@agentuity/core/package.json');
|
|
42
|
-
if (pkg?.version) {
|
|
43
|
-
const match = pkg.version.match(/^(\d+)\.\d+\.\d+/);
|
|
44
|
-
return {
|
|
45
|
-
version: pkg.version,
|
|
46
|
-
major: match ? parseInt(match[1], 10) : 0,
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
} catch {
|
|
50
|
-
// Ignore
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return null;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Show deprecation warning for v1 packages.
|
|
58
|
-
*
|
|
59
|
-
* @param logger - Optional logger instance (falls back to console)
|
|
60
|
-
*/
|
|
61
|
-
export function showDeprecationWarning(logger?: Logger): void {
|
|
62
|
-
// Only show once per process
|
|
63
|
-
if (deprecationWarningShown) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// Skip if explicitly disabled
|
|
68
|
-
if (process.env.AGENTUITY_NO_DEPRECATION_WARNING === 'true') {
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// Skip in test environments
|
|
73
|
-
if (process.env.NODE_ENV === 'test' || process.env.VITEST === 'true') {
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const pkgVersion = getPackageVersion();
|
|
78
|
-
|
|
79
|
-
// Only warn if this is a v1 package
|
|
80
|
-
if (!pkgVersion || pkgVersion.major !== 1) {
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
deprecationWarningShown = true;
|
|
85
|
-
|
|
86
|
-
const message =
|
|
87
|
-
'\n' +
|
|
88
|
-
'┌──────────────────────────────────────────────────────────────────────┐\n' +
|
|
89
|
-
'│ │\n' +
|
|
90
|
-
'│ ⚠️ Agentuity SDK v1 is deprecated │\n' +
|
|
91
|
-
'│ │\n' +
|
|
92
|
-
'│ You are using @agentuity/core@' +
|
|
93
|
-
pkgVersion.version.padEnd(22) +
|
|
94
|
-
' │\n' +
|
|
95
|
-
'│ │\n' +
|
|
96
|
-
'│ v2 introduces major improvements: │\n' +
|
|
97
|
-
'│ • Hono RPC for end-to-end type safety │\n' +
|
|
98
|
-
'│ • Vite-native dev server with HMR │\n' +
|
|
99
|
-
'│ • Simplified configuration in createApp() │\n' +
|
|
100
|
-
'│ │\n' +
|
|
101
|
-
'│ → Run `npx @agentuity/migrate` to upgrade your project │\n' +
|
|
102
|
-
'│ │\n' +
|
|
103
|
-
'│ Docs: https://docs.agentuity.com/migration/v1-to-v2 │\n' +
|
|
104
|
-
'│ │\n' +
|
|
105
|
-
'└──────────────────────────────────────────────────────────────────────┘\n';
|
|
106
|
-
|
|
107
|
-
if (logger) {
|
|
108
|
-
logger.warn(message);
|
|
109
|
-
} else {
|
|
110
|
-
console.warn(message);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Check if the current package is v1.
|
|
116
|
-
*/
|
|
117
|
-
export function isV1Package(): boolean {
|
|
118
|
-
const pkgVersion = getPackageVersion();
|
|
119
|
-
return pkgVersion?.major === 1;
|
|
120
|
-
}
|