@p-sw/brainbox 0.1.2-alpha.0 → 0.1.2-alpha.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/index.js +277 -108
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4186,7 +4186,8 @@ import { Box, Text as Text2, render } from "ink";
|
|
|
4186
4186
|
// src/ui/TextInput.tsx
|
|
4187
4187
|
import { useEffect, useState } from "react";
|
|
4188
4188
|
import { Text, useInput, useStdin } from "ink";
|
|
4189
|
-
|
|
4189
|
+
|
|
4190
|
+
// src/ui/pipedStdin.ts
|
|
4190
4191
|
var pipedBuffer = null;
|
|
4191
4192
|
var pipedSubscribers = [];
|
|
4192
4193
|
function drainPiped(stdin) {
|
|
@@ -4220,6 +4221,21 @@ function drainPiped(stdin) {
|
|
|
4220
4221
|
};
|
|
4221
4222
|
tryRead();
|
|
4222
4223
|
}
|
|
4224
|
+
function takePipedLine(stdin, onLine) {
|
|
4225
|
+
drainPiped(stdin);
|
|
4226
|
+
pipedSubscribers.push(onLine);
|
|
4227
|
+
if (pipedBuffer && pipedBuffer.length > 0) {
|
|
4228
|
+
const line = pipedBuffer.shift();
|
|
4229
|
+
if (line !== undefined)
|
|
4230
|
+
onLine(line);
|
|
4231
|
+
}
|
|
4232
|
+
return () => {
|
|
4233
|
+
pipedSubscribers = pipedSubscribers.filter((s) => s !== onLine);
|
|
4234
|
+
};
|
|
4235
|
+
}
|
|
4236
|
+
|
|
4237
|
+
// src/ui/TextInput.tsx
|
|
4238
|
+
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
4223
4239
|
function PipedInput({
|
|
4224
4240
|
prompt,
|
|
4225
4241
|
initialValue = "",
|
|
@@ -4229,16 +4245,7 @@ function PipedInput({
|
|
|
4229
4245
|
}) {
|
|
4230
4246
|
const [value] = useState(initialValue);
|
|
4231
4247
|
useEffect(() => {
|
|
4232
|
-
|
|
4233
|
-
pipedSubscribers.push(onSubmit);
|
|
4234
|
-
if (pipedBuffer && pipedBuffer.length > 0) {
|
|
4235
|
-
const line = pipedBuffer.shift();
|
|
4236
|
-
if (line !== undefined)
|
|
4237
|
-
onSubmit(line);
|
|
4238
|
-
}
|
|
4239
|
-
return () => {
|
|
4240
|
-
pipedSubscribers = pipedSubscribers.filter((s) => s !== onSubmit);
|
|
4241
|
-
};
|
|
4248
|
+
return takePipedLine(stdin, onSubmit);
|
|
4242
4249
|
}, [stdin, onSubmit]);
|
|
4243
4250
|
const shown = value.length > 0 ? value : placeholder;
|
|
4244
4251
|
return /* @__PURE__ */ jsxDEV(Text, {
|
|
@@ -4765,57 +4772,223 @@ function register7(program) {
|
|
|
4765
4772
|
}
|
|
4766
4773
|
|
|
4767
4774
|
// src/commands/onboard.tsx
|
|
4768
|
-
import { useState as
|
|
4769
|
-
import { Box as
|
|
4775
|
+
import { useState as useState5 } from "react";
|
|
4776
|
+
import { Box as Box4, Text as Text5, render as render3 } from "ink";
|
|
4770
4777
|
import chalk3 from "chalk";
|
|
4771
|
-
|
|
4778
|
+
|
|
4779
|
+
// src/ui/Select.tsx
|
|
4780
|
+
import { useEffect as useEffect2, useMemo, useState as useState4 } from "react";
|
|
4781
|
+
import { Box as Box3, Text as Text4, useInput as useInput2, useStdin as useStdin2 } from "ink";
|
|
4782
|
+
import { jsxDEV as jsxDEV4, Fragment } from "react/jsx-dev-runtime";
|
|
4783
|
+
function filterItems(items, query) {
|
|
4784
|
+
const q = query.trim().toLowerCase();
|
|
4785
|
+
if (!q)
|
|
4786
|
+
return items;
|
|
4787
|
+
return items.filter((i) => i.toLowerCase().includes(q));
|
|
4788
|
+
}
|
|
4789
|
+
function windowStart(cursor, total, limit) {
|
|
4790
|
+
if (total <= limit)
|
|
4791
|
+
return 0;
|
|
4792
|
+
return Math.max(0, Math.min(cursor - Math.floor(limit / 2), total - limit));
|
|
4793
|
+
}
|
|
4794
|
+
function resolvePiped(items, line) {
|
|
4795
|
+
if (items.includes(line))
|
|
4796
|
+
return line;
|
|
4797
|
+
const exact = items.find((i) => i.toLowerCase() === line.toLowerCase());
|
|
4798
|
+
if (exact)
|
|
4799
|
+
return exact;
|
|
4800
|
+
const filtered = filterItems(items, line);
|
|
4801
|
+
if (filtered.length === 1)
|
|
4802
|
+
return filtered[0];
|
|
4803
|
+
return;
|
|
4804
|
+
}
|
|
4805
|
+
function PipedSelect({
|
|
4806
|
+
prompt = "",
|
|
4807
|
+
items,
|
|
4808
|
+
onSelect,
|
|
4809
|
+
stdin
|
|
4810
|
+
}) {
|
|
4811
|
+
useEffect2(() => {
|
|
4812
|
+
return takePipedLine(stdin, (line) => {
|
|
4813
|
+
const match = resolvePiped(items, line.trim());
|
|
4814
|
+
if (match)
|
|
4815
|
+
onSelect(match);
|
|
4816
|
+
});
|
|
4817
|
+
}, [stdin, onSelect, items]);
|
|
4818
|
+
return /* @__PURE__ */ jsxDEV4(Box3, {
|
|
4819
|
+
flexDirection: "column",
|
|
4820
|
+
children: [
|
|
4821
|
+
/* @__PURE__ */ jsxDEV4(Text4, {
|
|
4822
|
+
children: [
|
|
4823
|
+
prompt,
|
|
4824
|
+
/* @__PURE__ */ jsxDEV4(Text4, {
|
|
4825
|
+
dimColor: true,
|
|
4826
|
+
children: "(piped)"
|
|
4827
|
+
}, undefined, false, undefined, this)
|
|
4828
|
+
]
|
|
4829
|
+
}, undefined, true, undefined, this),
|
|
4830
|
+
/* @__PURE__ */ jsxDEV4(Text4, {
|
|
4831
|
+
dimColor: true,
|
|
4832
|
+
children: [
|
|
4833
|
+
"matches (",
|
|
4834
|
+
items.length,
|
|
4835
|
+
"/",
|
|
4836
|
+
items.length,
|
|
4837
|
+
"):"
|
|
4838
|
+
]
|
|
4839
|
+
}, undefined, true, undefined, this),
|
|
4840
|
+
items.slice(0, 8).map((item) => /* @__PURE__ */ jsxDEV4(Text4, {
|
|
4841
|
+
children: [
|
|
4842
|
+
" ",
|
|
4843
|
+
item
|
|
4844
|
+
]
|
|
4845
|
+
}, item, true, undefined, this))
|
|
4846
|
+
]
|
|
4847
|
+
}, undefined, true, undefined, this);
|
|
4848
|
+
}
|
|
4849
|
+
function RawSelect({
|
|
4850
|
+
prompt = "",
|
|
4851
|
+
items,
|
|
4852
|
+
limit = 8,
|
|
4853
|
+
onSelect
|
|
4854
|
+
}) {
|
|
4855
|
+
const [query, setQuery] = useState4("");
|
|
4856
|
+
const [cursor, setCursor] = useState4(0);
|
|
4857
|
+
const filtered = useMemo(() => filterItems(items, query), [items, query]);
|
|
4858
|
+
const active = Math.min(cursor, Math.max(0, filtered.length - 1));
|
|
4859
|
+
const start = windowStart(active, filtered.length, limit);
|
|
4860
|
+
const visible = filtered.slice(start, start + limit);
|
|
4861
|
+
useInput2((input, key) => {
|
|
4862
|
+
if (key.return) {
|
|
4863
|
+
const item = filtered[active];
|
|
4864
|
+
if (item)
|
|
4865
|
+
onSelect(item);
|
|
4866
|
+
return;
|
|
4867
|
+
}
|
|
4868
|
+
if (key.upArrow) {
|
|
4869
|
+
setCursor((c) => Math.max(0, Math.min(c, filtered.length - 1) - 1));
|
|
4870
|
+
return;
|
|
4871
|
+
}
|
|
4872
|
+
if (key.downArrow) {
|
|
4873
|
+
setCursor((c) => Math.min(filtered.length - 1, Math.min(c, filtered.length - 1) + 1));
|
|
4874
|
+
return;
|
|
4875
|
+
}
|
|
4876
|
+
if (key.pageUp) {
|
|
4877
|
+
setCursor((c) => Math.max(0, Math.min(c, filtered.length - 1) - limit));
|
|
4878
|
+
return;
|
|
4879
|
+
}
|
|
4880
|
+
if (key.pageDown) {
|
|
4881
|
+
setCursor((c) => Math.min(filtered.length - 1, Math.min(c, filtered.length - 1) + limit));
|
|
4882
|
+
return;
|
|
4883
|
+
}
|
|
4884
|
+
if (key.backspace || key.delete) {
|
|
4885
|
+
setQuery((q) => q.slice(0, -1));
|
|
4886
|
+
setCursor(0);
|
|
4887
|
+
return;
|
|
4888
|
+
}
|
|
4889
|
+
if (key.ctrl && input === "c") {
|
|
4890
|
+
process.exit(130);
|
|
4891
|
+
}
|
|
4892
|
+
if (input.length > 0 && !key.ctrl && !key.meta) {
|
|
4893
|
+
setQuery((q) => q + input);
|
|
4894
|
+
setCursor(0);
|
|
4895
|
+
}
|
|
4896
|
+
});
|
|
4897
|
+
return /* @__PURE__ */ jsxDEV4(Box3, {
|
|
4898
|
+
flexDirection: "column",
|
|
4899
|
+
children: [
|
|
4900
|
+
/* @__PURE__ */ jsxDEV4(Text4, {
|
|
4901
|
+
children: [
|
|
4902
|
+
prompt,
|
|
4903
|
+
query,
|
|
4904
|
+
/* @__PURE__ */ jsxDEV4(Text4, {
|
|
4905
|
+
color: "cyan",
|
|
4906
|
+
children: "|"
|
|
4907
|
+
}, undefined, false, undefined, this)
|
|
4908
|
+
]
|
|
4909
|
+
}, undefined, true, undefined, this),
|
|
4910
|
+
/* @__PURE__ */ jsxDEV4(Text4, {
|
|
4911
|
+
dimColor: true,
|
|
4912
|
+
children: [
|
|
4913
|
+
"matches (",
|
|
4914
|
+
filtered.length,
|
|
4915
|
+
"/",
|
|
4916
|
+
items.length,
|
|
4917
|
+
") · ↑↓ · type to filter · enter"
|
|
4918
|
+
]
|
|
4919
|
+
}, undefined, true, undefined, this),
|
|
4920
|
+
filtered.length === 0 ? /* @__PURE__ */ jsxDEV4(Text4, {
|
|
4921
|
+
dimColor: true,
|
|
4922
|
+
children: " (no matches)"
|
|
4923
|
+
}, undefined, false, undefined, this) : /* @__PURE__ */ jsxDEV4(Fragment, {
|
|
4924
|
+
children: [
|
|
4925
|
+
start > 0 && /* @__PURE__ */ jsxDEV4(Text4, {
|
|
4926
|
+
dimColor: true,
|
|
4927
|
+
children: " …"
|
|
4928
|
+
}, undefined, false, undefined, this),
|
|
4929
|
+
visible.map((item, i) => {
|
|
4930
|
+
const idx = start + i;
|
|
4931
|
+
const selected = idx === active;
|
|
4932
|
+
return /* @__PURE__ */ jsxDEV4(Text4, {
|
|
4933
|
+
color: selected ? "cyan" : undefined,
|
|
4934
|
+
children: [
|
|
4935
|
+
selected ? "> " : " ",
|
|
4936
|
+
item
|
|
4937
|
+
]
|
|
4938
|
+
}, item, true, undefined, this);
|
|
4939
|
+
}),
|
|
4940
|
+
start + visible.length < filtered.length && /* @__PURE__ */ jsxDEV4(Text4, {
|
|
4941
|
+
dimColor: true,
|
|
4942
|
+
children: " …"
|
|
4943
|
+
}, undefined, false, undefined, this)
|
|
4944
|
+
]
|
|
4945
|
+
}, undefined, true, undefined, this)
|
|
4946
|
+
]
|
|
4947
|
+
}, undefined, true, undefined, this);
|
|
4948
|
+
}
|
|
4949
|
+
function Select(props) {
|
|
4950
|
+
const { isRawModeSupported, stdin } = useStdin2();
|
|
4951
|
+
if (!isRawModeSupported)
|
|
4952
|
+
return /* @__PURE__ */ jsxDEV4(PipedSelect, {
|
|
4953
|
+
...props,
|
|
4954
|
+
stdin
|
|
4955
|
+
}, undefined, false, undefined, this);
|
|
4956
|
+
return /* @__PURE__ */ jsxDEV4(RawSelect, {
|
|
4957
|
+
...props
|
|
4958
|
+
}, undefined, false, undefined, this);
|
|
4959
|
+
}
|
|
4960
|
+
|
|
4961
|
+
// src/commands/onboard.tsx
|
|
4962
|
+
import { jsxDEV as jsxDEV5 } from "react/jsx-dev-runtime";
|
|
4772
4963
|
function ProviderApp({
|
|
4773
4964
|
providers,
|
|
4774
4965
|
onDone
|
|
4775
4966
|
}) {
|
|
4776
|
-
const [stage, setStage] =
|
|
4777
|
-
const [error, setError] =
|
|
4967
|
+
const [stage, setStage] = useState5({ kind: "pick" });
|
|
4968
|
+
const [error, setError] = useState5(null);
|
|
4778
4969
|
if (stage.kind === "pick") {
|
|
4779
|
-
return /* @__PURE__ */
|
|
4970
|
+
return /* @__PURE__ */ jsxDEV5(Box4, {
|
|
4780
4971
|
flexDirection: "column",
|
|
4781
4972
|
children: [
|
|
4782
|
-
/* @__PURE__ */
|
|
4973
|
+
/* @__PURE__ */ jsxDEV5(Text5, {
|
|
4783
4974
|
children: [
|
|
4784
4975
|
chalk3.bold("Step 1/4"),
|
|
4785
4976
|
" — Choose your first provider"
|
|
4786
4977
|
]
|
|
4787
4978
|
}, undefined, true, undefined, this),
|
|
4788
|
-
/* @__PURE__ */
|
|
4979
|
+
/* @__PURE__ */ jsxDEV5(Text5, {
|
|
4789
4980
|
dimColor: true,
|
|
4790
|
-
children: "
|
|
4981
|
+
children: "↑↓ to move, type to filter, enter to select"
|
|
4791
4982
|
}, undefined, false, undefined, this),
|
|
4792
|
-
/* @__PURE__ */
|
|
4983
|
+
/* @__PURE__ */ jsxDEV5(Select, {
|
|
4793
4984
|
prompt: "provider> ",
|
|
4794
|
-
|
|
4795
|
-
|
|
4796
|
-
if (!p) {
|
|
4797
|
-
setError("Provider name is required");
|
|
4798
|
-
return;
|
|
4799
|
-
}
|
|
4800
|
-
if (!providers.includes(p)) {
|
|
4801
|
-
setError(`Unknown provider "${p}"`);
|
|
4802
|
-
return;
|
|
4803
|
-
}
|
|
4985
|
+
items: providers,
|
|
4986
|
+
onSelect: (p) => {
|
|
4804
4987
|
setError(null);
|
|
4805
4988
|
setStage({ kind: "apiKey", provider: p });
|
|
4806
4989
|
}
|
|
4807
4990
|
}, undefined, false, undefined, this),
|
|
4808
|
-
/* @__PURE__ */
|
|
4809
|
-
dimColor: true,
|
|
4810
|
-
children: [
|
|
4811
|
-
"known (",
|
|
4812
|
-
providers.length,
|
|
4813
|
-
"): ",
|
|
4814
|
-
providers.slice(0, 10).join(", "),
|
|
4815
|
-
providers.length > 10 ? "…" : ""
|
|
4816
|
-
]
|
|
4817
|
-
}, undefined, true, undefined, this),
|
|
4818
|
-
error && /* @__PURE__ */ jsxDEV4(Text4, {
|
|
4991
|
+
error && /* @__PURE__ */ jsxDEV5(Text5, {
|
|
4819
4992
|
color: "red",
|
|
4820
4993
|
children: error
|
|
4821
4994
|
}, undefined, false, undefined, this)
|
|
@@ -4824,14 +4997,14 @@ function ProviderApp({
|
|
|
4824
4997
|
}
|
|
4825
4998
|
if (stage.kind === "apiKey") {
|
|
4826
4999
|
const envName = `${stage.provider.toUpperCase().replace(/-/g, "_")}_API_KEY`;
|
|
4827
|
-
return /* @__PURE__ */
|
|
5000
|
+
return /* @__PURE__ */ jsxDEV5(Box4, {
|
|
4828
5001
|
flexDirection: "column",
|
|
4829
5002
|
children: [
|
|
4830
|
-
/* @__PURE__ */
|
|
5003
|
+
/* @__PURE__ */ jsxDEV5(Text5, {
|
|
4831
5004
|
children: [
|
|
4832
5005
|
chalk3.bold("Step 1/4"),
|
|
4833
5006
|
" — ",
|
|
4834
|
-
/* @__PURE__ */
|
|
5007
|
+
/* @__PURE__ */ jsxDEV5(Text5, {
|
|
4835
5008
|
color: "cyan",
|
|
4836
5009
|
children: stage.provider
|
|
4837
5010
|
}, undefined, false, undefined, this),
|
|
@@ -4839,7 +5012,7 @@ function ProviderApp({
|
|
|
4839
5012
|
"api key"
|
|
4840
5013
|
]
|
|
4841
5014
|
}, undefined, true, undefined, this),
|
|
4842
|
-
/* @__PURE__ */
|
|
5015
|
+
/* @__PURE__ */ jsxDEV5(Text5, {
|
|
4843
5016
|
dimColor: true,
|
|
4844
5017
|
children: [
|
|
4845
5018
|
"(blank reuses $",
|
|
@@ -4847,7 +5020,7 @@ function ProviderApp({
|
|
|
4847
5020
|
" from env)"
|
|
4848
5021
|
]
|
|
4849
5022
|
}, undefined, true, undefined, this),
|
|
4850
|
-
/* @__PURE__ */
|
|
5023
|
+
/* @__PURE__ */ jsxDEV5(TextInput, {
|
|
4851
5024
|
prompt: "apiKey> ",
|
|
4852
5025
|
onSubmit: (raw) => {
|
|
4853
5026
|
const apiKey = raw.trim() || (process.env[envName] ?? "");
|
|
@@ -4871,7 +5044,7 @@ function ProviderApp({
|
|
|
4871
5044
|
});
|
|
4872
5045
|
}
|
|
4873
5046
|
}, undefined, false, undefined, this),
|
|
4874
|
-
error && /* @__PURE__ */
|
|
5047
|
+
error && /* @__PURE__ */ jsxDEV5(Text5, {
|
|
4875
5048
|
color: "red",
|
|
4876
5049
|
children: error
|
|
4877
5050
|
}, undefined, false, undefined, this)
|
|
@@ -4882,28 +5055,28 @@ function ProviderApp({
|
|
|
4882
5055
|
if (!nextField) {
|
|
4883
5056
|
setProviderAuth(stage.provider, stage.values);
|
|
4884
5057
|
logger.success(`Saved ${stage.provider} to auth.yaml`);
|
|
4885
|
-
return /* @__PURE__ */
|
|
5058
|
+
return /* @__PURE__ */ jsxDEV5(Text5, {
|
|
4886
5059
|
children: "Continuing…"
|
|
4887
5060
|
}, undefined, false, undefined, this);
|
|
4888
5061
|
}
|
|
4889
|
-
return /* @__PURE__ */
|
|
5062
|
+
return /* @__PURE__ */ jsxDEV5(Box4, {
|
|
4890
5063
|
flexDirection: "column",
|
|
4891
5064
|
children: [
|
|
4892
|
-
/* @__PURE__ */
|
|
5065
|
+
/* @__PURE__ */ jsxDEV5(Text5, {
|
|
4893
5066
|
children: [
|
|
4894
5067
|
chalk3.bold("Step 1/4"),
|
|
4895
5068
|
" — ",
|
|
4896
5069
|
stage.provider,
|
|
4897
5070
|
" extra:",
|
|
4898
5071
|
" ",
|
|
4899
|
-
/* @__PURE__ */
|
|
5072
|
+
/* @__PURE__ */ jsxDEV5(Text5, {
|
|
4900
5073
|
color: "cyan",
|
|
4901
5074
|
children: nextField
|
|
4902
5075
|
}, undefined, false, undefined, this),
|
|
4903
5076
|
" (blank to skip)"
|
|
4904
5077
|
]
|
|
4905
5078
|
}, undefined, true, undefined, this),
|
|
4906
|
-
/* @__PURE__ */
|
|
5079
|
+
/* @__PURE__ */ jsxDEV5(TextInput, {
|
|
4907
5080
|
prompt: `${nextField}> `,
|
|
4908
5081
|
onSubmit: (raw) => {
|
|
4909
5082
|
const value = raw.trim();
|
|
@@ -4926,21 +5099,21 @@ function ModelApp2({
|
|
|
4926
5099
|
provider,
|
|
4927
5100
|
onDone
|
|
4928
5101
|
}) {
|
|
4929
|
-
const [error, setError] =
|
|
4930
|
-
return /* @__PURE__ */
|
|
5102
|
+
const [error, setError] = useState5(null);
|
|
5103
|
+
return /* @__PURE__ */ jsxDEV5(Box4, {
|
|
4931
5104
|
flexDirection: "column",
|
|
4932
5105
|
children: [
|
|
4933
|
-
/* @__PURE__ */
|
|
5106
|
+
/* @__PURE__ */ jsxDEV5(Text5, {
|
|
4934
5107
|
children: [
|
|
4935
5108
|
chalk3.bold("Step 1/4"),
|
|
4936
5109
|
" — Default model (both slots)"
|
|
4937
5110
|
]
|
|
4938
5111
|
}, undefined, true, undefined, this),
|
|
4939
|
-
/* @__PURE__ */
|
|
5112
|
+
/* @__PURE__ */ jsxDEV5(Text5, {
|
|
4940
5113
|
dimColor: true,
|
|
4941
5114
|
children: [
|
|
4942
5115
|
"e.g. ",
|
|
4943
|
-
/* @__PURE__ */
|
|
5116
|
+
/* @__PURE__ */ jsxDEV5(Text5, {
|
|
4944
5117
|
color: "cyan",
|
|
4945
5118
|
children: [
|
|
4946
5119
|
provider,
|
|
@@ -4948,13 +5121,13 @@ function ModelApp2({
|
|
|
4948
5121
|
]
|
|
4949
5122
|
}, undefined, true, undefined, this),
|
|
4950
5123
|
"model-name — fine-tune later with ",
|
|
4951
|
-
/* @__PURE__ */
|
|
5124
|
+
/* @__PURE__ */ jsxDEV5(Text5, {
|
|
4952
5125
|
color: "cyan",
|
|
4953
5126
|
children: "brainbox model"
|
|
4954
5127
|
}, undefined, false, undefined, this)
|
|
4955
5128
|
]
|
|
4956
5129
|
}, undefined, true, undefined, this),
|
|
4957
|
-
/* @__PURE__ */
|
|
5130
|
+
/* @__PURE__ */ jsxDEV5(TextInput, {
|
|
4958
5131
|
prompt: `${provider}/model> `,
|
|
4959
5132
|
onSubmit: (raw) => {
|
|
4960
5133
|
const value = raw.trim();
|
|
@@ -4972,7 +5145,7 @@ function ModelApp2({
|
|
|
4972
5145
|
onDone();
|
|
4973
5146
|
}
|
|
4974
5147
|
}, undefined, false, undefined, this),
|
|
4975
|
-
error && /* @__PURE__ */
|
|
5148
|
+
error && /* @__PURE__ */ jsxDEV5(Text5, {
|
|
4976
5149
|
color: "red",
|
|
4977
5150
|
children: error
|
|
4978
5151
|
}, undefined, false, undefined, this)
|
|
@@ -4982,21 +5155,21 @@ function ModelApp2({
|
|
|
4982
5155
|
function SuperMemoryApp({
|
|
4983
5156
|
onDone
|
|
4984
5157
|
}) {
|
|
4985
|
-
const [error, setError] =
|
|
4986
|
-
return /* @__PURE__ */
|
|
5158
|
+
const [error, setError] = useState5(null);
|
|
5159
|
+
return /* @__PURE__ */ jsxDEV5(Box4, {
|
|
4987
5160
|
flexDirection: "column",
|
|
4988
5161
|
children: [
|
|
4989
|
-
/* @__PURE__ */
|
|
5162
|
+
/* @__PURE__ */ jsxDEV5(Text5, {
|
|
4990
5163
|
children: [
|
|
4991
5164
|
chalk3.bold("Step 2/4"),
|
|
4992
5165
|
" — Supermemory API key"
|
|
4993
5166
|
]
|
|
4994
5167
|
}, undefined, true, undefined, this),
|
|
4995
|
-
/* @__PURE__ */
|
|
5168
|
+
/* @__PURE__ */ jsxDEV5(Text5, {
|
|
4996
5169
|
dimColor: true,
|
|
4997
5170
|
children: "powers each brain's long-term memory. Blank reuses $SUPERMEMORY_API_KEY from env."
|
|
4998
5171
|
}, undefined, false, undefined, this),
|
|
4999
|
-
/* @__PURE__ */
|
|
5172
|
+
/* @__PURE__ */ jsxDEV5(TextInput, {
|
|
5000
5173
|
prompt: "supermemory apiKey> ",
|
|
5001
5174
|
onSubmit: (raw) => {
|
|
5002
5175
|
const key = raw.trim() || (process.env["SUPERMEMORY_API_KEY"] ?? "");
|
|
@@ -5009,7 +5182,7 @@ function SuperMemoryApp({
|
|
|
5009
5182
|
onDone();
|
|
5010
5183
|
}
|
|
5011
5184
|
}, undefined, false, undefined, this),
|
|
5012
|
-
error && /* @__PURE__ */
|
|
5185
|
+
error && /* @__PURE__ */ jsxDEV5(Text5, {
|
|
5013
5186
|
color: "red",
|
|
5014
5187
|
children: error
|
|
5015
5188
|
}, undefined, false, undefined, this)
|
|
@@ -5019,23 +5192,23 @@ function SuperMemoryApp({
|
|
|
5019
5192
|
function BrainApp({
|
|
5020
5193
|
onDone
|
|
5021
5194
|
}) {
|
|
5022
|
-
const [stage, setStage] =
|
|
5023
|
-
const [error, setError] =
|
|
5195
|
+
const [stage, setStage] = useState5({ kind: "name" });
|
|
5196
|
+
const [error, setError] = useState5(null);
|
|
5024
5197
|
if (stage.kind === "name") {
|
|
5025
|
-
return /* @__PURE__ */
|
|
5198
|
+
return /* @__PURE__ */ jsxDEV5(Box4, {
|
|
5026
5199
|
flexDirection: "column",
|
|
5027
5200
|
children: [
|
|
5028
|
-
/* @__PURE__ */
|
|
5201
|
+
/* @__PURE__ */ jsxDEV5(Text5, {
|
|
5029
5202
|
children: [
|
|
5030
5203
|
chalk3.bold("Step 3/4"),
|
|
5031
5204
|
" — Brain name"
|
|
5032
5205
|
]
|
|
5033
5206
|
}, undefined, true, undefined, this),
|
|
5034
|
-
/* @__PURE__ */
|
|
5207
|
+
/* @__PURE__ */ jsxDEV5(Text5, {
|
|
5035
5208
|
dimColor: true,
|
|
5036
5209
|
children: "The display name your channel will see"
|
|
5037
5210
|
}, undefined, false, undefined, this),
|
|
5038
|
-
/* @__PURE__ */
|
|
5211
|
+
/* @__PURE__ */ jsxDEV5(TextInput, {
|
|
5039
5212
|
prompt: "name> ",
|
|
5040
5213
|
onSubmit: (raw) => {
|
|
5041
5214
|
const v = raw.trim();
|
|
@@ -5047,32 +5220,32 @@ function BrainApp({
|
|
|
5047
5220
|
setStage({ kind: "seed", displayName: v });
|
|
5048
5221
|
}
|
|
5049
5222
|
}, undefined, false, undefined, this),
|
|
5050
|
-
error && /* @__PURE__ */
|
|
5223
|
+
error && /* @__PURE__ */ jsxDEV5(Text5, {
|
|
5051
5224
|
color: "red",
|
|
5052
5225
|
children: error
|
|
5053
5226
|
}, undefined, false, undefined, this)
|
|
5054
5227
|
]
|
|
5055
5228
|
}, undefined, true, undefined, this);
|
|
5056
5229
|
}
|
|
5057
|
-
return /* @__PURE__ */
|
|
5230
|
+
return /* @__PURE__ */ jsxDEV5(Box4, {
|
|
5058
5231
|
flexDirection: "column",
|
|
5059
5232
|
children: [
|
|
5060
|
-
/* @__PURE__ */
|
|
5233
|
+
/* @__PURE__ */ jsxDEV5(Text5, {
|
|
5061
5234
|
children: [
|
|
5062
5235
|
chalk3.bold("Step 3/4"),
|
|
5063
5236
|
" — Seed for",
|
|
5064
5237
|
" ",
|
|
5065
|
-
/* @__PURE__ */
|
|
5238
|
+
/* @__PURE__ */ jsxDEV5(Text5, {
|
|
5066
5239
|
color: "cyan",
|
|
5067
5240
|
children: stage.displayName
|
|
5068
5241
|
}, undefined, false, undefined, this)
|
|
5069
5242
|
]
|
|
5070
5243
|
}, undefined, true, undefined, this),
|
|
5071
|
-
/* @__PURE__ */
|
|
5244
|
+
/* @__PURE__ */ jsxDEV5(Text5, {
|
|
5072
5245
|
dimColor: true,
|
|
5073
5246
|
children: "One sentence about who they are. The model will expand it."
|
|
5074
5247
|
}, undefined, false, undefined, this),
|
|
5075
|
-
/* @__PURE__ */
|
|
5248
|
+
/* @__PURE__ */ jsxDEV5(TextInput, {
|
|
5076
5249
|
prompt: "seed> ",
|
|
5077
5250
|
onSubmit: async (raw) => {
|
|
5078
5251
|
const seed = raw.trim();
|
|
@@ -5094,7 +5267,7 @@ function BrainApp({
|
|
|
5094
5267
|
onDone({ brainId: result.brainId, displayName: stage.displayName });
|
|
5095
5268
|
}
|
|
5096
5269
|
}, undefined, false, undefined, this),
|
|
5097
|
-
error && /* @__PURE__ */
|
|
5270
|
+
error && /* @__PURE__ */ jsxDEV5(Text5, {
|
|
5098
5271
|
color: "red",
|
|
5099
5272
|
children: error
|
|
5100
5273
|
}, undefined, false, undefined, this)
|
|
@@ -5106,45 +5279,41 @@ function ChannelApp({
|
|
|
5106
5279
|
displayName,
|
|
5107
5280
|
onDone
|
|
5108
5281
|
}) {
|
|
5109
|
-
const [stage, setStage] =
|
|
5110
|
-
const [error, setError] =
|
|
5282
|
+
const [stage, setStage] = useState5({ kind: "kind" });
|
|
5283
|
+
const [error, setError] = useState5(null);
|
|
5111
5284
|
if (stage.kind === "kind") {
|
|
5112
|
-
return /* @__PURE__ */
|
|
5285
|
+
return /* @__PURE__ */ jsxDEV5(Box4, {
|
|
5113
5286
|
flexDirection: "column",
|
|
5114
5287
|
children: [
|
|
5115
|
-
/* @__PURE__ */
|
|
5288
|
+
/* @__PURE__ */ jsxDEV5(Text5, {
|
|
5116
5289
|
children: [
|
|
5117
5290
|
chalk3.bold("Step 4/4"),
|
|
5118
5291
|
" — Channel for",
|
|
5119
5292
|
" ",
|
|
5120
|
-
/* @__PURE__ */
|
|
5293
|
+
/* @__PURE__ */ jsxDEV5(Text5, {
|
|
5121
5294
|
color: "cyan",
|
|
5122
5295
|
children: displayName
|
|
5123
5296
|
}, undefined, false, undefined, this)
|
|
5124
5297
|
]
|
|
5125
5298
|
}, undefined, true, undefined, this),
|
|
5126
|
-
/* @__PURE__ */
|
|
5299
|
+
/* @__PURE__ */ jsxDEV5(Text5, {
|
|
5127
5300
|
dimColor: true,
|
|
5128
|
-
children: "
|
|
5301
|
+
children: "↑↓ to move, type to filter, enter to select"
|
|
5129
5302
|
}, undefined, false, undefined, this),
|
|
5130
|
-
/* @__PURE__ */
|
|
5303
|
+
/* @__PURE__ */ jsxDEV5(Select, {
|
|
5131
5304
|
prompt: "channel> ",
|
|
5132
|
-
|
|
5133
|
-
|
|
5305
|
+
items: ["discord", "telegram", "skip"],
|
|
5306
|
+
onSelect: (v) => {
|
|
5134
5307
|
if (v === "skip") {
|
|
5135
5308
|
logger.info("Skipped channel setup.");
|
|
5136
5309
|
onDone();
|
|
5137
5310
|
return;
|
|
5138
5311
|
}
|
|
5139
|
-
if (v !== "discord" && v !== "telegram") {
|
|
5140
|
-
setError(`Expected "discord", "telegram", or "skip"`);
|
|
5141
|
-
return;
|
|
5142
|
-
}
|
|
5143
5312
|
setError(null);
|
|
5144
5313
|
setStage({ kind: "token", kind_: v });
|
|
5145
5314
|
}
|
|
5146
5315
|
}, undefined, false, undefined, this),
|
|
5147
|
-
error && /* @__PURE__ */
|
|
5316
|
+
error && /* @__PURE__ */ jsxDEV5(Text5, {
|
|
5148
5317
|
color: "red",
|
|
5149
5318
|
children: error
|
|
5150
5319
|
}, undefined, false, undefined, this)
|
|
@@ -5152,10 +5321,10 @@ function ChannelApp({
|
|
|
5152
5321
|
}, undefined, true, undefined, this);
|
|
5153
5322
|
}
|
|
5154
5323
|
if (stage.kind === "token") {
|
|
5155
|
-
return /* @__PURE__ */
|
|
5324
|
+
return /* @__PURE__ */ jsxDEV5(Box4, {
|
|
5156
5325
|
flexDirection: "column",
|
|
5157
5326
|
children: [
|
|
5158
|
-
/* @__PURE__ */
|
|
5327
|
+
/* @__PURE__ */ jsxDEV5(Text5, {
|
|
5159
5328
|
children: [
|
|
5160
5329
|
chalk3.bold("Step 4/4"),
|
|
5161
5330
|
" — ",
|
|
@@ -5163,7 +5332,7 @@ function ChannelApp({
|
|
|
5163
5332
|
" bot token"
|
|
5164
5333
|
]
|
|
5165
5334
|
}, undefined, true, undefined, this),
|
|
5166
|
-
/* @__PURE__ */
|
|
5335
|
+
/* @__PURE__ */ jsxDEV5(TextInput, {
|
|
5167
5336
|
prompt: "token> ",
|
|
5168
5337
|
onSubmit: (raw) => {
|
|
5169
5338
|
const token = raw.trim();
|
|
@@ -5175,17 +5344,17 @@ function ChannelApp({
|
|
|
5175
5344
|
setStage({ kind: "target", kind_: stage.kind_, token });
|
|
5176
5345
|
}
|
|
5177
5346
|
}, undefined, false, undefined, this),
|
|
5178
|
-
error && /* @__PURE__ */
|
|
5347
|
+
error && /* @__PURE__ */ jsxDEV5(Text5, {
|
|
5179
5348
|
color: "red",
|
|
5180
5349
|
children: error
|
|
5181
5350
|
}, undefined, false, undefined, this)
|
|
5182
5351
|
]
|
|
5183
5352
|
}, undefined, true, undefined, this);
|
|
5184
5353
|
}
|
|
5185
|
-
return /* @__PURE__ */
|
|
5354
|
+
return /* @__PURE__ */ jsxDEV5(Box4, {
|
|
5186
5355
|
flexDirection: "column",
|
|
5187
5356
|
children: [
|
|
5188
|
-
/* @__PURE__ */
|
|
5357
|
+
/* @__PURE__ */ jsxDEV5(Text5, {
|
|
5189
5358
|
children: [
|
|
5190
5359
|
chalk3.bold("Step 4/4"),
|
|
5191
5360
|
" — Optional",
|
|
@@ -5194,7 +5363,7 @@ function ChannelApp({
|
|
|
5194
5363
|
" (blank = pair later)"
|
|
5195
5364
|
]
|
|
5196
5365
|
}, undefined, true, undefined, this),
|
|
5197
|
-
/* @__PURE__ */
|
|
5366
|
+
/* @__PURE__ */ jsxDEV5(TextInput, {
|
|
5198
5367
|
prompt: `${stage.kind_ === "discord" ? "channelId" : "chatId"}> `,
|
|
5199
5368
|
onSubmit: async (raw) => {
|
|
5200
5369
|
const target = raw.trim();
|
|
@@ -5229,7 +5398,7 @@ function ChannelApp({
|
|
|
5229
5398
|
onDone();
|
|
5230
5399
|
}
|
|
5231
5400
|
}, undefined, false, undefined, this),
|
|
5232
|
-
error && /* @__PURE__ */
|
|
5401
|
+
error && /* @__PURE__ */ jsxDEV5(Text5, {
|
|
5233
5402
|
color: "red",
|
|
5234
5403
|
children: error
|
|
5235
5404
|
}, undefined, false, undefined, this)
|
|
@@ -5240,25 +5409,25 @@ async function runOnboard() {
|
|
|
5240
5409
|
logger.info(`Welcome — let's get ${chalk3.bold("brainbox")} ready.`);
|
|
5241
5410
|
const providers = listProviderNames().slice().sort();
|
|
5242
5411
|
const { promise, resolve: resolve2 } = Promise.withResolvers();
|
|
5243
|
-
let active = render3(/* @__PURE__ */
|
|
5412
|
+
let active = render3(/* @__PURE__ */ jsxDEV5(ProviderApp, {
|
|
5244
5413
|
providers,
|
|
5245
5414
|
onDone: (p) => {
|
|
5246
5415
|
active.unmount();
|
|
5247
|
-
active = render3(/* @__PURE__ */
|
|
5416
|
+
active = render3(/* @__PURE__ */ jsxDEV5(ModelApp2, {
|
|
5248
5417
|
provider: p.provider,
|
|
5249
5418
|
onDone: () => {
|
|
5250
5419
|
active.unmount();
|
|
5251
|
-
active = render3(/* @__PURE__ */
|
|
5420
|
+
active = render3(/* @__PURE__ */ jsxDEV5(SuperMemoryApp, {
|
|
5252
5421
|
onDone: () => {
|
|
5253
5422
|
active.unmount();
|
|
5254
|
-
active = render3(/* @__PURE__ */
|
|
5423
|
+
active = render3(/* @__PURE__ */ jsxDEV5(BrainApp, {
|
|
5255
5424
|
onDone: (b) => {
|
|
5256
5425
|
active.unmount();
|
|
5257
5426
|
if (!b.brainId) {
|
|
5258
5427
|
resolve2();
|
|
5259
5428
|
return;
|
|
5260
5429
|
}
|
|
5261
|
-
active = render3(/* @__PURE__ */
|
|
5430
|
+
active = render3(/* @__PURE__ */ jsxDEV5(ChannelApp, {
|
|
5262
5431
|
brainId: b.brainId,
|
|
5263
5432
|
displayName: b.displayName,
|
|
5264
5433
|
onDone: () => {
|