@ai-matrx/api 0.0.0-stage → 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 (146) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/LICENSE +21 -0
  3. package/README.md +18 -2
  4. package/dist/account.cjs +670 -0
  5. package/dist/account.d.cts +3246 -0
  6. package/dist/account.d.ts +3246 -0
  7. package/dist/account.js +558 -0
  8. package/dist/agents.cjs +598 -0
  9. package/dist/agents.d.cts +3417 -0
  10. package/dist/agents.d.ts +3417 -0
  11. package/dist/agents.js +497 -0
  12. package/dist/ai.cjs +109 -0
  13. package/dist/ai.d.cts +493 -0
  14. package/dist/ai.d.ts +493 -0
  15. package/dist/ai.js +91 -0
  16. package/dist/apps.cjs +394 -0
  17. package/dist/apps.d.cts +1094 -0
  18. package/dist/apps.d.ts +1094 -0
  19. package/dist/apps.js +328 -0
  20. package/dist/architecture.cjs +1223 -0
  21. package/dist/architecture.d.cts +4701 -0
  22. package/dist/architecture.d.ts +4701 -0
  23. package/dist/architecture.js +1016 -0
  24. package/dist/audio.cjs +226 -0
  25. package/dist/audio.d.cts +723 -0
  26. package/dist/audio.d.ts +723 -0
  27. package/dist/audio.js +188 -0
  28. package/dist/chat.cjs +538 -0
  29. package/dist/chat.d.cts +2251 -0
  30. package/dist/chat.d.ts +2251 -0
  31. package/dist/chat.js +447 -0
  32. package/dist/chunk-2SXAAKGV.cjs +279 -0
  33. package/dist/chunk-AY5N6EA4.js +43 -0
  34. package/dist/chunk-BMQI7UET.cjs +48 -0
  35. package/dist/chunk-FNIYADWI.cjs +59 -0
  36. package/dist/chunk-KIEAFMKB.js +264 -0
  37. package/dist/chunk-UONBYRE4.js +1012 -0
  38. package/dist/chunk-YTEOFGFC.js +57 -0
  39. package/dist/chunk-YUDQWDCM.cjs +1047 -0
  40. package/dist/code.cjs +561 -0
  41. package/dist/code.d.cts +1976 -0
  42. package/dist/code.d.ts +1976 -0
  43. package/dist/code.js +467 -0
  44. package/dist/commerce.cjs +22 -0
  45. package/dist/commerce.d.cts +45 -0
  46. package/dist/commerce.d.ts +45 -0
  47. package/dist/commerce.js +18 -0
  48. package/dist/communications.cjs +215 -0
  49. package/dist/communications.d.cts +948 -0
  50. package/dist/communications.d.ts +948 -0
  51. package/dist/communications.js +179 -0
  52. package/dist/computer.cjs +330 -0
  53. package/dist/computer.d.cts +733 -0
  54. package/dist/computer.d.ts +733 -0
  55. package/dist/computer.js +275 -0
  56. package/dist/content.cjs +425 -0
  57. package/dist/content.d.cts +1796 -0
  58. package/dist/content.d.ts +1796 -0
  59. package/dist/content.js +354 -0
  60. package/dist/credentials.cjs +22 -0
  61. package/dist/credentials.d.cts +82 -0
  62. package/dist/credentials.d.ts +82 -0
  63. package/dist/credentials.js +1 -0
  64. package/dist/crm.cjs +271 -0
  65. package/dist/crm.d.cts +1731 -0
  66. package/dist/crm.d.ts +1731 -0
  67. package/dist/crm.js +226 -0
  68. package/dist/data.cjs +382 -0
  69. package/dist/data.d.cts +1860 -0
  70. package/dist/data.d.ts +1860 -0
  71. package/dist/data.js +318 -0
  72. package/dist/education.cjs +28 -0
  73. package/dist/education.d.cts +73 -0
  74. package/dist/education.d.ts +73 -0
  75. package/dist/education.js +23 -0
  76. package/dist/files.cjs +1330 -0
  77. package/dist/files.d.cts +4956 -0
  78. package/dist/files.d.ts +4956 -0
  79. package/dist/files.js +1104 -0
  80. package/dist/human-resources.cjs +178 -0
  81. package/dist/human-resources.d.cts +1208 -0
  82. package/dist/human-resources.d.ts +1208 -0
  83. package/dist/human-resources.js +148 -0
  84. package/dist/index-C2E-Cp19.d.ts +385 -0
  85. package/dist/index-wC2vtb70.d.cts +385 -0
  86. package/dist/index.cjs +1934 -0
  87. package/dist/index.d.cts +2006 -0
  88. package/dist/index.d.ts +2006 -0
  89. package/dist/index.js +1668 -0
  90. package/dist/integrations.cjs +5116 -0
  91. package/dist/integrations.d.cts +19213 -0
  92. package/dist/integrations.d.ts +19213 -0
  93. package/dist/integrations.js +4263 -0
  94. package/dist/intelligence.cjs +1305 -0
  95. package/dist/intelligence.d.cts +4658 -0
  96. package/dist/intelligence.d.ts +4658 -0
  97. package/dist/intelligence.js +1196 -0
  98. package/dist/knowledge.cjs +1113 -0
  99. package/dist/knowledge.d.cts +5427 -0
  100. package/dist/knowledge.d.ts +5427 -0
  101. package/dist/knowledge.js +921 -0
  102. package/dist/legal.cjs +225 -0
  103. package/dist/legal.d.cts +1038 -0
  104. package/dist/legal.d.ts +1038 -0
  105. package/dist/legal.js +187 -0
  106. package/dist/marketing.cjs +1155 -0
  107. package/dist/marketing.d.cts +7741 -0
  108. package/dist/marketing.d.ts +7741 -0
  109. package/dist/marketing.js +951 -0
  110. package/dist/masterwork.cjs +283 -0
  111. package/dist/masterwork.d.cts +1938 -0
  112. package/dist/masterwork.d.ts +1938 -0
  113. package/dist/masterwork.js +231 -0
  114. package/dist/media.cjs +610 -0
  115. package/dist/media.d.cts +2270 -0
  116. package/dist/media.d.ts +2270 -0
  117. package/dist/media.js +507 -0
  118. package/dist/net.cjs +67 -0
  119. package/dist/net.d.cts +204 -0
  120. package/dist/net.d.ts +204 -0
  121. package/dist/net.js +2 -0
  122. package/dist/platform.cjs +150 -0
  123. package/dist/platform.d.cts +572 -0
  124. package/dist/platform.d.ts +572 -0
  125. package/dist/platform.js +125 -0
  126. package/dist/publish.cjs +248 -0
  127. package/dist/publish.d.cts +1431 -0
  128. package/dist/publish.d.ts +1431 -0
  129. package/dist/publish.js +206 -0
  130. package/dist/schemas.cjs +2 -0
  131. package/dist/schemas.d.cts +1353 -0
  132. package/dist/schemas.d.ts +1353 -0
  133. package/dist/schemas.js +1 -0
  134. package/dist/stream.cjs +44 -0
  135. package/dist/stream.d.cts +2 -0
  136. package/dist/stream.d.ts +2 -0
  137. package/dist/stream.js +3 -0
  138. package/dist/web.cjs +1045 -0
  139. package/dist/web.d.cts +4186 -0
  140. package/dist/web.d.ts +4186 -0
  141. package/dist/web.js +867 -0
  142. package/dist/workflows.cjs +825 -0
  143. package/dist/workflows.d.cts +4699 -0
  144. package/dist/workflows.d.ts +4699 -0
  145. package/dist/workflows.js +686 -0
  146. package/package.json +418 -4
