@pinixai/hub-client 0.1.0 → 0.1.2

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": "@pinixai/hub-client",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Typed Hub client for Pinix — Connect-RPC transport + proto types",
5
5
  "main": "src/index.ts",
6
6
  "module": "src/index.ts",
package/src/helpers.ts CHANGED
@@ -5,10 +5,11 @@ const encoder = new TextEncoder();
5
5
  const decoder = new TextDecoder();
6
6
 
7
7
  /**
8
- * Invoke a clip command via Hub and aggregate streaming output into a single result.
8
+ * Invoke a clip command via Hub and return the parsed result.
9
9
  *
10
10
  * The Hub's Invoke RPC is server-streaming: each response carries a chunk of output.
11
- * This helper collects all chunks and returns the parsed JSON result.
11
+ * Each chunk is parsed independently. Returns a single value for one chunk,
12
+ * or an array for multiple chunks.
12
13
  */
13
14
  export async function hubInvoke(
14
15
  client: Client<typeof HubService>,
@@ -18,7 +19,7 @@ export async function hubInvoke(
18
19
  clipToken?: string,
19
20
  ): Promise<unknown> {
20
21
  const inputBytes = encoder.encode(JSON.stringify(input));
21
- let outputBytes = new Uint8Array(0);
22
+ const results: unknown[] = [];
22
23
 
23
24
  for await (const response of client.invoke({
24
25
  clipName,
@@ -33,15 +34,16 @@ export async function hubInvoke(
33
34
  }
34
35
 
35
36
  if (response.output.length > 0) {
36
- const merged = new Uint8Array(outputBytes.length + response.output.length);
37
- merged.set(outputBytes);
38
- merged.set(response.output, outputBytes.length);
39
- outputBytes = merged;
37
+ const text = decoder.decode(response.output);
38
+ try {
39
+ results.push(JSON.parse(text));
40
+ } catch {
41
+ results.push(text);
42
+ }
40
43
  }
41
44
  }
42
45
 
43
- if (outputBytes.length === 0) return undefined;
44
-
45
- const text = decoder.decode(outputBytes);
46
- return JSON.parse(text) as unknown;
46
+ if (results.length === 0) return undefined;
47
+ if (results.length === 1) return results[0];
48
+ return results;
47
49
  }
package/src/index.ts CHANGED
@@ -3,6 +3,7 @@ export { hubInvoke } from "./helpers";
3
3
 
4
4
  export {
5
5
  HubService,
6
+ // Types
6
7
  type ClipInfo,
7
8
  type CommandInfo,
8
9
  type ClipManifest,
@@ -31,6 +32,27 @@ export {
31
32
  type RemoveBindingResponse,
32
33
  type HubError,
33
34
  type ClipStatus,
35
+ // Provider types (ProviderStream protocol)
36
+ type ProviderMessage,
37
+ type HubMessage,
38
+ type RegisterRequest,
39
+ type RegisterResponse,
40
+ type ClipRegistration,
41
+ type InvokeCommand,
42
+ type InvokeInput,
43
+ type InvokeResult,
44
+ type Heartbeat,
45
+ // Provider schemas (for create())
46
+ ProviderMessageSchema,
47
+ HubMessageSchema,
48
+ RegisterRequestSchema,
49
+ RegisterResponseSchema,
50
+ ClipRegistrationSchema,
51
+ InvokeCommandSchema,
52
+ InvokeResultSchema,
53
+ HeartbeatSchema,
54
+ HubErrorSchema,
55
+ CommandInfoSchema,
34
56
  } from "./gen/hub_pb";
35
57
 
36
58
  export type { Interceptor } from "@connectrpc/connect";