@eworkbase/sdk 0.8.4 → 0.8.5

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.
@@ -72,9 +72,9 @@ declare const executionLogRecordSchema: z.ZodObject<{
72
72
  id: z.ZodString;
73
73
  createdAt: z.ZodString;
74
74
  level: z.ZodEnum<{
75
+ info: "info";
75
76
  error: "error";
76
77
  debug: "debug";
77
- info: "info";
78
78
  warn: "warn";
79
79
  }>;
80
80
  message: z.ZodString;
package/dist/index.d.ts CHANGED
@@ -1,17 +1,23 @@
1
- import { a as executionLogRecordSchema, i as executionLogEntrySchema, n as ExecutionLogEntryKind, r as ExecutionLogRecord, t as ExecutionLogEntry } from "./ExecutionLog.dto-ig9GUWhK.js";
2
- import { $ as PluginViewDefinition, A as PluginLifecycleDispatchResult, At as PluginTaskResult, B as PluginProcessOutputMode, Bt as RoleToolEnvironment, C as PluginExecutionEvidence, Ct as PluginPromptQuestion, D as PluginHookId, Dt as PluginStoreApi, E as PluginFileChange, Et as PluginStatusCatalogEntry, F as PluginLogger, Ft as PluginViewCatalogEntry, G as PluginRepositoryStatus, Gt as roleToolsProposalSchema, H as PluginProcessRunOptions, Ht as RoleToolsProposal, I as PluginOverviewCardData, It as PluginWorkflowContribution, J as PluginSharedChanges, K as PluginSetupHooks, L as PluginOverviewCardDefinition, Lt as PluginWorkflowOutput, M as PluginLifecycleOutcome, Mt as PluginToastApi, N as PluginLifecyclePolicy, Nt as PluginToastLevel, O as PluginHookResult, Ot as PluginSystemContextService, P as PluginLifecycleStatus, Pt as PluginToastOptions, Q as PluginViewContribution, R as PluginOverviewCardStatus, Rt as workflowContributionSchema, S as PluginDisposable, St as PluginPromptChoice, T as PluginExecutionStatus, Tt as PluginPromptViewRequest, U as PluginProject, Ut as roleToolEnvironmentSchema, V as PluginProcessResult, Vt as RoleToolsApplied, W as PluginRepository, Wt as roleToolsAppliedSchema, X as PluginStatusDefinition, Y as PluginStatusContribution, Z as PluginToolContribution, _ as PluginCommandOption, _t as PluginLogEntry, a as PluginCapabilityReference, at as PluginAgentContextCatalogEntry, b as PluginContextExposure, bt as PluginLogService, c as PluginCommandCategory, ct as PluginCapabilityCommandRequest, d as PluginCommandDefinition, dt as PluginColoredMessage, et as PluginViewLayout, f as PluginCommandDetails, ft as PluginCommandCatalogEntry, g as PluginCommandLogPolicy, gt as PluginInteractiveLogger, h as PluginCommandExecutionResult, ht as PluginHostServices, i as PluginCapabilityKind, it as WorkbasePluginDefinition, j as PluginLifecycleHook, jt as PluginTaskService, k as PluginInvocationContext, kt as PluginTaskDescriptor, l as PluginCommandContext, lt as PluginCapabilityResolveRequest, m as PluginCommandExecutionMode, mt as PluginExecutionService, n as PluginAgentContextDefinition, nt as PluginViewRequest, o as PluginCardAction, ot as PluginAgentPolicy, p as PluginCommandEffect, pt as PluginConfigApi, q as PluginSharedChangeKind, r as PluginAgentScope, rt as PluginWorkspace, s as PluginCommandArgument, st as PluginCapabilityCatalog, t as PluginAgentContextContribution, tt as PluginViewMethod, u as PluginCommandContribution, ut as PluginCapabilityService, v as PluginCommandTransaction, vt as PluginLogQueryRequest, w as PluginExecutionSnapshot, wt as PluginPromptType, x as PluginContributionSnapshot, xt as PluginPromptApi, y as PluginContext, yt as PluginLogQueryResult, z as PluginProcessApi, zt as PluginToolsService } from "./types-2X-_T_W_.js";
3
- export * from "zod";
4
- //#region src/publication.d.ts
5
- interface PublicationContext {
6
- readonly project: PluginProject;
7
- readonly process: PluginProcessApi;
8
- readonly signal?: AbortSignal;
1
+ import { a as executionLogRecordSchema, i as executionLogEntrySchema, n as ExecutionLogEntryKind, r as ExecutionLogRecord, t as ExecutionLogEntry } from "./ExecutionLog.dto-Bq2u5C90.js";
2
+ import { $ as WorkbasePluginDefinition, A as PluginLifecycleStatus, At as PluginViewCatalogEntry, B as PluginRepository, C as PluginHookId, Ct as PluginSystemContextService, D as PluginLifecycleHook, Dt as PluginToastApi, E as PluginLifecycleDispatchResult, Et as PluginTaskService, F as PluginProcessApi, Ft as roleToolEnvironmentSchema, G as PluginStatusContribution, H as PluginSetupHooks, I as PluginProcessOutputMode, It as roleToolsAppliedSchema, J as PluginViewContribution, K as PluginStatusDefinition, L as PluginProcessResult, Lt as roleToolsProposalSchema, M as PluginOverviewCardData, Mt as RoleToolEnvironment, N as PluginOverviewCardDefinition, Nt as RoleToolsApplied, O as PluginLifecycleOutcome, Ot as PluginToastLevel, P as PluginOverviewCardStatus, Pt as RoleToolsProposal, Q as PluginWorkspace, R as PluginProcessRunOptions, S as PluginFileChange, St as PluginStoreApi, T as PluginInvocationContext, Tt as PluginTaskResult, U as PluginSharedChangeKind, V as PluginRepositoryStatus, W as PluginSharedChanges, X as PluginViewLayout, Y as PluginViewDefinition, Z as PluginViewMethod, _ as PluginContributionSnapshot, _t as PluginPromptQuestion, a as PluginCapabilityReference, at as PluginCapabilityService, b as PluginExecutionSnapshot, bt as PluginPublicationChanges, c as PluginCommandContribution, ct as PluginExecutionService, d as PluginCommandEffect, dt as PluginLogEntry, et as PluginAgentContextCatalogEntry, f as PluginCommandExecutionResult, ft as PluginLogQueryRequest, g as PluginContextExposure, gt as PluginPromptChoice, h as PluginContext, ht as PluginPromptApi, i as PluginCapabilityKind, it as PluginCapabilityResolveRequest, j as PluginLogger, jt as PluginToolsService, k as PluginLifecyclePolicy, kt as PluginToastOptions, l as PluginCommandDefinition, lt as PluginHostServices, m as PluginCommandTransaction, mt as PluginLogService, n as PluginAgentContextDefinition, nt as PluginCapabilityCatalog, o as PluginCardAction, ot as PluginCommandCatalogEntry, p as PluginCommandLogPolicy, pt as PluginLogQueryResult, q as PluginToolContribution, r as PluginAgentScope, rt as PluginCapabilityCommandRequest, s as PluginCommandContext, st as PluginConfigApi, t as PluginAgentContextContribution, tt as PluginAgentPolicy, u as PluginCommandDetails, ut as PluginInteractiveLogger, v as PluginDisposable, vt as PluginPromptType, w as PluginHookResult, wt as PluginTaskDescriptor, x as PluginExecutionStatus, xt as PluginStatusCatalogEntry, y as PluginExecutionEvidence, yt as PluginPromptViewRequest, z as PluginProject } from "./types-WIMkhmH4.js";
3
+ import { ZodError, ZodType, z } from "zod";
4
+ //#region src/error.d.ts
5
+ /**
6
+ * Canonical structured plugin error recognized by the Workbase Node Bridge.
7
+ */
8
+ interface PluginErrorOptions {
9
+ readonly code: string;
10
+ readonly message: string;
11
+ readonly details?: unknown;
12
+ readonly retryable?: boolean;
9
13
  }
10
- export declare function readPublicationChanges({ project, process, signal }: PublicationContext, directory: string): Promise<{
11
- files: string[];
12
- working: Set<string>;
13
- partiallyStaged: boolean;
14
- }>;
14
+ export declare class PluginError extends Error {
15
+ readonly code: string;
16
+ readonly details?: unknown;
17
+ readonly retryable: boolean;
18
+ constructor({ code, message, details, retryable }: PluginErrorOptions);
19
+ }
20
+ export declare function createPluginError(options: PluginErrorOptions): PluginError;
15
21
  //#endregion
16
22
  //#region src/definition.d.ts
17
23
  export declare const PLUGIN_API_VERSION = 2;
@@ -19,4 +25,4 @@ type DefinedWorkbasePlugin = Readonly<WorkbasePluginDefinition>;
19
25
  export declare function definePlugin(definition: WorkbasePluginDefinition): DefinedWorkbasePlugin;
20
26
  export declare function isDefinedPlugin(value: unknown): value is DefinedWorkbasePlugin;
21
27
  //#endregion
22
- 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 PluginCardAction, type PluginColoredMessage, type PluginCommandArgument, type PluginCommandCatalogEntry, PluginCommandCategory, type PluginCommandContext, type PluginCommandContribution, type PluginCommandDefinition, type PluginCommandDetails, PluginCommandEffect, PluginCommandExecutionMode, type PluginCommandExecutionResult, PluginCommandLogPolicy, 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 PluginOverviewCardData, type PluginOverviewCardDefinition, type PluginOverviewCardStatus, 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, PluginViewMethod, type PluginViewRequest, type PluginWorkflowContribution, type PluginWorkflowOutput, type PluginWorkspace, RoleToolEnvironment, RoleToolsApplied, RoleToolsProposal, type WorkbasePluginDefinition, executionLogEntrySchema, executionLogRecordSchema, roleToolEnvironmentSchema, roleToolsAppliedSchema, roleToolsProposalSchema, workflowContributionSchema };
28
+ 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 PluginCardAction, type PluginCommandCatalogEntry, type PluginCommandContext, type PluginCommandContribution, type PluginCommandDefinition, type PluginCommandDetails, PluginCommandEffect, type PluginCommandExecutionResult, PluginCommandLogPolicy, PluginCommandTransaction, type PluginConfigApi, type PluginContext, PluginContextExposure, type PluginContributionSnapshot, type PluginDisposable, type PluginErrorOptions, 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 PluginOverviewCardData, type PluginOverviewCardDefinition, type PluginOverviewCardStatus, type PluginProcessApi, PluginProcessOutputMode, type PluginProcessResult, type PluginProcessRunOptions, type PluginProject, type PluginPromptApi, type PluginPromptChoice, type PluginPromptQuestion, type PluginPromptType, type PluginPromptViewRequest, type PluginPublicationChanges, 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, PluginViewMethod, type PluginWorkspace, RoleToolEnvironment, RoleToolsApplied, RoleToolsProposal, type WorkbasePluginDefinition, ZodError, type ZodType, executionLogEntrySchema, executionLogRecordSchema, roleToolEnvironmentSchema, roleToolsAppliedSchema, roleToolsProposalSchema, z };
package/dist/index.js CHANGED
@@ -1,5 +1,51 @@
1
- import { z } from "zod";
2
- export * from "zod";
1
+ import { ZodError, z, z as z$1 } from "zod";
2
+ //#region src/error.ts
3
+ var PluginError = class extends Error {
4
+ code;
5
+ details;
6
+ retryable;
7
+ constructor({ code, message, details, retryable = false }) {
8
+ super(message);
9
+ this.name = "PluginError";
10
+ this.code = code;
11
+ this.retryable = retryable;
12
+ if (details !== void 0) this.details = details;
13
+ }
14
+ };
15
+ function createPluginError(options) {
16
+ return new PluginError(options);
17
+ }
18
+ //#endregion
19
+ //#region src/definition.ts
20
+ const PLUGIN_API_VERSION = 2;
21
+ const PLUGIN_ID_PATTERN = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;
22
+ function definePlugin(definition) {
23
+ validateDefinition(definition);
24
+ return Object.freeze({
25
+ ...definition,
26
+ dependencies: Object.freeze([...definition.dependencies ?? []])
27
+ });
28
+ }
29
+ function isDefinedPlugin(value) {
30
+ try {
31
+ validateDefinition(value);
32
+ return true;
33
+ } catch {
34
+ return false;
35
+ }
36
+ }
37
+ function validateDefinition(definition) {
38
+ if (!isRecord(definition)) throw new TypeError("definePlugin requires a plugin definition object.");
39
+ if (typeof definition.id !== "string" || !PLUGIN_ID_PATTERN.test(definition.id)) throw new TypeError("Plugin id must use lowercase kebab-case.");
40
+ if (typeof definition.setup !== "function") throw new TypeError("Plugin setup must be a function.");
41
+ if (typeof definition.title !== "string" || definition.title.trim() === "") throw new TypeError("Plugin title must be a non-empty string.");
42
+ const dependencies = definition.dependencies ?? [];
43
+ if (!Array.isArray(dependencies) || dependencies.some((id) => typeof id !== "string" || !PLUGIN_ID_PATTERN.test(id) || id === definition.id) || new Set(dependencies).size !== dependencies.length) throw new TypeError("Plugin dependencies must be unique plugin ids and cannot include itself.");
44
+ }
45
+ function isRecord(value) {
46
+ return value !== null && typeof value === "object" && !Array.isArray(value);
47
+ }
48
+ //#endregion
3
49
  //#region src/types.ts
