hci-atrium 0.1.0

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.
Files changed (163) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +182 -0
  3. package/dist/atrium.d.ts +522 -0
  4. package/dist/atrium.d.ts.map +1 -0
  5. package/dist/atrium.js +806 -0
  6. package/dist/atrium.js.map +1 -0
  7. package/dist/auth.d.ts +85 -0
  8. package/dist/auth.d.ts.map +1 -0
  9. package/dist/auth.js +369 -0
  10. package/dist/auth.js.map +1 -0
  11. package/dist/by.d.ts +84 -0
  12. package/dist/by.d.ts.map +1 -0
  13. package/dist/by.js +87 -0
  14. package/dist/by.js.map +1 -0
  15. package/dist/decider.d.ts +40 -0
  16. package/dist/decider.d.ts.map +1 -0
  17. package/dist/decider.js +76 -0
  18. package/dist/decider.js.map +1 -0
  19. package/dist/discovery.d.ts +15 -0
  20. package/dist/discovery.d.ts.map +1 -0
  21. package/dist/discovery.js +38 -0
  22. package/dist/discovery.js.map +1 -0
  23. package/dist/env.d.ts +11 -0
  24. package/dist/env.d.ts.map +1 -0
  25. package/dist/env.js +28 -0
  26. package/dist/env.js.map +1 -0
  27. package/dist/errors.d.ts +67 -0
  28. package/dist/errors.d.ts.map +1 -0
  29. package/dist/errors.js +86 -0
  30. package/dist/errors.js.map +1 -0
  31. package/dist/files.d.ts +7 -0
  32. package/dist/files.d.ts.map +1 -0
  33. package/dist/files.js +2 -0
  34. package/dist/files.js.map +1 -0
  35. package/dist/http.d.ts +11 -0
  36. package/dist/http.d.ts.map +1 -0
  37. package/dist/http.js +21 -0
  38. package/dist/http.js.map +1 -0
  39. package/dist/index.d.ts +17 -0
  40. package/dist/index.d.ts.map +1 -0
  41. package/dist/index.js +14 -0
  42. package/dist/index.js.map +1 -0
  43. package/dist/models.d.ts +456 -0
  44. package/dist/models.d.ts.map +1 -0
  45. package/dist/models.js +487 -0
  46. package/dist/models.js.map +1 -0
  47. package/dist/pkce.d.ts +16 -0
  48. package/dist/pkce.d.ts.map +1 -0
  49. package/dist/pkce.js +40 -0
  50. package/dist/pkce.js.map +1 -0
  51. package/dist/react/index.d.ts +37 -0
  52. package/dist/react/index.d.ts.map +1 -0
  53. package/dist/react/index.js +89 -0
  54. package/dist/react/index.js.map +1 -0
  55. package/dist/rooms/armed-set.d.ts +33 -0
  56. package/dist/rooms/armed-set.d.ts.map +1 -0
  57. package/dist/rooms/armed-set.js +65 -0
  58. package/dist/rooms/armed-set.js.map +1 -0
  59. package/dist/rooms/brokers.d.ts +62 -0
  60. package/dist/rooms/brokers.d.ts.map +1 -0
  61. package/dist/rooms/brokers.js +109 -0
  62. package/dist/rooms/brokers.js.map +1 -0
  63. package/dist/rooms/codec.d.ts +100 -0
  64. package/dist/rooms/codec.d.ts.map +1 -0
  65. package/dist/rooms/codec.js +101 -0
  66. package/dist/rooms/codec.js.map +1 -0
  67. package/dist/rooms/index.d.ts +40 -0
  68. package/dist/rooms/index.d.ts.map +1 -0
  69. package/dist/rooms/index.js +45 -0
  70. package/dist/rooms/index.js.map +1 -0
  71. package/dist/rooms/offer-capture.d.ts +96 -0
  72. package/dist/rooms/offer-capture.d.ts.map +1 -0
  73. package/dist/rooms/offer-capture.js +338 -0
  74. package/dist/rooms/offer-capture.js.map +1 -0
  75. package/dist/rooms/offer-transcription.d.ts +63 -0
  76. package/dist/rooms/offer-transcription.d.ts.map +1 -0
  77. package/dist/rooms/offer-transcription.js +231 -0
  78. package/dist/rooms/offer-transcription.js.map +1 -0
  79. package/dist/rooms/participant.d.ts +35 -0
  80. package/dist/rooms/participant.d.ts.map +1 -0
  81. package/dist/rooms/participant.js +53 -0
  82. package/dist/rooms/participant.js.map +1 -0
  83. package/dist/rooms/recorder.d.ts +74 -0
  84. package/dist/rooms/recorder.d.ts.map +1 -0
  85. package/dist/rooms/recorder.js +157 -0
  86. package/dist/rooms/recorder.js.map +1 -0
  87. package/dist/rooms/room.d.ts +542 -0
  88. package/dist/rooms/room.d.ts.map +1 -0
  89. package/dist/rooms/room.js +1357 -0
  90. package/dist/rooms/room.js.map +1 -0
  91. package/dist/rooms/snippet.d.ts +48 -0
  92. package/dist/rooms/snippet.d.ts.map +1 -0
  93. package/dist/rooms/snippet.js +70 -0
  94. package/dist/rooms/snippet.js.map +1 -0
  95. package/dist/rooms/sse.d.ts +102 -0
  96. package/dist/rooms/sse.d.ts.map +1 -0
  97. package/dist/rooms/sse.js +347 -0
  98. package/dist/rooms/sse.js.map +1 -0
  99. package/dist/rooms/standing-source.d.ts +190 -0
  100. package/dist/rooms/standing-source.d.ts.map +1 -0
  101. package/dist/rooms/standing-source.js +431 -0
  102. package/dist/rooms/standing-source.js.map +1 -0
  103. package/dist/rooms/transcriber.d.ts +81 -0
  104. package/dist/rooms/transcriber.d.ts.map +1 -0
  105. package/dist/rooms/transcriber.js +111 -0
  106. package/dist/rooms/transcriber.js.map +1 -0
  107. package/dist/rooms/transport-shared.d.ts +28 -0
  108. package/dist/rooms/transport-shared.d.ts.map +1 -0
  109. package/dist/rooms/transport-shared.js +42 -0
  110. package/dist/rooms/transport-shared.js.map +1 -0
  111. package/dist/rooms/transport.d.ts +161 -0
  112. package/dist/rooms/transport.d.ts.map +1 -0
  113. package/dist/rooms/transport.js +258 -0
  114. package/dist/rooms/transport.js.map +1 -0
  115. package/dist/shaping/assets.d.ts +42 -0
  116. package/dist/shaping/assets.d.ts.map +1 -0
  117. package/dist/shaping/assets.js +77 -0
  118. package/dist/shaping/assets.js.map +1 -0
  119. package/dist/shaping/chat.d.ts +39 -0
  120. package/dist/shaping/chat.d.ts.map +1 -0
  121. package/dist/shaping/chat.js +62 -0
  122. package/dist/shaping/chat.js.map +1 -0
  123. package/dist/shaping/index.d.ts +14 -0
  124. package/dist/shaping/index.d.ts.map +1 -0
  125. package/dist/shaping/index.js +13 -0
  126. package/dist/shaping/index.js.map +1 -0
  127. package/dist/shaping/library.d.ts +84 -0
  128. package/dist/shaping/library.d.ts.map +1 -0
  129. package/dist/shaping/library.js +288 -0
  130. package/dist/shaping/library.js.map +1 -0
  131. package/dist/shaping/request.d.ts +47 -0
  132. package/dist/shaping/request.d.ts.map +1 -0
  133. package/dist/shaping/request.js +25 -0
  134. package/dist/shaping/request.js.map +1 -0
  135. package/dist/shaping/rooms.d.ts +128 -0
  136. package/dist/shaping/rooms.d.ts.map +1 -0
  137. package/dist/shaping/rooms.js +330 -0
  138. package/dist/shaping/rooms.js.map +1 -0
  139. package/dist/shaping/sources.d.ts +29 -0
  140. package/dist/shaping/sources.d.ts.map +1 -0
  141. package/dist/shaping/sources.js +51 -0
  142. package/dist/shaping/sources.js.map +1 -0
  143. package/dist/shaping/structured.d.ts +47 -0
  144. package/dist/shaping/structured.d.ts.map +1 -0
  145. package/dist/shaping/structured.js +115 -0
  146. package/dist/shaping/structured.js.map +1 -0
  147. package/dist/storage.d.ts +36 -0
  148. package/dist/storage.d.ts.map +1 -0
  149. package/dist/storage.js +86 -0
  150. package/dist/storage.js.map +1 -0
  151. package/dist/transcribe-stream.d.ts +81 -0
  152. package/dist/transcribe-stream.d.ts.map +1 -0
  153. package/dist/transcribe-stream.js +253 -0
  154. package/dist/transcribe-stream.js.map +1 -0
  155. package/dist/transcribe.d.ts +57 -0
  156. package/dist/transcribe.d.ts.map +1 -0
  157. package/dist/transcribe.js +267 -0
  158. package/dist/transcribe.js.map +1 -0
  159. package/dist/types.d.ts +20 -0
  160. package/dist/types.d.ts.map +1 -0
  161. package/dist/types.js +3 -0
  162. package/dist/types.js.map +1 -0
  163. package/package.json +56 -0
