@theia/ai-core 1.59.0-next.72 → 1.59.0
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/lib/browser/theia-variable-contribution.d.ts +5 -1
- package/lib/browser/theia-variable-contribution.d.ts.map +1 -1
- package/lib/browser/theia-variable-contribution.js +48 -9
- package/lib/browser/theia-variable-contribution.js.map +1 -1
- package/lib/common/language-model.d.ts +5 -3
- package/lib/common/language-model.d.ts.map +1 -1
- package/lib/common/language-model.js +32 -7
- package/lib/common/language-model.js.map +1 -1
- package/lib/node/tool-request-parameters.spec.d.ts +2 -0
- package/lib/node/tool-request-parameters.spec.d.ts.map +1 -0
- package/lib/node/tool-request-parameters.spec.js +116 -0
- package/lib/node/tool-request-parameters.spec.js.map +1 -0
- package/package.json +10 -10
- package/src/browser/theia-variable-contribution.ts +49 -8
- package/src/common/language-model.ts +46 -11
- package/src/node/tool-request-parameters.spec.ts +121 -0
|
@@ -5,10 +5,14 @@ import { AIVariableContribution, AIVariableResolver, AIVariableService, AIVariab
|
|
|
5
5
|
* Integrates the Theia VariableRegistry with the Theia AI VariableService
|
|
6
6
|
*/
|
|
7
7
|
export declare class TheiaVariableContribution implements AIVariableContribution, AIVariableResolver {
|
|
8
|
+
private static readonly THEIA_PREFIX;
|
|
8
9
|
protected readonly variableResolverService: VariableResolverService;
|
|
9
10
|
protected readonly variableRegistry: VariableRegistry;
|
|
10
11
|
protected readonly stateService: FrontendApplicationStateService;
|
|
11
|
-
protected variableRenameMap: Map<string,
|
|
12
|
+
protected variableRenameMap: Map<string, {
|
|
13
|
+
name?: string;
|
|
14
|
+
description?: string;
|
|
15
|
+
}>;
|
|
12
16
|
registerVariables(service: AIVariableService): void;
|
|
13
17
|
protected toTheiaVariable(request: AIVariableResolutionRequest): string;
|
|
14
18
|
canResolve(request: AIVariableResolutionRequest, context: AIVariableContext): Promise<number>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theia-variable-contribution.d.ts","sourceRoot":"","sources":["../../src/browser/theia-variable-contribution.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,+BAA+B,EAAE,MAAM,oDAAoD,CAAC;AAGrG,OAAO,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AACjG,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,2BAA2B,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAE9J;;GAEG;AACH,qBACa,yBAA0B,YAAW,sBAAsB,EAAE,kBAAkB;IAExF,SAAS,CAAC,QAAQ,CAAC,uBAAuB,EAAE,uBAAuB,CAAC;IAGpE,SAAS,CAAC,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IAGtD,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"theia-variable-contribution.d.ts","sourceRoot":"","sources":["../../src/browser/theia-variable-contribution.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,+BAA+B,EAAE,MAAM,oDAAoD,CAAC;AAGrG,OAAO,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AACjG,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,2BAA2B,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAE9J;;GAEG;AACH,qBACa,yBAA0B,YAAW,sBAAsB,EAAE,kBAAkB;IAExF,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAY;IAGhD,SAAS,CAAC,QAAQ,CAAC,uBAAuB,EAAE,uBAAuB,CAAC;IAGpE,SAAS,CAAC,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IAGtD,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,+BAA+B,CAAC;IAIjE,SAAS,CAAC,iBAAiB,EAAE,GAAG,CAAC,MAAM,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAyB9E;IAEH,iBAAiB,CAAC,OAAO,EAAE,iBAAiB,GAAG,IAAI;IAuBnD,SAAS,CAAC,eAAe,CAAC,OAAO,EAAE,2BAA2B,GAAG,MAAM;IAOjE,UAAU,CAAC,OAAO,EAAE,2BAA2B,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC;IAU7F,OAAO,CAAC,OAAO,EAAE,2BAA2B,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,GAAG,SAAS,CAAC;CAI3H"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var TheiaVariableContribution_1;
|
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
4
|
exports.TheiaVariableContribution = void 0;
|
|
4
5
|
const tslib_1 = require("tslib");
|
|
@@ -24,10 +25,35 @@ const browser_1 = require("@theia/variable-resolver/lib/browser");
|
|
|
24
25
|
/**
|
|
25
26
|
* Integrates the Theia VariableRegistry with the Theia AI VariableService
|
|
26
27
|
*/
|
|
27
|
-
let TheiaVariableContribution = class TheiaVariableContribution {
|
|
28
|
+
let TheiaVariableContribution = TheiaVariableContribution_1 = class TheiaVariableContribution {
|
|
28
29
|
constructor() {
|
|
30
|
+
// Map original variable name to new name and description. If a mapped value is not present then the original will be kept.
|
|
31
|
+
// Only variables present in this map are registered.
|
|
29
32
|
this.variableRenameMap = new Map([
|
|
30
|
-
['file',
|
|
33
|
+
['file', {
|
|
34
|
+
name: 'currentAbsoluteFilePath', description: nls_1.nls.localize('theia/ai/core/variable-contribution/currentAbsoluteFilePath', 'The absolute path of the \
|
|
35
|
+
currently opened file. Please note that most agents will expect a relative file path (relative to the current workspace).')
|
|
36
|
+
}],
|
|
37
|
+
['selectedText', {
|
|
38
|
+
description: nls_1.nls.localize('theia/ai/core/variable-contribution/currentSelectedText', 'The plain text that is currently selected in the \
|
|
39
|
+
opened file. This excludes the information where the content is coming from. Please note that most agents will work better with a relative file path \
|
|
40
|
+
(relative to the current workspace).')
|
|
41
|
+
}],
|
|
42
|
+
['currentText', {
|
|
43
|
+
name: 'currentFileContent', description: nls_1.nls.localize('theia/ai/core/variable-contribution/currentFileContent', 'The plain content of the \
|
|
44
|
+
currently opened file. This excludes the information where the content is coming from. Please note that most agents will work better with a relative file path \
|
|
45
|
+
(relative to the current workspace).')
|
|
46
|
+
}],
|
|
47
|
+
['relativeFile', {
|
|
48
|
+
name: 'currentRelativeFilePath', description: nls_1.nls.localize('theia/ai/core/variable-contribution/currentRelativeFilePath', 'The relative path of the \
|
|
49
|
+
currently opened file.')
|
|
50
|
+
}],
|
|
51
|
+
['relativeFileDirname', {
|
|
52
|
+
name: 'currentRelativeDirPath', description: nls_1.nls.localize('theia/ai/core/variable-contribution/currentRelativeDirPath', 'The relative path of the directory \
|
|
53
|
+
containing the currently opened file.')
|
|
54
|
+
}],
|
|
55
|
+
['lineNumber', {}],
|
|
56
|
+
['workspaceFolder', {}]
|
|
31
57
|
]);
|
|
32
58
|
}
|
|
33
59
|
registerVariables(service) {
|
|
@@ -35,20 +61,32 @@ let TheiaVariableContribution = class TheiaVariableContribution {
|
|
|
35
61
|
// some variable contributions in Theia are done as part of the onStart, same as our AI variable contributions
|
|
36
62
|
// we therefore wait for all of them to be registered before we register we map them to our own
|
|
37
63
|
this.variableRegistry.getVariables().forEach(variable => {
|
|
38
|
-
|
|
39
|
-
|
|
64
|
+
if (!this.variableRenameMap.has(variable.name)) {
|
|
65
|
+
return; // Do not register variables not part of the map
|
|
66
|
+
}
|
|
67
|
+
const mapping = this.variableRenameMap.get(variable.name);
|
|
68
|
+
const newName = (mapping.name && mapping.name.trim() !== '') ? mapping.name : variable.name;
|
|
69
|
+
const newDescription = (mapping.description && mapping.description.trim() !== '') ? mapping.description
|
|
70
|
+
: (variable.description && variable.description.trim() !== '' ? variable.description
|
|
71
|
+
: nls_1.nls.localize('theia/ai/core/variable-contribution/builtInVariable', 'Theia Built-in Variable'));
|
|
40
72
|
service.registerResolver({
|
|
41
|
-
id:
|
|
42
|
-
name:
|
|
43
|
-
description:
|
|
73
|
+
id: `${TheiaVariableContribution_1.THEIA_PREFIX}${variable.name}`,
|
|
74
|
+
name: newName,
|
|
75
|
+
description: newDescription
|
|
44
76
|
}, this);
|
|
45
77
|
});
|
|
46
78
|
});
|
|
47
79
|
}
|
|
48
80
|
toTheiaVariable(request) {
|
|
49
|
-
|
|
81
|
+
// Remove the THEIA_PREFIX if present before constructing the variable string
|
|
82
|
+
const variableId = request.variable.id.startsWith(TheiaVariableContribution_1.THEIA_PREFIX) ? request.variable.id.slice(TheiaVariableContribution_1.THEIA_PREFIX.length) :
|
|
83
|
+
request.variable.id;
|
|
84
|
+
return `\${${variableId}${request.arg ? ':' + request.arg : ''}}`;
|
|
50
85
|
}
|
|
51
86
|
async canResolve(request, context) {
|
|
87
|
+
if (!request.variable.id.startsWith(TheiaVariableContribution_1.THEIA_PREFIX)) {
|
|
88
|
+
return 0;
|
|
89
|
+
}
|
|
52
90
|
// some variables are not resolvable without providing a specific context
|
|
53
91
|
// this may be expensive but was not a problem for Theia's built-in variables
|
|
54
92
|
const resolved = await this.variableResolverService.resolve(this.toTheiaVariable(request), context);
|
|
@@ -60,6 +98,7 @@ let TheiaVariableContribution = class TheiaVariableContribution {
|
|
|
60
98
|
}
|
|
61
99
|
};
|
|
62
100
|
exports.TheiaVariableContribution = TheiaVariableContribution;
|
|
101
|
+
TheiaVariableContribution.THEIA_PREFIX = 'theia-';
|
|
63
102
|
tslib_1.__decorate([
|
|
64
103
|
(0, inversify_1.inject)(browser_1.VariableResolverService),
|
|
65
104
|
tslib_1.__metadata("design:type", browser_1.VariableResolverService)
|
|
@@ -72,7 +111,7 @@ tslib_1.__decorate([
|
|
|
72
111
|
(0, inversify_1.inject)(frontend_application_state_1.FrontendApplicationStateService),
|
|
73
112
|
tslib_1.__metadata("design:type", frontend_application_state_1.FrontendApplicationStateService)
|
|
74
113
|
], TheiaVariableContribution.prototype, "stateService", void 0);
|
|
75
|
-
exports.TheiaVariableContribution = TheiaVariableContribution = tslib_1.__decorate([
|
|
114
|
+
exports.TheiaVariableContribution = TheiaVariableContribution = TheiaVariableContribution_1 = tslib_1.__decorate([
|
|
76
115
|
(0, inversify_1.injectable)()
|
|
77
116
|
], TheiaVariableContribution);
|
|
78
117
|
//# sourceMappingURL=theia-variable-contribution.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theia-variable-contribution.js","sourceRoot":"","sources":["../../src/browser/theia-variable-contribution.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"theia-variable-contribution.js","sourceRoot":"","sources":["../../src/browser/theia-variable-contribution.ts"],"names":[],"mappings":";;;;;AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;AAChF,mGAAqG;AACrG,oDAAiD;AACjD,4DAAkE;AAClE,kEAAiG;AAGjG;;GAEG;AAEI,IAAM,yBAAyB,iCAA/B,MAAM,yBAAyB;IAA/B;QAaH,2HAA2H;QAC3H,qDAAqD;QAC3C,sBAAiB,GAAyD,IAAI,GAAG,CAAC;YACxF,CAAC,MAAM,EAAE;oBACL,IAAI,EAAE,yBAAyB,EAAE,WAAW,EAAE,SAAG,CAAC,QAAQ,CAAC,6DAA6D,EAAE;sIACA,CAAC;iBAC9H,CAAC;YACF,CAAC,cAAc,EAAE;oBACb,WAAW,EAAE,SAAG,CAAC,QAAQ,CAAC,yDAAyD,EAAE;;iDAEhD,CAAC;iBACzC,CAAC;YACF,CAAC,aAAa,EAAE;oBAC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AI,CAAC,uBAAuB,CAAC,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC;QACpG,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7B,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,OAAoC,EAAE,OAA0B;QAC1E,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,uBAAuB,CAAC,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC;QACpG,OAAO,QAAQ,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;IAClF,CAAC;;AArFQ,8DAAyB;AAEV,sCAAY,GAAG,QAAQ,AAAX,CAAY;AAG7B;IADlB,IAAA,kBAAM,EAAC,iCAAuB,CAAC;sCACY,iCAAuB;0EAAC;AAGjD;IADlB,IAAA,kBAAM,EAAC,0BAAgB,CAAC;sCACY,0BAAgB;mEAAC;AAGnC;IADlB,IAAA,kBAAM,EAAC,4DAA+B,CAAC;sCACP,4DAA+B;+DAAC;oCAXxD,yBAAyB;IADrC,IAAA,sBAAU,GAAE;GACA,yBAAyB,CAsFrC"}
|
|
@@ -6,10 +6,12 @@ export interface LanguageModelRequestMessage {
|
|
|
6
6
|
query: string;
|
|
7
7
|
}
|
|
8
8
|
export declare const isLanguageModelRequestMessage: (obj: unknown) => obj is LanguageModelRequestMessage;
|
|
9
|
-
export
|
|
10
|
-
type
|
|
9
|
+
export interface ToolRequestParameterProperty {
|
|
10
|
+
type?: string;
|
|
11
|
+
anyOf?: ToolRequestParameterProperty[];
|
|
11
12
|
[key: string]: unknown;
|
|
12
|
-
}
|
|
13
|
+
}
|
|
14
|
+
export type ToolRequestParametersProperties = Record<string, ToolRequestParameterProperty>;
|
|
13
15
|
export interface ToolRequestParameters {
|
|
14
16
|
type?: 'object';
|
|
15
17
|
properties: ToolRequestParametersProperties;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"language-model.d.ts","sourceRoot":"","sources":["../../src/common/language-model.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,oBAAoB,EAAE,OAAO,EAAwB,KAAK,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGrH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,IAAI,GAAG,QAAQ,CAAC;AAEpD,MAAM,WAAW,2BAA2B;IACxC,KAAK,EAAE,YAAY,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACjB;AACD,eAAO,MAAM,6BAA6B,QAAS,OAAO,uCAOrD,CAAC;
|
|
1
|
+
{"version":3,"file":"language-model.d.ts","sourceRoot":"","sources":["../../src/common/language-model.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,oBAAoB,EAAE,OAAO,EAAwB,KAAK,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGrH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,IAAI,GAAG,QAAQ,CAAC;AAEpD,MAAM,WAAW,2BAA2B;IACxC,KAAK,EAAE,YAAY,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACjB;AACD,eAAO,MAAM,6BAA6B,QAAS,OAAO,uCAOrD,CAAC;AAEN,MAAM,WAAW,4BAA4B;IACzC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,4BAA4B,EAAE,CAAC;IACvC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CAC1B;AAED,MAAM,MAAM,+BAA+B,GAAG,MAAM,CAAC,MAAM,EAAE,4BAA4B,CAAC,CAAC;AAC3F,MAAM,WAAW,qBAAqB;IAClC,IAAI,CAAC,EAAE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CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;CAGhG;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,qBAAqB,EAAE,KAAK,EAAE,aAAa,GAAG,OAAO,CAM7F"}
|
|
@@ -28,17 +28,42 @@ const isLanguageModelRequestMessage = (obj) => !!(obj && typeof obj === 'object'
|
|
|
28
28
|
exports.isLanguageModelRequestMessage = isLanguageModelRequestMessage;
|
|
29
29
|
var ToolRequest;
|
|
30
30
|
(function (ToolRequest) {
|
|
31
|
+
function isToolRequestParameterProperty(obj) {
|
|
32
|
+
if (!obj || typeof obj !== 'object') {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
const record = obj;
|
|
36
|
+
// Check that at least one of "type" or "anyOf" exists
|
|
37
|
+
if (!('type' in record) && !('anyOf' in record)) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
// If an "anyOf" field is present, it must be an array where each item is also a valid property.
|
|
41
|
+
if ('anyOf' in record) {
|
|
42
|
+
if (!Array.isArray(record.anyOf)) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
for (const item of record.anyOf) {
|
|
46
|
+
if (!isToolRequestParameterProperty(item)) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if ('type' in record && typeof record.type !== 'string') {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
// No further checks required for additional properties.
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
31
57
|
function isToolRequestParametersProperties(obj) {
|
|
32
58
|
if (!obj || typeof obj !== 'object') {
|
|
33
59
|
return false;
|
|
34
60
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
Object.keys(value).every(k => typeof k === 'string'));
|
|
61
|
+
return Object.entries(obj).every(([key, value]) => {
|
|
62
|
+
if (typeof key !== 'string') {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
return isToolRequestParameterProperty(value);
|
|
66
|
+
});
|
|
42
67
|
}
|
|
43
68
|
ToolRequest.isToolRequestParametersProperties = isToolRequestParametersProperties;
|
|
44
69
|
function isToolRequestParameters(obj) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"language-model.js","sourceRoot":"","sources":["../../src/common/language-model.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;;AAEhF,sCAAqH;AACrH,4DAAwF;AASjF,MAAM,6BAA6B,GAAG,CAAC,GAAY,EAAsC,EAAE,CAC9F,CAAC,CAAC,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ;IAC7B,MAAM,IAAI,GAAG;IACb,OAAQ,GAAyB,CAAC,IAAI,KAAK,QAAQ;IAClD,GAAyB,CAAC,IAAI,KAAK,MAAM;IAC1C,OAAO,IAAI,GAAG;IACd,OAAQ,GAA0B,CAAC,KAAK,KAAK,QAAQ,CACxD,CAAC;AAPO,QAAA,6BAA6B,iCAOpC;
|
|
1
|
+
{"version":3,"file":"language-model.js","sourceRoot":"","sources":["../../src/common/language-model.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;;AAEhF,sCAAqH;AACrH,4DAAwF;AASjF,MAAM,6BAA6B,GAAG,CAAC,GAAY,EAAsC,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oB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACzD,CAAC;CACJ,CAAA;AAxEY,4EAAgC;AAE/B;IADT,IAAA,kBAAM,EAAC,cAAO,CAAC;;gEACU;AAEP;IADlB,IAAA,kBAAM,EAAC,2BAAoB,CAAC;IAAE,IAAA,iBAAK,EAAC,6BAAqB,CAAC;;oFACgC;AAWjF;IADT,IAAA,yBAAa,GAAE;;;;4DAcf;2CA5BQ,gCAAgC;IAD5C,IAAA,sBAAU,GAAE;GACA,gCAAgC,CAwE5C;AAED,SAAgB,eAAe,CAAC,OAA8B,EAAE,KAAoB;IAChF,OAAO,CAAC,CAAC,OAAO,CAAC,UAAU,IAAI,KAAK,CAAC,EAAE,KAAK,OAAO,CAAC,UAAU,CAAC;QAC3D,CAAC,CAAC,OAAO,CAAC,IAAI,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC;QAC9C,CAAC,CAAC,OAAO,CAAC,MAAM,IAAI,KAAK,CAAC,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC;QACpD,CAAC,CAAC,OAAO,CAAC,OAAO,IAAI,KAAK,CAAC,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC;QACvD,CAAC,CAAC,OAAO,CAAC,MAAM,IAAI,KAAK,CAAC,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;AAC7D,CAAC;AAND,0CAMC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-request-parameters.spec.d.ts","sourceRoot":"","sources":["../../src/node/tool-request-parameters.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
// *****************************************************************************
|
|
4
|
+
// Copyright (C) 2025 EclipseSource GmbH.
|
|
5
|
+
//
|
|
6
|
+
// This program and the accompanying materials are made available under the
|
|
7
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
8
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
9
|
+
//
|
|
10
|
+
// This Source Code may also be made available under the following Secondary
|
|
11
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
12
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
13
|
+
// with the GNU Classpath Exception which is available at
|
|
14
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
15
|
+
//
|
|
16
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
17
|
+
// *****************************************************************************
|
|
18
|
+
const chai_1 = require("chai");
|
|
19
|
+
const language_model_1 = require("../common/language-model");
|
|
20
|
+
describe('isToolRequestParameters', () => {
|
|
21
|
+
it('should return true for valid ToolRequestParameters', () => {
|
|
22
|
+
const validParams = {
|
|
23
|
+
type: 'object',
|
|
24
|
+
properties: {
|
|
25
|
+
param1: {
|
|
26
|
+
type: 'string'
|
|
27
|
+
},
|
|
28
|
+
param2: {
|
|
29
|
+
type: 'number'
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
required: ['param1']
|
|
33
|
+
};
|
|
34
|
+
(0, chai_1.expect)(language_model_1.ToolRequest.isToolRequestParameters(validParams)).to.be.true;
|
|
35
|
+
});
|
|
36
|
+
it('should return false for ToolRequestParameters without type or anyOf', () => {
|
|
37
|
+
const paramsWithoutType = {
|
|
38
|
+
properties: {
|
|
39
|
+
param1: {
|
|
40
|
+
description: 'string'
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
required: ['param1']
|
|
44
|
+
};
|
|
45
|
+
(0, chai_1.expect)(language_model_1.ToolRequest.isToolRequestParameters(paramsWithoutType)).to.be.false;
|
|
46
|
+
});
|
|
47
|
+
it('should return false for invalid ToolRequestParameters with wrong property type', () => {
|
|
48
|
+
const invalidParams = {
|
|
49
|
+
type: 'object',
|
|
50
|
+
properties: {
|
|
51
|
+
param1: {
|
|
52
|
+
type: 123
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
(0, chai_1.expect)(language_model_1.ToolRequest.isToolRequestParameters(invalidParams)).to.be.false;
|
|
57
|
+
});
|
|
58
|
+
it('should return false if properties is not an object', () => {
|
|
59
|
+
const invalidParams = {
|
|
60
|
+
type: 'object',
|
|
61
|
+
properties: 'not-an-object',
|
|
62
|
+
};
|
|
63
|
+
(0, chai_1.expect)(language_model_1.ToolRequest.isToolRequestParameters(invalidParams)).to.be.false;
|
|
64
|
+
});
|
|
65
|
+
it('should return true if required is missing', () => {
|
|
66
|
+
const missingRequiredParams = {
|
|
67
|
+
type: 'object',
|
|
68
|
+
properties: {
|
|
69
|
+
param1: {
|
|
70
|
+
type: 'string'
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
(0, chai_1.expect)(language_model_1.ToolRequest.isToolRequestParameters(missingRequiredParams)).to.be.true;
|
|
75
|
+
});
|
|
76
|
+
it('should return false if required is not an array', () => {
|
|
77
|
+
const invalidRequiredParams = {
|
|
78
|
+
type: 'object',
|
|
79
|
+
properties: {
|
|
80
|
+
param1: {
|
|
81
|
+
type: 'string'
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
required: 'param1'
|
|
85
|
+
};
|
|
86
|
+
(0, chai_1.expect)(language_model_1.ToolRequest.isToolRequestParameters(invalidRequiredParams)).to.be.false;
|
|
87
|
+
});
|
|
88
|
+
it('should return false if a required field is not a string', () => {
|
|
89
|
+
const invalidRequiredParams = {
|
|
90
|
+
type: 'object',
|
|
91
|
+
properties: {
|
|
92
|
+
param1: {
|
|
93
|
+
type: 'string'
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
required: [123]
|
|
97
|
+
};
|
|
98
|
+
(0, chai_1.expect)(language_model_1.ToolRequest.isToolRequestParameters(invalidRequiredParams)).to.be.false;
|
|
99
|
+
});
|
|
100
|
+
it('should validate properties with anyOf correctly', () => {
|
|
101
|
+
const paramsWithAnyOf = {
|
|
102
|
+
type: 'object',
|
|
103
|
+
properties: {
|
|
104
|
+
param1: {
|
|
105
|
+
anyOf: [
|
|
106
|
+
{ type: 'string' },
|
|
107
|
+
{ type: 'number' }
|
|
108
|
+
]
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
required: ['param1']
|
|
112
|
+
};
|
|
113
|
+
(0, chai_1.expect)(language_model_1.ToolRequest.isToolRequestParameters(paramsWithAnyOf)).to.be.true;
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
//# sourceMappingURL=tool-request-parameters.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-request-parameters.spec.js","sourceRoot":"","sources":["../../src/node/tool-request-parameters.spec.ts"],"names":[],"mappings":";;AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;AAChF,+BAA8B;AAC9B,6DAAuD;AAEvD,QAAQ,CAAC,yBAAyB,EAAE,GAAG,EAAE;IACrC,EAAE,CAAC,oDAAoD,EAAE,GAAG,EAAE;QAC1D,MAAM,WAAW,GAAG;YAChB,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACR,MAAM,EAAE;oBACJ,IAAI,EAAE,QAAQ;iBACjB;gBACD,MAAM,EAAE;oBACJ,IAAI,EAAE,QAAQ;iBACjB;aACJ;YACD,QAAQ,EAAE,CAAC,QAAQ,CAAC;SACvB,CAAC;QACF,IAAA,aAAM,EAAC,4BAAW,CAAC,uBAAuB,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;IACxE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,qEAAqE,EAAE,GAAG,EAAE;QAC3E,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
+
"version": "1.59.0",
|
|
4
4
|
"description": "Theia - AI Core",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@theia/core": "1.59.0
|
|
7
|
-
"@theia/editor": "1.59.0
|
|
8
|
-
"@theia/filesystem": "1.59.0
|
|
9
|
-
"@theia/monaco": "1.59.0
|
|
6
|
+
"@theia/core": "1.59.0",
|
|
7
|
+
"@theia/editor": "1.59.0",
|
|
8
|
+
"@theia/filesystem": "1.59.0",
|
|
9
|
+
"@theia/monaco": "1.59.0",
|
|
10
10
|
"@theia/monaco-editor-core": "1.96.302",
|
|
11
|
-
"@theia/output": "1.59.0
|
|
12
|
-
"@theia/variable-resolver": "1.59.0
|
|
13
|
-
"@theia/workspace": "1.59.0
|
|
11
|
+
"@theia/output": "1.59.0",
|
|
12
|
+
"@theia/variable-resolver": "1.59.0",
|
|
13
|
+
"@theia/workspace": "1.59.0",
|
|
14
14
|
"@types/js-yaml": "^4.0.9",
|
|
15
15
|
"js-yaml": "^4.1.0",
|
|
16
16
|
"minimatch": "^5.1.0",
|
|
@@ -52,10 +52,10 @@
|
|
|
52
52
|
"watch": "theiaext watch"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@theia/ext-scripts": "1.
|
|
55
|
+
"@theia/ext-scripts": "1.59.0"
|
|
56
56
|
},
|
|
57
57
|
"nyc": {
|
|
58
58
|
"extends": "../../configs/nyc.json"
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "21358137e41342742707f660b8e222f940a27652"
|
|
61
61
|
}
|
|
@@ -24,6 +24,9 @@ import { AIVariableContribution, AIVariableResolver, AIVariableService, AIVariab
|
|
|
24
24
|
*/
|
|
25
25
|
@injectable()
|
|
26
26
|
export class TheiaVariableContribution implements AIVariableContribution, AIVariableResolver {
|
|
27
|
+
|
|
28
|
+
private static readonly THEIA_PREFIX = 'theia-';
|
|
29
|
+
|
|
27
30
|
@inject(VariableResolverService)
|
|
28
31
|
protected readonly variableResolverService: VariableResolverService;
|
|
29
32
|
|
|
@@ -33,8 +36,33 @@ export class TheiaVariableContribution implements AIVariableContribution, AIVari
|
|
|
33
36
|
@inject(FrontendApplicationStateService)
|
|
34
37
|
protected readonly stateService: FrontendApplicationStateService;
|
|
35
38
|
|
|
36
|
-
|
|
37
|
-
|
|
39
|
+
// Map original variable name to new name and description. If a mapped value is not present then the original will be kept.
|
|
40
|
+
// Only variables present in this map are registered.
|
|
41
|
+
protected variableRenameMap: Map<string, { name?: string, description?: string }> = new Map([
|
|
42
|
+
['file', {
|
|
43
|
+
name: 'currentAbsoluteFilePath', description: nls.localize('theia/ai/core/variable-contribution/currentAbsoluteFilePath', 'The absolute path of the \
|
|
44
|
+
currently opened file. Please note that most agents will expect a relative file path (relative to the current workspace).')
|
|
45
|
+
}],
|
|
46
|
+
['selectedText', {
|
|
47
|
+
description: nls.localize('theia/ai/core/variable-contribution/currentSelectedText', 'The plain text that is currently selected in the \
|
|
48
|
+
opened file. This excludes the information where the content is coming from. Please note that most agents will work better with a relative file path \
|
|
49
|
+
(relative to the current workspace).')
|
|
50
|
+
}],
|
|
51
|
+
['currentText', {
|
|
52
|
+
name: 'currentFileContent', description: nls.localize('theia/ai/core/variable-contribution/currentFileContent', 'The plain content of the \
|
|
53
|
+
currently opened file. This excludes the information where the content is coming from. Please note that most agents will work better with a relative file path \
|
|
54
|
+
(relative to the current workspace).')
|
|
55
|
+
}],
|
|
56
|
+
['relativeFile', {
|
|
57
|
+
name: 'currentRelativeFilePath', description: nls.localize('theia/ai/core/variable-contribution/currentRelativeFilePath', 'The relative path of the \
|
|
58
|
+
currently opened file.')
|
|
59
|
+
}],
|
|
60
|
+
['relativeFileDirname', {
|
|
61
|
+
name: 'currentRelativeDirPath', description: nls.localize('theia/ai/core/variable-contribution/currentRelativeDirPath', 'The relative path of the directory \
|
|
62
|
+
containing the currently opened file.')
|
|
63
|
+
}],
|
|
64
|
+
['lineNumber', {}],
|
|
65
|
+
['workspaceFolder', {}]
|
|
38
66
|
]);
|
|
39
67
|
|
|
40
68
|
registerVariables(service: AIVariableService): void {
|
|
@@ -42,21 +70,35 @@ export class TheiaVariableContribution implements AIVariableContribution, AIVari
|
|
|
42
70
|
// some variable contributions in Theia are done as part of the onStart, same as our AI variable contributions
|
|
43
71
|
// we therefore wait for all of them to be registered before we register we map them to our own
|
|
44
72
|
this.variableRegistry.getVariables().forEach(variable => {
|
|
45
|
-
|
|
73
|
+
if (!this.variableRenameMap.has(variable.name)) {
|
|
74
|
+
return; // Do not register variables not part of the map
|
|
75
|
+
}
|
|
76
|
+
const mapping = this.variableRenameMap.get(variable.name)!;
|
|
77
|
+
const newName = (mapping.name && mapping.name.trim() !== '') ? mapping.name : variable.name;
|
|
78
|
+
const newDescription = (mapping.description && mapping.description.trim() !== '') ? mapping.description
|
|
79
|
+
: (variable.description && variable.description.trim() !== '' ? variable.description
|
|
80
|
+
: nls.localize('theia/ai/core/variable-contribution/builtInVariable', 'Theia Built-in Variable'));
|
|
81
|
+
|
|
46
82
|
service.registerResolver({
|
|
47
|
-
id:
|
|
48
|
-
name:
|
|
49
|
-
description:
|
|
83
|
+
id: `${TheiaVariableContribution.THEIA_PREFIX}${variable.name}`,
|
|
84
|
+
name: newName,
|
|
85
|
+
description: newDescription
|
|
50
86
|
}, this);
|
|
51
87
|
});
|
|
52
88
|
});
|
|
53
89
|
}
|
|
54
90
|
|
|
55
91
|
protected toTheiaVariable(request: AIVariableResolutionRequest): string {
|
|
56
|
-
|
|
92
|
+
// Remove the THEIA_PREFIX if present before constructing the variable string
|
|
93
|
+
const variableId = request.variable.id.startsWith(TheiaVariableContribution.THEIA_PREFIX) ? request.variable.id.slice(TheiaVariableContribution.THEIA_PREFIX.length) :
|
|
94
|
+
request.variable.id;
|
|
95
|
+
return `\${${variableId}${request.arg ? ':' + request.arg : ''}}`;
|
|
57
96
|
}
|
|
58
97
|
|
|
59
98
|
async canResolve(request: AIVariableResolutionRequest, context: AIVariableContext): Promise<number> {
|
|
99
|
+
if (!request.variable.id.startsWith(TheiaVariableContribution.THEIA_PREFIX)) {
|
|
100
|
+
return 0;
|
|
101
|
+
}
|
|
60
102
|
// some variables are not resolvable without providing a specific context
|
|
61
103
|
// this may be expensive but was not a problem for Theia's built-in variables
|
|
62
104
|
const resolved = await this.variableResolverService.resolve(this.toTheiaVariable(request), context);
|
|
@@ -68,4 +110,3 @@ export class TheiaVariableContribution implements AIVariableContribution, AIVari
|
|
|
68
110
|
return resolved ? { value: resolved, variable: request.variable } : undefined;
|
|
69
111
|
}
|
|
70
112
|
}
|
|
71
|
-
|
|
@@ -32,7 +32,14 @@ export const isLanguageModelRequestMessage = (obj: unknown): obj is LanguageMode
|
|
|
32
32
|
'query' in obj &&
|
|
33
33
|
typeof (obj as { query: unknown }).query === 'string'
|
|
34
34
|
);
|
|
35
|
-
|
|
35
|
+
|
|
36
|
+
export interface ToolRequestParameterProperty {
|
|
37
|
+
type?: string;
|
|
38
|
+
anyOf?: ToolRequestParameterProperty[];
|
|
39
|
+
[key: string]: unknown;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export type ToolRequestParametersProperties = Record<string, ToolRequestParameterProperty>;
|
|
36
43
|
export interface ToolRequestParameters {
|
|
37
44
|
type?: 'object';
|
|
38
45
|
properties: ToolRequestParametersProperties;
|
|
@@ -48,17 +55,45 @@ export interface ToolRequest {
|
|
|
48
55
|
}
|
|
49
56
|
|
|
50
57
|
export namespace ToolRequest {
|
|
58
|
+
function isToolRequestParameterProperty(obj: unknown): obj is ToolRequestParameterProperty {
|
|
59
|
+
if (!obj || typeof obj !== 'object') {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
const record = obj as Record<string, unknown>;
|
|
63
|
+
|
|
64
|
+
// Check that at least one of "type" or "anyOf" exists
|
|
65
|
+
if (!('type' in record) && !('anyOf' in record)) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// If an "anyOf" field is present, it must be an array where each item is also a valid property.
|
|
70
|
+
if ('anyOf' in record) {
|
|
71
|
+
if (!Array.isArray(record.anyOf)) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
for (const item of record.anyOf) {
|
|
75
|
+
if (!isToolRequestParameterProperty(item)) {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
if ('type' in record && typeof record.type !== 'string') {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// No further checks required for additional properties.
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
51
87
|
export function isToolRequestParametersProperties(obj: unknown): obj is ToolRequestParametersProperties {
|
|
52
|
-
if (!obj || typeof obj !== 'object') {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
);
|
|
88
|
+
if (!obj || typeof obj !== 'object') {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
return Object.entries(obj).every(([key, value]) => {
|
|
92
|
+
if (typeof key !== 'string') {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
return isToolRequestParameterProperty(value);
|
|
96
|
+
});
|
|
62
97
|
}
|
|
63
98
|
export function isToolRequestParameters(obj: unknown): obj is ToolRequestParameters {
|
|
64
99
|
return !!obj && typeof obj === 'object' &&
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2025 EclipseSource GmbH.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
import { expect } from 'chai';
|
|
17
|
+
import { ToolRequest } from '../common/language-model';
|
|
18
|
+
|
|
19
|
+
describe('isToolRequestParameters', () => {
|
|
20
|
+
it('should return true for valid ToolRequestParameters', () => {
|
|
21
|
+
const validParams = {
|
|
22
|
+
type: 'object',
|
|
23
|
+
properties: {
|
|
24
|
+
param1: {
|
|
25
|
+
type: 'string'
|
|
26
|
+
},
|
|
27
|
+
param2: {
|
|
28
|
+
type: 'number'
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
required: ['param1']
|
|
32
|
+
};
|
|
33
|
+
expect(ToolRequest.isToolRequestParameters(validParams)).to.be.true;
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('should return false for ToolRequestParameters without type or anyOf', () => {
|
|
37
|
+
const paramsWithoutType = {
|
|
38
|
+
properties: {
|
|
39
|
+
param1: {
|
|
40
|
+
description: 'string'
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
required: ['param1']
|
|
44
|
+
};
|
|
45
|
+
expect(ToolRequest.isToolRequestParameters(paramsWithoutType)).to.be.false;
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('should return false for invalid ToolRequestParameters with wrong property type', () => {
|
|
49
|
+
const invalidParams = {
|
|
50
|
+
type: 'object',
|
|
51
|
+
properties: {
|
|
52
|
+
param1: {
|
|
53
|
+
type: 123
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
expect(ToolRequest.isToolRequestParameters(invalidParams)).to.be.false;
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('should return false if properties is not an object', () => {
|
|
61
|
+
const invalidParams = {
|
|
62
|
+
type: 'object',
|
|
63
|
+
properties: 'not-an-object',
|
|
64
|
+
};
|
|
65
|
+
expect(ToolRequest.isToolRequestParameters(invalidParams)).to.be.false;
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('should return true if required is missing', () => {
|
|
69
|
+
const missingRequiredParams = {
|
|
70
|
+
type: 'object',
|
|
71
|
+
properties: {
|
|
72
|
+
param1: {
|
|
73
|
+
type: 'string'
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
expect(ToolRequest.isToolRequestParameters(missingRequiredParams)).to.be.true;
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it('should return false if required is not an array', () => {
|
|
81
|
+
const invalidRequiredParams = {
|
|
82
|
+
type: 'object',
|
|
83
|
+
properties: {
|
|
84
|
+
param1: {
|
|
85
|
+
type: 'string'
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
required: 'param1'
|
|
89
|
+
};
|
|
90
|
+
expect(ToolRequest.isToolRequestParameters(invalidRequiredParams)).to.be.false;
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it('should return false if a required field is not a string', () => {
|
|
94
|
+
const invalidRequiredParams = {
|
|
95
|
+
type: 'object',
|
|
96
|
+
properties: {
|
|
97
|
+
param1: {
|
|
98
|
+
type: 'string'
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
required: [123]
|
|
102
|
+
};
|
|
103
|
+
expect(ToolRequest.isToolRequestParameters(invalidRequiredParams)).to.be.false;
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it('should validate properties with anyOf correctly', () => {
|
|
107
|
+
const paramsWithAnyOf = {
|
|
108
|
+
type: 'object',
|
|
109
|
+
properties: {
|
|
110
|
+
param1: {
|
|
111
|
+
anyOf: [
|
|
112
|
+
{ type: 'string' },
|
|
113
|
+
{ type: 'number' }
|
|
114
|
+
]
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
required: ['param1']
|
|
118
|
+
};
|
|
119
|
+
expect(ToolRequest.isToolRequestParameters(paramsWithAnyOf)).to.be.true;
|
|
120
|
+
});
|
|
121
|
+
});
|