@eworkbase/sdk 0.8.5 → 0.8.7

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";
76
75
  error: "error";
77
76
  debug: "debug";
77
+ info: "info";
78
78
  warn: "warn";
79
79
  }>;
80
80
  message: z.ZodString;
@@ -0,0 +1,54 @@
1
+ //#region src/build.d.ts
2
+ /**
3
+ * Shared tsdown build factory for Workbase plugins.
4
+ * Generates the Node backend bundle, browser React bundle and canonical dist/ui/index.html.
5
+ */
6
+ export interface PluginBuildCopyEntry {
7
+ readonly from: string | readonly string[];
8
+ readonly to?: string;
9
+ }
10
+ export interface PluginBuildEntryConfig {
11
+ readonly entry: Readonly<Record<string, string>>;
12
+ readonly outDir?: string;
13
+ readonly platform: "node" | "browser" | "neutral";
14
+ readonly target: string;
15
+ readonly minify?: boolean;
16
+ readonly shims?: boolean;
17
+ readonly dts?: boolean;
18
+ readonly env?: Readonly<Record<string, string>>;
19
+ readonly inputOptions?: Readonly<Record<string, unknown>>;
20
+ readonly deps?: {
21
+ readonly alwaysBundle?: readonly (string | RegExp)[];
22
+ readonly neverBundle?: readonly (string | RegExp)[];
23
+ };
24
+ readonly plugins?: readonly unknown[];
25
+ readonly copy?: readonly PluginBuildCopyEntry[];
26
+ }
27
+ export interface PluginBackendBuildOverrides {
28
+ readonly entry?: string;
29
+ readonly alwaysBundle?: readonly (string | RegExp)[];
30
+ readonly neverBundle?: readonly (string | RegExp)[];
31
+ readonly inputOptions?: Readonly<Record<string, unknown>>;
32
+ readonly copy?: readonly PluginBuildCopyEntry[];
33
+ }
34
+ export interface PluginUiBuildOverrides {
35
+ readonly entry?: string;
36
+ readonly plugins?: readonly unknown[];
37
+ readonly copy?: readonly PluginBuildCopyEntry[];
38
+ }
39
+ export interface DefinePluginBuildOptions {
40
+ /** Page <title> emitted into dist/ui/index.html. Omit only for backend-only plugins (ui: false). */
41
+ readonly title?: string;
42
+ /** Copies shared Vditor / markdown editor static assets into dist/ui. */
43
+ readonly markdownEditorAssets?: boolean;
44
+ readonly backend?: PluginBackendBuildOverrides;
45
+ /** Pass false for backend-only plugins without a browser view. */
46
+ readonly ui?: false | PluginUiBuildOverrides;
47
+ /** Additional standalone build targets (for example a stdio bridge helper). */
48
+ readonly extraEntries?: readonly PluginBuildEntryConfig[];
49
+ }
50
+ /** Creates the canonical tsdown config array for a Workbase plugin package. */
51
+ export declare function definePluginBuild(options: DefinePluginBuildOptions): PluginBuildEntryConfig[];
52
+ /** Renders the canonical Workbase plugin iframe HTML document with CSP style nonce placeholder. */
53
+ export declare function renderPluginHtml(title: string): string;
54
+ //#endregion
package/dist/build.js ADDED
@@ -0,0 +1,78 @@
1
+ import { fileURLToPath } from "node:url";
2
+ //#region src/build.ts
3
+ /**
4
+ * Shared tsdown build factory for Workbase plugins.
5
+ * Generates the Node backend bundle, browser React bundle and canonical dist/ui/index.html.
6
+ */
7
+ const DEFAULT_SDK_EXTERNAL = /^@eworkbase\/sdk(?:\/.*)?$/;
8
+ /** Creates the canonical tsdown config array for a Workbase plugin package. */
9
+ function definePluginBuild(options) {
10
+ const { backend = {}, extraEntries = [], markdownEditorAssets = false, title = "Workbase Plugin", ui } = options;
11
+ const entries = [{
12
+ entry: { plugin: backend.entry ?? "src/plugin.ts" },
13
+ platform: "node",
14
+ target: "node22",
15
+ minify: true,
16
+ shims: true,
17
+ dts: false,
18
+ ...backend.inputOptions ? { inputOptions: backend.inputOptions } : {},
19
+ deps: {
20
+ alwaysBundle: backend.alwaysBundle ?? [/.*/],
21
+ neverBundle: [DEFAULT_SDK_EXTERNAL, ...backend.neverBundle ?? []]
22
+ },
23
+ ...backend.copy?.length ? { copy: backend.copy } : {}
24
+ }, ...extraEntries];
25
+ if (ui === false) return entries;
26
+ const uiCopy = [...ui?.copy ?? []];
27
+ if (markdownEditorAssets) uiCopy.push({
28
+ from: fileURLToPath(new URL("./ui/markdown-editor-assets", import.meta.url)),
29
+ to: "dist/ui"
30
+ });
31
+ entries.push({
32
+ entry: { main: ui?.entry ?? "src/ui/main.tsx" },
33
+ outDir: "dist/ui",
34
+ platform: "browser",
35
+ target: "es2022",
36
+ minify: true,
37
+ dts: false,
38
+ env: { NODE_ENV: "production" },
39
+ deps: { alwaysBundle: [/.*/] },
40
+ plugins: [emitPluginHtml(title), ...ui?.plugins ?? []],
41
+ ...uiCopy.length ? { copy: uiCopy } : {}
42
+ });
43
+ return entries;
44
+ }
45
+ /** Renders the canonical Workbase plugin iframe HTML document with CSP style nonce placeholder. */
46
+ function renderPluginHtml(title) {
47
+ return [
48
+ "<!doctype html>",
49
+ "<html lang=\"zh-CN\">",
50
+ " <head>",
51
+ " <meta name=\"workbase-style-nonce\" content=\"__WORKBASE_STYLE_NONCE__\" />",
52
+ " <meta charset=\"UTF-8\" />",
53
+ " <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />",
54
+ " <link rel=\"stylesheet\" href=\"./style.css\" />",
55
+ ` <title>${title.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;")}</title>`,
56
+ " </head>",
57
+ " <body>",
58
+ " <div id=\"root\"></div>",
59
+ " <script type=\"module\" src=\"./main.js\"><\/script>",
60
+ " </body>",
61
+ "</html>",
62
+ ""
63
+ ].join("\n");
64
+ }
65
+ function emitPluginHtml(title) {
66
+ return {
67
+ name: "workbase-plugin-html",
68
+ generateBundle() {
69
+ this.emitFile({
70
+ type: "asset",
71
+ fileName: "index.html",
72
+ source: renderPluginHtml(title)
73
+ });
74
+ }
75
+ };
76
+ }
77
+ //#endregion
78
+ export { definePluginBuild, renderPluginHtml };
@@ -0,0 +1,171 @@
1
+ import { PluginErrorPanel } from "./ui/error-panel.js";
2
+ import { Component, memo } from "react";
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
+ //#region src/ui/Components.dto.ts
5
+ let PluginStatusTone = /* @__PURE__ */ function(PluginStatusTone) {
6
+ PluginStatusTone["Success"] = "success";
7
+ PluginStatusTone["Warning"] = "warning";
8
+ PluginStatusTone["Danger"] = "danger";
9
+ PluginStatusTone["Info"] = "info";
10
+ PluginStatusTone["Neutral"] = "neutral";
11
+ return PluginStatusTone;
12
+ }({});
13
+ //#endregion
14
+ //#region src/ui/components.tsx
15
+ /**
16
+ * Shared React primitives for Workbase plugins (status pill, inline error, empty state, error boundary).
17
+ * Implemented with semantic HTML and SDK CSS tokens to stay zero-dependency beyond React.
18
+ */
19
+ const DEFAULT_ERROR_BOUNDARY_TITLE = "界面渲染异常";
20
+ const DEFAULT_ERROR_BOUNDARY_SCOPE = "当前插件视图。";
21
+ const DEFAULT_ERROR_BOUNDARY_RECOVERY = "可重试渲染当前视图;若反复出现,请刷新工作区或查看执行日志。";
22
+ const DEFAULT_RETRY_LABEL = "重试渲染";
23
+ const DEFAULT_DISMISS_LABEL = "关闭错误提示";
24
+ const PluginStatusPill = memo(function PluginStatusPill({ tone, label, isLoading = false, className, ...attributes }) {
25
+ return /* @__PURE__ */ jsxs("span", {
26
+ ...attributes,
27
+ "data-tone": tone,
28
+ "data-loading": isLoading || void 0,
29
+ className: joinClassNames("workbase-pill", className),
30
+ children: [isLoading ? /* @__PURE__ */ jsx("span", {
31
+ "aria-hidden": "true",
32
+ className: "workbase-pill-spinner"
33
+ }) : /* @__PURE__ */ jsx("span", {
34
+ "aria-hidden": "true",
35
+ className: "workbase-pill-dot"
36
+ }), /* @__PURE__ */ jsx("span", { children: label })]
37
+ });
38
+ });
39
+ const PluginInlineError = memo(function PluginInlineError({ message, actionLabel, onAction, isActionDisabled = false, onDismiss, dismissLabel = DEFAULT_DISMISS_LABEL, className, ...attributes }) {
40
+ return /* @__PURE__ */ jsxs("div", {
41
+ role: "alert",
42
+ ...attributes,
43
+ className: joinClassNames("workbase-inline-error", className),
44
+ children: [
45
+ /* @__PURE__ */ jsx("span", { children: message }),
46
+ actionLabel && onAction ? /* @__PURE__ */ jsx("button", {
47
+ type: "button",
48
+ disabled: isActionDisabled,
49
+ onClick: onAction,
50
+ children: actionLabel
51
+ }) : null,
52
+ onDismiss ? /* @__PURE__ */ jsx("button", {
53
+ type: "button",
54
+ className: "workbase-error-close",
55
+ "aria-label": dismissLabel,
56
+ title: dismissLabel,
57
+ onClick: onDismiss
58
+ }) : null
59
+ ]
60
+ });
61
+ });
62
+ const PluginEmptyState = memo(function PluginEmptyState({ title, description, icon, action, className, ...attributes }) {
63
+ return /* @__PURE__ */ jsxs("section", {
64
+ ...attributes,
65
+ className: joinClassNames("workbase-empty-state", className),
66
+ children: [
67
+ icon ? /* @__PURE__ */ jsx("span", {
68
+ "aria-hidden": "true",
69
+ className: "workbase-empty-icon",
70
+ children: icon
71
+ }) : null,
72
+ /* @__PURE__ */ jsx("h2", {
73
+ className: "workbase-empty-title",
74
+ children: title
75
+ }),
76
+ description ? /* @__PURE__ */ jsx("p", {
77
+ className: "workbase-empty-description",
78
+ children: description
79
+ }) : null,
80
+ action ? /* @__PURE__ */ jsx("div", {
81
+ className: "workbase-empty-action",
82
+ children: action
83
+ }) : null
84
+ ]
85
+ });
86
+ });
87
+ const PluginPublicationButton = memo(function PluginPublicationButton({ label, count, isLoading = false, icon, disabled, className, type = "button", ...attributes }) {
88
+ return /* @__PURE__ */ jsxs("button", {
89
+ ...attributes,
90
+ type,
91
+ disabled: disabled || isLoading,
92
+ "aria-busy": isLoading || void 0,
93
+ "data-pending-count": count,
94
+ className: joinClassNames("workbase-publish-button", className),
95
+ children: [
96
+ isLoading ? /* @__PURE__ */ jsx("span", {
97
+ "aria-hidden": "true",
98
+ className: "workbase-pill-spinner"
99
+ }) : /* @__PURE__ */ jsx("span", {
100
+ "aria-hidden": "true",
101
+ className: "workbase-publish-icon",
102
+ children: icon ?? /* @__PURE__ */ jsxs("svg", {
103
+ viewBox: "0 0 24 24",
104
+ fill: "none",
105
+ stroke: "currentColor",
106
+ strokeWidth: "2",
107
+ strokeLinecap: "round",
108
+ strokeLinejoin: "round",
109
+ children: [
110
+ /* @__PURE__ */ jsx("path", { d: "M12 16V4" }),
111
+ /* @__PURE__ */ jsx("path", { d: "m7 9 5-5 5 5" }),
112
+ /* @__PURE__ */ jsx("path", { d: "M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2" })
113
+ ]
114
+ })
115
+ }),
116
+ /* @__PURE__ */ jsx("span", {
117
+ className: "workbase-publish-label",
118
+ children: label
119
+ }),
120
+ count > 0 ? /* @__PURE__ */ jsx("span", {
121
+ className: "workbase-publish-count",
122
+ children: count
123
+ }) : null
124
+ ]
125
+ });
126
+ });
127
+ var PluginErrorBoundary = class extends Component {
128
+ state = {
129
+ error: null,
130
+ componentStack: null
131
+ };
132
+ static getDerivedStateFromError(error) {
133
+ return { error: error instanceof Error ? error : new Error(String(error ?? "未知渲染异常")) };
134
+ }
135
+ componentDidCatch(_error, info) {
136
+ this.setState({ componentStack: info.componentStack?.trim() || null });
137
+ }
138
+ handleReset = () => {
139
+ this.setState({
140
+ error: null,
141
+ componentStack: null
142
+ });
143
+ this.props.onReset?.();
144
+ };
145
+ render() {
146
+ const { error, componentStack } = this.state;
147
+ if (!error) return this.props.children;
148
+ const details = [error.stack || error.message, componentStack].filter(Boolean).join("\n\n");
149
+ return /* @__PURE__ */ jsx("div", {
150
+ className: "workbase-feedback-page workbase-error-boundary",
151
+ children: /* @__PURE__ */ jsx(PluginErrorPanel, {
152
+ title: this.props.title ?? DEFAULT_ERROR_BOUNDARY_TITLE,
153
+ error: error.message,
154
+ scope: this.props.scope ?? DEFAULT_ERROR_BOUNDARY_SCOPE,
155
+ recovery: this.props.recovery ?? DEFAULT_ERROR_BOUNDARY_RECOVERY,
156
+ technicalDetails: details,
157
+ children: /* @__PURE__ */ jsx("button", {
158
+ type: "button",
159
+ className: "workbase-error-retry",
160
+ onClick: this.handleReset,
161
+ children: this.props.retryLabel ?? DEFAULT_RETRY_LABEL
162
+ })
163
+ })
164
+ });
165
+ }
166
+ };
167
+ function joinClassNames(...values) {
168
+ return values.filter(Boolean).join(" ");
169
+ }
170
+ //#endregion
171
+ export { PluginStatusPill as a, PluginPublicationButton as i, PluginErrorBoundary as n, PluginStatusTone as o, PluginInlineError as r, PluginEmptyState as t };
@@ -0,0 +1,5 @@
1
+ //#region src/host-services.ts
2
+ const DEFAULT_VIEW_STATE_TOPIC = "default";
3
+ const MAXIMUM_VIEW_STATE_BYTES = 1048576;
4
+ //#endregion
5
+ export { MAXIMUM_VIEW_STATE_BYTES as n, DEFAULT_VIEW_STATE_TOPIC as t };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
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";
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 WorkbasePluginDefinition, A as PluginLifecycleStatus, At as PluginToastApi, B as PluginRepository, Bt as roleToolEnvironmentSchema, C as PluginHookId, Ct as PluginPublicationChanges, D as PluginLifecycleHook, Dt as PluginTaskDescriptor, E as PluginLifecycleDispatchResult, Et as PluginSystemContextService, F as PluginProcessApi, Ft as PluginViewStateService, G as PluginStatusContribution, H as PluginSetupHooks, Ht as roleToolsProposalSchema, I as PluginProcessOutputMode, It as PluginToolsService, J as PluginViewContribution, K as PluginStatusDefinition, L as PluginProcessResult, Lt as RoleToolEnvironment, M as PluginOverviewCardData, Mt as PluginToastOptions, N as PluginOverviewCardDefinition, Nt as PluginViewCatalogEntry, O as PluginLifecycleOutcome, Ot as PluginTaskResult, P as PluginOverviewCardStatus, Pt as PluginViewStatePublishOptions, Q as PluginWorkspace, R as PluginProcessRunOptions, Rt as RoleToolsApplied, S as PluginFileChange, St as PluginPromptViewRequest, T as PluginInvocationContext, Tt as PluginStoreApi, U as PluginSharedChangeKind, V as PluginRepositoryStatus, Vt as roleToolsAppliedSchema, W as PluginSharedChanges, X as PluginViewLayout, Y as PluginViewDefinition, Z as PluginViewMethod, _ as PluginContributionSnapshot, _t as PluginProjectWorkspaceSummary, a as PluginCapabilityReference, at as PluginCapabilityCommandRequest, b as PluginExecutionSnapshot, bt as PluginPromptQuestion, c as PluginCommandContribution, ct as PluginCommandCatalogEntry, d as PluginCommandEffect, dt as PluginHostServices, et as DEFAULT_VIEW_STATE_TOPIC, f as PluginCommandExecutionResult, ft as PluginInteractiveLogger, g as PluginContextExposure, gt as PluginLogService, h as PluginContext, ht as PluginLogQueryResult, i as PluginCapabilityKind, it as PluginCapabilityCatalog, j as PluginLogger, jt as PluginToastLevel, k as PluginLifecyclePolicy, kt as PluginTaskService, l as PluginCommandDefinition, lt as PluginConfigApi, m as PluginCommandTransaction, mt as PluginLogQueryRequest, n as PluginAgentContextDefinition, nt as PluginAgentContextCatalogEntry, o as PluginCardAction, ot as PluginCapabilityResolveRequest, p as PluginCommandLogPolicy, pt as PluginLogEntry, q as PluginToolContribution, r as PluginAgentScope, rt as PluginAgentPolicy, s as PluginCommandContext, st as PluginCapabilityService, t as PluginAgentContextContribution, tt as MAXIMUM_VIEW_STATE_BYTES, u as PluginCommandDetails, ut as PluginExecutionService, v as PluginDisposable, vt as PluginPromptApi, w as PluginHookResult, wt as PluginStatusCatalogEntry, x as PluginExecutionStatus, xt as PluginPromptType, y as PluginExecutionEvidence, yt as PluginPromptChoice, z as PluginProject, zt as RoleToolsProposal } from "./types-D1Ezgwbv.js";
3
3
  import { ZodError, ZodType, z } from "zod";
