@nesso-how/plugin 0.6.0 → 0.8.0

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.
@@ -167,6 +167,9 @@ type NessoOperation = {
167
167
  } | {
168
168
  readonly kind: 'preferences.locale';
169
169
  readonly value: Locale;
170
+ } | {
171
+ readonly kind: 'preferences.relationGroups';
172
+ readonly value: boolean;
170
173
  } | {
171
174
  readonly kind: 'preferences.panels';
172
175
  readonly value: PanelSizes;
@@ -207,11 +210,14 @@ type Preferences = {
207
210
  readonly locale?: Locale;
208
211
  readonly introSeen?: boolean;
209
212
  readonly mcpEnabled?: boolean;
213
+ readonly disabledBundledActionPlugins?: readonly string[];
214
+ readonly canvasTabOrder?: readonly string[];
210
215
  readonly activeVocabId: string;
211
216
  readonly activeRendererId: string;
212
217
  readonly activeThemeId: string;
213
218
  readonly panels: PanelSizes;
214
219
  readonly inspectorTab?: 'details' | 'chat';
220
+ readonly relationGroups?: boolean;
215
221
  readonly collapsedSections?: readonly SectionId[];
216
222
  };
217
223
  type NessoState = {
@@ -302,30 +308,6 @@ declare const themeDefinition: z.ZodObject<{
302
308
  'radius-object': z.ZodNumber;
303
309
  'duration-state': z.ZodNumber;
304
310
  }, z.core.$strict>;
305
- fonts: z.ZodObject<{
306
- sans: z.ZodObject<{
307
- faces: z.ZodArray<z.ZodObject<{
308
- path: z.ZodString;
309
- weight: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
310
- style: z.ZodEnum<{
311
- italic: "italic";
312
- normal: "normal";
313
- }>;
314
- unicodeRange: z.ZodOptional<z.ZodArray<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>>;
315
- }, z.core.$strict>>;
316
- }, z.core.$strict>;
317
- mono: z.ZodObject<{
318
- faces: z.ZodArray<z.ZodObject<{
319
- path: z.ZodString;
320
- weight: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
321
- style: z.ZodEnum<{
322
- italic: "italic";
323
- normal: "normal";
324
- }>;
325
- unicodeRange: z.ZodOptional<z.ZodArray<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>>;
326
- }, z.core.$strict>>;
327
- }, z.core.$strict>;
328
- }, z.core.$strict>;
329
311
  }, z.core.$strict>;
330
312
  type ThemeDefinition = DeepReadonly<z.infer<typeof themeDefinition>>;
331
313
  type Definition = ThemeDefinition | VocabDefinition;
@@ -348,17 +330,33 @@ declare class PluginError extends NessoError {
348
330
  }
349
331
  declare function parseOrThrow(schema: ZodType, value: unknown, prefix?: string): any;
350
332
  //#endregion
333
+ //#region src/images.d.ts
334
+ declare const imageRenderOptions: z.ZodObject<{
335
+ format: z.ZodLiteral<"png">;
336
+ scale: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<2>, z.ZodLiteral<4>]>>;
337
+ }, z.core.$strict>;
338
+ declare const renderedImage: z.ZodObject<{
339
+ mediaType: z.ZodLiteral<"image/png">;
340
+ base64: z.ZodString;
341
+ }, z.core.$strict>;
342
+ type ImageRenderOptions = Readonly<z.infer<typeof imageRenderOptions>>;
343
+ type RenderedImage = Readonly<z.infer<typeof renderedImage>>;
344
+ //#endregion
351
345
  //#region src/files.d.ts
352
346
  declare const fileTextLimit: number;
353
347
  declare const fileOpenOptions: z.ZodObject<{
354
348
  extensions: z.ZodArray<z.ZodString>;
355
349
  mimeTypes: z.ZodArray<z.ZodString>;
356
350
  }, z.core.$strict>;
357
- declare const fileSaveOptions: z.ZodObject<{
351
+ declare const fileSaveOptions: z.ZodUnion<readonly [z.ZodObject<{
358
352
  name: z.ZodString;
359
353
  mediaType: z.ZodString;
360
354
  text: z.ZodString;
361
- }, z.core.$strict>;
355
+ }, z.core.$strict>, z.ZodObject<{
356
+ name: z.ZodString;
357
+ mediaType: z.ZodString;
358
+ base64: z.ZodString;
359
+ }, z.core.$strict>]>;
362
360
  declare const fileOpenResult: z.ZodNullable<z.ZodObject<{
363
361
  name: z.ZodString;
364
362
  mediaType: z.ZodString;
@@ -381,13 +379,32 @@ declare const pluginStorageLimits: {
381
379
  type JsonValue = null | string | number | boolean | readonly JsonValue[] | {
382
380
  readonly [key: string]: JsonValue;
383
381
  };
382
+ declare const pluginStorageScope: z.ZodDiscriminatedUnion<[z.ZodObject<{
383
+ kind: z.ZodLiteral<"concept">;
384
+ id: z.ZodString;
385
+ }, z.core.$strict>, z.ZodObject<{
386
+ kind: z.ZodLiteral<"view">;
387
+ id: z.ZodString;
388
+ }, z.core.$strict>], "kind">;
384
389
  declare const pluginStorageKey: z.ZodObject<{
385
390
  key: z.ZodString;
386
- conceptId: z.ZodOptional<z.ZodString>;
391
+ scope: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
392
+ kind: z.ZodLiteral<"concept">;
393
+ id: z.ZodString;
394
+ }, z.core.$strict>, z.ZodObject<{
395
+ kind: z.ZodLiteral<"view">;
396
+ id: z.ZodString;
397
+ }, z.core.$strict>], "kind">>;
387
398
  }, z.core.$strict>;
