@niscorp/moss 0.6.0 → 0.8.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 +144 -0
- package/DESIGN.md +77 -40
- package/DOCS.md +673 -78
- package/README.md +2 -2
- package/dist/chunk-3DCTQKPQ.cjs +943 -0
- package/dist/chunk-3DCTQKPQ.cjs.map +1 -0
- package/dist/{chunk-WKBH3UMB.js → chunk-3T422CCN.js} +9 -3
- package/dist/chunk-3T422CCN.js.map +1 -0
- package/dist/chunk-6XC2MD7S.js +906 -0
- package/dist/chunk-6XC2MD7S.js.map +1 -0
- package/dist/{chunk-D3YZIAYV.cjs → chunk-I4UOWER3.cjs} +11 -5
- package/dist/chunk-I4UOWER3.cjs.map +1 -0
- package/dist/{chunk-VBWNHF4H.cjs → chunk-PVZMCEBX.cjs} +4 -3
- package/dist/chunk-PVZMCEBX.cjs.map +1 -0
- package/dist/{chunk-NSK7QSSG.js → chunk-QAHDSRPK.js} +4 -3
- package/dist/chunk-QAHDSRPK.js.map +1 -0
- package/dist/{chunk-R66WUKGC.cjs → chunk-TMDKNZYL.cjs} +2169 -1319
- package/dist/chunk-TMDKNZYL.cjs.map +1 -0
- package/dist/{chunk-V5YMJL7Z.js → chunk-YZILOVCR.js} +2147 -1295
- package/dist/chunk-YZILOVCR.js.map +1 -0
- package/dist/document-BYAY-Qle.d.ts +381 -0
- package/dist/document-DAE71J27.d.cts +381 -0
- package/dist/{index-B411sK9M.d.cts → index-CSEo7Tys.d.cts} +5 -0
- package/dist/{index-B411sK9M.d.ts → index-CSEo7Tys.d.ts} +5 -0
- package/dist/index.cjs +17 -17
- package/dist/index.d.cts +8 -10
- package/dist/index.d.ts +8 -10
- 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-D3YZIAYV.cjs.map +0 -1
- 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/chunk-WKBH3UMB.js.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 { Shell, FetchFn, LayoutNode, ActionDefinition, CanvasConfig, ActionFragment, FunctionDefinition, FunctionHandler, 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-CSEo7Tys.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
|
+
|
|
36
|
+
type WrittenFunctions = readonly FunctionDefinition[] | Record<string, FunctionHandler>;
|
|
37
|
+
type NiscApp = {
|
|
38
|
+
charter: Charter;
|
|
39
|
+
assignments?: Record<string, readonly string[]>;
|
|
40
|
+
wearable?: readonly (readonly string[])[];
|
|
41
|
+
actions: Record<string, ActionDefinition>;
|
|
42
|
+
layouts?: Record<string, LayoutVariant>;
|
|
43
|
+
behaviors?: ScopeBehaviors;
|
|
44
|
+
scope?: (principal: string | null, identity?: IdentityRecord) => Record<string, unknown>;
|
|
45
|
+
identity?: {
|
|
46
|
+
as?: string;
|
|
47
|
+
resolve: (principal: string, read: (fingerprint: string, scope: Record<string, unknown>) => Promise<unknown>) => Promise<IdentityRecord>;
|
|
48
|
+
};
|
|
49
|
+
phrases?: (session: {
|
|
50
|
+
principal: string | null;
|
|
51
|
+
identity: Record<string, unknown>;
|
|
52
|
+
wire: FetchFn;
|
|
53
|
+
}) => Phrasebook | undefined | Promise<Phrasebook | undefined>;
|
|
54
|
+
phraseKeys?: PhraseKeys;
|
|
55
|
+
features?: readonly Feature[];
|
|
56
|
+
entries?: readonly (SeedEntry | SeedMutation)[];
|
|
57
|
+
resources?: Record<string, readonly string[] | {
|
|
58
|
+
entities: readonly string[];
|
|
59
|
+
}>;
|
|
60
|
+
shell?: ShellManifest;
|
|
61
|
+
pages?: Record<string, PageManifest>;
|
|
62
|
+
grammars?: readonly Sequence[];
|
|
63
|
+
functions?: (session: FunctionSession) => WrittenFunctions;
|
|
64
|
+
onSession?: (session: FunctionSession) => void;
|
|
65
|
+
runs?: RunSink;
|
|
66
|
+
reactions?: readonly {
|
|
67
|
+
table: string;
|
|
68
|
+
op?: 'insert' | 'update' | 'delete';
|
|
69
|
+
run: (event: {
|
|
70
|
+
fingerprint: string;
|
|
71
|
+
table: string;
|
|
72
|
+
op: 'insert' | 'update' | 'delete';
|
|
73
|
+
count: number;
|
|
74
|
+
scope: Record<string, unknown>;
|
|
75
|
+
}, tools: {
|
|
76
|
+
deliver: (principal: string, channel: string, payload?: unknown) => boolean;
|
|
77
|
+
}) => void;
|
|
78
|
+
}[];
|
|
79
|
+
};
|
|
80
|
+
type RunTurn = {
|
|
81
|
+
role: 'system' | 'user' | 'assistant' | 'tool';
|
|
82
|
+
content: string;
|
|
83
|
+
calls?: ReadonlyArray<{
|
|
84
|
+
name: string;
|
|
85
|
+
args: string;
|
|
86
|
+
}>;
|
|
87
|
+
name?: string;
|
|
88
|
+
};
|
|
89
|
+
type RunRecord = {
|
|
90
|
+
at: number;
|
|
91
|
+
principal: string | null;
|
|
92
|
+
shellId: string;
|
|
93
|
+
agentId: string;
|
|
94
|
+
agentPath: readonly string[];
|
|
95
|
+
label: string;
|
|
96
|
+
provider: string;
|
|
97
|
+
model: string;
|
|
98
|
+
inputTokens: number;
|
|
99
|
+
outputTokens: number;
|
|
100
|
+
totalTokens: number;
|
|
101
|
+
reported: boolean;
|
|
102
|
+
steps: number;
|
|
103
|
+
elapsedMs: number;
|
|
104
|
+
turns?: readonly RunTurn[];
|
|
105
|
+
response?: string;
|
|
106
|
+
outcome: 'ok' | 'failed';
|
|
107
|
+
};
|
|
108
|
+
type RunSink = (record: RunRecord, session: FunctionSession) => void;
|
|
109
|
+
type ArtifactKind = 'layout' | 'action' | 'fragment' | 'read';
|
|
110
|
+
type ArtifactVersion = {
|
|
111
|
+
kind: ArtifactKind;
|
|
112
|
+
id: string;
|
|
113
|
+
save: string;
|
|
114
|
+
createdAt: string;
|
|
115
|
+
copiedFrom: string | null;
|
|
116
|
+
body: unknown;
|
|
117
|
+
};
|
|
118
|
+
type SessionArtifacts = {
|
|
119
|
+
save: (artifacts: readonly {
|
|
120
|
+
kind: ArtifactKind;
|
|
121
|
+
id?: string;
|
|
122
|
+
body: unknown;
|
|
123
|
+
}[]) => Promise<{
|
|
124
|
+
save: string;
|
|
125
|
+
artifacts: readonly {
|
|
126
|
+
kind: ArtifactKind;
|
|
127
|
+
id: string;
|
|
128
|
+
}[];
|
|
129
|
+
}>;
|
|
130
|
+
list: (kind?: ArtifactKind) => Promise<readonly ArtifactVersion[]>;
|
|
131
|
+
history: (kind: ArtifactKind, id: string) => Promise<readonly ArtifactVersion[]>;
|
|
132
|
+
restore: (kind: ArtifactKind, id: string, save: string) => Promise<{
|
|
133
|
+
save: string;
|
|
134
|
+
}>;
|
|
135
|
+
reset: (kind: ArtifactKind, id: string) => Promise<{
|
|
136
|
+
save: string;
|
|
137
|
+
}>;
|
|
138
|
+
};
|
|
139
|
+
type DraftArtifact = {
|
|
140
|
+
kind: ArtifactKind;
|
|
141
|
+
id: string;
|
|
142
|
+
body: unknown;
|
|
143
|
+
};
|
|
144
|
+
type SessionDraft = {
|
|
145
|
+
add: (artifacts: readonly {
|
|
146
|
+
kind: ArtifactKind;
|
|
147
|
+
id?: string;
|
|
148
|
+
body: unknown;
|
|
149
|
+
}[]) => Promise<{
|
|
150
|
+
step: number;
|
|
151
|
+
artifacts: readonly {
|
|
152
|
+
kind: ArtifactKind;
|
|
153
|
+
id: string;
|
|
154
|
+
}[];
|
|
155
|
+
}>;
|
|
156
|
+
list: () => readonly DraftArtifact[];
|
|
157
|
+
remove: (kind: ArtifactKind, id: string) => Promise<{
|
|
158
|
+
step: number;
|
|
159
|
+
}>;
|
|
160
|
+
show: (step: number) => Promise<void>;
|
|
161
|
+
discard: () => Promise<void>;
|
|
162
|
+
save: () => Promise<{
|
|
163
|
+
save: string;
|
|
164
|
+
artifacts: readonly {
|
|
165
|
+
kind: ArtifactKind;
|
|
166
|
+
id: string;
|
|
167
|
+
}[];
|
|
168
|
+
}>;
|
|
169
|
+
};
|
|
170
|
+
type FunctionSession = {
|
|
171
|
+
shell: Shell;
|
|
172
|
+
artifacts: SessionArtifacts;
|
|
173
|
+
draft: SessionDraft;
|
|
174
|
+
principal: string | null;
|
|
175
|
+
roles: readonly string[];
|
|
176
|
+
identity: Record<string, unknown>;
|
|
177
|
+
actions: readonly string[];
|
|
178
|
+
wire: FetchFn;
|
|
179
|
+
grant: (token: string) => void;
|
|
180
|
+
revoke: () => Promise<void>;
|
|
181
|
+
answerIntent: (writers: {
|
|
182
|
+
generateDsl: GenerateDsl;
|
|
183
|
+
mapToShape: MapToShape;
|
|
184
|
+
}, asked: {
|
|
185
|
+
intent: string;
|
|
186
|
+
shape: unknown;
|
|
187
|
+
context?: Record<string, unknown>;
|
|
188
|
+
} | {
|
|
189
|
+
fingerprint: string;
|
|
190
|
+
context?: Record<string, unknown>;
|
|
191
|
+
}) => Promise<QueryResponse>;
|
|
192
|
+
recordRun: (run: Omit<RunRecord, 'at' | 'principal' | 'shellId'>) => void;
|
|
193
|
+
functions: () => readonly {
|
|
194
|
+
id: string;
|
|
195
|
+
description?: string;
|
|
196
|
+
}[];
|
|
197
|
+
};
|
|
198
|
+
type CanvasSeed = string | {
|
|
199
|
+
action: string;
|
|
200
|
+
input?: Record<string, unknown>;
|
|
201
|
+
with?: string[];
|
|
202
|
+
};
|
|
203
|
+
type ShellCanvas = Omit<CanvasConfig, 'initial'> & {
|
|
204
|
+
initial?: CanvasSeed | CanvasSeed[];
|
|
205
|
+
};
|
|
206
|
+
type ShellManifest = {
|
|
207
|
+
canvases: ShellCanvas[];
|
|
208
|
+
layout?: LayoutNode;
|
|
209
|
+
layoutStore?: Record<string, LayoutNode>;
|
|
210
|
+
fragments?: Record<string, ActionFragment>;
|
|
211
|
+
seeds?: (session: {
|
|
212
|
+
principal: string | null;
|
|
213
|
+
actions: readonly string[];
|
|
214
|
+
roles: readonly string[];
|
|
215
|
+
wire: FetchFn;
|
|
216
|
+
}) => Promise<Record<string, CanvasSeed[]>> | Record<string, CanvasSeed[]>;
|
|
217
|
+
components?: Record<string, {
|
|
218
|
+
meta?: {
|
|
219
|
+
description?: string;
|
|
220
|
+
propsSchema?: unknown;
|
|
221
|
+
};
|
|
222
|
+
}>;
|
|
223
|
+
inputs?: (session: {
|
|
224
|
+
principal: string | null;
|
|
225
|
+
actions: readonly string[];
|
|
226
|
+
roles: readonly string[];
|
|
227
|
+
identity: Record<string, unknown>;
|
|
228
|
+
wire: FetchFn;
|
|
229
|
+
}) => Record<string, Record<string, unknown>> | Promise<Record<string, Record<string, unknown>>>;
|
|
230
|
+
};
|
|
231
|
+
type PageManifest = ShellManifest & {
|
|
232
|
+
path: string;
|
|
233
|
+
params?: string;
|
|
234
|
+
};
|
|
235
|
+
declare const defineApp: (app: NiscApp) => NiscApp;
|
|
236
|
+
|
|
237
|
+
type ExecuteAs = (role: string, fingerprint: string, context: Record<string, unknown>, scope?: Record<string, unknown>) => Promise<unknown>;
|
|
238
|
+
|
|
239
|
+
type Catalog = {
|
|
240
|
+
ids: readonly string[];
|
|
241
|
+
hash: string;
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
type ShellConnection = {
|
|
245
|
+
send: (text: string) => void;
|
|
246
|
+
close: (code?: number, reason?: string) => void;
|
|
247
|
+
seal?: (token: string) => Promise<string>;
|
|
248
|
+
};
|
|
249
|
+
type ShellSession = {
|
|
250
|
+
readonly shell: Shell;
|
|
251
|
+
attach: (connection: ShellConnection, options?: {
|
|
252
|
+
delta?: boolean;
|
|
253
|
+
}) => void;
|
|
254
|
+
detach: (connection: ShellConnection) => void;
|
|
255
|
+
resync: (connection: ShellConnection) => void;
|
|
256
|
+
dispatch: (canvas: string, event: Record<string, unknown>) => void;
|
|
257
|
+
publish: (channel: string, payload?: unknown) => void;
|
|
258
|
+
back: () => boolean;
|
|
259
|
+
popTo: (canvas: string, instance: string) => void;
|
|
260
|
+
reset: () => void;
|
|
261
|
+
};
|
|
262
|
+
type ShellReport = {
|
|
263
|
+
principal: string;
|
|
264
|
+
connections: number;
|
|
265
|
+
since: number;
|
|
266
|
+
idleSince: number | null;
|
|
267
|
+
canvases: {
|
|
268
|
+
id: string;
|
|
269
|
+
actions: readonly string[];
|
|
270
|
+
}[];
|
|
271
|
+
};
|
|
272
|
+
type ShellSnapshot = {
|
|
273
|
+
frame: RenderNode[];
|
|
274
|
+
trees: Record<string, RenderNode[]>;
|
|
275
|
+
seed?: string;
|
|
276
|
+
settled: boolean;
|
|
277
|
+
live: boolean;
|
|
278
|
+
why: string[];
|
|
279
|
+
drawnWith: string[];
|
|
280
|
+
};
|
|
281
|
+
type ShellOpening = {
|
|
282
|
+
seed?: string;
|
|
283
|
+
inputs?: Record<string, Record<string, unknown>>;
|
|
284
|
+
};
|
|
285
|
+
type ShellHost = {
|
|
286
|
+
session: (token: string | null, principal: string | null, options?: ShellOpening) => Promise<ShellSession>;
|
|
287
|
+
snapshot: (token: string | null, principal: string | null, options?: {
|
|
288
|
+
waitMs?: number;
|
|
289
|
+
inputs?: ShellOpening['inputs'];
|
|
290
|
+
}) => Promise<ShellSnapshot>;
|
|
291
|
+
deliver: (principal: string, channel: string, payload?: unknown) => boolean;
|
|
292
|
+
list: () => ShellReport[];
|
|
293
|
+
reset: (principal: string) => boolean;
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
type Env = {
|
|
297
|
+
Variables: {
|
|
298
|
+
principal: string | null;
|
|
299
|
+
resolved: ResolvedIdentity;
|
|
300
|
+
};
|
|
301
|
+
};
|
|
302
|
+
type MossServer = Hono<Env> & {
|
|
303
|
+
socket: SocketAccept;
|
|
304
|
+
shells?: ShellHost;
|
|
305
|
+
principalOf: (token: string) => Promise<string | null>;
|
|
306
|
+
page: (path: string) => {
|
|
307
|
+
name: string;
|
|
308
|
+
host: ShellHost;
|
|
309
|
+
inputs: Record<string, Record<string, unknown>>;
|
|
310
|
+
} | undefined;
|
|
311
|
+
pages: readonly {
|
|
312
|
+
name: string;
|
|
313
|
+
path: string;
|
|
314
|
+
}[];
|
|
315
|
+
checkFunctions: () => Promise<void>;
|
|
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 FunctionSession 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 RunSink as b, type RunTurn as c, type ShellManifest as d, type ShellSnapshot as e, defineApp as f, renderDocument as r };
|