@modesto_ma/dsh-guanxiang 0.1.0 → 0.2.0-beta.2
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 +67 -2
- package/lib/client.js +382 -97
- package/lib/client.js.map +1 -1
- package/lib/index.js +472 -62
- package/lib/index.js.map +1 -1
- package/package.json +2 -1
- package/src/analyze/contract.ts +124 -0
- package/src/analyze/server.ts +195 -0
- package/src/analyze/topics.ts +109 -0
- package/src/client/page.tsx +172 -41
- package/src/client/styles.ts +4 -0
- package/src/config.ts +25 -3
- package/src/index.ts +10 -4
- package/src/repos/credentials.ts +2 -3
- package/src/service.ts +47 -12
- package/src/settings/contract.ts +41 -2
package/src/settings/contract.ts
CHANGED
|
@@ -11,9 +11,15 @@ export const STATE_ROUTE = '/guanxiang/state'
|
|
|
11
11
|
export const SETTINGS_ROUTE = '/guanxiang/settings'
|
|
12
12
|
/** POST:立即重新拉取全部仓库,或 body `{ url }` 指定的一个仓库。 */
|
|
13
13
|
export const SYNC_ROUTE = '/guanxiang/sync'
|
|
14
|
-
/** PUT:body `{ tokenEnv, value }` 把令牌存入 DSH 凭据库;DELETE:body `{ tokenEnv }`
|
|
14
|
+
/** PUT:body `{ tokenEnv, value }` 把令牌存入 DSH 凭据库;DELETE:body `{ tokenEnv }` 删除已存的值。只接受已保存的访问令牌配置引用的名称和分析接口令牌的名称。 */
|
|
15
15
|
export const TOKEN_ROUTE = '/guanxiang/token'
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
* POST:日志平台分析接口(Bearer 令牌鉴权,不走 DSH 登录)。它在 DSH 的
|
|
19
|
+
* `/api` 命名空间之外,网关可以把它和需要登录的 DSH 接口分开暴露。
|
|
20
|
+
*/
|
|
21
|
+
export const ANALYZE_ROUTE = '/open-api/logalyze'
|
|
22
|
+
|
|
17
23
|
/** One configured application repository. */
|
|
18
24
|
export interface RepoSpec {
|
|
19
25
|
/** Git remote address, cloned with the host machine's existing git credentials or a matching {@link GitCredentialSpec}. */
|
|
@@ -22,10 +28,15 @@ export interface RepoSpec {
|
|
|
22
28
|
branch?: string
|
|
23
29
|
}
|
|
24
30
|
|
|
31
|
+
/** Credential reference grammar of `@deepseek-ai/dsh-credentials` (a POSIX shell identifier), which {@link GitCredentialSpec.tokenEnv} follows. */
|
|
32
|
+
export const TOKEN_ENV_PATTERN = /^[A-Za-z_][A-Za-z0-9_]*$/
|
|
33
|
+
|
|
25
34
|
/** HTTPS access token used for the repositories under one address prefix. */
|
|
26
35
|
export interface GitCredentialSpec {
|
|
27
36
|
/** `https://host[:port][/path]` (or `http://`) prefix; repository addresses under it use this token. */
|
|
28
37
|
url: string
|
|
38
|
+
/** Display name the panel shows for this token; omitted shows the address. */
|
|
39
|
+
alias?: string
|
|
29
40
|
/** HTTP username sent with the token; GitLab personal access tokens accept `oauth2`. */
|
|
30
41
|
username: string
|
|
31
42
|
/** Credential reference (environment-variable name) whose value in DSH's credential store is the token. */
|
|
@@ -52,6 +63,12 @@ export interface SkillUpdateSettings {
|
|
|
52
63
|
maxFileBytes: number
|
|
53
64
|
}
|
|
54
65
|
|
|
66
|
+
/** The log-platform analyze API ({@link ANALYZE_ROUTE}). */
|
|
67
|
+
export interface AnalyzeSettings {
|
|
68
|
+
/** Whether the API accepts requests; switched off it answers 404. */
|
|
69
|
+
enabled: boolean
|
|
70
|
+
}
|
|
71
|
+
|
|
55
72
|
/** The settings the Web panel can override; every field is required on the wire. */
|
|
56
73
|
export interface EditableSettings {
|
|
57
74
|
/** Absolute directory holding the cloned repositories (`~` expands to the home directory). */
|
|
@@ -70,10 +87,12 @@ export interface EditableSettings {
|
|
|
70
87
|
download: DownloadSettings
|
|
71
88
|
/** SKILL improvement proposals. */
|
|
72
89
|
skillUpdates: SkillUpdateSettings
|
|
90
|
+
/** Log-platform analyze API. */
|
|
91
|
+
analyze: AnalyzeSettings
|
|
73
92
|
}
|
|
74
93
|
|
|
75
94
|
/** Keys of {@link EditableSettings}, in panel order. */
|
|
76
|
-
export const EDITABLE_KEYS = ['reposDir', 'repos', 'gitCredentials', 'fetchIntervalMs', 'maxAppsPerRequest', 'dispatchTimeoutMs', 'download', 'skillUpdates'] as const satisfies readonly (keyof EditableSettings)[]
|
|
95
|
+
export const EDITABLE_KEYS = ['reposDir', 'repos', 'gitCredentials', 'fetchIntervalMs', 'maxAppsPerRequest', 'dispatchTimeoutMs', 'download', 'skillUpdates', 'analyze'] as const satisfies readonly (keyof EditableSettings)[]
|
|
77
96
|
|
|
78
97
|
/** One editable key. */
|
|
79
98
|
export type EditableKey = (typeof EDITABLE_KEYS)[number]
|
|
@@ -141,6 +160,25 @@ export interface CredentialsWire {
|
|
|
141
160
|
tokens: TokenStatusWire[]
|
|
142
161
|
}
|
|
143
162
|
|
|
163
|
+
/**
|
|
164
|
+
* Whether dsh-channels provides the `feishuTopics` service the analyze API
|
|
165
|
+
* posts through: `missing` while it is not loaded (or older than 0.8, which
|
|
166
|
+
* serves the API itself), `incompatible` when its contract version is not
|
|
167
|
+
* the one this plugin speaks.
|
|
168
|
+
*/
|
|
169
|
+
export type TopicsAvailability = 'ready' | 'missing' | 'incompatible'
|
|
170
|
+
|
|
171
|
+
/** Analyze API view of the panel. */
|
|
172
|
+
export interface AnalyzeWire {
|
|
173
|
+
/** Route the log platform posts to. */
|
|
174
|
+
route: string
|
|
175
|
+
/** Credential reference (`analyzeTokenRef`) holding the bearer token. */
|
|
176
|
+
tokenEnv: string
|
|
177
|
+
/** Token status; absent while the DSH composition has no credential store. */
|
|
178
|
+
token?: TokenStatusWire
|
|
179
|
+
topics: TopicsAvailability
|
|
180
|
+
}
|
|
181
|
+
|
|
144
182
|
/** `GET /guanxiang/state` response. */
|
|
145
183
|
export interface StateWire {
|
|
146
184
|
/** Effective settings: cordis.yml values with panel overrides applied. */
|
|
@@ -153,6 +191,7 @@ export interface StateWire {
|
|
|
153
191
|
overlayError?: string
|
|
154
192
|
repos: RepoStatusWire[]
|
|
155
193
|
credentials: CredentialsWire
|
|
194
|
+
analyze: AnalyzeWire
|
|
156
195
|
}
|
|
157
196
|
|
|
158
197
|
/** Successful mutation response. */
|