@absolutejs/voice 0.0.22-beta.644 → 0.0.22-beta.646

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,6 +1,8 @@
1
1
  export { bindVoiceReactiveSource, voiceSseReactiveSource, } from "./reactiveSource";
2
2
  export type { VoiceReactiveSource, VoiceSseReactiveSourceOptions, } from "./reactiveSource";
3
3
  export { createVoiceConnection } from "./connection";
4
+ export { checkBrowserVoiceSupport, probeBrowserVoiceSupport, } from "./browserVoiceSupport";
5
+ export type { BrowserVoiceSupportProbe, BrowserVoiceSupportReport, } from "./browserVoiceSupport";
4
6
  export { createVoiceAudioPlayer, decodeVoiceAudioChunk } from "./audioPlayer";
5
7
  export { createTimeStretcher, type TimeStretcher } from "./timeStretch";
6
8
  export { createVoiceStream } from "./createVoiceStream";
@@ -375,6 +375,88 @@ var createVoiceConnection = (path, options = {}) => {
375
375
  getSessionId: () => state.sessionId
376
376
  };
377
377
  };
378
+ // src/client/browserVoiceSupport.ts
379
+ var safeGet = (fn) => {
380
+ try {
381
+ return fn();
382
+ } catch {
383
+ return;
384
+ }
385
+ };
386
+ var detectMediaRecorderOpus = (ctor) => {
387
+ if (!ctor || typeof ctor.isTypeSupported !== "function")
388
+ return false;
389
+ try {
390
+ return ctor.isTypeSupported("audio/webm;codecs=opus");
391
+ } catch {
392
+ return false;
393
+ }
394
+ };
395
+ var checkBrowserVoiceSupport = (globalScope = globalThis) => {
396
+ const capabilities = probeBrowserVoiceSupport(globalScope);
397
+ const blockers = [];
398
+ const warnings = [];
399
+ if (!capabilities.hasWebSocket) {
400
+ blockers.push("WebSocket is not available \u2014 voice runtime cannot stream audio.");
401
+ }
402
+ if (!capabilities.hasGetUserMedia) {
403
+ blockers.push("navigator.mediaDevices.getUserMedia is not available \u2014 cannot capture microphone.");
404
+ }
405
+ if (capabilities.isInsecureContext) {
406
+ blockers.push("Page is served from an insecure context; getUserMedia requires HTTPS or localhost.");
407
+ }
408
+ if (!capabilities.hasAudioContext) {
409
+ blockers.push("AudioContext is not available \u2014 cannot decode or play TTS audio.");
410
+ }
411
+ if (!capabilities.hasAudioWorklet) {
412
+ warnings.push("AudioWorklet is unavailable \u2014 noise suppression and custom audio processors won't run.");
413
+ }
414
+ if (!capabilities.hasRTCPeerConnection) {
415
+ warnings.push("RTCPeerConnection is unavailable \u2014 WebRTC transport paths are disabled.");
416
+ }
417
+ if (!capabilities.hasOpusEncoding) {
418
+ warnings.push("MediaRecorder does not advertise Opus support \u2014 fall back to PCM streaming.");
419
+ }
420
+ if (capabilities.requiresUserGestureToResumeAudio) {
421
+ warnings.push("Safari / iOS requires a user gesture before audioContext.resume() succeeds.");
422
+ }
423
+ return {
424
+ blockers,
425
+ capabilities,
426
+ ok: blockers.length === 0,
427
+ warnings
428
+ };
429
+ };
430
+ var probeBrowserVoiceSupport = (globalScope = globalThis) => {
431
+ const win = globalScope;
432
+ const userAgent = win.navigator?.userAgent ?? "";
433
+ const audioContextCtor = win.AudioContext ?? win.webkitAudioContext;
434
+ const hasAudioContext = typeof audioContextCtor === "function";
435
+ const hasAudioWorklet = hasAudioContext ? safeGet(() => ("audioWorklet" in audioContextCtor.prototype)) === true : false;
436
+ const hasGetUserMedia = Boolean(win.navigator?.mediaDevices && typeof win.navigator.mediaDevices.getUserMedia === "function");
437
+ const hasMediaRecorder = typeof win.MediaRecorder === "function";
438
+ const hasRTCPeerConnection = typeof win.RTCPeerConnection === "function";
439
+ const hasWebSocket = typeof win.WebSocket === "function";
440
+ const isInsecureContext = typeof win.isSecureContext === "boolean" ? !win.isSecureContext : false;
441
+ const isSafari = /^((?!chrome|android).)*safari/i.test(userAgent);
442
+ const isIos = /iPad|iPhone|iPod/.test(userAgent);
443
+ const requiresUserGestureToResumeAudio = isSafari || isIos;
444
+ const hasOpusEncoding = detectMediaRecorderOpus(win.MediaRecorder);
445
+ return {
446
+ hasAudioContext,
447
+ hasAudioWorklet,
448
+ hasGetUserMedia,
449
+ hasMediaRecorder,
450
+ hasOpusEncoding,
451
+ hasRTCPeerConnection,
452
+ hasWebSocket,
453
+ isInsecureContext,
454
+ isIos,
455
+ isSafari,
456
+ requiresUserGestureToResumeAudio,
457
+ userAgent
458
+ };
459
+ };
378
460
  // src/client/timeStretch.ts
