Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/build/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const KINODE_WIT_1_0_0_URL: &str =
const WASI_VERSION: &str = "27.0.0"; // TODO: un-hardcode
const DEFAULT_WORLD_0_7_0: &str = "process";
const DEFAULT_WORLD_0_8_0: &str = "process-v0";
const DEFAULT_WORLD_1_0_0: &str = "process-v1";
const KINODE_PROCESS_LIB_CRATE_NAME: &str = "kinode_process_lib";

#[derive(Debug, Clone, Serialize, Deserialize)]
Expand Down Expand Up @@ -1564,7 +1565,8 @@ async fn compile_package(
let wit_world = default_world
.unwrap_or_else(|| match metadata.properties.wit_version {
None => DEFAULT_WORLD_0_7_0,
Some(0) | _ => DEFAULT_WORLD_0_8_0,
Some(0) => DEFAULT_WORLD_0_8_0,
Some(1) | _ => DEFAULT_WORLD_1_0_0,
})
.to_string();

Expand Down
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1049,8 +1049,8 @@ async fn make_app(current_dir: &std::ffi::OsString) -> Result<Command> {
.short('l')
.long("language")
.help("Programming language of the template")
.value_parser(["rust"])
//.value_parser(["rust", "python", "javascript"]) // TODO: resupport
.value_parser(["rust", "javascript"])
//.value_parser(["rust", "python", "javascript"])
.default_value("rust")
)
.arg(Arg::new("TEMPLATE")
Expand Down
2 changes: 1 addition & 1 deletion src/new/componentize.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const witPath = 'target/wit';

const { component } = await componentize(
jsSource,
{ witPath: witPath, worldName: worldName, debug: false },
{ witPath: witPath, worldName: worldName, debug: false, disableFeatures: ['http'] },
);

await writeFile(`../pkg/${processName}.wasm`, component);
2 changes: 1 addition & 1 deletion src/new/templates/javascript/no-ui/chat/chat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
"author": "template.os",
"license": "MIT",
"dependencies": {
"@bytecodealliance/componentize-js": "0.5.0"
"@bytecodealliance/componentize-js": "0.15.1"
}
}
25 changes: 21 additions & 4 deletions src/new/templates/javascript/no-ui/chat/chat/src/lib.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { printToTerminal, receive, sendAndAwaitResponse, sendResponse } from "kinode:process/standard@0.7.0";
import { printToTerminal, receive, sendAndAwaitResponse, sendResponse } from "kinode:process/standard@1.0.0";

function parseAddress(addressString) {
const [node, rest] = addressString.split('@');
Expand Down Expand Up @@ -36,48 +36,62 @@ function addToArchive(conversation, author, content, messageArchive) {
}

function handleMessage(ourNode, messageArchive) {
printToTerminal(0, `a`);
const [source, message] = receive();
printToTerminal(0, `b`);

if (message.tag == 'response') {
throw new Error(`unexpected Response: ${JSON.stringify(message.val)}`);
} else if (message.tag == 'request') {
printToTerminal(0, `c`);
const { bytes: bodyBytes, string: body0 } = inputBytesToString(message.val.body)
printToTerminal(0, `d`);
const body = JSON.parse(body0);
printToTerminal(0, `e`);
const encoder = new TextEncoder();
if (body.Send) {
printToTerminal(0, `f`);
const { target, message: messageText } = body.Send;
printToTerminal(0, `g`);
if (target === ourNode) {
printToTerminal(0, `h`);
printToTerminal(0, `chat|${source.node}: ${messageText}`);
printToTerminal(0, `i`);
messageArchive = addToArchive(
source.node,
source.node,
messageText,
messageArchive,
);
printToTerminal(0, `j`);
} else {
printToTerminal(0, `k`);
sendAndAwaitResponse(
{
node: target,
process: {
processName: "chat",
packageName: "chat",
publisherNode: "template.os"
publisherNode: "template.os",
}
},
{
inherit: false,
expectsResponse: 5,
body: bodyBytes,
metadata: null
metadata: null,
capabilities: [],
},
null
null,
);
printToTerminal(0, `l`);
messageArchive = addToArchive(
target,
ourNode,
messageText,
messageArchive,
);
printToTerminal(0, `m`);
}
sendResponse(
{
Expand All @@ -88,7 +102,9 @@ function handleMessage(ourNode, messageArchive) {
},
null
);
printToTerminal(0, `n`);
} else if (body.History) {
printToTerminal(0, `o`);
sendResponse(
{
inherit: false,
Expand All @@ -98,6 +114,7 @@ function handleMessage(ourNode, messageArchive) {
},
null
);
printToTerminal(0, `p`);
} else {
throw new Error(`Unexpected Request: ${body}`)
}
Expand Down
2 changes: 1 addition & 1 deletion src/new/templates/javascript/no-ui/echo/echo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
"author": "template.os",
"license": "MIT",
"dependencies": {
"@bytecodealliance/componentize-js": "0.5.0"
"@bytecodealliance/componentize-js": "0.15.1"
}
}
2 changes: 1 addition & 1 deletion src/new/templates/javascript/no-ui/echo/echo/src/lib.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { printToTerminal, receive, sendResponse } from "kinode:process/standard@0.7.0";
import { printToTerminal, receive, sendResponse } from "kinode:process/standard@1.0.0";

function parseAddress(addressString) {
const [node, rest] = addressString.split('@');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
"author": "template.os",
"license": "MIT",
"dependencies": {
"@bytecodealliance/componentize-js": "0.5.0"
"@bytecodealliance/componentize-js": "0.15.1"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// 240103: Date.now() always returns 0, so this timing does not currently work.

import { printToTerminal, receive, sendResponse } from "kinode:process/standard@0.7.0";
import { printToTerminal, receive, sendResponse } from "kinode:process/standard@1.0.0";

function parseAddress(addressString) {
const [node, rest] = addressString.split('@');
Expand Down
4 changes: 3 additions & 1 deletion src/new/templates/rust/no-ui/chat/pkg/scripts.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
"root": false,
"public": false,
"request_networking": false,
"request_capabilities": [],
"request_capabilities": [
"chat:chat:template.os"
],
"grant_capabilities": [
"chat:chat:template.os"
],
Expand Down