motifcode 0.4.1 → 0.4.3
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 +16 -9
- package/dist/build-info.json +2 -2
- package/dist/motif.js +208 -48
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,26 +5,33 @@ A Claude Code-style terminal session — transcript above, prompt below, `/` com
|
|
|
5
5
|
a permission prompt, a `.motif/` directory behind it — whose tool set, prompt layout, parser and
|
|
6
6
|
failure handling follow from what is measurably true about Motif-3.
|
|
7
7
|
|
|
8
|
-
> **
|
|
9
|
-
>
|
|
10
|
-
>
|
|
8
|
+
> **Choose your provider.** First launch offers [Infron](https://infron.ai) or
|
|
9
|
+
> [Morphfactory (BETA)](https://cbt.morphfactory.io/console?view=keys).
|
|
10
|
+
> Switch later with `/provider` or `/config`; each provider keeps its own API key.
|
|
11
11
|
|
|
12
12
|
> **Not an official Motif project.** Not certified, endorsed, sponsored or maintained by Motif
|
|
13
13
|
> Technologies or by Infron. *Motif* and *Motif-3* are their names; this package is a client of the model.
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
16
|
cd your-project
|
|
17
|
-
npx motifcode #
|
|
17
|
+
npx motifcode # choose a provider and enter its API key once, then offers to install the `motif` command
|
|
18
18
|
```
|
|
19
19
|
|
|
20
20
|
Or `npm install -g motifcode` directly; either way `motif` (or `motifcode`) opens the session
|
|
21
21
|
from any folder afterwards, with the key saved in `~/.motif/.env`.
|
|
22
22
|
|
|
23
|
-
1.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
1. Create an API key at [Infron's dashboard](https://infron.ai/dashboard/apiKeys) or
|
|
24
|
+
[Morphfactory's console](https://cbt.morphfactory.io/console?view=keys).
|
|
25
|
+
2. Run `motif`, choose the provider and paste its key. It is checked against the endpoint,
|
|
26
|
+
saved to `~/.motif/.env` (readable only by you), and never shown to the model. Use
|
|
27
|
+
`/provider` to switch, or `/login` and `/logout` to manage the selected provider's key.
|
|
28
|
+
3. Outside a session, use `motif login --provider morphfactory` and
|
|
29
|
+
`motif doctor --provider morphfactory`. `--provider infron` selects Infron.
|
|
30
|
+
|
|
31
|
+
The environment keys are `MOTIF_API_KEY` for Infron and `MOTIF_MORPHFACTORY_API_KEY`
|
|
32
|
+
for Morphfactory. Use `--provider morphfactory` for a single invocation, or choose
|
|
33
|
+
with `/provider` to save the selection. Explicit `--endpoint` and `--model` flags
|
|
34
|
+
still override a provider preset.
|
|
28
35
|
|
|
29
36
|
```bash
|
|
30
37
|
motif # interactive session in the current directory
|
package/dist/build-info.json
CHANGED
package/dist/motif.js
CHANGED
|
@@ -48058,6 +48058,23 @@ var DEFAULT_MODEL = "motif/motif-3";
|
|
|
48058
48058
|
var ENV_ENDPOINT = "MOTIF_ENDPOINT";
|
|
48059
48059
|
var ENV_MODEL = "MOTIF_MODEL";
|
|
48060
48060
|
var ENV_API_KEY = "MOTIF_API_KEY";
|
|
48061
|
+
var ENV_MORPHFACTORY_API_KEY = "MOTIF_MORPHFACTORY_API_KEY";
|
|
48062
|
+
var PROVIDERS = {
|
|
48063
|
+
infron: {
|
|
48064
|
+
label: "Infron",
|
|
48065
|
+
endpoint: DEFAULT_ENDPOINT,
|
|
48066
|
+
model: DEFAULT_MODEL,
|
|
48067
|
+
apiKeyEnv: ENV_API_KEY,
|
|
48068
|
+
keyPage: "https://infron.ai/dashboard/apiKeys"
|
|
48069
|
+
},
|
|
48070
|
+
morphfactory: {
|
|
48071
|
+
label: "Morphfactory (BETA)",
|
|
48072
|
+
endpoint: "https://api-cbt.morphfactory.io",
|
|
48073
|
+
model: DEFAULT_MODEL,
|
|
48074
|
+
apiKeyEnv: ENV_MORPHFACTORY_API_KEY,
|
|
48075
|
+
keyPage: "https://cbt.morphfactory.io/console?view=keys"
|
|
48076
|
+
}
|
|
48077
|
+
};
|
|
48061
48078
|
function parseDotenv(text) {
|
|
48062
48079
|
const out = {};
|
|
48063
48080
|
for (const rawLine of text.split(/\r?\n/)) {
|
|
@@ -48087,6 +48104,18 @@ function isInfronEndpoint(endpoint) {
|
|
|
48087
48104
|
const origin = /^https:\/\/llm\.onerouter\.pro(?=\/|$)/i.exec(value)?.[0];
|
|
48088
48105
|
return origin !== void 0 && ["", "/", "/v1", "/v1/"].includes(value.slice(origin.length));
|
|
48089
48106
|
}
|
|
48107
|
+
function providerForEndpoint(endpoint) {
|
|
48108
|
+
if (isInfronEndpoint(endpoint)) return "infron";
|
|
48109
|
+
try {
|
|
48110
|
+
const url2 = new URL(endpoint.trim());
|
|
48111
|
+
if (url2.origin === PROVIDERS.morphfactory.endpoint && !url2.username && !url2.password && !url2.search && !url2.hash && ["/", "/v1", "/v1/"].includes(url2.pathname)) return "morphfactory";
|
|
48112
|
+
} catch {
|
|
48113
|
+
}
|
|
48114
|
+
return void 0;
|
|
48115
|
+
}
|
|
48116
|
+
function apiKeyEnvForEndpoint(endpoint) {
|
|
48117
|
+
return providerForEndpoint(endpoint) === "morphfactory" ? ENV_MORPHFACTORY_API_KEY : ENV_API_KEY;
|
|
48118
|
+
}
|
|
48090
48119
|
function defaultDotenvPaths(cwd = process.cwd()) {
|
|
48091
48120
|
return [join(cwd, ".env"), join(homedir(), ".motif", ".env")];
|
|
48092
48121
|
}
|
|
@@ -48113,9 +48142,10 @@ function resolveEndpointConfig(opts = {}) {
|
|
|
48113
48142
|
};
|
|
48114
48143
|
const endpoint = pick2(opts.flags?.endpoint, ENV_ENDPOINT, opts.defaults?.endpoint ?? DEFAULT_ENDPOINT);
|
|
48115
48144
|
const model = pick2(opts.flags?.model, ENV_MODEL, opts.defaults?.model ?? DEFAULT_MODEL);
|
|
48116
|
-
const
|
|
48145
|
+
const normalizedEndpoint = normalizeEndpoint(endpoint.value);
|
|
48146
|
+
const apiKey = pick2(void 0, apiKeyEnvForEndpoint(normalizedEndpoint), void 0);
|
|
48117
48147
|
return {
|
|
48118
|
-
endpoint:
|
|
48148
|
+
endpoint: normalizedEndpoint,
|
|
48119
48149
|
model: model.value,
|
|
48120
48150
|
...apiKey.value !== void 0 ? { apiKey: apiKey.value } : {},
|
|
48121
48151
|
sources: {
|
|
@@ -48127,6 +48157,7 @@ function resolveEndpointConfig(opts = {}) {
|
|
|
48127
48157
|
}
|
|
48128
48158
|
function withholdSecrets(env) {
|
|
48129
48159
|
delete env[ENV_API_KEY];
|
|
48160
|
+
delete env[ENV_MORPHFACTORY_API_KEY];
|
|
48130
48161
|
}
|
|
48131
48162
|
function defaultEnvPath(home = homedir()) {
|
|
48132
48163
|
return join(home, ".motif", ".env");
|
|
@@ -48150,17 +48181,17 @@ function removeDotenvKey(text, key) {
|
|
|
48150
48181
|
const out = kept.join("\n").replace(/\n+$/, "");
|
|
48151
48182
|
return out === "" ? "" : out + "\n";
|
|
48152
48183
|
}
|
|
48153
|
-
function saveApiKey(apiKey, path = defaultEnvPath()) {
|
|
48184
|
+
function saveApiKey(apiKey, path = defaultEnvPath(), provider = "infron") {
|
|
48154
48185
|
mkdirSync(dirname(path), { recursive: true, mode: 448 });
|
|
48155
48186
|
const existing = existsSync(path) ? readFileSync(path, "utf8") : "";
|
|
48156
|
-
writeFileSync(path, upsertDotenv(existing,
|
|
48187
|
+
writeFileSync(path, upsertDotenv(existing, PROVIDERS[provider].apiKeyEnv, apiKey), { encoding: "utf8", mode: 384 });
|
|
48157
48188
|
chmodSync(path, 384);
|
|
48158
48189
|
return path;
|
|
48159
48190
|
}
|
|
48160
|
-
function forgetApiKey(path = defaultEnvPath()) {
|
|
48191
|
+
function forgetApiKey(path = defaultEnvPath(), provider = "infron") {
|
|
48161
48192
|
if (!existsSync(path)) return false;
|
|
48162
48193
|
const existing = readFileSync(path, "utf8");
|
|
48163
|
-
const next = removeDotenvKey(existing,
|
|
48194
|
+
const next = removeDotenvKey(existing, PROVIDERS[provider].apiKeyEnv);
|
|
48164
48195
|
if (next === existing) return false;
|
|
48165
48196
|
writeFileSync(path, next, { encoding: "utf8", mode: 384 });
|
|
48166
48197
|
return true;
|
|
@@ -48371,7 +48402,8 @@ var HttpTransport = class {
|
|
|
48371
48402
|
const detail = text.trim().slice(0, 400);
|
|
48372
48403
|
let message2 = detail ? `${res.status} ${res.statusText} \u2014 ${detail}` : `${res.status} ${res.statusText}`;
|
|
48373
48404
|
if (res.status === 401 || res.status === 403) {
|
|
48374
|
-
|
|
48405
|
+
const keyEnv = apiKeyEnvForEndpoint(this.endpoint);
|
|
48406
|
+
message2 += this.apiKey ? ` (the endpoint rejected the API key that was sent; check ${keyEnv})` : ` (no API key was sent; set ${keyEnv} in the environment or in .env)`;
|
|
48375
48407
|
}
|
|
48376
48408
|
const retryAfterMs = res.status === 429 ? parseRetryAfter(res.headers.get("retry-after")) ?? DEFAULT_RETRY_AFTER_MS : void 0;
|
|
48377
48409
|
throw new TransportError(message2, {
|
|
@@ -48882,12 +48914,13 @@ var LoopGuard = class _LoopGuard {
|
|
|
48882
48914
|
return actions.map((a) => `${a.name}(${JSON.stringify(a.arguments)})`).join("|");
|
|
48883
48915
|
}
|
|
48884
48916
|
observe(signature, output) {
|
|
48885
|
-
|
|
48917
|
+
const sameOutput = output === this.lastOutput;
|
|
48918
|
+
if (signature !== "" && signature === this.lastSignature && sameOutput) this.repeats++;
|
|
48886
48919
|
else {
|
|
48887
48920
|
this.lastSignature = signature;
|
|
48888
48921
|
this.repeats = 1;
|
|
48889
48922
|
}
|
|
48890
|
-
if (
|
|
48923
|
+
if (sameOutput && output !== "") this.stalls++;
|
|
48891
48924
|
else {
|
|
48892
48925
|
this.lastOutput = output;
|
|
48893
48926
|
this.stalls = 0;
|
|
@@ -53633,7 +53666,7 @@ function installCommand(version2) {
|
|
|
53633
53666
|
|
|
53634
53667
|
// packages/cli/src/login.ts
|
|
53635
53668
|
import { homedir as homedir3 } from "node:os";
|
|
53636
|
-
var KEY_PAGE =
|
|
53669
|
+
var KEY_PAGE = PROVIDERS.infron.keyPage;
|
|
53637
53670
|
async function verifyApiKey(opts) {
|
|
53638
53671
|
const fetchImpl = opts.fetchImpl ?? globalThis.fetch;
|
|
53639
53672
|
const endpoint = normalizeEndpoint(opts.endpoint);
|
|
@@ -53673,15 +53706,14 @@ async function serverMessage(res) {
|
|
|
53673
53706
|
}
|
|
53674
53707
|
function normaliseKeyInput(raw) {
|
|
53675
53708
|
let s = raw.trim();
|
|
53676
|
-
s = s.replace(new RegExp(`^(?:export\\s+)
|
|
53709
|
+
s = s.replace(new RegExp(`^(?:export\\s+)?(?:${ENV_API_KEY}|${ENV_MORPHFACTORY_API_KEY})\\s*=\\s*`), "");
|
|
53677
53710
|
if (s.startsWith('"') && s.endsWith('"') || s.startsWith("'") && s.endsWith("'")) s = s.slice(1, -1);
|
|
53678
53711
|
return s.trim();
|
|
53679
53712
|
}
|
|
53680
|
-
function loginLines(envPath, home = homedir3()) {
|
|
53713
|
+
function loginLines(envPath, home = homedir3(), provider = "infron") {
|
|
53681
53714
|
const shown = envPath.startsWith(home + "/") ? `~${envPath.slice(home.length)}` : envPath;
|
|
53682
53715
|
return [
|
|
53683
|
-
`Get one at ${
|
|
53684
|
-
"Motif-3 is free there through September 2026.",
|
|
53716
|
+
`Get one at ${PROVIDERS[provider].keyPage}`,
|
|
53685
53717
|
`The key is checked with the endpoint and saved to ${shown},`,
|
|
53686
53718
|
"readable only by you and never shown to the model."
|
|
53687
53719
|
];
|
|
@@ -53827,9 +53859,15 @@ var COMMANDS = [
|
|
|
53827
53859
|
description: "probe the endpoint: auth, parsers, cache, channels",
|
|
53828
53860
|
run: async (ctx) => ok("/doctor", await ctx.doctor())
|
|
53829
53861
|
},
|
|
53862
|
+
{
|
|
53863
|
+
name: "provider",
|
|
53864
|
+
description: "choose Infron or Morphfactory (BETA)",
|
|
53865
|
+
usage: "[infron|morphfactory]",
|
|
53866
|
+
run: (ctx, args) => ctx.provider?.(args) ?? fail("/provider", "Provider selection requires an interactive session.")
|
|
53867
|
+
},
|
|
53830
53868
|
{
|
|
53831
53869
|
name: "login",
|
|
53832
|
-
description: "paste
|
|
53870
|
+
description: "paste the selected provider\u2019s API key; it is checked against the endpoint and saved to ~/.motif/.env",
|
|
53833
53871
|
run: async (ctx) => ok("/login", await ctx.login())
|
|
53834
53872
|
},
|
|
53835
53873
|
{
|
|
@@ -53854,7 +53892,9 @@ var COMMANDS = [
|
|
|
53854
53892
|
run: (ctx, args) => {
|
|
53855
53893
|
if (args === "") return ok("/endpoint", [ctx.settings.endpoint]);
|
|
53856
53894
|
if (!/^https?:\/\//.test(args)) return fail("/endpoint", `not a URL: ${args}`);
|
|
53857
|
-
|
|
53895
|
+
const endpoint = args.replace(/\/+$/, "").replace(/\/v1$/, "");
|
|
53896
|
+
if (ctx.setEndpoint) ctx.setEndpoint(endpoint);
|
|
53897
|
+
else ctx.settings.endpoint = endpoint;
|
|
53858
53898
|
return ok("/endpoint", [
|
|
53859
53899
|
`endpoint set to ${ctx.settings.endpoint} for the next task`,
|
|
53860
53900
|
...saved(ctx, "endpoint", ctx.settings.endpoint)
|
|
@@ -54191,6 +54231,7 @@ var CONFIG_FIELDS = [
|
|
|
54191
54231
|
{ key: "maxOutputTokens", label: "Max output tokens", detail: "Positive integer per model step, or off to use the server default." },
|
|
54192
54232
|
{ key: "seed", label: "Sampling seed", detail: "Integer >= 0, or off. The endpoint must support seeded sampling." },
|
|
54193
54233
|
{ key: "compactAt", label: "Compact at", detail: "Context fraction from 0.1 to 1 at which automatic compaction runs." },
|
|
54234
|
+
{ key: "provider", label: "Provider", choices: ["infron", "morphfactory"], detail: "Infron or Morphfactory (BETA). Switches endpoint, model and the provider\u2019s own API key; /login adds a missing key." },
|
|
54194
54235
|
{ key: "theme", label: "Theme", choices: Object.keys(THEMES), detail: "Terminal color palette. Applies immediately; NO_COLOR takes precedence." }
|
|
54195
54236
|
];
|
|
54196
54237
|
function configField(key) {
|
|
@@ -54843,6 +54884,7 @@ async function doctor(opts) {
|
|
|
54843
54884
|
const fetchImpl = opts.fetchImpl ?? globalThis.fetch;
|
|
54844
54885
|
const endpoint = opts.endpoint.replace(/\/+$/, "").replace(/\/v1$/, "");
|
|
54845
54886
|
const checks = [];
|
|
54887
|
+
const apiKeyEnv = apiKeyEnvForEndpoint(endpoint);
|
|
54846
54888
|
const headers = { "content-type": "application/json" };
|
|
54847
54889
|
if (opts.apiKey) headers["authorization"] = `Bearer ${opts.apiKey}`;
|
|
54848
54890
|
const sandbox = detectSandbox();
|
|
@@ -54859,7 +54901,7 @@ async function doctor(opts) {
|
|
|
54859
54901
|
name: "api key",
|
|
54860
54902
|
state: "warn",
|
|
54861
54903
|
detail: "none \u2014 requests go out unauthenticated",
|
|
54862
|
-
fix:
|
|
54904
|
+
fix: `set ${apiKeyEnv} in the environment or in a .env file (not needed for a local server without auth)`
|
|
54863
54905
|
}
|
|
54864
54906
|
);
|
|
54865
54907
|
let models = null;
|
|
@@ -54873,7 +54915,7 @@ async function doctor(opts) {
|
|
|
54873
54915
|
name: "endpoint",
|
|
54874
54916
|
state: "fail",
|
|
54875
54917
|
detail: `${endpoint} returned ${res.status}`,
|
|
54876
|
-
fix: res.status === 401 || res.status === 403 ?
|
|
54918
|
+
fix: res.status === 401 || res.status === 403 ? `the endpoint refused the credentials; check ${apiKeyEnv}` : "start the server, or point --endpoint somewhere else"
|
|
54877
54919
|
});
|
|
54878
54920
|
return checks;
|
|
54879
54921
|
}
|
|
@@ -54957,7 +54999,7 @@ async function doctor(opts) {
|
|
|
54957
54999
|
name: "authentication",
|
|
54958
55000
|
state: "fail",
|
|
54959
55001
|
detail: `the endpoint refused the request (${res.status}${text ? `: ${text}` : ""})`,
|
|
54960
|
-
fix: opts.apiKey ?
|
|
55002
|
+
fix: opts.apiKey ? `the key was sent and rejected; check ${apiKeyEnv}` : `set ${apiKeyEnv}`
|
|
54961
55003
|
});
|
|
54962
55004
|
return checks;
|
|
54963
55005
|
}
|
|
@@ -58213,7 +58255,7 @@ var PLACEHOLDER = "type a task, / for commands";
|
|
|
58213
58255
|
var IDLE_HINT = "";
|
|
58214
58256
|
var RUNNING_HINT = "esc to interrupt";
|
|
58215
58257
|
var CTRL_C_WINDOW_MS = 2e3;
|
|
58216
|
-
var BLOCKED_WHILE_RUNNING = /* @__PURE__ */ new Set(["new", "clear", "channel", "resume", "cwd", "compact"]);
|
|
58258
|
+
var BLOCKED_WHILE_RUNNING = /* @__PURE__ */ new Set(["new", "clear", "channel", "resume", "cwd", "compact", "provider"]);
|
|
58217
58259
|
var MENU_ITEMS = COMMANDS.map((c) => ({
|
|
58218
58260
|
name: c.name,
|
|
58219
58261
|
description: c.description,
|
|
@@ -58233,6 +58275,9 @@ var Chat = class {
|
|
|
58233
58275
|
this.projectNotes = opts.projectNotes;
|
|
58234
58276
|
this.apiKey = opts.apiKey;
|
|
58235
58277
|
this.apiKeySource = opts.apiKeySource;
|
|
58278
|
+
this.requireKey = opts.requireKey === true;
|
|
58279
|
+
this.providerCredentials = { ...opts.providerCredentials };
|
|
58280
|
+
this.cacheProviderCredential();
|
|
58236
58281
|
this.now = opts.now ?? (() => Date.now());
|
|
58237
58282
|
this.billing = new InfronBilling({
|
|
58238
58283
|
fetchImpl: opts.balanceFetch,
|
|
@@ -58284,6 +58329,8 @@ var Chat = class {
|
|
|
58284
58329
|
apiKey;
|
|
58285
58330
|
apiKeySource;
|
|
58286
58331
|
apiKeyVerified = false;
|
|
58332
|
+
requireKey;
|
|
58333
|
+
providerCredentials;
|
|
58287
58334
|
authGeneration = 0;
|
|
58288
58335
|
verifyingLogin = null;
|
|
58289
58336
|
billing;
|
|
@@ -58344,7 +58391,7 @@ var Chat = class {
|
|
|
58344
58391
|
}
|
|
58345
58392
|
this.screen.setLabel(this.settings.model);
|
|
58346
58393
|
this.screen.setTitle(`motif \xB7 ${this.settings.cwd.split("/").pop() ?? this.settings.cwd}`);
|
|
58347
|
-
if (this.apiKey === void 0 && !this.opts.
|
|
58394
|
+
if (this.apiKey === void 0 && !this.requireKey && !this.opts.chooseProvider) {
|
|
58348
58395
|
this.screen.append({
|
|
58349
58396
|
kind: "notice",
|
|
58350
58397
|
level: "warn",
|
|
@@ -58358,6 +58405,17 @@ var Chat = class {
|
|
|
58358
58405
|
}
|
|
58359
58406
|
/** What happens before the first prompt is free: the login, the resumed conversation, the first task. */
|
|
58360
58407
|
async start() {
|
|
58408
|
+
if (this.opts.chooseProvider) {
|
|
58409
|
+
const choice = await this.chooseProvider();
|
|
58410
|
+
if (this.quitting) return;
|
|
58411
|
+
if (choice === null) return;
|
|
58412
|
+
const result = this.switchProvider(choice);
|
|
58413
|
+
if (result.error) {
|
|
58414
|
+
this.screen.append({ kind: "notice", level: "error", text: result.lines.join(" ") });
|
|
58415
|
+
this.refresh();
|
|
58416
|
+
return;
|
|
58417
|
+
}
|
|
58418
|
+
}
|
|
58361
58419
|
void this.billing.refresh();
|
|
58362
58420
|
if (this.needsLogin) {
|
|
58363
58421
|
const lines = await this.login("startup");
|
|
@@ -58497,7 +58555,7 @@ var Chat = class {
|
|
|
58497
58555
|
break;
|
|
58498
58556
|
}
|
|
58499
58557
|
if (key.type !== "ctrl" || key.key !== "c") this.ctrlCArmedAt = 0;
|
|
58500
|
-
this.refresh();
|
|
58558
|
+
if (!this.quitting) this.refresh();
|
|
58501
58559
|
}
|
|
58502
58560
|
onControl(letter) {
|
|
58503
58561
|
switch (letter) {
|
|
@@ -58666,7 +58724,7 @@ var Chat = class {
|
|
|
58666
58724
|
return this.opts.envPath ?? defaultEnvPath();
|
|
58667
58725
|
}
|
|
58668
58726
|
get needsLogin() {
|
|
58669
|
-
return this.
|
|
58727
|
+
return this.requireKey && this.apiKey === void 0;
|
|
58670
58728
|
}
|
|
58671
58729
|
/** Take over the prompt for one question; resolves with the index chosen, or null on esc. */
|
|
58672
58730
|
askChoice(title, lines, options, wrap2 = false) {
|
|
@@ -58806,12 +58864,19 @@ var Chat = class {
|
|
|
58806
58864
|
this.invalidateAuthentication();
|
|
58807
58865
|
const generation = this.authGeneration;
|
|
58808
58866
|
const endpoint = this.settings.endpoint;
|
|
58809
|
-
const
|
|
58867
|
+
const model = this.settings.model;
|
|
58868
|
+
const provider = providerForEndpoint(endpoint) ?? "infron";
|
|
58869
|
+
const label3 = PROVIDERS[provider].label;
|
|
58870
|
+
const keyEnv = apiKeyEnvForEndpoint(endpoint);
|
|
58871
|
+
const title = reason === "command" ? `Paste your ${label3} API key` : reason === "task" ? "An API key is needed before the task can run" : `Paste your ${label3} API key to get started`;
|
|
58810
58872
|
const cancelHint = reason === "command" ? "enter to check and save \xB7 esc to cancel" : "enter to check and save \xB7 esc to skip for now";
|
|
58811
58873
|
for (; ; ) {
|
|
58812
|
-
const raw = await this.askSecret(title, loginLines(this.envPath), "key \u203A ", cancelHint);
|
|
58874
|
+
const raw = await this.askSecret(title, loginLines(this.envPath, void 0, provider), "key \u203A ", cancelHint);
|
|
58813
58875
|
if (raw === null) {
|
|
58814
|
-
return reason === "command" ? ["login cancelled"] : [`no key entered; /login when you have one, or put
|
|
58876
|
+
return reason === "command" ? ["login cancelled"] : [`no key entered; /login when you have one, or put ${keyEnv} in ${this.envPath}`];
|
|
58877
|
+
}
|
|
58878
|
+
if (this.quitting || generation !== this.authGeneration || endpoint !== this.settings.endpoint) {
|
|
58879
|
+
return ["login cancelled because the session or endpoint changed; /login to try again"];
|
|
58815
58880
|
}
|
|
58816
58881
|
const key = normaliseKeyInput(raw);
|
|
58817
58882
|
if (key === "") continue;
|
|
@@ -58819,7 +58884,7 @@ var Chat = class {
|
|
|
58819
58884
|
this.screen.setActivity("Checking the key\u2026");
|
|
58820
58885
|
let result;
|
|
58821
58886
|
try {
|
|
58822
|
-
result = await (this.opts.verifyKey ?? ((k) => verifyApiKey({ endpoint
|
|
58887
|
+
result = await (this.opts.verifyKey ?? ((k) => verifyApiKey({ endpoint, model, apiKey: k })))(key);
|
|
58823
58888
|
} finally {
|
|
58824
58889
|
if (this.verifyingLogin === generation) {
|
|
58825
58890
|
this.verifyingLogin = null;
|
|
@@ -58837,10 +58902,12 @@ var Chat = class {
|
|
|
58837
58902
|
this.apiKeyVerified = true;
|
|
58838
58903
|
this.syncBilling();
|
|
58839
58904
|
try {
|
|
58840
|
-
const path = saveApiKey(key, this.envPath);
|
|
58841
|
-
this.apiKeySource = `${path} (
|
|
58905
|
+
const path = saveApiKey(key, this.envPath, provider);
|
|
58906
|
+
this.apiKeySource = `${path} (${keyEnv})`;
|
|
58907
|
+
this.cacheProviderCredential();
|
|
58842
58908
|
} catch (err) {
|
|
58843
58909
|
this.apiKeySource = "this session only";
|
|
58910
|
+
this.cacheProviderCredential();
|
|
58844
58911
|
return [`the key works, but ${this.envPath} could not be written: ${err instanceof Error ? err.message : String(err)}`, "it is kept for this session only"];
|
|
58845
58912
|
}
|
|
58846
58913
|
return [`signed in \xB7 the key is saved to ${this.envPath}`];
|
|
@@ -58850,9 +58917,10 @@ var Chat = class {
|
|
|
58850
58917
|
this.invalidateAuthentication();
|
|
58851
58918
|
const source = this.apiKeySource;
|
|
58852
58919
|
const had = this.apiKey !== void 0;
|
|
58853
|
-
const removed = forgetApiKey(this.envPath);
|
|
58920
|
+
const removed = forgetApiKey(this.envPath, providerForEndpoint(this.settings.endpoint) ?? "infron");
|
|
58854
58921
|
this.apiKey = void 0;
|
|
58855
58922
|
this.apiKeySource = void 0;
|
|
58923
|
+
this.cacheProviderCredential();
|
|
58856
58924
|
this.apiKeyVerified = false;
|
|
58857
58925
|
this.billing.configure(this.settings.endpoint);
|
|
58858
58926
|
if (!had && !removed) return ["no key is set"];
|
|
@@ -59261,12 +59329,7 @@ var Chat = class {
|
|
|
59261
59329
|
this.refresh();
|
|
59262
59330
|
return;
|
|
59263
59331
|
}
|
|
59264
|
-
const previousEndpoint = this.settings.endpoint;
|
|
59265
59332
|
const out = await runSlash(text, this.context());
|
|
59266
|
-
if (previousEndpoint !== this.settings.endpoint) {
|
|
59267
|
-
this.apiKeyVerified = false;
|
|
59268
|
-
this.invalidateAuthentication();
|
|
59269
|
-
}
|
|
59270
59333
|
this.syncBilling();
|
|
59271
59334
|
if (!this.quitting && !out.silent && out.lines.length > 0) {
|
|
59272
59335
|
this.screen.append(
|
|
@@ -59765,6 +59828,16 @@ ${output.slice(0, 8e3)}
|
|
|
59765
59828
|
config: () => this.configLines(),
|
|
59766
59829
|
openPanel: (tab) => this.openPanel(tab),
|
|
59767
59830
|
configure: (args) => this.configure(args),
|
|
59831
|
+
provider: (args) => this.providerCommand(args),
|
|
59832
|
+
setEndpoint: (endpoint) => {
|
|
59833
|
+
if (endpoint === this.settings.endpoint) return;
|
|
59834
|
+
const previous = this.settings.endpoint;
|
|
59835
|
+
this.settings.endpoint = endpoint;
|
|
59836
|
+
this.rebindProviderCredential(previous);
|
|
59837
|
+
this.apiKeyVerified = false;
|
|
59838
|
+
this.invalidateAuthentication();
|
|
59839
|
+
this.syncBilling();
|
|
59840
|
+
},
|
|
59768
59841
|
stats: () => statsRows(this.insights()).flatMap((r) => [`${r.label} ${r.value ?? ""}`, ...r.detail ? [` ${r.detail}`] : []]),
|
|
59769
59842
|
usage: () => [...balanceRows(this.billing.state), ...usageRows(this.insights())].flatMap((r) => [`${r.label} ${r.value ?? ""}`, ...r.detail ? [` ${r.detail}`] : []]),
|
|
59770
59843
|
themes: () => Object.entries(THEMES).map(([name, t]) => `${name.padEnd(10)} ${t.description}`),
|
|
@@ -59823,6 +59896,7 @@ ${output.slice(0, 8e3)}
|
|
|
59823
59896
|
};
|
|
59824
59897
|
}
|
|
59825
59898
|
settingSource(key) {
|
|
59899
|
+
if (key === "provider") return this.settingSource("endpoint");
|
|
59826
59900
|
return this.changedSettings.get(key) ?? this.opts.settingSources?.[key] ?? this.opts.settingsInfo?.sources[key] ?? "default";
|
|
59827
59901
|
}
|
|
59828
59902
|
rememberSetting(key, value) {
|
|
@@ -59831,6 +59905,7 @@ ${output.slice(0, 8e3)}
|
|
|
59831
59905
|
return path;
|
|
59832
59906
|
}
|
|
59833
59907
|
configValue(key) {
|
|
59908
|
+
if (key === "provider") return providerForEndpoint(this.settings.endpoint) ?? "custom";
|
|
59834
59909
|
if (key === "thinking") return String(this.screen.thinkingShown);
|
|
59835
59910
|
if (key === "verbose") return String(this.screen.verboseOutput);
|
|
59836
59911
|
return String(this.settings[key] ?? "off");
|
|
@@ -59843,17 +59918,19 @@ ${output.slice(0, 8e3)}
|
|
|
59843
59918
|
}
|
|
59844
59919
|
applyConfig(field, raw) {
|
|
59845
59920
|
const fail5 = (message2) => ({ title: "/config", error: true, lines: [message2] });
|
|
59846
|
-
if ((this.active || this.shellBusy || this.compacting) && !["thinking", "verbose", "theme"].includes(field.key)) {
|
|
59921
|
+
if ((this.active || this.settlingTask || this.shellBusy || this.compacting) && !["thinking", "verbose", "theme"].includes(field.key)) {
|
|
59847
59922
|
return fail5("Wait for the running task to finish, or close this panel and press Esc to interrupt it.");
|
|
59848
59923
|
}
|
|
59849
59924
|
let value;
|
|
59850
59925
|
let path;
|
|
59851
59926
|
try {
|
|
59852
59927
|
value = parseConfigValue(field, raw);
|
|
59928
|
+
if (field.key === "provider") return this.switchProvider(value);
|
|
59853
59929
|
path = this.rememberSetting(field.key, value);
|
|
59854
59930
|
} catch (err) {
|
|
59855
59931
|
return fail5(err instanceof Error ? err.message : String(err));
|
|
59856
59932
|
}
|
|
59933
|
+
const previousEndpoint = this.settings.endpoint;
|
|
59857
59934
|
switch (field.key) {
|
|
59858
59935
|
case "thinking":
|
|
59859
59936
|
if (this.screen.thinkingShown !== value) this.screen.toggleThinking();
|
|
@@ -59878,6 +59955,7 @@ ${output.slice(0, 8e3)}
|
|
|
59878
59955
|
break;
|
|
59879
59956
|
}
|
|
59880
59957
|
if (field.key === "endpoint") {
|
|
59958
|
+
this.rebindProviderCredential(previousEndpoint);
|
|
59881
59959
|
this.apiKeyVerified = false;
|
|
59882
59960
|
this.invalidateAuthentication();
|
|
59883
59961
|
this.syncBilling();
|
|
@@ -59891,6 +59969,66 @@ ${output.slice(0, 8e3)}
|
|
|
59891
59969
|
]
|
|
59892
59970
|
};
|
|
59893
59971
|
}
|
|
59972
|
+
get providerLabel() {
|
|
59973
|
+
const provider = providerForEndpoint(this.settings.endpoint);
|
|
59974
|
+
return provider ? PROVIDERS[provider].label : "Custom endpoint";
|
|
59975
|
+
}
|
|
59976
|
+
cacheProviderCredential() {
|
|
59977
|
+
const provider = providerForEndpoint(this.settings.endpoint);
|
|
59978
|
+
if (provider) this.providerCredentials[provider] = { apiKey: this.apiKey, source: this.apiKeySource };
|
|
59979
|
+
}
|
|
59980
|
+
rebindProviderCredential(previousEndpoint) {
|
|
59981
|
+
const previous = providerForEndpoint(previousEndpoint);
|
|
59982
|
+
const next = providerForEndpoint(this.settings.endpoint);
|
|
59983
|
+
if (previous === next) return;
|
|
59984
|
+
if (next) this.requireKey = true;
|
|
59985
|
+
if (previous !== "morphfactory" && next !== "morphfactory" && !(next && this.apiKey === void 0)) return;
|
|
59986
|
+
if (previous) this.providerCredentials[previous] = { apiKey: this.apiKey, source: this.apiKeySource };
|
|
59987
|
+
const credential = next ? this.providerCredentials[next] : void 0;
|
|
59988
|
+
this.apiKey = credential?.apiKey;
|
|
59989
|
+
this.apiKeySource = credential?.source;
|
|
59990
|
+
this.requireKey = next !== void 0;
|
|
59991
|
+
}
|
|
59992
|
+
chooseProvider() {
|
|
59993
|
+
const providers = Object.keys(PROVIDERS);
|
|
59994
|
+
return this.askChoice("Choose a provider", ["Both providers serve Motif-3. Each uses its own API key.", "Change this later with /provider or /config provider."], providers.map((id, i) => `${i + 1}. ${PROVIDERS[id].label}`), true).then((choice) => choice === null ? null : providers[choice]);
|
|
59995
|
+
}
|
|
59996
|
+
switchProvider(provider) {
|
|
59997
|
+
const selected = PROVIDERS[provider];
|
|
59998
|
+
try {
|
|
59999
|
+
this.rememberSetting("model", selected.model);
|
|
60000
|
+
this.rememberSetting("endpoint", selected.endpoint);
|
|
60001
|
+
} catch (err) {
|
|
60002
|
+
return { title: "/provider", error: true, lines: [err instanceof Error ? err.message : String(err)] };
|
|
60003
|
+
}
|
|
60004
|
+
this.cacheProviderCredential();
|
|
60005
|
+
this.invalidateAuthentication();
|
|
60006
|
+
this.settings.endpoint = selected.endpoint;
|
|
60007
|
+
this.settings.model = selected.model;
|
|
60008
|
+
this.apiKey = this.providerCredentials[provider]?.apiKey;
|
|
60009
|
+
this.apiKeySource = this.providerCredentials[provider]?.source;
|
|
60010
|
+
this.apiKeyVerified = false;
|
|
60011
|
+
this.requireKey = true;
|
|
60012
|
+
this.screen.setLabel(selected.model);
|
|
60013
|
+
this.syncBilling();
|
|
60014
|
+
return { title: "/provider", lines: [
|
|
60015
|
+
`Provider: ${selected.label} \xB7 ${this.apiKey ? "API key loaded" : "no API key; use /login"}.`,
|
|
60016
|
+
`${selected.endpoint} \xB7 ${selected.model}`,
|
|
60017
|
+
"Saved defaults can be overridden by startup flags, environment or trusted project settings."
|
|
60018
|
+
] };
|
|
60019
|
+
}
|
|
60020
|
+
async providerCommand(args) {
|
|
60021
|
+
if (this.active || this.settlingTask || this.shellBusy || this.compacting) return { title: "/provider", error: true, lines: ["Wait for the running task to finish before changing provider."] };
|
|
60022
|
+
if (args && !Object.hasOwn(PROVIDERS, args)) return { title: "/provider", error: true, lines: ["Choose infron or morphfactory."] };
|
|
60023
|
+
const provider = args ? args : await this.chooseProvider();
|
|
60024
|
+
if (provider === null || this.quitting) return { title: "/provider", lines: ["Provider selection cancelled."] };
|
|
60025
|
+
const result = this.switchProvider(provider);
|
|
60026
|
+
if (!result.error && this.needsLogin) {
|
|
60027
|
+
result.lines.push(...await this.login("command"));
|
|
60028
|
+
if (this.apiKey && providerForEndpoint(this.settings.endpoint) === provider) result.lines[0] = `Provider: ${PROVIDERS[provider].label} \xB7 API key loaded.`;
|
|
60029
|
+
}
|
|
60030
|
+
return result;
|
|
60031
|
+
}
|
|
59894
60032
|
invalidateAuthentication() {
|
|
59895
60033
|
this.authGeneration++;
|
|
59896
60034
|
if (this.verifyingLogin !== null) {
|
|
@@ -59921,9 +60059,10 @@ ${output.slice(0, 8e3)}
|
|
|
59921
60059
|
}
|
|
59922
60060
|
panelView() {
|
|
59923
60061
|
const panel = this.panel;
|
|
59924
|
-
const rows = panel.tab === "config" ? CONFIG_FIELDS.map((f) => ({ label: f.label, value: this.configValue(f.key), detail: `${f.detail}${f.key === "permissions" && this.alwaysAllowed.size ? ` Already allowed this session: ${[...this.alwaysAllowed].join(", ")}.` : ""} Source: ${this.settingSource(f.key)}.` })) : panel.tab === "status" ? [
|
|
60062
|
+
const rows = panel.tab === "config" ? CONFIG_FIELDS.map((f) => ({ label: f.label, value: f.key === "provider" ? this.providerLabel : this.configValue(f.key), detail: `${f.detail}${f.key === "permissions" && this.alwaysAllowed.size ? ` Already allowed this session: ${[...this.alwaysAllowed].join(", ")}.` : ""} Source: ${this.settingSource(f.key)}.` })) : panel.tab === "status" ? [
|
|
59925
60063
|
{ label: "Version", value: this.opts.version },
|
|
59926
60064
|
{ label: "State", value: this.active ? "Running" : this.shellBusy ? "Shell running" : this.compacting ? "Compacting" : "Ready", tone: "good" },
|
|
60065
|
+
{ label: "Provider", value: this.providerLabel },
|
|
59927
60066
|
{ label: "Model", value: this.settings.model },
|
|
59928
60067
|
{ label: "Endpoint", value: this.settings.endpoint },
|
|
59929
60068
|
{ label: "Authentication", value: this.apiKey ? this.apiKeyVerified ? "Verified this session" : "API key loaded" : "No API key \xB7 /login" },
|
|
@@ -60053,6 +60192,7 @@ ${output.slice(0, 8e3)}
|
|
|
60053
60192
|
const s = this.settings;
|
|
60054
60193
|
const src = (key) => this.settingSource(key);
|
|
60055
60194
|
const rows = [
|
|
60195
|
+
["provider", this.providerLabel, src("endpoint")],
|
|
60056
60196
|
["model", s.model, src("model")],
|
|
60057
60197
|
["endpoint", s.endpoint, src("endpoint")],
|
|
60058
60198
|
["channel", s.channel, src("channel")],
|
|
@@ -60081,6 +60221,7 @@ ${output.slice(0, 8e3)}
|
|
|
60081
60221
|
const t = this.totals;
|
|
60082
60222
|
const fmt = (n) => n.toLocaleString("en-US");
|
|
60083
60223
|
return [
|
|
60224
|
+
`provider ${this.providerLabel}`,
|
|
60084
60225
|
`model ${s.model}`,
|
|
60085
60226
|
`endpoint ${s.endpoint}`,
|
|
60086
60227
|
`channel ${s.channel} (policy ${this.opts.channelPolicy})`,
|
|
@@ -62523,7 +62664,7 @@ function pluginConnectionUi(signal) {
|
|
|
62523
62664
|
}
|
|
62524
62665
|
|
|
62525
62666
|
// packages/cli/src/main.ts
|
|
62526
|
-
var VERSION = "0.4.
|
|
62667
|
+
var VERSION = "0.4.3";
|
|
62527
62668
|
var SHORT_FLAGS = { p: "print", c: "continue", i: "interactive", v: "verbose", h: "help" };
|
|
62528
62669
|
var BOOLEAN_FLAGS = /* @__PURE__ */ new Set([
|
|
62529
62670
|
"print",
|
|
@@ -62731,7 +62872,7 @@ var HELP = `motif ${VERSION} \u2014 a coding agent built for Motif-3 (unofficial
|
|
|
62731
62872
|
motif open the interactive session (a terminal is required)
|
|
62732
62873
|
motif "<task>" run one task and exit; add --interactive to stay
|
|
62733
62874
|
motif -p "<question>" print only the final reply, for scripts and pipes (also --print)
|
|
62734
|
-
motif login paste
|
|
62875
|
+
motif login paste the selected provider's API key; it is checked and saved to ~/.motif/.env
|
|
62735
62876
|
motif logout remove the saved key
|
|
62736
62877
|
motif doctor check the endpoint, the credentials and what the server produces
|
|
62737
62878
|
motif sessions list recorded sessions
|
|
@@ -62759,6 +62900,7 @@ var HELP = `motif ${VERSION} \u2014 a coding agent built for Motif-3 (unofficial
|
|
|
62759
62900
|
motif corpus-render render a corpus JSONL to prompt text, as the harness would
|
|
62760
62901
|
|
|
62761
62902
|
Flags
|
|
62903
|
+
--provider <id> infron | morphfactory (BETA); sets endpoint and model defaults
|
|
62762
62904
|
--endpoint <url> model server (default ${DEFAULT_ENDPOINT}; a trailing /v1 is accepted)
|
|
62763
62905
|
--model <name> model id to request (default ${DEFAULT_MODEL})
|
|
62764
62906
|
--env-file <path> read MOTIF_* settings from this file first
|
|
@@ -62787,9 +62929,11 @@ distil flags
|
|
|
62787
62929
|
--include-children also export subagent scopes
|
|
62788
62930
|
|
|
62789
62931
|
Connection
|
|
62790
|
-
The first session
|
|
62791
|
-
and saves it to ~/.motif/.env;
|
|
62792
|
-
|
|
62932
|
+
The first session offers Infron or Morphfactory (BETA), checks your API key
|
|
62933
|
+
and saves it to ~/.motif/.env; use /provider to switch inside a session.
|
|
62934
|
+
'motif login --provider morphfactory' signs in outside a session.
|
|
62935
|
+
MOTIF_API_KEY (Infron), MOTIF_MORPHFACTORY_API_KEY, MOTIF_ENDPOINT and
|
|
62936
|
+
MOTIF_MODEL are read from the environment,
|
|
62793
62937
|
then from ./.env, then from ~/.motif/.env \u2014 MOTIF_* keys only, and never into
|
|
62794
62938
|
the environment. The key is sent as a bearer token and is withheld from every
|
|
62795
62939
|
command the agent runs.
|
|
@@ -62819,13 +62963,14 @@ channel after repeated parse failures, and that move restarts the conversation
|
|
|
62819
62963
|
because the transcript formats are not interchangeable.
|
|
62820
62964
|
`;
|
|
62821
62965
|
function keyRequired(endpoint) {
|
|
62822
|
-
return endpoint
|
|
62966
|
+
return providerForEndpoint(endpoint) !== void 0;
|
|
62823
62967
|
}
|
|
62824
62968
|
async function loginAtTerminal(endpoint, model) {
|
|
62825
62969
|
const path = defaultEnvPath();
|
|
62970
|
+
const provider = providerForEndpoint(endpoint) ?? "infron";
|
|
62826
62971
|
if (process.stdin.isTTY) {
|
|
62827
62972
|
process.stdout.write(
|
|
62828
|
-
`Paste your
|
|
62973
|
+
`Paste your ${PROVIDERS[provider].label} API key. Get one at ${PROVIDERS[provider].keyPage}.
|
|
62829
62974
|
It is checked against ${endpoint}, then saved to ${path} (readable only by you).
|
|
62830
62975
|
`
|
|
62831
62976
|
);
|
|
@@ -62842,7 +62987,7 @@ It is checked against ${endpoint}, then saved to ${path} (readable only by you).
|
|
|
62842
62987
|
`);
|
|
62843
62988
|
return null;
|
|
62844
62989
|
}
|
|
62845
|
-
saveApiKey(key, path);
|
|
62990
|
+
saveApiKey(key, path, provider);
|
|
62846
62991
|
process.stdout.write(`signed in \xB7 the key is saved to ${path}
|
|
62847
62992
|
`);
|
|
62848
62993
|
const billing = new InfronBilling();
|
|
@@ -62885,12 +63030,15 @@ async function main() {
|
|
|
62885
63030
|
warn: (m) => process.stderr.write(`${m}
|
|
62886
63031
|
`)
|
|
62887
63032
|
});
|
|
63033
|
+
const provider = args.flags["provider"] === void 0 ? void 0 : flagEnum(args.flags, "provider", ["infron", "morphfactory"], "infron");
|
|
63034
|
+
const dotenvPaths = [...envFile ? [envFile] : [], ...defaultDotenvPaths()];
|
|
62888
63035
|
const connection = resolveEndpointConfig({
|
|
62889
63036
|
flags: {
|
|
63037
|
+
...provider ? { endpoint: PROVIDERS[provider].endpoint, model: PROVIDERS[provider].model } : {},
|
|
62890
63038
|
...typeof args.flags["endpoint"] === "string" ? { endpoint: args.flags["endpoint"] } : {},
|
|
62891
63039
|
...typeof args.flags["model"] === "string" ? { model: args.flags["model"] } : {}
|
|
62892
63040
|
},
|
|
62893
|
-
dotenvPaths
|
|
63041
|
+
dotenvPaths,
|
|
62894
63042
|
defaults: {
|
|
62895
63043
|
...stored.values.endpoint !== void 0 ? { endpoint: stored.values.endpoint } : {},
|
|
62896
63044
|
...stored.values.model !== void 0 ? { model: stored.values.model } : {}
|
|
@@ -62905,6 +63053,14 @@ async function main() {
|
|
|
62905
63053
|
const compactAt = stored.values.compactAt ?? 0.75;
|
|
62906
63054
|
const permissions = flagEnum(args.flags, "permissions", ["ask", "auto"], stored.values.permissions ?? "ask");
|
|
62907
63055
|
const { endpoint, model, apiKey } = connection;
|
|
63056
|
+
const providerCredentials = {};
|
|
63057
|
+
for (const id of Object.keys(PROVIDERS)) {
|
|
63058
|
+
const credentials = resolveEndpointConfig({ flags: { endpoint: PROVIDERS[id].endpoint }, dotenvPaths });
|
|
63059
|
+
providerCredentials[id] = {
|
|
63060
|
+
...credentials.apiKey !== void 0 ? { apiKey: credentials.apiKey } : {},
|
|
63061
|
+
...credentials.sources.apiKey !== void 0 ? { source: credentials.sources.apiKey } : {}
|
|
63062
|
+
};
|
|
63063
|
+
}
|
|
62908
63064
|
withholdSecrets(process.env);
|
|
62909
63065
|
let resumeFrom;
|
|
62910
63066
|
switch (args.command) {
|
|
@@ -62999,7 +63155,7 @@ async function main() {
|
|
|
62999
63155
|
}
|
|
63000
63156
|
case "logout": {
|
|
63001
63157
|
const path = defaultEnvPath();
|
|
63002
|
-
process.stdout.write(forgetApiKey(path) ? `the key was removed from ${path}
|
|
63158
|
+
process.stdout.write(forgetApiKey(path, providerForEndpoint(endpoint) ?? "infron") ? `the key was removed from ${path}
|
|
63003
63159
|
` : `no key in ${path}
|
|
63004
63160
|
`);
|
|
63005
63161
|
return 0;
|
|
@@ -63043,7 +63199,9 @@ ${"".padEnd(12)} tools: ${tools}
|
|
|
63043
63199
|
return 0;
|
|
63044
63200
|
}
|
|
63045
63201
|
case "config": {
|
|
63202
|
+
const selectedProvider = providerForEndpoint(endpoint);
|
|
63046
63203
|
const rows = [
|
|
63204
|
+
["provider", selectedProvider ? PROVIDERS[selectedProvider].label : "custom", connection.sources.endpoint],
|
|
63047
63205
|
["model", model, connection.sources.model],
|
|
63048
63206
|
["endpoint", endpoint, connection.sources.endpoint],
|
|
63049
63207
|
["channel", stored.values.channel ?? "toolcall", stored.sources.channel ?? "default"],
|
|
@@ -63286,6 +63444,8 @@ user file ${stored.userPath}${existsSync16(stored.userPath) ? "" : " (absent
|
|
|
63286
63444
|
...apiKey !== void 0 ? { apiKey } : {},
|
|
63287
63445
|
...connection.sources.apiKey !== void 0 ? { apiKeySource: connection.sources.apiKey } : {},
|
|
63288
63446
|
requireKey: keyRequired(endpoint),
|
|
63447
|
+
chooseProvider: apiKey === void 0 && connection.sources.endpoint === "default" && stored.values.endpoint === void 0,
|
|
63448
|
+
providerCredentials,
|
|
63289
63449
|
envPath: defaultEnvPath(),
|
|
63290
63450
|
offerInstall: ranFromNpx(process.argv[1]) && !commandOnPath("motif"),
|
|
63291
63451
|
skills,
|
|
@@ -63337,7 +63497,7 @@ user file ${stored.userPath}${existsSync16(stored.userPath) ? "" : " (absent
|
|
|
63337
63497
|
let sessionKey = apiKey;
|
|
63338
63498
|
if (sessionKey === void 0 && keyRequired(endpoint)) {
|
|
63339
63499
|
if (!tty) {
|
|
63340
|
-
process.stderr.write(`no API key: run 'motif login', or put
|
|
63500
|
+
process.stderr.write(`no API key: run 'motif login${providerForEndpoint(endpoint) === "morphfactory" ? " --provider morphfactory" : ""}', or put ${apiKeyEnvForEndpoint(endpoint)} in ${defaultEnvPath()}
|
|
63341
63501
|
`);
|
|
63342
63502
|
return 2;
|
|
63343
63503
|
}
|