379
461
  var HOP_MS = 10;
380
462
  var SEEK_MS = 5;
@@ -12464,6 +12546,7 @@ export {
12464
12546
  renderVoiceCallDebuggerLaunchHTML,
12465
12547
  renderVoiceAgentSquadStatusHTML,
12466
12548
  recordVoiceOpsActionResult,
12549
+ probeBrowserVoiceSupport,
12467
12550
  postVoiceLiveOpsAction,
12468
12551
  mountVoiceTurnQuality,
12469
12552
  mountVoiceTurnLatency,
@@ -12609,6 +12692,7 @@ export {
12609
12692
  createVoiceAgentSquadStatusStore,
12610
12693
  createTimeStretcher,
12611
12694
  createMicrophoneCapture,
12695
+ checkBrowserVoiceSupport,
12612
12696
  buildVoiceAgentSquadStatusReport,
12613
12697
  bindVoiceReactiveSource,
12614
12698
  bindVoiceProviderSimulationControls,
@@ -1,2 +1,17 @@
1
1
  import type { VoicePluginConfig, VoiceSessionStore } from "./core/types";
2
- export declare const manifest: import("@absolutejs/manifest").PackageManifest<VoicePluginConfig, VoiceSessionStore>;
2
+ export declare const manifest: Omit<import("@absolutejs/manifest").PackageManifest<VoicePluginConfig, VoiceSessionStore>, "tools" | "contract" | "settings"> & (({
3
+ contract: 1;
4
+ tools?: Record<string, import("@absolutejs/manifest").LegacyManifestTool<VoiceSessionStore>> | undefined;
5
+ } | {
6
+ contract: 2;
7
+ tools?: Record<string, import("@absolutejs/manifest").AuthorizedManifestTool<VoiceSessionStore>> | undefined;
8
+ }) & {
9
+ settings: import("@sinclair/typebox").TObject<{
10
+ backchannelBargeInGuard: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
11
+ greeting: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
12
+ normalizeNumbers: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
13
+ path: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
14
+ preset: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"default">, import("@sinclair/typebox").TLiteral<"chat">, import("@sinclair/typebox").TLiteral<"guided-intake">, import("@sinclair/typebox").TLiteral<"dictation">, import("@sinclair/typebox").TLiteral<"noisy-room">, import("@sinclair/typebox").TLiteral<"pstn-balanced">, import("@sinclair/typebox").TLiteral<"pstn-fast">, import("@sinclair/typebox").TLiteral<"reliability">]>>;
15
+ resumeGreeting: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
16
+ }>;
17
+ });
package/dist/manifest.js CHANGED
@@ -102,14 +102,19 @@ var defineImplementation = () => (implementation) => {
102
102
  const defined = implementation;
103
103
  return defined;
104
104
  };
105
- var defineManifest = () => (manifest) => {
106
- const defined = manifest;
107
- return defined;
105
+ var defineManifest = () => (manifest) => manifest;
106
+ var literal = (value) => value;
107
+ var RUNTIME_KIND = literal("runtime");
108
+ var WORKSPACE_KIND = literal("workspace");
109
+ var toolFactory = () => {
110
+ function runtime(definition) {
111
+ return { kind: RUNTIME_KIND, ...definition };
112
+ }
113
+ function workspace(definition) {
114
+ return { kind: WORKSPACE_KIND, ...definition };
115
+ }
116
+ return { runtime, workspace };
108
117
  };
109
- var toolFactory = () => ({
110
- runtime: (definition) => ({ kind: "runtime", ...definition }),
111
- workspace: (definition) => ({ kind: "workspace", ...definition })
112
- });
113
118
  function IsAsyncIterator(value) {
114
119
  return IsObject(value) && globalThis.Symbol.asyncIterator in value;
115
120
  }
@@ -847,7 +852,7 @@ function String2(options) {
847
852
  function* FromUnion(syntax) {
848
853
  const trim = syntax.trim().replace(/"|'/g, "");
849
854
  return trim === "boolean" ? yield Boolean() : trim === "number" ? yield Number2() : trim === "bigint" ? yield BigInt2() : trim === "string" ? yield String2() : yield (() => {
850
- const literals = trim.split("|").map((literal) => Literal(literal.trim()));
855
+ const literals = trim.split("|").map((literal2) => Literal(literal2.trim()));
851
856
  return literals.length === 0 ? Never() : literals.length === 1 ? literals[0] : UnionEvaluated(literals);
852
857
  })();
853
858
  }
@@ -3555,10 +3560,10 @@ function ScoreUnion(schema, references, value) {
3555
3560
  const keys = Object.getOwnPropertyNames(value);
3556
3561
  const entries = Object.entries(object.properties);
3557
3562
  return entries.reduce((acc, [key, schema2]) => {
3558
- const literal = schema2[Kind] === "Literal" && schema2.const === value[key] ? 100 : 0;
3563
+ const literal2 = schema2[Kind] === "Literal" && schema2.const === value[key] ? 100 : 0;
3559
3564
  const checks = Check(schema2, references, value[key]) ? 10 : 0;
3560
3565
  const exists = keys.includes(key) ? 1 : 0;
3561
- return acc + (literal + checks + exists);
3566
+ return acc + (literal2 + checks + exists);
3562
3567
  }, 0);
3563
3568
  } else if (schema[Kind] === "Union") {
3564
3569
  const schemas = schema.anyOf.map((schema2) => Deref(schema2, references));
@@ -5895,7 +5900,13 @@ var wiringSnippet = Type.Object({
5895
5900
  Type.Literal("server-plugin")
5896
5901
  ]))
5897
5902
  });
5898
- var clientFrameworks = ["angular", "client", "react", "svelte", "vue"];
5903
+ var clientFrameworks = [
5904
+ "angular",
5905
+ "client",
5906
+ "react",
5907
+ "svelte",
5908
+ "vue"
5909
+ ];
5899
5910
  var wiringRecipe = Type.Object({
5900
5911
  client: Type.Optional(Type.Partial(Type.Object(Object.fromEntries(clientFrameworks.map((framework) => [framework, wiringSnippet]))))),
5901
5912
  description: Type.Optional(Type.String()),
@@ -5960,8 +5971,47 @@ var toolAnnotations = Type.Object({
5960
5971
  readOnlyHint: Type.Optional(Type.Boolean()),
5961
5972
  title: Type.Optional(Type.String())
5962
5973
  });
5974
+ var toolAuthorization = Type.Object({
5975
+ approval: Type.Union([
5976
+ Type.Literal("always"),
5977
+ Type.Literal("never"),
5978
+ Type.Literal("policy")
5979
+ ]),
5980
+ audience: Type.Union([
5981
+ Type.Literal("admin"),
5982
+ Type.Literal("authenticated"),
5983
+ Type.Literal("owner"),
5984
+ Type.Literal("public")
5985
+ ]),
5986
+ compensatingTool: Type.Optional(Type.String({ pattern: TOOL_NAME_PATTERN.source })),
5987
+ destinationFields: Type.Optional(Type.Array(Type.String({ minLength: 1 }), { minItems: 1 })),
5988
+ destinations: Type.Optional(Type.Array(Type.String({ minLength: 1 }), { minItems: 1 })),
5989
+ effects: Type.Array(Type.String({ minLength: 1 }), { minItems: 1 }),
5990
+ idempotency: Type.Optional(Type.Union([
5991
+ Type.Object({
5992
+ field: Type.String({ minLength: 1 }),
5993
+ mode: Type.Literal("field")
5994
+ }),
5995
+ Type.Object({ mode: Type.Literal("host") }),
5996
+ Type.Object({ mode: Type.Literal("resource") })
5997
+ ])),
5998
+ requiredScopes: Type.Optional(Type.Array(Type.String({ minLength: 1 }), { minItems: 1 })),
5999
+ resource: Type.Optional(Type.Object({
6000
+ idField: Type.Optional(Type.String({ minLength: 1 })),
6001
+ ownerIdField: Type.Optional(Type.String({ minLength: 1 })),
6002
+ tenantIdField: Type.Optional(Type.String({ minLength: 1 })),
6003
+ type: Type.String({ minLength: 1 })
6004
+ })),
6005
+ reversible: Type.Optional(Type.Boolean()),
6006
+ spend: Type.Optional(Type.Object({
6007
+ amountMinorField: Type.String({ minLength: 1 }),
6008
+ currencyField: Type.String({ minLength: 1 }),
6009
+ maximumAmountMinor: Type.Optional(Type.Integer({ minimum: 0 }))
6010
+ }))
6011
+ });
5963
6012
  var serializedTool = Type.Object({
5964
6013
  annotations: Type.Optional(toolAnnotations),
6014
+ authorization: Type.Optional(toolAuthorization),
5965
6015
  capabilities: Type.Optional(Type.Array(Type.Union([
5966
6016
  Type.Literal("exec"),
5967
6017
  Type.Literal("glob"),
@@ -5973,7 +6023,15 @@ var serializedTool = Type.Object({
5973
6023
  kind: Type.Union([Type.Literal("runtime"), Type.Literal("workspace")])
5974
6024
  });
5975
6025
  var manifestSchema = Type.Object({
5976
- contract: Type.Literal(1),
6026
+ contract: Type.Union([Type.Literal(1), Type.Literal(2)]),
6027
+ discovery: Type.Optional(Type.Object({
6028
+ audiences: Type.Optional(Type.Array(Type.String({ minLength: 1 }))),
6029
+ certificationUrl: Type.Optional(Type.String()),
6030
+ intents: Type.Optional(Type.Array(Type.String({ minLength: 1 }))),
6031
+ keywords: Type.Optional(Type.Array(Type.String({ minLength: 1 }))),
6032
+ protocols: Type.Optional(Type.Array(Type.String({ minLength: 1 }))),
6033
+ url: Type.Optional(Type.String())
6034
+ })),
5977
6035
  identity: Type.Object({
5978
6036
  accent: Type.Optional(Type.String({ pattern: "^#[0-9a-fA-F]{3,8}$" })),
5979
6037
  category: Type.String({ minLength: 1 }),
@@ -5983,7 +6041,9 @@ var manifestSchema = Type.Object({
5983
6041
  svg: Type.Optional(Type.String()),
5984
6042
  url: Type.Optional(Type.String())
5985
6043
  })),
5986
- name: Type.String({ pattern: "^(@[a-z0-9-~][a-z0-9-._~]*/)?[a-z0-9-~][a-z0-9-._~]*$" }),
6044
+ name: Type.String({
6045
+ pattern: "^(@[a-z0-9-~][a-z0-9-._~]*/)?[a-z0-9-~][a-z0-9-._~]*$"
6046
+ }),
5987
6047
  tagline: Type.String({ minLength: 1 })
5988
6048
  }),
5989
6049
  implements: Type.Optional(Type.Array(adapterImplementation)),
@@ -6956,7 +7016,7 @@ function String3(options) {
6956
7016
  function* FromUnion21(syntax) {
6957
7017
  const trim = syntax.trim().replace(/"|'/g, "");
6958
7018
  return trim === "boolean" ? yield Boolean2() : trim === "number" ? yield Number3() : trim === "bigint" ? yield BigInt3() : trim === "string" ? yield String3() : yield (() => {
6959
- const literals = trim.split("|").map((literal) => Literal2(literal.trim()));
7019
+ const literals = trim.split("|").map((literal2) => Literal2(literal2.trim()));
6960
7020
  return literals.length === 0 ? Never2() : literals.length === 1 ? literals[0] : UnionEvaluated2(literals);
6961
7021
  })();
6962
7022
  }
@@ -8557,7 +8617,7 @@ var tool = toolFactory();
8557
8617
  var MAX_LIST_LIMIT = 200;
8558
8618
  var MAX_TRANSCRIPT_TURNS = 20;
8559
8619
  var manifest = defineManifest()({
8560
- contract: 1,
8620
+ contract: 2,
8561
8621
  identity: {
8562
8622
  accent: "#f43f5e",
8563
8623
  category: "voice",
@@ -8760,6 +8820,15 @@ var manifest = defineManifest()({
8760
8820
  tools: {
8761
8821
  delete_session: tool.runtime({
8762
8822
  annotations: { destructiveHint: true, idempotentHint: true },
8823
+ authorization: {
8824
+ approval: "policy",
8825
+ audience: "owner",
8826
+ effects: ["delete"],
8827
+ idempotency: { mode: "resource" },
8828
+ requiredScopes: ["voice:sessions:delete"],
8829
+ resource: { idField: "id", type: "voice-session" },
8830
+ reversible: false
8831
+ },
8763
8832
  description: "Delete one call session (its transcript and state) by id. Deleting an unknown id succeeds.",
8764
8833
  input: Type2.Object({ id: Type2.String({ minLength: 1 }) }),
8765
8834
  handler: async ({ id }, store) => {
@@ -8769,6 +8838,13 @@ var manifest = defineManifest()({
8769
8838
  }),
8770
8839
  get_session: tool.runtime({
8771
8840
  annotations: { readOnlyHint: true },
8841
+ authorization: {
8842
+ approval: "never",
8843
+ audience: "owner",
8844
+ effects: ["read"],
8845
+ requiredScopes: ["voice:sessions:read"],
8846
+ resource: { idField: "id", type: "voice-session" }
8847
+ },
8772
8848
  description: "Fetch one call session by id: status, timing, and the committed conversation turns (caller text and assistant reply), most recent last.",
8773
8849
  input: Type2.Object({
8774
8850
  id: Type2.String({ minLength: 1 }),
@@ -8796,6 +8872,12 @@ var manifest = defineManifest()({
8796
8872
  }),
8797
8873
  list_sessions: tool.runtime({
8798
8874
  annotations: { readOnlyHint: true },
8875
+ authorization: {
8876
+ approval: "never",
8877
+ audience: "owner",
8878
+ effects: ["read"],
8879
+ requiredScopes: ["voice:sessions:read"]
8880
+ },
8799
8881
  description: "List call sessions with status, creation time, last activity, and turn count \u2014 most recently active first.",
8800
8882
  input: Type2.Object({
8801
8883
  limit: Type2.Optional(Type2.Integer({ maximum: MAX_LIST_LIMIT, minimum: 1 }))
@@ -1,5 +1,5 @@
1
1
  {
2
- "contract": 1,
2
+ "contract": 2,
3
3
  "identity": {
4
4
  "accent": "#f43f5e",
5
5
  "category": "voice",
@@ -325,6 +325,24 @@
325
325
  "destructiveHint": true,
326
326
  "idempotentHint": true
327
327
  },
328
+ "authorization": {
329
+ "approval": "policy",
330
+ "audience": "owner",
331
+ "effects": [
332
+ "delete"
333
+ ],
334
+ "idempotency": {
335
+ "mode": "resource"
336
+ },
337
+ "requiredScopes": [
338
+ "voice:sessions:delete"
339
+ ],
340
+ "resource": {
341
+ "idField": "id",
342
+ "type": "voice-session"
343
+ },
344
+ "reversible": false
345
+ },
328
346
  "description": "Delete one call session (its transcript and state) by id. Deleting an unknown id succeeds.",
329
347
  "input": {
330
348
  "type": "object",
@@ -344,6 +362,20 @@
344
362
  "annotations": {
345
363
  "readOnlyHint": true
346
364
  },
365
+ "authorization": {
366
+ "approval": "never",
367
+ "audience": "owner",
368
+ "effects": [
369
+ "read"
370
+ ],
371
+ "requiredScopes": [
372
+ "voice:sessions:read"
373
+ ],
374
+ "resource": {
375
+ "idField": "id",
376
+ "type": "voice-session"
377
+ }
378
+ },
347
379
  "description": "Fetch one call session by id: status, timing, and the committed conversation turns (caller text and assistant reply), most recent last.",
348
380
  "input": {
349
381
  "type": "object",
@@ -368,6 +400,16 @@
368
400
  "annotations": {
369
401
  "readOnlyHint": true
370
402
  },
403
+ "authorization": {
404
+ "approval": "never",
405
+ "audience": "owner",
406
+ "effects": [
407
+ "read"
408
+ ],
409
+ "requiredScopes": [
410
+ "voice:sessions:read"
411
+ ]
412
+ },
371
413
  "description": "List call sessions with status, creation time, last activity, and turn count — most recently active first.",
372
414
  "input": {
373
415
  "type": "object",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@absolutejs/voice",
3
- "version": "0.0.22-beta.644",
3
+ "version": "0.0.22-beta.646",
4
4
  "description": "Voice primitives and Elysia plugin for AbsoluteJS",
5
5
  "repository": {
6
6
  "type": "git",
@@ -140,13 +140,13 @@
140
140
  }
141
141
  },
142
142
  "dependencies": {
143
- "@absolutejs/manifest": "^0.1.0",
143
+ "@absolutejs/manifest": "^0.4.0",
144
144
  "@absolutejs/media": "0.0.1-beta.19",
145
145
  "@sinclair/typebox": "^0.34.0"
146
146
  },
147
147
  "devDependencies": {
148
148
  "@absolutejs/absolute": "0.19.0-beta.1009",
149
- "@absolutejs/ai": "0.0.5",
149
+ "@absolutejs/ai": "0.0.46",
150
150
  "@angular/core": "^21.0.0",
151
151
  "@electric-sql/pglite": "^0.4.5",
152
152
  "@eslint/js": "^10.0.1",
@@ -169,6 +169,6 @@
169
169
  "vue": "3.5.27"
170
170
  },
171
171
  "absolutejs": {
172
- "manifestContract": 1
172
+ "manifestContract": 2
173
173
  }
174
174
  }