@project-ajax/create 0.0.15 → 0.0.17
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/package.json +1 -1
- package/template/.examples/sync-example.ts +34 -0
- package/template/.examples/tool-example.ts +52 -0
- package/template/README.md +91 -317
- package/template/package-lock.json +1656 -0
- package/template/package.json +1 -1
- package/template/src/index.ts +1 -184
package/template/package.json
CHANGED
package/template/src/index.ts
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import { tool } from "@project-ajax/sdk";
|
|
2
|
-
import type {
|
|
3
|
-
Block,
|
|
4
|
-
CalloutBlock,
|
|
5
|
-
ParagraphBlock,
|
|
6
|
-
} from "@project-ajax/sdk/block";
|
|
7
2
|
import * as Builder from "@project-ajax/sdk/builder";
|
|
8
3
|
import * as Schema from "@project-ajax/sdk/schema";
|
|
9
|
-
import { slashCommand } from "@project-ajax/sdk/slashCommand";
|
|
10
4
|
import { sync } from "@project-ajax/sdk/sync";
|
|
11
5
|
|
|
12
6
|
// Sample data for demonstration
|
|
@@ -21,7 +15,7 @@ const sampleTasks = [
|
|
|
21
15
|
id: "task-2",
|
|
22
16
|
title: "Build your first worker",
|
|
23
17
|
status: "In Progress",
|
|
24
|
-
description: "Create a sync or
|
|
18
|
+
description: "Create a sync or tool worker",
|
|
25
19
|
},
|
|
26
20
|
{
|
|
27
21
|
id: "task-3",
|
|
@@ -87,183 +81,6 @@ export const tasksSync = sync({
|
|
|
87
81
|
},
|
|
88
82
|
});
|
|
89
83
|
|
|
90
|
-
// Example slash command that searches and inserts sample tasks
|
|
91
|
-
export const taskSearchSlashCommand = slashCommand({
|
|
92
|
-
menuTitle: "Insert Sample Task",
|
|
93
|
-
menuDescription: "Search for a sample task to insert",
|
|
94
|
-
search: {
|
|
95
|
-
placeholder: "Search for tasks...",
|
|
96
|
-
debounce: 300,
|
|
97
|
-
},
|
|
98
|
-
executeSearch: async (query: string) => {
|
|
99
|
-
// Filter tasks based on the search query
|
|
100
|
-
const filtered = sampleTasks.filter(
|
|
101
|
-
(task) =>
|
|
102
|
-
task.title.toLowerCase().includes(query.toLowerCase()) ||
|
|
103
|
-
task.description.toLowerCase().includes(query.toLowerCase()),
|
|
104
|
-
);
|
|
105
|
-
|
|
106
|
-
// Transform tasks into menu items
|
|
107
|
-
const items = filtered.map((task) => ({
|
|
108
|
-
id: task.id,
|
|
109
|
-
title: task.title,
|
|
110
|
-
description: `${task.status} • ${task.description}`,
|
|
111
|
-
}));
|
|
112
|
-
|
|
113
|
-
return { items };
|
|
114
|
-
},
|
|
115
|
-
|
|
116
|
-
executeSelect: async (taskId: string) => {
|
|
117
|
-
// Find the selected task
|
|
118
|
-
const task = sampleTasks.find((t) => t.id === taskId);
|
|
119
|
-
|
|
120
|
-
if (!task) {
|
|
121
|
-
return [];
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
// Create blocks to insert into the page
|
|
125
|
-
const calloutBlock: CalloutBlock = {
|
|
126
|
-
object: "block",
|
|
127
|
-
type: "callout",
|
|
128
|
-
callout: {
|
|
129
|
-
icon: {
|
|
130
|
-
type: "emoji",
|
|
131
|
-
emoji: "✨",
|
|
132
|
-
},
|
|
133
|
-
rich_text: [
|
|
134
|
-
{
|
|
135
|
-
type: "text",
|
|
136
|
-
text: {
|
|
137
|
-
content: `Task: ${task.id}`,
|
|
138
|
-
link: null,
|
|
139
|
-
},
|
|
140
|
-
plain_text: `Task: ${task.id}`,
|
|
141
|
-
href: null,
|
|
142
|
-
annotations: {
|
|
143
|
-
bold: true,
|
|
144
|
-
italic: false,
|
|
145
|
-
strikethrough: false,
|
|
146
|
-
underline: false,
|
|
147
|
-
code: false,
|
|
148
|
-
color: "default",
|
|
149
|
-
},
|
|
150
|
-
},
|
|
151
|
-
],
|
|
152
|
-
color: "blue_background",
|
|
153
|
-
},
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
const titleBlock: ParagraphBlock = {
|
|
157
|
-
object: "block",
|
|
158
|
-
type: "paragraph",
|
|
159
|
-
paragraph: {
|
|
160
|
-
rich_text: [
|
|
161
|
-
{
|
|
162
|
-
type: "text",
|
|
163
|
-
text: {
|
|
164
|
-
content: task.title,
|
|
165
|
-
link: null,
|
|
166
|
-
},
|
|
167
|
-
plain_text: task.title,
|
|
168
|
-
href: null,
|
|
169
|
-
annotations: {
|
|
170
|
-
bold: true,
|
|
171
|
-
italic: false,
|
|
172
|
-
strikethrough: false,
|
|
173
|
-
underline: false,
|
|
174
|
-
code: false,
|
|
175
|
-
color: "default",
|
|
176
|
-
},
|
|
177
|
-
},
|
|
178
|
-
],
|
|
179
|
-
},
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
const statusBlock: ParagraphBlock = {
|
|
183
|
-
object: "block",
|
|
184
|
-
type: "paragraph",
|
|
185
|
-
paragraph: {
|
|
186
|
-
rich_text: [
|
|
187
|
-
{
|
|
188
|
-
type: "text",
|
|
189
|
-
text: {
|
|
190
|
-
content: "Status: ",
|
|
191
|
-
link: null,
|
|
192
|
-
},
|
|
193
|
-
plain_text: "Status: ",
|
|
194
|
-
href: null,
|
|
195
|
-
annotations: {
|
|
196
|
-
bold: true,
|
|
197
|
-
italic: false,
|
|
198
|
-
strikethrough: false,
|
|
199
|
-
underline: false,
|
|
200
|
-
code: false,
|
|
201
|
-
color: "default",
|
|
202
|
-
},
|
|
203
|
-
},
|
|
204
|
-
{
|
|
205
|
-
type: "text",
|
|
206
|
-
text: {
|
|
207
|
-
content: task.status,
|
|
208
|
-
link: null,
|
|
209
|
-
},
|
|
210
|
-
plain_text: task.status,
|
|
211
|
-
href: null,
|
|
212
|
-
annotations: {
|
|
213
|
-
bold: false,
|
|
214
|
-
italic: false,
|
|
215
|
-
strikethrough: false,
|
|
216
|
-
underline: false,
|
|
217
|
-
code: false,
|
|
218
|
-
color:
|
|
219
|
-
task.status === "Completed"
|
|
220
|
-
? "green"
|
|
221
|
-
: task.status === "In Progress"
|
|
222
|
-
? "blue"
|
|
223
|
-
: "default",
|
|
224
|
-
},
|
|
225
|
-
},
|
|
226
|
-
],
|
|
227
|
-
},
|
|
228
|
-
};
|
|
229
|
-
|
|
230
|
-
const descriptionBlock: ParagraphBlock = {
|
|
231
|
-
object: "block",
|
|
232
|
-
type: "paragraph",
|
|
233
|
-
paragraph: {
|
|
234
|
-
rich_text: [
|
|
235
|
-
{
|
|
236
|
-
type: "text",
|
|
237
|
-
text: {
|
|
238
|
-
content: task.description,
|
|
239
|
-
link: null,
|
|
240
|
-
},
|
|
241
|
-
plain_text: task.description,
|
|
242
|
-
href: null,
|
|
243
|
-
annotations: {
|
|
244
|
-
bold: false,
|
|
245
|
-
italic: true,
|
|
246
|
-
strikethrough: false,
|
|
247
|
-
underline: false,
|
|
248
|
-
code: false,
|
|
249
|
-
color: "gray",
|
|
250
|
-
},
|
|
251
|
-
},
|
|
252
|
-
],
|
|
253
|
-
},
|
|
254
|
-
};
|
|
255
|
-
|
|
256
|
-
const blocks: Block[] = [
|
|
257
|
-
calloutBlock,
|
|
258
|
-
titleBlock,
|
|
259
|
-
statusBlock,
|
|
260
|
-
descriptionBlock,
|
|
261
|
-
];
|
|
262
|
-
|
|
263
|
-
return blocks;
|
|
264
|
-
},
|
|
265
|
-
});
|
|
266
|
-
|
|
267
84
|
// Example agent tool for retrieving task information
|
|
268
85
|
export const taskSearchTool = tool({
|
|
269
86
|
title: "Task Search",
|