@opensumi/ide-core-common 2.27.3-rc-1708399099.0 → 2.27.3-rc-1710489030.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.
Files changed (128) hide show
  1. package/lib/codicons.d.ts +687 -0
  2. package/lib/codicons.d.ts.map +1 -0
  3. package/lib/codicons.js +735 -0
  4. package/lib/codicons.js.map +1 -0
  5. package/lib/command.d.ts.map +1 -1
  6. package/lib/const/application.d.ts +4 -4
  7. package/lib/const/application.d.ts.map +1 -1
  8. package/lib/const/application.js +7 -7
  9. package/lib/const/application.js.map +1 -1
  10. package/lib/contribution-provider.d.ts +1 -1
  11. package/lib/contribution-provider.d.ts.map +1 -1
  12. package/lib/di-helper/domain-helper.d.ts +0 -6
  13. package/lib/di-helper/domain-helper.d.ts.map +1 -1
  14. package/lib/di-helper/domain-helper.js +1 -33
  15. package/lib/di-helper/domain-helper.js.map +1 -1
  16. package/lib/electron.d.ts +1 -1
  17. package/lib/electron.d.ts.map +1 -1
  18. package/lib/event-bus/event-bus.d.ts +1 -1
  19. package/lib/event-bus/event-bus.d.ts.map +1 -1
  20. package/lib/hash-calculate/WASMInterface.d.ts.map +1 -1
  21. package/lib/hash-calculate/lockedCreate.d.ts.map +1 -1
  22. package/lib/index.d.ts +0 -1
  23. package/lib/index.d.ts.map +1 -1
  24. package/lib/index.js +0 -1
  25. package/lib/index.js.map +1 -1
  26. package/lib/json-schema.d.ts +25 -1
  27. package/lib/json-schema.d.ts.map +1 -1
  28. package/lib/line-text.d.ts.map +1 -1
  29. package/lib/localize.d.ts.map +1 -1
  30. package/lib/module.d.ts +7 -1
  31. package/lib/module.d.ts.map +1 -1
  32. package/lib/module.js.map +1 -1
  33. package/lib/network.d.ts +1 -0
  34. package/lib/network.d.ts.map +1 -1
  35. package/lib/network.js +1 -0
  36. package/lib/network.js.map +1 -1
  37. package/lib/problem-matcher.d.ts +2 -2
  38. package/lib/problem-matcher.d.ts.map +1 -1
  39. package/lib/problem-pattern.d.ts.map +1 -1
  40. package/lib/problem-pattern.js.map +1 -1
  41. package/lib/reference.d.ts +1 -1
  42. package/lib/reference.d.ts.map +1 -1
  43. package/lib/reporter.d.ts +1 -1
  44. package/lib/reporter.d.ts.map +1 -1
  45. package/lib/settings/ai-native.d.ts +5 -0
  46. package/lib/settings/ai-native.d.ts.map +1 -0
  47. package/lib/settings/ai-native.js +9 -0
  48. package/lib/settings/ai-native.js.map +1 -0
  49. package/lib/settings/general.d.ts +2 -1
  50. package/lib/settings/general.d.ts.map +1 -1
  51. package/lib/settings/index.d.ts +1 -0
  52. package/lib/settings/index.d.ts.map +1 -1
  53. package/lib/settings/index.js +1 -0
  54. package/lib/settings/index.js.map +1 -1
  55. package/lib/storage.d.ts +1 -1
  56. package/lib/storage.d.ts.map +1 -1
  57. package/lib/task-definition.d.ts +1 -1
  58. package/lib/task-definition.d.ts.map +1 -1
  59. package/lib/theme.d.ts +23 -0
  60. package/lib/theme.d.ts.map +1 -1
  61. package/lib/theme.js +82 -1
  62. package/lib/theme.js.map +1 -1
  63. package/lib/types/ai-native/index.d.ts +169 -0
  64. package/lib/types/ai-native/index.d.ts.map +1 -0
  65. package/lib/types/ai-native/index.js +23 -0
  66. package/lib/types/ai-native/index.js.map +1 -0
  67. package/lib/types/ai-native/reporter.d.ts +95 -0
  68. package/lib/types/ai-native/reporter.d.ts.map +1 -0
  69. package/lib/types/ai-native/reporter.js +21 -0
  70. package/lib/types/ai-native/reporter.js.map +1 -0
  71. package/lib/types/application.d.ts +1 -2
  72. package/lib/types/application.d.ts.map +1 -1
  73. package/lib/types/authentication.d.ts +1 -5
  74. package/lib/types/authentication.d.ts.map +1 -1
  75. package/lib/types/authentication.js.map +1 -1
  76. package/lib/types/file.d.ts +6 -0
  77. package/lib/types/file.d.ts.map +1 -1
  78. package/lib/types/file.js.map +1 -1
  79. package/lib/types/index.d.ts +1 -0
  80. package/lib/types/index.d.ts.map +1 -1
  81. package/lib/types/index.js +1 -0
  82. package/lib/types/index.js.map +1 -1
  83. package/lib/types/markdown.d.ts +1 -11
  84. package/lib/types/markdown.d.ts.map +1 -1
  85. package/lib/types/markers/markers-manager.d.ts.map +1 -1
  86. package/lib/types/markers/markers-manager.js +3 -4
  87. package/lib/types/markers/markers-manager.js.map +1 -1
  88. package/lib/types/markers/markers.d.ts.map +1 -1
  89. package/lib/types/rpc.d.ts +1 -5
  90. package/lib/types/rpc.d.ts.map +1 -1
  91. package/package.json +3 -3
  92. package/src/codicons.ts +751 -0
  93. package/src/command.ts +1 -1
  94. package/src/comparers.ts +1 -1
  95. package/src/const/application.ts +4 -4
  96. package/src/contribution-provider.ts +1 -1
  97. package/src/di-helper/domain-helper.ts +1 -34
  98. package/src/electron.ts +2 -2
  99. package/src/event-bus/event-bus.ts +2 -2
  100. package/src/hash-calculate/WASMInterface.ts +1 -1
  101. package/src/hash-calculate/lockedCreate.ts +1 -1
  102. package/src/index.ts +0 -1
  103. package/src/json-schema.ts +34 -10
  104. package/src/line-text.ts +1 -1
  105. package/src/localize.ts +1 -1
  106. package/src/module.ts +8 -1
  107. package/src/network.ts +2 -0
  108. package/src/problem-matcher.ts +5 -5
  109. package/src/problem-pattern.ts +2 -1
  110. package/src/reference.ts +1 -1
  111. package/src/reporter.ts +4 -4
  112. package/src/settings/ai-native.ts +4 -0
  113. package/src/settings/general.ts +1 -0
  114. package/src/settings/index.ts +1 -0
  115. package/src/storage.ts +2 -2
  116. package/src/task-definition.ts +2 -2
  117. package/src/theme.ts +92 -0
  118. package/src/types/ai-native/index.ts +205 -0
  119. package/src/types/ai-native/reporter.ts +109 -0
  120. package/src/types/application.ts +1 -2
  121. package/src/types/authentication.ts +1 -6
  122. package/src/types/file.ts +8 -0
  123. package/src/types/index.ts +1 -0
  124. package/src/types/markdown.ts +1 -10
  125. package/src/types/markers/markers-manager.ts +1 -2
  126. package/src/types/markers/markers.ts +1 -1
  127. package/src/types/rpc.ts +1 -5
  128. package/src/utils/ipc.ts +2 -2
