Transcription: OpenAgents Episode 053 - Loading WASM Plugins
June 9, 2026 ยท View on GitHub
Source: https://twitter.com/OpenAgentsInc/status/1747791884414599350 Wiki source: https://raw.githubusercontent.com/wiki/OpenAgentsInc/openagents/Video-Series.md Media title: OpenAgents - Episode 053: Loading WASM Plugins After a foray through the weeds of ... Upload date: 20240118 Transcription model: mlx-whisper/mlx-community/whisper-tiny Generated at: 2026-06-01T20:13:20Z
Machine-generated transcript. Review speaker labels and wording before using this as quote-grade source material.
[00:00] Christopher David: So we've learned two things. One is that HTML works just fine for our purposes. I enjoy building it.
[00:07] Christopher David: I am seeing a path to this improving simplicity and velocity. So we're going to keep going on HTML.
[00:13] Christopher David: And we learned that we can run plugins in Lairvelle.
[00:23] Christopher David: I was concerned originally that we might want to have our plugin play around being rust.
[00:30] Christopher David: But this is a Wazom plugin being pulled in fine to Lairvelle.
[00:35] Christopher David: I just had to monkey with the PHP, I and I settings a little bit and stuff.
[00:40] Christopher David: So we are going to kind of revisit the ideas of our plugin registry video.
[00:47] Christopher David: But pull them into Lairvelle. And my goal for the end of this video is to have basic data models of plugins and feature in unit tests.
[01:00] Christopher David: And specifically to be able to do the relevant functions that Ektsism gives us for working with Wazom modules.
[01:11] Christopher David: Like from our the PHP SDK.
[01:16] Christopher David: And create unit tests around a well called a plugin class for working with these Wazom plugins.
[01:26] Christopher David: For doing things like loading manifests, reading about the attributes of each plugin,
[01:36] Christopher David: and maybe even executing the plugin. Like if we can see what the parameters of the plugin are,
[01:42] Christopher David: we'll do this probably for the like count vowels demo one.
[01:46] Christopher David: This is what we want to do. We want to do plugin call, count vowel is hello world.
[01:51] Christopher David: And get this kind of data, but in like a Lairvelle plugin because next we're going to be building a public registry in HTML where people can submit their own plugins.
[02:02] Christopher David: And then after that we'll make it so that people can easily pull those plugins into agents and start building up a agents using these plugins.
[02:11] Christopher David: Pretty cool.
[02:16] Christopher David: Okay, so let's first take us been through the code that we have working right now.
[02:26] Christopher David: Let's open up the code base.
[02:33] Christopher David: Where are we at?
[02:41] Christopher David: All right, we'll call this plugins one.
[02:45] Christopher David: And let's go take a look right now at, okay, we have ex-tism, I made an ex-tism controller.
[02:57] Christopher David: And this is code I just copy pasted from the example in here.
[03:10] Christopher David: So what are we doing?
[03:17] Christopher David: We are taking a wasm file that is somewhere on the internet or we can load it from locally if we want to host it ourselves.
[03:33] Christopher David: We're generating a manifest from that.
[03:42] Christopher David: We're generating a plugin from the manifest and we'll dig into what each of these types are.
[03:47] Christopher David: And then on the plugin we're calling the method called count vowels for yellow world.
[03:56] Christopher David: And then we're adding a double in the output.
[03:59] Christopher David: And that corresponds to string 43 counts total vowels.
[04:06] Christopher David: That's the vowels that we're looking for.
[04:09] Christopher David: Oh, and if you're including a Y.
[04:14] Christopher David: Okay, so here's an example of editing the config of the manifest.
[04:22] Christopher David: And if you're using a language that you want to use in the language, you can use a language that you want to use in the language.
[04:37] Christopher David: And if you're using a language that you want to use in the language, you can use a language that you want to use in the language.
[04:48] Christopher David: So you can see how these kind of, it's just like a little building block that one person could build.
[04:58] Christopher David: Other people can pull in.
[05:00] Christopher David: It's extensible.
[05:02] Christopher David: And these things can work together.
[05:05] Christopher David: This is the right kind of building block for agents.
[05:11] Christopher David: We wouldn't know. I wouldn't say much as we would love to have everyone just.
[05:16] Christopher David: Only paying open agents and using our thing as a service that's just like a giant monopolistic model if we would not enjoy that.
[05:26] Christopher David: But, you know, we don't think that that's how a company should be structured.
[05:32] Christopher David: And this allows for more of a open community driven approach, allowing a bunch of different companies to participate.
[05:40] Christopher David: And people open source for the win.
[05:44] Christopher David: Okay.
[05:46] Christopher David: Let's maybe go take a quick look at these types.
[05:52] Christopher David: I have somehow messed up my go-to definition here.
[06:01] Christopher David: But maybe we'll just go look at the actual source code.
[06:09] Christopher David: Let's go see where manifest and plug in or define real quick.
[06:20] Christopher David: Okay. The first thing is URL wasmsource for things.
[06:23] Christopher David: It's pretty clear.
[06:27] Christopher David: Is that defined here?
[06:31] Christopher David: Yeah.
[06:32] Christopher David: So wasmsource has
[06:38] Christopher David: URL, optional name, optional hash.
[06:42] Christopher David: And the hash is for kind of, I guess, verifying that it is what you expect, which is important if you're doing particularly things at handle payments or maybe do option, you know, actions with private keys that you pass in.
[07:00] Christopher David: And then you have to do that.
[07:04] Christopher David: And then you have to do that.
[07:08] Christopher David: And then you have to do that.
[07:12] Christopher David: Okay.
[07:14] Christopher David: Okay.
[07:16] Christopher David: Okay.
[07:18] Christopher David: Okay.
[07:21] Christopher David: Okay.
[07:23] Christopher David: Okay.
[07:25] Christopher David: Okay.
[07:27] Christopher David: Okay.
[07:28] Christopher David: Okay.
[07:30] Christopher David: Okay.
[07:31] Christopher David: Okay.
[07:33] Christopher David: Okay.
[07:35] Christopher David: Okay.
[07:37] Christopher David: Okay.
[07:39] Christopher David: Okay.
[07:41] Christopher David: Okay.
[07:43] Christopher David: Okay.
[07:45] Christopher David: Okay.
[07:47] Christopher David: Okay.
[07:49] Christopher David: Okay.
[07:51] Christopher David: Okay.
[07:53] Christopher David: Okay.
[07:54] Christopher David: Okay.
[07:55] Christopher David: Okay.
[07:56] Christopher David: Okay.
[07:57] Christopher David: Okay.
[07:59] Christopher David: Okay.
[08:01] Christopher David: Okay.
[08:03] Christopher David: Okay.
[08:05] Christopher David: Okay.
[08:07] Christopher David: Okay.
[08:08] Christopher David: Okay.
[08:10] Christopher David: Okay.
[08:11] Christopher David: Okay.
[08:12] Christopher David: Okay.
[08:13] Christopher David: Okay.
[08:14] Christopher David: Okay.
[08:15] Christopher David: Okay.
[08:16] Christopher David: Okay.
[08:17] Christopher David: Okay.
[08:18] Christopher David: Okay.
[08:19] Christopher David: Okay.
[08:20] Christopher David: Okay.
[08:21] Christopher David: Okay.
[08:22] Christopher David: Okay.
[08:23] Christopher David: Okay.
[08:25] Christopher David: Okay.
[08:26] Christopher David: Okay.
[08:27] Christopher David: Okay.
[08:28] Christopher David: Okay.
[08:30] Christopher David: Okay.
[08:32] Christopher David: Okay.
[08:33] Christopher David: Okay.
[08:34] Christopher David: Okay.
[08:35] Christopher David: Okay.
[08:36] Christopher David: Okay.
[08:37] Christopher David: Okay.
[08:38] Christopher David: Okay.
[08:39] Christopher David: Okay.
[08:40] Christopher David: Okay.
[08:41] Christopher David: Okay.
[08:42] Christopher David: Okay.
[08:43] Christopher David: Okay.
[08:44] Christopher David: Okay.
[08:45] Christopher David: Okay.
[08:46] Christopher David: Okay.
[08:47] Christopher David: Okay.
[08:48] Christopher David: Okay.
[08:49] Christopher David: Okay.
[08:50] Christopher David: Okay.
[08:51] Christopher David: Okay.
[08:52] Christopher David: Okay.
[08:53] Christopher David: Okay.
[08:54] Christopher David: Okay.
[08:55] Christopher David: Okay.
[08:56] Christopher David: Okay.
[08:57] Christopher David: Okay.
[08:59] Christopher David: Okay.
[09:00] Christopher David: Okay.
[09:01] Christopher David: Okay.
[09:02] Christopher David: Okay.
[09:03] Christopher David: Okay.
[09:04] Christopher David: Okay.
[09:05] Christopher David: Okay.
[09:06] Christopher David: Okay.
[09:07] Christopher David: Okay.
[09:08] Christopher David: Okay.
[09:09] Christopher David: Okay.
[09:10] Christopher David: Okay.
[09:11] Christopher David: Okay.
[09:12] Christopher David: Okay.
[09:13] Christopher David: Okay.
[09:14] Christopher David: Okay.
[09:15] Christopher David: Okay.
[09:16] Christopher David: Okay.
[09:17] Christopher David: Okay.
[09:18] Christopher David: Okay.
[09:19] Christopher David: Okay.
[09:20] Christopher David: Okay.
[09:21] Christopher David: Okay.
[09:22] Christopher David: Okay.
[09:23] Christopher David: Okay.
[09:24] Christopher David: So the plugin requires the ex-tism library.
[09:30] Christopher David: FFI thing.
[09:31] Christopher David: That's something I had to go to the PHP.
[09:33] Christopher David: I and I to enable on the server.
[09:36] Christopher David: It's like the C interface.
[09:38] Christopher David: Because it requires like a C stuff.
[09:42] Christopher David: All right.
[09:43] Christopher David: So initialize a plugin.
[09:44] Christopher David: Constructor.
[09:45] Christopher David: It requires a manifest describing the laws of binary and
[09:49] Christopher David: distributions.
[09:50] Christopher David: And then with Wazee.
[09:53] Christopher David: So Wazee is required for I'm still learning about this.
[09:57] Christopher David: Certain additional system permissions if you need to access like device randomness or something.
[10:05] Christopher David: All right.
[10:06] Christopher David: This live, access and plugin new blah blah blah.
[10:10] Christopher David: Check if the plugin contains a function.
[10:15] Christopher David: Call, call a function in the plugin and return there result.
[10:27] Christopher David: Logging version.
[10:28] Christopher David: Okay.
[10:29] Christopher David: That's simple.
[10:30] Christopher David: It's just function calling in the plugins.
[10:42] Christopher David: All of those developers building open AI plugins.
[10:45] Christopher David: Sorry, building open AI like doing function calling.
[10:52] Christopher David: There's no marketplace for functions.
[10:54] Christopher David: There should be a marketplace for functions.
[10:55] Christopher David: They kind of have this plugins thing.
[10:57] Christopher David: Man, it's all just so tightly coupled to their particular way of doing things.
[11:04] Christopher David: We're going to crush them.
[11:09] Christopher David: It should be done as plugins.
[11:11] Christopher David: Okay.
[11:13] Christopher David: So we've just explored the entire functionality.
[11:17] Christopher David: That's pretty simple.
[11:19] Christopher David: So, access and has a concept of a plugin.
[11:24] Christopher David: We are going to build up our own concept of a plugin.
[11:35] Christopher David: Probably.
[11:36] Christopher David: So what do we want to do?
[11:37] Christopher David: I want to be able to write some tests that a model that we create can run this.
[11:49] Christopher David: So let's go write a failing test.
[11:51] Christopher David: First let's go make sure that our tests are passing.
[11:57] Christopher David: Yep.
[12:03] Christopher David: And we'll start with a feature test.
[12:13] Christopher David: Or would this be a unit test?
[12:14] Christopher David: What do I want to do?
[12:16] Christopher David: I want to run a plugin.
[12:24] Christopher David: Actually, maybe first I want to get the functions in a plugin.
[12:32] Christopher David: For now, we'll call this plugin test with my specify that later.
[12:37] Christopher David: Okay. Here's what I want.
[12:38] Christopher David: I want to know what functions a plugin has.
[12:43] Christopher David: Can read what functions a plugin has.
[12:56] Christopher David: Okay.
[12:57] Christopher David: And we're just going to say that we're going to assume we need models.
[13:03] Christopher David: Plug in.
[13:06] Christopher David: And we'll do plugin equals.
[13:10] Christopher David: Plug in factory creates.
[13:13] Christopher David: For now, we're going to use this demo.
[13:16] Christopher David: Count of vowels plugin.
[13:21] Christopher David: Thank you, co-pilot.
[13:27] Christopher David: So name count vowels. We don't want that.
[13:34] Christopher David: Well, count underscore vowels just seems like it's the name of the function.
[13:39] Christopher David: I'd rather call it like by an actual human name.
[13:44] Christopher David: So given just it has a name.
[13:47] Christopher David: It has.
[13:51] Christopher David: The wasm there.
[13:55] Christopher David: What am I expecting to be able to do?
[14:01] Christopher David: Let's try this functions equals.
[14:07] Christopher David: Plug in functions.
[14:11] Christopher David: Expect functions to be in a ring.
[14:15] Christopher David: Expect functions to contain count vowels.
[14:19] Christopher David: What else do you think? Co-pilot?
[14:24] Christopher David: Okay. Let's start with this.
[14:27] Christopher David: We're on our branch.
[14:29] Christopher David: All right. Let's do test.
[14:39] Christopher David: Okay. Let's run this.
[14:43] Christopher David: So app models plugin.
[14:53] Christopher David: Make model with a migration.
[14:57] Christopher David: Can I do factory to make a factory too?
[15:03] Christopher David: Heck yeah. Model factory migration. That's nice.
[15:10] Christopher David: Let's commit that.
[15:18] Christopher David: Okay. So let's just see what fails now.
[15:21] Christopher David: So I'm going to find column.
[15:23] Christopher David: Call name of relation plugins does not exist.
[15:26] Christopher David: Now what I'm going to do here is I'm going to drop down to unit test.
[15:32] Christopher David: And I'm going to say it has a name.
[15:36] Christopher David: And we'll pull and use app models plugin.
[15:45] Christopher David: Co-pilot cannot complete your else.
[15:47] Christopher David: Actually don't need that there.
[15:52] Christopher David: Okay. So now pf.
[15:57] Christopher David: Well, I'm going to run plugin times.
[16:00] Christopher David: It's called the same thing. So both of those were run.
[16:03] Christopher David: All right. So I'm going to find column name.
[16:06] Christopher David: And we'll go to our plugins table.
[16:16] Christopher David: Is text the right thing?
[16:22] Christopher David: String.
[16:25] Christopher David: Text is too long. I think.
[16:36] Christopher David: Okay. column.
[16:38] Christopher David: Okay.
[16:44] Christopher David: Okay.
[16:49] Christopher David: Okay.
[16:52] Christopher David: Okay.
[16:55] Christopher David: Okay.
[17:00] Christopher David: So we'll go to our unit test.
[17:07] Christopher David: Okay.
[17:10] Christopher David: So we'll go to our unit test.
[17:15] Christopher David: Okay.
[17:18] Christopher David: Okay.
[17:21] Christopher David: So we'll go to our unit test.
[17:30] Christopher David: It.
[17:34] Christopher David: First of all, does this pass?
[17:44] Christopher David: Yep.
[17:47] Christopher David: Has a wasm URL?
[17:55] Christopher David: I can't tell what it's trying to do there.
[18:25] Christopher David: Okay.
[18:45] Christopher David: Okay. Now value in column name.
[18:48] Christopher David: I think we need to edit our factory.
[18:51] Christopher David: So we have a default name.
[18:55] Christopher David: And a default URL.
[18:59] Christopher David: Okay. So our unit test pass.
[19:01] Christopher David: It has a new has a wasm URL.
[19:03] Christopher David: Now we're getting call to undefined method plugin functions.
[19:14] Christopher David: So it.
[19:17] Christopher David: It can.
[19:20] Christopher David: Read or functions of plugin has.
[19:25] Christopher David: I don't need to do that because the factory takes care of that.
[19:27] Christopher David: In fact, I don't need to do this at all.
[19:37] Christopher David: Okay. We're kind of like.
[19:40] Christopher David: Doing exactly the feature test.
[19:42] Christopher David: Okay.
[19:44] Christopher David: All right.
[19:45] Christopher David: Call to undefined method plugins.
[19:49] Christopher David: Or functions.
[19:51] Christopher David: So on the model, we say public function.
[19:56] Christopher David: Yeah.
[19:59] Christopher David: You want to start with the minimum needed to get it to pass, minute does.
[20:05] Christopher David: Returns functions.
[20:13] Christopher David: Hmm.
[20:14] Christopher David: You want to start with the minimum needed to pass.
[20:18] Christopher David: You want to start with the minimum needed to pass.
[20:26] Christopher David: To make it fail, I might want to assert that it contains a manifest thing, but I don't know what to assert right now.
[20:32] Christopher David: So I'm just going to, we're just going to kind of say what we're not going to do that.
[20:38] Christopher David: How do we call the
[20:44] Christopher David: functions? How do we learn that? I don't know.
[20:48] Christopher David: So what we're going to do is we're going to go pull in these things.
[20:55] Christopher David: And how do I rename this?
[21:01] Christopher David: There we go. Exism plugin.
[21:07] Christopher David: Oh look at this.
[21:08] Christopher David: See, I don't know that exism plugin has the thing called functions.
[21:18] Christopher David: Let's go take a look at the source again.
[21:22] Christopher David: Maybe they're dogs explain it, but reading the source is fun. If it's this easy.
[21:26] Christopher David: Does it have a thing called functions?
[21:28] Christopher David: No, it has function exists. That doesn't help us.
[21:32] Christopher David: I want to list of all of them.
[21:34] Christopher David: I'm guessing the manifest has something we need.
[21:54] Christopher David: Maybe it doesn't.
[21:58] Christopher David: I'm guessing it does.
[22:00] Christopher David: So it's first just kind of take a look at each one of these.
[22:06] Christopher David: See what it looks like.
[22:16] Christopher David: Okay, so here we have fake URL.
[22:18] Christopher David: Howl.com.
[22:22] Christopher David: Alright, so we don't actually want our factory to use a fake URL.
[22:31] Christopher David: Alright, good. That in there.
[22:34] Christopher David: Okay, so we have URL.
[22:36] Christopher David: Capiles.
[22:38] Christopher David: That is our URL.
[22:40] Christopher David: Wasm source.
[22:46] Christopher David: That's fine.
[22:47] Christopher David: Okay, let's take a look at the manifest.
[23:00] Christopher David: So you got the source memory.
[23:10] Christopher David: A lot of those lot of paths can fit.
[23:26] Christopher David: Now let's take a look at the plug-in.
[23:30] Christopher David: Okay.
[23:42] Christopher David: So the first thing I'm going to do is first of all, I'm just going to see if this works.
[24:00] Christopher David: Okay, so plug-in function exists works and let's just make sure that fails.
[24:14] Christopher David: Or says false. Okay.
[24:18] Christopher David: So I see that this is calling into the lib.
[24:24] Christopher David: Is lib public or private?
[24:27] Christopher David: lib is private. We cannot access it.
[24:37] Christopher David: So I don't see a way using the functions that they gave us unless I miss something to list all of the functions.
[24:51] Christopher David: But I'm curious now.
[24:54] Christopher David: This plug-in is reaching into this lib.
[24:58] Christopher David: This lib being private lib.
[25:01] Christopher David: Exxstism.
[25:03] Christopher David: And I'm curious what this has.
[25:13] Christopher David: That calls this exstism.
[25:16] Christopher David: Exstism being.
[25:18] Christopher David: So that there's where, if I guess it's reaching into the C library or something.
[25:48] Christopher David: Okay.
[25:58] Christopher David: Okay.
[26:10] Christopher David: Out of curiosity, I want to take a quick spin through.
[26:18] Christopher David: Okay.
[26:22] Christopher David: They have a dev tool for inspecting a wasom that I think pulls the functions in.
[26:27] Christopher David: So one thing I want to know is how they do it.
[26:31] Christopher David: And maybe there's just something missing from the PHP SDK.
[26:34] Christopher David: I don't know.
[26:36] Christopher David: Sure.
[26:38] Christopher David: Where is the interface?
[26:48] Christopher David: Okay.
[26:55] Christopher David: Let's try this.
[27:03] Christopher David: Okay.
[27:04] Christopher David: Okay.
[27:06] Christopher David: Okay.
[27:09] Christopher David: Okay.
[27:12] Christopher David: I have that from...
[27:16] Christopher David: Do you have that inventor?
[27:27] Christopher David: Yeah.
[27:28] Christopher David: So I don't want my desktop to.
[27:42] Christopher David: Okay.
[27:55] Christopher David: So the...
[27:57] Christopher David: And the question of one was, is it possible to extract the functions from a...
[28:03] Christopher David: Wasom?
[28:04] Christopher David: So it's obviously possible.
[28:05] Christopher David: And then the question is, are we able to do it with the PHP SDK?
[28:09] Christopher David: Or do we need to hack something or make a feature request that's that be added to the SDK?
[28:13] Christopher David: Let's take a look through the Mod Server code base a little bit.
[28:17] Christopher David: I'm going to already put it down.
[28:32] Christopher David: And what did it call it on the interface?
[28:36] Christopher David: It lists the module exports.
[28:45] Christopher David: Although this might just be the CLI to not the web interface tool.
[28:51] Christopher David: But let's see if we can find it anyways.
[29:06] Christopher David: Thank you.
[29:36] Christopher David: The CLI provides a novel feature to process and validate a web assembly module based on
[29:58] Christopher David: the policy slash properties of the module that you define.
[30:01] Christopher David: And then check file to clear certain properties of the web assembly module and
[30:05] Christopher David: Module of the verify that they're true or report which properties of your binary and
[30:10] Christopher David: R&B.
[30:13] Christopher David: I wonder if this is what they're doing?
[30:15] Christopher David: No, they wouldn't know in advance.
[30:31] Christopher David: So a bunch of these kind of validation things will be useful once we get like a role.
[30:51] Christopher David: Ecosystem going of plugins and making sure that plugins do it.
[30:55] Christopher David: They say they're going to do et cetera.
[30:58] Christopher David: Search module.
[31:58] Christopher David: Thank you.
[32:28] Christopher David: Function exports provided by the module.
[32:41] Christopher David: Okay, this is from the web assembly design.
[32:46] Christopher David: Let's read about this.
[32:48] Christopher David: The distributable loadable and executable unit of code and web assembly is called a module.
[32:53] Christopher David: At runtime, a module can be instantiated with a set of important values to produce an instance, which is an
[32:58] Christopher David: immutable tool referencing all the state accessible to the running module.
[33:02] Christopher David: Multiple module instances can access the same shared state, which is the basis for dynamic linking
[33:06] Christopher David: in web assembly.
[33:07] Christopher David: Web assembly modules are also meant to integrate with ES6 modules in the future.
[33:13] Christopher David: A module contains the following sections.
[33:18] Christopher David: Export, I guess, is what we need.
[33:30] Christopher David: Export.
[33:31] Christopher David: Immodulkin declarer sequence of exports, which are returned at instantiation times the host environment.
[33:36] Christopher David: Each export has three fields, a name which is required to be valued to F8, whose meaning is defined by the host environment.
[33:44] Christopher David: A type indicating whether the export is a function global memory or table, and then index into the types corresponding index space.
[33:53] Christopher David: All definitions are exportable.
[33:56] Christopher David: Functions, global, linear memories, and tales.
[33:59] Christopher David: The meaning of the meaning and export definition is defined by the host environment.
[34:04] Christopher David: However, if another web assembly instance import the definition, then both instances will share the same definition and
[34:11] Christopher David: state, global variable value, lay, and remember, sure.
[34:15] Christopher David: Export instance, be unique.
[34:17] Christopher David: Okay.
[34:19] Christopher David: So how do I get the exports of a module?
[34:29] Christopher David: Let's see if chat, LGBT has anything to say about this.
[34:39] Christopher David: I think that's a good idea.
[34:49] Christopher David: I think that's a good idea.
[34:55] Christopher David: I think that's a good idea.
[35:02] Christopher David: Wasm time page p, while I know that at least some parts of X-Tism are built on wasm time, so that might be fine.
[35:17] Christopher David: Okay.
[35:32] Christopher David: So this gives us, okay.
[35:45] Christopher David: So this is functionality that maybe they could add to the PHP SDK for X-Tism unless I'm missing it.
[35:54] Christopher David: But let's just play around with this wasm time thing.
[35:59] Christopher David: Because I really want the list of the exports.
[36:04] Christopher David: And I don't see a way to do it through the, what we have from the X-Tism SDK.
[36:15] Christopher David: So, where we at our test.
[36:29] Christopher David: Okay.
[36:39] Christopher David: Let's see if wasm time PHP can wasmrphp.
[37:00] Christopher David: If you need a list of wasm files export to a typically use a tool designed for this purpose such as the wasm object dump tool from the web assembly binary toolkit.
[37:09] Christopher David: This tool can provide a disassembly of a wasm binary including a list of its exports.
[37:14] Christopher David: However, this would need to be done outside of PHP, so to do this shell script or other system level programming environment.
[37:21] Christopher David: So we are already running this like X-Tism CLI thingy that's I guess interacting with the CFFI.
[37:52] Christopher David: Okay.
[38:01] Christopher David: So what I'm going to do is table that for now.
[38:04] Christopher David: I want that I think that's going to be needed for us.
[38:08] Christopher David: But let's just change this around for now.
[38:12] Christopher David: Let's skip this test.
[38:18] Christopher David: And for now, we're just going to do a test or something that I know is possible with the SDK which is can execute plugin.
[38:33] Christopher David: Can execute plugin function.
[38:36] Christopher David: Now we know that the count files about count files function exists so we can like put that in.
[38:43] Christopher David: But we need an answer to how we retrieve functions from a given wasm module.
[38:51] Christopher David: Okay, can execute plugin function.
[39:00] Christopher David: With default config. I don't care about that.
[39:11] Christopher David: All right, we're in feature test.
[39:20] Christopher David: You know, this might not even really belong in feature test.
[39:23] Christopher David: It might just belong in the unit test.
[39:28] Christopher David: Let's just do the same thing.
[39:38] Christopher David: Let's just do the same thing.
[39:43] Christopher David: Let's just do the same thing.
[39:49] Christopher David: I want to know what the signature of the output is in advance.
[39:59] Christopher David: Okay, plug in has what the hell that I do do.
[40:16] Christopher David: I like hit the VIM undo and then the editor redo.
[40:29] Christopher David: I'm going to be switching to full VIM since so that will hopefully not happen again.
[40:36] Christopher David: Okay, that's feature test.
[40:39] Christopher David: I don't want to feature test.
[40:40] Christopher David: Okay, watch.
[40:41] Christopher David: Okay, watch.
[40:42] Christopher David: Okay, it's right there.
[40:48] Christopher David: Okay, one of them is fine.
[40:52] Christopher David: Okay, plug in call.
[40:56] Christopher David: Call does not exist.
[40:58] Christopher David: So.
[41:11] Christopher David: Is that work?
[41:20] Christopher David: There we go.
[41:23] Christopher David: Count three.
[41:32] Christopher David: So in this case, we're expecting the output to be this thing.
[41:39] Christopher David: Okay.
[41:46] Christopher David: Okay.
[41:54] Christopher David: Cool, so we have a plug-in model.
[42:05] Christopher David: We are calling or like loading it in and calling a function.
[42:11] Christopher David: We're kind of like assuming we know an advance with the actual function.
[42:15] Christopher David: Name is and what the input is expected to be.
[42:24] Christopher David: And I guess the output is going to depend on what it chooses to return.
[42:29] Christopher David: So I'm just going to keep that the way that it is.
[42:31] Christopher David: Okay, I think that's a good starting point for this video.
[42:35] Christopher David: We have the ability now to work directly with plug-ins.
[42:39] Christopher David: We are starting to build up our plug-in model based on what's enabled by the underlying
[42:43] Christopher David: X's and SDK.
[42:44] Christopher David: We can start to reason about how we're going to be listing these in a directory.
[42:48] Christopher David: We're just missing one thing I think which is to be able to pull in like the list
[42:54] Christopher David: of plug-ins.
[42:55] Christopher David: So we can kind of show relevant manifest and plug-ins input output, et cetera in public
[43:02] Christopher David: listing that people will be able to easily pull these in and we'll keep building this up.
[43:08] Christopher David: It's easy.
[43:09] Christopher David: Okay, we're going to keep going.
[43:12] Christopher David: Thank you to the Xism team, gave me this answer.
[43:17] Christopher David: So to parse the module to get the functions, they have a plug-in for that.
[43:24] Christopher David: So let's try it out.
[43:27] Christopher David: We're going to first load this plug-in.
[43:40] Christopher David: We're going to type up this.
[43:47] Christopher David: So we're going to test this later.
[43:48] Christopher David: First I just want to let it get this parse module.
[44:02] Christopher David: What I'm going to do is I'm going to test called it can parse can be parsed.
[44:12] Christopher David: I just want to simply let it run that function.
[44:21] Christopher David: Pf can be parsed.
[44:57] Christopher David: We'll set the WASM URL to try and instantiate it to plug-in module.
[45:09] Christopher David: All right, let's just keep it simple for now.
[45:19] Christopher David: Let's just put this in.
[45:29] Christopher David: Plug-in call.
[45:36] Christopher David: We're going to call parse module.
[45:41] Christopher David: We're going to pass in the bytes of the this one.
[45:55] Christopher David: So you need to load the bytes of a URL.
[46:18] Christopher David: Let's make it a function.
[46:20] Christopher David: This wasm bytes.
[46:23] Christopher David: I've it function WASM bytes.
[46:29] Christopher David: And I'll say load WASM bytes from URLs.
[46:36] Christopher David: If copilot knows what to do here.
[46:41] Christopher David: WASM equals file get contents, but then I need to be this WASM URL.
[46:50] Christopher David: Okay, I'll have curiosity.
[46:53] Christopher David: Let's do this and see if we have some ugly bytes.
[47:00] Christopher David: Yeah, look at the bytes.
[47:05] Christopher David: They're not ugly.
[47:06] Christopher David: They're beautiful.
[47:07] Christopher David: Okay.
[47:14] Christopher David: Okay, that was easy now.
[47:15] Christopher David: Plug-in call.
[47:17] Christopher David: And this is going to return the prototype data.
[47:29] Christopher David: And what does that look like?
[47:47] Christopher David: Surged JSON panic game.
[47:49] Christopher David: Okay, how cool is this?
[47:52] Christopher David: Look, I don't know how to do this.
[47:53] Christopher David: There's a function that the dilipso the team behind the X is and put out.
[47:59] Christopher David: It has the thing I just put in and I'm calling the function on it.
[48:04] Christopher David: That's pretty bother.
[48:06] Christopher David: Okay, so now I have prototype data.
[48:11] Christopher David: And it has to be desirialized into the PHP type for module.
[48:16] Christopher David: Okay.
[48:17] Christopher David: Let's just go see if our friend's chatty GPT can help us.
[48:41] Christopher David: Do you know how I can do it?
[48:58] Christopher David: Install the prototype of PHP extension.
[49:02] Christopher David: It's been lying to me today.
[49:07] Christopher David: You need to generate PHP classes.
[49:37] Christopher David: Okay, we're a lot closer.
[49:46] Christopher David: We got these bytes.
[49:52] Christopher David: All right, let's learn about PHP prototype.
[50:03] Christopher David: Let's see if this is an actual thing.
[50:10] Christopher David: Eight years ago, well, this actually worked.
[50:21] Christopher David: Does it actually work?
[50:25] Christopher David: All right, after some finagling and diving into the wonderful world of proto and having
[50:35] Christopher David: help of the X-tism team, we were able to get this to pass.
[50:39] Christopher David: Here's what we had to do.
[50:44] Christopher David: So the X-tism PHP SDK itself does not have the ability to call like find all the functions.
[50:53] Christopher David: There's a separate module that we load in to do that.
[50:57] Christopher David: We pass it in the bytes of the wasm.
[51:00] Christopher David: It'll parse it.
[51:02] Christopher David: And then we create this module from using this PHP generated class over here.
[51:13] Christopher David: The module generated from the API.protophile that we got from the X-tism mod scripts that kind
[51:30] Christopher David: of generate and analyze.
[51:32] Christopher David: Save dev tools around dealing with these wasm things.
[51:40] Christopher David: We converted that to proto.
[51:43] Christopher David: We create from that module and then run this merge from string thing to kind of take the
[51:58] Christopher David: parsed proto buff data back from that module, merge it into that thing, which knows
[52:05] Christopher David: how to parse it.
[52:07] Christopher David: Then we're able to call the functions on the module, like get exports.
[52:13] Christopher David: And module also gives us metadata things we can call.
[52:19] Christopher David: And you can kind of see the API for that either in the module file, which is now in our
[52:23] Christopher David: code base.
[52:25] Christopher David: Protogin thing.
[52:27] Christopher David: It's got explanations of different fields.
[52:31] Christopher David: Hash is a super cool one.
[52:32] Christopher David: This is a shot to 56 hash of the module's raw bytes.
[52:37] Christopher David: So if you've got one module and you know it's hash and if it doesn't change then you
[52:42] Christopher David: know that that's associated with one particular iteration of a module, if it changes,
[52:46] Christopher David: then you know that the code changes.
[52:48] Christopher David: That's cool for verifying source.
[52:51] Christopher David: That's nice.
[52:54] Christopher David: I mentioned metadata in here, including like the source language it was written in.
[53:00] Christopher David: And for exports, we can loop through each of the exports and get the function.
[53:06] Christopher David: We can get the function name.
[53:07] Christopher David: I'm still figuring out how to get the.
[53:12] Christopher David: It also has the like parameter data of what it takes in returns.
[53:15] Christopher David: I do a little more work to figure out how to properly decode that and pass it here.
[53:21] Christopher David: Right now we can take a look at the example of what our new parse function returns.
[53:29] Christopher David: The module ID, the hash, how many exports it has, the size, module location, source language
[53:36] Christopher David: rust and export scount vows.
[53:39] Christopher David: This is what we've been looking for.
[53:41] Christopher David: And we now have it.
[53:43] Christopher David: So with this and also sort of like the parameters that go into and out of the function, we
[53:49] Christopher David: have everything that we need to display a program registry and playgrounds, like a full
[53:55] Christopher David: mechanism of interactive with all these plugins, strictly via opagents.com, pretty exciting.
[54:02] Christopher David: So if I remove the diand up there, I'll probably end up putting all these tests into integration
[54:09] Christopher David: because they're taking a few seconds to run through all of them.
[54:14] Christopher David: But all of our tests pass.
[54:17] Christopher David: Okay, so we've done like the way to leave the last amount of validation to know that this
[54:22] Christopher David: is something that's appropriate for us to pull entirely into our layer of a code base.
[54:29] Christopher David: So we're going to do that next and next build up some fun UI and let people start to
[54:35] Christopher David: bang it on this and building plugins.
[54:38] Christopher David: Real soon.
[54:39] Christopher David: See ya.