crewx-pi-kit 0.1.1 → 0.1.3
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/README.md +1 -1
- package/extensions/crewx-tools.ts +74 -6
- package/package.json +1 -1
- package/skills/artifact-delivery/SKILL.md +13 -0
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
import { Type } from "typebox";
|
|
3
|
+
import { readFile } from "node:fs/promises";
|
|
4
|
+
import { basename } from "node:path";
|
|
3
5
|
|
|
4
6
|
const API_PATH = "/api/agent/v1";
|
|
5
7
|
const MAX_RESULT_CHARS = 100_000;
|
|
@@ -48,6 +50,37 @@ async function crewxRequest(
|
|
|
48
50
|
return payload;
|
|
49
51
|
}
|
|
50
52
|
|
|
53
|
+
async function crewxUpload(
|
|
54
|
+
path: string,
|
|
55
|
+
caption: string | undefined,
|
|
56
|
+
signal?: AbortSignal,
|
|
57
|
+
): Promise<unknown> {
|
|
58
|
+
const { baseUrl, token } = connection();
|
|
59
|
+
const contents = await readFile(path);
|
|
60
|
+
const form = new FormData();
|
|
61
|
+
form.set("file", new Blob([contents]), basename(path));
|
|
62
|
+
if (caption?.trim()) form.set("caption", caption.trim());
|
|
63
|
+
const response = await fetch(`${baseUrl}${API_PATH}/files`, {
|
|
64
|
+
method: "POST",
|
|
65
|
+
headers: {
|
|
66
|
+
accept: "application/json",
|
|
67
|
+
authorization: `Bearer ${token}`,
|
|
68
|
+
},
|
|
69
|
+
body: form,
|
|
70
|
+
redirect: "error",
|
|
71
|
+
...(signal ? { signal } : {}),
|
|
72
|
+
});
|
|
73
|
+
const payload = (await response.json().catch(() => ({
|
|
74
|
+
message: `CrewX returned HTTP ${response.status}.`,
|
|
75
|
+
}))) as JsonRecord;
|
|
76
|
+
if (!response.ok) {
|
|
77
|
+
throw new Error(typeof payload.message === "string"
|
|
78
|
+
? payload.message
|
|
79
|
+
: `CrewX returned HTTP ${response.status}.`);
|
|
80
|
+
}
|
|
81
|
+
return payload;
|
|
82
|
+
}
|
|
83
|
+
|
|
51
84
|
function result(value: unknown) {
|
|
52
85
|
return {content: [{type: "text" as const, text: jsonText(value)}], details: {}};
|
|
53
86
|
}
|
|
@@ -61,6 +94,41 @@ function query(parameters: Record<string, string | number | boolean | undefined>
|
|
|
61
94
|
}
|
|
62
95
|
|
|
63
96
|
export default function crewxTools(pi: ExtensionAPI) {
|
|
97
|
+
pi.registerTool({
|
|
98
|
+
name: "crewx_attach_file",
|
|
99
|
+
label: "Attach CrewX file",
|
|
100
|
+
description: "Upload a durable file and attach it to the current CrewX reply.",
|
|
101
|
+
parameters: Type.Object({
|
|
102
|
+
path: Type.String({minLength: 1, maxLength: 4096}),
|
|
103
|
+
caption: Type.Optional(Type.String({maxLength: 1000})),
|
|
104
|
+
}),
|
|
105
|
+
promptSnippet: "Deliver generated files directly into the CrewX conversation.",
|
|
106
|
+
promptGuidelines: [
|
|
107
|
+
"Use crewx_attach_file for requested screenshots, reports, exports, and other deliverables instead of returning a local path.",
|
|
108
|
+
],
|
|
109
|
+
async execute(_id, params, signal) {
|
|
110
|
+
return result(await crewxUpload(params.path, params.caption, signal));
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
pi.registerTool({
|
|
115
|
+
name: "crewx_publish_preview",
|
|
116
|
+
label: "Publish CrewX preview",
|
|
117
|
+
description: "Publish a web service running on this CrewX Cloud Agent as a live preview.",
|
|
118
|
+
parameters: Type.Object({
|
|
119
|
+
port: Type.Integer({minimum: 1024, maximum: 65535}),
|
|
120
|
+
title: Type.Optional(Type.String({maxLength: 120})),
|
|
121
|
+
}),
|
|
122
|
+
promptSnippet: "Share interactive work as a managed CrewX live preview.",
|
|
123
|
+
promptGuidelines: [
|
|
124
|
+
"Bind the service to 0.0.0.0, verify it locally, then publish the port.",
|
|
125
|
+
"Do not reveal provider URLs, access tokens, or local file paths in the reply.",
|
|
126
|
+
],
|
|
127
|
+
async execute(_id, params, signal) {
|
|
128
|
+
return result(await crewxRequest("/previews", {method: "POST", body: params, signal}));
|
|
129
|
+
},
|
|
130
|
+
});
|
|
131
|
+
|
|
64
132
|
pi.registerTool({
|
|
65
133
|
name: "crewx_memory_search",
|
|
66
134
|
label: "Search CrewX memory",
|
|
@@ -105,7 +173,7 @@ export default function crewxTools(pi: ExtensionAPI) {
|
|
|
105
173
|
label: "Update CrewX memory",
|
|
106
174
|
description: "Update a CrewX memory originally recorded by this agent.",
|
|
107
175
|
parameters: Type.Object({
|
|
108
|
-
id: Type.Integer({minimum: 1}),
|
|
176
|
+
id: Type.Union([Type.String({minLength: 1, maxLength: 128}), Type.Integer({minimum: 1})]),
|
|
109
177
|
title: Type.Optional(Type.String({maxLength: 255})),
|
|
110
178
|
content: Type.Optional(Type.String({maxLength: 100_000})),
|
|
111
179
|
category: Type.Optional(Type.String({maxLength: 50})),
|
|
@@ -114,7 +182,7 @@ export default function crewxTools(pi: ExtensionAPI) {
|
|
|
114
182
|
channel_id: Type.Optional(Type.Union([Type.Integer({minimum: 1}), Type.Null()])),
|
|
115
183
|
}),
|
|
116
184
|
async execute(_id, {id, ...body}, signal) {
|
|
117
|
-
return result(await crewxRequest(`/memories/${id}`, {method: "PATCH", body, signal}));
|
|
185
|
+
return result(await crewxRequest(`/memories/${encodeURIComponent(String(id))}`, {method: "PATCH", body, signal}));
|
|
118
186
|
},
|
|
119
187
|
});
|
|
120
188
|
|
|
@@ -155,7 +223,7 @@ export default function crewxTools(pi: ExtensionAPI) {
|
|
|
155
223
|
label: "Update CrewX task",
|
|
156
224
|
description: "Update a task assigned to this agent.",
|
|
157
225
|
parameters: Type.Object({
|
|
158
|
-
id: Type.Integer({minimum: 1}),
|
|
226
|
+
id: Type.Union([Type.String({minLength: 1, maxLength: 128}), Type.Integer({minimum: 1})]),
|
|
159
227
|
status: Type.Optional(Type.Union([
|
|
160
228
|
Type.Literal("backlog"), Type.Literal("todo"), Type.Literal("in_progress"),
|
|
161
229
|
Type.Literal("review"), Type.Literal("done"), Type.Literal("cancelled"),
|
|
@@ -164,7 +232,7 @@ export default function crewxTools(pi: ExtensionAPI) {
|
|
|
164
232
|
description: Type.Optional(Type.String({maxLength: 100_000})),
|
|
165
233
|
}),
|
|
166
234
|
async execute(_id, {id, ...body}, signal) {
|
|
167
|
-
return result(await crewxRequest(`/tasks/${id}`, {method: "PATCH", body, signal}));
|
|
235
|
+
return result(await crewxRequest(`/tasks/${encodeURIComponent(String(id))}`, {method: "PATCH", body, signal}));
|
|
168
236
|
},
|
|
169
237
|
});
|
|
170
238
|
|
|
@@ -197,14 +265,14 @@ export default function crewxTools(pi: ExtensionAPI) {
|
|
|
197
265
|
label: "Update CrewX document",
|
|
198
266
|
description: "Safely update an unprotected CrewX document using its current version.",
|
|
199
267
|
parameters: Type.Object({
|
|
200
|
-
id: Type.Integer({minimum: 1}),
|
|
268
|
+
id: Type.Union([Type.String({minLength: 1, maxLength: 128}), Type.Integer({minimum: 1})]),
|
|
201
269
|
expected_version: Type.Integer({minimum: 1}),
|
|
202
270
|
title: Type.Optional(Type.String({maxLength: 255})),
|
|
203
271
|
content: Type.Optional(Type.String({maxLength: 250_000})),
|
|
204
272
|
summary: Type.Optional(Type.String({maxLength: 255})),
|
|
205
273
|
}),
|
|
206
274
|
async execute(_id, {id, ...body}, signal) {
|
|
207
|
-
return result(await crewxRequest(`/documents/${id}`, {method: "PATCH", body, signal}));
|
|
275
|
+
return result(await crewxRequest(`/documents/${encodeURIComponent(String(id))}`, {method: "PATCH", body, signal}));
|
|
208
276
|
},
|
|
209
277
|
});
|
|
210
278
|
|
package/package.json
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: artifact-delivery
|
|
3
|
+
description: Deliver files and interactive previews back to the CrewX conversation. Use when an assignment produces screenshots, reports, exports, generated media, or a locally running web experience.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Artifact Delivery
|
|
7
|
+
|
|
8
|
+
1. Treat the final CrewX reply as the handoff, not the machine filesystem. Never ask a teammate to retrieve `/home`, `/tmp`, or another local path.
|
|
9
|
+
2. Use `crewx_attach_file` for durable outputs such as screenshots, documents, archives, data exports, and generated media. Add a short caption that explains what the file contains.
|
|
10
|
+
3. Use `crewx_publish_preview` only when interaction materially improves the handoff. Bind the service to `0.0.0.0`, verify the local port, then publish it.
|
|
11
|
+
4. A preview is a running service, not permanent storage. Also attach durable source or output files when the teammate may need them later.
|
|
12
|
+
5. Do not include provider URLs, preview tokens, credentials, or local paths in the response. CrewX presents the safe file and preview controls automatically.
|
|
13
|
+
6. Confirm that every requested deliverable was attached before sending the concise final response.
|