4
4
  //#region src/error.d.ts
5
5
  /**
@@ -25,4 +25,4 @@ type DefinedWorkbasePlugin = Readonly<WorkbasePluginDefinition>;
25
25
  export declare function definePlugin(definition: WorkbasePluginDefinition): DefinedWorkbasePlugin;
26
26
  export declare function isDefinedPlugin(value: unknown): value is DefinedWorkbasePlugin;
27
27
  //#endregion
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 };
28
+ export { DEFAULT_VIEW_STATE_TOPIC, type DefinedWorkbasePlugin, type ExecutionLogEntry, ExecutionLogEntryKind, type ExecutionLogRecord, MAXIMUM_VIEW_STATE_BYTES, 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 PluginProjectWorkspaceSummary, 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 PluginViewStatePublishOptions, type PluginViewStateService, type PluginWorkspace, RoleToolEnvironment, RoleToolsApplied, RoleToolsProposal, type WorkbasePluginDefinition, ZodError, type ZodType, executionLogEntrySchema, executionLogRecordSchema, roleToolEnvironmentSchema, roleToolsAppliedSchema, roleToolsProposalSchema, z };
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { n as MAXIMUM_VIEW_STATE_BYTES, t as DEFAULT_VIEW_STATE_TOPIC } from "./host-services-cIH3aYQD.js";
1
2
  import { ZodError, z, z as z$1 } from "zod";
2
3
  //#region src/error.ts
3
4
  var PluginError = class extends Error {
@@ -303,4 +304,4 @@ const executionLogRecordSchema = z$1.object({
303
304
  context: executionContextSchema.optional()
304
305
  });
305
306
  //#endregion
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 };
307
+ export { DEFAULT_VIEW_STATE_TOPIC, ExecutionLogEntryKind, MAXIMUM_VIEW_STATE_BYTES, 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 { T as PluginInvocationContext } from "./types-WIMkhmH4.js";
1
+ import { T as PluginInvocationContext } from "./types-D1Ezgwbv.js";
2
2
  //#region src/Markdown.dto.d.ts
3
3
  interface MarkdownDocument {
4
4
  readonly path: string;
@@ -1,4 +1,4 @@
1
- import { Ot as PluginToastLevel, b as PluginExecutionSnapshot, f as PluginCommandExecutionResult } from "./types-WIMkhmH4.js";
1
+ import { b as PluginExecutionSnapshot, f as PluginCommandExecutionResult, jt as PluginToastLevel } from "./types-D1Ezgwbv.js";
2
2
  //#region src/ui/types.d.ts
3
3
  type PluginUiPromptType = 'confirm' | 'multi-select' | 'select' | 'text';
4
4
  type PluginUiFileSelectionScope = 'project' | 'workspace';
@@ -10,7 +10,14 @@ interface PluginUiViewIdentity extends PluginUiContextIdentity {
10
10
  readonly pluginId: string;
11
11
  readonly title: string;
12
12
  }
13
+ interface PluginUiActivationState {
14
+ readonly status: 'loading' | 'blocked' | 'failed' | 'ready';
15
+ readonly error: string | null;
16
+ readonly blockedByPluginId?: string | null;
17
+ }
13
18
  interface PluginUiInitializationPayload {
19
+ /** Current host activation state of this plugin; updated in place without recreating the view. */
20
+ readonly activation?: PluginUiActivationState;
14
21
  /** Accepted configuration for a view that refreshes in place. */
