@knpkv/herdr-connect 0.2.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.
- package/LICENSE +21 -0
- package/README.md +11 -0
- package/dist/activity-store.d.ts +11 -0
- package/dist/activity-store.d.ts.map +1 -0
- package/dist/activity-store.js +76 -0
- package/dist/activity-store.js.map +1 -0
- package/dist/client-entry.d.ts +2 -0
- package/dist/client-entry.d.ts.map +1 -0
- package/dist/client-entry.js +11 -0
- package/dist/client-entry.js.map +1 -0
- package/dist/client.d.ts +86 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +453 -0
- package/dist/client.js.map +1 -0
- package/dist/directory.d.ts +159 -0
- package/dist/directory.d.ts.map +1 -0
- package/dist/directory.js +186 -0
- package/dist/directory.js.map +1 -0
- package/dist/errors.d.ts +62 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +36 -0
- package/dist/errors.js.map +1 -0
- package/dist/forest.d.ts +61 -0
- package/dist/forest.d.ts.map +1 -0
- package/dist/forest.js +90 -0
- package/dist/forest.js.map +1 -0
- package/dist/id.d.ts +4 -0
- package/dist/id.d.ts.map +1 -0
- package/dist/id.js +10 -0
- package/dist/id.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/terminal-release.d.ts +6 -0
- package/dist/internal/terminal-release.d.ts.map +1 -0
- package/dist/internal/terminal-release.js +13 -0
- package/dist/internal/terminal-release.js.map +1 -0
- package/dist/keyboard.d.ts +2 -0
- package/dist/keyboard.d.ts.map +1 -0
- package/dist/keyboard.js +19 -0
- package/dist/keyboard.js.map +1 -0
- package/dist/model.d.ts +144 -0
- package/dist/model.d.ts.map +1 -0
- package/dist/model.js +104 -0
- package/dist/model.js.map +1 -0
- package/dist/relationship-store.d.ts +66 -0
- package/dist/relationship-store.d.ts.map +1 -0
- package/dist/relationship-store.js +246 -0
- package/dist/relationship-store.js.map +1 -0
- package/dist/target.d.ts +83 -0
- package/dist/target.d.ts.map +1 -0
- package/dist/target.js +56 -0
- package/dist/target.js.map +1 -0
- package/dist/terminal-input.d.ts +30 -0
- package/dist/terminal-input.d.ts.map +1 -0
- package/dist/terminal-input.js +95 -0
- package/dist/terminal-input.js.map +1 -0
- package/dist/terminal-setup.d.ts +10 -0
- package/dist/terminal-setup.d.ts.map +1 -0
- package/dist/terminal-setup.js +11 -0
- package/dist/terminal-setup.js.map +1 -0
- package/dist/terminal-theme.d.ts +3 -0
- package/dist/terminal-theme.d.ts.map +1 -0
- package/dist/terminal-theme.js +3 -0
- package/dist/terminal-theme.js.map +1 -0
- package/dist/terminal-viewport.d.ts +12 -0
- package/dist/terminal-viewport.d.ts.map +1 -0
- package/dist/terminal-viewport.js +21 -0
- package/dist/terminal-viewport.js.map +1 -0
- package/dist/terminal.d.ts +794 -0
- package/dist/terminal.d.ts.map +1 -0
- package/dist/terminal.js +166 -0
- package/dist/terminal.js.map +1 -0
- package/dist/view.d.ts +51 -0
- package/dist/view.d.ts.map +1 -0
- package/dist/view.js +210 -0
- package/dist/view.js.map +1 -0
- package/package.json +84 -0
- package/src/styles.css +527 -0
package/dist/model.d.ts
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
export declare const AgentWorkLabel: Schema.String;
|
|
3
|
+
export declare const ConnectAgentRelation: Schema.Literals<readonly ["delegated", "pair", "review"]>;
|
|
4
|
+
export type ConnectAgentRelation = typeof ConnectAgentRelation.Type;
|
|
5
|
+
export declare const ConnectAgentRelationship: Schema.Struct<{
|
|
6
|
+
readonly parentAgentId: Schema.String;
|
|
7
|
+
readonly relation: Schema.Literals<readonly ["delegated", "pair", "review"]>;
|
|
8
|
+
}>;
|
|
9
|
+
export type ConnectAgentRelationship = typeof ConnectAgentRelationship.Type;
|
|
10
|
+
export declare const ConnectAgent: Schema.Struct<{
|
|
11
|
+
readonly id: Schema.String;
|
|
12
|
+
readonly host: Schema.String;
|
|
13
|
+
readonly name: Schema.String;
|
|
14
|
+
readonly kind: Schema.String;
|
|
15
|
+
readonly state: Schema.String;
|
|
16
|
+
readonly work: Schema.String;
|
|
17
|
+
readonly lastActivityAt: Schema.Number;
|
|
18
|
+
readonly relationship: Schema.optionalKey<Schema.Struct<{
|
|
19
|
+
readonly parentAgentId: Schema.String;
|
|
20
|
+
readonly relation: Schema.Literals<readonly ["delegated", "pair", "review"]>;
|
|
21
|
+
}>>;
|
|
22
|
+
}>;
|
|
23
|
+
export type ConnectAgent = typeof ConnectAgent.Type;
|
|
24
|
+
export declare const LocalConnectAgents: Schema.Struct<{
|
|
25
|
+
readonly host: Schema.String;
|
|
26
|
+
readonly agents: Schema.$Array<Schema.Struct<{
|
|
27
|
+
readonly id: Schema.String;
|
|
28
|
+
readonly host: Schema.String;
|
|
29
|
+
readonly name: Schema.String;
|
|
30
|
+
readonly kind: Schema.String;
|
|
31
|
+
readonly state: Schema.String;
|
|
32
|
+
readonly work: Schema.String;
|
|
33
|
+
readonly lastActivityAt: Schema.Number;
|
|
34
|
+
readonly relationship: Schema.optionalKey<Schema.Struct<{
|
|
35
|
+
readonly parentAgentId: Schema.String;
|
|
36
|
+
readonly relation: Schema.Literals<readonly ["delegated", "pair", "review"]>;
|
|
37
|
+
}>>;
|
|
38
|
+
}>>;
|
|
39
|
+
}>;
|
|
40
|
+
export type LocalConnectAgents = typeof LocalConnectAgents.Type;
|
|
41
|
+
export declare const ConnectPeerFailure: Schema.Struct<{
|
|
42
|
+
readonly host: Schema.String;
|
|
43
|
+
readonly reason: Schema.Literals<readonly ["offline", "unavailable", "timeout", "request_failed", "invalid_response"]>;
|
|
44
|
+
}>;
|
|
45
|
+
export type ConnectPeerFailure = typeof ConnectPeerFailure.Type;
|
|
46
|
+
export declare const FleetConnectAgents: Schema.Struct<{
|
|
47
|
+
readonly agents: Schema.$Array<Schema.Struct<{
|
|
48
|
+
readonly id: Schema.String;
|
|
49
|
+
readonly host: Schema.String;
|
|
50
|
+
readonly name: Schema.String;
|
|
51
|
+
readonly kind: Schema.String;
|
|
52
|
+
readonly state: Schema.String;
|
|
53
|
+
readonly work: Schema.String;
|
|
54
|
+
readonly lastActivityAt: Schema.Number;
|
|
55
|
+
readonly relationship: Schema.optionalKey<Schema.Struct<{
|
|
56
|
+
readonly parentAgentId: Schema.String;
|
|
57
|
+
readonly relation: Schema.Literals<readonly ["delegated", "pair", "review"]>;
|
|
58
|
+
}>>;
|
|
59
|
+
}>>;
|
|
60
|
+
readonly failures: Schema.$Array<Schema.Struct<{
|
|
61
|
+
readonly host: Schema.String;
|
|
62
|
+
readonly reason: Schema.Literals<readonly ["offline", "unavailable", "timeout", "request_failed", "invalid_response"]>;
|
|
63
|
+
}>>;
|
|
64
|
+
}>;
|
|
65
|
+
export type FleetConnectAgents = typeof FleetConnectAgents.Type;
|
|
66
|
+
export declare const connectAgentPageMaxRecords = 64;
|
|
67
|
+
export declare const ConnectAgentCursor: Schema.Struct<{
|
|
68
|
+
readonly host: Schema.String;
|
|
69
|
+
readonly id: Schema.String;
|
|
70
|
+
}>;
|
|
71
|
+
export type ConnectAgentCursor = typeof ConnectAgentCursor.Type;
|
|
72
|
+
export declare const FleetConnectAgentPage: Schema.Struct<{
|
|
73
|
+
readonly agents: Schema.$Array<Schema.Struct<{
|
|
74
|
+
readonly id: Schema.String;
|
|
75
|
+
readonly host: Schema.String;
|
|
76
|
+
readonly name: Schema.String;
|
|
77
|
+
readonly kind: Schema.String;
|
|
78
|
+
readonly state: Schema.String;
|
|
79
|
+
readonly work: Schema.String;
|
|
80
|
+
readonly lastActivityAt: Schema.Number;
|
|
81
|
+
readonly relationship: Schema.optionalKey<Schema.Struct<{
|
|
82
|
+
readonly parentAgentId: Schema.String;
|
|
83
|
+
readonly relation: Schema.Literals<readonly ["delegated", "pair", "review"]>;
|
|
84
|
+
}>>;
|
|
85
|
+
}>>;
|
|
86
|
+
readonly failures: Schema.$Array<Schema.Struct<{
|
|
87
|
+
readonly host: Schema.String;
|
|
88
|
+
readonly reason: Schema.Literals<readonly ["offline", "unavailable", "timeout", "request_failed", "invalid_response"]>;
|
|
89
|
+
}>>;
|
|
90
|
+
readonly nextCursor: Schema.NullOr<Schema.Struct<{
|
|
91
|
+
readonly host: Schema.String;
|
|
92
|
+
readonly id: Schema.String;
|
|
93
|
+
}>>;
|
|
94
|
+
}>;
|
|
95
|
+
export type FleetConnectAgentPage = typeof FleetConnectAgentPage.Type;
|
|
96
|
+
export declare const terminalCommandMaxPayloadBytes: number;
|
|
97
|
+
export declare const TerminalSelection: Schema.Struct<{
|
|
98
|
+
readonly host: Schema.String;
|
|
99
|
+
readonly agentId: Schema.String;
|
|
100
|
+
readonly cols: Schema.Number;
|
|
101
|
+
readonly rows: Schema.Number;
|
|
102
|
+
}>;
|
|
103
|
+
export type TerminalSelection = typeof TerminalSelection.Type;
|
|
104
|
+
export declare const TerminalClientCommand: Schema.Union<readonly [Schema.Struct<{
|
|
105
|
+
readonly type: Schema.Literal<"terminal.input">;
|
|
106
|
+
readonly text: Schema.String;
|
|
107
|
+
}>, Schema.Struct<{
|
|
108
|
+
readonly type: Schema.Literal<"terminal.resize">;
|
|
109
|
+
readonly cols: Schema.Number;
|
|
110
|
+
readonly rows: Schema.Number;
|
|
111
|
+
readonly cell_width_px: Schema.Number;
|
|
112
|
+
readonly cell_height_px: Schema.Number;
|
|
113
|
+
}>, Schema.Struct<{
|
|
114
|
+
readonly type: Schema.Literal<"terminal.release">;
|
|
115
|
+
}>, Schema.Struct<{
|
|
116
|
+
readonly type: Schema.Literal<"terminal.scroll">;
|
|
117
|
+
readonly direction: Schema.Literals<readonly ["up", "down"]>;
|
|
118
|
+
readonly lines: Schema.Number;
|
|
119
|
+
readonly source: Schema.Literals<readonly ["wheel", "page_key"]>;
|
|
120
|
+
readonly modifiers: Schema.Number;
|
|
121
|
+
}>]>;
|
|
122
|
+
export type TerminalClientCommand = typeof TerminalClientCommand.Type;
|
|
123
|
+
export declare const terminalFrameMaxEncodedBytes: number;
|
|
124
|
+
export declare const HerdrTerminalEvent: Schema.Union<readonly [Schema.Struct<{
|
|
125
|
+
readonly type: Schema.Literal<"terminal.frame">;
|
|
126
|
+
readonly seq: Schema.Number;
|
|
127
|
+
readonly encoding: Schema.Literal<"ansi">;
|
|
128
|
+
readonly width: Schema.Number;
|
|
129
|
+
readonly height: Schema.Number;
|
|
130
|
+
readonly full: Schema.Boolean;
|
|
131
|
+
readonly bytes: Schema.String;
|
|
132
|
+
}>, Schema.Struct<{
|
|
133
|
+
readonly type: Schema.Literal<"terminal.closed">;
|
|
134
|
+
readonly reason: Schema.String;
|
|
135
|
+
}>]>;
|
|
136
|
+
export type HerdrTerminalEvent = typeof HerdrTerminalEvent.Type;
|
|
137
|
+
export declare const TerminalServerSignal: Schema.Union<readonly [Schema.Struct<{
|
|
138
|
+
readonly type: Schema.Literal<"terminal.ready">;
|
|
139
|
+
}>, Schema.Struct<{
|
|
140
|
+
readonly type: Schema.Literal<"terminal.closed">;
|
|
141
|
+
readonly reason: Schema.String;
|
|
142
|
+
}>]>;
|
|
143
|
+
export type TerminalServerSignal = typeof TerminalServerSignal.Type;
|
|
144
|
+
//# sourceMappingURL=model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAM/B,eAAO,MAAM,cAAc,eAI1B,CAAA;AAMD,eAAO,MAAM,oBAAoB,2DAI/B,CAAA;AACF,MAAM,MAAM,oBAAoB,GAAG,OAAO,oBAAoB,CAAC,IAAI,CAAA;AAEnE,eAAO,MAAM,wBAAwB;;;EAA0B,CAAA;AAC/D,MAAM,MAAM,wBAAwB,GAAG,OAAO,wBAAwB,CAAC,IAAI,CAAA;AAE3E,eAAO,MAAM,YAAY;;;;;;;;;;;;EASvB,CAAA;AACF,MAAM,M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ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { AgentStableId, AgentWorkerIdentity, AgentWorkerRelationship } from "@knpkv/herdr-fleet/model";
|
|
2
|
+
import { Schema } from "effect";
|
|
3
|
+
const BoundedString = Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(256));
|
|
4
|
+
export const AgentWorkLabel = Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(256), Schema.isPattern(/^[^/\\\p{Cc}]+$/u));
|
|
5
|
+
const ActivityTimestamp = Schema.Number.check(Schema.isInt(), Schema.isBetween({ minimum: 0, maximum: 8_640_000_000_000_000 }));
|
|
6
|
+
export const ConnectAgentRelation = Schema.Literals([
|
|
7
|
+
"delegated",
|
|
8
|
+
"pair",
|
|
9
|
+
"review"
|
|
10
|
+
]);
|
|
11
|
+
export const ConnectAgentRelationship = AgentWorkerRelationship;
|
|
12
|
+
export const ConnectAgent = Schema.Struct({
|
|
13
|
+
id: AgentStableId,
|
|
14
|
+
host: AgentWorkerIdentity.fields.host,
|
|
15
|
+
name: AgentWorkerIdentity.fields.name,
|
|
16
|
+
kind: BoundedString,
|
|
17
|
+
state: BoundedString,
|
|
18
|
+
work: AgentWorkLabel,
|
|
19
|
+
lastActivityAt: ActivityTimestamp,
|
|
20
|
+
relationship: Schema.optionalKey(ConnectAgentRelationship)
|
|
21
|
+
});
|
|
22
|
+
export const LocalConnectAgents = Schema.Struct({
|
|
23
|
+
host: BoundedString,
|
|
24
|
+
agents: Schema.Array(ConnectAgent).check(Schema.isMaxLength(256))
|
|
25
|
+
});
|
|
26
|
+
export const ConnectPeerFailure = Schema.Struct({
|
|
27
|
+
host: BoundedString,
|
|
28
|
+
reason: Schema.Literals([
|
|
29
|
+
"offline",
|
|
30
|
+
"unavailable",
|
|
31
|
+
"timeout",
|
|
32
|
+
"request_failed",
|
|
33
|
+
"invalid_response"
|
|
34
|
+
])
|
|
35
|
+
});
|
|
36
|
+
export const FleetConnectAgents = Schema.Struct({
|
|
37
|
+
agents: Schema.Array(ConnectAgent).check(Schema.isMaxLength(1_024)),
|
|
38
|
+
failures: Schema.Array(ConnectPeerFailure).check(Schema.isMaxLength(256))
|
|
39
|
+
});
|
|
40
|
+
export const connectAgentPageMaxRecords = 64;
|
|
41
|
+
export const ConnectAgentCursor = Schema.Struct({
|
|
42
|
+
host: ConnectAgent.fields.host,
|
|
43
|
+
id: ConnectAgent.fields.id
|
|
44
|
+
});
|
|
45
|
+
export const FleetConnectAgentPage = Schema.Struct({
|
|
46
|
+
agents: Schema.Array(ConnectAgent).check(Schema.isMaxLength(connectAgentPageMaxRecords)),
|
|
47
|
+
failures: FleetConnectAgents.fields.failures,
|
|
48
|
+
nextCursor: Schema.NullOr(ConnectAgentCursor)
|
|
49
|
+
});
|
|
50
|
+
const TerminalColumns = Schema.Number.check(Schema.isInt(), Schema.isBetween({ minimum: 20, maximum: 400 }));
|
|
51
|
+
const TerminalRows = Schema.Number.check(Schema.isInt(), Schema.isBetween({ minimum: 5, maximum: 200 }));
|
|
52
|
+
const TerminalScrollLines = Schema.Number.check(Schema.isInt(), Schema.isBetween({ minimum: 1, maximum: 400 }));
|
|
53
|
+
export const terminalCommandMaxPayloadBytes = 512 * 1024;
|
|
54
|
+
export const TerminalSelection = Schema.Struct({
|
|
55
|
+
host: BoundedString,
|
|
56
|
+
agentId: BoundedString,
|
|
57
|
+
cols: TerminalColumns,
|
|
58
|
+
rows: TerminalRows
|
|
59
|
+
});
|
|
60
|
+
export const TerminalClientCommand = Schema.Union([
|
|
61
|
+
Schema.Struct({
|
|
62
|
+
type: Schema.Literal("terminal.input"),
|
|
63
|
+
text: Schema.String.check(Schema.isMaxLength(65_536))
|
|
64
|
+
}),
|
|
65
|
+
Schema.Struct({
|
|
66
|
+
type: Schema.Literal("terminal.resize"),
|
|
67
|
+
cols: TerminalColumns,
|
|
68
|
+
rows: TerminalRows,
|
|
69
|
+
cell_width_px: Schema.Number.check(Schema.isInt(), Schema.isBetween({ minimum: 0, maximum: 1_024 })),
|
|
70
|
+
cell_height_px: Schema.Number.check(Schema.isInt(), Schema.isBetween({ minimum: 0, maximum: 1_024 }))
|
|
71
|
+
}),
|
|
72
|
+
Schema.Struct({ type: Schema.Literal("terminal.release") }),
|
|
73
|
+
Schema.Struct({
|
|
74
|
+
type: Schema.Literal("terminal.scroll"),
|
|
75
|
+
direction: Schema.Literals(["up", "down"]),
|
|
76
|
+
lines: TerminalScrollLines,
|
|
77
|
+
source: Schema.Literals(["wheel", "page_key"]),
|
|
78
|
+
modifiers: Schema.Number.check(Schema.isInt(), Schema.isBetween({ minimum: 0, maximum: 15 }))
|
|
79
|
+
})
|
|
80
|
+
]);
|
|
81
|
+
export const terminalFrameMaxEncodedBytes = 4 * 1024 * 1024;
|
|
82
|
+
export const HerdrTerminalEvent = Schema.Union([
|
|
83
|
+
Schema.Struct({
|
|
84
|
+
type: Schema.Literal("terminal.frame"),
|
|
85
|
+
seq: Schema.Number,
|
|
86
|
+
encoding: Schema.Literal("ansi"),
|
|
87
|
+
width: Schema.Number,
|
|
88
|
+
height: Schema.Number,
|
|
89
|
+
full: Schema.Boolean,
|
|
90
|
+
bytes: Schema.String.check(Schema.isMaxLength(terminalFrameMaxEncodedBytes), Schema.isPattern(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/))
|
|
91
|
+
}),
|
|
92
|
+
Schema.Struct({
|
|
93
|
+
type: Schema.Literal("terminal.closed"),
|
|
94
|
+
reason: Schema.String.check(Schema.isMaxLength(1_024))
|
|
95
|
+
})
|
|
96
|
+
]);
|
|
97
|
+
export const TerminalServerSignal = Schema.Union([
|
|
98
|
+
Schema.Struct({ type: Schema.Literal("terminal.ready") }),
|
|
99
|
+
Schema.Struct({
|
|
100
|
+
type: Schema.Literal("terminal.closed"),
|
|
101
|
+
reason: Schema.String.check(Schema.isMaxLength(1_024))
|
|
102
|
+
})
|
|
103
|
+
]);
|
|
104
|
+
//# sourceMappingURL=model.js.map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AAC,gBAAgB,CAAC;QACtC,GAAG,EAAE,MAAM,CAAC,MAAM;QAClB,QAAQ,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;QAChC,KAAK,EAAE,MAAM,CAAC,MAAM;QACpB,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,IAAI,EAAE,MAAM,CAAC,OAAO;QACpB,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,CACxB,MAAM,CAAC,WAAW,CAAC,4BAA4B,CAAC,EAChD,MAAM,CAAC,SAAS,CACd,kEAAkE,CACnE,CACF;KACF,CAAC;IACF,MAAM,CAAC,MAAM,CAAC;QACZ,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC;QACvC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;KACvD,CAAC;CACH,CAAC,CAAA;AAGF,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,KAAK,CAAC;IAC/C,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAAE,CAAC;IACzD,MAAM,CAAC,MAAM,CAAC;QACZ,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC;QACvC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;KACvD,CAAC;CACH,CAAC,CAAA"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Effect, FileSystem, Path, Schema } from "effect";
|
|
2
|
+
import { ConnectRelationshipError, ConnectRelationshipStoreError } from "./errors.js";
|
|
3
|
+
export declare const PersistedConnectAgentMetadata: Schema.Struct<{
|
|
4
|
+
readonly agentId: Schema.String;
|
|
5
|
+
readonly host: Schema.String;
|
|
6
|
+
readonly observedAt: Schema.Number;
|
|
7
|
+
readonly paneId: Schema.String;
|
|
8
|
+
readonly relationship: Schema.optionalKey<Schema.Struct<{
|
|
9
|
+
readonly parentAgentId: Schema.String;
|
|
10
|
+
readonly relation: Schema.Literals<readonly ["delegated", "pair", "review"]>;
|
|
11
|
+
}>>;
|
|
12
|
+
}>;
|
|
13
|
+
export type PersistedConnectAgentMetadata = typeof PersistedConnectAgentMetadata.Type;
|
|
14
|
+
export type RelationshipObservationSource = "durable_worker" | "trusted_live_inventory";
|
|
15
|
+
export interface RelationshipObservation {
|
|
16
|
+
readonly metadata: PersistedConnectAgentMetadata;
|
|
17
|
+
readonly source: RelationshipObservationSource;
|
|
18
|
+
}
|
|
19
|
+
export declare class AgentRelationshipStore {
|
|
20
|
+
#private;
|
|
21
|
+
readonly path: string;
|
|
22
|
+
private constructor();
|
|
23
|
+
static readonly open: (path: string) => Effect.Effect<AgentRelationshipStore, ConnectRelationshipStoreError, FileSystem.FileSystem | Path.Path>;
|
|
24
|
+
readonly persist: (this: AgentRelationshipStore, metadata: {
|
|
25
|
+
readonly agentId: string;
|
|
26
|
+
readonly host: string;
|
|
27
|
+
readonly observedAt: number;
|
|
28
|
+
readonly paneId: string;
|
|
29
|
+
readonly relationship?: {
|
|
30
|
+
readonly parentAgentId: string;
|
|
31
|
+
readonly relation: "delegated" | "pair" | "review";
|
|
32
|
+
};
|
|
33
|
+
}, source: RelationshipObservationSource) => Effect.Effect<{
|
|
34
|
+
readonly agentId: string;
|
|
35
|
+
readonly host: string;
|
|
36
|
+
readonly observedAt: number;
|
|
37
|
+
readonly paneId: string;
|
|
38
|
+
readonly relationship?: {
|
|
39
|
+
readonly parentAgentId: string;
|
|
40
|
+
readonly relation: "delegated" | "pair" | "review";
|
|
41
|
+
};
|
|
42
|
+
}, ConnectRelationshipError | ConnectRelationshipStoreError, never>;
|
|
43
|
+
readonly persistAll: (this: AgentRelationshipStore, observations: readonly RelationshipObservation[]) => Effect.Effect<readonly {
|
|
44
|
+
readonly agentId: string;
|
|
45
|
+
readonly host: string;
|
|
46
|
+
readonly observedAt: number;
|
|
47
|
+
readonly paneId: string;
|
|
48
|
+
readonly relationship?: {
|
|
49
|
+
readonly parentAgentId: string;
|
|
50
|
+
readonly relation: "delegated" | "pair" | "review";
|
|
51
|
+
};
|
|
52
|
+
}[], ConnectRelationshipError | ConnectRelationshipStoreError, never>;
|
|
53
|
+
readonly list: (this: AgentRelationshipStore) => Effect.Effect<readonly {
|
|
54
|
+
readonly agentId: string;
|
|
55
|
+
readonly host: string;
|
|
56
|
+
readonly observedAt: number;
|
|
57
|
+
readonly paneId: string;
|
|
58
|
+
readonly relationship?: {
|
|
59
|
+
readonly parentAgentId: string;
|
|
60
|
+
readonly relation: "delegated" | "pair" | "review";
|
|
61
|
+
};
|
|
62
|
+
}[], ConnectRelationshipStoreError, never>;
|
|
63
|
+
private listUnlocked;
|
|
64
|
+
close(): void;
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=relationship-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relationship-store.d.ts","sourceRoot":"","sources":["../src/relationship-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAa,MAAM,QAAQ,CAAA;AAEpE,OAAO,EAAE,wBAAwB,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAA;AAIrF,eAAO,MAAM,6BAA6B;;;;;;;;;EAYxC,CAAA;AACF,MAAM,MAAM,6BAA6B,GAAG,OAAO,6BAA6B,CAAC,IAAI,CAAA;AAErF,MAAM,MAAM,6BAA6B,GAAG,gBAAgB,GAAG,wBAAwB,CAAA;AAEvF,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,QAAQ,EAAE,6BAA6B,CAAA;IAChD,QAAQ,CAAC,MAAM,EAAE,6BAA6B,CAAA;CAC/C;AA6DD,qBAAa,sBAAsB;;IAGjC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IAErB,OAAO,eA+EN;IAED,MAAM,CAAC,QAAQ,CAAC,IAAI,4HAiBnB;IAED,QAAQ,CAAC,OAAO;;;;;;;;;;;;;;;;;;wEAkBd;IAEF,QAAQ,CAAC,UAAU;;;;;;;;;0EAuGjB;IAEF,QAAQ,CAAC,IAAI;;;;;;;;;+CAIX;IAEF,OAAO,CAAC,YAAY;IAQpB,KAAK,IAAI,IAAI,CAEZ;CACF"}
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import { Effect, FileSystem, Path, Schema, Semaphore } from "effect";
|
|
2
|
+
import { DatabaseSync } from "node:sqlite";
|
|
3
|
+
import { ConnectRelationshipError, ConnectRelationshipStoreError } from "./errors.js";
|
|
4
|
+
import { connectRelationshipViolation } from "./forest.js";
|
|
5
|
+
import { ConnectAgent, ConnectAgentRelationship } from "./model.js";
|
|
6
|
+
export const PersistedConnectAgentMetadata = Schema.Struct({
|
|
7
|
+
agentId: ConnectAgent.fields.id,
|
|
8
|
+
host: ConnectAgent.fields.host,
|
|
9
|
+
observedAt: Schema.Number.check(Schema.isInt(), Schema.isBetween({ minimum: 0, maximum: 8_640_000_000_000_000 })),
|
|
10
|
+
paneId: Schema.String.check(Schema.isMaxLength(64), Schema.isPattern(/^w[0-9A-Z]+:p[0-9A-Z]+$/)),
|
|
11
|
+
relationship: Schema.optionalKey(ConnectAgentRelationship)
|
|
12
|
+
});
|
|
13
|
+
const RelationshipRow = Schema.Struct({
|
|
14
|
+
agent_id: Schema.String,
|
|
15
|
+
host: Schema.String,
|
|
16
|
+
observed_at: Schema.Number,
|
|
17
|
+
parent_agent_id: Schema.NullOr(Schema.String),
|
|
18
|
+
pane_id: Schema.String,
|
|
19
|
+
relation: Schema.NullOr(Schema.String),
|
|
20
|
+
source: Schema.Literals(["durable_worker", "trusted_live_inventory"])
|
|
21
|
+
});
|
|
22
|
+
const storeError = (operation) => (cause) => new ConnectRelationshipStoreError({ cause, operation });
|
|
23
|
+
const isRelationshipPersistenceFailure = Schema.is(Schema.Union([ConnectRelationshipError, ConnectRelationshipStoreError]));
|
|
24
|
+
const decodeRowSync = (row) => {
|
|
25
|
+
const decoded = Schema.decodeUnknownSync(RelationshipRow)(row);
|
|
26
|
+
const metadata = decoded.parent_agent_id === null || decoded.relation === null
|
|
27
|
+
? {
|
|
28
|
+
agentId: decoded.agent_id,
|
|
29
|
+
host: decoded.host,
|
|
30
|
+
observedAt: decoded.observed_at,
|
|
31
|
+
paneId: decoded.pane_id
|
|
32
|
+
}
|
|
33
|
+
: {
|
|
34
|
+
agentId: decoded.agent_id,
|
|
35
|
+
host: decoded.host,
|
|
36
|
+
observedAt: decoded.observed_at,
|
|
37
|
+
paneId: decoded.pane_id,
|
|
38
|
+
relationship: {
|
|
39
|
+
parentAgentId: decoded.parent_agent_id,
|
|
40
|
+
relation: decoded.relation
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
const decodedMetadata = Schema.decodeUnknownSync(PersistedConnectAgentMetadata)(metadata);
|
|
44
|
+
return { metadata: decodedMetadata, source: decoded.source };
|
|
45
|
+
};
|
|
46
|
+
const sameMetadata = (left, right) => left.agentId === right.agentId &&
|
|
47
|
+
left.host.toLowerCase() === right.host.toLowerCase() &&
|
|
48
|
+
left.paneId === right.paneId &&
|
|
49
|
+
left.relationship?.parentAgentId === right.relationship?.parentAgentId &&
|
|
50
|
+
left.relationship?.relation === right.relationship?.relation;
|
|
51
|
+
const listUnlockedSync = (database) => database.prepare(`SELECT agent_id, host, pane_id, parent_agent_id, relation, observed_at, source
|
|
52
|
+
FROM connect_agent_relationships
|
|
53
|
+
ORDER BY host, agent_id`).all().map((row) => decodeRowSync(row).metadata);
|
|
54
|
+
export class AgentRelationshipStore {
|
|
55
|
+
#database;
|
|
56
|
+
#transactions;
|
|
57
|
+
path;
|
|
58
|
+
constructor(path, transactions) {
|
|
59
|
+
this.path = path;
|
|
60
|
+
this.#transactions = transactions;
|
|
61
|
+
this.#database = new DatabaseSync(path);
|
|
62
|
+
try {
|
|
63
|
+
this.#database.exec(`
|
|
64
|
+
CREATE TABLE IF NOT EXISTS connect_store_metadata (
|
|
65
|
+
key TEXT PRIMARY KEY,
|
|
66
|
+
value TEXT NOT NULL
|
|
67
|
+
);
|
|
68
|
+
CREATE TABLE IF NOT EXISTS connect_agent_relationships (
|
|
69
|
+
host TEXT NOT NULL COLLATE NOCASE,
|
|
70
|
+
agent_id TEXT NOT NULL,
|
|
71
|
+
pane_id TEXT NOT NULL,
|
|
72
|
+
parent_agent_id TEXT,
|
|
73
|
+
relation TEXT,
|
|
74
|
+
observed_at INTEGER NOT NULL,
|
|
75
|
+
PRIMARY KEY (host, agent_id),
|
|
76
|
+
CHECK ((parent_agent_id IS NULL) = (relation IS NULL))
|
|
77
|
+
);
|
|
78
|
+
`);
|
|
79
|
+
const version = this.#database.prepare("SELECT value FROM connect_store_metadata WHERE key = 'relationship_schema'").get();
|
|
80
|
+
const decodedVersion = Schema.decodeUnknownResult(Schema.Struct({ value: Schema.String }))(version);
|
|
81
|
+
if (decodedVersion._tag === "Failure" ||
|
|
82
|
+
(decodedVersion.success.value !== "3" && decodedVersion.success.value !== "4")) {
|
|
83
|
+
this.#database.exec(`
|
|
84
|
+
BEGIN IMMEDIATE;
|
|
85
|
+
CREATE TABLE connect_agent_relationships_v2 (
|
|
86
|
+
host TEXT NOT NULL COLLATE NOCASE,
|
|
87
|
+
agent_id TEXT NOT NULL,
|
|
88
|
+
pane_id TEXT NOT NULL,
|
|
89
|
+
parent_agent_id TEXT,
|
|
90
|
+
relation TEXT,
|
|
91
|
+
observed_at INTEGER NOT NULL,
|
|
92
|
+
PRIMARY KEY (host, agent_id),
|
|
93
|
+
CHECK ((parent_agent_id IS NULL) = (relation IS NULL))
|
|
94
|
+
);
|
|
95
|
+
INSERT INTO connect_agent_relationships_v2
|
|
96
|
+
(host, agent_id, pane_id, parent_agent_id, relation, observed_at)
|
|
97
|
+
SELECT host, agent_id, pane_id, parent_agent_id, relation, observed_at
|
|
98
|
+
FROM connect_agent_relationships;
|
|
99
|
+
DROP TABLE connect_agent_relationships;
|
|
100
|
+
ALTER TABLE connect_agent_relationships_v2 RENAME TO connect_agent_relationships;
|
|
101
|
+
INSERT INTO connect_store_metadata (key, value)
|
|
102
|
+
VALUES ('relationship_schema', '3')
|
|
103
|
+
ON CONFLICT(key) DO UPDATE SET value = excluded.value;
|
|
104
|
+
COMMIT;
|
|
105
|
+
`);
|
|
106
|
+
}
|
|
107
|
+
const migratedVersion = this.#database.prepare("SELECT value FROM connect_store_metadata WHERE key = 'relationship_schema'").get();
|
|
108
|
+
const decodedMigratedVersion = Schema.decodeUnknownResult(Schema.Struct({ value: Schema.String }))(migratedVersion);
|
|
109
|
+
if (decodedMigratedVersion._tag === "Failure" || decodedMigratedVersion.success.value !== "4") {
|
|
110
|
+
this.#database.exec(`
|
|
111
|
+
BEGIN IMMEDIATE;
|
|
112
|
+
ALTER TABLE connect_agent_relationships
|
|
113
|
+
ADD COLUMN source TEXT NOT NULL DEFAULT 'durable_worker'
|
|
114
|
+
CHECK (source IN ('durable_worker', 'trusted_live_inventory'));
|
|
115
|
+
UPDATE connect_agent_relationships
|
|
116
|
+
SET source = 'trusted_live_inventory';
|
|
117
|
+
INSERT INTO connect_store_metadata (key, value)
|
|
118
|
+
VALUES ('relationship_schema', '4')
|
|
119
|
+
ON CONFLICT(key) DO UPDATE SET value = excluded.value;
|
|
120
|
+
COMMIT;
|
|
121
|
+
`);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
this.#database.close();
|
|
126
|
+
throw error;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
static open = Effect.fn("AgentRelationshipStore.open")(function* (path) {
|
|
130
|
+
const fileSystem = yield* FileSystem.FileSystem;
|
|
131
|
+
const paths = yield* Path.Path;
|
|
132
|
+
const directory = paths.dirname(path);
|
|
133
|
+
yield* fileSystem.makeDirectory(directory, { recursive: true, mode: 0o700 }).pipe(Effect.mapError(storeError("open.directory")));
|
|
134
|
+
yield* fileSystem.chmod(directory, 0o700).pipe(Effect.mapError(storeError("open.secureDirectory")));
|
|
135
|
+
const transactions = yield* Semaphore.make(1);
|
|
136
|
+
return yield* Effect.try({
|
|
137
|
+
try: () => new AgentRelationshipStore(path, transactions),
|
|
138
|
+
catch: storeError("open")
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
persist = Effect.fn("AgentRelationshipStore.persist")(function* (metadata, source) {
|
|
142
|
+
const stored = yield* this.persistAll([{ metadata, source }]);
|
|
143
|
+
const persisted = stored.find((candidate) => candidate.agentId === metadata.agentId &&
|
|
144
|
+
candidate.host.toLowerCase() === metadata.host.toLowerCase());
|
|
145
|
+
if (persisted === undefined) {
|
|
146
|
+
return yield* new ConnectRelationshipStoreError({
|
|
147
|
+
cause: metadata,
|
|
148
|
+
operation: "persist.result"
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
return persisted;
|
|
152
|
+
});
|
|
153
|
+
persistAll = Effect.fn("AgentRelationshipStore.persistAll")(function* (observations) {
|
|
154
|
+
const database = this.#database;
|
|
155
|
+
return yield* this.#transactions.withPermits(1)(Effect.try({
|
|
156
|
+
try: () => {
|
|
157
|
+
database.exec("BEGIN IMMEDIATE");
|
|
158
|
+
try {
|
|
159
|
+
const acceptedObservations = [];
|
|
160
|
+
for (const { metadata, source } of observations) {
|
|
161
|
+
const changed = database.prepare(`INSERT INTO connect_agent_relationships
|
|
162
|
+
(agent_id, host, pane_id, parent_agent_id, relation, observed_at, source)
|
|
163
|
+
VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
164
|
+
ON CONFLICT(host, agent_id) DO UPDATE SET
|
|
165
|
+
parent_agent_id = excluded.parent_agent_id,
|
|
166
|
+
relation = excluded.relation,
|
|
167
|
+
observed_at = excluded.observed_at,
|
|
168
|
+
source = CASE
|
|
169
|
+
WHEN connect_agent_relationships.source = 'trusted_live_inventory'
|
|
170
|
+
AND excluded.source = 'durable_worker'
|
|
171
|
+
AND connect_agent_relationships.parent_agent_id IS excluded.parent_agent_id
|
|
172
|
+
AND connect_agent_relationships.relation IS excluded.relation
|
|
173
|
+
THEN connect_agent_relationships.source
|
|
174
|
+
ELSE excluded.source
|
|
175
|
+
END
|
|
176
|
+
WHERE connect_agent_relationships.pane_id = excluded.pane_id
|
|
177
|
+
AND (
|
|
178
|
+
(
|
|
179
|
+
connect_agent_relationships.parent_agent_id IS excluded.parent_agent_id
|
|
180
|
+
AND connect_agent_relationships.relation IS excluded.relation
|
|
181
|
+
AND excluded.observed_at >= connect_agent_relationships.observed_at
|
|
182
|
+
)
|
|
183
|
+
OR (
|
|
184
|
+
? = 'trusted_live_inventory'
|
|
185
|
+
AND excluded.observed_at > connect_agent_relationships.observed_at
|
|
186
|
+
)
|
|
187
|
+
)
|
|
188
|
+
RETURNING agent_id, host, pane_id, parent_agent_id, relation, observed_at, source`).get(metadata.agentId, metadata.host, metadata.paneId, metadata.relationship?.parentAgentId ?? null, metadata.relationship?.relation ?? null, metadata.observedAt, source, source);
|
|
189
|
+
const currentObservation = decodeRowSync(changed ?? database.prepare(`SELECT agent_id, host, pane_id, parent_agent_id, relation, observed_at, source
|
|
190
|
+
FROM connect_agent_relationships
|
|
191
|
+
WHERE host = ? AND agent_id = ?`).get(metadata.host, metadata.agentId));
|
|
192
|
+
const current = currentObservation.metadata;
|
|
193
|
+
const staleDurableLoser = source === "durable_worker" &&
|
|
194
|
+
currentObservation.source === "trusted_live_inventory" &&
|
|
195
|
+
current.paneId === metadata.paneId &&
|
|
196
|
+
current.observedAt > metadata.observedAt &&
|
|
197
|
+
!sameMetadata(current, metadata);
|
|
198
|
+
if (!staleDurableLoser)
|
|
199
|
+
acceptedObservations.push({ metadata, source });
|
|
200
|
+
}
|
|
201
|
+
const persisted = listUnlockedSync(database);
|
|
202
|
+
const finalObservations = new Map();
|
|
203
|
+
for (const { metadata } of acceptedObservations) {
|
|
204
|
+
finalObservations.set(`${metadata.host.toLowerCase()}\u0000${metadata.agentId}`, metadata);
|
|
205
|
+
}
|
|
206
|
+
for (const metadata of finalObservations.values()) {
|
|
207
|
+
const current = persisted.find((candidate) => candidate.agentId === metadata.agentId &&
|
|
208
|
+
candidate.host.toLowerCase() === metadata.host.toLowerCase());
|
|
209
|
+
if (current === undefined || !sameMetadata(current, metadata)) {
|
|
210
|
+
throw new ConnectRelationshipError({
|
|
211
|
+
detail: `agent ${metadata.agentId} already has different relationship ownership`,
|
|
212
|
+
reason: "ambiguous_ownership"
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
const violation = connectRelationshipViolation(persisted.map(({ agentId: id, host, relationship }) => relationship === undefined ? { host, id } : { host, id, relationship }));
|
|
217
|
+
if (violation !== undefined)
|
|
218
|
+
throw violation;
|
|
219
|
+
database.exec("COMMIT");
|
|
220
|
+
return persisted;
|
|
221
|
+
}
|
|
222
|
+
catch (cause) {
|
|
223
|
+
database.exec("ROLLBACK");
|
|
224
|
+
throw cause;
|
|
225
|
+
}
|
|
226
|
+
},
|
|
227
|
+
catch: (cause) => isRelationshipPersistenceFailure(cause)
|
|
228
|
+
? cause
|
|
229
|
+
: storeError("persist.transaction")(cause)
|
|
230
|
+
}));
|
|
231
|
+
});
|
|
232
|
+
list = Effect.fn("AgentRelationshipStore.list")(function* () {
|
|
233
|
+
return yield* this.#transactions.withPermits(1)(this.listUnlocked());
|
|
234
|
+
});
|
|
235
|
+
listUnlocked() {
|
|
236
|
+
const database = this.#database;
|
|
237
|
+
return Effect.try({
|
|
238
|
+
try: () => listUnlockedSync(database),
|
|
239
|
+
catch: storeError("list")
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
close() {
|
|
243
|
+
this.#database.close();
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
//# sourceMappingURL=relationship-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relationship-store.js","sourceRoot":"","sources":["../src/relationship-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MA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