@softov/ahpc 0.1.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.
Files changed (111) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +296 -0
  3. package/dist/src/ahp/channels.d.ts +146 -0
  4. package/dist/src/ahp/channels.js +423 -0
  5. package/dist/src/ahp/connection.d.ts +656 -0
  6. package/dist/src/ahp/connection.js +1 -0
  7. package/dist/src/ahp/fake.d.ts +69 -0
  8. package/dist/src/ahp/fake.js +1996 -0
  9. package/dist/src/ahp/live.d.ts +160 -0
  10. package/dist/src/ahp/live.js +2641 -0
  11. package/dist/src/ahp/operate.d.ts +36 -0
  12. package/dist/src/ahp/operate.js +56 -0
  13. package/dist/src/ahp/publish.d.ts +39 -0
  14. package/dist/src/ahp/publish.js +370 -0
  15. package/dist/src/ahp/status.d.ts +23 -0
  16. package/dist/src/ahp/status.js +23 -0
  17. package/dist/src/ahp/types.d.ts +745 -0
  18. package/dist/src/ahp/types.js +27 -0
  19. package/dist/src/app.d.ts +54 -0
  20. package/dist/src/app.js +369 -0
  21. package/dist/src/blocks.d.ts +88 -0
  22. package/dist/src/blocks.js +102 -0
  23. package/dist/src/cli/main.d.ts +13 -0
  24. package/dist/src/cli/main.js +1537 -0
  25. package/dist/src/cli/render.d.ts +43 -0
  26. package/dist/src/cli/render.js +91 -0
  27. package/dist/src/config.d.ts +63 -0
  28. package/dist/src/config.js +45 -0
  29. package/dist/src/connect.d.ts +53 -0
  30. package/dist/src/connect.js +69 -0
  31. package/dist/src/control.d.ts +189 -0
  32. package/dist/src/control.js +2241 -0
  33. package/dist/src/diff.d.ts +44 -0
  34. package/dist/src/diff.js +111 -0
  35. package/dist/src/flags.d.ts +28 -0
  36. package/dist/src/flags.js +76 -0
  37. package/dist/src/main.d.ts +10 -0
  38. package/dist/src/main.js +54 -0
  39. package/dist/src/schedule.d.ts +46 -0
  40. package/dist/src/schedule.js +140 -0
  41. package/dist/src/screens.d.ts +79 -0
  42. package/dist/src/screens.js +1322 -0
  43. package/dist/src/state.d.ts +355 -0
  44. package/dist/src/state.js +531 -0
  45. package/dist/src/terminal.d.ts +44 -0
  46. package/dist/src/terminal.js +101 -0
  47. package/dist/src/tui.d.ts +92 -0
  48. package/dist/src/tui.js +372 -0
  49. package/dist/src/view/automations.d.ts +31 -0
  50. package/dist/src/view/automations.js +76 -0
  51. package/dist/src/view/bood/art.d.ts +90 -0
  52. package/dist/src/view/bood/art.js +152 -0
  53. package/dist/src/view/bood/beetle.d.ts +7 -0
  54. package/dist/src/view/bood/beetle.js +123 -0
  55. package/dist/src/view/bood/bunny.d.ts +8 -0
  56. package/dist/src/view/bood/bunny.js +228 -0
  57. package/dist/src/view/bood/cat.d.ts +9 -0
  58. package/dist/src/view/bood/cat.js +358 -0
  59. package/dist/src/view/bood/crab.d.ts +7 -0
  60. package/dist/src/view/bood/crab.js +121 -0
  61. package/dist/src/view/bood/index.d.ts +29 -0
  62. package/dist/src/view/bood/index.js +25 -0
  63. package/dist/src/view/bood/motion.d.ts +178 -0
  64. package/dist/src/view/bood/motion.js +298 -0
  65. package/dist/src/view/bood/owl.d.ts +9 -0
  66. package/dist/src/view/bood/owl.js +285 -0
  67. package/dist/src/view/bood/registry.d.ts +36 -0
  68. package/dist/src/view/bood/registry.js +218 -0
  69. package/dist/src/view/bood/render.d.ts +31 -0
  70. package/dist/src/view/bood/render.js +196 -0
  71. package/dist/src/view/bood/sprite.d.ts +18 -0
  72. package/dist/src/view/bood/sprite.js +130 -0
  73. package/dist/src/view/bood/sprout.d.ts +8 -0
  74. package/dist/src/view/bood/sprout.js +121 -0
  75. package/dist/src/view/bood/types.d.ts +158 -0
  76. package/dist/src/view/bood/types.js +57 -0
  77. package/dist/src/view/bubble.d.ts +75 -0
  78. package/dist/src/view/bubble.js +86 -0
  79. package/dist/src/view/changes.d.ts +35 -0
  80. package/dist/src/view/changes.js +22 -0
  81. package/dist/src/view/composer.d.ts +64 -0
  82. package/dist/src/view/composer.js +192 -0
  83. package/dist/src/view/controls.d.ts +44 -0
  84. package/dist/src/view/controls.js +49 -0
  85. package/dist/src/view/creature.d.ts +69 -0
  86. package/dist/src/view/creature.js +83 -0
  87. package/dist/src/view/customizations.d.ts +28 -0
  88. package/dist/src/view/customizations.js +53 -0
  89. package/dist/src/view/details.d.ts +65 -0
  90. package/dist/src/view/details.js +65 -0
  91. package/dist/src/view/filediff.d.ts +29 -0
  92. package/dist/src/view/filediff.js +24 -0
  93. package/dist/src/view/files.d.ts +31 -0
  94. package/dist/src/view/files.js +39 -0
  95. package/dist/src/view/hitl.d.ts +43 -0
  96. package/dist/src/view/hitl.js +171 -0
  97. package/dist/src/view/icons.d.ts +13 -0
  98. package/dist/src/view/icons.js +71 -0
  99. package/dist/src/view/picker.d.ts +42 -0
  100. package/dist/src/view/picker.js +71 -0
  101. package/dist/src/view/sessionhead.d.ts +41 -0
  102. package/dist/src/view/sessionhead.js +60 -0
  103. package/dist/src/view/sessions.d.ts +34 -0
  104. package/dist/src/view/sessions.js +61 -0
  105. package/dist/src/view/terminal.d.ts +30 -0
  106. package/dist/src/view/terminal.js +32 -0
  107. package/dist/src/view/toolcall.d.ts +27 -0
  108. package/dist/src/view/toolcall.js +48 -0
  109. package/dist/src/view/transcript.d.ts +50 -0
  110. package/dist/src/view/transcript.js +60 -0
  111. package/package.json +72 -0
