@happyrobot-ai/sdk 0.1.1 → 0.1.3
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/README.md +10 -33
- package/client.d.ts +0 -3
- package/client.js +0 -4
- package/index.d.ts +0 -2
- package/index.js +1 -3
- package/package.json +1 -1
- package/resources/usage.d.ts +0 -27
- package/resources/usage.js +0 -70
- package/resources/usage.mjs +0 -3
package/README.md
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
# @happyrobot/sdk
|
|
1
|
+
# @happyrobot-ai/sdk
|
|
2
2
|
|
|
3
3
|
TypeScript SDK for the HappyRobot Public API.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
npm install @happyrobot/sdk
|
|
8
|
+
npm install @happyrobot-ai/sdk
|
|
9
9
|
# or
|
|
10
|
-
pnpm add @happyrobot/sdk
|
|
10
|
+
pnpm add @happyrobot-ai/sdk
|
|
11
11
|
# or
|
|
12
|
-
yarn add @happyrobot/sdk
|
|
12
|
+
yarn add @happyrobot-ai/sdk
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
## Quick Start
|
|
16
16
|
|
|
17
17
|
```ts
|
|
18
|
-
import { HappyRobotClient } from "@happyrobot/sdk";
|
|
18
|
+
import { HappyRobotClient } from "@happyrobot-ai/sdk";
|
|
19
19
|
|
|
20
20
|
const client = new HappyRobotClient({ apiKey: "sk_live_..." });
|
|
21
21
|
|
|
@@ -41,14 +41,14 @@ const client = new HappyRobotClient({
|
|
|
41
41
|
|
|
42
42
|
## Helpers
|
|
43
43
|
|
|
44
|
-
High-level convenience functions available via `@happyrobot/sdk/helpers`.
|
|
44
|
+
High-level convenience functions available via `@happyrobot-ai/sdk/helpers`.
|
|
45
45
|
|
|
46
46
|
### `triggerAndWait`
|
|
47
47
|
|
|
48
48
|
Trigger a workflow run and poll until it reaches a terminal status.
|
|
49
49
|
|
|
50
50
|
```ts
|
|
51
|
-
import { triggerAndWait } from "@happyrobot/sdk/helpers";
|
|
51
|
+
import { triggerAndWait } from "@happyrobot-ai/sdk/helpers";
|
|
52
52
|
|
|
53
53
|
const { run, sessions } = await triggerAndWait(client, {
|
|
54
54
|
workflowId: "my-workflow",
|
|
@@ -67,7 +67,7 @@ console.log(run.status); // "completed" | "failed" | "canceled" | ...
|
|
|
67
67
|
Create a voice agent workflow from a template with optional publishing.
|
|
68
68
|
|
|
69
69
|
```ts
|
|
70
|
-
import { createVoiceAgent } from "@happyrobot/sdk/helpers";
|
|
70
|
+
import { createVoiceAgent } from "@happyrobot-ai/sdk/helpers";
|
|
71
71
|
|
|
72
72
|
const { workflow, publishResult } = await createVoiceAgent(client, {
|
|
73
73
|
name: "Sales Agent",
|
|
@@ -85,7 +85,7 @@ const { workflow, publishResult } = await createVoiceAgent(client, {
|
|
|
85
85
|
Create any workflow from a template with custom inputs.
|
|
86
86
|
|
|
87
87
|
```ts
|
|
88
|
-
import { createFromTemplate } from "@happyrobot/sdk/helpers";
|
|
88
|
+
import { createFromTemplate } from "@happyrobot-ai/sdk/helpers";
|
|
89
89
|
|
|
90
90
|
const { workflow } = await createFromTemplate(client, {
|
|
91
91
|
template: "voice-agent",
|
|
@@ -113,7 +113,6 @@ const { workflow } = await createFromTemplate(client, {
|
|
|
113
113
|
| `client.knowledgeBases` | `KnowledgeBasesResource` | Knowledge base document management |
|
|
114
114
|
| `client.workflowFolders` | `WorkflowFoldersResource` | Workflow folder organization |
|
|
115
115
|
| `client.mcp` | `MCPResource` | MCP server management |
|
|
116
|
-
| `client.usage` | `UsageResource` | Usage metrics (call minutes, tokens, etc.) |
|
|
117
116
|
| `client.billing` | `BillingResource` | Billing usage details and totals |
|
|
118
117
|
| `client.apiKey` | `ApiKeyResource` | API key introspection |
|
|
119
118
|
| `client.adversarialSuites` | `AdversarialSuitesResource` | Adversarial suite management and execution |
|
|
@@ -507,28 +506,6 @@ await client.mcp.refresh("mcp-id");
|
|
|
507
506
|
|
|
508
507
|
---
|
|
509
508
|
|
|
510
|
-
## `client.usage`
|
|
511
|
-
|
|
512
|
-
All methods accept a `UsageQuery` with `workflow_id`, `start_date`, and `end_date`.
|
|
513
|
-
|
|
514
|
-
```ts
|
|
515
|
-
const data = await client.usage.callMinutes({ workflow_id: "wf-id", start_date: "2024-01-01", end_date: "2024-01-31" });
|
|
516
|
-
await client.usage.llmTokens({ ... });
|
|
517
|
-
await client.usage.textCount({ ... });
|
|
518
|
-
await client.usage.ocrCount({ ... });
|
|
519
|
-
await client.usage.rpaMinutes({ ... });
|
|
520
|
-
```
|
|
521
|
-
|
|
522
|
-
| Method | HTTP | Path | Description |
|
|
523
|
-
|---|---|---|---|
|
|
524
|
-
| `callMinutes(query)` | GET | `/usage/call-minutes` | Voice call minutes consumed |
|
|
525
|
-
| `llmTokens(query)` | GET | `/usage/llm-tokens` | LLM tokens consumed |
|
|
526
|
-
| `textCount(query)` | GET | `/usage/text-count` | Text messages sent |
|
|
527
|
-
| `ocrCount(query)` | GET | `/usage/ocr-count` | OCR operations performed |
|
|
528
|
-
| `rpaMinutes(query)` | GET | `/usage/rpa-minutes` | RPA automation minutes consumed |
|
|
529
|
-
|
|
530
|
-
---
|
|
531
|
-
|
|
532
509
|
## `client.billing`
|
|
533
510
|
|
|
534
511
|
```ts
|
|
@@ -758,7 +735,7 @@ for await (const workflow of client.workflows.listAll({ folder_id: "..." })) {
|
|
|
758
735
|
## Error Handling
|
|
759
736
|
|
|
760
737
|
```ts
|
|
761
|
-
import { ApiError, AuthenticationError, NotFoundError } from "@happyrobot/sdk";
|
|
738
|
+
import { ApiError, AuthenticationError, NotFoundError } from "@happyrobot-ai/sdk";
|
|
762
739
|
|
|
763
740
|
try {
|
|
764
741
|
const wf = await client.workflows.get("nonexistent");
|
package/client.d.ts
CHANGED
|
@@ -24,7 +24,6 @@ import { ContactsResource } from "./resources/contacts";
|
|
|
24
24
|
import { KnowledgeBasesResource } from "./resources/knowledge-bases";
|
|
25
25
|
import { WorkflowFoldersResource } from "./resources/workflow-folders";
|
|
26
26
|
import { MCPResource } from "./resources/mcp";
|
|
27
|
-
import { UsageResource } from "./resources/usage";
|
|
28
27
|
import { BillingResource } from "./resources/billing";
|
|
29
28
|
import { ApiKeyResource } from "./resources/api-key";
|
|
30
29
|
import { AdversarialSuitesResource } from "./resources/adversarial-suites";
|
|
@@ -63,8 +62,6 @@ export declare class HappyRobotClient {
|
|
|
63
62
|
readonly workflowFolders: WorkflowFoldersResource;
|
|
64
63
|
/** MCP server management. */
|
|
65
64
|
readonly mcp: MCPResource;
|
|
66
|
-
/** Usage metrics (call minutes, tokens, etc.). */
|
|
67
|
-
readonly usage: UsageResource;
|
|
68
65
|
/** Billing usage details and totals. */
|
|
69
66
|
readonly billing: BillingResource;
|
|
70
67
|
/** API key introspection. */
|
package/client.js
CHANGED
|
@@ -27,7 +27,6 @@ const contacts_1 = require("./resources/contacts");
|
|
|
27
27
|
const knowledge_bases_1 = require("./resources/knowledge-bases");
|
|
28
28
|
const workflow_folders_1 = require("./resources/workflow-folders");
|
|
29
29
|
const mcp_1 = require("./resources/mcp");
|
|
30
|
-
const usage_1 = require("./resources/usage");
|
|
31
30
|
const billing_1 = require("./resources/billing");
|
|
32
31
|
const api_key_1 = require("./resources/api-key");
|
|
33
32
|
const adversarial_suites_1 = require("./resources/adversarial-suites");
|
|
@@ -66,8 +65,6 @@ class HappyRobotClient {
|
|
|
66
65
|
workflowFolders;
|
|
67
66
|
/** MCP server management. */
|
|
68
67
|
mcp;
|
|
69
|
-
/** Usage metrics (call minutes, tokens, etc.). */
|
|
70
|
-
usage;
|
|
71
68
|
/** Billing usage details and totals. */
|
|
72
69
|
billing;
|
|
73
70
|
/** API key introspection. */
|
|
@@ -100,7 +97,6 @@ class HappyRobotClient {
|
|
|
100
97
|
this.knowledgeBases = new knowledge_bases_1.KnowledgeBasesResource(this.http);
|
|
101
98
|
this.workflowFolders = new workflow_folders_1.WorkflowFoldersResource(this.http);
|
|
102
99
|
this.mcp = new mcp_1.MCPResource(this.http);
|
|
103
|
-
this.usage = new usage_1.UsageResource(this.http);
|
|
104
100
|
this.billing = new billing_1.BillingResource(this.http);
|
|
105
101
|
this.apiKey = new api_key_1.ApiKeyResource(this.http);
|
|
106
102
|
this.adversarialSuites = new adversarial_suites_1.AdversarialSuitesResource(this.http);
|
package/index.d.ts
CHANGED
|
@@ -43,7 +43,6 @@ export { ContactsResource } from "./resources/contacts";
|
|
|
43
43
|
export { KnowledgeBasesResource } from "./resources/knowledge-bases";
|
|
44
44
|
export { WorkflowFoldersResource } from "./resources/workflow-folders";
|
|
45
45
|
export { MCPResource } from "./resources/mcp";
|
|
46
|
-
export { UsageResource } from "./resources/usage";
|
|
47
46
|
export { BillingResource } from "./resources/billing";
|
|
48
47
|
export { ApiKeyResource } from "./resources/api-key";
|
|
49
48
|
export { AdversarialSuitesResource } from "./resources/adversarial-suites";
|
|
@@ -62,7 +61,6 @@ export type * from "./types/sip-trunks.types";
|
|
|
62
61
|
export type * from "./types/integrations.types";
|
|
63
62
|
export type * from "./types/contacts.types";
|
|
64
63
|
export type * from "./types/knowledge-bases.types";
|
|
65
|
-
export type * from "./types/usage.types";
|
|
66
64
|
export type * from "./types/variables.types";
|
|
67
65
|
export type * from "./types/messages.types";
|
|
68
66
|
export type * from "./types/mcp.types";
|
package/index.js
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
* ```
|
|
24
24
|
*/
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.AuditRemarksResource = exports.IssuesResource = exports.CustomEvalsResource = exports.NorthstarsResource = exports.AdversarialTestsResource = exports.AdversarialSuitesResource = exports.ApiKeyResource = exports.BillingResource = exports.
|
|
26
|
+
exports.AuditRemarksResource = exports.IssuesResource = exports.CustomEvalsResource = exports.NorthstarsResource = exports.AdversarialTestsResource = exports.AdversarialSuitesResource = exports.ApiKeyResource = exports.BillingResource = exports.MCPResource = exports.WorkflowFoldersResource = exports.KnowledgeBasesResource = exports.ContactsResource = exports.IntegrationsResource = exports.SipTrunksResource = exports.PhoneNumbersResource = exports.VariablesResource = exports.MessagesResource = exports.SessionsResource = exports.RunsResource = exports.NodesResource = exports.VersionsResource = exports.WorkflowsResource = exports.iterateSSE = exports.paginate = exports.NetworkError = exports.TimeoutError = exports.RateLimitError = exports.ValidationError = exports.NotFoundError = exports.AuthenticationError = exports.ApiError = exports.HappyRobotError = exports.HappyRobotClient = void 0;
|
|
27
27
|
// ── Client ──
|
|
28
28
|
var client_1 = require("./client");
|
|
29
29
|
Object.defineProperty(exports, "HappyRobotClient", { enumerable: true, get: function () { return client_1.HappyRobotClient; } });
|
|
@@ -69,8 +69,6 @@ var workflow_folders_1 = require("./resources/workflow-folders");
|
|
|
69
69
|
Object.defineProperty(exports, "WorkflowFoldersResource", { enumerable: true, get: function () { return workflow_folders_1.WorkflowFoldersResource; } });
|
|
70
70
|
var mcp_1 = require("./resources/mcp");
|
|
71
71
|
Object.defineProperty(exports, "MCPResource", { enumerable: true, get: function () { return mcp_1.MCPResource; } });
|
|
72
|
-
var usage_1 = require("./resources/usage");
|
|
73
|
-
Object.defineProperty(exports, "UsageResource", { enumerable: true, get: function () { return usage_1.UsageResource; } });
|
|
74
72
|
var billing_1 = require("./resources/billing");
|
|
75
73
|
Object.defineProperty(exports, "BillingResource", { enumerable: true, get: function () { return billing_1.BillingResource; } });
|
|
76
74
|
var api_key_1 = require("./resources/api-key");
|
package/package.json
CHANGED
package/resources/usage.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Usage resource — client.usage.*
|
|
3
|
-
*
|
|
4
|
-
* Maps to:
|
|
5
|
-
* GET /usage/call-minutes
|
|
6
|
-
* GET /usage/llm-tokens
|
|
7
|
-
* GET /usage/text-count
|
|
8
|
-
* GET /usage/ocr-count
|
|
9
|
-
* GET /usage/rpa-minutes
|
|
10
|
-
*/
|
|
11
|
-
import type { HttpClient } from "../core/http";
|
|
12
|
-
import type { UsageQuery, DetailedUsageResponse } from "../types/usage.types";
|
|
13
|
-
export declare class UsageResource {
|
|
14
|
-
private readonly http;
|
|
15
|
-
constructor(http: HttpClient);
|
|
16
|
-
/** Get call minutes usage. */
|
|
17
|
-
callMinutes(query: UsageQuery): Promise<DetailedUsageResponse>;
|
|
18
|
-
/** Get LLM token usage. */
|
|
19
|
-
llmTokens(query: UsageQuery): Promise<DetailedUsageResponse>;
|
|
20
|
-
/** Get text message count usage. */
|
|
21
|
-
textCount(query: UsageQuery): Promise<DetailedUsageResponse>;
|
|
22
|
-
/** Get OCR count usage. */
|
|
23
|
-
ocrCount(query: UsageQuery): Promise<DetailedUsageResponse>;
|
|
24
|
-
/** Get RPA minutes usage. */
|
|
25
|
-
rpaMinutes(query: UsageQuery): Promise<DetailedUsageResponse>;
|
|
26
|
-
private toQuery;
|
|
27
|
-
}
|
package/resources/usage.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Usage resource — client.usage.*
|
|
4
|
-
*
|
|
5
|
-
* Maps to:
|
|
6
|
-
* GET /usage/call-minutes
|
|
7
|
-
* GET /usage/llm-tokens
|
|
8
|
-
* GET /usage/text-count
|
|
9
|
-
* GET /usage/ocr-count
|
|
10
|
-
* GET /usage/rpa-minutes
|
|
11
|
-
*/
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.UsageResource = void 0;
|
|
14
|
-
class UsageResource {
|
|
15
|
-
http;
|
|
16
|
-
constructor(http) {
|
|
17
|
-
this.http = http;
|
|
18
|
-
}
|
|
19
|
-
/** Get call minutes usage. */
|
|
20
|
-
async callMinutes(query) {
|
|
21
|
-
return this.http.request({
|
|
22
|
-
method: "GET",
|
|
23
|
-
path: "/usage/call-minutes",
|
|
24
|
-
query: this.toQuery(query),
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
/** Get LLM token usage. */
|
|
28
|
-
async llmTokens(query) {
|
|
29
|
-
return this.http.request({
|
|
30
|
-
method: "GET",
|
|
31
|
-
path: "/usage/llm-tokens",
|
|
32
|
-
query: this.toQuery(query),
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
/** Get text message count usage. */
|
|
36
|
-
async textCount(query) {
|
|
37
|
-
return this.http.request({
|
|
38
|
-
method: "GET",
|
|
39
|
-
path: "/usage/text-count",
|
|
40
|
-
query: this.toQuery(query),
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
/** Get OCR count usage. */
|
|
44
|
-
async ocrCount(query) {
|
|
45
|
-
return this.http.request({
|
|
46
|
-
method: "GET",
|
|
47
|
-
path: "/usage/ocr-count",
|
|
48
|
-
query: this.toQuery(query),
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
/** Get RPA minutes usage. */
|
|
52
|
-
async rpaMinutes(query) {
|
|
53
|
-
return this.http.request({
|
|
54
|
-
method: "GET",
|
|
55
|
-
path: "/usage/rpa-minutes",
|
|
56
|
-
query: this.toQuery(query),
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
toQuery(query) {
|
|
60
|
-
const { workflow_id, start_date, end_date } = query;
|
|
61
|
-
const ids = Array.isArray(workflow_id) ? workflow_id : [workflow_id];
|
|
62
|
-
return {
|
|
63
|
-
workflow_id: ids.join(","),
|
|
64
|
-
start_date,
|
|
65
|
-
end_date,
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
exports.UsageResource = UsageResource;
|
|
70
|
-
//# sourceMappingURL=usage.js.map
|
package/resources/usage.mjs
DELETED