feat: add JavaScript session orchestration runtime
This commit is contained in:
31
.ccweb/scripts/session-orchestration-e2e-20260826.js
Normal file
31
.ccweb/scripts/session-orchestration-e2e-20260826.js
Normal file
@@ -0,0 +1,31 @@
|
||||
import {
|
||||
createConversation,
|
||||
sendMessage,
|
||||
selectSemanticBranch,
|
||||
} from '@ccweb/session';
|
||||
|
||||
const conversationId = await createConversation(
|
||||
'这是 JavaScript 会话编排端到端测试。请只回复:测试成功'
|
||||
);
|
||||
|
||||
const branch = await selectSemanticBranch(conversationId, [
|
||||
'测试成功',
|
||||
'测试失败',
|
||||
]);
|
||||
|
||||
if (branch !== '测试成功') {
|
||||
const error = new Error(`语义分支未命中测试成功:${branch}`);
|
||||
error.code = 'unexpected_semantic_branch';
|
||||
throw error;
|
||||
}
|
||||
|
||||
const message = await sendMessage(
|
||||
conversationId,
|
||||
'收到。请只回复:已收到'
|
||||
);
|
||||
|
||||
console.log(JSON.stringify({
|
||||
conversationId,
|
||||
branch,
|
||||
message,
|
||||
}));
|
||||
Reference in New Issue
Block a user