@@ -0,0 +1,152 @@
1
+ /**
2
+ * The drawing tag.
3
+ *
4
+ * A tagged template reading `strings.raw`, because this is drawing. A figure
5
+ * whose every backslash has to be doubled to survive the parser is one
6
+ * somebody will eventually get wrong, and the mistake does not look like a
7
+ * mistake - it looks like a slightly worse cat.
8
+ *
9
+ * art`
10
+ * /\_/\
11
+ * ( ^.^ )
12
+ * `
13
+ *
14
+ * The leading and trailing blank lines are the ones the backticks sit on, and
15
+ * they are dropped. Nothing else is: art starts at column zero in the file,
16
+ * because leading spaces are part of the animal and a dedent would eat them.
17
+ */
18
+ export function art(strings) {
19
+ const rows = strings.raw.join('').split('\n');
20
+ if (rows[0]?.trim() === '')
21
+ rows.shift();
22
+ if (rows[rows.length - 1]?.trim() === '')
23
+ rows.pop();
24
+ return rows;
25
+ }
26
+ /** One cell's frames, however the file wrote them. One frame, or several. */
27
+ export function framesOf(cell) {
28
+ return Array.isArray(cell[0]) ? cell : [cell];
29
+ }
30
+ /**
31
+ * Square a form off: one width, one height, across every mood and every frame.
32
+ *
33
+ * Padded once, here, rather than by the compositor - because the compositor
34
+ * pads to the widest row *it* was given, and a centred figure with one short
35
+ * row leans. And because a frame one row taller than the next does not read as
36
+ * animation, it reads as the line underneath it jumping.
37
+ */
38
+ export function square(cells) {
39
+ const width = Math.max(0, ...cells.flatMap((frames) => frames.flatMap((rows) => rows.map((row) => row.length))));
40
+ const height = Math.max(0, ...cells.flatMap((frames) => frames.map((rows) => rows.length)));
41
+ for (const frames of cells) {
42
+ for (let at = 0; at < frames.length; at += 1) {
43
+ const rows = frames[at].map((row) => row.padEnd(width));
44
+ while (rows.length < height)
45
+ rows.push(' '.repeat(width));
46
+ frames[at] = rows;
47
+ }
48
+ }
49
+ return { width, height };
50
+ }
51
+ /**
52
+ * A long open and a short shut.
53
+ *
54
+ * Two frames alternating at the ticker's rate is not a blink, it is a strobe.
55
+ * The hold lives in the data rather than in the component, because how long a
56
+ * cat's eyes stay open is a fact about the cat.
57
+ */
58
+ export const blink = (open, shut) => [open, open, open, shut];
59
+ /** Two frames, each held for two - a slow alternation inside a fast ticker. */
60
+ export const alternate = (a, b) => [a, a, b, b];
61
+ /**
62
+ * Fill a pose's slots: a run of `%` takes the face, a run of `#` the tell.
63
+ *
64
+ * The run is written exactly as wide as the token that fills it, so a filled
65
+ * row is the same length as the row it came from and nothing downstream has to
66
+ * re-measure. `registerCreature` checks that at registration; the padding here
67
+ * is what happens when somebody registers their own creature at runtime and
68
+ * got it wrong, and a short token is better than a row that shifts.
69
+ */
70
+ export function fill(rows, face, tell) {
71
+ return rows.map((row) => row
72
+ .replace(/%+/g, (run) => pad(face, run.length))
73
+ .replace(/#+/g, (run) => pad(tell, run.length)));
74
+ }
75
+ function pad(token, width) {
76
+ if (token.length === width)
77
+ return token;
78
+ return token.length > width ? token.slice(0, width) : token.padEnd(width);
79
+ }
80
+ /**
81
+ * What one frame is, and where the animal is inside it.
82
+ *
83
+ * The anchor is the middle of the face slot - the creature's identity point -
84
+ * and a figure is placed by it rather than by its left edge. That is what lets
85
+ * a cat turn side-on: the walking drawing is twice as wide as the front one
86
+ * with the head at the far end, and anchored on the face the body swings round
87
+ * a head that stays where it was. Anchored on the corner it would jump ten
88
+ * cells every time the cat turned round.
89
+ *
90
+ * A pose that pins its own face has no slot to read, so it falls back to the
91
+ * middle, which is where a symmetrical drawing's identity is anyway.
92
+ */
93
+ export function metric(rows) {
94
+ let width = 0;
95
+ let anchor = -1;
96
+ for (const row of rows) {
97
+ if (row.length > width)
98
+ width = row.length;
99
+ const slot = /%+/.exec(row);
100
+ if (slot && anchor < 0)
101
+ anchor = slot.index + Math.floor(slot[0].length / 2);
102
+ }
103
+ return { width, height: rows.length, anchor: anchor < 0 ? Math.floor(width / 2) : anchor };
104
+ }
105
+ /**
106
+ * The anchor a whole pose is placed by: frame zero's, shared by every frame.
107
+ *
108
+ * Per-frame anchors would hold the face still and slide everything else, which
109
+ * is the wrong half of the motion to believe. The cat at the keyboard bobs its
110
+ * head one cell between frames; taking the anchor from frame zero keeps the
111
+ * desk still and moves the head, which is what the drawing means.
112
+ */
113
+ export function anchorOf(frames) {
114
+ return metric(frames[0]).anchor;
115
+ }
116
+ /**
117
+ * Write a figure into a field of rows, bottom-aligned and anchored.
118
+ *
119
+ * Bottom-aligned because the feet own the y: the landing squash is a row
120
+ * shorter than the stand, and padding underneath would sink the creature
121
+ * through the floor at exactly the moment it hits it.
122
+ *
123
+ * Anything off the field is dropped rather than wrapped, so a creature halfway
124
+ * out of a narrow box is half a creature instead of a smear down the far side.
125
+ */
126
+ export function blit(field, rows, x, y, anchor) {
127
+ const out = [...field];
128
+ const left = Math.round(x) - anchor;
129
+ const top = Math.round(y) - rows.length + 1;
130
+ for (let at = 0; at < rows.length; at += 1) {
131
+ const line = top + at;
132
+ if (line < 0 || line >= out.length)
133
+ continue;
134
+ const into = out[line];
135
+ const art = rows[at];
136
+ let built = '';
137
+ for (let col = 0; col < art.length; col += 1) {
138
+ const cell = left + col;
139
+ if (cell < 0 || cell >= into.length)
140
+ continue;
141
+ if (built === '')
142
+ built = into;
143
+ const glyph = art[col];
144
+ if (glyph === ' ')
145
+ continue;
146
+ built = built.slice(0, cell) + glyph + built.slice(cell + 1);
147
+ }
148
+ if (built !== '')
149
+ out[line] = built;
150
+ }
151
+ return out;
152
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * A beetle. Antennae up, six legs, a shell drawn as a row of equals.
3
+ *
4
+ * The legs are what move while it is working. Antennae carry sad, the way the
5
+ * cat's tail does: they come down, and they stay down until the mood does.
6
+ */
7
+ export declare const beetle: import("./types.js").CreatureSpec;
@@ -0,0 +1,123 @@
1
+ import { alternate, art, blink } from './art.js';
2
+ import { defineCreature } from './types.js';
3
+ /**
4
+ * A beetle. Antennae up, six legs, a shell drawn as a row of equals.
5
+ *
6
+ * The legs are what move while it is working. Antennae carry sad, the way the
7
+ * cat's tail does: they come down, and they stay down until the mood does.
8
+ */
9
+ export const beetle = defineCreature({
10
+ name: 'beetle',
11
+ label: 'Beetle',
12
+ about: 'Carries more than it weighs',
13
+ draw: {
14
+ happy: blink(art `
15
+ \ /
16
+ __\_/__
17
+ /( ^.^ )\
18
+ \|=====|/
19
+ / | \
20
+ `, art `
21
+ \ /
22
+ __\_/__
23
+ /( -.- )\
24
+ \|=====|/
25
+ / | \
26
+ `),
27
+ sad: art `
28
+ | |
29
+ __\_/__
30
+ /( T.T )\
31
+ \|=====|/
32
+ \ | /
33
+ `,
34
+ thinking: alternate(art `
35
+ \ / o
36
+ __\_/__
37
+ /( o.- )\
38
+ \|=====|/
39
+ / | \
40
+ `, art `
41
+ \ / .
42
+ __\_/__
43
+ /( o.- )\
44
+ \|=====|/
45
+ / | \
46
+ `),
47
+ executing: [art `
48
+ \ /
49
+ __\_/__
50
+ /( o.o )\
51
+ \|=====|/
52
+ / | \
53
+ `, art `
54
+ \ /
55
+ __\_/__
56
+ /( o.- )\
57
+ \|=====|/
58
+ \ | /
59
+ `, art `
60
+ \ /
61
+ __\_/__
62
+ /( -.o )\
63
+ \|=====|/
64
+ / | \
65
+ `],
66
+ error: art `
67
+ \ /
68
+ _\___/_
69
+ /( >.< )\
70
+ \|=====|/
71
+ / | \
72
+ `,
73
+ },
74
+ block: {
75
+ happy: blink(art `
76
+ _\_/_
77
+ (^.^)
78
+ / | \
79
+ `, art `
80
+ _\_/_
81
+ (-.-)
82
+ / | \
83
+ `),
84
+ sad: art `
85
+ _|_|_
86
+ (T.T)
87
+ \ | /
88
+ `,
89
+ thinking: art `
90
+ _\_/_
91
+ (-.o)
92
+ / | \
93
+ `,
94
+ executing: [art `
95
+ _\_/_
96
+ (o.o)
97
+ / | \
98
+ `, art `
99
+ _\_/_
100
+ (o.-)
101
+ \ | /
102
+ `, art `
103
+ _\_/_
104
+ (-.o)
105
+ / | \
106
+ `],
107
+ error: art `
108
+ _\_/_
109
+ (>.<)
110
+ / | \
111
+ `,
112
+ },
113
+ // Square brackets rather than the slashes the bigger forms use: a drawing
114
+ // that ends in a backslash cannot be written as a template literal at all,
115
+ // and the shell is the beetle's other outline anyway.
116
+ inline: {
117
+ happy: blink(art `[^.^]`, art `[-.-]`),
118
+ sad: art `[T.T]`,
119
+ thinking: art `[-.o]`,
120
+ executing: [art `[o.o]`, art `[o.-]`, art `[-.o]`],
121
+ error: art `[>.<]`,
122
+ },
123
+ });
@@ -0,0 +1,8 @@
1
+ /**
2
+ * A bunny. The ears are the tell.
3
+ *
4
+ * Up and open when things are well, folded flat when they are not. At block
5
+ * and inline size there are no ears to fold, so the face does all of it -
6
+ * which is what those two sizes are for.
7
+ */
8
+ export declare const bunny: import("./types.js").CreatureSpec;
@@ -0,0 +1,228 @@
1
+ import { alternate, art, blink } from './art.js';
2
+ import { defineCreature } from './types.js';
3
+ /**
4
+ * A bunny. The ears are the tell.
5
+ *
6
+ * Up and open when things are well, folded flat when they are not. At block
7
+ * and inline size there are no ears to fold, so the face does all of it -
8
+ * which is what those two sizes are for.
9
+ */
10
+ export const bunny = defineCreature({
11
+ name: 'bunny',
12
+ label: 'Bunny',
13
+ about: 'Quiet, and faster than it looks',
14
+ draw: {
15
+ happy: blink(art `
16
+ (\_/)
17
+ ( ^.^)
18
+ c(")_(")
19
+ `, art `
20
+ (\_/)
21
+ ( -.-)
22
+ c(")_(")
23
+ `),
24
+ // Ears down. The face alone would read as a bunny squinting.
25
+ sad: art `
26
+ (,_,)
27
+ ( T.T)
28
+ c(")_(")
29
+ `,
30
+ thinking: alternate(art `
31
+ (\_/) o
32
+ ( o.-)
33
+ c(")_(")
34
+ `, art `
35
+ (\_/) .
36
+ ( o.-)
37
+ c(")_(")
38
+ `),
39
+ executing: [art `
40
+ (\_/)
41
+ ( o.o)
42
+ c(")_(")
43
+ `, art `
44
+ (\_/)
45
+ ( o.-)
46
+ c(")_(")
47
+ `, art `
48
+ (\_/)
49
+ ( -.o)
50
+ c(")_(")
51
+ `],
52
+ error: art `
53
+ (\_/)
54
+ ( >.<)
55
+ c(")_(")
56
+ `,
57
+ },
58
+ block: {
59
+ happy: blink(art `
60
+ (\_/)
61
+ (^.^)
62
+ ("_")
63
+ `, art `
64
+ (\_/)
65
+ (-.-)
66
+ ("_")
67
+ `),
68
+ sad: art `
69
+ (,_,)
70
+ (T.T)
71
+ ("_")
72
+ `,
73
+ thinking: art `
74
+ (\_/)
75
+ (-.o)
76
+ ("_")
77
+ `,
78
+ executing: [art `
79
+ (\_/)
80
+ (o.o)
81
+ ("_")
82
+ `, art `
83
+ (\_/)
84
+ (o.-)
85
+ ("_")
86
+ `, art `
87
+ (\_/)
88
+ (-.o)
89
+ ("_")
90
+ `],
91
+ error: art `
92
+ (\_/)
93
+ (>.<)
94
+ ("_")
95
+ `,
96
+ },
97
+ inline: {
98
+ happy: blink(art `(\^.^/)`, art `(\-.-/)`),
99
+ sad: art `(,T.T,)`,
100
+ thinking: art `(\-.o/)`,
101
+ executing: [art `(\o.o/)`, art `(\o.-/)`, art `(\-.o/)`],
102
+ error: art `(x>.<x)`,
103
+ },
104
+ /**
105
+ * Moving, and the ears keep doing the work.
106
+ *
107
+ * The forepaw is what says which way it is pointed - planted at the front
108
+ * when it is facing right, trailed behind when it is facing left - and it is
109
+ * a `c` on both sides here. The reference sheet mirrors it properly, as `c`
110
+ * and an open o, and that second glyph is U+0254: not ASCII, and East Asian
111
+ * Ambiguous, which means two cells wide under a CJK font setting. A rabbit
112
+ * one cell wider on somebody else's terminal does not look wide, it looks
113
+ * broken. So the paw curves the wrong way going left, which nobody reads at
114
+ * one cell, and the drawing is the same width everywhere.
115
+ *
116
+ * There is no walk cycle, because a bunny cannot travel without leaving the
117
+ * ground: `walk` is the crouch it launches from and is over in two frames.
118
+ */
119
+ motion: {
120
+ gait: 'hop',
121
+ flies: false,
122
+ sits: true,
123
+ bounce: 0.25,
124
+ fallSpeed: 1.15,
125
+ hop: 1,
126
+ blink: '-.-',
127
+ faces: { happy: '^.^', sad: 'T.T', thinking: '-.o', executing: 'o.o', error: '>.<' },
128
+ tells: { happy: '(\\_/)', sad: '(,_,)', thinking: '(\\_/)', executing: '(\\_/)', error: '(x_x)' },
129
+ poses: {
130
+ // Front is what it returns to: after a couple of seconds it looks at you,
131
+ // and shifts its weight from one paw to the other while it waits.
132
+ 'idle.front': [art `
133
+ #####
134
+ (%%%)
135
+ c((_ _))
136
+ `, art `
137
+ #####
138
+ (%%%)
139
+ ((_ _))D
140
+ `],
141
+ 'idle.right': [art `
142
+ #####
143
+ ( %%%)
144
+ c(")_(")
145
+ `],
146
+ 'idle.left': [art `
147
+ #####
148
+ (%%% )
149
+ (")_(")D
150
+ `],
151
+ 'sit.front': art `
152
+ #####
153
+ (%%%)
154
+ ((_ _))
155
+ `,
156
+ 'sit.right': art `
157
+ #####
158
+ ( %%%)
159
+ C(")(")
160
+ `,
161
+ 'sit.left': art `
162
+ #####
163
+ (%%% )
164
+ (")(")D
165
+ `,
166
+ 'walk.right': art `
167
+ #####
168
+ ( %%%)
169
+ .(")_(")
170
+ `,
171
+ 'walk.left': art `
172
+ #####
173
+ (%%% )
174
+ (")_(")D
175
+ `,
176
+ 'jump.right': art `
177
+ #####
178
+ ( %%%)
179
+ C((")(")
180
+ (") (")
181
+ `,
182
+ 'jump.left': art `
183
+ #####
184
+ (%%% )
185
+ (")("))D
186
+ (") (")
187
+ `,
188
+ 'fall.right': art `
189
+ #####
190
+ ( %%%)
191
+ C(")_(")
192
+ ' '
193
+ `,
194
+ 'fall.left': art `
195
+ #####
196
+ (%%% )
197
+ (")_(")D
198
+ ' '
199
+ `,
200
+ // A squash is wider and shorter. Bottom-aligned, so it settles onto the
201
+ // floor rather than sinking through it.
202
+ land: art `
203
+ #####
204
+ (%%%)
205
+ ((" "))
206
+ `,
207
+ held: art `
208
+ #####
209
+ (%%%)
210
+ ("|")
211
+ (")U(")
212
+ `,
213
+ // Pins its own face over the mood, and the mood comes straight back when
214
+ // anything wakes it.
215
+ sleep: art `
216
+ (,_,)
217
+ (-.-)
218
+ ((_ _))
219
+ `,
220
+ alarm: art `
221
+ #####
222
+ (%%%)
223
+ C((_ _))
224
+ ^ ^
225
+ `,
226
+ },
227
+ },
228
+ });
@@ -0,0 +1,9 @@
1
+ /**
2
+ * A cat, in three sizes.
3
+ *
4
+ * The tail is what carries the mood at full size after the face does: up and
5
+ * curled when things are well, flat when they are not, swishing while there is
6
+ * work going on. Which is a second carrier of the same meaning, and that is the
7
+ * point - a 16-colour session and a piped log both keep the tail.
8
+ */
9
+ export declare const cat: import("./types.js").CreatureSpec;