@lapxo/head 0.1.3 → 0.1.4
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/README.md +24 -0
- package/TARGET.bound +164 -44
- package/dist/src/access/obtain.d.ts +7 -1
- package/dist/src/access/obtain.js +4 -4
- package/dist/src/core/answer.d.ts +2 -0
- package/dist/src/core/read.js +1 -1
- package/dist/src/flows/call.d.ts +1 -3
- package/dist/src/flows/call.js +3 -6
- package/dist/src/flows/read.js +6 -3
- package/dist/src/index.js +14 -9
- package/dist/src/onboard/first.d.ts +5 -3
- package/dist/src/onboard/first.js +25 -8
- package/dist/src/onboard/owed.d.ts +10 -0
- package/dist/src/onboard/owed.js +28 -0
- package/dist/src/onboard/site.d.ts +12 -0
- package/dist/src/onboard/site.js +22 -0
- package/dist/src/ports/surface.d.ts +5 -1
- package/dist/src/ports/surface.js +7 -5
- package/dist/src/sources/connect.d.ts +8 -0
- package/dist/src/sources/connect.js +16 -47
- package/dist/src/sources/refused.d.ts +7 -0
- package/dist/src/sources/refused.js +16 -0
- package/dist/src/tools/ask.d.ts +1 -0
- package/dist/src/tools/ask.js +1 -0
- package/dist/src/tools/card.d.ts +1 -1
- package/dist/src/tools/card.js +6 -5
- package/dist/src/tools/do.d.ts +1 -0
- package/dist/src/tools/do.js +1 -0
- package/dist/src/tools/look.d.ts +5 -4
- package/dist/src/tools/look.js +14 -13
- package/dist/src/verbs/ask.d.ts +11 -0
- package/dist/src/verbs/ask.js +35 -0
- package/dist/src/verbs/card.d.ts +11 -0
- package/dist/src/verbs/card.js +16 -0
- package/dist/src/verbs/do.d.ts +8 -0
- package/dist/src/verbs/do.js +28 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { asked as answer } from "../verbs/ask.js";
|
package/dist/src/tools/card.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Answer } from '../core/answer.ts';
|
|
2
|
-
/** What is open for a key: the cells view the place's standing declares, as bound folded it, narrowed to the key; a refused fold is said, never read as no view. */
|
|
2
|
+
/** What is open for a key: the cells view the place's standing declares, as bound folded it at the resolution asked, narrowed to the key; a refused fold is said, never read as no view. The standing is the one the card was read off, folded once a call. */
|
|
3
3
|
export declare const answer: Answer;
|
package/dist/src/tools/card.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { inPlace, printedOr, standingOr } from "../core/answer.js";
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { members, valueOf } from "../core/lock.js";
|
|
3
|
+
import { sayIn } from "../core/surface.js";
|
|
4
|
+
/** What is open for a key: the cells view the place's standing declares, as bound folded it at the resolution asked, narrowed to the key; a refused fold is said, never read as no view. The standing is the one the card was read off, folded once a call. */
|
|
4
5
|
export const answer = (asked, context) => inPlace(asked, context, async (place) => {
|
|
5
6
|
const word = (scope) => valueOf(context.lock, `bound/${scope}`);
|
|
6
|
-
const held = await standingOr(context, place
|
|
7
|
+
const held = await standingOr(context, place);
|
|
7
8
|
if ('said' in held)
|
|
8
9
|
return held.said;
|
|
9
10
|
const view = held.lines.find((f) => f.scope?.startsWith('view/') && !f.shape && members(f.value ?? '').includes(word('cells')));
|
|
10
11
|
if (view === undefined)
|
|
11
|
-
return [
|
|
12
|
-
return printedOr(context, await context.bound(place, [word('read'), word('view'), view.scope.split('/')[1]
|
|
12
|
+
return [sayIn(context.lock)('no-cells', { place })];
|
|
13
|
+
return printedOr(context, await context.bound(place, [word('read'), word('view'), `${view.scope.split('/')[1]}${asked['at'] ? `${word('at')}${asked['at']}` : ''}`, ...(asked['key'] ? [word('key'), asked['key']] : [])]));
|
|
13
14
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { done as answer } from '../verbs/do.ts';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { done as answer } from "../verbs/do.js";
|
package/dist/src/tools/look.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { Answer } from '../core/answer.ts';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
3
|
+
* A view of a place, folded by bound at the resolution asked; or the region of a source, or of one operation in it, as
|
|
4
|
+
* typed lines at the resolution asked: at 0 where it is reached and each offer's class, past it their forms and access,
|
|
5
|
+
* flows in the order of trust, never what only a transport reads. An operation asked no why is read once, if of the class
|
|
6
|
+
* head reads; asked why, its region is followed by why its newest answer stands. Each answer reads red past answer/seconds
|
|
7
|
+
* from the call's start, all head did for it included, with the question it answered as its coordinate.
|
|
7
8
|
*/
|
|
8
9
|
export declare const answer: Answer;
|
package/dist/src/tools/look.js
CHANGED
|
@@ -7,35 +7,36 @@ import { readSource } from "../flows/read.js";
|
|
|
7
7
|
import { standingFor } from "../flows/world.js";
|
|
8
8
|
import { trustOf } from "../core/trust.js";
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
10
|
+
* A view of a place, folded by bound at the resolution asked; or the region of a source, or of one operation in it, as
|
|
11
|
+
* typed lines at the resolution asked: at 0 where it is reached and each offer's class, past it their forms and access,
|
|
12
|
+
* flows in the order of trust, never what only a transport reads. An operation asked no why is read once, if of the class
|
|
13
|
+
* head reads; asked why, its region is followed by why its newest answer stands. Each answer reads red past answer/seconds
|
|
14
|
+
* from the call's start, all head did for it included, with the question it answered as its coordinate.
|
|
14
15
|
*/
|
|
15
|
-
export const answer = (asked, context) =>
|
|
16
|
+
export const answer = (asked, context) => inPlace(asked, context, async (place) => {
|
|
16
17
|
const word = (scope) => valueOf(context.lock, scope);
|
|
17
18
|
const source = asked['source'];
|
|
18
19
|
if (source) {
|
|
19
|
-
|
|
20
|
+
const [operation, why] = [asked['operation'], asked['why'] === 'true'];
|
|
21
|
+
if (operation && !why)
|
|
20
22
|
return readSource(asked, context);
|
|
21
23
|
const held = await standingFor(context, place);
|
|
22
24
|
if ('unsettled' in held)
|
|
23
25
|
return [sayIn(context.lock)('unsettled', { source, why: held.unsettled })];
|
|
24
|
-
const [v, first, shallow] = [vocabOf(context.lock),
|
|
25
|
-
const
|
|
26
|
+
const [v, first, shallow] = [vocabOf(context.lock), asked['at'] === '0', word('look/first').split('|')];
|
|
27
|
+
const region = `${v.offers}/${source}/${operation ?? ''}`;
|
|
26
28
|
const shown = held.lines.filter((l) => {
|
|
27
29
|
const scope = l.scope ?? '';
|
|
28
30
|
if (scope === `${v.region}/${source}`)
|
|
29
31
|
return true;
|
|
30
32
|
if (scope.startsWith(`${v.keys}/${source}/`))
|
|
31
33
|
return !first;
|
|
32
|
-
|
|
33
|
-
if (!ofOffer || scope.endsWith(`/${v.carry}`))
|
|
34
|
+
if (!(operation ? scope === region || scope.startsWith(`${region}/`) : scope.startsWith(region)) || scope.endsWith(`/${v.carry}`))
|
|
34
35
|
return false;
|
|
35
36
|
return !first || (!scope.endsWith(`/${v.form}`) && shallow.includes(l.measure ?? ''));
|
|
36
37
|
});
|
|
37
|
-
return shown.length ? [...shown.map((l) => canonical(l)).sort(), ...(first ? [] : trustOf(context.lock, held.lines, source))] : [sayIn(context.lock)('unread', { source })];
|
|
38
|
+
return shown.length ? [...shown.map((l) => canonical(l)).sort(), ...(first ? [] : trustOf(context.lock, held.lines, source)), ...(operation ? await readSource(asked, context) : [])] : [sayIn(context.lock)('unread', { source })];
|
|
38
39
|
}
|
|
39
|
-
const view = `${asked['view']
|
|
40
|
+
const view = `${asked['view'] ?? ''}${asked['at'] ? `${word('bound/at')}${asked['at']}` : ''}`;
|
|
40
41
|
return printedOr(context, await context.bound(place, [word('bound/read'), word('bound/view'), view]));
|
|
41
|
-
}).then((lines) => [...lines, ...redIn(context.lock)('answer/seconds', `answer/${asked['source'] ? `${asked['source']}/${asked['operation'] ?? ''}` : asked['view']
|
|
42
|
+
}).then((lines) => [...lines, ...redIn(context.lock)('answer/seconds', `answer/${asked['source'] ? `${asked['source']}/${asked['operation'] ?? ''}` : asked['view'] ?? ''}`, context.begun, context.machine())]);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Answer } from '../core/answer.ts';
|
|
2
|
+
/**
|
|
3
|
+
* What a person asks, answered by the question it is. A view, or the region of a source or of one operation in it (what
|
|
4
|
+
* it offers, one read of it, why that answer stands, what was kept of it), is answered by look; drafted lines by plan;
|
|
5
|
+
* what is open by card; anything else by places. Each form is read with no resolution unless the lock declares one for a
|
|
6
|
+
* person; asked why, at the one it declares to explain, and where it declares none, the same answer, said so. Nothing
|
|
7
|
+
* here writes one. An answer about one place ends with its card, taken off the fold the answer reads, valid from it.
|
|
8
|
+
* With no place at all, nothing is founded: it says so, and that connecting an API founds the person's place, the question
|
|
9
|
+
* carried along. A place still owing a source's bytes is answered only once they arrive.
|
|
10
|
+
*/
|
|
11
|
+
export declare const asked: Answer;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { join } from 'node:path';
|
|
2
|
+
import { LOCK } from '@lapxo/topos/wire';
|
|
3
|
+
import { answerOf, placeOf } from "../core/answer.js";
|
|
4
|
+
import { valueOf } from "../core/lock.js";
|
|
5
|
+
import { sayIn } from "../core/surface.js";
|
|
6
|
+
import { paidIn } from "../onboard/owed.js";
|
|
7
|
+
import { pendingIn } from "../sources/refused.js";
|
|
8
|
+
import { cardAt } from "./card.js";
|
|
9
|
+
/**
|
|
10
|
+
* What a person asks, answered by the question it is. A view, or the region of a source or of one operation in it (what
|
|
11
|
+
* it offers, one read of it, why that answer stands, what was kept of it), is answered by look; drafted lines by plan;
|
|
12
|
+
* what is open by card; anything else by places. Each form is read with no resolution unless the lock declares one for a
|
|
13
|
+
* person; asked why, at the one it declares to explain, and where it declares none, the same answer, said so. Nothing
|
|
14
|
+
* here writes one. An answer about one place ends with its card, taken off the fold the answer reads, valid from it.
|
|
15
|
+
* With no place at all, nothing is founded: it says so, and that connecting an API founds the person's place, the question
|
|
16
|
+
* carried along. A place still owing a source's bytes is answered only once they arrive.
|
|
17
|
+
*/
|
|
18
|
+
export const asked = async (asked, context) => {
|
|
19
|
+
const why = asked['why'] === 'true', at = (form) => valueOf(context.lock, `resolution/${form}/${why ? 'why' : 'person'}`) || undefined;
|
|
20
|
+
const read = async (form, tool, more = {}) => [...(why && at(form) === undefined ? [sayIn(context.lock)('why-undeclared', { form })] : []),
|
|
21
|
+
...await (await answerOf('tools', tool))({ ...asked, ...more, at: at(form) }, context)];
|
|
22
|
+
const place = await placeOf(asked, context), founded = place !== undefined && context.files.has(place, LOCK), carded = asked['card'] === 'true';
|
|
23
|
+
if (place === undefined && !carded && !context.files.has(context.home(), LOCK))
|
|
24
|
+
return [sayIn(context.lock)('unborn', { dir: join(context.personal(), valueOf(context.lock, 'first-run/folder')), source: asked['source'], operation: asked['operation'], args: asked['args'] })];
|
|
25
|
+
const held = founded || carded ? await cardAt(context, place) : undefined;
|
|
26
|
+
if (carded && held !== undefined && 'said' in held)
|
|
27
|
+
return held.said;
|
|
28
|
+
const owed = asked['source'] && founded ? await paidIn(asked, context, place) : undefined;
|
|
29
|
+
if (owed !== undefined && !owed.answer)
|
|
30
|
+
return owed.said;
|
|
31
|
+
const answer = asked['lines'] ? await read('plan', 'plan') : asked['view'] ? await read('view', 'look') : asked['source'] ? await read('offers', 'look')
|
|
32
|
+
: !carded ? await read('places', 'places') : founded ? [...await read('card', 'card', { place }), ...await pendingIn(context, place)] : [];
|
|
33
|
+
const after = held === undefined || 'said' in held || place === undefined || !context.moved(place) ? held : await cardAt(context, place);
|
|
34
|
+
return [...(owed?.said ?? []), ...answer, ...(after === undefined || 'said' in after ? [] : [sayIn(context.lock)('card', { place: place ?? '', card: after.card, from: 'ask' })])];
|
|
35
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Context } from '../core/answer.ts';
|
|
2
|
+
/**
|
|
3
|
+
* The card an act is made on: the place's standing as bound folds it, with the reads it kept set aside, and the keys this
|
|
4
|
+
* device acts with. Anything landed, a grant withdrawn or a key admitted or changed moves it; a read never does. A folder
|
|
5
|
+
* that holds no place yet has the card of nothing.
|
|
6
|
+
*/
|
|
7
|
+
export declare const cardAt: (context: Context, place: string | undefined) => Promise<{
|
|
8
|
+
readonly card: string;
|
|
9
|
+
} | {
|
|
10
|
+
readonly said: readonly string[];
|
|
11
|
+
}>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { LOCK } from '@lapxo/topos/wire';
|
|
3
|
+
import { baseOf, standingOr } from "../core/answer.js";
|
|
4
|
+
import { valueOf } from "../core/lock.js";
|
|
5
|
+
/**
|
|
6
|
+
* The card an act is made on: the place's standing as bound folds it, with the reads it kept set aside, and the keys this
|
|
7
|
+
* device acts with. Anything landed, a grant withdrawn or a key admitted or changed moves it; a read never does. A folder
|
|
8
|
+
* that holds no place yet has the card of nothing.
|
|
9
|
+
*/
|
|
10
|
+
export const cardAt = async (context, place) => {
|
|
11
|
+
const held = place === undefined || !context.files.has(place, LOCK) ? { lines: [] } : await standingOr(context, place);
|
|
12
|
+
if ('said' in held)
|
|
13
|
+
return held;
|
|
14
|
+
const read = `${valueOf(context.lock, 'receipt/at')}:`, keys = ['head', 'person'].map((role) => context.device(role) ?? '');
|
|
15
|
+
return { card: createHash('sha256').update([baseOf(held.lines.filter((l) => !l.at?.startsWith(read))), ...keys].join('\n')).digest('hex').slice(0, 16) };
|
|
16
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Answer } from '../core/answer.ts';
|
|
2
|
+
/**
|
|
3
|
+
* What a person does, carried out by the action it names and only on the card it was asked on: an act on a place that
|
|
4
|
+
* moved since is refused before anything is done. An action the place does not allow is said not to be in the card, by
|
|
5
|
+
* bound's own refusals, and by head's words for its own checks only until bound folds the card. The answer ends with the
|
|
6
|
+
* card valid from this act: the same one where nothing but a read's receipts landed, folded again where more did.
|
|
7
|
+
*/
|
|
8
|
+
export declare const done: Answer;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { answerOf, placeOf } from "../core/answer.js";
|
|
2
|
+
import { members, valueOf } from "../core/lock.js";
|
|
3
|
+
import { sayIn } from "../core/surface.js";
|
|
4
|
+
import { cardAt } from "./card.js";
|
|
5
|
+
/**
|
|
6
|
+
* What a person does, carried out by the action it names and only on the card it was asked on: an act on a place that
|
|
7
|
+
* moved since is refused before anything is done. An action the place does not allow is said not to be in the card, by
|
|
8
|
+
* bound's own refusals, and by head's words for its own checks only until bound folds the card. The answer ends with the
|
|
9
|
+
* card valid from this act: the same one where nothing but a read's receipts landed, folded again where more did.
|
|
10
|
+
*/
|
|
11
|
+
export const done = async (asked, context) => {
|
|
12
|
+
const [say, word] = [sayIn(context.lock), (scope) => valueOf(context.lock, scope)];
|
|
13
|
+
const action = asked['action'] ?? '';
|
|
14
|
+
if (!members(word('do/actions')).includes(action))
|
|
15
|
+
return [say('unknown-action', { action, actions: word('do/actions') })];
|
|
16
|
+
const place = asked['place'] || asked['dir'] || await placeOf(asked, context), held = await cardAt(context, place);
|
|
17
|
+
if ('said' in held)
|
|
18
|
+
return held.said;
|
|
19
|
+
if (held.card !== asked['card'])
|
|
20
|
+
return [say('card-stale', { action, place: place ?? '', card: asked['card'] ?? '' })];
|
|
21
|
+
const answer = await (await answerOf('tools', action))(asked, context);
|
|
22
|
+
const [bound, own] = [members(word('do/not-in-card/bound')), members(word('do/not-in-card/head'))];
|
|
23
|
+
const refusal = (line) => ((r) => (r && [r[1], ...r[2].split(' ')].some((w) => bound.includes(w)) ? r[0] : undefined))(/REFUSE·([\w-]+)([^"]*)/.exec(line));
|
|
24
|
+
const check = (line) => ((c) => ((code) => (code && own.includes(code) ? `head/${code}` : undefined))(c?.[1] ?? c?.[2]))(/^said\/head\/([\w-]+) |head="head\/([\w-]+)"/.exec(line));
|
|
25
|
+
const why = answer.map((line) => refusal(line) ?? check(line)).find(Boolean);
|
|
26
|
+
const after = place === undefined || !context.moved(place) ? held : await cardAt(context, place);
|
|
27
|
+
return [...(why === undefined ? [] : [say('not-in-card', { action, place: place ?? '', why })]), ...answer, ...(place === undefined || 'said' in after ? [] : [say('card', { place, card: after.card, from: `do ${action}` })])];
|
|
28
|
+
};
|
package/package.json
CHANGED