@poncho-ai/client 0.2.1 → 0.4.0

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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @poncho-ai/client@0.2.1 build /Users/cesar/Dev/latitude/poncho-ai/packages/client
2
+ > @poncho-ai/client@0.4.0 build /Users/cesar/Dev/latitude/poncho-ai/packages/client
3
3
  > tsup src/index.ts --format esm --dts
4
4
 
5
5
  CLI Building entry: src/index.ts
@@ -7,8 +7,8 @@
7
7
  CLI tsup v8.5.1
8
8
  CLI Target: es2022
9
9
  ESM Build start
10
- ESM dist/index.js 6.32 KB
11
- ESM ⚡️ Build success in 18ms
10
+ ESM dist/index.js 6.71 KB
11
+ ESM ⚡️ Build success in 17ms
12
12
  DTS Build start
13
- DTS ⚡️ Build success in 1213ms
13
+ DTS ⚡️ Build success in 1152ms
14
14
  DTS dist/index.d.ts 1.83 KB
package/dist/index.js CHANGED
@@ -114,14 +114,29 @@ var AgentClient = class {
114
114
  const completed = events.find(
115
115
  (event) => event.type === "run:completed"
116
116
  );
117
- if (!completed) {
118
- throw new Error("Send message failed: missing run:completed event");
117
+ if (completed) {
118
+ return {
119
+ runId: runStarted?.runId ?? completed.runId,
120
+ status: completed.result.status,
121
+ result: completed.result
122
+ };
119
123
  }
120
- return {
121
- runId: runStarted?.runId ?? completed.runId,
122
- status: completed.result.status,
123
- result: completed.result
124
- };
124
+ const cancelled = events.find(
125
+ (event) => event.type === "run:cancelled"
126
+ );
127
+ if (cancelled) {
128
+ return {
129
+ runId: runStarted?.runId ?? cancelled.runId,
130
+ status: "cancelled",
131
+ result: {
132
+ status: "cancelled",
133
+ steps: 0,
134
+ tokens: { input: 0, output: 0, cached: 0 },
135
+ duration: 0
136
+ }
137
+ };
138
+ }
139
+ throw new Error("Send message failed: missing run:completed or run:cancelled event");
125
140
  }
126
141
  async run(input) {
127
142
  if ((input.messages?.length ?? 0) > 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@poncho-ai/client",
3
- "version": "0.2.1",
3
+ "version": "0.4.0",
4
4
  "description": "TypeScript client for calling deployed Poncho agents",
5
5
  "repository": {
6
6
  "type": "git",
@@ -20,7 +20,7 @@
20
20
  }
21
21
  },
22
22
  "dependencies": {
23
- "@poncho-ai/sdk": "0.2.1"
23
+ "@poncho-ai/sdk": "0.4.0"
24
24
  },
25
25
  "devDependencies": {
26
26
  "tsup": "^8.0.0",
package/src/index.ts CHANGED
@@ -166,14 +166,30 @@ export class AgentClient {
166
166
  (event): event is Extract<AgentEvent, { type: "run:completed" }> =>
167
167
  event.type === "run:completed",
168
168
  );
169
- if (!completed) {
170
- throw new Error("Send message failed: missing run:completed event");
169
+ if (completed) {
170
+ return {
171
+ runId: runStarted?.runId ?? completed.runId,
172
+ status: completed.result.status,
173
+ result: completed.result,
174
+ };
171
175
  }
172
- return {
173
- runId: runStarted?.runId ?? completed.runId,
174
- status: completed.result.status,
175
- result: completed.result,
176
- };
176
+ const cancelled = events.find(
177
+ (event): event is Extract<AgentEvent, { type: "run:cancelled" }> =>
178
+ event.type === "run:cancelled",
179
+ );
180
+ if (cancelled) {
181
+ return {
182
+ runId: runStarted?.runId ?? cancelled.runId,
183
+ status: "cancelled",
184
+ result: {
185
+ status: "cancelled",
186
+ steps: 0,
187
+ tokens: { input: 0, output: 0, cached: 0 },
188
+ duration: 0,
189
+ },
190
+ };
191
+ }
192
+ throw new Error("Send message failed: missing run:completed or run:cancelled event");
177
193
  }
178
194
 
179
195
  async run(input: RunInput): Promise<SyncRunResponse> {