@ai2aim.ai/hivemind-sdk 2.0.1 → 3.1.1
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 +41 -145
- package/dist/cli.js +92 -36
- package/dist/cli.js.map +1 -1
- package/dist/client.d.ts +3 -34
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +74 -205
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -4
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +81 -221
- package/dist/types.d.ts.map +1 -1
- package/dist/web.d.ts.map +1 -1
- package/dist/web.js +185 -59
- package/dist/web.js.map +1 -1
- package/package.json +1 -1
- package/dist/ws.d.ts +0 -33
- package/dist/ws.d.ts.map +0 -1
- package/dist/ws.js +0 -78
- package/dist/ws.js.map +0 -1
package/dist/web.js
CHANGED
|
@@ -242,13 +242,9 @@ function buildDashboardHtml(config) {
|
|
|
242
242
|
</section>
|
|
243
243
|
|
|
244
244
|
<section class="card">
|
|
245
|
-
<h2>
|
|
246
|
-
<p class="sub">Use the active API key to run
|
|
245
|
+
<h2>Search</h2>
|
|
246
|
+
<p class="sub">Use the active API key to run discovery search across the current scope.</p>
|
|
247
247
|
<div class="form">
|
|
248
|
-
<label>Query<textarea id="ragQuery">What is the latest summary of our indexed content?</textarea></label>
|
|
249
|
-
<div class="actions">
|
|
250
|
-
<button id="runQuery">Run Query</button>
|
|
251
|
-
</div>
|
|
252
248
|
<div class="row">
|
|
253
249
|
<label>Search Query<input id="searchQuery" value="content marketing trends 2026"></label>
|
|
254
250
|
<label>Search Type<input id="searchType" value="organic"></label>
|
|
@@ -258,7 +254,7 @@ function buildDashboardHtml(config) {
|
|
|
258
254
|
<div></div>
|
|
259
255
|
</div>
|
|
260
256
|
<div class="actions">
|
|
261
|
-
<button id="runSearch"
|
|
257
|
+
<button id="runSearch">Run Search</button>
|
|
262
258
|
</div>
|
|
263
259
|
</div>
|
|
264
260
|
</section>
|
|
@@ -274,27 +270,6 @@ function buildDashboardHtml(config) {
|
|
|
274
270
|
</div>
|
|
275
271
|
</section>
|
|
276
272
|
|
|
277
|
-
<section class="card">
|
|
278
|
-
<h2>Projects</h2>
|
|
279
|
-
<p class="sub">Create projects, list them, and chat against a selected project.</p>
|
|
280
|
-
<div class="form">
|
|
281
|
-
<div class="row">
|
|
282
|
-
<label>Project Name<input id="projectName" value="Launch Campaign"></label>
|
|
283
|
-
<label>Project ID<input id="projectId" placeholder="Paste an existing project id"></label>
|
|
284
|
-
</div>
|
|
285
|
-
<label>Description<textarea id="projectDescription">Campaign workspace for API-key-scoped content operations.</textarea></label>
|
|
286
|
-
<div class="actions">
|
|
287
|
-
<button id="createProject">Create Project</button>
|
|
288
|
-
<button id="listProjects" class="secondary">List Projects</button>
|
|
289
|
-
</div>
|
|
290
|
-
<label>Chat Message<textarea id="projectMessage">Draft a short update using the saved project sources.</textarea></label>
|
|
291
|
-
<label>User ID<input id="projectUserId" value="sdk-dashboard"></label>
|
|
292
|
-
<div class="actions">
|
|
293
|
-
<button id="chatProject">Chat Project</button>
|
|
294
|
-
</div>
|
|
295
|
-
</div>
|
|
296
|
-
</section>
|
|
297
|
-
|
|
298
273
|
<section class="card">
|
|
299
274
|
<h2>Generation</h2>
|
|
300
275
|
<p class="sub">Start video, image, or music jobs and poll by job id.</p>
|
|
@@ -321,6 +296,135 @@ function buildDashboardHtml(config) {
|
|
|
321
296
|
</div>
|
|
322
297
|
</section>
|
|
323
298
|
|
|
299
|
+
<section class="card">
|
|
300
|
+
<h2>Social Content</h2>
|
|
301
|
+
<p class="sub">Generate platform-tailored content with tone, writing style, SEO review, and guardrail checks.</p>
|
|
302
|
+
<div class="form">
|
|
303
|
+
<label>Prompt<textarea id="socialPrompt">Launch our AI writing assistant for startup marketing teams that need faster campaign drafts and better collaboration.</textarea></label>
|
|
304
|
+
<div class="row">
|
|
305
|
+
<label>Platforms<input id="socialPlatforms" value="x,linkedin,instagram"></label>
|
|
306
|
+
<label>Objective
|
|
307
|
+
<select id="socialObjective">
|
|
308
|
+
<option value="engagement">engagement</option>
|
|
309
|
+
<option value="awareness">awareness</option>
|
|
310
|
+
<option value="clicks">clicks</option>
|
|
311
|
+
<option value="leads">leads</option>
|
|
312
|
+
<option value="conversions">conversions</option>
|
|
313
|
+
<option value="education">education</option>
|
|
314
|
+
<option value="community">community</option>
|
|
315
|
+
<option value="launch">launch</option>
|
|
316
|
+
</select>
|
|
317
|
+
</label>
|
|
318
|
+
</div>
|
|
319
|
+
<div class="row">
|
|
320
|
+
<label>Tone
|
|
321
|
+
<select id="socialTone">
|
|
322
|
+
<option value="professional">professional</option>
|
|
323
|
+
<option value="friendly">friendly</option>
|
|
324
|
+
<option value="playful">playful</option>
|
|
325
|
+
<option value="bold">bold</option>
|
|
326
|
+
<option value="authoritative">authoritative</option>
|
|
327
|
+
<option value="educational">educational</option>
|
|
328
|
+
<option value="witty">witty</option>
|
|
329
|
+
</select>
|
|
330
|
+
</label>
|
|
331
|
+
<label>Writing Style
|
|
332
|
+
<select id="socialStyle">
|
|
333
|
+
<option value="conversational">conversational</option>
|
|
334
|
+
<option value="storytelling">storytelling</option>
|
|
335
|
+
<option value="direct">direct</option>
|
|
336
|
+
<option value="thought_leadership">thought_leadership</option>
|
|
337
|
+
<option value="persuasive">persuasive</option>
|
|
338
|
+
<option value="community_led">community_led</option>
|
|
339
|
+
<option value="scripted">scripted</option>
|
|
340
|
+
</select>
|
|
341
|
+
</label>
|
|
342
|
+
</div>
|
|
343
|
+
<div class="row">
|
|
344
|
+
<label>Length
|
|
345
|
+
<select id="socialLength">
|
|
346
|
+
<option value="short">short</option>
|
|
347
|
+
<option value="medium">medium</option>
|
|
348
|
+
<option value="long">long</option>
|
|
349
|
+
</select>
|
|
350
|
+
</label>
|
|
351
|
+
<label>Variations<input id="socialVariations" type="number" min="1" max="5" value="2"></label>
|
|
352
|
+
</div>
|
|
353
|
+
<div class="row">
|
|
354
|
+
<label>Audience<input id="socialAudience" value="startup marketing teams"></label>
|
|
355
|
+
<label>Brand<input id="socialBrand" value="LaunchPilot"></label>
|
|
356
|
+
</div>
|
|
357
|
+
<div class="row">
|
|
358
|
+
<label>Call To Action<input id="socialCta" value="Book a demo this week."></label>
|
|
359
|
+
<label>Primary Keyword<input id="socialKeyword" value="AI writing assistant"></label>
|
|
360
|
+
</div>
|
|
361
|
+
<div class="row">
|
|
362
|
+
<label>Secondary Keywords<input id="socialSecondary" value="startup marketing,content workflow"></label>
|
|
363
|
+
<label>Hashtags<input id="socialHashtags" value="AIWriting,StartupMarketing"></label>
|
|
364
|
+
</div>
|
|
365
|
+
<div class="row">
|
|
366
|
+
<label>Landing Page URL<input id="socialUrl" value="https://example.com/demo"></label>
|
|
367
|
+
<label>Language<input id="socialLanguage" value="en"></label>
|
|
368
|
+
</div>
|
|
369
|
+
<div class="row">
|
|
370
|
+
<label>Emoji Density
|
|
371
|
+
<select id="socialEmojiDensity">
|
|
372
|
+
<option value="none">none</option>
|
|
373
|
+
<option value="light">light</option>
|
|
374
|
+
<option value="medium">medium</option>
|
|
375
|
+
<option value="heavy">heavy</option>
|
|
376
|
+
</select>
|
|
377
|
+
</label>
|
|
378
|
+
<label>Hashtag Count<input id="socialHashtagCount" type="number" min="0" max="12" value="3"></label>
|
|
379
|
+
</div>
|
|
380
|
+
<div class="row">
|
|
381
|
+
<label>Must Include<input id="socialMustInclude" value="free trial"></label>
|
|
382
|
+
<label>Avoid Terms<input id="socialAvoid" value="guaranteed results"></label>
|
|
383
|
+
</div>
|
|
384
|
+
<label>Compliance Notes<textarea id="socialCompliance">Avoid unverifiable performance claims.</textarea></label>
|
|
385
|
+
<div class="row">
|
|
386
|
+
<label>Include Emojis
|
|
387
|
+
<select id="socialIncludeEmojis">
|
|
388
|
+
<option value="false">false</option>
|
|
389
|
+
<option value="true">true</option>
|
|
390
|
+
</select>
|
|
391
|
+
</label>
|
|
392
|
+
<label>Include Script
|
|
393
|
+
<select id="socialIncludeScript">
|
|
394
|
+
<option value="false">false</option>
|
|
395
|
+
<option value="true">true</option>
|
|
396
|
+
</select>
|
|
397
|
+
</label>
|
|
398
|
+
</div>
|
|
399
|
+
<div class="row">
|
|
400
|
+
<label>Include Title
|
|
401
|
+
<select id="socialIncludeTitle">
|
|
402
|
+
<option value="true">true</option>
|
|
403
|
+
<option value="false">false</option>
|
|
404
|
+
</select>
|
|
405
|
+
</label>
|
|
406
|
+
<label>Include Hook
|
|
407
|
+
<select id="socialIncludeHook">
|
|
408
|
+
<option value="true">true</option>
|
|
409
|
+
<option value="false">false</option>
|
|
410
|
+
</select>
|
|
411
|
+
</label>
|
|
412
|
+
</div>
|
|
413
|
+
<div class="row">
|
|
414
|
+
<label>Include Short Description
|
|
415
|
+
<select id="socialIncludeShortDescription">
|
|
416
|
+
<option value="true">true</option>
|
|
417
|
+
<option value="false">false</option>
|
|
418
|
+
</select>
|
|
419
|
+
</label>
|
|
420
|
+
<div></div>
|
|
421
|
+
</div>
|
|
422
|
+
<div class="actions">
|
|
423
|
+
<button id="generateSocial">Generate Social Content</button>
|
|
424
|
+
</div>
|
|
425
|
+
</div>
|
|
426
|
+
</section>
|
|
427
|
+
|
|
324
428
|
<section class="card">
|
|
325
429
|
<h2>Scraping</h2>
|
|
326
430
|
<p class="sub">Submit public URLs for scraping and then inspect the task status.</p>
|
|
@@ -341,7 +445,6 @@ https://www.openai.com</textarea></label>
|
|
|
341
445
|
<div class="actions">
|
|
342
446
|
<button id="getRateLimits">Rate Limits</button>
|
|
343
447
|
<button id="getJobs" class="secondary">Jobs</button>
|
|
344
|
-
<button id="runSchedules" class="secondary">Run Due Schedules</button>
|
|
345
448
|
<button id="getAudit" class="secondary">Admin Audit</button>
|
|
346
449
|
</div>
|
|
347
450
|
</section>
|
|
@@ -369,8 +472,8 @@ https://www.openai.com</textarea></label>
|
|
|
369
472
|
</select>
|
|
370
473
|
</label>
|
|
371
474
|
</div>
|
|
372
|
-
<label>Path<input id="manualPath" value="/
|
|
373
|
-
<label>JSON Body<textarea id="manualBody">{"query":"
|
|
475
|
+
<label>Path<input id="manualPath" value="/search"></label>
|
|
476
|
+
<label>JSON Body<textarea id="manualBody">{"query":"content marketing trends 2026","num":5}</textarea></label>
|
|
374
477
|
<div class="actions">
|
|
375
478
|
<button id="sendManual">Send Request</button>
|
|
376
479
|
</div>
|
|
@@ -458,6 +561,22 @@ https://www.openai.com</textarea></label>
|
|
|
458
561
|
return JSON.parse(raw);
|
|
459
562
|
}
|
|
460
563
|
|
|
564
|
+
function parseList(raw, stripHashes = false) {
|
|
565
|
+
if (!raw) return [];
|
|
566
|
+
const seen = new Set();
|
|
567
|
+
return raw
|
|
568
|
+
.split(",")
|
|
569
|
+
.map((item) => item.trim())
|
|
570
|
+
.filter(Boolean)
|
|
571
|
+
.map((item) => stripHashes ? item.replace(/^#+/, "") : item)
|
|
572
|
+
.filter((item) => {
|
|
573
|
+
const key = item.toLowerCase();
|
|
574
|
+
if (seen.has(key)) return false;
|
|
575
|
+
seen.add(key);
|
|
576
|
+
return true;
|
|
577
|
+
});
|
|
578
|
+
}
|
|
579
|
+
|
|
461
580
|
async function apiRequest(method, path, options = {}) {
|
|
462
581
|
const settings = cfg();
|
|
463
582
|
const url = new URL((settings.apiPrefix || "/v1") + path, settings.baseUrl);
|
|
@@ -527,10 +646,6 @@ https://www.openai.com</textarea></label>
|
|
|
527
646
|
};
|
|
528
647
|
|
|
529
648
|
document.getElementById("rotateApiKey").onclick = () => apiRequest("POST", "/api-key/rotate", { auth: "api" });
|
|
530
|
-
document.getElementById("runQuery").onclick = () => apiRequest("POST", "/query", {
|
|
531
|
-
auth: "api",
|
|
532
|
-
json: { query: document.getElementById("ragQuery").value },
|
|
533
|
-
});
|
|
534
649
|
document.getElementById("runSearch").onclick = () => apiRequest("POST", "/search", {
|
|
535
650
|
auth: "api",
|
|
536
651
|
json: {
|
|
@@ -552,29 +667,6 @@ https://www.openai.com</textarea></label>
|
|
|
552
667
|
await apiRequest("POST", "/documents/upload", { auth: "api", formData });
|
|
553
668
|
};
|
|
554
669
|
|
|
555
|
-
document.getElementById("createProject").onclick = () => apiRequest("POST", "/projects", {
|
|
556
|
-
auth: "api",
|
|
557
|
-
json: {
|
|
558
|
-
name: document.getElementById("projectName").value,
|
|
559
|
-
description: document.getElementById("projectDescription").value,
|
|
560
|
-
},
|
|
561
|
-
});
|
|
562
|
-
document.getElementById("listProjects").onclick = () => apiRequest("GET", "/projects", { auth: "api" });
|
|
563
|
-
document.getElementById("chatProject").onclick = () => {
|
|
564
|
-
const projectId = document.getElementById("projectId").value.trim();
|
|
565
|
-
if (!projectId) {
|
|
566
|
-
setOutput("Chat Project", "Provide a project id first.");
|
|
567
|
-
return;
|
|
568
|
-
}
|
|
569
|
-
return apiRequest("POST", "/projects/" + encodeURIComponent(projectId) + "/chat", {
|
|
570
|
-
auth: "api",
|
|
571
|
-
json: {
|
|
572
|
-
message: document.getElementById("projectMessage").value,
|
|
573
|
-
user_id: document.getElementById("projectUserId").value || "sdk-dashboard",
|
|
574
|
-
},
|
|
575
|
-
});
|
|
576
|
-
};
|
|
577
|
-
|
|
578
670
|
document.getElementById("startGeneration").onclick = () => {
|
|
579
671
|
const type = document.getElementById("generationType").value;
|
|
580
672
|
const prompt = document.getElementById("generationPrompt").value;
|
|
@@ -591,6 +683,41 @@ https://www.openai.com</textarea></label>
|
|
|
591
683
|
return apiRequest("POST", "/generate/" + type, { auth: "api", json: body });
|
|
592
684
|
};
|
|
593
685
|
|
|
686
|
+
document.getElementById("generateSocial").onclick = () => apiRequest("POST", "/generate/social", {
|
|
687
|
+
auth: "api",
|
|
688
|
+
json: {
|
|
689
|
+
prompt: document.getElementById("socialPrompt").value,
|
|
690
|
+
platforms: parseList(document.getElementById("socialPlatforms").value).map((item) => item.toLowerCase()),
|
|
691
|
+
objective: document.getElementById("socialObjective").value,
|
|
692
|
+
target_audience: document.getElementById("socialAudience").value || undefined,
|
|
693
|
+
brand_name: document.getElementById("socialBrand").value || undefined,
|
|
694
|
+
tone: document.getElementById("socialTone").value,
|
|
695
|
+
writing_style: document.getElementById("socialStyle").value,
|
|
696
|
+
length: document.getElementById("socialLength").value,
|
|
697
|
+
call_to_action: document.getElementById("socialCta").value || undefined,
|
|
698
|
+
primary_keyword: document.getElementById("socialKeyword").value || undefined,
|
|
699
|
+
secondary_keywords: parseList(document.getElementById("socialSecondary").value),
|
|
700
|
+
hashtags: parseList(document.getElementById("socialHashtags").value, true),
|
|
701
|
+
hashtag_count: Number(document.getElementById("socialHashtagCount").value || 3),
|
|
702
|
+
include_hashtags: true,
|
|
703
|
+
include_emojis: document.getElementById("socialIncludeEmojis").value === "true",
|
|
704
|
+
emoji_density: document.getElementById("socialEmojiDensity").value,
|
|
705
|
+
variation_count: Number(document.getElementById("socialVariations").value || 1),
|
|
706
|
+
include_title: document.getElementById("socialIncludeTitle").value === "true",
|
|
707
|
+
include_hook: document.getElementById("socialIncludeHook").value === "true",
|
|
708
|
+
include_short_description: document.getElementById("socialIncludeShortDescription").value === "true",
|
|
709
|
+
include_script: document.getElementById("socialIncludeScript").value === "true",
|
|
710
|
+
must_include: parseList(document.getElementById("socialMustInclude").value),
|
|
711
|
+
avoid_terms: parseList(document.getElementById("socialAvoid").value),
|
|
712
|
+
compliance_notes: document.getElementById("socialCompliance").value
|
|
713
|
+
.split("\\n")
|
|
714
|
+
.map((item) => item.trim())
|
|
715
|
+
.filter(Boolean),
|
|
716
|
+
landing_page_url: document.getElementById("socialUrl").value || undefined,
|
|
717
|
+
language: document.getElementById("socialLanguage").value || "en",
|
|
718
|
+
},
|
|
719
|
+
});
|
|
720
|
+
|
|
594
721
|
document.getElementById("getJob").onclick = () => {
|
|
595
722
|
const jobId = document.getElementById("jobId").value.trim();
|
|
596
723
|
if (!jobId) {
|
|
@@ -619,7 +746,6 @@ https://www.openai.com</textarea></label>
|
|
|
619
746
|
|
|
620
747
|
document.getElementById("getRateLimits").onclick = () => apiRequest("GET", "/admin/rate-limits", { auth: "admin" });
|
|
621
748
|
document.getElementById("getJobs").onclick = () => apiRequest("GET", "/admin/jobs", { auth: "admin" });
|
|
622
|
-
document.getElementById("runSchedules").onclick = () => apiRequest("POST", "/admin/content-creator/schedules/run-due", { auth: "admin" });
|
|
623
749
|
document.getElementById("getAudit").onclick = () => apiRequest("GET", "/admin/audit", { auth: "admin" });
|
|
624
750
|
|
|
625
751
|
document.getElementById("sendManual").onclick = () => {
|
package/dist/web.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.js","sourceRoot":"","sources":["../src/web.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../src/web.ts"],"names":[],"mappings":";;;;;AAuxBA,wCAkCC;AAzzBD,0DAA6B;AAG7B,SAAS,kBAAkB,CAAC,MAM3B;IACC,MAAM,GAAG,GAAG,CAAC,KAAa,EAAE,EAAE,CAC5B,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAEzE,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wDA8M+C,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC;4DACf,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC;;oDAE7B,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC;wDACd,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC;kEACV,GAAG,CAAC,MAAM,CAAC,aAAa,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AI,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE;QACzC,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,EAAiB,CAAC;QAC7C,MAAM,GAAG,GAAG,oBAAoB,IAAI,CAAC,IAAI,EAAE,CAAC;QAC5C,OAAO,CAAC,GAAG,CAAC,yCAAyC,GAAG,IAAI,CAAC,CAAC;QAC9D,OAAO,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC;QAEzC,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YACd,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,oBAAoB,CAAwC,CAAC;YACtF,MAAM,GAAG,GACP,OAAO,CAAC,QAAQ,KAAK,QAAQ;gBAC3B,CAAC,CAAC,SAAS,GAAG,GAAG;gBACjB,CAAC,CAAC,OAAO,CAAC,QAAQ,KAAK,OAAO;oBAC5B,CAAC,CAAC,aAAa,GAAG,GAAG;oBACrB,CAAC,CAAC,aAAa,GAAG,GAAG,CAAC;YAC5B,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QACtB,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/package.json
CHANGED
package/dist/ws.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WebSocket helper for the Hivemind real-time protocol.
|
|
3
|
-
*
|
|
4
|
-
* Uses `globalThis.WebSocket` (available in browsers and Node 22+).
|
|
5
|
-
* For older Node versions, install the `ws` package and assign it to
|
|
6
|
-
* `globalThis.WebSocket` before calling these helpers.
|
|
7
|
-
*/
|
|
8
|
-
import type { WsChatCommand, WsChatFrame } from "./types";
|
|
9
|
-
export interface HivemindWebSocketOptions {
|
|
10
|
-
/** API key appended as `?api_key=` query param. */
|
|
11
|
-
apiKey?: string;
|
|
12
|
-
/** WebSocket sub-protocols to request. */
|
|
13
|
-
protocols?: string | string[];
|
|
14
|
-
/** AbortSignal — closing the signal closes the socket. */
|
|
15
|
-
signal?: AbortSignal;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Open a WebSocket to a Hivemind real-time endpoint.
|
|
19
|
-
*
|
|
20
|
-
* @param url - Full `ws://` or `wss://` URL (caller builds it from baseUrl).
|
|
21
|
-
* @param opts - Options including API key and abort signal.
|
|
22
|
-
* @returns The raw `WebSocket` instance after the connection opens.
|
|
23
|
-
*/
|
|
24
|
-
export declare function openHivemindWebSocket(url: string, opts?: HivemindWebSocketOptions): Promise<WebSocket>;
|
|
25
|
-
/**
|
|
26
|
-
* Send a chat command and wait for the next server frame.
|
|
27
|
-
*
|
|
28
|
-
* @param ws - An open Hivemind WebSocket.
|
|
29
|
-
* @param cmd - The chat command to send.
|
|
30
|
-
* @returns The server's response frame.
|
|
31
|
-
*/
|
|
32
|
-
export declare function sendChatCommand(ws: WebSocket, cmd: WsChatCommand): Promise<WsChatFrame>;
|
|
33
|
-
//# sourceMappingURL=ws.d.ts.map
|
package/dist/ws.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ws.d.ts","sourceRoot":"","sources":["../src/ws.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE1D,MAAM,WAAW,wBAAwB;IACvC,mDAAmD;IACnD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,0CAA0C;IAC1C,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC9B,0DAA0D;IAC1D,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,MAAM,EACX,IAAI,GAAE,wBAA6B,GAClC,OAAO,CAAC,SAAS,CAAC,CAoCpB;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,EAAE,EAAE,SAAS,EACb,GAAG,EAAE,aAAa,GACjB,OAAO,CAAC,WAAW,CAAC,CAsBtB"}
|
package/dist/ws.js
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* WebSocket helper for the Hivemind real-time protocol.
|
|
4
|
-
*
|
|
5
|
-
* Uses `globalThis.WebSocket` (available in browsers and Node 22+).
|
|
6
|
-
* For older Node versions, install the `ws` package and assign it to
|
|
7
|
-
* `globalThis.WebSocket` before calling these helpers.
|
|
8
|
-
*/
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.openHivemindWebSocket = openHivemindWebSocket;
|
|
11
|
-
exports.sendChatCommand = sendChatCommand;
|
|
12
|
-
/**
|
|
13
|
-
* Open a WebSocket to a Hivemind real-time endpoint.
|
|
14
|
-
*
|
|
15
|
-
* @param url - Full `ws://` or `wss://` URL (caller builds it from baseUrl).
|
|
16
|
-
* @param opts - Options including API key and abort signal.
|
|
17
|
-
* @returns The raw `WebSocket` instance after the connection opens.
|
|
18
|
-
*/
|
|
19
|
-
function openHivemindWebSocket(url, opts = {}) {
|
|
20
|
-
const target = new URL(url);
|
|
21
|
-
if (opts.apiKey) {
|
|
22
|
-
target.searchParams.set("api_key", opts.apiKey);
|
|
23
|
-
}
|
|
24
|
-
return new Promise((resolve, reject) => {
|
|
25
|
-
const ws = new WebSocket(target.toString(), opts.protocols);
|
|
26
|
-
const onOpen = () => {
|
|
27
|
-
cleanup();
|
|
28
|
-
resolve(ws);
|
|
29
|
-
};
|
|
30
|
-
const onError = (ev) => {
|
|
31
|
-
cleanup();
|
|
32
|
-
const msg = ev.message ?? "unknown";
|
|
33
|
-
reject(new Error(`WebSocket connection failed: ${msg}`));
|
|
34
|
-
};
|
|
35
|
-
const cleanup = () => {
|
|
36
|
-
ws.removeEventListener("open", onOpen);
|
|
37
|
-
ws.removeEventListener("error", onError);
|
|
38
|
-
};
|
|
39
|
-
ws.addEventListener("open", onOpen);
|
|
40
|
-
ws.addEventListener("error", onError);
|
|
41
|
-
if (opts.signal) {
|
|
42
|
-
opts.signal.addEventListener("abort", () => {
|
|
43
|
-
ws.close(1000, "aborted");
|
|
44
|
-
}, { once: true });
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Send a chat command and wait for the next server frame.
|
|
50
|
-
*
|
|
51
|
-
* @param ws - An open Hivemind WebSocket.
|
|
52
|
-
* @param cmd - The chat command to send.
|
|
53
|
-
* @returns The server's response frame.
|
|
54
|
-
*/
|
|
55
|
-
function sendChatCommand(ws, cmd) {
|
|
56
|
-
return new Promise((resolve, reject) => {
|
|
57
|
-
const onMessage = (ev) => {
|
|
58
|
-
ws.removeEventListener("message", onMessage);
|
|
59
|
-
ws.removeEventListener("error", onError);
|
|
60
|
-
try {
|
|
61
|
-
resolve(JSON.parse(typeof ev.data === "string" ? ev.data : new TextDecoder().decode(ev.data)));
|
|
62
|
-
}
|
|
63
|
-
catch (err) {
|
|
64
|
-
reject(err);
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
const onError = (ev) => {
|
|
68
|
-
ws.removeEventListener("message", onMessage);
|
|
69
|
-
ws.removeEventListener("error", onError);
|
|
70
|
-
const msg = ev.message ?? "unknown";
|
|
71
|
-
reject(new Error(`WebSocket error: ${msg}`));
|
|
72
|
-
};
|
|
73
|
-
ws.addEventListener("message", onMessage);
|
|
74
|
-
ws.addEventListener("error", onError);
|
|
75
|
-
ws.send(JSON.stringify(cmd));
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
//# sourceMappingURL=ws.js.map
|
package/dist/ws.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ws.js","sourceRoot":"","sources":["../src/ws.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAoBH,sDAuCC;AASD,0CAyBC;AAhFD;;;;;;GAMG;AACH,SAAgB,qBAAqB,CACnC,GAAW,EACX,OAAiC,EAAE;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