@trama-dev/runtime 0.4.0 → 0.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.
Files changed (56) hide show
  1. package/README.md +4 -3
  2. package/dist/abort.d.ts +12 -0
  3. package/dist/abort.js +31 -0
  4. package/dist/agent-backend.d.ts +127 -7
  5. package/dist/agent-backend.js +38 -19
  6. package/dist/agent-host.d.ts +50 -0
  7. package/dist/agent-host.js +97 -0
  8. package/dist/agent-hosts.d.ts +14 -0
  9. package/dist/agent-hosts.js +321 -0
  10. package/dist/agent.d.ts +26 -3
  11. package/dist/agent.js +165 -43
  12. package/dist/bridge-client.d.ts +6 -0
  13. package/dist/bridge-client.js +69 -16
  14. package/dist/budget.d.ts +52 -0
  15. package/dist/budget.js +118 -0
  16. package/dist/child-process.d.ts +18 -0
  17. package/dist/child-process.js +38 -9
  18. package/dist/client.d.ts +2 -1
  19. package/dist/client.js +9 -19
  20. package/dist/context.d.ts +36 -7
  21. package/dist/context.js +83 -92
  22. package/dist/errors.d.ts +2 -0
  23. package/dist/errors.js +2 -0
  24. package/dist/index.d.ts +7 -2
  25. package/dist/index.js +254 -88
  26. package/dist/ipc-server.d.ts +14 -5
  27. package/dist/ipc-server.js +174 -144
  28. package/dist/journal-view.d.ts +2 -0
  29. package/dist/journal-view.js +52 -7
  30. package/dist/journal.d.ts +27 -9
  31. package/dist/journal.js +216 -79
  32. package/dist/meta.d.ts +18 -0
  33. package/dist/meta.js +29 -0
  34. package/dist/model-relay.d.ts +130 -0
  35. package/dist/model-relay.js +339 -0
  36. package/dist/path-guard.d.ts +128 -19
  37. package/dist/path-guard.js +384 -68
  38. package/dist/pi-adapter.d.ts +35 -9
  39. package/dist/pi-adapter.js +865 -66
  40. package/dist/replace-file.d.ts +31 -0
  41. package/dist/replace-file.js +75 -0
  42. package/dist/runner-types.d.ts +35 -0
  43. package/dist/runner.d.ts +202 -30
  44. package/dist/runner.js +949 -273
  45. package/dist/serializable.d.ts +10 -4
  46. package/dist/serializable.js +56 -31
  47. package/dist/stopping.d.ts +37 -3
  48. package/dist/stopping.js +167 -21
  49. package/dist/tools.d.ts +2 -1
  50. package/dist/tools.js +90 -21
  51. package/dist/tree.d.ts +241 -0
  52. package/dist/tree.js +1431 -0
  53. package/dist/types.d.ts +106 -15
  54. package/dist/workspace.d.ts +7 -0
  55. package/dist/workspace.js +93 -104
  56. package/package.json +1 -1
