@yaks/lens 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 +228 -2
- package/_dist/compile.d.ts +30 -0
- package/_dist/compile.d.ts.map +1 -0
- package/_dist/described.d.ts +12 -0
- package/_dist/described.d.ts.map +1 -0
- package/_dist/document.d.ts +59 -0
- package/_dist/document.d.ts.map +1 -0
- package/_dist/graph.d.ts +3 -0
- package/_dist/graph.d.ts.map +1 -0
- package/_dist/mod.d.ts +7 -0
- package/_dist/mod.d.ts.map +1 -0
- package/_dist/plugin.d.ts +9 -0
- package/_dist/plugin.d.ts.map +1 -0
- package/_dist/steps.d.ts +10 -0
- package/_dist/steps.d.ts.map +1 -0
- package/_dist/view.d.ts +40 -0
- package/_dist/view.d.ts.map +1 -0
- package/_dist/vocab.d.ts +4 -0
- package/_dist/vocab.d.ts.map +1 -0
- package/compile.js +318 -0
- package/compile.js.map +1 -0
- package/compile.ts +290 -0
- package/deno.json +1 -0
- package/described.js +80 -0
- package/described.js.map +1 -0
- package/described.ts +85 -0
- package/document.js +268 -0
- package/document.js.map +1 -0
- package/document.ts +335 -0
- package/graph.js +5 -0
- package/graph.js.map +1 -0
- package/graph.ts +4 -0
- package/mod.js +7 -0
- package/mod.js.map +1 -0
- package/mod.ts +6 -0
- package/package.json +28 -4
- package/plugin.js +454 -0
- package/plugin.js.map +1 -0
- package/plugin.ts +597 -0
- package/schema.js +61 -0
- package/schema.js.map +1 -0
- package/schema.ts +53 -0
- package/steps.js +35 -0
- package/steps.js.map +1 -0
- package/steps.ts +47 -0
- package/tools.fixture.json +190 -0
- package/view.js +430 -0
- package/view.js.map +1 -0
- package/view.ts +448 -0
- package/vocab.js +11 -0
- package/vocab.js.map +1 -0
- package/vocab.json +34 -0
- package/vocab.ts +8 -0
package/schema.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { VocabDoc } from 'jsr:@yaks/vocab@0.2.36'
|
|
2
|
+
|
|
3
|
+
type Rename = { from: [string, string]; to: [string, string] }
|
|
4
|
+
|
|
5
|
+
/** Translate declarations by the same inverse as read views. Components keep
|
|
6
|
+
* their membership; a cross-component target remains an old-readable word. */
|
|
7
|
+
export let schema = (docs: VocabDoc[], pairs: Rename[]): VocabDoc[] => {
|
|
8
|
+
let out = docs
|
|
9
|
+
for (let { from: [fc, fp], to: [tc, tp] } of pairs.toReversed()) {
|
|
10
|
+
let source = out.findIndex((d) => d.$defs?.[fc]?.properties)
|
|
11
|
+
let target = out.findIndex((d) => d.$defs?.[tc]?.properties?.[tp])
|
|
12
|
+
if (source < 0 || target < 0) continue
|
|
13
|
+
let sourceDoc = out[source], sourceComp = sourceDoc.$defs![fc]
|
|
14
|
+
let targetComp = out[target].$defs![tc]
|
|
15
|
+
let props = { ...sourceComp.properties, [fp]: targetComp.properties![tp] }
|
|
16
|
+
if (fc == tc) delete props[tp]
|
|
17
|
+
let required = sourceComp.required?.map((p) => fc == tc && p == tp ? fp : p)
|
|
18
|
+
if (targetComp.required?.includes(tp)) {
|
|
19
|
+
required = [...new Set([...(required ?? []), fp])]
|
|
20
|
+
}
|
|
21
|
+
let next = {
|
|
22
|
+
...sourceDoc,
|
|
23
|
+
$defs: {
|
|
24
|
+
...sourceDoc.$defs,
|
|
25
|
+
[fc]: {
|
|
26
|
+
...sourceComp,
|
|
27
|
+
properties: props,
|
|
28
|
+
...(required ? { required } : {}),
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
}
|
|
32
|
+
out = out.map((d, i) => {
|
|
33
|
+
if (i == source) return next
|
|
34
|
+
if (fc != tc || !d.$defs?.[tc]?.properties?.[tp]) return d
|
|
35
|
+
let comp = d.$defs[tc], properties = { ...comp.properties }
|
|
36
|
+
delete properties[tp]
|
|
37
|
+
return {
|
|
38
|
+
...d,
|
|
39
|
+
$defs: {
|
|
40
|
+
...d.$defs,
|
|
41
|
+
[tc]: {
|
|
42
|
+
...comp,
|
|
43
|
+
properties,
|
|
44
|
+
...(comp.required
|
|
45
|
+
? { required: comp.required.filter((p) => p != tp) }
|
|
46
|
+
: {}),
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
}
|
|
50
|
+
})
|
|
51
|
+
}
|
|
52
|
+
return out
|
|
53
|
+
}
|
package/steps.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** Rails-style UTC timestamps, written as YYYYMMDDHHMMSS. */ export let timestamp = (value)=>{
|
|
2
|
+
if (typeof value != 'number' || !Number.isSafeInteger(value)) return false;
|
|
3
|
+
let text = String(value);
|
|
4
|
+
if (!/^\d{14}$/.test(text)) return false;
|
|
5
|
+
let iso = `${text.slice(0, 4)}-${text.slice(4, 6)}-${text.slice(6, 8)}T${text.slice(8, 10)}:${text.slice(10, 12)}:${text.slice(12, 14)}.000Z`;
|
|
6
|
+
let date = new Date(iso);
|
|
7
|
+
return !Number.isNaN(date.valueOf()) && date.toISOString() == iso;
|
|
8
|
+
};
|
|
9
|
+
/** Validate and order a package's history, retaining the pilot's landed
|
|
10
|
+
* zero-based steps and count versions. New histories use timestamps. */ export let history = (declarations, speaks)=>{
|
|
11
|
+
let fail = (why)=>{
|
|
12
|
+
throw new Error(`Lens: ${why}`);
|
|
13
|
+
};
|
|
14
|
+
let steps = declarations.toSorted((a, b)=>a.step - b.step);
|
|
15
|
+
let legacy = 0, previous = -1;
|
|
16
|
+
for (let { step } of steps){
|
|
17
|
+
if (step == previous) fail(`duplicate step ${step}`);
|
|
18
|
+
if (!timestamp(step)) {
|
|
19
|
+
if (step !== legacy || previous >= 10000000000000) {
|
|
20
|
+
fail(`invalid step ${step}; expected YYYYMMDDHHMMSS`);
|
|
21
|
+
}
|
|
22
|
+
legacy++;
|
|
23
|
+
}
|
|
24
|
+
previous = step;
|
|
25
|
+
}
|
|
26
|
+
let version = previous >= 10000000000000 ? previous : legacy;
|
|
27
|
+
let start = speaks === undefined ? version : speaks;
|
|
28
|
+
if (!Number.isSafeInteger(start) || start < 0 || !(start <= legacy || timestamp(start) && start <= version)) fail(`unknown version ${start}`);
|
|
29
|
+
return {
|
|
30
|
+
steps,
|
|
31
|
+
version,
|
|
32
|
+
remaining: steps.filter(({ step })=>timestamp(start) ? step > start : timestamp(step) || step >= start)
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=steps.js.map
|
package/steps.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"steps.js","sources":["./steps.ts"],"names":[],"mappings":"AAAA,2DAA2D,GAC3D,OAAO,IAAI,YAAY,CAAC;EACtB,IAAI,OAAO,SAAS,YAAY,CAAC,OAAO,aAAa,CAAC,QAAQ,OAAO;EACrE,IAAI,OAAO,OAAO;EAClB,IAAI,CAAC,WAAW,IAAI,CAAC,OAAO,OAAO;EACnC,IAAI,MAAM,GAAG,KAAK,KAAK,CAAC,GAAG,GAAG,CAAC,EAAE,KAAK,KAAK,CAAC,GAAG,GAAG,CAAC,EAAE,KAAK,KAAK,CAAC,GAAG,GAAG,CAAC,EACrE,KAAK,KAAK,CAAC,GAAG,IACf,CAAC,EAAE,KAAK,KAAK,CAAC,IAAI,IAAI,CAAC,EAAE,KAAK,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC;EACnD,IAAI,OAAO,IAAI,KAAK;EACpB,OAAO,CAAC,OAAO,KAAK,CAAC,KAAK,OAAO,OAAO,KAAK,WAAW,MAAM;AAChE,EAAC;AAED;sEACsE,GACtE,OAAO,IAAI,UAAU,CACnB,cACA;EAEA,IAAI,OAAO,CAAC;IACV,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,KAAK;EAChC;EACA,IAAI,QAAQ,aAAa,QAAQ,CAAC,CAAC,GAAG,IAAM,EAAE,IAAI,GAAG,EAAE,IAAI;EAC3D,IAAI,SAAS,GAAG,WAAW,CAAC;EAC5B,KAAK,IAAI,EAAE,IAAI,EAAE,IAAI,MAAO;IAC1B,IAAI,QAAQ,UAAU,KAAK,CAAC,eAAe,EAAE,MAAM;IACnD,IAAI,CAAC,UAAU,OAAO;MACpB,IAAI,SAAS,UAAU,YAAY,gBAAgB;QACjD,KAAK,CAAC,aAAa,EAAE,KAAK,yBAAyB,CAAC;MACtD;MACA;IACF;IACA,WAAW;EACb;EACA,IAAI,UAAU,YAAY,iBAAiB,WAAW;EACtD,IAAI,QAAQ,WAAW,YAAY,UAAU;EAC7C,IACE,CAAC,OAAO,aAAa,CAAC,UAAU,QAAQ,KACxC,CAAC,CAAC,SAAS,UAAU,UAAU,UAAU,SAAS,OAAO,GACzD,KAAK,CAAC,gBAAgB,EAAE,OAAO;EACjC,OAAO;IACL;IACA;IACA,WAAW,MAAM,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,GAC/B,UAAU,SAAS,OAAO,QAAQ,UAAU,SAAS,QAAQ;EAEjE;AACF,EAAC"}
|
package/steps.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/** Rails-style UTC timestamps, written as YYYYMMDDHHMMSS. */
|
|
2
|
+
export let timestamp = (value: unknown): value is number => {
|
|
3
|
+
if (typeof value != 'number' || !Number.isSafeInteger(value)) return false
|
|
4
|
+
let text = String(value)
|
|
5
|
+
if (!/^\d{14}$/.test(text)) return false
|
|
6
|
+
let iso = `${text.slice(0, 4)}-${text.slice(4, 6)}-${text.slice(6, 8)}T${
|
|
7
|
+
text.slice(8, 10)
|
|
8
|
+
}:${text.slice(10, 12)}:${text.slice(12, 14)}.000Z`
|
|
9
|
+
let date = new Date(iso)
|
|
10
|
+
return !Number.isNaN(date.valueOf()) && date.toISOString() == iso
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** Validate and order a package's history, retaining the pilot's landed
|
|
14
|
+
* zero-based steps and count versions. New histories use timestamps. */
|
|
15
|
+
export let history = <T extends { step: number }>(
|
|
16
|
+
declarations: readonly T[],
|
|
17
|
+
speaks?: number,
|
|
18
|
+
): { steps: T[]; version: number; remaining: T[] } => {
|
|
19
|
+
let fail = (why: string): never => {
|
|
20
|
+
throw new Error(`Lens: ${why}`)
|
|
21
|
+
}
|
|
22
|
+
let steps = declarations.toSorted((a, b) => a.step - b.step)
|
|
23
|
+
let legacy = 0, previous = -1
|
|
24
|
+
for (let { step } of steps) {
|
|
25
|
+
if (step == previous) fail(`duplicate step ${step}`)
|
|
26
|
+
if (!timestamp(step)) {
|
|
27
|
+
if (step !== legacy || previous >= 10000000000000) {
|
|
28
|
+
fail(`invalid step ${step}; expected YYYYMMDDHHMMSS`)
|
|
29
|
+
}
|
|
30
|
+
legacy++
|
|
31
|
+
}
|
|
32
|
+
previous = step
|
|
33
|
+
}
|
|
34
|
+
let version = previous >= 10000000000000 ? previous : legacy
|
|
35
|
+
let start = speaks === undefined ? version : speaks
|
|
36
|
+
if (
|
|
37
|
+
!Number.isSafeInteger(start) || start < 0 ||
|
|
38
|
+
!(start <= legacy || timestamp(start) && start <= version)
|
|
39
|
+
) fail(`unknown version ${start}`)
|
|
40
|
+
return {
|
|
41
|
+
steps,
|
|
42
|
+
version,
|
|
43
|
+
remaining: steps.filter(({ step }) =>
|
|
44
|
+
timestamp(start) ? step > start : timestamp(step) || step >= start
|
|
45
|
+
),
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
{
|
|
2
|
+
"package": "lens-pilot",
|
|
3
|
+
"$defs": {
|
|
4
|
+
"graph_query": {
|
|
5
|
+
"tool": true,
|
|
6
|
+
"noun": "graph",
|
|
7
|
+
"verb": "query",
|
|
8
|
+
"title": "Query entities",
|
|
9
|
+
"description": "Find stored records (entities) by filtering on their named groups of fields (components) and their properties. Returns bundles: JSON objects with entity: {eid} and the record\u2019s component objects. A bundle carries the components the query names, by a filter on one ('.recipe', '.doc.title~=cake') or by asking for one without filtering on it ('?doc'), and no other: name each component you will read, or add * for all of them. A query that names no component ('.entity.eid=T-12', a bare search word) answers whole. graph_show returns one entity whole. A query string selects the records: '.task.status=open&.filed.priority<3'. It is made of filters written as .component.property=value, joined with &, with lists (a,b), ranges (1..9), != for not equal, ~= for text containing a value, < or > comparisons, '.component' for present and '!component' for absent. A property is always named with its component. Directives go in the same string: .order=, .limit=, and .refs=<id> for everything that references an entity. filters, if passed, each narrow the whole of q. Documentation: https://yaks.app/docs/querying.",
|
|
10
|
+
"input": {
|
|
11
|
+
"q": {
|
|
12
|
+
"type": "string",
|
|
13
|
+
"description": "query filters, e.g. .task.status=open&.filed.priority<3; graph_schema lists the valid components and properties"
|
|
14
|
+
},
|
|
15
|
+
"filters": {
|
|
16
|
+
"type": "array",
|
|
17
|
+
"items": {
|
|
18
|
+
"type": "string"
|
|
19
|
+
},
|
|
20
|
+
"description": "extra filters, each narrowing the whole of q"
|
|
21
|
+
},
|
|
22
|
+
"limit": {
|
|
23
|
+
"type": "number",
|
|
24
|
+
"description": "return at most this many entities"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"required": [
|
|
28
|
+
"q"
|
|
29
|
+
],
|
|
30
|
+
"options": {
|
|
31
|
+
"positional": [
|
|
32
|
+
"q"
|
|
33
|
+
],
|
|
34
|
+
"short": {
|
|
35
|
+
"n": "limit"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"readOnly": true
|
|
39
|
+
},
|
|
40
|
+
"graph_show": {
|
|
41
|
+
"tool": true,
|
|
42
|
+
"noun": "graph",
|
|
43
|
+
"verb": "show",
|
|
44
|
+
"title": "Show entities",
|
|
45
|
+
"description": "Read one or more stored records (entities) by their unique string id (eid), each returned whole as its own bundle: a JSON object with entity: {eid} and every named group of fields (component) it has. Only the entities asked for come back; what references one is a query of its own, graph_query with .refs=<id>, and a relationship is an edge entity found the same way. This is lookup by identity, not search: pass eids, or the names entities are addressed by where this store keeps names (an eid wins over a name spelled the same way).",
|
|
46
|
+
"input": {
|
|
47
|
+
"ids": {
|
|
48
|
+
"type": "array",
|
|
49
|
+
"items": {
|
|
50
|
+
"type": "string"
|
|
51
|
+
},
|
|
52
|
+
"ref": "entity",
|
|
53
|
+
"description": "the eids or names of the entities to read"
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
"required": [
|
|
57
|
+
"ids"
|
|
58
|
+
],
|
|
59
|
+
"options": {
|
|
60
|
+
"rest": "ids"
|
|
61
|
+
},
|
|
62
|
+
"readOnly": true
|
|
63
|
+
},
|
|
64
|
+
"builder_build": {
|
|
65
|
+
"tool": true,
|
|
66
|
+
"noun": "builder",
|
|
67
|
+
"verb": "build",
|
|
68
|
+
"title": "Build now",
|
|
69
|
+
"description": "Build bindings with new or changed inputs, independent of floor and staged. Current outputs are untouched unless --rebuild redoes every selected binding, or --outdated redoes bindings under an older definition. Both combine with --only and --limit. Alternate provider, model, template or native input creates a shadow variant.",
|
|
70
|
+
"input": {
|
|
71
|
+
"builder": {
|
|
72
|
+
"type": "string",
|
|
73
|
+
"ref": "builder",
|
|
74
|
+
"description": "id of the builder to build"
|
|
75
|
+
},
|
|
76
|
+
"provider": {
|
|
77
|
+
"type": "string",
|
|
78
|
+
"ref": "provider",
|
|
79
|
+
"description": "the provider to ask instead of the configured one"
|
|
80
|
+
},
|
|
81
|
+
"model": {
|
|
82
|
+
"type": "string",
|
|
83
|
+
"ref": "model",
|
|
84
|
+
"description": "the model to build with instead of the configured one"
|
|
85
|
+
},
|
|
86
|
+
"template": {
|
|
87
|
+
"type": "string",
|
|
88
|
+
"description": "alternate content.body template for a shadow variant"
|
|
89
|
+
},
|
|
90
|
+
"input": {
|
|
91
|
+
"type": "object",
|
|
92
|
+
"description": "native request fields merged into sending.input for a shadow variant; --input @input.json reads an object"
|
|
93
|
+
},
|
|
94
|
+
"only": {
|
|
95
|
+
"type": "array",
|
|
96
|
+
"items": {
|
|
97
|
+
"type": "string",
|
|
98
|
+
"ref": "entity"
|
|
99
|
+
},
|
|
100
|
+
"description": "build only the bindings whose outer entities these name, and leave the other builds as they are"
|
|
101
|
+
},
|
|
102
|
+
"limit": {
|
|
103
|
+
"type": "integer",
|
|
104
|
+
"minimum": 1,
|
|
105
|
+
"description": "build only the first n bindings, and leave the other builds as they are"
|
|
106
|
+
},
|
|
107
|
+
"rebuild": {
|
|
108
|
+
"type": "boolean",
|
|
109
|
+
"description": "redo every selected binding, even with unchanged inputs and definition"
|
|
110
|
+
},
|
|
111
|
+
"outdated": {
|
|
112
|
+
"type": "boolean",
|
|
113
|
+
"description": "redo selected bindings only when their definition is older; otherwise build only missing or changed inputs"
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
"required": [
|
|
117
|
+
"builder"
|
|
118
|
+
],
|
|
119
|
+
"options": {
|
|
120
|
+
"positional": [
|
|
121
|
+
"builder"
|
|
122
|
+
],
|
|
123
|
+
"rest": "only",
|
|
124
|
+
"short": {
|
|
125
|
+
"m": "model",
|
|
126
|
+
"p": "provider"
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
"idempotent": false
|
|
130
|
+
},
|
|
131
|
+
"session_spawn": {
|
|
132
|
+
"tool": true,
|
|
133
|
+
"noun": "session",
|
|
134
|
+
"verb": "spawn",
|
|
135
|
+
"title": "Start an agent on a task",
|
|
136
|
+
"description": "Start an agent on a task. Creates a session record for the run, an initial log entry naming the provider (agent runner), model and reasoning effort, and a claim reserving the task for that session; committing that starts the agent, so a task a run still going holds refuses the whole request. A task a parked run is waiting on, or whose run a wake has asked for or started, starts nothing: that run gets the instruction, on its own provider, and the answer says so. With wait, returns how the run ended (its brief or final output, and its exit code when recorded) instead of the session id. Returns text in content.body. A wait timeout reports that the run is still running and does not kill it.",
|
|
137
|
+
"input": {
|
|
138
|
+
"task": {
|
|
139
|
+
"type": "string",
|
|
140
|
+
"ref": "task",
|
|
141
|
+
"description": "the task to hand to the agent, which the session claims; pass its id or registered name"
|
|
142
|
+
},
|
|
143
|
+
"provider": {
|
|
144
|
+
"type": "string",
|
|
145
|
+
"ref": "provider",
|
|
146
|
+
"description": "id or registered name of the provider (agent runner); it must use command-line transport"
|
|
147
|
+
},
|
|
148
|
+
"model": {
|
|
149
|
+
"type": "string",
|
|
150
|
+
"ref": "model",
|
|
151
|
+
"description": "id or registered name of the model the run uses; optional"
|
|
152
|
+
},
|
|
153
|
+
"persona": {
|
|
154
|
+
"type": "string",
|
|
155
|
+
"ref": "persona",
|
|
156
|
+
"description": "the persona to carry, by id or name (default: the checkout's persona)"
|
|
157
|
+
},
|
|
158
|
+
"effort": {
|
|
159
|
+
"type": "string",
|
|
160
|
+
"description": "the reasoning effort, where the model accepts such a setting"
|
|
161
|
+
},
|
|
162
|
+
"instruction": {
|
|
163
|
+
"type": "string",
|
|
164
|
+
"description": "what to tell the agent (default: the task\u2019s id and title; it holds the claim and reads the rest itself)"
|
|
165
|
+
},
|
|
166
|
+
"wait": {
|
|
167
|
+
"type": "boolean",
|
|
168
|
+
"description": "block until the run is over and return how it ended"
|
|
169
|
+
},
|
|
170
|
+
"timeout": {
|
|
171
|
+
"type": "string",
|
|
172
|
+
"description": "how long to wait: 45m, 2h, or bare seconds (default 30m)"
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
"required": [
|
|
176
|
+
"task",
|
|
177
|
+
"provider"
|
|
178
|
+
],
|
|
179
|
+
"options": {
|
|
180
|
+
"positional": [
|
|
181
|
+
"task"
|
|
182
|
+
],
|
|
183
|
+
"short": {
|
|
184
|
+
"p": "provider",
|
|
185
|
+
"m": "model"
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|