package/src/command.ts CHANGED
@@ -2,7 +2,7 @@ import { Autowired, Injectable } from '@opensumi/di';
2
2
  import { Disposable, Emitter, Event, IDisposable, MaybePromise } from '@opensumi/ide-utils';
3
3
 
4
4
  import { ContributionProvider } from './contribution-provider';
5
- import { createLocalizedStr, ILocalizedStr, replaceLocalizePlaceholder } from './localize';
5
+ import { ILocalizedStr, createLocalizedStr, replaceLocalizePlaceholder } from './localize';
6
6
  import { getDebugLogger } from './log';
7
7
  import { IExtensionInfo } from './types';
8
8
 
package/src/comparers.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  *--------------------------------------------------------------------------------------------*/
5
5
  // Some code copied and modified from https://github.com/microsoft/vscode/blob/1.44.0/src/vs/base/common/comparers.ts
6
6
 
7
- import { path, IdleValue } from '@opensumi/ide-utils';
7
+ import { IdleValue, path } from '@opensumi/ide-utils';
8
8
 
9
9
  import { IRange } from './types';
10
10
  const { sep } = path;
@@ -4,10 +4,10 @@ export const DEFAULT_APPLICATION_WEB_HOST = 'web';
4
4
  export const DEFAULT_URI_SCHEME = 'sumi';
5
5
  export const DEFAULT_OPENVSX_REGISTRY = 'https://open-vsx.org'; // Official Registry
6
6
 
