feat: migrate to Letta TS SDK v1 (alpha) (#11)
This commit is contained in:
@@ -18,19 +18,21 @@ async function main() {
|
||||
console.log(`✅ Agent created: ${agent.id}`);
|
||||
|
||||
console.log("💬 Sending test message...");
|
||||
const stream = await sendMessageStream(
|
||||
agent.id,
|
||||
"Hello from Bun smoke test! Try calling a tool.",
|
||||
);
|
||||
const stream = await sendMessageStream(agent.id, [
|
||||
{
|
||||
role: "user",
|
||||
content: "Hello from Bun smoke test! Try calling a tool.",
|
||||
},
|
||||
]);
|
||||
|
||||
// Print every chunk as it arrives
|
||||
for await (const chunk of stream) {
|
||||
const type = chunk.messageType ?? "unknown";
|
||||
const type = chunk.message_type ?? "unknown";
|
||||
|
||||
switch (chunk.messageType) {
|
||||
switch (chunk.message_type) {
|
||||
case "reasoning_message": {
|
||||
const run = chunk.runId
|
||||
? `run=${chunk.runId}:${chunk.seqId ?? "-"} `
|
||||
const run = chunk.run_id
|
||||
? `run=${chunk.run_id}:${chunk.seq_id ?? "-"} `
|
||||
: "";
|
||||
process.stdout.write(
|
||||
`[reasoning] ${run}${JSON.stringify(chunk) ?? ""}\n`,
|
||||
@@ -38,8 +40,8 @@ async function main() {
|
||||
break;
|
||||
}
|
||||
case "assistant_message": {
|
||||
const run = chunk.runId
|
||||
? `run=${chunk.runId}:${chunk.seqId ?? "-"} `
|
||||
const run = chunk.run_id
|
||||
? `run=${chunk.run_id}:${chunk.seq_id ?? "-"} `
|
||||
: "";
|
||||
process.stdout.write(
|
||||
`[assistant] ${run}${JSON.stringify(chunk) ?? ""}\n`,
|
||||
@@ -47,8 +49,8 @@ async function main() {
|
||||
break;
|
||||
}
|
||||
case "tool_call_message": {
|
||||
const run = chunk.runId
|
||||
? `run=${chunk.runId}:${chunk.seqId ?? "-"} `
|
||||
const run = chunk.run_id
|
||||
? `run=${chunk.run_id}:${chunk.seq_id ?? "-"} `
|
||||
: "";
|
||||
process.stdout.write(
|
||||
`[tool_call] ${run}${JSON.stringify(chunk) ?? ""}\n`,
|
||||
@@ -56,15 +58,15 @@ async function main() {
|
||||
break;
|
||||
}
|
||||
case "tool_return_message": {
|
||||
const run = chunk.runId
|
||||
? `run=${chunk.runId}:${chunk.seqId ?? "-"} `
|
||||
const run = chunk.run_id
|
||||
? `run=${chunk.run_id}:${chunk.seq_id ?? "-"} `
|
||||
: "";
|
||||
process.stdout.write(`[tool_return] ${run}${chunk}\n`);
|
||||
break;
|
||||
}
|
||||
case "approval_request_message": {
|
||||
const run = chunk.runId
|
||||
? `run=${chunk.runId}:${chunk.seqId ?? "-"} `
|
||||
const run = chunk.run_id
|
||||
? `run=${chunk.run_id}:${chunk.seq_id ?? "-"} `
|
||||
: "";
|
||||
process.stdout.write(
|
||||
`[approval_request] ${run}${JSON.stringify(chunk)}\n`,
|
||||
|
||||
Reference in New Issue
Block a user