@eworkbase/sdk 0.2.0 → 0.3.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/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as PluginConfigApi, A as PluginProject, B as PluginViewDefinition, C as PluginLifecycleOutcome, D as PluginProcessApi, E as PluginLogger, F as PluginSharedChanges, G as PluginAgentContextCatalogEntry, H as PluginViewRequest, I as PluginStatusContribution, J as PluginCapabilityCommandRequest, K as PluginAgentPolicy, L as PluginStatusDefinition, M as PluginRepositoryStatus, N as PluginSetupHooks, O as PluginProcessResult, P as PluginSharedChangeKind, Q as PluginCommandCatalogEntry, R as PluginToolContribution, S as PluginLifecycleHook, T as PluginLifecycleStatus, U as PluginWorkspace, V as PluginViewLayout, W as WorkbasePluginDefinition, X as PluginCapabilityService, Y as PluginCapabilityResolveRequest, Z as PluginColoredMessage, _ as PluginDisposable, _t as PluginToastLevel, a as PluginCommandContext, at as PluginLogService, b as PluginInvocationContext, c as PluginCommandDetails, ct as PluginPromptQuestion, d as PluginCommandExecutionResult, dt as PluginStoreApi, et as PluginHostServices, f as PluginCommandOption, ft as PluginSystemContextService, g as PluginContributionSnapshot, gt as PluginToastApi, h as PluginContextExposure, ht as PluginTaskService, i as PluginCommandCategory, it as PluginLogQueryResult, j as PluginRepository, k as PluginProcessRunOptions, l as PluginCommandEffect, lt as PluginPromptType, m as PluginContext, mt as PluginTaskResult, n as PluginAgentContextDefinition, nt as PluginLogEntry, o as PluginCommandContribution, ot as PluginPromptApi, p as PluginCommandTransaction, pt as PluginTaskDescriptor, q as PluginCapabilityCatalog, r as PluginCommandArgument, rt as PluginLogQueryRequest, s as PluginCommandDefinition, st as PluginPromptChoice, t as PluginAgentContextContribution, tt as PluginInteractiveLogger, u as PluginCommandExecutionMode, ut as PluginStatusCatalogEntry, v as PluginHookId, vt as PluginToastOptions, w as PluginLifecyclePolicy, x as PluginLifecycleDispatchResult, y as PluginHookResult, yt as PluginViewCatalogEntry, z as PluginViewContribution } from "./types-CYt_KGKR.js";
1
+ import { $ as PluginColoredMessage, A as PluginProcessResult, At as roleToolsProposalSchema, B as PluginToolContribution, C as PluginLifecycleDispatchResult, Ct as PluginViewCatalogEntry, D as PluginLifecycleStatus, Dt as RoleToolsProposal, E as PluginLifecyclePolicy, Et as RoleToolsApplied, F as PluginSetupHooks, G as PluginWorkspace, H as PluginViewDefinition, I as PluginSharedChangeKind, J as PluginAgentPolicy, K as WorkbasePluginDefinition, L as PluginSharedChanges, M as PluginProject, N as PluginRepository, O as PluginLogger, Ot as roleToolEnvironmentSchema, P as PluginRepositoryStatus, Q as PluginCapabilityService, R as PluginStatusContribution, S as PluginInvocationContext, St as PluginToastOptions, T as PluginLifecycleOutcome, Tt as RoleToolEnvironment, U as PluginViewLayout, V as PluginViewContribution, W as PluginViewRequest, X as PluginCapabilityCommandRequest, Y as PluginCapabilityCatalog, Z as PluginCapabilityResolveRequest, _ as PluginDisposable, _t as PluginTaskDescriptor, a as PluginCommandContext, at as PluginLogEntry, b as PluginHookId, bt as PluginToastApi, c as PluginCommandDetails, ct as PluginLogService, d as PluginCommandExecutionResult, dt as PluginPromptQuestion, et as PluginCommandCatalogEntry, f as PluginCommandOption, ft as PluginPromptType, g as PluginContributionSnapshot, gt as PluginSystemContextService, h as PluginContextExposure, ht as PluginStoreApi, i as PluginCommandCategory, it as PluginInteractiveLogger, j as PluginProcessRunOptions, k as PluginProcessApi, kt as roleToolsAppliedSchema, l as PluginCommandEffect, lt as PluginPromptApi, m as PluginContext, mt as PluginStatusCatalogEntry, n as PluginAgentContextDefinition, nt as PluginExecutionService, o as PluginCommandContribution, ot as PluginLogQueryRequest, p as PluginCommandTransaction, pt as PluginPromptViewRequest, q as PluginAgentContextCatalogEntry, r as PluginCommandArgument, rt as PluginHostServices, s as PluginCommandDefinition, st as PluginLogQueryResult, t as PluginAgentContextContribution, tt as PluginConfigApi, u as PluginCommandExecutionMode, ut as PluginPromptChoice, v as PluginExecutionSnapshot, vt as PluginTaskResult, w as PluginLifecycleHook, wt as PluginToolsService, x as PluginHookResult, xt as PluginToastLevel, y as PluginExecutionStatus, yt as PluginTaskService, z as PluginStatusDefinition } from "./types-CoZB_r31.js";
2
2
  export * from "zod";
3
3
  //#region src/definition.d.ts
4
4
  export declare const PLUGIN_API_VERSION = 2;
@@ -6,4 +6,4 @@ type DefinedWorkbasePlugin = Readonly<WorkbasePluginDefinition>;
6
6
  export declare function definePlugin(definition: WorkbasePluginDefinition): DefinedWorkbasePlugin;
7
7
  export declare function isDefinedPlugin(value: unknown): value is DefinedWorkbasePlugin;
8
8
  //#endregion
9
- export { type DefinedWorkbasePlugin, type PluginAgentContextCatalogEntry, type PluginAgentContextContribution, type PluginAgentContextDefinition, type PluginAgentPolicy, type PluginCapabilityCatalog, type PluginCapabilityCommandRequest, 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, 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, type PluginProcessResult, type PluginProcessRunOptions, type PluginProject, type PluginPromptApi, type PluginPromptChoice, type PluginPromptQuestion, type PluginPromptType, 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, type PluginViewCatalogEntry, type PluginViewContribution, type PluginViewDefinition, PluginViewLayout, type PluginViewRequest, type PluginWorkspace, type WorkbasePluginDefinition };
9
+ export { type DefinedWorkbasePlugin, type PluginAgentContextCatalogEntry, type PluginAgentContextContribution, type PluginAgentContextDefinition, type PluginAgentPolicy, type PluginCapabilityCatalog, type PluginCapabilityCommandRequest, 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 PluginExecutionService, type PluginExecutionSnapshot, PluginExecutionStatus, 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, 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 };
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { z } from "zod";
1
2
  export * from "zod";
2
3
  //#region src/definition.ts
3
4
  const PLUGIN_API_VERSION = 2;
@@ -39,6 +40,19 @@ let PluginHookId = /* @__PURE__ */ function(PluginHookId) {
39
40
  PluginHookId["Cleanup"] = "cleanup";
40
41
  return PluginHookId;
41
42
  }({});