388
399
  declare const pluginStorageRecord: z.ZodObject<{
389
400
  key: z.ZodString;
390
- conceptId: z.ZodOptional<z.ZodString>;
401
+ scope: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
402
+ kind: z.ZodLiteral<"concept">;
403
+ id: z.ZodString;
404
+ }, z.core.$strict>, z.ZodObject<{
405
+ kind: z.ZodLiteral<"view">;
406
+ id: z.ZodString;
407
+ }, z.core.$strict>], "kind">>;
391
408
  value: z.ZodPipe<z.ZodCustom<JsonValue, JsonValue>, z.ZodTransform<string | number | boolean | readonly JsonValue[] | {
392
409
  readonly [key: string]: JsonValue;
393
410
  } | null, JsonValue>>;
@@ -396,7 +413,13 @@ declare const pluginStorageSnapshot: z.ZodObject<{
396
413
  revision: z.ZodNumber;
397
414
  records: z.ZodArray<z.ZodObject<{
398
415
  key: z.ZodString;
399
- conceptId: z.ZodOptional<z.ZodString>;
416
+ scope: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
417
+ kind: z.ZodLiteral<"concept">;
418
+ id: z.ZodString;
419
+ }, z.core.$strict>, z.ZodObject<{
420
+ kind: z.ZodLiteral<"view">;
421
+ id: z.ZodString;
422
+ }, z.core.$strict>], "kind">>;
400
423
  value: z.ZodPipe<z.ZodCustom<JsonValue, JsonValue>, z.ZodTransform<string | number | boolean | readonly JsonValue[] | {
401
424
  readonly [key: string]: JsonValue;
402
425
  } | null, JsonValue>>;
@@ -404,10 +427,11 @@ declare const pluginStorageSnapshot: z.ZodObject<{
404
427
  }, z.core.$strict>;
405
428
  type PluginStorageRecord = DeepReadonly<z.infer<typeof pluginStorageRecord>>;
406
429
  type PluginStorageKey = DeepReadonly<z.infer<typeof pluginStorageKey>>;
430
+ type PluginStorageScope = DeepReadonly<z.infer<typeof pluginStorageScope>>;
407
431
  type PluginStorage = {
408
432
  readonly list: () => Promise<readonly PluginStorageRecord[]>;
409
- readonly set: (key: string, value: PluginStorageRecord['value'], conceptId?: string) => Promise<boolean>;
410
- readonly delete: (key: string, conceptId?: string) => Promise<boolean>;
433
+ readonly set: (key: string, value: PluginStorageRecord['value'], scope?: PluginStorageScope) => Promise<boolean>;
434
+ readonly delete: (key: string, scope?: PluginStorageScope) => Promise<boolean>;
411
435
  };
412
436
  declare function parsePluginStorageSnapshot(value: unknown): DeepReadonly<z.infer<typeof pluginStorageSnapshot>>;
413
437
  declare function parsePluginStorageRecord(value: unknown): PluginStorageRecord;
@@ -416,9 +440,6 @@ declare function parsePluginStorageKey(value: unknown): PluginStorageKey;
416
440
  //#region src/data.d.ts
417
441
  declare function checkMessageSize(value: unknown, limit: number, maximumDepth?: number): void;
418
442
  //#endregion
419
- //#region src/theme-fonts.d.ts
420
- declare const fontFaces: (ranges: Record<string, string>, stem: string, weight: [number, number]) => ThemeDefinition['fonts']['sans'];
421
- //#endregion
422
443
  //#region src/runtime.d.ts