@@ -0,0 +1,148 @@
1
+ // src/generated/human-resources.ts
2
+ var $hrIdentitySsnReveal = { m: "POST", p: "/hr/identity/{identity_id}/ssn/reveal", d: "aidream", a: "user", o: "required", n: "human-resources.hr_identity_ssn_reveal" };
3
+ function hrIdentitySsnReveal(api, args, options) {
4
+ return api.call($hrIdentitySsnReveal, args, options);
5
+ }
6
+ var $hrIdentitySsnStore = { m: "POST", p: "/hr/identity/{identity_id}/ssn", d: "aidream", a: "user", o: "required", n: "human-resources.hr_identity_ssn_store" };
7
+ function hrIdentitySsnStore(api, args, options) {
8
+ return api.call($hrIdentitySsnStore, args, options);
9
+ }
10
+ var $hrIdentitySsnFingerprint = { m: "POST", p: "/hr/identity/ssn/fingerprint", d: "aidream", a: "user", o: "required", n: "human-resources.hr_identity_ssn_fingerprint" };
11
+ function hrIdentitySsnFingerprint(api, args, options) {
12
+ return api.call($hrIdentitySsnFingerprint, args, options);
13
+ }
14
+ var $hrVerificationLettersGenerate = { m: "POST", p: "/hr/verification-letters/{letter_id}/generate", d: "aidream", a: "user", o: "required", n: "human-resources.hr_verification_letters_generate" };
15
+ function hrVerificationLettersGenerate(api, args, options) {
16
+ return api.call($hrVerificationLettersGenerate, args, options);
17
+ }
18
+ var $hrExportsFormatsList = { m: "GET", p: "/hr/exports/formats", d: "aidream", a: "user", o: "required", n: "human-resources.hr_exports_formats_list" };
19
+ function hrExportsFormatsList(api, args, options) {
20
+ return api.call($hrExportsFormatsList, args, options);
21
+ }
22
+ var $hrExportsPayrollPreview = { m: "POST", p: "/hr/exports/payroll/preview", d: "aidream", a: "user", o: "required", n: "human-resources.hr_exports_payroll_preview" };
23
+ function hrExportsPayrollPreview(api, args, options) {
24
+ return api.call($hrExportsPayrollPreview, args, options);
25
+ }
26
+ var $hrExportsPayrollCreate = { m: "POST", p: "/hr/exports/payroll", d: "aidream", a: "user", o: "required", n: "human-resources.hr_exports_payroll_create" };
27
+ function hrExportsPayrollCreate(api, args, options) {
28
+ return api.call($hrExportsPayrollCreate, args, options);
29
+ }
30
+ var $hrExportsTimesheetCreate = { m: "POST", p: "/hr/exports/timesheet", d: "aidream", a: "user", o: "required", n: "human-resources.hr_exports_timesheet_create" };
31
+ function hrExportsTimesheetCreate(api, args, options) {
32
+ return api.call($hrExportsTimesheetCreate, args, options);
33
+ }
34
+ var $hrExportsGet = { m: "GET", p: "/hr/exports/{export_id}", d: "aidream", a: "user", o: "required", n: "human-resources.hr_exports_get" };
35
+ function hrExportsGet(api, args, options) {
36
+ return api.call($hrExportsGet, args, options);
37
+ }
38
+ var $hrExportsArtifactGet = { m: "GET", p: "/hr/exports/{export_id}/artifact", d: "aidream", a: "user", o: "required", n: "human-resources.hr_exports_artifact_get" };
39
+ function hrExportsArtifactGet(api, args, options) {
40
+ return api.call($hrExportsArtifactGet, args, options);
41
+ }
42
+ var $hrExportsAcknowledge = { m: "POST", p: "/hr/exports/{export_id}/acknowledge", d: "aidream", a: "user", o: "required", n: "human-resources.hr_exports_acknowledge" };
43
+ function hrExportsAcknowledge(api, args, options) {
44
+ return api.call($hrExportsAcknowledge, args, options);
45
+ }
46
+ var $hrExportsFail = { m: "POST", p: "/hr/exports/{export_id}/fail", d: "aidream", a: "user", o: "required", n: "human-resources.hr_exports_fail" };
47
+ function hrExportsFail(api, args, options) {
48
+ return api.call($hrExportsFail, args, options);
49
+ }
50
+ var $hrExportsSupersede = { m: "POST", p: "/hr/exports/{export_id}/supersede", d: "aidream", a: "user", o: "required", n: "human-resources.hr_exports_supersede" };
51
+ function hrExportsSupersede(api, args, options) {
52
+ return api.call($hrExportsSupersede, args, options);
53
+ }
54
+ var $hrProvidersBindingsList = { m: "GET", p: "/hr/providers/{seam}/bindings", d: "aidream", a: "user", o: "required", n: "human-resources.hr_providers_bindings_list" };
55
+ function hrProvidersBindingsList(api, args, options) {
56
+ return api.call($hrProvidersBindingsList, args, options);
57
+ }
58
+ var $hrProvidersDispatch = { m: "POST", p: "/hr/providers/{seam}/dispatch", d: "aidream", a: "user", o: "required", n: "human-resources.hr_providers_dispatch" };
59
+ function hrProvidersDispatch(api, args, options) {
60
+ return api.call($hrProvidersDispatch, args, options);
61
+ }
62
+ var $hrProvidersResultsRecord = { m: "POST", p: "/hr/providers/{seam}/results", d: "aidream", a: "user", o: "required", n: "human-resources.hr_providers_results_record" };
63
+ function hrProvidersResultsRecord(api, args, options) {
64
+ return api.call($hrProvidersResultsRecord, args, options);
65
+ }
66
+ var $hrProvidersSync = { m: "POST", p: "/hr/providers/{seam}/sync", d: "aidream", a: "user", o: "required", n: "human-resources.hr_providers_sync" };
67
+ function hrProvidersSync(api, args, options) {
68
+ return api.call($hrProvidersSync, args, options);
69
+ }
70
+ var $hrHooksProviderWebhook = { m: "POST", p: "/hooks/providers/{seam}/{provider_key}", d: "aidream", a: "scoped", o: "required", n: "human-resources.hr_hooks_provider_webhook" };
71
+ function hrHooksProviderWebhook(api, args, options) {
72
+ return api.call($hrHooksProviderWebhook, args, options);
73
+ }
74
+ var $hrCalcOvertime = { m: "POST", p: "/hr/calc/overtime", d: "aidream", a: "user", o: "required", n: "human-resources.hr_calc_overtime" };
75
+ function hrCalcOvertime(api, args, options) {
76
+ return api.call($hrCalcOvertime, args, options);
77
+ }
78
+ var $hrCalcBreakPremium = { m: "POST", p: "/hr/calc/break-premium", d: "aidream", a: "user", o: "required", n: "human-resources.hr_calc_break_premium" };
79
+ function hrCalcBreakPremium(api, args, options) {
80
+ return api.call($hrCalcBreakPremium, args, options);
81
+ }
82
+ var $hrTimeOvertimeEvaluate = { m: "POST", p: "/hr/time/overtime/evaluate", d: "aidream", a: "user", o: "required", n: "human-resources.hr_time_overtime_evaluate" };
83
+ function hrTimeOvertimeEvaluate(api, args, options) {
84
+ return api.call($hrTimeOvertimeEvaluate, args, options);
85
+ }
86
+ var $hrTimeRecompute = { m: "POST", p: "/hr/time/recompute", d: "aidream", a: "user", o: "required", n: "human-resources.hr_time_recompute" };
87
+ function hrTimeRecompute(api, args, options) {
88
+ return api.call($hrTimeRecompute, args, options);
89
+ }
90
+ var $hrTimeExceptionsScan = { m: "POST", p: "/hr/time/exceptions/scan", d: "aidream", a: "user", o: "required", n: "human-resources.hr_time_exceptions_scan" };
91
+ function hrTimeExceptionsScan(api, args, options) {
92
+ return api.call($hrTimeExceptionsScan, args, options);
93
+ }
94
+ var $hrTimeOvertimeScan = { m: "POST", p: "/hr/time/overtime/scan", d: "aidream", a: "user", o: "required", n: "human-resources.hr_time_overtime_scan" };
95
+ function hrTimeOvertimeScan(api, args, options) {
96
+ return api.call($hrTimeOvertimeScan, args, options);
97
+ }
98
+ var $hrCalcLeaveAccrual = { m: "POST", p: "/hr/calc/leave-accrual", d: "aidream", a: "user", o: "required", n: "human-resources.hr_calc_leave_accrual" };
99
+ function hrCalcLeaveAccrual(api, args, options) {
100
+ return api.call($hrCalcLeaveAccrual, args, options);
101
+ }
102
+ var $hrCalcCarryover = { m: "POST", p: "/hr/calc/carryover", d: "aidream", a: "user", o: "required", n: "human-resources.hr_calc_carryover" };
103
+ function hrCalcCarryover(api, args, options) {
104
+ return api.call($hrCalcCarryover, args, options);
105
+ }
106
+ var $hrAccrualsRun = { m: "POST", p: "/hr/accruals/run", d: "aidream", a: "user", o: "required", n: "human-resources.hr_accruals_run" };
107
+ function hrAccrualsRun(api, args, options) {
108
+ return api.call($hrAccrualsRun, args, options);
109
+ }
110
+ var $hrAccrualsCarryoverRun = { m: "POST", p: "/hr/accruals/carryover/run", d: "aidream", a: "user", o: "required", n: "human-resources.hr_accruals_carryover_run" };
111
+ function hrAccrualsCarryoverRun(api, args, options) {
112
+ return api.call($hrAccrualsCarryoverRun, args, options);
113
+ }
114
+ var TABLE = {
115
+ "POST /hr/identity/{identity_id}/ssn/reveal": $hrIdentitySsnReveal,
116
+ "POST /hr/identity/{identity_id}/ssn": $hrIdentitySsnStore,
117
+ "POST /hr/identity/ssn/fingerprint": $hrIdentitySsnFingerprint,
118
+ "POST /hr/verification-letters/{letter_id}/generate": $hrVerificationLettersGenerate,
119
+ "GET /hr/exports/formats": $hrExportsFormatsList,
120
+ "POST /hr/exports/payroll/preview": $hrExportsPayrollPreview,
121
+ "POST /hr/exports/payroll": $hrExportsPayrollCreate,
122
+ "POST /hr/exports/timesheet": $hrExportsTimesheetCreate,
123
+ "GET /hr/exports/{export_id}": $hrExportsGet,
124
+ "GET /hr/exports/{export_id}/artifact": $hrExportsArtifactGet,
125
+ "POST /hr/exports/{export_id}/acknowledge": $hrExportsAcknowledge,
126
+ "POST /hr/exports/{export_id}/fail": $hrExportsFail,
127
+ "POST /hr/exports/{export_id}/supersede": $hrExportsSupersede,
128
+ "GET /hr/providers/{seam}/bindings": $hrProvidersBindingsList,
129
+ "POST /hr/providers/{seam}/dispatch": $hrProvidersDispatch,
130
+ "POST /hr/providers/{seam}/results": $hrProvidersResultsRecord,
131
+ "POST /hr/providers/{seam}/sync": $hrProvidersSync,
132
+ "POST /hooks/providers/{seam}/{provider_key}": $hrHooksProviderWebhook,
133
+ "POST /hr/calc/overtime": $hrCalcOvertime,
134
+ "POST /hr/calc/break-premium": $hrCalcBreakPremium,
135
+ "POST /hr/time/overtime/evaluate": $hrTimeOvertimeEvaluate,
136
+ "POST /hr/time/recompute": $hrTimeRecompute,
137
+ "POST /hr/time/exceptions/scan": $hrTimeExceptionsScan,
138
+ "POST /hr/time/overtime/scan": $hrTimeOvertimeScan,
139
+ "POST /hr/calc/leave-accrual": $hrCalcLeaveAccrual,
140
+ "POST /hr/calc/carryover": $hrCalcCarryover,
141
+ "POST /hr/accruals/run": $hrAccrualsRun,
142
+ "POST /hr/accruals/carryover/run": $hrAccrualsCarryoverRun
143
+ };
144
+ function call(api, key, args, options) {
145
+ return api.call(TABLE[key], args, options);
146
+ }
147
+
148
+ export { call, hrAccrualsCarryoverRun, hrAccrualsRun, hrCalcBreakPremium, hrCalcCarryover, hrCalcLeaveAccrual, hrCalcOvertime, hrExportsAcknowledge, hrExportsArtifactGet, hrExportsFail, hrExportsFormatsList, hrExportsGet, hrExportsPayrollCreate, hrExportsPayrollPreview, hrExportsSupersede, hrExportsTimesheetCreate, hrHooksProviderWebhook, hrIdentitySsnFingerprint, hrIdentitySsnReveal, hrIdentitySsnStore, hrProvidersBindingsList, hrProvidersDispatch, hrProvidersResultsRecord, hrProvidersSync, hrTimeExceptionsScan, hrTimeOvertimeEvaluate, hrTimeOvertimeScan, hrTimeRecompute, hrVerificationLettersGenerate };
@@ -0,0 +1,385 @@
1
+ import { CredentialsSetting } from './credentials.js';
2
+
3
+ /**
4
+ * Canonical AI Matrx NDJSON wire kernel.
5
+ *
6
+ * This module is deliberately independent of React, Redux, Next.js, Supabase,
7
+ * and generated application types. Every Matrx client uses it to turn the
8
+ * backend's byte stream into the same normalized `{ event, data }` envelopes.
9
+ * Host runtimes remain responsible for HTTP/auth errors and for deciding what
10
+ * each event means in their state model.
11
+ */
12
+ interface MatrxStreamEnvelope<TData = unknown> {
13
+ event: string;
14
+ /** Immutable emitter segment; transport sequence is scoped to this id. */
15
+ stream_id?: string;
16
+ data: TData;
17
+ /** Monotonic transport sequence from full envelopes, when supplied. */
18
+ stream_seq?: number;
19
+ }
20
+ interface MatrxNdjsonIssue {
21
+ line: string;
22
+ error: unknown;
23
+ /** One-based physical NDJSON line number. */
24
+ lineNumber: number;
25
+ /** True when an unterminated trailing fragment was parsed by `finish()`. */
26
+ atCompletion: boolean;
27
+ }
28
+ interface MatrxStreamEnvelopeObservation {
29
+ /** Exact parsed JSON value before compact/full normalization. */
30
+ raw: unknown;
31
+ envelope: MatrxStreamEnvelope;
32
+ line: string;
33
+ lineNumber: number;
34
+ atCompletion: boolean;
35
+ }
36
+ interface MatrxNdjsonFramerOptions {
37
+ /** Malformed JSON is non-fatal, but it must never disappear silently. */
38
+ onMalformedLine?: (issue: MatrxNdjsonIssue) => void;
39
+ /** Valid JSON with no recognized Matrx event envelope is also non-fatal. */
40
+ onUnknownEnvelope?: (value: unknown) => void;
41
+ /** Observe every valid envelope without changing or consuming it. */
42
+ onValidEnvelope?: (observation: MatrxStreamEnvelopeObservation) => void;
43
+ }
44
+ interface ReadMatrxNdjsonOptions extends MatrxNdjsonFramerOptions {
45
+ signal?: AbortSignal;
46
+ /** Maximum normalized events read ahead of the iterator consumer. */
47
+ maxReadAhead?: number;
48
+ }
49
+ interface MatrxNdjsonFramer {
50
+ /** Push a text fragment. Fragments may split JSON tokens or line endings. */
51
+ pushText(fragment: string): MatrxStreamEnvelope[];
52
+ /** Push a byte fragment. UTF-8 code points may span calls. */
53
+ pushBytes(fragment: Uint8Array): MatrxStreamEnvelope[];
54
+ /** Parse the final unterminated line and flush any pending UTF-8 bytes. */
55
+ finish(): MatrxStreamEnvelope[];
56
+ }
57
+ declare const DEFAULT_MATRX_NDJSON_READ_AHEAD = 64;
58
+ /**
59
+ * Normalize both supported Matrx wire shapes:
60
+ *
61
+ * - full: `{ "event": "chunk", "data": { "text": "..." } }`
62
+ * - compact chunk: `{ "e": "c", "t": "..." }`
63
+ * - compact reasoning: `{ "e": "r", "t": "..." }`
64
+ */
65
+ declare function normalizeMatrxStreamEnvelope(value: unknown): MatrxStreamEnvelope | null;
66
+ /**
67
+ * Create the transport-independent NDJSON framer used by the stream reader.
68
+ * Browser extensions, desktop bridges, WebSockets, and tests can feed it
69
+ * fragmented strings or bytes without constructing a `ReadableStream`.
70
+ */
71
+ declare function createMatrxNdjsonFramer(options?: MatrxNdjsonFramerOptions): MatrxNdjsonFramer;
72
+ /**
73
+ * Read and normalize a Matrx NDJSON response body with bounded background
74
+ * read-ahead. Consumer work does not stall the network until `maxReadAhead`
75
+ * complete events are waiting; the bound prevents an abandoned or blocked
76
+ * consumer from growing memory without limit.
77
+ */
78
+ declare function readMatrxNdjsonStream(body: ReadableStream<Uint8Array>, options?: ReadMatrxNdjsonOptions): AsyncGenerator<MatrxStreamEnvelope, void, undefined>;
79
+
80
+ /**
81
+ * `@ai-matrx/agents/stream/sse` — the Matrx SSE frame kernel.
82
+ *
83
+ * Two Matrx clients hand-rolled the identical `text/event-stream` framing —
84
+ * the same separator regex, the same field parsing, the same CRLF incident —
85
+ * for the durable rejoin endpoints (`/runtime/.../events/stream`,
86
+ * `/runs/.../events/stream`). This module is that framing extracted ONCE, as a
87
+ * pure incremental parser, so a host keeps only what is genuinely host policy:
88
+ * the fetch, the stall timer, the retry budget, and what each event MEANS.
89
+ *
90
+ * Contract, mirroring `stream/ndjson`:
91
+ * - Pure and effect-free: no fetch, no timers, no globals. Importing this
92
+ * module performs no work.
93
+ * - Incremental across arbitrary chunk boundaries: a frame split anywhere —
94
+ * mid-line, mid-separator, mid-UTF-8 when using the byte reader — parses
95
+ * identically to one delivered whole.
96
+ * - All three SSE line terminators (`\r\n`, `\n`, `\r`) and all three frame
97
+ * separators are handled — the CRLF-vs-LF divergence that bit production is
98
+ * covered by construction and by test.
99
+ * - Comment-only frames (heartbeats, `:` lines) ARE emitted (with
100
+ * `data === null`) because hosts use any parsed frame as liveness proof to
101
+ * reset stall timers and retry budgets. Frames with data join multi-line
102
+ * `data:` fields with `\n` per the SSE spec.
103
+ * - `id:` is surfaced raw AND, when it is a safe integer, as `seq` — the
104
+ * `Last-Event-ID` cursor both Matrx rejoin endpoints use for durable replay.
105
+ * Cursor ADVANCEMENT (`seq > cursor`) stays host-side, next to the retry.
106
+ */
107
+ interface MatrxSseFrame {
108
+ /** `event:` field; the SSE default "message" when absent. */
109
+ event: string;
110
+ /** `id:` field, raw, when present. */
111
+ id: string | null;
112
+ /**
113
+ * `id:` parsed as a non-negative safe integer, else null. Matrx rejoin
114
+ * streams use integer ids as the `Last-Event-ID` replay cursor.
115
+ */
116
+ seq: number | null;
117
+ /**
118
+ * Joined `data:` lines (`\n`-separated per spec), or null for a frame with
119
+ * no data field at all (e.g. a comment-only heartbeat). An empty-string
120
+ * data field is `""`, not null.
121
+ */
122
+ data: string | null;
123
+ }
124
+ /** Parse ONE complete frame's text (no trailing separator). */
125
+ declare function parseMatrxSseFrame(frame: string): MatrxSseFrame;
126
+ interface MatrxSseFramer {
127
+ /** Feed a decoded text chunk; returns every frame it completed. */
128
+ push(chunk: string): MatrxSseFrame[];
129
+ /**
130
+ * Signal end of input. A non-empty trailing buffer is an UNTERMINATED frame:
131
+ * per the SSE spec it was never dispatched, so it is returned separately for
132
+ * the host to treat as diagnostic, never as a delivered event.
133
+ */
134
+ flush(): {
135
+ incomplete: string | null;
136
+ };
137
+ }
138
+ /** Incremental SSE framer over already-decoded text. */
139
+ declare function createMatrxSseFramer(): MatrxSseFramer;
140
+ interface ReadMatrxSseOptions {
141
+ /**
142
+ * Called with any unterminated trailing text at stream end (a frame the
143
+ * server never finished — diagnostic, not a delivered event).
144
+ */
145
+ onIncomplete?: (text: string) => void;
146
+ }
147
+ /**
148
+ * Async-iterate the frames of a byte stream (e.g. `response.body`), handling
149
+ * split UTF-8 across chunk boundaries. Cancellation follows the reader: abort
150
+ * the fetch and the iterator ends; a transport error after complete frames
151
+ * were yielded surfaces AFTER those frames, with its original cause.
152
+ */
153
+ declare function readMatrxSseStream(stream: ReadableStream<Uint8Array>, options?: ReadMatrxSseOptions): AsyncGenerator<MatrxSseFrame, void, undefined>;
154
+
155
+ /**
156
+ * GENERATED by @ai-matrx/api scripts/generate.mjs from aidream/api-contract — never edit by hand.
157
+ * CONTRACT_SHA256 50a790edb39e682b46e0fa9e674faf5ce2a0ba7de2cd01930a497fca4c47844a
158
+ */
159
+ /** The server contract's hash; the Python `matrx-api` and any native client carry the same value. */
160
+ declare const CONTRACT_SHA256 = "50a790edb39e682b46e0fa9e674faf5ce2a0ba7de2cd01930a497fca4c47844a";
161
+ /** Which deployment answers (api-deployments.json): default base URLs and the existing env names that override them. */
162
+ declare const DEPLOYMENTS: {
163
+ readonly files: {
164
+ readonly app: "files-standalone";
165
+ readonly baseUrl: {
166
+ readonly production: "https://files.matrxserver.com";
167
+ readonly localhost: "http://127.0.0.1:8090";
168
+ };
169
+ readonly env: {
170
+ readonly browser: "NEXT_PUBLIC_FILES_URL";
171
+ readonly browser_local: "NEXT_PUBLIC_FILES_URL_LOCAL";
172
+ readonly server: "MATRX_FILES_URL";
173
+ };
174
+ };
175
+ readonly scraper: {
176
+ readonly app: "scraper-server";
177
+ readonly baseUrl: {
178
+ readonly production: "https://scraper.app.matrxserver.com";
179
+ readonly localhost: "http://localhost:8001";
180
+ };
181
+ readonly env: {
182
+ readonly browser: "NEXT_PUBLIC_SCRAPER_URL";
183
+ readonly browser_local: "NEXT_PUBLIC_SCRAPER_URL_LOCAL";
184
+ readonly server: "MATRX_SCRAPER_URL";
185
+ readonly service_token: "MATRX_SCRAPER_TOKEN";
186
+ };
187
+ };
188
+ readonly seo: {
189
+ readonly app: "seo-standalone";
190
+ readonly baseUrl: {
191
+ readonly production: "https://seo.matrxserver.com";
192
+ readonly localhost: "http://127.0.0.1:8081";
193
+ };
194
+ readonly env: {
195
+ readonly browser: "NEXT_PUBLIC_SEO_URL";
196
+ readonly browser_local: "NEXT_PUBLIC_SEO_URL_LOCAL";
197
+ };
198
+ };
199
+ readonly "sandbox-orchestrator": {
200
+ readonly app: "sandbox-orchestrator";
201
+ readonly baseUrl: {
202
+ readonly production: "https://orchestrator.dev.codematrx.com";
203
+ };
204
+ readonly env: {
205
+ readonly server: "SANDBOX_ORCHESTRATOR_URL";
206
+ readonly service_token: "SANDBOX_ORCHESTRATOR_API_KEY";
207
+ };
208
+ };
209
+ readonly "matrx-local": {
210
+ readonly app: "matrx-local";
211
+ readonly baseUrl: {
212
+ readonly localhost: "http://127.0.0.1:22140";
213
+ };
214
+ readonly env: {
215
+ readonly port_base: "MATRX_PORT_BASE";
216
+ };
217
+ };
218
+ readonly "cloud-browser-streaming": {
219
+ readonly app: "cloud-browser-streaming";
220
+ readonly baseUrl: {};
221
+ readonly env: {};
222
+ };
223
+ readonly "cloud-browser-worker": {
224
+ readonly app: "cloud-browser-worker";
225
+ readonly baseUrl: {};
226
+ readonly env: {};
227
+ };
228
+ readonly "hosted-box": {
229
+ readonly app: "hosted-box";
230
+ readonly baseUrl: {};
231
+ readonly env: {};
232
+ };
233
+ readonly aidream: {
234
+ readonly app: "aidream-main";
235
+ readonly baseUrl: {
236
+ readonly production: "https://server.app.matrxserver.com";
237
+ readonly localhost: "http://localhost:8000";
238
+ };
239
+ readonly env: {
240
+ readonly browser: "NEXT_PUBLIC_BACKEND_URL_PROD";
241
+ readonly server: "MATRX_AIDREAM_URL";
242
+ readonly service_token: "MATRX_AIDREAM_SERVICE_TOKEN";
243
+ readonly sandbox_service_token: "AIDREAM_SANDBOX_SERVICE_TOKEN";
244
+ };
245
+ };
246
+ };
247
+ type DeploymentName = keyof typeof DEPLOYMENTS;
248
+ /** Every generated domain section (`@ai-matrx/api/<domain>`). */
249
+ declare const DOMAINS: readonly ["account", "agents", "ai", "apps", "architecture", "audio", "chat", "code", "commerce", "communications", "computer", "content", "crm", "data", "education", "files", "human-resources", "integrations", "intelligence", "knowledge", "legal", "marketing", "masterwork", "media", "platform", "publish", "web", "workflows"];
250
+
251
+ /**
252
+ * `createApi` — the ONE client of every AI Matrx server.
253
+ *
254
+ * Every generated operation (`@ai-matrx/api/<domain>`) is a standalone
255
+ * function that hands this client a small {@link OperationDescriptor} straight
256
+ * from the server contract: method, path template, which deployment answers
257
+ * (`api-deployments.json`), the auth tier, the organization rule and the
258
+ * stream kind. The client owns everything else, once:
259
+ *
260
+ * - base URL per deployment (production / localhost defaults from the
261
+ * deployment map, host overrides per service);
262
+ * - the ONE credentials setting (five kinds, `credentials.ts`);
263
+ * - the organization binding, honouring each operation's `x-matrx-org`:
264
+ * `required` fails closed before the wire, `optional` sends one when bound,
265
+ * `exempt` never sends one;
266
+ * - `X-Request-Id` on every call;
267
+ * - connect/total timeouts (`net/resilient-fetch`) and retry of idempotent
268
+ * reads (`net/retry`);
269
+ * - one error model (`MatrxApiError`, `NetError`, `OrganizationContextError`);
270
+ * - stream parsing (NDJSON, SSE, bytes, and the conditional `*_or_json`).
271
+ *
272
+ * No Supabase, no React, no state: a host injects identity, never policy.
273
+ */
274
+
275
+ type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS";
276
+ /** The contract's `x-matrx-auth` tiers. */
277
+ type AuthTier = "public" | "guest" | "user" | "api_key" | "service" | "scoped" | "admin" | "loopback_token" | "loopback_open";
278
+ /** The contract's `x-matrx-org` rules. */
279
+ type OrgRule = "required" | "optional" | "exempt";
280
+ /** The contract's `x-matrx-stream` kinds. */
281
+ type StreamKind = "none" | "ndjson" | "sse" | "bytes" | "ndjson_or_json" | "sse_or_json" | "bytes_or_json";
282
+ /**
283
+ * One operation, as the generator writes it. Short keys keep thousands of
284
+ * descriptors small; only the operations an app imports are ever bundled.
285
+ */
286
+ interface OperationDescriptor {
287
+ /** HTTP method. */
288
+ readonly m: HttpMethod;
289
+ /** Path template as the deployment serves it (`/files/{file_id}`). */
290
+ readonly p: string;
291
+ /** The deployment that answers (`api-deployments.json` service name). */
292
+ readonly d: DeploymentName;
293
+ /** Auth tier. */
294
+ readonly a: AuthTier;
295
+ /** Organization rule. */
296
+ readonly o: OrgRule;
297
+ /** Stream kind; omitted = plain JSON. */
298
+ readonly s?: StreamKind;
299
+ /** Stable name `<domain>.<op>` (diagnostics, request logs). */
300
+ readonly n: string;
301
+ }
302
+ type Environment = "production" | "localhost";
303
+ interface ApiRequestInfo {
304
+ readonly operation: string;
305
+ readonly method: HttpMethod;
306
+ readonly url: string;
307
+ readonly requestId: string;
308
+ readonly deployment: DeploymentName;
309
+ }
310
+ interface CreateApiOptions {
311
+ /** The ONE credentials setting: a credential, a getter, or a `CredentialsPort`. */
312
+ credentials?: CredentialsSetting;
313
+ /** The bound organization (value or getter). Sent per each operation's org rule. */
314
+ organizationId?: string | null | (() => string | null | undefined);
315
+ /** Which default base URLs to use. Default `"production"`. */
316
+ environment?: Environment;
317
+ /** Per-deployment base URL overrides (no trailing slash), e.g. `{ aidream: "http://localhost:8000" }`. */
318
+ baseUrls?: Partial<Record<DeploymentName, string>>;
319
+ /** Fully dynamic routing; wins over `baseUrls`. Return undefined to fall through. */
320
+ resolveBaseUrl?: (deployment: DeploymentName, operation: OperationDescriptor) => string | undefined;
321
+ /** Max ms request start → response headers. Default 15 000. */
322
+ connectTimeoutMs?: number;
323
+ /** Max ms for the whole request. Default null (streams are long-lived). */
324
+ totalTimeoutMs?: number | null;
325
+ /** Attempts for idempotent reads (GET/HEAD) on transport failures. Default 3; 1 disables. */
326
+ retryAttempts?: number;
327
+ /** Mints the `X-Request-Id`. Default `crypto.randomUUID()`. */
328
+ requestId?: () => string;
329
+ /** Extra headers on every call (never overrides credentials or org). */
330
+ headers?: Record<string, string>;
331
+ /** Observability sink; the client works fully without it. */
332
+ onRequest?: (info: ApiRequestInfo) => void;
333
+ }
334
+ /** Per-call options. */
335
+ interface CallOptions {
336
+ signal?: AbortSignal;
337
+ /** This call's organization; wins over the bound one. */
338
+ organizationId?: string;
339
+ headers?: Record<string, string>;
340
+ connectTimeoutMs?: number;
341
+ totalTimeoutMs?: number | null;
342
+ }
343
+ /** The arguments a generated operation accepts (each operation narrows them). */
344
+ interface OperationArgs {
345
+ path?: Record<string, string | number> | undefined;
346
+ query?: object | undefined;
347
+ body?: unknown;
348
+ }
349
+ /** A parsed stream. `requestId` is the `X-Request-Id` this call carried. */
350
+ interface ApiStream<E> extends AsyncIterable<E> {
351
+ readonly response: Response;
352
+ readonly requestId: string;
353
+ /** Abort the underlying request. */
354
+ cancel(): void;
355
+ }
356
+ /** A conditional stream: the server answered with JSON (e.g. a cached result) or a stream. */
357
+ type JsonOrStream<J, E> = {
358
+ readonly kind: "json";
359
+ readonly data: J;
360
+ } | {
361
+ readonly kind: "stream";
362
+ readonly stream: ApiStream<E>;
363
+ };
364
+ type NdjsonEvent = MatrxStreamEnvelope;
365
+ type SseEvent = MatrxSseFrame;
366
+ interface Api {
367
+ /** Send one operation; plain JSON operations resolve to the parsed body. */
368
+ call<T>(op: OperationDescriptor, args?: OperationArgs, options?: CallOptions): Promise<T>;
369
+ /** Send one operation and return the raw `Response` (bytes, custom parsing). */
370
+ send(op: OperationDescriptor, args?: OperationArgs, options?: CallOptions): Promise<{
371
+ response: Response;
372
+ requestId: string;
373
+ controller: AbortController;
374
+ }>;
375
+ /** Resolve where an operation goes, without sending it. */
376
+ url(op: OperationDescriptor, args?: OperationArgs): string;
377
+ }
378
+ /** Build the one client. */
379
+ declare function createApi(options?: CreateApiOptions): Api;
380
+ /** Send a streaming operation and parse it per its contract stream kind. */
381
+ declare function openStream<E>(api: Api, op: OperationDescriptor, args?: OperationArgs, options?: CallOptions): Promise<ApiStream<E>>;
382
+ /** Send a conditional (`*_or_json`) operation: JSON when the server answered JSON, else the stream. */
383
+ declare function openJsonOrStream<J, E>(api: Api, op: OperationDescriptor, args?: OperationArgs, options?: CallOptions): Promise<JsonOrStream<J, E>>;
384
+
385
+ export { type Api as A, readMatrxSseStream as B, type CallOptions as C, DEPLOYMENTS as D, type Environment as E, type HttpMethod as H, type JsonOrStream as J, type MatrxStreamEnvelope as M, type NdjsonEvent as N, type OperationArgs as O, type ReadMatrxNdjsonOptions as R, type SseEvent as S, type ApiStream as a, type MatrxNdjsonIssue as b, type MatrxStreamEnvelopeObservation as c, type MatrxSseFrame as d, type ApiRequestInfo as e, type AuthTier as f, CONTRACT_SHA256 as g, type CreateApiOptions as h, DOMAINS as i, type DeploymentName as j, type OperationDescriptor as k, type OrgRule as l, type StreamKind as m, createApi as n, openJsonOrStream as o, openStream as p, DEFAULT_MATRX_NDJSON_READ_AHEAD as q, type MatrxNdjsonFramer as r, type MatrxNdjsonFramerOptions as s, type MatrxSseFramer as t, type ReadMatrxSseOptions as u, createMatrxNdjsonFramer as v, createMatrxSseFramer as w, normalizeMatrxStreamEnvelope as x, parseMatrxSseFrame as y, readMatrxNdjsonStream as z };