motifcode 0.4.1 → 0.4.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 +16 -9
- package/dist/build-info.json +2 -2
- package/dist/motif.js +204 -45
- 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, {
|
|
@@ -53633,7 +53665,7 @@ function installCommand(version2) {
|
|
|
53633
53665
|
|
|
53634
53666
|
// packages/cli/src/login.ts
|
|
53635
53667
|
import { homedir as homedir3 } from "node:os";
|
|
53636
|
-
var KEY_PAGE =
|
|
53668
|
+
var KEY_PAGE = PROVIDERS.infron.keyPage;
|
|
53637
53669
|
async function verifyApiKey(opts) {
|
|
53638
53670
|
const fetchImpl = opts.fetchImpl ?? globalThis.fetch;
|
|
53639
53671
|
const endpoint = normalizeEndpoint(opts.endpoint);
|
|
@@ -53673,15 +53705,14 @@ async function serverMessage(res) {
|
|
|
53673
53705
|
}
|
|
53674
53706
|
function normaliseKeyInput(raw) {
|
|
53675
53707
|
let s = raw.trim();
|
|
53676
|
-
s = s.replace(new RegExp(`^(?:export\\s+)
|
|
53708
|
+
s = s.replace(new RegExp(`^(?:export\\s+)?(?:${ENV_API_KEY}|${ENV_MORPHFACTORY_API_KEY})\\s*=\\s*`), "");
|
|
53677
53709
|
if (s.startsWith('"') && s.endsWith('"') || s.startsWith("'") && s.endsWith("'")) s = s.slice(1, -1);
|
|
53678
53710
|
return s.trim();
|
|
53679
53711
|
}
|
|
53680
|
-
function loginLines(envPath, home = homedir3()) {
|
|
53712
|
+
function loginLines(envPath, home = homedir3(), provider = "infron") {
|
|
53681
53713
|
const shown = envPath.startsWith(home + "/") ? `~${envPath.slice(home.length)}` : envPath;
|
|
53682
53714
|
return [
|
|
53683
|
-
`Get one at ${
|
|
53684
|
-
"Motif-3 is free there through September 2026.",
|
|
53715
|
+
`Get one at ${PROVIDERS[provider].keyPage}`,
|
|
53685
53716
|
`The key is checked with the endpoint and saved to ${shown},`,
|
|
53686
53717
|
"readable only by you and never shown to the model."
|
|
53687
53718
|
];
|
|
@@ -53827,9 +53858,15 @@ var COMMANDS = [
|
|
|
53827
53858
|
description: "probe the endpoint: auth, parsers, cache, channels",
|
|
53828
53859
|
run: async (ctx) => ok("/doctor", await ctx.doctor())
|
|
53829
53860
|
},
|
|
53861
|
+
{
|
|
53862
|
+
name: "provider",
|
|
53863
|
+
description: "choose Infron or Morphfactory (BETA)",
|
|
53864
|
+
usage: "[infron|morphfactory]",
|
|
53865
|
+
run: (ctx, args) => ctx.provider?.(args) ?? fail("/provider", "Provider selection requires an interactive session.")
|
|
53866
|
+
},
|
|
53830
53867
|
{
|
|
53831
53868
|
name: "login",
|
|
53832
|
-
description: "paste
|
|
53869
|
+
description: "paste the selected provider\u2019s API key; it is checked against the endpoint and saved to ~/.motif/.env",
|
|
53833
53870
|
run: async (ctx) => ok("/login", await ctx.login())
|
|
53834
53871
|
},
|
|
53835
53872
|
{
|
|
@@ -53854,7 +53891,9 @@ var COMMANDS = [
|
|
|
53854
53891
|
run: (ctx, args) => {
|
|
53855
53892
|
if (args === "") return ok("/endpoint", [ctx.settings.endpoint]);
|
|
53856
53893
|
if (!/^https?:\/\//.test(args)) return fail("/endpoint", `not a URL: ${args}`);
|
|
53857
|
-
|
|
53894
|
+
const endpoint = args.replace(/\/+$/, "").replace(/\/v1$/, "");
|
|
53895
|
+
if (ctx.setEndpoint) ctx.setEndpoint(endpoint);
|
|
53896
|
+
else ctx.settings.endpoint = endpoint;
|
|
53858
53897
|
return ok("/endpoint", [
|
|
53859
53898
|
`endpoint set to ${ctx.settings.endpoint} for the next task`,
|
|
53860
53899
|
...saved(ctx, "endpoint", ctx.settings.endpoint)
|
|
@@ -54191,6 +54230,7 @@ var CONFIG_FIELDS = [
|
|
|
54191
54230
|
{ key: "maxOutputTokens", label: "Max output tokens", detail: "Positive integer per model step, or off to use the server default." },
|
|
54192
54231
|
{ key: "seed", label: "Sampling seed", detail: "Integer >= 0, or off. The endpoint must support seeded sampling." },
|
|
54193
54232
|
{ key: "compactAt", label: "Compact at", detail: "Context fraction from 0.1 to 1 at which automatic compaction runs." },
|
|
54233
|
+
{ 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
54234
|
{ key: "theme", label: "Theme", choices: Object.keys(THEMES), detail: "Terminal color palette. Applies immediately; NO_COLOR takes precedence." }
|
|
54195
54235
|
];
|
|
54196
54236
|
function configField(key) {
|
|
@@ -54843,6 +54883,7 @@ async function doctor(opts) {
|
|
|
54843
54883
|
const fetchImpl = opts.fetchImpl ?? globalThis.fetch;
|
|
54844
54884
|
const endpoint = opts.endpoint.replace(/\/+$/, "").replace(/\/v1$/, "");
|
|
54845
54885
|
const checks = [];
|
|
54886
|
+
const apiKeyEnv = apiKeyEnvForEndpoint(endpoint);
|
|
54846
54887
|
const headers = { "content-type": "application/json" };
|
|
54847
54888
|
if (opts.apiKey) headers["authorization"] = `Bearer ${opts.apiKey}`;
|
|
54848
54889
|
const sandbox = detectSandbox();
|
|
@@ -54859,7 +54900,7 @@ async function doctor(opts) {
|
|
|
54859
54900
|
name: "api key",
|
|
54860
54901
|
state: "warn",
|
|
54861
54902
|
detail: "none \u2014 requests go out unauthenticated",
|
|
54862
|
-
fix:
|
|
54903
|
+
fix: `set ${apiKeyEnv} in the environment or in a .env file (not needed for a local server without auth)`
|
|
54863
54904
|
}
|
|
54864
54905
|
);
|
|
54865
54906
|
let models = null;
|
|
@@ -54873,7 +54914,7 @@ async function doctor(opts) {
|
|
|
54873
54914
|
name: "endpoint",
|
|
54874
54915
|
state: "fail",
|
|
54875
54916
|
detail: `${endpoint} returned ${res.status}`,
|
|
54876
|
-
fix: res.status === 401 || res.status === 403 ?
|
|
54917
|
+
fix: res.status === 401 || res.status === 403 ? `the endpoint refused the credentials; check ${apiKeyEnv}` : "start the server, or point --endpoint somewhere else"
|
|
54877
54918
|
});
|
|
54878
54919
|
return checks;
|
|
54879
54920
|
}
|
|
@@ -54957,7 +54998,7 @@ async function doctor(opts) {
|
|
|
54957
54998
|
name: "authentication",
|
|
54958
54999
|
state: "fail",
|
|
54959
55000
|
detail: `the endpoint refused the request (${res.status}${text ? `: ${text}` : ""})`,
|
|
54960
|
-
fix: opts.apiKey ?
|
|
55001
|
+
fix: opts.apiKey ? `the key was sent and rejected; check ${apiKeyEnv}` : `set ${apiKeyEnv}`
|
|
54961
55002
|
});
|
|
54962
55003
|
return checks;
|
|
54963
55004
|
}
|
|
@@ -58213,7 +58254,7 @@ var PLACEHOLDER = "type a task, / for commands";
|
|
|
58213
58254
|
var IDLE_HINT = "";
|
|
58214
58255
|
var RUNNING_HINT = "esc to interrupt";
|
|
58215
58256
|
var CTRL_C_WINDOW_MS = 2e3;
|
|
58216
|
-
var BLOCKED_WHILE_RUNNING = /* @__PURE__ */ new Set(["new", "clear", "channel", "resume", "cwd", "compact"]);
|
|
58257
|
+
var BLOCKED_WHILE_RUNNING = /* @__PURE__ */ new Set(["new", "clear", "channel", "resume", "cwd", "compact", "provider"]);
|
|
58217
58258
|
var MENU_ITEMS = COMMANDS.map((c) => ({
|
|
58218
58259
|
name: c.name,
|
|
58219
58260
|
description: c.description,
|
|
@@ -58233,6 +58274,9 @@ var Chat = class {
|
|
|
58233
58274
|
this.projectNotes = opts.projectNotes;
|
|
58234
58275
|
this.apiKey = opts.apiKey;
|
|
58235
58276
|
this.apiKeySource = opts.apiKeySource;
|
|
58277
|
+
this.requireKey = opts.requireKey === true;
|
|
58278
|
+
this.providerCredentials = { ...opts.providerCredentials };
|
|
58279
|
+
this.cacheProviderCredential();
|
|
58236
58280
|
this.now = opts.now ?? (() => Date.now());
|
|
58237
58281
|
this.billing = new InfronBilling({
|
|
58238
58282
|
fetchImpl: opts.balanceFetch,
|
|
@@ -58284,6 +58328,8 @@ var Chat = class {
|
|
|
58284
58328
|
apiKey;
|
|
58285
58329
|
apiKeySource;
|
|
58286
58330
|
apiKeyVerified = false;
|
|
58331
|
+
requireKey;
|
|
58332
|
+
providerCredentials;
|
|
58287
58333
|
authGeneration = 0;
|
|
58288
58334
|
verifyingLogin = null;
|
|
58289
58335
|
billing;
|
|
@@ -58344,7 +58390,7 @@ var Chat = class {
|
|
|
58344
58390
|
}
|
|
58345
58391
|
this.screen.setLabel(this.settings.model);
|
|
58346
58392
|
this.screen.setTitle(`motif \xB7 ${this.settings.cwd.split("/").pop() ?? this.settings.cwd}`);
|
|
58347
|
-
if (this.apiKey === void 0 && !this.opts.
|
|
58393
|
+
if (this.apiKey === void 0 && !this.requireKey && !this.opts.chooseProvider) {
|
|
58348
58394
|
this.screen.append({
|
|
58349
58395
|
kind: "notice",
|
|
58350
58396
|
level: "warn",
|
|
@@ -58358,6 +58404,17 @@ var Chat = class {
|
|
|
58358
58404
|
}
|
|
58359
58405
|
/** What happens before the first prompt is free: the login, the resumed conversation, the first task. */
|
|
58360
58406
|
async start() {
|
|
58407
|
+
if (this.opts.chooseProvider) {
|
|
58408
|
+
const choice = await this.chooseProvider();
|
|
58409
|
+
if (this.quitting) return;
|
|
58410
|
+
if (choice === null) return;
|
|
58411
|
+
const result = this.switchProvider(choice);
|
|
58412
|
+
if (result.error) {
|
|
58413
|
+
this.screen.append({ kind: "notice", level: "error", text: result.lines.join(" ") });
|
|
58414
|
+
this.refresh();
|
|
58415
|
+
return;
|
|
58416
|
+
}
|
|
58417
|
+
}
|
|
58361
58418
|
void this.billing.refresh();
|
|
58362
58419
|
if (this.needsLogin) {
|
|
58363
58420
|
const lines = await this.login("startup");
|
|
@@ -58666,7 +58723,7 @@ var Chat = class {
|
|
|
58666
58723
|
return this.opts.envPath ?? defaultEnvPath();
|
|
58667
58724
|
}
|
|
58668
58725
|
get needsLogin() {
|
|
58669
|
-
return this.
|
|
58726
|
+
return this.requireKey && this.apiKey === void 0;
|
|
58670
58727
|
}
|
|
58671
58728
|
/** Take over the prompt for one question; resolves with the index chosen, or null on esc. */
|
|
58672
58729
|
askChoice(title, lines, options, wrap2 = false) {
|
|
@@ -58806,12 +58863,19 @@ var Chat = class {
|
|
|
58806
58863
|
this.invalidateAuthentication();
|
|
58807
58864
|
const generation = this.authGeneration;
|
|
58808
58865
|
const endpoint = this.settings.endpoint;
|
|
58809
|
-
const
|
|
58866
|
+
const model = this.settings.model;
|
|
58867
|
+
const provider = providerForEndpoint(endpoint) ?? "infron";
|
|
58868
|
+
const label3 = PROVIDERS[provider].label;
|
|
58869
|
+
const keyEnv = apiKeyEnvForEndpoint(endpoint);
|
|
58870
|
+
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
58871
|
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
58872
|
for (; ; ) {
|
|
58812
|
-
const raw = await this.askSecret(title, loginLines(this.envPath), "key \u203A ", cancelHint);
|
|
58873
|
+
const raw = await this.askSecret(title, loginLines(this.envPath, void 0, provider), "key \u203A ", cancelHint);
|
|
58813
58874
|
if (raw === null) {
|
|
58814
|
-
return reason === "command" ? ["login cancelled"] : [`no key entered; /login when you have one, or put
|
|
58875
|
+
return reason === "command" ? ["login cancelled"] : [`no key entered; /login when you have one, or put ${keyEnv} in ${this.envPath}`];
|
|
58876
|
+
}
|
|
58877
|
+
if (this.quitting || generation !== this.authGeneration || endpoint !== this.settings.endpoint) {
|
|
58878
|
+
return ["login cancelled because the session or endpoint changed; /login to try again"];
|
|
58815
58879
|
}
|
|
58816
58880
|
const key = normaliseKeyInput(raw);
|
|
58817
58881
|
if (key === "") continue;
|
|
@@ -58819,7 +58883,7 @@ var Chat = class {
|
|
|
58819
58883
|
this.screen.setActivity("Checking the key\u2026");
|
|
58820
58884
|
let result;
|
|
58821
58885
|
try {
|
|
58822
|
-
result = await (this.opts.verifyKey ?? ((k) => verifyApiKey({ endpoint
|
|
58886
|
+
result = await (this.opts.verifyKey ?? ((k) => verifyApiKey({ endpoint, model, apiKey: k })))(key);
|
|
58823
58887
|
} finally {
|
|
58824
58888
|
if (this.verifyingLogin === generation) {
|
|
58825
58889
|
this.verifyingLogin = null;
|
|
@@ -58837,10 +58901,12 @@ var Chat = class {
|
|
|
58837
58901
|
this.apiKeyVerified = true;
|
|
58838
58902
|
this.syncBilling();
|
|
58839
58903
|
try {
|
|
58840
|
-
const path = saveApiKey(key, this.envPath);
|
|
58841
|
-
this.apiKeySource = `${path} (
|
|
58904
|
+
const path = saveApiKey(key, this.envPath, provider);
|
|
58905
|
+
this.apiKeySource = `${path} (${keyEnv})`;
|
|
58906
|
+
this.cacheProviderCredential();
|
|
58842
58907
|
} catch (err) {
|
|
58843
58908
|
this.apiKeySource = "this session only";
|
|
58909
|
+
this.cacheProviderCredential();
|
|
58844
58910
|
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
58911
|
}
|
|
58846
58912
|
return [`signed in \xB7 the key is saved to ${this.envPath}`];
|
|
@@ -58850,9 +58916,10 @@ var Chat = class {
|
|
|
58850
58916
|
this.invalidateAuthentication();
|
|
58851
58917
|
const source = this.apiKeySource;
|
|
58852
58918
|
const had = this.apiKey !== void 0;
|
|
58853
|
-
const removed = forgetApiKey(this.envPath);
|
|
58919
|
+
const removed = forgetApiKey(this.envPath, providerForEndpoint(this.settings.endpoint) ?? "infron");
|
|
58854
58920
|
this.apiKey = void 0;
|
|
58855
58921
|
this.apiKeySource = void 0;
|
|
58922
|
+
this.cacheProviderCredential();
|
|
58856
58923
|
this.apiKeyVerified = false;
|
|
58857
58924
|
this.billing.configure(this.settings.endpoint);
|
|
58858
58925
|
if (!had && !removed) return ["no key is set"];
|
|
@@ -59261,12 +59328,7 @@ var Chat = class {
|
|
|
59261
59328
|
this.refresh();
|
|
59262
59329
|
return;
|
|
59263
59330
|
}
|
|
59264
|
-
const previousEndpoint = this.settings.endpoint;
|
|
59265
59331
|
const out = await runSlash(text, this.context());
|
|
59266
|
-
if (previousEndpoint !== this.settings.endpoint) {
|
|
59267
|
-
this.apiKeyVerified = false;
|
|
59268
|
-
this.invalidateAuthentication();
|
|
59269
|
-
}
|
|
59270
59332
|
this.syncBilling();
|
|
59271
59333
|
if (!this.quitting && !out.silent && out.lines.length > 0) {
|
|
59272
59334
|
this.screen.append(
|
|
@@ -59765,6 +59827,16 @@ ${output.slice(0, 8e3)}
|
|
|
59765
59827
|
config: () => this.configLines(),
|
|
59766
59828
|
openPanel: (tab) => this.openPanel(tab),
|
|
59767
59829
|
configure: (args) => this.configure(args),
|
|
59830
|
+
provider: (args) => this.providerCommand(args),
|
|
59831
|
+
setEndpoint: (endpoint) => {
|
|
59832
|
+
if (endpoint === this.settings.endpoint) return;
|
|
59833
|
+
const previous = this.settings.endpoint;
|
|
59834
|
+
this.settings.endpoint = endpoint;
|
|
59835
|
+
this.rebindProviderCredential(previous);
|
|
59836
|
+
this.apiKeyVerified = false;
|
|
59837
|
+
this.invalidateAuthentication();
|
|
59838
|
+
this.syncBilling();
|
|
59839
|
+
},
|
|
59768
59840
|
stats: () => statsRows(this.insights()).flatMap((r) => [`${r.label} ${r.value ?? ""}`, ...r.detail ? [` ${r.detail}`] : []]),
|
|
59769
59841
|
usage: () => [...balanceRows(this.billing.state), ...usageRows(this.insights())].flatMap((r) => [`${r.label} ${r.value ?? ""}`, ...r.detail ? [` ${r.detail}`] : []]),
|
|
59770
59842
|
themes: () => Object.entries(THEMES).map(([name, t]) => `${name.padEnd(10)} ${t.description}`),
|
|
@@ -59823,6 +59895,7 @@ ${output.slice(0, 8e3)}
|
|
|
59823
59895
|
};
|
|
59824
59896
|
}
|
|
59825
59897
|
settingSource(key) {
|
|
59898
|
+
if (key === "provider") return this.settingSource("endpoint");
|
|
59826
59899
|
return this.changedSettings.get(key) ?? this.opts.settingSources?.[key] ?? this.opts.settingsInfo?.sources[key] ?? "default";
|
|
59827
59900
|
}
|
|
59828
59901
|
rememberSetting(key, value) {
|
|
@@ -59831,6 +59904,7 @@ ${output.slice(0, 8e3)}
|
|
|
59831
59904
|
return path;
|
|
59832
59905
|
}
|
|
59833
59906
|
configValue(key) {
|
|
59907
|
+
if (key === "provider") return providerForEndpoint(this.settings.endpoint) ?? "custom";
|
|
59834
59908
|
if (key === "thinking") return String(this.screen.thinkingShown);
|
|
59835
59909
|
if (key === "verbose") return String(this.screen.verboseOutput);
|
|
59836
59910
|
return String(this.settings[key] ?? "off");
|
|
@@ -59843,17 +59917,19 @@ ${output.slice(0, 8e3)}
|
|
|
59843
59917
|
}
|
|
59844
59918
|
applyConfig(field, raw) {
|
|
59845
59919
|
const fail5 = (message2) => ({ title: "/config", error: true, lines: [message2] });
|
|
59846
|
-
if ((this.active || this.shellBusy || this.compacting) && !["thinking", "verbose", "theme"].includes(field.key)) {
|
|
59920
|
+
if ((this.active || this.settlingTask || this.shellBusy || this.compacting) && !["thinking", "verbose", "theme"].includes(field.key)) {
|
|
59847
59921
|
return fail5("Wait for the running task to finish, or close this panel and press Esc to interrupt it.");
|
|
59848
59922
|
}
|
|
59849
59923
|
let value;
|
|
59850
59924
|
let path;
|
|
59851
59925
|
try {
|
|
59852
59926
|
value = parseConfigValue(field, raw);
|
|
59927
|
+
if (field.key === "provider") return this.switchProvider(value);
|
|
59853
59928
|
path = this.rememberSetting(field.key, value);
|
|
59854
59929
|
} catch (err) {
|
|
59855
59930
|
return fail5(err instanceof Error ? err.message : String(err));
|
|
59856
59931
|
}
|
|
59932
|
+
const previousEndpoint = this.settings.endpoint;
|
|
59857
59933
|
switch (field.key) {
|
|
59858
59934
|
case "thinking":
|
|
59859
59935
|
if (this.screen.thinkingShown !== value) this.screen.toggleThinking();
|
|
@@ -59878,6 +59954,7 @@ ${output.slice(0, 8e3)}
|
|
|
59878
59954
|
break;
|
|
59879
59955
|
}
|
|
59880
59956
|
if (field.key === "endpoint") {
|
|
59957
|
+
this.rebindProviderCredential(previousEndpoint);
|
|
59881
59958
|
this.apiKeyVerified = false;
|
|
59882
59959
|
this.invalidateAuthentication();
|
|
59883
59960
|
this.syncBilling();
|
|
@@ -59891,6 +59968,66 @@ ${output.slice(0, 8e3)}
|
|
|
59891
59968
|
]
|
|
59892
59969
|
};
|
|
59893
59970
|
}
|
|
59971
|
+
get providerLabel() {
|
|
59972
|
+
const provider = providerForEndpoint(this.settings.endpoint);
|
|
59973
|
+
return provider ? PROVIDERS[provider].label : "Custom endpoint";
|
|
59974
|
+
}
|
|
59975
|
+
cacheProviderCredential() {
|
|
59976
|
+
const provider = providerForEndpoint(this.settings.endpoint);
|
|
59977
|
+
if (provider) this.providerCredentials[provider] = { apiKey: this.apiKey, source: this.apiKeySource };
|
|
59978
|
+
}
|
|
59979
|
+
rebindProviderCredential(previousEndpoint) {
|
|
59980
|
+
const previous = providerForEndpoint(previousEndpoint);
|
|
59981
|
+
const next = providerForEndpoint(this.settings.endpoint);
|
|
59982
|
+
if (previous === next) return;
|
|
59983
|
+
if (next) this.requireKey = true;
|
|
59984
|
+
if (previous !== "morphfactory" && next !== "morphfactory" && !(next && this.apiKey === void 0)) return;
|
|
59985
|
+
if (previous) this.providerCredentials[previous] = { apiKey: this.apiKey, source: this.apiKeySource };
|
|
59986
|
+
const credential = next ? this.providerCredentials[next] : void 0;
|
|
59987
|
+
this.apiKey = credential?.apiKey;
|
|
59988
|
+
this.apiKeySource = credential?.source;
|
|
59989
|
+
this.requireKey = next !== void 0;
|
|
59990
|
+
}
|
|
59991
|
+
chooseProvider() {
|
|
59992
|
+
const providers = Object.keys(PROVIDERS);
|
|
59993
|
+
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]);
|
|
59994
|
+
}
|
|
59995
|
+
switchProvider(provider) {
|
|
59996
|
+
const selected = PROVIDERS[provider];
|
|
59997
|
+
try {
|
|
59998
|
+
this.rememberSetting("model", selected.model);
|
|
59999
|
+
this.rememberSetting("endpoint", selected.endpoint);
|
|
60000
|
+
} catch (err) {
|
|
60001
|
+
return { title: "/provider", error: true, lines: [err instanceof Error ? err.message : String(err)] };
|
|
60002
|
+
}
|
|
60003
|
+
this.cacheProviderCredential();
|
|
60004
|
+
this.invalidateAuthentication();
|
|
60005
|
+
this.settings.endpoint = selected.endpoint;
|
|
60006
|
+
this.settings.model = selected.model;
|
|
60007
|
+
this.apiKey = this.providerCredentials[provider]?.apiKey;
|
|
60008
|
+
this.apiKeySource = this.providerCredentials[provider]?.source;
|
|
60009
|
+
this.apiKeyVerified = false;
|
|
60010
|
+
this.requireKey = true;
|
|
60011
|
+
this.screen.setLabel(selected.model);
|
|
60012
|
+
this.syncBilling();
|
|
60013
|
+
return { title: "/provider", lines: [
|
|
60014
|
+
`Provider: ${selected.label} \xB7 ${this.apiKey ? "API key loaded" : "no API key; use /login"}.`,
|
|
60015
|
+
`${selected.endpoint} \xB7 ${selected.model}`,
|
|
60016
|
+
"Saved defaults can be overridden by startup flags, environment or trusted project settings."
|
|
60017
|
+
] };
|
|
60018
|
+
}
|
|
60019
|
+
async providerCommand(args) {
|
|
60020
|
+
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."] };
|
|
60021
|
+
if (args && !Object.hasOwn(PROVIDERS, args)) return { title: "/provider", error: true, lines: ["Choose infron or morphfactory."] };
|
|
60022
|
+
const provider = args ? args : await this.chooseProvider();
|
|
60023
|
+
if (provider === null || this.quitting) return { title: "/provider", lines: ["Provider selection cancelled."] };
|
|
60024
|
+
const result = this.switchProvider(provider);
|
|
60025
|
+
if (!result.error && this.needsLogin) {
|
|
60026
|
+
result.lines.push(...await this.login("command"));
|
|
60027
|
+
if (this.apiKey && providerForEndpoint(this.settings.endpoint) === provider) result.lines[0] = `Provider: ${PROVIDERS[provider].label} \xB7 API key loaded.`;
|
|
60028
|
+
}
|
|
60029
|
+
return result;
|
|
60030
|
+
}
|
|
59894
60031
|
invalidateAuthentication() {
|
|
59895
60032
|
this.authGeneration++;
|
|
59896
60033
|
if (this.verifyingLogin !== null) {
|
|
@@ -59921,9 +60058,10 @@ ${output.slice(0, 8e3)}
|
|
|
59921
60058
|
}
|
|
59922
60059
|
panelView() {
|
|
59923
60060
|
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" ? [
|
|
60061
|
+
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
60062
|
{ label: "Version", value: this.opts.version },
|
|
59926
60063
|
{ label: "State", value: this.active ? "Running" : this.shellBusy ? "Shell running" : this.compacting ? "Compacting" : "Ready", tone: "good" },
|
|
60064
|
+
{ label: "Provider", value: this.providerLabel },
|
|
59927
60065
|
{ label: "Model", value: this.settings.model },
|
|
59928
60066
|
{ label: "Endpoint", value: this.settings.endpoint },
|
|
59929
60067
|
{ label: "Authentication", value: this.apiKey ? this.apiKeyVerified ? "Verified this session" : "API key loaded" : "No API key \xB7 /login" },
|
|
@@ -60053,6 +60191,7 @@ ${output.slice(0, 8e3)}
|
|
|
60053
60191
|
const s = this.settings;
|
|
60054
60192
|
const src = (key) => this.settingSource(key);
|
|
60055
60193
|
const rows = [
|
|
60194
|
+
["provider", this.providerLabel, src("endpoint")],
|
|
60056
60195
|
["model", s.model, src("model")],
|
|
60057
60196
|
["endpoint", s.endpoint, src("endpoint")],
|
|
60058
60197
|
["channel", s.channel, src("channel")],
|
|
@@ -60081,6 +60220,7 @@ ${output.slice(0, 8e3)}
|
|
|
60081
60220
|
const t = this.totals;
|
|
60082
60221
|
const fmt = (n) => n.toLocaleString("en-US");
|
|
60083
60222
|
return [
|
|
60223
|
+
`provider ${this.providerLabel}`,
|
|
60084
60224
|
`model ${s.model}`,
|
|
60085
60225
|
`endpoint ${s.endpoint}`,
|
|
60086
60226
|
`channel ${s.channel} (policy ${this.opts.channelPolicy})`,
|
|
@@ -62523,7 +62663,7 @@ function pluginConnectionUi(signal) {
|
|
|
62523
62663
|
}
|
|
62524
62664
|
|
|
62525
62665
|
// packages/cli/src/main.ts
|
|
62526
|
-
var VERSION = "0.4.
|
|
62666
|
+
var VERSION = "0.4.2";
|
|
62527
62667
|
var SHORT_FLAGS = { p: "print", c: "continue", i: "interactive", v: "verbose", h: "help" };
|
|
62528
62668
|
var BOOLEAN_FLAGS = /* @__PURE__ */ new Set([
|
|
62529
62669
|
"print",
|
|
@@ -62731,7 +62871,7 @@ var HELP = `motif ${VERSION} \u2014 a coding agent built for Motif-3 (unofficial
|
|
|
62731
62871
|
motif open the interactive session (a terminal is required)
|
|
62732
62872
|
motif "<task>" run one task and exit; add --interactive to stay
|
|
62733
62873
|
motif -p "<question>" print only the final reply, for scripts and pipes (also --print)
|
|
62734
|
-
motif login paste
|
|
62874
|
+
motif login paste the selected provider's API key; it is checked and saved to ~/.motif/.env
|
|
62735
62875
|
motif logout remove the saved key
|
|
62736
62876
|
motif doctor check the endpoint, the credentials and what the server produces
|
|
62737
62877
|
motif sessions list recorded sessions
|
|
@@ -62759,6 +62899,7 @@ var HELP = `motif ${VERSION} \u2014 a coding agent built for Motif-3 (unofficial
|
|
|
62759
62899
|
motif corpus-render render a corpus JSONL to prompt text, as the harness would
|
|
62760
62900
|
|
|
62761
62901
|
Flags
|
|
62902
|
+
--provider <id> infron | morphfactory (BETA); sets endpoint and model defaults
|
|
62762
62903
|
--endpoint <url> model server (default ${DEFAULT_ENDPOINT}; a trailing /v1 is accepted)
|
|
62763
62904
|
--model <name> model id to request (default ${DEFAULT_MODEL})
|
|
62764
62905
|
--env-file <path> read MOTIF_* settings from this file first
|
|
@@ -62787,9 +62928,11 @@ distil flags
|
|
|
62787
62928
|
--include-children also export subagent scopes
|
|
62788
62929
|
|
|
62789
62930
|
Connection
|
|
62790
|
-
The first session
|
|
62791
|
-
and saves it to ~/.motif/.env;
|
|
62792
|
-
|
|
62931
|
+
The first session offers Infron or Morphfactory (BETA), checks your API key
|
|
62932
|
+
and saves it to ~/.motif/.env; use /provider to switch inside a session.
|
|
62933
|
+
'motif login --provider morphfactory' signs in outside a session.
|
|
62934
|
+
MOTIF_API_KEY (Infron), MOTIF_MORPHFACTORY_API_KEY, MOTIF_ENDPOINT and
|
|
62935
|
+
MOTIF_MODEL are read from the environment,
|
|
62793
62936
|
then from ./.env, then from ~/.motif/.env \u2014 MOTIF_* keys only, and never into
|
|
62794
62937
|
the environment. The key is sent as a bearer token and is withheld from every
|
|
62795
62938
|
command the agent runs.
|
|
@@ -62819,13 +62962,14 @@ channel after repeated parse failures, and that move restarts the conversation
|
|
|
62819
62962
|
because the transcript formats are not interchangeable.
|
|
62820
62963
|
`;
|
|
62821
62964
|
function keyRequired(endpoint) {
|
|
62822
|
-
return endpoint
|
|
62965
|
+
return providerForEndpoint(endpoint) !== void 0;
|
|
62823
62966
|
}
|
|
62824
62967
|
async function loginAtTerminal(endpoint, model) {
|
|
62825
62968
|
const path = defaultEnvPath();
|
|
62969
|
+
const provider = providerForEndpoint(endpoint) ?? "infron";
|
|
62826
62970
|
if (process.stdin.isTTY) {
|
|
62827
62971
|
process.stdout.write(
|
|
62828
|
-
`Paste your
|
|
62972
|
+
`Paste your ${PROVIDERS[provider].label} API key. Get one at ${PROVIDERS[provider].keyPage}.
|
|
62829
62973
|
It is checked against ${endpoint}, then saved to ${path} (readable only by you).
|
|
62830
62974
|
`
|
|
62831
62975
|
);
|
|
@@ -62842,7 +62986,7 @@ It is checked against ${endpoint}, then saved to ${path} (readable only by you).
|
|
|
62842
62986
|
`);
|
|
62843
62987
|
return null;
|
|
62844
62988
|
}
|
|
62845
|
-
saveApiKey(key, path);
|
|
62989
|
+
saveApiKey(key, path, provider);
|
|
62846
62990
|
process.stdout.write(`signed in \xB7 the key is saved to ${path}
|
|
62847
62991
|
`);
|
|
62848
62992
|
const billing = new InfronBilling();
|
|
@@ -62885,12 +63029,15 @@ async function main() {
|
|
|
62885
63029
|
warn: (m) => process.stderr.write(`${m}
|
|
62886
63030
|
`)
|
|
62887
63031
|
});
|
|
63032
|
+
const provider = args.flags["provider"] === void 0 ? void 0 : flagEnum(args.flags, "provider", ["infron", "morphfactory"], "infron");
|
|
63033
|
+
const dotenvPaths = [...envFile ? [envFile] : [], ...defaultDotenvPaths()];
|
|
62888
63034
|
const connection = resolveEndpointConfig({
|
|
62889
63035
|
flags: {
|
|
63036
|
+
...provider ? { endpoint: PROVIDERS[provider].endpoint, model: PROVIDERS[provider].model } : {},
|
|
62890
63037
|
...typeof args.flags["endpoint"] === "string" ? { endpoint: args.flags["endpoint"] } : {},
|
|
62891
63038
|
...typeof args.flags["model"] === "string" ? { model: args.flags["model"] } : {}
|
|
62892
63039
|
},
|
|
62893
|
-
dotenvPaths
|
|
63040
|
+
dotenvPaths,
|
|
62894
63041
|
defaults: {
|
|
62895
63042
|
...stored.values.endpoint !== void 0 ? { endpoint: stored.values.endpoint } : {},
|
|
62896
63043
|
...stored.values.model !== void 0 ? { model: stored.values.model } : {}
|
|
@@ -62905,6 +63052,14 @@ async function main() {
|
|
|
62905
63052
|
const compactAt = stored.values.compactAt ?? 0.75;
|
|
62906
63053
|
const permissions = flagEnum(args.flags, "permissions", ["ask", "auto"], stored.values.permissions ?? "ask");
|
|
62907
63054
|
const { endpoint, model, apiKey } = connection;
|
|
63055
|
+
const providerCredentials = {};
|
|
63056
|
+
for (const id of Object.keys(PROVIDERS)) {
|
|
63057
|
+
const credentials = resolveEndpointConfig({ flags: { endpoint: PROVIDERS[id].endpoint }, dotenvPaths });
|
|
63058
|
+
providerCredentials[id] = {
|
|
63059
|
+
...credentials.apiKey !== void 0 ? { apiKey: credentials.apiKey } : {},
|
|
63060
|
+
...credentials.sources.apiKey !== void 0 ? { source: credentials.sources.apiKey } : {}
|
|
63061
|
+
};
|
|
63062
|
+
}
|
|
62908
63063
|
withholdSecrets(process.env);
|
|
62909
63064
|
let resumeFrom;
|
|
62910
63065
|
switch (args.command) {
|
|
@@ -62999,7 +63154,7 @@ async function main() {
|
|
|
62999
63154
|
}
|
|
63000
63155
|
case "logout": {
|
|
63001
63156
|
const path = defaultEnvPath();
|
|
63002
|
-
process.stdout.write(forgetApiKey(path) ? `the key was removed from ${path}
|
|
63157
|
+
process.stdout.write(forgetApiKey(path, providerForEndpoint(endpoint) ?? "infron") ? `the key was removed from ${path}
|
|
63003
63158
|
` : `no key in ${path}
|
|
63004
63159
|
`);
|
|
63005
63160
|
return 0;
|
|
@@ -63043,7 +63198,9 @@ ${"".padEnd(12)} tools: ${tools}
|
|
|
63043
63198
|
return 0;
|
|
63044
63199
|
}
|
|
63045
63200
|
case "config": {
|
|
63201
|
+
const selectedProvider = providerForEndpoint(endpoint);
|
|
63046
63202
|
const rows = [
|
|
63203
|
+
["provider", selectedProvider ? PROVIDERS[selectedProvider].label : "custom", connection.sources.endpoint],
|
|
63047
63204
|
["model", model, connection.sources.model],
|
|
63048
63205
|
["endpoint", endpoint, connection.sources.endpoint],
|
|
63049
63206
|
["channel", stored.values.channel ?? "toolcall", stored.sources.channel ?? "default"],
|
|
@@ -63286,6 +63443,8 @@ user file ${stored.userPath}${existsSync16(stored.userPath) ? "" : " (absent
|
|
|
63286
63443
|
...apiKey !== void 0 ? { apiKey } : {},
|
|
63287
63444
|
...connection.sources.apiKey !== void 0 ? { apiKeySource: connection.sources.apiKey } : {},
|
|
63288
63445
|
requireKey: keyRequired(endpoint),
|
|
63446
|
+
chooseProvider: apiKey === void 0 && connection.sources.endpoint === "default" && stored.values.endpoint === void 0,
|
|
63447
|
+
providerCredentials,
|
|
63289
63448
|
envPath: defaultEnvPath(),
|
|
63290
63449
|
offerInstall: ranFromNpx(process.argv[1]) && !commandOnPath("motif"),
|
|
63291
63450
|
skills,
|
|
@@ -63337,7 +63496,7 @@ user file ${stored.userPath}${existsSync16(stored.userPath) ? "" : " (absent
|
|
|
63337
63496
|
let sessionKey = apiKey;
|
|
63338
63497
|
if (sessionKey === void 0 && keyRequired(endpoint)) {
|
|
63339
63498
|
if (!tty) {
|
|
63340
|
-
process.stderr.write(`no API key: run 'motif login', or put
|
|
63499
|
+
process.stderr.write(`no API key: run 'motif login${providerForEndpoint(endpoint) === "morphfactory" ? " --provider morphfactory" : ""}', or put ${apiKeyEnvForEndpoint(endpoint)} in ${defaultEnvPath()}
|
|
63341
63500
|
`);
|
|
63342
63501
|
return 2;
|
|
63343
63502
|
}
|