43
+ let PluginExecutionStatus = /* @__PURE__ */ function(PluginExecutionStatus) {
44
+ PluginExecutionStatus["Queued"] = "queued";
45
+ PluginExecutionStatus["Starting"] = "starting";
46
+ PluginExecutionStatus["Running"] = "running";
47
+ PluginExecutionStatus["WaitingInput"] = "waitingInput";
48
+ PluginExecutionStatus["WaitingApproval"] = "waitingApproval";
49
+ PluginExecutionStatus["Cancelling"] = "cancelling";
50
+ PluginExecutionStatus["Succeeded"] = "succeeded";
51
+ PluginExecutionStatus["Failed"] = "failed";
52
+ PluginExecutionStatus["Cancelled"] = "cancelled";
53
+ PluginExecutionStatus["Interrupted"] = "interrupted";
54
+ return PluginExecutionStatus;
55
+ }({});
42
56
  let PluginCommandEffect = /* @__PURE__ */ function(PluginCommandEffect) {
43
57
  PluginCommandEffect["Immediate"] = "immediate";
44
58
  PluginCommandEffect["LongRunning"] = "longRunning";
@@ -93,4 +107,86 @@ let PluginContextExposure = /* @__PURE__ */ function(PluginContextExposure) {
93
107
  return PluginContextExposure;
94
108
  }({});
95
109
  //#endregion
96
- export { PLUGIN_API_VERSION, PluginCommandCategory, PluginCommandEffect, PluginCommandExecutionMode, PluginCommandTransaction, PluginContextExposure, PluginHookId, PluginLifecyclePolicy, PluginLifecycleStatus, PluginRepositoryStatus, PluginSharedChangeKind, PluginViewLayout, definePlugin, isDefinedPlugin };
110
+ //#region src/Tools.dto.ts
111
+ /** Typed tool-domain contracts shared by the SDK and host bridge. */
112
+ const identifier = z.string().min(1);
113
+ const toolKind = z.enum([
114
+ "runtime",
115
+ "cli",
116
+ "desktop"
117
+ ]);
118
+ const toolStatus = z.enum([
119
+ "unknown",
120
+ "running",
121
+ "ready",
122
+ "prepared",
123
+ "missing",
124
+ "unsupported-platform",
125
+ "failed",
126
+ "manual-action-required",
127
+ "cancelled",
128
+ "interrupted"
129
+ ]);
130
+ const roleToolEnvironmentSchema = z.object({
131
+ roleId: identifier,
132
+ roleLabel: z.string(),
133
+ revision: identifier,
134
+ assignedToolIds: z.array(identifier),
135
+ tools: z.array(z.object({
136
+ id: identifier,
137
+ label: z.string(),
138
+ kind: toolKind,
139
+ version: z.string().nullable(),
140
+ assigned: z.boolean(),
141
+ shared: z.boolean(),
142
+ assignable: z.boolean()
143
+ })),
144
+ runtimes: z.object({
145
+ projectRoot: z.string(),
146
+ miseVersion: z.string().nullable(),
147
+ status: z.enum([
148
+ "missing",
149
+ "outdated",
150
+ "not-prepared",
151
+ "ready",
152
+ "failed"
153
+ ]),
154
+ detail: z.string(),
155
+ runtimes: z.array(z.object({
156
+ id: identifier,
157
+ label: z.string(),
158
+ runtimeId: identifier,
159
+ version: z.string(),
160
+ installed: z.boolean(),
161
+ terminalApplied: z.boolean()
162
+ }))
163
+ }),
164
+ nativeTools: z.array(z.object({
165
+ id: identifier,
166
+ label: z.string(),
167
+ kind: toolKind,
168
+ currentVersion: z.string().nullable(),
169
+ status: toolStatus,
170
+ detail: z.string(),
171
+ manualActionMessage: z.string().nullable()
172
+ }))
173
+ });
174
+ const roleToolsProposalSchema = z.object({
175
+ id: z.string().uuid(),
176
+ roleId: identifier,
177
+ roleLabel: z.string(),
178
+ revision: identifier,
179
+ toolIds: z.array(identifier),
180
+ before: z.array(identifier),
181
+ after: z.array(identifier),
182
+ labels: z.array(z.string()),
183
+ reason: z.string()
184
+ });
185
+ const roleToolsAppliedSchema = z.object({
186
+ roleId: identifier,
187
+ toolIds: z.array(identifier),
188
+ applied: z.literal(true),
189
+ requiresPreparation: z.boolean()
190
+ });
191
+ //#endregion
192
+ export { PLUGIN_API_VERSION, PluginCommandCategory, PluginCommandEffect, PluginCommandExecutionMode, PluginCommandTransaction, PluginContextExposure, PluginExecutionStatus, PluginHookId, PluginLifecyclePolicy, PluginLifecycleStatus, PluginRepositoryStatus, PluginSharedChangeKind, PluginViewLayout, definePlugin, isDefinedPlugin, roleToolEnvironmentSchema, roleToolsAppliedSchema, roleToolsProposalSchema };
@@ -1,4 +1,103 @@
1
- import { ZodType } from "zod";
1
+ import { ZodType, z } from "zod";
2
+ //#region src/Tools.dto.d.ts
3
+ declare const roleToolEnvironmentSchema: z.ZodObject<{
4
+ roleId: z.ZodString;
5
+ roleLabel: z.ZodString;
6
+ revision: z.ZodString;
7
+ assignedToolIds: z.ZodArray<z.ZodString>;
8
+ tools: z.ZodArray<z.ZodObject<{
9
+ id: z.ZodString;
10
+ label: z.ZodString;
11
+ kind: z.ZodEnum<{
12
+ runtime: "runtime";
13
+ cli: "cli";
14
+ desktop: "desktop";
15
+ }>;
16
+ version: z.ZodNullable<z.ZodString>;
17
+ assigned: z.ZodBoolean;
18
+ shared: z.ZodBoolean;
19
+ assignable: z.ZodBoolean;
20
+ }, z.core.$strip>>;
21
+ runtimes: z.ZodObject<{
22
+ projectRoot: z.ZodString;
23
+ miseVersion: z.ZodNullable<z.ZodString>;
24
+ status: z.ZodEnum<{
25
+ missing: "missing";
26
+ outdated: "outdated";
27
+ "not-prepared": "not-prepared";
28
+ ready: "ready";
29
+ failed: "failed";
30
+ }>;
31
+ detail: z.ZodString;
32
+ runtimes: z.ZodArray<z.ZodObject<{
33
+ id: z.ZodString;
34
+ label: z.ZodString;
35
+ runtimeId: z.ZodString;
36
+ version: z.ZodString;
37
+ installed: z.ZodBoolean;
38
+ terminalApplied: z.ZodBoolean;
39
+ }, z.core.$strip>>;
40
+ }, z.core.$strip>;
41
+ nativeTools: z.ZodArray<z.ZodObject<{
42
+ id: z.ZodString;
43
+ label: z.ZodString;
44
+ kind: z.ZodEnum<{
45
+ runtime: "runtime";
46
+ cli: "cli";
47
+ desktop: "desktop";
48
+ }>;
49
+ currentVersion: z.ZodNullable<z.ZodString>;
50
+ status: z.ZodEnum<{
51
+ unknown: "unknown";
52
+ missing: "missing";
53
+ ready: "ready";
54
+ failed: "failed";
55
+ running: "running";
56
+ prepared: "prepared";
57
+ "unsupported-platform": "unsupported-platform";
58
+ "manual-action-required": "manual-action-required";
59
+ cancelled: "cancelled";
60
+ interrupted: "interrupted";
61
+ }>;
62
+ detail: z.ZodString;
63
+ manualActionMessage: z.ZodNullable<z.ZodString>;
64
+ }, z.core.$strip>>;
65
+ }, z.core.$strip>;
66
+ declare const roleToolsProposalSchema: z.ZodObject<{
67
+ id: z.ZodString;
68
+ roleId: z.ZodString;
69
+ roleLabel: z.ZodString;
70
+ revision: z.ZodString;
71
+ toolIds: z.ZodArray<z.ZodString>;
72
+ before: z.ZodArray<z.ZodString>;
73
+ after: z.ZodArray<z.ZodString>;
74
+ labels: z.ZodArray<z.ZodString>;
75
+ reason: z.ZodString;
76
+ }, z.core.$strip>;
77
+ declare const roleToolsAppliedSchema: z.ZodObject<{
78
+ roleId: z.ZodString;
79
+ toolIds: z.ZodArray<z.ZodString>;
80
+ applied: z.ZodLiteral<true>;
81
+ requiresPreparation: z.ZodBoolean;
82
+ }, z.core.$strip>;
83
+ type RoleToolEnvironment = z.infer<typeof roleToolEnvironmentSchema>;
84
+ type RoleToolsProposal = z.infer<typeof roleToolsProposalSchema>;
85
+ type RoleToolsApplied = z.infer<typeof roleToolsAppliedSchema> | {
86
+ readonly applied: false;
87
+ };
88
+ interface PluginToolsService {
89
+ /** Detects the active role and platform tools without installing anything. */
90
+ readonly inspectEnvironment: () => Promise<RoleToolEnvironment>;
91
+ /** Plans additions to project-declared tools; does not apply shared configuration. */
92
+ readonly proposeRoleTools: (request: {
93
+ readonly toolIds: readonly string[];
94
+ readonly reason: string;
95
+ }) => Promise<RoleToolsProposal>;
96
+ readonly roleToolsProposal: () => Promise<RoleToolsProposal | null>;
97
+ /** Collects explicit confirmation before applying this exact proposal in a foreground project.yaml transaction. */
98
+ readonly applyRoleTools: (proposalId: string) => Promise<RoleToolsApplied>;
99
+ }
100
+ //#endregion
2
101
  //#region src/host-services.d.ts
3
102
  interface PluginColoredMessage {
4
103
  readonly color?: string;
@@ -25,18 +124,31 @@ interface PluginPromptChoice<Value = unknown> {
25
124
  }
26
125
  type PluginPromptType = "input" | "confirm" | "list" | "rawlist" | "search-list" | "search-checkbox" | "fuzzy-path";
27
126
  interface PluginPromptQuestion<Key = string, Value = unknown, Choice = unknown> {
127
+ /** Allows a list answer outside its choices, returned as the entered string. */
128
+ readonly allowCustomInput?: boolean;
28
129
  readonly choices?: readonly PluginPromptChoice<Choice>[] | readonly string[];
29
130
  readonly default?: Value;
131
+ readonly details?: string;
30
132
  readonly excludePath?: (path: string) => boolean;
31
133
  readonly itemType?: "file" | "directory" | "any";
32
134
  readonly message: string;
135
+ readonly title?: string;
136
+ readonly purpose?: "input" | "approval";
33
137
  readonly name: Key;
34
138
  readonly pageSize?: number;
35
139
  readonly rootPath?: string;
36
140
  readonly type: PluginPromptType;
37
141
  readonly validate?: (value: unknown) => boolean | string;
38
142
  }
143
+ /** Plugin-owned UI; the host owns identity, cancellation and response delivery. */
144
+ interface PluginPromptViewRequest {
145
+ readonly viewId: string;
146
+ readonly title: string;
147
+ readonly input: unknown;
148
+ readonly purpose?: "input" | "approval";
149
+ }
39
150
  interface PluginPromptApi<Parameters extends Record<string, unknown> = Record<string, unknown>> {
151
+ readonly open: (request: PluginPromptViewRequest) => Promise<unknown>;
40
152
  readonly ask: <Key extends keyof Parameters>(question: PluginPromptQuestion<Key, Parameters[Key]>) => Promise<{ [Property in Key]: Parameters[Property]; }>;
41
153
  }
42
154
  type PluginToastLevel = "info" | "warn" | "error" | "success";
@@ -49,6 +161,8 @@ interface PluginToastApi {
49
161
  readonly update: (id: number, message: string, level?: PluginToastLevel, options?: PluginToastOptions) => number;
50
162
  }
51
163
  interface PluginStoreApi {
164
+ /** Private workspace/plugin directory, allocated and validated by the host. */
165
+ readonly directory: () => string;
52
166
  readonly getState: () => Readonly<Record<string, unknown>>;
53
167
  readonly setState: (partial: Readonly<Record<string, unknown>>) => void;
54
168
  readonly subscribe: (listener: () => void) => () => void;
@@ -58,6 +172,7 @@ interface PluginConfigApi {
58
172
  readonly replace: (config: Readonly<Record<string, unknown>>) => Promise<Readonly<Record<string, unknown>>>;
59
173
  }
60
174
  interface PluginCommandCatalogEntry {
175
+ readonly background?: boolean;
61
176
  readonly agent?: PluginAgentPolicy;
62
177
  readonly arguments?: readonly PluginCommandArgument[];
63
178
  readonly category?: PluginCommandCategory;
@@ -78,6 +193,10 @@ interface PluginAgentPolicy {
78
193
  readonly readOnly: boolean;
79
194
  }
80
195
  interface PluginCapabilityCommandRequest {
196
+ /** Background commands only: run after this execution finishes; queued predecessors must succeed. */
197
+ readonly afterExecutionId?: string;
198
+ /** Optional bounded display details for an accepted background command, sanitized by the host. */
199
+ readonly initialDetails?: PluginCommandDetails;
81
200
  readonly commandId: string;
82
201
  readonly executionId?: string;
83
202
  readonly input?: unknown;
@@ -92,6 +211,7 @@ interface PluginCapabilityResolveRequest {
92
211
  interface PluginStatusCatalogEntry {
93
212
  readonly description: string;
94
213
  readonly id: string;
214
+ readonly input?: ZodType;
95
215
  readonly label: string;
96
216
  readonly pluginId: string;
97
217
  }
@@ -99,6 +219,7 @@ interface PluginAgentContextCatalogEntry {
99
219
  readonly exposure: PluginContextExposure;
100
220
  readonly description: string;
101
221
  readonly id: string;
222
+ readonly input?: ZodType;
102
223
  readonly pluginId: string;
103
224
  readonly title: string;
104
225
  }
@@ -122,6 +243,16 @@ interface PluginCapabilityService {
122
243
  readonly resolveStatus: (request: PluginCapabilityResolveRequest) => Promise<unknown>;
123
244
  }
124
245
  interface PluginSystemContextService {
246
+ /** @deprecated Use services.tools.inspectEnvironment. */
247
+ readonly inspectEnvironment: () => Promise<Readonly<Record<string, unknown>>>;
248
+ /** Requires a foreground ProjectMutation command declaring project.yaml and a reviewed configuration revision. */
249
+ readonly applyRoleTools: (request: {
250
+ readonly roleId: string;
251
+ readonly revision: string;
252
+ readonly toolIds: readonly string[];
253
+ }) => Promise<Readonly<Record<string, unknown>>>;
254
+ /** Finds an installed desktop app by its platform identity without launching it. */
255
+ readonly findApplication: (applicationId: string) => Promise<string | null>;
125
256
  readonly getContext: () => Promise<Readonly<Record<string, unknown>>>;
126
257
  }
127
258
  interface PluginLogQueryRequest {
@@ -151,7 +282,23 @@ interface PluginTaskService {
151
282
  readonly list: () => Promise<readonly PluginTaskDescriptor[]>;
152
283
  readonly run: (taskId: string) => Promise<PluginTaskResult>;
153
284
  }
285
+ /** Opaque delegation is usable only while its verified parent execution remains active. */
286
+ interface PluginExecutionService {
287
+ readonly report: (details: PluginCommandDetails) => Promise<void>;
288
+ readonly start: (request: PluginCapabilityCommandRequest) => Promise<PluginExecutionSnapshot>;
289
+ readonly query: (executionId?: string) => Promise<readonly PluginExecutionSnapshot[]>;
290
+ readonly grant: (options: {
291
+ readonly readOnly: boolean;
292
+ readonly tasks: readonly string[];
293
+ }) => Promise<string>;
294
+ readonly revoke: (token: string) => Promise<void>;
295
+ readonly delegate: (token: string, request: {
296
+ readonly method: "tasks.list" | "tasks.run" | "commands.execute" | "commands.start" | "commands.query";
297
+ readonly input: unknown;
298
+ }) => Promise<unknown>;
299
+ }
154
300
  interface PluginHostServices {
301
+ readonly executions: PluginExecutionService;
155
302
  readonly capabilities: PluginCapabilityService;
156
303
  readonly config: PluginConfigApi;
157
304
  readonly logger: PluginInteractiveLogger;
@@ -161,6 +308,7 @@ interface PluginHostServices {
161
308
  readonly system: PluginSystemContextService;
162
309
  readonly toast: PluginToastApi;
163
310
  readonly tasks: PluginTaskService;
311
+ readonly tools: PluginToolsService;
164
312
  }
165
313
  //#endregion
166
314
  //#region src/types.d.ts
@@ -172,6 +320,41 @@ declare enum PluginHookId {
172
320
  WorkspaceProvision = "workspace.provision",
173
321
  Cleanup = "cleanup"
174
322
  }
323
+ declare enum PluginExecutionStatus {
324
+ Queued = "queued",
325
+ Starting = "starting",
326
+ Running = "running",
327
+ WaitingInput = "waitingInput",
328
+ WaitingApproval = "waitingApproval",
329
+ Cancelling = "cancelling",
330
+ Succeeded = "succeeded",
331
+ Failed = "failed",
332
+ Cancelled = "cancelled",
333
+ Interrupted = "interrupted"
334
+ }
335
+ interface PluginExecutionSnapshot {
336
+ readonly afterExecutionId?: string | null;
337
+ readonly revision: number;
338
+ readonly tasks: readonly {
339
+ readonly taskId: string;
340
+ readonly success: boolean;
341
+ readonly logId: string;
342
+ }[];
343
+ readonly executionId: string;
344
+ readonly projectId: string;
345
+ readonly workspaceId: string;
346
+ readonly activationGeneration: number;
347
+ readonly pluginId: string;
348
+ readonly commandId: string;
349
+ readonly title: string;
350
+ readonly status: PluginExecutionStatus;
351
+ readonly startedAt: string;
352
+ readonly finishedAt: string | null;
353
+ readonly logId: string;
354
+ readonly error: string | null;
355
+ readonly details: PluginCommandDetails | null;
356
+ readonly result: PluginCommandExecutionResult | null;
357
+ }
175
358
  declare enum PluginCommandEffect {
176
359
  Immediate = "immediate",
177
360
  LongRunning = "longRunning"
@@ -282,6 +465,8 @@ type PluginSharedChanges = {
282
465
  };
283
466
  /** Explicit, sanitized business details for the command execution record. */
284
467
  interface PluginCommandDetails {
468
+ /** Bounded, sanitized plugin-owned progress; never credentials or pending answers. */
469
+ readonly metadata?: unknown;
285
470
  readonly success: boolean;
286
471
  readonly summary?: string;
287
472
  readonly command?: string;
@@ -305,6 +490,8 @@ interface PluginCommandContext extends PluginInvocationContext {
305
490
  readonly executionId: string;
306
491
  }
307
492
  interface PluginCommandDefinition {
493
+ /** Explicit host-owned background execution; transaction must be None. */
494
+ readonly background?: boolean;
308
495
  /** Required for ProjectMutation; read-only and evaluated before the write lease is used. */
309
496
  readonly plan?: (input: unknown) => PluginSharedChanges | Promise<PluginSharedChanges>;
310
497
  readonly agent?: PluginAgentPolicy;
@@ -338,6 +525,7 @@ interface PluginAgentContextDefinition {
338
525
  readonly exposure: PluginContextExposure;
339
526
  readonly description: string;
340
527
  readonly id: string;
528
+ readonly input?: ZodType;
341
529
  readonly title: string;
342
530
  readonly resolve: (input: unknown, context: PluginInvocationContext) => unknown | Promise<unknown>;
343
531
  }
@@ -359,6 +547,7 @@ interface PluginViewDefinition {
359
547
  interface PluginStatusDefinition {
360
548
  readonly description: string;
361
549
  readonly id: string;
550
+ readonly input?: ZodType;
362
551
  readonly label: string;
363
552
  readonly resolve: (input: unknown, context: PluginInvocationContext) => unknown | Promise<unknown>;
364
553
  }
@@ -412,6 +601,8 @@ interface WorkbasePluginDefinition {
412
601
  readonly title: string;
413
602
  }
414
603
  interface PluginCommandContribution {
604
+ readonly background?: boolean;
605
+ readonly agent?: PluginAgentPolicy;
415
606
  readonly description?: string;
416
607
  readonly effect: PluginCommandEffect;
417
608
  readonly id: string;
@@ -446,4 +637,4 @@ interface PluginContributionSnapshot {
446
637
  readonly views: readonly PluginViewContribution[];
447
638
  }
448
639
  //#endregion
449
- export { PluginConfigApi as $, PluginProject as A, PluginViewDefinition as B, PluginLifecycleOutcome as C, PluginProcessApi as D, PluginLogger as E, PluginSharedChanges as F, PluginAgentContextCatalogEntry as G, PluginViewRequest as H, PluginStatusContribution as I, PluginCapabilityCommandRequest as J, PluginAgentPolicy as K, PluginStatusDefinition as L, PluginRepositoryStatus as M, PluginSetupHooks as N, PluginProcessResult as O, PluginSharedChangeKind as P, PluginCommandCatalogEntry as Q, PluginToolContribution as R, PluginLifecycleHook as S, PluginLifecycleStatus as T, PluginWorkspace as U, PluginViewLayout as V, WorkbasePluginDefinition as W, PluginCapabilityService as X, PluginCapabilityResolveRequest as Y, PluginColoredMessage as Z, PluginDisposable as _, PluginToastLevel as _t, PluginCommandContext as a, PluginLogService as at, PluginInvocationContext as b, PluginCommandDetails as c, PluginPromptQuestion as ct, PluginCommandExecutionResult as d, PluginStoreApi as dt, PluginHostServices as et, PluginCommandOption as f, PluginSystemContextService as ft, PluginContributionSnapshot as g, PluginToastApi as gt, PluginContextExposure as h, PluginTaskService as ht, PluginCommandCategory as i, PluginLogQueryResult as it, PluginRepository as j, PluginProcessRunOptions as k, PluginCommandEffect as l, PluginPromptType as lt, PluginContext as m, PluginTaskResult as mt, PluginAgentContextDefinition as n, PluginLogEntry as nt, PluginCommandContribution as o, PluginPromptApi as ot, PluginCommandTransaction as p, PluginTaskDescriptor as pt, PluginCapabilityCatalog as q, PluginCommandArgument as r, PluginLogQueryRequest as rt, PluginCommandDefinition as s, PluginPromptChoice as st, PluginAgentContextContribution as t, PluginInteractiveLogger as tt, PluginCommandExecutionMode as u, PluginStatusCatalogEntry as ut, PluginHookId as v, PluginToastOptions as vt, PluginLifecyclePolicy as w, PluginLifecycleDispatchResult as x, PluginHookResult as y, PluginViewCatalogEntry as yt, PluginViewContribution as z };
640
+ export { PluginColoredMessage as $, PluginProcessResult as A, roleToolsProposalSchema as At, PluginToolContribution as B, PluginLifecycleDispatchResult as C, PluginViewCatalogEntry as Ct, PluginLifecycleStatus as D, RoleToolsProposal as Dt, PluginLifecyclePolicy as E, RoleToolsApplied as Et, PluginSetupHooks as F, PluginWorkspace as G, PluginViewDefinition as H, PluginSharedChangeKind as I, PluginAgentPolicy as J, WorkbasePluginDefinition as K, PluginSharedChanges as L, PluginProject as M, PluginRepository as N, PluginLogger as O, roleToolEnvironmentSchema as Ot, PluginRepositoryStatus as P, PluginCapabilityService as Q, PluginStatusContribution as R, PluginInvocationContext as S, PluginToastOptions as St, PluginLifecycleOutcome as T, RoleToolEnvironment as Tt, PluginViewLayout as U, PluginViewContribution as V, PluginViewRequest as W, PluginCapabilityCommandRequest as X, PluginCapabilityCatalog as Y, PluginCapabilityResolveRequest as Z, PluginDisposable as _, PluginTaskDescriptor as _t, PluginCommandContext as a, PluginLogEntry as at, PluginHookId as b, PluginToastApi as bt, PluginCommandDetails as c, PluginLogService as ct, PluginCommandExecutionResult as d, PluginPromptQuestion as dt, PluginCommandCatalogEntry as et, PluginCommandOption as f, PluginPromptType as ft, PluginContributionSnapshot as g, PluginSystemContextService as gt, PluginContextExposure as h, PluginStoreApi as ht, PluginCommandCategory as i, PluginInteractiveLogger as it, PluginProcessRunOptions as j, PluginProcessApi as k, roleToolsAppliedSchema as kt, PluginCommandEffect as l, PluginPromptApi as lt, PluginContext as m, PluginStatusCatalogEntry as mt, PluginAgentContextDefinition as n, PluginExecutionService as nt, PluginCommandContribution as o, PluginLogQueryRequest as ot, PluginCommandTransaction as p, PluginPromptViewRequest as pt, PluginAgentContextCatalogEntry as q, PluginCommandArgument as r, PluginHostServices as rt, PluginCommandDefinition as s, PluginLogQueryResult as st, PluginAgentContextContribution as t, PluginConfigApi as tt, PluginCommandExecutionMode as u, PluginPromptChoice as ut, PluginExecutionSnapshot as v, PluginTaskResult as vt, PluginLifecycleHook as w, PluginToolsService as wt, PluginHookResult as x, PluginToastLevel as xt, PluginExecutionStatus as y, PluginTaskService as yt, PluginStatusDefinition as z };
package/dist/ui/index.css CHANGED
@@ -1,10 +1,21 @@
1
+ @layer base, mantine, components;
2
+ @import "./theme.css";
3
+
4
+ @layer base {
1
5
  :root {
2
6
  --color-foreground: #342f28;
3
7
  --color-muted: #6c675f;
8
+ --color-tertiary: #756f66;
4
9
  --color-border: #e2dfd6;
10
+ --color-border-strong: #c9c4b8;
5
11
  --color-surface: #fff;
6
12
  --color-surface-muted: #f3f2ed;
13
+ --color-surface-raised: #faf9f5;
14
+ --color-table-row: #fcfbf7;
7
15
  --color-brand: #8a5000;
16
+ --color-brand-deep: #502e00;
17
+ --color-brand-gold: #ca8818;
18
+ --color-brand-weak: #fffee5;
8
19
  --color-primary: #ffde39;
9
20
  --color-primary-hover: #ffca00;
10
21
  --color-primary-foreground: #322d16;
@@ -29,20 +40,6 @@ body {
29
40
  background: transparent;
30
41
  }
31
42
 
32
- button,
33
- input,
34
- select {
35
- font: inherit;
36
- }
37
-
38
- button:focus-visible,
39
- input:focus-visible,
40
- select:focus-visible,
41
- a:focus-visible {
42
- outline: 2px solid color-mix(in srgb, var(--color-accent) 25%, transparent);
43
- outline-offset: 2px;
44
- }
45
-
46
43
  h1,
47
44
  h2,
48
45
  p {
@@ -146,36 +143,6 @@ h2 {
146
143
  gap: 8px;
147
144
  }
148
145
 
149
- .button {
150
- min-height: 34px;
151
- padding: 7px 12px;
152
- border: 1px solid transparent;
153
- border-radius: 7px;
154
- cursor: pointer;
155
- font-size: 13px;
156
- font-weight: 700;
157
- }
158
-
159
- .button:disabled {
160
- cursor: not-allowed;
161
- opacity: 0.55;
162
- }
163
-
164
- .button-primary {
165
- color: var(--color-primary-foreground);
166
- background: var(--color-primary);
167
- }
168
-
169
- .button-primary:hover:not(:disabled) {
170
- background: var(--color-primary-hover);
171
- }
172
-
173
- .button-secondary {
174
- border-color: var(--color-border);
175
- color: var(--color-foreground);
176
- background: var(--color-surface);
177
- }
178
-
179
146
  .form-grid,
180
147
  .stack-form {
181
148
  display: grid;
@@ -196,18 +163,6 @@ h2 {
196
163
  font-weight: 700;
197
164
  }
198
165
 
199
- .form-grid input,
200
- .form-grid select,
201
- .stack-form select {
202
- width: 100%;
203
- min-height: 38px;
204
- padding: 7px 9px;
205
- border: 1px solid var(--color-border);
206
- border-radius: 7px;
207
- color: var(--color-foreground);
208
- background: var(--color-surface);
209
- }
210
-
211
166
  .form-span {
212
167
  grid-column: 1 / -1;
213
168
  }
@@ -220,12 +175,6 @@ h2 {
220
175
  font-weight: 500;
221
176
  }
222
177
 
223
- .checkbox-row input {
224
- width: 16px;
225
- min-height: 16px;
226
- margin: 0;
227
- }
228
-
229
178
  .form-actions {
230
179
  min-height: 36px;
231
180
  color: var(--color-muted);
@@ -254,59 +203,6 @@ h2 {
254
203
  margin-left: auto;
255
204
  }
256
205
 
257
- .status-pill {
258
- display: inline-flex;
259
- flex: none;
260
- align-items: center;
261
- gap: 6px;
262
- min-height: 24px;
263
- padding: 3px 9px;
264
- border-radius: 999px;
265
- color: var(--color-foreground);
266
- background: var(--color-surface-muted);
267
- box-shadow: inset 0 0 0 1px var(--color-border);
268
- font-size: 12px;
269
- font-weight: 700;
270
- white-space: nowrap;
271
- }
272
-
273
- .status-pill::before {
274
- width: 6px;
275
- height: 6px;
276
- border-radius: 50%;
277
- background: currentColor;
278
- content: "";
279
- }
280
-
281
- .status-pill[data-status="success"],
282
- .status-pill[data-status="running"] {
283
- color: var(--color-success);
284
- background: color-mix(in srgb, var(--color-success) 10%, transparent);
285
- }
286
-
287
- .status-pill[data-status="pending"],
288
- .status-pill[data-status="warning"] {
289
- color: var(--color-warning);
290
- background: color-mix(in srgb, var(--color-warning) 10%, transparent);
291
- }
292
-
293
- .status-pill[data-status="failed"],
294
- .status-pill[data-status="error"] {
295
- color: var(--color-danger);
296
- background: color-mix(in srgb, var(--color-danger) 10%, transparent);
297
- }
298
-
299
- .error-message {
300
- padding: 10px 12px;
301
- margin-bottom: 0;
302
- border: 1px solid color-mix(in srgb, var(--color-danger) 25%, transparent);
303
- border-radius: 7px;
304
- color: var(--color-danger);
305
- background: color-mix(in srgb, var(--color-danger) 8%, transparent);
306
- font-size: 13px;
307
- line-height: 1.5;
308
- }
309
-
310
206
  .output-panel[data-status="failed"] {
311
207
  border-color: color-mix(in srgb, var(--color-danger) 35%, var(--color-border));
312
208
  }
@@ -328,9 +224,7 @@ h2 {
328
224
  @media (max-width: 760px) {
329
225
  .summary-grid,
330
226
  .two-column-layout,
331
- .form-grid {
332
- grid-template-columns: 1fr;
333
- }
227
+ .form-grid { grid-template-columns: 1fr; }
334
228
 
335
229
  .form-span {
336
230
  grid-column: auto;
@@ -346,3 +240,10 @@ h2 {
346
240
  justify-content: flex-start;
347
241
  }
348
242
  }
243
+
244
+ }
245
+
246
+ @layer components {
247
+ .maintenance-panel .mantine-Accordion-control { padding: 11px 14px; font-size: 13px; }
248
+ .error-message, .notice-card { margin: 12px 0 0; }
249
+ }
@@ -1,4 +1,4 @@
1
- import { d as PluginCommandExecutionResult } from "../types-CYt_KGKR.js";
1
+ import { d as PluginCommandExecutionResult, v as PluginExecutionSnapshot } from "../types-CoZB_r31.js";
2
2
  //#region src/ui/types.d.ts
3
3
  /**
4
4
  * Browser authoring API and transport contracts for Workbase plugin views.
@@ -67,7 +67,20 @@ interface PluginUiOutputOptions {
67
67
  readonly status?: string | null;
68
68
  readonly title: string;
69
69
  }
70
+ /** A single authoritative execution update; removal retains its identity and revision. */
71
+ interface PluginUiExecutionChange {
72
+ readonly snapshot: PluginExecutionSnapshot;
73
+ readonly removed: boolean;
74
+ }
70
75
  interface PluginUiCommands {
76
+ /** Subscribe before querying snapshots. Dispose when the view no longer consumes events. */
77
+ readonly subscribe: (onChange: (change: PluginUiExecutionChange) => void) => Promise<() => Promise<void>>;
78
+ /** Reveal the existing host question; does not create or answer a prompt. */
79
+ readonly reply: (executionId: string) => Promise<void>;
80
+ /** Clear one ended execution, or all when omitted; active runs, logs and Agent sessions are retained. */
81
+ readonly clear: (executionId?: string) => Promise<void>;
82
+ readonly start: (commandId: string, input: unknown, options?: PluginUiCommandExecuteOptions) => Promise<PluginExecutionSnapshot>;
83
+ readonly query: (executionId?: string) => Promise<readonly PluginExecutionSnapshot[]>;
71
84
  readonly cancel: <Result = unknown>(executionId: string) => Promise<Result>;
72
85
  readonly execute: <Result = unknown>(commandId: string, input: unknown, options?: PluginUiCommandExecuteOptions) => Promise<PluginCommandExecutionResult<Result>>;
73
86
  }
@@ -78,6 +91,10 @@ interface PluginUiView {
78
91
  readonly call: <Result = unknown>(method: string, input: unknown) => Promise<Result>;
79
92
  }
80
93
  interface WorkbasePluginUi {
94
+ /** Hides a resumable interaction without answering or cancelling it. */
95
+ readonly dismiss: () => Promise<void>;
96
+ /** Answers only the interaction currently hosted in this frame. Null cancels it. */
97
+ readonly respond: (value: unknown | null) => Promise<void>;
81
98
  readonly closeOutput: <Result = unknown>(id: string) => Promise<Result>;
82
99
  readonly commands: PluginUiCommands;
83
100
  readonly navigate: <Result = unknown>(to: string, options?: PluginUiNavigateOptions) => Promise<Result>;
@@ -98,6 +115,7 @@ interface PluginUiHostMethods {
98
115
  readonly reportFatal: (message: string) => Promise<void>;
99
116
  }
100
117
  interface PluginUiClientMethods {
118
+ readonly executionChanged: (change: PluginUiExecutionChange) => Promise<void>;
101
119
  readonly initialize: (payload: unknown) => Promise<void>;
102
120
  }
103
121
  interface PluginUiTransportConnection {
@@ -115,4 +133,4 @@ export declare function createPluginUiController(definition: WorkbasePluginUiDef
115
133
  //#region src/ui/index.d.ts
116
134
  export declare function defineWorkbasePluginUi(definition: WorkbasePluginUiDefinition): WorkbasePluginUi;
117
135
  //#endregion
118
- export type { PluginUiClientMethods, PluginUiCommandExecuteOptions, PluginUiCommands, PluginUiContextIdentity, PluginUiControllerOptions, PluginUiFileFilter, PluginUiFileSelectOptions, PluginUiFileSelectionItemType, PluginUiFileSelectionScope, PluginUiHostError, PluginUiHostMethods, PluginUiInitializationPayload, PluginUiNavigateOptions, PluginUiOutputOptions, PluginUiPromptChoice, PluginUiPromptOptions, PluginUiPromptType, PluginUiStatus, PluginUiToastOptions, PluginUiTransportConnection, PluginUiView, PluginUiViewIdentity, WorkbasePluginUi, WorkbasePluginUiDefinition };
136
+ export type { PluginUiClientMethods, PluginUiCommandExecuteOptions, PluginUiCommands, PluginUiContextIdentity, PluginUiControllerOptions, PluginUiExecutionChange, PluginUiFileFilter, PluginUiFileSelectOptions, PluginUiFileSelectionItemType, PluginUiFileSelectionScope, PluginUiHostError, PluginUiHostMethods, PluginUiInitializationPayload, PluginUiNavigateOptions, PluginUiOutputOptions, PluginUiPromptChoice, PluginUiPromptOptions, PluginUiPromptType, PluginUiStatus, PluginUiToastOptions, PluginUiTransportConnection, PluginUiView, PluginUiViewIdentity, WorkbasePluginUi, WorkbasePluginUiDefinition };
package/dist/ui/index.js CHANGED
@@ -12,15 +12,25 @@ function createPluginUiController(definition, options) {
12
12
  const state = {
13
13
  fatalReportPromise: null,
14
14
  isInitialized: false,
15
+ contentHeight: null,
15
16
  recoverableHostErrors: /* @__PURE__ */ new WeakSet()
16
17
  };
17
- const connection = connectToHost({ initialize: async (payload) => {
18
- assertInitializationPayload(payload);
19
- state.isInitialized = true;
20
- await onInit(payload);
21
- await waitForPluginUiPaint(targetWindow);
22
- await reportContentHeight(hostPromise, targetWindow);
23
- } });
18
+ const executionListeners = /* @__PURE__ */ new Set();
19
+ const connection = connectToHost({
20
+ executionChanged: async (change) => {
21
+ if (state.isInitialized) [...executionListeners].forEach((listener) => listener(change));
22
+ },
23
+ initialize: async (payload) => {
24
+ assertInitializationPayload(payload);
25
+ state.isInitialized = true;
26
+ await onInit(payload);
27
+ await waitForPluginUiPaint(targetWindow);
28
+ await reportContentHeight(hostPromise, {
29
+ targetWindow,
30
+ state
31
+ });
32
+ }
33
+ });
24
34
  const hostPromise = connection.promise;
25
35
  const request = createHostRequest(hostPromise, state);
26
36
  bindPluginUiLifecycle({
@@ -28,7 +38,24 @@ function createPluginUiController(definition, options) {
28
38
  state,
29
39
  targetWindow
30
40
  });
31
- return createPluginUiApi(request, targetWindow);
41
+ const subscribe = async (onChange) => {
42
+ const listener = (change) => onChange(change);
43
+ executionListeners.add(listener);
44
+ try {
45
+ await request("command.subscribe", { enabled: true });
46
+ } catch (error) {
47
+ executionListeners.delete(listener);
48
+ throw error;
49
+ }
50
+ return async () => {
51
+ if (!executionListeners.delete(listener) || executionListeners.size) return;
52
+ await request("command.subscribe", { enabled: false });
53
+ };
54
+ };
55
+ return createPluginUiApi(request, {
56
+ targetWindow,
57
+ subscribe
58
+ });
32
59
  }
33
60
  function createHostRequest(hostPromise, state) {
34
61
  return async (method, params) => {
@@ -46,8 +73,17 @@ function createHostError(response) {
46
73
  const code = typeof responseError?.code === "string" ? responseError.code : "host_error";
47
74
  return Object.assign(new Error(message), { code });
48
75
  }
49
- function createPluginUiApi(request, targetWindow) {
76
+ function createPluginUiApi(request, { targetWindow, subscribe }) {
50
77
  const commands = Object.freeze({
78
+ subscribe,
79
+ reply: (executionId) => request("command.reply", { executionId }),
80
+ clear: (executionId) => request("command.clear", executionId === void 0 ? {} : { executionId }),
81
+ start: (commandId, input, options = {}) => request("command.start", {
82
+ commandId,
83
+ input,
84
+ executionId: options.executionId ?? targetWindow.crypto.randomUUID()
85
+ }),
86
+ query: (executionId) => request("command.query", { executionId: executionId ?? null }),
51
87
  cancel: (executionId) => request("command.cancel", { executionId }),
52
88
  execute: (commandId, input, options = {}) => {
53
89
  return request("command.execute", {
@@ -66,6 +102,8 @@ function createPluginUiApi(request, targetWindow) {
66
102
  method
67
103
  }) });
68
104
  return Object.freeze({
105
+ dismiss: () => request("interaction.dismiss", {}),
106
+ respond: (value) => request("interaction.respond", { value }),
69
107
  closeOutput: (id) => request("output.close", { id }),
70
108
  commands,
71
109
  navigate: (to, { replace = false } = {}) => request("navigate", {
@@ -82,7 +120,9 @@ function createPluginUiApi(request, targetWindow) {
82
120
  });
83
121
  }
84
122
  function bindPluginUiLifecycle({ connection, state, targetWindow }) {
123
+ let resizeFrame = null;
85
124
  const handleWindowError = (event) => {
125
+ if (!event.error && (event.message === "ResizeObserver loop completed with undelivered notifications." || event.message === "ResizeObserver loop limit exceeded")) return;
86
126
  reportFirstFatal(connection.promise, state, event.error ?? event.message);
87
127
  };
88
128
  const handleUnhandledRejection = (event) => {
@@ -90,13 +130,21 @@ function bindPluginUiLifecycle({ connection, state, targetWindow }) {
90
130
  reportFirstFatal(connection.promise, state, event.reason);
91
131
  };
92
132
  const resizeObserver = new targetWindow.ResizeObserver(() => {
93
- reportContentHeight(connection.promise, targetWindow);
133
+ if (resizeFrame !== null) return;
134
+ resizeFrame = targetWindow.requestAnimationFrame(() => {
135
+ resizeFrame = null;
136
+ if (state.isInitialized) reportContentHeight(connection.promise, {
137
+ targetWindow,
138
+ state
139
+ });
140
+ });
94
141
  });
95
142
  const cleanup = () => {
96
143
  targetWindow.removeEventListener("error", handleWindowError, true);
97
144
  targetWindow.removeEventListener("unhandledrejection", handleUnhandledRejection);
98
145
  targetWindow.removeEventListener("beforeunload", cleanup);
99
146
  resizeObserver.disconnect();
147
+ if (resizeFrame !== null) targetWindow.cancelAnimationFrame(resizeFrame);
100
148
  connection.destroy();
101
149
  state.fatalReportPromise = null;
102
150
  state.isInitialized = false;
@@ -128,13 +176,15 @@ async function sendFatalReport(hostPromise, message) {
128
176
  await (await hostPromise).reportFatal(message);
129
177
  } catch {}
130
178
  }
131
- async function reportContentHeight(hostPromise, targetWindow) {
179
+ async function reportContentHeight(hostPromise, { targetWindow, state }) {
132
180
  const contentElement = targetWindow.document.body ?? targetWindow.document.documentElement;
133
181
  const height = Math.max(contentElement.offsetHeight, contentElement.scrollHeight);
134
182
  if (!Number.isFinite(height)) return;
135
183
  try {
136
184
  const host = await hostPromise;
137
185
  const contentHeight = Math.min(Math.max(Math.ceil(height), MIN_CONTENT_HEIGHT), MAX_CONTENT_HEIGHT);
186
+ if (!state.isInitialized || state.contentHeight === contentHeight) return;
187
+ state.contentHeight = contentHeight;
138
188
  await host.reportContentHeight(contentHeight);
139
189
  } catch {}
140
190
  }
@@ -0,0 +1,202 @@
1
+ /** Shared Mantine appearance for the desktop shell and isolated plugin views. */
2
+ @layer components {
3
+ .mantine-Badge-root {
4
+ width: fit-content;
5
+ height: auto;
6
+ min-height: 24px;
7
+ flex-shrink: 0;
8
+ gap: 6px;
9
+ padding: 3px 7px;
10
+ overflow: visible;
11
+ font-size: 12px;
12
+ font-weight: 600;
13
+ line-height: 16px;
14
+ letter-spacing: 0;
15
+ text-transform: none;
16
+ white-space: nowrap;
17
+ }
18
+
19
+ .mantine-Badge-label,
20
+ .mantine-Button-label,
21
+ .mantine-Tabs-tabLabel {
22
+ display: inline-flex;
23
+ align-items: center;
24
+ gap: inherit;
25
+ overflow: visible;
26
+ line-height: inherit;
27
+ }
28
+
29
+ .mantine-Badge-section { margin: 0; }
30
+ .mantine-Badge-root[data-full-width] { width: 100%; }
31
+
32
+ .mantine-Badge-label > svg,
33
+ .mantine-Button-label > svg { flex-shrink: 0; }
34
+
35
+ .mantine-Button-root,
36
+ .mantine-ActionIcon-root {
37
+ flex-shrink: 0;
38
+ font-weight: 600;
39
+ transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease;
40
+ }
41
+
42
+ .mantine-Button-inner,
43
+ .mantine-Button-label { gap: 6px; }
44
+
45
+ .mantine-Button-root[data-variant="default"],
46
+ .mantine-ActionIcon-root[data-variant="default"] {
47
+ border-color: var(--color-border-strong);
48
+ color: var(--color-foreground);
49
+ background: var(--color-surface);
50
+ }
51
+
52
+ .mantine-ActionIcon-root[data-variant="default"] { color: var(--color-muted); }
53
+
54
+ .workbase-brand-control[data-variant="filled"]:not(:disabled):not([data-disabled]) {
55
+ border-color: var(--color-primary-hover);
56
+ color: var(--color-primary-foreground);
57
+ }
58
+
59
+ .workbase-brand-control[data-variant="light"] {
60
+ color: var(--color-brand-deep);
61
+ background: var(--color-brand-weak);
62
+ }
63
+
64
+ .workbase-brand-control[data-variant="subtle"] { color: var(--color-brand); }
65
+
66
+ .workbase-status-teal { --workbase-status-color: var(--color-success); }
67
+ .workbase-status-orange { --workbase-status-color: var(--color-warning); }
68
+ .workbase-status-red { --workbase-status-color: var(--color-danger); }
69
+ .workbase-status-blue { --workbase-status-color: var(--color-accent); }
70
+ .workbase-status-gray { --workbase-status-color: var(--color-muted); }
71
+
72
+ .workbase-status-badge {
73
+ height: 24px;
74
+ align-self: center;
75
+ padding: 2px 8px;
76
+ border: 0;
77
+ color: var(--workbase-status-color);
78
+ background: color-mix(in srgb, var(--workbase-status-color) 8%, transparent);
79
+ font-weight: 500;
80
+ }
81
+
82
+ .workbase-status-gray { background: transparent; }
83
+
84
+ .workbase-status-badge:not(:has(.mantine-Badge-section)) .mantine-Badge-label::before {
85
+ content: "";
86
+ width: 6px;
87
+ height: 6px;
88
+ flex-shrink: 0;
89
+ border-radius: 50%;
90
+ background: currentColor;
91
+ opacity: 0.8;
92
+ }
93
+
94
+ @media (hover: hover) {
95
+ .mantine-Button-root[data-variant="default"]:hover:not(:disabled),
96
+ .mantine-ActionIcon-root[data-variant="default"]:hover:not(:disabled) {
97
+ border-color: var(--color-brand-gold);
98
+ background: var(--color-brand-weak);
99
+ }
100
+
101
+ .workbase-brand-control[data-variant="subtle"]:hover:not(:disabled) {
102
+ color: var(--color-brand-deep);
103
+ background: var(--color-brand-weak);
104
+ }
105
+ }
106
+
107
+ .mantine-Button-root:disabled,
108
+ .mantine-ActionIcon-root:disabled { opacity: 0.5; }
109
+
110
+ .mantine-Input-input {
111
+ border-color: var(--color-border-strong);
112
+ color: var(--color-foreground);
113
+ transition: border-color 150ms ease;
114
+ }
115
+
116
+ .mantine-Input-input::placeholder { color: var(--color-muted); }
117
+
118
+ .mantine-Input-input:hover:not(:disabled):not([data-error]) { border-color: var(--color-brand-gold); }
119
+
120
+ .mantine-Input-input:focus-visible:not([data-error]) {
121
+ border-color: var(--color-accent);
122
+ outline: 2px solid color-mix(in srgb, var(--color-accent) 18%, transparent);
123
+ outline-offset: 1px;
124
+ }
125
+
126
+ .mantine-Input-input:disabled { background: var(--color-surface-muted); }
127
+ .mantine-Input-input[data-error] { border-color: var(--color-danger); color: var(--color-danger); }
128
+
129
+ .mantine-InputWrapper-label { color: var(--color-foreground); }
130
+
131
+ .mantine-Combobox-dropdown { border-color: var(--color-border-strong); border-radius: 6px; }
132
+ .mantine-Combobox-option { border-radius: 4px; font-size: 14px; }
133
+ .mantine-Combobox-option[data-combobox-selected],
134
+ .mantine-Combobox-option[data-checked] { background: var(--color-brand-weak); color: var(--color-brand-deep); }
135
+
136
+ .mantine-Accordion-item { border: 0; }
137
+
138
+ .mantine-Accordion-control {
139
+ min-height: 32px;
140
+ gap: 8px;
141
+ padding: 6px 0;
142
+ color: inherit;
143
+ font-size: inherit;
144
+ font-weight: 600;
145
+ }
146
+
147
+ .mantine-Accordion-control:hover { background: var(--color-surface-raised); }
148
+
149
+ .mantine-Accordion-label {
150
+ display: flex;
151
+ min-width: 0;
152
+ align-items: center;
153
+ gap: 8px;
154
+ padding: 0;
155
+ font: inherit;
156
+ }
157
+
158
+ .mantine-Accordion-chevron { color: var(--color-muted); }
159
+ .mantine-Accordion-content { padding: 0; }
160
+
161
+ .mantine-Tabs-list { border-bottom: 1px solid var(--color-border); }
162
+ .mantine-Tabs-list::before { display: none; }
163
+
164
+ .mantine-Tabs-tab {
165
+ height: 36px;
166
+ margin-bottom: -1px;
167
+ padding: 0 12px;
168
+ border-radius: 0;
169
+ border-bottom: 2px solid transparent;
170
+ color: var(--color-muted);
171
+ font-size: 14px;
172
+ font-weight: 600;
173
+ }
174
+
175
+ .mantine-Tabs-tab[data-active] {
176
+ border-color: var(--color-primary-hover);
177
+ color: var(--color-brand-deep);
178
+ }
179
+
180
+ .mantine-Tabs-panel { margin-top: 12px; }
181
+ .mantine-Modal-title { color: var(--color-brand-deep); font-size: 18px; font-weight: 600; }
182
+ .mantine-Modal-overlay { background: rgb(0 0 0 / 45%); }
183
+ .mantine-Modal-content {
184
+ border: 1px solid var(--color-border-strong);
185
+ color: var(--color-foreground);
186
+ box-shadow: 0 18px 56px rgb(32 27 18 / 24%);
187
+ }
188
+
189
+ .mantine-Alert-root { padding: 12px; border: 1px solid color-mix(in srgb, currentColor 20%, transparent); }
190
+ .mantine-Alert-message { color: inherit; font-size: 14px; line-height: 1.5; }
191
+ .mantine-Notification-root { border: 1px solid var(--color-border); }
192
+ .mantine-Notification-title { color: var(--color-brand-deep); font-weight: 600; }
193
+ .mantine-Notification-description { color: var(--color-muted); }
194
+
195
+ .mantine-Checkbox-input:checked,
196
+ .mantine-Switch-track[data-checked] { border-color: var(--color-primary-hover); }
197
+
198
+ .mantine-UnstyledButton-root:focus-visible {
199
+ outline: 2px solid var(--color-primary-hover);
200
+ outline-offset: 2px;
201
+ }
202
+ }
@@ -0,0 +1,79 @@
1
+ //#region src/ui/theme.d.ts
2
+ /** Shared Mantine tokens for Workbase and its React plugin views; no runtime bridge dependencies. */
3
+ /** Allows the modal scroll-lock stylesheet to use the same nonce as Mantine. Call before mounting React. */
4
+ export declare function initializeWorkbaseUiStyles(): void;
5
+ /** Reads the per-document style authorization issued by the plugin asset protocol. */
6
+ export declare function getWorkbaseStyleNonce(): string;
7
+ export declare const workbaseUiTheme: {
8
+ readonly black: "#342f28";
9
+ readonly primaryColor: "workbase";
10
+ readonly primaryShade: 4;
11
+ readonly autoContrast: true;
12
+ readonly defaultRadius: "md";
13
+ readonly radius: {
14
+ readonly xs: "0.25rem";
15
+ readonly sm: "0.25rem";
16
+ readonly md: "0.375rem";
17
+ readonly lg: "0.5rem";
18
+ readonly xl: "0.75rem";
19
+ };
20
+ readonly fontFamily: "Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", sans-serif";
21
+ readonly fontSizes: {
22
+ readonly xs: "0.75rem";
23
+ readonly sm: "0.875rem";
24
+ readonly md: "0.875rem";
25
+ readonly lg: "1rem";
26
+ readonly xl: "1.25rem";
27
+ };
28
+ readonly colors: {
29
+ readonly workbase: readonly ["#fffde8", "#fff7bf", "#ffef94", "#ffe76a", "#ffde39", "#ffca00", "#d5a900", "#aa8200", "#805f00", "#502e00"];
30
+ readonly gray: readonly ["#faf9f5", "#f3f2ed", "#e2dfd6", "#c9c4b8", "#aaa49a", "#756f66", "#6c675f", "#514b41", "#342f28", "#211d17"];
31
+ readonly red: readonly ["#fff4ef", "#f8ebe7", "#f7b49a", "#dc7756", "#b9360a", "#a52f09", "#902908", "#772207", "#601b06", "#491505"];
32
+ readonly teal: readonly ["#eef9f7", "#eaf5f4", "#a2d8d0", "#51aca2", "#087c75", "#076e68", "#06615b", "#05514c", "#04423e", "#033330"];
33
+ readonly orange: readonly ["#fff7e9", "#f5eee6", "#e9c98b", "#c4913d", "#9a5600", "#894d00", "#784300", "#643800", "#522e00", "#3f2300"];
34
+ readonly blue: readonly ["#f0f7ff", "#ebf3fc", "#a6ccfa", "#599be9", "#0969da", "#085ec2", "#0752aa", "#06458e", "#053974", "#042b59"];
35
+ };
36
+ readonly components: {
37
+ readonly Badge: {
38
+ readonly defaultProps: {
39
+ readonly radius: "md";
40
+ };
41
+ readonly classNames: typeof badgeClassNames;
42
+ };
43
+ readonly Button: {
44
+ readonly defaultProps: {
45
+ readonly size: "sm";
46
+ };
47
+ readonly classNames: typeof brandClassNames;
48
+ };
49
+ readonly ActionIcon: {
50
+ readonly classNames: typeof brandClassNames;
51
+ };
52
+ readonly Accordion: {
53
+ readonly defaultProps: {
54
+ readonly chevronSize: 14;
55
+ };
56
+ };
57
+ readonly Modal: {
58
+ readonly defaultProps: {
59
+ readonly radius: "xl";
60
+ };
61
+ };
62
+ };
63
+ readonly headings: {
64
+ readonly fontWeight: "600";
65
+ };
66
+ readonly respectReducedMotion: true;
67
+ };
68
+ declare function brandClassNames(_theme: unknown, { color }: {
69
+ readonly color?: string;
70
+ }): {
71
+ root: string | undefined;
72
+ };
73
+ declare function badgeClassNames(theme: unknown, props: {
74
+ readonly color?: string;
75
+ readonly variant?: string;
76
+ }): {
77
+ root: string | undefined;
78
+ };
79
+ //#endregion
@@ -0,0 +1,137 @@
1
+ //#region src/ui/theme.ts
2
+ /** Shared Mantine tokens for Workbase and its React plugin views; no runtime bridge dependencies. */
3
+ /** Allows the modal scroll-lock stylesheet to use the same nonce as Mantine. Call before mounting React. */
4
+ function initializeWorkbaseUiStyles() {
5
+ Object.assign(window, { __webpack_nonce__: getWorkbaseStyleNonce() });
6
+ }
7
+ /** Reads the per-document style authorization issued by the plugin asset protocol. */
8
+ function getWorkbaseStyleNonce() {
9
+ return document.querySelector("meta[name=\"workbase-style-nonce\"]")?.content ?? "";
10
+ }
11
+ const workbaseUiTheme = {
12
+ black: "#342f28",
13
+ primaryColor: "workbase",
14
+ primaryShade: 4,
15
+ autoContrast: true,
16
+ defaultRadius: "md",
17
+ radius: {
18
+ xs: "0.25rem",
19
+ sm: "0.25rem",
20
+ md: "0.375rem",
21
+ lg: "0.5rem",
22
+ xl: "0.75rem"
23
+ },
24
+ fontFamily: "Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", sans-serif",
25
+ fontSizes: {
26
+ xs: "0.75rem",
27
+ sm: "0.875rem",
28
+ md: "0.875rem",
29
+ lg: "1rem",
30
+ xl: "1.25rem"
31
+ },
32
+ colors: {
33
+ workbase: [
34
+ "#fffde8",
35
+ "#fff7bf",
36
+ "#ffef94",
37
+ "#ffe76a",
38
+ "#ffde39",
39
+ "#ffca00",
40
+ "#d5a900",
41
+ "#aa8200",
42
+ "#805f00",
43
+ "#502e00"
44
+ ],
45
+ gray: [
46
+ "#faf9f5",
47
+ "#f3f2ed",
48
+ "#e2dfd6",
49
+ "#c9c4b8",
50
+ "#aaa49a",
51
+ "#756f66",
52
+ "#6c675f",
53
+ "#514b41",
54
+ "#342f28",
55
+ "#211d17"
56
+ ],
57
+ red: [
58
+ "#fff4ef",
59
+ "#f8ebe7",
60
+ "#f7b49a",
61
+ "#dc7756",
62
+ "#b9360a",
63
+ "#a52f09",
64
+ "#902908",
65
+ "#772207",
66
+ "#601b06",
67
+ "#491505"
68
+ ],
69
+ teal: [
70
+ "#eef9f7",
71
+ "#eaf5f4",
72
+ "#a2d8d0",
73
+ "#51aca2",
74
+ "#087c75",
75
+ "#076e68",
76
+ "#06615b",
77
+ "#05514c",
78
+ "#04423e",
79
+ "#033330"
80
+ ],
81
+ orange: [
82
+ "#fff7e9",
83
+ "#f5eee6",
84
+ "#e9c98b",
85
+ "#c4913d",
86
+ "#9a5600",
87
+ "#894d00",
88
+ "#784300",
89
+ "#643800",
90
+ "#522e00",
91
+ "#3f2300"
92
+ ],
93
+ blue: [
94
+ "#f0f7ff",
95
+ "#ebf3fc",
96
+ "#a6ccfa",
97
+ "#599be9",
98
+ "#0969da",
99
+ "#085ec2",
100
+ "#0752aa",
101
+ "#06458e",
102
+ "#053974",
103
+ "#042b59"
104
+ ]
105
+ },
106
+ components: {
107
+ Badge: {
108
+ defaultProps: { radius: "md" },
109
+ classNames: badgeClassNames
110
+ },
111
+ Button: {
112
+ defaultProps: { size: "sm" },
113
+ classNames: brandClassNames
114
+ },
115
+ ActionIcon: { classNames: brandClassNames },
116
+ Accordion: { defaultProps: { chevronSize: 14 } },
117
+ Modal: { defaultProps: { radius: "xl" } }
118
+ },
119
+ headings: { fontWeight: "600" },
120
+ respectReducedMotion: true
121
+ };
122
+ function brandClassNames(_theme, { color }) {
123
+ return { root: !color || color === "workbase" ? "workbase-brand-control" : void 0 };
124
+ }
125
+ function badgeClassNames(theme, props) {
126
+ const { color, variant } = props;
127
+ if (variant === "light" && color && [
128
+ "teal",
129
+ "orange",
130
+ "red",
131
+ "blue",
132
+ "gray"
133
+ ].includes(color)) return { root: `workbase-status-badge workbase-status-${color}` };
134
+ return brandClassNames(theme, props);
135
+ }
136
+ //#endregion
137
+ export { getWorkbaseStyleNonce, initializeWorkbaseUiStyles, workbaseUiTheme };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eworkbase/sdk",
3
- "version": "0.2.0",
3
+ "version": "0.3.1",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -18,14 +18,19 @@
18
18
  "./ui/model": {
19
19
  "types": "./dist/ui/model.d.ts",
20
20
  "import": "./dist/ui/model.js"
21
- }
21
+ },
22
+ "./ui/theme": {
23
+ "types": "./dist/ui/theme.d.ts",
24
+ "import": "./dist/ui/theme.js"
25
+ },
26
+ "./ui/theme.css": "./dist/ui/theme.css"
22
27
  },
23
28
  "engines": {
24
29
  "node": ">=22"
25
30
  },
26
31
  "dependencies": {
27
32
  "penpal": "^7.0.0",
28
- "zod": "^4.3.6"
33
+ "zod": "^4.6.5"
29
34
  },
30
35
  "publishConfig": {
31
36
  "access": "public"
@@ -34,9 +39,9 @@
34
39
  "dist"
35
40
  ],
36
41
  "devDependencies": {
37
- "typescript": "^5.8.3",
38
42
  "@types/node": "^24.0.3",
39
- "tsdown": "0.23.0"
43
+ "tsdown": "0.23.0",
44
+ "typescript": "^5.8.3"
40
45
  },
41
46
  "scripts": {
42
47
  "build": "tsdown",