package/dist/tree.d.ts ADDED
@@ -0,0 +1,241 @@
1
+ /**
2
+ * What is at one path. `id` says which file, directory or link it is: it
3
+ * stays the same through being written to, renamed, or given other
4
+ * permissions, and nothing else has it. (It is the system's numbers for it —
5
+ * its device's, and its own on that — and a file system may give a number
6
+ * again once what had it is gone: what was removed can so be taken for what
7
+ * was made after it.)
8
+ */
9
+ export type Entry =
10
+ /** `stamp` is different after any change to the file — to what it holds or to what it allows — and cannot be set by a program. */
11
+ {
12
+ kind: "file";
13
+ mode: number;
14
+ size: number;
15
+ stamp: string;
16
+ id: string;
17
+ } | {
18
+ kind: "dir";
19
+ mode: number;
20
+ id: string;
21
+ } | {
22
+ kind: "link";
23
+ text: string;
24
+ id: string;
25
+ }
26
+ /** A pipe, a socket, a device, a link that says nothing a path can be made of: one end of something else, not content. */
27
+ | {
28
+ kind: "other";
29
+ };
30
+ /**
31
+ * What a directory is and holds: the directory itself, as ".", and every path
32
+ * under it ("/" between the names) — a directory before what is in it.
33
+ */
34
+ export type Tree = Map<string, Entry>;
35
+ /** What is at a path — the path itself, not what a link there leads to. Undefined if nothing is. */
36
+ export declare function entryAt(path: string): Entry | undefined;
37
+ /** The paths at which two readings of a directory differ, a path before every path under it. */
38
+ export declare function differences(before: Tree, after: Tree): string[];
39
+ /**
40
+ * What a directory is and holds. The directory must be there, and all of it
41
+ * readable — or, with `opening`, to be made so: a directory that may not be
42
+ * looked into is opened for the reading, and left allowing what it allowed.
43
+ * (That is for a directory that is the reader's own to open: a copy.)
44
+ */
45
+ export declare function readTree(dir: string, opening?: boolean): Tree;
46
+ /**
47
+ * Make `toDir` — an empty directory — what `fromDir` is: allowing what it
48
+ * allows and holding what it holds. Returns what that was: the directory, and
49
+ * each entry as it was when it was copied. `leaveOut` names
50
+ * what is no part of it; those entries are neither copied nor returned.
51
+ *
52
+ * What a directory holds is its files, its directories with what they allow,
53
+ * and its links. What is not content is not carried over, though the tree
54
+ * returned says it is there. The directory itself is one of its directories
55
+ * in this: the copy is left allowing what it allows — to its owner, and to
56
+ * everybody else. (So a copy that is to be nobody else's is made in a
57
+ * directory that is nobody else's.)
58
+ *
59
+ * A link is made to name, in the copy, what it names here: the same place in
60
+ * the copy if that is under `fromDir`, and the same place outside it if not.
61
+ * Most links do that as they are written, and are kept so — but for the
62
+ * letters of a name the copy does not have as it is written, where its file
63
+ * system tells apart what this one takes for one name. Not one whose
64
+ * way steps out of the directory over its top with "..", or into it from
65
+ * outside: from the copy's place those words lead somewhere else — or back
66
+ * into the original, where what was done through the link in the copy would
67
+ * be done to the original. Such a link is rewritten. If its way comes to the
68
+ * directory from outside and stays in it, what it says from there on is said
69
+ * of the directory, and is kept, said of the copy: only the part that comes
70
+ * to the directory is replaced, and a link of the directory on the rest of
71
+ * the way is still passed through in the copy, wherever it then leads. If
72
+ * not — the way ends outside — the link is made to name the place itself.
73
+ * A link whose way cannot be followed here names nothing that can be told,
74
+ * and is not carried over. Whether it can be is asked of this reading, and of
75
+ * the system: a link the system will not follow — too many links on its way,
76
+ * a name too long — is not carried either, whatever it says, since a copy of
77
+ * it could come to be followed where a link on its way is rewritten shorter.
78
+ * Nor is one whose rewritten words the system will not have for a link.
79
+ *
80
+ * The tree returned is read in the same pass that copies, each entry before
81
+ * it is copied. So the copy never holds what the tree does not know of; and
82
+ * an entry that changes while it is copied is in the tree as it was before,
83
+ * which is the side to err on — it will not be taken for untouched later.
84
+ */
85
+ export declare function copyTree(fromDir: string, toDir: string, leaveOut?: (at: string, entry: Entry) => boolean): Tree;
86
+ /**
87
+ * The path a reading of `dir` has for a place: each step by the name its
88
+ * directory lists for it, and "." for the directory itself. Undefined if
89
+ * nothing is there, or the place is not in `dir`. The place is named without
90
+ * links.
91
+ */
92
+ export declare function pathAsListed(dir: string, place: string): string | undefined;
93
+ /** Something a run did in a copy that did not reach the real directory, and why. */
94
+ export interface Unmerged {
95
+ path: string;
96
+ why: string;
97
+ }
98
+ /**
99
+ * Carry what a run did to a copy back into the directory it is a copy of.
100
+ *
101
+ * @param stagedDir - the copy, as the run left it
102
+ * @param realDir - the directory it was copied from
103
+ * @param before - the copy as it was before the run (readTree)
104
+ * @param seed - the real directory as it was when the copy was made (copyTree)
105
+ * @param together - things that are one thing to the caller: each list the
106
+ * `id`s (see Entry) of the files, links and directories that are one
107
+ *
108
+ * What the run did is where the copy differs from what it was: a file, a
109
+ * directory or a link made, removed, changed, or put where something of
110
+ * another kind was; permissions changed — those of the directory itself
111
+ * among them, which is a directory like any in it: only that it is neither
112
+ * made nor removed. Each difference is carried over on
113
+ * one condition: the place in the real directory is still as it was when the
114
+ * copy was made — and so is the directory it is in. If not, somebody else —
115
+ * the user, another run of the same project — has been there since, and
116
+ * theirs is kept. A place that already holds what the run left needs nothing
117
+ * done, whoever made it so.
118
+ *
119
+ * There is no path this leaves out. Where the caller has itself put
120
+ * something into the real directory since the copy was made, it says so in
121
+ * `seed`: the place is then as the seed has it, and what the run did there is
122
+ * carried over like anything else.
123
+ *
124
+ * All of that is found out before anything is done. What cannot arrive is
125
+ * then left alone, with everything under it; and a directory the run removed,
126
+ * or put something else in the place of, goes only if all that is in it goes
127
+ * — if anything in it stays, or it holds something the run never saw, the
128
+ * directory stays whole. What the run moved — a file, a link, a directory —
129
+ * goes from where it was only if it arrives where the run moved it: what it
130
+ * holds is not to be in neither place. (What was moved is known by its `id`,
131
+ * see Entry. What the run copied and then removed is a new file, and is not
132
+ * known to be the old one's.) And what the caller says is one thing — a
133
+ * link, say, with the file that makes it lead somewhere: the things in one
134
+ * list of `together`, each known by what it is, at every path where the copy
135
+ * had it before the run or has it now — arrives together or not at all: if
136
+ * one of those paths is left alone, nothing is done at any of them. A part
137
+ * the run left as it was has nothing to arrive, but the rest leans on it: if
138
+ * it is not, in the project, as it was when the copy was made, that is told
139
+ * of it, and the rest does not arrive. (So that all this holds where the
140
+ * system refuses in the doing, what is done at such a path is only what can
141
+ * be taken back: a file there is not written into but has the new one put in
142
+ * its place, and what is to go from there is moved aside first, as what is
143
+ * taken the place of is. A directory among them that stays a directory is
144
+ * not left alone with the rest — what else the run did in it could not be
145
+ * taken for undone with it — but what it was to be left allowing does not
146
+ * arrive either, and that is told of it. And a part the run left as it was,
147
+ * and that is not so in the project, is told of besides, as that: nothing
148
+ * under it is left alone for it — and nothing is told of it where nothing is
149
+ * held back for it.) So what is returned as not arrived is as it
150
+ * was, at that path and under it. That holds where the system refuses, in
151
+ * the doing, what had been found possible — see how it is done, below — as
152
+ * long as it does not also refuse to put back what was moved aside; then
153
+ * the report says where that is.
154
+ *
155
+ * Some things are told of besides, which are not that. What was moved aside
156
+ * to go, or made ready and not needed, and which the system will not have
157
+ * removed, is told of at the name it is left under — a path that is none of
158
+ * the run's. A directory the run removed which the system will not remove,
159
+ * or not with all that was in it, holds what is left, as it would had the
160
+ * run removed it there, and is told of so. A directory or a file that could
161
+ * not be given, at the end, what it is to allow is told of for that: what
162
+ * it holds has arrived, unless that is told of itself. A file that could not
163
+ * be written into, and had a new one put in its place, is told of for that.
164
+ * (If the system will not have the new one put there either, the file did
165
+ * not arrive, and the report says that what it held may be damaged, and
166
+ * where what it was to hold is.)
167
+ *
168
+ * Finding out is looking, and a directory that is closed cannot be looked
169
+ * into. One of the real directory's — or the directory itself — is opened
170
+ * for it, as it is for what is then done in it, and one of the copy's is
171
+ * opened to be read: both are this merge's to open. Each is left, at the end,
172
+ * allowing what the run left it allowing — or, if that did not arrive, what
173
+ * it allowed. (One that somebody else gave other permissions since the copy
174
+ * was made is theirs, and is not opened: nothing is made or removed in it.)
175
+ *
176
+ * A path is a name, and the real directory has the last word on its names:
177
+ * its file system may take "Notes.txt" and "notes.txt" for one. A path of
178
+ * the tree whose place holds something, though the directory does not list
179
+ * the name as the tree spells it, is such a second spelling — the run
180
+ * spelled a name anew, or made one beside another on a file system that
181
+ * tells them apart. To a tree that is one entry removed and another made; in
182
+ * the real directory the two are one place, and removing the one would
183
+ * remove the other. Neither is touched: nothing is done to what is there
184
+ * under any name the run changed, and each is told of as not arrived. (What
185
+ * is there is known by what it is. All the names of a file that has several
186
+ * are therefore left, where one would have done.) If what is there is a
187
+ * directory, nothing is done in it either: a path through it is a path
188
+ * through the other, and what the run left under the two names is in one
189
+ * place. And two names the run made where nothing was, which the directory
190
+ * turns out to take for one when the second is put there: neither is put.
191
+ * (That can only be seen in the putting. If the first was not put, for a
192
+ * reason of its own, the second is — and what is told of the first is then
193
+ * true of the name as the run spelled it, not as the directory takes it.)
194
+ * The same is asked of the way to a path: a directory on it that the real
195
+ * one no longer lists as the tree spells it — somebody spelled it anew — is
196
+ * not the tree's directory any more, and nothing is done in it.
197
+ *
198
+ * What is to be done is done so that nothing is lost by its being done in
199
+ * part. A file or a link that is to be where something is, is made beside
200
+ * the place first. Then what the run made is made, a directory before what
201
+ * goes in it. What is in the place of it is not removed but moved aside,
202
+ * under a name of its own beside the place, and what was made beside the
203
+ * place is moved in. (Only a directory that stays a directory, and a file
204
+ * the run wrote into that can be written into, stay and are changed where
205
+ * they are. A file that is written into has what it is to hold made beside
206
+ * it first all the same: if the system will not have the writing — which it
207
+ * may have begun — that takes its place.) Where the system will not have a thing done, that
208
+ * thing is left alone like what was found impossible beforehand, with what
209
+ * follows from it — and what follows may be that something already done is
210
+ * not to stand: what the run moved from there did not arrive where it went.
211
+ * Then what was put there is removed again, and what was moved aside comes
212
+ * back. Only when all that is settled does what was moved aside go for good,
213
+ * and what the run removed, where it is. (A runner that is stopped in the
214
+ * middle leaves what it had moved aside, or made ready, where it is: under
215
+ * names that begin with .trama-tmp-.) It is where the run ended that is
216
+ * carried over, not the steps by which it got there.
217
+ *
218
+ * A file the run wrote into is written into, if it may be, and stays the
219
+ * file it is — as does one that holds what the run left already, and has
220
+ * only what it allows changed. Where the run put another file in the place,
221
+ * or the file may not be written into, or the system will not have it
222
+ * written into after all, a new one is put in its place — and then a second
223
+ * name of the old file is none of the new one, and holds whatever the
224
+ * writing left. A link is written as the run wrote it
225
+ * — the run took its copy for the directory itself — unless its way comes to
226
+ * the copy from outside: by the copy's full path, or out of the copy and
227
+ * back in by its name. What such a link says from there on is said of the
228
+ * real directory, wherever that leads from there. So a link the copy
229
+ * was given in other words than the directory's own (see copyTree), if the
230
+ * run moved it, is merged in those words: it names what the run found it to
231
+ * name, which is not always what the directory's own words would name from
232
+ * the new place. And a link the run made that climbs out of its directory
233
+ * with ".." and does not come back says the same in the real directory, and
234
+ * names from there what it names from there.
235
+ *
236
+ * Nothing is thrown. What could not be carried over is returned, each path
237
+ * with the reason, so that a run whose work did not all arrive is not passed
238
+ * off as one whose work did. Under a path that did not arrive, what was not
239
+ * looked at for that reason is not listed: it is as it was, with the path.
240
+ */
241
+ export declare function mergeTree(stagedDir: string, realDir: string, before: Tree, seed: Tree, together?: string[][]): Unmerged[];