@theia/ai-core 1.54.0 → 1.55.0-next.25

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.
@@ -19,5 +19,7 @@ export interface CommunicationRecordingService {
19
19
  recordResponse(responseEntry: CommunicationResponseEntry): void;
20
20
  readonly onDidRecordResponse: Event<CommunicationResponseEntry>;
21
21
  getHistory(agentId: string): CommunicationHistory;
22
+ clearHistory(): void;
23
+ readonly onStructuralChange: Event<void>;
22
24
  }
23
25
  //# sourceMappingURL=communication-recording-service.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"communication-recording-service.d.ts","sourceRoot":"","sources":["../../src/common/communication-recording-service.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,MAAM,MAAM,oBAAoB,GAAG,yBAAyB,EAAE,CAAC;AAE/D,MAAM,WAAW,yBAAyB;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;CACxB;AAED,MAAM,MAAM,yBAAyB,GAAG,IAAI,CAAC,yBAAyB,EAAE,UAAU,GAAG,cAAc,CAAC,CAAC;AACrG,MAAM,MAAM,0BAA0B,GAAG,IAAI,CAAC,yBAAyB,EAAE,SAAS,CAAC,CAAC;AAEpF,eAAO,MAAM,6BAA6B,eAA0C,CAAC;AACrF,MAAM,WAAW,6BAA6B;IAC1C,aAAa,CAAC,YAAY,EAAE,yBAAyB,GAAG,IAAI,CAAC;IAC7D,QAAQ,CAAC,kBAAkB,EAAE,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAE9D,cAAc,CAAC,aAAa,EAAE,0BAA0B,GAAG,IAAI,CAAC;IAChE,QAAQ,CAAC,mBAAmB,EAAE,KAAK,CAAC,0BAA0B,CAAC,CAAC;IAEhE,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,oBAAoB,CAAC;CACrD"}
