@eworkbase/sdk 0.3.6 → 0.4.1
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/dist/ExecutionLog.dto-CI-HpxZa.d.ts +116 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +85 -1
- package/dist/markdown-link-C-qw7xuN.js +50 -0
- package/dist/markdown.d.ts +18 -0
- package/dist/markdown.js +112 -0
- package/dist/style.css +110 -12
- package/dist/{types-Cl1kerLO.d.ts → types-Bv7aJizu.d.ts} +10 -0
- package/dist/types-C8byxPji.d.ts +154 -0
- package/dist/ui/error-panel.d.ts +15 -0
- package/dist/ui/error-panel.js +44 -0
- package/dist/ui/execution-log.d.ts +42 -0
- package/dist/ui/execution-log.js +443 -0
- package/dist/ui/index.css +16 -6
- package/dist/ui/index.d.ts +2 -151
- package/dist/ui/index.js +1 -0
- package/dist/ui/markdown-editor.d.ts +4 -1
- package/dist/ui/markdown-editor.js +56 -25
- package/dist/ui/markdown-links.d.ts +12 -0
- package/dist/ui/markdown-links.js +246 -0
- package/dist/ui/model.d.ts +2 -0
- package/dist/ui/model.js +5 -1
- package/dist/ui/theme.css +106 -0
- package/package.json +22 -4
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
//#region src/ExecutionLog.dto.d.ts
|
|
3
|
+
declare enum ExecutionLogEntryKind {
|
|
4
|
+
Message = "message",
|
|
5
|
+
Activity = "activity",
|
|
6
|
+
Question = "question",
|
|
7
|
+
Answer = "answer"
|
|
8
|
+
}
|
|
9
|
+
declare const executionLogEntrySchema: z.ZodObject<{
|
|
10
|
+
id: z.ZodString;
|
|
11
|
+
kind: z.ZodEnum<typeof ExecutionLogEntryKind>;
|
|
12
|
+
time: z.ZodISODateTime;
|
|
13
|
+
title: z.ZodString;
|
|
14
|
+
content: z.ZodString;
|
|
15
|
+
details: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
16
|
+
status: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
17
|
+
}, z.core.$strict>;
|
|
18
|
+
declare const logCallSchema: z.ZodObject<{
|
|
19
|
+
id: z.ZodString;
|
|
20
|
+
title: z.ZodString;
|
|
21
|
+
status: z.ZodString;
|
|
22
|
+
createdAt: z.ZodString;
|
|
23
|
+
operationKind: z.ZodString;
|
|
24
|
+
hasWarnings: z.ZodBoolean;
|
|
25
|
+
context: z.ZodObject<{
|
|
26
|
+
finishedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
27
|
+
}, z.core.$strip>;
|
|
28
|
+
hasChildErrors: z.ZodOptional<z.ZodBoolean>;
|
|
29
|
+
execution: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
30
|
+
pluginId: z.ZodString;
|
|
31
|
+
commandId: z.ZodString;
|
|
32
|
+
}, z.core.$strip>>>;
|
|
33
|
+
}, z.core.$strip>;
|
|
34
|
+
/** Existing operation evidence is returned alongside entries; it is never copied into another store. */
|
|
35
|
+
declare const executionLogRecordSchema: z.ZodObject<{
|
|
36
|
+
id: z.ZodString;
|
|
37
|
+
title: z.ZodString;
|
|
38
|
+
entries: z.ZodArray<z.ZodObject<{
|
|
39
|
+
id: z.ZodString;
|
|
40
|
+
kind: z.ZodEnum<typeof ExecutionLogEntryKind>;
|
|
41
|
+
time: z.ZodISODateTime;
|
|
42
|
+
title: z.ZodString;
|
|
43
|
+
content: z.ZodString;
|
|
44
|
+
details: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
45
|
+
status: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
46
|
+
}, z.core.$strict>>;
|
|
47
|
+
steps: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
48
|
+
id: z.ZodString;
|
|
49
|
+
legacyId: z.ZodOptional<z.ZodString>;
|
|
50
|
+
label: z.ZodString;
|
|
51
|
+
detail: z.ZodString;
|
|
52
|
+
status: z.ZodString;
|
|
53
|
+
executionState: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
54
|
+
phase: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
55
|
+
timing: z.ZodOptional<z.ZodObject<{
|
|
56
|
+
queuedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
57
|
+
startedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
58
|
+
finishedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
59
|
+
}, z.core.$strip>>;
|
|
60
|
+
target: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
61
|
+
kind: z.ZodString;
|
|
62
|
+
id: z.ZodString;
|
|
63
|
+
label: z.ZodString;
|
|
64
|
+
}, z.core.$strip>>>;
|
|
65
|
+
provider: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
66
|
+
command: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
67
|
+
stdout: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
68
|
+
stderr: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
69
|
+
manualActionMessage: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
70
|
+
}, z.core.$strip>>>;
|
|
71
|
+
children: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
72
|
+
id: z.ZodString;
|
|
73
|
+
title: z.ZodString;
|
|
74
|
+
status: z.ZodString;
|
|
75
|
+
createdAt: z.ZodString;
|
|
76
|
+
operationKind: z.ZodString;
|
|
77
|
+
hasWarnings: z.ZodBoolean;
|
|
78
|
+
context: z.ZodObject<{
|
|
79
|
+
finishedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
80
|
+
}, z.core.$strip>;
|
|
81
|
+
hasChildErrors: z.ZodOptional<z.ZodBoolean>;
|
|
82
|
+
execution: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
83
|
+
pluginId: z.ZodString;
|
|
84
|
+
commandId: z.ZodString;
|
|
85
|
+
}, z.core.$strip>>>;
|
|
86
|
+
}, z.core.$strip>>>;
|
|
87
|
+
messages: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
88
|
+
id: z.ZodString;
|
|
89
|
+
createdAt: z.ZodString;
|
|
90
|
+
level: z.ZodEnum<{
|
|
91
|
+
error: "error";
|
|
92
|
+
debug: "debug";
|
|
93
|
+
info: "info";
|
|
94
|
+
warn: "warn";
|
|
95
|
+
}>;
|
|
96
|
+
message: z.ZodString;
|
|
97
|
+
}, z.core.$strip>>>;
|
|
98
|
+
warnings: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
99
|
+
createdAt: z.ZodOptional<z.ZodString>;
|
|
100
|
+
execution: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
101
|
+
pluginId: z.ZodString;
|
|
102
|
+
commandId: z.ZodString;
|
|
103
|
+
}, z.core.$strip>>>;
|
|
104
|
+
context: z.ZodOptional<z.ZodObject<{
|
|
105
|
+
finishedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
106
|
+
}, z.core.$strip>>;
|
|
107
|
+
}, z.core.$strip>;
|
|
108
|
+
type ExecutionLogEntry = Omit<z.infer<typeof executionLogEntrySchema>, "kind"> & {
|
|
109
|
+
readonly kind: `${ExecutionLogEntryKind}`;
|
|
110
|
+
};
|
|
111
|
+
type ExecutionLogCallRecord = z.infer<typeof logCallSchema>;
|
|
112
|
+
type ExecutionLogRecord = Readonly<Omit<z.infer<typeof executionLogRecordSchema>, "entries">> & {
|
|
113
|
+
readonly entries: readonly ExecutionLogEntry[];
|
|
114
|
+
};
|
|
115
|
+
//#endregion
|
|
116
|
+
export { executionLogEntrySchema as a, ExecutionLogRecord as i, ExecutionLogEntry as n, executionLogRecordSchema as o, ExecutionLogEntryKind as r, ExecutionLogCallRecord as t };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as executionLogEntrySchema, i as ExecutionLogRecord, n as ExecutionLogEntry, o as executionLogRecordSchema, r as ExecutionLogEntryKind } from "./ExecutionLog.dto-CI-HpxZa.js";
|
|
2
|
+
import { $ as PluginAgentContextCatalogEntry, A as PluginLifecycleOutcome, At as PluginToolsService, B as PluginRepositoryStatus, C as PluginExecutionStatus, Ct as PluginTaskDescriptor, D as PluginInvocationContext, Dt as PluginToastLevel, E as PluginHookResult, Et as PluginToastApi, F as PluginProcessOutputMode, Ft as roleToolsAppliedSchema, G as PluginStatusDefinition, H as PluginSharedChangeKind, I as PluginProcessResult, It as roleToolsProposalSchema, J as PluginViewDefinition, K as PluginToolContribution, L as PluginProcessRunOptions, M as PluginLifecycleStatus, Mt as RoleToolsApplied, N as PluginLogger, Nt as RoleToolsProposal, O as PluginLifecycleDispatchResult, Ot as PluginToastOptions, P as PluginProcessApi, Pt as roleToolEnvironmentSchema, Q as WorkbasePluginDefinition, R as PluginProject, S as PluginExecutionSnapshot, St as PluginSystemContextService, T as PluginHookId, Tt as PluginTaskService, U as PluginSharedChanges, V as PluginSetupHooks, W as PluginStatusContribution, X as PluginViewRequest, Y as PluginViewLayout, Z as PluginWorkspace, _ as PluginContext, _t as PluginPromptQuestion, a as PluginCapabilityReference, at as PluginColoredMessage, b as PluginDisposable, bt as PluginStatusCatalogEntry, c as PluginCommandContext, ct as PluginExecutionService, d as PluginCommandDetails, dt as PluginLogEntry, et as PluginAgentPolicy, f as PluginCommandEffect, ft as PluginLogQueryRequest, g as PluginCommandTransaction, gt as PluginPromptChoice, h as PluginCommandOption, ht as PluginPromptApi, i as PluginCapabilityKind, it as PluginCapabilityService, j as PluginLifecyclePolicy, jt as RoleToolEnvironment, k as PluginLifecycleHook, kt as PluginViewCatalogEntry, l as PluginCommandContribution, lt as PluginHostServices, m as PluginCommandExecutionResult, mt as PluginLogService, n as PluginAgentContextDefinition, nt as PluginCapabilityCommandRequest, o as PluginCommandArgument, ot as PluginCommandCatalogEntry, p as PluginCommandExecutionMode, pt as PluginLogQueryResult, q as PluginViewContribution, r as PluginAgentScope, rt as PluginCapabilityResolveRequest, s as PluginCommandCategory, st as PluginConfigApi, t as PluginAgentContextContribution, tt as PluginCapabilityCatalog, u as PluginCommandDefinition, ut as PluginInteractiveLogger, v as PluginContextExposure, vt as PluginPromptType, w as PluginFileChange, wt as PluginTaskResult, x as PluginExecutionEvidence, xt as PluginStoreApi, y as PluginContributionSnapshot, yt as PluginPromptViewRequest, z as PluginRepository } from "./types-Bv7aJizu.js";
|
|
2
3
|
export * from "zod";
|
|
3
4
|
//#region src/definition.d.ts
|
|
4
5
|
export declare const PLUGIN_API_VERSION = 2;
|
|
@@ -6,4 +7,4 @@ type DefinedWorkbasePlugin = Readonly<WorkbasePluginDefinition>;
|
|
|
6
7
|
export declare function definePlugin(definition: WorkbasePluginDefinition): DefinedWorkbasePlugin;
|
|
7
8
|
export declare function isDefinedPlugin(value: unknown): value is DefinedWorkbasePlugin;
|
|
8
9
|
//#endregion
|
|
9
|
-
export { type DefinedWorkbasePlugin, type PluginAgentContextCatalogEntry, type PluginAgentContextContribution, type PluginAgentContextDefinition, type PluginAgentPolicy, PluginAgentScope, type PluginCapabilityCatalog, type PluginCapabilityCommandRequest, PluginCapabilityKind, type PluginCapabilityReference, type PluginCapabilityResolveRequest, type PluginCapabilityService, type PluginColoredMessage, type PluginCommandArgument, type PluginCommandCatalogEntry, PluginCommandCategory, type PluginCommandContext, type PluginCommandContribution, type PluginCommandDefinition, type PluginCommandDetails, PluginCommandEffect, PluginCommandExecutionMode, type PluginCommandExecutionResult, type PluginCommandOption, PluginCommandTransaction, type PluginConfigApi, type PluginContext, PluginContextExposure, type PluginContributionSnapshot, type PluginDisposable, type PluginExecutionEvidence, type PluginExecutionService, type PluginExecutionSnapshot, PluginExecutionStatus, type PluginFileChange, PluginHookId, type PluginHookResult, type PluginHostServices, type PluginInteractiveLogger, type PluginInvocationContext, type PluginLifecycleDispatchResult, type PluginLifecycleHook, type PluginLifecycleOutcome, PluginLifecyclePolicy, PluginLifecycleStatus, type PluginLogEntry, type PluginLogQueryRequest, type PluginLogQueryResult, type PluginLogService, type PluginLogger, type PluginProcessApi, PluginProcessOutputMode, type PluginProcessResult, type PluginProcessRunOptions, type PluginProject, type PluginPromptApi, type PluginPromptChoice, type PluginPromptQuestion, type PluginPromptType, type PluginPromptViewRequest, type PluginRepository, PluginRepositoryStatus, type PluginSetupHooks, PluginSharedChangeKind, type PluginSharedChanges, type PluginStatusCatalogEntry, type PluginStatusContribution, type PluginStatusDefinition, type PluginStoreApi, type PluginSystemContextService, type PluginTaskDescriptor, type PluginTaskResult, type PluginTaskService, type PluginToastApi, type PluginToastLevel, type PluginToastOptions, type PluginToolContribution, PluginToolsService, type PluginViewCatalogEntry, type PluginViewContribution, type PluginViewDefinition, PluginViewLayout, type PluginViewRequest, type PluginWorkspace, RoleToolEnvironment, RoleToolsApplied, RoleToolsProposal, type WorkbasePluginDefinition, roleToolEnvironmentSchema, roleToolsAppliedSchema, roleToolsProposalSchema };
|
|
10
|
+
export { type DefinedWorkbasePlugin, type ExecutionLogEntry, ExecutionLogEntryKind, type ExecutionLogRecord, type PluginAgentContextCatalogEntry, type PluginAgentContextContribution, type PluginAgentContextDefinition, type PluginAgentPolicy, PluginAgentScope, type PluginCapabilityCatalog, type PluginCapabilityCommandRequest, PluginCapabilityKind, type PluginCapabilityReference, type PluginCapabilityResolveRequest, type PluginCapabilityService, type PluginColoredMessage, type PluginCommandArgument, type PluginCommandCatalogEntry, PluginCommandCategory, type PluginCommandContext, type PluginCommandContribution, type PluginCommandDefinition, type PluginCommandDetails, PluginCommandEffect, PluginCommandExecutionMode, type PluginCommandExecutionResult, type PluginCommandOption, PluginCommandTransaction, type PluginConfigApi, type PluginContext, PluginContextExposure, type PluginContributionSnapshot, type PluginDisposable, type PluginExecutionEvidence, type PluginExecutionService, type PluginExecutionSnapshot, PluginExecutionStatus, type PluginFileChange, PluginHookId, type PluginHookResult, type PluginHostServices, type PluginInteractiveLogger, type PluginInvocationContext, type PluginLifecycleDispatchResult, type PluginLifecycleHook, type PluginLifecycleOutcome, PluginLifecyclePolicy, PluginLifecycleStatus, type PluginLogEntry, type PluginLogQueryRequest, type PluginLogQueryResult, type PluginLogService, type PluginLogger, type PluginProcessApi, PluginProcessOutputMode, type PluginProcessResult, type PluginProcessRunOptions, type PluginProject, type PluginPromptApi, type PluginPromptChoice, type PluginPromptQuestion, type PluginPromptType, type PluginPromptViewRequest, type PluginRepository, PluginRepositoryStatus, type PluginSetupHooks, PluginSharedChangeKind, type PluginSharedChanges, type PluginStatusCatalogEntry, type PluginStatusContribution, type PluginStatusDefinition, type PluginStoreApi, type PluginSystemContextService, type PluginTaskDescriptor, type PluginTaskResult, type PluginTaskService, type PluginToastApi, type PluginToastLevel, type PluginToastOptions, type PluginToolContribution, PluginToolsService, type PluginViewCatalogEntry, type PluginViewContribution, type PluginViewDefinition, PluginViewLayout, type PluginViewRequest, type PluginWorkspace, RoleToolEnvironment, RoleToolsApplied, RoleToolsProposal, type WorkbasePluginDefinition, executionLogEntrySchema, executionLogRecordSchema, roleToolEnvironmentSchema, roleToolsAppliedSchema, roleToolsProposalSchema };
|
package/dist/index.js
CHANGED
|
@@ -36,6 +36,7 @@ let PluginHookId = /* @__PURE__ */ function(PluginHookId) {
|
|
|
36
36
|
PluginHookId["WorkspaceActivate"] = "workspace.activate";
|
|
37
37
|
PluginHookId["WorkspaceAfterPrepare"] = "workspace.afterPrepare";
|
|
38
38
|
PluginHookId["WorkspaceDeactivate"] = "workspace.deactivate";
|
|
39
|
+
PluginHookId["WorkspaceFinalize"] = "workspace.finalize";
|
|
39
40
|
PluginHookId["WorkspaceProvision"] = "workspace.provision";
|
|
40
41
|
PluginHookId["Cleanup"] = "cleanup";
|
|
41
42
|
return PluginHookId;
|
|
@@ -205,4 +206,87 @@ const roleToolsAppliedSchema = z.object({
|
|
|
205
206
|
requiresPreparation: z.boolean()
|
|
206
207
|
});
|
|
207
208
|
//#endregion
|
|
208
|
-
|
|
209
|
+
//#region src/ExecutionLog.dto.ts
|
|
210
|
+
/** 通用执行时间线契约;内容由调用方提供,宿主校验作用域、脱敏并持久保存。 */
|
|
211
|
+
let ExecutionLogEntryKind = /* @__PURE__ */ function(ExecutionLogEntryKind) {
|
|
212
|
+
ExecutionLogEntryKind["Message"] = "message";
|
|
213
|
+
ExecutionLogEntryKind["Activity"] = "activity";
|
|
214
|
+
ExecutionLogEntryKind["Question"] = "question";
|
|
215
|
+
ExecutionLogEntryKind["Answer"] = "answer";
|
|
216
|
+
return ExecutionLogEntryKind;
|
|
217
|
+
}({});
|
|
218
|
+
const executionLogEntrySchema = z.object({
|
|
219
|
+
id: z.string().min(1).max(160),
|
|
220
|
+
kind: z.enum(ExecutionLogEntryKind),
|
|
221
|
+
time: z.iso.datetime(),
|
|
222
|
+
title: z.string().max(240),
|
|
223
|
+
content: z.string().max(48e3),
|
|
224
|
+
details: z.string().max(8e3).nullish(),
|
|
225
|
+
status: z.string().max(64).nullish()
|
|
226
|
+
}).strict();
|
|
227
|
+
const executionTimingSchema = z.object({
|
|
228
|
+
queuedAt: z.string().nullish(),
|
|
229
|
+
startedAt: z.string().nullish(),
|
|
230
|
+
finishedAt: z.string().nullish()
|
|
231
|
+
});
|
|
232
|
+
const executionIdentitySchema = z.object({
|
|
233
|
+
pluginId: z.string(),
|
|
234
|
+
commandId: z.string()
|
|
235
|
+
});
|
|
236
|
+
const executionContextSchema = z.object({ finishedAt: z.string().nullish() });
|
|
237
|
+
const logStepSchema = z.object({
|
|
238
|
+
id: z.string(),
|
|
239
|
+
legacyId: z.string().optional(),
|
|
240
|
+
label: z.string(),
|
|
241
|
+
detail: z.string(),
|
|
242
|
+
status: z.string(),
|
|
243
|
+
executionState: z.string().nullish(),
|
|
244
|
+
phase: z.string().nullish(),
|
|
245
|
+
timing: executionTimingSchema.optional(),
|
|
246
|
+
target: z.object({
|
|
247
|
+
kind: z.string(),
|
|
248
|
+
id: z.string(),
|
|
249
|
+
label: z.string()
|
|
250
|
+
}).nullish(),
|
|
251
|
+
provider: z.string().nullish(),
|
|
252
|
+
command: z.string().nullish(),
|
|
253
|
+
stdout: z.string().nullish(),
|
|
254
|
+
stderr: z.string().nullish(),
|
|
255
|
+
manualActionMessage: z.string().nullish()
|
|
256
|
+
});
|
|
257
|
+
const logCallSchema = z.object({
|
|
258
|
+
id: z.string(),
|
|
259
|
+
title: z.string(),
|
|
260
|
+
status: z.string(),
|
|
261
|
+
createdAt: z.string(),
|
|
262
|
+
operationKind: z.string(),
|
|
263
|
+
hasWarnings: z.boolean(),
|
|
264
|
+
context: executionContextSchema,
|
|
265
|
+
hasChildErrors: z.boolean().optional(),
|
|
266
|
+
execution: executionIdentitySchema.nullish()
|
|
267
|
+
});
|
|
268
|
+
/** Existing operation evidence is returned alongside entries; it is never copied into another store. */
|
|
269
|
+
const executionLogRecordSchema = z.object({
|
|
270
|
+
id: z.string(),
|
|
271
|
+
title: z.string(),
|
|
272
|
+
entries: z.array(executionLogEntrySchema),
|
|
273
|
+
steps: z.array(logStepSchema).optional(),
|
|
274
|
+
children: z.array(logCallSchema).optional(),
|
|
275
|
+
messages: z.array(z.object({
|
|
276
|
+
id: z.string(),
|
|
277
|
+
createdAt: z.string(),
|
|
278
|
+
level: z.enum([
|
|
279
|
+
"debug",
|
|
280
|
+
"info",
|
|
281
|
+
"warn",
|
|
282
|
+
"error"
|
|
283
|
+
]),
|
|
284
|
+
message: z.string()
|
|
285
|
+
})).optional(),
|
|
286
|
+
warnings: z.array(z.string()).optional(),
|
|
287
|
+
createdAt: z.string().optional(),
|
|
288
|
+
execution: executionIdentitySchema.nullish(),
|
|
289
|
+
context: executionContextSchema.optional()
|
|
290
|
+
});
|
|
291
|
+
//#endregion
|
|
292
|
+
export { ExecutionLogEntryKind, PLUGIN_API_VERSION, PluginAgentScope, PluginCapabilityKind, PluginCommandCategory, PluginCommandEffect, PluginCommandExecutionMode, PluginCommandTransaction, PluginContextExposure, PluginExecutionStatus, PluginHookId, PluginLifecyclePolicy, PluginLifecycleStatus, PluginProcessOutputMode, PluginRepositoryStatus, PluginSharedChangeKind, PluginViewLayout, definePlugin, executionLogEntrySchema, executionLogRecordSchema, isDefinedPlugin, roleToolEnvironmentSchema, roleToolsAppliedSchema, roleToolsProposalSchema };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
//#region src/markdown-link.ts
|
|
2
|
+
const MAXIMUM_LINK_LENGTH = 4096;
|
|
3
|
+
const CONTROL_CHARACTERS = /[\u0000-\u001f\u007f]/;
|
|
4
|
+
const URL_SCHEME = /^[a-z][a-z\d+.-]*:/i;
|
|
5
|
+
const WEBSITE_PREFIX = /^(?:https?:)?\/\//i;
|
|
6
|
+
const MARKDOWN_EXTENSION = /\.(?:md|markdown)$/i;
|
|
7
|
+
function parseMarkdownLink(value) {
|
|
8
|
+
const href = value.trim();
|
|
9
|
+
if (!href || href.length > MAXIMUM_LINK_LENGTH || CONTROL_CHARACTERS.test(value)) throw new Error("链接为空、过长或包含无效字符。");
|
|
10
|
+
if (WEBSITE_PREFIX.test(href)) return websiteLink(href);
|
|
11
|
+
if (URL_SCHEME.test(href) || href.includes("\\")) throw new Error("不支持此链接协议或路径格式。");
|
|
12
|
+
const fragmentIndex = href.indexOf("#");
|
|
13
|
+
const fragment = fragmentIndex < 0 ? "" : decodeLink(href.slice(fragmentIndex + 1));
|
|
14
|
+
if (href.startsWith("#")) return {
|
|
15
|
+
kind: "anchor",
|
|
16
|
+
fragment
|
|
17
|
+
};
|
|
18
|
+
const pathname = decodeLink(href.split(/[?#]/, 1)[0]);
|
|
19
|
+
if (!MARKDOWN_EXTENSION.test(pathname) || pathname.includes("\\")) throw new Error("应用内预览仅支持 Markdown 文件。");
|
|
20
|
+
return {
|
|
21
|
+
kind: "document",
|
|
22
|
+
path: pathname,
|
|
23
|
+
fragment
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function websiteLink(href) {
|
|
27
|
+
let url;
|
|
28
|
+
try {
|
|
29
|
+
url = new URL(href.startsWith("//") ? "https:" + href : href);
|
|
30
|
+
} catch {
|
|
31
|
+
throw new Error("网页地址无效,请检查链接。");
|
|
32
|
+
}
|
|
33
|
+
if (!url.hostname || url.username || url.password || href.includes("\\")) throw new Error("网页地址不能包含登录凭据或无效主机。");
|
|
34
|
+
return {
|
|
35
|
+
kind: "website",
|
|
36
|
+
url: url.href
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function decodeLink(value) {
|
|
40
|
+
let decoded;
|
|
41
|
+
try {
|
|
42
|
+
decoded = decodeURIComponent(value);
|
|
43
|
+
} catch {
|
|
44
|
+
throw new Error("链接包含无效的字符编码。");
|
|
45
|
+
}
|
|
46
|
+
if (CONTROL_CHARACTERS.test(decoded)) throw new Error("链接包含无效字符。");
|
|
47
|
+
return decoded;
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
export { parseMarkdownLink as t };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { D as PluginInvocationContext } from "./types-Bv7aJizu.js";
|
|
2
|
+
//#region src/Markdown.dto.d.ts
|
|
3
|
+
interface MarkdownDocument {
|
|
4
|
+
readonly path: string;
|
|
5
|
+
readonly content: string;
|
|
6
|
+
readonly revision: string;
|
|
7
|
+
readonly fragment: string;
|
|
8
|
+
}
|
|
9
|
+
interface MarkdownReaderOptions {
|
|
10
|
+
readonly root: string;
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region src/markdown.d.ts
|
|
14
|
+
/** Register these handlers on the plugin view; the plugin chooses the allowed document tree. */
|
|
15
|
+
export declare function createMarkdownHandlers({ root }: MarkdownReaderOptions): {
|
|
16
|
+
openMarkdownLink: (input: unknown, invocation: PluginInvocationContext) => Promise<MarkdownDocument | null>;
|
|
17
|
+
};
|
|
18
|
+
//#endregion
|
package/dist/markdown.js
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { t as parseMarkdownLink } from "./markdown-link-C-qw7xuN.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { createHash } from "node:crypto";
|
|
4
|
+
import { closeSync, constants, fstatSync, lstatSync, openSync, readSync, realpathSync } from "node:fs";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
//#region src/markdown.ts
|
|
7
|
+
/** Reads bounded Markdown within a plugin-selected root and confirms external browser actions. */
|
|
8
|
+
const MAXIMUM_DOCUMENT_BYTES = 1048576;
|
|
9
|
+
const MAXIMUM_PATH_LENGTH = 4096;
|
|
10
|
+
const OPEN_TIMEOUT_MILLISECONDS = 1e4;
|
|
11
|
+
const requestSchema = z.object({
|
|
12
|
+
href: z.string().min(1).max(MAXIMUM_PATH_LENGTH),
|
|
13
|
+
sourcePath: z.string().min(1).max(MAXIMUM_PATH_LENGTH).optional()
|
|
14
|
+
}).strict();
|
|
15
|
+
/** Register these handlers on the plugin view; the plugin chooses the allowed document tree. */
|
|
16
|
+
function createMarkdownHandlers({ root }) {
|
|
17
|
+
return { openMarkdownLink: async (input, invocation) => {
|
|
18
|
+
const { href, sourcePath } = requestSchema.parse(input);
|
|
19
|
+
const link = parseMarkdownLink(href);
|
|
20
|
+
invocation.signal.throwIfAborted();
|
|
21
|
+
if (link.kind === "website") {
|
|
22
|
+
await openWebsite(link.url, invocation);
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
if (link.kind === "anchor") throw new Error("当前文档的标题链接无需重新读取文件。");
|
|
26
|
+
const relativePath = resolveDocumentPath({
|
|
27
|
+
root,
|
|
28
|
+
sourcePath,
|
|
29
|
+
destination: link.path
|
|
30
|
+
});
|
|
31
|
+
const content = readDocument(root, relativePath);
|
|
32
|
+
return {
|
|
33
|
+
path: relativePath.split(path.sep).join("/"),
|
|
34
|
+
content,
|
|
35
|
+
fragment: link.fragment,
|
|
36
|
+
revision: createHash("sha256").update(content).digest("hex")
|
|
37
|
+
};
|
|
38
|
+
} };
|
|
39
|
+
}
|
|
40
|
+
async function openWebsite(url, invocation) {
|
|
41
|
+
const { confirmed } = await invocation.services.prompt.ask({
|
|
42
|
+
name: "confirmed",
|
|
43
|
+
type: "confirm",
|
|
44
|
+
purpose: "approval",
|
|
45
|
+
default: false,
|
|
46
|
+
title: "打开浏览器",
|
|
47
|
+
submitLabel: "打开浏览器",
|
|
48
|
+
message: "是否在系统浏览器中打开以下网页?\n\n" + url
|
|
49
|
+
});
|
|
50
|
+
invocation.signal.throwIfAborted();
|
|
51
|
+
if (confirmed !== true) return;
|
|
52
|
+
const opener = (/* @__PURE__ */ new Map([
|
|
53
|
+
["darwin", {
|
|
54
|
+
program: "/usr/bin/open",
|
|
55
|
+
arguments: [url]
|
|
56
|
+
}],
|
|
57
|
+
["linux", {
|
|
58
|
+
program: "xdg-open",
|
|
59
|
+
arguments: [url]
|
|
60
|
+
}],
|
|
61
|
+
["win32", {
|
|
62
|
+
program: "rundll32.exe",
|
|
63
|
+
arguments: ["url.dll,FileProtocolHandler", url]
|
|
64
|
+
}]
|
|
65
|
+
])).get(process.platform);
|
|
66
|
+
if (!opener) throw new Error("当前系统不支持直接打开网页,请复制链接到浏览器。");
|
|
67
|
+
const result = await invocation.process.run({
|
|
68
|
+
...opener,
|
|
69
|
+
timeoutMilliseconds: OPEN_TIMEOUT_MILLISECONDS
|
|
70
|
+
}, invocation.signal);
|
|
71
|
+
if (result.failed || result.exitCode !== 0) throw new Error("系统未能打开网页,请复制链接到浏览器后重试。");
|
|
72
|
+
}
|
|
73
|
+
function resolveDocumentPath({ root, sourcePath, destination }) {
|
|
74
|
+
const owner = path.resolve(root);
|
|
75
|
+
const source = sourcePath ? path.resolve(owner, sourcePath) : null;
|
|
76
|
+
if (source) requireContained(owner, source);
|
|
77
|
+
return requireContained(owner, path.resolve(source ? path.dirname(source) : owner, destination));
|
|
78
|
+
}
|
|
79
|
+
function requireContained(root, candidate) {
|
|
80
|
+
const relative = path.relative(root, candidate);
|
|
81
|
+
if (!relative || relative === ".." || relative.startsWith(".." + path.sep) || path.isAbsolute(relative) || relative.includes("\0")) throw new Error("文档链接超出当前可预览的目录。");
|
|
82
|
+
return relative;
|
|
83
|
+
}
|
|
84
|
+
function readDocument(root, relativePath) {
|
|
85
|
+
const owner = realpathSync(root);
|
|
86
|
+
const segments = relativePath.split(path.sep);
|
|
87
|
+
let candidate = owner;
|
|
88
|
+
for (const segment of segments) {
|
|
89
|
+
candidate = path.join(candidate, segment);
|
|
90
|
+
const entry = lstatSync(candidate, { throwIfNoEntry: false });
|
|
91
|
+
if (!entry) throw new Error("文档不存在:" + relativePath);
|
|
92
|
+
if (entry.isSymbolicLink()) throw new Error("文档预览不允许读取符号链接:" + relativePath);
|
|
93
|
+
}
|
|
94
|
+
const descriptor = openSync(candidate, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
|
|
95
|
+
try {
|
|
96
|
+
const metadata = fstatSync(descriptor);
|
|
97
|
+
if (!metadata.isFile() || metadata.size > MAXIMUM_DOCUMENT_BYTES) throw new Error("只能预览不超过 1 MB 的普通 Markdown 文件:" + relativePath);
|
|
98
|
+
const buffer = Buffer.alloc(1048577);
|
|
99
|
+
let length = 0;
|
|
100
|
+
while (length < buffer.length) {
|
|
101
|
+
const count = readSync(descriptor, buffer, length, buffer.length - length, length);
|
|
102
|
+
if (!count) break;
|
|
103
|
+
length += count;
|
|
104
|
+
}
|
|
105
|
+
if (length > MAXIMUM_DOCUMENT_BYTES) throw new Error("文档超过 1 MB,无法预览:" + relativePath);
|
|
106
|
+
return buffer.subarray(0, length).toString("utf8");
|
|
107
|
+
} finally {
|
|
108
|
+
closeSync(descriptor);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
//#endregion
|
|
112
|
+
export { createMarkdownHandlers };
|
package/dist/style.css
CHANGED
|
@@ -2089,6 +2089,110 @@
|
|
|
2089
2089
|
display: none;
|
|
2090
2090
|
}
|
|
2091
2091
|
|
|
2092
|
+
.workbase-markdown-links {
|
|
2093
|
+
flex-direction: column;
|
|
2094
|
+
flex: 1;
|
|
2095
|
+
min-width: 0;
|
|
2096
|
+
min-height: 0;
|
|
2097
|
+
display: flex;
|
|
2098
|
+
}
|
|
2099
|
+
|
|
2100
|
+
.markdown-document-preview {
|
|
2101
|
+
border: 1px solid var(--color-border);
|
|
2102
|
+
background: var(--color-surface);
|
|
2103
|
+
min-width: 0;
|
|
2104
|
+
color: var(--color-foreground);
|
|
2105
|
+
border-radius: 8px;
|
|
2106
|
+
margin-bottom: 20px;
|
|
2107
|
+
padding: 20px;
|
|
2108
|
+
}
|
|
2109
|
+
|
|
2110
|
+
.markdown-document-heading {
|
|
2111
|
+
justify-content: space-between;
|
|
2112
|
+
align-items: start;
|
|
2113
|
+
gap: 16px;
|
|
2114
|
+
margin-bottom: 20px;
|
|
2115
|
+
display: flex;
|
|
2116
|
+
}
|
|
2117
|
+
|
|
2118
|
+
.markdown-document-heading h2 {
|
|
2119
|
+
margin: 0;
|
|
2120
|
+
font-size: 18px;
|
|
2121
|
+
line-height: 1.5;
|
|
2122
|
+
}
|
|
2123
|
+
|
|
2124
|
+
.markdown-document-heading p {
|
|
2125
|
+
color: var(--color-muted);
|
|
2126
|
+
overflow-wrap: anywhere;
|
|
2127
|
+
margin: 8px 0 0;
|
|
2128
|
+
}
|
|
2129
|
+
|
|
2130
|
+
.markdown-document-heading button, .markdown-link-error button {
|
|
2131
|
+
border: 1px solid var(--color-border-strong);
|
|
2132
|
+
background: var(--color-surface);
|
|
2133
|
+
color: var(--color-foreground);
|
|
2134
|
+
font: inherit;
|
|
2135
|
+
cursor: pointer;
|
|
2136
|
+
border-radius: 6px;
|
|
2137
|
+
flex-shrink: 0;
|
|
2138
|
+
padding: 6px 10px;
|
|
2139
|
+
}
|
|
2140
|
+
|
|
2141
|
+
.markdown-document-heading button:hover, .markdown-link-error button:hover {
|
|
2142
|
+
background: var(--color-surface-muted);
|
|
2143
|
+
}
|
|
2144
|
+
|
|
2145
|
+
.markdown-document-preview:focus-visible, .workbase-markdown-links button:focus-visible {
|
|
2146
|
+
outline: 2px solid var(--color-brand);
|
|
2147
|
+
outline-offset: 2px;
|
|
2148
|
+
}
|
|
2149
|
+
|
|
2150
|
+
.markdown-link-error {
|
|
2151
|
+
color: var(--color-danger);
|
|
2152
|
+
overflow-wrap: anywhere;
|
|
2153
|
+
line-height: 1.6;
|
|
2154
|
+
}
|
|
2155
|
+
|
|
2156
|
+
.markdown-link-error button {
|
|
2157
|
+
margin-inline-start: 8px;
|
|
2158
|
+
}
|
|
2159
|
+
|
|
2160
|
+
.workbase-markdown-links .markdown-document-body {
|
|
2161
|
+
max-width: 75ch;
|
|
2162
|
+
max-height: 65vh;
|
|
2163
|
+
color: var(--color-foreground);
|
|
2164
|
+
overflow-wrap: anywhere;
|
|
2165
|
+
font-family: inherit;
|
|
2166
|
+
font-size: 14px;
|
|
2167
|
+
line-height: 1.85;
|
|
2168
|
+
overflow: auto;
|
|
2169
|
+
}
|
|
2170
|
+
|
|
2171
|
+
.markdown-document-body :is(h1, h2, h3, h4, h5, h6) {
|
|
2172
|
+
color: var(--color-foreground);
|
|
2173
|
+
}
|
|
2174
|
+
|
|
2175
|
+
.markdown-document-body a {
|
|
2176
|
+
color: var(--color-accent);
|
|
2177
|
+
text-underline-offset: 3px;
|
|
2178
|
+
}
|
|
2179
|
+
|
|
2180
|
+
.markdown-document-body pre {
|
|
2181
|
+
background: var(--color-surface-muted);
|
|
2182
|
+
overflow: auto;
|
|
2183
|
+
}
|
|
2184
|
+
|
|
2185
|
+
.markdown-document-body table {
|
|
2186
|
+
max-width: 100%;
|
|
2187
|
+
display: block;
|
|
2188
|
+
overflow: auto;
|
|
2189
|
+
}
|
|
2190
|
+
|
|
2191
|
+
.markdown-document-body ::selection {
|
|
2192
|
+
background: var(--color-brand-weak);
|
|
2193
|
+
color: var(--color-foreground);
|
|
2194
|
+
}
|
|
2195
|
+
|
|
2092
2196
|
.workbase-markdown-editor, .workbase-markdown-editor .vditor {
|
|
2093
2197
|
--panel-background-color: var(--color-surface);
|
|
2094
2198
|
--border-color: var(--color-border);
|
|
@@ -2115,17 +2219,6 @@
|
|
|
2115
2219
|
display: block;
|
|
2116
2220
|
}
|
|
2117
2221
|
|
|
2118
|
-
.workbase-markdown-editor > select {
|
|
2119
|
-
border: 1px solid var(--color-border);
|
|
2120
|
-
background: var(--color-surface);
|
|
2121
|
-
max-width: 100%;
|
|
2122
|
-
color: var(--color-foreground);
|
|
2123
|
-
font: inherit;
|
|
2124
|
-
border-radius: 6px;
|
|
2125
|
-
margin-bottom: 8px;
|
|
2126
|
-
padding: 6px 8px;
|
|
2127
|
-
}
|
|
2128
|
-
|
|
2129
2222
|
.workbase-markdown-editor .vditor {
|
|
2130
2223
|
border-radius: 6px;
|
|
2131
2224
|
}
|
|
@@ -2203,7 +2296,7 @@
|
|
|
2203
2296
|
box-shadow: inset 0 0 0 2px var(--color-primary);
|
|
2204
2297
|
}
|
|
2205
2298
|
|
|
2206
|
-
.workbase-markdown-editor button:focus-visible
|
|
2299
|
+
.workbase-markdown-editor button:focus-visible {
|
|
2207
2300
|
outline: 2px solid var(--color-brand);
|
|
2208
2301
|
outline-offset: 2px;
|
|
2209
2302
|
}
|
|
@@ -2217,6 +2310,11 @@
|
|
|
2217
2310
|
opacity: .7;
|
|
2218
2311
|
}
|
|
2219
2312
|
|
|
2313
|
+
.workbase-markdown-editor[data-readonly="true"] :is(.vditor-reset, .vditor-sv)[contenteditable="false"] {
|
|
2314
|
+
opacity: 1;
|
|
2315
|
+
cursor: text;
|
|
2316
|
+
}
|
|
2317
|
+
|
|
2220
2318
|
.markdown-editor-loading {
|
|
2221
2319
|
color: var(--color-muted);
|
|
2222
2320
|
border: 1px solid var(--color-border);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { i as ExecutionLogRecord, n as ExecutionLogEntry } from "./ExecutionLog.dto-CI-HpxZa.js";
|
|
1
2
|
import { ZodType, z } from "zod";
|
|
2
3
|
//#region src/Tools.dto.d.ts
|
|
3
4
|
declare const roleToolEnvironmentSchema: z.ZodObject<{
|
|
@@ -133,6 +134,7 @@ interface PluginPromptQuestion<Key = string, Value = unknown, Choice = unknown>
|
|
|
133
134
|
readonly itemType?: "file" | "directory" | "any";
|
|
134
135
|
readonly message: string;
|
|
135
136
|
readonly title?: string;
|
|
137
|
+
readonly submitLabel?: string;
|
|
136
138
|
readonly purpose?: "input" | "approval";
|
|
137
139
|
readonly name: Key;
|
|
138
140
|
readonly pageSize?: number;
|
|
@@ -269,6 +271,7 @@ interface PluginLogQueryResult {
|
|
|
269
271
|
}
|
|
270
272
|
interface PluginLogService {
|
|
271
273
|
readonly query: (request?: PluginLogQueryRequest) => Promise<PluginLogQueryResult>;
|
|
274
|
+
readonly get: (executionId: string) => Promise<ExecutionLogRecord>;
|
|
272
275
|
}
|
|
273
276
|
interface PluginTaskDescriptor {
|
|
274
277
|
readonly id: string;
|
|
@@ -287,6 +290,7 @@ interface PluginTaskService {
|
|
|
287
290
|
}
|
|
288
291
|
/** Opaque delegation is usable only while its verified parent execution remains active. */
|
|
289
292
|
interface PluginExecutionService {
|
|
293
|
+
readonly log: (entry: ExecutionLogEntry) => Promise<void>;
|
|
290
294
|
readonly report: (details: PluginCommandDetails) => Promise<void>;
|
|
291
295
|
readonly start: (request: PluginCapabilityCommandRequest) => Promise<PluginExecutionSnapshot>;
|
|
292
296
|
readonly query: (executionId?: string) => Promise<readonly PluginExecutionSnapshot[]>;
|
|
@@ -318,6 +322,10 @@ interface PluginHostServices {
|
|
|
318
322
|
readonly toast: PluginToastApi;
|
|
319
323
|
readonly tasks: PluginTaskService;
|
|
320
324
|
readonly tools: PluginToolsService;
|
|
325
|
+
/** Checks committed code against the configured collaboration branches without closing the workspace. */
|
|
326
|
+
readonly workspace: {
|
|
327
|
+
readonly verifySynchronized: () => Promise<void>;
|
|
328
|
+
};
|
|
321
329
|
}
|
|
322
330
|
//#endregion
|
|
323
331
|
//#region src/types.d.ts
|
|
@@ -326,6 +334,7 @@ declare enum PluginHookId {
|
|
|
326
334
|
WorkspaceActivate = "workspace.activate",
|
|
327
335
|
WorkspaceAfterPrepare = "workspace.afterPrepare",
|
|
328
336
|
WorkspaceDeactivate = "workspace.deactivate",
|
|
337
|
+
WorkspaceFinalize = "workspace.finalize",
|
|
329
338
|
WorkspaceProvision = "workspace.provision",
|
|
330
339
|
Cleanup = "cleanup"
|
|
331
340
|
}
|
|
@@ -646,6 +655,7 @@ interface PluginSetupHooks {
|
|
|
646
655
|
readonly onWorkspaceActivate: PluginLifecycleHook;
|
|
647
656
|
readonly onWorkspaceAfterPrepare: PluginLifecycleHook;
|
|
648
657
|
readonly onWorkspaceDeactivate: PluginLifecycleHook;
|
|
658
|
+
readonly onWorkspaceFinalize: PluginLifecycleHook;
|
|
649
659
|
readonly onWorkspaceProvision: PluginLifecycleHook;
|
|
650
660
|
readonly registerAgentContext: (definition: PluginAgentContextDefinition) => void;
|
|
651
661
|
readonly registerCommand: (definition: PluginCommandDefinition) => void;
|