-
Notifications
You must be signed in to change notification settings - Fork 41
Code-first agent build integration and the initial version of the TS agent templates #307
Conversation
...s/templates/ts/ts-agent-app-component-default/components-ts/component-name/rollup.config.mjs
Outdated
Show resolved
Hide resolved
golem-templates/templates/ts/ts-app-common/common-ts/golem.yaml
Outdated
Show resolved
Hide resolved
|
After I change ts-user to use rollup (instead of tsup) let's have a quick catchup to align a few things |
| args = ["--interfaces", "127.0.0.1", "--port", "41357", "schema.golem.cloud"] | ||
|
|
||
| ## Agent template management | ||
| [tasks.rebuild-ts-agent-template] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a manual step on purpose. We will run it whenever we want to update the "base wasm" for agents, and the compiled WASM itself is part of the template. There is no need to do this on every build.
| Ok(result) | ||
| } | ||
|
|
||
| fn jco_async_export_args( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed support for componentize.js/jco completely, as wasm-rquickjs seems to work well
| ComponentItem::Type(_) => {} | ||
| ComponentItem::Resource(_resource) => { | ||
| resources.entry((name, inner_name)).or_default(); | ||
| if &inner_name != "pollable" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The horrible hack mentioned in the PR description
|
|
||
| const externalPackages = (id) => { | ||
| return ( | ||
| id === "@afsalthaj/golem-ts-sdk" || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: replace with @golemcloud when published
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
published to golemcloud now.
@golemcloud/golem-ts-sdk@0.0.1-dev.3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Versions may keep getting updated, but ts-user is also updated with dev.3, the import statements changed after changing to golemcloud
| @@ -0,0 +1,15 @@ | |||
| import '../.metadata/metadata.index'; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file was generated build-time in Afsal's prototype but there is no need to do so, so I've just "hid it" in a different directory than src but it is just part of the template.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't get you.
- Why is generated file (the output of npm run build) part of the template even under hidden files?
npm run buildfor user code builds a ts under.generatedfolder in prototype and then it gets build todist/index.mjs- If these are not used, then it won't work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no npm run build just golem app build. Nothing was dynamic in that generated file, so it is no longer generated just part of the template.
|
|
||
| templates: | ||
| ts: | ||
| build: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the TS agent build flow.
- two calls to
npx, first generated the type info, the second runs rollup to generate the bundledmain.js - then we inject the
main.jsinto pre-compiledgolem_agent.wasm - then generate the static agent wrapper (this first extracts the agent types by instantiating the component and this is where we currently fail because of the old package version)
- then compose with the generated wrapper to get the final component
|
Work in progress
Resolves golemcloud/golem#1831
Resolves golemcloud/golem#1840
A couple of things are not good enough for a final release, but I would deal with them separately from this PR:
defaultTS template group to be the agent one, because the CLI only supports the one nameddefaultat the moment (even though it is prepared to support multiple template groups per language). So the only TS template available now is the new one.pollableandinput-streamandoutput-stream). I could not figure out how to do it properly and my guess is that it will have to be done in the wasmtime fork because some things are not exposed. Also I noticed that wasmtime itself has a very similar function to mock unavailable imports but that does not work either (for multiple reasons, there is also an open ticket about it in wasmtime).golem_agent.wasmas the source wit and with that things are working - more or less. The transformation from the "source wit" to the "generated wit dir" is turned off in this case and this definitely breaks all the dependency related golem-cli features. This will have to be solved, at least partially, to be able to link with the golem-ai components, but can be done separately.Testable with
Requires a new published version of the agent SDK (golemcloud/golem-agentic#12) to finish testing the wrapping steps because right now it fails on the agent type extraction due to the wrong
golem:rpcversion used in the last published SDK package.