@niscorp/moss 0.6.0 → 0.7.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 (57) hide show
  1. package/CHANGELOG.md +100 -0
  2. package/DESIGN.md +77 -40
  3. package/DOCS.md +636 -78
  4. package/README.md +2 -2
  5. package/dist/{chunk-VBWNHF4H.cjs → chunk-C2DNDIQX.cjs} +4 -3
  6. package/dist/chunk-C2DNDIQX.cjs.map +1 -0
  7. package/dist/{chunk-R66WUKGC.cjs → chunk-DSTHFSTO.cjs} +1988 -1328
  8. package/dist/chunk-DSTHFSTO.cjs.map +1 -0
  9. package/dist/chunk-F45SFR7W.cjs +903 -0
  10. package/dist/chunk-F45SFR7W.cjs.map +1 -0
  11. package/dist/{chunk-NSK7QSSG.js → chunk-IMZZB4JE.js} +4 -3
  12. package/dist/chunk-IMZZB4JE.js.map +1 -0
  13. package/dist/{chunk-V5YMJL7Z.js → chunk-MTC46PGQ.js} +1971 -1309
  14. package/dist/chunk-MTC46PGQ.js.map +1 -0
  15. package/dist/chunk-MYGVHWS5.js +870 -0
  16. package/dist/chunk-MYGVHWS5.js.map +1 -0
  17. package/dist/{chunk-WKBH3UMB.js → chunk-X2Q546EB.js} +3 -3
  18. package/dist/{chunk-WKBH3UMB.js.map → chunk-X2Q546EB.js.map} +1 -1
  19. package/dist/{chunk-D3YZIAYV.cjs → chunk-Z2VA6AOE.cjs} +5 -5
  20. package/dist/{chunk-D3YZIAYV.cjs.map → chunk-Z2VA6AOE.cjs.map} +1 -1
  21. package/dist/document-AbQUbQaP.d.ts +381 -0
  22. package/dist/document-wHHxIXJz.d.cts +381 -0
  23. package/dist/{index-B411sK9M.d.cts → index-Dml1klpZ.d.cts} +4 -0
  24. package/dist/{index-B411sK9M.d.ts → index-Dml1klpZ.d.ts} +4 -0
  25. package/dist/index.cjs +17 -17
  26. package/dist/index.d.cts +7 -9
  27. package/dist/index.d.ts +7 -9
  28. package/dist/index.js +3 -3
  29. package/dist/integrations.cjs +3 -3
  30. package/dist/integrations.d.cts +1 -1
  31. package/dist/integrations.d.ts +1 -1
  32. package/dist/integrations.js +1 -1
  33. package/dist/node.cjs +8 -8
  34. package/dist/node.d.cts +3 -4
  35. package/dist/node.d.ts +3 -4
  36. package/dist/node.js +4 -4
  37. package/dist/tide.d.cts +1 -1
  38. package/dist/tide.d.ts +1 -1
  39. package/dist/unverified.cjs +3 -3
  40. package/dist/unverified.js +2 -2
  41. package/dist/vite.cjs +9 -9
  42. package/dist/vite.d.cts +6 -1
  43. package/dist/vite.d.ts +6 -1
  44. package/dist/vite.js +4 -4
  45. package/package.json +13 -13
  46. package/dist/app-CUnDcXQu.d.ts +0 -143
  47. package/dist/app-CdANzi2q.d.cts +0 -143
  48. package/dist/chunk-NSK7QSSG.js.map +0 -1
  49. package/dist/chunk-PWUO4RET.js +0 -374
  50. package/dist/chunk-PWUO4RET.js.map +0 -1
  51. package/dist/chunk-R2YPQHQH.cjs +0 -383
  52. package/dist/chunk-R2YPQHQH.cjs.map +0 -1
  53. package/dist/chunk-R66WUKGC.cjs.map +0 -1
  54. package/dist/chunk-V5YMJL7Z.js.map +0 -1
  55. package/dist/chunk-VBWNHF4H.cjs.map +0 -1
  56. package/dist/document-D7nroBww.d.cts +0 -169
  57. package/dist/document-DeTPGBil.d.ts +0 -169