423
444
  declare const runtimeLimits: {
424
445
  readonly request: number;
@@ -472,7 +493,7 @@ type PluginI18n = DeepReadonly<{
472
493
  }>;
473
494
  declare function parsePluginI18n(value: unknown): PluginI18n;
474
495
  declare const manifest: z.ZodDiscriminatedUnion<[z.ZodObject<{
475
- apiVersion: z.ZodLiteral<1>;
496
+ apiVersion: z.ZodLiteral<3>;
476
497
  kind: z.ZodLiteral<"actions">;
477
498
  entry: z.ZodString;
478
499
  writes: z.ZodArray<z.ZodEnum<{
@@ -495,12 +516,13 @@ declare const manifest: z.ZodDiscriminatedUnion<[z.ZodObject<{
495
516
  }>>;
496
517
  capabilities: z.ZodArray<z.ZodEnum<{
497
518
  files: "files";
519
+ images: "images";
498
520
  notifications: "notifications";
499
521
  storage: "storage";
500
522
  ui: "ui";
501
523
  }>>;
502
524
  }, z.core.$strict>, ...z.ZodObject<{
503
- apiVersion: z.ZodLiteral<1>;
525
+ apiVersion: z.ZodLiteral<3>;
504
526
  kind: z.ZodLiteral<"theme" | "vocab">;
505
527
  entry: z.ZodString;
506
528
  writes: z.ZodTuple<[], null>;
@@ -678,7 +700,13 @@ declare const message: z.ZodUnion<readonly [z.ZodDiscriminatedUnion<[z.ZodObject
678
700
  method: z.ZodLiteral<"storage.set">;
679
701
  params: z.ZodObject<{
680
702
  key: z.ZodString;
681
- conceptId: z.ZodOptional<z.ZodString>;
703
+ scope: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
704
+ kind: z.ZodLiteral<"concept">;
705
+ id: z.ZodString;
706
+ }, z.core.$strict>, z.ZodObject<{
707
+ kind: z.ZodLiteral<"view">;
708
+ id: z.ZodString;
709
+ }, z.core.$strict>], "kind">>;
682
710
  value: z.ZodPipe<z.ZodCustom<string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | /*elided*/ any | {
683
711
  readonly [key: string]: string | number | boolean | /*elided*/ any | /*elided*/ any | null;
684
712
  } | null)[] | {
@@ -785,7 +813,13 @@ declare const message: z.ZodUnion<readonly [z.ZodDiscriminatedUnion<[z.ZodObject
785
813
  method: z.ZodLiteral<"storage.delete">;
786
814
  params: z.ZodObject<{
787
815
  key: z.ZodString;
788
- conceptId: z.ZodOptional<z.ZodString>;
816
+ scope: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
817
+ kind: z.ZodLiteral<"concept">;
818
+ id: z.ZodString;
819
+ }, z.core.$strict>, z.ZodObject<{
820
+ kind: z.ZodLiteral<"view">;
821
+ id: z.ZodString;
822
+ }, z.core.$strict>], "kind">>;
789
823
  revision: z.ZodNumber;
790
824
  }, z.core.$strict>;
791
825
  }, z.core.$strict>, z.ZodObject<{
@@ -823,10 +857,23 @@ declare const message: z.ZodUnion<readonly [z.ZodDiscriminatedUnion<[z.ZodObject
823
857
  id: z.ZodNumber;
824
858
  contextId: z.ZodString;
825
859
  method: z.ZodLiteral<"files.save">;
826
- params: z.ZodObject<{
860
+ params: z.ZodUnion<readonly [z.ZodObject<{
827
861
  name: z.ZodString;
828
862
  mediaType: z.ZodString;
829
863
  text: z.ZodString;
864
+ }, z.core.$strict>, z.ZodObject<{
865
+ name: z.ZodString;
866
+ mediaType: z.ZodString;
867
+ base64: z.ZodString;
868
+ }, z.core.$strict>]>;
869
+ }, z.core.$strict>, z.ZodObject<{
870
+ type: z.ZodLiteral<"request">;
871
+ id: z.ZodNumber;
872
+ contextId: z.ZodString;
873
+ method: z.ZodLiteral<"images.renderView">;
874
+ params: z.ZodObject<{
875
+ format: z.ZodLiteral<"png">;
876
+ scale: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<2>, z.ZodLiteral<4>]>>;
830
877
  }, z.core.$strict>;
831
878
  }, z.core.$strict>], "method">, z.ZodObject<{
832
879
  type: z.ZodLiteral<"panel-ready">;
@@ -950,6 +997,9 @@ type ActionContext = {
950
997
  }>;
951
998
  };
952
999
  readonly storage: PluginStorage;
1000
+ readonly images: {
1001
+ readonly renderView: (options: ImageRenderOptions) => Promise<RenderedImage>;
1002
+ };
953
1003
  readonly signal: AbortSignal;
954
1004
  };
955
1005
  declare function parsePluginMessage(value: unknown): z.infer<typeof message>;
@@ -960,4 +1010,4 @@ declare function createPluginClient(port: MessagePort, initial: unknown): {
960
1010
  getPresentation: () => Pick<ActionState, 'theme' | 'locale'>;
961
1011
  };
962
1012
  //#endregion
963
- export { FileOpenOptions as A, ThemeDefinition as B, PluginStorage as C, parsePluginStorageRecord as D, parsePluginStorageKey as E, PluginError as F, SavedView as G, themeColors as H, parseOrThrow as I, Selection as K, LocalizedText as L, FileSaveOptions as M, fileTextLimit as N, parsePluginStorageSnapshot as O, parseFileOptions as P, resolvePluginText as R, checkMessageSize as S, PluginStorageRecord as T, GraphSnapshot as U, parseDefinition as V, NessoOperation as W, parsePluginMessage as _, ActionDescriptor as a, themeTokens as b, PluginI18n as c, badgeLimits as d, createPluginClient as f, parsePluginManifest as g, parsePluginI18n as h, ActionContribution as i, FileOpenResult as j, pluginStorageLimits as k, PluginManifest as l, parseContribution as m, ActionBadgeResult as n, ActionIconName as o, parseActionBadgeResult as p, VocabDefinition as q, ActionContext as r, ActionState as s, ActionBadgeInput as t, actionIconNames as u, runtimeLimits as v, PluginStorageKey as w, fontFaces as x, sha256Hex as y, Definition as z };
1013
+ export { FileOpenOptions as A, resolvePluginText as B, PluginStorageKey as C, parsePluginStorageRecord as D, parsePluginStorageKey as E, ImageRenderOptions as F, GraphSnapshot as G, ThemeDefinition as H, RenderedImage as I, Selection as J, NessoOperation as K, PluginError as L, FileSaveOptions as M, fileTextLimit as N, parsePluginStorageSnapshot as O, parseFileOptions as P, parseOrThrow as R, PluginStorage as S, PluginStorageScope as T, parseDefinition as U, Definition as V, themeColors as W, VocabDefinition as Y, parsePluginMessage as _, ActionDescriptor as a, themeTokens as b, PluginI18n as c, badgeLimits as d, createPluginClient as f, parsePluginManifest as g, parsePluginI18n as h, ActionContribution as i, FileOpenResult as j, pluginStorageLimits as k, PluginManifest as l, parseContribution as m, ActionBadgeResult as n, ActionIconName as o, parseActionBadgeResult as p, SavedView as q, ActionContext as r, ActionState as s, ActionBadgeInput as t, actionIconNames as u, runtimeLimits as v, PluginStorageRecord as w, checkMessageSize as x, sha256Hex as y, LocalizedText as z };
@@ -27,6 +27,17 @@ const boundText = (text, limit) => {
27
27
  }
28
28
  return result;
29
29
  };
30
+ const pluginErrorCodes = [
31
+ "invalid-input",
32
+ "denied",
33
+ "stale-state",
34
+ "stale-context",
35
+ "unavailable",
36
+ "cancelled",
37
+ "timeout",
38
+ "closed",
39
+ "failed"
40
+ ];
30
41
  var PluginError = class extends NessoError {
31
42
  name = "PluginError";
32
43
  code;
@@ -58,7 +69,62 @@ function parseOrThrow(schema, value, prefix = "") {
58
69
  return parsed.data;
59
70
  }
60
71
  //#endregion
72
+ //#region src/files.ts
73
+ const fileTextLimit = 16777216;
74
+ const mediaType = z.string().max(128).regex(/^[\w!#$&^.+-]+\/[\w!#$&^.+-]+$/);
75
+ const fileOpenOptions = z.strictObject({
76
+ extensions: z.array(z.string().regex(/^[a-zA-Z0-9]{1,16}$/)).min(1).max(16),
77
+ mimeTypes: z.array(mediaType).max(16)
78
+ });
79
+ const fileFields = {
80
+ name: z.string().trim().min(1).max(240).regex(/^[^/\\]+$/).refine((value) => value !== "." && value !== ".." && [...value].every((character) => character.charCodeAt(0) >= 32 && character.charCodeAt(0) !== 127)),
81
+ mediaType
82
+ };
83
+ const fileText = z.string().max(fileTextLimit).refine((value) => new TextEncoder().encode(value).byteLength <= fileTextLimit, "File text byte limit exceeded");
84
+ const fileBase64 = z.string().max(4 * Math.ceil(fileTextLimit / 3)).regex(/^[A-Za-z0-9+/]*={0,2}$/).refine((value) => {
85
+ const size = value.length / 4 * 3 - (value.endsWith("==") ? 2 : value.endsWith("=") ? 1 : 0);
86
+ try {
87
+ return value.length % 4 === 0 && size <= 16777216 && btoa(atob(value)) === value;
88
+ } catch {
89
+ return false;
90
+ }
91
+ }, "Invalid base64 or file byte limit exceeded");
92
+ const fileSaveOptions = z.union([z.strictObject({
93
+ ...fileFields,
94
+ text: fileText
95
+ }), z.strictObject({
96
+ ...fileFields,
97
+ base64: fileBase64
98
+ })]);
99
+ const fileOpenResult = z.strictObject({
100
+ name: z.string().min(1).max(240),
101
+ mediaType,
102
+ text: fileText
103
+ }).nullable();
104
+ function parseFileOptions(kind, value) {
105
+ return parseOrThrow(kind === "open" ? fileOpenOptions : fileSaveOptions, value);
106
+ }
107
+ //#endregion
108
+ //#region src/images.ts
109
+ const imageRenderOptions = z.strictObject({
110
+ format: z.literal("png"),
111
+ scale: z.union([z.literal(2), z.literal(4)]).optional()
112
+ });
113
+ const renderedImage = z.strictObject({
114
+ mediaType: z.literal("image/png"),
115
+ base64: fileBase64
116
+ });
117
+ //#endregion
61
118
  //#region ../schema/dist/core.js
119
+ const conceptKeys = [
120
+ "@id",
121
+ "rdfs:label",
122
+ "rdfs:comment",
123
+ "position",
124
+ "color",
125
+ "bold",
126
+ "italic"
127
+ ];
62
128
  const newIri = () => `urn:uuid:${crypto.randomUUID()}`;
63
129
  const isAbsoluteIri = (value) => typeof value === "string" && /^[a-z][a-z0-9+.-]*:/i.test(value);
64
130
  const relationKey = ({ source, predicate, target }) => JSON.stringify([
@@ -83,7 +149,7 @@ const conceptSchema = z.strictObject({
83
149
  position: positionSchema
84
150
  });
85
151
  const relationTypeSchema = z.strictObject({
86
- id: iriSchema,
152
+ id: iriSchema.refine((id) => !conceptKeys.includes(id), "Reserved concept property IRI"),
87
153
  label: z.string()
88
154
  });
89
155
  const relationSchema = z.strictObject({
@@ -197,13 +263,6 @@ const themeColors = [
197
263
  ];
198
264
  const contributionId = z.string().max(64).regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/);
199
265
  const color = z.string().regex(/^#[\da-fA-F]{6}([\da-fA-F]{2})?$/);
200
- const fontFace = z.strictObject({
201
- path: z.string().max(240).regex(/^(?:[\w-]+\/)*[\w-]+\.woff2$/),
202
- weight: z.tuple([z.number().int().min(1).max(1e3), z.number().int().min(1).max(1e3)]).refine(([min, max]) => min <= max),
203
- style: z.enum(["normal", "italic"]),
204
- unicodeRange: z.array(z.tuple([z.number().int().min(0).max(1114111), z.number().int().min(0).max(1114111)]).refine(([min, max]) => min <= max)).min(1).max(64).optional()
205
- });
206
- const font = z.strictObject({ faces: z.array(fontFace).max(32) });
207
266
  const luminance = (value) => {
208
267
  const linear = [
209
268
  1,
@@ -221,12 +280,8 @@ const themeDefinition = z.strictObject({
221
280
  "radius-control": z.number().min(0).max(16),
222
281
  "radius-object": z.number().min(0).max(16),
223
282
  "duration-state": z.number().int().min(0).max(300)
224
- }),
225
- fonts: z.strictObject({
226
- sans: font,
227
- mono: font
228
283
  })
229
- }).superRefine(({ colors, fonts }, context) => {
284
+ }).superRefine(({ colors }, context) => {
230
285
  for (const key of [
231
286
  "background",
232
287
  "canvas",
@@ -248,11 +303,6 @@ const themeDefinition = z.strictObject({
248
303
  path: ["colors", "primary-foreground"],
249
304
  message: "Insufficient primary contrast"
250
305
  });
251
- if (fonts.sans.faces.length + fonts.mono.faces.length > 32) context.addIssue({
252
- code: "custom",
253
- path: ["fonts"],
254
- message: "Font face limit exceeded"
255
- });
256
306
  });
257
307
  const vocabRelationType = z.strictObject({
258
308
  id: z.string().min(1).max(2048),
@@ -290,27 +340,6 @@ function parseDefinition(kind, value) {
290
340
  return parseOrThrow(kind === "theme" ? themeDefinition : vocabDefinition, value);
291
341
  }
292
342
  //#endregion
293
- //#region src/files.ts
294
- const fileTextLimit = 16777216;
295
- const mediaType = z.string().max(128).regex(/^[\w!#$&^.+-]+\/[\w!#$&^.+-]+$/);
296
- const fileOpenOptions = z.strictObject({
297
- extensions: z.array(z.string().regex(/^[a-zA-Z0-9]{1,16}$/)).min(1).max(16),
298
- mimeTypes: z.array(mediaType).max(16)
299
- });
300
- const fileSaveOptions = z.strictObject({
301
- name: z.string().trim().min(1).max(240).regex(/^[^/\\]+$/).refine((value) => value !== "." && value !== ".." && [...value].every((character) => character.charCodeAt(0) >= 32 && character.charCodeAt(0) !== 127)),
302
- mediaType,
303
- text: z.string().max(fileTextLimit).refine((value) => new TextEncoder().encode(value).byteLength <= fileTextLimit, "File text byte limit exceeded")
304
- });
305
- const fileOpenResult = z.strictObject({
306
- name: z.string().min(1).max(240),
307
- mediaType,
308
- text: fileSaveOptions.shape.text
309
- }).nullable();
310
- function parseFileOptions(kind, value) {
311
- return parseOrThrow(kind === "open" ? fileOpenOptions : fileSaveOptions, value);
312
- }
313
- //#endregion
314
343
  //#region ../core/dist/commands.js
315
344
  function createWriteCommands(applyOperations, created) {
316
345
  return {
@@ -460,33 +489,41 @@ const resolvePluginText = (value, locale) => value[locale] ?? value.en;
460
489
  //#endregion
461
490
  //#region src/data.ts
462
491
  function checkMessageSize(value, limit, maximumDepth = 32) {
492
+ const exceeded = () => new PluginError("invalid-input", [{
493
+ path: "message",
494
+ message: "Message limit exceeded"
495
+ }]);
496
+ let size = 0;
463
497
  const visit = (value, depth) => {
464
498
  if (depth > maximumDepth) throw new PluginError("invalid-input", [{
465
499
  path: "message",
466
500
  message: "Nesting limit exceeded"
467
501
  }]);
502
+ if (value === void 0) return;
503
+ size += typeof value === "string" ? value.length + 1 : 1;
504
+ if (size > limit) throw exceeded();
468
505
  if (value === null) return;
469
506
  if (typeof value === "object") {
470
- if (!Array.isArray(value) && Object.getPrototypeOf(value) !== Object.prototype) throw new PluginError("invalid-input", [{
507
+ const array = Array.isArray(value);
508
+ if (!array && Object.getPrototypeOf(value) !== Object.prototype) throw new PluginError("invalid-input", [{
471
509
  path: "message",
472
510
  message: "Expected plain data"
473
511
  }]);
474
- for (const item of Object.values(value)) visit(item, depth + 1);
512
+ for (const [key, item] of Object.entries(value)) {
513
+ if (!array && item !== void 0) size += key.length;
514
+ visit(item, depth + 1);
515
+ }
475
516
  } else if (![
476
517
  "string",
477
518
  "number",
478
- "boolean",
479
- "undefined"
519
+ "boolean"
480
520
  ].includes(typeof value) || typeof value === "number" && !Number.isFinite(value)) throw new PluginError("invalid-input", [{
481
521
  path: "message",
482
522
  message: "Expected serializable data"
483
523
  }]);
484
524
  };
485
525
  visit(value, 0);
486
- if (new TextEncoder().encode(JSON.stringify(value)).byteLength > limit) throw new PluginError("invalid-input", [{
487
- path: "message",
488
- message: "Message limit exceeded"
489
- }]);
526
+ if (new TextEncoder().encode(JSON.stringify(value)).byteLength > limit) throw exceeded();
490
527
  }
491
528
  //#endregion
492
529
  //#region src/storage.ts
@@ -506,9 +543,16 @@ const isJsonValue = (value, depth = 0) => {
506
543
  if (Array.isArray(value)) return Reflect.ownKeys(value).length === value.length + 1 && Array.from(value).every((item) => isJsonValue(item, depth + 1));
507
544
  return Object.getPrototypeOf(value) === Object.prototype && Reflect.ownKeys(value).length === Object.keys(value).length && Object.values(value).every((item) => isJsonValue(item, depth + 1));
508
545
  };
546
+ const pluginStorageScope = z.discriminatedUnion("kind", [z.strictObject({
547
+ kind: z.literal("concept"),
548
+ id: z.string().max(2048)
549
+ }), z.strictObject({
550
+ kind: z.literal("view"),
551
+ id: z.string().max(2048)
552
+ })]);
509
553
  const fields = {
510
554
  key: z.string().min(1).max(128),
511
- conceptId: z.string().max(2048).optional()
555
+ scope: pluginStorageScope.optional()
512
556
  };
513
557
  const pluginStorageKey = z.strictObject(fields);
514
558
  const pluginStorageRecord = z.strictObject({
@@ -542,17 +586,6 @@ function parsePluginStorageKey(value) {
542
586
  return parseOrThrow(pluginStorageKey, value);
543
587
  }
544
588
  //#endregion
545
- //#region src/theme-fonts.ts
546
- const fontFaces = (ranges, stem, weight) => ({ faces: Object.entries(ranges).map(([subset, intervals]) => ({
547
- path: `fonts/${stem.replace("{subset}", subset)}.woff2`,
548
- weight,
549
- style: "normal",
550
- unicodeRange: intervals.split(",").map((interval) => {
551
- const [from, to = from] = interval.slice(2).split("-");
552
- return [parseInt(from, 16), parseInt(to, 16)];
553
- })
554
- })) });
555
- //#endregion
556
589
  //#region src/runtime.ts
557
590
  const runtimeLimits = {
558
591
  request: 33554432,
@@ -752,7 +785,7 @@ function parsePluginI18n(value) {
752
785
  checkMessageSize(value, 65536);
753
786
  return parseOrThrow(pluginI18n, value, "i18n.");
754
787
  }
755
- const manifestFields = { apiVersion: z.literal(1) };
788
+ const manifestFields = { apiVersion: z.literal(3) };
756
789
  const jsEntry = z.string().max(240).regex(/^(?:[\w-]+\/)*[\w-]+\.js$/);
757
790
  const jsonEntry = z.string().max(240).regex(/^(?:[\w-]+\/)*[\w-]+\.json$/);
758
791
  const operationDeclarations = z.array(z.enum([
@@ -780,6 +813,7 @@ const manifest = z.discriminatedUnion("kind", [z.strictObject({
780
813
  writes: operationDeclarations,
781
814
  capabilities: z.array(z.enum([
782
815
  "files",
816
+ "images",
783
817
  "notifications",
784
818
  "storage",
785
819
  "ui"
@@ -848,20 +882,15 @@ const request = z.discriminatedUnion("method", [
848
882
  ...envelope,
849
883
  method: z.literal("files.save"),
850
884
  params: fileSaveOptions
885
+ }),
886
+ z.strictObject({
887
+ ...envelope,
888
+ method: z.literal("images.renderView"),
889
+ params: imageRenderOptions
851
890
  })
852
891
  ]);
853
892
  const wireError = z.strictObject({
854
- code: z.enum([
855
- "invalid-input",
856
- "denied",
857
- "stale-state",
858
- "stale-context",
859
- "unavailable",
860
- "cancelled",
861
- "timeout",
862
- "closed",
863
- "failed"
864
- ]),
893
+ code: z.enum(pluginErrorCodes),
865
894
  issues: z.array(z.strictObject({
866
895
  path: text(256),
867
896
  message: text(2048)
@@ -1004,7 +1033,8 @@ const results = {
1004
1033
  }),
1005
1034
  "notifications.notify": id,
1006
1035
  "files.open": fileOpenResult,
1007
- "files.save": z.strictObject({ saved: z.boolean() })
1036
+ "files.save": z.strictObject({ saved: z.boolean() }),
1037
+ "images.renderView": renderedImage
1008
1038
  };
1009
1039
  function parsePluginMessage(value) {
1010
1040
  checkMessageSize(value, runtimeLimits.request);
@@ -1171,23 +1201,24 @@ function createPluginClient(port, initial) {
1171
1201
  applyOperations
1172
1202
  },
1173
1203
  notifications: { notify: (value) => call("notifications.notify", value) },
1204
+ images: { renderView: (options) => call("images.renderView", options) },
1174
1205
  files: {
1175
1206
  open: (options) => call("files.open", options),
1176
1207
  save: (options) => call("files.save", options)
1177
1208
  },
1178
1209
  storage: {
1179
1210
  list: listStorage,
1180
- set: (key, value, conceptId) => mutateStorage("storage.set", conceptId === void 0 ? {
1211
+ set: (key, value, scope) => mutateStorage("storage.set", scope === void 0 ? {
1181
1212
  key,
1182
1213
  value
1183
1214
  } : {
1184
1215
  key,
1185
1216
  value,
1186
- conceptId
1217
+ scope
1187
1218
  }),
1188
- delete: (key, conceptId) => mutateStorage("storage.delete", conceptId === void 0 ? { key } : {
1219
+ delete: (key, scope) => mutateStorage("storage.delete", scope === void 0 ? { key } : {
1189
1220
  key,
1190
- conceptId
1221
+ scope
1191
1222
  })
1192
1223
  },
1193
1224
  signal: controller.signal
@@ -1200,4 +1231,4 @@ function createPluginClient(port, initial) {
1200
1231
  };
1201
1232
  }
1202
1233
  //#endregion
1203
- export { PluginError as C, themeColors as S, checkMessageSize as _, parseContribution as a, parseFileOptions as b, parsePluginMessage as c, themeTokens as d, fontFaces as f, pluginStorageLimits as g, parsePluginStorageSnapshot as h, parseActionBadgeResult as i, runtimeLimits as l, parsePluginStorageRecord as m, badgeLimits as n, parsePluginI18n as o, parsePluginStorageKey as p, createPluginClient as r, parsePluginManifest as s, actionIconNames as t, sha256Hex as u, resolvePluginText as v, parseOrThrow as w, parseDefinition as x, fileTextLimit as y };
1234
+ export { parseOrThrow as C, PluginError as S, resolvePluginText as _, parseContribution as a, fileTextLimit as b, parsePluginMessage as c, themeTokens as d, parsePluginStorageKey as f, checkMessageSize as g, pluginStorageLimits as h, parseActionBadgeResult as i, runtimeLimits as l, parsePluginStorageSnapshot as m, badgeLimits as n, parsePluginI18n as o, parsePluginStorageRecord as p, createPluginClient as r, parsePluginManifest as s, actionIconNames as t, sha256Hex as u, parseDefinition as v, parseFileOptions as x, themeColors as y };
package/dist/runtime.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { A as FileOpenOptions, D as parsePluginStorageRecord, E as parsePluginStorageKey, F as PluginError, H as themeColors, I as parseOrThrow, L as LocalizedText, M as FileSaveOptions, N as fileTextLimit, O as parsePluginStorageSnapshot, P as parseFileOptions, R as resolvePluginText, S as checkMessageSize, V as parseDefinition, _ as parsePluginMessage, a as ActionDescriptor, b as themeTokens, c as PluginI18n, d as badgeLimits, f as createPluginClient, g as parsePluginManifest, h as parsePluginI18n, i as ActionContribution, j as FileOpenResult, k as pluginStorageLimits, l as PluginManifest, m as parseContribution, n as ActionBadgeResult, o as ActionIconName, p as parseActionBadgeResult, r as ActionContext, s as ActionState, t as ActionBadgeInput, u as actionIconNames, v as runtimeLimits, x as fontFaces, y as sha256Hex, z as Definition } from "./runtime-BxtTAcko.js";
2
- export { ActionBadgeInput, ActionBadgeResult, ActionContext, ActionContribution, ActionDescriptor, ActionIconName, ActionState, type Definition, type FileOpenOptions, type FileOpenResult, type FileSaveOptions, type LocalizedText, PluginError, PluginI18n, PluginManifest, actionIconNames, badgeLimits, checkMessageSize, createPluginClient, fileTextLimit, fontFaces, parseActionBadgeResult, parseContribution, parseDefinition, parseFileOptions, parseOrThrow, parsePluginI18n, parsePluginManifest, parsePluginMessage, parsePluginStorageKey, parsePluginStorageRecord, parsePluginStorageSnapshot, pluginStorageLimits, resolvePluginText, runtimeLimits, sha256Hex, themeColors, themeTokens };
1
+ import { A as FileOpenOptions, B as resolvePluginText, D as parsePluginStorageRecord, E as parsePluginStorageKey, F as ImageRenderOptions, I as RenderedImage, L as PluginError, M as FileSaveOptions, N as fileTextLimit, O as parsePluginStorageSnapshot, P as parseFileOptions, R as parseOrThrow, U as parseDefinition, V as Definition, W as themeColors, _ as parsePluginMessage, a as ActionDescriptor, b as themeTokens, c as PluginI18n, d as badgeLimits, f as createPluginClient, g as parsePluginManifest, h as parsePluginI18n, i as ActionContribution, j as FileOpenResult, k as pluginStorageLimits, l as PluginManifest, m as parseContribution, n as ActionBadgeResult, o as ActionIconName, p as parseActionBadgeResult, r as ActionContext, s as ActionState, t as ActionBadgeInput, u as actionIconNames, v as runtimeLimits, x as checkMessageSize, y as sha256Hex, z as LocalizedText } from "./runtime-DCyJA620.js";
2
+ export { ActionBadgeInput, ActionBadgeResult, ActionContext, ActionContribution, ActionDescriptor, ActionIconName, ActionState, type Definition, type FileOpenOptions, type FileOpenResult, type FileSaveOptions, type ImageRenderOptions, type LocalizedText, PluginError, PluginI18n, PluginManifest, type RenderedImage, actionIconNames, badgeLimits, checkMessageSize, createPluginClient, fileTextLimit, parseActionBadgeResult, parseContribution, parseDefinition, parseFileOptions, parseOrThrow, parsePluginI18n, parsePluginManifest, parsePluginMessage, parsePluginStorageKey, parsePluginStorageRecord, parsePluginStorageSnapshot, pluginStorageLimits, resolvePluginText, runtimeLimits, sha256Hex, themeColors, themeTokens };
package/dist/runtime.js CHANGED
@@ -1 +1 @@
1
- export { C as PluginError, t as actionIconNames, n as badgeLimits, _ as checkMessageSize, r as createPluginClient, y as fileTextLimit, f as fontFaces, i as parseActionBadgeResult, a as parseContribution, x as parseDefinition, b as parseFileOptions, w as parseOrThrow, o as parsePluginI18n, s as parsePluginManifest, c as parsePluginMessage, p as parsePluginStorageKey, m as parsePluginStorageRecord, h as parsePluginStorageSnapshot, g as pluginStorageLimits, v as resolvePluginText, l as runtimeLimits, u as sha256Hex, S as themeColors, d as themeTokens } from "./runtime-BM45o1qi.js";
1
+ export { S as PluginError, t as actionIconNames, n as badgeLimits, g as checkMessageSize, r as createPluginClient, b as fileTextLimit, i as parseActionBadgeResult, a as parseContribution, v as parseDefinition, x as parseFileOptions, C as parseOrThrow, o as parsePluginI18n, s as parsePluginManifest, c as parsePluginMessage, f as parsePluginStorageKey, p as parsePluginStorageRecord, m as parsePluginStorageSnapshot, h as pluginStorageLimits, _ as resolvePluginText, l as runtimeLimits, u as sha256Hex, y as themeColors, d as themeTokens } from "./runtime-uvKgm2yV.js";
package/example/README.md CHANGED
@@ -1,39 +1,35 @@
1
1
  # Plugin Example
2
2
 
3
- The official Nesso plugin example: an **Uppercase labels** action and a React **Concept Quiz** with persistent progress. See [`src/index.ts`](src/index.ts) and [`src/Quiz.tsx`](src/Quiz.tsx).
3
+ Two actions built with the Nesso SDK:
4
+
5
+ - **Uppercase labels** changes concept labels in the current view. See [`src/index.ts`](src/index.ts).
6
+ - **Concept Quiz** uses React to quiz you on the view's relations and saves your progress. See [`src/Quiz.tsx`](src/Quiz.tsx).
4
7
 
5
8
  ## Install and try
6
9
 
7
- In the desktop app, open Settings → Plugins, search for `@nesso-how/plugin-example`, and install it. Approve its declared access to concept labels, interactive panels, and private storage. The panel example requires the SDK and app versions containing central-panel support; build from this checkout until that SDK release is published.
10
+ In the desktop app, open Settings → Plugins, search for `@nesso-how/plugin-example`, and install it. Approve access to concept labels, panels, and private storage.
8
11
 
9
12
  Run either action from a view's context menu in the Explorer, or from its actions in the Inspector with nothing selected.
10
13
 
11
14
  ## Build your own
12
15
 
13
- Copy this example into a separate project, then install dependencies and build:
16
+ Use Node.js 24. Copy this example into a separate project. Choose your own package name, update the metadata and action IDs/labels, and remove any permissions you do not use. Then install dependencies and build:
14
17
 
15
18
  ```sh
16
19
  npm install
17
20
  npm run build
18
21
  ```
19
22
 
20
- The Vite configuration bundles code and imported CSS into `dist/index.js`, leaving React and React DOM to Nesso. See the [UI contract](../README.md#action-ui) for runtime requirements.
23
+ The build runs TypeScript checks, then bundles code and CSS into `dist/index.js`. Nesso supplies React and React DOM at runtime. To typecheck without building, run `npm run check`.
21
24
 
22
- Choose your own package name, plugin metadata, and action IDs and labels before publishing.
25
+ See the SDK guide for [tests and package validation](../README.md#build-and-test) and [panel APIs and styling](../README.md#action-ui).
23
26
 
24
27
  ## Test an unpublished build
25
28
 
26
- Open `package.json` and `dist/index.js` in a text editor. In desktop DevTools, set `manifest` to the parsed package JSON and `compiledCode` to the bundled JavaScript as a string:
27
-
28
- ```ts
29
- const result = await window.nessoPlugins.propose(
30
- crypto.randomUUID(),
31
- {
32
- manifest,
33
- files: [{ path: manifest.nesso.entry, bytes: new TextEncoder().encode(compiledCode) }],
34
- },
35
- 'en',
36
- )
29
+ Follow the SDK guide to [connect your agent](../README.md#with-an-agent) and [install through MCP](../README.md#install-or-update-through-mcp). Pass your project's absolute root path to `propose_plugin`, not its `dist` directory:
30
+
31
+ ```json
32
+ { "directory": "/absolute/path/to/my-plugin" }
37
33
  ```
38
34
 
39
- Approve the Nesso access dialog. Installation persists. On success, `result.value` contains the installed package; it is `null` if approval is declined. Failures return `result.issues`. To replace a build, pass the installed package's `contentId` as the fourth argument; development proposals require fresh approval.
35
+ Approve the installation in Nesso when prompted. Rebuilding does not update the installed copy; use the SDK guide's replacement procedure for later builds. If the published example is already installed, your local copy needs a different package name.