@theia/ai-core 1.73.0-next.3 → 1.73.0-next.7
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.
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
16
|
// *****************************************************************************
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
const language_model_1 = require("./language-model");
|
|
19
18
|
const chai_1 = require("chai");
|
|
19
|
+
const language_model_1 = require("./language-model");
|
|
20
20
|
describe('isModelMatching', () => {
|
|
21
21
|
it('returns false with one of two parameter mismatches', () => {
|
|
22
22
|
(0, chai_1.expect)((0, language_model_1.isModelMatching)({
|
|
@@ -59,4 +59,68 @@ describe('isModelMatching', () => {
|
|
|
59
59
|
})).eql(true);
|
|
60
60
|
});
|
|
61
61
|
});
|
|
62
|
+
describe('isToolCallContent', () => {
|
|
63
|
+
it('accepts a well-formed ToolCallContent with a text item', () => {
|
|
64
|
+
(0, chai_1.expect)((0, language_model_1.isToolCallContent)({ content: [{ type: 'text', text: 'hello' }] })).to.be.true;
|
|
65
|
+
});
|
|
66
|
+
it('accepts an empty content array', () => {
|
|
67
|
+
(0, chai_1.expect)((0, language_model_1.isToolCallContent)({ content: [] })).to.be.true;
|
|
68
|
+
});
|
|
69
|
+
it('accepts content with mixed item types', () => {
|
|
70
|
+
const value = {
|
|
71
|
+
content: [
|
|
72
|
+
{ type: 'text', text: 'hello' },
|
|
73
|
+
{ type: 'image', mimeType: 'image/png', base64data: 'abc' },
|
|
74
|
+
{ type: 'error', data: 'boom' }
|
|
75
|
+
]
|
|
76
|
+
};
|
|
77
|
+
(0, chai_1.expect)((0, language_model_1.isToolCallContent)(value)).to.be.true;
|
|
78
|
+
});
|
|
79
|
+
it('rejects undefined', () => {
|
|
80
|
+
(0, chai_1.expect)((0, language_model_1.isToolCallContent)(undefined)).to.be.false;
|
|
81
|
+
});
|
|
82
|
+
it('rejects null', () => {
|
|
83
|
+
// eslint-disable-next-line no-null/no-null
|
|
84
|
+
(0, chai_1.expect)((0, language_model_1.isToolCallContent)(null)).to.be.false;
|
|
85
|
+
});
|
|
86
|
+
it('rejects primitive values', () => {
|
|
87
|
+
(0, chai_1.expect)((0, language_model_1.isToolCallContent)('not an object')).to.be.false;
|
|
88
|
+
(0, chai_1.expect)((0, language_model_1.isToolCallContent)(42)).to.be.false;
|
|
89
|
+
(0, chai_1.expect)((0, language_model_1.isToolCallContent)(true)).to.be.false;
|
|
90
|
+
});
|
|
91
|
+
it('rejects objects without a content key', () => {
|
|
92
|
+
(0, chai_1.expect)((0, language_model_1.isToolCallContent)({ files: [] })).to.be.false;
|
|
93
|
+
(0, chai_1.expect)((0, language_model_1.isToolCallContent)({})).to.be.false;
|
|
94
|
+
});
|
|
95
|
+
// Regression: this is the exact shape that triggered the chat-flicker bug.
|
|
96
|
+
// `getWorkspaceFileList` echoes workspace entry names into the result keys,
|
|
97
|
+
// and a workspace containing a directory literally named `content` produces
|
|
98
|
+
// an object where `content` is a plain string, not a ToolCallContentResult
|
|
99
|
+
// array.
|
|
100
|
+
it('rejects an object whose content is a string (regression)', () => {
|
|
101
|
+
(0, chai_1.expect)((0, language_model_1.isToolCallContent)({ content: 'directory' })).to.be.false;
|
|
102
|
+
});
|
|
103
|
+
it('rejects an object whose content is a nested object', () => {
|
|
104
|
+
(0, chai_1.expect)((0, language_model_1.isToolCallContent)({ content: { nested: true } })).to.be.false;
|
|
105
|
+
});
|
|
106
|
+
it('rejects an object whose content is a number', () => {
|
|
107
|
+
(0, chai_1.expect)((0, language_model_1.isToolCallContent)({ content: 42 })).to.be.false;
|
|
108
|
+
});
|
|
109
|
+
it('rejects an object whose content is null', () => {
|
|
110
|
+
// eslint-disable-next-line no-null/no-null
|
|
111
|
+
(0, chai_1.expect)((0, language_model_1.isToolCallContent)({ content: null })).to.be.false;
|
|
112
|
+
});
|
|
113
|
+
it('rejects a top-level array (no content key)', () => {
|
|
114
|
+
(0, chai_1.expect)((0, language_model_1.isToolCallContent)([{ type: 'text', text: 'hello' }])).to.be.false;
|
|
115
|
+
});
|
|
116
|
+
it('rejects a directory-listing-shaped object containing a "content" entry (regression)', () => {
|
|
117
|
+
const value = {
|
|
118
|
+
'.devcontainer': 'directory',
|
|
119
|
+
'config.yaml': 'file',
|
|
120
|
+
'content': 'directory',
|
|
121
|
+
'go.mod': 'file'
|
|
122
|
+
};
|
|
123
|
+
(0, chai_1.expect)((0, language_model_1.isToolCallContent)(value)).to.be.false;
|
|
124
|
+
});
|
|
125
|
+
});
|
|
62
126
|
//# sourceMappingURL=language-model.spec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"language-model.spec.js","sourceRoot":"","sources":["../../src/common/language-model.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;;AAEhF
|
|
1
|
+
{"version":3,"file":"language-model.spec.js","sourceRoot":"","sources":["../../src/common/language-model.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;;AAEhF,+BAA8B;AAC9B,qDAA4G;AAE5G,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC7B,EAAE,CAAC,oDAAoD,EAAE,GAAG,EAAE;QAC1D,IAAA,aAAM,EACF,IAAA,gCAAe,EACY;YACnB,IAAI,EAAE,KA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AE;QACnD,IAAA,aAAM,EAAC,IAAA,kCAAiB,EAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC;IAC3D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,yCAAyC,EAAE,GAAG,EAAE;QAC/C,2CAA2C;QAC3C,IAAA,aAAM,EAAC,IAAA,kCAAiB,EAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC;IAC7D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,4CAA4C,EAAE,GAAG,EAAE;QAClD,IAAA,aAAM,EAAC,IAAA,kCAAiB,EAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC;IAC7E,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,qFAAqF,EAAE,GAAG,EAAE;QAC3F,MAAM,KAAK,GAAG;YACV,eAAe,EAAE,WAAW;YAC5B,aAAa,EAAE,MAAM;YACrB,SAAS,EAAE,WAAW;YACtB,QAAQ,EAAE,MAAM;SACnB,CAAC;QACF,IAAA,aAAM,EAAC,IAAA,kCAAiB,EAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC;IACjD,CAAC,CAAC,CAAC;AAEP,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theia/ai-core",
|
|
3
|
-
"version": "1.73.0-next.
|
|
3
|
+
"version": "1.73.0-next.7+c60326bb9",
|
|
4
4
|
"description": "Theia - AI Core",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@theia/core": "1.73.0-next.
|
|
7
|
-
"@theia/editor": "1.73.0-next.
|
|
8
|
-
"@theia/filesystem": "1.73.0-next.
|
|
9
|
-
"@theia/monaco": "1.73.0-next.
|
|
6
|
+
"@theia/core": "1.73.0-next.7+c60326bb9",
|
|
7
|
+
"@theia/editor": "1.73.0-next.7+c60326bb9",
|
|
8
|
+
"@theia/filesystem": "1.73.0-next.7+c60326bb9",
|
|
9
|
+
"@theia/monaco": "1.73.0-next.7+c60326bb9",
|
|
10
10
|
"@theia/monaco-editor-core": "1.108.201",
|
|
11
|
-
"@theia/output": "1.73.0-next.
|
|
12
|
-
"@theia/variable-resolver": "1.73.0-next.
|
|
13
|
-
"@theia/workspace": "1.73.0-next.
|
|
11
|
+
"@theia/output": "1.73.0-next.7+c60326bb9",
|
|
12
|
+
"@theia/variable-resolver": "1.73.0-next.7+c60326bb9",
|
|
13
|
+
"@theia/workspace": "1.73.0-next.7+c60326bb9",
|
|
14
14
|
"@types/js-yaml": "^4.0.9",
|
|
15
15
|
"fast-deep-equal": "^3.1.3",
|
|
16
16
|
"js-yaml": "^4.1.1",
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"nyc": {
|
|
59
59
|
"extends": "../../configs/nyc.json"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "c60326bb9abc480805eec58eed75e58f08c2569a"
|
|
62
62
|
}
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
|
-
import { isModelMatching, LanguageModel, LanguageModelSelector } from './language-model';
|
|
18
17
|
import { expect } from 'chai';
|
|
18
|
+
import { isModelMatching, isToolCallContent, LanguageModel, LanguageModelSelector } from './language-model';
|
|
19
19
|
|
|
20
20
|
describe('isModelMatching', () => {
|
|
21
21
|
it('returns false with one of two parameter mismatches', () => {
|
|
@@ -84,3 +84,82 @@ describe('isModelMatching', () => {
|
|
|
84
84
|
).eql(true);
|
|
85
85
|
});
|
|
86
86
|
});
|
|
87
|
+
|
|
88
|
+
describe('isToolCallContent', () => {
|
|
89
|
+
|
|
90
|
+
it('accepts a well-formed ToolCallContent with a text item', () => {
|
|
91
|
+
expect(isToolCallContent({ content: [{ type: 'text', text: 'hello' }] })).to.be.true;
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it('accepts an empty content array', () => {
|
|
95
|
+
expect(isToolCallContent({ content: [] })).to.be.true;
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it('accepts content with mixed item types', () => {
|
|
99
|
+
const value = {
|
|
100
|
+
content: [
|
|
101
|
+
{ type: 'text', text: 'hello' },
|
|
102
|
+
{ type: 'image', mimeType: 'image/png', base64data: 'abc' },
|
|
103
|
+
{ type: 'error', data: 'boom' }
|
|
104
|
+
]
|
|
105
|
+
};
|
|
106
|
+
expect(isToolCallContent(value)).to.be.true;
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('rejects undefined', () => {
|
|
110
|
+
expect(isToolCallContent(undefined)).to.be.false;
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it('rejects null', () => {
|
|
114
|
+
// eslint-disable-next-line no-null/no-null
|
|
115
|
+
expect(isToolCallContent(null)).to.be.false;
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it('rejects primitive values', () => {
|
|
119
|
+
expect(isToolCallContent('not an object')).to.be.false;
|
|
120
|
+
expect(isToolCallContent(42)).to.be.false;
|
|
121
|
+
expect(isToolCallContent(true)).to.be.false;
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it('rejects objects without a content key', () => {
|
|
125
|
+
expect(isToolCallContent({ files: [] })).to.be.false;
|
|
126
|
+
expect(isToolCallContent({})).to.be.false;
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
// Regression: this is the exact shape that triggered the chat-flicker bug.
|
|
130
|
+
// `getWorkspaceFileList` echoes workspace entry names into the result keys,
|
|
131
|
+
// and a workspace containing a directory literally named `content` produces
|
|
132
|
+
// an object where `content` is a plain string, not a ToolCallContentResult
|
|
133
|
+
// array.
|
|
134
|
+
it('rejects an object whose content is a string (regression)', () => {
|
|
135
|
+
expect(isToolCallContent({ content: 'directory' })).to.be.false;
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
it('rejects an object whose content is a nested object', () => {
|
|
139
|
+
expect(isToolCallContent({ content: { nested: true } })).to.be.false;
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it('rejects an object whose content is a number', () => {
|
|
143
|
+
expect(isToolCallContent({ content: 42 })).to.be.false;
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
it('rejects an object whose content is null', () => {
|
|
147
|
+
// eslint-disable-next-line no-null/no-null
|
|
148
|
+
expect(isToolCallContent({ content: null })).to.be.false;
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
it('rejects a top-level array (no content key)', () => {
|
|
152
|
+
expect(isToolCallContent([{ type: 'text', text: 'hello' }])).to.be.false;
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
it('rejects a directory-listing-shaped object containing a "content" entry (regression)', () => {
|
|
156
|
+
const value = {
|
|
157
|
+
'.devcontainer': 'directory',
|
|
158
|
+
'config.yaml': 'file',
|
|
159
|
+
'content': 'directory',
|
|
160
|
+
'go.mod': 'file'
|
|
161
|
+
};
|
|
162
|
+
expect(isToolCallContent(value)).to.be.false;
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
});
|