api.ts 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // @ts-nocheck
  2. import { KirinCode } from "@kirincode-ai/core"
  3. import { ReadTool } from "@kirincode-ai/core/tools"
  4. const kirincode = KirinCode.make({})
  5. opencode.tool.add(ReadTool)
  6. opencode.tool.add({
  7. name: "bash",
  8. schema: {
  9. type: "object",
  10. properties: {
  11. command: {
  12. type: "string",
  13. description: "The command to run.",
  14. },
  15. },
  16. required: ["command"],
  17. },
  18. execute(input, ctx) {},
  19. })
  20. opencode.auth.add({
  21. provider: "openai",
  22. type: "api",
  23. value: process.env.OPENAI_API_KEY,
  24. })
  25. opencode.agent.add({
  26. name: "build",
  27. permissions: [],
  28. model: {
  29. id: "gpt-5-5",
  30. provider: "openai",
  31. variant: "xhigh",
  32. },
  33. })
  34. const sessionID = await opencode.session.create({
  35. agent: "build",
  36. })
  37. opencode.subscribe((event) => {
  38. console.log(event)
  39. })
  40. await opencode.session.prompt({
  41. sessionID,
  42. text: "hey what is up",
  43. })
  44. await opencode.session.prompt({
  45. sessionID,
  46. text: "what is up with this",
  47. files: [
  48. {
  49. mime: "image/png",
  50. uri: "data:image/png;base64,xxxx",
  51. },
  52. ],
  53. })
  54. await opencode.session.wait()
  55. console.log(await opencode.session.messages(sessionID))