7
- export namespace DEFAULT_TRS_REGISTRY {
8
- export const ENDPOINT = 'https://marketplace.opentrs.cn';
9
- export const ACCOUNT_ID = 'clcJKq_Gea47whxAJGrgoYqf';
10
- export const MASTER_KEY = '_V_LPJ6Ar-1nrSVa05xDGBYp';
7
+ export namespace DEFAULT_ALIPAY_CLOUD_REGISTRY {
8
+ export const ENDPOINT = 'https://twebgwnet.alipay.com/atsmarketplace';
9
+ export const ACCOUNT_ID = 'WWPLOa7vWXCUTSHCfV5FK7Su';
10
+ export const MASTER_KEY = 'i6rkupqyvC6Bc6CiO0yVLNqq';
11
11
  }
12
12
 
13
13
  export const DEFAULT_VSCODE_ENGINE_VERSION = '1.68.0';
@@ -1,4 +1,4 @@
1
- import { Injector, Domain, ConstructorOf } from '@opensumi/di';
1
+ import { ConstructorOf, Domain, Injector } from '@opensumi/di';
2
2
 
3
3
  export const ContributionProvider = Symbol('ContributionProvider');
4
4
 
@@ -1,4 +1,4 @@
1
- import { markInjectable, getInjectableOpts, Domain } from '@opensumi/di';
1
+ import { Domain, getInjectableOpts, markInjectable } from '@opensumi/di';
2
2
 
3
3
  import { ConstructorOf } from '../declare';
4
4
 
@@ -13,36 +13,3 @@ export function Domain(...domains: Domain[]) {
13
13
  markInjectable(target, opts);
14
14
  };
15
15
  }
16
-
17
- const domainMap = new Map<Domain, ConstructorOf<any>>();
18
-
19
- /**
20
- * 带全局记录的 Domain 装饰器
21
- * @param domain
22
- */
23
- export function EffectDomain(domain: Domain) {
24
- return (target: ConstructorOf<any>) => {
25
- const opts = getInjectableOpts(target) || {};
26
- opts.domain = domain;
27
- markInjectable(target, opts);
28
-
29
- const tmp = domainMap.get(domain);
30
- if (!tmp) {
31
- domainMap.set(domain, target);
32
- }
33
- };
34
- }
35
-
36
- export function getDomainConstructors(...domains: Domain[]) {
37
- const constructorSet = new Set<ConstructorOf<any>>();
38
- for (const domain of domains) {
39
- const constructor = domainMap.get(domain);
40
- if (constructor) {
41
- constructorSet.add(constructor);
42
- } else {
43
- // eslint-disable-next-line no-console
44
- console.error(`Unable to retrieve the Constructor for ${String(domain)}`);
45
- }
46
- }
47
- return Array.from(constructorSet);
48
- }
package/src/electron.ts CHANGED
@@ -1,9 +1,9 @@
1
- import type Electron from 'electron';
2
-
3
1
  import { IDisposable } from '@opensumi/ide-utils';
4
2
 
5
3
  import { ExtensionCandidate } from './types';
6
4
 
5
+ import type Electron from 'electron';
6
+
7
7
  export interface IElectronMainApi<Events> {
8
8
  on(event: Events, listener: (...args) => void): IDisposable;
9
9
  }
@@ -1,10 +1,10 @@
1
1
  import { Injectable } from '@opensumi/di';
2
- import { Emitter, IAsyncResult, Event } from '@opensumi/ide-utils';
2
+ import { Emitter, Event, IAsyncResult } from '@opensumi/ide-utils';
3
3
 
4
4
  import { ConstructorOf } from '../declare';
5
5
 
6
6
  import { BasicEvent } from './basic-event';
7
- import { IEventBus, IEventListener, IEventFireOpts, IAsyncEventFireOpts } from './event-bus-types';
7
+ import { IAsyncEventFireOpts, IEventBus, IEventFireOpts, IEventListener } from './event-bus-types';
8
8
 
9
9
  @Injectable()
