@project-ajax/sdk 0.0.28

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.
Files changed (145) hide show
  1. package/README.md +22 -0
  2. package/dist/block.d.ts +321 -0
  3. package/dist/block.d.ts.map +1 -0
  4. package/dist/block.js +0 -0
  5. package/dist/builder.d.ts +12 -0
  6. package/dist/builder.d.ts.map +1 -0
  7. package/dist/builder.js +22 -0
  8. package/dist/capabilities/slashCommand.d.ts +56 -0
  9. package/dist/capabilities/slashCommand.d.ts.map +1 -0
  10. package/dist/capabilities/slashCommand.js +32 -0
  11. package/dist/capabilities/sync.d.ts +58 -0
  12. package/dist/capabilities/sync.d.ts.map +1 -0
  13. package/dist/capabilities/sync.js +26 -0
  14. package/dist/capabilities/tool.d.ts +69 -0
  15. package/dist/capabilities/tool.d.ts.map +1 -0
  16. package/dist/capabilities/tool.js +75 -0
  17. package/dist/capabilities/tool.test.d.ts +2 -0
  18. package/dist/capabilities/tool.test.d.ts.map +1 -0
  19. package/dist/cli/api/client.d.ts +185 -0
  20. package/dist/cli/api/client.d.ts.map +1 -0
  21. package/dist/cli/api/client.js +315 -0
  22. package/dist/cli/api/result.d.ts +43 -0
  23. package/dist/cli/api/result.d.ts.map +1 -0
  24. package/dist/cli/api/result.js +43 -0
  25. package/dist/cli/bin/cli.d.ts +3 -0
  26. package/dist/cli/bin/cli.d.ts.map +1 -0
  27. package/dist/cli/bin/cli.js +5 -0
  28. package/dist/cli/commands/auth.d.ts +2 -0
  29. package/dist/cli/commands/auth.d.ts.map +1 -0
  30. package/dist/cli/commands/auth.impl.d.ts +10 -0
  31. package/dist/cli/commands/auth.impl.d.ts.map +1 -0
  32. package/dist/cli/commands/auth.impl.js +68 -0
  33. package/dist/cli/commands/auth.js +71 -0
  34. package/dist/cli/commands/bundle.d.ts +2 -0
  35. package/dist/cli/commands/bundle.d.ts.map +1 -0
  36. package/dist/cli/commands/bundle.impl.d.ts +2 -0
  37. package/dist/cli/commands/bundle.impl.d.ts.map +1 -0
  38. package/dist/cli/commands/bundle.impl.js +21 -0
  39. package/dist/cli/commands/bundle.js +23 -0
  40. package/dist/cli/commands/capabilities.d.ts +2 -0
  41. package/dist/cli/commands/capabilities.d.ts.map +1 -0
  42. package/dist/cli/commands/capabilities.impl.d.ts +3 -0
  43. package/dist/cli/commands/capabilities.impl.d.ts.map +1 -0
  44. package/dist/cli/commands/capabilities.impl.js +40 -0
  45. package/dist/cli/commands/capabilities.js +24 -0
  46. package/dist/cli/commands/deploy.d.ts +3 -0
  47. package/dist/cli/commands/deploy.d.ts.map +1 -0
  48. package/dist/cli/commands/deploy.impl.d.ts +2 -0
  49. package/dist/cli/commands/deploy.impl.d.ts.map +1 -0
  50. package/dist/cli/commands/deploy.impl.js +31 -0
  51. package/dist/cli/commands/deploy.js +16 -0
  52. package/dist/cli/commands/exec.d.ts +3 -0
  53. package/dist/cli/commands/exec.d.ts.map +1 -0
  54. package/dist/cli/commands/exec.impl.d.ts +7 -0
  55. package/dist/cli/commands/exec.impl.d.ts.map +1 -0
  56. package/dist/cli/commands/exec.impl.js +122 -0
  57. package/dist/cli/commands/exec.js +30 -0
  58. package/dist/cli/commands/runs.d.ts +2 -0
  59. package/dist/cli/commands/runs.d.ts.map +1 -0
  60. package/dist/cli/commands/runs.impl.d.ts +4 -0
  61. package/dist/cli/commands/runs.impl.d.ts.map +1 -0
  62. package/dist/cli/commands/runs.impl.js +71 -0
  63. package/dist/cli/commands/runs.js +45 -0
  64. package/dist/cli/commands/secrets.d.ts +2 -0
  65. package/dist/cli/commands/secrets.d.ts.map +1 -0
  66. package/dist/cli/commands/secrets.impl.d.ts +5 -0
  67. package/dist/cli/commands/secrets.impl.d.ts.map +1 -0
  68. package/dist/cli/commands/secrets.impl.js +93 -0
  69. package/dist/cli/commands/secrets.js +64 -0
  70. package/dist/cli/config.d.ts +38 -0
  71. package/dist/cli/config.d.ts.map +1 -0
  72. package/dist/cli/config.js +133 -0
  73. package/dist/cli/context.d.ts +15 -0
  74. package/dist/cli/context.d.ts.map +1 -0
  75. package/dist/cli/context.js +16 -0
  76. package/dist/cli/deploy.d.ts +25 -0
  77. package/dist/cli/deploy.d.ts.map +1 -0
  78. package/dist/cli/deploy.js +101 -0
  79. package/dist/cli/flags.d.ts +16 -0
  80. package/dist/cli/flags.d.ts.map +1 -0
  81. package/dist/cli/flags.js +24 -0
  82. package/dist/cli/handler.d.ts +14 -0
  83. package/dist/cli/handler.d.ts.map +1 -0
  84. package/dist/cli/handler.js +30 -0
  85. package/dist/cli/routes.d.ts +2 -0
  86. package/dist/cli/routes.d.ts.map +1 -0
  87. package/dist/cli/routes.js +44 -0
  88. package/dist/cli/utils/array.d.ts +2 -0
  89. package/dist/cli/utils/array.d.ts.map +1 -0
  90. package/dist/cli/utils/array.js +10 -0
  91. package/dist/cli/utils/string.d.ts +2 -0
  92. package/dist/cli/utils/string.d.ts.map +1 -0
  93. package/dist/cli/utils/string.js +12 -0
  94. package/dist/cli/writer.d.ts +48 -0
  95. package/dist/cli/writer.d.ts.map +1 -0
  96. package/dist/cli/writer.js +73 -0
  97. package/dist/error.d.ts +8 -0
  98. package/dist/error.d.ts.map +1 -0
  99. package/dist/error.js +11 -0
  100. package/dist/index.d.ts +4 -0
  101. package/dist/index.d.ts.map +1 -0
  102. package/dist/index.js +8 -0
  103. package/dist/schema.d.ts +45 -0
  104. package/dist/schema.d.ts.map +1 -0
  105. package/dist/schema.js +14 -0
  106. package/dist/types.d.ts +11 -0
  107. package/dist/types.d.ts.map +1 -0
  108. package/dist/types.js +0 -0
  109. package/package.json +79 -0
  110. package/src/block.ts +529 -0
  111. package/src/builder.ts +26 -0
  112. package/src/capabilities/slashCommand.ts +71 -0
  113. package/src/capabilities/sync.ts +76 -0
  114. package/src/capabilities/tool.test.ts +181 -0
  115. package/src/capabilities/tool.ts +145 -0
  116. package/src/cli/api/client.ts +588 -0
  117. package/src/cli/api/result.ts +71 -0
  118. package/src/cli/bin/cli.ts +7 -0
  119. package/src/cli/commands/auth.impl.ts +92 -0
  120. package/src/cli/commands/auth.ts +77 -0
  121. package/src/cli/commands/bundle.impl.ts +21 -0
  122. package/src/cli/commands/bundle.ts +23 -0
  123. package/src/cli/commands/capabilities.impl.ts +47 -0
  124. package/src/cli/commands/capabilities.ts +25 -0
  125. package/src/cli/commands/deploy.impl.ts +34 -0
  126. package/src/cli/commands/deploy.ts +16 -0
  127. package/src/cli/commands/exec.impl.ts +169 -0
  128. package/src/cli/commands/exec.ts +32 -0
  129. package/src/cli/commands/runs.impl.ts +87 -0
  130. package/src/cli/commands/runs.ts +49 -0
  131. package/src/cli/commands/secrets.impl.ts +124 -0
  132. package/src/cli/commands/secrets.ts +73 -0
  133. package/src/cli/config.ts +175 -0
  134. package/src/cli/context.ts +26 -0
  135. package/src/cli/deploy.ts +175 -0
  136. package/src/cli/flags.ts +43 -0
  137. package/src/cli/handler.ts +62 -0
  138. package/src/cli/routes.ts +43 -0
  139. package/src/cli/utils/array.ts +7 -0
  140. package/src/cli/utils/string.ts +9 -0
  141. package/src/cli/writer.ts +97 -0
  142. package/src/error.ts +12 -0
  143. package/src/index.ts +3 -0
  144. package/src/schema.ts +54 -0
  145. package/src/types.ts +10 -0
