@moxxy/sdk 0.14.4 → 0.14.5

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 (40) hide show
  1. package/README.md +2 -0
  2. package/dist/compactor-helpers.d.ts +59 -0
  3. package/dist/compactor-helpers.d.ts.map +1 -1
  4. package/dist/compactor-helpers.js +72 -1
  5. package/dist/compactor-helpers.js.map +1 -1
  6. package/dist/elision-helpers.d.ts.map +1 -1
  7. package/dist/elision-helpers.js +12 -5
  8. package/dist/elision-helpers.js.map +1 -1
  9. package/dist/elision-state.d.ts +4 -0
  10. package/dist/elision-state.d.ts.map +1 -1
  11. package/dist/elision-state.js +41 -0
  12. package/dist/elision-state.js.map +1 -1
  13. package/dist/index.d.ts +4 -5
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +6 -5
  16. package/dist/index.js.map +1 -1
  17. package/dist/mode/project-messages.d.ts +9 -0
  18. package/dist/mode/project-messages.d.ts.map +1 -1
  19. package/dist/mode/project-messages.js +4 -1
  20. package/dist/mode/project-messages.js.map +1 -1
  21. package/dist/server.d.ts +21 -0
  22. package/dist/server.d.ts.map +1 -0
  23. package/dist/server.js +21 -0
  24. package/dist/server.js.map +1 -0
  25. package/dist/transcriber.d.ts +13 -0
  26. package/dist/transcriber.d.ts.map +1 -1
  27. package/dist/transcriber.js +13 -1
  28. package/dist/transcriber.js.map +1 -1
  29. package/package.json +9 -1
  30. package/src/compactor-helpers.test.ts +106 -0
  31. package/src/compactor-helpers.ts +125 -1
  32. package/src/elision-helpers.ts +14 -5
  33. package/src/elision-state.test.ts +78 -0
  34. package/src/elision-state.ts +42 -0
  35. package/src/index.ts +13 -19
  36. package/src/mode/project-messages.ts +13 -1
  37. package/src/package-root.test.ts +37 -0
  38. package/src/server.ts +34 -0
  39. package/src/transcriber.test.ts +12 -0
  40. package/src/transcriber.ts +14 -0
@@ -61,6 +61,15 @@ export interface ProjectMessagesOptions {
61
61
  readonly systemPrompt?: string;
62
62
  /** Optional trailing user message — useful for plan-execute's "Focus on this step now: X". */
63
63
  readonly trailingUserText?: string;
64
+ /**
65
+ * Optional precomputed elision state for THIS exact log snapshot. When a
66
+ * caller already derived it within the same loop iteration (e.g. the
67
+ * compaction/elision gates), threading it here skips a redundant
68
+ * `computeElisionState` fold. MUST be the state of the same log — a stale one
69
+ * would mis-render stubs — so it is purely an opt-in fast path; omitting it
70
+ * recomputes (memoized on the log version), byte-identically.
71
+ */
72
+ readonly precomputedElisionState?: ElisionState;
64
73
  }
65
74
 
66
75
  interface CompactionRange {
@@ -260,7 +269,10 @@ export function projectMessages(
260
269
  const compactions = activeCompactionRanges(allEvents);
261
270
  const compactionFor = makeCompactionLookup(compactions);
262
271
  const emittedCompactions = new Set<CompactionRange>();
263
- const el = computeElisionState(allEvents);
272
+ // Reuse a threaded state when the caller already derived it for this exact
273
+ // snapshot; otherwise `computeElisionState` is memoized on the log version so
274
+ // the in-iteration projection still folds only once.
275
+ const el = opts.precomputedElisionState ?? computeElisionState(allEvents);
264
276
 
265
277
  const messages: ProviderMessage[] = [];
266
278
  // The stable prefix is every message produced from events at/below the
@@ -37,4 +37,41 @@ describe('@moxxy/sdk package root', () => {
37
37
 
38
38
  expect(check.issues[0]?.requirement.name).toBe('auth:provider:openai-codex');
39
39
  });
40
+
41
+ // The main barrel is the browser/RN-safe surface: a value import of any of
42
+ // these would drag a node:* builtin into a Metro/browser bundle. They live on
43
+ // the './server' subpath instead. This pins the split so a future accidental
44
+ // re-export on the main barrel is caught (see .dependency-cruiser.cjs
45
+ // `no-node-builtins-in-renderer`).
46
+ const NODE_ONLY_VALUE_EXPORTS = [
47
+ 'spawnCliTunnel',
48
+ 'isCliTunnelAvailable',
49
+ 'writeFileAtomic',
50
+ 'writeFileAtomicSync',
51
+ 'moxxyHome',
52
+ 'moxxyPath',
53
+ 'readRequestBody',
54
+ 'bearerTokenMatches',
55
+ 'resolveChannelToken',
56
+ 'rotateChannelToken',
57
+ 'bearerGuard',
58
+ 'encodeWsBearerProtocol',
59
+ 'tokenFromWsProtocolHeader',
60
+ 'MOXXY_WS_SUBPROTOCOL',
61
+ 'MOXXY_WS_BEARER_PROTOCOL_PREFIX',
62
+ ] as const;
63
+
64
+ it('does NOT expose Node-runtime values on the browser/RN-safe main barrel', async () => {
65
+ const sdk: Record<string, unknown> = await import('@moxxy/sdk');
66
+ for (const name of NODE_ONLY_VALUE_EXPORTS) {
67
+ expect(sdk[name], `${name} must not be on the @moxxy/sdk main barrel`).toBeUndefined();
68
+ }
69
+ });
70
+
71
+ it('exposes the Node-runtime helpers on the @moxxy/sdk/server subpath', async () => {
72
+ const server: Record<string, unknown> = await import('@moxxy/sdk/server');
73
+ for (const name of NODE_ONLY_VALUE_EXPORTS) {
74
+ expect(server[name], `${name} must be exported from @moxxy/sdk/server`).toBeDefined();
75
+ }
76
+ });
40
77
  });
