@makine/cli 0.1.5 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/baseline/command.d.ts +30 -0
- package/dist/baseline/command.d.ts.map +1 -0
- package/dist/baseline/command.js +185 -0
- package/dist/baseline/command.js.map +1 -0
- package/dist/contracts/command.d.ts +29 -0
- package/dist/contracts/command.d.ts.map +1 -0
- package/dist/contracts/command.js +327 -0
- package/dist/contracts/command.js.map +1 -0
- package/dist/index.d.ts +15 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +207 -49
- package/dist/index.js.map +1 -1
- package/dist/login/command.d.ts +20 -0
- package/dist/login/command.d.ts.map +1 -0
- package/dist/login/command.js +119 -0
- package/dist/login/command.js.map +1 -0
- package/dist/main.js +4 -7
- package/dist/main.js.map +1 -1
- package/dist/migrate/command.d.ts +4 -12
- package/dist/migrate/command.d.ts.map +1 -1
- package/dist/migrate/command.js +28 -83
- package/dist/migrate/command.js.map +1 -1
- package/dist/migrate/credentials.d.ts +5 -14
- package/dist/migrate/credentials.d.ts.map +1 -1
- package/dist/migrate/credentials.js +5 -14
- package/dist/migrate/credentials.js.map +1 -1
- package/dist/migrate/litellm.d.ts +3 -8
- package/dist/migrate/litellm.d.ts.map +1 -1
- package/dist/migrate/litellm.js +11 -21
- package/dist/migrate/litellm.js.map +1 -1
- package/dist/migrate/paths.d.ts +2 -7
- package/dist/migrate/paths.d.ts.map +1 -1
- package/dist/migrate/paths.js +11 -37
- package/dist/migrate/paths.js.map +1 -1
- package/dist/migrate/portkey.d.ts +6 -16
- package/dist/migrate/portkey.d.ts.map +1 -1
- package/dist/migrate/portkey.js +19 -40
- package/dist/migrate/portkey.js.map +1 -1
- package/dist/migrate/render.d.ts +5 -13
- package/dist/migrate/render.d.ts.map +1 -1
- package/dist/migrate/render.js +6 -16
- package/dist/migrate/render.js.map +1 -1
- package/dist/migrate/runtime-rules.d.ts +14 -28
- package/dist/migrate/runtime-rules.d.ts.map +1 -1
- package/dist/migrate/runtime-rules.js +27 -54
- package/dist/migrate/runtime-rules.js.map +1 -1
- package/dist/migrate/translate.d.ts +14 -30
- package/dist/migrate/translate.d.ts.map +1 -1
- package/dist/migrate/translate.js +24 -52
- package/dist/migrate/translate.js.map +1 -1
- package/dist/migrate/types.d.ts +4 -10
- package/dist/migrate/types.d.ts.map +1 -1
- package/dist/migrate/types.js +2 -5
- package/dist/migrate/types.js.map +1 -1
- package/dist/session-store.d.ts +29 -0
- package/dist/session-store.d.ts.map +1 -0
- package/dist/session-store.js +78 -0
- package/dist/session-store.js.map +1 -0
- package/package.json +6 -2
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/**
|
|
3
|
+
* Where `makine login` keeps its token (ADR 0009 § `makine login`, step 6).
|
|
4
|
+
*
|
|
5
|
+
* The directory is `0700` and the file is created `0600`, because the token is a 30-day credential
|
|
6
|
+
* for the member's whole workspace. The file also records the base URL the token was minted
|
|
7
|
+
* against, and the CLI refuses to send it anywhere else — a stored credential that follows
|
|
8
|
+
* `MAKINE_BASE_URL` around would hand one deployment's token to another.
|
|
9
|
+
*/
|
|
10
|
+
import { chmodSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
11
|
+
import { homedir } from "node:os";
|
|
12
|
+
import { join } from "node:path";
|
|
13
|
+
export const SESSION_DIRECTORY_NAME = ".makine";
|
|
14
|
+
export const SESSION_FILE_NAME = "session";
|
|
15
|
+
/**
|
|
16
|
+
* Trailing slashes and a default port are not identity, so they are folded away before two base
|
|
17
|
+
* URLs are compared. Anything that does not parse compares only as itself.
|
|
18
|
+
*/
|
|
19
|
+
export function normalizeBaseUrl(raw) {
|
|
20
|
+
try {
|
|
21
|
+
const url = new URL(raw);
|
|
22
|
+
const path = url.pathname.replace(/\/+$/, "");
|
|
23
|
+
return `${url.origin}${path}`;
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return raw.replace(/\/+$/, "");
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export function sessionDirectory(io) {
|
|
30
|
+
return join(io.env.HOME ?? homedir(), SESSION_DIRECTORY_NAME);
|
|
31
|
+
}
|
|
32
|
+
export function sessionFilePath(io) {
|
|
33
|
+
return join(sessionDirectory(io), SESSION_FILE_NAME);
|
|
34
|
+
}
|
|
35
|
+
export function readStoredSession(io) {
|
|
36
|
+
let raw;
|
|
37
|
+
try {
|
|
38
|
+
raw = readFileSync(sessionFilePath(io), "utf8");
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
try {
|
|
44
|
+
const parsed = JSON.parse(raw);
|
|
45
|
+
if (typeof parsed !== "object" || parsed === null)
|
|
46
|
+
return undefined;
|
|
47
|
+
const session = parsed;
|
|
48
|
+
if (typeof session.token !== "string" || session.token.length === 0)
|
|
49
|
+
return undefined;
|
|
50
|
+
if (typeof session.base_url !== "string" || session.base_url.length === 0)
|
|
51
|
+
return undefined;
|
|
52
|
+
return session;
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
export function writeStoredSession(io, session) {
|
|
59
|
+
const directory = sessionDirectory(io);
|
|
60
|
+
mkdirSync(directory, { recursive: true, mode: 0o700 });
|
|
61
|
+
// `mkdirSync`'s mode is masked by the process umask and is ignored when the directory already
|
|
62
|
+
// exists, so the mode is set again rather than assumed.
|
|
63
|
+
chmodSync(directory, 0o700);
|
|
64
|
+
const path = sessionFilePath(io);
|
|
65
|
+
writeFileSync(path, `${JSON.stringify(session, null, 2)}\n`, { mode: 0o600 });
|
|
66
|
+
chmodSync(path, 0o600);
|
|
67
|
+
}
|
|
68
|
+
export function deleteStoredSession(io) {
|
|
69
|
+
rmSync(sessionFilePath(io), { force: true });
|
|
70
|
+
}
|
|
71
|
+
/** The stored token, but only when it was minted against the base URL about to be called. */
|
|
72
|
+
export function storedSessionFor(io, baseUrl) {
|
|
73
|
+
const session = readStoredSession(io);
|
|
74
|
+
if (session === undefined)
|
|
75
|
+
return undefined;
|
|
76
|
+
return { session, matches: normalizeBaseUrl(session.base_url) === normalizeBaseUrl(baseUrl) };
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=session-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-store.js","sourceRoot":"","sources":["../src/session-store.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAE9B;;;;;;;GAOG;AAEH,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACpF,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,MAAM,CAAC,MAAM,sBAAsB,GAAG,SAAS,CAAC;AAChD,MAAM,CAAC,MAAM,iBAAiB,GAAG,SAAS,CAAC;AAe3C;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,GAAW;IAC1C,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QACzB,MAAM,IAAI,GAAG,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAC9C,OAAO,GAAG,GAAG,CAAC,MAAM,GAAG,IAAI,EAAE,CAAC;IAChC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACjC,CAAC;AACH,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,EAAkB;IACjD,OAAO,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,IAAI,OAAO,EAAE,EAAE,sBAAsB,CAAC,CAAC;AAChE,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,EAAkB;IA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AG,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IAC9E,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AACzB,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,EAAkB;IACpD,MAAM,CAAC,eAAe,CAAC,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC/C,CAAC;AAED,6FAA6F;AAC7F,MAAM,UAAU,gBAAgB,CAC9B,EAAkB,EAClB,OAAe;IAEf,MAAM,OAAO,GAAG,iBAAiB,CAAC,EAAE,CAAC,CAAC;IACtC,IAAI,OAAO,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC5C,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,gBAAgB,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,gBAAgB,CAAC,OAAO,CAAC,EAAE,CAAC;AAChG,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@makine/cli",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "The makine command line: send a prompt to a Makine Gateway, list its models, and translate a Portkey or LiteLLM config into makine.env settings.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/OsmanBaytaroglu/Makine-AI.git"
|
|
9
|
+
},
|
|
6
10
|
"type": "module",
|
|
7
11
|
"main": "./dist/index.js",
|
|
8
12
|
"types": "./dist/index.d.ts",
|
|
@@ -22,7 +26,7 @@
|
|
|
22
26
|
"access": "public"
|
|
23
27
|
},
|
|
24
28
|
"dependencies": {
|
|
25
|
-
"@makine/sdk": "0.1
|
|
29
|
+
"@makine/sdk": "0.2.1",
|
|
26
30
|
"yaml": "2.9.0"
|
|
27
31
|
},
|
|
28
32
|
"devDependencies": {
|