package/README.md ADDED
@@ -0,0 +1,22 @@
1
+ # Workers SDK
2
+
3
+ ## Development
4
+
5
+ 1. Install [mise](https://mise.jdx.dev/getting-started.html)
6
+ 2. Run `mise install`
7
+ 3. Run `npm run bootstrap`
8
+
9
+ ## Publishing New Versions
10
+
11
+ Increment the package.json version and create a new Git tag:
12
+
13
+ ```shell
14
+ # This also creates a Git tag.
15
+ npm version patch
16
+ ```
17
+
18
+ Then, push the commit and tag:
19
+
20
+ ```shell
21
+ git push origin main --follow-tags
22
+ ```
@@ -0,0 +1,321 @@
1
+ type ApiColor = "default" | "gray" | "brown" | "orange" | "yellow" | "green" | "blue" | "purple" | "pink" | "red" | "gray_background" | "brown_background" | "orange_background" | "yellow_background" | "green_background" | "blue_background" | "purple_background" | "pink_background" | "red_background";
2
+ type RichTextAnnotations = {
3
+ bold: boolean;
4
+ italic: boolean;
5
+ strikethrough: boolean;
6
+ underline: boolean;
7
+ code: boolean;
8
+ color: ApiColor;
9
+ };
10
+ type RichTextBase = {
11
+ plain_text: string;
12
+ href: string | null;
13
+ annotations: RichTextAnnotations;
14
+ };
15
+ type TextContent = {
16
+ content: string;
17
+ link: {
18
+ url: string;
19
+ } | null;
20
+ };
21
+ type EquationContent = {
22
+ expression: string;
23
+ };
24
+ type DateMention = {
25
+ type: "date";
26
+ date: {
27
+ start: string;
28
+ end?: string | null;
29
+ time_zone?: string | null;
30
+ };
31
+ };
32
+ type CustomEmojiMention = {
33
+ type: "custom_emoji";
34
+ custom_emoji: {
35
+ id: string;
36
+ name?: string;
37
+ url?: string;
38
+ };
39
+ };
40
+ type LinkPreviewMention = {
41
+ type: "link_preview";
42
+ link_preview: {
43
+ url: string;
44
+ };
45
+ };
46
+ type LinkMention = {
47
+ type: "link_mention";
48
+ link_mention: {
49
+ href: string;
50
+ };
51
+ };
52
+ type MentionContent = DateMention | CustomEmojiMention | LinkPreviewMention | LinkMention;
53
+ type RichTextItem = RichTextBase & ({
54
+ type: "text";
55
+ text: TextContent;
56
+ } | {
57
+ type: "mention";
58
+ mention: MentionContent;
59
+ } | {
60
+ type: "equation";
61
+ equation: EquationContent;
62
+ });
63
+ type RichText = RichTextItem[];
64
+ type EmojiIcon = {
65
+ type: "emoji";
66
+ emoji: string;
67
+ };
68
+ type ExternalIcon = {
69
+ type: "external";
70
+ external: {
71
+ url: string;
72
+ };
73
+ };
74
+ type FileIcon = {
75
+ type: "file";
76
+ file: {
77
+ url: string;
78
+ expiry_time: string;
79
+ };
80
+ };
81
+ type Icon = EmojiIcon | ExternalIcon | FileIcon;
82
+ type ExternalFile = {
83
+ type: "external";
84
+ external: {
85
+ url: string;
86
+ };
87
+ };
88
+ type HostedFile = {
89
+ type: "file";
90
+ file: {
91
+ url: string;
92
+ expiry_time: string;
93
+ };
94
+ name?: string;
95
+ };
96
+ type FileObject = ExternalFile | HostedFile;
97
+ type BlockBase = {
98
+ object: "block";
99
+ };
100
+ type ParagraphBlock = BlockBase & {
101
+ type: "paragraph";
102
+ paragraph: {
103
+ rich_text: RichText;
104
+ color?: ApiColor;
105
+ children?: Block[];
106
+ };
107
+ };
108
+ type Heading1Block = BlockBase & {
109
+ type: "heading_1";
110
+ heading_1: {
111
+ rich_text: RichText;
112
+ color?: ApiColor;
113
+ is_toggleable?: boolean;
114
+ children?: Block[];
115
+ };
116
+ };
117
+ type Heading2Block = BlockBase & {
118
+ type: "heading_2";
119
+ heading_2: {
120
+ rich_text: RichText;
121
+ color?: ApiColor;
122
+ is_toggleable?: boolean;
123
+ children?: Block[];
124
+ };
125
+ };
126
+ type Heading3Block = BlockBase & {
127
+ type: "heading_3";
128
+ heading_3: {
129
+ rich_text: RichText;
130
+ color?: ApiColor;
131
+ is_toggleable?: boolean;
132
+ children?: Block[];
133
+ };
134
+ };
135
+ type BulletedListItemBlock = BlockBase & {
136
+ type: "bulleted_list_item";
137
+ bulleted_list_item: {
138
+ rich_text: RichText;
139
+ color?: ApiColor;
140
+ children?: Block[];
141
+ };
142
+ };
143
+ type NumberedListItemBlock = BlockBase & {
144
+ type: "numbered_list_item";
145
+ numbered_list_item: {
146
+ rich_text: RichText;
147
+ color?: ApiColor;
148
+ children?: Block[];
149
+ };
150
+ };
151
+ type ToDoBlock = BlockBase & {
152
+ type: "to_do";
153
+ to_do: {
154
+ rich_text: RichText;
155
+ checked: boolean;
156
+ color?: ApiColor;
157
+ children?: Block[];
158
+ };
159
+ };
160
+ type ToggleBlock = BlockBase & {
161
+ type: "toggle";
162
+ toggle: {
163
+ rich_text: RichText;
164
+ color?: ApiColor;
165
+ children?: Block[];
166
+ };
167
+ };
168
+ type QuoteBlock = BlockBase & {
169
+ type: "quote";
170
+ quote: {
171
+ rich_text: RichText;
172
+ color?: ApiColor;
173
+ children?: Block[];
174
+ };
175
+ };
176
+ type CalloutBlock = BlockBase & {
177
+ type: "callout";
178
+ callout: {
179
+ rich_text: RichText;
180
+ icon?: Icon | null;
181
+ color?: ApiColor;
182
+ children?: Block[];
183
+ };
184
+ };
185
+ type CodeBlock = BlockBase & {
186
+ type: "code";
187
+ code: {
188
+ rich_text: RichText;
189
+ caption?: RichText;
190
+ language: string;
191
+ };
192
+ };
193
+ type EquationBlock = BlockBase & {
194
+ type: "equation";
195
+ equation: {
196
+ expression: string;
197
+ };
198
+ };
199
+ type DividerBlock = BlockBase & {
200
+ type: "divider";
201
+ divider: Record<string, never>;
202
+ };
203
+ type BreadcrumbBlock = BlockBase & {
204
+ type: "breadcrumb";
205
+ breadcrumb: Record<string, never>;
206
+ };
207
+ type TableOfContentsBlock = BlockBase & {
208
+ type: "table_of_contents";
209
+ table_of_contents: {
210
+ color?: ApiColor;
211
+ };
212
+ };
213
+ type ColumnListBlock = BlockBase & {
214
+ type: "column_list";
215
+ column_list: {
216
+ children: ColumnBlock[];
217
+ };
218
+ };
219
+ type ColumnBlock = BlockBase & {
220
+ type: "column";
221
+ column: {
222
+ children?: Block[];
223
+ };
224
+ };
225
+ type ImageBlock = BlockBase & {
226
+ type: "image";
227
+ image: FileObject & {
228
+ caption?: RichText;
229
+ };
230
+ };
231
+ type VideoBlock = BlockBase & {
232
+ type: "video";
233
+ video: FileObject & {
234
+ caption?: RichText;
235
+ };
236
+ };
237
+ type AudioBlock = BlockBase & {
238
+ type: "audio";
239
+ audio: FileObject & {
240
+ caption?: RichText;
241
+ };
242
+ };
243
+ type PDFBlock = BlockBase & {
244
+ type: "pdf";
245
+ pdf: FileObject & {
246
+ caption?: RichText;
247
+ };
248
+ };
249
+ type FileBlock = BlockBase & {
250
+ type: "file";
251
+ file: FileObject & {
252
+ caption?: RichText;
253
+ };
254
+ };
255
+ type EmbedBlock = BlockBase & {
256
+ type: "embed";
257
+ embed: {
258
+ url: string;
259
+ caption?: RichText;
260
+ };
261
+ };
262
+ type BookmarkBlock = BlockBase & {
263
+ type: "bookmark";
264
+ bookmark: {
265
+ url: string;
266
+ caption?: RichText;
267
+ };
268
+ };
269
+ type LinkPreviewBlock = BlockBase & {
270
+ type: "link_preview";
271
+ link_preview: {
272
+ url: string;
273
+ };
274
+ };
275
+ type ChildPageBlock = BlockBase & {
276
+ type: "child_page";
277
+ child_page: {
278
+ title: string;
279
+ };
280
+ };
281
+ type ChildDatabaseBlock = BlockBase & {
282
+ type: "child_database";
283
+ child_database: {
284
+ title: string;
285
+ };
286
+ };
287
+ type TemplateBlock = BlockBase & {
288
+ type: "template";
289
+ template: {
290
+ rich_text: RichText;
291
+ children?: Block[];
292
+ };
293
+ };
294
+ type TableBlock = BlockBase & {
295
+ type: "table";
296
+ table: {
297
+ table_width: number;
298
+ has_column_header: boolean;
299
+ has_row_header: boolean;
300
+ children: TableRowBlock[];
301
+ };
302
+ };
303
+ type TableRowBlock = BlockBase & {
304
+ type: "table_row";
305
+ table_row: {
306
+ cells: RichText[];
307
+ };
308
+ };
309
+ type AIBlock = BlockBase & {
310
+ type: "ai_block";
311
+ ai_block: {
312
+ prompt?: string;
313
+ };
314
+ };
315
+ type UnsupportedBlock = BlockBase & {
316
+ type: "unsupported";
317
+ unsupported: Record<string, never>;
318
+ };
319
+ type Block = ParagraphBlock | Heading1Block | Heading2Block | Heading3Block | BulletedListItemBlock | NumberedListItemBlock | ToDoBlock | ToggleBlock | QuoteBlock | CalloutBlock | CodeBlock | EquationBlock | DividerBlock | BreadcrumbBlock | TableOfContentsBlock | ColumnListBlock | ColumnBlock | ImageBlock | VideoBlock | AudioBlock | PDFBlock | FileBlock | EmbedBlock | BookmarkBlock | LinkPreviewBlock | ChildPageBlock | ChildDatabaseBlock | TemplateBlock | TableBlock | TableRowBlock | AIBlock | UnsupportedBlock;
320
+ export type { RichText, RichTextItem, RichTextBase, RichTextAnnotations, TextContent, EquationContent, MentionContent, DateMention, CustomEmojiMention, LinkPreviewMention, LinkMention, ApiColor, Icon, EmojiIcon, ExternalIcon, FileIcon, FileObject, ExternalFile, HostedFile, BlockBase, ParagraphBlock, Heading1Block, Heading2Block, Heading3Block, BulletedListItemBlock, NumberedListItemBlock, ToDoBlock, ToggleBlock, QuoteBlock, CalloutBlock, CodeBlock, EquationBlock, DividerBlock, BreadcrumbBlock, TableOfContentsBlock, ColumnListBlock, ColumnBlock, ImageBlock, VideoBlock, AudioBlock, PDFBlock, FileBlock, EmbedBlock, BookmarkBlock, LinkPreviewBlock, ChildPageBlock, ChildDatabaseBlock, TemplateBlock, TableBlock, TableRowBlock, AIBlock, UnsupportedBlock, Block, };
321
+ //# sourceMappingURL=block.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../src/block.ts"],"names":[],"mappings":"AAKA,KAAK,QAAQ,GACV,SAAS,GACT,MAAM,GACN,OAAO,GACP,QAAQ,GACR,QAAQ,GACR,OAAO,GACP,MAAM,GACN,QAAQ,GACR,MAAM,GACN,KAAK,GACL,iBAAiB,GACjB,kBAAkB,GAClB,mBAAmB,GACnB,mBAAmB,GACnB,kBAAkB,GAClB,iBAAiB,GACjB,mBAAmB,GACnB,iBAAiB,GACjB,gBAAgB,CAAC;AAGpB,KAAK,mBAAmB,GAAG;IAC1B,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,OAAO,CAAC;IAChB,aAAa,EAAE,OAAO,CAAC;IACvB,SAAS,EAAE,OAAO,CAAC;IACnB,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,QAAQ,CAAC;CAChB,CAAC;AAGF,KAAK,YAAY,GAAG;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,WAAW,EAAE,mBAAmB,CAAC;CACjC,CAAC;AAGF,KAAK,WAAW,GAAG;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;CAC7B,CAAC;AAGF,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,eAAe,EACf,oBAAoB,EACpB,eAAe,EACf,WAAW,EACX,UAAU,EACV,UAAU,EACV,UAAU,EACV,QAAQ,EACR,SAAS,EACT,UAAU,EACV,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,kBAAkB,EAClB,aAAa,EACb,UAAU,EACV,aAAa,EACb,OAAO,EACP,gBAAgB,EAChB,KAAK,GACL,CAAC"}
package/dist/block.js ADDED
File without changes
@@ -0,0 +1,12 @@
1
+ import type { TextValue } from "./types.js";
2
+ export declare function richText(content: string): TextValue;
3
+ export declare function url(url: string): TextValue;
4
+ export declare function title(content: string): TextValue;
5
+ export declare function text(content: string): TextValue;
6
+ /**
7
+ * Creates a link with custom display text
8
+ * @param displayText - The text to display
9
+ * @param url - The URL to link to
10
+ */
11
+ export declare function link(displayText: string, url: string): TextValue;
12
+ //# sourceMappingURL=builder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../src/builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAEnD;AAED,wBAAgB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAE1C;AAED,wBAAgB,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAEhD;AAED,wBAAgB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAE/C;AAED;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,SAAS,CAEhE"}
@@ -0,0 +1,22 @@
1
+ function richText(content) {
2
+ return [[content]];
3
+ }
4
+ function url(url2) {
5
+ return [[url2]];
6
+ }
7
+ function title(content) {
8
+ return [[content]];
9
+ }
10
+ function text(content) {
11
+ return [[content]];
12
+ }
13
+ function link(displayText, url2) {
14
+ return [[displayText, [["a", url2]]]];
15
+ }
16
+ export {
17
+ link,
18
+ richText,
19
+ text,
20
+ title,
21
+ url
22
+ };
@@ -0,0 +1,56 @@
1
+ import type { Block } from "../block.js";
2
+ export type SlashCommandConfiguration = {
3
+ menuTitle: string;
4
+ menuDescription: string;
5
+ search: {
6
+ placeholder: string;
7
+ debounce: number;
8
+ };
9
+ /**
10
+ * A function that returns a list of items to display in the search results
11
+ * as well as the corresponding blocks to insert for each item should it be selected.
12
+ */
13
+ executeSearch: (searchQuery: string) => Promise<{
14
+ items: {
15
+ title: string;
16
+ description: string;
17
+ id: string;
18
+ }[];
19
+ }>;
20
+ executeSelect: (selectedItemId: string) => Promise<Block[]>;
21
+ };
22
+ export type SlashCommandHandlerResult = {
23
+ menuTitle: string;
24
+ menuDescription: string;
25
+ search: {
26
+ placeholder: string;
27
+ debounce: number;
28
+ };
29
+ };
30
+ /**
31
+ * Creates a special handler for handling slash commands.
32
+ *
33
+ * @param slashCommandConfiguration - The configuration for the slash command.
34
+ * @returns A handler function that executes the slash command function, and passes data
35
+ * needed to complete the operation back to the platform.
36
+ */
37
+ export declare function slashCommand(slashCommandConfiguration: SlashCommandConfiguration): {
38
+ _tag: string;
39
+ config: {
40
+ menuTitle: string;
41
+ menuDescription: string;
42
+ search: {
43
+ placeholder: string;
44
+ debounce: number;
45
+ };
46
+ };
47
+ handleSearch(searchQuery: string): Promise<{
48
+ items: {
49
+ title: string;
50
+ description: string;
51
+ id: string;
52
+ }[];
53
+ }>;
54
+ handleSelect(selectedItemId: string): Promise<Block[]>;
55
+ };
56
+ //# sourceMappingURL=slashCommand.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slashCommand.d.ts","sourceRoot":"","sources":["../../src/capabilities/slashCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAGzC,MAAM,MAAM,yBAAyB,GAAG;IACvC,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE;QACP,WAAW,EAAE,MAAM,CAAC;QACpB,QAAQ,EAAE,MAAM,CAAC;KACjB,CAAC;IAEF;;;OAGG;IACH,aAAa,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,OAAO,CAAC;QAC/C,KAAK,EAAE;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,WAAW,EAAE,MAAM,CAAC;YAAC,EAAE,EAAE,MAAM,CAAA;SAAE,EAAE,CAAC;KAC5D,CAAC,CAAC;IACH,aAAa,EAAE,CAAC,cAAc,EAAE,MAAM,KAAK,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;CAC5D,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACvC,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE;QACP,WAAW,EAAE,MAAM,CAAC;QACpB,QAAQ,EAAE,MAAM,CAAC;KACjB,CAAC;CACF,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC3B,yBAAyB,EAAE,yBAAyB;;;;;;yBA/BtC,MAAM;sBACT,MAAM;;;8BAuCgB,MAAM;eA/B/B;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,WAAW,EAAE,MAAM,CAAC;YAAC,EAAE,EAAE,MAAM,CAAA;SAAE,EAAE;;iCA0CxB,MAAM;EAY1C"}
@@ -0,0 +1,32 @@
1
+ import { ExecutionError } from "../error.js";
2
+ function slashCommand(slashCommandConfiguration) {
3
+ return {
4
+ _tag: "slashCommand",
5
+ config: {
6
+ menuTitle: slashCommandConfiguration.menuTitle,
7
+ menuDescription: slashCommandConfiguration.menuDescription,
8
+ search: slashCommandConfiguration.search
9
+ },
10
+ async handleSearch(searchQuery) {
11
+ const result = await slashCommandConfiguration.executeSearch(searchQuery).catch((err) => {
12
+ throw new ExecutionError(err);
13
+ });
14
+ process.stdout.write(`
15
+ <output>${JSON.stringify(result)}</output>
16
+ `);
17
+ return result;
18
+ },
19
+ async handleSelect(selectedItemId) {
20
+ const result = await slashCommandConfiguration.executeSelect(selectedItemId).catch((err) => {
21
+ throw new ExecutionError(err);
22
+ });
23
+ process.stdout.write(`
24
+ <output>${JSON.stringify(result)}</output>
25
+ `);
26
+ return result;
27
+ }
28
+ };
29
+ }
30
+ export {
31
+ slashCommand
32
+ };
@@ -0,0 +1,58 @@
1
+ import type { PropertySchema, Schema } from "../schema.js";
2
+ import type { TextValue } from "../types.js";
3
+ /**
4
+ * An object representing a third-party record to be synced.
5
+ */
6
+ export type SyncedObject<PK extends string, S extends PropertySchema<PK>> = {
7
+ key: string;
8
+ properties: {
9
+ [Property in keyof S]: TextValue;
10
+ };
11
+ };
12
+ /**
13
+ * A configuration object that enables synchronization between a data
14
+ * source and a third-party source.
15
+ */
16
+ export type SyncConfiguration<PK extends string, S extends Schema<PK>> = {
17
+ /**
18
+ * The property of the data source that maps to a "primary key" in the
19
+ * third-party data. This is used to match existing pages to
20
+ * records in the third-party service. Must be a property defined in the schema.
21
+ */
22
+ primaryKeyProperty: PK;
23
+ /**
24
+ * The schema defining the structure of properties in the collection.
25
+ */
26
+ schema: S;
27
+ /**
28
+ * A function that fetches the data to sync from the third-party service.
29
+ *
30
+ * For now, this function must return all of the data to be synced each time
31
+ * it's called. The runtime will handle diffing this against the data source
32
+ * and creating, updating, and deleting pages as necessary.
33
+ */
34
+ execute: () => Promise<SyncedObject<PK, PropertySchema<PK>>[]>;
35
+ };
36
+ export type SyncHandlerResult<PK extends string> = {
37
+ primaryKeyProperty: PK;
38
+ objects: SyncedObject<PK, PropertySchema<PK>>[];
39
+ };
40
+ /**
41
+ * Creates a special handler for syncing third-party data to a collection.
42
+ *
43
+ * @param syncConfiguration - The configuration for the sync.
44
+ * @returns A handler function that executes the sync function, and passes data
45
+ * needed to complete the sync back to the platform.
46
+ */
47
+ export declare function sync<PK extends string, S extends Schema<PK>>(syncConfiguration: SyncConfiguration<PK, S>): {
48
+ _tag: string;
49
+ config: {
50
+ schema: S;
51
+ };
52
+ handler(): Promise<{
53
+ schema: S;
54
+ primaryKeyProperty: PK;
55
+ objects: SyncedObject<PK, PropertySchema<PK>>[];
56
+ }>;
57
+ };
58
+ //# sourceMappingURL=sync.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../src/capabilities/sync.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C;;GAEG;AACH,MAAM,MAAM,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC,SAAS,cAAc,CAAC,EAAE,CAAC,IAAI;IAC3E,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE;SAAG,QAAQ,IAAI,MAAM,CAAC,GAAG,SAAS;KAAE,CAAC;CACjD,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,iBAAiB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,CAAC,EAAE,CAAC,IAAI;IACxE;;;;OAIG;IACH,kBAAkB,EAAE,EAAE,CAAC;IAEvB;;OAEG;IACH,MAAM,EAAE,CAAC,CAAC;IAEV;;;;;;OAMG;IACH,OAAO,EAAE,MAAM,OAAO,CAAC,YAAY,CAAC,EAAE,EAAE,cAAc,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;CAC/D,CAAC;AAEF,MAAM,MAAM,iBAAiB,CAAC,EAAE,SAAS,MAAM,IAAI;IAClD,kBAAkB,EAAE,EAAE,CAAC;IACvB,OAAO,EAAE,YAAY,CAAC,EAAE,EAAE,cAAc,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;CAChD,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,CAAC,EAAE,CAAC,EAC3D,iBAAiB,EAAE,iBAAiB,CAAC,EAAE,EAAE,CAAC,CAAC;;;;;;;;;;EAuB3C"}
@@ -0,0 +1,26 @@
1
+ import { ExecutionError } from "../error.js";
2
+ function sync(syncConfiguration) {
3
+ return {
4
+ _tag: "sync",
5
+ config: {
6
+ schema: syncConfiguration.schema
7
+ },
8
+ async handler() {
9
+ const objects = await syncConfiguration.execute().catch((err) => {
10
+ throw new ExecutionError(err);
11
+ });
12
+ const result = {
13
+ schema: syncConfiguration.schema,
14
+ primaryKeyProperty: syncConfiguration.primaryKeyProperty,
15
+ objects
16
+ };
17
+ process.stdout.write(`
18
+ <output>${JSON.stringify(result)}</output>
19
+ `);
20
+ return result;
21
+ }
22
+ };
23
+ }
24
+ export {
25
+ sync
26
+ };
@@ -0,0 +1,69 @@
1
+ import { type JSONSchemaType } from "ajv";
2
+ type JSONValue = string | number | boolean | null | JSONValue[] | {
3
+ [key: string]: JSONValue;
4
+ };
5
+ export interface ToolConfiguration<I extends JSONValue, O extends JSONValue = JSONValue> {
6
+ description: string;
7
+ schema: JSONSchemaType<I>;
8
+ outputSchema?: JSONSchemaType<O>;
9
+ execute: (input: I) => O | Promise<O>;
10
+ }
11
+ /**
12
+ * An error returned when the input to a tool doesn't match the input schema.
13
+ */
14
+ export declare class InvalidToolInputError extends Error {
15
+ constructor(message: string);
16
+ }
17
+ /**
18
+ * An error returned when the output from a tool doesn't match the output schema.
19
+ */
20
+ export declare class InvalidToolOutputError extends Error {
21
+ constructor(message: string);
22
+ }
23
+ /**
24
+ * An error returned when the tool execution fails.
25
+ */
26
+ export declare class ToolExecutionError extends Error {
27
+ constructor(message: string);
28
+ }
29
+ /**
30
+ * Creates a capability definition for a tool to be used by an agent.
31
+ *
32
+ * Example:
33
+ *
34
+ * ```ts
35
+ * tool<{ name: string }>({
36
+ * description: "Say hello to the user",
37
+ * schema: {
38
+ * type: "object",
39
+ * properties: {
40
+ * name: { type: "string" },
41
+ * },
42
+ * required: ["name"],
43
+ * },
44
+ * execute: ({ name }) => {
45
+ * return `Hello, ${name}!`;
46
+ * },
47
+ * })
48
+ * ```
49
+ *
50
+ * @param config - The configuration for the tool.
51
+ * @returns A capability definition for the tool.
52
+ */
53
+ export declare function tool<I extends JSONValue, O extends JSONValue = JSONValue>(config: ToolConfiguration<I, O>): {
54
+ _tag: string;
55
+ config: {
56
+ description: string;
57
+ schema: JSONSchemaType<I>;
58
+ outputSchema: JSONSchemaType<O> | undefined;
59
+ };
60
+ handler(input: JSONValue): Promise<{
61
+ _tag: "success";
62
+ value: O;
63
+ } | {
64
+ _tag: "error";
65
+ error: InvalidToolInputError | InvalidToolOutputError | ToolExecutionError;
66
+ }>;
67
+ };
68
+ export {};
69
+ //# sourceMappingURL=tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../../src/capabilities/tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AAE/C,KAAK,SAAS,GACX,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,SAAS,EAAE,GACX;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AAEhC,MAAM,WAAW,iBAAiB,CACjC,CAAC,SAAS,SAAS,EACnB,CAAC,SAAS,SAAS,GAAG,SAAS;IAE/B,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC;IAC1B,YAAY,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC;IACjC,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;CACtC;AAED;;GAEG;AACH,qBAAa,qBAAsB,SAAQ,KAAK;gBACnC,OAAO,EAAE,MAAM;CAI3B;AAED;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,KAAK;gBACpC,OAAO,EAAE,MAAM;CAI3B;AAED;;G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