@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.
- package/CHANGELOG.md +100 -0
- package/DESIGN.md +77 -40
- package/DOCS.md +636 -78
- package/README.md +2 -2
- package/dist/{chunk-VBWNHF4H.cjs → chunk-C2DNDIQX.cjs} +4 -3
- package/dist/chunk-C2DNDIQX.cjs.map +1 -0
- package/dist/{chunk-R66WUKGC.cjs → chunk-DSTHFSTO.cjs} +1988 -1328
- package/dist/chunk-DSTHFSTO.cjs.map +1 -0
- package/dist/chunk-F45SFR7W.cjs +903 -0
- package/dist/chunk-F45SFR7W.cjs.map +1 -0
- package/dist/{chunk-NSK7QSSG.js → chunk-IMZZB4JE.js} +4 -3
- package/dist/chunk-IMZZB4JE.js.map +1 -0
- package/dist/{chunk-V5YMJL7Z.js → chunk-MTC46PGQ.js} +1971 -1309
- package/dist/chunk-MTC46PGQ.js.map +1 -0
- package/dist/chunk-MYGVHWS5.js +870 -0
- package/dist/chunk-MYGVHWS5.js.map +1 -0
- package/dist/{chunk-WKBH3UMB.js → chunk-X2Q546EB.js} +3 -3
- package/dist/{chunk-WKBH3UMB.js.map → chunk-X2Q546EB.js.map} +1 -1
- package/dist/{chunk-D3YZIAYV.cjs → chunk-Z2VA6AOE.cjs} +5 -5
- package/dist/{chunk-D3YZIAYV.cjs.map → chunk-Z2VA6AOE.cjs.map} +1 -1
- package/dist/document-AbQUbQaP.d.ts +381 -0
- package/dist/document-wHHxIXJz.d.cts +381 -0
- package/dist/{index-B411sK9M.d.cts → index-Dml1klpZ.d.cts} +4 -0
- package/dist/{index-B411sK9M.d.ts → index-Dml1klpZ.d.ts} +4 -0
- package/dist/index.cjs +17 -17
- package/dist/index.d.cts +7 -9
- package/dist/index.d.ts +7 -9
- package/dist/index.js +3 -3
- package/dist/integrations.cjs +3 -3
- package/dist/integrations.d.cts +1 -1
- package/dist/integrations.d.ts +1 -1
- package/dist/integrations.js +1 -1
- package/dist/node.cjs +8 -8
- package/dist/node.d.cts +3 -4
- package/dist/node.d.ts +3 -4
- package/dist/node.js +4 -4
- package/dist/tide.d.cts +1 -1
- package/dist/tide.d.ts +1 -1
- package/dist/unverified.cjs +3 -3
- package/dist/unverified.js +2 -2
- package/dist/vite.cjs +9 -9
- package/dist/vite.d.cts +6 -1
- package/dist/vite.d.ts +6 -1
- package/dist/vite.js +4 -4
- package/package.json +13 -13
- package/dist/app-CUnDcXQu.d.ts +0 -143
- package/dist/app-CdANzi2q.d.cts +0 -143
- package/dist/chunk-NSK7QSSG.js.map +0 -1
- package/dist/chunk-PWUO4RET.js +0 -374
- package/dist/chunk-PWUO4RET.js.map +0 -1
- package/dist/chunk-R2YPQHQH.cjs +0 -383
- package/dist/chunk-R2YPQHQH.cjs.map +0 -1
- package/dist/chunk-R66WUKGC.cjs.map +0 -1
- package/dist/chunk-V5YMJL7Z.js.map +0 -1
- package/dist/chunk-VBWNHF4H.cjs.map +0 -1
- package/dist/document-D7nroBww.d.cts +0 -169
- package/dist/document-DeTPGBil.d.ts +0 -169
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
import { Hono } from 'hono';
|
|
2
|
+
import { Charter, VerifyReport } from '@niscorp/charter';
|
|
3
|
+
import { FunctionHandler, Shell, FetchFn, LayoutNode, ActionDefinition, CanvasConfig, ActionFragment, RenderNode } from '@niscorp/nova';
|
|
4
|
+
import { GenerateDsl, MapToShape, QueryResponse, ScopeBehaviors, SeedEntry, SeedMutation, ScopePolicy } from '@niscorp/vex';
|
|
5
|
+
import { Sequence } from '@niscorp/strata';
|
|
6
|
+
import { Phrasebook, PhraseKeys } from '@niscorp/nova/i18n';
|
|
7
|
+
import { F as Feature } from './index-Dml1klpZ.js';
|
|
8
|
+
import { S as SocketAccept } from './socket-D90h1xSV.js';
|
|
9
|
+
import { ScreenHead } from '@niscorp/nova/document';
|
|
10
|
+
|
|
11
|
+
type IdentityReport = {
|
|
12
|
+
principal: string;
|
|
13
|
+
since: number;
|
|
14
|
+
lastSeen: number;
|
|
15
|
+
};
|
|
16
|
+
type IdentityRecord = {
|
|
17
|
+
roles: readonly string[];
|
|
18
|
+
scope: Record<string, unknown>;
|
|
19
|
+
installed?: readonly string[];
|
|
20
|
+
tag?: string;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
type ResolvedIdentity = {
|
|
24
|
+
roles: readonly string[];
|
|
25
|
+
scope: Record<string, unknown>;
|
|
26
|
+
installed: readonly string[] | undefined;
|
|
27
|
+
memoKey: string;
|
|
28
|
+
record?: IdentityRecord;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
type LayoutVariant = {
|
|
32
|
+
action: string;
|
|
33
|
+
layout: LayoutNode;
|
|
34
|
+
};
|
|
35
|
+
type FunctionDefinition = {
|
|
36
|
+
id: string;
|
|
37
|
+
description: string;
|
|
38
|
+
execute: FunctionHandler;
|
|
39
|
+
};
|
|
40
|
+
type WrittenFunctions = readonly FunctionDefinition[] | Record<string, FunctionHandler>;
|
|
41
|
+
type NiscApp = {
|
|
42
|
+
charter: Charter;
|
|
43
|
+
assignments?: Record<string, readonly string[]>;
|
|
44
|
+
wearable?: readonly (readonly string[])[];
|
|
45
|
+
actions: Record<string, ActionDefinition>;
|
|
46
|
+
layouts?: Record<string, LayoutVariant>;
|
|
47
|
+
behaviors?: ScopeBehaviors;
|
|
48
|
+
scope?: (principal: string | null, identity?: IdentityRecord) => Record<string, unknown>;
|
|
49
|
+
identity?: {
|
|
50
|
+
as?: string;
|
|
51
|
+
resolve: (principal: string, read: (fingerprint: string, scope: Record<string, unknown>) => Promise<unknown>) => Promise<IdentityRecord>;
|
|
52
|
+
};
|
|
53
|
+
phrases?: (session: {
|
|
54
|
+
principal: string | null;
|
|
55
|
+
identity: Record<string, unknown>;
|
|
56
|
+
wire: FetchFn;
|
|
57
|
+
}) => Phrasebook | undefined | Promise<Phrasebook | undefined>;
|
|
58
|
+
phraseKeys?: PhraseKeys;
|
|
59
|
+
features?: readonly Feature[];
|
|
60
|
+
entries?: readonly (SeedEntry | SeedMutation)[];
|
|
61
|
+
resources?: Record<string, readonly string[] | {
|
|
62
|
+
entities: readonly string[];
|
|
63
|
+
}>;
|
|
64
|
+
shell?: ShellManifest;
|
|
65
|
+
pages?: Record<string, PageManifest>;
|
|
66
|
+
grammars?: readonly Sequence[];
|
|
67
|
+
functions?: (session: FunctionSession) => WrittenFunctions;
|
|
68
|
+
onSession?: (session: FunctionSession) => void;
|
|
69
|
+
runs?: RunSink;
|
|
70
|
+
reactions?: readonly {
|
|
71
|
+
table: string;
|
|
72
|
+
op?: 'insert' | 'update' | 'delete';
|
|
73
|
+
run: (event: {
|
|
74
|
+
fingerprint: string;
|
|
75
|
+
table: string;
|
|
76
|
+
op: 'insert' | 'update' | 'delete';
|
|
77
|
+
count: number;
|
|
78
|
+
scope: Record<string, unknown>;
|
|
79
|
+
}, tools: {
|
|
80
|
+
deliver: (principal: string, channel: string, payload?: unknown) => boolean;
|
|
81
|
+
}) => void;
|
|
82
|
+
}[];
|
|
83
|
+
};
|
|
84
|
+
type RunTurn = {
|
|
85
|
+
role: 'system' | 'user' | 'assistant' | 'tool';
|
|
86
|
+
content: string;
|
|
87
|
+
calls?: ReadonlyArray<{
|
|
88
|
+
name: string;
|
|
89
|
+
args: string;
|
|
90
|
+
}>;
|
|
91
|
+
name?: string;
|
|
92
|
+
};
|
|
93
|
+
type RunRecord = {
|
|
94
|
+
at: number;
|
|
95
|
+
principal: string | null;
|
|
96
|
+
shellId: string;
|
|
97
|
+
agentId: string;
|
|
98
|
+
agentPath: readonly string[];
|
|
99
|
+
label: string;
|
|
100
|
+
provider: string;
|
|
101
|
+
model: string;
|
|
102
|
+
inputTokens: number;
|
|
103
|
+
outputTokens: number;
|
|
104
|
+
totalTokens: number;
|
|
105
|
+
reported: boolean;
|
|
106
|
+
steps: number;
|
|
107
|
+
elapsedMs: number;
|
|
108
|
+
turns?: readonly RunTurn[];
|
|
109
|
+
response?: string;
|
|
110
|
+
outcome: 'ok' | 'failed';
|
|
111
|
+
};
|
|
112
|
+
type RunSink = (record: RunRecord, session: FunctionSession) => void;
|
|
113
|
+
type ArtifactKind = 'layout' | 'action' | 'fragment' | 'read';
|
|
114
|
+
type ArtifactVersion = {
|
|
115
|
+
kind: ArtifactKind;
|
|
116
|
+
id: string;
|
|
117
|
+
save: string;
|
|
118
|
+
createdAt: string;
|
|
119
|
+
copiedFrom: string | null;
|
|
120
|
+
body: unknown;
|
|
121
|
+
};
|
|
122
|
+
type SessionArtifacts = {
|
|
123
|
+
save: (artifacts: readonly {
|
|
124
|
+
kind: ArtifactKind;
|
|
125
|
+
id?: string;
|
|
126
|
+
body: unknown;
|
|
127
|
+
}[]) => Promise<{
|
|
128
|
+
save: string;
|
|
129
|
+
artifacts: readonly {
|
|
130
|
+
kind: ArtifactKind;
|
|
131
|
+
id: string;
|
|
132
|
+
}[];
|
|
133
|
+
}>;
|
|
134
|
+
list: (kind?: ArtifactKind) => Promise<readonly ArtifactVersion[]>;
|
|
135
|
+
history: (kind: ArtifactKind, id: string) => Promise<readonly ArtifactVersion[]>;
|
|
136
|
+
restore: (kind: ArtifactKind, id: string, save: string) => Promise<{
|
|
137
|
+
save: string;
|
|
138
|
+
}>;
|
|
139
|
+
reset: (kind: ArtifactKind, id: string) => Promise<{
|
|
140
|
+
save: string;
|
|
141
|
+
}>;
|
|
142
|
+
};
|
|
143
|
+
type DraftArtifact = {
|
|
144
|
+
kind: ArtifactKind;
|
|
145
|
+
id: string;
|
|
146
|
+
body: unknown;
|
|
147
|
+
};
|
|
148
|
+
type SessionDraft = {
|
|
149
|
+
put: (artifacts: readonly {
|
|
150
|
+
kind: ArtifactKind;
|
|
151
|
+
id?: string;
|
|
152
|
+
body: unknown;
|
|
153
|
+
}[]) => Promise<{
|
|
154
|
+
step: number;
|
|
155
|
+
artifacts: readonly {
|
|
156
|
+
kind: ArtifactKind;
|
|
157
|
+
id: string;
|
|
158
|
+
}[];
|
|
159
|
+
}>;
|
|
160
|
+
list: () => readonly DraftArtifact[];
|
|
161
|
+
remove: (kind: ArtifactKind, id: string) => Promise<{
|
|
162
|
+
step: number;
|
|
163
|
+
}>;
|
|
164
|
+
show: (step: number) => Promise<void>;
|
|
165
|
+
discard: () => Promise<void>;
|
|
166
|
+
save: () => Promise<{
|
|
167
|
+
save: string;
|
|
168
|
+
artifacts: readonly {
|
|
169
|
+
kind: ArtifactKind;
|
|
170
|
+
id: string;
|
|
171
|
+
}[];
|
|
172
|
+
}>;
|
|
173
|
+
};
|
|
174
|
+
type FunctionSession = {
|
|
175
|
+
shell: Shell;
|
|
176
|
+
artifacts: SessionArtifacts;
|
|
177
|
+
draft: SessionDraft;
|
|
178
|
+
principal: string | null;
|
|
179
|
+
roles: readonly string[];
|
|
180
|
+
identity: Record<string, unknown>;
|
|
181
|
+
actions: readonly string[];
|
|
182
|
+
wire: FetchFn;
|
|
183
|
+
grant: (token: string) => void;
|
|
184
|
+
revoke: () => Promise<void>;
|
|
185
|
+
answerIntent: (writers: {
|
|
186
|
+
generateDsl: GenerateDsl;
|
|
187
|
+
mapToShape: MapToShape;
|
|
188
|
+
}, asked: {
|
|
189
|
+
intent: string;
|
|
190
|
+
shape: unknown;
|
|
191
|
+
context?: Record<string, unknown>;
|
|
192
|
+
}) => Promise<QueryResponse>;
|
|
193
|
+
recordRun: (run: Omit<RunRecord, 'at' | 'principal' | 'shellId'>) => void;
|
|
194
|
+
functions: () => readonly {
|
|
195
|
+
id: string;
|
|
196
|
+
description?: string;
|
|
197
|
+
}[];
|
|
198
|
+
};
|
|
199
|
+
type CanvasSeed = string | {
|
|
200
|
+
action: string;
|
|
201
|
+
input?: Record<string, unknown>;
|
|
202
|
+
with?: string[];
|
|
203
|
+
};
|
|
204
|
+
type ShellCanvas = Omit<CanvasConfig, 'initial'> & {
|
|
205
|
+
initial?: CanvasSeed | CanvasSeed[];
|
|
206
|
+
};
|
|
207
|
+
type ShellManifest = {
|
|
208
|
+
canvases: ShellCanvas[];
|
|
209
|
+
layout?: LayoutNode;
|
|
210
|
+
layoutStore?: Record<string, LayoutNode>;
|
|
211
|
+
fragments?: Record<string, ActionFragment>;
|
|
212
|
+
seeds?: (session: {
|
|
213
|
+
principal: string | null;
|
|
214
|
+
actions: readonly string[];
|
|
215
|
+
roles: readonly string[];
|
|
216
|
+
wire: FetchFn;
|
|
217
|
+
}) => Promise<Record<string, CanvasSeed[]>> | Record<string, CanvasSeed[]>;
|
|
218
|
+
components?: Record<string, {
|
|
219
|
+
meta?: {
|
|
220
|
+
description?: string;
|
|
221
|
+
propsSchema?: unknown;
|
|
222
|
+
};
|
|
223
|
+
}>;
|
|
224
|
+
inputs?: (session: {
|
|
225
|
+
principal: string | null;
|
|
226
|
+
actions: readonly string[];
|
|
227
|
+
roles: readonly string[];
|
|
228
|
+
identity: Record<string, unknown>;
|
|
229
|
+
wire: FetchFn;
|
|
230
|
+
}) => Record<string, Record<string, unknown>> | Promise<Record<string, Record<string, unknown>>>;
|
|
231
|
+
};
|
|
232
|
+
type PageManifest = ShellManifest & {
|
|
233
|
+
path: string;
|
|
234
|
+
params?: string;
|
|
235
|
+
};
|
|
236
|
+
declare const defineApp: (app: NiscApp) => NiscApp;
|
|
237
|
+
|
|
238
|
+
type ExecuteAs = (role: string, fingerprint: string, context: Record<string, unknown>, scope?: Record<string, unknown>) => Promise<unknown>;
|
|
239
|
+
|
|
240
|
+
type Catalog = {
|
|
241
|
+
ids: readonly string[];
|
|
242
|
+
hash: string;
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
type ShellConnection = {
|
|
246
|
+
send: (text: string) => void;
|
|
247
|
+
close: (code?: number, reason?: string) => void;
|
|
248
|
+
seal?: (token: string) => Promise<string>;
|
|
249
|
+
};
|
|
250
|
+
type ShellSession = {
|
|
251
|
+
readonly shell: Shell;
|
|
252
|
+
attach: (connection: ShellConnection, options?: {
|
|
253
|
+
delta?: boolean;
|
|
254
|
+
}) => void;
|
|
255
|
+
detach: (connection: ShellConnection) => void;
|
|
256
|
+
resync: (connection: ShellConnection) => void;
|
|
257
|
+
dispatch: (canvas: string, event: Record<string, unknown>) => void;
|
|
258
|
+
publish: (channel: string, payload?: unknown) => void;
|
|
259
|
+
back: () => boolean;
|
|
260
|
+
popTo: (canvas: string, instance: string) => void;
|
|
261
|
+
reset: () => void;
|
|
262
|
+
};
|
|
263
|
+
type ShellReport = {
|
|
264
|
+
principal: string;
|
|
265
|
+
connections: number;
|
|
266
|
+
since: number;
|
|
267
|
+
idleSince: number | null;
|
|
268
|
+
canvases: {
|
|
269
|
+
id: string;
|
|
270
|
+
actions: readonly string[];
|
|
271
|
+
}[];
|
|
272
|
+
};
|
|
273
|
+
type ShellSnapshot = {
|
|
274
|
+
frame: RenderNode[];
|
|
275
|
+
trees: Record<string, RenderNode[]>;
|
|
276
|
+
seed?: string;
|
|
277
|
+
settled: boolean;
|
|
278
|
+
live: boolean;
|
|
279
|
+
why: string[];
|
|
280
|
+
drawnWith: string[];
|
|
281
|
+
};
|
|
282
|
+
type ShellOpening = {
|
|
283
|
+
seed?: string;
|
|
284
|
+
inputs?: Record<string, Record<string, unknown>>;
|
|
285
|
+
};
|
|
286
|
+
type ShellHost = {
|
|
287
|
+
session: (token: string | null, principal: string | null, options?: ShellOpening) => Promise<ShellSession>;
|
|
288
|
+
snapshot: (token: string | null, principal: string | null, options?: {
|
|
289
|
+
waitMs?: number;
|
|
290
|
+
inputs?: ShellOpening['inputs'];
|
|
291
|
+
}) => Promise<ShellSnapshot>;
|
|
292
|
+
deliver: (principal: string, channel: string, payload?: unknown) => boolean;
|
|
293
|
+
list: () => ShellReport[];
|
|
294
|
+
reset: (principal: string) => boolean;
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
type Env = {
|
|
298
|
+
Variables: {
|
|
299
|
+
principal: string | null;
|
|
300
|
+
resolved: ResolvedIdentity;
|
|
301
|
+
};
|
|
302
|
+
};
|
|
303
|
+
type MossServer = Hono<Env> & {
|
|
304
|
+
socket: SocketAccept;
|
|
305
|
+
shells?: ShellHost;
|
|
306
|
+
principalOf: (token: string) => Promise<string | null>;
|
|
307
|
+
page: (path: string) => {
|
|
308
|
+
name: string;
|
|
309
|
+
host: ShellHost;
|
|
310
|
+
inputs: Record<string, Record<string, unknown>>;
|
|
311
|
+
} | undefined;
|
|
312
|
+
pages: readonly {
|
|
313
|
+
name: string;
|
|
314
|
+
path: string;
|
|
315
|
+
}[];
|
|
316
|
+
refresh: () => void;
|
|
317
|
+
replaceActions: (source: string, actions: Record<string, ActionDefinition>) => void;
|
|
318
|
+
replaceEntries: (source: string, entries: readonly (SeedEntry | SeedMutation)[]) => Promise<void>;
|
|
319
|
+
actions: () => Readonly<Record<string, ActionDefinition>>;
|
|
320
|
+
defaults: (publisher: string) => SessionArtifacts;
|
|
321
|
+
catalogOf: (principal: string | null) => Promise<Catalog>;
|
|
322
|
+
policyForRoles: (roles: readonly string[]) => ScopePolicy;
|
|
323
|
+
charterReport: () => VerifyReport;
|
|
324
|
+
invalidateIdentity: (principal: string) => boolean;
|
|
325
|
+
identity: (principal: string | null) => Promise<IdentityRecord>;
|
|
326
|
+
executeAs: ExecuteAs;
|
|
327
|
+
invalidateTag: (tag: string) => number;
|
|
328
|
+
nudge: (principal: string, channel: string) => void;
|
|
329
|
+
close: () => void;
|
|
330
|
+
identities?: {
|
|
331
|
+
list: () => IdentityReport[];
|
|
332
|
+
meter: () => {
|
|
333
|
+
size: number;
|
|
334
|
+
max: number;
|
|
335
|
+
resolved: number;
|
|
336
|
+
evicted: number;
|
|
337
|
+
expired: number;
|
|
338
|
+
};
|
|
339
|
+
};
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
type DocumentHost = Pick<ShellHost, 'snapshot'>;
|
|
343
|
+
type DocumentSource = {
|
|
344
|
+
principalOf: (token: string) => Promise<string | null>;
|
|
345
|
+
page: (path: string) => {
|
|
346
|
+
name: string;
|
|
347
|
+
host: DocumentHost;
|
|
348
|
+
inputs: Record<string, Record<string, unknown>>;
|
|
349
|
+
} | undefined;
|
|
350
|
+
shells?: DocumentHost;
|
|
351
|
+
};
|
|
352
|
+
type DocumentConfig = {
|
|
353
|
+
server: DocumentSource;
|
|
354
|
+
template: string;
|
|
355
|
+
request: {
|
|
356
|
+
path: string;
|
|
357
|
+
cookie?: string | null;
|
|
358
|
+
host?: string | null;
|
|
359
|
+
};
|
|
360
|
+
draw: (snapshot: ShellSnapshot) => string | Promise<string>;
|
|
361
|
+
htmlAttributes?: (snapshot: ShellSnapshot) => Record<string, string>;
|
|
362
|
+
site?: string;
|
|
363
|
+
tokenKey?: string;
|
|
364
|
+
waitMs?: number;
|
|
365
|
+
root?: string;
|
|
366
|
+
};
|
|
367
|
+
type DrawnDocument = {
|
|
368
|
+
html: string;
|
|
369
|
+
headers: Record<string, string>;
|
|
370
|
+
drawn: boolean;
|
|
371
|
+
principal: string | null;
|
|
372
|
+
page?: string;
|
|
373
|
+
head?: ScreenHead;
|
|
374
|
+
live?: boolean;
|
|
375
|
+
why?: string[];
|
|
376
|
+
drawnWith?: string[];
|
|
377
|
+
settled?: boolean;
|
|
378
|
+
};
|
|
379
|
+
declare const renderDocument: (config: DocumentConfig) => Promise<DrawnDocument>;
|
|
380
|
+
|
|
381
|
+
export { type DocumentConfig as D, type ExecuteAs as E, type FunctionDefinition as F, type IdentityRecord as I, type LayoutVariant as L, type MossServer as M, type NiscApp as N, type PageManifest as P, type RunRecord as R, type ShellHost as S, type DrawnDocument as a, type FunctionSession as b, type RunSink as c, type RunTurn as d, type ShellManifest as e, type ShellSnapshot as f, defineApp as g, renderDocument as r };
|