package/dist/node.d.ts CHANGED
@@ -1,6 +1,5 @@
1
- import { D as DocumentConfig, M as MossServer } from './document-DeTPGBil.js';
2
- import { N as NiscApp } from './app-CUnDcXQu.js';
3
- import { N as NiscRuntime } from './index-B411sK9M.js';
1
+ import { D as DocumentConfig, M as MossServer, N as NiscApp } from './document-AbQUbQaP.js';
2
+ import { N as NiscRuntime } from './index-Dml1klpZ.js';
4
3
  import { S as SocketAccept, T as TransportSettings } from './socket-D90h1xSV.js';
5
4
  import { IncomingMessage } from 'node:http';
6
5
  import { Duplex } from 'node:stream';
@@ -8,9 +7,9 @@ import 'hono';
8
7
  import '@niscorp/charter';
9
8
  import '@niscorp/nova';
10
9
  import '@niscorp/vex';
11
- import '@niscorp/nova/document';
12
10
  import '@niscorp/strata';
13
11
  import '@niscorp/nova/i18n';
12
+ import '@niscorp/nova/document';
14
13
  import '@niscorp/strata/postgres';
15
14
  import 'zod';
16
15
 
package/dist/node.js CHANGED
@@ -1,7 +1,7 @@
1
- export { MOSS_PATHS, attachSocket, mountSite, serve } from './chunk-WKBH3UMB.js';
2
- import './chunk-V5YMJL7Z.js';
3
- import './chunk-PWUO4RET.js';
4
- import './chunk-NSK7QSSG.js';
1
+ export { MOSS_PATHS, attachSocket, mountSite, serve } from './chunk-X2Q546EB.js';
2
+ import './chunk-MTC46PGQ.js';
3
+ import './chunk-MYGVHWS5.js';
4
+ import './chunk-IMZZB4JE.js';
5
5
  import './chunk-4ZGAFZGS.js';
6
6
  //# sourceMappingURL=node.js.map
7
7
  //# sourceMappingURL=node.js.map
package/dist/tide.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Tide } from '@niscorp/tide';
2
- import { F as Feature } from './index-B411sK9M.cjs';
2
+ import { F as Feature } from './index-Dml1klpZ.cjs';
3
3
  import 'hono';
4
4
  import '@niscorp/charter';
5
5
  import '@niscorp/nova';
package/dist/tide.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Tide } from '@niscorp/tide';
2
- import { F as Feature } from './index-B411sK9M.js';
2
+ import { F as Feature } from './index-Dml1klpZ.js';
3
3
  import 'hono';
4
4
  import '@niscorp/charter';
5
5
  import '@niscorp/nova';
@@ -1,11 +1,11 @@
1
1
  'use strict';
2
2
 
3
- var chunkR2YPQHQH_cjs = require('./chunk-R2YPQHQH.cjs');
4
- require('./chunk-VBWNHF4H.cjs');
3
+ var chunkF45SFR7W_cjs = require('./chunk-F45SFR7W.cjs');
4
+ require('./chunk-C2DNDIQX.cjs');
5
5
  require('./chunk-3RIWTXGI.cjs');
6
6
 
7
7
  // src/shells/unverified.ts
8
- var unverifiedShell = (session) => chunkR2YPQHQH_cjs.wholeShellOf(session.shell);
8
+ var unverifiedShell = (session) => chunkF45SFR7W_cjs.wholeShellOf(session.shell);
9
9
 
10
10
  exports.unverifiedShell = unverifiedShell;
11
11
  //# sourceMappingURL=unverified.cjs.map
@@ -1,5 +1,5 @@
1
- import { wholeShellOf } from './chunk-PWUO4RET.js';
2
- import './chunk-NSK7QSSG.js';
1
+ import { wholeShellOf } from './chunk-MYGVHWS5.js';
2
+ import './chunk-IMZZB4JE.js';
3
3
  import './chunk-4ZGAFZGS.js';
4
4
 
5
5
  // src/shells/unverified.ts
package/dist/vite.cjs CHANGED
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
- var chunkD3YZIAYV_cjs = require('./chunk-D3YZIAYV.cjs');
4
- var chunkR66WUKGC_cjs = require('./chunk-R66WUKGC.cjs');
5
- require('./chunk-R2YPQHQH.cjs');
6
- require('./chunk-VBWNHF4H.cjs');
3
+ var chunkZ2VA6AOE_cjs = require('./chunk-Z2VA6AOE.cjs');
4
+ var chunkDSTHFSTO_cjs = require('./chunk-DSTHFSTO.cjs');
5
+ require('./chunk-F45SFR7W.cjs');
6
+ require('./chunk-C2DNDIQX.cjs');
7
7
  require('./chunk-3RIWTXGI.cjs');
