pi-codebuddy-sdk 0.1.4 → 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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-codebuddy-sdk",
3
- "version": "0.1.4",
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",
package/src/index.ts CHANGED
@@ -54,7 +54,7 @@ async function discoverModels(): Promise<ProviderModelConfig[]> {
54
54
  ),
55
55
  ]);
56
56
  if (models && models.length > 0) {
57
- let mapped = models.map((m) => {
57
+ return models.map((m) => {
58
58
  const caps = detectCapabilities(m.id);
59
59
  return {
60
60
  id: m.id,
@@ -66,15 +66,6 @@ async function discoverModels(): Promise<ProviderModelConfig[]> {
66
66
  maxTokens: caps.maxTokens,
67
67
  };
68
68
  });
69
- // Sort Hunyuan first — this model is the fallback when quota is constrained.
70
- // Pi auto-selects the first model, so this prevents "CLI process stdout closed"
71
- // errors from models without token quota.
72
- mapped.sort((a, b) => {
73
- const aHy = a.id.includes('hy') || a.name.includes('Hunyuan') ? 0 : 1;
74
- const bHy = b.id.includes('hy') || b.name.includes('Hunyuan') ? 0 : 1;
75
- return aHy - bHy;
76
- });
77
- return mapped;
78
69
  }
79
70
  } catch (e) {
80
71
  // Discovery failed — SDK not installed, CLI missing, or network issue.
@@ -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));