@bendyline/gezel-sdk 1.0.9 → 1.1.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.
- package/README.md +28 -1
- package/dist/checks.d.ts +84 -2
- package/dist/checks.js +1352 -852
- package/dist/index.d.ts +5 -711
- package/dist/index.js +102 -91
- package/dist/portable.d.ts +742 -0
- package/dist/portable.js +102 -0
- package/dist/{types-DCBb1goX.d.ts → types-rOo0kM35.d.ts} +1 -1
- package/package.json +6 -2
package/dist/index.js
CHANGED
|
@@ -1,3 +1,102 @@
|
|
|
1
|
+
// src/portable.ts
|
|
2
|
+
function defineScript(meta) {
|
|
3
|
+
return meta;
|
|
4
|
+
}
|
|
5
|
+
function createGezelSDK(rpc, options = {}) {
|
|
6
|
+
let outputStamped = false;
|
|
7
|
+
return {
|
|
8
|
+
get input() {
|
|
9
|
+
return rpc.init.input ?? {};
|
|
10
|
+
},
|
|
11
|
+
output(value) {
|
|
12
|
+
if (outputStamped) {
|
|
13
|
+
throw new Error(
|
|
14
|
+
"gezel.output() called more than once \u2014 a script may only stamp one output"
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
outputStamped = true;
|
|
18
|
+
rpc.notify("script.output", { value });
|
|
19
|
+
},
|
|
20
|
+
log(...args) {
|
|
21
|
+
rpc.notify("script.log", { args });
|
|
22
|
+
options.log?.(...args);
|
|
23
|
+
},
|
|
24
|
+
fs: {
|
|
25
|
+
read: (path) => rpc.call("fs.read", { path }),
|
|
26
|
+
write: (path, content) => rpc.call("fs.write", { path, content }),
|
|
27
|
+
list: (path) => rpc.call("fs.list", { path }),
|
|
28
|
+
listAll: () => rpc.call("fs.listAll"),
|
|
29
|
+
stat: (path) => rpc.call("fs.stat", { path }),
|
|
30
|
+
rm: (path) => rpc.call("fs.rm", { path }),
|
|
31
|
+
mkdir: (path) => rpc.call("fs.mkdir", { path }),
|
|
32
|
+
rename: (from, to) => rpc.call("fs.rename", { from, to })
|
|
33
|
+
},
|
|
34
|
+
artifacts: {
|
|
35
|
+
read: (path) => rpc.call("artifact.read", { path }),
|
|
36
|
+
write: (path, content) => rpc.call("artifact.write", { path, content }),
|
|
37
|
+
list: (prefix, opts) => rpc.call("artifact.list", {
|
|
38
|
+
prefix,
|
|
39
|
+
...opts?.recursive ? { recursive: true } : {}
|
|
40
|
+
}),
|
|
41
|
+
delete: (path) => rpc.call("artifact.delete", { path })
|
|
42
|
+
},
|
|
43
|
+
documents: {
|
|
44
|
+
read: (name) => rpc.call("document.read", { name }),
|
|
45
|
+
write: (name, content) => rpc.call("document.write", { name, content }),
|
|
46
|
+
list: () => rpc.call("document.list"),
|
|
47
|
+
delete: (name) => rpc.call("document.delete", { name })
|
|
48
|
+
},
|
|
49
|
+
task: {
|
|
50
|
+
get: (ref) => rpc.call("task.get", { ref }),
|
|
51
|
+
steps: (ref) => rpc.call("task.steps", { ref }),
|
|
52
|
+
currentStep: (ref) => rpc.call("task.currentStep", { ref }),
|
|
53
|
+
update: (ref, patch) => rpc.call("task.update", { ref, patch }),
|
|
54
|
+
advance: (ref, nextPhaseName) => rpc.call("task.advance", { ref, nextPhaseName }),
|
|
55
|
+
writeNotes: (ref, content, phaseId) => rpc.call("task.writeNotes", { ref, content, phaseId }),
|
|
56
|
+
appendNote: (ref, text, stepId) => rpc.call("task.appendNote", { ref, text, stepId }),
|
|
57
|
+
readNotes: (ref, phaseId) => rpc.call("task.readNotes", { ref, phaseId }),
|
|
58
|
+
deleteNote: (ref, noteId) => rpc.call("task.deleteNote", { ref, noteId }),
|
|
59
|
+
create: (req) => rpc.call("task.create", { req })
|
|
60
|
+
},
|
|
61
|
+
memory: {
|
|
62
|
+
search: (query) => rpc.call("memory.search", { query }),
|
|
63
|
+
save: (text, meta) => rpc.call("memory.save", { text, meta })
|
|
64
|
+
},
|
|
65
|
+
llm: {
|
|
66
|
+
oneShot: (prompt, opts) => rpc.call("llm.oneShot", { prompt, opts })
|
|
67
|
+
},
|
|
68
|
+
mcp: {
|
|
69
|
+
call: (tool, args) => rpc.call("mcp.call", { tool, args })
|
|
70
|
+
},
|
|
71
|
+
index: {
|
|
72
|
+
status: () => rpc.call("index.status"),
|
|
73
|
+
ensureFresh: (opts) => rpc.call("index.ensureFresh", {
|
|
74
|
+
...opts?.waitBudgetMs !== void 0 ? { waitBudgetMs: opts.waitBudgetMs } : {},
|
|
75
|
+
...opts?.reviews !== void 0 ? { reviews: opts.reviews } : {}
|
|
76
|
+
})
|
|
77
|
+
},
|
|
78
|
+
http: {
|
|
79
|
+
request: (url, opts) => rpc.call("http.request", {
|
|
80
|
+
url,
|
|
81
|
+
...opts?.method ? { method: opts.method } : {},
|
|
82
|
+
...opts?.body !== void 0 ? { body: opts.body } : {},
|
|
83
|
+
...opts?.headers ? { headers: opts.headers } : {}
|
|
84
|
+
}),
|
|
85
|
+
authed: (url, opts) => rpc.call("http.authed", {
|
|
86
|
+
url,
|
|
87
|
+
credential: opts.credential,
|
|
88
|
+
...opts.method ? { method: opts.method } : {},
|
|
89
|
+
...opts.body !== void 0 ? { body: opts.body } : {},
|
|
90
|
+
...opts.headers ? { headers: opts.headers } : {},
|
|
91
|
+
...opts.authScheme ? { authScheme: opts.authScheme } : {}
|
|
92
|
+
})
|
|
93
|
+
},
|
|
94
|
+
script: {
|
|
95
|
+
run: (name, input) => rpc.call("script.run", { name, input })
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
1
100
|
// src/rpc.ts
|
|
2
101
|
import { readFileSync, writeSync } from "fs";
|
|
3
102
|
import { Socket } from "net";
|
|
@@ -162,104 +261,16 @@ function writeFrame(payload) {
|
|
|
162
261
|
}
|
|
163
262
|
|
|
164
263
|
// src/index.ts
|
|
165
|
-
|
|
166
|
-
return meta;
|
|
167
|
-
}
|
|
168
|
-
var rpc = new RpcClient();
|
|
169
|
-
var outputStamped = false;
|
|
170
|
-
var gezel = {
|
|
171
|
-
get input() {
|
|
172
|
-
return rpc.init.input ?? {};
|
|
173
|
-
},
|
|
174
|
-
output(value) {
|
|
175
|
-
if (outputStamped) {
|
|
176
|
-
throw new Error("gezel.output() called more than once \u2014 a script may only stamp one output");
|
|
177
|
-
}
|
|
178
|
-
outputStamped = true;
|
|
179
|
-
rpc.notify("script.output", { value });
|
|
180
|
-
},
|
|
264
|
+
var gezel = createGezelSDK(new RpcClient(), {
|
|
181
265
|
log(...args) {
|
|
182
|
-
rpc.notify("script.log", { args });
|
|
183
266
|
process.stderr.write(
|
|
184
267
|
`${args.map((a) => typeof a === "string" ? a : JSON.stringify(a)).join(" ")}
|
|
185
268
|
`
|
|
186
269
|
);
|
|
187
|
-
},
|
|
188
|
-
fs: {
|
|
189
|
-
read: (path) => rpc.call("fs.read", { path }),
|
|
190
|
-
write: (path, content) => rpc.call("fs.write", { path, content }),
|
|
191
|
-
list: (path) => rpc.call("fs.list", { path }),
|
|
192
|
-
listAll: () => rpc.call("fs.listAll"),
|
|
193
|
-
stat: (path) => rpc.call("fs.stat", { path }),
|
|
194
|
-
rm: (path) => rpc.call("fs.rm", { path }),
|
|
195
|
-
mkdir: (path) => rpc.call("fs.mkdir", { path }),
|
|
196
|
-
rename: (from, to) => rpc.call("fs.rename", { from, to })
|
|
197
|
-
},
|
|
198
|
-
artifacts: {
|
|
199
|
-
read: (path) => rpc.call("artifact.read", { path }),
|
|
200
|
-
write: (path, content) => rpc.call("artifact.write", { path, content }),
|
|
201
|
-
list: (prefix, opts) => rpc.call("artifact.list", {
|
|
202
|
-
prefix,
|
|
203
|
-
...opts?.recursive ? { recursive: true } : {}
|
|
204
|
-
}),
|
|
205
|
-
delete: (path) => rpc.call("artifact.delete", { path })
|
|
206
|
-
},
|
|
207
|
-
documents: {
|
|
208
|
-
read: (name) => rpc.call("document.read", { name }),
|
|
209
|
-
write: (name, content) => rpc.call("document.write", { name, content }),
|
|
210
|
-
list: () => rpc.call("document.list"),
|
|
211
|
-
delete: (name) => rpc.call("document.delete", { name })
|
|
212
|
-
},
|
|
213
|
-
task: {
|
|
214
|
-
get: (ref) => rpc.call("task.get", { ref }),
|
|
215
|
-
steps: (ref) => rpc.call("task.steps", { ref }),
|
|
216
|
-
currentStep: (ref) => rpc.call("task.currentStep", { ref }),
|
|
217
|
-
update: (ref, patch) => rpc.call("task.update", { ref, patch }),
|
|
218
|
-
advance: (ref, nextPhaseName) => rpc.call("task.advance", { ref, nextPhaseName }),
|
|
219
|
-
writeNotes: (ref, content, phaseId) => rpc.call("task.writeNotes", { ref, content, phaseId }),
|
|
220
|
-
appendNote: (ref, text, stepId) => rpc.call("task.appendNote", { ref, text, stepId }),
|
|
221
|
-
readNotes: (ref, phaseId) => rpc.call("task.readNotes", { ref, phaseId }),
|
|
222
|
-
deleteNote: (ref, noteId) => rpc.call("task.deleteNote", { ref, noteId }),
|
|
223
|
-
create: (req) => rpc.call("task.create", { req })
|
|
224
|
-
},
|
|
225
|
-
memory: {
|
|
226
|
-
search: (query) => rpc.call("memory.search", { query }),
|
|
227
|
-
save: (text, meta) => rpc.call("memory.save", { text, meta })
|
|
228
|
-
},
|
|
229
|
-
llm: {
|
|
230
|
-
oneShot: (prompt, opts) => rpc.call("llm.oneShot", { prompt, opts })
|
|
231
|
-
},
|
|
232
|
-
mcp: {
|
|
233
|
-
call: (tool, args) => rpc.call("mcp.call", { tool, args })
|
|
234
|
-
},
|
|
235
|
-
index: {
|
|
236
|
-
status: () => rpc.call("index.status"),
|
|
237
|
-
ensureFresh: (opts) => rpc.call("index.ensureFresh", {
|
|
238
|
-
...opts?.waitBudgetMs !== void 0 ? { waitBudgetMs: opts.waitBudgetMs } : {},
|
|
239
|
-
...opts?.reviews !== void 0 ? { reviews: opts.reviews } : {}
|
|
240
|
-
})
|
|
241
|
-
},
|
|
242
|
-
http: {
|
|
243
|
-
request: (url, opts) => rpc.call("http.request", {
|
|
244
|
-
url,
|
|
245
|
-
...opts?.method ? { method: opts.method } : {},
|
|
246
|
-
...opts?.body !== void 0 ? { body: opts.body } : {},
|
|
247
|
-
...opts?.headers ? { headers: opts.headers } : {}
|
|
248
|
-
}),
|
|
249
|
-
authed: (url, opts) => rpc.call("http.authed", {
|
|
250
|
-
url,
|
|
251
|
-
credential: opts.credential,
|
|
252
|
-
...opts.method ? { method: opts.method } : {},
|
|
253
|
-
...opts.body !== void 0 ? { body: opts.body } : {},
|
|
254
|
-
...opts.headers ? { headers: opts.headers } : {},
|
|
255
|
-
...opts.authScheme ? { authScheme: opts.authScheme } : {}
|
|
256
|
-
})
|
|
257
|
-
},
|
|
258
|
-
script: {
|
|
259
|
-
run: (name, input) => rpc.call("script.run", { name, input })
|
|
260
270
|
}
|
|
261
|
-
};
|
|
271
|
+
});
|
|
262
272
|
export {
|
|
273
|
+
createGezelSDK,
|
|
263
274
|
defineScript,
|
|
264
275
|
gezel
|
|
265
276
|
};
|