MoonBit SDK for embedding the Codex agent in workflows and applications
Dependencies
import {
"totto2727/codex-sdk" @codex_sdk,
}async fn main {
let codex = @codex_sdk.Codex::Codex()
let thread = codex.start_thread()
let turn = thread.run(
@codex_sdk.Input::Prompt("Diagnose the test failure and propose a fix"),
)
println(turn.final_response)
}thread.run_streamed(
@codex_sdk.Input::Prompt("Diagnose the test failure"),
async event => {
match event {
ItemCompleted(completed) => println("\{completed.item}")
TurnCompleted(completed) => println("\{completed.usage}")
_ => ()
}
},
)let schema = Json::object({
"type": "object",
"properties": {
"summary": Json::object({ "type": "string" }),
},
"required": ["summary"],
"additionalProperties": false,
})
let turn = thread.run(
Prompt("Summarize repository status"),
turn_options=@codex_sdk.TurnOptions::TurnOptions(output_schema=schema),
)| Upstream TypeScript | MoonBit |
|---|---|
| codex.ts | codex.mbt |
| codexOptions.ts | codex_options.mbt |
| events.ts | events.mbt |
| exec.ts | exec.mbt |
| index.ts | index.mbt |
| items.ts | items.mbt |
| outputSchemaFile.ts | output_schema_file.mbt |
| thread.ts | thread.mbt |
| threadOptions.ts | thread_options.mbt |
| turnOptions.ts | turn_options.mbt |
moon test --target native mbt/package/codex-sdk/srcMoonBit SDK for embedding the Codex agent in workflows and applications
Dependencies