package/src/server.ts ADDED
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Node-runtime-only surface of @moxxy/sdk.
3
+ *
4
+ * Importing `@moxxy/sdk/server` pulls in the value helpers that statically
5
+ * depend on Node builtins (`node:child_process`, `node:fs`, `node:os`,
6
+ * `node:http`, `node:crypto`, `node:path`). The MAIN barrel (`@moxxy/sdk`) is
7
+ * deliberately kept free of these so a browser/React-Native bundle can value-
8
+ * import from it (and from `@moxxy/sdk/tool-display`) without dragging a Node
9
+ * builtin into the bundle — Metro cannot polyfill `node:child_process`.
10
+ *
11
+ * Node-side consumers (cli, runner, desktop-host, channel/oauth/webhooks
12
+ * plugins, …) import these helpers from here. The corresponding *type* exports
13
+ * (e.g. `TunnelHandle`, `WriteFileAtomicOptions`, `ChannelTokenOptions`) remain
14
+ * on the main barrel because types are erased at build time and never reach a
15
+ * bundle.
16
+ */
17
+
18
+ export { spawnCliTunnel, isCliTunnelAvailable } from './tunnel.js';
19
+ export {
20
+ writeFileAtomic,
21
+ writeFileAtomicSync,
22
+ moxxyHome,
23
+ moxxyPath,
24
+ } from './fs-utils.js';
25
+ export { readRequestBody, bearerTokenMatches } from './http-utils.js';
26
+ export {
27
+ resolveChannelToken,
28
+ rotateChannelToken,
29
+ bearerGuard,
30
+ encodeWsBearerProtocol,
31
+ tokenFromWsProtocolHeader,
32
+ MOXXY_WS_SUBPROTOCOL,
33
+ MOXXY_WS_BEARER_PROTOCOL_PREFIX,
34
+ } from './channel-auth.js';
@@ -0,0 +1,12 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { MOXXY_PCM16_24KHZ_MIME } from './transcriber.js';
3
+
4
+ describe('MOXXY_PCM16_24KHZ_MIME', () => {
5
+ it('locks the cross-package wire value', () => {
6
+ // This is a PROTOCOL constant: the desktop/web capture path stamps it onto
7
+ // the audio blob and the Codex transcriber keys on it to wrap the raw PCM
8
+ // samples in a WAV header. Drift in the literal silently breaks
9
+ // transcription with no compile-time signal — so pin the exact bytes here.
10
+ expect(MOXXY_PCM16_24KHZ_MIME).toBe('audio/x-moxxy-pcm16-24khz');
11
+ });
12
+ });
@@ -18,6 +18,20 @@
18
18
  * used by models that advertise `supportsAudio: true`.
19
19
  */
20
20
 
21
+ /**
22
+ * Wire MIME tag for raw 16-bit little-endian PCM mono at 24 kHz — the lossless
23
+ * format the desktop/web mic capture path produces and that the Codex
24
+ * transcriber keys on to wrap the bytes in a WAV header before upload.
25
+ *
26
+ * This is a cross-package PROTOCOL value: client-platform-web stamps it onto
27
+ * the captured blob, plugin-cli forwards it as the attachment `mimeType`, and
28
+ * plugin-stt-whisper switches on it. It lived as an independently-redeclared
29
+ * literal in all three (silent transcription breakage if any drifted), so it is
30
+ * hoisted here to the SDK's single zero-dep typed surface as the source of
31
+ * truth. Consumers should import this rather than re-spell the literal.
32
+ */
33
+ export const MOXXY_PCM16_24KHZ_MIME = 'audio/x-moxxy-pcm16-24khz';
34
+
21
35
  export interface TranscriptionSegment {
22
36
  /** Segment start, in seconds from the start of the clip. */
23
37
  readonly start: number;