@heysummon/consumer-sdk 0.1.1 → 0.2.7

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/LICENSE.md ADDED
@@ -0,0 +1,87 @@
1
+ # License
2
+
3
+ Portions of this software are licensed as follows:
4
+
5
+ - Source code files that contain ".cloud." in their filename or ".cloud" in their dirname are NOT licensed under
6
+ the Sustainable Use License.
7
+ To use source code files that contain ".cloud." in their filename or ".cloud" in their dirname you must hold a
8
+ valid HeySummon Cloud License specifically allowing you access to such source code files and as defined
9
+ in "LICENSE_CLOUD.md".
10
+ - All third party components incorporated into the HeySummon Software are licensed under the original license
11
+ provided by the owner of the applicable component.
12
+ - Content outside of the above mentioned files or restrictions is available under the "Sustainable Use
13
+ License" as defined below.
14
+
15
+ ## Sustainable Use License
16
+
17
+ Version 1.0
18
+
19
+ ### Acceptance
20
+
21
+ By using the software, you agree to all of the terms and conditions below.
22
+
23
+ ### Copyright License
24
+
25
+ The licensor grants you a non-exclusive, royalty-free, worldwide, non-sublicensable, non-transferable license
26
+ to use, copy, distribute, make available, and prepare derivative works of the software, in each case subject
27
+ to the limitations below.
28
+
29
+ ### Limitations
30
+
31
+ You may use or modify the software only for your own internal business purposes or for non-commercial or
32
+ personal use. You may distribute the software or provide it to others only if you do so free of charge for
33
+ non-commercial purposes. You may not alter, remove, or obscure any licensing, copyright, or other notices of
34
+ the licensor in the software. Any use of the licensor's trademarks is subject to applicable law.
35
+
36
+ ### Patents
37
+
38
+ The licensor grants you a license, under any patent claims the licensor can license, or becomes able to
39
+ license, to make, have made, use, sell, offer for sale, import and have imported the software, in each case
40
+ subject to the limitations and conditions in this license. This license does not cover any patent claims that
41
+ you cause to be infringed by modifications or additions to the software. If you or your company make any
42
+ written claim that the software infringes or contributes to infringement of any patent, your patent license
43
+ for the software granted under these terms ends immediately. If your company makes such a claim, your patent
44
+ license ends immediately for work on behalf of your company.
45
+
46
+ ### Notices
47
+
48
+ You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these
49
+ terms. If you modify the software, you must include in any modified copies of the software a prominent notice
50
+ stating that you have modified the software.
51
+
52
+ ### No Other Rights
53
+
54
+ These terms do not imply any licenses other than those expressly granted in these terms.
55
+
56
+ ### Termination
57
+
58
+ If you use the software in violation of these terms, such use is not licensed, and your license will
59
+ automatically terminate. If the licensor provides you with a notice of your violation, and you cease all
60
+ violation of this license no later than 30 days after you receive that notice, your license will be reinstated
61
+ retroactively. However, if you violate these terms after such reinstatement, any additional violation of these
62
+ terms will cause your license to terminate automatically and permanently.
63
+
64
+ ### No Liability
65
+
66
+ As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will
67
+ not be liable to you for any damages arising out of these terms or the use or nature of the software, under
68
+ any kind of legal claim.
69
+
70
+ ### Definitions
71
+
72
+ The "licensor" is Thomas Ansems and HeySummon.
73
+
74
+ The "software" is the software the licensor makes available under these terms, including any portion of it.
75
+
76
+ "You" refers to the individual or entity agreeing to these terms.
77
+
78
+ "Your company" is any legal entity, sole proprietorship, or other kind of organization that you work for, plus
79
+ all organizations that have control over, are under the control of, or are under common control with that
80
+ organization. Control means ownership of substantially all the assets of an entity, or the power to direct its
81
+ management and policies by vote, contract, or otherwise. Control can be direct or indirect.
82
+
83
+ "Your license" is the license granted to you for the software under these terms.
84
+
85
+ "Use" means anything you do with the software requiring your license.
86
+
87
+ "Trademark" means trademarks, service marks, and similar rights.
package/README.md ADDED
@@ -0,0 +1,225 @@
1
+ # @heysummon/consumer-sdk
2
+
3
+ TypeScript SDK for [HeySummon](https://heysummon.ai) consumers (AI agents). Submit help requests to human experts, poll for responses, and optionally encrypt messages end-to-end.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ pnpm install @heysummon/consumer-sdk
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```typescript
14
+ import { HeySummonClient } from "@heysummon/consumer-sdk";
15
+
16
+ const client = new HeySummonClient({
17
+ baseUrl: "https://cloud.heysummon.ai",
18
+ apiKey: process.env.HEYSUMMON_API_KEY!,
19
+ });
20
+
21
+ // Submit a help request
22
+ const result = await client.submitRequest({
23
+ question: "Should I proceed with the database migration?",
24
+ });
25
+
26
+ // Poll for the response
27
+ const status = await client.getRequestStatus(result.requestId!);
28
+ console.log(status.response);
29
+ ```
30
+
31
+ ## Client API
32
+
33
+ ### `HeySummonClient`
34
+
35
+ All methods authenticate via the `x-api-key` header using the API key provided at construction.
36
+
37
+ ```typescript
38
+ const client = new HeySummonClient({ baseUrl, apiKey });
39
+ ```
40
+
41
+ | Method | Description |
42
+ |--------|-------------|
43
+ | `whoami()` | Identify which expert this API key is linked to |
44
+ | `submitRequest(opts)` | Submit a help request to a human expert |
45
+ | `getRequestStatus(requestId)` | Get the current status of a request |
46
+ | `getRequestByRef(refCode)` | Look up a request by its `HS-XXXX` reference code |
47
+ | `getPendingEvents()` | Poll for pending events (new messages, responses, etc.) |
48
+ | `ackEvent(requestId)` | Acknowledge a specific event |
49
+ | `getMessages(requestId)` | Fetch the full message history for a request |
50
+ | `reportTimeout(requestId)` | Report that the client's poll timed out |
51
+
52
+ ### Submit Request Options
53
+
54
+ ```typescript
55
+ interface SubmitRequestOptions {
56
+ question: string;
57
+ messages?: Array<{ role: string; content: string }>;
58
+ signPublicKey?: string;
59
+ encryptPublicKey?: string;
60
+ expertName?: string;
61
+ requiresApproval?: boolean;
62
+ }
63
+ ```
64
+
65
+ ### Approval Requests
66
+
67
+ Set `requiresApproval: true` to show Approve/Deny buttons to the expert instead of a free-text reply prompt. The decision is delivered as a message event:
68
+
69
+ ```typescript
70
+ const result = await client.submitRequest({
71
+ question: "Should I proceed with the $5,000 purchase?",
72
+ requiresApproval: true,
73
+ });
74
+
75
+ // Poll until the expert decides
76
+ const status = await client.getRequestStatus(result.requestId!);
77
+ if (status.status === "responded") {
78
+ const messages = await client.getMessages(result.requestId!);
79
+ // Expert message contains "approved" or "denied"
80
+ }
81
+ ```
82
+
83
+ ### Error Handling
84
+
85
+ The client throws `HeySummonHttpError` for non-2xx responses:
86
+
87
+ ```typescript
88
+ import { HeySummonHttpError } from "@heysummon/consumer-sdk";
89
+
90
+ try {
91
+ await client.submitRequest({ question: "..." });
92
+ } catch (err) {
93
+ if (err instanceof HeySummonHttpError) {
94
+ console.error(err.status, err.body);
95
+ if (err.isAuthError) {
96
+ // 401, 403, or 404
97
+ }
98
+ }
99
+ }
100
+ ```
101
+
102
+ ## End-to-End Encryption
103
+
104
+ The SDK includes X25519 + AES-256-GCM encryption with Ed25519 signatures.
105
+
106
+ ### Ephemeral Keys (in-memory)
107
+
108
+ ```typescript
109
+ import { generateEphemeralKeys } from "@heysummon/consumer-sdk";
110
+
111
+ const keys = generateEphemeralKeys();
112
+ // { signPublicKey: "hex...", encryptPublicKey: "hex..." }
113
+
114
+ await client.submitRequest({
115
+ question: "Sensitive question",
116
+ signPublicKey: keys.signPublicKey,
117
+ encryptPublicKey: keys.encryptPublicKey,
118
+ });
119
+ ```
120
+
121
+ ### Persistent Keys (file-based)
122
+
123
+ ```typescript
124
+ import { generatePersistentKeys, loadPublicKeys } from "@heysummon/consumer-sdk";
125
+
126
+ // Generate and save to disk
127
+ const keys = generatePersistentKeys("/path/to/keys");
128
+
129
+ // Load existing keys without regenerating
130
+ const existing = loadPublicKeys("/path/to/keys");
131
+ ```
132
+
133
+ ### Encrypt / Decrypt
134
+
135
+ ```typescript
136
+ import { encrypt, decrypt } from "@heysummon/consumer-sdk";
137
+
138
+ const encrypted = encrypt(
139
+ "Hello, human!",
140
+ "/path/to/recipient_encrypt_public.pem",
141
+ "/path/to/own_sign_private.pem",
142
+ "/path/to/own_encrypt_private.pem"
143
+ );
144
+
145
+ const plaintext = decrypt(
146
+ encrypted,
147
+ "/path/to/sender_encrypt_public.pem",
148
+ "/path/to/sender_sign_public.pem",
149
+ "/path/to/own_encrypt_private.pem"
150
+ );
151
+ ```
152
+
153
+ ## Expert Store
154
+
155
+ Manage multiple expert registrations in a local JSON file:
156
+
157
+ ```typescript
158
+ import { ExpertStore } from "@heysummon/consumer-sdk";
159
+
160
+ const store = new ExpertStore("/path/to/experts.json");
161
+
162
+ store.add({
163
+ name: "My Expert",
164
+ apiKey: "hs_cli_...",
165
+ expertId: "...",
166
+ expertName: "Expert Name",
167
+ });
168
+
169
+ const expert = store.findByName("My Expert");
170
+ const defaultExpert = store.getDefault();
171
+ ```
172
+
173
+ ## CLI
174
+
175
+ The package includes a CLI for use in shell scripts and automation:
176
+
177
+ ```bash
178
+ pnpm dlx @heysummon/consumer-sdk <command> [options]
179
+ ```
180
+
181
+ ### Commands
182
+
183
+ | Command | Description |
184
+ |---------|-------------|
185
+ | `submit-and-poll` | Submit a request and wait for a response |
186
+ | `add-expert` | Register an expert by API key |
187
+ | `list-experts` | List registered experts |
188
+ | `check-status` | Check the status of an existing request |
189
+ | `keygen` | Generate persistent encryption key pairs |
190
+
191
+ ### Environment Variables
192
+
193
+ | Variable | Required | Description |
194
+ |----------|----------|-------------|
195
+ | `HEYSUMMON_BASE_URL` | Yes | Platform URL (e.g. `https://cloud.heysummon.ai`) |
196
+ | `HEYSUMMON_API_KEY` | Varies | Consumer API key (not needed if using expert store) |
197
+ | `HEYSUMMON_EXPERTS_FILE` | No | Path to experts.json for multi-expert setups |
198
+ | `HEYSUMMON_TIMEOUT` | No | Poll timeout in seconds (default: 900) |
199
+ | `HEYSUMMON_POLL_INTERVAL` | No | Poll interval in seconds (default: 3) |
200
+
201
+ ### Examples
202
+
203
+ ```bash
204
+ # Submit and wait for a response
205
+ HEYSUMMON_BASE_URL=https://cloud.heysummon.ai \
206
+ HEYSUMMON_API_KEY=hs_cli_... \
207
+ pnpm dlx @heysummon/consumer-sdk submit-and-poll --question "Should I deploy?"
208
+
209
+ # Register an expert
210
+ HEYSUMMON_BASE_URL=https://cloud.heysummon.ai \
211
+ HEYSUMMON_EXPERTS_FILE=./experts.json \
212
+ pnpm dlx @heysummon/consumer-sdk add-expert --key hs_cli_... --alias "DevOps Lead"
213
+
214
+ # Check request status
215
+ HEYSUMMON_BASE_URL=https://cloud.heysummon.ai \
216
+ HEYSUMMON_API_KEY=hs_cli_... \
217
+ pnpm dlx @heysummon/consumer-sdk check-status --ref HS-1234
218
+
219
+ # Generate encryption keys
220
+ pnpm dlx @heysummon/consumer-sdk keygen --dir ./keys
221
+ ```
222
+
223
+ ## License
224
+
225
+ MIT
package/dist/cli.d.ts CHANGED
@@ -3,12 +3,12 @@
3
3
  * HeySummon Consumer SDK CLI
4
4
  *
5
5
  * Shared CLI entry point used by both Claude Code and OpenClaw skill scripts.
6
- * Subcommands: submit, submit-and-poll, add-provider, list-providers,
7
- * check-status, watch, keygen
6
+ * Subcommands: submit-and-poll, add-expert, list-experts,
7
+ * check-status, keygen
8
8
  *
9
9
  * All config comes from environment variables (set by the calling bash wrapper):
10
- * HEYSUMMON_BASE_URL, HEYSUMMON_API_KEY, HEYSUMMON_PROVIDERS_FILE,
11
- * HEYSUMMON_KEY_DIR, HEYSUMMON_REQUESTS_DIR, HEYSUMMON_TIMEOUT,
10
+ * HEYSUMMON_BASE_URL, HEYSUMMON_API_KEY, HEYSUMMON_EXPERTS_FILE,
11
+ * HEYSUMMON_TIMEOUT,
12
12
  * HEYSUMMON_POLL_INTERVAL
13
13
  */
14
14
  export {};