Skip to content

Commit fd623c3

Browse files
vincent99thedadams
andauthored
fix: Main node entrypoint, async nits, global tools (#26)
* Fix main entrypoint, async nits, global tools - Changed main entrypoint js in package.json to be where it is now. - If you know something is defined but TS doesn't, you can use the damnit flag, `!` instead of eslint ignore comments. `this.promise = new Promise(() => { .... this.process!.on('exit', ...)` - `async function foo(): Promise<x> { return await bar() }` is redundant. This is functionally the same as just saying `function foo(): Promise<x> { return bar() }` but makes debugging harder. By marking the function async and awaiting you're creating an extra promise that does nothing but immediately resolve after bar's does. You don't have to declare your function as async in order for the consumer to be able to await it. The consumer just needs a function that returns a Promise (which bar() already returns). On your side you only have to say `async` if you want to use `await` for something in the body (other than just immediately returning it) - Similarly text() and json() have that + a 2nd layer of extra promises. `throw` is the same as reject() and throws 'cascade' up so all json() needs to be is `return JSON.parse(await this.text())`. Also the returned JSON isn't necessarily an object, it could be an array or a random scalar so it should just return `any`. - Changed default for a text block to just plain 'text' format, markdown will be a separate option (that the parser doesn't need to know about) - Parameters (or ToolDef) should support globalTools and toolDefToString serializing them. - Changes for running in node vs. browser including dynamic loading of node packages and using sse.js. Co-authored-by: Donnie Adams <[email protected]>
1 parent 6ea6f8b commit fd623c3

File tree

8 files changed

+9778
-5802
lines changed

8 files changed

+9778
-5802
lines changed

.gitignore

-3
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,3 @@ dist/
5353
lib/
5454

5555
.npmrc
56-
57-
**/*.js
58-
**/*.d.ts

0 commit comments

Comments
 (0)