tapline-host 1.4.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/accounts.d.ts +72 -0
- package/dist/accounts.js +208 -0
- package/dist/accounts.js.map +1 -0
- package/dist/actionlog.d.ts +20 -0
- package/dist/actionlog.js.map +1 -1
- package/dist/animations.d.ts +39 -0
- package/dist/animations.js +124 -0
- package/dist/animations.js.map +1 -0
- package/dist/api.d.ts +43 -0
- package/dist/api.js +154 -0
- package/dist/api.js.map +1 -0
- package/dist/audit.d.ts +3 -0
- package/dist/audit.js +1 -1
- package/dist/audit.js.map +1 -1
- package/dist/bin.d.ts +2 -0
- package/dist/bin.js +19 -0
- package/dist/bin.js.map +1 -0
- package/dist/brief.d.ts +41 -0
- package/dist/brief.js +78 -0
- package/dist/brief.js.map +1 -0
- package/dist/cli.d.ts +41 -1
- package/dist/cli.js +100 -53
- package/dist/cli.js.map +1 -1
- package/dist/conditions.d.ts +36 -0
- package/dist/conditions.js +67 -0
- package/dist/conditions.js.map +1 -0
- package/dist/confirm.d.ts +21 -2
- package/dist/confirm.js +39 -6
- package/dist/confirm.js.map +1 -1
- package/dist/dispatch.d.ts +27 -0
- package/dist/dispatch.js +114 -0
- package/dist/dispatch.js.map +1 -0
- package/dist/doctor.d.ts +5 -0
- package/dist/doctor.js +20 -0
- package/dist/doctor.js.map +1 -1
- package/dist/drive.d.ts +184 -0
- package/dist/drive.js +908 -0
- package/dist/drive.js.map +1 -0
- package/dist/elicit.d.ts +90 -0
- package/dist/elicit.js +179 -0
- package/dist/elicit.js.map +1 -0
- package/dist/format.d.ts +16 -0
- package/dist/format.js +81 -24
- package/dist/format.js.map +1 -1
- package/dist/images.d.ts +35 -0
- package/dist/images.js +76 -6
- package/dist/images.js.map +1 -1
- package/dist/inspect.d.ts +1 -0
- package/dist/journey.d.ts +276 -0
- package/dist/journey.js +368 -0
- package/dist/journey.js.map +1 -0
- package/dist/journeyexport.d.ts +58 -0
- package/dist/journeyexport.js +318 -0
- package/dist/journeyexport.js.map +1 -0
- package/dist/journeygif.d.ts +62 -0
- package/dist/journeygif.js +192 -0
- package/dist/journeygif.js.map +1 -0
- package/dist/journeyreport.d.ts +202 -0
- package/dist/journeyreport.js +666 -0
- package/dist/journeyreport.js.map +1 -0
- package/dist/mapcmd.d.ts +200 -0
- package/dist/mapcmd.js +412 -0
- package/dist/mapcmd.js.map +1 -0
- package/dist/mapfile.d.ts +155 -0
- package/dist/mapfile.js +575 -0
- package/dist/mapfile.js.map +1 -0
- package/dist/mcp.d.ts +14 -11
- package/dist/mcp.js +50 -318
- package/dist/mcp.js.map +1 -1
- package/dist/media.d.ts +88 -0
- package/dist/media.js +263 -0
- package/dist/media.js.map +1 -0
- package/dist/nochange.d.ts +77 -0
- package/dist/nochange.js +77 -0
- package/dist/nochange.js.map +1 -0
- package/dist/places.d.ts +239 -0
- package/dist/places.js +823 -0
- package/dist/places.js.map +1 -0
- package/dist/policy.d.ts +18 -0
- package/dist/policy.js +52 -0
- package/dist/policy.js.map +1 -1
- package/dist/protocol.d.ts +27 -1
- package/dist/protocol.js +25 -0
- package/dist/protocol.js.map +1 -1
- package/dist/reflexes.d.ts +59 -0
- package/dist/reflexes.js +133 -0
- package/dist/reflexes.js.map +1 -0
- package/dist/report.d.ts +32 -2
- package/dist/report.js +154 -9
- package/dist/report.js.map +1 -1
- package/dist/routes.d.ts +115 -0
- package/dist/routes.js +287 -0
- package/dist/routes.js.map +1 -0
- package/dist/run.d.ts +28 -1
- package/dist/run.js +32 -3
- package/dist/run.js.map +1 -1
- package/dist/runtime.d.ts +60 -0
- package/dist/runtime.js +255 -0
- package/dist/runtime.js.map +1 -0
- package/dist/script.d.ts +114 -10
- package/dist/script.js +30 -2
- package/dist/script.js.map +1 -1
- package/dist/server.d.ts +48 -2
- package/dist/server.js +88 -13
- package/dist/server.js.map +1 -1
- package/dist/thincall.d.ts +13 -0
- package/dist/thincall.js +335 -0
- package/dist/thincall.js.map +1 -0
- package/dist/tool-text-data.d.ts +10 -5
- package/dist/tool-text-data.js +11 -6
- package/dist/tool-text-data.js.map +1 -1
- package/dist/tool-text.d.ts +1 -1
- package/dist/tools.d.ts +585 -5
- package/dist/tools.js +2926 -185
- package/dist/tools.js.map +1 -1
- package/dist/uxcheck.d.ts +103 -0
- package/dist/uxcheck.js +128 -0
- package/dist/uxcheck.js.map +1 -0
- package/package.json +3 -2
- package/skills/tapline/SKILL.md +57 -11
- package/skills/tapline/references/personas.md +45 -0
- package/skills/tapline/references/setup.md +6 -1
package/dist/mapcmd.js
ADDED
|
@@ -0,0 +1,412 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { readRouteSync } from "./mapfile.js";
|
|
3
|
+
import { placeNameFromRoute, samePlace } from "./places.js";
|
|
4
|
+
import { asWords, decodeComplete, decodePath, linkReadable, linkWords, matchWord } from "./policy.js";
|
|
5
|
+
import { looksLikeValue } from "./protocol.js";
|
|
6
|
+
import { routeEdges } from "./routes.js";
|
|
7
|
+
import { describeRunStep } from "./run.js";
|
|
8
|
+
// The `map` tool (AGENT-TOOLS 1.13 §18.8): a read, and the way to edit what a map holds. It never touches the app.
|
|
9
|
+
// Every edit goes through AppMap, which writes with saveMap; nothing here writes the file.
|
|
10
|
+
const NAME = /^[a-z0-9_]+$/;
|
|
11
|
+
const LIST_MAX = 60;
|
|
12
|
+
// -- the reflex a call may add (§18.7)
|
|
13
|
+
const whenSchema = z
|
|
14
|
+
.object({ text: z.string().min(1).optional(), label: z.string().min(1).optional(), id: z.string().min(1).optional() })
|
|
15
|
+
.strict()
|
|
16
|
+
.refine((when) => [when.text, when.label, when.id].filter((value) => value !== undefined).length === 1, { message: "when needs exactly one of text, label or id" });
|
|
17
|
+
/**
|
|
18
|
+
* What a reflex may do: one step that acts, written as `run` takes it and nothing more (no force, text, secure, index
|
|
19
|
+
* or account). Typing, waiting and the tools that read are not reflexes. An element is named by id, label or text,
|
|
20
|
+
* never by a ref or a point.
|
|
21
|
+
*/
|
|
22
|
+
const named = z.string().min(1).max(200);
|
|
23
|
+
const elementTarget = z.union([z.object({ id: named }).strict(), z.object({ label: named }).strict(), z.object({ text: named }).strict()]);
|
|
24
|
+
const elementStep = (tool) => z.object({ tool: z.literal(tool), target: elementTarget }).strict();
|
|
25
|
+
export const reflexDoSchema = z.discriminatedUnion("tool", [
|
|
26
|
+
elementStep("tap"),
|
|
27
|
+
elementStep("long_press"),
|
|
28
|
+
elementStep("toggle"),
|
|
29
|
+
z.object({ tool: z.literal("back") }).strict(),
|
|
30
|
+
z
|
|
31
|
+
.object({ tool: z.literal("swipe"), x0: z.number(), y0: z.number(), x1: z.number(), y1: z.number(), seconds: z.number().min(0.05).max(5).optional() })
|
|
32
|
+
.strict(),
|
|
33
|
+
z
|
|
34
|
+
.object({
|
|
35
|
+
tool: z.literal("scroll"),
|
|
36
|
+
direction: z.enum(["up", "down", "left", "right"]).optional(),
|
|
37
|
+
amount: z.number().min(0.1).max(1).optional(),
|
|
38
|
+
to: z.enum(["start", "end"]).optional(),
|
|
39
|
+
target: elementTarget.optional(),
|
|
40
|
+
})
|
|
41
|
+
.strict(),
|
|
42
|
+
// The cut-down link, as a road keeps it (clarification 14): no query, fragment, credentials or value.
|
|
43
|
+
z
|
|
44
|
+
.object({ tool: z.literal("open_url"), url: named })
|
|
45
|
+
.strict()
|
|
46
|
+
.superRefine((step, ctx) => {
|
|
47
|
+
const problem = linkProblem(step.url);
|
|
48
|
+
if (problem !== null)
|
|
49
|
+
ctx.addIssue({ code: "custom", path: ["url"], message: problem });
|
|
50
|
+
}),
|
|
51
|
+
]);
|
|
52
|
+
export const reflexSchema = z
|
|
53
|
+
.object({
|
|
54
|
+
name: z.string().regex(NAME, "a reflex's name is [a-z0-9_]"),
|
|
55
|
+
when: whenSchema,
|
|
56
|
+
do: reflexDoSchema,
|
|
57
|
+
max: z.number().int().min(1).max(3).optional(),
|
|
58
|
+
at: z.string().regex(NAME).optional(),
|
|
59
|
+
})
|
|
60
|
+
.strict();
|
|
61
|
+
const ONE_OF = ["to", "name", "link", "reflex", "forget_reflex", "forget"];
|
|
62
|
+
const bad = (message) => ({ text: `Error bad_params: ${message}`, error: true });
|
|
63
|
+
const notFoundPlace = (name) => ({ text: `Error not_found: no place named "${name}"; map lists the places.`, error: true });
|
|
64
|
+
const said = (text) => ({ text, error: false });
|
|
65
|
+
/** One argument at a time; `place` only with `link`. A message, or null when the call is well formed. */
|
|
66
|
+
export function mapArgsError(args) {
|
|
67
|
+
const given = ONE_OF.filter((key) => args[key] !== undefined);
|
|
68
|
+
if (given.length > 1)
|
|
69
|
+
return `map takes one argument at a time; you gave ${given.join(", ")}.`;
|
|
70
|
+
if (args.place !== undefined && args.link === undefined)
|
|
71
|
+
return "place goes with link.";
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
/** Runs one `map` call. The arguments were checked by `mapArgsError`. */
|
|
75
|
+
export async function runMap(args, ctx) {
|
|
76
|
+
let answer;
|
|
77
|
+
let edited = false;
|
|
78
|
+
if (args.to !== undefined)
|
|
79
|
+
answer = await way(args.to, ctx);
|
|
80
|
+
else if (args.name !== undefined)
|
|
81
|
+
[answer, edited] = await nameHere(args.name, ctx);
|
|
82
|
+
else if (args.link !== undefined)
|
|
83
|
+
[answer, edited] = await addLink(args.link, args.place, ctx);
|
|
84
|
+
else if (args.reflex !== undefined)
|
|
85
|
+
[answer, edited] = addReflex(args.reflex, ctx);
|
|
86
|
+
else if (args.forget_reflex !== undefined)
|
|
87
|
+
[answer, edited] = forgetReflex(args.forget_reflex, ctx);
|
|
88
|
+
else if (args.forget !== undefined)
|
|
89
|
+
[answer, edited] = forgetPlace(args.forget, ctx);
|
|
90
|
+
else
|
|
91
|
+
answer = await listing(ctx);
|
|
92
|
+
if (!edited)
|
|
93
|
+
return answer;
|
|
94
|
+
// An edit is written now, so a person or the other tool sees it; a failed write is kept and tried again.
|
|
95
|
+
await ctx.map.flush();
|
|
96
|
+
const failed = ctx.map.lastError();
|
|
97
|
+
// The merge with the file keeps what has newer evidence, so a removal may not hold: say so instead of "Forgot".
|
|
98
|
+
if (!answer.error && args.forget !== undefined && ctx.map.data().places[args.forget] !== undefined) {
|
|
99
|
+
answer = { text: `Error stale: place ${args.forget} was kept; the map file holds newer evidence for it. Look at it again and forget it once it is quiet.`, error: true };
|
|
100
|
+
}
|
|
101
|
+
if (!answer.error && args.forget_reflex !== undefined && ctx.map.data().reflexes.some((reflex) => reflex.name === args.forget_reflex)) {
|
|
102
|
+
answer = { text: `Error stale: reflex ${args.forget_reflex} was kept; the map file holds a newer one.`, error: true };
|
|
103
|
+
}
|
|
104
|
+
return failed === null ? answer : { ...answer, text: `${answer.text}\nNote: the map file wasn't written (${failed}); the change is kept and written when it can be.` };
|
|
105
|
+
}
|
|
106
|
+
// -- the listing
|
|
107
|
+
const plural = (n, one, many) => `${n} ${n === 1 ? one : many}`;
|
|
108
|
+
/** At most 60 entries, then `…`. */
|
|
109
|
+
function capped(items) {
|
|
110
|
+
return items.length > LIST_MAX ? [...items.slice(0, LIST_MAX), "…"] : items;
|
|
111
|
+
}
|
|
112
|
+
function withLink(name, link) {
|
|
113
|
+
return link !== null && link !== undefined && link !== "" ? `${name} (link ${link})` : name;
|
|
114
|
+
}
|
|
115
|
+
function routeLine(map, name, relative) {
|
|
116
|
+
const file = readRouteSync(map.folder(), relative);
|
|
117
|
+
if (file === null)
|
|
118
|
+
return name;
|
|
119
|
+
// A route file is a person's to edit: only a name-shaped start or end is printed, and cut short.
|
|
120
|
+
const place = (value) => (typeof value === "string" && NAME.test(value) ? value.slice(0, 40) : undefined);
|
|
121
|
+
const start = place(file["start"]);
|
|
122
|
+
const end = place(file["end"]);
|
|
123
|
+
const variables = Array.isArray(file["variables"])
|
|
124
|
+
? file["variables"].filter((v) => typeof v === "string" && /^\w+$/.test(v)).map((v) => v.slice(0, 40))
|
|
125
|
+
: [];
|
|
126
|
+
const way = start !== undefined && end !== undefined ? `${start} → ${end}` : "";
|
|
127
|
+
const parts = [way, variables.join(", ")].filter((part) => part !== "");
|
|
128
|
+
return parts.length === 0 ? name : `${name} (${parts.join("; ")})`;
|
|
129
|
+
}
|
|
130
|
+
/** Places the app lists that the map has no place for yet: with their links, and no roads. */
|
|
131
|
+
function notVisited(map, known) {
|
|
132
|
+
const saved = Object.values(map.data().places);
|
|
133
|
+
const lines = [];
|
|
134
|
+
for (const place of known.places) {
|
|
135
|
+
if (saved.some((own) => samePlace(own.key, { route: place.route })))
|
|
136
|
+
continue;
|
|
137
|
+
const name = placeNameFromRoute(place.route);
|
|
138
|
+
if (name === "")
|
|
139
|
+
continue;
|
|
140
|
+
const params = place.params ?? [];
|
|
141
|
+
const notes = [
|
|
142
|
+
place.link !== null && place.link !== undefined && place.link !== "" ? `link ${place.link}` : "",
|
|
143
|
+
params.length > 0 ? `needs ${params.join(", ")}` : "",
|
|
144
|
+
].filter((note) => note !== "");
|
|
145
|
+
lines.push(notes.length === 0 ? name : `${name} (${notes.join("; ")})`);
|
|
146
|
+
}
|
|
147
|
+
return lines;
|
|
148
|
+
}
|
|
149
|
+
async function listing(ctx) {
|
|
150
|
+
const { map, app } = ctx;
|
|
151
|
+
// Reading where the app is can save the screen it is on as a first place, so it comes before the counts.
|
|
152
|
+
const here = await ctx.here();
|
|
153
|
+
const data = map.data();
|
|
154
|
+
const roads = data.roads.length;
|
|
155
|
+
const proven = data.roads.filter((road) => map.isProven(road)).length;
|
|
156
|
+
const routes = Object.entries(data.routes);
|
|
157
|
+
const reflexes = data.reflexes;
|
|
158
|
+
const places = Object.entries(data.places);
|
|
159
|
+
const head = `Map of ${app.name} (${app.id}), build ${map.currentBuild()}: ${plural(places.length, "place", "places")}, ` +
|
|
160
|
+
`${plural(roads, "road", "roads")}${roads > 0 ? ` (${proven} proven)` : ""}, ${plural(routes.length, "route", "routes")}, ` +
|
|
161
|
+
`${plural(reflexes.length, "reflex", "reflexes")}. Now at: ${here?.name ?? "unknown"}.`;
|
|
162
|
+
const lines = [head];
|
|
163
|
+
if (places.length > 0)
|
|
164
|
+
lines.push(`Places: ${capped(places.map(([name, place]) => withLink(name, place.link))).join(", ")}`);
|
|
165
|
+
const up = notVisited(map, await ctx.known());
|
|
166
|
+
if (up.length > 0)
|
|
167
|
+
lines.push(`Known up front, not visited: ${capped(up).join(", ")}.`);
|
|
168
|
+
if (routes.length > 0)
|
|
169
|
+
lines.push(`Routes: ${capped(routes.map(([name, relative]) => routeLine(map, name, relative))).join(", ")}`);
|
|
170
|
+
if (reflexes.length > 0)
|
|
171
|
+
lines.push(`Reflexes: ${capped(reflexes.map((reflex) => reflex.name)).join(", ")}.`);
|
|
172
|
+
if (ctx.accounts.length > 0)
|
|
173
|
+
lines.push(`Accounts: ${ctx.accounts.join(", ")}.`);
|
|
174
|
+
return said(lines.join("\n"));
|
|
175
|
+
}
|
|
176
|
+
// -- `to`: the way drive would take (§18.4)
|
|
177
|
+
/** Roads this tool replays: its own, and the ones both tools have driven (§18.2). */
|
|
178
|
+
const driveable = (road) => road.by === "tapline" || road.by === "both";
|
|
179
|
+
/**
|
|
180
|
+
* The cheapest chain of roads: a proven road costs 1, an unproven one 2. Equal cost goes to the chain with the road used most
|
|
181
|
+
* recently. The graph is a few screens, and the search is capped so a tangled map can't stall a read.
|
|
182
|
+
*/
|
|
183
|
+
export function cheapestWay(roads, from, to, isProven, routes = []) {
|
|
184
|
+
const recent = (leg) => {
|
|
185
|
+
const at = Date.parse(leg.last);
|
|
186
|
+
return Number.isNaN(at) ? 0 : at;
|
|
187
|
+
};
|
|
188
|
+
// A route is one leg from its start to its end that costs a move for each of its steps (§18.5).
|
|
189
|
+
const legs = [
|
|
190
|
+
...roads.filter(driveable).map((road) => ({ leg: road, from: road.from, to: road.to, cost: isProven(road) ? 1 : 2 })),
|
|
191
|
+
...routes.map((route) => ({ leg: route, from: route.from, to: route.to, cost: route.moves })),
|
|
192
|
+
];
|
|
193
|
+
const better = (a, b) => a.cost < b.cost || (a.cost === b.cost && (a.routeLegs > b.routeLegs || (a.routeLegs === b.routeLegs && a.used > b.used)));
|
|
194
|
+
const labels = new Map([[from, { cost: 0, routeLegs: 0, used: 0, chain: [] }]]);
|
|
195
|
+
const settled = new Set();
|
|
196
|
+
for (;;) {
|
|
197
|
+
let at = null;
|
|
198
|
+
let label;
|
|
199
|
+
for (const [place, candidate] of labels) {
|
|
200
|
+
if (settled.has(place) || (label !== undefined && !better(candidate, label)))
|
|
201
|
+
continue;
|
|
202
|
+
at = place;
|
|
203
|
+
label = candidate;
|
|
204
|
+
}
|
|
205
|
+
if (at === null || label === undefined)
|
|
206
|
+
return null;
|
|
207
|
+
if (at === to)
|
|
208
|
+
return label.chain;
|
|
209
|
+
settled.add(at);
|
|
210
|
+
for (const next of legs) {
|
|
211
|
+
if (next.from !== at || settled.has(next.to))
|
|
212
|
+
continue;
|
|
213
|
+
const reached = {
|
|
214
|
+
cost: label.cost + next.cost,
|
|
215
|
+
routeLegs: label.routeLegs + (isRouteLeg(next.leg) ? 1 : 0),
|
|
216
|
+
used: Math.max(label.used, recent(next.leg)),
|
|
217
|
+
chain: [...label.chain, next.leg],
|
|
218
|
+
};
|
|
219
|
+
const known = labels.get(next.to);
|
|
220
|
+
if (known === undefined || better(reached, known))
|
|
221
|
+
labels.set(next.to, reached);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
/** A leg that is a saved route rather than a road. */
|
|
226
|
+
export const isRouteLeg = (leg) => typeof leg.route === "string" && typeof leg.moves === "number";
|
|
227
|
+
async function way(to, ctx) {
|
|
228
|
+
const { map } = ctx;
|
|
229
|
+
const saved = map.data().places[to];
|
|
230
|
+
const up = saved === undefined ? (await ctx.known()).places.find((place) => placeNameFromRoute(place.route) === to) : undefined;
|
|
231
|
+
if (saved === undefined && up === undefined)
|
|
232
|
+
return notFoundPlace(to);
|
|
233
|
+
const here = await ctx.here();
|
|
234
|
+
if (here?.name === to)
|
|
235
|
+
return said(`Already at ${to}.`);
|
|
236
|
+
// A jump goes to a place's link from wherever the app is (§18.4).
|
|
237
|
+
const link = saved !== undefined ? saved.link : (up?.link ?? null);
|
|
238
|
+
if (link !== null && link !== "")
|
|
239
|
+
return said(describeWay(to, here?.name ?? "?", [{ from: here?.name ?? "?", to, kind: "link", url: link, proven: true }], map.currentBuild(), false));
|
|
240
|
+
if (here === null)
|
|
241
|
+
return { text: "Error not_found: the app's current place isn't known, so no way can be planned; look at the screen first.", error: true };
|
|
242
|
+
const chain = cheapestWay(map.data().roads, here.name, to, (road) => map.isProven(road), routeEdges(map));
|
|
243
|
+
if (chain === null) {
|
|
244
|
+
return { text: `Error not_found: no known way from ${here.name} to ${to}; drive it once (the driver), and it is remembered.`, error: true };
|
|
245
|
+
}
|
|
246
|
+
const legs = chain.map((leg) => isRouteLeg(leg)
|
|
247
|
+
? { from: leg.from, to: leg.to, kind: "route", route: leg.route, proven: true }
|
|
248
|
+
: { from: leg.from, to: leg.to, kind: leg.move.tool === "tap" ? "tap" : "other", proven: map.isProven(leg) });
|
|
249
|
+
return said(describeWay(to, here.name, legs, map.currentBuild(), false));
|
|
250
|
+
}
|
|
251
|
+
// -- `name`
|
|
252
|
+
const NO_HERE = { text: "Error not_found: the app's current place isn't known; look at the screen first.", error: true };
|
|
253
|
+
async function nameHere(name, ctx) {
|
|
254
|
+
const here = await ctx.here();
|
|
255
|
+
if (here === null)
|
|
256
|
+
return [NO_HERE, false];
|
|
257
|
+
if (ctx.map.data().places[here.name] === undefined)
|
|
258
|
+
return [{ text: "Error not_found: the current place isn't in the map yet; look at the screen first.", error: true }, false];
|
|
259
|
+
if (here.name === name)
|
|
260
|
+
return [said(`The current place is already ${name}.`), false];
|
|
261
|
+
if (ctx.map.data().places[name] !== undefined)
|
|
262
|
+
return [bad(`a place named "${name}" already exists; pick another name.`), false];
|
|
263
|
+
// The name is the agent's choice and may be any [a-z0-9_]; the tool never fills one in from screen text.
|
|
264
|
+
if (!ctx.map.renamePlace(here.name, name))
|
|
265
|
+
return [bad(`"${name}" can't name a place; use [a-z0-9_].`), false];
|
|
266
|
+
return [said(`Named the current place ${name} (was ${here.name}).`), true];
|
|
267
|
+
}
|
|
268
|
+
// -- `link`: kept as given, as a pattern, never a real id (§18.3)
|
|
269
|
+
const PARAM_PIECE = /^\[(?:\.\.\.)?[A-Za-z0-9_]+\]$/;
|
|
270
|
+
/** A segment as written and as the router reads it: `%34%38%32` is 482, so both are looked at. */
|
|
271
|
+
const valueIn = (segment) => holdsValue(segment) || decodePath(segment).split("/").some(holdsValue);
|
|
272
|
+
/** A segment that holds a value: a number, a uuid, long hex (§18.1), or a long mixed run that looks like a token. */
|
|
273
|
+
function holdsValue(segment) {
|
|
274
|
+
if (PARAM_PIECE.test(segment))
|
|
275
|
+
return false;
|
|
276
|
+
// A JWT is three dotted parts: each part is looked at on its own.
|
|
277
|
+
return segment.split(".").some((part) => looksLikeValue(part) ||
|
|
278
|
+
(part.length >= 20 && /^[A-Za-z0-9_-]+$/.test(part) && /[A-Za-z]/.test(part) && /\d/.test(part)) ||
|
|
279
|
+
// A long run with no separator is no word of a route.
|
|
280
|
+
(part.length >= 24 && /^[A-Za-z0-9]+$/.test(part)));
|
|
281
|
+
}
|
|
282
|
+
/** A message when the link can't be kept as given; null when it can. It never repeats what was refused. */
|
|
283
|
+
function linkProblem(link) {
|
|
284
|
+
const found = /^([a-z][a-z0-9+.-]*):\/\/(.*)$/i.exec(link.trim());
|
|
285
|
+
if (found === null)
|
|
286
|
+
return "a link is scheme://path, like wayfare://settings.";
|
|
287
|
+
const [, scheme = "", rest = ""] = found;
|
|
288
|
+
const authority = rest.split("/")[0] ?? "";
|
|
289
|
+
// A link that can't be fully decoded is refused: what a router would make of it is unknown. The link isn't repeated.
|
|
290
|
+
if (!decodeComplete(rest).complete)
|
|
291
|
+
return "a link whose percent escapes can't be decoded (invalid or too deeply encoded) isn't kept; write it plainly.";
|
|
292
|
+
const unescaped = decodePath(rest);
|
|
293
|
+
if (/[?#]/.test(unescaped) || (decodePath(authority)).includes("@")) {
|
|
294
|
+
return "a link holds only a scheme and a path: no query, no fragment, no credentials. A value there may be a secret; drop it.";
|
|
295
|
+
}
|
|
296
|
+
const segments = rest.split("/").filter((segment) => segment !== "");
|
|
297
|
+
if (!segments.some(valueIn))
|
|
298
|
+
return null;
|
|
299
|
+
const suggestion = `${scheme}://${segments.map((segment) => (valueIn(segment) ? "[id]" : segment)).join("/")}`;
|
|
300
|
+
return `a segment of the link looks like a value (an id, a uuid or a token), and a link holds a pattern; write it as ${suggestion}.`;
|
|
301
|
+
}
|
|
302
|
+
async function addLink(link, placeName, ctx) {
|
|
303
|
+
const problem = linkProblem(link);
|
|
304
|
+
if (problem !== null)
|
|
305
|
+
return [bad(problem), false];
|
|
306
|
+
let target = placeName;
|
|
307
|
+
if (target === undefined) {
|
|
308
|
+
const here = await ctx.here();
|
|
309
|
+
if (here === null)
|
|
310
|
+
return [NO_HERE, false];
|
|
311
|
+
target = here.name;
|
|
312
|
+
}
|
|
313
|
+
const saved = ctx.map.data().places[target];
|
|
314
|
+
if (saved === undefined)
|
|
315
|
+
return [notFoundPlace(target), false];
|
|
316
|
+
const was = saved.link;
|
|
317
|
+
const given = link.trim();
|
|
318
|
+
ctx.map.setLink(target, given);
|
|
319
|
+
const replaced = was !== null && was !== "" && was !== given ? ` (was ${was})` : "";
|
|
320
|
+
return [said(`Added link ${given} to ${target}${replaced}.`), true];
|
|
321
|
+
}
|
|
322
|
+
// -- reflexes (§18.7); the machinery that fires them is not here
|
|
323
|
+
/** The words a policy could match in a reflex's `do`: its text and label, an id's words, and a link's path words. */
|
|
324
|
+
export function reflexWords(step) {
|
|
325
|
+
if (step.tool === "open_url")
|
|
326
|
+
return { text: linkWords(step.url) };
|
|
327
|
+
if (step.tool !== "tap" && step.tool !== "long_press" && step.tool !== "toggle")
|
|
328
|
+
return {};
|
|
329
|
+
const target = step.target;
|
|
330
|
+
if ("id" in target)
|
|
331
|
+
return { text: asWords(target.id) };
|
|
332
|
+
if ("label" in target)
|
|
333
|
+
return { label: target.label };
|
|
334
|
+
return { text: target.text };
|
|
335
|
+
}
|
|
336
|
+
function addReflex(input, ctx) {
|
|
337
|
+
if (input.at !== undefined && ctx.map.data().places[input.at] === undefined)
|
|
338
|
+
return [notFoundPlace(input.at), false];
|
|
339
|
+
if (input.do.tool === "open_url" && !linkReadable(input.do.url)) {
|
|
340
|
+
return [{ text: `Error not_allowed: blocked: reflex "${input.name}" would open a link whose percent escapes can't be decoded, so the policy can't check it. Nothing was saved.`, error: true }, false];
|
|
341
|
+
}
|
|
342
|
+
const words = reflexWords(input.do);
|
|
343
|
+
const blocked = matchWord(ctx.lists.block, words);
|
|
344
|
+
const flagged = blocked === null ? matchWord(ctx.lists.confirm, words) : null;
|
|
345
|
+
if (blocked !== null || flagged !== null) {
|
|
346
|
+
const what = describeRunStep(input.do);
|
|
347
|
+
const refusal = blocked !== null
|
|
348
|
+
? `which the policy blocks (${JSON.stringify(blocked)}); a reflex may not do it.`
|
|
349
|
+
: `which the policy flags (${JSON.stringify(flagged)}); a reflex may not do what needs a person's OK.`;
|
|
350
|
+
return [{ text: `Error not_allowed: blocked: reflex "${input.name}" would ${what}, ${refusal} Nothing was saved.`, error: true }, false];
|
|
351
|
+
}
|
|
352
|
+
const reflex = {
|
|
353
|
+
name: input.name,
|
|
354
|
+
when: input.when,
|
|
355
|
+
do: input.do,
|
|
356
|
+
...(input.max !== undefined ? { max: input.max } : {}),
|
|
357
|
+
...(input.at !== undefined ? { at: input.at } : {}),
|
|
358
|
+
};
|
|
359
|
+
const result = ctx.map.addReflex(reflex);
|
|
360
|
+
return [said(`${result === "added" ? "Added" : "Replaced"} reflex ${input.name}.`), true];
|
|
361
|
+
}
|
|
362
|
+
function forgetReflex(name, ctx) {
|
|
363
|
+
if (!ctx.map.removeReflex(name))
|
|
364
|
+
return [{ text: `Error not_found: no reflex named "${name}".`, error: true }, false];
|
|
365
|
+
return [said(`Forgot reflex ${name}.`), true];
|
|
366
|
+
}
|
|
367
|
+
// -- `forget`
|
|
368
|
+
function forgetPlace(name, ctx) {
|
|
369
|
+
const { map } = ctx;
|
|
370
|
+
if (map.data().places[name] === undefined)
|
|
371
|
+
return [notFoundPlace(name), false];
|
|
372
|
+
// Counted before it goes: the answer says what went with the place.
|
|
373
|
+
const counts = [
|
|
374
|
+
plural(map.data().roads.filter((road) => road.from === name || road.to === name).length, "road", "roads"),
|
|
375
|
+
plural(map.routesAt(name).length, "route", "routes"),
|
|
376
|
+
plural(map.data().reflexes.filter((reflex) => reflex.at === name).length, "reflex", "reflexes"),
|
|
377
|
+
].filter((count) => !count.startsWith("0 "));
|
|
378
|
+
map.removePlace(name);
|
|
379
|
+
const together = counts.length <= 1 ? counts.join("") : `${counts.slice(0, -1).join(", ")} and ${counts[counts.length - 1]}`;
|
|
380
|
+
return [said(`Forgot place ${name}${together === "" ? "" : `, with ${together}`}.`), true];
|
|
381
|
+
}
|
|
382
|
+
/** `by link`, `by 3 taps`, `by link then 1 tap`, `by route sign_in` (18.4: how it travelled is always said). A person's eyes never see a route's name. */
|
|
383
|
+
export function howText(links, taps, others, routes = [], eyes = false) {
|
|
384
|
+
const asMoves = eyes ? routes.length : 0;
|
|
385
|
+
const rest = taps + others + asMoves;
|
|
386
|
+
const noun = others + asMoves === 0 ? (rest === 1 ? "tap" : "taps") : rest === 1 ? "move" : "moves";
|
|
387
|
+
const link = links === 1 ? "link" : `${links} links`;
|
|
388
|
+
const parts = [...(links > 0 ? [link] : []), ...(!eyes && routes.length > 0 ? [`route ${routes.join(", ")}`] : []), ...(rest > 0 ? [`${rest} ${noun}`] : [])];
|
|
389
|
+
return `by ${parts.length > 0 ? parts.join(" then ") : "0 taps"}`;
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* The dry-run sentence for a way. In a user's eyes it holds no place, link or route name: only how many moves and how many
|
|
393
|
+
* are unproven (18.12).
|
|
394
|
+
*/
|
|
395
|
+
export function describeWay(to, from, legs, build, eyes) {
|
|
396
|
+
const links = legs.filter((leg) => leg.kind === "link").length;
|
|
397
|
+
const taps = legs.filter((leg) => leg.kind === "tap").length;
|
|
398
|
+
const others = legs.filter((leg) => leg.kind === "other").length;
|
|
399
|
+
const routes = legs.flatMap((leg) => (leg.kind === "route" && leg.route !== undefined ? [leg.route] : []));
|
|
400
|
+
const how = howText(links, taps, others, routes, eyes);
|
|
401
|
+
const unproven = legs.filter((leg) => !leg.proven);
|
|
402
|
+
if (eyes)
|
|
403
|
+
return `Would drive to ${to} ${how} (${unproven.length === 0 ? "all proven" : `${unproven.length} unproven`}).`;
|
|
404
|
+
const only = legs[0];
|
|
405
|
+
if (legs.length === 1 && only?.kind === "link")
|
|
406
|
+
return `Would drive to ${to} by link (${only.url ?? ""}).`;
|
|
407
|
+
const names = [from, ...legs.map((leg) => leg.to)].join(" > ");
|
|
408
|
+
const via = routes.map((route) => `via route ${route}`);
|
|
409
|
+
const state = [unproven.length === 0 ? "all proven" : `unproven for build ${build}: ${unproven.map((leg) => `${leg.from} > ${leg.to}`).join(", ")}`, ...via].join("; ");
|
|
410
|
+
return `Would drive to ${to} ${how}: ${names} (${state}).`;
|
|
411
|
+
}
|
|
412
|
+
//# sourceMappingURL=mapcmd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapcmd.js","sourceRoot":"","sources":["../src/mapcmd.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,aAAa,EAAgC,MAAM,cAAc,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAA6C,MAAM,aAAa,CAAC;AACvG,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACtG,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAkB,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,U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GAAG,GAAG,CAAC,IAAI,MAAM,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,GAAG,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACxK,OAAO,kBAAkB,EAAE,IAAI,GAAG,KAAK,KAAK,KAAK,KAAK,IAAI,CAAC;AAC7D,CAAC"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
export declare const MAP_FORMAT = "agent-tools-map";
|
|
2
|
+
export declare const MAP_VERSION = 1;
|
|
3
|
+
export type PlaceKey = {
|
|
4
|
+
route: string[];
|
|
5
|
+
tab?: string;
|
|
6
|
+
layer?: string;
|
|
7
|
+
} | {
|
|
8
|
+
signature: string;
|
|
9
|
+
parts: Record<string, unknown>;
|
|
10
|
+
};
|
|
11
|
+
export type MoveTool = "tap" | "long_press" | "toggle" | "back" | "open_url" | "swipe";
|
|
12
|
+
export type RoadBy = "tapline" | "tapwright" | "both";
|
|
13
|
+
export interface MapPlace {
|
|
14
|
+
key: PlaceKey;
|
|
15
|
+
link: string | null;
|
|
16
|
+
titles?: Record<string, string>;
|
|
17
|
+
last: string;
|
|
18
|
+
[unknown: string]: unknown;
|
|
19
|
+
}
|
|
20
|
+
export type Move = {
|
|
21
|
+
tool: MoveTool | (string & {});
|
|
22
|
+
target?: {
|
|
23
|
+
id?: string;
|
|
24
|
+
label?: string;
|
|
25
|
+
text?: string;
|
|
26
|
+
row?: true;
|
|
27
|
+
x?: number;
|
|
28
|
+
y?: number;
|
|
29
|
+
};
|
|
30
|
+
url?: string;
|
|
31
|
+
/** A swipe is a step as `run` takes it: both points and, when given, its length (1.13.1 item 14). */
|
|
32
|
+
x0?: number;
|
|
33
|
+
y0?: number;
|
|
34
|
+
x1?: number;
|
|
35
|
+
y1?: number;
|
|
36
|
+
seconds?: number;
|
|
37
|
+
};
|
|
38
|
+
export interface MapRoad {
|
|
39
|
+
from: string;
|
|
40
|
+
to: string;
|
|
41
|
+
move: Move;
|
|
42
|
+
names?: {
|
|
43
|
+
id?: string;
|
|
44
|
+
label?: string;
|
|
45
|
+
text?: string;
|
|
46
|
+
};
|
|
47
|
+
by: RoadBy | (string & {});
|
|
48
|
+
seen: number;
|
|
49
|
+
failed: number;
|
|
50
|
+
ms: number;
|
|
51
|
+
last: string;
|
|
52
|
+
build: string;
|
|
53
|
+
[unknown: string]: unknown;
|
|
54
|
+
}
|
|
55
|
+
export interface MapReflex {
|
|
56
|
+
name: string;
|
|
57
|
+
when: {
|
|
58
|
+
text?: string;
|
|
59
|
+
label?: string;
|
|
60
|
+
id?: string;
|
|
61
|
+
};
|
|
62
|
+
do: Record<string, unknown>;
|
|
63
|
+
max?: number;
|
|
64
|
+
at?: string;
|
|
65
|
+
[unknown: string]: unknown;
|
|
66
|
+
}
|
|
67
|
+
export interface MapFile {
|
|
68
|
+
format: typeof MAP_FORMAT;
|
|
69
|
+
version: 1;
|
|
70
|
+
app: string;
|
|
71
|
+
titleKey?: string;
|
|
72
|
+
places: Record<string, MapPlace>;
|
|
73
|
+
roads: MapRoad[];
|
|
74
|
+
routes: Record<string, string>;
|
|
75
|
+
reflexes: MapReflex[];
|
|
76
|
+
[unknown: string]: unknown;
|
|
77
|
+
}
|
|
78
|
+
/** The file system and the clock, injectable so tests can interleave steps and fake time. */
|
|
79
|
+
export interface MapIo {
|
|
80
|
+
/** The file's text, or null when it doesn't exist. */
|
|
81
|
+
readFile(path: string): Promise<string | null>;
|
|
82
|
+
/** Writes the file and syncs it to disk before it returns. */
|
|
83
|
+
writeFile(path: string, data: string): Promise<void>;
|
|
84
|
+
rename(from: string, to: string): Promise<void>;
|
|
85
|
+
/** Creates the file with `data` only if it is absent; false when it already exists. */
|
|
86
|
+
createExclusive(path: string, data: string): Promise<boolean>;
|
|
87
|
+
remove(path: string): Promise<void>;
|
|
88
|
+
/** The file's modified time in ms, or null when it doesn't exist. */
|
|
89
|
+
statMtimeMs(path: string): Promise<number | null>;
|
|
90
|
+
/** The names in a folder; empty when it doesn't exist. */
|
|
91
|
+
listDir(path: string): Promise<string[]>;
|
|
92
|
+
mkdirp(path: string): Promise<void>;
|
|
93
|
+
now(): number;
|
|
94
|
+
sleep(ms: number): Promise<void>;
|
|
95
|
+
}
|
|
96
|
+
export declare function nodeMapIo(): MapIo;
|
|
97
|
+
/** The folder is named by the app's own id, reduced so it can never leave the maps folder. */
|
|
98
|
+
export declare function mapDir(app: string, options: {
|
|
99
|
+
mapsDir?: string;
|
|
100
|
+
home?: string;
|
|
101
|
+
}): string;
|
|
102
|
+
/** `unreadable`: the file is left alone and driving goes on with an empty map. */
|
|
103
|
+
export declare function loadMap(dir: string, app: string): {
|
|
104
|
+
map: MapFile;
|
|
105
|
+
status: "ok" | "new" | "unreadable";
|
|
106
|
+
};
|
|
107
|
+
/** A stable text for a value: object keys sorted, so the same key always compares equal. */
|
|
108
|
+
export declare function stable(value: unknown): string;
|
|
109
|
+
/** What names one road: where it starts, the move, where it ends. */
|
|
110
|
+
export declare function roadId(from: string, move: Move, to: string): string;
|
|
111
|
+
/**
|
|
112
|
+
* Merges mine into the disk copy. `options.renamed` (old to new) are renames I made on purpose:
|
|
113
|
+
* they are applied to the disk copy first so the merge doesn't bring the old name back.
|
|
114
|
+
* `renames` in the answer lists every name of mine that ended up under another (a clash with a
|
|
115
|
+
* different place of the same name gets the next free `_n`).
|
|
116
|
+
*/
|
|
117
|
+
export declare function mergeMapsWithRenames(disk: MapFile, mine: MapFile, options?: {
|
|
118
|
+
renamed?: Record<string, string>;
|
|
119
|
+
}): {
|
|
120
|
+
map: MapFile;
|
|
121
|
+
renames: Record<string, string>;
|
|
122
|
+
};
|
|
123
|
+
export declare function mergeMaps(disk: MapFile, mine: MapFile, options?: {
|
|
124
|
+
renamed?: Record<string, string>;
|
|
125
|
+
}): MapFile;
|
|
126
|
+
/** What a caller took out on purpose. Each removal waits for the other tool's newer evidence. */
|
|
127
|
+
export interface MapRemovals {
|
|
128
|
+
places?: {
|
|
129
|
+
name: string;
|
|
130
|
+
before: string;
|
|
131
|
+
}[];
|
|
132
|
+
roads?: {
|
|
133
|
+
from: string;
|
|
134
|
+
move: Move;
|
|
135
|
+
to: string;
|
|
136
|
+
before: string;
|
|
137
|
+
}[];
|
|
138
|
+
reflexes?: string[];
|
|
139
|
+
/** Places renamed on purpose (old to new). */
|
|
140
|
+
renamed?: Record<string, string>;
|
|
141
|
+
}
|
|
142
|
+
export declare function insideDir(dir: string, relative: string): string | null;
|
|
143
|
+
/** A route file read at once, for the `map` listing and a forget's counts. Null when it is missing, outside the folder or not an object. */
|
|
144
|
+
export declare function readRouteSync(dir: string, relative: string): Record<string, unknown> | null;
|
|
145
|
+
/** Writes a route's file inside the map folder (atomic, so a reader never sees half a file). Throws for a path outside it. */
|
|
146
|
+
export declare function saveRouteFile(dir: string, relative: string, data: string, io?: MapIo): Promise<void>;
|
|
147
|
+
/**
|
|
148
|
+
* Merges `map` into what is on disk and writes it; answers the merged file, which the caller
|
|
149
|
+
* adopts. `readOnly` (replay) throws before touching anything.
|
|
150
|
+
*/
|
|
151
|
+
export declare function saveMap(dir: string, map: MapFile, options?: {
|
|
152
|
+
readOnly?: boolean;
|
|
153
|
+
io?: MapIo;
|
|
154
|
+
removed?: MapRemovals;
|
|
155
|
+
}): Promise<MapFile>;
|