pi-codebuddy-sdk 0.1.3 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/test-sesh.ts +35 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-codebuddy-sdk",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "CodeBuddy Agent SDK provider for Pi — native tool execution, 29+ models, thinking controls, session pool",
5
5
  "author": "slahser",
6
6
  "license": "MIT",
@@ -0,0 +1,35 @@
1
+ import sdk from '@tencent-ai/agent-sdk';
2
+
3
+ async function main() {
4
+ console.log('Creating session with includePartialMessages=true...');
5
+ const session = await sdk.unstable_v2_createSession({
6
+ model: 'hy3-preview-agent-ioa',
7
+ permissionMode: 'bypassPermissions',
8
+ maxTurns: 3,
9
+ includePartialMessages: true,
10
+ });
11
+ console.log('Session created, sending...');
12
+ await session.send('say: hello in 3 words');
13
+ console.log('Sent, streaming...');
14
+
15
+ let count = 0;
16
+ try {
17
+ for await (const msg of session.stream()) {
18
+ count++;
19
+ const t = msg.type;
20
+ if (t === 'stream_event') {
21
+ const evt = (msg as any).event;
22
+ console.log(` #${count} ${t}.${evt.type} idx=${evt.index}`);
23
+ } else if (t === 'assistant') {
24
+ console.log(` #${count} ${t} blocks=${(msg as any).message.content.length}`);
25
+ } else {
26
+ console.log(` #${count} ${t}`);
27
+ }
28
+ }
29
+ } catch (e: any) {
30
+ console.error('STREAM ERROR:', e.message);
31
+ }
32
+ console.log(`Done. Total messages: ${count}`);
33
+ await session.close();
34
+ }
35
+ main().catch(e => console.error('FATAL:', e.message));