@agentshouse/mdruntime-adapter 0.1.0-ca47c2e51c195 → 0.1.0-ca5b5175ac20a
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 +1 -1
- package/dist/actions.d.ts +9 -0
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +179 -5
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +109 -108
- package/dist/authored-path.d.ts +54 -2
- package/dist/authored-path.d.ts.map +1 -1
- package/dist/authored-path.js +142 -10
- package/dist/chunks.d.ts +2 -3
- package/dist/chunks.d.ts.map +1 -1
- package/dist/chunks.js +47 -35
- package/dist/discovery.d.ts +25 -5
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +169 -21
- package/dist/index.d.ts +6 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -5
- package/dist/model.d.ts +5 -5
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +17 -27
- package/dist/read.d.ts +11 -24
- package/dist/read.d.ts.map +1 -1
- package/dist/read.js +74 -47
- package/dist/refusal.d.ts +4 -1
- package/dist/refusal.d.ts.map +1 -1
- package/dist/refusal.js +11 -0
- package/dist/renamed.d.ts +10 -0
- package/dist/renamed.d.ts.map +1 -0
- package/dist/renamed.js +20 -0
- package/dist/room-query.d.ts +4 -0
- package/dist/room-query.d.ts.map +1 -0
- package/dist/room-query.js +63 -0
- package/dist/session-content/check.d.ts +4 -2
- package/dist/session-content/index.d.ts +3 -4
- package/dist/session-content/parts.d.ts +14 -87
- package/dist/session-content/state.d.ts +21 -23
- package/dist/session-content/turn.d.ts +82 -258
- package/dist/site.d.ts.map +1 -1
- package/dist/site.js +44 -10
- package/dist/space-schema.d.ts +1 -1
- package/dist/space-schema.d.ts.map +1 -1
- package/dist/space-schema.js +2 -9
- package/dist/stream.d.ts +4 -4
- package/dist/stream.d.ts.map +1 -1
- package/dist/stream.js +114 -53
- package/dist/transport.d.ts +62 -11
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js +46 -8
- package/dist/upload.d.ts +4 -0
- package/dist/upload.d.ts.map +1 -1
- package/dist/upload.js +41 -0
- package/dist/write.d.ts +3 -8
- package/dist/write.d.ts.map +1 -1
- package/dist/write.js +72 -92
- package/package.json +4 -4
- package/dist/session-content/bounds.d.ts +0 -7
package/dist/upload.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { sha256 } from '@agentshouse/mdruntime/digest';
|
|
2
|
+
import { answeredFailure, doorRefusal } from './refusal.js';
|
|
2
3
|
import { houseDoorRoute } from './transport.js';
|
|
4
|
+
import { unusable } from './uncertain.js';
|
|
3
5
|
const FINISHING_ROUNDS = 24;
|
|
4
6
|
function record(value) {
|
|
5
7
|
return value !== null && typeof value === 'object' ? value : {};
|
|
@@ -63,3 +65,42 @@ export async function finishedUpload(transport, first, blob) {
|
|
|
63
65
|
}
|
|
64
66
|
return { unfinished: 200 };
|
|
65
67
|
}
|
|
68
|
+
function unstagedRefusal(answer) {
|
|
69
|
+
const refusal = doorRefusal(answer.body);
|
|
70
|
+
return refusal?.code === 'files_unstaged' ? refusal : null;
|
|
71
|
+
}
|
|
72
|
+
async function staged(transport, named, file) {
|
|
73
|
+
const upload = houseUpload(named);
|
|
74
|
+
if (upload === null)
|
|
75
|
+
return unusable();
|
|
76
|
+
const blob = file(record(named).sha256);
|
|
77
|
+
if (blob === null)
|
|
78
|
+
return unusable();
|
|
79
|
+
const sent = await finishedUpload(transport, upload, await blob);
|
|
80
|
+
if ('unfinished' in sent)
|
|
81
|
+
return answeredFailure(sent.unfinished, null);
|
|
82
|
+
if (sent.status !== 200)
|
|
83
|
+
return answeredFailure(sent.status, sent.body);
|
|
84
|
+
return record(sent.body).staged === true ? null : unusable();
|
|
85
|
+
}
|
|
86
|
+
export async function stagedBatch(transport, body, file) {
|
|
87
|
+
let answer = await transport.door(houseDoorRoute('update'), body);
|
|
88
|
+
const finished = new Set();
|
|
89
|
+
for (let unstaged = unstagedRefusal(answer); unstaged !== null; unstaged = unstagedRefusal(answer)) {
|
|
90
|
+
const named = unstaged.fields.upload;
|
|
91
|
+
if (!Array.isArray(named))
|
|
92
|
+
return unusable();
|
|
93
|
+
const fresh = named.filter((upload) => !finished.has(record(upload).id));
|
|
94
|
+
if (fresh.length === 0)
|
|
95
|
+
return answeredFailure(answer.status, answer.body);
|
|
96
|
+
for (const upload of fresh) {
|
|
97
|
+
const staging = await staged(transport, upload, file);
|
|
98
|
+
if (staging !== null)
|
|
99
|
+
return staging;
|
|
100
|
+
}
|
|
101
|
+
for (const upload of fresh)
|
|
102
|
+
finished.add(record(upload).id);
|
|
103
|
+
answer = await transport.door(houseDoorRoute('update'), body);
|
|
104
|
+
}
|
|
105
|
+
return answer;
|
|
106
|
+
}
|
package/dist/write.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ChangeBatch, type HistoryResult, type MutationResult } from '@agentshouse/mdruntime';
|
|
1
|
+
import { type ChangeBatch, type HistoryResult, type MutationResult, type Written } from '@agentshouse/mdruntime';
|
|
2
2
|
import type { HouseBounds } from './discovery.js';
|
|
3
3
|
export type HouseOperation = Readonly<Record<string, unknown>>;
|
|
4
4
|
export type ChangeMapping = {
|
|
@@ -9,19 +9,14 @@ export type ChangeMapping = {
|
|
|
9
9
|
path: string;
|
|
10
10
|
rule: string;
|
|
11
11
|
};
|
|
12
|
-
export declare function houseChanges(batch: ChangeBatch, handle: string): ChangeMapping;
|
|
13
|
-
export declare function houseParts(saved: readonly {
|
|
14
|
-
readonly path: string;
|
|
15
|
-
readonly parts: unknown;
|
|
16
|
-
}[], handle: string): ChangeMapping;
|
|
12
|
+
export declare function houseChanges(batch: ChangeBatch, handle: string, written: Written): ChangeMapping;
|
|
17
13
|
export declare function houseMove(batch: ChangeBatch, source: string, destination: string): ChangeMapping;
|
|
18
14
|
export type OperationHead = {
|
|
19
15
|
readonly operation_id: string;
|
|
20
|
-
readonly room_ref: string;
|
|
21
16
|
readonly app_ref?: string;
|
|
22
17
|
readonly release?: string;
|
|
23
18
|
};
|
|
24
|
-
export declare function operationHead(batch: ChangeBatch
|
|
19
|
+
export declare function operationHead(batch: ChangeBatch): OperationHead;
|
|
25
20
|
export declare function batchPaths(changes: readonly HouseOperation[]): readonly string[];
|
|
26
21
|
export declare function deltaBody(changes: readonly HouseOperation[]): string;
|
|
27
22
|
export declare function deltaBytes(delta: string): number;
|
package/dist/write.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write.d.ts","sourceRoot":"","sources":["../src/write.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,WAAW,EAEhB,KAAK,aAAa,EAElB,KAAK,cAAc,
|
|
1
|
+
{"version":3,"file":"write.d.ts","sourceRoot":"","sources":["../src/write.ts"],"names":[],"mappings":"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"}
|
package/dist/write.js
CHANGED
|
@@ -1,18 +1,14 @@
|
|
|
1
|
-
import { departure,
|
|
2
|
-
import { answered, answering,
|
|
1
|
+
import { departure, isPart, ROW_WEIGHT, } from '@agentshouse/mdruntime';
|
|
2
|
+
import { answered, answering, attachmentOf, headChange, revised } from './read.js';
|
|
3
3
|
import { sha256Hex, textBytes } from './digest.js';
|
|
4
4
|
import { nativePath, roomLocalPath } from './map.js';
|
|
5
5
|
import { answeredFailure, classifyDoor, doorRefusal, resetOf, scopedRefusal } from './refusal.js';
|
|
6
6
|
import { readPosition, roomVersion } from './version.js';
|
|
7
7
|
import { unusable } from './uncertain.js';
|
|
8
|
-
function
|
|
9
|
-
return batch.preconditions.find((
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
return batch.preconditions.find((precondition) => precondition.kind === 'section' && precondition.path === path && precondition.name === name);
|
|
13
|
-
}
|
|
14
|
-
function priorPreamble(batch, path) {
|
|
15
|
-
return batch.preconditions.find((precondition) => precondition.kind === 'preamble' && precondition.path === path);
|
|
8
|
+
function priorPart(batch, change) {
|
|
9
|
+
return batch.preconditions.find((held) => held.kind === change.kind &&
|
|
10
|
+
held.path === change.path &&
|
|
11
|
+
(change.kind === 'preamble' || ('name' in held && held.name === change.name)));
|
|
16
12
|
}
|
|
17
13
|
function priorAbsence(batch, path) {
|
|
18
14
|
return batch.preconditions.find((precondition) => precondition.kind === 'absent' && precondition.path === path);
|
|
@@ -23,60 +19,30 @@ function priorExistence(batch, path) {
|
|
|
23
19
|
return undefined;
|
|
24
20
|
return precondition.kind === 'revision' ? { base: precondition.revision } : { kind: 'presence' };
|
|
25
21
|
}
|
|
26
|
-
function
|
|
27
|
-
if (
|
|
28
|
-
return {
|
|
29
|
-
|
|
30
|
-
|
|
22
|
+
function textOf(batch, change, path, document) {
|
|
23
|
+
if (isPart(change) && priorPart(batch, change) === undefined)
|
|
24
|
+
return { rule: 'precondition-missing' };
|
|
25
|
+
if (change.kind === 'create' && priorAbsence(batch, change.path) === undefined)
|
|
26
|
+
return { rule: 'precondition-missing' };
|
|
27
|
+
if (change.kind === 'replace' && priorExistence(batch, change.path) === undefined)
|
|
28
|
+
return { rule: 'precondition-missing' };
|
|
29
|
+
if (document === null || document === undefined)
|
|
31
30
|
return null;
|
|
32
|
-
|
|
31
|
+
if (document.stale)
|
|
32
|
+
return { rule: 'precondition-stale' };
|
|
33
|
+
if (document.created)
|
|
34
|
+
return { operation: { op: 'write', path, content: document.content } };
|
|
35
|
+
if (document.base === null)
|
|
36
|
+
return { rule: 'presence-base-unrepresentable' };
|
|
37
|
+
return { operation: { op: 'write', path, base: document.base, content: document.content } };
|
|
33
38
|
}
|
|
34
|
-
function operationOf(batch,
|
|
39
|
+
function operationOf(batch, index, handle, written) {
|
|
40
|
+
const change = batch.changes[index];
|
|
35
41
|
const path = nativePath(change.path, handle);
|
|
36
|
-
if (change.kind === '
|
|
37
|
-
|
|
38
|
-
if (prior === undefined)
|
|
39
|
-
return { rule: 'precondition-missing' };
|
|
40
|
-
return {
|
|
41
|
-
operation: {
|
|
42
|
-
op: 'set_field',
|
|
43
|
-
path,
|
|
44
|
-
field: change.name,
|
|
45
|
-
value: change.value,
|
|
46
|
-
...(prior.value === undefined ? {} : { base: prior.value }),
|
|
47
|
-
},
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
if (change.kind === 'section') {
|
|
51
|
-
const prior = priorSection(batch, change.path, change.name);
|
|
52
|
-
if (prior === undefined)
|
|
53
|
-
return { rule: 'precondition-missing' };
|
|
54
|
-
return {
|
|
55
|
-
operation: {
|
|
56
|
-
op: 'replace_section',
|
|
57
|
-
path,
|
|
58
|
-
section: change.name,
|
|
59
|
-
base: prior.value,
|
|
60
|
-
content: change.value,
|
|
61
|
-
},
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
if (change.kind === 'preamble') {
|
|
65
|
-
const prior = priorPreamble(batch, change.path);
|
|
66
|
-
if (prior === undefined)
|
|
67
|
-
return { rule: 'precondition-missing' };
|
|
68
|
-
return {
|
|
69
|
-
operation: { op: 'replace_preamble', path, base: prior.value, content: change.value },
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
if (change.kind === 'create') {
|
|
73
|
-
if (priorAbsence(batch, change.path) === undefined)
|
|
74
|
-
return { rule: 'precondition-missing' };
|
|
75
|
-
const operation = created(change, path);
|
|
76
|
-
return operation === null ? { rule: 'type-missing' } : { operation };
|
|
77
|
-
}
|
|
42
|
+
if (isPart(change) || change.kind === 'create' || change.kind === 'replace')
|
|
43
|
+
return textOf(batch, change, path, written[index]);
|
|
78
44
|
if (change.kind === 'binary') {
|
|
79
|
-
const
|
|
45
|
+
const uploaded = {
|
|
80
46
|
op: 'upload',
|
|
81
47
|
path,
|
|
82
48
|
local_id: change.localId,
|
|
@@ -84,45 +50,61 @@ function operationOf(batch, change, handle) {
|
|
|
84
50
|
sha256: change.sha256,
|
|
85
51
|
media_type: change.mediaType,
|
|
86
52
|
};
|
|
87
|
-
const from = departure(batch.changes,
|
|
53
|
+
const from = departure(batch.changes, index);
|
|
88
54
|
if (from === change.path && priorAbsence(batch, change.path) !== undefined)
|
|
89
|
-
return { operation:
|
|
55
|
+
return { operation: uploaded };
|
|
90
56
|
const replaced = priorExistence(batch, from);
|
|
91
57
|
if (replaced === undefined)
|
|
92
58
|
return { rule: 'precondition-missing' };
|
|
93
59
|
if (!('base' in replaced))
|
|
94
60
|
return { rule: 'presence-base-unrepresentable' };
|
|
95
|
-
return { operation: { ...
|
|
61
|
+
return { operation: { ...uploaded, base: replaced.base } };
|
|
96
62
|
}
|
|
97
63
|
const existence = priorExistence(batch, change.path);
|
|
98
64
|
if (existence === undefined)
|
|
99
65
|
return { rule: 'precondition-missing' };
|
|
100
66
|
if (!('base' in existence))
|
|
101
67
|
return { rule: 'presence-base-unrepresentable' };
|
|
102
|
-
if (change.kind === 'replace') {
|
|
103
|
-
return { operation: { op: 'replace', path, base: existence.base, content: change.content } };
|
|
104
|
-
}
|
|
105
68
|
if (change.kind === 'move') {
|
|
106
69
|
if (priorAbsence(batch, change.to) === undefined)
|
|
107
70
|
return { rule: 'precondition-missing' };
|
|
108
71
|
return {
|
|
109
|
-
operation: { op: '
|
|
72
|
+
operation: { op: 'move', path, to: nativePath(change.to, handle), base: existence.base },
|
|
110
73
|
};
|
|
111
74
|
}
|
|
112
|
-
return { operation: { op: '
|
|
75
|
+
return { operation: { op: 'delete', path, base: existence.base } };
|
|
113
76
|
}
|
|
114
|
-
export function houseChanges(batch, handle) {
|
|
77
|
+
export function houseChanges(batch, handle, written) {
|
|
115
78
|
const changes = [];
|
|
116
|
-
|
|
117
|
-
|
|
79
|
+
const moves = new Map();
|
|
80
|
+
const before = new Map();
|
|
81
|
+
for (const [index, change] of batch.changes.entries()) {
|
|
82
|
+
const mapped = operationOf(batch, index, handle, written);
|
|
83
|
+
if (mapped === null)
|
|
84
|
+
continue;
|
|
118
85
|
if ('rule' in mapped)
|
|
119
86
|
return { kind: 'unmapped', path: change.path, rule: mapped.rule };
|
|
120
|
-
|
|
87
|
+
const { operation } = mapped;
|
|
88
|
+
const from = departure(batch.changes, index);
|
|
89
|
+
if (change.kind === 'move' && !moves.has(from))
|
|
90
|
+
moves.set(from, changes.length);
|
|
91
|
+
const moved = moves.get(from);
|
|
92
|
+
if (change.kind !== 'move' &&
|
|
93
|
+
moved !== undefined &&
|
|
94
|
+
operation.op === 'write' &&
|
|
95
|
+
'base' in operation) {
|
|
96
|
+
before.set(moved, { ...operation, path: nativePath(from, handle) });
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
changes.push(operation);
|
|
121
100
|
}
|
|
122
|
-
return {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
101
|
+
return {
|
|
102
|
+
kind: 'changes',
|
|
103
|
+
changes: changes.flatMap((operation, at) => {
|
|
104
|
+
const written = before.get(at);
|
|
105
|
+
return written === undefined ? [operation] : [written, operation];
|
|
106
|
+
}),
|
|
107
|
+
};
|
|
126
108
|
}
|
|
127
109
|
export function houseMove(batch, source, destination) {
|
|
128
110
|
const changes = [];
|
|
@@ -134,7 +116,7 @@ export function houseMove(batch, source, destination) {
|
|
|
134
116
|
return { kind: 'unmapped', path, rule: 'presence-base-unrepresentable' };
|
|
135
117
|
}
|
|
136
118
|
changes.push({
|
|
137
|
-
op: '
|
|
119
|
+
op: 'move',
|
|
138
120
|
path: nativePath(path, source),
|
|
139
121
|
to: nativePath(to, destination),
|
|
140
122
|
base: existence.base,
|
|
@@ -142,14 +124,14 @@ export function houseMove(batch, source, destination) {
|
|
|
142
124
|
}
|
|
143
125
|
return { kind: 'changes', changes };
|
|
144
126
|
}
|
|
145
|
-
export function operationHead(batch
|
|
127
|
+
export function operationHead(batch) {
|
|
146
128
|
const writer = batch.writtenBy;
|
|
147
|
-
const head = { operation_id: batch.id
|
|
129
|
+
const head = { operation_id: batch.id };
|
|
148
130
|
return writer === undefined ? head : { ...head, app_ref: writer.app, release: writer.release };
|
|
149
131
|
}
|
|
150
132
|
export function batchPaths(changes) {
|
|
151
133
|
return [
|
|
152
|
-
...new Set(changes.flatMap((change) => change.op === '
|
|
134
|
+
...new Set(changes.flatMap((change) => change.op === 'move' ? [String(change.path), String(change.to)] : [String(change.path)])),
|
|
153
135
|
];
|
|
154
136
|
}
|
|
155
137
|
export function deltaBody(changes) {
|
|
@@ -182,7 +164,7 @@ function* material(value, handle, within = () => true) {
|
|
|
182
164
|
return null;
|
|
183
165
|
if (file.revision !== null && file.revision !== undefined && typeof file.revision !== 'string')
|
|
184
166
|
return null;
|
|
185
|
-
const binary =
|
|
167
|
+
const binary = attachmentOf(file);
|
|
186
168
|
if (binary === null)
|
|
187
169
|
return null;
|
|
188
170
|
const head = headChange(file);
|
|
@@ -225,14 +207,14 @@ function* acceptedOf(at, contents) {
|
|
|
225
207
|
if (entry.content !== null)
|
|
226
208
|
answer.documents.set(entry.path, entry.content);
|
|
227
209
|
if (entry.binary !== undefined)
|
|
228
|
-
answer.
|
|
210
|
+
answer.attachments.set(entry.path, entry.binary);
|
|
229
211
|
revised(answer, entry.path, entry.revision);
|
|
230
212
|
if (entry.head !== undefined)
|
|
231
213
|
answer.changes.set(entry.path, entry.head);
|
|
232
214
|
}
|
|
233
|
-
const unbinaried = answer.
|
|
234
|
-
const {
|
|
235
|
-
return { roomVersion: roomVersion(at), ...room, ...(unbinaried ? {} : {
|
|
215
|
+
const unbinaried = answer.attachments.size === 0;
|
|
216
|
+
const { attachments, facts: _facts, ...room } = yield* answered(answer);
|
|
217
|
+
return { roomVersion: roomVersion(at), ...room, ...(unbinaried ? {} : { attachments }) };
|
|
236
218
|
}
|
|
237
219
|
function* movedOutcome(held, move) {
|
|
238
220
|
const authorities = Array.isArray(held.authorities) ? held.authorities : [];
|
|
@@ -373,12 +355,10 @@ export function historyOutcome(status, body, locator, request) {
|
|
|
373
355
|
return unusable();
|
|
374
356
|
entries.push(entry);
|
|
375
357
|
}
|
|
376
|
-
|
|
377
|
-
|
|
358
|
+
const named = entries[0];
|
|
359
|
+
if (request.revision !== undefined && typeof named?.media_type !== 'string') {
|
|
378
360
|
if (named === undefined)
|
|
379
361
|
return { kind: 'no-history' };
|
|
380
|
-
if (typeof named.media_type === 'string')
|
|
381
|
-
return { kind: 'no-history' };
|
|
382
362
|
if (typeof named.content !== 'string')
|
|
383
363
|
return unusable();
|
|
384
364
|
return { kind: 'revision', content: named.content };
|
|
@@ -393,14 +373,14 @@ export function historyOutcome(status, body, locator, request) {
|
|
|
393
373
|
typeof entry.created_at !== 'string') {
|
|
394
374
|
return unusable();
|
|
395
375
|
}
|
|
396
|
-
const
|
|
397
|
-
if (
|
|
376
|
+
const attachment = attachmentOf(entry);
|
|
377
|
+
if (attachment === null)
|
|
398
378
|
return unusable();
|
|
399
379
|
revisions.push({
|
|
400
380
|
revision: entry.revision,
|
|
401
381
|
author,
|
|
402
382
|
time: entry.created_at,
|
|
403
|
-
...(
|
|
383
|
+
...(attachment === undefined ? {} : { attachment }),
|
|
404
384
|
});
|
|
405
385
|
}
|
|
406
386
|
const next = held.next_before;
|
package/package.json
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentshouse/mdruntime-adapter",
|
|
3
|
-
"version": "0.1.0-ca47c2e51c195",
|
|
4
3
|
"description": "Agents House Adapter for the MD Runtime",
|
|
5
4
|
"license": "MIT",
|
|
6
5
|
"type": "module",
|
|
@@ -24,12 +23,13 @@
|
|
|
24
23
|
"LICENSE"
|
|
25
24
|
],
|
|
26
25
|
"dependencies": {
|
|
27
|
-
"@agentshouse/mdmodel": "0.1.0-
|
|
28
|
-
"@agentshouse/mdruntime": "0.1.0-
|
|
26
|
+
"@agentshouse/mdmodel": "0.1.0-ccb5d0a28eae3",
|
|
27
|
+
"@agentshouse/mdruntime": "0.1.0-c1107a5a4f7d8"
|
|
29
28
|
},
|
|
30
29
|
"repository": {
|
|
31
30
|
"type": "git",
|
|
32
31
|
"url": "git+https://github.com/agentshouse/core.git",
|
|
33
32
|
"directory": "mdruntime/packages/mdruntime-adapter"
|
|
34
|
-
}
|
|
33
|
+
},
|
|
34
|
+
"version": "0.1.0-ca5b5175ac20a"
|
|
35
35
|
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export declare const OUTPUT_LINES = 20;
|
|
2
|
-
export declare const OUTPUT_CHARACTERS = 4000;
|
|
3
|
-
export declare const DIFF_CHARACTERS = 10000;
|
|
4
|
-
export declare const FIRST_PART_CHARACTERS = 2000;
|
|
5
|
-
export declare function lastLines(output: string): string;
|
|
6
|
-
export declare function firstPart(result: string): string;
|
|
7
|
-
export declare function keptDiff(diff: string): string | null;
|