@delali/narsil 0.2.2 → 0.2.3-next.33
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 +12 -9
- package/dist/adapters/filesystem.d.ts +1 -1
- package/dist/adapters/filesystem.mjs +1 -1
- package/dist/adapters/indexeddb.d.ts +1 -1
- package/dist/adapters/indexeddb.mjs +1 -1
- package/dist/adapters/memory.d.ts +1 -1
- package/dist/{adapters-CVqI5NBt.d.ts → adapters-79OIa4xm.d.ts} +1 -1
- package/dist/brute-force-DbHYCTc3.d.ts +8 -0
- package/dist/chunk-BFIH7OV5.mjs +185 -0
- package/dist/chunk-C6VVLMRX.mjs +63 -0
- package/dist/{chunk-UNJZ7ZDB.mjs → chunk-EMI63EXP.mjs} +33 -2
- package/dist/chunk-MFFAJ2NR.mjs +135 -0
- package/dist/chunk-OBXS7OZM.mjs +376 -0
- package/dist/{chunk-ASI6AOW2.mjs → chunk-RO4EFWE6.mjs} +7833 -3524
- package/dist/{chunk-WLR5BFL3.mjs → chunk-TEAJO7CU.mjs} +3067 -2087
- package/dist/{chunk-S7RJJMHI.mjs → chunk-WDL632CN.mjs} +699 -222
- package/dist/{chunk-BKAI2WXI.mjs → chunk-WTONLDU3.mjs} +5 -0
- package/dist/client-DQHB_swQ.d.ts +793 -0
- package/dist/client.d.ts +6 -0
- package/dist/client.mjs +843 -0
- package/dist/{config-DXypXAfN.d.ts → config-ChZ7lfqc.d.ts} +3 -3
- package/dist/direct-executor-YARCDMJF.mjs +8 -0
- package/dist/distribution/coordinator/etcd.d.ts +3 -3
- package/dist/distribution/coordinator/etcd.mjs +471 -2
- package/dist/distribution/coordinator/in-memory.d.ts +3 -3
- package/dist/distribution/coordinator/in-memory.mjs +286 -1
- package/dist/distribution/transport/grpc.d.ts +45 -0
- package/dist/distribution/transport/grpc.mjs +586 -0
- package/dist/distribution/transport/in-memory.d.ts +118 -0
- package/dist/distribution/transport/in-memory.mjs +214 -0
- package/dist/distribution/transport/tcp.d.ts +27 -0
- package/dist/distribution/transport/tcp.mjs +595 -0
- package/dist/distribution.d.ts +241 -192
- package/dist/distribution.mjs +6620 -4795
- package/dist/embeddings/openai.d.ts +1 -1
- package/dist/embeddings/openai.mjs +1 -1
- package/dist/{engine-CO9Wnfie.d.ts → engine-DScGlT2Z.d.ts} +30 -3
- package/dist/index.browser.mjs +10035 -3914
- package/dist/index.d.ts +8 -8
- package/dist/index.mjs +8 -5
- package/dist/invalidation/broadcast-channel.d.ts +1 -1
- package/dist/invalidation/filesystem.d.ts +1 -1
- package/dist/invalidation/filesystem.mjs +3 -1
- package/dist/invalidation/noop.d.ts +1 -1
- package/dist/options-BORJg5XB.d.ts +234 -0
- package/dist/persistence/durability/checkpoint-worker.d.ts +4 -2
- package/dist/persistence/durability/checkpoint-worker.mjs +8 -5
- package/dist/react.d.ts +340 -0
- package/dist/react.mjs +687 -0
- package/dist/{schema-CE6S_aAr.d.ts → schema-emTQfEiX.d.ts} +21 -7
- package/dist/{search-DLBtiPdQ.d.ts → search-CQ-9bKxo.d.ts} +226 -14
- package/dist/server.d.ts +42 -356
- package/dist/server.mjs +493 -106
- package/dist/tasks-CnMLpfk-.d.ts +274 -0
- package/dist/types-BQDlIvfS.d.ts +34 -0
- package/dist/{types-BV3nAKTL.d.ts → types-Bfhhnh3G.d.ts} +23 -1
- package/dist/types-D5OwhtsQ.d.ts +97 -0
- package/dist/vector/hnsw-build-worker.d.ts +2 -7
- package/dist/vector/hnsw-build-worker.mjs +2 -1
- package/dist/vector/search-worker.d.ts +373 -0
- package/dist/vector/search-worker.mjs +279 -0
- package/dist/workers/entry.mjs +43 -25
- package/package.json +42 -2
- package/dist/chunk-FKK76OR7.mjs +0 -456
- package/dist/chunk-RQLXC2YS.mjs +0 -269
- package/dist/direct-executor-3W4QRA4E.mjs +0 -5
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import { DEFAULT_TRANSPORT_CONFIG, TransportError, TransportErrorCodes, MAX_MESSAGE_SIZE_BYTES } from '../../chunk-C6VVLMRX.mjs';
|
|
2
|
+
|
|
3
|
+
// src/distribution/transport/in-memory.ts
|
|
4
|
+
function createInMemoryNetwork() {
|
|
5
|
+
const transports = /* @__PURE__ */ new Map();
|
|
6
|
+
return {
|
|
7
|
+
register(nodeId, transport) {
|
|
8
|
+
transports.set(nodeId, transport);
|
|
9
|
+
},
|
|
10
|
+
unregister(nodeId) {
|
|
11
|
+
transports.delete(nodeId);
|
|
12
|
+
},
|
|
13
|
+
getTransport(nodeId) {
|
|
14
|
+
return transports.get(nodeId);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function createInMemoryTransport(nodeId, network, config) {
|
|
19
|
+
const resolvedConfig = {
|
|
20
|
+
...DEFAULT_TRANSPORT_CONFIG,
|
|
21
|
+
...config
|
|
22
|
+
};
|
|
23
|
+
let listenHandler;
|
|
24
|
+
let isShutdown = false;
|
|
25
|
+
function assertNotShutdown() {
|
|
26
|
+
if (isShutdown) {
|
|
27
|
+
throw new TransportError(
|
|
28
|
+
TransportErrorCodes.PEER_UNAVAILABLE,
|
|
29
|
+
`Transport for node '${nodeId}' has been shut down`,
|
|
30
|
+
{ nodeId }
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function lookupPeer(target) {
|
|
35
|
+
const peer = network.getTransport(target);
|
|
36
|
+
if (peer === void 0) {
|
|
37
|
+
throw new TransportError(TransportErrorCodes.PEER_UNAVAILABLE, `Node '${target}' is not reachable`, { target });
|
|
38
|
+
}
|
|
39
|
+
return peer;
|
|
40
|
+
}
|
|
41
|
+
const internal = {
|
|
42
|
+
deliverMessage(message, respond) {
|
|
43
|
+
if (listenHandler === void 0) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
listenHandler(message, respond);
|
|
47
|
+
},
|
|
48
|
+
deliverStream(message, sink) {
|
|
49
|
+
if (listenHandler === void 0) {
|
|
50
|
+
sink.fail(
|
|
51
|
+
new TransportError(TransportErrorCodes.PEER_UNAVAILABLE, `Node '${nodeId}' has no listener registered`, {
|
|
52
|
+
nodeId,
|
|
53
|
+
requestId: message.requestId
|
|
54
|
+
})
|
|
55
|
+
);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
let chunkCount = 0;
|
|
59
|
+
const respond = async (response) => {
|
|
60
|
+
chunkCount++;
|
|
61
|
+
await sink.chunk(response.payload);
|
|
62
|
+
};
|
|
63
|
+
const finish = () => {
|
|
64
|
+
if (chunkCount === 0) {
|
|
65
|
+
sink.fail(
|
|
66
|
+
new TransportError(
|
|
67
|
+
TransportErrorCodes.PEER_UNAVAILABLE,
|
|
68
|
+
`Node '${nodeId}' answered the stream with no chunks`,
|
|
69
|
+
{ nodeId, requestId: message.requestId }
|
|
70
|
+
)
|
|
71
|
+
);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
sink.end();
|
|
75
|
+
};
|
|
76
|
+
try {
|
|
77
|
+
const handlerResult = listenHandler(message, respond);
|
|
78
|
+
if (handlerResult instanceof Promise) {
|
|
79
|
+
handlerResult.then(finish, (error) => {
|
|
80
|
+
sink.fail(error instanceof Error ? error : new Error(String(error)));
|
|
81
|
+
});
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
finish();
|
|
85
|
+
} catch (error) {
|
|
86
|
+
sink.fail(error instanceof Error ? error : new Error(String(error)));
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
async send(target, message) {
|
|
90
|
+
assertNotShutdown();
|
|
91
|
+
if (message.payload.byteLength > MAX_MESSAGE_SIZE_BYTES) {
|
|
92
|
+
throw new TransportError(
|
|
93
|
+
TransportErrorCodes.MESSAGE_TOO_LARGE,
|
|
94
|
+
`Message payload (${message.payload.byteLength} bytes) exceeds the ${MAX_MESSAGE_SIZE_BYTES} byte limit`,
|
|
95
|
+
{ target, requestId: message.requestId, payloadSize: message.payload.byteLength }
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
const peer = lookupPeer(target);
|
|
99
|
+
return new Promise((resolve, reject) => {
|
|
100
|
+
let settled = false;
|
|
101
|
+
const timeoutId = setTimeout(() => {
|
|
102
|
+
if (!settled) {
|
|
103
|
+
settled = true;
|
|
104
|
+
reject(
|
|
105
|
+
new TransportError(
|
|
106
|
+
TransportErrorCodes.TIMEOUT,
|
|
107
|
+
`Request to node '${target}' timed out after ${resolvedConfig.requestTimeout}ms`,
|
|
108
|
+
{ target, requestId: message.requestId, timeoutMs: resolvedConfig.requestTimeout }
|
|
109
|
+
)
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
}, resolvedConfig.requestTimeout);
|
|
113
|
+
try {
|
|
114
|
+
peer.deliverMessage(message, async (response) => {
|
|
115
|
+
if (!settled) {
|
|
116
|
+
settled = true;
|
|
117
|
+
clearTimeout(timeoutId);
|
|
118
|
+
resolve(response);
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
} catch (error) {
|
|
122
|
+
if (!settled) {
|
|
123
|
+
settled = true;
|
|
124
|
+
clearTimeout(timeoutId);
|
|
125
|
+
reject(error);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
},
|
|
130
|
+
async stream(target, message, handler) {
|
|
131
|
+
assertNotShutdown();
|
|
132
|
+
const peer = lookupPeer(target);
|
|
133
|
+
return new Promise((resolve, reject) => {
|
|
134
|
+
let settled = false;
|
|
135
|
+
const timeoutId = setTimeout(() => {
|
|
136
|
+
if (!settled) {
|
|
137
|
+
settled = true;
|
|
138
|
+
reject(
|
|
139
|
+
new TransportError(
|
|
140
|
+
TransportErrorCodes.TIMEOUT,
|
|
141
|
+
`Stream to node '${target}' timed out after ${resolvedConfig.snapshotTimeout}ms`,
|
|
142
|
+
{ target, requestId: message.requestId, timeoutMs: resolvedConfig.snapshotTimeout }
|
|
143
|
+
)
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
}, resolvedConfig.snapshotTimeout);
|
|
147
|
+
const settle = (action) => {
|
|
148
|
+
if (settled) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
settled = true;
|
|
152
|
+
clearTimeout(timeoutId);
|
|
153
|
+
action();
|
|
154
|
+
};
|
|
155
|
+
const sink = {
|
|
156
|
+
chunk(payload) {
|
|
157
|
+
if (settled) {
|
|
158
|
+
return Promise.resolve();
|
|
159
|
+
}
|
|
160
|
+
try {
|
|
161
|
+
handler(payload);
|
|
162
|
+
} catch (error) {
|
|
163
|
+
settle(() => {
|
|
164
|
+
reject(
|
|
165
|
+
new TransportError(
|
|
166
|
+
TransportErrorCodes.DECODE_FAILED,
|
|
167
|
+
`The stream chunk handler failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
168
|
+
{ target, requestId: message.requestId }
|
|
169
|
+
)
|
|
170
|
+
);
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
return Promise.resolve();
|
|
174
|
+
},
|
|
175
|
+
end() {
|
|
176
|
+
settle(resolve);
|
|
177
|
+
},
|
|
178
|
+
fail(error) {
|
|
179
|
+
settle(() => {
|
|
180
|
+
reject(error);
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
try {
|
|
185
|
+
peer.deliverStream(message, sink);
|
|
186
|
+
} catch (error) {
|
|
187
|
+
settle(() => {
|
|
188
|
+
reject(error);
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
},
|
|
193
|
+
async listen(handler) {
|
|
194
|
+
listenHandler = handler;
|
|
195
|
+
return () => {
|
|
196
|
+
if (listenHandler === handler) {
|
|
197
|
+
listenHandler = void 0;
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
},
|
|
201
|
+
async shutdown() {
|
|
202
|
+
if (isShutdown) {
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
isShutdown = true;
|
|
206
|
+
network.unregister(nodeId);
|
|
207
|
+
listenHandler = void 0;
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
network.register(nodeId, internal);
|
|
211
|
+
return internal;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export { createInMemoryNetwork, createInMemoryTransport };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { N as NodeTransport } from '../../types-D5OwhtsQ.js';
|
|
2
|
+
import { T as TcpTransportConfig, a as TlsConfig } from '../../types-BQDlIvfS.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Builds the TCP transport a cluster node reaches its peers through, with
|
|
6
|
+
* length-prefixed MessagePack frames and optional mutual TLS.
|
|
7
|
+
*
|
|
8
|
+
* The transport listens on `config.host` and `config.port`, and it dials a
|
|
9
|
+
* peer at the `host:port` address that peer registered with the coordinator.
|
|
10
|
+
* Passing `config.tls` makes every connection mutually authenticated: the
|
|
11
|
+
* server requests a client certificate and both sides verify against the
|
|
12
|
+
* configured authority.
|
|
13
|
+
*
|
|
14
|
+
* @param nodeId - The node this transport belongs to, used in error reports.
|
|
15
|
+
* @param config - The listen address, the connection limits, the timeouts,
|
|
16
|
+
* and the TLS material.
|
|
17
|
+
* @returns The transport, with `getPort` for reading the bound port and
|
|
18
|
+
* `rotateTlsContext` for renewing certificates without a restart.
|
|
19
|
+
*
|
|
20
|
+
* @public
|
|
21
|
+
*/
|
|
22
|
+
declare function createTcpTransport(nodeId: string, config?: Partial<TcpTransportConfig>): NodeTransport & {
|
|
23
|
+
getPort(): number;
|
|
24
|
+
rotateTlsContext(nextTlsConfig: TlsConfig): void;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export { TcpTransportConfig, TlsConfig, createTcpTransport };
|