15
22
  readonly configurationRevision?: string;
16
23
  /** Changes when the workspace is prepared again; route changes retain the same generation. */
@@ -101,11 +108,22 @@ interface PluginUiCommands {
101
108
  interface PluginUiStatus {
102
109
  readonly resolve: <Result = unknown>(statusId: string, input: unknown) => Promise<Result>;
103
110
  }
111
+ /** A single authoritative state snapshot pushed by the plugin backend. */
112
+ interface PluginUiStateChange<State = unknown> {
113
+ readonly topic: string;
114
+ readonly state: State;
115
+ }
104
116
  interface PluginUiView {
105
117
  /** Report in-memory edits to the navigation for this view instance. */
106
118
  readonly setModified: (modified: boolean) => Promise<void>;
119
+ /** Declare whether this view currently renders its own recovery surface for the host activation error. */
120
+ readonly setActivationErrorHandled?: (handled: boolean) => Promise<void>;
121
+ /** Subscribe to live host activation state changes for this plugin without recreating the view. */
122
+ readonly onActivationChanged?: (listener: (activation: PluginUiActivationState) => void) => () => void;
107
123
  /** Refresh retained data when this plugin's declared files change. */
108
124
  readonly onFilesChanged: (refresh: () => void | Promise<unknown>) => () => void;
125
+ /** Subscribe to backend-pushed state snapshots for a topic (defaults to "default"). */
126
+ readonly onStateChanged: <State = unknown>(listener: (state: State) => void, topic?: string) => () => void;
109
127
  readonly call: <Result = unknown>(method: string, input: unknown) => Promise<Result>;
110
128
  }
111
129
  declare enum PluginDesktopTarget {
@@ -180,8 +198,10 @@ interface PluginUiHostMethods {
180
198
  readonly reportFatal: (message: string) => Promise<void>;
181
199
  }
182
200
  interface PluginUiClientMethods {
201
+ readonly activationChanged?: (activation: PluginUiActivationState) => Promise<void>;
183
202
  readonly filesChanged: () => Promise<void>;
184
203
  readonly executionChanged: (change: PluginUiExecutionChange) => Promise<void>;
204
+ readonly stateChanged: (change: PluginUiStateChange) => Promise<void>;
185
205
  readonly initialize: (payload: unknown) => Promise<void>;
186
206
  }
187
207
  interface PluginUiTransportConnection {
@@ -193,4 +213,4 @@ interface PluginUiControllerOptions {
193
213
  readonly targetWindow: Window & typeof globalThis;
194
214
  }
195
215
  //#endregion
196
- export { PluginUiViewIdentity as A, PluginUiRepositoryPushOutcome as C, PluginUiToastOptions as D, PluginUiStatus as E, WorkbasePluginUiDefinition as M, PluginUiTransportConnection as O, PluginUiPromptType as S, PluginUiRepositoryPushTarget as T, PluginUiNavigateOptions as _, PluginUiContextIdentity as a, PluginUiPromptChoice as b, PluginUiDesktopOpenResult as c, PluginUiFileSelectOptions as d, PluginUiFileSelectionItemType as f, PluginUiInitializationPayload as g, PluginUiHostMethods as h, PluginUiCommands as i, WorkbasePluginUi as j, PluginUiView as k, PluginUiExecutionChange as l, PluginUiHostError as m, PluginUiClientMethods as n, PluginUiControllerOptions as o, PluginUiFileSelectionScope as p, PluginUiCommandExecuteOptions as r, PluginUiDesktopOpenOptions as s, PluginDesktopTarget as t, PluginUiFileFilter as u, PluginUiOpenViewOptions as v, PluginUiRepositoryPushResult as w, PluginUiPromptOptions as x, PluginUiOutputOptions as y };
216
+ export { PluginUiTransportConnection as A, PluginUiPromptType as C, PluginUiStateChange as D, PluginUiRepositoryPushTarget as E, PluginUiViewIdentity as M, WorkbasePluginUi as N, PluginUiStatus as O, WorkbasePluginUiDefinition as P, PluginUiPromptOptions as S, PluginUiRepositoryPushResult as T, PluginUiInitializationPayload as _, PluginUiCommands as a, PluginUiOutputOptions as b, PluginUiDesktopOpenOptions as c, PluginUiFileFilter as d, PluginUiFileSelectOptions as f, PluginUiHostMethods as g, PluginUiHostError as h, PluginUiCommandExecuteOptions as i, PluginUiView as j, PluginUiToastOptions as k, PluginUiDesktopOpenResult as l, PluginUiFileSelectionScope as m, PluginUiActivationState as n, PluginUiContextIdentity as o, PluginUiFileSelectionItemType as p, PluginUiClientMethods as r, PluginUiControllerOptions as s, PluginDesktopTarget as t, PluginUiExecutionChange as u, PluginUiNavigateOptions as v, PluginUiRepositoryPushOutcome as w, PluginUiPromptChoice as x, PluginUiOpenViewOptions as y };
@@ -1,4 +1,4 @@
1
- import { r as ExecutionLogRecord, t as ExecutionLogEntry } from "./ExecutionLog.dto-Bq2u5C90.js";
1
+ import { r as ExecutionLogRecord, t as ExecutionLogEntry } from "./ExecutionLog.dto-ig9GUWhK.js";
2
2
  import { ZodType, z } from "zod";
3
3
  //#region src/Tools.dto.d.ts
4
4
  declare const roleToolEnvironmentSchema: z.ZodObject<{
@@ -247,6 +247,11 @@ interface PluginPublicationChanges {
247
247
  readonly working: readonly string[];
248
248
  readonly partiallyStaged: boolean;
249
249
  }
250
+ interface PluginProjectWorkspaceSummary {
251
+ readonly id: string;
252
+ readonly title: string;
253
+ readonly status: "active" | "paused" | "archived";
254
+ }
250
255
  interface PluginLogQueryRequest {
251
256
  readonly cursor?: string;
252
257
  readonly limit?: number;
@@ -298,6 +303,15 @@ interface PluginExecutionService {
298
303
  readonly input: unknown;
299
304
  }) => Promise<unknown>;
300
305
  }
306
+ declare const DEFAULT_VIEW_STATE_TOPIC = "default";
307
+ declare const MAXIMUM_VIEW_STATE_BYTES: number;
308
+ interface PluginViewStatePublishOptions {
309
+ readonly topic?: string;
310
+ }
311
+ interface PluginViewStateService {
312
+ /** Pushes a bounded, JSON-serializable state snapshot to active views of this plugin. */
313
+ readonly publishState: (state: unknown, options?: PluginViewStatePublishOptions) => void;
314
+ }
301
315
  interface PluginHostServices {
302
316
  readonly executions: PluginExecutionService;
303
317
  readonly capabilities: PluginCapabilityService;
@@ -310,6 +324,7 @@ interface PluginHostServices {
310
324
  readonly toast: PluginToastApi;
311
325
  readonly tasks: PluginTaskService;
312
326
  readonly tools: PluginToolsService;
327
+ readonly views?: PluginViewStateService;
313
328
  readonly workspace: {
314
329
  /** Observe plugin-owned inputs during activation. The optional plugin command runs through the host transaction before notifying views. */
315
330
  readonly watchFiles?: (targets: readonly {
@@ -322,8 +337,12 @@ interface PluginHostServices {
322
337
  readonly notifyRepositoryChanged: (repositoryId: string) => Promise<void>;
323
338
  /** Reads unpublished changes in a plugin-owned directory relative to the host's publication baseline. */
324
339
  readonly readPublicationChanges: (directory: string) => Promise<PluginPublicationChanges>;
340
+ /** Lists all defined workspaces in the current project (read-only). */
341
+ readonly listProjectWorkspaces?: () => Promise<readonly PluginProjectWorkspaceSummary[]>;
325
342
  /** Checks committed code against the configured collaboration branches without closing the workspace. */
326
343
  readonly verifySynchronized: () => Promise<void>;
344
+ /** Queues an asynchronous activation retry for this plugin when its host activation is currently failed or blocked. */
345
+ readonly requestActivationRetry?: () => Promise<void>;
327
346
  };
328
347
  }
329
348
  //#endregion
@@ -627,6 +646,7 @@ interface PluginToolContribution {
627
646
  readonly version?: string;
628
647
  }
629
648
  interface PluginLifecycleOutcome {
649
+ readonly artifactPaths?: readonly string[];
630
650
  readonly fileChanges?: readonly PluginFileChange[];
631
651
  readonly code: string | null;
632
652
  readonly details: unknown | null;
@@ -641,6 +661,8 @@ interface PluginLifecycleOutcome {
641
661
  readonly warnings: readonly string[];
642
662
  }
643
663
  interface PluginHookResult {
664
+ /** WorkspaceFinalize only: finite artifact files relative to project.workbaseRoot, outside configuration. */
665
+ readonly artifactPaths?: readonly string[];
644
666
  /** WorkspaceProvision only: proposed project files, applied by the host after preparation. */
645
667
  readonly fileChanges?: readonly PluginFileChange[];
646
668
  readonly standardError?: string;
@@ -720,4 +742,4 @@ interface PluginContributionSnapshot {
720
742
  readonly views: readonly PluginViewContribution[];
721
743
  }
722
744
  //#endregion
723
- export { WorkbasePluginDefinition as $, PluginLifecycleStatus as A, PluginViewCatalogEntry as At, PluginRepository as B, PluginHookId as C, PluginSystemContextService as Ct, PluginLifecycleHook as D, PluginToastApi as Dt, PluginLifecycleDispatchResult as E, PluginTaskService as Et, PluginProcessApi as F, roleToolEnvironmentSchema as Ft, PluginStatusContribution as G, PluginSetupHooks as H, PluginProcessOutputMode as I, roleToolsAppliedSchema as It, PluginViewContribution as J, PluginStatusDefinition as K, PluginProcessResult as L, roleToolsProposalSchema as Lt, PluginOverviewCardData as M, RoleToolEnvironment as Mt, PluginOverviewCardDefinition as N, RoleToolsApplied as Nt, PluginLifecycleOutcome as O, PluginToastLevel as Ot, PluginOverviewCardStatus as P, RoleToolsProposal as Pt, PluginWorkspace as Q, PluginProcessRunOptions as R, PluginFileChange as S, PluginStoreApi as St, PluginInvocationContext as T, PluginTaskResult as Tt, PluginSharedChangeKind as U, PluginRepositoryStatus as V, PluginSharedChanges as W, PluginViewLayout as X, PluginViewDefinition as Y, PluginViewMethod as Z, PluginContributionSnapshot as _, PluginPromptQuestion as _t, PluginCapabilityReference as a, PluginCapabilityService as at, PluginExecutionSnapshot as b, PluginPublicationChanges as bt, PluginCommandContribution as c, PluginExecutionService as ct, PluginCommandEffect as d, PluginLogEntry as dt, PluginAgentContextCatalogEntry as et, PluginCommandExecutionResult as f, PluginLogQueryRequest as ft, PluginContextExposure as g, PluginPromptChoice as gt, PluginContext as h, PluginPromptApi as ht, PluginCapabilityKind as i, PluginCapabilityResolveRequest as it, PluginLogger as j, PluginToolsService as jt, PluginLifecyclePolicy as k, PluginToastOptions as kt, PluginCommandDefinition as l, PluginHostServices as lt, PluginCommandTransaction as m, PluginLogService as mt, PluginAgentContextDefinition as n, PluginCapabilityCatalog as nt, PluginCardAction as o, PluginCommandCatalogEntry as ot, PluginCommandLogPolicy as p, PluginLogQueryResult as pt, PluginToolContribution as q, PluginAgentScope as r, PluginCapabilityCommandRequest as rt, PluginCommandContext as s, PluginConfigApi as st, PluginAgentContextContribution as t, PluginAgentPolicy as tt, PluginCommandDetails as u, PluginInteractiveLogger as ut, PluginDisposable as v, PluginPromptType as vt, PluginHookResult as w, PluginTaskDescriptor as wt, PluginExecutionStatus as x, PluginStatusCatalogEntry as xt, PluginExecutionEvidence as y, PluginPromptViewRequest as yt, PluginProject as z };
745
+ export { WorkbasePluginDefinition as $, PluginLifecycleStatus as A, PluginToastApi as At, PluginRepository as B, roleToolEnvironmentSchema as Bt, PluginHookId as C, PluginPublicationChanges as Ct, PluginLifecycleHook as D, PluginTaskDescriptor as Dt, PluginLifecycleDispatchResult as E, PluginSystemContextService as Et, PluginProcessApi as F, PluginViewStateService as Ft, PluginStatusContribution as G, PluginSetupHooks as H, roleToolsProposalSchema as Ht, PluginProcessOutputMode as I, PluginToolsService as It, PluginViewContribution as J, PluginStatusDefinition as K, PluginProcessResult as L, RoleToolEnvironment as Lt, PluginOverviewCardData as M, PluginToastOptions as Mt, PluginOverviewCardDefinition as N, PluginViewCatalogEntry as Nt, PluginLifecycleOutcome as O, PluginTaskResult as Ot, PluginOverviewCardStatus as P, PluginViewStatePublishOptions as Pt, PluginWorkspace as Q, PluginProcessRunOptions as R, RoleToolsApplied as Rt, PluginFileChange as S, PluginPromptViewRequest as St, PluginInvocationContext as T, PluginStoreApi as Tt, PluginSharedChangeKind as U, PluginRepositoryStatus as V, roleToolsAppliedSchema as Vt, PluginSharedChanges as W, PluginViewLayout as X, PluginViewDefinition as Y, PluginViewMethod as Z, PluginContributionSnapshot as _, PluginProjectWorkspaceSummary as _t, PluginCapabilityReference as a, PluginCapabilityCommandRequest as at, PluginExecutionSnapshot as b, PluginPromptQuestion as bt, PluginCommandContribution as c, PluginCommandCatalogEntry as ct, PluginCommandEffect as d, PluginHostServices as dt, DEFAULT_VIEW_STATE_TOPIC as et, PluginCommandExecutionResult as f, PluginInteractiveLogger as ft, PluginContextExposure as g, PluginLogService as gt, PluginContext as h, PluginLogQueryResult as ht, PluginCapabilityKind as i, PluginCapabilityCatalog as it, PluginLogger as j, PluginToastLevel as jt, PluginLifecyclePolicy as k, PluginTaskService as kt, PluginCommandDefinition as l, PluginConfigApi as lt, PluginCommandTransaction as m, PluginLogQueryRequest as mt, PluginAgentContextDefinition as n, PluginAgentContextCatalogEntry as nt, PluginCardAction as o, PluginCapabilityResolveRequest as ot, PluginCommandLogPolicy as p, PluginLogEntry as pt, PluginToolContribution as q, PluginAgentScope as r, PluginAgentPolicy as rt, PluginCommandContext as s, PluginCapabilityService as st, PluginAgentContextContribution as t, MAXIMUM_VIEW_STATE_BYTES as tt, PluginCommandDetails as u, PluginExecutionService as ut, PluginDisposable as v, PluginPromptApi as vt, PluginHookResult as w, PluginStatusCatalogEntry as wt, PluginExecutionStatus as x, PluginPromptType as xt, PluginExecutionEvidence as y, PluginPromptChoice as yt, PluginProject as z, RoleToolsProposal as zt };
@@ -1,4 +1,4 @@
1
- import { Component, ErrorInfo, HTMLAttributes, ReactNode } from "react";
1
+ import { ButtonHTMLAttributes, Component, ErrorInfo, HTMLAttributes, ReactNode } from "react";
2
2
  //#region src/ui/Components.dto.d.ts
3
3
  export declare enum PluginStatusTone {
4
4
  Success = "success",
@@ -35,11 +35,18 @@ interface PluginErrorBoundaryProps {
35
35
  readonly retryLabel?: string;
36
36
  readonly onReset?: () => void;
37
37
  }
38
+ interface PluginPublicationButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
39
+ readonly label: string;
40
+ readonly count: number;
41
+ readonly isLoading?: boolean;
42
+ readonly icon?: ReactNode;
43
+ }
38
44
  //#endregion
39
45
  //#region src/ui/components.d.ts
40
46
  export declare const PluginStatusPill: import("react").NamedExoticComponent<PluginStatusPillProps>;
41
47
  export declare const PluginInlineError: import("react").NamedExoticComponent<PluginInlineErrorProps>;
42
48
  export declare const PluginEmptyState: import("react").NamedExoticComponent<PluginEmptyStateProps>;
49
+ export declare const PluginPublicationButton: import("react").NamedExoticComponent<PluginPublicationButtonProps>;
43
50
  interface PluginErrorBoundaryState {
44
51
  readonly error: Error | null;
45
52
  readonly componentStack: string | null;
@@ -52,4 +59,4 @@ export declare class PluginErrorBoundary extends Component<PluginErrorBoundaryPr
52
59
  render(): ReactNode;
53
60
  }
54
61
  //#endregion
55
- export type { PluginEmptyStateProps, PluginErrorBoundaryProps, PluginInlineErrorProps, PluginStatusPillProps, PluginStatusToneValue };
62
+ export type { PluginEmptyStateProps, PluginErrorBoundaryProps, PluginInlineErrorProps, PluginPublicationButtonProps, PluginStatusPillProps, PluginStatusToneValue };