@yaks/browse 0.0.0-stage → 0.2.36
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 +202 -0
- package/README.md +324 -2
- package/_dist/app.d.ts +8 -0
- package/_dist/app.d.ts.map +1 -0
- package/_dist/cli.d.ts +16 -0
- package/_dist/cli.d.ts.map +1 -0
- package/_dist/hosting.d.ts +24 -0
- package/_dist/hosting.d.ts.map +1 -0
- package/_dist/mod.d.ts +7 -0
- package/_dist/mod.d.ts.map +1 -0
- package/_dist/types.d.ts +5 -0
- package/_dist/types.d.ts.map +1 -0
- package/_dist/url.d.ts +2 -0
- package/_dist/url.d.ts.map +1 -0
- package/app.js +10 -0
- package/app.js.map +1 -0
- package/app.ts +10 -0
- package/browser-links.js +22 -0
- package/browser-links.js.map +1 -0
- package/browser-links.ts +28 -0
- package/cli.js +172 -0
- package/cli.js.map +1 -0
- package/cli.ts +168 -0
- package/client.js +748 -0
- package/client.js.map +1 -0
- package/client.ts +734 -0
- package/clipboard.js +18 -0
- package/clipboard.js.map +1 -0
- package/clipboard.ts +17 -0
- package/commands.js +1157 -0
- package/commands.js.map +1 -0
- package/commands.ts +1108 -0
- package/components/Ansi.tsx +160 -0
- package/components/App.tsx +446 -0
- package/components/Canvas.tsx +625 -0
- package/components/Card.tsx +276 -0
- package/components/Chat.tsx +205 -0
- package/components/Configuration.tsx +218 -0
- package/components/Decision.tsx +49 -0
- package/components/Dot.tsx +52 -0
- package/components/Entity.tsx +609 -0
- package/components/Fault.tsx +43 -0
- package/components/Filter.tsx +103 -0
- package/components/Keybindings.tsx +100 -0
- package/components/Keys.tsx +67 -0
- package/components/Markdown.tsx +90 -0
- package/components/Navigation.tsx +161 -0
- package/components/New.tsx +490 -0
- package/components/Peek.tsx +168 -0
- package/components/Prio.tsx +20 -0
- package/components/Run.tsx +263 -0
- package/components/Search.tsx +280 -0
- package/components/Stamp.tsx +44 -0
- package/components/Status.tsx +514 -0
- package/components/Sync.tsx +173 -0
- package/components/Tile.tsx +50 -0
- package/components/answered.js +23 -0
- package/components/answered.js.map +1 -0
- package/components/answered.ts +25 -0
- package/components/comp.js +11 -0
- package/components/comp.js.map +1 -0
- package/components/comp.ts +10 -0
- package/components/drag.js +173 -0
- package/components/drag.js.map +1 -0
- package/components/drag.ts +198 -0
- package/components/fields.tsx +90 -0
- package/components/fixtures/README.md +10 -0
- package/components/fixtures/archetypes.json +3646 -0
- package/components/hits.js +63 -0
- package/components/hits.js.map +1 -0
- package/components/hits.ts +84 -0
- package/components/icons.tsx +177 -0
- package/components/inspect.tsx +331 -0
- package/components/mount.ts +79 -0
- package/components/nav.tsx +479 -0
- package/components/offers.js +26 -0
- package/components/offers.js.map +1 -0
- package/components/offers.ts +54 -0
- package/components/page.js +21 -0
- package/components/page.js.map +1 -0
- package/components/page.ts +18 -0
- package/components/read.js +5 -0
- package/components/read.js.map +1 -0
- package/components/read.ts +7 -0
- package/components/registry.js +285 -0
- package/components/registry.js.map +1 -0
- package/components/registry.ts +317 -0
- package/components/session_status.tsx +115 -0
- package/components/subscriptions.js +149 -0
- package/components/subscriptions.js.map +1 -0
- package/components/subscriptions.ts +161 -0
- package/components/title.tsx +21 -0
- package/components/useQuery.js +166 -0
- package/components/useQuery.js.map +1 -0
- package/components/useQuery.ts +211 -0
- package/components/views/Board.tsx +450 -0
- package/components/views/BoardTile.tsx +65 -0
- package/components/views/Dashboard.tsx +148 -0
- package/components/views/Debug.tsx +445 -0
- package/components/views/Dependency.tsx +51 -0
- package/components/views/Entry.tsx +500 -0
- package/components/views/Gist.tsx +28 -0
- package/components/views/Inline.tsx +54 -0
- package/components/views/Json.tsx +19 -0
- package/components/views/Layout.tsx +211 -0
- package/components/views/List.tsx +238 -0
- package/components/views/Md.tsx +43 -0
- package/components/views/Media.tsx +48 -0
- package/components/views/Memory.tsx +32 -0
- package/components/views/Relate.tsx +205 -0
- package/components/views/Search.tsx +42 -0
- package/components/views/Session.tsx +850 -0
- package/components/views/SessionManage.tsx +127 -0
- package/components/views/Show.tsx +758 -0
- package/components/views/Shown.tsx +72 -0
- package/components/views/Split.tsx +58 -0
- package/components/views/TaskTile.tsx +37 -0
- package/components/views/Title.tsx +105 -0
- package/components/views/Wake.tsx +77 -0
- package/components/views/Web.tsx +49 -0
- package/components/wells.js +30 -0
- package/components/wells.js.map +1 -0
- package/components/wells.ts +33 -0
- package/configuration.js +38 -0
- package/configuration.js.map +1 -0
- package/configuration.ts +41 -0
- package/decision_sync.js +88 -0
- package/decision_sync.js.map +1 -0
- package/decision_sync.ts +93 -0
- package/deno.json +1 -0
- package/domain-host.tsx +108 -0
- package/edge.js +193 -0
- package/edge.js.map +1 -0
- package/edge.ts +196 -0
- package/entry_log.js +241 -0
- package/entry_log.js.map +1 -0
- package/entry_log.ts +214 -0
- package/failure.js +22 -0
- package/failure.js.map +1 -0
- package/failure.ts +34 -0
- package/front.json +61 -0
- package/highlight.js +143 -0
- package/highlight.js.map +1 -0
- package/highlight.ts +149 -0
- package/history.js +68 -0
- package/history.js.map +1 -0
- package/history.ts +72 -0
- package/host_commands.js +107 -0
- package/host_commands.js.map +1 -0
- package/host_commands.ts +38 -0
- package/hosting.js +53 -0
- package/hosting.js.map +1 -0
- package/hosting.ts +72 -0
- package/idb.js +14 -0
- package/idb.js.map +1 -0
- package/idb.ts +15 -0
- package/index.js +232 -0
- package/index.js.map +1 -0
- package/index.ts +252 -0
- package/keybindings.js +136 -0
- package/keybindings.js.map +1 -0
- package/keybindings.ts +37 -0
- package/kit.js +103 -0
- package/kit.js.map +1 -0
- package/kit.ts +119 -0
- package/layout.js +254 -0
- package/layout.js.map +1 -0
- package/layout.ts +210 -0
- package/legacy_outbox.js +53 -0
- package/legacy_outbox.js.map +1 -0
- package/legacy_outbox.ts +63 -0
- package/live.js +2883 -0
- package/live.js.map +1 -0
- package/live.ts +3334 -0
- package/live_archetypes.js +92 -0
- package/live_archetypes.js.map +1 -0
- package/live_archetypes.ts +113 -0
- package/live_client.js +145 -0
- package/live_client.js.map +1 -0
- package/live_client.ts +120 -0
- package/main.tsx +5 -0
- package/mod.js +7 -0
- package/mod.js.map +1 -0
- package/mod.ts +7 -0
- package/mount.tsx +50 -0
- package/navigation.js +120 -0
- package/navigation.js.map +1 -0
- package/navigation.ts +152 -0
- package/near.js +83 -0
- package/near.js.map +1 -0
- package/near.ts +83 -0
- package/new.js +295 -0
- package/new.js.map +1 -0
- package/new.ts +361 -0
- package/outbox.js +112 -0
- package/outbox.js.map +1 -0
- package/outbox.ts +129 -0
- package/owner.js +39 -0
- package/owner.js.map +1 -0
- package/owner.ts +37 -0
- package/package.json +81 -4
- package/paste.js +157 -0
- package/paste.js.map +1 -0
- package/paste.ts +122 -0
- package/props.js +303 -0
- package/props.js.map +1 -0
- package/props.ts +358 -0
- package/providers.js +136 -0
- package/providers.js.map +1 -0
- package/providers.ts +194 -0
- package/query.js +987 -0
- package/query.js.map +1 -0
- package/query.ts +1113 -0
- package/remote.js +37 -0
- package/remote.js.map +1 -0
- package/remote.ts +46 -0
- package/resolver.js +149 -0
- package/resolver.js.map +1 -0
- package/resolver.ts +213 -0
- package/rfc2047.js +37 -0
- package/rfc2047.js.map +1 -0
- package/rfc2047.ts +40 -0
- package/row_holds.js +107 -0
- package/row_holds.js.map +1 -0
- package/row_holds.ts +93 -0
- package/served.ts +42 -0
- package/session_worktree.js +7 -0
- package/session_worktree.js.map +1 -0
- package/session_worktree.ts +16 -0
- package/sessions.js +57 -0
- package/sessions.js.map +1 -0
- package/sessions.ts +53 -0
- package/sha.js +161 -0
- package/sha.js.map +1 -0
- package/sha.ts +164 -0
- package/styles.css +2823 -0
- package/subs.js +36 -0
- package/subs.js.map +1 -0
- package/subs.ts +40 -0
- package/terminal-route.js +13 -0
- package/terminal-route.js.map +1 -0
- package/terminal-route.ts +17 -0
- package/terminal.js +251 -0
- package/terminal.js.map +1 -0
- package/terminal.ts +186 -0
- package/time.js +142 -0
- package/time.js.map +1 -0
- package/time.ts +133 -0
- package/title.js +25 -0
- package/title.js.map +1 -0
- package/title.ts +50 -0
- package/tui/doc.ts +6 -0
- package/tui/testing.ts +19 -0
- package/twin.js +11 -0
- package/twin.js.map +1 -0
- package/twin.ts +13 -0
- package/types.js +456 -0
- package/types.js.map +1 -0
- package/types.ts +1370 -0
- package/url.js +77 -0
- package/url.js.map +1 -0
- package/url.ts +85 -0
- package/verb.js +82 -0
- package/verb.js.map +1 -0
- package/verb.ts +137 -0
- package/warmth.js +41 -0
- package/warmth.js.map +1 -0
- package/warmth.ts +54 -0
- package/wire.js +86 -0
- package/wire.js.map +1 -0
- package/wire.ts +63 -0
package/types.ts
ADDED
|
@@ -0,0 +1,1370 @@
|
|
|
1
|
+
import { apiPath, hosting } from './hosting.js'
|
|
2
|
+
import { writeOwner } from './owner.js'
|
|
3
|
+
// The browser's vocabulary: what each component is, learned from the graph it
|
|
4
|
+
// is looking at. A host serves the documents it composed (`/vocab`,
|
|
5
|
+
// @yaks/api) and `learn()` reads the tables below out of them before
|
|
6
|
+
// anything renders, so the page and the server read one set of components.
|
|
7
|
+
// Nothing here is written down per component: a plugin the host lists is
|
|
8
|
+
// understood the moment the host loads it.
|
|
9
|
+
//
|
|
10
|
+
// In a browser the documents are fetched at the top of this module, so every
|
|
11
|
+
// module that imports it evaluates after the tables are full. Under Deno the
|
|
12
|
+
// tables start empty until something calls learn(): the tests learn the
|
|
13
|
+
// documents a host composes (testing.ts), a terminal the ones its server
|
|
14
|
+
// serves.
|
|
15
|
+
|
|
16
|
+
import {
|
|
17
|
+
type Keywords,
|
|
18
|
+
loadVocab,
|
|
19
|
+
type Vocab,
|
|
20
|
+
type VocabDoc,
|
|
21
|
+
} from '@yaks/vocab'
|
|
22
|
+
import { idOf as idsOf, SHORT } from '@yaks/id'
|
|
23
|
+
import { idKeywords } from '@yaks/id/vocab'
|
|
24
|
+
import { nameKeywords } from '@yaks/names'
|
|
25
|
+
import { edgeKeywords } from '@yaks/edge/vocab'
|
|
26
|
+
import { relations as edgeRelations } from '@yaks/edge'
|
|
27
|
+
import { blobKeywords } from '@yaks/blob'
|
|
28
|
+
import { kernelKeywords } from '@yaks/kernel/vocab'
|
|
29
|
+
import { keyKeywords } from '@yaks/key/vocab'
|
|
30
|
+
import { settled, statusOf as taskStatus } from '@yaks/task'
|
|
31
|
+
|
|
32
|
+
export let statuses = ['open', 'wip', 'done', 'cancelled'] as const
|
|
33
|
+
export let turnStates = ['idle', 'busy'] as const
|
|
34
|
+
export let messageRoles = ['user', 'agent'] as const
|
|
35
|
+
export let httpMethods = [
|
|
36
|
+
'GET',
|
|
37
|
+
'HEAD',
|
|
38
|
+
'POST',
|
|
39
|
+
'PUT',
|
|
40
|
+
'PATCH',
|
|
41
|
+
'DELETE',
|
|
42
|
+
] as const
|
|
43
|
+
export let roleSurfaces = ['native', 'managed'] as const
|
|
44
|
+
export let wakePolicies = [
|
|
45
|
+
'always',
|
|
46
|
+
'attention',
|
|
47
|
+
'scheduled',
|
|
48
|
+
'manual',
|
|
49
|
+
] as const
|
|
50
|
+
export let dirs = ['h', 'v'] as const
|
|
51
|
+
export let subModes = ['watch', 'mute'] as const
|
|
52
|
+
export let verdicts = ['approved', 'rejected', 'changes_requested'] as const
|
|
53
|
+
export let grades = ['frontier', 'mid', 'small'] as const
|
|
54
|
+
export let transports = ['process', 'http', 'machine'] as const
|
|
55
|
+
export let signalKinds = ['lapse', 'sweep', 'scene', 'wake'] as const
|
|
56
|
+
export let effectStates = ['pending', 'leased', 'delivered', 'failed'] as const
|
|
57
|
+
export let appAccess = ['public', 'open', 'private'] as const
|
|
58
|
+
export let planTiers = ['free', 'plus', 'pro'] as const
|
|
59
|
+
export let hostnameStages = ['pending', 'active', 'error'] as const
|
|
60
|
+
|
|
61
|
+
// The keyword vocabularies the documents are written with: every set the
|
|
62
|
+
// packages ship.
|
|
63
|
+
export let keywords: Keywords[] = [
|
|
64
|
+
idKeywords,
|
|
65
|
+
nameKeywords,
|
|
66
|
+
edgeKeywords,
|
|
67
|
+
blobKeywords,
|
|
68
|
+
kernelKeywords,
|
|
69
|
+
keyKeywords,
|
|
70
|
+
]
|
|
71
|
+
|
|
72
|
+
// The loaded vocabulary itself, for readers that ask it directly (the renderer
|
|
73
|
+
// registry, the browser replica).
|
|
74
|
+
export let vocab: Vocab = loadVocab([], keywords)
|
|
75
|
+
|
|
76
|
+
// The components and their wire-writable columns, each with what it IS.
|
|
77
|
+
export let comps: Record<string, Record<string, PropType>> = {}
|
|
78
|
+
|
|
79
|
+
// Composite indexes (see index.ts): what a component declares `index` or
|
|
80
|
+
// `unique` over.
|
|
81
|
+
export let indexes: Record<string, Idx[]> = {}
|
|
82
|
+
|
|
83
|
+
// Components never part of a working set (the kernel's `lazy` keyword): a
|
|
84
|
+
// view that needs them holds its own subscription (live.ts entrySub).
|
|
85
|
+
export let partition: Record<string, 'eager' | 'lazy'> = {}
|
|
86
|
+
|
|
87
|
+
// Server-stamped columns — never wire-writable, still read.
|
|
88
|
+
export let stamped: Record<string, Record<string, PropType>> = {}
|
|
89
|
+
|
|
90
|
+
// kind is DERIVED: the most specific component an entity carries names it.
|
|
91
|
+
export let kindOrder: string[] = []
|
|
92
|
+
|
|
93
|
+
// Kinds whose doc title is a NAME a caller can type (near.ts).
|
|
94
|
+
export let byName = new Set<string>()
|
|
95
|
+
|
|
96
|
+
// An entity's id as a person reads it: `T-9` once the store numbers it, its
|
|
97
|
+
// short handle `#3b5bc70420` until then. @yaks/id's, the one every door reads
|
|
98
|
+
// an id through.
|
|
99
|
+
export let idOf = idsOf(vocab)
|
|
100
|
+
|
|
101
|
+
let irregular: Record<string, string> = {
|
|
102
|
+
person: 'people',
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// The edge vocabulary — every edge reads as a sentence, parent first: each
|
|
106
|
+
// relation a component declares with the `edge` keyword.
|
|
107
|
+
export let edges: string[] = []
|
|
108
|
+
|
|
109
|
+
// Durable work/knowledge facets governed by project-rooted edge paths.
|
|
110
|
+
export let governed = ['task', 'architecture', 'memory', 'persona'] as const
|
|
111
|
+
|
|
112
|
+
// What the host derives a session's status as, and the ones still going.
|
|
113
|
+
export let sessionStates = [
|
|
114
|
+
'pending',
|
|
115
|
+
'running',
|
|
116
|
+
'settled',
|
|
117
|
+
'stopped',
|
|
118
|
+
'failed',
|
|
119
|
+
] as const
|
|
120
|
+
export let sessionActive = ['pending', 'running']
|
|
121
|
+
|
|
122
|
+
// One property, in the words the views speak (PropType below).
|
|
123
|
+
let typeOf = (v: Vocab, comp: string, prop: string): PropType => {
|
|
124
|
+
let p = v.prop(comp, prop)!
|
|
125
|
+
let raw = (v.def(comp)?.properties?.[prop] ?? {}) as {
|
|
126
|
+
store?: string
|
|
127
|
+
well?: string
|
|
128
|
+
}
|
|
129
|
+
if (p.category == 'ref') {
|
|
130
|
+
return { eid: p.ref || 'entity', death: p.death ?? 'keep' }
|
|
131
|
+
}
|
|
132
|
+
if (p.category == 'enum') {
|
|
133
|
+
return {
|
|
134
|
+
enum: p.values?.map(String) ?? [],
|
|
135
|
+
...(p.aliases ? { aliases: p.aliases } : {}),
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
if (raw.store == 'blob') return 'body'
|
|
139
|
+
if (raw.well) return { text: raw.well }
|
|
140
|
+
let s = p.scalar
|
|
141
|
+
return s == 'bool' || s == 'number' || s == 'priority' || s == 'time' ||
|
|
142
|
+
s == 'url' || s == 'query'
|
|
143
|
+
? s
|
|
144
|
+
: 'text'
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** Read the tables above out of a host's vocabulary documents, replacing
|
|
148
|
+
* whatever was learned before. */
|
|
149
|
+
export let learn = (docs: VocabDoc[], hostKeywords?: Keywords[]): Vocab => {
|
|
150
|
+
if (hostKeywords) keywords = hostKeywords
|
|
151
|
+
let v = loadVocab(docs, keywords)
|
|
152
|
+
let c: typeof comps = {}
|
|
153
|
+
let st: typeof stamped = {}
|
|
154
|
+
let ix: typeof indexes = {}
|
|
155
|
+
let names = new Set<string>()
|
|
156
|
+
let parts: typeof partition = {}
|
|
157
|
+
// The spine's columns are the store's to stamp: read and filtered on, never
|
|
158
|
+
// written. Its identity, eid, is read through spineProps below.
|
|
159
|
+
let spine = v.props('entity').map((p) => [p, typeOf(v, 'entity', p)])
|
|
160
|
+
if (spine.length) st.entity = Object.fromEntries(spine)
|
|
161
|
+
for (let name of v.all.filter((n) => n != 'entity')) {
|
|
162
|
+
let def = (v.def(name) ?? {}) as {
|
|
163
|
+
by_name?: boolean
|
|
164
|
+
index?: string[][]
|
|
165
|
+
unique?: string[][]
|
|
166
|
+
}
|
|
167
|
+
let own: Record<string, PropType> = {}
|
|
168
|
+
let server: Record<string, PropType> = {}
|
|
169
|
+
// A computed column is the host's to derive: read, filtered on, never
|
|
170
|
+
// written — the same standing as a stamped one.
|
|
171
|
+
for (let prop of v.props(name)) {
|
|
172
|
+
let p = v.prop(name, prop)!
|
|
173
|
+
;(p.stamped || p.computed ? server : own)[prop] = typeOf(v, name, prop)
|
|
174
|
+
}
|
|
175
|
+
c[name] = own
|
|
176
|
+
if (Object.keys(server).length) st[name] = server
|
|
177
|
+
let rows = [
|
|
178
|
+
...(def.unique ?? []).map((cols) => ({ cols, unique: true })),
|
|
179
|
+
...(def.index ?? []).map((cols) => ({ cols })),
|
|
180
|
+
].filter((r) => Array.isArray(r.cols))
|
|
181
|
+
if (rows.length) ix[name] = rows
|
|
182
|
+
if (def.by_name) names.add(name)
|
|
183
|
+
if (v.comp(name)?.keywords?.lazy) parts[name] = 'lazy'
|
|
184
|
+
}
|
|
185
|
+
vocab = v
|
|
186
|
+
comps = c
|
|
187
|
+
stamped = st
|
|
188
|
+
indexes = ix
|
|
189
|
+
idOf = idsOf(v)
|
|
190
|
+
byName = names
|
|
191
|
+
edges = Object.keys(edgeRelations(v))
|
|
192
|
+
partition = parts
|
|
193
|
+
kindOrder = [...v.kinds]
|
|
194
|
+
kindRank = new Map(kindOrder.map((k, i) => [k, i]))
|
|
195
|
+
planted = 0
|
|
196
|
+
plurals = new Set(kindOrder.flatMap((k) => [plural(k), `${k}s`]))
|
|
197
|
+
return v
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// What a prop IS — the detection layer editors and docs read. The
|
|
201
|
+
// vocabulary stays deliberately tiny:
|
|
202
|
+
// 'text' one line (sometimes more)
|
|
203
|
+
// 'body' long markdown
|
|
204
|
+
// 'number' 'bool' what they say
|
|
205
|
+
// 'priority' a number operators spell with an optional P
|
|
206
|
+
// 'query' a line of the filter grammar (query.ts) — text
|
|
207
|
+
// whose editor knows the vocabulary
|
|
208
|
+
// 'time' an ISO timestamp — a text column whose face is
|
|
209
|
+
// relative words (full stamp on hover)
|
|
210
|
+
// 'url' an address out on the web — a text column whose
|
|
211
|
+
// face is a link
|
|
212
|
+
// {enum: [...]} a closed set; aliases are input spellings only
|
|
213
|
+
// {eid: 'project', an association; the name says which component the
|
|
214
|
+
// death: …} target carries ('entity' = any entity — the spine is
|
|
215
|
+
// a real component, so 'entity' names it like any
|
|
216
|
+
// other, never a falsy '' that truthiness misreads),
|
|
217
|
+
// the death word what the reference means when the
|
|
218
|
+
// target dies
|
|
219
|
+
// {text: 'domains'} open text, suggestions from a named WELL the
|
|
220
|
+
// browser registers (the schema stays declarative —
|
|
221
|
+
// it can't reach a live cache from here)
|
|
222
|
+
|
|
223
|
+
// Every reference declares what the reaper does when its TARGET dies —
|
|
224
|
+
// the host derives the cascade from these words, so a reference without one
|
|
225
|
+
// doesn't typecheck and an undeclared behavior can't exist:
|
|
226
|
+
// 'cascade' the row's whole entity dies with the target (a card
|
|
227
|
+
// viewing it, a comment aimed at it)
|
|
228
|
+
// 'detach' the column lets go — set null, and the wire hears it
|
|
229
|
+
// (a task's dead project or assignee)
|
|
230
|
+
// 'release' the ROW dies but its entity lives — for tag comps whose
|
|
231
|
+
// existence is the reference (a claim: the lease vanishes,
|
|
232
|
+
// the claimed task survives)
|
|
233
|
+
// 'keep' the reference stands as history — the target's tombstone
|
|
234
|
+
// is the only mark (dead provenance)
|
|
235
|
+
export type Death = 'cascade' | 'detach' | 'release' | 'keep'
|
|
236
|
+
|
|
237
|
+
export type PropType =
|
|
238
|
+
| 'text'
|
|
239
|
+
| 'body'
|
|
240
|
+
| 'number'
|
|
241
|
+
| 'priority'
|
|
242
|
+
| 'bool'
|
|
243
|
+
| 'query'
|
|
244
|
+
| 'time'
|
|
245
|
+
| 'url'
|
|
246
|
+
| { enum: readonly string[]; aliases?: Record<string, string> }
|
|
247
|
+
| { eid: string; death: Death }
|
|
248
|
+
| { text: string }
|
|
249
|
+
|
|
250
|
+
// One column's type in a word an app author already knows — the five a
|
|
251
|
+
// vocab.json may spell (store/vocab.ts TYPES), plus `eid` for a reference and
|
|
252
|
+
// the values themselves for a closed set. The internal spellings collapse:
|
|
253
|
+
// a body and a saved query are text, a priority is a number.
|
|
254
|
+
export let typeName = (t: PropType): string =>
|
|
255
|
+
typeof t == 'string'
|
|
256
|
+
? t == 'body' || t == 'query' ? 'text' : t == 'priority' ? 'number' : t
|
|
257
|
+
: 'enum' in t
|
|
258
|
+
? t.enum.join('|')
|
|
259
|
+
: 'eid' in t
|
|
260
|
+
? 'eid'
|
|
261
|
+
: 'text'
|
|
262
|
+
|
|
263
|
+
// A component's whole shape, said in one line: `attachment has artifact
|
|
264
|
+
// (eid), media_type (text), name (text)`. Every unknown-column refusal carries it, at the
|
|
265
|
+
// write door and the filter door alike, because a refusal that names only what
|
|
266
|
+
// it did not understand teaches nothing — the seventh user test learned
|
|
267
|
+
// `artifact` by guessing five times and still read `size` as the bytes
|
|
268
|
+
// (C-32675 items 2 and 3). `type` is how the caller's vocabulary answers what
|
|
269
|
+
// a column is; a column it cannot type says its name alone.
|
|
270
|
+
export let shapeOf = (
|
|
271
|
+
name: string,
|
|
272
|
+
cols: readonly string[],
|
|
273
|
+
type: (col: string) => PropType | undefined = () => undefined,
|
|
274
|
+
): string => {
|
|
275
|
+
let said = cols.map((col) => {
|
|
276
|
+
let t = type(col)
|
|
277
|
+
return t ? `${col} (${typeName(t)})` : col
|
|
278
|
+
})
|
|
279
|
+
return said.length
|
|
280
|
+
? `${name} has ${said.join(', ')}`
|
|
281
|
+
: `${name} has no columns`
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
export let verdictName = (verdict?: string | null) =>
|
|
285
|
+
String(verdict ?? '').replaceAll('_', ' ')
|
|
286
|
+
|
|
287
|
+
// DERIVED columns (D-24102): readable exactly like a stored column — filter,
|
|
288
|
+
// project, tally, sort — but absent from `comps`/`stamped`, so raw graph writes
|
|
289
|
+
// cannot store one. The query evaluators compute the value (statusOf in query.ts
|
|
290
|
+
// read() and its SQL CASE mirror). Merged into readable routing so
|
|
291
|
+
// `.task.status` resolves and type-checks; CLI/MCP compatibility writers expand
|
|
292
|
+
// that spelling into facets. `status` is the first and only member: it reads
|
|
293
|
+
// completed/cancelled/claim.
|
|
294
|
+
export let derivedProps: Record<string, Record<string, PropType>> = {
|
|
295
|
+
task: { status: { enum: statuses } },
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
// The spine's own identity column. The contract declares what a store STAMPS on
|
|
299
|
+
// `entity` (num); the `eid` beside it is the identity itself — readable on every
|
|
300
|
+
// row, never writable, and derived
|
|
301
|
+
// from nothing, so it belongs to neither map above. Declared here so both
|
|
302
|
+
// routing tables carry it and `.entity.eid=<id>` NAMES entities at this door exactly as
|
|
303
|
+
// @yaks/sql and @yaks/match answer the same predicate.
|
|
304
|
+
export let spineProps: Record<string, Record<string, PropType>> = {
|
|
305
|
+
entity: { eid: 'text' },
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
// Task status is derived, never stored (D-24102). The rule is the ladder the
|
|
309
|
+
// learned vocabulary declares (@yaks/task's `statusOf`): `cancelled`, then
|
|
310
|
+
// `completed`, then a held `claim` reads wip (@yaks/session's rung), then the
|
|
311
|
+
// `task.status` the row carries, else open. The carried value is what the host
|
|
312
|
+
// derived; it holds where a row arrives without its marks (a read answers the
|
|
313
|
+
// components it names, and an edge rider ships projected columns only). A mark
|
|
314
|
+
// the row does carry wins, so a local patch reads its own evidence before the
|
|
315
|
+
// host's older answer. `has` is a component bag (a live row's `.comps`, a
|
|
316
|
+
// Row's comps).
|
|
317
|
+
export let statusOf = (has: Record<string, unknown>) =>
|
|
318
|
+
taskStatus(vocab, has) ?? 'open'
|
|
319
|
+
|
|
320
|
+
// Settled = no longer open work, whether it finished or was called off.
|
|
321
|
+
// Gating, board defaults, and lease-lapse audits all key off this
|
|
322
|
+
// instead of 'done' alone, so a cancelled blocker releases its gate too.
|
|
323
|
+
export { settled }
|
|
324
|
+
|
|
325
|
+
// The shape of one index declaration (see the indexes map in the data
|
|
326
|
+
// section above): its columns, uniqueness, and an optional partial-index
|
|
327
|
+
// predicate.
|
|
328
|
+
export type Idx = { cols: string[]; unique?: boolean; where?: string }
|
|
329
|
+
|
|
330
|
+
export let lazy = (name: string) => partition[name] === 'lazy'
|
|
331
|
+
|
|
332
|
+
// A component's wire-writable column names — what most consumers of the
|
|
333
|
+
// old flat list actually want.
|
|
334
|
+
export let cols = (comp: string) => Object.keys(comps[comp] ?? {})
|
|
335
|
+
|
|
336
|
+
// The reaper's worklists, derived: every wire-writable reference wearing
|
|
337
|
+
// the given death word, as (comp, column) pairs. The host walks these when
|
|
338
|
+
// an entity dies — the declarations above ARE the cascade, so a new
|
|
339
|
+
// reference can't dodge the reaper by forgetting a hand-kept list.
|
|
340
|
+
// (`stamped` refs stay out on purpose: server-owned rows die by server
|
|
341
|
+
// code, not by the wire's cascade.)
|
|
342
|
+
export let deaths = (word: Death): [string, string][] =>
|
|
343
|
+
Object.entries(comps).flatMap(([name, props]) =>
|
|
344
|
+
Object.entries(props).flatMap(([col, t]) =>
|
|
345
|
+
typeof t == 'object' && 'eid' in t && t.death == word
|
|
346
|
+
? [[name, col] as [string, string]]
|
|
347
|
+
: []
|
|
348
|
+
)
|
|
349
|
+
)
|
|
350
|
+
|
|
351
|
+
// The eid minter. Both sides of the wire mint them (clients name their own
|
|
352
|
+
// entities), so it must work on both: crypto.randomUUID is gated to secure
|
|
353
|
+
// contexts and this page is served over plain http on the tailnet, while
|
|
354
|
+
// getRandomValues is gated nowhere.
|
|
355
|
+
export let uuid = () => {
|
|
356
|
+
let b = crypto.getRandomValues(new Uint8Array(16))
|
|
357
|
+
b[6] = (b[6] & 0x0f) | 0x40
|
|
358
|
+
b[8] = (b[8] & 0x3f) | 0x80
|
|
359
|
+
let h = [...b].map((x) => x.toString(16).padStart(2, '0')).join('')
|
|
360
|
+
return `${h.slice(0, 8)}-${h.slice(8, 12)}-${h.slice(12, 16)}-${
|
|
361
|
+
h.slice(16, 20)
|
|
362
|
+
}-${h.slice(20)}`
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
// One log line, in the vocabulary the RENDERER speaks — flat and small, the
|
|
366
|
+
// same six shapes whatever provider wrote it. @yaks/session's readers own the
|
|
367
|
+
// dialects and turn each line into transcript entries, and entry_log.ts turns
|
|
368
|
+
// those into these, so the Session view never learns a vendor:
|
|
369
|
+
// say what the agent (or the human, resuming) actually said
|
|
370
|
+
// reason the model thinking out loud — dim, skippable
|
|
371
|
+
// tool a tool call as a chip: name + ok/✗, its detail, its error
|
|
372
|
+
// exec a shell command it ran — desc says what for, in its own words
|
|
373
|
+
// turn a turn closing, with usage and duration — a divider, not content
|
|
374
|
+
// error the run itself went wrong
|
|
375
|
+
// sys provider housekeeping worth a dim chip: the tag names the
|
|
376
|
+
// family (thinking, hook, task, …), the text carries the gist.
|
|
377
|
+
// A view may squeeze a run of same-tag frames into one line.
|
|
378
|
+
// `at` is the event's clock when the dialect (or our own writer) carries one.
|
|
379
|
+
export type LogRow =
|
|
380
|
+
& { at?: string; context?: number }
|
|
381
|
+
& (
|
|
382
|
+
| { kind: 'say'; role: 'agent' | 'user'; text: string }
|
|
383
|
+
| { kind: 'reason'; text: string }
|
|
384
|
+
| {
|
|
385
|
+
kind: 'tool'
|
|
386
|
+
name: string
|
|
387
|
+
detail?: string
|
|
388
|
+
ok?: boolean
|
|
389
|
+
error?: string
|
|
390
|
+
}
|
|
391
|
+
| {
|
|
392
|
+
kind: 'exec'
|
|
393
|
+
command: string
|
|
394
|
+
desc?: string
|
|
395
|
+
exit?: number
|
|
396
|
+
status?: string
|
|
397
|
+
}
|
|
398
|
+
| { kind: 'turn'; model?: string; usage?: string; ms?: number }
|
|
399
|
+
| { kind: 'error'; text: string }
|
|
400
|
+
| { kind: 'sys'; tag: string; text?: string }
|
|
401
|
+
)
|
|
402
|
+
|
|
403
|
+
// Token counts the way a human reads them: 831, 12k, 1.2M.
|
|
404
|
+
export let kilo = (n: number): string =>
|
|
405
|
+
n < 1000
|
|
406
|
+
? String(n)
|
|
407
|
+
: n < 1e6
|
|
408
|
+
? `${+(n / 1e3).toFixed(n < 10_000 ? 1 : 0)}k`
|
|
409
|
+
: `${+(n / 1e6).toFixed(1)}M`
|
|
410
|
+
|
|
411
|
+
// Precedence as a LOOKUP, one rank per kind. kindOf runs once per row on
|
|
412
|
+
// every snapshot read, so it must cost the ENTITY's component count (a
|
|
413
|
+
// handful), never the vocabulary's (~50 and growing): a scan down kindOrder
|
|
414
|
+
// charges every row for wherever its kind happens to sit, and kindOrder is
|
|
415
|
+
// derived (alphabetical, refined by `before`), so nothing keeps the hot
|
|
416
|
+
// kinds near the front of it.
|
|
417
|
+
//
|
|
418
|
+
// An APP's own components join the same table when a store
|
|
419
|
+
// plants them — the registry query.ts keeps for the
|
|
420
|
+
// filter grammar, safe for the same reason: a row wears a word only if its
|
|
421
|
+
// OWN store planted the table, so no store is ever told about another's
|
|
422
|
+
// rows. They rank NEGATIVE in the order learned, so a store's word beats
|
|
423
|
+
// every platform kind and an earlier-planted word beats a later one.
|
|
424
|
+
let kindRank = new Map(kindOrder.map((k, i) => [k, i]))
|
|
425
|
+
let planted = 0
|
|
426
|
+
|
|
427
|
+
export let learnKinds = (names: Iterable<string>) => {
|
|
428
|
+
for (let name of names) if (!kindRank.has(name)) kindRank.set(name, --planted)
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
// A store's own word is the most specific thing it says about a row, so it
|
|
432
|
+
// outranks every platform kind: an entity carrying `book` IS a book, not the
|
|
433
|
+
// `doc` it also wears for its title (C-32574 item 7).
|
|
434
|
+
export let kindOf = (has: Record<string, unknown>) => {
|
|
435
|
+
let kind = 'entity'
|
|
436
|
+
let best = Infinity
|
|
437
|
+
for (let k in has) {
|
|
438
|
+
if (!has[k]) continue
|
|
439
|
+
let r = kindRank.get(k) ?? Infinity
|
|
440
|
+
if (r < best) [best, kind] = [r, k]
|
|
441
|
+
}
|
|
442
|
+
return kind
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
// The id of an entity read as its components, its `entity` row among them:
|
|
446
|
+
// the number and the prefix stored there, the kind's letter for a row stored
|
|
447
|
+
// without one.
|
|
448
|
+
export let idIn = (
|
|
449
|
+
eid: string,
|
|
450
|
+
has: { entity?: { num?: number | null; prefix?: string | null } },
|
|
451
|
+
) =>
|
|
452
|
+
idOf({
|
|
453
|
+
eid,
|
|
454
|
+
kind: kindOf(has),
|
|
455
|
+
num: has.entity?.num,
|
|
456
|
+
prefix: has.entity?.prefix,
|
|
457
|
+
})
|
|
458
|
+
|
|
459
|
+
// Kinds are singular in the graph and plural in the mouth — a listing is
|
|
460
|
+
// asked for `projects`, never `project`. Derived, so a new kind gets its
|
|
461
|
+
// listing word the moment it joins kindOrder.
|
|
462
|
+
export let plural = (kind: string) =>
|
|
463
|
+
irregular[kind] ??
|
|
464
|
+
(kind.endsWith('y')
|
|
465
|
+
? `${kind.slice(0, -1)}ies`
|
|
466
|
+
: /(?:s|x|ch|sh)$/.test(kind)
|
|
467
|
+
? `${kind}es`
|
|
468
|
+
: `${kind}s`)
|
|
469
|
+
// Every plural spelling — the naive one rides along so whatever a listing
|
|
470
|
+
// accepts as a word, the bare verb accepts too.
|
|
471
|
+
export let plurals = new Set(kindOrder.flatMap((k) => [plural(k), `${k}s`]))
|
|
472
|
+
|
|
473
|
+
// The word a caller types for a kind, in either number — the naive plural
|
|
474
|
+
// too, so `persons` still lands where `people` does.
|
|
475
|
+
export let kindWord = (word: string) =>
|
|
476
|
+
kindOrder.find((k) => k == word || plural(k) == word || `${k}s` == word)
|
|
477
|
+
|
|
478
|
+
// Identity refusals must not become a saved query's ordinary "not loaded" miss.
|
|
479
|
+
export class IdError extends Error {}
|
|
480
|
+
// The hex a short handle (@yaks/id `SHORT`, `#3b5bc70420`) names.
|
|
481
|
+
export let shortHex = (id: string) =>
|
|
482
|
+
SHORT.test(id) ? id.slice(1).toLowerCase() : undefined
|
|
483
|
+
// A WHOLE eid, in every shape a client may name an entity by: the uuid it
|
|
484
|
+
// mints, or the hash a content-addressed entity is its own name by — a
|
|
485
|
+
// blob's sha-256 (64 hex), a commit's git sha (40). One spelling for every
|
|
486
|
+
// id door, so none of them can drift out of knowing a shape the others take
|
|
487
|
+
// (props.ts reference, client.ts minting).
|
|
488
|
+
export let EID =
|
|
489
|
+
/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$|^[0-9a-f]{40}$|^[0-9a-f]{64}$/i
|
|
490
|
+
|
|
491
|
+
// A model's short name — 'claude-fable-5' is fable, 'gpt-5.6-sol' is sol:
|
|
492
|
+
// drop the vendor word and anything wearing a digit, keep what's left.
|
|
493
|
+
// The composer greets an agent by it; a persona's name outranks it once
|
|
494
|
+
// personas exist.
|
|
495
|
+
export let nick = (model?: string | null) => {
|
|
496
|
+
let words = (model ?? '').split('-')
|
|
497
|
+
.filter((w) => w && !/\d/.test(w) && w != 'claude' && w != 'gpt')
|
|
498
|
+
return words.join('-') || null
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
// A model id worn friendly — nick's display face: the vendor prefix and
|
|
502
|
+
// date pin drop, version digits regain their dots, words their caps.
|
|
503
|
+
// 'claude-opus-4-8' → 'Opus 4.8', 'gpt-5.6-sol' → 'GPT 5.6 Sol'.
|
|
504
|
+
export let friendly = (model?: string | null) => {
|
|
505
|
+
let words: string[] = []
|
|
506
|
+
for (
|
|
507
|
+
let w of (model ?? '').replace(/-\d{8}$/, '').split('-').filter(Boolean)
|
|
508
|
+
) {
|
|
509
|
+
if (/^[\d.]+$/.test(w) && /\d$/.test(words.at(-1) ?? '')) {
|
|
510
|
+
words[words.length - 1] += `.${w}`
|
|
511
|
+
} else if (w != 'claude') {
|
|
512
|
+
words.push(w == 'gpt' ? 'GPT' : w[0].toUpperCase() + w.slice(1))
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
return words.join(' ') || null
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
export type Edge = (typeof edges)[number]
|
|
519
|
+
|
|
520
|
+
// The written face of an entity — title and markdown body. Anything can
|
|
521
|
+
// carry one: tasks and boards do; notes, comments, and future kinds get
|
|
522
|
+
// rendering/editing/files for free by carrying it too.
|
|
523
|
+
// `body` is optional because a payload may DEFER it (a `.fields=` projection):
|
|
524
|
+
// undefined means unloaded, '' means empty, and the column defaults to ''
|
|
525
|
+
// so the two can never be confused. Every reader must tell them apart —
|
|
526
|
+
// paint a placeholder and ask (live.ts `pending`), never treat a missing
|
|
527
|
+
// body as an empty one, which is how an editor clobbers a stored body.
|
|
528
|
+
export type Doc = { eid: string; title: string; body?: string }
|
|
529
|
+
|
|
530
|
+
// Workflow state only — a task is a doc with task-management added.
|
|
531
|
+
export type Task = {
|
|
532
|
+
eid: string
|
|
533
|
+
// DERIVED (D-24102), never stored: statusOf reads it off the completed/
|
|
534
|
+
// cancelled/claim comps, and rowed() materializes it onto a read shape. Present
|
|
535
|
+
// on a row that has been through statusOf; absent on a bare write literal.
|
|
536
|
+
status?: string
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
// Optional portfolio filing; a microtask carries none of these columns.
|
|
540
|
+
export type Filed = {
|
|
541
|
+
eid: string
|
|
542
|
+
priority?: number | null // board order within a status column; lower sorts first
|
|
543
|
+
project?: string | null // the project (venture) this task belongs to
|
|
544
|
+
assignee?: string | null // whose plate — durable; claim is who's on it now
|
|
545
|
+
// Cross-project facet (Eng, Legal, Ops, …), free text by convention; a
|
|
546
|
+
// picker derives its options from distinct values.
|
|
547
|
+
domain?: string | null
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
// Acceptance criteria are their own deferred Markdown body, distinct from the
|
|
551
|
+
// task's narrative and from the review that records a verdict.
|
|
552
|
+
export type Accept = { eid: string; body?: string }
|
|
553
|
+
|
|
554
|
+
// A tag: "this doc fronts a project" (a venture, a workstream). Its name
|
|
555
|
+
// is its doc.title — one naming mechanism, no drift. An archived project is
|
|
556
|
+
// over — kept, referenceable, sunk in every ranking.
|
|
557
|
+
export type ProjectTag = { eid: string }
|
|
558
|
+
|
|
559
|
+
// Where a project's code lives: a checkout on this box and the branch a
|
|
560
|
+
// session's worktree grows from. A tag like project — it never names an
|
|
561
|
+
// entity alone (doc+project+repo is still a project), so it stays out of
|
|
562
|
+
// kindOrder. Wire-writable, because the owner points a project at a
|
|
563
|
+
// checkout from the UI or the CLI like any other data; spawning only
|
|
564
|
+
// READS it, so a browser can never hand the server a path to run in.
|
|
565
|
+
// `push` is that same owner saying the projection's commits may leave the
|
|
566
|
+
// box for this venture — a per-venture permission because in some of them
|
|
567
|
+
// a push to main deploys.
|
|
568
|
+
export type Repo = {
|
|
569
|
+
eid: string
|
|
570
|
+
path: string
|
|
571
|
+
url?: string | null
|
|
572
|
+
base_branch: string
|
|
573
|
+
gate?: string | null
|
|
574
|
+
push?: boolean
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
// A project's venture facet (@yaks/project): the phase it is in and its
|
|
578
|
+
// address. A tag like project/repo — it never names an entity alone, so it
|
|
579
|
+
// stays out of kindOrder.
|
|
580
|
+
export type Venture = {
|
|
581
|
+
eid: string
|
|
582
|
+
phase?: string | null
|
|
583
|
+
tagline?: string | null
|
|
584
|
+
site?: string | null
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
// A board is a saved filter over tasks: `query` speaks the query.ts
|
|
588
|
+
// grammar ('.filed.project=…&.task.status=open,wip'); empty/null selects NOTHING —
|
|
589
|
+
// a board that means "every task" says `.task`.
|
|
590
|
+
export type BoardTag = { eid: string; query?: string | null }
|
|
591
|
+
|
|
592
|
+
// A tiling layout (D-14718): the doc names it, root its top pane.
|
|
593
|
+
export type LayoutTag = { eid: string; root?: string | null }
|
|
594
|
+
|
|
595
|
+
// One pane: container (dir set, children point here via parent) or
|
|
596
|
+
// leaf (content + view). size is its weight among siblings.
|
|
597
|
+
export type Pane = {
|
|
598
|
+
eid: string
|
|
599
|
+
layout?: string | null
|
|
600
|
+
parent?: string | null
|
|
601
|
+
size?: number
|
|
602
|
+
order?: number
|
|
603
|
+
dir?: string | null
|
|
604
|
+
content?: string | null
|
|
605
|
+
view?: string | null
|
|
606
|
+
}
|
|
607
|
+
// An external page. The URL is what was pasted; the rendered thing is the
|
|
608
|
+
// server's frozen archive of it (one self-contained HTML file on disk),
|
|
609
|
+
// stamped frozen_at when ready — frozen_at is server-owned, never wire-set.
|
|
610
|
+
export type Web = { eid: string; url: string; frozen_at?: string | null }
|
|
611
|
+
// Immutable content: eid is its SHA-256; external bytes live beside the db.
|
|
612
|
+
// The word is @yaks/blob's own for the stored thing — `blob` there names the
|
|
613
|
+
// STORE, and @yaks/git's `blob{sha}` is a git blob, a different idea.
|
|
614
|
+
export type Artifact = {
|
|
615
|
+
eid: string
|
|
616
|
+
address: string
|
|
617
|
+
media_type: string
|
|
618
|
+
size?: number | null
|
|
619
|
+
}
|
|
620
|
+
// Per-use file metadata points at shared content.
|
|
621
|
+
export type Attachment = {
|
|
622
|
+
eid: string
|
|
623
|
+
artifact: string
|
|
624
|
+
media_type?: string | null
|
|
625
|
+
name?: string | null
|
|
626
|
+
}
|
|
627
|
+
export type Image = {
|
|
628
|
+
eid: string
|
|
629
|
+
w?: number | null
|
|
630
|
+
h?: number | null
|
|
631
|
+
}
|
|
632
|
+
export type CardComp = { eid: string; target: string; view: string }
|
|
633
|
+
export type Pin = {
|
|
634
|
+
eid: string
|
|
635
|
+
canvas: string
|
|
636
|
+
x: number
|
|
637
|
+
y: number
|
|
638
|
+
w: number
|
|
639
|
+
h: number
|
|
640
|
+
z: number // stacking order; dragging a card raises it to top
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
// A browser identity: its uuid is minted client-side into localStorage on
|
|
644
|
+
// first visit. ip is server-stamped (a client can't self-report one).
|
|
645
|
+
export type Client = {
|
|
646
|
+
eid: string
|
|
647
|
+
user_agent: string
|
|
648
|
+
ip: string
|
|
649
|
+
actor?: string | null // who this browser acts for (comps comment)
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
// A camera joins a client to a canvas: per-client pan/zoom, one row per
|
|
653
|
+
// (client, canvas) pair — canvases nest, so this is NOT keyed by the client.
|
|
654
|
+
// x/y is the viewport CENTER in plane coords; w/h is the viewport size in
|
|
655
|
+
// screen px, stored so other clients can render each other's viewports.
|
|
656
|
+
export type Camera = {
|
|
657
|
+
eid: string
|
|
658
|
+
client: string
|
|
659
|
+
canvas: string
|
|
660
|
+
x: number
|
|
661
|
+
y: number
|
|
662
|
+
zoom: number
|
|
663
|
+
w: number
|
|
664
|
+
h: number
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
// A client's folded columns on one board — per-client UI state IN the
|
|
668
|
+
// graph (like camera), so it syncs across tabs and agents can see it.
|
|
669
|
+
// statuses is a comma-joined list of folded column names.
|
|
670
|
+
export type Fold = {
|
|
671
|
+
eid: string
|
|
672
|
+
client: string
|
|
673
|
+
board: string
|
|
674
|
+
statuses: string
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
// A cursor joins a client to where it is LOOKING — one row per client, the
|
|
678
|
+
// per-client twin of camera (which is per client+canvas). target is the
|
|
679
|
+
// fullscreened entity, view its ?v= tab. Navigation as graph data: the
|
|
680
|
+
// browser writes it on navigate, an agent writes it to move the human's tab.
|
|
681
|
+
export type Cursor = {
|
|
682
|
+
eid: string
|
|
683
|
+
client: string
|
|
684
|
+
target?: string | null
|
|
685
|
+
view?: string | null
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
export type Favorite = { eid: string; at?: string | null }
|
|
689
|
+
export type Setting = {
|
|
690
|
+
eid: string
|
|
691
|
+
key?: string | null
|
|
692
|
+
value?: string | null
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
// An agent session as yak keeps it. `session` is who it is and the status the
|
|
696
|
+
// host derives from its transcript; the rest are components beside it: `using`
|
|
697
|
+
// names the provider and model entities it runs on, `process` and `exit` the
|
|
698
|
+
// process behind it when it has one, and `created.at` when it began.
|
|
699
|
+
export type Session = {
|
|
700
|
+
eid: string
|
|
701
|
+
id: string
|
|
702
|
+
actor?: string | null // who this run acts for
|
|
703
|
+
operator?: boolean | null // receives project-wide attention
|
|
704
|
+
persona?: string | null // the persona it wears
|
|
705
|
+
standing?: string | null // log-derived: busy|terminal|idle
|
|
706
|
+
status?: typeof sessionStates[number] | null // derived by the host
|
|
707
|
+
}
|
|
708
|
+
export type Using = {
|
|
709
|
+
eid: string
|
|
710
|
+
provider?: string | null // a provider entity
|
|
711
|
+
model?: string | null // a model entity
|
|
712
|
+
effort?: string | null
|
|
713
|
+
instructions?: string | null
|
|
714
|
+
}
|
|
715
|
+
export type Process = {
|
|
716
|
+
eid: string
|
|
717
|
+
pid?: number | null
|
|
718
|
+
command?: string | null
|
|
719
|
+
cwd?: string | null
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
// Token counts a provider self-reported for a settled session, normalized to
|
|
723
|
+
// ONE vocabulary (Anthropic's field names) at the adapter — the browser and CLI
|
|
724
|
+
// read this shape, never a vendor's. Distinct from the per-entry `Usage`
|
|
725
|
+
// component below: this splits cache reads from cache writes (their prices
|
|
726
|
+
// differ 12×), which cost needs and `Usage.cached` conflates. Every field is
|
|
727
|
+
// optional ON PURPOSE: a count a provider never reported stays ABSENT, it never
|
|
728
|
+
// folds to 0 (absent beats zero — a missing number is not a free one). `input`
|
|
729
|
+
// is FRESH input only, cache reads/writes split out, so the four are comparable
|
|
730
|
+
// across providers even though each vendor slices its bill differently.
|
|
731
|
+
export type Tokens = {
|
|
732
|
+
input?: number // fresh (uncached) input tokens
|
|
733
|
+
cache_read?: number // input served from cache (Anthropic's discount tier)
|
|
734
|
+
cache_creation?: number // input written to cache (Anthropic's premium tier)
|
|
735
|
+
output?: number // generated tokens (reasoning included, as the bill counts it)
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
// One ordered Session-log entity. Every other log shape is a facet on this
|
|
739
|
+
// entity; seq is minted by the server within the Session partition.
|
|
740
|
+
export type Entry = { eid: string; session: string; seq: number }
|
|
741
|
+
// Where in a file an entity sits (@yaks/file): for an entry read from a
|
|
742
|
+
// transcript, the file and the 1-based line it came from, distinct from
|
|
743
|
+
// entry.seq.
|
|
744
|
+
export type Lines = { eid: string; file: string; start: number; end?: number }
|
|
745
|
+
export type Content = { eid: string; body: string }
|
|
746
|
+
export type Message = { eid: string; role: typeof messageRoles[number] }
|
|
747
|
+
export type Generation = {
|
|
748
|
+
eid: string
|
|
749
|
+
through: string
|
|
750
|
+
provider: string
|
|
751
|
+
model: string
|
|
752
|
+
effort?: string | null
|
|
753
|
+
serving_model?: string | null
|
|
754
|
+
}
|
|
755
|
+
export type Output = {
|
|
756
|
+
eid: string
|
|
757
|
+
source: string
|
|
758
|
+
id?: string | null
|
|
759
|
+
}
|
|
760
|
+
export type Call = {
|
|
761
|
+
eid: string
|
|
762
|
+
to?: string | null
|
|
763
|
+
id?: string | null
|
|
764
|
+
args?: Record<string, unknown> | null
|
|
765
|
+
source?: string | null
|
|
766
|
+
}
|
|
767
|
+
// Provider-neutral named tool use (D-16704): an imported tool call with no
|
|
768
|
+
// first-class facet keeps its real name and a one-line arg preview. The word
|
|
769
|
+
// is the transcript's own — @yaks/tools' `tool` is the registered tool ENTITY
|
|
770
|
+
// a call points at, and this is the block in the log that used one.
|
|
771
|
+
export type ToolUse = { eid: string; name: string; detail?: string | null }
|
|
772
|
+
export type Bash = { eid: string; command: string; cwd?: string | null }
|
|
773
|
+
export type Fetch = {
|
|
774
|
+
eid: string
|
|
775
|
+
url: string
|
|
776
|
+
method: typeof httpMethods[number]
|
|
777
|
+
}
|
|
778
|
+
export type Patch = { eid: string; path: string; diff: string }
|
|
779
|
+
export type GraphQuery = { eid: string; query?: string | null }
|
|
780
|
+
export type ApplyComp = { eid: string; changes: string }
|
|
781
|
+
export type Result = { eid: string; call: string }
|
|
782
|
+
export type Exit = { eid: string; code: number }
|
|
783
|
+
export type ResponseComp = { eid: string; status: number }
|
|
784
|
+
export type Headers = { eid: string; data: string }
|
|
785
|
+
export type Stderr = { eid: string; text: string }
|
|
786
|
+
export type Brief = { eid: string; text: string }
|
|
787
|
+
export type Timeout = { eid: string; ms: number }
|
|
788
|
+
export type Checkpoint = { eid: string; through: string }
|
|
789
|
+
export type Recalled = { eid: string; source: string }
|
|
790
|
+
export type Cancel = { eid: string; target: string }
|
|
791
|
+
export type Opaque = { eid: string; format: string; data: string }
|
|
792
|
+
export type Runner = { eid: string; name: string }
|
|
793
|
+
export type Lease = {
|
|
794
|
+
eid: string
|
|
795
|
+
holder: string
|
|
796
|
+
at: string
|
|
797
|
+
until: string
|
|
798
|
+
}
|
|
799
|
+
export type Usage = {
|
|
800
|
+
eid: string
|
|
801
|
+
input_tokens?: number
|
|
802
|
+
output_tokens?: number
|
|
803
|
+
total_tokens?: number
|
|
804
|
+
cached_tokens?: number
|
|
805
|
+
reasoning_tokens?: number
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
// What a session's life is read from: its own row, and the process behind
|
|
809
|
+
// it, which has an `exit` once it is gone.
|
|
810
|
+
export type Life = {
|
|
811
|
+
session?: Session | null
|
|
812
|
+
process?: Process | null
|
|
813
|
+
exit?: Exit | null
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
// Is anybody home? A session whose transcript still asks for work is, and so
|
|
817
|
+
// is one whose process has not exited — a harness session announces itself
|
|
818
|
+
// with a pid and keeps no transcript for the host to read a status from.
|
|
819
|
+
export let awake = (e: Life) =>
|
|
820
|
+
sessionActive.includes(String(e.session?.status)) ||
|
|
821
|
+
(!!e.process?.pid && !e.exit)
|
|
822
|
+
|
|
823
|
+
// The word a session's pip and label wear. Between turns an awake session is
|
|
824
|
+
// idle; otherwise its status, or `running` while only its process says so. An
|
|
825
|
+
// ended one keeps its ending.
|
|
826
|
+
export let standing = (e: Life) =>
|
|
827
|
+
awake(e) && e.session?.standing == 'idle'
|
|
828
|
+
? 'idle'
|
|
829
|
+
: e.session?.status || (awake(e) ? 'running' : '')
|
|
830
|
+
|
|
831
|
+
// A session's lease on an entity — claims point at the session ENTITY.
|
|
832
|
+
// One claim per entity; taking one over another session's is a CONFLICT
|
|
833
|
+
// the server rejects — release first (comp: null), then claim.
|
|
834
|
+
export type Claim = { eid: string; session: string; at?: string }
|
|
835
|
+
|
|
836
|
+
// One task parked on one actor's interruption stack. rank preserves the
|
|
837
|
+
// nested claim order when one wrap releases several leases at the same time.
|
|
838
|
+
export type Resume = {
|
|
839
|
+
eid: string
|
|
840
|
+
actor: string
|
|
841
|
+
at: string
|
|
842
|
+
rank: number
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
// A request to stop the session it targets — the graph-native stop
|
|
846
|
+
// button. Created over the wire, acted on by the server's effect, kept
|
|
847
|
+
// as audit; acted_at is stamped when the signals have been sent.
|
|
848
|
+
// A stop signal, sent. It settles into `delivered` once the signals leave
|
|
849
|
+
// — no receipt column of its own; the audit row is the request.
|
|
850
|
+
export type StopRequest = { eid: string; target: string }
|
|
851
|
+
|
|
852
|
+
// An entity's mail address — the address-book facet, one comp for all.
|
|
853
|
+
export type Email = { eid: string; address: string }
|
|
854
|
+
|
|
855
|
+
// Addressing (D-14945): WHERE a deliverable goes. `to` names a graph
|
|
856
|
+
// entity — the recipient a knock/wake/outbound-mail is aimed at. Shared
|
|
857
|
+
// across the deliverable kinds, the intent half of the deliver/delivered/
|
|
858
|
+
// failed triad.
|
|
859
|
+
export type Deliver = { eid: string; to: string }
|
|
860
|
+
|
|
861
|
+
// A knock: the request column is the ask (what to look at); WHO looks is
|
|
862
|
+
// the `deliver {to}` facet, and the outcome the shared `delivered`/`failed`
|
|
863
|
+
// facet — neither a column here.
|
|
864
|
+
export type Knock = {
|
|
865
|
+
eid: string
|
|
866
|
+
target: string
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
// A knock waiting on the clock: `at` absolute (resolved at mint). WHO to
|
|
870
|
+
// wake is the `deliver {to}` facet; the outcome — the timer fired and
|
|
871
|
+
// minted the knock, or why it couldn't — is the shared `delivered`/`failed`
|
|
872
|
+
// facet. Neither a column here.
|
|
873
|
+
export type Wake = {
|
|
874
|
+
eid: string
|
|
875
|
+
at: string
|
|
876
|
+
target?: string | null
|
|
877
|
+
note?: string | null
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
// A dream: a venture's consolidation cursor. `scope` is the
|
|
881
|
+
// venture project it combs; `floor` the sliding cursor over sessions
|
|
882
|
+
// finished since. Both wire-writable — `task dream <project>` mints the
|
|
883
|
+
// entity; the comb advances the floor.
|
|
884
|
+
export type Dream = {
|
|
885
|
+
eid: string
|
|
886
|
+
scope?: string | null
|
|
887
|
+
floor?: string | null
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
// Mail, either direction (@yaks/mail): `to` is the address, `at` when it
|
|
891
|
+
// was sent or arrived. An INBOUND mail carries message_id (also the
|
|
892
|
+
// never-send mark) and the edge's verified verdict.
|
|
893
|
+
export type Mail = {
|
|
894
|
+
eid: string
|
|
895
|
+
from?: string | null
|
|
896
|
+
to?: string | null
|
|
897
|
+
at?: string | null
|
|
898
|
+
target?: string | null
|
|
899
|
+
reply_to?: string | null
|
|
900
|
+
message_id?: string | null
|
|
901
|
+
verified?: boolean | null
|
|
902
|
+
in_reply_to?: string | null
|
|
903
|
+
reply_address?: string | null
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
// The shared outcome and health facets (D-14945): `delivered` reached its
|
|
907
|
+
// destination (`via` says how — cast S-9 / spawned S-9 / local / a
|
|
908
|
+
// Message-ID), and `failed` is @yaks/kernel's mark on work that was tried and
|
|
909
|
+
// given up on (`reason` says why). The word is a MARK, beside `delivered`,
|
|
910
|
+
// because @yaks/tools spells a tool's own expected outcome `refusal{code}` and
|
|
911
|
+
// one word answers to one idea. `.failed` is the fleet health query.
|
|
912
|
+
export type Delivered = { eid: string; at?: string | null; via?: string | null }
|
|
913
|
+
export type Failure = {
|
|
914
|
+
eid: string
|
|
915
|
+
at?: string | null
|
|
916
|
+
by?: string | null
|
|
917
|
+
via?: string | null
|
|
918
|
+
reason?: string | null
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
// What was thrown, retained in an answer or transcript entry (@yaks/tools).
|
|
922
|
+
export type Exception = {
|
|
923
|
+
eid: string
|
|
924
|
+
type?: string | null
|
|
925
|
+
value?: string | null
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
// The self-healing diagnosis facet (D-17077): a task auto-filed about an
|
|
929
|
+
// error, keyed for dedup and tallying its recurrences in place.
|
|
930
|
+
export type Bug = {
|
|
931
|
+
eid: string
|
|
932
|
+
fault?: string | null
|
|
933
|
+
hits?: number | null
|
|
934
|
+
last?: string | null
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
// The dream's dedup marker (T-17407): the shape key of a filed finding and its
|
|
938
|
+
// recurrence tally, riding on the consider-task or memory the finding became.
|
|
939
|
+
export type Finding = {
|
|
940
|
+
eid: string
|
|
941
|
+
key?: string | null
|
|
942
|
+
hits?: number | null
|
|
943
|
+
last?: string | null
|
|
944
|
+
}
|
|
945
|
+
|
|
946
|
+
// The block facet (D-17094): this task is stuck on an EXTERNAL thing with no
|
|
947
|
+
// entity. `on` is that free-text reason (wire-written); `since` is when it
|
|
948
|
+
// became blocked (server-stamped). The only thing that reddens the Dot.
|
|
949
|
+
export type Blocked = {
|
|
950
|
+
eid: string
|
|
951
|
+
on?: string | null
|
|
952
|
+
since?: string | null
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
// The git-anchor facet (D-18378): the revision an entity was verified against.
|
|
956
|
+
// `paths` are repo-relative paths/globs (newline- or comma-separated); `sha`
|
|
957
|
+
// the commit last verified against; the exact tiers (D-21211) narrow the first
|
|
958
|
+
// path to a symbol, a hunk of raw text, and/or a 1-based inclusive line range.
|
|
959
|
+
// All wire-written; freshness is derived at read time by asking git, never
|
|
960
|
+
// stored.
|
|
961
|
+
export type Anchor = {
|
|
962
|
+
eid: string
|
|
963
|
+
paths?: string | null
|
|
964
|
+
sha?: string | null
|
|
965
|
+
symbol?: string | null
|
|
966
|
+
hunk?: string | null
|
|
967
|
+
start?: number | null
|
|
968
|
+
end?: number | null
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
// A webhook delivery, pulled apart from the edge's raw request spool —
|
|
972
|
+
// all server-stamped (see `stamped`), payload kept verbatim.
|
|
973
|
+
export type Hook = {
|
|
974
|
+
eid: string
|
|
975
|
+
source?: string | null
|
|
976
|
+
event?: string | null
|
|
977
|
+
payload?: string | null
|
|
978
|
+
spool_id?: string | null
|
|
979
|
+
received_at?: string | null
|
|
980
|
+
method?: string | null
|
|
981
|
+
path?: string | null
|
|
982
|
+
headers?: string | null
|
|
983
|
+
sig_ok?: boolean | null
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
// A comment is a doc AIMED at something — and since target is any
|
|
987
|
+
// entity, ANYTHING is commentable: tasks, boards, frozen pages, other
|
|
988
|
+
// comments. Its actor and instrument ride the universal created stamp.
|
|
989
|
+
export type Comment = {
|
|
990
|
+
eid: string
|
|
991
|
+
target: string
|
|
992
|
+
reply_to?: string | null
|
|
993
|
+
}
|
|
994
|
+
|
|
995
|
+
// A commit: a git revision landed FOR its target (M-31946 §7) — the
|
|
996
|
+
// structured twin of a comment, with no doc: sha, repo and the whole
|
|
997
|
+
// message are columns; compact rows show the message's first line.
|
|
998
|
+
export type Commit = {
|
|
999
|
+
eid: string
|
|
1000
|
+
target: string
|
|
1001
|
+
sha?: string
|
|
1002
|
+
repo?: string
|
|
1003
|
+
message?: string
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
// A signal: a doc EMITTED about its target, not said (D-13858). Same aim
|
|
1007
|
+
// column as comment, and `event` names what happened; the words ride the
|
|
1008
|
+
// doc. Delivered by the bus beside comments, but never a comment — off the
|
|
1009
|
+
// mail relay, out of the conversation thread. The word is the
|
|
1010
|
+
// fleet's because @yaks/session spells a passive transcript line `notice`.
|
|
1011
|
+
export type Signal = {
|
|
1012
|
+
eid: string
|
|
1013
|
+
target: string
|
|
1014
|
+
event: string
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
// A verdict-bearing comment. The aim, rationale, and authorship stay on
|
|
1018
|
+
// comment + doc + created; this component contributes only judgment.
|
|
1019
|
+
export type Review = {
|
|
1020
|
+
eid: string
|
|
1021
|
+
verdict: string
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
// A claim that BOUNCED, kept as an entity: who tried (loser), who held
|
|
1025
|
+
// (holder) — session references; a loser whose session was minted in the
|
|
1026
|
+
// very batch that rolled back has no spine row and is null. Server-minted
|
|
1027
|
+
// only; audit contention with graph_query kind=conflict.
|
|
1028
|
+
export type Conflict = {
|
|
1029
|
+
eid: string
|
|
1030
|
+
target: string
|
|
1031
|
+
loser: string | null
|
|
1032
|
+
holder: string | null
|
|
1033
|
+
at?: string
|
|
1034
|
+
}
|
|
1035
|
+
|
|
1036
|
+
// An audit entity for bytes deliberately removed from live doc state and its
|
|
1037
|
+
// journal history. The created stamp carries when/by/via; only the digest of
|
|
1038
|
+
// the removed value remains.
|
|
1039
|
+
export type Redaction = {
|
|
1040
|
+
eid: string
|
|
1041
|
+
target: string
|
|
1042
|
+
column: 'title' | 'body'
|
|
1043
|
+
hash: string
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1046
|
+
// A value that names an entity, on an entity of its own: `key{of, value}`,
|
|
1047
|
+
// beside a tag saying which kind of value it is (@yaks/key). `alias{}` is the
|
|
1048
|
+
// tag for a name, a handle accepted wherever an id is (@yaks/alias); an entity
|
|
1049
|
+
// may have several, each unique in the store.
|
|
1050
|
+
export type Key = { eid: string; of: string; value: string }
|
|
1051
|
+
export type Alias = { eid: string }
|
|
1052
|
+
|
|
1053
|
+
// The name an alias key gives and the entity it names — one reading for every
|
|
1054
|
+
// resolution door (client.ts find, live.ts cache); undefined for any other
|
|
1055
|
+
// row.
|
|
1056
|
+
export let aliasOf = (
|
|
1057
|
+
c: { alias?: unknown; key?: { of?: unknown; value?: unknown } | null },
|
|
1058
|
+
): { name: string; eid: string } | undefined =>
|
|
1059
|
+
c.alias && c.key?.value && c.key.of
|
|
1060
|
+
? { name: String(c.key.value), eid: String(c.key.of) }
|
|
1061
|
+
: undefined
|
|
1062
|
+
|
|
1063
|
+
// A wearable voice: core text in the doc, tiers in the edges, home in
|
|
1064
|
+
// home (null = fleet-shared).
|
|
1065
|
+
export type Persona = { eid: string; home?: string | null }
|
|
1066
|
+
|
|
1067
|
+
// A model reified (D-21308): name is the wire spelling the session and
|
|
1068
|
+
// generation string columns speak, vendor its maker, grade its tier.
|
|
1069
|
+
export type Model = {
|
|
1070
|
+
eid: string
|
|
1071
|
+
name?: string | null
|
|
1072
|
+
vendor?: string | null
|
|
1073
|
+
grade?: string | null
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
// A tool a transcript's calls name (@yaks/tools `tool`).
|
|
1077
|
+
export type Tool = {
|
|
1078
|
+
eid: string
|
|
1079
|
+
name?: string | null
|
|
1080
|
+
title?: string | null
|
|
1081
|
+
description?: string | null
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
// A distilled fact the fleet keeps: content in the doc, provenance in
|
|
1085
|
+
// created, scope in scope (the project it belongs to; absent = a
|
|
1086
|
+
// principle every operator carries). last_confirmed_at is the last explicit
|
|
1087
|
+
// re-confirmation — server-stamped, like every recall statistic.
|
|
1088
|
+
export type Memory = {
|
|
1089
|
+
eid: string
|
|
1090
|
+
scope?: string | null
|
|
1091
|
+
last_confirmed_at?: string | null
|
|
1092
|
+
}
|
|
1093
|
+
|
|
1094
|
+
// A standing purpose (M-31946 §5): the doc carries the words, `scope` the
|
|
1095
|
+
// project it guides (absent = fleet-wide). Never completed or reviewed —
|
|
1096
|
+
// tasks `satisfies` it.
|
|
1097
|
+
export type Goal = {
|
|
1098
|
+
eid: string
|
|
1099
|
+
scope?: string | null
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
// This entity records feedback; `by` is who gave it, absent when nobody
|
|
1103
|
+
// wrote the source down. A facet — any entity may wear it.
|
|
1104
|
+
export type Feedback = { eid: string; by?: string | null }
|
|
1105
|
+
|
|
1106
|
+
// Recall aggregates, server-minted on every activation.
|
|
1107
|
+
// Three numbers are the whole model: query.ts hot() derives stability
|
|
1108
|
+
// (count and spacing) and decays against last_at at read time — no
|
|
1109
|
+
// stored score anywhere, nothing to sweep.
|
|
1110
|
+
export type Recall = {
|
|
1111
|
+
eid: string
|
|
1112
|
+
count: number
|
|
1113
|
+
first_at: string
|
|
1114
|
+
last_at: string
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
// Provenance, paired when+who+how (T-6670/T-7113). `at` is server-frozen,
|
|
1118
|
+
// `by` the actor (wire-writable for attribution), and `via` the server-stamped
|
|
1119
|
+
// instrument. `created` is set once; `updated` is the last edit and is absent
|
|
1120
|
+
// until the first modification after birth (absence = never edited).
|
|
1121
|
+
export type Created = {
|
|
1122
|
+
eid: string
|
|
1123
|
+
at?: string
|
|
1124
|
+
by?: string | null
|
|
1125
|
+
via?: string | null
|
|
1126
|
+
}
|
|
1127
|
+
export type Updated = Created
|
|
1128
|
+
|
|
1129
|
+
// A moment stamped on an entity — the notification lifecycle (T-7006:
|
|
1130
|
+
// presence records it, the whole stamp is server-frozen), `decided`, and
|
|
1131
|
+
// `proposed` (the wire dates and signs them, the server names the instrument).
|
|
1132
|
+
// Same shape as Created/Updated; absence is the earlier state (no `opened`
|
|
1133
|
+
// row == unread, no `decided` row == nothing settled, no `proposed` row ==
|
|
1134
|
+
// self-authorizing work). Read as pure Row-predicates, like unreadMail today.
|
|
1135
|
+
export type Stamp = Created
|
|
1136
|
+
|
|
1137
|
+
// `decided` alone carries which way it went; absent verdict reads as
|
|
1138
|
+
// approved (what pre-verdict rows meant when stamped).
|
|
1139
|
+
export type Decided = Stamp & {
|
|
1140
|
+
verdict?: string | null
|
|
1141
|
+
choice?: string | null
|
|
1142
|
+
}
|
|
1143
|
+
|
|
1144
|
+
// A row a search answered, as the palette groups and opens it. What it says
|
|
1145
|
+
// and where the words matched are its tile's (views/Search.tsx).
|
|
1146
|
+
export type Hit = {
|
|
1147
|
+
eid: string
|
|
1148
|
+
num: number
|
|
1149
|
+
kind: string
|
|
1150
|
+
title: string
|
|
1151
|
+
score?: number // query-only relevance; larger ranks earlier
|
|
1152
|
+
}
|
|
1153
|
+
|
|
1154
|
+
// `ord` is an optional, editable listing order for the edge — a tie-break
|
|
1155
|
+
// among members of one (parent, type) that share a rank. Only persona
|
|
1156
|
+
// materialization reads it today (equal-warmth tier members list in a
|
|
1157
|
+
// declared order, stable across databases and rewrites); every other edge
|
|
1158
|
+
// leaves it null and behaves exactly as before. Lower sorts first.
|
|
1159
|
+
export type Dep = { parent: string; type: Edge; child: string; ord?: number }
|
|
1160
|
+
|
|
1161
|
+
// An outgoing edge, verb + child — the Dependency view resolves the name.
|
|
1162
|
+
export type Ref = { type: Edge; child: string }
|
|
1163
|
+
|
|
1164
|
+
// The bundle a renderer pattern-matches on: the entity plus whichever
|
|
1165
|
+
// components it carries, its edge sentences, and the entities it
|
|
1166
|
+
// contains. kind is derived (kindOf) — display convention, not data.
|
|
1167
|
+
// EntCore is the CLOSED, precise face: one field per known component, each its
|
|
1168
|
+
// exact type, plus the scalar spine (eid/num/kind) and edges (refs/kids). Ent
|
|
1169
|
+
// (below) is the OPEN face the renderers see — a plugin's own component has no
|
|
1170
|
+
// core field, so the index signature admits it (as `unknown`, the only element
|
|
1171
|
+
// type that also tolerates the scalar spine in an object literal), enough to
|
|
1172
|
+
// pattern-match with has() while every known comp keeps its precise type
|
|
1173
|
+
// (intersection: T & unknown = T). The split is load-bearing: a bare index
|
|
1174
|
+
// signature INSIDE this literal would collapse `keyof Ent` to `string`, so
|
|
1175
|
+
// `Comps = Omit<Ent, …>` (live.ts) would lose every precise type. Applying the
|
|
1176
|
+
// index signature by intersection over a closed core keeps both faces honest
|
|
1177
|
+
// (D-18663 seam 2, T-12765 option 1). The richer option — derive EntCore from
|
|
1178
|
+
// `comps` — is deferred to T-18672.
|
|
1179
|
+
export type EntCore = {
|
|
1180
|
+
eid: string
|
|
1181
|
+
num: number
|
|
1182
|
+
/** the letter of the series `num` is in (@yaks/id) */
|
|
1183
|
+
prefix?: string
|
|
1184
|
+
kind: string
|
|
1185
|
+
doc?: Doc
|
|
1186
|
+
design?: { eid: string }
|
|
1187
|
+
goal?: Goal
|
|
1188
|
+
architecture?: { eid: string }
|
|
1189
|
+
task?: Task
|
|
1190
|
+
filed?: Filed
|
|
1191
|
+
accept?: Accept
|
|
1192
|
+
project?: ProjectTag
|
|
1193
|
+
venture?: Venture
|
|
1194
|
+
person?: { eid: string }
|
|
1195
|
+
repo?: Repo
|
|
1196
|
+
canvas?: { eid: string }
|
|
1197
|
+
board?: BoardTag
|
|
1198
|
+
layout?: LayoutTag
|
|
1199
|
+
pane?: Pane
|
|
1200
|
+
web?: Web
|
|
1201
|
+
artifact?: Artifact
|
|
1202
|
+
attachment?: Attachment
|
|
1203
|
+
image?: Image
|
|
1204
|
+
card?: CardComp
|
|
1205
|
+
pin?: Pin
|
|
1206
|
+
client?: Client
|
|
1207
|
+
camera?: Camera
|
|
1208
|
+
fold?: Fold
|
|
1209
|
+
cursor?: Cursor
|
|
1210
|
+
favorite?: Favorite
|
|
1211
|
+
setting?: Setting
|
|
1212
|
+
subscription?: {
|
|
1213
|
+
eid: string
|
|
1214
|
+
actor?: string | null
|
|
1215
|
+
target?: string | null
|
|
1216
|
+
mode?: (typeof subModes)[number]
|
|
1217
|
+
}
|
|
1218
|
+
chat?: { eid: string; actor?: string | null; target?: string | null }
|
|
1219
|
+
session?: Session
|
|
1220
|
+
using?: Using
|
|
1221
|
+
process?: Process
|
|
1222
|
+
brief?: Brief
|
|
1223
|
+
entry?: Entry
|
|
1224
|
+
lines?: Lines
|
|
1225
|
+
content?: Content
|
|
1226
|
+
message?: Message
|
|
1227
|
+
attention?: { eid: string }
|
|
1228
|
+
generation?: Generation
|
|
1229
|
+
output?: Output
|
|
1230
|
+
call?: Call
|
|
1231
|
+
tool_use?: ToolUse
|
|
1232
|
+
bash?: Bash
|
|
1233
|
+
fetch?: Fetch
|
|
1234
|
+
patch?: Patch
|
|
1235
|
+
task_context?: { eid: string }
|
|
1236
|
+
graph_query?: GraphQuery
|
|
1237
|
+
apply?: ApplyComp
|
|
1238
|
+
result?: Result
|
|
1239
|
+
exit?: Exit
|
|
1240
|
+
response?: ResponseComp
|
|
1241
|
+
headers?: Headers
|
|
1242
|
+
stderr?: Stderr
|
|
1243
|
+
timeout?: Timeout
|
|
1244
|
+
checkpoint?: Checkpoint
|
|
1245
|
+
cancel?: Cancel
|
|
1246
|
+
reasoning?: { eid: string }
|
|
1247
|
+
recalled?: Recalled
|
|
1248
|
+
opaque?: Opaque
|
|
1249
|
+
runner?: Runner
|
|
1250
|
+
lease?: Lease
|
|
1251
|
+
usage?: Usage
|
|
1252
|
+
claim?: Claim
|
|
1253
|
+
resume?: Resume
|
|
1254
|
+
stop_request?: StopRequest
|
|
1255
|
+
knock?: Knock
|
|
1256
|
+
wake?: Wake
|
|
1257
|
+
dream?: Dream
|
|
1258
|
+
mail?: Mail
|
|
1259
|
+
deliver?: Deliver
|
|
1260
|
+
hook?: Hook
|
|
1261
|
+
email?: Email
|
|
1262
|
+
conflict?: Conflict
|
|
1263
|
+
redaction?: Redaction
|
|
1264
|
+
comment?: Comment
|
|
1265
|
+
commit?: Commit
|
|
1266
|
+
signal?: Signal
|
|
1267
|
+
meta?: { eid: string }
|
|
1268
|
+
review?: Review
|
|
1269
|
+
alias?: Alias
|
|
1270
|
+
key?: Key
|
|
1271
|
+
memory?: Memory
|
|
1272
|
+
feedback?: Feedback
|
|
1273
|
+
persona?: Persona
|
|
1274
|
+
model?: Model
|
|
1275
|
+
tool?: Tool
|
|
1276
|
+
recall?: Recall
|
|
1277
|
+
created?: Created
|
|
1278
|
+
updated?: Updated
|
|
1279
|
+
notified?: Stamp
|
|
1280
|
+
opened?: Stamp
|
|
1281
|
+
archived?: Stamp
|
|
1282
|
+
quarantined?: Stamp
|
|
1283
|
+
decided?: Decided
|
|
1284
|
+
proposed?: Stamp
|
|
1285
|
+
delivered?: Delivered
|
|
1286
|
+
failed?: Failure
|
|
1287
|
+
exception?: Exception
|
|
1288
|
+
bug?: Bug
|
|
1289
|
+
finding?: Finding
|
|
1290
|
+
blocked?: Blocked
|
|
1291
|
+
anchor?: Anchor
|
|
1292
|
+
refs: Ref[]
|
|
1293
|
+
kids: Ent[]
|
|
1294
|
+
}
|
|
1295
|
+
|
|
1296
|
+
// The open face: EntCore plus an index signature that admits a plugin's own
|
|
1297
|
+
// components. `e.doc` stays precise; `e.invoice` (a plugin comp) typechecks as
|
|
1298
|
+
// `unknown` — enough for has('invoice') to be a valid matcher; a plugin's own
|
|
1299
|
+
// renderer narrows it. This is what widening has() to `string[]` relies on.
|
|
1300
|
+
export type Ent = EntCore & { [comp: string]: unknown }
|
|
1301
|
+
|
|
1302
|
+
// A pin row joined to its card: where the card sits and what it shows.
|
|
1303
|
+
export type Pinned = Pin & { target: string; view: string }
|
|
1304
|
+
|
|
1305
|
+
// The sync unit — one component patch landing on (or leaving) an entity. A
|
|
1306
|
+
// batch is a flat array; a comp is a PATCH: omitted columns are untouched
|
|
1307
|
+
// (a single prop change sends a single prop), `prop: null` clears that
|
|
1308
|
+
// column, comp: null deletes the component, and {name: 'entity', comp: null}
|
|
1309
|
+
// deletes the entity, its components, and every edge touching it. Deleting a
|
|
1310
|
+
// bunch is just a long batch. Client-minted UUID eids are welcome — the
|
|
1311
|
+
// spine (and its num) appears on first touch.
|
|
1312
|
+
//
|
|
1313
|
+
// An EDGE is an entity of its own, named by the sentence it says
|
|
1314
|
+
// (edge.ts edgeEid): `edge{from, to}` beside the nature tag that is its
|
|
1315
|
+
// verb, both written to link and both taken away to unlink. Both endpoints
|
|
1316
|
+
// must exist. `edge.ord` is the listing order (types.ts Dep) — a patch on
|
|
1317
|
+
// the same entity, never a second edge; omitting it leaves the stored one
|
|
1318
|
+
// untouched.
|
|
1319
|
+
// `was` is a PRECONDITION — the graph's --ff-only. It names the value the
|
|
1320
|
+
// caller read, column by column (SHA-256 of it, or null for "I read no
|
|
1321
|
+
// value"), and apply() refuses the whole batch if any guarded column has
|
|
1322
|
+
// moved since. Per column, so a title edit never refuses an unrelated body
|
|
1323
|
+
// write; a column absent from `was` is simply unguarded, which is every
|
|
1324
|
+
// caller's behavior today. It rides BESIDE comp, never inside it: comp
|
|
1325
|
+
// admits only real columns, so `doc.was` would be refused as alien.
|
|
1326
|
+
//
|
|
1327
|
+
// Riding beside comp is also why every hop from a client to apply() must
|
|
1328
|
+
// SPREAD a change rather than rebuild it. Rewrite one as `{eid, name, comp}`
|
|
1329
|
+
// and nothing breaks loudly — the guard just stops guarding, and the write
|
|
1330
|
+
// lands unguarded while the caller believes it was protected. That is worse
|
|
1331
|
+
// than never having had it.
|
|
1332
|
+
export type Change = {
|
|
1333
|
+
eid: string
|
|
1334
|
+
name: string
|
|
1335
|
+
comp: Record<string, unknown> | null
|
|
1336
|
+
$num?: boolean
|
|
1337
|
+
was?: Record<string, string | null>
|
|
1338
|
+
}
|
|
1339
|
+
|
|
1340
|
+
// A negotiated committed batch. The cursor makes the frame a complete
|
|
1341
|
+
// IndexedDB checkpoint: a sole writer can land changes + cursor atomically.
|
|
1342
|
+
export type Live = { live: Change[]; cursor: number }
|
|
1343
|
+
|
|
1344
|
+
// The whole graph in one gulp — a batch that fills an empty cache, plus the
|
|
1345
|
+
// edges (edges aren't components; they ride alongside).
|
|
1346
|
+
// `cursor` = the journal rowid this snapshot is current as of (a returning
|
|
1347
|
+
// client's next delta `since`); `epoch`/`vocabHash` = the server-boot and
|
|
1348
|
+
// vocabulary stamps a delta is validated against. OPTIONAL so the
|
|
1349
|
+
// additions stay additive: snapshot() fills every field, but the many
|
|
1350
|
+
// consumers that only read `changes`/`deps` (and build a bare {changes, deps}
|
|
1351
|
+
// to feed notices/edgesOf/digests) stay valid Snapshots untouched.
|
|
1352
|
+
export type Snapshot = {
|
|
1353
|
+
changes: Change[]
|
|
1354
|
+
deps: Dep[]
|
|
1355
|
+
cursor?: number
|
|
1356
|
+
epoch?: string
|
|
1357
|
+
vocabHash?: string
|
|
1358
|
+
capabilities?: string[]
|
|
1359
|
+
}
|
|
1360
|
+
|
|
1361
|
+
// A page learns its host's vocabulary here, at the bottom of the module, so
|
|
1362
|
+
// every module that imports this one evaluates with the tables full.
|
|
1363
|
+
if (globalThis.document && !('Deno' in globalThis)) {
|
|
1364
|
+
// This independent authenticated read need not wait for vocabulary parsing.
|
|
1365
|
+
writeOwner.begin(
|
|
1366
|
+
new URL(hosting().owner, `${location.origin}${hosting().api}`).href,
|
|
1367
|
+
)
|
|
1368
|
+
let wire = await (await fetch(apiPath('/vocab'))).json()
|
|
1369
|
+
learn(wire.docs, wire.keywords)
|
|
1370
|
+
}
|