@nosana/api 2.12.0 → 2.13.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/README.md +35 -0
- package/dist/client/createClient.d.ts +5 -3
- package/dist/client/createClient.d.ts.map +1 -1
- package/dist/client/createClient.js +4 -2
- package/dist/client/createClient.js.map +1 -1
- package/dist/client/deployment-manager/schema.d.ts +166 -100
- package/dist/client/deployment-manager/schema.d.ts.map +1 -1
- package/dist/client/index.d.ts +1 -0
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +1 -0
- package/dist/client/index.js.map +1 -1
- package/dist/client/node/index.d.ts +23 -0
- package/dist/client/node/index.d.ts.map +1 -0
- package/dist/client/node/index.js +24 -0
- package/dist/client/node/index.js.map +1 -0
- package/dist/defaults/index.d.ts.map +1 -1
- package/dist/defaults/index.js +3 -0
- package/dist/defaults/index.js.map +1 -1
- package/dist/index.d.ts +18 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -3
- package/dist/index.js.map +1 -1
- package/dist/routes/auth/index.d.ts.map +1 -1
- package/dist/routes/auth/index.js +12 -0
- package/dist/routes/auth/index.js.map +1 -1
- package/dist/routes/auth/types.d.ts +8 -0
- package/dist/routes/auth/types.d.ts.map +1 -1
- package/dist/routes/deployments/deployment/actions/deploymentAddSshKeys.d.ts +9 -0
- package/dist/routes/deployments/deployment/actions/deploymentAddSshKeys.d.ts.map +1 -0
- package/dist/routes/deployments/deployment/actions/deploymentAddSshKeys.js +17 -0
- package/dist/routes/deployments/deployment/actions/deploymentAddSshKeys.js.map +1 -0
- package/dist/routes/deployments/deployment/actions/deploymentGetSshKeys.d.ts +7 -0
- package/dist/routes/deployments/deployment/actions/deploymentGetSshKeys.d.ts.map +1 -0
- package/dist/routes/deployments/deployment/actions/deploymentGetSshKeys.js +14 -0
- package/dist/routes/deployments/deployment/actions/deploymentGetSshKeys.js.map +1 -0
- package/dist/routes/deployments/deployment/actions/deploymentRemoveSshKeys.d.ts +9 -0
- package/dist/routes/deployments/deployment/actions/deploymentRemoveSshKeys.d.ts.map +1 -0
- package/dist/routes/deployments/deployment/actions/deploymentRemoveSshKeys.js +17 -0
- package/dist/routes/deployments/deployment/actions/deploymentRemoveSshKeys.js.map +1 -0
- package/dist/routes/deployments/deployment/actions/deploymentStream.d.ts.map +1 -1
- package/dist/routes/deployments/deployment/actions/deploymentStream.js +10 -30
- package/dist/routes/deployments/deployment/actions/deploymentStream.js.map +1 -1
- package/dist/routes/deployments/deployment/actions/index.d.ts +3 -0
- package/dist/routes/deployments/deployment/actions/index.d.ts.map +1 -1
- package/dist/routes/deployments/deployment/actions/index.js +3 -0
- package/dist/routes/deployments/deployment/actions/index.js.map +1 -1
- package/dist/routes/deployments/deployment/createDeployment.d.ts.map +1 -1
- package/dist/routes/deployments/deployment/createDeployment.js +68 -12
- package/dist/routes/deployments/deployment/createDeployment.js.map +1 -1
- package/dist/routes/deployments/types.d.ts +44 -10
- package/dist/routes/deployments/types.d.ts.map +1 -1
- package/dist/routes/index.d.ts +1 -0
- package/dist/routes/index.d.ts.map +1 -1
- package/dist/routes/index.js +1 -0
- package/dist/routes/index.js.map +1 -1
- package/dist/routes/jobs/index.d.ts +8 -2
- package/dist/routes/jobs/index.d.ts.map +1 -1
- package/dist/routes/jobs/index.js +64 -14
- package/dist/routes/jobs/index.js.map +1 -1
- package/dist/routes/jobs/types.d.ts +17 -1
- package/dist/routes/jobs/types.d.ts.map +1 -1
- package/dist/routes/node/__tests__/fixtures.d.ts +30 -0
- package/dist/routes/node/__tests__/fixtures.d.ts.map +1 -0
- package/dist/routes/node/__tests__/fixtures.js +38 -0
- package/dist/routes/node/__tests__/fixtures.js.map +1 -0
- package/dist/routes/node/actions/authorization.d.ts +4 -0
- package/dist/routes/node/actions/authorization.d.ts.map +1 -0
- package/dist/routes/node/actions/authorization.js +9 -0
- package/dist/routes/node/actions/authorization.js.map +1 -0
- package/dist/routes/node/actions/nodeInfo.d.ts +4 -0
- package/dist/routes/node/actions/nodeInfo.d.ts.map +1 -0
- package/dist/routes/node/actions/nodeInfo.js +9 -0
- package/dist/routes/node/actions/nodeInfo.js.map +1 -0
- package/dist/routes/node/actions/nodeJob/index.d.ts +14 -0
- package/dist/routes/node/actions/nodeJob/index.d.ts.map +1 -0
- package/dist/routes/node/actions/nodeJob/index.js +14 -0
- package/dist/routes/node/actions/nodeJob/index.js.map +1 -0
- package/dist/routes/node/actions/nodeJob/nodeJobDefinition.d.ts +4 -0
- package/dist/routes/node/actions/nodeJob/nodeJobDefinition.d.ts.map +1 -0
- package/dist/routes/node/actions/nodeJob/nodeJobDefinition.js +9 -0
- package/dist/routes/node/actions/nodeJob/nodeJobDefinition.js.map +1 -0
- package/dist/routes/node/actions/nodeJob/nodeJobEndpoints.d.ts +4 -0
- package/dist/routes/node/actions/nodeJob/nodeJobEndpoints.d.ts.map +1 -0
- package/dist/routes/node/actions/nodeJob/nodeJobEndpoints.js +9 -0
- package/dist/routes/node/actions/nodeJob/nodeJobEndpoints.js.map +1 -0
- package/dist/routes/node/actions/nodeJob/nodeJobGroup.d.ts +4 -0
- package/dist/routes/node/actions/nodeJob/nodeJobGroup.d.ts.map +1 -0
- package/dist/routes/node/actions/nodeJob/nodeJobGroup.js +11 -0
- package/dist/routes/node/actions/nodeJob/nodeJobGroup.js.map +1 -0
- package/dist/routes/node/actions/nodeJob/nodeJobOperation.d.ts +3 -0
- package/dist/routes/node/actions/nodeJob/nodeJobOperation.d.ts.map +1 -0
- package/dist/routes/node/actions/nodeJob/nodeJobOperation.js +9 -0
- package/dist/routes/node/actions/nodeJob/nodeJobOperation.js.map +1 -0
- package/dist/routes/node/actions/nodeJob/nodeJobOperations.d.ts +4 -0
- package/dist/routes/node/actions/nodeJob/nodeJobOperations.d.ts.map +1 -0
- package/dist/routes/node/actions/nodeJob/nodeJobOperations.js +9 -0
- package/dist/routes/node/actions/nodeJob/nodeJobOperations.js.map +1 -0
- package/dist/routes/node/actions/nodeJob/nodeJobResults.d.ts +4 -0
- package/dist/routes/node/actions/nodeJob/nodeJobResults.d.ts.map +1 -0
- package/dist/routes/node/actions/nodeJob/nodeJobResults.js +9 -0
- package/dist/routes/node/actions/nodeJob/nodeJobResults.js.map +1 -0
- package/dist/routes/node/actions/nodeJob/nodeJobStats.d.ts +4 -0
- package/dist/routes/node/actions/nodeJob/nodeJobStats.d.ts.map +1 -0
- package/dist/routes/node/actions/nodeJob/nodeJobStats.js +9 -0
- package/dist/routes/node/actions/nodeJob/nodeJobStats.js.map +1 -0
- package/dist/routes/node/actions/nodeJob/restartNodeJobGroup.d.ts +3 -0
- package/dist/routes/node/actions/nodeJob/restartNodeJobGroup.d.ts.map +1 -0
- package/dist/routes/node/actions/nodeJob/restartNodeJobGroup.js +10 -0
- package/dist/routes/node/actions/nodeJob/restartNodeJobGroup.js.map +1 -0
- package/dist/routes/node/actions/nodeJob/restartNodeJobOperation.d.ts +3 -0
- package/dist/routes/node/actions/nodeJob/restartNodeJobOperation.d.ts.map +1 -0
- package/dist/routes/node/actions/nodeJob/restartNodeJobOperation.js +10 -0
- package/dist/routes/node/actions/nodeJob/restartNodeJobOperation.js.map +1 -0
- package/dist/routes/node/actions/nodeJob/setNodeJobDefinition.d.ts +4 -0
- package/dist/routes/node/actions/nodeJob/setNodeJobDefinition.d.ts.map +1 -0
- package/dist/routes/node/actions/nodeJob/setNodeJobDefinition.js +12 -0
- package/dist/routes/node/actions/nodeJob/setNodeJobDefinition.js.map +1 -0
- package/dist/routes/node/actions/nodeJob/stopNodeJob.d.ts +3 -0
- package/dist/routes/node/actions/nodeJob/stopNodeJob.d.ts.map +1 -0
- package/dist/routes/node/actions/nodeJob/stopNodeJob.js +11 -0
- package/dist/routes/node/actions/nodeJob/stopNodeJob.js.map +1 -0
- package/dist/routes/node/actions/nodeJob/stopNodeJobGroup.d.ts +3 -0
- package/dist/routes/node/actions/nodeJob/stopNodeJobGroup.d.ts.map +1 -0
- package/dist/routes/node/actions/nodeJob/stopNodeJobGroup.js +10 -0
- package/dist/routes/node/actions/nodeJob/stopNodeJobGroup.js.map +1 -0
- package/dist/routes/node/actions/nodeJob/stopNodeJobOperation.d.ts +3 -0
- package/dist/routes/node/actions/nodeJob/stopNodeJobOperation.d.ts.map +1 -0
- package/dist/routes/node/actions/nodeJob/stopNodeJobOperation.js +10 -0
- package/dist/routes/node/actions/nodeJob/stopNodeJobOperation.js.map +1 -0
- package/dist/routes/node/actions/nodeJobSsh/index.d.ts +4 -0
- package/dist/routes/node/actions/nodeJobSsh/index.d.ts.map +1 -0
- package/dist/routes/node/actions/nodeJobSsh/index.js +4 -0
- package/dist/routes/node/actions/nodeJobSsh/index.js.map +1 -0
- package/dist/routes/node/actions/nodeJobSsh/nodeJobSshAdd.d.ts +5 -0
- package/dist/routes/node/actions/nodeJobSsh/nodeJobSshAdd.d.ts.map +1 -0
- package/dist/routes/node/actions/nodeJobSsh/nodeJobSshAdd.js +25 -0
- package/dist/routes/node/actions/nodeJobSsh/nodeJobSshAdd.js.map +1 -0
- package/dist/routes/node/actions/nodeJobSsh/nodeJobSshKeys.d.ts +4 -0
- package/dist/routes/node/actions/nodeJobSsh/nodeJobSshKeys.d.ts.map +1 -0
- package/dist/routes/node/actions/nodeJobSsh/nodeJobSshKeys.js +12 -0
- package/dist/routes/node/actions/nodeJobSsh/nodeJobSshKeys.js.map +1 -0
- package/dist/routes/node/actions/nodeJobSsh/nodeJobSshRemove.d.ts +4 -0
- package/dist/routes/node/actions/nodeJobSsh/nodeJobSshRemove.d.ts.map +1 -0
- package/dist/routes/node/actions/nodeJobSsh/nodeJobSshRemove.js +14 -0
- package/dist/routes/node/actions/nodeJobSsh/nodeJobSshRemove.js.map +1 -0
- package/dist/routes/node/actions/nodeJobStreams/index.d.ts +3 -0
- package/dist/routes/node/actions/nodeJobStreams/index.d.ts.map +1 -0
- package/dist/routes/node/actions/nodeJobStreams/index.js +3 -0
- package/dist/routes/node/actions/nodeJobStreams/index.js.map +1 -0
- package/dist/routes/node/actions/nodeJobStreams/nodeJobInfoStream.d.ts +4 -0
- package/dist/routes/node/actions/nodeJobStreams/nodeJobInfoStream.d.ts.map +1 -0
- package/dist/routes/node/actions/nodeJobStreams/nodeJobInfoStream.js +5 -0
- package/dist/routes/node/actions/nodeJobStreams/nodeJobInfoStream.js.map +1 -0
- package/dist/routes/node/actions/nodeJobStreams/nodeJobStatsStream.d.ts +4 -0
- package/dist/routes/node/actions/nodeJobStreams/nodeJobStatsStream.d.ts.map +1 -0
- package/dist/routes/node/actions/nodeJobStreams/nodeJobStatsStream.js +6 -0
- package/dist/routes/node/actions/nodeJobStreams/nodeJobStatsStream.js.map +1 -0
- package/dist/routes/node/actions/nodeJobStreams/nodeStream.d.ts +5 -0
- package/dist/routes/node/actions/nodeJobStreams/nodeStream.d.ts.map +1 -0
- package/dist/routes/node/actions/nodeJobStreams/nodeStream.js +10 -0
- package/dist/routes/node/actions/nodeJobStreams/nodeStream.js.map +1 -0
- package/dist/routes/node/actions/nodeSocket/index.d.ts +4 -0
- package/dist/routes/node/actions/nodeSocket/index.d.ts.map +1 -0
- package/dist/routes/node/actions/nodeSocket/index.js +4 -0
- package/dist/routes/node/actions/nodeSocket/index.js.map +1 -0
- package/dist/routes/node/actions/nodeSocket/nodeJobLogs.d.ts +3 -0
- package/dist/routes/node/actions/nodeSocket/nodeJobLogs.d.ts.map +1 -0
- package/dist/routes/node/actions/nodeSocket/nodeJobLogs.js +10 -0
- package/dist/routes/node/actions/nodeSocket/nodeJobLogs.js.map +1 -0
- package/dist/routes/node/actions/nodeSocket/nodeJobStatus.d.ts +3 -0
- package/dist/routes/node/actions/nodeSocket/nodeJobStatus.d.ts.map +1 -0
- package/dist/routes/node/actions/nodeSocket/nodeJobStatus.js +5 -0
- package/dist/routes/node/actions/nodeSocket/nodeJobStatus.js.map +1 -0
- package/dist/routes/node/actions/nodeSocket/socket.d.ts +19 -0
- package/dist/routes/node/actions/nodeSocket/socket.d.ts.map +1 -0
- package/dist/routes/node/actions/nodeSocket/socket.js +38 -0
- package/dist/routes/node/actions/nodeSocket/socket.js.map +1 -0
- package/dist/routes/node/actions/terminal/grant.d.ts +21 -0
- package/dist/routes/node/actions/terminal/grant.d.ts.map +1 -0
- package/dist/routes/node/actions/terminal/grant.js +28 -0
- package/dist/routes/node/actions/terminal/grant.js.map +1 -0
- package/dist/routes/node/actions/terminal/openTerminal.d.ts +4 -0
- package/dist/routes/node/actions/terminal/openTerminal.d.ts.map +1 -0
- package/dist/routes/node/actions/terminal/openTerminal.js +22 -0
- package/dist/routes/node/actions/terminal/openTerminal.js.map +1 -0
- package/dist/routes/node/actions/terminal/session.d.ts +7 -0
- package/dist/routes/node/actions/terminal/session.d.ts.map +1 -0
- package/dist/routes/node/actions/terminal/session.js +133 -0
- package/dist/routes/node/actions/terminal/session.js.map +1 -0
- package/dist/routes/node/createNodeJob.d.ts +3 -0
- package/dist/routes/node/createNodeJob.d.ts.map +1 -0
- package/dist/routes/node/createNodeJob.js +39 -0
- package/dist/routes/node/createNodeJob.js.map +1 -0
- package/dist/routes/node/index.d.ts +8 -0
- package/dist/routes/node/index.d.ts.map +1 -0
- package/dist/routes/node/index.js +21 -0
- package/dist/routes/node/index.js.map +1 -0
- package/dist/routes/node/types.d.ts +148 -0
- package/dist/routes/node/types.d.ts.map +1 -0
- package/dist/routes/node/types.js +2 -0
- package/dist/routes/node/types.js.map +1 -0
- package/dist/types.d.ts +31 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -1
- package/dist/types.js.map +1 -1
- package/dist/utils/eventStream.d.ts +15 -0
- package/dist/utils/eventStream.d.ts.map +1 -0
- package/dist/utils/eventStream.js +36 -0
- package/dist/utils/eventStream.js.map +1 -0
- package/dist/utils/json.d.ts +3 -0
- package/dist/utils/json.d.ts.map +1 -0
- package/dist/utils/json.js +10 -0
- package/dist/utils/json.js.map +1 -0
- package/package.json +7 -3
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { tryParseJson } from '../../../../utils/json.js';
|
|
2
|
+
const WEB_SOCKET_OPEN = 1;
|
|
3
|
+
const DEFAULT_CONNECTION_TIMEOUT_MS = 10000;
|
|
4
|
+
const UNREACHABLE = 'Could not reach the node terminal.';
|
|
5
|
+
const encoder = new TextEncoder();
|
|
6
|
+
/**
|
|
7
|
+
* Drives one terminal WebSocket: sends the signed handshake once the socket
|
|
8
|
+
* opens, relays frames in both directions, and reports each status change once.
|
|
9
|
+
*/
|
|
10
|
+
export function openTerminalSession(socket, job, authorization, options) {
|
|
11
|
+
let phase = 'connecting';
|
|
12
|
+
const report = (status, detail) => options.onStatus?.(status, detail);
|
|
13
|
+
const timeout = setTimeout(() => end('error', 'The node terminal did not respond in time.'), options.timeoutMs ?? DEFAULT_CONNECTION_TIMEOUT_MS);
|
|
14
|
+
/** Ends the session once; later calls are ignored. */
|
|
15
|
+
function end(status, detail) {
|
|
16
|
+
if (phase === 'closed')
|
|
17
|
+
return;
|
|
18
|
+
phase = 'closed';
|
|
19
|
+
clearTimeout(timeout);
|
|
20
|
+
options.signal?.removeEventListener('abort', close);
|
|
21
|
+
socket.onopen = socket.onmessage = socket.onclose = socket.onerror = null;
|
|
22
|
+
closeQuietly(socket);
|
|
23
|
+
report(status, detail);
|
|
24
|
+
}
|
|
25
|
+
function close() {
|
|
26
|
+
end('closed');
|
|
27
|
+
}
|
|
28
|
+
function connected() {
|
|
29
|
+
if (phase !== 'connecting')
|
|
30
|
+
return;
|
|
31
|
+
phase = 'connected';
|
|
32
|
+
clearTimeout(timeout);
|
|
33
|
+
report('connected');
|
|
34
|
+
}
|
|
35
|
+
function send(frame) {
|
|
36
|
+
if (socket.readyState === WEB_SOCKET_OPEN)
|
|
37
|
+
socket.send(JSON.stringify(frame));
|
|
38
|
+
}
|
|
39
|
+
/** Terminal output; the first frame of any kind means the node accepted the session. */
|
|
40
|
+
function deliver(bytes) {
|
|
41
|
+
if (phase === 'closed')
|
|
42
|
+
return;
|
|
43
|
+
connected();
|
|
44
|
+
options.onData(bytes);
|
|
45
|
+
}
|
|
46
|
+
function receive(frame) {
|
|
47
|
+
if (frame.kind === 'error') {
|
|
48
|
+
end('error', frame.message);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (frame.kind === 'data') {
|
|
52
|
+
deliver(frame.bytes);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
connected();
|
|
56
|
+
if (frame.kind === 'exit')
|
|
57
|
+
options.onExit?.(frame.code);
|
|
58
|
+
}
|
|
59
|
+
socket.binaryType = 'arraybuffer';
|
|
60
|
+
socket.onopen = () => socket.send(JSON.stringify({
|
|
61
|
+
path: '/terminal',
|
|
62
|
+
body: {
|
|
63
|
+
jobAddress: job,
|
|
64
|
+
message: authorization.message,
|
|
65
|
+
signature: authorization.signature,
|
|
66
|
+
op: options.op,
|
|
67
|
+
cols: options.cols,
|
|
68
|
+
rows: options.rows,
|
|
69
|
+
},
|
|
70
|
+
}));
|
|
71
|
+
socket.onmessage = (event) => {
|
|
72
|
+
if (typeof event.data === 'string') {
|
|
73
|
+
receive(parseTextFrame(event.data));
|
|
74
|
+
}
|
|
75
|
+
else if (typeof Blob !== 'undefined' && event.data instanceof Blob) {
|
|
76
|
+
void event.data.arrayBuffer().then((buffer) => deliver(new Uint8Array(buffer)));
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
const bytes = viewBytes(event.data);
|
|
80
|
+
if (bytes)
|
|
81
|
+
deliver(bytes);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
socket.onclose = (event) => {
|
|
85
|
+
const abnormal = event.code >= 3000 || event.code === 1006 || event.code === 1011;
|
|
86
|
+
end(abnormal ? 'error' : 'closed', event.reason || (abnormal ? UNREACHABLE : undefined));
|
|
87
|
+
};
|
|
88
|
+
socket.onerror = () => end('error', UNREACHABLE);
|
|
89
|
+
options.signal?.addEventListener('abort', close, { once: true });
|
|
90
|
+
report('connecting');
|
|
91
|
+
return {
|
|
92
|
+
authorization,
|
|
93
|
+
socket,
|
|
94
|
+
sendInput: (data) => send({ type: 'stdin', data }),
|
|
95
|
+
resize: (cols, rows) => send({ type: 'resize', cols, rows }),
|
|
96
|
+
close,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
/** Text frames are JSON control messages; anything that is not JSON is terminal output. */
|
|
100
|
+
function parseTextFrame(text) {
|
|
101
|
+
const payload = tryParseJson(text);
|
|
102
|
+
if (payload === undefined)
|
|
103
|
+
return { kind: 'data', bytes: encoder.encode(text) };
|
|
104
|
+
if (typeof payload !== 'object' || payload === null || Array.isArray(payload)) {
|
|
105
|
+
return { kind: 'control' };
|
|
106
|
+
}
|
|
107
|
+
const frame = payload;
|
|
108
|
+
if (frame.type === 'error') {
|
|
109
|
+
const message = typeof frame.message === 'string' ? frame.message : undefined;
|
|
110
|
+
return { kind: 'error', message: message ?? 'Terminal connection failed.' };
|
|
111
|
+
}
|
|
112
|
+
if (frame.type === 'exit') {
|
|
113
|
+
return { kind: 'exit', code: typeof frame.code === 'number' ? frame.code : null };
|
|
114
|
+
}
|
|
115
|
+
return { kind: 'control' };
|
|
116
|
+
}
|
|
117
|
+
function viewBytes(data) {
|
|
118
|
+
if (data instanceof ArrayBuffer)
|
|
119
|
+
return new Uint8Array(data);
|
|
120
|
+
if (ArrayBuffer.isView(data)) {
|
|
121
|
+
return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
|
|
122
|
+
}
|
|
123
|
+
return undefined;
|
|
124
|
+
}
|
|
125
|
+
function closeQuietly(socket) {
|
|
126
|
+
try {
|
|
127
|
+
socket.close();
|
|
128
|
+
}
|
|
129
|
+
catch {
|
|
130
|
+
// Already closing or closed.
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../../../../src/routes/node/actions/terminal/session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;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I,EAAE,CAAC;IACpF,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;AAC7B,CAAC;AAED,SAAS,SAAS,CAAC,IAAa;IAC9B,IAAI,IAAI,YAAY,WAAW;QAAE,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;IAC7D,IAAI,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;QAC7B,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IACvE,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,YAAY,CAAC,MAAiB;IACrC,IAAI,CAAC;QACH,MAAM,CAAC,KAAK,EAAE,CAAC;IACjB,CAAC;IAAC,MAAM,CAAC;QACP,6BAA6B;IAC/B,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createNodeJob.d.ts","sourceRoot":"","sources":["../../../src/routes/node/createNodeJob.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE7D,wBAAgB,aAAa,CAAC,OAAO,EAAE,cAAc,GAAG,UAAU,CAgCjE"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { createSshCommand } from '@nosana/ssh';
|
|
2
|
+
import { nodeJobDefinition, nodeJobEndpoints, nodeJobGroup, nodeJobOperation, nodeJobOperations, nodeJobResults, nodeJobStats, restartNodeJobGroup, restartNodeJobOperation, setNodeJobDefinition, stopNodeJob, stopNodeJobGroup, stopNodeJobOperation, } from './actions/nodeJob/index.js';
|
|
3
|
+
import { nodeJobSshAdd, nodeJobSshKeys, nodeJobSshRemove } from './actions/nodeJobSsh/index.js';
|
|
4
|
+
import { nodeJobInfoStream, nodeJobStatsStream } from './actions/nodeJobStreams/index.js';
|
|
5
|
+
import { nodeJobLogs, nodeJobStatus } from './actions/nodeSocket/index.js';
|
|
6
|
+
import { openNodeJobTerminal } from './actions/terminal/openTerminal.js';
|
|
7
|
+
export function createNodeJob(context) {
|
|
8
|
+
const { client, job, node } = context;
|
|
9
|
+
const target = { job, node, nodeDomain: context.domain };
|
|
10
|
+
return {
|
|
11
|
+
address: job,
|
|
12
|
+
node,
|
|
13
|
+
definition: () => nodeJobDefinition(client, job),
|
|
14
|
+
setDefinition: (definition) => setNodeJobDefinition(client, job, definition),
|
|
15
|
+
results: () => nodeJobResults(client, job),
|
|
16
|
+
operations: () => nodeJobOperations(client, job),
|
|
17
|
+
operation: (op) => nodeJobOperation(client, job, op),
|
|
18
|
+
group: (group) => nodeJobGroup(client, job, group),
|
|
19
|
+
restartGroup: (group) => restartNodeJobGroup(client, job, group),
|
|
20
|
+
restartOperation: (group, op) => restartNodeJobOperation(client, job, group, op),
|
|
21
|
+
stopGroup: (group) => stopNodeJobGroup(client, job, group),
|
|
22
|
+
stopOperation: (group, op) => stopNodeJobOperation(client, job, group, op),
|
|
23
|
+
stop: () => stopNodeJob(client, job),
|
|
24
|
+
endpoints: () => nodeJobEndpoints(client, job),
|
|
25
|
+
stats: (query) => nodeJobStats(client, job, query),
|
|
26
|
+
streamInfo: (handlers) => nodeJobInfoStream(client, job, handlers),
|
|
27
|
+
streamStats: (handlers, query) => nodeJobStatsStream(client, job, handlers, query),
|
|
28
|
+
logs: (handlers, filter, options) => nodeJobLogs(context, handlers, filter, options),
|
|
29
|
+
status: (handlers, options) => nodeJobStatus(context, handlers, options),
|
|
30
|
+
ssh: {
|
|
31
|
+
keys: (options) => nodeJobSshKeys(client, job, options),
|
|
32
|
+
add: (publicKey, options) => nodeJobSshAdd(client, job, publicKey, options),
|
|
33
|
+
remove: (publicKey, options) => nodeJobSshRemove(client, job, publicKey, options),
|
|
34
|
+
command: (options) => createSshCommand(target, options),
|
|
35
|
+
},
|
|
36
|
+
terminal: (options) => openNodeJobTerminal(context, options),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=createNodeJob.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createNodeJob.js","sourceRoot":"","sources":["../../../src/routes/node/createNodeJob.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACd,YAAY,EACZ,mBAAmB,EACnB,uBAAuB,EACvB,oBAAoB,EACpB,WAAW,EACX,gBAAgB,EAChB,oBAAoB,GACrB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAChG,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAC1F,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAIzE,MAAM,UAAU,aAAa,CAAC,OAAuB;IACnD,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;IACtC,MAAM,MAAM,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC;IAEzD,OAAO;QACL,OAAO,EAAE,GAAG;QACZ,IAAI;QACJ,UAAU,EAAE,GAAG,EAAE,CAAC,iBAAiB,CAAC,MAAM,EAAE,GAAG,CAAC;QAChD,aAAa,EAAE,CAAC,UAAU,EAAE,EAAE,CAAC,oBAAoB,CAAC,MAAM,EAAE,GAAG,EAAE,UAAU,CAAC;QAC5E,OAAO,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,MAAM,EAAE,GAAG,CAAC;QAC1C,UAAU,EAAE,GAAG,EAAE,CA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W,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC;QACpF,MAAM,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,CAAC,aAAa,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC;QACxE,GAAG,EAAE;YACH,IAAI,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,cAAc,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,CAAC;YACvD,GAAG,EAAE,CAAC,SAAS,EAAE,OAAO,EAAE,EAAE,CAAC,aAAa,CAAC,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,OAAO,CAAC;YAC3E,MAAM,EAAE,CAAC,SAAS,EAAE,OAAO,EAAE,EAAE,CAAC,gBAAgB,CAAC,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,OAAO,CAAC;YACjF,OAAO,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,gBAAgB,CAAC,MAAM,EAAE,OAAO,CAAC;SACxD;QACD,QAAQ,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC;KAC7D,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { NodeRouteDeps, NosanaNodeApi } from './types.js';
|
|
2
|
+
export type * from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Talks to nodes directly. Each node runs the same API on its own host, checks
|
|
5
|
+
* the job owner's wallet signature, and knows only about the jobs it runs.
|
|
6
|
+
*/
|
|
7
|
+
export declare function createNosanaNodeApi({ environment, authParams, options }: NodeRouteDeps): NosanaNodeApi;
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/routes/node/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAW,aAAa,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAExE,mBAAmB,YAAY,CAAC;AAEhC;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE,aAAa,GAAG,aAAa,CActG"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { createNodeClient, nodeDomain } from '../../client/node/index.js';
|
|
2
|
+
import { nodeInfo } from './actions/nodeInfo.js';
|
|
3
|
+
import { createNodeJob } from './createNodeJob.js';
|
|
4
|
+
/**
|
|
5
|
+
* Talks to nodes directly. Each node runs the same API on its own host, checks
|
|
6
|
+
* the job owner's wallet signature, and knows only about the jobs it runs.
|
|
7
|
+
*/
|
|
8
|
+
export function createNosanaNodeApi({ environment, authParams, options }) {
|
|
9
|
+
const domain = nodeDomain(environment, options);
|
|
10
|
+
const authorize = authParams?.generate;
|
|
11
|
+
return (address) => {
|
|
12
|
+
const client = createNodeClient(environment, address, authParams, options);
|
|
13
|
+
return {
|
|
14
|
+
address,
|
|
15
|
+
url: client.connection.baseUrl,
|
|
16
|
+
info: () => nodeInfo(client),
|
|
17
|
+
job: (job) => createNodeJob({ client, environment, domain, authorize, node: address, job }),
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/routes/node/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAMnD;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,EAAiB;IACrF,MAAM,MAAM,GAAG,UAAU,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IAChD,MAAM,SAAS,GAAG,UAAU,EAAE,QAAQ,CAAC;IAEvC,OAAO,CAAC,OAAO,EAAW,EAAE;QAC1B,MAAM,MAAM,GAAG,gBAAgB,CAAC,WAAW,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;QAE3E,OAAO;YACL,OAAO;YACP,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC,OAAO;YAC9B,IAAI,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC;YAC5B,GAAG,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,aAAa,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC;SAC5F,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import type { FlowState, JobDefinition, NodeApiSchema } from '@nosana/types';
|
|
2
|
+
import type { SshCommandOptions, SshConnectionDescriptor } from '@nosana/ssh';
|
|
3
|
+
import type { NodeClient } from '../../client/node/index.js';
|
|
4
|
+
import type { CreateNosanaApiOptions, NosanaNetwork, SignedHeaderAuth, StreamLifecycleHandlers, StreamSubscription } from '../../types.js';
|
|
5
|
+
type Schemas = NodeApiSchema.components['schemas'];
|
|
6
|
+
export type NodeInfo = Schemas['NodeInfo'];
|
|
7
|
+
export type NodeJobInfo = Schemas['JobInfo'];
|
|
8
|
+
export type NodeOperationStatuses = Schemas['OperationStatuses'];
|
|
9
|
+
export type NodeJobEndpoints = Schemas['JobEndpoints'];
|
|
10
|
+
export type NodeTaskStat = Schemas['TaskStat'];
|
|
11
|
+
/** One log line from the job's task manager, as streamed over `/flog`. */
|
|
12
|
+
export type NodeTaskLog = Schemas['TaskLog'];
|
|
13
|
+
export type NodeSshAuthorization = Schemas['SshAuthorization'];
|
|
14
|
+
export type NodeSshAuthorizedKey = Schemas['SshAuthorizedKey'];
|
|
15
|
+
export type NodeSshRevocation = Schemas['SshRevocation'];
|
|
16
|
+
export interface NodeStatsQuery {
|
|
17
|
+
/** Seconds between samples. */
|
|
18
|
+
interval?: number;
|
|
19
|
+
/** Unix milliseconds. */
|
|
20
|
+
start?: number;
|
|
21
|
+
end?: number;
|
|
22
|
+
}
|
|
23
|
+
export interface NodeLogsFilter {
|
|
24
|
+
group?: string;
|
|
25
|
+
opId?: string;
|
|
26
|
+
type?: string;
|
|
27
|
+
}
|
|
28
|
+
export type NodeStreamSubscription = StreamSubscription;
|
|
29
|
+
export interface NodeStreamHandlers<T> extends StreamLifecycleHandlers {
|
|
30
|
+
onData: (data: T) => void;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Signs a message the way the API's signer does, answering with the standard
|
|
34
|
+
* `message:base58-signature` authorization string. Lets a deployment's wallet
|
|
35
|
+
* sign for its jobs, through the deployment manager, instead of the client's.
|
|
36
|
+
*/
|
|
37
|
+
export type NodeAuthorizationProvider = SignedHeaderAuth['generate'];
|
|
38
|
+
export interface NodeSshKeyOptions {
|
|
39
|
+
signal?: AbortSignal;
|
|
40
|
+
}
|
|
41
|
+
export interface NodeSshAddKeyOptions extends NodeSshKeyOptions {
|
|
42
|
+
/** Omit for access until the key is removed or the job ends. */
|
|
43
|
+
expiresAt?: Date;
|
|
44
|
+
}
|
|
45
|
+
/** SSH access to one job, mirroring `deployment.ssh`. */
|
|
46
|
+
export interface NodeJobSsh {
|
|
47
|
+
/** The keys currently allowed to reach the job, with their expiry when temporary. */
|
|
48
|
+
keys(options?: NodeSshKeyOptions): Promise<NodeSshAuthorizedKey[]>;
|
|
49
|
+
add(publicKey: string, options?: NodeSshAddKeyOptions): Promise<NodeSshAuthorization>;
|
|
50
|
+
remove(publicKey: string, options?: NodeSshKeyOptions): Promise<NodeSshRevocation>;
|
|
51
|
+
/** The `ssh` command that reaches the job; `identityFile` picks the private key to connect with. */
|
|
52
|
+
command(options?: SshCommandOptions): SshConnectionDescriptor;
|
|
53
|
+
}
|
|
54
|
+
export type TerminalStatus = 'authorizing' | 'connecting' | 'connected' | 'closed' | 'error';
|
|
55
|
+
/** A signed, short-lived permission the node checks before opening a terminal. */
|
|
56
|
+
export interface TerminalAuthorizationGrant {
|
|
57
|
+
message: string;
|
|
58
|
+
/** Base64 of the raw 64-byte signature over `message`. */
|
|
59
|
+
signature: string;
|
|
60
|
+
expiresAt: string;
|
|
61
|
+
}
|
|
62
|
+
export interface TerminalSession {
|
|
63
|
+
readonly authorization: TerminalAuthorizationGrant;
|
|
64
|
+
readonly socket: WebSocket;
|
|
65
|
+
sendInput(data: string): void;
|
|
66
|
+
resize(cols: number, rows: number): void;
|
|
67
|
+
close(): void;
|
|
68
|
+
}
|
|
69
|
+
export interface NodeSocketOptions {
|
|
70
|
+
authorizationProvider?: NodeAuthorizationProvider;
|
|
71
|
+
webSocketFactory?: (url: string) => WebSocket;
|
|
72
|
+
}
|
|
73
|
+
export interface NodeTerminalOptions extends NodeSocketOptions {
|
|
74
|
+
cols: number;
|
|
75
|
+
rows: number;
|
|
76
|
+
/** Attach to one operation of the job instead of opening a shell. */
|
|
77
|
+
op?: string;
|
|
78
|
+
/** Lifetime of the signed grant; defaults to four minutes and is capped at five. */
|
|
79
|
+
ttlMs?: number;
|
|
80
|
+
/** How long to wait for the node's first frame; defaults to ten seconds. */
|
|
81
|
+
timeoutMs?: number;
|
|
82
|
+
signal?: AbortSignal;
|
|
83
|
+
onData: (data: Uint8Array) => void;
|
|
84
|
+
onStatus?: (status: TerminalStatus, detail?: string) => void;
|
|
85
|
+
onExit?: (code: number | null) => void;
|
|
86
|
+
}
|
|
87
|
+
/** Everything the node knows about one job it runs. */
|
|
88
|
+
export interface NodeJobApi {
|
|
89
|
+
readonly address: string;
|
|
90
|
+
readonly node: string;
|
|
91
|
+
definition(): Promise<JobDefinition>;
|
|
92
|
+
/** Accepted only while the job waits for its definition. */
|
|
93
|
+
setDefinition(definition: JobDefinition): Promise<void>;
|
|
94
|
+
/** The finished flow; the node hands it over once and marks it collected. */
|
|
95
|
+
results(): Promise<FlowState>;
|
|
96
|
+
operations(): Promise<NodeOperationStatuses>;
|
|
97
|
+
operation(op: string): Promise<string>;
|
|
98
|
+
/** Status of one group's operations; the current group when none is named. */
|
|
99
|
+
group(group?: string): Promise<NodeOperationStatuses>;
|
|
100
|
+
restartGroup(group: string): Promise<void>;
|
|
101
|
+
restartOperation(group: string, op: string): Promise<void>;
|
|
102
|
+
stopGroup(group: string): Promise<void>;
|
|
103
|
+
stopOperation(group: string, op: string): Promise<void>;
|
|
104
|
+
stop(): Promise<void>;
|
|
105
|
+
endpoints(): Promise<NodeJobEndpoints>;
|
|
106
|
+
stats(query?: NodeStatsQuery): Promise<NodeTaskStat[]>;
|
|
107
|
+
/** Server-sent events: the flow and task status, whenever they change. */
|
|
108
|
+
streamInfo(handlers: NodeStreamHandlers<NodeJobInfo>): NodeStreamSubscription;
|
|
109
|
+
streamStats(handlers: NodeStreamHandlers<NodeTaskStat[]>, query?: Pick<NodeStatsQuery, 'interval'>): NodeStreamSubscription;
|
|
110
|
+
/** Task manager logs over WebSocket: history first, then live. */
|
|
111
|
+
logs(handlers: NodeStreamHandlers<NodeTaskLog>, filter?: NodeLogsFilter, options?: NodeSocketOptions): NodeStreamSubscription;
|
|
112
|
+
/** The node's state updates for this job over WebSocket. */
|
|
113
|
+
status(handlers: NodeStreamHandlers<unknown>, options?: NodeSocketOptions): NodeStreamSubscription;
|
|
114
|
+
ssh: NodeJobSsh;
|
|
115
|
+
/** Opens a web terminal into the job; progress arrives through `onStatus`. */
|
|
116
|
+
terminal(options: NodeTerminalOptions): Promise<TerminalSession>;
|
|
117
|
+
}
|
|
118
|
+
export interface NodeApi {
|
|
119
|
+
readonly address: string;
|
|
120
|
+
readonly url: string;
|
|
121
|
+
/** Public: what the node is, what it runs on and what it holds. */
|
|
122
|
+
info(): Promise<NodeInfo>;
|
|
123
|
+
job(address: string): NodeJobApi;
|
|
124
|
+
}
|
|
125
|
+
/** Addresses one node. Nothing is fetched until a method is called. */
|
|
126
|
+
export type NosanaNodeApi = (address: string) => NodeApi;
|
|
127
|
+
export interface NodeRouteDeps {
|
|
128
|
+
environment: NosanaNetwork;
|
|
129
|
+
/**
|
|
130
|
+
* Signs the `authorization` header a node verifies against the job owner. A
|
|
131
|
+
* wallet signs directly; an API-key caller uses a client-manager-backed signer.
|
|
132
|
+
*/
|
|
133
|
+
authParams: SignedHeaderAuth | undefined;
|
|
134
|
+
options?: CreateNosanaApiOptions;
|
|
135
|
+
}
|
|
136
|
+
/** What every action on one job needs, resolved once when the node is addressed. */
|
|
137
|
+
export interface NodeJobContext {
|
|
138
|
+
client: NodeClient;
|
|
139
|
+
environment: NosanaNetwork;
|
|
140
|
+
/** The domain the node answers under; also where its SSH proxy lives. */
|
|
141
|
+
domain: string;
|
|
142
|
+
/** Signs on behalf of the API's wallet; absent when none is configured. */
|
|
143
|
+
authorize: NodeAuthorizationProvider | undefined;
|
|
144
|
+
node: string;
|
|
145
|
+
job: string;
|
|
146
|
+
}
|
|
147
|
+
export {};
|
|
148
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/routes/node/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC7E,OAAO,KAAK,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAC9E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,KAAK,EACV,sBAAsB,EACtB,aAAa,EACb,gBAAgB,EAChB,uBAAuB,EACvB,kBAAkB,EACnB,MAAM,gBAAgB,CAAC;AAExB,KAAK,OAAO,GAAG,aAAa,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;AAEnD,MAAM,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAC3C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,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE,aAAa,CAAC;IAC3B;;;OAGG;IACH,UAAU,EAAE,gBAAgB,GAAG,SAAS,CAAC;IACzC,OAAO,CAAC,EAAE,sBAAsB,CAAC;CAClC;AAED,oFAAoF;AACpF,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,UAAU,CAAC;IACnB,WAAW,EAAE,aAAa,CAAC;IAC3B,yEAAyE;IACzE,MAAM,EAAE,MAAM,CAAC;IACf,2EAA2E;IAC3E,SAAS,EAAE,yBAAyB,GAAG,SAAS,CAAC;IACjD,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;CACb"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/routes/node/types.ts"],"names":[],"mappings":""}
|
package/dist/types.d.ts
CHANGED
|
@@ -2,8 +2,10 @@ import type { ClientManagerClient } from './client/client-manager/index.js';
|
|
|
2
2
|
import type { BlockchainIndexerClient } from './client/blockchain-indexer/index.js';
|
|
3
3
|
import type { HostManagerClient } from './client/host-manager/index.js';
|
|
4
4
|
import type { DeploymentManagerClient } from './client/deployment-manager/index.js';
|
|
5
|
+
import type { GenerateOptions } from '@nosana/authorization';
|
|
5
6
|
import { TopupVaultOptions } from './routes/deployments/types.js';
|
|
6
|
-
|
|
7
|
+
import { NosanaNetwork } from '@nosana/types';
|
|
8
|
+
export { NosanaNetwork };
|
|
7
9
|
export type { NosanaNetwork as NosanaNetworkType } from '@nosana/types';
|
|
8
10
|
export interface SolanaConfig {
|
|
9
11
|
network: string;
|
|
@@ -26,15 +28,28 @@ export type ExternalSolanaFunctions = {
|
|
|
26
28
|
};
|
|
27
29
|
export type SignerAuth = {
|
|
28
30
|
identifier: string;
|
|
29
|
-
generate:
|
|
31
|
+
generate: SignedHeaderAuth['generate'];
|
|
30
32
|
solana: ExternalSolanaFunctions;
|
|
31
33
|
};
|
|
34
|
+
/**
|
|
35
|
+
* The minimal auth a node needs. A node verifies the signed `authorization`
|
|
36
|
+
* header against the job owner's key, so only a header generator is required;
|
|
37
|
+
* `x-user-id` is optional and unused by nodes. `SignerAuth` satisfies it, and
|
|
38
|
+
* an API-key caller supplies one backed by the client manager's signing service.
|
|
39
|
+
*/
|
|
40
|
+
export type SignedHeaderAuth = {
|
|
41
|
+
identifier?: string;
|
|
42
|
+
/** Terminal grants request fresh signing without touching the normal auth cache. */
|
|
43
|
+
generate: (message: string, options?: Pick<GenerateOptions, 'skipCache'>) => Promise<string>;
|
|
44
|
+
};
|
|
32
45
|
export type CreateNosanaApiOptions = Partial<{
|
|
33
46
|
client_manager_url: string;
|
|
34
47
|
host_manager_url: string;
|
|
35
48
|
blockchain_indexer_url: string;
|
|
36
49
|
/** Under API key auth this becomes the client manager proxy's forwarding target. */
|
|
37
50
|
deployment_manager_url: string;
|
|
51
|
+
/** Domain under which every node's API answers, as `<address>.<domain>`. */
|
|
52
|
+
node_domain: string;
|
|
38
53
|
include_credentials: boolean;
|
|
39
54
|
}>;
|
|
40
55
|
export interface Config {
|
|
@@ -42,6 +57,7 @@ export interface Config {
|
|
|
42
57
|
host_manager_url: string;
|
|
43
58
|
blockchain_indexer_url: string;
|
|
44
59
|
deployment_manager_url: string;
|
|
60
|
+
node_domain: string;
|
|
45
61
|
nos_address: string;
|
|
46
62
|
}
|
|
47
63
|
/**
|
|
@@ -53,8 +69,21 @@ export interface NosanaClients {
|
|
|
53
69
|
blockchainIndexer: BlockchainIndexerClient;
|
|
54
70
|
deploymentManager: DeploymentManagerClient;
|
|
55
71
|
}
|
|
72
|
+
/** An open stream, for as long as the caller wants it. */
|
|
73
|
+
export type StreamSubscription = {
|
|
74
|
+
close: () => void;
|
|
75
|
+
};
|
|
76
|
+
/** What every stream reports besides its frames. */
|
|
77
|
+
export interface StreamLifecycleHandlers {
|
|
78
|
+
/** The stream opened, or reopened after dropping: resynchronise from here. */
|
|
79
|
+
onOpen?: () => void;
|
|
80
|
+
onError?: (error: unknown) => void;
|
|
81
|
+
}
|
|
56
82
|
export interface DeploymentRouteClients {
|
|
57
83
|
deploymentManager: DeploymentManagerClient;
|
|
84
|
+
/** Network and options a deployment needs to reach its jobs' nodes directly. */
|
|
85
|
+
environment: NosanaNetwork;
|
|
86
|
+
options?: CreateNosanaApiOptions;
|
|
58
87
|
}
|
|
59
88
|
export type DeploymentRouteClientsWithSigner = DeploymentRouteClients & {
|
|
60
89
|
solana: ExternalSolanaFunctions;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AACpF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AACpF,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAGlE,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,YAAY,EAAE,aAAa,IAAI,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAExE,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,UAAU,GAAG,MAAM,CAAA;AAE/B;;;GAGG;AACH,MAAM,MAAM,uBAAuB,GAAG;IACpC,iEAAiE;IACjE,UAAU,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAEvE,0EAA0E;IAC1E,yBAAyB,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,KAAK,OAAO,CAAC,IAAI,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AAK,EAAE,MAAM,IAAI,CAAA;CAAE,CAAC;AAEvD,oDAAoD;AACpD,MAAM,WAAW,uBAAuB;IACtC,8EAA8E;IAC9E,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CACpC;AAED,MAAM,WAAW,sBAAsB;IACrC,iBAAiB,EAAE,uBAAuB,CAAC;IAC3C,gFAAgF;IAChF,WAAW,EAAE,aAAa,CAAC;IAC3B,OAAO,CAAC,EAAE,sBAAsB,CAAC;CAClC;AAED,MAAM,MAAM,gCAAgC,GAAG,sBAAsB,GAAG;IACtE,MAAM,EAAE,uBAAuB,CAAC;CACjC,CAAA"}
|
package/dist/types.js
CHANGED
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAOA,4CAA4C;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ClientConnection } from '../client/type.utils.js';
|
|
2
|
+
import type { StreamLifecycleHandlers, StreamSubscription } from '../types.js';
|
|
3
|
+
export interface EventStreamHandlers extends StreamLifecycleHandlers {
|
|
4
|
+
/** One parsed frame. Frames that are not JSON are dropped before this. */
|
|
5
|
+
onMessage: (frame: unknown) => void;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Opens a server-sent event stream addressed and authenticated exactly as an
|
|
9
|
+
* ordinary request on the same connection. `EventSource` reconnects by itself,
|
|
10
|
+
* so errors are reported rather than thrown and `onOpen` may fire more than
|
|
11
|
+
* once. A handler that throws is swallowed with the malformed frames, the
|
|
12
|
+
* price of never letting one bad frame end the stream.
|
|
13
|
+
*/
|
|
14
|
+
export declare function openEventStream(connection: ClientConnection, path: string, handlers: EventStreamHandlers): StreamSubscription;
|
|
15
|
+
//# sourceMappingURL=eventStream.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eventStream.d.ts","sourceRoot":"","sources":["../../src/utils/eventStream.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,KAAK,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAE/E,MAAM,WAAW,mBAAoB,SAAQ,uBAAuB;IAClE,0EAA0E;IAC1E,SAAS,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CACrC;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,UAAU,EAAE,gBAAgB,EAC5B,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,mBAAmB,GAC5B,kBAAkB,CA0BpB"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { EventSource } from 'eventsource';
|
|
2
|
+
import { tryParseJson } from './json.js';
|
|
3
|
+
/**
|
|
4
|
+
* Opens a server-sent event stream addressed and authenticated exactly as an
|
|
5
|
+
* ordinary request on the same connection. `EventSource` reconnects by itself,
|
|
6
|
+
* so errors are reported rather than thrown and `onOpen` may fire more than
|
|
7
|
+
* once. A handler that throws is swallowed with the malformed frames, the
|
|
8
|
+
* price of never letting one bad frame end the stream.
|
|
9
|
+
*/
|
|
10
|
+
export function openEventStream(connection, path, handlers) {
|
|
11
|
+
const { baseUrl, headers, credentials } = connection;
|
|
12
|
+
const source = new EventSource(`${baseUrl}${path}`, {
|
|
13
|
+
fetch: async (input, init) => fetch(input, {
|
|
14
|
+
...init,
|
|
15
|
+
// Under cookie auth there are no headers to copy, so the stream has to
|
|
16
|
+
// opt into sending the cookie or it authenticates as nobody.
|
|
17
|
+
...(credentials ? { credentials } : {}),
|
|
18
|
+
headers: { ...init.headers, ...(await headers()) },
|
|
19
|
+
}),
|
|
20
|
+
});
|
|
21
|
+
source.onopen = () => handlers.onOpen?.();
|
|
22
|
+
source.onerror = (error) => handlers.onError?.(error);
|
|
23
|
+
source.onmessage = ({ data }) => {
|
|
24
|
+
const frame = tryParseJson(data);
|
|
25
|
+
if (frame === undefined)
|
|
26
|
+
return;
|
|
27
|
+
try {
|
|
28
|
+
handlers.onMessage(frame);
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
return { close: () => source.close() };
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=eventStream.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eventStream.js","sourceRoot":"","sources":["../../src/utils/eventStream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAUzC;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAC7B,UAA4B,EAC5B,IAAY,EACZ,QAA6B;IAE7B,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,UAAU,CAAC;IACrD,MAAM,MAAM,GAAG,IAAI,WAAW,CAAC,GAAG,OAAO,GAAG,IAAI,EAAE,EAAE;QAClD,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,CAC3B,KAAK,CAAC,KAAK,EAAE;YACX,GAAG,IAAI;YACP,uEAAuE;YACvE,6DAA6D;YAC7D,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACvC,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,OAAO,EAAE,CAAC,EAAE;SACnD,CAAC;KACL,CAAC,CAAC;IAEH,MAAM,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC;IAC1C,MAAM,CAAC,OAAO,GAAG,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC;IACtD,MAAM,CAAC,SAAS,GAAG,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE;QAC9B,MAAM,KAAK,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;QACjC,IAAI,KAAK,KAAK,SAAS;YAAE,OAAO;QAChC,IAAI,CAAC;YACH,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAC5B,CAAC;QAAC,MAAM,CAAC;YACP,OAAO;QACT,CAAC;IACH,CAAC,CAAC;IAEF,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,CAAC;AACzC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../src/utils/json.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAMlD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json.js","sourceRoot":"","sources":["../../src/utils/json.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nosana/api",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.13.2",
|
|
4
4
|
"description": "Nosana API module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -49,15 +49,19 @@
|
|
|
49
49
|
"@typescript-eslint/eslint-plugin": "^8.38.0",
|
|
50
50
|
"@typescript-eslint/parser": "^8.38.0",
|
|
51
51
|
"@vitest/coverage-v8": "^4.0.3",
|
|
52
|
+
"bs58": "^6.0.0",
|
|
52
53
|
"eslint": "^9.31.0",
|
|
53
54
|
"eslint-plugin-import": "^2.32.0",
|
|
54
55
|
"husky": "^9.1.7",
|
|
55
56
|
"openapi-typescript": "^7.8.0",
|
|
57
|
+
"tweetnacl": "^1.0.3",
|
|
56
58
|
"typescript": "^5.9.3",
|
|
57
59
|
"vitest": "^4.0.3"
|
|
58
60
|
},
|
|
59
61
|
"dependencies": {
|
|
60
|
-
"@nosana/
|
|
62
|
+
"@nosana/authorization": "2.13.0",
|
|
63
|
+
"@nosana/ssh": "2.13.1",
|
|
64
|
+
"@nosana/types": "2.13.0",
|
|
61
65
|
"eventsource": "^4.1.0",
|
|
62
66
|
"openapi-fetch": "^0.14.0"
|
|
63
67
|
},
|
|
@@ -65,5 +69,5 @@
|
|
|
65
69
|
"engines": {
|
|
66
70
|
"node": ">=20.18.0"
|
|
67
71
|
},
|
|
68
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "90aa04060245fd5f1b0f6bf4aea4b86776a9bfed"
|
|
69
73
|
}
|