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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,6 @@ docs/snippets/loop.log

/sdks/scala/out/
/sdks/scala/mill/out/

/sdks/moonbit/_build
/sdks/moonbit/.mooncakes
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ applying = "1.0.1"
arc-swap = "1.9.1"
arbitrary = "1.4.1"
assert2 = "0.3.15"
async-broadcast = "0.7.2"
async-fs = "2.1.2"
async-hash = "0.5.4"
async-lock = "3.4.0"
Expand Down
5 changes: 4 additions & 1 deletion cli/golem-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ test = true
harness = false

[dependencies]
golem-api-grpc = { workspace = true }
golem-client = { workspace = true }
golem-common = { workspace = true, default-features = true }

Expand Down Expand Up @@ -72,6 +73,7 @@ phf = { workspace = true }
portable-pty = { workspace = true }
prettyplease = { workspace = true }
proc-macro2 = { workspace = true }
prost = { workspace = true }
quote = { workspace = true }
regex = { workspace = true }
reqwest = { workspace = true }
Expand All @@ -92,9 +94,10 @@ tempfile = { workspace = true }
terminal_size = { workspace = true }
textwrap = { workspace = true }
thiserror = { workspace = true }
tokio = { workspace = true }
tokio = { workspace = true, features = ["io-util"] }
tokio-stream = { workspace = true }
tokio-tungstenite = { workspace = true }
tokio-util = { workspace = true }
toml = { workspace = true }
toml_edit = { workspace = true }
tracing = { workspace = true }
Expand Down
77 changes: 77 additions & 0 deletions cli/golem-cli/command-output-schema/command-output.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@
{
"$ref": "#/definitions/agent.invoke"
},
{
"$ref": "#/definitions/agent.invoke-session"
},
{
"$ref": "#/definitions/agent.list"
},
Expand Down Expand Up @@ -1559,6 +1562,63 @@
},
"additionalProperties": false
},
"agent.invoke-session": {
"type": "object",
"description": "One lifecycle document emitted per accepted, result, stream, or terminal event by `golem agent invoke` in structured formats. Parse stdout as a sequence of documents, not as one array or object.",
"x-golem-output-mode": "multi-document",
"x-golem-command": "agent invoke",
"required": [
"$type",
"kind",
"idempotencyKey"
],
"properties": {
"$type": {
"const": "agent.invoke-session"
},
"kind": {
"$ref": "#/definitions/AgentInvocationSessionEventKind"
},
"idempotencyKey": {
"type": "string"
},
"agentId": {
"type": "string"
},
"componentRevision": {
"type": "integer",
"minimum": 0
},
"outcome": {
"type": "string"
},
"reason": {
"type": "string"
},
"error": {
"type": "string"
},
"streamId": {
"type": "integer",
"minimum": 0
},
"parentStreamId": {
"type": "integer",
"minimum": 0
},
"path": {
"type": "string"
},
"offset": {
"type": "integer",
"minimum": 0
},
"value": {
"$ref": "#/definitions/JsonValue"
}
},
"additionalProperties": false
},
"agent.list": {
"type": "object",
"description": "Single structured output document emitted by `golem agent list`.",
Expand Down Expand Up @@ -4788,6 +4848,19 @@
"missed-messages"
]
},
"AgentInvocationSessionEventKind": {
"type": "string",
"enum": [
"accepted",
"rejected",
"result",
"item",
"end",
"stream-error",
"stream-cancel",
"finished"
]
},
"AgentDeletionMeta": {
"type": "object",
"required": ["componentName", "agentId"],
Expand Down Expand Up @@ -7373,6 +7446,10 @@
"type": "agent.invoke",
"rustType": "InvokeResultView"
},
{
"type": "agent.invoke-session",
"rustType": "AgentInvocationSessionEvent"
},
{
"type": "agent.list",
"rustType": "AgentsMetadataResponseView"
Expand Down
9 changes: 8 additions & 1 deletion cli/golem-cli/src/bridge_gen/moonbit/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ impl MoonBitBridgeGenerator {
"golemcloud/golem_sdk/interface/wasi/clocks/system-clock" @systemClock,
"golemcloud/golem_sdk/rpc",
"golemcloud/golem_sdk/schema_model" @model,
"golemcloud/golem_sdk/schema_model_host" @model_host,
}}
"#},
};
Expand Down Expand Up @@ -1448,7 +1449,7 @@ fn guest_decode_unstructured_binary(value : @model.SchemaValue, allowed : Array[
writer.indent();
writer.line("Some(tree) => {");
writer.indent();
writer.line("let value = @model.schema_value_from_wit(tree) catch {");
writer.line("let value = @model_host.schema_value_from_wit(tree) catch {");
writer.indent();
writer.line(format!(
"error => raise @common.AgentError::InvalidType({} + error.to_string())",
Expand Down Expand Up @@ -2924,6 +2925,12 @@ fn moonbit_string_literal(value: &str) -> String {
escaped
}

fn moonbit_char_option_literal(value: Option<char>) -> String {
value
.map(|value| format!("Some('\\u{{{:x}}}')", value as u32))
.unwrap_or_else(|| "None".to_string())
}

/// Whether a (ref-resolved) schema type becomes a generated MoonBit definition
/// (struct / enum). Other named defs are inlined at their use sites.
fn is_named_composite(resolved: &SchemaType) -> bool {
Expand Down
6 changes: 4 additions & 2 deletions cli/golem-cli/src/bridge_gen/moonbit/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ use super::moonbit::{
to_moonbit_constructor_ident, to_moonbit_term_ident, unique_idents_with_reserved,
};
use super::{
MoonBitBridgeGenerator, emit_schema_graph_literal, guest_codec_source, moonbit_string_literal,
MoonBitBridgeGenerator, emit_schema_graph_literal, guest_codec_source,
moonbit_char_option_literal, moonbit_string_literal,
};
use crate::bridge_gen::tool_bridge_client_directory_name;
use crate::bridge_gen::tool_common::{
Expand Down Expand Up @@ -581,9 +582,10 @@ impl MoonBitToolBridgeGenerator {
.zip(&field_graphs)
.map(|(field, field_graph)| {
format!(
"@tool.CanonicalInputField::{{ name: {}, aliases: {}, type_: {} }}",
"@tool.CanonicalInputField::{{ name: {}, aliases: {}, short: {}, type_: {} }}",
moonbit_string_literal(&field.name),
moonbit_string_array(&field.aliases),
moonbit_char_option_literal(field.short),
emit_schema_graph_literal(&field_graph.graph)
)
})
Expand Down
Loading
Loading