1
+ {"version":3,"file":"communication-recording-service.d.ts","sourceRoot":"","sources":["../../src/common/communication-recording-service.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,MAAM,MAAM,oBAAoB,GAAG,yBAAyB,EAAE,CAAC;AAE/D,MAAM,WAAW,yBAAyB;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;CACxB;AAED,MAAM,MAAM,yBAAyB,GAAG,IAAI,CAAC,yBAAyB,EAAE,UAAU,GAAG,cAAc,CAAC,CAAC;AACrG,MAAM,MAAM,0BAA0B,GAAG,IAAI,CAAC,yBAAyB,EAAE,SAAS,CAAC,CAAC;AAEpF,eAAO,MAAM,6BAA6B,eAA0C,CAAC;AACrF,MAAM,WAAW,6BAA6B;IAC1C,aAAa,CAAC,YAAY,EAAE,yBAAyB,GAAG,IAAI,CAAC;IAC7D,QAAQ,CAAC,kBAAkB,EAAE,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAE9D,cAAc,CAAC,aAAa,EAAE,0BAA0B,GAAG,IAAI,CAAC;IAChE,QAAQ,CAAC,mBAAmB,EAAE,KAAK,CAAC,0BAA0B,CAAC,CAAC;IAEhE,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,oBAAoB,CAAC;IAElD,YAAY,IAAI,IAAI,CAAC;IACrB,QAAQ,CAAC,kBAAkB,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;CAC5C"}
@@ -1,5 +1,16 @@
1
1
  import { LanguageModelResponse, ToolRequest } from './language-model';
2
+ /**
3
+ * Retrieves the text content from a `LanguageModelResponse` object.
4
+ *
5
+ * **Important:** For stream responses, the stream can only be consumed once. Calling this function multiple times on the same stream response will return an empty string (`''`)
6
+ * on subsequent calls, as the stream will have already been consumed.
7
+ *
8
+ * @param {LanguageModelResponse} response - The response object, which may contain a text, stream, or parsed response.
9
+ * @returns {Promise<string>} - A promise that resolves to the text content of the response.
10
+ * @throws {Error} - Throws an error if the response type is not supported or does not contain valid text content.
11
+ */
2
12
  export declare const getTextOfResponse: (response: LanguageModelResponse) => Promise<string>;
3
13
  export declare const getJsonOfResponse: (response: LanguageModelResponse) => Promise<unknown>;
14
+ export declare const getJsonOfText: (text: string) => unknown;
4
15
  export declare const toolRequestToPromptText: (toolRequest: ToolRequest) => string;
5
16
  //# sourceMappingURL=language-model-util.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"language-model-util.d.ts","sourceRoot":"","sources":["../../src/common/language-model-util.ts"],"names":[],"mappings":"AAgBA,OAAO,EAA8D,qBAAqB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAElI,eAAO,MAAM,iBAAiB,aAAoB,qBAAqB,KAAG,QAAQ,MAAM,CAWvF,CAAC;AAEF,eAAO,MAAM,iBAAiB,aAAoB,qBAAqB,KAAG,QAAQ,OAAO,CAiBxF,CAAC;AACF,eAAO,MAAM,uBAAuB,gBAAiB,WAAW,KAAG,MAiBlE,CAAC"}
1
+ {"version":3,"file":"language-model-util.d.ts","sourceRoot":"","sources":["../../src/common/language-model-util.ts"],"names":[],"mappings":"AAgBA,OAAO,EAA6F,qBAAqB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEjK;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,aAAoB,qBAAqB,KAAG,QAAQ,MAAM,CAavF,CAAC;AAEF,eAAO,MAAM,iBAAiB,aAAoB,qBAAqB,KAAG,QAAQ,OAAO,CAGxF,CAAC;AAEF,eAAO,MAAM,aAAa,SAAU,MAAM,KAAG,OAgB5C,CAAC;AAEF,eAAO,MAAM,uBAAuB,gBAAiB,WAAW,KAAG,MAiBlE,CAAC"}
@@ -15,8 +15,18 @@
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
- exports.toolRequestToPromptText = exports.getJsonOfResponse = exports.getTextOfResponse = void 0;
18
+ exports.toolRequestToPromptText = exports.getJsonOfText = exports.getJsonOfResponse = exports.getTextOfResponse = void 0;
19
19
  const language_model_1 = require("./language-model");
20
+ /**
21
+ * Retrieves the text content from a `LanguageModelResponse` object.
22
+ *
23
+ * **Important:** For stream responses, the stream can only be consumed once. Calling this function multiple times on the same stream response will return an empty string (`''`)
24
+ * on subsequent calls, as the stream will have already been consumed.
25
+ *
26
+ * @param {LanguageModelResponse} response - The response object, which may contain a text, stream, or parsed response.
27
+ * @returns {Promise<string>} - A promise that resolves to the text content of the response.
28
+ * @throws {Error} - Throws an error if the response type is not supported or does not contain valid text content.
29
+ */
20
30
  const getTextOfResponse = async (response) => {
21
31
  var _a;
22
32
  if ((0, language_model_1.isLanguageModelTextResponse)(response)) {
@@ -29,11 +39,18 @@ const getTextOfResponse = async (response) => {
29
39
  }
30
40
  return result;
31
41
  }
42
+ else if ((0, language_model_1.isLanguageModelParsedResponse)(response)) {
43
+ return response.content;
44
+ }
32
45
  throw new Error(`Invalid response type ${response}`);
33
46
  };
34
47
  exports.getTextOfResponse = getTextOfResponse;
35
48
  const getJsonOfResponse = async (response) => {
36
49
  const text = await (0, exports.getTextOfResponse)(response);
50
+ return (0, exports.getJsonOfText)(text);
51
+ };
52
+ exports.getJsonOfResponse = getJsonOfResponse;
53
+ const getJsonOfText = (text) => {
37
54
  if (text.startsWith('```json')) {
38
55
  const regex = /```json\s*([\s\S]*?)\s*```/g;
39
56
  let match;
@@ -52,7 +69,7 @@ const getJsonOfResponse = async (response) => {
52
69
  }
53
70
  throw new Error('Invalid response format');
54
71
  };
55
- exports.getJsonOfResponse = getJsonOfResponse;
72
+ exports.getJsonOfText = getJsonOfText;
56
73
  const toolRequestToPromptText = (toolRequest) => {
57
74
  const parameters = toolRequest.parameters;
58
75
  let paramsText = '';
@@ -1 +1 @@
1
- {"version":3,"file":"language-model-util.js","sourceRoot":"","sources":["../../src/common/language-model-util.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,qDAAkI;AAE3H,MAAM,iBAAiB,GAAG,KAAK,EAAE,QAA+B,EAAmB,EAAE;;IACxF,IAAI,IAAA,4CAA2B,EAAC,QAAQ,CAAC,EAAE,CAAC;QACxC,OAAO,QAAQ,CAAC,IAAI,CAAC;IACzB,CAAC;SAAM,IAAI,IAAA,8CAA6B,EAAC,QAAQ,CAAC,EAAE,CAAC;QACjD,IAAI,MAAM,GAAG,EAAE,CAAC;QAChB,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,QAAQ,CAAC,MAAM,EAAE,CAAC;YACxC,MAAM,IAAI,MAAA,KAAK,CAAC,OAAO,mCAAI,EAAE,CAAC;QAClC,CAAC;QACD,OAAO,MAAM,CAAC;IAClB,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,yBAAyB,QAAQ,EAAE,CAAC,CAAC;AACzD,CAAC,CAAC;AAXW,QAAA,iBAAiB,qBAW5B;AAEK,MAAM,iBAAiB,GAAG,KAAK,EAAE,QAA+B,EAAoB,EAAE;IACzF,MAAM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C,CAAC,CAAC;aACD,IAAI,CAAC,IAAI,CAAC,CAAC;IACpB,CAAC;IACD,MAAM,eAAe,GAAG,WAAW,CAAC,WAAW;QAC3C,CAAC,CAAC,KAAK,WAAW,CAAC,WAAW,EAAE;QAChC,CAAC,CAAC,EAAE,CAAC;IACT,OAAO,0BAA0B,WAAW,CAAC,EAAE,IAAI,UAAU,IAAI,eAAe,EAAE,CAAC;AACvF,CAAC,CAAC;AAjBW,QAAA,uBAAuB,2BAiBlC"}
1
+ {"version":3,"file":"language-model-util.js","sourceRoot":"","sources":["../../src/common/language-model-util.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,qDAAiK;AAEjK;;;;;;;;;GASG;AACI,MAAM,iBAAiB,GAAG,KAAK,EAAE,QAA+B,EAAmB,EAAE;;IACxF,IAAI,IAAA,4CAA2B,EAAC,QAAQ,CAAC,EAAE,CAAC;QACxC,OAAO,QAAQ,CAAC,IAAI,CAAC;IACzB,CAAC;SAAM,IAAI,IAAA,8CAA6B,EAAC,QAAQ,CAAC,EAAE,CAAC;QACjD,IAAI,MAAM,GAAG,EAAE,CAAC;QAChB,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,QAAQ,CAAC,MAAM,EAAE,CAAC;YACxC,MAAM,IAAI,MAAA,KAAK,CAAC,OAAO,mCAAI,EAAE,CAAC;QAClC,CAAC;QACD,OAAO,MAAM,CAAC;IAClB,CAAC;SAAM,IAAI,IAAA,8CAA6B,EAAC,QAAQ,CAAC,EAAE,CAAC;QACjD,OAAO,QAAQ,CAAC,OAAO,CAAC;IAC5B,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,yBAAyB,QAAQ,EAAE,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AAU,EAAE,CAAC;QACb,MAAM,UAAU,GAAG,UAAU,CAAC,UAAU,CAAC;QACzC,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC;aAC/B,GAAG,CAAC,GAAG,CAAC,EAAE;YACP,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC;YAC9B,OAAO,GAAG,GAAG,KAAK,KAAK,CAAC,IAAI,EAAE,CAAC;QACnC,CAAC,CAAC;aACD,IAAI,CAAC,IAAI,CAAC,CAAC;IACpB,CAAC;IACD,MAAM,eAAe,GAAG,WAAW,CAAC,WAAW;QAC3C,CAAC,CAAC,KAAK,WAAW,CAAC,WAAW,EAAE;QAChC,CAAC,CAAC,EAAE,CAAC;IACT,OAAO,0BAA0B,WAAW,CAAC,EAAE,IAAI,UAAU,IAAI,eAAe,EAAE,CAAC;AACvF,CAAC,CAAC;AAjBW,QAAA,uBAAuB,2BAiBlC"}
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@theia/ai-core",
3
- "version": "1.54.0",
3
+ "version": "1.55.0-next.25+2be612f8a",
4
4
  "description": "Theia - AI Core",
5
5
  "dependencies": {
6
- "@theia/core": "1.54.0",
7
- "@theia/editor": "1.54.0",
8
- "@theia/filesystem": "1.54.0",
9
- "@theia/monaco": "1.54.0",
6
+ "@theia/core": "1.55.0-next.25+2be612f8a",
7
+ "@theia/editor": "1.55.0-next.25+2be612f8a",
8
+ "@theia/filesystem": "1.55.0-next.25+2be612f8a",
9
+ "@theia/monaco": "1.55.0-next.25+2be612f8a",
10
10
  "@theia/monaco-editor-core": "1.83.101",
11
- "@theia/output": "1.54.0",
12
- "@theia/variable-resolver": "1.54.0",
13
- "@theia/workspace": "1.54.0",
11
+ "@theia/output": "1.55.0-next.25+2be612f8a",
12
+ "@theia/variable-resolver": "1.55.0-next.25+2be612f8a",
13
+ "@theia/workspace": "1.55.0-next.25+2be612f8a",
14
14
  "minimatch": "^5.1.0",
15
15
  "tslib": "^2.6.2"
16
16
  },
@@ -55,5 +55,5 @@
55
55
  "nyc": {
56
56
  "extends": "../../configs/nyc.json"
57
57
  },
58
- "gitHead": "8fb36a237db744cff6e78eaff1481e1f36bb7a69"
58
+ "gitHead": "2be612f8a7efb90c1183ba47f0897040925b304a"
59
59
  }
@@ -41,4 +41,7 @@ export interface CommunicationRecordingService {
41
41
  readonly onDidRecordResponse: Event<CommunicationResponseEntry>;
42
42
 
43
43
  getHistory(agentId: string): CommunicationHistory;
44
+
45
+ clearHistory(): void;
46
+ readonly onStructuralChange: Event<void>;
44
47
  }
@@ -14,8 +14,18 @@
14
14
  // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
15
  // *****************************************************************************
16
16
 
17
- import { isLanguageModelStreamResponse, isLanguageModelTextResponse, LanguageModelResponse, ToolRequest } from './language-model';
17
+ import { isLanguageModelParsedResponse, isLanguageModelStreamResponse, isLanguageModelTextResponse, LanguageModelResponse, ToolRequest } from './language-model';
18
18
 
19
+ /**
20
+ * Retrieves the text content from a `LanguageModelResponse` object.
21
+ *
22
+ * **Important:** For stream responses, the stream can only be consumed once. Calling this function multiple times on the same stream response will return an empty string (`''`)
23
+ * on subsequent calls, as the stream will have already been consumed.
24
+ *
25
+ * @param {LanguageModelResponse} response - The response object, which may contain a text, stream, or parsed response.
26
+ * @returns {Promise<string>} - A promise that resolves to the text content of the response.
27
+ * @throws {Error} - Throws an error if the response type is not supported or does not contain valid text content.
28
+ */
19
29
  export const getTextOfResponse = async (response: LanguageModelResponse): Promise<string> => {
20
30
  if (isLanguageModelTextResponse(response)) {
21
31
  return response.text;
@@ -25,12 +35,18 @@ export const getTextOfResponse = async (response: LanguageModelResponse): Promis
25
35
  result += chunk.content ?? '';
26
36
  }
27
37
  return result;
38
+ } else if (isLanguageModelParsedResponse(response)) {
39
+ return response.content;
28
40
  }
29
41
  throw new Error(`Invalid response type ${response}`);
30
42
  };
31
43
 
32
44
  export const getJsonOfResponse = async (response: LanguageModelResponse): Promise<unknown> => {
33
45
  const text = await getTextOfResponse(response);
46
+ return getJsonOfText(text);
47
+ };
48
+
49
+ export const getJsonOfText = (text: string): unknown => {
34
50
  if (text.startsWith('```json')) {
35
51
  const regex = /```json\s*([\s\S]*?)\s*```/g;
36
52
  let match;
@@ -47,6 +63,7 @@ export const getJsonOfResponse = async (response: LanguageModelResponse): Promis
47
63
  }
48
64
  throw new Error('Invalid response format');
49
65
  };
66
+
50
67
  export const toolRequestToPromptText = (toolRequest: ToolRequest): string => {
51
68
  const parameters = toolRequest.parameters;
52
69
  let paramsText = '';