package/dist/by.js ADDED
@@ -0,0 +1,87 @@
1
+ /**
2
+ * The ``by`` operand grammar — how ``searchByExamples`` (and, later, ``compare``) names a thing to
3
+ * embed. The TypeScript mirror of ``hci_atrium._operands``.
4
+ *
5
+ * Decision 9: no bare ``number[]`` heuristic. A raw vector is *always* explicit — ``by.vector([…])``
6
+ * — because a bare array is otherwise ambiguous (a few-shot list vs. a vector). Every operand is a
7
+ * member of a discriminated union keyed on ``kind``. ``by.text`` / ``by.asset`` disambiguate the
8
+ * two cases whose bare form clashes (a text string vs. an id string; a text string vs. a file);
9
+ * ``by.file`` / ``by.concept`` have no bare form.
10
+ *
11
+ * ```ts
12
+ * import { by } from "hci-atrium"
13
+ * client.library.searchByExamples([hit.asset, by.asset("uuid")])
14
+ * ```
15
+ */
16
+ import { InvalidArgumentError } from "./errors.js";
17
+ /** Explicit operand constructors. */
18
+ export const by = {
19
+ /** An existing library asset, by object or id. */
20
+ asset(asset) {
21
+ return { kind: "asset", assetId: typeof asset === "string" ? asset : asset.id };
22
+ },
23
+ /** A file to embed in-flight. Pass ``format`` (e.g. ``"wav"``) for raw bytes with no type. */
24
+ file(source, opts = {}) {
25
+ return { kind: "file", file: source, format: opts.format };
26
+ },
27
+ /** A text query (the explicit form of a bare string). */
28
+ text(text) {
29
+ return { kind: "text", text };
30
+ },
31
+ /** A raw embedding vector (the explicit form there is no bare form for). */
32
+ vector(vector) {
33
+ return { kind: "vector", vector: vector.map(Number) };
34
+ },
35
+ /** A tag's concept classifier, by name (scoped to ``collection``'s chain) or id. */
36
+ concept(nameOrId, opts = {}) {
37
+ return { kind: "concept", name: nameOrId, collection: opts.collection };
38
+ },
39
+ };
40
+ function isAsset(value) {
41
+ return typeof value === "object" && "id" in value && !("kind" in value);
42
+ }
43
+ /** Normalize a call-site value to an {@link Operand} using the bare-value rules. */
44
+ export function toOperand(value) {
45
+ if (typeof value === "string") {
46
+ return { kind: "text", text: value };
47
+ }
48
+ if (isAsset(value)) {
49
+ return { kind: "asset", assetId: value.id };
50
+ }
51
+ return value;
52
+ }
53
+ /** Whether a bare array is a raw vector (all plain finite numbers) rather than a few-shot list of
54
+ * anchor members — the same bare-value rule {@link toOperand} applies to a plain array. */
55
+ function isVector(value) {
56
+ return value.length === 0 || value.every((x) => typeof x === "number");
57
+ }
58
+ /**
59
+ * Resolve one ``audioScores`` anchor's value to its member {@link Operand}(s): a scalar is a
60
+ * single-member anchor; an array that *isn't* a raw vector is a few-shot category (each member
61
+ * resolved by the normal bare-value rules, so a nested ``number[]`` member is still a vector).
62
+ * Mirror of Python's ``to_anchor_members``.
63
+ */
64
+ export function toAnchorMembers(value) {
65
+ if (Array.isArray(value) && !isVector(value)) {
66
+ if (value.length === 0) {
67
+ throw new InvalidArgumentError("an anchor's few-shot list must not be empty");
68
+ }
69
+ return value.map(toOperand);
70
+ }
71
+ // A scalar or a raw vector (``number[]``), both an OperandLike.
72
+ return [toOperand(value)];
73
+ }
74
+ /**
75
+ * Resolve a ``searchByExamples`` seed to an asset id. v1 seeds are assets only — an {@link Asset}
76
+ * object or ``by.asset(id)``. A bare string is a *text* query in the grammar (not a valid seed
77
+ * yet), so it is rejected with a pointer to ``by.asset(...)``.
78
+ */
79
+ export function seedAssetId(value) {
80
+ const op = toOperand(value);
81
+ if (op.kind !== "asset") {
82
+ throw new InvalidArgumentError("searchByExamples seeds must be assets — pass an Asset object or by.asset(id) " +
83
+ `(got a ${op.kind} operand)`);
84
+ }
85
+ return op.assetId;
86
+ }
87
+ //# sourceMappingURL=by.js.map
package/dist/by.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"by.js","sourceRoot":"","sources":["../src/by.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AA8ClD,qCAAqC;AACrC,MAAM,CAAC,MAAM,EAAE,GAAG;IAChB,kDAAkD;IAClD,KAAK,CAAC,KAAqB;QACzB,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,CAAA;IACjF,CAAC;IACD,8FAA8F;IAC9F,IAAI,CAAC,MAAkB,EAAE,OAA4B,EAAE;QACrD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,C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M,UAAU,eAAe,CAAC,KAAiB;IAC/C,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QAC7C,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACvB,MAAM,IAAI,oBAAoB,CAAC,6CAA6C,CAAC,CAAA;QAC/E,CAAC;QACD,OAAQ,KAAuB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;IAChD,CAAC;IACD,gEAAgE;IAChE,OAAO,CAAC,SAAS,CAAC,KAAoB,CAAC,CAAC,CAAA;AAC1C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,KAAkB;IAC5C,MAAM,EAAE,GAAG,SAAS,CAAC,KAAK,CAAC,CAAA;IAC3B,IAAI,EAAE,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QACxB,MAAM,IAAI,oBAAoB,CAC5B,+EAA+E;YAC7E,UAAU,EAAE,CAAC,IAAI,WAAW,CAC/B,CAAA;IACH,CAAC;IACD,OAAO,EAAE,CAAC,OAAO,CAAA;AACnB,CAAC"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Reactive helpers — a small, framework-free stateful policy over a live score stream (e.g. the
3
+ * per-anchor scores a soundscape derives each frame). No transport dependency; pure and easy to
4
+ * unit-test. A line-for-line port of ``hci_atrium.reactive`` (Python SDK).
5
+ */
6
+ /**
7
+ * N-way winner selection with hysteresis over a live ``Record<string, number>`` score stream.
8
+ *
9
+ * A new winner must beat the current one by ``margin`` **and** at least ``dwell`` seconds must have
10
+ * passed since the last switch, or nothing changes. Call {@link update} once per frame; it returns
11
+ * the new winner's name only on an actual change — every call that keeps the same winner returns
12
+ * ``null``. The first call always fires (there's no current winner to beat yet). With two anchors
13
+ * this degrades to a plain binary hysteresis switch — the same margin/dwell rule *is* that switch.
14
+ *
15
+ * ``Decider`` only decides *when* to switch, not what the incoming scores mean — no smoothing here;
16
+ * ease/debounce the stream upstream if you want that (EMA is caller policy, not SDK).
17
+ *
18
+ * With a single anchor there's nothing to switch *to*: the first call still fires (returning that
19
+ * one name), but every call after it returns ``null`` forever (``null`` means "no change", and the
20
+ * lone anchor can never stop being the winner).
21
+ */
22
+ export declare class Decider {
23
+ readonly margin: number;
24
+ readonly dwell: number;
25
+ private currentWinner;
26
+ private switchedAt;
27
+ constructor(opts?: {
28
+ margin?: number;
29
+ dwell?: number;
30
+ });
31
+ /** The current winner (``null`` before the first {@link update}). */
32
+ get current(): string | null;
33
+ /**
34
+ * Feed one frame of named scores. Returns the new winner's name when the current one changes,
35
+ * else ``null``. ``now`` overrides the clock (monotonic seconds by default) — mainly for
36
+ * deterministic tests.
37
+ */
38
+ update(scores: Record<string, number>, now?: number): string | null;
39
+ }
40
+ //# sourceMappingURL=decider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decider.d.ts","sourceRoot":"","sources":["../src/decider.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,OAAO;IAClB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,OAAO,CAAC,aAAa,CAAsB;IAC3C,OAAO,CAAC,UAAU,CAAsB;gBAE5B,IAAI,GAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAO;IAK1D,qEAAqE;IACrE,IAAI,OAAO,IAAI,MAAM,GAAG,IAAI,CAE3B;IAED;;;;OAIG;IACH,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;CA0BpE"}
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Reactive helpers — a small, framework-free stateful policy over a live score stream (e.g. the
3
+ * per-anchor scores a soundscape derives each frame). No transport dependency; pure and easy to
4
+ * unit-test. A line-for-line port of ``hci_atrium.reactive`` (Python SDK).
5
+ */
6
+ /** Monotonic seconds — ``performance.now()`` where available, else the wall clock. */
7
+ function monotonicSeconds() {
8
+ const perf = globalThis.performance;
9
+ return (perf ? perf.now() : Date.now()) / 1000;
10
+ }
11
+ /**
12
+ * N-way winner selection with hysteresis over a live ``Record<string, number>`` score stream.
13
+ *
14
+ * A new winner must beat the current one by ``margin`` **and** at least ``dwell`` seconds must have
15
+ * passed since the last switch, or nothing changes. Call {@link update} once per frame; it returns
16
+ * the new winner's name only on an actual change — every call that keeps the same winner returns
17
+ * ``null``. The first call always fires (there's no current winner to beat yet). With two anchors
18
+ * this degrades to a plain binary hysteresis switch — the same margin/dwell rule *is* that switch.
19
+ *
20
+ * ``Decider`` only decides *when* to switch, not what the incoming scores mean — no smoothing here;
21
+ * ease/debounce the stream upstream if you want that (EMA is caller policy, not SDK).
22
+ *
23
+ * With a single anchor there's nothing to switch *to*: the first call still fires (returning that
24
+ * one name), but every call after it returns ``null`` forever (``null`` means "no change", and the
25
+ * lone anchor can never stop being the winner).
26
+ */
27
+ export class Decider {
28
+ margin;
29
+ dwell;
30
+ currentWinner = null;
31
+ switchedAt = null;
32
+ constructor(opts = {}) {
33
+ this.margin = opts.margin ?? 0.1;
34
+ this.dwell = opts.dwell ?? 0.0;
35
+ }
36
+ /** The current winner (``null`` before the first {@link update}). */
37
+ get current() {
38
+ return this.currentWinner;
39
+ }
40
+ /**
41
+ * Feed one frame of named scores. Returns the new winner's name when the current one changes,
42
+ * else ``null``. ``now`` overrides the clock (monotonic seconds by default) — mainly for
43
+ * deterministic tests.
44
+ */
45
+ update(scores, now) {
46
+ const names = Object.keys(scores);
47
+ if (names.length === 0)
48
+ return null;
49
+ const moment = now ?? monotonicSeconds();
50
+ let best = names[0];
51
+ let bestScore = scores[best];
52
+ for (const name of names) {
53
+ const s = scores[name];
54
+ if (s > bestScore) {
55
+ best = name;
56
+ bestScore = s;
57
+ }
58
+ }
59
+ if (this.currentWinner === null) {
60
+ this.currentWinner = best;
61
+ this.switchedAt = moment;
62
+ return best;
63
+ }
64
+ if (best === this.currentWinner)
65
+ return null;
66
+ if (this.switchedAt !== null && moment - this.switchedAt < this.dwell)
67
+ return null;
68
+ const currentScore = scores[this.currentWinner] ?? Number.NEGATIVE_INFINITY;
69
+ if (bestScore - currentScore < this.margin)
70
+ return null;
71
+ this.currentWinner = best;
72
+ this.switchedAt = moment;
73
+ return best;
74
+ }
75
+ }
76
+ //# sourceMappingURL=decider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decider.js","sourceRoot":"","sources":["../src/decider.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,sFAAsF;AACtF,SAAS,gBAAgB;IACvB,MAAM,IAAI,GAAI,UAAkD,CAAC,WAAW,CAAA;IAC5E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,GAAG,IAAI,CAAA;AAChD,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAO,OAAO;IACT,MAAM,CAAQ;IACd,KAAK,CAAQ;IACd,aAAa,GAAkB,IAAI,CAAA;IACnC,UAAU,GAAkB,IAAI,CAAA;IAExC,YAAY,OAA4C,EAAE;QACxD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,GAAG,CAAA;QAChC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,GAAG,CAAA;IAChC,CAAC;IAED,qEAAqE;IACrE,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,aAAa,CAAA;IAC3B,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,MAA8B,EAAE,GAAY;QACjD,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QACjC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,IAAI,CAAA;QACnC,MAAM,MAAM,GAAG,GAAG,IAAI,gBAAgB,EAAE,CAAA;QACxC,IAAI,IAAI,GAAG,KAAK,CAAC,CAAC,CAAW,CAAA;QAC7B,IAAI,SAAS,GAAG,MAAM,CAAC,IAAI,CAAW,CAAA;QACtC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,MAAM,CAAC,GAAG,MAAM,CAAC,IAAI,CAAW,CAAA;YAChC,IAAI,CAAC,GAAG,SAAS,EAAE,CAAC;gBAClB,IAAI,GAAG,IAAI,CAAA;gBACX,SAAS,GAAG,CAAC,CAAA;YACf,CAAC;QACH,CAAC;QACD,IAAI,IAAI,CAAC,aAAa,KAAK,IAAI,EAAE,CAAC;YAChC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAA;YACzB,IAAI,CAAC,UAAU,GAAG,MAAM,CAAA;YACxB,OAAO,IAAI,CAAA;QACb,CAAC;QACD,IAAI,IAAI,KAAK,IAAI,CAAC,aAAa;YAAE,OAAO,IAAI,CAAA;QAC5C,IAAI,IAAI,CAAC,UAAU,KAAK,IAAI,IAAI,MAAM,GAAG,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,KAAK;YAAE,OAAO,IAAI,CAAA;QAClF,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,MAAM,CAAC,iBAAiB,CAAA;QAC3E,IAAI,SAAS,GAAG,YAAY,GAAG,IAAI,CAAC,MAAM;YAAE,OAAO,IAAI,CAAA;QACvD,IAAI,CAAC,aAAa,GAAG,IAAI,CAAA;QACzB,IAAI,CAAC,UAAU,GAAG,MAAM,CAAA;QACxB,OAAO,IAAI,CAAA;IACb,CAAC;CACF"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Authorization-server endpoint discovery (RFC 8414).
3
+ *
4
+ * The SDK resolves the authorize/token/revoke endpoints from
5
+ * ``{baseUrl}/.well-known/oauth-authorization-server`` and falls back to Atrium's conventional
6
+ * paths when discovery is unreachable or incomplete.
7
+ */
8
+ export interface Endpoints {
9
+ authorization: string;
10
+ token: string;
11
+ revocation: string;
12
+ }
13
+ /** Resolve the OAuth endpoints for ``baseUrl``, falling back to the conventional paths. */
14
+ export declare function discoverEndpoints(baseUrl: string): Promise<Endpoints>;
15
+ //# sourceMappingURL=discovery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,MAAM,WAAW,SAAS;IACxB,aAAa,EAAE,MAAM,CAAA;IACrB,KAAK,EAAE,MAAM,CAAA;IACb,UAAU,EAAE,MAAM,CAAA;CACnB;AAcD,2FAA2F;AAC3F,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAgB3E"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Authorization-server endpoint discovery (RFC 8414).
3
+ *
4
+ * The SDK resolves the authorize/token/revoke endpoints from
5
+ * ``{baseUrl}/.well-known/oauth-authorization-server`` and falls back to Atrium's conventional
6
+ * paths when discovery is unreachable or incomplete.
7
+ */
8
+ import { httpFetch } from "./http.js";
9
+ function conventional(baseUrl) {
10
+ return {
11
+ authorization: `${baseUrl}/oauth/authorize`,
12
+ token: `${baseUrl}/oauth/token`,
13
+ revocation: `${baseUrl}/oauth/revoke`,
14
+ };
15
+ }
16
+ function pick(value, fallback) {
17
+ return typeof value === "string" && value.length > 0 ? value : fallback;
18
+ }
19
+ /** Resolve the OAuth endpoints for ``baseUrl``, falling back to the conventional paths. */
20
+ export async function discoverEndpoints(baseUrl) {
21
+ const fallback = conventional(baseUrl);
22
+ try {
23
+ const res = await httpFetch(`${baseUrl}/.well-known/oauth-authorization-server`);
24
+ if (!res.ok) {
25
+ return fallback;
26
+ }
27
+ const doc = (await res.json());
28
+ return {
29
+ authorization: pick(doc.authorization_endpoint, fallback.authorization),
30
+ token: pick(doc.token_endpoint, fallback.token),
31
+ revocation: pick(doc.revocation_endpoint, fallback.revocation),
32
+ };
33
+ }
34
+ catch {
35
+ return fallback;
36
+ }
37
+ }
38
+ //# sourceMappingURL=discovery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discovery.js","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAQrC,SAAS,YAAY,CAAC,OAAe;IACnC,OAAO;QACL,aAAa,EAAE,GAAG,OAAO,kBAAkB;QAC3C,KAAK,EAAE,GAAG,OAAO,cAAc;QAC/B,UAAU,EAAE,GAAG,OAAO,eAAe;KACtC,CAAA;AACH,CAAC;AAED,SAAS,IAAI,CAAC,KAAc,EAAE,QAAgB;IAC5C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAA;AACzE,CAAC;AAED,2FAA2F;AAC3F,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,OAAe;IACrD,MAAM,QAAQ,GAAG,YAAY,CAAC,OAAO,CAAC,CAAA;IACtC,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,SAAS,CAAC,GAAG,OAAO,yCAAyC,CAAC,CAAA;QAChF,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;YACZ,OAAO,QAAQ,CAAA;QACjB,CAAC;QACD,MAAM,GAAG,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAA4B,CAAA;QACzD,OAAO;YACL,aAAa,EAAE,IAAI,CAAC,GAAG,CAAC,sBAAsB,EAAE,QAAQ,CAAC,aAAa,CAAC;YACvE,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,cAAc,EAAE,QAAQ,CAAC,KAAK,CAAC;YAC/C,UAAU,EAAE,IAAI,CAAC,GAAG,CAAC,mBAAmB,EAAE,QAAQ,CAAC,UAAU,CAAC;SAC/D,CAAA;IACH,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,QAAQ,CAAA;IACjB,CAAC;AACH,CAAC"}
package/dist/env.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ /** Best-effort, guarded reads of build-time / runtime environment variables. */
2
+ /** The deployed instance — the default when neither an explicit ``baseUrl`` nor
3
+ * ``ATRIUM_BASE_URL`` is set (mirrors the Python SDK's ``DEFAULT_BASE_URL``). */
4
+ export declare const DEFAULT_BASE_URL = "https://atrium.hci.rwth-aachen.de";
5
+ /**
6
+ * Read ``key`` from ``import.meta.env`` (Vite/bundlers) then ``process.env`` (Node), returning
7
+ * ``undefined`` if neither has it. Both lookups are guarded so importing the SDK never throws in an
8
+ * environment that lacks one of them.
9
+ */
10
+ export declare function readEnv(key: string): string | undefined;
11
+ //# sourceMappingURL=env.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAEhF;iFACiF;AACjF,eAAO,MAAM,gBAAgB,sCAAsC,CAAA;AAEnE;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAevD"}
package/dist/env.js ADDED
@@ -0,0 +1,28 @@
1
+ /** Best-effort, guarded reads of build-time / runtime environment variables. */
2
+ /** The deployed instance — the default when neither an explicit ``baseUrl`` nor
3
+ * ``ATRIUM_BASE_URL`` is set (mirrors the Python SDK's ``DEFAULT_BASE_URL``). */
4
+ export const DEFAULT_BASE_URL = "https://atrium.hci.rwth-aachen.de";
5
+ /**
6
+ * Read ``key`` from ``import.meta.env`` (Vite/bundlers) then ``process.env`` (Node), returning
7
+ * ``undefined`` if neither has it. Both lookups are guarded so importing the SDK never throws in an
8
+ * environment that lacks one of them.
9
+ */
10
+ export function readEnv(key) {
11
+ let value;
12
+ try {
13
+ value = import.meta.env?.[key];
14
+ }
15
+ catch {
16
+ // ``import.meta.env`` is not defined outside a bundler — fall through to process.env.
17
+ }
18
+ if (value == null) {
19
+ try {
20
+ value = globalThis.process?.env?.[key];
21
+ }
22
+ catch {
23
+ // No ``process`` in this environment.
24
+ }
25
+ }
26
+ return value == null ? undefined : String(value);
27
+ }
28
+ //# sourceMappingURL=env.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env.js","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAEhF;iFACiF;AACjF,MAAM,CAAC,MAAM,gBAAgB,GAAG,mCAAmC,CAAA;AAEnE;;;;GAIG;AACH,MAAM,UAAU,OAAO,CAAC,GAAW;IACjC,IAAI,KAAc,CAAA;IAClB,IAAI,CAAC;QACH,KAAK,GAAI,MAAM,CAAC,IAAqD,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAA;IAClF,CAAC;IAAC,MAAM,CAAC;QACP,sFAAsF;IACxF,CAAC;IACD,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;QAClB,IAAI,CAAC;YACH,KAAK,GAAI,UAA8D,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAA;QAC7F,CAAC;QAAC,MAAM,CAAC;YACP,sCAAsC;QACxC,CAAC;IACH,CAAC;IACD,OAAO,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AAClD,CAAC"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Exception hierarchy for the Atrium SDK — the TypeScript mirror of ``hci_atrium.errors``.
3
+ *
4
+ * Everything the SDK throws derives from {@link AtriumError}, so one ``catch`` covers the whole
5
+ * surface. Two conventions to know:
6
+ *
7
+ * - **HTTP failures** surface as {@link APIError} (or its {@link AuthError} /
8
+ * {@link TransientAuthError} subclasses), carrying the status, response detail, and request id.
9
+ * - **Bad arguments** (the Python ``ValueError`` / ``TypeError`` cases in the shaping and operand
10
+ * layers — mutually-exclusive inputs, an unsupported filter, an un-coercible operand) surface as
11
+ * {@link InvalidArgumentError}. This is the single, documented convention for caller mistakes; we
12
+ * do not reach for the platform ``TypeError`` / ``RangeError`` so that every SDK throw stays
13
+ * catchable under ``AtriumError``.
14
+ */
15
+ /** Base class for every error the SDK raises. */
16
+ export declare class AtriumError extends Error {
17
+ constructor(message: string);
18
+ }
19
+ /** A caller-side mistake — the analog of Python's ``ValueError`` / ``TypeError`` at the API edge. */
20
+ export declare class InvalidArgumentError extends AtriumError {
21
+ }
22
+ /**
23
+ * The Atrium API returned a non-2xx response.
24
+ *
25
+ * ``status`` is the HTTP status; ``detail`` is the (truncated) response body; ``requestId`` is the
26
+ * server's ``x-request-id`` when present, for correlating with server logs.
27
+ */
28
+ export declare class APIError extends AtriumError {
29
+ readonly status: number;
30
+ readonly detail: string;
31
+ readonly requestId?: string | undefined;
32
+ constructor(status: number, detail: string, requestId?: string | undefined);
33
+ }
34
+ /** Authentication failed — sign-in, token exchange, or refresh could not complete (401 / 403). */
35
+ export declare class AuthError extends APIError {
36
+ }
37
+ /**
38
+ * A token operation failed *transiently* (429, 5xx, or a network error), not permanently.
39
+ *
40
+ * Distinct from a plain {@link AuthError} (a genuinely revoked/expired credential): the credential
41
+ * may still be valid, so the right response is to retry — never to drop the user into an
42
+ * interactive sign-in. Derives from {@link AuthError} so existing ``catch (AuthError)`` handlers
43
+ * still catch it.
44
+ */
45
+ export declare class TransientAuthError extends AuthError {
46
+ }
47
+ /**
48
+ * A ``responseFormat`` (Zod schema) call could not produce schema-valid output.
49
+ *
50
+ * Thrown by ``chat`` when, even after one repair turn, the model's reply isn't valid JSON for the
51
+ * requested schema. The raw text and the validation detail are attached for debugging.
52
+ */
53
+ export declare class StructuredOutputError extends AtriumError {
54
+ readonly schema: string;
55
+ readonly raw: string;
56
+ readonly detail: string;
57
+ constructor(schema: string, raw: string, detail: string);
58
+ }
59
+ /**
60
+ * Raise for a non-ok {@link Response} on the general request path — a plain {@link APIError} for
61
+ * every status ``>= 400`` (mirror of Python's ``Atrium._request``, which raises ``APIError`` for
62
+ * everything). Auth-specific mapping ({@link AuthError} / {@link TransientAuthError}) lives only in
63
+ * the OAuth token flow (``auth.ts``), matching Python's split. Reads the body once for ``detail`` and
64
+ * keeps the server's ``x-request-id`` for log correlation.
65
+ */
66
+ export declare function raiseForStatus(res: Response): Promise<never>;
67
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,iDAAiD;AACjD,qBAAa,WAAY,SAAQ,KAAK;gBACxB,OAAO,EAAE,MAAM;CAM5B;AAED,qGAAqG;AACrG,qBAAa,oBAAqB,SAAQ,WAAW;CAAG;AAExD;;;;;GAKG;AACH,qBAAa,QAAS,SAAQ,WAAW;IAErC,QAAQ,CAAC,MAAM,EAAE,MAAM;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM;IACvB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM;gBAFlB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,SAAS,CAAC,EAAE,MAAM,YAAA;CAI9B;AAED,kGAAkG;AAClG,qBAAa,SAAU,SAAQ,QAAQ;CAAG;AAE1C;;;;;;;GAOG;AACH,qBAAa,kBAAmB,SAAQ,SAAS;CAAG;AAEpD;;;;;GAKG;AACH,qBAAa,qBAAsB,SAAQ,WAAW;IAElD,QAAQ,CAAC,MAAM,EAAE,MAAM;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM;IACpB,QAAQ,CAAC,MAAM,EAAE,MAAM;gBAFd,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM;CAI1B;AAED;;;;;;GAMG;AACH,wBAAsB,cAAc,CAAC,GAAG,EAAE,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC,CAIlE"}
package/dist/errors.js ADDED
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Exception hierarchy for the Atrium SDK — the TypeScript mirror of ``hci_atrium.errors``.
3
+ *
4
+ * Everything the SDK throws derives from {@link AtriumError}, so one ``catch`` covers the whole
5
+ * surface. Two conventions to know:
6
+ *
7
+ * - **HTTP failures** surface as {@link APIError} (or its {@link AuthError} /
8
+ * {@link TransientAuthError} subclasses), carrying the status, response detail, and request id.
9
+ * - **Bad arguments** (the Python ``ValueError`` / ``TypeError`` cases in the shaping and operand
10
+ * layers — mutually-exclusive inputs, an unsupported filter, an un-coercible operand) surface as
11
+ * {@link InvalidArgumentError}. This is the single, documented convention for caller mistakes; we
12
+ * do not reach for the platform ``TypeError`` / ``RangeError`` so that every SDK throw stays
13
+ * catchable under ``AtriumError``.
14
+ */
15
+ /** Base class for every error the SDK raises. */
16
+ export class AtriumError extends Error {
17
+ constructor(message) {
18
+ super(message);
19
+ this.name = new.target.name;
20
+ // Restore the prototype chain across the ES5 target so ``instanceof`` works.
21
+ Object.setPrototypeOf(this, new.target.prototype);
22
+ }
23
+ }
24
+ /** A caller-side mistake — the analog of Python's ``ValueError`` / ``TypeError`` at the API edge. */
25
+ export class InvalidArgumentError extends AtriumError {
26
+ }
27
+ /**
28
+ * The Atrium API returned a non-2xx response.
29
+ *
30
+ * ``status`` is the HTTP status; ``detail`` is the (truncated) response body; ``requestId`` is the
31
+ * server's ``x-request-id`` when present, for correlating with server logs.
32
+ */
33
+ export class APIError extends AtriumError {
34
+ status;
35
+ detail;
36
+ requestId;
37
+ constructor(status, detail, requestId) {
38
+ super(`HTTP ${status}: ${detail.slice(0, 500)}`);
39
+ this.status = status;
40
+ this.detail = detail;
41
+ this.requestId = requestId;
42
+ }
43
+ }
44
+ /** Authentication failed — sign-in, token exchange, or refresh could not complete (401 / 403). */
45
+ export class AuthError extends APIError {
46
+ }
47
+ /**
48
+ * A token operation failed *transiently* (429, 5xx, or a network error), not permanently.
49
+ *
50
+ * Distinct from a plain {@link AuthError} (a genuinely revoked/expired credential): the credential
51
+ * may still be valid, so the right response is to retry — never to drop the user into an
52
+ * interactive sign-in. Derives from {@link AuthError} so existing ``catch (AuthError)`` handlers
53
+ * still catch it.
54
+ */
55
+ export class TransientAuthError extends AuthError {
56
+ }
57
+ /**
58
+ * A ``responseFormat`` (Zod schema) call could not produce schema-valid output.
59
+ *
60
+ * Thrown by ``chat`` when, even after one repair turn, the model's reply isn't valid JSON for the
61
+ * requested schema. The raw text and the validation detail are attached for debugging.
62
+ */
63
+ export class StructuredOutputError extends AtriumError {
64
+ schema;
65
+ raw;
66
+ detail;
67
+ constructor(schema, raw, detail) {
68
+ super(`output did not match schema ${schema}: ${detail}`);
69
+ this.schema = schema;
70
+ this.raw = raw;
71
+ this.detail = detail;
72
+ }
73
+ }
74
+ /**
75
+ * Raise for a non-ok {@link Response} on the general request path — a plain {@link APIError} for
76
+ * every status ``>= 400`` (mirror of Python's ``Atrium._request``, which raises ``APIError`` for
77
+ * everything). Auth-specific mapping ({@link AuthError} / {@link TransientAuthError}) lives only in
78
+ * the OAuth token flow (``auth.ts``), matching Python's split. Reads the body once for ``detail`` and
79
+ * keeps the server's ``x-request-id`` for log correlation.
80
+ */
81
+ export async function raiseForStatus(res) {
82
+ const detail = await res.text().catch(() => "");
83
+ const requestId = res.headers.get("x-request-id") ?? undefined;
84
+ throw new APIError(res.status, detail, requestId);
85
+ }
86
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,iDAAiD;AACjD,MAAM,OAAO,WAAY,SAAQ,KAAK;IACpC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAA;QAC3B,6EAA6E;QAC7E,MAAM,CAAC,cAAc,CAAC,IA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0 +1,7 @@
1
+ /**
2
+ * File inputs stay browser-safe (decision 10): a ``Blob`` / ``File`` (in-memory bytes) or a URL
3
+ * string. No filesystem paths in core — a Node caller wraps a Buffer in a ``Blob``. Turning a URL
4
+ * string into bytes is I/O, so it happens in the client's request layer, never in shaping.
5
+ */
6
+ export type FileSource = Blob | string;
7
+ //# sourceMappingURL=files.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../src/files.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,MAAM,CAAA"}
package/dist/files.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=files.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files.js","sourceRoot":"","sources":["../src/files.ts"],"names":[],"mappings":""}
package/dist/http.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ /** Environment-guarded primitives shared across the SDK. */
2
+ /**
3
+ * Call the global ``fetch`` at request time (not import time), so importing the package in an
4
+ * environment without ``fetch`` never throws — only actually making a request does.
5
+ */
6
+ export declare function httpFetch(input: string, init?: RequestInit): Promise<Response>;
7
+ /** True when running in a DOM environment (a real browser or jsdom). */
8
+ export declare function isBrowser(): boolean;
9
+ /** Coerce an unknown thrown value into an ``Error``. */
10
+ export declare function asError(err: unknown): Error;
11
+ //# sourceMappingURL=http.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAE5D;;;GAGG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,CAM9E;AAED,wEAAwE;AACxE,wBAAgB,SAAS,IAAI,OAAO,CAEnC;AAED,wDAAwD;AACxD,wBAAgB,OAAO,CAAC,GAAG,EAAE,OAAO,GAAG,KAAK,CAE3C"}
package/dist/http.js ADDED
@@ -0,0 +1,21 @@
1
+ /** Environment-guarded primitives shared across the SDK. */
2
+ /**
3
+ * Call the global ``fetch`` at request time (not import time), so importing the package in an
4
+ * environment without ``fetch`` never throws — only actually making a request does.
5
+ */
6
+ export function httpFetch(input, init) {
7
+ const f = globalThis.fetch;
8
+ if (!f) {
9
+ throw new Error("Atrium: global fetch is unavailable in this environment");
10
+ }
11
+ return f(input, init);
12
+ }
13
+ /** True when running in a DOM environment (a real browser or jsdom). */
14
+ export function isBrowser() {
15
+ return typeof window !== "undefined" && typeof window.document !== "undefined";
16
+ }
17
+ /** Coerce an unknown thrown value into an ``Error``. */
18
+ export function asError(err) {
19
+ return err instanceof Error ? err : new Error(String(err));
20
+ }
21
+ //# sourceMappingURL=http.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAE5D;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,KAAa,EAAE,IAAkB;IACzD,MAAM,CAAC,GAAI,UAAuC,CAAC,KAAK,CAAA;IACxD,IAAI,CAAC,CAAC,EAAE,CAAC;QACP,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAA;IAC5E,CAAC;IACD,OAAO,CAAC,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;AACvB,CAAC;AAED,wEAAwE;AACxE,MAAM,UAAU,SAAS;IACvB,OAAO,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,MAAM,CAAC,QAAQ,KAAK,WAAW,CAAA;AAChF,CAAC;AAED,wDAAwD;AACxD,MAAM,UAAU,OAAO,CAAC,GAAY;IAClC,OAAO,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAA;AAC5D,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * ``hci-atrium`` — the Atrium TypeScript SDK.
3
+ *
4
+ * The default entry exposes the framework-agnostic core. React bindings live at the
5
+ * ``hci-atrium/react`` subpath so importing this entry never pulls in React.
6
+ */
7
+ export { type AssetListOptions, Assets, Atrium, type AtriumOptions, type ChatOptions, type CompareOptions, DEFAULT_BASE_URL, type EmbedOptions, type EnrichOptions, Library, type LibraryVectorsOptions, type LiveRoomOptions, type RoomOpenOptions, Rooms, type SearchByExamplesOptions, type SearchOptions, type SessionEventOptions, type SessionEventsOptions, type SessionExportFormat, type SessionListOptions, type SessionStartOptions, Sessions, type SourceImportOptions, Sources, type SourcesSearchOptions, type TagOptions, type TranscribeLiveOptions, type TranscribeOptions, type UploadOptions, } from "./atrium.js";
8
+ export type { ChangeListener, ErrorListener, SignInOptions } from "./auth.js";
9
+ export { Auth } from "./auth.js";
10
+ export { type AnchorLike, type AssetOperand, by, type ConceptOperand, type FileOperand, type Operand, type OperandLike, type TextOperand, toAnchorMembers, type VectorOperand, } from "./by.js";
11
+ export { Decider } from "./decider.js";
12
+ export { APIError, AtriumError, AuthError, InvalidArgumentError, StructuredOutputError, TransientAuthError, } from "./errors.js";
13
+ export type { FileSource } from "./files.js";
14
+ export { Asset, type AssetBinder, type AssetPage, type AssetRef, type AssetVector, type AssetVectorsOptions, assetCapabilities, assetPlayback, type Candidate, type ChatReply, type CompareFeature, type CompareResult, type Event, type Filters, type IndexEntry, type OperandInfo, type RoomInfo, type SearchByExamplesHit, type SearchHit, type SegmentRef, type Session, type SessionEvent, type SessionInfo, type SourceInfo, type SourceSearchResult, type SourceSkip, type Space, type TagDefinition, type TagSnapshot, type TagSnapshotFeature, type Transcript, type User, } from "./models.js";
15
+ export { type ActiveSource, ArmedSet, AUDIO_ROLE, AUDIO_SIGNAL, AUDIO_SNIPPET_CONSUMER_ROLE, AUDIO_SNIPPET_MAGIC, AUDIO_SNIPPET_SOURCE_ROLE, AUDIO_SNIPPET_VERSION, AUDIO_SNIPPET_VERSION_2, type AudioAnnounce, type AudioBeatEvent, type AudioClip, type AudioFrame, type AudioInputKind, type AudioSignal, type AudioSnippetFrame, type AudioTrack, type AudioVector, BrokerError, CAPTURE_OFFER_ROLE, CAPTURE_SOURCE_ROLE, type CaptureOfferDeps, type CaptureRecorder, CHAT_BROKER_ROLE, DEFAULT_CHAT_MAX_TOKENS, DEFAULT_MAX_ANCHORS, decodeAudioFrame, decodeAudioSnippetFrame, EMBED_BROKER_ROLE, encodeAudioFrame, type FetchImpl, type Handler, isAudioFrame, isAudioSnippetFrame, type JoinRoomOptions, joinRoom, OFFER_MAX_SOURCES, type OfferDeps, OfferedCapture, OfferedTranscription, type Participant, type ParticipantPredicate, Recorder, type RecorderStopReason, Room, type RoomAudioClient, type RoomDeps, type RoomEndReason, type RoomEvent, RoomEventStream, type RoomSignal, type RoomTransport, type RoomTransportMode, type RosterEntry, type ScoredAudio, StandingSource, TRANSCRIBER_SOURCE, TRANSCRIPTION_OFFER_ROLE, Transcriber, type TranscriberDeps, type TranscriptionOfferDeps, validateChatMessages, type WebSocketCtor, type WebSocketLike, } from "./rooms/index.js";
16
+ export type { AudioChunk } from "./transcribe.js";
17
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,KAAK,gBAAgB,EACrB,MAAM,EACN,MAAM,EACN,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,cAAc,EACnB,gBAAgB,EAChB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,OAAO,EACP,KAAK,qBAAqB,EAC1B,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,EACL,KAAK,uBAAuB,EAC5B,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,QAAQ,EACR,KAAK,mBAA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,GACV,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,KAAK,YAAY,EACjB,QAAQ,EACR,UAAU,EACV,YAAY,EACZ,2BAA2B,EAC3B,mBAAmB,EACnB,yBAAyB,EACzB,qBAAqB,EACrB,uBAAuB,EACvB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,WAAW,EACX,kBAAkB,EAClB,mBAAmB,EACnB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,gBAAgB,EAChB,uBAAuB,EACvB,mBAAmB,EACnB,gBAAgB,EAChB,uBAAuB,EACvB,iBAAiB,EACjB,gBAAgB,EAChB,KAAK,SAAS,EACd,KAAK,OAAO,EACZ,YAAY,EACZ,mBAAmB,EACnB,KAAK,eAAe,EACpB,QAAQ,EACR,iBAAiB,EACjB,KAAK,SAAS,EACd,cAAc,EACd,oBAAoB,EACpB,KAAK,WAAW,EAChB,KAAK,oBAAoB,EACzB,QAAQ,EACR,KAAK,kBAAkB,EACvB,IAAI,EACJ,KAAK,eAAe,EACpB,KAAK,QAAQ,EACb,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,eAAe,EACf,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,cAAc,EACd,kBAAkB,EAClB,wBAAwB,EACxB,WAAW,EACX,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,oBAAoB,EACpB,KAAK,aAAa,EAClB,KAAK,aAAa,GACnB,MAAM,kBAAkB,CAAA;AACzB,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,14 @@
1
+ /**
2
+ * ``hci-atrium`` — the Atrium TypeScript SDK.
3
+ *
4
+ * The default entry exposes the framework-agnostic core. React bindings live at the
5
+ * ``hci-atrium/react`` subpath so importing this entry never pulls in React.
6
+ */
7
+ export { Assets, Atrium, DEFAULT_BASE_URL, Library, Rooms, Sessions, Sources, } from "./atrium.js";
8
+ export { Auth } from "./auth.js";
9
+ export { by, toAnchorMembers, } from "./by.js";
10
+ export { Decider } from "./decider.js";
11
+ export { APIError, AtriumError, AuthError, InvalidArgumentError, StructuredOutputError, TransientAuthError, } from "./errors.js";
12
+ export { Asset, assetCapabilities, assetPlayback, } from "./models.js";
13
+ export { ArmedSet, AUDIO_ROLE, AUDIO_SIGNAL, AUDIO_SNIPPET_CONSUMER_ROLE, AUDIO_SNIPPET_MAGIC, AUDIO_SNIPPET_SOURCE_ROLE, AUDIO_SNIPPET_VERSION, AUDIO_SNIPPET_VERSION_2, BrokerError, CAPTURE_OFFER_ROLE, CAPTURE_SOURCE_ROLE, CHAT_BROKER_ROLE, DEFAULT_CHAT_MAX_TOKENS, DEFAULT_MAX_ANCHORS, decodeAudioFrame, decodeAudioSnippetFrame, EMBED_BROKER_ROLE, encodeAudioFrame, isAudioFrame, isAudioSnippetFrame, joinRoom, OFFER_MAX_SOURCES, OfferedCapture, OfferedTranscription, Recorder, Room, RoomEventStream, StandingSource, TRANSCRIBER_SOURCE, TRANSCRIPTION_OFFER_ROLE, Transcriber, validateChatMessages, } from "./rooms/index.js";
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAEL,MAAM,EACN,MAAM,EAIN,gBAAgB,EAGhB,OAAO,EAIP,KAAK,EAQL,QAAQ,EAER,OAAO,GAMR,MAAM,aAAa,CAAA;AAEpB,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAGL,EAAE,EAMF,eAAe,GAEhB,MAAM,SAAS,CAAA;AAChB,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EACL,QAAQ,EACR,WAAW,EACX,SAAS,EACT,oBAAoB,EACpB,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,aAAa,CAAA;AAEpB,OAAO,EACL,KAAK,EAML,iBAAiB,EACjB,aAAa,GAyBd,MAAM,aAAa,CAAA;AACpB,OAAO,EAEL,QAAQ,EACR,UAAU,EACV,YAAY,EACZ,2BAA2B,EAC3B,mBAAmB,EACnB,yBAAyB,EACzB,qBAAqB,EACrB,uBAAuB,EAUvB,WAAW,EACX,kBAAkB,EAClB,mBAAmB,EAGnB,gBAAgB,EAChB,uBAAuB,EACvB,mBAAmB,EACnB,gBAAgB,EAChB,uBAAuB,EACvB,iBAAiB,EACjB,gBAAgB,EAGhB,YAAY,EACZ,mBAAmB,EAEnB,QAAQ,EACR,iBAAiB,EAEjB,cAAc,EACd,oBAAoB,EAGpB,QAAQ,EAER,IAAI,EAKJ,eAAe,EAMf,cAAc,EACd,kBAAkB,EAClB,wBAAwB,EACxB,WAAW,EAGX,oBAAoB,GAGrB,MAAM,kBAAkB,CAAA"}