@knpkv/herdr-connect 0.4.1 → 0.4.2
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/internal/terminal-lines.d.ts +16 -0
- package/dist/internal/terminal-lines.d.ts.map +1 -0
- package/dist/internal/terminal-lines.js +70 -0
- package/dist/internal/terminal-lines.js.map +1 -0
- package/dist/terminal.d.ts +119 -120
- package/dist/terminal.d.ts.map +1 -1
- package/dist/terminal.js +8 -67
- package/dist/terminal.js.map +1 -1
- package/package.json +3 -2
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Splits the Herdr attach client's stdout into lines, each capped at
|
|
3
|
+
* {@link terminalEventMaxLineBytes}.
|
|
4
|
+
*
|
|
5
|
+
* This caps each line, not the stream's running total, so it is not a
|
|
6
|
+
* `@knpkv/bounded-io` budget: a long session may emit any number of lines.
|
|
7
|
+
* The buffer grows geometrically and is reused, keeping copies linear.
|
|
8
|
+
*
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
import { Stream } from "effect";
|
|
12
|
+
import { TerminalProtocolError } from "../errors.js";
|
|
13
|
+
export declare const terminalEventMaxLineBytes: number;
|
|
14
|
+
/** @internal Exposes copied-byte accounting only for the deterministic complexity regression. */
|
|
15
|
+
export declare const boundedTerminalLines: <E, R>(stream: Stream.Stream<Uint8Array, E, R>, onBufferCopy?: (bytes: number) => void) => Stream.Stream<string, E | TerminalProtocolError, R>;
|
|
16
|
+
//# sourceMappingURL=terminal-lines.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terminal-lines.d.ts","sourceRoot":"","sources":["../../src/internal/terminal-lines.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAU,MAAM,EAAE,MAAM,QAAQ,CAAA;AACvC,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAA;AAEpD,eAAO,MAAM,yBAAyB,QAA6B,CAAA;AAmCnE,iGAAiG;AACjG,eAAO,MAAM,oBAAoB,GAAI,CAAC,EAAE,CAAC,UAC/B,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC,EAAE,CAAC,CAAC,iBACxB,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,wDA2CrC,CAAA"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Splits the Herdr attach client's stdout into lines, each capped at
|
|
3
|
+
* {@link terminalEventMaxLineBytes}.
|
|
4
|
+
*
|
|
5
|
+
* This caps each line, not the stream's running total, so it is not a
|
|
6
|
+
* `@knpkv/bounded-io` budget: a long session may emit any number of lines.
|
|
7
|
+
* The buffer grows geometrically and is reused, keeping copies linear.
|
|
8
|
+
*
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
import { Effect, Stream } from "effect";
|
|
12
|
+
import { TerminalProtocolError } from "../errors.js";
|
|
13
|
+
export const terminalEventMaxLineBytes = 4 * 1024 * 1024 + 4 * 1024;
|
|
14
|
+
const terminalLineInitialBytes = 64 * 1_024;
|
|
15
|
+
const emptyTerminalLine = () => ({
|
|
16
|
+
buffer: new Uint8Array(terminalLineInitialBytes),
|
|
17
|
+
length: 0
|
|
18
|
+
});
|
|
19
|
+
const decodeTerminalLine = (bytes) => {
|
|
20
|
+
const content = bytes.at(-1) === 13 ? bytes.subarray(0, -1) : bytes;
|
|
21
|
+
return new TextDecoder().decode(content);
|
|
22
|
+
};
|
|
23
|
+
const growTerminalLineBuffer = (buffer, requiredBytes, onBufferCopy) => {
|
|
24
|
+
if (requiredBytes <= buffer.byteLength)
|
|
25
|
+
return buffer;
|
|
26
|
+
let capacity = buffer.byteLength;
|
|
27
|
+
while (capacity < requiredBytes) {
|
|
28
|
+
capacity = Math.min(capacity * 2, terminalEventMaxLineBytes);
|
|
29
|
+
}
|
|
30
|
+
const grown = new Uint8Array(capacity);
|
|
31
|
+
onBufferCopy?.(buffer.byteLength);
|
|
32
|
+
grown.set(buffer);
|
|
33
|
+
return grown;
|
|
34
|
+
};
|
|
35
|
+
/** @internal Exposes copied-byte accounting only for the deterministic complexity regression. */
|
|
36
|
+
export const boundedTerminalLines = (stream, onBufferCopy) => stream.pipe(Stream.mapAccumEffect(emptyTerminalLine, (state, chunk) => {
|
|
37
|
+
let buffer = state.buffer;
|
|
38
|
+
let length = state.length;
|
|
39
|
+
const lines = [];
|
|
40
|
+
let offset = 0;
|
|
41
|
+
while (offset < chunk.byteLength) {
|
|
42
|
+
const newline = chunk.indexOf(10, offset);
|
|
43
|
+
const end = newline === -1 ? chunk.byteLength : newline;
|
|
44
|
+
const nextLength = length + end - offset;
|
|
45
|
+
if (nextLength > terminalEventMaxLineBytes) {
|
|
46
|
+
return Effect.fail(new TerminalProtocolError({
|
|
47
|
+
cause: nextLength,
|
|
48
|
+
detail: `Herdr terminal event exceeded ${terminalEventMaxLineBytes} bytes`
|
|
49
|
+
}));
|
|
50
|
+
}
|
|
51
|
+
buffer = growTerminalLineBuffer(buffer, nextLength, onBufferCopy);
|
|
52
|
+
buffer.set(chunk.subarray(offset, end), length);
|
|
53
|
+
length = nextLength;
|
|
54
|
+
if (newline === -1)
|
|
55
|
+
break;
|
|
56
|
+
lines.push(decodeTerminalLine(buffer.subarray(0, length)));
|
|
57
|
+
length = 0;
|
|
58
|
+
offset = newline + 1;
|
|
59
|
+
}
|
|
60
|
+
const result = [
|
|
61
|
+
{ buffer, length },
|
|
62
|
+
lines
|
|
63
|
+
];
|
|
64
|
+
return Effect.succeed(result);
|
|
65
|
+
}, {
|
|
66
|
+
onHalt: (state) => state.length === 0
|
|
67
|
+
? []
|
|
68
|
+
: [decodeTerminalLine(state.buffer.subarray(0, state.length))]
|
|
69
|
+
}));
|
|
70
|
+
//# sourceMappingURL=terminal-lines.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terminal-lines.js","sourceRoot":"","sources":["../../src/internal/terminal-lines.ts"],"names":[],"mappings":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AAM,CAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAA;QAC1D,MAAM,GAAG,CAAC,CAAA;QACV,MAAM,GAAG,OAAO,GAAG,CAAC,CAAA;IACtB,CAAC;IACD,MAAM,MAAM,GAAwD;QAClE,EAAE,MAAM,EAAE,MAAM,EAAE;QAClB,KAAK;KACN,CAAA;IACD,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;AAC/B,CAAC,EACD;IACE,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAChB,KAAK,CAAC,MAAM,KAAK,CAAC;QAChB,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC,CAAC,kBAAkB,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;CACnE,CACF,CACF,CAAA"}
|
package/dist/terminal.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { Scope } from "effect";
|
|
|
2
2
|
import { Crypto, Effect, Stream } from "effect";
|
|
3
3
|
import { ChildProcessSpawner } from "effect/process";
|
|
4
4
|
import { TerminalAgentNotFoundError, TerminalProtocolError, TerminalTransportError } from "./errors.js";
|
|
5
|
+
import { boundedTerminalLines, terminalEventMaxLineBytes } from "./internal/terminal-lines.js";
|
|
5
6
|
import { HerdrTerminalEvent, type TerminalClientCommand, type TerminalSelection } from "./model.js";
|
|
6
7
|
export type TerminalError = TerminalAgentNotFoundError | TerminalProtocolError | TerminalTransportError;
|
|
7
8
|
export interface TerminalSession {
|
|
@@ -12,9 +13,7 @@ export interface TerminalConnector {
|
|
|
12
13
|
readonly open: (selection: TerminalSelection) => Effect.Effect<TerminalSession, TerminalError, Scope.Scope>;
|
|
13
14
|
}
|
|
14
15
|
export declare const terminalStderrMaxBytes: number;
|
|
15
|
-
export
|
|
16
|
-
/** @internal Exposes copied-byte accounting only for the deterministic complexity regression. */
|
|
17
|
-
export declare const boundedTerminalLines: <E, R>(stream: Stream.Stream<Uint8Array, E, R>, onBufferCopy?: (bytes: number) => void) => Stream.Stream<string, E | TerminalProtocolError, R>;
|
|
16
|
+
export { boundedTerminalLines, terminalEventMaxLineBytes };
|
|
18
17
|
export declare const makeHerdrTerminalConnector: (config: {
|
|
19
18
|
readonly host: string;
|
|
20
19
|
readonly repository: string;
|
|
@@ -56,11 +55,20 @@ export declare const makeHerdrTerminalConnector: (config: {
|
|
|
56
55
|
}, service: {
|
|
57
56
|
submit: (request: {
|
|
58
57
|
readonly payload: {
|
|
58
|
+
readonly kind: "nix.check";
|
|
59
|
+
} | {
|
|
60
|
+
readonly kind: "nix.apply";
|
|
61
|
+
readonly ref: string;
|
|
62
|
+
} | {
|
|
59
63
|
readonly kind: "agent.delegate";
|
|
60
64
|
readonly repository: string;
|
|
61
65
|
readonly prompt: string;
|
|
62
66
|
readonly mode: "consult" | "review" | "transition_summary" | "work";
|
|
63
67
|
readonly channel?: "coordinator_chat";
|
|
68
|
+
} | {
|
|
69
|
+
readonly kind: "agent.message";
|
|
70
|
+
readonly session: string;
|
|
71
|
+
readonly message: string;
|
|
64
72
|
} | {
|
|
65
73
|
readonly kind: "work.reconcile";
|
|
66
74
|
readonly repository: string;
|
|
@@ -187,15 +195,6 @@ export declare const makeHerdrTerminalConnector: (config: {
|
|
|
187
195
|
readonly expectedGoalUpdatedAt: number;
|
|
188
196
|
} | {
|
|
189
197
|
readonly kind: "browser.mcp.recover";
|
|
190
|
-
} | {
|
|
191
|
-
readonly kind: "nix.check";
|
|
192
|
-
} | {
|
|
193
|
-
readonly kind: "nix.apply";
|
|
194
|
-
readonly ref: string;
|
|
195
|
-
} | {
|
|
196
|
-
readonly kind: "agent.message";
|
|
197
|
-
readonly session: string;
|
|
198
|
-
readonly message: string;
|
|
199
198
|
};
|
|
200
199
|
}, actor: string, provenance?: import("@knpkv/herdr-fleet").SubmissionProvenance | undefined) => Effect.Effect<{
|
|
201
200
|
readonly id: string;
|
|
@@ -212,11 +211,20 @@ export declare const makeHerdrTerminalConnector: (config: {
|
|
|
212
211
|
readonly expiredAt?: number | null;
|
|
213
212
|
readonly status: "expired" | "failed" | "interrupted" | "pending_approval" | "queued" | "rejected" | "running" | "succeeded";
|
|
214
213
|
readonly payload: {
|
|
214
|
+
readonly kind: "nix.check";
|
|
215
|
+
} | {
|
|
216
|
+
readonly kind: "nix.apply";
|
|
217
|
+
readonly ref: string;
|
|
218
|
+
} | {
|
|
215
219
|
readonly kind: "agent.delegate";
|
|
216
220
|
readonly repository: string;
|
|
217
221
|
readonly prompt: string;
|
|
218
222
|
readonly mode: "consult" | "review" | "transition_summary" | "work";
|
|
219
223
|
readonly channel?: "coordinator_chat";
|
|
224
|
+
} | {
|
|
225
|
+
readonly kind: "agent.message";
|
|
226
|
+
readonly session: string;
|
|
227
|
+
readonly message: string;
|
|
220
228
|
} | {
|
|
221
229
|
readonly kind: "work.reconcile";
|
|
222
230
|
readonly repository: string;
|
|
@@ -343,15 +351,6 @@ export declare const makeHerdrTerminalConnector: (config: {
|
|
|
343
351
|
readonly expectedGoalUpdatedAt: number;
|
|
344
352
|
} | {
|
|
345
353
|
readonly kind: "browser.mcp.recover";
|
|
346
|
-
} | {
|
|
347
|
-
readonly kind: "nix.check";
|
|
348
|
-
} | {
|
|
349
|
-
readonly kind: "nix.apply";
|
|
350
|
-
readonly ref: string;
|
|
351
|
-
} | {
|
|
352
|
-
readonly kind: "agent.message";
|
|
353
|
-
readonly session: string;
|
|
354
|
-
readonly message: string;
|
|
355
354
|
};
|
|
356
355
|
readonly result: string | null;
|
|
357
356
|
readonly acceptedReceipt?: string | null;
|
|
@@ -389,11 +388,20 @@ export declare const makeHerdrTerminalConnector: (config: {
|
|
|
389
388
|
readonly expiredAt?: number | null;
|
|
390
389
|
readonly status: "expired" | "failed" | "interrupted" | "pending_approval" | "queued" | "rejected" | "running" | "succeeded";
|
|
391
390
|
readonly payload: {
|
|
391
|
+
readonly kind: "nix.check";
|
|
392
|
+
} | {
|
|
393
|
+
readonly kind: "nix.apply";
|
|
394
|
+
readonly ref: string;
|
|
395
|
+
} | {
|
|
392
396
|
readonly kind: "agent.delegate";
|
|
393
397
|
readonly repository: string;
|
|
394
398
|
readonly prompt: string;
|
|
395
399
|
readonly mode: "consult" | "review" | "transition_summary" | "work";
|
|
396
400
|
readonly channel?: "coordinator_chat";
|
|
401
|
+
} | {
|
|
402
|
+
readonly kind: "agent.message";
|
|
403
|
+
readonly session: string;
|
|
404
|
+
readonly message: string;
|
|
397
405
|
} | {
|
|
398
406
|
readonly kind: "work.reconcile";
|
|
399
407
|
readonly repository: string;
|
|
@@ -520,15 +528,6 @@ export declare const makeHerdrTerminalConnector: (config: {
|
|
|
520
528
|
readonly expectedGoalUpdatedAt: number;
|
|
521
529
|
} | {
|
|
522
530
|
readonly kind: "browser.mcp.recover";
|
|
523
|
-
} | {
|
|
524
|
-
readonly kind: "nix.check";
|
|
525
|
-
} | {
|
|
526
|
-
readonly kind: "nix.apply";
|
|
527
|
-
readonly ref: string;
|
|
528
|
-
} | {
|
|
529
|
-
readonly kind: "agent.message";
|
|
530
|
-
readonly session: string;
|
|
531
|
-
readonly message: string;
|
|
532
531
|
};
|
|
533
532
|
readonly result: string | null;
|
|
534
533
|
readonly acceptedReceipt?: string | null;
|
|
@@ -566,11 +565,20 @@ export declare const makeHerdrTerminalConnector: (config: {
|
|
|
566
565
|
readonly expiredAt?: number | null;
|
|
567
566
|
readonly status: "expired" | "failed" | "interrupted" | "pending_approval" | "queued" | "rejected" | "running" | "succeeded";
|
|
568
567
|
readonly payload: {
|
|
568
|
+
readonly kind: "nix.check";
|
|
569
|
+
} | {
|
|
570
|
+
readonly kind: "nix.apply";
|
|
571
|
+
readonly ref: string;
|
|
572
|
+
} | {
|
|
569
573
|
readonly kind: "agent.delegate";
|
|
570
574
|
readonly repository: string;
|
|
571
575
|
readonly prompt: string;
|
|
572
576
|
readonly mode: "consult" | "review" | "transition_summary" | "work";
|
|
573
577
|
readonly channel?: "coordinator_chat";
|
|
578
|
+
} | {
|
|
579
|
+
readonly kind: "agent.message";
|
|
580
|
+
readonly session: string;
|
|
581
|
+
readonly message: string;
|
|
574
582
|
} | {
|
|
575
583
|
readonly kind: "work.reconcile";
|
|
576
584
|
readonly repository: string;
|
|
@@ -697,15 +705,6 @@ export declare const makeHerdrTerminalConnector: (config: {
|
|
|
697
705
|
readonly expectedGoalUpdatedAt: number;
|
|
698
706
|
} | {
|
|
699
707
|
readonly kind: "browser.mcp.recover";
|
|
700
|
-
} | {
|
|
701
|
-
readonly kind: "nix.check";
|
|
702
|
-
} | {
|
|
703
|
-
readonly kind: "nix.apply";
|
|
704
|
-
readonly ref: string;
|
|
705
|
-
} | {
|
|
706
|
-
readonly kind: "agent.message";
|
|
707
|
-
readonly session: string;
|
|
708
|
-
readonly message: string;
|
|
709
708
|
};
|
|
710
709
|
readonly result: string | null;
|
|
711
710
|
readonly acceptedReceipt?: string | null;
|
|
@@ -743,11 +742,20 @@ export declare const makeHerdrTerminalConnector: (config: {
|
|
|
743
742
|
readonly expiredAt?: number | null;
|
|
744
743
|
readonly status: "expired" | "failed" | "interrupted" | "pending_approval" | "queued" | "rejected" | "running" | "succeeded";
|
|
745
744
|
readonly payload: {
|
|
745
|
+
readonly kind: "nix.check";
|
|
746
|
+
} | {
|
|
747
|
+
readonly kind: "nix.apply";
|
|
748
|
+
readonly ref: string;
|
|
749
|
+
} | {
|
|
746
750
|
readonly kind: "agent.delegate";
|
|
747
751
|
readonly repository: string;
|
|
748
752
|
readonly prompt: string;
|
|
749
753
|
readonly mode: "consult" | "review" | "transition_summary" | "work";
|
|
750
754
|
readonly channel?: "coordinator_chat";
|
|
755
|
+
} | {
|
|
756
|
+
readonly kind: "agent.message";
|
|
757
|
+
readonly session: string;
|
|
758
|
+
readonly message: string;
|
|
751
759
|
} | {
|
|
752
760
|
readonly kind: "work.reconcile";
|
|
753
761
|
readonly repository: string;
|
|
@@ -874,15 +882,6 @@ export declare const makeHerdrTerminalConnector: (config: {
|
|
|
874
882
|
readonly expectedGoalUpdatedAt: number;
|
|
875
883
|
} | {
|
|
876
884
|
readonly kind: "browser.mcp.recover";
|
|
877
|
-
} | {
|
|
878
|
-
readonly kind: "nix.check";
|
|
879
|
-
} | {
|
|
880
|
-
readonly kind: "nix.apply";
|
|
881
|
-
readonly ref: string;
|
|
882
|
-
} | {
|
|
883
|
-
readonly kind: "agent.message";
|
|
884
|
-
readonly session: string;
|
|
885
|
-
readonly message: string;
|
|
886
885
|
};
|
|
887
886
|
readonly result: string | null;
|
|
888
887
|
readonly acceptedReceipt?: string | null;
|
|
@@ -920,11 +919,20 @@ export declare const makeHerdrTerminalConnector: (config: {
|
|
|
920
919
|
readonly expiredAt?: number | null;
|
|
921
920
|
readonly status: "expired" | "failed" | "interrupted" | "pending_approval" | "queued" | "rejected" | "running" | "succeeded";
|
|
922
921
|
readonly payload: {
|
|
922
|
+
readonly kind: "nix.check";
|
|
923
|
+
} | {
|
|
924
|
+
readonly kind: "nix.apply";
|
|
925
|
+
readonly ref: string;
|
|
926
|
+
} | {
|
|
923
927
|
readonly kind: "agent.delegate";
|
|
924
928
|
readonly repository: string;
|
|
925
929
|
readonly prompt: string;
|
|
926
930
|
readonly mode: "consult" | "review" | "transition_summary" | "work";
|
|
927
931
|
readonly channel?: "coordinator_chat";
|
|
932
|
+
} | {
|
|
933
|
+
readonly kind: "agent.message";
|
|
934
|
+
readonly session: string;
|
|
935
|
+
readonly message: string;
|
|
928
936
|
} | {
|
|
929
937
|
readonly kind: "work.reconcile";
|
|
930
938
|
readonly repository: string;
|
|
@@ -1051,15 +1059,6 @@ export declare const makeHerdrTerminalConnector: (config: {
|
|
|
1051
1059
|
readonly expectedGoalUpdatedAt: number;
|
|
1052
1060
|
} | {
|
|
1053
1061
|
readonly kind: "browser.mcp.recover";
|
|
1054
|
-
} | {
|
|
1055
|
-
readonly kind: "nix.check";
|
|
1056
|
-
} | {
|
|
1057
|
-
readonly kind: "nix.apply";
|
|
1058
|
-
readonly ref: string;
|
|
1059
|
-
} | {
|
|
1060
|
-
readonly kind: "agent.message";
|
|
1061
|
-
readonly session: string;
|
|
1062
|
-
readonly message: string;
|
|
1063
1062
|
};
|
|
1064
1063
|
readonly result: string | null;
|
|
1065
1064
|
readonly acceptedReceipt?: string | null;
|
|
@@ -1097,11 +1096,20 @@ export declare const makeHerdrTerminalConnector: (config: {
|
|
|
1097
1096
|
readonly expiredAt?: number | null;
|
|
1098
1097
|
readonly status: "expired" | "failed" | "interrupted" | "pending_approval" | "queued" | "rejected" | "running" | "succeeded";
|
|
1099
1098
|
readonly payload: {
|
|
1099
|
+
readonly kind: "nix.check";
|
|
1100
|
+
} | {
|
|
1101
|
+
readonly kind: "nix.apply";
|
|
1102
|
+
readonly ref: string;
|
|
1103
|
+
} | {
|
|
1100
1104
|
readonly kind: "agent.delegate";
|
|
1101
1105
|
readonly repository: string;
|
|
1102
1106
|
readonly prompt: string;
|
|
1103
1107
|
readonly mode: "consult" | "review" | "transition_summary" | "work";
|
|
1104
1108
|
readonly channel?: "coordinator_chat";
|
|
1109
|
+
} | {
|
|
1110
|
+
readonly kind: "agent.message";
|
|
1111
|
+
readonly session: string;
|
|
1112
|
+
readonly message: string;
|
|
1105
1113
|
} | {
|
|
1106
1114
|
readonly kind: "work.reconcile";
|
|
1107
1115
|
readonly repository: string;
|
|
@@ -1228,15 +1236,6 @@ export declare const makeHerdrTerminalConnector: (config: {
|
|
|
1228
1236
|
readonly expectedGoalUpdatedAt: number;
|
|
1229
1237
|
} | {
|
|
1230
1238
|
readonly kind: "browser.mcp.recover";
|
|
1231
|
-
} | {
|
|
1232
|
-
readonly kind: "nix.check";
|
|
1233
|
-
} | {
|
|
1234
|
-
readonly kind: "nix.apply";
|
|
1235
|
-
readonly ref: string;
|
|
1236
|
-
} | {
|
|
1237
|
-
readonly kind: "agent.message";
|
|
1238
|
-
readonly session: string;
|
|
1239
|
-
readonly message: string;
|
|
1240
1239
|
};
|
|
1241
1240
|
readonly result: string | null;
|
|
1242
1241
|
readonly acceptedReceipt?: string | null;
|
|
@@ -1274,11 +1273,20 @@ export declare const makeHerdrTerminalConnector: (config: {
|
|
|
1274
1273
|
readonly expiredAt?: number | null;
|
|
1275
1274
|
readonly status: "expired" | "failed" | "interrupted" | "pending_approval" | "queued" | "rejected" | "running" | "succeeded";
|
|
1276
1275
|
readonly payload: {
|
|
1276
|
+
readonly kind: "nix.check";
|
|
1277
|
+
} | {
|
|
1278
|
+
readonly kind: "nix.apply";
|
|
1279
|
+
readonly ref: string;
|
|
1280
|
+
} | {
|
|
1277
1281
|
readonly kind: "agent.delegate";
|
|
1278
1282
|
readonly repository: string;
|
|
1279
1283
|
readonly prompt: string;
|
|
1280
1284
|
readonly mode: "consult" | "review" | "transition_summary" | "work";
|
|
1281
1285
|
readonly channel?: "coordinator_chat";
|
|
1286
|
+
} | {
|
|
1287
|
+
readonly kind: "agent.message";
|
|
1288
|
+
readonly session: string;
|
|
1289
|
+
readonly message: string;
|
|
1282
1290
|
} | {
|
|
1283
1291
|
readonly kind: "work.reconcile";
|
|
1284
1292
|
readonly repository: string;
|
|
@@ -1405,15 +1413,6 @@ export declare const makeHerdrTerminalConnector: (config: {
|
|
|
1405
1413
|
readonly expectedGoalUpdatedAt: number;
|
|
1406
1414
|
} | {
|
|
1407
1415
|
readonly kind: "browser.mcp.recover";
|
|
1408
|
-
} | {
|
|
1409
|
-
readonly kind: "nix.check";
|
|
1410
|
-
} | {
|
|
1411
|
-
readonly kind: "nix.apply";
|
|
1412
|
-
readonly ref: string;
|
|
1413
|
-
} | {
|
|
1414
|
-
readonly kind: "agent.message";
|
|
1415
|
-
readonly session: string;
|
|
1416
|
-
readonly message: string;
|
|
1417
1416
|
};
|
|
1418
1417
|
readonly result: string | null;
|
|
1419
1418
|
readonly acceptedReceipt?: string | null;
|
|
@@ -1454,11 +1453,20 @@ export declare const makeHerdrTerminalConnector: (config: {
|
|
|
1454
1453
|
readonly expiredAt?: number | null;
|
|
1455
1454
|
readonly status: "expired" | "failed" | "interrupted" | "pending_approval" | "queued" | "rejected" | "running" | "succeeded";
|
|
1456
1455
|
readonly payload: {
|
|
1456
|
+
readonly kind: "nix.check";
|
|
1457
|
+
} | {
|
|
1458
|
+
readonly kind: "nix.apply";
|
|
1459
|
+
readonly ref: string;
|
|
1460
|
+
} | {
|
|
1457
1461
|
readonly kind: "agent.delegate";
|
|
1458
1462
|
readonly repository: string;
|
|
1459
1463
|
readonly prompt: string;
|
|
1460
1464
|
readonly mode: "consult" | "review" | "transition_summary" | "work";
|
|
1461
1465
|
readonly channel?: "coordinator_chat";
|
|
1466
|
+
} | {
|
|
1467
|
+
readonly kind: "agent.message";
|
|
1468
|
+
readonly session: string;
|
|
1469
|
+
readonly message: string;
|
|
1462
1470
|
} | {
|
|
1463
1471
|
readonly kind: "work.reconcile";
|
|
1464
1472
|
readonly repository: string;
|
|
@@ -1585,15 +1593,6 @@ export declare const makeHerdrTerminalConnector: (config: {
|
|
|
1585
1593
|
readonly expectedGoalUpdatedAt: number;
|
|
1586
1594
|
} | {
|
|
1587
1595
|
readonly kind: "browser.mcp.recover";
|
|
1588
|
-
} | {
|
|
1589
|
-
readonly kind: "nix.check";
|
|
1590
|
-
} | {
|
|
1591
|
-
readonly kind: "nix.apply";
|
|
1592
|
-
readonly ref: string;
|
|
1593
|
-
} | {
|
|
1594
|
-
readonly kind: "agent.message";
|
|
1595
|
-
readonly session: string;
|
|
1596
|
-
readonly message: string;
|
|
1597
1596
|
};
|
|
1598
1597
|
readonly result: string | null;
|
|
1599
1598
|
readonly acceptedReceipt?: string | null;
|
|
@@ -1635,11 +1634,20 @@ export declare const makeHerdrTerminalConnector: (config: {
|
|
|
1635
1634
|
readonly expiredAt?: number | null;
|
|
1636
1635
|
readonly status: "expired" | "failed" | "interrupted" | "pending_approval" | "queued" | "rejected" | "running" | "succeeded";
|
|
1637
1636
|
readonly payload: {
|
|
1637
|
+
readonly kind: "nix.check";
|
|
1638
|
+
} | {
|
|
1639
|
+
readonly kind: "nix.apply";
|
|
1640
|
+
readonly ref: string;
|
|
1641
|
+
} | {
|
|
1638
1642
|
readonly kind: "agent.delegate";
|
|
1639
1643
|
readonly repository: string;
|
|
1640
1644
|
readonly prompt: string;
|
|
1641
1645
|
readonly mode: "consult" | "review" | "transition_summary" | "work";
|
|
1642
1646
|
readonly channel?: "coordinator_chat";
|
|
1647
|
+
} | {
|
|
1648
|
+
readonly kind: "agent.message";
|
|
1649
|
+
readonly session: string;
|
|
1650
|
+
readonly message: string;
|
|
1643
1651
|
} | {
|
|
1644
1652
|
readonly kind: "work.reconcile";
|
|
1645
1653
|
readonly repository: string;
|
|
@@ -1766,15 +1774,6 @@ export declare const makeHerdrTerminalConnector: (config: {
|
|
|
1766
1774
|
readonly expectedGoalUpdatedAt: number;
|
|
1767
1775
|
} | {
|
|
1768
1776
|
readonly kind: "browser.mcp.recover";
|
|
1769
|
-
} | {
|
|
1770
|
-
readonly kind: "nix.check";
|
|
1771
|
-
} | {
|
|
1772
|
-
readonly kind: "nix.apply";
|
|
1773
|
-
readonly ref: string;
|
|
1774
|
-
} | {
|
|
1775
|
-
readonly kind: "agent.message";
|
|
1776
|
-
readonly session: string;
|
|
1777
|
-
readonly message: string;
|
|
1778
1777
|
};
|
|
1779
1778
|
readonly result: string | null;
|
|
1780
1779
|
readonly acceptedReceipt?: string | null;
|
|
@@ -1821,11 +1820,20 @@ export declare const makeHerdrTerminalConnector: (config: {
|
|
|
1821
1820
|
readonly expiredAt?: number | null;
|
|
1822
1821
|
readonly status: "expired" | "failed" | "interrupted" | "pending_approval" | "queued" | "rejected" | "running" | "succeeded";
|
|
1823
1822
|
readonly payload: {
|
|
1823
|
+
readonly kind: "nix.check";
|
|
1824
|
+
} | {
|
|
1825
|
+
readonly kind: "nix.apply";
|
|
1826
|
+
readonly ref: string;
|
|
1827
|
+
} | {
|
|
1824
1828
|
readonly kind: "agent.delegate";
|
|
1825
1829
|
readonly repository: string;
|
|
1826
1830
|
readonly prompt: string;
|
|
1827
1831
|
readonly mode: "consult" | "review" | "transition_summary" | "work";
|
|
1828
1832
|
readonly channel?: "coordinator_chat";
|
|
1833
|
+
} | {
|
|
1834
|
+
readonly kind: "agent.message";
|
|
1835
|
+
readonly session: string;
|
|
1836
|
+
readonly message: string;
|
|
1829
1837
|
} | {
|
|
1830
1838
|
readonly kind: "work.reconcile";
|
|
1831
1839
|
readonly repository: string;
|
|
@@ -1952,15 +1960,6 @@ export declare const makeHerdrTerminalConnector: (config: {
|
|
|
1952
1960
|
readonly expectedGoalUpdatedAt: number;
|
|
1953
1961
|
} | {
|
|
1954
1962
|
readonly kind: "browser.mcp.recover";
|
|
1955
|
-
} | {
|
|
1956
|
-
readonly kind: "nix.check";
|
|
1957
|
-
} | {
|
|
1958
|
-
readonly kind: "nix.apply";
|
|
1959
|
-
readonly ref: string;
|
|
1960
|
-
} | {
|
|
1961
|
-
readonly kind: "agent.message";
|
|
1962
|
-
readonly session: string;
|
|
1963
|
-
readonly message: string;
|
|
1964
1963
|
};
|
|
1965
1964
|
readonly result: string | null;
|
|
1966
1965
|
readonly acceptedReceipt?: string | null;
|
|
@@ -2003,11 +2002,20 @@ export declare const makeHerdrTerminalConnector: (config: {
|
|
|
2003
2002
|
readonly expiredAt?: number | null;
|
|
2004
2003
|
readonly status: "expired" | "failed" | "interrupted" | "pending_approval" | "queued" | "rejected" | "running" | "succeeded";
|
|
2005
2004
|
readonly payload: {
|
|
2005
|
+
readonly kind: "nix.check";
|
|
2006
|
+
} | {
|
|
2007
|
+
readonly kind: "nix.apply";
|
|
2008
|
+
readonly ref: string;
|
|
2009
|
+
} | {
|
|
2006
2010
|
readonly kind: "agent.delegate";
|
|
2007
2011
|
readonly repository: string;
|
|
2008
2012
|
readonly prompt: string;
|
|
2009
2013
|
readonly mode: "consult" | "review" | "transition_summary" | "work";
|
|
2010
2014
|
readonly channel?: "coordinator_chat";
|
|
2015
|
+
} | {
|
|
2016
|
+
readonly kind: "agent.message";
|
|
2017
|
+
readonly session: string;
|
|
2018
|
+
readonly message: string;
|
|
2011
2019
|
} | {
|
|
2012
2020
|
readonly kind: "work.reconcile";
|
|
2013
2021
|
readonly repository: string;
|
|
@@ -2134,15 +2142,6 @@ export declare const makeHerdrTerminalConnector: (config: {
|
|
|
2134
2142
|
readonly expectedGoalUpdatedAt: number;
|
|
2135
2143
|
} | {
|
|
2136
2144
|
readonly kind: "browser.mcp.recover";
|
|
2137
|
-
} | {
|
|
2138
|
-
readonly kind: "nix.check";
|
|
2139
|
-
} | {
|
|
2140
|
-
readonly kind: "nix.apply";
|
|
2141
|
-
readonly ref: string;
|
|
2142
|
-
} | {
|
|
2143
|
-
readonly kind: "agent.message";
|
|
2144
|
-
readonly session: string;
|
|
2145
|
-
readonly message: string;
|
|
2146
2145
|
};
|
|
2147
2146
|
readonly result: string | null;
|
|
2148
2147
|
readonly acceptedReceipt?: string | null;
|
|
@@ -2232,11 +2231,20 @@ export declare const makeHerdrTerminalConnector: (config: {
|
|
|
2232
2231
|
readonly expiredAt?: number | null;
|
|
2233
2232
|
readonly status: "expired" | "failed" | "interrupted" | "pending_approval" | "queued" | "rejected" | "running" | "succeeded";
|
|
2234
2233
|
readonly payload: {
|
|
2234
|
+
readonly kind: "nix.check";
|
|
2235
|
+
} | {
|
|
2236
|
+
readonly kind: "nix.apply";
|
|
2237
|
+
readonly ref: string;
|
|
2238
|
+
} | {
|
|
2235
2239
|
readonly kind: "agent.delegate";
|
|
2236
2240
|
readonly repository: string;
|
|
2237
2241
|
readonly prompt: string;
|
|
2238
2242
|
readonly mode: "consult" | "review" | "transition_summary" | "work";
|
|
2239
2243
|
readonly channel?: "coordinator_chat";
|
|
2244
|
+
} | {
|
|
2245
|
+
readonly kind: "agent.message";
|
|
2246
|
+
readonly session: string;
|
|
2247
|
+
readonly message: string;
|
|
2240
2248
|
} | {
|
|
2241
2249
|
readonly kind: "work.reconcile";
|
|
2242
2250
|
readonly repository: string;
|
|
@@ -2363,15 +2371,6 @@ export declare const makeHerdrTerminalConnector: (config: {
|
|
|
2363
2371
|
readonly expectedGoalUpdatedAt: number;
|
|
2364
2372
|
} | {
|
|
2365
2373
|
readonly kind: "browser.mcp.recover";
|
|
2366
|
-
} | {
|
|
2367
|
-
readonly kind: "nix.check";
|
|
2368
|
-
} | {
|
|
2369
|
-
readonly kind: "nix.apply";
|
|
2370
|
-
readonly ref: string;
|
|
2371
|
-
} | {
|
|
2372
|
-
readonly kind: "agent.message";
|
|
2373
|
-
readonly session: string;
|
|
2374
|
-
readonly message: string;
|
|
2375
2374
|
};
|
|
2376
2375
|
readonly result: string | null;
|
|
2377
2376
|
readonly acceptedReceipt?: string | null;
|
package/dist/terminal.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"terminal.d.ts","sourceRoot":"","sources":["../src/terminal.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"terminal.d.ts","sourceRoot":"","sources":["../src/terminal.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAqB,MAAM,EAAE,MAAM,QAAQ,CAAA;AAClE,OAAO,EAAgB,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AAClE,OAAO,EAAE,0BAA0B,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAEvG,OAAO,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAA;AAE9F,OAAO,EAAE,kBAAkB,EAAE,KAAK,qBAAqB,EAAE,KAAK,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAEnG,MAAM,MAAM,aAAa,GACrB,0BAA0B,GAC1B,qBAAqB,GACrB,sBAAsB,CAAA;AAE1B,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,kBAAkB,EAAE,aAAa,CAAC,CAAA;IACjE,QAAQ,CAAC,IAAI,EA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kEA8KrC,CAAA"}
|
package/dist/terminal.js
CHANGED
|
@@ -1,67 +1,13 @@
|
|
|
1
|
+
import { limitBytes } from "@knpkv/bounded-io";
|
|
1
2
|
import { Crypto, Effect, Predicate, Schema, Stream } from "effect";
|
|
2
3
|
import { ChildProcess, ChildProcessSpawner } from "effect/process";
|
|
3
4
|
import { TerminalAgentNotFoundError, TerminalProtocolError, TerminalTransportError } from "./errors.js";
|
|
4
5
|
import { connectAgentId } from "./id.js";
|
|
6
|
+
import { boundedTerminalLines, terminalEventMaxLineBytes } from "./internal/terminal-lines.js";
|
|
5
7
|
import { releaseTerminalControl, terminalKillOptions, terminalReleaseKillOptions } from "./internal/terminal-release.js";
|
|
6
8
|
import { HerdrTerminalEvent } from "./model.js";
|
|
7
9
|
export const terminalStderrMaxBytes = 1024 * 1024;
|
|
8
|
-
export
|
|
9
|
-
const terminalLineInitialBytes = 64 * 1_024;
|
|
10
|
-
const emptyTerminalLine = () => ({
|
|
11
|
-
buffer: new Uint8Array(terminalLineInitialBytes),
|
|
12
|
-
length: 0
|
|
13
|
-
});
|
|
14
|
-
const decodeTerminalLine = (bytes) => {
|
|
15
|
-
const content = bytes.at(-1) === 13 ? bytes.subarray(0, -1) : bytes;
|
|
16
|
-
return new TextDecoder().decode(content);
|
|
17
|
-
};
|
|
18
|
-
const growTerminalLineBuffer = (buffer, requiredBytes, onBufferCopy) => {
|
|
19
|
-
if (requiredBytes <= buffer.byteLength)
|
|
20
|
-
return buffer;
|
|
21
|
-
let capacity = buffer.byteLength;
|
|
22
|
-
while (capacity < requiredBytes) {
|
|
23
|
-
capacity = Math.min(capacity * 2, terminalEventMaxLineBytes);
|
|
24
|
-
}
|
|
25
|
-
const grown = new Uint8Array(capacity);
|
|
26
|
-
onBufferCopy?.(buffer.byteLength);
|
|
27
|
-
grown.set(buffer);
|
|
28
|
-
return grown;
|
|
29
|
-
};
|
|
30
|
-
/** @internal Exposes copied-byte accounting only for the deterministic complexity regression. */
|
|
31
|
-
export const boundedTerminalLines = (stream, onBufferCopy) => stream.pipe(Stream.mapAccumEffect(emptyTerminalLine, (state, chunk) => {
|
|
32
|
-
let buffer = state.buffer;
|
|
33
|
-
let length = state.length;
|
|
34
|
-
const lines = [];
|
|
35
|
-
let offset = 0;
|
|
36
|
-
while (offset < chunk.byteLength) {
|
|
37
|
-
const newline = chunk.indexOf(10, offset);
|
|
38
|
-
const end = newline === -1 ? chunk.byteLength : newline;
|
|
39
|
-
const nextLength = length + end - offset;
|
|
40
|
-
if (nextLength > terminalEventMaxLineBytes) {
|
|
41
|
-
return Effect.fail(new TerminalProtocolError({
|
|
42
|
-
cause: nextLength,
|
|
43
|
-
detail: `Herdr terminal event exceeded ${terminalEventMaxLineBytes} bytes`
|
|
44
|
-
}));
|
|
45
|
-
}
|
|
46
|
-
buffer = growTerminalLineBuffer(buffer, nextLength, onBufferCopy);
|
|
47
|
-
buffer.set(chunk.subarray(offset, end), length);
|
|
48
|
-
length = nextLength;
|
|
49
|
-
if (newline === -1)
|
|
50
|
-
break;
|
|
51
|
-
lines.push(decodeTerminalLine(buffer.subarray(0, length)));
|
|
52
|
-
length = 0;
|
|
53
|
-
offset = newline + 1;
|
|
54
|
-
}
|
|
55
|
-
const result = [
|
|
56
|
-
{ buffer, length },
|
|
57
|
-
lines
|
|
58
|
-
];
|
|
59
|
-
return Effect.succeed(result);
|
|
60
|
-
}, {
|
|
61
|
-
onHalt: (state) => state.length === 0
|
|
62
|
-
? []
|
|
63
|
-
: [decodeTerminalLine(state.buffer.subarray(0, state.length))]
|
|
64
|
-
}));
|
|
10
|
+
export { boundedTerminalLines, terminalEventMaxLineBytes };
|
|
65
11
|
const transportError = (operation) => (cause) => new TerminalTransportError({ cause, detail: String(cause), operation });
|
|
66
12
|
export const makeHerdrTerminalConnector = Effect.fn("HerdrTerminal.make")(function* (config, service) {
|
|
67
13
|
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
|
|
@@ -136,16 +82,11 @@ export const makeHerdrTerminalConnector = Effect.fn("HerdrTerminal.make")(functi
|
|
|
136
82
|
detail: String(cause),
|
|
137
83
|
operation: "herdr.terminal.read"
|
|
138
84
|
})));
|
|
139
|
-
const stderrDrain = handle.stderr.pipe(Stream.mapError(transportError("herdr.terminal.stderr")), Stream.
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
detail: `Herdr terminal stderr exceeded ${terminalStderrMaxBytes} bytes`,
|
|
145
|
-
operation: "herdr.terminal.stderr"
|
|
146
|
-
}))
|
|
147
|
-
: Effect.succeed(next);
|
|
148
|
-
}));
|
|
85
|
+
const stderrDrain = limitBytes(handle.stderr.pipe(Stream.mapError(transportError("herdr.terminal.stderr"))), terminalStderrMaxBytes).pipe(Stream.catchTag("ByteLimitExceeded", ({ observedBytes }) => Stream.fail(new TerminalTransportError({
|
|
86
|
+
cause: observedBytes,
|
|
87
|
+
detail: `Herdr terminal stderr exceeded ${terminalStderrMaxBytes} bytes`,
|
|
88
|
+
operation: "herdr.terminal.stderr"
|
|
89
|
+
}))), Stream.runDrain);
|
|
149
90
|
const events = Stream.merge(terminalEvents, Stream.fromEffect(stderrDrain).pipe(Stream.drain)).pipe(Stream.concat(Stream.fromEffect(handle.exitCode.pipe(Effect.flatMap((code) => Number(code) === 0
|
|
150
91
|
? Effect.void
|
|
151
92
|
: Effect.fail(new TerminalTransportError({
|
package/dist/terminal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"terminal.js","sourceRoot":"","sources":["../src/terminal.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"terminal.js","sourceRoot":"","sources":["../src/terminal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAG9C,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAClE,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AAClE,OAAO,EAAE,0BAA0B,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AACvG,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AACxC,OAAO,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAA;AAC9F,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAA;AACxH,OAAO,EAAE,kBAAkB,EAAsD,MAAM,YAAY,CAAA;AAkBnG,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI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
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"description": "Fleet Herdr agent directory and authenticated terminal control",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "knpkv",
|
|
@@ -52,7 +52,8 @@
|
|
|
52
52
|
"@effect/platform-browser": "4.0.0",
|
|
53
53
|
"effect": "4.0.0",
|
|
54
54
|
"ghostty-web": "0.4.0",
|
|
55
|
-
"@knpkv/
|
|
55
|
+
"@knpkv/bounded-io": "^0.2.0",
|
|
56
|
+
"@knpkv/herdr-fleet": "^0.5.1",
|
|
56
57
|
"@knpkv/herdr-work": "^0.5.1",
|
|
57
58
|
"@knpkv/rly": "^0.6.1"
|
|
58
59
|
},
|