4
50
  let PluginHookId = /* @__PURE__ */ function(PluginHookId) {
5
51
  PluginHookId["ProjectReconcile"] = "project.reconcile";
@@ -50,19 +96,6 @@ let PluginCommandTransaction = /* @__PURE__ */ function(PluginCommandTransaction
50
96
  PluginCommandTransaction["ProjectMutation"] = "projectMutation";
51
97
  return PluginCommandTransaction;
52
98
  }({});
53
- let PluginCommandCategory = /* @__PURE__ */ function(PluginCommandCategory) {
54
- PluginCommandCategory["Build"] = "build";
55
- PluginCommandCategory["Publish"] = "publish";
56
- PluginCommandCategory["Run"] = "run";
57
- PluginCommandCategory["Settings"] = "settings";
58
- return PluginCommandCategory;
59
- }({});
60
- let PluginCommandExecutionMode = /* @__PURE__ */ function(PluginCommandExecutionMode) {
61
- PluginCommandExecutionMode["Async"] = "async";
62
- PluginCommandExecutionMode["Persistent"] = "persistent";
63
- PluginCommandExecutionMode["Sync"] = "sync";
64
- return PluginCommandExecutionMode;
65
- }({});
66
99
  let PluginLifecyclePolicy = /* @__PURE__ */ function(PluginLifecyclePolicy) {
67
100
  PluginLifecyclePolicy["BestEffort"] = "bestEffort";
68
101
  PluginLifecyclePolicy["FailFast"] = "failFast";
@@ -105,125 +138,15 @@ let PluginViewMethod = /* @__PURE__ */ function(PluginViewMethod) {
105
138
  return PluginViewMethod;
106
139
  }({});
107
140
  //#endregion
108
- //#region src/publication.ts
109
- async function readPublicationChanges({ project, process, signal }, directory) {
110
- const working = /* @__PURE__ */ new Set();
111
- if (!project.publicationBranch) return {
112
- files: [],
113
- working,
114
- partiallyStaged: false
115
- };
116
- const read = async (args, allowMissingAncestor = false) => {
117
- const result = await process.run({
118
- program: "git",
119
- arguments: args,
120
- currentDirectory: project.root,
121
- outputMode: "content",
122
- environment: {
123
- GIT_OPTIONAL_LOCKS: "0",
124
- GIT_LITERAL_PATHSPECS: "1",
125
- GIT_TERMINAL_PROMPT: "0"
126
- }
127
- }, signal);
128
- if (allowMissingAncestor && result.exitCode === 1 && !result.standardError && !result.timedOut && !result.wasCancelled) return "";
129
- if (result.failed || result.timedOut || result.wasCancelled || result.standardOutputTruncated !== false) throw new Error("无法完整读取文件的发布状态。");
130
- return result.standardOutput;
131
- };
132
- const names = async (args) => (await read([
133
- ...args,
134
- "--",
135
- directory
136
- ])).split("\0").filter((file) => file && !file.endsWith("/"));
137
- const remote = "refs/remotes/origin/" + project.publicationBranch;
138
- const common = (await read([
139
- "merge-base",
140
- "HEAD",
141
- remote
142
- ], true)).trim();
143
- const baseline = (await read([
144
- "for-each-ref",
145
- "--format=%(objectname)",
146
- `refs/workbase/publications/${project.publicationBranch}/${common || "unrelated"}`
147
- ])).trim() || common;
148
- if (!baseline) throw new Error("远端分支历史已更换,请先确认团队配置版本。");
149
- const diff = [
150
- "diff",
151
- "--relative",
152
- "--ignore-submodules=all",
153
- "--no-renames",
154
- "--name-only",
155
- "-z"
156
- ];
157
- const [unstaged, staged, committed, unequal, untracked] = await Promise.all([
158
- names(diff),
159
- names([...diff, "--cached"]),
160
- names([
161
- ...diff,
162
- baseline,
163
- "HEAD"
164
- ]),
165
- names([
166
- ...diff,
167
- remote,
168
- "HEAD"
169
- ]),
170
- names([
171
- "ls-files",
172
- "--others",
173
- "--exclude-standard",
174
- "-z"
175
- ])
176
- ]);
177
- [...unstaged, ...untracked].forEach((file) => working.add(file));
178
- const partiallyStaged = staged.some((file) => working.has(file));
179
- staged.forEach((file) => working.add(file));
180
- const unpublished = new Set(unequal);
181
- return {
182
- files: [.../* @__PURE__ */ new Set([...working, ...committed.filter((file) => unpublished.has(file))])].sort(),
183
- working,
184
- partiallyStaged
185
- };
186
- }
187
- //#endregion
188
- //#region src/definition.ts
189
- const PLUGIN_API_VERSION = 2;
190
- const PLUGIN_ID_PATTERN = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;
191
- function definePlugin(definition) {
192
- validateDefinition(definition);
193
- return Object.freeze({
194
- ...definition,
195
- dependencies: Object.freeze([...definition.dependencies ?? []])
196
- });
197
- }
198
- function isDefinedPlugin(value) {
199
- try {
200
- validateDefinition(value);
201
- return true;
202
- } catch {
203
- return false;
204
- }
205
- }
206
- function validateDefinition(definition) {
207
- if (!isRecord(definition)) throw new TypeError("definePlugin requires a plugin definition object.");
208
- if (typeof definition.id !== "string" || !PLUGIN_ID_PATTERN.test(definition.id)) throw new TypeError("Plugin id must use lowercase kebab-case.");
209
- if (typeof definition.setup !== "function") throw new TypeError("Plugin setup must be a function.");
210
- if (typeof definition.title !== "string" || definition.title.trim() === "") throw new TypeError("Plugin title must be a non-empty string.");
211
- const dependencies = definition.dependencies ?? [];
212
- if (!Array.isArray(dependencies) || dependencies.some((id) => typeof id !== "string" || !PLUGIN_ID_PATTERN.test(id) || id === definition.id) || new Set(dependencies).size !== dependencies.length) throw new TypeError("Plugin dependencies must be unique plugin ids and cannot include itself.");
213
- }
214
- function isRecord(value) {
215
- return value !== null && typeof value === "object" && !Array.isArray(value);
216
- }
217
- //#endregion
218
141
  //#region src/Tools.dto.ts
219
142
  /** Typed tool-domain contracts shared by the SDK and host bridge. */
220
- const identifier = z.string().min(1);
221
- const toolKind = z.enum([
143
+ const identifier = z$1.string().min(1);
144
+ const toolKind = z$1.enum([
222
145
  "runtime",
223
146
  "cli",
224
147
  "desktop"
225
148
  ]);
226
- const toolStatus = z.enum([
149
+ const toolStatus = z$1.enum([
227
150
  "unknown",
228
151
  "running",
229
152
  "ready",
@@ -235,66 +158,66 @@ const toolStatus = z.enum([
235
158
  "cancelled",
236
159
  "interrupted"
237
160
  ]);
238
- const roleToolEnvironmentSchema = z.object({
161
+ const roleToolEnvironmentSchema = z$1.object({
239
162
  roleId: identifier,
240
- roleLabel: z.string(),
163
+ roleLabel: z$1.string(),
241
164
  revision: identifier,
242
- assignedToolIds: z.array(identifier),
243
- tools: z.array(z.object({
165
+ assignedToolIds: z$1.array(identifier),
166
+ tools: z$1.array(z$1.object({
244
167
  id: identifier,
245
- label: z.string(),
168
+ label: z$1.string(),
246
169
  kind: toolKind,
247
- version: z.string().nullable(),
248
- assigned: z.boolean(),
249
- shared: z.boolean(),
250
- assignable: z.boolean()
170
+ version: z$1.string().nullable(),
171
+ assigned: z$1.boolean(),
172
+ shared: z$1.boolean(),
173
+ assignable: z$1.boolean()
251
174
  })),
252
- runtimes: z.object({
253
- projectRoot: z.string(),
254
- miseVersion: z.string().nullable(),
255
- status: z.enum([
175
+ runtimes: z$1.object({
176
+ projectRoot: z$1.string(),
177
+ miseVersion: z$1.string().nullable(),
178
+ status: z$1.enum([
256
179
  "missing",
257
180
  "outdated",
258
181
  "not-prepared",
259
182
  "ready",
260
183
  "failed"
261
184
  ]),
262
- detail: z.string(),
263
- runtimes: z.array(z.object({
185
+ detail: z$1.string(),
186
+ runtimes: z$1.array(z$1.object({
264
187
  id: identifier,
265
- label: z.string(),
188
+ label: z$1.string(),
266
189
  runtimeId: identifier,
267
- version: z.string(),
268
- installed: z.boolean(),
269
- terminalApplied: z.boolean()
190
+ version: z$1.string(),
191
+ installed: z$1.boolean(),
192
+ terminalApplied: z$1.boolean()
270
193
  }))
271
194
  }),
272
- nativeTools: z.array(z.object({
195
+ nativeTools: z$1.array(z$1.object({
273
196
  id: identifier,
274
- label: z.string(),
197
+ label: z$1.string(),
275
198
  kind: toolKind,
276
- currentVersion: z.string().nullable(),
199
+ currentVersion: z$1.string().nullable(),
277
200
  status: toolStatus,
278
- detail: z.string(),
279
- manualActionMessage: z.string().nullable()
201
+ detail: z$1.string(),
202
+ manualActionMessage: z$1.string().nullable()
280
203
  }))
281
204
  });
282
- const roleToolsProposalSchema = z.object({
283
- id: z.string().uuid(),
205
+ const roleToolsProposalSchema = z$1.object({
206
+ id: z$1.string().uuid(),
284
207
  roleId: identifier,
285
- roleLabel: z.string(),
208
+ roleLabel: z$1.string(),
286
209
  revision: identifier,
287
- toolIds: z.array(identifier),
288
- before: z.array(identifier),
289
- after: z.array(identifier),
290
- labels: z.array(z.string()),
291
- reason: z.string()
210
+ toolIds: z$1.array(identifier),
211
+ before: z$1.array(identifier),
212
+ after: z$1.array(identifier),
213
+ labels: z$1.array(z$1.string()),
214
+ reason: z$1.string()
292
215
  });
293
- const roleToolsAppliedSchema = z.object({
216
+ const roleToolsAppliedSchema = z$1.object({
294
217
  roleId: identifier,
295
- toolIds: z.array(identifier),
296
- applied: z.literal(true),
297
- requiresPreparation: z.boolean()
218
+ toolIds: z$1.array(identifier),
219
+ applied: z$1.literal(true),
220
+ requiresPreparation: z$1.boolean()
298
221
  });
299
222
  //#endregion
300
223
  //#region src/ExecutionLog.dto.ts
@@ -306,104 +229,78 @@ let ExecutionLogEntryKind = /* @__PURE__ */ function(ExecutionLogEntryKind) {
306
229
  ExecutionLogEntryKind["Answer"] = "answer";
307
230
  return ExecutionLogEntryKind;
308
231
  }({});
309
- const executionLogEntrySchema = z.object({
310
- id: z.string().min(1).max(160),
311
- kind: z.enum(ExecutionLogEntryKind),
312
- time: z.iso.datetime(),
313
- title: z.string().max(240),
314
- content: z.string().max(48e3),
315
- details: z.string().max(8e3).nullish(),
316
- status: z.string().max(64).nullish()
232
+ const executionLogEntrySchema = z$1.object({
233
+ id: z$1.string().min(1).max(160),
234
+ kind: z$1.enum(ExecutionLogEntryKind),
235
+ time: z$1.iso.datetime(),
236
+ title: z$1.string().max(240),
237
+ content: z$1.string().max(48e3),
238
+ details: z$1.string().max(8e3).nullish(),
239
+ status: z$1.string().max(64).nullish()
317
240
  }).strict();
318
- const executionTimingSchema = z.object({
319
- queuedAt: z.string().nullish(),
320
- startedAt: z.string().nullish(),
321
- finishedAt: z.string().nullish()
241
+ const executionTimingSchema = z$1.object({
242
+ queuedAt: z$1.string().nullish(),
243
+ startedAt: z$1.string().nullish(),
244
+ finishedAt: z$1.string().nullish()
322
245
  });
323
- const executionIdentitySchema = z.object({
324
- pluginId: z.string(),
325
- commandId: z.string()
246
+ const executionIdentitySchema = z$1.object({
247
+ pluginId: z$1.string(),
248
+ commandId: z$1.string()
326
249
  });
327
- const executionContextSchema = z.object({ finishedAt: z.string().nullish() });
328
- const logStepSchema = z.object({
329
- id: z.string(),
330
- legacyId: z.string().optional(),
331
- label: z.string(),
332
- detail: z.string(),
333
- status: z.string(),
334
- executionState: z.string().nullish(),
335
- phase: z.string().nullish(),
250
+ const executionContextSchema = z$1.object({ finishedAt: z$1.string().nullish() });
251
+ const logStepSchema = z$1.object({
252
+ id: z$1.string(),
253
+ legacyId: z$1.string().optional(),
254
+ label: z$1.string(),
255
+ detail: z$1.string(),
256
+ status: z$1.string(),
257
+ executionState: z$1.string().nullish(),
258
+ phase: z$1.string().nullish(),
336
259
  timing: executionTimingSchema.optional(),
337
- target: z.object({
338
- kind: z.string(),
339
- id: z.string(),
340
- label: z.string()
260
+ target: z$1.object({
261
+ kind: z$1.string(),
262
+ id: z$1.string(),
263
+ label: z$1.string()
341
264
  }).nullish(),
342
- provider: z.string().nullish(),
343
- command: z.string().nullish(),
344
- stdout: z.string().nullish(),
345
- stderr: z.string().nullish(),
346
- manualActionMessage: z.string().nullish()
265
+ provider: z$1.string().nullish(),
266
+ command: z$1.string().nullish(),
267
+ stdout: z$1.string().nullish(),
268
+ stderr: z$1.string().nullish(),
269
+ manualActionMessage: z$1.string().nullish()
347
270
  });
348
- const logCallSchema = z.object({
349
- id: z.string(),
350
- title: z.string(),
351
- status: z.string(),
352
- createdAt: z.string(),
353
- operationKind: z.string(),
354
- hasWarnings: z.boolean(),
271
+ const logCallSchema = z$1.object({
272
+ id: z$1.string(),
273
+ title: z$1.string(),
274
+ status: z$1.string(),
275
+ createdAt: z$1.string(),
276
+ operationKind: z$1.string(),
277
+ hasWarnings: z$1.boolean(),
355
278
  context: executionContextSchema,
356
- hasChildErrors: z.boolean().optional(),
279
+ hasChildErrors: z$1.boolean().optional(),
357
280
  execution: executionIdentitySchema.nullish()
358
281
  });
359
282
  /** Existing operation evidence is returned alongside entries; it is never copied into another store. */
360
- const executionLogRecordSchema = z.object({
361
- id: z.string(),
362
- title: z.string(),
363
- entries: z.array(executionLogEntrySchema),
364
- steps: z.array(logStepSchema).optional(),
365
- children: z.array(logCallSchema).optional(),
366
- messages: z.array(z.object({
367
- id: z.string(),
368
- createdAt: z.string(),
369
- level: z.enum([
283
+ const executionLogRecordSchema = z$1.object({
284
+ id: z$1.string(),
285
+ title: z$1.string(),
286
+ entries: z$1.array(executionLogEntrySchema),
287
+ steps: z$1.array(logStepSchema).optional(),
288
+ children: z$1.array(logCallSchema).optional(),
289
+ messages: z$1.array(z$1.object({
290
+ id: z$1.string(),
291
+ createdAt: z$1.string(),
292
+ level: z$1.enum([
370
293
  "debug",
371
294
  "info",
372
295
  "warn",
373
296
  "error"
374
297
  ]),
375
- message: z.string()
298
+ message: z$1.string()
376
299
  })).optional(),
377
- warnings: z.array(z.string()).optional(),
378
- createdAt: z.string().optional(),
300
+ warnings: z$1.array(z$1.string()).optional(),
301
+ createdAt: z$1.string().optional(),
379
302
  execution: executionIdentitySchema.nullish(),
380
303
  context: executionContextSchema.optional()
381
304
  });
382
305
  //#endregion
383
- //#region src/WorkflowContribution.dto.ts
384
- /** Serializable opt-in for workflow nodes and the result fields a condition may read. */
385
- const name = z.string().trim().min(1).max(120);
386
- const fieldKey = z.string().regex(/^[A-Za-z][A-Za-z0-9_]{0,63}$/).refine((key) => ![
387
- "constructor",
388
- "prototype",
389
- "__proto__"
390
- ].includes(key));
391
- const outputField = z.discriminatedUnion("type", [
392
- z.object({
393
- type: z.literal("boolean"),
394
- label: name
395
- }).strict(),
396
- z.object({
397
- type: z.literal("number"),
398
- label: name,
399
- unit: name.optional()
400
- }).strict(),
401
- z.object({
402
- type: z.literal("enum"),
403
- label: name,
404
- values: z.array(name).min(1).max(64)
405
- }).strict()
406
- ]);
407
- const workflowContributionSchema = z.union([z.literal(true), z.object({ outputs: z.record(fieldKey, outputField).refine((fields) => Object.keys(fields).length <= 32) }).strict()]);
408
- //#endregion
409
- export { ExecutionLogEntryKind, PLUGIN_API_VERSION, PluginAgentScope, PluginCapabilityKind, PluginCommandCategory, PluginCommandEffect, PluginCommandExecutionMode, PluginCommandLogPolicy, PluginCommandTransaction, PluginContextExposure, PluginExecutionStatus, PluginHookId, PluginLifecyclePolicy, PluginLifecycleStatus, PluginProcessOutputMode, PluginRepositoryStatus, PluginSharedChangeKind, PluginViewLayout, PluginViewMethod, definePlugin, executionLogEntrySchema, executionLogRecordSchema, isDefinedPlugin, readPublicationChanges, roleToolEnvironmentSchema, roleToolsAppliedSchema, roleToolsProposalSchema, workflowContributionSchema };
306
+ export { ExecutionLogEntryKind, PLUGIN_API_VERSION, PluginAgentScope, PluginCapabilityKind, PluginCommandEffect, PluginCommandLogPolicy, PluginCommandTransaction, PluginContextExposure, PluginError, PluginExecutionStatus, PluginHookId, PluginLifecyclePolicy, PluginLifecycleStatus, PluginProcessOutputMode, PluginRepositoryStatus, PluginSharedChangeKind, PluginViewLayout, PluginViewMethod, ZodError, createPluginError, definePlugin, executionLogEntrySchema, executionLogRecordSchema, isDefinedPlugin, roleToolEnvironmentSchema, roleToolsAppliedSchema, roleToolsProposalSchema, z };
@@ -1,4 +1,4 @@
1
- import { k as PluginInvocationContext } from "./types-2X-_T_W_.js";
1
+ import { T as PluginInvocationContext } from "./types-WIMkhmH4.js";
2
2
  //#region src/Markdown.dto.d.ts
3
3
  interface MarkdownDocument {
4
4
  readonly path: string;
package/dist/markdown.js CHANGED
@@ -95,9 +95,16 @@ function readDocument(root, relativePath) {
95
95
  try {
96
96
  const metadata = fstatSync(descriptor);
97
97
  if (!metadata.isFile() || metadata.size > MAXIMUM_DOCUMENT_BYTES) throw new Error("只能预览不超过 1 MB 的普通 Markdown 文件:" + relativePath);
98
- const buffer = Buffer.alloc(1048577);
98
+ const initialCapacity = Math.min(Math.max(metadata.size, 0) + 1, 1048577);
99
+ let buffer = Buffer.alloc(initialCapacity);
99
100
  let length = 0;
100
- while (length < buffer.length) {
101
+ while (length <= MAXIMUM_DOCUMENT_BYTES) {
102
+ if (length === buffer.length) {
103
+ const nextCapacity = Math.min(buffer.length * 2, 1048577);
104
+ const expanded = Buffer.alloc(nextCapacity);
105
+ buffer.copy(expanded, 0, 0, length);
106
+ buffer = expanded;
107
+ }
101
108
  const count = readSync(descriptor, buffer, length, buffer.length - length, length);
102
109
  if (!count) break;
103
110
  length += count;