8
8
  var promises = require('fs/promises');
9
9
  var net = require('net');
@@ -57,7 +57,7 @@ var devMiddleware = (vite, options, owned, current) => (req, res, next) => {
57
57
  }
58
58
  const scheme = "encrypted" in req.socket && req.socket.encrypted === true ? "https" : "http";
59
59
  res.statusCode = 302;
60
- res.setHeader("set-cookie", chunkR66WUKGC_cjs.sessionCookies(`${scheme}://${req.headers.host ?? "localhost"}`, token, app.tokenKey !== void 0 ? { key: app.tokenKey } : {}));
60
+ res.setHeader("set-cookie", chunkDSTHFSTO_cjs.sessionCookies(`${scheme}://${req.headers.host ?? "localhost"}`, token, app.tokenKey !== void 0 ? { key: app.tokenKey } : {}));
61
61
  res.setHeader("location", "/");
62
62
  res.end();
63
63
  }).catch(() => {
@@ -83,7 +83,7 @@ var devMiddleware = (vite, options, owned, current) => (req, res, next) => {
83
83
  return;
84
84
  }
85
85
  const template = await vite.transformIndexHtml(url, await promises.readFile(path.resolve(vite.config.root, options.index ?? "index.html"), "utf8"));
86
- const page = await chunkR66WUKGC_cjs.renderDocument({
86
+ const page = await chunkDSTHFSTO_cjs.renderDocument({
87
87
  server: app.server,
88
88
  template,
89
89
  request: { path: path$1 === "/index.html" ? "/" : path$1, cookie: req.headers.cookie ?? null, host: req.headers.host ?? null },
@@ -104,17 +104,17 @@ var mossDev = (options) => ({
104
104
  configureServer: (vite) => {
105
105
  const label = options.label ?? "moss";
106
106
  const watch = options.watch ?? DEFAULT_WATCH;
107
- const owned = options.owned ?? chunkD3YZIAYV_cjs.MOSS_PATHS;
107
+ const owned = options.owned ?? chunkZ2VA6AOE_cjs.MOSS_PATHS;
108
108
  const load = (id) => vite.ssrLoadModule(id);
109
109
  const httpServer = vite.httpServer;
110
110
  const boot = async () => {
111
111
  const app = await options.app(load);
112
- return { app, listener: nodeServer.getRequestListener(app.server.fetch), ...httpServer !== null ? { transport: chunkD3YZIAYV_cjs.createTransport(app.server.socket) } : {} };
112
+ return { app, listener: nodeServer.getRequestListener(app.server.fetch), ...httpServer !== null ? { transport: chunkZ2VA6AOE_cjs.createTransport(app.server.socket) } : {} };
113
113
  };
114
114
  let current = boot();
115
115
  current.catch((error) => vite.config.logger.error(`[${label}] the app did not boot: ${said(error)}`, { timestamp: true }));
116
116
  if (httpServer !== null) {
117
- chunkD3YZIAYV_cjs.listenForUpgrades(httpServer, "/socket", (req, socket, head) => {
117
+ chunkZ2VA6AOE_cjs.listenForUpgrades(httpServer, "/socket", (req, socket, head) => {
118
118
  void current.then(
119
119
  ({ transport }) => transport?.upgrade(req, socket, head),
120
120
  () => socket.end("HTTP/1.1 503 Service Unavailable\r\nConnection: close\r\nContent-Length: 0\r\n\r\n")
package/dist/vite.d.cts CHANGED
@@ -1,9 +1,14 @@
1
1
  import { Plugin } from 'vite';
2
- import { M as MossServer, D as DocumentConfig } from './document-D7nroBww.cjs';
2
+ import { M as MossServer, D as DocumentConfig } from './document-wHHxIXJz.cjs';
3
3
  import 'hono';
4
4
  import '@niscorp/charter';
5
5
  import '@niscorp/nova';
6
6
  import '@niscorp/vex';
7
+ import '@niscorp/strata';
8
+ import '@niscorp/nova/i18n';
9
+ import './index-Dml1klpZ.cjs';
10
+ import '@niscorp/strata/postgres';
11
+ import 'zod';
7
12
  import './socket-D90h1xSV.cjs';
8
13
  import '@niscorp/nova/document';
9
14
 
package/dist/vite.d.ts CHANGED
@@ -1,9 +1,14 @@
1
1
  import { Plugin } from 'vite';
2
- import { M as MossServer, D as DocumentConfig } from './document-DeTPGBil.js';
2
+ import { M as MossServer, D as DocumentConfig } from './document-AbQUbQaP.js';
3
3
  import 'hono';
4
4
  import '@niscorp/charter';
5
5
  import '@niscorp/nova';
6
6
  import '@niscorp/vex';
7
+ import '@niscorp/strata';
8
+ import '@niscorp/nova/i18n';
9
+ import './index-Dml1klpZ.js';
10
+ import '@niscorp/strata/postgres';
11
+ import 'zod';
7
12
  import './socket-D90h1xSV.js';
8
13
  import '@niscorp/nova/document';
9
14
 
package/dist/vite.js CHANGED
@@ -1,7 +1,7 @@
1
- import { MOSS_PATHS, listenForUpgrades, createTransport } from './chunk-WKBH3UMB.js';
2
- import { sessionCookies, renderDocument } from './chunk-V5YMJL7Z.js';
3
- import './chunk-PWUO4RET.js';
4
- import './chunk-NSK7QSSG.js';
1
+ import { MOSS_PATHS, listenForUpgrades, createTransport } from './chunk-X2Q546EB.js';
2
+ import { sessionCookies, renderDocument } from './chunk-MTC46PGQ.js';
3
+ import './chunk-MYGVHWS5.js';
4
+ import './chunk-IMZZB4JE.js';
5
5
  import './chunk-4ZGAFZGS.js';
6
6
  import { readFile } from 'fs/promises';
7
7
  import { BlockList, isIPv4, isIPv6 } from 'net';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@niscorp/moss",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "moss — the nisc app server: serves existence (catalog, scoped vex, the socket), derived from artifacts",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -212,12 +212,12 @@
212
212
  "zod": "^4.2.0",
213
213
  "vue": "^3.5.0",
214
214
  "vite": ">=6",
215
- "@niscorp/prism": "^0.3.0",
216
- "@niscorp/tide": "^0.1.6",
217
- "@niscorp/strata": "^0.1.6",
218
- "@niscorp/nova": "^0.3.0",
219
- "@niscorp/vex": "^0.3.0",
220
- "@niscorp/charter": "^0.1.3"
215
+ "@niscorp/strata": "^0.1.7",
216
+ "@niscorp/charter": "^0.1.4",
217
+ "@niscorp/tide": "^0.1.7",
218
+ "@niscorp/nova": "^0.4.0",
219
+ "@niscorp/vex": "^0.4.0",
220
+ "@niscorp/prism": "^0.3.1"
221
221
  },
222
222
  "peerDependenciesMeta": {
223
223
  "@niscorp/tide": {
@@ -255,12 +255,12 @@
255
255
  "vitest": "^4.1.2",
256
256
  "vue": "^3.5.43",
257
257
  "zod": "^4.6.5",
258
- "@niscorp/nova": "^0.3.0",
259
- "@niscorp/strata": "^0.1.6",
260
- "@niscorp/vex": "^0.3.0",
261
- "@niscorp/prism": "^0.3.0",
262
- "@niscorp/tide": "^0.1.6",
263
- "@niscorp/charter": "^0.1.3"
258
+ "@niscorp/charter": "^0.1.4",
259
+ "@niscorp/nova": "^0.4.0",
260
+ "@niscorp/strata": "^0.1.7",
261
+ "@niscorp/prism": "^0.3.1",
262
+ "@niscorp/tide": "^0.1.7",
263
+ "@niscorp/vex": "^0.4.0"
264
264
  },
265
265
  "scripts": {
266
266
  "build": "node -e \"fs.rmSync('dist',{recursive:true,force:true})\" && tsup",
@@ -1,143 +0,0 @@
1
- import { Sequence } from '@niscorp/strata';
2
- import { GenerateDsl, MapToShape, QueryResponse, ScopeBehaviors, SeedEntry, SeedMutation } from '@niscorp/vex';
3
- import { Charter } from '@niscorp/charter';
4
- import { Shell, FetchFn, LayoutNode, ActionDefinition, CanvasConfig, ActionFragment, FunctionHandler } from '@niscorp/nova';
5
- import { Phrasebook, PhraseKeys } from '@niscorp/nova/i18n';
6
- import { F as Feature } from './index-B411sK9M.js';
7
- import { I as IdentityRecord } from './document-DeTPGBil.js';
8
-
9
- type LayoutVariant = {
10
- action: string;
11
- layout: LayoutNode;
12
- };
13
- type NiscApp = {
14
- charter: Charter;
15
- assignments?: Record<string, readonly string[]>;
16
- wearable?: readonly (readonly string[])[];
17
- actions: Record<string, ActionDefinition>;
18
- layouts?: Record<string, LayoutVariant>;
19
- behaviors?: ScopeBehaviors;
20
- scope?: (principal: string | null, identity?: IdentityRecord) => Record<string, unknown>;
21
- identity?: {
22
- as?: string;
23
- resolve: (principal: string, read: (fingerprint: string, scope: Record<string, unknown>) => Promise<unknown>) => Promise<IdentityRecord>;
24
- };
25
- phrases?: (session: {
26
- principal: string | null;
27
- identity: Record<string, unknown>;
28
- wire: FetchFn;
29
- }) => Phrasebook | undefined | Promise<Phrasebook | undefined>;
30
- phraseKeys?: PhraseKeys;
31
- features?: readonly Feature[];
32
- entries?: readonly (SeedEntry | SeedMutation)[];
33
- resources?: Record<string, readonly string[] | {
34
- entities: readonly string[];
35
- }>;
36
- shell?: ShellManifest;
37
- pages?: Record<string, PageManifest>;
38
- grammars?: readonly Sequence[];
39
- functions?: (session: FunctionSession) => Record<string, FunctionHandler>;
40
- onSession?: (session: FunctionSession) => void;
41
- runs?: RunSink;
42
- reactions?: readonly {
43
- table: string;
44
- op?: 'insert' | 'update' | 'delete';
45
- run: (event: {
46
- fingerprint: string;
47
- table: string;
48
- op: 'insert' | 'update' | 'delete';
49
- count: number;
50
- scope: Record<string, unknown>;
51
- }, tools: {
52
- deliver: (principal: string, channel: string, payload?: unknown) => boolean;
53
- }) => void;
54
- }[];
55
- };
56
- type RunTurn = {
57
- role: 'system' | 'user' | 'assistant' | 'tool';
58
- content: string;
59
- calls?: ReadonlyArray<{
60
- name: string;
61
- args: string;
62
- }>;
63
- name?: string;
64
- };
65
- type RunRecord = {
66
- at: number;
67
- principal: string | null;
68
- shellId: string;
69
- agentId: string;
70
- agentPath: readonly string[];
71
- label: string;
72
- provider: string;
73
- model: string;
74
- inputTokens: number;
75
- outputTokens: number;
76
- totalTokens: number;
77
- reported: boolean;
78
- steps: number;
79
- elapsedMs: number;
80
- turns?: readonly RunTurn[];
81
- response?: string;
82
- outcome: 'ok' | 'failed';
83
- };
84
- type RunSink = (record: RunRecord, session: FunctionSession) => void;
85
- type FunctionSession = {
86
- shell: Shell;
87
- principal: string | null;
88
- roles: readonly string[];
89
- identity: Record<string, unknown>;
90
- actions: readonly string[];
91
- wire: FetchFn;
92
- grant: (token: string) => void;
93
- revoke: () => Promise<void>;
94
- answerIntent: (writers: {
95
- generateDsl: GenerateDsl;
96
- mapToShape: MapToShape;
97
- }, asked: {
98
- intent: string;
99
- shape: unknown;
100
- context?: Record<string, unknown>;
101
- }) => Promise<QueryResponse>;
102
- recordRun: (run: Omit<RunRecord, 'at' | 'principal' | 'shellId'>) => void;
103
- };
104
- type CanvasSeed = string | {
105
- action: string;
106
- input?: Record<string, unknown>;
107
- with?: string[];
108
- };
109
- type ShellCanvas = Omit<CanvasConfig, 'initial'> & {
110
- initial?: CanvasSeed | CanvasSeed[];
111
- };
112
- type ShellManifest = {
113
- canvases: ShellCanvas[];
114
- layout?: LayoutNode;
115
- layoutStore?: Record<string, LayoutNode>;
116
- fragments?: Record<string, ActionFragment>;
117
- seeds?: (session: {
118
- principal: string | null;
119
- actions: readonly string[];
120
- roles: readonly string[];
121
- wire: FetchFn;
122
- }) => Promise<Record<string, CanvasSeed[]>> | Record<string, CanvasSeed[]>;
123
- components?: Record<string, {
124
- meta?: {
125
- description?: string;
126
- propsSchema?: unknown;
127
- };
128
- }>;
129
- inputs?: (session: {
130
- principal: string | null;
131
- actions: readonly string[];
132
- roles: readonly string[];
133
- identity: Record<string, unknown>;
134
- wire: FetchFn;
135
- }) => Record<string, Record<string, unknown>> | Promise<Record<string, Record<string, unknown>>>;
136
- };
137
- type PageManifest = ShellManifest & {
138
- path: string;
139
- params?: string;
140
- };
141
- declare const defineApp: (app: NiscApp) => NiscApp;
142
-
143
- export { type FunctionSession as F, type LayoutVariant as L, type NiscApp as N, type PageManifest as P, type RunRecord as R, type ShellManifest as S, type RunSink as a, type RunTurn as b, defineApp as d };
@@ -1,143 +0,0 @@
1
- import { Sequence } from '@niscorp/strata';
2
- import { GenerateDsl, MapToShape, QueryResponse, ScopeBehaviors, SeedEntry, SeedMutation } from '@niscorp/vex';
3
- import { Charter } from '@niscorp/charter';
4
- import { Shell, FetchFn, LayoutNode, ActionDefinition, CanvasConfig, ActionFragment, FunctionHandler } from '@niscorp/nova';
5
- import { Phrasebook, PhraseKeys } from '@niscorp/nova/i18n';
6
- import { F as Feature } from './index-B411sK9M.cjs';
7
- import { I as IdentityRecord } from './document-D7nroBww.cjs';
8
-
9
- type LayoutVariant = {
10
- action: string;
11
- layout: LayoutNode;
12
- };
13
- type NiscApp = {
14
- charter: Charter;
15
- assignments?: Record<string, readonly string[]>;
16
- wearable?: readonly (readonly string[])[];
17
- actions: Record<string, ActionDefinition>;
18
- layouts?: Record<string, LayoutVariant>;
19
- behaviors?: ScopeBehaviors;
20
- scope?: (principal: string | null, identity?: IdentityRecord) => Record<string, unknown>;
21
- identity?: {
22
- as?: string;
23
- resolve: (principal: string, read: (fingerprint: string, scope: Record<string, unknown>) => Promise<unknown>) => Promise<IdentityRecord>;
24
- };
25
- phrases?: (session: {
26
- principal: string | null;
27
- identity: Record<string, unknown>;
28
- wire: FetchFn;
29
- }) => Phrasebook | undefined | Promise<Phrasebook | undefined>;
30
- phraseKeys?: PhraseKeys;
31
- features?: readonly Feature[];
32
- entries?: readonly (SeedEntry | SeedMutation)[];
33
- resources?: Record<string, readonly string[] | {
34
- entities: readonly string[];
35
- }>;
36
- shell?: ShellManifest;
37
- pages?: Record<string, PageManifest>;
38
- grammars?: readonly Sequence[];
39
- functions?: (session: FunctionSession) => Record<string, FunctionHandler>;
40
- onSession?: (session: FunctionSession) => void;
41
- runs?: RunSink;
42
- reactions?: readonly {
43
- table: string;
44
- op?: 'insert' | 'update' | 'delete';
45
- run: (event: {
46
- fingerprint: string;
47
- table: string;
48
- op: 'insert' | 'update' | 'delete';
49
- count: number;
50
- scope: Record<string, unknown>;
51
- }, tools: {
52
- deliver: (principal: string, channel: string, payload?: unknown) => boolean;
53
- }) => void;
54
- }[];
55
- };
56
- type RunTurn = {
57
- role: 'system' | 'user' | 'assistant' | 'tool';
58
- content: string;
59
- calls?: ReadonlyArray<{
60
- name: string;
61
- args: string;
62
- }>;
63
- name?: string;
64
- };
65
- type RunRecord = {
66
- at: number;
67
- principal: string | null;
68
- shellId: string;
69
- agentId: string;
70
- agentPath: readonly string[];
71
- label: string;
72
- provider: string;
73
- model: string;
74
- inputTokens: number;
75
- outputTokens: number;
76
- totalTokens: number;
77
- reported: boolean;
78
- steps: number;
79
- elapsedMs: number;
80
- turns?: readonly RunTurn[];
81
- response?: string;
82
- outcome: 'ok' | 'failed';
83
- };
84
- type RunSink = (record: RunRecord, session: FunctionSession) => void;
85
- type FunctionSession = {
86
- shell: Shell;
87
- principal: string | null;
88
- roles: readonly string[];
89
- identity: Record<string, unknown>;
90
- actions: readonly string[];
91
- wire: FetchFn;
92
- grant: (token: string) => void;
93
- revoke: () => Promise<void>;
94
- answerIntent: (writers: {
95
- generateDsl: GenerateDsl;
96
- mapToShape: MapToShape;
97
- }, asked: {
98
- intent: string;
99
- shape: unknown;
100
- context?: Record<string, unknown>;
101
- }) => Promise<QueryResponse>;
102
- recordRun: (run: Omit<RunRecord, 'at' | 'principal' | 'shellId'>) => void;
103
- };
104
- type CanvasSeed = string | {
105
- action: string;
106
- input?: Record<string, unknown>;
107
- with?: string[];
108
- };
109
- type ShellCanvas = Omit<CanvasConfig, 'initial'> & {
110
- initial?: CanvasSeed | CanvasSeed[];
111
- };
112
- type ShellManifest = {
113
- canvases: ShellCanvas[];
114
- layout?: LayoutNode;
115
- layoutStore?: Record<string, LayoutNode>;
116
- fragments?: Record<string, ActionFragment>;
117
- seeds?: (session: {
118
- principal: string | null;
119
- actions: readonly string[];
120
- roles: readonly string[];
121
- wire: FetchFn;
122
- }) => Promise<Record<string, CanvasSeed[]>> | Record<string, CanvasSeed[]>;
123
- components?: Record<string, {
124
- meta?: {
125
- description?: string;
126
- propsSchema?: unknown;
127
- };
128
- }>;
129
- inputs?: (session: {
130
- principal: string | null;
131
- actions: readonly string[];
132
- roles: readonly string[];
133
- identity: Record<string, unknown>;
134
- wire: FetchFn;
135
- }) => Record<string, Record<string, unknown>> | Promise<Record<string, Record<string, unknown>>>;
136
- };
137
- type PageManifest = ShellManifest & {
138
- path: string;
139
- params?: string;
140
- };
141
- declare const defineApp: (app: NiscApp) => NiscApp;
142
-
143
- export { type FunctionSession as F, type LayoutVariant as L, type NiscApp as N, type PageManifest as P, type RunRecord as R, type ShellManifest as S, type RunSink as a, type RunTurn as b, defineApp as d };
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/runtime/runtime.ts"],"names":[],"mappings":";;;AAsDO,IAAM,YAAY,CAAC,SAAA,KACxB,cAAc,MAAA,GACV,MAAA,GACA,CAAC,IAAA,KAAS;AACR,EAAA,IAAI;AACF,IAAA,SAAA,CAAU,KAAK,IAAI,CAAA;AAAA,EACrB,SAAS,GAAA,EAAK;AACZ,IAAA,OAAA,CAAQ,KAAA,CAAM,oBAAoB,GAAG,CAAA;AAAA,EACvC;AACF;AAIN,IAAM,YAAA,GAAe,MAAe,OAAO,WAAA,KAAgB,cAAc,WAAA,CAAY,GAAA,EAAI,GAAI,IAAA,CAAK,GAAA,EAAI;AAE/F,IAAM,YAAY,MAAiB;AACxC,EAAA,MAAM,aAAA,GAAgB,IAAA,CAAK,GAAA,EAAI,GAAI,GAAA;AACnC,EAAA,MAAM,KAAK,YAAA,EAAa;AACxB,EAAA,OAAO,EAAE,eAAe,WAAA,EAAa,MAAM,iBAAiB,YAAA,EAAa,GAAI,MAAM,GAAA,EAAI;AACzF;AAEA,IAAM,KAAA,GAAQ,EAAE,MAAA,EAAQ,CAAA,CAAE,QAAO,EAAE;AAE5B,IAAM,mBAAA,GAAsB,CAAA,CAAE,kBAAA,CAAmB,MAAA,EAAQ;AAAA,EAC9D,CAAA,CAAE,YAAA,CAAa,EAAE,IAAA,EAAM,EAAE,OAAA,CAAQ,qBAAqB,CAAA,EAAG,SAAA,EAAW,CAAA,CAAE,MAAA,EAAO,EAAG,GAAG,OAAO,CAAA;AAAA,EAC1F,CAAA,CAAE,YAAA,CAAa,EAAE,IAAA,EAAM,EAAE,OAAA,CAAQ,gBAAgB,CAAA,EAAG,GAAA,EAAK,CAAA,CAAE,MAAA,EAAO,EAAG,GAAG,OAAO,CAAA;AAAA,EAC/E,EAAE,YAAA,CAAa,EAAE,MAAM,CAAA,CAAE,OAAA,CAAQ,OAAO,CAAA,EAAG,SAAA,EAAW,CAAA,CAAE,MAAA,IAAU,OAAA,EAAS,CAAA,CAAE,QAAO,EAAG,GAAG,OAAO;AACnG,CAAC","file":"chunk-NSK7QSSG.js","sourcesContent":["import type { Context, Next } from 'hono';\nimport type { CacheBackend, MutationClient, PgPool, QueryEngineConfig } from '@niscorp/vex';\nimport type { Sequence } from '@niscorp/strata';\nimport { z } from 'zod';\n\nexport type SessionVerifier = (token: string) => string | null | Promise<string | null>;\n\nexport type NiscRuntime = {\n pool: PgPool;\n db: MutationClient;\n cache?: CacheBackend;\n vexConfig?: QueryEngineConfig['config'];\n session: SessionVerifier | 'sessions' | 'dev-open';\n origins?: readonly string[];\n migrations?: 'apply' | 'verify';\n tables?: readonly Sequence[];\n shellIdleMs?: number;\n anonymousShellMax?: number;\n endpointTimeoutMs?: number;\n sessionRevalidateMs?: number;\n identityMax?: number;\n identityIdleMs?: number;\n shellFrameDelta?: boolean;\n socketCompression?: boolean | Record<string, unknown>;\n socketMaxMessageBytes?: number;\n operatorKey?: string;\n\n operatorGate?: (c: Context, next: Next) => Response | void | Promise<Response | void>;\n\n fabric?: Fabric;\n\n telemetry?: Telemetry;\n};\n\nexport type TelemetrySpan = {\n name: string;\n // A JS number cannot hold epoch nanoseconds exactly: the loss is far below\n // the milliseconds measured here.\n startUnixNano: number;\n endUnixNano: number;\n status: 'ok' | 'error' | 'refused';\n // Identifiers and measurements only: never a payload, a name, or who a principal is.\n attributes: Record<string, string | number | boolean>;\n traceId?: string;\n spanId?: string;\n parentSpanId?: string;\n};\n\nexport type Telemetry = {\n emit: (span: TelemetrySpan) => void;\n};\n\nexport type Emit = (span: TelemetrySpan) => void;\n\nexport const emitterOf = (telemetry: Telemetry | undefined): Emit | undefined =>\n telemetry === undefined\n ? undefined\n : (span) => {\n try {\n telemetry.emit(span);\n } catch (err) {\n console.error('[moss:telemetry]', err);\n }\n };\n\nexport type SpanClock = { startUnixNano: number; endUnixNano: () => number };\n\nconst elapsedClock = (): number => (typeof performance !== 'undefined' ? performance.now() : Date.now());\n\nexport const spanClock = (): SpanClock => {\n const startUnixNano = Date.now() * 1e6;\n const t0 = elapsedClock();\n return { startUnixNano, endUnixNano: () => startUnixNano + (elapsedClock() - t0) * 1e6 };\n};\n\nconst stamp = { origin: z.string() };\n\nexport const FabricMessageSchema = z.discriminatedUnion('kind', [\n z.strictObject({ kind: z.literal('invalidate-identity'), principal: z.string(), ...stamp }),\n z.strictObject({ kind: z.literal('invalidate-tag'), tag: z.string(), ...stamp }),\n z.strictObject({ kind: z.literal('nudge'), principal: z.string(), channel: z.string(), ...stamp }),\n]);\n\nexport type FabricMessage = z.infer<typeof FabricMessageSchema>;\n\ntype Unstamped<Message> = Message extends unknown ? Omit<Message, 'origin'> : never;\nexport type FabricSignal = Unstamped<FabricMessage>;\n\nexport type Fabric = {\n publish: (message: FabricMessage) => void;\n subscribe: (apply: (message: unknown) => void) => void;\n};\n"]}