@nola-lang/console 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +23 -0
- package/dist/core/labels.d.ts +15 -0
- package/dist/core/labels.d.ts.map +1 -0
- package/dist/core/labels.js +23 -0
- package/dist/core/labels.js.map +1 -0
- package/dist/core/service.d.ts +27 -0
- package/dist/core/service.d.ts.map +1 -0
- package/dist/core/service.js +43 -0
- package/dist/core/service.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/server/app.d.ts +7 -0
- package/dist/server/app.d.ts.map +1 -0
- package/dist/server/app.js +130 -0
- package/dist/server/app.js.map +1 -0
- package/dist/server/static.d.ts +12 -0
- package/dist/server/static.d.ts.map +1 -0
- package/dist/server/static.js +51 -0
- package/dist/server/static.js.map +1 -0
- package/dist/start.d.ts +36 -0
- package/dist/start.d.ts.map +1 -0
- package/dist/start.js +66 -0
- package/dist/start.js.map +1 -0
- package/dist/storage/sqlite.d.ts +20 -0
- package/dist/storage/sqlite.d.ts.map +1 -0
- package/dist/storage/sqlite.js +588 -0
- package/dist/storage/sqlite.js.map +1 -0
- package/dist/storage/types.d.ts +173 -0
- package/dist/storage/types.d.ts.map +1 -0
- package/dist/storage/types.js +2 -0
- package/dist/storage/types.js.map +1 -0
- package/dist/ui/assets/index-B0axHa78.js +90 -0
- package/dist/ui/assets/index-CI2n4AW-.css +2 -0
- package/dist/ui/index.html +14 -0
- package/dist/ui/nola.svg +5 -0
- package/package.json +46 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Evgen Mykhailenko
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# @nola-lang/console
|
|
2
|
+
|
|
3
|
+
The local [Nola](https://github.com/nola-lang/nola) Console: trace ingestion,
|
|
4
|
+
storage and API for observing every `ask`. Started from the CLI:
|
|
5
|
+
|
|
6
|
+
```bash
|
|
7
|
+
npx nola-lang console
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
The console binds `http://localhost:4141` (loopback only; the first free port
|
|
11
|
+
upward, `--port` overrides), stores traces in one per-machine database at
|
|
12
|
+
`~/.nola/console/data/console.db` (built-in Node SQLite — Node ≥ 22.13),
|
|
13
|
+
and receives events from any Nola app that has
|
|
14
|
+
`NOLA_TRACING_URL` set or a connection in its `nola.config.ts` —
|
|
15
|
+
`hooks: [tracer("<url>")]`, or `export default nola({ baseUrl: "<url>", model: … })` when the console serves the whole stack.
|
|
16
|
+
|
|
17
|
+
Endpoints: `POST /v1/ingest` and `GET /v1/capabilities` (the Nola wire
|
|
18
|
+
protocol), `GET /api/projects`, `GET /api/records`, `GET /api/traces/:id`,
|
|
19
|
+
`GET /api/asks/:id`, `GET /api/definitions`, `GET /api/definitions/:def`,
|
|
20
|
+
`DELETE /api/records` (clear everything), `GET /api/events` (SSE).
|
|
21
|
+
|
|
22
|
+
You normally install `nola-lang` (which depends on this package) rather than
|
|
23
|
+
installing `@nola-lang/console` directly. Docs: <https://nola.sh/docs/>.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { AskKind } from "@nola-lang/core";
|
|
2
|
+
/** `triage(..)` — the infer function as a call; `<anonymous>` for a scope-less root. */
|
|
3
|
+
export declare function invocationLabel(fn: string | undefined): string;
|
|
4
|
+
/**
|
|
5
|
+
* The ask as the author wrote it: ``..`instruction`<T>`` for an extract,
|
|
6
|
+
* ``callee`hint`(..)`` for a call. Display text only — never identity.
|
|
7
|
+
*/
|
|
8
|
+
export declare function askLabel(ask: {
|
|
9
|
+
kind: AskKind;
|
|
10
|
+
instruction?: string;
|
|
11
|
+
callee?: string;
|
|
12
|
+
hint?: string;
|
|
13
|
+
typeText?: string;
|
|
14
|
+
}): string;
|
|
15
|
+
//# sourceMappingURL=labels.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"labels.d.ts","sourceRoot":"","sources":["../../src/core/labels.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAU/C,wFAAwF;AACxF,wBAAgB,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAE9D;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE;IAC5B,IAAI,EAAE,OAAO,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,GAAG,MAAM,CAOT"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const INSTRUCTION_MAX = 80;
|
|
2
|
+
/** One line, whitespace collapsed, cut to INSTRUCTION_MAX characters with an ellipsis. */
|
|
3
|
+
function excerpt(text) {
|
|
4
|
+
const flat = text.replace(/\s+/g, " ").trim();
|
|
5
|
+
return flat.length > INSTRUCTION_MAX ? `${flat.slice(0, INSTRUCTION_MAX - 1)}…` : flat;
|
|
6
|
+
}
|
|
7
|
+
/** `triage(..)` — the infer function as a call; `<anonymous>` for a scope-less root. */
|
|
8
|
+
export function invocationLabel(fn) {
|
|
9
|
+
return `${fn ?? "<anonymous>"}(..)`;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The ask as the author wrote it: ``..`instruction`<T>`` for an extract,
|
|
13
|
+
* ``callee`hint`(..)`` for a call. Display text only — never identity.
|
|
14
|
+
*/
|
|
15
|
+
export function askLabel(ask) {
|
|
16
|
+
if (ask.kind === "call") {
|
|
17
|
+
const hint = ask.hint ? `\`${excerpt(ask.hint)}\`` : "";
|
|
18
|
+
return `${ask.callee ?? "?"}${hint}(..)`;
|
|
19
|
+
}
|
|
20
|
+
const type = ask.typeText ? `<${ask.typeText}>` : "";
|
|
21
|
+
return `..\`${excerpt(ask.instruction ?? "")}\`${type}`;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=labels.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"labels.js","sourceRoot":"","sources":["../../src/core/labels.ts"],"names":[],"mappings":"AAEA,MAAM,eAAe,GAAG,EAAE,CAAC;AAE3B,0FAA0F;AAC1F,SAAS,OAAO,CAAC,IAAY;IAC3B,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;IAC9C,OAAO,IAAI,CAAC,MAAM,GAAG,eAAe,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,eAAe,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;AACzF,CAAC;AAED,wFAAwF;AACxF,MAAM,UAAU,eAAe,CAAC,EAAsB;IACpD,OAAO,GAAG,EAAE,IAAI,aAAa,MAAM,CAAC;AACtC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,GAMxB;IACC,IAAI,GAAG,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QACxB,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;QACxD,OAAO,GAAG,GAAG,CAAC,MAAM,IAAI,GAAG,GAAG,IAAI,MAAM,CAAC;IAC3C,CAAC;IACD,MAAM,IAAI,GAAG,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IACrD,OAAO,OAAO,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC;AAC1D,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { NolaIngestEnvelope } from "@nola-lang/core";
|
|
2
|
+
import type { AskDetail, ConsoleStorage, DefinitionDetail, DefinitionSummary, ProjectSummary, RecordsQuery, TraceDetail, TraceRecord } from "../storage/types.js";
|
|
3
|
+
/** What live subscribers receive: every ingested envelope, plus a notice when the store was cleared. */
|
|
4
|
+
export type ConsoleNotice = NolaIngestEnvelope | {
|
|
5
|
+
kind: "cleared";
|
|
6
|
+
at: number;
|
|
7
|
+
};
|
|
8
|
+
/** Framework-independent console domain: persistence + live fan-out. Knows nothing of Hono or HTTP. */
|
|
9
|
+
export declare class ConsoleService {
|
|
10
|
+
#private;
|
|
11
|
+
constructor(storage: ConsoleStorage);
|
|
12
|
+
ingest(envelope: NolaIngestEnvelope): Promise<void>;
|
|
13
|
+
/** Wipe the store; subscribers hear a `cleared` notice so open UIs refetch. */
|
|
14
|
+
clear(): Promise<void>;
|
|
15
|
+
onEvent(listener: (notice: ConsoleNotice) => void): () => void;
|
|
16
|
+
listProjects(): Promise<ProjectSummary[]>;
|
|
17
|
+
/** The flattened tree in display order — roots newest first, children in start order beneath each. */
|
|
18
|
+
listRecords(query?: RecordsQuery): Promise<TraceRecord[]>;
|
|
19
|
+
getTrace(invocationId: string): Promise<TraceDetail | undefined>;
|
|
20
|
+
getAsk(askId: string): Promise<AskDetail | undefined>;
|
|
21
|
+
listDefinitions(query?: {
|
|
22
|
+
project?: string;
|
|
23
|
+
noProject?: boolean;
|
|
24
|
+
}): Promise<DefinitionSummary[]>;
|
|
25
|
+
getDefinition(def: string): Promise<DefinitionDetail | undef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,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC;CAGlE"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { EventEmitter } from "node:events";
|
|
2
|
+
/** Framework-independent console domain: persistence + live fan-out. Knows nothing of Hono or HTTP. */
|
|
3
|
+
export class ConsoleService {
|
|
4
|
+
#storage;
|
|
5
|
+
#emitter = new EventEmitter();
|
|
6
|
+
constructor(storage) {
|
|
7
|
+
this.#storage = storage;
|
|
8
|
+
this.#emitter.setMaxListeners(0); // one listener per open SSE stream
|
|
9
|
+
}
|
|
10
|
+
async ingest(envelope) {
|
|
11
|
+
await this.#storage.ingest(envelope);
|
|
12
|
+
this.#emitter.emit("event", envelope);
|
|
13
|
+
}
|
|
14
|
+
/** Wipe the store; subscribers hear a `cleared` notice so open UIs refetch. */
|
|
15
|
+
async clear() {
|
|
16
|
+
await this.#storage.clear();
|
|
17
|
+
this.#emitter.emit("event", { kind: "cleared", at: Date.now() });
|
|
18
|
+
}
|
|
19
|
+
onEvent(listener) {
|
|
20
|
+
this.#emitter.on("event", listener);
|
|
21
|
+
return () => this.#emitter.off("event", listener);
|
|
22
|
+
}
|
|
23
|
+
listProjects() {
|
|
24
|
+
return this.#storage.listProjects();
|
|
25
|
+
}
|
|
26
|
+
/** The flattened tree in display order — roots newest first, children in start order beneath each. */
|
|
27
|
+
listRecords(query) {
|
|
28
|
+
return this.#storage.listRecords(query);
|
|
29
|
+
}
|
|
30
|
+
getTrace(invocationId) {
|
|
31
|
+
return this.#storage.getTrace(invocationId);
|
|
32
|
+
}
|
|
33
|
+
getAsk(askId) {
|
|
34
|
+
return this.#storage.getAsk(askId);
|
|
35
|
+
}
|
|
36
|
+
listDefinitions(query) {
|
|
37
|
+
return this.#storage.listDefinitions(query);
|
|
38
|
+
}
|
|
39
|
+
getDefinition(def) {
|
|
40
|
+
return this.#storage.getDefinition(def);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
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AAC,KAAK,CAAC,CAAC;IAC1C,CAAC;IAED,QAAQ,CAAC,YAAoB;QAC3B,OAAO,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;IAC9C,CAAC;IAED,MAAM,CAAC,KAAa;QAClB,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACrC,CAAC;IAED,eAAe,CAAC,KAAiD;QAC/D,OAAO,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;IAC9C,CAAC;IAED,aAAa,CAAC,GAAW;QACvB,OAAO,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;IAC1C,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { askLabel, invocationLabel } from "./core/labels.js";
|
|
2
|
+
export { type ConsoleNotice, ConsoleService } from "./core/service.js";
|
|
3
|
+
export { createApp } from "./server/app.js";
|
|
4
|
+
export { loadUiAssets, type UiAsset } from "./server/static.js";
|
|
5
|
+
export type { RunningConsole, StartConsoleOptions } from "./start.js";
|
|
6
|
+
export { CONSOLE_DEFAULT_PORT, consoleDbPath, defaultConsolePath, findFreePort, startConsole } from "./start.js";
|
|
7
|
+
export { SqliteConsoleStorage } from "./storage/sqlite.js";
|
|
8
|
+
export type { AskDetail, AskEventRow, AskRecord, AskSummary, AttemptSummary, ConsoleStorage, DefinitionDetail, DefinitionSummary, InvocationLink, InvocationRecord, ProjectSummary, RecordBase, RecordKind, RecordsQuery, TraceDetail, TraceRecord, } from "./storage/types.js";
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,KAAK,aAAa,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,KAAK,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAChE,YAAY,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,kBAAkB,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AACjH,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,YAAY,EACV,SAAS,EACT,WAAW,EACX,SAAS,EACT,UAAU,EACV,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,UAAU,EACV,UAAU,EACV,YAAY,EACZ,WAAW,EACX,WAAW,GACZ,MAAM,oBAAoB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { askLabel, invocationLabel } from "./core/labels.js";
|
|
2
|
+
export { ConsoleService } from "./core/service.js";
|
|
3
|
+
export { createApp } from "./server/app.js";
|
|
4
|
+
export { loadUiAssets } from "./server/static.js";
|
|
5
|
+
export { CONSOLE_DEFAULT_PORT, consoleDbPath, defaultConsolePath, findFreePort, startConsole } from "./start.js";
|
|
6
|
+
export { SqliteConsoleStorage } from "./storage/sqlite.js";
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAsB,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAgB,MAAM,oBAAoB,CAAC;AAEhE,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,kBAAkB,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AACjH,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Hono } from "hono";
|
|
2
|
+
import type { ConsoleService } from "../core/service.js";
|
|
3
|
+
/** Thin HTTP adapter over ConsoleService — no domain logic in handlers (console design §13). */
|
|
4
|
+
export declare function createApp(service: ConsoleService, opts?: {
|
|
5
|
+
uiDir?: string;
|
|
6
|
+
}): Hono;
|
|
7
|
+
//# sourceMappingURL=app.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../src/server/app.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAsBzD,gGAAgG;AAChG,wBAAgB,SAAS,CAAC,OAAO,EAAE,cAAc,EAAE,IAAI,GAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,IAAI,CAsHtF"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { NOLA_INGEST_KINDS, NOLA_INGEST_VERSION, NOLA_PROTOCOL } from "@nola-lang/core";
|
|
2
|
+
import { Hono } from "hono";
|
|
3
|
+
import { streamSSE } from "hono/streaming";
|
|
4
|
+
import { loadUiAssets } from "./static.js";
|
|
5
|
+
const isClientRoute = (pathname) => !pathname.startsWith("/api/") && !pathname.startsWith("/v1/") && !/\.[a-z0-9]+$/i.test(pathname);
|
|
6
|
+
const invalid = (message) => ({ error: { code: "invalid_envelope", message } });
|
|
7
|
+
function isIngestEnvelope(body) {
|
|
8
|
+
const e = body;
|
|
9
|
+
return (!!e &&
|
|
10
|
+
typeof e === "object" &&
|
|
11
|
+
e.v === NOLA_INGEST_VERSION &&
|
|
12
|
+
typeof e.runId === "string" &&
|
|
13
|
+
typeof e.pid === "number" &&
|
|
14
|
+
typeof e.seq === "number" &&
|
|
15
|
+
typeof e.at === "number" &&
|
|
16
|
+
NOLA_INGEST_KINDS.includes(e.kind));
|
|
17
|
+
}
|
|
18
|
+
/** Thin HTTP adapter over ConsoleService — no domain logic in handlers (console design §13). */
|
|
19
|
+
export function createApp(service, opts = {}) {
|
|
20
|
+
const app = new Hono();
|
|
21
|
+
const assets = opts.uiDir !== undefined ? loadUiAssets(opts.uiDir) : undefined;
|
|
22
|
+
app.get("/v1/capabilities", (c) => {
|
|
23
|
+
// Phase 1 observes but does not serve inference; the phase-2 gateway flips `infer` on.
|
|
24
|
+
const capabilities = { protocol: NOLA_PROTOCOL, infer: false, ingest: true };
|
|
25
|
+
return c.json(capabilities);
|
|
26
|
+
});
|
|
27
|
+
app.post("/v1/ingest", async (c) => {
|
|
28
|
+
let body;
|
|
29
|
+
try {
|
|
30
|
+
body = await c.req.json();
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
return c.json(invalid("body is not JSON"), 400);
|
|
34
|
+
}
|
|
35
|
+
if (!isIngestEnvelope(body))
|
|
36
|
+
return c.json(invalid("body is not a NolaIngestEnvelope"), 400);
|
|
37
|
+
await service.ingest(body);
|
|
38
|
+
return c.body(null, 204);
|
|
39
|
+
});
|
|
40
|
+
app.get("/api/projects", async (c) => c.json({ projects: await service.listProjects() }));
|
|
41
|
+
app.get("/api/records", async (c) => {
|
|
42
|
+
const project = c.req.query("project");
|
|
43
|
+
const noProject = c.req.query("noProject") === "1";
|
|
44
|
+
if (project !== undefined && noProject)
|
|
45
|
+
return c.json({ error: { code: "invalid_query", message: "project and noProject are mutually exclusive" } }, 400);
|
|
46
|
+
const runId = c.req.query("runId");
|
|
47
|
+
const limitRaw = c.req.query("limit");
|
|
48
|
+
const limit = limitRaw !== undefined ? Number(limitRaw) : undefined;
|
|
49
|
+
return c.json({
|
|
50
|
+
records: await service.listRecords({
|
|
51
|
+
...(project !== undefined ? { project } : {}),
|
|
52
|
+
...(noProject ? { noProject } : {}),
|
|
53
|
+
...(runId !== undefined ? { runId } : {}),
|
|
54
|
+
...(limit !== undefined && Number.isFinite(limit) ? { limit } : {}),
|
|
55
|
+
}),
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
app.delete("/api/records", async (c) => {
|
|
59
|
+
await service.clear();
|
|
60
|
+
return c.body(null, 204);
|
|
61
|
+
});
|
|
62
|
+
app.get("/api/traces/:id", async (c) => {
|
|
63
|
+
const trace = await service.getTrace(c.req.param("id"));
|
|
64
|
+
if (!trace)
|
|
65
|
+
return c.json({ error: { code: "not_found", message: "unknown trace" } }, 404);
|
|
66
|
+
return c.json(trace);
|
|
67
|
+
});
|
|
68
|
+
app.get("/api/asks/:id", async (c) => {
|
|
69
|
+
const ask = await service.getAsk(c.req.param("id"));
|
|
70
|
+
if (!ask)
|
|
71
|
+
return c.json({ error: { code: "not_found", message: "unknown ask" } }, 404);
|
|
72
|
+
return c.json(ask);
|
|
73
|
+
});
|
|
74
|
+
app.get("/api/definitions", async (c) => {
|
|
75
|
+
const project = c.req.query("project");
|
|
76
|
+
const noProject = c.req.query("noProject") === "1";
|
|
77
|
+
if (project !== undefined && noProject)
|
|
78
|
+
return c.json({ error: { code: "invalid_query", message: "project and noProject are mutually exclusive" } }, 400);
|
|
79
|
+
return c.json({
|
|
80
|
+
definitions: await service.listDefinitions({
|
|
81
|
+
...(project !== undefined ? { project } : {}),
|
|
82
|
+
...(noProject ? { noProject } : {}),
|
|
83
|
+
}),
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
app.get("/api/definitions/:def", async (c) => {
|
|
87
|
+
const definition = await service.getDefinition(c.req.param("def"));
|
|
88
|
+
if (!definition)
|
|
89
|
+
return c.json({ error: { code: "not_found", message: "unknown definition" } }, 404);
|
|
90
|
+
return c.json(definition);
|
|
91
|
+
});
|
|
92
|
+
app.get("/api/events", (c) => streamSSE(c, async (stream) => {
|
|
93
|
+
const unsubscribe = service.onEvent((notice) => {
|
|
94
|
+
void stream.writeSSE({ data: JSON.stringify(notice) });
|
|
95
|
+
});
|
|
96
|
+
stream.onAbort(() => unsubscribe());
|
|
97
|
+
// Hold the stream open until the client goes away; heartbeat comments keep proxies from timing it out.
|
|
98
|
+
while (!stream.aborted) {
|
|
99
|
+
await stream.sleep(15_000);
|
|
100
|
+
if (!stream.aborted)
|
|
101
|
+
await stream.writeSSE({ event: "ping", data: "" });
|
|
102
|
+
}
|
|
103
|
+
}));
|
|
104
|
+
if (assets) {
|
|
105
|
+
const serveAsset = (path) => {
|
|
106
|
+
const asset = assets.get(path);
|
|
107
|
+
if (!asset)
|
|
108
|
+
return undefined;
|
|
109
|
+
return new Response(asset.body, { headers: { "content-type": asset.type } });
|
|
110
|
+
};
|
|
111
|
+
// Exact matches against the frozen startup map only — no fs at request time,
|
|
112
|
+
// and the API routes above win by registration order. An extension-less path
|
|
113
|
+
// outside /api and /v1 is a client-side route (the UI is a react-router SPA):
|
|
114
|
+
// it gets index.html and the router takes it from there.
|
|
115
|
+
app.get("*", (c) => {
|
|
116
|
+
const pathname = new URL(c.req.url).pathname;
|
|
117
|
+
const asset = serveAsset(pathname);
|
|
118
|
+
if (asset)
|
|
119
|
+
return asset;
|
|
120
|
+
if (isClientRoute(pathname))
|
|
121
|
+
return serveAsset("/") ?? c.notFound();
|
|
122
|
+
return c.notFound();
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
app.get("/", (c) => c.html(`<!doctype html><meta charset="utf-8"><title>Nola Console</title><body style="font-family:system-ui;margin:3rem"><h1>Nola Console</h1><p>The trace UI ships in the next release. The API is live: <code>GET /api/traces</code>, <code>GET /api/traces/:id</code>, <code>GET /api/events</code> (SSE).</p></body>`));
|
|
127
|
+
}
|
|
128
|
+
return app;
|
|
129
|
+
}
|
|
130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UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC;YACpE,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC;QACtB,CAAC,CAAC,CAAC;IACL,CAAC;SAAM,CAAC;QACN,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,EAAE,CACjB,CAAC,CAAC,IAAI,CACJ,iTAAiT,CAClT,CACF,CAAC;IACJ,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface UiAsset {
|
|
2
|
+
body: Uint8Array;
|
|
3
|
+
type: string;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Read a built Vite output into an in-memory URL map at startup. The bundle
|
|
7
|
+
* is small; a frozen map avoids path traversal and per-request fs entirely.
|
|
8
|
+
* Undefined when the directory has no index.html (running from src, or the
|
|
9
|
+
* UI was not built) — the caller falls back to the placeholder page.
|
|
10
|
+
*/
|
|
11
|
+
export declare function loadUiAssets(dir: string): Map<string, UiAsset> | undefined;
|
|
12
|
+
//# sourceMappingURL=static.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"static.d.ts","sourceRoot":"","sources":["../../src/server/static.ts"],"names":[],"mappings":"AAeA,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAiB1E"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { readdirSync, readFileSync, statSync } from "node:fs";
|
|
2
|
+
import { extname, join, relative, sep } from "node:path";
|
|
3
|
+
const TYPES = {
|
|
4
|
+
".html": "text/html; charset=utf-8",
|
|
5
|
+
".js": "text/javascript; charset=utf-8",
|
|
6
|
+
".css": "text/css; charset=utf-8",
|
|
7
|
+
".map": "application/json; charset=utf-8",
|
|
8
|
+
".json": "application/json; charset=utf-8",
|
|
9
|
+
".svg": "image/svg+xml",
|
|
10
|
+
".ico": "image/x-icon",
|
|
11
|
+
".png": "image/png",
|
|
12
|
+
".woff2": "font/woff2",
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Read a built Vite output into an in-memory URL map at startup. The bundle
|
|
16
|
+
* is small; a frozen map avoids path traversal and per-request fs entirely.
|
|
17
|
+
* Undefined when the directory has no index.html (running from src, or the
|
|
18
|
+
* UI was not built) — the caller falls back to the placeholder page.
|
|
19
|
+
*/
|
|
20
|
+
export function loadUiAssets(dir) {
|
|
21
|
+
let entries;
|
|
22
|
+
try {
|
|
23
|
+
entries = walk(dir);
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
const map = new Map();
|
|
29
|
+
for (const file of entries) {
|
|
30
|
+
const url = `/${relative(dir, file).split(sep).join("/")}`;
|
|
31
|
+
const type = TYPES[extname(file)] ?? "application/octet-stream";
|
|
32
|
+
map.set(url, { body: readFileSync(file), type });
|
|
33
|
+
}
|
|
34
|
+
const index = map.get("/index.html");
|
|
35
|
+
if (!index)
|
|
36
|
+
return undefined;
|
|
37
|
+
map.set("/", index);
|
|
38
|
+
return map;
|
|
39
|
+
}
|
|
40
|
+
function walk(dir) {
|
|
41
|
+
const out = [];
|
|
42
|
+
for (const name of readdirSync(dir)) {
|
|
43
|
+
const full = join(dir, name);
|
|
44
|
+
if (statSync(full).isDirectory())
|
|
45
|
+
out.push(...walk(full));
|
|
46
|
+
else
|
|
47
|
+
out.push(full);
|
|
48
|
+
}
|
|
49
|
+
return out;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=static.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"static.js","sourceRoot":"","sources":["../../src/server/static.ts"],"names":[],"mappings":"A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