10
10
  export class EventBusImpl implements IEventBus {
@@ -7,7 +7,7 @@
7
7
  // copy and modified from https://github.com/Daninet/hash-wasm/blob/bd3a205ca5603fc80adf71d0966fc72e8d4fa0ef/lib/WASMInterface.ts
8
8
 
9
9
  import { Mutex } from './mutex';
10
- import { decodeBase64, getDigestHex, getUInt8Buffer, IDataType, writeHexToUInt8, hexStringEqualsUInt8 } from './util';
10
+ import { IDataType, decodeBase64, getDigestHex, getUInt8Buffer, hexStringEqualsUInt8, writeHexToUInt8 } from './util';
11
11
 
12
12
  export const MAX_HEAP = 16 * 1024;
13
13
  const WASM_FUNC_HASH_LENGTH = 4;
@@ -7,7 +7,7 @@
7
7
  // copy and modified from https://github.com/Daninet/hash-wasm/blob/bd3a205ca5603fc80adf71d0966fc72e8d4fa0ef/lib/lockedCreate.ts
8
8
 
9
9
  import { Mutex } from './mutex';
10
- import { WASMInterface, IWASMInterface } from './WASMInterface';
10
+ import { IWASMInterface, WASMInterface } from './WASMInterface';
11
11
 
12
12
  export async function lockedCreate(mutex: Mutex, binary: any, hashLength: number): Promise<IWASMInterface> {
13
13
  const unlock = await mutex.lock();
package/src/index.ts CHANGED
@@ -21,7 +21,6 @@ export * from './range';
21
21
  export * from './problem-pattern';
22
22
  export * from './problem-matcher';
23
23
  export * from './task-definition';
24
- export * from './node/port';
25
24
  export * from './line-text';
26
25
  export * from './keyboard';
27
26
  export * from './theme';
@@ -1,8 +1,10 @@
1
+ export type JSONSchemaType = string | 'number' | 'integer' | 'boolean' | 'null' | 'array' | 'object';
2
+
1
3
  export interface IJSONSchema {
2
4
  id?: string;
3
5
  $id?: string;
4
6
  $schema?: string;
5
- type?: string | string[];
7
+ type?: JSONSchemaType | JSONSchemaType[];
6
8
  title?: string;
7
9
  default?: any;
8
10
  definitions?: IJSONSchemaMap;
@@ -39,6 +41,7 @@ export interface IJSONSchema {
39
41
  const?: any;
40
42
  contains?: IJSONSchema;
41
43
  propertyNames?: IJSONSchema;
44
+ examples?: any[];
42
45
 
43
46
  // schema draft 07
44
47
  $comment?: string;
@@ -46,16 +49,37 @@ export interface IJSONSchema {
46
49
  then?: IJSONSchema;
47
50
  else?: IJSONSchema;
48
51
 
52
+ unevaluatedProperties?: boolean | IJSONSchema;
53
+ unevaluatedItems?: boolean | IJSONSchema;
54
+ minContains?: number;
55
+ maxContains?: number;
56
+ deprecated?: boolean;
57
+ dependentRequired?: { [prop: string]: string[] };
58
+ dependentSchemas?: IJSONSchemaMap;
59
+ $defs?: { [name: string]: IJSONSchema };
60
+ $anchor?: string;
61
+ $recursiveRef?: string;
62
+ $recursiveAnchor?: string;
63
+ $vocabulary?: any;
64
+
65
+ prefixItems?: IJSONSchema[];
66
+ $dynamicRef?: string;
67
+ $dynamicAnchor?: string;
68
+
49
69
  // VSCode extensions
50
- defaultSnippets?: IJSONSchemaSnippet[]; // VSCode extension
51
- errorMessage?: string; // VSCode extension
52
- patternErrorMessage?: string; // VSCode extension
53
- deprecationMessage?: string; // VSCode extension
54
- enumDescriptions?: string[]; // VSCode extension
55
- markdownEnumDescriptions?: string[]; // VSCode extension
56
- markdownDescription?: string; // VSCode extension
57
- doNotSuggest?: boolean; // VSCode extension
58
- allowComments?: boolean; // VSCode extension
70
+
71
+ defaultSnippets?: IJSONSchemaSnippet[];
72
+ errorMessage?: string;
73
+ patternErrorMessage?: string;
74
+ deprecationMessage?: string;
75
+ markdownDeprecationMessage?: string;
76
+ enumDescriptions?: string[];
77
+ markdownEnumDescriptions?: string[];
78
+ markdownDescription?: string;
79
+ doNotSuggest?: boolean;
80
+ suggestSortText?: string;
81
+ allowComments?: boolean;
82
+ allowTrailingCommas?: boolean;
59
83
  }
60
84
 
61
85
  export interface IJSONSchemaMap {
package/src/line-text.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  * 用于实现效率更高的编辑操作
3
3
  */
4
4
 
5
- import { IRange, IPosition, IEditOperation } from './types/editor';
5
+ import { IEditOperation, IPosition, IRange } from './types/editor';
6
6
 
7
7
  export class BasicTextLines {
8
8
  constructor(protected readonly _lines: string[], protected _eol: '\n' | '\r\n') {}
package/src/localize.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { strings, CaseInsensitiveMap } from '@opensumi/ide-utils';
1
+ import { CaseInsensitiveMap, strings } from '@opensumi/ide-utils';
2
2
 
3
3
  const { format, mnemonicButtonLabel } = strings;
4
4
 
package/src/module.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  * 项目中会使用到的模块接口定义
3
3
  */
4
4
 
5
- import { Autowired, INJECTOR_TOKEN, Injector, Provider, ConstructorOf, Token, Domain } from '@opensumi/di';
5
+ import { Autowired, ConstructorOf, Domain, INJECTOR_TOKEN, Injector, Provider, Token } from '@opensumi/di';
6
6
 
7
7
  import { RPCProtocol } from './types/rpc';
8
8
 
@@ -22,8 +22,15 @@ export interface BackService {
22
22
  export class BasicModule {
23
23
  @Autowired(INJECTOR_TOKEN)
24
24
  protected injector: Injector;
25
+
25
26
  providers?: Provider[];
27
+ /**
28
+ * providers only avaiable in electron
29
+ */
26
30
  electronProviders?: Provider[];
31
+ /**
32
+ * providers only avaiable in web
33
+ */
27
34
  webProviders?: Provider[];
28
35
  backServices?: BackService[];
29
36
  frontServices?: FrontService[];
package/src/network.ts CHANGED
@@ -44,4 +44,6 @@ export namespace Schemes {
44
44
  export const userData = 'vscode-userdata';
45
45
 
46
46
  export const userStorage = 'user_storage';
47
+
48
+ export const design = 'design';
47
49
  }
@@ -15,16 +15,16 @@
15
15
  ********************************************************************************/
16
16
  // Some code copied and modified from https://github.com/eclipse-theia/theia/tree/v1.14.0/packages/task/src/browser/task-problem-matcher-registry.ts
17
17
 
18
- import { Injectable, Autowired } from '@opensumi/di';
19
- import { URI, Emitter, DisposableCollection, Disposable, IDisposable } from '@opensumi/ide-utils';
18
+ import { Autowired, Injectable } from '@opensumi/di';
19
+ import { Disposable, DisposableCollection, Emitter, IDisposable, URI } from '@opensumi/ide-utils';
20
20
 
21
21
  import {
22
- IProblemPatternRegistry,
23
22
  ApplyToKind,
24
23
  FileLocationKind,
25
- Severity,
26
- ProblemPatternContribution,
24
+ IProblemPatternRegistry,
27
25
  ProblemPattern,
26
+ ProblemPatternContribution,
27
+ Severity,
28
28
  WatchingPattern,
29
29
  } from './problem-pattern';
30
30
 
@@ -15,10 +15,11 @@
15
15
  ********************************************************************************/
16
16
  // Some code copied and modified from https://github.com/eclipse-theia/theia/tree/v1.14.0/packages/core/src/common/severity.ts
17
17
 
18
+ // eslint-disable-next-line import/no-unresolved
18
19
  import { Diagnostic } from 'vscode';
19
20
 
20
21
  import { Injectable } from '@opensumi/di';
21
- import { isArray, isString, IDisposable, Disposable, DisposableCollection, URI } from '@opensumi/ide-utils';
22
+ import { Disposable, DisposableCollection, IDisposable, URI, isArray, isString } from '@opensumi/ide-utils';
22
23
 
23
24
  import { ProblemMatcher } from './problem-matcher';
24
25
 
package/src/reference.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Emitter, Event, Disposable, MaybePromise } from '@opensumi/ide-utils';
1
+ import { Disposable, Emitter, Event, MaybePromise } from '@opensumi/ide-utils';
2
2
 
3
3
  export interface IRef<T> {
4
4
  instance: T;
package/src/reporter.ts CHANGED
@@ -1,15 +1,15 @@
1
- import { Injectable, Inject } from '@opensumi/di';
1
+ import { Inject, Injectable } from '@opensumi/di';
2
2
  import { IDisposable } from '@opensumi/ide-utils';
3
3
 
4
4
  import { getDebugLogger } from './log';
5
5
  import {
6
- IReporterService,
7
- ReporterMetadata,
8
6
  IReporter,
7
+ IReporterService,
8
+ IReporterTimer,
9
9
  PerformanceData,
10
10
  PointData,
11
- IReporterTimer,
12
11
  REPORT_NAME,
12
+ ReporterMetadata,
13
13
  } from './types/reporter';
14
14
 
15
15
  class ReporterTimer implements IReporterTimer {
@@ -0,0 +1,4 @@
1
+ export enum AINativeSettingSectionsId {
2
+ INLINE_CHAT_AUTO_VISIBLE = 'inlineChat.auto.visible',
3
+ }
4
+ export const AI_NATIVE_SETTING_GROUP_ID = 'AI-Native';
@@ -2,4 +2,5 @@ export const enum GeneralSettingsId {
2
2
  Icon = 'general.icon',
3
3
  Theme = 'general.theme',
4
4
  Language = 'general.language',
5
+ ProductIconTheme = 'general.productIconTheme',
5
6
  }
@@ -2,3 +2,4 @@ export * from './general';
2
2
  export * from './search';
3
3
  export * from './terminal';
4
4
  export * from './menubar';
5
+ export * from './ai-native';
package/src/storage.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { Injectable, Autowired } from '@opensumi/di';
2
- import { IDisposable, MaybePromise, Event, URI } from '@opensumi/ide-utils';
1
+ import { Autowired, Injectable } from '@opensumi/di';
2
+ import { Event, IDisposable, MaybePromise, URI } from '@opensumi/ide-utils';
3
3
 
4
4
  import { ContributionProvider } from './contribution-provider';
5
5
 
@@ -1,7 +1,7 @@
1
1
  import { Injectable } from '@opensumi/di';
2
- import { objects, IDisposable, Disposable } from '@opensumi/ide-utils';
2
+ import { Disposable, IDisposable, objects } from '@opensumi/ide-utils';
3
3
 
4
- import { IJSONSchemaMap, IJSONSchema } from './json-schema';
4
+ import { IJSONSchema, IJSONSchemaMap } from './json-schema';
5
5
  import { formatLocalize } from './localize';
6
6
  import { IStringDictionary } from './types/string';
7
7
 
package/src/theme.ts CHANGED
@@ -1,7 +1,99 @@
1
+ import { isObject, isString, isUndefined } from '@opensumi/ide-utils';
2
+
3
+ import { Codicon } from './codicons';
4
+
1
5
  export interface IThemeColor {
2
6
  id: string;
3
7
  }
4
8
 
9
+ export interface ThemeIcon {
10
+ readonly id: string;
11
+ readonly color?: IThemeColor;
12
+ // for sumiicon proxy
13
+ readonly alias?: string[];
14
+ }
15
+
16
+ export namespace IThemeColor {
17
+ export function isThemeColor(obj: any): obj is IThemeColor {
18
+ return obj && typeof obj === 'object' && typeof obj.id === 'string';
19
+ }
20
+ }
21
+
5
22
  export function isThemeColor(obj: any): obj is IThemeColor {
6
23
  return obj && typeof obj === 'object' && typeof (obj as IThemeColor).id === 'string';
7
24
  }
25
+
26
+ export namespace ThemeIcon {
27
+ export const iconNameSegment = '[A-Za-z0-9]+';
28
+ export const iconNameExpression = '[A-Za-z0-9-]+';
29
+ export const iconModifierExpression = '~[A-Za-z]+';
30
+ export const iconNameCharacter = '[A-Za-z0-9~-]';
31
+
32
+ const ThemeIconIdRegex = new RegExp(`^(${iconNameExpression})(${iconModifierExpression})?$`);
33
+
34
+ export function asClassNameArray(icon: ThemeIcon): string[] {
35
+ const match = ThemeIconIdRegex.exec(icon.id);
36
+ if (!match) {
37
+ return asClassNameArray(Codicon.error);
38
+ }
39
+ const [, id, modifier] = match;
40
+ const classNames = ['codicon', 'codicon-' + id];
41
+ if (modifier) {
42
+ classNames.push('codicon-modifier-' + modifier.substring(1));
43
+ }
44
+ return classNames;
45
+ }
46
+
47
+ export function asClassName(icon: ThemeIcon): string {
48
+ return asClassNameArray(icon).join(' ');
49
+ }
50
+
51
+ export function asCSSSelector(icon: ThemeIcon): string {
52
+ return '.' + asClassNameArray(icon).join('.');
53
+ }
54
+
55
+ export function isThemeIcon(obj: any): obj is ThemeIcon {
56
+ return isObject(obj) && isString(obj.id) && (isUndefined(obj.color) || IThemeColor.isThemeColor(obj.color));
57
+ }
58
+
59
+ const _regexFromString = new RegExp(
60
+ `^\\$\\((${ThemeIcon.iconNameExpression}(?:${ThemeIcon.iconModifierExpression})?)\\)$`,
61
+ );
62
+
63
+ export function fromString(str: string): ThemeIcon | undefined {
64
+ const match = _regexFromString.exec(str);
65
+ if (!match) {
66
+ return undefined;
67
+ }
68
+ const [, name] = match;
69
+ return { id: name };
70
+ }
71
+
72
+ export function fromId(id: string): ThemeIcon {
73
+ return { id };
74
+ }
75
+
76
+ export function modify(icon: ThemeIcon, modifier: 'disabled' | 'spin' | undefined): ThemeIcon {
77
+ let id = icon.id;
78
+ const tildeIndex = id.lastIndexOf('~');
79
+ if (tildeIndex !== -1) {
80
+ id = id.substring(0, tildeIndex);
81
+ }
82
+ if (modifier) {
83
+ id = `${id}~${modifier}`;
84
+ }
85
+ return { id };
86
+ }
87
+
88
+ export function getModifier(icon: ThemeIcon): string | undefined {
89
+ const tildeIndex = icon.id.lastIndexOf('~');
90
+ if (tildeIndex !== -1) {
91
+ return icon.id.substring(tildeIndex + 1);
92
+ }
93
+ return undefined;
94
+ }
95
+
96
+ export function isEqual(ti1: ThemeIcon, ti2: ThemeIcon): boolean {
97
+ return ti1.id === ti2.id && ti1.color?.id === ti2.color?.id;
98
+ }
99
+ }
@@ -0,0 +1,205 @@
1
+ import { CancellationToken } from '../../utils';
2
+
3
+ export interface IAINativeCapabilities {
4
+ /**
5
+ * Use opensumi design UI style
6
+ */
7
+ supportsOpenSumiDesign?: boolean;
8
+ /**
9
+ * Problem panel uses ai capabilities
10
+ */
11
+ supportsMarkers?: boolean;
12
+ /**
13
+ * Use ai chat capabilities
14
+ */
15
+ supportsChatAssistant?: boolean;
16
+ /**
17
+ * Use inline chat capabilities
18
+ */
19
+ supportsInlineChat?: boolean;
20
+ /**
21
+ * Use code intelligent completion capabilities
22
+ */
23
+ supportsInlineCompletion?: boolean;
24
+ /**
25
+ * Use ai to intelligently resolve conflicts
26
+ */
27
+ supportsConflictResolve?: boolean;
28
+ }
29
+
30
+ export interface IAINativeConfig {
31
+ capabilities?: IAINativeCapabilities;
32
+ }
33
+
34
+ export interface IAICompletionResultModel {
35
+ sessionId: string;
36
+ codeModelList: Array<{ content: string }>;
37
+ isCancel?: boolean;
38
+ }
39
+
40
+ export const AIBackSerivceToken = Symbol('AIBackSerivceToken');
41
+ export const AIBackSerivcePath = 'AIBackSerivcePath';
42
+
43
+ export interface IAIBackServiceResponse<T = string> {
44
+ errorCode?: number;
45
+ errorMsg?: string;
46
+ isCancel?: boolean;
47
+ data?: T;
48
+ }
49
+
50
+ export interface IAIBackServiceOption {
51
+ type?: string;
52
+ model?: string;
53
+ enableGptCache?: boolean;
54
+ sessionId?: string;
55
+ }
56
+
57
+ export interface IAICompletionOption {
58
+ prompt: string;
59
+ suffix?: string;
60
+ language?: string;
61
+ fileUrl?: string;
62
+ sessionId?: string;
63
+ }
64
+
65
+ export interface IAIReportCompletionOption {
66
+ relationId: string;
67
+ sessionId: string;
68
+ accept: boolean;
69
+ repo?: string;
70
+ completionUseTime?: number;
71
+ renderingTime?: number;
72
+ }
73
+
74
+ export interface IAIBackService<
75
+ BaseResponse extends IAIBackServiceResponse = IAIBackServiceResponse,
76
+ StreamResponse extends NodeJS.ReadableStream = NodeJS.ReadableStream,
77
+ CompletionResponse = IAICompletionResultModel,
78
+ > {
79
+ request<O extends IAIBackServiceOption>(
80
+ input: string,
81
+ options: O,
82
+ cancelToken?: CancellationToken,
83
+ ): Promise<BaseResponse>;
84
+ requestStream<O extends IAIBackServiceOption>(
85
+ input: string,
86
+ options: O,
87
+ cancelToken?: CancellationToken,
88
+ ): Promise<StreamResponse>;
89
+ requestCompletion<I extends IAICompletionOption>(
90
+ input: I,
91
+ cancelToken?: CancellationToken,
92
+ ): Promise<CompletionResponse>;
93
+ reportCompletion<I extends IAIReportCompletionOption>(input: I): Promise<void>;
94
+ destroyStreamRequest?: (sessionId: string) => Promise<void>;
95
+ }
96
+
97
+ export const AI_REPORTER_NAME = 'AI';
98
+
99
+ export enum AISerivceType {
100
+ SearchDoc = 'searchDoc',
101
+ SearchCode = 'searchCode',
102
+ Sumi = 'sumi',
103
+ GPT = 'chat',
104
+ Explain = 'explain',
105
+ Run = 'run',
106
+ Test = 'test',
107
+ Optimize = 'optimize',
108
+ Generate = 'generate',
109
+ Completion = 'completion',
110
+ Agent = 'agent',
111
+ MergeConflict = 'mergeConflict',
112
+ }
113
+
114
+ export interface CommonLogInfo {
115
+ msgType: AISerivceType | string;
116
+ relationId: string;
117
+ replytime: number;
118
+ success: boolean;
119
+ message: string;
120
+ isStart: boolean;
121
+ isLike: boolean;
122
+ // 是否有效
123
+ isValid: boolean;
124
+ model: string;
125
+ copy: boolean;
126
+ insert: boolean;
127
+ }
128
+
129
+ export interface QuestionRT extends Partial<CommonLogInfo> {
130
+ isRetry: boolean;
131
+ isStop: boolean;
132
+ }
133
+
134
+ export interface CodeRT extends Partial<CommonLogInfo> {
135
+ isReceive: boolean;
136
+ isDrop: boolean;
137
+ }
138
+
139
+ export interface GenerateRT extends Partial<CommonLogInfo> {
140
+ fileCount: number;
141
+ requirment: string;
142
+ }
143
+
144
+ export interface CommandRT extends Partial<CommonLogInfo> {
145
+ useCommand: boolean;
146
+ useCommandSuccess: boolean;
147
+ }
148
+
149
+ export interface RunRT extends Partial<CommonLogInfo> {
150
+ runSuccess: boolean;
151
+ }
152
+
153
+ export interface CompletionRT extends Partial<CommonLogInfo> {
154
+ isReceive?: boolean;
155
+ // 是否取消
156
+ isStop?: boolean;
157
+ // 补全条数
158
+ completionNum?: number;
159
+ // 渲染时长
160
+ renderingTime?: number;
161
+ }
162
+
163
+ export interface MergeConflictRT extends Partial<CommonLogInfo> {
164
+ // 解决冲突模式 (3-way 或 传统模式)
165
+ editorMode: '3way' | 'traditional';
166
+ // 冲突点数量(仅包含 AI 冲突点)
167
+ conflictPointNum: number;
168
+ // 使用了 ai 处理的冲突点数量
169
+ useAiConflictPointNum: number;
170
+ // 被用户采纳了的冲突点数量
171
+ receiveNum: number;
172
+ // 点击了 ai 解决冲突的数量
173
+ clickNum: number;
174
+ // 点击了一键解决的次数
175
+ clickAllNum: number;
176
+ // ai 成功输出了的数量
177
+ aiOutputNum: number;
178
+ // 取消次数
179
+ cancelNum: number;
180
+ }
181
+
182
+ export type ReportInfo =
183
+ | Partial<CommonLogInfo>
184
+ | ({ type: AISerivceType.GPT } & QuestionRT)
185
+ | ({ type: AISerivceType.Explain } & QuestionRT)
186
+ | ({ type: AISerivceType.SearchCode } & QuestionRT)
187
+ | ({ type: AISerivceType.SearchDoc } & QuestionRT)
188
+ | ({ type: AISerivceType.Test } & QuestionRT)
189
+ | ({ type: AISerivceType.Optimize } & CodeRT)
190
+ | ({ type: AISerivceType.Generate } & GenerateRT)
191
+ | ({ type: AISerivceType.Sumi } & CommandRT)
192
+ | ({ type: AISerivceType.Run } & RunRT)
193
+ | ({ type: AISerivceType.Completion } & CompletionRT)
194
+ | ({ type: AISerivceType.MergeConflict } & MergeConflictRT);
195
+
196
+ export const IAIReporter = Symbol('IAIReporter');
197
+
198
+ export interface IAIReporter {
199
+ getCommonReportInfo(): Record<string, unknown>;
200
+ getCacheReportInfo<T = ReportInfo>(relationId: string): T | undefined;
201
+ record(data: ReportInfo, relationId?: string): ReportInfo;
202
+ // 返回关联 ID
203
+ start(msg: string, data: ReportInfo): string;
204
+ end(relationId: string, data: ReportInfo): void;
205
+ }