lucid-extension-sdk 0.0.202 → 0.0.203

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/commandtypes.d.ts CHANGED
@@ -67,6 +67,7 @@ export declare const enum CommandName {
67
67
  GetEnvironmentConfig = "gec",
68
68
  GetItemPageId = "gip",
69
69
  GetItemsAt = "gia",
70
+ GetLLMContextFromItems = "llm",
70
71
  GetOAuthToken = "got",
71
72
  GetPackageSettings = "gps",
72
73
  GetProduct = "gpr",
@@ -326,6 +327,10 @@ export type CommandArgs = {
326
327
  query: GetItemsAtQuery;
327
328
  result: GetItemsAtResult;
328
329
  };
330
+ [CommandName.GetLLMContextFromItems]: {
331
+ query: GetLLMContextFromItemsQuery;
332
+ result: GetLLMContextFromItemsResult;
333
+ };
329
334
  [CommandName.GetOAuthToken]: {
330
335
  query: GetOAuthTokenQuery;
331
336
  result: GetOAuthTokenResult;
@@ -1013,6 +1018,17 @@ export type GetItemsAtQuery = {
1013
1018
  };
1014
1019
  /** IDs of the items found */
1015
1020
  export type GetItemsAtResult = string[];
1021
+ export type GetLLMContextFromItemsQuery = {
1022
+ /** Page ID to find closely-related items */
1023
+ 'p': string;
1024
+ /** List of item IDs to return LLM-readable context for */
1025
+ 'i': string[];
1026
+ };
1027
+ /**
1028
+ * A string in a format that LLMs like ChatGPT can easily understand, representing the content
1029
+ * of the items specified as well as their immediate context if necessary
1030
+ */
1031
+ export type GetLLMContextFromItemsResult = string;
1016
1032
  export type GetReferenceKeyQuery = {
1017
1033
  /** ID of the LucidElement to read a reference key from, or undefined to read from the LucidDocument */
1018
1034
  'id'?: string | undefined;
package/commandtypes.js CHANGED
@@ -45,6 +45,7 @@ exports.commandTitles = new Map([
45
45
  ["gec" /* CommandName.GetEnvironmentConfig */, 'GetEnvironmentConfig'],
46
46
  ["gip" /* CommandName.GetItemPageId */, 'GetItemPageId'],
47
47
  ["gia" /* CommandName.GetItemsAt */, 'GetItemsAt'],
48
+ ["llm" /* CommandName.GetLLMContextFromItems */, 'GetLLMContextFromItems'],
48
49
  ["got" /* CommandName.GetOAuthToken */, 'GetOAuthToken'],
49
50
  ["gps" /* CommandName.GetPackageSettings */, 'GetPackageSettings'],
50
51
  ["gpr" /* CommandName.GetProduct */, 'GetProduct'],
@@ -7,6 +7,7 @@ import { RuleProxy } from './documentelement/ruleproxy';
7
7
  import { ElementProxy } from './elementproxy';
8
8
  import { GroupProxy } from './groupproxy';
9
9
  import { ImageDefinition } from './imagedefinition';
10
+ import { ItemProxy } from './itemproxy';
10
11
  import { LineDefinition } from './linedefinition';
11
12
  import { LineProxy } from './lineproxy';
12
13
  import { MapProxy } from './mapproxy';
@@ -107,4 +108,10 @@ export declare class PageProxy extends ElementProxy {
107
108
  * @param links links to be imported onto the canvas as link unfurl blocks
108
109
  */
109
110
  importLinks(links: string[]): Promise<void>;
111
+ /**
112
+ * @param items
113
+ * @returns A string representing the content of the items provided, including immediate surrounding context if
114
+ * necessary, in a format that is easily understandable by LLMs like ChatGPT.
115
+ */
116
+ getLLMContextForItems(items: ItemProxy[]): string;
110
117
  }
@@ -162,5 +162,18 @@ class PageProxy extends elementproxy_1.ElementProxy {
162
162
  async importLinks(links) {
163
163
  return await this.client.sendCommand("il" /* CommandName.ImportLinks */, { 'p': this.id, 'l': links });
164
164
  }
165
+ /**
166
+ * @param items
167
+ * @returns A string representing the content of the items provided, including immediate surrounding context if
168
+ * necessary, in a format that is easily understandable by LLMs like ChatGPT.
169
+ */
170
+ getLLMContextForItems(items) {
171
+ //We don't check that the items are on this page here; that is done in the implementation
172
+ //of the API command. It would be a lot of extra API calls for no benefit.
173
+ return this.client.sendCommand("llm" /* CommandName.GetLLMContextFromItems */, {
174
+ 'p': this.id,
175
+ 'i': items.map((item) => item.id),
176
+ });
177
+ }
165
178
  }
166
179
  exports.PageProxy = PageProxy;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lucid-extension-sdk",
3
- "version": "0.0.202",
3
+ "version": "0.0.203",
4
4
  "description": "Utility classes for writing Lucid Software editor extensions",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",